1/* eslint-disable */ 2;(function() { 3 4 if (typeof window.BX === 'function') 5 { 6 return; 7 } 8 9/** 10 * Babel external helpers 11 * (c) 2018 Babel 12 * @license MIT 13 */ 14(function (global) { 15 var babelHelpers = global.babelHelpers = {}; 16 17 function _typeof(obj) { 18 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { 19 babelHelpers.typeof = _typeof = function (obj) { 20 return typeof obj; 21 }; 22 } else { 23 babelHelpers.typeof = _typeof = function (obj) { 24 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; 25 }; 26 } 27 28 return _typeof(obj); 29 } 30 31 babelHelpers.typeof = _typeof; 32 var REACT_ELEMENT_TYPE; 33 34 function _createRawReactElement(type, props, key, children) { 35 if (!REACT_ELEMENT_TYPE) { 36 REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for && Symbol.for("react.element") || 0xeac7; 37 } 38 39 var defaultProps = type && type.defaultProps; 40 var childrenLength = arguments.length - 3; 41 42 if (!props && childrenLength !== 0) { 43 props = { 44 children: void 0 45 }; 46 } 47 48 if (props && defaultProps) { 49 for (var propName in defaultProps) { 50 if (props[propName] === void 0) { 51 props[propName] = defaultProps[propName]; 52 } 53 } 54 } else if (!props) { 55 props = defaultProps || {}; 56 } 57 58 if (childrenLength === 1) { 59 props.children = children; 60 } else if (childrenLength > 1) { 61 var childArray = new Array(childrenLength); 62 63 for (var i = 0; i < childrenLength; i++) { 64 childArray[i] = arguments[i + 3]; 65 } 66 67 props.children = childArray; 68 } 69 70 return { 71 $$typeof: REACT_ELEMENT_TYPE, 72 type: type, 73 key: key === undefined ? null : '' + key, 74 ref: null, 75 props: props, 76 _owner: null 77 }; 78 } 79 80 babelHelpers.jsx = _createRawReactElement; 81 82 function _asyncIterator(iterable) { 83 var method; 84 85 if (typeof Symbol === "function") { 86 if (Symbol.asyncIterator) { 87 method = iterable[Symbol.asyncIterator]; 88 if (method != null) return method.call(iterable); 89 } 90 91 if (Symbol.iterator) { 92 method = iterable[Symbol.iterator]; 93 if (method != null) return method.call(iterable); 94 } 95 } 96 97 throw new TypeError("Object is not async iterable"); 98 } 99 100 babelHelpers.asyncIterator = _asyncIterator; 101 102 function _AwaitValue(value) { 103 this.wrapped = value; 104 } 105 106 babelHelpers.AwaitValue = _AwaitValue; 107 108 function AsyncGenerator(gen) { 109 var front, back; 110 111 function send(key, arg) { 112 return new Promise(function (resolve, reject) { 113 var request = { 114 key: key, 115 arg: arg, 116 resolve: resolve, 117 reject: reject, 118 next: null 119 }; 120 121 if (back) { 122 back = back.next = request; 123 } else { 124 front = back = request; 125 resume(key, arg); 126 } 127 }); 128 } 129 130 function resume(key, arg) { 131 try { 132 var result = gen[key](arg); 133 var value = result.value; 134 var wrappedAwait = value instanceof babelHelpers.AwaitValue; 135 Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { 136 if (wrappedAwait) { 137 resume("next", arg); 138 return; 139 } 140 141 settle(result.done ? "return" : "normal", arg); 142 }, function (err) { 143 resume("throw", err); 144 }); 145 } catch (err) { 146 settle("throw", err); 147 } 148 } 149 150 function settle(type, value) { 151 switch (type) { 152 case "return": 153 front.resolve({ 154 value: value, 155 done: true 156 }); 157 break; 158 159 case "throw": 160 front.reject(value); 161 break; 162 163 default: 164 front.resolve({ 165 value: value, 166 done: false 167 }); 168 break; 169 } 170 171 front = front.next; 172 173 if (front) { 174 resume(front.key, front.arg); 175 } else { 176 back = null; 177 } 178 } 179 180 this._invoke = send; 181 182 if (typeof gen.return !== "function") { 183 this.return = undefined; 184 } 185 } 186 187 if (typeof Symbol === "function" && Symbol.asyncIterator) { 188 AsyncGenerator.prototype[Symbol.asyncIterator] = function () { 189 return this; 190 }; 191 } 192 193 AsyncGenerator.prototype.next = function (arg) { 194 return this._invoke("next", arg); 195 }; 196 197 AsyncGenerator.prototype.throw = function (arg) { 198 return this._invoke("throw", arg); 199 }; 200 201 AsyncGenerator.prototype.return = function (arg) { 202 return this._invoke("return", arg); 203 }; 204 205 babelHelpers.AsyncGenerator = AsyncGenerator; 206 207 function _wrapAsyncGenerator(fn) { 208 return function () { 209 return new babelHelpers.AsyncGenerator(fn.apply(this, arguments)); 210 }; 211 } 212 213 babelHelpers.wrapAsyncGenerator = _wrapAsyncGenerator; 214 215 function _awaitAsyncGenerator(value) { 216 return new babelHelpers.AwaitValue(value); 217 } 218 219 babelHelpers.awaitAsyncGenerator = _awaitAsyncGenerator; 220 221 function _asyncGeneratorDelegate(inner, awaitWrap) { 222 var iter = {}, 223 waiting = false;
224 225 function pump(key, value) { 226 waiting = true; 227 value = new Promise(function (resolve) { 228 resolve(inner[key](value)); 229 }); 230 return { 231 done: false, 232 value: awaitWrap(value) 233 }; 234 } 235 236 ; 237 238 if (typeof Symbol === "function" && Symbol.iterator) { 239 iter[Symbol.iterator] = function () { 240 return this; 241 }; 242 } 243 244 iter.next = function (value) { 245 if (waiting) { 246 waiting = false; 247 return value; 248 } 249 250 return pump("next", value); 251 }; 252 253 if (typeof inner.throw === "function") { 254 iter.throw = function (value) { 255 if (waiting) { 256 waiting = false; 257 throw value; 258 } 259 260 return pump("throw", value); 261 }; 262 } 263 264 if (typeof inner.return === "function") { 265 iter.return = function (value) { 266 return pump("return", value); 267 }; 268 } 269 270 return iter; 271 } 272 273 babelHelpers.asyncGeneratorDelegate = _asyncGeneratorDelegate; 274 275 function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { 276 try { 277 var info = gen[key](arg); 278 var value = info.value; 279 } catch (error) { 280 reject(error); 281 return; 282 } 283 284 if (info.done) { 285 resolve(value); 286 } else { 287 Promise.resolve(value).then(_next, _throw); 288 } 289 } 290 291 function _asyncToGenerator(fn) { 292 return function () { 293 var self = this, 294 args = arguments; 295 return new Promise(function (resolve, reject) { 296 var gen = fn.apply(self, args); 297 298 function _next(value) { 299 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); 300 } 301 302 function _throw(err) { 303 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); 304 } 305 306 _next(undefined); 307 }); 308 }; 309 } 310 311 babelHelpers.asyncToGenerator = _asyncToGenerator; 312 313 function _classCallCheck(instance, Constructor) { 314 if (!(instance instanceof Constructor)) { 315 throw new TypeError("Cannot call a class as a function"); 316 } 317 } 318 319 babelHelpers.classCallCheck = _classCallCheck; 320 321 function _defineProperties(target, props) { 322 for (var i = 0; i < props.length; i++) { 323 var descriptor = props[i]; 324 descriptor.enumerable = descriptor.enumerable || false; 325 descriptor.configurable = true; 326 if ("value" in descriptor) descriptor.writable = true; 327 Object.defineProperty(target, descriptor.key, descriptor); 328 } 329 } 330 331 function _createClass(Constructor, protoProps, staticProps) { 332 if (protoProps) _defineProperties(Constructor.prototype, protoProps); 333 if (staticProps) _defineProperties(Constructor, staticProps); 334 return Constructor; 335 } 336 337 babelHelpers.createClass = _createClass; 338 339 function _defineEnumerableProperties(obj, descs) { 340 for (var key in descs) { 341 var desc = descs[key]; 342 desc.configurable = desc.enumerable = true; 343 if ("value" in desc) desc.writable = true; 344 Object.defineProperty(obj, key, desc); 345 } 346 347 if (Object.getOwnPropertySymbols) { 348 var objectSymbols = Object.getOwnPropertySymbols(descs); 349 350 for (var i = 0; i < objectSymbols.length; i++) { 351 var sym = objectSymbols[i]; 352 var desc = descs[sym]; 353 desc.configurable = desc.enumerable = true; 354 if ("value" in desc) desc.writable = true; 355 Object.defineProperty(obj, sym, desc); 356 } 357 } 358 359 return obj; 360 } 361 362 babelHelpers.defineEnumerableProperties = _defineEnumerableProperties; 363 364 function _defaults(obj, defaults) { 365 var keys = Object.getOwnPropertyNames(defaults); 366 367 for (var i = 0; i < keys.length; i++) { 368 var key = keys[i]; 369 var value = Object.getOwnPropertyDescriptor(defaults, key); 370 371 if (value && value.configurable && obj[key] === undefined) { 372 Object.defineProperty(obj, key, value); 373 } 374 } 375 376 return obj; 377 } 378 379 babelHelpers.defaults = _defaults; 380 381 function _defineProperty(obj, key, value) { 382 if (key in obj) { 383 Object.defineProperty(obj, key, { 384 value: value, 385 enumerable: true, 386 configurable: true, 387 writable: true 388 }); 389 } else { 390 obj[key] = value; 391 } 392 393 return obj; 394 } 395 396 babelHelpers.defineProperty = _defineProperty; 397 398 function _extends() { 399 babelHelpers.extends = _extends = Object.assign || function (target) { 400 for (var i = 1; i < arguments.length; i++) { 401 var source = arguments[i]; 402 403 for (var key in source) { 404 if (Object.prototype.hasOwnProperty.call(source, key)) { 405 target[key] = source[key]; 406 } 407 } 408 } 409 410 return target; 411 }; 412 413 return _extends.apply(this, arguments); 414 } 415 416 babelHelpers.extends = _extends; 417 418 function _objectSpread(target) { 419 for (var i = 1; i < arguments.length; i++) { 420 var source = arguments[i] != null ? arguments[i] : {}; 421 var ownKeys = Object.keys(source); 422 423 if (typeof Object.getOwnPropertySymbols === 'function') { 424 ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { 425 return Object.getOwnPropertyDescriptor(source, sym).enumerable; 426 })); 427 } 428 429 ownKeys.forEach(function (key) { 430 babelHelpers.defineProperty(target, key, source[key]); 431 }); 432 } 433 434 return target; 435 } 436 437 babelHelpers.objectSpread = _objectSpread; 438 439 function _inherits(subClass, superClass) { 440 if (typeof superClass !== "function" && superClass !== null) { 441 throw new TypeError("Super expression must either be null or a function"); 442 } 443 444 subClass.prototype = Object.create(superClass && superClass.prototype, { 445 constructor: { 446 value: subClass, 447 writable: true, 448 configurable: true 449 } 450 }); 451 if (superClass) babelHelpers.setPrototypeOf(subClass, superClass); 452 } 453 454 babelHelpers.inherits = _inherits; 455 456 function _inheritsLoose(subClass, superClass) { 457 subClass.prototype = Object.create(superClass.prototype); 458 subClass.prototype.constructor = subClass; 459 subClass.__proto__ = superClass; 460 } 461 462 babelHelpers.inheritsLoose = _inheritsLoose; 463
464 function _getPrototypeOf(o) { 465 babelHelpers.getPrototypeOf = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { 466 return o.__proto__ || Object.getPrototypeOf(o); 467 }; 468 return _getPrototypeOf(o); 469 } 470 471 babelHelpers.getPrototypeOf = _getPrototypeOf; 472 473 function _setPrototypeOf(o, p) { 474 babelHelpers.setPrototypeOf = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { 475 o.__proto__ = p; 476 return o; 477 }; 478 479 return _setPrototypeOf(o, p); 480 } 481 482 babelHelpers.setPrototypeOf = _setPrototypeOf; 483 484 function isNativeReflectConstruct() { 485 if (typeof Reflect === "undefined" || !Reflect.construct) return false; 486 if (Reflect.construct.sham) return false; 487 if (typeof Proxy === "function") return true; 488 489 try { 490 Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); 491 return true; 492 } catch (e) { 493 return false; 494 } 495 } 496 497 function _construct(Parent, args, Class) { 498 if (isNativeReflectConstruct()) { 499 babelHelpers.construct = _construct = Reflect.construct; 500 } else { 501 babelHelpers.construct = _construct = function _construct(Parent, args, Class) { 502 var a = [null]; 503 a.push.apply(a, args); 504 var Constructor = Function.bind.apply(Parent, a); 505 var instance = new Constructor(); 506 if (Class) babelHelpers.setPrototypeOf(instance, Class.prototype); 507 return instance; 508 }; 509 } 510 511 return _construct.apply(null, arguments); 512 } 513 514 babelHelpers.construct = _construct; 515 516 function _isNativeFunction(fn) { 517 return Function.toString.call(fn).indexOf("[native code]") !== -1; 518 } 519 520 babelHelpers.isNativeFunction = _isNativeFunction; 521 522 function _wrapNativeSuper(Class) { 523 var _cache = typeof Map === "function" ? new Map() : undefined; 524 525 babelHelpers.wrapNativeSuper = _wrapNativeSuper = function _wrapNativeSuper(Class) { 526 if (Class === null || !babelHelpers.isNativeFunction(Class)) return Class; 527 528 if (typeof Class !== "function") { 529 throw new TypeError("Super expression must either be null or a function"); 530 } 531 532 if (typeof _cache !== "undefined") { 533 if (_cache.has(Class)) return _cache.get(Class); 534 535 _cache.set(Class, Wrapper); 536 } 537 538 function Wrapper() { 539 return babelHelpers.construct(Class, arguments, babelHelpers.getPrototypeOf(this).constructor); 540 } 541 542 Wrapper.prototype = Object.create(Class.prototype, { 543 constructor: { 544 value: Wrapper, 545 enumerable: false, 546 writable: true, 547 configurable: true 548 } 549 }); 550 return babelHelpers.setPrototypeOf(Wrapper, Class); 551 }; 552 553 return _wrapNativeSuper(Class); 554 } 555 556 babelHelpers.wrapNativeSuper = _wrapNativeSuper; 557 558 function _instanceof(left, right) { 559 if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { 560 return right[Symbol.hasInstance](left); 561 } else { 562 return left instanceof right; 563 } 564 } 565 566 babelHelpers.instanceof = _instanceof; 567 568 function _interopRequireDefault(obj) { 569 return obj && obj.__esModule ? obj : { 570 default: obj 571 }; 572 } 573 574 babelHelpers.interopRequireDefault = _interopRequireDefault; 575 576 function _interopRequireWildcard(obj) { 577 if (obj && obj.__esModule) { 578 return obj; 579 } else { 580 var newObj = {}; 581 582 if (obj != null) { 583 for (var key in obj) { 584 if (Object.prototype.hasOwnProperty.call(obj, key)) { 585 var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; 586 587 if (desc.get || desc.set) { 588 Object.defineProperty(newObj, key, desc); 589 } else { 590 newObj[key] = obj[key]; 591 } 592 } 593 } 594 } 595 596 newObj.default = obj; 597 return newObj; 598 } 599 } 600 601 babelHelpers.interopRequireWildcard = _interopRequireWildcard; 602 603 function _newArrowCheck(innerThis, boundThis) { 604 if (innerThis !== boundThis) { 605 throw new TypeError("Cannot instantiate an arrow function"); 606 } 607 } 608 609 babelHelpers.newArrowCheck = _newArrowCheck; 610 611 function _objectDestructuringEmpty(obj) { 612 if (obj == null) throw new TypeError("Cannot destructure undefined"); 613 } 614 615 babelHelpers.objectDestructuringEmpty = _objectDestructuringEmpty; 616 617 function _objectWithoutPropertiesLoose(source, excluded) { 618 if (source == null) return {}; 619 var target = {}; 620 var sourceKeys = Object.keys(source); 621 var key, i; 622 623 for (i = 0; i < sourceKeys.length; i++) { 624 key = sourceKeys[i]; 625 if (excluded.indexOf(key) >= 0) continue; 626 target[key] = source[key]; 627 } 628 629 return target; 630 } 631 632 babelHelpers.objectWithoutPropertiesLoose = _objectWithoutPropertiesLoose; 633 634 function _objectWithoutProperties(source, excluded) { 635 if (source == null) return {}; 636 var target = babelHelpers.objectWithoutPropertiesLoose(source, excluded); 637 var key, i; 638 639 if (Object.getOwnPropertySymbols) { 640 var sourceSymbolKeys = Object.getOwnPropertySymbols(source); 641 642 for (i = 0; i < sourceSymbolKeys.length; i++) { 643 key = sourceSymbolKeys[i]; 644 if (excluded.indexOf(key) >= 0) continue; 645 if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; 646 target[key] = source[key]; 647 } 648 } 649 650 return target; 651 } 652 653 babelHelpers.objectWithoutProperties = _objectWithoutProperties; 654 655 function _assertThisInitialized(self) { 656 if (self === void 0) { 657 throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); 658 } 659 660 return self; 661 } 662 663 babelHelpers.assertThisInitialized = _assertThisInitialized; 664 665 function _possibleConstructorReturn(self, call) { 666 if (call && (typeof call === "object" || typeof call === "function")) { 667 return call; 668 } 669 670 return babelHelpers.assertThisInitialized(self); 671 } 672 673 babelHelpers.possibleConstructorReturn = _possibleConstructorReturn; 674 675 function _superPropBase(object, property) { 676 while (!Object.prototype.hasOwnProperty.call(object, property)) { 677 object = babelHelpers.getPrototypeOf(object); 678 if (object === null) break; 679 } 680 681 return object; 682 } 683 684 babelHelpers.superPropBase = _superPropBase; 685 686 function _get(target, property, receiver) { 687 if (typeof Reflect !== "undefined" && Reflect.get) { 688 babelHelpers.get = _get = Reflect.get; 689 } else { 690 babelHelpers.get = _get = function _get(target, property, receiver) { 691 var base = babelHelpers.superPropBase(target, property); 692 if (!base) return; 693 var desc = Object.getOwnPropertyDescriptor(base, property); 694 695 if (desc.get) { 696 return desc.get.call(receiver); 697 } 698 699 return desc.value; 700 }; 701 } 702 703 return _get(target, property, receiver || target); 704 } 705 706 babelHelpers.get = _get; 707 708 function set(target, property, value, receiver) { 709 if (typeof Reflect !== "undefined" && Reflect.set) { 710 set = Reflect.set; 711 } else { 712 set = function set(target, property, value, receiver) { 713 var base = babelHelpers.superPropBase(target, property); 714 var desc; 715 716 if (base) { 717 desc = Object.getOwnPropertyDescriptor(base, property); 718 719 if (desc.set) { 720 desc.set.call(receiver, value); 721 return true; 722 } else if (!desc.writable) { 723 return false;
724 } 725 } 726 727 desc = Object.getOwnPropertyDescriptor(receiver, property); 728 729 if (desc) { 730 if (!desc.writable) { 731 return false; 732 } 733 734 desc.value = value; 735 Object.defineProperty(receiver, property, desc); 736 } else { 737 babelHelpers.defineProperty(receiver, property, value); 738 } 739 740 return true; 741 }; 742 } 743 744 return set(target, property, value, receiver); 745 } 746 747 function _set(target, property, value, receiver, isStrict) { 748 var s = set(target, property, value, receiver || target); 749 750 if (!s && isStrict) { 751 throw new Error('failed to set property'); 752 } 753 754 return value; 755 } 756 757 babelHelpers.set = _set; 758 759 function _taggedTemplateLiteral(strings, raw) { 760 if (!raw) { 761 raw = strings.slice(0); 762 } 763 764 return Object.freeze(Object.defineProperties(strings, { 765 raw: { 766 value: Object.freeze(raw) 767 } 768 })); 769 } 770 771 babelHelpers.taggedTemplateLiteral = _taggedTemplateLiteral; 772 773 function _taggedTemplateLiteralLoose(strings, raw) { 774 if (!raw) { 775 raw = strings.slice(0); 776 } 777 778 strings.raw = raw; 779 return strings; 780 } 781 782 babelHelpers.taggedTemplateLiteralLoose = _taggedTemplateLiteralLoose; 783 784 function _temporalRef(val, name) { 785 if (val === babelHelpers.temporalUndefined) { 786 throw new ReferenceError(name + " is not defined - temporal dead zone"); 787 } else { 788 return val; 789 } 790 } 791 792 babelHelpers.temporalRef = _temporalRef; 793 794 function _readOnlyError(name) { 795 throw new Error("\"" + name + "\" is read-only"); 796 } 797 798 babelHelpers.readOnlyError = _readOnlyError; 799 800 function _classNameTDZError(name) { 801 throw new Error("Class \"" + name + "\" cannot be referenced in computed property keys."); 802 } 803 804 babelHelpers.classNameTDZError = _classNameTDZError; 805 babelHelpers.temporalUndefined = {}; 806 807 function _slicedToArray(arr, i) { 808 return babelHelpers.arrayWithHoles(arr) || babelHelpers.iterableToArrayLimit(arr, i) || babelHelpers.nonIterableRest(); 809 } 810 811 babelHelpers.slicedToArray = _slicedToArray; 812 813 function _slicedToArrayLoose(arr, i) { 814 return babelHelpers.arrayWithHoles(arr) || babelHelpers.iterableToArrayLimitLoose(arr, i) || babelHelpers.nonIterableRest(); 815 } 816 817 babelHelpers.slicedToArrayLoose = _slicedToArrayLoose; 818 819 function _toArray(arr) { 820 return babelHelpers.arrayWithHoles(arr) || babelHelpers.iterableToArray(arr) || babelHelpers.nonIterableRest(); 821 } 822 823 babelHelpers.toArray = _toArray; 824 825 function _toConsumableArray(arr) { 826 return babelHelpers.arrayWithoutHoles(arr) || babelHelpers.iterableToArray(arr) || babelHelpers.nonIterableSpread(); 827 } 828 829 babelHelpers.toConsumableArray = _toConsumableArray; 830 831 function _arrayWithoutHoles(arr) { 832 if (Array.isArray(arr)) { 833 for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; 834 835 return arr2; 836 } 837 } 838 839 babelHelpers.arrayWithoutHoles = _arrayWithoutHoles; 840 841 function _arrayWithHoles(arr) { 842 if (Array.isArray(arr)) return arr; 843 } 844 845 babelHelpers.arrayWithHoles = _arrayWithHoles; 846 847 function _iterableToArray(iter) { 848 if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); 849 } 850 851 babelHelpers.iterableToArray = _iterableToArray; 852 853 function _iterableToArrayLimit(arr, i) { 854 var _arr = []; 855 var _n = true; 856 var _d = false; 857 var _e = undefined; 858 859 try { 860 for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { 861 _arr.push(_s.value); 862 863 if (i && _arr.length === i) break; 864 } 865 } catch (err) { 866 _d = true; 867 _e = err; 868 } finally { 869 try { 870 if (!_n && _i["return"] != null) _i["return"](); 871 } finally { 872 if (_d) throw _e; 873 } 874 } 875 876 return _arr; 877 } 878 879 babelHelpers.iterableToArrayLimit = _iterableToArrayLimit; 880 881 function _iterableToArrayLimitLoose(arr, i) { 882 var _arr = []; 883 884 for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { 885 _arr.push(_step.value); 886 887 if (i && _arr.length === i) break; 888 } 889 890 return _arr; 891 } 892 893 babelHelpers.iterableToArrayLimitLoose = _iterableToArrayLimitLoose; 894 895 function _nonIterableSpread() { 896 throw new TypeError("Invalid attempt to spread non-iterable instance"); 897 } 898 899 babelHelpers.nonIterableSpread = _nonIterableSpread; 900 901 function _nonIterableRest() {
902 throw new TypeError("Invalid attempt to destructure non-iterable instance"); 903 } 904 905 babelHelpers.nonIterableRest = _nonIterableRest; 906 907 function _skipFirstGeneratorNext(fn) { 908 return function () { 909 var it = fn.apply(this, arguments); 910 it.next(); 911 return it; 912 }; 913 } 914 915 babelHelpers.skipFirstGeneratorNext = _skipFirstGeneratorNext; 916 917 function _toPropertyKey(key) { 918 if (typeof key === "symbol") { 919 return key; 920 } else { 921 return String(key); 922 } 923 } 924 925 babelHelpers.toPropertyKey = _toPropertyKey; 926 927 function _initializerWarningHelper(descriptor, context) { 928 throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and set to use loose mode. ' + 'To use proposal-class-properties in spec mode with decorators, wait for ' + 'the next major version of decorators in stage 2.'); 929 } 930 931 babelHelpers.initializerWarningHelper = _initializerWarningHelper; 932 933 function _initializerDefineProperty(target, property, descriptor, context) { 934 if (!descriptor) return; 935 Object.defineProperty(target, property, { 936 enumerable: descriptor.enumerable, 937 configurable: descriptor.configurable, 938 writable: descriptor.writable, 939 value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 940 }); 941 } 942 943 babelHelpers.initializerDefineProperty = _initializerDefineProperty; 944 945 function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { 946 var desc = {}; 947 Object['ke' + 'ys'](descriptor).forEach(function (key) { 948 desc[key] = descriptor[key]; 949 }); 950 desc.enumerable = !!desc.enumerable; 951 desc.configurable = !!desc.configurable; 952 953 if ('value' in desc || desc.initializer) { 954 desc.writable = true; 955 } 956 957 desc = decorators.slice().reverse().reduce(function (desc, decorator) { 958 return decorator(target, property, desc) || desc; 959 }, desc); 960 961 if (context && desc.initializer !== void 0) { 962 desc.value = desc.initializer ? desc.initializer.call(context) : void 0; 963 desc.initializer = undefined; 964 } 965 966 if (desc.initializer === void 0) { 967 Object['define' + 'Property'](target, property, desc); 968 desc = null; 969 } 970 971 return desc; 972 } 973 974 babelHelpers.applyDecoratedDescriptor = _applyDecoratedDescriptor; 975 var id = 0; 976 977 function _classPrivateFieldKey(name) { 978 return "__private_" + id++ + "_" + name; 979 } 980 981 babelHelpers.classPrivateFieldLooseKey = _classPrivateFieldKey; 982 983 function _classPrivateFieldBase(receiver, privateKey) { 984 if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { 985 throw new TypeError("attempted to use private field on non-instance"); 986 } 987 988 return receiver; 989 } 990 991 babelHelpers.classPrivateFieldLooseBase = _classPrivateFieldBase; 992 993 function _classPrivateFieldGet(receiver, privateMap) { 994 if (!privateMap.has(receiver)) { 995 throw new TypeError("attempted to get private field on non-instance"); 996 } 997 998 return privateMap.get(receiver).value; 999 } 1000 1001 babelHelpers.classPrivateFieldGet = _classPrivateFieldGet; 1002 1003 function _classPrivateFieldSet(receiver, privateMap, value) { 1004 if (!privateMap.has(receiver)) { 1005 throw new TypeError("attempted to set private field on non-instance"); 1006 } 1007 1008 var descriptor = privateMap.get(receiver); 1009 1010 if (!descriptor.writable) { 1011 throw new TypeError("attempted to set read only private field"); 1012 } 1013 1014 descriptor.value = value; 1015 return value; 1016 } 1017 1018 babelHelpers.classPrivateFieldSet = _classPrivateFieldSet; 1019})(typeof global === "undefined" ? window : global); 1020 1021/** 1022 * Copyright (c) 2014-present, Facebook, Inc. 1023 * 1024 * This source code is licensed under the MIT license found in the 1025 * LICENSE file in the root directory of this source tree. 1026 */ 1027 1028!(function(global) { 1029 "use strict"; 1030 1031 var Op = Object.prototype; 1032 var hasOwn = Op.hasOwnProperty; 1033 var undefined; // More compressible than void 0. 1034 var $Symbol = typeof Symbol === "function" ? Symbol : {}; 1035 var iteratorSymbol = $Symbol.iterator || "@@iterator"; 1036 var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; 1037 var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; 1038 1039 // Define the runtime globally (as expected by generated code) as either 1040 // module.exports (if we're in a module) or a new, empty object. 1041 var runtime = global.regeneratorRuntime = {}; 1042 1043 function wrap(innerFn, outerFn, self, tryLocsList) { 1044 // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. 1045 var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; 1046 var generator = Object.create(protoGenerator.prototype); 1047 var context = new Context(tryLocsList || []); 1048 1049 // The ._invoke method unifies the implementations of the .next, 1050 // .throw, and .return methods. 1051 generator._invoke = makeInvokeMethod(innerFn, self, context); 1052 1053 return generator; 1054 } 1055 runtime.wrap = wrap; 1056 1057 // Try/catch helper to minimize deoptimizations. Returns a completion 1058 // record like context.tryEntries[i].completion. This interface could
vendor: 10,591 bytes, lines 1059-1352
1059 // have been (and was previously) designed to take a closure to be 1060 // invoked without arguments, but in all the cases we care about we 1061 // already have an existing method we want to call, so there's no need 1062 // to create a new function object. We can even get away with assuming 1063 // the method takes exactly one argument, since that happens to be true 1064 // in every case, so we don't have to touch the arguments object. The 1065 // only additional allocation required is the completion record, which 1066 // has a stable shape and so hopefully should be cheap to allocate. 1067 function tryCatch(fn, obj, arg) { 1068 try { 1069 return { type: "normal", arg: fn.call(obj, arg) }; 1070 } catch (err) { 1071 return { type: "throw", arg: err }; 1072 } 1073 } 1074 1075 var GenStateSuspendedStart = "suspendedStart"; 1076 var GenStateSuspendedYield = "suspendedYield"; 1077 var GenStateExecuting = "executing"; 1078 var GenStateCompleted = "completed"; 1079 1080 // Returning this object from the innerFn has the same effect as 1081 // breaking out of the dispatch switch statement. 1082 var ContinueSentinel = {}; 1083 1084 // Dummy constructor functions that we use as the .constructor and 1085 // .constructor.prototype properties for functions that return Generator 1086 // objects. For full spec compliance, you may wish to configure your 1087 // minifier not to mangle the names of these two functions. 1088 function Generator() {} 1089 function GeneratorFunction() {} 1090 function GeneratorFunctionPrototype() {} 1091 1092 // This is a polyfill for %IteratorPrototype% for environments that 1093 // don't natively support it. 1094 var IteratorPrototype = {}; 1095 IteratorPrototype[iteratorSymbol] = function () { 1096 return this; 1097 }; 1098 1099 var getProto = Object.getPrototypeOf; 1100 var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); 1101 if (NativeIteratorPrototype && 1102 NativeIteratorPrototype !== Op && 1103 hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { 1104 // This environment has a native %IteratorPrototype%; use it instead 1105 // of the polyfill. 1106 IteratorPrototype = NativeIteratorPrototype; 1107 } 1108 1109 var Gp = GeneratorFunctionPrototype.prototype = 1110 Generator.prototype = Object.create(IteratorPrototype); 1111 GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype; 1112 GeneratorFunctionPrototype.constructor = GeneratorFunction; 1113 GeneratorFunctionPrototype[toStringTagSymbol] = 1114 GeneratorFunction.displayName = "GeneratorFunction"; 1115 1116 // Helper for defining the .next, .throw, and .return methods of the 1117 // Iterator interface in terms of a single ._invoke method. 1118 function defineIteratorMethods(prototype) { 1119 ["next", "throw", "return"].forEach(function(method) { 1120 prototype[method] = function(arg) { 1121 return this._invoke(method, arg); 1122 }; 1123 }); 1124 } 1125 1126 runtime.isGeneratorFunction = function(genFun) { 1127 var ctor = typeof genFun === "function" && genFun.constructor; 1128 return ctor 1129 ? ctor === GeneratorFunction || 1130 // For the native GeneratorFunction constructor, the best we can 1131 // do is to check its .name property. 1132 (ctor.displayName || ctor.name) === "GeneratorFunction" 1133 : false; 1134 }; 1135 1136 runtime.mark = function(genFun) { 1137 if (Object.setPrototypeOf) { 1138 Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); 1139 } else { 1140 genFun.__proto__ = GeneratorFunctionPrototype; 1141 if (!(toStringTagSymbol in genFun)) { 1142 genFun[toStringTagSymbol] = "GeneratorFunction"; 1143 } 1144 } 1145 genFun.prototype = Object.create(Gp); 1146 return genFun; 1147 }; 1148 1149 // Within the body of any async function, `await x` is transformed to 1150 // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test 1151 // `hasOwn.call(value, "__await")` to determine if the yielded value is 1152 // meant to be awaited. 1153 runtime.awrap = function(arg) { 1154 return { __await: arg }; 1155 }; 1156 1157 function AsyncIterator(generator) { 1158 function invoke(method, arg, resolve, reject) { 1159 var record = tryCatch(generator[method], generator, arg); 1160 if (record.type === "throw") { 1161 reject(record.arg); 1162 } else { 1163 var result = record.arg; 1164 var value = result.value; 1165 if (value && 1166 typeof value === "object" && 1167 hasOwn.call(value, "__await")) { 1168 return Promise.resolve(value.__await).then(function(value) { 1169 invoke("next", value, resolve, reject); 1170 }, function(err) { 1171 invoke("throw", err, resolve, reject); 1172 }); 1173 } 1174 1175 return Promise.resolve(value).then(function(unwrapped) { 1176 // When a yielded Promise is resolved, its final value becomes 1177 // the .value of the Promise<{value,done}> result for the 1178 // current iteration. If the Promise is rejected, however, the 1179 // result for this iteration will be rejected with the same 1180 // reason. Note that rejections of yielded Promises are not 1181 // thrown back into the generator function, as is the case 1182 // when an awaited Promise is rejected. This difference in 1183 // behavior between yield and await is important, because it 1184 // allows the consumer to decide what to do with the yielded 1185 // rejection (swallow it and continue, manually .throw it back 1186 // into the generator, abandon iteration, whatever). With 1187 // await, by contrast, there is no opportunity to examine the 1188 // rejection reason outside the generator function, so the 1189 // only option is to throw it from the await expression, and 1190 // let the generator function handle the exception. 1191 result.value = unwrapped; 1192 resolve(result); 1193 }, reject); 1194 } 1195 } 1196 1197 var previousPromise; 1198 1199 function enqueue(method, arg) { 1200 function callInvokeWithMethodAndArg() { 1201 return new Promise(function(resolve, reject) { 1202 invoke(method, arg, resolve, reject); 1203 }); 1204 } 1205 1206 return previousPromise = 1207 // If enqueue has been called before, then we want to wait until 1208 // all previous Promises have been resolved before calling invoke, 1209 // so that results are always delivered in the correct order. If 1210 // enqueue has not been called before, then it is important to 1211 // call invoke immediately, without waiting on a callback to fire, 1212 // so that the async generator function has the opportunity to do 1213 // any necessary setup in a predictable way. This predictability 1214 // is why the Promise constructor synchronously invokes its 1215 // executor callback, and why async functions synchronously 1216 // execute code before the first await. Since we implement simple 1217 // async functions in terms of async generators, it is especially 1218 // important to get this right, even though it requires care. 1219 previousPromise ? previousPromise.then( 1220 callInvokeWithMethodAndArg, 1221 // Avoid propagating failures to Promises returned by later 1222 // invocations of the iterator. 1223 callInvokeWithMethodAndArg 1224 ) : callInvokeWithMethodAndArg(); 1225 } 1226 1227 // Define the unified helper method that is used to implement .next, 1228 // .throw, and .return (see defineIteratorMethods). 1229 this._invoke = enqueue; 1230 } 1231 1232 defineIteratorMethods(AsyncIterator.prototype); 1233 AsyncIterator.prototype[asyncIteratorSymbol] = function () { 1234 return this; 1235 }; 1236 runtime.AsyncIterator = AsyncIterator; 1237 1238 // Note that simple async functions are implemented on top of 1239 // AsyncIterator objects; they just return a Promise for the value of 1240 // the final result produced by the iterator. 1241 runtime.async = function(innerFn, outerFn, self, tryLocsList) { 1242 var iter = new AsyncIterator( 1243 wrap(innerFn, outerFn, self, tryLocsList) 1244 ); 1245 1246 return runtime.isGeneratorFunction(outerFn) 1247 ? iter // If outerFn is a generator, return the full iterator. 1248 : iter.next().then(function(result) { 1249 return result.done ? result.value : iter.next(); 1250 }); 1251 }; 1252 1253 function makeInvokeMethod(innerFn, self, context) { 1254 var state = GenStateSuspendedStart; 1255 1256 return function invoke(method, arg) { 1257 if (state === GenStateExecuting) { 1258 throw new Error("Generator is already running"); 1259 } 1260 1261 if (state === GenStateCompleted) { 1262 if (method === "throw") { 1263 throw arg; 1264 } 1265 1266 // Be forgiving, per 25.3.3.3.3 of the spec: 1267 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume 1268 return doneResult(); 1269 } 1270 1271 context.method = method; 1272 context.arg = arg; 1273 1274 while (true) { 1275 var delegate = context.delegate; 1276 if (delegate) { 1277 var delegateResult = maybeInvokeDelegate(delegate, context); 1278 if (delegateResult) { 1279 if (delegateResult === ContinueSentinel) continue; 1280 return delegateResult; 1281 } 1282 } 1283 1284 if (context.method === "next") { 1285 // Setting context._sent for legacy support of Babel's 1286 // function.sent implementation. 1287 context.sent = context._sent = context.arg; 1288 1289 } else if (context.method === "throw") { 1290 if (state === GenStateSuspendedStart) { 1291 state = GenStateCompleted; 1292 throw context.arg; 1293 } 1294 1295 context.dispatchException(context.arg); 1296 1297 } else if (context.method === "return") { 1298 context.abrupt("return", context.arg); 1299 } 1300 1301 state = GenStateExecuting; 1302 1303 var record = tryCatch(innerFn, self, context); 1304 if (record.type === "normal") { 1305 // If an exception is thrown from innerFn, we leave state === 1306 // GenStateExecuting and loop back for another invocation. 1307 state = context.done 1308 ? GenStateCompleted 1309 : GenStateSuspendedYield; 1310 1311 if (record.arg === ContinueSentinel) { 1312 continue; 1313 } 1314 1315 return { 1316 value: record.arg, 1317 done: context.done 1318 }; 1319 1320 } else if (record.type === "throw") { 1321 state = GenStateCompleted; 1322 // Dispatch the exception by looping back around to the 1323 // context.dispatchException(context.arg) call above. 1324 context.method = "throw"; 1325 context.arg = record.arg; 1326 } 1327 } 1328 }; 1329 } 1330 1331 // Call delegate.iterator[context.method](context.arg) and handle the 1332 // result, either by returning a { value, done } result from the 1333 // delegate iterator, or by modifying context.method and context.arg, 1334 // setting context.delegate to null, and returning the ContinueSentinel. 1335 function maybeInvokeDelegate(delegate, context) { 1336 var method = delegate.iterator[context.method]; 1337 if (method === undefined) { 1338 // A .throw or .return when the delegate iterator has no .throw 1339 // method always terminates the yield* loop. 1340 context.delegate = null; 1341 1342 if (context.method === "throw") { 1343 if (delegate.iterator.return) { 1344 // If the delegate iterator has a return method, give it a 1345 // chance to clean up. 1346 context.method = "return"; 1347 context.arg = undefined; 1348 maybeInvokeDelegate(delegate, context); 1349 1350 if (context.method === "throw") { 1351 // If maybeInvokeDelegate(context) changed context.method from 1352 // "return" to "throw", let that override the TypeError below.
vendor: 4,172 bytes, lines 1353-1506
1353 return ContinueSentinel; 1354 } 1355 } 1356 1357 context.method = "throw"; 1358 context.arg = new TypeError( 1359 "The iterator does not provide a 'throw' method"); 1360 } 1361 1362 return ContinueSentinel; 1363 } 1364 1365 var record = tryCatch(method, delegate.iterator, context.arg); 1366 1367 if (record.type === "throw") { 1368 context.method = "throw"; 1369 context.arg = record.arg; 1370 context.delegate = null; 1371 return ContinueSentinel; 1372 } 1373 1374 var info = record.arg; 1375 1376 if (! info) { 1377 context.method = "throw"; 1378 context.arg = new TypeError("iterator result is not an object"); 1379 context.delegate = null; 1380 return ContinueSentinel; 1381 } 1382 1383 if (info.done) { 1384 // Assign the result of the finished delegate to the temporary 1385 // variable specified by delegate.resultName (see delegateYield). 1386 context[delegate.resultName] = info.value; 1387 1388 // Resume execution at the desired location (see delegateYield). 1389 context.next = delegate.nextLoc; 1390 1391 // If context.method was "throw" but the delegate handled the 1392 // exception, let the outer generator proceed normally. If 1393 // context.method was "next", forget context.arg since it has been 1394 // "consumed" by the delegate iterator. If context.method was 1395 // "return", allow the original .return call to continue in the 1396 // outer generator. 1397 if (context.method !== "return") { 1398 context.method = "next"; 1399 context.arg = undefined; 1400 } 1401 1402 } else { 1403 // Re-yield the result returned by the delegate method. 1404 return info; 1405 } 1406 1407 // The delegate iterator is finished, so forget it and continue with 1408 // the outer generator. 1409 context.delegate = null; 1410 return ContinueSentinel; 1411 } 1412 1413 // Define Generator.prototype.{next,throw,return} in terms of the 1414 // unified ._invoke helper method. 1415 defineIteratorMethods(Gp); 1416 1417 Gp[toStringTagSymbol] = "Generator"; 1418 1419 // A Generator should always return itself as the iterator object when the 1420 // @@iterator function is called on it. Some browsers' implementations of the 1421 // iterator prototype chain incorrectly implement this, causing the Generator 1422 // object to not be returned from this call. This ensures that doesn't happen. 1423 // See https://github.com/facebook/regenerator/issues/274 for more details. 1424 Gp[iteratorSymbol] = function() { 1425 return this; 1426 }; 1427 1428 Gp.toString = function() { 1429 return "[object Generator]"; 1430 }; 1431 1432 function pushTryEntry(locs) { 1433 var entry = { tryLoc: locs[0] }; 1434 1435 if (1 in locs) { 1436 entry.catchLoc = locs[1]; 1437 } 1438 1439 if (2 in locs) { 1440 entry.finallyLoc = locs[2]; 1441 entry.afterLoc = locs[3]; 1442 } 1443 1444 this.tryEntries.push(entry); 1445 } 1446 1447 function resetTryEntry(entry) { 1448 var record = entry.completion || {}; 1449 record.type = "normal"; 1450 delete record.arg; 1451 entry.completion = record; 1452 } 1453 1454 function Context(tryLocsList) { 1455 // The root entry object (effectively a try statement without a catch 1456 // or a finally block) gives us a place to store values thrown from 1457 // locations where there is no enclosing try statement. 1458 this.tryEntries = [{ tryLoc: "root" }]; 1459 tryLocsList.forEach(pushTryEntry, this); 1460 this.reset(true); 1461 } 1462 1463 runtime.keys = function(object) { 1464 var keys = []; 1465 for (var key in object) { 1466 keys.push(key); 1467 } 1468 keys.reverse(); 1469 1470 // Rather than returning an object with a next method, we keep 1471 // things simple and return the next function itself. 1472 return function next() { 1473 while (keys.length) { 1474 var key = keys.pop(); 1475 if (key in object) { 1476 next.value = key; 1477 next.done = false; 1478 return next; 1479 } 1480 } 1481 1482 // To avoid creating an additional object, we just hang the .value 1483 // and .done properties off the next function object itself. This 1484 // also ensures that the minifier will not anonymize the function. 1485 next.done = true; 1486 return next; 1487 }; 1488 }; 1489 1490 function values(iterable) { 1491 if (iterable) { 1492 var iteratorMethod = iterable[iteratorSymbol]; 1493 if (iteratorMethod) { 1494 return iteratorMethod.call(iterable); 1495 } 1496 1497 if (typeof iterable.next === "function") { 1498 return iterable; 1499 } 1500 1501 if (!isNaN(iterable.length)) { 1502 var i = -1, next = function next() { 1503 while (++i < iterable.length) { 1504 if (hasOwn.call(iterable, i)) { 1505 next.value = iterable[i]; 1506 next.done = false;
1507 return next; 1508 } 1509 } 1510 1511 next.value = undefined; 1512 next.done = true; 1513 1514 return next; 1515 }; 1516 1517 return next.next = next; 1518 } 1519 } 1520 1521 // Return an iterator with no values. 1522 return { next: doneResult }; 1523 } 1524 runtime.values = values; 1525 1526 function doneResult() { 1527 return { value: undefined, done: true }; 1528 } 1529 1530 Context.prototype = { 1531 constructor: Context, 1532 1533 reset: function(skipTempReset) { 1534 this.prev = 0; 1535 this.next = 0; 1536 // Resetting context._sent for legacy support of Babel's 1537 // function.sent implementation. 1538 this.sent = this._sent = undefined; 1539 this.done = false; 1540 this.delegate = null; 1541 1542 this.method = "next"; 1543 this.arg = undefined; 1544 1545 this.tryEntries.forEach(resetTryEntry); 1546 1547 if (!skipTempReset) { 1548 for (var name in this) { 1549 // Not sure about the optimal order of these conditions: 1550 if (name.charAt(0) === "t" && 1551 hasOwn.call(this, name) && 1552 !isNaN(+name.slice(1))) { 1553 this[name] = undefined; 1554 } 1555 } 1556 } 1557 }, 1558 1559 stop: function() { 1560 this.done = true; 1561 1562 var rootEntry = this.tryEntries[0]; 1563 var rootRecord = rootEntry.completion; 1564 if (rootRecord.type === "throw") { 1565 throw rootRecord.arg; 1566 } 1567 1568 return this.rval; 1569 }, 1570 1571 dispatchException: function(exception) { 1572 if (this.done) { 1573 throw exception; 1574 } 1575 1576 var context = this; 1577 function handle(loc, caught) { 1578 record.type = "throw"; 1579 record.arg = exception; 1580 context.next = loc; 1581 1582 if (caught) { 1583 // If the dispatched exception was caught by a catch block, 1584 // then let that catch block handle the exception normally. 1585 context.method = "next"; 1586 context.arg = undefined; 1587 } 1588 1589 return !! caught; 1590 } 1591 1592 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 1593 var entry = this.tryEntries[i]; 1594 var record = entry.completion; 1595 1596 if (entry.tryLoc === "root") { 1597 // Exception thrown outside of any try block that could handle 1598 // it, so set the completion value of the entire function to 1599 // throw the exception. 1600 return handle("end"); 1601 } 1602 1603 if (entry.tryLoc <= this.prev) { 1604 var hasCatch = hasOwn.call(entry, "catchLoc"); 1605 var hasFinally = hasOwn.call(entry, "finallyLoc"); 1606 1607 if (hasCatch && hasFinally) { 1608 if (this.prev < entry.catchLoc) { 1609 return handle(entry.catchLoc, true); 1610 } else if (this.prev < entry.finallyLoc) { 1611 return handle(entry.finallyLoc); 1612 } 1613 1614 } else if (hasCatch) { 1615 if (this.prev < entry.catchLoc) { 1616 return handle(entry.catchLoc, true); 1617 } 1618 1619 } else if (hasFinally) { 1620 if (this.prev < entry.finallyLoc) { 1621 return handle(entry.finallyLoc); 1622 } 1623 1624 } else { 1625 throw new Error("try statement without catch or finally"); 1626 } 1627 } 1628 } 1629 }, 1630 1631 abrupt: function(type, arg) { 1632 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 1633 var entry = this.tryEntries[i]; 1634 if (entry.tryLoc <= this.prev && 1635 hasOwn.call(entry, "finallyLoc") && 1636 this.prev < entry.finallyLoc) { 1637 var finallyEntry = entry; 1638 break; 1639 } 1640 } 1641 1642 if (finallyEntry && 1643 (type === "break" || 1644 type === "continue") && 1645 finallyEntry.tryLoc <= arg && 1646 arg <= finallyEntry.finallyLoc) { 1647 // Ignore the finally entry if control is not jumping to a 1648 // location outside the try/catch block. 1649 finallyEntry = null; 1650 } 1651 1652 var record = finallyEntry ? finallyEntry.completion : {}; 1653 record.type = type; 1654 record.arg = arg; 1655 1656 if (finallyEntry) { 1657 this.method = "next"; 1658 this.next = finallyEntry.finallyLoc; 1659 return ContinueSentinel; 1660 } 1661 1662 return this.complete(record); 1663 }, 1664 1665 complete: function(record, afterLoc) { 1666 if (record.type === "throw") { 1667 throw record.arg; 1668 } 1669 1670 if (record.type === "break" || 1671 record.type === "continue") { 1672 this.next = record.arg; 1673 } else if (record.type === "return") { 1674 this.rval = this.arg = record.arg; 1675 this.method = "return"; 1676 this.next = "end"; 1677 } else if (record.type === "normal" && afterLoc) { 1678 this.next = afterLoc; 1679 } 1680 1681 return ContinueSentinel; 1682 }, 1683 1684 finish: function(finallyLoc) { 1685 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 1686 var entry = this.tryEntries[i]; 1687 if (entry.finallyLoc === finallyLoc) { 1688 this.complete(entry.completion, entry.afterLoc); 1689 resetTryEntry(entry); 1690 return ContinueSentinel; 1691 } 1692 } 1693 }, 1694 1695 "catch": function(tryLoc) { 1696 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 1697 var entry = this.tryEntries[i]; 1698 if (entry.tryLoc === tryLoc) { 1699 var record = entry.completion; 1700 if (record.type === "throw") { 1701 var thrown = record.arg; 1702 resetTryEntry(entry); 1703 } 1704 return thrown; 1705 } 1706 } 1707 1708 // The context.catch method must only be called with a location 1709 // argument that corresponds to a known catch block. 1710 throw new Error("illegal catch attempt"); 1711 }, 1712 1713 delegateYield: function(iterable, resultName, nextLoc) { 1714 this.delegate = { 1715 iterator: values(iterable), 1716 resultName: resultName, 1717 nextLoc: nextLoc 1718 }; 1719 1720 if (this.method === "next") { 1721 // Deliberately forget the last sent value so that we don't 1722 // accidentally pass it on to the delegate. 1723 this.arg = undefined; 1724 } 1725 1726 return ContinueSentinel; 1727 } 1728 }; 1729})( 1730 // In sloppy mode, unbound `this` refers to the global object, fallback to 1731 // Function constructor if we're in global strict mode. That is sadly a form 1732 // of indirect eval which violates Content Security Policy. 1733 (function() { return this })() || Function("return this")() 1734); 1735 1736(function (exports) { 1737 'use strict'; 1738 1739 var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; 1740 function createCommonjsModule(fn, module) { 1741 return module = { 1742 exports: {} 1743 }, fn(module, module.exports), module.exports; 1744 } 1745 1746 var check = function (it) { 1747 return it && it.Math === Math && it; 1748 }; 1749 1750 // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 1751 var globalThis_1 = 1752 // eslint-disable-next-line es/no-global-this -- safe 1753 check(typeof globalThis == 'object' && globalThis) || check(typeof window == 'object' && window) || 1754 // eslint-disable-next-line no-restricted-globals -- safe 1755 check(typeof self == 'object' && self) || check(typeof commonjsGlobal == 'object' && commonjsGlobal) || check(typeof commonjsGlobal == 'object' && commonjsGlobal) || 1756 // eslint-disable-next-line no-new-func -- fallback 1757 function () { 1758 return this; 1759 }() || Function('return this')(); 1760 1761 var fails = function (exec) { 1762 try { 1763 return !!exec(); 1764 } catch (error) { 1765 return true; 1766 } 1767 }; 1768 1769 // Detect IE8's incomplete defineProperty implementation 1770 var descriptors = !fails(function () { 1771 // eslint-disable-next-line es/no-object-defineproperty -- required for testing 1772 return Object.defineProperty({}, 1, { 1773 get: function () { 1774 return 7; 1775 } 1776 })[1] !== 7; 1777 }); 1778 1779 var functionBindNative = !fails(function () { 1780 // eslint-disable-next-line es/no-function-prototype-bind -- safe 1781 var test = function () {/* empty */}.bind(); 1782 // eslint-disable-next-line no-prototype-builtins -- safe 1783 return typeof test != 'function' || test.hasOwnProperty('prototype'); 1784 }); 1785 1786 var call = Function.prototype.call; 1787 // eslint-disable-next-line es/no-function-prototype-bind -- safe 1788 var functionCall = functionBindNative ? call.bind(call) : function () { 1789 return call.apply(call, arguments); 1790 }; 1791 1792 var $propertyIsEnumerable = {}.propertyIsEnumerable; 1793 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 1794 var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; 1795 1796 // Nashorn ~ JDK8 bug 1797 var NASHORN_BUG = getOwnPropertyDescriptor && !$propertyIsEnumerable.call({ 1798 1: 2 1799 }, 1); 1800 1801 // `Object.prototype.propertyIsEnumerable` method implementation 1802 // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable 1803 var f = NASHORN_BUG ? function propertyIsEnumerable(V) { 1804 var descriptor = getOwnPropertyDescriptor(this, V); 1805 return !!descriptor && descriptor.enumerable; 1806 } : $propertyIsEnumerable; 1807 1808 var objectPropertyIsEnumerable = { 1809 f: f 1810 }; 1811 1812 var createPropertyDescriptor = function (bitmap, value) { 1813 return { 1814 enumerable: !(bitmap & 1), 1815 configurable: !(bitmap & 2), 1816 writable: !(bitmap & 4), 1817 value: value 1818 }; 1819 }; 1820 1821 var FunctionPrototype = Function.prototype; 1822 var call$1 = FunctionPrototype.call; 1823 // eslint-disable-next-line es/no-function-prototype-bind -- safe 1824 var uncurryThisWithBind = functionBindNative && FunctionPrototype.bind.bind(call$1, call$1); 1825 var functionUncurryThis = functionBindNative ? uncurryThisWithBind : function (fn) { 1826 return function () { 1827 return call$1.apply(fn, arguments); 1828 }; 1829 }; 1830 1831 var toString = functionUncurryThis({}.toString); 1832 var stringSlice = functionUncurryThis(''.slice); 1833 var classofRaw = function (it) { 1834 return stringSlice(toString(it), 8, -1); 1835 }; 1836 1837 var $Object = Object; 1838 var split = functionUncurryThis(''.split); 1839 1840 // fallback for non-array-like ES3 and non-enumerable old V8 strings 1841 var indexedObject = fails(function () { 1842 // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346 1843 // eslint-disable-next-line no-prototype-builtins -- safe 1844 return !$Object('z').propertyIsEnumerable(0); 1845 }) ? function (it) { 1846 return classofRaw(it) === 'String' ? split(it, '') : $Object(it); 1847 } : $Object; 1848 1849 // we can't use just `it == null` since of `document.all` special case
vendor: 58,422 bytes, lines 1850-3460
1850 // https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot-aec 1851 var isNullOrUndefined = function (it) { 1852 return it === null || it === undefined; 1853 }; 1854 1855 var $TypeError = TypeError; 1856 1857 // `RequireObjectCoercible` abstract operation 1858 // https://tc39.es/ecma262/#sec-requireobjectcoercible 1859 var requireObjectCoercible = function (it) { 1860 if (isNullOrUndefined(it)) throw new $TypeError("Can't call method on " + it); 1861 return it; 1862 }; 1863 1864 // toObject with fallback for non-array-like ES3 strings 1865 1866 1867 var toIndexedObject = function (it) { 1868 return indexedObject(requireObjectCoercible(it)); 1869 }; 1870 1871 // https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot 1872 var documentAll = typeof document == 'object' && document.all; 1873 1874 // `IsCallable` abstract operation 1875 // https://tc39.es/ecma262/#sec-iscallable 1876 // eslint-disable-next-line unicorn/no-typeof-undefined -- required for testing 1877 var isCallable = typeof documentAll == 'undefined' && documentAll !== undefined ? function (argument) { 1878 return typeof argument == 'function' || argument === documentAll; 1879 } : function (argument) { 1880 return typeof argument == 'function'; 1881 }; 1882 1883 var isObject = function (it) { 1884 return typeof it == 'object' ? it !== null : isCallable(it); 1885 }; 1886 1887 var aFunction = function (argument) { 1888 return isCallable(argument) ? argument : undefined; 1889 }; 1890 var getBuiltIn = function (namespace, method) { 1891 return arguments.length < 2 ? aFunction(globalThis_1[namespace]) : globalThis_1[namespace] && globalThis_1[namespace][method]; 1892 }; 1893 1894 var objectIsPrototypeOf = functionUncurryThis({}.isPrototypeOf); 1895 1896 var navigator = globalThis_1.navigator; 1897 var userAgent = navigator && navigator.userAgent; 1898 var environmentUserAgent = userAgent ? String(userAgent) : ''; 1899 1900 var process = globalThis_1.process; 1901 var Deno$1 = globalThis_1.Deno; 1902 var versions = process && process.versions || Deno$1 && Deno$1.version; 1903 var v8 = versions && versions.v8; 1904 var match, version; 1905 if (v8) { 1906 match = v8.split('.'); 1907 // in old Chrome, versions of V8 isn't V8 = Chrome / 10 1908 // but their correct versions are not interesting for us 1909 version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]); 1910 } 1911 1912 // BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0` 1913 // so check `userAgent` even if `.v8` exists, but 0 1914 if (!version && environmentUserAgent) { 1915 match = environmentUserAgent.match(/Edge\/(\d+)/); 1916 if (!match || match[1] >= 74) { 1917 match = environmentUserAgent.match(/Chrome\/(\d+)/); 1918 if (match) version = +match[1]; 1919 } 1920 } 1921 var environmentV8Version = version; 1922 1923 /* eslint-disable es/no-symbol -- required for testing */ 1924 1925 1926 1927 var $String = globalThis_1.String; 1928 1929 // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing 1930 var symbolConstructorDetection = !!Object.getOwnPropertySymbols && !fails(function () { 1931 var symbol = Symbol('symbol detection'); 1932 // Chrome 38 Symbol has incorrect toString conversion 1933 // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances 1934 // nb: Do not call `String` directly to avoid this being optimized out to `symbol+''` which will, 1935 // of course, fail. 1936 return !$String(symbol) || !(Object(symbol) instanceof Symbol) || 1937 // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances 1938 !Symbol.sham && environmentV8Version && environmentV8Version < 41; 1939 }); 1940 1941 /* eslint-disable es/no-symbol -- required for testing */ 1942 1943 var useSymbolAsUid = symbolConstructorDetection && !Symbol.sham && typeof Symbol.iterator == 'symbol'; 1944 1945 var $Object$1 = Object; 1946 var isSymbol = useSymbolAsUid ? function (it) { 1947 return typeof it == 'symbol'; 1948 } : function (it) { 1949 var $Symbol = getBuiltIn('Symbol'); 1950 return isCallable($Symbol) && objectIsPrototypeOf($Symbol.prototype, $Object$1(it)); 1951 }; 1952 1953 var $String$1 = String; 1954 var tryToString = function (argument) { 1955 try { 1956 return $String$1(argument); 1957 } catch (error) { 1958 return 'Object'; 1959 } 1960 }; 1961 1962 var $TypeError$1 = TypeError; 1963 1964 // `Assert: IsCallable(argument) is true` 1965 var aCallable = function (argument) { 1966 if (isCallable(argument)) return argument; 1967 throw new $TypeError$1(tryToString(argument) + ' is not a function'); 1968 }; 1969 1970 // `GetMethod` abstract operation 1971 // https://tc39.es/ecma262/#sec-getmethod 1972 var getMethod = function (V, P) { 1973 var func = V[P]; 1974 return isNullOrUndefined(func) ? undefined : aCallable(func); 1975 }; 1976 1977 var $TypeError$2 = TypeError; 1978 1979 // `OrdinaryToPrimitive` abstract operation 1980 // https://tc39.es/ecma262/#sec-ordinarytoprimitive 1981 var ordinaryToPrimitive = function (input, pref) { 1982 var fn, val; 1983 if (pref === 'string' && isCallable(fn = input.toString) && !isObject(val = functionCall(fn, input))) return val; 1984 if (isCallable(fn = input.valueOf) && !isObject(val = functionCall(fn, input))) return val; 1985 if (pref !== 'string' && isCallable(fn = input.toString) && !isObject(val = functionCall(fn, input))) return val; 1986 throw new $TypeError$2("Can't convert object to primitive value"); 1987 }; 1988 1989 var isPure = false; 1990 1991 // eslint-disable-next-line es/no-object-defineproperty -- safe 1992 var defineProperty = Object.defineProperty; 1993 var defineGlobalProperty = function (key, value) { 1994 try { 1995 defineProperty(globalThis_1, key, { 1996 value: value, 1997 configurable: true, 1998 writable: true 1999 }); 2000 } catch (error) { 2001 globalThis_1[key] = value; 2002 } 2003 return value; 2004 }; 2005 2006 var sharedStore = createCommonjsModule(function (module) { 2007 2008 2009 2010 2011 var SHARED = '__core-js_shared__'; 2012 var store = module.exports = globalThis_1[SHARED] || defineGlobalProperty(SHARED, {}); 2013 (store.versions || (store.versions = [])).push({ 2014 version: '3.41.0', 2015 mode: 'global', 2016 copyright: '© 2014-2025 Denis Pushkarev (zloirock.ru)', 2017 license: 'https://github.com/zloirock/core-js/blob/v3.41.0/LICENSE', 2018 source: 'https://github.com/zloirock/core-js' 2019 }); 2020 }); 2021 2022 var shared = createCommonjsModule(function (module) { 2023 (module.exports = function (key, value) { 2024 return sharedStore[key] || (sharedStore[key] = value !== undefined ? value : {}); 2025 })('versions', []).push({ 2026 version: '3.19.2', 2027 mode: 'global', 2028 copyright: '(c) 2021 Denis Pushkarev (zloirock.ru)' 2029 }); 2030 }); 2031 2032 var $Object$2 = Object; 2033 2034 // `ToObject` abstract operation 2035 // https://tc39.es/ecma262/#sec-toobject 2036 var toObject = function (argument) { 2037 return $Object$2(requireObjectCoercible(argument)); 2038 }; 2039 2040 var hasOwnProperty = functionUncurryThis({}.hasOwnProperty); 2041 2042 // `HasOwnProperty` abstract operation 2043 // https://tc39.es/ecma262/#sec-hasownproperty 2044 // eslint-disable-next-line es/no-object-hasown -- safe 2045 var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) { 2046 return hasOwnProperty(toObject(it), key); 2047 }; 2048 2049 var id = 0; 2050 var postfix = Math.random(); 2051 var toString$1 = functionUncurryThis(1.0.toString); 2052 var uid = function (key) { 2053 return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString$1(++id + postfix, 36); 2054 }; 2055 2056 var Symbol$1 = globalThis_1.Symbol; 2057 var WellKnownSymbolsStore = shared('wks'); 2058 var createWellKnownSymbol = useSymbolAsUid ? Symbol$1['for'] || Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid; 2059 var wellKnownSymbol = function (name) { 2060 if (!hasOwnProperty_1(WellKnownSymbolsStore, name)) { 2061 WellKnownSymbolsStore[name] = symbolConstructorDetection && hasOwnProperty_1(Symbol$1, name) ? Symbol$1[name] : createWellKnownSymbol('Symbol.' + name); 2062 } 2063 return WellKnownSymbolsStore[name]; 2064 }; 2065 2066 var $TypeError$3 = TypeError; 2067 var TO_PRIMITIVE = wellKnownSymbol('toPrimitive'); 2068 2069 // `ToPrimitive` abstract operation 2070 // https://tc39.es/ecma262/#sec-toprimitive 2071 var toPrimitive = function (input, pref) { 2072 if (!isObject(input) || isSymbol(input)) return input; 2073 var exoticToPrim = getMethod(input, TO_PRIMITIVE); 2074 var result; 2075 if (exoticToPrim) { 2076 if (pref === undefined) pref = 'default'; 2077 result = functionCall(exoticToPrim, input, pref); 2078 if (!isObject(result) || isSymbol(result)) return result; 2079 throw new $TypeError$3("Can't convert object to primitive value"); 2080 } 2081 if (pref === undefined) pref = 'number'; 2082 return ordinaryToPrimitive(input, pref); 2083 }; 2084 2085 // `ToPropertyKey` abstract operation 2086 // https://tc39.es/ecma262/#sec-topropertykey 2087 var toPropertyKey = function (argument) { 2088 var key = toPrimitive(argument, 'string'); 2089 return isSymbol(key) ? key : key + ''; 2090 }; 2091 2092 var document$1 = globalThis_1.document; 2093 // typeof document.createElement is 'object' in old IE 2094 var EXISTS = isObject(document$1) && isObject(document$1.createElement); 2095 var documentCreateElement = function (it) { 2096 return EXISTS ? document$1.createElement(it) : {}; 2097 }; 2098 2099 // Thanks to IE8 for its funny defineProperty 2100 var ie8DomDefine = !descriptors && !fails(function () { 2101 // eslint-disable-next-line es/no-object-defineproperty -- required for testing 2102 return Object.defineProperty(documentCreateElement('div'), 'a', { 2103 get: function () { 2104 return 7; 2105 } 2106 }).a !== 7; 2107 }); 2108 2109 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 2110 var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; 2111 2112 // `Object.getOwnPropertyDescriptor` method 2113 // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor 2114 var f$1 = descriptors ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) { 2115 O = toIndexedObject(O); 2116 P = toPropertyKey(P); 2117 if (ie8DomDefine) try { 2118 return $getOwnPropertyDescriptor(O, P); 2119 } catch (error) {/* empty */} 2120 if (hasOwnProperty_1(O, P)) return createPropertyDescriptor(!functionCall(objectPropertyIsEnumerable.f, O, P), O[P]); 2121 }; 2122 2123 var objectGetOwnPropertyDescriptor = { 2124 f: f$1 2125 }; 2126 2127 // V8 ~ Chrome 36- 2128 // https://bugs.chromium.org/p/v8/issues/detail?id=3334 2129 var v8PrototypeDefineBug = descriptors && fails(function () { 2130 // eslint-disable-next-line es/no-object-defineproperty -- required for testing 2131 return Object.defineProperty(function () {/* empty */}, 'prototype', { 2132 value: 42, 2133 writable: false 2134 }).prototype !== 42; 2135 }); 2136 2137 var $String$2 = String; 2138 var $TypeError$4 = TypeError; 2139 2140 // `Assert: Type(argument) is Object` 2141 var anObject = function (argument) { 2142 if (isObject(argument)) return argument; 2143 throw new $TypeError$4($String$2(argument) + ' is not an object'); 2144 }; 2145 2146 var $TypeError$5 = TypeError; 2147 // eslint-disable-next-line es/no-object-defineproperty -- safe 2148 var $defineProperty = Object.defineProperty; 2149 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 2150 var $getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor; 2151 var ENUMERABLE = 'enumerable'; 2152 var CONFIGURABLE = 'configurable'; 2153 var WRITABLE = 'writable'; 2154 2155 // `Object.defineProperty` method 2156 // https://tc39.es/ecma262/#sec-object.defineproperty 2157 var f$2 = descriptors ? v8PrototypeDefineBug ? function defineProperty(O, P, Attributes) { 2158 anObject(O); 2159 P = toPropertyKey(P); 2160 anObject(Attributes); 2161 if (typeof O === 'function' && P === 'prototype' && 'value' in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) { 2162 var current = $getOwnPropertyDescriptor$1(O, P); 2163 if (current && current[WRITABLE]) { 2164 O[P] = Attributes.value; 2165 Attributes = { 2166 configurable: CONFIGURABLE in Attributes ? Attributes[CONFIGURABLE] : current[CONFIGURABLE], 2167 enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE], 2168 writable: false 2169 }; 2170 } 2171 } 2172 return $defineProperty(O, P, Attributes); 2173 } : $defineProperty : function defineProperty(O, P, Attributes) { 2174 anObject(O); 2175 P = toPropertyKey(P); 2176 anObject(Attributes); 2177 if (ie8DomDefine) try { 2178 return $defineProperty(O, P, Attributes); 2179 } catch (error) {/* empty */} 2180 if ('get' in Attributes || 'set' in Attributes) throw new $TypeError$5('Accessors not supported'); 2181 if ('value' in Attributes) O[P] = Attributes.value; 2182 return O; 2183 }; 2184 2185 var objectDefineProperty = { 2186 f: f$2 2187 }; 2188 2189 var createNonEnumerableProperty = descriptors ? function (object, key, value) { 2190 return objectDefineProperty.f(object, key, createPropertyDescriptor(1, value)); 2191 } : function (object, key, value) { 2192 object[key] = value; 2193 return object; 2194 }; 2195 2196 var FunctionPrototype$1 = Function.prototype; 2197 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 2198 var getDescriptor = descriptors && Object.getOwnPropertyDescriptor; 2199 var EXISTS$1 = hasOwnProperty_1(FunctionPrototype$1, 'name'); 2200 // additional protection from minified / mangled / dropped function names 2201 var PROPER = EXISTS$1 && function something() {/* empty */}.name === 'something'; 2202 var CONFIGURABLE$1 = EXISTS$1 && (!descriptors || descriptors && getDescriptor(FunctionPrototype$1, 'name').configurable); 2203 var functionName = { 2204 EXISTS: EXISTS$1, 2205 PROPER: PROPER, 2206 CONFIGURABLE: CONFIGURABLE$1 2207 }; 2208 2209 var functionToString = functionUncurryThis(Function.toString); 2210 2211 // this helper broken in `[email protected]`, so we can't use `shared` helper 2212 if (!isCallable(sharedStore.inspectSource)) { 2213 sharedStore.inspectSource = function (it) { 2214 return functionToString(it); 2215 }; 2216 } 2217 var inspectSource = sharedStore.inspectSource; 2218 2219 var WeakMap = globalThis_1.WeakMap; 2220 var weakMapBasicDetection = isCallable(WeakMap) && /native code/.test(String(WeakMap)); 2221 2222 var keys = shared('keys'); 2223 var sharedKey = function (key) { 2224 return keys[key] || (keys[key] = uid(key)); 2225 }; 2226 2227 var hiddenKeys = {}; 2228 2229 var OBJECT_ALREADY_INITIALIZED = 'Object already initialized'; 2230 var TypeError$1 = globalThis_1.TypeError; 2231 var WeakMap$1 = globalThis_1.WeakMap; 2232 var set, get, has; 2233 var enforce = function (it) { 2234 return has(it) ? get(it) : set(it, {}); 2235 }; 2236 var getterFor = function (TYPE) { 2237 return function (it) { 2238 var state; 2239 if (!isObject(it) || (state = get(it)).type !== TYPE) { 2240 throw new TypeError$1('Incompatible receiver, ' + TYPE + ' required'); 2241 } 2242 return state; 2243 }; 2244 }; 2245 if (weakMapBasicDetection || sharedStore.state) { 2246 var store = sharedStore.state || (sharedStore.state = new WeakMap$1()); 2247 /* eslint-disable no-self-assign -- prototype methods protection */ 2248 store.get = store.get; 2249 store.has = store.has; 2250 store.set = store.set; 2251 /* eslint-enable no-self-assign -- prototype methods protection */ 2252 set = function (it, metadata) { 2253 if (store.has(it)) throw new TypeError$1(OBJECT_ALREADY_INITIALIZED); 2254 metadata.facade = it; 2255 store.set(it, metadata); 2256 return metadata; 2257 }; 2258 get = function (it) { 2259 return store.get(it) || {}; 2260 }; 2261 has = function (it) { 2262 return store.has(it); 2263 }; 2264 } else { 2265 var STATE = sharedKey('state'); 2266 hiddenKeys[STATE] = true; 2267 set = function (it, metadata) { 2268 if (hasOwnProperty_1(it, STATE)) throw new TypeError$1(OBJECT_ALREADY_INITIALIZED); 2269 metadata.facade = it; 2270 createNonEnumerableProperty(it, STATE, metadata); 2271 return metadata; 2272 }; 2273 get = function (it) { 2274 return hasOwnProperty_1(it, STATE) ? it[STATE] : {}; 2275 }; 2276 has = function (it) { 2277 return hasOwnProperty_1(it, STATE); 2278 }; 2279 } 2280 var internalState = { 2281 set: set, 2282 get: get, 2283 has: has, 2284 enforce: enforce, 2285 getterFor: getterFor 2286 }; 2287 2288 var makeBuiltIn_1 = createCommonjsModule(function (module) { 2289 2290 2291 2292 2293 2294 2295 var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE; 2296 2297 2298 var enforceInternalState = internalState.enforce; 2299 var getInternalState = internalState.get; 2300 var $String = String; 2301 // eslint-disable-next-line es/no-object-defineproperty -- safe 2302 var defineProperty = Object.defineProperty; 2303 var stringSlice = functionUncurryThis(''.slice); 2304 var replace = functionUncurryThis(''.replace); 2305 var join = functionUncurryThis([].join); 2306 var CONFIGURABLE_LENGTH = descriptors && !fails(function () { 2307 return defineProperty(function () {/* empty */}, 'length', { 2308 value: 8 2309 }).length !== 8; 2310 }); 2311 var TEMPLATE = String(String).split('String'); 2312 var makeBuiltIn = module.exports = function (value, name, options) { 2313 if (stringSlice($String(name), 0, 7) === 'Symbol(') { 2314 name = '[' + replace($String(name), /^Symbol\(([^)]*)\).*$/, '$1') + ']'; 2315 } 2316 if (options && options.getter) name = 'get ' + name; 2317 if (options && options.setter) name = 'set ' + name; 2318 if (!hasOwnProperty_1(value, 'name') || CONFIGURABLE_FUNCTION_NAME && value.name !== name) { 2319 if (descriptors) defineProperty(value, 'name', { 2320 value: name, 2321 configurable: true 2322 });else value.name = name; 2323 } 2324 if (CONFIGURABLE_LENGTH && options && hasOwnProperty_1(options, 'arity') && value.length !== options.arity) { 2325 defineProperty(value, 'length', { 2326 value: options.arity 2327 }); 2328 } 2329 try { 2330 if (options && hasOwnProperty_1(options, 'constructor') && options.constructor) { 2331 if (descriptors) defineProperty(value, 'prototype', { 2332 writable: false 2333 }); 2334 // in V8 ~ Chrome 53, prototypes of some methods, like `Array.prototype.values`, are non-writable 2335 } else if (value.prototype) value.prototype = undefined; 2336 } catch (error) {/* empty */} 2337 var state = enforceInternalState(value); 2338 if (!hasOwnProperty_1(state, 'source')) { 2339 state.source = join(TEMPLATE, typeof name == 'string' ? name : ''); 2340 } 2341 return value; 2342 }; 2343 2344 // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative 2345 // eslint-disable-next-line no-extend-native -- required 2346 Function.prototype.toString = makeBuiltIn(function toString() { 2347 return isCallable(this) && getInternalState(this).source || inspectSource(this); 2348 }, 'toString'); 2349 }); 2350 2351 var defineBuiltIn = function (O, key, value, options) { 2352 if (!options) options = {}; 2353 var simple = options.enumerable; 2354 var name = options.name !== undefined ? options.name : key; 2355 if (isCallable(value)) makeBuiltIn_1(value, name, options); 2356 if (options.global) { 2357 if (simple) O[key] = value;else defineGlobalProperty(key, value); 2358 } else { 2359 try { 2360 if (!options.unsafe) delete O[key];else if (O[key]) simple = true; 2361 } catch (error) {/* empty */} 2362 if (simple) O[key] = value;else objectDefineProperty.f(O, key, { 2363 value: value, 2364 enumerable: false, 2365 configurable: !options.nonConfigurable, 2366 writable: !options.nonWritable 2367 }); 2368 } 2369 return O; 2370 }; 2371 2372 var ceil = Math.ceil; 2373 var floor = Math.floor; 2374 2375 // `Math.trunc` method 2376 // https://tc39.es/ecma262/#sec-math.trunc 2377 // eslint-disable-next-line es/no-math-trunc -- safe 2378 var mathTrunc = Math.trunc || function trunc(x) { 2379 var n = +x; 2380 return (n > 0 ? floor : ceil)(n); 2381 }; 2382 2383 // `ToIntegerOrInfinity` abstract operation 2384 // https://tc39.es/ecma262/#sec-tointegerorinfinity 2385 var toIntegerOrInfinity = function (argument) { 2386 var number = +argument; 2387 // eslint-disable-next-line no-self-compare -- NaN check 2388 return number !== number || number === 0 ? 0 : mathTrunc(number); 2389 }; 2390 2391 var max = Math.max; 2392 var min = Math.min; 2393 2394 // Helper for a popular repeating case of the spec: 2395 // Let integer be ? ToInteger(index). 2396 // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length). 2397 var toAbsoluteIndex = function (index, length) { 2398 var integer = toIntegerOrInfinity(index); 2399 return integer < 0 ? max(integer + length, 0) : min(integer, length); 2400 }; 2401 2402 var min$1 = Math.min; 2403 2404 // `ToLength` abstract operation 2405 // https://tc39.es/ecma262/#sec-tolength 2406 var toLength = function (argument) { 2407 var len = toIntegerOrInfinity(argument); 2408 return len > 0 ? min$1(len, 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991 2409 }; 2410 2411 // `LengthOfArrayLike` abstract operation 2412 // https://tc39.es/ecma262/#sec-lengthofarraylike 2413 var lengthOfArrayLike = function (obj) { 2414 return toLength(obj.length); 2415 }; 2416 2417 // `Array.prototype.{ indexOf, includes }` methods implementation 2418 var createMethod = function (IS_INCLUDES) { 2419 return function ($this, el, fromIndex) { 2420 var O = toIndexedObject($this); 2421 var length = lengthOfArrayLike(O); 2422 if (length === 0) return !IS_INCLUDES && -1; 2423 var index = toAbsoluteIndex(fromIndex, length); 2424 var value; 2425 // Array#includes uses SameValueZero equality algorithm 2426 // eslint-disable-next-line no-self-compare -- NaN check 2427 if (IS_INCLUDES && el !== el) while (length > index) { 2428 value = O[index++]; 2429 // eslint-disable-next-line no-self-compare -- NaN check 2430 if (value !== value) return true; 2431 // Array#indexOf ignores holes, Array#includes - not 2432 } else for (; length > index; index++) { 2433 if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0; 2434 } 2435 return !IS_INCLUDES && -1; 2436 }; 2437 }; 2438 var arrayIncludes = { 2439 // `Array.prototype.includes` method 2440 // https://tc39.es/ecma262/#sec-array.prototype.includes 2441 includes: createMethod(true), 2442 // `Array.prototype.indexOf` method 2443 // https://tc39.es/ecma262/#sec-array.prototype.indexof 2444 indexOf: createMethod(false) 2445 }; 2446 2447 var indexOf = arrayIncludes.indexOf; 2448 2449 var push = functionUncurryThis([].push); 2450 var objectKeysInternal = function (object, names) { 2451 var O = toIndexedObject(object); 2452 var i = 0; 2453 var result = []; 2454 var key; 2455 for (key in O) !hasOwnProperty_1(hiddenKeys, key) && hasOwnProperty_1(O, key) && push(result, key); 2456 // Don't enum bug & hidden keys 2457 while (names.length > i) if (hasOwnProperty_1(O, key = names[i++])) { 2458 ~indexOf(result, key) || push(result, key); 2459 } 2460 return result; 2461 }; 2462 2463 // IE8- don't enum bug keys 2464 var enumBugKeys = ['constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf']; 2465 2466 var hiddenKeys$1 = enumBugKeys.concat('length', 'prototype'); 2467 2468 // `Object.getOwnPropertyNames` method 2469 // https://tc39.es/ecma262/#sec-object.getownpropertynames 2470 // eslint-disable-next-line es/no-object-getownpropertynames -- safe 2471 var f$3 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { 2472 return objectKeysInternal(O, hiddenKeys$1); 2473 }; 2474 2475 var objectGetOwnPropertyNames = { 2476 f: f$3 2477 }; 2478 2479 // eslint-disable-next-line es/no-object-getownpropertysymbols -- safe 2480 var f$4 = Object.getOwnPropertySymbols; 2481 2482 var objectGetOwnPropertySymbols = { 2483 f: f$4 2484 }; 2485 2486 var concat = functionUncurryThis([].concat); 2487 2488 // all object keys, includes non-enumerable and symbols 2489 var ownKeys = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) { 2490 var keys = objectGetOwnPropertyNames.f(anObject(it)); 2491 var getOwnPropertySymbols = objectGetOwnPropertySymbols.f; 2492 return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys; 2493 }; 2494 2495 var copyConstructorProperties = function (target, source, exceptions) { 2496 var keys = ownKeys(source); 2497 var defineProperty = objectDefineProperty.f; 2498 var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f; 2499 for (var i = 0; i < keys.length; i++) { 2500 var key = keys[i]; 2501 if (!hasOwnProperty_1(target, key) && !(exceptions && hasOwnProperty_1(exceptions, key))) { 2502 defineProperty(target, key, getOwnPropertyDescriptor(source, key)); 2503 } 2504 } 2505 }; 2506 2507 var replacement = /#|\.prototype\./; 2508 var isForced = function (feature, detection) { 2509 var value = data[normalize(feature)]; 2510 return value === POLYFILL ? true : value === NATIVE ? false : isCallable(detection) ? fails(detection) : !!detection; 2511 }; 2512 var normalize = isForced.normalize = function (string) { 2513 return String(string).replace(replacement, '.').toLowerCase(); 2514 }; 2515 var data = isForced.data = {}; 2516 var NATIVE = isForced.NATIVE = 'N'; 2517 var POLYFILL = isForced.POLYFILL = 'P'; 2518 var isForced_1 = isForced; 2519 2520 var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f; 2521 2522 2523 2524 2525 2526 2527 /* 2528 options.target - name of the target object 2529 options.global - target is the global object 2530 options.stat - export as static methods of target 2531 options.proto - export as prototype methods of target 2532 options.real - real prototype method for the `pure` version 2533 options.forced - export even if the native feature is available 2534 options.bind - bind methods to the target, required for the `pure` version 2535 options.wrap - wrap constructors to preventing global pollution, required for the `pure` version 2536 options.unsafe - use the simple assignment of property instead of delete + defineProperty 2537 options.sham - add a flag to not completely full polyfills 2538 options.enumerable - export as enumerable property 2539 options.dontCallGetSet - prevent calling a getter on target 2540 options.name - the .name of the function if it does not match the key 2541 */ 2542 var _export = function (options, source) { 2543 var TARGET = options.target; 2544 var GLOBAL = options.global; 2545 var STATIC = options.stat; 2546 var FORCED, target, key, targetProperty, sourceProperty, descriptor; 2547 if (GLOBAL) { 2548 target = globalThis_1; 2549 } else if (STATIC) { 2550 target = globalThis_1[TARGET] || defineGlobalProperty(TARGET, {}); 2551 } else { 2552 target = globalThis_1[TARGET] && globalThis_1[TARGET].prototype; 2553 } 2554 if (target) for (key in source) { 2555 sourceProperty = source[key]; 2556 if (options.dontCallGetSet) { 2557 descriptor = getOwnPropertyDescriptor$1(target, key); 2558 targetProperty = descriptor && descriptor.value; 2559 } else targetProperty = target[key]; 2560 FORCED = isForced_1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced); 2561 // contained in target 2562 if (!FORCED && targetProperty !== undefined) { 2563 if (typeof sourceProperty == typeof targetProperty) continue; 2564 copyConstructorProperties(sourceProperty, targetProperty); 2565 } 2566 // add a flag to not completely full polyfills 2567 if (options.sham || targetProperty && targetProperty.sham) { 2568 createNonEnumerableProperty(sourceProperty, 'sham', true); 2569 } 2570 defineBuiltIn(target, key, sourceProperty, options); 2571 } 2572 }; 2573 2574 var correctPrototypeGetter = !fails(function () { 2575 function F() {/* empty */} 2576 F.prototype.constructor = null; 2577 // eslint-disable-next-line es/no-object-getprototypeof -- required for testing 2578 return Object.getPrototypeOf(new F()) !== F.prototype; 2579 }); 2580 2581 var IE_PROTO = sharedKey('IE_PROTO'); 2582 var $Object$3 = Object; 2583 var ObjectPrototype = $Object$3.prototype; 2584 2585 // `Object.getPrototypeOf` method 2586 // https://tc39.es/ecma262/#sec-object.getprototypeof 2587 // eslint-disable-next-line es/no-object-getprototypeof -- safe 2588 var objectGetPrototypeOf = correctPrototypeGetter ? $Object$3.getPrototypeOf : function (O) { 2589 var object = toObject(O); 2590 if (hasOwnProperty_1(object, IE_PROTO)) return object[IE_PROTO]; 2591 var constructor = object.constructor; 2592 if (isCallable(constructor) && object instanceof constructor) { 2593 return constructor.prototype; 2594 } 2595 return object instanceof $Object$3 ? ObjectPrototype : null; 2596 }; 2597 2598 var functionUncurryThisAccessor = function (object, key, method) { 2599 try { 2600 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 2601 return functionUncurryThis(aCallable(Object.getOwnPropertyDescriptor(object, key)[method])); 2602 } catch (error) {/* empty */} 2603 }; 2604 2605 var isPossiblePrototype = function (argument) { 2606 return isObject(argument) || argument === null; 2607 }; 2608 2609 var $String$3 = String; 2610 var $TypeError$6 = TypeError; 2611 var aPossiblePrototype = function (argument) { 2612 if (isPossiblePrototype(argument)) return argument; 2613 throw new $TypeError$6("Can't set " + $String$3(argument) + ' as a prototype'); 2614 }; 2615 2616 /* eslint-disable no-proto -- safe */ 2617 2618 2619 2620 2621 2622 // `Object.setPrototypeOf` method 2623 // https://tc39.es/ecma262/#sec-object.setprototypeof 2624 // Works with __proto__ only. Old v8 can't work with null proto objects. 2625 // eslint-disable-next-line es/no-object-setprototypeof -- safe 2626 var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? function () { 2627 var CORRECT_SETTER = false; 2628 var test = {}; 2629 var setter; 2630 try { 2631 setter = functionUncurryThisAccessor(Object.prototype, '__proto__', 'set'); 2632 setter(test, []); 2633 CORRECT_SETTER = test instanceof Array; 2634 } catch (error) {/* empty */} 2635 return function setPrototypeOf(O, proto) { 2636 requireObjectCoercible(O); 2637 aPossiblePrototype(proto); 2638 if (!isObject(O)) return O; 2639 if (CORRECT_SETTER) setter(O, proto);else O.__proto__ = proto; 2640 return O; 2641 }; 2642 }() : undefined); 2643 2644 // `Object.keys` method 2645 // https://tc39.es/ecma262/#sec-object.keys 2646 // eslint-disable-next-line es/no-object-keys -- safe 2647 var objectKeys = Object.keys || function keys(O) { 2648 return objectKeysInternal(O, enumBugKeys); 2649 }; 2650 2651 // `Object.defineProperties` method 2652 // https://tc39.es/ecma262/#sec-object.defineproperties 2653 // eslint-disable-next-line es/no-object-defineproperties -- safe 2654 var f$5 = descriptors && !v8PrototypeDefineBug ? Object.defineProperties : function defineProperties(O, Properties) { 2655 anObject(O); 2656 var props = toIndexedObject(Properties); 2657 var keys = objectKeys(Properties); 2658 var length = keys.length; 2659 var index = 0; 2660 var key; 2661 while (length > index) objectDefineProperty.f(O, key = keys[index++], props[key]); 2662 return O; 2663 }; 2664 2665 var objectDefineProperties = { 2666 f: f$5 2667 }; 2668 2669 var html = getBuiltIn('document', 'documentElement'); 2670 2671 /* global ActiveXObject -- old IE, WSH */ 2672 2673 2674 2675 2676 2677 2678 2679 var GT = '>'; 2680 var LT = '<'; 2681 var PROTOTYPE = 'prototype'; 2682 var SCRIPT = 'script'; 2683 var IE_PROTO$1 = sharedKey('IE_PROTO'); 2684 var EmptyConstructor = function () {/* empty */}; 2685 var scriptTag = function (content) { 2686 return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT; 2687 }; 2688 2689 // Create object with fake `null` prototype: use ActiveX Object with cleared prototype 2690 var NullProtoObjectViaActiveX = function (activeXDocument) { 2691 activeXDocument.write(scriptTag('')); 2692 activeXDocument.close(); 2693 var temp = activeXDocument.parentWindow.Object; 2694 // eslint-disable-next-line no-useless-assignment -- avoid memory leak 2695 activeXDocument = null; 2696 return temp; 2697 }; 2698 2699 // Create object with fake `null` prototype: use iframe Object with cleared prototype 2700 var NullProtoObjectViaIFrame = function () { 2701 // Thrash, waste and sodomy: IE GC bug 2702 var iframe = documentCreateElement('iframe'); 2703 var JS = 'java' + SCRIPT + ':'; 2704 var iframeDocument; 2705 iframe.style.display = 'none'; 2706 html.appendChild(iframe); 2707 // https://github.com/zloirock/core-js/issues/475 2708 iframe.src = String(JS); 2709 iframeDocument = iframe.contentWindow.document; 2710 iframeDocument.open(); 2711 iframeDocument.write(scriptTag('document.F=Object')); 2712 iframeDocument.close(); 2713 return iframeDocument.F; 2714 }; 2715 2716 // Check for document.domain and active x support 2717 // No need to use active x approach when document.domain is not set 2718 // see https://github.com/es-shims/es5-shim/issues/150 2719 // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346 2720 // avoid IE GC bug 2721 var activeXDocument; 2722 var NullProtoObject = function () { 2723 try { 2724 activeXDocument = new ActiveXObject('htmlfile'); 2725 } catch (error) {/* ignore */} 2726 NullProtoObject = typeof document != 'undefined' ? document.domain && activeXDocument ? NullProtoObjectViaActiveX(activeXDocument) // old IE 2727 : NullProtoObjectViaIFrame() : NullProtoObjectViaActiveX(activeXDocument); // WSH 2728 var length = enumBugKeys.length; 2729 while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]]; 2730 return NullProtoObject(); 2731 }; 2732 hiddenKeys[IE_PROTO$1] = true; 2733 2734 // `Object.create` method 2735 // https://tc39.es/ecma262/#sec-object.create 2736 // eslint-disable-next-line es/no-object-create -- safe 2737 var objectCreate = Object.create || function create(O, Properties) { 2738 var result; 2739 if (O !== null) { 2740 EmptyConstructor[PROTOTYPE] = anObject(O); 2741 result = new EmptyConstructor(); 2742 EmptyConstructor[PROTOTYPE] = null; 2743 // add "__proto__" for Object.getPrototypeOf polyfill 2744 result[IE_PROTO$1] = O; 2745 } else result = NullProtoObject(); 2746 return Properties === undefined ? result : objectDefineProperties.f(result, Properties); 2747 }; 2748 2749 // `InstallErrorCause` abstract operation 2750 // https://tc39.es/proposal-error-cause/#sec-errorobjects-install-error-cause 2751 var installErrorCause = function (O, options) { 2752 if (isObject(options) && 'cause' in options) { 2753 createNonEnumerableProperty(O, 'cause', options.cause); 2754 } 2755 }; 2756 2757 var $Error = Error; 2758 var replace = functionUncurryThis(''.replace); 2759 var TEST = function (arg) { 2760 return String(new $Error(arg).stack); 2761 }('zxcasd'); 2762 // eslint-disable-next-line redos/no-vulnerable, sonarjs/slow-regex -- safe 2763 var V8_OR_CHAKRA_STACK_ENTRY = /\n\s*at [^:]*:[^\n]*/; 2764 var IS_V8_OR_CHAKRA_STACK = V8_OR_CHAKRA_STACK_ENTRY.test(TEST); 2765 var errorStackClear = function (stack, dropEntries) { 2766 if (IS_V8_OR_CHAKRA_STACK && typeof stack == 'string' && !$Error.prepareStackTrace) { 2767 while (dropEntries--) stack = replace(stack, V8_OR_CHAKRA_STACK_ENTRY, ''); 2768 } 2769 return stack; 2770 }; 2771 2772 var errorStackInstallable = !fails(function () { 2773 var error = new Error('a'); 2774 if (!('stack' in error)) return true; 2775 // eslint-disable-next-line es/no-object-defineproperty -- safe 2776 Object.defineProperty(error, 'stack', createPropertyDescriptor(1, 7)); 2777 return error.stack !== 7; 2778 }); 2779 2780 // non-standard V8 2781 var captureStackTrace = Error.captureStackTrace; 2782 var errorStackInstall = function (error, C, stack, dropEntries) { 2783 if (errorStackInstallable) { 2784 if (captureStackTrace) captureStackTrace(error, C);else createNonEnumerableProperty(error, 'stack', errorStackClear(stack, dropEntries)); 2785 } 2786 }; 2787 2788 var functionUncurryThisClause = function (fn) { 2789 // Nashorn bug: 2790 // https://github.com/zloirock/core-js/issues/1128 2791 // https://github.com/zloirock/core-js/issues/1130 2792 if (classofRaw(fn) === 'Function') return functionUncurryThis(fn); 2793 }; 2794 2795 var bind = functionUncurryThisClause(functionUncurryThisClause.bind); 2796 2797 // optional / simple context binding 2798 var functionBindContext = function (fn, that) { 2799 aCallable(fn); 2800 return that === undefined ? fn : functionBindNative ? bind(fn, that) : function /* ...args */ 2801 () { 2802 return fn.apply(that, arguments); 2803 }; 2804 }; 2805 2806 var iterators = {}; 2807 2808 var ITERATOR = wellKnownSymbol('iterator'); 2809 var ArrayPrototype = Array.prototype; 2810 2811 // check on default Array iterator 2812 var isArrayIteratorMethod = function (it) { 2813 return it !== undefined && (iterators.Array === it || ArrayPrototype[ITERATOR] === it); 2814 }; 2815 2816 var TO_STRING_TAG = wellKnownSymbol('toStringTag'); 2817 var test = {}; 2818 test[TO_STRING_TAG] = 'z'; 2819 var toStringTagSupport = String(test) === '[object z]'; 2820 2821 var TO_STRING_TAG$1 = wellKnownSymbol('toStringTag'); 2822 var $Object$4 = Object; 2823 2824 // ES3 wrong here 2825 var CORRECT_ARGUMENTS = classofRaw(function () { 2826 return arguments; 2827 }()) === 'Arguments'; 2828 2829 // fallback for IE11 Script Access Denied error 2830 var tryGet = function (it, key) { 2831 try { 2832 return it[key]; 2833 } catch (error) {/* empty */} 2834 }; 2835 2836 // getting tag from ES6+ `Object.prototype.toString` 2837 var classof = toStringTagSupport ? classofRaw : function (it) { 2838 var O, tag, result; 2839 return it === undefined ? 'Undefined' : it === null ? 'Null' 2840 // @@toStringTag case 2841 : typeof (tag = tryGet(O = $Object$4(it), TO_STRING_TAG$1)) == 'string' ? tag 2842 // builtinTag case 2843 : CORRECT_ARGUMENTS ? classofRaw(O) 2844 // ES3 arguments fallback 2845 : (result = classofRaw(O)) === 'Object' && isCallable(O.callee) ? 'Arguments' : result; 2846 }; 2847 2848 var ITERATOR$1 = wellKnownSymbol('iterator'); 2849 var getIteratorMethod = function (it) { 2850 if (!isNullOrUndefined(it)) return getMethod(it, ITERATOR$1) || getMethod(it, '@@iterator') || iterators[classof(it)]; 2851 }; 2852 2853 var $TypeError$7 = TypeError; 2854 var getIterator = function (argument, usingIterator) { 2855 var iteratorMethod = arguments.length < 2 ? getIteratorMethod(argument) : usingIterator; 2856 if (aCallable(iteratorMethod)) return anObject(functionCall(iteratorMethod, argument)); 2857 throw new $TypeError$7(tryToString(argument) + ' is not iterable'); 2858 }; 2859 2860 var iteratorClose = function (iterator, kind, value) { 2861 var innerResult, innerError; 2862 anObject(iterator); 2863 try { 2864 innerResult = getMethod(iterator, 'return'); 2865 if (!innerResult) { 2866 if (kind === 'throw') throw value; 2867 return value; 2868 } 2869 innerResult = functionCall(innerResult, iterator); 2870 } catch (error) { 2871 innerError = true; 2872 innerResult = error; 2873 } 2874 if (kind === 'throw') throw value; 2875 if (innerError) throw innerResult; 2876 anObject(innerResult); 2877 return value; 2878 }; 2879 2880 var $TypeError$8 = TypeError; 2881 var Result = function (stopped, result) { 2882 this.stopped = stopped; 2883 this.result = result; 2884 }; 2885 var ResultPrototype = Result.prototype; 2886 var iterate = function (iterable, unboundFunction, options) { 2887 var that = options && options.that; 2888 var AS_ENTRIES = !!(options && options.AS_ENTRIES); 2889 var IS_RECORD = !!(options && options.IS_RECORD); 2890 var IS_ITERATOR = !!(options && options.IS_ITERATOR); 2891 var INTERRUPTED = !!(options && options.INTERRUPTED); 2892 var fn = functionBindContext(unboundFunction, that); 2893 var iterator, iterFn, index, length, result, next, step; 2894 var stop = function (condition) { 2895 if (iterator) iteratorClose(iterator, 'normal', condition); 2896 return new Result(true, condition); 2897 }; 2898 var callFn = function (value) { 2899 if (AS_ENTRIES) { 2900 anObject(value); 2901 return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]); 2902 } 2903 return INTERRUPTED ? fn(value, stop) : fn(value); 2904 }; 2905 if (IS_RECORD) { 2906 iterator = iterable.iterator; 2907 } else if (IS_ITERATOR) { 2908 iterator = iterable; 2909 } else { 2910 iterFn = getIteratorMethod(iterable); 2911 if (!iterFn) throw new $TypeError$8(tryToString(iterable) + ' is not iterable'); 2912 // optimisation for array iterators 2913 if (isArrayIteratorMethod(iterFn)) { 2914 for (index = 0, length = lengthOfArrayLike(iterable); length > index; index++) { 2915 result = callFn(iterable[index]); 2916 if (result && objectIsPrototypeOf(ResultPrototype, result)) return result; 2917 } 2918 return new Result(false); 2919 } 2920 iterator = getIterator(iterable, iterFn); 2921 } 2922 next = IS_RECORD ? iterable.next : iterator.next; 2923 while (!(step = functionCall(next, iterator)).done) { 2924 try { 2925 result = callFn(step.value); 2926 } catch (error) { 2927 iteratorClose(iterator, 'throw', error); 2928 } 2929 if (typeof result == 'object' && result && objectIsPrototypeOf(ResultPrototype, result)) return result; 2930 } 2931 return new Result(false); 2932 }; 2933 2934 var $String$4 = String; 2935 var toString_1 = function (argument) { 2936 if (classof(argument) === 'Symbol') throw new TypeError('Cannot convert a Symbol value to a string'); 2937 return $String$4(argument); 2938 }; 2939 2940 var normalizeStringArgument = function (argument, $default) { 2941 return argument === undefined ? arguments.length < 2 ? '' : $default : toString_1(argument); 2942 }; 2943 2944 var TO_STRING_TAG$2 = wellKnownSymbol('toStringTag'); 2945 var $Error$1 = Error; 2946 var push$1 = [].push; 2947 var $AggregateError = function AggregateError(errors, message /* , options */) { 2948 var isInstance = objectIsPrototypeOf(AggregateErrorPrototype, this); 2949 var that; 2950 if (objectSetPrototypeOf) { 2951 that = objectSetPrototypeOf(new $Error$1(), isInstance ? objectGetPrototypeOf(this) : AggregateErrorPrototype); 2952 } else { 2953 that = isInstance ? this : objectCreate(AggregateErrorPrototype); 2954 createNonEnumerableProperty(that, TO_STRING_TAG$2, 'Error'); 2955 } 2956 if (message !== undefined) createNonEnumerableProperty(that, 'message', normalizeStringArgument(message)); 2957 errorStackInstall(that, $AggregateError, that.stack, 1); 2958 if (arguments.length > 2) installErrorCause(that, arguments[2]); 2959 var errorsArray = []; 2960 iterate(errors, push$1, { 2961 that: errorsArray 2962 }); 2963 createNonEnumerableProperty(that, 'errors', errorsArray); 2964 return that; 2965 }; 2966 if (objectSetPrototypeOf) objectSetPrototypeOf($AggregateError, $Error$1);else copyConstructorProperties($AggregateError, $Error$1, { 2967 name: true 2968 }); 2969 var AggregateErrorPrototype = $AggregateError.prototype = objectCreate($Error$1.prototype, { 2970 constructor: createPropertyDescriptor(1, $AggregateError), 2971 message: createPropertyDescriptor(1, ''), 2972 name: createPropertyDescriptor(1, 'AggregateError') 2973 }); 2974 2975 // `AggregateError` constructor 2976 // https://tc39.es/ecma262/#sec-aggregate-error-constructor 2977 _export({ 2978 global: true, 2979 constructor: true, 2980 arity: 2 2981 }, { 2982 AggregateError: $AggregateError 2983 }); 2984 2985 var defineProperty$1 = objectDefineProperty.f; 2986 var UNSCOPABLES = wellKnownSymbol('unscopables'); 2987 var ArrayPrototype$1 = Array.prototype; 2988 2989 // Array.prototype[@@unscopables] 2990 // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables 2991 if (ArrayPrototype$1[UNSCOPABLES] === undefined) { 2992 defineProperty$1(ArrayPrototype$1, UNSCOPABLES, { 2993 configurable: true, 2994 value: objectCreate(null) 2995 }); 2996 } 2997 2998 // add a key to Array.prototype[@@unscopables] 2999 var addToUnscopables = function (key) { 3000 ArrayPrototype$1[UNSCOPABLES][key] = true; 3001 }; 3002 3003 // `Array.prototype.at` method 3004 // https://tc39.es/ecma262/#sec-array.prototype.at 3005 _export({ 3006 target: 'Array', 3007 proto: true 3008 }, { 3009 at: function at(index) { 3010 var O = toObject(this); 3011 var len = lengthOfArrayLike(O); 3012 var relativeIndex = toIntegerOrInfinity(index); 3013 var k = relativeIndex >= 0 ? relativeIndex : len + relativeIndex; 3014 return k < 0 || k >= len ? undefined : O[k]; 3015 } 3016 }); 3017 addToUnscopables('at'); 3018 3019 // eslint-disable-next-line es/no-typed-arrays -- safe 3020 var arrayBufferBasicDetection = typeof ArrayBuffer != 'undefined' && typeof DataView != 'undefined'; 3021 3022 var defineBuiltInAccessor = function (target, name, descriptor) { 3023 if (descriptor.get) makeBuiltIn_1(descriptor.get, name, { 3024 getter: true 3025 }); 3026 if (descriptor.set) makeBuiltIn_1(descriptor.set, name, { 3027 setter: true 3028 }); 3029 return objectDefineProperty.f(target, name, descriptor); 3030 }; 3031 3032 var defineBuiltIns = function (target, src, options) { 3033 for (var key in src) defineBuiltIn(target, key, src[key], options); 3034 return target; 3035 }; 3036 3037 var $TypeError$9 = TypeError; 3038 var anInstance = function (it, Prototype) { 3039 if (objectIsPrototypeOf(Prototype, it)) return it; 3040 throw new $TypeError$9('Incorrect invocation'); 3041 }; 3042 3043 var $RangeError = RangeError; 3044 3045 // `ToIndex` abstract operation 3046 // https://tc39.es/ecma262/#sec-toindex 3047 var toIndex = function (it) { 3048 if (it === undefined) return 0; 3049 var number = toIntegerOrInfinity(it); 3050 var length = toLength(number); 3051 if (number !== length) throw new $RangeError('Wrong length or index'); 3052 return length; 3053 }; 3054 3055 // `Math.sign` method implementation 3056 // https://tc39.es/ecma262/#sec-math.sign 3057 // eslint-disable-next-line es/no-math-sign -- safe 3058 var mathSign = Math.sign || function sign(x) { 3059 var n = +x; 3060 // eslint-disable-next-line no-self-compare -- NaN check 3061 return n === 0 || n !== n ? n : n < 0 ? -1 : 1; 3062 }; 3063 3064 var EPSILON = 2.220446049250313e-16; // Number.EPSILON 3065 var INVERSE_EPSILON = 1 / EPSILON; 3066 var mathRoundTiesToEven = function (n) { 3067 return n + INVERSE_EPSILON - INVERSE_EPSILON; 3068 }; 3069 3070 var abs = Math.abs; 3071 var EPSILON$1 = 2.220446049250313e-16; // Number.EPSILON 3072 3073 var mathFloatRound = function (x, FLOAT_EPSILON, FLOAT_MAX_VALUE, FLOAT_MIN_VALUE) { 3074 var n = +x; 3075 var absolute = abs(n); 3076 var s = mathSign(n); 3077 if (absolute < FLOAT_MIN_VALUE) return s * mathRoundTiesToEven(absolute / FLOAT_MIN_VALUE / FLOAT_EPSILON) * FLOAT_MIN_VALUE * FLOAT_EPSILON; 3078 var a = (1 + FLOAT_EPSILON / EPSILON$1) * absolute; 3079 var result = a - (a - absolute); 3080 // eslint-disable-next-line no-self-compare -- NaN check 3081 if (result > FLOAT_MAX_VALUE || result !== result) return s * Infinity; 3082 return s * result; 3083 }; 3084 3085 var FLOAT32_EPSILON = 1.1920928955078125e-7; // 2 ** -23; 3086 var FLOAT32_MAX_VALUE = 3.4028234663852886e+38; // 2 ** 128 - 2 ** 104 3087 var FLOAT32_MIN_VALUE = 1.1754943508222875e-38; // 2 ** -126; 3088 3089 // `Math.fround` method implementation 3090 // https://tc39.es/ecma262/#sec-math.fround 3091 // eslint-disable-next-line es/no-math-fround -- safe 3092 var mathFround = Math.fround || function fround(x) { 3093 return mathFloatRound(x, FLOAT32_EPSILON, FLOAT32_MAX_VALUE, FLOAT32_MIN_VALUE); 3094 }; 3095 3096 // IEEE754 conversions based on https://github.com/feross/ieee754 3097 var $Array = Array; 3098 var abs$1 = Math.abs; 3099 var pow = Math.pow; 3100 var floor$1 = Math.floor; 3101 var log = Math.log; 3102 var LN2 = Math.LN2; 3103 var pack = function (number, mantissaLength, bytes) { 3104 var buffer = $Array(bytes); 3105 var exponentLength = bytes * 8 - mantissaLength - 1; 3106 var eMax = (1 << exponentLength) - 1; 3107 var eBias = eMax >> 1; 3108 var rt = mantissaLength === 23 ? pow(2, -24) - pow(2, -77) : 0; 3109 var sign = number < 0 || number === 0 && 1 / number < 0 ? 1 : 0; 3110 var index = 0; 3111 var exponent, mantissa, c; 3112 number = abs$1(number); 3113 // eslint-disable-next-line no-self-compare -- NaN check 3114 if (number !== number || number === Infinity) { 3115 // eslint-disable-next-line no-self-compare -- NaN check 3116 mantissa = number !== number ? 1 : 0; 3117 exponent = eMax; 3118 } else { 3119 exponent = floor$1(log(number) / LN2); 3120 c = pow(2, -exponent); 3121 if (number * c < 1) { 3122 exponent--; 3123 c *= 2; 3124 } 3125 if (exponent + eBias >= 1) { 3126 number += rt / c; 3127 } else { 3128 number += rt * pow(2, 1 - eBias); 3129 } 3130 if (number * c >= 2) { 3131 exponent++; 3132 c /= 2; 3133 } 3134 if (exponent + eBias >= eMax) { 3135 mantissa = 0; 3136 exponent = eMax; 3137 } else if (exponent + eBias >= 1) { 3138 mantissa = (number * c - 1) * pow(2, mantissaLength); 3139 exponent += eBias; 3140 } else { 3141 mantissa = number * pow(2, eBias - 1) * pow(2, mantissaLength); 3142 exponent = 0; 3143 } 3144 } 3145 while (mantissaLength >= 8) { 3146 buffer[index++] = mantissa & 255; 3147 mantissa /= 256; 3148 mantissaLength -= 8; 3149 } 3150 exponent = exponent << mantissaLength | mantissa; 3151 exponentLength += mantissaLength; 3152 while (exponentLength > 0) { 3153 buffer[index++] = exponent & 255; 3154 exponent /= 256; 3155 exponentLength -= 8; 3156 } 3157 buffer[index - 1] |= sign * 128; 3158 return buffer; 3159 }; 3160 var unpack = function (buffer, mantissaLength) { 3161 var bytes = buffer.length; 3162 var exponentLength = bytes * 8 - mantissaLength - 1; 3163 var eMax = (1 << exponentLength) - 1; 3164 var eBias = eMax >> 1; 3165 var nBits = exponentLength - 7; 3166 var index = bytes - 1; 3167 var sign = buffer[index--]; 3168 var exponent = sign & 127; 3169 var mantissa; 3170 sign >>= 7; 3171 while (nBits > 0) { 3172 exponent = exponent * 256 + buffer[index--]; 3173 nBits -= 8; 3174 } 3175 mantissa = exponent & (1 << -nBits) - 1; 3176 exponent >>= -nBits; 3177 nBits += mantissaLength; 3178 while (nBits > 0) { 3179 mantissa = mantissa * 256 + buffer[index--]; 3180 nBits -= 8; 3181 } 3182 if (exponent === 0) { 3183 exponent = 1 - eBias; 3184 } else if (exponent === eMax) { 3185 return mantissa ? NaN : sign ? -Infinity : Infinity; 3186 } else { 3187 mantissa += pow(2, mantissaLength); 3188 exponent -= eBias; 3189 } 3190 return (sign ? -1 : 1) * mantissa * pow(2, exponent - mantissaLength); 3191 }; 3192 var ieee754 = { 3193 pack: pack, 3194 unpack: unpack 3195 }; 3196 3197 // `Array.prototype.fill` method implementation 3198 // https://tc39.es/ecma262/#sec-array.prototype.fill 3199 var arrayFill = function fill(value /* , start = 0, end = @length */) { 3200 var O = toObject(this); 3201 var length = lengthOfArrayLike(O); 3202 var argumentsLength = arguments.length; 3203 var index = toAbsoluteIndex(argumentsLength > 1 ? arguments[1] : undefined, length); 3204 var end = argumentsLength > 2 ? arguments[2] : undefined; 3205 var endPos = end === undefined ? length : toAbsoluteIndex(end, length); 3206 while (endPos > index) O[index++] = value; 3207 return O; 3208 }; 3209 3210 var arraySlice = functionUncurryThis([].slice); 3211 3212 // makes subclassing work correct for wrapped built-ins 3213 var inheritIfRequired = function ($this, dummy, Wrapper) { 3214 var NewTarget, NewTargetPrototype; 3215 if ( 3216 // it can work only with native `setPrototypeOf` 3217 objectSetPrototypeOf && 3218 // we haven't completely correct pre-ES6 way for getting `new.target`, so use this 3219 isCallable(NewTarget = dummy.constructor) && NewTarget !== Wrapper && isObject(NewTargetPrototype = NewTarget.prototype) && NewTargetPrototype !== Wrapper.prototype) objectSetPrototypeOf($this, NewTargetPrototype); 3220 return $this; 3221 }; 3222 3223 var defineProperty$2 = objectDefineProperty.f; 3224 3225 3226 var TO_STRING_TAG$3 = wellKnownSymbol('toStringTag'); 3227 var setToStringTag = function (target, TAG, STATIC) { 3228 if (target && !STATIC) target = target.prototype; 3229 if (target && !hasOwnProperty_1(target, TO_STRING_TAG$3)) { 3230 defineProperty$2(target, TO_STRING_TAG$3, { 3231 configurable: true, 3232 value: TAG 3233 }); 3234 } 3235 }; 3236 3237 var PROPER_FUNCTION_NAME = functionName.PROPER; 3238 var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE; 3239 var ARRAY_BUFFER = 'ArrayBuffer'; 3240 var DATA_VIEW = 'DataView'; 3241 var PROTOTYPE$1 = 'prototype'; 3242 var WRONG_LENGTH = 'Wrong length'; 3243 var WRONG_INDEX = 'Wrong index'; 3244 var getInternalArrayBufferState = internalState.getterFor(ARRAY_BUFFER); 3245 var getInternalDataViewState = internalState.getterFor(DATA_VIEW); 3246 var setInternalState = internalState.set; 3247 var NativeArrayBuffer = globalThis_1[ARRAY_BUFFER]; 3248 var $ArrayBuffer = NativeArrayBuffer; 3249 var ArrayBufferPrototype = $ArrayBuffer && $ArrayBuffer[PROTOTYPE$1]; 3250 var $DataView = globalThis_1[DATA_VIEW]; 3251 var DataViewPrototype = $DataView && $DataView[PROTOTYPE$1]; 3252 var ObjectPrototype$1 = Object.prototype; 3253 var Array$1 = globalThis_1.Array; 3254 var RangeError$1 = globalThis_1.RangeError; 3255 var fill = functionUncurryThis(arrayFill); 3256 var reverse = functionUncurryThis([].reverse); 3257 var packIEEE754 = ieee754.pack; 3258 var unpackIEEE754 = ieee754.unpack; 3259 var packInt8 = function (number) { 3260 return [number & 0xFF]; 3261 }; 3262 var packInt16 = function (number) { 3263 return [number & 0xFF, number >> 8 & 0xFF]; 3264 }; 3265 var packInt32 = function (number) { 3266 return [number & 0xFF, number >> 8 & 0xFF, number >> 16 & 0xFF, number >> 24 & 0xFF]; 3267 }; 3268 var unpackInt32 = function (buffer) { 3269 return buffer[3] << 24 | buffer[2] << 16 | buffer[1] << 8 | buffer[0]; 3270 }; 3271 var packFloat32 = function (number) { 3272 return packIEEE754(mathFround(number), 23, 4); 3273 }; 3274 var packFloat64 = function (number) { 3275 return packIEEE754(number, 52, 8); 3276 }; 3277 var addGetter = function (Constructor, key, getInternalState) { 3278 defineBuiltInAccessor(Constructor[PROTOTYPE$1], key, { 3279 configurable: true, 3280 get: function () { 3281 return getInternalState(this)[key]; 3282 } 3283 }); 3284 }; 3285 var get$1 = function (view, count, index, isLittleEndian) { 3286 var store = getInternalDataViewState(view); 3287 var intIndex = toIndex(index); 3288 var boolIsLittleEndian = !!isLittleEndian; 3289 if (intIndex + count > store.byteLength) throw new RangeError$1(WRONG_INDEX); 3290 var bytes = store.bytes; 3291 var start = intIndex + store.byteOffset; 3292 var pack = arraySlice(bytes, start, start + count); 3293 return boolIsLittleEndian ? pack : reverse(pack); 3294 }; 3295 var set$1 = function (view, count, index, conversion, value, isLittleEndian) { 3296 var store = getInternalDataViewState(view); 3297 var intIndex = toIndex(index); 3298 var pack = conversion(+value); 3299 var boolIsLittleEndian = !!isLittleEndian; 3300 if (intIndex + count > store.byteLength) throw new RangeError$1(WRONG_INDEX); 3301 var bytes = store.bytes; 3302 var start = intIndex + store.byteOffset; 3303 for (var i = 0; i < count; i++) bytes[start + i] = pack[boolIsLittleEndian ? i : count - i - 1]; 3304 }; 3305 if (!arrayBufferBasicDetection) { 3306 $ArrayBuffer = function ArrayBuffer(length) { 3307 anInstance(this, ArrayBufferPrototype); 3308 var byteLength = toIndex(length); 3309 setInternalState(this, { 3310 type: ARRAY_BUFFER, 3311 bytes: fill(Array$1(byteLength), 0), 3312 byteLength: byteLength 3313 }); 3314 if (!descriptors) { 3315 this.byteLength = byteLength; 3316 this.detached = false; 3317 } 3318 }; 3319 ArrayBufferPrototype = $ArrayBuffer[PROTOTYPE$1]; 3320 $DataView = function DataView(buffer, byteOffset, byteLength) { 3321 anInstance(this, DataViewPrototype); 3322 anInstance(buffer, ArrayBufferPrototype); 3323 var bufferState = getInternalArrayBufferState(buffer); 3324 var bufferLength = bufferState.byteLength; 3325 var offset = toIntegerOrInfinity(byteOffset); 3326 if (offset < 0 || offset > bufferLength) throw new RangeError$1('Wrong offset'); 3327 byteLength = byteLength === undefined ? bufferLength - offset : toLength(byteLength); 3328 if (offset + byteLength > bufferLength) throw new RangeError$1(WRONG_LENGTH); 3329 setInternalState(this, { 3330 type: DATA_VIEW, 3331 buffer: buffer, 3332 byteLength: byteLength, 3333 byteOffset: offset, 3334 bytes: bufferState.bytes 3335 }); 3336 if (!descriptors) { 3337 this.buffer = buffer; 3338 this.byteLength = byteLength; 3339 this.byteOffset = offset; 3340 } 3341 }; 3342 DataViewPrototype = $DataView[PROTOTYPE$1]; 3343 if (descriptors) { 3344 addGetter($ArrayBuffer, 'byteLength', getInternalArrayBufferState); 3345 addGetter($DataView, 'buffer', getInternalDataViewState); 3346 addGetter($DataView, 'byteLength', getInternalDataViewState); 3347 addGetter($DataView, 'byteOffset', getInternalDataViewState); 3348 } 3349 defineBuiltIns(DataViewPrototype, { 3350 getInt8: function getInt8(byteOffset) { 3351 return get$1(this, 1, byteOffset)[0] << 24 >> 24; 3352 }, 3353 getUint8: function getUint8(byteOffset) { 3354 return get$1(this, 1, byteOffset)[0]; 3355 }, 3356 getInt16: function getInt16(byteOffset /* , littleEndian */) { 3357 var bytes = get$1(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : false); 3358 return (bytes[1] << 8 | bytes[0]) << 16 >> 16; 3359 }, 3360 getUint16: function getUint16(byteOffset /* , littleEndian */) { 3361 var bytes = get$1(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : false); 3362 return bytes[1] << 8 | bytes[0]; 3363 }, 3364 getInt32: function getInt32(byteOffset /* , littleEndian */) { 3365 return unpackInt32(get$1(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : false)); 3366 }, 3367 getUint32: function getUint32(byteOffset /* , littleEndian */) { 3368 return unpackInt32(get$1(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : false)) >>> 0; 3369 }, 3370 getFloat32: function getFloat32(byteOffset /* , littleEndian */) { 3371 return unpackIEEE754(get$1(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : false), 23); 3372 }, 3373 getFloat64: function getFloat64(byteOffset /* , littleEndian */) { 3374 return unpackIEEE754(get$1(this, 8, byteOffset, arguments.length > 1 ? arguments[1] : false), 52); 3375 }, 3376 setInt8: function setInt8(byteOffset, value) { 3377 set$1(this, 1, byteOffset, packInt8, value); 3378 }, 3379 setUint8: function setUint8(byteOffset, value) { 3380 set$1(this, 1, byteOffset, packInt8, value); 3381 }, 3382 setInt16: function setInt16(byteOffset, value /* , littleEndian */) { 3383 set$1(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : false); 3384 }, 3385 setUint16: function setUint16(byteOffset, value /* , littleEndian */) { 3386 set$1(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : false); 3387 }, 3388 setInt32: function setInt32(byteOffset, value /* , littleEndian */) { 3389 set$1(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : false); 3390 }, 3391 setUint32: function setUint32(byteOffset, value /* , littleEndian */) { 3392 set$1(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : false); 3393 }, 3394 setFloat32: function setFloat32(byteOffset, value /* , littleEndian */) { 3395 set$1(this, 4, byteOffset, packFloat32, value, arguments.length > 2 ? arguments[2] : false); 3396 }, 3397 setFloat64: function setFloat64(byteOffset, value /* , littleEndian */) { 3398 set$1(this, 8, byteOffset, packFloat64, value, arguments.length > 2 ? arguments[2] : false); 3399 } 3400 }); 3401 } else { 3402 var INCORRECT_ARRAY_BUFFER_NAME = PROPER_FUNCTION_NAME && NativeArrayBuffer.name !== ARRAY_BUFFER; 3403 /* eslint-disable no-new, sonarjs/inconsistent-function-call -- required for testing */ 3404 if (!fails(function () { 3405 NativeArrayBuffer(1); 3406 }) || !fails(function () { 3407 new NativeArrayBuffer(-1); 3408 }) || fails(function () { 3409 new NativeArrayBuffer(); 3410 new NativeArrayBuffer(1.5); 3411 new NativeArrayBuffer(NaN); 3412 return NativeArrayBuffer.length !== 1 || INCORRECT_ARRAY_BUFFER_NAME && !CONFIGURABLE_FUNCTION_NAME; 3413 })) { 3414 /* eslint-enable no-new, sonarjs/inconsistent-function-call -- required for testing */ 3415 $ArrayBuffer = function ArrayBuffer(length) { 3416 anInstance(this, ArrayBufferPrototype); 3417 return inheritIfRequired(new NativeArrayBuffer(toIndex(length)), this, $ArrayBuffer); 3418 }; 3419 $ArrayBuffer[PROTOTYPE$1] = ArrayBufferPrototype; 3420 ArrayBufferPrototype.constructor = $ArrayBuffer; 3421 copyConstructorProperties($ArrayBuffer, NativeArrayBuffer); 3422 } else if (INCORRECT_ARRAY_BUFFER_NAME && CONFIGURABLE_FUNCTION_NAME) { 3423 createNonEnumerableProperty(NativeArrayBuffer, 'name', ARRAY_BUFFER); 3424 } 3425 3426 // WebKit bug - the same parent prototype for typed arrays and data view 3427 if (objectSetPrototypeOf && objectGetPrototypeOf(DataViewPrototype) !== ObjectPrototype$1) { 3428 objectSetPrototypeOf(DataViewPrototype, ObjectPrototype$1); 3429 } 3430 3431 // iOS Safari 7.x bug 3432 var testView = new $DataView(new $ArrayBuffer(2)); 3433 var $setInt8 = functionUncurryThis(DataViewPrototype.setInt8); 3434 testView.setInt8(0, 2147483648); 3435 testView.setInt8(1, 2147483649); 3436 if (testView.getInt8(0) || !testView.getInt8(1)) defineBuiltIns(DataViewPrototype, { 3437 setInt8: function setInt8(byteOffset, value) { 3438 $setInt8(this, byteOffset, value << 24 >> 24); 3439 }, 3440 setUint8: function setUint8(byteOffset, value) { 3441 $setInt8(this, byteOffset, value << 24 >> 24); 3442 } 3443 }, { 3444 unsafe: true 3445 }); 3446 } 3447 setToStringTag($ArrayBuffer, ARRAY_BUFFER); 3448 setToStringTag($DataView, DATA_VIEW); 3449 var arrayBuffer = { 3450 ArrayBuffer: $ArrayBuffer, 3451 DataView: $DataView 3452 }; 3453 3454 var ArrayBuffer$1 = arrayBuffer.ArrayBuffer; 3455 var DataView$1 = arrayBuffer.DataView; 3456 var DataViewPrototype$1 = DataView$1.prototype; 3457 var nativeArrayBufferSlice = functionUncurryThisClause(ArrayBuffer$1.prototype.slice); 3458 var getUint8 = functionUncurryThisClause(DataViewPrototype$1.getUint8); 3459 var setUint8 = functionUncurryThisClause(DataViewPrototype$1.setUint8); 3460 var INCORRECT_SLICE = fails(function () {
3461 return !new ArrayBuffer$1(2).slice(1, undefined).byteLength; 3462 }); 3463 3464 // `ArrayBuffer.prototype.slice` method 3465 // https://tc39.es/ecma262/#sec-arraybuffer.prototype.slice 3466 _export({ 3467 target: 'ArrayBuffer', 3468 proto: true, 3469 unsafe: true, 3470 forced: INCORRECT_SLICE 3471 }, { 3472 slice: function slice(start, end) { 3473 if (nativeArrayBufferSlice && end === undefined) { 3474 return nativeArrayBufferSlice(anObject(this), start); // FF fix 3475 } 3476 3477 var length = anObject(this).byteLength; 3478 var first = toAbsoluteIndex(start, length); 3479 var fin = toAbsoluteIndex(end === undefined ? length : end, length); 3480 var result = new ArrayBuffer$1(toLength(fin - first)); 3481 var viewSource = new DataView$1(this); 3482 var viewTarget = new DataView$1(result); 3483 var index = 0; 3484 while (first < fin) { 3485 setUint8(viewTarget, index++, getUint8(viewSource, first++)); 3486 } 3487 return result; 3488 } 3489 }); 3490 3491 var createProperty = function (object, key, value) { 3492 if (descriptors) objectDefineProperty.f(object, key, createPropertyDescriptor(0, value));else object[key] = value; 3493 }; 3494 3495 // `Object.fromEntries` method 3496 // https://tc39.es/ecma262/#sec-object.fromentries 3497 _export({ 3498 target: 'Object', 3499 stat: true 3500 }, { 3501 fromEntries: function fromEntries(iterable) { 3502 var obj = {}; 3503 iterate(iterable, function (k, v) { 3504 createProperty(obj, k, v); 3505 }, { 3506 AS_ENTRIES: true 3507 }); 3508 return obj; 3509 } 3510 }); 3511 3512 // `Object.hasOwn` method 3513 // https://tc39.es/ecma262/#sec-object.hasown 3514 _export({ 3515 target: 'Object', 3516 stat: true 3517 }, { 3518 hasOwn: hasOwnProperty_1 3519 }); 3520 3521 var $TypeError$a = TypeError; 3522 var PromiseCapability = function (C) { 3523 var resolve, reject; 3524 this.promise = new C(function ($$resolve, $$reject) { 3525 if (resolve !== undefined || reject !== undefined) throw new $TypeError$a('Bad Promise constructor'); 3526 resolve = $$resolve; 3527 reject = $$reject; 3528 }); 3529 this.resolve = aCallable(resolve); 3530 this.reject = aCallable(reject); 3531 }; 3532 3533 // `NewPromiseCapability` abstract operation 3534 // https://tc39.es/ecma262/#sec-newpromisecapability 3535 var f$6 = function (C) { 3536 return new PromiseCapability(C); 3537 }; 3538 3539 var newPromiseCapability = { 3540 f: f$6 3541 }; 3542 3543 var perform = function (exec) { 3544 try { 3545 return { 3546 error: false, 3547 value: exec() 3548 }; 3549 } catch (error) { 3550 return { 3551 error: true, 3552 value: error 3553 }; 3554 } 3555 }; 3556 3557 var promiseNativeConstructor = globalThis_1.Promise; 3558 3559 var ITERATOR$2 = wellKnownSymbol('iterator'); 3560 var SAFE_CLOSING = false; 3561 var checkCorrectnessOfIteration = function (exec, SKIP_CLOSING) { 3562 try { 3563 if (!SKIP_CLOSING && !SAFE_CLOSING) return false; 3564 } catch (error) { 3565 return false; 3566 } // workaround of old WebKit + `eval` bug 3567 var ITERATION_SUPPORT = false; 3568 try { 3569 var object = {}; 3570 object[ITERATOR$2] = function () { 3571 return { 3572 next: function () { 3573 return { 3574 done: ITERATION_SUPPORT = true 3575 }; 3576 } 3577 }; 3578 }; 3579 exec(object); 3580 } catch (error) {/* empty */} 3581 return ITERATION_SUPPORT; 3582 }; 3583 3584 /* global Bun, Deno -- detection */ 3585 3586 3587 3588 var userAgentStartsWith = function (string) { 3589 return environmentUserAgent.slice(0, string.length) === string; 3590 }; 3591 var environment = function () { 3592 if (userAgentStartsWith('Bun/')) return 'BUN'; 3593 if (userAgentStartsWith('Cloudflare-Workers')) return 'CLOUDFLARE'; 3594 if (userAgentStartsWith('Deno/')) return 'DENO'; 3595 if (userAgentStartsWith('Node.js/')) return 'NODE'; 3596 if (globalThis_1.Bun && typeof Bun.version == 'string') return 'BUN'; 3597 if (globalThis_1.Deno && typeof Deno.version == 'object') return 'DENO'; 3598 if (classofRaw(globalThis_1.process) === 'process') return 'NODE'; 3599 if (globalThis_1.window && globalThis_1.document) return 'BROWSER'; 3600 return 'REST'; 3601 }(); 3602 3603 var NativePromisePrototype = promiseNativeConstructor && promiseNativeConstructor.prototype; 3604 var SPECIES = wellKnownSymbol('species'); 3605 var SUBCLASSING = false; 3606 var NATIVE_PROMISE_REJECTION_EVENT = isCallable(globalThis_1.PromiseRejectionEvent); 3607 var FORCED_PROMISE_CONSTRUCTOR = isForced_1('Promise', function () { 3608 var PROMISE_CONSTRUCTOR_SOURCE = inspectSource(promiseNativeConstructor); 3609 var GLOBAL_CORE_JS_PROMISE = PROMISE_CONSTRUCTOR_SOURCE !== String(promiseNativeConstructor); 3610 // V8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables 3611 // https://bugs.chromium.org/p/chromium/issues/detail?id=830565 3612 // We can't detect it synchronously, so just check versions 3613 if (!GLOBAL_CORE_JS_PROMISE && environmentV8Version === 66) return true; 3614 // We can't use @@species feature detection in V8 since it causes 3615 // deoptimization and performance degradation 3616 // https://github.com/zloirock/core-js/issues/679 3617 if (!environmentV8Version || environmentV8Version < 51 || !/native code/.test(PROMISE_CONSTRUCTOR_SOURCE)) { 3618 // Detect correctness of subclassing with @@species support 3619 var promise = new promiseNativeConstructor(function (resolve) { 3620 resolve(1); 3621 }); 3622 var FakePromise = function (exec) { 3623 exec(function () {/* empty */}, function () {/* empty */}); 3624 }; 3625 var constructor = promise.constructor = {}; 3626 constructor[SPECIES] = FakePromise; 3627 SUBCLASSING = promise.then(function () {/* empty */}) instanceof FakePromise; 3628 if (!SUBCLASSING) return true; 3629 // Unhandled rejections tracking support, NodeJS Promise without it fails @@species test 3630 } 3631 return !GLOBAL_CORE_JS_PROMISE && (environment === 'BROWSER' || environment === 'DENO') && !NATIVE_PROMISE_REJECTION_EVENT; 3632 }); 3633 var promiseConstructorDetection = { 3634 CONSTRUCTOR: FORCED_PROMISE_CONSTRUCTOR, 3635 REJECTION_EVENT: NATIVE_PROMISE_REJECTION_EVENT, 3636 SUBCLASSING: SUBCLASSING 3637 }; 3638 3639 var FORCED_PROMISE_CONSTRUCTOR$1 = promiseConstructorDetection.CONSTRUCTOR; 3640 var promiseStaticsIncorrectIteration = FORCED_PROMISE_CONSTRUCTOR$1 || !checkCorrectnessOfIteration(function (iterable) { 3641 promiseNativeConstructor.all(iterable).then(undefined, function () {/* empty */}); 3642 }); 3643 3644 // `Promise.allSettled` method 3645 // https://tc39.es/ecma262/#sec-promise.allsettled 3646 _export({ 3647 target: 'Promise', 3648 stat: true, 3649 forced: promiseStaticsIncorrectIteration 3650 }, { 3651 allSettled: function allSettled(iterable) { 3652 var C = this; 3653 var capability = newPromiseCapability.f(C); 3654 var resolve = capability.resolve; 3655 var reject = capability.reject; 3656 var result = perform(function () { 3657 var promiseResolve = aCallable(C.resolve); 3658 var values = []; 3659 var counter = 0; 3660 var remaining = 1; 3661 iterate(iterable, function (promise) { 3662 var index = counter++; 3663 var alreadyCalled = false;
vendor: 17,489 bytes, lines 3664-4180
3664 remaining++; 3665 functionCall(promiseResolve, C, promise).then(function (value) { 3666 if (alreadyCalled) return; 3667 alreadyCalled = true; 3668 values[index] = { 3669 status: 'fulfilled', 3670 value: value 3671 }; 3672 --remaining || resolve(values); 3673 }, function (error) { 3674 if (alreadyCalled) return; 3675 alreadyCalled = true; 3676 values[index] = { 3677 status: 'rejected', 3678 reason: error 3679 }; 3680 --remaining || resolve(values); 3681 }); 3682 }); 3683 --remaining || resolve(values); 3684 }); 3685 if (result.error) reject(result.value); 3686 return capability.promise; 3687 } 3688 }); 3689 3690 var PROMISE_ANY_ERROR = 'No one promise resolved'; 3691 3692 // `Promise.any` method 3693 // https://tc39.es/ecma262/#sec-promise.any 3694 _export({ 3695 target: 'Promise', 3696 stat: true, 3697 forced: promiseStaticsIncorrectIteration 3698 }, { 3699 any: function any(iterable) { 3700 var C = this; 3701 var AggregateError = getBuiltIn('AggregateError'); 3702 var capability = newPromiseCapability.f(C); 3703 var resolve = capability.resolve; 3704 var reject = capability.reject; 3705 var result = perform(function () { 3706 var promiseResolve = aCallable(C.resolve); 3707 var errors = []; 3708 var counter = 0; 3709 var remaining = 1; 3710 var alreadyResolved = false; 3711 iterate(iterable, function (promise) { 3712 var index = counter++; 3713 var alreadyRejected = false; 3714 remaining++; 3715 functionCall(promiseResolve, C, promise).then(function (value) { 3716 if (alreadyRejected || alreadyResolved) return; 3717 alreadyResolved = true; 3718 resolve(value); 3719 }, function (error) { 3720 if (alreadyRejected || alreadyResolved) return; 3721 alreadyRejected = true; 3722 errors[index] = error; 3723 --remaining || reject(new AggregateError(errors, PROMISE_ANY_ERROR)); 3724 }); 3725 }); 3726 --remaining || reject(new AggregateError(errors, PROMISE_ANY_ERROR)); 3727 }); 3728 if (result.error) reject(result.value); 3729 return capability.promise; 3730 } 3731 }); 3732 3733 var noop = function () {/* empty */}; 3734 var construct = getBuiltIn('Reflect', 'construct'); 3735 var constructorRegExp = /^\s*(?:class|function)\b/; 3736 var exec = functionUncurryThis(constructorRegExp.exec); 3737 var INCORRECT_TO_STRING = !constructorRegExp.test(noop); 3738 var isConstructorModern = function isConstructor(argument) { 3739 if (!isCallable(argument)) return false; 3740 try { 3741 construct(noop, [], argument); 3742 return true; 3743 } catch (error) { 3744 return false; 3745 } 3746 }; 3747 var isConstructorLegacy = function isConstructor(argument) { 3748 if (!isCallable(argument)) return false; 3749 switch (classof(argument)) { 3750 case 'AsyncFunction': 3751 case 'GeneratorFunction': 3752 case 'AsyncGeneratorFunction': 3753 return false; 3754 } 3755 try { 3756 // we can't check .prototype since constructors produced by .bind haven't it 3757 // `Function#toString` throws on some built-it function in some legacy engines 3758 // (for example, `DOMQuad` and similar in FF41-) 3759 return INCORRECT_TO_STRING || !!exec(constructorRegExp, inspectSource(argument)); 3760 } catch (error) { 3761 return true; 3762 } 3763 }; 3764 isConstructorLegacy.sham = true; 3765 3766 // `IsConstructor` abstract operation 3767 // https://tc39.es/ecma262/#sec-isconstructor 3768 var isConstructor = !construct || fails(function () { 3769 var called; 3770 return isConstructorModern(isConstructorModern.call) || !isConstructorModern(Object) || !isConstructorModern(function () { 3771 called = true; 3772 }) || called; 3773 }) ? isConstructorLegacy : isConstructorModern; 3774 3775 var $TypeError$b = TypeError; 3776 3777 // `Assert: IsConstructor(argument) is true` 3778 var aConstructor = function (argument) { 3779 if (isConstructor(argument)) return argument; 3780 throw new $TypeError$b(tryToString(argument) + ' is not a constructor'); 3781 }; 3782 3783 var SPECIES$1 = wellKnownSymbol('species'); 3784 3785 // `SpeciesConstructor` abstract operation 3786 // https://tc39.es/ecma262/#sec-speciesconstructor 3787 var speciesConstructor = function (O, defaultConstructor) { 3788 var C = anObject(O).constructor; 3789 var S; 3790 return C === undefined || isNullOrUndefined(S = anObject(C)[SPECIES$1]) ? defaultConstructor : aConstructor(S); 3791 }; 3792 3793 var promiseResolve = function (C, x) { 3794 anObject(C); 3795 if (isObject(x) && x.constructor === C) return x; 3796 var promiseCapability = newPromiseCapability.f(C); 3797 var resolve = promiseCapability.resolve; 3798 resolve(x); 3799 return promiseCapability.promise; 3800 }; 3801 3802 var NativePromisePrototype$1 = promiseNativeConstructor && promiseNativeConstructor.prototype; 3803 3804 // Safari bug https://bugs.webkit.org/show_bug.cgi?id=200829 3805 var NON_GENERIC = !!promiseNativeConstructor && fails(function () { 3806 // eslint-disable-next-line unicorn/no-thenable -- required for testing 3807 NativePromisePrototype$1['finally'].call({ 3808 then: function () {/* empty */} 3809 }, function () {/* empty */}); 3810 }); 3811 3812 // `Promise.prototype.finally` method 3813 // https://tc39.es/ecma262/#sec-promise.prototype.finally 3814 _export({ 3815 target: 'Promise', 3816 proto: true, 3817 real: true, 3818 forced: NON_GENERIC 3819 }, { 3820 'finally': function (onFinally) { 3821 var C = speciesConstructor(this, getBuiltIn('Promise')); 3822 var isFunction = isCallable(onFinally); 3823 return this.then(isFunction ? function (x) { 3824 return promiseResolve(C, onFinally()).then(function () { 3825 return x; 3826 }); 3827 } : onFinally, isFunction ? function (e) { 3828 return promiseResolve(C, onFinally()).then(function () { 3829 throw e; 3830 }); 3831 } : onFinally); 3832 } 3833 }); 3834 3835 // makes sure that native promise-based APIs `Promise#finally` properly works with patched `Promise#then` 3836 if (!isPure && isCallable(promiseNativeConstructor)) { 3837 var method = getBuiltIn('Promise').prototype['finally']; 3838 if (NativePromisePrototype$1['finally'] !== method) { 3839 defineBuiltIn(NativePromisePrototype$1, 'finally', method, { 3840 unsafe: true 3841 }); 3842 } 3843 } 3844 3845 var ITERATOR$3 = wellKnownSymbol('iterator'); 3846 var BUGGY_SAFARI_ITERATORS = false; 3847 3848 // `%IteratorPrototype%` object 3849 // https://tc39.es/ecma262/#sec-%iteratorprototype%-object 3850 var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator; 3851 3852 /* eslint-disable es/no-array-prototype-keys -- safe */ 3853 if ([].keys) { 3854 arrayIterator = [].keys(); 3855 // Safari 8 has buggy iterators w/o `next` 3856 if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true;else { 3857 PrototypeOfArrayIteratorPrototype = objectGetPrototypeOf(objectGetPrototypeOf(arrayIterator)); 3858 if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype; 3859 } 3860 } 3861 var NEW_ITERATOR_PROTOTYPE = !isObject(IteratorPrototype) || fails(function () { 3862 var test = {}; 3863 // FF44- legacy iterators case 3864 return IteratorPrototype[ITERATOR$3].call(test) !== test; 3865 }); 3866 if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype = {}; 3867 3868 // `%IteratorPrototype%[@@iterator]()` method 3869 // https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator 3870 if (!isCallable(IteratorPrototype[ITERATOR$3])) { 3871 defineBuiltIn(IteratorPrototype, ITERATOR$3, function () { 3872 return this; 3873 }); 3874 } 3875 var iteratorsCore = { 3876 IteratorPrototype: IteratorPrototype, 3877 BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS 3878 }; 3879 3880 var IteratorPrototype$1 = iteratorsCore.IteratorPrototype; 3881 3882 3883 3884 3885 var returnThis = function () { 3886 return this; 3887 }; 3888 var iteratorCreateConstructor = function (IteratorConstructor, NAME, next, ENUMERABLE_NEXT) { 3889 var TO_STRING_TAG = NAME + ' Iterator'; 3890 IteratorConstructor.prototype = objectCreate(IteratorPrototype$1, { 3891 next: createPropertyDescriptor(+!ENUMERABLE_NEXT, next) 3892 }); 3893 setToStringTag(IteratorConstructor, TO_STRING_TAG, false, true); 3894 iterators[TO_STRING_TAG] = returnThis; 3895 return IteratorConstructor; 3896 }; 3897 3898 // `CreateIterResultObject` abstract operation 3899 // https://tc39.es/ecma262/#sec-createiterresultobject 3900 var createIterResultObject = function (value, done) { 3901 return { 3902 value: value, 3903 done: done 3904 }; 3905 }; 3906 3907 var MATCH = wellKnownSymbol('match'); 3908 3909 // `IsRegExp` abstract operation 3910 // https://tc39.es/ecma262/#sec-isregexp 3911 var isRegexp = function (it) { 3912 var isRegExp; 3913 return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classofRaw(it) === 'RegExp'); 3914 }; 3915 3916 // `RegExp.prototype.flags` getter implementation 3917 // https://tc39.es/ecma262/#sec-get-regexp.prototype.flags 3918 var regexpFlags = function () { 3919 var that = anObject(this); 3920 var result = ''; 3921 if (that.hasIndices) result += 'd'; 3922 if (that.global) result += 'g'; 3923 if (that.ignoreCase) result += 'i'; 3924 if (that.multiline) result += 'm'; 3925 if (that.dotAll) result += 's'; 3926 if (that.unicode) result += 'u'; 3927 if (that.unicodeSets) result += 'v'; 3928 if (that.sticky) result += 'y'; 3929 return result; 3930 }; 3931 3932 var RegExpPrototype = RegExp.prototype; 3933 var regexpGetFlags = function (R) { 3934 var flags = R.flags; 3935 return flags === undefined && !('flags' in RegExpPrototype) && !hasOwnProperty_1(R, 'flags') && objectIsPrototypeOf(RegExpPrototype, R) ? functionCall(regexpFlags, R) : flags; 3936 }; 3937 3938 var charAt = functionUncurryThis(''.charAt); 3939 var charCodeAt = functionUncurryThis(''.charCodeAt); 3940 var stringSlice$1 = functionUncurryThis(''.slice); 3941 var createMethod$1 = function (CONVERT_TO_STRING) { 3942 return function ($this, pos) { 3943 var S = toString_1(requireObjectCoercible($this)); 3944 var position = toIntegerOrInfinity(pos); 3945 var size = S.length; 3946 var first, second; 3947 if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined; 3948 first = charCodeAt(S, position); 3949 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; 3950 }; 3951 }; 3952 var stringMultibyte = { 3953 // `String.prototype.codePointAt` method 3954 // https://tc39.es/ecma262/#sec-string.prototype.codepointat 3955 codeAt: createMethod$1(false), 3956 // `String.prototype.at` method 3957 // https://github.com/mathiasbynens/String.prototype.at 3958 charAt: createMethod$1(true) 3959 }; 3960 3961 var charAt$1 = stringMultibyte.charAt; 3962 3963 // `AdvanceStringIndex` abstract operation 3964 // https://tc39.es/ecma262/#sec-advancestringindex 3965 var advanceStringIndex = function (S, index, unicode) { 3966 return index + (unicode ? charAt$1(S, index).length : 1); 3967 }; 3968 3969 // babel-minify and Closure Compiler transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError 3970 var $RegExp = globalThis_1.RegExp; 3971 var UNSUPPORTED_Y = fails(function () { 3972 var re = $RegExp('a', 'y'); 3973 re.lastIndex = 2; 3974 return re.exec('abcd') !== null; 3975 }); 3976 3977 // UC Browser bug 3978 // https://github.com/zloirock/core-js/issues/1008 3979 var MISSED_STICKY = UNSUPPORTED_Y || fails(function () { 3980 return !$RegExp('a', 'y').sticky; 3981 }); 3982 var BROKEN_CARET = UNSUPPORTED_Y || fails(function () { 3983 // https://bugzilla.mozilla.org/show_bug.cgi?id=773687 3984 var re = $RegExp('^r', 'gy'); 3985 re.lastIndex = 2; 3986 return re.exec('str') !== null; 3987 }); 3988 var regexpStickyHelpers = { 3989 BROKEN_CARET: BROKEN_CARET, 3990 MISSED_STICKY: MISSED_STICKY, 3991 UNSUPPORTED_Y: UNSUPPORTED_Y 3992 }; 3993 3994 // babel-minify and Closure Compiler transpiles RegExp('.', 's') -> /./s and it causes SyntaxError 3995 var $RegExp$1 = globalThis_1.RegExp; 3996 var regexpUnsupportedDotAll = fails(function () { 3997 var re = $RegExp$1('.', 's'); 3998 return !(re.dotAll && re.test('\n') && re.flags === 's'); 3999 }); 4000 4001 // babel-minify and Closure Compiler transpiles RegExp('(?<a>b)', 'g') -> /(?<a>b)/g and it causes SyntaxError 4002 var $RegExp$2 = globalThis_1.RegExp; 4003 var regexpUnsupportedNcg = fails(function () { 4004 var re = $RegExp$2('(?<a>b)', 'g'); 4005 return re.exec('b').groups.a !== 'b' || 'b'.replace(re, '$<a>c') !== 'bc'; 4006 }); 4007 4008 /* eslint-disable regexp/no-empty-capturing-group, regexp/no-empty-group, regexp/no-lazy-ends -- testing */ 4009 /* eslint-disable regexp/no-useless-quantifier -- testing */ 4010 4011 4012 4013 4014 4015 4016 4017 var getInternalState = internalState.get; 4018 4019 4020 var nativeReplace = shared('native-string-replace', String.prototype.replace); 4021 var nativeExec = RegExp.prototype.exec; 4022 var patchedExec = nativeExec; 4023 var charAt$2 = functionUncurryThis(''.charAt); 4024 var indexOf$1 = functionUncurryThis(''.indexOf); 4025 var replace$1 = functionUncurryThis(''.replace); 4026 var stringSlice$2 = functionUncurryThis(''.slice); 4027 var UPDATES_LAST_INDEX_WRONG = function () { 4028 var re1 = /a/; 4029 var re2 = /b*/g; 4030 functionCall(nativeExec, re1, 'a'); 4031 functionCall(nativeExec, re2, 'a'); 4032 return re1.lastIndex !== 0 || re2.lastIndex !== 0; 4033 }(); 4034 var UNSUPPORTED_Y$1 = regexpStickyHelpers.BROKEN_CARET; 4035 4036 // nonparticipating capturing group, copied from es5-shim's String#split patch. 4037 var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined; 4038 var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y$1 || regexpUnsupportedDotAll || regexpUnsupportedNcg; 4039 if (PATCH) { 4040 patchedExec = function exec(string) { 4041 var re = this; 4042 var state = getInternalState(re); 4043 var str = toString_1(string); 4044 var raw = state.raw; 4045 var result, reCopy, lastIndex, match, i, object, group; 4046 if (raw) { 4047 raw.lastIndex = re.lastIndex; 4048 result = functionCall(patchedExec, raw, str); 4049 re.lastIndex = raw.lastIndex; 4050 return result; 4051 } 4052 var groups = state.groups; 4053 var sticky = UNSUPPORTED_Y$1 && re.sticky; 4054 var flags = functionCall(regexpFlags, re); 4055 var source = re.source; 4056 var charsAdded = 0; 4057 var strCopy = str; 4058 if (sticky) { 4059 flags = replace$1(flags, 'y', ''); 4060 if (indexOf$1(flags, 'g') === -1) { 4061 flags += 'g'; 4062 } 4063 strCopy = stringSlice$2(str, re.lastIndex); 4064 // Support anchored sticky behavior. 4065 if (re.lastIndex > 0 && (!re.multiline || re.multiline && charAt$2(str, re.lastIndex - 1) !== '\n')) { 4066 source = '(?: ' + source + ')'; 4067 strCopy = ' ' + strCopy; 4068 charsAdded++; 4069 } 4070 // ^(? + rx + ) is needed, in combination with some str slicing, to 4071 // simulate the 'y' flag. 4072 reCopy = new RegExp('^(?:' + source + ')', flags); 4073 } 4074 if (NPCG_INCLUDED) { 4075 reCopy = new RegExp('^' + source + '$(?!\\s)', flags); 4076 } 4077 if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex; 4078 match = functionCall(nativeExec, sticky ? reCopy : re, strCopy); 4079 if (sticky) { 4080 if (match) { 4081 match.input = stringSlice$2(match.input, charsAdded); 4082 match[0] = stringSlice$2(match[0], charsAdded); 4083 match.index = re.lastIndex; 4084 re.lastIndex += match[0].length; 4085 } else re.lastIndex = 0; 4086 } else if (UPDATES_LAST_INDEX_WRONG && match) { 4087 re.lastIndex = re.global ? match.index + match[0].length : lastIndex; 4088 } 4089 if (NPCG_INCLUDED && match && match.length > 1) { 4090 // Fix browsers whose `exec` methods don't consistently return `undefined` 4091 // for NPCG, like IE8. NOTE: This doesn't work for /(.?)?/ 4092 functionCall(nativeReplace, match[0], reCopy, function () { 4093 for (i = 1; i < arguments.length - 2; i++) { 4094 if (arguments[i] === undefined) match[i] = undefined; 4095 } 4096 }); 4097 } 4098 if (match && groups) { 4099 match.groups = object = objectCreate(null); 4100 for (i = 0; i < groups.length; i++) { 4101 group = groups[i]; 4102 object[group[0]] = match[group[1]]; 4103 } 4104 } 4105 return match; 4106 }; 4107 } 4108 var regexpExec = patchedExec; 4109 4110 var $TypeError$c = TypeError; 4111 4112 // `RegExpExec` abstract operation 4113 // https://tc39.es/ecma262/#sec-regexpexec 4114 var regexpExecAbstract = function (R, S) { 4115 var exec = R.exec; 4116 if (isCallable(exec)) { 4117 var result = functionCall(exec, R, S); 4118 if (result !== null) anObject(result); 4119 return result; 4120 } 4121 if (classofRaw(R) === 'RegExp') return functionCall(regexpExec, R, S); 4122 throw new $TypeError$c('RegExp#exec called on incompatible receiver'); 4123 }; 4124 4125 /* eslint-disable es/no-string-prototype-matchall -- safe */ 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 var MATCH_ALL = wellKnownSymbol('matchAll'); 4149 var REGEXP_STRING = 'RegExp String'; 4150 var REGEXP_STRING_ITERATOR = REGEXP_STRING + ' Iterator'; 4151 var setInternalState$1 = internalState.set; 4152 var getInternalState$1 = internalState.getterFor(REGEXP_STRING_ITERATOR); 4153 var RegExpPrototype$1 = RegExp.prototype; 4154 var $TypeError$d = TypeError; 4155 var stringIndexOf = functionUncurryThisClause(''.indexOf); 4156 var nativeMatchAll = functionUncurryThisClause(''.matchAll); 4157 var WORKS_WITH_NON_GLOBAL_REGEX = !!nativeMatchAll && !fails(function () { 4158 nativeMatchAll('a', /./); 4159 }); 4160 var $RegExpStringIterator = iteratorCreateConstructor(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$1(this); 4171 if (state.done) return createIterResultObject(undefined, true); 4172 var R = state.regexp; 4173 var S = state.string; 4174 var match = regexpExecAbstract(R, S); 4175 if (match === null) { 4176 state.done = true; 4177 return createIterResultObject(undefined, true); 4178 } 4179 if (state.global) { 4180 if (toString_1(match[0]) === '') R.lastIndex = advanceStringIndex(S, toLe
vendor: 6,629 bytes, lines 4180-4337
4180ngth(R.lastIndex), state.unicode); 4181 return createIterResultObject(match, false); 4182 } 4183 state.done = true; 4184 return createIterResultObject(match, false); 4185 }); 4186 var $matchAll = function (string) { 4187 var R = anObject(this); 4188 var S = toString_1(string); 4189 var C = speciesConstructor(R, RegExp); 4190 var flags = toString_1(regexpGetFlags(R)); 4191 var matcher, $global, fullUnicode; 4192 matcher = new C(C === RegExp ? R.source : R, flags); 4193 $global = !!~stringIndexOf(flags, 'g'); 4194 fullUnicode = !!~stringIndexOf(flags, 'u'); 4195 matcher.lastIndex = toLength(R.lastIndex); 4196 return new $RegExpStringIterator(matcher, S, $global, fullUnicode); 4197 }; 4198 4199 // `String.prototype.matchAll` method 4200 // https://tc39.es/ecma262/#sec-string.prototype.matchall 4201 _export({ 4202 target: 'String', 4203 proto: true, 4204 forced: WORKS_WITH_NON_GLOBAL_REGEX 4205 }, { 4206 matchAll: function matchAll(regexp) { 4207 var O = requireObjectCoercible(this); 4208 var flags, S, matcher, rx; 4209 if (!isNullOrUndefined(regexp)) { 4210 if (isRegexp(regexp)) { 4211 flags = toString_1(requireObjectCoercible(regexpGetFlags(regexp))); 4212 if (!~stringIndexOf(flags, 'g')) throw new $TypeError$d('`.matchAll` does not allow non-global regexes'); 4213 } 4214 if (WORKS_WITH_NON_GLOBAL_REGEX) return nativeMatchAll(O, regexp); 4215 matcher = getMethod(regexp, MATCH_ALL); 4216 if (matcher === undefined && isPure && classofRaw(regexp) === 'RegExp') matcher = $matchAll; 4217 if (matcher) return functionCall(matcher, regexp, O); 4218 } else if (WORKS_WITH_NON_GLOBAL_REGEX) return nativeMatchAll(O, regexp); 4219 S = toString_1(O); 4220 rx = new RegExp(regexp, 'g'); 4221 return isPure ? functionCall($matchAll, rx, S) : rx[MATCH_ALL](S); 4222 } 4223 }); 4224 isPure || MATCH_ALL in RegExpPrototype$1 || defineBuiltIn(RegExpPrototype$1, MATCH_ALL, $matchAll); 4225 4226 var floor$2 = Math.floor; 4227 var charAt$3 = functionUncurryThis(''.charAt); 4228 var replace$2 = functionUncurryThis(''.replace); 4229 var stringSlice$3 = functionUncurryThis(''.slice); 4230 // eslint-disable-next-line redos/no-vulnerable -- safe 4231 var SUBSTITUTION_SYMBOLS = /\$([$&'`]|\d{1,2}|<[^>]*>)/g; 4232 var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&'`]|\d{1,2})/g; 4233 4234 // `GetSubstitution` abstract operation 4235 // https://tc39.es/ecma262/#sec-getsubstitution 4236 var getSubstitution = function (matched, str, position, captures, namedCaptures, replacement) { 4237 var tailPos = position + matched.length; 4238 var m = captures.length; 4239 var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED; 4240 if (namedCaptures !== undefined) { 4241 namedCaptures = toObject(namedCaptures); 4242 symbols = SUBSTITUTION_SYMBOLS; 4243 } 4244 return replace$2(replacement, symbols, function (match, ch) { 4245 var capture; 4246 switch (charAt$3(ch, 0)) { 4247 case '$': 4248 return '$'; 4249 case '&': 4250 return matched; 4251 case '`': 4252 return stringSlice$3(str, 0, position); 4253 case "'": 4254 return stringSlice$3(str, tailPos); 4255 case '<': 4256 capture = namedCaptures[stringSlice$3(ch, 1, -1)]; 4257 break; 4258 default: 4259 // \d\d? 4260 var n = +ch; 4261 if (n === 0) return match; 4262 if (n > m) { 4263 var f = floor$2(n / 10); 4264 if (f === 0) return match; 4265 if (f <= m) return captures[f - 1] === undefined ? charAt$3(ch, 1) : captures[f - 1] + charAt$3(ch, 1); 4266 return match; 4267 } 4268 capture = captures[n - 1]; 4269 } 4270 return capture === undefined ? '' : capture; 4271 }); 4272 }; 4273 4274 var REPLACE = wellKnownSymbol('replace'); 4275 var $TypeError$e = TypeError; 4276 var indexOf$2 = functionUncurryThis(''.indexOf); 4277 var replace$3 = functionUncurryThis(''.replace); 4278 var stringSlice$4 = functionUncurryThis(''.slice); 4279 var max$1 = Math.max; 4280 4281 // `String.prototype.replaceAll` method 4282 // https://tc39.es/ecma262/#sec-string.prototype.replaceall 4283 _export({ 4284 target: 'String', 4285 proto: true 4286 }, { 4287 replaceAll: function replaceAll(searchValue, replaceValue) { 4288 var O = requireObjectCoercible(this); 4289 var IS_REG_EXP, flags, replacer, string, searchString, functionalReplace, searchLength, advanceBy, position, replacement; 4290 var endOfLastMatch = 0; 4291 var result = ''; 4292 if (!isNullOrUndefined(searchValue)) { 4293 IS_REG_EXP = isRegexp(searchValue); 4294 if (IS_REG_EXP) { 4295 flags = toString_1(requireObjectCoercible(regexpGetFlags(searchValue))); 4296 if (!~indexOf$2(flags, 'g')) throw new $TypeError$e('`.replaceAll` does not allow non-global regexes'); 4297 } 4298 replacer = getMethod(searchValue, REPLACE); 4299 if (replacer) return functionCall(replacer, searchValue, O, replaceValue); 4300 if (isPure && IS_REG_EXP) return replace$3(toString_1(O), searchValue, replaceValue); 4301 } 4302 string = toString_1(O); 4303 searchString = toString_1(searchValue); 4304 functionalReplace = isCallable(replaceValue); 4305 if (!functionalReplace) replaceValue = toString_1(replaceValue); 4306 searchLength = searchString.length; 4307 advanceBy = max$1(1, searchLength); 4308 position = indexOf$2(string, searchString); 4309 while (position !== -1) { 4310 replacement = functionalReplace ? toString_1(replaceValue(searchString, position, string)) : getSubstitution(searchString, string, position, [], undefined, replaceValue); 4311 result += stringSlice$4(string, endOfLastMatch, position) + replacement; 4312 endOfLastMatch = position + searchLength; 4313 position = position + advanceBy > string.length ? -1 : indexOf$2(string, searchString, position + advanceBy); 4314 } 4315 if (endOfLastMatch < string.length) { 4316 result += stringSlice$4(string, endOfLastMatch); 4317 } 4318 return result; 4319 } 4320 }); 4321 4322 var enforceInternalState = internalState.enforce; 4323 var getInternalState$2 = internalState.get; 4324 var Int8Array = globalThis_1.Int8Array; 4325 var Int8ArrayPrototype = Int8Array && Int8Array.prototype; 4326 var Uint8ClampedArray = globalThis_1.Uint8ClampedArray; 4327 var Uint8ClampedArrayPrototype = Uint8ClampedArray && Uint8ClampedArray.prototype; 4328 var TypedArray = Int8Array && objectGetPrototypeOf(Int8Array); 4329 var TypedArrayPrototype = Int8ArrayPrototype && objectGetPrototypeOf(Int8ArrayPrototype); 4330 var ObjectPrototype$2 = Object.prototype; 4331 var TypeError$2 = globalThis_1.TypeError; 4332 var TO_STRING_TAG$4 = wellKnownSymbol('toStringTag'); 4333 var TYPED_ARRAY_TAG = uid('TYPED_ARRAY_TAG'); 4334 var TYPED_ARRAY_CONSTRUCTOR = 'TypedArrayConstructor'; 4335 // Fixing native typed arrays in Opera Presto crashes the browser, see #595 4336 var NATIVE_ARRAY_BUFFER_VIEWS = arrayBufferBasicDetection && !!objectSetPrototypeOf && classof(globalThis_1.opera) !== 'Opera'; 4337 var TYPED_ARRAY_TAG_REQUIRED = false;
vendor: 13,836 bytes, lines 4338-4732
4338 var NAME, Constructor, Prototype; 4339 var TypedArrayConstructorsList = { 4340 Int8Array: 1, 4341 Uint8Array: 1, 4342 Uint8ClampedArray: 1, 4343 Int16Array: 2, 4344 Uint16Array: 2, 4345 Int32Array: 4, 4346 Uint32Array: 4, 4347 Float32Array: 4, 4348 Float64Array: 8 4349 }; 4350 var BigIntArrayConstructorsList = { 4351 BigInt64Array: 8, 4352 BigUint64Array: 8 4353 }; 4354 var isView = function isView(it) { 4355 if (!isObject(it)) return false; 4356 var klass = classof(it); 4357 return klass === 'DataView' || hasOwnProperty_1(TypedArrayConstructorsList, klass) || hasOwnProperty_1(BigIntArrayConstructorsList, klass); 4358 }; 4359 var getTypedArrayConstructor = function (it) { 4360 var proto = objectGetPrototypeOf(it); 4361 if (!isObject(proto)) return; 4362 var state = getInternalState$2(proto); 4363 return state && hasOwnProperty_1(state, TYPED_ARRAY_CONSTRUCTOR) ? state[TYPED_ARRAY_CONSTRUCTOR] : getTypedArrayConstructor(proto); 4364 }; 4365 var isTypedArray = function (it) { 4366 if (!isObject(it)) return false; 4367 var klass = classof(it); 4368 return hasOwnProperty_1(TypedArrayConstructorsList, klass) || hasOwnProperty_1(BigIntArrayConstructorsList, klass); 4369 }; 4370 var aTypedArray = function (it) { 4371 if (isTypedArray(it)) return it; 4372 throw new TypeError$2('Target is not a typed array'); 4373 }; 4374 var aTypedArrayConstructor = function (C) { 4375 if (isCallable(C) && (!objectSetPrototypeOf || objectIsPrototypeOf(TypedArray, C))) return C; 4376 throw new TypeError$2(tryToString(C) + ' is not a typed array constructor'); 4377 }; 4378 var exportTypedArrayMethod = function (KEY, property, forced, options) { 4379 if (!descriptors) return; 4380 if (forced) for (var ARRAY in TypedArrayConstructorsList) { 4381 var TypedArrayConstructor = globalThis_1[ARRAY]; 4382 if (TypedArrayConstructor && hasOwnProperty_1(TypedArrayConstructor.prototype, KEY)) try { 4383 delete TypedArrayConstructor.prototype[KEY]; 4384 } catch (error) { 4385 // old WebKit bug - some methods are non-configurable 4386 try { 4387 TypedArrayConstructor.prototype[KEY] = property; 4388 } catch (error2) {/* empty */} 4389 } 4390 } 4391 if (!TypedArrayPrototype[KEY] || forced) { 4392 defineBuiltIn(TypedArrayPrototype, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS && Int8ArrayPrototype[KEY] || property, options); 4393 } 4394 }; 4395 var exportTypedArrayStaticMethod = function (KEY, property, forced) { 4396 var ARRAY, TypedArrayConstructor; 4397 if (!descriptors) return; 4398 if (objectSetPrototypeOf) { 4399 if (forced) for (ARRAY in TypedArrayConstructorsList) { 4400 TypedArrayConstructor = globalThis_1[ARRAY]; 4401 if (TypedArrayConstructor && hasOwnProperty_1(TypedArrayConstructor, KEY)) try { 4402 delete TypedArrayConstructor[KEY]; 4403 } catch (error) {/* empty */} 4404 } 4405 if (!TypedArray[KEY] || forced) { 4406 // V8 ~ Chrome 49-50 `%TypedArray%` methods are non-writable non-configurable 4407 try { 4408 return defineBuiltIn(TypedArray, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS && TypedArray[KEY] || property); 4409 } catch (error) {/* empty */} 4410 } else return; 4411 } 4412 for (ARRAY in TypedArrayConstructorsList) { 4413 TypedArrayConstructor = globalThis_1[ARRAY]; 4414 if (TypedArrayConstructor && (!TypedArrayConstructor[KEY] || forced)) { 4415 defineBuiltIn(TypedArrayConstructor, KEY, property); 4416 } 4417 } 4418 }; 4419 for (NAME in TypedArrayConstructorsList) { 4420 Constructor = globalThis_1[NAME]; 4421 Prototype = Constructor && Constructor.prototype; 4422 if (Prototype) enforceInternalState(Prototype)[TYPED_ARRAY_CONSTRUCTOR] = Constructor;else NATIVE_ARRAY_BUFFER_VIEWS = false; 4423 } 4424 for (NAME in BigIntArrayConstructorsList) { 4425 Constructor = globalThis_1[NAME]; 4426 Prototype = Constructor && Constructor.prototype; 4427 if (Prototype) enforceInternalState(Prototype)[TYPED_ARRAY_CONSTRUCTOR] = Constructor; 4428 } 4429 4430 // WebKit bug - typed arrays constructors prototype is Object.prototype 4431 if (!NATIVE_ARRAY_BUFFER_VIEWS || !isCallable(TypedArray) || TypedArray === Function.prototype) { 4432 // eslint-disable-next-line no-shadow -- safe 4433 TypedArray = function TypedArray() { 4434 throw new TypeError$2('Incorrect invocation'); 4435 }; 4436 if (NATIVE_ARRAY_BUFFER_VIEWS) for (NAME in TypedArrayConstructorsList) { 4437 if (globalThis_1[NAME]) objectSetPrototypeOf(globalThis_1[NAME], TypedArray); 4438 } 4439 } 4440 if (!NATIVE_ARRAY_BUFFER_VIEWS || !TypedArrayPrototype || TypedArrayPrototype === ObjectPrototype$2) { 4441 TypedArrayPrototype = TypedArray.prototype; 4442 if (NATIVE_ARRAY_BUFFER_VIEWS) for (NAME in TypedArrayConstructorsList) { 4443 if (globalThis_1[NAME]) objectSetPrototypeOf(globalThis_1[NAME].prototype, TypedArrayPrototype); 4444 } 4445 } 4446 4447 // WebKit bug - one more object in Uint8ClampedArray prototype chain 4448 if (NATIVE_ARRAY_BUFFER_VIEWS && objectGetPrototypeOf(Uint8ClampedArrayPrototype) !== TypedArrayPrototype) { 4449 objectSetPrototypeOf(Uint8ClampedArrayPrototype, TypedArrayPrototype); 4450 } 4451 if (descriptors && !hasOwnProperty_1(TypedArrayPrototype, TO_STRING_TAG$4)) { 4452 TYPED_ARRAY_TAG_REQUIRED = true; 4453 defineBuiltInAccessor(TypedArrayPrototype, TO_STRING_TAG$4, { 4454 configurable: true, 4455 get: function () { 4456 return isObject(this) ? this[TYPED_ARRAY_TAG] : undefined; 4457 } 4458 }); 4459 for (NAME in TypedArrayConstructorsList) if (globalThis_1[NAME]) { 4460 createNonEnumerableProperty(globalThis_1[NAME], TYPED_ARRAY_TAG, NAME); 4461 } 4462 } 4463 var arrayBufferViewCore = { 4464 NATIVE_ARRAY_BUFFER_VIEWS: NATIVE_ARRAY_BUFFER_VIEWS, 4465 TYPED_ARRAY_TAG: TYPED_ARRAY_TAG_REQUIRED && TYPED_ARRAY_TAG, 4466 aTypedArray: aTypedArray, 4467 aTypedArrayConstructor: aTypedArrayConstructor, 4468 exportTypedArrayMethod: exportTypedArrayMethod, 4469 exportTypedArrayStaticMethod: exportTypedArrayStaticMethod, 4470 getTypedArrayConstructor: getTypedArrayConstructor, 4471 isView: isView, 4472 isTypedArray: isTypedArray, 4473 TypedArray: TypedArray, 4474 TypedArrayPrototype: TypedArrayPrototype 4475 }; 4476 4477 /* eslint-disable no-new, sonarjs/inconsistent-function-call -- required for testing */ 4478 4479 4480 4481 var NATIVE_ARRAY_BUFFER_VIEWS$1 = arrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS; 4482 var ArrayBuffer$2 = globalThis_1.ArrayBuffer; 4483 var Int8Array$1 = globalThis_1.Int8Array; 4484 var typedArrayConstructorsRequireWrappers = !NATIVE_ARRAY_BUFFER_VIEWS$1 || !fails(function () { 4485 Int8Array$1(1); 4486 }) || !fails(function () { 4487 new Int8Array$1(-1); 4488 }) || !checkCorrectnessOfIteration(function (iterable) { 4489 new Int8Array$1(); 4490 new Int8Array$1(null); 4491 new Int8Array$1(1.5); 4492 new Int8Array$1(iterable); 4493 }, true) || fails(function () { 4494 // Safari (11+) bug - a reason why even Safari 13 should load a typed array polyfill 4495 return new Int8Array$1(new ArrayBuffer$2(2), 1, undefined).length !== 1; 4496 }); 4497 4498 var floor$3 = Math.floor; 4499 4500 // `IsIntegralNumber` abstract operation 4501 // https://tc39.es/ecma262/#sec-isintegralnumber 4502 // eslint-disable-next-line es/no-number-isinteger -- safe 4503 var isIntegralNumber = Number.isInteger || function isInteger(it) { 4504 return !isObject(it) && isFinite(it) && floor$3(it) === it; 4505 }; 4506 4507 var $RangeError$1 = RangeError; 4508 var toPositiveInteger = function (it) { 4509 var result = toIntegerOrInfinity(it); 4510 if (result < 0) throw new $RangeError$1("The argument can't be less than 0"); 4511 return result; 4512 }; 4513 4514 var $RangeError$2 = RangeError; 4515 var toOffset = function (it, BYTES) { 4516 var offset = toPositiveInteger(it); 4517 if (offset % BYTES) throw new $RangeError$2('Wrong offset'); 4518 return offset; 4519 }; 4520 4521 var round = Math.round; 4522 var toUint8Clamped = function (it) { 4523 var value = round(it); 4524 return value < 0 ? 0 : value > 0xFF ? 0xFF : value & 0xFF; 4525 }; 4526 4527 var isBigIntArray = function (it) { 4528 var klass = classof(it); 4529 return klass === 'BigInt64Array' || klass === 'BigUint64Array'; 4530 }; 4531 4532 var $TypeError$f = TypeError; 4533 4534 // `ToBigInt` abstract operation 4535 // https://tc39.es/ecma262/#sec-tobigint 4536 var toBigInt = function (argument) { 4537 var prim = toPrimitive(argument, 'number'); 4538 if (typeof prim == 'number') throw new $TypeError$f("Can't convert number to bigint"); 4539 // eslint-disable-next-line es/no-bigint -- safe 4540 return BigInt(prim); 4541 }; 4542 4543 var aTypedArrayConstructor$1 = arrayBufferViewCore.aTypedArrayConstructor; 4544 4545 var typedArrayFrom = function from(source /* , mapfn, thisArg */) { 4546 var C = aConstructor(this); 4547 var O = toObject(source); 4548 var argumentsLength = arguments.length; 4549 var mapfn = argumentsLength > 1 ? arguments[1] : undefined; 4550 var mapping = mapfn !== undefined; 4551 var iteratorMethod = getIteratorMethod(O); 4552 var i, length, result, thisIsBigIntArray, value, step, iterator, next; 4553 if (iteratorMethod && !isArrayIteratorMethod(iteratorMethod)) { 4554 iterator = getIterator(O, iteratorMethod); 4555 next = iterator.next; 4556 O = []; 4557 while (!(step = functionCall(next, iterator)).done) { 4558 O.push(step.value); 4559 } 4560 } 4561 if (mapping && argumentsLength > 2) { 4562 mapfn = functionBindContext(mapfn, arguments[2]); 4563 } 4564 length = lengthOfArrayLike(O); 4565 result = new (aTypedArrayConstructor$1(C))(length); 4566 thisIsBigIntArray = isBigIntArray(result); 4567 for (i = 0; length > i; i++) { 4568 value = mapping ? mapfn(O[i], i) : O[i]; 4569 // FF30- typed arrays doesn't properly convert objects to typed array values 4570 result[i] = thisIsBigIntArray ? toBigInt(value) : +value; 4571 } 4572 return result; 4573 }; 4574 4575 // `IsArray` abstract operation 4576 // https://tc39.es/ecma262/#sec-isarray 4577 // eslint-disable-next-line es/no-array-isarray -- safe 4578 var isArray = Array.isArray || function isArray(argument) { 4579 return classofRaw(argument) === 'Array'; 4580 }; 4581 4582 var SPECIES$2 = wellKnownSymbol('species'); 4583 var $Array$1 = Array; 4584 4585 // a part of `ArraySpeciesCreate` abstract operation 4586 // https://tc39.es/ecma262/#sec-arrayspeciescreate 4587 var arraySpeciesConstructor = function (originalArray) { 4588 var C; 4589 if (isArray(originalArray)) { 4590 C = originalArray.constructor; 4591 // cross-realm fallback 4592 if (isConstructor(C) && (C === $Array$1 || isArray(C.prototype))) C = undefined;else if (isObject(C)) { 4593 C = C[SPECIES$2]; 4594 if (C === null) C = undefined; 4595 } 4596 } 4597 return C === undefined ? $Array$1 : C; 4598 }; 4599 4600 // `ArraySpeciesCreate` abstract operation 4601 // https://tc39.es/ecma262/#sec-arrayspeciescreate 4602 var arraySpeciesCreate = function (originalArray, length) { 4603 return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length); 4604 }; 4605 4606 var push$2 = functionUncurryThis([].push); 4607 4608 // `Array.prototype.{ forEach, map, filter, some, every, find, findIndex, filterReject }` methods implementation 4609 var createMethod$2 = function (TYPE) { 4610 var IS_MAP = TYPE === 1; 4611 var IS_FILTER = TYPE === 2; 4612 var IS_SOME = TYPE === 3; 4613 var IS_EVERY = TYPE === 4; 4614 var IS_FIND_INDEX = TYPE === 6; 4615 var IS_FILTER_REJECT = TYPE === 7; 4616 var NO_HOLES = TYPE === 5 || IS_FIND_INDEX; 4617 return function ($this, callbackfn, that, specificCreate) { 4618 var O = toObject($this); 4619 var self = indexedObject(O); 4620 var length = lengthOfArrayLike(self); 4621 var boundFunction = functionBindContext(callbackfn, that); 4622 var index = 0; 4623 var create = specificCreate || arraySpeciesCreate; 4624 var target = IS_MAP ? create($this, length) : IS_FILTER || IS_FILTER_REJECT ? create($this, 0) : undefined; 4625 var value, result; 4626 for (; length > index; index++) if (NO_HOLES || index in self) { 4627 value = self[index]; 4628 result = boundFunction(value, index, O); 4629 if (TYPE) { 4630 if (IS_MAP) target[index] = result; // map 4631 else if (result) switch (TYPE) { 4632 case 3: 4633 return true; 4634 // some 4635 case 5: 4636 return value; 4637 // find 4638 case 6: 4639 return index; 4640 // findIndex 4641 case 2: 4642 push$2(target, value); 4643 // filter 4644 } else switch (TYPE) { 4645 case 4: 4646 return false; 4647 // every 4648 case 7: 4649 push$2(target, value); 4650 // filterReject 4651 } 4652 } 4653 } 4654 4655 return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target; 4656 }; 4657 }; 4658 var arrayIteration = { 4659 // `Array.prototype.forEach` method 4660 // https://tc39.es/ecma262/#sec-array.prototype.foreach 4661 forEach: createMethod$2(0), 4662 // `Array.prototype.map` method 4663 // https://tc39.es/ecma262/#sec-array.prototype.map 4664 map: createMethod$2(1), 4665 // `Array.prototype.filter` method 4666 // https://tc39.es/ecma262/#sec-array.prototype.filter 4667 filter: createMethod$2(2), 4668 // `Array.prototype.some` method 4669 // https://tc39.es/ecma262/#sec-array.prototype.some 4670 some: createMethod$2(3), 4671 // `Array.prototype.every` method 4672 // https://tc39.es/ecma262/#sec-array.prototype.every 4673 every: createMethod$2(4), 4674 // `Array.prototype.find` method 4675 // https://tc39.es/ecma262/#sec-array.prototype.find 4676 find: createMethod$2(5), 4677 // `Array.prototype.findIndex` method 4678 // https://tc39.es/ecma262/#sec-array.prototype.findIndex 4679 findIndex: createMethod$2(6), 4680 // `Array.prototype.filterReject` method 4681 // https://github.com/tc39/proposal-array-filtering 4682 filterReject: createMethod$2(7) 4683 }; 4684 4685 var SPECIES$3 = wellKnownSymbol('species'); 4686 var setSpecies = function (CONSTRUCTOR_NAME) { 4687 var Constructor = getBuiltIn(CONSTRUCTOR_NAME); 4688 if (descriptors && Constructor && !Constructor[SPECIES$3]) { 4689 defineBuiltInAccessor(Constructor, SPECIES$3, { 4690 configurable: true, 4691 get: function () { 4692 return this; 4693 } 4694 }); 4695 } 4696 }; 4697 4698 var arrayFromConstructorAndList = function (Constructor, list, $length) { 4699 var index = 0; 4700 var length = arguments.length > 2 ? $length : lengthOfArrayLike(list); 4701 var result = new Constructor(length); 4702 while (length > index) result[index] = list[index++]; 4703 return result; 4704 }; 4705 4706 var typedArrayConstructor = createCommonjsModule(function (module) { 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 var getOwnPropertyNames = objectGetOwnPropertyNames.f; 4732
vendor: 6,764 bytes, lines 4733-4880
4733 var forEach = arrayIteration.forEach; 4734 4735 4736 4737 4738 4739 4740 4741 var getInternalState = internalState.get; 4742 var setInternalState = internalState.set; 4743 var enforceInternalState = internalState.enforce; 4744 var nativeDefineProperty = objectDefineProperty.f; 4745 var nativeGetOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f; 4746 var RangeError = globalThis_1.RangeError; 4747 var ArrayBuffer = arrayBuffer.ArrayBuffer; 4748 var ArrayBufferPrototype = ArrayBuffer.prototype; 4749 var DataView = arrayBuffer.DataView; 4750 var NATIVE_ARRAY_BUFFER_VIEWS = arrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS; 4751 var TYPED_ARRAY_TAG = arrayBufferViewCore.TYPED_ARRAY_TAG; 4752 var TypedArray = arrayBufferViewCore.TypedArray; 4753 var TypedArrayPrototype = arrayBufferViewCore.TypedArrayPrototype; 4754 var isTypedArray = arrayBufferViewCore.isTypedArray; 4755 var BYTES_PER_ELEMENT = 'BYTES_PER_ELEMENT'; 4756 var WRONG_LENGTH = 'Wrong length'; 4757 var addGetter = function (it, key) { 4758 defineBuiltInAccessor(it, key, { 4759 configurable: true, 4760 get: function () { 4761 return getInternalState(this)[key]; 4762 } 4763 }); 4764 }; 4765 var isArrayBuffer = function (it) { 4766 var klass; 4767 return objectIsPrototypeOf(ArrayBufferPrototype, it) || (klass = classof(it)) === 'ArrayBuffer' || klass === 'SharedArrayBuffer'; 4768 }; 4769 var isTypedArrayIndex = function (target, key) { 4770 return isTypedArray(target) && !isSymbol(key) && key in target && isIntegralNumber(+key) && key >= 0; 4771 }; 4772 var wrappedGetOwnPropertyDescriptor = function getOwnPropertyDescriptor(target, key) { 4773 key = toPropertyKey(key); 4774 return isTypedArrayIndex(target, key) ? createPropertyDescriptor(2, target[key]) : nativeGetOwnPropertyDescriptor(target, key); 4775 }; 4776 var wrappedDefineProperty = function defineProperty(target, key, descriptor) { 4777 key = toPropertyKey(key); 4778 if (isTypedArrayIndex(target, key) && isObject(descriptor) && hasOwnProperty_1(descriptor, 'value') && !hasOwnProperty_1(descriptor, 'get') && !hasOwnProperty_1(descriptor, 'set') 4779 // TODO: add validation descriptor w/o calling accessors 4780 && !descriptor.configurable && (!hasOwnProperty_1(descriptor, 'writable') || descriptor.writable) && (!hasOwnProperty_1(descriptor, 'enumerable') || descriptor.enumerable)) { 4781 target[key] = descriptor.value; 4782 return target; 4783 } 4784 return nativeDefineProperty(target, key, descriptor); 4785 }; 4786 if (descriptors) { 4787 if (!NATIVE_ARRAY_BUFFER_VIEWS) { 4788 objectGetOwnPropertyDescriptor.f = wrappedGetOwnPropertyDescriptor; 4789 objectDefineProperty.f = wrappedDefineProperty; 4790 addGetter(TypedArrayPrototype, 'buffer'); 4791 addGetter(TypedArrayPrototype, 'byteOffset'); 4792 addGetter(TypedArrayPrototype, 'byteLength'); 4793 addGetter(TypedArrayPrototype, 'length'); 4794 } 4795 _export({ 4796 target: 'Object', 4797 stat: true, 4798 forced: !NATIVE_ARRAY_BUFFER_VIEWS 4799 }, { 4800 getOwnPropertyDescriptor: wrappedGetOwnPropertyDescriptor, 4801 defineProperty: wrappedDefineProperty 4802 }); 4803 module.exports = function (TYPE, wrapper, CLAMPED) { 4804 var BYTES = TYPE.match(/\d+/)[0] / 8; 4805 var CONSTRUCTOR_NAME = TYPE + (CLAMPED ? 'Clamped' : '') + 'Array'; 4806 var GETTER = 'get' + TYPE; 4807 var SETTER = 'set' + TYPE; 4808 var NativeTypedArrayConstructor = globalThis_1[CONSTRUCTOR_NAME]; 4809 var TypedArrayConstructor = NativeTypedArrayConstructor; 4810 var TypedArrayConstructorPrototype = TypedArrayConstructor && TypedArrayConstructor.prototype; 4811 var exported = {}; 4812 var getter = function (that, index) { 4813 var data = getInternalState(that); 4814 return data.view[GETTER](index * BYTES + data.byteOffset, true); 4815 }; 4816 var setter = function (that, index, value) { 4817 var data = getInternalState(that); 4818 data.view[SETTER](index * BYTES + data.byteOffset, CLAMPED ? toUint8Clamped(value) : value, true); 4819 }; 4820 var addElement = function (that, index) { 4821 nativeDefineProperty(that, index, { 4822 get: function () { 4823 return getter(this, index); 4824 }, 4825 set: function (value) { 4826 return setter(this, index, value); 4827 }, 4828 enumerable: true 4829 }); 4830 }; 4831 if (!NATIVE_ARRAY_BUFFER_VIEWS) { 4832 TypedArrayConstructor = wrapper(function (that, data, offset, $length) { 4833 anInstance(that, TypedArrayConstructorPrototype); 4834 var index = 0; 4835 var byteOffset = 0; 4836 var buffer, byteLength, length; 4837 if (!isObject(data)) { 4838 length = toIndex(data); 4839 byteLength = length * BYTES; 4840 buffer = new ArrayBuffer(byteLength); 4841 } else if (isArrayBuffer(data)) { 4842 buffer = data; 4843 byteOffset = toOffset(offset, BYTES); 4844 var $len = data.byteLength; 4845 if ($length === undefined) { 4846 if ($len % BYTES) throw new RangeError(WRONG_LENGTH); 4847 byteLength = $len - byteOffset; 4848 if (byteLength < 0) throw new RangeError(WRONG_LENGTH); 4849 } else { 4850 byteLength = toLength($length) * BYTES; 4851 if (byteLength + byteOffset > $len) throw new RangeError(WRONG_LENGTH); 4852 } 4853 length = byteLength / BYTES; 4854 } else if (isTypedArray(data)) { 4855 return arrayFromConstructorAndList(TypedArrayConstructor, data); 4856 } else { 4857 return functionCall(typedArrayFrom, TypedArrayConstructor, data); 4858 } 4859 setInternalState(that, { 4860 buffer: buffer, 4861 byteOffset: byteOffset, 4862 byteLength: byteLength, 4863 length: length, 4864 view: new DataView(buffer) 4865 }); 4866 while (index < length) addElement(that, index++); 4867 }); 4868 if (objectSetPrototypeOf) objectSetPrototypeOf(TypedArrayConstructor, TypedArray); 4869 TypedArrayConstructorPrototype = TypedArrayConstructor.prototype = objectCreate(TypedArrayPrototype); 4870 } else if (typedArrayConstructorsRequireWrappers) { 4871 TypedArrayConstructor = wrapper(function (dummy, data, typedArrayOffset, $length) { 4872 anInstance(dummy, TypedArrayConstructorPrototype); 4873 return inheritIfRequired(function () { 4874 if (!isObject(data)) return new NativeTypedArrayConstructor(toIndex(data)); 4875 if (isArrayBuffer(data)) return $length !== undefined ? new NativeTypedArrayConstructor(data, toOffset(typedArrayOffset, BYTES), $length) : typedArrayOffset !== undefined ? new NativeTypedArrayConstructor(data, toOffset(typedArrayOffset, BYTES)) : new NativeTypedArrayConstructor(data); 4876 if (isTypedArray(data)) return arrayFromConstructorAndList(TypedArrayConstructor, data); 4877 return functionCall(typedArrayFrom, TypedArrayConstructor, data); 4878 }(), dummy, TypedArrayConstructor); 4879 }); 4880 if (objectSetPrototypeOf) objectSetPrototypeOf(TypedArrayConstructor, TypedArray);
vendor: 10,961 bytes, lines 4881-5188
4881 forEach(getOwnPropertyNames(NativeTypedArrayConstructor), function (key) { 4882 if (!(key in TypedArrayConstructor)) { 4883 createNonEnumerableProperty(TypedArrayConstructor, key, NativeTypedArrayConstructor[key]); 4884 } 4885 }); 4886 TypedArrayConstructor.prototype = TypedArrayConstructorPrototype; 4887 } 4888 if (TypedArrayConstructorPrototype.constructor !== TypedArrayConstructor) { 4889 createNonEnumerableProperty(TypedArrayConstructorPrototype, 'constructor', TypedArrayConstructor); 4890 } 4891 enforceInternalState(TypedArrayConstructorPrototype).TypedArrayConstructor = TypedArrayConstructor; 4892 if (TYPED_ARRAY_TAG) { 4893 createNonEnumerableProperty(TypedArrayConstructorPrototype, TYPED_ARRAY_TAG, CONSTRUCTOR_NAME); 4894 } 4895 var FORCED = TypedArrayConstructor !== NativeTypedArrayConstructor; 4896 exported[CONSTRUCTOR_NAME] = TypedArrayConstructor; 4897 _export({ 4898 global: true, 4899 constructor: true, 4900 forced: FORCED, 4901 sham: !NATIVE_ARRAY_BUFFER_VIEWS 4902 }, exported); 4903 if (!(BYTES_PER_ELEMENT in TypedArrayConstructor)) { 4904 createNonEnumerableProperty(TypedArrayConstructor, BYTES_PER_ELEMENT, BYTES); 4905 } 4906 if (!(BYTES_PER_ELEMENT in TypedArrayConstructorPrototype)) { 4907 createNonEnumerableProperty(TypedArrayConstructorPrototype, BYTES_PER_ELEMENT, BYTES); 4908 } 4909 setSpecies(CONSTRUCTOR_NAME); 4910 }; 4911 } else module.exports = function () {/* empty */}; 4912 }); 4913 4914 // `Float32Array` constructor 4915 // https://tc39.es/ecma262/#sec-typedarray-objects 4916 typedArrayConstructor('Float32', function (init) { 4917 return function Float32Array(data, byteOffset, length) { 4918 return init(this, data, byteOffset, length); 4919 }; 4920 }); 4921 4922 // `Float64Array` constructor 4923 // https://tc39.es/ecma262/#sec-typedarray-objects 4924 typedArrayConstructor('Float64', function (init) { 4925 return function Float64Array(data, byteOffset, length) { 4926 return init(this, data, byteOffset, length); 4927 }; 4928 }); 4929 4930 // `Int8Array` constructor 4931 // https://tc39.es/ecma262/#sec-typedarray-objects 4932 typedArrayConstructor('Int8', function (init) { 4933 return function Int8Array(data, byteOffset, length) { 4934 return init(this, data, byteOffset, length); 4935 }; 4936 }); 4937 4938 // `Int16Array` constructor 4939 // https://tc39.es/ecma262/#sec-typedarray-objects 4940 typedArrayConstructor('Int16', function (init) { 4941 return function Int16Array(data, byteOffset, length) { 4942 return init(this, data, byteOffset, length); 4943 }; 4944 }); 4945 4946 // `Int32Array` constructor 4947 // https://tc39.es/ecma262/#sec-typedarray-objects 4948 typedArrayConstructor('Int32', function (init) { 4949 return function Int32Array(data, byteOffset, length) { 4950 return init(this, data, byteOffset, length); 4951 }; 4952 }); 4953 4954 // `Uint8Array` constructor 4955 // https://tc39.es/ecma262/#sec-typedarray-objects 4956 typedArrayConstructor('Uint8', function (init) { 4957 return function Uint8Array(data, byteOffset, length) { 4958 return init(this, data, byteOffset, length); 4959 }; 4960 }); 4961 4962 // `Uint8ClampedArray` constructor 4963 // https://tc39.es/ecma262/#sec-typedarray-objects 4964 typedArrayConstructor('Uint8', function (init) { 4965 return function Uint8ClampedArray(data, byteOffset, length) { 4966 return init(this, data, byteOffset, length); 4967 }; 4968 }, true); 4969 4970 // `Uint16Array` constructor 4971 // https://tc39.es/ecma262/#sec-typedarray-objects 4972 typedArrayConstructor('Uint16', function (init) { 4973 return function Uint16Array(data, byteOffset, length) { 4974 return init(this, data, byteOffset, length); 4975 }; 4976 }); 4977 4978 // `Uint32Array` constructor 4979 // https://tc39.es/ecma262/#sec-typedarray-objects 4980 typedArrayConstructor('Uint32', function (init) { 4981 return function Uint32Array(data, byteOffset, length) { 4982 return init(this, data, byteOffset, length); 4983 }; 4984 }); 4985 4986 var aTypedArray$1 = arrayBufferViewCore.aTypedArray; 4987 var exportTypedArrayMethod$1 = arrayBufferViewCore.exportTypedArrayMethod; 4988 4989 // `%TypedArray%.prototype.at` method 4990 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.at 4991 exportTypedArrayMethod$1('at', function at(index) { 4992 var O = aTypedArray$1(this); 4993 var len = lengthOfArrayLike(O); 4994 var relativeIndex = toIntegerOrInfinity(index); 4995 var k = relativeIndex >= 0 ? relativeIndex : len + relativeIndex; 4996 return k < 0 || k >= len ? undefined : O[k]; 4997 }); 4998 4999 var exportTypedArrayStaticMethod$1 = arrayBufferViewCore.exportTypedArrayStaticMethod; 5000 5001 5002 // `%TypedArray%.from` method 5003 // https://tc39.es/ecma262/#sec-%typedarray%.from 5004 exportTypedArrayStaticMethod$1('from', typedArrayFrom, typedArrayConstructorsRequireWrappers); 5005 5006 var aTypedArrayConstructor$2 = arrayBufferViewCore.aTypedArrayConstructor; 5007 var exportTypedArrayStaticMethod$2 = arrayBufferViewCore.exportTypedArrayStaticMethod; 5008 5009 // `%TypedArray%.of` method 5010 // https://tc39.es/ecma262/#sec-%typedarray%.of 5011 exportTypedArrayStaticMethod$2('of', function of( /* ...items */ 5012 ) { 5013 var index = 0; 5014 var length = arguments.length; 5015 var result = new (aTypedArrayConstructor$2(this))(length); 5016 while (length > index) result[index] = arguments[index++]; 5017 return result; 5018 }, typedArrayConstructorsRequireWrappers); 5019 5020 var floor$4 = Math.floor; 5021 var sort = function (array, comparefn) { 5022 var length = array.length; 5023 if (length < 8) { 5024 // insertion sort 5025 var i = 1; 5026 var element, j; 5027 while (i < length) { 5028 j = i; 5029 element = array[i]; 5030 while (j && comparefn(array[j - 1], element) > 0) { 5031 array[j] = array[--j]; 5032 } 5033 if (j !== i++) array[j] = element; 5034 } 5035 } else { 5036 // merge sort 5037 var middle = floor$4(length / 2); 5038 var left = sort(arraySlice(array, 0, middle), comparefn); 5039 var right = sort(arraySlice(array, middle), comparefn); 5040 var llength = left.length; 5041 var rlength = right.length; 5042 var lindex = 0; 5043 var rindex = 0; 5044 while (lindex < llength || rindex < rlength) { 5045 array[lindex + rindex] = lindex < llength && rindex < rlength ? comparefn(left[lindex], right[rindex]) <= 0 ? left[lindex++] : right[rindex++] : lindex < llength ? left[lindex++] : right[rindex++]; 5046 } 5047 } 5048 return array; 5049 }; 5050 var arraySort = sort; 5051 5052 var firefox = environmentUserAgent.match(/firefox\/(\d+)/i); 5053 var environmentFfVersion = !!firefox && +firefox[1]; 5054 5055 var environmentIsIeOrEdge = /MSIE|Trident/.test(environmentUserAgent); 5056 5057 var webkit = environmentUserAgent.match(/AppleWebKit\/(\d+)\./); 5058 var environmentWebkitVersion = !!webkit && +webkit[1]; 5059 5060 var aTypedArray$2 = arrayBufferViewCore.aTypedArray; 5061 var exportTypedArrayMethod$2 = arrayBufferViewCore.exportTypedArrayMethod; 5062 var Uint16Array = globalThis_1.Uint16Array; 5063 var nativeSort = Uint16Array && functionUncurryThisClause(Uint16Array.prototype.sort); 5064 5065 // WebKit 5066 var ACCEPT_INCORRECT_ARGUMENTS = !!nativeSort && !(fails(function () { 5067 nativeSort(new Uint16Array(2), null); 5068 }) && fails(function () { 5069 nativeSort(new Uint16Array(2), {}); 5070 })); 5071 var STABLE_SORT = !!nativeSort && !fails(function () { 5072 // feature detection can be too slow, so check engines versions 5073 if (environmentV8Version) return environmentV8Version < 74; 5074 if (environmentFfVersion) return environmentFfVersion < 67; 5075 if (environmentIsIeOrEdge) return true; 5076 if (environmentWebkitVersion) return environmentWebkitVersion < 602; 5077 var array = new Uint16Array(516); 5078 var expected = Array(516); 5079 var index, mod; 5080 for (index = 0; index < 516; index++) { 5081 mod = index % 4; 5082 array[index] = 515 - index; 5083 expected[index] = index - 2 * mod + 3; 5084 } 5085 nativeSort(array, function (a, b) { 5086 return (a / 4 | 0) - (b / 4 | 0); 5087 }); 5088 for (index = 0; index < 516; index++) { 5089 if (array[index] !== expected[index]) return true; 5090 } 5091 }); 5092 var getSortCompare = function (comparefn) { 5093 return function (x, y) { 5094 if (comparefn !== undefined) return +comparefn(x, y) || 0; 5095 // eslint-disable-next-line no-self-compare -- NaN check 5096 if (y !== y) return -1; 5097 // eslint-disable-next-line no-self-compare -- NaN check 5098 if (x !== x) return 1; 5099 if (x === 0 && y === 0) return 1 / x > 0 && 1 / y < 0 ? 1 : -1; 5100 return x > y; 5101 }; 5102 }; 5103 5104 // `%TypedArray%.prototype.sort` method 5105 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.sort 5106 exportTypedArrayMethod$2('sort', function sort(comparefn) { 5107 if (comparefn !== undefined) aCallable(comparefn); 5108 if (STABLE_SORT) return nativeSort(this, comparefn); 5109 return arraySort(aTypedArray$2(this), getSortCompare(comparefn)); 5110 }, !STABLE_SORT || ACCEPT_INCORRECT_ARGUMENTS); 5111 5112 // iterable DOM collections 5113 // flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods 5114 var domIterables = { 5115 CSSRuleList: 0, 5116 CSSStyleDeclaration: 0, 5117 CSSValueList: 0, 5118 ClientRectList: 0, 5119 DOMRectList: 0, 5120 DOMStringList: 0, 5121 DOMTokenList: 1, 5122 DataTransferItemList: 0, 5123 FileList: 0, 5124 HTMLAllCollection: 0, 5125 HTMLCollection: 0, 5126 HTMLFormElement: 0, 5127 HTMLSelectElement: 0, 5128 MediaList: 0, 5129 MimeTypeArray: 0, 5130 NamedNodeMap: 0, 5131 NodeList: 1, 5132 PaintRequestList: 0, 5133 Plugin: 0, 5134 PluginArray: 0, 5135 SVGLengthList: 0, 5136 SVGNumberList: 0, 5137 SVGPathSegList: 0, 5138 SVGPointList: 0, 5139 SVGStringList: 0, 5140 SVGTransformList: 0, 5141 SourceBufferList: 0, 5142 StyleSheetList: 0, 5143 TextTrackCueList: 0, 5144 TextTrackList: 0, 5145 TouchList: 0 5146 }; 5147 5148 // in old WebKit versions, `element.classList` is not an instance of global `DOMTokenList` 5149 5150 var classList = documentCreateElement('span').classList; 5151 var DOMTokenListPrototype = classList && classList.constructor && classList.constructor.prototype; 5152 var domTokenListPrototype = DOMTokenListPrototype === Object.prototype ? undefined : DOMTokenListPrototype; 5153 5154 var PROPER_FUNCTION_NAME$1 = functionName.PROPER; 5155 var CONFIGURABLE_FUNCTION_NAME$1 = functionName.CONFIGURABLE; 5156 var IteratorPrototype$2 = iteratorsCore.IteratorPrototype; 5157 var BUGGY_SAFARI_ITERATORS$1 = iteratorsCore.BUGGY_SAFARI_ITERATORS; 5158 var ITERATOR$4 = wellKnownSymbol('iterator'); 5159 var KEYS = 'keys'; 5160 var VALUES = 'values'; 5161 var ENTRIES = 'entries'; 5162 var returnThis$1 = function () { 5163 return this; 5164 }; 5165 var iteratorDefine = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) { 5166 iteratorCreateConstructor(IteratorConstructor, NAME, next); 5167 var getIterationMethod = function (KIND) { 5168 if (KIND === DEFAULT && defaultIterator) return defaultIterator; 5169 if (!BUGGY_SAFARI_ITERATORS$1 && KIND && KIND in IterablePrototype) return IterablePrototype[KIND]; 5170 switch (KIND) { 5171 case KEYS: 5172 return function keys() { 5173 return new IteratorConstructor(this, KIND); 5174 }; 5175 case VALUES: 5176 return function values() { 5177 return new IteratorConstructor(this, KIND); 5178 }; 5179 case ENTRIES: 5180 return function entries() { 5181 return new IteratorConstructor(this, KIND); 5182 }; 5183 } 5184 return function () { 5185 return new IteratorConstructor(this); 5186 }; 5187 }; 5188 var TO_STRING_TAG = NAME + ' Iterator';
vendor: 16,324 bytes, lines 5189-5672
5189 var INCORRECT_VALUES_NAME = false; 5190 var IterablePrototype = Iterable.prototype; 5191 var nativeIterator = IterablePrototype[ITERATOR$4] || IterablePrototype['@@iterator'] || DEFAULT && IterablePrototype[DEFAULT]; 5192 var defaultIterator = !BUGGY_SAFARI_ITERATORS$1 && nativeIterator || getIterationMethod(DEFAULT); 5193 var anyNativeIterator = NAME === 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator; 5194 var CurrentIteratorPrototype, methods, KEY; 5195 5196 // fix native 5197 if (anyNativeIterator) { 5198 CurrentIteratorPrototype = objectGetPrototypeOf(anyNativeIterator.call(new Iterable())); 5199 if (CurrentIteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) { 5200 if (objectGetPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype$2) { 5201 if (objectSetPrototypeOf) { 5202 objectSetPrototypeOf(CurrentIteratorPrototype, IteratorPrototype$2); 5203 } else if (!isCallable(CurrentIteratorPrototype[ITERATOR$4])) { 5204 defineBuiltIn(CurrentIteratorPrototype, ITERATOR$4, returnThis$1); 5205 } 5206 } 5207 // Set @@toStringTag to native iterators 5208 setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true, true); 5209 } 5210 } 5211 5212 // fix Array.prototype.{ values, @@iterator }.name in V8 / FF 5213 if (PROPER_FUNCTION_NAME$1 && DEFAULT === VALUES && nativeIterator && nativeIterator.name !== VALUES) { 5214 if (CONFIGURABLE_FUNCTION_NAME$1) { 5215 createNonEnumerableProperty(IterablePrototype, 'name', VALUES); 5216 } else { 5217 INCORRECT_VALUES_NAME = true; 5218 defaultIterator = function values() { 5219 return functionCall(nativeIterator, this); 5220 }; 5221 } 5222 } 5223 5224 // export additional methods 5225 if (DEFAULT) { 5226 methods = { 5227 values: getIterationMethod(VALUES), 5228 keys: IS_SET ? defaultIterator : getIterationMethod(KEYS), 5229 entries: getIterationMethod(ENTRIES) 5230 }; 5231 if (FORCED) for (KEY in methods) { 5232 if (BUGGY_SAFARI_ITERATORS$1 || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) { 5233 defineBuiltIn(IterablePrototype, KEY, methods[KEY]); 5234 } 5235 } else _export({ 5236 target: NAME, 5237 proto: true, 5238 forced: BUGGY_SAFARI_ITERATORS$1 || INCORRECT_VALUES_NAME 5239 }, methods); 5240 } 5241 5242 // define iterator 5243 if (IterablePrototype[ITERATOR$4] !== defaultIterator) { 5244 defineBuiltIn(IterablePrototype, ITERATOR$4, defaultIterator, { 5245 name: DEFAULT 5246 }); 5247 } 5248 iterators[NAME] = defaultIterator; 5249 return methods; 5250 }; 5251 5252 var defineProperty$3 = objectDefineProperty.f; 5253 5254 5255 5256 5257 var ARRAY_ITERATOR = 'Array Iterator'; 5258 var setInternalState$2 = internalState.set; 5259 var getInternalState$3 = internalState.getterFor(ARRAY_ITERATOR); 5260 5261 // `Array.prototype.entries` method 5262 // https://tc39.es/ecma262/#sec-array.prototype.entries 5263 // `Array.prototype.keys` method 5264 // https://tc39.es/ecma262/#sec-array.prototype.keys 5265 // `Array.prototype.values` method 5266 // https://tc39.es/ecma262/#sec-array.prototype.values 5267 // `Array.prototype[@@iterator]` method 5268 // https://tc39.es/ecma262/#sec-array.prototype-@@iterator 5269 // `CreateArrayIterator` internal method 5270 // https://tc39.es/ecma262/#sec-createarrayiterator 5271 var es_array_iterator = iteratorDefine(Array, 'Array', function (iterated, kind) { 5272 setInternalState$2(this, { 5273 type: ARRAY_ITERATOR, 5274 target: toIndexedObject(iterated), 5275 // target 5276 index: 0, 5277 // next index 5278 kind: kind // kind 5279 }); 5280 // `%ArrayIteratorPrototype%.next` method 5281 // https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next 5282 }, function () { 5283 var state = getInternalState$3(this); 5284 var target = state.target; 5285 var index = state.index++; 5286 if (!target || index >= target.length) { 5287 state.target = null; 5288 return createIterResultObject(undefined, true); 5289 } 5290 switch (state.kind) { 5291 case 'keys': 5292 return createIterResultObject(index, false); 5293 case 'values': 5294 return createIterResultObject(target[index], false); 5295 } 5296 return createIterResultObject([index, target[index]], false); 5297 }, 'values'); 5298 5299 // argumentsList[@@iterator] is %ArrayProto_values% 5300 // https://tc39.es/ecma262/#sec-createunmappedargumentsobject 5301 // https://tc39.es/ecma262/#sec-createmappedargumentsobject 5302 var values = iterators.Arguments = iterators.Array; 5303 5304 // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables 5305 addToUnscopables('keys'); 5306 addToUnscopables('values'); 5307 addToUnscopables('entries'); 5308 5309 // V8 ~ Chrome 45- bug 5310 if (!isPure && descriptors && values.name !== 'values') try { 5311 defineProperty$3(values, 'name', { 5312 value: 'values' 5313 }); 5314 } catch (error) {/* empty */} 5315 5316 var ITERATOR$5 = wellKnownSymbol('iterator'); 5317 var ArrayValues = es_array_iterator.values; 5318 var handlePrototype = function (CollectionPrototype, COLLECTION_NAME) { 5319 if (CollectionPrototype) { 5320 // some Chrome versions have non-configurable methods on DOMTokenList 5321 if (CollectionPrototype[ITERATOR$5] !== ArrayValues) try { 5322 createNonEnumerableProperty(CollectionPrototype, ITERATOR$5, ArrayValues); 5323 } catch (error) { 5324 CollectionPrototype[ITERATOR$5] = ArrayValues; 5325 } 5326 setToStringTag(CollectionPrototype, COLLECTION_NAME, true); 5327 if (domIterables[COLLECTION_NAME]) for (var METHOD_NAME in es_array_iterator) { 5328 // some Chrome versions have non-configurable methods on DOMTokenList 5329 if (CollectionPrototype[METHOD_NAME] !== es_array_iterator[METHOD_NAME]) try { 5330 createNonEnumerableProperty(CollectionPrototype, METHOD_NAME, es_array_iterator[METHOD_NAME]); 5331 } catch (error) { 5332 CollectionPrototype[METHOD_NAME] = es_array_iterator[METHOD_NAME]; 5333 } 5334 } 5335 } 5336 }; 5337 for (var COLLECTION_NAME in domIterables) { 5338 handlePrototype(globalThis_1[COLLECTION_NAME] && globalThis_1[COLLECTION_NAME].prototype, COLLECTION_NAME); 5339 } 5340 handlePrototype(domTokenListPrototype, 'DOMTokenList'); 5341 5342 var FunctionPrototype$2 = Function.prototype; 5343 var apply = FunctionPrototype$2.apply; 5344 var call$2 = FunctionPrototype$2.call; 5345 5346 // eslint-disable-next-line es/no-function-prototype-bind, es/no-reflect -- safe 5347 var functionApply = typeof Reflect == 'object' && Reflect.apply || (functionBindNative ? call$2.bind(apply) : function () { 5348 return call$2.apply(apply, arguments); 5349 }); 5350 5351 var $TypeError$g = TypeError; 5352 var validateArgumentsLength = function (passed, required) { 5353 if (passed < required) throw new $TypeError$g('Not enough arguments'); 5354 return passed; 5355 }; 5356 5357 // eslint-disable-next-line redos/no-vulnerable -- safe 5358 var environmentIsIos = /(?:ipad|iphone|ipod).*applewebkit/i.test(environmentUserAgent); 5359 5360 var environmentIsNode = environment === 'NODE'; 5361 5362 var set$2 = globalThis_1.setImmediate; 5363 var clear = globalThis_1.clearImmediate; 5364 var process$1 = globalThis_1.process; 5365 var Dispatch = globalThis_1.Dispatch; 5366 var Function$1 = globalThis_1.Function; 5367 var MessageChannel = globalThis_1.MessageChannel; 5368 var String$1 = globalThis_1.String; 5369 var counter = 0; 5370 var queue = {}; 5371 var ONREADYSTATECHANGE = 'onreadystatechange'; 5372 var $location, defer, channel, port; 5373 fails(function () { 5374 // Deno throws a ReferenceError on `location` access without `--location` flag 5375 $location = globalThis_1.location; 5376 }); 5377 var run = function (id) { 5378 if (hasOwnProperty_1(queue, id)) { 5379 var fn = queue[id]; 5380 delete queue[id]; 5381 fn(); 5382 } 5383 }; 5384 var runner = function (id) { 5385 return function () { 5386 run(id); 5387 }; 5388 }; 5389 var eventListener = function (event) { 5390 run(event.data); 5391 }; 5392 var globalPostMessageDefer = function (id) { 5393 // old engines have not location.origin 5394 globalThis_1.postMessage(String$1(id), $location.protocol + '//' + $location.host); 5395 }; 5396 5397 // Node.js 0.9+ & IE10+ has setImmediate, otherwise: 5398 if (!set$2 || !clear) { 5399 set$2 = function setImmediate(handler) { 5400 validateArgumentsLength(arguments.length, 1); 5401 var fn = isCallable(handler) ? handler : Function$1(handler); 5402 var args = arraySlice(arguments, 1); 5403 queue[++counter] = function () { 5404 functionApply(fn, undefined, args); 5405 }; 5406 defer(counter); 5407 return counter; 5408 }; 5409 clear = function clearImmediate(id) { 5410 delete queue[id]; 5411 }; 5412 // Node.js 0.8- 5413 if (environmentIsNode) { 5414 defer = function (id) { 5415 process$1.nextTick(runner(id)); 5416 }; 5417 // Sphere (JS game engine) Dispatch API 5418 } else if (Dispatch && Dispatch.now) { 5419 defer = function (id) { 5420 Dispatch.now(runner(id)); 5421 }; 5422 // Browsers with MessageChannel, includes WebWorkers 5423 // except iOS - https://github.com/zloirock/core-js/issues/624 5424 } else if (MessageChannel && !environmentIsIos) { 5425 channel = new MessageChannel(); 5426 port = channel.port2; 5427 channel.port1.onmessage = eventListener; 5428 defer = functionBindContext(port.postMessage, port); 5429 // Browsers with postMessage, skip WebWorkers 5430 // IE8 has postMessage, but it's sync & typeof its postMessage is 'object' 5431 } else if (globalThis_1.addEventListener && isCallable(globalThis_1.postMessage) && !globalThis_1.importScripts && $location && $location.protocol !== 'file:' && !fails(globalPostMessageDefer)) { 5432 defer = globalPostMessageDefer; 5433 globalThis_1.addEventListener('message', eventListener, false); 5434 // IE8- 5435 } else if (ONREADYSTATECHANGE in documentCreateElement('script')) { 5436 defer = function (id) { 5437 html.appendChild(documentCreateElement('script'))[ONREADYSTATECHANGE] = function () { 5438 html.removeChild(this); 5439 run(id); 5440 }; 5441 }; 5442 // Rest old browsers 5443 } else { 5444 defer = function (id) { 5445 setTimeout(runner(id), 0); 5446 }; 5447 } 5448 } 5449 var task = { 5450 set: set$2, 5451 clear: clear 5452 }; 5453 5454 var clearImmediate = task.clear; 5455 5456 // `clearImmediate` method 5457 // http://w3c.github.io/setImmediate/#si-clearImmediate 5458 _export({ 5459 global: true, 5460 bind: true, 5461 enumerable: true, 5462 forced: globalThis_1.clearImmediate !== clearImmediate 5463 }, { 5464 clearImmediate: clearImmediate 5465 }); 5466 5467 var Function$2 = globalThis_1.Function; 5468 // dirty IE9- and Bun 0.3.0- checks 5469 var WRAP = /MSIE .\./.test(environmentUserAgent) || environment === 'BUN' && function () { 5470 var version = globalThis_1.Bun.version.split('.'); 5471 return version.length < 3 || version[0] === '0' && (version[1] < 3 || version[1] === '3' && version[2] === '0'); 5472 }(); 5473 5474 // IE9- / Bun 0.3.0- setTimeout / setInterval / setImmediate additional parameters fix 5475 // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timers 5476 // https://github.com/oven-sh/bun/issues/1633 5477 var schedulersFix = function (scheduler, hasTimeArg) { 5478 var firstParamIndex = hasTimeArg ? 2 : 1; 5479 return WRAP ? function (handler, timeout /* , ...arguments */) { 5480 var boundArgs = validateArgumentsLength(arguments.length, 1) > firstParamIndex; 5481 var fn = isCallable(handler) ? handler : Function$2(handler); 5482 var params = boundArgs ? arraySlice(arguments, firstParamIndex) : []; 5483 var callback = boundArgs ? function () { 5484 functionApply(fn, this, params); 5485 } : fn; 5486 return hasTimeArg ? scheduler(callback, timeout) : scheduler(callback); 5487 } : scheduler; 5488 }; 5489 5490 var setTask = task.set; 5491 5492 5493 // https://github.com/oven-sh/bun/issues/1633 5494 var setImmediate = globalThis_1.setImmediate ? schedulersFix(setTask, false) : setTask; 5495 5496 // `setImmediate` method 5497 // http://w3c.github.io/setImmediate/#si-setImmediate 5498 _export({ 5499 global: true, 5500 bind: true, 5501 enumerable: true, 5502 forced: globalThis_1.setImmediate !== setImmediate 5503 }, { 5504 setImmediate: setImmediate 5505 }); 5506 5507 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 5508 var getOwnPropertyDescriptor$2 = Object.getOwnPropertyDescriptor; 5509 5510 // Avoid NodeJS experimental warning 5511 var safeGetBuiltIn = function (name) { 5512 if (!descriptors) return globalThis_1[name]; 5513 var descriptor = getOwnPropertyDescriptor$2(globalThis_1, name); 5514 return descriptor && descriptor.value; 5515 }; 5516 5517 var Queue = function () { 5518 this.head = null; 5519 this.tail = null; 5520 }; 5521 Queue.prototype = { 5522 add: function (item) { 5523 var entry = { 5524 item: item, 5525 next: null 5526 }; 5527 var tail = this.tail; 5528 if (tail) tail.next = entry;else this.head = entry; 5529 this.tail = entry; 5530 }, 5531 get: function () { 5532 var entry = this.head; 5533 if (entry) { 5534 var next = this.head = entry.next; 5535 if (next === null) this.tail = null; 5536 return entry.item; 5537 } 5538 } 5539 }; 5540 var queue$1 = Queue; 5541 5542 var environmentIsIosPebble = /ipad|iphone|ipod/i.test(environmentUserAgent) && typeof Pebble != 'undefined'; 5543 5544 var environmentIsWebosWebkit = /web0s(?!.*chrome)/i.test(environmentUserAgent); 5545 5546 var macrotask = task.set; 5547 5548 5549 5550 5551 5552 var MutationObserver = globalThis_1.MutationObserver || globalThis_1.WebKitMutationObserver; 5553 var document$2 = globalThis_1.document; 5554 var process$2 = globalThis_1.process; 5555 var Promise = globalThis_1.Promise; 5556 var microtask = safeGetBuiltIn('queueMicrotask'); 5557 var notify, toggle, node, promise, then; 5558 5559 // modern engines have queueMicrotask method 5560 if (!microtask) { 5561 var queue$2 = new queue$1(); 5562 var flush = function () { 5563 var parent, fn; 5564 if (environmentIsNode && (parent = process$2.domain)) parent.exit(); 5565 while (fn = queue$2.get()) try { 5566 fn(); 5567 } catch (error) { 5568 if (queue$2.head) notify(); 5569 throw error; 5570 } 5571 if (parent) parent.enter(); 5572 }; 5573 5574 // browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339 5575 // also except WebOS Webkit https://github.com/zloirock/core-js/issues/898 5576 if (!environmentIsIos && !environmentIsNode && !environmentIsWebosWebkit && MutationObserver && document$2) { 5577 toggle = true; 5578 node = document$2.createTextNode(''); 5579 new MutationObserver(flush).observe(node, { 5580 characterData: true 5581 }); 5582 notify = function () { 5583 node.data = toggle = !toggle; 5584 }; 5585 // environments with maybe non-completely correct, but existent Promise 5586 } else if (!environmentIsIosPebble && Promise && Promise.resolve) { 5587 // Promise.resolve without an argument throws an error in LG WebOS 2 5588 promise = Promise.resolve(undefined); 5589 // workaround of WebKit ~ iOS Safari 10.1 bug 5590 promise.constructor = Promise; 5591 then = functionBindContext(promise.then, promise); 5592 notify = function () { 5593 then(flush); 5594 }; 5595 // Node.js without promises 5596 } else if (environmentIsNode) { 5597 notify = function () { 5598 process$2.nextTick(flush); 5599 }; 5600 // for other environments - macrotask based on: 5601 // - setImmediate 5602 // - MessageChannel 5603 // - window.postMessage 5604 // - onreadystatechange 5605 // - setTimeout 5606 } else { 5607 // `webpack` dev server bug on IE global methods - use bind(fn, global) 5608 macrotask = functionBindContext(macrotask, globalThis_1); 5609 notify = function () { 5610 macrotask(flush); 5611 }; 5612 } 5613 microtask = function (fn) { 5614 if (!queue$2.head) notify(); 5615 queue$2.add(fn); 5616 }; 5617 } 5618 var microtask_1 = microtask; 5619 5620 // Bun ~ 1.0.30 bug 5621 // https://github.com/oven-sh/bun/issues/9249 5622 var WRONG_ARITY = fails(function () { 5623 // getOwnPropertyDescriptor for prevent experimental warning in Node 11 5624 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 5625 return descriptors && Object.getOwnPropertyDescriptor(globalThis_1, 'queueMicrotask').value.length !== 1; 5626 }); 5627 5628 // `queueMicrotask` method 5629 // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-queuemicrotask 5630 _export({ 5631 global: true, 5632 enumerable: true, 5633 dontCallGetSet: true, 5634 forced: WRONG_ARITY 5635 }, { 5636 queueMicrotask: function queueMicrotask(fn) { 5637 validateArgumentsLength(arguments.length, 1); 5638 microtask_1(aCallable(fn)); 5639 } 5640 }); 5641 5642 // File generated automatically. Don't modify it. 5643 5644}((this.window = this.window || {}))); 5645 5646 5647 5648if (window._main_polyfill_core) 5649{ 5650 console.warn('main.polyfill.core is loaded more than once on this page'); 5651} 5652 5653window._main_polyfill_core = true; 5654 5655 5656(function (exports) { 5657 'use strict'; 5658 5659 var bxTmp = window.BX; 5660 window.BX = function (node) { 5661 if (window.BX.type.isNotEmptyString(node)) { 5662 return document.getElementById(node); 5663 } 5664 if (window.BX.type.isDomNode(node)) { 5665 return node; 5666 } 5667 if (window.BX.type.isFunction(node)) { 5668 return window.BX.ready(node); 5669 } 5670 return null; 5671 }; 5672 if (bxTmp) {
5673 Object.keys(bxTmp).forEach(key => { 5674 window.BX[key] = bxTmp[key]; 5675 }); 5676 } 5677 exports = window.BX; 5678 5679 /** 5680 * Gets object.toString result 5681 * @param value 5682 * @return {string} 5683 */ 5684 function getTag(value) { 5685 return Object.prototype.toString.call(value); 5686 } 5687 5688 const objectCtorString = Function.prototype.toString.call(Object); 5689 5690 /** 5691 * @memberOf BX 5692 */ 5693 let Type = /*#__PURE__*/function () { 5694 function Type() { 5695 babelHelpers.classCallCheck(this, Type); 5696 } 5697 babelHelpers.createClass(Type, null, [{ 5698 key: "isString", 5699 /** 5700 * Checks that value is string 5701 * @param value 5702 * @return {boolean} 5703 */ 5704 value: function isString(value) { 5705 return typeof value === 'string'; 5706 } 5707 /** 5708 * Returns true if a value is not empty string 5709 * @param value 5710 * @returns {boolean} 5711 */ 5712 }, { 5713 key: "isStringFilled", 5714 value: function isStringFilled(value) { 5715 return Type.isString(value) && value !== ''; 5716 } 5717 /** 5718 * Checks that value is function 5719 * @param value 5720 * @return {boolean} 5721 */ 5722 }, { 5723 key: "isFunction", 5724 value: function isFunction(value) { 5725 return typeof value === 'function'; 5726 } 5727 /** 5728 * Checks that value is object 5729 * @param value 5730 * @return {boolean} 5731 */ 5732 }, { 5733 key: "isObject", 5734 value: function isObject(value) { 5735 return !!value && (typeof value === 'object' || typeof value === 'function'); 5736 } 5737 /** 5738 * Checks that value is object like 5739 * @param value 5740 * @return {boolean} 5741 */ 5742 }, { 5743 key: "isObjectLike", 5744 value: function isObjectLike(value) { 5745 return !!value && typeof value === 'object'; 5746 } 5747 /** 5748 * Checks that value is plain object 5749 * @param value 5750 * @return {boolean} 5751 */ 5752 }, { 5753 key: "isPlainObject", 5754 value: function isPlainObject(value) { 5755 if (!Type.isObjectLike(value) || getTag(value) !== '[object Object]') { 5756 return false; 5757 } 5758 const proto = Object.getPrototypeOf(value); 5759 if (proto === null) { 5760 return true; 5761 } 5762 const ctor = proto.hasOwnProperty('constructor') && proto.constructor; 5763 return typeof ctor === 'function' && Function.prototype.toString.call(ctor) === objectCtorString; 5764 } 5765 /** 5766 * Checks that value is boolean 5767 * @param value 5768 * @return {boolean} 5769 */ 5770 }, { 5771 key: "isBoolean", 5772 value: function isBoolean(value) { 5773 return value === true || value === false; 5774 } 5775 /** 5776 * Checks that value is number 5777 * @param value 5778 * @return {boolean} 5779 */ 5780 }, { 5781 key: "isNumber", 5782 value: function isNumber(value) { 5783 return !Number.isNaN(value) && typeof value === 'number'; 5784 } 5785 /** 5786 * Checks that value is integer 5787 * @param value 5788 * @return {boolean} 5789 */ 5790 }, { 5791 key: "isInteger", 5792 value: function isInteger(value) { 5793 return Type.isNumber(value) && value % 1 === 0; 5794 } 5795 /** 5796 * Checks that value is float 5797 * @param value 5798 * @return {boolean} 5799 */ 5800 }, { 5801 key: "isFloat", 5802 value: function isFloat(value) { 5803 return Type.isNumber(value) && !Type.isInteger(value); 5804 } 5805 /** 5806 * Checks that value is nil 5807 * @param value 5808 * @return {boolean} 5809 */ 5810 }, { 5811 key: "isNil", 5812 value: function isNil(value) { 5813 return value === null || value === undefined; 5814 } 5815 /** 5816 * Checks that value is array 5817 * @param value 5818 * @return {boolean} 5819 */ 5820 }, { 5821 key: "isArray", 5822 value: function isArray(value) { 5823 return !Type.isNil(value) && Array.isArray(value); 5824 } 5825 /** 5826 * Returns true if a value is an array and it has at least one element 5827 * @param value 5828 * @returns {boolean} 5829 */ 5830 }, { 5831 key: "isArrayFilled", 5832 value: function isArrayFilled(value) { 5833 return Type.isArray(value) && value.length > 0; 5834 } 5835 /** 5836 * Checks that value is array like 5837 * @param value 5838 * @return {boolean} 5839 */ 5840 }, { 5841 key: "isArrayLike", 5842 value: function isArrayLike(value) { 5843 return !Type.isNil(value) && !Type.isFunction(value) && value.length > -1 && value.length <= Number.MAX_SAFE_INTEGER; 5844 } 5845 /** 5846 * Checks that value is Date 5847 * @param value 5848 * @return {boolean} 5849 */ 5850 }, { 5851 key: "isDate", 5852 value: function isDate(value) { 5853 return Type.isObjectLike(value) && getTag(value) === '[object Date]'; 5854 } 5855 /** 5856 * Checks that is DOM node 5857 * @param value 5858 * @return {boolean} 5859 */ 5860 }, { 5861 key: "isDomNode", 5862 value: function isDomNode(value) { 5863 return Type.isObjectLike(value) && !Type.isPlainObject(value) && 'nodeType' in value; 5864 } 5865 /** 5866 * Checks that value is element node 5867 * @param value 5868 * @return {boolean} 5869 */ 5870 }, { 5871 key: "isElementNode", 5872 value: function isElementNode(value) { 5873 return Type.isDomNode(value) && value.nodeType === Node.ELEMENT_NODE; 5874 } 5875 /** 5876 * Checks that value is text node 5877 * @param value 5878 * @return {boolean} 5879 */ 5880 }, { 5881 key: "isTextNode", 5882 value: function isTextNode(value) { 5883 return Type.isDomNode(value) && value.nodeType === Node.TEXT_NODE; 5884 } 5885 /** 5886 * Checks that value is Map 5887 * @param value 5888 * @return {boolean} 5889 */ 5890 }, { 5891 key: "isMap", 5892 value: function isMap(value) { 5893 return Type.isObjectLike(value) && getTag(value) === '[object Map]'; 5894 } 5895 /** 5896 * Checks that value is Set 5897 * @param value 5898 * @return {boolean} 5899 */ 5900 }, { 5901 key: "isSet", 5902 value: function isSet(value) { 5903 return Type.isObjectLike(value) && getTag(value) === '[object Set]'; 5904 } 5905 /** 5906 * Checks that value is WeakMap 5907 * @param value 5908 * @return {boolean} 5909 */ 5910 }, { 5911 key: "isWeakMap", 5912 value: function isWeakMap(value) { 5913 return Type.isObjectLike(value) && getTag(value) === '[object WeakMap]'; 5914 } 5915 /** 5916 * Checks that value is WeakSet 5917 * @param value 5918 * @return {boolean} 5919 */ 5920 }, { 5921 key: "isWeakSet", 5922 value: function isWeakSet(value) { 5923 return Type.isObjectLike(value) && getTag(value) === '[object WeakSet]'; 5924 } 5925 /** 5926 * Checks that value is prototype 5927 * @param value 5928 * @return {boolean} 5929 */ 5930 }, { 5931 key: "isPrototype", 5932 value: function isPrototype(value) { 5933 return (typeof (value && value.constructor) === 'function' && value.constructor.prototype || Object.prototype) === value; 5934 } 5935 /** 5936 * Checks that value is regexp 5937 * @param value 5938 * @return {boolean} 5939 */ 5940 }, { 5941 key: "isRegExp", 5942 value: function isRegExp(value) { 5943 return Type.isObjectLike(value) && getTag(value) === '[object RegExp]'; 5944 } 5945 /** 5946 * Checks that value is null 5947 * @param value 5948 * @return {boolean} 5949 */ 5950 }, { 5951 key: "isNull", 5952 value: function isNull(value) { 5953 return value === null; 5954 } 5955 /** 5956 * Checks that value is undefined 5957 * @param value 5958 * @return {boolean} 5959 */ 5960 }, { 5961 key: "isUndefined", 5962 value: function isUndefined(value) { 5963 return typeof value === 'undefined'; 5964 } 5965 /** 5966 * Checks that value is ArrayBuffer 5967 * @param value 5968 * @return {boolean} 5969 */ 5970 }, { 5971 key: "isArrayBuffer", 5972 value: function isArrayBuffer(value) { 5973 return Type.isObjectLike(value) && getTag(value) === '[object ArrayBuffer]'; 5974 } 5975 /** 5976 * Checks that value is typed array 5977 * @param value 5978 * @return {boolean} 5979 */ 5980 }, { 5981 key: "isTypedArray", 5982 value: function isTypedArray(value) { 5983 const regExpTypedTag = /^\[object (?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)]$/; 5984 return Type.isObjectLike(value) && regExpTypedTag.test(getTag(value)); 5985 } 5986 /** 5987 * Checks that value is Blob 5988 * @param value 5989 * @return {boolean} 5990 */ 5991 }, { 5992 key: "isBlob", 5993 value: function isBlob(value) { 5994 return Type.isObjectLike(value) && Type.isNumber(value.size) && Type.isString(value.type) && Type.isFunction(value.slice); 5995 } 5996 /** 5997 * Checks that value is File 5998 * @param value 5999 * @return {boolean} 6000 */ 6001 }, { 6002 key: "isFile", 6003 value: function isFile(value) { 6004 return Type.isBlob(value) && Type.isString(value.name) && (Type.isNumber(value.lastModified) || Type.isObjectLike(value.lastModifiedDate)); 6005 } 6006 /** 6007 * Checks that value is FormData 6008 * @param value 6009 * @return {boolean} 6010 */ 6011 }, { 6012 key: "isFormData", 6013 value: function isFormData(value) { 6014 return value instanceof FormData; 6015 } 6016 }]); 6017 return Type; 6018 }(); 6019 6020 /** 6021 * @memberOf BX 6022 */ 6023 let Reflection = /*#__PURE__*/function () { 6024 function Reflection() { 6025 babelHelpers.classCallCheck(this, Reflection); 6026 } 6027 babelHelpers.createClass(Reflection, null, [{ 6028 key: "getClass", 6029 /** 6030 * Gets link to function by function name 6031 * @param className 6032 * @return {?Function} 6033 */ 6034 value: function getClass(className) { 6035 if (Type.isString(className) && !!className) { 6036 let classFn = null; 6037 let currentNamespace = window; 6038 const namespaces = className.split('.'); 6039 for (let i = 0; i < namespaces.length; i += 1) { 6040 const namespace = namespaces[i]; 6041 if (!currentNamespace[namespace]) { 6042 return null; 6043 } 6044 currentNamespace = currentNamespace[namespace]; 6045 classFn = currentNamespace; 6046 } 6047 return classFn; 6048 } 6049 if (Type.isFunction(className)) { 6050 return className; 6051 } 6052 return null; 6053 } 6054 /** 6055 * Creates a namespace or returns a link to a previously created one 6056 * @param {String} namespaceName 6057 * @return {Object<string, any> | Function | null} 6058 */ 6059 }, { 6060 key: "namespace", 6061 value: function namespace(namespaceName) { 6062 let parts = namespaceName.split('.'); 6063 let parent = window.BX; 6064 if (parts[0] === 'BX') { 6065 parts = parts.slice(1); 6066 } 6067 for (let i = 0; i < parts.length; i += 1) { 6068 if (Type.isUndefined(parent[parts[i]])) { 6069 parent[parts[i]] = {}; 6070 } 6071 parent = parent[parts[i]]; 6072 } 6073 return parent; 6074 } 6075 }]); 6076 return Reflection; 6077 }(); 6078 6079 const reEscape = /[&<>'"]/g; 6080 const reUnescape = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g; 6081 const escapeEntities = { 6082 '&': '&', 6083 '<': '<', 6084 '>': '>', 6085 "'": ''', 6086 '"': '"' 6087 }; 6088 const unescapeEntities = { 6089 '&': '&', 6090 '&': '&', 6091 '<': '<', 6092 '<': '<', 6093 '>': '>', 6094 '>': '>', 6095 ''': "'", 6096 ''': "'", 6097 '"': '"', 6098 '"': '"' 6099 }; 6100 6101 /** 6102 * @memberOf BX 6103 */ 6104 let Text = /*#__PURE__*/function () { 6105 function Text() { 6106 babelHelpers.classCallCheck(this, Text); 6107 } 6108 babelHelpers.createClass(Text, null, [{ 6109 key: "encode", 6110 /** 6111 * Encodes all unsafe entities 6112 * @param {string} value 6113 * @return {string} 6114 */ 6115 value: function encode(value) { 6116 if (Type.isString(value)) { 6117 return value.replace(reEscape, item => escapeEntities[item]); 6118 } 6119 return value; 6120 } 6121 /** 6122 * Decodes all encoded entities 6123 * @param {string} value 6124 * @return {string} 6125 */ 6126 }, { 6127 key: "decode", 6128 value: function decode(value) { 6129 if (Type.isString(value)) { 6130 return value.replace(reUnescape, item => unescapeEntities[item]); 6131 } 6132 return value; 6133 } 6134 }, { 6135 key: "getRandom", 6136 value: function getRandom(length = 8) { 6137 // eslint-disable-next-line 6138 return [...Array(length)].map(() => (~~(Math.random() * 36)).toString(36)).join(''); 6139 } 6140 }, { 6141 key: "toNumber", 6142 value: function toNumber(value) { 6143 const parsedValue = Number.parseFloat(value); 6144 if (Type.isNumber(parsedValue)) { 6145 return parsedValue; 6146 } 6147 return 0; 6148 } 6149 }, { 6150 key: "toInteger", 6151 value: function toInteger(value) { 6152 return Text.toNumber(Number.parseInt(value, 10)); 6153 } 6154 }, { 6155 key: "toBoolean", 6156 value: function toBoolean(value, trueValues = []) { 6157 const transformedValue = Type.isString(value) ? value.toLowerCase() : value; 6158 return ['true', 'y', '1', 1, true, ...trueValues].includes(transformedValue); 6159 } 6160 }, { 6161 key: "toCamelCase", 6162 value: function toCamelCase(str) { 6163 if (!Type.isStringFilled(str)) { 6164 return str; 6165 } 6166 const regex = /[-_\s]+(.)?/g; 6167 if (!regex.test(str)) { 6168 return str.match(/^[A-Z]+$/) ? str.toLowerCase() : str[0].toLowerCase() + str.slice(1); 6169 } 6170 str = str.toLowerCase(); 6171 str = str.replace(regex, function (match, letter) { 6172 return letter ? letter.toUpperCase() : ''; 6173 }); 6174 return str[0].toLowerCase() + str.substr(1); 6175 } 6176 }, { 6177 key: "toPascalCase", 6178 value: function toPascalCase(str) { 6179 if (!Type.isStringFilled(str)) { 6180 return str; 6181 } 6182 return this.capitalize(this.toCamelCase(str)); 6183 } 6184 }, { 6185 key: "toKebabCase", 6186 value: function toKebabCase(str) { 6187 if (!Type.isStringFilled(str)) { 6188 return str; 6189 } 6190 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); 6191 if (!matches) { 6192 return str; 6193 } 6194 return matches.map(x => x.toLowerCase()).join('-'); 6195 } 6196 }, { 6197 key: "capitalize", 6198 value: function capitalize(str) { 6199 if (!Type.isStringFilled(str)) { 6200 return str; 6201 } 6202 return str[0].toUpperCase() + str.substr(1); 6203 } 6204 }]); 6205 return Text; 6206 }(); 6207 6208 const aliases = { 6209 mousewheel: ['DOMMouseScroll'], 6210 bxchange: ['change', 'cut', 'paste', 'drop', 'keyup'], 6211 animationend: ['animationend', 'oAnimationEnd', 'webkitAnimationEnd', 'MSAnimationEnd'], 6212 transitionend: ['webkitTransitionEnd', 'otransitionend', 'oTransitionEnd', 'msTransitionEnd', 'transitionend'], 6213 fullscreenchange: ['fullscreenchange', 'webkitfullscreenchange', 'mozfullscreenchange', 'MSFullscreenChange'], 6214 fullscreenerror: ['fullscreenerror', 'webkitfullscreenerror', 'mozfullscreenerror', 'MSFullscreenError'] 6215 }; 6216 6217 let Registry = /*#__PURE__*/function () { 6218 function Registry() { 6219 babelHelpers.classCallCheck(this, Registry); 6220 babelHelpers.defineProperty(this, "registry", new WeakMap()); 6221 } 6222 babelHelpers.createClass(Registry, [{ 6223 key: "set", 6224 value: function set(target, event, listener) { 6225 const events = this.get(target); 6226 if (!Type.isSet(events[event])) { 6227 events[event] = new Set(); 6228 } 6229 events[event].add(listener); 6230 this.registry.set(target, events); 6231 } 6232 }, { 6233 key: "get", 6234 value: function get(target) { 6235 return this.registry.get(target) || {}; 6236 } 6237 }, { 6238 key: "has", 6239 value: function has(target, event, listener) { 6240 if (event && listener) { 6241 return this.registry.has(target) && this.registry.get(target)[event].has(listener); 6242 } 6243 return this.registry.has(target); 6244 } 6245 }, { 6246 key: "delete", 6247 value: function _delete(target, event, listener) { 6248 if (!Type.isDomNode(target)) { 6249 return; 6250 } 6251 if (Type.isString(event) && Type.isFunction(listener)) { 6252 const events = this.registry.get(target); 6253 if (Type.isPlainObject(events) && Type.isSet(events[event])) { 6254 events[event].delete(listener); 6255 } 6256 return; 6257 } 6258 if (Type.isString(event)) { 6259 const events = this.registry.get(target); 6260 if (Type.isPlainObject(events) && Type.isSet(events[event])) { 6261 events[event] = new Set(); 6262 } 6263 return; 6264 } 6265 this.registry.delete(target); 6266 } 6267 }]); 6268 return Registry; 6269 }(); 6270 var registry = new Registry(); 6271 6272 function isOptionSupported(name) { 6273 let isSupported = false;
6274 try { 6275 const options = Object.defineProperty({}, name, { 6276 get() { 6277 isSupported = true; 6278 return undefined; 6279 } 6280 }); 6281 window.addEventListener('test', null, options); 6282 } 6283 // eslint-disable-next-line 6284 catch (err) {} 6285 return isSupported; 6286 } 6287 function fetchSupportedListenerOptions(options) { 6288 if (!Type.isPlainObject(options)) { 6289 return options; 6290 } 6291 return Object.keys(options).reduce((acc, name) => { 6292 if (isOptionSupported(name)) { 6293 acc[name] = options[name]; 6294 } 6295 return acc; 6296 }, {}); 6297 } 6298 6299 function bind(target, eventName, handler, options) { 6300 if (!Type.isObject(target) || !Type.isFunction(target.addEventListener)) { 6301 return; 6302 } 6303 const listenerOptions = fetchSupportedListenerOptions(options); 6304 if (eventName in aliases) { 6305 aliases[eventName].forEach(key => { 6306 target.addEventListener(key, handler, listenerOptions); 6307 registry.set(target, eventName, handler); 6308 }); 6309 return; 6310 } 6311 target.addEventListener(eventName, handler, listenerOptions); 6312 registry.set(target, eventName, handler); 6313 } 6314 6315 function unbind(target, eventName, handler, options) { 6316 if (!Type.isObject(target) || !Type.isFunction(target.removeEventListener)) { 6317 return; 6318 } 6319 const listenerOptions = fetchSupportedListenerOptions(options); 6320 if (eventName in aliases) { 6321 aliases[eventName].forEach(key => { 6322 target.removeEventListener(key, handler, listenerOptions); 6323 registry.delete(target, key, handler); 6324 }); 6325 return; 6326 } 6327 target.removeEventListener(eventName, handler, listenerOptions); 6328 registry.delete(target, eventName, handler); 6329 } 6330 6331 function unbindAll(target, eventName) { 6332 const events = registry.get(target); 6333 Object.keys(events).forEach(currentEvent => { 6334 events[currentEvent].forEach(handler => { 6335 if (!Type.isString(eventName) || eventName === currentEvent) { 6336 unbind(target, currentEvent, handler); 6337 } 6338 }); 6339 }); 6340 } 6341 6342 function bindOnce(target, eventName, handler, options) { 6343 const once = function once(...args) { 6344 unbind(target, eventName, once, options); 6345 handler(...args); 6346 }; 6347 bind(target, eventName, once, options); 6348 } 6349 6350 // eslint-disable-next-line 6351 let debugState = true; 6352 function enableDebug() { 6353 debugState = true; 6354 } 6355 function disableDebug() { 6356 debugState = false; 6357 } 6358 function isDebugEnabled() { 6359 return debugState; 6360 } 6361 function debug(...args) { 6362 if (isDebugEnabled() && Type.isObject(window.console)) { 6363 if (Type.isFunction(window.console.log)) { 6364 window.console.log('BX.debug: ', args.length > 0 ? args : args[0]); 6365 if (args[0] instanceof Error && args[0].stack) { 6366 window.console.log('BX.debug error stack trace', args[0].stack); 6367 } 6368 } 6369 if (Type.isFunction(window.console.trace)) { 6370 // eslint-disable-next-line 6371 console.trace(); 6372 } 6373 } 6374 } 6375 6376 var debugNs = /*#__PURE__*/Object.freeze({ 6377 get debugState () { return debugState; }, 6378 enableDebug: enableDebug, 6379 disableDebug: disableDebug, 6380 isDebugEnabled: isDebugEnabled, 6381 default: debug 6382 }); 6383 6384 const extensionsStorage = new Map(); 6385 6386 const ajaxController = 'main.bitrix.main.controller.loadext.getextensions'; 6387 function loadAssets(options) { 6388 return new Promise(resolve => { 6389 // eslint-disable-next-line 6390 BX.ajax.runAction(ajaxController, { 6391 data: options 6392 }).then(resolve); 6393 }); 6394 } 6395 6396 function fetchInlineScripts(acc, item) { 6397 if (item.isInternal) { 6398 acc.push(item.JS); 6399 } 6400 return acc; 6401 } 6402 function fetchExternalScripts(acc, item) { 6403 if (!item.isInternal) { 6404 acc.push(item.JS); 6405 } 6406 return acc; 6407 } 6408 function fetchExternalStyles(acc, item) { 6409 if (Type.isString(item) && item !== '') { 6410 acc.push(item); 6411 } 6412 return acc; 6413 } 6414 function fetchExtensionSettings(html) { 6415 if (Type.isStringFilled(html)) { 6416 const scripts = html.match(/<script type="extension\/settings" \b[^>]*>([\s\S]*?)<\/script>/g); 6417 if (Type.isArrayFilled(scripts)) { 6418 return scripts.map(script => { 6419 const [, extension] = script.match(/data-extension="(.[a-z0-9_.-]+)"/); 6420 return { 6421 extension, 6422 script 6423 }; 6424 }); 6425 } 6426 } 6427 return []; 6428 } 6429 function loadAll(items) { 6430 const itemsList = Type.isArray(items) ? items : [items]; 6431 if (!itemsList.length) { 6432 return Promise.resolve(); 6433 } 6434 return new Promise(resolve => { 6435 // eslint-disable-next-line 6436 BX.load(itemsList, resolve); 6437 }); 6438 } 6439 6440 function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); } 6441 function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } } 6442 const defaultOptions = { 6443 loaded: false 6444 }; 6445 var _state = /*#__PURE__*/new WeakMap(); 6446 var _name = /*#__PURE__*/new WeakMap(); 6447 var _namespace = /*#__PURE__*/new WeakMap(); 6448 var _promise = /*#__PURE__*/new WeakMap(); 6449 let Extension = /*#__PURE__*/function () { 6450 function Extension(options) { 6451 babelHelpers.classCallCheck(this, Extension); 6452 _classPrivateFieldInitSpec(this, _state, { 6453 writable: true, 6454 value: Extension.State.LOADING 6455 }); 6456 _classPrivateFieldInitSpec(this, _name, { 6457 writable: true, 6458 value: '' 6459 }); 6460 _classPrivateFieldInitSpec(this, _namespace, { 6461 writable: true, 6462 value: '' 6463 }); 6464 _classPrivateFieldInitSpec(this, _promise, { 6465 writable: true, 6466 value: null 6467 }); 6468 const preparedOptions = { 6469 ...defaultOptions, 6470 ...options 6471 }; 6472 babelHelpers.classPrivateFieldSet(this, _name, preparedOptions.name); 6473 babelHelpers.classPrivateFieldSet(this, _namespace, Type.isStringFilled(preparedOptions.namespace) ? preparedOptions.namespace : 'window'); 6474 if (preparedOptions.loaded) { 6475 babelHelpers.classPrivateFieldSet(this, _state, Extension.State.LOADED); 6476 } 6477 } 6478 babelHelpers.createClass(Extension, [{ 6479 key: "load", 6480 value: function load() { 6481 if (babelHelpers.classPrivateFieldGet(this, _state) === Extension.State.LOADED && !babelHelpers.classPrivateFieldGet(this, _promise)) { 6482 babelHelpers.classPrivateFieldSet(this, _promise, Promise.resolve(Reflection.getClass(babelHelpers.classPrivateFieldGet(this, _namespace)))); 6483 } 6484 if (babelHelpers.classPrivateFieldGet(this, _promise)) { 6485 return babelHelpers.classPrivateFieldGet(this, _promise); 6486 } 6487 babelHelpers.classPrivateFieldSet(this, _state, Extension.State.LOADING); 6488 babelHelpers.classPrivateFieldSet(this, _promise, new Promise(resolve => { 6489 void loadAssets({ 6490 extension: [babelHelpers.classPrivateFieldGet(this, _name)] 6491 }).then(assetsResult => { 6492 if (!Type.isArrayFilled(assetsResult.data)) { 6493 resolve(window); 6494 }
6495 const extensionData = assetsResult.data.at(0); 6496 if (Type.isPlainObject(extensionData.config) && Type.isStringFilled(extensionData.config.namespace)) { 6497 babelHelpers.classPrivateFieldSet(this, _namespace, extensionData.config.namespace); 6498 } 6499 const result = BX.processHTML(extensionData.html || ''); 6500 const inlineScripts = result.SCRIPT.reduce(fetchInlineScripts, []); 6501 const externalScripts = result.SCRIPT.reduce(fetchExternalScripts, []); 6502 const externalStyles = result.STYLE.reduce(fetchExternalStyles, []); 6503 const settingsScripts = fetchExtensionSettings(result.HTML); 6504 settingsScripts.forEach(entry => { 6505 document.body.insertAdjacentHTML('beforeend', entry.script); 6506 }); 6507 const runScriptsBefore = inlineScripts.filter(script => { 6508 return !script.startsWith('BX.Runtime.registerExtension'); 6509 }); 6510 const runScriptsAfter = inlineScripts.filter(script => { 6511 return script.startsWith('BX.Runtime.registerExtension'); 6512 }); 6513 runScriptsBefore.forEach(script => { 6514 BX.evalGlobal(script); 6515 }); 6516 void Promise.all([loadAll(externalScripts), loadAll(externalStyles)]).then(() => { 6517 babelHelpers.classPrivateFieldSet(this, _state, Extension.State.LOADED); 6518 runScriptsAfter.forEach(script => { 6519 BX.evalGlobal(script); 6520 }); 6521 if (babelHelpers.classPrivateFieldGet(this, _namespace)) { 6522 return Reflection.getClass(babelHelpers.classPrivateFieldGet(this, _namespace)); 6523 } 6524 return window; 6525 }).then(exports => { 6526 resolve(exports); 6527 }); 6528 }); 6529 })); 6530 return babelHelpers.classPrivateFieldGet(this, _promise); 6531 } 6532 }]); 6533 return Extension; 6534 }(); 6535 babelHelpers.defineProperty(Extension, "State", { 6536 LOADED: 'LOADED', 6537 LOADING: 'LOADING' 6538 }); 6539 6540 async function loadExtension(...extensionName) { 6541 const extensionNames = extensionName.flat(); 6542 const result = extensionNames.map(name => { 6543 if (extensionsStorage.has(name)) { 6544 return extensionsStorage.get(name).load(); 6545 } 6546 const extension = new Extension({ 6547 name 6548 }); 6549 extensionsStorage.set(name, extension); 6550 return extension.load(); 6551 }); 6552 return Promise.all(result).then(exports => { 6553 return exports.reduce((acc, currentExports) => { 6554 if (Type.isObject(currentExports)) { 6555 return { 6556 ...acc, 6557 ...currentExports 6558 }; 6559 } 6560 return acc; 6561 }, {}); 6562 }); 6563 } 6564 6565 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]']; 6566 function isCloneable(value) { 6567 const isCloneableValue = Type.isObjectLike(value) && cloneableTags.includes(getTag(value)); 6568 return isCloneableValue || Type.isDomNode(value); 6569 } 6570 function internalClone(value, map) { 6571 if (map.has(value)) { 6572 return map.get(value); 6573 } 6574 if (isCloneable(value)) { 6575 if (Type.isArray(value)) { 6576 const cloned = Array.from(value); 6577 map.set(value, cloned); 6578 value.forEach((item, index) => { 6579 cloned[index] = internalClone(item, map); 6580 }); 6581 return map.get(value); 6582 } 6583 if (Type.isDomNode(value)) { 6584 return value.cloneNode(true); 6585 } 6586 if (Type.isMap(value)) { 6587 const result = new Map(); 6588 map.set(value, result); 6589 value.forEach((item, key) => { 6590 result.set(internalClone(key, map), internalClone(item, map)); 6591 }); 6592 return result; 6593 } 6594 if (Type.isSet(value)) { 6595 const result = new Set(); 6596 map.set(value, result); 6597 value.forEach(item => { 6598 result.add(internalClone(item, map)); 6599 }); 6600 return result; 6601 } 6602 if (Type.isDate(value)) { 6603 return new Date(value); 6604 } 6605 if (Type.isRegExp(value)) { 6606 const regExpFlags = /\w*$/; 6607 const flags = regExpFlags.exec(value); 6608 let result = new RegExp(value.source); 6609 if (flags && Type.isArray(flags)) { 6610 result = new RegExp(value.source, flags[0]); 6611 } 6612 result.lastIndex = value.lastIndex; 6613 return result; 6614 } 6615 const proto = Object.getPrototypeOf(value); 6616 const result = Object.assign(Object.create(proto), value); 6617 map.set(value, result); 6618 Object.keys(value).forEach(key => { 6619 result[key] = internalClone(value[key], map); 6620 }); 6621 return result; 6622 } 6623 return value; 6624 } 6625 6626 /** 6627 * Clones any cloneable object 6628 * @param value 6629 * @return {*} 6630 */ 6631 function clone(value) { 6632 return internalClone(value, new WeakMap()); 6633 } 6634 6635 function merge(current, target) { 6636 return Object.entries(target).reduce((acc, [key, value]) => { 6637 if (!Type.isDomNode(acc[key]) && Type.isObjectLike(acc[key]) && Type.isObjectLike(value)) { 6638 acc[key] = merge(acc[key], value); 6639 return acc; 6640 } 6641 acc[key] = value; 6642 return acc; 6643 }, current); 6644 } 6645 6646 function createComparator(fields, orders = []) { 6647 return (a, b) => { 6648 const field = fields[0]; 6649 const order = orders[0] || 'asc'; 6650 if (Type.isUndefined(field)) { 6651 return 0; 6652 } 6653 let valueA = a[field]; 6654 let valueB = b[field]; 6655 if (Type.isString(valueA) && Type.isString(valueB)) { 6656 valueA = valueA.toLowerCase(); 6657 valueB = valueB.toLowerCase(); 6658 } 6659 if (valueA < valueB) { 6660 return order === 'asc' ? -1 : 1; 6661 } 6662 if (valueA > valueB) { 6663 return order === 'asc' ? 1 : -1; 6664 } 6665 return createComparator(fields.slice(1), orders.slice(1))(a, b); 6666 }; 6667 } 6668 6669 function registerExtension(options) { 6670 if (!extensionsStorage.has(options.name)) { 6671 extensionsStorage.set(options.name, new Extension(options)); 6672 } 6673 } 6674
6675 /** 6676 * @memberOf BX 6677 */ 6678 let Runtime = /*#__PURE__*/function () { 6679 function Runtime() { 6680 babelHelpers.classCallCheck(this, Runtime); 6681 } 6682 babelHelpers.createClass(Runtime, null, [{ 6683 key: "debounce", 6684 value: function debounce(func, wait = 0, context = null) { 6685 let timeoutId; 6686 return function debounced(...args) { 6687 if (Type.isNumber(timeoutId)) { 6688 clearTimeout(timeoutId); 6689 } 6690 timeoutId = setTimeout(() => { 6691 func.apply(context || this, args); 6692 }, wait); 6693 }; 6694 } 6695 }, { 6696 key: "throttle", 6697 value: function throttle(func, wait = 0, context = null) { 6698 let timer = 0; 6699 let invoke; 6700 return function wrapper(...args) { 6701 invoke = true; 6702 if (!timer) { 6703 const q = function q() { 6704 if (invoke) { 6705 func.apply(context || this, args); 6706 invoke = false; 6707 timer = setTimeout(q, wait); 6708 } else { 6709 timer = null; 6710 } 6711 }; 6712 q(); 6713 } 6714 }; 6715 } 6716 }, { 6717 key: "html", 6718 value: function html(node, _html, params = {}) { 6719 if (Type.isNil(_html) && Type.isDomNode(node)) { 6720 return node.innerHTML; 6721 } 6722 6723 // eslint-disable-next-line 6724 const parsedHtml = BX.processHTML(_html); 6725 const externalCss = parsedHtml.STYLE.reduce(fetchExternalStyles, []); 6726 const externalJs = parsedHtml.SCRIPT.reduce(fetchExternalScripts, []); 6727 const inlineJs = parsedHtml.SCRIPT.reduce(fetchInlineScripts, []); 6728 if (Type.isDomNode(node)) { 6729 if (params.htmlFirst || !externalJs.length && !externalCss.length) { 6730 if (params.useAdjacentHTML) { 6731 node.insertAdjacentHTML('beforeend', parsedHtml.HTML); 6732 } else { 6733 node.innerHTML = parsedHtml.HTML; 6734 } 6735 } 6736 } 6737 return Promise.all([loadAll(externalJs), loadAll(externalCss)]).then(() => { 6738 if (Type.isDomNode(node) && (externalJs.length > 0 || externalCss.length > 0)) { 6739 if (params.useAdjacentHTML) { 6740 node.insertAdjacentHTML('beforeend', parsedHtml.HTML); 6741 } else { 6742 node.innerHTML = parsedHtml.HTML; 6743 } 6744 } 6745 6746 // eslint-disable-next-line 6747 inlineJs.forEach(script => BX.evalGlobal(script)); 6748 if (Type.isFunction(params.callback)) { 6749 params.callback(); 6750 } 6751 }); 6752 } 6753 /** 6754 * Merges objects or arrays 6755 * @param targets 6756 * @return {any} 6757 */ 6758 }, { 6759 key: "merge", 6760 value: function merge$$1(...targets) { 6761 if (Type.isArray(targets[0])) { 6762 targets.unshift([]); 6763 } else if (Type.isObject(targets[0])) { 6764 targets.unshift({}); 6765 } 6766 return targets.reduce((acc, item) => { 6767 return merge(acc, item); 6768 }, targets[0]); 6769 } 6770 }, { 6771 key: "orderBy", 6772 value: function orderBy(collection, fields = [], orders = []) { 6773 const comparator = createComparator(fields, orders); 6774 return Object.values(collection).sort(comparator); 6775 } 6776 }, { 6777 key: "destroy", 6778 value: function destroy(target, errorMessage = 'Object is destroyed') { 6779 if (Type.isObject(target)) { 6780 const onPropertyAccess = () => { 6781 throw new Error(errorMessage); 6782 }; 6783 const ownProperties = Object.keys(target); 6784 const prototypeProperties = (() => { 6785 const targetPrototype = Object.getPrototypeOf(target); 6786 if (Type.isObject(targetPrototype)) { 6787 return Object.getOwnPropertyNames(targetPrototype); 6788 } 6789 return []; 6790 })(); 6791 const uniquePropertiesList = [...new Set([...ownProperties, ...prototypeProperties])]; 6792 uniquePropertiesList.filter(name => { 6793 const descriptor = Object.getOwnPropertyDescriptor(target, name); 6794 return !/__(.+)__/.test(name) && (!Type.isObject(descriptor) || descriptor.configurable === true); 6795 }
6795).forEach(name => { 6796 Object.defineProperty(target, name, { 6797 get: onPropertyAccess, 6798 set: onPropertyAccess, 6799 configurable: false 6800 }); 6801 }); 6802 Object.setPrototypeOf(target, null); 6803 } 6804 } 6805 }]); 6806 return Runtime; 6807 }(); 6808 babelHelpers.defineProperty(Runtime, "debug", debug); 6809 babelHelpers.defineProperty(Runtime, "loadExtension", loadExtension); 6810 babelHelpers.defineProperty(Runtime, "registerExtension", registerExtension); 6811 babelHelpers.defineProperty(Runtime, "clone", clone); 6812 6813 const _isError = Symbol.for('BX.BaseError.isError'); 6814 6815 /** 6816 * @memberOf BX 6817 */ 6818 let BaseError = /*#__PURE__*/function () { 6819 function BaseError(message, code, customData) { 6820 babelHelpers.classCallCheck(this, BaseError); 6821 this[_isError] = true; 6822 this.message = ''; 6823 this.code = null; 6824 this.customData = null; 6825 this.setMessage(message); 6826 this.setCode(code); 6827 this.setCustomData(customData); 6828 } 6829 6830 /** 6831 * Returns a brief description of the error 6832 * @returns {string} 6833 */ 6834 babelHelpers.createClass(BaseError, [{ 6835 key: "getMessage", 6836 value: function getMessage() { 6837 return this.message; 6838 } 6839 /** 6840 * Sets a message of the error 6841 * @param {string} message 6842 * @returns {this} 6843 */ 6844 }, { 6845 key: "setMessage", 6846 value: function setMessage(message) { 6847 if (Type.isString(message)) { 6848 this.message = message; 6849 } 6850 return this; 6851 } 6852 /** 6853 * Returns a code of the error 6854 * @returns {?string} 6855 */ 6856 }, { 6857 key: "getCode", 6858 value: function getCode() { 6859 return this.code; 6860 } 6861 /** 6862 * Sets a code of the error 6863 * @param {string} code 6864 * @returns {this} 6865 */ 6866 }, { 6867 key: "setCode", 6868 value: function setCode(code) { 6869 if (Type.isStringFilled(code) || code === null) { 6870 this.code = code; 6871 } 6872 return this; 6873 } 6874 /** 6875 * Returns custom data of the error 6876 * @returns {null|*} 6877 */ 6878 }, { 6879 key: "getCustomData", 6880 value: function getCustomData() { 6881 return this.customData; 6882 } 6883 /** 6884 * Sets custom data of the error 6885 * @returns {this} 6886 */ 6887 }, { 6888 key: "setCustomData", 6889 value: function setCustomData(customData) { 6890 if (!Type.isUndefined(customData)) { 6891 this.customData = customData; 6892 } 6893 return this; 6894 } 6895 }, { 6896 key: "toString", 6897 value: function toString() { 6898 const code = this.getCode(); 6899 const message = this.getMessage(); 6900 if (!Type.isStringFilled(code) && !Type.isStringFilled(message)) { 6901 return ''; 6902 } else if (!Type.isStringFilled(code)) { 6903 return `Error: ${message}`; 6904 } else if (!Type.isStringFilled(message)) { 6905 return code; 6906 } else { 6907 return `${code}: ${message}`; 6908 } 6909 } 6910 /** 6911 * Returns true if the object is an instance of BaseError 6912 * @param error 6913 * @returns {boolean} 6914 */ 6915 }], [{ 6916 key: "isError", 6917 value: function isError(error) { 6918 return Type.isObject(error) && error[_isError] === true; 6919 } 6920 }]); 6921 return BaseError; 6922 }(); 6923 6924 /** 6925 * Implements base event object interface 6926 */ 6927 let BaseEvent = /*#__PURE__*/function () { 6928 function BaseEvent(options = { 6929 data: {} 6930 }) { 6931 babelHelpers.classCallCheck(this, BaseEvent); 6932 this.type = ''; 6933 this.data = null; 6934 this.target = null; 6935 this.compatData = null; 6936 this.defaultPrevented = false; 6937 this.immediatePropagationStopped = false; 6938 this.errors = []; 6939 this.setData(options.data); 6940 this.setCompatData(options.compatData); 6941 } 6942 babelHelpers.createClass(BaseEvent, [{ 6943 key: "getType", 6944 /** 6945 * Returns the name of the event 6946 * @returns {string} 6947 */ 6948 value: function getType() { 6949 return this.type; 6950 } 6951 /** 6952 * 6953 * @param {string} type 6954 */ 6955 }, { 6956 key: "setType", 6957 value: function setType(type) { 6958 if (Type.isStringFilled(type)) { 6959 this.type = type; 6960 } 6961 return this; 6962 } 6963 /** 6964 * Returns an event data 6965 */ 6966 }, { 6967 key: "getData", 6968 value: function getData() { 6969 return this.data; 6970 } 6971 /** 6972 * Sets an event data 6973 * @param data 6974 */ 6975 }, { 6976 key: "setData", 6977 value: function setData(data) { 6978 if (!Type.isUndefined(data)) { 6979 this.data = data; 6980 } 6981 return this; 6982 } 6983 /** 6984 * Returns arguments for BX.addCustomEvent handlers (deprecated). 6985 * @returns {array | null} 6986 */ 6987 }, { 6988 key: "getCompatData", 6989 value: function getCompatData() { 6990 return this.compatData; 6991 } 6992 /** 6993 * Sets arguments for BX.addCustomEvent handlers (deprecated) 6994 * @param data 6995 */ 6996 }, { 6997 key: "setCompatData", 6998 value: function setCompatData(data) { 6999 if (Type.isArrayLike(data)) { 7000 this.compatData = data; 7001 } 7002 return this; 7003 } 7004 /** 7005 * Sets a event target 7006 * @param target 7007 */ 7008 }, { 7009 key: "setTarget", 7010 value: function setTarget(target) { 7011 this.target = target; 7012 return this; 7013 } 7014 /** 7015 * Returns a event target 7016 */ 7017 }, { 7018 key: "getTarget", 7019 value: function getTarget() { 7020 return this.target; 7021 } 7022 /** 7023 * Returns an array of event errors 7024 * @returns {[]} 7025 */ 7026 }, { 7027 key: "getErrors", 7028 value: function getErrors() { 7029 return this.errors; 7030 } 7031 /** 7032 * Adds an error of the event. 7033 * Event listeners can prevent emitter's default action and set the reason of this behavior. 7034 * @param error 7035 */ 7036 }, { 7037 key: "setError", 7038 value: function setError(error) { 7039 if (BaseError.isError(error)) { 7040 this.errors.push(error); 7041 } 7042 } 7043 /** 7044 * Prevents default action 7045 */ 7046 }, { 7047 key: "preventDefault", 7048 value: function preventDefault() { 7049 this.defaultPrevented = true; 7050 } 7051 /** 7052 * Checks that is default action prevented 7053 * @return {boolean} 7054 */ 7055 }, { 7056 key: "isDefaultPrevented", 7057 value: function isDefaultPrevented() { 7058 return this.defaultPrevented; 7059 } 7060 /** 7061 * Stops event immediate propagation 7062 */ 7063 }, { 7064 key: "stopImmediatePropagation", 7065 value: function stopImmediatePropagation() { 7066 this.immediatePropagationStopped = true; 7067 } 7068 /** 7069 * Checks that is immediate propagation stopped 7070 * @return {boolean} 7071 */ 7072 }, { 7073 key: "isImmediatePropagationStopped", 7074 value: function isImmediatePropagationStopped() { 7075 return this.immediatePropagationStopped; 7076 } 7077 }], [{ 7078 key: "create", 7079 value: function create(options) { 7080 return new this(options); 7081 } 7082 }]); 7083 return BaseEvent; 7084 }(); 7085 7086 let EventStore = /*#__PURE__*/function () { 7087 function EventStore(options = {}) { 7088 babelHelpers.classCallCheck(this, EventStore); 7089 this.defaultMaxListeners = Type.isNumber(options.defaultMaxListeners) ? options.defaultMaxListeners : 10; 7090 this.eventStore = new WeakMap(); 7091 } 7092 babelHelpers.createClass(EventStore, [{ 7093 key: "add", 7094 value: function add(target, options = {}) { 7095 const record = this.getRecordScheme(); 7096 if (Type.isNumber(options.maxListeners)) { 7097 record.maxListeners = options.maxListeners; 7098 } 7099 this.eventStore.set(target, record); 7100 return record; 7101 } 7102 }, { 7103 key: "get", 7104 value: function get(target) { 7105 return this.eventStore.get(target); 7106 } 7107 }, { 7108 key: "getOrAdd", 7109 value: function getOrAdd(target, options = {}) { 7110 return this.get(target) || this.add(target, options); 7111 } 7112 }, { 7113 key: "delete", 7114 value: function _delete(context) { 7115 this.eventStore.delete(context); 7116 } 7117 }, { 7118 key: "getRecordScheme", 7119 value: function getRecordScheme() { 7120 return { 7121 eventsMap: new Map(), 7122 onceMap: new Map(), 7123 maxListeners: this.getDefaultMaxListeners(), 7124 eventsMaxListeners: new Map() 7125 }; 7126 } 7127 }, { 7128 key: "getDefaultMaxListeners", 7129 value: function getDefaultMaxListeners() { 7130 return this.defaultMaxListeners; 7131 } 7132 }]); 7133 return EventStore; 7134 }(); 7135 7136 let WarningStore = /*#__PURE__*/function () {
7137 function WarningStore() { 7138 babelHelpers.classCallCheck(this, WarningStore); 7139 this.warnings = new Map(); 7140 this.printDelayed = Runtime.debounce(this.print.bind(this), 500); 7141 } 7142 babelHelpers.createClass(WarningStore, [{ 7143 key: "add", 7144 value: function add(target, eventName, listeners) { 7145 let contextWarnings = this.warnings.get(target); 7146 if (!contextWarnings) { 7147 contextWarnings = Object.create(null); 7148 this.warnings.set(target, contextWarnings); 7149 } 7150 if (!contextWarnings[eventName]) { 7151 contextWarnings[eventName] = {}; 7152 } 7153 contextWarnings[eventName].size = listeners.size; 7154 if (!Type.isArray(contextWarnings[eventName].errors)) { 7155 contextWarnings[eventName].errors = []; 7156 } 7157 contextWarnings[eventName].errors.push(new Error()); 7158 } 7159 }, { 7160 key: "print", 7161 value: function print() { 7162 this.warnings.forEach(warnings => { 7163 for (let eventName in warnings) { 7164 console.groupCollapsed('Possible BX.Event.EventEmitter memory leak detected. ' + warnings[eventName].size + ' "' + eventName + '" listeners added. ' + 'Use emitter.setMaxListeners() to increase limit.'); 7165 console.dir(warnings[eventName].errors); 7166 console.groupEnd(); 7167 } 7168 }); 7169 this.clear(); 7170 } 7171 }, { 7172 key: "clear", 7173 value: function clear() { 7174 this.warnings.clear(); 7175 } 7176 }, { 7177 key: "printDelayed", 7178 value: function printDelayed() {} 7179 }]); 7180 return WarningStore; 7181 }(); 7182 7183 const eventStore = new EventStore({ 7184 defaultMaxListeners: 10 7185 }); 7186 const warningStore = new WarningStore(); 7187 const aliasStore = new Map(); 7188 const globalTarget = { 7189 GLOBAL_TARGET: 'GLOBAL_TARGET' // this key only for debugging purposes 7190 }; 7191 7192 eventStore.add(globalTarget, { 7193 maxListeners: 25 7194 }); 7195 const isEmitterProperty = Symbol.for('BX.Event.EventEmitter.isEmitter'); 7196 const namespaceProperty = Symbol('namespaceProperty'); 7197 const targetProperty = Symbol('targetProperty'); 7198 let EventEmitter = /*#__PURE__*/function () { 7199 /** @private */ 7200 7201 function EventEmitter(...args) { 7202 babelHelpers.classCallCheck(this, EventEmitter); 7203 this[targetProperty] = null; 7204 this[namespaceProperty] = null; 7205 this[isEmitterProperty] = true; 7206 let target = this; 7207 if (Object.getPrototypeOf(this) === EventEmitter.prototype && args.length > 0) 7208 //new EventEmitter(obj) case 7209 { 7210 if (!Type.isObject(args[0])) { 7211 throw new TypeError(`The "target" argument must be an object.`); 7212 } 7213 target = args[0]; 7214 this.setEventNamespace(args[1]); 7215 } 7216 this[targetProperty] = target; 7217 } 7218 7219 /** 7220 * Makes a target observable 7221 * @param {object} target 7222 * @param {string} namespace 7223 */ 7224 babelHelpers.createClass(EventEmitter, [{ 7225 key: "setEventNamespace", 7226 value: function setEventNamespace(namespace) { 7227 if (Type.isStringFilled(namespace)) { 7228 this[namespaceProperty] = namespace; 7229 } 7230 } 7231 }, { 7232 key: "getEventNamespace", 7233 value: function getEventNamespace() { 7234 return this[namespaceProperty]; 7235 } 7236 /** 7237 * Subscribes listener on specified global event 7238 * @param {object} target 7239 * @param {string} eventName 7240 * @param {Function<BaseEvent>} listener 7241 * @param {object} options 7242 */ 7243 }, { 7244 key: "subscribe", 7245 /** 7246 * Subscribes a listener on a specified event 7247 * @param {string} eventName 7248 * @param {Function<BaseEvent>} listener 7249 * @return {this} 7250 */ 7251 value: function subscribe(eventName, listener) { 7252 EventEmitter.subscribe(this, eventName, listener); 7253 return this; 7254 } 7255 /** 7256 * 7257 * @param {object} options 7258 * @param {object} [aliases] 7259 * @param {boolean} [compatMode=false] 7260 */ 7261 }, { 7262 key: "subscribeFromOptions", 7263 value: function subscribeFromOptions(options, aliases, compatMode) { 7264 if (Type.isArrayFilled(options)) { 7265 options.forEach(events => { 7266 this.subscribeFromOptions(events); 7267 }); 7268 return; 7269 } 7270 if (!Type.isPlainObject(options)) { 7271 return; 7272 } 7273 aliases = Type.isPlainObject(aliases) ? EventEmitter.normalizeAliases(aliases) : {};
7274 Object.keys(options).forEach(eventName => { 7275 const listener = EventEmitter.normalizeListener(options[eventName]); 7276 eventName = EventEmitter.normalizeEventName(eventName); 7277 if (aliases[eventName]) { 7278 const { 7279 eventName: actualName 7280 } = aliases[eventName]; 7281 EventEmitter.subscribe(this, actualName, listener, { 7282 compatMode: compatMode !== false 7283 }); 7284 } else { 7285 EventEmitter.subscribe(this, eventName, listener, { 7286 compatMode: compatMode === true 7287 }); 7288 } 7289 }); 7290 } 7291 /** 7292 * Subscribes a listener that is called at 7293 * most once for a specified event. 7294 * @param {object} target 7295 * @param {string} eventName 7296 * @param {Function<BaseEvent>} listener 7297 */ 7298 }, { 7299 key: "subscribeOnce", 7300 /** 7301 * Subscribes a listener that is called at most once for a specified event. 7302 * @param {string} eventName 7303 * @param {Function<BaseEvent>} listener 7304 * @return {this} 7305 */ 7306 value: function subscribeOnce(eventName, listener) { 7307 EventEmitter.subscribeOnce(this, eventName, listener); 7308 return this; 7309 } 7310 /** 7311 * Unsubscribes an event listener 7312 * @param {object} target 7313 * @param {string} eventName 7314 * @param {Function<BaseEvent>} listener 7315 * @param options 7316 */ 7317 }, { 7318 key: "unsubscribe", 7319 /** 7320 * Unsubscribes an event listener 7321 * @param {string} eventName 7322 * @param {Function<BaseEvent>} listener 7323 * @return {this} 7324 */ 7325 value: function unsubscribe(eventName, listener) { 7326 EventEmitter.unsubscribe(this, eventName, listener); 7327 return this; 7328 } 7329 /** 7330 * Unsubscribes all event listeners 7331 * @param {object} target 7332 * @param {string} eventName 7333 * @param options 7334 */ 7335 }, { 7336 key: "unsubscribeAll", 7337 /** 7338 * Unsubscribes all event listeners 7339 * @param {string} [eventName] 7340 */ 7341 value: function unsubscribeAll(eventName) { 7342 EventEmitter.unsubscribeAll(this, eventName); 7343 } 7344 /** 7345 * 7346 * @param {object} target 7347 * @param {string} eventName 7348 * @param {BaseEvent | any} event 7349 * @param {object} options 7350 * @returns {Array} 7351 */ 7352 }, { 7353 key: "emit", 7354 /** 7355 * Emits specified event with specified event object 7356 * @param {string} eventName 7357 * @param {BaseEvent | any} event 7358 * @return {this} 7359 */ 7360 value: function emit(eventName, event) { 7361 if (this.getEventNamespace() === null) { 7362 console.warn('The instance of BX.Event.EventEmitter is supposed to have an event namespace. ' + 'Use emitter.setEventNamespace() to make events more unique.'); 7363 } 7364 EventEmitter.emit(this, eventName, event); 7365 return this; 7366 } 7367 /** 7368 * Emits global event and returns a promise that is resolved when 7369 * all promise returned from event handlers are resolved, 7370 * or rejected when at least one of the returned promise is rejected. 7371 * Importantly. You can return any value from synchronous handlers, not just promise 7372 * @param {object} target 7373 * @param {string} eventName 7374 * @param {BaseEvent | any} event 7375 * @return {Promise<Array>} 7376 */ 7377 }, { 7378 key: "emitAsync", 7379 /** 7380 * Emits event and returns a promise that is resolved when 7381 * all promise returned from event handlers are resolved, 7382 * or rejected when at least one of the returned promise is rejected. 7383 * Importantly. You can return any value from synchronous handlers, not just promise 7384 * @param {string} eventName 7385 * @param {BaseEvent|any} event 7386 * @return {Promise<Array>} 7387 */ 7388 value: function emitAsync(eventName, event) { 7389 if (this.getEventNamespace() === null) { 7390 console.warn('The instance of BX.Event.EventEmitter is supposed to have an event namespace. ' + 'Use emitter.setEventNamespace() to make events more unique.'); 7391 } 7392 return EventEmitter.emitAsync(this, eventName, event); 7393 } 7394 /** 7395 * @private 7396 * @param {object} target 7397 * @param {string} eventName 7398 * @param {BaseEvent|any} event 7399 * @returns {BaseEvent} 7400 */ 7401 }, { 7402 key: "setMaxListeners", 7403 /** 7404 * Sets max events listeners count 7405 * this.setMaxListeners(10) - sets the default value for all events
7406 * this.setMaxListeners("onClose", 10) sets the value for onClose event 7407 * @return {this} 7408 * @param args 7409 */ 7410 value: function setMaxListeners(...args) { 7411 EventEmitter.setMaxListeners(this, ...args); 7412 return this; 7413 } 7414 /** 7415 * Returns max event listeners count 7416 * @param {object} target 7417 * @param {string} [eventName] 7418 * @returns {number} 7419 */ 7420 }, { 7421 key: "getMaxListeners", 7422 /** 7423 * Returns max event listeners count 7424 * @param {string} [eventName] 7425 * @returns {number} 7426 */ 7427 value: function getMaxListeners(eventName) { 7428 return EventEmitter.getMaxListeners(this, eventName); 7429 } 7430 /** 7431 * Adds or subtracts max listeners count 7432 * Event.EventEmitter.addMaxListeners() - adds one max listener for all events of global target 7433 * Event.EventEmitter.addMaxListeners(3) - adds three max listeners for all events of global target 7434 * Event.EventEmitter.addMaxListeners(-1) - subtracts one max listener for all events of global target 7435 * Event.EventEmitter.addMaxListeners('onClose') - adds one max listener for onClose event of global target 7436 * Event.EventEmitter.addMaxListeners('onClose', 2) - adds two max listeners for onClose event of global target 7437 * Event.EventEmitter.addMaxListeners('onClose', -1) - subtracts one max listener for onClose event of global target 7438 * 7439 * Event.EventEmitter.addMaxListeners(obj) - adds one max listener for all events of 'obj' target 7440 * Event.EventEmitter.addMaxListeners(obj, 3) - adds three max listeners for all events of 'obj' target 7441 * Event.EventEmitter.addMaxListeners(obj, -1) - subtracts one max listener for all events of 'obj' target 7442 * Event.EventEmitter.addMaxListeners(obj, 'onClose') - adds one max listener for onClose event of 'obj' target 7443 * Event.EventEmitter.addMaxListeners(obj, 'onClose', 2) - adds two max listeners for onClose event of 'obj' target 7444 * Event.EventEmitter.addMaxListeners(obj, 'onClose', -1) - subtracts one max listener for onClose event of 'obj' target 7445 * @param args 7446 * @returns {number} 7447 */ 7448 }, { 7449 key: "incrementMaxListeners", 7450 /** 7451 * Increases max listeners count 7452 * this.incrementMaxListeners() - adds one max listener for all events 7453 * this.incrementMaxListeners(3) - adds three max listeners for all events 7454 * this.incrementMaxListeners('onClose') - adds one max listener for onClose event 7455 * this.incrementMaxListeners('onClose', 2) - adds two max listeners for onClose event 7456 */ 7457 value: function incrementMaxListeners(...args) { 7458 return EventEmitter.incrementMaxListeners(this, ...args); 7459 } 7460 /** 7461 * Decreases max listeners count 7462 * 7463 * Event.EventEmitter.decrementMaxListeners() - subtracts one max listener for all events of global target 7464 * Event.EventEmitter.decrementMaxListeners(3) - subtracts three max listeners for all events of global target 7465 * Event.EventEmitter.decrementMaxListeners('onClose') - subtracts one max listener for onClose event of global target 7466 * Event.EventEmitter.decrementMaxListeners('onClose', 2) - subtracts two max listeners for onClose event of global target 7467 * 7468 * Event.EventEmitter.decrementMaxListeners(obj) - subtracts one max listener for all events of 'obj' target 7469 * Event.EventEmitter.decrementMaxListeners(obj, 3) - subtracts three max listeners for all events of 'obj' target 7470 * Event.EventEmitter.decrementMaxListeners(obj, 'onClose') - subtracts one max listener for onClose event of 'obj' target 7471 * Event.EventEmitter.decrementMaxListeners(obj, 'onClose', 2) - subtracts two max listeners for onClose event of 'obj' target 7472 */ 7473 }, { 7474 key: "decrementMaxListeners", 7475 /** 7476 * Increases max listeners count 7477 * this.decrementMaxListeners() - subtracts one max listener for all events 7478 * this.decrementMaxListeners(3) - subtracts three max listeners for all events 7479 * this.decrementMaxListeners('onClose') - subtracts one max listener for onClose event 7480 * this.decrementMaxListeners('onClose', 2) - subtracts two max listeners for onClose event 7481 */ 7482 value: function decrementMaxListeners(...args) { 7483 return EventEmitter.decrementMaxListeners(this, ...args); 7484 } 7485 /** 7486 * @private 7487 * @param {Array} args 7488 * @returns Array 7489 */ 7490 }, { 7491 key: "getListeners", 7492 /** 7493 * Gets listeners list for specified event 7494 * @param {string} eventName 7495 */ 7496 value: function getListeners(eventName) { 7497 return EventEmitter.getListeners(this, eventName); 7498 } 7499 /** 7500 * Returns a full event name with namespace 7501 * @param {string} eventName 7502 * @returns {string} 7503 */ 7504 }, { 7505 key: "getFullEventName", 7506 value: function getFullEventName(eventName) { 7507 if (!Type.isStringFilled(eventName)) { 7508 throw new TypeError(`The "eventName" argument must be a string.`); 7509 } 7510 return EventEmitter.makeFullEventName(this.getEventNamespace(), eventName); 7511 } 7512 /** 7513 * Registers aliases (old event names for BX.onCustomEvent) 7514 * @param aliases 7515 */ 7516 }], [{ 7517 key: "makeObservable", 7518 value: function makeObservable(target, namespace) { 7519 if (!Type.isObject(target)) { 7520 throw new TypeError('The "target" argument must be an object.'); 7521 } 7522 if (!Type.isStringFilled(namespace)) { 7523 throw new TypeError('The "namespace" must be an non-empty string.'); 7524 } 7525 if (EventEmitter.isEventEmitter(target)) { 7526 throw new TypeError('The "target" is an event emitter already.'); 7527 } 7528 const targetProto = Object.getPrototypeOf(target); 7529 const emitter = new EventEmitter(); 7530 emitter.setEventNamespace(namespace); 7531 Object.setPrototypeOf(emitter, targetProto); 7532 Object.setPrototypeOf(target, emitter); 7533 Object.getOwnPropertyNames(EventEmitter.prototype).forEach(method => {
7534 if (['constructor'].includes(method)) { 7535 return; 7536 } 7537 emitter[method] = function (...args) { 7538 return EventEmitter.prototype[method].apply(target, args); 7539 }; 7540 }); 7541 } 7542 }, { 7543 key: "subscribe", 7544 value: function subscribe(target, eventName, listener, options) { 7545 if (Type.isString(target)) { 7546 options = listener; 7547 listener = eventName; 7548 eventName = target; 7549 target = this.GLOBAL_TARGET; 7550 } 7551 if (!Type.isObject(target)) { 7552 throw new TypeError(`The "target" argument must be an object.`); 7553 } 7554 eventName = this.normalizeEventName(eventName); 7555 if (!Type.isStringFilled(eventName)) { 7556 throw new TypeError(`The "eventName" argument must be a string.`); 7557 } 7558 listener = this.normalizeListener(listener); 7559 options = Type.isPlainObject(options) ? options : {}; 7560 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 7561 const { 7562 eventsMap, 7563 onceMap 7564 } = eventStore.getOrAdd(target); 7565 const onceListeners = onceMap.get(fullEventName); 7566 let listeners = eventsMap.get(fullEventName); 7567 if (listeners && listeners.has(listener) || onceListeners && onceListeners.has(listener)) { 7568 console.error(`You cannot subscribe the same "${fullEventName}" event listener twice.`); 7569 } else { 7570 if (listeners) { 7571 listeners.set(listener, { 7572 listener, 7573 options, 7574 sort: this.getNextSequenceValue() 7575 }); 7576 } else { 7577 listeners = new Map([[listener, { 7578 listener, 7579 options, 7580 sort: this.getNextSequenceValue() 7581 }]]); 7582 eventsMap.set(fullEventName, listeners); 7583 } 7584 } 7585 const maxListeners = this.getMaxListeners(target, eventName); 7586 if (listeners.size > maxListeners) { 7587 warningStore.add(target, fullEventName, listeners); 7588 warningStore.printDelayed(); 7589 } 7590 } 7591 }, { 7592 key: "subscribeOnce", 7593 value: function subscribeOnce(target, eventName, listener) { 7594 if (Type.isString(target)) { 7595 listener = eventName; 7596 eventName = target; 7597 target = this.GLOBAL_TARGET;
7598 } 7599 if (!Type.isObject(target)) { 7600 throw new TypeError(`The "target" argument must be an object.`); 7601 } 7602 eventName = this.normalizeEventName(eventName); 7603 if (!Type.isStringFilled(eventName)) { 7604 throw new TypeError(`The "eventName" argument must be a string.`); 7605 } 7606 listener = this.normalizeListener(listener); 7607 const fullEventName = this.resolveEventName(eventName, target); 7608 const { 7609 eventsMap, 7610 onceMap 7611 } = eventStore.getOrAdd(target); 7612 const listeners = eventsMap.get(fullEventName); 7613 let onceListeners = onceMap.get(fullEventName); 7614 if (listeners && listeners.has(listener) || onceListeners && onceListeners.has(listener)) { 7615 console.error(`You cannot subscribe the same "${fullEventName}" event listener twice.`); 7616 } else { 7617 const once = (...args) => { 7618 this.unsubscribe(target, eventName, once); 7619 onceListeners.delete(listener); 7620 listener(...args); 7621 }; 7622 if (onceListeners) { 7623 onceListeners.set(listener, once); 7624 } else { 7625 onceListeners = new Map([[listener, once]]); 7626 onceMap.set(fullEventName, onceListeners); 7627 } 7628 this.subscribe(target, eventName, once); 7629 } 7630 } 7631 }, { 7632 key: "unsubscribe", 7633 value: function unsubscribe(target, eventName, listener, options) { 7634 if (Type.isString(target)) { 7635 listener = eventName; 7636 eventName = target; 7637 target = this.GLOBAL_TARGET;
7638 } 7639 eventName = this.normalizeEventName(eventName); 7640 if (!Type.isStringFilled(eventName)) { 7641 throw new TypeError(`The "eventName" argument must be a string.`); 7642 } 7643 listener = this.normalizeListener(listener); 7644 options = Type.isPlainObject(options) ? options : {}; 7645 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 7646 const targetInfo = eventStore.get(target); 7647 const listeners = targetInfo && targetInfo.eventsMap.get(fullEventName); 7648 const onceListeners = targetInfo && targetInfo.onceMap.get(fullEventName); 7649 if (listeners) { 7650 listeners.delete(listener); 7651 } 7652 if (onceListeners) { 7653 const once = onceListeners.get(listener); 7654 if (once) { 7655 onceListeners.delete(listener); 7656 listeners.delete(once); 7657 } 7658 } 7659 } 7660 }, { 7661 key: "unsubscribeAll", 7662 value: function unsubscribeAll(target, eventName, options) { 7663 if (Type.isString(target)) { 7664 eventName = target; 7665 target = this.GLOBAL_TARGET;
7666 } 7667 if (Type.isStringFilled(eventName)) { 7668 const targetInfo = eventStore.get(target); 7669 if (targetInfo) { 7670 options = Type.isPlainObject(options) ? options : {}; 7671 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 7672 targetInfo.eventsMap.delete(fullEventName); 7673 targetInfo.onceMap.delete(fullEventName); 7674 } 7675 } else if (Type.isNil(eventName)) { 7676 if (target === this.GLOBAL_TARGET) { 7677 console.error('You cannot unsubscribe all global listeners.'); 7678 } else { 7679 eventStore.delete(target); 7680 } 7681 } 7682 } 7683 }, { 7684 key: "emit", 7685 value: function emit(target, eventName, event, options) { 7686 if (Type.isString(target)) { 7687 options = event; 7688 event = eventName; 7689 eventName = target; 7690 target = this.GLOBAL_TARGET; 7691 } 7692 if (!Type.isObject(target)) { 7693 throw new TypeError(`The "target" argument must be an object.`); 7694 } 7695 eventName = this.normalizeEventName(eventName); 7696 if (!Type.isStringFilled(eventName)) { 7697 throw new TypeError(`The "eventName" argument must be a string.`); 7698 } 7699 options = Type.isPlainObject(options) ? options : {}; 7700 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 7701 const globalEvents = eventStore.get(this.GLOBAL_TARGET); 7702 const globalListeners = globalEvents && globalEvents.eventsMap.get(fullEventName) || new Map(); 7703 let targetListeners = new Set(); 7704 if (target !== this.GLOBAL_TARGET) { 7705 const targetEvents = eventStore.get(target); 7706 targetListeners = targetEvents && targetEvents.eventsMap.get(fullEventName) || new Map(); 7707 } 7708 const listeners = [...globalListeners.values(), ...targetListeners.values()]; 7709 listeners.sort(function (a, b) { 7710 return a.sort - b.sort; 7711 }); 7712 const preparedEvent = this.prepareEvent(target, fullEventName, event); 7713 const result = []; 7714 for (let i = 0; i < listeners.length; i++) { 7715 if (preparedEvent.isImmediatePropagationStopped()) { 7716 break; 7717 } 7718 const { 7719 listener, 7720 options: listenerOptions 7721 } = listeners[i]; 7722 7723 //A previous listener could remove a current listener. 7724 if (globalListeners.has(listener) || targetListeners.has(listener)) { 7725 let listenerResult; 7726 if (listenerOptions.compatMode) { 7727 let params = []; 7728 const compatData = preparedEvent.getCompatData(); 7729 if (compatData !== null) { 7730 params = options.cloneData === true ? Runtime.clone(compatData) : compatData; 7731 } else { 7732 params = [preparedEvent]; 7733 } 7734 const context = Type.isUndefined(options.thisArg) ? target : options.thisArg; 7735 listenerResult = listener.apply(context, params); 7736 } else { 7737 listenerResult = Type.isUndefined(options.thisArg) ? listener(preparedEvent) : listener.call(options.thisArg, preparedEvent); 7738 } 7739 result.push(listenerResult); 7740 } 7741 } 7742 return result; 7743 } 7744 }, { 7745 key: "emitAsync", 7746 value: function emitAsync(target, eventName, event) { 7747 if (Type.isString(target)) { 7748 event = eventName; 7749 eventName = target; 7750 target = this.GLOBAL_TARGET;
7751 } 7752 return Promise.all(this.emit(target, eventName, event)); 7753 } 7754 }, { 7755 key: "prepareEvent", 7756 value: function prepareEvent(target, eventName, event) { 7757 let preparedEvent = event; 7758 if (!(event instanceof BaseEvent)) { 7759 preparedEvent = new BaseEvent(); 7760 preparedEvent.setData(event); 7761 } 7762 preparedEvent.setTarget(this.isEventEmitter(target) ? target[targetProperty] : target); 7763 preparedEvent.setType(eventName); 7764 return preparedEvent; 7765 } 7766 /** 7767 * @private 7768 * @returns {number} 7769 */ 7770 }, { 7771 key: "getNextSequenceValue", 7772 value: function getNextSequenceValue() { 7773 return this.sequenceValue++; 7774 } 7775 /** 7776 * Sets max global events listeners count 7777 * Event.EventEmitter.setMaxListeners(10) - sets the default value for all events (global target) 7778 * Event.EventEmitter.setMaxListeners("onClose", 10) - sets the value for onClose event (global target) 7779 * Event.EventEmitter.setMaxListeners(obj, 10) - sets the default value for all events (obj target) 7780 * Event.EventEmitter.setMaxListeners(obj, "onClose", 10); - sets the value for onClose event (obj target) 7781 * @return {void} 7782 * @param args 7783 */ 7784 }, { 7785 key: "setMaxListeners", 7786 value: function setMaxListeners(...args) { 7787 let target = this.GLOBAL_TARGET;
7788 let eventName = null; 7789 let count = undefined; 7790 if (args.length === 1) { 7791 count = args[0]; 7792 } else if (args.length === 2) { 7793 if (Type.isString(args[0])) { 7794 [eventName, count] = args; 7795 } else { 7796 [target, count] = args; 7797 } 7798 } else if (args.length >= 3) { 7799 [target, eventName, count] = args; 7800 } 7801 if (!Type.isObject(target)) { 7802 throw new TypeError(`The "target" argument must be an object.`); 7803 } 7804 if (eventName !== null && !Type.isStringFilled(eventName)) { 7805 throw new TypeError(`The "eventName" argument must be a string.`); 7806 } 7807 if (!Type.isNumber(count) || count < 0) { 7808 throw new TypeError(`The value of "count" is out of range. It must be a non-negative number. Received ${count}.`); 7809 } 7810 const targetInfo = eventStore.getOrAdd(target); 7811 if (Type.isStringFilled(eventName)) { 7812 const fullEventName = this.resolveEventName(eventName, target); 7813 targetInfo.eventsMaxListeners.set(fullEventName, count); 7814 } else { 7815 targetInfo.maxListeners = count; 7816 } 7817 } 7818 }, { 7819 key: "getMaxListeners", 7820 value: function getMaxListeners(target, eventName) { 7821 if (Type.isString(target)) { 7822 eventName = target; 7823 target = this.GLOBAL_TARGET;
7824 } else if (Type.isNil(target)) { 7825 target = this.GLOBAL_TARGET; 7826 } 7827 if (!Type.isObject(target)) { 7828 throw new TypeError(`The "target" argument must be an object.`); 7829 } 7830 const targetInfo = eventStore.get(target); 7831 if (targetInfo) { 7832 let maxListeners = targetInfo.maxListeners; 7833 if (Type.isStringFilled(eventName)) { 7834 const fullEventName = this.resolveEventName(eventName, target); 7835 maxListeners = targetInfo.eventsMaxListeners.get(fullEventName) || maxListeners; 7836 } 7837 return maxListeners; 7838 } 7839 return this.DEFAULT_MAX_LISTENERS; 7840 } 7841 }, { 7842 key: "addMaxListeners", 7843 value: function addMaxListeners(...args) { 7844 const [target, eventName, increment] = this.destructMaxListenersArgs(...args); 7845 const maxListeners = Math.max(this.getMaxListeners(target, eventName) + increment, 0); 7846 if (Type.isStringFilled(eventName)) { 7847 EventEmitter.setMaxListeners(target, eventName, maxListeners); 7848 } else { 7849 EventEmitter.setMaxListeners(target, maxListeners); 7850 } 7851 return maxListeners; 7852 } 7853 /** 7854 * Increases max listeners count 7855 * 7856 * Event.EventEmitter.incrementMaxListeners() - adds one max listener for all events of global target 7857 * Event.EventEmitter.incrementMaxListeners(3) - adds three max listeners for all events of global target 7858 * Event.EventEmitter.incrementMaxListeners('onClose') - adds one max listener for onClose event of global target 7859 * Event.EventEmitter.incrementMaxListeners('onClose', 2) - adds two max listeners for onClose event of global target 7860 * 7861 * Event.EventEmitter.incrementMaxListeners(obj) - adds one max listener for all events of 'obj' target 7862 * Event.EventEmitter.incrementMaxListeners(obj, 3) - adds three max listeners for all events of 'obj' target 7863 * Event.EventEmitter.incrementMaxListeners(obj, 'onClose') - adds one max listener for onClose event of 'obj' target 7864 * Event.EventEmitter.incrementMaxListeners(obj, 'onClose', 2) - adds two max listeners for onClose event of 'obj' target 7865 */ 7866 }, { 7867 key: "incrementMaxListeners", 7868 value: function incrementMaxListeners(...args) { 7869 const [target, eventName, increment] = this.destructMaxListenersArgs(...args); 7870 return this.addMaxListeners(target, eventName, Math.abs(increment)); 7871 } 7872 }, { 7873 key: "decrementMaxListeners", 7874 value: function decrementMaxListeners(...args) { 7875 const [target, eventName, increment] = this.destructMaxListenersArgs(...args); 7876 return this.addMaxListeners(target, eventName, -Math.abs(increment)); 7877 } 7878 }, { 7879 key: "destructMaxListenersArgs", 7880 value: function destructMaxListenersArgs(...args) { 7881 let eventName = null; 7882 let increment = 1; 7883 let target = this.GLOBAL_TARGET;
7884 if (args.length === 1) { 7885 if (Type.isNumber(args[0])) { 7886 increment = args[0]; 7887 } else if (Type.isString(args[0])) { 7888 eventName = args[0]; 7889 } else { 7890 target = args[0]; 7891 } 7892 } else if (args.length === 2) { 7893 if (Type.isString(args[0])) { 7894 [eventName, increment] = args; 7895 } else if (Type.isString(args[1])) { 7896 [target, eventName] = args; 7897 } else { 7898 [target, increment] = args; 7899 } 7900 } else if (args.length >= 3) { 7901 [target, eventName, increment] = args; 7902 } 7903 if (!Type.isObject(target)) { 7904 throw new TypeError(`The "target" argument must be an object.`); 7905 } 7906 if (eventName !== null && !Type.isStringFilled(eventName)) { 7907 throw new TypeError(`The "eventName" argument must be a string.`); 7908 } 7909 if (!Type.isNumber(increment)) { 7910 throw new TypeError(`The value of "increment" must be a number.`); 7911 } 7912 return [target, eventName, increment]; 7913 } 7914 /** 7915 * Gets listeners list for a specified event 7916 * @param {object} target 7917 * @param {string} eventName 7918 */ 7919 }, { 7920 key: "getListeners", 7921 value: function getListeners(target, eventName) { 7922 if (Type.isString(target)) { 7923 eventName = target; 7924 target = this.GLOBAL_TARGET;
7925 } 7926 if (!Type.isObject(target)) { 7927 throw new TypeError(`The "target" argument must be an object.`); 7928 } 7929 eventName = this.normalizeEventName(eventName); 7930 if (!Type.isStringFilled(eventName)) { 7931 throw new TypeError(`The "eventName" argument must be a string.`); 7932 } 7933 const targetInfo = eventStore.get(target); 7934 if (!targetInfo) { 7935 return new Map(); 7936 } 7937 const fullEventName = this.resolveEventName(eventName, target); 7938 return targetInfo.eventsMap.get(fullEventName) || new Map(); 7939 } 7940 }, { 7941 key: "registerAliases", 7942 value: function registerAliases(aliases) { 7943 aliases = this.normalizeAliases(aliases); 7944 Object.keys(aliases).forEach(alias => { 7945 aliasStore.set(alias, { 7946 eventName: aliases[alias].eventName, 7947 namespace: aliases[alias].namespace 7948 }); 7949 }); 7950 EventEmitter.mergeEventAliases(aliases); 7951 } 7952 /** 7953 * @private 7954 * @param aliases 7955 */ 7956 }, { 7957 key: "normalizeAliases", 7958 value: function normalizeAliases(aliases) { 7959 if (!Type.isPlainObject(aliases)) { 7960 throw new TypeError(`The "aliases" argument must be an object.`); 7961 } 7962 const result = Object.create(null); 7963 for (let alias in aliases) { 7964 if (!Type.isStringFilled(alias)) { 7965 throw new TypeError(`The alias must be an non-empty string.`); 7966 } 7967 const options = aliases[alias]; 7968 if (!options || !Type.isStringFilled(options.eventName) || !Type.isStringFilled(options.namespace)) { 7969 throw new TypeError(`The alias options must set the "eventName" and the "namespace".`); 7970 } 7971 alias = this.normalizeEventName(alias); 7972 result[alias] = { 7973 eventName: options.eventName, 7974 namespace: options.namespace 7975 }; 7976 } 7977 return result; 7978 } 7979 /** 7980 * @private 7981 */ 7982 }, { 7983 key: "mergeEventAliases", 7984 value: function mergeEventAliases(aliases) { 7985 const globalEvents = eventStore.get(this.GLOBAL_TARGET); 7986 if (!globalEvents) { 7987 return; 7988 } 7989 Object.keys(aliases).forEach(alias => { 7990 const options = aliases[alias]; 7991 alias = this.normalizeEventName(alias); 7992 const fullEventName = this.makeFullEventName(options.namespace, options.eventName); 7993 const aliasListeners = globalEvents.eventsMap.get(alias); 7994 if (aliasListeners) { 7995 const listeners = globalEvents.eventsMap.get(fullEventName) || new Map(); 7996 globalEvents.eventsMap.set(fullEventName, new Map([...listeners, ...aliasListeners])); 7997 globalEvents.eventsMap.delete(alias); 7998 } 7999 const aliasOnceListeners = globalEvents.onceMap.get(alias); 8000 if (aliasOnceListeners) { 8001 const onceListeners = globalEvents.onceMap.get(fullEventName) || new Map(); 8002 globalEvents.onceMap.set(fullEventName, new Map([...onceListeners, ...aliasOnceListeners])); 8003 globalEvents.onceMap.delete(alias); 8004 } 8005 const aliasMaxListeners = globalEvents.eventsMaxListeners.get(alias); 8006 if (aliasMaxListeners) { 8007 const eventMaxListeners = globalEvents.eventsMaxListeners.get(fullEventName) || 0; 8008 globalEvents.eventsMaxListeners.set(fullEventName, Math.max(eventMaxListeners, aliasMaxListeners)); 8009 globalEvents.eventsMaxListeners.delete(alias); 8010 } 8011 }); 8012 } 8013 /** 8014 * Returns true if the target is an instance of Event.EventEmitter 8015 * @param {object} target 8016 * @returns {boolean} 8017 */ 8018 }, { 8019 key: "isEventEmitter", 8020 value: function isEventEmitter(target) { 8021 return Type.isObject(target) && target[isEmitterProperty] === true; 8022 } 8023 /** 8024 * @private 8025 * @param {string} eventName 8026 * @returns {string} 8027 */ 8028 }, { 8029 key: "normalizeEventName", 8030 value: function normalizeEventName(eventName) { 8031 if (!Type.isStringFilled(eventName)) { 8032 return ''; 8033 } 8034 return eventName.toLowerCase(); 8035 } 8036 /** 8037 * @private 8038 */ 8039 }, { 8040 key: "normalizeListener", 8041 value: function normalizeListener(listener) { 8042 if (Type.isString(listener)) { 8043 listener = Reflection.getClass(listener); 8044 } 8045 if (!Type.isFunction(listener)) { 8046 throw new TypeError(`The "listener" argument must be of type Function. Received type ${typeof listener}.`); 8047 } 8048 return listener; 8049 } 8050 /** 8051 * @private 8052 * @param eventName 8053 * @param target 8054 * @param useGlobalNaming 8055 * @returns {string} 8056 */ 8057 }, { 8058 key: "resolveEventName", 8059 value: function resolveEventName(eventName, target, useGlobalNaming = false) { 8060 eventName = this.normalizeEventName(eventName); 8061 if (!Type.isStringFilled(eventName)) { 8062 return ''; 8063 } 8064 if (this.isEventEmitter(target) && useGlobalNaming !== true) { 8065 if (target.getEventNamespace() !== null && eventName.includes('.')) { 8066 console.warn(`Possible the wrong event name "${eventName}".`); 8067 } 8068 eventName = target.getFullEventName(eventName); 8069 } else if (aliasStore.has(eventName)) { 8070 const { 8071 namespace, 8072 eventName: actualEventName 8073 } = aliasStore.get(eventName); 8074 eventName = this.makeFullEventName(namespace, actualEventName); 8075 } 8076 return eventName; 8077 } 8078 /** 8079 * @private 8080 * @param {string} namespace 8081 * @param {string} eventName 8082 * @returns {string} 8083 */ 8084 }, { 8085 key: "makeFullEventName", 8086 value: function makeFullEventName(namespace, eventName) { 8087 const fullName = Type.isStringFilled(namespace) ? `${namespace}:${eventName}` : eventName; 8088 return Type.isStringFilled(fullName) ? fullName.toLowerCase() : ''; 8089 } 8090 }]); 8091 return EventEmitter; 8092 }(); 8093 babelHelpers.defineProperty(EventEmitter, "GLOBAL_TARGET", globalTarget); 8094 babelHelpers.defineProperty(EventEmitter, "DEFAULT_MAX_LISTENERS", eventStore.getDefaultMaxListeners()); 8095 babelHelpers.defineProperty(EventEmitter, "sequenceValue", 1); 8096 8097 let stack = []; 8098 /** 8099 * For compatibility only 8100 * @type {boolean} 8101 */ 8102 // eslint-disable-next-line 8103 exports.isReady = false;
8104 function ready(handler) { 8105 if (!Type.isFunction(handler)) { 8106 return; 8107 } 8108 if (exports.isReady) { 8109 handler(); 8110 } else { 8111 stack.push(handler); 8112 } 8113 } 8114 bindOnce(document, 'DOMContentLoaded', () => { 8115 exports.isReady = true; 8116 stack.forEach(handler => { 8117 handler(); 8118 }); 8119 stack = []; 8120 }); 8121 8122 /** 8123 * @memberOf BX 8124 */ 8125 let Event = function Event() { 8126 babelHelpers.classCallCheck(this, Event); 8127 }; 8128 babelHelpers.defineProperty(Event, "bind", bind); 8129 babelHelpers.defineProperty(Event, "bindOnce", bindOnce); 8130 babelHelpers.defineProperty(Event, "unbind", unbind); 8131 babelHelpers.defineProperty(Event, "unbindAll", unbindAll); 8132 babelHelpers.defineProperty(Event, "ready", ready); 8133 babelHelpers.defineProperty(Event, "EventEmitter", EventEmitter); 8134 babelHelpers.defineProperty(Event, "BaseEvent", BaseEvent); 8135 8136 function encodeAttributeValue(value) { 8137 if (Type.isPlainObject(value) || Type.isArray(value)) { 8138 return JSON.stringify(value); 8139 } 8140 return Text.encode(Text.decode(value)); 8141 } 8142 8143 function decodeAttributeValue(value) { 8144 if (Type.isString(value)) { 8145 const decodedValue = Text.decode(value); 8146 let result; 8147 try { 8148 result = JSON.parse(decodedValue); 8149 } catch (e) { 8150 result = decodedValue; 8151 } 8152 if (result === decodedValue) { 8153 if (/^[\d.]+[.]?\d+$/.test(result)) { 8154 return Number(result); 8155 } 8156 } 8157 if (result === 'true' || result === 'false') { 8158 return Boolean(result); 8159 } 8160 return result; 8161 } 8162 return value; 8163 } 8164 8165 function getPageScroll() { 8166 const { 8167 documentElement, 8168 body 8169 } = document; 8170 const scrollTop = Math.max(window.pageYOffset || 0, documentElement ? documentElement.scrollTop : 0, body ? body.scrollTop : 0); 8171 const scrollLeft = Math.max(window.pageXOffset || 0, documentElement ? documentElement.scrollLeft : 0, body ? body.scrollLeft : 0); 8172 return { 8173 scrollTop, 8174 scrollLeft 8175 }; 8176 } 8177 8178 /* eslint-disable @bitrix24/bitrix24-rules/no-classlist */ 8179 8180 /** 8181 * @memberOf BX 8182 */ 8183 let Dom = /*#__PURE__*/function () { 8184 function Dom() { 8185 babelHelpers.classCallCheck(this, Dom); 8186 } 8187 babelHelpers.createClass(Dom, null, [{ 8188 key: "replace", 8189 /** 8190 * Replaces old html element to new html element 8191 * @param oldElement 8192 * @param newElement 8193 */ 8194 value: function replace(oldElement, newElement) { 8195 if (Type.isDomNode(oldElement) && Type.isDomNode(newElement)) { 8196 if (Type.isDomNode(oldElement.parentNode)) { 8197 oldElement.parentNode.replaceChild(newElement, oldElement); 8198 } 8199 } 8200 } 8201 /** 8202 * Removes element 8203 * @param element 8204 */ 8205 }, { 8206 key: "remove", 8207 value: function remove(element) { 8208 if (Type.isDomNode(element) && Type.isDomNode(element.parentNode)) { 8209 element.parentNode.removeChild(element); 8210 } 8211 } 8212 /** 8213 * Cleans element 8214 * @param element 8215 */ 8216 }, { 8217 key: "clean", 8218 value: function clean(element) { 8219 if (Type.isDomNode(element)) { 8220 while (element.childNodes.length > 0) { 8221 element.removeChild(element.firstChild); 8222 } 8223 return; 8224 } 8225 if (Type.isString(element)) { 8226 Dom.clean(document.getElementById(element)); 8227 } 8228 } 8229 /** 8230 * Inserts element before target element 8231 * @param current 8232 * @param target 8233 */ 8234 }, { 8235 key: "insertBefore", 8236 value: function insertBefore(current, target) { 8237 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8238 if (Type.isDomNode(target.parentNode)) { 8239 target.parentNode.insertBefore(current, target); 8240 } 8241 } 8242 } 8243 /** 8244 * Inserts element after target element 8245 * @param current 8246 * @param target 8247 */ 8248 }, { 8249 key: "insertAfter", 8250 value: function insertAfter(current, target) { 8251 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8252 if (Type.isDomNode(target.parentNode)) { 8253 const parent = target.parentNode; 8254 if (Type.isDomNode(target.nextSibling)) { 8255 parent.insertBefore(current, target.nextSibling); 8256 return; 8257 } 8258 parent.appendChild(current); 8259 } 8260 } 8261 } 8262 /** 8263 * Appends element to target element 8264 * @param current 8265 * @param target 8266 */ 8267 }, { 8268 key: "append", 8269 value: function append(current, target) { 8270 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8271 target.appendChild(current); 8272 } 8273 } 8274 /** 8275 * Prepends element to target element 8276 * @param current 8277 * @param target 8278 */ 8279 }, {
8280 key: "prepend", 8281 value: function prepend(current, target) { 8282 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8283 if (Type.isDomNode(target.firstChild)) { 8284 target.insertBefore(current, target.firstChild); 8285 return; 8286 } 8287 Dom.append(current, target); 8288 } 8289 } 8290 /** 8291 * Checks that element contains class name or class names 8292 * @param element 8293 * @param className 8294 * @return {Boolean} 8295 */ 8296 }, { 8297 key: "hasClass", 8298 value: function hasClass(element, className) { 8299 if (Type.isElementNode(element)) { 8300 if (Type.isString(className)) { 8301 const preparedClassName = className.trim(); 8302 if (preparedClassName.length > 0) { 8303 if (preparedClassName.includes(' ')) { 8304 return preparedClassName.split(' ').every(name => Dom.hasClass(element, name)); 8305 } 8306 if ('classList' in element) { 8307 return element.classList.contains(preparedClassName); 8308 } 8309 if (Type.isObject(element.className) && Type.isString(element.className.baseVal)) { 8310 return element.getAttribute('class').split(' ').some(name => name === preparedClassName); 8311 } 8312 } 8313 } 8314 if (Type.isArray(className) && className.length > 0) { 8315 return className.every(name => Dom.hasClass(element, name)); 8316 } 8317 } 8318 return false; 8319 } 8320 /** 8321 * Adds class name 8322 * @param element 8323 * @param className 8324 */ 8325 }, { 8326 key: "addClass", 8327 value: function addClass(element, className) { 8328 if (Type.isElementNode(element)) { 8329 if (Type.isString(className)) { 8330 const preparedClassName = className.trim(); 8331 if (preparedClassName.length > 0) { 8332 if (preparedClassName.includes(' ')) { 8333 Dom.addClass(element, preparedClassName.split(' ')); 8334 return; 8335 } 8336 if ('classList' in element) { 8337 element.classList.add(preparedClassName); 8338 return; 8339 } 8340 if (Type.isObject(element.className) && Type.isString(element.className.baseVal)) { 8341 if (element.className.baseVal === '') { 8342 element.className.baseVal = preparedClassName; 8343 return; 8344 } 8345 const names = element.className.baseVal.split(' '); 8346 if (!names.includes(preparedClassName)) { 8347 names.push(preparedClassName); 8348 element.className.baseVal = names.join(' ').trim(); 8349 return; 8350 } 8351 } 8352 return; 8353 } 8354 } 8355 if (Type.isArray(className)) { 8356 className.forEach(name => Dom.addClass(element, name)); 8357 } 8358 } 8359 } 8360 /** 8361 * Removes class name 8362 * @param element 8363 * @param className 8364 */ 8365 }, { 8366 key: "removeClass", 8367 value: function removeClass(element, className) { 8368 if (Type.isElementNode(element)) { 8369 if (Type.isString(className)) { 8370 const preparedClassName = className.trim(); 8371 if (preparedClassName.length > 0) { 8372 if (preparedClassName.includes(' ')) { 8373 Dom.removeClass(element, preparedClassName.split(' ')); 8374 return; 8375 } 8376 if ('classList' in element) { 8377 element.classList.remove(preparedClassName); 8378 return; 8379 } 8380 if (Type.isObject(element.className) && Type.isString(element.className.baseVal)) { 8381 const names = element.className.baseVal.split(' ').filter(name => name !== preparedClassName); 8382 element.className.baseVal = names.join(' '); 8383 return; 8384 } 8385 } 8386 } 8387 if (Type.isArray(className)) { 8388 className.forEach(name => Dom.removeClass(element, name)); 8389 } 8390 } 8391 } 8392 /** 8393 * Toggles class name 8394 */ 8395 }, { 8396 key: "toggleClass", 8397 value: function toggleClass(element, className, force) { 8398 if (!Type.isElementNode(element) || !Type.isStringFilled(className) && !Type.isArrayFilled(className)) { 8399 return; 8400 } 8401 [className].flat().flatMap(it => { 8402 var _it$trim; 8403 return it === null || it === void 0 ? void 0 : (_it$trim = it.trim) === null || _it$trim === void 0 ? void 0 : _it$trim.call(it).split(' '); 8404 }
8404).forEach(token => { 8405 if (Type.isStringFilled(token)) { 8406 element.classList.toggle(token, Type.isBoolean(force) ? force : undefined); 8407 } 8408 }); 8409 } 8410 /** 8411 * Styles element 8412 */ 8413 }, { 8414 key: "style", 8415 value: function style(element, prop, value) { 8416 if (Type.isElementNode(element)) { 8417 if (Type.isNull(prop)) { 8418 element.removeAttribute('style'); 8419 return element; 8420 } 8421 if (Type.isPlainObject(prop)) { 8422 Object.entries(prop).forEach(item => { 8423 const [currentKey, currentValue] = item; 8424 Dom.style(element, currentKey, currentValue); 8425 }); 8426 return element; 8427 } 8428 if (Type.isString(prop)) { 8429 if (Type.isUndefined(value) && element.nodeType !== Node.DOCUMENT_NODE) { 8430 const computedStyle = getComputedStyle(element); 8431 if (prop in computedStyle) { 8432 return computedStyle[prop]; 8433 } 8434 return computedStyle.getPropertyValue(prop); 8435 } 8436 if (Type.isNull(value) || value === '' || value === 'null') { 8437 if (String(prop).startsWith('--')) { 8438 // eslint-disable-next-line 8439 element.style.removeProperty(prop); 8440 return element; 8441 } 8442 8443 // eslint-disable-next-line 8444 element.style[prop] = ''; 8445 return element; 8446 } 8447 if (Type.isString(value) || Type.isNumber(value)) { 8448 if (String(prop).startsWith('--')) { 8449 // eslint-disable-next-line 8450 element.style.setProperty(prop, value); 8451 return element; 8452 } 8453 8454 // eslint-disable-next-line 8455 element.style[prop] = value; 8456 return element; 8457 } 8458 } 8459 } 8460 return null; 8461 } 8462 /** 8463 * Adjusts element 8464 * @param target 8465 * @param data 8466 * @return {*} 8467 */ 8468 }, { 8469 key: "adjust", 8470 value: function adjust(target, data = {}) { 8471 if (!target.nodeType) { 8472 return null; 8473 } 8474 let element = target; 8475 if (target.nodeType === Node.DOCUMENT_NODE) { 8476 element = target.body; 8477 } 8478 if (Type.isPlainObject(data)) { 8479 if (Type.isPlainObject(data.attrs)) { 8480 Object.keys(data.attrs).forEach(key => { 8481 if (key === 'class' || key.toLowerCase() === 'classname') { 8482 element.className = data.attrs[key]; 8483 return; 8484 } 8485 8486 // eslint-disable-next-line 8487 if (data.attrs[key] == '') { 8488 element.removeAttribute(key); 8489 return; 8490 } 8491 element.setAttribute(key, data.attrs[key]); 8492 }); 8493 } 8494 if (Type.isPlainObject(data.style)) { 8495 Dom.style(element, data.style); 8496 } 8497 if (Type.isPlainObject(data.props)) { 8498 Object.keys(data.props).forEach(key => { 8499 element[key] = data.props[key]; 8500 }); 8501 } 8502 if (Type.isPlainObject(data.events)) { 8503 Object.keys(data.events).forEach(key => { 8504 Event.bind(element, key, data.events[key]); 8505 }); 8506 } 8507 if (Type.isPlainObject(data.dataset)) { 8508 Object.keys(data.dataset).forEach(key => { 8509 element.dataset[key] = data.dataset[key]; 8510 }); 8511 } 8512 if (Type.isString(data.children)) { 8513 data.children = [data.children]; 8514 } 8515 if (Type.isArray(data.children) && data.children.length > 0) { 8516 data.children.forEach(item => { 8517 if (Type.isDomNode(item)) { 8518 Dom.append(item, element); 8519 } 8520 if (Type.isString(item)) { 8521 element.insertAdjacentHTML('beforeend', item); 8522 } 8523 }); 8524 return element; 8525 } 8526 if ('text' in data && !Type.isNil(data.text)) { 8527 element.textContent = data.text; 8528 return element; 8529 } 8530 if ('html' in data && !Type.isNil(data.html)) { 8531 element.innerHTML = data.html; 8532 } 8533 } 8534 return element; 8535 } 8536 /** 8537 * Creates element 8538 * @param tag 8539 * @param data 8540 * @param context 8541 * @return {HTMLElement|HTMLBodyElement} 8542 */ 8543 }, { 8544 key: "create", 8545 value: function create(tag, data = {}, context = document) { 8546 let tagName = tag; 8547 let options = data; 8548 if (Type.isObjectLike(tag)) { 8549 options = tag; 8550 tagName = tag.tag; 8551 } 8552 return Dom.adjust(context.createElement(tagName), options); 8553 } 8554 /** 8555 * Shows element 8556 * @param element 8557 */ 8558 }, { 8559 key: "show", 8560 value: function show(element) { 8561 if (Type.isDomNode(element)) { 8562 // eslint-disable-next-line 8563 element.hidden = false;
8564 } 8565 } 8566 /** 8567 * Hides element 8568 * @param element 8569 */ 8570 }, { 8571 key: "hide", 8572 value: function hide(element) { 8573 if (Type.isDomNode(element)) { 8574 // eslint-disable-next-line 8575 element.hidden = true; 8576 } 8577 } 8578 /** 8579 * Checks that element is shown 8580 * @param element 8581 * @return {*|boolean} 8582 */ 8583 }, { 8584 key: "isShown", 8585 value: function isShown(element) { 8586 return Type.isDomNode(element) && !element.hidden && element.style.getPropertyValue('display') !== 'none'; 8587 } 8588 /** 8589 * Toggles element visibility 8590 * @param element 8591 */ 8592 }, { 8593 key: "toggle", 8594 value: function toggle(element) { 8595 if (Type.isDomNode(element)) { 8596 if (Dom.isShown(element)) { 8597 Dom.hide(element); 8598 } else { 8599 Dom.show(element); 8600 } 8601 } 8602 } 8603 /** 8604 * Gets element position relative page 8605 * @param {HTMLElement} element 8606 * @return {DOMRect} 8607 */ 8608 }, { 8609 key: "getPosition", 8610 value: function getPosition(element) { 8611 if (Type.isDomNode(element)) { 8612 const elementRect = element.getBoundingClientRect(); 8613 const { 8614 scrollLeft, 8615 scrollTop 8616 } = getPageScroll(); 8617 return new DOMRect(elementRect.left + scrollLeft, elementRect.top + scrollTop, elementRect.width, elementRect.height); 8618 } 8619 return new DOMRect(); 8620 } 8621 /** 8622 * Gets element position relative specified element position 8623 * @param {HTMLElement} element 8624 * @param {HTMLElement} relationElement 8625 * @return {DOMRect} 8626 */ 8627 }, { 8628 key: "getRelativePosition", 8629 value: function getRelativePosition(element, relationElement) { 8630 if (Type.isDomNode(element) && Type.isDomNode(relationElement)) { 8631 const elementPosition = Dom.getPosition(element); 8632 const relationElementPosition = Dom.getPosition(relationElement); 8633 return new DOMRect(elementPosition.left - relationElementPosition.left, elementPosition.top - relationElementPosition.top, elementPosition.width, elementPosition.height); 8634 } 8635 return new DOMRect(); 8636 } 8637 }, { 8638 key: "attr", 8639 value: function attr(element, _attr, value) { 8640 if (Type.isElementNode(element)) { 8641 if (Type.isString(_attr)) { 8642 if (!Type.isNil(value)) { 8643 return element.setAttribute(_attr, encodeAttributeValue(value)); 8644 } 8645 if (Type.isNull(value)) { 8646 return element.removeAttribute(_attr); 8647 } 8648 return decodeAttributeValue(element.getAttribute(_attr)); 8649 } 8650 if (Type.isPlainObject(_attr)) { 8651 return Object.entries(_attr).forEach(([attrKey, attrValue]) => { 8652 Dom.attr(element, attrKey, attrValue); 8653 }); 8654 } 8655 } 8656 return null; 8657 } 8658 }]); 8659 return Dom; 8660 }(); 8661 8662 const UA = navigator.userAgent.toLowerCase(); 8663 8664 /** 8665 * @memberOf BX 8666 */ 8667 let Browser = /*#__PURE__*/function () { 8668 function Browser() { 8669 babelHelpers.classCallCheck(this, Browser); 8670 } 8671 babelHelpers.createClass(Browser, null, [{ 8672 key: "isOpera", 8673 value: function isOpera() { 8674 return UA.includes('opera'); 8675 } 8676 }, { 8677 key: "isIE", 8678 value: function isIE() { 8679 return 'attachEvent' in document && !Browser.isOpera(); 8680 } 8681 }, { 8682 key: "isIE6", 8683 value: function isIE6() { 8684 return UA.includes('msie 6'); 8685 } 8686 }, { 8687 key: "isIE7", 8688 value: function isIE7() { 8689 return UA.includes('msie 7'); 8690 } 8691 }, { 8692 key: "isIE8", 8693 value: function isIE8() { 8694 return UA.includes('msie 8'); 8695 } 8696 }, { 8697 key: "isIE9", 8698 value: function isIE9() { 8699 return 'documentMode' in document && document.documentMode >= 9; 8700 } 8701 }, { 8702 key: "isIE10", 8703 value: function isIE10() { 8704 return 'documentMode' in document && document.documentMode >= 10; 8705 } 8706 }, { 8707 key: "isSafari", 8708 value: function isSafari() { 8709 return UA.includes('safari') && !UA.includes('chrome'); 8710 } 8711 }, { 8712 key: "isFirefox", 8713 value: function isFirefox() { 8714 return UA.includes('firefox'); 8715 } 8716 }, { 8717 key: "isChrome", 8718 value: function isChrome() { 8719 return UA.includes('chrome'); 8720 } 8721 }, { 8722 key: "detectIEVersion", 8723 value: function detectIEVersion() { 8724 if (Browser.isOpera() || Browser.isSafari() || Browser.isFirefox() || Browser.isChrome()) { 8725 return -1; 8726 } 8727 let rv = -1; 8728 if (!!window.MSStream && !window.ActiveXObject && 'ActiveXObject' in window) { 8729 rv = 11; 8730 } else if (Browser.isIE10()) { 8731 rv = 10; 8732 } else if (Browser.isIE9()) { 8733 rv = 9; 8734 } else if (Browser.isIE()) { 8735 rv = 8; 8736 } 8737 if (rv === -1 || rv === 8) { 8738 if (navigator.appName === 'Microsoft Internet Explorer') { 8739 const re = new RegExp('MSIE ([0-9]+[.0-9]*)'); 8740 const res = navigator.userAgent.match(re); 8741 if (Type.isArrayLike(res) && res.length > 0) { 8742 rv = parseFloat(res[1]); 8743 } 8744 } 8745 if (navigator.appName === 'Netscape') { 8746 // Alternative check for IE 11 8747 rv = 11; 8748 const re = new RegExp('Trident/.*rv:([0-9]+[.0-9]*)'); 8749 if (re.exec(navigator.userAgent) != null) { 8750 const res = navigator.userAgent.match(re); 8751 if (Type.isArrayLike(res) && res.length > 0) { 8752 rv = parseFloat(res[1]); 8753 } 8754 } 8755 } 8756 } 8757 return rv; 8758 } 8759 }, { 8760 key: "isIE11", 8761 value: function isIE11() { 8762 return Browser.detectIEVersion() >= 11; 8763 } 8764 }, { 8765 key: "isMac", 8766 value: function isMac() { 8767 return UA.includes('macintosh'); 8768 } 8769 }, { 8770 key: "isWin", 8771 value: function isWin() { 8772 return UA.includes('windows'); 8773 } 8774 }, { 8775 key: "isLinux", 8776 value: function isLinux() { 8777 return UA.includes('linux') && !Browser.isAndroid(); 8778 } 8779 }, { 8780 key: "isAndroid", 8781 value: function isAndroid() { 8782 return UA.includes('android'); 8783 } 8784 }, { 8785 key: "isIPad", 8786 value: function isIPad() { 8787 return UA.includes('ipad;') || this.isMac() && this.isTouchDevice(); 8788 } 8789 }, { 8790 key: "isIPhone", 8791 value: function isIPhone() { 8792 return UA.includes('iphone;'); 8793 } 8794 }, { 8795 key: "isIOS", 8796 value: function isIOS() { 8797 return Browser.isIPad() || Browser.isIPhone(); 8798 } 8799 }, { 8800 key: "isMobile", 8801 value: function isMobile() { 8802 return Browser.isIPhone() || Browser.isIPad() || Browser.isAndroid() || UA.includes('mobile') || UA.includes('touch'); 8803 } 8804 }, { 8805 key: "isRetina", 8806 value: function isRetina() { 8807 return window.devicePixelRatio && window.devicePixelRatio >= 2; 8808 } 8809 }, { 8810 key: "isTouchDevice", 8811 value: function isTouchDevice() { 8812 return 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0; 8813 } 8814 }, { 8815 key: "isDoctype", 8816 value: function isDoctype(target) { 8817 const doc = target || document; 8818 if (doc.compatMode) { 8819 return doc.compatMode === 'CSS1Compat'; 8820 } 8821 return doc.documentElement && doc.documentElement.clientHeight; 8822 } 8823 }, { 8824 key: "isLocalStorageSupported", 8825 value: function isLocalStorageSupported() { 8826 try { 8827 localStorage.setItem('test', 'test'); 8828 localStorage.removeItem('test'); 8829 return true; 8830 } catch (e) { 8831 return false;
8832 } 8833 } 8834 }, { 8835 key: "addGlobalClass", 8836 value: function addGlobalClass(target) { 8837 let globalClass = 'bx-core'; 8838 target = Type.isElementNode(target) ? target : document.documentElement; 8839 if (Dom.hasClass(target, globalClass)) { 8840 return; 8841 } 8842 if (Browser.isIOS()) { 8843 globalClass += ' bx-ios'; 8844 } else if (Browser.isWin()) { 8845 globalClass += ' bx-win'; 8846 } else if (Browser.isMac()) { 8847 globalClass += ' bx-mac'; 8848 } else if (Browser.isLinux()) { 8849 globalClass += ' bx-linux'; 8850 } else if (Browser.isAndroid()) { 8851 globalClass += ' bx-android'; 8852 } 8853 globalClass += Browser.isMobile() ? ' bx-touch' : ' bx-no-touch'; 8854 globalClass += Browser.isRetina() ? ' bx-retina' : ' bx-no-retina'; 8855 if (/AppleWebKit/.test(navigator.userAgent)) { 8856 globalClass += ' bx-chrome'; 8857 } else if (/Opera/.test(navigator.userAgent)) { 8858 globalClass += ' bx-opera'; 8859 } else if (Browser.isFirefox()) { 8860 globalClass += ' bx-firefox'; 8861 } 8862 Dom.addClass(target, globalClass); 8863 } 8864 }, { 8865 key: "detectAndroidVersion", 8866 value: function detectAndroidVersion() { 8867 const re = new RegExp('Android ([0-9]+[.0-9]*)'); 8868 if (re.exec(navigator.userAgent) != null) { 8869 const res = navigator.userAgent.match(re); 8870 if (Type.isArrayLike(res) && res.length > 0) { 8871 return parseFloat(res[1]); 8872 } 8873 } 8874 return 0; 8875 } 8876 }, { 8877 key: "isPropertySupported", 8878 value: function isPropertySupported(jsProperty, returnCSSName) { 8879 if (jsProperty === '') { 8880 return false; 8881 } 8882 function getCssName(propertyName) { 8883 return propertyName.replace(/([A-Z])/g, (...args) => `-${args[1].toLowerCase()}`); 8884 } 8885 function getJsName(cssName) { 8886 const reg = /(\\-([a-z]))/g; 8887 if (reg.test(cssName)) { 8888 return cssName.replace(reg, (...args) => args[2].toUpperCase()); 8889 } 8890 return cssName; 8891 } 8892 const property = jsProperty.includes('-') ? getJsName(jsProperty) : jsProperty; 8893 const bReturnCSSName = !!returnCSSName; 8894 const ucProperty = property.charAt(0).toUpperCase() + property.slice(1); 8895 const props = ['Webkit', 'Moz', 'O', 'ms'].join(`${ucProperty} `); 8896 const properties = `${property} ${props} ${ucProperty}`.split(' '); 8897 const obj = document.body || document.documentElement; 8898 for (let i = 0; i < properties.length; i += 1) { 8899 const prop = properties[i]; 8900 if (obj && 'style' in obj && prop in obj.style) { 8901 const lowerProp = prop.substr(0, prop.length - property.length).toLowerCase(); 8902 const prefix = prop === property ? '' : `-${lowerProp}-`; 8903 return bReturnCSSName ? prefix + getCssName(property) : prop; 8904 } 8905 } 8906 return false; 8907 } 8908 }, { 8909 key: "addGlobalFeatures", 8910 value: function addGlobalFeatures(features) { 8911 if (!Type.isArray(features)) { 8912 return; 8913 } 8914 const classNames = []; 8915 for (let i = 0; i < features.length; i += 1) { 8916 const support = !!Browser.isPropertySupported(features[i]); 8917 classNames.push(`bx-${support ? '' : 'no-'}${features[i].toLowerCase()}`); 8918 } 8919 Dom.addClass(document.documentElement, classNames.join(' ')); 8920 } 8921 }]); 8922 return Browser; 8923 }(); 8924 8925 let Cookie = /*#__PURE__*/function () { 8926 function Cookie() { 8927 babelHelpers.classCallCheck(this, Cookie); 8928 } 8929 babelHelpers.createClass(Cookie, null, [{ 8930 key: "getList", 8931 /** 8932 * Gets cookies list for current domain 8933 * @return {object} 8934 */ 8935 value: function getList() { 8936 return document.cookie.split(';').map(item => item.split('=')).map(item => item.map(subItem => subItem.trim())).reduce((acc, item) => { 8937 const [key, value] = item; 8938 acc[decodeURIComponent(key)] = decodeURIComponent(value); 8939 return acc; 8940 }, {}); 8941 } 8942 /** 8943 * Gets cookie value 8944 * @param {string} name 8945 * @return {*} 8946 */ 8947 }, { 8948 key: "get", 8949 value: function get(name) { 8950 const cookiesList = Cookie.getList(); 8951 if (name in cookiesList) { 8952 return cookiesList[name]; 8953 } 8954 return undefined; 8955 } 8956 /** 8957 * Sets cookie 8958 * @param {string} name 8959 * @param {*} value 8960 * @param {object} [options] 8961 */ 8962 }, { 8963 key: "set", 8964 value: function set(name, value, options = {}) { 8965 const attributes = { 8966 expires: '', 8967 ...options 8968 }; 8969 if (Type.isNumber(attributes.expires)) { 8970 const now = +new Date(); 8971 const days = attributes.expires; 8972 const dayInMs = 864e+5; 8973 attributes.expires = new Date(now + days * dayInMs); 8974 } 8975 if (Type.isDate(attributes.expires)) { 8976 attributes.expires = attributes.expires.toUTCString(); 8977 } 8978 const safeName = decodeURIComponent(String(name)).replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape); 8979 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); 8980 const stringifiedAttributes = Object.keys(attributes).reduce((acc, key) => { 8981 const attributeValue = attributes[key]; 8982 if (!attributeValue) { 8983 return acc; 8984 } 8985 if (attributeValue === true) { 8986 return `${acc}; ${key}`; 8987 } 8988 8989 /** 8990 * Considers RFC 6265 section 5.2: 8991 * ... 8992 * 3. If the remaining unparsed-attributes contains a %x3B (';') 8993 * character: 8994 * Consume the characters of the unparsed-attributes up to, 8995 * not including, the first %x3B (';') character. 8996 */ 8997 return `${acc}; ${key}=${attributeValue.split(';')[0]}`; 8998 }, ''); 8999 document.cookie = `${safeName}=${safeValue}${stringifiedAttributes}`; 9000 } 9001 /** 9002 * Removes cookie 9003 * @param {string} name 9004 * @param {object} [options] 9005 */ 9006 }, { 9007 key: "remove", 9008 value: function remove(name, options = {}) { 9009 Cookie.set(name, '', { 9010 ...options, 9011 expires: -1 9012 }); 9013 } 9014 }]); 9015 return Cookie; 9016 }(); 9017 9018 function objectToFormData(source, formData = new FormData(), pre = null) { 9019 if (Type.isUndefined(source)) { 9020 return formData; 9021 } 9022 if (Type.isNull(source)) { 9023 formData.append(pre, ''); 9024 } else if (Type.isArray(source)) { 9025 if (!source.length) {
9026 const key = `${pre}[]`; 9027 formData.append(key, ''); 9028 } else { 9029 source.forEach((value, index) => { 9030 const key = `${pre}[${index}]`; 9031 objectToFormData(value, formData, key); 9032 }); 9033 } 9034 } else if (Type.isDate(source)) { 9035 formData.append(pre, source.toISOString()); 9036 } else if (Type.isObject(source) && !Type.isFile(source) && !Type.isBlob(source)) { 9037 Object.keys(source).forEach(property => { 9038 const value = source[property]; 9039 let preparedProperty = property; 9040 if (Type.isArray(value)) { 9041 while (preparedProperty.length > 2 && preparedProperty.lastIndexOf('[]') === preparedProperty.length - 2) { 9042 preparedProperty = preparedProperty.substring(0, preparedProperty.length - 2); 9043 } 9044 } 9045 const key = pre ? `${pre}[${preparedProperty}]` : preparedProperty; 9046 objectToFormData(value, formData, key); 9047 }); 9048 } else { 9049 formData.append(pre, source); 9050 } 9051 return formData; 9052 } 9053 9054 let Data = /*#__PURE__*/function () { 9055 function Data() { 9056 babelHelpers.classCallCheck(this, Data); 9057 } 9058 babelHelpers.createClass(Data, null, [{ 9059 key: "convertObjectToFormData", 9060 /** 9061 * Converts object to FormData 9062 * @param source 9063 * @return {FormData} 9064 */ 9065 value: function convertObjectToFormData(source) { 9066 return objectToFormData(source); 9067 } 9068 }]); 9069 return Data; 9070 }(); 9071 9072 /** 9073 * @memberOf BX 9074 */ 9075 let Http = function Http() { 9076 babelHelpers.classCallCheck(this, Http); 9077 }; 9078 babelHelpers.defineProperty(Http, "Cookie", Cookie); 9079 babelHelpers.defineProperty(Http, "Data", Data); 9080 9081 function message(value) { 9082 if (Type.isString(value)) { 9083 if (Type.isNil(message[value])) { 9084 // eslint-disable-next-line 9085 EventEmitter.emit('onBXMessageNotFound', new BaseEvent({ 9086 compatData: [value] 9087 })); 9088 if (Type.isNil(message[value])) { 9089 Runtime.debug(`message undefined: ${value}`); 9090 message[value] = ''; 9091 } 9092 } 9093 } 9094 if (Type.isPlainObject(value)) { 9095 Object.keys(value).forEach(key => { 9096 message[key] = value[key]; 9097 }); 9098 } 9099 return message[value]; 9100 } 9101 if (!Type.isNil(window.BX) && Type.isFunction(window.BX.message)) { 9102 Object.keys(window.BX.message).forEach(key => { 9103 message({ 9104 [key]: window.BX.message[key] 9105 }); 9106 }); 9107 } 9108 9109 /** 9110 * Implements interface for works with language messages 9111 * @memberOf BX 9112 */ 9113 let Loc = /*#__PURE__*/function () { 9114 function Loc() { 9115 babelHelpers.classCallCheck(this, Loc); 9116 } 9117 babelHelpers.createClass(Loc, null, [{ 9118 key: "getMessage", 9119 /** 9120 * Gets message by id 9121 * @param {string} messageId 9122 * @param {object} replacements 9123 * @return {?string} 9124 */ 9125 value: function getMessage(messageId, replacements = null) { 9126 let mess = message(messageId); 9127 if (Type.isString(mess) && Type.isPlainObject(replacements)) { 9128 const escape = str => String(str).replace(/[\\^$*+?.()|[\]{}]/g, '\\$&'); 9129 Object.keys(replacements).forEach(replacement => { 9130 const globalRegexp = new RegExp(escape(replacement), 'gi'); 9131 mess = mess.replace(globalRegexp, () => { 9132 return Type.isNil(replacements[replacement]) ? '' : String(replacements[replacement]); 9133 }); 9134 }); 9135 } 9136 return mess; 9137 } 9138 }, { 9139 key: "hasMessage", 9140 value: function hasMessage(messageId) { 9141 return Type.isString(messageId) && !Type.isNil(message[messageId]); 9142 } 9143 /** 9144 * Sets message or messages 9145 * @param {string | Object<string, string>} id 9146 * @param {string} [value] 9147 */ 9148 }, { 9149 key: "setMessage", 9150 value: function setMessage(id, value) { 9151 if (Type.isString(id) && Type.isString(value)) { 9152 message({ 9153 [id]: value 9154 }); 9155 } 9156 if (Type.isObject(id)) { 9157 message(id); 9158 } 9159 } 9160 /** 9161 * Gets plural message by id and number 9162 * @param {string} messageId 9163 * @param {number} value 9164 * @param {object} [replacements] 9165 * @return {?string} 9166 */ 9167 }, { 9168 key: "getMessagePlural",
9169 value: function getMessagePlural(messageId, value, replacements = null) { 9170 let result = ''; 9171 if (Type.isNumber(value)) { 9172 if (this.hasMessage(`${messageId}_PLURAL_${this.getPluralForm(value)}`)) { 9173 result = this.getMessage(`${messageId}_PLURAL_${this.getPluralForm(value)}`, replacements); 9174 } else { 9175 result = this.getMessage(`${messageId}_PLURAL_1`, replacements); 9176 } 9177 } else { 9178 result = this.getMessage(messageId, replacements); 9179 } 9180 return result; 9181 } 9182 /** 9183 * Gets language plural form id by number 9184 * see http://docs.translatehouse.org/projects/localization-guide/en/latest/l10n/pluralforms.html 9185 * @param {number} value 9186 * @param {string} [languageId] 9187 * @return {?number} 9188 */ 9189 }, { 9190 key: "getPluralForm", 9191 value: function getPluralForm(value, languageId) { 9192 let pluralForm; 9193 if (!Type.isStringFilled(languageId)) { 9194 languageId = message('LANGUAGE_ID'); 9195 } 9196 if (value < 0) { 9197 value = -1 * value; 9198 } 9199 switch (languageId) { 9200 case 'ar': 9201 pluralForm = value !== 1 ? 1 : 0; 9202 /* 9203 if (value === 0) 9204 { 9205 pluralForm = 0; 9206 } 9207 else if (value === 1) 9208 { 9209 pluralForm = 1; 9210 } 9211 else if (value === 2) 9212 { 9213 pluralForm = 2; 9214 } 9215 else if ( 9216 value % 100 >= 3 9217 && value % 100 <= 10 9218 ) 9219 { 9220 pluralForm = 3; 9221 } 9222 else if (value % 100 >= 11) 9223 { 9224 pluralForm = 4; 9225 } 9226 else 9227 { 9228 pluralForm = 5; 9229 } 9230 */ 9231 break; 9232 case 'br': 9233 case 'fr': 9234 case 'tr': 9235 pluralForm = value > 1 ? 1 : 0; 9236 break; 9237 case 'de': 9238 case 'en': 9239 case 'hi': 9240 case 'it': 9241 case 'la': 9242 pluralForm = value !== 1 ? 1 : 0; 9243 break; 9244 case 'ru': 9245 case 'ua': 9246 if (value % 10 === 1 && value % 100 !== 11) { 9247 pluralForm = 0; 9248 } else if (value % 10 >= 2 && value % 10 <= 4 && (value % 100 < 10 || value % 100 >= 20)) { 9249 pluralForm = 1; 9250 } else { 9251 pluralForm = 2; 9252 } 9253 break; 9254 case 'pl': 9255 if (value === 1) { 9256 pluralForm = 0; 9257 } else if (value % 10 >= 2 && value % 10 <= 4 && (value % 100 < 10 || value % 100 >= 20)) { 9258 pluralForm = 1; 9259 } else { 9260 pluralForm = 2; 9261 } 9262 break; 9263 case 'id': 9264 case 'ja': 9265 case 'ms': 9266 case 'sc': 9267 case 'tc': 9268 case 'th': 9269 case 'vn': 9270 pluralForm = 0; 9271 break; 9272 default: 9273 pluralForm = 1; 9274 break; 9275 } 9276 return pluralForm; 9277 } 9278 }]); 9279 return Loc; 9280 }(); 9281 9282 const voidElements = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr']; 9283 function isVoidElement(element) { 9284 return voidElements.includes(element); 9285 } 9286 9287 const matchers = { 9288 tag: /<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>|{{uid[0-9]+}}/g, 9289 comment: /<!--(?!<!)[^\[>].*?-->/g, 9290 tagName: /<\/?([^\s]+?)[/\s>]/, 9291 attributes: /\s([\w\-_:.]+)\s?\n?=\s?\n?"([^"]+)?"|\s([\w\-_:.]+)\s?\n?=\s?\n?'([^']+)?'|\s([\w\-_:.]+)/gs, 9292 placeholder: /{{uid[0-9]+}}/g 9293 }; 9294 9295 function parseTag(tag) { 9296 const tagResult = { 9297 type: 'tag', 9298 name: '', 9299 svg: false, 9300 attrs: {}, 9301 children: [], 9302 voidElement: false 9303 }; 9304 if (tag.startsWith('<!--')) { 9305 const endIndex = tag.indexOf('-->'); 9306 const openTagLength = '<!--'.length; 9307 return { 9308 type: 'comment', 9309 content: endIndex !== -1 ? tag.slice(openTagLength, endIndex) : '' 9310 }; 9311 } 9312 const tagNameMatch = tag.match(matchers.tagName); 9313 if (Type.isArrayFilled(tagNameMatch)) { 9314 const [, tagName] = tagNameMatch; 9315 tagResult.name = tagName; 9316 tagResult.svg = tagName === 'svg'; 9317 tagResult.voidElement = isVoidElement(tagName) || tag.trim().endsWith('/>'); 9318 } 9319 const reg = new RegExp(matchers.attributes); 9320 for (;;) { 9321 const result = reg.exec(tag); 9322 if (!Type.isNil(result)) { 9323 // Attributes with double quotes 9324 const [, attrName, attrValue] = result; 9325 if (!Type.isNil(attrName)) { 9326 tagResult.attrs[attrName] = Type.isStringFilled(attrValue) ? attrValue : ''; 9327 } else { 9328 // Attributes with single quotes 9329 const [,,, attrName, attrValue] = result; 9330 if (!Type.isNil(attrName)) { 9331 tagResult.attrs[attrName] = Type.isStringFilled(attrValue) ? attrValue : ''; 9332 } else { 9333 // Attributes without value 9334 const [,,,,, attrName] = result; 9335 tagResult.attrs[attrName] = ''; 9336 } 9337 } 9338 } else { 9339 break; 9340 } 9341 } 9342 return tagResult; 9343 } 9344 9345 function parseText(input) { 9346 const preparedText = input.replace(/[\n\r\t]$/, ''); 9347 const placeholders = preparedText.match(matchers.placeholder); 9348 return preparedText.split(matchers.placeholder).reduce((acc, item, index) => { 9349 if (Type.isStringFilled(item)) { 9350 acc.push(...item.split(/\n/).reduce((textAcc, text) => { 9351 const preparedItemText = text.replace(/[\t\r]/g, ''); 9352 if (Type.isStringFilled(preparedItemText)) { 9353 textAcc.push({ 9354 type: 'text', 9355 content: preparedItemText 9356 }); 9357 } 9358 return textAcc; 9359 }, [])); 9360 } 9361 if (placeholders && placeholders[index]) { 9362 acc.push({ 9363 type: 'placeholder', 9364 uid: parseInt(placeholders[index].replace(/{{uid|}}/, '')) 9365 }); 9366 } 9367 return acc; 9368 }, []); 9369 } 9370 9371 function parse(html, substitutions) { 9372 const result = []; 9373 if (html.indexOf('<') !== 0 && !html.startsWith('{{')) { 9374 const end = html.indexOf('<'); 9375 result.push(...parseText(end === -1 ? html : html.slice(0, end))); 9376 } 9377 const commentsContent = []; 9378 let commentIndex = -1; 9379 html = html.replace(matchers.comment, tag => { 9380 commentIndex += 1; 9381 commentsContent.push(tag.replace(/^<!--|-->$/g, '')); 9382 return `<!--{{cUid${commentIndex}}}-->`; 9383 }); 9384 const arr = []; 9385 let level = -1; 9386 let current; 9387 html.replace(matchers.tag, (tag, index) => { 9388 const start = index + tag.length; 9389 const nextChar = html.charAt(start); 9390 let parent; 9391 if (tag.startsWith('<!--')) { 9392 const comment = parseTag(tag, substitutions); 9393 comment.content = commentsContent[tag.replace(/<!--{{cUid|}}-->/g, '')]; 9394 if (level < 0) { 9395 result.push(comment); 9396 return result; 9397 } 9398 parent = arr[level]; 9399 parent.children.push(comment); 9400 return result; 9401 } 9402 if (tag.startsWith('{{')) { 9403 const [placeholder] = parseText(tag); 9404 if (level < 0) { 9405 result.push(placeholder); 9406 return result; 9407 } 9408 parent = arr[level]; 9409 parent.children.push(placeholder); 9410 return result; 9411 } 9412 if (!tag.startsWith('</')) { 9413 level++; 9414 current = parseTag(tag, substitutions); 9415 if (!current.voidElement && nextChar && nextChar !== '<') { 9416 current.children.push(...parseText(html.slice(start, html.indexOf('<', start)))); 9417 } 9418 if (level === 0) { 9419 result.push(current); 9420 } 9421 parent = arr[level - 1]; 9422 if (parent) { 9423 if (!current.svg) { 9424 current.svg = parent.svg; 9425 } 9426 parent.children.push(current); 9427 } 9428 arr[level] = current; 9429 } 9430 if (tag.startsWith('</') || current.voidElement) { 9431 if (level > -1 && (current.voidElement || current.name === tag.slice(2, -1))) { 9432 level--; 9433 current = level === -1 ? result : arr[level]; 9434 } 9435 if (nextChar && nextChar !== '<') { 9436 parent = level === -1 ? result : arr[level].children; 9437 const end = html.indexOf('<', start); 9438 const content = html.slice(start, end === -1 ? undefined : end); 9439 if (end >
9439 -1 && level + parent.length >= 0 || content !== ' ') { 9440 parent.push(...parseText(content)); 9441 } 9442 } 9443 } 9444 }); 9445 return result; 9446 } 9447 9448 const appendElement = (current, target) => { 9449 if (Type.isDomNode(current) && Type.isDomNode(target)) { 9450 if (target.nodeName !== 'TEMPLATE') { 9451 Dom.append(current, target); 9452 } else { 9453 // eslint-disable-next-line bitrix-rules/no-native-dom-methods 9454 target.content.append(current); 9455 } 9456 } 9457 }; 9458 function renderNode(options) { 9459 const { 9460 node, 9461 parentElement, 9462 substitutions, 9463 refs = [] 9464 } = options; 9465 if (node.type === 'tag') { 9466 const element = (() => { 9467 if (node.svg) { 9468 return document.createElementNS('http://www.w3.org/2000/svg', node.name); 9469 } 9470 return document.createElement(node.name); 9471 })(); 9472 if (Object.hasOwn(node.attrs, 'ref')) { 9473 refs.push([node.attrs.ref, element]); 9474 delete node.attrs.ref; 9475 } 9476 Object.entries(node.attrs).forEach(([key, value]) => { 9477 if (key.startsWith('on') && new RegExp(matchers.placeholder).test(value)) { 9478 const substitution = substitutions[parseInt(value.replace(/{{uid|}}/, '')) - 1]; 9479 if (Type.isFunction(substitution)) { 9480 const bindFunctionName = key.endsWith('once') ? 'bindOnce' : 'bind'; 9481 Event[bindFunctionName](element, key.replace(/^on|once$/g, ''), substitution); 9482 } else { 9483 element.setAttribute(key, substitution); 9484 } 9485 } else { 9486 if (new RegExp(matchers.placeholder).test(value)) { 9487 const preparedValue = value.split(/{{|}}/).reduce((acc, item) => { 9488 if (item.startsWith('uid')) { 9489 const substitution = substitutions[parseInt(item.replace('uid', '')) - 1]; 9490 return `${acc}${substitution}`; 9491 } 9492 return `${acc}${item}`; 9493 }, ''); 9494 element.setAttribute(key, preparedValue); 9495 } else { 9496 element.setAttribute(key, Text.decode(value)); 9497 } 9498 } 9499 }); 9500 node.children.forEach(childNode => { 9501 const result = renderNode({ 9502 node: childNode, 9503 parentElement: element, 9504 substitutions, 9505 refs 9506 }); 9507 if (Type.isArray(result)) { 9508 result.forEach(subChildElement => { 9509 appendElement(subChildElement, element); 9510 }); 9511 } else { 9512 appendElement(result, element); 9513 } 9514 }); 9515 return element; 9516 } 9517 if (node.type === 'comment') { 9518 return document.createComment(node.content); 9519 } 9520 if (node.type === 'text') { 9521 if (parentElement) { 9522 if (parentElement.nodeName !== 'TEMPLATE') { 9523 parentElement.insertAdjacentHTML('beforeend', node.content); 9524 } else { 9525 parentElement.content.append(node.content); 9526 } 9527 return; 9528 } 9529 return document.createTextNode(node.content); 9530 } 9531 if (node.type === 'placeholder') { 9532 return substitutions[node.uid - 1]; 9533 } 9534 } 9535 9536 function render(sections, ...substitutions) { 9537 const html = sections.reduce((acc, item, index) => { 9538 if (index > 0) { 9539 const substitution = substitutions[index - 1]; 9540 if (Type.isString(substitution) || Type.isNumber(substitution)) { 9541 return `${acc}${substitution}${item}`; 9542 } 9543 return `${acc}{{uid${index}}}${item}`; 9544 } 9545 return acc; 9546 }, sections[0]).replace(/^[\r\n\t\s]+/gm, '').replace(/>[\n]+/g, '>').replace(/[}][\n]+/g, '}'); 9547 const ast = parse(html); 9548 if (ast.length === 1) { 9549 const refs = []; 9550 const renderedNode = renderNode({ 9551 node: ast[0], 9552 substitutions, 9553 refs 9554 }); 9555 if (Type.isArrayFilled(refs)) { 9556 return Object.fromEntries([['root', renderedNode], ...refs]); 9557 } 9558 return renderedNode; 9559 } 9560 if (ast.length > 1) { 9561 const refs = []; 9562 const renderedNodes = ast.map(node => { 9563 return renderNode({ 9564 node, 9565 substitutions, 9566 refs 9567 }); 9568 }); 9569 if (Type.isArrayFilled(refs)) { 9570 return Object.fromEntries([['root', renderedNodes], ...refs]); 9571 } 9572 return renderedNodes; 9573 } 9574 return false;
9575 } 9576 9577 function parseProps(sections, ...substitutions) { 9578 return substitutions.reduce((acc, item, index) => { 9579 const nextSectionIndex = index + 1; 9580 if (!Type.isPlainObject(item) && !Type.isArray(item)) { 9581 return acc + item + sections[nextSectionIndex]; 9582 } 9583 return `${acc}__s${index}${sections[nextSectionIndex]}`; 9584 }, sections[0]).replace(/[\r\t]/gm, '').split(';\n').map(item => item.replace(/\n/, '')).reduce((acc, item) => { 9585 if (item !== '') { 9586 const matches = item.match(/^[\w-. ]+:/); 9587 const splitted = item.split(/^[\w-. ]+:/); 9588 const key = matches[0].replace(':', '').trim(); 9589 const value = splitted[1].trim(); 9590 const substitutionPlaceholderExp = /^__s\d+/; 9591 if (substitutionPlaceholderExp.test(value)) { 9592 acc[key] = substitutions[value.replace('__s', '')]; 9593 return acc; 9594 } 9595 acc[key] = value; 9596 } 9597 return acc; 9598 }, {}); 9599 } 9600 9601 /** 9602 * @memberOf BX 9603 */ 9604 let Tag = /*#__PURE__*/function () { 9605 function Tag() { 9606 babelHelpers.classCallCheck(this, Tag); 9607 } 9608 babelHelpers.createClass(Tag, null, [{ 9609 key: "safe", 9610 /** 9611 * Encodes all substitutions 9612 * @param sections 9613 * @param substitutions 9614 * @return {string} 9615 */ 9616 value: function safe(sections, ...substitutions) { 9617 return substitutions.reduce((acc, item, index) => acc + Text.encode(item) + sections[index + 1], sections[0]); 9618 } 9619 /** 9620 * Decodes all substitutions 9621 * @param sections 9622 * @param substitutions 9623 * @return {string} 9624 */ 9625 }, { 9626 key: "unsafe", 9627 value: function unsafe(sections, ...substitutions) { 9628 return substitutions.reduce((acc, item, index) => acc + Text.decode(item) + sections[index + 1], sections[0]); 9629 } 9630 /** 9631 * Adds styles to specified element 9632 * @param {HTMLElement} element 9633 * @return {Function} 9634 */ 9635 }, { 9636 key: "style", 9637 value: function style(element) { 9638 if (!Type.isDomNode(element)) { 9639 throw new Error('element is not HTMLElement'); 9640 } 9641 return function styleTagHandler(...args) { 9642 Dom.style(element, parseProps(...args)); 9643 }; 9644 } 9645 /** 9646 * Replace all messages identifiers to real messages 9647 * @param sections 9648 * @param substitutions 9649 * @return {string} 9650 */ 9651 }, { 9652 key: "message", 9653 value: function message(sections, ...substitutions) { 9654 return substitutions.reduce((acc, item, index) => acc + Loc.getMessage(item) + sections[index + 1], sections[0]); 9655 } 9656 }, { 9657 key: "attrs", 9658 /** 9659 * Adds attributes to specified element 9660 * @param element 9661 * @return {Function} 9662 */ 9663 value: function attrs(element) { 9664 if (!Type.isDomNode(element)) { 9665 throw new Error('element is not HTMLElement'); 9666 } 9667 return function attrsTagHandler(...args) { 9668 Dom.attr(element, parseProps(...args)); 9669 }; 9670 } 9671 }]); 9672 return Tag; 9673 }(); 9674 babelHelpers.defineProperty(Tag, "render", render); 9675 babelHelpers.defineProperty(Tag, "attr", Tag.attrs); 9676 9677 function getParser(format) { 9678 switch (format) { 9679 case 'index': 9680 return (sourceKey, value, accumulator) => { 9681 const result = /\[(\w*)\]$/.exec(sourceKey); 9682 const key = sourceKey.replace(/\[\w*\]$/, ''); 9683 if (Type.isNil(result)) { 9684 accumulator[key] = value; 9685 return; 9686 } 9687 if (Type.isUndefined(accumulator[key])) { 9688 accumulator[key] = {}; 9689 } 9690 accumulator[key][result[1]] = value; 9691 }; 9692 case 'bracket': 9693 return (sourceKey, value, accumulator) => { 9694 const result = /(\[\])$/.exec(sourceKey); 9695 const key = sourceKey.replace(/\[\]$/, ''); 9696 if (Type.isNil(result)) { 9697 accumulator[key] = value; 9698 return; 9699 } 9700 if (Type.isUndefined(accumulator[key])) { 9701 accumulator[key] = Type.isNil(value) ? [] : [value]; 9702 return; 9703 } 9704 accumulator[key] = [].concat(accumulator[key], value); 9705 }; 9706 default: 9707 return (sourceKey, value, accumulator) => {
9708 const key = sourceKey.replace(/\[\]$/, ''); 9709 accumulator[key] = value; 9710 }; 9711 } 9712 } 9713 function getKeyFormat(key) { 9714 if (/^\w+\[([\w]+)\]$/.test(key)) { 9715 return 'index'; 9716 } 9717 if (/^\w+\[\]$/.test(key)) { 9718 return 'bracket'; 9719 } 9720 return 'default'; 9721 } 9722 function isAllowedKey(key) { 9723 return !String(key).startsWith('__proto__'); 9724 } 9725 function parseQuery(input) { 9726 if (!Type.isString(input)) { 9727 return {}; 9728 } 9729 const url = input.trim().replace(/^[?#&]/, ''); 9730 if (!url) { 9731 return {}; 9732 } 9733 return { 9734 ...url.split('&').reduce((acc, param) => { 9735 const [key, value] = param.replace(/\+/g, ' ').split('='); 9736 if (isAllowedKey(key)) { 9737 const keyFormat = getKeyFormat(key); 9738 const formatter = getParser(keyFormat); 9739 formatter(key, value, acc); 9740 } 9741 return acc; 9742 }, Object.create(null)) 9743 }; 9744 } 9745 const urlExp = /^((\w+):)?(\/\/((\w+)?(:(\w+))?@)?([^\/\?:]+)(:(\d+))?)?(\/?([^\/\?#][^\?#]*)?)?(\?([^#]+))?(#((?:[\w-?/:@.~!$&'()*+,;=]|%\w{2})*))?/; 9746 function prepareParams(params) { 9747 const paramsEntries = Object.entries(params); 9748 return paramsEntries.reduce((acc, [key, value]) => { 9749 if (Type.isNil(value)) { 9750 acc[key] = ''; 9751 } else if (Type.isPlainObject(value)) { 9752 acc[key] = prepareParams(value); 9753 } else { 9754 acc[key] = value; 9755 } 9756 return acc; 9757 }, {}); 9758 } 9759 function parseUrl(url) { 9760 const result = url.match(urlExp); 9761 if (Type.isArray(result)) { 9762 const sourceParams = parseQuery(result[14]); 9763 const preparedParams = prepareParams(sourceParams); 9764 return { 9765 useShort: /^\/\//.test(url), 9766 href: result[0] || '', 9767 schema: result[2] || '', 9768 host: result[8] || '', 9769 port: result[10] || '', 9770 path: result[11] || '', 9771 query: result[14] || '', 9772 sourceQueryParams: sourceParams, 9773 queryParams: preparedParams, 9774 hash: result[16] || '', 9775 username: result[5] || '', 9776 password: result[7] || '', 9777 origin: result[8] || '' 9778 }; 9779 } 9780 return {}; 9781 } 9782 9783 function renderParam(param, value) { 9784 if (Type.isNil(value)) { 9785 return param; 9786 } 9787 return `${param}=${value}`; 9788 } 9789 9790 function buildQueryString(params = {}) { 9791 const queryString = Object.keys(params).reduce((acc, key) => { 9792 if (Type.isArray(params[key])) { 9793 if (Type.isArrayFilled(params[key])) { 9794 params[key].forEach(paramValue => { 9795 acc.push(renderParam(`${key}[]`, paramValue)); 9796 }); 9797 } else { 9798 acc.push(renderParam(`${key}[]`, null)); 9799 } 9800 } 9801 if (Type.isPlainObject(params[key])) { 9802 Object.keys(params[key]).forEach(paramIndex => { 9803 acc.push(renderParam(`${key}[${paramIndex}]`, params[key][paramIndex])); 9804 }); 9805 } 9806 if (!Type.isObject(params[key]) && !Type.isArray(params[key])) { 9807 acc.push(renderParam(key, params[key])); 9808 } 9809 return acc; 9810 }, []).join('&'); 9811 if (queryString.length > 0) { 9812 return `?${queryString}`; 9813 } 9814 return queryString; 9815 } 9816 9817 function prepareParamValue(value) { 9818 if (Type.isArray(value)) { 9819 return value.map(item => String(item)); 9820 } 9821 if (Type.isPlainObject(value)) { 9822 return { 9823 ...value 9824 }; 9825 } 9826 return String(value); 9827 } 9828 9829 const map = new WeakMap(); 9830 9831 /** 9832 * Implements interface for works with URI 9833 * @memberOf BX 9834 */ 9835 let Uri = /*#__PURE__*/function () { 9836 babelHelpers.createClass(Uri, null, [{ 9837 key: "addParam", 9838 value: function addParam(url, params = {}) { 9839 return new Uri(url).setQueryParams(params).toString(); 9840 } 9841 }, { 9842 key: "removeParam", 9843 value: function removeParam(url, params) { 9844 const removableParams = Type.isArray(params) ? params : [params]; 9845 return new Uri(url).removeQueryParam(...removableParams).toString(); 9846 } 9847 }]); 9848 function Uri(url = '') { 9849 babelHelpers.classCallCheck(this, Uri); 9850 map.set(this, parseUrl(url)); 9851 } 9852 babelHelpers.createClass(Uri, [{ 9853 key: "getSchema", 9854 value: function getSchema() { 9855 return map.get(this).schema; 9856 } 9857 }, { 9858 key: "setSchema", 9859 value: function setSchema(schema) { 9860 map.get(this).schema = String(schema); 9861 return this; 9862 } 9863 }, { 9864 key: "getHost", 9865 value: function getHost() { 9866 return map.get(this).host; 9867 } 9868 }, { 9869 key: "setHost", 9870 value: function setHost(host) { 9871 map.get(this).host = String(host); 9872 return this; 9873 } 9874 }, { 9875 key: "getPort", 9876 value: function getPort() { 9877 return map.get(this).port; 9878 } 9879 }, { 9880 key: "setPort", 9881 value: function setPort(port) { 9882 map.get(this).port = String(port); 9883 return this; 9884 } 9885 }, { 9886 key: "getPath", 9887 value: function getPath() { 9888 return map.get(this).path; 9889 } 9890 }, { 9891 key: "setPath", 9892 value: function setPath(path) { 9893 if (!/^\//.test(path)) {
9894 map.get(this).path = `/${String(path)}`; 9895 return this; 9896 } 9897 map.get(this).path = String(path); 9898 return this; 9899 } 9900 }, { 9901 key: "getQuery", 9902 value: function getQuery() { 9903 return buildQueryString(map.get(this).queryParams); 9904 } 9905 }, { 9906 key: "getQueryParam", 9907 value: function getQueryParam(key) { 9908 const params = this.getQueryParams(); 9909 if (Object.hasOwn(params, key)) { 9910 return params[key]; 9911 } 9912 return null; 9913 } 9914 }, { 9915 key: "setQueryParam", 9916 value: function setQueryParam(key, value = '') { 9917 map.get(this).queryParams[key] = prepareParamValue(value); 9918 map.get(this).sourceQueryParams[key] = prepareParamValue(value); 9919 return this; 9920 } 9921 }, { 9922 key: "getQueryParams", 9923 value: function getQueryParams() { 9924 return { 9925 ...map.get(this).queryParams 9926 }; 9927 } 9928 }, { 9929 key: "setQueryParams", 9930 value: function setQueryParams(params = {}) { 9931 if (Type.isPlainObject(params)) { 9932 const { 9933 queryParams, 9934 sourceQueryParams 9935 } = map.get(this); 9936 Object.entries(params).forEach(([key, value]) => { 9937 const preparedValue = prepareParamValue(value); 9938 queryParams[key] = preparedValue; 9939 sourceQueryParams[key] = preparedValue; 9940 }); 9941 } 9942 return this; 9943 } 9944 }, { 9945 key: "removeQueryParam", 9946 value: function removeQueryParam(...keys) { 9947 const { 9948 queryParams, 9949 sourceQueryParams 9950 } = map.get(this); 9951 keys.forEach(key => { 9952 delete queryParams[key]; 9953 delete sourceQueryParams[key]; 9954 }); 9955 return this; 9956 } 9957 }, { 9958 key: "getFragment", 9959 value: function getFragment() { 9960 return map.get(this).hash; 9961 } 9962 }, { 9963 key: "setFragment", 9964 value: function setFragment(hash) { 9965 map.get(this).hash = String(hash); 9966 return this; 9967 } 9968 }, { 9969 key: "serialize", 9970 value: function serialize() { 9971 const serialized = { 9972 ...map.get(this) 9973 }; 9974 delete serialized.sourceQueryParams; 9975 serialized.href = this.toString(); 9976 return serialized; 9977 } 9978 }, { 9979 key: "toString", 9980 value: function toString() { 9981 const data = { 9982 ...map.get(this) 9983 }; 9984 let protocol = data.schema ? `${data.schema}://` : ''; 9985 if (data.useShort) { 9986 protocol = '//'; 9987 } 9988 const port = (() => { 9989 if (Type.isString(data.port) && !['', '80'].includes(data.port)) { 9990 return `:${data.port}`; 9991 } 9992 return ''; 9993 })(); 9994 const host = this.getHost(); 9995 const path = this.getPath(); 9996 const query = buildQueryString(data.sourceQueryParams); 9997 const hash = data.hash ? `#${data.hash}` : ''; 9998 return `${host ? protocol : ''}${host}${host ? port : ''}${path}${query}${hash}`; 9999 } 10000 }]); 10001 return Uri; 10002 }(); 10003 10004 /** 10005 * @memberOf BX 10006 */ 10007 let Validation = /*#__PURE__*/function () { 10008 function Validation() { 10009 babelHelpers.classCallCheck(this, Validation); 10010 } 10011 babelHelpers.createClass(Validation, null, [{ 10012 key: "isEmail", 10013 /** 10014 * Checks that value is valid email 10015 * @param value 10016 * @return {boolean} 10017 */ 10018 value: function isEmail(value) { 10019 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])?)*$/; 10020 return exp.test(String(value).toLowerCase()); 10021 } 10022 }]); 10023 return Validation; 10024 }(); 10025 10026 let BaseCache = /*#__PURE__*/function () { 10027 function BaseCache() { 10028 babelHelpers.classCallCheck(this, BaseCache); 10029 babelHelpers.defineProperty(this, "storage", new Map()); 10030 } 10031 babelHelpers.createClass(BaseCache, [{ 10032 key: "get", 10033 /** 10034 * Gets cached value or default value 10035 */ 10036 value: function get(key, defaultValue) { 10037 if (!this.storage.has(key)) { 10038 if (Type.isFunction(defaultValue)) { 10039 return defaultValue(); 10040 } 10041 if (!Type.isUndefined(defaultValue)) { 10042 return defaultValue; 10043 } 10044 } 10045 return this.storage.get(key); 10046 } 10047 /**
10048 * Sets cache entry 10049 */ 10050 }, { 10051 key: "set", 10052 value: function set(key, value) { 10053 this.storage.set(key, value); 10054 } 10055 /** 10056 * Deletes cache entry 10057 */ 10058 }, { 10059 key: "delete", 10060 value: function _delete(key) { 10061 this.storage.delete(key); 10062 } 10063 /** 10064 * Checks that storage contains entry with specified key 10065 */ 10066 }, { 10067 key: "has", 10068 value: function has(key) { 10069 return this.storage.has(key); 10070 } 10071 /** 10072 * Gets cached value if exists, 10073 */ 10074 }, { 10075 key: "remember", 10076 value: function remember(key, defaultValue) { 10077 if (!this.storage.has(key)) { 10078 if (Type.isFunction(defaultValue)) { 10079 this.storage.set(key, defaultValue()); 10080 } else if (!Type.isUndefined(defaultValue)) { 10081 this.storage.set(key, defaultValue); 10082 } 10083 } 10084 return this.storage.get(key); 10085 } 10086 /** 10087 * Gets storage size 10088 */ 10089 }, { 10090 key: "size", 10091 value: function size() { 10092 return this.storage.size; 10093 } 10094 /** 10095 * Gets storage keys 10096 */ 10097 }, { 10098 key: "keys", 10099 value: function keys() { 10100 return [...this.storage.keys()]; 10101 } 10102 /** 10103 * Gets storage values 10104 */ 10105 }, { 10106 key: "values", 10107 value: function values() { 10108 return [...this.storage.values()]; 10109 } 10110 }]); 10111 return BaseCache; 10112 }(); 10113 10114 let MemoryCache = /*#__PURE__*/function (_BaseCache) { 10115 babelHelpers.inherits(MemoryCache, _BaseCache); 10116 function MemoryCache(...args) { 10117 var _this; 10118 babelHelpers.classCallCheck(this, MemoryCache); 10119 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(MemoryCache).call(this, ...args)); 10120 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "storage", new Map()); 10121 return _this; 10122 } 10123 return MemoryCache; 10124 }(BaseCache); 10125 10126 let LsStorage = /*#__PURE__*/function () { 10127 function LsStorage() { 10128 babelHelpers.classCallCheck(this, LsStorage); 10129 babelHelpers.defineProperty(this, "stackKey", 'BX.Cache.Storage.LsStorage.stack'); 10130 babelHelpers.defineProperty(this, "stack", null); 10131 } 10132 babelHelpers.createClass(LsStorage, [{ 10133 key: "getStack", 10134 /** 10135 * @private 10136 */ 10137 value: function getStack() { 10138 if (Type.isPlainObject(this.stack)) { 10139 return this.stack; 10140 } 10141 const stack = localStorage.getItem(this.stackKey); 10142 if (Type.isString(stack) && stack !== '') { 10143 const parsedStack = JSON.parse(stack); 10144 if (Type.isPlainObject(parsedStack)) { 10145 this.stack = parsedStack; 10146 return this.stack; 10147 } 10148 } 10149 this.stack = {}; 10150 return this.stack; 10151 } 10152 /** 10153 * @private 10154 */ 10155 }, { 10156 key: "saveStack", 10157 value: function saveStack() { 10158 if (Type.isPlainObject(this.stack)) { 10159 const preparedStack = JSON.stringify(this.stack); 10160 localStorage.setItem(this.stackKey, preparedStack); 10161 } 10162 } 10163 }, { 10164 key: "get", 10165 value: function get(key) { 10166 const stack = this.getStack(); 10167 return stack[key]; 10168 } 10169 }, { 10170 key: "set", 10171 value: function set(key, value) { 10172 const stack = this.getStack(); 10173 stack[key] = value; 10174 this.saveStack(); 10175 } 10176 }, { 10177 key: "delete", 10178 value: function _delete(key) { 10179 const stack = this.getStack(); 10180 if (key in stack) { 10181 delete stack[key]; 10182 } 10183 } 10184 }, { 10185 key: "has", 10186 value: function has(key) { 10187 const stack = this.getStack(); 10188 return key in stack; 10189 } 10190 }, { 10191 key: "keys", 10192 value: function keys() { 10193 const stack = this.getStack(); 10194 return Object.keys(stack); 10195 } 10196 }, { 10197 key: "values", 10198 value: function values() { 10199 const stack = this.getStack(); 10200 return Object.values(stack); 10201 } 10202 }, { 10203 key: "size", 10204 get: function () { 10205 const stack = this.getStack(); 10206 return Object.keys(stack).length; 10207 } 10208 }]); 10209 return LsStorage; 10210 }(); 10211 10212 let LocalStorageCache = /*#__PURE__*/function (_BaseCache) { 10213 babelHelpers.inherits(LocalStorageCache, _BaseCache); 10214 function LocalStorageCache(...args) { 10215 var _this; 10216 babelHelpers.classCallCheck(this, LocalStorageCache); 10217 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(LocalStorageCache).call(this, ...args)); 10218 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "storage", new LsStorage()); 10219 return _this; 10220 } 10221 return LocalStorageCache; 10222 }(BaseCache); 10223 10224 /** 10225 * @memberOf BX 10226 */ 10227 let Cache = function Cache() { 10228 babelHelpers.classCallCheck(this, Cache); 10229 }; 10230 babelHelpers.defineProperty(Cache, "BaseCache", BaseCache); 10231 babelHelpers.defineProperty(Cache, "MemoryCache", MemoryCache); 10232 babelHelpers.defineProperty(Cache, "LocalStorageCache", LocalStorageCache); 10233 10234 function convertPath(path) { 10235 if (Type.isStringFilled(path)) { 10236 return path.split('.').reduce((acc, item) => { 10237 item.split(/\[['"]?(.+?)['"]?\]/g).forEach(key => { 10238 if (Type.isStringFilled(key)) { 10239 acc.push(key); 10240 } 10241 }); 10242 return acc; 10243 }, []); 10244 } 10245 return []; 10246 } 10247 10248 let SettingsCollection = /*#__PURE__*/function () { 10249 function SettingsCollection(options = {}) { 10250 babelHelpers.classCallCheck(this, SettingsCollection); 10251 if (Type.isPlainObject(options)) { 10252 Object.assign(this, options); 10253 } 10254 } 10255 babelHelpers.createClass(SettingsCollection, [{ 10256 key: "get", 10257 value: function get(path, defaultValue = null) { 10258 const convertedPath = convertPath(path); 10259 return convertedPath.reduce((acc, key) => { 10260 if (!Type.isNil(acc) && acc !== defaultValue) { 10261 if (!Type.isUndefined(acc[key])) { 10262 return acc[key]; 10263 } 10264 return defaultValue; 10265 } 10266 return acc; 10267 }, this); 10268 } 10269 }]); 10270 return SettingsCollection; 10271 }(); 10272 10273 function deepFreeze(target) { 10274 if (Type.isObject(target)) { 10275 Object.values(target).forEach(value => { 10276 deepFreeze(value); 10277 }); 10278 return Object.freeze(target); 10279 } 10280 return target; 10281 } 10282 10283 const settingsStorage = new Map(); 10284 let Extension$1 = /*#__PURE__*/function () { 10285 function Extension() { 10286 babelHelpers.classCallCheck(this, Extension); 10287 } 10288 babelHelpers.createClass(Extension, null, [{ 10289 key: "getSettings", 10290 value: function getSettings(extensionName) { 10291 if (Type.isStringFilled(extensionName)) { 10292 if (settingsStorage.has(extensionName)) { 10293 return settingsStorage.get(extensionName); 10294 } 10295 const settingsScriptNode = document.querySelector(`script[data-extension="${extensionName}"]`); 10296 if (Type.isDomNode(settingsScriptNode)) { 10297 const decodedSettings = (() => { 10298 try { 10299 return new SettingsCollection(JSON.parse(settingsScriptNode.innerHTML)); 10300 } catch (error) { 10301 return new SettingsCollection(); 10302 } 10303 })(); 10304 const frozenSettings = deepFreeze(decodedSettings); 10305 settingsStorage.set(extensionName, frozenSettings); 10306 return frozenSettings; 10307 } 10308 } 10309 return deepFreeze(new SettingsCollection()); 10310 } 10311 }]); 10312 return Extension; 10313 }(); 10314 10315 let _Symbol$iterator; 10316 function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration$1(obj, privateSet); privateSet.add(obj); } 10317 function _checkPrivateRedeclaration$1(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } } 10318 function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; } 10319 var _searchIndexToInsert = /*#__PURE__*/new WeakSet(); 10320 _Symbol$iterator = Symbol.iterator; 10321 let OrderedArray = /*#__PURE__*/function () { 10322 function OrderedArray(comparator = null) { 10323 babelHelpers.classCallCheck(this, OrderedArray); 10324 _classPrivateMethodInitSpec(this, _searchIndexToInsert); 10325 babelHelpers.defineProperty(this, "comparator", null); 10326 babelHelpers.defineProperty(this, "items", []); 10327 this.comparator = Type.isFunction(comparator) ? comparator : null; 10328 } 10329 babelHelpers.createClass(OrderedArray, [{ 10330 key: "add", 10331 value: function add(item) { 10332 let index = -1; 10333 if (this.comparator) { 10334 index = _classPrivateMethodGet(this, _searchIndexToInsert, _searchIndexToInsert2).call(this, item); 10335 this.items.splice(index, 0, item); 10336 } else { 10337 this.items.push(item); 10338 } 10339 return index; 10340 } 10341 }, { 10342 key: "has", 10343 value: function has(item) { 10344 return this.items.includes(item); 10345 } 10346 }, { 10347 key: "getIndex", 10348 value: function getIndex(item) { 10349 return this.items.indexOf(item); 10350 } 10351 }, { 10352 key: "getByIndex", 10353 value: function getByIndex(index) { 10354 if (Type.isNumber(index) && index >= 0) { 10355 const item = this.items[index]; 10356 return Type.isUndefined(item) ? null : item; 10357 } 10358 return null; 10359 } 10360 }, { 10361 key: "getFirst", 10362 value: function getFirst() { 10363 const first = this.items[0]; 10364 return Type.isUndefined(first) ? null : first; 10365 } 10366 }, { 10367 key: "getLast", 10368 value: function getLast() { 10369 const last = this.items[this.count() - 1]; 10370 return Type.isUndefined(last) ? null : last; 10371 } 10372 }, { 10373 key: "count", 10374 value: function count() { 10375 return this.items.length; 10376 } 10377 }, { 10378 key: "delete", 10379 value: function _delete(item) { 10380 const index = this.getIndex(item); 10381 if (index !== -1) { 10382 this.items.splice(index, 1); 10383 return true; 10384 } 10385 return false;
10386 } 10387 }, { 10388 key: "clear", 10389 value: function clear() { 10390 this.items = []; 10391 } 10392 }, { 10393 key: _Symbol$iterator, 10394 value: function () { 10395 return this.items[Symbol.iterator](); 10396 } 10397 }, { 10398 key: "forEach", 10399 value: function forEach(callbackfn, thisArg) { 10400 return this.items.forEach(callbackfn, thisArg); 10401 } 10402 }, { 10403 key: "getAll", 10404 value: function getAll() { 10405 return this.items; 10406 } 10407 }, { 10408 key: "getComparator", 10409 value: function getComparator() { 10410 return this.comparator; 10411 } 10412 }, { 10413 key: "sort", 10414 value: function sort() { 10415 const comparator = this.getComparator(); 10416 if (comparator === null) { 10417 return; 10418 } 10419 10420 /* 10421 Simple implementation 10422 this.items.sort((item1, item2) => { 10423 return comparator(item1, item2); 10424 }); 10425 */ 10426 10427 // For stable sorting https://v8.dev/features/stable-sort 10428 const length = this.items.length; 10429 const indexes = new Array(length); 10430 for (let i = 0; i < length; i++) { 10431 indexes[i] = i; 10432 } 10433 10434 // If the comparator returns zero, use the original indexes 10435 indexes.sort((index1, index2) => { 10436 return comparator(this.items[index1], this.items[index2]) || index1 - index2; 10437 }); 10438 for (let i = 0; i < length; i++) { 10439 indexes[i] = this.items[indexes[i]]; 10440 } 10441 for (let i = 0; i < length; i++) { 10442 this.items[i] = indexes[i]; 10443 } 10444 } 10445 }]); 10446 return OrderedArray; 10447 }(); 10448 function _searchIndexToInsert2(value) { 10449 let low = 0; 10450 let high = this.items.length; 10451 while (low < high) { 10452 const mid = Math.floor((low + high) / 2); 10453 if (this.comparator(this.items[mid], value) >= 0) { 10454 high = mid; 10455 } else { 10456 low = mid + 1; 10457 } 10458 } 10459 return low; 10460 } 10461 10462 let ZIndexComponent = /*#__PURE__*/function (_EventEmitter) { 10463 babelHelpers.inherits(ZIndexComponent, _EventEmitter); 10464 function ZIndexComponent(element, componentOptions = {}) { 10465 var _this; 10466 babelHelpers.classCallCheck(this, ZIndexComponent); 10467 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(ZIndexComponent).call(this)); 10468 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "sort", 0); 10469 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "alwaysOnTop", false); 10470 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "zIndex", 0); 10471 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "element", null); 10472 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "overlay", null); 10473 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "overlayGap", -5); 10474 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "stack", null); 10475 _this.setEventNamespace('BX.Main.ZIndexManager.Component'); 10476 if (!Type.isElementNode(element)) { 10477 throw new Error('ZIndexManager.Component: The argument \'element\' must be a DOM element.'); 10478 } 10479 _this.element = element; 10480 const options = Type.isPlainObject(componentOptions) ? componentOptions : {}; 10481 _this.setAlwaysOnTop(options.alwaysOnTop); 10482 _this.setOverlay(options.overlay); 10483 _this.setOverlayGap(options.overlayGap); 10484 _this.subscribeFromOptions(options.events); 10485 return _this; 10486 } 10487 babelHelpers.createClass(ZIndexComponent, [{ 10488 key: "getSort", 10489 value: function getSort() { 10490 return this.sort; 10491 } 10492 /** 10493 * @internal 10494 * @param sort 10495 */ 10496 }, { 10497 key: "setSort", 10498 value: function setSort(sort) { 10499 if (Type.isNumber(sort)) { 10500 this.sort = sort; 10501 } 10502 } 10503 /** 10504 * @internal 10505 * @param stack 10506 */ 10507 }, { 10508 key: "setStack", 10509 value: function setStack(stack) { 10510 this.stack = stack; 10511 } 10512 }, { 10513 key: "getStack", 10514 value: function getStack() { 10515 return this.stack; 10516 } 10517 }, { 10518 key: "getZIndex", 10519 value: function getZIndex() { 10520 return this.zIndex; 10521 } 10522 /** 10523 * @internal 10524 */ 10525 }, { 10526 key: "setZIndex", 10527 value: function setZIndex(zIndex) { 10528 const changed = this.getZIndex() !== zIndex; 10529 this.getElement().style.setProperty('z-index', zIndex, 'important'); 10530 this.zIndex = zIndex; 10531 if (this.getOverlay() !== null) { 10532 this.getOverlay().style.setProperty('z-index', zIndex + this.getOverlayGap(), 'important'); 10533 } 10534 if (changed) {
10535 this.emit('onZIndexChange', { 10536 component: this 10537 }); 10538 } 10539 } 10540 }, { 10541 key: "getAlwaysOnTop", 10542 value: function getAlwaysOnTop() { 10543 return this.alwaysOnTop; 10544 } 10545 }, { 10546 key: "setAlwaysOnTop", 10547 value: function setAlwaysOnTop(value) { 10548 if (Type.isNumber(value) || Type.isBoolean(value)) { 10549 this.alwaysOnTop = value; 10550 } 10551 } 10552 }, { 10553 key: "getElement", 10554 value: function getElement() { 10555 return this.element; 10556 } 10557 }, { 10558 key: "setOverlay", 10559 value: function setOverlay(overlay, gap) { 10560 if (Type.isElementNode(overlay) || overlay === null) { 10561 this.overlay = overlay; 10562 this.setOverlayGap(gap); 10563 if (this.getStack()) { 10564 this.getStack().sort(); 10565 } 10566 } 10567 } 10568 }, { 10569 key: "getOverlay", 10570 value: function getOverlay() { 10571 return this.overlay; 10572 } 10573 }, { 10574 key: "setOverlayGap", 10575 value: function setOverlayGap(gap) { 10576 if (Type.isNumber(gap)) { 10577 this.overlayGap = gap; 10578 } 10579 } 10580 }, { 10581 key: "getOverlayGap", 10582 value: function getOverlayGap() { 10583 return this.overlayGap; 10584 } 10585 }]); 10586 return ZIndexComponent; 10587 }(EventEmitter); 10588 10589 let ZIndexStack = /*#__PURE__*/function () { 10590 function ZIndexStack(container) { 10591 babelHelpers.classCallCheck(this, ZIndexStack); 10592 babelHelpers.defineProperty(this, "container", null); 10593 babelHelpers.defineProperty(this, "components", null); 10594 babelHelpers.defineProperty(this, "elements", new WeakMap()); 10595 babelHelpers.defineProperty(this, "baseIndex", 1000); 10596 babelHelpers.defineProperty(this, "baseStep", 50); 10597 babelHelpers.defineProperty(this, "sortCount", 0); 10598 if (!Type.isDomNode(container)) { 10599 throw new Error('ZIndexManager.Stack: The \'container\' argument must be a DOM element.'); 10600 } 10601 this.container = container; 10602 const comparator = (componentA, componentB) => { 10603 let result = (componentA.getAlwaysOnTop() || 0) - (componentB.getAlwaysOnTop() || 0); 10604 if (!result) { 10605 result = componentA.getSort() - componentB.getSort(); 10606 } 10607 return result; 10608 }; 10609 this.components = new OrderedArray(comparator); 10610 } 10611 babelHelpers.createClass(ZIndexStack, [{ 10612 key: "getBaseIndex", 10613 value: function getBaseIndex() { 10614 return this.baseIndex; 10615 } 10616 }, { 10617 key: "setBaseIndex", 10618 value: function setBaseIndex(index) { 10619 if (Type.isNumber(index) && index >= 0) { 10620 this.baseIndex = index; 10621 this.sort(); 10622 } 10623 } 10624 }, { 10625 key: "setBaseStep", 10626 value: function setBaseStep(step) { 10627 if (Type.isNumber(step) && step > 0) { 10628 this.baseStep = step; 10629 this.sort(); 10630 } 10631 } 10632 }, { 10633 key: "getBaseStep", 10634 value: function getBaseStep() { 10635 return this.baseStep; 10636 } 10637 }, { 10638 key: "register", 10639 value: function register(element, options = {}) { 10640 if (this.getComponent(element)) { 10641 console.warn('ZIndexManager: You cannot register the element twice.', element); 10642 return this.getComponent(element); 10643 } 10644 const component = new ZIndexComponent(element, options); 10645 component.setStack(this); 10646 component.setSort(++this.sortCount); 10647 this.elements.set(element, component); 10648 this.components.add(component); 10649 this.sort(); 10650 return component; 10651 } 10652 }, { 10653 key: "unregister", 10654 value: function unregister(element) { 10655 const component = this.elements.get(element); 10656 this.components.delete(component); 10657 this.elements.delete(element); 10658 this.sort(); 10659 } 10660 }, { 10661 key: "getComponent", 10662 value: function getComponent(element) { 10663 return this.elements.get(element) || null; 10664 } 10665 }, { 10666 key: "getComponents", 10667 value: function getComponents() { 10668 return this.components.getAll(); 10669 } 10670 }, { 10671 key: "getMaxZIndex", 10672 value: function getMaxZIndex() { 10673 const last = this.components.getLast(); 10674 return last ? last.getZIndex() : this.baseIndex; 10675 } 10676 }, { 10677 key: "sort", 10678 value: function sort() { 10679 this.components.sort(); 10680 let zIndex = this.baseIndex;
10681 this.components.forEach(component => { 10682 component.setZIndex(zIndex); 10683 zIndex += this.baseStep; 10684 }); 10685 } 10686 }, { 10687 key: "bringToFront", 10688 value: function bringToFront(element) { 10689 const component = this.getComponent(element); 10690 if (!component) { 10691 console.error('ZIndexManager: element was not found in the stack.', element); 10692 return null; 10693 } 10694 component.setSort(++this.sortCount); 10695 this.sort(); 10696 return component; 10697 } 10698 }]); 10699 return ZIndexStack; 10700 }(); 10701 10702 function _classStaticPrivateMethodGet(receiver, classConstructor, method) { _classCheckPrivateStaticAccess(receiver, classConstructor); return method; } 10703 function _classCheckPrivateStaticAccess(receiver, classConstructor) { if (receiver !== classConstructor) { throw new TypeError("Private static access of wrong provenance"); } } 10704 /** 10705 * @memberof BX 10706 */ 10707 let ZIndexManager = /*#__PURE__*/function () { 10708 function ZIndexManager() { 10709 babelHelpers.classCallCheck(this, ZIndexManager); 10710 } 10711 babelHelpers.createClass(ZIndexManager, null, [{ 10712 key: "register", 10713 value: function register(element, options = {}) { 10714 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element); 10715 if (!parentNode) { 10716 return null; 10717 } 10718 const stack = this.getOrAddStack(parentNode); 10719 return stack.register(element, options); 10720 } 10721 }, { 10722 key: "unregister", 10723 value: function unregister(element) { 10724 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element); 10725 const stack = this.getStack(parentNode); 10726 if (stack) { 10727 stack.unregister(element); 10728 } 10729 } 10730 }, { 10731 key: "addStack", 10732 value: function addStack(container) { 10733 const stack = new ZIndexStack(container); 10734 this.stacks.set(container, stack); 10735 return stack; 10736 } 10737 }, { 10738 key: "getStack", 10739 value: function getStack(container) { 10740 return this.stacks.get(container) || null; 10741 } 10742 }, { 10743 key: "getOrAddStack", 10744 value: function getOrAddStack(container) { 10745 return this.getStack(container) || this.addStack(container); 10746 } 10747 }, { 10748 key: "getComponent", 10749 value: function getComponent(element) { 10750 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element, true); 10751 if (!parentNode) { 10752 return null; 10753 } 10754 const stack = this.getStack(parentNode); 10755 return stack ? stack.getComponent(element) : null; 10756 } 10757 }, { 10758 key: "bringToFront", 10759 value: function bringToFront(element) { 10760 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element); 10761 const stack = this.getStack(parentNode); 10762 if (stack) { 10763 return stack.bringToFront(element); 10764 } 10765 return null; 10766 } 10767 }]); 10768 return ZIndexManager; 10769 }(); 10770 function _getParentNode(element, suppressWarnings = false) { 10771 if (!Type.isElementNode(element)) { 10772 if (!suppressWarnings) { 10773 console.error('ZIndexManager: The argument \'element\' must be a DOM element.', element); 10774 } 10775 return null; 10776 } else if (!Type.isElementNode(element.parentNode)) { 10777 if (!suppressWarnings) { 10778 console.error('ZIndexManager: The \'element\' doesn\'t have a parent node.', element); 10779 } 10780 return null; 10781 } 10782 return element.parentNode; 10783 } 10784 babelHelpers.defineProperty(ZIndexManager, "stacks", new WeakMap()); 10785 10786 function _classPrivateMethodInitSpec$1(obj, privateSet) { _checkPrivateRedeclaration$2(obj, privateSet); privateSet.add(obj); } 10787 function _classPrivateFieldInitSpec$1(obj, privateMap, value) { _checkPrivateRedeclaration$2(obj, privateMap); privateMap.set(obj, value); } 10788 function _checkPrivateRedeclaration$2(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } } 10789 function _classPrivateMethodGet$1(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; } 10790 10791 // eslint-disable-next-line @bitrix24/bitrix24-rules/no-typeof 10792 const IS_WEAK_REF_SUPPORTED = typeof WeakRef !== 'undefined'; 10793 var _refs = /*#__PURE__*/new WeakMap(); 10794 var _registry = /*#__PURE__*/new WeakMap(); 10795 var _cleanupCallback = /*#__PURE__*/new WeakSet(); 10796 let WeakRefMap = /*#__PURE__*/function () { 10797 function WeakRefMap() { 10798 babelHelpers.classCallCheck(this, WeakRefMap); 10799 _classPrivateMethodInitSpec$1(this, _cleanupCallback); 10800 _classPrivateFieldInitSpec$1(this, _refs, { 10801 writable: true, 10802 value: new Map() 10803 }); 10804 _classPrivateFieldInitSpec$1(this, _registry, { 10805 writable: true, 10806 value: null 10807 }); 10808 if (IS_WEAK_REF_SUPPORTED) { 10809 babelHelpers.classPrivateFieldSet(this, _registry, new FinalizationRegistry(_classPrivateMethodGet$1(this, _cleanupCallback, _cleanupCallback2).bind(this))); 10810 } 10811 } 10812 babelHelpers.createClass(WeakRefMap, [{ 10813 key: "clear", 10814 value: function clear() { 10815 if (!IS_WEAK_REF_SUPPORTED) { 10816 babelHelpers.classPrivateFieldGet(this, _refs).clear(); 10817 return; 10818 }
10819 babelHelpers.classPrivateFieldGet(this, _refs).forEach((ref, key) => { 10820 const value = ref === null || ref === void 0 ? void 0 : ref.deref(); 10821 if (!Type.isUndefined(value)) { 10822 babelHelpers.classPrivateFieldGet(this, _registry).unregister(value); 10823 } 10824 }); 10825 babelHelpers.classPrivateFieldGet(this, _refs).clear(); 10826 } 10827 }, { 10828 key: "delete", 10829 value: function _delete(key) { 10830 if (!IS_WEAK_REF_SUPPORTED) { 10831 return babelHelpers.classPrivateFieldGet(this, _refs).delete(key); 10832 } 10833 const value = this.get(key); 10834 if (!Type.isUndefined(value)) { 10835 babelHelpers.classPrivateFieldGet(this, _registry).unregister(value); 10836 } 10837 return babelHelpers.classPrivateFieldGet(this, _refs).delete(key); 10838 } 10839 }, { 10840 key: "get", 10841 value: function get(key) { 10842 var _babelHelpers$classPr; 10843 if (!IS_WEAK_REF_SUPPORTED) { 10844 return babelHelpers.classPrivateFieldGet(this, _refs).get(key); 10845 } 10846 return (_babelHelpers$classPr = babelHelpers.classPrivateFieldGet(this, _refs).get(key)) === null || _babelHelpers$classPr === void 0 ? void 0 : _babelHelpers$classPr.deref(); 10847 } 10848 }, { 10849 key: "has", 10850 value: function has(key) { 10851 var _babelHelpers$classPr2; 10852 if (!IS_WEAK_REF_SUPPORTED) { 10853 return babelHelpers.classPrivateFieldGet(this, _refs).has(key); 10854 } 10855 return !Type.isUndefined((_babelHelpers$classPr2 = babelHelpers.classPrivateFieldGet(this, _refs).get(key)) === null || _babelHelpers$classPr2 === void 0 ? void 0 : _babelHelpers$classPr2.deref()); 10856 } 10857 }, { 10858 key: "set", 10859 value: function set(key, value) { 10860 if (!IS_WEAK_REF_SUPPORTED) { 10861 babelHelpers.classPrivateFieldGet(this, _refs).set(key, value); 10862 return this; 10863 } 10864 babelHelpers.classPrivateFieldGet(this, _refs).set(key, new WeakRef(value)); 10865 babelHelpers.classPrivateFieldGet(this, _registry).register(value, key, value); 10866 return this; 10867 } 10868 }]); 10869 return WeakRefMap; 10870 }(); 10871 function _cleanupCallback2(key) { 10872 const ref = babelHelpers.classPrivateFieldGet(this, _refs).get(key); 10873 if (ref && !ref.deref()) { 10874 babelHelpers.classPrivateFieldGet(this, _refs).delete(key); 10875 } 10876 } 10877 10878 var collections = { 10879 OrderedArray, 10880 SettingsCollection, 10881 WeakRefMap 10882 }; 10883 10884 function getElement(element) { 10885 if (Type.isString(element)) { 10886 return document.getElementById(element); 10887 } 10888 return element; 10889 } 10890 10891 function getWindow(element) { 10892 if (Type.isElementNode(element)) { 10893 return element.ownerDocument.parentWindow || element.ownerDocument.defaultView || window; 10894 } 10895 if (Type.isDomNode(element)) { 10896 return element.parentWindow || element.defaultView || window; 10897 } 10898 return window; 10899 } 10900 10901 /* eslint-disable prefer-rest-params */ 10902 10903 // BX.* 10904 const { 10905 getClass, 10906 namespace 10907 } = Reflection; 10908 const message$1 = message; 10909 10910 /** 10911 * @memberOf BX 10912 */ 10913 const { 10914 replace, 10915 remove, 10916 clean, 10917 insertBefore, 10918 insertAfter, 10919 append, 10920 prepend, 10921 style, 10922 adjust, 10923 create, 10924 isShown 10925 } = Dom; 10926 const addClass = function addClass() { 10927 Dom.addClass(...Runtime.merge([], Array.from(arguments), [getElement(arguments[0])])); 10928 }; 10929 const removeClass = function removeClass() { 10930 Dom.removeClass(...Runtime.merge(Array.from(arguments), [getElement(arguments[0])])); 10931 }; 10932 const hasClass = function hasClass() { 10933 return Dom.hasClass(...Runtime.merge(Array.from(arguments), [getElement(arguments[0])])); 10934 }; 10935 const toggleClass = function toggleClass() { 10936 Dom.toggleClass(...Runtime.merge(Array.from(arguments), [getElement(arguments[0])])); 10937 }; 10938 const cleanNode = (element, removeElement = false) => { 10939 const currentElement = getElement(element); 10940 if (Type.isDomNode(currentElement)) { 10941 Dom.clean(currentElement); 10942 if (removeElement) { 10943 Dom.remove(currentElement); 10944 return currentElement; 10945 } 10946 } 10947 return currentElement; 10948 }; 10949 const getCookie = Http.Cookie.get; 10950 const setCookie = (name, value, options = {}) => { 10951 const attributes = { 10952 ...options 10953 }; 10954 if (Type.isNumber(attributes.expires)) { 10955 attributes.expires /= 3600 * 24; 10956 } 10957 Http.Cookie.set(name, value, attributes); 10958 }; 10959 const { 10960 bind: bind$1, 10961 unbind: unbind$1, 10962 unbindAll: unbindAll$1, 10963 bindOnce: bindOnce$1, 10964 ready: ready$1 10965 } = Event; 10966 const { 10967 debugState: debugEnableFlag, 10968 isDebugEnabled: debugStatus, 10969 default: debug$1 10970 }
10970 = debugNs; 10971 const debugEnable = value => { 10972 if (value) { 10973 enableDebug(); 10974 } else { 10975 disableDebug(); 10976 } 10977 }; 10978 const { 10979 clone: clone$1, 10980 loadExtension: loadExt, 10981 debounce, 10982 throttle, 10983 html 10984 } = Runtime; 10985 10986 // BX.type 10987 const type = { 10988 ...Object.getOwnPropertyNames(Type).filter(key => !['name', 'length', 'prototype', 'caller', 'arguments'].includes(key)).reduce((acc, key) => { 10989 acc[key] = Type[key]; 10990 return acc; 10991 }, {}), 10992 isNotEmptyString: value => Type.isString(value) && value !== '', 10993 isNotEmptyObject: value => Type.isObjectLike(value) && Object.keys(value).length > 0, 10994 isMapKey: Type.isObject, 10995 stringToInt: value => { 10996 const parsed = parseInt(value); 10997 return !Number.isNaN(parsed) ? parsed : 0; 10998 } 10999 }; 11000 11001 // BX.browser 11002 const browser = { 11003 IsOpera: Browser.isOpera, 11004 IsIE: Browser.isIE, 11005 IsIE6: Browser.isIE6, 11006 IsIE7: Browser.isIE7, 11007 IsIE8: Browser.isIE8, 11008 IsIE9: Browser.isIE9, 11009 IsIE10: Browser.isIE10, 11010 IsIE11: Browser.isIE11, 11011 IsSafari: Browser.isSafari, 11012 IsFirefox: Browser.isFirefox, 11013 IsChrome: Browser.isChrome, 11014 DetectIeVersion: Browser.detectIEVersion, 11015 IsMac: Browser.isMac, 11016 IsAndroid: Browser.isAndroid, 11017 isIPad: Browser.isIPad, 11018 isIPhone: Browser.isIPhone, 11019 IsIOS: Browser.isIOS, 11020 IsMobile: Browser.isMobile, 11021 isRetina: Browser.isRetina, 11022 IsDoctype: Browser.isDoctype, 11023 SupportLocalStorage: Browser.isLocalStorageSupported, 11024 addGlobalClass: Browser.addGlobalClass, 11025 DetectAndroidVersion: Browser.detectAndroidVersion, 11026 isPropertySupported: Browser.isPropertySupported, 11027 addGlobalFeatures: Browser.addGlobalFeatures 11028 }; 11029 11030 // eslint-disable-next-line 11031 const ajax = window.BX ? window.BX.ajax : () => {}; 11032 function GetWindowScrollSize(doc = document) { 11033 return { 11034 scrollWidth: doc.documentElement.scrollWidth, 11035 scrollHeight: doc.documentElement.scrollHeight 11036 }; 11037 } 11038 function GetWindowScrollPos(doc = document) { 11039 const win = getWindow(doc); 11040 return { 11041 scrollLeft: win.pageXOffset, 11042 scrollTop: win.pageYOffset 11043 }; 11044 } 11045 function GetWindowInnerSize(doc = document) { 11046 const win = getWindow(doc); 11047 return { 11048 innerWidth: win.innerWidth, 11049 innerHeight: win.innerHeight 11050 }; 11051 } 11052 function GetWindowSize(doc = document) { 11053 return { 11054 ...GetWindowInnerSize(doc), 11055 ...GetWindowScrollPos(doc), 11056 ...GetWindowScrollSize(doc) 11057 }; 11058 } 11059 function GetContext(node) { 11060 return getWindow(node); 11061 } 11062 function pos(element, relative = false) { 11063 if (!element) { 11064 return new DOMRect().toJSON(); 11065 } 11066 if (element.ownerDocument === document && !relative) { 11067 const clientRect = element.getBoundingClientRect(); 11068 const root = document.documentElement; 11069 const { 11070 body 11071 } = document; 11072 return { 11073 top: Math.round(clientRect.top + (root.scrollTop || body.scrollTop)), 11074 left: Math.round(clientRect.left + (root.scrollLeft || body.scrollLeft)), 11075 width: Math.round(clientRect.right - clientRect.left), 11076 height: Math.round(clientRect.bottom - clientRect.top), 11077 right: Math.round(clientRect.right + (root.scrollLeft || body.scrollLeft)), 11078 bottom: Math.round(clientRect.bottom + (root.scrollTop || body.scrollTop)) 11079 }; 11080 } 11081 let x = 0; 11082 let y = 0; 11083 const w = element.offsetWidth; 11084 const h = element.offsetHeight; 11085 let first = true; 11086 11087 // eslint-disable-next-line no-param-reassign 11088 for (; element != null; element = element.offsetParent) { 11089 if (!first && relative && BX.is_relative(element)) { 11090 break; 11091 } 11092 x += element.offsetLeft; 11093 y += element.offsetTop; 11094 if (first) { 11095 first = false; 11096 // eslint-disable-next-line no-continue 11097 continue; 11098 } 11099 x += Text.toNumber(Dom.style(element, 'border-left-width')); 11100 y += Text.toNumber(Dom.style(element, 'border-top-width')); 11101 } 11102 return new DOMRect(x, y, w, h).toJSON(); 11103 } 11104 function addCustomEvent(eventObject, eventName, eventHandler) { 11105 if (Type.isString(eventObject)) { 11106 eventHandler = eventName; 11107 eventName = eventObject; 11108 eventObject = EventEmitter.GLOBAL_TARGET;
11109 } 11110 if (eventObject === window) { 11111 eventObject = EventEmitter.GLOBAL_TARGET; 11112 } 11113 if (!Type.isObject(eventObject)) { 11114 console.error('The "eventObject" argument must be an object. Received type ' + typeof eventObject + '.'); 11115 return; 11116 } 11117 if (!Type.isStringFilled(eventName)) { 11118 console.error('The "eventName" argument must be a string.'); 11119 return; 11120 } 11121 if (!Type.isFunction(eventHandler)) { 11122 console.error('The "eventHandler" argument must be a function. Received type ' + typeof eventHandler + '.'); 11123 return; 11124 } 11125 eventName = eventName.toLowerCase(); 11126 EventEmitter.subscribe(eventObject, eventName, eventHandler, { 11127 compatMode: true, 11128 useGlobalNaming: true 11129 }); 11130 } 11131 function onCustomEvent(eventObject, eventName, eventParams, secureParams) { 11132 if (Type.isString(eventObject)) { 11133 secureParams = eventParams; 11134 eventParams = eventName; 11135 eventName = eventObject; 11136 eventObject = EventEmitter.GLOBAL_TARGET; 11137 } 11138 if (!Type.isObject(eventObject) || eventObject === window) { 11139 eventObject = EventEmitter.GLOBAL_TARGET;
11140 } 11141 if (!eventParams) { 11142 eventParams = []; 11143 } 11144 eventName = eventName.toLowerCase(); 11145 const event = new BaseEvent(); 11146 event.setData(eventParams); 11147 event.setCompatData(eventParams); 11148 EventEmitter.emit(eventObject, eventName, event, { 11149 cloneData: secureParams === true, 11150 useGlobalNaming: true 11151 }); 11152 } 11153 function removeCustomEvent(eventObject, eventName, eventHandler) { 11154 if (Type.isString(eventObject)) { 11155 eventHandler = eventName; 11156 eventName = eventObject; 11157 eventObject = EventEmitter.GLOBAL_TARGET; 11158 } 11159 if (!Type.isFunction(eventHandler)) { 11160 console.error('The "eventHandler" argument must be a function. Received type ' + typeof eventHandler + '.'); 11161 return; 11162 } 11163 if (eventObject === window) { 11164 eventObject = EventEmitter.GLOBAL_TARGET; 11165 } 11166 eventName = eventName.toLowerCase(); 11167 EventEmitter.unsubscribe(eventObject, eventName, eventHandler, { 11168 useGlobalNaming: true 11169 }); 11170 } 11171 function removeAllCustomEvents(eventObject, eventName) { 11172 if (Type.isString(eventObject)) { 11173 eventName = eventObject; 11174 eventObject = EventEmitter.GLOBAL_TARGET;
11175 } 11176 if (eventObject === window) { 11177 eventObject = EventEmitter.GLOBAL_TARGET; 11178 } 11179 eventName = eventName.toLowerCase(); 11180 EventEmitter.unsubscribeAll(eventObject, eventName, { 11181 useGlobalNaming: true 11182 }); 11183 } 11184 11185 if (typeof global === 'object' && global.window && global.window.BX) { 11186 Object.assign(global.window.BX, exports); 11187 } 11188 11189 exports.Type = Type; 11190 exports.Reflection = Reflection; 11191 exports.Text = Text; 11192 exports.Dom = Dom; 11193 exports.Browser = Browser; 11194 exports.Event = Event; 11195 exports.Http = Http; 11196 exports.Runtime = Runtime; 11197 exports.Loc = Loc; 11198 exports.Tag = Tag; 11199 exports.Uri = Uri; 11200 exports.Validation = Validation; 11201 exports.Cache = Cache; 11202 exports.BaseError = BaseError; 11203 exports.Extension = Extension$1; 11204 exports.ZIndexManager = ZIndexManager; 11205 exports.Collections = collections; 11206 exports.getClass = getClass; 11207 exports.namespace = namespace; 11208 exports.message = message$1; 11209 exports.replace = replace; 11210 exports.remove = remove; 11211 exports.clean = clean; 11212 exports.insertBefore = insertBefore; 11213 exports.insertAfter = insertAfter; 11214 exports.append = append; 11215 exports.prepend = prepend; 11216 exports.style = style; 11217 exports.adjust = adjust; 11218 exports.create = create; 11219 exports.isShown = isShown; 11220 exports.addClass = addClass; 11221 exports.removeClass = removeClass; 11222 exports.hasClass = hasClass; 11223 exports.toggleClass = toggleClass; 11224 exports.cleanNode = cleanNode; 11225 exports.getCookie = getCookie; 11226 exports.setCookie = setCookie; 11227 exports.bind = bind$1; 11228 exports.unbind = unbind$1; 11229 exports.unbindAll = unbindAll$1; 11230 exports.bindOnce = bindOnce$1; 11231 exports.ready = ready$1; 11232 exports.debugEnableFlag = debugEnableFlag; 11233 exports.debugStatus = debugStatus; 11234 exports.debug = debug$1; 11235 exports.debugEnable = debugEnable; 11236 exports.clone = clone$1; 11237 exports.loadExt = loadExt; 11238 exports.debounce = debounce; 11239 exports.throttle = throttle; 11240 exports.html = html; 11241 exports.type = type; 11242 exports.browser = browser; 11243 exports.ajax = ajax; 11244 exports.GetWindowScrollSize = GetWindowScrollSize; 11245 exports.GetWindowScrollPos = GetWindowScrollPos; 11246 exports.GetWindowInnerSize = GetWindowInnerSize; 11247 exports.GetWindowSize = GetWindowSize; 11248 exports.GetContext = GetContext; 11249 exports.pos = pos; 11250 exports.addCustomEvent = addCustomEvent; 11251 exports.onCustomEvent = onCustomEvent; 11252 exports.removeCustomEvent = removeCustomEvent; 11253 exports.removeAllCustomEvents = removeAllCustomEvents; 11254 11255}((this.BX = this.BX || {}))); 11256 11257 11258 11259(function(BX) { 11260 /* list of registered proxy functions */ 11261 var proxyList = new WeakMap(); 11262 var deferList = new WeakMap(); 11263 11264 /* List of denied event handlers */ 11265 var deniedEvents = []; 11266 11267 /* list of registered custom events */ 11268 var customEvents = new WeakMap(); 11269 var customEventsCnt = 0; 11270 11271 /* list of external garbage collectors */ 11272 var garbageCollectors = []; 11273 11274 /* list of loaded CSS files */ 11275 var cssList = []; 11276 var cssInit = false; 11277 11278 /* list of loaded JS files */ 11279 var jsList = []; 11280 var jsInit = false; 11281 11282 var eventTypes = { 11283 click: 'MouseEvent', 11284 dblclick: 'MouseEvent', 11285 mousedown: 'MouseEvent', 11286 mousemove: 'MouseEvent', 11287 mouseout: 'MouseEvent', 11288 mouseover: 'MouseEvent', 11289 mouseup: 'MouseEvent', 11290 focus: 'MouseEvent', 11291 blur: 'MouseEvent' 11292 }; 11293 11294 var lastWait = []; 11295 11296 var CHECK_FORM_ELEMENTS = {tagName: /^INPUT|SELECT|TEXTAREA|BUTTON$/i}; 11297 11298 BX.MSLEFT = 1; 11299 BX.MSMIDDLE = 2; 11300 BX.MSRIGHT = 4; 11301 11302 BX.AM_PM_UPPER = 1; 11303 BX.AM_PM_LOWER = 2; 11304 BX.AM_PM_NONE = false; 11305 11306 BX.ext = function(ob) 11307 { 11308 for (var i in ob) 11309 { 11310 if(ob.hasOwnProperty(i)) 11311 { 11312 this[i] = ob[i]; 11313 } 11314 } 11315 }; 11316 11317 var r = { 11318 script: /<script([^>]*)>/ig, 11319 script_end: /<\/script>/ig, 11320 script_src: /src=["\']([^"\']+)["\']/i, 11321 script_type: /type=["\']([^"\']+)["\']/i, 11322 space: /\s+/, 11323 ltrim: /^[\s\r\n]+/g, 11324 rtrim: /[\s\r\n]+$/g, 11325 style: /<link.*?(rel="stylesheet"|type="text\/css")[^>]*>/i, 11326 style_href: /href=["\']([^"\']+)["\']/i 11327 }; 11328 11329 BX.processHTML = function(data, scriptsRunFirst) 11330 { 11331 var matchScript, matchStyle, matchSrc, matchHref, matchType, scripts = [], styles = []; 11332 var textIndexes = []; 11333 var lastIndex = r.script.lastIndex = r.script_end.lastIndex = 0; 11334 11335 while ((matchScript = r.script.exec(data)) !== null) 11336 { 11337 r.script_end.lastIndex = r.script.lastIndex; 11338 var matchScriptEnd = r.script_end.exec(data); 11339 if (matchScriptEnd === null) 11340 { 11341 break; 11342 } 11343 11344 // skip script tags of special types 11345 var skipTag = false;
11346 if ((matchType = matchScript[1].match(r.script_type)) !== null) 11347 { 11348 if( 11349 matchType[1] == 'text/html' 11350 || matchType[1] == 'text/template' 11351 || matchType[1] == 'extension/settings' 11352 ) 11353 { 11354 skipTag = true; 11355 } 11356 } 11357 11358 if(skipTag) 11359 { 11360 textIndexes.push([lastIndex, r.script_end.lastIndex - lastIndex]); 11361 } 11362 else 11363 { 11364 textIndexes.push([lastIndex, matchScript.index - lastIndex]); 11365 11366 var bRunFirst = scriptsRunFirst || (matchScript[1].indexOf('bxrunfirst') != '-1'); 11367 11368 if ((matchSrc = matchScript[1].match(r.script_src)) !== null) 11369 { 11370 scripts.push({"bRunFirst": bRunFirst, "isInternal": false, "JS": matchSrc[1]}); 11371 } 11372 else 11373 { 11374 var start = matchScript.index + matchScript[0].length; 11375 var js = data.substr(start, matchScriptEnd.index-start); 11376 11377 scripts.push({"bRunFirst": bRunFirst, "isInternal": true, "JS": js}); 11378 } 11379 } 11380 11381 lastIndex = matchScriptEnd.index + 9; 11382 r.script.lastIndex = lastIndex; 11383 } 11384 11385 textIndexes.push([lastIndex, lastIndex === 0 ? data.length : data.length - lastIndex]); 11386 var pureData = ""; 11387 for (var i = 0, length = textIndexes.length; i < length; i++) 11388 { 11389 if (BX.type.isString(data) && BX.type.isFunction(data.substr)) 11390 { 11391 pureData += data.substr(textIndexes[i][0], textIndexes[i][1]); 11392 } 11393 } 11394 11395 while ((matchStyle = pureData.match(r.style)) !== null) 11396 { 11397 if ((matchHref = matchStyle[0].match(r.style_href)) !== null && matchStyle[0].indexOf('media="') < 0) 11398 { 11399 styles.push(matchHref[1]); 11400 } 11401 11402 pureData = pureData.replace(matchStyle[0], ''); 11403 } 11404 11405 return {'HTML': pureData, 'SCRIPT': scripts, 'STYLE': styles}; 11406 }; 11407 11408 /* OO emulation utility */ 11409 BX.extend = function(child, parent) 11410 { 11411 var f = function() {}; 11412 f.prototype = parent.prototype; 11413 11414 child.prototype = new f(); 11415 child.prototype.constructor = child; 11416 11417 child.superclass = parent.prototype; 11418 child.prototype.superclass = parent.prototype; 11419 if(parent.prototype.constructor == Object.prototype.constructor) 11420 { 11421 parent.prototype.constructor = parent; 11422 } 11423 }; 11424 11425 BX.is_subclass_of = function(ob, parent_class) 11426 { 11427 if (ob instanceof parent_class) 11428 return true; 11429 11430 if (parent_class.superclass) 11431 return BX.is_subclass_of(ob, parent_class.superclass); 11432 11433 return false; 11434 }; 11435 11436 BX.clearNodeCache = function() 11437 { 11438 return false; 11439 }; 11440 11441 BX.bitrix_sessid = function() {return BX.message("bitrix_sessid"); }; 11442 11443 /** 11444 * Creates document fragment with child nodes. 11445 * 11446 * @param {Node[]} nodes 11447 * @return {DocumentFragment} 11448 */ 11449 BX.createFragment = function(nodes) 11450 { 11451 var fragment = document.createDocumentFragment(); 11452 11453 if(!BX.type.isArray(nodes)) 11454 { 11455 return fragment; 11456 } 11457 for(var i = 0; i < nodes.length; i++) 11458 { 11459 fragment.appendChild(nodes[i]); 11460 } 11461 11462 return fragment; 11463 }; 11464 11465 /** 11466 * @deprecated 11467 * @use BX.style 11468 * @param element 11469 * @param opacity 11470 */ 11471 BX.setOpacity = function(element, opacity) 11472 { 11473 var opacityValue = parseFloat(opacity); 11474 11475 if (!isNaN(opacityValue) && BX.type.isDomNode(element)) 11476 { 11477 opacityValue = opacityValue < 1 ? opacityValue : opacityValue / 100; 11478 BX.style(element, 'opacity', opacityValue); 11479 } 11480 }; 11481 11482 /** 11483 * @deprecated 11484 * @param el 11485 * @return {*} 11486 */ 11487 BX.hoverEvents = function(el) 11488 { 11489 if (el) 11490 return BX.adjust(el, {events: BX.hoverEvents()}); 11491 else 11492 return {mouseover: BX.hoverEventsHover, mouseout: BX.hoverEventsHout}; 11493 }; 11494 11495 /** 11496 * @deprecated 11497 */ 11498 BX.hoverEventsHover = function(){BX.addClass(this,'bx-hover');this.BXHOVER=true;}; 11499 /** 11500 * @deprecated 11501 */ 11502 BX.hoverEventsHout = function(){BX.removeClass(this,'bx-hover');this.BXHOVER=false;}; 11503 11504 /** 11505 * @deprecated 11506 */ 11507 BX.focusEvents = function(el) 11508 { 11509 if (el) 11510 return BX.adjust(el, {events: BX.focusEvents()}); 11511 else 11512 return {mouseover: BX.focusEventsFocus, mouseout: BX.focusEventsBlur}; 11513 }; 11514 11515 /** 11516 * @deprecated 11517 */ 11518 BX.focusEventsFocus = function(){BX.addClass(this,'bx-focus');this.BXFOCUS=true;}; 11519 /** 11520 * @deprecated 11521 */ 11522 BX.focusEventsBlur = function(){BX.removeClass(this,'bx-focus');this.BXFOCUS=false;}; 11523 11524 BX.setUnselectable = function(node) 11525 { 11526 BX.style(node, { 11527 'userSelect': 'none', 11528 'MozUserSelect': 'none', 11529 'WebkitUserSelect': 'none', 11530 'KhtmlUserSelect': 'none', 11531 }); 11532 node.setAttribute('unSelectable', 'on'); 11533 }; 11534 11535 BX.setSelectable = function(node) 11536 { 11537 BX.style(node, { 11538 'userSelect': null, 11539 'MozUserSelect': null, 11540 'WebkitUserSelect': null, 11541 'KhtmlUserSelect': null, 11542 }); 11543 node.removeAttribute('unSelectable'); 11544 }; 11545 11546 BX.styleIEPropertyName = function(name) 11547 { 11548 if (name == 'float') 11549 name = BX.browser.IsIE() ? 'styleFloat' : 'cssFloat'; 11550 else 11551 { 11552 var res = BX.browser.isPropertySupported(name); 11553 if (res) 11554 { 11555 name = res; 11556 } 11557 else 11558 {
11559 var reg = /(\-([a-z]){1})/g; 11560 if (reg.test(name)) 11561 { 11562 name = name.replace(reg, function () {return arguments[2].toUpperCase();}); 11563 } 11564 } 11565 } 11566 return name; 11567 }; 11568 11569 BX.focus = function(el) 11570 { 11571 try 11572 { 11573 el.focus(); 11574 return true; 11575 } 11576 catch (e) 11577 { 11578 return false; 11579 } 11580 }; 11581 11582 BX.firstChild = function(el) 11583 { 11584 return BX.type.isDomNode(el) ? el.firstElementChild : null; 11585 }; 11586 11587 BX.lastChild = function(el) 11588 { 11589 return BX.type.isDomNode(el) ? el.lastElementChild : null; 11590 }; 11591 11592 BX.previousSibling = function(el) 11593 { 11594 return BX.type.isDomNode(el) ? el.previousElementSibling : null; 11595 }; 11596 11597 BX.nextSibling = function(el) 11598 { 11599 return BX.type.isDomNode(el) ? el.nextElementSibling : null; 11600 }; 11601 11602 /* 11603 params: { 11604 obj : html node 11605 className : className value 11606 recursive : used only for older browsers to optimize the tree traversal, in new browsers the search is always recursively, default - true 11607 } 11608 11609 Search all nodes with className 11610 */ 11611 /** 11612 * @deprecated 11613 * @use .querySelectorAll 11614 * @param obj 11615 * @param className 11616 * @param recursive 11617 * @return {*} 11618 */ 11619 BX.findChildrenByClassName = function(obj, className, recursive) 11620 { 11621 if(!obj || !obj.childNodes) return null; 11622 11623 var result = []; 11624 if (typeof(obj.getElementsByClassName) == 'undefined') 11625 { 11626 recursive = recursive !== false; 11627 result = BX.findChildren(obj, {className : className}, recursive); 11628 } 11629 else 11630 { 11631 var col = obj.getElementsByClassName(className); 11632 for (i=0,l=col.length;i<l;i++) 11633 { 11634 result[i] = col[i]; 11635 } 11636 } 11637 return result; 11638 }; 11639 11640 /* 11641 params: { 11642 obj : html node 11643 className : className value 11644 recursive : used only for older browsers to optimize the tree traversal, in new browsers the search is always recursively, default - true 11645 } 11646 11647 Search first node with className 11648 */ 11649 /** 11650 * @deprecated 11651 * @use .querySelector 11652 * @param obj 11653 * @param className 11654 * @param recursive 11655 * @return {*} 11656 */ 11657 BX.findChildByClassName = function(obj, className, recursive) 11658 { 11659 if(!obj || !obj.childNodes) return null; 11660 11661 var result = null; 11662 if (typeof(obj.getElementsByClassName) == 'undefined') 11663 { 11664 recursive = recursive !== false; 11665 result = BX.findChild(obj, {className : className}, recursive); 11666 } 11667 else 11668 { 11669 var col = obj.getElementsByClassName(className); 11670 if (col && typeof(col[0]) != 'undefined') 11671 { 11672 result = col[0]; 11673 } 11674 else 11675 { 11676 result = null; 11677 } 11678 } 11679 return result; 11680 }; 11681 11682 /* 11683 params: { 11684 tagName|tag : 'tagName', 11685 className|class : 'className', 11686 attribute : {attribute : value, attribute : value} | attribute | [attribute, attribute....], 11687 property : {prop: value, prop: value} | prop | [prop, prop] 11688 } 11689 11690 all values can be RegExps or strings 11691 */ 11692 /** 11693 * @deprecated 11694 * @use .querySelectorAll 11695 * @param obj 11696 * @param params 11697 * @param recursive 11698 * @return {*|Node} 11699 */ 11700 BX.findChildren = function(obj, params, recursive) 11701 { 11702 return BX.findChild(obj, params, recursive, true); 11703 }; 11704 11705 /** 11706 * @deprecated 11707 * @use .querySelectorAll 11708 * @param obj 11709 * @param params 11710 * @param recursive 11711 * @param get_all 11712 * @return {*} 11713 */ 11714 BX.findChild = function(obj, params, recursive, get_all) 11715 { 11716 if(!obj || !obj.childNodes) return null; 11717 11718 recursive = !!recursive; get_all = !!get_all; 11719 11720 var n = obj.childNodes.length, result = []; 11721 11722 for (var j=0; j<n; j++) 11723 { 11724 var child = obj.childNodes[j]; 11725 11726 if (_checkNode(child, params)) 11727 { 11728 if (get_all) 11729 result.push(child); 11730 else 11731 return child; 11732 } 11733 11734 if(recursive == true) 11735 { 11736 var res = BX.findChild(child, params, recursive, get_all); 11737 if (res) 11738 { 11739 if (get_all) 11740 result = BX.util.array_merge(result, res); 11741 else 11742 return res; 11743 } 11744 } 11745 } 11746 11747 if (get_all || result.length > 0) 11748 return result; 11749 else 11750 return null; 11751 }; 11752 11753 /** 11754 * @deprecated 11755 * @use .closest() 11756 * @param obj 11757 * @param params 11758 * @param maxParent 11759 * @return {*} 11760 */ 11761 BX.findParent = function(obj, params, maxParent) 11762 { 11763 if(!obj) 11764 return null; 11765 11766 var o = obj; 11767 while(o.parentNode) 11768 { 11769 var parent = o.parentNode; 11770 11771 if (_checkNode(parent, params)) 11772 return parent; 11773 11774 o = parent; 11775 11776 if (!!maxParent &&
11777 (BX.type.isFunction(maxParent) 11778 || typeof maxParent == 'object')) 11779 { 11780 if (BX.type.isElementNode(maxParent)) 11781 { 11782 if (o == maxParent) 11783 break; 11784 } 11785 else 11786 { 11787 if (_checkNode(o, maxParent)) 11788 break; 11789 } 11790 } 11791 } 11792 return null; 11793 }; 11794 11795 /** 11796 * @deprecated 11797 * @use .querySelector 11798 * @param obj 11799 * @param params 11800 * @return {*} 11801 */ 11802 BX.findNextSibling = function(obj, params) 11803 { 11804 if(!obj) 11805 return null; 11806 var o = obj; 11807 while(o.nextSibling) 11808 { 11809 var sibling = o.nextSibling; 11810 if (_checkNode(sibling, params)) 11811 return sibling; 11812 o = sibling; 11813 } 11814 return null; 11815 }; 11816 11817 /** 11818 * @deprecated 11819 * @use .querySelector 11820 * @param obj 11821 * @param params 11822 * @return {*} 11823 */ 11824 BX.findPreviousSibling = function(obj, params) 11825 { 11826 if(!obj) 11827 return null; 11828 11829 var o = obj; 11830 while(o.previousSibling) 11831 { 11832 var sibling = o.previousSibling; 11833 if(_checkNode(sibling, params)) 11834 return sibling; 11835 o = sibling; 11836 } 11837 return null; 11838 }; 11839 11840 BX.checkNode = function(obj, params) 11841 { 11842 return _checkNode(obj, params); 11843 }; 11844 11845 /** 11846 * @deprecated 11847 * @use .querySelectorAll 11848 * @param form 11849 * @return {Array} 11850 */ 11851 BX.findFormElements = function(form) 11852 { 11853 if (BX.type.isString(form)) 11854 form = document.forms[form]||BX(form); 11855 11856 var res = []; 11857 11858 if (BX.type.isElementNode(form)) 11859 { 11860 if (form.tagName.toUpperCase() == 'FORM') 11861 { 11862 res = form.elements; 11863 } 11864 else 11865 { 11866 res = BX.findChildren(form, CHECK_FORM_ELEMENTS, true); 11867 } 11868 } 11869 11870 return res; 11871 }; 11872 11873 /** 11874 * @deprecated 11875 * @use .contains() 11876 * @param whichNode 11877 * @param forNode 11878 * @return {boolean} 11879 */ 11880 BX.isParentForNode = function(whichNode, forNode) 11881 { 11882 if (BX.type.isDomNode(whichNode) && BX.type.isDomNode(forNode)) 11883 { 11884 return whichNode.contains(forNode); 11885 } 11886 11887 return false; 11888 }; 11889 11890 BX.getCaretPosition = function(node) 11891 { 11892 var pos = 0; 11893 11894 if(node.selectionStart || node.selectionStart == 0) 11895 { 11896 pos = node.selectionStart; 11897 } 11898 else if(document.selection) 11899 { 11900 node.focus(); 11901 var selection = document.selection.createRange(); 11902 selection.moveStart('character', -node.value.length); 11903 pos = selection.text.length; 11904 } 11905 11906 return (pos); 11907 }; 11908 11909 BX.setCaretPosition = function(node, pos) 11910 { 11911 if(!BX.isNodeInDom(node) || BX.isNodeHidden(node) || node.disabled) 11912 { 11913 return; 11914 } 11915 11916 if(node.setSelectionRange) 11917 { 11918 node.focus(); 11919 node.setSelectionRange(pos, pos); 11920 } 11921 else if(node.createTextRange) 11922 { 11923 var range = node.createTextRange(); 11924 range.collapse(true); 11925 range.moveEnd('character', pos); 11926 range.moveStart('character', pos); 11927 range.select(); 11928 } 11929 }; 11930 11931 // access private. use BX.mergeEx instead. 11932 // todo: refactor BX.merge, make it work through BX.mergeEx 11933 BX.merge = function(){ 11934 var arg = Array.prototype.slice.call(arguments); 11935 11936 if(arg.length < 2) 11937 return {}; 11938 11939 var result = arg.shift(); 11940 11941 for(var i = 0; i < arg.length; i++) 11942 { 11943 for(var k in arg[i]){ 11944 11945 if(typeof arg[i] == 'undefined' || arg[i] == null) 11946 continue; 11947 11948 if(arg[i].hasOwnProperty(k)){ 11949 11950 if(typeof arg[i][k] == 'undefined' || arg[i][k] == null) 11951 continue; 11952 11953 if(typeof arg[i][k] == 'object' && !BX.type.isDomNode(arg[i][k]) && (typeof arg[i][k]['isUIWidget'] == 'undefined')){ 11954 11955 // go deeper 11956 11957 var isArray = 'length' in arg[i][k]; 11958 11959 if(typeof result[k] != 'object') 11960 result[k] = isArray ? [] : {}; 11961 11962 if(isArray) 11963 BX.util.array_merge(result[k], arg[i][k]); 11964 else 11965 BX.merge(result[k], arg[i][k]); 11966 11967 }else 11968 result[k] = arg[i][k]; 11969 } 11970 } 11971 } 11972 11973 return result; 11974 }; 11975 11976 BX.mergeEx = function() 11977 { 11978 var arg = Array.prototype.slice.call(arguments); 11979 if(arg.length < 2) 11980 { 11981 return {}; 11982 } 11983 11984 var result = arg.shift(); 11985 for (var i = 0; i < arg.length; i++) 11986 { 11987 for (var k in arg[i]) 11988 { 11989 if (typeof arg[i] == "undefined" || arg[i] == null || !arg[i].hasOwnProperty(k)) 11990 { 11991 continue; 11992 } 11993 11994 if (BX.type.isPlainObject(arg[i][k]) && BX.type.isPlainObject(result[k])) 11995 { 11996 BX.mergeEx(result[k], arg[i][k]); 11997 } 11998 else 11999 { 12000 result[k] = BX.type.isPlainObject(arg[i][k]) ? BX.clone(arg[i][k]) : arg[i][k]; 12001 } 12002 } 12003 } 12004 12005 return result; 12006 }; 12007 12008 BX.getEventButton = function(e) 12009 { 12010 e = e || window.event; 12011 12012 var flags = 0; 12013 12014 if (typeof e.which != 'undefined') 12015 { 12016 switch (e.which) 12017 { 12018 case 1: flags = flags|BX.MSLEFT; break; 12019 case 2: flags = flags|BX.MSMIDDLE; break; 12020 case 3: flags = flags|BX.MSRIGHT; break; 12021 } 12022 } 12023 else if (typeof e.button != 'undefined') 12024 { 12025 flags = event.button; 12026 } 12027 12028 return flags || BX.MSLEFT; 12029 }; 12030 12031 var captured_events = null, _bind = null; 12032 BX.CaptureEvents = function(el_c, evname_c) 12033 { 12034 if (_bind) 12035 return; 12036 12037 _bind = BX.bind; 12038 captured_events = []; 12039 12040 BX.bind = function(el, evname, func) 12041 { 12042 if (el === el_c && evname === evname_c) 12043 captured_events.push(func); 12044 12045 _bind.apply(this, arguments); 12046 } 12047 }; 12048 12049 BX.CaptureEventsGet = function() 12050 { 12051 if (_bind) 12052 { 12053 BX.bind = _bind; 12054 12055 var captured = captured_events; 12056 12057 _bind = null; 12058 captured_events = null; 12059 return captured; 12060 } 12061 return null; 12062 }; 12063 12064 // Don't even try to use it for submit event! 12065 BX.fireEvent = function(ob,ev) 12066 { 12067 var result = false, e = null; 12068 if (BX.type.isDomNode(ob)) 12069 { 12070 result = true; 12071 if (document.createEventObject) 12072 { 12073 // IE 12074 if (eventTypes[ev] != 'MouseEvent') 12075 { 12076 e = document.createEventObject(); 12077 e.type = ev; 12078 result = ob.fireEvent('on' + ev, e); 12079 } 12080 12081 if (ob[ev]) 12082 { 12083 ob[ev](); 12084 } 12085 } 12086 else 12087 {
12088 // non-IE 12089 e = null; 12090 12091 switch (eventTypes[ev]) 12092 { 12093 case 'MouseEvent': 12094 e = document.createEvent('MouseEvent'); 12095 try 12096 { 12097 e.initMouseEvent(ev, true, true, top, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, null); 12098 } 12099 catch (initException) 12100 { 12101 e.initMouseEvent(ev, true, true, window, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, null); 12102 } 12103 12104 break; 12105 default: 12106 e = document.createEvent('Event'); 12107 e.initEvent(ev, true, true); 12108 } 12109 12110 result = ob.dispatchEvent(e); 12111 } 12112 } 12113 12114 return result; 12115 }; 12116 12117 BX.getWheelData = function(e) 12118 { 12119 e = e || window.event; 12120 e.wheelData = e.detail ? e.detail * -1 : e.wheelDelta / 40; 12121 return e.wheelData; 12122 }; 12123 12124 BX.proxy_context = null; 12125 12126 BX.delegate = function (func, thisObject) 12127 { 12128 if (!func || !thisObject) 12129 return func; 12130 12131 return function() { 12132 var cur = BX.proxy_context; 12133 BX.proxy_context = this; 12134 var res = func.apply(thisObject, arguments); 12135 BX.proxy_context = cur; 12136 return res; 12137 } 12138 }; 12139 12140 BX.delegateLater = function (func_name, thisObject, contextObject) 12141 { 12142 return function() 12143 { 12144 if (thisObject[func_name]) 12145 { 12146 var cur = BX.proxy_context; 12147 BX.proxy_context = this; 12148 var res = thisObject[func_name].apply(contextObject||thisObject, arguments); 12149 BX.proxy_context = cur; 12150 return res; 12151 } 12152 return null; 12153 } 12154 }; 12155 12156 BX.proxy = function(func, thisObject) 12157 { 12158 return getObjectDelegate(func, thisObject, proxyList); 12159 }; 12160 12161 BX.defer = function(func, thisObject) 12162 { 12163 if (!!thisObject) 12164 return BX.defer_proxy(func, thisObject); 12165 else 12166 return function() { 12167 var arg = arguments; 12168 setTimeout(function(){func.apply(this,arg)}, 10); 12169 }; 12170 }; 12171 12172 BX.defer_proxy = function(func, thisObject) 12173 { 12174 return getObjectDelegate(func, thisObject, deferList, BX.defer); 12175 }; 12176 12177 /** 12178 * 12179 * @private 12180 */ 12181 function getObjectDelegate(func, thisObject, collection, decorator) 12182 { 12183 if (!BX.type.isFunction(func) || !BX.type.isMapKey(thisObject)) 12184 { 12185 return func; 12186 } 12187 12188 var objectDelegates = collection.get(thisObject); 12189 if (!objectDelegates) 12190 { 12191 objectDelegates = new WeakMap(); 12192 collection.set(thisObject, objectDelegates); 12193 } 12194 12195 var delegate = objectDelegates.get(func); 12196 if (!delegate) 12197 { 12198 delegate = decorator ? decorator(BX.delegate(func, thisObject)) : BX.delegate(func, thisObject); 12199 objectDelegates.set(func, delegate); 12200 } 12201 12202 return delegate; 12203 } 12204 12205 BX.once = function(el, evname, func) 12206 { 12207 var fn = function() 12208 { 12209 BX.unbind(el, evname, fn); 12210 func.apply(this, arguments); 12211 }; 12212 12213 return fn; 12214 }; 12215 12216 BX.bindDelegate = function (elem, eventName, isTarget, handler) 12217 { 12218 var h = BX.delegateEvent(isTarget, handler); 12219 BX.bind(elem, eventName, h); 12220 return h; 12221 }; 12222 12223 BX.delegateEvent = function(isTarget, handler) 12224 { 12225 return function(e) 12226 { 12227 e = e || window.event; 12228 var target = e.target || e.srcElement; 12229 12230 while (target != this) 12231 { 12232 if (_checkNode(target, isTarget)) 12233 { 12234 return handler.call(target, e); 12235 } 12236 if (target && target.parentNode) 12237 target = target.parentNode; 12238 else 12239 break; 12240 } 12241 return null; 12242 } 12243 }; 12244 12245 BX.False = function() {return false;}; 12246 BX.DoNothing = function() {}; 12247 12248 // TODO: also check event handlers set via BX.bind() 12249 BX.denyEvent = function(el, ev) 12250 { 12251 deniedEvents.push([el, ev, el['on' + ev]]); 12252 el['on' + ev] = BX.DoNothing; 12253 }; 12254 12255 BX.allowEvent = function(el, ev) 12256 { 12257 for(var i=0, len=deniedEvents.length; i<len; i++) 12258 { 12259 if (deniedEvents[i][0] == el && deniedEvents[i][1] == ev) 12260 { 12261 el['on' + ev] = deniedEvents[i][2]; 12262 BX.util.deleteFromArray(deniedEvents, i); 12263 return; 12264 } 12265 } 12266 }; 12267 12268 BX.fixEventPageXY = function(event) 12269 { 12270 BX.fixEventPageX(event); 12271 BX.fixEventPageY(event); 12272 return event; 12273 }; 12274 12275 BX.fixEventPageX = function(event) 12276 { 12277 if (event.pageX == null && event.clientX != null) 12278 { 12279 event.pageX = 12280 event.clientX + 12281 (document.documentElement && document.documentElement.scrollLeft || document.body && document.body.scrollLeft || 0) - 12282 (document.documentElement.clientLeft || 0); 12283 } 12284 12285 return event; 12286 }; 12287 12288 BX.fixEventPageY = function(event) 12289 { 12290 if (event.pageY == null && event.clientY != null) 12291 { 12292 event.pageY = 12293 event.clientY + 12294 (document.documentElement && document.documentElement.scrollTop || document.body && document.body.scrollTop || 0) - 12295 (document.documentElement.clientTop || 0); 12296 } 12297 12298 return event; 12299 }; 12300 12301 /** 12302 * @deprecated 12303 * @see e.preventDefault() 12304 */ 12305 BX.PreventDefault = function(e) 12306 { 12307 if(!e) e = window.event; 12308 if(e.stopPropagation) 12309 { 12310 e.preventDefault(); 12311 e.stopPropagation(); 12312 } 12313 else 12314 { 12315 e.cancelBubble = true; 12316 e.returnValue = false;
12317 } 12318 return false; 12319 }; 12320 12321 /** 12322 * @deprecated 12323 * @see e.preventDefault(); 12324 * 12325 * @param e 12326 * @return {boolean} 12327 */ 12328 BX.eventReturnFalse = function(e) 12329 { 12330 e=e||window.event; 12331 if (e && e.preventDefault) e.preventDefault(); 12332 else e.returnValue = false; 12333 return false; 12334 }; 12335 12336 /** 12337 * @deprecated 12338 * @see e.stopPropagation() 12339 * @param e 12340 */ 12341 BX.eventCancelBubble = function(e) 12342 { 12343 e=e||window.event; 12344 if(e && e.stopPropagation) 12345 e.stopPropagation(); 12346 else 12347 e.cancelBubble = true; 12348 }; 12349 12350 BX.bindDebouncedChange = function(node, fn, fnInstant, timeout, ctx) 12351 { 12352 ctx = ctx || window; 12353 timeout = timeout || 300; 12354 12355 var dataTag = 'bx-dc-previous-value'; 12356 BX.data(node, dataTag, node.value); 12357 12358 var act = function(fn, val){ 12359 12360 var pVal = BX.data(node, dataTag); 12361 12362 if(typeof pVal == 'undefined' || pVal != val){ 12363 if(typeof ctx != 'object') 12364 fn(val); 12365 else 12366 fn.apply(ctx, [val]); 12367 } 12368 }; 12369 12370 var actD = BX.debounce(function(){ 12371 var val = node.value; 12372 act(fn, val); 12373 BX.data(node, dataTag, val); 12374 }, timeout); 12375 12376 BX.bind(node, 'keyup', actD); 12377 BX.bind(node, 'change', actD); 12378 BX.bind(node, 'input', actD); 12379 12380 if(BX.type.isFunction(fnInstant)){ 12381 12382 var actI = function(){ 12383 act(fnInstant, node.value); 12384 }; 12385 12386 BX.bind(node, 'keyup', actI); 12387 BX.bind(node, 'change', actI); 12388 BX.bind(node, 'input', actI); 12389 } 12390 }; 12391 12392 BX.parseJSON = function(data, context) 12393 { 12394 var result = null; 12395 if (BX.type.isNotEmptyString(data)) 12396 { 12397 try { 12398 if (data.indexOf("\n") >= 0) 12399 eval('result = ' + data); 12400 else 12401 result = (new Function("return " + data))(); 12402 } catch(e) { 12403 BX.onCustomEvent(context, 'onParseJSONFailure', [data, context]) 12404 } 12405 } 12406 else if(BX.type.isPlainObject(data)) 12407 { 12408 return data; 12409 } 12410 12411 return result; 12412 }; 12413 12414 BX.submit = function(obForm, action_name, action_value, onAfterSubmit) 12415 { 12416 action_name = action_name || 'save'; 12417 if (!obForm['BXFormSubmit_' + action_name]) 12418 { 12419 obForm['BXFormSubmit_' + action_name] = obForm.appendChild(BX.create('INPUT', { 12420 'props': { 12421 'type': 'submit', 12422 'name': action_name, 12423 'value': action_value || 'Y' 12424 }, 12425 'style': { 12426 'display': 'none' 12427 } 12428 })); 12429 } 12430 12431 if (obForm.sessid) 12432 obForm.sessid.value = BX.bitrix_sessid(); 12433 12434 setTimeout(BX.delegate(function() {BX.fireEvent(this, 'click'); if (onAfterSubmit) onAfterSubmit();}, obForm['BXFormSubmit_' + action_name]), 10); 12435 }; 12436 12437 BX.show = function(ob, displayType) 12438 { 12439 if (ob.BXDISPLAY || !_checkDisplay(ob, displayType)) 12440 { 12441 ob.style.display = ob.BXDISPLAY; 12442 } 12443 }; 12444 12445 BX.hide = function(ob, displayType) 12446 { 12447 if (!ob.BXDISPLAY) 12448 _checkDisplay(ob, displayType); 12449 12450 ob.style.display = 'none'; 12451 }; 12452 12453 BX.toggle = function(ob, values) 12454 { 12455 if (!values && BX.type.isElementNode(ob)) 12456 { 12457 var bShow = true; 12458 if (ob.BXDISPLAY) 12459 bShow = !_checkDisplay(ob); 12460 else 12461 bShow = ob.style.display == 'none'; 12462 12463 if (bShow) 12464 BX.show(ob); 12465 else 12466 BX.hide(ob); 12467 } 12468 else if (BX.type.isArray(values)) 12469 { 12470 for (var i=0,len=values.length; i<len; i++) 12471 { 12472 if (ob == values[i]) 12473 { 12474 ob = values[i==len-1 ? 0 : i+1]; 12475 break; 12476 } 12477 } 12478 if (i==len) 12479 ob = values[0]; 12480 } 12481 12482 return ob; 12483 }; 12484 12485 function _checkDisplay(ob, displayType) 12486 { 12487 if (typeof displayType != 'undefined') 12488 ob.BXDISPLAY = displayType; 12489 12490 var d = ob.style.display || BX.style(ob, 'display'); 12491 if (d != 'none') 12492 { 12493 ob.BXDISPLAY = ob.BXDISPLAY || d; 12494 return true; 12495 } 12496 else 12497 { 12498 ob.BXDISPLAY = ob.BXDISPLAY || 'block'; 12499 return false; 12500 } 12501 } 12502 12503 /* some useful util functions */ 12504 12505 BX.util = { 12506 /** 12507 * @deprecated 12508 * @use [].filter(value => !BX.Type.isNil(value)) 12509 * @param ar 12510 * @return {*} 12511 */ 12512 array_values: function(ar) 12513 { 12514 if (!BX.type.isArray(ar)) 12515 return BX.util._array_values_ob(ar); 12516 var arv = []; 12517 for(var i=0,l=ar.length;i<l;i++) 12518 if (ar[i] !== null && typeof ar[i] != 'undefined') 12519 arv.push(ar[i]); 12520 return arv; 12521 }, 12522 12523 /** 12524 * @deprecated 12525 * @use Object.values([]).filter(value => !BX.Type.isNil(value)) 12526 * @param ar 12527 * @return {Array} 12528 * @private 12529 */ 12530 _array_values_ob: function(ar) 12531 { 12532 var arv = []; 12533 for(var i in ar) 12534 if (ar[i] !== null && typeof ar[i] != 'undefined') 12535 arv.push(ar[i]); 12536 return arv; 12537 }, 12538 12539 /** 12540 * @deprecated 12541 * @use 12542 * @param ar 12543 * @return {*} 12544 */ 12545 array_keys: function(ar) 12546 { 12547 if (!BX.type.isArray(ar)) 12548 return BX.util._array_keys_ob(ar); 12549 var arv = []; 12550 for(var i=0,l=ar.length;i<l;i++) 12551 if (ar[i] !== null && typeof ar[i] != 'undefined') 12552 arv.push(i); 12553 return arv; 12554 }, 12555 12556 _array_keys_ob: function(ar) 12557 { 12558 var arv = []; 12559 for(var i in ar) 12560 if (ar[i] !== null && typeof ar[i] != 'undefined') 12561 arv.push(i); 12562 return arv; 12563 }, 12564 12565 object_keys: function(obj) 12566 { 12567 var arv = []; 12568 for(var k in obj) 12569 { 12570 if(obj.hasOwnProperty(k)) 12571 { 12572 arv.push(k); 12573 } 12574 } 12575 return arv; 12576 }, 12577 12578 /** 12579 * @deprecated 12580 * @use firstArr.concat(secondArr); 12581 * @param first 12582 * @param second 12583 * @return {*[]} 12584 */ 12585 array_merge: function(first, second) 12586 { 12587 if (!BX.type.isArray(first)) first = []; 12588 if (!BX.type.isArray(second)) second = []; 12589 12590 var i = first.length, j = 0; 12591 12592 if (typeof second.length === "number") 12593 { 12594 for (var l = second.length; j < l; j++) 12595 { 12596 first[i++] = second[j]; 12597 } 12598 } 12599 else 12600 {
12601 while (second[j] !== undefined) 12602 { 12603 first[i++] = second[j++]; 12604 } 12605 } 12606 12607 first.length = i; 12608 12609 return first; 12610 }, 12611 12612 array_flip: function (object) 12613 { 12614 var newObject = {}; 12615 12616 for (var key in object) 12617 { 12618 newObject[object[key]] = key; 12619 } 12620 12621 return newObject; 12622 }, 12623 12624 array_diff: function(ar1, ar2, hash) 12625 { 12626 hash = BX.type.isFunction(hash) ? hash : null; 12627 var i, length, v, h, map = {}, result = []; 12628 for(i = 0, length = ar2.length; i < length; i++) 12629 { 12630 v = ar2[i]; 12631 h = hash ? hash(v) : v; 12632 map[h] = true; 12633 } 12634 12635 for(i = 0, length = ar1.length; i < length; i++) 12636 { 12637 v = ar1[i]; 12638 h = hash ? hash(v) : v; 12639 if(typeof(map[h]) === "undefined") 12640 { 12641 result.push(v); 12642 } 12643 } 12644 return result; 12645 }, 12646 12647 /** 12648 * @deprecated 12649 * @use Set 12650 */ 12651 array_unique: function(ar) 12652 { 12653 var i=0,j,len=ar.length; 12654 if(len<2) return ar; 12655 12656 for (; i<len-1;i++) 12657 { 12658 for (j=i+1; j<len;j++) 12659 { 12660 if (ar[i]==ar[j]) 12661 { 12662 ar.splice(j--,1); len--; 12663 } 12664 } 12665 } 12666 12667 return ar; 12668 }, 12669 12670 /** 12671 * @deprecated 12672 * @use myArr.includes(needle) 12673 */ 12674 in_array: function(needle, haystack) 12675 { 12676 for(var i=0; i<haystack.length; i++) 12677 { 12678 if(haystack[i] == needle) 12679 return true; 12680 } 12681 return false; 12682 }, 12683 12684 /** 12685 * @deprecated 12686 * @use myArr.findIndex(item => item === needle); 12687 */ 12688 array_search: function(needle, haystack) 12689 { 12690 for(var i=0; i<haystack.length; i++) 12691 { 12692 if(haystack[i] == needle) 12693 return i; 12694 } 12695 return -1; 12696 }, 12697 12698 object_search_key: function(needle, haystack) 12699 { 12700 if (typeof haystack[needle] != 'undefined') 12701 return haystack[needle]; 12702 12703 for(var i in haystack) 12704 { 12705 if (typeof haystack[i] == "object") 12706 { 12707 var result = BX.util.object_search_key(needle, haystack[i]); 12708 if (result !== false) 12709 return result; 12710 } 12711 } 12712 return false; 12713 }, 12714 12715 trim: function(s) 12716 { 12717 if (BX.type.isString(s)) 12718 { 12719 return s.trim(); 12720 } 12721 12722 return s; 12723 }, 12724 12725 urlencode: function(s){return encodeURIComponent(s);}, 12726 12727 // it may also be useful. via sVD. 12728 deleteFromArray: function(ar, ind) {return ar.slice(0, ind).concat(ar.slice(ind + 1));}, 12729 insertIntoArray: function(ar, ind, el) {return ar.slice(0, ind).concat([el]).concat(ar.slice(ind));}, 12730 12731 htmlspecialchars: function(str) 12732 { 12733 return BX.Text.encode(str); 12734 }, 12735 12736 htmlspecialcharsback: function(str) 12737 { 12738 return BX.Text.decode(str); 12739 }, 12740 12741 // Quote regular expression characters plus an optional character 12742 preg_quote: function(str, delimiter) 12743 { 12744 if(!str.replace) 12745 return str; 12746 return str.replace(new RegExp('[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\' + (delimiter || '') + '-]', 'g'), '\\$&'); 12747 }, 12748 12749 jsencode: function(str) 12750 { 12751 if (!str || !str.replace) 12752 return str; 12753 12754 var escapes = 12755 [ 12756 { c: "\\\\", r: "\\\\" }, // should be first 12757 { c: "\\t", r: "\\t" }, 12758 { c: "\\n", r: "\\n" }, 12759 { c: "\\r", r: "\\r" }, 12760 { c: "\"", r: "\\\"" }, 12761 { c: "'", r: "\\'" }, 12762 { c: "<", r: "\\x3C" }, 12763 { c: ">", r: "\\x3E" }, 12764 { c: "\\u2028", r: "\\u2028" }, 12765 { c: "\\u2029", r: "\\u2029" } 12766 ]; 12767 for (var i = 0; i < escapes.length; i++) 12768 str = str.replace(new RegExp(escapes[i].c, 'g'), escapes[i].r); 12769 return str; 12770 }, 12771 12772 getCssName: function(jsName) 12773 { 12774 if (!BX.type.isNotEmptyString(jsName)) 12775 { 12776 return ""; 12777 } 12778 12779 return jsName.replace(/[A-Z]/g, function(match) { 12780 return "-" + match.toLowerCase(); 12781 }); 12782 }, 12783 12784 getJsName: function(cssName) 12785 { 12786 var regex = /\-([a-z]){1}/g; 12787 if (regex.test(cssName)) 12788 { 12789 return cssName.replace(regex, function(match, letter) { 12790 return letter.toUpperCase(); 12791 }); 12792 } 12793 12794 return cssName; 12795 }, 12796 12797 nl2br: function(str) 12798 { 12799 if (!str || !str.replace) 12800 return str; 12801 12802 return str.replace(/([^>])\n/g, '$1<br/>'); 12803 }, 12804 12805 /** 12806 * @deprecated 12807 * @use .padStart() / .padEnd() 12808 * @param input 12809 * @param pad_length 12810 * @param pad_string 12811 * @param pad_type 12812 * @return {*} 12813 */ 12814 str_pad: function(input, pad_length, pad_string, pad_type) 12815 { 12816 pad_string = pad_string || ' '; 12817 pad_type = pad_type || 'right'; 12818 input = input.toString(); 12819 12820 if (pad_type === 'left') 12821 { 12822 return BX.util.str_pad_left(input, pad_length, pad_string); 12823 } 12824 12825 return BX.util.str_pad_right(input, pad_length, pad_string); 12826 }, 12827 12828 str_pad_left: function(input, pad_length, pad_string) 12829 { 12830 return input.toString().padStart(pad_length, pad_string); 12831 }, 12832 12833 str_pad_right: function(input, pad_length, pad_string) 12834 { 12835 return input.toString().padEnd(pad_length, pad_string); 12836 }, 12837 12838 strip_tags: function(str) 12839 { 12840 return str.split(/<[^>]+>/g).join(''); 12841 }, 12842 12843 strip_php_tags: function(str) 12844 { 12845 return str.replace(/<\?(.|[\r\n])*?\?>/g, ''); 12846 }, 12847 12848 popup: function(url, width, height) 12849 { 12850 var w, h; 12851 if(BX.browser.IsOpera()) 12852 { 12853 w = document.body.offsetWidth; 12854 h = document.body.offsetHeight; 12855 } 12856 else 12857 {
12858 w = screen.width; 12859 h = screen.height; 12860 } 12861 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)); 12862 }, 12863 12864 shuffle: function(array) 12865 { 12866 var temporaryValue, randomIndex; 12867 var currentIndex = array.length; 12868 12869 while (0 !== currentIndex) 12870 { 12871 randomIndex = Math.floor(Math.random() * currentIndex); 12872 currentIndex -= 1; 12873 12874 temporaryValue = array[currentIndex]; 12875 array[currentIndex] = array[randomIndex]; 12876 array[randomIndex] = temporaryValue; 12877 } 12878 12879 return array; 12880 }, 12881 12882 // BX.util.objectSort(object, sortBy, sortDir) - Sort object by property 12883 // function params: 1 - object for sort, 2 - sort by property, 3 - sort direction (asc/desc) 12884 // return: sort array [[objectElement], [objectElement]] in sortDir direction 12885 12886 // example: BX.util.objectSort({'L1': {'name': 'Last'}, 'F1': {'name': 'First'}}, 'name', 'asc'); 12887 // return: [{'name' : 'First'}, {'name' : 'Last'}] 12888 objectSort: function(object, sortBy, sortDir) 12889 { 12890 sortDir = sortDir == 'asc'? 'asc': 'desc'; 12891 12892 var arItems = [], i; 12893 for (i in object) 12894 { 12895 if (object.hasOwnProperty(i) && object[i][sortBy]) 12896 { 12897 arItems.push([i, object[i][sortBy]]); 12898 } 12899 } 12900 12901 if (sortDir == 'asc') 12902 { 12903 arItems.sort(function(i, ii) { 12904 var s1, s2; 12905 if (BX.type.isDate(i[1])) 12906 { 12907 s1 = i[1].getTime(); 12908 } 12909 else if (!isNaN(i[1])) 12910 { 12911 s1 = parseInt(i[1]); 12912 } 12913 else 12914 { 12915 s1 = i[1].toString().toLowerCase(); 12916 } 12917 12918 if (BX.type.isDate(ii[1])) 12919 { 12920 s2 = ii[1].getTime(); 12921 } 12922 else if (!isNaN(ii[1])) 12923 { 12924 s2 = parseInt(ii[1]); 12925 } 12926 else 12927 { 12928 s2 = ii[1].toString().toLowerCase(); 12929 } 12930 12931 if (s1 > s2) 12932 return 1; 12933 else if (s1 < s2) 12934 return -1; 12935 else 12936 return 0; 12937 }); 12938 } 12939 else 12940 { 12941 arItems.sort(function(i, ii) { 12942 var s1, s2; 12943 if (BX.type.isDate(i[1])) 12944 { 12945 s1 = i[1].getTime(); 12946 } 12947 else if (!isNaN(i[1])) 12948 { 12949 s1 = parseInt(i[1]); 12950 } 12951 else 12952 { 12953 s1 = i[1].toString().toLowerCase(); 12954 } 12955 12956 if (BX.type.isDate(ii[1])) 12957 { 12958 s2 = ii[1].getTime(); 12959 } 12960 else if (!isNaN(ii[1])) 12961 { 12962 s2 = parseInt(ii[1]); 12963 } 12964 else 12965 { 12966 s2 = ii[1].toString().toLowerCase(); 12967 } 12968 12969 if (s1 < s2) 12970 return 1; 12971 else if (s1 > s2) 12972 return -1; 12973 else 12974 return 0; 12975 }); 12976 } 12977 12978 var arReturnArray = Array(); 12979 for (i = 0; i < arItems.length; i++) 12980 { 12981 arReturnArray.push(object[arItems[i][0]]); 12982 } 12983 12984 return arReturnArray; 12985 }, 12986 12987 objectMerge: function() 12988 { 12989 return BX.mergeEx.apply(window, arguments); 12990 }, 12991 12992 objectClone : function(object) 12993 { 12994 return BX.clone(object, true); 12995 }, 12996 12997 // #fdf9e5 => {r=253, g=249, b=229} 12998 hex2rgb: function(color) 12999 { 13000 var rgb = color.replace(/[# ]/g,"").replace(/^(.)(.)(.)$/,'$1$1$2$2$3$3').match(/.{2}/g); 13001 for (var i=0; i<3; i++) 13002 { 13003 rgb[i] = parseInt(rgb[i], 16); 13004 } 13005 return {'r':rgb[0],'g':rgb[1],'b':rgb[2]}; 13006 }, 13007 13008 /** 13009 * @deprecated 13010 * @use BX.Uri 13011 * @param url 13012 * @param param 13013 * @return {string} 13014 */ 13015 remove_url_param: function(url, param) 13016 { 13017 return BX.Uri.removeParam(url, param); 13018 }, 13019 13020 /* 13021 {'param1': 'value1', 'param2': 'value2'} 13022 */ 13023 /** 13024 * @deprecated 13025 * @use BX.Uri 13026 * @param url 13027 * @param params 13028 * @return {string} 13029 */ 13030 add_url_param: function(url, params) 13031 { 13032 var preparedParams = Object.entries(params).reduce(function(acc, item) { 13033 acc[item[0]] = BX.type.isArray(item[1]) ? item[1].join() : item[1]; 13034 return acc; 13035 }, {}); 13036 13037 return BX.Uri.addParam(url, preparedParams); 13038 }, 13039 13040 /* 13041 {'param1': 'value1', 'param2': 'value2'} 13042 */ 13043 buildQueryString: function(params) 13044 { 13045 var result = ''; 13046 for (var key in params) 13047 { 13048 var value = params[key]; 13049 if(BX.type.isArray(value)) 13050 { 13051 value.forEach(function(valueElement, index) 13052 { 13053 result += encodeURIComponent(key + "[" + index + "]") + "=" + encodeURIComponent(valueElement) + "&"; 13054 }); 13055 } 13056 else 13057 { 13058 result += encodeURIComponent(key) + "=" + encodeURIComponent(value) + "&"; 13059 } 13060 } 13061 13062 if(result.length > 0) 13063 { 13064 result = result.substr(0, result.length - 1); 13065 } 13066 return result; 13067 }, 13068 13069 even: function(digit) 13070 { 13071 return (parseInt(digit) % 2 == 0); 13072 }, 13073 13074 hashCode: function(str) 13075 { 13076 if(!BX.type.isNotEmptyString(str)) 13077 { 13078 return 0; 13079 } 13080 13081 var hash = 0; 13082 for (var i = 0; i < str.length; i++) 13083 { 13084 var c = str.charCodeAt(i); 13085 hash = ((hash << 5) - hash) + c; 13086 hash = hash & hash; 13087 } 13088 return hash; 13089 }, 13090 13091 getRandomString: function (length) 13092 { 13093 return BX.Text.getRandom(length); 13094 }, 13095 13096 number_format: function(number, decimals, dec_point, thousands_sep) 13097 { 13098 var i, j, kw, kd, km, sign = ''; 13099 decimals = Math.abs(decimals); 13100 if (isNaN(decimals) || decimals < 0) 13101 { 13102 decimals = 2; 13103 } 13104 dec_point = dec_point || ','; 13105 if (typeof thousands_sep === 'undefined') 13106 thousands_sep = '.'; 13107 13108 number = (+number || 0).toFixed(decimals); 13109 if (number < 0) 13110 { 13111 sign = '-'; 13112 number = -number; 13113 } 13114 13115 i = parseInt(number, 10) + ''; 13116 j = (i.length > 3 ? i.length % 3 : 0); 13117 13118 km = (j ? i.substr(0, j) + thousands_sep : ''); 13119 kw = i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousands_sep); 13120 kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).replace(/-/, '0').slice(2) : ''); 13121 13122 return sign + km + kw + kd; 13123 }, 13124 13125 getExtension: function (url) 13126 { 13127 url = url || ""; 13128 var items = url.split("?")[0].split("."); 13129 return items[items.length-1].toLowerCase(); 13130 }, 13131 addObjectToForm: function(object, form, prefix) 13132 { 13133 if(!BX.type.isString(prefix)) 13134 { 13135 prefix = ""; 13136 } 13137 13138 for(var key in object) 13139 { 13140 if(!object.hasOwnProperty(key)) 13141 { 13142 continue; 13143 } 13144 13145 var value = object[key]; 13146 var name = prefix !== "" ? (prefix + "[" + key + "]") : key; 13147 if(BX.type.isArray(value)) 13148 { 13149 var obj = {}; 13150 for(var i = 0; i < value.length; i++) 13151 { 13152 obj[i] = value[i]; 13153 } 13154 13155 BX.util.addObjectToForm(obj, form, name); 13156 } 13157 else if(BX.type.isPlainObject(value)) 13158 { 13159 BX.util.addObjectToForm(value, form, name); 13160 } 13161 else 13162 { 13163 value = BX.type.isFunction(value.toString) ? value.toString() : ""; 13164 if(value !== "") 13165 { 13166 form.appendChild(BX.create("INPUT", { attrs: { type: "hidden", name: name, value: value } })); 13167 } 13168 } 13169 } 13170 }, 13171 13172 observe: function(object, enable) 13173 {
13174 console.error('BX.util.observe: function is no longer supported by browser.'); 13175 return false; 13176 }, 13177 13178 escapeRegExp: function(str) 13179 { 13180 return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); 13181 } 13182 }; 13183 13184 BX.validation = { 13185 checkIfEmail: function(s) 13186 { 13187 var atom = "[=a-z0-9_+~'!$&*^`|#%/?{}-]"; 13188 return (new RegExp('^\\s*'+atom+'+(\\.'+atom+'+)*@([a-z0-9-]+\\.)+[a-z0-9-]{2,20}\\s*$', 'i')).test(s); 13189 }, 13190 checkIfPhone: function(s) 13191 { 13192 var regexp = new RegExp( 13193 typeof(BX.PhoneNumber) === "undefined" 13194 ? BX.PhoneNumber.getValidNumberPattern() 13195 : '^\\s*\\+?\s*[0-9(-)\\s]+\\s*$', 13196 'i' 13197 ); 13198 return regexp.test(s); 13199 } 13200 }; 13201 13202 BX.prop = 13203 { 13204 get: function(object, key, defaultValue) 13205 { 13206 return object && object.hasOwnProperty(key) ? object[key] : defaultValue; 13207 }, 13208 getObject: function(object, key, defaultValue) 13209 { 13210 return object && BX.type.isPlainObject(object[key]) ? object[key] : defaultValue; 13211 }, 13212 getElementNode: function(object, key, defaultValue) 13213 { 13214 return object && BX.type.isElementNode(object[key]) ? object[key] : defaultValue; 13215 }, 13216 getArray: function(object, key, defaultValue) 13217 { 13218 return object && BX.type.isArray(object[key]) ? object[key] : defaultValue; 13219 }, 13220 getFunction: function(object, key, defaultValue) 13221 { 13222 return object && BX.type.isFunction(object[key]) ? object[key] : defaultValue; 13223 }, 13224 getNumber: function(object, key, defaultValue) 13225 { 13226 if(!(object && object.hasOwnProperty(key))) 13227 { 13228 return defaultValue; 13229 } 13230 13231 var value = object[key]; 13232 if(BX.type.isNumber(value)) 13233 { 13234 return value; 13235 } 13236 13237 value = parseFloat(value); 13238 return !isNaN(value) ? value : defaultValue; 13239 }, 13240 getInteger: function(object, key, defaultValue) 13241 { 13242 if(!(object && object.hasOwnProperty(key))) 13243 { 13244 return defaultValue; 13245 } 13246 13247 var value = object[key]; 13248 if(BX.type.isNumber(value)) 13249 { 13250 return value; 13251 } 13252 13253 value = parseInt(value); 13254 return !isNaN(value) ? value : defaultValue; 13255 }, 13256 getBoolean: function(object, key, defaultValue) 13257 { 13258 if(!(object && object.hasOwnProperty(key))) 13259 { 13260 return defaultValue; 13261 } 13262 13263 var value = object[key]; 13264 return (BX.type.isBoolean(value) 13265 ? value 13266 : (BX.type.isString(value) ? (value.toLowerCase() === "true") : !!value) 13267 ); 13268 }, 13269 getString: function(object, key, defaultValue) 13270 { 13271 if(!(object && object.hasOwnProperty(key))) 13272 { 13273 return defaultValue; 13274 } 13275 13276 var value = object[key]; 13277 return BX.type.isString(value) ? value : (value ? value.toString() : ''); 13278 }, 13279 extractDate: function(datetime) 13280 { 13281 if(!BX.type.isDate(datetime)) 13282 { 13283 datetime = new Date(); 13284 } 13285 13286 datetime.setHours(0); 13287 datetime.setMinutes(0); 13288 datetime.setSeconds(0); 13289 datetime.setMilliseconds(0); 13290 13291 return datetime; 13292 } 13293 }; 13294 13295 BX.isNodeInDom = function(node, doc) 13296 { 13297 return node === (doc || document) ? true : 13298 (node.parentNode ? BX.isNodeInDom(node.parentNode) : false); 13299 }; 13300 13301 BX.isNodeHidden = function(node) 13302 { 13303 if (node === document) 13304 return false; 13305 else if (BX.style(node, 'display') == 'none') 13306 return true; 13307 else 13308 return (node.parentNode ? BX.isNodeHidden(node.parentNode) : true); 13309 }; 13310 13311 BX.evalPack = function(code) 13312 { 13313 while (code.length > 0) 13314 { 13315 var c = code.shift(); 13316 13317 if (c.TYPE == 'SCRIPT_EXT' || c.TYPE == 'SCRIPT_SRC') 13318 { 13319 BX.loadScript(c.DATA, function() {BX.evalPack(code)}); 13320 return; 13321 } 13322 else if (c.TYPE == 'SCRIPT') 13323 { 13324 BX.evalGlobal(c.DATA); 13325 } 13326 } 13327 }; 13328 13329 BX.evalGlobal = function(data) 13330 { 13331 if (data) 13332 { 13333 var head = document.getElementsByTagName("head")[0] || document.documentElement, 13334 script = document.createElement("script"); 13335 13336 script.type = "text/javascript"; 13337 13338 if (!BX.browser.IsIE()) 13339 { 13340 script.appendChild(document.createTextNode(data)); 13341 } 13342 else 13343 { 13344 script.text = data; 13345 } 13346 13347 head.insertBefore(script, head.firstChild); 13348 head.removeChild(script); 13349 } 13350 }; 13351 13352 BX.garbage = function(call, thisObject) 13353 { 13354 garbageCollectors.push({callback: call, context: thisObject}); 13355 }; 13356 13357 BX.GetDocElement = function (pDoc) 13358 { 13359 pDoc = pDoc || document; 13360 return (BX.browser.IsDoctype(pDoc) ? pDoc.documentElement : pDoc.body); 13361 }; 13362 13363 BX.scrollTop = function(node, val){ 13364 if(typeof val != 'undefined'){ 13365 13366 if(node == window){ 13367 throw new Error('scrollTop() for window is not implemented'); 13368 }else 13369 node.scrollTop = parseInt(val); 13370 13371 }else{ 13372 13373 if(node == window) 13374 return BX.GetWindowScrollPos().scrollTop; 13375 13376 return node.scrollTop; 13377 } 13378 }; 13379 13380 BX.scrollLeft = function(node, val){ 13381 if(typeof val != 'undefined'){ 13382 13383 if(node == window){ 13384 throw new Error('scrollLeft() for window is not implemented'); 13385 }else 13386 node.scrollLeft = parseInt(val); 13387 13388 }else{ 13389 13390 if(node == window) 13391 return BX.GetWindowScrollPos().scrollLeft; 13392 13393 return node.scrollLeft; 13394 } 13395 }; 13396 13397 BX.hide_object = function(ob) 13398 { 13399 ob = BX(ob); 13400 ob.style.position = 'absolute'; 13401 ob.style.top = '-1000px'; 13402 ob.style.left = '-1000px'; 13403 ob.style.height = '10px'; 13404 ob.style.width = '10px'; 13405 }; 13406 13407 BX.is_relative = function(el) 13408 { 13409 var p = BX.style(el, 'position'); 13410 return p == 'relative' || p == 'absolute'; 13411 }; 13412 13413 BX.is_float = function(el) 13414 { 13415 var p = BX.style(el, 'float'); 13416 return p == 'right' || p == 'left'; 13417 }; 13418 13419 BX.is_fixed = function(el) 13420 { 13421 var p = BX.style(el, 'position'); 13422 return p == 'fixed'; 13423 }; 13424 13425 BX.width = function(node, val){ 13426 if(typeof val != 'undefined') 13427 BX.style(node, 'width', parseInt(val)+'px'); 13428 else{ 13429 13430 if(node == window) 13431 return window.innerWidth; 13432 13433 //return parseInt(BX.style(node, 'width')); 13434 return BX.pos(node).width; 13435 } 13436 }; 13437 13438 BX.height = function(node, val){ 13439 if(typeof val != 'undefined') 13440 BX.style(node, 'height', parseInt(val)+'px'); 13441 else{ 13442 13443 if(node == window) 13444 return window.innerHeight; 13445 13446 //return parseInt(BX.style(node, 'height')); 13447 return BX.pos(node).height; 13448 } 13449 }; 13450 13451 BX.align = function(pos, w, h, type) 13452 { 13453 if (type) 13454 type = type.toLowerCase(); 13455 else 13456 type = ''; 13457 13458 var pDoc = document; 13459 if (BX.type.isElementNode(pos)) 13460 { 13461 pDoc = pos.ownerDocument; 13462 pos = BX.pos(pos); 13463 } 13464 13465 var x = pos["left"], y = pos["bottom"]; 13466 13467 var scroll = BX.GetWindowScrollPos(pDoc); 13468 var size = BX.GetWindowInnerSize(pDoc); 13469 13470 if((size.innerWidth + scroll.scrollLeft) - (pos["left"] + w) < 0) 13471 { 13472 if(pos["right"] - w >= 0 ) 13473 x = pos["right"] - w; 13474 else 13475 x = scroll.scrollLeft; 13476 } 13477
13478 if(((size.innerHeight + scroll.scrollTop) - (pos["bottom"] + h) < 0) || ~type.indexOf('top')) 13479 { 13480 if(pos["top"] - h >= 0 || ~type.indexOf('top')) 13481 y = pos["top"] - h; 13482 else 13483 y = scroll.scrollTop; 13484 } 13485 13486 return {'left':x, 'top':y}; 13487 }; 13488 13489 BX.scrollToNode = function(node) 13490 { 13491 var obNode = BX(node); 13492 13493 if (obNode.scrollIntoView) 13494 obNode.scrollIntoView(true); 13495 else 13496 { 13497 var arNodePos = BX.pos(obNode); 13498 window.scrollTo(arNodePos.left, arNodePos.top); 13499 } 13500 }; 13501 13502 /* non-xhr loadings */ 13503 BX.showWait = function(node, msg) 13504 { 13505 node = BX(node) || document.body || document.documentElement; 13506 msg = msg || BX.message('JS_CORE_LOADING'); 13507 13508 var container_id = node.id || Math.random(); 13509 13510 var obMsg = node.bxmsg = document.body.appendChild(BX.create('DIV', { 13511 props: { 13512 id: 'wait_' + container_id 13513 }, 13514 style: { 13515 background: 'url("/bitrix/js/main/core/images/wait.gif") no-repeat scroll 10px center #fcf7d1', 13516 border: '1px solid #E1B52D', 13517 color: 'black', 13518 fontFamily: 'Verdana,Arial,sans-serif', 13519 fontSize: '11px', 13520 padding: '10px 30px 10px 37px', 13521 position: 'absolute', 13522 textAlign:'center' 13523 }, 13524 text: msg 13525 })); 13526 13527 BX.ZIndexManager.register(obMsg); 13528 BX.ZIndexManager.bringToFront(obMsg); 13529 13530 setTimeout(BX.delegate(_adjustWait, node), 10); 13531 13532 lastWait[lastWait.length] = obMsg; 13533 return obMsg; 13534 }; 13535 13536 BX.closeWait = function(node, obMsg) 13537 { 13538 if(node && !obMsg) 13539 obMsg = node.bxmsg; 13540 if(node && !obMsg && BX.hasClass(node, 'bx-core-waitwindow')) 13541 obMsg = node; 13542 if(node && !obMsg) 13543 obMsg = BX('wait_' + node.id); 13544 if(!obMsg) 13545 obMsg = lastWait.pop(); 13546 13547 if (obMsg && obMsg.parentNode) 13548 { 13549 for (var i=0,len=lastWait.length;i<len;i++) 13550 { 13551 if (obMsg == lastWait[i]) 13552 { 13553 lastWait = BX.util.deleteFromArray(lastWait, i); 13554 break; 13555 } 13556 } 13557 13558 BX.ZIndexManager.unregister(obMsg); 13559 obMsg.parentNode.removeChild(obMsg); 13560 if (node) node.bxmsg = null; 13561 BX.cleanNode(obMsg, true); 13562 } 13563 }; 13564 13565 BX.setJSList = function(scripts) 13566 { 13567 if (BX.type.isArray(scripts)) 13568 { 13569 scripts = scripts.map(function(script) { 13570 return normalizeUrl(script) 13571 }); 13572 13573 jsList = jsList.concat(scripts); 13574 } 13575 }; 13576 13577 BX.getJSList = function() 13578 { 13579 initJsList(); 13580 return jsList; 13581 }; 13582 13583 BX.setCSSList = function(cssFiles) 13584 { 13585 if (BX.type.isArray(cssFiles)) 13586 { 13587 cssFiles = cssFiles.map(function(cssFile) { 13588 return normalizeUrl(cssFile); 13589 }); 13590 13591 cssList = cssList.concat(cssFiles); 13592 } 13593 }; 13594 13595 BX.getCSSList = function() 13596 { 13597 initCssList(); 13598 return cssList; 13599 }; 13600 13601 BX.getJSPath = function(js) 13602 { 13603 return js.replace(/^(http[s]*:)*\/\/[^\/]+/i, ''); 13604 }; 13605 13606 BX.getCSSPath = function(css) 13607 { 13608 return css.replace(/^(http[s]*:)*\/\/[^\/]+/i, ''); 13609 }; 13610 13611 BX.getCDNPath = function(path) 13612 { 13613 return path; 13614 }; 13615 13616 BX.loadScript = function(script, callback, doc) 13617 { 13618 if (BX.type.isString(script)) 13619 { 13620 script = [script]; 13621 } 13622 13623 return BX.load(script, callback, doc); 13624 }; 13625 13626 BX.loadCSS = function(css, doc, win) 13627 { 13628 if (BX.type.isString(css)) 13629 { 13630 css = [css]; 13631 } 13632 13633 if (BX.type.isArray(css)) 13634 { 13635 css = css.map(function(url) { 13636 return { url: url, ext: "css" } 13637 }); 13638 13639 BX.load(css, null, doc); 13640 } 13641 }; 13642 13643 const LOADING = 3; 13644 const LOADED = 4; 13645 const assets = {}; 13646 const loadingAssetCallbacks = {}; 13647 13648 BX.load = function(items, callback, doc) 13649 { 13650 if (!BX.isReady) 13651 { 13652 var _args = arguments; 13653 BX.ready(function() { 13654 BX.load.apply(this, _args); 13655 }); 13656 13657 return null; 13658 } 13659 13660 doc = doc || document; 13661 13662 callback = BX.Type.isFunction(callback) ? callback : () => {}; 13663 13664 return loadAsync(items, callback, doc); 13665 }; 13666 13667 function loadAsync(items, callback, doc) 13668 { 13669 if (!BX.type.isArray(items)) 13670 { 13671 callback(); 13672 13673 return; 13674 } 13675 13676 function onLoad() 13677 { 13678 const nextAsset = queue.shift(); 13679 if (nextAsset) 13680 { 13681 load(nextAsset, onLoad, doc); 13682 } 13683 else if (allLoaded()) 13684 { 13685 callback(); 13686 } 13687 } 13688 13689 function allLoaded() 13690 { 13691 for (const name in assetMap) 13692 { 13693 if (assetMap[name].state !== LOADED) 13694 { 13695 return false; 13696 } 13697 } 13698 13699 return true; 13700 } 13701 13702 const queue = []; 13703 const assetMap = {}; 13704 items.forEach(item => { 13705 const asset = getAsset(item); 13706 if (asset && asset.state !== LOADED) 13707 { 13708 queue.push(asset); 13709 assetMap[asset.name] = asset; 13710 } 13711 }); 13712 13713 if (queue.length > 0) 13714 {
13715 const maxParallelLoads = 6; 13716 const parallelLoads = Math.min(queue.length, maxParallelLoads); 13717 const firstPackage = queue.splice(0, parallelLoads); 13718 firstPackage.forEach(asset => { 13719 load(asset, onLoad, doc); 13720 }); 13721 } 13722 else 13723 { 13724 callback(); 13725 } 13726 } 13727 13728 function load(asset, callback, doc) 13729 { 13730 callback = callback || BX.DoNothing; 13731 13732 if (asset.state === LOADED) 13733 { 13734 callback(); 13735 return; 13736 } 13737 13738 if (asset.state === LOADING) 13739 { 13740 if (!BX.Type.isArray(loadingAssetCallbacks[asset.name])) 13741 { 13742 loadingAssetCallbacks[asset.name] = []; 13743 } 13744 13745 loadingAssetCallbacks[asset.name].push(callback); 13746 13747 return; 13748 } 13749 13750 asset.state = LOADING; 13751 13752 loadAsset( 13753 asset, 13754 function () { 13755 asset.state = LOADED; 13756 callback(); 13757 if (BX.Type.isArrayFilled(loadingAssetCallbacks[asset.name])) 13758 { 13759 for (const cb of loadingAssetCallbacks[asset.name]) 13760 { 13761 cb(); 13762 } 13763 } 13764 13765 delete loadingAssetCallbacks[asset.name]; 13766 }, 13767 doc 13768 ); 13769 } 13770 13771 function loadAsset(asset, callback, doc) 13772 { 13773 callback = callback || BX.DoNothing; 13774 13775 function error(event) 13776 { 13777 window.clearTimeout(asset.errorTimeout); 13778 window.clearTimeout(asset.cssTimeout); 13779 ele.onload = ele.onreadystatechange = ele.onerror = null; 13780 callback(); 13781 } 13782 13783 function process(event) 13784 { 13785 event = event || window.event; 13786 if (event.type === "load" || (/loaded|complete/.test(ele.readyState) && (!doc.documentMode || doc.documentMode < 9))) 13787 { 13788 window.clearTimeout(asset.errorTimeout); 13789 window.clearTimeout(asset.cssTimeout); 13790 ele.onload = ele.onreadystatechange = ele.onerror = null; 13791 callback(); 13792 } 13793 } 13794 13795 function isCssLoaded() 13796 { 13797 if (asset.state !== LOADED && asset.cssRetries <= 20) 13798 { 13799 for (var i = 0, l = doc.styleSheets.length; i < l; i++) 13800 { 13801 if (doc.styleSheets[i].href === ele.href) 13802 { 13803 process({"type": "load"}); 13804 return; 13805 } 13806 } 13807 13808 asset.cssRetries++; 13809 asset.cssTimeout = window.setTimeout(isCssLoaded, 250); 13810 } 13811 } 13812 13813 let ele = null; 13814 const ext = BX.type.isNotEmptyString(asset.ext) ? asset.ext : BX.util.getExtension(asset.url); 13815 13816 if (ext === "css") 13817 { 13818 ele = doc.createElement("link"); 13819 ele.type = "text/" + (asset.type || "css"); 13820 ele.rel = "stylesheet"; 13821 ele.href = asset.url; 13822 13823 asset.cssRetries = 0; 13824 asset.cssTimeout = window.setTimeout(isCssLoaded, 500); 13825 } 13826 else 13827 { 13828 ele = doc.createElement("script"); 13829 ele.type = "text/" + (asset.type || "javascript"); 13830 ele.src = asset.url; 13831 } 13832 13833 ele.onload = ele.onreadystatechange = process; 13834 ele.onerror = error; 13835 13836 ele.async = false; 13837 ele.defer = false; 13838 13839 asset.errorTimeout = window.setTimeout(function () { 13840 error({type: "timeout"}); 13841 }, 7000); 13842 13843 if (ext === "css") 13844 { 13845 cssList.push(normalizeMinUrl(normalizeUrl(asset.url))); 13846 } 13847 else 13848 { 13849 jsList.push(normalizeMinUrl(normalizeUrl(asset.url))); 13850 } 13851 13852 let templateLink = null; 13853 const head = doc.head || doc.getElementsByTagName("head")[0]; 13854 if (ext === "css" && (templateLink = getTemplateLink(head)) !== null) 13855 { 13856 templateLink.parentNode.insertBefore(ele, templateLink); 13857 } 13858 else 13859 { 13860 head.insertBefore(ele, head.lastChild); 13861 } 13862 } 13863 13864 function getAsset(item) 13865 { 13866 var asset = {}; 13867 if (typeof item === "object") 13868 { 13869 asset = item; 13870 asset.name = asset.name ? asset.name : BX.util.hashCode(item.url); 13871 } 13872 else 13873 { 13874 asset = { name: BX.util.hashCode(item), url : item }; 13875 } 13876 13877 var ext = BX.type.isNotEmptyString(asset.ext) ? asset.ext : BX.util.getExtension(asset.url); 13878 if ((ext === "css" && isCssLoaded(asset.url)) || isScriptLoaded(asset.url)) 13879 { 13880 asset.state = LOADED; 13881 } 13882 13883 var existing = assets[asset.name]; 13884 if (existing && existing.url === asset.url) 13885 { 13886 return existing; 13887 } 13888 13889 assets[asset.name] = asset; 13890 13891 return asset; 13892 } 13893 13894 function normalizeUrl(url) 13895 { 13896 if (!BX.type.isNotEmptyString(url)) 13897 { 13898 return ""; 13899 } 13900 13901 url = BX.getJSPath(url); 13902 url = url.replace(/\?[0-9]*$/, ""); 13903 13904 return url; 13905 } 13906 13907 function normalizeMinUrl(url) 13908 { 13909 if (!BX.type.isNotEmptyString(url)) 13910 { 13911 return ""; 13912 } 13913 13914 var minPos = url.indexOf(".min"); 13915 return minPos >= 0 ? url.substr(0, minPos) + url.substr(minPos + 4) : url; 13916 } 13917 13918 function isCssLoaded(fileSrc) 13919 { 13920 initCssList(); 13921 13922 fileSrc = normalizeUrl(fileSrc); 13923 var fileSrcMin = normalizeMinUrl(fileSrc); 13924 13925 return (fileSrc !== fileSrcMin && BX.util.in_array(fileSrcMin, cssList)) || BX.util.in_array(fileSrc, cssList); 13926 } 13927 13928 function initCssList() 13929 { 13930 if(!cssInit) 13931 { 13932 var linksCol = document.getElementsByTagName('link'); 13933 13934 if(!!linksCol && linksCol.length > 0) 13935 { 13936 for(var i = 0; i < linksCol.length; i++) 13937 { 13938 var href = linksCol[i].getAttribute('href'); 13939 if (BX.type.isNotEmptyString(href)) 13940 { 13941 href = normalizeMinUrl(normalizeUrl(href)); 13942 cssList.push(href); 13943 } 13944 } 13945 } 13946 cssInit = true; 13947 } 13948 } 13949 13950 function getTemplateLink(head) 13951 { 13952 var findLink = function(tag) 13953 { 13954 var links = head.getElementsByTagName(tag); 13955 for (var i = 0, length = links.length; i < length; i++) 13956 { 13957 var templateStyle = links[i].getAttribute("data-template-style"); 13958 if (BX.type.isNotEmptyString(templateStyle) && templateStyle == "true") 13959 { 13960 return links[i]; 13961 } 13962 } 13963 13964 return null; 13965 }; 13966 13967 var link = findLink("link"); 13968 if (link === null) 13969 { 13970 link = findLink("style"); 13971 } 13972 13973 return link; 13974 } 13975 13976 function isScriptLoaded(fileSrc) 13977 { 13978 initJsList(); 13979 13980 fileSrc = normalizeUrl(fileSrc); 13981 var fileSrcMin = normalizeMinUrl(fileSrc); 13982 13983 return (fileSrc !== fileSrcMin && BX.util.in_array(fileSrcMin, jsList)) || BX.util.in_array(fileSrc, jsList); 13984 } 13985 13986 function initJsList() 13987 { 13988 if(!jsInit) 13989 { 13990 var scriptCol = document.getElementsByTagName('script'); 13991 13992 if(!!scriptCol && scriptCol.length > 0) 13993 { 13994 for(var i=0; i<scriptCol.length; i++) 13995 { 13996 var src = scriptCol[i].getAttribute('src'); 13997 13998 if (BX.type.isNotEmptyString(src)) 13999 { 14000 src = normalizeMinUrl(normalizeUrl(src)); 14001 jsList.push(src); 14002 } 14003 } 14004 } 14005 jsInit = true; 14006 } 14007 } 14008 14009 function reloadInternal(back_url, bAddClearCache) 14010 { 14011 if (back_url === true) 14012 { 14013 bAddClearCache = true; 14014 back_url = null; 14015 } 14016 14017 var topWindow = (function() { 14018 if (BX.PageObject && BX.PageObject.getRootWindow) 14019 { 14020 return BX.PageObject.getRootWindow(); 14021 } 14022 14023 return window.top; 14024 })(); 14025 var new_href = back_url || topWindow.location.href; 14026 14027 var hashpos = new_href.indexOf('#'), hash = ''; 14028 14029 if (hashpos != -1) 14030 { 14031 hash = new_href.substr(hashpos); 14032 new_href = new_href.substr(0, hashpos); 14033 } 14034 14035 if (bAddClearCache && new_href.indexOf('clear_cache=Y') < 0) 14036 new_href += (new_href.indexOf('?') == -1 ? '?' : '&') + 'clear_cache=Y'; 14037 14038 if (hash) 14039 { 14040 // hack for clearing cache in ajax mode components with history emulation 14041 if (bAddClearCache && (hash.substr(0, 5) == 'view/' || hash.substr(0, 6) == '#view/') && hash.indexOf('clear_cache%3DY') < 0) 14042 hash += (hash.indexOf('%3F') == -1 ? '%3F' : '%26') + 'clear_cache%3DY'; 14043 14044 new_href = new_href.replace(/(\?|\&)_r=[\d]*/, ''); 14045 new_href += (new_href.indexOf('?') == -1 ? '?' : '&') + '_r='+Math.round(Math.random()*10000) + hash; 14046 } 14047 14048 topWindow.location.href = new_href; 14049 } 14050 14051 BX.reload = function(back_url, bAddClearCache) 14052 { 14053 if (window !== window.top) 14054 { 14055 BX.Runtime 14056 .loadExtension('main.pageobject') 14057 .then(function() { 14058 reloadInternal(back_url, bAddClearCache); 14059 }); 14060 } 14061 else 14062 { 14063 reloadInternal(back_url, bAddClearCache); 14064 } 14065 }; 14066 14067 BX.clearCache = function() 14068 { 14069 BX.showWait(); 14070 BX.reload(true); 14071 }; 14072 14073 BX.template = function(tpl, callback, bKillTpl) 14074 { 14075 BX.ready(function() { 14076 _processTpl(BX(tpl), callback, bKillTpl); 14077 }); 14078 }; 14079 14080 BX.isAmPmMode = function(returnConst) 14081 { 14082 if (returnConst === true) 14083 { 14084 return BX.message.AMPM_MODE; 14085 } 14086 return BX.message.AMPM_MODE !== false; 14087 }; 14088 14089 BX.formatDate = function(date, format) 14090 { 14091 date = date || new Date(); 14092 14093 var bTime = date.getHours() || date.getMinutes() || date.getSeconds(), 14094 str = !!format 14095 ? format : 14096 (bTime ? BX.message('FORMAT_DATETIME') : BX.message('FORMAT_DATE') 14097 ); 14098 14099 return str.replace(/YYYY/ig, date.getFullYear()) 14100 .replace(/MMMM/ig, BX.util.str_pad_left((date.getMonth()+1).toString(), 2, '0')) 14101 .replace(/MM/ig, BX.util.str_pad_left((date.getMonth()+1).toString(), 2, '0')) 14102 .replace(/DD/ig, BX.util.str_pad_left(date.getDate().toString(), 2, '0')) 14103 .replace(/HH/ig, BX.util.str_pad_left(date.getHours().toString(), 2, '0')) 14104 .replace(/MI/ig, BX.util.str_pad_left(date.getMinutes().toString(), 2, '0')) 14105 .replace(/SS/ig, BX.util.str_pad_left(date.getSeconds().toString(), 2, '0')); 14106 }; 14107 BX.formatName = function(user, template, login) 14108 { 14109 user = user || {}; 14110 template = (template || ''); 14111 var replacement = { 14112 TITLE : (user["TITLE"] || ''), 14113 NAME : (user["NAME"] || ''),
14114 LAST_NAME : (user["LAST_NAME"] || ''), 14115 SECOND_NAME : (user["SECOND_NAME"] || ''), 14116 LOGIN : (user["LOGIN"] || ''), 14117 NAME_SHORT : user["NAME"] ? user["NAME"].substr(0, 1) + '.' : '', 14118 LAST_NAME_SHORT : user["LAST_NAME"] ? user["LAST_NAME"].substr(0, 1) + '.' : '', 14119 SECOND_NAME_SHORT : user["SECOND_NAME"] ? user["SECOND_NAME"].substr(0, 1) + '.' : '', 14120 EMAIL : (user["EMAIL"] || ''), 14121 ID : (user["ID"] || ''), 14122 NOBR : "", 14123 '/NOBR' : "" 14124 }, result = template; 14125 for (var ii in replacement) 14126 { 14127 if (replacement.hasOwnProperty(ii)) 14128 { 14129 result = result.replace("#" + ii+ "#", replacement[ii]) 14130 } 14131 } 14132 result = result.replace(/([\s]+)/gi, " ").trim(); 14133 if (result == "") 14134 { 14135 result = (login == "Y" ? replacement["LOGIN"] : ""); 14136 result = (result == "" ? "Noname" : result); 14137 } 14138 return result; 14139 }; 14140 14141 BX.getNumMonth = function(month) 14142 { 14143 var wordMonthCut = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']; 14144 var wordMonth = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december']; 14145 14146 var q = month.toUpperCase(); 14147 for (i = 1; i <= 12; i++) 14148 { 14149 if (q == BX.message('MON_'+i).toUpperCase() || q == BX.message('MONTH_'+i).toUpperCase() || q == wordMonthCut[i-1].toUpperCase() || q == wordMonth[i-1].toUpperCase()) 14150 { 14151 return i; 14152 } 14153 } 14154 return month; 14155 }; 14156 14157 BX.parseDate = function(str, bUTC, formatDate, formatDatetime) 14158 { 14159 if (BX.type.isNotEmptyString(str)) 14160 { 14161 if (!formatDate) 14162 formatDate = BX.message('FORMAT_DATE'); 14163 if (!formatDatetime) 14164 formatDatetime = BX.message('FORMAT_DATETIME'); 14165 14166 var regMonths = ''; 14167 for (i = 1; i <= 12; i++) 14168 { 14169 regMonths = regMonths + '|' + BX.message('MON_'+i); 14170 } 14171
14172 var expr = new RegExp('([0-9]+|[a-z]+' + regMonths + ')', 'ig'); 14173 var aDate = str.match(expr), 14174 aFormat = formatDate.match(/(DD|MI|MMMM|MM|M|YYYY)/ig), 14175 i, cnt, 14176 aDateArgs=[], aFormatArgs=[], 14177 aResult={}; 14178 14179 if (!aDate) 14180 return null; 14181 14182 if(aDate.length > aFormat.length) 14183 { 14184 aFormat = formatDatetime.match(/(DD|MI|MMMM|MM|M|YYYY|HH|H|SS|TT|T|GG|G)/ig); 14185 } 14186 14187 for(i = 0, cnt = aDate.length; i < cnt; i++) 14188 { 14189 if(BX.util.trim(aDate[i]) != '') 14190 { 14191 aDateArgs[aDateArgs.length] = aDate[i]; 14192 } 14193 } 14194 14195 for(i = 0, cnt = aFormat.length; i < cnt; i++) 14196 { 14197 if(BX.util.trim(aFormat[i]) != '') 14198 { 14199 aFormatArgs[aFormatArgs.length] = aFormat[i]; 14200 } 14201 } 14202 14203 14204 var m = BX.util.array_search('MMMM', aFormatArgs); 14205 if (m > 0) 14206 { 14207 aDateArgs[m] = BX.getNumMonth(aDateArgs[m]); 14208 aFormatArgs[m] = "MM"; 14209 } 14210 else 14211 { 14212 m = BX.util.array_search('M', aFormatArgs); 14213 if (m > 0) 14214 { 14215 aDateArgs[m] = BX.getNumMonth(aDateArgs[m]); 14216 aFormatArgs[m] = "MM"; 14217 } 14218 } 14219 14220 for(i = 0, cnt = aFormatArgs.length; i < cnt; i++) 14221 { 14222 var k = aFormatArgs[i].toUpperCase(); 14223 aResult[k] = k == 'T' || k == 'TT' ? aDateArgs[i] : parseInt(aDateArgs[i], 10); 14224 } 14225 14226 if(aResult['DD'] > 0 && aResult['MM'] > 0 && aResult['YYYY'] > 0) 14227 { 14228 var d = new Date(); 14229 14230 if(bUTC) 14231 { 14232 d.setUTCDate(1); 14233 d.setUTCFullYear(aResult['YYYY']); 14234 d.setUTCMonth(aResult['MM'] - 1); 14235 d.setUTCDate(aResult['DD']); 14236 d.setUTCHours(0, 0, 0, 0); 14237 } 14238 else 14239 { 14240 d.setDate(1); 14241 d.setFullYear(aResult['YYYY']); 14242 d.setMonth(aResult['MM'] - 1); 14243 d.setDate(aResult['DD']); 14244 d.setHours(0, 0, 0, 0); 14245 } 14246 14247 if( 14248 (!isNaN(aResult['HH']) || !isNaN(aResult['GG']) || !isNaN(aResult['H']) || !isNaN(aResult['G'])) 14249 && !isNaN(aResult['MI']) 14250 ) 14251 { 14252 if (!isNaN(aResult['H']) || !isNaN(aResult['G'])) 14253 { 14254 var bPM = (aResult['T']||aResult['TT']||'am').toUpperCase()=='PM'; 14255 var h = parseInt(aResult['H']||aResult['G']||0, 10); 14256 if(bPM) 14257 { 14258 aResult['HH'] = h + (h == 12 ? 0 : 12); 14259 } 14260 else 14261 { 14262 aResult['HH'] = h < 12 ? h : 0; 14263 } 14264 } 14265 else 14266 { 14267 aResult['HH'] = parseInt(aResult['HH']||aResult['GG']||0, 10); 14268 } 14269 14270 if (isNaN(aResult['SS'])) 14271 aResult['SS'] = 0; 14272 14273 if(bUTC) 14274 { 14275 d.setUTCHours(aResult['HH'], aResult['MI'], aResult['SS']); 14276 } 14277 else 14278 { 14279 d.setHours(aResult['HH'], aResult['MI'], aResult['SS']); 14280 } 14281 } 14282 14283 return d; 14284 } 14285 } 14286 14287 return null; 14288 }; 14289 14290 BX.selectUtils = 14291 { 14292 addNewOption: function(oSelect, opt_value, opt_name, do_sort, check_unique) 14293 { 14294 oSelect = BX(oSelect); 14295 if(oSelect) 14296 { 14297 var n = oSelect.length; 14298 if(check_unique !== false) 14299 { 14300 for(var i=0;i<n;i++) 14301 { 14302 if(oSelect[i].value==opt_value) 14303 { 14304 return; 14305 } 14306 } 14307 } 14308 14309 oSelect.options[n] = new Option(opt_name, opt_value, false, false); 14310 } 14311 14312 if(do_sort === true) 14313 { 14314 this.sortSelect(oSelect); 14315 } 14316 }, 14317 14318 deleteOption: function(oSelect, opt_value) 14319 { 14320 oSelect = BX(oSelect); 14321 if(oSelect) 14322 { 14323 for(var i=0;i<oSelect.length;i++) 14324 { 14325 if(oSelect[i].value==opt_value) 14326 { 14327 oSelect.remove(i); 14328 break; 14329 } 14330 } 14331 } 14332 }, 14333 14334 deleteSelectedOptions: function(oSelect) 14335 { 14336 oSelect = BX(oSelect); 14337 if(oSelect) 14338 { 14339 var i=0; 14340 while(i<oSelect.length) 14341 { 14342 if(oSelect[i].selected) 14343 { 14344 oSelect[i].selected=false; 14345 oSelect.remove(i); 14346 } 14347 else 14348 { 14349 i++; 14350 } 14351 } 14352 } 14353 }, 14354 14355 deleteAllOptions: function(oSelect) 14356 { 14357 oSelect = BX(oSelect); 14358 if(oSelect) 14359 { 14360 for(var i=oSelect.length-1; i>=0; i--) 14361 { 14362 oSelect.remove(i); 14363 } 14364 } 14365 }, 14366 14367 optionCompare: function(record1, record2) 14368 { 14369 var value1 = record1.optText.toLowerCase(); 14370 var value2 = record2.optText.toLowerCase(); 14371 if (value1 > value2) return(1); 14372 if (value1 < value2) return(-1); 14373 return(0); 14374 }, 14375 14376 sortSelect: function(oSelect) 14377 { 14378 oSelect = BX(oSelect); 14379 if(oSelect) 14380 { 14381 var myOptions = []; 14382 var n = oSelect.options.length; 14383 var i; 14384 for (i=0;i<n;i++) 14385 { 14386 myOptions[i] = { 14387 optText:oSelect[i].text, 14388 optValue:oSelect[i].value 14389 }; 14390 } 14391 myOptions.sort(this.optionCompare); 14392 oSelect.length=0; 14393 n = myOptions.length; 14394 for(i=0;i<n;i++) 14395 { 14396 oSelect[i] = new Option(myOptions[i].optText, myOptions[i].optValue, false, false); 14397 } 14398 } 14399 }, 14400 14401 selectAllOptions: function(oSelect) 14402 { 14403 oSelect = BX(oSelect); 14404 if(oSelect) 14405 { 14406 var n = oSelect.length; 14407 for(var i=0;i<n;i++) 14408 { 14409 oSelect[i].selected=true; 14410 } 14411 } 14412 }, 14413 14414 selectOption: function(oSelect, opt_value) 14415 { 14416 oSelect = BX(oSelect); 14417 if(oSelect) 14418 { 14419 var n = oSelect.length; 14420 for(var i=0;i<n;i++) 14421 { 14422 oSelect[i].selected = (oSelect[i].value == opt_value); 14423 } 14424 } 14425 }, 14426 14427 addSelectedOptions: function(oSelect, to_select_id, check_unique, do_sort) 14428 { 14429 oSelect = BX(oSelect); 14430 if(!oSelect) 14431 return; 14432 var n = oSelect.length; 14433 for(var i=0; i<n; i++) 14434 if(oSelect[i].selected) 14435 this.addNewOption(to_select_id, oSelect[i].value, oSelect[i].text, do_sort, check_unique); 14436 }, 14437 14438 moveOptionsUp: function(oSelect) 14439 { 14440 oSelect = BX(oSelect); 14441 if(!oSelect) 14442 return; 14443 var n = oSelect.length; 14444 for(var i=0; i<n; i++) 14445 { 14446 if(oSelect[i].selected && i>0 && oSelect[i-1].selected == false) 14447 { 14448 var option = new Option(oSelect[i].text, oSelect[i].value); 14449 oSelect[i] = new Option(oSelect[i-1].text, oSelect[i-1].value); 14450 oSelect[i].selected = false;
14451 oSelect[i-1] = option; 14452 oSelect[i-1].selected = true; 14453 } 14454 } 14455 }, 14456 14457 moveOptionsDown: function(oSelect) 14458 { 14459 oSelect = BX(oSelect); 14460 if(!oSelect) 14461 return; 14462 var n = oSelect.length; 14463 for(var i=n-1; i>=0; i--) 14464 { 14465 if(oSelect[i].selected && i<n-1 && oSelect[i+1].selected == false) 14466 { 14467 var option = new Option(oSelect[i].text, oSelect[i].value); 14468 oSelect[i] = new Option(oSelect[i+1].text, oSelect[i+1].value); 14469 oSelect[i].selected = false; 14470 oSelect[i+1] = option; 14471 oSelect[i+1].selected = true; 14472 } 14473 } 14474 } 14475 }; 14476 14477 BX.getEventTarget = function(e) 14478 { 14479 if(e.target) 14480 { 14481 return e.target; 14482 } 14483 else if(e.srcElement) 14484 { 14485 return e.srcElement; 14486 } 14487 return null; 14488 }; 14489 14490 BX.convert = { 14491 toNumber: function(value) 14492 { 14493 if(BX.type.isNumber(value)) 14494 { 14495 return value; 14496 } 14497 14498 value = Number(value); 14499 return !isNaN(value) ? value : 0; 14500 }, 14501 nodeListToArray: function(nodes) 14502 { 14503 try 14504 { 14505 return (Array.prototype.slice.call(nodes, 0)); 14506 } 14507 catch (ex) 14508 { 14509 var ary = []; 14510 for(var i = 0, l = nodes.length; i < l; i++) 14511 { 14512 ary.push(nodes[i]); 14513 } 14514 return ary; 14515 } 14516 } 14517 }; 14518 14519 /******* HINT ***************/ 14520// if function has 2 params - the 2nd one is hint html. otherwise hint_html is third and hint_title - 2nd; 14521// '<div onmouseover="BX.hint(this, 'This is <b>Hint</b>')"'>; 14522// BX.hint(el, 'This is <b>Hint</b>') - this won't work, use constructor 14523 BX.hint = function(el, hint_title, hint_html, hint_id) 14524 { 14525 if (null == hint_html) 14526 { 14527 hint_html = hint_title; 14528 hint_title = ''; 14529 } 14530 14531 if (null == el.BXHINT) 14532 { 14533 el.BXHINT = new BX.CHint({ 14534 parent: el, hint: hint_html, title: hint_title, id: hint_id 14535 }); 14536 el.BXHINT.Show(); 14537 } 14538 }; 14539 14540 BX.hint_replace = function(el, hint_title, hint_html) 14541 { 14542 if (null == hint_html) 14543 { 14544 hint_html = hint_title; 14545 hint_title = ''; 14546 } 14547 14548 if (!el || !el.parentNode || !hint_html) 14549 return null; 14550 14551 var obHint = new BX.CHint({ 14552 hint: hint_html, 14553 title: hint_title 14554 }); 14555 14556 obHint.CreateParent(); 14557 14558 el.parentNode.insertBefore(obHint.PARENT, el); 14559 el.parentNode.removeChild(el); 14560 14561 obHint.PARENT.style.marginLeft = '5px'; 14562 14563 return el; 14564 }; 14565 14566 BX.CHint = function(params) 14567 { 14568 if (BX.CHint.cssLoaded === false) 14569 { 14570 BX.load(['/bitrix/js/main/core/css/core_hint.css']); 14571 BX.CHint.cssLoaded = true; 14572 } 14573 14574 this.PARENT = BX(params.parent); 14575 14576 this.HINT = params.hint; 14577 this.HINT_TITLE = params.title; 14578 14579 this.PARAMS = {}; 14580 for (var i in this.defaultSettings) 14581 { 14582 if (null == params[i]) 14583 this.PARAMS[i] = this.defaultSettings[i]; 14584 else 14585 this.PARAMS[i] = params[i]; 14586 } 14587 14588 if (null != params.id) 14589 this.ID = params.id; 14590 14591 this.timer = null; 14592 this.bInited = false; 14593 this.msover = true; 14594 14595 if (this.PARAMS.showOnce) 14596 { 14597 this.__show(); 14598 this.msover = false; 14599 this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout); 14600 } 14601 else if (this.PARENT) 14602 { 14603 BX.bind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 14604 BX.bind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 14605 } 14606 }; 14607 14608 BX.CHint.cssLoaded = false; 14609 14610 BX.CHint.openHints = new Set(); 14611 14612 BX.CHint.globalDisabled = false; 14613 14614 BX.CHint.handleMenuOpen = function() { 14615 BX.CHint.globalDisabled = true; 14616 14617 BX.CHint.openHints.forEach(function(hint) { 14618 hint.__hide_immediately(); 14619 }); 14620 }; 14621 14622 BX.CHint.handleMenuClose = function() { 14623 BX.CHint.globalDisabled = false; 14624 }; 14625 14626 BX.addCustomEvent('onMenuOpen', BX.CHint.handleMenuOpen); 14627 BX.addCustomEvent('onMenuClose', BX.CHint.handleMenuClose); 14628 14629 BX.CHint.prototype.defaultSettings = { 14630 show_timeout: 1000, 14631 hide_timeout: 500, 14632 dx: 2, 14633 showOnce: false, 14634 preventHide: true, 14635 min_width: 250 14636 }; 14637 14638 BX.CHint.prototype.CreateParent = function(element, params) 14639 { 14640 if (this.PARENT) 14641 { 14642 BX.unbind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 14643 BX.unbind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 14644 } 14645 14646 if (!params) params = {}; 14647 var type = 'icon'; 14648 14649 if (params.type && (params.type == "link" || params.type == "icon")) 14650 type = params.type; 14651 14652 if (element) 14653 type = "element";
14654 14655 if (type == "icon") 14656 { 14657 element = BX.create('IMG', { 14658 props: { 14659 src: params.iconSrc 14660 ? params.iconSrc 14661 : "/bitrix/js/main/core/images/hint.gif" 14662 } 14663 }); 14664 } 14665 else if (type == "link") 14666 { 14667 element = BX.create("A", { 14668 props: {href: 'javascript:void(0)'}, 14669 html: '[?]' 14670 }); 14671 } 14672 14673 this.PARENT = element; 14674 14675 BX.bind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 14676 BX.bind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 14677 14678 return this.PARENT; 14679 }; 14680 14681 BX.CHint.prototype.Show = function() 14682 { 14683 this.msover = true; 14684 14685 if (null != this.timer) 14686 clearTimeout(this.timer); 14687 14688 this.timer = setTimeout(BX.proxy(this.__show, this), this.PARAMS.show_timeout); 14689 }; 14690 14691 BX.CHint.prototype.Hide = function() 14692 { 14693 this.msover = false; 14694 14695 if (null != this.timer) 14696 clearTimeout(this.timer); 14697 14698 this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout); 14699 }; 14700 14701 BX.CHint.prototype.__show = function() 14702 { 14703 if (!this.msover || this.disabled || BX.CHint.globalDisabled) return; 14704 if (!this.bInited) this.Init(); 14705 14706 if (this.prepareAdjustPos()) 14707 { 14708 this.DIV.style.display = 'block'; 14709 BX.ZIndexManager.bringToFront(this.DIV); 14710 14711 this.adjustPos(); 14712 14713 BX.CHint.openHints.add(this); 14714 14715 BX.bind(window, 'scroll', BX.proxy(this.__onscroll, this)); 14716 14717 if (this.PARAMS.showOnce) 14718 { 14719 this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout); 14720 } 14721 } 14722 }; 14723 14724 BX.CHint.prototype.__onscroll = function() 14725 { 14726 if (!BX.admin || !BX.admin.panel || !BX.admin.panel.isFixed()) return; 14727 14728 if (this.scrollTimer) clearTimeout(this.scrollTimer); 14729 14730 this.DIV.style.display = 'none'; 14731 this.scrollTimer = setTimeout(BX.proxy(this.Reopen, this), this.PARAMS.show_timeout); 14732 }; 14733 14734 BX.CHint.prototype.Reopen = function() 14735 { 14736 if (null != this.timer) clearTimeout(this.timer); 14737 this.timer = setTimeout(BX.proxy(this.__show, this), 50); 14738 }; 14739 14740 BX.CHint.prototype.__hide = function() 14741 { 14742 if (this.msover) return; 14743 if (!this.bInited) return; 14744 14745 BX.unbind(window, 'scroll', BX.proxy(this.Reopen, this)); 14746 14747 BX.CHint.openHints.delete(this); 14748 14749 if (this.PARAMS.showOnce) 14750 { 14751 this.Destroy(); 14752 } 14753 else 14754 { 14755 this.DIV.style.display = 'none'; 14756 } 14757 }; 14758 14759 BX.CHint.prototype.__hide_immediately = function() 14760 { 14761 this.msover = false; 14762 this.__hide(); 14763 }; 14764 14765 BX.CHint.prototype.Init = function() 14766 { 14767 this.DIV = document.body.appendChild(BX.create('DIV', { 14768 props: {className: 'bx-panel-tooltip'}, 14769 style: { 14770 display: 'none', 14771 position: 'absolute', 14772 visibility: 'hidden' 14773 }, 14774 children: [ 14775 (this.CONTENT = BX.create('DIV', { 14776 props: {className: 'bx-panel-tooltip-content'}, 14777 children: [ 14778 BX.create('DIV', { 14779 props: {className: 'bx-panel-tooltip-underlay'}, 14780 children: [ 14781 BX.create('DIV', {props: {className: 'bx-panel-tooltip-underlay-bg'}}) 14782 ] 14783 }) 14784 ] 14785 })) 14786 ] 14787 })); 14788 14789 BX.ZIndexManager.register(this.DIV); 14790 14791 if (this.ID) 14792 { 14793 this.CONTENT.insertBefore(BX.create('A', { 14794 attrs: {href: 'javascript:void(0)'}, 14795 props: {className: 'bx-panel-tooltip-close'}, 14796 events: {click: BX.delegate(this.Close, this)} 14797 }), this.CONTENT.firstChild); 14798 } 14799 14800 if (this.HINT_TITLE) 14801 { 14802 this.CONTENT.appendChild( 14803 BX.create('DIV', { 14804 props: {className: 'bx-panel-tooltip-title'}, 14805 text: this.HINT_TITLE 14806 }) 14807 ); 14808 } 14809 14810 if (this.HINT) 14811 { 14812 this.CONTENT_TEXT = this.CONTENT.appendChild(BX.create('DIV', {props: {className: 'bx-panel-tooltip-text'}})).appendChild(BX.create('SPAN', {html: this.HINT})); 14813 } 14814 14815 if (this.PARAMS.preventHide) 14816 { 14817 BX.bind(this.DIV, 'mouseout', BX.proxy(this.Hide, this)); 14818 BX.bind(this.DIV, 'mouseover', BX.proxy(this.Show, this)); 14819 } 14820 14821 this.bInited = true; 14822 }; 14823 14824 BX.CHint.prototype.setContent = function(content) 14825 { 14826 this.HINT = content; 14827 14828 if (this.CONTENT_TEXT) 14829 this.CONTENT_TEXT.innerHTML = this.HINT; 14830 else 14831 this.CONTENT_TEXT = this.CONTENT.appendChild(BX.create('DIV', {props: {className: 'bx-panel-tooltip-text'}})).appendChild(BX.create('SPAN', {html: this.HINT})); 14832 }; 14833 14834 BX.CHint.prototype.prepareAdjustPos = function() 14835 { 14836 this._wnd = {scrollPos: BX.GetWindowScrollPos(),scrollSize:BX.GetWindowScrollSize()}; 14837 return BX.style(this.PARENT, 'display') != 'none'; 14838 }; 14839 14840 BX.CHint.prototype.getAdjustPos = function() 14841 { 14842 var res = {}, pos = BX.pos(this.PARENT), min_top = 0; 14843 14844 res.top = pos.bottom + this.PARAMS.dx; 14845 14846 if (BX.admin && BX.admin.panel.DIV) 14847 { 14848 min_top = BX.admin.panel.DIV.offsetHeight + this.PARAMS.dx; 14849 14850 if (BX.admin.panel.isFixed()) 14851 { 14852 min_top += this._wnd.scrollPos.scrollTop; 14853 } 14854 } 14855 14856 if (res.top < min_top) 14857 res.top = min_top; 14858 else 14859 { 14860 if (res.top + this.DIV.offsetHeight > this._wnd.scrollSize.scrollHeight) 14861 res.top = pos.top - this.PARAMS.dx - this.DIV.offsetHeight; 14862 } 14863 14864 res.left = pos.left; 14865 if (pos.left < this.PARAMS.dx) 14866 pos.left = this.PARAMS.dx; 14867 else 14868 { 14869 var floatWidth = this.DIV.offsetWidth; 14870 14871 var max_left = this._wnd.scrollSize.scrollWidth - floatWidth - this.PARAMS.dx; 14872 14873 if (res.left > max_left) 14874 res.left = max_left; 14875 } 14876 14877 return res; 14878 }; 14879 14880 BX.CHint.prototype.adjustWidth = function() 14881 { 14882 if (this.bWidthAdjusted) return; 14883 14884 var w = this.DIV.offsetWidth, h = this.DIV.offsetHeight; 14885 14886 if (w > this.PARAMS.min_width) 14887 w = Math.round(Math.sqrt(1.618*w*h)); 14888 14889 if (w < this.PARAMS.min_width) 14890 w = this.PARAMS.min_width; 14891 14892 this.DIV.style.width = w + "px"; 14893 14894 if (this._adjustWidthInt) 14895 clearInterval(this._adjustWidthInt); 14896 this._adjustWidthInt = setInterval(BX.delegate(this._adjustWidthInterval, this), 5); 14897 14898 this.bWidthAdjusted = true; 14899 }; 14900 14901 BX.CHint.prototype._adjustWidthInterval = function() 14902 { 14903 if (!this.DIV || this.DIV.style.display == 'none') 14904 clearInterval(this._adjustWidthInt); 14905 14906 var
14907 dW = 20, 14908 maxWidth = 1500, 14909 w = this.DIV.offsetWidth, 14910 w1 = this.CONTENT_TEXT.offsetWidth; 14911 14912 if (w > 0 && w1 > 0 && w - w1 < dW && w < maxWidth) 14913 { 14914 this.DIV.style.width = (w + dW) + "px"; 14915 return; 14916 } 14917 14918 clearInterval(this._adjustWidthInt); 14919 }; 14920 14921 BX.CHint.prototype.adjustPos = function() 14922 { 14923 this.adjustWidth(); 14924 14925 var pos = this.getAdjustPos(); 14926 14927 this.DIV.style.top = pos.top + 'px'; 14928 this.DIV.style.left = pos.left + 'px'; 14929 }; 14930 14931 BX.CHint.prototype.Close = function() 14932 { 14933 if (this.ID && BX.WindowManager) 14934 BX.WindowManager.saveWindowOptions(this.ID, {display: 'off'}); 14935 this.__hide_immediately(); 14936 this.Destroy(); 14937 }; 14938 14939 BX.CHint.prototype.Destroy = function() 14940 { 14941 if (this.PARENT) 14942 { 14943 BX.unbind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 14944 BX.unbind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 14945 } 14946 14947 if (this.DIV) 14948 { 14949 BX.unbind(this.DIV, 'mouseover', BX.proxy(this.Show, this)); 14950 BX.unbind(this.DIV, 'mouseout', BX.proxy(this.Hide, this)); 14951 14952 BX.ZIndexManager.unregister(this.DIV); 14953 14954 BX.cleanNode(this.DIV, true); 14955 } 14956 }; 14957 14958 BX.CHint.prototype.enable = function(){this.disabled = false;}; 14959 BX.CHint.prototype.disable = function(){this.__hide_immediately(); this.disabled = true;}; 14960 14961 14962 function _adjustWait() 14963 { 14964 if (!this.bxmsg) return; 14965 14966 var arContainerPos = BX.pos(this), 14967 div_top = arContainerPos.top; 14968 14969 if (div_top < BX.GetDocElement().scrollTop) 14970 div_top = BX.GetDocElement().scrollTop + 5; 14971 14972 this.bxmsg.style.top = (div_top + 5) + 'px'; 14973 14974 if (this == BX.GetDocElement()) 14975 { 14976 this.bxmsg.style.right = '5px'; 14977 } 14978 else 14979 { 14980 this.bxmsg.style.left = (arContainerPos.right - this.bxmsg.offsetWidth - 5) + 'px'; 14981 } 14982 } 14983 14984 function _processTpl(tplNode, cb, bKillTpl) 14985 { 14986 if (tplNode) 14987 { 14988 if (bKillTpl) 14989 tplNode.parentNode.removeChild(tplNode); 14990 14991 var res = {}, nodes = BX.findChildren(tplNode, {attribute: 'data-role'}, true); 14992 14993 for (var i = 0, l = nodes.length; i < l; i++) 14994 { 14995 res[nodes[i].getAttribute('data-role')] = nodes[i]; 14996 } 14997 14998 cb.apply(tplNode, [res]); 14999 } 15000 } 15001 15002 function _checkNode(obj, params) 15003 { 15004 params = params || {}; 15005 15006 if (BX.type.isFunction(params)) 15007 return params.call(window, obj); 15008 15009 if (!params.allowTextNodes && !BX.type.isElementNode(obj)) 15010 return false; 15011 var i,j,len; 15012 for (i in params) 15013 { 15014 if(params.hasOwnProperty(i)) 15015 { 15016 switch(i) 15017 { 15018 case 'tag': 15019 case 'tagName': 15020 if (BX.type.isString(params[i])) 15021 { 15022 if (obj.tagName.toUpperCase() != params[i].toUpperCase()) 15023 return false; 15024 } 15025 else if (params[i] instanceof RegExp) 15026 { 15027 if (!params[i].test(obj.tagName)) 15028 return false; 15029 } 15030 break; 15031 15032 case 'class': 15033 case 'className': 15034 if (BX.type.isString(params[i])) 15035 { 15036 if (!BX.hasClass(obj, params[i])) 15037 return false; 15038 } 15039 else if (params[i] instanceof RegExp) 15040 { 15041 if (!BX.type.isString(obj.className) || !params[i].test(obj.className)) 15042 return false; 15043 } 15044 break; 15045 15046 case 'attr': 15047 case 'attrs': 15048 case 'attribute': 15049 if (BX.type.isString(params[i])) 15050 { 15051 if (!obj.getAttribute(params[i])) 15052 return false; 15053 } 15054 else if (BX.type.isArray(params[i])) 15055 { 15056 for (j = 0, len = params[i].length; j < len; j++) 15057 { 15058 if (params[i] && !obj.getAttribute(params[i])) 15059 return false; 15060 } 15061 } 15062 else 15063 { 15064 for (j in params[i]) 15065 { 15066 if(params[i].hasOwnProperty(j)) 15067 { 15068 var q = obj.getAttribute(j); 15069 if (params[i][j] instanceof RegExp) 15070 { 15071 if (!BX.type.isString(q) || !params[i][j].test(q)) 15072 { 15073 return false; 15074 } 15075 } 15076 else 15077 { 15078 if (q != '' + params[i][j]) 15079 { 15080 return false; 15081 } 15082 } 15083 } 15084 } 15085 } 15086 break; 15087 15088 case 'property': 15089 case 'props': 15090 if (BX.type.isString(params[i])) 15091 { 15092 if (!obj[params[i]]) 15093 return false; 15094 } 15095 else if (BX.type.isArray(params[i])) 15096 { 15097 for (j = 0, len = params[i].length; j < len; j++) 15098 { 15099 if (params[i] && !obj[params[i]]) 15100 return false;
15101 } 15102 } 15103 else 15104 { 15105 for (j in params[i]) 15106 { 15107 if (BX.type.isString(params[i][j])) 15108 { 15109 if (obj[j] != params[i][j]) 15110 return false; 15111 } 15112 else if (params[i][j] instanceof RegExp) 15113 { 15114 if (!BX.type.isString(obj[j]) || !params[i][j].test(obj[j])) 15115 return false; 15116 } 15117 } 15118 } 15119 break; 15120 15121 case 'callback': 15122 return params[i](obj); 15123 } 15124 } 15125 } 15126 15127 return true; 15128 } 15129 15130 window.addEventListener('pagehide', () => { 15131 garbageCollectors.forEach(({ callback, context = window }) => { 15132 try 15133 { 15134 callback.apply(context); 15135 } catch (err) {} 15136 }); 15137 }); 15138 15139 // set empty ready handler 15140 BX(BX.DoNothing); 15141 window.BX = BX; 15142 15143 BX.browser.addGlobalClass(); 15144 15145 /* data storage */ 15146 BX.data = function(node, key, value) 15147 { 15148 if(typeof node == 'undefined') 15149 return undefined; 15150 15151 if(typeof key == 'undefined') 15152 return undefined; 15153 15154 if(typeof value != 'undefined') 15155 { 15156 // write to manager 15157 dataStorage.set(node, key, value); 15158 } 15159 else 15160 { 15161 var data; 15162 15163 // from manager 15164 if((data = dataStorage.get(node, key)) != undefined) 15165 { 15166 return data; 15167 } 15168 else 15169 { 15170 // from attribute data-* 15171 if('getAttribute' in node) 15172 { 15173 data = node.getAttribute('data-'+key.toString()); 15174 if(data === null) 15175 { 15176 return undefined; 15177 } 15178 return data; 15179 } 15180 } 15181 15182 return undefined; 15183 } 15184 }; 15185 15186 BX.DataStorage = function() 15187 { 15188 15189 this.keyOffset = 1; 15190 this.data = {}; 15191 this.uniqueTag = 'BX-'+Math.random(); 15192 15193 this.resolve = function(owner, create){ 15194 if(typeof owner[this.uniqueTag] == 'undefined') 15195 if(create) 15196 { 15197 try 15198 { 15199 Object.defineProperty(owner, this.uniqueTag, { 15200 value: this.keyOffset++ 15201 }); 15202 } 15203 catch(e) 15204 { 15205 owner[this.uniqueTag] = this.keyOffset++; 15206 } 15207 } 15208 else 15209 return undefined; 15210 15211 return owner[this.uniqueTag]; 15212 }; 15213 this.get = function(owner, key){ 15214 if((owner != document && !BX.type.isElementNode(owner)) || typeof key == 'undefined') 15215 return undefined; 15216 15217 owner = this.resolve(owner, false); 15218 15219 if(typeof owner == 'undefined' || typeof this.data[owner] == 'undefined') 15220 return undefined; 15221 15222 return this.data[owner][key]; 15223 }; 15224 this.set = function(owner, key, value){ 15225 15226 if((owner != document && !BX.type.isElementNode(owner)) || typeof value == 'undefined') 15227 return; 15228 15229 var o = this.resolve(owner, true); 15230 15231 if(typeof this.data[o] == 'undefined') 15232 this.data[o] = {}; 15233 15234 this.data[o][key] = value; 15235 }; 15236 }; 15237 15238// some internal variables for new logic 15239 var dataStorage = new BX.DataStorage(); // manager which BX.data() uses to keep data 15240})(window.BX); 15241 15242 15243;(function(window) 15244{ 15245 /****************** ATTENTION ******************************* 15246 * Please do not use Bitrix CoreJS in this class. 15247 * This class can be called on page without Bitrix Framework 15248 *************************************************************/ 15249 15250 if (!window.BX) 15251 { 15252 window.BX = {}; 15253 } 15254 15255 var BX = window.BX; 15256 15257 BX.Promise = function(fn, ctx) // fn is future-reserved 15258 { 15259 this.state = null; 15260 this.value = null; 15261 this.reason = null; 15262 this.next = null; 15263 this.ctx = ctx || this; 15264 15265 this.onFulfilled = []; 15266 this.onRejected = []; 15267 }; 15268 BX.Promise.prototype.fulfill = function(value) 15269 { 15270 this.checkState(); 15271 15272 this.value = value; 15273 this.state = true; 15274 this.execute(); 15275 }; 15276 BX.Promise.prototype.reject = function(reason) 15277 { 15278 this.checkState(); 15279 15280 this.reason = reason; 15281 this.state = false; 15282 this.execute(); 15283 }; 15284 BX.Promise.prototype.then = function(onFulfilled, onRejected) 15285 { 15286 if(typeof (onFulfilled) == "function" || onFulfilled instanceof Function) 15287 { 15288 this.onFulfilled.push(onFulfilled); 15289 } 15290 if(typeof (onRejected) == "function" || onRejected instanceof Function) 15291 { 15292 this.onRejected.push(onRejected); 15293 } 15294 15295 if(this.next === null) 15296 { 15297 this.next = new BX.Promise(null, this.ctx); 15298 } 15299 15300 if(this.state !== null) // if promise was already resolved, execute immediately 15301 { 15302 this.execute(); 15303 } 15304 15305 return this.next; 15306 }; 15307 15308 BX.Promise.prototype.catch = function(onRejected) 15309 { 15310 if(typeof (onRejected) == "function" || onRejected instanceof Function) 15311 { 15312 this.onRejected.push(onRejected); 15313 } 15314 15315 if(this.next === null) 15316 { 15317 this.next = new BX.Promise(null, this.ctx); 15318 } 15319 15320 if(this.state !== null) // if promise was already resolved, execute immediately 15321 { 15322 this.execute(); 15323 } 15324 15325 return this.next; 15326 }; 15327 15328 BX.Promise.prototype.setAutoResolve = function(way, ms) 15329 { 15330 this.timer = setTimeout(function(){ 15331 if(this.state === null) 15332 { 15333 this[way ? 'fulfill' : 'reject'](); 15334 } 15335 }.bind(this), ms || 15); 15336 };
15337 BX.Promise.prototype.cancelAutoResolve = function() 15338 { 15339 clearTimeout(this.timer); 15340 }; 15341 /** 15342 * Resolve function. This function allows promise chaining, like ..then().then()... 15343 * Typical usage: 15344 * 15345 * var p = new Promise(); 15346 * 15347 * p.then(function(value){ 15348 * return someValue; // next promise in the chain will be fulfilled with someValue 15349 * }).then(function(value){ 15350 * 15351 * var p1 = new Promise(); 15352 * *** some async code here, that eventually resolves p1 *** 15353 * 15354 * return p1; // chain will resume when p1 resolved (fulfilled or rejected) 15355 * }).then(function(value){ 15356 * 15357 * // you can also do 15358 * var e = new Error(); 15359 * throw e; 15360 * // it will cause next promise to be rejected with e 15361 * 15362 * return someOtherValue; 15363 * }).then(function(value){ 15364 * ... 15365 * }, function(reason){ 15366 * // promise was rejected with reason 15367 * })...; 15368 * 15369 * p.fulfill('let`s start this chain'); 15370 * 15371 * @param x 15372 */ 15373 BX.Promise.prototype.resolve = function(x) 15374 { 15375 var this_ = this; 15376 15377 if(this === x) 15378 { 15379 this.reject(new TypeError('Promise cannot fulfill or reject itself')); // avoid recursion 15380 } 15381 // allow "pausing" promise chaining until promise x is fulfilled or rejected 15382 else if(x && x.toString() === "[object BX.Promise]") 15383 { 15384 x.then(function(value){ 15385 this_.fulfill(value); 15386 }, function(reason){ 15387 this_.reject(reason); 15388 }); 15389 } 15390 else // auto-fulfill this promise 15391 { 15392 this.fulfill(x); 15393 } 15394 }; 15395 15396 BX.Promise.prototype.toString = function() 15397 { 15398 return "[object BX.Promise]"; 15399 }; 15400 15401 BX.Promise.prototype.execute = function() 15402 { 15403 if(this.state === null) 15404 { 15405 //then() must not be called before BX.Promise resolve() happens 15406 return; 15407 } 15408 15409 var value = undefined; 15410 var reason = undefined; 15411 var x = undefined; 15412 var k; 15413 if(this.state === true) // promise was fulfill()-ed 15414 { 15415 if(this.onFulfilled.length) 15416 { 15417 try 15418 { 15419 for(k = 0; k < this.onFulfilled.length; k++) 15420 {
15421 x = this.onFulfilled[k].apply(this.ctx, [this.value]); 15422 if(typeof x != 'undefined') 15423 { 15424 value = x; 15425 } 15426 } 15427 } 15428 catch(e) 15429 { 15430 if('console' in window) 15431 { 15432 console.dir(e); 15433 } 15434 15435 if (typeof BX.debug !== 'undefined') 15436 { 15437 BX.debug(e); 15438 } 15439 15440 reason = e; // reject next 15441 } 15442 } 15443 else 15444 { 15445 value = this.value; // resolve next 15446 } 15447 } 15448 else if(this.state === false) // promise was reject()-ed 15449 { 15450 if(this.onRejected.length) 15451 { 15452 try 15453 { 15454 for(k = 0; k < this.onRejected.length; k++) 15455 { 15456 x = this.onRejected[k].apply(this.ctx, [this.reason]); 15457 if(typeof x != 'undefined') 15458 { 15459 value = x; 15460 } 15461 } 15462 } 15463 catch(e) 15464 { 15465 if('console' in window) 15466 { 15467 console.dir(e); 15468 } 15469 15470 if (typeof BX.debug !== 'undefined') 15471 { 15472 BX.debug(e); 15473 } 15474 15475 reason = e; // reject next 15476 } 15477 } 15478 else 15479 { 15480 reason = this.reason; // reject next 15481 } 15482 } 15483 15484 if(this.next !== null) 15485 { 15486 if(typeof reason != 'undefined') 15487 { 15488 this.next.reject(reason); 15489 } 15490 else if(typeof value != 'undefined') 15491 { 15492 this.next.resolve(value); 15493 } 15494 } 15495 }; 15496 BX.Promise.prototype.checkState = function() 15497 { 15498 if(this.state !== null) 15499 { 15500 throw new Error('You can not do fulfill() or reject() multiple times'); 15501 } 15502 }; 15503})(window); 15504 15505 15506 15507;(function(window){ 15508 15509if (window.BX.ajax) 15510 return; 15511 15512var 15513 BX = window.BX, 15514 15515 tempDefaultConfig = {}, 15516 defaultConfig = { 15517 method: 'GET', // request method: GET|POST 15518 dataType: 'html', // type of data loading: html|json|script 15519 timeout: 0, // request timeout in seconds. 0 for browser-default 15520 async: true, // whether request is asynchronous or not 15521 processData: true, // any data processing is disabled if false, only callback call 15522 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 15523 emulateOnload: true, 15524 skipAuthCheck: false, // whether to check authorization failure (SHOUD be set to true for CORS requests) 15525 start: true, // send request immediately (if false, request can be started manually via XMLHttpRequest object returned) 15526 cache: true, // whether NOT to add random addition to URL 15527 preparePost: true, // whether set Content-Type x-www-form-urlencoded in POST 15528 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'}] 15529 lsTimeout: 30, //local storage data TTL. useless without lsId. 15530 lsForce: false //wheter to force query instead of using localStorage data. useless without lsId. 15531/* 15532other parameters: 15533 url: url to get/post 15534 data: data to post 15535 onsuccess: successful request callback. BX.proxy may be used. 15536 onfailure: request failure callback. BX.proxy may be used. 15537 onprogress: request progress callback. BX.proxy may be used. 15538 15539 lsId: local storage id - for constantly updating queries which can communicate via localStorage. core_ls.js needed 15540 15541any of the default parameters can be overridden. defaults can be changed by BX.ajax.Setup() - for all further requests! 15542*/ 15543 }, 15544 loadedScripts = {}, 15545 loadedScriptsQueue = [], 15546 r = { 15547 'url_utf': /[^\034-\254]+/g, 15548 'script_self': /\/bitrix\/js\/main\/core\/core(_ajax)*.js$/i, 15549 'script_self_window': /\/bitrix\/js\/main\/core\/core_window.js$/i, 15550 'script_self_admin': /\/bitrix\/js\/main\/core\/core_admin.js$/i, 15551 'script_onload': /window.onload/g 15552 }; 15553 15554// low-level method 15555BX.ajax = function(config) 15556{ 15557 var status, data; 15558
15559 if (!config || !config.url || !BX.type.isString(config.url)) 15560 { 15561 return false; 15562 } 15563 15564 for (var i in tempDefaultConfig) 15565 if (typeof (config[i]) == "undefined") config[i] = tempDefaultConfig[i]; 15566 15567 tempDefaultConfig = {}; 15568 15569 for (i in defaultConfig) 15570 if (typeof (config[i]) == "undefined") config[i] = defaultConfig[i]; 15571 15572 config.method = config.method.toUpperCase(); 15573 15574 if (!BX.localStorage) 15575 config.lsId = null; 15576 15577 if (BX.browser.IsIE()) 15578 { 15579 var result = r.url_utf.exec(config.url); 15580 if (result) 15581 { 15582 do 15583 { 15584 config.url = config.url.replace(result, BX.util.urlencode(result)); 15585 result = r.url_utf.exec(config.url); 15586 } while (result); 15587 } 15588 } 15589 15590 if(config.dataType == 'json') 15591 config.emulateOnload = false; 15592 15593 if (!config.cache && config.method == 'GET') 15594 config.url = BX.ajax._uncache(config.url); 15595 15596 if (config.method == 'POST') 15597 { 15598 if (config.preparePost) 15599 { 15600 config.data = BX.ajax.prepareData(config.data); 15601 } 15602 else if (getLastContentTypeHeader(config.headers) === 'application/json') 15603 { 15604 const isJson = ( 15605 BX.Type.isPlainObject(config.data) 15606 || BX.Type.isString(config.data) 15607 || BX.Type.isNumber(config.data) 15608 || BX.Type.isBoolean(config.data) 15609 || BX.Type.isArray(config.data) 15610 ); 15611 15612 if (isJson) 15613 { 15614 config.data = JSON.stringify(config.data); 15615 } 15616 } 15617 } 15618 15619 var bXHR = true; 15620 if (config.lsId && !config.lsForce) 15621 { 15622 var v = BX.localStorage.get('ajax-' + config.lsId); 15623 if (v !== null) 15624 { 15625 bXHR = false; 15626 15627 var lsHandler = function(lsData) { 15628 if (lsData.key == 'ajax-' + config.lsId && lsData.value != 'BXAJAXWAIT') 15629 { 15630 var data = lsData.value, 15631 bRemove = !!lsData.oldValue && data == null; 15632 if (!bRemove) 15633 BX.ajax.__run(config, data); 15634 else if (config.onfailure) 15635 config.onfailure("timeout"); 15636 15637 BX.removeCustomEvent('onLocalStorageChange', lsHandler); 15638 } 15639 }; 15640 15641 if (v == 'BXAJAXWAIT') 15642 { 15643 BX.addCustomEvent('onLocalStorageChange', lsHandler); 15644 } 15645 else 15646 { 15647 setTimeout(function() {lsHandler({key: 'ajax-' + config.lsId, value: v})}, 10); 15648 } 15649 } 15650 } 15651 15652 if (bXHR) 15653 { 15654 config.xhr = BX.ajax.xhr(); 15655 if (!config.xhr) return; 15656 15657 if (config.lsId) 15658 { 15659 BX.localStorage.set('ajax-' + config.lsId, 'BXAJAXWAIT', config.lsTimeout); 15660 } 15661 15662 if (BX.Type.isFunction(config.onprogress)) 15663 { 15664 BX.bind(config.xhr, 'progress', config.onprogress); 15665 } 15666 15667 if (BX.Type.isFunction(config.onprogressupload) && config.xhr.upload) 15668 { 15669 BX.bind(config.xhr.upload, 'progress', config.onprogressupload); 15670 } 15671 15672 config.xhr.open(config.method, config.url, config.async); 15673 15674 if (!config.skipBxHeader && !BX.ajax.isCrossDomain(config.url)) 15675 { 15676 config.xhr.setRequestHeader('Bx-ajax', 'true'); 15677 } 15678 15679 if (config.method == 'POST' && config.preparePost) 15680 { 15681 config.xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 15682 } 15683 if (typeof(config.headers) == "object") 15684 { 15685 for (i = 0; i < config.headers.length; i++) 15686 config.xhr.setRequestHeader(config.headers[i].name, config.headers[i].value); 15687 } 15688 15689 var bRequestCompleted = false; 15690 var onreadystatechange = config.xhr.onreadystatechange = function(additional) 15691 { 15692 if (bRequestCompleted) 15693 return; 15694 15695 if (additional === 'timeout') 15696 { 15697 if (config.onfailure) 15698 { 15699 config.onfailure('timeout', '', config); 15700 } 15701 15702 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['timeout', '', config]); 15703 15704 config.xhr.onreadystatechange = BX.DoNothing; 15705 config.xhr.abort(); 15706 15707 if (config.async) 15708 { 15709 config.xhr = null; 15710 } 15711 } 15712 else 15713 { 15714 if (config.xhr.readyState == 4 || additional == 'run') 15715 { 15716 status = BX.ajax.xhrSuccess(config.xhr) ? "success" : "error"; 15717 bRequestCompleted = true; 15718 config.xhr.onreadystatechange = BX.DoNothing; 15719 15720 if (status == 'success') 15721 { 15722 var authHeader = (!!config.skipAuthCheck || BX.ajax.isCrossDomain(config.url)) 15723 ? false 15724 : config.xhr.getResponseHeader('X-Bitrix-Ajax-Status'); 15725 15726 if(!!authHeader && authHeader == 'Authorize') 15727 { 15728 if (config.onfailure) 15729 { 15730 config.onfailure('auth', config.xhr.status, config); 15731 } 15732 15733 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['auth', config.xhr.status, config]); 15734 } 15735 else 15736 { 15737 var data = config.xhr.responseText; 15738 15739 if (config.lsId) 15740 { 15741 BX.localStorage.set('ajax-' + config.lsId, data, config.lsTimeout); 15742 } 15743 15744 BX.ajax.__run(config, data); 15745 } 15746 } 15747 else 15748 { 15749 if (config.onfailure) 15750 { 15751 config.onfailure('status', config.xhr.status, config); 15752 } 15753 15754 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['status', config.xhr.status, config]); 15755 } 15756 15757 if (config.async) 15758 { 15759 config.xhr = null; 15760 } 15761 } 15762 } 15763 }; 15764 15765 if (config.async && config.timeout > 0) 15766 { 15767 setTimeout(function() { 15768 if (config.xhr && !bRequestCompleted) 15769 { 15770 onreadystatechange("timeout"); 15771 } 15772 }, config.timeout * 1000); 15773 } 15774 15775 if (config.start) 15776 {
15777 config.xhr.send(config.data); 15778 15779 if (!config.async) 15780 { 15781 onreadystatechange('run'); 15782 } 15783 } 15784 15785 return config.xhr; 15786 } 15787}; 15788 15789BX.ajax.xhr = function() 15790{ 15791 if (window.XMLHttpRequest) 15792 { 15793 try {return new XMLHttpRequest();} catch(e){} 15794 } 15795 else if (window.ActiveXObject) 15796 { 15797 try { return new window.ActiveXObject("Msxml2.XMLHTTP.6.0"); } 15798 catch(e) {} 15799 try { return new window.ActiveXObject("Msxml2.XMLHTTP.3.0"); } 15800 catch(e) {} 15801 try { return new window.ActiveXObject("Msxml2.XMLHTTP"); } 15802 catch(e) {} 15803 try { return new window.ActiveXObject("Microsoft.XMLHTTP"); } 15804 catch(e) {} 15805 throw new Error("This browser does not support XMLHttpRequest."); 15806 } 15807 15808 return null; 15809}; 15810 15811BX.ajax.isCrossDomain = function(url, location) 15812{ 15813 location = location || window.location; 15814 15815 //Relative URL gets a current protocol 15816 if (url.indexOf("//") === 0) 15817 { 15818 url = location.protocol + url; 15819 } 15820 15821 //Fast check 15822 if (url.indexOf("http") !== 0) 15823 { 15824 return false; 15825 } 15826 15827 var link = window.document.createElement("a"); 15828 link.href = url; 15829 15830 return link.protocol !== location.protocol || 15831 link.hostname !== location.hostname || 15832 BX.ajax.getHostPort(link.protocol, link.host) !== BX.ajax.getHostPort(location.protocol, location.host); 15833}; 15834 15835BX.ajax.getHostPort = function(protocol, host) 15836{ 15837 var match = /:(\d+)$/.exec(host); 15838 if (match) 15839 { 15840 return match[1]; 15841 } 15842 else 15843 { 15844 if (protocol === "http:") 15845 { 15846 return "80"; 15847 } 15848 else if (protocol === "https:") 15849 { 15850 return "443"; 15851 } 15852 } 15853 15854 return ""; 15855}; 15856 15857BX.ajax.__prepareOnload = function(scripts, ajax_session) 15858{ 15859 if (scripts.length > 0) 15860 { 15861 BX.ajax['onload_' + ajax_session] = null; 15862 15863 for (var i=0,len=scripts.length;i<len;i++) 15864 { 15865 if (scripts[i].isInternal) 15866 { 15867 scripts[i].JS = scripts[i].JS.replace(r.script_onload, 'BX.aja
15867x.onload_' + ajax_session); 15868 } 15869 } 15870 } 15871 15872 BX.CaptureEventsGet(); 15873 BX.CaptureEvents(window, 'load'); 15874}; 15875 15876BX.ajax.__runOnload = function(ajax_session) 15877{ 15878 if (null != BX.ajax['onload_' + ajax_session]) 15879 { 15880 BX.ajax['onload_' + ajax_session].apply(window); 15881 BX.ajax['onload_' + ajax_session] = null; 15882 } 15883 15884 var h = BX.CaptureEventsGet(); 15885 15886 if (h) 15887 { 15888 for (var i=0; i<h.length; i++) 15889 h[i].apply(window); 15890 } 15891}; 15892 15893BX.ajax.__run = function(config, data) 15894{ 15895 if (!config.processData) 15896 { 15897 if (config.onsuccess) 15898 { 15899 config.onsuccess(data); 15900 } 15901 15902 BX.onCustomEvent(config.xhr, 'onAjaxSuccess', [data, config]); 15903 } 15904 else 15905 { 15906 data = BX.ajax.processRequestData(data, config); 15907 } 15908}; 15909 15910 15911BX.ajax._onParseJSONFailure = function(data) 15912{ 15913 this.jsonFailure = true; 15914 this.jsonResponse = data; 15915 this.jsonProactive = /^\[WAF\]/.test(data); 15916}; 15917 15918BX.ajax.processRequestData = function(data, config) 15919{ 15920 var result, scripts = [], styles = []; 15921 switch (config.dataType.toUpperCase()) 15922 { 15923 case 'JSON': 15924 15925 var context = config.xhr || {}; 15926 BX.addCustomEvent(context, 'onParseJSONFailure', BX.proxy(BX.ajax._onParseJSONFailure, config)); 15927 result = BX.parseJSON(data, context); 15928 BX.removeCustomEvent(context, 'onParseJSONFailure', BX.proxy(BX.ajax._onParseJSONFailure, config)); 15929 15930 if(!!result && BX.type.isArray(result['bxjs'])) 15931 { 15932 for(var i = 0; i < result['bxjs'].length; i++) 15933 { 15934 if(BX.type.isNotEmptyString(result['bxjs'][i])) 15935 { 15936 scripts.push({ 15937 "isInternal": false, 15938 "JS": result['bxjs'][i], 15939 "bRunFirst": config.scriptsRunFirst 15940 }); 15941 } 15942 else 15943 { 15944 scripts.push(result['bxjs'][i]) 15945 } 15946 } 15947 } 15948 15949 if(!!result && BX.type.isArray(result['bxcss'])) 15950 { 15951 styles = result['bxcss']; 15952 } 15953 15954 break; 15955 case 'SCRIPT': 15956 scripts.push({"isInternal": true, "JS": data, "bRunFirst": config.scriptsRunFirst}); 15957 result = data; 15958 break; 15959 15960 default: // HTML 15961 var ob = BX.processHTML(data, config.scriptsRunFirst); 15962 result = ob.HTML; scripts = ob.SCRIPT; styles = ob.STYLE; 15963 break; 15964 } 15965 15966 if (styles.length > 0) 15967 { 15968 BX.loadCSS(styles); 15969 } 15970 15971 let ajax_session = null; 15972 if (config.emulateOnload) 15973 { 15974 ajax_session = parseInt(Math.random() * 1000000); 15975 BX.ajax.__prepareOnload(scripts, ajax_session); 15976 } 15977 15978 const cb = BX.defer(function() 15979 { 15980 if (config.emulateOnload) 15981 { 15982 BX.ajax.__runOnload(ajax_session); 15983 } 15984 15985 BX.onCustomEvent(config.xhr, 'onAjaxSuccessFinish', [config]); 15986 }); 15987 15988 try 15989 { 15990 if (!!config.jsonFailure) 15991 { 15992 throw {type: 'json_failure', data: config.jsonResponse, bProactive: config.jsonProactive}; 15993 } 15994 15995 config.scripts = scripts; 15996 15997 BX.ajax.processScripts(config.scripts, true); 15998 15999 if (config.onsuccess) 16000 { 16001 config.onsuccess(result); 16002 } 16003 16004 BX.onCustomEvent(config.xhr, 'onAjaxSuccess', [result, config]); 16005 16006 BX.ajax.processScripts(config.scripts, false, cb); 16007 } 16008 catch (e) 16009 { 16010 if (config.onfailure) 16011 config.onfailure("processing", e); 16012 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['processing', e, config]); 16013 } 16014}; 16015 16016BX.ajax.processScripts = function(scripts, bRunFirst, cb) 16017{ 16018 var scriptsExt = [], scriptsInt = ''; 16019 16020 cb = cb || BX.DoNothing; 16021 16022 for (var i = 0, length = scripts.length; i < length; i++) 16023 { 16024 if (typeof bRunFirst != 'undefined' && bRunFirst != !!scripts[i].bRunFirst) 16025 continue; 16026 16027 if (scripts[i].isInternal) 16028 scriptsInt += ';' + scripts[i].JS; 16029 else 16030 scriptsExt.push(scripts[i].JS); 16031 } 16032 16033 scriptsExt = BX.util.array_unique(scriptsExt); 16034 var inlineScripts = scriptsInt.length > 0 ? function() { BX.evalGlobal(scriptsInt); } : BX.DoNothing; 16035 16036 if (scriptsExt.length > 0) 16037 { 16038 BX.load(scriptsExt, function() { 16039 inlineScripts(); 16040 cb(); 16041 }); 16042 } 16043 else 16044 { 16045 inlineScripts(); 16046 cb(); 16047 } 16048}; 16049 16050// TODO: extend this function to use with any data objects or forms 16051BX.ajax.prepareData = function(arData, prefix) 16052{ 16053 var data = ''; 16054 if (BX.type.isString(arData)) 16055 data = arData; 16056 else if (null != arData) 16057 { 16058 for(var i in arData) 16059 { 16060 if (arData.hasOwnProperty(i)) 16061 { 16062 if (data.length > 0) 16063 data += '&'; 16064 var name = BX.util.urlencode(i); 16065 if(prefix) 16066 name = prefix + '[' + name + ']'; 16067 if(typeof arData[i] == 'object') 16068 data += BX.ajax.prepareData(arData[i], name); 16069 else 16070 data += name + '=' + BX.util.urlencode(arData[i]); 16071 } 16072 } 16073 } 16074 return data; 16075}; 16076 16077BX.ajax.xhrSuccess = function(xhr) 16078{ 16079 return (xhr.status >= 200 && xhr.status < 300) || xhr.status === 304 || xhr.status === 1223 || xhr.status === 0; 16080}; 16081 16082BX.ajax.Setup = function(config, bTemp) 16083{ 16084 bTemp = !!bTemp; 16085 16086 for (var i in config) 16087 { 16088 if (bTemp) 16089 tempDefaultConfig[i] = config[i]; 16090 else 16091 defaultConfig[i] = config[i]; 16092 } 16093}; 16094 16095BX.ajax.replaceLocalStorageValue = function(lsId, data, ttl) 16096{ 16097 if (!!BX.localStorage) 16098 BX.localStorage.set('ajax-' + lsId, data, ttl); 16099}; 16100 16101 16102BX.ajax._uncache = function(url) 16103{ 16104 return url + ((url.indexOf('?') !== -1 ? "&" : "?") + '_=' + (new Date()).getTime()); 16105}; 16106 16107/* simple interface */ 16108BX.ajax.get = function(url, data, callback) 16109{ 16110 if (BX.type.isFunction(data)) 16111 { 16112 callback = data; 16113 data = ''; 16114 } 16115
16116 data = BX.ajax.prepareData(data); 16117 16118 if (data) 16119 { 16120 url += (url.indexOf('?') !== -1 ? "&" : "?") + data; 16121 data = ''; 16122 } 16123 16124 return BX.ajax({ 16125 'method': 'GET', 16126 'dataType': 'html', 16127 'url': url, 16128 'data': '', 16129 'onsuccess': callback 16130 }); 16131}; 16132 16133BX.ajax.getCaptcha = function(callback) 16134{ 16135 return BX.ajax.loadJSON('/bitrix/tools/ajax_captcha.php', callback); 16136}; 16137 16138BX.ajax.insertToNode = function(url, node) 16139{ 16140 node = BX(node); 16141 if (!!node) 16142 { 16143 var eventArgs = { cancel: false }; 16144 BX.onCustomEvent('onAjaxInsertToNode', [{ url: url, node: node, eventArgs: eventArgs }]); 16145 if(eventArgs.cancel === true) 16146 { 16147 return; 16148 } 16149 16150 var show = null; 16151 if (!tempDefaultConfig.denyShowWait) 16152 { 16153 show = BX.showWait(node); 16154 delete tempDefaultConfig.denyShowWait; 16155 } 16156 16157 return BX.ajax.get(url, function(data) { 16158 node.innerHTML = data; 16159 BX.closeWait(node, show); 16160 }); 16161 } 16162}; 16163 16164BX.ajax.post = function(url, data, callback) 16165{ 16166 data = BX.ajax.prepareData(data); 16167 16168 return BX.ajax({ 16169 'method': 'POST', 16170 'dataType': 'html', 16171 'url': url, 16172 'data': data, 16173 'onsuccess': callback 16174 }); 16175}; 16176 16177/** 16178 * BX.ajax with BX.Promise 16179 * 16180 * @param config 16181 * @returns {BX.Promise|false} 16182 */ 16183BX.ajax.promise = function(config) 16184{ 16185 var result = new BX.Promise(); 16186 16187 config.onsuccess = function(data) 16188 { 16189 result.fulfill(data); 16190 }; 16191 config.onfailure = function(reason, httpStatus, config) 16192 { 16193 result.reject({ 16194 reason: reason, 16195 data: httpStatus, 16196 ajaxConfig: config, 16197 xhr: config.xhr 16198 }); 16199 }; 16200 16201 var xhr = BX.ajax(config); 16202 if (xhr) 16203 { 16204 if (typeof config.onrequeststart === 'function') 16205 { 16206 config.onrequeststart(xhr); 16207 } 16208 } 16209 else 16210 { 16211 result.reject({ 16212 reason: "init", 16213 data: false 16214 }); 16215 } 16216 16217 return result; 16218}; 16219 16220/* load and execute external file script with onload emulation */ 16221BX.ajax.loadScriptAjax = function(script_src, callback, bPreload) 16222{ 16223 if (BX.type.isArray(script_src)) 16224 { 16225 for (var i=0,len=script_src.length;i<len;i++) 16226 { 16227 BX.ajax.loadScriptAjax(script_src[i], callback, bPreload); 16228 } 16229 } 16230 else 16231 { 16232 var script_src_test = script_src.replace(/\.js\?.*/, '.js'); 16233 16234 if (r.script_self.test(script_src_test)) return; 16235 if (r.script_self_window.test(script_src_test) && BX.CWindow) return; 16236 if (r.script_self_admin.test(script_src_test) && BX.admin) return; 16237 16238 if (typeof loadedScripts[script_src_test] == 'undefined') 16239 { 16240 if (!!bPreload) 16241 { 16242 loadedScripts[script_src_test] = ''; 16243 return BX.loadScript(script_src); 16244 } 16245 else 16246 { 16247 return BX.ajax({ 16248 url: script_src, 16249 method: 'GET', 16250 dataType: 'script', 16251 processData: true, 16252 emulateOnload: false, 16253 scriptsRunFirst: true, 16254 async: false, 16255 start: true, 16256 onsuccess: function(result) { 16257 loadedScripts[script_src_test] = result; 16258 if (callback) 16259 callback(result); 16260 } 16261 }); 16262 } 16263 } 16264 else if (callback) 16265 { 16266 callback(loadedScripts[script_src_test]); 16267 } 16268 } 16269}; 16270 16271/* non-xhr loadings */ 16272BX.ajax.loadJSON = function(url, data, callback, callback_failure) 16273{ 16274 if (BX.type.isFunction(data)) 16275 { 16276 callback_failure = callback; 16277 callback = data; 16278 data = ''; 16279 } 16280 16281 data = BX.ajax.prepareData(data); 16282 16283 if (data) 16284 { 16285 url += (url.indexOf('?') !== -1 ? "&" : "?") + data; 16286 data = ''; 16287 } 16288 16289 return BX.ajax({ 16290 'method': 'GET', 16291 'dataType': 'json', 16292 'url': url, 16293 'onsuccess': callback, 16294 'onfailure': callback_failure 16295 }); 16296}; 16297 16298var getLastContentTypeHeader = function (headers) { 16299 if (!BX.Type.isArray(headers)) 16300 { 16301 return null; 16302 } 16303 var lastHeader = headers 16304 .filter(function (header) { 16305 return header.name === 'Content-Type'; 16306 }) 16307 .pop(); 16308 16309 return lastHeader ? lastHeader.value : null; 16310}; 16311 16312/** 16313 * @see isValidAnalyticsData in ui.analytics 16314* */ 16315const isValidAnalyticsData = function (analytics) 16316{ 16317 if (!BX.Type.isPlainObject(analytics)) 16318 { 16319 console.error('BX.ajax: {analytics} must be an object.'); 16320 16321 return false; 16322 } 16323 16324 const requiredFields = ['event', 'tool', 'category']; 16325 for (const field of requiredFields) 16326 { 16327 if (!BX.Type.isStringFilled(analytics[field])) 16328 { 16329 console.error(`BX.ajax: The "${field}" property in the "analytics" object must be a non-empty string.`); 16330 16331 return false;
16332 } 16333 } 16334 16335 const additionalFields = ['p1', 'p2', 'p3', 'p4', 'p5']; 16336 for (const field of additionalFields) 16337 { 16338 const value = analytics[field]; 16339 if (!BX.Type.isStringFilled(value)) 16340 { 16341 continue; 16342 } 16343 16344 if (value.split('_').length > 2) 16345 { 16346 console.error(`BX.ajax: The "${field}" property (${value}) in the "analytics" object must be a string containing a single underscore.`); 16347 16348 return false; 16349 } 16350 } 16351 16352 return true; 16353}; 16354 16355const processAnalyticsDataToGetParameters = function(config) 16356{ 16357 const getParameters = {}; 16358 if (BX.Type.isStringFilled(config.analyticsLabel) || BX.Type.isPlainObject(config.analyticsLabel)) 16359 { 16360 getParameters.analyticsLabel = config.analyticsLabel; 16361 } 16362 16363 if (BX.Type.isPlainObject(config.analytics)) 16364 { 16365 if (config.analyticsLabel) 16366 { 16367 delete getParameters.analyticsLabel; 16368 console.error('BX.ajax: Only {analytics} or {analyticsLabel} should be used. If both are present, {analyticsLabel} will be ignored.'); 16369 } 16370 16371 if (isValidAnalyticsData(config.analytics)) 16372 { 16373 getParameters.st = config.analytics; 16374 } 16375 else 16376 { 16377 console.error('BX.ajax: {analytics} is invalid and is skipped.'); 16378 } 16379 } 16380 16381 return getParameters; 16382}; 16383 16384const prepareAjaxGetParameters = function(config) 16385{ 16386 let getParameters = config.getParameters || {}; 16387 getParameters = { ...getParameters, ...processAnalyticsDataToGetParameters(config) }; 16388 16389 if (typeof config.mode !== 'undefined') 16390 { 16391 getParameters.mode = config.mode; 16392 } 16393 if (config.navigation) 16394 { 16395 if (config.navigation.page) 16396 { 16397 getParameters.nav = 'page-' + config.navigation.page; 16398 } 16399 if (config.navigation.size) 16400 { 16401 if (getParameters.nav) 16402 { 16403 getParameters.nav += '-'; 16404 } 16405 else 16406 { 16407 getParameters.nav = ''; 16408 } 16409 getParameters.nav += 'size-' + config.navigation.size; 16410 } 16411 } 16412 16413 return getParameters; 16414}; 16415 16416var prepareAjaxConfig = function(config) 16417{ 16418 config = BX.type.isPlainObject(config) ? config : {}; 16419 16420 config.headers = config.headers || []; 16421 config.headers.push({name: 'X-Bitrix-Csrf-Token', value: BX.bitrix_sessid()}); 16422 if (BX.message.SITE_ID) 16423 { 16424 config.headers.push({name: 'X-Bitrix-Site-Id', value: BX.message.SITE_ID}); 16425 } 16426 16427 if (typeof config.json !== 'undefined') 16428 { 16429 if (!BX.type.isPlainObject(config.json)) 16430 { 16431 throw new Error('Wrong `config.json`, plain object expected.') 16432 } 16433 16434 config.headers.push({name: 'Content-Type', value: 'application/json'}); 16435 config.data = config.json; 16436 config.preparePost = false; 16437 } 16438 else if (config.data instanceof FormData) 16439 { 16440 config.preparePost = false; 16441 if (typeof config.signedParameters !== 'undefined') 16442 { 16443 config.data.append('signedParameters', config.signedParameters); 16444 } 16445 } 16446 else if (BX.type.isPlainObject(config.data) || BX.Type.isNil(config.data)) 16447 { 16448 config.data = BX.type.isPlainObject(config.data) ? config.data : {}; 16449 if (typeof config.signedParameters !== 'undefined') 16450 { 16451 config.data.signedParameters = config.signedParameters; 16452 } 16453 } 16454 16455 if (!config.method) 16456 { 16457 config.method = 'POST' 16458 } 16459 16460 return config; 16461}; 16462 16463var buildAjaxPromiseToRestoreCsrf = function(config, withoutRestoringCsrf) 16464{ 16465 withoutRestoringCsrf = withoutRestoringCsrf || false; 16466 var originalConfig = BX.clone(config); 16467 var request = null; 16468 16469 var onrequeststart = config.onrequeststart; 16470 config.onrequeststart = function(xhr) { 16471 request = xhr; 16472 if (BX.type.isFunction(onrequeststart)) 16473 { 16474 onrequeststart(xhr); 16475 } 16476 }; 16477 var onrequeststartOrig = originalConfig.onrequeststart; 16478 originalConfig.onrequeststart = function(xhr) { 16479 request = xhr; 16480 if (BX.type.isFunction(onrequeststartOrig)) 16481 { 16482 onrequeststartOrig(xhr); 16483 } 16484 }; 16485 16486 var promise = BX.ajax.promise(config); 16487 16488 return promise.then(function(response) { 16489 if (!withoutRestoringCsrf && BX.type.isPlainObject(response) && BX.type.isArray(response.errors)) 16490 { 16491 var csrfProblem = false; 16492 response.errors.forEach(function(error) { 16493 if (error.code === 'invalid_csrf' && error.customData.csrf) 16494 { 16495 BX.message({'bitrix_sessid': error.customData.csrf}); 16496 16497 originalConfig.headers = originalConfig.headers || []; 16498 originalConfig.headers = originalConfig.headers.filter(function(header) {
16499 return header && header.name !== 'X-Bitrix-Csrf-Token'; 16500 }); 16501 originalConfig.headers.push({name: 'X-Bitrix-Csrf-Token', value: BX.bitrix_sessid()}); 16502 16503 csrfProblem = true; 16504 } 16505 }); 16506 16507 if (csrfProblem) 16508 { 16509 return buildAjaxPromiseToRestoreCsrf(originalConfig, true); 16510 } 16511 } 16512 16513 if (!BX.type.isPlainObject(response) || response.status !== 'success') 16514 { 16515 var errorPromise = new BX.Promise(); 16516 errorPromise.reject(response); 16517 16518 return errorPromise; 16519 } 16520 16521 return response; 16522 }).catch(function(data) { 16523 var ajaxReject = new BX.Promise(); 16524 16525 var originalJsonResponse; 16526 if (BX.type.isPlainObject(data) && data.xhr && data.xhr.responseText) 16527 { 16528 try 16529 { 16530 originalJsonResponse = JSON.parse(data.xhr.responseText); 16531 data = originalJsonResponse; 16532 } 16533 catch (err) 16534 {} 16535 } 16536 16537 if (BX.type.isPlainObject(data) && data.status && data.hasOwnProperty('data')) 16538 { 16539 ajaxReject.reject(data); 16540 } 16541 else 16542 { 16543 ajaxReject.reject({ 16544 status: 'error', 16545 data: { 16546 ajaxRejectData: data 16547 }, 16548 errors: [ 16549 { 16550 code: 'NETWORK_ERROR', 16551 message: 'Network error' 16552 } 16553 ] 16554 }); 16555 } 16556 16557 return ajaxReject; 16558 }).then(function(response){ 16559 16560 var assetsLoaded = new BX.Promise(); 16561 16562 var headers = request.getAllResponseHeaders().trim().split(/[\r\n]+/); 16563 var headerMap = {}; 16564 headers.forEach(function (line) { 16565 var parts = line.split(': '); 16566 var header = parts.shift().toLowerCase(); 16567 headerMap[header] = parts.join(': '); 16568 }); 16569 16570 if (!headerMap['x-process-assets']) 16571 { 16572 assetsLoaded.fulfill(response); 16573 16574 return assetsLoaded; 16575 } 16576 16577 var assets = BX.prop.getObject(BX.prop.getObject(response, "data", {}), "assets", {}); 16578 16579 var inlineScripts = []; 16580 if (BX.Type.isArrayFilled(assets.string)) 16581 { 16582 assets.string 16583 .reduce(function(acc, item) { 16584 if (String(item).length > 0 && !acc.includes(item)) 16585 { 16586 acc.push(item); 16587 } 16588 16589 return acc; 16590 }, []) 16591 .forEach(function(item) { 16592 if (String(item).startsWith('<script type="extension/settings"')) 16593 { 16594 BX.html(document.head, item, { useAdjacentHTML: true }); 16595 } 16596 else 16597 { 16598 inlineScripts.push(item); 16599 } 16600 }); 16601 } 16602 16603 var promise = new Promise(function(resolve, reject) { 16604 var css = BX.prop.getArray(assets, "css", []); 16605 BX.load(css, function(){ 16606 BX.loadScript( 16607 BX.prop.getArray(assets, "js", []), 16608 resolve 16609 ); 16610 }); 16611 }); 16612 16613 promise.then(function(){ 16614 var stringAsset = inlineScripts.join('\n'); 16615 BX.html(document.head, stringAsset, { useAdjacentHTML: true }).then(function(){ 16616 assetsLoaded.fulfill(response); 16617 }); 16618 }); 16619 16620 return assetsLoaded; 16621 }); 16622}; 16623 16624/** 16625 * 16626 * @param {string} action 16627 * @param {Object} config 16628 * @param {?string|?Object} [config.analyticsLabel] 16629 * @param {?Object} [config.analytics] 16630 * @param {string} [config.analytics.event] 16631 * @param {string} [config.analytics.tool] 16632 * @param {string} [config.analytics.category] 16633 * @param {?string} [config.analytics.c_section] 16634 * @param {?string} [config.analytics.c_sub_section] 16635 * @param {?string} [config.analytics.c_element] 16636 * @param {?string} [config.analytics.type] 16637 * @param {?string} [config.analytics.p1] 16638 * @param {?string} [config.analytics.p2] 16639 * @param {?string} [config.analytics.p3] 16640 * @param {?string} [config.analytics.p4] 16641 * @param {?string} [config.analytics.p5] 16642 * @param {?('success' | 'error' | 'attempt' | 'cancel')} [config.analytics.status] 16643 * @param {string} [config.method='POST'] 16644 * @param {Object} [config.data] 16645 * @param {?Object} [config.getParameters] 16646 * @param {?Object} [config.headers] 16647 * @param {?Object} [config.timeout] 16648 * @param {Object} [config.navigation] 16649 * @param {number} [config.navigation.page] 16650 */ 16651BX.ajax.runAction = function(action, config) 16652{ 16653 config = prepareAjaxConfig(config); 16654 var getParameters = prepareAjaxGetParameters(config); 16655 getParameters.action = action; 16656
16657 var url = '/bitrix/services/main/ajax.php?' + BX.ajax.prepareData(getParameters); 16658 return buildAjaxPromiseToRestoreCsrf({ 16659 method: config.method, 16660 dataType: 'json', 16661 url: url, 16662 data: config.data, 16663 timeout: config.timeout, 16664 preparePost: config.preparePost, 16665 headers: config.headers, 16666 onrequeststart: config.onrequeststart, 16667 onprogress: config.onprogress, 16668 onprogressupload: config.onprogressupload 16669 }); 16670}; 16671 16672/** 16673 * 16674 * @param {string} component 16675 * @param {string} action 16676 * @param {Object} config 16677 * @param {?string|?Object} [config.analyticsLabel] 16678 * @param {?Object} [config.analytics] 16679 * @param {string} [config.analytics.event] 16680 * @param {string} [config.analytics.tool] 16681 * @param {string} [config.analytics.category] 16682 * @param {?string} [config.analytics.c_section] 16683 * @param {?string} [config.analytics.c_sub_section] 16684 * @param {?string} [config.analytics.c_element] 16685 * @param {?string} [config.analytics.type] 16686 * @param {?string} [config.analytics.p1] 16687 * @param {?string} [config.analytics.p2] 16688 * @param {?string} [config.analytics.p3] 16689 * @param {?string} [config.analytics.p4] 16690 * @param {?string} [config.analytics.p5] 16691 * @param {?string} [config.signedParameters] 16692 * @param {string} [config.method='POST'] 16693 * @param {string} [config.mode='ajax'] Ajax or class. 16694 * @param {Object} [config.data] 16695 * @param {?Object} [config.getParameters] 16696 * @param {?array} [config.headers] 16697 * @param {?number} [config.timeout] 16698 * @param {Object} [config.navigation] 16699 */ 16700BX.ajax.runComponentAction = function (component, action, config) 16701{ 16702 config = prepareAjaxConfig(config); 16703 config.mode = config.mode || 'ajax'; 16704 16705 var getParameters = prepareAjaxGetParameters(config); 16706 getParameters.c = component; 16707 getParameters.action = action; 16708
16709 var url = '/bitrix/services/main/ajax.php?' + BX.ajax.prepareData(getParameters); 16710 16711 return buildAjaxPromiseToRestoreCsrf({ 16712 method: config.method, 16713 dataType: 'json', 16714 url: url, 16715 data: config.data, 16716 timeout: config.timeout, 16717 preparePost: config.preparePost, 16718 headers: config.headers, 16719 onrequeststart: (config.onrequeststart ? config.onrequeststart : null), 16720 onprogress: config.onprogress, 16721 onprogressupload: config.onprogressupload 16722 }); 16723}; 16724 16725/* 16726arObs = [{ 16727 url: url, 16728 type: html|script|json|css, 16729 callback: function 16730}] 16731*/ 16732BX.ajax.load = function(arObs, callback) 16733{ 16734 if (!BX.type.isArray(arObs)) 16735 arObs = [arObs]; 16736 16737 var cnt = 0; 16738 16739 if (!BX.type.isFunction(callback)) 16740 callback = BX.DoNothing; 16741 16742 var handler = function(data) 16743 { 16744 if (BX.type.isFunction(this.callback)) 16745 this.callback(data); 16746 16747 if (++cnt >= len) 16748 callback(); 16749 }; 16750 16751 for (var i = 0, len = arObs.length; i<len; i++) 16752 { 16753 switch(arObs[i].type.toUpperCase()) 16754 { 16755 case 'SCRIPT': 16756 BX.loadScript([arObs[i].url], BX.proxy(handler, arObs[i])); 16757 break; 16758 case 'CSS': 16759 BX.loadCSS([arObs[i].url]); 16760 16761 if (++cnt >= len) 16762 callback(); 16763 break; 16764 case 'JSON': 16765 BX.ajax.loadJSON(arObs[i].url, BX.proxy(handler, arObs[i])); 16766 break; 16767 16768 default: 16769 BX.ajax.get(arObs[i].url, '', BX.proxy(handler, arObs[i])); 16770 break; 16771 } 16772 } 16773}; 16774 16775/* ajax form sending */ 16776BX.ajax.submit = function(obForm, callback) 16777{ 16778 if (!obForm.target) 16779 { 16780 if (null == obForm.BXFormTarget) 16781 { 16782 var frame_name = 'formTarget_' + Math.random(); 16783 obForm.BXFormTarget = document.body.appendChild(BX.create('IFRAME', { 16784 props: { 16785 name: frame_name, 16786 id: frame_name, 16787 src: 'javascript:void(0)' 16788 }, 16789 style: { 16790 display: 'none' 16791 } 16792 })); 16793 } 16794 16795 obForm.target = obForm.BXFormTarget.name; 16796 } 16797 16798 obForm.BXFormCallback = callback; 16799 BX.bind(obForm.BXFormTarget, 'load', BX.proxy(BX.ajax._submit_callback, obForm)); 16800 16801 BX.submit(obForm); 16802 16803 return false; 16804}; 16805 16806BX.ajax.submitComponentForm = function(obForm, container, bWait) 16807{ 16808 if (!obForm.target) 16809 { 16810 if (null == obForm.BXFormTarget) 16811 { 16812 var frame_name = 'formTarget_' + Math.random(); 16813 obForm.BXFormTarget = document.body.appendChild(BX.create('IFRAME', { 16814 props: { 16815 name: frame_name, 16816 id: frame_name, 16817 src: 'javascript:void(0)' 16818 }, 16819 style: { 16820 display: 'none' 16821 } 16822 })); 16823 } 16824 16825 obForm.target = obForm.BXFormTarget.name; 16826 } 16827 16828 if (!!bWait) 16829 var w = BX.showWait(container); 16830 16831 obForm.BXFormCallback = function(d) { 16832 if (!!bWait) 16833 BX.closeWait(w); 16834 16835 var callOnload = function(){ 16836 if(!!window.bxcompajaxframeonload) 16837 { 16838 setTimeout(function(){window.bxcompajaxframeonload();window.bxcompajaxframeonload=null;}, 10); 16839 } 16840 }; 16841 16842 BX(container).innerHTML = d; 16843 BX.onCustomEvent('onAjaxSuccess', [null,null,callOnload]); 16844 }; 16845 16846 BX.bind(obForm.BXFormTarget, 'load', BX.proxy(BX.ajax._submit_callback, obForm)); 16847 16848 return true; 16849}; 16850 16851// func will be executed in form context 16852BX.ajax._submit_callback = function() 16853{ 16854 //opera and IE8 triggers onload event even on empty iframe 16855 try 16856 { 16857 if(this.BXFormTarget.contentWindow.location.href.indexOf('http') != 0) 16858 return; 16859 } catch (e) { 16860 return; 16861 } 16862 16863 if (this.BXFormCallback) 16864 this.BXFormCallback.apply(this, [this.BXFormTarget.contentWindow.document.body.innerHTML]); 16865 16866 BX.unbindAll(this.BXFormTarget); 16867}; 16868 16869BX.ajax.prepareForm = function(obForm, data) 16870{ 16871 data = (!!data ? data : {}); 16872 var i, ii, el, 16873 _data = [], 16874 n = obForm.elements.length, 16875 files = 0, length = 0; 16876 if(!!obForm) 16877 { 16878 for (i = 0; i < n; i++) 16879 { 16880 el = obForm.elements[i]; 16881 if (el.disabled) 16882 continue; 16883 16884 if(!el.type) 16885 continue; 16886 16887 switch(el.type.toLowerCase()) 16888 { 16889 case 'text': 16890 case 'textarea': 16891 case 'password': 16892 case 'number': 16893 case 'hidden': 16894 case 'select-one': 16895 _data.push({name: el.name, value: el.value}); 16896 length += (el.name.length + el.value.length); 16897 break; 16898 case 'file': 16899 if (!!el.files) 16900 { 16901 for (ii = 0; ii < el.files.length; ii++) 16902 { 16903 files++; 16904 _data.push({name: el.name, value: el.files[ii], file : true}); 16905 length += el.files[ii].size; 16906 } 16907 } 16908 break; 16909 case 'radio':
16910 case 'checkbox': 16911 if(el.checked) 16912 { 16913 _data.push({name: el.name, value: el.value}); 16914 length += (el.name.length + el.value.length); 16915 } 16916 break; 16917 case 'select-multiple': 16918 for (var j = 0; j < el.options.length; j++) 16919 { 16920 if (el.options[j].selected) 16921 { 16922 _data.push({name : el.name, value : el.options[j].value}); 16923 length += (el.name.length + el.options[j].length); 16924 } 16925 } 16926 break; 16927 default: 16928 break; 16929 } 16930 } 16931 16932 i = 0; length = 0; 16933 var current = data, name, rest, pp, tmpKey; 16934 16935 while(i < _data.length) 16936 { 16937 var p = _data[i].name.indexOf('['); 16938 if (tmpKey) 16939 { 16940 current[_data[i].name] = {}; 16941 current[_data[i].name][tmpKey.replace(/\[|\]/gi, '')] = _data[i].value; 16942 current = data; 16943 tmpKey = null; 16944 i++; 16945 } 16946 else if (p == -1) 16947 { 16948 current[_data[i].name] = _data[i].value; 16949 current = data; 16950 i++; 16951 } 16952 else 16953 { 16954 name = _data[i].name.substring(0, p); 16955 rest = _data[i].name.substring(p+1); 16956 pp = rest.indexOf(']'); 16957 16958 if(pp == -1) 16959 { 16960 if (!current[name]) 16961 current[name] = []; 16962 current = data; 16963 i++; 16964 } 16965 else if(pp == 0) 16966 { 16967 if (!current[name]) 16968 current[name] = []; 16969 //No index specified - so take the next integer 16970 current = current[name]; 16971 _data[i].name = '' + current.length; 16972 if (rest.substring(pp+1).indexOf('[') === 0) 16973 tmpKey = rest.substring(0, pp) + rest.substring(pp+1); 16974 } 16975 else 16976 { 16977 if (!current[name]) 16978 current[name] = {}; 16979 //Now index name becomes and name and we go deeper into the array 16980 current = current[name]; 16981 _data[i].name = rest.substring(0, pp) + rest.substring(pp+1); 16982 } 16983 } 16984 } 16985 } 16986 return {data : data, filesCount : files, roughSize : length}; 16987}; 16988BX.ajax.submitAjax = function(obForm, config) 16989{ 16990 config = (config !== null && typeof config == "object" ? config : {}); 16991 config.url = (config["url"] || obForm.getAttribute("action")); 16992 16993 var additionalData = (config["data"] || {}); 16994 config.data = BX.ajax.prepareForm(obForm).data; 16995 for (var ii in additionalData) 16996 { 16997 if (additionalData.hasOwnProperty(ii)) 16998 { 16999 config.data[ii] = additionalData[ii]; 17000 } 17001 } 17002 17003 if (!window["FormData"]) 17004 { 17005 BX.ajax(config); 17006 } 17007 else 17008 { 17009 var isFile = function(item) 17010 { 17011 var res = Object.prototype.toString.call(item); 17012 return (res == '[object File]' || res == '[object Blob]'); 17013 }, 17014 appendToForm = function(fd, key, val) 17015 { 17016 if (!!val && typeof val == "object" && !isFile(val)) 17017 { 17018 for (var ii in val) 17019 { 17020 if (val.hasOwnProperty(ii)) 17021 { 17022 appendToForm(fd, (key == '' ? ii : key + '[' + ii + ']'), val[ii]); 17023 } 17024 } 17025 } 17026 else 17027 fd.append(key, (!!val ? val : '')); 17028 }, 17029 prepareData = function(arData) 17030 { 17031 var data = {}; 17032 if (null != arData) 17033 { 17034 if(typeof arData == 'object') 17035 { 17036 for(var i in arData) 17037 { 17038 if (arData.hasOwnProperty(i)) 17039 { 17040 var name = BX.util.urlencode(i); 17041 if(typeof arData[i] == 'object' && arData[i]["file"] !== true) 17042 data[name] = prepareData(arData[i]); 17043 else if (arData[i]["file"] === true) 17044 data[name] = arData[i]["value"]; 17045 else 17046 data[name] = BX.util.urlencode(arData[i]); 17047 } 17048 } 17049 } 17050 else 17051 data = BX.util.urlencode(arData); 17052 } 17053 return data; 17054 }, 17055 fd = new window.FormData(); 17056 17057 if (config.method !== 'POST') 17058 { 17059 config.data = BX.ajax.prepareData(config.data); 17060 if (config.data) 17061 { 17062 config.url += (config.url.indexOf('?') !== -1 ? "&" : "?") + config.data; 17063 config.data = ''; 17064 } 17065 } 17066 else 17067 { 17068 if (config.preparePost === true) 17069 config.data = prepareData(config.data); 17070 appendToForm(fd, '', config.data); 17071 config.data = fd; 17072 } 17073 17074 config.preparePost = false; 17075 config.start = false;
17076 17077 var xhr = BX.ajax(config); 17078 if (!!config["onprogress"]) 17079 xhr.upload.addEventListener( 17080 'progress', 17081 function(e){ 17082 var percent = null; 17083 if(e.lengthComputable && (e.total || e["totalSize"])) { 17084 percent = e.loaded * 100 / (e.total || e["totalSize"]); 17085 } 17086 config["onprogress"](e, percent); 17087 } 17088 ); 17089 xhr.send(fd); 17090 } 17091}; 17092 17093BX.ajax.UpdatePageData = function (arData) 17094{ 17095 if (arData.TITLE) 17096 BX.ajax.UpdatePageTitle(arData.TITLE); 17097 if (arData.WINDOW_TITLE || arData.TITLE) 17098 BX.ajax.UpdateWindowTitle(arData.WINDOW_TITLE || arData.TITLE); 17099 if (arData.NAV_CHAIN) 17100 BX.ajax.UpdatePageNavChain(arData.NAV_CHAIN); 17101 if (arData.CSS && arData.CSS.length > 0) 17102 BX.loadCSS(arData.CSS); 17103 if (arData.SCRIPTS && arData.SCRIPTS.length > 0) 17104 { 17105 var f = function(result,config,cb){ 17106 17107 if(!!config && BX.type.isArray(config.scripts)) 17108 { 17109 for(var i=0,l=arData.SCRIPTS.length;i<l;i++) 17110 { 17111 config.scripts.push({isInternal:false,JS:arData.SCRIPTS[i]}); 17112 } 17113 } 17114 else 17115 { 17116 BX.loadScript(arData.SCRIPTS,cb); 17117 } 17118 17119 BX.removeCustomEvent('onAjaxSuccess',f); 17120 }; 17121 BX.addCustomEvent('onAjaxSuccess',f); 17122 } 17123 else 17124 { 17125 var f1 = function(result,config,cb){ 17126 if(BX.type.isFunction(cb)) 17127 { 17128 cb(); 17129 } 17130 BX.removeCustomEvent('onAjaxSuccess',f1); 17131 }; 17132 BX.addCustomEvent('onAjaxSuccess', f1); 17133 } 17134}; 17135 17136BX.ajax.UpdatePageTitle = function(title) 17137{ 17138 var obTitle = BX('pagetitle'); 17139 if (obTitle) 17140 { 17141 BX.remove(obTitle.firstChild); 17142 if (!obTitle.firstChild) 17143 obTitle.appendChild(document.createTextNode(title)); 17144 else 17145 obTitle.insertBefore(document.createTextNode(title), obTitle.firstChild); 17146 } 17147}; 17148 17149BX.ajax.UpdateWindowTitle = function(title) 17150{ 17151 document.title = title; 17152}; 17153 17154BX.ajax.UpdatePageNavChain = function(nav_chain) 17155{ 17156 var obNavChain = BX('navigation'); 17157 if (obNavChain) 17158 { 17159 obNavChain.innerHTML = nav_chain; 17160 } 17161}; 17162 17163/* user options handling */ 17164BX.userOptions = { 17165 options: null, 17166 bSend: false, 17167 delay: 5000, 17168 path: '/bitrix/admin/user_options.php?' 17169}; 17170 17171BX.userOptions.setAjaxPath = function(url) 17172{ 17173 // eslint-disable-next-line no-console 17174 console.warn('BX.userOptions.setAjaxPath is deprecated. There is no way to change ajax path.'); 17175}; 17176BX.userOptions.save = function(category, name, valueName, value, common) 17177{ 17178 if (BX.userOptions.options === null) 17179 { 17180 BX.userOptions.options = {}; 17181 } 17182 17183 common = Boolean(common); 17184 BX.userOptions.options[`${category}.${name}.${valueName}`] = [category, name, valueName, value, common]; 17185 17186 const stringPackedValue = BX.userOptions.__get(); 17187 if (stringPackedValue) 17188 { 17189 document.cookie = `${BX.message('COOKIE_PREFIX')}_LAST_SETTINGS=${encodeURIComponent(stringPackedValue)}&sessid=${BX.bitrix_sessid()}; expires=Thu, 31 Dec ${(new Date()).getFullYear() + 1} 23:59:59 GMT; path=/;`; 17190 } 17191 17192 if (!BX.userOptions.bSend) 17193 { 17194 BX.userOptions.bSend = true; 17195 setTimeout(() => { 17196 BX.userOptions.send(null); 17197 }, BX.userOptions.delay); 17198 } 17199}; 17200 17201BX.userOptions.send = function(callback) 17202{ 17203 const values = BX.userOptions.__get_values({ backwardCompatibility: true}); 17204 17205 BX.userOptions.options = null; 17206 BX.userOptions.bSend = false; 17207 17208 if (values) 17209 { 17210 document.cookie = `${BX.message('COOKIE_PREFIX')}_LAST_SETTINGS=; path=/;`; 17211 17212 BX.ajax.runAction( 17213 'main.userOption.saveOptions', 17214 { 17215 json: { 17216 newValues: values, 17217 }, 17218 }, 17219 ).then((response) => { 17220 if (BX.type.isFunction(callback)) 17221 { 17222 callback(response); 17223 } 17224 }); 17225 } 17226}; 17227 17228BX.userOptions.del = function(category, name, common, callback) 17229{ 17230 BX.ajax.runAction( 17231 'main.userOption.deleteOption', 17232 { 17233 json: { 17234 category, 17235 name, 17236 common, 17237 }, 17238 }, 17239 ).then((response) => { 17240 if (BX.type.isFunction(callback)) 17241 { 17242 callback(response); 17243 } 17244 }); 17245}; 17246 17247BX.userOptions.__get_values = function({ backwardCompatibility }) 17248{ 17249 if (!BX.userOptions || !BX.Type.isPlainObject(BX.userOptions.options)) 17250 { 17251 return null; 17252 } 17253 17254 const CATEGORY = 0; 17255 const NAME = 1; 17256 const VALUE_NAME = 2; 17257 const VALUE = 3; 17258 const IS_DEFAULT = 4; 17259 17260 const packedValues = { p: [] }; 17261 let currentIndex = -1; 17262 let previousOptionIdentifier = ''; 17263 17264 Object.entries(BX.userOptions.options).forEach(([key, userOption]) => { 17265 const category = userOption[CATEGORY]; 17266 const name = userOption[NAME]; 17267 const currentOptionIdentifier = `${category}.${name}`; 17268 17269 if (previousOptionIdentifier !== currentOptionIdentifier) 17270 { 17271 currentIndex++; 17272 packedValues.p.push({ 17273 c: category, 17274 n: name, 17275 v: {}, 17276 }); 17277 if (userOption[IS_DEFAULT] === true) 17278 { 17279 packedValues.p[currentIndex].d = 'Y'; 17280 } 17281 previousOptionIdentifier = currentOptionIdentifier; 17282 } 17283 17284 if (userOption[VALUE_NAME] === null) 17285 { 17286 packedValues.p[currentIndex].v = userOption[VALUE]; 17287 } 17288 else 17289 { 17290 let data = userOption[VALUE]; 17291 if (backwardCompatibility && Array.isArray(userOption[VALUE])) 17292 { 17293 data = userOption[VALUE].join(','); 17294 } 17295 packedValues.p[currentIndex].v[userOption[VALUE_NAME]] = data; 17296 } 17297 }); 17298 17299 return packedValues.p.length > 0 ? packedValues.p : null; 17300}; 17301 17302/** 17303 * @deprecated Use instead BX.userOptions.__get_values. 17304 * */ 17305BX.userOptions.__get = function() 17306{ 17307 if (!BX.userOptions.options) return ''; 17308 17309 var sParam = '', n = -1, prevParam = '', aOpt, i; 17310 17311 for (i in BX.userOptions.options) 17312 { 17313 if(BX.userOptions.options.hasOwnProperty(i)) 17314 { 17315 aOpt = BX.userOptions.options[i]; 17316 17317 if (prevParam != aOpt[0]+'.'+aOpt[1]) 17318 { 17319 n++; 17320 sParam += '&p['+n+'][c]='+BX.util.urlencode(aOpt[0]); 17321 sParam += '&p['+n+'][n]='+BX.util.urlencode(aOpt[1]); 17322 if (aOpt[4] == true) 17323 sParam += '&p['+n+'][d]=Y'; 17324 prevParam = aOpt[0]+'.'+aOpt[1]; 17325 } 17326 17327 var valueName = aOpt[2]; 17328 var value = aOpt[3]; 17329 17330 if (valueName === null) 17331 { 17332 sParam += '&p['+n+'][v]='+BX.util.urlencode(value); 17333 } 17334 else 17335 {
17336 sParam += '&p['+n+'][v]['+BX.util.urlencode(valueName)+']='+BX.util.urlencode(value); 17337 } 17338 } 17339 } 17340 17341 return sParam.substr(1); 17342}; 17343 17344BX.ajax.history = { 17345 expected_hash: '', 17346 17347 obParams: null, 17348 17349 obFrame: null, 17350 obImage: null, 17351 17352 obTimer: null, 17353 17354 bInited: false, 17355 bHashCollision: false, 17356 bPushState: !!(history.pushState && BX.type.isFunction(history.pushState)), 17357 17358 startState: null, 17359 17360 init: function(obParams) 17361 { 17362 if (BX.ajax.history.bInited) 17363 return; 17364 17365 this.obParams = obParams; 17366 var obCurrentState = this.obParams.getState(); 17367 17368 if (BX.ajax.history.bPushState) 17369 { 17370 BX.ajax.history.expected_hash = window.location.pathname; 17371 if (window.location.search) 17372 BX.ajax.history.expected_hash += window.location.search; 17373 17374 BX.ajax.history.put(obCurrentState, BX.ajax.history.expected_hash, '', true); 17375 // due to some strange thing, chrome calls popstate event on page start. so we should delay it 17376 setTimeout(function(){BX.bind(window, 'popstate', BX.ajax.history.__hashListener);}, 500); 17377 } 17378 else 17379 { 17380 BX.ajax.history.expected_hash = window.location.hash; 17381 17382 if (!BX.ajax.history.expected_hash || BX.ajax.history.expected_hash == '#') 17383 BX.ajax.history.expected_hash = '__bx_no_hash__'; 17384 17385 jsAjaxHistoryContainer.put(BX.ajax.history.expected_hash, obCurrentState); 17386 BX.ajax.history.obTimer = setTimeout(BX.ajax.history.__hashListener, 500); 17387 17388 if (BX.browser.IsIE()) 17389 { 17390 BX.ajax.history.obFrame = document.createElement('IFRAME'); 17391 BX.hide_object(BX.ajax.history.obFrame); 17392 17393 document.body.appendChild(BX.ajax.history.obFrame); 17394 17395 BX.ajax.history.obFrame.contentWindow.document.open(); 17396 BX.ajax.history.obFrame.contentWindow.document.write(BX.ajax.history.expected_hash); 17397 BX.ajax.history.obFrame.contentWindow.document.close(); 17398 } 17399 else if (BX.browser.IsOpera()) 17400 { 17401 BX.ajax.history.obImage = document.createElement('IMG'); 17402 BX.hide_object(BX.ajax.history.obImage); 17403 17404 document.body.appendChild(BX.ajax.history.obImage); 17405 17406 BX.ajax.history.obImage.setAttribute('src', 'javascript:location.href = \'javascript:BX.ajax.history.__hashListener();\';'); 17407 } 17408 } 17409 17410 BX.ajax.history.bInited = true; 17411 }, 17412 17413 __hashListener: function(e) 17414 { 17415 e = e || window.event || {state:false}; 17416 17417 if (BX.ajax.history.bPushState) 17418 { 17419 BX.ajax.history.obParams.setState(e.state||BX.ajax.history.startState); 17420 } 17421 else 17422 { 17423 if (BX.ajax.history.obTimer) 17424 { 17425 window.clearTimeout(BX.ajax.history.obTimer); 17426 BX.ajax.history.obTimer = null; 17427 } 17428 17429 var current_hash; 17430 if (null != BX.ajax.history.obFrame) 17431 current_hash = BX.ajax.history.obFrame.contentWindow.document.body.innerText; 17432 else 17433 current_hash = window.location.hash; 17434 17435 if (!current_hash || current_hash == '#') 17436 current_hash = '__bx_no_hash__'; 17437 17438 if (current_hash.indexOf('#') == 0) 17439 current_hash = current_hash.substring(1); 17440 17441 if (current_hash != BX.ajax.history.expected_hash) 17442 { 17443 var state = jsAjaxHistoryContainer.get(current_hash); 17444 if (state) 17445 { 17446 BX.ajax.history.obParams.setState(state); 17447 17448 BX.ajax.history.expected_hash = current_hash; 17449 if (null != BX.ajax.history.obFrame) 17450 { 17451 var __hash = current_hash == '__bx_no_hash__' ? '' : current_hash; 17452 if (window.location.hash != __hash && window.location.hash != '#' + __hash) 17453 window.location.hash = __hash; 17454 } 17455 } 17456 } 17457 17458 BX.ajax.history.obTimer = setTimeout(BX.ajax.history.__hashListener, 500); 17459 } 17460 }, 17461 17462 put: function(state, new_hash, new_hash1, bStartState) 17463 { 17464 if (this.bPushState) 17465 { 17466 if(!bStartState) 17467 { 17468 history.pushState(state, '', new_hash); 17469 } 17470 else 17471 { 17472 BX.ajax.history.startState = state; 17473 } 17474 } 17475 else 17476 { 17477 if (typeof new_hash1 != 'undefined') 17478 new_hash = new_hash1; 17479 else 17480 new_hash = 'view' + new_hash; 17481 17482 jsAjaxHistoryContainer.put(new_hash, state); 17483 BX.ajax.history.expected_hash = new_hash; 17484 17485 window.location.hash = BX.util.urlencode(new_hash); 17486 17487 if (null != BX.ajax.history.obFrame) 17488 { 17489 BX.ajax.history.obFrame.contentWindow.document.open(); 17490 BX.ajax.history.obFrame.contentWindow.document.write(new_hash); 17491 BX.ajax.history.obFrame.contentWindow.document.close(); 17492 } 17493 } 17494 }, 17495 17496 checkRedirectStart: function(param_name, param_value) 17497 { 17498 var current_hash = window.location.hash; 17499 if (current_hash.substring(0, 1) == '#') current_hash = current_hash.substring(1); 17500 17501 var test = current_hash.substring(0, 5); 17502 if (test == 'view/' || test == 'view%') 17503 { 17504 BX.ajax.history.bHashCollision = true;
17505 document.write('<' + 'div id="__ajax_hash_collision_' + param_value + '" style="display: none;">'); 17506 } 17507 }, 17508 17509 checkRedirectFinish: function(param_name, param_value) 17510 { 17511 document.write('</div>'); 17512 17513 var current_hash = window.location.hash; 17514 if (current_hash.substring(0, 1) == '#') current_hash = current_hash.substring(1); 17515 17516 BX.ready(function () 17517 { 17518 var test = current_hash.substring(0, 5); 17519 if (test == 'view/' || test == 'view%') 17520 { 17521 var obColNode = BX('__ajax_hash_collision_' + param_value); 17522 var obNode = obColNode.firstChild; 17523 BX.cleanNode(obNode); 17524 obColNode.style.display = 'block'; 17525 17526 // IE, Opera and Chrome automatically modifies hash with urlencode, but FF doesn't ;-( 17527 if (test != 'view%') 17528 current_hash = BX.util.urlencode(current_hash); 17529 17530 current_hash += (current_hash.indexOf('%3F') == -1 ? '%3F' : '%26') + param_name + '=' + param_value; 17531 17532 var url = '/bitrix/tools/ajax_redirector.php?hash=' + current_hash; 17533 17534 BX.ajax.insertToNode(url, obNode); 17535 } 17536 }); 17537 } 17538}; 17539 17540BX.ajax.component = function(node) 17541{ 17542 this.node = node; 17543}; 17544 17545BX.ajax.component.prototype.getState = function() 17546{ 17547 var state = { 17548 'node': this.node, 17549 'title': window.document.title, 17550 'data': BX(this.node).innerHTML 17551 }; 17552 17553 var obNavChain = BX('navigation'); 17554 if (null != obNavChain) 17555 state.nav_chain = obNavChain.innerHTML; 17556 17557 BX.onCustomEvent(BX(state.node), "onComponentAjaxHistoryGetState", [state]); 17558 17559 return state; 17560}; 17561 17562BX.ajax.component.prototype.setState = function(state) 17563{ 17564 BX(state.node).innerHTML = state.data; 17565 BX.ajax.UpdatePageTitle(state.title); 17566 17567 if (state.nav_chain) 17568 { 17569 BX.ajax.UpdatePageNavChain(state.nav_chain); 17570 } 17571 17572 BX.onCustomEvent(BX(state.node), "onComponentAjaxHistorySetState", [state]); 17573}; 17574 17575var jsAjaxHistoryContainer = { 17576 arHistory: {}, 17577 17578 put: function(hash, state) 17579 { 17580 this.arHistory[hash] = state; 17581 }, 17582 17583 get: function(hash) 17584 { 17585 return this.arHistory[hash]; 17586 } 17587}; 17588 17589 17590BX.ajax.FormData = function() 17591{ 17592 this.elements = []; 17593 this.files = []; 17594 this.features = {}; 17595 this.isSupported(); 17596 this.log('BX FormData init'); 17597}; 17598 17599BX.ajax.FormData.isSupported = function() 17600{ 17601 var f = new BX.ajax.FormData(); 17602 var result = f.features.supported; 17603 f = null; 17604 return result; 17605}; 17606 17607BX.ajax.FormData.prototype.log = function(o) 17608{ 17609 if (false) { 17610 try { 17611 if (BX.browser.IsIE()) o = JSON.stringify(o); 17612 console.log(o); 17613 } catch(e) {} 17614 } 17615}; 17616 17617BX.ajax.FormData.prototype.isSupported = function() 17618{ 17619 var f = {}; 17620 f.fileReader = (window.FileReader && window.FileReader.prototype.readAsBinaryString); 17621 f.readFormData = f.sendFormData = !!(window.FormData); 17622 f.supported = !!(f.readFormData && f.sendFormData); 17623 this.features = f; 17624 this.log('features:'); 17625 this.log(f); 17626 17627 return f.supported; 17628}; 17629 17630BX.ajax.FormData.prototype.append = function(name, value) 17631{ 17632 if (typeof(value) === 'object') { // seems to be files element 17633 this.files.push({'name': name, 'value':value}); 17634 } else { 17635 this.elements.push({'name': name, 'value':value}); 17636 } 17637}; 17638 17639BX.ajax.FormData.prototype.send = function(url, callbackOk, callbackProgress, callbackError) 17640{ 17641 this.log('FD send'); 17642 this.xhr = BX.ajax({ 17643 'method': 'POST', 17644 'dataType': 'html', 17645 'url': url, 17646 'onsuccess': callbackOk, 17647 'onfailure': callbackError, 17648 'start': false, 17649 'preparePost':false 17650 }); 17651 17652 if (callbackProgress) 17653 { 17654 this.xhr.upload.addEventListener( 17655 'progress', 17656 function(e) { 17657 if (e.lengthComputable) 17658 callbackProgress(e.loaded / (e.total || e.totalSize)); 17659 }, 17660 false 17661 ); 17662 } 17663 17664 if (this.features.readFormData && this.features.sendFormData) 17665 { 17666 var fd = new FormData(); 17667 this.log('use browser formdata'); 17668 for (var i in this.elements) 17669 { 17670 if(this.elements.hasOwnProperty(i)) 17671 fd.append(this.elements[i].name,this.elements[i].value); 17672 } 17673 for (i in this.files) 17674 { 17675 if(this.files.hasOwnProperty(i)) 17676 fd.append(this.files[i].name, this.files[i].value); 17677 } 17678 this.xhr.send(fd); 17679 } 17680 17681 return this.xhr; 17682}; 17683 17684BX.addCustomEvent('onAjaxFailure', BX.debug); 17685})(window); 17686 17687 17688(function (exports,main_core) { 17689 'use strict'; 17690 17691 var LazyLoad = { 17692 observer: null, 17693 images: {}, 17694 imageStatus: { 17695 hidden: -2, 17696 error: -1, 17697 "undefined": 0, 17698 inited: 1, 17699 loaded: 2 17700 }, 17701 imageTypes: { 17702 image: 1, 17703 background: 2 17704 },
17705 initObserver: function initObserver() { 17706 this.observer = new IntersectionObserver(this.onIntersection.bind(this), { 17707 rootMargin: '20% 0% 20% 0%', 17708 threshold: 0.10 17709 }); 17710 }, 17711 onIntersection: function onIntersection(entries) { 17712 entries.forEach(function (entry) { 17713 if (entry.isIntersecting) { 17714 this.showImage(entry.target); 17715 } 17716 }.bind(this)); 17717 }, 17718 registerImage: function registerImage(id, isImageVisibleCallback, options) { 17719 if (this.observer === null) { 17720 this.initObserver(); 17721 } 17722 17723 options = options || {}; 17724 17725 if (!main_core.Type.isStringFilled(id)) { 17726 return; 17727 } 17728 17729 if (main_core.Type.isObject(this.images[id])) { 17730 return; 17731 } 17732 17733 var element = document.getElementById(id); 17734 17735 if (!main_core.Type.isDomNode(element)) { 17736 return; 17737 } 17738 17739 this.observer.observe(element); 17740 this.images[id] = { 17741 id: id, 17742 node: null, 17743 src: null, 17744 dataSrcName: options.dataSrcName || 'src', 17745 type: null, 17746 func: main_core.Type.isFunction(isImageVisibleCallback) ? isImageVisibleCallback : null, 17747 status: this.imageStatus.undefined 17748 }; 17749 }, 17750 registerImages: function registerImages(ids, isImageVisibleCallback, options) { 17751 if (main_core.Type.isArray(ids)) { 17752 for (var i = 0, length = ids.length; i < length; i++) { 17753 this.registerImage(ids[i], isImageVisibleCallback, options); 17754 } 17755 } 17756 }, 17757 showImage: function showImage(imageNode) { 17758 var imageNodeId = imageNode.id; 17759 17760 if (!main_core.Type.isStringFilled(imageNodeId)) { 17761 return; 17762 } 17763 17764 var image = this.images[imageNodeId]; 17765 17766 if (!main_core.Type.isPlainObject(image)) { 17767 return; 17768 } 17769 17770 if (image.status == this.imageStatus.undefined) { 17771 this.initImage(image); 17772 } 17773 17774 if (image.status !== this.imageStatus.inited) { 17775 return; 17776 } 17777 17778 if (!image.node || !image.node.parentNode) { 17779 image.node = null; 17780 image.status = this.imageStatus.error; 17781 return; 17782 } 17783 17784 if (image.type == this.imageTypes.image) { 17785 image.node.src = image.src; 17786 } else { 17787 image.node.style.backgroundImage = "url('" + image.src + "')"; 17788 } 17789 17790 image.node.dataset[image.dataSrcName] = ""; 17791 image.status = this.imageStatus.loaded; 17792 }, 17793 showImages: function showImages(checkOwnVisibility) { 17794 checkOwnVisibility = checkOwnVisibility !== false; 17795 17796 for (var id in this.images) { 17797 if (!this.images.hasOwnProperty(id)) { 17798 continue; 17799 } 17800 17801 var image = this.images[id]; 17802 17803 if (image.status == this.imageStatus.undefined) { 17804 this.initImage(image); 17805 } 17806 17807 if (image.status !== this.imageStatus.inited) { 17808 continue; 17809 } 17810 17811 if (!image.node || !image.node.parentNode) { 17812 image.node = null; 17813 image.status = this.imageStatus.error; 17814 continue; 17815 } 17816 17817 var isImageVisible = true; 17818 17819 if (checkOwnVisibility && main_core.Type.isFunction(image.func)) { 17820 isImageVisible = image.func(image); 17821 } 17822 17823 if (isImageVisible === true && this.isElementVisibleOnScreen(image.node)) { 17824 if (image.type == this.imageTypes.image) { 17825 image.node.src = image.src; 17826 } else { 17827 image.node.style.backgroundImage = "url('" + image.src + "')"; 17828 } 17829 17830 image.node.dataset[image.dataSrcName] = ""; 17831 image.status = this.imageStatus.loaded; 17832 } 17833 } 17834 }, 17835 initImage: function initImage(image) { 17836 image.status = this.imageStatus.error; 17837 var node = document.getElementById(image.id); 17838 17839 if (!main_core.Type.isDomNode(node)) { 17840 return; 17841 } 17842 17843 var src = node.dataset[image.dataSrcName]; 17844 17845 if (main_core.Type.isStringFilled(src)) { 17846 image.node = node; 17847 image.src = src; 17848 image.status = this.imageStatus.inited; 17849 image.type = image.node.tagName.toLowerCase() == "img" ? this.imageTypes.image : this.imageTypes.background; 17850 } 17851 }, 17852 isElementVisibleOnScreen: function isElementVisibleOnScreen(element) { 17853 var coords = this.getElementCoords(element); 17854 var windowTop = window.pageYOffset || document.documentElement.scrollTop; 17855 var windowBottom = windowTop + document.documentElement.clientHeight; 17856 coords.bottom = coords.top + element.offsetHeight; 17857 return coords.top > windowTop && coords.top < windowBottom || // topVisible 17858 coords.bottom < windowBottom && coords.bottom > windowTop // bottomVisible 17859 ; 17860 }, 17861 isElementVisibleOn2Screens: function isElementVisibleOn2Screens(element) { 17862 var windowHeight = document.documentElement.clientHeight; 17863 var windowTop = window.pageYOffset || document.documentElement.scrollTop; 17864 var windowBottom = windowTop + windowHeight; 17865 var coords = this.getElementCoords(element); 17866 coords.bottom = coords.top + element.offsetHeight; 17867 windowTop -= windowHeight; 17868 windowBottom += windowHeight; 17869 return coords.top > windowTop && coords.top < windowBottom || // topVisible 17870 coords.bottom < windowBottom && coords.bottom > windowTop // bottomVisible 17871 ; 17872 }, 17873 getElementCoords: function getElementCoords(element) { 17874 var box = element.getBoundingClientRect(); 17875 return { 17876 originTop: box.top, 17877 originLeft: box.left, 17878 top: box.top + window.pageYOffset, 17879 left: box.left + window.pageXOffset 17880 }; 17881 }, 17882 onScroll: function onScroll() {}, 17883 clearImages: function clearImages() { 17884 this.images = []; 17885 } 17886 }; 17887 17888 exports.LazyLoad = LazyLoad; 17889 17890}((this.BX = this.BX || {}),BX)); 17891 17892 17893 17894(function (exports) { 17895 'use strict'; 17896 17897 var ParamBag = /*#__PURE__*/function () { 17898 function ParamBag() { 17899 var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 17900 babelHelpers.classCallCheck(this, ParamBag); 17901 17902 if (!!params && babelHelpers.typeof(params) === 'object') { 17903 this.params = new Map(Object.entries(params)); 17904 } else { 17905 this.params = new Map(); 17906 } 17907 } 17908 17909 babelHelpers.createClass(ParamBag, [{ 17910 key: "getParam", 17911 value: function getParam(key) { 17912 var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; 17913 17914 if (this.params.has(key)) { 17915 return this.params.get(key); 17916 } 17917 17918 return defaultValue; 17919 } 17920 }, { 17921 key: "setParam", 17922 value: function setParam(key, value) { 17923 this.params.set(key, value); 17924 } 17925 }, { 17926 key: "clear", 17927 value: function clear() { 17928 this.params.clear(); 17929 } 17930 }], [{ 17931 key: "create", 17932 value: function create() { 17933 var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 17934 return new ParamBag(params); 17935 } 17936 }]); 17937 return ParamBag; 17938 }(); 17939 17940 exports.ParamBag = ParamBag; 17941 17942}((this.BX = this.BX || {}))); 17943 17944 17945 17946(function() { 17947 BX.FixFontSize = function(params) 17948 { 17949 var widthNode, computedStyles, width; 17950 17951 this.node = null; 17952 this.prevWindowSize = 0; 17953 this.prevWrapperSize = 0; 17954 this.mainWrapper = null; 17955 this.textWrapper = null; 17956 this.objList = params.objList; 17957 this.minFontSizeList = []; 17958 this.minFontSize = 0; 17959 17960 if (params.onresize) 17961 { 17962 this.prevWindowSize = window.innerWidth || document.documentElement.clientWidth; 17963 BX.bind(window, 'resize', BX.throttle(this.onResize, 350, this)); 17964 } 17965 17966 if (params.onAdaptiveResize) 17967 { 17968 widthNode = this.objList[0].scaleBy || this.objList[0].node; 17969 computedStyles = getComputedStyle(widthNode); 17970 this.prevWrapperSize = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 17971 BX.bind(window, 'resize', BX.throttle(this.onAdaptiveResize, 350, this)); 17972 } 17973 17974 this.createTestNodes(); 17975 this.decrease(); 17976 }; 17977 17978 BX.FixFontSize.prototype = 17979 { 17980 createTestNodes: function() 17981 { 17982 this.textWrapper = BX.create('div',{ 17983 style : { 17984 display : 'inline-block', 17985 whiteSpace : 'nowrap' 17986 } 17987 }); 17988 17989 this.mainWrapper = BX.create('div',{ 17990 style : { 17991 height : 0, 17992 overflow : 'hidden' 17993 }, 17994 children : [this.textWrapper] 17995 }); 17996 17997 }, 17998 insertTestNodes: function() 17999 { 18000 document.body.appendChild(this.mainWrapper); 18001 }, 18002 removeTestNodes: function() 18003 { 18004 document.body.removeChild(this.mainWrapper); 18005 }, 18006 decrease: function() 18007 { 18008 var width, 18009 fontSize, 18010 widthNode, 18011 computedStyles; 18012 18013 this.insertTestNodes(); 18014
18015 for(var i=this.objList.length-1; i>=0; i--) 18016 { 18017 widthNode = this.objList[i].scaleBy || this.objList[i].node; 18018 computedStyles = getComputedStyle(widthNode); 18019 width = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 18020 fontSize = parseInt(getComputedStyle(this.objList[i].node)["font-size"]); 18021 18022 this.textWrapperSetStyle(this.objList[i].node); 18023 18024 if(this.textWrapperInsertText(this.objList[i].node)) 18025 { 18026 while(this.textWrapper.offsetWidth > width && fontSize > 0) 18027 { 18028 this.textWrapper.style.fontSize = --fontSize + 'px'; 18029 } 18030 18031 if(this.objList[i].smallestValue) 18032 { 18033 this.minFontSize = this.minFontSize ? Math.min(this.minFontSize, fontSize) : fontSize; 18034 18035 this.minFontSizeList.push(this.objList[i].node) 18036 } 18037 else 18038 { 18039 this.objList[i].node.style.fontSize = fontSize + 'px'; 18040 } 18041 } 18042 } 18043 18044 if(this.minFontSizeList.length > 0) 18045 this.setMinFont(); 18046 18047 this.removeTestNodes(); 18048 18049 }, 18050 increase: function() 18051 { 18052 this.insertTestNodes(); 18053 var width, 18054 fontSize, 18055 widthNode, 18056 computedStyles; 18057 18058 this.insertTestNodes(); 18059 18060 for(var i=this.objList.length-1; i>=0; i--) 18061 { 18062 widthNode = this.objList[i].scaleBy || this.objList[i].node; 18063 computedStyles = getComputedStyle(widthNode); 18064 width = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 18065 fontSize = parseInt(getComputedStyle(this.objList[i].node)["font-size"]); 18066 18067 this.textWrapperSetStyle(this.objList[i].node); 18068 18069 if(this.textWrapperInsertText(this.objList[i].node)) 18070 { 18071 while(this.textWrapper.offsetWidth < width && fontSize < this.objList[i].maxFontSize) 18072 { 18073 this.textWrapper.style.fontSize = ++fontSize + 'px'; 18074 } 18075 18076 fontSize--; 18077 18078 if(this.objList[i].smallestValue) 18079 { 18080 this.minFontSize = this.minFontSize ? Math.min(this.minFontSize, fontSize) : fontSize; 18081 18082 this.minFontSizeList.push(this.objList[i].node) 18083 } 18084 else 18085 { 18086 this.objList[i].node.style.fontSize = fontSize + 'px'; 18087 } 18088 } 18089 } 18090 18091 if(this.minFontSizeList.length > 0) 18092 this.setMinFont(); 18093 18094 this.removeTestNodes(); 18095 }, 18096 setMinFont : function() 18097 { 18098 for(var i = this.minFontSizeList.length-1; i>=0; i--) 18099 { 18100 this.minFontSizeList[i].style.fontSize = this.minFontSize + 'px'; 18101 } 18102 18103 this.minFontSize = 0; 18104 }, 18105 onResize : function() 18106 { 18107 var width = window.innerWidth || document.documentElement.clientWidth; 18108 18109 if(this.prevWindowSize > width) 18110 this.decrease(); 18111 18112 else if (this.prevWindowSize < width) 18113 this.increase(); 18114 18115 this.prevWindowSize = width; 18116 }, 18117 onAdaptiveResize : function() 18118 { 18119 var widthNode = this.objList[0].scaleBy || this.objList[0].node, 18120 computedStyles = getComputedStyle(widthNode), 18121 width = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 18122 18123 if (this.prevWrapperSize > width) 18124 this.decrease(); 18125 else if (this.prevWrapperSize < width) 18126 this.increase(); 18127 18128 this.prevWrapperSize = width; 18129 }, 18130 textWrapperInsertText : function(node) 18131 { 18132 if(node.textContent){ 18133 this.textWrapper.textContent = node.textContent; 18134 return true; 18135 } 18136 else if(node.innerText) 18137 { 18138 this.textWrapper.innerText = node.innerText; 18139 return true; 18140 } 18141 else { 18142 return false; 18143 } 18144 }, 18145 textWrapperSetStyle : function(node) 18146 { 18147 this.textWrapper.style.fontFamily = getComputedStyle(node)["font-family"]; 18148 this.textWrapper.style.fontSize = getComputedStyle(node)["font-size"]; 18149 this.textWrapper.style.fontStyle = getComputedStyle(node)["font-style"]; 18150 this.textWrapper.style.fontWeight = getComputedStyle(node)["font-weight"]; 18151 this.textWrapper.style.lineHeight = getComputedStyle(node)["line-height"]; 18152 } 18153 }; 18154 18155 BX.FixFontSize.init = function(params) 18156 { 18157 return new BX.FixFontSize(params); 18158 }; 18159})(); 18160 18161})(); 18162//# 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.