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 EventTarget like object 5877 * @param value 5878 * @return {boolean} 5879 */ 5880 }, { 5881 key: "isEventTargetLike", 5882 value: function isEventTargetLike(value) { 5883 return Type.isObject(value) 5884 // eslint-disable-next-line @bitrix24/bitrix24-rules/no-native-events-binding 5885 && Type.isFunction(value.addEventListener) 5886 // eslint-disable-next-line @bitrix24/bitrix24-rules/no-native-events-binding 5887 && Type.isFunction(value.removeEventListener) && Type.isFunction(value.dispatchEvent); 5888 } 5889 /** 5890 * Checks that value is text node 5891 * @param value 5892 * @return {boolean} 5893 */ 5894 }, { 5895 key: "isTextNode", 5896 value: function isTextNode(value) { 5897 return Type.isDomNode(value) && value.nodeType === Node.TEXT_NODE; 5898 } 5899 /** 5900 * Checks that value is Map 5901 * @param value 5902 * @return {boolean} 5903 */ 5904 }, { 5905 key: "isMap", 5906 value: function isMap(value) { 5907 return Type.isObjectLike(value) && getTag(value) === '[object Map]'; 5908 } 5909 /** 5910 * Checks that value is Set 5911 * @param value 5912 * @return {boolean} 5913 */ 5914 }, { 5915 key: "isSet", 5916 value: function isSet(value) { 5917 return Type.isObjectLike(value) && getTag(value) === '[object Set]'; 5918 } 5919 /** 5920 * Checks that value is WeakMap 5921 * @param value 5922 * @return {boolean} 5923 */ 5924 }, { 5925 key: "isWeakMap", 5926 value: function isWeakMap(value) { 5927 return Type.isObjectLike(value) && getTag(value) === '[object WeakMap]'; 5928 } 5929 /** 5930 * Checks that value is WeakSet 5931 * @param value 5932 * @return {boolean} 5933 */ 5934 }, { 5935 key: "isWeakSet", 5936 value: function isWeakSet(value) { 5937 return Type.isObjectLike(value) && getTag(value) === '[object WeakSet]'; 5938 } 5939 /** 5940 * Checks that value is prototype 5941 * @param value 5942 * @return {boolean} 5943 */ 5944 }, { 5945 key: "isPrototype", 5946 value: function isPrototype(value) { 5947 return (typeof (value && value.constructor) === 'function' && value.constructor.prototype || Object.prototype) === value; 5948 } 5949 /** 5950 * Checks that value is regexp 5951 * @param value 5952 * @return {boolean} 5953 */ 5954 }, { 5955 key: "isRegExp", 5956 value: function isRegExp(value) { 5957 return Type.isObjectLike(value) && getTag(value) === '[object RegExp]'; 5958 } 5959 /** 5960 * Checks that value is null 5961 * @param value 5962 * @return {boolean} 5963 */ 5964 }, { 5965 key: "isNull", 5966 value: function isNull(value) { 5967 return value === null; 5968 } 5969 /** 5970 * Checks that value is undefined 5971 * @param value 5972 * @return {boolean} 5973 */ 5974 }, { 5975 key: "isUndefined", 5976 value: function isUndefined(value) { 5977 return typeof value === 'undefined'; 5978 } 5979 /** 5980 * Checks that value is ArrayBuffer 5981 * @param value 5982 * @return {boolean} 5983 */ 5984 }, { 5985 key: "isArrayBuffer", 5986 value: function isArrayBuffer(value) { 5987 return Type.isObjectLike(value) && getTag(value) === '[object ArrayBuffer]'; 5988 } 5989 /** 5990 * Checks that value is typed array 5991 * @param value 5992 * @return {boolean} 5993 */ 5994 }, { 5995 key: "isTypedArray", 5996 value: function isTypedArray(value) { 5997 const regExpTypedTag = /^\[object (?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)]$/; 5998 return Type.isObjectLike(value) && regExpTypedTag.test(getTag(value)); 5999 } 6000 /** 6001 * Checks that value is Blob 6002 * @param value 6003 * @return {boolean} 6004 */ 6005 }, { 6006 key: "isBlob", 6007 value: function isBlob(value) { 6008 return Type.isObjectLike(value) && Type.isNumber(value.size) && Type.isString(value.type) && Type.isFunction(value.slice); 6009 } 6010 /** 6011 * Checks that value is File 6012 * @param value 6013 * @return {boolean} 6014 */ 6015 }, { 6016 key: "isFile", 6017 value: function isFile(value) { 6018 return Type.isBlob(value) && Type.isString(value.name) && (Type.isNumber(value.lastModified) || Type.isObjectLike(value.lastModifiedDate)); 6019 } 6020 /** 6021 * Checks that value is FormData 6022 * @param value 6023 * @return {boolean} 6024 */ 6025 }, { 6026 key: "isFormData", 6027 value: function isFormData(value) { 6028 return value instanceof FormData; 6029 } 6030 }, { 6031 key: "isJsonValue", 6032 value: function isJsonValue(value) { 6033 return Type.isPlainObject(value) || Type.isString(value) || Type.isNumber(value) || Type.isBoolean(value) || Type.isNull(value) || Type.isArray(value); 6034 } 6035 }]); 6036 return Type; 6037 }(); 6038 6039 /** 6040 * @memberOf BX 6041 */ 6042 let Reflection = /*#__PURE__*/function () { 6043 function Reflection() { 6044 babelHelpers.classCallCheck(this, Reflection); 6045 } 6046 babelHelpers.createClass(Reflection, null, [{ 6047 key: "getClass", 6048 /** 6049 * Gets link to function by function name 6050 * @param className 6051 * @return {?Function} 6052 */ 6053 value: function getClass(className) { 6054 if (Type.isString(className) && !!className) { 6055 let classFn = null; 6056 let currentNamespace = window; 6057 const namespaces = className.split('.'); 6058 for (let i = 0; i < namespaces.length; i += 1) { 6059 const namespace = namespaces[i]; 6060 if (!currentNamespace[namespace]) { 6061 return null; 6062 } 6063 currentNamespace = currentNamespace[namespace]; 6064 classFn = currentNamespace; 6065 } 6066 return classFn; 6067 } 6068 if (Type.isFunction(className)) { 6069 return className; 6070 } 6071 return null; 6072 } 6073 /** 6074 * Creates a namespace or returns a link to a previously created one 6075 * @param {String} namespaceName 6076 * @return {Object<string, any> | Function | null} 6077 */ 6078 }, { 6079 key: "namespace", 6080 value: function namespace(namespaceName) { 6081 let parts = namespaceName.split('.'); 6082 let parent = window.BX; 6083 if (parts[0] === 'BX') { 6084 parts = parts.slice(1); 6085 } 6086 for (let i = 0; i < parts.length; i += 1) { 6087 if (Type.isUndefined(parent[parts[i]])) { 6088 parent[parts[i]] = {}; 6089 } 6090 parent = parent[parts[i]]; 6091 } 6092 return parent; 6093 } 6094 }]); 6095 return Reflection; 6096 }(); 6097 6098 const reEscape = /[&<>'"]/g; 6099 const reUnescape = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g; 6100 const escapeEntities = { 6101 '&': '&', 6102 '<': '<', 6103 '>': '>', 6104 "'": ''', 6105 '"': '"' 6106 }; 6107 const unescapeEntities = { 6108 '&': '&', 6109 '&': '&', 6110 '<': '<', 6111 '<': '<', 6112 '>': '>', 6113 '>': '>', 6114 ''': "'", 6115 ''': "'", 6116 '"': '"', 6117 '"': '"' 6118 }; 6119 6120 /** 6121 * @memberOf BX 6122 */ 6123 let Text = /*#__PURE__*/function () { 6124 function Text() { 6125 babelHelpers.classCallCheck(this, Text); 6126 } 6127 babelHelpers.createClass(Text, null, [{ 6128 key: "encode", 6129 /** 6130 * Encodes all unsafe entities 6131 * @param {string} value 6132 * @return {string} 6133 */ 6134 value: function encode(value) { 6135 if (Type.isString(value)) { 6136 return value.replace(reEscape, item => escapeEntities[item]); 6137 } 6138 return value; 6139 } 6140 /** 6141 * Decodes all encoded entities 6142 * @param {string} value 6143 * @return {string} 6144 */ 6145 }, { 6146 key: "decode", 6147 value: function decode(value) { 6148 if (Type.isString(value)) { 6149 return value.replace(reUnescape, item => unescapeEntities[item]); 6150 } 6151 return value; 6152 } 6153 }, { 6154 key: "getRandom", 6155 value: function getRandom(length = 8) { 6156 // eslint-disable-next-line 6157 return [...Array(length)].map(() => (~~(Math.random() * 36)).toString(36)).join(''); 6158 } 6159 }, { 6160 key: "toNumber", 6161 value: function toNumber(value) { 6162 const parsedValue = Number.parseFloat(value); 6163 if (Type.isNumber(parsedValue)) { 6164 return parsedValue; 6165 } 6166 return 0; 6167 } 6168 }, { 6169 key: "toInteger", 6170 value: function toInteger(value) { 6171 return Text.toNumber(Number.parseInt(value, 10)); 6172 } 6173 }, { 6174 key: "toBoolean", 6175 value: function toBoolean(value, trueValues = []) { 6176 const transformedValue = Type.isString(value) ? value.toLowerCase() : value; 6177 return ['true', 'y', '1', 1, true, ...trueValues].includes(transformedValue); 6178 } 6179 }, { 6180 key: "toCamelCase", 6181 value: function toCamelCase(str) { 6182 if (!Type.isStringFilled(str)) { 6183 return str; 6184 } 6185 const regex = /[-_\s]+(.)?/g; 6186 if (!regex.test(str)) { 6187 return str.match(/^[A-Z]+$/) ? str.toLowerCase() : str[0].toLowerCase() + str.slice(1); 6188 } 6189 str = str.toLowerCase(); 6190 str = str.replace(regex, function (match, letter) { 6191 return letter ? letter.toUpperCase() : ''; 6192 }); 6193 return str[0].toLowerCase() + str.substr(1); 6194 } 6195 }, { 6196 key: "toPascalCase", 6197 value: function toPascalCase(str) { 6198 if (!Type.isStringFilled(str)) { 6199 return str; 6200 } 6201 return this.capitalize(this.toCamelCase(str)); 6202 } 6203 }, { 6204 key: "toKebabCase", 6205 value: function toKebabCase(str) { 6206 if (!Type.isStringFilled(str)) { 6207 return str; 6208 } 6209 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); 6210 if (!matches) { 6211 return str; 6212 } 6213 return matches.map(x => x.toLowerCase()).join('-'); 6214 } 6215 }, { 6216 key: "capitalize", 6217 value: function capitalize(str) { 6218 if (!Type.isStringFilled(str)) { 6219 return str; 6220 } 6221 return str[0].toUpperCase() + str.substr(1); 6222 } 6223 }]); 6224 return Text; 6225 }(); 6226 6227 const aliases = { 6228 mousewheel: ['DOMMouseScroll'], 6229 bxchange: ['change', 'cut', 'paste', 'drop', 'keyup'], 6230 animationend: ['animationend', 'oAnimationEnd', 'webkitAnimationEnd', 'MSAnimationEnd'], 6231 transitionend: ['webkitTransitionEnd', 'otransitionend', 'oTransitionEnd', 'msTransitionEnd', 'transitionend'], 6232 fullscreenchange: ['fullscreenchange', 'webkitfullscreenchange', 'mozfullscreenchange', 'MSFullscreenChange'], 6233 fullscreenerror: ['fullscreenerror', 'webkitfullscreenerror', 'mozfullscreenerror', 'MSFullscreenError'] 6234 }; 6235 6236 let Registry = /*#__PURE__*/function () { 6237 function Registry() { 6238 babelHelpers.classCallCheck(this, Registry); 6239 babelHelpers.defineProperty(this, "registry", new WeakMap()); 6240 } 6241 babelHelpers.createClass(Registry, [{ 6242 key: "set", 6243 value: function set(target, event, listener) { 6244 if (!Type.isEventTargetLike(target)) { 6245 return; 6246 } 6247 const events = this.get(target); 6248 if (!Type.isSet(events[event])) { 6249 events[event] = new Set(); 6250 } 6251 events[event].add(listener); 6252 this.registry.set(target, events); 6253 } 6254 }, { 6255 key: "get", 6256 value: function get(target) { 6257 return this.registry.get(target) || {}; 6258 } 6259 }, { 6260 key: "has", 6261 value: function has(target, event, listener) { 6262 if (event && listener) { 6263 return this.registry.has(target) && this.registry.get(target)[event].has(listener); 6264 } 6265 return this.registry.has(target); 6266 } 6267 }, { 6268 key: "delete", 6269 value: function _delete(target, event, listener) { 6270 if (!Type.isEventTargetLike(target)) { 6271 retu
6271rn; 6272 } 6273 if (Type.isString(event) && Type.isFunction(listener)) { 6274 const events = this.registry.get(target); 6275 if (Type.isPlainObject(events) && Type.isSet(events[event])) { 6276 events[event].delete(listener); 6277 } 6278 return; 6279 } 6280 if (Type.isString(event)) { 6281 const events = this.registry.get(target); 6282 if (Type.isPlainObject(events) && Type.isSet(events[event])) { 6283 events[event] = new Set(); 6284 } 6285 return; 6286 } 6287 this.registry.delete(target); 6288 } 6289 }]); 6290 return Registry; 6291 }(); 6292 var registry = new Registry(); 6293 6294 function isOptionSupported(name) { 6295 let isSupported = false; 6296 try { 6297 const options = Object.defineProperty({}, name, { 6298 get() { 6299 isSupported = true; 6300 return undefined; 6301 } 6302 }); 6303 window.addEventListener('test', null, options); 6304 } 6305 // eslint-disable-next-line 6306 catch (err) {} 6307 return isSupported; 6308 } 6309 function fetchSupportedListenerOptions(options) { 6310 if (!Type.isPlainObject(options)) { 6311 return options; 6312 } 6313 return Object.keys(options).reduce((acc, name) => { 6314 if (isOptionSupported(name)) { 6315 acc[name] = options[name]; 6316 } 6317 return acc; 6318 }, {}); 6319 } 6320 6321 function bind(target, eventName, handler, options) { 6322 if (!Type.isEventTargetLike(target)) { 6323 return; 6324 } 6325 const listenerOptions = fetchSupportedListenerOptions(options); 6326 if (eventName in aliases) { 6327 aliases[eventName].forEach(key => { 6328 // eslint-disable-next-line @bitrix24/bitrix24-rules/no-native-events-binding 6329 target.addEventListener(key, handler, listenerOptions); 6330 registry.set(target, eventName, handler); 6331 }); 6332 return; 6333 } 6334 6335 // eslint-disable-next-line @bitrix24/bitrix24-rules/no-native-events-binding 6336 target.addEventListener(eventName, handler, listenerOptions); 6337 registry.set(target, eventName, handler); 6338 } 6339 6340 function unbind(target, eventName, handler, options) { 6341 if (!Type.isEventTargetLike(target)) { 6342 return; 6343 } 6344 const listenerOptions = fetchSupportedListenerOptions(options); 6345 if (eventName in aliases) { 6346 aliases[eventName].forEach(key => { 6347 // eslint-disable-next-line @bitrix24/bitrix24-rules/no-native-events-binding 6348 target.removeEventListener(key, handler, listenerOptions); 6349 registry.delete(target, key, handler); 6350 }); 6351 return; 6352 } 6353 6354 // eslint-disable-next-line @bitrix24/bitrix24-rules/no-native-events-binding 6355 target.removeEventListener(eventName, handler, listenerOptions); 6356 registry.delete(target, eventName, handler); 6357 } 6358 6359 function unbindAll(target, eventName) { 6360 const events = registry.get(target); 6361 Object.keys(events).forEach(currentEvent => { 6362 events[currentEvent].forEach(handler => { 6363 if (!Type.isString(eventName) || eventName === currentEvent) { 6364 unbind(target, currentEvent, handler); 6365 } 6366 }); 6367 }); 6368 } 6369 6370 function bindOnce(target, eventName, handler, options) { 6371 const once = function once(...args) { 6372 unbind(target, eventName, once, options); 6373 handler(...args); 6374 }; 6375 bind(target, eventName, once, options); 6376 } 6377 6378 // eslint-disable-next-line 6379 let debugState = true; 6380 function enableDebug() { 6381 debugState = true; 6382 } 6383 function disableDebug() { 6384 debugState = false; 6385 } 6386 function isDebugEnabled() { 6387 return debugState; 6388 } 6389 function debug(...args) { 6390 if (isDebugEnabled() && Type.isObject(window.console)) { 6391 if (Type.isFunction(window.console.log)) { 6392 window.console.log('BX.debug: ', args.length > 0 ? args : args[0]); 6393 if (args[0] instanceof Error && args[0].stack) { 6394 window.console.log('BX.debug error stack trace', args[0].stack); 6395 } 6396 } 6397 if (Type.isFunction(window.console.trace)) { 6398 // eslint-disable-next-line 6399 console.trace(); 6400 } 6401 } 6402 } 6403 6404 var debugNs = /*#__PURE__*/Object.freeze({ 6405 get debugState () { return debugState; }, 6406 enableDebug: enableDebug, 6407 disableDebug: disableDebug, 6408 isDebugEnabled: isDebugEnabled, 6409 default: debug 6410 }); 6411 6412 const extensionsStorage = new Map(); 6413 6414 const ajaxController = 'main.bitrix.main.controller.loadext.getextensions'; 6415 function loadAssets(options) { 6416 return new Promise((resolve, reject) => { 6417 const getParameters = { 6418 e: ((options === null || options === void 0 ? void 0 : options.extension) || []).join(',') 6419 }; 6420 BX.ajax.runAction(ajaxController, { 6421 data: options, 6422 getParameters 6423 }).then(result => { 6424 resolve(result === null || result === void 0 ? void 0 : result.data); 6425 }).catch(err => { 6426 reject(err); 6427 }); 6428 }); 6429 } 6430 6431 function fetchInlineScripts(acc, item) { 6432 if (item.isInternal) { 6433 acc.push(item.JS); 6434 } 6435 return acc; 6436 } 6437 function fetchExternalScripts(acc, item) { 6438 if (!item.isInternal) { 6439 acc.push(item.JS); 6440 } 6441 return acc; 6442 } 6443 function fetchExternalStyles(acc, item) { 6444 if (Type.isString(item) && item !== '') { 6445 acc.push(item); 6446 } 6447 return acc; 6448 } 6449 function fetchExtensionSettings(html) { 6450 if (Type.isStringFilled(html)) { 6451 const scripts = html.match(/<script type="extension\/settings" \b[^>]*>([\s\S]*?)<\/script>/g); 6452 if (Type.isArrayFilled(scripts)) { 6453 return scripts.map(script => { 6454 const [, extension] = script.match(/data-extension="(.[a-z0-9_.-]+)"/); 6455 return { 6456 extension, 6457 script 6458 }; 6459 }); 6460 } 6461 } 6462 return []; 6463 } 6464 function loadAll(items) { 6465 const itemsList = Type.isArray(items) ? items : [items]; 6466 if (!itemsList.length) { 6467 return Promise.resolve(); 6468 } 6469 return new Promise((resolve, reject) => { 6470 // eslint-disable-next-line 6471 BX.load(itemsList, resolve, document, reject); 6472 }); 6473 } 6474 6475 function parseExtensionHtml(html) { 6476 const result = window.BX.processHTML(html); 6477 const inlinePreScripts = []; 6478 const inlineAfterScripts = []; 6479 result.SCRIPT.reduce((accumulator, element) => { 6480 return fetchInlineScripts(accumulator, element); 6481 }
6481, []).forEach(script => { 6482 if (script.startsWith('BX.Runtime.registerExtension')) { 6483 inlineAfterScripts.push(script); 6484 } else { 6485 inlinePreScripts.push(script); 6486 } 6487 }); 6488 return { 6489 inlinePreScripts, 6490 inlineAfterScripts, 6491 externalScripts: result.SCRIPT.reduce((accumulator, element) => { 6492 return fetchExternalScripts(accumulator, element); 6493 }, []), 6494 externalStyles: result.STYLE.reduce((accumulator, element) => { 6495 return fetchExternalStyles(accumulator, element); 6496 }, []), 6497 settingsScripts: fetchExtensionSettings(result.HTML) 6498 }; 6499 } 6500 6501 function waitOnline() { 6502 return new Promise(resolve => { 6503 Event.bindOnce(window, 'online', () => resolve()); 6504 }); 6505 } 6506 6507 const TIMEOUTS = [1000, 3000, 5000]; 6508 async function tryLoad(extensions, callback) { 6509 for (let i = 0; i <= TIMEOUTS.length; i++) { 6510 try { 6511 // eslint-disable-next-line no-await-in-loop 6512 return await callback(); 6513 } catch { 6514 if (navigator.onLine === false) { 6515 // eslint-disable-next-line no-console 6516 console.warn(`Wait online for load ${extensions.join(', ')}`); 6517 6518 // eslint-disable-next-line no-await-in-loop 6519 await waitOnline(); 6520 i--; 6521 continue; 6522 } 6523 if (i === TIMEOUTS.length) { 6524 throw new Error(`${extensions.join(', ')} loading failed...`); 6525 } 6526 const delay = TIMEOUTS[i]; 6527 const displayRetryCount = i + 1; 6528 6529 // eslint-disable-next-line no-console 6530 console.warn(`Retry load #${displayRetryCount}: ${extensions.join(', ')}`); 6531 6532 // eslint-disable-next-line no-await-in-loop 6533 await new Promise(resolve => { 6534 setTimeout(resolve, delay); 6535 }); 6536 } 6537 } 6538 throw new Error('Unexpected end of retry loop'); 6539 } 6540 6541 async function processExtensions(map) { 6542 var _await$tryLoad; 6543 const loadableExtensions = [...map.keys()]; 6544 const rawAssets = (_await$tryLoad = await tryLoad(loadableExtensions, () => loadAssets({ 6545 extension: loadableExtensions 6546 }))) !== null && _await$tryLoad !== void 0 ? _await$tryLoad : []; 6547 rawAssets.forEach(rawAsset => { 6548 var _rawAsset$html; 6549 const preparedHtml = (_rawAsset$html = rawAsset.html) !== null && _rawAsset$html !== void 0 ? _rawAsset$html : ''; 6550 const extensionAssets = parseExtensionHtml(preparedHtml); 6551 extensionAssets.settingsScripts.forEach(({ 6552 script 6553 }) => { 6554 document.body.insertAdjacentHTML('beforeend', script); 6555 }); 6556 extensionAssets.inlinePreScripts.forEach(script => { 6557 window.BX.evalGlobal(script); 6558 }); 6559 const loadableExtensionEntry = map.get(rawAsset.extension); 6560 void Promise.all([tryLoad(loadableExtensions, () => loadAll(extensionAssets.externalScripts)), tryLoad(loadableExtensions, () => loadAll(extensionAssets.externalStyles))]).then(() => { 6561 var _rawAsset$config$name, _rawAsset$config; 6562 extensionAssets.inlineAfterScripts.forEach(script => { 6563 window.BX.evalGlobal(script); 6564 }); 6565 const namespace = (_rawAsset$config$name = rawAsset === null || rawAsset === void 0 ? void 0 : (_rawAsset$config = rawAsset.config) === null || _rawAsset$config === void 0 ? void 0 : _rawAsset$config.namespace) !== null && _rawAsset$config$name !== void 0 ? _rawAsset$config$name : 'window'; 6566 loadableExtensionEntry.resolve(namespace); 6567 }).catch(error => { 6568 loadableExtensionEntry.reject(error); 6569 }); 6570 }); 6571 } 6572 6573 const queue = new Map(); 6574 let timerId = null; 6575 async function loadExtension(...name) { 6576 if (Type.isNumber(timerId)) { 6577 clearTimeout(timerId); 6578 } 6579 const requestedNames = name.flat(); 6580 const extensionsToLoad = requestedNames.filter(extensionName => { 6581 return !extensionsStorage.has(extensionName); 6582 }); 6583 extensionsToLoad.forEach(extensionName => { 6584 let resolve = null; 6585 let reject = null; 6586 const loadableExtensionEntry = { 6587 // eslint-disable-next-line promise/param-names 6588 promise: new Promise((sourceResolve, sourceReject) => { 6589 resolve = sourceResolve; 6590 reject = sourceReject; 6591 }), 6592 resolve, 6593 reject 6594 };
6595 extensionsStorage.set(extensionName, loadableExtensionEntry.promise); 6596 queue.set(extensionName, loadableExtensionEntry); 6597 }); 6598 timerId = setTimeout(() => { 6599 if (queue.size > 0) { 6600 void processExtensions(new Map(queue.entries())); 6601 queue.clear(); 6602 } 6603 }); 6604 const namespaces = await Promise.all(requestedNames.map(extensionName => { 6605 return extensionsStorage.get(extensionName); 6606 })); 6607 return namespaces.reduce((acc, namespace) => { 6608 return { 6609 ...acc, 6610 ...Reflection.getClass(namespace) 6611 }; 6612 }, {}); 6613 } 6614 6615 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]']; 6616 function isCloneable(value) { 6617 const isCloneableValue = Type.isObjectLike(value) && cloneableTags.includes(getTag(value)); 6618 return isCloneableValue || Type.isDomNode(value); 6619 } 6620 function internalClone(value, map) { 6621 if (map.has(value)) { 6622 return map.get(value); 6623 } 6624 if (isCloneable(value)) { 6625 if (Type.isArray(value)) { 6626 const cloned = Array.from(value); 6627 map.set(value, cloned); 6628 value.forEach((item, index) => { 6629 cloned[index] = internalClone(item, map); 6630 }); 6631 return map.get(value); 6632 } 6633 if (Type.isDomNode(value)) { 6634 return value.cloneNode(true); 6635 } 6636 if (Type.isMap(value)) { 6637 const result = new Map(); 6638 map.set(value, result); 6639 value.forEach((item, key) => { 6640 result.set(internalClone(key, map), internalClone(item, map)); 6641 }); 6642 return result; 6643 } 6644 if (Type.isSet(value)) { 6645 const result = new Set(); 6646 map.set(value, result); 6647 value.forEach(item => { 6648 result.add(internalClone(item, map)); 6649 }); 6650 return result; 6651 } 6652 if (Type.isDate(value)) { 6653 return new Date(value); 6654 } 6655 if (Type.isRegExp(value)) { 6656 const regExpFlags = /\w*$/; 6657 const flags = regExpFlags.exec(value); 6658 let result = new RegExp(value.source); 6659 if (flags && Type.isArray(flags)) { 6660 result = new RegExp(value.source, flags[0]); 6661 } 6662 result.lastIndex = value.lastIndex; 6663 return result; 6664 } 6665 const proto = Object.getPrototypeOf(value); 6666 const result = Object.assign(Object.create(proto), value); 6667 map.set(value, result); 6668 Object.keys(value).forEach(key => { 6669 result[key] = internalClone(value[key], map); 6670 }); 6671 return result; 6672 } 6673 return value; 6674 } 6675 6676 /** 6677 * Clones any cloneable object 6678 * @param value 6679 * @return {*} 6680 */ 6681 function clone(value) { 6682 return internalClone(value, new WeakMap()); 6683 } 6684 6685 function merge(current, target) { 6686 return Object.entries(target).reduce((acc, [key, value]) => { 6687 if (!Type.isDomNode(acc[key]) && Type.isObjectLike(acc[key]) && Type.isObjectLike(value)) { 6688 acc[key] = merge(acc[key], value); 6689 return acc; 6690 } 6691 acc[key] = value; 6692 return acc; 6693 }, current); 6694 } 6695 6696 function createComparator(fields, orders = []) { 6697 return (a, b) => { 6698 const field = fields[0]; 6699 const order = orders[0] || 'asc'; 6700 if (Type.isUndefined(field)) { 6701 return 0; 6702 } 6703 let valueA = a[field]; 6704 let valueB = b[field]; 6705 if (Type.isString(valueA) && Type.isString(valueB)) { 6706 valueA = valueA.toLowerCase(); 6707 valueB = valueB.toLowerCase(); 6708 } 6709 if (valueA < valueB) { 6710 return order === 'asc' ? -1 : 1; 6711 } 6712 if (valueA > valueB) { 6713 return order === 'asc' ? 1 : -1; 6714 } 6715 return createComparator(fields.slice(1), orders.slice(1))(a, b); 6716 }; 6717 } 6718 6719 function registerExtension(options) { 6720 if (!extensionsStorage.has(options.name)) { 6721 var _options$namespace; 6722 const namespace = (_options$namespace = options === null || options === void 0 ? void 0 : options.namespace) !== null && _options$namespace !== void 0 ? _options$namespace : 'window'; 6723 extensionsStorage.set(options.name, Promise.resolve(namespace)); 6724 } 6725 } 6726
6727 /** 6728 * @memberOf BX 6729 */ 6730 let Runtime = /*#__PURE__*/function () { 6731 function Runtime() { 6732 babelHelpers.classCallCheck(this, Runtime); 6733 } 6734 babelHelpers.createClass(Runtime, null, [{ 6735 key: "debounce", 6736 value: function debounce(func, wait = 0, context = null) { 6737 let timeoutId; 6738 return function debounced(...args) { 6739 if (Type.isNumber(timeoutId)) { 6740 clearTimeout(timeoutId); 6741 } 6742 timeoutId = setTimeout(() => { 6743 func.apply(context || this, args); 6744 }, wait); 6745 }; 6746 } 6747 }, { 6748 key: "throttle", 6749 value: function throttle(func, wait = 0, context = null) { 6750 let timer = 0; 6751 let invoke; 6752 return function wrapper(...args) { 6753 invoke = true; 6754 if (!timer) { 6755 const q = function q() { 6756 if (invoke) { 6757 func.apply(context || this, args); 6758 invoke = false; 6759 timer = setTimeout(q, wait); 6760 } else { 6761 timer = null; 6762 } 6763 }; 6764 q(); 6765 } 6766 }; 6767 } 6768 }, { 6769 key: "html", 6770 value: function html(node, _html, params = {}) { 6771 if (Type.isNil(_html) && Type.isDomNode(node)) { 6772 return node.innerHTML; 6773 } 6774 6775 // eslint-disable-next-line 6776 const parsedHtml = BX.processHTML(_html); 6777 const externalCss = parsedHtml.STYLE.reduce(fetchExternalStyles, []); 6778 const externalJs = parsedHtml.SCRIPT.reduce(fetchExternalScripts, []); 6779 const inlineJs = parsedHtml.SCRIPT.reduce(fetchInlineScripts, []); 6780 if (Type.isDomNode(node)) { 6781 if (params.htmlFirst || !externalJs.length && !externalCss.length) { 6782 if (params.useAdjacentHTML) { 6783 node.insertAdjacentHTML('beforeend', parsedHtml.HTML); 6784 } else { 6785 node.innerHTML = parsedHtml.HTML; 6786 } 6787 } 6788 } 6789 return Promise.all([loadAll(externalJs), loadAll(externalCss)]).then(() => { 6790 if (Type.isDomNode(node) && (externalJs.length > 0 || externalCss.length > 0)) { 6791 if (params.useAdjacentHTML) { 6792 node.insertAdjacentHTML('beforeend', parsedHtml.HTML); 6793 } else { 6794 node.innerHTML = parsedHtml.HTML; 6795 } 6796 } 6797 6798 // eslint-disable-next-line 6799 inlineJs.forEach(script => BX.evalGlobal(script)); 6800 if (Type.isFunction(params.callback)) { 6801 params.callback(); 6802 } 6803 }); 6804 } 6805 /** 6806 * Merges objects or arrays 6807 * @param targets 6808 * @return {any} 6809 */ 6810 }, { 6811 key: "merge", 6812 value: function merge$$1(...targets) { 6813 if (Type.isArray(targets[0])) { 6814 targets.unshift([]); 6815 } else if (Type.isObject(targets[0])) { 6816 targets.unshift({}); 6817 } 6818 return targets.reduce((acc, item) => { 6819 return merge(acc, item); 6820 }, targets[0]); 6821 } 6822 }, { 6823 key: "orderBy", 6824 value: function orderBy(collection, fields = [], orders = []) { 6825 const comparator = createComparator(fields, orders); 6826 return Object.values(collection).sort(comparator); 6827 } 6828 }, { 6829 key: "destroy", 6830 value: function destroy(target, errorMessage = 'Object is destroyed') { 6831 if (Type.isObject(target)) { 6832 const onPropertyAccess = () => { 6833 throw new Error(errorMessage); 6834 }; 6835 const ownProperties = Object.keys(target); 6836 const prototypeProperties = (() => { 6837 const targetPrototype = Object.getPrototypeOf(target); 6838 if (Type.isObject(targetPrototype)) { 6839 return Object.getOwnPropertyNames(targetPrototype); 6840 } 6841 return []; 6842 })(); 6843 const uniquePropertiesList = [...new Set([...ownProperties, ...prototypeProperties])]; 6844 uniquePropertiesList.filter(name => { 6845 const descriptor = Object.getOwnPropertyDescriptor(target, name); 6846 return !/__(.+)__/.test(name) && (!Type.isObject(descriptor) || descriptor.configurable === true); 6847 }
6847).forEach(name => { 6848 Object.defineProperty(target, name, { 6849 get: onPropertyAccess, 6850 set: onPropertyAccess, 6851 configurable: false 6852 }); 6853 }); 6854 Object.setPrototypeOf(target, null); 6855 } 6856 } 6857 }]); 6858 return Runtime; 6859 }(); 6860 babelHelpers.defineProperty(Runtime, "debug", debug); 6861 babelHelpers.defineProperty(Runtime, "loadExtension", loadExtension); 6862 babelHelpers.defineProperty(Runtime, "registerExtension", registerExtension); 6863 babelHelpers.defineProperty(Runtime, "clone", clone); 6864 6865 const _isError = Symbol.for('BX.BaseError.isError'); 6866 6867 /** 6868 * @memberOf BX 6869 */ 6870 let BaseError = /*#__PURE__*/function () { 6871 function BaseError(message, code, customData) { 6872 babelHelpers.classCallCheck(this, BaseError); 6873 this[_isError] = true; 6874 this.message = ''; 6875 this.code = null; 6876 this.customData = null; 6877 this.setMessage(message); 6878 this.setCode(code); 6879 this.setCustomData(customData); 6880 } 6881 6882 /** 6883 * Returns a brief description of the error 6884 * @returns {string} 6885 */ 6886 babelHelpers.createClass(BaseError, [{ 6887 key: "getMessage", 6888 value: function getMessage() { 6889 return this.message; 6890 } 6891 /** 6892 * Sets a message of the error 6893 * @param {string} message 6894 * @returns {this} 6895 */ 6896 }, { 6897 key: "setMessage", 6898 value: function setMessage(message) { 6899 if (Type.isString(message)) { 6900 this.message = message; 6901 } 6902 return this; 6903 } 6904 /** 6905 * Returns a code of the error 6906 * @returns {?string} 6907 */ 6908 }, { 6909 key: "getCode", 6910 value: function getCode() { 6911 return this.code; 6912 } 6913 /** 6914 * Sets a code of the error 6915 * @param {string} code 6916 * @returns {this} 6917 */ 6918 }, { 6919 key: "setCode", 6920 value: function setCode(code) { 6921 if (Type.isStringFilled(code) || code === null) { 6922 this.code = code; 6923 } 6924 return this; 6925 } 6926 /** 6927 * Returns custom data of the error 6928 * @returns {null|*} 6929 */ 6930 }, { 6931 key: "getCustomData", 6932 value: function getCustomData() { 6933 return this.customData; 6934 } 6935 /** 6936 * Sets custom data of the error 6937 * @returns {this} 6938 */ 6939 }, { 6940 key: "setCustomData", 6941 value: function setCustomData(customData) { 6942 if (!Type.isUndefined(customData)) { 6943 this.customData = customData; 6944 } 6945 return this; 6946 } 6947 }, { 6948 key: "toString", 6949 value: function toString() { 6950 const code = this.getCode(); 6951 const message = this.getMessage(); 6952 if (!Type.isStringFilled(code) && !Type.isStringFilled(message)) { 6953 return ''; 6954 } else if (!Type.isStringFilled(code)) { 6955 return `Error: ${message}`; 6956 } else if (!Type.isStringFilled(message)) { 6957 return code; 6958 } else { 6959 return `${code}: ${message}`; 6960 } 6961 } 6962 /** 6963 * Returns true if the object is an instance of BaseError 6964 * @param error 6965 * @returns {boolean} 6966 */ 6967 }], [{ 6968 key: "isError", 6969 value: function isError(error) { 6970 return Type.isObject(error) && error[_isError] === true; 6971 } 6972 }]); 6973 return BaseError; 6974 }(); 6975 6976 /** 6977 * Implements base event object interface 6978 */ 6979 let BaseEvent = /*#__PURE__*/function () { 6980 function BaseEvent(options = { 6981 data: {} 6982 }) { 6983 babelHelpers.classCallCheck(this, BaseEvent); 6984 this.type = ''; 6985 this.data = null; 6986 this.target = null; 6987 this.compatData = null; 6988 this.defaultPrevented = false; 6989 this.immediatePropagationStopped = false; 6990 this.errors = []; 6991 this.setData(options.data); 6992 this.setCompatData(options.compatData); 6993 } 6994 babelHelpers.createClass(BaseEvent, [{ 6995 key: "getType", 6996 /** 6997 * Returns the name of the event 6998 * @returns {string} 6999 */ 7000 value: function getType() { 7001 return this.type; 7002 } 7003 /** 7004 * 7005 * @param {string} type 7006 */ 7007 }, { 7008 key: "setType", 7009 value: function setType(type) { 7010 if (Type.isStringFilled(type)) { 7011 this.type = type; 7012 } 7013 return this; 7014 } 7015 /** 7016 * Returns an event data 7017 */ 7018 }, { 7019 key: "getData", 7020 value: function getData() { 7021 return this.data; 7022 } 7023 /** 7024 * Sets an event data 7025 * @param data 7026 */ 7027 }, { 7028 key: "setData", 7029 value: function setData(data) { 7030 if (!Type.isUndefined(data)) { 7031 this.data = data; 7032 } 7033 return this; 7034 } 7035 /** 7036 * Returns arguments for BX.addCustomEvent handlers (deprecated). 7037 * @returns {array | null} 7038 */ 7039 }, { 7040 key: "getCompatData", 7041 value: function getCompatData() { 7042 return this.compatData; 7043 } 7044 /** 7045 * Sets arguments for BX.addCustomEvent handlers (deprecated) 7046 * @param data 7047 */ 7048 }, { 7049 key: "setCompatData", 7050 value: function setCompatData(data) { 7051 if (Type.isArrayLike(data)) { 7052 this.compatData = data; 7053 } 7054 return this; 7055 } 7056 /** 7057 * Sets a event target 7058 * @param target 7059 */ 7060 }, { 7061 key: "setTarget", 7062 value: function setTarget(target) { 7063 this.target = target; 7064 return this; 7065 } 7066 /** 7067 * Returns a event target 7068 */ 7069 }, { 7070 key: "getTarget", 7071 value: function getTarget() { 7072 return this.target; 7073 } 7074 /** 7075 * Returns an array of event errors 7076 * @returns {[]} 7077 */ 7078 }, { 7079 key: "getErrors", 7080 value: function getErrors() { 7081 return this.errors; 7082 } 7083 /** 7084 * Adds an error of the event. 7085 * Event listeners can prevent emitter's default action and set the reason of this behavior. 7086 * @param error 7087 */ 7088 }, { 7089 key: "setError", 7090 value: function setError(error) { 7091 if (BaseError.isError(error)) { 7092 this.errors.push(error); 7093 } 7094 } 7095 /** 7096 * Prevents default action 7097 */ 7098 }, { 7099 key: "preventDefault", 7100 value: function preventDefault() { 7101 this.defaultPrevented = true; 7102 } 7103 /** 7104 * Checks that is default action prevented 7105 * @return {boolean} 7106 */ 7107 }, { 7108 key: "isDefaultPrevented", 7109 value: function isDefaultPrevented() { 7110 return this.defaultPrevented; 7111 } 7112 /** 7113 * Stops event immediate propagation 7114 */ 7115 }, { 7116 key: "stopImmediatePropagation", 7117 value: function stopImmediatePropagation() { 7118 this.immediatePropagationStopped = true; 7119 } 7120 /** 7121 * Checks that is immediate propagation stopped 7122 * @return {boolean} 7123 */ 7124 }, { 7125 key: "isImmediatePropagationStopped", 7126 value: function isImmediatePropagationStopped() { 7127 return this.immediatePropagationStopped; 7128 } 7129 }], [{ 7130 key: "create", 7131 value: function create(options) { 7132 return new this(options); 7133 } 7134 }]); 7135 return BaseEvent; 7136 }(); 7137 7138 let EventStore = /*#__PURE__*/function () { 7139 function EventStore(options = {}) { 7140 babelHelpers.classCallCheck(this, EventStore); 7141 this.defaultMaxListeners = Type.isNumber(options.defaultMaxListeners) ? options.defaultMaxListeners : 10; 7142 this.eventStore = new WeakMap(); 7143 } 7144 babelHelpers.createClass(EventStore, [{ 7145 key: "add", 7146 value: function add(target, options = {}) { 7147 const record = this.getRecordScheme(); 7148 if (Type.isNumber(options.maxListeners)) { 7149 record.maxListeners = options.maxListeners; 7150 } 7151 this.eventStore.set(target, record); 7152 return record; 7153 } 7154 }, { 7155 key: "get", 7156 value: function get(target) { 7157 return this.eventStore.get(target); 7158 } 7159 }, { 7160 key: "getOrAdd", 7161 value: function getOrAdd(target, options = {}) { 7162 return this.get(target) || this.add(target, options); 7163 } 7164 }, { 7165 key: "delete", 7166 value: function _delete(context) { 7167 this.eventStore.delete(context); 7168 } 7169 }, { 7170 key: "getRecordScheme", 7171 value: function getRecordScheme() { 7172 return { 7173 eventsMap: new Map(), 7174 onceMap: new Map(), 7175 maxListeners: this.getDefaultMaxListeners(), 7176 eventsMaxListeners: new Map() 7177 }; 7178 } 7179 }, { 7180 key: "getDefaultMaxListeners", 7181 value: function getDefaultMaxListeners() { 7182 return this.defaultMaxListeners; 7183 } 7184 }]); 7185 return EventStore; 7186 }(); 7187 7188 let WarningStore = /*#__PURE__*/function () {
7189 function WarningStore() { 7190 babelHelpers.classCallCheck(this, WarningStore); 7191 this.warnings = new Map(); 7192 this.printDelayed = Runtime.debounce(this.print.bind(this), 500); 7193 } 7194 babelHelpers.createClass(WarningStore, [{ 7195 key: "add", 7196 value: function add(target, eventName, listeners) { 7197 let contextWarnings = this.warnings.get(target); 7198 if (!contextWarnings) { 7199 contextWarnings = Object.create(null); 7200 this.warnings.set(target, contextWarnings); 7201 } 7202 if (!contextWarnings[eventName]) { 7203 contextWarnings[eventName] = {}; 7204 } 7205 contextWarnings[eventName].size = listeners.size; 7206 if (!Type.isArray(contextWarnings[eventName].errors)) { 7207 contextWarnings[eventName].errors = []; 7208 } 7209 contextWarnings[eventName].errors.push(new Error()); 7210 } 7211 }, { 7212 key: "print", 7213 value: function print() { 7214 this.warnings.forEach(warnings => { 7215 for (let eventName in warnings) { 7216 console.groupCollapsed('Possible BX.Event.EventEmitter memory leak detected. ' + warnings[eventName].size + ' "' + eventName + '" listeners added. ' + 'Use emitter.setMaxListeners() to increase limit.'); 7217 console.dir(warnings[eventName].errors); 7218 console.groupEnd(); 7219 } 7220 }); 7221 this.clear(); 7222 } 7223 }, { 7224 key: "clear", 7225 value: function clear() { 7226 this.warnings.clear(); 7227 } 7228 }, { 7229 key: "printDelayed", 7230 value: function printDelayed() {} 7231 }]); 7232 return WarningStore; 7233 }(); 7234 7235 const eventStore = new EventStore({ 7236 defaultMaxListeners: 10 7237 }); 7238 const warningStore = new WarningStore(); 7239 const aliasStore = new Map(); 7240 const globalTarget = { 7241 GLOBAL_TARGET: 'GLOBAL_TARGET' // this key only for debugging purposes 7242 }; 7243 7244 eventStore.add(globalTarget, { 7245 maxListeners: 25 7246 }); 7247 const isEmitterProperty = Symbol.for('BX.Event.EventEmitter.isEmitter'); 7248 const namespaceProperty = Symbol('namespaceProperty'); 7249 const targetProperty = Symbol('targetProperty'); 7250 let EventEmitter = /*#__PURE__*/function () { 7251 /** @private */ 7252 7253 function EventEmitter(...args) { 7254 babelHelpers.classCallCheck(this, EventEmitter); 7255 this[targetProperty] = null; 7256 this[namespaceProperty] = null; 7257 this[isEmitterProperty] = true; 7258 let target = this; 7259 if (Object.getPrototypeOf(this) === EventEmitter.prototype && args.length > 0) { 7260 if (!Type.isObject(args[0])) { 7261 throw new TypeError('The "target" argument must be an object.'); 7262 } 7263 target = args[0]; 7264 this.setEventNamespace(args[1]); 7265 } 7266 this[targetProperty] = target; 7267 } 7268 7269 /** 7270 * Makes a target observable 7271 * @param {object} target 7272 * @param {string} namespace 7273 */ 7274 babelHelpers.createClass(EventEmitter, [{ 7275 key: "setEventNamespace", 7276 value: function setEventNamespace(namespace) { 7277 if (Type.isStringFilled(namespace)) { 7278 this[namespaceProperty] = namespace; 7279 } 7280 } 7281 }, { 7282 key: "getEventNamespace", 7283 value: function getEventNamespace() { 7284 return this[namespaceProperty]; 7285 } 7286 /** 7287 * Subscribes listener on specified global event 7288 * @param {object} target 7289 * @param {string} eventName 7290 * @param {Function<BaseEvent>} listener 7291 * @param {object} options 7292 */ 7293 }, { 7294 key: "subscribe", 7295 /** 7296 * Subscribes a listener on a specified event 7297 * @param {string} eventName 7298 * @param {Function<BaseEvent>} listener 7299 * @return {this} 7300 */ 7301 value: function subscribe(eventName, listener) { 7302 EventEmitter.subscribe(this, eventName, listener); 7303 return this; 7304 } 7305 /** 7306 * 7307 * @param {object} options 7308 * @param {object} [aliases] 7309 * @param {boolean} [compatMode=false] 7310 */ 7311 }, { 7312 key: "subscribeFromOptions", 7313 value: function subscribeFromOptions(options, aliases, compatMode) { 7314 if (Type.isArrayFilled(options)) { 7315 options.forEach(events => { 7316 this.subscribeFromOptions(events); 7317 }); 7318 return; 7319 } 7320 if (!Type.isPlainObject(options)) { 7321 return; 7322 } 7323 aliases = Type.isPlainObject(aliases) ? EventEmitter.normalizeAliases(aliases) : {};
7324 Object.keys(options).forEach(eventName => { 7325 const listener = EventEmitter.normalizeListener(options[eventName]); 7326 eventName = EventEmitter.normalizeEventName(eventName); 7327 if (aliases[eventName]) { 7328 const { 7329 eventName: actualName 7330 } = aliases[eventName]; 7331 EventEmitter.subscribe(this, actualName, listener, { 7332 compatMode: compatMode !== false 7333 }); 7334 } else { 7335 EventEmitter.subscribe(this, eventName, listener, { 7336 compatMode: compatMode === true 7337 }); 7338 } 7339 }); 7340 } 7341 /** 7342 * Subscribes a listener that is called at 7343 * most once for a specified event. 7344 * @param {object} target 7345 * @param {string} eventName 7346 * @param {Function<BaseEvent>} listener 7347 */ 7348 }, { 7349 key: "subscribeOnce", 7350 /** 7351 * Subscribes a listener that is called at most once for a specified event. 7352 * @param {string} eventName 7353 * @param {Function<BaseEvent>} listener 7354 * @return {this} 7355 */ 7356 value: function subscribeOnce(eventName, listener) { 7357 EventEmitter.subscribeOnce(this, eventName, listener); 7358 return this; 7359 } 7360 /** 7361 * Unsubscribes an event listener 7362 * @param {object} target 7363 * @param {string} eventName 7364 * @param {Function<BaseEvent>} listener 7365 * @param options 7366 */ 7367 }, { 7368 key: "unsubscribe", 7369 /** 7370 * Unsubscribes an event listener 7371 * @param {string} eventName 7372 * @param {Function<BaseEvent>} listener 7373 * @return {this} 7374 */ 7375 value: function unsubscribe(eventName, listener) { 7376 EventEmitter.unsubscribe(this, eventName, listener); 7377 return this; 7378 } 7379 /** 7380 * Unsubscribes all event listeners 7381 * @param {object} target 7382 * @param {string} eventName 7383 * @param options 7384 */ 7385 }, { 7386 key: "unsubscribeAll", 7387 /** 7388 * Unsubscribes all event listeners 7389 * @param {string} [eventName] 7390 */ 7391 value: function unsubscribeAll(eventName) { 7392 EventEmitter.unsubscribeAll(this, eventName); 7393 } 7394 /** 7395 * 7396 * @param {object} target 7397 * @param {string} eventName 7398 * @param {BaseEvent | any} event 7399 * @param {object} options 7400 * @returns {Array} 7401 */ 7402 }, { 7403 key: "emit", 7404 /** 7405 * Emits specified event with specified event object 7406 * @param {string} eventName 7407 * @param {BaseEvent | any} event 7408 * @return {this} 7409 */ 7410 value: function emit(eventName, event) { 7411 if (this.getEventNamespace() === null) { 7412 console.warn('The instance of BX.Event.EventEmitter is supposed to have an event namespace. ' + 'Use emitter.setEventNamespace() to make events more unique.'); 7413 } 7414 EventEmitter.emit(this, eventName, event); 7415 return this; 7416 } 7417 /** 7418 * Emits global event and returns a promise that is resolved when 7419 * all promise returned from event handlers are resolved, 7420 * or rejected when at least one of the returned promise is rejected. 7421 * Importantly. You can return any value from synchronous handlers, not just promise 7422 * @param {object} target 7423 * @param {string} eventName 7424 * @param {BaseEvent | any} event 7425 * @return {Promise<Array>} 7426 */ 7427 }, { 7428 key: "emitAsync", 7429 /** 7430 * Emits event and returns a promise that is resolved when 7431 * all promise returned from event handlers are resolved, 7432 * or rejected when at least one of the returned promise is rejected. 7433 * Importantly. You can return any value from synchronous handlers, not just promise 7434 * @param {string} eventName 7435 * @param {BaseEvent|any} event 7436 * @return {Promise<Array>} 7437 */ 7438 value: function emitAsync(eventName, event) { 7439 if (this.getEventNamespace() === null) { 7440 console.warn('The instance of BX.Event.EventEmitter is supposed to have an event namespace. ' + 'Use emitter.setEventNamespace() to make events more unique.'); 7441 } 7442 return EventEmitter.emitAsync(this, eventName, event); 7443 } 7444 /** 7445 * @private 7446 * @param {object} target 7447 * @param {string} eventName 7448 * @param {BaseEvent|any} event 7449 * @returns {BaseEvent} 7450 */ 7451 }, { 7452 key: "setMaxListeners", 7453 /** 7454 * Sets max events listeners count 7455 * this.setMaxListeners(10) - sets the default value for all events
7456 * this.setMaxListeners("onClose", 10) sets the value for onClose event 7457 * @return {this} 7458 * @param args 7459 */ 7460 value: function setMaxListeners(...args) { 7461 EventEmitter.setMaxListeners(this, ...args); 7462 return this; 7463 } 7464 /** 7465 * Returns max event listeners count 7466 * @param {object} target 7467 * @param {string} [eventName] 7468 * @returns {number} 7469 */ 7470 }, { 7471 key: "getMaxListeners", 7472 /** 7473 * Returns max event listeners count 7474 * @param {string} [eventName] 7475 * @returns {number} 7476 */ 7477 value: function getMaxListeners(eventName) { 7478 return EventEmitter.getMaxListeners(this, eventName); 7479 } 7480 /** 7481 * Adds or subtracts max listeners count 7482 * Event.EventEmitter.addMaxListeners() - adds one max listener for all events of global target 7483 * Event.EventEmitter.addMaxListeners(3) - adds three max listeners for all events of global target 7484 * Event.EventEmitter.addMaxListeners(-1) - subtracts one max listener for all events of global target 7485 * Event.EventEmitter.addMaxListeners('onClose') - adds one max listener for onClose event of global target 7486 * Event.EventEmitter.addMaxListeners('onClose', 2) - adds two max listeners for onClose event of global target 7487 * Event.EventEmitter.addMaxListeners('onClose', -1) - subtracts one max listener for onClose event of global target 7488 * 7489 * Event.EventEmitter.addMaxListeners(obj) - adds one max listener for all events of 'obj' target 7490 * Event.EventEmitter.addMaxListeners(obj, 3) - adds three max listeners for all events of 'obj' target 7491 * Event.EventEmitter.addMaxListeners(obj, -1) - subtracts one max listener for all events of 'obj' target 7492 * Event.EventEmitter.addMaxListeners(obj, 'onClose') - adds one max listener for onClose event of 'obj' target 7493 * Event.EventEmitter.addMaxListeners(obj, 'onClose', 2) - adds two max listeners for onClose event of 'obj' target 7494 * Event.EventEmitter.addMaxListeners(obj, 'onClose', -1) - subtracts one max listener for onClose event of 'obj' target 7495 * @param args 7496 * @returns {number} 7497 */ 7498 }, { 7499 key: "incrementMaxListeners", 7500 /** 7501 * Increases max listeners count 7502 * this.incrementMaxListeners() - adds one max listener for all events 7503 * this.incrementMaxListeners(3) - adds three max listeners for all events 7504 * this.incrementMaxListeners('onClose') - adds one max listener for onClose event 7505 * this.incrementMaxListeners('onClose', 2) - adds two max listeners for onClose event 7506 */ 7507 value: function incrementMaxListeners(...args) { 7508 return EventEmitter.incrementMaxListeners(this, ...args); 7509 } 7510 /** 7511 * Decreases max listeners count 7512 * 7513 * Event.EventEmitter.decrementMaxListeners() - subtracts one max listener for all events of global target 7514 * Event.EventEmitter.decrementMaxListeners(3) - subtracts three max listeners for all events of global target 7515 * Event.EventEmitter.decrementMaxListeners('onClose') - subtracts one max listener for onClose event of global target 7516 * Event.EventEmitter.decrementMaxListeners('onClose', 2) - subtracts two max listeners for onClose event of global target 7517 * 7518 * Event.EventEmitter.decrementMaxListeners(obj) - subtracts one max listener for all events of 'obj' target 7519 * Event.EventEmitter.decrementMaxListeners(obj, 3) - subtracts three max listeners for all events of 'obj' target 7520 * Event.EventEmitter.decrementMaxListeners(obj, 'onClose') - subtracts one max listener for onClose event of 'obj' target 7521 * Event.EventEmitter.decrementMaxListeners(obj, 'onClose', 2) - subtracts two max listeners for onClose event of 'obj' target 7522 */ 7523 }, { 7524 key: "decrementMaxListeners", 7525 /** 7526 * Increases max listeners count 7527 * this.decrementMaxListeners() - subtracts one max listener for all events 7528 * this.decrementMaxListeners(3) - subtracts three max listeners for all events 7529 * this.decrementMaxListeners('onClose') - subtracts one max listener for onClose event 7530 * this.decrementMaxListeners('onClose', 2) - subtracts two max listeners for onClose event 7531 */ 7532 value: function decrementMaxListeners(...args) { 7533 return EventEmitter.decrementMaxListeners(this, ...args); 7534 } 7535 /** 7536 * @private 7537 * @param {Array} args 7538 * @returns Array 7539 */ 7540 }, { 7541 key: "getListeners", 7542 /** 7543 * Gets listeners list for specified event 7544 * @param {string} eventName 7545 */ 7546 value: function getListeners(eventName) { 7547 return EventEmitter.getListeners(this, eventName); 7548 } 7549 /** 7550 * Returns a full event name with namespace 7551 * @param {string} eventName 7552 * @returns {string} 7553 */ 7554 }, { 7555 key: "getFullEventName", 7556 value: function getFullEventName(eventName) { 7557 if (!Type.isStringFilled(eventName)) { 7558 throw new TypeError('The "eventName" argument must be a string.'); 7559 } 7560 return EventEmitter.makeFullEventName(this.getEventNamespace(), eventName); 7561 } 7562 /** 7563 * Registers aliases (old event names for BX.onCustomEvent) 7564 * @param aliases 7565 */ 7566 }], [{ 7567 key: "makeObservable", 7568 value: function makeObservable(target, namespace) { 7569 if (!Type.isObject(target)) { 7570 throw new TypeError('The "target" argument must be an object.'); 7571 } 7572 if (!Type.isStringFilled(namespace)) { 7573 throw new TypeError('The "namespace" must be an non-empty string.'); 7574 } 7575 if (EventEmitter.isEventEmitter(target)) { 7576 throw new TypeError('The "target" is an event emitter already.'); 7577 } 7578 const targetProto = Object.getPrototypeOf(target); 7579 const emitter = new EventEmitter(); 7580 emitter.setEventNamespace(namespace); 7581 Object.setPrototypeOf(emitter, targetProto); 7582 Object.setPrototypeOf(target, emitter); 7583 Object.getOwnPropertyNames(EventEmitter.prototype).forEach(method => {
7584 if (['constructor'].includes(method)) { 7585 return; 7586 } 7587 emitter[method] = function (...args) { 7588 return EventEmitter.prototype[method].apply(target, args); 7589 }; 7590 }); 7591 } 7592 }, { 7593 key: "subscribe", 7594 value: function subscribe(target, eventName, listener, options) { 7595 if (Type.isString(target)) { 7596 options = listener; 7597 listener = eventName; 7598 eventName = target; 7599 target = this.GLOBAL_TARGET; 7600 } 7601 if (!Type.isObject(target)) { 7602 throw new TypeError('The "target" argument must be an object.'); 7603 } 7604 eventName = this.normalizeEventName(eventName); 7605 if (!Type.isStringFilled(eventName)) { 7606 throw new TypeError('The "eventName" argument must be a string.'); 7607 } 7608 listener = this.normalizeListener(listener); 7609 options = Type.isPlainObject(options) ? options : {}; 7610 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 7611 const { 7612 eventsMap, 7613 onceMap 7614 } = eventStore.getOrAdd(target); 7615 const onceListeners = onceMap.get(fullEventName); 7616 let listeners = eventsMap.get(fullEventName); 7617 if (listeners && listeners.has(listener) || onceListeners && onceListeners.has(listener)) { 7618 console.error(`You cannot subscribe the same "${fullEventName}" event listener twice.`); 7619 } else if (listeners) { 7620 listeners.set(listener, { 7621 listener, 7622 options, 7623 sort: this.getNextSequenceValue() 7624 }); 7625 } else { 7626 listeners = new Map([[listener, { 7627 listener, 7628 options, 7629 sort: this.getNextSequenceValue() 7630 }]]); 7631 eventsMap.set(fullEventName, listeners); 7632 } 7633 const maxListeners = this.getMaxListeners(target, eventName); 7634 if (listeners.size > maxListeners) { 7635 warningStore.add(target, fullEventName, listeners); 7636 warningStore.printDelayed(); 7637 } 7638 } 7639 }, { 7640 key: "subscribeOnce", 7641 value: function subscribeOnce(target, eventName, listener) { 7642 if (Type.isString(target)) { 7643 listener = eventName; 7644 eventName = target; 7645 target = this.GLOBAL_TARGET;
7646 } 7647 if (!Type.isObject(target)) { 7648 throw new TypeError('The "target" argument must be an object.'); 7649 } 7650 eventName = this.normalizeEventName(eventName); 7651 if (!Type.isStringFilled(eventName)) { 7652 throw new TypeError('The "eventName" argument must be a string.'); 7653 } 7654 listener = this.normalizeListener(listener); 7655 const fullEventName = this.resolveEventName(eventName, target); 7656 const { 7657 eventsMap, 7658 onceMap 7659 } = eventStore.getOrAdd(target); 7660 const listeners = eventsMap.get(fullEventName); 7661 let onceListeners = onceMap.get(fullEventName); 7662 if (listeners && listeners.has(listener) || onceListeners && onceListeners.has(listener)) { 7663 console.error(`You cannot subscribe the same "${fullEventName}" event listener twice.`); 7664 } else { 7665 const once = (...args) => { 7666 this.unsubscribe(target, eventName, once); 7667 onceListeners.delete(listener); 7668 listener(...args); 7669 }; 7670 if (onceListeners) { 7671 onceListeners.set(listener, once); 7672 } else { 7673 onceListeners = new Map([[listener, once]]); 7674 onceMap.set(fullEventName, onceListeners); 7675 } 7676 this.subscribe(target, eventName, once); 7677 } 7678 } 7679 }, { 7680 key: "unsubscribe", 7681 value: function unsubscribe(target, eventName, listener, options) { 7682 if (Type.isString(target)) { 7683 listener = eventName; 7684 eventName = target; 7685 target = this.GLOBAL_TARGET;
7686 } 7687 eventName = this.normalizeEventName(eventName); 7688 if (!Type.isStringFilled(eventName)) { 7689 throw new TypeError('The "eventName" argument must be a string.'); 7690 } 7691 listener = this.normalizeListener(listener); 7692 options = Type.isPlainObject(options) ? options : {}; 7693 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 7694 const targetInfo = eventStore.get(target); 7695 const listeners = targetInfo && targetInfo.eventsMap.get(fullEventName); 7696 const onceListeners = targetInfo && targetInfo.onceMap.get(fullEventName); 7697 if (listeners) { 7698 listeners.delete(listener); 7699 } 7700 if (onceListeners) { 7701 const once = onceListeners.get(listener); 7702 if (once) { 7703 onceListeners.delete(listener); 7704 listeners.delete(once); 7705 } 7706 } 7707 } 7708 }, { 7709 key: "unsubscribeAll", 7710 value: function unsubscribeAll(target, eventName, options) { 7711 if (Type.isString(target)) { 7712 eventName = target; 7713 target = this.GLOBAL_TARGET;
7714 } 7715 if (Type.isStringFilled(eventName)) { 7716 const targetInfo = eventStore.get(target); 7717 if (targetInfo) { 7718 options = Type.isPlainObject(options) ? options : {}; 7719 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 7720 targetInfo.eventsMap.delete(fullEventName); 7721 targetInfo.onceMap.delete(fullEventName); 7722 } 7723 } else if (Type.isNil(eventName)) { 7724 if (target === this.GLOBAL_TARGET) { 7725 console.error('You cannot unsubscribe all global listeners.'); 7726 } else { 7727 eventStore.delete(target); 7728 } 7729 } 7730 } 7731 }, { 7732 key: "emit", 7733 value: function emit(target, eventName, event, options) { 7734 if (Type.isString(target)) { 7735 options = event; 7736 event = eventName; 7737 eventName = target; 7738 target = this.GLOBAL_TARGET; 7739 } 7740 if (!Type.isObject(target)) { 7741 throw new TypeError('The "target" argument must be an object.'); 7742 } 7743 eventName = this.normalizeEventName(eventName); 7744 if (!Type.isStringFilled(eventName)) { 7745 throw new TypeError('The "eventName" argument must be a string.'); 7746 } 7747 options = Type.isPlainObject(options) ? options : {}; 7748 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 7749 const globalEvents = eventStore.get(this.GLOBAL_TARGET); 7750 const globalListeners = globalEvents && globalEvents.eventsMap.get(fullEventName) || new Map(); 7751 let targetListeners = new Set(); 7752 if (target !== this.GLOBAL_TARGET) { 7753 const targetEvents = eventStore.get(target); 7754 targetListeners = targetEvents && targetEvents.eventsMap.get(fullEventName) || new Map(); 7755 } 7756 const listeners = [...globalListeners.values(), ...targetListeners.values()]; 7757 listeners.sort((a, b) => { 7758 return a.sort - b.sort; 7759 }); 7760 const preparedEvent = this.prepareEvent(target, fullEventName, event); 7761 const result = []; 7762 for (const { 7763 listener, 7764 options: listenerOptions 7765 } of listeners) { 7766 if (preparedEvent.isImmediatePropagationStopped()) { 7767 break; 7768 } 7769 7770 // A previous listener could remove a current listener. 7771 if (globalListeners.has(listener) || targetListeners.has(listener)) { 7772 let listenerResult; 7773 if (listenerOptions.compatMode) { 7774 let params = []; 7775 const compatData = preparedEvent.getCompatData(); 7776 if (compatData === null) { 7777 params = [preparedEvent]; 7778 } else { 7779 params = options.cloneData === true ? Runtime.clone(compatData) : compatData; 7780 } 7781 const context = Type.isUndefined(options.thisArg) ? target : options.thisArg; 7782 listenerResult = listener.apply(context, params); 7783 } else { 7784 listenerResult = Type.isUndefined(options.thisArg) ? listener(preparedEvent) : listener.call(options.thisArg, preparedEvent); 7785 } 7786 result.push(listenerResult); 7787 } 7788 } 7789 return result; 7790 } 7791 }, { 7792 key: "emitAsync", 7793 value: function emitAsync(target, eventName, event) { 7794 if (Type.isString(target)) { 7795 event = eventName; 7796 eventName = target; 7797 target = this.GLOBAL_TARGET;
7798 } 7799 return Promise.all(this.emit(target, eventName, event)); 7800 } 7801 }, { 7802 key: "prepareEvent", 7803 value: function prepareEvent(target, eventName, event) { 7804 let preparedEvent = event; 7805 if (!(event instanceof BaseEvent)) { 7806 preparedEvent = new BaseEvent(); 7807 preparedEvent.setData(event); 7808 } 7809 preparedEvent.setTarget(this.isEventEmitter(target) ? target[targetProperty] : target); 7810 preparedEvent.setType(eventName); 7811 return preparedEvent; 7812 } 7813 /** 7814 * @private 7815 * @returns {number} 7816 */ 7817 }, { 7818 key: "getNextSequenceValue", 7819 value: function getNextSequenceValue() { 7820 return this.sequenceValue++; 7821 } 7822 /** 7823 * Sets max global events listeners count 7824 * Event.EventEmitter.setMaxListeners(10) - sets the default value for all events (global target) 7825 * Event.EventEmitter.setMaxListeners("onClose", 10) - sets the value for onClose event (global target) 7826 * Event.EventEmitter.setMaxListeners(obj, 10) - sets the default value for all events (obj target) 7827 * Event.EventEmitter.setMaxListeners(obj, "onClose", 10); - sets the value for onClose event (obj target) 7828 * @return {void} 7829 * @param args 7830 */ 7831 }, { 7832 key: "setMaxListeners", 7833 value: function setMaxListeners(...args) { 7834 let target = this.GLOBAL_TARGET;
7835 let eventName = null; 7836 let count; 7837 if (args.length === 1) { 7838 count = args[0]; 7839 } else if (args.length === 2) { 7840 if (Type.isString(args[0])) { 7841 [eventName, count] = args; 7842 } else { 7843 [target, count] = args; 7844 } 7845 } else if (args.length >= 3) { 7846 [target, eventName, count] = args; 7847 } 7848 if (!Type.isObject(target)) { 7849 throw new TypeError('The "target" argument must be an object.'); 7850 } 7851 if (eventName !== null && !Type.isStringFilled(eventName)) { 7852 throw new TypeError('The "eventName" argument must be a string.'); 7853 } 7854 if (!Type.isNumber(count) || count < 0) { 7855 throw new TypeError(`The value of "count" is out of range. It must be a non-negative number. Received ${count}.`); 7856 } 7857 const targetInfo = eventStore.getOrAdd(target); 7858 if (Type.isStringFilled(eventName)) { 7859 const fullEventName = this.resolveEventName(eventName, target); 7860 targetInfo.eventsMaxListeners.set(fullEventName, count); 7861 } else { 7862 targetInfo.maxListeners = count; 7863 } 7864 } 7865 }, { 7866 key: "getMaxListeners", 7867 value: function getMaxListeners(target, eventName) { 7868 if (Type.isString(target)) { 7869 eventName = target; 7870 target = this.GLOBAL_TARGET;
7871 } else if (Type.isNil(target)) { 7872 target = this.GLOBAL_TARGET; 7873 } 7874 if (!Type.isObject(target)) { 7875 throw new TypeError('The "target" argument must be an object.'); 7876 } 7877 const targetInfo = eventStore.get(target); 7878 if (targetInfo) { 7879 let maxListeners = targetInfo.maxListeners; 7880 if (Type.isStringFilled(eventName)) { 7881 const fullEventName = this.resolveEventName(eventName, target); 7882 maxListeners = targetInfo.eventsMaxListeners.get(fullEventName) || maxListeners; 7883 } 7884 return maxListeners; 7885 } 7886 return this.DEFAULT_MAX_LISTENERS; 7887 } 7888 }, { 7889 key: "addMaxListeners", 7890 value: function addMaxListeners(...args) { 7891 const [target, eventName, increment] = this.destructMaxListenersArgs(...args); 7892 const maxListeners = Math.max(this.getMaxListeners(target, eventName) + increment, 0); 7893 if (Type.isStringFilled(eventName)) { 7894 EventEmitter.setMaxListeners(target, eventName, maxListeners); 7895 } else { 7896 EventEmitter.setMaxListeners(target, maxListeners); 7897 } 7898 return maxListeners; 7899 } 7900 /** 7901 * Increases max listeners count 7902 * 7903 * Event.EventEmitter.incrementMaxListeners() - adds one max listener for all events of global target 7904 * Event.EventEmitter.incrementMaxListeners(3) - adds three max listeners for all events of global target 7905 * Event.EventEmitter.incrementMaxListeners('onClose') - adds one max listener for onClose event of global target 7906 * Event.EventEmitter.incrementMaxListeners('onClose', 2) - adds two max listeners for onClose event of global target 7907 * 7908 * Event.EventEmitter.incrementMaxListeners(obj) - adds one max listener for all events of 'obj' target 7909 * Event.EventEmitter.incrementMaxListeners(obj, 3) - adds three max listeners for all events of 'obj' target 7910 * Event.EventEmitter.incrementMaxListeners(obj, 'onClose') - adds one max listener for onClose event of 'obj' target 7911 * Event.EventEmitter.incrementMaxListeners(obj, 'onClose', 2) - adds two max listeners for onClose event of 'obj' target 7912 */ 7913 }, { 7914 key: "incrementMaxListeners", 7915 value: function incrementMaxListeners(...args) { 7916 const [target, eventName, increment] = this.destructMaxListenersArgs(...args); 7917 return this.addMaxListeners(target, eventName, Math.abs(increment)); 7918 } 7919 }, { 7920 key: "decrementMaxListeners", 7921 value: function decrementMaxListeners(...args) { 7922 const [target, eventName, increment] = this.destructMaxListenersArgs(...args); 7923 return this.addMaxListeners(target, eventName, -Math.abs(increment)); 7924 } 7925 }, { 7926 key: "destructMaxListenersArgs", 7927 value: function destructMaxListenersArgs(...args) { 7928 let eventName = null; 7929 let increment = 1; 7930 let target = this.GLOBAL_TARGET;
7931 if (args.length === 1) { 7932 if (Type.isNumber(args[0])) { 7933 increment = args[0]; 7934 } else if (Type.isString(args[0])) { 7935 eventName = args[0]; 7936 } else { 7937 target = args[0]; 7938 } 7939 } else if (args.length === 2) { 7940 if (Type.isString(args[0])) { 7941 [eventName, increment] = args; 7942 } else if (Type.isString(args[1])) { 7943 [target, eventName] = args; 7944 } else { 7945 [target, increment] = args; 7946 } 7947 } else if (args.length >= 3) { 7948 [target, eventName, increment] = args; 7949 } 7950 if (!Type.isObject(target)) { 7951 throw new TypeError('The "target" argument must be an object.'); 7952 } 7953 if (eventName !== null && !Type.isStringFilled(eventName)) { 7954 throw new TypeError('The "eventName" argument must be a string.'); 7955 } 7956 if (!Type.isNumber(increment)) { 7957 throw new TypeError('The value of "increment" must be a number.'); 7958 } 7959 return [target, eventName, increment]; 7960 } 7961 /** 7962 * Gets listeners list for a specified event 7963 * @param {object} target 7964 * @param {string} eventName 7965 */ 7966 }, { 7967 key: "getListeners", 7968 value: function getListeners(target, eventName) { 7969 if (Type.isString(target)) { 7970 eventName = target; 7971 target = this.GLOBAL_TARGET;
7972 } 7973 if (!Type.isObject(target)) { 7974 throw new TypeError('The "target" argument must be an object.'); 7975 } 7976 eventName = this.normalizeEventName(eventName); 7977 if (!Type.isStringFilled(eventName)) { 7978 throw new TypeError('The "eventName" argument must be a string.'); 7979 } 7980 const targetInfo = eventStore.get(target); 7981 if (!targetInfo) { 7982 return new Map(); 7983 } 7984 const fullEventName = this.resolveEventName(eventName, target); 7985 return targetInfo.eventsMap.get(fullEventName) || new Map(); 7986 } 7987 }, { 7988 key: "registerAliases", 7989 value: function registerAliases(aliases) { 7990 aliases = this.normalizeAliases(aliases); 7991 Object.keys(aliases).forEach(alias => { 7992 aliasStore.set(alias, { 7993 eventName: aliases[alias].eventName, 7994 namespace: aliases[alias].namespace 7995 }); 7996 }); 7997 EventEmitter.mergeEventAliases(aliases); 7998 } 7999 /** 8000 * @private 8001 * @param aliases 8002 */ 8003 }, { 8004 key: "normalizeAliases", 8005 value: function normalizeAliases(aliases) { 8006 if (!Type.isPlainObject(aliases)) { 8007 throw new TypeError('The "aliases" argument must be an object.'); 8008 } 8009 const result = Object.create(null); 8010 for (let alias in aliases) { 8011 if (!Type.isStringFilled(alias)) { 8012 throw new TypeError('The alias must be an non-empty string.'); 8013 } 8014 const options = aliases[alias]; 8015 if (!options || !Type.isStringFilled(options.eventName) || !Type.isStringFilled(options.namespace)) { 8016 throw new TypeError('The alias options must set the "eventName" and the "namespace".'); 8017 } 8018 alias = this.normalizeEventName(alias); 8019 result[alias] = { 8020 eventName: options.eventName, 8021 namespace: options.namespace 8022 }; 8023 } 8024 return result; 8025 } 8026 /** 8027 * @private 8028 */ 8029 }, { 8030 key: "mergeEventAliases", 8031 value: function mergeEventAliases(aliases) { 8032 const globalEvents = eventStore.get(this.GLOBAL_TARGET); 8033 if (!globalEvents) { 8034 return; 8035 } 8036 Object.keys(aliases).forEach(alias => { 8037 const options = aliases[alias]; 8038 alias = this.normalizeEventName(alias); 8039 const fullEventName = this.makeFullEventName(options.namespace, options.eventName); 8040 const aliasListeners = globalEvents.eventsMap.get(alias); 8041 if (aliasListeners) { 8042 const listeners = globalEvents.eventsMap.get(fullEventName) || new Map(); 8043 globalEvents.eventsMap.set(fullEventName, new Map([...listeners, ...aliasListeners])); 8044 globalEvents.eventsMap.delete(alias); 8045 } 8046 const aliasOnceListeners = globalEvents.onceMap.get(alias); 8047 if (aliasOnceListeners) { 8048 const onceListeners = globalEvents.onceMap.get(fullEventName) || new Map(); 8049 globalEvents.onceMap.set(fullEventName, new Map([...onceListeners, ...aliasOnceListeners])); 8050 globalEvents.onceMap.delete(alias); 8051 } 8052 const aliasMaxListeners = globalEvents.eventsMaxListeners.get(alias); 8053 if (aliasMaxListeners) { 8054 const eventMaxListeners = globalEvents.eventsMaxListeners.get(fullEventName) || 0; 8055 globalEvents.eventsMaxListeners.set(fullEventName, Math.max(eventMaxListeners, aliasMaxListeners)); 8056 globalEvents.eventsMaxListeners.delete(alias); 8057 } 8058 }); 8059 } 8060 /** 8061 * Returns true if the target is an instance of Event.EventEmitter 8062 * @param {object} target 8063 * @returns {boolean} 8064 */ 8065 }, { 8066 key: "isEventEmitter", 8067 value: function isEventEmitter(target) { 8068 return Type.isObject(target) && target[isEmitterProperty] === true; 8069 } 8070 /** 8071 * @private 8072 * @param {string} eventName 8073 * @returns {string} 8074 */ 8075 }, { 8076 key: "normalizeEventName", 8077 value: function normalizeEventName(eventName) { 8078 if (!Type.isStringFilled(eventName)) { 8079 return ''; 8080 } 8081 return eventName.toLowerCase(); 8082 } 8083 /** 8084 * @private 8085 */ 8086 }, { 8087 key: "normalizeListener", 8088 value: function normalizeListener(listener) { 8089 if (Type.isString(listener)) { 8090 listener = Reflection.getClass(listener); 8091 } 8092 if (!Type.isFunction(listener)) { 8093 throw new TypeError(`The "listener" argument must be of type Function. Received type ${typeof listener}.`); 8094 } 8095 return listener; 8096 } 8097 /** 8098 * @private 8099 * @param eventName 8100 * @param target 8101 * @param useGlobalNaming 8102 * @returns {string} 8103 */ 8104 }, { 8105 key: "resolveEventName", 8106 value: function resolveEventName(eventName, target, useGlobalNaming = false) { 8107 eventName = this.normalizeEventName(eventName); 8108 if (!Type.isStringFilled(eventName)) { 8109 return ''; 8110 } 8111 if (this.isEventEmitter(target) && useGlobalNaming !== true) { 8112 if (target.getEventNamespace() !== null && eventName.includes('.')) { 8113 console.warn(`Possible the wrong event name "${eventName}".`); 8114 } 8115 eventName = target.getFullEventName(eventName); 8116 } else if (aliasStore.has(eventName)) { 8117 const { 8118 namespace, 8119 eventName: actualEventName 8120 } = aliasStore.get(eventName); 8121 eventName = this.makeFullEventName(namespace, actualEventName); 8122 } 8123 return eventName; 8124 } 8125 /** 8126 * @private 8127 * @param {string} namespace 8128 * @param {string} eventName 8129 * @returns {string} 8130 */ 8131 }, { 8132 key: "makeFullEventName", 8133 value: function makeFullEventName(namespace, eventName) { 8134 const fullName = Type.isStringFilled(namespace) ? `${namespace}:${eventName}` : eventName; 8135 return Type.isStringFilled(fullName) ? fullName.toLowerCase() : ''; 8136 } 8137 }]); 8138 return EventEmitter; 8139 }(); 8140 babelHelpers.defineProperty(EventEmitter, "GLOBAL_TARGET", globalTarget); 8141 babelHelpers.defineProperty(EventEmitter, "DEFAULT_MAX_LISTENERS", eventStore.getDefaultMaxListeners()); 8142 babelHelpers.defineProperty(EventEmitter, "sequenceValue", 1); 8143 8144 let stack = []; 8145 /** 8146 * For compatibility only 8147 * @type {boolean} 8148 */ 8149 // eslint-disable-next-line 8150 exports.isReady = false;
8151 function ready(handler) { 8152 if (!Type.isFunction(handler)) { 8153 return; 8154 } 8155 if (exports.isReady) { 8156 handler(); 8157 } else { 8158 stack.push(handler); 8159 } 8160 } 8161 bindOnce(document, 'DOMContentLoaded', () => { 8162 exports.isReady = true; 8163 stack.forEach(handler => { 8164 handler(); 8165 }); 8166 stack = []; 8167 }); 8168 8169 /** 8170 * @memberOf BX 8171 */ 8172 let Event = function Event() { 8173 babelHelpers.classCallCheck(this, Event); 8174 }; 8175 babelHelpers.defineProperty(Event, "bind", bind); 8176 babelHelpers.defineProperty(Event, "bindOnce", bindOnce); 8177 babelHelpers.defineProperty(Event, "unbind", unbind); 8178 babelHelpers.defineProperty(Event, "unbindAll", unbindAll); 8179 babelHelpers.defineProperty(Event, "ready", ready); 8180 babelHelpers.defineProperty(Event, "EventEmitter", EventEmitter); 8181 babelHelpers.defineProperty(Event, "BaseEvent", BaseEvent); 8182 8183 function encodeAttributeValue(value) { 8184 if (Type.isPlainObject(value) || Type.isArray(value)) { 8185 return JSON.stringify(value); 8186 } 8187 return Text.encode(Text.decode(value)); 8188 } 8189 8190 function decodeAttributeValue(value) { 8191 if (Type.isString(value)) { 8192 const decodedValue = Text.decode(value); 8193 let result; 8194 try { 8195 result = JSON.parse(decodedValue); 8196 } catch (e) { 8197 result = decodedValue; 8198 } 8199 if (result === decodedValue) { 8200 if (/^[\d.]+[.]?\d+$/.test(result)) { 8201 return Number(result); 8202 } 8203 } 8204 if (result === 'true' || result === 'false') { 8205 return Boolean(result); 8206 } 8207 return result; 8208 } 8209 return value; 8210 } 8211 8212 function getPageScroll() { 8213 const { 8214 documentElement, 8215 body 8216 } = document; 8217 const scrollTop = Math.max(window.pageYOffset || 0, documentElement ? documentElement.scrollTop : 0, body ? body.scrollTop : 0); 8218 const scrollLeft = Math.max(window.pageXOffset || 0, documentElement ? documentElement.scrollLeft : 0, body ? body.scrollLeft : 0); 8219 return { 8220 scrollTop, 8221 scrollLeft 8222 }; 8223 } 8224 8225 /* eslint-disable @bitrix24/bitrix24-rules/no-classlist */ 8226 8227 /** 8228 * @memberOf BX 8229 */ 8230 let Dom = /*#__PURE__*/function () { 8231 function Dom() { 8232 babelHelpers.classCallCheck(this, Dom); 8233 } 8234 babelHelpers.createClass(Dom, null, [{ 8235 key: "replace", 8236 /** 8237 * Replaces old html element to new html element 8238 * @param oldElement 8239 * @param newElement 8240 */ 8241 value: function replace(oldElement, newElement) { 8242 if (Type.isDomNode(oldElement) && Type.isDomNode(newElement)) { 8243 if (Type.isDomNode(oldElement.parentNode)) { 8244 oldElement.parentNode.replaceChild(newElement, oldElement); 8245 } 8246 } 8247 } 8248 /** 8249 * Removes element 8250 * @param element 8251 */ 8252 }, { 8253 key: "remove", 8254 value: function remove(element) { 8255 if (Type.isDomNode(element) && Type.isDomNode(element.parentNode)) { 8256 element.parentNode.removeChild(element); 8257 } 8258 } 8259 /** 8260 * Cleans element 8261 * @param element 8262 */ 8263 }, { 8264 key: "clean", 8265 value: function clean(element) { 8266 if (Type.isDomNode(element)) { 8267 while (element.childNodes.length > 0) { 8268 element.removeChild(element.firstChild); 8269 } 8270 return; 8271 } 8272 if (Type.isString(element)) { 8273 Dom.clean(document.getElementById(element)); 8274 } 8275 } 8276 /** 8277 * Inserts element before target element 8278 * @param current 8279 * @param target 8280 */ 8281 }, { 8282 key: "insertBefore", 8283 value: function insertBefore(current, target) { 8284 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8285 if (Type.isDomNode(target.parentNode)) { 8286 target.parentNode.insertBefore(current, target); 8287 } 8288 } 8289 } 8290 /** 8291 * Inserts element after target element 8292 * @param current 8293 * @param target 8294 */ 8295 }, { 8296 key: "insertAfter", 8297 value: function insertAfter(current, target) { 8298 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8299 if (Type.isDomNode(target.parentNode)) { 8300 const parent = target.parentNode; 8301 if (Type.isDomNode(target.nextSibling)) { 8302 parent.insertBefore(current, target.nextSibling); 8303 return; 8304 } 8305 parent.appendChild(current); 8306 } 8307 } 8308 } 8309 /** 8310 * Appends element to target element 8311 * @param current 8312 * @param target 8313 */ 8314 }, { 8315 key: "append", 8316 value: function append(current, target) { 8317 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8318 target.appendChild(current); 8319 } 8320 } 8321 /** 8322 * Prepends element to target element 8323 * @param current 8324 * @param target 8325 */ 8326 }, {
8327 key: "prepend", 8328 value: function prepend(current, target) { 8329 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8330 if (Type.isDomNode(target.firstChild)) { 8331 target.insertBefore(current, target.firstChild); 8332 return; 8333 } 8334 Dom.append(current, target); 8335 } 8336 } 8337 /** 8338 * Checks that element contains class name or class names 8339 * @param element 8340 * @param className 8341 * @return {Boolean} 8342 */ 8343 }, { 8344 key: "hasClass", 8345 value: function hasClass(element, className) { 8346 if (Type.isElementNode(element)) { 8347 if (Type.isString(className)) { 8348 const preparedClassName = className.trim(); 8349 if (preparedClassName.length > 0) { 8350 if (preparedClassName.includes(' ')) { 8351 return preparedClassName.split(' ').every(name => Dom.hasClass(element, name)); 8352 } 8353 if ('classList' in element) { 8354 return element.classList.contains(preparedClassName); 8355 } 8356 if (Type.isObject(element.className) && Type.isString(element.className.baseVal)) { 8357 return element.getAttribute('class').split(' ').some(name => name === preparedClassName); 8358 } 8359 } 8360 } 8361 if (Type.isArray(className) && className.length > 0) { 8362 return className.every(name => Dom.hasClass(element, name)); 8363 } 8364 } 8365 return false; 8366 } 8367 /** 8368 * Adds class name 8369 * @param element 8370 * @param className 8371 */ 8372 }, { 8373 key: "addClass", 8374 value: function addClass(element, className) { 8375 if (Type.isElementNode(element)) { 8376 if (Type.isString(className)) { 8377 const preparedClassName = className.trim(); 8378 if (preparedClassName.length > 0) { 8379 if (preparedClassName.includes(' ')) { 8380 Dom.addClass(element, preparedClassName.split(' ')); 8381 return; 8382 } 8383 if ('classList' in element) { 8384 element.classList.add(preparedClassName); 8385 return; 8386 } 8387 if (Type.isObject(element.className) && Type.isString(element.className.baseVal)) { 8388 if (element.className.baseVal === '') { 8389 element.className.baseVal = preparedClassName; 8390 return; 8391 } 8392 const names = element.className.baseVal.split(' '); 8393 if (!names.includes(preparedClassName)) { 8394 names.push(preparedClassName); 8395 element.className.baseVal = names.join(' ').trim(); 8396 return; 8397 } 8398 } 8399 return; 8400 } 8401 } 8402 if (Type.isArray(className)) { 8403 className.forEach(name => Dom.addClass(element, name)); 8404 } 8405 } 8406 } 8407 /** 8408 * Removes class name 8409 * @param element 8410 * @param className 8411 */ 8412 }, { 8413 key: "removeClass", 8414 value: function removeClass(element, className) { 8415 if (Type.isElementNode(element)) { 8416 if (Type.isString(className)) { 8417 const preparedClassName = className.trim(); 8418 if (preparedClassName.length > 0) { 8419 if (preparedClassName.includes(' ')) { 8420 Dom.removeClass(element, preparedClassName.split(' ')); 8421 return; 8422 } 8423 if ('classList' in element) { 8424 element.classList.remove(preparedClassName); 8425 return; 8426 } 8427 if (Type.isObject(element.className) && Type.isString(element.className.baseVal)) { 8428 const names = element.className.baseVal.split(' ').filter(name => name !== preparedClassName); 8429 element.className.baseVal = names.join(' '); 8430 return; 8431 } 8432 } 8433 } 8434 if (Type.isArray(className)) { 8435 className.forEach(name => Dom.removeClass(element, name)); 8436 } 8437 } 8438 } 8439 /** 8440 * Toggles class name 8441 */ 8442 }, { 8443 key: "toggleClass", 8444 value: function toggleClass(element, className, force) { 8445 if (!Type.isElementNode(element) || !Type.isStringFilled(className) && !Type.isArrayFilled(className)) { 8446 return; 8447 } 8448 [className].flat().flatMap(it => { 8449 var _it$trim; 8450 return it === null || it === void 0 ? void 0 : (_it$trim = it.trim) === null || _it$trim === void 0 ? void 0 : _it$trim.call(it).split(' '); 8451 }
8451).forEach(token => { 8452 if (Type.isStringFilled(token)) { 8453 element.classList.toggle(token, Type.isBoolean(force) ? force : undefined); 8454 } 8455 }); 8456 } 8457 /** 8458 * Styles element 8459 */ 8460 }, { 8461 key: "style", 8462 value: function style(element, prop, value) { 8463 if (Type.isElementNode(element)) { 8464 if (Type.isNull(prop)) { 8465 element.removeAttribute('style'); 8466 return element; 8467 } 8468 if (Type.isPlainObject(prop)) { 8469 Object.entries(prop).forEach(item => { 8470 const [currentKey, currentValue] = item; 8471 Dom.style(element, currentKey, currentValue); 8472 }); 8473 return element; 8474 } 8475 if (Type.isString(prop)) { 8476 if (Type.isUndefined(value) && element.nodeType !== Node.DOCUMENT_NODE) { 8477 const computedStyle = getComputedStyle(element); 8478 if (prop in computedStyle) { 8479 return computedStyle[prop]; 8480 } 8481 return computedStyle.getPropertyValue(prop); 8482 } 8483 if (Type.isNull(value) || value === '' || value === 'null') { 8484 if (String(prop).startsWith('--')) { 8485 // eslint-disable-next-line 8486 element.style.removeProperty(prop); 8487 return element; 8488 } 8489 8490 // eslint-disable-next-line 8491 element.style[prop] = ''; 8492 return element; 8493 } 8494 if (Type.isString(value) || Type.isNumber(value)) { 8495 if (String(prop).startsWith('--')) { 8496 // eslint-disable-next-line 8497 element.style.setProperty(prop, value); 8498 return element; 8499 } 8500 8501 // eslint-disable-next-line 8502 element.style[prop] = value; 8503 return element; 8504 } 8505 } 8506 } 8507 return null; 8508 } 8509 /** 8510 * Adjusts element 8511 * @param target 8512 * @param data 8513 * @return {*} 8514 */ 8515 }, { 8516 key: "adjust", 8517 value: function adjust(target, data = {}) { 8518 if (!target.nodeType) { 8519 return null; 8520 } 8521 let element = target; 8522 if (target.nodeType === Node.DOCUMENT_NODE) { 8523 element = target.body; 8524 } 8525 if (Type.isPlainObject(data)) { 8526 if (Type.isPlainObject(data.attrs)) { 8527 Object.keys(data.attrs).forEach(key => { 8528 if (key === 'class' || key.toLowerCase() === 'classname') { 8529 element.className = data.attrs[key]; 8530 return; 8531 } 8532 8533 // eslint-disable-next-line 8534 if (data.attrs[key] == '') { 8535 element.removeAttribute(key); 8536 return; 8537 } 8538 element.setAttribute(key, data.attrs[key]); 8539 }); 8540 } 8541 if (Type.isPlainObject(data.style)) { 8542 Dom.style(element, data.style); 8543 } 8544 if (Type.isPlainObject(data.props)) { 8545 Object.keys(data.props).forEach(key => { 8546 element[key] = data.props[key]; 8547 }); 8548 } 8549 if (Type.isPlainObject(data.events)) { 8550 Object.keys(data.events).forEach(key => { 8551 Event.bind(element, key, data.events[key]); 8552 }); 8553 } 8554 if (Type.isPlainObject(data.dataset)) { 8555 Object.keys(data.dataset).forEach(key => { 8556 element.dataset[key] = data.dataset[key]; 8557 }); 8558 } 8559 if (Type.isString(data.children)) { 8560 data.children = [data.children]; 8561 } 8562 if (Type.isArray(data.children) && data.children.length > 0) { 8563 data.children.forEach(item => { 8564 if (Type.isDomNode(item)) { 8565 Dom.append(item, element); 8566 } 8567 if (Type.isString(item)) { 8568 element.insertAdjacentHTML('beforeend', item); 8569 } 8570 }); 8571 return element; 8572 } 8573 if ('text' in data && !Type.isNil(data.text)) { 8574 element.textContent = data.text; 8575 return element; 8576 } 8577 if ('html' in data && !Type.isNil(data.html)) { 8578 element.innerHTML = data.html; 8579 } 8580 } 8581 return element; 8582 } 8583 /** 8584 * Creates element 8585 * @param tag 8586 * @param data 8587 * @param context 8588 * @return {HTMLElement|HTMLBodyElement} 8589 */ 8590 }, { 8591 key: "create", 8592 value: function create(tag, data = {}, context = document) { 8593 let tagName = tag; 8594 let options = data; 8595 if (Type.isObjectLike(tag)) { 8596 options = tag; 8597 tagName = tag.tag; 8598 } 8599 return Dom.adjust(context.createElement(tagName), options); 8600 } 8601 /** 8602 * Shows element 8603 * @param element 8604 */ 8605 }, { 8606 key: "show", 8607 value: function show(element) { 8608 if (Type.isDomNode(element)) { 8609 // eslint-disable-next-line 8610 element.hidden = false;
8611 } 8612 } 8613 /** 8614 * Hides element 8615 * @param element 8616 */ 8617 }, { 8618 key: "hide", 8619 value: function hide(element) { 8620 if (Type.isDomNode(element)) { 8621 // eslint-disable-next-line 8622 element.hidden = true; 8623 } 8624 } 8625 /** 8626 * Checks that element is shown 8627 * @param element 8628 * @return {*|boolean} 8629 */ 8630 }, { 8631 key: "isShown", 8632 value: function isShown(element) { 8633 return Type.isDomNode(element) && !element.hidden && element.style.getPropertyValue('display') !== 'none'; 8634 } 8635 /** 8636 * Checks if element is shown with recursive check of its ancestors 8637 */ 8638 }, { 8639 key: "isShownRecursive", 8640 value: function isShownRecursive(element) { 8641 if (!Type.isDomNode(element)) { 8642 return false; 8643 } 8644 if (element === document.body) { 8645 return Dom.isShown(element); 8646 } 8647 return Dom.isShown(element) && Dom.isShownRecursive(element.parentElement); 8648 } 8649 /** 8650 * Toggles element visibility 8651 * @param element 8652 */ 8653 }, { 8654 key: "toggle", 8655 value: function toggle(element) { 8656 if (Type.isDomNode(element)) { 8657 if (Dom.isShown(element)) { 8658 Dom.hide(element); 8659 } else { 8660 Dom.show(element); 8661 } 8662 } 8663 } 8664 /** 8665 * Gets element position relative page 8666 * @param {HTMLElement} element 8667 * @return {DOMRect} 8668 */ 8669 }, { 8670 key: "getPosition", 8671 value: function getPosition(element) { 8672 if (Type.isDomNode(element)) { 8673 const elementRect = element.getBoundingClientRect(); 8674 const { 8675 scrollLeft, 8676 scrollTop 8677 } = getPageScroll(); 8678 return new DOMRect(elementRect.left + scrollLeft, elementRect.top + scrollTop, elementRect.width, elementRect.height); 8679 } 8680 return new DOMRect(); 8681 } 8682 /** 8683 * Gets element position relative specified element position 8684 * @param {HTMLElement} element 8685 * @param {HTMLElement} relationElement 8686 * @return {DOMRect} 8687 */ 8688 }, { 8689 key: "getRelativePosition", 8690 value: function getRelativePosition(element, relationElement) { 8691 if (Type.isDomNode(element) && Type.isDomNode(relationElement)) { 8692 const elementPosition = Dom.getPosition(element); 8693 const relationElementPosition = Dom.getPosition(relationElement); 8694 return new DOMRect(elementPosition.left - relationElementPosition.left, elementPosition.top - relationElementPosition.top, elementPosition.width, elementPosition.height); 8695 } 8696 return new DOMRect(); 8697 } 8698 }, { 8699 key: "attr", 8700 value: function attr(element, _attr, value) { 8701 if (Type.isElementNode(element)) { 8702 if (Type.isString(_attr)) { 8703 if (!Type.isNil(value)) { 8704 if (Type.isObjectLike(value)) { 8705 element.setAttribute(_attr, encodeAttributeValue(value)); 8706 } else { 8707 element.setAttribute(_attr, value); 8708 } 8709 } else if (Type.isNull(value)) { 8710 element.removeAttribute(_attr); 8711 } else { 8712 return decodeAttributeValue(element.getAttribute(_attr)); 8713 } 8714 } 8715 if (Type.isPlainObject(_attr)) { 8716 Object.entries(_attr).forEach(([attrKey, attrValue]) => { 8717 Dom.attr(element, attrKey, attrValue); 8718 }); 8719 } 8720 } 8721 return null; 8722 } 8723 }]); 8724 return Dom; 8725 }(); 8726 8727 const UA = navigator.userAgent.toLowerCase(); 8728 8729 /** 8730 * @memberOf BX 8731 */ 8732 let Browser = /*#__PURE__*/function () { 8733 function Browser() { 8734 babelHelpers.classCallCheck(this, Browser); 8735 } 8736 babelHelpers.createClass(Browser, null, [{ 8737 key: "isOpera", 8738 value: function isOpera() { 8739 return UA.includes('opera'); 8740 } 8741 }, { 8742 key: "isIE", 8743 value: function isIE() { 8744 return 'attachEvent' in document && !Browser.isOpera(); 8745 } 8746 }, { 8747 key: "isIE6", 8748 value: function isIE6() { 8749 return UA.includes('msie 6'); 8750 } 8751 }, { 8752 key: "isIE7", 8753 value: function isIE7() { 8754 return UA.includes('msie 7'); 8755 } 8756 }, { 8757 key: "isIE8", 8758 value: function isIE8() { 8759 return UA.includes('msie 8'); 8760 } 8761 }, { 8762 key: "isIE9", 8763 value: function isIE9() { 8764 return 'documentMode' in document && document.documentMode >= 9; 8765 } 8766 }, { 8767 key: "isIE10", 8768 value: function isIE10() { 8769 return 'documentMode' in document && document.documentMode >= 10; 8770 } 8771 }, { 8772 key: "isSafari", 8773 value: function isSafari() { 8774 return UA.includes('safari') && !UA.includes('chrome'); 8775 } 8776 }, { 8777 key: "isFirefox", 8778 value: function isFirefox() { 8779 return UA.includes('firefox'); 8780 } 8781 }, { 8782 key: "isChrome", 8783 value: function isChrome() { 8784 return UA.includes('chrome'); 8785 } 8786 }, { 8787 key: "detectIEVersion", 8788 value: function detectIEVersion() { 8789 if (Browser.isOpera() || Browser.isSafari() || Browser.isFirefox() || Browser.isChrome()) { 8790 return -1; 8791 } 8792 let rv = -1; 8793 if (!!window.MSStream && !window.ActiveXObject && 'ActiveXObject' in window) { 8794 rv = 11; 8795 } else if (Browser.isIE10()) { 8796 rv = 10; 8797 } else if (Browser.isIE9()) { 8798 rv = 9; 8799 } else if (Browser.isIE()) { 8800 rv = 8; 8801 } 8802 if (rv === -1 || rv === 8) { 8803 if (navigator.appName === 'Microsoft Internet Explorer') { 8804 const re = new RegExp('MSIE ([0-9]+[.0-9]*)'); 8805 const res = navigator.userAgent.match(re); 8806 if (Type.isArrayLike(res) && res.length > 0) { 8807 rv = parseFloat(res[1]); 8808 } 8809 } 8810 if (navigator.appName === 'Netscape') { 8811 // Alternative check for IE 11 8812 rv = 11; 8813 const re = new RegExp('Trident/.*rv:([0-9]+[.0-9]*)'); 8814 if (re.exec(navigator.userAgent) != null) { 8815 const res = navigator.userAgent.match(re); 8816 if (Type.isArrayLike(res) && res.length > 0) { 8817 rv = parseFloat(res[1]); 8818 } 8819 } 8820 } 8821 } 8822 return rv; 8823 } 8824 }, { 8825 key: "isIE11", 8826 value: function isIE11() { 8827 return Browser.detectIEVersion() >= 11; 8828 } 8829 }, { 8830 key: "isMac", 8831 value: function isMac() { 8832 return UA.includes('macintosh'); 8833 } 8834 }, { 8835 key: "isWin", 8836 value: function isWin() { 8837 return UA.includes('windows'); 8838 } 8839 }, { 8840 key: "isLinux", 8841 value: function isLinux() { 8842 return UA.includes('linux') && !Browser.isAndroid(); 8843 } 8844 }, { 8845 key: "isAndroid", 8846 value: function isAndroid() { 8847 return UA.includes('android'); 8848 } 8849 }, { 8850 key: "isIPad", 8851 value: function isIPad() { 8852 return UA.includes('ipad;') || this.isMac() && this.isTouchDevice(); 8853 } 8854 }, { 8855 key: "isIPhone", 8856 value: function isIPhone() { 8857 return UA.includes('iphone;'); 8858 } 8859 }, { 8860 key: "isIOS", 8861 value: function isIOS() { 8862 return Browser.isIPad() || Browser.isIPhone(); 8863 } 8864 }, { 8865 key: "isMobile", 8866 value: function isMobile() { 8867 return Browser.isIPhone() || Browser.isIPad() || Browser.isAndroid() || UA.includes('mobile') || UA.includes('touch'); 8868 } 8869 }, { 8870 key: "isRetina", 8871 value: function isRetina() { 8872 return window.devicePixelRatio && window.devicePixelRatio >= 2; 8873 } 8874 }, { 8875 key: "isTouchDevice", 8876 value: function isTouchDevice() { 8877 return 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0; 8878 } 8879 }, { 8880 key: "isDoctype", 8881 value: function isDoctype(target) { 8882 const doc = target || document; 8883 if (doc.compatMode) { 8884 return doc.compatMode === 'CSS1Compat'; 8885 } 8886 return doc.documentElement && doc.documentElement.clientHeight; 8887 } 8888 }, { 8889 key: "isLocalStorageSupported", 8890 value: function isLocalStorageSupported() { 8891 try { 8892 localStorage.setItem('test', 'test'); 8893 localStorage.removeItem('test'); 8894 return true; 8895 } catch (e) { 8896 return false;
8897 } 8898 } 8899 }, { 8900 key: "addGlobalClass", 8901 value: function addGlobalClass(target) { 8902 let globalClass = 'bx-core'; 8903 target = Type.isElementNode(target) ? target : document.documentElement; 8904 if (Dom.hasClass(target, globalClass)) { 8905 return; 8906 } 8907 if (Browser.isIOS()) { 8908 globalClass += ' bx-ios'; 8909 } else if (Browser.isWin()) { 8910 globalClass += ' bx-win'; 8911 } else if (Browser.isMac()) { 8912 globalClass += ' bx-mac'; 8913 } else if (Browser.isLinux()) { 8914 globalClass += ' bx-linux'; 8915 } else if (Browser.isAndroid()) { 8916 globalClass += ' bx-android'; 8917 } 8918 globalClass += Browser.isMobile() ? ' bx-touch' : ' bx-no-touch'; 8919 globalClass += Browser.isRetina() ? ' bx-retina' : ' bx-no-retina'; 8920 if (Browser.isSafari()) { 8921 globalClass += ' bx-safari'; 8922 } else if (/AppleWebKit/.test(navigator.userAgent)) { 8923 globalClass += ' bx-chrome'; 8924 } else if (/Opera/.test(navigator.userAgent)) { 8925 globalClass += ' bx-opera'; 8926 } else if (Browser.isFirefox()) { 8927 globalClass += ' bx-firefox'; 8928 } 8929 Dom.addClass(target, globalClass); 8930 } 8931 }, { 8932 key: "detectAndroidVersion", 8933 value: function detectAndroidVersion() { 8934 const re = new RegExp('Android ([0-9]+[.0-9]*)'); 8935 if (re.exec(navigator.userAgent) != null) { 8936 const res = navigator.userAgent.match(re); 8937 if (Type.isArrayLike(res) && res.length > 0) { 8938 return parseFloat(res[1]); 8939 } 8940 } 8941 return 0; 8942 } 8943 }, { 8944 key: "isPropertySupported", 8945 value: function isPropertySupported(jsProperty, returnCSSName) { 8946 if (jsProperty === '') { 8947 return false; 8948 } 8949 function getCssName(propertyName) { 8950 return propertyName.replace(/([A-Z])/g, (...args) => `-${args[1].toLowerCase()}`); 8951 } 8952 function getJsName(cssName) { 8953 const reg = /(\\-([a-z]))/g; 8954 if (reg.test(cssName)) { 8955 return cssName.replace(reg, (...args) => args[2].toUpperCase()); 8956 } 8957 return cssName; 8958 } 8959 const property = jsProperty.includes('-') ? getJsName(jsProperty) : jsProperty; 8960 const bReturnCSSName = !!returnCSSName; 8961 const ucProperty = property.charAt(0).toUpperCase() + property.slice(1); 8962 const props = ['Webkit', 'Moz', 'O', 'ms'].join(`${ucProperty} `); 8963 const properties = `${property} ${props} ${ucProperty}`.split(' '); 8964 const obj = document.body || document.documentElement; 8965 for (let i = 0; i < properties.length; i += 1) { 8966 const prop = properties[i]; 8967 if (obj && 'style' in obj && prop in obj.style) { 8968 const lowerProp = prop.substr(0, prop.length - property.length).toLowerCase(); 8969 const prefix = prop === property ? '' : `-${lowerProp}-`; 8970 return bReturnCSSName ? prefix + getCssName(property) : prop; 8971 } 8972 } 8973 return false; 8974 } 8975 }, { 8976 key: "addGlobalFeatures", 8977 value: function addGlobalFeatures(features) { 8978 if (!Type.isArray(features)) { 8979 return; 8980 } 8981 const classNames = []; 8982 for (let i = 0; i < features.length; i += 1) { 8983 const support = !!Browser.isPropertySupported(features[i]); 8984 classNames.push(`bx-${support ? '' : 'no-'}${features[i].toLowerCase()}`); 8985 } 8986 Dom.addClass(document.documentElement, classNames.join(' ')); 8987 } 8988 }]); 8989 return Browser; 8990 }(); 8991 8992 let Cookie = /*#__PURE__*/function () { 8993 function Cookie() { 8994 babelHelpers.classCallCheck(this, Cookie); 8995 } 8996 babelHelpers.createClass(Cookie, null, [{ 8997 key: "getList", 8998 /** 8999 * Gets cookies list for current domain 9000 * @return {object} 9001 */ 9002 value: function getList() { 9003 return document.cookie.split(';').map(item => item.split('=')).map(item => item.map(subItem => subItem.trim())).reduce((acc, item) => { 9004 const [key, value] = item; 9005 acc[decodeURIComponent(key)] = decodeURIComponent(value); 9006 return acc; 9007 }, {}); 9008 } 9009 /** 9010 * Gets cookie value 9011 * @param {string} name 9012 * @return {*} 9013 */ 9014 }, { 9015 key: "get", 9016 value: function get(name) { 9017 const cookiesList = Cookie.getList(); 9018 if (name in cookiesList) { 9019 return cookiesList[name]; 9020 } 9021 return undefined; 9022 } 9023 /** 9024 * Sets cookie 9025 * @param {string} name 9026 * @param {*} value 9027 * @param {object} [options] 9028 */ 9029 }, { 9030 key: "set", 9031 value: function set(name, value, options = {}) { 9032 const attributes = { 9033 expires: '', 9034 ...options 9035 }; 9036 if (Type.isNumber(attributes.expires)) { 9037 const now = +new Date(); 9038 const days = attributes.expires; 9039 const dayInMs = 864e+5; 9040 attributes.expires = new Date(now + days * dayInMs); 9041 } 9042 if (Type.isDate(attributes.expires)) { 9043 attributes.expires = attributes.expires.toUTCString(); 9044 } 9045 const safeName = decodeURIComponent(String(name)).replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape); 9046 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); 9047 const stringifiedAttributes = Object.keys(attributes).reduce((acc, key) => { 9048 const attributeValue = attributes[key]; 9049 if (!attributeValue) { 9050 return acc; 9051 } 9052 if (attributeValue === true) { 9053 return `${acc}; ${key}`; 9054 } 9055 9056 /** 9057 * Considers RFC 6265 section 5.2: 9058 * ... 9059 * 3. If the remaining unparsed-attributes contains a %x3B (';') 9060 * character: 9061 * Consume the characters of the unparsed-attributes up to, 9062 * not including, the first %x3B (';') character. 9063 */ 9064 return `${acc}; ${key}=${attributeValue.split(';')[0]}`; 9065 }, ''); 9066 document.cookie = `${safeName}=${safeValue}${stringifiedAttributes}`; 9067 } 9068 /** 9069 * Removes cookie 9070 * @param {string} name 9071 * @param {object} [options] 9072 */ 9073 }, { 9074 key: "remove", 9075 value: function remove(name, options = {}) { 9076 Cookie.set(name, '', { 9077 ...options, 9078 expires: -1 9079 }); 9080 } 9081 }]); 9082 return Cookie; 9083 }(); 9084 9085 function objectToFormData(source, formData = new FormData(), pre = null) { 9086 if (Type.isUndefined(source)) { 9087 return formData; 9088 } 9089 if (Type.isNull(source)) { 9090 formData.append(pre, ''); 9091 } else if (Type.isArray(source)) { 9092 if (!source.length) {
9093 const key = `${pre}[]`; 9094 formData.append(key, ''); 9095 } else { 9096 source.forEach((value, index) => { 9097 const key = `${pre}[${index}]`; 9098 objectToFormData(value, formData, key); 9099 }); 9100 } 9101 } else if (Type.isDate(source)) { 9102 formData.append(pre, source.toISOString()); 9103 } else if (Type.isObject(source) && !Type.isFile(source) && !Type.isBlob(source)) { 9104 Object.keys(source).forEach(property => { 9105 const value = source[property]; 9106 let preparedProperty = property; 9107 if (Type.isArray(value)) { 9108 while (preparedProperty.length > 2 && preparedProperty.lastIndexOf('[]') === preparedProperty.length - 2) { 9109 preparedProperty = preparedProperty.substring(0, preparedProperty.length - 2); 9110 } 9111 } 9112 const key = pre ? `${pre}[${preparedProperty}]` : preparedProperty; 9113 objectToFormData(value, formData, key); 9114 }); 9115 } else { 9116 formData.append(pre, source); 9117 } 9118 return formData; 9119 } 9120 9121 let Data = /*#__PURE__*/function () { 9122 function Data() { 9123 babelHelpers.classCallCheck(this, Data); 9124 } 9125 babelHelpers.createClass(Data, null, [{ 9126 key: "convertObjectToFormData", 9127 /** 9128 * Converts object to FormData 9129 * @param source 9130 * @return {FormData} 9131 */ 9132 value: function convertObjectToFormData(source) { 9133 return objectToFormData(source); 9134 } 9135 }]); 9136 return Data; 9137 }(); 9138 9139 /** 9140 * @memberOf BX 9141 */ 9142 let Http = function Http() { 9143 babelHelpers.classCallCheck(this, Http); 9144 }; 9145 babelHelpers.defineProperty(Http, "Cookie", Cookie); 9146 babelHelpers.defineProperty(Http, "Data", Data); 9147 9148 function message(value) { 9149 if (Type.isString(value)) { 9150 if (Type.isNil(message[value])) { 9151 // eslint-disable-next-line 9152 EventEmitter.emit('onBXMessageNotFound', new BaseEvent({ 9153 compatData: [value] 9154 })); 9155 if (Type.isNil(message[value])) { 9156 Runtime.debug(`message undefined: ${value}`); 9157 message[value] = ''; 9158 } 9159 } 9160 } 9161 if (Type.isPlainObject(value)) { 9162 Object.keys(value).forEach(key => { 9163 message[key] = value[key]; 9164 }); 9165 } 9166 return message[value]; 9167 } 9168 if (!Type.isNil(window.BX) && Type.isFunction(window.BX.message)) { 9169 Object.keys(window.BX.message).forEach(key => { 9170 message({ 9171 [key]: window.BX.message[key] 9172 }); 9173 }); 9174 } 9175 9176 /** 9177 * Implements interface for works with language messages 9178 * @memberOf BX 9179 */ 9180 let Loc = /*#__PURE__*/function () { 9181 function Loc() { 9182 babelHelpers.classCallCheck(this, Loc); 9183 } 9184 babelHelpers.createClass(Loc, null, [{ 9185 key: "getMessage", 9186 /** 9187 * Gets message by id 9188 * @param {string} messageId 9189 * @param {object} replacements 9190 * @return {?string} 9191 */ 9192 value: function getMessage(messageId, replacements = null) { 9193 let mess = message(messageId); 9194 if (Type.isString(mess) && Type.isPlainObject(replacements)) { 9195 const escape = str => String(str).replace(/[\\^$*+?.()|[\]{}]/g, '\\$&'); 9196 Object.keys(replacements).forEach(replacement => { 9197 const globalRegexp = new RegExp(escape(replacement), 'gi'); 9198 mess = mess.replace(globalRegexp, () => { 9199 return Type.isNil(replacements[replacement]) ? '' : String(replacements[replacement]); 9200 }); 9201 }); 9202 } 9203 return mess; 9204 } 9205 }, { 9206 key: "hasMessage", 9207 value: function hasMessage(messageId) { 9208 return Type.isString(messageId) && !Type.isNil(message[messageId]); 9209 } 9210 /** 9211 * Sets message or messages 9212 * @param {string | Object<string, string>} id 9213 * @param {string} [value] 9214 */ 9215 }, { 9216 key: "setMessage", 9217 value: function setMessage(id, value) { 9218 if (Type.isString(id) && Type.isString(value)) { 9219 message({ 9220 [id]: value 9221 }); 9222 } 9223 if (Type.isObject(id)) { 9224 message(id); 9225 } 9226 } 9227 /** 9228 * Gets plural message by id and number 9229 * @param {string} messageId 9230 * @param {number} value 9231 * @param {object} [replacements] 9232 * @return {?string} 9233 */ 9234 }, { 9235 key: "getMessagePlural",
9236 value: function getMessagePlural(messageId, value, replacements = null) { 9237 let result = ''; 9238 if (Type.isNumber(value)) { 9239 if (this.hasMessage(`${messageId}_PLURAL_${this.getPluralForm(value)}`)) { 9240 result = this.getMessage(`${messageId}_PLURAL_${this.getPluralForm(value)}`, replacements); 9241 } else { 9242 result = this.getMessage(`${messageId}_PLURAL_1`, replacements); 9243 } 9244 } else { 9245 result = this.getMessage(messageId, replacements); 9246 } 9247 return result; 9248 } 9249 /** 9250 * Gets language plural form id by number 9251 * see http://docs.translatehouse.org/projects/localization-guide/en/latest/l10n/pluralforms.html 9252 * @param {number} value 9253 * @param {string} [languageId] 9254 * @return {?number} 9255 */ 9256 }, { 9257 key: "getPluralForm", 9258 value: function getPluralForm(value, languageId) { 9259 let pluralForm; 9260 if (!Type.isStringFilled(languageId)) { 9261 languageId = message('LANGUAGE_ID'); 9262 } 9263 if (value < 0) { 9264 value = -1 * value; 9265 } 9266 switch (languageId) { 9267 case 'ar': 9268 pluralForm = value !== 1 ? 1 : 0; 9269 /* 9270 if (value === 0) 9271 { 9272 pluralForm = 0; 9273 } 9274 else if (value === 1) 9275 { 9276 pluralForm = 1; 9277 } 9278 else if (value === 2) 9279 { 9280 pluralForm = 2; 9281 } 9282 else if ( 9283 value % 100 >= 3 9284 && value % 100 <= 10 9285 ) 9286 { 9287 pluralForm = 3; 9288 } 9289 else if (value % 100 >= 11) 9290 { 9291 pluralForm = 4; 9292 } 9293 else 9294 { 9295 pluralForm = 5; 9296 } 9297 */ 9298 break; 9299 case 'br': 9300 case 'fr': 9301 case 'tr': 9302 pluralForm = value > 1 ? 1 : 0; 9303 break; 9304 case 'de': 9305 case 'en': 9306 case 'hi': 9307 case 'it': 9308 case 'la': 9309 pluralForm = value !== 1 ? 1 : 0; 9310 break; 9311 case 'ru': 9312 case 'ua': 9313 if (value % 10 === 1 && value % 100 !== 11) { 9314 pluralForm = 0; 9315 } else if (value % 10 >= 2 && value % 10 <= 4 && (value % 100 < 10 || value % 100 >= 20)) { 9316 pluralForm = 1; 9317 } else { 9318 pluralForm = 2; 9319 } 9320 break; 9321 case 'pl': 9322 if (value === 1) { 9323 pluralForm = 0; 9324 } else if (value % 10 >= 2 && value % 10 <= 4 && (value % 100 < 10 || value % 100 >= 20)) { 9325 pluralForm = 1; 9326 } else { 9327 pluralForm = 2; 9328 } 9329 break; 9330 case 'id': 9331 case 'ja': 9332 case 'ms': 9333 case 'sc': 9334 case 'tc': 9335 case 'th': 9336 case 'vn': 9337 pluralForm = 0; 9338 break; 9339 default: 9340 pluralForm = 1; 9341 break; 9342 } 9343 return pluralForm; 9344 } 9345 }]); 9346 return Loc; 9347 }(); 9348 9349 const voidElements = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr']; 9350 function isVoidElement(element) { 9351 return voidElements.includes(element); 9352 } 9353 9354 const matchers = { 9355 tag: /<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>|{{uid[0-9]+}}/g, 9356 comment: /<!--(?!<!)[^\[>].*?-->/g, 9357 tagName: /<\/?([^\s]+?)[/\s>]/, 9358 attributes: /\s([\w\-_:.]+)\s?\n?=\s?\n?"([^"]+)?"|\s([\w\-_:.]+)\s?\n?=\s?\n?'([^']+)?'|\s([\w\-_:.]+)/gs, 9359 placeholder: /{{uid[0-9]+}}/g 9360 }; 9361 9362 function parseTag(tag) { 9363 const tagResult = { 9364 type: 'tag', 9365 name: '', 9366 svg: false, 9367 attrs: {}, 9368 children: [], 9369 voidElement: false 9370 }; 9371 if (tag.startsWith('<!--')) { 9372 const endIndex = tag.indexOf('-->'); 9373 const openTagLength = '<!--'.length; 9374 return { 9375 type: 'comment', 9376 content: endIndex !== -1 ? tag.slice(openTagLength, endIndex) : '' 9377 }; 9378 } 9379 const tagNameMatch = tag.match(matchers.tagName); 9380 if (Type.isArrayFilled(tagNameMatch)) { 9381 const [, tagName] = tagNameMatch; 9382 tagResult.name = tagName; 9383 tagResult.svg = tagName === 'svg'; 9384 tagResult.voidElement = isVoidElement(tagName) || tag.trim().endsWith('/>'); 9385 } 9386 const reg = new RegExp(matchers.attributes); 9387 for (;;) { 9388 const result = reg.exec(tag); 9389 if (!Type.isNil(result)) { 9390 // Attributes with double quotes 9391 const [, attrName, attrValue] = result; 9392 if (!Type.isNil(attrName)) { 9393 tagResult.attrs[attrName] = Type.isStringFilled(attrValue) ? attrValue : ''; 9394 } else { 9395 // Attributes with single quotes 9396 const [,,, attrName, attrValue] = result; 9397 if (!Type.isNil(attrName)) { 9398 tagResult.attrs[attrName] = Type.isStringFilled(attrValue) ? attrValue : ''; 9399 } else { 9400 // Attributes without value 9401 const [,,,,, attrName] = result; 9402 tagResult.attrs[attrName] = ''; 9403 } 9404 } 9405 } else { 9406 break; 9407 } 9408 } 9409 return tagResult; 9410 } 9411 9412 function parseText(input) { 9413 const preparedText = input.replace(/[\n\r\t]$/, ''); 9414 const placeholders = preparedText.match(matchers.placeholder); 9415 return preparedText.split(matchers.placeholder).reduce((acc, item, index) => { 9416 if (Type.isStringFilled(item)) { 9417 acc.push(...item.split(/\n/).reduce((textAcc, text) => { 9418 const preparedItemText = text.replace(/[\t\r]/g, ''); 9419 if (Type.isStringFilled(preparedItemText)) { 9420 textAcc.push({ 9421 type: 'text', 9422 content: preparedItemText 9423 }); 9424 } 9425 return textAcc; 9426 }, [])); 9427 } 9428 if (placeholders && placeholders[index]) { 9429 acc.push({ 9430 type: 'placeholder', 9431 uid: parseInt(placeholders[index].replace(/{{uid|}}/, '')) 9432 }); 9433 } 9434 return acc; 9435 }, []); 9436 } 9437 9438 function parse(html, substitutions) { 9439 const result = []; 9440 if (html.indexOf('<') !== 0 && !html.startsWith('{{')) { 9441 const end = html.indexOf('<'); 9442 result.push(...parseText(end === -1 ? html : html.slice(0, end))); 9443 } 9444 const commentsContent = []; 9445 let commentIndex = -1; 9446 html = html.replace(matchers.comment, tag => { 9447 commentIndex += 1; 9448 commentsContent.push(tag.replace(/^<!--|-->$/g, '')); 9449 return `<!--{{cUid${commentIndex}}}-->`; 9450 }); 9451 const arr = []; 9452 let level = -1; 9453 let current; 9454 html.replace(matchers.tag, (tag, index) => { 9455 const start = index + tag.length; 9456 const nextChar = html.charAt(start); 9457 let parent; 9458 if (tag.startsWith('<!--')) { 9459 const comment = parseTag(tag, substitutions); 9460 comment.content = commentsContent[tag.replace(/<!--{{cUid|}}-->/g, '')]; 9461 if (level < 0) { 9462 result.push(comment); 9463 return result; 9464 } 9465 parent = arr[level]; 9466 parent.children.push(comment); 9467 return result; 9468 } 9469 if (tag.startsWith('{{')) { 9470 const [placeholder] = parseText(tag); 9471 if (level < 0) { 9472 result.push(placeholder); 9473 return result; 9474 } 9475 parent = arr[level]; 9476 parent.children.push(placeholder); 9477 return result; 9478 } 9479 if (!tag.startsWith('</')) { 9480 level++; 9481 current = parseTag(tag, substitutions); 9482 if (!current.voidElement && nextChar && nextChar !== '<') { 9483 current.children.push(...parseText(html.slice(start, html.indexOf('<', start)))); 9484 } 9485 if (level === 0) { 9486 result.push(current); 9487 } 9488 parent = arr[level - 1]; 9489 if (parent) { 9490 if (!current.svg) { 9491 current.svg = parent.svg; 9492 } 9493 parent.children.push(current); 9494 } 9495 arr[level] = current; 9496 } 9497 if (tag.startsWith('</') || current.voidElement) { 9498 if (level > -1 && (current.voidElement || current.name === tag.slice(2, -1))) { 9499 level--; 9500 current = level === -1 ? result : arr[level]; 9501 } 9502 if (nextChar && nextChar !== '<') { 9503 parent = level === -1 ? result : arr[level].children; 9504 const end = html.indexOf('<', start); 9505 const content = html.slice(start, end === -1 ? undefined : end); 9506 if (end >
9506 -1 && level + parent.length >= 0 || content !== ' ') { 9507 parent.push(...parseText(content)); 9508 } 9509 } 9510 } 9511 }); 9512 return result; 9513 } 9514 9515 const appendElement = (current, target) => { 9516 if (Type.isDomNode(current) && Type.isDomNode(target)) { 9517 if (target.nodeName !== 'TEMPLATE') { 9518 Dom.append(current, target); 9519 } else { 9520 // eslint-disable-next-line bitrix-rules/no-native-dom-methods 9521 target.content.append(current); 9522 } 9523 } 9524 }; 9525 function renderNode(options) { 9526 const { 9527 node, 9528 parentElement, 9529 substitutions, 9530 refs = [] 9531 } = options; 9532 if (node.type === 'tag') { 9533 const element = (() => { 9534 if (node.svg) { 9535 return document.createElementNS('http://www.w3.org/2000/svg', node.name); 9536 } 9537 return document.createElement(node.name); 9538 })(); 9539 if (Object.hasOwn(node.attrs, 'ref')) { 9540 refs.push([node.attrs.ref, element]); 9541 delete node.attrs.ref; 9542 } 9543 Object.entries(node.attrs).forEach(([key, value]) => { 9544 if (key.startsWith('on') && new RegExp(matchers.placeholder).test(value)) { 9545 const substitution = substitutions[parseInt(value.replace(/{{uid|}}/, '')) - 1]; 9546 if (Type.isFunction(substitution)) { 9547 const bindFunctionName = key.endsWith('once') ? 'bindOnce' : 'bind'; 9548 Event[bindFunctionName](element, key.replace(/^on|once$/g, ''), substitution); 9549 } else { 9550 element.setAttribute(key, substitution); 9551 } 9552 } else { 9553 if (new RegExp(matchers.placeholder).test(value)) { 9554 const preparedValue = value.split(/{{|}}/).reduce((acc, item) => { 9555 if (item.startsWith('uid')) { 9556 const substitution = substitutions[parseInt(item.replace('uid', '')) - 1]; 9557 return `${acc}${substitution}`; 9558 } 9559 return `${acc}${item}`; 9560 }, ''); 9561 element.setAttribute(key, preparedValue); 9562 } else { 9563 element.setAttribute(key, Text.decode(value)); 9564 } 9565 } 9566 }); 9567 node.children.forEach(childNode => { 9568 const result = renderNode({ 9569 node: childNode, 9570 parentElement: element, 9571 substitutions, 9572 refs 9573 }); 9574 if (Type.isArray(result)) { 9575 result.forEach(subChildElement => { 9576 appendElement(subChildElement, element); 9577 }); 9578 } else { 9579 appendElement(result, element); 9580 } 9581 }); 9582 return element; 9583 } 9584 if (node.type === 'comment') { 9585 return document.createComment(node.content); 9586 } 9587 if (node.type === 'text') { 9588 if (parentElement) { 9589 if (parentElement.nodeName !== 'TEMPLATE') { 9590 parentElement.insertAdjacentHTML('beforeend', node.content); 9591 } else { 9592 parentElement.content.append(node.content); 9593 } 9594 return; 9595 } 9596 return document.createTextNode(node.content); 9597 } 9598 if (node.type === 'placeholder') { 9599 return substitutions[node.uid - 1]; 9600 } 9601 } 9602 9603 function render(sections, ...substitutions) { 9604 const html = sections.reduce((acc, item, index) => { 9605 if (index > 0) { 9606 const substitution = substitutions[index - 1]; 9607 if (Type.isString(substitution) || Type.isNumber(substitution)) { 9608 return `${acc}${substitution}${item}`; 9609 } 9610 return `${acc}{{uid${index}}}${item}`; 9611 } 9612 return acc; 9613 }, sections[0]).replace(/^[\r\n\t\s]+/gm, '').replace(/>[\n]+/g, '>').replace(/[}][\n]+/g, '}'); 9614 const ast = parse(html); 9615 if (ast.length === 1) { 9616 const refs = []; 9617 const renderedNode = renderNode({ 9618 node: ast[0], 9619 substitutions, 9620 refs 9621 }); 9622 if (Type.isArrayFilled(refs)) { 9623 return Object.fromEntries([['root', renderedNode], ...refs]); 9624 } 9625 return renderedNode; 9626 } 9627 if (ast.length > 1) { 9628 const refs = []; 9629 const renderedNodes = ast.map(node => { 9630 return renderNode({ 9631 node, 9632 substitutions, 9633 refs 9634 }); 9635 }); 9636 if (Type.isArrayFilled(refs)) { 9637 return Object.fromEntries([['root', renderedNodes], ...refs]); 9638 } 9639 return renderedNodes; 9640 } 9641 return false;
9642 } 9643 9644 function parseProps(sections, ...substitutions) { 9645 return substitutions.reduce((acc, item, index) => { 9646 const nextSectionIndex = index + 1; 9647 if (!Type.isPlainObject(item) && !Type.isArray(item)) { 9648 return acc + item + sections[nextSectionIndex]; 9649 } 9650 return `${acc}__s${index}${sections[nextSectionIndex]}`; 9651 }, sections[0]).replace(/[\r\t]/gm, '').split(';\n').map(item => item.replace(/\n/, '')).reduce((acc, item) => { 9652 if (item !== '') { 9653 const matches = item.match(/^[\w-. ]+:/); 9654 const splitted = item.split(/^[\w-. ]+:/); 9655 const key = matches[0].replace(':', '').trim(); 9656 const value = splitted[1].trim(); 9657 const substitutionPlaceholderExp = /^__s\d+/; 9658 if (substitutionPlaceholderExp.test(value)) { 9659 acc[key] = substitutions[value.replace('__s', '')]; 9660 return acc; 9661 } 9662 acc[key] = value; 9663 } 9664 return acc; 9665 }, {}); 9666 } 9667 9668 /** 9669 * @memberOf BX 9670 */ 9671 let Tag = /*#__PURE__*/function () { 9672 function Tag() { 9673 babelHelpers.classCallCheck(this, Tag); 9674 } 9675 babelHelpers.createClass(Tag, null, [{ 9676 key: "safe", 9677 /** 9678 * Encodes all substitutions 9679 * @param sections 9680 * @param substitutions 9681 * @return {string} 9682 */ 9683 value: function safe(sections, ...substitutions) { 9684 return substitutions.reduce((acc, item, index) => acc + Text.encode(item) + sections[index + 1], sections[0]); 9685 } 9686 /** 9687 * Decodes all substitutions 9688 * @param sections 9689 * @param substitutions 9690 * @return {string} 9691 */ 9692 }, { 9693 key: "unsafe", 9694 value: function unsafe(sections, ...substitutions) { 9695 return substitutions.reduce((acc, item, index) => acc + Text.decode(item) + sections[index + 1], sections[0]); 9696 } 9697 /** 9698 * Adds styles to specified element 9699 * @param {HTMLElement} element 9700 * @return {Function} 9701 */ 9702 }, { 9703 key: "style", 9704 value: function style(element) { 9705 if (!Type.isDomNode(element)) { 9706 throw new Error('element is not HTMLElement'); 9707 } 9708 return function styleTagHandler(...args) { 9709 Dom.style(element, parseProps(...args)); 9710 }; 9711 } 9712 /** 9713 * Replace all messages identifiers to real messages 9714 * @param sections 9715 * @param substitutions 9716 * @return {string} 9717 */ 9718 }, { 9719 key: "message", 9720 value: function message(sections, ...substitutions) { 9721 return substitutions.reduce((acc, item, index) => acc + Loc.getMessage(item) + sections[index + 1], sections[0]); 9722 } 9723 }, { 9724 key: "attrs", 9725 /** 9726 * Adds attributes to specified element 9727 * @param element 9728 * @return {Function} 9729 */ 9730 value: function attrs(element) { 9731 if (!Type.isDomNode(element)) { 9732 throw new Error('element is not HTMLElement'); 9733 } 9734 return function attrsTagHandler(...args) { 9735 Dom.attr(element, parseProps(...args)); 9736 }; 9737 } 9738 }]); 9739 return Tag; 9740 }(); 9741 babelHelpers.defineProperty(Tag, "render", render); 9742 babelHelpers.defineProperty(Tag, "attr", Tag.attrs); 9743 9744 function getParser(format) { 9745 switch (format) { 9746 case 'index': 9747 return (sourceKey, value, accumulator) => { 9748 const result = /\[(\w*)\]$/.exec(sourceKey); 9749 const key = sourceKey.replace(/\[\w*\]$/, ''); 9750 if (Type.isNil(result)) { 9751 accumulator[key] = value; 9752 return; 9753 } 9754 if (Type.isUndefined(accumulator[key])) { 9755 accumulator[key] = {}; 9756 } 9757 accumulator[key][result[1]] = value; 9758 }; 9759 case 'bracket': 9760 return (sourceKey, value, accumulator) => { 9761 const result = /(\[\])$/.exec(sourceKey); 9762 const key = sourceKey.replace(/\[\]$/, ''); 9763 if (Type.isNil(result)) { 9764 accumulator[key] = value; 9765 return; 9766 } 9767 if (Type.isUndefined(accumulator[key])) { 9768 accumulator[key] = Type.isNil(value) ? [] : [value]; 9769 return; 9770 } 9771 accumulator[key] = [].concat(accumulator[key], value); 9772 }; 9773 default: 9774 return (sourceKey, value, accumulator) => {
9775 const key = sourceKey.replace(/\[\]$/, ''); 9776 accumulator[key] = value; 9777 }; 9778 } 9779 } 9780 function getKeyFormat(key) { 9781 if (/^\w+\[([\w]+)\]$/.test(key)) { 9782 return 'index'; 9783 } 9784 if (/^\w+\[\]$/.test(key)) { 9785 return 'bracket'; 9786 } 9787 return 'default'; 9788 } 9789 function isAllowedKey(key) { 9790 return !String(key).startsWith('__proto__'); 9791 } 9792 function parseQuery(input) { 9793 if (!Type.isString(input)) { 9794 return {}; 9795 } 9796 const url = input.trim().replace(/^[?#&]/, ''); 9797 if (!url) { 9798 return {}; 9799 } 9800 return { 9801 ...url.split('&').reduce((acc, param) => { 9802 const [key, value] = param.replace(/\+/g, ' ').split('='); 9803 if (isAllowedKey(key)) { 9804 const keyFormat = getKeyFormat(key); 9805 const formatter = getParser(keyFormat); 9806 formatter(key, value, acc); 9807 } 9808 return acc; 9809 }, Object.create(null)) 9810 }; 9811 } 9812 const urlExp = /^((\w+):)?(\/\/((\w+)?(:(\w+))?@)?([^\/\?:]+)(:(\d+))?)?(\/?([^\/\?#][^\?#]*)?)?(\?([^#]+))?(#((?:[\w-?/:@.~!$&'()*+,;=]|%\w{2})*))?/; 9813 function prepareParams(params) { 9814 const paramsEntries = Object.entries(params); 9815 return paramsEntries.reduce((acc, [key, value]) => { 9816 if (Type.isNil(value)) { 9817 acc[key] = ''; 9818 } else if (Type.isPlainObject(value)) { 9819 acc[key] = prepareParams(value); 9820 } else { 9821 acc[key] = value; 9822 } 9823 return acc; 9824 }, {}); 9825 } 9826 function parseUrl(url) { 9827 const result = url.match(urlExp); 9828 if (Type.isArray(result)) { 9829 const sourceParams = parseQuery(result[14]); 9830 const preparedParams = prepareParams(sourceParams); 9831 return { 9832 useShort: /^\/\//.test(url), 9833 href: result[0] || '', 9834 schema: result[2] || '', 9835 host: result[8] || '', 9836 port: result[10] || '', 9837 path: result[11] || '', 9838 query: result[14] || '', 9839 sourceQueryParams: sourceParams, 9840 queryParams: preparedParams, 9841 hash: result[16] || '', 9842 username: result[5] || '', 9843 password: result[7] || '', 9844 origin: result[8] || '' 9845 }; 9846 } 9847 return {}; 9848 } 9849 9850 function renderParam(param, value) { 9851 if (Type.isNil(value)) { 9852 return param; 9853 } 9854 return `${param}=${value}`; 9855 } 9856 9857 function buildQueryString(params = {}) { 9858 const queryString = Object.keys(params).reduce((acc, key) => { 9859 if (Type.isArray(params[key])) { 9860 if (Type.isArrayFilled(params[key])) { 9861 params[key].forEach(paramValue => { 9862 acc.push(renderParam(`${key}[]`, paramValue)); 9863 }); 9864 } else { 9865 acc.push(renderParam(`${key}[]`, null)); 9866 } 9867 } 9868 if (Type.isPlainObject(params[key])) { 9869 Object.keys(params[key]).forEach(paramIndex => { 9870 acc.push(renderParam(`${key}[${paramIndex}]`, params[key][paramIndex])); 9871 }); 9872 } 9873 if (!Type.isObject(params[key]) && !Type.isArray(params[key])) { 9874 acc.push(renderParam(key, params[key])); 9875 } 9876 return acc; 9877 }, []).join('&'); 9878 if (queryString.length > 0) { 9879 return `?${queryString}`; 9880 } 9881 return queryString; 9882 } 9883 9884 function prepareParamValue(value) { 9885 if (Type.isArray(value)) { 9886 return value.map(item => String(item)); 9887 } 9888 if (Type.isPlainObject(value)) { 9889 return { 9890 ...value 9891 }; 9892 } 9893 return String(value); 9894 } 9895 9896 const map = new WeakMap(); 9897 9898 /** 9899 * Implements interface for works with URI 9900 * @memberOf BX 9901 */ 9902 let Uri = /*#__PURE__*/function () { 9903 babelHelpers.createClass(Uri, null, [{ 9904 key: "addParam", 9905 value: function addParam(url, params = {}) { 9906 return new Uri(url).setQueryParams(params).toString(); 9907 } 9908 }, { 9909 key: "removeParam", 9910 value: function removeParam(url, params) { 9911 const removableParams = Type.isArray(params) ? params : [params]; 9912 return new Uri(url).removeQueryParam(...removableParams).toString(); 9913 } 9914 }]); 9915 function Uri(url = '') { 9916 babelHelpers.classCallCheck(this, Uri); 9917 map.set(this, parseUrl(url)); 9918 } 9919 babelHelpers.createClass(Uri, [{ 9920 key: "getSchema", 9921 value: function getSchema() { 9922 return map.get(this).schema; 9923 } 9924 }, { 9925 key: "setSchema", 9926 value: function setSchema(schema) { 9927 map.get(this).schema = String(schema); 9928 return this; 9929 } 9930 }, { 9931 key: "getHost", 9932 value: function getHost() { 9933 return map.get(this).host; 9934 } 9935 }, { 9936 key: "setHost", 9937 value: function setHost(host) { 9938 map.get(this).host = String(host); 9939 return this; 9940 } 9941 }, { 9942 key: "getPort", 9943 value: function getPort() { 9944 return map.get(this).port; 9945 } 9946 }, { 9947 key: "setPort", 9948 value: function setPort(port) { 9949 map.get(this).port = String(port); 9950 return this; 9951 } 9952 }, { 9953 key: "getPath", 9954 value: function getPath() { 9955 return map.get(this).path; 9956 } 9957 }, { 9958 key: "setPath", 9959 value: function setPath(path) { 9960 if (!/^\//.test(path)) {
9961 map.get(this).path = `/${String(path)}`; 9962 return this; 9963 } 9964 map.get(this).path = String(path); 9965 return this; 9966 } 9967 }, { 9968 key: "getQuery", 9969 value: function getQuery() { 9970 return buildQueryString(map.get(this).queryParams); 9971 } 9972 }, { 9973 key: "getQueryParam", 9974 value: function getQueryParam(key) { 9975 const params = this.getQueryParams(); 9976 if (Object.hasOwn(params, key)) { 9977 return params[key]; 9978 } 9979 return null; 9980 } 9981 }, { 9982 key: "setQueryParam", 9983 value: function setQueryParam(key, value = '') { 9984 map.get(this).queryParams[key] = prepareParamValue(value); 9985 map.get(this).sourceQueryParams[key] = prepareParamValue(value); 9986 return this; 9987 } 9988 }, { 9989 key: "getQueryParams", 9990 value: function getQueryParams() { 9991 return { 9992 ...map.get(this).queryParams 9993 }; 9994 } 9995 }, { 9996 key: "setQueryParams", 9997 value: function setQueryParams(params = {}) { 9998 if (Type.isPlainObject(params)) { 9999 const { 10000 queryParams, 10001 sourceQueryParams 10002 } = map.get(this); 10003 Object.entries(params).forEach(([key, value]) => { 10004 const preparedValue = prepareParamValue(value); 10005 queryParams[key] = preparedValue; 10006 sourceQueryParams[key] = preparedValue; 10007 }); 10008 } 10009 return this; 10010 } 10011 }, { 10012 key: "removeQueryParam", 10013 value: function removeQueryParam(...keys) { 10014 const { 10015 queryParams, 10016 sourceQueryParams 10017 } = map.get(this); 10018 keys.forEach(key => { 10019 delete queryParams[key]; 10020 delete sourceQueryParams[key]; 10021 }); 10022 return this; 10023 } 10024 }, { 10025 key: "getFragment", 10026 value: function getFragment() { 10027 return map.get(this).hash; 10028 } 10029 }, { 10030 key: "setFragment", 10031 value: function setFragment(hash) { 10032 map.get(this).hash = String(hash); 10033 return this; 10034 } 10035 }, { 10036 key: "serialize", 10037 value: function serialize() { 10038 const serialized = { 10039 ...map.get(this) 10040 }; 10041 delete serialized.sourceQueryParams; 10042 serialized.href = this.toString(); 10043 return serialized; 10044 } 10045 }, { 10046 key: "toString", 10047 value: function toString() { 10048 const data = { 10049 ...map.get(this) 10050 }; 10051 let protocol = data.schema ? `${data.schema}://` : ''; 10052 if (data.useShort) { 10053 protocol = '//'; 10054 } 10055 const port = (() => { 10056 if (Type.isString(data.port) && !['', '80'].includes(data.port)) { 10057 return `:${data.port}`; 10058 } 10059 return ''; 10060 })(); 10061 const host = this.getHost(); 10062 const path = this.getPath(); 10063 const query = buildQueryString(data.sourceQueryParams); 10064 const hash = data.hash ? `#${data.hash}` : ''; 10065 return `${host ? protocol : ''}${host}${host ? port : ''}${path}${query}${hash}`; 10066 } 10067 }]); 10068 return Uri; 10069 }(); 10070 10071 /** 10072 * Checks if the given value is a valid email address. 10073 * Supports Cyrillic characters in both local and domain parts. 10074 * 10075 * @param {any} email The value to validate. 10076 * @returns {boolean} True if the value is a valid email, false otherwise. 10077 * @memberOf BX 10078 */ 10079 let Validation = /*#__PURE__*/function () { 10080 function Validation() { 10081 babelHelpers.classCallCheck(this, Validation); 10082 } 10083 babelHelpers.createClass(Validation, null, [{ 10084 key: "isEmail", 10085 value: function isEmail(email) { 10086 if (!Type.isStringFilled(email)) { 10087 return false; 10088 } 10089 if (email.length > Validation.MAX_EMAIL_LENGTH) { 10090 return false; 10091 } 10092 const atPos = email.indexOf('@'); 10093 if (atPos <= 0 || atPos === email.length - 1 || email.includes('@', atPos + 1)) { 10094 return false; 10095 } 10096 const local = email.slice(0, atPos); 10097 const domain = email.slice(atPos + 1); 10098 if (!Validation.LOCAL_ALLOWED_CHARS.test(local)) { 10099 return false; 10100 } 10101 if (local.startsWith('.') || local.endsWith('.') || local.startsWith('-') || local.endsWith('-') || local.includes('..') || local.length > Validation.MAX_LOCAL_LENGTH) { 10102 return false;
10103 } 10104 if (!Validation.DOMAIN_LABEL_CHARS.test(domain)) { 10105 return false; 10106 } 10107 if (domain.startsWith('.') || domain.endsWith('.') || domain.includes('..')) { 10108 return false; 10109 } 10110 const labels = domain.split('.'); 10111 if (labels.length < 2) { 10112 return false; 10113 } 10114 const tld = labels[labels.length - 1]; 10115 if (tld.length < 2 || tld.length > 24) { 10116 return false; 10117 } 10118 for (const label of labels) { 10119 if (label.startsWith('-') || label.endsWith('-')) { 10120 return false; 10121 } 10122 const startsWithLetterOrDigit = /^[\dA-Za-zÐÐ-ÑÑ]/.test(label); 10123 const endsWithLetterOrDigit = /[\dA-Za-zÐÐ-ÑÑ]$/.test(label); 10124 if (!startsWithLetterOrDigit || !endsWithLetterOrDigit) { 10125 return false; 10126 } 10127 } 10128 return true; 10129 } 10130 }]); 10131 return Validation; 10132 }(); 10133 babelHelpers.defineProperty(Validation, "MAX_EMAIL_LENGTH", 254); 10134 babelHelpers.defineProperty(Validation, "MAX_LOCAL_LENGTH", 64); 10135 babelHelpers.defineProperty(Validation, "LOCAL_ALLOWED_CHARS", /^[\w%+.ÐÐ-ÑÑ-]+$/); 10136 babelHelpers.defineProperty(Validation, "DOMAIN_LABEL_CHARS", /^[\w.ÐÐ-ÑÑ-]+$/); 10137 10138 let BaseCache = /*#__PURE__*/function () { 10139 function BaseCache() { 10140 babelHelpers.classCallCheck(this, BaseCache); 10141 babelHelpers.defineProperty(this, "storage", new Map()); 10142 } 10143 babelHelpers.createClass(BaseCache, [{ 10144 key: "get", 10145 /** 10146 * Gets cached value or default value 10147 */ 10148 value: function get(key, defaultValue) { 10149 if (!this.storage.has(key)) { 10150 if (Type.isFunction(defaultValue)) { 10151 return defaultValue(); 10152 } 10153 if (!Type.isUndefined(defaultValue)) { 10154 return defaultValue; 10155 } 10156 } 10157 return this.storage.get(key); 10158 } 10159 /** 10160 * Sets cache entry 10161 */ 10162 }, { 10163 key: "set", 10164 value: function set(key, value) { 10165 this.storage.set(key, value); 10166 } 10167 /** 10168 * Deletes cache entry 10169 */ 10170 }, { 10171 key: "delete", 10172 value: function _delete(key) { 10173 this.storage.delete(key); 10174 } 10175 /** 10176 * Checks that storage contains entry with specified key 10177 */ 10178 }, { 10179 key: "has", 10180 value: function has(key) { 10181 return this.storage.has(key); 10182 } 10183 /** 10184 * Gets cached value if exists, 10185 */ 10186 }, { 10187 key: "remember", 10188 value: function remember(key, defaultValue) { 10189 if (!this.storage.has(key)) { 10190 if (Type.isFunction(defaultValue)) { 10191 this.storage.set(key, defaultValue()); 10192 } else if (!Type.isUndefined(defaultValue)) { 10193 this.storage.set(key, defaultValue); 10194 } 10195 } 10196 return this.storage.get(key); 10197 } 10198 /** 10199 * Gets storage size 10200 */ 10201 }, { 10202 key: "size", 10203 value: function size() { 10204 return this.storage.size; 10205 } 10206 /** 10207 * Gets storage keys 10208 */ 10209 }, { 10210 key: "keys", 10211 value: function keys() { 10212 return [...this.storage.keys()]; 10213 } 10214 /** 10215 * Gets storage values 10216 */ 10217 }, { 10218 key: "values", 10219 value: function values() { 10220 return [...this.storage.values()]; 10221 } 10222 }]); 10223 return BaseCache; 10224 }(); 10225 10226 let MemoryCache = /*#__PURE__*/function (_BaseCache) { 10227 babelHelpers.inherits(MemoryCache, _BaseCache); 10228 function MemoryCache(...args) { 10229 var _this; 10230 babelHelpers.classCallCheck(this, MemoryCache); 10231 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(MemoryCache).call(this, ...args)); 10232 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "storage", new Map()); 10233 return _this; 10234 } 10235 return MemoryCache; 10236 }(BaseCache); 10237 10238 let LsStorage = /*#__PURE__*/function () { 10239 function LsStorage() { 10240 babelHelpers.classCallCheck(this, LsStorage); 10241 babelHelpers.defineProperty(this, "stackKey", 'BX.Cache.Storage.LsStorage.stack'); 10242 babelHelpers.defineProperty(this, "stack", null); 10243 } 10244 babelHelpers.createClass(LsStorage, [{ 10245 key: "getStack", 10246 /** 10247 * @private 10248 */ 10249 value: function getStack() { 10250 if (Type.isPlainObject(this.stack)) { 10251 return this.stack; 10252 } 10253 const stack = localStorage.getItem(this.stackKey); 10254 if (Type.isString(stack) && stack !== '') { 10255 const parsedStack = JSON.parse(stack); 10256 if (Type.isPlainObject(parsedStack)) { 10257 this.stack = parsedStack; 10258 return this.stack; 10259 } 10260 } 10261 this.stack = {}; 10262 return this.stack; 10263 } 10264 /** 10265 * @private 10266 */ 10267 }, { 10268 key: "saveStack", 10269 value: function saveStack() { 10270 if (Type.isPlainObject(this.stack)) { 10271 const preparedStack = JSON.stringify(this.stack); 10272 localStorage.setItem(this.stackKey, preparedStack); 10273 } 10274 } 10275 }, { 10276 key: "get", 10277 value: function get(key) {
10278 const stack = this.getStack(); 10279 return stack[key]; 10280 } 10281 }, { 10282 key: "set", 10283 value: function set(key, value) { 10284 const stack = this.getStack(); 10285 stack[key] = value; 10286 this.saveStack(); 10287 } 10288 }, { 10289 key: "delete", 10290 value: function _delete(key) { 10291 const stack = this.getStack(); 10292 if (key in stack) { 10293 delete stack[key]; 10294 } 10295 } 10296 }, { 10297 key: "has", 10298 value: function has(key) { 10299 const stack = this.getStack(); 10300 return key in stack; 10301 } 10302 }, { 10303 key: "keys", 10304 value: function keys() { 10305 const stack = this.getStack(); 10306 return Object.keys(stack); 10307 } 10308 }, { 10309 key: "values", 10310 value: function values() { 10311 const stack = this.getStack(); 10312 return Object.values(stack); 10313 } 10314 }, { 10315 key: "size", 10316 get: function () { 10317 const stack = this.getStack(); 10318 return Object.keys(stack).length; 10319 } 10320 }]); 10321 return LsStorage; 10322 }(); 10323 10324 let LocalStorageCache = /*#__PURE__*/function (_BaseCache) { 10325 babelHelpers.inherits(LocalStorageCache, _BaseCache); 10326 function LocalStorageCache(...args) { 10327 var _this; 10328 babelHelpers.classCallCheck(this, LocalStorageCache); 10329 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(LocalStorageCache).call(this, ...args)); 10330 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "storage", new LsStorage()); 10331 return _this; 10332 } 10333 return LocalStorageCache; 10334 }(BaseCache); 10335 10336 /** 10337 * @memberOf BX 10338 */ 10339 let Cache = function Cache() { 10340 babelHelpers.classCallCheck(this, Cache); 10341 }; 10342 babelHelpers.defineProperty(Cache, "BaseCache", BaseCache); 10343 babelHelpers.defineProperty(Cache, "MemoryCache", MemoryCache); 10344 babelHelpers.defineProperty(Cache, "LocalStorageCache", LocalStorageCache); 10345 10346 function convertPath(path) { 10347 if (Type.isStringFilled(path)) { 10348 return path.split('.').reduce((acc, item) => { 10349 item.split(/\[['"]?(.+?)['"]?\]/g).forEach(key => { 10350 if (Type.isStringFilled(key)) { 10351 acc.push(key); 10352 } 10353 }); 10354 return acc; 10355 }, []); 10356 } 10357 return []; 10358 } 10359 10360 let SettingsCollection = /*#__PURE__*/function () { 10361 function SettingsCollection(options = {}) { 10362 babelHelpers.classCallCheck(this, SettingsCollection); 10363 if (Type.isPlainObject(options)) { 10364 Object.assign(this, options); 10365 } 10366 } 10367 babelHelpers.createClass(SettingsCollection, [{ 10368 key: "get", 10369 value: function get(path, defaultValue = null) { 10370 const convertedPath = convertPath(path); 10371 return convertedPath.reduce((acc, key) => { 10372 if (!Type.isNil(acc) && acc !== defaultValue) { 10373 if (!Type.isUndefined(acc[key])) { 10374 return acc[key]; 10375 } 10376 return defaultValue; 10377 } 10378 return acc; 10379 }, this); 10380 } 10381 }]); 10382 return SettingsCollection; 10383 }(); 10384 10385 function deepFreeze(target) { 10386 if (Type.isObject(target)) { 10387 Object.values(target).forEach(value => { 10388 deepFreeze(value); 10389 }); 10390 return Object.freeze(target); 10391 } 10392 return target; 10393 } 10394 10395 const settingsStorage = new Map(); 10396 let Extension = /*#__PURE__*/function () { 10397 function Extension() { 10398 babelHelpers.classCallCheck(this, Extension); 10399 } 10400 babelHelpers.createClass(Extension, null, [{ 10401 key: "getSettings", 10402 value: function getSettings(extensionName) { 10403 if (Type.isStringFilled(extensionName)) { 10404 if (settingsStorage.has(extensionName)) { 10405 return settingsStorage.get(extensionName); 10406 } 10407 const settingsScriptNode = document.querySelector(`script[data-extension="${extensionName}"]`); 10408 if (Type.isDomNode(settingsScriptNode)) { 10409 const decodedSettings = (() => { 10410 try { 10411 return new SettingsCollection(JSON.parse(settingsScriptNode.innerHTML)); 10412 } catch (error) { 10413 return new SettingsCollection(); 10414 } 10415 })(); 10416 const frozenSettings = deepFreeze(decodedSettings); 10417 settingsStorage.set(extensionName, frozenSettings); 10418 return frozenSettings; 10419 } 10420 } 10421 return deepFreeze(new SettingsCollection()); 10422 } 10423 }]); 10424 return Extension; 10425 }(); 10426 10427 let _Symbol$iterator; 10428 function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); } 10429 function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } } 10430 function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; } 10431 var _searchIndexToInsert = /*#__PURE__*/new WeakSet(); 10432 _Symbol$iterator = Symbol.iterator; 10433 let OrderedArray = /*#__PURE__*/function () { 10434 function OrderedArray(comparator = null) { 10435 babelHelpers.classCallCheck(this, OrderedArray); 10436 _classPrivateMethodInitSpec(this, _searchIndexToInsert); 10437 babelHelpers.defineProperty(this, "comparator", null); 10438 babelHelpers.defineProperty(this, "items", []); 10439 this.comparator = Type.isFunction(comparator) ? comparator : null; 10440 } 10441 babelHelpers.createClass(OrderedArray, [{ 10442 key: "add", 10443 value: function add(item) { 10444 let index = -1; 10445 if (this.comparator) { 10446 index = _classPrivateMethodGet(this, _searchIndexToInsert, _searchIndexToInsert2).call(this, item); 10447 this.items.splice(index, 0, item); 10448 } else { 10449 this.items.push(item); 10450 } 10451 return index; 10452 } 10453 }, { 10454 key: "has", 10455 value: function has(item) { 10456 return this.items.includes(item); 10457 } 10458 }, { 10459 key: "getIndex", 10460 value: function getIndex(item) { 10461 return this.items.indexOf(item); 10462 } 10463 }, { 10464 key: "getByIndex", 10465 value: function getByIndex(index) { 10466 if (Type.isNumber(index) && index >= 0) { 10467 const item = this.items[index]; 10468 return Type.isUndefined(item) ? null : item; 10469 } 10470 return null; 10471 } 10472 }, { 10473 key: "getFirst", 10474 value: function getFirst() { 10475 const first = this.items[0]; 10476 return Type.isUndefined(first) ? null : first; 10477 } 10478 }, { 10479 key: "getLast", 10480 value: function getLast() { 10481 const last = this.items[this.count() - 1]; 10482 return Type.isUndefined(last) ? null : last; 10483 } 10484 }, { 10485 key: "count", 10486 value: function count() { 10487 return this.items.length; 10488 } 10489 }, { 10490 key: "delete", 10491 value: function _delete(item) { 10492 const index = this.getIndex(item); 10493 if (index !== -1) { 10494 this.items.splice(index, 1); 10495 return true; 10496 } 10497 return false;
10498 } 10499 }, { 10500 key: "clear", 10501 value: function clear() { 10502 this.items = []; 10503 } 10504 }, { 10505 key: _Symbol$iterator, 10506 value: function () { 10507 return this.items[Symbol.iterator](); 10508 } 10509 }, { 10510 key: "forEach", 10511 value: function forEach(callbackfn, thisArg) { 10512 return this.items.forEach(callbackfn, thisArg); 10513 } 10514 }, { 10515 key: "getAll", 10516 value: function getAll() { 10517 return this.items; 10518 } 10519 }, { 10520 key: "getComparator", 10521 value: function getComparator() { 10522 return this.comparator; 10523 } 10524 }, { 10525 key: "sort", 10526 value: function sort() { 10527 const comparator = this.getComparator(); 10528 if (comparator === null) { 10529 return; 10530 } 10531 10532 /* 10533 Simple implementation 10534 this.items.sort((item1, item2) => { 10535 return comparator(item1, item2); 10536 }); 10537 */ 10538 10539 // For stable sorting https://v8.dev/features/stable-sort 10540 const length = this.items.length; 10541 const indexes = new Array(length); 10542 for (let i = 0; i < length; i++) { 10543 indexes[i] = i; 10544 } 10545 10546 // If the comparator returns zero, use the original indexes 10547 indexes.sort((index1, index2) => { 10548 return comparator(this.items[index1], this.items[index2]) || index1 - index2; 10549 }); 10550 for (let i = 0; i < length; i++) { 10551 indexes[i] = this.items[indexes[i]]; 10552 } 10553 for (let i = 0; i < length; i++) { 10554 this.items[i] = indexes[i]; 10555 } 10556 } 10557 }]); 10558 return OrderedArray; 10559 }(); 10560 function _searchIndexToInsert2(value) { 10561 let low = 0; 10562 let high = this.items.length; 10563 while (low < high) { 10564 const mid = Math.floor((low + high) / 2); 10565 if (this.comparator(this.items[mid], value) >= 0) { 10566 high = mid; 10567 } else { 10568 low = mid + 1; 10569 } 10570 } 10571 return low; 10572 } 10573 10574 let ZIndexComponent = /*#__PURE__*/function (_EventEmitter) { 10575 babelHelpers.inherits(ZIndexComponent, _EventEmitter); 10576 function ZIndexComponent(element, componentOptions = {}) { 10577 var _this; 10578 babelHelpers.classCallCheck(this, ZIndexComponent); 10579 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(ZIndexComponent).call(this)); 10580 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "sort", 0); 10581 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "alwaysOnTop", false); 10582 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "zIndex", 0); 10583 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "element", null); 10584 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "overlay", null); 10585 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "overlayGap", -5); 10586 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "stack", null); 10587 _this.setEventNamespace('BX.Main.ZIndexManager.Component'); 10588 if (!Type.isElementNode(element)) { 10589 throw new Error('ZIndexManager.Component: The argument \'element\' must be a DOM element.'); 10590 } 10591 _this.element = element; 10592 const options = Type.isPlainObject(componentOptions) ? componentOptions : {}; 10593 _this.setAlwaysOnTop(options.alwaysOnTop); 10594 _this.setOverlay(options.overlay); 10595 _this.setOverlayGap(options.overlayGap); 10596 _this.subscribeFromOptions(options.events); 10597 return _this; 10598 } 10599 babelHelpers.createClass(ZIndexComponent, [{ 10600 key: "getSort", 10601 value: function getSort() { 10602 return this.sort; 10603 } 10604 /** 10605 * @internal 10606 * @param sort 10607 */ 10608 }, { 10609 key: "setSort", 10610 value: function setSort(sort) { 10611 if (Type.isNumber(sort)) { 10612 this.sort = sort; 10613 } 10614 } 10615 /** 10616 * @internal 10617 * @param stack 10618 */ 10619 }, { 10620 key: "setStack", 10621 value: function setStack(stack) { 10622 this.stack = stack; 10623 } 10624 }, { 10625 key: "getStack", 10626 value: function getStack() { 10627 return this.stack; 10628 } 10629 }, { 10630 key: "getZIndex", 10631 value: function getZIndex() { 10632 return this.zIndex; 10633 } 10634 /** 10635 * @internal 10636 */ 10637 }, { 10638 key: "setZIndex", 10639 value: function setZIndex(zIndex) { 10640 const changed = this.getZIndex() !== zIndex; 10641 this.getElement().style.setProperty('z-index', zIndex, 'important'); 10642 this.zIndex = zIndex; 10643 if (this.getOverlay() !== null) { 10644 this.getOverlay().style.setProperty('z-index', zIndex + this.getOverlayGap(), 'important'); 10645 } 10646 if (changed) {
10647 this.emit('onZIndexChange', { 10648 component: this 10649 }); 10650 } 10651 } 10652 }, { 10653 key: "getAlwaysOnTop", 10654 value: function getAlwaysOnTop() { 10655 return this.alwaysOnTop; 10656 } 10657 }, { 10658 key: "setAlwaysOnTop", 10659 value: function setAlwaysOnTop(value) { 10660 if (Type.isNumber(value) || Type.isBoolean(value)) { 10661 this.alwaysOnTop = value; 10662 } 10663 } 10664 }, { 10665 key: "getElement", 10666 value: function getElement() { 10667 return this.element; 10668 } 10669 }, { 10670 key: "setOverlay", 10671 value: function setOverlay(overlay, gap) { 10672 if (Type.isElementNode(overlay) || overlay === null) { 10673 this.overlay = overlay; 10674 this.setOverlayGap(gap); 10675 if (this.getStack()) { 10676 this.getStack().sort(); 10677 } 10678 } 10679 } 10680 }, { 10681 key: "getOverlay", 10682 value: function getOverlay() { 10683 return this.overlay; 10684 } 10685 }, { 10686 key: "setOverlayGap", 10687 value: function setOverlayGap(gap) { 10688 if (Type.isNumber(gap)) { 10689 this.overlayGap = gap; 10690 } 10691 } 10692 }, { 10693 key: "getOverlayGap", 10694 value: function getOverlayGap() { 10695 return this.overlayGap; 10696 } 10697 }]); 10698 return ZIndexComponent; 10699 }(EventEmitter); 10700 10701 let ZIndexStack = /*#__PURE__*/function () { 10702 function ZIndexStack(container) { 10703 babelHelpers.classCallCheck(this, ZIndexStack); 10704 babelHelpers.defineProperty(this, "container", null); 10705 babelHelpers.defineProperty(this, "components", null); 10706 babelHelpers.defineProperty(this, "elements", new WeakMap()); 10707 babelHelpers.defineProperty(this, "baseIndex", 1000); 10708 babelHelpers.defineProperty(this, "baseStep", 50); 10709 babelHelpers.defineProperty(this, "sortCount", 0); 10710 if (!Type.isDomNode(container)) { 10711 throw new Error('ZIndexManager.Stack: The \'container\' argument must be a DOM element.'); 10712 } 10713 this.container = container; 10714 const comparator = (componentA, componentB) => { 10715 let result = (componentA.getAlwaysOnTop() || 0) - (componentB.getAlwaysOnTop() || 0); 10716 if (!result) { 10717 result = componentA.getSort() - componentB.getSort(); 10718 } 10719 return result; 10720 }; 10721 this.components = new OrderedArray(comparator); 10722 } 10723 babelHelpers.createClass(ZIndexStack, [{ 10724 key: "getBaseIndex", 10725 value: function getBaseIndex() { 10726 return this.baseIndex; 10727 } 10728 }, { 10729 key: "setBaseIndex", 10730 value: function setBaseIndex(index) { 10731 if (Type.isNumber(index) && index >= 0) { 10732 this.baseIndex = index; 10733 this.sort(); 10734 } 10735 } 10736 }, { 10737 key: "setBaseStep", 10738 value: function setBaseStep(step) { 10739 if (Type.isNumber(step) && step > 0) { 10740 this.baseStep = step; 10741 this.sort(); 10742 } 10743 } 10744 }, { 10745 key: "getBaseStep", 10746 value: function getBaseStep() { 10747 return this.baseStep; 10748 } 10749 }, { 10750 key: "register", 10751 value: function register(element, options = {}) { 10752 if (this.getComponent(element)) { 10753 console.warn('ZIndexManager: You cannot register the element twice.', element); 10754 return this.getComponent(element); 10755 } 10756 const component = new ZIndexComponent(element, options); 10757 component.setStack(this); 10758 component.setSort(++this.sortCount); 10759 this.elements.set(element, component); 10760 this.components.add(component); 10761 this.sort(); 10762 return component; 10763 } 10764 }, { 10765 key: "unregister", 10766 value: function unregister(element) { 10767 const component = this.elements.get(element); 10768 this.components.delete(component); 10769 this.elements.delete(element); 10770 this.sort(); 10771 } 10772 }, { 10773 key: "getComponent", 10774 value: function getComponent(element) { 10775 return this.elements.get(element) || null; 10776 } 10777 }, { 10778 key: "getComponents", 10779 value: function getComponents() { 10780 return this.components.getAll(); 10781 } 10782 }, { 10783 key: "getMaxZIndex", 10784 value: function getMaxZIndex() { 10785 const last = this.components.getLast(); 10786 return last ? last.getZIndex() : this.baseIndex; 10787 } 10788 }, { 10789 key: "sort", 10790 value: function sort() { 10791 this.components.sort(); 10792 let zIndex = this.baseIndex;
10793 this.components.forEach(component => { 10794 component.setZIndex(zIndex); 10795 zIndex += this.baseStep; 10796 }); 10797 } 10798 }, { 10799 key: "bringToFront", 10800 value: function bringToFront(element) { 10801 const component = this.getComponent(element); 10802 if (!component) { 10803 console.error('ZIndexManager: element was not found in the stack.', element); 10804 return null; 10805 } 10806 component.setSort(++this.sortCount); 10807 this.sort(); 10808 return component; 10809 } 10810 }]); 10811 return ZIndexStack; 10812 }(); 10813 10814 function _classStaticPrivateMethodGet(receiver, classConstructor, method) { _classCheckPrivateStaticAccess(receiver, classConstructor); return method; } 10815 function _classCheckPrivateStaticAccess(receiver, classConstructor) { if (receiver !== classConstructor) { throw new TypeError("Private static access of wrong provenance"); } } 10816 /** 10817 * @memberof BX 10818 */ 10819 let ZIndexManager = /*#__PURE__*/function () { 10820 function ZIndexManager() { 10821 babelHelpers.classCallCheck(this, ZIndexManager); 10822 } 10823 babelHelpers.createClass(ZIndexManager, null, [{ 10824 key: "register", 10825 value: function register(element, options = {}) { 10826 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element); 10827 if (!parentNode) { 10828 return null; 10829 } 10830 const stack = this.getOrAddStack(parentNode); 10831 return stack.register(element, options); 10832 } 10833 }, { 10834 key: "unregister", 10835 value: function unregister(element) { 10836 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element); 10837 const stack = this.getStack(parentNode); 10838 if (stack) { 10839 stack.unregister(element); 10840 } 10841 } 10842 }, { 10843 key: "addStack", 10844 value: function addStack(container) { 10845 const stack = new ZIndexStack(container); 10846 this.stacks.set(container, stack); 10847 return stack; 10848 } 10849 }, { 10850 key: "getStack", 10851 value: function getStack(container) { 10852 return this.stacks.get(container) || null; 10853 } 10854 }, { 10855 key: "getOrAddStack", 10856 value: function getOrAddStack(container) { 10857 return this.getStack(container) || this.addStack(container); 10858 } 10859 }, { 10860 key: "getComponent", 10861 value: function getComponent(element) { 10862 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element, true); 10863 if (!parentNode) { 10864 return null; 10865 } 10866 const stack = this.getStack(parentNode); 10867 return stack ? stack.getComponent(element) : null; 10868 } 10869 }, { 10870 key: "bringToFront", 10871 value: function bringToFront(element) { 10872 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element); 10873 const stack = this.getStack(parentNode); 10874 if (stack) { 10875 return stack.bringToFront(element); 10876 } 10877 return null; 10878 } 10879 }]); 10880 return ZIndexManager; 10881 }(); 10882 function _getParentNode(element, suppressWarnings = false) { 10883 if (!Type.isElementNode(element)) { 10884 if (!suppressWarnings) { 10885 console.error('ZIndexManager: The argument \'element\' must be a DOM element.', element); 10886 } 10887 return null; 10888 } else if (!Type.isElementNode(element.parentNode)) { 10889 if (!suppressWarnings) { 10890 console.error('ZIndexManager: The \'element\' doesn\'t have a parent node.', element); 10891 } 10892 return null; 10893 } 10894 return element.parentNode; 10895 } 10896 babelHelpers.defineProperty(ZIndexManager, "stacks", new WeakMap()); 10897 10898 function _classPrivateMethodInitSpec$1(obj, privateSet) { _checkPrivateRedeclaration$1(obj, privateSet); privateSet.add(obj); } 10899 function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration$1(obj, privateMap); privateMap.set(obj, value); } 10900 function _checkPrivateRedeclaration$1(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } } 10901 function _classPrivateMethodGet$1(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; } 10902 10903 // eslint-disable-next-line @bitrix24/bitrix24-rules/no-typeof 10904 const IS_WEAK_REF_SUPPORTED = typeof WeakRef !== 'undefined'; 10905 var _refs = /*#__PURE__*/new WeakMap(); 10906 var _registry = /*#__PURE__*/new WeakMap(); 10907 var _cleanupCallback = /*#__PURE__*/new WeakSet(); 10908 let WeakRefMap = /*#__PURE__*/function () { 10909 function WeakRefMap() { 10910 babelHelpers.classCallCheck(this, WeakRefMap); 10911 _classPrivateMethodInitSpec$1(this, _cleanupCallback); 10912 _classPrivateFieldInitSpec(this, _refs, { 10913 writable: true, 10914 value: new Map() 10915 }); 10916 _classPrivateFieldInitSpec(this, _registry, { 10917 writable: true, 10918 value: null 10919 }); 10920 if (IS_WEAK_REF_SUPPORTED) { 10921 babelHelpers.classPrivateFieldSet(this, _registry, new FinalizationRegistry(_classPrivateMethodGet$1(this, _cleanupCallback, _cleanupCallback2).bind(this))); 10922 } 10923 } 10924 babelHelpers.createClass(WeakRefMap, [{ 10925 key: "clear", 10926 value: function clear() { 10927 if (!IS_WEAK_REF_SUPPORTED) { 10928 babelHelpers.classPrivateFieldGet(this, _refs).clear(); 10929 return; 10930 }
10931 babelHelpers.classPrivateFieldGet(this, _refs).forEach((ref, key) => { 10932 const value = ref === null || ref === void 0 ? void 0 : ref.deref(); 10933 if (!Type.isUndefined(value)) { 10934 babelHelpers.classPrivateFieldGet(this, _registry).unregister(value); 10935 } 10936 }); 10937 babelHelpers.classPrivateFieldGet(this, _refs).clear(); 10938 } 10939 }, { 10940 key: "delete", 10941 value: function _delete(key) { 10942 if (!IS_WEAK_REF_SUPPORTED) { 10943 return babelHelpers.classPrivateFieldGet(this, _refs).delete(key); 10944 } 10945 const value = this.get(key); 10946 if (!Type.isUndefined(value)) { 10947 babelHelpers.classPrivateFieldGet(this, _registry).unregister(value); 10948 } 10949 return babelHelpers.classPrivateFieldGet(this, _refs).delete(key); 10950 } 10951 }, { 10952 key: "get", 10953 value: function get(key) { 10954 var _babelHelpers$classPr; 10955 if (!IS_WEAK_REF_SUPPORTED) { 10956 return babelHelpers.classPrivateFieldGet(this, _refs).get(key); 10957 } 10958 return (_babelHelpers$classPr = babelHelpers.classPrivateFieldGet(this, _refs).get(key)) === null || _babelHelpers$classPr === void 0 ? void 0 : _babelHelpers$classPr.deref(); 10959 } 10960 }, { 10961 key: "has", 10962 value: function has(key) { 10963 var _babelHelpers$classPr2; 10964 if (!IS_WEAK_REF_SUPPORTED) { 10965 return babelHelpers.classPrivateFieldGet(this, _refs).has(key); 10966 } 10967 return !Type.isUndefined((_babelHelpers$classPr2 = babelHelpers.classPrivateFieldGet(this, _refs).get(key)) === null || _babelHelpers$classPr2 === void 0 ? void 0 : _babelHelpers$classPr2.deref()); 10968 } 10969 }, { 10970 key: "set", 10971 value: function set(key, value) { 10972 if (!IS_WEAK_REF_SUPPORTED) { 10973 babelHelpers.classPrivateFieldGet(this, _refs).set(key, value); 10974 return this; 10975 } 10976 babelHelpers.classPrivateFieldGet(this, _refs).set(key, new WeakRef(value)); 10977 babelHelpers.classPrivateFieldGet(this, _registry).register(value, key, value); 10978 return this; 10979 } 10980 }]); 10981 return WeakRefMap; 10982 }(); 10983 function _cleanupCallback2(key) { 10984 const ref = babelHelpers.classPrivateFieldGet(this, _refs).get(key); 10985 if (ref && !ref.deref()) { 10986 babelHelpers.classPrivateFieldGet(this, _refs).delete(key); 10987 } 10988 } 10989 10990 var collections = { 10991 OrderedArray, 10992 SettingsCollection, 10993 WeakRefMap 10994 }; 10995 10996 function _classPrivateFieldInitSpec$1(obj, privateMap, value) { _checkPrivateRedeclaration$2(obj, privateMap); privateMap.set(obj, value); } 10997 function _checkPrivateRedeclaration$2(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } } 10998 function _classStaticPrivateMethodGet$1(receiver, classConstructor, method) { _classCheckPrivateStaticAccess$1(receiver, classConstructor); return method; } 10999 function _classCheckPrivateStaticAccess$1(receiver, classConstructor) { if (receiver !== classConstructor) { throw new TypeError("Private static access of wrong provenance"); } } 11000 var _easing = /*#__PURE__*/new WeakMap(); 11001 /** 11002 * @deprecated 11003 */ 11004 let FX = /*#__PURE__*/function () { 11005 function FX(options) { 11006 babelHelpers.classCallCheck(this, FX); 11007 _classPrivateFieldInitSpec$1(this, _easing, { 11008 writable: true, 11009 value: null 11010 }); 11011 const fxOptions = Type.isPlainObject(options) ? options : {}; 11012 const callback = Type.isFunction(fxOptions.callback) ? fxOptions.callback : null; 11013 const callbackStart = Type.isFunction(fxOptions.callback_start) ? fxOptions.callback_start : null; 11014 const callbackComplete = Type.isFunction(fxOptions.callback_complete) ? fxOptions.callback_complete : null; 11015 const easingOptions = { 11016 transition: 'linear', 11017 duration: Type.isNumber(fxOptions.time) && fxOptions.time > 0 ? fxOptions.time * 1000 : 1000, 11018 begin: state => { 11019 if (callbackStart !== null) { 11020 // eslint-disable-next-line no-underscore-dangle 11021 callbackStart(Type.isUndefined(state._param) ? state : state._param); 11022 } 11023 }, 11024 step: state => { 11025 if (callback !== null) { 11026 // eslint-disable-next-line no-underscore-dangle 11027 callback(Type.isUndefined(state._param) ? state : state._param); 11028 } 11029 }, 11030 complete: state => { 11031 if (callbackComplete !== null) { 11032 // eslint-disable-next-line no-underscore-dangle 11033 callbackComplete(Type.isUndefined(state._param) ? state : state._param); 11034 } 11035 } 11036 }; 11037 if (Type.isPlainObject(fxOptions.start)) { 11038 easingOptions.start = fxOptions.start; 11039 easingOptions.finish = fxOptions.finish; 11040 } else { 11041 easingOptions.start = { 11042 _param: fxOptions.start 11043 }; 11044 easingOptions.finish = { 11045 _param: fxOptions.finish 11046 }; 11047 } 11048 if (fxOptions.type === 'accelerated') { 11049 easingOptions.transition = 'quint'; 11050 } else if (fxOptions.type === 'decelerated') { 11051 fxOptions.transition = 'ease-out-quint'; 11052 } 11053 babelHelpers.classPrivateFieldSet(this, _easing, new Easing(easingOptions)); 11054 } 11055 babelHelpers.createClass(FX, [{ 11056 key: "start", 11057 value: function start() { 11058 babelHelpers.classPrivateFieldGet(this, _easing).animate(); 11059 return this; 11060 } 11061 }, { 11062 key: "stop", 11063 value: function stop(silent = false) { 11064 babelHelpers.classPrivateFieldGet(this, _easing).stop(silent); 11065 } 11066 }, { 11067 key: "pause", 11068 value: function pause() { 11069 // just for compatibility 11070 } 11071 /** 11072 * @deprecated 11073 */ 11074 }], [{ 11075 key: "hide", 11076 value: function hide(el, type, opts) { 11077 return _classStaticPrivateMethodGet$1(this, FX, _toggle).call(this, 'hide', el, type, opts); 11078 } 11079 /** 11080 * @deprecated 11081 */ 11082 }, { 11083 key: "show", 11084 value: function show(el, type, opts) { 11085 return _classStaticPrivateMethodGet$1(this, FX, _toggle).call(this, 'show', el, type, opts); 11086 } 11087 }]); 11088 return FX; 11089 }(); 11090 function _toggle(mode, el, type, opts) { 11091 let options = {}; 11092 let effect = null; 11093 const element = Type.isStringFilled(el) ? document.getElementById(el) : el; 11094 if (Type.isPlainObject(type) && Type.isNil(opts)) { 11095 options = type; 11096 effect = options.type; 11097 } else if (Type.isPlainObject(opts)) { 11098 options = opts; 11099 effect = type; 11100 } 11101 if (!Type.isStringFilled(effect)) { 11102 Dom.style(element, 'display', mode === 'show' ? 'block' : 'none'); 11103 return undefined; 11104 } 11105 const fxOptions = effect === 'scroll' ? _classStaticPrivateMethodGet$1(this, FX, _scroll).call(this, element, options, mode) : _classStaticPrivateMethodGet$1(this, FX, _fade).call(this, element, options, mode); 11106 fxOptions.callback_complete = () => { 11107 if (options.show !== false && options.hide !== false) { 11108 Dom.style(element, 'display', mode === 'show' ? 'block' : 'none'); 11109 } 11110 if (options.callback_complete) { 11111 options.callback_complete(); 11112 } 11113 }; 11114 return new FX(fxOptions).start(); 11115 } 11116 function _scroll(el, opts) { 11117 const param = opts.direction === 'horizontal' ? 'width' : 'height';
11118 let currentValue = parseInt(Dom.style(el, param), 10); 11119 if (Number.isNaN(currentValue)) { 11120 currentValue = Dom.getPosition(el)[param]; 11121 } 11122 const start = currentValue; 11123 const finish = opts.min_height ? parseInt(opts.min_height, 10) : 0; 11124 return { 11125 start, 11126 finish, 11127 time: opts.time || 1, 11128 type: 'linear', 11129 callback_start: () => { 11130 if (Dom.style(el, 'position') === 'static') { 11131 Dom.style(el, 'position', 'relative'); 11132 } 11133 Dom.style(el, 'overflow', 'hidden'); 11134 Dom.style(el, param, `${start}px`); 11135 Dom.style(el, 'display', 'block'); 11136 }, 11137 callback: value => { 11138 Dom.style(el, param, `${value}px`); 11139 } 11140 }; 11141 } 11142 function _fade(element, opts, mode) { 11143 return { 11144 time: opts.time || 1, 11145 type: mode === 'show' ? 'linear' : 'decelerated', 11146 start: mode === 'show' ? 0 : 100, 11147 finish: mode === 'show' ? 100 : 0, 11148 callback_start: () => { 11149 Dom.style(element, 'display', 'block'); 11150 }, 11151 callback: val => { 11152 Dom.style(element, 'opacity', val / 100); 11153 } 11154 }; 11155 } 11156 11157 let Transition = /*#__PURE__*/function () { 11158 function Transition() { 11159 babelHelpers.classCallCheck(this, Transition); 11160 } 11161 babelHelpers.createClass(Transition, null, [{ 11162 key: "linear", 11163 value: function linear(progress) { 11164 return progress; 11165 } 11166 }, { 11167 key: "quad", 11168 value: function quad(progress) { 11169 return progress ** 2; 11170 } 11171 }, { 11172 key: "cubic", 11173 value: function cubic(progress) { 11174 return progress ** 3; 11175 } 11176 }, { 11177 key: "quart", 11178 value: function quart(progress) { 11179 return progress ** 4; 11180 } 11181 }, { 11182 key: "quint", 11183 value: function quint(progress) { 11184 return progress ** 5; 11185 } 11186 }, { 11187 key: "circ", 11188 value: function circ(progress) { 11189 return 1 - Math.sin(Math.acos(progress)); 11190 } 11191 }, { 11192 key: "back", 11193 value: function back(progress) { 11194 return progress ** 2 * ((1.5 + 1) * progress - 1.5); 11195 } 11196 }, { 11197 key: "elasti", 11198 value: function elasti(progress) { 11199 return 2 ** (10 * (progress - 1)) * Math.cos(20 * Math.PI * 1.5 / 3 * progress); 11200 } 11201 }, { 11202 key: "bounce", 11203 value: function bounce(progress) { 11204 for (let a = 0, b = 1;; a += b, b /= 2) { 11205 if (progress >= (7 - 4 * a) / 11) { 11206 return -(((11 - 6 * a - 11 * progress) / 4) ** 2) + b ** 2; 11207 } 11208 } 11209 } 11210 }]); 11211 return Transition; 11212 }(); 11213 11214 function _classPrivateMethodInitSpec$2(obj, privateSet) { _checkPrivateRedeclaration$3(obj, privateSet); privateSet.add(obj); } 11215 function _classPrivateFieldInitSpec$2(obj, privateMap, value) { _checkPrivateRedeclaration$3(obj, privateMap); privateMap.set(obj, value); } 11216 function _checkPrivateRedeclaration$3(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } } 11217 function _classPrivateMethodGet$2(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; } 11218 var _duration = /*#__PURE__*/new WeakMap(); 11219 var _transition = /*#__PURE__*/new WeakMap(); 11220 var _begin = /*#__PURE__*/new WeakMap(); 11221 var _step = /*#__PURE__*/new WeakMap(); 11222 var _complete = /*#__PURE__*/new WeakMap(); 11223 var _start = /*#__PURE__*/new WeakMap(); 11224 var _finish = /*#__PURE__*/new WeakMap(); 11225 var _currentState = /*#__PURE__*/new WeakMap(); 11226 var _progress = /*#__PURE__*/new WeakMap(); 11227 var _timer = /*#__PURE__*/new WeakMap(); 11228 var _options = /*#__PURE__*/new WeakMap(); 11229 var _animate = /*#__PURE__*/new WeakSet(); 11230 let Easing = /*#__PURE__*/function () { 11231 function Easing(easingOptions) { 11232 babelHelpers.classCallCheck(this, Easing); 11233 _classPrivateMethodInitSpec$2(this, _animate); 11234 _classPrivateFieldInitSpec$2(this, _duration, { 11235 writable: true, 11236 value: 1000 11237 }); 11238 _classPrivateFieldInitSpec$2(this, _transition, { 11239 writable: true, 11240 value: Transition.linear 11241 }); 11242 _classPrivateFieldInitSpec$2(this, _begin, { 11243 writable: true, 11244 value: null 11245 }); 11246 _classPrivateFieldInitSpec$2(this, _step, { 11247 writable: true, 11248 value: null 11249 }); 11250 _classPrivateFieldInitSpec$2(this, _complete, { 11251 writable: true, 11252 value: null 11253 }); 11254 _classPrivateFieldInitSpec$2(this, _start, { 11255 writable: true, 11256 value: {} 11257 }); 11258 _classPrivateFieldInitSpec$2(this, _finish, { 11259 writable: true, 11260 value: {} 11261 }); 11262 _classPrivateFieldInitSpec$2(this, _currentState, { 11263 writable: true, 11264 value: {} 11265 }); 11266 _classPrivateFieldInitSpec$2(this, _progress, { 11267 writable: true, 11268 value: null 11269 }); 11270 _classPrivateFieldInitSpec$2(this, _timer, { 11271 writable: true, 11272 value: null 11273 }); 11274 _classPrivateFieldInitSpec$2(this, _options, { 11275 writable: true, 11276 value: null 11277 }); 11278 this.setOptions(easingOptions); 11279 } 11280 babelHelpers.createClass(Easing, [{ 11281 key: "setOptions", 11282 value: function setOptions(easingOptions) { 11283 const options = Type.isPlainObject(easingOptions) ? easingOptions : {}; 11284 babelHelpers.classPrivateFieldSet(this, _duration, Type.isNumber(options.duration) && options.duration > 0 ? options.duration : babelHelpers.classPrivateFieldGet(this, _duration)); 11285 babelHelpers.classPrivateFieldSet(this, _begin, Type.isFunction(options.begin) || options.begin === null ? options.begin : babelHelpers.classPrivateFieldGet(this, _begin)); 11286 babelHelpers.classPrivateFieldSet(this, _step, Type.isFunction(options.step) || options.step === null ? options.step : babelHelpers.classPrivateFieldGet(this, _step)); 11287 babelHelpers.classPrivateFieldSet(this, _complete, Type.isFunction(options.complete) || options.complete === null ? options.complete : babelHelpers.classPrivateFieldGet(this, _complete)); 11288 babelHelpers.classPrivateFieldSet(this, _progress, Type.isFunction(options.progress) || options.progress === null ? options.progress : babelHelpers.classPrivateFieldGet(this, _progress)); 11289 babelHelpers.classPrivateFieldSet(this, _start, Type.isPlainObject(options.start) ? {
11290 ...options.start 11291 } : babelHelpers.classPrivateFieldGet(this, _start)); 11292 babelHelpers.classPrivateFieldSet(this, _finish, Type.isPlainObject(options.finish) ? { 11293 ...options.finish 11294 } : babelHelpers.classPrivateFieldGet(this, _finish)); 11295 } 11296 }, { 11297 key: "setTransition", 11298 value: function setTransition(transition) { 11299 if (Type.isFunction(transition)) { 11300 babelHelpers.classPrivateFieldSet(this, _transition, transition); 11301 } else if (Type.isStringFilled(transition)) { 11302 let funcName = transition; 11303 let decorator = null; 11304 if (transition.startsWith('ease-out-')) { 11305 funcName = funcName.replace('ease-out-', ''); 11306 decorator = this.constructor.makeEaseOut; 11307 } else if (transition.startsWith('ease-in-out-')) { 11308 funcName = funcName.replace('ease-in-out-', ''); 11309 decorator = this.constructor.makeEaseInOut; 11310 } 11311 if (Type.isFunction(Transition[funcName])) { 11312 babelHelpers.classPrivateFieldSet(this, _transition, decorator === null ? Transition[funcName] : decorator(Transition[funcName])); 11313 } 11314 } 11315 } 11316 }, { 11317 key: "animateProgress", 11318 value: function animateProgress() { 11319 _classPrivateMethodGet$2(this, _animate, _animate2).call(this); 11320 } 11321 }, { 11322 key: "animate", 11323 value: function animate() { 11324 babelHelpers.classPrivateFieldSet(this, _progress, progress => { 11325 babelHelpers.classPrivateFieldSet(this, _currentState, {}); 11326 for (const propName of Object.keys(babelHelpers.classPrivateFieldGet(this, _start))) { 11327 babelHelpers.classPrivateFieldGet(this, _currentState)[propName] = Math.round(babelHelpers.classPrivateFieldGet(this, _start)[propName] + (babelHelpers.classPrivateFieldGet(this, _finish)[propName] - babelHelpers.classPrivateFieldGet(this, _start)[propName]) * progress); 11328 } 11329 if (babelHelpers.classPrivateFieldGet(this, _step) !== null) { 11330 babelHelpers.classPrivateFieldGet(this, _step).call(this, babelHelpers.classPrivateFieldGet(this, _currentState)); 11331 } 11332 }); 11333 _classPrivateMethodGet$2(this, _animate, _animate2).call(this); 11334 } 11335 }, { 11336 key: "stop", 11337 value: function stop(completed = false) { 11338 if (babelHelpers.classPrivateFieldGet(this, _timer) !== null) { 11339 cancelAnimationFrame(babelHelpers.classPrivateFieldGet(this, _timer)); 11340 babelHelpers.classPrivateFieldSet(this, _timer, null); 11341 if (completed && babelHelpers.classPrivateFieldGet(this, _complete) !== null) { 11342 babelHelpers.classPrivateFieldGet(this, _complete).call(this, babelHelpers.classPrivateFieldGet(this, _currentState)); 11343 } 11344 } 11345 } 11346 }, { 11347 key: "options", 11348 /** 11349 * @private 11350 * Compatible proxy for options 11351 */ 11352 get: function () { 11353 if (babelHelpers.classPrivateFieldGet(this, _options) === null) { 11354 babelHelpers.classPrivateFieldSet(this, _options, new Proxy(this, { 11355 get(target, property, receiver) { 11356 switch (property) { 11357 case 'transition': 11358 return babelHelpers.classPrivateFieldGet(this, _transition); 11359 case 'start': 11360 return babelHelpers.classPrivateFieldGet(this, _start); 11361 case 'finish': 11362 return babelHelpers.classPrivateFieldGet(this, _finish); 11363 case 'duration': 11364 return babelHelpers.classPrivateFieldGet(this, _duration); 11365 default: 11366 return null; 11367 } 11368 }, 11369 set(target, property, value, receiver) { 11370 target.setOptions({ 11371 [property]: value 11372 }); 11373 return true; 11374 } 11375 })); 11376 } 11377 return babelHelpers.classPrivateFieldGet(this, _options); 11378 } 11379 }], [{ 11380 key: "makeEaseInOut", 11381 value: function makeEaseInOut(delta) { 11382 return progress => { 11383 if (progress < 0.5) { 11384 return delta(2 * progress) / 2; 11385 } 11386 return (2 - delta(2 * (1 - progress))) / 2; 11387 }; 11388 } 11389 }, { 11390 key: "makeEaseOut", 11391 value: function makeEaseOut(delta) { 11392 return progress => { 11393 return 1 - delta(1 - progress); 11394 }; 11395 } 11396 }, { 11397 key: "transitions", 11398 get: function () { 11399 return Transition; 11400 } 11401 }]); 11402 return Easing; 11403 }(); 11404 function _animate2() {
11405 for (const propName of Object.keys(babelHelpers.classPrivateFieldGet(this, _start))) { 11406 if (Type.isUndefined(babelHelpers.classPrivateFieldGet(this, _finish)[propName])) { 11407 delete babelHelpers.classPrivateFieldGet(this, _start)[propName]; 11408 } 11409 } 11410 let start = null; 11411 const animation = time => { 11412 if (start === null) { 11413 start = time; 11414 } 11415 let progress = (time - start) / babelHelpers.classPrivateFieldGet(this, _duration); 11416 if (progress > 1) { 11417 progress = 1; 11418 } 11419 const delta = babelHelpers.classPrivateFieldGet(this, _transition).call(this, progress); 11420 babelHelpers.classPrivateFieldGet(this, _progress).call(this, delta); 11421 if (progress === 1) { 11422 this.stop(true); 11423 } else { 11424 babelHelpers.classPrivateFieldSet(this, _timer, requestAnimationFrame(animation)); 11425 } 11426 }; 11427 if (babelHelpers.classPrivateFieldGet(this, _begin) !== null) { 11428 babelHelpers.classPrivateFieldGet(this, _begin).call(this, babelHelpers.classPrivateFieldGet(this, _currentState)); 11429 } 11430 babelHelpers.classPrivateFieldSet(this, _timer, requestAnimationFrame(animation)); 11431 } 11432 11433 function _classPrivateMethodInitSpec$3(obj, privateSet) { _checkPrivateRedeclaration$4(obj, privateSet); privateSet.add(obj); } 11434 function _classPrivateFieldInitSpec$3(obj, privateMap, value) { _checkPrivateRedeclaration$4(obj, privateMap); privateMap.set(obj, value); } 11435 function _checkPrivateRedeclaration$4(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } } 11436 function _classPrivateMethodGet$3(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; } 11437 var _prefix = /*#__PURE__*/new WeakMap(); 11438 var _setPrefix = /*#__PURE__*/new WeakSet(); 11439 var _handleStorageChange = /*#__PURE__*/new WeakSet(); 11440 var _clear = /*#__PURE__*/new WeakSet(); 11441 var _encode = /*#__PURE__*/new WeakSet(); 11442 var _decode = /*#__PURE__*/new WeakSet(); 11443 var _getRealValue = /*#__PURE__*/new WeakSet(); 11444 var _parseValue = /*#__PURE__*/new WeakSet(); 11445 var _isValueValid = /*#__PURE__*/new WeakSet(); 11446 let LocalStorage = /*#__PURE__*/function () { 11447 function LocalStorage(storageOptions = {}) { 11448 babelHelpers.classCallCheck(this, LocalStorage); 11449 _classPrivateMethodInitSpec$3(this, _isValueValid); 11450 _classPrivateMethodInitSpec$3(this, _parseValue); 11451 _classPrivateMethodInitSpec$3(this, _getRealValue); 11452 _classPrivateMethodInitSpec$3(this, _decode); 11453 _classPrivateMethodInitSpec$3(this, _encode); 11454 _classPrivateMethodInitSpec$3(this, _clear); 11455 _classPrivateMethodInitSpec$3(this, _handleStorageChange); 11456 _classPrivateMethodInitSpec$3(this, _setPrefix); 11457 _classPrivateFieldInitSpec$3(this, _prefix, { 11458 writable: true, 11459 value: null 11460 }); 11461 const options = Type.isPlainObject(storageOptions) ? storageOptions : {}; 11462 _classPrivateMethodGet$3(this, _setPrefix, _setPrefix2).call(this, options.prefix); 11463 Event.bind(window, 'storage', _classPrivateMethodGet$3(this, _handleStorageChange, _handleStorageChange2).bind(this)); 11464 setInterval(_classPrivateMethodGet$3(this, _clear, _clear2).bind(this), 5000); 11465 } 11466 babelHelpers.createClass(LocalStorage, [{ 11467 key: "set", 11468 value: function set(key, value, ttl = 60) { 11469 if (!Type.isStringFilled(key) || Type.isNil(value)) { 11470 return false; 11471 } 11472 try { 11473 window.localStorage.setItem(this.getPrefix() + key, `${Math.round(Date.now() / 1000) + ttl}:${_classPrivateMethodGet$3(this, _encode, _encode2).call(this, value)}`); 11474 } catch { 11475 console.error('LocalStorage error', key, ttl); 11476 return false; 11477 } 11478 return true; 11479 } 11480 }, { 11481 key: "get", 11482 value: function get(key) { 11483 const storageValue = window.localStorage.getItem(this.getPrefix() + key); 11484 if (storageValue) { 11485 const valueParts = _classPrivateMethodGet$3(this, _parseValue, _parseValue2).call(this, storageValue); 11486 if (valueParts === null) { 11487 return null; 11488 } 11489 const [ttl, value] = valueParts; 11490 if (Date.now() <= ttl) { 11491 return _classPrivateMethodGet$3(this, _decode, _decode2).call(this, value); 11492 } 11493 this.remove(key); 11494 } 11495 return null; 11496 } 11497 }, { 11498 key: "remove", 11499 value: function remove(key) {
11500 window.localStorage.removeItem(this.getPrefix() + key); 11501 } 11502 }, { 11503 key: "getPrefix", 11504 value: function getPrefix() { 11505 if (babelHelpers.classPrivateFieldGet(this, _prefix) === null) { 11506 const userId = Loc.hasMessage('USER_ID') ? Loc.getMessage('USER_ID') : ''; 11507 const siteId = Loc.hasMessage('SITE_ID') ? Loc.getMessage('SITE_ID') : 'admin'; 11508 babelHelpers.classPrivateFieldSet(this, _prefix, `${this.getBasePrefix()}${userId}-${siteId}-`); 11509 } 11510 return babelHelpers.classPrivateFieldGet(this, _prefix); 11511 } 11512 }, { 11513 key: "getBasePrefix", 11514 value: function getBasePrefix() { 11515 return 'bx'; 11516 } 11517 }]); 11518 return LocalStorage; 11519 }(); 11520 function _setPrefix2(prefix) { 11521 if (Type.isString(prefix)) { 11522 babelHelpers.classPrivateFieldSet(this, _prefix, `${this.getBasePrefix()}-${prefix}`); 11523 } 11524 } 11525 function _handleStorageChange2(event) { 11526 if (!Type.isStringFilled(event.key) || !event.key.startsWith(this.getPrefix())) { 11527 return; 11528 } 11529 const key = event.key.slice(this.getPrefix().length); 11530 const value = _classPrivateMethodGet$3(this, _getRealValue, _getRealValue2).call(this, event.newValue); 11531 const oldValue = _classPrivateMethodGet$3(this, _getRealValue, _getRealValue2).call(this, event.oldValue); 11532 const data = { 11533 key, 11534 value, 11535 oldValue 11536 }; 11537 if (key === 'BXGCE') { 11538 // BX Global Custom Event 11539 if (value) { 11540 EventEmitter.emit(data.value.e, new BaseEvent({ 11541 data: data.value.p, 11542 compatData: data.value.p 11543 })); 11544 } 11545 } else { 11546 // normal event handlers 11547 if (event.newValue) { 11548 EventEmitter.emit('onLocalStorageSet', new BaseEvent({ 11549 data: [data], 11550 compatData: [data] 11551 })); 11552 } 11553 if (event.oldValue && !event.newValue) { 11554 EventEmitter.emit('onLocalStorageRemove', new BaseEvent({ 11555 data: [data], 11556 compatData: [data] 11557 })); 11558 } 11559 EventEmitter.emit('onLocalStorageChange', new BaseEvent({ 11560 data: [data], 11561 compatData: [data] 11562 })); 11563 } 11564 } 11565 function _clear2() { 11566 const curDate = Date.now(); 11567 for (let i = 0; i < window.localStorage.length; i++) { 11568 const key = window.localStorage.key(i); 11569 if (key.startsWith(this.getBasePrefix())) { 11570 const value = window.localStorage.getItem(key); 11571 const valueParts = _classPrivateMethodGet$3(this, _parseValue, _parseValue2).call(this, value); 11572 if (valueParts === null) { 11573 continue; 11574 } 11575 const [ttl] = valueParts; 11576 if (curDate >= ttl) { 11577 window.localStorage.removeItem(key); 11578 } 11579 } 11580 } 11581 } 11582 function _encode2(value) { 11583 if (Type.isJsonValue(value)) { 11584 return JSON.stringify(value); 11585 } 11586 return value.toString(); 11587 } 11588 function _decode2(value) { 11589 let result = null; 11590 if (Type.isStringFilled(value)) { 11591 try { 11592 result = JSON.parse(value); 11593 } catch { 11594 result = value; 11595 } 11596 } 11597 return result; 11598 } 11599 function _getRealValue2(value) { 11600 const valueParts = _classPrivateMethodGet$3(this, _parseValue, _parseValue2).call(this, value); 11601 if (valueParts === null) { 11602 return null; 11603 } 11604 return _classPrivateMethodGet$3(this, _decode, _decode2).call(this, valueParts[1]); 11605 } 11606 function _parseValue2(value) { 11607 if (!_classPrivateMethodGet$3(this, _isValueValid, _isValueValid2).call(this, value)) { 11608 return null; 11609 } 11610 const [ttl] = value.split(':', 1); 11611 const realValue = value.slice(ttl.length + 1); 11612 return [parseInt(ttl, 10) * 1000, realValue]; 11613 } 11614 function _isValueValid2(value) { 11615 return Type.isStringFilled(value) && /^\d{10}:/.test(value); 11616 } 11617 const localStorage$1 = new LocalStorage(); 11618 11619 function _classStaticPrivateMethodGet$2(receiver, classConstructor, method) { _classCheckPrivateStaticAccess$2(receiver, classConstructor); return method; } 11620 function _classCheckPrivateStaticAccess$2(receiver, classConstructor) { if (receiver !== classConstructor) { throw new TypeError("Private static access of wrong provenance"); } } 11621 let Page = /*#__PURE__*/function () { 11622 function Page() { 11623 babelHelpers.classCallCheck(this, Page); 11624 } 11625 babelHelpers.createClass(Page, null, [{ 11626 key: "getRootWindow", 11627 value: function getRootWindow() { 11628 return this.getTopWindowOfCurrentHost(window); 11629 } 11630 }, { 11631 key: "isCrossOriginObject", 11632 value: function isCrossOriginObject(currentWindow) { 11633 try { 11634 void currentWindow.location.host; 11635 } catch { 11636 // cross-origin object 11637 return true; 11638 } 11639 return false;
11640 } 11641 }, { 11642 key: "getTopWindowOfCurrentHost", 11643 value: function getTopWindowOfCurrentHost(currentWindow) { 11644 if (!this.isCrossOriginObject(currentWindow.parent) && currentWindow.parent !== currentWindow && currentWindow.parent.location.host === currentWindow.location.host) { 11645 return this.getTopWindowOfCurrentHost(currentWindow.parent); 11646 } 11647 return currentWindow; 11648 } 11649 }, { 11650 key: "getParentWindowOfCurrentHost", 11651 value: function getParentWindowOfCurrentHost(currentWindow) { 11652 if (this.isCrossOriginObject(currentWindow.parent)) { 11653 return currentWindow; 11654 } 11655 return currentWindow.parent; 11656 } 11657 }, { 11658 key: "redirect", 11659 value: function redirect(redirectUrl, redirectOptions = {}) { 11660 if (!Type.isStringFilled(redirectUrl)) { 11661 throw new Error('Redirect: "url" must be a non-empty string.'); 11662 } 11663 const rootWindow = this.getRootWindow(); 11664 let url = null; 11665 try { 11666 url = new URL(redirectUrl, rootWindow.location.origin); 11667 } catch { 11668 throw new Error(`Redirect: invalid URL: ${redirectUrl}`); 11669 } 11670 const options = Type.isPlainObject(redirectOptions) ? redirectOptions : {}; 11671 if (!_classStaticPrivateMethodGet$2(this, Page, _isSafeUrl).call(this, url, options.allowedOrigins)) { 11672 console.error(`Redirect: blocked potentially unsafe URL: ${url}`); 11673 return; 11674 } 11675 const wholeUrl = url.toString(); 11676 if (options.newTab === true) { 11677 const win = rootWindow.open(wholeUrl, '_blank', 'noopener,noreferrer'); 11678 if (win) { 11679 win.opener = null; 11680 } 11681 return; 11682 } 11683 if (options.replaceHistory === true) { 11684 rootWindow.location.replace(wholeUrl); 11685 } else { 11686 rootWindow.location.assign(wholeUrl); 11687 } 11688 } 11689 }, { 11690 key: "reload", 11691 value: function reload() { 11692 const rootWindow = this.getRootWindow(); 11693 rootWindow.location.reload(); 11694 } 11695 }]); 11696 return Page; 11697 }(); 11698 function _isSafeUrl(url, allowedOrigins = []) { 11699 if (!(url instanceof URL)) { 11700 return false; 11701 } 11702 const allowedProtocols = ['http:', 'https:']; 11703 if (!allowedProtocols.includes(url.protocol)) { 11704 return false; 11705 } 11706 const rootWindow = this.getRootWindow(); 11707 if (url.origin === rootWindow.location.origin) { 11708 return true; 11709 } 11710 if (Type.isArray(allowedOrigins) && allowedOrigins.length > 0) { 11711 return allowedOrigins.includes(url.origin); 11712 } 11713 return false; 11714 } 11715 11716 function getElement(element) { 11717 if (Type.isString(element)) { 11718 return document.getElementById(element); 11719 } 11720 return element; 11721 } 11722 11723 function getWindow(element) { 11724 if (Type.isElementNode(element)) { 11725 return element.ownerDocument.parentWindow || element.ownerDocument.defaultView || window; 11726 } 11727 if (Type.isDomNode(element)) { 11728 return element.parentWindow || element.defaultView || window; 11729 } 11730 return window; 11731 } 11732 11733 /* eslint-disable prefer-rest-params */ 11734 11735 // BX.* 11736 const { 11737 getClass, 11738 namespace 11739 } = Reflection; 11740 const message$1 = message; 11741 const easing = Easing; 11742 const fx = FX; 11743 const PageObject = Page; 11744 11745 /** 11746 * @memberOf BX 11747 */ 11748 const { 11749 replace, 11750 remove, 11751 clean, 11752 insertBefore, 11753 insertAfter, 11754 append, 11755 prepend, 11756 style, 11757 adjust, 11758 create, 11759 isShown 11760 } = Dom; 11761 const addClass = function addClass() { 11762 Dom.addClass(...Runtime.merge([], Array.from(arguments), [getElement(arguments[0])])); 11763 }; 11764 const removeClass = function removeClass() { 11765 Dom.removeClass(...Runtime.merge(Array.from(arguments), [getElement(arguments[0])])); 11766 }; 11767 const hasClass = function hasClass() { 11768 return Dom.hasClass(...Runtime.merge(Array.from(arguments), [getElement(arguments[0])])); 11769 }; 11770 const toggleClass = function toggleClass() { 11771 Dom.toggleClass(...Runtime.merge(Array.from(arguments), [getElement(arguments[0])])); 11772 }; 11773 const cleanNode = (element, removeElement = false) => { 11774 const currentElement = getElement(element); 11775 if (Type.isDomNode(currentElement)) { 11776 Dom.clean(currentElement); 11777 if (removeElement) { 11778 Dom.remove(currentElement); 11779 return currentElement; 11780 } 11781 } 11782 return currentElement; 11783 }; 11784 const getCookie = Http.Cookie.get;
11785 const setCookie = (name, value, options = {}) => { 11786 const attributes = { 11787 ...options 11788 }; 11789 if (Type.isNumber(attributes.expires)) { 11790 attributes.expires /= 3600 * 24; 11791 } 11792 Http.Cookie.set(name, value, attributes); 11793 }; 11794 const { 11795 bind: bind$1, 11796 unbind: unbind$1, 11797 unbindAll: unbindAll$1, 11798 bindOnce: bindOnce$1, 11799 ready: ready$1 11800 } = Event; 11801 const { 11802 debugState: debugEnableFlag, 11803 isDebugEnabled: debugStatus, 11804 default: debug$1 11805 } = debugNs; 11806 const debugEnable = value => { 11807 if (value) { 11808 enableDebug(); 11809 } else { 11810 disableDebug(); 11811 } 11812 }; 11813 const { 11814 clone: clone$1, 11815 loadExtension: loadExt, 11816 debounce, 11817 throttle, 11818 html 11819 } = Runtime; 11820 11821 // BX.type 11822 const type = { 11823 ...Object.getOwnPropertyNames(Type).filter(key => !['name', 'length', 'prototype', 'caller', 'arguments'].includes(key)).reduce((acc, key) => { 11824 acc[key] = Type[key]; 11825 return acc; 11826 }, {}), 11827 isNotEmptyString: value => Type.isString(value) && value !== '', 11828 isNotEmptyObject: value => Type.isObjectLike(value) && Object.keys(value).length > 0, 11829 isMapKey: Type.isObject, 11830 stringToInt: value => { 11831 const parsed = parseInt(value); 11832 return !Number.isNaN(parsed) ? parsed : 0; 11833 } 11834 }; 11835 11836 // BX.browser 11837 const browser = { 11838 IsOpera: Browser.isOpera, 11839 IsIE: Browser.isIE, 11840 IsIE6: Browser.isIE6, 11841 IsIE7: Browser.isIE7, 11842 IsIE8: Browser.isIE8, 11843 IsIE9: Browser.isIE9, 11844 IsIE10: Browser.isIE10, 11845 IsIE11: Browser.isIE11, 11846 IsSafari: Browser.isSafari, 11847 IsFirefox: Browser.isFirefox, 11848 IsChrome: Browser.isChrome, 11849 DetectIeVersion: Browser.detectIEVersion, 11850 IsMac: Browser.isMac, 11851 IsAndroid: Browser.isAndroid, 11852 isIPad: Browser.isIPad, 11853 isIPhone: Browser.isIPhone, 11854 IsIOS: Browser.isIOS, 11855 IsMobile: Browser.isMobile, 11856 isRetina: Browser.isRetina, 11857 IsDoctype: Browser.isDoctype, 11858 SupportLocalStorage: Browser.isLocalStorageSupported, 11859 addGlobalClass: Browser.addGlobalClass, 11860 DetectAndroidVersion: Browser.detectAndroidVersion, 11861 isPropertySupported: Browser.isPropertySupported, 11862 addGlobalFeatures: Browser.addGlobalFeatures 11863 }; 11864 11865 // eslint-disable-next-line 11866 const ajax = window.BX ? window.BX.ajax : () => {}; 11867 function GetWindowScrollSize(doc = document) { 11868 return { 11869 scrollWidth: doc.documentElement.scrollWidth, 11870 scrollHeight: doc.documentElement.scrollHeight 11871 }; 11872 } 11873 function GetWindowScrollPos(doc = document) { 11874 const win = getWindow(doc); 11875 return { 11876 scrollLeft: win.pageXOffset, 11877 scrollTop: win.pageYOffset 11878 }; 11879 } 11880 function GetWindowInnerSize(doc = document) { 11881 const win = getWindow(doc); 11882 return { 11883 innerWidth: win.innerWidth, 11884 innerHeight: win.innerHeight 11885 }; 11886 } 11887 function GetWindowSize(doc = document) { 11888 return { 11889 ...GetWindowInnerSize(doc), 11890 ...GetWindowScrollPos(doc), 11891 ...GetWindowScrollSize(doc) 11892 }; 11893 } 11894 function GetContext(node) { 11895 return getWindow(node); 11896 } 11897 function pos(element, relative = false) { 11898 if (!element) { 11899 return new DOMRect().toJSON(); 11900 } 11901 if (element.ownerDocument === document && !relative) { 11902 const clientRect = element.getBoundingClientRect(); 11903 const root = document.documentElement; 11904 const { 11905 body 11906 } = document; 11907 return { 11908 top: Math.round(clientRect.top + (root.scrollTop || body.scrollTop)), 11909 left: Math.round(clientRect.left + (root.scrollLeft || body.scrollLeft)), 11910 width: Math.round(clientRect.right - clientRect.left), 11911 height: Math.round(clientRect.bottom - clientRect.top), 11912 right: Math.round(clientRect.right + (root.scrollLeft || body.scrollLeft)), 11913 bottom: Math.round(clientRect.bottom + (root.scrollTop || body.scrollTop)) 11914 }; 11915 } 11916 let x = 0; 11917 let y = 0; 11918 const w = element.offsetWidth; 11919 const h = element.offsetHeight; 11920 let first = true; 11921 11922 // eslint-disable-next-line no-param-reassign 11923 for (; element != null; element = element.offsetParent) { 11924 if (!first && relative && BX.is_relative(element)) { 11925 break; 11926 } 11927 x += element.offsetLeft; 11928 y += element.offsetTop; 11929 if (first) { 11930 first = false; 11931 // eslint-disable-next-line no-continue 11932 continue; 11933 } 11934 x += Text.toNumber(Dom.style(element, 'border-left-width')); 11935 y += Text.toNumber(Dom.style(element, 'border-top-width')); 11936 } 11937 return new DOMRect(x, y, w, h).toJSON(); 11938 } 11939 function addCustomEvent(eventObject, eventName, eventHandler) { 11940 if (Type.isString(eventObject)) { 11941 eventHandler = eventName; 11942 eventName = eventObject; 11943 eventObject = EventEmitter.GLOBAL_TARGET;
11944 } 11945 if (eventObject === window) { 11946 eventObject = EventEmitter.GLOBAL_TARGET; 11947 } 11948 if (!Type.isObject(eventObject)) { 11949 console.error('The "eventObject" argument must be an object. Received type ' + typeof eventObject + '.'); 11950 return; 11951 } 11952 if (!Type.isStringFilled(eventName)) { 11953 console.error('The "eventName" argument must be a string.'); 11954 return; 11955 } 11956 if (!Type.isFunction(eventHandler)) { 11957 console.error('The "eventHandler" argument must be a function. Received type ' + typeof eventHandler + '.'); 11958 return; 11959 } 11960 eventName = eventName.toLowerCase(); 11961 EventEmitter.subscribe(eventObject, eventName, eventHandler, { 11962 compatMode: true, 11963 useGlobalNaming: true 11964 }); 11965 } 11966 function onCustomEvent(eventObject, eventName, eventParams, secureParams) { 11967 if (Type.isString(eventObject)) { 11968 secureParams = eventParams; 11969 eventParams = eventName; 11970 eventName = eventObject; 11971 eventObject = EventEmitter.GLOBAL_TARGET; 11972 } 11973 if (!Type.isObject(eventObject) || eventObject === window) { 11974 eventObject = EventEmitter.GLOBAL_TARGET;
11975 } 11976 if (!eventParams) { 11977 eventParams = []; 11978 } 11979 eventName = eventName.toLowerCase(); 11980 const event = new BaseEvent(); 11981 event.setData(eventParams); 11982 event.setCompatData(eventParams); 11983 EventEmitter.emit(eventObject, eventName, event, { 11984 cloneData: secureParams === true, 11985 useGlobalNaming: true 11986 }); 11987 } 11988 function removeCustomEvent(eventObject, eventName, eventHandler) { 11989 if (Type.isString(eventObject)) { 11990 eventHandler = eventName; 11991 eventName = eventObject; 11992 eventObject = EventEmitter.GLOBAL_TARGET; 11993 } 11994 if (!Type.isFunction(eventHandler)) { 11995 console.error('The "eventHandler" argument must be a function. Received type ' + typeof eventHandler + '.'); 11996 return; 11997 } 11998 if (eventObject === window) { 11999 eventObject = EventEmitter.GLOBAL_TARGET; 12000 } 12001 eventName = eventName.toLowerCase(); 12002 EventEmitter.unsubscribe(eventObject, eventName, eventHandler, { 12003 useGlobalNaming: true 12004 }); 12005 } 12006 function removeAllCustomEvents(eventObject, eventName) { 12007 if (Type.isString(eventObject)) { 12008 eventName = eventObject; 12009 eventObject = EventEmitter.GLOBAL_TARGET;
12010 } 12011 if (eventObject === window) { 12012 eventObject = EventEmitter.GLOBAL_TARGET; 12013 } 12014 eventName = eventName.toLowerCase(); 12015 EventEmitter.unsubscribeAll(eventObject, eventName, { 12016 useGlobalNaming: true 12017 }); 12018 } 12019 function onGlobalCustomEvent(eventName, arEventParams, bSkipSelf) { 12020 localStorage$1.set('BXGCE', { 12021 e: eventName, 12022 p: arEventParams 12023 }, 1); 12024 if (!bSkipSelf) { 12025 onCustomEvent(eventName, arEventParams); 12026 } 12027 } 12028 12029 if (typeof global === 'object' && global.window && global.window.BX) { 12030 Object.assign(global.window.BX, exports); 12031 } 12032 12033 exports.Type = Type; 12034 exports.Reflection = Reflection; 12035 exports.Text = Text; 12036 exports.Dom = Dom; 12037 exports.Browser = Browser; 12038 exports.Event = Event; 12039 exports.Http = Http; 12040 exports.Runtime = Runtime; 12041 exports.Loc = Loc; 12042 exports.Tag = Tag; 12043 exports.Uri = Uri; 12044 exports.Validation = Validation; 12045 exports.Cache = Cache; 12046 exports.BaseError = BaseError; 12047 exports.Extension = Extension; 12048 exports.ZIndexManager = ZIndexManager; 12049 exports.Collections = collections; 12050 exports.Easing = Easing; 12051 exports.LocalStorage = LocalStorage; 12052 exports.localStorage = localStorage$1; 12053 exports.Page = Page; 12054 exports.getClass = getClass; 12055 exports.namespace = namespace; 12056 exports.message = message$1; 12057 exports.easing = easing; 12058 exports.fx = fx; 12059 exports.PageObject = PageObject; 12060 exports.replace = replace; 12061 exports.remove = remove; 12062 exports.clean = clean; 12063 exports.insertBefore = insertBefore; 12064 exports.insertAfter = insertAfter; 12065 exports.append = append; 12066 exports.prepend = prepend; 12067 exports.style = style; 12068 exports.adjust = adjust; 12069 exports.create = create; 12070 exports.isShown = isShown; 12071 exports.addClass = addClass; 12072 exports.removeClass = removeClass; 12073 exports.hasClass = hasClass; 12074 exports.toggleClass = toggleClass; 12075 exports.cleanNode = cleanNode; 12076 exports.getCookie = getCookie; 12077 exports.setCookie = setCookie; 12078 exports.bind = bind$1; 12079 exports.unbind = unbind$1; 12080 exports.unbindAll = unbindAll$1; 12081 exports.bindOnce = bindOnce$1; 12082 exports.ready = ready$1; 12083 exports.debugEnableFlag = debugEnableFlag; 12084 exports.debugStatus = debugStatus; 12085 exports.debug = debug$1; 12086 exports.debugEnable = debugEnable; 12087 exports.clone = clone$1; 12088 exports.loadExt = loadExt; 12089 exports.debounce = debounce; 12090 exports.throttle = throttle; 12091 exports.html = html; 12092 exports.type = type; 12093 exports.browser = browser; 12094 exports.ajax = ajax; 12095 exports.GetWindowScrollSize = GetWindowScrollSize; 12096 exports.GetWindowScrollPos = GetWindowScrollPos; 12097 exports.GetWindowInnerSize = GetWindowInnerSize; 12098 exports.GetWindowSize = GetWindowSize; 12099 exports.GetContext = GetContext; 12100 exports.pos = pos; 12101 exports.addCustomEvent = addCustomEvent; 12102 exports.onCustomEvent = onCustomEvent; 12103 exports.removeCustomEvent = removeCustomEvent; 12104 exports.removeAllCustomEvents = removeAllCustomEvents; 12105 exports.onGlobalCustomEvent = onGlobalCustomEvent; 12106 12107}((this.BX = this.BX || {}))); 12108 12109 12110 12111(function(BX) { 12112 /* list of registered proxy functions */ 12113 var proxyList = new WeakMap(); 12114 var deferList = new WeakMap(); 12115 12116 /* List of denied event handlers */ 12117 var deniedEvents = []; 12118 12119 /* list of registered custom events */ 12120 var customEvents = new WeakMap(); 12121 var customEventsCnt = 0; 12122 12123 /* list of external garbage collectors */ 12124 var garbageCollectors = []; 12125 12126 /* list of loaded CSS files */ 12127 var cssList = []; 12128 var cssInit = false; 12129 12130 /* list of loaded JS files */ 12131 var jsList = []; 12132 var jsInit = false; 12133 12134 var eventTypes = { 12135 click: 'MouseEvent', 12136 dblclick: 'MouseEvent', 12137 mousedown: 'MouseEvent', 12138 mousemove: 'MouseEvent', 12139 mouseout: 'MouseEvent', 12140 mouseover: 'MouseEvent', 12141 mouseup: 'MouseEvent', 12142 focus: 'MouseEvent', 12143 blur: 'MouseEvent' 12144 }; 12145 12146 var lastWait = []; 12147 12148 var CHECK_FORM_ELEMENTS = {tagName: /^INPUT|SELECT|TEXTAREA|BUTTON$/i}; 12149 12150 BX.MSLEFT = 1; 12151 BX.MSMIDDLE = 2; 12152 BX.MSRIGHT = 4; 12153 12154 BX.AM_PM_UPPER = 1; 12155 BX.AM_PM_LOWER = 2; 12156 BX.AM_PM_NONE = false; 12157 12158 BX.ext = function(ob) 12159 { 12160 for (var i in ob) 12161 { 12162 if(ob.hasOwnProperty(i)) 12163 { 12164 this[i] = ob[i]; 12165 } 12166 } 12167 }; 12168 12169 var r = { 12170 script: /<script([^>]*)>/ig, 12171 script_end: /<\/script>/ig, 12172 script_src: /src=["\']([^"\']+)["\']/i, 12173 script_type: /type=["\']([^"\']+)["\']/i, 12174 space: /\s+/, 12175 ltrim: /^[\s\r\n]+/g,
12176 rtrim: /[\s\r\n]+$/g, 12177 style: /<link[^>]*?(rel="stylesheet"|type="text\/css")[^>]*>/i, 12178 style_href: /href=["\']([^"\']+)["\']/i 12179 }; 12180 12181 BX.processHTML = function(data, scriptsRunFirst) 12182 { 12183 var matchScript, matchStyle, matchSrc, matchHref, matchType, scripts = [], styles = []; 12184 var textIndexes = []; 12185 var lastIndex = r.script.lastIndex = r.script_end.lastIndex = 0; 12186 12187 while ((matchScript = r.script.exec(data)) !== null) 12188 { 12189 r.script_end.lastIndex = r.script.lastIndex; 12190 var matchScriptEnd = r.script_end.exec(data); 12191 if (matchScriptEnd === null) 12192 { 12193 break; 12194 } 12195 12196 // skip script tags of special types 12197 var skipTag = false; 12198 if ((matchType = matchScript[1].match(r.script_type)) !== null) 12199 { 12200 if( 12201 matchType[1] == 'text/html' 12202 || matchType[1] == 'text/template' 12203 || matchType[1] == 'extension/settings' 12204 ) 12205 { 12206 skipTag = true; 12207 } 12208 } 12209 12210 if(skipTag) 12211 { 12212 textIndexes.push([lastIndex, r.script_end.lastIndex - lastIndex]); 12213 } 12214 else 12215 { 12216 textIndexes.push([lastIndex, matchScript.index - lastIndex]); 12217 12218 var bRunFirst = scriptsRunFirst || (matchScript[1].indexOf('bxrunfirst') != '-1'); 12219 12220 if ((matchSrc = matchScript[1].match(r.script_src)) !== null) 12221 { 12222 scripts.push({"bRunFirst": bRunFirst, "isInternal": false, "JS": matchSrc[1]}); 12223 } 12224 else 12225 { 12226 var start = matchScript.index + matchScript[0].length; 12227 var js = data.substr(start, matchScriptEnd.index-start); 12228 12229 scripts.push({"bRunFirst": bRunFirst, "isInternal": true, "JS": js}); 12230 } 12231 } 12232 12233 lastIndex = matchScriptEnd.index + 9; 12234 r.script.lastIndex = lastIndex; 12235 } 12236 12237 textIndexes.push([lastIndex, lastIndex === 0 ? data.length : data.length - lastIndex]); 12238 var pureData = ""; 12239 for (var i = 0, length = textIndexes.length; i < length; i++) 12240 { 12241 if (BX.type.isString(data) && BX.type.isFunction(data.substr)) 12242 { 12243 pureData += data.substr(textIndexes[i][0], textIndexes[i][1]); 12244 } 12245 } 12246 12247 while ((matchStyle = pureData.match(r.style)) !== null) 12248 { 12249 if ((matchHref = matchStyle[0].match(r.style_href)) !== null && matchStyle[0].indexOf('media="') < 0) 12250 { 12251 styles.push(matchHref[1]); 12252 } 12253 12254 pureData = pureData.replace(matchStyle[0], ''); 12255 } 12256 12257 return {'HTML': pureData, 'SCRIPT': scripts, 'STYLE': styles}; 12258 }; 12259 12260 /* OO emulation utility */ 12261 BX.extend = function(child, parent) 12262 { 12263 var f = function() {}; 12264 f.prototype = parent.prototype; 12265 12266 child.prototype = new f(); 12267 child.prototype.constructor = child; 12268 12269 child.superclass = parent.prototype; 12270 child.prototype.superclass = parent.prototype; 12271 if(parent.prototype.constructor == Object.prototype.constructor) 12272 { 12273 parent.prototype.constructor = parent; 12274 } 12275 }; 12276 12277 BX.is_subclass_of = function(ob, parent_class) 12278 { 12279 if (ob instanceof parent_class) 12280 return true; 12281 12282 if (parent_class.superclass) 12283 return BX.is_subclass_of(ob, parent_class.superclass); 12284 12285 return false; 12286 }; 12287 12288 BX.clearNodeCache = function() 12289 { 12290 return false; 12291 }; 12292 12293 BX.bitrix_sessid = function() {return BX.message("bitrix_sessid"); }; 12294 12295 /** 12296 * Creates document fragment with child nodes. 12297 * 12298 * @param {Node[]} nodes 12299 * @return {DocumentFragment} 12300 */ 12301 BX.createFragment = function(nodes) 12302 { 12303 var fragment = document.createDocumentFragment(); 12304 12305 if(!BX.type.isArray(nodes)) 12306 { 12307 return fragment; 12308 } 12309 for(var i = 0; i < nodes.length; i++) 12310 { 12311 fragment.appendChild(nodes[i]); 12312 } 12313 12314 return fragment; 12315 }; 12316 12317 /** 12318 * @deprecated 12319 * @use BX.style 12320 * @param element 12321 * @param opacity 12322 */ 12323 BX.setOpacity = function(element, opacity) 12324 { 12325 var opacityValue = parseFloat(opacity); 12326 12327 if (!isNaN(opacityValue) && BX.type.isDomNode(element)) 12328 { 12329 opacityValue = opacityValue < 1 ? opacityValue : opacityValue / 100; 12330 BX.style(element, 'opacity', opacityValue); 12331 } 12332 }; 12333 12334 /** 12335 * @deprecated 12336 * @param el 12337 * @return {*} 12338 */ 12339 BX.hoverEvents = function(el) 12340 { 12341 if (el) 12342 return BX.adjust(el, {events: BX.hoverEvents()}); 12343 else 12344 return {mouseover: BX.hoverEventsHover, mouseout: BX.hoverEventsHout}; 12345 }; 12346 12347 /** 12348 * @deprecated 12349 */ 12350 BX.hoverEventsHover = function(){BX.addClass(this,'bx-hover');this.BXHOVER=true;}; 12351 /** 12352 * @deprecated 12353 */ 12354 BX.hoverEventsHout = function(){BX.removeClass(this,'bx-hover');this.BXHOVER=false;}; 12355 12356 /** 12357 * @deprecated 12358 */ 12359 BX.focusEvents = function(el) 12360 { 12361 if (el) 12362 return BX.adjust(el, {events: BX.focusEvents()}); 12363 else 12364 return {mouseover: BX.focusEventsFocus, mouseout: BX.focusEventsBlur}; 12365 }; 12366 12367 /** 12368 * @deprecated 12369 */ 12370 BX.focusEventsFocus = function(){BX.addClass(this,'bx-focus');this.BXFOCUS=true;}; 12371 /** 12372 * @deprecated 12373 */ 12374 BX.focusEventsBlur = function(){BX.removeClass(this,'bx-focus');this.BXFOCUS=false;}; 12375 12376 BX.setUnselectable = function(node) 12377 { 12378 BX.style(node, { 12379 'userSelect': 'none', 12380 'MozUserSelect': 'none', 12381 'WebkitUserSelect': 'none', 12382 'KhtmlUserSelect': 'none', 12383 }); 12384 node.setAttribute('unSelectable', 'on'); 12385 }; 12386 12387 BX.setSelectable = function(node) 12388 { 12389 BX.style(node, { 12390 'userSelect': null, 12391 'MozUserSelect': null, 12392 'WebkitUserSelect': null, 12393 'KhtmlUserSelect': null, 12394 }); 12395 node.removeAttribute('unSelectable'); 12396 }; 12397 12398 BX.styleIEPropertyName = function(name) 12399 { 12400 if (name == 'float') 12401 name = BX.browser.IsIE() ? 'styleFloat' : 'cssFloat'; 12402 else 12403 { 12404 var res = BX.browser.isPropertySupported(name); 12405 if (res) 12406 { 12407 name = res; 12408 } 12409 else 12410 {
12411 var reg = /(\-([a-z]){1})/g; 12412 if (reg.test(name)) 12413 { 12414 name = name.replace(reg, function () {return arguments[2].toUpperCase();}); 12415 } 12416 } 12417 } 12418 return name; 12419 }; 12420 12421 BX.focus = function(el) 12422 { 12423 try 12424 { 12425 el.focus(); 12426 return true; 12427 } 12428 catch (e) 12429 { 12430 return false; 12431 } 12432 }; 12433 12434 BX.firstChild = function(el) 12435 { 12436 return BX.type.isDomNode(el) ? el.firstElementChild : null; 12437 }; 12438 12439 BX.lastChild = function(el) 12440 { 12441 return BX.type.isDomNode(el) ? el.lastElementChild : null; 12442 }; 12443 12444 BX.previousSibling = function(el) 12445 { 12446 return BX.type.isDomNode(el) ? el.previousElementSibling : null; 12447 }; 12448 12449 BX.nextSibling = function(el) 12450 { 12451 return BX.type.isDomNode(el) ? el.nextElementSibling : null; 12452 }; 12453 12454 /* 12455 params: { 12456 obj : html node 12457 className : className value 12458 recursive : used only for older browsers to optimize the tree traversal, in new browsers the search is always recursively, default - true 12459 } 12460 12461 Search all nodes with className 12462 */ 12463 /** 12464 * @deprecated 12465 * @use .querySelectorAll 12466 * @param obj 12467 * @param className 12468 * @param recursive 12469 * @return {*} 12470 */ 12471 BX.findChildrenByClassName = function(obj, className, recursive) 12472 { 12473 if(!obj || !obj.childNodes) return null; 12474 12475 var result = []; 12476 if (typeof(obj.getElementsByClassName) == 'undefined') 12477 { 12478 recursive = recursive !== false; 12479 result = BX.findChildren(obj, {className : className}, recursive); 12480 } 12481 else 12482 { 12483 var col = obj.getElementsByClassName(className); 12484 for (i=0,l=col.length;i<l;i++) 12485 { 12486 result[i] = col[i]; 12487 } 12488 } 12489 return result; 12490 }; 12491 12492 /* 12493 params: { 12494 obj : html node 12495 className : className value 12496 recursive : used only for older browsers to optimize the tree traversal, in new browsers the search is always recursively, default - true 12497 } 12498 12499 Search first node with className 12500 */ 12501 /** 12502 * @deprecated 12503 * @use .querySelector 12504 * @param obj 12505 * @param className 12506 * @param recursive 12507 * @return {*} 12508 */ 12509 BX.findChildByClassName = function(obj, className, recursive) 12510 { 12511 if(!obj || !obj.childNodes) return null; 12512 12513 var result = null; 12514 if (typeof(obj.getElementsByClassName) == 'undefined') 12515 { 12516 recursive = recursive !== false; 12517 result = BX.findChild(obj, {className : className}, recursive); 12518 } 12519 else 12520 { 12521 var col = obj.getElementsByClassName(className); 12522 if (col && typeof(col[0]) != 'undefined') 12523 { 12524 result = col[0]; 12525 } 12526 else 12527 { 12528 result = null; 12529 } 12530 } 12531 return result; 12532 }; 12533 12534 /* 12535 params: { 12536 tagName|tag : 'tagName', 12537 className|class : 'className', 12538 attribute : {attribute : value, attribute : value} | attribute | [attribute, attribute....], 12539 property : {prop: value, prop: value} | prop | [prop, prop] 12540 } 12541 12542 all values can be RegExps or strings 12543 */ 12544 /** 12545 * @deprecated 12546 * @use .querySelectorAll 12547 * @param obj 12548 * @param params 12549 * @param recursive 12550 * @return {*|Node} 12551 */ 12552 BX.findChildren = function(obj, params, recursive) 12553 { 12554 return BX.findChild(obj, params, recursive, true); 12555 }; 12556 12557 /** 12558 * @deprecated 12559 * @use .querySelectorAll 12560 * @param obj 12561 * @param params 12562 * @param recursive 12563 * @param get_all 12564 * @return {*} 12565 */ 12566 BX.findChild = function(obj, params, recursive, get_all) 12567 { 12568 if(!obj || !obj.childNodes) return null; 12569 12570 recursive = !!recursive; get_all = !!get_all; 12571 12572 var n = obj.childNodes.length, result = []; 12573 12574 for (var j=0; j<n; j++) 12575 { 12576 var child = obj.childNodes[j]; 12577 12578 if (_checkNode(child, params)) 12579 { 12580 if (get_all) 12581 result.push(child); 12582 else 12583 return child; 12584 } 12585 12586 if(recursive == true) 12587 { 12588 var res = BX.findChild(child, params, recursive, get_all); 12589 if (res) 12590 { 12591 if (get_all) 12592 result = BX.util.array_merge(result, res); 12593 else 12594 return res; 12595 } 12596 } 12597 } 12598 12599 if (get_all || result.length > 0) 12600 return result; 12601 else 12602 return null; 12603 }; 12604 12605 /** 12606 * @deprecated 12607 * @use .closest() 12608 * @param obj 12609 * @param params 12610 * @param maxParent 12611 * @return {*} 12612 */ 12613 BX.findParent = function(obj, params, maxParent) 12614 { 12615 if(!obj) 12616 return null; 12617 12618 var o = obj; 12619 while(o.parentNode) 12620 { 12621 var parent = o.parentNode; 12622 12623 if (_checkNode(parent, params)) 12624 return parent; 12625 12626 o = parent; 12627 12628 if (!!maxParent &&
12629 (BX.type.isFunction(maxParent) 12630 || typeof maxParent == 'object')) 12631 { 12632 if (BX.type.isElementNode(maxParent)) 12633 { 12634 if (o == maxParent) 12635 break; 12636 } 12637 else 12638 { 12639 if (_checkNode(o, maxParent)) 12640 break; 12641 } 12642 } 12643 } 12644 return null; 12645 }; 12646 12647 /** 12648 * @deprecated 12649 * @use .querySelector 12650 * @param obj 12651 * @param params 12652 * @return {*} 12653 */ 12654 BX.findNextSibling = function(obj, params) 12655 { 12656 if(!obj) 12657 return null; 12658 var o = obj; 12659 while(o.nextSibling) 12660 { 12661 var sibling = o.nextSibling; 12662 if (_checkNode(sibling, params)) 12663 return sibling; 12664 o = sibling; 12665 } 12666 return null; 12667 }; 12668 12669 /** 12670 * @deprecated 12671 * @use .querySelector 12672 * @param obj 12673 * @param params 12674 * @return {*} 12675 */ 12676 BX.findPreviousSibling = function(obj, params) 12677 { 12678 if(!obj) 12679 return null; 12680 12681 var o = obj; 12682 while(o.previousSibling) 12683 { 12684 var sibling = o.previousSibling; 12685 if(_checkNode(sibling, params)) 12686 return sibling; 12687 o = sibling; 12688 } 12689 return null; 12690 }; 12691 12692 BX.checkNode = function(obj, params) 12693 { 12694 return _checkNode(obj, params); 12695 }; 12696 12697 /** 12698 * @deprecated 12699 * @use .querySelectorAll 12700 * @param form 12701 * @return {Array} 12702 */ 12703 BX.findFormElements = function(form) 12704 { 12705 if (BX.type.isString(form)) 12706 form = document.forms[form]||BX(form); 12707 12708 var res = []; 12709 12710 if (BX.type.isElementNode(form)) 12711 { 12712 if (form.tagName.toUpperCase() == 'FORM') 12713 { 12714 res = form.elements; 12715 } 12716 else 12717 { 12718 res = BX.findChildren(form, CHECK_FORM_ELEMENTS, true); 12719 } 12720 } 12721 12722 return res; 12723 }; 12724 12725 /** 12726 * @deprecated 12727 * @use .contains() 12728 * @param whichNode 12729 * @param forNode 12730 * @return {boolean} 12731 */ 12732 BX.isParentForNode = function(whichNode, forNode) 12733 { 12734 if (BX.type.isDomNode(whichNode) && BX.type.isDomNode(forNode)) 12735 { 12736 return whichNode.contains(forNode); 12737 } 12738 12739 return false; 12740 }; 12741 12742 BX.getCaretPosition = function(node) 12743 { 12744 var pos = 0; 12745 12746 if(node.selectionStart || node.selectionStart == 0) 12747 { 12748 pos = node.selectionStart; 12749 } 12750 else if(document.selection) 12751 { 12752 node.focus(); 12753 var selection = document.selection.createRange(); 12754 selection.moveStart('character', -node.value.length); 12755 pos = selection.text.length; 12756 } 12757 12758 return (pos); 12759 }; 12760 12761 BX.setCaretPosition = function(node, pos) 12762 { 12763 if(!BX.isNodeInDom(node) || BX.isNodeHidden(node) || node.disabled) 12764 { 12765 return; 12766 } 12767 12768 if(node.setSelectionRange) 12769 { 12770 node.focus(); 12771 node.setSelectionRange(pos, pos); 12772 } 12773 else if(node.createTextRange) 12774 { 12775 var range = node.createTextRange(); 12776 range.collapse(true); 12777 range.moveEnd('character', pos); 12778 range.moveStart('character', pos); 12779 range.select(); 12780 } 12781 }; 12782 12783 // access private. use BX.mergeEx instead. 12784 // todo: refactor BX.merge, make it work through BX.mergeEx 12785 BX.merge = function(){ 12786 var arg = Array.prototype.slice.call(arguments); 12787 12788 if(arg.length < 2) 12789 return {}; 12790 12791 var result = arg.shift(); 12792 12793 for(var i = 0; i < arg.length; i++) 12794 { 12795 for(var k in arg[i]){ 12796 12797 if(typeof arg[i] == 'undefined' || arg[i] == null) 12798 continue; 12799 12800 if(arg[i].hasOwnProperty(k)){ 12801 12802 if(typeof arg[i][k] == 'undefined' || arg[i][k] == null) 12803 continue; 12804 12805 if(typeof arg[i][k] == 'object' && !BX.type.isDomNode(arg[i][k]) && (typeof arg[i][k]['isUIWidget'] == 'undefined')){ 12806 12807 // go deeper 12808 12809 var isArray = 'length' in arg[i][k]; 12810 12811 if(typeof result[k] != 'object') 12812 result[k] = isArray ? [] : {}; 12813 12814 if(isArray) 12815 BX.util.array_merge(result[k], arg[i][k]); 12816 else 12817 BX.merge(result[k], arg[i][k]); 12818 12819 }else 12820 result[k] = arg[i][k]; 12821 } 12822 } 12823 } 12824 12825 return result; 12826 }; 12827 12828 BX.mergeEx = function() 12829 { 12830 var arg = Array.prototype.slice.call(arguments); 12831 if(arg.length < 2) 12832 { 12833 return {}; 12834 } 12835 12836 var result = arg.shift(); 12837 for (var i = 0; i < arg.length; i++) 12838 { 12839 for (var k in arg[i]) 12840 { 12841 if (typeof arg[i] == "undefined" || arg[i] == null || !arg[i].hasOwnProperty(k)) 12842 { 12843 continue; 12844 } 12845 12846 if (BX.type.isPlainObject(arg[i][k]) && BX.type.isPlainObject(result[k])) 12847 { 12848 BX.mergeEx(result[k], arg[i][k]); 12849 } 12850 else 12851 { 12852 result[k] = BX.type.isPlainObject(arg[i][k]) ? BX.clone(arg[i][k]) : arg[i][k]; 12853 } 12854 } 12855 } 12856 12857 return result; 12858 }; 12859 12860 BX.getEventButton = function(e) 12861 { 12862 e = e || window.event; 12863 12864 var flags = 0; 12865 12866 if (typeof e.which != 'undefined') 12867 { 12868 switch (e.which) 12869 { 12870 case 1: flags = flags|BX.MSLEFT; break; 12871 case 2: flags = flags|BX.MSMIDDLE; break; 12872 case 3: flags = flags|BX.MSRIGHT; break; 12873 } 12874 } 12875 else if (typeof e.button != 'undefined') 12876 { 12877 flags = event.button; 12878 } 12879 12880 return flags || BX.MSLEFT; 12881 }; 12882 12883 var captured_events = null, _bind = null; 12884 BX.CaptureEvents = function(el_c, evname_c) 12885 { 12886 if (_bind) 12887 return; 12888 12889 _bind = BX.bind; 12890 captured_events = []; 12891 12892 BX.bind = function(el, evname, func) 12893 { 12894 if (el === el_c && evname === evname_c) 12895 captured_events.push(func); 12896 12897 _bind.apply(this, arguments); 12898 } 12899 }; 12900 12901 BX.CaptureEventsGet = function() 12902 { 12903 if (_bind) 12904 { 12905 BX.bind = _bind; 12906 12907 var captured = captured_events; 12908 12909 _bind = null; 12910 captured_events = null; 12911 return captured; 12912 } 12913 return null; 12914 }; 12915 12916 // Don't even try to use it for submit event! 12917 BX.fireEvent = function(ob,ev) 12918 { 12919 var result = false, e = null; 12920 if (BX.type.isDomNode(ob)) 12921 { 12922 result = true; 12923 if (document.createEventObject) 12924 { 12925 // IE 12926 if (eventTypes[ev] != 'MouseEvent') 12927 { 12928 e = document.createEventObject(); 12929 e.type = ev; 12930 result = ob.fireEvent('on' + ev, e); 12931 } 12932 12933 if (ob[ev]) 12934 { 12935 ob[ev](); 12936 } 12937 } 12938 else 12939 {
12940 // non-IE 12941 e = null; 12942 12943 switch (eventTypes[ev]) 12944 { 12945 case 'MouseEvent': 12946 e = document.createEvent('MouseEvent'); 12947 try 12948 { 12949 e.initMouseEvent(ev, true, true, top, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, null); 12950 } 12951 catch (initException) 12952 { 12953 e.initMouseEvent(ev, true, true, window, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, null); 12954 } 12955 12956 break; 12957 default: 12958 e = document.createEvent('Event'); 12959 e.initEvent(ev, true, true); 12960 } 12961 12962 result = ob.dispatchEvent(e); 12963 } 12964 } 12965 12966 return result; 12967 }; 12968 12969 BX.getWheelData = function(e) 12970 { 12971 e = e || window.event; 12972 e.wheelData = e.detail ? e.detail * -1 : e.wheelDelta / 40; 12973 return e.wheelData; 12974 }; 12975 12976 BX.proxy_context = null; 12977 12978 BX.delegate = function (func, thisObject) 12979 { 12980 if (!func || !thisObject) 12981 return func; 12982 12983 return function() { 12984 var cur = BX.proxy_context; 12985 BX.proxy_context = this; 12986 var res = func.apply(thisObject, arguments); 12987 BX.proxy_context = cur; 12988 return res; 12989 } 12990 }; 12991 12992 BX.delegateLater = function (func_name, thisObject, contextObject) 12993 { 12994 return function() 12995 { 12996 if (thisObject[func_name]) 12997 { 12998 var cur = BX.proxy_context; 12999 BX.proxy_context = this; 13000 var res = thisObject[func_name].apply(contextObject||thisObject, arguments); 13001 BX.proxy_context = cur; 13002 return res; 13003 } 13004 return null; 13005 } 13006 }; 13007 13008 BX.proxy = function(func, thisObject) 13009 { 13010 return getObjectDelegate(func, thisObject, proxyList); 13011 }; 13012 13013 BX.defer = function(func, thisObject) 13014 { 13015 if (!!thisObject) 13016 return BX.defer_proxy(func, thisObject); 13017 else 13018 return function() { 13019 var arg = arguments; 13020 setTimeout(function(){func.apply(this,arg)}, 10); 13021 }; 13022 }; 13023 13024 BX.defer_proxy = function(func, thisObject) 13025 { 13026 return getObjectDelegate(func, thisObject, deferList, BX.defer); 13027 }; 13028 13029 /** 13030 * 13031 * @private 13032 */ 13033 function getObjectDelegate(func, thisObject, collection, decorator) 13034 { 13035 if (!BX.type.isFunction(func) || !BX.type.isMapKey(thisObject)) 13036 { 13037 return func; 13038 } 13039 13040 var objectDelegates = collection.get(thisObject); 13041 if (!objectDelegates) 13042 { 13043 objectDelegates = new WeakMap(); 13044 collection.set(thisObject, objectDelegates); 13045 } 13046 13047 var delegate = objectDelegates.get(func); 13048 if (!delegate) 13049 { 13050 delegate = decorator ? decorator(BX.delegate(func, thisObject)) : BX.delegate(func, thisObject); 13051 objectDelegates.set(func, delegate); 13052 } 13053 13054 return delegate; 13055 } 13056 13057 BX.once = function(el, evname, func) 13058 { 13059 var fn = function() 13060 { 13061 BX.unbind(el, evname, fn); 13062 func.apply(this, arguments); 13063 }; 13064 13065 return fn; 13066 }; 13067 13068 BX.bindDelegate = function (elem, eventName, isTarget, handler) 13069 { 13070 var h = BX.delegateEvent(isTarget, handler); 13071 BX.bind(elem, eventName, h); 13072 return h; 13073 }; 13074 13075 BX.delegateEvent = function(isTarget, handler) 13076 { 13077 return function(e) 13078 { 13079 e = e || window.event; 13080 var target = e.target || e.srcElement; 13081 13082 while (target != this) 13083 { 13084 if (_checkNode(target, isTarget)) 13085 { 13086 return handler.call(target, e); 13087 } 13088 if (target && target.parentNode) 13089 target = target.parentNode; 13090 else 13091 break; 13092 } 13093 return null; 13094 } 13095 }; 13096 13097 BX.False = function() {return false;}; 13098 BX.DoNothing = function() {}; 13099 13100 // TODO: also check event handlers set via BX.bind() 13101 BX.denyEvent = function(el, ev) 13102 { 13103 deniedEvents.push([el, ev, el['on' + ev]]); 13104 el['on' + ev] = BX.DoNothing; 13105 }; 13106 13107 BX.allowEvent = function(el, ev) 13108 { 13109 for(var i=0, len=deniedEvents.length; i<len; i++) 13110 { 13111 if (deniedEvents[i][0] == el && deniedEvents[i][1] == ev) 13112 { 13113 el['on' + ev] = deniedEvents[i][2]; 13114 BX.util.deleteFromArray(deniedEvents, i); 13115 return; 13116 } 13117 } 13118 }; 13119 13120 BX.fixEventPageXY = function(event) 13121 { 13122 BX.fixEventPageX(event); 13123 BX.fixEventPageY(event); 13124 return event; 13125 }; 13126 13127 BX.fixEventPageX = function(event) 13128 { 13129 if (event.pageX == null && event.clientX != null) 13130 { 13131 event.pageX = 13132 event.clientX + 13133 (document.documentElement && document.documentElement.scrollLeft || document.body && document.body.scrollLeft || 0) - 13134 (document.documentElement.clientLeft || 0); 13135 } 13136 13137 return event; 13138 }; 13139 13140 BX.fixEventPageY = function(event) 13141 { 13142 if (event.pageY == null && event.clientY != null) 13143 { 13144 event.pageY = 13145 event.clientY + 13146 (document.documentElement && document.documentElement.scrollTop || document.body && document.body.scrollTop || 0) - 13147 (document.documentElement.clientTop || 0); 13148 } 13149 13150 return event; 13151 }; 13152 13153 /** 13154 * @deprecated 13155 * @see e.preventDefault() 13156 */ 13157 BX.PreventDefault = function(e) 13158 { 13159 if(!e) e = window.event; 13160 if(e.stopPropagation) 13161 { 13162 e.preventDefault(); 13163 e.stopPropagation(); 13164 } 13165 else 13166 { 13167 e.cancelBubble = true; 13168 e.returnValue = false;
13169 } 13170 return false; 13171 }; 13172 13173 /** 13174 * @deprecated 13175 * @see e.preventDefault(); 13176 * 13177 * @param e 13178 * @return {boolean} 13179 */ 13180 BX.eventReturnFalse = function(e) 13181 { 13182 e=e||window.event; 13183 if (e && e.preventDefault) e.preventDefault(); 13184 else e.returnValue = false; 13185 return false; 13186 }; 13187 13188 /** 13189 * @deprecated 13190 * @see e.stopPropagation() 13191 * @param e 13192 */ 13193 BX.eventCancelBubble = function(e) 13194 { 13195 e=e||window.event; 13196 if(e && e.stopPropagation) 13197 e.stopPropagation(); 13198 else 13199 e.cancelBubble = true; 13200 }; 13201 13202 BX.bindDebouncedChange = function(node, fn, fnInstant, timeout, ctx) 13203 { 13204 ctx = ctx || window; 13205 timeout = timeout || 300; 13206 13207 var dataTag = 'bx-dc-previous-value'; 13208 BX.data(node, dataTag, node.value); 13209 13210 var act = function(fn, val){ 13211 13212 var pVal = BX.data(node, dataTag); 13213 13214 if(typeof pVal == 'undefined' || pVal != val){ 13215 if(typeof ctx != 'object') 13216 fn(val); 13217 else 13218 fn.apply(ctx, [val]); 13219 } 13220 }; 13221 13222 var actD = BX.debounce(function(){ 13223 var val = node.value; 13224 act(fn, val); 13225 BX.data(node, dataTag, val); 13226 }, timeout); 13227 13228 BX.bind(node, 'keyup', actD); 13229 BX.bind(node, 'change', actD); 13230 BX.bind(node, 'input', actD); 13231 13232 if(BX.type.isFunction(fnInstant)){ 13233 13234 var actI = function(){ 13235 act(fnInstant, node.value); 13236 }; 13237 13238 BX.bind(node, 'keyup', actI); 13239 BX.bind(node, 'change', actI); 13240 BX.bind(node, 'input', actI); 13241 } 13242 }; 13243 13244 BX.parseJSON = function(data, context) 13245 { 13246 var result = null; 13247 if (BX.type.isNotEmptyString(data)) 13248 { 13249 try { 13250 if (data.indexOf("\n") >= 0) 13251 eval('result = ' + data); 13252 else 13253 result = (new Function("return " + data))(); 13254 } catch(e) { 13255 BX.onCustomEvent(context, 'onParseJSONFailure', [data, context]) 13256 } 13257 } 13258 else if(BX.type.isPlainObject(data)) 13259 { 13260 return data; 13261 } 13262 13263 return result; 13264 }; 13265 13266 BX.submit = function(obForm, action_name, action_value, onAfterSubmit) 13267 { 13268 action_name = action_name || 'save'; 13269 if (!obForm['BXFormSubmit_' + action_name]) 13270 { 13271 obForm['BXFormSubmit_' + action_name] = obForm.appendChild(BX.create('INPUT', { 13272 'props': { 13273 'type': 'submit', 13274 'name': action_name, 13275 'value': action_value || 'Y' 13276 }, 13277 'style': { 13278 'display': 'none' 13279 } 13280 })); 13281 } 13282 13283 if (obForm.sessid) 13284 obForm.sessid.value = BX.bitrix_sessid(); 13285 13286 setTimeout(BX.delegate(function() {BX.fireEvent(this, 'click'); if (onAfterSubmit) onAfterSubmit();}, obForm['BXFormSubmit_' + action_name]), 10); 13287 }; 13288 13289 BX.show = function(ob, displayType) 13290 { 13291 if (ob.BXDISPLAY || !_checkDisplay(ob, displayType)) 13292 { 13293 ob.style.display = ob.BXDISPLAY; 13294 } 13295 }; 13296 13297 BX.hide = function(ob, displayType) 13298 { 13299 if (!ob.BXDISPLAY) 13300 _checkDisplay(ob, displayType); 13301 13302 ob.style.display = 'none'; 13303 }; 13304 13305 BX.toggle = function(ob, values) 13306 { 13307 if (!values && BX.type.isElementNode(ob)) 13308 { 13309 var bShow = true; 13310 if (ob.BXDISPLAY) 13311 bShow = !_checkDisplay(ob); 13312 else 13313 bShow = ob.style.display == 'none'; 13314 13315 if (bShow) 13316 BX.show(ob); 13317 else 13318 BX.hide(ob); 13319 } 13320 else if (BX.type.isArray(values)) 13321 { 13322 for (var i=0,len=values.length; i<len; i++) 13323 { 13324 if (ob == values[i]) 13325 { 13326 ob = values[i==len-1 ? 0 : i+1]; 13327 break; 13328 } 13329 } 13330 if (i==len) 13331 ob = values[0]; 13332 } 13333 13334 return ob; 13335 }; 13336 13337 function _checkDisplay(ob, displayType) 13338 { 13339 if (typeof displayType != 'undefined') 13340 ob.BXDISPLAY = displayType; 13341 13342 var d = ob.style.display || BX.style(ob, 'display'); 13343 if (d != 'none') 13344 { 13345 ob.BXDISPLAY = ob.BXDISPLAY || d; 13346 return true; 13347 } 13348 else 13349 { 13350 ob.BXDISPLAY = ob.BXDISPLAY || 'block'; 13351 return false; 13352 } 13353 } 13354 13355 /* some useful util functions */ 13356 13357 BX.util = { 13358 /** 13359 * @deprecated 13360 * @use [].filter(value => !BX.Type.isNil(value)) 13361 * @param ar 13362 * @return {*} 13363 */ 13364 array_values: function(ar) 13365 { 13366 if (!BX.type.isArray(ar)) 13367 return BX.util._array_values_ob(ar); 13368 var arv = []; 13369 for(var i=0,l=ar.length;i<l;i++) 13370 if (ar[i] !== null && typeof ar[i] != 'undefined') 13371 arv.push(ar[i]); 13372 return arv; 13373 }, 13374 13375 /** 13376 * @deprecated 13377 * @use Object.values([]).filter(value => !BX.Type.isNil(value)) 13378 * @param ar 13379 * @return {Array} 13380 * @private 13381 */ 13382 _array_values_ob: function(ar) 13383 { 13384 var arv = []; 13385 for(var i in ar) 13386 if (ar[i] !== null && typeof ar[i] != 'undefined') 13387 arv.push(ar[i]); 13388 return arv; 13389 }, 13390 13391 /** 13392 * @deprecated 13393 * @use 13394 * @param ar 13395 * @return {*} 13396 */ 13397 array_keys: function(ar) 13398 { 13399 if (!BX.type.isArray(ar)) 13400 return BX.util._array_keys_ob(ar); 13401 var arv = []; 13402 for(var i=0,l=ar.length;i<l;i++) 13403 if (ar[i] !== null && typeof ar[i] != 'undefined') 13404 arv.push(i); 13405 return arv; 13406 }, 13407 13408 _array_keys_ob: function(ar) 13409 { 13410 var arv = []; 13411 for(var i in ar) 13412 if (ar[i] !== null && typeof ar[i] != 'undefined') 13413 arv.push(i); 13414 return arv; 13415 }, 13416 13417 object_keys: function(obj) 13418 { 13419 var arv = []; 13420 for(var k in obj) 13421 { 13422 if(obj.hasOwnProperty(k)) 13423 { 13424 arv.push(k); 13425 } 13426 } 13427 return arv; 13428 }, 13429 13430 /** 13431 * @deprecated 13432 * @use firstArr.concat(secondArr); 13433 * @param first 13434 * @param second 13435 * @return {*[]} 13436 */ 13437 array_merge: function(first, second) 13438 { 13439 if (!BX.type.isArray(first)) first = []; 13440 if (!BX.type.isArray(second)) second = []; 13441 13442 var i = first.length, j = 0; 13443 13444 if (typeof second.length === "number") 13445 { 13446 for (var l = second.length; j < l; j++) 13447 { 13448 first[i++] = second[j]; 13449 } 13450 } 13451 else 13452 {
13453 while (second[j] !== undefined) 13454 { 13455 first[i++] = second[j++]; 13456 } 13457 } 13458 13459 first.length = i; 13460 13461 return first; 13462 }, 13463 13464 array_flip: function (object) 13465 { 13466 var newObject = {}; 13467 13468 for (var key in object) 13469 { 13470 newObject[object[key]] = key; 13471 } 13472 13473 return newObject; 13474 }, 13475 13476 array_diff: function(ar1, ar2, hash) 13477 { 13478 hash = BX.type.isFunction(hash) ? hash : null; 13479 var i, length, v, h, map = {}, result = []; 13480 for(i = 0, length = ar2.length; i < length; i++) 13481 { 13482 v = ar2[i]; 13483 h = hash ? hash(v) : v; 13484 map[h] = true; 13485 } 13486 13487 for(i = 0, length = ar1.length; i < length; i++) 13488 { 13489 v = ar1[i]; 13490 h = hash ? hash(v) : v; 13491 if(typeof(map[h]) === "undefined") 13492 { 13493 result.push(v); 13494 } 13495 } 13496 return result; 13497 }, 13498 13499 /** 13500 * @deprecated 13501 * @use Set 13502 */ 13503 array_unique: function(ar) 13504 { 13505 var i=0,j,len=ar.length; 13506 if(len<2) return ar; 13507 13508 for (; i<len-1;i++) 13509 { 13510 for (j=i+1; j<len;j++) 13511 { 13512 if (ar[i]==ar[j]) 13513 { 13514 ar.splice(j--,1); len--; 13515 } 13516 } 13517 } 13518 13519 return ar; 13520 }, 13521 13522 /** 13523 * @deprecated 13524 * @use myArr.includes(needle) 13525 */ 13526 in_array: function(needle, haystack) 13527 { 13528 for(var i=0; i<haystack.length; i++) 13529 { 13530 if(haystack[i] == needle) 13531 return true; 13532 } 13533 return false; 13534 }, 13535 13536 /** 13537 * @deprecated 13538 * @use myArr.findIndex(item => item === needle); 13539 */ 13540 array_search: function(needle, haystack) 13541 { 13542 for(var i=0; i<haystack.length; i++) 13543 { 13544 if(haystack[i] == needle) 13545 return i; 13546 } 13547 return -1; 13548 }, 13549 13550 object_search_key: function(needle, haystack) 13551 { 13552 if (typeof haystack[needle] != 'undefined') 13553 return haystack[needle]; 13554 13555 for(var i in haystack) 13556 { 13557 if (typeof haystack[i] == "object") 13558 { 13559 var result = BX.util.object_search_key(needle, haystack[i]); 13560 if (result !== false) 13561 return result; 13562 } 13563 } 13564 return false; 13565 }, 13566 13567 trim: function(s) 13568 { 13569 if (BX.type.isString(s)) 13570 { 13571 return s.trim(); 13572 } 13573 13574 return s; 13575 }, 13576 13577 urlencode: function(s){return encodeURIComponent(s);}, 13578 13579 // it may also be useful. via sVD. 13580 deleteFromArray: function(ar, ind) {return ar.slice(0, ind).concat(ar.slice(ind + 1));}, 13581 insertIntoArray: function(ar, ind, el) {return ar.slice(0, ind).concat([el]).concat(ar.slice(ind));}, 13582 13583 htmlspecialchars: function(str) 13584 { 13585 return BX.Text.encode(str); 13586 }, 13587 13588 htmlspecialcharsback: function(str) 13589 { 13590 return BX.Text.decode(str); 13591 }, 13592 13593 // Quote regular expression characters plus an optional character 13594 preg_quote: function(str, delimiter) 13595 { 13596 if(!str.replace) 13597 return str; 13598 return str.replace(new RegExp('[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\' + (delimiter || '') + '-]', 'g'), '\\$&'); 13599 }, 13600 13601 jsencode: function(str) 13602 { 13603 if (!str || !str.replace) 13604 return str; 13605 13606 var escapes = 13607 [ 13608 { c: "\\\\", r: "\\\\" }, // should be first 13609 { c: "\\t", r: "\\t" }, 13610 { c: "\\n", r: "\\n" }, 13611 { c: "\\r", r: "\\r" }, 13612 { c: "\"", r: "\\\"" }, 13613 { c: "'", r: "\\'" }, 13614 { c: "<", r: "\\x3C" }, 13615 { c: ">", r: "\\x3E" }, 13616 { c: "\\u2028", r: "\\u2028" }, 13617 { c: "\\u2029", r: "\\u2029" } 13618 ]; 13619 for (var i = 0; i < escapes.length; i++) 13620 str = str.replace(new RegExp(escapes[i].c, 'g'), escapes[i].r); 13621 return str; 13622 }, 13623 13624 getCssName: function(jsName) 13625 { 13626 if (!BX.type.isNotEmptyString(jsName)) 13627 { 13628 return ""; 13629 } 13630 13631 return jsName.replace(/[A-Z]/g, function(match) { 13632 return "-" + match.toLowerCase(); 13633 }); 13634 }, 13635 13636 getJsName: function(cssName) 13637 { 13638 var regex = /\-([a-z]){1}/g; 13639 if (regex.test(cssName)) 13640 { 13641 return cssName.replace(regex, function(match, letter) { 13642 return letter.toUpperCase(); 13643 }); 13644 } 13645 13646 return cssName; 13647 }, 13648 13649 nl2br: function(str) 13650 { 13651 if (!str || !str.replace) 13652 return str; 13653 13654 return str.replace(/([^>])\n/g, '$1<br/>'); 13655 }, 13656 13657 /** 13658 * @deprecated 13659 * @use .padStart() / .padEnd() 13660 * @param input 13661 * @param pad_length 13662 * @param pad_string 13663 * @param pad_type 13664 * @return {*} 13665 */ 13666 str_pad: function(input, pad_length, pad_string, pad_type) 13667 { 13668 pad_string = pad_string || ' '; 13669 pad_type = pad_type || 'right'; 13670 input = input.toString(); 13671 13672 if (pad_type === 'left') 13673 { 13674 return BX.util.str_pad_left(input, pad_length, pad_string); 13675 } 13676 13677 return BX.util.str_pad_right(input, pad_length, pad_string); 13678 }, 13679 13680 str_pad_left: function(input, pad_length, pad_string) 13681 { 13682 return input.toString().padStart(pad_length, pad_string); 13683 }, 13684 13685 str_pad_right: function(input, pad_length, pad_string) 13686 { 13687 return input.toString().padEnd(pad_length, pad_string); 13688 }, 13689 13690 strip_tags: function(str) 13691 { 13692 return str.split(/<[^>]+>/g).join(''); 13693 }, 13694 13695 strip_php_tags: function(str) 13696 { 13697 return str.replace(/<\?(.|[\r\n])*?\?>/g, ''); 13698 }, 13699 13700 popup: function(url, width, height) 13701 { 13702 var w, h; 13703 if(BX.browser.IsOpera()) 13704 { 13705 w = document.body.offsetWidth; 13706 h = document.body.offsetHeight; 13707 } 13708 else 13709 {
13710 w = screen.width; 13711 h = screen.height; 13712 } 13713 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)); 13714 }, 13715 13716 shuffle: function(array) 13717 { 13718 var temporaryValue, randomIndex; 13719 var currentIndex = array.length; 13720 13721 while (0 !== currentIndex) 13722 { 13723 randomIndex = Math.floor(Math.random() * currentIndex); 13724 currentIndex -= 1; 13725 13726 temporaryValue = array[currentIndex]; 13727 array[currentIndex] = array[randomIndex]; 13728 array[randomIndex] = temporaryValue; 13729 } 13730 13731 return array; 13732 }, 13733 13734 // BX.util.objectSort(object, sortBy, sortDir) - Sort object by property 13735 // function params: 1 - object for sort, 2 - sort by property, 3 - sort direction (asc/desc) 13736 // return: sort array [[objectElement], [objectElement]] in sortDir direction 13737 13738 // example: BX.util.objectSort({'L1': {'name': 'Last'}, 'F1': {'name': 'First'}}, 'name', 'asc'); 13739 // return: [{'name' : 'First'}, {'name' : 'Last'}] 13740 objectSort: function(object, sortBy, sortDir) 13741 { 13742 sortDir = sortDir == 'asc'? 'asc': 'desc'; 13743 13744 var arItems = [], i; 13745 for (i in object) 13746 { 13747 if (object.hasOwnProperty(i) && object[i][sortBy]) 13748 { 13749 arItems.push([i, object[i][sortBy]]); 13750 } 13751 } 13752 13753 if (sortDir == 'asc') 13754 { 13755 arItems.sort(function(i, ii) { 13756 var s1, s2; 13757 if (BX.type.isDate(i[1])) 13758 { 13759 s1 = i[1].getTime(); 13760 } 13761 else if (!isNaN(i[1])) 13762 { 13763 s1 = parseInt(i[1]); 13764 } 13765 else 13766 { 13767 s1 = i[1].toString().toLowerCase(); 13768 } 13769 13770 if (BX.type.isDate(ii[1])) 13771 { 13772 s2 = ii[1].getTime(); 13773 } 13774 else if (!isNaN(ii[1])) 13775 { 13776 s2 = parseInt(ii[1]); 13777 } 13778 else 13779 { 13780 s2 = ii[1].toString().toLowerCase(); 13781 } 13782 13783 if (s1 > s2) 13784 return 1; 13785 else if (s1 < s2) 13786 return -1; 13787 else 13788 return 0; 13789 }); 13790 } 13791 else 13792 { 13793 arItems.sort(function(i, ii) { 13794 var s1, s2; 13795 if (BX.type.isDate(i[1])) 13796 { 13797 s1 = i[1].getTime(); 13798 } 13799 else if (!isNaN(i[1])) 13800 { 13801 s1 = parseInt(i[1]); 13802 } 13803 else 13804 { 13805 s1 = i[1].toString().toLowerCase(); 13806 } 13807 13808 if (BX.type.isDate(ii[1])) 13809 { 13810 s2 = ii[1].getTime(); 13811 } 13812 else if (!isNaN(ii[1])) 13813 { 13814 s2 = parseInt(ii[1]); 13815 } 13816 else 13817 { 13818 s2 = ii[1].toString().toLowerCase(); 13819 } 13820 13821 if (s1 < s2) 13822 return 1; 13823 else if (s1 > s2) 13824 return -1; 13825 else 13826 return 0; 13827 }); 13828 } 13829 13830 var arReturnArray = Array(); 13831 for (i = 0; i < arItems.length; i++) 13832 { 13833 arReturnArray.push(object[arItems[i][0]]); 13834 } 13835 13836 return arReturnArray; 13837 }, 13838 13839 objectMerge: function() 13840 { 13841 return BX.mergeEx.apply(window, arguments); 13842 }, 13843 13844 objectClone : function(object) 13845 { 13846 return BX.clone(object, true); 13847 }, 13848 13849 // #fdf9e5 => {r=253, g=249, b=229} 13850 hex2rgb: function(color) 13851 { 13852 var rgb = color.replace(/[# ]/g,"").replace(/^(.)(.)(.)$/,'$1$1$2$2$3$3').match(/.{2}/g); 13853 for (var i=0; i<3; i++) 13854 { 13855 rgb[i] = parseInt(rgb[i], 16); 13856 } 13857 return {'r':rgb[0],'g':rgb[1],'b':rgb[2]}; 13858 }, 13859 13860 /** 13861 * @deprecated 13862 * @use BX.Uri 13863 * @param url 13864 * @param param 13865 * @return {string} 13866 */ 13867 remove_url_param: function(url, param) 13868 { 13869 return BX.Uri.removeParam(url, param); 13870 }, 13871 13872 /* 13873 {'param1': 'value1', 'param2': 'value2'} 13874 */ 13875 /** 13876 * @deprecated 13877 * @use BX.Uri 13878 * @param url 13879 * @param params 13880 * @return {string} 13881 */ 13882 add_url_param: function(url, params) 13883 { 13884 var preparedParams = Object.entries(params).reduce(function(acc, item) { 13885 acc[item[0]] = BX.type.isArray(item[1]) ? item[1].join() : item[1]; 13886 return acc; 13887 }, {}); 13888 13889 return BX.Uri.addParam(url, preparedParams); 13890 }, 13891 13892 /* 13893 {'param1': 'value1', 'param2': 'value2'} 13894 */ 13895 buildQueryString: function(params) 13896 { 13897 var result = ''; 13898 for (var key in params) 13899 { 13900 var value = params[key]; 13901 if(BX.type.isArray(value)) 13902 { 13903 value.forEach(function(valueElement, index) 13904 { 13905 result += encodeURIComponent(key + "[" + index + "]") + "=" + encodeURIComponent(valueElement) + "&"; 13906 }); 13907 } 13908 else 13909 { 13910 result += encodeURIComponent(key) + "=" + encodeURIComponent(value) + "&"; 13911 } 13912 } 13913 13914 if(result.length > 0) 13915 { 13916 result = result.substr(0, result.length - 1); 13917 } 13918 return result; 13919 }, 13920 13921 even: function(digit) 13922 { 13923 return (parseInt(digit) % 2 == 0); 13924 }, 13925 13926 hashCode: function(str) 13927 { 13928 if(!BX.type.isNotEmptyString(str)) 13929 { 13930 return 0; 13931 } 13932 13933 var hash = 0; 13934 for (var i = 0; i < str.length; i++) 13935 { 13936 var c = str.charCodeAt(i); 13937 hash = ((hash << 5) - hash) + c; 13938 hash = hash & hash; 13939 } 13940 return hash; 13941 }, 13942 13943 getRandomString: function (length) 13944 { 13945 return BX.Text.getRandom(length); 13946 }, 13947 13948 number_format: function(number, decimals, dec_point, thousands_sep) 13949 { 13950 var i, j, kw, kd, km, sign = ''; 13951 decimals = Math.abs(decimals); 13952 if (isNaN(decimals) || decimals < 0) 13953 { 13954 decimals = 2; 13955 } 13956 dec_point = dec_point || ','; 13957 if (typeof thousands_sep === 'undefined') 13958 thousands_sep = '.'; 13959 13960 number = (+number || 0).toFixed(decimals); 13961 if (number < 0) 13962 { 13963 sign = '-'; 13964 number = -number; 13965 } 13966 13967 i = parseInt(number, 10) + ''; 13968 j = (i.length > 3 ? i.length % 3 : 0); 13969 13970 km = (j ? i.substr(0, j) + thousands_sep : ''); 13971 kw = i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousands_sep); 13972 kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).replace(/-/, '0').slice(2) : ''); 13973 13974 return sign + km + kw + kd; 13975 }, 13976 13977 getExtension: function (url) 13978 { 13979 url = url || ""; 13980 var items = url.split("?")[0].split("."); 13981 return items[items.length-1].toLowerCase(); 13982 }, 13983 addObjectToForm: function(object, form, prefix) 13984 { 13985 if(!BX.type.isString(prefix)) 13986 { 13987 prefix = ""; 13988 } 13989 13990 for(var key in object) 13991 { 13992 if(!object.hasOwnProperty(key)) 13993 { 13994 continue; 13995 } 13996 13997 var value = object[key]; 13998 var name = prefix !== "" ? (prefix + "[" + key + "]") : key; 13999 if(BX.type.isArray(value)) 14000 { 14001 var obj = {}; 14002 for(var i = 0; i < value.length; i++) 14003 { 14004 obj[i] = value[i]; 14005 } 14006 14007 BX.util.addObjectToForm(obj, form, name); 14008 } 14009 else if(BX.type.isPlainObject(value)) 14010 { 14011 BX.util.addObjectToForm(value, form, name); 14012 } 14013 else 14014 { 14015 value = BX.type.isFunction(value.toString) ? value.toString() : ""; 14016 if(value !== "") 14017 { 14018 form.appendChild(BX.create("INPUT", { attrs: { type: "hidden", name: name, value: value } })); 14019 } 14020 } 14021 } 14022 }, 14023 14024 observe: function(object, enable) 14025 {
14026 console.error('BX.util.observe: function is no longer supported by browser.'); 14027 return false; 14028 }, 14029 14030 escapeRegExp: function(str) 14031 { 14032 return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); 14033 } 14034 }; 14035 14036 BX.validation = { 14037 checkIfEmail: function(s) 14038 { 14039 var atom = "[=a-z0-9_+~'!$&*^`|#%/?{}-]"; 14040 return (new RegExp('^\\s*'+atom+'+(\\.'+atom+'+)*@([a-z0-9-]+\\.)+[a-z0-9-]{2,20}\\s*$', 'i')).test(s); 14041 }, 14042 checkIfPhone: function(s) 14043 { 14044 var regexp = new RegExp( 14045 typeof(BX.PhoneNumber) === "undefined" 14046 ? BX.PhoneNumber.getValidNumberPattern() 14047 : '^\\s*\\+?\s*[0-9(-)\\s]+\\s*$', 14048 'i' 14049 ); 14050 return regexp.test(s); 14051 } 14052 }; 14053 14054 BX.prop = 14055 { 14056 get: function(object, key, defaultValue) 14057 { 14058 return object && object.hasOwnProperty(key) ? object[key] : defaultValue; 14059 }, 14060 getObject: function(object, key, defaultValue) 14061 { 14062 return object && BX.type.isPlainObject(object[key]) ? object[key] : defaultValue; 14063 }, 14064 getElementNode: function(object, key, defaultValue) 14065 { 14066 return object && BX.type.isElementNode(object[key]) ? object[key] : defaultValue; 14067 }, 14068 getArray: function(object, key, defaultValue) 14069 { 14070 return object && BX.type.isArray(object[key]) ? object[key] : defaultValue; 14071 }, 14072 getFunction: function(object, key, defaultValue) 14073 { 14074 return object && BX.type.isFunction(object[key]) ? object[key] : defaultValue; 14075 }, 14076 getNumber: function(object, key, defaultValue) 14077 { 14078 if(!(object && object.hasOwnProperty(key))) 14079 { 14080 return defaultValue; 14081 } 14082 14083 var value = object[key]; 14084 if(BX.type.isNumber(value)) 14085 { 14086 return value; 14087 } 14088 14089 value = parseFloat(value); 14090 return !isNaN(value) ? value : defaultValue; 14091 }, 14092 getInteger: function(object, key, defaultValue) 14093 { 14094 if(!(object && object.hasOwnProperty(key))) 14095 { 14096 return defaultValue; 14097 } 14098 14099 var value = object[key]; 14100 if(BX.type.isNumber(value)) 14101 { 14102 return value; 14103 } 14104 14105 value = parseInt(value); 14106 return !isNaN(value) ? value : defaultValue; 14107 }, 14108 getBoolean: function(object, key, defaultValue) 14109 { 14110 if(!(object && object.hasOwnProperty(key))) 14111 { 14112 return defaultValue; 14113 } 14114 14115 var value = object[key]; 14116 return (BX.type.isBoolean(value) 14117 ? value 14118 : (BX.type.isString(value) ? (value.toLowerCase() === "true") : !!value) 14119 ); 14120 }, 14121 getString: function(object, key, defaultValue) 14122 { 14123 if(!(object && object.hasOwnProperty(key))) 14124 { 14125 return defaultValue; 14126 } 14127 14128 var value = object[key]; 14129 return BX.type.isString(value) ? value : (value ? value.toString() : ''); 14130 }, 14131 extractDate: function(datetime) 14132 { 14133 if(!BX.type.isDate(datetime)) 14134 { 14135 datetime = new Date(); 14136 } 14137 14138 datetime.setHours(0); 14139 datetime.setMinutes(0); 14140 datetime.setSeconds(0); 14141 datetime.setMilliseconds(0); 14142 14143 return datetime; 14144 } 14145 }; 14146 14147 BX.isNodeInDom = function(node, doc) 14148 { 14149 return node === (doc || document) ? true : 14150 (node.parentNode ? BX.isNodeInDom(node.parentNode) : false); 14151 }; 14152 14153 BX.isNodeHidden = function(node) 14154 { 14155 if (node === document) 14156 return false; 14157 else if (BX.style(node, 'display') == 'none') 14158 return true; 14159 else 14160 return (node.parentNode ? BX.isNodeHidden(node.parentNode) : true); 14161 }; 14162 14163 BX.evalPack = function(code) 14164 { 14165 while (code.length > 0) 14166 { 14167 var c = code.shift(); 14168 14169 if (c.TYPE == 'SCRIPT_EXT' || c.TYPE == 'SCRIPT_SRC') 14170 { 14171 BX.loadScript(c.DATA, function() {BX.evalPack(code)}); 14172 return; 14173 } 14174 else if (c.TYPE == 'SCRIPT') 14175 { 14176 BX.evalGlobal(c.DATA); 14177 } 14178 } 14179 }; 14180 14181 BX.evalGlobal = function(data) 14182 { 14183 if (data) 14184 { 14185 var head = document.getElementsByTagName("head")[0] || document.documentElement, 14186 script = document.createElement("script"); 14187 14188 script.type = "text/javascript"; 14189 14190 if (!BX.browser.IsIE()) 14191 { 14192 script.appendChild(document.createTextNode(data)); 14193 } 14194 else 14195 { 14196 script.text = data; 14197 } 14198 14199 head.insertBefore(script, head.firstChild); 14200 head.removeChild(script); 14201 } 14202 }; 14203 14204 BX.garbage = function(call, thisObject) 14205 { 14206 garbageCollectors.push({callback: call, context: thisObject}); 14207 }; 14208 14209 BX.GetDocElement = function (pDoc) 14210 { 14211 pDoc = pDoc || document; 14212 return (BX.browser.IsDoctype(pDoc) ? pDoc.documentElement : pDoc.body); 14213 }; 14214 14215 BX.scrollTop = function(node, val){ 14216 if(typeof val != 'undefined'){ 14217 14218 if(node == window){ 14219 throw new Error('scrollTop() for window is not implemented'); 14220 }else 14221 node.scrollTop = parseInt(val); 14222 14223 }else{ 14224 14225 if(node == window) 14226 return BX.GetWindowScrollPos().scrollTop; 14227 14228 return node.scrollTop; 14229 } 14230 }; 14231 14232 BX.scrollLeft = function(node, val){ 14233 if(typeof val != 'undefined'){ 14234 14235 if(node == window){ 14236 throw new Error('scrollLeft() for window is not implemented'); 14237 }else 14238 node.scrollLeft = parseInt(val); 14239 14240 }else{ 14241 14242 if(node == window) 14243 return BX.GetWindowScrollPos().scrollLeft; 14244 14245 return node.scrollLeft; 14246 } 14247 }; 14248 14249 BX.hide_object = function(ob) 14250 { 14251 ob = BX(ob); 14252 ob.style.position = 'absolute'; 14253 ob.style.top = '-1000px'; 14254 ob.style.left = '-1000px'; 14255 ob.style.height = '10px'; 14256 ob.style.width = '10px'; 14257 }; 14258 14259 BX.is_relative = function(el) 14260 { 14261 var p = BX.style(el, 'position'); 14262 return p == 'relative' || p == 'absolute'; 14263 }; 14264 14265 BX.is_float = function(el) 14266 { 14267 var p = BX.style(el, 'float'); 14268 return p == 'right' || p == 'left'; 14269 }; 14270 14271 BX.is_fixed = function(el) 14272 { 14273 var p = BX.style(el, 'position'); 14274 return p == 'fixed'; 14275 }; 14276 14277 BX.width = function(node, val){ 14278 if(typeof val != 'undefined') 14279 BX.style(node, 'width', parseInt(val)+'px'); 14280 else{ 14281 14282 if(node == window) 14283 return window.innerWidth; 14284 14285 //return parseInt(BX.style(node, 'width')); 14286 return BX.pos(node).width; 14287 } 14288 }; 14289 14290 BX.height = function(node, val){ 14291 if(typeof val != 'undefined') 14292 BX.style(node, 'height', parseInt(val)+'px'); 14293 else{ 14294 14295 if(node == window) 14296 return window.innerHeight; 14297 14298 //return parseInt(BX.style(node, 'height')); 14299 return BX.pos(node).height; 14300 } 14301 }; 14302 14303 BX.align = function(pos, w, h, type) 14304 { 14305 if (type) 14306 type = type.toLowerCase(); 14307 else 14308 type = ''; 14309 14310 var pDoc = document; 14311 if (BX.type.isElementNode(pos)) 14312 { 14313 pDoc = pos.ownerDocument; 14314 pos = BX.pos(pos); 14315 } 14316 14317 var x = pos["left"], y = pos["bottom"]; 14318 14319 var scroll = BX.GetWindowScrollPos(pDoc); 14320 var size = BX.GetWindowInnerSize(pDoc); 14321 14322 if((size.innerWidth + scroll.scrollLeft) - (pos["left"] + w) < 0) 14323 { 14324 if(pos["right"] - w >= 0 ) 14325 x = pos["right"] - w; 14326 else 14327 x = scroll.scrollLeft; 14328 } 14329
14330 if(((size.innerHeight + scroll.scrollTop) - (pos["bottom"] + h) < 0) || ~type.indexOf('top')) 14331 { 14332 if(pos["top"] - h >= 0 || ~type.indexOf('top')) 14333 y = pos["top"] - h; 14334 else 14335 y = scroll.scrollTop; 14336 } 14337 14338 return {'left':x, 'top':y}; 14339 }; 14340 14341 BX.scrollToNode = function(node) 14342 { 14343 var obNode = BX(node); 14344 14345 if (obNode.scrollIntoView) 14346 obNode.scrollIntoView(true); 14347 else 14348 { 14349 var arNodePos = BX.pos(obNode); 14350 window.scrollTo(arNodePos.left, arNodePos.top); 14351 } 14352 }; 14353 14354 /* non-xhr loadings */ 14355 BX.showWait = function(node, msg) 14356 { 14357 node = BX(node) || document.body || document.documentElement; 14358 msg = msg || BX.message('JS_CORE_LOADING'); 14359 14360 var container_id = node.id || Math.random(); 14361 14362 var obMsg = node.bxmsg = document.body.appendChild(BX.create('DIV', { 14363 props: { 14364 id: 'wait_' + container_id 14365 }, 14366 style: { 14367 background: 'url("/bitrix/js/main/core/images/wait.gif") no-repeat scroll 10px center #fcf7d1', 14368 border: '1px solid #E1B52D', 14369 color: 'black', 14370 fontFamily: 'Verdana,Arial,sans-serif', 14371 fontSize: '11px', 14372 padding: '10px 30px 10px 37px', 14373 position: 'absolute', 14374 textAlign:'center' 14375 }, 14376 text: msg 14377 })); 14378 14379 BX.ZIndexManager.register(obMsg); 14380 BX.ZIndexManager.bringToFront(obMsg); 14381 14382 setTimeout(BX.delegate(_adjustWait, node), 10); 14383 14384 lastWait[lastWait.length] = obMsg; 14385 return obMsg; 14386 }; 14387 14388 BX.closeWait = function(node, obMsg) 14389 { 14390 if(node && !obMsg) 14391 obMsg = node.bxmsg; 14392 if(node && !obMsg && BX.hasClass(node, 'bx-core-waitwindow')) 14393 obMsg = node; 14394 if(node && !obMsg) 14395 obMsg = BX('wait_' + node.id); 14396 if(!obMsg) 14397 obMsg = lastWait.pop(); 14398 14399 if (obMsg && obMsg.parentNode) 14400 { 14401 for (var i=0,len=lastWait.length;i<len;i++) 14402 { 14403 if (obMsg == lastWait[i]) 14404 { 14405 lastWait = BX.util.deleteFromArray(lastWait, i); 14406 break; 14407 } 14408 } 14409 14410 BX.ZIndexManager.unregister(obMsg); 14411 obMsg.parentNode.removeChild(obMsg); 14412 if (node) node.bxmsg = null; 14413 BX.cleanNode(obMsg, true); 14414 } 14415 }; 14416 14417 BX.setJSList = function(scripts) 14418 { 14419 if (BX.type.isArray(scripts)) 14420 { 14421 scripts = scripts.map(function(script) { 14422 return normalizeUrl(script) 14423 }); 14424 14425 jsList = jsList.concat(scripts); 14426 } 14427 }; 14428 14429 BX.getJSList = function() 14430 { 14431 initJsList(); 14432 return jsList; 14433 }; 14434 14435 BX.setCSSList = function(cssFiles) 14436 { 14437 if (BX.type.isArray(cssFiles)) 14438 { 14439 cssFiles = cssFiles.map(function(cssFile) { 14440 return normalizeUrl(cssFile); 14441 }); 14442 14443 cssList = cssList.concat(cssFiles); 14444 } 14445 }; 14446 14447 BX.getCSSList = function() 14448 { 14449 initCssList(); 14450 return cssList; 14451 }; 14452 14453 BX.getJSPath = function(js) 14454 { 14455 return js.replace(/^(http[s]*:)*\/\/[^\/]+/i, ''); 14456 }; 14457 14458 BX.getCSSPath = function(css) 14459 { 14460 return css.replace(/^(http[s]*:)*\/\/[^\/]+/i, ''); 14461 }; 14462 14463 BX.getCDNPath = function(path) 14464 { 14465 return path; 14466 }; 14467 14468 BX.loadScript = function(script, callback, doc) 14469 { 14470 if (BX.type.isString(script)) 14471 { 14472 script = [script]; 14473 } 14474 14475 return BX.load(script, callback, doc); 14476 }; 14477 14478 BX.loadCSS = function(css, doc, win) 14479 { 14480 if (BX.type.isString(css)) 14481 { 14482 css = [css]; 14483 } 14484 14485 if (BX.type.isArray(css)) 14486 { 14487 css = css.map(function(url) { 14488 return { url: url, ext: "css" } 14489 }); 14490 14491 BX.load(css, null, doc); 14492 } 14493 }; 14494 14495 const LOADING = 3; 14496 const LOADED = 4; 14497 const assets = {}; 14498 const loadingAssetCallbacks = {}; 14499 14500 BX.load = function(items, callback, doc, reject) 14501 { 14502 if (!BX.isReady) 14503 { 14504 var _args = arguments; 14505 BX.ready(function() { 14506 BX.load.apply(this, _args); 14507 }); 14508 14509 return null; 14510 } 14511 14512 doc = doc || document; 14513 14514 callback = BX.Type.isFunction(callback) ? callback : () => {}; 14515 14516 return loadAsync(items, callback, doc, reject); 14517 }; 14518 14519 function loadAsync(items, callback, doc, reject) 14520 { 14521 if (!BX.type.isArray(items)) 14522 { 14523 callback(); 14524 14525 return; 14526 } 14527 14528 function onLoad() 14529 { 14530 const nextAsset = queue.shift(); 14531 if (nextAsset) 14532 { 14533 load(nextAsset, onLoad, doc, reject); 14534 } 14535 else if (allLoaded()) 14536 { 14537 callback(); 14538 } 14539 } 14540 14541 function allLoaded() 14542 { 14543 for (const name in assetMap) 14544 { 14545 if (assetMap[name].state !== LOADED) 14546 { 14547 return false; 14548 } 14549 } 14550 14551 return true; 14552 } 14553 14554 const queue = []; 14555 const assetMap = {};
14556 items.forEach(item => { 14557 const asset = getAsset(item); 14558 if (asset && asset.state !== LOADED) 14559 { 14560 queue.push(asset); 14561 assetMap[asset.name] = asset; 14562 } 14563 }); 14564 14565 if (queue.length > 0) 14566 { 14567 const maxParallelLoads = 6; 14568 const parallelLoads = Math.min(queue.length, maxParallelLoads); 14569 const firstPackage = queue.splice(0, parallelLoads); 14570 firstPackage.forEach(asset => { 14571 load(asset, onLoad, doc, reject); 14572 }); 14573 } 14574 else 14575 { 14576 callback(); 14577 } 14578 } 14579 14580 function load(asset, callback, doc, reject) 14581 { 14582 callback = callback || BX.DoNothing; 14583 14584 if (asset.state === LOADED) 14585 { 14586 callback(); 14587 return; 14588 } 14589 14590 if (asset.state === LOADING) 14591 { 14592 if (!BX.Type.isArray(loadingAssetCallbacks[asset.name])) 14593 { 14594 loadingAssetCallbacks[asset.name] = []; 14595 } 14596 14597 loadingAssetCallbacks[asset.name].push(callback); 14598 14599 return; 14600 } 14601 14602 asset.state = LOADING; 14603 14604 const onReject = () => { 14605 delete assets[asset.name]; 14606 delete loadingAssetCallbacks[asset.name]; 14607 reject(); 14608 }; 14609 14610 loadAsset( 14611 asset, 14612 function () { 14613 asset.state = LOADED; 14614 callback(); 14615 if (BX.Type.isArrayFilled(loadingAssetCallbacks[asset.name])) 14616 { 14617 for (const cb of loadingAssetCallbacks[asset.name]) 14618 { 14619 cb(); 14620 } 14621 } 14622 14623 delete loadingAssetCallbacks[asset.name]; 14624 }, 14625 doc, 14626 BX.Type.isFunction(reject) ? onReject : null, 14627 ); 14628 } 14629 14630 function loadAsset(asset, callback, doc, reject) 14631 { 14632 callback = callback || BX.DoNothing; 14633 14634 function error(event) 14635 { 14636 window.clearTimeout(asset.errorTimeout); 14637 window.clearTimeout(asset.cssTimeout); 14638 ele.onload = ele.onreadystatechange = ele.onerror = null; 14639 if (BX.Type.isFunction(reject)) 14640 { 14641 reject(); 14642 } 14643 else 14644 { 14645 callback(); 14646 } 14647 } 14648 14649 function process(event) 14650 { 14651 if (ext === "css") 14652 { 14653 cssList.push(normalizeMinUrl(normalizeUrl(asset.url))); 14654 } 14655 else 14656 { 14657 jsList.push(normalizeMinUrl(normalizeUrl(asset.url))); 14658 } 14659 14660 event = event || window.event; 14661 if (event.type === "load" || (/loaded|complete/.test(ele.readyState) && (!doc.documentMode || doc.documentMode < 9))) 14662 { 14663 window.clearTimeout(asset.errorTimeout); 14664 window.clearTimeout(asset.cssTimeout); 14665 ele.onload = ele.onreadystatechange = ele.onerror = null; 14666 callback(); 14667 } 14668 } 14669 14670 function isCssLoaded() 14671 { 14672 if (asset.state !== LOADED && asset.cssRetries <= 20) 14673 { 14674 for (var i = 0, l = doc.styleSheets.length; i < l; i++) 14675 { 14676 if (doc.styleSheets[i].href === ele.href) 14677 { 14678 process({"type": "load"}); 14679 return; 14680 } 14681 } 14682 14683 asset.cssRetries++; 14684 asset.cssTimeout = window.setTimeout(isCssLoaded, 250); 14685 } 14686 } 14687 14688 let ele = null; 14689 const ext = BX.type.isNotEmptyString(asset.ext) ? asset.ext : BX.util.getExtension(asset.url); 14690 14691 if (ext === "css") 14692 { 14693 ele = doc.createElement("link"); 14694 ele.type = "text/" + (asset.type || "css"); 14695 ele.rel = "stylesheet"; 14696 ele.href = asset.url; 14697 14698 asset.cssRetries = 0; 14699 asset.cssTimeout = window.setTimeout(isCssLoaded, 500); 14700 } 14701 else 14702 { 14703 ele = doc.createElement("script"); 14704 ele.type = "text/" + (asset.type || "javascript"); 14705 ele.src = asset.url; 14706 } 14707 14708 ele.onload = ele.onreadystatechange = process; 14709 ele.onerror = error; 14710 14711 ele.async = false; 14712 ele.defer = false; 14713 14714 asset.errorTimeout = window.setTimeout(function () { 14715 error({type: "timeout"}); 14716 }, 7000); 14717 14718 let templateLink = null; 14719 const head = doc.head || doc.getElementsByTagName("head")[0]; 14720 if (ext === "css" && (templateLink = getTemplateLink(head)) !== null) 14721 { 14722 templateLink.parentNode.insertBefore(ele, templateLink); 14723 } 14724 else 14725 { 14726 head.insertBefore(ele, head.lastChild); 14727 } 14728 } 14729 14730 function getAsset(item) 14731 { 14732 var asset = {}; 14733 if (typeof item === "object") 14734 { 14735 asset = item; 14736 asset.name = asset.name ? asset.name : BX.util.hashCode(item.url); 14737 } 14738 else 14739 { 14740 asset = { name: BX.util.hashCode(item), url : item }; 14741 } 14742 14743 var ext = BX.type.isNotEmptyString(asset.ext) ? asset.ext : BX.util.getExtension(asset.url); 14744 if ((ext === "css" && isCssLoaded(asset.url)) || isScriptLoaded(asset.url)) 14745 { 14746 asset.state = LOADED; 14747 } 14748 14749 var existing = assets[asset.name]; 14750 if (existing && existing.url === asset.url) 14751 { 14752 return existing; 14753 } 14754 14755 assets[asset.name] = asset; 14756 14757 return asset; 14758 } 14759 14760 function normalizeUrl(url) 14761 { 14762 if (!BX.type.isNotEmptyString(url)) 14763 { 14764 return ""; 14765 } 14766 14767 url = BX.getJSPath(url); 14768 url = url.replace(/\?[0-9]*$/, ""); 14769 14770 return url; 14771 } 14772 14773 function normalizeMinUrl(url) 14774 { 14775 if (!BX.type.isNotEmptyString(url)) 14776 { 14777 return ""; 14778 } 14779 14780 var minPos = url.indexOf(".min"); 14781 return minPos >= 0 ? url.substr(0, minPos) + url.substr(minPos + 4) : url; 14782 } 14783 14784 function isCssLoaded(fileSrc) 14785 { 14786 initCssList(); 14787 14788 fileSrc = normalizeUrl(fileSrc); 14789 var fileSrcMin = normalizeMinUrl(fileSrc); 14790 14791 return (fileSrc !== fileSrcMin && BX.util.in_array(fileSrcMin, cssList)) || BX.util.in_array(fileSrc, cssList); 14792 } 14793 14794 function initCssList() 14795 { 14796 if(!cssInit) 14797 { 14798 var linksCol = document.getElementsByTagName('link'); 14799 14800 if(!!linksCol && linksCol.length > 0) 14801 { 14802 for(var i = 0; i < linksCol.length; i++) 14803 { 14804 var href = linksCol[i].getAttribute('href'); 14805 if (BX.type.isNotEmptyString(href)) 14806 { 14807 href = normalizeMinUrl(normalizeUrl(href)); 14808 cssList.push(href); 14809 } 14810 } 14811 } 14812 cssInit = true; 14813 } 14814 } 14815 14816 function getTemplateLink(head) 14817 { 14818 var findLink = function(tag) 14819 { 14820 var links = head.getElementsByTagName(tag); 14821 for (var i = 0, length = links.length; i < length; i++) 14822 { 14823 var templateStyle = links[i].getAttribute("data-template-style"); 14824 if (BX.type.isNotEmptyString(templateStyle) && templateStyle == "true") 14825 { 14826 return links[i]; 14827 } 14828 } 14829 14830 return null; 14831 }; 14832 14833 var link = findLink("link"); 14834 if (link === null) 14835 { 14836 link = findLink("style"); 14837 } 14838 14839 return link; 14840 } 14841 14842 function isScriptLoaded(fileSrc) 14843 { 14844 initJsList(); 14845 14846 fileSrc = normalizeUrl(fileSrc); 14847 var fileSrcMin = normalizeMinUrl(fileSrc); 14848 14849 return (fileSrc !== fileSrcMin && BX.util.in_array(fileSrcMin, jsList)) || BX.util.in_array(fileSrc, jsList); 14850 } 14851 14852 function initJsList() 14853 { 14854 if(!jsInit) 14855 { 14856 var scriptCol = document.getElementsByTagName('script'); 14857 14858 if(!!scriptCol && scriptCol.length > 0) 14859 { 14860 for(var i=0; i<scriptCol.length; i++) 14861 { 14862 var src = scriptCol[i].getAttribute('src'); 14863 14864 if (BX.type.isNotEmptyString(src)) 14865 { 14866 src = normalizeMinUrl(normalizeUrl(src)); 14867 jsList.push(src); 14868 } 14869 } 14870 } 14871 jsInit = true; 14872 } 14873 } 14874 14875 function reloadInternal(back_url, bAddClearCache) 14876 { 14877 if (back_url === true) 14878 { 14879 bAddClearCache = true; 14880 back_url = null; 14881 } 14882 14883 var topWindow = (function() { 14884 if (BX.PageObject && BX.PageObject.getRootWindow) 14885 { 14886 return BX.PageObject.getRootWindow(); 14887 } 14888 14889 return window.top; 14890 })(); 14891 var new_href = back_url || topWindow.location.href; 14892 14893 var hashpos = new_href.indexOf('#'), hash = ''; 14894 14895 if (hashpos != -1) 14896 { 14897 hash = new_href.substr(hashpos); 14898 new_href = new_href.substr(0, hashpos); 14899 } 14900 14901 if (bAddClearCache && new_href.indexOf('clear_cache=Y') < 0) 14902 new_href += (new_href.indexOf('?') == -1 ? '?' : '&') + 'clear_cache=Y'; 14903 14904 if (hash) 14905 { 14906 // hack for clearing cache in ajax mode components with history emulation 14907 if (bAddClearCache && (hash.substr(0, 5) == 'view/' || hash.substr(0, 6) == '#view/') && hash.indexOf('clear_cache%3DY') < 0) 14908 hash += (hash.indexOf('%3F') == -1 ? '%3F' : '%26') + 'clear_cache%3DY'; 14909 14910 new_href = new_href.replace(/(\?|\&)_r=[\d]*/, ''); 14911 new_href += (new_href.indexOf('?') == -1 ? '?' : '&') + '_r='+Math.round(Math.random()*10000) + hash; 14912 } 14913 14914 topWindow.location.href = new_href; 14915 } 14916 14917 BX.reload = function(back_url, bAddClearCache) 14918 { 14919 reloadInternal(back_url, bAddClearCache); 14920 }; 14921 14922 BX.clearCache = function() 14923 { 14924 BX.showWait(); 14925 BX.reload(true); 14926 }; 14927 14928 BX.template = function(tpl, callback, bKillTpl) 14929 { 14930 BX.ready(function() { 14931 _processTpl(BX(tpl), callback, bKillTpl); 14932 }); 14933 }; 14934 14935 BX.isAmPmMode = function(returnConst) 14936 { 14937 if (returnConst === true) 14938 { 14939 return BX.message.AMPM_MODE; 14940 } 14941 return BX.message.AMPM_MODE !== false; 14942 }; 14943 14944 BX.formatDate = function(date, format) 14945 { 14946 date = date || new Date(); 14947 14948 var bTime = date.getHours() || date.getMinutes() || date.getSeconds(), 14949 str = !!format 14950 ? format : 14951 (bTime ? BX.message('FORMAT_DATETIME') : BX.message('FORMAT_DATE') 14952 ); 14953 14954 return str.replace(/YYYY/ig, date.getFullYear()) 14955 .replace(/MMMM/ig, BX.util.str_pad_left((date.getMonth()+1).toString(), 2, '0')) 14956 .replace(/MM/ig, BX.util.str_pad_left((date.getMonth()+1).toString(), 2, '0')) 14957 .replace(/DD/ig, BX.util.str_pad_left(date.getDate().toString(), 2, '0')) 14958 .replace(/HH/ig, BX.util.str_pad_left(date.getHours().toString(), 2, '0')) 14959 .replace(/MI/ig, BX.util.str_pad_left(date.getMinutes().toString(), 2, '0')) 14960 .replace(/SS/ig, BX.util.str_pad_left(date.getSeconds().toString(), 2, '0')); 14961 }; 14962 BX.formatName = function(user, template, login) 14963 { 14964 user = user || {}; 14965 template = (template || ''); 14966 var replacement = { 14967 TITLE : (user["TITLE"] || ''), 14968 NAME : (user["NAME"] || ''),
14969 LAST_NAME : (user["LAST_NAME"] || ''), 14970 SECOND_NAME : (user["SECOND_NAME"] || ''), 14971 LOGIN : (user["LOGIN"] || ''), 14972 NAME_SHORT : user["NAME"] ? user["NAME"].substr(0, 1) + '.' : '', 14973 LAST_NAME_SHORT : user["LAST_NAME"] ? user["LAST_NAME"].substr(0, 1) + '.' : '', 14974 SECOND_NAME_SHORT : user["SECOND_NAME"] ? user["SECOND_NAME"].substr(0, 1) + '.' : '', 14975 EMAIL : (user["EMAIL"] || ''), 14976 ID : (user["ID"] || ''), 14977 NOBR : "", 14978 '/NOBR' : "" 14979 }, result = template; 14980 for (var ii in replacement) 14981 { 14982 if (replacement.hasOwnProperty(ii)) 14983 { 14984 result = result.replace("#" + ii+ "#", replacement[ii]) 14985 } 14986 } 14987 result = result.replace(/([\s]+)/gi, " ").trim(); 14988 if (result == "") 14989 { 14990 result = (login == "Y" ? replacement["LOGIN"] : ""); 14991 result = (result == "" ? "Noname" : result); 14992 } 14993 return result; 14994 }; 14995 14996 BX.getNumMonth = function(month) 14997 { 14998 var wordMonthCut = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']; 14999 var wordMonth = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december']; 15000 15001 var q = month.toUpperCase(); 15002 for (i = 1; i <= 12; i++) 15003 { 15004 if (q == BX.message('MON_'+i).toUpperCase() || q == BX.message('MONTH_'+i).toUpperCase() || q == wordMonthCut[i-1].toUpperCase() || q == wordMonth[i-1].toUpperCase()) 15005 { 15006 return i; 15007 } 15008 } 15009 return month; 15010 }; 15011 15012 BX.parseDate = function(str, bUTC, formatDate, formatDatetime) 15013 { 15014 if (BX.type.isNotEmptyString(str)) 15015 { 15016 if (!formatDate) 15017 formatDate = BX.message('FORMAT_DATE'); 15018 if (!formatDatetime) 15019 formatDatetime = BX.message('FORMAT_DATETIME'); 15020 15021 var regMonths = ''; 15022 for (i = 1; i <= 12; i++) 15023 { 15024 regMonths = regMonths + '|' + BX.message('MON_'+i); 15025 } 15026
15027 var expr = new RegExp('([0-9]+|[a-z]+' + regMonths + ')', 'ig'); 15028 var aDate = str.match(expr), 15029 aFormat = formatDate.match(/(DD|MI|MMMM|MM|M|YYYY)/ig), 15030 i, cnt, 15031 aDateArgs=[], aFormatArgs=[], 15032 aResult={}; 15033 15034 if (!aDate) 15035 return null; 15036 15037 if(aDate.length > aFormat.length) 15038 { 15039 aFormat = formatDatetime.match(/(DD|MI|MMMM|MM|M|YYYY|HH|H|SS|TT|T|GG|G)/ig); 15040 } 15041 15042 for(i = 0, cnt = aDate.length; i < cnt; i++) 15043 { 15044 if(BX.util.trim(aDate[i]) != '') 15045 { 15046 aDateArgs[aDateArgs.length] = aDate[i]; 15047 } 15048 } 15049 15050 for(i = 0, cnt = aFormat.length; i < cnt; i++) 15051 { 15052 if(BX.util.trim(aFormat[i]) != '') 15053 { 15054 aFormatArgs[aFormatArgs.length] = aFormat[i]; 15055 } 15056 } 15057 15058 15059 var m = BX.util.array_search('MMMM', aFormatArgs); 15060 if (m > 0) 15061 { 15062 aDateArgs[m] = BX.getNumMonth(aDateArgs[m]); 15063 aFormatArgs[m] = "MM"; 15064 } 15065 else 15066 { 15067 m = BX.util.array_search('M', aFormatArgs); 15068 if (m > 0) 15069 { 15070 aDateArgs[m] = BX.getNumMonth(aDateArgs[m]); 15071 aFormatArgs[m] = "MM"; 15072 } 15073 } 15074 15075 for(i = 0, cnt = aFormatArgs.length; i < cnt; i++) 15076 { 15077 var k = aFormatArgs[i].toUpperCase(); 15078 aResult[k] = k == 'T' || k == 'TT' ? aDateArgs[i] : parseInt(aDateArgs[i], 10); 15079 } 15080 15081 if(aResult['DD'] > 0 && aResult['MM'] > 0 && aResult['YYYY'] > 0) 15082 { 15083 var d = new Date(); 15084 15085 if(bUTC) 15086 { 15087 d.setUTCDate(1); 15088 d.setUTCFullYear(aResult['YYYY']); 15089 d.setUTCMonth(aResult['MM'] - 1); 15090 d.setUTCDate(aResult['DD']); 15091 d.setUTCHours(0, 0, 0, 0); 15092 } 15093 else 15094 { 15095 d.setDate(1); 15096 d.setFullYear(aResult['YYYY']); 15097 d.setMonth(aResult['MM'] - 1); 15098 d.setDate(aResult['DD']); 15099 d.setHours(0, 0, 0, 0); 15100 } 15101 15102 if( 15103 (!isNaN(aResult['HH']) || !isNaN(aResult['GG']) || !isNaN(aResult['H']) || !isNaN(aResult['G'])) 15104 && !isNaN(aResult['MI']) 15105 ) 15106 { 15107 if (!isNaN(aResult['H']) || !isNaN(aResult['G'])) 15108 { 15109 var bPM = (aResult['T']||aResult['TT']||'am').toUpperCase()=='PM'; 15110 var h = parseInt(aResult['H']||aResult['G']||0, 10); 15111 if(bPM) 15112 { 15113 aResult['HH'] = h + (h == 12 ? 0 : 12); 15114 } 15115 else 15116 { 15117 aResult['HH'] = h < 12 ? h : 0; 15118 } 15119 } 15120 else 15121 { 15122 aResult['HH'] = parseInt(aResult['HH']||aResult['GG']||0, 10); 15123 } 15124 15125 if (isNaN(aResult['SS'])) 15126 aResult['SS'] = 0; 15127 15128 if(bUTC) 15129 { 15130 d.setUTCHours(aResult['HH'], aResult['MI'], aResult['SS']); 15131 } 15132 else 15133 { 15134 d.setHours(aResult['HH'], aResult['MI'], aResult['SS']); 15135 } 15136 } 15137 15138 return d; 15139 } 15140 } 15141 15142 return null; 15143 }; 15144 15145 BX.selectUtils = 15146 { 15147 addNewOption: function(oSelect, opt_value, opt_name, do_sort, check_unique) 15148 { 15149 oSelect = BX(oSelect); 15150 if(oSelect) 15151 { 15152 var n = oSelect.length; 15153 if(check_unique !== false) 15154 { 15155 for(var i=0;i<n;i++) 15156 { 15157 if(oSelect[i].value==opt_value) 15158 { 15159 return; 15160 } 15161 } 15162 } 15163 15164 oSelect.options[n] = new Option(opt_name, opt_value, false, false); 15165 } 15166 15167 if(do_sort === true) 15168 { 15169 this.sortSelect(oSelect); 15170 } 15171 }, 15172 15173 deleteOption: function(oSelect, opt_value) 15174 { 15175 oSelect = BX(oSelect); 15176 if(oSelect) 15177 { 15178 for(var i=0;i<oSelect.length;i++) 15179 { 15180 if(oSelect[i].value==opt_value) 15181 { 15182 oSelect.remove(i); 15183 break; 15184 } 15185 } 15186 } 15187 }, 15188 15189 deleteSelectedOptions: function(oSelect) 15190 { 15191 oSelect = BX(oSelect); 15192 if(oSelect) 15193 { 15194 var i=0; 15195 while(i<oSelect.length) 15196 { 15197 if(oSelect[i].selected) 15198 { 15199 oSelect[i].selected=false; 15200 oSelect.remove(i); 15201 } 15202 else 15203 { 15204 i++; 15205 } 15206 } 15207 } 15208 }, 15209 15210 deleteAllOptions: function(oSelect) 15211 { 15212 oSelect = BX(oSelect); 15213 if(oSelect) 15214 { 15215 for(var i=oSelect.length-1; i>=0; i--) 15216 { 15217 oSelect.remove(i); 15218 } 15219 } 15220 }, 15221 15222 optionCompare: function(record1, record2) 15223 { 15224 var value1 = record1.optText.toLowerCase(); 15225 var value2 = record2.optText.toLowerCase(); 15226 if (value1 > value2) return(1); 15227 if (value1 < value2) return(-1); 15228 return(0); 15229 }, 15230 15231 sortSelect: function(oSelect) 15232 { 15233 oSelect = BX(oSelect); 15234 if(oSelect) 15235 { 15236 var myOptions = []; 15237 var n = oSelect.options.length; 15238 var i; 15239 for (i=0;i<n;i++) 15240 { 15241 myOptions[i] = { 15242 optText:oSelect[i].text, 15243 optValue:oSelect[i].value 15244 }; 15245 } 15246 myOptions.sort(this.optionCompare); 15247 oSelect.length=0; 15248 n = myOptions.length; 15249 for(i=0;i<n;i++) 15250 { 15251 oSelect[i] = new Option(myOptions[i].optText, myOptions[i].optValue, false, false); 15252 } 15253 } 15254 }, 15255 15256 selectAllOptions: function(oSelect) 15257 { 15258 oSelect = BX(oSelect); 15259 if(oSelect) 15260 { 15261 var n = oSelect.length; 15262 for(var i=0;i<n;i++) 15263 { 15264 oSelect[i].selected=true; 15265 } 15266 } 15267 }, 15268 15269 selectOption: function(oSelect, opt_value) 15270 { 15271 oSelect = BX(oSelect); 15272 if(oSelect) 15273 { 15274 var n = oSelect.length; 15275 for(var i=0;i<n;i++) 15276 { 15277 oSelect[i].selected = (oSelect[i].value == opt_value); 15278 } 15279 } 15280 }, 15281 15282 addSelectedOptions: function(oSelect, to_select_id, check_unique, do_sort) 15283 { 15284 oSelect = BX(oSelect); 15285 if(!oSelect) 15286 return; 15287 var n = oSelect.length; 15288 for(var i=0; i<n; i++) 15289 if(oSelect[i].selected) 15290 this.addNewOption(to_select_id, oSelect[i].value, oSelect[i].text, do_sort, check_unique); 15291 }, 15292 15293 moveOptionsUp: function(oSelect) 15294 { 15295 oSelect = BX(oSelect); 15296 if(!oSelect) 15297 return; 15298 var n = oSelect.length; 15299 for(var i=0; i<n; i++) 15300 { 15301 if(oSelect[i].selected && i>0 && oSelect[i-1].selected == false) 15302 { 15303 var option = new Option(oSelect[i].text, oSelect[i].value); 15304 oSelect[i] = new Option(oSelect[i-1].text, oSelect[i-1].value); 15305 oSelect[i].selected = false;
15306 oSelect[i-1] = option; 15307 oSelect[i-1].selected = true; 15308 } 15309 } 15310 }, 15311 15312 moveOptionsDown: function(oSelect) 15313 { 15314 oSelect = BX(oSelect); 15315 if(!oSelect) 15316 return; 15317 var n = oSelect.length; 15318 for(var i=n-1; i>=0; i--) 15319 { 15320 if(oSelect[i].selected && i<n-1 && oSelect[i+1].selected == false) 15321 { 15322 var option = new Option(oSelect[i].text, oSelect[i].value); 15323 oSelect[i] = new Option(oSelect[i+1].text, oSelect[i+1].value); 15324 oSelect[i].selected = false; 15325 oSelect[i+1] = option; 15326 oSelect[i+1].selected = true; 15327 } 15328 } 15329 } 15330 }; 15331 15332 BX.getEventTarget = function(e) 15333 { 15334 if(e.target) 15335 { 15336 return e.target; 15337 } 15338 else if(e.srcElement) 15339 { 15340 return e.srcElement; 15341 } 15342 return null; 15343 }; 15344 15345 BX.convert = { 15346 toNumber: function(value) 15347 { 15348 if(BX.type.isNumber(value)) 15349 { 15350 return value; 15351 } 15352 15353 value = Number(value); 15354 return !isNaN(value) ? value : 0; 15355 }, 15356 nodeListToArray: function(nodes) 15357 { 15358 try 15359 { 15360 return (Array.prototype.slice.call(nodes, 0)); 15361 } 15362 catch (ex) 15363 { 15364 var ary = []; 15365 for(var i = 0, l = nodes.length; i < l; i++) 15366 { 15367 ary.push(nodes[i]); 15368 } 15369 return ary; 15370 } 15371 } 15372 }; 15373 15374 /******* HINT ***************/ 15375// if function has 2 params - the 2nd one is hint html. otherwise hint_html is third and hint_title - 2nd; 15376// '<div onmouseover="BX.hint(this, 'This is <b>Hint</b>')"'>; 15377// BX.hint(el, 'This is <b>Hint</b>') - this won't work, use constructor 15378 BX.hint = function(el, hint_title, hint_html, hint_id) 15379 { 15380 if (null == hint_html) 15381 { 15382 hint_html = hint_title; 15383 hint_title = ''; 15384 } 15385 15386 if (null == el.BXHINT) 15387 { 15388 el.BXHINT = new BX.CHint({ 15389 parent: el, hint: hint_html, title: hint_title, id: hint_id 15390 }); 15391 el.BXHINT.Show(); 15392 } 15393 }; 15394 15395 BX.hint_replace = function(el, hint_title, hint_html) 15396 { 15397 if (null == hint_html) 15398 { 15399 hint_html = hint_title; 15400 hint_title = ''; 15401 } 15402 15403 if (!el || !el.parentNode || !hint_html) 15404 return null; 15405 15406 var obHint = new BX.CHint({ 15407 hint: hint_html, 15408 title: hint_title 15409 }); 15410 15411 obHint.CreateParent(); 15412 15413 el.parentNode.insertBefore(obHint.PARENT, el); 15414 el.parentNode.removeChild(el); 15415 15416 obHint.PARENT.style.marginLeft = '5px'; 15417 15418 return el; 15419 }; 15420 15421 BX.CHint = function(params) 15422 { 15423 if (BX.CHint.cssLoaded === false) 15424 { 15425 BX.load(['/bitrix/js/main/core/css/core_hint.css']); 15426 BX.CHint.cssLoaded = true; 15427 } 15428 15429 this.PARENT = BX(params.parent); 15430 15431 this.HINT = params.hint; 15432 this.HINT_TITLE = params.title; 15433 15434 this.PARAMS = {}; 15435 for (var i in this.defaultSettings) 15436 { 15437 if (null == params[i]) 15438 this.PARAMS[i] = this.defaultSettings[i]; 15439 else 15440 this.PARAMS[i] = params[i]; 15441 } 15442 15443 if (null != params.id) 15444 this.ID = params.id; 15445 15446 this.timer = null; 15447 this.bInited = false; 15448 this.msover = true; 15449 15450 if (this.PARAMS.showOnce) 15451 { 15452 this.__show(); 15453 this.msover = false; 15454 this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout); 15455 } 15456 else if (this.PARENT) 15457 { 15458 BX.bind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 15459 BX.bind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 15460 } 15461 }; 15462 15463 BX.CHint.cssLoaded = false; 15464 15465 BX.CHint.openHints = new Set(); 15466 15467 BX.CHint.globalDisabled = false; 15468 15469 BX.CHint.handleMenuOpen = function() { 15470 BX.CHint.globalDisabled = true; 15471 15472 BX.CHint.openHints.forEach(function(hint) { 15473 hint.__hide_immediately(); 15474 }); 15475 }; 15476 15477 BX.CHint.handleMenuClose = function() { 15478 BX.CHint.globalDisabled = false; 15479 }; 15480 15481 BX.addCustomEvent('onMenuOpen', BX.CHint.handleMenuOpen); 15482 BX.addCustomEvent('onMenuClose', BX.CHint.handleMenuClose); 15483 15484 BX.CHint.prototype.defaultSettings = { 15485 show_timeout: 1000, 15486 hide_timeout: 500, 15487 dx: 2, 15488 showOnce: false, 15489 preventHide: true, 15490 min_width: 250 15491 }; 15492 15493 BX.CHint.prototype.CreateParent = function(element, params) 15494 { 15495 if (this.PARENT) 15496 { 15497 BX.unbind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 15498 BX.unbind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 15499 } 15500 15501 if (!params) params = {}; 15502 var type = 'icon'; 15503 15504 if (params.type && (params.type == "link" || params.type == "icon")) 15505 type = params.type; 15506 15507 if (element) 15508 type = "element";
15509 15510 if (type == "icon") 15511 { 15512 element = BX.create('IMG', { 15513 props: { 15514 src: params.iconSrc 15515 ? params.iconSrc 15516 : "/bitrix/js/main/core/images/hint.gif" 15517 } 15518 }); 15519 } 15520 else if (type == "link") 15521 { 15522 element = BX.create("A", { 15523 props: {href: 'javascript:void(0)'}, 15524 html: '[?]' 15525 }); 15526 } 15527 15528 this.PARENT = element; 15529 15530 BX.bind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 15531 BX.bind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 15532 15533 return this.PARENT; 15534 }; 15535 15536 BX.CHint.prototype.Show = function() 15537 { 15538 this.msover = true; 15539 15540 if (null != this.timer) 15541 clearTimeout(this.timer); 15542 15543 this.timer = setTimeout(BX.proxy(this.__show, this), this.PARAMS.show_timeout); 15544 }; 15545 15546 BX.CHint.prototype.Hide = function() 15547 { 15548 this.msover = false; 15549 15550 if (null != this.timer) 15551 clearTimeout(this.timer); 15552 15553 this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout); 15554 }; 15555 15556 BX.CHint.prototype.__show = function() 15557 { 15558 if (!this.msover || this.disabled || BX.CHint.globalDisabled) return; 15559 if (!this.bInited) this.Init(); 15560 15561 if (this.prepareAdjustPos()) 15562 { 15563 this.DIV.style.display = 'block'; 15564 BX.ZIndexManager.bringToFront(this.DIV); 15565 15566 this.adjustPos(); 15567 15568 BX.CHint.openHints.add(this); 15569 15570 BX.bind(window, 'scroll', BX.proxy(this.__onscroll, this)); 15571 15572 if (this.PARAMS.showOnce) 15573 { 15574 this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout); 15575 } 15576 } 15577 }; 15578 15579 BX.CHint.prototype.__onscroll = function() 15580 { 15581 if (!BX.admin || !BX.admin.panel || !BX.admin.panel.isFixed()) return; 15582 15583 if (this.scrollTimer) clearTimeout(this.scrollTimer); 15584 15585 this.DIV.style.display = 'none'; 15586 this.scrollTimer = setTimeout(BX.proxy(this.Reopen, this), this.PARAMS.show_timeout); 15587 }; 15588 15589 BX.CHint.prototype.Reopen = function() 15590 { 15591 if (null != this.timer) clearTimeout(this.timer); 15592 this.timer = setTimeout(BX.proxy(this.__show, this), 50); 15593 }; 15594 15595 BX.CHint.prototype.__hide = function() 15596 { 15597 if (this.msover) return; 15598 if (!this.bInited) return; 15599 15600 BX.unbind(window, 'scroll', BX.proxy(this.Reopen, this)); 15601 15602 BX.CHint.openHints.delete(this); 15603 15604 if (this.PARAMS.showOnce) 15605 { 15606 this.Destroy(); 15607 } 15608 else 15609 { 15610 this.DIV.style.display = 'none'; 15611 } 15612 }; 15613 15614 BX.CHint.prototype.__hide_immediately = function() 15615 { 15616 this.msover = false; 15617 this.__hide(); 15618 }; 15619 15620 BX.CHint.prototype.Init = function() 15621 { 15622 this.DIV = document.body.appendChild(BX.create('DIV', { 15623 props: {className: 'bx-panel-tooltip'}, 15624 style: { 15625 display: 'none', 15626 position: 'absolute', 15627 visibility: 'hidden' 15628 }, 15629 children: [ 15630 (this.CONTENT = BX.create('DIV', { 15631 props: {className: 'bx-panel-tooltip-content'}, 15632 children: [ 15633 BX.create('DIV', { 15634 props: {className: 'bx-panel-tooltip-underlay'}, 15635 children: [ 15636 BX.create('DIV', {props: {className: 'bx-panel-tooltip-underlay-bg'}}) 15637 ] 15638 }) 15639 ] 15640 })) 15641 ] 15642 })); 15643 15644 BX.ZIndexManager.register(this.DIV); 15645 15646 if (this.ID) 15647 { 15648 this.CONTENT.insertBefore(BX.create('A', { 15649 attrs: {href: 'javascript:void(0)'}, 15650 props: {className: 'bx-panel-tooltip-close'}, 15651 events: {click: BX.delegate(this.Close, this)} 15652 }), this.CONTENT.firstChild); 15653 } 15654 15655 if (this.HINT_TITLE) 15656 { 15657 this.CONTENT.appendChild( 15658 BX.create('DIV', { 15659 props: {className: 'bx-panel-tooltip-title'}, 15660 text: this.HINT_TITLE 15661 }) 15662 ); 15663 } 15664 15665 if (this.HINT) 15666 { 15667 this.CONTENT_TEXT = this.CONTENT.appendChild(BX.create('DIV', {props: {className: 'bx-panel-tooltip-text'}})).appendChild(BX.create('SPAN', {html: this.HINT})); 15668 } 15669 15670 if (this.PARAMS.preventHide) 15671 { 15672 BX.bind(this.DIV, 'mouseout', BX.proxy(this.Hide, this)); 15673 BX.bind(this.DIV, 'mouseover', BX.proxy(this.Show, this)); 15674 } 15675 15676 this.bInited = true; 15677 }; 15678 15679 BX.CHint.prototype.setContent = function(content) 15680 { 15681 this.HINT = content; 15682 15683 if (this.CONTENT_TEXT) 15684 this.CONTENT_TEXT.innerHTML = this.HINT; 15685 else 15686 this.CONTENT_TEXT = this.CONTENT.appendChild(BX.create('DIV', {props: {className: 'bx-panel-tooltip-text'}})).appendChild(BX.create('SPAN', {html: this.HINT})); 15687 }; 15688 15689 BX.CHint.prototype.prepareAdjustPos = function() 15690 { 15691 this._wnd = {scrollPos: BX.GetWindowScrollPos(),scrollSize:BX.GetWindowScrollSize()}; 15692 return BX.style(this.PARENT, 'display') != 'none'; 15693 }; 15694 15695 BX.CHint.prototype.getAdjustPos = function() 15696 { 15697 var res = {}, pos = BX.pos(this.PARENT), min_top = 0; 15698 15699 res.top = pos.bottom + this.PARAMS.dx; 15700 15701 if (BX.admin && BX.admin.panel.DIV) 15702 { 15703 min_top = BX.admin.panel.DIV.offsetHeight + this.PARAMS.dx; 15704 15705 if (BX.admin.panel.isFixed()) 15706 { 15707 min_top += this._wnd.scrollPos.scrollTop; 15708 } 15709 } 15710 15711 if (res.top < min_top) 15712 res.top = min_top; 15713 else 15714 { 15715 if (res.top + this.DIV.offsetHeight > this._wnd.scrollSize.scrollHeight) 15716 res.top = pos.top - this.PARAMS.dx - this.DIV.offsetHeight; 15717 } 15718 15719 res.left = pos.left; 15720 if (pos.left < this.PARAMS.dx) 15721 pos.left = this.PARAMS.dx; 15722 else 15723 { 15724 var floatWidth = this.DIV.offsetWidth; 15725 15726 var max_left = this._wnd.scrollSize.scrollWidth - floatWidth - this.PARAMS.dx; 15727 15728 if (res.left > max_left) 15729 res.left = max_left; 15730 } 15731 15732 return res; 15733 }; 15734 15735 BX.CHint.prototype.adjustWidth = function() 15736 { 15737 if (this.bWidthAdjusted) return; 15738 15739 var w = this.DIV.offsetWidth, h = this.DIV.offsetHeight; 15740 15741 if (w > this.PARAMS.min_width) 15742 w = Math.round(Math.sqrt(1.618*w*h)); 15743 15744 if (w < this.PARAMS.min_width) 15745 w = this.PARAMS.min_width; 15746 15747 this.DIV.style.width = w + "px"; 15748 15749 if (this._adjustWidthInt) 15750 clearInterval(this._adjustWidthInt); 15751 this._adjustWidthInt = setInterval(BX.delegate(this._adjustWidthInterval, this), 5); 15752 15753 this.bWidthAdjusted = true; 15754 }; 15755 15756 BX.CHint.prototype._adjustWidthInterval = function() 15757 { 15758 if (!this.DIV || this.DIV.style.display == 'none') 15759 clearInterval(this._adjustWidthInt); 15760 15761 var
15762 dW = 20, 15763 maxWidth = 1500, 15764 w = this.DIV.offsetWidth, 15765 w1 = this.CONTENT_TEXT.offsetWidth; 15766 15767 if (w > 0 && w1 > 0 && w - w1 < dW && w < maxWidth) 15768 { 15769 this.DIV.style.width = (w + dW) + "px"; 15770 return; 15771 } 15772 15773 clearInterval(this._adjustWidthInt); 15774 }; 15775 15776 BX.CHint.prototype.adjustPos = function() 15777 { 15778 this.adjustWidth(); 15779 15780 var pos = this.getAdjustPos(); 15781 15782 this.DIV.style.top = pos.top + 'px'; 15783 this.DIV.style.left = pos.left + 'px'; 15784 }; 15785 15786 BX.CHint.prototype.Close = function() 15787 { 15788 if (this.ID && BX.WindowManager) 15789 BX.WindowManager.saveWindowOptions(this.ID, {display: 'off'}); 15790 this.__hide_immediately(); 15791 this.Destroy(); 15792 }; 15793 15794 BX.CHint.prototype.Destroy = function() 15795 { 15796 if (this.PARENT) 15797 { 15798 BX.unbind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 15799 BX.unbind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 15800 } 15801 15802 if (this.DIV) 15803 { 15804 BX.unbind(this.DIV, 'mouseover', BX.proxy(this.Show, this)); 15805 BX.unbind(this.DIV, 'mouseout', BX.proxy(this.Hide, this)); 15806 15807 BX.ZIndexManager.unregister(this.DIV); 15808 15809 BX.cleanNode(this.DIV, true); 15810 } 15811 }; 15812 15813 BX.CHint.prototype.enable = function(){this.disabled = false;}; 15814 BX.CHint.prototype.disable = function(){this.__hide_immediately(); this.disabled = true;}; 15815 15816 15817 function _adjustWait() 15818 { 15819 if (!this.bxmsg) return; 15820 15821 var arContainerPos = BX.pos(this), 15822 div_top = arContainerPos.top; 15823 15824 if (div_top < BX.GetDocElement().scrollTop) 15825 div_top = BX.GetDocElement().scrollTop + 5; 15826 15827 this.bxmsg.style.top = (div_top + 5) + 'px'; 15828 15829 if (this == BX.GetDocElement()) 15830 { 15831 this.bxmsg.style.right = '5px'; 15832 } 15833 else 15834 { 15835 this.bxmsg.style.left = (arContainerPos.right - this.bxmsg.offsetWidth - 5) + 'px'; 15836 } 15837 } 15838 15839 function _processTpl(tplNode, cb, bKillTpl) 15840 { 15841 if (tplNode) 15842 { 15843 if (bKillTpl) 15844 tplNode.parentNode.removeChild(tplNode); 15845 15846 var res = {}, nodes = BX.findChildren(tplNode, {attribute: 'data-role'}, true); 15847 15848 for (var i = 0, l = nodes.length; i < l; i++) 15849 { 15850 res[nodes[i].getAttribute('data-role')] = nodes[i]; 15851 } 15852 15853 cb.apply(tplNode, [res]); 15854 } 15855 } 15856 15857 function _checkNode(obj, params) 15858 { 15859 params = params || {}; 15860 15861 if (BX.type.isFunction(params)) 15862 return params.call(window, obj); 15863 15864 if (!params.allowTextNodes && !BX.type.isElementNode(obj)) 15865 return false; 15866 var i,j,len; 15867 for (i in params) 15868 { 15869 if(params.hasOwnProperty(i)) 15870 { 15871 switch(i) 15872 { 15873 case 'tag': 15874 case 'tagName': 15875 if (BX.type.isString(params[i])) 15876 { 15877 if (obj.tagName.toUpperCase() != params[i].toUpperCase()) 15878 return false; 15879 } 15880 else if (params[i] instanceof RegExp) 15881 { 15882 if (!params[i].test(obj.tagName)) 15883 return false; 15884 } 15885 break; 15886 15887 case 'class': 15888 case 'className': 15889 if (BX.type.isString(params[i])) 15890 { 15891 if (!BX.hasClass(obj, params[i])) 15892 return false; 15893 } 15894 else if (params[i] instanceof RegExp) 15895 { 15896 if (!BX.type.isString(obj.className) || !params[i].test(obj.className)) 15897 return false; 15898 } 15899 break; 15900 15901 case 'attr': 15902 case 'attrs': 15903 case 'attribute': 15904 if (BX.type.isString(params[i])) 15905 { 15906 if (!obj.getAttribute(params[i])) 15907 return false; 15908 } 15909 else if (BX.type.isArray(params[i])) 15910 { 15911 for (j = 0, len = params[i].length; j < len; j++) 15912 { 15913 if (params[i] && !obj.getAttribute(params[i])) 15914 return false; 15915 } 15916 } 15917 else 15918 { 15919 for (j in params[i]) 15920 { 15921 if(params[i].hasOwnProperty(j)) 15922 { 15923 var q = obj.getAttribute(j); 15924 if (params[i][j] instanceof RegExp) 15925 { 15926 if (!BX.type.isString(q) || !params[i][j].test(q)) 15927 { 15928 return false; 15929 } 15930 } 15931 else 15932 { 15933 if (q != '' + params[i][j]) 15934 { 15935 return false; 15936 } 15937 } 15938 } 15939 } 15940 } 15941 break; 15942 15943 case 'property': 15944 case 'props': 15945 if (BX.type.isString(params[i])) 15946 { 15947 if (!obj[params[i]]) 15948 return false; 15949 } 15950 else if (BX.type.isArray(params[i])) 15951 { 15952 for (j = 0, len = params[i].length; j < len; j++) 15953 { 15954 if (params[i] && !obj[params[i]]) 15955 return false;
15956 } 15957 } 15958 else 15959 { 15960 for (j in params[i]) 15961 { 15962 if (BX.type.isString(params[i][j])) 15963 { 15964 if (obj[j] != params[i][j]) 15965 return false; 15966 } 15967 else if (params[i][j] instanceof RegExp) 15968 { 15969 if (!BX.type.isString(obj[j]) || !params[i][j].test(obj[j])) 15970 return false; 15971 } 15972 } 15973 } 15974 break; 15975 15976 case 'callback': 15977 return params[i](obj); 15978 } 15979 } 15980 } 15981 15982 return true; 15983 } 15984 15985 window.addEventListener('pagehide', () => { 15986 garbageCollectors.forEach(({ callback, context = window }) => { 15987 try 15988 { 15989 callback.apply(context); 15990 } catch (err) {} 15991 }); 15992 }); 15993 15994 // set empty ready handler 15995 BX(BX.DoNothing); 15996 window.BX = BX; 15997 15998 BX.browser.addGlobalClass(); 15999 16000 /* data storage */ 16001 BX.data = function(node, key, value) 16002 { 16003 if(typeof node == 'undefined') 16004 return undefined; 16005 16006 if(typeof key == 'undefined') 16007 return undefined; 16008 16009 if(typeof value != 'undefined') 16010 { 16011 // write to manager 16012 dataStorage.set(node, key, value); 16013 } 16014 else 16015 { 16016 var data; 16017 16018 // from manager 16019 if((data = dataStorage.get(node, key)) != undefined) 16020 { 16021 return data; 16022 } 16023 else 16024 { 16025 // from attribute data-* 16026 if('getAttribute' in node) 16027 { 16028 data = node.getAttribute('data-'+key.toString()); 16029 if(data === null) 16030 { 16031 return undefined; 16032 } 16033 return data; 16034 } 16035 } 16036 16037 return undefined; 16038 } 16039 }; 16040 16041 BX.DataStorage = function() 16042 { 16043 16044 this.keyOffset = 1; 16045 this.data = {}; 16046 this.uniqueTag = 'BX-'+Math.random(); 16047 16048 this.resolve = function(owner, create){ 16049 if(typeof owner[this.uniqueTag] == 'undefined') 16050 if(create) 16051 { 16052 try 16053 { 16054 Object.defineProperty(owner, this.uniqueTag, { 16055 value: this.keyOffset++ 16056 }); 16057 } 16058 catch(e) 16059 { 16060 owner[this.uniqueTag] = this.keyOffset++; 16061 } 16062 } 16063 else 16064 return undefined; 16065 16066 return owner[this.uniqueTag]; 16067 }; 16068 this.get = function(owner, key){ 16069 if((owner != document && !BX.type.isElementNode(owner)) || typeof key == 'undefined') 16070 return undefined; 16071 16072 owner = this.resolve(owner, false); 16073 16074 if(typeof owner == 'undefined' || typeof this.data[owner] == 'undefined') 16075 return undefined; 16076 16077 return this.data[owner][key]; 16078 }; 16079 this.set = function(owner, key, value){ 16080 16081 if((owner != document && !BX.type.isElementNode(owner)) || typeof value == 'undefined') 16082 return; 16083 16084 var o = this.resolve(owner, true); 16085 16086 if(typeof this.data[o] == 'undefined') 16087 this.data[o] = {}; 16088 16089 this.data[o][key] = value; 16090 }; 16091 }; 16092 16093// some internal variables for new logic 16094 var dataStorage = new BX.DataStorage(); // manager which BX.data() uses to keep data 16095})(window.BX); 16096 16097 16098;(function(window) 16099{ 16100 /****************** ATTENTION ******************************* 16101 * Please do not use Bitrix CoreJS in this class. 16102 * This class can be called on page without Bitrix Framework 16103 *************************************************************/ 16104 16105 if (!window.BX) 16106 { 16107 window.BX = {}; 16108 } 16109 16110 var BX = window.BX; 16111 16112 BX.Promise = function(fn, ctx) // fn is future-reserved 16113 { 16114 this.state = null; 16115 this.value = null; 16116 this.reason = null; 16117 this.next = null; 16118 this.ctx = ctx || this; 16119 16120 this.onFulfilled = []; 16121 this.onRejected = []; 16122 }; 16123 BX.Promise.prototype.fulfill = function(value) 16124 { 16125 this.checkState(); 16126 16127 this.value = value; 16128 this.state = true; 16129 this.execute(); 16130 }; 16131 BX.Promise.prototype.reject = function(reason) 16132 { 16133 this.checkState(); 16134 16135 this.reason = reason; 16136 this.state = false; 16137 this.execute(); 16138 }; 16139 BX.Promise.prototype.then = function(onFulfilled, onRejected) 16140 { 16141 if(typeof (onFulfilled) == "function" || onFulfilled instanceof Function) 16142 { 16143 this.onFulfilled.push(onFulfilled); 16144 } 16145 if(typeof (onRejected) == "function" || onRejected instanceof Function) 16146 { 16147 this.onRejected.push(onRejected); 16148 } 16149 16150 if(this.next === null) 16151 { 16152 this.next = new BX.Promise(null, this.ctx); 16153 } 16154 16155 if(this.state !== null) // if promise was already resolved, execute immediately 16156 { 16157 this.execute(); 16158 } 16159 16160 return this.next; 16161 }; 16162 16163 BX.Promise.prototype.catch = function(onRejected) 16164 { 16165 if(typeof (onRejected) == "function" || onRejected instanceof Function) 16166 { 16167 this.onRejected.push(onRejected); 16168 } 16169 16170 if(this.next === null) 16171 { 16172 this.next = new BX.Promise(null, this.ctx); 16173 } 16174 16175 if(this.state !== null) // if promise was already resolved, execute immediately 16176 { 16177 this.execute(); 16178 } 16179 16180 return this.next; 16181 }; 16182 16183 BX.Promise.prototype.setAutoResolve = function(way, ms) 16184 { 16185 this.timer = setTimeout(function(){ 16186 if(this.state === null) 16187 { 16188 this[way ? 'fulfill' : 'reject'](); 16189 } 16190 }.bind(this), ms || 15); 16191 };
16192 BX.Promise.prototype.cancelAutoResolve = function() 16193 { 16194 clearTimeout(this.timer); 16195 }; 16196 /** 16197 * Resolve function. This function allows promise chaining, like ..then().then()... 16198 * Typical usage: 16199 * 16200 * var p = new Promise(); 16201 * 16202 * p.then(function(value){ 16203 * return someValue; // next promise in the chain will be fulfilled with someValue 16204 * }).then(function(value){ 16205 * 16206 * var p1 = new Promise(); 16207 * *** some async code here, that eventually resolves p1 *** 16208 * 16209 * return p1; // chain will resume when p1 resolved (fulfilled or rejected) 16210 * }).then(function(value){ 16211 * 16212 * // you can also do 16213 * var e = new Error(); 16214 * throw e; 16215 * // it will cause next promise to be rejected with e 16216 * 16217 * return someOtherValue; 16218 * }).then(function(value){ 16219 * ... 16220 * }, function(reason){ 16221 * // promise was rejected with reason 16222 * })...; 16223 * 16224 * p.fulfill('let`s start this chain'); 16225 * 16226 * @param x 16227 */ 16228 BX.Promise.prototype.resolve = function(x) 16229 { 16230 var this_ = this; 16231 16232 if(this === x) 16233 { 16234 this.reject(new TypeError('Promise cannot fulfill or reject itself')); // avoid recursion 16235 } 16236 // allow "pausing" promise chaining until promise x is fulfilled or rejected 16237 else if(x && x.toString() === "[object BX.Promise]") 16238 { 16239 x.then(function(value){ 16240 this_.fulfill(value); 16241 }, function(reason){ 16242 this_.reject(reason); 16243 }); 16244 } 16245 else // auto-fulfill this promise 16246 { 16247 this.fulfill(x); 16248 } 16249 }; 16250 16251 BX.Promise.prototype.toString = function() 16252 { 16253 return "[object BX.Promise]"; 16254 }; 16255 16256 BX.Promise.prototype.execute = function() 16257 { 16258 if(this.state === null) 16259 { 16260 //then() must not be called before BX.Promise resolve() happens 16261 return; 16262 } 16263 16264 var value = undefined; 16265 var reason = undefined; 16266 var x = undefined; 16267 var k; 16268 if(this.state === true) // promise was fulfill()-ed 16269 { 16270 if(this.onFulfilled.length) 16271 { 16272 try 16273 { 16274 for(k = 0; k < this.onFulfilled.length; k++) 16275 {
16276 x = this.onFulfilled[k].apply(this.ctx, [this.value]); 16277 if(typeof x != 'undefined') 16278 { 16279 value = x; 16280 } 16281 } 16282 } 16283 catch(e) 16284 { 16285 if('console' in window) 16286 { 16287 console.dir(e); 16288 } 16289 16290 if (typeof BX.debug !== 'undefined') 16291 { 16292 BX.debug(e); 16293 } 16294 16295 reason = e; // reject next 16296 } 16297 } 16298 else 16299 { 16300 value = this.value; // resolve next 16301 } 16302 } 16303 else if(this.state === false) // promise was reject()-ed 16304 { 16305 if(this.onRejected.length) 16306 { 16307 try 16308 { 16309 for(k = 0; k < this.onRejected.length; k++) 16310 { 16311 x = this.onRejected[k].apply(this.ctx, [this.reason]); 16312 if(typeof x != 'undefined') 16313 { 16314 value = x; 16315 } 16316 } 16317 } 16318 catch(e) 16319 { 16320 if('console' in window) 16321 { 16322 console.dir(e); 16323 } 16324 16325 if (typeof BX.debug !== 'undefined') 16326 { 16327 BX.debug(e); 16328 } 16329 16330 reason = e; // reject next 16331 } 16332 } 16333 else 16334 { 16335 reason = this.reason; // reject next 16336 } 16337 } 16338 16339 if(this.next !== null) 16340 { 16341 if(typeof reason != 'undefined') 16342 { 16343 this.next.reject(reason); 16344 } 16345 else if(typeof value != 'undefined') 16346 { 16347 this.next.resolve(value); 16348 } 16349 } 16350 }; 16351 BX.Promise.prototype.checkState = function() 16352 { 16353 if(this.state !== null) 16354 { 16355 throw new Error('You can not do fulfill() or reject() multiple times'); 16356 } 16357 }; 16358})(window); 16359 16360 16361 16362 16363;(function(window){ 16364 16365if (window.BX.ajax) 16366 return; 16367 16368var 16369 BX = window.BX, 16370 16371 tempDefaultConfig = {}, 16372 defaultConfig = { 16373 method: 'GET', // request method: GET|POST 16374 dataType: 'html', // type of data loading: html|json|script 16375 timeout: 0, // request timeout in seconds. 0 for browser-default 16376 async: true, // whether request is asynchronous or not 16377 processData: true, // any data processing is disabled if false, only callback call 16378 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 16379 emulateOnload: true, 16380 skipAuthCheck: false, // whether to check authorization failure (SHOUD be set to true for CORS requests) 16381 start: true, // send request immediately (if false, request can be started manually via XMLHttpRequest object returned) 16382 cache: true, // whether NOT to add random addition to URL 16383 preparePost: true, // whether set Content-Type x-www-form-urlencoded in POST 16384 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'}] 16385 lsTimeout: 30, //local storage data TTL. useless without lsId. 16386 lsForce: false //wheter to force query instead of using localStorage data. useless without lsId. 16387/* 16388other parameters: 16389 url: url to get/post 16390 data: data to post 16391 onsuccess: successful request callback. BX.proxy may be used. 16392 onfailure: request failure callback. BX.proxy may be used. 16393 onprogress: request progress callback. BX.proxy may be used. 16394 16395 lsId: local storage id - for constantly updating queries which can communicate via localStorage. core_ls.js needed 16396 16397any of the default parameters can be overridden. defaults can be changed by BX.ajax.Setup() - for all further requests! 16398*/ 16399 }, 16400 loadedScripts = {}, 16401 loadedScriptsQueue = [], 16402 r = { 16403 'url_utf': /[^\034-\254]+/g, 16404 'script_self': /\/bitrix\/js\/main\/core\/core(_ajax)*.js$/i, 16405 'script_self_window': /\/bitrix\/js\/main\/core\/core_window.js$/i, 16406 'script_self_admin': /\/bitrix\/js\/main\/core\/core_admin.js$/i, 16407 'script_onload': /window.onload/g 16408 }; 16409 16410// low-level method 16411BX.ajax = function(config) 16412{ 16413 var status, data; 16414
16415 if (!config || !config.url || !BX.type.isString(config.url)) 16416 { 16417 return false; 16418 } 16419 16420 for (var i in tempDefaultConfig) 16421 if (typeof (config[i]) == "undefined") config[i] = tempDefaultConfig[i]; 16422 16423 tempDefaultConfig = {}; 16424 16425 for (i in defaultConfig) 16426 if (typeof (config[i]) == "undefined") config[i] = defaultConfig[i]; 16427 16428 config.method = config.method.toUpperCase(); 16429 16430 if (!BX.localStorage) 16431 config.lsId = null; 16432 16433 if (BX.browser.IsIE()) 16434 { 16435 var result = r.url_utf.exec(config.url); 16436 if (result) 16437 { 16438 do 16439 { 16440 config.url = config.url.replace(result, BX.util.urlencode(result)); 16441 result = r.url_utf.exec(config.url); 16442 } while (result); 16443 } 16444 } 16445 16446 if(config.dataType == 'json') 16447 config.emulateOnload = false; 16448 16449 if (!config.cache && config.method == 'GET') 16450 config.url = BX.ajax._uncache(config.url); 16451 16452 if (config.method == 'POST') 16453 { 16454 if (config.preparePost) 16455 { 16456 config.data = BX.ajax.prepareData(config.data); 16457 } 16458 else if (getLastContentTypeHeader(config.headers) === 'application/json') 16459 { 16460 const isJson = ( 16461 BX.Type.isPlainObject(config.data) 16462 || BX.Type.isString(config.data) 16463 || BX.Type.isNumber(config.data) 16464 || BX.Type.isBoolean(config.data) 16465 || BX.Type.isArray(config.data) 16466 ); 16467 16468 if (isJson) 16469 { 16470 config.data = JSON.stringify(config.data); 16471 } 16472 } 16473 } 16474 16475 var bXHR = true; 16476 if (config.lsId && !config.lsForce) 16477 { 16478 var v = BX.localStorage.get('ajax-' + config.lsId); 16479 if (v !== null) 16480 { 16481 bXHR = false; 16482 16483 var lsHandler = function(lsData) { 16484 if (lsData.key == 'ajax-' + config.lsId && lsData.value != 'BXAJAXWAIT') 16485 { 16486 var data = lsData.value, 16487 bRemove = !!lsData.oldValue && data == null; 16488 if (!bRemove) 16489 BX.ajax.__run(config, data); 16490 else if (config.onfailure) 16491 config.onfailure("timeout"); 16492 16493 BX.removeCustomEvent('onLocalStorageChange', lsHandler); 16494 } 16495 }; 16496 16497 if (v == 'BXAJAXWAIT') 16498 { 16499 BX.addCustomEvent('onLocalStorageChange', lsHandler); 16500 } 16501 else 16502 { 16503 setTimeout(function() {lsHandler({key: 'ajax-' + config.lsId, value: v})}, 10); 16504 } 16505 } 16506 } 16507 16508 if (bXHR) 16509 { 16510 config.xhr = BX.ajax.xhr(); 16511 if (!config.xhr) return; 16512 16513 if (config.lsId) 16514 { 16515 BX.localStorage.set('ajax-' + config.lsId, 'BXAJAXWAIT', config.lsTimeout); 16516 } 16517 16518 if (BX.Type.isFunction(config.onprogress)) 16519 { 16520 BX.bind(config.xhr, 'progress', config.onprogress); 16521 } 16522 16523 if (BX.Type.isFunction(config.onprogressupload) && config.xhr.upload) 16524 { 16525 BX.bind(config.xhr.upload, 'progress', config.onprogressupload); 16526 } 16527 16528 config.xhr.open(config.method, config.url, config.async); 16529 16530 if (!config.skipBxHeader && !BX.ajax.isCrossDomain(config.url)) 16531 { 16532 config.xhr.setRequestHeader('Bx-ajax', 'true'); 16533 } 16534 16535 if (config.method == 'POST' && config.preparePost) 16536 { 16537 config.xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 16538 } 16539 if (typeof(config.headers) == "object") 16540 { 16541 for (i = 0; i < config.headers.length; i++) 16542 config.xhr.setRequestHeader(config.headers[i].name, config.headers[i].value); 16543 } 16544 16545 var bRequestCompleted = false; 16546 var onreadystatechange = config.xhr.onreadystatechange = function(additional) 16547 { 16548 if (bRequestCompleted) 16549 return; 16550 16551 if (additional === 'timeout') 16552 { 16553 if (config.onfailure) 16554 { 16555 config.onfailure('timeout', '', config); 16556 } 16557 16558 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['timeout', '', config]); 16559 16560 config.xhr.onreadystatechange = BX.DoNothing; 16561 config.xhr.abort(); 16562 16563 if (config.async) 16564 { 16565 config.xhr = null; 16566 } 16567 } 16568 else 16569 { 16570 if (config.xhr.readyState == 4 || additional == 'run') 16571 { 16572 status = BX.ajax.xhrSuccess(config.xhr) ? "success" : "error"; 16573 bRequestCompleted = true; 16574 config.xhr.onreadystatechange = BX.DoNothing; 16575 16576 if (status == 'success') 16577 { 16578 var authHeader = (!!config.skipAuthCheck || BX.ajax.isCrossDomain(config.url)) 16579 ? false 16580 : config.xhr.getResponseHeader('X-Bitrix-Ajax-Status'); 16581 16582 if(!!authHeader && authHeader == 'Authorize') 16583 { 16584 if (config.onfailure) 16585 { 16586 config.onfailure('auth', config.xhr.status, config); 16587 } 16588 16589 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['auth', config.xhr.status, config]); 16590 } 16591 else 16592 { 16593 var data = config.xhr.responseText; 16594 16595 if (config.lsId) 16596 { 16597 BX.localStorage.set('ajax-' + config.lsId, data, config.lsTimeout); 16598 } 16599 16600 BX.ajax.__run(config, data); 16601 } 16602 } 16603 else 16604 { 16605 if (config.onfailure) 16606 { 16607 config.onfailure('status', config.xhr.status, config); 16608 } 16609 16610 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['status', config.xhr.status, config]); 16611 } 16612 16613 if (config.async) 16614 { 16615 config.xhr = null; 16616 } 16617 } 16618 } 16619 }; 16620 16621 if (config.async && config.timeout > 0) 16622 { 16623 setTimeout(function() { 16624 if (config.xhr && !bRequestCompleted) 16625 { 16626 onreadystatechange("timeout"); 16627 } 16628 }, config.timeout * 1000); 16629 } 16630 16631 if (config.start) 16632 {
16633 config.xhr.send(config.data); 16634 16635 if (!config.async) 16636 { 16637 onreadystatechange('run'); 16638 } 16639 } 16640 16641 return config.xhr; 16642 } 16643}; 16644 16645BX.ajax.xhr = function() 16646{ 16647 if (window.XMLHttpRequest) 16648 { 16649 try {return new XMLHttpRequest();} catch(e){} 16650 } 16651 else if (window.ActiveXObject) 16652 { 16653 try { return new window.ActiveXObject("Msxml2.XMLHTTP.6.0"); } 16654 catch(e) {} 16655 try { return new window.ActiveXObject("Msxml2.XMLHTTP.3.0"); } 16656 catch(e) {} 16657 try { return new window.ActiveXObject("Msxml2.XMLHTTP"); } 16658 catch(e) {} 16659 try { return new window.ActiveXObject("Microsoft.XMLHTTP"); } 16660 catch(e) {} 16661 throw new Error("This browser does not support XMLHttpRequest."); 16662 } 16663 16664 return null; 16665}; 16666 16667BX.ajax.isCrossDomain = function(url, location) 16668{ 16669 location = location || window.location; 16670 16671 //Relative URL gets a current protocol 16672 if (url.indexOf("//") === 0) 16673 { 16674 url = location.protocol + url; 16675 } 16676 16677 //Fast check 16678 if (url.indexOf("http") !== 0) 16679 { 16680 return false; 16681 } 16682 16683 var link = window.document.createElement("a"); 16684 link.href = url; 16685 16686 return link.protocol !== location.protocol || 16687 link.hostname !== location.hostname || 16688 BX.ajax.getHostPort(link.protocol, link.host) !== BX.ajax.getHostPort(location.protocol, location.host); 16689}; 16690 16691BX.ajax.getHostPort = function(protocol, host) 16692{ 16693 var match = /:(\d+)$/.exec(host); 16694 if (match) 16695 { 16696 return match[1]; 16697 } 16698 else 16699 { 16700 if (protocol === "http:") 16701 { 16702 return "80"; 16703 } 16704 else if (protocol === "https:") 16705 { 16706 return "443"; 16707 } 16708 } 16709 16710 return ""; 16711}; 16712 16713BX.ajax.__prepareOnload = function(scripts, ajax_session) 16714{ 16715 if (scripts.length > 0) 16716 { 16717 BX.ajax['onload_' + ajax_session] = null; 16718 16719 for (var i=0,len=scripts.length;i<len;i++) 16720 { 16721 if (scripts[i].isInternal) 16722 { 16723 scripts[i].JS = scripts[i].JS.replace(r.script_onload, 'BX.aja
16723x.onload_' + ajax_session); 16724 } 16725 } 16726 } 16727 16728 BX.CaptureEventsGet(); 16729 BX.CaptureEvents(window, 'load'); 16730}; 16731 16732BX.ajax.__runOnload = function(ajax_session) 16733{ 16734 if (null != BX.ajax['onload_' + ajax_session]) 16735 { 16736 BX.ajax['onload_' + ajax_session].apply(window); 16737 BX.ajax['onload_' + ajax_session] = null; 16738 } 16739 16740 var h = BX.CaptureEventsGet(); 16741 16742 if (h) 16743 { 16744 for (var i=0; i<h.length; i++) 16745 h[i].apply(window); 16746 } 16747}; 16748 16749BX.ajax.__run = function(config, data) 16750{ 16751 if (!config.processData) 16752 { 16753 if (config.onsuccess) 16754 { 16755 config.onsuccess(data); 16756 } 16757 16758 BX.onCustomEvent(config.xhr, 'onAjaxSuccess', [data, config]); 16759 } 16760 else 16761 { 16762 data = BX.ajax.processRequestData(data, config); 16763 } 16764}; 16765 16766 16767BX.ajax._onParseJSONFailure = function(data) 16768{ 16769 this.jsonFailure = true; 16770 this.jsonResponse = data; 16771 this.jsonProactive = /^\[WAF\]/.test(data); 16772}; 16773 16774BX.ajax.processRequestData = function(data, config) 16775{ 16776 var result, scripts = [], styles = []; 16777 switch (config.dataType.toUpperCase()) 16778 { 16779 case 'JSON': 16780 16781 var context = config.xhr || {}; 16782 BX.addCustomEvent(context, 'onParseJSONFailure', BX.proxy(BX.ajax._onParseJSONFailure, config)); 16783 result = BX.parseJSON(data, context); 16784 BX.removeCustomEvent(context, 'onParseJSONFailure', BX.proxy(BX.ajax._onParseJSONFailure, config)); 16785 16786 if(!!result && BX.type.isArray(result['bxjs'])) 16787 { 16788 for(var i = 0; i < result['bxjs'].length; i++) 16789 { 16790 if(BX.type.isNotEmptyString(result['bxjs'][i])) 16791 { 16792 scripts.push({ 16793 "isInternal": false, 16794 "JS": result['bxjs'][i], 16795 "bRunFirst": config.scriptsRunFirst 16796 }); 16797 } 16798 else 16799 { 16800 scripts.push(result['bxjs'][i]) 16801 } 16802 } 16803 } 16804 16805 if(!!result && BX.type.isArray(result['bxcss'])) 16806 { 16807 styles = result['bxcss']; 16808 } 16809 16810 break; 16811 case 'SCRIPT': 16812 scripts.push({"isInternal": true, "JS": data, "bRunFirst": config.scriptsRunFirst}); 16813 result = data; 16814 break; 16815 16816 default: // HTML 16817 var ob = BX.processHTML(data, config.scriptsRunFirst); 16818 result = ob.HTML; scripts = ob.SCRIPT; styles = ob.STYLE; 16819 break; 16820 } 16821 16822 if (styles.length > 0) 16823 { 16824 BX.loadCSS(styles); 16825 } 16826 16827 let ajax_session = null; 16828 if (config.emulateOnload) 16829 { 16830 ajax_session = parseInt(Math.random() * 1000000); 16831 BX.ajax.__prepareOnload(scripts, ajax_session); 16832 } 16833 16834 const cb = BX.defer(function() 16835 { 16836 if (config.emulateOnload) 16837 { 16838 BX.ajax.__runOnload(ajax_session); 16839 } 16840 16841 BX.onCustomEvent(config.xhr, 'onAjaxSuccessFinish', [config]); 16842 }); 16843 16844 try 16845 { 16846 if (!!config.jsonFailure) 16847 { 16848 throw {type: 'json_failure', data: config.jsonResponse, bProactive: config.jsonProactive}; 16849 } 16850 16851 config.scripts = scripts; 16852 16853 BX.ajax.processScripts(config.scripts, true); 16854 16855 if (config.onsuccess) 16856 { 16857 config.onsuccess(result); 16858 } 16859 16860 BX.onCustomEvent(config.xhr, 'onAjaxSuccess', [result, config]); 16861 16862 BX.ajax.processScripts(config.scripts, false, cb); 16863 } 16864 catch (e) 16865 { 16866 if (config.onfailure) 16867 config.onfailure("processing", e); 16868 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['processing', e, config]); 16869 } 16870}; 16871 16872BX.ajax.processScripts = function(scripts, bRunFirst, cb) 16873{ 16874 var scriptsExt = [], scriptsInt = ''; 16875 16876 cb = cb || BX.DoNothing; 16877 16878 for (var i = 0, length = scripts.length; i < length; i++) 16879 { 16880 if (typeof bRunFirst != 'undefined' && bRunFirst != !!scripts[i].bRunFirst) 16881 continue; 16882 16883 if (scripts[i].isInternal) 16884 scriptsInt += ';' + scripts[i].JS; 16885 else 16886 scriptsExt.push(scripts[i].JS); 16887 } 16888 16889 scriptsExt = BX.util.array_unique(scriptsExt); 16890 var inlineScripts = scriptsInt.length > 0 ? function() { BX.evalGlobal(scriptsInt); } : BX.DoNothing; 16891 16892 if (scriptsExt.length > 0) 16893 { 16894 BX.load(scriptsExt, function() { 16895 inlineScripts(); 16896 cb(); 16897 }); 16898 } 16899 else 16900 { 16901 inlineScripts(); 16902 cb(); 16903 } 16904}; 16905 16906// TODO: extend this function to use with any data objects or forms 16907BX.ajax.prepareData = function(arData, prefix) 16908{ 16909 var data = ''; 16910 if (BX.type.isString(arData)) 16911 data = arData; 16912 else if (null != arData) 16913 { 16914 for(var i in arData) 16915 { 16916 if (arData.hasOwnProperty(i)) 16917 { 16918 if (data.length > 0) 16919 data += '&'; 16920 var name = BX.util.urlencode(i); 16921 if(prefix) 16922 name = prefix + '[' + name + ']'; 16923 if(typeof arData[i] == 'object') 16924 data += BX.ajax.prepareData(arData[i], name); 16925 else 16926 data += name + '=' + BX.util.urlencode(arData[i]); 16927 } 16928 } 16929 } 16930 return data; 16931}; 16932 16933BX.ajax.xhrSuccess = function(xhr) 16934{ 16935 return (xhr.status >= 200 && xhr.status < 300) || xhr.status === 304 || xhr.status === 1223 || xhr.status === 0; 16936}; 16937 16938BX.ajax.Setup = function(config, bTemp) 16939{ 16940 bTemp = !!bTemp; 16941 16942 for (var i in config) 16943 { 16944 if (bTemp) 16945 tempDefaultConfig[i] = config[i]; 16946 else 16947 defaultConfig[i] = config[i]; 16948 } 16949}; 16950 16951BX.ajax.replaceLocalStorageValue = function(lsId, data, ttl) 16952{ 16953 if (!!BX.localStorage) 16954 BX.localStorage.set('ajax-' + lsId, data, ttl); 16955}; 16956 16957 16958BX.ajax._uncache = function(url) 16959{ 16960 return url + ((url.indexOf('?') !== -1 ? "&" : "?") + '_=' + (new Date()).getTime()); 16961}; 16962 16963/* simple interface */ 16964BX.ajax.get = function(url, data, callback) 16965{ 16966 if (BX.type.isFunction(data)) 16967 { 16968 callback = data; 16969 data = ''; 16970 } 16971
16972 data = BX.ajax.prepareData(data); 16973 16974 if (data) 16975 { 16976 url += (url.indexOf('?') !== -1 ? "&" : "?") + data; 16977 data = ''; 16978 } 16979 16980 return BX.ajax({ 16981 'method': 'GET', 16982 'dataType': 'html', 16983 'url': url, 16984 'data': '', 16985 'onsuccess': callback 16986 }); 16987}; 16988 16989BX.ajax.getCaptcha = function(callback) 16990{ 16991 return BX.ajax.loadJSON('/bitrix/tools/ajax_captcha.php', callback); 16992}; 16993 16994BX.ajax.insertToNode = function(url, node) 16995{ 16996 node = BX(node); 16997 if (!!node) 16998 { 16999 var eventArgs = { cancel: false }; 17000 BX.onCustomEvent('onAjaxInsertToNode', [{ url: url, node: node, eventArgs: eventArgs }]); 17001 if(eventArgs.cancel === true) 17002 { 17003 return; 17004 } 17005 17006 var show = null; 17007 if (!tempDefaultConfig.denyShowWait) 17008 { 17009 show = BX.showWait(node); 17010 delete tempDefaultConfig.denyShowWait; 17011 } 17012 17013 return BX.ajax.get(url, function(data) { 17014 node.innerHTML = data; 17015 BX.closeWait(node, show); 17016 }); 17017 } 17018}; 17019 17020BX.ajax.post = function(url, data, callback) 17021{ 17022 data = BX.ajax.prepareData(data); 17023 17024 return BX.ajax({ 17025 'method': 'POST', 17026 'dataType': 'html', 17027 'url': url, 17028 'data': data, 17029 'onsuccess': callback 17030 }); 17031}; 17032 17033/** 17034 * BX.ajax with BX.Promise 17035 * 17036 * @param config 17037 * @returns {BX.Promise|false} 17038 */ 17039BX.ajax.promise = function(config) 17040{ 17041 var result = new BX.Promise(); 17042 17043 config.onsuccess = function(data) 17044 { 17045 result.fulfill(data); 17046 }; 17047 config.onfailure = function(reason, httpStatus, config) 17048 { 17049 result.reject({ 17050 reason: reason, 17051 data: httpStatus, 17052 ajaxConfig: config, 17053 xhr: config.xhr 17054 }); 17055 }; 17056 17057 var xhr = BX.ajax(config); 17058 if (xhr) 17059 { 17060 if (typeof config.onrequeststart === 'function') 17061 { 17062 config.onrequeststart(xhr); 17063 } 17064 } 17065 else 17066 { 17067 result.reject({ 17068 reason: "init", 17069 data: false 17070 }); 17071 } 17072 17073 return result; 17074}; 17075 17076/* load and execute external file script with onload emulation */ 17077BX.ajax.loadScriptAjax = function(script_src, callback, bPreload) 17078{ 17079 if (BX.type.isArray(script_src)) 17080 { 17081 for (var i=0,len=script_src.length;i<len;i++) 17082 { 17083 BX.ajax.loadScriptAjax(script_src[i], callback, bPreload); 17084 } 17085 } 17086 else 17087 { 17088 var script_src_test = script_src.replace(/\.js\?.*/, '.js'); 17089 17090 if (r.script_self.test(script_src_test)) return; 17091 if (r.script_self_window.test(script_src_test) && BX.CWindow) return; 17092 if (r.script_self_admin.test(script_src_test) && BX.admin) return; 17093 17094 if (typeof loadedScripts[script_src_test] == 'undefined') 17095 { 17096 if (!!bPreload) 17097 { 17098 loadedScripts[script_src_test] = ''; 17099 return BX.loadScript(script_src); 17100 } 17101 else 17102 { 17103 return BX.ajax({ 17104 url: script_src, 17105 method: 'GET', 17106 dataType: 'script', 17107 processData: true, 17108 emulateOnload: false, 17109 scriptsRunFirst: true, 17110 async: false, 17111 start: true, 17112 onsuccess: function(result) { 17113 loadedScripts[script_src_test] = result; 17114 if (callback) 17115 callback(result); 17116 } 17117 }); 17118 } 17119 } 17120 else if (callback) 17121 { 17122 callback(loadedScripts[script_src_test]); 17123 } 17124 } 17125}; 17126 17127/* non-xhr loadings */ 17128BX.ajax.loadJSON = function(url, data, callback, callback_failure) 17129{ 17130 if (BX.type.isFunction(data)) 17131 { 17132 callback_failure = callback; 17133 callback = data; 17134 data = ''; 17135 } 17136 17137 data = BX.ajax.prepareData(data); 17138 17139 if (data) 17140 { 17141 url += (url.indexOf('?') !== -1 ? "&" : "?") + data; 17142 data = ''; 17143 } 17144 17145 return BX.ajax({ 17146 'method': 'GET', 17147 'dataType': 'json', 17148 'url': url, 17149 'onsuccess': callback, 17150 'onfailure': callback_failure 17151 }); 17152}; 17153 17154var getLastContentTypeHeader = function (headers) { 17155 if (!BX.Type.isArray(headers)) 17156 { 17157 return null; 17158 } 17159 var lastHeader = headers 17160 .filter(function (header) { 17161 return header.name === 'Content-Type'; 17162 }) 17163 .pop(); 17164 17165 return lastHeader ? lastHeader.value : null; 17166}; 17167 17168/** 17169 * @see isValidAnalyticsData in ui.analytics 17170* */ 17171const isValidAnalyticsData = function (analytics) 17172{ 17173 if (!BX.Type.isPlainObject(analytics)) 17174 { 17175 console.error('BX.ajax: {analytics} must be an object.'); 17176 17177 return false; 17178 } 17179 17180 const requiredFields = ['event', 'tool', 'category']; 17181 for (const field of requiredFields) 17182 { 17183 if (!BX.Type.isStringFilled(analytics[field])) 17184 { 17185 console.error(`BX.ajax: The "${field}" property in the "analytics" object must be a non-empty string.`); 17186 17187 return false;
17188 } 17189 } 17190 17191 const additionalFields = ['p1', 'p2', 'p3', 'p4', 'p5']; 17192 for (const field of additionalFields) 17193 { 17194 const value = analytics[field]; 17195 if (!BX.Type.isStringFilled(value)) 17196 { 17197 continue; 17198 } 17199 17200 if (value.split('_').length > 2) 17201 { 17202 console.error(`BX.ajax: The "${field}" property (${value}) in the "analytics" object must be a string containing a single underscore.`); 17203 17204 return false; 17205 } 17206 } 17207 17208 return true; 17209}; 17210 17211const processAnalyticsDataToGetParameters = function(config) 17212{ 17213 const getParameters = {}; 17214 if (BX.Type.isStringFilled(config.analyticsLabel) || BX.Type.isPlainObject(config.analyticsLabel)) 17215 { 17216 getParameters.analyticsLabel = config.analyticsLabel; 17217 } 17218 17219 if (BX.Type.isPlainObject(config.analytics)) 17220 { 17221 if (config.analyticsLabel) 17222 { 17223 delete getParameters.analyticsLabel; 17224 console.error('BX.ajax: Only {analytics} or {analyticsLabel} should be used. If both are present, {analyticsLabel} will be ignored.'); 17225 } 17226 17227 if (isValidAnalyticsData(config.analytics)) 17228 { 17229 getParameters.st = config.analytics; 17230 } 17231 else 17232 { 17233 console.error('BX.ajax: {analytics} is invalid and is skipped.'); 17234 } 17235 } 17236 17237 return getParameters; 17238}; 17239 17240const prepareAjaxGetParameters = function(config) 17241{ 17242 let getParameters = config.getParameters || {}; 17243 getParameters = { ...getParameters, ...processAnalyticsDataToGetParameters(config) }; 17244 17245 if (typeof config.mode !== 'undefined') 17246 { 17247 getParameters.mode = config.mode; 17248 } 17249 if (config.navigation) 17250 { 17251 if (config.navigation.page) 17252 { 17253 getParameters.nav = 'page-' + config.navigation.page; 17254 } 17255 if (config.navigation.size) 17256 { 17257 if (getParameters.nav) 17258 { 17259 getParameters.nav += '-'; 17260 } 17261 else 17262 { 17263 getParameters.nav = ''; 17264 } 17265 getParameters.nav += 'size-' + config.navigation.size; 17266 } 17267 } 17268 17269 return getParameters; 17270}; 17271 17272var prepareAjaxConfig = function(config) 17273{ 17274 config = BX.type.isPlainObject(config) ? config : {}; 17275 17276 config.headers = config.headers || []; 17277 config.headers.push({name: 'X-Bitrix-Csrf-Token', value: BX.bitrix_sessid()}); 17278 if (BX.message.SITE_ID) 17279 { 17280 config.headers.push({name: 'X-Bitrix-Site-Id', value: BX.message.SITE_ID}); 17281 } 17282 17283 if (typeof config.json !== 'undefined') 17284 { 17285 if (!BX.type.isPlainObject(config.json)) 17286 { 17287 throw new Error('Wrong `config.json`, plain object expected.') 17288 } 17289 17290 config.headers.push({name: 'Content-Type', value: 'application/json'}); 17291 config.data = config.json; 17292 config.preparePost = false; 17293 } 17294 else if (config.data instanceof FormData) 17295 { 17296 config.preparePost = false; 17297 if (typeof config.signedParameters !== 'undefined') 17298 { 17299 config.data.append('signedParameters', config.signedParameters); 17300 } 17301 } 17302 else if (BX.type.isPlainObject(config.data) || BX.Type.isNil(config.data)) 17303 { 17304 config.data = BX.type.isPlainObject(config.data) ? config.data : {}; 17305 if (typeof config.signedParameters !== 'undefined') 17306 { 17307 config.data.signedParameters = config.signedParameters; 17308 } 17309 } 17310 17311 if (!config.method) 17312 { 17313 config.method = 'POST' 17314 } 17315 17316 return config; 17317}; 17318 17319var buildAjaxPromiseToRestoreCsrf = function(config, withoutRestoringCsrf) 17320{ 17321 withoutRestoringCsrf = withoutRestoringCsrf || false; 17322 var originalConfig = BX.clone(config); 17323 var request = null; 17324 17325 var onrequeststart = config.onrequeststart; 17326 config.onrequeststart = function(xhr) { 17327 request = xhr; 17328 if (BX.type.isFunction(onrequeststart)) 17329 { 17330 onrequeststart(xhr); 17331 } 17332 }; 17333 var onrequeststartOrig = originalConfig.onrequeststart; 17334 originalConfig.onrequeststart = function(xhr) { 17335 request = xhr; 17336 if (BX.type.isFunction(onrequeststartOrig)) 17337 { 17338 onrequeststartOrig(xhr); 17339 } 17340 }; 17341 17342 var promise = BX.ajax.promise(config); 17343 17344 return promise.then(function(response) { 17345 if (!withoutRestoringCsrf && BX.type.isPlainObject(response) && BX.type.isArray(response.errors)) 17346 { 17347 var csrfProblem = false; 17348 response.errors.forEach(function(error) { 17349 if (error.code === 'invalid_csrf' && error.customData.csrf) 17350 { 17351 BX.message({'bitrix_sessid': error.customData.csrf}); 17352 17353 originalConfig.headers = originalConfig.headers || []; 17354 originalConfig.headers = originalConfig.headers.filter(function(header) {
17355 return header && header.name !== 'X-Bitrix-Csrf-Token'; 17356 }); 17357 originalConfig.headers.push({name: 'X-Bitrix-Csrf-Token', value: BX.bitrix_sessid()}); 17358 17359 csrfProblem = true; 17360 } 17361 }); 17362 17363 if (csrfProblem) 17364 { 17365 return buildAjaxPromiseToRestoreCsrf(originalConfig, true); 17366 } 17367 } 17368 17369 if (!BX.type.isPlainObject(response) || response.status !== 'success') 17370 { 17371 var errorPromise = new BX.Promise(); 17372 errorPromise.reject(response); 17373 17374 return errorPromise; 17375 } 17376 17377 return response; 17378 }).catch(function(data) { 17379 var ajaxReject = new BX.Promise(); 17380 17381 var originalJsonResponse; 17382 if (BX.type.isPlainObject(data) && data.xhr && data.xhr.responseText) 17383 { 17384 try 17385 { 17386 originalJsonResponse = JSON.parse(data.xhr.responseText); 17387 data = originalJsonResponse; 17388 } 17389 catch (err) 17390 {} 17391 } 17392 17393 if (BX.type.isPlainObject(data) && data.status && data.hasOwnProperty('data')) 17394 { 17395 ajaxReject.reject(data); 17396 } 17397 else 17398 { 17399 ajaxReject.reject({ 17400 status: 'error', 17401 data: { 17402 ajaxRejectData: data 17403 }, 17404 errors: [ 17405 { 17406 code: 'NETWORK_ERROR', 17407 message: 'Network error' 17408 } 17409 ] 17410 }); 17411 } 17412 17413 return ajaxReject; 17414 }).then(function(response){ 17415 17416 var assetsLoaded = new BX.Promise(); 17417 17418 var headers = request.getAllResponseHeaders().trim().split(/[\r\n]+/); 17419 var headerMap = {}; 17420 headers.forEach(function (line) { 17421 var parts = line.split(': '); 17422 var header = parts.shift().toLowerCase(); 17423 headerMap[header] = parts.join(': '); 17424 }); 17425 17426 if (!headerMap['x-process-assets']) 17427 { 17428 assetsLoaded.fulfill(response); 17429 17430 return assetsLoaded; 17431 } 17432 17433 var assets = BX.prop.getObject(BX.prop.getObject(response, "data", {}), "assets", {}); 17434 17435 var inlineScripts = []; 17436 if (BX.Type.isArrayFilled(assets.string)) 17437 { 17438 assets.string 17439 .reduce(function(acc, item) { 17440 if (String(item).length > 0 && !acc.includes(item)) 17441 { 17442 acc.push(item); 17443 } 17444 17445 return acc; 17446 }, []) 17447 .forEach(function(item) { 17448 if (String(item).startsWith('<script type="extension/settings"')) 17449 { 17450 BX.html(document.head, item, { useAdjacentHTML: true }); 17451 } 17452 else 17453 { 17454 inlineScripts.push(item); 17455 } 17456 }); 17457 } 17458 17459 var promise = new Promise(function(resolve, reject) { 17460 var css = BX.prop.getArray(assets, "css", []); 17461 BX.load(css, function(){ 17462 BX.loadScript( 17463 BX.prop.getArray(assets, "js", []), 17464 resolve 17465 ); 17466 }); 17467 }); 17468 17469 promise.then(function(){ 17470 var stringAsset = inlineScripts.join('\n'); 17471 BX.html(document.head, stringAsset, { useAdjacentHTML: true }).then(function(){ 17472 assetsLoaded.fulfill(response); 17473 }); 17474 }); 17475 17476 return assetsLoaded; 17477 }); 17478}; 17479 17480/** 17481 * 17482 * @param {string} action 17483 * @param {Object} config 17484 * @param {?string|?Object} [config.analyticsLabel] 17485 * @param {?Object} [config.analytics] 17486 * @param {string} [config.analytics.event] 17487 * @param {string} [config.analytics.tool] 17488 * @param {string} [config.analytics.category] 17489 * @param {?string} [config.analytics.c_section] 17490 * @param {?string} [config.analytics.c_sub_section] 17491 * @param {?string} [config.analytics.c_element] 17492 * @param {?string} [config.analytics.type] 17493 * @param {?string} [config.analytics.p1] 17494 * @param {?string} [config.analytics.p2] 17495 * @param {?string} [config.analytics.p3] 17496 * @param {?string} [config.analytics.p4] 17497 * @param {?string} [config.analytics.p5] 17498 * @param {?('success' | 'error' | 'attempt' | 'cancel')} [config.analytics.status] 17499 * @param {string} [config.method='POST'] 17500 * @param {Object} [config.data] 17501 * @param {?Object} [config.getParameters] 17502 * @param {?Object} [config.headers] 17503 * @param {?Object} [config.timeout] 17504 * @param {Object} [config.navigation] 17505 * @param {number} [config.navigation.page] 17506 */ 17507BX.ajax.runAction = function(action, config) 17508{ 17509 config = prepareAjaxConfig(config); 17510 var getParameters = prepareAjaxGetParameters(config); 17511 getParameters.action = action; 17512
17513 var url = '/bitrix/services/main/ajax.php?' + BX.ajax.prepareData(getParameters); 17514 return buildAjaxPromiseToRestoreCsrf({ 17515 method: config.method, 17516 dataType: 'json', 17517 url: url, 17518 data: config.data, 17519 timeout: config.timeout, 17520 preparePost: config.preparePost, 17521 headers: config.headers, 17522 onrequeststart: config.onrequeststart, 17523 onprogress: config.onprogress, 17524 onprogressupload: config.onprogressupload 17525 }); 17526}; 17527 17528/** 17529 * 17530 * @param {string} component 17531 * @param {string} action 17532 * @param {Object} config 17533 * @param {?string|?Object} [config.analyticsLabel] 17534 * @param {?Object} [config.analytics] 17535 * @param {string} [config.analytics.event] 17536 * @param {string} [config.analytics.tool] 17537 * @param {string} [config.analytics.category] 17538 * @param {?string} [config.analytics.c_section] 17539 * @param {?string} [config.analytics.c_sub_section] 17540 * @param {?string} [config.analytics.c_element] 17541 * @param {?string} [config.analytics.type] 17542 * @param {?string} [config.analytics.p1] 17543 * @param {?string} [config.analytics.p2] 17544 * @param {?string} [config.analytics.p3] 17545 * @param {?string} [config.analytics.p4] 17546 * @param {?string} [config.analytics.p5] 17547 * @param {?string} [config.signedParameters] 17548 * @param {string} [config.method='POST'] 17549 * @param {string} [config.mode='ajax'] Ajax or class. 17550 * @param {Object} [config.data] 17551 * @param {?Object} [config.getParameters] 17552 * @param {?array} [config.headers] 17553 * @param {?number} [config.timeout] 17554 * @param {Object} [config.navigation] 17555 */ 17556BX.ajax.runComponentAction = function (component, action, config) 17557{ 17558 config = prepareAjaxConfig(config); 17559 config.mode = config.mode || 'ajax'; 17560 17561 var getParameters = prepareAjaxGetParameters(config); 17562 getParameters.c = component; 17563 getParameters.action = action; 17564
17565 var url = '/bitrix/services/main/ajax.php?' + BX.ajax.prepareData(getParameters); 17566 17567 return buildAjaxPromiseToRestoreCsrf({ 17568 method: config.method, 17569 dataType: 'json', 17570 url: url, 17571 data: config.data, 17572 timeout: config.timeout, 17573 preparePost: config.preparePost, 17574 headers: config.headers, 17575 onrequeststart: (config.onrequeststart ? config.onrequeststart : null), 17576 onprogress: config.onprogress, 17577 onprogressupload: config.onprogressupload 17578 }); 17579}; 17580 17581/* 17582arObs = [{ 17583 url: url, 17584 type: html|script|json|css, 17585 callback: function 17586}] 17587*/ 17588BX.ajax.load = function(arObs, callback) 17589{ 17590 if (!BX.type.isArray(arObs)) 17591 arObs = [arObs]; 17592 17593 var cnt = 0; 17594 17595 if (!BX.type.isFunction(callback)) 17596 callback = BX.DoNothing; 17597 17598 var handler = function(data) 17599 { 17600 if (BX.type.isFunction(this.callback)) 17601 this.callback(data); 17602 17603 if (++cnt >= len) 17604 callback(); 17605 }; 17606 17607 for (var i = 0, len = arObs.length; i<len; i++) 17608 { 17609 switch(arObs[i].type.toUpperCase()) 17610 { 17611 case 'SCRIPT': 17612 BX.loadScript([arObs[i].url], BX.proxy(handler, arObs[i])); 17613 break; 17614 case 'CSS': 17615 BX.loadCSS([arObs[i].url]); 17616 17617 if (++cnt >= len) 17618 callback(); 17619 break; 17620 case 'JSON': 17621 BX.ajax.loadJSON(arObs[i].url, BX.proxy(handler, arObs[i])); 17622 break; 17623 17624 default: 17625 BX.ajax.get(arObs[i].url, '', BX.proxy(handler, arObs[i])); 17626 break; 17627 } 17628 } 17629}; 17630 17631/* ajax form sending */ 17632BX.ajax.submit = function(obForm, callback) 17633{ 17634 if (!obForm.target) 17635 { 17636 if (null == obForm.BXFormTarget) 17637 { 17638 var frame_name = 'formTarget_' + Math.random(); 17639 obForm.BXFormTarget = document.body.appendChild(BX.create('IFRAME', { 17640 props: { 17641 name: frame_name, 17642 id: frame_name, 17643 src: 'javascript:void(0)' 17644 }, 17645 style: { 17646 display: 'none' 17647 } 17648 })); 17649 } 17650 17651 obForm.target = obForm.BXFormTarget.name; 17652 } 17653 17654 obForm.BXFormCallback = callback; 17655 BX.bind(obForm.BXFormTarget, 'load', BX.proxy(BX.ajax._submit_callback, obForm)); 17656 17657 BX.submit(obForm); 17658 17659 return false; 17660}; 17661 17662BX.ajax.submitComponentForm = function(obForm, container, bWait) 17663{ 17664 if (!obForm.target) 17665 { 17666 if (null == obForm.BXFormTarget) 17667 { 17668 var frame_name = 'formTarget_' + Math.random(); 17669 obForm.BXFormTarget = document.body.appendChild(BX.create('IFRAME', { 17670 props: { 17671 name: frame_name, 17672 id: frame_name, 17673 src: 'javascript:void(0)' 17674 }, 17675 style: { 17676 display: 'none' 17677 } 17678 })); 17679 } 17680 17681 obForm.target = obForm.BXFormTarget.name; 17682 } 17683 17684 if (!!bWait) 17685 var w = BX.showWait(container); 17686 17687 obForm.BXFormCallback = function(d) { 17688 if (!!bWait) 17689 BX.closeWait(w); 17690 17691 var callOnload = function(){ 17692 if(!!window.bxcompajaxframeonload) 17693 { 17694 setTimeout(function(){window.bxcompajaxframeonload();window.bxcompajaxframeonload=null;}, 10); 17695 } 17696 }; 17697 17698 BX(container).innerHTML = d; 17699 BX.onCustomEvent('onAjaxSuccess', [null,null,callOnload]); 17700 }; 17701 17702 BX.bind(obForm.BXFormTarget, 'load', BX.proxy(BX.ajax._submit_callback, obForm)); 17703 17704 return true; 17705}; 17706 17707// func will be executed in form context 17708BX.ajax._submit_callback = function() 17709{ 17710 //opera and IE8 triggers onload event even on empty iframe 17711 try 17712 { 17713 if(this.BXFormTarget.contentWindow.location.href.indexOf('http') != 0) 17714 return; 17715 } catch (e) { 17716 return; 17717 } 17718 17719 if (this.BXFormCallback) 17720 this.BXFormCallback.apply(this, [this.BXFormTarget.contentWindow.document.body.innerHTML]); 17721 17722 BX.unbindAll(this.BXFormTarget); 17723}; 17724 17725BX.ajax.prepareForm = function(obForm, data) 17726{ 17727 data = (!!data ? data : {}); 17728 var i, ii, el, 17729 _data = [], 17730 n = obForm.elements.length, 17731 files = 0, length = 0; 17732 if(!!obForm) 17733 { 17734 for (i = 0; i < n; i++) 17735 { 17736 el = obForm.elements[i]; 17737 if (el.disabled) 17738 continue; 17739 17740 if(!el.type) 17741 continue; 17742 17743 switch(el.type.toLowerCase()) 17744 { 17745 case 'text': 17746 case 'textarea': 17747 case 'password': 17748 case 'number': 17749 case 'hidden': 17750 case 'select-one': 17751 _data.push({name: el.name, value: el.value}); 17752 length += (el.name.length + el.value.length); 17753 break; 17754 case 'file': 17755 if (!!el.files) 17756 { 17757 for (ii = 0; ii < el.files.length; ii++) 17758 { 17759 files++; 17760 _data.push({name: el.name, value: el.files[ii], file : true}); 17761 length += el.files[ii].size; 17762 } 17763 } 17764 break; 17765 case 'radio':
17766 case 'checkbox': 17767 if(el.checked) 17768 { 17769 _data.push({name: el.name, value: el.value}); 17770 length += (el.name.length + el.value.length); 17771 } 17772 break; 17773 case 'select-multiple': 17774 for (var j = 0; j < el.options.length; j++) 17775 { 17776 if (el.options[j].selected) 17777 { 17778 _data.push({name : el.name, value : el.options[j].value}); 17779 length += (el.name.length + el.options[j].length); 17780 } 17781 } 17782 break; 17783 default: 17784 break; 17785 } 17786 } 17787 17788 i = 0; length = 0; 17789 var current = data, name, rest, pp, tmpKey; 17790 17791 while(i < _data.length) 17792 { 17793 var p = _data[i].name.indexOf('['); 17794 if (tmpKey) 17795 { 17796 current[_data[i].name] = {}; 17797 current[_data[i].name][tmpKey.replace(/\[|\]/gi, '')] = _data[i].value; 17798 current = data; 17799 tmpKey = null; 17800 i++; 17801 } 17802 else if (p == -1) 17803 { 17804 current[_data[i].name] = _data[i].value; 17805 current = data; 17806 i++; 17807 } 17808 else 17809 { 17810 name = _data[i].name.substring(0, p); 17811 rest = _data[i].name.substring(p+1); 17812 pp = rest.indexOf(']'); 17813 17814 if(pp == -1) 17815 { 17816 if (!current[name]) 17817 current[name] = []; 17818 current = data; 17819 i++; 17820 } 17821 else if(pp == 0) 17822 { 17823 if (!current[name]) 17824 current[name] = []; 17825 //No index specified - so take the next integer 17826 current = current[name]; 17827 _data[i].name = '' + current.length; 17828 if (rest.substring(pp+1).indexOf('[') === 0) 17829 tmpKey = rest.substring(0, pp) + rest.substring(pp+1); 17830 } 17831 else 17832 { 17833 if (!current[name]) 17834 current[name] = {}; 17835 //Now index name becomes and name and we go deeper into the array 17836 current = current[name]; 17837 _data[i].name = rest.substring(0, pp) + rest.substring(pp+1); 17838 } 17839 } 17840 } 17841 } 17842 return {data : data, filesCount : files, roughSize : length}; 17843}; 17844BX.ajax.submitAjax = function(obForm, config) 17845{ 17846 config = (config !== null && typeof config == "object" ? config : {}); 17847 config.url = (config["url"] || obForm.getAttribute("action")); 17848 17849 var additionalData = (config["data"] || {}); 17850 config.data = BX.ajax.prepareForm(obForm).data; 17851 for (var ii in additionalData) 17852 { 17853 if (additionalData.hasOwnProperty(ii)) 17854 { 17855 config.data[ii] = additionalData[ii]; 17856 } 17857 } 17858 17859 if (!window["FormData"]) 17860 { 17861 BX.ajax(config); 17862 } 17863 else 17864 { 17865 var isFile = function(item) 17866 { 17867 var res = Object.prototype.toString.call(item); 17868 return (res == '[object File]' || res == '[object Blob]'); 17869 }, 17870 appendToForm = function(fd, key, val) 17871 { 17872 if (!!val && typeof val == "object" && !isFile(val)) 17873 { 17874 for (var ii in val) 17875 { 17876 if (val.hasOwnProperty(ii)) 17877 { 17878 appendToForm(fd, (key == '' ? ii : key + '[' + ii + ']'), val[ii]); 17879 } 17880 } 17881 } 17882 else 17883 fd.append(key, (!!val ? val : '')); 17884 }, 17885 prepareData = function(arData) 17886 { 17887 var data = {}; 17888 if (null != arData) 17889 { 17890 if(typeof arData == 'object') 17891 { 17892 for(var i in arData) 17893 { 17894 if (arData.hasOwnProperty(i)) 17895 { 17896 var name = BX.util.urlencode(i); 17897 if(typeof arData[i] == 'object' && arData[i]["file"] !== true) 17898 data[name] = prepareData(arData[i]); 17899 else if (arData[i]["file"] === true) 17900 data[name] = arData[i]["value"]; 17901 else 17902 data[name] = BX.util.urlencode(arData[i]); 17903 } 17904 } 17905 } 17906 else 17907 data = BX.util.urlencode(arData); 17908 } 17909 return data; 17910 }, 17911 fd = new window.FormData(); 17912 17913 if (config.method !== 'POST') 17914 { 17915 config.data = BX.ajax.prepareData(config.data); 17916 if (config.data) 17917 { 17918 config.url += (config.url.indexOf('?') !== -1 ? "&" : "?") + config.data; 17919 config.data = ''; 17920 } 17921 } 17922 else 17923 { 17924 if (config.preparePost === true) 17925 config.data = prepareData(config.data); 17926 appendToForm(fd, '', config.data); 17927 config.data = fd; 17928 } 17929 17930 config.preparePost = false; 17931 config.start = false;
17932 17933 var xhr = BX.ajax(config); 17934 if (!!config["onprogress"]) 17935 xhr.upload.addEventListener( 17936 'progress', 17937 function(e){ 17938 var percent = null; 17939 if(e.lengthComputable && (e.total || e["totalSize"])) { 17940 percent = e.loaded * 100 / (e.total || e["totalSize"]); 17941 } 17942 config["onprogress"](e, percent); 17943 } 17944 ); 17945 xhr.send(fd); 17946 } 17947}; 17948 17949BX.ajax.UpdatePageData = function (arData) 17950{ 17951 if (arData.TITLE) 17952 BX.ajax.UpdatePageTitle(arData.TITLE); 17953 if (arData.WINDOW_TITLE || arData.TITLE) 17954 BX.ajax.UpdateWindowTitle(arData.WINDOW_TITLE || arData.TITLE); 17955 if (arData.NAV_CHAIN) 17956 BX.ajax.UpdatePageNavChain(arData.NAV_CHAIN); 17957 if (arData.CSS && arData.CSS.length > 0) 17958 BX.loadCSS(arData.CSS); 17959 if (arData.SCRIPTS && arData.SCRIPTS.length > 0) 17960 { 17961 var f = function(result,config,cb){ 17962 17963 if(!!config && BX.type.isArray(config.scripts)) 17964 { 17965 for(var i=0,l=arData.SCRIPTS.length;i<l;i++) 17966 { 17967 config.scripts.push({isInternal:false,JS:arData.SCRIPTS[i]}); 17968 } 17969 } 17970 else 17971 { 17972 BX.loadScript(arData.SCRIPTS,cb); 17973 } 17974 17975 BX.removeCustomEvent('onAjaxSuccess',f); 17976 }; 17977 BX.addCustomEvent('onAjaxSuccess',f); 17978 } 17979 else 17980 { 17981 var f1 = function(result,config,cb){ 17982 if(BX.type.isFunction(cb)) 17983 { 17984 cb(); 17985 } 17986 BX.removeCustomEvent('onAjaxSuccess',f1); 17987 }; 17988 BX.addCustomEvent('onAjaxSuccess', f1); 17989 } 17990}; 17991 17992BX.ajax.UpdatePageTitle = function(title) 17993{ 17994 var obTitle = BX('pagetitle'); 17995 if (obTitle) 17996 { 17997 BX.remove(obTitle.firstChild); 17998 if (!obTitle.firstChild) 17999 obTitle.appendChild(document.createTextNode(title)); 18000 else 18001 obTitle.insertBefore(document.createTextNode(title), obTitle.firstChild); 18002 } 18003}; 18004 18005BX.ajax.UpdateWindowTitle = function(title) 18006{ 18007 document.title = title; 18008}; 18009 18010BX.ajax.UpdatePageNavChain = function(nav_chain) 18011{ 18012 var obNavChain = BX('navigation'); 18013 if (obNavChain) 18014 { 18015 obNavChain.innerHTML = nav_chain; 18016 } 18017}; 18018 18019/* user options handling */ 18020BX.userOptions = { 18021 options: null, 18022 bSend: false, 18023 delay: 5000, 18024 path: '/bitrix/admin/user_options.php?' 18025}; 18026 18027BX.userOptions.setAjaxPath = function(url) 18028{ 18029 // eslint-disable-next-line no-console 18030 console.warn('BX.userOptions.setAjaxPath is deprecated. There is no way to change ajax path.'); 18031}; 18032BX.userOptions.save = function(category, name, valueName, value, common) 18033{ 18034 if (BX.userOptions.options === null) 18035 { 18036 BX.userOptions.options = {}; 18037 } 18038 18039 common = Boolean(common); 18040 BX.userOptions.options[`${category}.${name}.${valueName}`] = [category, name, valueName, value, common]; 18041 18042 const stringPackedValue = BX.userOptions.__get(); 18043 if (stringPackedValue) 18044 { 18045 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=/;`; 18046 } 18047 18048 if (!BX.userOptions.bSend) 18049 { 18050 BX.userOptions.bSend = true; 18051 setTimeout(() => { 18052 BX.userOptions.send(null); 18053 }, BX.userOptions.delay); 18054 } 18055}; 18056 18057BX.userOptions.send = function(callback) 18058{ 18059 const values = BX.userOptions.__get_values({ backwardCompatibility: true}); 18060 18061 BX.userOptions.options = null; 18062 BX.userOptions.bSend = false; 18063 18064 if (values) 18065 { 18066 document.cookie = `${BX.message('COOKIE_PREFIX')}_LAST_SETTINGS=; path=/;`; 18067 18068 BX.ajax.runAction( 18069 'main.userOption.saveOptions', 18070 { 18071 json: { 18072 newValues: values, 18073 }, 18074 }, 18075 ).then((response) => { 18076 if (BX.type.isFunction(callback)) 18077 { 18078 callback(response); 18079 } 18080 }); 18081 } 18082}; 18083 18084BX.userOptions.del = function(category, name, common, callback) 18085{ 18086 BX.ajax.runAction( 18087 'main.userOption.deleteOption', 18088 { 18089 json: { 18090 category, 18091 name, 18092 common, 18093 }, 18094 }, 18095 ).then((response) => { 18096 if (BX.type.isFunction(callback)) 18097 { 18098 callback(response); 18099 } 18100 }); 18101}; 18102 18103BX.userOptions.__get_values = function({ backwardCompatibility }) 18104{ 18105 if (!BX.userOptions || !BX.Type.isPlainObject(BX.userOptions.options)) 18106 { 18107 return null; 18108 } 18109 18110 const CATEGORY = 0; 18111 const NAME = 1; 18112 const VALUE_NAME = 2; 18113 const VALUE = 3; 18114 const IS_DEFAULT = 4; 18115 18116 const packedValues = { p: [] }; 18117 let currentIndex = -1; 18118 let previousOptionIdentifier = ''; 18119 18120 Object.entries(BX.userOptions.options).forEach(([key, userOption]) => { 18121 const category = userOption[CATEGORY]; 18122 const name = userOption[NAME]; 18123 const currentOptionIdentifier = `${category}.${name}`; 18124 18125 if (previousOptionIdentifier !== currentOptionIdentifier) 18126 { 18127 currentIndex++; 18128 packedValues.p.push({ 18129 c: category, 18130 n: name, 18131 v: {}, 18132 }); 18133 if (userOption[IS_DEFAULT] === true) 18134 { 18135 packedValues.p[currentIndex].d = 'Y'; 18136 } 18137 previousOptionIdentifier = currentOptionIdentifier; 18138 } 18139 18140 if (userOption[VALUE_NAME] === null) 18141 { 18142 packedValues.p[currentIndex].v = userOption[VALUE]; 18143 } 18144 else 18145 { 18146 let data = userOption[VALUE]; 18147 if (backwardCompatibility && Array.isArray(userOption[VALUE])) 18148 { 18149 data = userOption[VALUE].join(','); 18150 } 18151 packedValues.p[currentIndex].v[userOption[VALUE_NAME]] = data; 18152 } 18153 }); 18154 18155 return packedValues.p.length > 0 ? packedValues.p : null; 18156}; 18157 18158/** 18159 * @deprecated Use instead BX.userOptions.__get_values. 18160 * */ 18161BX.userOptions.__get = function() 18162{ 18163 if (!BX.userOptions.options) return ''; 18164 18165 var sParam = '', n = -1, prevParam = '', aOpt, i; 18166 18167 for (i in BX.userOptions.options) 18168 { 18169 if(BX.userOptions.options.hasOwnProperty(i)) 18170 { 18171 aOpt = BX.userOptions.options[i]; 18172 18173 if (prevParam != aOpt[0]+'.'+aOpt[1]) 18174 { 18175 n++; 18176 sParam += '&p['+n+'][c]='+BX.util.urlencode(aOpt[0]); 18177 sParam += '&p['+n+'][n]='+BX.util.urlencode(aOpt[1]); 18178 if (aOpt[4] == true) 18179 sParam += '&p['+n+'][d]=Y'; 18180 prevParam = aOpt[0]+'.'+aOpt[1]; 18181 } 18182 18183 var valueName = aOpt[2]; 18184 var value = aOpt[3]; 18185 18186 if (valueName === null) 18187 { 18188 sParam += '&p['+n+'][v]='+BX.util.urlencode(value); 18189 } 18190 else 18191 {
18192 sParam += '&p['+n+'][v]['+BX.util.urlencode(valueName)+']='+BX.util.urlencode(value); 18193 } 18194 } 18195 } 18196 18197 return sParam.substr(1); 18198}; 18199 18200BX.ajax.history = { 18201 expected_hash: '', 18202 18203 obParams: null, 18204 18205 obFrame: null, 18206 obImage: null, 18207 18208 obTimer: null, 18209 18210 bInited: false, 18211 bHashCollision: false, 18212 bPushState: !!(history.pushState && BX.type.isFunction(history.pushState)), 18213 18214 startState: null, 18215 18216 init: function(obParams) 18217 { 18218 if (BX.ajax.history.bInited) 18219 return; 18220 18221 this.obParams = obParams; 18222 var obCurrentState = this.obParams.getState(); 18223 18224 if (BX.ajax.history.bPushState) 18225 { 18226 BX.ajax.history.expected_hash = window.location.pathname; 18227 if (window.location.search) 18228 BX.ajax.history.expected_hash += window.location.search; 18229 18230 BX.ajax.history.put(obCurrentState, BX.ajax.history.expected_hash, '', true); 18231 // due to some strange thing, chrome calls popstate event on page start. so we should delay it 18232 setTimeout(function(){BX.bind(window, 'popstate', BX.ajax.history.__hashListener);}, 500); 18233 } 18234 else 18235 { 18236 BX.ajax.history.expected_hash = window.location.hash; 18237 18238 if (!BX.ajax.history.expected_hash || BX.ajax.history.expected_hash == '#') 18239 BX.ajax.history.expected_hash = '__bx_no_hash__'; 18240 18241 jsAjaxHistoryContainer.put(BX.ajax.history.expected_hash, obCurrentState); 18242 BX.ajax.history.obTimer = setTimeout(BX.ajax.history.__hashListener, 500); 18243 18244 if (BX.browser.IsIE()) 18245 { 18246 BX.ajax.history.obFrame = document.createElement('IFRAME'); 18247 BX.hide_object(BX.ajax.history.obFrame); 18248 18249 document.body.appendChild(BX.ajax.history.obFrame); 18250 18251 BX.ajax.history.obFrame.contentWindow.document.open(); 18252 BX.ajax.history.obFrame.contentWindow.document.write(BX.ajax.history.expected_hash); 18253 BX.ajax.history.obFrame.contentWindow.document.close(); 18254 } 18255 else if (BX.browser.IsOpera()) 18256 { 18257 BX.ajax.history.obImage = document.createElement('IMG'); 18258 BX.hide_object(BX.ajax.history.obImage); 18259 18260 document.body.appendChild(BX.ajax.history.obImage); 18261 18262 BX.ajax.history.obImage.setAttribute('src', 'javascript:location.href = \'javascript:BX.ajax.history.__hashListener();\';'); 18263 } 18264 } 18265 18266 BX.ajax.history.bInited = true; 18267 }, 18268 18269 __hashListener: function(e) 18270 { 18271 e = e || window.event || {state:false}; 18272 18273 if (BX.ajax.history.bPushState) 18274 { 18275 BX.ajax.history.obParams.setState(e.state||BX.ajax.history.startState); 18276 } 18277 else 18278 { 18279 if (BX.ajax.history.obTimer) 18280 { 18281 window.clearTimeout(BX.ajax.history.obTimer); 18282 BX.ajax.history.obTimer = null; 18283 } 18284 18285 var current_hash; 18286 if (null != BX.ajax.history.obFrame) 18287 current_hash = BX.ajax.history.obFrame.contentWindow.document.body.innerText; 18288 else 18289 current_hash = window.location.hash; 18290 18291 if (!current_hash || current_hash == '#') 18292 current_hash = '__bx_no_hash__'; 18293 18294 if (current_hash.indexOf('#') == 0) 18295 current_hash = current_hash.substring(1); 18296 18297 if (current_hash != BX.ajax.history.expected_hash) 18298 { 18299 var state = jsAjaxHistoryContainer.get(current_hash); 18300 if (state) 18301 { 18302 BX.ajax.history.obParams.setState(state); 18303 18304 BX.ajax.history.expected_hash = current_hash; 18305 if (null != BX.ajax.history.obFrame) 18306 { 18307 var __hash = current_hash == '__bx_no_hash__' ? '' : current_hash; 18308 if (window.location.hash != __hash && window.location.hash != '#' + __hash) 18309 window.location.hash = __hash; 18310 } 18311 } 18312 } 18313 18314 BX.ajax.history.obTimer = setTimeout(BX.ajax.history.__hashListener, 500); 18315 } 18316 }, 18317 18318 put: function(state, new_hash, new_hash1, bStartState) 18319 { 18320 if (this.bPushState) 18321 { 18322 if(!bStartState) 18323 { 18324 history.pushState(state, '', new_hash); 18325 } 18326 else 18327 { 18328 BX.ajax.history.startState = state; 18329 } 18330 } 18331 else 18332 { 18333 if (typeof new_hash1 != 'undefined') 18334 new_hash = new_hash1; 18335 else 18336 new_hash = 'view' + new_hash; 18337 18338 jsAjaxHistoryContainer.put(new_hash, state); 18339 BX.ajax.history.expected_hash = new_hash; 18340 18341 window.location.hash = BX.util.urlencode(new_hash); 18342 18343 if (null != BX.ajax.history.obFrame) 18344 { 18345 BX.ajax.history.obFrame.contentWindow.document.open(); 18346 BX.ajax.history.obFrame.contentWindow.document.write(new_hash); 18347 BX.ajax.history.obFrame.contentWindow.document.close(); 18348 } 18349 } 18350 }, 18351 18352 checkRedirectStart: function(param_name, param_value) 18353 { 18354 var current_hash = window.location.hash; 18355 if (current_hash.substring(0, 1) == '#') current_hash = current_hash.substring(1); 18356 18357 var test = current_hash.substring(0, 5); 18358 if (test == 'view/' || test == 'view%') 18359 { 18360 BX.ajax.history.bHashCollision = true;
18361 document.write('<' + 'div id="__ajax_hash_collision_' + param_value + '" style="display: none;">'); 18362 } 18363 }, 18364 18365 checkRedirectFinish: function(param_name, param_value) 18366 { 18367 document.write('</div>'); 18368 18369 var current_hash = window.location.hash; 18370 if (current_hash.substring(0, 1) == '#') current_hash = current_hash.substring(1); 18371 18372 BX.ready(function () 18373 { 18374 var test = current_hash.substring(0, 5); 18375 if (test == 'view/' || test == 'view%') 18376 { 18377 var obColNode = BX('__ajax_hash_collision_' + param_value); 18378 var obNode = obColNode.firstChild; 18379 BX.cleanNode(obNode); 18380 obColNode.style.display = 'block'; 18381 18382 // IE, Opera and Chrome automatically modifies hash with urlencode, but FF doesn't ;-( 18383 if (test != 'view%') 18384 current_hash = BX.util.urlencode(current_hash); 18385 18386 current_hash += (current_hash.indexOf('%3F') == -1 ? '%3F' : '%26') + param_name + '=' + param_value; 18387 18388 var url = '/bitrix/tools/ajax_redirector.php?hash=' + current_hash; 18389 18390 BX.ajax.insertToNode(url, obNode); 18391 } 18392 }); 18393 } 18394}; 18395 18396BX.ajax.component = function(node) 18397{ 18398 this.node = node; 18399}; 18400 18401BX.ajax.component.prototype.getState = function() 18402{ 18403 var state = { 18404 'node': this.node, 18405 'title': window.document.title, 18406 'data': BX(this.node).innerHTML 18407 }; 18408 18409 var obNavChain = BX('navigation'); 18410 if (null != obNavChain) 18411 state.nav_chain = obNavChain.innerHTML; 18412 18413 BX.onCustomEvent(BX(state.node), "onComponentAjaxHistoryGetState", [state]); 18414 18415 return state; 18416}; 18417 18418BX.ajax.component.prototype.setState = function(state) 18419{ 18420 BX(state.node).innerHTML = state.data; 18421 BX.ajax.UpdatePageTitle(state.title); 18422 18423 if (state.nav_chain) 18424 { 18425 BX.ajax.UpdatePageNavChain(state.nav_chain); 18426 } 18427 18428 BX.onCustomEvent(BX(state.node), "onComponentAjaxHistorySetState", [state]); 18429}; 18430 18431var jsAjaxHistoryContainer = { 18432 arHistory: {}, 18433 18434 put: function(hash, state) 18435 { 18436 this.arHistory[hash] = state; 18437 }, 18438 18439 get: function(hash) 18440 { 18441 return this.arHistory[hash]; 18442 } 18443}; 18444 18445 18446BX.ajax.FormData = function() 18447{ 18448 this.elements = []; 18449 this.files = []; 18450 this.features = {}; 18451 this.isSupported(); 18452 this.log('BX FormData init'); 18453}; 18454 18455BX.ajax.FormData.isSupported = function() 18456{ 18457 var f = new BX.ajax.FormData(); 18458 var result = f.features.supported; 18459 f = null; 18460 return result; 18461}; 18462 18463BX.ajax.FormData.prototype.log = function(o) 18464{ 18465 if (false) { 18466 try { 18467 if (BX.browser.IsIE()) o = JSON.stringify(o); 18468 console.log(o); 18469 } catch(e) {} 18470 } 18471}; 18472 18473BX.ajax.FormData.prototype.isSupported = function() 18474{ 18475 var f = {}; 18476 f.fileReader = (window.FileReader && window.FileReader.prototype.readAsBinaryString); 18477 f.readFormData = f.sendFormData = !!(window.FormData); 18478 f.supported = !!(f.readFormData && f.sendFormData); 18479 this.features = f; 18480 this.log('features:'); 18481 this.log(f); 18482 18483 return f.supported; 18484}; 18485 18486BX.ajax.FormData.prototype.append = function(name, value) 18487{ 18488 if (typeof(value) === 'object') { // seems to be files element 18489 this.files.push({'name': name, 'value':value}); 18490 } else { 18491 this.elements.push({'name': name, 'value':value}); 18492 } 18493}; 18494 18495BX.ajax.FormData.prototype.send = function(url, callbackOk, callbackProgress, callbackError) 18496{ 18497 this.log('FD send'); 18498 this.xhr = BX.ajax({ 18499 'method': 'POST', 18500 'dataType': 'html', 18501 'url': url, 18502 'onsuccess': callbackOk, 18503 'onfailure': callbackError, 18504 'start': false, 18505 'preparePost':false 18506 }); 18507 18508 if (callbackProgress) 18509 { 18510 this.xhr.upload.addEventListener( 18511 'progress', 18512 function(e) { 18513 if (e.lengthComputable) 18514 callbackProgress(e.loaded / (e.total || e.totalSize)); 18515 }, 18516 false 18517 ); 18518 } 18519 18520 if (this.features.readFormData && this.features.sendFormData) 18521 { 18522 var fd = new FormData(); 18523 this.log('use browser formdata'); 18524 for (var i in this.elements) 18525 { 18526 if(this.elements.hasOwnProperty(i)) 18527 fd.append(this.elements[i].name,this.elements[i].value); 18528 } 18529 for (i in this.files) 18530 { 18531 if(this.files.hasOwnProperty(i)) 18532 fd.append(this.files[i].name, this.files[i].value); 18533 } 18534 this.xhr.send(fd); 18535 } 18536 18537 return this.xhr; 18538}; 18539 18540BX.addCustomEvent('onAjaxFailure', BX.debug); 18541})(window); 18542 18543 18544 18545(function (exports,main_core) { 18546 'use strict'; 18547 18548 var LazyLoad = { 18549 observer: null, 18550 images: {}, 18551 imageStatus: { 18552 hidden: -2, 18553 error: -1, 18554 "undefined": 0, 18555 inited: 1, 18556 loaded: 2 18557 }, 18558 imageTypes: { 18559 image: 1, 18560 background: 2 18561 },
18562 initObserver: function initObserver() { 18563 this.observer = new IntersectionObserver(this.onIntersection.bind(this), { 18564 rootMargin: '20% 0% 20% 0%', 18565 threshold: 0.10 18566 }); 18567 }, 18568 onIntersection: function onIntersection(entries) { 18569 entries.forEach(function (entry) { 18570 if (entry.isIntersecting) { 18571 this.showImage(entry.target); 18572 } 18573 }.bind(this)); 18574 }, 18575 registerImage: function registerImage(id, isImageVisibleCallback, options) { 18576 if (this.observer === null) { 18577 this.initObserver(); 18578 } 18579 18580 options = options || {}; 18581 18582 if (!main_core.Type.isStringFilled(id)) { 18583 return; 18584 } 18585 18586 if (main_core.Type.isObject(this.images[id])) { 18587 return; 18588 } 18589 18590 var element = document.getElementById(id); 18591 18592 if (!main_core.Type.isDomNode(element)) { 18593 return; 18594 } 18595 18596 this.observer.observe(element); 18597 this.images[id] = { 18598 id: id, 18599 node: null, 18600 src: null, 18601 dataSrcName: options.dataSrcName || 'src', 18602 type: null, 18603 func: main_core.Type.isFunction(isImageVisibleCallback) ? isImageVisibleCallback : null, 18604 status: this.imageStatus.undefined 18605 }; 18606 }, 18607 registerImages: function registerImages(ids, isImageVisibleCallback, options) { 18608 if (main_core.Type.isArray(ids)) { 18609 for (var i = 0, length = ids.length; i < length; i++) { 18610 this.registerImage(ids[i], isImageVisibleCallback, options); 18611 } 18612 } 18613 }, 18614 showImage: function showImage(imageNode) { 18615 var imageNodeId = imageNode.id; 18616 18617 if (!main_core.Type.isStringFilled(imageNodeId)) { 18618 return; 18619 } 18620 18621 var image = this.images[imageNodeId]; 18622 18623 if (!main_core.Type.isPlainObject(image)) { 18624 return; 18625 } 18626 18627 if (image.status == this.imageStatus.undefined) { 18628 this.initImage(image); 18629 } 18630 18631 if (image.status !== this.imageStatus.inited) { 18632 return; 18633 } 18634 18635 if (!image.node || !image.node.parentNode) { 18636 image.node = null; 18637 image.status = this.imageStatus.error; 18638 return; 18639 } 18640 18641 if (image.type == this.imageTypes.image) { 18642 image.node.src = image.src; 18643 } else { 18644 image.node.style.backgroundImage = "url('" + image.src + "')"; 18645 } 18646 18647 image.node.dataset[image.dataSrcName] = ""; 18648 image.status = this.imageStatus.loaded; 18649 }, 18650 showImages: function showImages(checkOwnVisibility) { 18651 checkOwnVisibility = checkOwnVisibility !== false; 18652 18653 for (var id in this.images) { 18654 if (!this.images.hasOwnProperty(id)) { 18655 continue; 18656 } 18657 18658 var image = this.images[id]; 18659 18660 if (image.status == this.imageStatus.undefined) { 18661 this.initImage(image); 18662 } 18663 18664 if (image.status !== this.imageStatus.inited) { 18665 continue; 18666 } 18667 18668 if (!image.node || !image.node.parentNode) { 18669 image.node = null; 18670 image.status = this.imageStatus.error; 18671 continue; 18672 } 18673 18674 var isImageVisible = true; 18675 18676 if (checkOwnVisibility && main_core.Type.isFunction(image.func)) { 18677 isImageVisible = image.func(image); 18678 } 18679 18680 if (isImageVisible === true && this.isElementVisibleOnScreen(image.node)) { 18681 if (image.type == this.imageTypes.image) { 18682 image.node.src = image.src; 18683 } else { 18684 image.node.style.backgroundImage = "url('" + image.src + "')"; 18685 } 18686 18687 image.node.dataset[image.dataSrcName] = ""; 18688 image.status = this.imageStatus.loaded; 18689 } 18690 } 18691 }, 18692 initImage: function initImage(image) { 18693 image.status = this.imageStatus.error; 18694 var node = document.getElementById(image.id); 18695 18696 if (!main_core.Type.isDomNode(node)) { 18697 return; 18698 } 18699 18700 var src = node.dataset[image.dataSrcName]; 18701 18702 if (main_core.Type.isStringFilled(src)) { 18703 image.node = node; 18704 image.src = src; 18705 image.status = this.imageStatus.inited; 18706 image.type = image.node.tagName.toLowerCase() == "img" ? this.imageTypes.image : this.imageTypes.background; 18707 } 18708 }, 18709 isElementVisibleOnScreen: function isElementVisibleOnScreen(element) { 18710 var coords = this.getElementCoords(element); 18711 var windowTop = window.pageYOffset || document.documentElement.scrollTop; 18712 var windowBottom = windowTop + document.documentElement.clientHeight; 18713 coords.bottom = coords.top + element.offsetHeight; 18714 return coords.top > windowTop && coords.top < windowBottom || // topVisible 18715 coords.bottom < windowBottom && coords.bottom > windowTop // bottomVisible 18716 ; 18717 }, 18718 isElementVisibleOn2Screens: function isElementVisibleOn2Screens(element) { 18719 var windowHeight = document.documentElement.clientHeight; 18720 var windowTop = window.pageYOffset || document.documentElement.scrollTop; 18721 var windowBottom = windowTop + windowHeight; 18722 var coords = this.getElementCoords(element); 18723 coords.bottom = coords.top + element.offsetHeight; 18724 windowTop -= windowHeight; 18725 windowBottom += windowHeight; 18726 return coords.top > windowTop && coords.top < windowBottom || // topVisible 18727 coords.bottom < windowBottom && coords.bottom > windowTop // bottomVisible 18728 ; 18729 }, 18730 getElementCoords: function getElementCoords(element) { 18731 var box = element.getBoundingClientRect(); 18732 return { 18733 originTop: box.top, 18734 originLeft: box.left, 18735 top: box.top + window.pageYOffset, 18736 left: box.left + window.pageXOffset 18737 }; 18738 }, 18739 onScroll: function onScroll() {}, 18740 clearImages: function clearImages() { 18741 this.images = []; 18742 } 18743 }; 18744 18745 exports.LazyLoad = LazyLoad; 18746 18747}((this.BX = this.BX || {}),BX)); 18748 18749 18750 18751(function (exports) { 18752 'use strict'; 18753 18754 var ParamBag = /*#__PURE__*/function () { 18755 function ParamBag() { 18756 var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 18757 babelHelpers.classCallCheck(this, ParamBag); 18758 18759 if (!!params && babelHelpers.typeof(params) === 'object') { 18760 this.params = new Map(Object.entries(params)); 18761 } else { 18762 this.params = new Map(); 18763 } 18764 } 18765 18766 babelHelpers.createClass(ParamBag, [{ 18767 key: "getParam", 18768 value: function getParam(key) { 18769 var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; 18770 18771 if (this.params.has(key)) { 18772 return this.params.get(key); 18773 } 18774 18775 return defaultValue; 18776 } 18777 }, { 18778 key: "setParam", 18779 value: function setParam(key, value) { 18780 this.params.set(key, value); 18781 } 18782 }, { 18783 key: "clear", 18784 value: function clear() { 18785 this.params.clear(); 18786 } 18787 }], [{ 18788 key: "create", 18789 value: function create() { 18790 var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 18791 return new ParamBag(params); 18792 } 18793 }]); 18794 return ParamBag; 18795 }(); 18796 18797 exports.ParamBag = ParamBag; 18798 18799}((this.BX = this.BX || {}))); 18800 18801 18802 18803(function() { 18804 BX.FixFontSize = function(params) 18805 { 18806 var widthNode, computedStyles, width; 18807 18808 this.node = null; 18809 this.prevWindowSize = 0; 18810 this.prevWrapperSize = 0; 18811 this.mainWrapper = null; 18812 this.textWrapper = null; 18813 this.objList = params.objList; 18814 this.minFontSizeList = []; 18815 this.minFontSize = 0; 18816 18817 if (params.onresize) 18818 { 18819 this.prevWindowSize = window.innerWidth || document.documentElement.clientWidth; 18820 BX.bind(window, 'resize', BX.throttle(this.onResize, 350, this)); 18821 } 18822 18823 if (params.onAdaptiveResize) 18824 { 18825 widthNode = this.objList[0].scaleBy || this.objList[0].node; 18826 computedStyles = getComputedStyle(widthNode); 18827 this.prevWrapperSize = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 18828 BX.bind(window, 'resize', BX.throttle(this.onAdaptiveResize, 350, this)); 18829 } 18830 18831 this.createTestNodes(); 18832 this.decrease(); 18833 }; 18834 18835 BX.FixFontSize.prototype = 18836 { 18837 createTestNodes: function() 18838 { 18839 this.textWrapper = BX.create('div',{ 18840 style : { 18841 display : 'inline-block', 18842 whiteSpace : 'nowrap' 18843 } 18844 }); 18845 18846 this.mainWrapper = BX.create('div',{ 18847 style : { 18848 height : 0, 18849 overflow : 'hidden' 18850 }, 18851 children : [this.textWrapper] 18852 }); 18853 18854 }, 18855 insertTestNodes: function() 18856 { 18857 document.body.appendChild(this.mainWrapper); 18858 }, 18859 removeTestNodes: function() 18860 { 18861 document.body.removeChild(this.mainWrapper); 18862 }, 18863 decrease: function() 18864 { 18865 var width, 18866 fontSize, 18867 widthNode, 18868 computedStyles; 18869 18870 this.insertTestNodes(); 18871
18872 for(var i=this.objList.length-1; i>=0; i--) 18873 { 18874 widthNode = this.objList[i].scaleBy || this.objList[i].node; 18875 computedStyles = getComputedStyle(widthNode); 18876 width = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 18877 fontSize = parseInt(getComputedStyle(this.objList[i].node)["font-size"]); 18878 18879 this.textWrapperSetStyle(this.objList[i].node); 18880 18881 if(this.textWrapperInsertText(this.objList[i].node)) 18882 { 18883 while(this.textWrapper.offsetWidth > width && fontSize > 0) 18884 { 18885 this.textWrapper.style.fontSize = --fontSize + 'px'; 18886 } 18887 18888 if(this.objList[i].smallestValue) 18889 { 18890 this.minFontSize = this.minFontSize ? Math.min(this.minFontSize, fontSize) : fontSize; 18891 18892 this.minFontSizeList.push(this.objList[i].node) 18893 } 18894 else 18895 { 18896 this.objList[i].node.style.fontSize = fontSize + 'px'; 18897 } 18898 } 18899 } 18900 18901 if(this.minFontSizeList.length > 0) 18902 this.setMinFont(); 18903 18904 this.removeTestNodes(); 18905 18906 }, 18907 increase: function() 18908 { 18909 this.insertTestNodes(); 18910 var width, 18911 fontSize, 18912 widthNode, 18913 computedStyles; 18914 18915 this.insertTestNodes(); 18916 18917 for(var i=this.objList.length-1; i>=0; i--) 18918 { 18919 widthNode = this.objList[i].scaleBy || this.objList[i].node; 18920 computedStyles = getComputedStyle(widthNode); 18921 width = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 18922 fontSize = parseInt(getComputedStyle(this.objList[i].node)["font-size"]); 18923 18924 this.textWrapperSetStyle(this.objList[i].node); 18925 18926 if(this.textWrapperInsertText(this.objList[i].node)) 18927 { 18928 while(this.textWrapper.offsetWidth < width && fontSize < this.objList[i].maxFontSize) 18929 { 18930 this.textWrapper.style.fontSize = ++fontSize + 'px'; 18931 } 18932 18933 fontSize--; 18934 18935 if(this.objList[i].smallestValue) 18936 { 18937 this.minFontSize = this.minFontSize ? Math.min(this.minFontSize, fontSize) : fontSize; 18938 18939 this.minFontSizeList.push(this.objList[i].node) 18940 } 18941 else 18942 { 18943 this.objList[i].node.style.fontSize = fontSize + 'px'; 18944 } 18945 } 18946 } 18947 18948 if(this.minFontSizeList.length > 0) 18949 this.setMinFont(); 18950 18951 this.removeTestNodes(); 18952 }, 18953 setMinFont : function() 18954 { 18955 for(var i = this.minFontSizeList.length-1; i>=0; i--) 18956 { 18957 this.minFontSizeList[i].style.fontSize = this.minFontSize + 'px'; 18958 } 18959 18960 this.minFontSize = 0; 18961 }, 18962 onResize : function() 18963 { 18964 var width = window.innerWidth || document.documentElement.clientWidth; 18965 18966 if(this.prevWindowSize > width) 18967 this.decrease(); 18968 18969 else if (this.prevWindowSize < width) 18970 this.increase(); 18971 18972 this.prevWindowSize = width; 18973 }, 18974 onAdaptiveResize : function() 18975 { 18976 var widthNode = this.objList[0].scaleBy || this.objList[0].node, 18977 computedStyles = getComputedStyle(widthNode), 18978 width = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 18979 18980 if (this.prevWrapperSize > width) 18981 this.decrease(); 18982 else if (this.prevWrapperSize < width) 18983 this.increase(); 18984 18985 this.prevWrapperSize = width; 18986 }, 18987 textWrapperInsertText : function(node) 18988 { 18989 if(node.textContent){ 18990 this.textWrapper.textContent = node.textContent; 18991 return true; 18992 } 18993 else if(node.innerText) 18994 { 18995 this.textWrapper.innerText = node.innerText; 18996 return true; 18997 } 18998 else { 18999 return false; 19000 } 19001 }, 19002 textWrapperSetStyle : function(node) 19003 { 19004 this.textWrapper.style.fontFamily = getComputedStyle(node)["font-family"]; 19005 this.textWrapper.style.fontSize = getComputedStyle(node)["font-size"]; 19006 this.textWrapper.style.fontStyle = getComputedStyle(node)["font-style"]; 19007 this.textWrapper.style.fontWeight = getComputedStyle(node)["font-weight"]; 19008 this.textWrapper.style.lineHeight = getComputedStyle(node)["line-height"]; 19009 } 19010 }; 19011 19012 BX.FixFontSize.init = function(params) 19013 { 19014 return new BX.FixFontSize(params); 19015 }; 19016})(); 19017 19018})(); 19019//# 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.