1;(function() { 2 3 if (typeof window.BX === 'function') 4 { 5 return; 6 } 7 8/** 9 * Babel external helpers 10 * (c) 2018 Babel 11 * @license MIT 12 */ 13(function (global) { 14 var babelHelpers = global.babelHelpers = {}; 15 16 function _typeof(obj) { 17 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { 18 babelHelpers.typeof = _typeof = function (obj) { 19 return typeof obj; 20 }; 21 } else { 22 babelHelpers.typeof = _typeof = function (obj) { 23 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; 24 }; 25 } 26 27 return _typeof(obj); 28 } 29 30 babelHelpers.typeof = _typeof; 31 var REACT_ELEMENT_TYPE; 32 33 function _createRawReactElement(type, props, key, children) { 34 if (!REACT_ELEMENT_TYPE) { 35 REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for && Symbol.for("react.element") || 0xeac7; 36 } 37 38 var defaultProps = type && type.defaultProps; 39 var childrenLength = arguments.length - 3; 40 41 if (!props && childrenLength !== 0) { 42 props = { 43 children: void 0 44 }; 45 } 46 47 if (props && defaultProps) { 48 for (var propName in defaultProps) { 49 if (props[propName] === void 0) { 50 props[propName] = defaultProps[propName]; 51 } 52 } 53 } else if (!props) { 54 props = defaultProps || {}; 55 } 56 57 if (childrenLength === 1) { 58 props.children = children; 59 } else if (childrenLength > 1) { 60 var childArray = new Array(childrenLength); 61 62 for (var i = 0; i < childrenLength; i++) { 63 childArray[i] = arguments[i + 3]; 64 } 65 66 props.children = childArray; 67 } 68 69 return { 70 $$typeof: REACT_ELEMENT_TYPE, 71 type: type, 72 key: key === undefined ? null : '' + key, 73 ref: null, 74 props: props, 75 _owner: null 76 }; 77 } 78 79 babelHelpers.jsx = _createRawReactElement; 80 81 function _asyncIterator(iterable) { 82 var method; 83 84 if (typeof Symbol === "function") { 85 if (Symbol.asyncIterator) { 86 method = iterable[Symbol.asyncIterator]; 87 if (method != null) return method.call(iterable); 88 } 89 90 if (Symbol.iterator) { 91 method = iterable[Symbol.iterator]; 92 if (method != null) return method.call(iterable); 93 } 94 } 95 96 throw new TypeError("Object is not async iterable"); 97 } 98 99 babelHelpers.asyncIterator = _asyncIterator; 100 101 function _AwaitValue(value) { 102 this.wrapped = value; 103 } 104 105 babelHelpers.AwaitValue = _AwaitValue; 106 107 function AsyncGenerator(gen) { 108 var front, back; 109 110 function send(key, arg) { 111 return new Promise(function (resolve, reject) { 112 var request = { 113 key: key, 114 arg: arg, 115 resolve: resolve, 116 reject: reject, 117 next: null 118 }; 119 120 if (back) { 121 back = back.next = request; 122 } else { 123 front = back = request; 124 resume(key, arg); 125 } 126 }); 127 } 128 129 function resume(key, arg) { 130 try { 131 var result = gen[key](arg); 132 var value = result.value; 133 var wrappedAwait = value instanceof babelHelpers.AwaitValue; 134 Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { 135 if (wrappedAwait) { 136 resume("next", arg); 137 return; 138 } 139 140 settle(result.done ? "return" : "normal", arg); 141 }, function (err) { 142 resume("throw", err); 143 }); 144 } catch (err) { 145 settle("throw", err); 146 } 147 } 148 149 function settle(type, value) { 150 switch (type) { 151 case "return": 152 front.resolve({ 153 value: value, 154 done: true 155 }); 156 break; 157 158 case "throw": 159 front.reject(value); 160 break; 161 162 default: 163 front.resolve({ 164 value: value, 165 done: false 166 }); 167 break; 168 } 169 170 front = front.next; 171 172 if (front) { 173 resume(front.key, front.arg); 174 } else { 175 back = null; 176 } 177 } 178 179 this._invoke = send; 180 181 if (typeof gen.return !== "function") { 182 this.return = undefined; 183 } 184 } 185 186 if (typeof Symbol === "function" && Symbol.asyncIterator) { 187 AsyncGenerator.prototype[Symbol.asyncIterator] = function () { 188 return this; 189 }; 190 } 191 192 AsyncGenerator.prototype.next = function (arg) { 193 return this._invoke("next", arg); 194 }; 195 196 AsyncGenerator.prototype.throw = function (arg) { 197 return this._invoke("throw", arg); 198 }; 199 200 AsyncGenerator.prototype.return = function (arg) { 201 return this._invoke("return", arg); 202 }; 203 204 babelHelpers.AsyncGenerator = AsyncGenerator; 205 206 function _wrapAsyncGenerator(fn) { 207 return function () { 208 return new babelHelpers.AsyncGenerator(fn.apply(this, arguments)); 209 }; 210 } 211 212 babelHelpers.wrapAsyncGenerator = _wrapAsyncGenerator; 213 214 function _awaitAsyncGenerator(value) { 215 return new babelHelpers.AwaitValue(value); 216 } 217 218 babelHelpers.awaitAsyncGenerator = _awaitAsyncGenerator; 219 220 function _asyncGeneratorDelegate(inner, awaitWrap) { 221 var iter = {}, 222 waiting = false;
223 224 function pump(key, value) { 225 waiting = true; 226 value = new Promise(function (resolve) { 227 resolve(inner[key](value)); 228 }); 229 return { 230 done: false, 231 value: awaitWrap(value) 232 }; 233 } 234 235 ; 236 237 if (typeof Symbol === "function" && Symbol.iterator) { 238 iter[Symbol.iterator] = function () { 239 return this; 240 }; 241 } 242 243 iter.next = function (value) { 244 if (waiting) { 245 waiting = false; 246 return value; 247 } 248 249 return pump("next", value); 250 }; 251 252 if (typeof inner.throw === "function") { 253 iter.throw = function (value) { 254 if (waiting) { 255 waiting = false; 256 throw value; 257 } 258 259 return pump("throw", value); 260 }; 261 } 262 263 if (typeof inner.return === "function") { 264 iter.return = function (value) { 265 return pump("return", value); 266 }; 267 } 268 269 return iter; 270 } 271 272 babelHelpers.asyncGeneratorDelegate = _asyncGeneratorDelegate; 273 274 function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { 275 try { 276 var info = gen[key](arg); 277 var value = info.value; 278 } catch (error) { 279 reject(error); 280 return; 281 } 282 283 if (info.done) { 284 resolve(value); 285 } else { 286 Promise.resolve(value).then(_next, _throw); 287 } 288 } 289 290 function _asyncToGenerator(fn) { 291 return function () { 292 var self = this, 293 args = arguments; 294 return new Promise(function (resolve, reject) { 295 var gen = fn.apply(self, args); 296 297 function _next(value) { 298 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); 299 } 300 301 function _throw(err) { 302 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); 303 } 304 305 _next(undefined); 306 }); 307 }; 308 } 309 310 babelHelpers.asyncToGenerator = _asyncToGenerator; 311 312 function _classCallCheck(instance, Constructor) { 313 if (!(instance instanceof Constructor)) { 314 throw new TypeError("Cannot call a class as a function"); 315 } 316 } 317 318 babelHelpers.classCallCheck = _classCallCheck; 319 320 function _defineProperties(target, props) { 321 for (var i = 0; i < props.length; i++) { 322 var descriptor = props[i]; 323 descriptor.enumerable = descriptor.enumerable || false; 324 descriptor.configurable = true; 325 if ("value" in descriptor) descriptor.writable = true; 326 Object.defineProperty(target, descriptor.key, descriptor); 327 } 328 } 329 330 function _createClass(Constructor, protoProps, staticProps) { 331 if (protoProps) _defineProperties(Constructor.prototype, protoProps); 332 if (staticProps) _defineProperties(Constructor, staticProps); 333 return Constructor; 334 } 335 336 babelHelpers.createClass = _createClass; 337 338 function _defineEnumerableProperties(obj, descs) { 339 for (var key in descs) { 340 var desc = descs[key]; 341 desc.configurable = desc.enumerable = true; 342 if ("value" in desc) desc.writable = true; 343 Object.defineProperty(obj, key, desc); 344 } 345 346 if (Object.getOwnPropertySymbols) { 347 var objectSymbols = Object.getOwnPropertySymbols(descs); 348 349 for (var i = 0; i < objectSymbols.length; i++) { 350 var sym = objectSymbols[i]; 351 var desc = descs[sym]; 352 desc.configurable = desc.enumerable = true; 353 if ("value" in desc) desc.writable = true; 354 Object.defineProperty(obj, sym, desc); 355 } 356 } 357 358 return obj; 359 } 360 361 babelHelpers.defineEnumerableProperties = _defineEnumerableProperties; 362 363 function _defaults(obj, defaults) { 364 var keys = Object.getOwnPropertyNames(defaults); 365 366 for (var i = 0; i < keys.length; i++) { 367 var key = keys[i]; 368 var value = Object.getOwnPropertyDescriptor(defaults, key); 369 370 if (value && value.configurable && obj[key] === undefined) { 371 Object.defineProperty(obj, key, value); 372 } 373 } 374 375 return obj; 376 } 377 378 babelHelpers.defaults = _defaults; 379 380 function _defineProperty(obj, key, value) { 381 if (key in obj) { 382 Object.defineProperty(obj, key, { 383 value: value, 384 enumerable: true, 385 configurable: true, 386 writable: true 387 }); 388 } else { 389 obj[key] = value; 390 } 391 392 return obj; 393 } 394 395 babelHelpers.defineProperty = _defineProperty; 396 397 function _extends() { 398 babelHelpers.extends = _extends = Object.assign || function (target) { 399 for (var i = 1; i < arguments.length; i++) { 400 var source = arguments[i]; 401 402 for (var key in source) { 403 if (Object.prototype.hasOwnProperty.call(source, key)) { 404 target[key] = source[key]; 405 } 406 } 407 } 408 409 return target; 410 }; 411 412 return _extends.apply(this, arguments); 413 } 414 415 babelHelpers.extends = _extends; 416 417 function _objectSpread(target) { 418 for (var i = 1; i < arguments.length; i++) { 419 var source = arguments[i] != null ? arguments[i] : {}; 420 var ownKeys = Object.keys(source); 421 422 if (typeof Object.getOwnPropertySymbols === 'function') { 423 ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { 424 return Object.getOwnPropertyDescriptor(source, sym).enumerable; 425 })); 426 } 427 428 ownKeys.forEach(function (key) { 429 babelHelpers.defineProperty(target, key, source[key]); 430 }); 431 } 432 433 return target; 434 } 435 436 babelHelpers.objectSpread = _objectSpread; 437 438 function _inherits(subClass, superClass) { 439 if (typeof superClass !== "function" && superClass !== null) { 440 throw new TypeError("Super expression must either be null or a function"); 441 } 442 443 subClass.prototype = Object.create(superClass && superClass.prototype, { 444 constructor: { 445 value: subClass, 446 writable: true, 447 configurable: true 448 } 449 }); 450 if (superClass) babelHelpers.setPrototypeOf(subClass, superClass); 451 } 452 453 babelHelpers.inherits = _inherits; 454 455 function _inheritsLoose(subClass, superClass) { 456 subClass.prototype = Object.create(superClass.prototype); 457 subClass.prototype.constructor = subClass; 458 subClass.__proto__ = superClass; 459 } 460 461 babelHelpers.inheritsLoose = _inheritsLoose; 462
463 function _getPrototypeOf(o) { 464 babelHelpers.getPrototypeOf = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { 465 return o.__proto__ || Object.getPrototypeOf(o); 466 }; 467 return _getPrototypeOf(o); 468 } 469 470 babelHelpers.getPrototypeOf = _getPrototypeOf; 471 472 function _setPrototypeOf(o, p) { 473 babelHelpers.setPrototypeOf = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { 474 o.__proto__ = p; 475 return o; 476 }; 477 478 return _setPrototypeOf(o, p); 479 } 480 481 babelHelpers.setPrototypeOf = _setPrototypeOf; 482 483 function isNativeReflectConstruct() { 484 if (typeof Reflect === "undefined" || !Reflect.construct) return false; 485 if (Reflect.construct.sham) return false; 486 if (typeof Proxy === "function") return true; 487 488 try { 489 Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); 490 return true; 491 } catch (e) { 492 return false; 493 } 494 } 495 496 function _construct(Parent, args, Class) { 497 if (isNativeReflectConstruct()) { 498 babelHelpers.construct = _construct = Reflect.construct; 499 } else { 500 babelHelpers.construct = _construct = function _construct(Parent, args, Class) { 501 var a = [null]; 502 a.push.apply(a, args); 503 var Constructor = Function.bind.apply(Parent, a); 504 var instance = new Constructor(); 505 if (Class) babelHelpers.setPrototypeOf(instance, Class.prototype); 506 return instance; 507 }; 508 } 509 510 return _construct.apply(null, arguments); 511 } 512 513 babelHelpers.construct = _construct; 514 515 function _isNativeFunction(fn) { 516 return Function.toString.call(fn).indexOf("[native code]") !== -1; 517 } 518 519 babelHelpers.isNativeFunction = _isNativeFunction; 520 521 function _wrapNativeSuper(Class) { 522 var _cache = typeof Map === "function" ? new Map() : undefined; 523 524 babelHelpers.wrapNativeSuper = _wrapNativeSuper = function _wrapNativeSuper(Class) { 525 if (Class === null || !babelHelpers.isNativeFunction(Class)) return Class; 526 527 if (typeof Class !== "function") { 528 throw new TypeError("Super expression must either be null or a function"); 529 } 530 531 if (typeof _cache !== "undefined") { 532 if (_cache.has(Class)) return _cache.get(Class); 533 534 _cache.set(Class, Wrapper); 535 } 536 537 function Wrapper() { 538 return babelHelpers.construct(Class, arguments, babelHelpers.getPrototypeOf(this).constructor); 539 } 540 541 Wrapper.prototype = Object.create(Class.prototype, { 542 constructor: { 543 value: Wrapper, 544 enumerable: false, 545 writable: true, 546 configurable: true 547 } 548 }); 549 return babelHelpers.setPrototypeOf(Wrapper, Class); 550 }; 551 552 return _wrapNativeSuper(Class); 553 } 554 555 babelHelpers.wrapNativeSuper = _wrapNativeSuper; 556 557 function _instanceof(left, right) { 558 if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { 559 return right[Symbol.hasInstance](left); 560 } else { 561 return left instanceof right; 562 } 563 } 564 565 babelHelpers.instanceof = _instanceof; 566 567 function _interopRequireDefault(obj) { 568 return obj && obj.__esModule ? obj : { 569 default: obj 570 }; 571 } 572 573 babelHelpers.interopRequireDefault = _interopRequireDefault; 574 575 function _interopRequireWildcard(obj) { 576 if (obj && obj.__esModule) { 577 return obj; 578 } else { 579 var newObj = {}; 580 581 if (obj != null) { 582 for (var key in obj) { 583 if (Object.prototype.hasOwnProperty.call(obj, key)) { 584 var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; 585 586 if (desc.get || desc.set) { 587 Object.defineProperty(newObj, key, desc); 588 } else { 589 newObj[key] = obj[key]; 590 } 591 } 592 } 593 } 594 595 newObj.default = obj; 596 return newObj; 597 } 598 } 599 600 babelHelpers.interopRequireWildcard = _interopRequireWildcard; 601 602 function _newArrowCheck(innerThis, boundThis) { 603 if (innerThis !== boundThis) { 604 throw new TypeError("Cannot instantiate an arrow function"); 605 } 606 } 607 608 babelHelpers.newArrowCheck = _newArrowCheck; 609 610 function _objectDestructuringEmpty(obj) { 611 if (obj == null) throw new TypeError("Cannot destructure undefined"); 612 } 613 614 babelHelpers.objectDestructuringEmpty = _objectDestructuringEmpty; 615 616 function _objectWithoutPropertiesLoose(source, excluded) { 617 if (source == null) return {}; 618 var target = {}; 619 var sourceKeys = Object.keys(source); 620 var key, i; 621 622 for (i = 0; i < sourceKeys.length; i++) { 623 key = sourceKeys[i]; 624 if (excluded.indexOf(key) >= 0) continue; 625 target[key] = source[key]; 626 } 627 628 return target; 629 } 630 631 babelHelpers.objectWithoutPropertiesLoose = _objectWithoutPropertiesLoose; 632 633 function _objectWithoutProperties(source, excluded) { 634 if (source == null) return {}; 635 var target = babelHelpers.objectWithoutPropertiesLoose(source, excluded); 636 var key, i; 637 638 if (Object.getOwnPropertySymbols) { 639 var sourceSymbolKeys = Object.getOwnPropertySymbols(source); 640 641 for (i = 0; i < sourceSymbolKeys.length; i++) { 642 key = sourceSymbolKeys[i]; 643 if (excluded.indexOf(key) >= 0) continue; 644 if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; 645 target[key] = source[key]; 646 } 647 } 648 649 return target; 650 } 651 652 babelHelpers.objectWithoutProperties = _objectWithoutProperties; 653 654 function _assertThisInitialized(self) { 655 if (self === void 0) { 656 throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); 657 } 658 659 return self; 660 } 661 662 babelHelpers.assertThisInitialized = _assertThisInitialized; 663 664 function _possibleConstructorReturn(self, call) { 665 if (call && (typeof call === "object" || typeof call === "function")) { 666 return call; 667 } 668 669 return babelHelpers.assertThisInitialized(self); 670 } 671 672 babelHelpers.possibleConstructorReturn = _possibleConstructorReturn; 673 674 function _superPropBase(object, property) { 675 while (!Object.prototype.hasOwnProperty.call(object, property)) { 676 object = babelHelpers.getPrototypeOf(object); 677 if (object === null) break; 678 } 679 680 return object; 681 } 682 683 babelHelpers.superPropBase = _superPropBase; 684 685 function _get(target, property, receiver) { 686 if (typeof Reflect !== "undefined" && Reflect.get) { 687 babelHelpers.get = _get = Reflect.get; 688 } else { 689 babelHelpers.get = _get = function _get(target, property, receiver) { 690 var base = babelHelpers.superPropBase(target, property); 691 if (!base) return; 692 var desc = Object.getOwnPropertyDescriptor(base, property); 693 694 if (desc.get) { 695 return desc.get.call(receiver); 696 } 697 698 return desc.value; 699 }; 700 } 701 702 return _get(target, property, receiver || target); 703 } 704 705 babelHelpers.get = _get; 706 707 function set(target, property, value, receiver) { 708 if (typeof Reflect !== "undefined" && Reflect.set) { 709 set = Reflect.set; 710 } else { 711 set = function set(target, property, value, receiver) { 712 var base = babelHelpers.superPropBase(target, property); 713 var desc; 714 715 if (base) { 716 desc = Object.getOwnPropertyDescriptor(base, property); 717 718 if (desc.set) { 719 desc.set.call(receiver, value); 720 return true; 721 } else if (!desc.writable) { 722 return false;
723 } 724 } 725 726 desc = Object.getOwnPropertyDescriptor(receiver, property); 727 728 if (desc) { 729 if (!desc.writable) { 730 return false; 731 } 732 733 desc.value = value; 734 Object.defineProperty(receiver, property, desc); 735 } else { 736 babelHelpers.defineProperty(receiver, property, value); 737 } 738 739 return true; 740 }; 741 } 742 743 return set(target, property, value, receiver); 744 } 745 746 function _set(target, property, value, receiver, isStrict) { 747 var s = set(target, property, value, receiver || target); 748 749 if (!s && isStrict) { 750 throw new Error('failed to set property'); 751 } 752 753 return value; 754 } 755 756 babelHelpers.set = _set; 757 758 function _taggedTemplateLiteral(strings, raw) { 759 if (!raw) { 760 raw = strings.slice(0); 761 } 762 763 return Object.freeze(Object.defineProperties(strings, { 764 raw: { 765 value: Object.freeze(raw) 766 } 767 })); 768 } 769 770 babelHelpers.taggedTemplateLiteral = _taggedTemplateLiteral; 771 772 function _taggedTemplateLiteralLoose(strings, raw) { 773 if (!raw) { 774 raw = strings.slice(0); 775 } 776 777 strings.raw = raw; 778 return strings; 779 } 780 781 babelHelpers.taggedTemplateLiteralLoose = _taggedTemplateLiteralLoose; 782 783 function _temporalRef(val, name) { 784 if (val === babelHelpers.temporalUndefined) { 785 throw new ReferenceError(name + " is not defined - temporal dead zone"); 786 } else { 787 return val; 788 } 789 } 790 791 babelHelpers.temporalRef = _temporalRef; 792 793 function _readOnlyError(name) { 794 throw new Error("\"" + name + "\" is read-only"); 795 } 796 797 babelHelpers.readOnlyError = _readOnlyError; 798 799 function _classNameTDZError(name) { 800 throw new Error("Class \"" + name + "\" cannot be referenced in computed property keys."); 801 } 802 803 babelHelpers.classNameTDZError = _classNameTDZError; 804 babelHelpers.temporalUndefined = {}; 805 806 function _slicedToArray(arr, i) { 807 return babelHelpers.arrayWithHoles(arr) || babelHelpers.iterableToArrayLimit(arr, i) || babelHelpers.nonIterableRest(); 808 } 809 810 babelHelpers.slicedToArray = _slicedToArray; 811 812 function _slicedToArrayLoose(arr, i) { 813 return babelHelpers.arrayWithHoles(arr) || babelHelpers.iterableToArrayLimitLoose(arr, i) || babelHelpers.nonIterableRest(); 814 } 815 816 babelHelpers.slicedToArrayLoose = _slicedToArrayLoose; 817 818 function _toArray(arr) { 819 return babelHelpers.arrayWithHoles(arr) || babelHelpers.iterableToArray(arr) || babelHelpers.nonIterableRest(); 820 } 821 822 babelHelpers.toArray = _toArray; 823 824 function _toConsumableArray(arr) { 825 return babelHelpers.arrayWithoutHoles(arr) || babelHelpers.iterableToArray(arr) || babelHelpers.nonIterableSpread(); 826 } 827 828 babelHelpers.toConsumableArray = _toConsumableArray; 829 830 function _arrayWithoutHoles(arr) { 831 if (Array.isArray(arr)) { 832 for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; 833 834 return arr2; 835 } 836 } 837 838 babelHelpers.arrayWithoutHoles = _arrayWithoutHoles; 839 840 function _arrayWithHoles(arr) { 841 if (Array.isArray(arr)) return arr; 842 } 843 844 babelHelpers.arrayWithHoles = _arrayWithHoles; 845 846 function _iterableToArray(iter) { 847 if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); 848 } 849 850 babelHelpers.iterableToArray = _iterableToArray; 851 852 function _iterableToArrayLimit(arr, i) { 853 var _arr = []; 854 var _n = true; 855 var _d = false; 856 var _e = undefined; 857 858 try { 859 for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { 860 _arr.push(_s.value); 861 862 if (i && _arr.length === i) break; 863 } 864 } catch (err) { 865 _d = true; 866 _e = err; 867 } finally { 868 try { 869 if (!_n && _i["return"] != null) _i["return"](); 870 } finally { 871 if (_d) throw _e; 872 } 873 } 874 875 return _arr; 876 } 877 878 babelHelpers.iterableToArrayLimit = _iterableToArrayLimit; 879 880 function _iterableToArrayLimitLoose(arr, i) { 881 var _arr = []; 882 883 for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { 884 _arr.push(_step.value); 885 886 if (i && _arr.length === i) break; 887 } 888 889 return _arr; 890 } 891 892 babelHelpers.iterableToArrayLimitLoose = _iterableToArrayLimitLoose; 893 894 function _nonIterableSpread() { 895 throw new TypeError("Invalid attempt to spread non-iterable instance"); 896 } 897 898 babelHelpers.nonIterableSpread = _nonIterableSpread; 899 900 function _nonIterableRest() {
901 throw new TypeError("Invalid attempt to destructure non-iterable instance"); 902 } 903 904 babelHelpers.nonIterableRest = _nonIterableRest; 905 906 function _skipFirstGeneratorNext(fn) { 907 return function () { 908 var it = fn.apply(this, arguments); 909 it.next(); 910 return it; 911 }; 912 } 913 914 babelHelpers.skipFirstGeneratorNext = _skipFirstGeneratorNext; 915 916 function _toPropertyKey(key) { 917 if (typeof key === "symbol") { 918 return key; 919 } else { 920 return String(key); 921 } 922 } 923 924 babelHelpers.toPropertyKey = _toPropertyKey; 925 926 function _initializerWarningHelper(descriptor, context) { 927 throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and set to use loose mode. ' + 'To use proposal-class-properties in spec mode with decorators, wait for ' + 'the next major version of decorators in stage 2.'); 928 } 929 930 babelHelpers.initializerWarningHelper = _initializerWarningHelper; 931 932 function _initializerDefineProperty(target, property, descriptor, context) { 933 if (!descriptor) return; 934 Object.defineProperty(target, property, { 935 enumerable: descriptor.enumerable, 936 configurable: descriptor.configurable, 937 writable: descriptor.writable, 938 value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 939 }); 940 } 941 942 babelHelpers.initializerDefineProperty = _initializerDefineProperty; 943 944 function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { 945 var desc = {}; 946 Object['ke' + 'ys'](descriptor).forEach(function (key) { 947 desc[key] = descriptor[key]; 948 }); 949 desc.enumerable = !!desc.enumerable; 950 desc.configurable = !!desc.configurable; 951 952 if ('value' in desc || desc.initializer) { 953 desc.writable = true; 954 } 955 956 desc = decorators.slice().reverse().reduce(function (desc, decorator) { 957 return decorator(target, property, desc) || desc; 958 }, desc); 959 960 if (context && desc.initializer !== void 0) { 961 desc.value = desc.initializer ? desc.initializer.call(context) : void 0; 962 desc.initializer = undefined; 963 } 964 965 if (desc.initializer === void 0) { 966 Object['define' + 'Property'](target, property, desc); 967 desc = null; 968 } 969 970 return desc; 971 } 972 973 babelHelpers.applyDecoratedDescriptor = _applyDecoratedDescriptor; 974 var id = 0; 975 976 function _classPrivateFieldKey(name) { 977 return "__private_" + id++ + "_" + name; 978 } 979 980 babelHelpers.classPrivateFieldLooseKey = _classPrivateFieldKey; 981 982 function _classPrivateFieldBase(receiver, privateKey) { 983 if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { 984 throw new TypeError("attempted to use private field on non-instance"); 985 } 986 987 return receiver; 988 } 989 990 babelHelpers.classPrivateFieldLooseBase = _classPrivateFieldBase; 991 992 function _classPrivateFieldGet(receiver, privateMap) { 993 if (!privateMap.has(receiver)) { 994 throw new TypeError("attempted to get private field on non-instance"); 995 } 996 997 return privateMap.get(receiver).value; 998 } 999 1000 babelHelpers.classPrivateFieldGet = _classPrivateFieldGet; 1001 1002 function _classPrivateFieldSet(receiver, privateMap, value) { 1003 if (!privateMap.has(receiver)) { 1004 throw new TypeError("attempted to set private field on non-instance"); 1005 } 1006 1007 var descriptor = privateMap.get(receiver); 1008 1009 if (!descriptor.writable) { 1010 throw new TypeError("attempted to set read only private field"); 1011 } 1012 1013 descriptor.value = value; 1014 return value; 1015 } 1016 1017 babelHelpers.classPrivateFieldSet = _classPrivateFieldSet; 1018})(typeof global === "undefined" ? window : global); 1019 1020/** 1021 * Copyright (c) 2014-present, Facebook, Inc. 1022 * 1023 * This source code is licensed under the MIT license found in the 1024 * LICENSE file in the root directory of this source tree. 1025 */ 1026 1027!(function(global) { 1028 "use strict"; 1029 1030 var Op = Object.prototype; 1031 var hasOwn = Op.hasOwnProperty; 1032 var undefined; // More compressible than void 0. 1033 var $Symbol = typeof Symbol === "function" ? Symbol : {}; 1034 var iteratorSymbol = $Symbol.iterator || "@@iterator"; 1035 var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; 1036 var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; 1037 1038 // Define the runtime globally (as expected by generated code) as either 1039 // module.exports (if we're in a module) or a new, empty object. 1040 var runtime = global.regeneratorRuntime = {}; 1041 1042 function wrap(innerFn, outerFn, self, tryLocsList) { 1043 // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. 1044 var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; 1045 var generator = Object.create(protoGenerator.prototype); 1046 var context = new Context(tryLocsList || []); 1047 1048 // The ._invoke method unifies the implementations of the .next, 1049 // .throw, and .return methods. 1050 generator._invoke = makeInvokeMethod(innerFn, self, context); 1051 1052 return generator; 1053 } 1054 runtime.wrap = wrap; 1055 1056 // Try/catch helper to minimize deoptimizations. Returns a completion 1057 // record like context.tryEntries[i].completion. This interface could
vendor: 10,591 bytes, lines 1058-1351
1058 // have been (and was previously) designed to take a closure to be 1059 // invoked without arguments, but in all the cases we care about we 1060 // already have an existing method we want to call, so there's no need 1061 // to create a new function object. We can even get away with assuming 1062 // the method takes exactly one argument, since that happens to be true 1063 // in every case, so we don't have to touch the arguments object. The 1064 // only additional allocation required is the completion record, which 1065 // has a stable shape and so hopefully should be cheap to allocate. 1066 function tryCatch(fn, obj, arg) { 1067 try { 1068 return { type: "normal", arg: fn.call(obj, arg) }; 1069 } catch (err) { 1070 return { type: "throw", arg: err }; 1071 } 1072 } 1073 1074 var GenStateSuspendedStart = "suspendedStart"; 1075 var GenStateSuspendedYield = "suspendedYield"; 1076 var GenStateExecuting = "executing"; 1077 var GenStateCompleted = "completed"; 1078 1079 // Returning this object from the innerFn has the same effect as 1080 // breaking out of the dispatch switch statement. 1081 var ContinueSentinel = {}; 1082 1083 // Dummy constructor functions that we use as the .constructor and 1084 // .constructor.prototype properties for functions that return Generator 1085 // objects. For full spec compliance, you may wish to configure your 1086 // minifier not to mangle the names of these two functions. 1087 function Generator() {} 1088 function GeneratorFunction() {} 1089 function GeneratorFunctionPrototype() {} 1090 1091 // This is a polyfill for %IteratorPrototype% for environments that 1092 // don't natively support it. 1093 var IteratorPrototype = {}; 1094 IteratorPrototype[iteratorSymbol] = function () { 1095 return this; 1096 }; 1097 1098 var getProto = Object.getPrototypeOf; 1099 var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); 1100 if (NativeIteratorPrototype && 1101 NativeIteratorPrototype !== Op && 1102 hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { 1103 // This environment has a native %IteratorPrototype%; use it instead 1104 // of the polyfill. 1105 IteratorPrototype = NativeIteratorPrototype; 1106 } 1107 1108 var Gp = GeneratorFunctionPrototype.prototype = 1109 Generator.prototype = Object.create(IteratorPrototype); 1110 GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype; 1111 GeneratorFunctionPrototype.constructor = GeneratorFunction; 1112 GeneratorFunctionPrototype[toStringTagSymbol] = 1113 GeneratorFunction.displayName = "GeneratorFunction"; 1114 1115 // Helper for defining the .next, .throw, and .return methods of the 1116 // Iterator interface in terms of a single ._invoke method. 1117 function defineIteratorMethods(prototype) { 1118 ["next", "throw", "return"].forEach(function(method) { 1119 prototype[method] = function(arg) { 1120 return this._invoke(method, arg); 1121 }; 1122 }); 1123 } 1124 1125 runtime.isGeneratorFunction = function(genFun) { 1126 var ctor = typeof genFun === "function" && genFun.constructor; 1127 return ctor 1128 ? ctor === GeneratorFunction || 1129 // For the native GeneratorFunction constructor, the best we can 1130 // do is to check its .name property. 1131 (ctor.displayName || ctor.name) === "GeneratorFunction" 1132 : false; 1133 }; 1134 1135 runtime.mark = function(genFun) { 1136 if (Object.setPrototypeOf) { 1137 Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); 1138 } else { 1139 genFun.__proto__ = GeneratorFunctionPrototype; 1140 if (!(toStringTagSymbol in genFun)) { 1141 genFun[toStringTagSymbol] = "GeneratorFunction"; 1142 } 1143 } 1144 genFun.prototype = Object.create(Gp); 1145 return genFun; 1146 }; 1147 1148 // Within the body of any async function, `await x` is transformed to 1149 // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test 1150 // `hasOwn.call(value, "__await")` to determine if the yielded value is 1151 // meant to be awaited. 1152 runtime.awrap = function(arg) { 1153 return { __await: arg }; 1154 }; 1155 1156 function AsyncIterator(generator) { 1157 function invoke(method, arg, resolve, reject) { 1158 var record = tryCatch(generator[method], generator, arg); 1159 if (record.type === "throw") { 1160 reject(record.arg); 1161 } else { 1162 var result = record.arg; 1163 var value = result.value; 1164 if (value && 1165 typeof value === "object" && 1166 hasOwn.call(value, "__await")) { 1167 return Promise.resolve(value.__await).then(function(value) { 1168 invoke("next", value, resolve, reject); 1169 }, function(err) { 1170 invoke("throw", err, resolve, reject); 1171 }); 1172 } 1173 1174 return Promise.resolve(value).then(function(unwrapped) { 1175 // When a yielded Promise is resolved, its final value becomes 1176 // the .value of the Promise<{value,done}> result for the 1177 // current iteration. If the Promise is rejected, however, the 1178 // result for this iteration will be rejected with the same 1179 // reason. Note that rejections of yielded Promises are not 1180 // thrown back into the generator function, as is the case 1181 // when an awaited Promise is rejected. This difference in 1182 // behavior between yield and await is important, because it 1183 // allows the consumer to decide what to do with the yielded 1184 // rejection (swallow it and continue, manually .throw it back 1185 // into the generator, abandon iteration, whatever). With 1186 // await, by contrast, there is no opportunity to examine the 1187 // rejection reason outside the generator function, so the 1188 // only option is to throw it from the await expression, and 1189 // let the generator function handle the exception. 1190 result.value = unwrapped; 1191 resolve(result); 1192 }, reject); 1193 } 1194 } 1195 1196 var previousPromise; 1197 1198 function enqueue(method, arg) { 1199 function callInvokeWithMethodAndArg() { 1200 return new Promise(function(resolve, reject) { 1201 invoke(method, arg, resolve, reject); 1202 }); 1203 } 1204 1205 return previousPromise = 1206 // If enqueue has been called before, then we want to wait until 1207 // all previous Promises have been resolved before calling invoke, 1208 // so that results are always delivered in the correct order. If 1209 // enqueue has not been called before, then it is important to 1210 // call invoke immediately, without waiting on a callback to fire, 1211 // so that the async generator function has the opportunity to do 1212 // any necessary setup in a predictable way. This predictability 1213 // is why the Promise constructor synchronously invokes its 1214 // executor callback, and why async functions synchronously 1215 // execute code before the first await. Since we implement simple 1216 // async functions in terms of async generators, it is especially 1217 // important to get this right, even though it requires care. 1218 previousPromise ? previousPromise.then( 1219 callInvokeWithMethodAndArg, 1220 // Avoid propagating failures to Promises returned by later 1221 // invocations of the iterator. 1222 callInvokeWithMethodAndArg 1223 ) : callInvokeWithMethodAndArg(); 1224 } 1225 1226 // Define the unified helper method that is used to implement .next, 1227 // .throw, and .return (see defineIteratorMethods). 1228 this._invoke = enqueue; 1229 } 1230 1231 defineIteratorMethods(AsyncIterator.prototype); 1232 AsyncIterator.prototype[asyncIteratorSymbol] = function () { 1233 return this; 1234 }; 1235 runtime.AsyncIterator = AsyncIterator; 1236 1237 // Note that simple async functions are implemented on top of 1238 // AsyncIterator objects; they just return a Promise for the value of 1239 // the final result produced by the iterator. 1240 runtime.async = function(innerFn, outerFn, self, tryLocsList) { 1241 var iter = new AsyncIterator( 1242 wrap(innerFn, outerFn, self, tryLocsList) 1243 ); 1244 1245 return runtime.isGeneratorFunction(outerFn) 1246 ? iter // If outerFn is a generator, return the full iterator. 1247 : iter.next().then(function(result) { 1248 return result.done ? result.value : iter.next(); 1249 }); 1250 }; 1251 1252 function makeInvokeMethod(innerFn, self, context) { 1253 var state = GenStateSuspendedStart; 1254 1255 return function invoke(method, arg) { 1256 if (state === GenStateExecuting) { 1257 throw new Error("Generator is already running"); 1258 } 1259 1260 if (state === GenStateCompleted) { 1261 if (method === "throw") { 1262 throw arg; 1263 } 1264 1265 // Be forgiving, per 25.3.3.3.3 of the spec: 1266 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume 1267 return doneResult(); 1268 } 1269 1270 context.method = method; 1271 context.arg = arg; 1272 1273 while (true) { 1274 var delegate = context.delegate; 1275 if (delegate) { 1276 var delegateResult = maybeInvokeDelegate(delegate, context); 1277 if (delegateResult) { 1278 if (delegateResult === ContinueSentinel) continue; 1279 return delegateResult; 1280 } 1281 } 1282 1283 if (context.method === "next") { 1284 // Setting context._sent for legacy support of Babel's 1285 // function.sent implementation. 1286 context.sent = context._sent = context.arg; 1287 1288 } else if (context.method === "throw") { 1289 if (state === GenStateSuspendedStart) { 1290 state = GenStateCompleted; 1291 throw context.arg; 1292 } 1293 1294 context.dispatchException(context.arg); 1295 1296 } else if (context.method === "return") { 1297 context.abrupt("return", context.arg); 1298 } 1299 1300 state = GenStateExecuting; 1301 1302 var record = tryCatch(innerFn, self, context); 1303 if (record.type === "normal") { 1304 // If an exception is thrown from innerFn, we leave state === 1305 // GenStateExecuting and loop back for another invocation. 1306 state = context.done 1307 ? GenStateCompleted 1308 : GenStateSuspendedYield; 1309 1310 if (record.arg === ContinueSentinel) { 1311 continue; 1312 } 1313 1314 return { 1315 value: record.arg, 1316 done: context.done 1317 }; 1318 1319 } else if (record.type === "throw") { 1320 state = GenStateCompleted; 1321 // Dispatch the exception by looping back around to the 1322 // context.dispatchException(context.arg) call above. 1323 context.method = "throw"; 1324 context.arg = record.arg; 1325 } 1326 } 1327 }; 1328 } 1329 1330 // Call delegate.iterator[context.method](context.arg) and handle the 1331 // result, either by returning a { value, done } result from the 1332 // delegate iterator, or by modifying context.method and context.arg, 1333 // setting context.delegate to null, and returning the ContinueSentinel. 1334 function maybeInvokeDelegate(delegate, context) { 1335 var method = delegate.iterator[context.method]; 1336 if (method === undefined) { 1337 // A .throw or .return when the delegate iterator has no .throw 1338 // method always terminates the yield* loop. 1339 context.delegate = null; 1340 1341 if (context.method === "throw") { 1342 if (delegate.iterator.return) { 1343 // If the delegate iterator has a return method, give it a 1344 // chance to clean up. 1345 context.method = "return"; 1346 context.arg = undefined; 1347 maybeInvokeDelegate(delegate, context); 1348 1349 if (context.method === "throw") { 1350 // If maybeInvokeDelegate(context) changed context.method from 1351 // "return" to "throw", let that override the TypeError below.
vendor: 4,172 bytes, lines 1352-1505
1352 return ContinueSentinel; 1353 } 1354 } 1355 1356 context.method = "throw"; 1357 context.arg = new TypeError( 1358 "The iterator does not provide a 'throw' method"); 1359 } 1360 1361 return ContinueSentinel; 1362 } 1363 1364 var record = tryCatch(method, delegate.iterator, context.arg); 1365 1366 if (record.type === "throw") { 1367 context.method = "throw"; 1368 context.arg = record.arg; 1369 context.delegate = null; 1370 return ContinueSentinel; 1371 } 1372 1373 var info = record.arg; 1374 1375 if (! info) { 1376 context.method = "throw"; 1377 context.arg = new TypeError("iterator result is not an object"); 1378 context.delegate = null; 1379 return ContinueSentinel; 1380 } 1381 1382 if (info.done) { 1383 // Assign the result of the finished delegate to the temporary 1384 // variable specified by delegate.resultName (see delegateYield). 1385 context[delegate.resultName] = info.value; 1386 1387 // Resume execution at the desired location (see delegateYield). 1388 context.next = delegate.nextLoc; 1389 1390 // If context.method was "throw" but the delegate handled the 1391 // exception, let the outer generator proceed normally. If 1392 // context.method was "next", forget context.arg since it has been 1393 // "consumed" by the delegate iterator. If context.method was 1394 // "return", allow the original .return call to continue in the 1395 // outer generator. 1396 if (context.method !== "return") { 1397 context.method = "next"; 1398 context.arg = undefined; 1399 } 1400 1401 } else { 1402 // Re-yield the result returned by the delegate method. 1403 return info; 1404 } 1405 1406 // The delegate iterator is finished, so forget it and continue with 1407 // the outer generator. 1408 context.delegate = null; 1409 return ContinueSentinel; 1410 } 1411 1412 // Define Generator.prototype.{next,throw,return} in terms of the 1413 // unified ._invoke helper method. 1414 defineIteratorMethods(Gp); 1415 1416 Gp[toStringTagSymbol] = "Generator"; 1417 1418 // A Generator should always return itself as the iterator object when the 1419 // @@iterator function is called on it. Some browsers' implementations of the 1420 // iterator prototype chain incorrectly implement this, causing the Generator 1421 // object to not be returned from this call. This ensures that doesn't happen. 1422 // See https://github.com/facebook/regenerator/issues/274 for more details. 1423 Gp[iteratorSymbol] = function() { 1424 return this; 1425 }; 1426 1427 Gp.toString = function() { 1428 return "[object Generator]"; 1429 }; 1430 1431 function pushTryEntry(locs) { 1432 var entry = { tryLoc: locs[0] }; 1433 1434 if (1 in locs) { 1435 entry.catchLoc = locs[1]; 1436 } 1437 1438 if (2 in locs) { 1439 entry.finallyLoc = locs[2]; 1440 entry.afterLoc = locs[3]; 1441 } 1442 1443 this.tryEntries.push(entry); 1444 } 1445 1446 function resetTryEntry(entry) { 1447 var record = entry.completion || {}; 1448 record.type = "normal"; 1449 delete record.arg; 1450 entry.completion = record; 1451 } 1452 1453 function Context(tryLocsList) { 1454 // The root entry object (effectively a try statement without a catch 1455 // or a finally block) gives us a place to store values thrown from 1456 // locations where there is no enclosing try statement. 1457 this.tryEntries = [{ tryLoc: "root" }]; 1458 tryLocsList.forEach(pushTryEntry, this); 1459 this.reset(true); 1460 } 1461 1462 runtime.keys = function(object) { 1463 var keys = []; 1464 for (var key in object) { 1465 keys.push(key); 1466 } 1467 keys.reverse(); 1468 1469 // Rather than returning an object with a next method, we keep 1470 // things simple and return the next function itself. 1471 return function next() { 1472 while (keys.length) { 1473 var key = keys.pop(); 1474 if (key in object) { 1475 next.value = key; 1476 next.done = false; 1477 return next; 1478 } 1479 } 1480 1481 // To avoid creating an additional object, we just hang the .value 1482 // and .done properties off the next function object itself. This 1483 // also ensures that the minifier will not anonymize the function. 1484 next.done = true; 1485 return next; 1486 }; 1487 }; 1488 1489 function values(iterable) { 1490 if (iterable) { 1491 var iteratorMethod = iterable[iteratorSymbol]; 1492 if (iteratorMethod) { 1493 return iteratorMethod.call(iterable); 1494 } 1495 1496 if (typeof iterable.next === "function") { 1497 return iterable; 1498 } 1499 1500 if (!isNaN(iterable.length)) { 1501 var i = -1, next = function next() { 1502 while (++i < iterable.length) { 1503 if (hasOwn.call(iterable, i)) { 1504 next.value = iterable[i]; 1505 next.done = false;
1506 return next; 1507 } 1508 } 1509 1510 next.value = undefined; 1511 next.done = true; 1512 1513 return next; 1514 }; 1515 1516 return next.next = next; 1517 } 1518 } 1519 1520 // Return an iterator with no values. 1521 return { next: doneResult }; 1522 } 1523 runtime.values = values; 1524 1525 function doneResult() { 1526 return { value: undefined, done: true }; 1527 } 1528 1529 Context.prototype = { 1530 constructor: Context, 1531 1532 reset: function(skipTempReset) { 1533 this.prev = 0; 1534 this.next = 0; 1535 // Resetting context._sent for legacy support of Babel's 1536 // function.sent implementation. 1537 this.sent = this._sent = undefined; 1538 this.done = false; 1539 this.delegate = null; 1540 1541 this.method = "next"; 1542 this.arg = undefined; 1543 1544 this.tryEntries.forEach(resetTryEntry); 1545 1546 if (!skipTempReset) { 1547 for (var name in this) { 1548 // Not sure about the optimal order of these conditions: 1549 if (name.charAt(0) === "t" && 1550 hasOwn.call(this, name) && 1551 !isNaN(+name.slice(1))) { 1552 this[name] = undefined; 1553 } 1554 } 1555 } 1556 }, 1557 1558 stop: function() { 1559 this.done = true; 1560 1561 var rootEntry = this.tryEntries[0]; 1562 var rootRecord = rootEntry.completion; 1563 if (rootRecord.type === "throw") { 1564 throw rootRecord.arg; 1565 } 1566 1567 return this.rval; 1568 }, 1569 1570 dispatchException: function(exception) { 1571 if (this.done) { 1572 throw exception; 1573 } 1574 1575 var context = this; 1576 function handle(loc, caught) { 1577 record.type = "throw"; 1578 record.arg = exception; 1579 context.next = loc; 1580 1581 if (caught) { 1582 // If the dispatched exception was caught by a catch block, 1583 // then let that catch block handle the exception normally. 1584 context.method = "next"; 1585 context.arg = undefined; 1586 } 1587 1588 return !! caught; 1589 } 1590 1591 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 1592 var entry = this.tryEntries[i]; 1593 var record = entry.completion; 1594 1595 if (entry.tryLoc === "root") { 1596 // Exception thrown outside of any try block that could handle 1597 // it, so set the completion value of the entire function to 1598 // throw the exception. 1599 return handle("end"); 1600 } 1601 1602 if (entry.tryLoc <= this.prev) { 1603 var hasCatch = hasOwn.call(entry, "catchLoc"); 1604 var hasFinally = hasOwn.call(entry, "finallyLoc"); 1605 1606 if (hasCatch && hasFinally) { 1607 if (this.prev < entry.catchLoc) { 1608 return handle(entry.catchLoc, true); 1609 } else if (this.prev < entry.finallyLoc) { 1610 return handle(entry.finallyLoc); 1611 } 1612 1613 } else if (hasCatch) { 1614 if (this.prev < entry.catchLoc) { 1615 return handle(entry.catchLoc, true); 1616 } 1617 1618 } else if (hasFinally) { 1619 if (this.prev < entry.finallyLoc) { 1620 return handle(entry.finallyLoc); 1621 } 1622 1623 } else { 1624 throw new Error("try statement without catch or finally"); 1625 } 1626 } 1627 } 1628 }, 1629 1630 abrupt: function(type, arg) { 1631 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 1632 var entry = this.tryEntries[i]; 1633 if (entry.tryLoc <= this.prev && 1634 hasOwn.call(entry, "finallyLoc") && 1635 this.prev < entry.finallyLoc) { 1636 var finallyEntry = entry; 1637 break; 1638 } 1639 } 1640 1641 if (finallyEntry && 1642 (type === "break" || 1643 type === "continue") && 1644 finallyEntry.tryLoc <= arg && 1645 arg <= finallyEntry.finallyLoc) { 1646 // Ignore the finally entry if control is not jumping to a 1647 // location outside the try/catch block. 1648 finallyEntry = null; 1649 } 1650 1651 var record = finallyEntry ? finallyEntry.completion : {}; 1652 record.type = type; 1653 record.arg = arg; 1654 1655 if (finallyEntry) { 1656 this.method = "next"; 1657 this.next = finallyEntry.finallyLoc; 1658 return ContinueSentinel; 1659 } 1660 1661 return this.complete(record); 1662 }, 1663 1664 complete: function(record, afterLoc) { 1665 if (record.type === "throw") { 1666 throw record.arg; 1667 } 1668 1669 if (record.type === "break" || 1670 record.type === "continue") { 1671 this.next = record.arg; 1672 } else if (record.type === "return") { 1673 this.rval = this.arg = record.arg; 1674 this.method = "return"; 1675 this.next = "end"; 1676 } else if (record.type === "normal" && afterLoc) { 1677 this.next = afterLoc; 1678 } 1679 1680 return ContinueSentinel; 1681 }, 1682 1683 finish: function(finallyLoc) { 1684 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 1685 var entry = this.tryEntries[i]; 1686 if (entry.finallyLoc === finallyLoc) { 1687 this.complete(entry.completion, entry.afterLoc); 1688 resetTryEntry(entry); 1689 return ContinueSentinel; 1690 } 1691 } 1692 }, 1693 1694 "catch": function(tryLoc) { 1695 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 1696 var entry = this.tryEntries[i]; 1697 if (entry.tryLoc === tryLoc) { 1698 var record = entry.completion; 1699 if (record.type === "throw") { 1700 var thrown = record.arg; 1701 resetTryEntry(entry); 1702 } 1703 return thrown; 1704 } 1705 } 1706 1707 // The context.catch method must only be called with a location 1708 // argument that corresponds to a known catch block. 1709 throw new Error("illegal catch attempt"); 1710 }, 1711 1712 delegateYield: function(iterable, resultName, nextLoc) { 1713 this.delegate = { 1714 iterator: values(iterable), 1715 resultName: resultName, 1716 nextLoc: nextLoc 1717 }; 1718 1719 if (this.method === "next") { 1720 // Deliberately forget the last sent value so that we don't 1721 // accidentally pass it on to the delegate. 1722 this.arg = undefined; 1723 } 1724 1725 return ContinueSentinel; 1726 } 1727 }; 1728})( 1729 // In sloppy mode, unbound `this` refers to the global object, fallback to 1730 // Function constructor if we're in global strict mode. That is sadly a form 1731 // of indirect eval which violates Content Security Policy. 1732 (function() { return this })() || Function("return this")() 1733); 1734 1735(function (exports) { 1736 'use strict'; 1737 1738 var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; 1739 function createCommonjsModule(fn, module) { 1740 return module = { 1741 exports: {} 1742 }, fn(module, module.exports), module.exports; 1743 } 1744 1745 var check = function (it) { 1746 return it && it.Math == Math && it; 1747 }; // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 1748 1749 1750 var global_1 = // eslint-disable-next-line es/no-global-this -- safe 1751 check(typeof globalThis == 'object' && globalThis) || check(typeof window == 'object' && window) || // eslint-disable-next-line no-restricted-globals -- safe 1752 check(typeof self == 'object' && self) || check(typeof commonjsGlobal == 'object' && commonjsGlobal) || // eslint-disable-next-line no-new-func -- fallback 1753 function () { 1754 return this; 1755 }() || Function('return this')(); 1756 1757 var fails = function (exec) { 1758 try { 1759 return !!exec(); 1760 } catch (error) { 1761 return true; 1762 } 1763 }; 1764 1765 // Detect IE8's incomplete defineProperty implementation 1766 1767 1768 var descriptors = !fails(function () { 1769 // eslint-disable-next-line es/no-object-defineproperty -- required for testing 1770 return Object.defineProperty({}, 1, { 1771 get: function () { 1772 return 7; 1773 } 1774 })[1] != 7; 1775 }); 1776 1777 var call = Function.prototype.call; 1778 var functionCall = call.bind ? call.bind(call) : function () { 1779 return call.apply(call, arguments); 1780 }; 1781 1782 var $propertyIsEnumerable = {}.propertyIsEnumerable; // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 1783 1784 var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; // Nashorn ~ JDK8 bug 1785 1786 var NASHORN_BUG = getOwnPropertyDescriptor && !$propertyIsEnumerable.call({ 1787 1: 2 1788 }, 1); // `Object.prototype.propertyIsEnumerable` method implementation 1789 // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable 1790 1791 var f = NASHORN_BUG ? function propertyIsEnumerable(V) { 1792 var descriptor = getOwnPropertyDescriptor(this, V); 1793 return !!descriptor && descriptor.enumerable; 1794 } : $propertyIsEnumerable; 1795 1796 var objectPropertyIsEnumerable = { 1797 f: f 1798 }; 1799 1800 var createPropertyDescriptor = function (bitmap, value) { 1801 return { 1802 enumerable: !(bitmap & 1), 1803 configurable: !(bitmap & 2), 1804 writable: !(bitmap & 4), 1805 value: value 1806 }; 1807 }; 1808 1809 var FunctionPrototype = Function.prototype; 1810 var bind = FunctionPrototype.bind; 1811 var call$1 = FunctionPrototype.call; 1812 var callBind = bind && bind.bind(call$1); 1813 var functionUncurryThis = bind ? function (fn) {
1814 return fn && callBind(call$1, fn); 1815 } : function (fn) { 1816 return fn && function () { 1817 return call$1.apply(fn, arguments); 1818 }; 1819 }; 1820 1821 var toString = functionUncurryThis({}.toString); 1822 var stringSlice = functionUncurryThis(''.slice); 1823 1824 var classofRaw = function (it) { 1825 return stringSlice(toString(it), 8, -1); 1826 }; 1827 1828 var Object$1 = global_1.Object; 1829 var split = functionUncurryThis(''.split); // fallback for non-array-like ES3 and non-enumerable old V8 strings 1830 1831 var indexedObject = fails(function () { 1832 // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346 1833 // eslint-disable-next-line no-prototype-builtins -- safe 1834 return !Object$1('z').propertyIsEnumerable(0); 1835 }) ? function (it) { 1836 return classofRaw(it) == 'String' ? split(it, '') : Object$1(it); 1837 } : Object$1; 1838 1839 var TypeError$1 = global_1.TypeError; // `RequireObjectCoercible` abstract operation 1840 // https://tc39.es/ecma262/#sec-requireobjectcoercible 1841 1842 var requireObjectCoercible = function (it) { 1843 if (it == undefined) throw TypeError$1("Can't call method on " + it); 1844 return it; 1845 }; 1846 1847 // toObject with fallback for non-array-like ES3 strings 1848 1849 1850 1851 1852 var toIndexedObject = function (it) { 1853 return indexedObject(requireObjectCoercible(it)); 1854 }; 1855 1856 // `IsCallable` abstract operation 1857 // https://tc39.es/ecma262/#sec-iscallable 1858 var isCallable = function (argument) { 1859 return typeof argument == 'function'; 1860 }; 1861 1862 var isObject = function (it) { 1863 return typeof it == 'object' ? it !== null : isCallable(it); 1864 }; 1865 1866 var aFunction = function (argument) { 1867 return isCallable(argument) ? argument : undefined; 1868 }; 1869 1870 var getBuiltIn = function (namespace, method) { 1871 return arguments.length < 2 ? aFunction(global_1[namespace]) : global_1[namespace] && global_1[namespace][method]; 1872 }; 1873 1874 var objectIsPrototypeOf = functionUncurryThis({}.isPrototypeOf); 1875 1876 var engineUserAgent = getBuiltIn('navigator', 'userAgent') || ''; 1877 1878 var process = global_1.process; 1879 var Deno = global_1.Deno; 1880 var versions = process && process.versions || Deno && Deno.version; 1881 var v8 = versions && versions.v8; 1882 var match, version; 1883 1884 if (v8) { 1885 match = v8.split('.'); // in old Chrome, versions of V8 isn't V8 = Chrome / 10 1886 // but their correct versions are not interesting for us 1887 1888 version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]); 1889 } // BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0` 1890 // so check `userAgent` even if `.v8` exists, but 0 1891 1892 1893 if (!version && engineUserAgent) { 1894 match = engineUserAgent.match(/Edge\/(\d+)/); 1895 1896 if (!match || match[1] >= 74) { 1897 match = engineUserAgent.match(/Chrome\/(\d+)/); 1898 if (match) version = +match[1]; 1899 } 1900 } 1901 1902 var engineV8Version = version; 1903 1904 /* eslint-disable es/no-symbol -- required for testing */ 1905 1906 1907 // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing 1908 1909 1910 var nativeSymbol = !!Object.getOwnPropertySymbols && !fails(function () { 1911 var symbol = Symbol(); // Chrome 38 Symbol has incorrect toString conversion 1912 // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances 1913 1914 return !String(symbol) || !(Object(symbol) instanceof Symbol) || // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances 1915 !Symbol.sham && engineV8Version && engineV8Version < 41; 1916 }); 1917 1918 /* eslint-disable es/no-symbol -- required for testing */ 1919 1920 1921 var useSymbolAsUid = nativeSymbol && !Symbol.sham && typeof Symbol.iterator == 'symbol'; 1922 1923 var Object$2 = global_1.Object; 1924 var isSymbol = useSymbolAsUid ? function (it) { 1925 return typeof it == 'symbol'; 1926 } : function (it) { 1927 var $Symbol = getBuiltIn('Symbol'); 1928 return isCallable($Symbol) && objectIsPrototypeOf($Symbol.prototype, Object$2(it)); 1929 }; 1930 1931 var String$1 = global_1.String; 1932 1933 var tryToString = function (argument) { 1934 try { 1935 return String$1(argument); 1936 } catch (error) { 1937 return 'Object'; 1938 } 1939 }; 1940 1941 var TypeError$2 = global_1.TypeError; // `Assert: IsCallable(argument) is true` 1942 1943 var aCallable = function (argument) { 1944 if (isCallable(argument)) return argument; 1945 throw TypeError$2(tryToString(argument) + ' is not a function'); 1946 }; 1947 1948 // `GetMethod` abstract operation 1949 // https://tc39.es/ecma262/#sec-getmethod 1950 1951 1952 var getMethod = function (V, P) { 1953 var func = V[P]; 1954 return func == null ? undefined : aCallable(func); 1955 }; 1956 1957 var TypeError$3 = global_1.TypeError; // `OrdinaryToPrimitive` abstract operation 1958 // https://tc39.es/ecma262/#sec-ordinarytoprimitive 1959 1960 var ordinaryToPrimitive = function (input, pref) { 1961 var fn, val; 1962 if (pref === 'string' && isCallable(fn = input.toString) && !isObject(val = functionCall(fn, input))) return val; 1963 if (isCallable(fn = input.valueOf) && !isObject(val = functionCall(fn, input))) return val; 1964 if (pref !== 'string' && isCallable(fn = input.toString) && !isObject(val = functionCall(fn, input))) return val; 1965 throw TypeError$3("Can't convert object to primitive value"); 1966 }; 1967 1968 var isPure = false;
1969 1970 // eslint-disable-next-line es/no-object-defineproperty -- safe 1971 1972 1973 var defineProperty = Object.defineProperty; 1974 1975 var setGlobal = function (key, value) { 1976 try { 1977 defineProperty(global_1, key, { 1978 value: value, 1979 configurable: true, 1980 writable: true 1981 }); 1982 } catch (error) { 1983 global_1[key] = value; 1984 } 1985 1986 return value; 1987 }; 1988 1989 var SHARED = '__core-js_shared__'; 1990 var store = global_1[SHARED] || setGlobal(SHARED, {}); 1991 var sharedStore = store; 1992 1993 var shared = createCommonjsModule(function (module) { 1994 (module.exports = function (key, value) { 1995 return sharedStore[key] || (sharedStore[key] = value !== undefined ? value : {}); 1996 })('versions', []).push({ 1997 version: '3.19.2', 1998 mode: 'global', 1999 copyright: '(c) 2021 Denis Pushkarev (zloirock.ru)' 2000 }); 2001 }); 2002 2003 var Object$3 = global_1.Object; // `ToObject` abstract operation 2004 // https://tc39.es/ecma262/#sec-toobject 2005 2006 var toObject = function (argument) { 2007 return Object$3(requireObjectCoercible(argument)); 2008 }; 2009 2010 var hasOwnProperty = functionUncurryThis({}.hasOwnProperty); // `HasOwnProperty` abstract operation 2011 // https://tc39.es/ecma262/#sec-hasownproperty 2012 2013 var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) { 2014 return hasOwnProperty(toObject(it), key); 2015 }; 2016 2017 var id = 0; 2018 var postfix = Math.random(); 2019 var toString$1 = functionUncurryThis(1.0.toString); 2020 2021 var uid = function (key) { 2022 return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString$1(++id + postfix, 36); 2023 }; 2024 2025 var WellKnownSymbolsStore = shared('wks'); 2026 var Symbol$1 = global_1.Symbol; 2027 var symbolFor = Symbol$1 && Symbol$1['for']; 2028 var createWellKnownSymbol = useSymbolAsUid ? Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid; 2029 2030 var wellKnownSymbol = function (name) { 2031 if (!hasOwnProperty_1(WellKnownSymbolsStore, name) || !(nativeSymbol || typeof WellKnownSymbolsStore[name] == 'string')) { 2032 var description = 'Symbol.' + name; 2033 2034 if (nativeSymbol && hasOwnProperty_1(Symbol$1, name)) { 2035 WellKnownSymbolsStore[name] = Symbol$1[name]; 2036 } else if (useSymbolAsUid && symbolFor) { 2037 WellKnownSymbolsStore[name] = symbolFor(description); 2038 } else { 2039 WellKnownSymbolsStore[name] = createWellKnownSymbol(description); 2040 } 2041 } 2042 2043 return WellKnownSymbolsStore[name]; 2044 }; 2045 2046 var TypeError$4 = global_1.TypeError; 2047 var TO_PRIMITIVE = wellKnownSymbol('toPrimitive'); // `ToPrimitive` abstract operation 2048 // https://tc39.es/ecma262/#sec-toprimitive 2049 2050 var toPrimitive = function (input, pref) { 2051 if (!isObject(input) || isSymbol(input)) return input; 2052 var exoticToPrim = getMethod(input, TO_PRIMITIVE); 2053 var result; 2054 2055 if (exoticToPrim) { 2056 if (pref === undefined) pref = 'default'; 2057 result = functionCall(exoticToPrim, input, pref); 2058 if (!isObject(result) || isSymbol(result)) return result; 2059 throw TypeError$4("Can't convert object to primitive value"); 2060 } 2061 2062 if (pref === undefined) pref = 'number'; 2063 return ordinaryToPrimitive(input, pref); 2064 }; 2065 2066 // `ToPropertyKey` abstract operation 2067 // https://tc39.es/ecma262/#sec-topropertykey 2068 2069 2070 var toPropertyKey = function (argument) { 2071 var key = toPrimitive(argument, 'string'); 2072 return isSymbol(key) ? key : key + ''; 2073 }; 2074 2075 var document$1 = global_1.document; // typeof document.createElement is 'object' in old IE 2076 2077 var EXISTS = isObject(document$1) && isObject(document$1.createElement); 2078 2079 var documentCreateElement = function (it) { 2080 return EXISTS ? document$1.createElement(it) : {}; 2081 }; 2082 2083 // Thank's IE8 for his funny defineProperty 2084 2085 2086 var ie8DomDefine = !descriptors && !fails(function () { 2087 // eslint-disable-next-line es/no-object-defineproperty -- requied for testing 2088 return Object.defineProperty(documentCreateElement('div'), 'a', { 2089 get: function () { 2090 return 7; 2091 } 2092 }).a != 7; 2093 }); 2094 2095 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 2096 2097 2098 var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; // `Object.getOwnPropertyDescriptor` method 2099 // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor 2100 2101 var f$1 = descriptors ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) { 2102 O = toIndexedObject(O); 2103 P = toPropertyKey(P); 2104 if (ie8DomDefine) try { 2105 return $getOwnPropertyDescriptor(O, P); 2106 } catch (error) { 2107 /* empty */ 2108 } 2109 if (hasOwnProperty_1(O, P)) return createPropertyDescriptor(!functionCall(objectPropertyIsEnumerable.f, O, P), O[P]); 2110 }; 2111 2112 var objectGetOwnPropertyDescriptor = { 2113 f: f$1 2114 }; 2115 2116 var String$2 = global_1.String; 2117 var TypeError$5 = global_1.TypeError; // `Assert: Type(argument) is Object` 2118 2119 var anObject = function (argument) { 2120 if (isObject(argument)) return argument; 2121 throw TypeError$5(String$2(argument) + ' is not an object'); 2122 }; 2123 2124 var TypeError$6 = global_1.TypeError; // eslint-disable-next-line es/no-object-defineproperty -- safe 2125 2126 var $defineProperty = Object.defineProperty; // `Object.defineProperty` method 2127 // https://tc39.es/ecma262/#sec-object.defineproperty 2128 2129 var f$2 = descriptors ? $defineProperty : function defineProperty(O, P, Attributes) { 2130 anObject(O); 2131 P = toPropertyKey(P); 2132 anObject(Attributes); 2133 if (ie8DomDefine) try { 2134 return $defineProperty(O, P, Attributes); 2135 } catch (error) { 2136 /* empty */ 2137 } 2138 if ('get' in Attributes || 'set' in Attributes) throw TypeError$6('Accessors not supported'); 2139 if ('value' in Attributes) O[P] = Attributes.value; 2140 return O; 2141 }; 2142 2143 var objectDefineProperty = { 2144 f: f$2 2145 }; 2146 2147 var createNonEnumerableProperty = descriptors ? function (object, key, value) { 2148 return objectDefineProperty.f(object, key, createPropertyDescriptor(1, value)); 2149 } : function (object, key, value) { 2150 object[key] = value; 2151 return object; 2152 }; 2153 2154 var functionToString = functionUncurryThis(Function.toString); // this helper broken in `[email protected]`, so we can't use `shared` helper 2155 2156 if (!isCallable(sharedStore.inspectSource)) { 2157 sharedStore.inspectSource = function (it) { 2158 return functionToString(it); 2159 }; 2160 } 2161 2162 var inspectSource = sharedStore.inspectSource; 2163 2164 var WeakMap = global_1.WeakMap; 2165 var nativeWeakMap = isCallable(WeakMap) && /native code/.test(inspectSource(WeakMap)); 2166 2167 var keys = shared('keys'); 2168 2169 var sharedKey = function (key) { 2170 return keys[key] || (keys[key] = uid(key)); 2171 }; 2172 2173 var hiddenKeys = {}; 2174 2175 var OBJECT_ALREADY_INITIALIZED = 'Object already initialized'; 2176 var TypeError$7 = global_1.TypeError; 2177 var WeakMap$1 = global_1.WeakMap; 2178 var set, get, has; 2179 2180 var enforce = function (it) { 2181 return has(it) ? get(it) : set(it, {}); 2182 }; 2183 2184 var getterFor = function (TYPE) { 2185 return function (it) { 2186 var state; 2187 2188 if (!isObject(it) || (state = get(it)).type !== TYPE) { 2189 throw TypeError$7('Incompatible receiver, ' + TYPE + ' required'); 2190 } 2191 2192 return state; 2193 }; 2194 }; 2195 2196 if (nativeWeakMap || sharedStore.state) { 2197 var store$1 = sharedStore.state || (sharedStore.state = new WeakMap$1()); 2198 var wmget = functionUncurryThis(store$1.get); 2199 var wmhas = functionUncurryThis(store$1.has); 2200 var wmset = functionUncurryThis(store$1.set); 2201 2202 set = function (it, metadata) { 2203 if (wmhas(store$1, it)) throw new TypeError$7(OBJECT_ALREADY_INITIALIZED); 2204 metadata.facade = it; 2205 wmset(store$1, it, metadata); 2206 return metadata; 2207 }; 2208 2209 get = function (it) { 2210 return wmget(store$1, it) || {}; 2211 }; 2212 2213 has = function (it) { 2214 return wmhas(store$1, it); 2215 }; 2216 } else { 2217 var STATE = sharedKey('state'); 2218 hiddenKeys[STATE] = true; 2219 2220 set = function (it, metadata) { 2221 if (hasOwnProperty_1(it, STATE)) throw new TypeError$7(OBJECT_ALREADY_INITIALIZED); 2222 metadata.facade = it; 2223 createNonEnumerableProperty(it, STATE, metadata); 2224 return metadata; 2225 }; 2226 2227 get = function (it) { 2228 return hasOwnProperty_1(it, STATE) ? it[STATE] : {}; 2229 }; 2230 2231 has = function (it) { 2232 return hasOwnProperty_1(it, STATE); 2233 }; 2234 } 2235 2236 var internalState = { 2237 set: set, 2238 get: get, 2239 has: has, 2240 enforce: enforce, 2241 getterFor: getterFor 2242 }; 2243 2244 var FunctionPrototype$1 = Function.prototype; // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 2245 2246 var getDescriptor = descriptors && Object.getOwnPropertyDescriptor; 2247 var EXISTS$1 = hasOwnProperty_1(FunctionPrototype$1, 'name'); // additional protection from minified / mangled / dropped function names 2248 2249 var PROPER = EXISTS$1 && function something() { 2250 /* empty */ 2251 }.name === 'something'; 2252 2253 var CONFIGURABLE = EXISTS$1 && (!descriptors || descriptors && getDescriptor(FunctionPrototype$1, 'name').configurable); 2254 var functionName = { 2255 EXISTS: EXISTS$1, 2256 PROPER: PROPER, 2257 CONFIGURABLE: CONFIGURABLE 2258 }; 2259 2260 var redefine = createCommonjsModule(function (module) { 2261 var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE; 2262 2263 var getInternalState = internalState.get; 2264 var enforceInternalState = internalState.enforce;
vendor: 4,394 bytes, lines 2265-2393
2265 var TEMPLATE = String(String).split('String'); 2266 (module.exports = function (O, key, value, options) { 2267 var unsafe = options ? !!options.unsafe : false; 2268 var simple = options ? !!options.enumerable : false; 2269 var noTargetGet = options ? !!options.noTargetGet : false; 2270 var name = options && options.name !== undefined ? options.name : key; 2271 var state; 2272 2273 if (isCallable(value)) { 2274 if (String(name).slice(0, 7) === 'Symbol(') { 2275 name = '[' + String(name).replace(/^Symbol\(([^)]*)\)/, '$1') + ']'; 2276 } 2277 2278 if (!hasOwnProperty_1(value, 'name') || CONFIGURABLE_FUNCTION_NAME && value.name !== name) { 2279 createNonEnumerableProperty(value, 'name', name); 2280 } 2281 2282 state = enforceInternalState(value); 2283 2284 if (!state.source) { 2285 state.source = TEMPLATE.join(typeof name == 'string' ? name : ''); 2286 } 2287 } 2288 2289 if (O === global_1) { 2290 if (simple) O[key] = value;else setGlobal(key, value); 2291 return; 2292 } else if (!unsafe) { 2293 delete O[key]; 2294 } else if (!noTargetGet && O[key]) { 2295 simple = true; 2296 } 2297 2298 if (simple) O[key] = value;else createNonEnumerableProperty(O, key, value); // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative 2299 })(Function.prototype, 'toString', function toString() { 2300 return isCallable(this) && getInternalState(this).source || inspectSource(this); 2301 }); 2302 }); 2303 2304 var ceil = Math.ceil; 2305 var floor = Math.floor; // `ToIntegerOrInfinity` abstract operation 2306 // https://tc39.es/ecma262/#sec-tointegerorinfinity 2307 2308 var toIntegerOrInfinity = function (argument) { 2309 var number = +argument; // eslint-disable-next-line no-self-compare -- safe 2310 2311 return number !== number || number === 0 ? 0 : (number > 0 ? floor : ceil)(number); 2312 }; 2313 2314 var max = Math.max; 2315 var min = Math.min; // Helper for a popular repeating case of the spec: 2316 // Let integer be ? ToInteger(index). 2317 // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length). 2318 2319 var toAbsoluteIndex = function (index, length) { 2320 var integer = toIntegerOrInfinity(index); 2321 return integer < 0 ? max(integer + length, 0) : min(integer, length); 2322 }; 2323 2324 var min$1 = Math.min; // `ToLength` abstract operation 2325 // https://tc39.es/ecma262/#sec-tolength 2326 2327 var toLength = function (argument) { 2328 return argument > 0 ? min$1(toIntegerOrInfinity(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991 2329 }; 2330 2331 // `LengthOfArrayLike` abstract operation 2332 // https://tc39.es/ecma262/#sec-lengthofarraylike 2333 2334 2335 var lengthOfArrayLike = function (obj) { 2336 return toLength(obj.length); 2337 }; 2338 2339 // `Array.prototype.{ indexOf, includes }` methods implementation 2340 2341 2342 var createMethod = function (IS_INCLUDES) { 2343 return function ($this, el, fromIndex) { 2344 var O = toIndexedObject($this); 2345 var length = lengthOfArrayLike(O); 2346 var index = toAbsoluteIndex(fromIndex, length); 2347 var value; // Array#includes uses SameValueZero equality algorithm 2348 // eslint-disable-next-line no-self-compare -- NaN check 2349 2350 if (IS_INCLUDES && el != el) while (length > index) { 2351 value = O[index++]; // eslint-disable-next-line no-self-compare -- NaN check 2352 2353 if (value != value) return true; // Array#indexOf ignores holes, Array#includes - not 2354 } else for (; length > index; index++) { 2355 if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0; 2356 } 2357 return !IS_INCLUDES && -1; 2358 }; 2359 }; 2360 2361 var arrayIncludes = { 2362 // `Array.prototype.includes` method 2363 // https://tc39.es/ecma262/#sec-array.prototype.includes 2364 includes: createMethod(true), 2365 // `Array.prototype.indexOf` method 2366 // https://tc39.es/ecma262/#sec-array.prototype.indexof 2367 indexOf: createMethod(false) 2368 }; 2369 2370 var indexOf = arrayIncludes.indexOf; 2371 2372 2373 2374 var push = functionUncurryThis([].push); 2375 2376 var objectKeysInternal = function (object, names) { 2377 var O = toIndexedObject(object); 2378 var i = 0; 2379 var result = []; 2380 var key; 2381 2382 for (key in O) !hasOwnProperty_1(hiddenKeys, key) && hasOwnProperty_1(O, key) && push(result, key); // Don't enum bug & hidden keys 2383 2384 2385 while (names.length > i) if (hasOwnProperty_1(O, key = names[i++])) { 2386 ~indexOf(result, key) || push(result, key); 2387 } 2388 2389 return result; 2390 }; 2391 2392 // IE8- don't enum bug keys 2393 var enumBugKeys = ['constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleStr
2393ing', 'toString', 'valueOf']; 2394 2395 var hiddenKeys$1 = enumBugKeys.concat('length', 'prototype'); // `Object.getOwnPropertyNames` method 2396 // https://tc39.es/ecma262/#sec-object.getownpropertynames 2397 // eslint-disable-next-line es/no-object-getownpropertynames -- safe 2398 2399 var f$3 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { 2400 return objectKeysInternal(O, hiddenKeys$1); 2401 }; 2402 2403 var objectGetOwnPropertyNames = { 2404 f: f$3 2405 }; 2406 2407 // eslint-disable-next-line es/no-object-getownpropertysymbols -- safe 2408 var f$4 = Object.getOwnPropertySymbols; 2409 2410 var objectGetOwnPropertySymbols = { 2411 f: f$4 2412 }; 2413 2414 var concat = functionUncurryThis([].concat); // all object keys, includes non-enumerable and symbols 2415 2416 var ownKeys = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) { 2417 var keys = objectGetOwnPropertyNames.f(anObject(it)); 2418 var getOwnPropertySymbols = objectGetOwnPropertySymbols.f; 2419 return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys; 2420 }; 2421 2422 var copyConstructorProperties = function (target, source) { 2423 var keys = ownKeys(source); 2424 var defineProperty = objectDefineProperty.f; 2425 var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f; 2426 2427 for (var i = 0; i < keys.length; i++) { 2428 var key = keys[i]; 2429 if (!hasOwnProperty_1(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key)); 2430 } 2431 }; 2432 2433 var replacement = /#|\.prototype\./; 2434 2435 var isForced = function (feature, detection) { 2436 var value = data[normalize(feature)]; 2437 return value == POLYFILL ? true : value == NATIVE ? false : isCallable(detection) ? fails(detection) : !!detection; 2438 }; 2439 2440 var normalize = isForced.normalize = function (string) { 2441 return String(string).replace(replacement, '.').toLowerCase(); 2442 }; 2443 2444 var data = isForced.data = {}; 2445 var NATIVE = isForced.NATIVE = 'N'; 2446 var POLYFILL = isForced.POLYFILL = 'P'; 2447 var isForced_1 = isForced; 2448 2449 var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f; 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 /* 2461 options.target - name of the target object 2462 options.global - target is the global object 2463 options.stat - export as static methods of target 2464 options.proto - export as prototype methods of target 2465 options.real - real prototype method for the `pure` version 2466 options.forced - export even if the native feature is available 2467 options.bind - bind methods to the target, required for the `pure` version 2468 options.wrap - wrap constructors to preventing global pollution, required for the `pure` version 2469 options.unsafe - use the simple assignment of property instead of delete + defineProperty 2470 options.sham - add a flag to not completely full polyfills 2471 options.enumerable - export as enumerable property 2472 options.noTargetGet - prevent calling a getter on target 2473 options.name - the .name of the function if it does not match the key 2474 */ 2475 2476 2477 var _export = function (options, source) { 2478 var TARGET = options.target; 2479 var GLOBAL = options.global; 2480 var STATIC = options.stat; 2481 var FORCED, target, key, targetProperty, sourceProperty, descriptor; 2482 2483 if (GLOBAL) { 2484 target = global_1; 2485 } else if (STATIC) { 2486 target = global_1[TARGET] || setGlobal(TARGET, {}); 2487 } else { 2488 target = (global_1[TARGET] || {}).prototype; 2489 } 2490 2491 if (target) for (key in source) { 2492 sourceProperty = source[key]; 2493 2494 if (options.noTargetGet) { 2495 descriptor = getOwnPropertyDescriptor$1(target, key); 2496 targetProperty = descriptor && descriptor.value; 2497 } else targetProperty = target[key]; 2498 2499 FORCED = isForced_1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced); // contained in target 2500 2501 if (!FORCED && targetProperty !== undefined) { 2502 if (typeof sourceProperty == typeof targetProperty) continue; 2503 copyConstructorProperties(sourceProperty, targetProperty); 2504 } // add a flag to not completely full polyfills 2505 2506 2507 if (options.sham || targetProperty && targetProperty.sham) { 2508 createNonEnumerableProperty(sourceProperty, 'sham', true); 2509 } // extend global 2510 2511 2512 redefine(target, key, sourceProperty, options); 2513 } 2514 }; 2515 2516 var correctPrototypeGetter = !fails(function () { 2517 function F() { 2518 /* empty */ 2519 } 2520 2521 F.prototype.constructor = null; // eslint-disable-next-line es/no-object-getprototypeof -- required for testing 2522 2523 return Object.getPrototypeOf(new F()) !== F.prototype; 2524 }); 2525 2526 var IE_PROTO = sharedKey('IE_PROTO'); 2527 var Object$4 = global_1.Object; 2528 var ObjectPrototype = Object$4.prototype; // `Object.getPrototypeOf` method 2529 // https://tc39.es/ecma262/#sec-object.getprototypeof 2530 2531 var objectGetPrototypeOf = correctPrototypeGetter ? Object$4.getPrototypeOf : function (O) { 2532 var object = toObject(O); 2533 if (hasOwnProperty_1(object, IE_PROTO)) return object[IE_PROTO]; 2534 var constructor = object.constructor; 2535 2536 if (isCallable(constructor) && object instanceof constructor) { 2537 return constructor.prototype; 2538 } 2539
2540 return object instanceof Object$4 ? ObjectPrototype : null; 2541 }; 2542 2543 var String$3 = global_1.String; 2544 var TypeError$8 = global_1.TypeError; 2545 2546 var aPossiblePrototype = function (argument) { 2547 if (typeof argument == 'object' || isCallable(argument)) return argument; 2548 throw TypeError$8("Can't set " + String$3(argument) + ' as a prototype'); 2549 }; 2550 2551 /* eslint-disable no-proto -- safe */ 2552 2553 2554 2555 2556 // `Object.setPrototypeOf` method 2557 // https://tc39.es/ecma262/#sec-object.setprototypeof 2558 // Works with __proto__ only. Old v8 can't work with null proto objects. 2559 // eslint-disable-next-line es/no-object-setprototypeof -- safe 2560 2561 2562 var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? function () { 2563 var CORRECT_SETTER = false; 2564 var test = {}; 2565 var setter; 2566 2567 try { 2568 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 2569 setter = functionUncurryThis(Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set); 2570 setter(test, []); 2571 CORRECT_SETTER = test instanceof Array; 2572 } catch (error) { 2573 /* empty */ 2574 } 2575 2576 return function setPrototypeOf(O, proto) { 2577 anObject(O); 2578 aPossiblePrototype(proto); 2579 if (CORRECT_SETTER) setter(O, proto);else O.__proto__ = proto; 2580 return O; 2581 }; 2582 }() : undefined); 2583 2584 // `Object.keys` method 2585 // https://tc39.es/ecma262/#sec-object.keys 2586 // eslint-disable-next-line es/no-object-keys -- safe 2587 2588 2589 var objectKeys = Object.keys || function keys(O) { 2590 return objectKeysInternal(O, enumBugKeys); 2591 }; 2592 2593 // `Object.defineProperties` method 2594 // https://tc39.es/ecma262/#sec-object.defineproperties 2595 // eslint-disable-next-line es/no-object-defineproperties -- safe 2596 2597 2598 var objectDefineProperties = descriptors ? Object.defineProperties : function defineProperties(O, Properties) { 2599 anObject(O); 2600 var props = toIndexedObject(Properties); 2601 var keys = objectKeys(Properties); 2602 var length = keys.length; 2603 var index = 0; 2604 var key; 2605 2606 while (length > index) objectDefineProperty.f(O, key = keys[index++], props[key]); 2607 2608 return O; 2609 }; 2610 2611 var html = getBuiltIn('document', 'documentElement'); 2612 2613 /* global ActiveXObject -- old IE, WSH */ 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 var GT = '>'; 2629 var LT = '<'; 2630 var PROTOTYPE = 'prototype'; 2631 var SCRIPT = 'script'; 2632 var IE_PROTO$1 = sharedKey('IE_PROTO'); 2633 2634 var EmptyConstructor = function () { 2635 /* empty */ 2636 }; 2637 2638 var scriptTag = function (content) { 2639 return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT; 2640 }; // Create object with fake `null` prototype: use ActiveX Object with cleared prototype 2641 2642 2643 var NullProtoObjectViaActiveX = function (activeXDocument) { 2644 activeXDocument.write(scriptTag('')); 2645 activeXDocument.close(); 2646 var temp = activeXDocument.parentWindow.Object; 2647 activeXDocument = null; // avoid memory leak 2648 2649 return temp; 2650 }; // Create object with fake `null` prototype: use iframe Object with cleared prototype 2651 2652 2653 var NullProtoObjectViaIFrame = function () { 2654 // Thrash, waste and sodomy: IE GC bug 2655 var iframe = documentCreateElement('iframe'); 2656 var JS = 'java' + SCRIPT + ':'; 2657 var iframeDocument; 2658 iframe.style.display = 'none'; 2659 html.appendChild(iframe); // https://github.com/zloirock/core-js/issues/475 2660 2661 iframe.src = String(JS); 2662 iframeDocument = iframe.contentWindow.document; 2663 iframeDocument.open(); 2664 iframeDocument.write(scriptTag('document.F=Object')); 2665 iframeDocument.close(); 2666 return iframeDocument.F; 2667 }; // Check for document.domain and active x support 2668 // No need to use active x approach when document.domain is not set 2669 // see https://github.com/es-shims/es5-shim/issues/150 2670 // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346 2671 // avoid IE GC bug 2672 2673 2674 var activeXDocument; 2675 2676 var NullProtoObject = function () { 2677 try { 2678 activeXDocument = new ActiveXObject('htmlfile'); 2679 } catch (error) { 2680 /* ignore */ 2681 } 2682 2683 NullProtoObject = typeof document != 'undefined' ? document.domain && activeXDocument ? NullProtoObjectViaActiveX(activeXDocument) // old IE 2684 : NullProtoObjectViaIFrame() : NullProtoObjectViaActiveX(activeXDocument); // WSH 2685 2686 var length = enumBugKeys.length; 2687 2688 while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]]; 2689 2690 return NullProtoObject(); 2691 }; 2692 2693 hiddenKeys[IE_PROTO$1] = true; // `Object.create` method 2694 // https://tc39.es/ecma262/#sec-object.create 2695 2696 var objectCreate = Object.create || function create(O, Properties) { 2697 var result; 2698 2699 if (O !== null) { 2700 EmptyConstructor[PROTOTYPE] = anObject(O); 2701 result = new EmptyConstructor(); 2702 EmptyConstructor[PROTOTYPE] = null; // add "__proto__" for Object.getPrototypeOf polyfill 2703 2704 result[IE_PROTO$1] = O; 2705 } else result = NullProtoObject(); 2706 2707 return Properties === undefined ? result : objectDefineProperties(result, Properties); 2708 }; 2709 2710 var createProperty = function (object, key, value) { 2711 var propertyKey = toPropertyKey(key); 2712 if (propertyKey in object) objectDefineProperty.f(object, propertyKey, createPropertyDescriptor(0, value));else object[propertyKey] = value; 2713 }; 2714 2715 var Array$1 = global_1.Array; 2716 var max$1 = Math.max; 2717 2718 var arraySliceSimple = function (O, start, end) { 2719 var length = lengthOfArrayLike(O); 2720 var k = toAbsoluteIndex(start, length); 2721 var fin = toAbsoluteIndex(end === undefined ? length : end, length); 2722 var result = Array$1(max$1(fin - k, 0)); 2723 2724 for (var n = 0; k < fin; k++, n++) createProperty(result, n, O[k]); 2725 2726 result.length = n; 2727 return result; 2728 }; 2729 2730 var replace = functionUncurryThis(''.replace); 2731 var split$1 = functionUncurryThis(''.split); 2732 var join = functionUncurryThis([].join); 2733 2734 var TEST = function (arg) { 2735 return String(Error(arg).stack); 2736 }('zxcasd'); 2737 2738 var V8_OR_CHAKRA_STACK_ENTRY = /\n\s*at [^:]*:[^\n]*/; 2739 var IS_V8_OR_CHAKRA_STACK = V8_OR_CHAKRA_STACK_ENTRY.test(TEST); 2740 var IS_FIREFOX_OR_SAFARI_STACK = /@[^\n]*\n/.test(TEST) && !/zxcasd/.test(TEST); 2741 2742 var clearErrorStack = function (stack, dropEntries) { 2743 if (typeof stack != 'string') return stack; 2744 2745 if (IS_V8_OR_CHAKRA_STACK) { 2746 while (dropEntries--) stack = replace(stack, V8_OR_CHAKRA_STACK_ENTRY, ''); 2747 }
2747 else if (IS_FIREFOX_OR_SAFARI_STACK) { 2748 return join(arraySliceSimple(split$1(stack, '\n'), dropEntries), '\n'); 2749 } 2750 2751 return stack; 2752 }; 2753 2754 // `InstallErrorCause` abstract operation 2755 // https://tc39.es/proposal-error-cause/#sec-errorobjects-install-error-cause 2756 2757 2758 var installErrorCause = function (O, options) { 2759 if (isObject(options) && 'cause' in options) { 2760 createNonEnumerableProperty(O, 'cause', options.cause); 2761 } 2762 }; 2763 2764 var bind$1 = functionUncurryThis(functionUncurryThis.bind); // optional / simple context binding 2765 2766 var functionBindContext = function (fn, that) { 2767 aCallable(fn); 2768 return that === undefined ? fn : bind$1 ? bind$1(fn, that) : function () 2769 /* ...args */ 2770 { 2771 return fn.apply(that, arguments); 2772 }; 2773 }; 2774 2775 var iterators = {}; 2776 2777 var ITERATOR = wellKnownSymbol('iterator'); 2778 var ArrayPrototype = Array.prototype; // check on default Array iterator 2779 2780 var isArrayIteratorMethod = function (it) { 2781 return it !== undefined && (iterators.Array === it || ArrayPrototype[ITERATOR] === it); 2782 }; 2783 2784 var TO_STRING_TAG = wellKnownSymbol('toStringTag'); 2785 var test = {}; 2786 test[TO_STRING_TAG] = 'z'; 2787 var toStringTagSupport = String(test) === '[object z]'; 2788 2789 var TO_STRING_TAG$1 = wellKnownSymbol('toStringTag'); 2790 var Object$5 = global_1.Object; // ES3 wrong here 2791 2792 var CORRECT_ARGUMENTS = classofRaw(function () { 2793 return arguments; 2794 }()) == 'Arguments'; // fallback for IE11 Script Access Denied error 2795 2796 var tryGet = function (it, key) { 2797 try { 2798 return it[key]; 2799 } catch (error) { 2800 /* empty */ 2801 } 2802 }; // getting tag from ES6+ `Object.prototype.toString` 2803 2804 2805 var classof = toStringTagSupport ? classofRaw : function (it) { 2806 var O, tag, result; 2807 return it === undefined ? 'Undefined' : it === null ? 'Null' // @@toStringTag case 2808 : typeof (tag = tryGet(O = Object$5(it), TO_STRING_TAG$1)) == 'string' ? tag // builtinTag case 2809 : CORRECT_ARGUMENTS ? classofRaw(O) // ES3 arguments fallback 2810 : (result = classofRaw(O)) == 'Object' && isCallable(O.callee) ? 'Arguments' : result; 2811 }; 2812 2813 var ITERATOR$1 = wellKnownSymbol('iterator'); 2814 2815 var getIteratorMethod = function (it) { 2816 if (it != undefined) return getMethod(it, ITERATOR$1) || getMethod(it, '@@iterator') || iterators[classof(it)]; 2817 }; 2818 2819 var TypeError$9 = global_1.TypeError; 2820 2821 var getIterator = function (argument, usingIterator) { 2822 var iteratorMethod = arguments.length < 2 ? getIteratorMethod(argument) : usingIterator; 2823 if (aCallable(iteratorMethod)) return anObject(functionCall(iteratorMethod, argument)); 2824 throw TypeError$9(tryToString(argument) + ' is not iterable'); 2825 }; 2826 2827 var iteratorClose = function (iterator, kind, value) { 2828 var innerResult, innerError; 2829 anObject(iterator); 2830 2831 try { 2832 innerResult = getMethod(iterator, 'return'); 2833 2834 if (!innerResult) { 2835 if (kind === 'throw') throw value; 2836 return value; 2837 } 2838 2839 innerResult = functionCall(innerResult, iterator); 2840 } catch (error) { 2841 innerError = true; 2842 innerResult = error; 2843 } 2844 2845 if (kind === 'throw') throw value; 2846 if (innerError) throw innerResult; 2847 anObject(innerResult); 2848 return value; 2849 }; 2850 2851 var TypeError$a = global_1.TypeError; 2852 2853 var Result = function (stopped, result) { 2854 this.stopped = stopped; 2855 this.result = result; 2856 }; 2857 2858 var ResultPrototype = Result.prototype; 2859 2860 var iterate = function (iterable, unboundFunction, options) { 2861 var that = options && options.that; 2862 var AS_ENTRIES = !!(options && options.AS_ENTRIES); 2863 var IS_ITERATOR = !!(options && options.IS_ITERATOR); 2864 var INTERRUPTED = !!(options && options.INTERRUPTED); 2865 var fn = functionBindContext(unboundFunction, that); 2866 var iterator, iterFn, index, length, result, next, step; 2867 2868 var stop = function (condition) { 2869 if (iterator) iteratorClose(iterator, 'normal', condition); 2870 return new Result(true, condition); 2871 }; 2872 2873 var callFn = function (value) { 2874 if (AS_ENTRIES) { 2875 anObject(value); 2876 return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]); 2877 } 2878 2879 return INTERRUPTED ? fn(value, stop) : fn(value); 2880 }; 2881 2882 if (IS_ITERATOR) { 2883 iterator = iterable; 2884 } else { 2885 iterFn = getIteratorMethod(iterable); 2886 if (!iterFn) throw TypeError$a(tryToString(iterable) + ' is not iterable'); // optimisation for array iterators 2887 2888 if (isArrayIteratorMethod(iterFn)) { 2889 for (index = 0, length = lengthOfArrayLike(iterable); length > index; index++) { 2890 result = callFn(iterable[index]); 2891 if (result && objectIsPrototypeOf(ResultPrototype, result)) return result; 2892 } 2893 2894 return new Result(false); 2895 } 2896 2897 iterator = getIterator(iterable, iterFn); 2898 } 2899 2900 next = iterator.next; 2901 2902 while (!(step = functionCall(next, iterator)).done) { 2903 try { 2904 result = callFn(step.value); 2905 } catch (error) { 2906 iteratorClose(iterator, 'throw', error); 2907 } 2908 2909 if (typeof result == 'object' && result && objectIsPrototypeOf(ResultPrototype, result)) return result; 2910 } 2911 2912 return new Result(false); 2913 }; 2914 2915 var String$4 = global_1.String; 2916 2917 var toString_1 = function (argument) { 2918 if (classof(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string'); 2919 return String$4(argument); 2920 }; 2921 2922 var normalizeStringArgument = function (argument, $default) { 2923 return argument === undefined ? arguments.length < 2 ? '' : $default : toString_1(argument); 2924 }; 2925 2926 var errorStackInstallable = !fails(function () { 2927 var error = Error('a'); 2928 if (!('stack' in error)) return true; // eslint-disable-next-line es/no-object-defineproperty -- safe 2929 2930 Object.defineProperty(error, 'stack', createPropertyDescriptor(1, 7)); 2931 return error.stack !== 7; 2932 }); 2933 2934 var TO_STRING_TAG$2 = wellKnownSymbol('toStringTag'); 2935 var Error$1 = global_1.Error; 2936 var push$1 = [].push; 2937 2938 var $AggregateError = function AggregateError(errors, message 2939 /* , options */ 2940 ) { 2941 var options = arguments.length > 2 ? arguments[2] : undefined; 2942 var isInstance = objectIsPrototypeOf(AggregateErrorPrototype, this); 2943 var that; 2944 2945 if (objectSetPrototypeOf) { 2946 that = objectSetPrototypeOf(new Error$1(undefined), isInstance ? objectGetPrototypeOf(this) : AggregateErrorPrototype); 2947 } else { 2948 that = isInstance ? this : objectCreate(AggregateErrorPrototype); 2949 createNonEnumerableProperty(that, TO_STRING_TAG$2, 'Error'); 2950 } 2951 2952 createNonEnumerableProperty(that, 'message', normalizeStringArgument(message, '')); 2953 if (errorStackInstallable) createNonEnumerableProperty(that, 'stack', clearErrorStack(that.stack, 1)); 2954 installErrorCause(that, options); 2955 var errorsArray = []; 2956 iterate(errors, push$1, { 2957 that: errorsArray 2958 }); 2959 createNonEnumerableProperty(that, 'errors', errorsArray); 2960 return that; 2961 }; 2962 2963 if (objectSetPrototypeOf) objectSetPrototypeOf($AggregateError, Error$1);else copyConstructorProperties($AggregateError, Error$1); 2964 var AggregateErrorPrototype = $AggregateError.prototype = objectCreate(Error$1.prototype, { 2965 constructor: createPropertyDescriptor(1, $AggregateError), 2966 message: createPropertyDescriptor(1, ''), 2967 name: createPropertyDescriptor(1, 'AggregateError') 2968 }); // `AggregateError` constructor 2969 // https://tc39.es/ecma262/#sec-aggregate-error-constructor 2970 2971 _export({ 2972 global: true 2973 }, { 2974 AggregateError: $AggregateError 2975 }); 2976 2977 var UNSCOPABLES = wellKnownSymbol('unscopables'); 2978 var ArrayPrototype$1 = Array.prototype; // Array.prototype[@@unscopables] 2979 // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables 2980 2981 if (ArrayPrototype$1[UNSCOPABLES] == undefined) { 2982 objectDefineProperty.f(ArrayPrototype$1, UNSCOPABLES, { 2983 configurable: true, 2984 value: objectCreate(null) 2985 }); 2986 } // add a key to Array.prototype[@@unscopables] 2987 2988 2989 var addToUnscopables = function (key) { 2990 ArrayPrototype$1[UNSCOPABLES][key] = true; 2991 }; 2992 2993 // `Array.prototype.at` method 2994 // https://github.com/tc39/proposal-relative-indexing-method 2995 2996 2997 _export({ 2998 target: 'Array', 2999 proto: true 3000 }, { 3001 at: function at(index) { 3002 var O = toObject(this); 3003 var len = lengthOfArrayLike(O); 3004 var relativeIndex = toIntegerOrInfinity(index); 3005 var k = relativeIndex >= 0 ? relativeIndex : len + relativeIndex; 3006 return k < 0 || k >= len ? undefined : O[k]; 3007 } 3008 }); 3009 addToUnscopables('at'); 3010 3011 // `IsArray` abstract operation 3012 // https://tc39.es/ecma262/#sec-isarray 3013 // eslint-disable-next-line es/no-array-isarray -- safe 3014 3015 3016 var isArray = Array.isArray || function isArray(argument) { 3017 return classofRaw(argument) == 'Array'; 3018 }; 3019 3020 var un$Reverse = functionUncurryThis([].reverse); 3021 var test$1 = [1, 2]; // `Array.prototype.reverse` method 3022 // https://tc39.es/ecma262/#sec-array.prototype.reverse 3023 // fix for Safari 12.0 bug 3024 // https://bugs.webkit.org/show_bug.cgi?id=188794 3025 3026 _export({ 3027 target: 'Array', 3028 proto: true, 3029 forced: String(test$1) === String(test$1.reverse()) 3030 }, { 3031 reverse: function reverse() { 3032 // eslint-disable-next-line no-self-assign -- dirty hack 3033 if (isArray(this)) this.length = this.length; 3034 return un$Reverse(this); 3035 } 3036 }); 3037 3038 // eslint-disable-next-line es/no-typed-arrays -- safe 3039 var arrayBufferNative = typeof ArrayBuffer != 'undefined' && typeof DataView != 'undefined'; 3040 3041 var redefineAll = function (target, src, options) { 3042 for (var key in src) redefine(target, key, src[key], options); 3043 3044 return target; 3045 }; 3046 3047 var TypeError$b = global_1.TypeError; 3048 3049 var anInstance = function (it, Prototype) { 3050 if (objectIsPrototypeOf(Prototype, it)) return it; 3051 throw TypeError$b('Incorrect invocation'); 3052 }; 3053 3054 var RangeError = global_1.RangeError; // `ToIndex` abstract operation 3055 // https://tc39.es/ecma262/#sec-toindex 3056 3057 var toIndex = function (it) { 3058 if (it === undefined) return 0; 3059 var number = toIntegerOrInfinity(it); 3060 var length = toLength(number); 3061 if (number !== length) throw RangeError('Wrong length or index'); 3062 return length; 3063 }; 3064 3065 // IEEE754 conversions based on https://github.com/feross/ieee754 3066 3067 3068 var Array$2 = global_1.Array; 3069 var abs = Math.abs; 3070 var pow = Math.pow; 3071 var floor$1 = Math.floor; 3072 var log = Math.log; 3073 var LN2 = Math.LN2; 3074 3075 var pack = function (number, mantissaLength, bytes) { 3076 var buffer = Array$2(bytes); 3077 var exponentLength = bytes * 8 - mantissaLength - 1; 3078 var eMax = (1 << exponentLength) - 1; 3079 var eBias = eMax >> 1; 3080 var rt = mantissaLength === 23 ? pow(2, -24) - pow(2, -77) : 0; 3081 var sign = number < 0 || number === 0 && 1 / number < 0 ? 1 : 0; 3082 var index = 0; 3083 var exponent, mantissa, c; 3084 number = abs(number); // eslint-disable-next-line no-self-compare -- NaN check 3085 3086 if (number != number || number === Infinity) { 3087 // eslint-disable-next-line no-self-compare -- NaN check 3088 mantissa = number != number ? 1 : 0; 3089 exponent = eMax; 3090 } else { 3091 exponent = floor$1(log(number) / LN2); 3092 c = pow(2, -exponent); 3093 3094 if (number * c < 1) { 3095 exponent--; 3096 c *= 2; 3097 } 3098 3099 if (exponent + eBias >= 1) { 3100 number += rt / c; 3101 } else { 3102 number += rt * pow(2, 1 - eBias); 3103 } 3104 3105 if (number * c >= 2) { 3106 exponent++; 3107 c /= 2; 3108 } 3109 3110 if (exponent + eBias >= eMax) { 3111 mantissa = 0; 3112 exponent = eMax; 3113 } else if (exponent + eBias >= 1) { 3114 mantissa = (number * c - 1) * pow(2, mantissaLength); 3115 exponent = exponent + eBias; 3116 } else { 3117 mantissa = number * pow(2, eBias - 1) * pow(2, mantissaLength); 3118 exponent = 0; 3119 } 3120 } 3121 3122 while (mantissaLength >= 8) { 3123 buffer[index++] = mantissa & 255; 3124 mantissa /= 256; 3125 mantissaLength -= 8; 3126 } 3127 3128 exponent = exponent << mantissaLength | mantissa; 3129 exponentLength += mantissaLength; 3130 3131 while (exponentLength > 0) { 3132 buffer[index++] = exponent & 255; 3133 exponent /= 256; 3134 exponentLength -= 8; 3135 } 3136 3137 buffer[--index] |= sign * 128; 3138 return buffer; 3139 }; 3140 3141 var unpack = function (buffer, mantissaLength) { 3142 var bytes = buffer.length; 3143 var exponentLength = bytes * 8 - mantissaLength - 1; 3144 var eMax = (1 << exponentLength) - 1; 3145 var eBias = eMax >> 1;
vendor: 6,238 bytes, lines 3146-3360
3146 var nBits = exponentLength - 7; 3147 var index = bytes - 1; 3148 var sign = buffer[index--]; 3149 var exponent = sign & 127; 3150 var mantissa; 3151 sign >>= 7; 3152 3153 while (nBits > 0) { 3154 exponent = exponent * 256 + buffer[index--]; 3155 nBits -= 8; 3156 } 3157 3158 mantissa = exponent & (1 << -nBits) - 1; 3159 exponent >>= -nBits; 3160 nBits += mantissaLength; 3161 3162 while (nBits > 0) { 3163 mantissa = mantissa * 256 + buffer[index--]; 3164 nBits -= 8; 3165 } 3166 3167 if (exponent === 0) { 3168 exponent = 1 - eBias; 3169 } else if (exponent === eMax) { 3170 return mantissa ? NaN : sign ? -Infinity : Infinity; 3171 } else { 3172 mantissa = mantissa + pow(2, mantissaLength); 3173 exponent = exponent - eBias; 3174 } 3175 3176 return (sign ? -1 : 1) * mantissa * pow(2, exponent - mantissaLength); 3177 }; 3178 3179 var ieee754 = { 3180 pack: pack, 3181 unpack: unpack 3182 }; 3183 3184 // `Array.prototype.fill` method implementation 3185 // https://tc39.es/ecma262/#sec-array.prototype.fill 3186 3187 3188 var arrayFill = function fill(value 3189 /* , start = 0, end = @length */ 3190 ) { 3191 var O = toObject(this); 3192 var length = lengthOfArrayLike(O); 3193 var argumentsLength = arguments.length; 3194 var index = toAbsoluteIndex(argumentsLength > 1 ? arguments[1] : undefined, length); 3195 var end = argumentsLength > 2 ? arguments[2] : undefined; 3196 var endPos = end === undefined ? length : toAbsoluteIndex(end, length); 3197 3198 while (endPos > index) O[index++] = value; 3199 3200 return O; 3201 }; 3202 3203 var defineProperty$1 = objectDefineProperty.f; 3204 3205 3206 3207 3208 3209 var TO_STRING_TAG$3 = wellKnownSymbol('toStringTag'); 3210 3211 var setToStringTag = function (it, TAG, STATIC) { 3212 if (it && !hasOwnProperty_1(it = STATIC ? it : it.prototype, TO_STRING_TAG$3)) { 3213 defineProperty$1(it, TO_STRING_TAG$3, { 3214 configurable: true, 3215 value: TAG 3216 }); 3217 } 3218 }; 3219 3220 var getOwnPropertyNames = objectGetOwnPropertyNames.f; 3221 3222 var defineProperty$2 = objectDefineProperty.f; 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 var PROPER_FUNCTION_NAME = functionName.PROPER; 3233 var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE; 3234 var getInternalState = internalState.get; 3235 var setInternalState = internalState.set; 3236 var ARRAY_BUFFER = 'ArrayBuffer'; 3237 var DATA_VIEW = 'DataView'; 3238 var PROTOTYPE$1 = 'prototype'; 3239 var WRONG_LENGTH = 'Wrong length'; 3240 var WRONG_INDEX = 'Wrong index'; 3241 var NativeArrayBuffer = global_1[ARRAY_BUFFER]; 3242 var $ArrayBuffer = NativeArrayBuffer; 3243 var ArrayBufferPrototype = $ArrayBuffer && $ArrayBuffer[PROTOTYPE$1]; 3244 var $DataView = global_1[DATA_VIEW]; 3245 var DataViewPrototype = $DataView && $DataView[PROTOTYPE$1]; 3246 var ObjectPrototype$1 = Object.prototype; 3247 var Array$3 = global_1.Array; 3248 var RangeError$1 = global_1.RangeError; 3249 var fill = functionUncurryThis(arrayFill); 3250 var reverse = functionUncurryThis([].reverse); 3251 var packIEEE754 = ieee754.pack; 3252 var unpackIEEE754 = ieee754.unpack; 3253 3254 var packInt8 = function (number) { 3255 return [number & 0xFF]; 3256 }; 3257 3258 var packInt16 = function (number) { 3259 return [number & 0xFF, number >> 8 & 0xFF]; 3260 }; 3261 3262 var packInt32 = function (number) { 3263 return [number & 0xFF, number >> 8 & 0xFF, number >> 16 & 0xFF, number >> 24 & 0xFF]; 3264 }; 3265 3266 var unpackInt32 = function (buffer) { 3267 return buffer[3] << 24 | buffer[2] << 16 | buffer[1] << 8 | buffer[0]; 3268 }; 3269 3270 var packFloat32 = function (number) { 3271 return packIEEE754(number, 23, 4); 3272 }; 3273 3274 var packFloat64 = function (number) { 3275 return packIEEE754(number, 52, 8); 3276 }; 3277 3278 var addGetter = function (Constructor, key) { 3279 defineProperty$2(Constructor[PROTOTYPE$1], key, { 3280 get: function () { 3281 return getInternalState(this)[key]; 3282 } 3283 }); 3284 }; 3285 3286 var get$1 = function (view, count, index, isLittleEndian) { 3287 var intIndex = toIndex(index); 3288 var store = getInternalState(view); 3289 if (intIndex + count > store.byteLength) throw RangeError$1(WRONG_INDEX); 3290 var bytes = getInternalState(store.buffer).bytes; 3291 var start = intIndex + store.byteOffset; 3292 var pack = arraySliceSimple(bytes, start, start + count); 3293 return isLittleEndian ? pack : reverse(pack); 3294 }; 3295 3296 var set$1 = function (view, count, index, conversion, value, isLittleEndian) { 3297 var intIndex = toIndex(index); 3298 var store = getInternalState(view); 3299 if (intIndex + count > store.byteLength) throw RangeError$1(WRONG_INDEX); 3300 var bytes = getInternalState(store.buffer).bytes; 3301 var start = intIndex + store.byteOffset; 3302 var pack = conversion(+value); 3303 3304 for (var i = 0; i < count; i++) bytes[start + i] = pack[isLittleEndian ? i : count - i - 1]; 3305 }; 3306 3307 if (!arrayBufferNative) { 3308 $ArrayBuffer = function ArrayBuffer(length) { 3309 anInstance(this, ArrayBufferPrototype); 3310 var byteLength = toIndex(length); 3311 setInternalState(this, { 3312 bytes: fill(Array$3(byteLength), 0), 3313 byteLength: byteLength 3314 }); 3315 if (!descriptors) this.byteLength = byteLength; 3316 }; 3317 3318 ArrayBufferPrototype = $ArrayBuffer[PROTOTYPE$1]; 3319 3320 $DataView = function DataView(buffer, byteOffset, byteLength) { 3321 anInstance(this, DataViewPrototype); 3322 anInstance(buffer, ArrayBufferPrototype); 3323 var bufferLength = getInternalState(buffer).byteLength; 3324 var offset = toIntegerOrInfinity(byteOffset); 3325 if (offset < 0 || offset > bufferLength) throw RangeError$1('Wrong offset'); 3326 byteLength = byteLength === undefined ? bufferLength - offset : toLength(byteLength); 3327 if (offset + byteLength > bufferLength) throw RangeError$1(WRONG_LENGTH); 3328 setInternalState(this, { 3329 buffer: buffer, 3330 byteLength: byteLength, 3331 byteOffset: offset 3332 }); 3333 3334 if (!descriptors) { 3335 this.buffer = buffer; 3336 this.byteLength = byteLength; 3337 this.byteOffset = offset; 3338 } 3339 }; 3340 3341 DataViewPrototype = $DataView[PROTOTYPE$1]; 3342 3343 if (descriptors) { 3344 addGetter($ArrayBuffer, 'byteLength'); 3345 addGetter($DataView, 'buffer'); 3346 addGetter($DataView, 'byteLength'); 3347 addGetter($DataView, 'byteOffset'); 3348 } 3349 3350 redefineAll(DataViewPrototype, { 3351 getInt8: function getInt8(byteOffset) { 3352 return get$1(this, 1, byteOffset)[0] << 24 >> 24; 3353 }, 3354 getUint8: function getUint8(byteOffset) { 3355 return get$1(this, 1, byteOffset)[0]; 3356 }, 3357 getInt16: function getInt16(byteOffset 3358 /* , littleEndian */ 3359 ) { 3360 var bytes = get$1(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : undefined);
vendor: 5,073 bytes, lines 3361-3499
3361 return (bytes[1] << 8 | bytes[0]) << 16 >> 16; 3362 }, 3363 getUint16: function getUint16(byteOffset 3364 /* , littleEndian */ 3365 ) { 3366 var bytes = get$1(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : undefined); 3367 return bytes[1] << 8 | bytes[0]; 3368 }, 3369 getInt32: function getInt32(byteOffset 3370 /* , littleEndian */ 3371 ) { 3372 return unpackInt32(get$1(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined)); 3373 }, 3374 getUint32: function getUint32(byteOffset 3375 /* , littleEndian */ 3376 ) { 3377 return unpackInt32(get$1(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined)) >>> 0; 3378 }, 3379 getFloat32: function getFloat32(byteOffset 3380 /* , littleEndian */ 3381 ) { 3382 return unpackIEEE754(get$1(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined), 23); 3383 }, 3384 getFloat64: function getFloat64(byteOffset 3385 /* , littleEndian */ 3386 ) { 3387 return unpackIEEE754(get$1(this, 8, byteOffset, arguments.length > 1 ? arguments[1] : undefined), 52); 3388 }, 3389 setInt8: function setInt8(byteOffset, value) { 3390 set$1(this, 1, byteOffset, packInt8, value); 3391 }, 3392 setUint8: function setUint8(byteOffset, value) { 3393 set$1(this, 1, byteOffset, packInt8, value); 3394 }, 3395 setInt16: function setInt16(byteOffset, value 3396 /* , littleEndian */ 3397 ) { 3398 set$1(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : undefined); 3399 }, 3400 setUint16: function setUint16(byteOffset, value 3401 /* , littleEndian */ 3402 ) { 3403 set$1(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : undefined); 3404 }, 3405 setInt32: function setInt32(byteOffset, value 3406 /* , littleEndian */ 3407 ) { 3408 set$1(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : undefined); 3409 }, 3410 setUint32: function setUint32(byteOffset, value 3411 /* , littleEndian */ 3412 ) { 3413 set$1(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : undefined); 3414 }, 3415 setFloat32: function setFloat32(byteOffset, value 3416 /* , littleEndian */ 3417 ) { 3418 set$1(this, 4, byteOffset, packFloat32, value, arguments.length > 2 ? arguments[2] : undefined); 3419 }, 3420 setFloat64: function setFloat64(byteOffset, value 3421 /* , littleEndian */ 3422 ) { 3423 set$1(this, 8, byteOffset, packFloat64, value, arguments.length > 2 ? arguments[2] : undefined); 3424 } 3425 }); 3426 } else { 3427 var INCORRECT_ARRAY_BUFFER_NAME = PROPER_FUNCTION_NAME && NativeArrayBuffer.name !== ARRAY_BUFFER; 3428 /* eslint-disable no-new -- required for testing */ 3429 3430 if (!fails(function () { 3431 NativeArrayBuffer(1); 3432 }) || !fails(function () { 3433 new NativeArrayBuffer(-1); 3434 }) || fails(function () { 3435 new NativeArrayBuffer(); 3436 new NativeArrayBuffer(1.5); 3437 new NativeArrayBuffer(NaN); 3438 return INCORRECT_ARRAY_BUFFER_NAME && !CONFIGURABLE_FUNCTION_NAME; 3439 })) { 3440 /* eslint-enable no-new -- required for testing */ 3441 $ArrayBuffer = function ArrayBuffer(length) { 3442 anInstance(this, ArrayBufferPrototype); 3443 return new NativeArrayBuffer(toIndex(length)); 3444 }; 3445 3446 $ArrayBuffer[PROTOTYPE$1] = ArrayBufferPrototype; 3447 3448 for (var keys$1 = getOwnPropertyNames(NativeArrayBuffer), j = 0, key; keys$1.length > j;) { 3449 if (!((key = keys$1[j++]) in $ArrayBuffer)) { 3450 createNonEnumerableProperty($ArrayBuffer, key, NativeArrayBuffer[key]); 3451 } 3452 } 3453 3454 ArrayBufferPrototype.constructor = $ArrayBuffer; 3455 } else if (INCORRECT_ARRAY_BUFFER_NAME && CONFIGURABLE_FUNCTION_NAME) { 3456 createNonEnumerableProperty(NativeArrayBuffer, 'name', ARRAY_BUFFER); 3457 } // WebKit bug - the same parent prototype for typed arrays and data view 3458 3459 3460 if (objectSetPrototypeOf && objectGetPrototypeOf(DataViewPrototype) !== ObjectPrototype$1) { 3461 objectSetPrototypeOf(DataViewPrototype, ObjectPrototype$1); 3462 } // iOS Safari 7.x bug 3463 3464 3465 var testView = new $DataView(new $ArrayBuffer(2)); 3466 var $setInt8 = functionUncurryThis(DataViewPrototype.setInt8); 3467 testView.setInt8(0, 2147483648); 3468 testView.setInt8(1, 2147483649); 3469 if (testView.getInt8(0) || !testView.getInt8(1)) redefineAll(DataViewPrototype, { 3470 setInt8: function setInt8(byteOffset, value) { 3471 $setInt8(this, byteOffset, value << 24 >> 24); 3472 }, 3473 setUint8: function setUint8(byteOffset, value) { 3474 $setInt8(this, byteOffset, value << 24 >> 24); 3475 } 3476 }, { 3477 unsafe: true 3478 }); 3479 } 3480 3481 setToStringTag($ArrayBuffer, ARRAY_BUFFER); 3482 setToStringTag($DataView, DATA_VIEW); 3483 var arrayBuffer = { 3484 ArrayBuffer: $ArrayBuffer, 3485 DataView: $DataView 3486 }; 3487 3488 var noop = function () { 3489 /* empty */ 3490 }; 3491 3492 var empty = []; 3493 var construct = getBuiltIn('Reflect', 'construct'); 3494 var constructorRegExp = /^\s*(?:class|function)\b/; 3495 var exec = functionUncurryThis(constructorRegExp.exec); 3496 var INCORRECT_TO_STRING = !constructorRegExp.exec(noop); 3497 3498 var isConstructorModern = function (argument) { 3499 if (!isCallable(argument)) return false;
3500 3501 try { 3502 construct(noop, empty, argument); 3503 return true; 3504 } catch (error) { 3505 return false; 3506 } 3507 }; 3508 3509 var isConstructorLegacy = function (argument) { 3510 if (!isCallable(argument)) return false; 3511 3512 switch (classof(argument)) { 3513 case 'AsyncFunction': 3514 case 'GeneratorFunction': 3515 case 'AsyncGeneratorFunction': 3516 return false; 3517 // we can't check .prototype since constructors produced by .bind haven't it 3518 } 3519 3520 return INCORRECT_TO_STRING || !!exec(constructorRegExp, inspectSource(argument)); 3521 }; // `IsConstructor` abstract operation 3522 // https://tc39.es/ecma262/#sec-isconstructor 3523 3524 3525 var isConstructor = !construct || fails(function () { 3526 var called; 3527 return isConstructorModern(isConstructorModern.call) || !isConstructorModern(Object) || !isConstructorModern(function () { 3528 called = true; 3529 }) || called; 3530 }) ? isConstructorLegacy : isConstructorModern; 3531 3532 var TypeError$c = global_1.TypeError; // `Assert: IsConstructor(argument) is true` 3533 3534 var aConstructor = function (argument) { 3535 if (isConstructor(argument)) return argument; 3536 throw TypeError$c(tryToString(argument) + ' is not a constructor'); 3537 }; 3538 3539 var SPECIES = wellKnownSymbol('species'); // `SpeciesConstructor` abstract operation 3540 // https://tc39.es/ecma262/#sec-speciesconstructor 3541 3542 var speciesConstructor = function (O, defaultConstructor) { 3543 var C = anObject(O).constructor; 3544 var S; 3545 return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? defaultConstructor : aConstructor(S); 3546 }; 3547 3548 var ArrayBuffer$1 = arrayBuffer.ArrayBuffer; 3549 var DataView$1 = arrayBuffer.DataView; 3550 var DataViewPrototype$1 = DataView$1.prototype; 3551 var un$ArrayBufferSlice = functionUncurryThis(ArrayBuffer$1.prototype.slice); 3552 var getUint8 = functionUncurryThis(DataViewPrototype$1.getUint8); 3553 var setUint8 = functionUncurryThis(DataViewPrototype$1.setUint8); 3554 var INCORRECT_SLICE = fails(function () { 3555 return !new ArrayBuffer$1(2).slice(1, undefined).byteLength; 3556 }); // `ArrayBuffer.prototype.slice` method 3557 // https://tc39.es/ecma262/#sec-arraybuffer.prototype.slice 3558 3559 _export({ 3560 target: 'ArrayBuffer', 3561 proto: true, 3562 unsafe: true, 3563 forced: INCORRECT_SLICE 3564 }, { 3565 slice: function slice(start, end) { 3566 if (un$ArrayBufferSlice && end === undefined) { 3567 return un$ArrayBufferSlice(anObject(this), start); // FF fix 3568 } 3569 3570 var length = anObject(this).byteLength; 3571 var first = toAbsoluteIndex(start, length); 3572 var fin = toAbsoluteIndex(end === undefined ? length : end, length); 3573 var result = new (speciesConstructor(this, ArrayBuffer$1))(toLength(fin - first)); 3574 var viewSource = new DataView$1(this); 3575 var viewTarget = new DataView$1(result); 3576 var index = 0; 3577 3578 while (first < fin) { 3579 setUint8(viewTarget, index++, getUint8(viewSource, first++)); 3580 } 3581 3582 return result; 3583 } 3584 }); 3585 3586 // `Object.fromEntries` method 3587 // https://github.com/tc39/proposal-object-from-entries 3588 3589 3590 _export({ 3591 target: 'Object', 3592 stat: true 3593 }, { 3594 fromEntries: function fromEntries(iterable) { 3595 var obj = {}; 3596 iterate(iterable, function (k, v) { 3597 createProperty(obj, k, v); 3598 }, { 3599 AS_ENTRIES: true 3600 }); 3601 return obj; 3602 } 3603 }); 3604 3605 // `Object.hasOwn` method 3606 // https://github.com/tc39/proposal-accessible-object-hasownproperty 3607 3608 3609 _export({ 3610 target: 'Object', 3611 stat: true 3612 }, { 3613 hasOwn: hasOwnProperty_1 3614 }); 3615 3616 var PromiseCapability = function (C) { 3617 var resolve, reject; 3618 this.promise = new C(function ($$resolve, $$reject) { 3619 if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor'); 3620 resolve = $$resolve; 3621 reject = $$reject; 3622 }); 3623 this.resolve = aCallable(resolve); 3624 this.reject = aCallable(reject); 3625 }; // `NewPromiseCapability` abstract operation 3626 // https://tc39.es/ecma262/#sec-newpromisecapability 3627 3628 3629 var f$5 = function (C) { 3630 return new PromiseCapability(C); 3631 }; 3632 3633 var newPromiseCapability = { 3634 f: f$5 3635 }; 3636 3637 var perform = function (exec) { 3638 try { 3639 return { 3640 error: false, 3641 value: exec() 3642 }; 3643 } catch (error) { 3644 return { 3645 error: true, 3646 value: error 3647 }; 3648 } 3649 }; 3650 3651 // `Promise.allSettled` method 3652 // https://tc39.es/ecma262/#sec-promise.allsettled 3653 3654 3655 _export({ 3656 target: 'Promise', 3657 stat: true 3658 }, { 3659 allSettled: function allSettled(iterable) { 3660 var C = this; 3661 var capability = newPromiseCapability.f(C); 3662 var resolve = capability.resolve; 3663 var reject = capability.reject; 3664 var result = perform(function () { 3665 var promiseResolve = aCallable(C.resolve); 3666 var values = []; 3667 var counter = 0; 3668 var remaining = 1; 3669 iterate(iterable, function (promise) { 3670 var index = counter++; 3671 var alreadyCalled = false;
vendor: 2,994 bytes, lines 3672-3771
3672 remaining++; 3673 functionCall(promiseResolve, C, promise).then(function (value) { 3674 if (alreadyCalled) return; 3675 alreadyCalled = true; 3676 values[index] = { 3677 status: 'fulfilled', 3678 value: value 3679 }; 3680 --remaining || resolve(values); 3681 }, function (error) { 3682 if (alreadyCalled) return; 3683 alreadyCalled = true; 3684 values[index] = { 3685 status: 'rejected', 3686 reason: error 3687 }; 3688 --remaining || resolve(values); 3689 }); 3690 }); 3691 --remaining || resolve(values); 3692 }); 3693 if (result.error) reject(result.value); 3694 return capability.promise; 3695 } 3696 }); 3697 3698 var PROMISE_ANY_ERROR = 'No one promise resolved'; // `Promise.any` method 3699 // https://tc39.es/ecma262/#sec-promise.any 3700 3701 _export({ 3702 target: 'Promise', 3703 stat: true 3704 }, { 3705 any: function any(iterable) { 3706 var C = this; 3707 var AggregateError = getBuiltIn('AggregateError'); 3708 var capability = newPromiseCapability.f(C); 3709 var resolve = capability.resolve; 3710 var reject = capability.reject; 3711 var result = perform(function () { 3712 var promiseResolve = aCallable(C.resolve); 3713 var errors = []; 3714 var counter = 0; 3715 var remaining = 1; 3716 var alreadyResolved = false; 3717 iterate(iterable, function (promise) { 3718 var index = counter++; 3719 var alreadyRejected = false; 3720 remaining++; 3721 functionCall(promiseResolve, C, promise).then(function (value) { 3722 if (alreadyRejected || alreadyResolved) return; 3723 alreadyResolved = true; 3724 resolve(value); 3725 }, function (error) { 3726 if (alreadyRejected || alreadyResolved) return; 3727 alreadyRejected = true; 3728 errors[index] = error; 3729 --remaining || reject(new AggregateError(errors, PROMISE_ANY_ERROR)); 3730 }); 3731 }); 3732 --remaining || reject(new AggregateError(errors, PROMISE_ANY_ERROR)); 3733 }); 3734 if (result.error) reject(result.value); 3735 return capability.promise; 3736 } 3737 }); 3738 3739 var nativePromiseConstructor = global_1.Promise; 3740 3741 var promiseResolve = function (C, x) { 3742 anObject(C); 3743 if (isObject(x) && x.constructor === C) return x; 3744 var promiseCapability = newPromiseCapability.f(C); 3745 var resolve = promiseCapability.resolve; 3746 resolve(x); 3747 return promiseCapability.promise; 3748 }; 3749 3750 // Safari bug https://bugs.webkit.org/show_bug.cgi?id=200829 3751 3752 3753 var NON_GENERIC = !!nativePromiseConstructor && fails(function () { 3754 nativePromiseConstructor.prototype['finally'].call({ 3755 then: function () { 3756 /* empty */ 3757 } 3758 }, function () { 3759 /* empty */ 3760 }); 3761 }); // `Promise.prototype.finally` method 3762 // https://tc39.es/ecma262/#sec-promise.prototype.finally 3763 3764 _export({ 3765 target: 'Promise', 3766 proto: true, 3767 real: true, 3768 forced: NON_GENERIC 3769 }, { 3770 'finally': function (onFinally) { 3771 var C = speciesConstructor(this, getBuiltIn('Promise'));
3772 var isFunction = isCallable(onFinally); 3773 return this.then(isFunction ? function (x) { 3774 return promiseResolve(C, onFinally()).then(function () { 3775 return x; 3776 }); 3777 } : onFinally, isFunction ? function (e) { 3778 return promiseResolve(C, onFinally()).then(function () { 3779 throw e; 3780 }); 3781 } : onFinally); 3782 } 3783 }); // makes sure that native promise-based APIs `Promise#finally` properly works with patched `Promise#then` 3784 3785 if (!isPure && isCallable(nativePromiseConstructor)) { 3786 var method = getBuiltIn('Promise').prototype['finally']; 3787 3788 if (nativePromiseConstructor.prototype['finally'] !== method) { 3789 redefine(nativePromiseConstructor.prototype, 'finally', method, { 3790 unsafe: true 3791 }); 3792 } 3793 } 3794 3795 var ITERATOR$2 = wellKnownSymbol('iterator'); 3796 var BUGGY_SAFARI_ITERATORS = false; // `%IteratorPrototype%` object 3797 // https://tc39.es/ecma262/#sec-%iteratorprototype%-object 3798 3799 var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator; 3800 /* eslint-disable es/no-array-prototype-keys -- safe */ 3801 3802 if ([].keys) { 3803 arrayIterator = [].keys(); // Safari 8 has buggy iterators w/o `next` 3804 3805 if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true;else { 3806 PrototypeOfArrayIteratorPrototype = objectGetPrototypeOf(objectGetPrototypeOf(arrayIterator)); 3807 if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype; 3808 } 3809 } 3810 3811 var NEW_ITERATOR_PROTOTYPE = IteratorPrototype == undefined || fails(function () { 3812 var test = {}; // FF44- legacy iterators case 3813 3814 return IteratorPrototype[ITERATOR$2].call(test) !== test; 3815 }); 3816 if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype = {}; // `%IteratorPrototype%[@@iterator]()` method 3817 // https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator 3818 3819 if (!isCallable(IteratorPrototype[ITERATOR$2])) { 3820 redefine(IteratorPrototype, ITERATOR$2, function () { 3821 return this; 3822 }); 3823 } 3824 3825 var iteratorsCore = { 3826 IteratorPrototype: IteratorPrototype, 3827 BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS 3828 }; 3829 3830 var IteratorPrototype$1 = iteratorsCore.IteratorPrototype; 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 var returnThis = function () { 3841 return this; 3842 }; 3843 3844 var createIteratorConstructor = function (IteratorConstructor, NAME, next) { 3845 var TO_STRING_TAG = NAME + ' Iterator'; 3846 IteratorConstructor.prototype = objectCreate(IteratorPrototype$1, { 3847 next: createPropertyDescriptor(1, next) 3848 }); 3849 setToStringTag(IteratorConstructor, TO_STRING_TAG, false, true); 3850 iterators[TO_STRING_TAG] = returnThis; 3851 return IteratorConstructor; 3852 }; 3853 3854 var MATCH = wellKnownSymbol('match'); // `IsRegExp` abstract operation 3855 // https://tc39.es/ecma262/#sec-isregexp 3856 3857 var isRegexp = function (it) { 3858 var isRegExp; 3859 return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classofRaw(it) == 'RegExp'); 3860 }; 3861 3862 // `RegExp.prototype.flags` getter implementation 3863 // https://tc39.es/ecma262/#sec-get-regexp.prototype.flags 3864 3865 3866 var regexpFlags = function () { 3867 var that = anObject(this); 3868 var result = ''; 3869 if (that.global) result += 'g'; 3870 if (that.ignoreCase) result += 'i'; 3871 if (that.multiline) result += 'm'; 3872 if (that.dotAll) result += 's'; 3873 if (that.unicode) result += 'u'; 3874 if (that.sticky) result += 'y'; 3875 return result; 3876 }; 3877 3878 var charAt = functionUncurryThis(''.charAt); 3879 var charCodeAt = functionUncurryThis(''.charCodeAt); 3880 var stringSlice$1 = functionUncurryThis(''.slice); 3881 3882 var createMethod$1 = function (CONVERT_TO_STRING) { 3883 return function ($this, pos) { 3884 var S = toString_1(requireObjectCoercible($this)); 3885 var position = toIntegerOrInfinity(pos); 3886 var size = S.length; 3887 var first, second; 3888 if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined; 3889 first = charCodeAt(S, position); 3890 return first < 0xD800 || first > 0xDBFF || position + 1 === size || (second = charCodeAt(S, position + 1)) < 0xDC00 || second > 0xDFFF ? CONVERT_TO_STRING ? charAt(S, position) : first : CONVERT_TO_STRING ? stringSlice$1(S, position, position + 2) : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000; 3891 }; 3892 }; 3893 3894 var stringMultibyte = { 3895 // `String.prototype.codePointAt` method 3896 // https://tc39.es/ecma262/#sec-string.prototype.codepointat 3897 codeAt: createMethod$1(false), 3898 // `String.prototype.at` method 3899 // https://github.com/mathiasbynens/String.prototype.at 3900 charAt: createMethod$1(true) 3901 }; 3902 3903 var charAt$1 = stringMultibyte.charAt; // `AdvanceStringIndex` abstract operation 3904 // https://tc39.es/ecma262/#sec-advancestringindex 3905 3906 3907 var advanceStringIndex = function (S, index, unicode) { 3908 return index + (unicode ? charAt$1(S, index).length : 1); 3909 }; 3910 3911 // babel-minify and Closure Compiler transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError 3912 3913 3914 var $RegExp = global_1.RegExp; 3915 var UNSUPPORTED_Y = fails(function () { 3916 var re = $RegExp('a', 'y'); 3917 re.lastIndex = 2; 3918 return re.exec('abcd') != null; 3919 }); // UC Browser bug 3920 // https://github.com/zloirock/core-js/issues/1008 3921 3922 var MISSED_STICKY = UNSUPPORTED_Y || fails(function () { 3923 return !$RegExp('a', 'y').sticky; 3924 }); 3925 var BROKEN_CARET = UNSUPPORTED_Y || fails(function () { 3926 // https://bugzilla.mozilla.org/show_bug.cgi?id=773687 3927 var re = $RegExp('^r', 'gy'); 3928 re.lastIndex = 2; 3929 return re.exec('str') != null; 3930 }); 3931 var regexpStickyHelpers = { 3932 BROKEN_CARET: BROKEN_CARET, 3933 MISSED_STICKY: MISSED_STICKY, 3934 UNSUPPORTED_Y: UNSUPPORTED_Y 3935 }; 3936 3937 // babel-minify and Closure Compiler transpiles RegExp('.', 's') -> /./s and it causes SyntaxError 3938 3939 3940 var $RegExp$1 = global_1.RegExp; 3941 var regexpUnsupportedDotAll = fails(function () { 3942 var re = $RegExp$1('.', 's'); 3943 return !(re.dotAll && re.exec('\n') && re.flags === 's'); 3944 }); 3945 3946 // babel-minify and Closure Compiler transpiles RegExp('(?<a>b)', 'g') -> /(?<a>b)/g and it causes SyntaxError 3947 3948 3949 var $RegExp$2 = global_1.RegExp; 3950 var regexpUnsupportedNcg = fails(function () {
vendor: 5,743 bytes, lines 3951-4184
3951 var re = $RegExp$2('(?<a>b)', 'g'); 3952 return re.exec('b').groups.a !== 'b' || 'b'.replace(re, '$<a>c') !== 'bc'; 3953 }); 3954 3955 /* eslint-disable regexp/no-empty-capturing-group, regexp/no-empty-group, regexp/no-lazy-ends -- testing */ 3956 3957 /* eslint-disable regexp/no-useless-quantifier -- testing */ 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 var getInternalState$1 = internalState.get; 3974 3975 3976 3977 3978 3979 var nativeReplace = shared('native-string-replace', String.prototype.replace); 3980 var nativeExec = RegExp.prototype.exec; 3981 var patchedExec = nativeExec; 3982 var charAt$2 = functionUncurryThis(''.charAt); 3983 var indexOf$1 = functionUncurryThis(''.indexOf); 3984 var replace$1 = functionUncurryThis(''.replace); 3985 var stringSlice$2 = functionUncurryThis(''.slice); 3986 3987 var UPDATES_LAST_INDEX_WRONG = function () { 3988 var re1 = /a/; 3989 var re2 = /b*/g; 3990 functionCall(nativeExec, re1, 'a'); 3991 functionCall(nativeExec, re2, 'a'); 3992 return re1.lastIndex !== 0 || re2.lastIndex !== 0; 3993 }(); 3994 3995 var UNSUPPORTED_Y$1 = regexpStickyHelpers.BROKEN_CARET; // nonparticipating capturing group, copied from es5-shim's String#split patch. 3996 3997 var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined; 3998 var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y$1 || regexpUnsupportedDotAll || regexpUnsupportedNcg; 3999 4000 if (PATCH) { 4001 patchedExec = function exec(string) { 4002 var re = this; 4003 var state = getInternalState$1(re); 4004 var str = toString_1(string); 4005 var raw = state.raw; 4006 var result, reCopy, lastIndex, match, i, object, group; 4007 4008 if (raw) { 4009 raw.lastIndex = re.lastIndex; 4010 result = functionCall(patchedExec, raw, str); 4011 re.lastIndex = raw.lastIndex; 4012 return result; 4013 } 4014 4015 var groups = state.groups; 4016 var sticky = UNSUPPORTED_Y$1 && re.sticky; 4017 var flags = functionCall(regexpFlags, re); 4018 var source = re.source; 4019 var charsAdded = 0; 4020 var strCopy = str; 4021 4022 if (sticky) { 4023 flags = replace$1(flags, 'y', ''); 4024 4025 if (indexOf$1(flags, 'g') === -1) { 4026 flags += 'g'; 4027 } 4028 4029 strCopy = stringSlice$2(str, re.lastIndex); // Support anchored sticky behavior. 4030 4031 if (re.lastIndex > 0 && (!re.multiline || re.multiline && charAt$2(str, re.lastIndex - 1) !== '\n')) { 4032 source = '(?: ' + source + ')'; 4033 strCopy = ' ' + strCopy; 4034 charsAdded++; 4035 } // ^(? + rx + ) is needed, in combination with some str slicing, to 4036 // simulate the 'y' flag. 4037 4038 4039 reCopy = new RegExp('^(?:' + source + ')', flags); 4040 } 4041 4042 if (NPCG_INCLUDED) { 4043 reCopy = new RegExp('^' + source + '$(?!\\s)', flags); 4044 } 4045 4046 if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex; 4047 match = functionCall(nativeExec, sticky ? reCopy : re, strCopy); 4048 4049 if (sticky) { 4050 if (match) { 4051 match.input = stringSlice$2(match.input, charsAdded); 4052 match[0] = stringSlice$2(match[0], charsAdded); 4053 match.index = re.lastIndex; 4054 re.lastIndex += match[0].length; 4055 } else re.lastIndex = 0; 4056 } else if (UPDATES_LAST_INDEX_WRONG && match) { 4057 re.lastIndex = re.global ? match.index + match[0].length : lastIndex; 4058 } 4059 4060 if (NPCG_INCLUDED && match && match.length > 1) { 4061 // Fix browsers whose `exec` methods don't consistently return `undefined` 4062 // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/ 4063 functionCall(nativeReplace, match[0], reCopy, function () { 4064 for (i = 1; i < arguments.length - 2; i++) { 4065 if (arguments[i] === undefined) match[i] = undefined; 4066 } 4067 }); 4068 } 4069 4070 if (match && groups) { 4071 match.groups = object = objectCreate(null); 4072 4073 for (i = 0; i < groups.length; i++) { 4074 group = groups[i]; 4075 object[group[0]] = match[group[1]]; 4076 } 4077 } 4078 4079 return match; 4080 }; 4081 } 4082 4083 var regexpExec = patchedExec; 4084 4085 var TypeError$d = global_1.TypeError; // `RegExpExec` abstract operation 4086 // https://tc39.es/ecma262/#sec-regexpexec 4087 4088 var regexpExecAbstract = function (R, S) { 4089 var exec = R.exec; 4090 4091 if (isCallable(exec)) { 4092 var result = functionCall(exec, R, S); 4093 if (result !== null) anObject(result); 4094 return result; 4095 } 4096 4097 if (classofRaw(R) === 'RegExp') return functionCall(regexpExec, R, S); 4098 throw TypeError$d('RegExp#exec called on incompatible receiver'); 4099 }; 4100 4101 /* eslint-disable es/no-string-prototype-matchall -- safe */ 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 var MATCH_ALL = wellKnownSymbol('matchAll'); 4148 var REGEXP_STRING = 'RegExp String'; 4149 var REGEXP_STRING_ITERATOR = REGEXP_STRING + ' Iterator'; 4150 var setInternalState$1 = internalState.set; 4151 var getInternalState$2 = internalState.getterFor(REGEXP_STRING_ITERATOR); 4152 var RegExpPrototype = RegExp.prototype; 4153 var TypeError$e = global_1.TypeError; 4154 var getFlags = functionUncurryThis(regexpFlags); 4155 var stringIndexOf = functionUncurryThis(''.indexOf); 4156 var un$MatchAll = functionUncurryThis(''.matchAll); 4157 var WORKS_WITH_NON_GLOBAL_REGEX = !!un$MatchAll && !fails(function () { 4158 un$MatchAll('a', /./); 4159 }); 4160 var $RegExpStringIterator = createIteratorConstructor(function RegExpStringIterator(regexp, string, $global, fullUnicode) { 4161 setInternalState$1(this, { 4162 type: REGEXP_STRING_ITERATOR, 4163 regexp: regexp, 4164 string: string, 4165 global: $global, 4166 unicode: fullUnicode, 4167 done: false 4168 }); 4169 }, REGEXP_STRING, function next() { 4170 var state = getInternalState$2(this); 4171 if (state.done) return { 4172 value: undefined, 4173 done: true 4174 }; 4175 var R = state.regexp; 4176 var S = state.string; 4177 var match = regexpExecAbstract(R, S); 4178 if (match === null) return { 4179 value: undefined, 4180 done: state.done = true 4181 }; 4182 4183 if (state.global) { 4184 if (toString_1(match[0]) === '') R.lastIndex = advanceStringIndex(S, toLe
4184ngth(R.lastIndex), state.unicode); 4185 return { 4186 value: match, 4187 done: false 4188 }; 4189 } 4190 4191 state.done = true; 4192 return { 4193 value: match, 4194 done: false 4195 }; 4196 }); 4197 4198 var $matchAll = function (string) { 4199 var R = anObject(this); 4200 var S = toString_1(string); 4201 var C, flagsValue, flags, matcher, $global, fullUnicode; 4202 C = speciesConstructor(R, RegExp); 4203 flagsValue = R.flags; 4204 4205 if (flagsValue === undefined && objectIsPrototypeOf(RegExpPrototype, R) && !('flags' in RegExpPrototype)) { 4206 flagsValue = getFlags(R); 4207 } 4208 4209 flags = flagsValue === undefined ? '' : toString_1(flagsValue); 4210 matcher = new C(C === RegExp ? R.source : R, flags); 4211 $global = !!~stringIndexOf(flags, 'g'); 4212 fullUnicode = !!~stringIndexOf(flags, 'u'); 4213 matcher.lastIndex = toLength(R.lastIndex); 4214 return new $RegExpStringIterator(matcher, S, $global, fullUnicode); 4215 }; // `String.prototype.matchAll` method 4216 // https://tc39.es/ecma262/#sec-string.prototype.matchall 4217 4218 4219 _export({ 4220 target: 'String', 4221 proto: true, 4222 forced: WORKS_WITH_NON_GLOBAL_REGEX 4223 }, { 4224 matchAll: function matchAll(regexp) { 4225 var O = requireObjectCoercible(this); 4226 var flags, S, matcher, rx; 4227 4228 if (regexp != null) { 4229 if (isRegexp(regexp)) { 4230 flags = toString_1(requireObjectCoercible('flags' in RegExpPrototype ? regexp.flags : getFlags(regexp))); 4231 if (!~stringIndexOf(flags, 'g')) throw TypeError$e('`.matchAll` does not allow non-global regexes'); 4232 } 4233 4234 if (WORKS_WITH_NON_GLOBAL_REGEX) return un$MatchAll(O, regexp); 4235 matcher = getMethod(regexp, MATCH_ALL); 4236 if (matcher === undefined && isPure && classofRaw(regexp) == 'RegExp') matcher = $matchAll; 4237 if (matcher) return functionCall(matcher, regexp, O); 4238 } else if (WORKS_WITH_NON_GLOBAL_REGEX) return un$MatchAll(O, regexp); 4239 4240 S = toString_1(O); 4241 rx = new RegExp(regexp, 'g'); 4242 return isPure ? functionCall($matchAll, rx, S) : rx[MATCH_ALL](S); 4243 } 4244 }); 4245 isPure || MATCH_ALL in RegExpPrototype || redefine(RegExpPrototype, MATCH_ALL, $matchAll); 4246 4247 var floor$2 = Math.floor; 4248 var charAt$3 = functionUncurryThis(''.charAt); 4249 var replace$2 = functionUncurryThis(''.replace); 4250 var stringSlice$3 = functionUncurryThis(''.slice); 4251 var SUBSTITUTION_SYMBOLS = /\$([$&'`]|\d{1,2}|<[^>]*>)/g; 4252 var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&'`]|\d{1,2})/g; // `GetSubstitution` abstract operation 4253 // https://tc39.es/ecma262/#sec-getsubstitution 4254 4255 var getSubstitution = function (matched, str, position, captures, namedCaptures, replacement) { 4256 var tailPos = position + matched.length; 4257 var m = captures.length; 4258 var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED; 4259 4260 if (namedCaptures !== undefined) { 4261 namedCaptures = toObject(namedCaptures); 4262 symbols = SUBSTITUTION_SYMBOLS; 4263 } 4264 4265 return replace$2(replacement, symbols, function (match, ch) { 4266 var capture; 4267 4268 switch (charAt$3(ch, 0)) { 4269 case '$': 4270 return '$'; 4271 4272 case '&': 4273 return matched; 4274 4275 case '`': 4276 return stringSlice$3(str, 0, position); 4277 4278 case "'": 4279 return stringSlice$3(str, tailPos); 4280 4281 case '<': 4282 capture = namedCaptures[stringSlice$3(ch, 1, -1)]; 4283 break; 4284 4285 default: 4286 // \d\d? 4287 var n = +ch; 4288 if (n === 0) return match; 4289 4290 if (n > m) { 4291 var f = floor$2(n / 10); 4292 if (f === 0) return match; 4293 if (f <= m) return captures[f - 1] === undefined ? charAt$3(ch, 1) : captures[f - 1] + charAt$3(ch, 1); 4294 return match; 4295 } 4296 4297 capture = captures[n - 1]; 4298 } 4299 4300 return capture === undefined ? '' : capture; 4301 }); 4302 }; 4303 4304 var REPLACE = wellKnownSymbol('replace'); 4305 var RegExpPrototype$1 = RegExp.prototype; 4306 var TypeError$f = global_1.TypeError; 4307 var getFlags$1 = functionUncurryThis(regexpFlags); 4308 var indexOf$2 = functionUncurryThis(''.indexOf); 4309 var replace$3 = functionUncurryThis(''.replace); 4310 var stringSlice$4 = functionUncurryThis(''.slice); 4311 var max$2 = Math.max; 4312 4313 var stringIndexOf$1 = function (string, searchValue, fromIndex) { 4314 if (fromIndex > string.length) return -1; 4315 if (searchValue === '') return fromIndex; 4316 return indexOf$2(string, searchValue, fromIndex); 4317 }; // `String.prototype.replaceAll` method 4318 // https://tc39.es/ecma262/#sec-string.prototype.replaceall 4319 4320 4321 _export({ 4322 target: 'String', 4323 proto: true 4324 }, { 4325 replaceAll: function replaceAll(searchValue, replaceValue) { 4326 var O = requireObjectCoercible(this); 4327 var IS_REG_EXP, flags, replacer, string, searchString, functionalReplace, searchLength, advanceBy, replacement; 4328 var position = 0; 4329 var endOfLastMatch = 0; 4330 var result = ''; 4331 4332 if (searchValue != null) { 4333 IS_REG_EXP = isRegexp(searchValue); 4334 4335 if (IS_REG_EXP) { 4336 flags = toString_1(requireObjectCoercible('flags' in RegExpPrototype$1 ? searchValue.flags : getFlags$1(searchValue))); 4337 if (!~indexOf$2(flags, 'g')) throw TypeError$f('`.replaceAll` does not allow non-global regexes'); 4338 } 4339 4340 replacer = getMethod(searchValue, REPLACE); 4341 4342 if (replacer) { 4343 return functionCall(replacer, searchValue, O, replaceValue); 4344 } else if (isPure && IS_REG_EXP) { 4345 return replace$3(toString_1(O), searchValue, replaceValue); 4346 } 4347 } 4348 4349 string = toString_1(O); 4350 searchString = toString_1(searchValue); 4351 functionalReplace = isCallable(replaceValue); 4352 if (!functionalReplace) replaceValue = toString_1(replaceValue); 4353 searchLength = searchString.length; 4354 advanceBy = max$2(1, searchLength); 4355 position = stringIndexOf$1(string, searchString, 0); 4356 4357 while (position !== -1) { 4358 replacement = functionalReplace ? toString_1(replaceValue(searchString, position, string)) : getSubstitution(searchString, string, position, [], undefined, replaceValue); 4359 result += stringSlice$4(string, endOfLastMatch, position) + replacement; 4360 endOfLastMatch = position + searchLength; 4361 position = stringIndexOf$1(string, searchString, position + advanceBy); 4362 } 4363 4364 if (endOfLastMatch < string.length) { 4365 result += stringSlice$4(string, endOfLastMatch); 4366 } 4367 4368 return result; 4369 } 4370 }); 4371 4372 var ITERATOR$3 = wellKnownSymbol('iterator'); 4373 var SAFE_CLOSING = false;
vendor: 4,474 bytes, lines 4374-4517
4374 4375 var checkCorrectnessOfIteration = function (exec, SKIP_CLOSING) { 4376 if (!SKIP_CLOSING && !SAFE_CLOSING) return false; 4377 var ITERATION_SUPPORT = false; 4378 4379 try { 4380 var object = {}; 4381 4382 object[ITERATOR$3] = function () { 4383 return { 4384 next: function () { 4385 return { 4386 done: ITERATION_SUPPORT = true 4387 }; 4388 } 4389 }; 4390 }; 4391 4392 exec(object); 4393 } catch (error) { 4394 /* empty */ 4395 } 4396 4397 return ITERATION_SUPPORT; 4398 }; 4399 4400 var defineProperty$3 = objectDefineProperty.f; 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 var Int8Array = global_1.Int8Array; 4413 var Int8ArrayPrototype = Int8Array && Int8Array.prototype; 4414 var Uint8ClampedArray = global_1.Uint8ClampedArray; 4415 var Uint8ClampedArrayPrototype = Uint8ClampedArray && Uint8ClampedArray.prototype; 4416 var TypedArray = Int8Array && objectGetPrototypeOf(Int8Array); 4417 var TypedArrayPrototype = Int8ArrayPrototype && objectGetPrototypeOf(Int8ArrayPrototype); 4418 var ObjectPrototype$2 = Object.prototype; 4419 var TypeError$g = global_1.TypeError; 4420 var TO_STRING_TAG$4 = wellKnownSymbol('toStringTag'); 4421 var TYPED_ARRAY_TAG = uid('TYPED_ARRAY_TAG'); 4422 var TYPED_ARRAY_CONSTRUCTOR = uid('TYPED_ARRAY_CONSTRUCTOR'); // Fixing native typed arrays in Opera Presto crashes the browser, see #595 4423 4424 var NATIVE_ARRAY_BUFFER_VIEWS = arrayBufferNative && !!objectSetPrototypeOf && classof(global_1.opera) !== 'Opera'; 4425 var TYPED_ARRAY_TAG_REQIRED = false; 4426 var NAME, Constructor, Prototype; 4427 var TypedArrayConstructorsList = { 4428 Int8Array: 1, 4429 Uint8Array: 1, 4430 Uint8ClampedArray: 1, 4431 Int16Array: 2, 4432 Uint16Array: 2, 4433 Int32Array: 4, 4434 Uint32Array: 4, 4435 Float32Array: 4, 4436 Float64Array: 8 4437 }; 4438 var BigIntArrayConstructorsList = { 4439 BigInt64Array: 8, 4440 BigUint64Array: 8 4441 }; 4442 4443 var isView = function isView(it) { 4444 if (!isObject(it)) return false; 4445 var klass = classof(it); 4446 return klass === 'DataView' || hasOwnProperty_1(TypedArrayConstructorsList, klass) || hasOwnProperty_1(BigIntArrayConstructorsList, klass); 4447 }; 4448 4449 var isTypedArray = function (it) { 4450 if (!isObject(it)) return false; 4451 var klass = classof(it); 4452 return hasOwnProperty_1(TypedArrayConstructorsList, klass) || hasOwnProperty_1(BigIntArrayConstructorsList, klass); 4453 }; 4454 4455 var aTypedArray = function (it) { 4456 if (isTypedArray(it)) return it; 4457 throw TypeError$g('Target is not a typed array'); 4458 }; 4459 4460 var aTypedArrayConstructor = function (C) { 4461 if (isCallable(C) && (!objectSetPrototypeOf || objectIsPrototypeOf(TypedArray, C))) return C; 4462 throw TypeError$g(tryToString(C) + ' is not a typed array constructor'); 4463 }; 4464 4465 var exportTypedArrayMethod = function (KEY, property, forced) { 4466 if (!descriptors) return; 4467 if (forced) for (var ARRAY in TypedArrayConstructorsList) { 4468 var TypedArrayConstructor = global_1[ARRAY]; 4469 if (TypedArrayConstructor && hasOwnProperty_1(TypedArrayConstructor.prototype, KEY)) try { 4470 delete TypedArrayConstructor.prototype[KEY]; 4471 } catch (error) { 4472 /* empty */ 4473 } 4474 } 4475 4476 if (!TypedArrayPrototype[KEY] || forced) { 4477 redefine(TypedArrayPrototype, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS && Int8ArrayPrototype[KEY] || property); 4478 } 4479 }; 4480 4481 var exportTypedArrayStaticMethod = function (KEY, property, forced) { 4482 var ARRAY, TypedArrayConstructor; 4483 if (!descriptors) return; 4484 4485 if (objectSetPrototypeOf) { 4486 if (forced) for (ARRAY in TypedArrayConstructorsList) { 4487 TypedArrayConstructor = global_1[ARRAY]; 4488 if (TypedArrayConstructor && hasOwnProperty_1(TypedArrayConstructor, KEY)) try { 4489 delete TypedArrayConstructor[KEY]; 4490 } catch (error) { 4491 /* empty */ 4492 } 4493 } 4494 4495 if (!TypedArray[KEY] || forced) { 4496 // V8 ~ Chrome 49-50 `%TypedArray%` methods are non-writable non-configurable 4497 try { 4498 return redefine(TypedArray, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS && TypedArray[KEY] || property); 4499 } catch (error) { 4500 /* empty */ 4501 } 4502 } else return; 4503 } 4504 4505 for (ARRAY in TypedArrayConstructorsList) { 4506 TypedArrayConstructor = global_1[ARRAY]; 4507 4508 if (TypedArrayConstructor && (!TypedArrayConstructor[KEY] || forced)) { 4509 redefine(TypedArrayConstructor, KEY, property); 4510 } 4511 } 4512 }; 4513 4514 for (NAME in TypedArrayConstructorsList) { 4515 Constructor = global_1[NAME]; 4516 Prototype = Constructor && Constructor.prototype; 4517 if (Prototype) createNonEnumerableProperty(Prototype, TYPED_ARRAY_CONSTRUCTOR, Constructor);else NATIVE_ARRAY_BUFFER_VIEWS = false;
vendor: 5,622 bytes, lines 4518-4690
4518 } 4519 4520 for (NAME in BigIntArrayConstructorsList) { 4521 Constructor = global_1[NAME]; 4522 Prototype = Constructor && Constructor.prototype; 4523 if (Prototype) createNonEnumerableProperty(Prototype, TYPED_ARRAY_CONSTRUCTOR, Constructor); 4524 } // WebKit bug - typed arrays constructors prototype is Object.prototype 4525 4526 4527 if (!NATIVE_ARRAY_BUFFER_VIEWS || !isCallable(TypedArray) || TypedArray === Function.prototype) { 4528 // eslint-disable-next-line no-shadow -- safe 4529 TypedArray = function TypedArray() { 4530 throw TypeError$g('Incorrect invocation'); 4531 }; 4532 4533 if (NATIVE_ARRAY_BUFFER_VIEWS) for (NAME in TypedArrayConstructorsList) { 4534 if (global_1[NAME]) objectSetPrototypeOf(global_1[NAME], TypedArray); 4535 } 4536 } 4537 4538 if (!NATIVE_ARRAY_BUFFER_VIEWS || !TypedArrayPrototype || TypedArrayPrototype === ObjectPrototype$2) { 4539 TypedArrayPrototype = TypedArray.prototype; 4540 if (NATIVE_ARRAY_BUFFER_VIEWS) for (NAME in TypedArrayConstructorsList) { 4541 if (global_1[NAME]) objectSetPrototypeOf(global_1[NAME].prototype, TypedArrayPrototype); 4542 } 4543 } // WebKit bug - one more object in Uint8ClampedArray prototype chain 4544 4545 4546 if (NATIVE_ARRAY_BUFFER_VIEWS && objectGetPrototypeOf(Uint8ClampedArrayPrototype) !== TypedArrayPrototype) { 4547 objectSetPrototypeOf(Uint8ClampedArrayPrototype, TypedArrayPrototype); 4548 } 4549 4550 if (descriptors && !hasOwnProperty_1(TypedArrayPrototype, TO_STRING_TAG$4)) { 4551 TYPED_ARRAY_TAG_REQIRED = true; 4552 defineProperty$3(TypedArrayPrototype, TO_STRING_TAG$4, { 4553 get: function () { 4554 return isObject(this) ? this[TYPED_ARRAY_TAG] : undefined; 4555 } 4556 }); 4557 4558 for (NAME in TypedArrayConstructorsList) if (global_1[NAME]) { 4559 createNonEnumerableProperty(global_1[NAME], TYPED_ARRAY_TAG, NAME); 4560 } 4561 } 4562 4563 var arrayBufferViewCore = { 4564 NATIVE_ARRAY_BUFFER_VIEWS: NATIVE_ARRAY_BUFFER_VIEWS, 4565 TYPED_ARRAY_CONSTRUCTOR: TYPED_ARRAY_CONSTRUCTOR, 4566 TYPED_ARRAY_TAG: TYPED_ARRAY_TAG_REQIRED && TYPED_ARRAY_TAG, 4567 aTypedArray: aTypedArray, 4568 aTypedArrayConstructor: aTypedArrayConstructor, 4569 exportTypedArrayMethod: exportTypedArrayMethod, 4570 exportTypedArrayStaticMethod: exportTypedArrayStaticMethod, 4571 isView: isView, 4572 isTypedArray: isTypedArray, 4573 TypedArray: TypedArray, 4574 TypedArrayPrototype: TypedArrayPrototype 4575 }; 4576 4577 /* eslint-disable no-new -- required for testing */ 4578 4579 4580 4581 4582 4583 4584 var NATIVE_ARRAY_BUFFER_VIEWS$1 = arrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS; 4585 4586 var ArrayBuffer$2 = global_1.ArrayBuffer; 4587 var Int8Array$1 = global_1.Int8Array; 4588 var typedArrayConstructorsRequireWrappers = !NATIVE_ARRAY_BUFFER_VIEWS$1 || !fails(function () { 4589 Int8Array$1(1); 4590 }) || !fails(function () { 4591 new Int8Array$1(-1); 4592 }) || !checkCorrectnessOfIteration(function (iterable) { 4593 new Int8Array$1(); 4594 new Int8Array$1(null); 4595 new Int8Array$1(1.5); 4596 new Int8Array$1(iterable); 4597 }, true) || fails(function () { 4598 // Safari (11+) bug - a reason why even Safari 13 should load a typed array polyfill 4599 return new Int8Array$1(new ArrayBuffer$2(2), 1, undefined).length !== 1; 4600 }); 4601 4602 var floor$3 = Math.floor; // `IsIntegralNumber` abstract operation 4603 // https://tc39.es/ecma262/#sec-isintegralnumber 4604 // eslint-disable-next-line es/no-number-isinteger -- safe 4605 4606 var isIntegralNumber = Number.isInteger || function isInteger(it) { 4607 return !isObject(it) && isFinite(it) && floor$3(it) === it; 4608 }; 4609 4610 var RangeError$2 = global_1.RangeError; 4611 4612 var toPositiveInteger = function (it) { 4613 var result = toIntegerOrInfinity(it); 4614 if (result < 0) throw RangeError$2("The argument can't be less than 0"); 4615 return result; 4616 }; 4617 4618 var RangeError$3 = global_1.RangeError; 4619 4620 var toOffset = function (it, BYTES) { 4621 var offset = toPositiveInteger(it); 4622 if (offset % BYTES) throw RangeError$3('Wrong offset'); 4623 return offset; 4624 }; 4625 4626 var aTypedArrayConstructor$1 = arrayBufferViewCore.aTypedArrayConstructor; 4627 4628 var typedArrayFrom = function from(source 4629 /* , mapfn, thisArg */ 4630 ) { 4631 var C = aConstructor(this); 4632 var O = toObject(source); 4633 var argumentsLength = arguments.length; 4634 var mapfn = argumentsLength > 1 ? arguments[1] : undefined; 4635 var mapping = mapfn !== undefined; 4636 var iteratorMethod = getIteratorMethod(O); 4637 var i, length, result, step, iterator, next; 4638 4639 if (iteratorMethod && !isArrayIteratorMethod(iteratorMethod)) { 4640 iterator = getIterator(O, iteratorMethod); 4641 next = iterator.next; 4642 O = []; 4643 4644 while (!(step = functionCall(next, iterator)).done) { 4645 O.push(step.value); 4646 } 4647 } 4648 4649 if (mapping && argumentsLength > 2) { 4650 mapfn = functionBindContext(mapfn, arguments[2]); 4651 } 4652 4653 length = lengthOfArrayLike(O); 4654 result = new (aTypedArrayConstructor$1(C))(length); 4655 4656 for (i = 0; length > i; i++) { 4657 result[i] = mapping ? mapfn(O[i], i) : O[i]; 4658 } 4659 4660 return result; 4661 }; 4662 4663 var SPECIES$1 = wellKnownSymbol('species'); 4664 var Array$4 = global_1.Array; // a part of `ArraySpeciesCreate` abstract operation 4665 // https://tc39.es/ecma262/#sec-arrayspeciescreate 4666 4667 var arraySpeciesConstructor = function (originalArray) { 4668 var C; 4669 4670 if (isArray(originalArray)) { 4671 C = originalArray.constructor; // cross-realm fallback 4672 4673 if (isConstructor(C) && (C === Array$4 || isArray(C.prototype))) C = undefined;else if (isObject(C)) { 4674 C = C[SPECIES$1]; 4675 if (C === null) C = undefined; 4676 } 4677 } 4678 4679 return C === undefined ? Array$4 : C; 4680 }; 4681 4682 // `ArraySpeciesCreate` abstract operation 4683 // https://tc39.es/ecma262/#sec-arrayspeciescreate 4684 4685 4686 var arraySpeciesCreate = function (originalArray, length) { 4687 return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length); 4688 }; 4689 4690 var push$2 = functionUncurryThis([].push);
4690 // `Array.prototype.{ forEach, map, filter, some, every, find, findIndex, filterReject }` methods implementation 4691 4692 var createMethod$2 = function (TYPE) { 4693 var IS_MAP = TYPE == 1; 4694 var IS_FILTER = TYPE == 2; 4695 var IS_SOME = TYPE == 3; 4696 var IS_EVERY = TYPE == 4; 4697 var IS_FIND_INDEX = TYPE == 6; 4698 var IS_FILTER_REJECT = TYPE == 7; 4699 var NO_HOLES = TYPE == 5 || IS_FIND_INDEX; 4700 return function ($this, callbackfn, that, specificCreate) { 4701 var O = toObject($this); 4702 var self = indexedObject(O); 4703 var boundFunction = functionBindContext(callbackfn, that); 4704 var length = lengthOfArrayLike(self); 4705 var index = 0; 4706 var create = specificCreate || arraySpeciesCreate; 4707 var target = IS_MAP ? create($this, length) : IS_FILTER || IS_FILTER_REJECT ? create($this, 0) : undefined; 4708 var value, result; 4709 4710 for (; length > index; index++) if (NO_HOLES || index in self) { 4711 value = self[index]; 4712 result = boundFunction(value, index, O); 4713 4714 if (TYPE) { 4715 if (IS_MAP) target[index] = result; // map 4716 else if (result) switch (TYPE) { 4717 case 3: 4718 return true; 4719 // some 4720 4721 case 5: 4722 return value; 4723 // find 4724 4725 case 6: 4726 return index; 4727 // findIndex 4728 4729 case 2: 4730 push$2(target, value); 4731 // filter 4732 } else switch (TYPE) { 4733 case 4: 4734 return false; 4735 // every 4736 4737 case 7: 4738 push$2(target, value); 4739 // filterReject 4740 } 4741 } 4742 } 4743 4744 return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target; 4745 }; 4746 }; 4747 4748 var arrayIteration = { 4749 // `Array.prototype.forEach` method 4750 // https://tc39.es/ecma262/#sec-array.prototype.foreach 4751 forEach: createMethod$2(0), 4752 // `Array.prototype.map` method 4753 // https://tc39.es/ecma262/#sec-array.prototype.map 4754 map: createMethod$2(1), 4755 // `Array.prototype.filter` method 4756 // https://tc39.es/ecma262/#sec-array.prototype.filter 4757 filter: createMethod$2(2), 4758 // `Array.prototype.some` method 4759 // https://tc39.es/ecma262/#sec-array.prototype.some 4760 some: createMethod$2(3), 4761 // `Array.prototype.every` method 4762 // https://tc39.es/ecma262/#sec-array.prototype.every 4763 every: createMethod$2(4), 4764 // `Array.prototype.find` method 4765 // https://tc39.es/ecma262/#sec-array.prototype.find 4766 find: createMethod$2(5), 4767 // `Array.prototype.findIndex` method 4768 // https://tc39.es/ecma262/#sec-array.prototype.findIndex 4769 findIndex: createMethod$2(6), 4770 // `Array.prototype.filterReject` method 4771 // https://github.com/tc39/proposal-array-filtering 4772 filterReject: createMethod$2(7) 4773 }; 4774 4775 var SPECIES$2 = wellKnownSymbol('species'); 4776 4777 var setSpecies = function (CONSTRUCTOR_NAME) { 4778 var Constructor = getBuiltIn(CONSTRUCTOR_NAME); 4779 var defineProperty = objectDefineProperty.f; 4780 4781 if (descriptors && Constructor && !Constructor[SPECIES$2]) { 4782 defineProperty(Constructor, SPECIES$2, { 4783 configurable: true, 4784 get: function () { 4785 return this; 4786 } 4787 }); 4788 } 4789 }; 4790 4791 // makes subclassing work correct for wrapped built-ins 4792 4793 4794 var inheritIfRequired = function ($this, dummy, Wrapper) { 4795 var NewTarget, NewTargetPrototype; 4796 if ( // it can work only with native `setPrototypeOf` 4797 objectSetPrototypeOf && // we haven't completely correct pre-ES6 way for getting `new.target`, so use this 4798 isCallable(NewTarget = dummy.constructor) && NewTarget !== Wrapper && isObject(NewTargetPrototype = NewTarget.prototype) && NewTargetPrototype !== Wrapper.prototype) objectSetPrototypeOf($this, NewTargetPrototype); 4799 return $this; 4800 }; 4801 4802 var typedArrayConstructor = createCommonjsModule(function (module) { 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 var getOwnPropertyNames = objectGetOwnPropertyNames.f; 4849 4850 4851
vendor: 7,113 bytes, lines 4852-5034
4852 var forEach = arrayIteration.forEach; 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 var getInternalState = internalState.get; 4865 var setInternalState = internalState.set; 4866 var nativeDefineProperty = objectDefineProperty.f; 4867 var nativeGetOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f; 4868 var round = Math.round; 4869 var RangeError = global_1.RangeError; 4870 var ArrayBuffer = arrayBuffer.ArrayBuffer; 4871 var ArrayBufferPrototype = ArrayBuffer.prototype; 4872 var DataView = arrayBuffer.DataView; 4873 var NATIVE_ARRAY_BUFFER_VIEWS = arrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS; 4874 var TYPED_ARRAY_CONSTRUCTOR = arrayBufferViewCore.TYPED_ARRAY_CONSTRUCTOR; 4875 var TYPED_ARRAY_TAG = arrayBufferViewCore.TYPED_ARRAY_TAG; 4876 var TypedArray = arrayBufferViewCore.TypedArray; 4877 var TypedArrayPrototype = arrayBufferViewCore.TypedArrayPrototype; 4878 var aTypedArrayConstructor = arrayBufferViewCore.aTypedArrayConstructor; 4879 var isTypedArray = arrayBufferViewCore.isTypedArray; 4880 var BYTES_PER_ELEMENT = 'BYTES_PER_ELEMENT'; 4881 var WRONG_LENGTH = 'Wrong length'; 4882 4883 var fromList = function (C, list) { 4884 aTypedArrayConstructor(C); 4885 var index = 0; 4886 var length = list.length; 4887 var result = new C(length); 4888 4889 while (length > index) result[index] = list[index++]; 4890 4891 return result; 4892 }; 4893 4894 var addGetter = function (it, key) { 4895 nativeDefineProperty(it, key, { 4896 get: function () { 4897 return getInternalState(this)[key]; 4898 } 4899 }); 4900 }; 4901 4902 var isArrayBuffer = function (it) { 4903 var klass; 4904 return objectIsPrototypeOf(ArrayBufferPrototype, it) || (klass = classof(it)) == 'ArrayBuffer' || klass == 'SharedArrayBuffer'; 4905 }; 4906 4907 var isTypedArrayIndex = function (target, key) { 4908 return isTypedArray(target) && !isSymbol(key) && key in target && isIntegralNumber(+key) && key >= 0; 4909 }; 4910 4911 var wrappedGetOwnPropertyDescriptor = function getOwnPropertyDescriptor(target, key) { 4912 key = toPropertyKey(key); 4913 return isTypedArrayIndex(target, key) ? createPropertyDescriptor(2, target[key]) : nativeGetOwnPropertyDescriptor(target, key); 4914 }; 4915 4916 var wrappedDefineProperty = function defineProperty(target, key, descriptor) { 4917 key = toPropertyKey(key); 4918 4919 if (isTypedArrayIndex(target, key) && isObject(descriptor) && hasOwnProperty_1(descriptor, 'value') && !hasOwnProperty_1(descriptor, 'get') && !hasOwnProperty_1(descriptor, 'set') // TODO: add validation descriptor w/o calling accessors 4920 && !descriptor.configurable && (!hasOwnProperty_1(descriptor, 'writable') || descriptor.writable) && (!hasOwnProperty_1(descriptor, 'enumerable') || descriptor.enumerable)) { 4921 target[key] = descriptor.value; 4922 return target; 4923 } 4924 4925 return nativeDefineProperty(target, key, descriptor); 4926 }; 4927 4928 if (descriptors) { 4929 if (!NATIVE_ARRAY_BUFFER_VIEWS) { 4930 objectGetOwnPropertyDescriptor.f = wrappedGetOwnPropertyDescriptor; 4931 objectDefineProperty.f = wrappedDefineProperty; 4932 addGetter(TypedArrayPrototype, 'buffer'); 4933 addGetter(TypedArrayPrototype, 'byteOffset'); 4934 addGetter(TypedArrayPrototype, 'byteLength'); 4935 addGetter(TypedArrayPrototype, 'length'); 4936 } 4937 4938 _export({ 4939 target: 'Object', 4940 stat: true, 4941 forced: !NATIVE_ARRAY_BUFFER_VIEWS 4942 }, { 4943 getOwnPropertyDescriptor: wrappedGetOwnPropertyDescriptor, 4944 defineProperty: wrappedDefineProperty 4945 }); 4946 4947 module.exports = function (TYPE, wrapper, CLAMPED) { 4948 var BYTES = TYPE.match(/\d+$/)[0] / 8; 4949 var CONSTRUCTOR_NAME = TYPE + (CLAMPED ? 'Clamped' : '') + 'Array'; 4950 var GETTER = 'get' + TYPE; 4951 var SETTER = 'set' + TYPE; 4952 var NativeTypedArrayConstructor = global_1[CONSTRUCTOR_NAME]; 4953 var TypedArrayConstructor = NativeTypedArrayConstructor; 4954 var TypedArrayConstructorPrototype = TypedArrayConstructor && TypedArrayConstructor.prototype; 4955 var exported = {}; 4956 4957 var getter = function (that, index) { 4958 var data = getInternalState(that); 4959 return data.view[GETTER](index * BYTES + data.byteOffset, true); 4960 }; 4961 4962 var setter = function (that, index, value) { 4963 var data = getInternalState(that); 4964 if (CLAMPED) value = (value = round(value)) < 0 ? 0 : value > 0xFF ? 0xFF : value & 0xFF; 4965 data.view[SETTER](index * BYTES + data.byteOffset, value, true); 4966 }; 4967 4968 var addElement = function (that, index) { 4969 nativeDefineProperty(that, index, { 4970 get: function () { 4971 return getter(this, index); 4972 }, 4973 set: function (value) { 4974 return setter(this, index, value); 4975 }, 4976 enumerable: true 4977 }); 4978 }; 4979 4980 if (!NATIVE_ARRAY_BUFFER_VIEWS) { 4981 TypedArrayConstructor = wrapper(function (that, data, offset, $length) { 4982 anInstance(that, TypedArrayConstructorPrototype); 4983 var index = 0; 4984 var byteOffset = 0; 4985 var buffer, byteLength, length; 4986 4987 if (!isObject(data)) { 4988 length = toIndex(data); 4989 byteLength = length * BYTES; 4990 buffer = new ArrayBuffer(byteLength); 4991 } else if (isArrayBuffer(data)) { 4992 buffer = data; 4993 byteOffset = toOffset(offset, BYTES); 4994 var $len = data.byteLength; 4995 4996 if ($length === undefined) { 4997 if ($len % BYTES) throw RangeError(WRONG_LENGTH); 4998 byteLength = $len - byteOffset; 4999 if (byteLength < 0) throw RangeError(WRONG_LENGTH); 5000 } else { 5001 byteLength = toLength($length) * BYTES; 5002 if (byteLength + byteOffset > $len) throw RangeError(WRONG_LENGTH); 5003 } 5004 5005 length = byteLength / BYTES; 5006 } else if (isTypedArray(data)) { 5007 return fromList(TypedArrayConstructor, data); 5008 } else { 5009 return functionCall(typedArrayFrom, TypedArrayConstructor, data); 5010 } 5011 5012 setInternalState(that, { 5013 buffer: buffer, 5014 byteOffset: byteOffset, 5015 byteLength: byteLength, 5016 length: length, 5017 view: new DataView(buffer) 5018 }); 5019 5020 while (index < length) addElement(that, index++); 5021 }); 5022 if (objectSetPrototypeOf) objectSetPrototypeOf(TypedArrayConstructor, TypedArray); 5023 TypedArrayConstructorPrototype = TypedArrayConstructor.prototype = objectCreate(TypedArrayPrototype); 5024 } else if (typedArrayConstructorsRequireWrappers) { 5025 TypedArrayConstructor = wrapper(function (dummy, data, typedArrayOffset, $length) { 5026 anInstance(dummy, TypedArrayConstructorPrototype); 5027 return inheritIfRequired(function () { 5028 if (!isObject(data)) return new NativeTypedArrayConstructor(toIndex(data)); 5029 if (isArrayBuffer(data)) return $length !== undefined ? new NativeTypedArrayConstructor(data, toOffset(typedArrayOffset, BYTES), $length) : typedArrayOffset !== undefined ? new NativeTypedArrayConstructor(data, toOffset(typedArrayOffset, BYTES)) : new NativeTypedArrayConstructor(data); 5030 if (isTypedArray(data)) return fromList(TypedArrayConstructor, data); 5031 return functionCall(typedArrayFrom, TypedArrayConstructor, data); 5032 }(), dummy, TypedArrayConstructor); 5033 }); 5034 if (objectSetPrototypeOf) objectSetPrototypeOf(TypedArrayConstructor, TypedArray);
5035 forEach(getOwnPropertyNames(NativeTypedArrayConstructor), function (key) { 5036 if (!(key in TypedArrayConstructor)) { 5037 createNonEnumerableProperty(TypedArrayConstructor, key, NativeTypedArrayConstructor[key]); 5038 } 5039 }); 5040 TypedArrayConstructor.prototype = TypedArrayConstructorPrototype; 5041 } 5042 5043 if (TypedArrayConstructorPrototype.constructor !== TypedArrayConstructor) { 5044 createNonEnumerableProperty(TypedArrayConstructorPrototype, 'constructor', TypedArrayConstructor); 5045 } 5046 5047 createNonEnumerableProperty(TypedArrayConstructorPrototype, TYPED_ARRAY_CONSTRUCTOR, TypedArrayConstructor); 5048 5049 if (TYPED_ARRAY_TAG) { 5050 createNonEnumerableProperty(TypedArrayConstructorPrototype, TYPED_ARRAY_TAG, CONSTRUCTOR_NAME); 5051 } 5052 5053 exported[CONSTRUCTOR_NAME] = TypedArrayConstructor; 5054 _export({ 5055 global: true, 5056 forced: TypedArrayConstructor != NativeTypedArrayConstructor, 5057 sham: !NATIVE_ARRAY_BUFFER_VIEWS 5058 }, exported); 5059 5060 if (!(BYTES_PER_ELEMENT in TypedArrayConstructor)) { 5061 createNonEnumerableProperty(TypedArrayConstructor, BYTES_PER_ELEMENT, BYTES); 5062 } 5063 5064 if (!(BYTES_PER_ELEMENT in TypedArrayConstructorPrototype)) { 5065 createNonEnumerableProperty(TypedArrayConstructorPrototype, BYTES_PER_ELEMENT, BYTES); 5066 } 5067 5068 setSpecies(CONSTRUCTOR_NAME); 5069 }; 5070 } else module.exports = function () { 5071 /* empty */ 5072 }; 5073 }); 5074 5075 // `Float32Array` constructor 5076 // https://tc39.es/ecma262/#sec-typedarray-objects 5077 5078 5079 typedArrayConstructor('Float32', function (init) { 5080 return function Float32Array(data, byteOffset, length) { 5081 return init(this, data, byteOffset, length); 5082 }; 5083 }); 5084 5085 // `Float64Array` constructor 5086 // https://tc39.es/ecma262/#sec-typedarray-objects 5087 5088 5089 typedArrayConstructor('Float64', function (init) { 5090 return function Float64Array(data, byteOffset, length) { 5091 return init(this, data, byteOffset, length); 5092 }; 5093 }); 5094 5095 // `Int8Array` constructor 5096 // https://tc39.es/ecma262/#sec-typedarray-objects 5097 5098 5099 typedArrayConstructor('Int8', function (init) { 5100 return function Int8Array(data, byteOffset, length) { 5101 return init(this, data, byteOffset, length); 5102 }; 5103 }); 5104 5105 // `Int16Array` constructor 5106 // https://tc39.es/ecma262/#sec-typedarray-objects 5107 5108 5109 typedArrayConstructor('Int16', function (init) { 5110 return function Int16Array(data, byteOffset, length) { 5111 return init(this, data, byteOffset, length); 5112 }; 5113 }); 5114 5115 // `Int32Array` constructor 5116 // https://tc39.es/ecma262/#sec-typedarray-objects 5117 5118 5119 typedArrayConstructor('Int32', function (init) { 5120 return function Int32Array(data, byteOffset, length) { 5121 return init(this, data, byteOffset, length); 5122 }; 5123 }); 5124 5125 // `Uint8Array` constructor 5126 // https://tc39.es/ecma262/#sec-typedarray-objects 5127 5128 5129 typedArrayConstructor('Uint8', function (init) { 5130 return function Uint8Array(data, byteOffset, length) { 5131 return init(this, data, byteOffset, length); 5132 }; 5133 }); 5134 5135 // `Uint8ClampedArray` constructor 5136 // https://tc39.es/ecma262/#sec-typedarray-objects 5137 5138 5139 typedArrayConstructor('Uint8', function (init) { 5140 return function Uint8ClampedArray(data, byteOffset, length) { 5141 return init(this, data, byteOffset, length); 5142 }; 5143 }, true); 5144 5145 // `Uint16Array` constructor 5146 // https://tc39.es/ecma262/#sec-typedarray-objects 5147 5148 5149 typedArrayConstructor('Uint16', function (init) { 5150 return function Uint16Array(data, byteOffset, length) { 5151 return init(this, data, byteOffset, length); 5152 }; 5153 }); 5154 5155 // `Uint32Array` constructor 5156 // https://tc39.es/ecma262/#sec-typedarray-objects 5157 5158 5159 typedArrayConstructor('Uint32', function (init) { 5160 return function Uint32Array(data, byteOffset, length) { 5161 return init(this, data, byteOffset, length); 5162 }; 5163 }); 5164 5165 var aTypedArray$1 = arrayBufferViewCore.aTypedArray; 5166 var exportTypedArrayMethod$1 = arrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.at` method 5167 // https://github.com/tc39/proposal-relative-indexing-method 5168 5169 exportTypedArrayMethod$1('at', function at(index) { 5170 var O = aTypedArray$1(this); 5171 var len = lengthOfArrayLike(O); 5172 var relativeIndex = toIntegerOrInfinity(index); 5173 var k = relativeIndex >= 0 ? relativeIndex : len + relativeIndex; 5174 return k < 0 || k >= len ? undefined : O[k]; 5175 }); 5176 5177 var exportTypedArrayStaticMethod$1 = arrayBufferViewCore.exportTypedArrayStaticMethod; 5178 5179 // `%TypedArray%.from` method 5180 // https://tc39.es/ecma262/#sec-%typedarray%.from 5181 5182 5183 exportTypedArrayStaticMethod$1('from', typedArrayFrom, typedArrayConstructorsRequireWrappers); 5184 5185 var aTypedArrayConstructor$2 = arrayBufferViewCore.aTypedArrayConstructor; 5186 var exportTypedArrayStaticMethod$2 = arrayBufferViewCore.exportTypedArrayStaticMethod; // `%TypedArray%.of` method 5187 // https://tc39.es/ecma262/#sec-%typedarray%.of 5188 5189 exportTypedArrayStaticMethod$2('of', function of() 5190 /* ...items */ 5191 { 5192 var index = 0; 5193 var length = arguments.length; 5194 var result = new (aTypedArrayConstructor$2(this))(length); 5195 5196 while (length > index) result[index] = arguments[index++]; 5197 5198 return result; 5199 }, typedArrayConstructorsRequireWrappers); 5200 5201 var floor$4 = Math.floor; 5202 5203 var mergeSort = function (array, comparefn) { 5204 var length = array.length; 5205 var middle = floor$4(length / 2); 5206 return length < 8 ? insertionSort(array, comparefn) : merge(array, mergeSort(arraySliceSimple(array, 0, middle), comparefn), mergeSort(arraySliceSimple(array, middle), comparefn), comparefn); 5207 }; 5208 5209 var insertionSort = function (array, comparefn) { 5210 var length = array.length; 5211 var i = 1; 5212 var element, j; 5213 5214 while (i < length) { 5215 j = i; 5216 element = array[i]; 5217 5218 while (j && comparefn(array[j - 1], element) > 0) { 5219 array[j] = array[--j]; 5220 } 5221 5222 if (j !== i++) array[j] = element; 5223 } 5224 5225 return array; 5226 }; 5227 5228 var merge = function (array, left, right, comparefn) { 5229 var llength = left.length; 5230 var rlength = right.length; 5231 var lindex = 0; 5232 var rindex = 0; 5233 5234 while (lindex < llength || rindex < rlength) { 5235 array[lindex + rindex] = lindex < llength && rindex < rlength ? comparefn(left[lindex], right[rindex]) <= 0 ? left[lindex++] : right[rindex++] : lindex < llength ? left[lindex++] : right[rindex++]; 5236 } 5237 5238 return array; 5239 }; 5240 5241 var arraySort = mergeSort; 5242 5243 var firefox = engineUserAgent.match(/firefox\/(\d+)/i); 5244 var engineFfVersion = !!firefox && +firefox[1]; 5245 5246 var engineIsIeOrEdge = /MSIE|Trident/.test(engineUserAgent); 5247
vendor: 4,612 bytes, lines 5248-5392
5248 var webkit = engineUserAgent.match(/AppleWebKit\/(\d+)\./); 5249 var engineWebkitVersion = !!webkit && +webkit[1]; 5250 5251 var Array$5 = global_1.Array; 5252 var aTypedArray$2 = arrayBufferViewCore.aTypedArray; 5253 var exportTypedArrayMethod$2 = arrayBufferViewCore.exportTypedArrayMethod; 5254 var Uint16Array = global_1.Uint16Array; 5255 var un$Sort = Uint16Array && functionUncurryThis(Uint16Array.prototype.sort); // WebKit 5256 5257 var ACCEPT_INCORRECT_ARGUMENTS = !!un$Sort && !(fails(function () { 5258 un$Sort(new Uint16Array(2), null); 5259 }) && fails(function () { 5260 un$Sort(new Uint16Array(2), {}); 5261 })); 5262 var STABLE_SORT = !!un$Sort && !fails(function () { 5263 // feature detection can be too slow, so check engines versions 5264 if (engineV8Version) return engineV8Version < 74; 5265 if (engineFfVersion) return engineFfVersion < 67; 5266 if (engineIsIeOrEdge) return true; 5267 if (engineWebkitVersion) return engineWebkitVersion < 602; 5268 var array = new Uint16Array(516); 5269 var expected = Array$5(516); 5270 var index, mod; 5271 5272 for (index = 0; index < 516; index++) { 5273 mod = index % 4; 5274 array[index] = 515 - index; 5275 expected[index] = index - 2 * mod + 3; 5276 } 5277 5278 un$Sort(array, function (a, b) { 5279 return (a / 4 | 0) - (b / 4 | 0); 5280 }); 5281 5282 for (index = 0; index < 516; index++) { 5283 if (array[index] !== expected[index]) return true; 5284 } 5285 }); 5286 5287 var getSortCompare = function (comparefn) { 5288 return function (x, y) { 5289 if (comparefn !== undefined) return +comparefn(x, y) || 0; // eslint-disable-next-line no-self-compare -- NaN check 5290 5291 if (y !== y) return -1; // eslint-disable-next-line no-self-compare -- NaN check 5292 5293 if (x !== x) return 1; 5294 if (x === 0 && y === 0) return 1 / x > 0 && 1 / y < 0 ? 1 : -1; 5295 return x > y; 5296 }; 5297 }; // `%TypedArray%.prototype.sort` method 5298 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.sort 5299 5300 5301 exportTypedArrayMethod$2('sort', function sort(comparefn) { 5302 if (comparefn !== undefined) aCallable(comparefn); 5303 if (STABLE_SORT) return un$Sort(this, comparefn); 5304 return arraySort(aTypedArray$2(this), getSortCompare(comparefn)); 5305 }, !STABLE_SORT || ACCEPT_INCORRECT_ARGUMENTS); 5306 5307 // iterable DOM collections 5308 // flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods 5309 var domIterables = { 5310 CSSRuleList: 0, 5311 CSSStyleDeclaration: 0, 5312 CSSValueList: 0, 5313 ClientRectList: 0, 5314 DOMRectList: 0, 5315 DOMStringList: 0, 5316 DOMTokenList: 1, 5317 DataTransferItemList: 0, 5318 FileList: 0, 5319 HTMLAllCollection: 0, 5320 HTMLCollection: 0, 5321 HTMLFormElement: 0, 5322 HTMLSelectElement: 0, 5323 MediaList: 0, 5324 MimeTypeArray: 0, 5325 NamedNodeMap: 0, 5326 NodeList: 1, 5327 PaintRequestList: 0, 5328 Plugin: 0, 5329 PluginArray: 0, 5330 SVGLengthList: 0, 5331 SVGNumberList: 0, 5332 SVGPathSegList: 0, 5333 SVGPointList: 0, 5334 SVGStringList: 0, 5335 SVGTransformList: 0, 5336 SourceBufferList: 0, 5337 StyleSheetList: 0, 5338 TextTrackCueList: 0, 5339 TextTrackList: 0, 5340 TouchList: 0 5341 }; 5342 5343 // in old WebKit versions, `element.classList` is not an instance of global `DOMTokenList` 5344 5345 5346 var classList = documentCreateElement('span').classList; 5347 var DOMTokenListPrototype = classList && classList.constructor && classList.constructor.prototype; 5348 var domTokenListPrototype = DOMTokenListPrototype === Object.prototype ? undefined : DOMTokenListPrototype; 5349 5350 var PROPER_FUNCTION_NAME$1 = functionName.PROPER; 5351 var CONFIGURABLE_FUNCTION_NAME$1 = functionName.CONFIGURABLE; 5352 var IteratorPrototype$2 = iteratorsCore.IteratorPrototype; 5353 var BUGGY_SAFARI_ITERATORS$1 = iteratorsCore.BUGGY_SAFARI_ITERATORS; 5354 var ITERATOR$4 = wellKnownSymbol('iterator'); 5355 var KEYS = 'keys'; 5356 var VALUES = 'values'; 5357 var ENTRIES = 'entries'; 5358 5359 var returnThis$1 = function () { 5360 return this; 5361 }; 5362 5363 var defineIterator = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) { 5364 createIteratorConstructor(IteratorConstructor, NAME, next); 5365 5366 var getIterationMethod = function (KIND) { 5367 if (KIND === DEFAULT && defaultIterator) return defaultIterator; 5368 if (!BUGGY_SAFARI_ITERATORS$1 && KIND in IterablePrototype) return IterablePrototype[KIND]; 5369 5370 switch (KIND) { 5371 case KEYS: 5372 return function keys() { 5373 return new IteratorConstructor(this, KIND); 5374 }; 5375 5376 case VALUES: 5377 return function values() { 5378 return new IteratorConstructor(this, KIND); 5379 }; 5380 5381 case ENTRIES: 5382 return function entries() { 5383 return new IteratorConstructor(this, KIND); 5384 }; 5385 } 5386 5387 return function () { 5388 return new IteratorConstructor(this); 5389 }; 5390 }; 5391 5392 var TO_STRING_TAG = NAME + ' Iterator';
5393 var INCORRECT_VALUES_NAME = false; 5394 var IterablePrototype = Iterable.prototype; 5395 var nativeIterator = IterablePrototype[ITERATOR$4] || IterablePrototype['@@iterator'] || DEFAULT && IterablePrototype[DEFAULT]; 5396 var defaultIterator = !BUGGY_SAFARI_ITERATORS$1 && nativeIterator || getIterationMethod(DEFAULT); 5397 var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator; 5398 var CurrentIteratorPrototype, methods, KEY; // fix native 5399 5400 if (anyNativeIterator) { 5401 CurrentIteratorPrototype = objectGetPrototypeOf(anyNativeIterator.call(new Iterable())); 5402 5403 if (CurrentIteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) { 5404 if (objectGetPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype$2) { 5405 if (objectSetPrototypeOf) { 5406 objectSetPrototypeOf(CurrentIteratorPrototype, IteratorPrototype$2); 5407 } else if (!isCallable(CurrentIteratorPrototype[ITERATOR$4])) { 5408 redefine(CurrentIteratorPrototype, ITERATOR$4, returnThis$1); 5409 } 5410 } // Set @@toStringTag to native iterators 5411 5412 5413 setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true, true); 5414 } 5415 } // fix Array.prototype.{ values, @@iterator }.name in V8 / FF 5416 5417 5418 if (PROPER_FUNCTION_NAME$1 && DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) { 5419 if (CONFIGURABLE_FUNCTION_NAME$1) { 5420 createNonEnumerableProperty(IterablePrototype, 'name', VALUES); 5421 } else { 5422 INCORRECT_VALUES_NAME = true; 5423 5424 defaultIterator = function values() { 5425 return functionCall(nativeIterator, this); 5426 }; 5427 } 5428 } // export additional methods 5429 5430 5431 if (DEFAULT) { 5432 methods = { 5433 values: getIterationMethod(VALUES), 5434 keys: IS_SET ? defaultIterator : getIterationMethod(KEYS), 5435 entries: getIterationMethod(ENTRIES) 5436 }; 5437 if (FORCED) for (KEY in methods) { 5438 if (BUGGY_SAFARI_ITERATORS$1 || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) { 5439 redefine(IterablePrototype, KEY, methods[KEY]); 5440 } 5441 } else _export({ 5442 target: NAME, 5443 proto: true, 5444 forced: BUGGY_SAFARI_ITERATORS$1 || INCORRECT_VALUES_NAME 5445 }, methods); 5446 } // define iterator 5447 5448 5449 if (IterablePrototype[ITERATOR$4] !== defaultIterator) { 5450 redefine(IterablePrototype, ITERATOR$4, defaultIterator, { 5451 name: DEFAULT 5452 }); 5453 } 5454 5455 iterators[NAME] = defaultIterator; 5456 return methods; 5457 }; 5458 5459 var ARRAY_ITERATOR = 'Array Iterator'; 5460 var setInternalState$2 = internalState.set; 5461 var getInternalState$3 = internalState.getterFor(ARRAY_ITERATOR); // `Array.prototype.entries` method 5462 // https://tc39.es/ecma262/#sec-array.prototype.entries 5463 // `Array.prototype.keys` method 5464 // https://tc39.es/ecma262/#sec-array.prototype.keys 5465 // `Array.prototype.values` method 5466 // https://tc39.es/ecma262/#sec-array.prototype.values 5467 // `Array.prototype[@@iterator]` method 5468 // https://tc39.es/ecma262/#sec-array.prototype-@@iterator 5469 // `CreateArrayIterator` internal method 5470 // https://tc39.es/ecma262/#sec-createarrayiterator 5471 5472 var es_array_iterator = defineIterator(Array, 'Array', function (iterated, kind) { 5473 setInternalState$2(this, { 5474 type: ARRAY_ITERATOR, 5475 target: toIndexedObject(iterated), 5476 // target 5477 index: 0, 5478 // next index 5479 kind: kind // kind 5480 5481 }); // `%ArrayIteratorPrototype%.next` method 5482 // https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next 5483 }, function () { 5484 var state = getInternalState$3(this); 5485 var target = state.target; 5486 var kind = state.kind; 5487 var index = state.index++; 5488 5489 if (!target || index >= target.length) { 5490 state.target = undefined; 5491 return { 5492 value: undefined, 5493 done: true 5494 }; 5495 } 5496 5497 if (kind == 'keys') return { 5498 value: index, 5499 done: false 5500 }; 5501 if (kind == 'values') return { 5502 value: target[index], 5503 done: false 5504 }; 5505 return { 5506 value: [index, target[index]], 5507 done: false 5508 }; 5509 }, 'values'); // argumentsList[@@iterator] is %ArrayProto_values% 5510 // https://tc39.es/ecma262/#sec-createunmappedargumentsobject 5511 // https://tc39.es/ecma262/#sec-createmappedargumentsobject 5512 5513 iterators.Arguments = iterators.Array; // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables 5514 5515 addToUnscopables('keys'); 5516 addToUnscopables('values'); 5517 addToUnscopables('entries'); 5518 5519 var ITERATOR$5 = wellKnownSymbol('iterator'); 5520 var TO_STRING_TAG$5 = wellKnownSymbol('toStringTag'); 5521 var ArrayValues = es_array_iterator.values; 5522 5523 var handlePrototype = function (CollectionPrototype, COLLECTION_NAME) { 5524 if (CollectionPrototype) { 5525 // some Chrome versions have non-configurable methods on DOMTokenList 5526 if (CollectionPrototype[ITERATOR$5] !== ArrayValues) try { 5527 createNonEnumerableProperty(CollectionPrototype, ITERATOR$5, ArrayValues); 5528 } catch (error) { 5529 CollectionPrototype[ITERATOR$5] = ArrayValues; 5530 } 5531 5532 if (!CollectionPrototype[TO_STRING_TAG$5]) { 5533 createNonEnumerableProperty(CollectionPrototype, TO_STRING_TAG$5, COLLECTION_NAME); 5534 } 5535 5536 if (domIterables[COLLECTION_NAME]) for (var METHOD_NAME in es_array_iterator) { 5537 // some Chrome versions have non-configurable methods on DOMTokenList 5538 if (CollectionPrototype[METHOD_NAME] !== es_array_iterator[METHOD_NAME]) try { 5539 createNonEnumerableProperty(CollectionPrototype, METHOD_NAME, es_array_iterator[METHOD_NAME]); 5540 } catch (error) { 5541 CollectionPrototype[METHOD_NAME] = es_array_iterator[METHOD_NAME]; 5542 } 5543 } 5544 } 5545 }; 5546 5547 for (var COLLECTION_NAME in domIterables) { 5548 handlePrototype(global_1[COLLECTION_NAME] && global_1[COLLECTION_NAME].prototype, COLLECTION_NAME); 5549 } 5550 5551 handlePrototype(domTokenListPrototype, 'DOMTokenList'); 5552 5553 var FunctionPrototype$2 = Function.prototype; 5554 var apply = FunctionPrototype$2.apply; 5555 var bind$2 = FunctionPrototype$2.bind; 5556 var call$2 = FunctionPrototype$2.call; // eslint-disable-next-line es/no-reflect -- safe 5557 5558 var functionApply = typeof Reflect == 'object' && Reflect.apply || (bind$2 ? call$2.bind(apply) : function () { 5559 return call$2.apply(apply, arguments); 5560 }); 5561 5562 var arraySlice = functionUncurryThis([].slice); 5563 5564 var engineIsIos = /(?:ipad|iphone|ipod).*applewebkit/i.test(engineUserAgent); 5565 5566 var engineIsNode = classofRaw(global_1.process) == 'process'; 5567 5568 var set$2 = global_1.setImmediate; 5569 var clear = global_1.clearImmediate; 5570 var process$1 = global_1.process; 5571 var Dispatch = global_1.Dispatch; 5572 var Function$1 = global_1.Function; 5573 var MessageChannel = global_1.MessageChannel; 5574 var String$5 = global_1.String; 5575 var counter = 0; 5576 var queue = {}; 5577 var ONREADYSTATECHANGE = 'onreadystatechange'; 5578 var location, defer, channel, port; 5579 5580 try { 5581 // Deno throws a ReferenceError on `location` access without `--location` flag 5582 location = global_1.location; 5583 } catch (error) { 5584 /* empty */ 5585 } 5586 5587 var run = function (id) { 5588 if (hasOwnProperty_1(queue, id)) { 5589 var fn = queue[id]; 5590 delete queue[id]; 5591 fn(); 5592 } 5593 }; 5594 5595 var runner = function (id) { 5596 return function () { 5597 run(id); 5598 }; 5599 }; 5600 5601 var listener = function (event) { 5602 run(event.data); 5603 }; 5604 5605 var post = function (id) { 5606 // old engines have not location.origin 5607 global_1.postMessage(String$5(id), location.protocol + '//' + location.host); 5608 }; // Node.js 0.9+ & IE10+ has setImmediate, otherwise: 5609 5610 5611 if (!set$2 || !clear) { 5612 set$2 = function setImmediate(fn) { 5613 var args = arraySlice(arguments, 1); 5614 5615 queue[++counter] = function () { 5616 functionApply(isCallable(fn) ? fn : Function$1(fn), undefined, args); 5617 }; 5618 5619 defer(counter); 5620 return counter; 5621 }; 5622 5623 clear = function clearImmediate(id) { 5624 delete queue[id]; 5625 }; // Node.js 0.8- 5626 5627 5628 if (engineIsNode) { 5629 defer = function (id) { 5630 process$1.nextTick(runner(id)); 5631 }; // Sphere (JS game engine) Dispatch API 5632 5633 } else if (Dispatch && Dispatch.now) { 5634 defer = function (id) { 5635 Dispatch.now(runner(id)); 5636 }; // Browsers with MessageChannel, includes WebWorkers 5637 // except iOS - https://github.com/zloirock/core-js/issues/624 5638 5639 } else if (MessageChannel && !engineIsIos) { 5640 channel = new MessageChannel(); 5641 port = channel.port2; 5642 channel.port1.onmessage = listener; 5643 defer = functionBindContext(port.postMessage, port); // Browsers with postMessage, skip WebWorkers 5644 // IE8 has postMessage, but it's sync & typeof its postMessage is 'object' 5645 } else if (global_1.addEventListener && isCallable(global_1.postMessage) && !global_1.importScripts && location && location.protocol !== 'file:' && !fails(post)) { 5646 defer = post; 5647 global_1.addEventListener('message', listener, false); // IE8- 5648 } else if (ONREADYSTATECHANGE in documentCreateElement('script')) { 5649 defer = function (id) { 5650 html.appendChild(documentCreateElement('script'))[ONREADYSTATECHANGE] = function () { 5651 html.removeChild(this); 5652 run(id); 5653 }; 5654 }; // Rest old browsers 5655 5656 } else { 5657 defer = function (id) { 5658 setTimeout(runner(id), 0); 5659 }; 5660 } 5661 } 5662 5663 var task = { 5664 set: set$2, 5665 clear: clear 5666 }; 5667 5668 var FORCED = !global_1.setImmediate || !global_1.clearImmediate; // http://w3c.github.io/setImmediate/ 5669 5670 _export({ 5671 global: true, 5672 bind: true, 5673 enumerable: true, 5674 forced: FORCED 5675 }, { 5676 // `setImmediate` method 5677 // http://w3c.github.io/setImmediate/#si-setImmediate 5678 setImmediate: task.set, 5679 // `clearImmediate` method 5680 // http://w3c.github.io/setImmediate/#si-clearImmediate 5681 clearImmediate: task.clear 5682 }); 5683 5684 var engineIsIosPebble = /ipad|iphone|ipod/i.test(engineUserAgent) && global_1.Pebble !== undefined; 5685 5686 var engineIsWebosWebkit = /web0s(?!.*chrome)/i.test(engineUserAgent); 5687 5688 var getOwnPropertyDescriptor$2 = objectGetOwnPropertyDescriptor.f; 5689 5690 var macrotask = task.set; 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 var MutationObserver = global_1.MutationObserver || global_1.WebKitMutationObserver; 5701 var document$2 = global_1.document; 5702 var process$2 = global_1.process; 5703 var Promise = global_1.Promise; // Node.js 11 shows ExperimentalWarning on getting `queueMicrotask` 5704 5705 var queueMicrotaskDescriptor = getOwnPropertyDescriptor$2(global_1, 'queueMicrotask'); 5706 var queueMicrotask = queueMicrotaskDescriptor && queueMicrotaskDescriptor.value; 5707 var flush, head, last, notify, toggle, node, promise, then; // modern engines have queueMicrotask method 5708 5709 if (!queueMicrotask) { 5710 flush = function () { 5711 var parent, fn; 5712 if (engineIsNode && (parent = process$2.domain)) parent.exit(); 5713 5714 while (head) { 5715 fn = head.fn; 5716 head = head.next; 5717 5718 try { 5719 fn(); 5720 } catch (error) { 5721 if (head) notify();else last = undefined; 5722 throw error; 5723 } 5724 } 5725 5726 last = undefined; 5727 if (parent) parent.enter(); 5728 }; // browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339 5729 // also except WebOS Webkit https://github.com/zloirock/core-js/issues/898 5730 5731 5732 if (!engineIsIos && !engineIsNode && !engineIsWebosWebkit && MutationObserver && document$2) { 5733 toggle = true; 5734 node = document$2.createTextNode(''); 5735 new MutationObserver(flush).observe(node, { 5736 characterData: true 5737 }); 5738 5739 notify = function () { 5740 node.data = toggle = !toggle; 5741 }; // environments with maybe non-completely correct, but existent Promise 5742 5743 } else if (!engineIsIosPebble && Promise && Promise.resolve) { 5744 // Promise.resolve without an argument throws an error in LG WebOS 2 5745 promise = Promise.resolve(undefined); // workaround of WebKit ~ iOS Safari 10.1 bug 5746 5747 promise.constructor = Promise; 5748 then = functionBindContext(promise.then, promise); 5749 5750 notify = function () { 5751 then(flush); 5752 }; // Node.js without promises 5753 5754 } else if (engineIsNode) { 5755 notify = function () { 5756 process$2.nextTick(flush); 5757 }; // for other environments - macrotask based on: 5758 // - setImmediate 5759 // - MessageChannel 5760 // - window.postMessag 5761 // - onreadystatechange 5762 // - setTimeout 5763 5764 } else { 5765 // strange IE + webpack dev server bug - use .bind(global) 5766 macrotask = functionBindContext(macrotask, global_1); 5767 5768 notify = function () { 5769 macrotask(flush); 5770 }; 5771 } 5772 } 5773 5774 var microtask = queueMicrotask || function (fn) { 5775 var task$$1 = { 5776 fn: fn, 5777 next: undefined 5778 }; 5779 if (last) last.next = task$$1; 5780 5781 if (!head) { 5782 head = task$$1; 5783 notify(); 5784 } 5785 5786 last = task$$1; 5787 }; 5788 5789 var process$3 = global_1.process; // `queueMicrotask` method 5790 // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-queuemicrotask 5791 5792 _export({ 5793 global: true, 5794 enumerable: true, 5795 noTargetGet: true 5796 }, { 5797 queueMicrotask: function queueMicrotask(fn) { 5798 var domain = engineIsNode && process$3.domain; 5799 microtask(domain ? domain.bind(fn) : fn); 5800 } 5801 }); 5802 5803 // File generated automatically. Don't modify it. 5804 5805}((this.window = this.window || {}))); 5806 5807 5808 5809if (window._main_polyfill_core) 5810{ 5811 console.warn('main.polyfill.core is loaded more than once on this page'); 5812} 5813 5814window._main_polyfill_core = true; 5815 5816 5817(function (exports) { 5818 'use strict'; 5819 5820 var bxTmp = window.BX; 5821 5822 window.BX = function (node) { 5823 if (window.BX.type.isNotEmptyString(node)) { 5824 return document.getElementById(node); 5825 } 5826 5827 if (window.BX.type.isDomNode(node)) { 5828 return node; 5829 } 5830 5831 if (window.BX.type.isFunction(node)) { 5832 return window.BX.ready(node); 5833 } 5834 5835 return null; 5836 }; 5837 5838 if (bxTmp) {
5839 Object.keys(bxTmp).forEach(key => { 5840 window.BX[key] = bxTmp[key]; 5841 }); 5842 } 5843 5844 exports = window.BX; 5845 5846 /** 5847 * Gets object.toString result 5848 * @param value 5849 * @return {string} 5850 */ 5851 function getTag(value) { 5852 return Object.prototype.toString.call(value); 5853 } 5854 5855 const objectCtorString = Function.prototype.toString.call(Object); 5856 /** 5857 * @memberOf BX 5858 */ 5859 5860 let Type = /*#__PURE__*/function () { 5861 function Type() { 5862 babelHelpers.classCallCheck(this, Type); 5863 } 5864 5865 babelHelpers.createClass(Type, null, [{ 5866 key: "isString", 5867 5868 /** 5869 * Checks that value is string 5870 * @param value 5871 * @return {boolean} 5872 */ 5873 value: function isString(value) { 5874 return typeof value === 'string'; 5875 } 5876 /** 5877 * Returns true if a value is not empty string 5878 * @param value 5879 * @returns {boolean} 5880 */ 5881 5882 }, { 5883 key: "isStringFilled", 5884 value: function isStringFilled(value) { 5885 return this.isString(value) && value !== ''; 5886 } 5887 /** 5888 * Checks that value is function 5889 * @param value 5890 * @return {boolean} 5891 */ 5892 5893 }, { 5894 key: "isFunction", 5895 value: function isFunction(value) { 5896 return typeof value === 'function'; 5897 } 5898 /** 5899 * Checks that value is object 5900 * @param value 5901 * @return {boolean} 5902 */ 5903 5904 }, { 5905 key: "isObject", 5906 value: function isObject(value) { 5907 return !!value && (typeof value === 'object' || typeof value === 'function'); 5908 } 5909 /** 5910 * Checks that value is object like 5911 * @param value 5912 * @return {boolean} 5913 */ 5914 5915 }, { 5916 key: "isObjectLike", 5917 value: function isObjectLike(value) { 5918 return !!value && typeof value === 'object'; 5919 } 5920 /** 5921 * Checks that value is plain object 5922 * @param value 5923 * @return {boolean} 5924 */ 5925 5926 }, { 5927 key: "isPlainObject", 5928 value: function isPlainObject(value) { 5929 if (!Type.isObjectLike(value) || getTag(value) !== '[object Object]') { 5930 return false; 5931 } 5932 5933 const proto = Object.getPrototypeOf(value); 5934 5935 if (proto === null) { 5936 return true; 5937 } 5938 5939 const ctor = proto.hasOwnProperty('constructor') && proto.constructor; 5940 return typeof ctor === 'function' && Function.prototype.toString.call(ctor) === objectCtorString; 5941 } 5942 /** 5943 * Checks that value is boolean 5944 * @param value 5945 * @return {boolean} 5946 */ 5947 5948 }, { 5949 key: "isBoolean", 5950 value: function isBoolean(value) { 5951 return value === true || value === false; 5952 } 5953 /** 5954 * Checks that value is number 5955 * @param value 5956 * @return {boolean} 5957 */ 5958 5959 }, { 5960 key: "isNumber", 5961 value: function isNumber(value) { 5962 return !Number.isNaN(value) && typeof value === 'number'; 5963 } 5964 /** 5965 * Checks that value is integer 5966 * @param value 5967 * @return {boolean} 5968 */ 5969 5970 }, { 5971 key: "isInteger", 5972 value: function isInteger(value) { 5973 return Type.isNumber(value) && value % 1 === 0; 5974 } 5975 /** 5976 * Checks that value is float 5977 * @param value 5978 * @return {boolean} 5979 */ 5980 5981 }, { 5982 key: "isFloat", 5983 value: function isFloat(value) { 5984 return Type.isNumber(value) && !Type.isInteger(value); 5985 } 5986 /** 5987 * Checks that value is nil 5988 * @param value 5989 * @return {boolean} 5990 */ 5991 5992 }, { 5993 key: "isNil", 5994 value: function isNil(value) { 5995 return value === null || value === undefined; 5996 } 5997 /** 5998 * Checks that value is array 5999 * @param value 6000 * @return {boolean} 6001 */ 6002 6003 }, { 6004 key: "isArray", 6005 value: function isArray(value) { 6006 return !Type.isNil(value) && Array.isArray(value); 6007 } 6008 /** 6009 * Returns true if a value is an array and it has at least one element 6010 * @param value 6011 * @returns {boolean} 6012 */ 6013 6014 }, { 6015 key: "isArrayFilled", 6016 value: function isArrayFilled(value) { 6017 return this.isArray(value) && value.length > 0; 6018 } 6019 /** 6020 * Checks that value is array like 6021 * @param value 6022 * @return {boolean} 6023 */ 6024 6025 }, { 6026 key: "isArrayLike", 6027 value: function isArrayLike(value) { 6028 return !Type.isNil(value) && !Type.isFunction(value) && value.length > -1 && value.length <= Number.MAX_SAFE_INTEGER; 6029 } 6030 /** 6031 * Checks that value is Date 6032 * @param value 6033 * @return {boolean} 6034 */ 6035 6036 }, { 6037 key: "isDate", 6038 value: function isDate(value) { 6039 return Type.isObjectLike(value) && getTag(value) === '[object Date]'; 6040 } 6041 /** 6042 * Checks that is DOM node 6043 * @param value 6044 * @return {boolean} 6045 */ 6046 6047 }, { 6048 key: "isDomNode", 6049 value: function isDomNode(value) { 6050 return Type.isObjectLike(value) && !Type.isPlainObject(value) && 'nodeType' in value; 6051 } 6052 /** 6053 * Checks that value is element node 6054 * @param value 6055 * @return {boolean} 6056 */ 6057 6058 }, { 6059 key: "isElementNode", 6060 value: function isElementNode(value) { 6061 return Type.isDomNode(value) && value.nodeType === Node.ELEMENT_NODE; 6062 } 6063 /** 6064 * Checks that value is text node 6065 * @param value 6066 * @return {boolean} 6067 */ 6068 6069 }, { 6070 key: "isTextNode", 6071 value: function isTextNode(value) { 6072 return Type.isDomNode(value) && value.nodeType === Node.TEXT_NODE; 6073 } 6074 /** 6075 * Checks that value is Map 6076 * @param value 6077 * @return {boolean} 6078 */ 6079 6080 }, { 6081 key: "isMap", 6082 value: function isMap(value) { 6083 return Type.isObjectLike(value) && getTag(value) === '[object Map]'; 6084 } 6085 /** 6086 * Checks that value is Set 6087 * @param value 6088 * @return {boolean} 6089 */ 6090 6091 }, { 6092 key: "isSet", 6093 value: function isSet(value) { 6094 return Type.isObjectLike(value) && getTag(value) === '[object Set]'; 6095 } 6096 /** 6097 * Checks that value is WeakMap 6098 * @param value 6099 * @return {boolean} 6100 */ 6101 6102 }, { 6103 key: "isWeakMap", 6104 value: function isWeakMap(value) { 6105 return Type.isObjectLike(value) && getTag(value) === '[object WeakMap]'; 6106 } 6107 /** 6108 * Checks that value is WeakSet 6109 * @param value 6110 * @return {boolean} 6111 */ 6112 6113 }, { 6114 key: "isWeakSet", 6115 value: function isWeakSet(value) { 6116 return Type.isObjectLike(value) && getTag(value) === '[object WeakSet]'; 6117 } 6118 /** 6119 * Checks that value is prototype 6120 * @param value 6121 * @return {boolean} 6122 */ 6123 6124 }, { 6125 key: "isPrototype", 6126 value: function isPrototype(value) { 6127 return (typeof (value && value.constructor) === 'function' && value.constructor.prototype || Object.prototype) === value; 6128 } 6129 /** 6130 * Checks that value is regexp 6131 * @param value 6132 * @return {boolean} 6133 */ 6134 6135 }, { 6136 key: "isRegExp", 6137 value: function isRegExp(value) { 6138 return Type.isObjectLike(value) && getTag(value) === '[object RegExp]'; 6139 } 6140 /** 6141 * Checks that value is null 6142 * @param value 6143 * @return {boolean} 6144 */ 6145 6146 }, { 6147 key: "isNull", 6148 value: function isNull(value) { 6149 return value === null; 6150 } 6151 /** 6152 * Checks that value is undefined 6153 * @param value 6154 * @return {boolean} 6155 */ 6156 6157 }, { 6158 key: "isUndefined", 6159 value: function isUndefined(value) { 6160 return typeof value === 'undefined'; 6161 } 6162 /** 6163 * Checks that value is ArrayBuffer 6164 * @param value 6165 * @return {boolean} 6166 */ 6167 6168 }, { 6169 key: "isArrayBuffer", 6170 value: function isArrayBuffer(value) { 6171 return Type.isObjectLike(value) && getTag(value) === '[object ArrayBuffer]'; 6172 } 6173 /** 6174 * Checks that value is typed array 6175 * @param value 6176 * @return {boolean} 6177 */ 6178 6179 }, { 6180 key: "isTypedArray", 6181 value: function isTypedArray(value) { 6182 const regExpTypedTag = /^\[object (?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)]$/; 6183 return Type.isObjectLike(value) && regExpTypedTag.test(getTag(value)); 6184 } 6185 /** 6186 * Checks that value is Blob 6187 * @param value 6188 * @return {boolean} 6189 */ 6190 6191 }, { 6192 key: "isBlob", 6193 value: function isBlob(value) { 6194 return Type.isObjectLike(value) && Type.isNumber(value.size) && Type.isString(value.type) && Type.isFunction(value.slice); 6195 } 6196 /** 6197 * Checks that value is File 6198 * @param value 6199 * @return {boolean} 6200 */ 6201 6202 }, { 6203 key: "isFile", 6204 value: function isFile(value) { 6205 return Type.isBlob(value) && Type.isString(value.name) && (Type.isNumber(value.lastModified) || Type.isObjectLike(value.lastModifiedDate)); 6206 } 6207 /** 6208 * Checks that value is FormData 6209 * @param value 6210 * @return {boolean} 6211 */ 6212 6213 }, { 6214 key: "isFormData", 6215 value: function isFormData(value) { 6216 return value instanceof FormData; 6217 } 6218 }]); 6219 return Type; 6220 }(); 6221 6222 /** 6223 * @memberOf BX 6224 */ 6225 6226 let Reflection = /*#__PURE__*/function () { 6227 function Reflection() { 6228 babelHelpers.classCallCheck(this, Reflection); 6229 } 6230 6231 babelHelpers.createClass(Reflection, null, [{ 6232 key: "getClass", 6233 6234 /** 6235 * Gets link to function by function name 6236 * @param className 6237 * @return {?Function} 6238 */ 6239 value: function getClass(className) { 6240 if (Type.isString(className) && !!className) { 6241 let classFn = null; 6242 let currentNamespace = window; 6243 const namespaces = className.split('.'); 6244 6245 for (let i = 0; i < namespaces.length; i += 1) { 6246 const namespace = namespaces[i]; 6247 6248 if (!currentNamespace[namespace]) { 6249 return null; 6250 } 6251 6252 currentNamespace = currentNamespace[namespace]; 6253 classFn = currentNamespace; 6254 } 6255 6256 return classFn; 6257 } 6258 6259 if (Type.isFunction(className)) { 6260 return className; 6261 } 6262 6263 return null; 6264 } 6265 /** 6266 * Creates a namespace or returns a link to a previously created one 6267 * @param {String} namespaceName 6268 * @return {Object<string, any> | Function | null} 6269 */ 6270 6271 }, { 6272 key: "namespace", 6273 value: function namespace(namespaceName) { 6274 let parts = namespaceName.split('.'); 6275 let parent = window.BX; 6276 6277 if (parts[0] === 'BX') { 6278 parts = parts.slice(1); 6279 } 6280 6281 for (let i = 0; i < parts.length; i += 1) { 6282 if (Type.isUndefined(parent[parts[i]])) { 6283 parent[parts[i]] = {}; 6284 } 6285 6286 parent = parent[parts[i]]; 6287 } 6288 6289 return parent; 6290 } 6291 }]); 6292 return Reflection; 6293 }(); 6294 6295 const reEscape = /[&<>'"]/g; 6296 const reUnescape = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g; 6297 const escapeEntities = { 6298 '&': '&', 6299 '<': '<', 6300 '>': '>', 6301 "'": ''', 6302 '"': '"' 6303 }; 6304 const unescapeEntities = { 6305 '&': '&', 6306 '&': '&', 6307 '<': '<', 6308 '<': '<', 6309 '>': '>', 6310 '>': '>', 6311 ''': "'", 6312 ''': "'", 6313 '"': '"', 6314 '"': '"' 6315 }; 6316 /** 6317 * @memberOf BX 6318 */ 6319 6320 let Text = /*#__PURE__*/function () { 6321 function Text() { 6322 babelHelpers.classCallCheck(this, Text); 6323 } 6324 6325 babelHelpers.createClass(Text, null, [{ 6326 key: "encode", 6327 6328 /** 6329 * Encodes all unsafe entities 6330 * @param {string} value 6331 * @return {string} 6332 */ 6333 value: function encode(value) { 6334 if (Type.isString(value)) { 6335 return value.replace(reEscape, item => escapeEntities[item]); 6336 } 6337 6338 return value; 6339 } 6340 /** 6341 * Decodes all encoded entities 6342 * @param {string} value 6343 * @return {string} 6344 */ 6345 6346 }, { 6347 key: "decode", 6348 value: function decode(value) { 6349 if (Type.isString(value)) { 6350 return value.replace(reUnescape, item => unescapeEntities[item]); 6351 } 6352 6353 return value; 6354 } 6355 }, { 6356 key: "getRandom", 6357 value: function getRandom(length = 8) { 6358 // eslint-disable-next-line 6359 return [...Array(length)].map(() => (~~(Math.random() * 36)).toString(36)).join(''); 6360 } 6361 }, { 6362 key: "toNumber", 6363 value: function toNumber(value) { 6364 const parsedValue = Number.parseFloat(value); 6365 6366 if (Type.isNumber(parsedValue)) { 6367 return parsedValue; 6368 } 6369 6370 return 0; 6371 } 6372 }, { 6373 key: "toInteger", 6374 value: function toInteger(value) { 6375 return Text.toNumber(Number.parseInt(value, 10)); 6376 } 6377 }, { 6378 key: "toBoolean", 6379 value: function toBoolean(value, trueValues = []) { 6380 const transformedValue = Type.isString(value) ? value.toLowerCase() : value; 6381 return ['true', 'y', '1', 1, true, ...trueValues].includes(transformedValue); 6382 } 6383 }, { 6384 key: "toCamelCase", 6385 value: function toCamelCase(str) { 6386 if (!Type.isStringFilled(str)) { 6387 return str; 6388 } 6389 6390 const regex = /[-_\s]+(.)?/g; 6391 6392 if (!regex.test(str)) { 6393 return str.match(/^[A-Z]+$/) ? str.toLowerCase() : str[0].toLowerCase() + str.slice(1); 6394 } 6395 6396 str = str.toLowerCase(); 6397 str = str.replace(regex, function (match, letter) { 6398 return letter ? letter.toUpperCase() : ''; 6399 }); 6400 return str[0].toLowerCase() + str.substr(1); 6401 } 6402 }, { 6403 key: "toPascalCase", 6404 value: function toPascalCase(str) { 6405 if (!Type.isStringFilled(str)) { 6406 return str; 6407 } 6408 6409 return this.capitalize(this.toCamelCase(str)); 6410 } 6411 }, { 6412 key: "toKebabCase", 6413 value: function toKebabCase(str) { 6414 if (!Type.isStringFilled(str)) { 6415 return str; 6416 } 6417 6418 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); 6419 6420 if (!matches) { 6421 return str; 6422 } 6423 6424 return matches.map(x => x.toLowerCase()).join('-'); 6425 } 6426 }, { 6427 key: "capitalize", 6428 value: function capitalize(str) { 6429 if (!Type.isStringFilled(str)) { 6430 return str; 6431 } 6432 6433 return str[0].toUpperCase() + str.substr(1); 6434 } 6435 }]); 6436 return Text; 6437 }(); 6438 6439 const aliases = { 6440 mousewheel: ['DOMMouseScroll'], 6441 bxchange: ['change', 'cut', 'paste', 'drop', 'keyup'], 6442 animationend: ['animationend', 'oAnimationEnd', 'webkitAnimationEnd', 'MSAnimationEnd'], 6443 transitionend: ['webkitTransitionEnd', 'otransitionend', 'oTransitionEnd', 'msTransitionEnd', 'transitionend'], 6444 fullscreenchange: ['fullscreenchange', 'webkitfullscreenchange', 'mozfullscreenchange', 'MSFullscreenChange'], 6445 fullscreenerror: ['fullscreenerror', 'webkitfullscreenerror', 'mozfullscreenerror', 'MSFullscreenError'] 6446 }; 6447 6448 let Registry = /*#__PURE__*/function () { 6449 function Registry() { 6450 babelHelpers.classCallCheck(this, Registry); 6451 babelHelpers.defineProperty(this, "registry", new WeakMap()); 6452 } 6453 6454 babelHelpers.createClass(Registry, [{ 6455 key: "set", 6456 value: function set(target, event, listener) { 6457 const events = this.get(target); 6458 6459 if (!Type.isSet(events[event])) { 6460 events[event] = new Set(); 6461 } 6462 6463 events[event].add(listener); 6464 this.registry.set(target, events); 6465 } 6466 }, { 6467 key: "get", 6468 value: function get(target) { 6469 return this.registry.get(target) || {}; 6470 } 6471 }, { 6472 key: "has", 6473 value: function has(target, event, listener) { 6474 if (event && listener) { 6475 return this.registry.has(target) && this.registry.get(target)[event].has(listener); 6476 } 6477 6478 return this.registry.has(target); 6479 } 6480 }, { 6481 key: "delete", 6482 value: function _delete(target, event, listener) { 6483 if (!Type.isDomNode(target)) { 6484 return; 6485 } 6486 6487 if (Type.isString(event) && Type.isFunction(listener)) { 6488 const events = this.registry.get(target); 6489 6490 if (Type.isPlainObject(events) && Type.isSet(events[event])) { 6491 events[event].delete(listener); 6492 } 6493 6494 return; 6495 } 6496 6497 if (Type.isString(event)) { 6498 const events = this.registry.get(target); 6499 6500 if (Type.isPlainObject(events) && Type.isSet(events[event])) { 6501 events[event] = new Set(); 6502 } 6503 6504 return; 6505 } 6506 6507 this.registry.delete(target); 6508 } 6509 }]); 6510 return Registry; 6511 }(); 6512 var registry = new Registry(); 6513 6514 function isOptionSupported(name) { 6515 let isSupported = false;
6516 6517 try { 6518 const options = Object.defineProperty({}, name, { 6519 get() { 6520 isSupported = true; 6521 return undefined; 6522 } 6523 6524 }); 6525 window.addEventListener('test', null, options); 6526 } // eslint-disable-next-line 6527 catch (err) {} 6528 6529 return isSupported; 6530 } 6531 6532 function fetchSupportedListenerOptions(options) { 6533 if (!Type.isPlainObject(options)) { 6534 return options; 6535 } 6536 6537 return Object.keys(options).reduce((acc, name) => { 6538 if (isOptionSupported(name)) { 6539 acc[name] = options[name]; 6540 } 6541 6542 return acc; 6543 }, {}); 6544 } 6545 6546 function bind(target, eventName, handler, options) { 6547 if (!Type.isObject(target) || !Type.isFunction(target.addEventListener)) { 6548 return; 6549 } 6550 6551 const listenerOptions = fetchSupportedListenerOptions(options); 6552 6553 if (eventName in aliases) { 6554 aliases[eventName].forEach(key => { 6555 target.addEventListener(key, handler, listenerOptions); 6556 registry.set(target, eventName, handler); 6557 }); 6558 return; 6559 } 6560 6561 target.addEventListener(eventName, handler, listenerOptions); 6562 registry.set(target, eventName, handler); 6563 } 6564 6565 function unbind(target, eventName, handler, options) { 6566 if (!Type.isObject(target) || !Type.isFunction(target.removeEventListener)) { 6567 return; 6568 } 6569 6570 const listenerOptions = fetchSupportedListenerOptions(options); 6571 6572 if (eventName in aliases) { 6573 aliases[eventName].forEach(key => { 6574 target.removeEventListener(key, handler, listenerOptions); 6575 registry.delete(target, key, handler); 6576 }); 6577 return; 6578 } 6579 6580 target.removeEventListener(eventName, handler, listenerOptions); 6581 registry.delete(target, eventName, handler); 6582 } 6583 6584 function unbindAll(target, eventName) { 6585 const events = registry.get(target); 6586 Object.keys(events).forEach(currentEvent => { 6587 events[currentEvent].forEach(handler => { 6588 if (!Type.isString(eventName) || eventName === currentEvent) { 6589 unbind(target, currentEvent, handler); 6590 } 6591 }); 6592 }); 6593 } 6594 6595 function bindOnce(target, eventName, handler, options) { 6596 const once = function once(...args) { 6597 unbind(target, eventName, once, options); 6598 handler(...args); 6599 }; 6600 6601 bind(target, eventName, once, options); 6602 } 6603 6604 let debugState = true; 6605 function enableDebug() { 6606 debugState = true; 6607 } 6608 function disableDebug() { 6609 debugState = false; 6610 } 6611 function isDebugEnabled() { 6612 return debugState; 6613 } 6614 function debug(...args) { 6615 if (isDebugEnabled() && Type.isObject(window.console)) { 6616 if (Type.isFunction(window.console.log)) { 6617 window.console.log('BX.debug: ', args.length > 0 ? args : args[0]); 6618 6619 if (args[0] instanceof Error && args[0].stack) { 6620 window.console.log('BX.debug error stack trace', args[0].stack); 6621 } 6622 } 6623 6624 if (Type.isFunction(window.console.trace)) { 6625 // eslint-disable-next-line 6626 console.trace(); 6627 } 6628 } 6629 } 6630 6631 var debugNs = /*#__PURE__*/Object.freeze({ 6632 get debugState () { return debugState; }, 6633 enableDebug: enableDebug, 6634 disableDebug: disableDebug, 6635 isDebugEnabled: isDebugEnabled, 6636 default: debug 6637 }); 6638 6639 function fetchExtensionSettings(html) { 6640 if (Type.isStringFilled(html)) { 6641 const scripts = html.match(/<script type="extension\/settings" \b[^>]*>([\s\S]*?)<\/script>/g); 6642 6643 if (Type.isArrayFilled(scripts)) { 6644 return scripts.map(script => { 6645 const [, extension] = script.match(/data-extension="(.[a-z0-9_.-]+)"/); 6646 return { 6647 extension, 6648 script 6649 }; 6650 }); 6651 } 6652 } 6653 6654 return []; 6655 } 6656 6657 let Extension = /*#__PURE__*/function () { 6658 function Extension(options) { 6659 babelHelpers.classCallCheck(this, Extension); 6660 this.config = options.config || {}; 6661 this.name = options.extension; 6662 this.state = 'scheduled'; // eslint-disable-next-line 6663 6664 const result = BX.processHTML(options.html || ''); 6665 this.inlineScripts = result.SCRIPT.reduce(inlineScripts, []); 6666 this.externalScripts = result.SCRIPT.reduce(externalScripts, []); 6667 this.externalStyles = result.STYLE.reduce(externalStyles, []); 6668 this.settingsScripts = fetchExtensionSettings(result.HTML); 6669 } 6670 6671 babelHelpers.createClass(Extension, [{ 6672 key: "load", 6673 value: function load() { 6674 if (this.state === 'error') { 6675 this.loadPromise = this.loadPromise || Promise.resolve(this); 6676 console.warn('Extension', this.name, 'not found'); 6677 } 6678 6679 if (!this.loadPromise && this.state) { 6680 this.state = 'load';
6681 this.settingsScripts.forEach(entry => { 6682 const isLoaded = !!document.querySelector(`script[data-extension="${entry.extension}"]`); 6683 6684 if (!isLoaded) { 6685 document.body.insertAdjacentHTML('beforeend', entry.script); 6686 } 6687 }); 6688 this.inlineScripts.forEach(BX.evalGlobal); 6689 this.loadPromise = Promise.all([loadAll(this.externalScripts), loadAll(this.externalStyles)]).then(() => { 6690 this.state = 'loaded'; 6691 6692 if (Type.isPlainObject(this.config) && this.config.namespace) { 6693 return Reflection.getClass(this.config.namespace); 6694 } 6695 6696 return window; 6697 }); 6698 } 6699 6700 return this.loadPromise; 6701 } 6702 }]); 6703 return Extension; 6704 }(); 6705 6706 const initialized = {}; 6707 const ajaxController = 'main.bitrix.main.controller.loadext.getextensions'; 6708 6709 function makeIterable(value) { 6710 return Type.isArray(value) ? value : [value]; 6711 } 6712 function isInitialized(extension) { 6713 return extension in initialized; 6714 } 6715 function getInitialized(extension) { 6716 return initialized[extension]; 6717 } 6718 function isAllInitialized(extensions) { 6719 return extensions.every(isInitialized); 6720 } 6721 function loadExtensions(extensions) { 6722 return Promise.all(extensions.map(item => item.load())); 6723 } 6724 function mergeExports(exports) { 6725 return exports.reduce((acc, currentExports) => { 6726 if (Type.isObject(currentExports)) { 6727 return { ...currentExports 6728 }; 6729 } 6730 6731 return currentExports; 6732 }, {}); 6733 } 6734 function inlineScripts(acc, item) { 6735 if (item.isInternal) { 6736 acc.push(item.JS); 6737 } 6738 6739 return acc; 6740 } 6741 function externalScripts(acc, item) { 6742 if (!item.isInternal) { 6743 acc.push(item.JS); 6744 } 6745 6746 return acc; 6747 } 6748 function externalStyles(acc, item) { 6749 if (Type.isString(item) && item !== '') { 6750 acc.push(item); 6751 } 6752 6753 return acc; 6754 } 6755 function request(options) { 6756 return new Promise(resolve => { 6757 // eslint-disable-next-line 6758 BX.ajax.runAction(ajaxController, { 6759 data: options 6760 }).then(resolve); 6761 }); 6762 } 6763 function prepareExtensions(response) { 6764 if (response.status !== 'success') { 6765 response.errors.map(console.warn); 6766 return []; 6767 } 6768 6769 return response.data.map(item => { 6770 const initializedExtension = getInitialized(item.extension); 6771 6772 if (initializedExtension) { 6773 return initializedExtension; 6774 } 6775 6776 initialized[item.extension] = new Extension(item); 6777 return initialized[item.extension]; 6778 }); 6779 } 6780 function loadAll(items) { 6781 const itemsList = makeIterable(items); 6782 6783 if (!itemsList.length) { 6784 return Promise.resolve(); 6785 } 6786 6787 return new Promise(resolve => { 6788 // eslint-disable-next-line 6789 BX.load(itemsList, resolve); 6790 }); 6791 } 6792 6793 /** 6794 * Loads extensions asynchronously 6795 * @param {string|Array<string>} extension 6796 * @return {Promise<Array<Extension>>} 6797 */ 6798 function loadExtension(extension) { 6799 const extensions = makeIterable(extension); 6800 const isAllInitialized$$1 = isAllInitialized(extensions); 6801 6802 if (isAllInitialized$$1) { 6803 const initializedExtensions = extensions.map(getInitialized); 6804 return loadExtensions(initializedExtensions).then(mergeExports); 6805 } 6806 6807 return request({ 6808 extension: extensions 6809 }).then(prepareExtensions).then(loadExtensions).then(mergeExports); 6810 } 6811 6812 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]']; 6813 6814 function isCloneable(value) { 6815 const isCloneableValue = Type.isObjectLike(value) && cloneableTags.includes(getTag(value)); 6816 return isCloneableValue || Type.isDomNode(value); 6817 } 6818 6819 function internalClone(value, map) { 6820 if (map.has(value)) { 6821 return map.get(value); 6822 } 6823 6824 if (isCloneable(value)) { 6825 if (Type.isArray(value)) { 6826 const cloned = Array.from(value); 6827 map.set(value, cloned); 6828 value.forEach((item, index) => { 6829 cloned[index] = internalClone(item, map); 6830 }); 6831 return map.get(value); 6832 } 6833 6834 if (Type.isDomNode(value)) { 6835 return value.cloneNode(true); 6836 } 6837 6838 if (Type.isMap(value)) { 6839 const result = new Map(); 6840 map.set(value, result); 6841 value.forEach((item, key) => { 6842 result.set(internalClone(key, map), internalClone(item, map)); 6843 }); 6844 return result; 6845 } 6846 6847 if (Type.isSet(value)) { 6848 const result = new Set(); 6849 map.set(value, result); 6850 value.forEach(item => { 6851 result.add(internalClone(item, map)); 6852 }); 6853 return result; 6854 } 6855 6856 if (Type.isDate(value)) { 6857 return new Date(value); 6858 } 6859 6860 if (Type.isRegExp(value)) { 6861 const regExpFlags = /\w*$/; 6862 const flags = regExpFlags.exec(value); 6863 let result = new RegExp(value.source); 6864 6865 if (flags && Type.isArray(flags)) { 6866 result = new RegExp(value.source, flags[0]); 6867 } 6868 6869 result.lastIndex = value.lastIndex; 6870 return result; 6871 } 6872 6873 const proto = Object.getPrototypeOf(value); 6874 const result = Object.assign(Object.create(proto), value); 6875 map.set(value, result); 6876 Object.keys(value).forEach(key => { 6877 result[key] = internalClone(value[key], map); 6878 }); 6879 return result; 6880 } 6881 6882 return value; 6883 }
6884 /** 6885 * Clones any cloneable object 6886 * @param value 6887 * @return {*} 6888 */ 6889 6890 function clone(value) { 6891 return internalClone(value, new WeakMap()); 6892 } 6893 6894 function merge(current, target) { 6895 return Object.entries(target).reduce((acc, [key, value]) => { 6896 if (!Type.isDomNode(acc[key]) && Type.isObjectLike(acc[key]) && Type.isObjectLike(value)) { 6897 acc[key] = merge(acc[key], value); 6898 return acc; 6899 } 6900 6901 acc[key] = value; 6902 return acc; 6903 }, current); 6904 } 6905 6906 function createComparator(fields, orders = []) { 6907 return (a, b) => { 6908 const field = fields[0]; 6909 const order = orders[0] || 'asc'; 6910 6911 if (Type.isUndefined(field)) { 6912 return 0; 6913 } 6914 6915 let valueA = a[field]; 6916 let valueB = b[field]; 6917 6918 if (Type.isString(valueA) && Type.isString(valueB)) { 6919 valueA = valueA.toLowerCase(); 6920 valueB = valueB.toLowerCase(); 6921 } 6922 6923 if (valueA < valueB) { 6924 return order === 'asc' ? -1 : 1; 6925 } 6926 6927 if (valueA > valueB) { 6928 return order === 'asc' ? 1 : -1; 6929 } 6930 6931 return createComparator(fields.slice(1), orders.slice(1))(a, b); 6932 }; 6933 } 6934 6935 /** 6936 * @memberOf BX 6937 */ 6938 6939 let Runtime = /*#__PURE__*/function () { 6940 function Runtime() { 6941 babelHelpers.classCallCheck(this, Runtime); 6942 } 6943 6944 babelHelpers.createClass(Runtime, null, [{ 6945 key: "debounce", 6946 value: function debounce(func, wait = 0, context = null) { 6947 let timeoutId; 6948 return function debounced(...args) { 6949 if (Type.isNumber(timeoutId)) { 6950 clearTimeout(timeoutId); 6951 } 6952 6953 timeoutId = setTimeout(() => { 6954 func.apply(context || this, args); 6955 }, wait); 6956 }; 6957 } 6958 }, { 6959 key: "throttle", 6960 value: function throttle(func, wait = 0, context = null) { 6961 let timer = 0; 6962 let invoke; 6963 return function wrapper(...args) { 6964 invoke = true; 6965 6966 if (!timer) { 6967 const q = function q() { 6968 if (invoke) { 6969 func.apply(context || this, args); 6970 invoke = false; 6971 timer = setTimeout(q, wait); 6972 } else { 6973 timer = null; 6974 } 6975 }; 6976 6977 q(); 6978 } 6979 }; 6980 } 6981 }, { 6982 key: "html", 6983 value: function html(node, _html, params = {}) { 6984 if (Type.isNil(_html) && Type.isDomNode(node)) { 6985 return node.innerHTML; 6986 } // eslint-disable-next-line 6987 6988 6989 const parsedHtml = BX.processHTML(_html); 6990 const externalCss = parsedHtml.STYLE.reduce(externalStyles, []); 6991 const externalJs = parsedHtml.SCRIPT.reduce(externalScripts, []); 6992 const inlineJs = parsedHtml.SCRIPT.reduce(inlineScripts, []); 6993 6994 if (Type.isDomNode(node)) { 6995 if (params.htmlFirst || !externalJs.length && !externalCss.length) { 6996 if (params.useAdjacentHTML) { 6997 node.insertAdjacentHTML('beforeend', parsedHtml.HTML); 6998 } else { 6999 node.innerHTML = parsedHtml.HTML; 7000 } 7001 } 7002 } 7003 7004 return Promise.all([loadAll(externalJs), loadAll(externalCss)]).then(() => { 7005 if (Type.isDomNode(node) && (externalJs.length > 0 || externalCss.length > 0)) { 7006 if (params.useAdjacentHTML) { 7007 node.insertAdjacentHTML('beforeend', parsedHtml.HTML); 7008 } else { 7009 node.innerHTML = parsedHtml.HTML; 7010 } 7011 } // eslint-disable-next-line 7012 7013 7014 inlineJs.forEach(script => BX.evalGlobal(script)); 7015 7016 if (Type.isFunction(params.callback)) { 7017 params.callback(); 7018 } 7019 }); 7020 } 7021 /** 7022 * Merges objects or arrays 7023 * @param targets 7024 * @return {any} 7025 */ 7026 7027 }, { 7028 key: "merge", 7029 value: function merge$$1(...targets) { 7030 if (Type.isArray(targets[0])) { 7031 targets.unshift([]); 7032 } else if (Type.isObject(targets[0])) { 7033 targets.unshift({}); 7034 } 7035 7036 return targets.reduce((acc, item) => { 7037 return merge(acc, item); 7038 }, targets[0]); 7039 } 7040 }, { 7041 key: "orderBy", 7042 value: function orderBy(collection, fields = [], orders = []) { 7043 const comparator = createComparator(fields, orders); 7044 return Object.values(collection).sort(comparator); 7045 } 7046 }, {
7047 key: "destroy", 7048 value: function destroy(target, errorMessage = 'Object is destroyed') { 7049 if (Type.isObject(target)) { 7050 const onPropertyAccess = () => { 7051 throw new Error(errorMessage); 7052 }; 7053 7054 const ownProperties = Object.keys(target); 7055 7056 const prototypeProperties = (() => { 7057 const targetPrototype = Object.getPrototypeOf(target); 7058 7059 if (Type.isObject(targetPrototype)) { 7060 return Object.getOwnPropertyNames(targetPrototype); 7061 } 7062 7063 return []; 7064 })(); 7065 7066 const uniquePropertiesList = [...new Set([...ownProperties, ...prototypeProperties])]; 7067 uniquePropertiesList.filter(name => { 7068 const descriptor = Object.getOwnPropertyDescriptor(target, name); 7069 return !/__(.+)__/.test(name) && (!Type.isObject(descriptor) || descriptor.configurable === true); 7070 }).forEach(name => { 7071 Object.defineProperty(target, name, { 7072 get: onPropertyAccess, 7073 set: onPropertyAccess, 7074 configurable: false 7075 }); 7076 }); 7077 Object.setPrototypeOf(target, null); 7078 } 7079 } 7080 }]); 7081 return Runtime; 7082 }(); 7083 7084 babelHelpers.defineProperty(Runtime, "debug", debug); 7085 babelHelpers.defineProperty(Runtime, "loadExtension", loadExtension); 7086 babelHelpers.defineProperty(Runtime, "clone", clone); 7087 7088 const _isError = Symbol.for('BX.BaseError.isError'); 7089 /** 7090 * @memberOf BX 7091 */ 7092 7093 7094 let BaseError = /*#__PURE__*/function () { 7095 function BaseError(message, code, customData) { 7096 babelHelpers.classCallCheck(this, BaseError); 7097 this[_isError] = true; 7098 this.message = ''; 7099 this.code = null; 7100 this.customData = null; 7101 this.setMessage(message); 7102 this.setCode(code); 7103 this.setCustomData(customData); 7104 } 7105 /** 7106 * Returns a brief description of the error 7107 * @returns {string} 7108 */ 7109 7110 7111 babelHelpers.createClass(BaseError, [{ 7112 key: "getMessage", 7113 value: function getMessage() { 7114 return this.message; 7115 } 7116 /** 7117 * Sets a message of the error 7118 * @param {string} message 7119 * @returns {this} 7120 */ 7121 7122 }, { 7123 key: "setMessage", 7124 value: function setMessage(message) { 7125 if (Type.isString(message)) { 7126 this.message = message; 7127 } 7128 7129 return this; 7130 } 7131 /** 7132 * Returns a code of the error 7133 * @returns {?string} 7134 */ 7135 7136 }, { 7137 key: "getCode", 7138 value: function getCode() { 7139 return this.code; 7140 } 7141 /** 7142 * Sets a code of the error 7143 * @param {string} code 7144 * @returns {this} 7145 */ 7146 7147 }, { 7148 key: "setCode", 7149 value: function setCode(code) { 7150 if (Type.isStringFilled(code) || code === null) { 7151 this.code = code; 7152 } 7153 7154 return this; 7155 } 7156 /** 7157 * Returns custom data of the error 7158 * @returns {null|*} 7159 */ 7160 7161 }, { 7162 key: "getCustomData", 7163 value: function getCustomData() { 7164 return this.customData; 7165 } 7166 /** 7167 * Sets custom data of the error 7168 * @returns {this} 7169 */ 7170 7171 }, { 7172 key: "setCustomData", 7173 value: function setCustomData(customData) { 7174 if (!Type.isUndefined(customData)) { 7175 this.customData = customData; 7176 } 7177 7178 return this; 7179 } 7180 }, { 7181 key: "toString", 7182 value: function toString() { 7183 const code = this.getCode(); 7184 const message = this.getMessage(); 7185 7186 if (!Type.isStringFilled(code) && !Type.isStringFilled(message)) { 7187 return ''; 7188 } else if (!Type.isStringFilled(code)) { 7189 return `Error: ${message}`; 7190 } else if (!Type.isStringFilled(message)) { 7191 return code; 7192 } else { 7193 return `${code}: ${message}`; 7194 } 7195 } 7196 /** 7197 * Returns true if the object is an instance of BaseError 7198 * @param error 7199 * @returns {boolean} 7200 */ 7201 7202 }], [{ 7203 key: "isError", 7204 value: function isError(error) { 7205 return Type.isObject(error) && error[_isError] === true; 7206 } 7207 }]); 7208 return BaseError; 7209 }(); 7210 7211 /** 7212 * Implements base event object interface 7213 */ 7214 7215 let BaseEvent = /*#__PURE__*/function () { 7216 function BaseEvent(options = { 7217 data: {} 7218 }) { 7219 babelHelpers.classCallCheck(this, BaseEvent); 7220 this.type = ''; 7221 this.data = null; 7222 this.target = null; 7223 this.compatData = null; 7224 this.defaultPrevented = false;
7225 this.immediatePropagationStopped = false; 7226 this.errors = []; 7227 this.setData(options.data); 7228 this.setCompatData(options.compatData); 7229 } 7230 7231 babelHelpers.createClass(BaseEvent, [{ 7232 key: "getType", 7233 7234 /** 7235 * Returns the name of the event 7236 * @returns {string} 7237 */ 7238 value: function getType() { 7239 return this.type; 7240 } 7241 /** 7242 * 7243 * @param {string} type 7244 */ 7245 7246 }, { 7247 key: "setType", 7248 value: function setType(type) { 7249 if (Type.isStringFilled(type)) { 7250 this.type = type; 7251 } 7252 7253 return this; 7254 } 7255 /** 7256 * Returns an event data 7257 */ 7258 7259 }, { 7260 key: "getData", 7261 value: function getData() { 7262 return this.data; 7263 } 7264 /** 7265 * Sets an event data 7266 * @param data 7267 */ 7268 7269 }, { 7270 key: "setData", 7271 value: function setData(data) { 7272 if (!Type.isUndefined(data)) { 7273 this.data = data; 7274 } 7275 7276 return this; 7277 } 7278 /** 7279 * Returns arguments for BX.addCustomEvent handlers (deprecated). 7280 * @returns {array | null} 7281 */ 7282 7283 }, { 7284 key: "getCompatData", 7285 value: function getCompatData() { 7286 return this.compatData; 7287 } 7288 /** 7289 * Sets arguments for BX.addCustomEvent handlers (deprecated) 7290 * @param data 7291 */ 7292 7293 }, { 7294 key: "setCompatData", 7295 value: function setCompatData(data) { 7296 if (Type.isArrayLike(data)) { 7297 this.compatData = data; 7298 } 7299 7300 return this; 7301 } 7302 /** 7303 * Sets a event target 7304 * @param target 7305 */ 7306 7307 }, { 7308 key: "setTarget", 7309 value: function setTarget(target) { 7310 this.target = target; 7311 return this; 7312 } 7313 /** 7314 * Returns a event target 7315 */ 7316 7317 }, { 7318 key: "getTarget", 7319 value: function getTarget() { 7320 return this.target; 7321 } 7322 /** 7323 * Returns an array of event errors 7324 * @returns {[]} 7325 */ 7326 7327 }, { 7328 key: "getErrors", 7329 value: function getErrors() { 7330 return this.errors; 7331 } 7332 /** 7333 * Adds an error of the event. 7334 * Event listeners can prevent emitter's default action and set the reason of this behavior. 7335 * @param error 7336 */ 7337 7338 }, { 7339 key: "setError", 7340 value: function setError(error) { 7341 if (BaseError.isError(error)) { 7342 this.errors.push(error); 7343 } 7344 } 7345 /** 7346 * Prevents default action 7347 */ 7348 7349 }, { 7350 key: "preventDefault", 7351 value: function preventDefault() { 7352 this.defaultPrevented = true; 7353 } 7354 /** 7355 * Checks that is default action prevented 7356 * @return {boolean} 7357 */ 7358 7359 }, { 7360 key: "isDefaultPrevented", 7361 value: function isDefaultPrevented() { 7362 return this.defaultPrevented; 7363 } 7364 /** 7365 * Stops event immediate propagation 7366 */ 7367 7368 }, { 7369 key: "stopImmediatePropagation", 7370 value: function stopImmediatePropagation() { 7371 this.immediatePropagationStopped = true; 7372 } 7373 /** 7374 * Checks that is immediate propagation stopped 7375 * @return {boolean} 7376 */ 7377 7378 }, { 7379 key: "isImmediatePropagationStopped", 7380 value: function isImmediatePropagationStopped() { 7381 return this.immediatePropagationStopped; 7382 } 7383 }], [{ 7384 key: "create", 7385 value: function create(options) { 7386 return new this(options); 7387 } 7388 }]); 7389 return BaseEvent; 7390 }(); 7391 7392 let EventStore = /*#__PURE__*/function () { 7393 function EventStore(options = {}) { 7394 babelHelpers.classCallCheck(this, EventStore); 7395 this.defaultMaxListeners = Type.isNumber(options.defaultMaxListeners) ? options.defaultMaxListeners : 10; 7396 this.eventStore = new WeakMap(); 7397 } 7398 7399 babelHelpers.createClass(EventStore, [{ 7400 key: "add", 7401 value: function add(target, options = {}) { 7402 const record = this.getRecordScheme(); 7403 7404 if (Type.isNumber(options.maxListeners)) { 7405 record.maxListeners = options.maxListeners; 7406 } 7407 7408 this.eventStore.set(target, record); 7409 return record; 7410 } 7411 }, { 7412 key: "get", 7413 value: function get(target) { 7414 return this.eventStore.get(target); 7415 } 7416 }, { 7417 key: "getOrAdd", 7418 value: function getOrAdd(target, options = {}) { 7419 return this.get(target) || this.add(target, options); 7420 } 7421 }, { 7422 key: "delete", 7423 value: function _delete(context) { 7424 this.eventStore.delete(context); 7425 } 7426 }, { 7427 key: "getRecordScheme", 7428 value: function getRecordScheme() { 7429 return { 7430 eventsMap: new Map(), 7431 onceMap: new Map(), 7432 maxListeners: this.getDefaultMaxListeners(), 7433 eventsMaxListeners: new Map() 7434 }; 7435 } 7436 }, { 7437 key: "getDefaultMaxListeners", 7438 value: function getDefaultMaxListeners() { 7439 return this.defaultMaxListeners; 7440 } 7441 }]); 7442 return EventStore; 7443 }(); 7444 7445 let WarningStore = /*#__PURE__*/function () {
7446 function WarningStore() { 7447 babelHelpers.classCallCheck(this, WarningStore); 7448 this.warnings = new Map(); 7449 this.printDelayed = Runtime.debounce(this.print.bind(this), 500); 7450 } 7451 7452 babelHelpers.createClass(WarningStore, [{ 7453 key: "add", 7454 value: function add(target, eventName, listeners) { 7455 let contextWarnings = this.warnings.get(target); 7456 7457 if (!contextWarnings) { 7458 contextWarnings = Object.create(null); 7459 this.warnings.set(target, contextWarnings); 7460 } 7461 7462 if (!contextWarnings[eventName]) { 7463 contextWarnings[eventName] = {}; 7464 } 7465 7466 contextWarnings[eventName].size = listeners.size; 7467 7468 if (!Type.isArray(contextWarnings[eventName].errors)) { 7469 contextWarnings[eventName].errors = []; 7470 } 7471 7472 contextWarnings[eventName].errors.push(new Error()); 7473 } 7474 }, { 7475 key: "print", 7476 value: function print() { 7477 this.warnings.forEach(warnings => { 7478 for (let eventName in warnings) { 7479 console.groupCollapsed('Possible BX.Event.EventEmitter memory leak detected. ' + warnings[eventName].size + ' "' + eventName + '" listeners added. ' + 'Use emitter.setMaxListeners() to increase limit.'); 7480 console.dir(warnings[eventName].errors); 7481 console.groupEnd(); 7482 } 7483 }); 7484 this.clear(); 7485 } 7486 }, { 7487 key: "clear", 7488 value: function clear() { 7489 this.warnings.clear(); 7490 } 7491 }, { 7492 key: "printDelayed", 7493 value: function printDelayed() {} 7494 }]); 7495 return WarningStore; 7496 }(); 7497 7498 const eventStore = new EventStore({ 7499 defaultMaxListeners: 10 7500 }); 7501 const warningStore = new WarningStore(); 7502 const aliasStore = new Map(); 7503 const globalTarget = { 7504 GLOBAL_TARGET: 'GLOBAL_TARGET' // this key only for debugging purposes 7505 7506 }; 7507 eventStore.add(globalTarget, { 7508 maxListeners: 25 7509 }); 7510 const isEmitterProperty = Symbol.for('BX.Event.EventEmitter.isEmitter'); 7511 const namespaceProperty = Symbol('namespaceProperty'); 7512 const targetProperty = Symbol('targetProperty'); 7513 7514 let EventEmitter = /*#__PURE__*/function () { 7515 /** @private */ 7516 function EventEmitter(...args) { 7517 babelHelpers.classCallCheck(this, EventEmitter); 7518 this[targetProperty] = null; 7519 this[namespaceProperty] = null; 7520 this[isEmitterProperty] = true; 7521 let target = this; 7522 7523 if (Object.getPrototypeOf(this) === EventEmitter.prototype && args.length > 0) //new EventEmitter(obj) case 7524 { 7525 if (!Type.isObject(args[0])) { 7526 throw new TypeError(`The "target" argument must be an object.`); 7527 } 7528 7529 target = args[0]; 7530 this.setEventNamespace(args[1]); 7531 } 7532 7533 this[targetProperty] = target; 7534 } 7535 /** 7536 * Makes a target observable 7537 * @param {object} target 7538 * @param {string} namespace 7539 */ 7540 7541 7542 babelHelpers.createClass(EventEmitter, [{ 7543 key: "setEventNamespace", 7544 value: function setEventNamespace(namespace) { 7545 if (Type.isStringFilled(namespace)) { 7546 this[namespaceProperty] = namespace; 7547 } 7548 } 7549 }, { 7550 key: "getEventNamespace", 7551 value: function getEventNamespace() { 7552 return this[namespaceProperty]; 7553 } 7554 /** 7555 * Subscribes listener on specified global event 7556 * @param {object} target 7557 * @param {string} eventName 7558 * @param {Function<BaseEvent>} listener 7559 * @param {object} options 7560 */ 7561 7562 }, { 7563 key: "subscribe", 7564 7565 /** 7566 * Subscribes a listener on a specified event 7567 * @param {string} eventName 7568 * @param {Function<BaseEvent>} listener 7569 * @return {this} 7570 */ 7571 value: function subscribe(eventName, listener) { 7572 EventEmitter.subscribe(this, eventName, listener); 7573 return this; 7574 } 7575 /** 7576 * 7577 * @param {object} options 7578 * @param {object} [aliases] 7579 * @param {boolean} [compatMode=false] 7580 */ 7581 7582 }, { 7583 key: "subscribeFromOptions", 7584 value: function subscribeFromOptions(options, aliases, compatMode) { 7585 if (!Type.isPlainObject(options)) { 7586 return; 7587 } 7588 7589 aliases = Type.isPlainObject(aliases) ? EventEmitter.normalizeAliases(aliases) : {};
7590 Object.keys(options).forEach(eventName => { 7591 const listener = EventEmitter.normalizeListener(options[eventName]); 7592 eventName = EventEmitter.normalizeEventName(eventName); 7593 7594 if (aliases[eventName]) { 7595 const { 7596 eventName: actualName 7597 } = aliases[eventName]; 7598 EventEmitter.subscribe(this, actualName, listener, { 7599 compatMode: compatMode !== false 7600 }); 7601 } else { 7602 EventEmitter.subscribe(this, eventName, listener, { 7603 compatMode: compatMode === true 7604 }); 7605 } 7606 }); 7607 } 7608 /** 7609 * Subscribes a listener that is called at 7610 * most once for a specified event. 7611 * @param {object} target 7612 * @param {string} eventName 7613 * @param {Function<BaseEvent>} listener 7614 */ 7615 7616 }, { 7617 key: "subscribeOnce", 7618 7619 /** 7620 * Subscribes a listener that is called at most once for a specified event. 7621 * @param {string} eventName 7622 * @param {Function<BaseEvent>} listener 7623 * @return {this} 7624 */ 7625 value: function subscribeOnce(eventName, listener) { 7626 EventEmitter.subscribeOnce(this, eventName, listener); 7627 return this; 7628 } 7629 /** 7630 * Unsubscribes an event listener 7631 * @param {object} target 7632 * @param {string} eventName 7633 * @param {Function<BaseEvent>} listener 7634 * @param options 7635 */ 7636 7637 }, { 7638 key: "unsubscribe", 7639 7640 /** 7641 * Unsubscribes an event listener 7642 * @param {string} eventName 7643 * @param {Function<BaseEvent>} listener 7644 * @return {this} 7645 */ 7646 value: function unsubscribe(eventName, listener) { 7647 EventEmitter.unsubscribe(this, eventName, listener); 7648 return this; 7649 } 7650 /** 7651 * Unsubscribes all event listeners 7652 * @param {object} target 7653 * @param {string} eventName 7654 * @param options 7655 */ 7656 7657 }, { 7658 key: "unsubscribeAll", 7659 7660 /** 7661 * Unsubscribes all event listeners 7662 * @param {string} [eventName] 7663 */ 7664 value: function unsubscribeAll(eventName) { 7665 EventEmitter.unsubscribeAll(this, eventName); 7666 } 7667 /** 7668 * 7669 * @param {object} target 7670 * @param {string} eventName 7671 * @param {BaseEvent | any} event 7672 * @param {object} options 7673 * @returns {Array} 7674 */ 7675 7676 }, { 7677 key: "emit", 7678 7679 /** 7680 * Emits specified event with specified event object 7681 * @param {string} eventName 7682 * @param {BaseEvent | any} event 7683 * @return {this} 7684 */ 7685 value: function emit(eventName, event) { 7686 if (this.getEventNamespace() === null) { 7687 console.warn('The instance of BX.Event.EventEmitter is supposed to have an event namespace. ' + 'Use emitter.setEventNamespace() to make events more unique.'); 7688 } 7689 7690 EventEmitter.emit(this, eventName, event); 7691 return this; 7692 } 7693 /** 7694 * Emits global event and returns a promise that is resolved when 7695 * all promise returned from event handlers are resolved, 7696 * or rejected when at least one of the returned promise is rejected. 7697 * Importantly. You can return any value from synchronous handlers, not just promise 7698 * @param {object} target 7699 * @param {string} eventName 7700 * @param {BaseEvent | any} event 7701 * @return {Promise<Array>} 7702 */ 7703 7704 }, { 7705 key: "emitAsync", 7706 7707 /** 7708 * Emits event and returns a promise that is resolved when 7709 * all promise returned from event handlers are resolved, 7710 * or rejected when at least one of the returned promise is rejected. 7711 * Importantly. You can return any value from synchronous handlers, not just promise 7712 * @param {string} eventName 7713 * @param {BaseEvent|any} event 7714 * @return {Promise<Array>} 7715 */ 7716 value: function emitAsync(eventName, event) { 7717 if (this.getEventNamespace() === null) { 7718 console.warn('The instance of BX.Event.EventEmitter is supposed to have an event namespace. ' + 'Use emitter.setEventNamespace() to make events more unique.'); 7719 } 7720 7721 return EventEmitter.emitAsync(this, eventName, event); 7722 } 7723 /** 7724 * @private 7725 * @param {object} target 7726 * @param {string} eventName 7727 * @param {BaseEvent|any} event 7728 * @returns {BaseEvent} 7729 */ 7730 7731 }, { 7732 key: "setMaxListeners", 7733 7734 /** 7735 * Sets max events listeners count 7736 * this.setMaxListeners(10) - sets the default value for all events
7737 * this.setMaxListeners("onClose", 10) sets the value for onClose event 7738 * @return {this} 7739 * @param args 7740 */ 7741 value: function setMaxListeners(...args) { 7742 EventEmitter.setMaxListeners(this, ...args); 7743 return this; 7744 } 7745 /** 7746 * Returns max event listeners count 7747 * @param {object} target 7748 * @param {string} [eventName] 7749 * @returns {number} 7750 */ 7751 7752 }, { 7753 key: "getMaxListeners", 7754 7755 /** 7756 * Returns max event listeners count 7757 * @param {string} [eventName] 7758 * @returns {number} 7759 */ 7760 value: function getMaxListeners(eventName) { 7761 return EventEmitter.getMaxListeners(this, eventName); 7762 } 7763 /** 7764 * Adds or subtracts max listeners count 7765 * Event.EventEmitter.addMaxListeners() - adds one max listener for all events of global target 7766 * Event.EventEmitter.addMaxListeners(3) - adds three max listeners for all events of global target 7767 * Event.EventEmitter.addMaxListeners(-1) - subtracts one max listener for all events of global target 7768 * Event.EventEmitter.addMaxListeners('onClose') - adds one max listener for onClose event of global target 7769 * Event.EventEmitter.addMaxListeners('onClose', 2) - adds two max listeners for onClose event of global target 7770 * Event.EventEmitter.addMaxListeners('onClose', -1) - subtracts one max listener for onClose event of global target 7771 * 7772 * Event.EventEmitter.addMaxListeners(obj) - adds one max listener for all events of 'obj' target 7773 * Event.EventEmitter.addMaxListeners(obj, 3) - adds three max listeners for all events of 'obj' target 7774 * Event.EventEmitter.addMaxListeners(obj, -1) - subtracts one max listener for all events of 'obj' target 7775 * Event.EventEmitter.addMaxListeners(obj, 'onClose') - adds one max listener for onClose event of 'obj' target 7776 * Event.EventEmitter.addMaxListeners(obj, 'onClose', 2) - adds two max listeners for onClose event of 'obj' target 7777 * Event.EventEmitter.addMaxListeners(obj, 'onClose', -1) - subtracts one max listener for onClose event of 'obj' target 7778 * @param args 7779 * @returns {number} 7780 */ 7781 7782 }, { 7783 key: "incrementMaxListeners", 7784 7785 /** 7786 * Increases max listeners count 7787 * this.incrementMaxListeners() - adds one max listener for all events 7788 * this.incrementMaxListeners(3) - adds three max listeners for all events 7789 * this.incrementMaxListeners('onClose') - adds one max listener for onClose event 7790 * this.incrementMaxListeners('onClose', 2) - adds two max listeners for onClose event 7791 */ 7792 value: function incrementMaxListeners(...args) { 7793 return EventEmitter.incrementMaxListeners(this, ...args); 7794 } 7795 /** 7796 * Decreases max listeners count 7797 * 7798 * Event.EventEmitter.decrementMaxListeners() - subtracts one max listener for all events of global target 7799 * Event.EventEmitter.decrementMaxListeners(3) - subtracts three max listeners for all events of global target 7800 * Event.EventEmitter.decrementMaxListeners('onClose') - subtracts one max listener for onClose event of global target 7801 * Event.EventEmitter.decrementMaxListeners('onClose', 2) - subtracts two max listeners for onClose event of global target 7802 * 7803 * Event.EventEmitter.decrementMaxListeners(obj) - subtracts one max listener for all events of 'obj' target 7804 * Event.EventEmitter.decrementMaxListeners(obj, 3) - subtracts three max listeners for all events of 'obj' target 7805 * Event.EventEmitter.decrementMaxListeners(obj, 'onClose') - subtracts one max listener for onClose event of 'obj' target 7806 * Event.EventEmitter.decrementMaxListeners(obj, 'onClose', 2) - subtracts two max listeners for onClose event of 'obj' target 7807 */ 7808 7809 }, { 7810 key: "decrementMaxListeners", 7811 7812 /** 7813 * Increases max listeners count 7814 * this.decrementMaxListeners() - subtracts one max listener for all events 7815 * this.decrementMaxListeners(3) - subtracts three max listeners for all events 7816 * this.decrementMaxListeners('onClose') - subtracts one max listener for onClose event 7817 * this.decrementMaxListeners('onClose', 2) - subtracts two max listeners for onClose event 7818 */ 7819 value: function decrementMaxListeners(...args) { 7820 return EventEmitter.decrementMaxListeners(this, ...args); 7821 } 7822 /** 7823 * @private 7824 * @param {Array} args 7825 * @returns Array 7826 */ 7827 7828 }, { 7829 key: "getListeners", 7830 7831 /** 7832 * Gets listeners list for specified event 7833 * @param {string} eventName 7834 */ 7835 value: function getListeners(eventName) { 7836 return EventEmitter.getListeners(this, eventName); 7837 } 7838 /** 7839 * Returns a full event name with namespace 7840 * @param {string} eventName 7841 * @returns {string} 7842 */ 7843 7844 }, { 7845 key: "getFullEventName", 7846 value: function getFullEventName(eventName) { 7847 if (!Type.isStringFilled(eventName)) { 7848 throw new TypeError(`The "eventName" argument must be a string.`); 7849 } 7850 7851 return EventEmitter.makeFullEventName(this.getEventNamespace(), eventName); 7852 } 7853 /** 7854 * Registers aliases (old event names for BX.onCustomEvent) 7855 * @param aliases 7856 */ 7857 7858 }], [{ 7859 key: "makeObservable", 7860 value: function makeObservable(target, namespace) { 7861 if (!Type.isObject(target)) { 7862 throw new TypeError('The "target" argument must be an object.'); 7863 } 7864 7865 if (!Type.isStringFilled(namespace)) { 7866 throw new TypeError('The "namespace" must be an non-empty string.'); 7867 } 7868 7869 if (EventEmitter.isEventEmitter(target)) { 7870 throw new TypeError('The "target" is an event emitter already.'); 7871 } 7872 7873 const targetProto = Object.getPrototypeOf(target); 7874 const emitter = new EventEmitter(); 7875 emitter.setEventNamespace(namespace); 7876 Object.setPrototypeOf(emitter, targetProto); 7877 Object.setPrototypeOf(target, emitter); 7878 Object.getOwnPropertyNames(EventEmitter.prototype).forEach(method => {
7879 if (['constructor'].includes(method)) { 7880 return; 7881 } 7882 7883 emitter[method] = function (...args) { 7884 return EventEmitter.prototype[method].apply(target, args); 7885 }; 7886 }); 7887 } 7888 }, { 7889 key: "subscribe", 7890 value: function subscribe(target, eventName, listener, options) { 7891 if (Type.isString(target)) { 7892 options = listener; 7893 listener = eventName; 7894 eventName = target; 7895 target = this.GLOBAL_TARGET; 7896 } 7897 7898 if (!Type.isObject(target)) { 7899 throw new TypeError(`The "target" argument must be an object.`); 7900 } 7901 7902 eventName = this.normalizeEventName(eventName); 7903 7904 if (!Type.isStringFilled(eventName)) { 7905 throw new TypeError(`The "eventName" argument must be a string.`); 7906 } 7907 7908 listener = this.normalizeListener(listener); 7909 options = Type.isPlainObject(options) ? options : {}; 7910 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 7911 const { 7912 eventsMap, 7913 onceMap 7914 } = eventStore.getOrAdd(target); 7915 const onceListeners = onceMap.get(fullEventName); 7916 let listeners = eventsMap.get(fullEventName); 7917 7918 if (listeners && listeners.has(listener) || onceListeners && onceListeners.has(listener)) { 7919 console.error(`You cannot subscribe the same "${fullEventName}" event listener twice.`); 7920 } else { 7921 if (listeners) { 7922 listeners.set(listener, { 7923 listener, 7924 options, 7925 sort: this.getNextSequenceValue() 7926 }); 7927 } else { 7928 listeners = new Map([[listener, { 7929 listener, 7930 options, 7931 sort: this.getNextSequenceValue() 7932 }]]); 7933 eventsMap.set(fullEventName, listeners); 7934 } 7935 } 7936 7937 const maxListeners = this.getMaxListeners(target, eventName); 7938 7939 if (listeners.size > maxListeners) { 7940 warningStore.add(target, fullEventName, listeners); 7941 warningStore.printDelayed(); 7942 } 7943 } 7944 }, { 7945 key: "subscribeOnce", 7946 value: function subscribeOnce(target, eventName, listener) { 7947 if (Type.isString(target)) { 7948 listener = eventName; 7949 eventName = target; 7950 target = this.GLOBAL_TARGET;
7951 } 7952 7953 if (!Type.isObject(target)) { 7954 throw new TypeError(`The "target" argument must be an object.`); 7955 } 7956 7957 eventName = this.normalizeEventName(eventName); 7958 7959 if (!Type.isStringFilled(eventName)) { 7960 throw new TypeError(`The "eventName" argument must be a string.`); 7961 } 7962 7963 listener = this.normalizeListener(listener); 7964 const fullEventName = this.resolveEventName(eventName, target); 7965 const { 7966 eventsMap, 7967 onceMap 7968 } = eventStore.getOrAdd(target); 7969 const listeners = eventsMap.get(fullEventName); 7970 let onceListeners = onceMap.get(fullEventName); 7971 7972 if (listeners && listeners.has(listener) || onceListeners && onceListeners.has(listener)) { 7973 console.error(`You cannot subscribe the same "${fullEventName}" event listener twice.`); 7974 } else { 7975 const once = (...args) => { 7976 this.unsubscribe(target, eventName, once); 7977 onceListeners.delete(listener); 7978 listener(...args); 7979 }; 7980 7981 if (onceListeners) { 7982 onceListeners.set(listener, once); 7983 } else { 7984 onceListeners = new Map([[listener, once]]); 7985 onceMap.set(fullEventName, onceListeners); 7986 } 7987 7988 this.subscribe(target, eventName, once); 7989 } 7990 } 7991 }, { 7992 key: "unsubscribe", 7993 value: function unsubscribe(target, eventName, listener, options) { 7994 if (Type.isString(target)) { 7995 listener = eventName; 7996 eventName = target; 7997 target = this.GLOBAL_TARGET;
7998 } 7999 8000 eventName = this.normalizeEventName(eventName); 8001 8002 if (!Type.isStringFilled(eventName)) { 8003 throw new TypeError(`The "eventName" argument must be a string.`); 8004 } 8005 8006 listener = this.normalizeListener(listener); 8007 options = Type.isPlainObject(options) ? options : {}; 8008 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 8009 const targetInfo = eventStore.get(target); 8010 const listeners = targetInfo && targetInfo.eventsMap.get(fullEventName); 8011 const onceListeners = targetInfo && targetInfo.onceMap.get(fullEventName); 8012 8013 if (listeners) { 8014 listeners.delete(listener); 8015 } 8016 8017 if (onceListeners) { 8018 const once = onceListeners.get(listener); 8019 8020 if (once) { 8021 onceListeners.delete(listener); 8022 listeners.delete(once); 8023 } 8024 } 8025 } 8026 }, { 8027 key: "unsubscribeAll", 8028 value: function unsubscribeAll(target, eventName, options) { 8029 if (Type.isString(target)) { 8030 eventName = target; 8031 target = this.GLOBAL_TARGET;
8032 } 8033 8034 if (Type.isStringFilled(eventName)) { 8035 const targetInfo = eventStore.get(target); 8036 8037 if (targetInfo) { 8038 options = Type.isPlainObject(options) ? options : {}; 8039 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 8040 targetInfo.eventsMap.delete(fullEventName); 8041 targetInfo.onceMap.delete(fullEventName); 8042 } 8043 } else if (Type.isNil(eventName)) { 8044 if (target === this.GLOBAL_TARGET) { 8045 console.error('You cannot unsubscribe all global listeners.'); 8046 } else { 8047 eventStore.delete(target); 8048 } 8049 } 8050 } 8051 }, { 8052 key: "emit", 8053 value: function emit(target, eventName, event, options) { 8054 if (Type.isString(target)) { 8055 options = event; 8056 event = eventName; 8057 eventName = target; 8058 target = this.GLOBAL_TARGET; 8059 } 8060 8061 if (!Type.isObject(target)) { 8062 throw new TypeError(`The "target" argument must be an object.`); 8063 } 8064 8065 eventName = this.normalizeEventName(eventName); 8066 8067 if (!Type.isStringFilled(eventName)) { 8068 throw new TypeError(`The "eventName" argument must be a string.`); 8069 } 8070 8071 options = Type.isPlainObject(options) ? options : {}; 8072 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 8073 const globalEvents = eventStore.get(this.GLOBAL_TARGET); 8074 const globalListeners = globalEvents && globalEvents.eventsMap.get(fullEventName) || new Map(); 8075 let targetListeners = new Set(); 8076 8077 if (target !== this.GLOBAL_TARGET) { 8078 const targetEvents = eventStore.get(target); 8079 targetListeners = targetEvents && targetEvents.eventsMap.get(fullEventName) || new Map(); 8080 } 8081 8082 const listeners = [...globalListeners.values(), ...targetListeners.values()]; 8083 listeners.sort(function (a, b) { 8084 return a.sort - b.sort; 8085 }); 8086 const preparedEvent = this.prepareEvent(target, fullEventName, event); 8087 const result = []; 8088 8089 for (let i = 0; i < listeners.length; i++) { 8090 if (preparedEvent.isImmediatePropagationStopped()) { 8091 break; 8092 } 8093 8094 const { 8095 listener, 8096 options: listenerOptions 8097 } = listeners[i]; //A previous listener could remove a current listener. 8098 8099 if (globalListeners.has(listener) || targetListeners.has(listener)) { 8100 let listenerResult; 8101 8102 if (listenerOptions.compatMode) { 8103 let params = []; 8104 const compatData = preparedEvent.getCompatData(); 8105 8106 if (compatData !== null) { 8107 params = options.cloneData === true ? Runtime.clone(compatData) : compatData; 8108 } else { 8109 params = [preparedEvent]; 8110 } 8111 8112 const context = Type.isUndefined(options.thisArg) ? target : options.thisArg; 8113 listenerResult = listener.apply(context, params); 8114 } else { 8115 listenerResult = Type.isUndefined(options.thisArg) ? listener(preparedEvent) : listener.call(options.thisArg, preparedEvent); 8116 } 8117 8118 result.push(listenerResult); 8119 } 8120 } 8121 8122 return result; 8123 } 8124 }, { 8125 key: "emitAsync", 8126 value: function emitAsync(target, eventName, event) { 8127 if (Type.isString(target)) { 8128 event = eventName; 8129 eventName = target; 8130 target = this.GLOBAL_TARGET;
8131 } 8132 8133 return Promise.all(this.emit(target, eventName, event)); 8134 } 8135 }, { 8136 key: "prepareEvent", 8137 value: function prepareEvent(target, eventName, event) { 8138 let preparedEvent = event; 8139 8140 if (!(event instanceof BaseEvent)) { 8141 preparedEvent = new BaseEvent(); 8142 preparedEvent.setData(event); 8143 } 8144 8145 preparedEvent.setTarget(this.isEventEmitter(target) ? target[targetProperty] : target); 8146 preparedEvent.setType(eventName); 8147 return preparedEvent; 8148 } 8149 /** 8150 * @private 8151 * @returns {number} 8152 */ 8153 8154 }, { 8155 key: "getNextSequenceValue", 8156 value: function getNextSequenceValue() { 8157 return this.sequenceValue++; 8158 } 8159 /** 8160 * Sets max global events listeners count 8161 * Event.EventEmitter.setMaxListeners(10) - sets the default value for all events (global target) 8162 * Event.EventEmitter.setMaxListeners("onClose", 10) - sets the value for onClose event (global target) 8163 * Event.EventEmitter.setMaxListeners(obj, 10) - sets the default value for all events (obj target) 8164 * Event.EventEmitter.setMaxListeners(obj, "onClose", 10); - sets the value for onClose event (obj target) 8165 * @return {void} 8166 * @param args 8167 */ 8168 8169 }, { 8170 key: "setMaxListeners", 8171 value: function setMaxListeners(...args) { 8172 let target = this.GLOBAL_TARGET;
8173 let eventName = null; 8174 let count = undefined; 8175 8176 if (args.length === 1) { 8177 count = args[0]; 8178 } else if (args.length === 2) { 8179 if (Type.isString(args[0])) { 8180 [eventName, count] = args; 8181 } else { 8182 [target, count] = args; 8183 } 8184 } else if (args.length >= 3) { 8185 [target, eventName, count] = args; 8186 } 8187 8188 if (!Type.isObject(target)) { 8189 throw new TypeError(`The "target" argument must be an object.`); 8190 } 8191 8192 if (eventName !== null && !Type.isStringFilled(eventName)) { 8193 throw new TypeError(`The "eventName" argument must be a string.`); 8194 } 8195 8196 if (!Type.isNumber(count) || count < 0) { 8197 throw new TypeError(`The value of "count" is out of range. It must be a non-negative number. Received ${count}.`); 8198 } 8199 8200 const targetInfo = eventStore.getOrAdd(target); 8201 8202 if (Type.isStringFilled(eventName)) { 8203 const fullEventName = this.resolveEventName(eventName, target); 8204 targetInfo.eventsMaxListeners.set(fullEventName, count); 8205 } else { 8206 targetInfo.maxListeners = count; 8207 } 8208 } 8209 }, { 8210 key: "getMaxListeners", 8211 value: function getMaxListeners(target, eventName) { 8212 if (Type.isString(target)) { 8213 eventName = target; 8214 target = this.GLOBAL_TARGET;
8215 } else if (Type.isNil(target)) { 8216 target = this.GLOBAL_TARGET; 8217 } 8218 8219 if (!Type.isObject(target)) { 8220 throw new TypeError(`The "target" argument must be an object.`); 8221 } 8222 8223 const targetInfo = eventStore.get(target); 8224 8225 if (targetInfo) { 8226 let maxListeners = targetInfo.maxListeners; 8227 8228 if (Type.isStringFilled(eventName)) { 8229 const fullEventName = this.resolveEventName(eventName, target); 8230 maxListeners = targetInfo.eventsMaxListeners.get(fullEventName) || maxListeners; 8231 } 8232 8233 return maxListeners; 8234 } 8235 8236 return this.DEFAULT_MAX_LISTENERS; 8237 } 8238 }, { 8239 key: "addMaxListeners", 8240 value: function addMaxListeners(...args) { 8241 const [target, eventName, increment] = this.destructMaxListenersArgs(...args); 8242 const maxListeners = Math.max(this.getMaxListeners(target, eventName) + increment, 0); 8243 8244 if (Type.isStringFilled(eventName)) { 8245 EventEmitter.setMaxListeners(target, eventName, maxListeners); 8246 } else { 8247 EventEmitter.setMaxListeners(target, maxListeners); 8248 } 8249 8250 return maxListeners; 8251 } 8252 /** 8253 * Increases max listeners count 8254 * 8255 * Event.EventEmitter.incrementMaxListeners() - adds one max listener for all events of global target 8256 * Event.EventEmitter.incrementMaxListeners(3) - adds three max listeners for all events of global target 8257 * Event.EventEmitter.incrementMaxListeners('onClose') - adds one max listener for onClose event of global target 8258 * Event.EventEmitter.incrementMaxListeners('onClose', 2) - adds two max listeners for onClose event of global target 8259 * 8260 * Event.EventEmitter.incrementMaxListeners(obj) - adds one max listener for all events of 'obj' target 8261 * Event.EventEmitter.incrementMaxListeners(obj, 3) - adds three max listeners for all events of 'obj' target 8262 * Event.EventEmitter.incrementMaxListeners(obj, 'onClose') - adds one max listener for onClose event of 'obj' target 8263 * Event.EventEmitter.incrementMaxListeners(obj, 'onClose', 2) - adds two max listeners for onClose event of 'obj' target 8264 */ 8265 8266 }, { 8267 key: "incrementMaxListeners", 8268 value: function incrementMaxListeners(...args) { 8269 const [target, eventName, increment] = this.destructMaxListenersArgs(...args); 8270 return this.addMaxListeners(target, eventName, Math.abs(increment)); 8271 } 8272 }, { 8273 key: "decrementMaxListeners", 8274 value: function decrementMaxListeners(...args) { 8275 const [target, eventName, increment] = this.destructMaxListenersArgs(...args); 8276 return this.addMaxListeners(target, eventName, -Math.abs(increment)); 8277 } 8278 }, { 8279 key: "destructMaxListenersArgs", 8280 value: function destructMaxListenersArgs(...args) { 8281 let eventName = null; 8282 let increment = 1; 8283 let target = this.GLOBAL_TARGET;
8284 8285 if (args.length === 1) { 8286 if (Type.isNumber(args[0])) { 8287 increment = args[0]; 8288 } else if (Type.isString(args[0])) { 8289 eventName = args[0]; 8290 } else { 8291 target = args[0]; 8292 } 8293 } else if (args.length === 2) { 8294 if (Type.isString(args[0])) { 8295 [eventName, increment] = args; 8296 } else if (Type.isString(args[1])) { 8297 [target, eventName] = args; 8298 } else { 8299 [target, increment] = args; 8300 } 8301 } else if (args.length >= 3) { 8302 [target, eventName, increment] = args; 8303 } 8304 8305 if (!Type.isObject(target)) { 8306 throw new TypeError(`The "target" argument must be an object.`); 8307 } 8308 8309 if (eventName !== null && !Type.isStringFilled(eventName)) { 8310 throw new TypeError(`The "eventName" argument must be a string.`); 8311 } 8312 8313 if (!Type.isNumber(increment)) { 8314 throw new TypeError(`The value of "increment" must be a number.`); 8315 } 8316 8317 return [target, eventName, increment]; 8318 } 8319 /** 8320 * Gets listeners list for a specified event 8321 * @param {object} target 8322 * @param {string} eventName 8323 */ 8324 8325 }, { 8326 key: "getListeners", 8327 value: function getListeners(target, eventName) { 8328 if (Type.isString(target)) { 8329 eventName = target; 8330 target = this.GLOBAL_TARGET;
8331 } 8332 8333 if (!Type.isObject(target)) { 8334 throw new TypeError(`The "target" argument must be an object.`); 8335 } 8336 8337 eventName = this.normalizeEventName(eventName); 8338 8339 if (!Type.isStringFilled(eventName)) { 8340 throw new TypeError(`The "eventName" argument must be a string.`); 8341 } 8342 8343 const targetInfo = eventStore.get(target); 8344 8345 if (!targetInfo) { 8346 return new Map(); 8347 } 8348 8349 const fullEventName = this.resolveEventName(eventName, target); 8350 return targetInfo.eventsMap.get(fullEventName) || new Map(); 8351 } 8352 }, { 8353 key: "registerAliases", 8354 value: function registerAliases(aliases) { 8355 aliases = this.normalizeAliases(aliases); 8356 Object.keys(aliases).forEach(alias => { 8357 aliasStore.set(alias, { 8358 eventName: aliases[alias].eventName, 8359 namespace: aliases[alias].namespace 8360 }); 8361 }); 8362 EventEmitter.mergeEventAliases(aliases); 8363 } 8364 /** 8365 * @private 8366 * @param aliases 8367 */ 8368 8369 }, { 8370 key: "normalizeAliases", 8371 value: function normalizeAliases(aliases) { 8372 if (!Type.isPlainObject(aliases)) { 8373 throw new TypeError(`The "aliases" argument must be an object.`); 8374 } 8375 8376 const result = Object.create(null); 8377 8378 for (let alias in aliases) { 8379 if (!Type.isStringFilled(alias)) { 8380 throw new TypeError(`The alias must be an non-empty string.`); 8381 } 8382 8383 const options = aliases[alias]; 8384 8385 if (!options || !Type.isStringFilled(options.eventName) || !Type.isStringFilled(options.namespace)) { 8386 throw new TypeError(`The alias options must set the "eventName" and the "namespace".`); 8387 } 8388 8389 alias = this.normalizeEventName(alias); 8390 result[alias] = { 8391 eventName: options.eventName, 8392 namespace: options.namespace 8393 }; 8394 } 8395 8396 return result; 8397 } 8398 /** 8399 * @private 8400 */ 8401 8402 }, { 8403 key: "mergeEventAliases", 8404 value: function mergeEventAliases(aliases) { 8405 const globalEvents = eventStore.get(this.GLOBAL_TARGET); 8406 8407 if (!globalEvents) { 8408 return; 8409 } 8410 8411 Object.keys(aliases).forEach(alias => { 8412 const options = aliases[alias]; 8413 alias = this.normalizeEventName(alias); 8414 const fullEventName = this.makeFullEventName(options.namespace, options.eventName); 8415 const aliasListeners = globalEvents.eventsMap.get(alias); 8416 8417 if (aliasListeners) { 8418 const listeners = globalEvents.eventsMap.get(fullEventName) || new Map(); 8419 globalEvents.eventsMap.set(fullEventName, new Map([...listeners, ...aliasListeners])); 8420 globalEvents.eventsMap.delete(alias); 8421 } 8422 8423 const aliasOnceListeners = globalEvents.onceMap.get(alias); 8424 8425 if (aliasOnceListeners) { 8426 const onceListeners = globalEvents.onceMap.get(fullEventName) || new Map(); 8427 globalEvents.onceMap.set(fullEventName, new Map([...onceListeners, ...aliasOnceListeners])); 8428 globalEvents.onceMap.delete(alias); 8429 } 8430 8431 const aliasMaxListeners = globalEvents.eventsMaxListeners.get(alias); 8432 8433 if (aliasMaxListeners) { 8434 const eventMaxListeners = globalEvents.eventsMaxListeners.get(fullEventName) || 0; 8435 globalEvents.eventsMaxListeners.set(fullEventName, Math.max(eventMaxListeners, aliasMaxListeners)); 8436 globalEvents.eventsMaxListeners.delete(alias); 8437 } 8438 }); 8439 } 8440 /** 8441 * Returns true if the target is an instance of Event.EventEmitter 8442 * @param {object} target 8443 * @returns {boolean} 8444 */ 8445 8446 }, { 8447 key: "isEventEmitter", 8448 value: function isEventEmitter(target) { 8449 return Type.isObject(target) && target[isEmitterProperty] === true; 8450 } 8451 /** 8452 * @private 8453 * @param {string} eventName 8454 * @returns {string} 8455 */ 8456 8457 }, { 8458 key: "normalizeEventName", 8459 value: function normalizeEventName(eventName) { 8460 if (!Type.isStringFilled(eventName)) { 8461 return ''; 8462 } 8463 8464 return eventName.toLowerCase(); 8465 } 8466 /** 8467 * @private 8468 */ 8469 8470 }, { 8471 key: "normalizeListener", 8472 value: function normalizeListener(listener) { 8473 if (Type.isString(listener)) { 8474 listener = Reflection.getClass(listener); 8475 } 8476 8477 if (!Type.isFunction(listener)) { 8478 throw new TypeError(`The "listener" argument must be of type Function. Received type ${typeof listener}.`); 8479 } 8480 8481 return listener; 8482 } 8483 /** 8484 * @private 8485 * @param eventName 8486 * @param target 8487 * @param useGlobalNaming 8488 * @returns {string} 8489 */ 8490 8491 }, { 8492 key: "resolveEventName", 8493 value: function resolveEventName(eventName, target, useGlobalNaming = false) { 8494 eventName = this.normalizeEventName(eventName); 8495 8496 if (!Type.isStringFilled(eventName)) { 8497 return ''; 8498 } 8499 8500 if (this.isEventEmitter(target) && useGlobalNaming !== true) { 8501 if (target.getEventNamespace() !== null && eventName.includes('.')) { 8502 console.warn(`Possible the wrong event name "${eventName}".`); 8503 } 8504 8505 eventName = target.getFullEventName(eventName); 8506 } else if (aliasStore.has(eventName)) { 8507 const { 8508 namespace, 8509 eventName: actualEventName 8510 } = aliasStore.get(eventName); 8511 eventName = this.makeFullEventName(namespace, actualEventName); 8512 } 8513 8514 return eventName; 8515 } 8516 /** 8517 * @private 8518 * @param {string} namespace 8519 * @param {string} eventName 8520 * @returns {string} 8521 */ 8522 8523 }, { 8524 key: "makeFullEventName", 8525 value: function makeFullEventName(namespace, eventName) { 8526 const fullName = Type.isStringFilled(namespace) ? `${namespace}:${eventName}` : eventName; 8527 return Type.isStringFilled(fullName) ? fullName.toLowerCase() : ''; 8528 } 8529 }]); 8530 return EventEmitter; 8531 }(); 8532 8533 babelHelpers.defineProperty(EventEmitter, "GLOBAL_TARGET", globalTarget); 8534 babelHelpers.defineProperty(EventEmitter, "DEFAULT_MAX_LISTENERS", eventStore.getDefaultMaxListeners()); 8535 babelHelpers.defineProperty(EventEmitter, "sequenceValue", 1); 8536 8537 let stack = []; 8538 /** 8539 * For compatibility only 8540 * @type {boolean} 8541 */ 8542 // eslint-disable-next-line 8543 8544 exports.isReady = false;
8545 function ready(handler) { 8546 switch (document.readyState) { 8547 case 'loading': 8548 stack.push(handler); 8549 break; 8550 8551 case 'interactive': 8552 case 'complete': 8553 if (Type.isFunction(handler)) { 8554 handler(); 8555 } 8556 8557 exports.isReady = true; 8558 break; 8559 8560 default: 8561 break; 8562 } 8563 } 8564 document.addEventListener('readystatechange', () => { 8565 if (!exports.isReady) { 8566 stack.forEach(ready); 8567 stack = []; 8568 } 8569 }); 8570 8571 /** 8572 * @memberOf BX 8573 */ 8574 8575 let Event = function Event() { 8576 babelHelpers.classCallCheck(this, Event); 8577 }; 8578 8579 babelHelpers.defineProperty(Event, "bind", bind); 8580 babelHelpers.defineProperty(Event, "bindOnce", bindOnce); 8581 babelHelpers.defineProperty(Event, "unbind", unbind); 8582 babelHelpers.defineProperty(Event, "unbindAll", unbindAll); 8583 babelHelpers.defineProperty(Event, "ready", ready); 8584 babelHelpers.defineProperty(Event, "EventEmitter", EventEmitter); 8585 babelHelpers.defineProperty(Event, "BaseEvent", BaseEvent); 8586 8587 function encodeAttributeValue(value) { 8588 if (Type.isPlainObject(value) || Type.isArray(value)) { 8589 return JSON.stringify(value); 8590 } 8591 8592 return Text.encode(Text.decode(value)); 8593 } 8594 8595 function decodeAttributeValue(value) { 8596 if (Type.isString(value)) { 8597 const decodedValue = Text.decode(value); 8598 let result; 8599 8600 try { 8601 result = JSON.parse(decodedValue); 8602 } catch (e) { 8603 result = decodedValue; 8604 } 8605 8606 if (result === decodedValue) { 8607 if (/^[\d.]+[.]?\d+$/.test(result)) { 8608 return Number(result); 8609 } 8610 } 8611 8612 if (result === 'true' || result === 'false') { 8613 return Boolean(result); 8614 } 8615 8616 return result; 8617 } 8618 8619 return value; 8620 } 8621 8622 function getPageScroll() { 8623 const { 8624 documentElement, 8625 body 8626 } = document; 8627 const scrollTop = Math.max(window.pageYOffset || 0, documentElement ? documentElement.scrollTop : 0, body ? body.scrollTop : 0); 8628 const scrollLeft = Math.max(window.pageXOffset || 0, documentElement ? documentElement.scrollLeft : 0, body ? body.scrollLeft : 0); 8629 return { 8630 scrollTop, 8631 scrollLeft 8632 }; 8633 } 8634 8635 /** 8636 * @memberOf BX 8637 */ 8638 8639 let Dom = /*#__PURE__*/function () { 8640 function Dom() { 8641 babelHelpers.classCallCheck(this, Dom); 8642 } 8643 8644 babelHelpers.createClass(Dom, null, [{ 8645 key: "replace", 8646 8647 /** 8648 * Replaces old html element to new html element 8649 * @param oldElement 8650 * @param newElement 8651 */ 8652 value: function replace(oldElement, newElement) { 8653 if (Type.isDomNode(oldElement) && Type.isDomNode(newElement)) { 8654 if (Type.isDomNode(oldElement.parentNode)) { 8655 oldElement.parentNode.replaceChild(newElement, oldElement); 8656 } 8657 } 8658 } 8659 /** 8660 * Removes element 8661 * @param element 8662 */ 8663 8664 }, { 8665 key: "remove", 8666 value: function remove(element) { 8667 if (Type.isDomNode(element) && Type.isDomNode(element.parentNode)) { 8668 element.parentNode.removeChild(element); 8669 } 8670 } 8671 /** 8672 * Cleans element 8673 * @param element 8674 */ 8675 8676 }, { 8677 key: "clean", 8678 value: function clean(element) { 8679 if (Type.isDomNode(element)) { 8680 while (element.childNodes.length > 0) { 8681 element.removeChild(element.firstChild); 8682 } 8683 8684 return; 8685 } 8686 8687 if (Type.isString(element)) { 8688 Dom.clean(document.getElementById(element)); 8689 } 8690 } 8691 /** 8692 * Inserts element before target element 8693 * @param current 8694 * @param target 8695 */ 8696 8697 }, { 8698 key: "insertBefore", 8699 value: function insertBefore(current, target) { 8700 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8701 if (Type.isDomNode(target.parentNode)) { 8702 target.parentNode.insertBefore(current, target); 8703 } 8704 } 8705 } 8706 /** 8707 * Inserts element after target element 8708 * @param current 8709 * @param target 8710 */ 8711 8712 }, { 8713 key: "insertAfter", 8714 value: function insertAfter(current, target) { 8715 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8716 if (Type.isDomNode(target.parentNode)) { 8717 const parent = target.parentNode; 8718 8719 if (Type.isDomNode(target.nextSibling)) { 8720 parent.insertBefore(current, target.nextSibling); 8721 return; 8722 } 8723 8724 parent.appendChild(current); 8725 } 8726 } 8727 } 8728 /** 8729 * Appends element to target element 8730 * @param current 8731 * @param target 8732 */ 8733 8734 }, { 8735 key: "append", 8736 value: function append(current, target) { 8737 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8738 target.appendChild(current); 8739 } 8740 } 8741 /** 8742 * Prepends element to target element 8743 * @param current 8744 * @param target 8745 */ 8746 8747 }, {
8748 key: "prepend", 8749 value: function prepend(current, target) { 8750 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8751 if (Type.isDomNode(target.firstChild)) { 8752 target.insertBefore(current, target.firstChild); 8753 return; 8754 } 8755 8756 Dom.append(current, target); 8757 } 8758 } 8759 /** 8760 * Checks that element contains class name or class names 8761 * @param element 8762 * @param className 8763 * @return {Boolean} 8764 */ 8765 8766 }, { 8767 key: "hasClass", 8768 value: function hasClass(element, className) { 8769 if (Type.isElementNode(element)) { 8770 if (Type.isString(className)) { 8771 const preparedClassName = className.trim(); 8772 8773 if (preparedClassName.length > 0) { 8774 if (preparedClassName.includes(' ')) { 8775 return preparedClassName.split(' ').every(name => Dom.hasClass(element, name)); 8776 } 8777 8778 if ('classList' in element) { 8779 return element.classList.contains(preparedClassName); 8780 } 8781 8782 if (Type.isObject(element.className) && Type.isString(element.className.baseVal)) { 8783 return element.getAttribute('class').split(' ').some(name => name === preparedClassName); 8784 } 8785 } 8786 } 8787 8788 if (Type.isArray(className) && className.length > 0) { 8789 return className.every(name => Dom.hasClass(element, name)); 8790 } 8791 } 8792 8793 return false; 8794 } 8795 /** 8796 * Adds class name 8797 * @param element 8798 * @param className 8799 */ 8800 8801 }, { 8802 key: "addClass", 8803 value: function addClass(element, className) { 8804 if (Type.isElementNode(element)) { 8805 if (Type.isString(className)) { 8806 const preparedClassName = className.trim(); 8807 8808 if (preparedClassName.length > 0) { 8809 if (preparedClassName.includes(' ')) { 8810 Dom.addClass(element, preparedClassName.split(' ')); 8811 return; 8812 } 8813 8814 if ('classList' in element) { 8815 element.classList.add(preparedClassName); 8816 return; 8817 } 8818 8819 if (Type.isObject(element.className) && Type.isString(element.className.baseVal)) { 8820 if (element.className.baseVal === '') { 8821 element.className.baseVal = preparedClassName; 8822 return; 8823 } 8824 8825 const names = element.className.baseVal.split(' '); 8826 8827 if (!names.includes(preparedClassName)) { 8828 names.push(preparedClassName); 8829 element.className.baseVal = names.join(' ').trim(); 8830 return; 8831 } 8832 } 8833 8834 return; 8835 } 8836 } 8837 8838 if (Type.isArray(className)) { 8839 className.forEach(name => Dom.addClass(element, name)); 8840 } 8841 } 8842 } 8843 /** 8844 * Removes class name 8845 * @param element 8846 * @param className 8847 */ 8848 8849 }, { 8850 key: "removeClass", 8851 value: function removeClass(element, className) { 8852 if (Type.isElementNode(element)) { 8853 if (Type.isString(className)) { 8854 const preparedClassName = className.trim(); 8855 8856 if (preparedClassName.length > 0) { 8857 if (preparedClassName.includes(' ')) { 8858 Dom.removeClass(element, preparedClassName.split(' ')); 8859 return; 8860 } 8861 8862 if ('classList' in element) { 8863 element.classList.remove(preparedClassName); 8864 return; 8865 } 8866 8867 if (Type.isObject(element.className) && Type.isString(element.className.baseVal)) { 8868 const names = element.className.baseVal.split(' ').filter(name => name !== preparedClassName); 8869 element.className.baseVal = names.join(' '); 8870 return; 8871 } 8872 } 8873 } 8874 8875 if (Type.isArray(className)) { 8876 className.forEach(name => Dom.removeClass(element, name)); 8877 } 8878 } 8879 } 8880 /** 8881 * Toggles class name 8882 * @param element 8883 * @param className 8884 */ 8885 8886 }, { 8887 key: "toggleClass", 8888 value: function toggleClass(element, className) { 8889 if (Type.isElementNode(element)) { 8890 if (Type.isString(className)) { 8891 const preparedClassName = className.trim(); 8892 8893 if (preparedClassName.length > 0) { 8894 if (preparedClassName.includes(' ')) { 8895 Dom.toggleClass(element, preparedClassName.split(' ')); 8896 return; 8897 } 8898 8899 element.classList.toggle(preparedClassName); 8900 return; 8901 } 8902 } 8903 8904 if (Type.isArray(className)) { 8905 className.forEach(name => Dom.toggleClass(element, name)); 8906 } 8907 } 8908 } 8909 /** 8910 * Styles element 8911 */ 8912 8913 }, { 8914 key: "style", 8915 value: function style(element, prop, value) { 8916 if (Type.isElementNode(element)) { 8917 if (Type.isNull(prop)) { 8918 element.removeAttribute('style'); 8919 return element; 8920 } 8921 8922 if (Type.isPlainObject(prop)) {
8923 Object.entries(prop).forEach(item => { 8924 const [currentKey, currentValue] = item; 8925 Dom.style(element, currentKey, currentValue); 8926 }); 8927 return element; 8928 } 8929 8930 if (Type.isString(prop)) { 8931 if (Type.isUndefined(value) && element.nodeType !== Node.DOCUMENT_NODE) { 8932 const computedStyle = getComputedStyle(element); 8933 8934 if (prop in computedStyle) { 8935 return computedStyle[prop]; 8936 } 8937 8938 return computedStyle.getPropertyValue(prop); 8939 } 8940 8941 if (Type.isNull(value) || value === '' || value === 'null') { 8942 if (String(prop).startsWith('--')) { 8943 // eslint-disable-next-line 8944 element.style.removeProperty(prop); 8945 return element; 8946 } // eslint-disable-next-line 8947 8948 8949 element.style[prop] = ''; 8950 return element; 8951 } 8952 8953 if (Type.isString(value) || Type.isNumber(value)) { 8954 if (String(prop).startsWith('--')) { 8955 // eslint-disable-next-line 8956 element.style.setProperty(prop, value); 8957 return element; 8958 } // eslint-disable-next-line 8959 8960 8961 element.style[prop] = value; 8962 return element; 8963 } 8964 } 8965 } 8966 8967 return null; 8968 } 8969 /** 8970 * Adjusts element 8971 * @param target 8972 * @param data 8973 * @return {*} 8974 */ 8975 8976 }, { 8977 key: "adjust", 8978 value: function adjust(target, data = {}) { 8979 if (!target.nodeType) { 8980 return null; 8981 } 8982 8983 let element = target; 8984 8985 if (target.nodeType === Node.DOCUMENT_NODE) { 8986 element = target.body; 8987 } 8988 8989 if (Type.isPlainObject(data)) { 8990 if (Type.isPlainObject(data.attrs)) { 8991 Object.keys(data.attrs).forEach(key => { 8992 if (key === 'class' || key.toLowerCase() === 'classname') { 8993 element.className = data.attrs[key]; 8994 return; 8995 } // eslint-disable-next-line 8996 8997 8998 if (data.attrs[key] == '') { 8999 element.removeAttribute(key); 9000 return; 9001 } 9002 9003 element.setAttribute(key, data.attrs[key]); 9004 }); 9005 } 9006 9007 if (Type.isPlainObject(data.style)) { 9008 Dom.style(element, data.style); 9009 } 9010 9011 if (Type.isPlainObject(data.props)) { 9012 Object.keys(data.props).forEach(key => { 9013 element[key] = data.props[key]; 9014 }); 9015 } 9016 9017 if (Type.isPlainObject(data.events)) { 9018 Object.keys(data.events).forEach(key => { 9019 Event.bind(element, key, data.events[key]); 9020 }); 9021 } 9022 9023 if (Type.isPlainObject(data.dataset)) { 9024 Object.keys(data.dataset).forEach(key => { 9025 element.dataset[key] = data.dataset[key]; 9026 }); 9027 } 9028 9029 if (Type.isString(data.children)) { 9030 data.children = [data.children]; 9031 } 9032 9033 if (Type.isArray(data.children) && data.children.length > 0) { 9034 data.children.forEach(item => { 9035 if (Type.isDomNode(item)) { 9036 Dom.append(item, element); 9037 } 9038 9039 if (Type.isString(item)) { 9040 element.insertAdjacentHTML('beforeend', item); 9041 } 9042 }); 9043 return element; 9044 } 9045 9046 if ('text' in data && !Type.isNil(data.text)) { 9047 element.innerText = data.text; 9048 return element; 9049 } 9050 9051 if ('html' in data && !Type.isNil(data.html)) { 9052 element.innerHTML = data.html; 9053 } 9054 } 9055 9056 return element; 9057 } 9058 /** 9059 * Creates element 9060 * @param tag 9061 * @param data 9062 * @param context 9063 * @return {HTMLElement|HTMLBodyElement} 9064 */ 9065 9066 }, { 9067 key: "create", 9068 value: function create(tag, data = {}, context = document) { 9069 let tagName = tag; 9070 let options = data; 9071 9072 if (Type.isObjectLike(tag)) { 9073 options = tag; 9074 tagName = tag.tag; 9075 } 9076 9077 return Dom.adjust(context.createElement(tagName), options); 9078 } 9079 /** 9080 * Shows element 9081 * @param element 9082 */ 9083 9084 }, { 9085 key: "show", 9086 value: function show(element) { 9087 if (Type.isDomNode(element)) { 9088 // eslint-disable-next-line 9089 element.hidden = false;
9090 } 9091 } 9092 /** 9093 * Hides element 9094 * @param element 9095 */ 9096 9097 }, { 9098 key: "hide", 9099 value: function hide(element) { 9100 if (Type.isDomNode(element)) { 9101 // eslint-disable-next-line 9102 element.hidden = true; 9103 } 9104 } 9105 /** 9106 * Checks that element is shown 9107 * @param element 9108 * @return {*|boolean} 9109 */ 9110 9111 }, { 9112 key: "isShown", 9113 value: function isShown(element) { 9114 return Type.isDomNode(element) && !element.hidden && element.style.getPropertyValue('display') !== 'none'; 9115 } 9116 /** 9117 * Toggles element visibility 9118 * @param element 9119 */ 9120 9121 }, { 9122 key: "toggle", 9123 value: function toggle(element) { 9124 if (Type.isDomNode(element)) { 9125 if (Dom.isShown(element)) { 9126 Dom.hide(element); 9127 } else { 9128 Dom.show(element); 9129 } 9130 } 9131 } 9132 /** 9133 * Gets element position relative page 9134 * @param {HTMLElement} element 9135 * @return {DOMRect} 9136 */ 9137 9138 }, { 9139 key: "getPosition", 9140 value: function getPosition(element) { 9141 if (Type.isDomNode(element)) { 9142 const elementRect = element.getBoundingClientRect(); 9143 const { 9144 scrollLeft, 9145 scrollTop 9146 } = getPageScroll(); 9147 return new DOMRect(elementRect.left + scrollLeft, elementRect.top + scrollTop, elementRect.width, elementRect.height); 9148 } 9149 9150 return new DOMRect(); 9151 } 9152 /** 9153 * Gets element position relative specified element position 9154 * @param {HTMLElement} element 9155 * @param {HTMLElement} relationElement 9156 * @return {DOMRect} 9157 */ 9158 9159 }, { 9160 key: "getRelativePosition", 9161 value: function getRelativePosition(element, relationElement) { 9162 if (Type.isDomNode(element) && Type.isDomNode(relationElement)) { 9163 const elementPosition = Dom.getPosition(element); 9164 const relationElementPosition = Dom.getPosition(relationElement); 9165 return new DOMRect(elementPosition.left - relationElementPosition.left, elementPosition.top - relationElementPosition.top, elementPosition.width, elementPosition.height); 9166 } 9167 9168 return new DOMRect(); 9169 } 9170 }, { 9171 key: "attr", 9172 value: function attr(element, _attr, value) { 9173 if (Type.isElementNode(element)) { 9174 if (Type.isString(_attr)) { 9175 if (!Type.isNil(value)) { 9176 return element.setAttribute(_attr, encodeAttributeValue(value)); 9177 } 9178 9179 if (Type.isNull(value)) { 9180 return element.removeAttribute(_attr); 9181 } 9182 9183 return decodeAttributeValue(element.getAttribute(_attr)); 9184 } 9185 9186 if (Type.isPlainObject(_attr)) { 9187 return Object.entries(_attr).forEach(([attrKey, attrValue]) => { 9188 Dom.attr(element, attrKey, attrValue); 9189 }); 9190 } 9191 } 9192 9193 return null; 9194 } 9195 }]); 9196 return Dom; 9197 }(); 9198 9199 const UA = navigator.userAgent.toLowerCase(); 9200 /** 9201 * @memberOf BX 9202 */ 9203 9204 let Browser = /*#__PURE__*/function () { 9205 function Browser() { 9206 babelHelpers.classCallCheck(this, Browser); 9207 } 9208 9209 babelHelpers.createClass(Browser, null, [{ 9210 key: "isOpera", 9211 value: function isOpera() { 9212 return UA.includes('opera'); 9213 } 9214 }, { 9215 key: "isIE", 9216 value: function isIE() { 9217 return 'attachEvent' in document && !Browser.isOpera(); 9218 } 9219 }, { 9220 key: "isIE6", 9221 value: function isIE6() { 9222 return UA.includes('msie 6'); 9223 } 9224 }, { 9225 key: "isIE7", 9226 value: function isIE7() { 9227 return UA.includes('msie 7'); 9228 } 9229 }, { 9230 key: "isIE8", 9231 value: function isIE8() { 9232 return UA.includes('msie 8'); 9233 } 9234 }, { 9235 key: "isIE9", 9236 value: function isIE9() { 9237 return 'documentMode' in document && document.documentMode >= 9; 9238 } 9239 }, { 9240 key: "isIE10", 9241 value: function isIE10() { 9242 return 'documentMode' in document && document.documentMode >= 10; 9243 } 9244 }, { 9245 key: "isSafari", 9246 value: function isSafari() { 9247 return UA.includes('safari') && !UA.includes('chrome'); 9248 } 9249 }, { 9250 key: "isFirefox", 9251 value: function isFirefox() { 9252 return UA.includes('firefox'); 9253 } 9254 }, { 9255 key: "isChrome", 9256 value: function isChrome() { 9257 return UA.includes('chrome'); 9258 } 9259 }, { 9260 key: "detectIEVersion", 9261 value: function detectIEVersion() { 9262 if (Browser.isOpera() || Browser.isSafari() || Browser.isFirefox() || Browser.isChrome()) { 9263 return -1; 9264 } 9265 9266 let rv = -1; 9267 9268 if (!!window.MSStream && !window.ActiveXObject && 'ActiveXObject' in window) { 9269 rv = 11; 9270 } else if (Browser.isIE10()) { 9271 rv = 10; 9272 } else if (Browser.isIE9()) { 9273 rv = 9; 9274 } else if (Browser.isIE()) { 9275 rv = 8; 9276 } 9277 9278 if (rv === -1 || rv === 8) { 9279 if (navigator.appName === 'Microsoft Internet Explorer') { 9280 const re = new RegExp('MSIE ([0-9]+[.0-9]*)'); 9281 const res = navigator.userAgent.match(re); 9282 9283 if (Type.isArrayLike(res) && res.length > 0) { 9284 rv = parseFloat(res[1]); 9285 } 9286 } 9287 9288 if (navigator.appName === 'Netscape') { 9289 // Alternative check for IE 11 9290 rv = 11; 9291 const re = new RegExp('Trident/.*rv:([0-9]+[.0-9]*)'); 9292 9293 if (re.exec(navigator.userAgent) != null) { 9294 const res = navigator.userAgent.match(re); 9295 9296 if (Type.isArrayLike(res) && res.length > 0) { 9297 rv = parseFloat(res[1]); 9298 } 9299 } 9300 } 9301 } 9302 9303 return rv; 9304 } 9305 }, { 9306 key: "isIE11", 9307 value: function isIE11() { 9308 return Browser.detectIEVersion() >= 11; 9309 } 9310 }, { 9311 key: "isMac", 9312 value: function isMac() { 9313 return UA.includes('macintosh'); 9314 } 9315 }, { 9316 key: "isWin", 9317 value: function isWin() { 9318 return UA.includes('windows'); 9319 } 9320 }, { 9321 key: "isLinux", 9322 value: function isLinux() { 9323 return UA.includes('linux') && !Browser.isAndroid(); 9324 } 9325 }, { 9326 key: "isAndroid", 9327 value: function isAndroid() { 9328 return UA.includes('android'); 9329 } 9330 }, { 9331 key: "isIPad", 9332 value: function isIPad() { 9333 return UA.includes('ipad;') || this.isMac() && this.isTouchDevice(); 9334 } 9335 }, { 9336 key: "isIPhone", 9337 value: function isIPhone() { 9338 return UA.includes('iphone;'); 9339 } 9340 }, { 9341 key: "isIOS", 9342 value: function isIOS() { 9343 return Browser.isIPad() || Browser.isIPhone(); 9344 } 9345 }, { 9346 key: "isMobile", 9347 value: function isMobile() { 9348 return Browser.isIPhone() || Browser.isIPad() || Browser.isAndroid() || UA.includes('mobile') || UA.includes('touch'); 9349 } 9350 }, { 9351 key: "isRetina", 9352 value: function isRetina() { 9353 return window.devicePixelRatio && window.devicePixelRatio >= 2; 9354 } 9355 }, { 9356 key: "isTouchDevice", 9357 value: function isTouchDevice() { 9358 return 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0; 9359 } 9360 }, { 9361 key: "isDoctype", 9362 value: function isDoctype(target) { 9363 const doc = target || document; 9364 9365 if (doc.compatMode) { 9366 return doc.compatMode === 'CSS1Compat'; 9367 } 9368 9369 return doc.documentElement && doc.documentElement.clientHeight; 9370 } 9371 }, { 9372 key: "isLocalStorageSupported", 9373 value: function isLocalStorageSupported() { 9374 try { 9375 localStorage.setItem('test', 'test'); 9376 localStorage.removeItem('test'); 9377 return true; 9378 } catch (e) { 9379 return false;
9380 } 9381 } 9382 }, { 9383 key: "addGlobalClass", 9384 value: function addGlobalClass(target) { 9385 let globalClass = 'bx-core'; 9386 target = Type.isElementNode(target) ? target : document.documentElement; 9387 9388 if (Dom.hasClass(target, globalClass)) { 9389 return; 9390 } 9391 9392 if (Browser.isIOS()) { 9393 globalClass += ' bx-ios'; 9394 } else if (Browser.isWin()) { 9395 globalClass += ' bx-win'; 9396 } else if (Browser.isMac()) { 9397 globalClass += ' bx-mac'; 9398 } else if (Browser.isLinux()) { 9399 globalClass += ' bx-linux'; 9400 } else if (Browser.isAndroid()) { 9401 globalClass += ' bx-android'; 9402 } 9403 9404 globalClass += Browser.isMobile() ? ' bx-touch' : ' bx-no-touch'; 9405 globalClass += Browser.isRetina() ? ' bx-retina' : ' bx-no-retina'; 9406 9407 if (/AppleWebKit/.test(navigator.userAgent)) { 9408 globalClass += ' bx-chrome'; 9409 } else if (/Opera/.test(navigator.userAgent)) { 9410 globalClass += ' bx-opera'; 9411 } else if (Browser.isFirefox()) { 9412 globalClass += ' bx-firefox'; 9413 } 9414 9415 Dom.addClass(target, globalClass); 9416 } 9417 }, { 9418 key: "detectAndroidVersion", 9419 value: function detectAndroidVersion() { 9420 const re = new RegExp('Android ([0-9]+[.0-9]*)'); 9421 9422 if (re.exec(navigator.userAgent) != null) { 9423 const res = navigator.userAgent.match(re); 9424 9425 if (Type.isArrayLike(res) && res.length > 0) { 9426 return parseFloat(res[1]); 9427 } 9428 } 9429 9430 return 0; 9431 } 9432 }, { 9433 key: "isPropertySupported", 9434 value: function isPropertySupported(jsProperty, returnCSSName) { 9435 if (jsProperty === '') { 9436 return false; 9437 } 9438 9439 function getCssName(propertyName) { 9440 return propertyName.replace(/([A-Z])/g, (...args) => `-${args[1].toLowerCase()}`); 9441 } 9442 9443 function getJsName(cssName) { 9444 const reg = /(\\-([a-z]))/g; 9445 9446 if (reg.test(cssName)) { 9447 return cssName.replace(reg, (...args) => args[2].toUpperCase()); 9448 } 9449 9450 return cssName; 9451 } 9452 9453 const property = jsProperty.includes('-') ? getJsName(jsProperty) : jsProperty; 9454 const bReturnCSSName = !!returnCSSName; 9455 const ucProperty = property.charAt(0).toUpperCase() + property.slice(1); 9456 const props = ['Webkit', 'Moz', 'O', 'ms'].join(`${ucProperty} `); 9457 const properties = `${property} ${props} ${ucProperty}`.split(' '); 9458 const obj = document.body || document.documentElement; 9459 9460 for (let i = 0; i < properties.length; i += 1) { 9461 const prop = properties[i]; 9462 9463 if (obj && 'style' in obj && prop in obj.style) { 9464 const lowerProp = prop.substr(0, prop.length - property.length).toLowerCase(); 9465 const prefix = prop === property ? '' : `-${lowerProp}-`; 9466 return bReturnCSSName ? prefix + getCssName(property) : prop; 9467 } 9468 } 9469 9470 return false; 9471 } 9472 }, { 9473 key: "addGlobalFeatures", 9474 value: function addGlobalFeatures(features) { 9475 if (!Type.isArray(features)) { 9476 return; 9477 } 9478 9479 const classNames = []; 9480 9481 for (let i = 0; i < features.length; i += 1) { 9482 const support = !!Browser.isPropertySupported(features[i]); 9483 classNames.push(`bx-${support ? '' : 'no-'}${features[i].toLowerCase()}`); 9484 } 9485 9486 Dom.addClass(document.documentElement, classNames.join(' ')); 9487 } 9488 }]); 9489 return Browser; 9490 }(); 9491 9492 let Cookie = /*#__PURE__*/function () { 9493 function Cookie() { 9494 babelHelpers.classCallCheck(this, Cookie); 9495 } 9496 9497 babelHelpers.createClass(Cookie, null, [{ 9498 key: "getList", 9499 9500 /** 9501 * Gets cookies list for current domain 9502 * @return {object} 9503 */ 9504 value: function getList() { 9505 return document.cookie.split(';').map(item => item.split('=')).map(item => item.map(subItem => subItem.trim())).reduce((acc, item) => { 9506 const [key, value] = item; 9507 acc[decodeURIComponent(key)] = decodeURIComponent(value); 9508 return acc; 9509 }, {}); 9510 } 9511 /** 9512 * Gets cookie value 9513 * @param {string} name 9514 * @return {*} 9515 */ 9516 9517 }, { 9518 key: "get", 9519 value: function get(name) { 9520 const cookiesList = Cookie.getList(); 9521 9522 if (name in cookiesList) { 9523 return cookiesList[name]; 9524 } 9525 9526 return undefined; 9527 } 9528 /** 9529 * Sets cookie 9530 * @param {string} name 9531 * @param {*} value 9532 * @param {object} [options] 9533 */ 9534 9535 }, { 9536 key: "set", 9537 value: function set(name, value, options = {}) { 9538 const attributes = { 9539 expires: '', 9540 ...options 9541 }; 9542 9543 if (Type.isNumber(attributes.expires)) { 9544 const now = +new Date(); 9545 const days = attributes.expires; 9546 const dayInMs = 864e+5; 9547 attributes.expires = new Date(now + days * dayInMs); 9548 } 9549 9550 if (Type.isDate(attributes.expires)) { 9551 attributes.expires = attributes.expires.toUTCString(); 9552 } 9553 9554 const safeName = decodeURIComponent(String(name)).replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape); 9555 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); 9556 const stringifiedAttributes = Object.keys(attributes).reduce((acc, key) => { 9557 const attributeValue = attributes[key]; 9558 9559 if (!attributeValue) { 9560 return acc; 9561 } 9562 9563 if (attributeValue === true) { 9564 return `${acc}; ${key}`; 9565 } 9566 /** 9567 * Considers RFC 6265 section 5.2: 9568 * ... 9569 * 3. If the remaining unparsed-attributes contains a %x3B (';') 9570 * character: 9571 * Consume the characters of the unparsed-attributes up to, 9572 * not including, the first %x3B (';') character. 9573 */ 9574 9575 9576 return `${acc}; ${key}=${attributeValue.split(';')[0]}`; 9577 }, ''); 9578 document.cookie = `${safeName}=${safeValue}${stringifiedAttributes}`; 9579 } 9580 /** 9581 * Removes cookie 9582 * @param {string} name 9583 * @param {object} [options] 9584 */ 9585 9586 }, { 9587 key: "remove", 9588 value: function remove(name, options = {}) { 9589 Cookie.set(name, '', { ...options, 9590 expires: -1 9591 }); 9592 } 9593 }]); 9594 return Cookie; 9595 }(); 9596 9597 function objectToFormData(source, formData = new FormData(), pre = null) { 9598 if (Type.isUndefined(source)) { 9599 return formData; 9600 } 9601 9602 if (Type.isNull(source)) { 9603 formData.append(pre, ''); 9604 } else if (Type.isArray(source)) { 9605 if (!source.length) {
9606 const key = `${pre}[]`; 9607 formData.append(key, ''); 9608 } else { 9609 source.forEach((value, index) => { 9610 const key = `${pre}[${index}]`; 9611 objectToFormData(value, formData, key); 9612 }); 9613 } 9614 } else if (Type.isDate(source)) { 9615 formData.append(pre, source.toISOString()); 9616 } else if (Type.isObject(source) && !Type.isFile(source) && !Type.isBlob(source)) { 9617 Object.keys(source).forEach(property => { 9618 const value = source[property]; 9619 let preparedProperty = property; 9620 9621 if (Type.isArray(value)) { 9622 while (property.length > 2 && property.lastIndexOf('[]') === property.length - 2) { 9623 preparedProperty = property.substring(0, property.length - 2); 9624 } 9625 } 9626 9627 const key = pre ? `${pre}[${preparedProperty}]` : preparedProperty; 9628 objectToFormData(value, formData, key); 9629 }); 9630 } else { 9631 formData.append(pre, source); 9632 } 9633 9634 return formData; 9635 } 9636 9637 let Data = /*#__PURE__*/function () { 9638 function Data() { 9639 babelHelpers.classCallCheck(this, Data); 9640 } 9641 9642 babelHelpers.createClass(Data, null, [{ 9643 key: "convertObjectToFormData", 9644 9645 /** 9646 * Converts object to FormData 9647 * @param source 9648 * @return {FormData} 9649 */ 9650 value: function convertObjectToFormData(source) { 9651 return objectToFormData(source); 9652 } 9653 }]); 9654 return Data; 9655 }(); 9656 9657 /** 9658 * @memberOf BX 9659 */ 9660 9661 let Http = function Http() { 9662 babelHelpers.classCallCheck(this, Http); 9663 }; 9664 9665 babelHelpers.defineProperty(Http, "Cookie", Cookie); 9666 babelHelpers.defineProperty(Http, "Data", Data); 9667 9668 function message(value) { 9669 if (Type.isString(value)) { 9670 if (Type.isNil(message[value])) { 9671 // eslint-disable-next-line 9672 EventEmitter.emit('onBXMessageNotFound', new BaseEvent({ 9673 compatData: [value] 9674 })); 9675 9676 if (Type.isNil(message[value])) { 9677 Runtime.debug(`message undefined: ${value}`); 9678 message[value] = ''; 9679 } 9680 } 9681 } 9682 9683 if (Type.isPlainObject(value)) { 9684 Object.keys(value).forEach(key => { 9685 message[key] = value[key]; 9686 }); 9687 } 9688 9689 return message[value]; 9690 } 9691 9692 if (!Type.isNil(window.BX) && Type.isFunction(window.BX.message)) { 9693 Object.keys(window.BX.message).forEach(key => { 9694 message({ 9695 [key]: window.BX.message[key] 9696 }); 9697 }); 9698 } 9699 9700 /** 9701 * Implements interface for works with language messages 9702 * @memberOf BX 9703 */ 9704 9705 let Loc = /*#__PURE__*/function () { 9706 function Loc() { 9707 babelHelpers.classCallCheck(this, Loc); 9708 } 9709 9710 babelHelpers.createClass(Loc, null, [{ 9711 key: "getMessage", 9712 9713 /** 9714 * Gets message by id 9715 * @param {string} messageId 9716 * @param {object} replacements 9717 * @return {?string} 9718 */ 9719 value: function getMessage(messageId, replacements = null) { 9720 let mess = message(messageId); 9721 9722 if (Type.isString(mess) && Type.isPlainObject(replacements)) { 9723 Object.keys(replacements).forEach(replacement => { 9724 const globalRegexp = new RegExp(replacement, 'gi'); 9725 mess = mess.replace(globalRegexp, () => { 9726 return Type.isNil(replacements[replacement]) ? '' : String(replacements[replacement]); 9727 }); 9728 }); 9729 } 9730 9731 return mess; 9732 } 9733 }, { 9734 key: "hasMessage", 9735 value: function hasMessage(messageId) { 9736 return Type.isString(messageId) && !Type.isNil(message[messageId]); 9737 } 9738 /** 9739 * Sets message or messages 9740 * @param {string | Object<string, string>} id 9741 * @param {string} [value] 9742 */ 9743 9744 }, { 9745 key: "setMessage", 9746 value: function setMessage(id, value) { 9747 if (Type.isString(id) && Type.isString(value)) { 9748 message({ 9749 [id]: value 9750 }); 9751 } 9752 9753 if (Type.isObject(id)) { 9754 message(id); 9755 } 9756 } 9757 /** 9758 * Gets plural message by id and number 9759 * @param {string} messageId 9760 * @param {number} value 9761 * @param {object} [replacements] 9762 * @return {?string} 9763 */ 9764 9765 }, { 9766 key: "getMessagePlural", 9767 value: function getMessagePlural(messageId, value, replacements = null) { 9768 let result = ''; 9769 9770 if (Type.isNumber(value)) { 9771 if (this.hasMessage(`${messageId}_PLURAL_${this.getPluralForm(value)}`)) { 9772 result = this.getMessage(`${messageId}_PLURAL_${this.getPluralForm(value)}`, replacements); 9773 } else { 9774 result = this.getMessage(`${messageId}_PLURAL_1`, replacements); 9775 } 9776 } else { 9777 result = this.getMessage(messageId, replacements); 9778 } 9779 9780 return result; 9781 } 9782 /** 9783 * Gets language plural form id by number 9784 * see http://docs.translatehouse.org/projects/localization-guide/en/latest/l10n/pluralforms.html 9785 * @param {number} value 9786 * @param {string} [languageId] 9787 * @return {?number} 9788 */ 9789 9790 }, { 9791 key: "getPluralForm", 9792 value: function getPluralForm(value, languageId) { 9793 let pluralForm; 9794 9795 if (!Type.isStringFilled(languageId)) { 9796 languageId = message('LANGUAGE_ID'); 9797 } 9798 9799 if (value < 0) { 9800 value = -1 * value; 9801 } 9802 9803 switch (languageId) { 9804 case 'ar': 9805 pluralForm = value !== 1 ? 1 : 0; 9806 /* 9807 if (value === 0) 9808 { 9809 pluralForm = 0; 9810 } 9811 else if (value === 1) 9812 { 9813 pluralForm = 1; 9814 } 9815 else if (value === 2) 9816 { 9817 pluralForm = 2; 9818 } 9819 else if ( 9820 value % 100 >= 3 9821 && value % 100 <= 10 9822 ) 9823 { 9824 pluralForm = 3; 9825 } 9826 else if (value % 100 >= 11) 9827 { 9828 pluralForm = 4; 9829 } 9830 else 9831 { 9832 pluralForm = 5; 9833 } 9834 */ 9835 9836 break; 9837 9838 case 'br': 9839 case 'fr': 9840 case 'tr': 9841 pluralForm = value > 1 ? 1 : 0; 9842 break; 9843 9844 case 'de': 9845 case 'en': 9846 case 'hi': 9847 case 'it': 9848 case 'la': 9849 pluralForm = value !== 1 ? 1 : 0; 9850 break; 9851 9852 case 'ru': 9853 case 'ua': 9854 if (value % 10 === 1 && value % 100 !== 11) { 9855 pluralForm = 0; 9856 } else if (value % 10 >= 2 && value % 10 <= 4 && (value % 100 < 10 || value % 100 >= 20)) { 9857 pluralForm = 1; 9858 } else { 9859 pluralForm = 2; 9860 } 9861 9862 break; 9863 9864 case 'pl': 9865 if (value === 1) { 9866 pluralForm = 0; 9867 } else if (value % 10 >= 2 && value % 10 <= 4 && (value % 100 < 10 || value % 100 >= 20)) { 9868 pluralForm = 1; 9869 } else { 9870 pluralForm = 2; 9871 } 9872 9873 break; 9874 9875 case 'id': 9876 case 'ja': 9877 case 'ms': 9878 case 'sc': 9879 case 'tc': 9880 case 'th': 9881 case 'vn': 9882 pluralForm = 0; 9883 break; 9884 9885 default: 9886 pluralForm = 1; 9887 break; 9888 } 9889 9890 return pluralForm; 9891 } 9892 }]); 9893 return Loc; 9894 }(); 9895 9896 const voidElements = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr']; 9897 function isVoidElement(element) { 9898 return voidElements.includes(element); 9899 } 9900 9901 const matchers = { 9902 tag: /<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>|{{uid[0-9]+}}/g, 9903 comment: /<!--(?!<!)[^\[>].*?-->/g, 9904 tagName: /<\/?([^\s]+?)[/\s>]/, 9905 attributes: /\s([\w\-_:.]+)\s?\n?=\s?\n?"([^"]+)?"|\s([\w\-_:.]+)\s?\n?=\s?\n?'([^']+)?'|\s([\w\-_:.]+)/gs, 9906 placeholder: /{{uid[0-9]+}}/g 9907 }; 9908 9909 function parseTag(tag) { 9910 const tagResult = { 9911 type: 'tag', 9912 name: '', 9913 svg: false, 9914 attrs: {}, 9915 children: [], 9916 voidElement: false 9917 }; 9918 9919 if (tag.startsWith('<!--')) { 9920 const endIndex = tag.indexOf('-->'); 9921 const openTagLength = '<!--'.length; 9922 return { 9923 type: 'comment', 9924 content: endIndex !== -1 ? tag.slice(openTagLength, endIndex) : '' 9925 }; 9926 } 9927
9928 const tagNameMatch = tag.match(matchers.tagName); 9929 9930 if (Type.isArrayFilled(tagNameMatch)) { 9931 const [, tagName] = tagNameMatch; 9932 tagResult.name = tagName; 9933 tagResult.svg = tagName === 'svg'; 9934 tagResult.voidElement = isVoidElement(tagName) || tag.trim().endsWith('/>'); 9935 } 9936 9937 const reg = new RegExp(matchers.attributes); 9938 9939 for (;;) { 9940 const result = reg.exec(tag); 9941 9942 if (!Type.isNil(result)) { 9943 // Attributes with double quotes 9944 const [, attrName, attrValue] = result; 9945 9946 if (!Type.isNil(attrName)) { 9947 tagResult.attrs[attrName] = Type.isStringFilled(attrValue) ? attrValue : ''; 9948 } else { 9949 // Attributes with single quotes 9950 const [,,, attrName, attrValue] = result; 9951 9952 if (!Type.isNil(attrName)) { 9953 tagResult.attrs[attrName] = Type.isStringFilled(attrValue) ? attrValue : ''; 9954 } else { 9955 // Attributes without value 9956 const [,,,,, attrName] = result; 9957 tagResult.attrs[attrName] = ''; 9958 } 9959 } 9960 } else { 9961 break; 9962 } 9963 } 9964 9965 return tagResult; 9966 } 9967 9968 function parseText(input) { 9969 const preparedText = input.replace(/[\n\r\t]$/, ''); 9970 const placeholders = preparedText.match(matchers.placeholder); 9971 return preparedText.split(matchers.placeholder).reduce((acc, item, index) => { 9972 if (Type.isStringFilled(item)) { 9973 acc.push(...item.split(/\n/).reduce((textAcc, text) => { 9974 const preparedItemText = text.replace(/[\t\r]/g, ''); 9975 9976 if (Type.isStringFilled(preparedItemText)) { 9977 textAcc.push({ 9978 type: 'text', 9979 content: preparedItemText 9980 }); 9981 } 9982 9983 return textAcc; 9984 }, [])); 9985 } 9986 9987 if (placeholders && placeholders[index]) { 9988 acc.push({ 9989 type: 'placeholder', 9990 uid: parseInt(placeholders[index].replace(/{{uid|}}/, '')) 9991 }); 9992 } 9993 9994 return acc; 9995 }, []); 9996 } 9997 9998 function parse(html, substitutions) { 9999 const result = []; 10000 10001 if (html.indexOf('<') !== 0 && !html.startsWith('{{')) { 10002 const end = html.indexOf('<'); 10003 result.push(...parseText(end === -1 ? html : html.slice(0, end))); 10004 } 10005 10006 const commentsContent = []; 10007 let commentIndex = -1; 10008 html = html.replace(matchers.comment, tag => { 10009 commentIndex += 1; 10010 commentsContent.push(tag.replace(/^<!--|-->$/g, '')); 10011 return `<!--{{cUid${commentIndex}}}-->`; 10012 }); 10013 const arr = []; 10014 let level = -1; 10015 let current; 10016 html.replace(matchers.tag, (tag, index) => { 10017 const start = index + tag.length; 10018 const nextChar = html.charAt(start); 10019 let parent; 10020 10021 if (tag.startsWith('<!--')) { 10022 const comment = parseTag(tag, substitutions); 10023 comment.content = commentsContent[tag.replace(/<!--{{cUid|}}-->/g, '')]; 10024 10025 if (level < 0) { 10026 result.push(comment); 10027 return result; 10028 } 10029 10030 parent = arr[level]; 10031 parent.children.push(comment); 10032 return result; 10033 } 10034 10035 if (tag.startsWith('{{')) { 10036 const [placeholder] = parseText(tag); 10037 10038 if (level < 0) { 10039 result.push(placeholder); 10040 return result; 10041 } 10042 10043 parent = arr[level]; 10044 parent.children.push(placeholder); 10045 return result; 10046 } 10047 10048 if (!tag.startsWith('</')) { 10049 level++; 10050 current = parseTag(tag, substitutions); 10051 10052 if (!current.voidElement && nextChar && nextChar !== '<') { 10053 current.children.push(...parseText(html.slice(start, html.indexOf('<', start)))); 10054 } 10055 10056 if (level === 0) { 10057 result.push(current); 10058 } 10059 10060 parent = arr[level - 1]; 10061 10062 if (parent) { 10063 if (!current.svg) { 10064 current.svg = parent.svg; 10065 } 10066 10067 parent.children.push(current); 10068 } 10069 10070 arr[level] = current; 10071 } 10072 10073 if (tag.startsWith('</') || current.voidElement) { 10074 if (level > -1 && (current.voidElement || current.name === tag.slice(2, -1))) { 10075 level--; 10076 current = level === -1 ? result : arr[level]; 10077 } 10078 10079 if (nextChar && nextChar !== '<') { 10080 parent = level === -1 ? result : arr[level].children; 10081 const end = html.indexOf('<', start); 10082 const content = html.slice(start, end === -1 ? undefined : end); 10083 10084 if (end >
10084 -1 && level + parent.length >= 0 || content !== ' ') { 10085 parent.push(...parseText(content)); 10086 } 10087 } 10088 } 10089 }); 10090 return result; 10091 } 10092 10093 const appendElement = (current, target) => { 10094 if (Type.isDomNode(current) && Type.isDomNode(target)) { 10095 if (target.nodeName !== 'TEMPLATE') { 10096 Dom.append(current, target); 10097 } else { 10098 // eslint-disable-next-line bitrix-rules/no-native-dom-methods 10099 target.content.append(current); 10100 } 10101 } 10102 }; 10103 10104 function renderNode(options) { 10105 const { 10106 node, 10107 parentElement, 10108 substitutions 10109 } = options; 10110 10111 if (node.type === 'tag') { 10112 const element = (() => { 10113 if (node.svg) { 10114 return document.createElementNS('http://www.w3.org/2000/svg', node.name); 10115 } 10116 10117 return document.createElement(node.name); 10118 })(); 10119 10120 Object.entries(node.attrs).forEach(([key, value]) => { 10121 if (key.startsWith('on') && new RegExp(matchers.placeholder).test(value)) { 10122 const substitution = substitutions[parseInt(value.replace(/{{uid|}}/, '')) - 1]; 10123 10124 if (Type.isFunction(substitution)) { 10125 const bindFunctionName = key.endsWith('once') ? 'bindOnce' : 'bind'; 10126 Event[bindFunctionName](element, key.replace(/^on|once$/g, ''), substitution); 10127 } else { 10128 element.setAttribute(key, substitution); 10129 } 10130 } else { 10131 if (new RegExp(matchers.placeholder).test(value)) { 10132 const preparedValue = value.split(/{{|}}/).reduce((acc, item) => { 10133 if (item.startsWith('uid')) { 10134 const substitution = substitutions[parseInt(item.replace('uid', '')) - 1]; 10135 return `${acc}${substitution}`; 10136 } 10137 10138 return `${acc}${item}`; 10139 }, ''); 10140 element.setAttribute(key, preparedValue); 10141 } else { 10142 element.setAttribute(key, Text.decode(value)); 10143 } 10144 } 10145 }); 10146 node.children.forEach(childNode => { 10147 const result = renderNode({ 10148 node: childNode, 10149 parentElement: element, 10150 substitutions 10151 }); 10152 10153 if (Type.isArray(result)) { 10154 result.forEach(subChildElement => { 10155 appendElement(subChildElement, element); 10156 }); 10157 } else { 10158 appendElement(result, element); 10159 } 10160 }); 10161 return element; 10162 } 10163 10164 if (node.type === 'comment') { 10165 return document.createComment(node.content); 10166 } 10167 10168 if (node.type === 'text') { 10169 if (parentElement) { 10170 if (parentElement.nodeName !== 'TEMPLATE') { 10171 parentElement.insertAdjacentHTML('beforeend', node.content); 10172 } else { 10173 parentElement.content.append(node.content); 10174 } 10175 10176 return; 10177 } 10178 10179 return document.createTextNode(node.content); 10180 } 10181 10182 if (node.type === 'placeholder') { 10183 return substitutions[node.uid - 1]; 10184 } 10185 } 10186 10187 function render(sections, ...substitutions) { 10188 const html = sections.reduce((acc, item, index) => { 10189 if (index > 0) { 10190 const substitution = substitutions[index - 1]; 10191 10192 if (Type.isString(substitution) || Type.isNumber(substitution)) { 10193 return `${acc}${substitution}${item}`; 10194 } 10195 10196 return `${acc}{{uid${index}}}${item}`; 10197 } 10198 10199 return acc; 10200 }, sections[0]).replace(/^[\r\n\t\s]+/gm, '').replace(/>[\n]+/g, '>').replace(/[}][\n]+/g, '}'); 10201 const ast = parse(html); 10202 10203 if (ast.length === 1) { 10204 return renderNode({ 10205 node: ast[0], 10206 substitutions 10207 }); 10208 } 10209 10210 if (ast.length > 1) { 10211 return ast.map(node => { 10212 return renderNode({ 10213 node, 10214 substitutions 10215 }); 10216 }); 10217 } 10218 10219 return false; 10220 } 10221 10222 function parseProps(sections, ...substitutions) { 10223 return substitutions.reduce((acc, item, index) => { 10224 const nextSectionIndex = index + 1; 10225 10226 if (!Type.isPlainObject(item) && !Type.isArray(item)) { 10227 return acc + item + sections[nextSectionIndex]; 10228 } 10229 10230 return `${acc}__s${index}${sections[nextSectionIndex]}`; 10231 }, sections[0]).replace(/[\r\t]/gm, '').split(';\n').map(item => item.replace(/\n/, '')).reduce((acc, item) => { 10232 if (item !== '') { 10233 const matches = item.match(/^[\w-. ]+:/); 10234 const splitted = item.split(/^[\w-. ]+:/);
10235 const key = matches[0].replace(':', '').trim(); 10236 const value = splitted[1].trim(); 10237 const substitutionPlaceholderExp = /^__s\d+/; 10238 10239 if (substitutionPlaceholderExp.test(value)) { 10240 acc[key] = substitutions[value.replace('__s', '')]; 10241 return acc; 10242 } 10243 10244 acc[key] = value; 10245 } 10246 10247 return acc; 10248 }, {}); 10249 } 10250 /** 10251 * @memberOf BX 10252 */ 10253 10254 10255 let Tag = /*#__PURE__*/function () { 10256 function Tag() { 10257 babelHelpers.classCallCheck(this, Tag); 10258 } 10259 10260 babelHelpers.createClass(Tag, null, [{ 10261 key: "safe", 10262 10263 /** 10264 * Encodes all substitutions 10265 * @param sections 10266 * @param substitutions 10267 * @return {string} 10268 */ 10269 value: function safe(sections, ...substitutions) { 10270 return substitutions.reduce((acc, item, index) => acc + Text.encode(item) + sections[index + 1], sections[0]); 10271 } 10272 /** 10273 * Decodes all substitutions 10274 * @param sections 10275 * @param substitutions 10276 * @return {string} 10277 */ 10278 10279 }, { 10280 key: "unsafe", 10281 value: function unsafe(sections, ...substitutions) { 10282 return substitutions.reduce((acc, item, index) => acc + Text.decode(item) + sections[index + 1], sections[0]); 10283 } 10284 /** 10285 * Adds styles to specified element 10286 * @param {HTMLElement} element 10287 * @return {Function} 10288 */ 10289 10290 }, { 10291 key: "style", 10292 value: function style(element) { 10293 if (!Type.isDomNode(element)) { 10294 throw new Error('element is not HTMLElement'); 10295 } 10296 10297 return function styleTagHandler(...args) { 10298 Dom.style(element, parseProps(...args)); 10299 }; 10300 } 10301 /** 10302 * Replace all messages identifiers to real messages 10303 * @param sections 10304 * @param substitutions 10305 * @return {string} 10306 */ 10307 10308 }, { 10309 key: "message", 10310 value: function message(sections, ...substitutions) { 10311 return substitutions.reduce((acc, item, index) => acc + Loc.getMessage(item) + sections[index + 1], sections[0]); 10312 } 10313 }, { 10314 key: "attrs", 10315 10316 /** 10317 * Adds attributes to specified element 10318 * @param element 10319 * @return {Function} 10320 */ 10321 value: function attrs(element) { 10322 if (!Type.isDomNode(element)) { 10323 throw new Error('element is not HTMLElement'); 10324 } 10325 10326 return function attrsTagHandler(...args) { 10327 Dom.attr(element, parseProps(...args)); 10328 }; 10329 } 10330 }]); 10331 return Tag; 10332 }(); 10333 10334 babelHelpers.defineProperty(Tag, "render", render); 10335 babelHelpers.defineProperty(Tag, "attr", Tag.attrs); 10336 10337 function getParser(format) { 10338 switch (format) { 10339 case 'index': 10340 return (sourceKey, value, accumulator) => { 10341 const result = /\[(\w*)\]$/.exec(sourceKey); 10342 const key = sourceKey.replace(/\[\w*\]$/, ''); 10343 10344 if (Type.isNil(result)) { 10345 accumulator[key] = value; 10346 return; 10347 } 10348 10349 if (Type.isUndefined(accumulator[key])) { 10350 accumulator[key] = {}; 10351 } 10352 10353 accumulator[key][result[1]] = value; 10354 }; 10355 10356 case 'bracket': 10357 return (sourceKey, value, accumulator) => { 10358 const result = /(\[\])$/.exec(sourceKey); 10359 const key = sourceKey.replace(/\[\]$/, ''); 10360 10361 if (Type.isNil(result)) { 10362 accumulator[key] = value; 10363 return; 10364 } 10365 10366 if (Type.isUndefined(accumulator[key])) { 10367 accumulator[key] = [value]; 10368 return; 10369 } 10370 10371 accumulator[key] = [].concat(accumulator[key], value); 10372 }; 10373 10374 default: 10375 return (sourceKey, value, accumulator) => { 10376 const key = sourceKey.replace(/\[\]$/, ''); 10377 accumulator[key] = value; 10378 }; 10379 } 10380 } 10381 10382 function getKeyFormat(key) { 10383 if (/^\w+\[([\w]+)\]$/.test(key)) { 10384 return 'index'; 10385 } 10386 10387 if (/^\w+\[\]$/.test(key)) { 10388 return 'bracket'; 10389 } 10390 10391 return 'default'; 10392 } 10393 10394 function parseQuery(input) { 10395 if (!Type.isString(input)) { 10396 return {}; 10397 } 10398 10399 const url = input.trim().replace(/^[?#&]/, ''); 10400 10401 if (!url) { 10402 return {}; 10403 } 10404 10405 return url.split('&').reduce((acc, param) => { 10406 const [key, value] = param.replace(/\+/g, ' ').split('=');
10407 const keyFormat = getKeyFormat(key); 10408 const formatter = getParser(keyFormat); 10409 formatter(key, value, acc); 10410 return acc; 10411 }, {}); 10412 } 10413 10414 const urlExp = /^((\w+):)?(\/\/((\w+)?(:(\w+))?@)?([^\/\?:]+)(:(\d+))?)?(\/?([^\/\?#][^\?#]*)?)?(\?([^#]+))?(#(\w*))?/; 10415 function parseUrl(url) { 10416 const result = url.match(urlExp); 10417 10418 if (Type.isArray(result)) { 10419 const queryParams = parseQuery(result[14]); 10420 return { 10421 useShort: /^\/\//.test(url), 10422 href: result[0] || '', 10423 schema: result[2] || '', 10424 host: result[8] || '', 10425 port: result[10] || '', 10426 path: result[11] || '', 10427 query: result[14] || '', 10428 queryParams, 10429 hash: result[16] || '', 10430 username: result[5] || '', 10431 password: result[7] || '', 10432 origin: result[8] || '' 10433 }; 10434 } 10435 10436 return {}; 10437 } 10438 10439 function buildQueryString(params = {}) { 10440 const queryString = Object.keys(params).reduce((acc, key) => { 10441 if (Type.isArray(params[key])) { 10442 params[key].forEach(paramValue => { 10443 acc.push(`${key}[]=${paramValue}`); 10444 }, ''); 10445 } 10446 10447 if (Type.isPlainObject(params[key])) { 10448 Object.keys(params[key]).forEach(paramIndex => { 10449 acc.push(`${key}[${paramIndex}]=${params[key][paramIndex]}`); 10450 }, ''); 10451 } 10452 10453 if (!Type.isObject(params[key]) && !Type.isArray(params[key])) { 10454 acc.push(`${key}=${params[key]}`); 10455 } 10456 10457 return acc; 10458 }, []).join('&'); 10459 10460 if (queryString.length > 0) { 10461 return `?${queryString}`; 10462 } 10463 10464 return queryString; 10465 } 10466 10467 function prepareParamValue(value) { 10468 if (Type.isArray(value)) { 10469 return value.map(item => String(item)); 10470 } 10471 10472 if (Type.isPlainObject(value)) { 10473 return { ...value 10474 }; 10475 } 10476 10477 return String(value); 10478 } 10479 10480 const map = new WeakMap(); 10481 /** 10482 * Implements interface for works with URI 10483 * @memberOf BX 10484 */ 10485 10486 let Uri = /*#__PURE__*/function () { 10487 babelHelpers.createClass(Uri, null, [{ 10488 key: "addParam", 10489 value: function addParam(url, params = {}) { 10490 return new Uri(url).setQueryParams(params).toString(); 10491 } 10492 }, { 10493 key: "removeParam", 10494 value: function removeParam(url, params) { 10495 const removableParams = Type.isArray(params) ? params : [params]; 10496 return new Uri(url).removeQueryParam(...removableParams).toString(); 10497 } 10498 }]); 10499 10500 function Uri(url = '') { 10501 babelHelpers.classCallCheck(this, Uri); 10502 map.set(this, parseUrl(url)); 10503 } 10504 /** 10505 * Gets schema 10506 * @return {?string} 10507 */ 10508 10509 10510 babelHelpers.createClass(Uri, [{ 10511 key: "getSchema", 10512 value: function getSchema() { 10513 return map.get(this).schema; 10514 } 10515 /** 10516 * Sets schema 10517 * @param {string} schema 10518 * @return {Uri} 10519 */ 10520 10521 }, { 10522 key: "setSchema", 10523 value: function setSchema(schema) { 10524 map.get(this).schema = String(schema); 10525 return this; 10526 } 10527 /** 10528 * Gets host 10529 * @return {?string} 10530 */ 10531 10532 }, { 10533 key: "getHost", 10534 value: function getHost() { 10535 return map.get(this).host; 10536 } 10537 /** 10538 * Sets host 10539 * @param {string} host 10540 * @return {Uri} 10541 */ 10542 10543 }, { 10544 key: "setHost", 10545 value: function setHost(host) { 10546 map.get(this).host = String(host); 10547 return this; 10548 } 10549 /** 10550 * Gets port 10551 * @return {?string} 10552 */ 10553 10554 }, { 10555 key: "getPort", 10556 value: function getPort() { 10557 return map.get(this).port; 10558 } 10559 /** 10560 * Sets port 10561 * @param {String | Number} port 10562 * @return {Uri} 10563 */ 10564 10565 }, { 10566 key: "setPort", 10567 value: function setPort(port) { 10568 map.get(this).port = String(port); 10569 return this; 10570 } 10571 /** 10572 * Gets path 10573 * @return {?string} 10574 */ 10575 10576 }, { 10577 key: "getPath", 10578 value: function getPath() { 10579 return map.get(this).path; 10580 } 10581 /** 10582 * Sets path 10583 * @param {string} path 10584 * @return {Uri} 10585 */ 10586 10587 }, { 10588 key: "setPath", 10589 value: function setPath(path) { 10590 if (!/^\//.test(path)) { 10591 map.get(this).path = `/${String(path)}`; 10592 return this; 10593 } 10594 10595 map.get(this).path = String(path); 10596 return this; 10597 } 10598 /** 10599 * Gets query 10600 * @return {?string} 10601 */ 10602 10603 }, { 10604 key: "getQuery", 10605 value: function getQuery() { 10606 return buildQueryString(map.get(this).queryParams); 10607 } 10608 /** 10609 * Gets query param value by name 10610 * @param {string} key 10611 * @return {?string} 10612 */ 10613 10614 }, { 10615 key: "getQueryParam", 10616 value: function getQueryParam(key) { 10617 const params = this.getQueryParams(); 10618 10619 if (key in params) { 10620 return params[key]; 10621 } 10622 10623 return null; 10624 } 10625 /** 10626 * Sets query param 10627 * @param {string} key 10628 * @param [value] 10629 * @return {Uri} 10630 */ 10631 10632 }, { 10633 key: "setQueryParam", 10634 value: function setQueryParam(key, value = '') { 10635 map.get(this).queryParams[key] = prepareParamValue(value); 10636 return this; 10637 } 10638 /** 10639 * Gets query params 10640 * @return {Object<string, any>} 10641 */ 10642 10643 }, { 10644 key: "getQueryParams", 10645 value: function getQueryParams() { 10646 return { ...map.get(this).queryParams 10647 }; 10648 } 10649 /** 10650 * Sets query params 10651 * @param {Object<string, any>} params 10652 * @return {Uri} 10653 */ 10654 10655 }, { 10656 key: "setQueryParams", 10657 value: function setQueryParams(params = {}) {
10658 const currentParams = this.getQueryParams(); 10659 const newParams = { ...currentParams, 10660 ...params 10661 }; 10662 Object.keys(newParams).forEach(key => { 10663 newParams[key] = prepareParamValue(newParams[key]); 10664 }); 10665 map.get(this).queryParams = newParams; 10666 return this; 10667 } 10668 /** 10669 * Removes query params by name 10670 * @param keys 10671 * @return {Uri} 10672 */ 10673 10674 }, { 10675 key: "removeQueryParam", 10676 value: function removeQueryParam(...keys) { 10677 const currentParams = { ...map.get(this).queryParams 10678 }; 10679 keys.forEach(key => { 10680 if (key in currentParams) { 10681 delete currentParams[key]; 10682 } 10683 }); 10684 map.get(this).queryParams = currentParams; 10685 return this; 10686 } 10687 /** 10688 * Gets fragment 10689 * @return {?string} 10690 */ 10691 10692 }, { 10693 key: "getFragment", 10694 value: function getFragment() { 10695 return map.get(this).hash; 10696 } 10697 /** 10698 * Sets fragment 10699 * @param {string} hash 10700 * @return {Uri} 10701 */ 10702 10703 }, { 10704 key: "setFragment", 10705 value: function setFragment(hash) { 10706 map.get(this).hash = String(hash); 10707 return this; 10708 } 10709 /** 10710 * Serializes URI 10711 * @return {Object} 10712 */ 10713 10714 }, { 10715 key: "serialize", 10716 value: function serialize() { 10717 const serialized = { ...map.get(this) 10718 }; 10719 serialized.href = this.toString(); 10720 return serialized; 10721 } 10722 /** 10723 * Gets URI string 10724 * @return {string} 10725 */ 10726 10727 }, { 10728 key: "toString", 10729 value: function toString() { 10730 const data = { ...map.get(this) 10731 }; 10732 let protocol = data.schema ? `${data.schema}://` : ''; 10733 10734 if (data.useShort) { 10735 protocol = '//'; 10736 } 10737 10738 const port = (() => { 10739 if (Type.isString(data.port) && !['', '80'].includes(data.port)) { 10740 return `:${data.port}`; 10741 } 10742 10743 return ''; 10744 })(); 10745 10746 const host = this.getHost(); 10747 const path = this.getPath(); 10748 const query = buildQueryString(data.queryParams); 10749 const hash = data.hash ? `#${data.hash}` : ''; 10750 return `${host ? protocol : ''}${host}${host ? port : ''}${path}${query}${hash}`; 10751 } 10752 }]); 10753 return Uri; 10754 }(); 10755 10756 /** 10757 * @memberOf BX 10758 */ 10759 let Validation = /*#__PURE__*/function () { 10760 function Validation() { 10761 babelHelpers.classCallCheck(this, Validation); 10762 } 10763 10764 babelHelpers.createClass(Validation, null, [{ 10765 key: "isEmail", 10766 10767 /** 10768 * Checks that value is valid email 10769 * @param value 10770 * @return {boolean} 10771 */ 10772 value: function isEmail(value) { 10773 const exp = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/; 10774 return exp.test(String(value).toLowerCase()); 10775 } 10776 }]); 10777 return Validation; 10778 }(); 10779 10780 let BaseCache = /*#__PURE__*/function () { 10781 function BaseCache() { 10782 babelHelpers.classCallCheck(this, BaseCache); 10783 babelHelpers.defineProperty(this, "storage", new Map()); 10784 } 10785 10786 babelHelpers.createClass(BaseCache, [{ 10787 key: "get", 10788 10789 /** 10790 * Gets cached value or default value 10791 */ 10792 value: function get(key, defaultValue) { 10793 if (!this.storage.has(key)) { 10794 if (Type.isFunction(defaultValue)) { 10795 return defaultValue(); 10796 } 10797 10798 if (!Type.isUndefined(defaultValue)) { 10799 return defaultValue; 10800 } 10801 } 10802 10803 return this.storage.get(key); 10804 } 10805 /** 10806 * Sets cache entry 10807 */ 10808 10809 }, { 10810 key: "set", 10811 value: function set(key, value) { 10812 this.storage.set(key, value); 10813 } 10814 /** 10815 * Deletes cache entry 10816 */ 10817 10818 }, { 10819 key: "delete", 10820 value: function _delete(key) { 10821 this.storage.delete(key); 10822 } 10823 /** 10824 * Checks that storage contains entry with specified key 10825 */ 10826 10827 }, { 10828 key: "has", 10829 value: function has(key) { 10830 return this.storage.has(key); 10831 } 10832 /** 10833 * Gets cached value if exists, 10834 */ 10835 10836 }, { 10837 key: "remember", 10838 value: function remember(key, defaultValue) { 10839 if (!this.storage.has(key)) { 10840 if (Type.isFunction(defaultValue)) { 10841 this.storage.set(key, defaultValue()); 10842 } else if (!Type.isUndefined(defaultValue)) { 10843 this.storage.set(key, defaultValue); 10844 } 10845 } 10846 10847 return this.storage.get(key); 10848 } 10849 /** 10850 * Gets storage size 10851 */ 10852 10853 }, { 10854 key: "size", 10855 value: function size() { 10856 return this.storage.size; 10857 } 10858 /** 10859 * Gets storage keys 10860 */ 10861 10862 }, { 10863 key: "keys", 10864 value: function keys() { 10865 return [...this.storage.keys()]; 10866 } 10867 /** 10868 * Gets storage values 10869 */ 10870 10871 }, { 10872 key: "values", 10873 value: function values() { 10874 return [...this.storage.values()]; 10875 } 10876 }]); 10877 return BaseCache; 10878 }(); 10879 10880 let MemoryCache = /*#__PURE__*/function (_BaseCache) { 10881 babelHelpers.inherits(MemoryCache, _BaseCache); 10882 10883 function MemoryCache(...args) { 10884 var _this; 10885 10886 babelHelpers.classCallCheck(this, MemoryCache); 10887 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(MemoryCache).call(this, ...args)); 10888 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "storage", new Map()); 10889 return _this; 10890 } 10891 10892 return MemoryCache; 10893 }(BaseCache); 10894 10895 let LsStorage = /*#__PURE__*/function () { 10896 function LsStorage() { 10897 babelHelpers.classCallCheck(this, LsStorage); 10898 babelHelpers.defineProperty(this, "stackKey", 'BX.Cache.Storage.LsStorage.stack'); 10899 babelHelpers.defineProperty(this, "stack", null); 10900 } 10901 10902 babelHelpers.createClass(LsStorage, [{ 10903 key: "getStack", 10904 10905 /** 10906 * @private 10907 */ 10908 value: function getStack() { 10909 if (Type.isPlainObject(this.stack)) { 10910 return this.stack; 10911 } 10912 10913 const stack = localStorage.getItem(this.stackKey); 10914 10915 if (Type.isString(stack) && stack !== '') { 10916 const parsedStack = JSON.parse(stack); 10917 10918 if (Type.isPlainObject(parsedStack)) { 10919 this.stack = parsedStack; 10920 return this.stack; 10921 } 10922 } 10923 10924 this.stack = {}; 10925 return this.stack; 10926 } 10927 /** 10928 * @private 10929 */ 10930 10931 }, { 10932 key: "saveStack", 10933 value: function saveStack() { 10934 if (Type.isPlainObject(this.stack)) { 10935 const preparedStack = JSON.stringify(this.stack); 10936 localStorage.setItem(this.stackKey, preparedStack); 10937 } 10938 } 10939 }, { 10940 key: "get", 10941 value: function get(key) {
10942 const stack = this.getStack(); 10943 return stack[key]; 10944 } 10945 }, { 10946 key: "set", 10947 value: function set(key, value) { 10948 const stack = this.getStack(); 10949 stack[key] = value; 10950 this.saveStack(); 10951 } 10952 }, { 10953 key: "delete", 10954 value: function _delete(key) { 10955 const stack = this.getStack(); 10956 10957 if (key in stack) { 10958 delete stack[key]; 10959 } 10960 } 10961 }, { 10962 key: "has", 10963 value: function has(key) { 10964 const stack = this.getStack(); 10965 return key in stack; 10966 } 10967 }, { 10968 key: "keys", 10969 value: function keys() { 10970 const stack = this.getStack(); 10971 return Object.keys(stack); 10972 } 10973 }, { 10974 key: "values", 10975 value: function values() { 10976 const stack = this.getStack(); 10977 return Object.values(stack); 10978 } 10979 }, { 10980 key: "size", 10981 get: function () { 10982 const stack = this.getStack(); 10983 return Object.keys(stack).length; 10984 } 10985 }]); 10986 return LsStorage; 10987 }(); 10988 10989 let LocalStorageCache = /*#__PURE__*/function (_BaseCache) { 10990 babelHelpers.inherits(LocalStorageCache, _BaseCache); 10991 10992 function LocalStorageCache(...args) { 10993 var _this; 10994 10995 babelHelpers.classCallCheck(this, LocalStorageCache); 10996 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(LocalStorageCache).call(this, ...args)); 10997 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "storage", new LsStorage()); 10998 return _this; 10999 } 11000 11001 return LocalStorageCache; 11002 }(BaseCache); 11003 11004 /** 11005 * @memberOf BX 11006 */ 11007 11008 let Cache = function Cache() { 11009 babelHelpers.classCallCheck(this, Cache); 11010 }; 11011 11012 babelHelpers.defineProperty(Cache, "MemoryCache", MemoryCache); 11013 babelHelpers.defineProperty(Cache, "LocalStorageCache", LocalStorageCache); 11014 11015 function convertPath(path) { 11016 if (Type.isStringFilled(path)) { 11017 return path.split('.').reduce((acc, item) => { 11018 item.split(/\[['"]?(.+?)['"]?\]/g).forEach(key => { 11019 if (Type.isStringFilled(key)) { 11020 acc.push(key); 11021 } 11022 }); 11023 return acc; 11024 }, []); 11025 } 11026 11027 return []; 11028 } 11029 11030 let SettingsCollection = /*#__PURE__*/function () { 11031 function SettingsCollection(options = {}) { 11032 babelHelpers.classCallCheck(this, SettingsCollection); 11033 11034 if (Type.isPlainObject(options)) { 11035 Object.assign(this, options); 11036 } 11037 } 11038 11039 babelHelpers.createClass(SettingsCollection, [{ 11040 key: "get", 11041 value: function get(path, defaultValue = null) { 11042 const convertedPath = convertPath(path); 11043 return convertedPath.reduce((acc, key) => { 11044 if (!Type.isNil(acc) && acc !== defaultValue) { 11045 if (!Type.isUndefined(acc[key])) { 11046 return acc[key]; 11047 } 11048 11049 return defaultValue; 11050 } 11051 11052 return acc; 11053 }, this); 11054 } 11055 }]); 11056 return SettingsCollection; 11057 }(); 11058 11059 function deepFreeze(target) { 11060 if (Type.isObject(target)) { 11061 Object.values(target).forEach(value => { 11062 deepFreeze(value); 11063 }); 11064 return Object.freeze(target); 11065 } 11066 11067 return target; 11068 } 11069 11070 const settingsStorage = new Map(); 11071 11072 let Extension$1 = /*#__PURE__*/function () { 11073 function Extension() { 11074 babelHelpers.classCallCheck(this, Extension); 11075 } 11076 11077 babelHelpers.createClass(Extension, null, [{ 11078 key: "getSettings", 11079 value: function getSettings(extensionName) { 11080 if (Type.isStringFilled(extensionName)) { 11081 if (settingsStorage.has(extensionName)) { 11082 return settingsStorage.get(extensionName); 11083 } 11084 11085 const settingsScriptNode = document.querySelector(`script[data-extension="${extensionName}"]`); 11086 11087 if (Type.isDomNode(settingsScriptNode)) { 11088 const decodedSettings = (() => { 11089 try { 11090 return new SettingsCollection(JSON.parse(settingsScriptNode.innerHTML)); 11091 } catch (error) { 11092 return new SettingsCollection(); 11093 } 11094 })(); 11095 11096 const frozenSettings = deepFreeze(decodedSettings); 11097 settingsStorage.set(extensionName, frozenSettings); 11098 return frozenSettings; 11099 } 11100 } 11101 11102 return deepFreeze(new SettingsCollection()); 11103 } 11104 }]); 11105 return Extension; 11106 }(); 11107 11108 let _Symbol$iterator; 11109 11110 function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); } 11111 11112 function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } } 11113 11114 function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; } 11115 11116 var _searchIndexToInsert = /*#__PURE__*/new WeakSet(); 11117 11118 _Symbol$iterator = Symbol.iterator; 11119 11120 let OrderedArray = /*#__PURE__*/function () { 11121 function OrderedArray(comparator = null) { 11122 babelHelpers.classCallCheck(this, OrderedArray); 11123 11124 _classPrivateMethodInitSpec(this, _searchIndexToInsert); 11125 11126 babelHelpers.defineProperty(this, "comparator", null); 11127 babelHelpers.defineProperty(this, "items", []); 11128 this.comparator = Type.isFunction(comparator) ? comparator : null; 11129 } 11130 11131 babelHelpers.createClass(OrderedArray, [{ 11132 key: "add", 11133 value: function add(item) { 11134 let index = -1; 11135 11136 if (this.comparator) { 11137 index = _classPrivateMethodGet(this, _searchIndexToInsert, _searchIndexToInsert2).call(this, item); 11138 this.items.splice(index, 0, item); 11139 } else { 11140 this.items.push(item); 11141 } 11142 11143 return index; 11144 } 11145 }, { 11146 key: "has", 11147 value: function has(item) { 11148 return this.items.includes(item); 11149 } 11150 }, { 11151 key: "getIndex", 11152 value: function getIndex(item) { 11153 return this.items.indexOf(item); 11154 } 11155 }, { 11156 key: "getByIndex", 11157 value: function getByIndex(index) { 11158 if (Type.isNumber(index) && index >= 0) { 11159 const item = this.items[index]; 11160 return Type.isUndefined(item) ? null : item; 11161 } 11162 11163 return null; 11164 } 11165 }, { 11166 key: "getFirst", 11167 value: function getFirst() { 11168 const first = this.items[0]; 11169 return Type.isUndefined(first) ? null : first; 11170 } 11171 }, { 11172 key: "getLast", 11173 value: function getLast() { 11174 const last = this.items[this.count() - 1]; 11175 return Type.isUndefined(last) ? null : last; 11176 } 11177 }, { 11178 key: "count", 11179 value: function count() { 11180 return this.items.length; 11181 } 11182 }, { 11183 key: "delete", 11184 value: function _delete(item) { 11185 const index = this.getIndex(item); 11186 11187 if (index !== -1) { 11188 this.items.splice(index, 1); 11189 return true; 11190 } 11191 11192 return false;
11193 } 11194 }, { 11195 key: "clear", 11196 value: function clear() { 11197 this.items = []; 11198 } 11199 }, { 11200 key: _Symbol$iterator, 11201 value: function () { 11202 return this.items[Symbol.iterator](); 11203 } 11204 }, { 11205 key: "forEach", 11206 value: function forEach(callbackfn, thisArg) { 11207 return this.items.forEach(callbackfn, thisArg); 11208 } 11209 }, { 11210 key: "getAll", 11211 value: function getAll() { 11212 return this.items; 11213 } 11214 }, { 11215 key: "getComparator", 11216 value: function getComparator() { 11217 return this.comparator; 11218 } 11219 }, { 11220 key: "sort", 11221 value: function sort() { 11222 const comparator = this.getComparator(); 11223 11224 if (comparator === null) { 11225 return; 11226 } 11227 /* 11228 Simple implementation 11229 this.items.sort((item1, item2) => { 11230 return comparator(item1, item2); 11231 }); 11232 */ 11233 // For stable sorting https://v8.dev/features/stable-sort 11234 11235 11236 const length = this.items.length; 11237 const indexes = new Array(length); 11238 11239 for (let i = 0; i < length; i++) { 11240 indexes[i] = i; 11241 } // If the comparator returns zero, use the original indexes 11242 11243 11244 indexes.sort((index1, index2) => { 11245 return comparator(this.items[index1], this.items[index2]) || index1 - index2; 11246 }); 11247 11248 for (let i = 0; i < length; i++) { 11249 indexes[i] = this.items[indexes[i]]; 11250 } 11251 11252 for (let i = 0; i < length; i++) { 11253 this.items[i] = indexes[i]; 11254 } 11255 } 11256 }]); 11257 return OrderedArray; 11258 }(); 11259 11260 function _searchIndexToInsert2(value) { 11261 let low = 0; 11262 let high = this.items.length; 11263 11264 while (low < high) { 11265 const mid = Math.floor((low + high) / 2); 11266 11267 if (this.comparator(this.items[mid], value) >= 0) { 11268 high = mid; 11269 } else { 11270 low = mid + 1; 11271 } 11272 } 11273 11274 return low; 11275 } 11276 11277 let ZIndexComponent = /*#__PURE__*/function (_EventEmitter) { 11278 babelHelpers.inherits(ZIndexComponent, _EventEmitter); 11279 11280 function ZIndexComponent(element, componentOptions = {}) { 11281 var _this; 11282 11283 babelHelpers.classCallCheck(this, ZIndexComponent); 11284 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(ZIndexComponent).call(this)); 11285 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "sort", 0); 11286 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "alwaysOnTop", false); 11287 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "zIndex", 0); 11288 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "element", null); 11289 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "overlay", null); 11290 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "overlayGap", -5); 11291 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "stack", null); 11292 11293 _this.setEventNamespace('BX.Main.ZIndexManager.Component'); 11294 11295 if (!Type.isElementNode(element)) { 11296 throw new Error('ZIndexManager.Component: The argument \'element\' must be a DOM element.'); 11297 } 11298 11299 _this.element = element; 11300 const options = Type.isPlainObject(componentOptions) ? componentOptions : {}; 11301 11302 _this.setAlwaysOnTop(options.alwaysOnTop); 11303 11304 _this.setOverlay(options.overlay); 11305 11306 _this.setOverlayGap(options.overlayGap); 11307 11308 _this.subscribeFromOptions(options.events); 11309 11310 return _this; 11311 } 11312 11313 babelHelpers.createClass(ZIndexComponent, [{ 11314 key: "getSort", 11315 value: function getSort() { 11316 return this.sort; 11317 } 11318 /** 11319 * @internal 11320 * @param sort 11321 */ 11322 11323 }, { 11324 key: "setSort", 11325 value: function setSort(sort) { 11326 if (Type.isNumber(sort)) { 11327 this.sort = sort; 11328 } 11329 } 11330 /** 11331 * @internal 11332 * @param stack 11333 */ 11334 11335 }, { 11336 key: "setStack", 11337 value: function setStack(stack) { 11338 this.stack = stack; 11339 } 11340 }, { 11341 key: "getStack", 11342 value: function getStack() { 11343 return this.stack; 11344 } 11345 }, { 11346 key: "getZIndex", 11347 value: function getZIndex() { 11348 return this.zIndex; 11349 } 11350 /** 11351 * @internal 11352 */ 11353 11354 }, { 11355 key: "setZIndex", 11356 value: function setZIndex(zIndex) { 11357 const changed = this.getZIndex() !== zIndex; 11358 this.getElement().style.setProperty('z-index', zIndex, 'important'); 11359 this.zIndex = zIndex; 11360 11361 if (this.getOverlay() !== null) { 11362 this.getOverlay().style.setProperty('z-index', zIndex + this.getOverlayGap(), 'important'); 11363 } 11364 11365 if (changed) {
11366 this.emit('onZIndexChange', { 11367 component: this 11368 }); 11369 } 11370 } 11371 }, { 11372 key: "getAlwaysOnTop", 11373 value: function getAlwaysOnTop() { 11374 return this.alwaysOnTop; 11375 } 11376 }, { 11377 key: "setAlwaysOnTop", 11378 value: function setAlwaysOnTop(value) { 11379 if (Type.isNumber(value) || Type.isBoolean(value)) { 11380 this.alwaysOnTop = value; 11381 } 11382 } 11383 }, { 11384 key: "getElement", 11385 value: function getElement() { 11386 return this.element; 11387 } 11388 }, { 11389 key: "setOverlay", 11390 value: function setOverlay(overlay, gap) { 11391 if (Type.isElementNode(overlay) || overlay === null) { 11392 this.overlay = overlay; 11393 this.setOverlayGap(gap); 11394 11395 if (this.getStack()) { 11396 this.getStack().sort(); 11397 } 11398 } 11399 } 11400 }, { 11401 key: "getOverlay", 11402 value: function getOverlay() { 11403 return this.overlay; 11404 } 11405 }, { 11406 key: "setOverlayGap", 11407 value: function setOverlayGap(gap) { 11408 if (Type.isNumber(gap)) { 11409 this.overlayGap = gap; 11410 } 11411 } 11412 }, { 11413 key: "getOverlayGap", 11414 value: function getOverlayGap() { 11415 return this.overlayGap; 11416 } 11417 }]); 11418 return ZIndexComponent; 11419 }(EventEmitter); 11420 11421 let ZIndexStack = /*#__PURE__*/function () { 11422 function ZIndexStack(container) { 11423 babelHelpers.classCallCheck(this, ZIndexStack); 11424 babelHelpers.defineProperty(this, "container", null); 11425 babelHelpers.defineProperty(this, "components", null); 11426 babelHelpers.defineProperty(this, "elements", new WeakMap()); 11427 babelHelpers.defineProperty(this, "baseIndex", 1000); 11428 babelHelpers.defineProperty(this, "baseStep", 50); 11429 babelHelpers.defineProperty(this, "sortCount", 0); 11430 11431 if (!Type.isDomNode(container)) { 11432 throw new Error('ZIndexManager.Stack: The \'container\' argument must be a DOM element.'); 11433 } 11434 11435 this.container = container; 11436 11437 const comparator = (componentA, componentB) => { 11438 let result = (componentA.getAlwaysOnTop() || 0) - (componentB.getAlwaysOnTop() || 0); 11439 11440 if (!result) { 11441 result = componentA.getSort() - componentB.getSort(); 11442 } 11443 11444 return result; 11445 }; 11446 11447 this.components = new OrderedArray(comparator); 11448 } 11449 11450 babelHelpers.createClass(ZIndexStack, [{ 11451 key: "getBaseIndex", 11452 value: function getBaseIndex() { 11453 return this.baseIndex; 11454 } 11455 }, { 11456 key: "setBaseIndex", 11457 value: function setBaseIndex(index) { 11458 if (Type.isNumber(index) && index >= 0) { 11459 this.baseIndex = index; 11460 this.sort(); 11461 } 11462 } 11463 }, { 11464 key: "setBaseStep", 11465 value: function setBaseStep(step) { 11466 if (Type.isNumber(step) && step > 0) { 11467 this.baseStep = step; 11468 this.sort(); 11469 } 11470 } 11471 }, { 11472 key: "getBaseStep", 11473 value: function getBaseStep() { 11474 return this.baseStep; 11475 } 11476 }, { 11477 key: "register", 11478 value: function register(element, options = {}) { 11479 if (this.getComponent(element)) { 11480 console.warn('ZIndexManager: You cannot register the element twice.', element); 11481 return this.getComponent(element); 11482 } 11483 11484 const component = new ZIndexComponent(element, options); 11485 component.setStack(this); 11486 component.setSort(++this.sortCount); 11487 this.elements.set(element, component); 11488 this.components.add(component); 11489 this.sort(); 11490 return component; 11491 } 11492 }, { 11493 key: "unregister", 11494 value: function unregister(element) { 11495 const component = this.elements.get(element); 11496 this.components.delete(component); 11497 this.elements.delete(element); 11498 this.sort(); 11499 } 11500 }, { 11501 key: "getComponent", 11502 value: function getComponent(element) { 11503 return this.elements.get(element) || null; 11504 } 11505 }, { 11506 key: "getComponents", 11507 value: function getComponents() { 11508 return this.components.getAll(); 11509 } 11510 }, { 11511 key: "getMaxZIndex", 11512 value: function getMaxZIndex() { 11513 const last = this.components.getLast(); 11514 return last ? last.getZIndex() : this.baseIndex; 11515 } 11516 }, { 11517 key: "sort", 11518 value: function sort() { 11519 this.components.sort(); 11520 let zIndex = this.baseIndex;
11521 this.components.forEach(component => { 11522 component.setZIndex(zIndex); 11523 zIndex += this.baseStep; 11524 }); 11525 } 11526 }, { 11527 key: "bringToFront", 11528 value: function bringToFront(element) { 11529 const component = this.getComponent(element); 11530 11531 if (!component) { 11532 console.error('ZIndexManager: element was not found in the stack.', element); 11533 return null; 11534 } 11535 11536 component.setSort(++this.sortCount); 11537 this.sort(); 11538 return component; 11539 } 11540 }]); 11541 return ZIndexStack; 11542 }(); 11543 11544 function _classStaticPrivateMethodGet(receiver, classConstructor, method) { _classCheckPrivateStaticAccess(receiver, classConstructor); return method; } 11545 11546 function _classCheckPrivateStaticAccess(receiver, classConstructor) { if (receiver !== classConstructor) { throw new TypeError("Private static access of wrong provenance"); } } 11547 11548 /** 11549 * @memberof BX 11550 */ 11551 let ZIndexManager = /*#__PURE__*/function () { 11552 function ZIndexManager() { 11553 babelHelpers.classCallCheck(this, ZIndexManager); 11554 } 11555 11556 babelHelpers.createClass(ZIndexManager, null, [{ 11557 key: "register", 11558 value: function register(element, options = {}) { 11559 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element); 11560 11561 if (!parentNode) { 11562 return null; 11563 } 11564 11565 const stack = this.getOrAddStack(parentNode); 11566 return stack.register(element, options); 11567 } 11568 }, { 11569 key: "unregister", 11570 value: function unregister(element) { 11571 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element); 11572 11573 const stack = this.getStack(parentNode); 11574 11575 if (stack) { 11576 stack.unregister(element); 11577 } 11578 } 11579 }, { 11580 key: "addStack", 11581 value: function addStack(container) { 11582 const stack = new ZIndexStack(container); 11583 this.stacks.set(container, stack); 11584 return stack; 11585 } 11586 }, { 11587 key: "getStack", 11588 value: function getStack(container) { 11589 return this.stacks.get(container) || null; 11590 } 11591 }, { 11592 key: "getOrAddStack", 11593 value: function getOrAddStack(container) { 11594 return this.getStack(container) || this.addStack(container); 11595 } 11596 }, { 11597 key: "getComponent", 11598 value: function getComponent(element) { 11599 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element, true); 11600 11601 if (!parentNode) { 11602 return null; 11603 } 11604 11605 const stack = this.getStack(parentNode); 11606 return stack ? stack.getComponent(element) : null; 11607 } 11608 }, { 11609 key: "bringToFront", 11610 value: function bringToFront(element) { 11611 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element); 11612 11613 const stack = this.getStack(parentNode); 11614 11615 if (stack) { 11616 return stack.bringToFront(element); 11617 } 11618 11619 return null; 11620 } 11621 }]); 11622 return ZIndexManager; 11623 }(); 11624 11625 function _getParentNode(element, suppressWarnings = false) { 11626 if (!Type.isElementNode(element)) { 11627 if (!suppressWarnings) { 11628 console.error('ZIndexManager: The argument \'element\' must be a DOM element.', element); 11629 } 11630 11631 return null; 11632 } else if (!Type.isElementNode(element.parentNode)) { 11633 if (!suppressWarnings) { 11634 console.error('ZIndexManager: The \'element\' doesn\'t have a parent node.', element); 11635 } 11636 11637 return null; 11638 } 11639 11640 return element.parentNode; 11641 } 11642 11643 babelHelpers.defineProperty(ZIndexManager, "stacks", new WeakMap()); 11644 11645 var collections = { 11646 OrderedArray 11647 }; 11648 11649 function getElement(element) { 11650 if (Type.isString(element)) { 11651 return document.getElementById(element); 11652 } 11653 11654 return element; 11655 } 11656 11657 function getWindow(element) { 11658 if (Type.isElementNode(element)) { 11659 return element.ownerDocument.parentWindow || element.ownerDocument.defaultView || window; 11660 } 11661 11662 if (Type.isDomNode(element)) { 11663 return element.parentWindow || element.defaultView || window; 11664 } 11665 11666 return window; 11667 } 11668 11669 /* eslint-disable prefer-rest-params */ 11670 11671 const { 11672 getClass, 11673 namespace 11674 } = Reflection; 11675 const message$1 = message; 11676 /** 11677 * @memberOf BX 11678 */ 11679 11680 const { 11681 replace, 11682 remove, 11683 clean, 11684 insertBefore, 11685 insertAfter, 11686 append, 11687 prepend, 11688 style, 11689 adjust, 11690 create, 11691 isShown 11692 } = Dom; 11693 const addClass = function addClass() { 11694 Dom.addClass(...Runtime.merge([], Array.from(arguments), [getElement(arguments[0])])); 11695 }; 11696 const removeClass = function removeClass() { 11697 Dom.removeClass(...Runtime.merge(Array.from(arguments), [getElement(arguments[0])])); 11698 }; 11699 const hasClass = function hasClass() { 11700 return Dom.hasClass(...Runtime.merge(Array.from(arguments), [getElement(arguments[0])])); 11701 }; 11702 const toggleClass = function toggleClass() { 11703 Dom.toggleClass(...Runtime.merge(Array.from(arguments), [getElement(arguments[0])])); 11704 }; 11705 const cleanNode = (element, removeElement = false) => { 11706 const currentElement = getElement(element); 11707 11708 if (Type.isDomNode(currentElement)) { 11709 Dom.clean(currentElement); 11710 11711 if (removeElement) { 11712 Dom.remove(currentElement); 11713 return currentElement; 11714 } 11715 } 11716 11717 return currentElement; 11718 }; 11719 const getCookie = Http.Cookie.get;
11720 const setCookie = (name, value, options = {}) => { 11721 const attributes = { ...options 11722 }; 11723 11724 if (Type.isNumber(attributes.expires)) { 11725 attributes.expires /= 3600 * 24; 11726 } 11727 11728 Http.Cookie.set(name, value, attributes); 11729 }; 11730 const { 11731 bind: bind$1, 11732 unbind: unbind$1, 11733 unbindAll: unbindAll$1, 11734 bindOnce: bindOnce$1, 11735 ready: ready$1 11736 } = Event; 11737 const { 11738 debugState: debugEnableFlag, 11739 isDebugEnabled: debugStatus, 11740 default: debug$1 11741 } = debugNs; 11742 const debugEnable = value => { 11743 if (value) { 11744 enableDebug(); 11745 } else { 11746 disableDebug(); 11747 } 11748 }; 11749 const { 11750 clone: clone$1, 11751 loadExtension: loadExt, 11752 debounce, 11753 throttle, 11754 html 11755 } = Runtime; // BX.type 11756 11757 const type = { ...Object.getOwnPropertyNames(Type).filter(key => !['name', 'length', 'prototype', 'caller', 'arguments'].includes(key)).reduce((acc, key) => { 11758 acc[key] = Type[key]; 11759 return acc; 11760 }, {}), 11761 isNotEmptyString: value => Type.isString(value) && value !== '', 11762 isNotEmptyObject: value => Type.isObjectLike(value) && Object.keys(value).length > 0, 11763 isMapKey: Type.isObject, 11764 stringToInt: value => { 11765 const parsed = parseInt(value); 11766 return !Number.isNaN(parsed) ? parsed : 0; 11767 } 11768 }; // BX.browser 11769 11770 const browser = { 11771 IsOpera: Browser.isOpera, 11772 IsIE: Browser.isIE, 11773 IsIE6: Browser.isIE6, 11774 IsIE7: Browser.isIE7, 11775 IsIE8: Browser.isIE8, 11776 IsIE9: Browser.isIE9, 11777 IsIE10: Browser.isIE10, 11778 IsIE11: Browser.isIE11, 11779 IsSafari: Browser.isSafari, 11780 IsFirefox: Browser.isFirefox, 11781 IsChrome: Browser.isChrome, 11782 DetectIeVersion: Browser.detectIEVersion, 11783 IsMac: Browser.isMac, 11784 IsAndroid: Browser.isAndroid, 11785 isIPad: Browser.isIPad, 11786 isIPhone: Browser.isIPhone, 11787 IsIOS: Browser.isIOS, 11788 IsMobile: Browser.isMobile, 11789 isRetina: Browser.isRetina, 11790 IsDoctype: Browser.isDoctype, 11791 SupportLocalStorage: Browser.isLocalStorageSupported, 11792 addGlobalClass: Browser.addGlobalClass, 11793 DetectAndroidVersion: Browser.detectAndroidVersion, 11794 isPropertySupported: Browser.isPropertySupported, 11795 addGlobalFeatures: Browser.addGlobalFeatures 11796 }; // eslint-disable-next-line 11797 11798 const ajax = window.BX ? window.BX.ajax : () => {}; 11799 function GetWindowScrollSize(doc = document) { 11800 return { 11801 scrollWidth: doc.documentElement.scrollWidth, 11802 scrollHeight: doc.documentElement.scrollHeight 11803 }; 11804 } 11805 function GetWindowScrollPos(doc = document) { 11806 const win = getWindow(doc); 11807 return { 11808 scrollLeft: win.pageXOffset, 11809 scrollTop: win.pageYOffset 11810 }; 11811 } 11812 function GetWindowInnerSize(doc = document) { 11813 const win = getWindow(doc); 11814 return { 11815 innerWidth: win.innerWidth, 11816 innerHeight: win.innerHeight 11817 }; 11818 } 11819 function GetWindowSize(doc = document) { 11820 return { ...GetWindowInnerSize(doc), 11821 ...GetWindowScrollPos(doc), 11822 ...GetWindowScrollSize(doc) 11823 }; 11824 } 11825 function GetContext(node) { 11826 return getWindow(node); 11827 } 11828 function pos(element, relative = false) { 11829 if (!element) { 11830 return new DOMRect().toJSON(); 11831 } 11832 11833 if (element.ownerDocument === document && !relative) { 11834 const clientRect = element.getBoundingClientRect(); 11835 const root = document.documentElement; 11836 const { 11837 body 11838 } = document; 11839 return { 11840 top: Math.round(clientRect.top + (root.scrollTop || body.scrollTop)), 11841 left: Math.round(clientRect.left + (root.scrollLeft || body.scrollLeft)), 11842 width: Math.round(clientRect.right - clientRect.left), 11843 height: Math.round(clientRect.bottom - clientRect.top), 11844 right: Math.round(clientRect.right + (root.scrollLeft || body.scrollLeft)), 11845 bottom: Math.round(clientRect.bottom + (root.scrollTop || body.scrollTop)) 11846 }; 11847 } 11848 11849 let x = 0; 11850 let y = 0; 11851 const w = element.offsetWidth; 11852 const h = element.offsetHeight; 11853 let first = true; // eslint-disable-next-line no-param-reassign 11854 11855 for (; element != null; element = element.offsetParent) { 11856 if (!first && relative && BX.is_relative(element)) { 11857 break; 11858 } 11859 11860 x += element.offsetLeft; 11861 y += element.offsetTop; 11862 11863 if (first) { 11864 first = false; // eslint-disable-next-line no-continue 11865 11866 continue; 11867 } 11868 11869 x += Text.toNumber(Dom.style(element, 'border-left-width')); 11870 y += Text.toNumber(Dom.style(element, 'border-top-width')); 11871 } 11872 11873 return new DOMRect(x, y, w, h).toJSON(); 11874 } 11875 function addCustomEvent(eventObject, eventName, eventHandler) { 11876 if (Type.isString(eventObject)) { 11877 eventHandler = eventName; 11878 eventName = eventObject; 11879 eventObject = EventEmitter.GLOBAL_TARGET;
11880 } 11881 11882 if (eventObject === window) { 11883 eventObject = EventEmitter.GLOBAL_TARGET; 11884 } 11885 11886 if (!Type.isObject(eventObject)) { 11887 console.error('The "eventObject" argument must be an object. Received type ' + typeof eventObject + '.'); 11888 return; 11889 } 11890 11891 if (!Type.isStringFilled(eventName)) { 11892 console.error('The "eventName" argument must be a string.'); 11893 return; 11894 } 11895 11896 if (!Type.isFunction(eventHandler)) { 11897 console.error('The "eventHandler" argument must be a function. Received type ' + typeof eventHandler + '.'); 11898 return; 11899 } 11900 11901 eventName = eventName.toLowerCase(); 11902 EventEmitter.subscribe(eventObject, eventName, eventHandler, { 11903 compatMode: true, 11904 useGlobalNaming: true 11905 }); 11906 } 11907 function onCustomEvent(eventObject, eventName, eventParams, secureParams) { 11908 if (Type.isString(eventObject)) { 11909 secureParams = eventParams; 11910 eventParams = eventName; 11911 eventName = eventObject; 11912 eventObject = EventEmitter.GLOBAL_TARGET; 11913 } 11914 11915 if (!Type.isObject(eventObject) || eventObject === window) { 11916 eventObject = EventEmitter.GLOBAL_TARGET;
11917 } 11918 11919 if (!eventParams) { 11920 eventParams = []; 11921 } 11922 11923 eventName = eventName.toLowerCase(); 11924 const event = new BaseEvent(); 11925 event.setData(eventParams); 11926 event.setCompatData(eventParams); 11927 EventEmitter.emit(eventObject, eventName, event, { 11928 cloneData: secureParams === true, 11929 useGlobalNaming: true 11930 }); 11931 } 11932 function removeCustomEvent(eventObject, eventName, eventHandler) { 11933 if (Type.isString(eventObject)) { 11934 eventHandler = eventName; 11935 eventName = eventObject; 11936 eventObject = EventEmitter.GLOBAL_TARGET; 11937 } 11938 11939 if (!Type.isFunction(eventHandler)) { 11940 console.error('The "eventHandler" argument must be a function. Received type ' + typeof eventHandler + '.'); 11941 return; 11942 } 11943 11944 if (eventObject === window) { 11945 eventObject = EventEmitter.GLOBAL_TARGET; 11946 } 11947 11948 eventName = eventName.toLowerCase(); 11949 EventEmitter.unsubscribe(eventObject, eventName, eventHandler, { 11950 useGlobalNaming: true 11951 }); 11952 } 11953 function removeAllCustomEvents(eventObject, eventName) { 11954 if (Type.isString(eventObject)) { 11955 eventName = eventObject; 11956 eventObject = EventEmitter.GLOBAL_TARGET;
11957 } 11958 11959 if (eventObject === window) { 11960 eventObject = EventEmitter.GLOBAL_TARGET; 11961 } 11962 11963 eventName = eventName.toLowerCase(); 11964 EventEmitter.unsubscribeAll(eventObject, eventName, { 11965 useGlobalNaming: true 11966 }); 11967 } 11968 11969 if (typeof global === 'object' && global.window && global.window.BX) { 11970 Object.assign(global.window.BX, exports); 11971 } 11972 11973 exports.Type = Type; 11974 exports.Reflection = Reflection; 11975 exports.Text = Text; 11976 exports.Dom = Dom; 11977 exports.Browser = Browser; 11978 exports.Event = Event; 11979 exports.Http = Http; 11980 exports.Runtime = Runtime; 11981 exports.Loc = Loc; 11982 exports.Tag = Tag; 11983 exports.Uri = Uri; 11984 exports.Validation = Validation; 11985 exports.Cache = Cache; 11986 exports.BaseError = BaseError; 11987 exports.Extension = Extension$1; 11988 exports.ZIndexManager = ZIndexManager; 11989 exports.Collections = collections; 11990 exports.getClass = getClass; 11991 exports.namespace = namespace; 11992 exports.message = message$1; 11993 exports.replace = replace; 11994 exports.remove = remove; 11995 exports.clean = clean; 11996 exports.insertBefore = insertBefore; 11997 exports.insertAfter = insertAfter; 11998 exports.append = append; 11999 exports.prepend = prepend; 12000 exports.style = style; 12001 exports.adjust = adjust; 12002 exports.create = create; 12003 exports.isShown = isShown; 12004 exports.addClass = addClass; 12005 exports.removeClass = removeClass; 12006 exports.hasClass = hasClass; 12007 exports.toggleClass = toggleClass; 12008 exports.cleanNode = cleanNode; 12009 exports.getCookie = getCookie; 12010 exports.setCookie = setCookie; 12011 exports.bind = bind$1; 12012 exports.unbind = unbind$1; 12013 exports.unbindAll = unbindAll$1; 12014 exports.bindOnce = bindOnce$1; 12015 exports.ready = ready$1; 12016 exports.debugEnableFlag = debugEnableFlag; 12017 exports.debugStatus = debugStatus; 12018 exports.debug = debug$1; 12019 exports.debugEnable = debugEnable; 12020 exports.clone = clone$1; 12021 exports.loadExt = loadExt; 12022 exports.debounce = debounce; 12023 exports.throttle = throttle; 12024 exports.html = html; 12025 exports.type = type; 12026 exports.browser = browser; 12027 exports.ajax = ajax; 12028 exports.GetWindowScrollSize = GetWindowScrollSize; 12029 exports.GetWindowScrollPos = GetWindowScrollPos; 12030 exports.GetWindowInnerSize = GetWindowInnerSize; 12031 exports.GetWindowSize = GetWindowSize; 12032 exports.GetContext = GetContext; 12033 exports.pos = pos; 12034 exports.addCustomEvent = addCustomEvent; 12035 exports.onCustomEvent = onCustomEvent; 12036 exports.removeCustomEvent = removeCustomEvent; 12037 exports.removeAllCustomEvents = removeAllCustomEvents; 12038 12039}((this.BX = this.BX || {}))); 12040 12041 12042 12043(function(BX) { 12044 /* list of registered proxy functions */ 12045 var proxyList = new WeakMap(); 12046 var deferList = new WeakMap(); 12047 12048 /* List of denied event handlers */ 12049 var deniedEvents = []; 12050 12051 /* list of registered custom events */ 12052 var customEvents = new WeakMap(); 12053 var customEventsCnt = 0; 12054 12055 /* list of external garbage collectors */ 12056 var garbageCollectors = []; 12057 12058 /* list of loaded CSS files */ 12059 var cssList = []; 12060 var cssInit = false; 12061 12062 /* list of loaded JS files */ 12063 var jsList = []; 12064 var jsInit = false; 12065 12066 var eventTypes = { 12067 click: 'MouseEvent', 12068 dblclick: 'MouseEvent', 12069 mousedown: 'MouseEvent', 12070 mousemove: 'MouseEvent', 12071 mouseout: 'MouseEvent', 12072 mouseover: 'MouseEvent', 12073 mouseup: 'MouseEvent', 12074 focus: 'MouseEvent', 12075 blur: 'MouseEvent' 12076 }; 12077 12078 var lastWait = []; 12079 12080 var CHECK_FORM_ELEMENTS = {tagName: /^INPUT|SELECT|TEXTAREA|BUTTON$/i}; 12081 12082 var PRELOADING = 1; 12083 var PRELOADED = 2; 12084 var LOADING = 3; 12085 var LOADED = 4; 12086 var assets = {}; 12087 var isAsync = null; 12088 12089 BX.MSLEFT = 1; 12090 BX.MSMIDDLE = 2; 12091 BX.MSRIGHT = 4; 12092 12093 BX.AM_PM_UPPER = 1; 12094 BX.AM_PM_LOWER = 2; 12095 BX.AM_PM_NONE = false; 12096 12097 BX.ext = function(ob) 12098 { 12099 for (var i in ob) 12100 { 12101 if(ob.hasOwnProperty(i)) 12102 { 12103 this[i] = ob[i]; 12104 } 12105 } 12106 }; 12107 12108 var r = { 12109 script: /<script([^>]*)>/ig, 12110 script_end: /<\/script>/ig, 12111 script_src: /src=["\']([^"\']+)["\']/i, 12112 script_type: /type=["\']([^"\']+)["\']/i, 12113 space: /\s+/, 12114 ltrim: /^[\s\r\n]+/g, 12115 rtrim: /[\s\r\n]+$/g, 12116 style: /<link.*?(rel="stylesheet"|type="text\/css")[^>]*>/i, 12117 style_href: /href=["\']([^"\']+)["\']/i 12118 }; 12119 12120 BX.processHTML = function(data, scriptsRunFirst) 12121 { 12122 var matchScript, matchStyle, matchSrc, matchHref, matchType, scripts = [], styles = []; 12123 var textIndexes = []; 12124 var lastIndex = r.script.lastIndex = r.script_end.lastIndex = 0; 12125 12126 while ((matchScript = r.script.exec(data)) !== null) 12127 { 12128 r.script_end.lastIndex = r.script.lastIndex; 12129 var matchScriptEnd = r.script_end.exec(data); 12130 if (matchScriptEnd === null) 12131 { 12132 break; 12133 } 12134 12135 // skip script tags of special types 12136 var skipTag = false;
12137 if ((matchType = matchScript[1].match(r.script_type)) !== null) 12138 { 12139 if( 12140 matchType[1] == 'text/html' 12141 || matchType[1] == 'text/template' 12142 || matchType[1] == 'extension/settings' 12143 ) 12144 { 12145 skipTag = true; 12146 } 12147 } 12148 12149 if(skipTag) 12150 { 12151 textIndexes.push([lastIndex, r.script_end.lastIndex - lastIndex]); 12152 } 12153 else 12154 { 12155 textIndexes.push([lastIndex, matchScript.index - lastIndex]); 12156 12157 var bRunFirst = scriptsRunFirst || (matchScript[1].indexOf('bxrunfirst') != '-1'); 12158 12159 if ((matchSrc = matchScript[1].match(r.script_src)) !== null) 12160 { 12161 scripts.push({"bRunFirst": bRunFirst, "isInternal": false, "JS": matchSrc[1]}); 12162 } 12163 else 12164 { 12165 var start = matchScript.index + matchScript[0].length; 12166 var js = data.substr(start, matchScriptEnd.index-start); 12167 12168 scripts.push({"bRunFirst": bRunFirst, "isInternal": true, "JS": js}); 12169 } 12170 } 12171 12172 lastIndex = matchScriptEnd.index + 9; 12173 r.script.lastIndex = lastIndex; 12174 } 12175 12176 textIndexes.push([lastIndex, lastIndex === 0 ? data.length : data.length - lastIndex]); 12177 var pureData = ""; 12178 for (var i = 0, length = textIndexes.length; i < length; i++) 12179 { 12180 if (BX.type.isString(data) && BX.type.isFunction(data.substr)) 12181 { 12182 pureData += data.substr(textIndexes[i][0], textIndexes[i][1]); 12183 } 12184 } 12185 12186 while ((matchStyle = pureData.match(r.style)) !== null) 12187 { 12188 if ((matchHref = matchStyle[0].match(r.style_href)) !== null && matchStyle[0].indexOf('media="') < 0) 12189 { 12190 styles.push(matchHref[1]); 12191 } 12192 12193 pureData = pureData.replace(matchStyle[0], ''); 12194 } 12195 12196 return {'HTML': pureData, 'SCRIPT': scripts, 'STYLE': styles}; 12197 }; 12198 12199 /* OO emulation utility */ 12200 BX.extend = function(child, parent) 12201 { 12202 var f = function() {}; 12203 f.prototype = parent.prototype; 12204 12205 child.prototype = new f(); 12206 child.prototype.constructor = child; 12207 12208 child.superclass = parent.prototype; 12209 child.prototype.superclass = parent.prototype; 12210 if(parent.prototype.constructor == Object.prototype.constructor) 12211 { 12212 parent.prototype.constructor = parent; 12213 } 12214 }; 12215 12216 BX.is_subclass_of = function(ob, parent_class) 12217 { 12218 if (ob instanceof parent_class) 12219 return true; 12220 12221 if (parent_class.superclass) 12222 return BX.is_subclass_of(ob, parent_class.superclass); 12223 12224 return false; 12225 }; 12226 12227 BX.clearNodeCache = function() 12228 { 12229 return false; 12230 }; 12231 12232 BX.bitrix_sessid = function() {return BX.message("bitrix_sessid"); }; 12233 12234 /** 12235 * Creates document fragment with child nodes. 12236 * 12237 * @param {Node[]} nodes 12238 * @return {DocumentFragment} 12239 */ 12240 BX.createFragment = function(nodes) 12241 { 12242 var fragment = document.createDocumentFragment(); 12243 12244 if(!BX.type.isArray(nodes)) 12245 { 12246 return fragment; 12247 } 12248 for(var i = 0; i < nodes.length; i++) 12249 { 12250 fragment.appendChild(nodes[i]); 12251 } 12252 12253 return fragment; 12254 }; 12255 12256 /** 12257 * @deprecated 12258 * @use BX.style 12259 * @param element 12260 * @param opacity 12261 */ 12262 BX.setOpacity = function(element, opacity) 12263 { 12264 var opacityValue = parseFloat(opacity); 12265 12266 if (!isNaN(opacityValue) && BX.type.isDomNode(element)) 12267 { 12268 opacityValue = opacityValue < 1 ? opacityValue : opacityValue / 100; 12269 BX.style(element, 'opacity', opacityValue); 12270 } 12271 }; 12272 12273 /** 12274 * @deprecated 12275 * @param el 12276 * @return {*} 12277 */ 12278 BX.hoverEvents = function(el) 12279 { 12280 if (el) 12281 return BX.adjust(el, {events: BX.hoverEvents()}); 12282 else 12283 return {mouseover: BX.hoverEventsHover, mouseout: BX.hoverEventsHout}; 12284 }; 12285 12286 /** 12287 * @deprecated 12288 */ 12289 BX.hoverEventsHover = function(){BX.addClass(this,'bx-hover');this.BXHOVER=true;}; 12290 /** 12291 * @deprecated 12292 */ 12293 BX.hoverEventsHout = function(){BX.removeClass(this,'bx-hover');this.BXHOVER=false;}; 12294 12295 /** 12296 * @deprecated 12297 */ 12298 BX.focusEvents = function(el) 12299 { 12300 if (el) 12301 return BX.adjust(el, {events: BX.focusEvents()}); 12302 else 12303 return {mouseover: BX.focusEventsFocus, mouseout: BX.focusEventsBlur}; 12304 }; 12305 12306 /** 12307 * @deprecated 12308 */ 12309 BX.focusEventsFocus = function(){BX.addClass(this,'bx-focus');this.BXFOCUS=true;}; 12310 /** 12311 * @deprecated 12312 */ 12313 BX.focusEventsBlur = function(){BX.removeClass(this,'bx-focus');this.BXFOCUS=false;}; 12314 12315 BX.setUnselectable = function(node) 12316 { 12317 BX.style(node, { 12318 'userSelect': 'none', 12319 'MozUserSelect': 'none', 12320 'WebkitUserSelect': 'none', 12321 'KhtmlUserSelect': 'none', 12322 }); 12323 node.setAttribute('unSelectable', 'on'); 12324 }; 12325 12326 BX.setSelectable = function(node) 12327 { 12328 BX.style(node, { 12329 'userSelect': null, 12330 'MozUserSelect': null, 12331 'WebkitUserSelect': null, 12332 'KhtmlUserSelect': null, 12333 }); 12334 node.removeAttribute('unSelectable'); 12335 }; 12336 12337 BX.styleIEPropertyName = function(name) 12338 { 12339 if (name == 'float') 12340 name = BX.browser.IsIE() ? 'styleFloat' : 'cssFloat'; 12341 else 12342 { 12343 var res = BX.browser.isPropertySupported(name); 12344 if (res) 12345 { 12346 name = res; 12347 } 12348 else 12349 {
12350 var reg = /(\-([a-z]){1})/g; 12351 if (reg.test(name)) 12352 { 12353 name = name.replace(reg, function () {return arguments[2].toUpperCase();}); 12354 } 12355 } 12356 } 12357 return name; 12358 }; 12359 12360 BX.focus = function(el) 12361 { 12362 try 12363 { 12364 el.focus(); 12365 return true; 12366 } 12367 catch (e) 12368 { 12369 return false; 12370 } 12371 }; 12372 12373 BX.firstChild = function(el) 12374 { 12375 return BX.type.isDomNode(el) ? el.firstElementChild : null; 12376 }; 12377 12378 BX.lastChild = function(el) 12379 { 12380 return BX.type.isDomNode(el) ? el.lastElementChild : null; 12381 }; 12382 12383 BX.previousSibling = function(el) 12384 { 12385 return BX.type.isDomNode(el) ? el.previousElementSibling : null; 12386 }; 12387 12388 BX.nextSibling = function(el) 12389 { 12390 return BX.type.isDomNode(el) ? el.nextElementSibling : null; 12391 }; 12392 12393 /* 12394 params: { 12395 obj : html node 12396 className : className value 12397 recursive : used only for older browsers to optimize the tree traversal, in new browsers the search is always recursively, default - true 12398 } 12399 12400 Search all nodes with className 12401 */ 12402 /** 12403 * @deprecated 12404 * @use .querySelectorAll 12405 * @param obj 12406 * @param className 12407 * @param recursive 12408 * @return {*} 12409 */ 12410 BX.findChildrenByClassName = function(obj, className, recursive) 12411 { 12412 if(!obj || !obj.childNodes) return null; 12413 12414 var result = []; 12415 if (typeof(obj.getElementsByClassName) == 'undefined') 12416 { 12417 recursive = recursive !== false; 12418 result = BX.findChildren(obj, {className : className}, recursive); 12419 } 12420 else 12421 { 12422 var col = obj.getElementsByClassName(className); 12423 for (i=0,l=col.length;i<l;i++) 12424 { 12425 result[i] = col[i]; 12426 } 12427 } 12428 return result; 12429 }; 12430 12431 /* 12432 params: { 12433 obj : html node 12434 className : className value 12435 recursive : used only for older browsers to optimize the tree traversal, in new browsers the search is always recursively, default - true 12436 } 12437 12438 Search first node with className 12439 */ 12440 /** 12441 * @deprecated 12442 * @use .querySelector 12443 * @param obj 12444 * @param className 12445 * @param recursive 12446 * @return {*} 12447 */ 12448 BX.findChildByClassName = function(obj, className, recursive) 12449 { 12450 if(!obj || !obj.childNodes) return null; 12451 12452 var result = null; 12453 if (typeof(obj.getElementsByClassName) == 'undefined') 12454 { 12455 recursive = recursive !== false; 12456 result = BX.findChild(obj, {className : className}, recursive); 12457 } 12458 else 12459 { 12460 var col = obj.getElementsByClassName(className); 12461 if (col && typeof(col[0]) != 'undefined') 12462 { 12463 result = col[0]; 12464 } 12465 else 12466 { 12467 result = null; 12468 } 12469 } 12470 return result; 12471 }; 12472 12473 /* 12474 params: { 12475 tagName|tag : 'tagName', 12476 className|class : 'className', 12477 attribute : {attribute : value, attribute : value} | attribute | [attribute, attribute....], 12478 property : {prop: value, prop: value} | prop | [prop, prop] 12479 } 12480 12481 all values can be RegExps or strings 12482 */ 12483 /** 12484 * @deprecated 12485 * @use .querySelectorAll 12486 * @param obj 12487 * @param params 12488 * @param recursive 12489 * @return {*|Node} 12490 */ 12491 BX.findChildren = function(obj, params, recursive) 12492 { 12493 return BX.findChild(obj, params, recursive, true); 12494 }; 12495 12496 /** 12497 * @deprecated 12498 * @use .querySelectorAll 12499 * @param obj 12500 * @param params 12501 * @param recursive 12502 * @param get_all 12503 * @return {*} 12504 */ 12505 BX.findChild = function(obj, params, recursive, get_all) 12506 { 12507 if(!obj || !obj.childNodes) return null; 12508 12509 recursive = !!recursive; get_all = !!get_all; 12510 12511 var n = obj.childNodes.length, result = []; 12512 12513 for (var j=0; j<n; j++) 12514 { 12515 var child = obj.childNodes[j]; 12516 12517 if (_checkNode(child, params)) 12518 { 12519 if (get_all) 12520 result.push(child); 12521 else 12522 return child; 12523 } 12524 12525 if(recursive == true) 12526 { 12527 var res = BX.findChild(child, params, recursive, get_all); 12528 if (res) 12529 { 12530 if (get_all) 12531 result = BX.util.array_merge(result, res); 12532 else 12533 return res; 12534 } 12535 } 12536 } 12537 12538 if (get_all || result.length > 0) 12539 return result; 12540 else 12541 return null; 12542 }; 12543 12544 /** 12545 * @deprecated 12546 * @use .closest() 12547 * @param obj 12548 * @param params 12549 * @param maxParent 12550 * @return {*} 12551 */ 12552 BX.findParent = function(obj, params, maxParent) 12553 { 12554 if(!obj) 12555 return null; 12556 12557 var o = obj; 12558 while(o.parentNode) 12559 { 12560 var parent = o.parentNode; 12561 12562 if (_checkNode(parent, params)) 12563 return parent; 12564 12565 o = parent; 12566 12567 if (!!maxParent &&
12568 (BX.type.isFunction(maxParent) 12569 || typeof maxParent == 'object')) 12570 { 12571 if (BX.type.isElementNode(maxParent)) 12572 { 12573 if (o == maxParent) 12574 break; 12575 } 12576 else 12577 { 12578 if (_checkNode(o, maxParent)) 12579 break; 12580 } 12581 } 12582 } 12583 return null; 12584 }; 12585 12586 /** 12587 * @deprecated 12588 * @use .querySelector 12589 * @param obj 12590 * @param params 12591 * @return {*} 12592 */ 12593 BX.findNextSibling = function(obj, params) 12594 { 12595 if(!obj) 12596 return null; 12597 var o = obj; 12598 while(o.nextSibling) 12599 { 12600 var sibling = o.nextSibling; 12601 if (_checkNode(sibling, params)) 12602 return sibling; 12603 o = sibling; 12604 } 12605 return null; 12606 }; 12607 12608 /** 12609 * @deprecated 12610 * @use .querySelector 12611 * @param obj 12612 * @param params 12613 * @return {*} 12614 */ 12615 BX.findPreviousSibling = function(obj, params) 12616 { 12617 if(!obj) 12618 return null; 12619 12620 var o = obj; 12621 while(o.previousSibling) 12622 { 12623 var sibling = o.previousSibling; 12624 if(_checkNode(sibling, params)) 12625 return sibling; 12626 o = sibling; 12627 } 12628 return null; 12629 }; 12630 12631 BX.checkNode = function(obj, params) 12632 { 12633 return _checkNode(obj, params); 12634 }; 12635 12636 /** 12637 * @deprecated 12638 * @use .querySelectorAll 12639 * @param form 12640 * @return {Array} 12641 */ 12642 BX.findFormElements = function(form) 12643 { 12644 if (BX.type.isString(form)) 12645 form = document.forms[form]||BX(form); 12646 12647 var res = []; 12648 12649 if (BX.type.isElementNode(form)) 12650 { 12651 if (form.tagName.toUpperCase() == 'FORM') 12652 { 12653 res = form.elements; 12654 } 12655 else 12656 { 12657 res = BX.findChildren(form, CHECK_FORM_ELEMENTS, true); 12658 } 12659 } 12660 12661 return res; 12662 }; 12663 12664 /** 12665 * @deprecated 12666 * @use .contains() 12667 * @param whichNode 12668 * @param forNode 12669 * @return {boolean} 12670 */ 12671 BX.isParentForNode = function(whichNode, forNode) 12672 { 12673 if (BX.type.isDomNode(whichNode) && BX.type.isDomNode(forNode)) 12674 { 12675 return whichNode.contains(forNode); 12676 } 12677 12678 return false; 12679 }; 12680 12681 BX.getCaretPosition = function(node) 12682 { 12683 var pos = 0; 12684 12685 if(node.selectionStart || node.selectionStart == 0) 12686 { 12687 pos = node.selectionStart; 12688 } 12689 else if(document.selection) 12690 { 12691 node.focus(); 12692 var selection = document.selection.createRange(); 12693 selection.moveStart('character', -node.value.length); 12694 pos = selection.text.length; 12695 } 12696 12697 return (pos); 12698 }; 12699 12700 BX.setCaretPosition = function(node, pos) 12701 { 12702 if(!BX.isNodeInDom(node) || BX.isNodeHidden(node) || node.disabled) 12703 { 12704 return; 12705 } 12706 12707 if(node.setSelectionRange) 12708 { 12709 node.focus(); 12710 node.setSelectionRange(pos, pos); 12711 } 12712 else if(node.createTextRange) 12713 { 12714 var range = node.createTextRange(); 12715 range.collapse(true); 12716 range.moveEnd('character', pos); 12717 range.moveStart('character', pos); 12718 range.select(); 12719 } 12720 }; 12721 12722 // access private. use BX.mergeEx instead. 12723 // todo: refactor BX.merge, make it work through BX.mergeEx 12724 BX.merge = function(){ 12725 var arg = Array.prototype.slice.call(arguments); 12726 12727 if(arg.length < 2) 12728 return {}; 12729 12730 var result = arg.shift(); 12731 12732 for(var i = 0; i < arg.length; i++) 12733 { 12734 for(var k in arg[i]){ 12735 12736 if(typeof arg[i] == 'undefined' || arg[i] == null) 12737 continue; 12738 12739 if(arg[i].hasOwnProperty(k)){ 12740 12741 if(typeof arg[i][k] == 'undefined' || arg[i][k] == null) 12742 continue; 12743 12744 if(typeof arg[i][k] == 'object' && !BX.type.isDomNode(arg[i][k]) && (typeof arg[i][k]['isUIWidget'] == 'undefined')){ 12745 12746 // go deeper 12747 12748 var isArray = 'length' in arg[i][k]; 12749 12750 if(typeof result[k] != 'object') 12751 result[k] = isArray ? [] : {}; 12752 12753 if(isArray) 12754 BX.util.array_merge(result[k], arg[i][k]); 12755 else 12756 BX.merge(result[k], arg[i][k]); 12757 12758 }else 12759 result[k] = arg[i][k]; 12760 } 12761 } 12762 } 12763 12764 return result; 12765 }; 12766 12767 BX.mergeEx = function() 12768 { 12769 var arg = Array.prototype.slice.call(arguments); 12770 if(arg.length < 2) 12771 { 12772 return {}; 12773 } 12774 12775 var result = arg.shift(); 12776 for (var i = 0; i < arg.length; i++) 12777 { 12778 for (var k in arg[i]) 12779 { 12780 if (typeof arg[i] == "undefined" || arg[i] == null || !arg[i].hasOwnProperty(k)) 12781 { 12782 continue; 12783 } 12784 12785 if (BX.type.isPlainObject(arg[i][k]) && BX.type.isPlainObject(result[k])) 12786 { 12787 BX.mergeEx(result[k], arg[i][k]); 12788 } 12789 else 12790 { 12791 result[k] = BX.type.isPlainObject(arg[i][k]) ? BX.clone(arg[i][k]) : arg[i][k]; 12792 } 12793 } 12794 } 12795 12796 return result; 12797 }; 12798 12799 BX.getEventButton = function(e) 12800 { 12801 e = e || window.event; 12802 12803 var flags = 0; 12804 12805 if (typeof e.which != 'undefined') 12806 { 12807 switch (e.which) 12808 { 12809 case 1: flags = flags|BX.MSLEFT; break; 12810 case 2: flags = flags|BX.MSMIDDLE; break; 12811 case 3: flags = flags|BX.MSRIGHT; break; 12812 } 12813 } 12814 else if (typeof e.button != 'undefined') 12815 { 12816 flags = event.button; 12817 } 12818 12819 return flags || BX.MSLEFT; 12820 }; 12821 12822 var captured_events = null, _bind = null; 12823 BX.CaptureEvents = function(el_c, evname_c) 12824 { 12825 if (_bind) 12826 return; 12827 12828 _bind = BX.bind; 12829 captured_events = []; 12830 12831 BX.bind = function(el, evname, func) 12832 { 12833 if (el === el_c && evname === evname_c) 12834 captured_events.push(func); 12835 12836 _bind.apply(this, arguments); 12837 } 12838 }; 12839 12840 BX.CaptureEventsGet = function() 12841 { 12842 if (_bind) 12843 { 12844 BX.bind = _bind; 12845 12846 var captured = captured_events; 12847 12848 _bind = null; 12849 captured_events = null; 12850 return captured; 12851 } 12852 return null; 12853 }; 12854 12855 // Don't even try to use it for submit event! 12856 BX.fireEvent = function(ob,ev) 12857 { 12858 var result = false, e = null; 12859 if (BX.type.isDomNode(ob)) 12860 { 12861 result = true; 12862 if (document.createEventObject) 12863 { 12864 // IE 12865 if (eventTypes[ev] != 'MouseEvent') 12866 { 12867 e = document.createEventObject(); 12868 e.type = ev; 12869 result = ob.fireEvent('on' + ev, e); 12870 } 12871 12872 if (ob[ev]) 12873 { 12874 ob[ev](); 12875 } 12876 } 12877 else 12878 {
12879 // non-IE 12880 e = null; 12881 12882 switch (eventTypes[ev]) 12883 { 12884 case 'MouseEvent': 12885 e = document.createEvent('MouseEvent'); 12886 try 12887 { 12888 e.initMouseEvent(ev, true, true, top, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, null); 12889 } 12890 catch (initException) 12891 { 12892 e.initMouseEvent(ev, true, true, window, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, null); 12893 } 12894 12895 break; 12896 default: 12897 e = document.createEvent('Event'); 12898 e.initEvent(ev, true, true); 12899 } 12900 12901 result = ob.dispatchEvent(e); 12902 } 12903 } 12904 12905 return result; 12906 }; 12907 12908 BX.getWheelData = function(e) 12909 { 12910 e = e || window.event; 12911 e.wheelData = e.detail ? e.detail * -1 : e.wheelDelta / 40; 12912 return e.wheelData; 12913 }; 12914 12915 BX.proxy_context = null; 12916 12917 BX.delegate = function (func, thisObject) 12918 { 12919 if (!func || !thisObject) 12920 return func; 12921 12922 return function() { 12923 var cur = BX.proxy_context; 12924 BX.proxy_context = this; 12925 var res = func.apply(thisObject, arguments); 12926 BX.proxy_context = cur; 12927 return res; 12928 } 12929 }; 12930 12931 BX.delegateLater = function (func_name, thisObject, contextObject) 12932 { 12933 return function() 12934 { 12935 if (thisObject[func_name]) 12936 { 12937 var cur = BX.proxy_context; 12938 BX.proxy_context = this; 12939 var res = thisObject[func_name].apply(contextObject||thisObject, arguments); 12940 BX.proxy_context = cur; 12941 return res; 12942 } 12943 return null; 12944 } 12945 }; 12946 12947 BX.proxy = function(func, thisObject) 12948 { 12949 return getObjectDelegate(func, thisObject, proxyList); 12950 }; 12951 12952 BX.defer = function(func, thisObject) 12953 { 12954 if (!!thisObject) 12955 return BX.defer_proxy(func, thisObject); 12956 else 12957 return function() { 12958 var arg = arguments; 12959 setTimeout(function(){func.apply(this,arg)}, 10); 12960 }; 12961 }; 12962 12963 BX.defer_proxy = function(func, thisObject) 12964 { 12965 return getObjectDelegate(func, thisObject, deferList, BX.defer); 12966 }; 12967 12968 /** 12969 * 12970 * @private 12971 */ 12972 function getObjectDelegate(func, thisObject, collection, decorator) 12973 { 12974 if (!BX.type.isFunction(func) || !BX.type.isMapKey(thisObject)) 12975 { 12976 return func; 12977 } 12978 12979 var objectDelegates = collection.get(thisObject); 12980 if (!objectDelegates) 12981 { 12982 objectDelegates = new WeakMap(); 12983 collection.set(thisObject, objectDelegates); 12984 } 12985 12986 var delegate = objectDelegates.get(func); 12987 if (!delegate) 12988 { 12989 delegate = decorator ? decorator(BX.delegate(func, thisObject)) : BX.delegate(func, thisObject); 12990 objectDelegates.set(func, delegate); 12991 } 12992 12993 return delegate; 12994 } 12995 12996 BX.once = function(el, evname, func) 12997 { 12998 var fn = function() 12999 { 13000 BX.unbind(el, evname, fn); 13001 func.apply(this, arguments); 13002 }; 13003 13004 return fn; 13005 }; 13006 13007 BX.bindDelegate = function (elem, eventName, isTarget, handler) 13008 { 13009 var h = BX.delegateEvent(isTarget, handler); 13010 BX.bind(elem, eventName, h); 13011 return h; 13012 }; 13013 13014 BX.delegateEvent = function(isTarget, handler) 13015 { 13016 return function(e) 13017 { 13018 e = e || window.event; 13019 var target = e.target || e.srcElement; 13020 13021 while (target != this) 13022 { 13023 if (_checkNode(target, isTarget)) 13024 { 13025 return handler.call(target, e); 13026 } 13027 if (target && target.parentNode) 13028 target = target.parentNode; 13029 else 13030 break; 13031 } 13032 return null; 13033 } 13034 }; 13035 13036 BX.False = function() {return false;}; 13037 BX.DoNothing = function() {}; 13038 13039 // TODO: also check event handlers set via BX.bind() 13040 BX.denyEvent = function(el, ev) 13041 { 13042 deniedEvents.push([el, ev, el['on' + ev]]); 13043 el['on' + ev] = BX.DoNothing; 13044 }; 13045 13046 BX.allowEvent = function(el, ev) 13047 { 13048 for(var i=0, len=deniedEvents.length; i<len; i++) 13049 { 13050 if (deniedEvents[i][0] == el && deniedEvents[i][1] == ev) 13051 { 13052 el['on' + ev] = deniedEvents[i][2]; 13053 BX.util.deleteFromArray(deniedEvents, i); 13054 return; 13055 } 13056 } 13057 }; 13058 13059 BX.fixEventPageXY = function(event) 13060 { 13061 BX.fixEventPageX(event); 13062 BX.fixEventPageY(event); 13063 return event; 13064 }; 13065 13066 BX.fixEventPageX = function(event) 13067 { 13068 if (event.pageX == null && event.clientX != null) 13069 { 13070 event.pageX = 13071 event.clientX + 13072 (document.documentElement && document.documentElement.scrollLeft || document.body && document.body.scrollLeft || 0) - 13073 (document.documentElement.clientLeft || 0); 13074 } 13075 13076 return event; 13077 }; 13078 13079 BX.fixEventPageY = function(event) 13080 { 13081 if (event.pageY == null && event.clientY != null) 13082 { 13083 event.pageY = 13084 event.clientY + 13085 (document.documentElement && document.documentElement.scrollTop || document.body && document.body.scrollTop || 0) - 13086 (document.documentElement.clientTop || 0); 13087 } 13088 13089 return event; 13090 }; 13091 13092 /** 13093 * @deprecated 13094 * @see e.preventDefault() 13095 */ 13096 BX.PreventDefault = function(e) 13097 { 13098 if(!e) e = window.event; 13099 if(e.stopPropagation) 13100 { 13101 e.preventDefault(); 13102 e.stopPropagation(); 13103 } 13104 else 13105 { 13106 e.cancelBubble = true; 13107 e.returnValue = false;
13108 } 13109 return false; 13110 }; 13111 13112 /** 13113 * @deprecated 13114 * @see e.preventDefault(); 13115 * 13116 * @param e 13117 * @return {boolean} 13118 */ 13119 BX.eventReturnFalse = function(e) 13120 { 13121 e=e||window.event; 13122 if (e && e.preventDefault) e.preventDefault(); 13123 else e.returnValue = false; 13124 return false; 13125 }; 13126 13127 /** 13128 * @deprecated 13129 * @see e.stopPropagation() 13130 * @param e 13131 */ 13132 BX.eventCancelBubble = function(e) 13133 { 13134 e=e||window.event; 13135 if(e && e.stopPropagation) 13136 e.stopPropagation(); 13137 else 13138 e.cancelBubble = true; 13139 }; 13140 13141 BX.bindDebouncedChange = function(node, fn, fnInstant, timeout, ctx) 13142 { 13143 ctx = ctx || window; 13144 timeout = timeout || 300; 13145 13146 var dataTag = 'bx-dc-previous-value'; 13147 BX.data(node, dataTag, node.value); 13148 13149 var act = function(fn, val){ 13150 13151 var pVal = BX.data(node, dataTag); 13152 13153 if(typeof pVal == 'undefined' || pVal != val){ 13154 if(typeof ctx != 'object') 13155 fn(val); 13156 else 13157 fn.apply(ctx, [val]); 13158 } 13159 }; 13160 13161 var actD = BX.debounce(function(){ 13162 var val = node.value; 13163 act(fn, val); 13164 BX.data(node, dataTag, val); 13165 }, timeout); 13166 13167 BX.bind(node, 'keyup', actD); 13168 BX.bind(node, 'change', actD); 13169 BX.bind(node, 'input', actD); 13170 13171 if(BX.type.isFunction(fnInstant)){ 13172 13173 var actI = function(){ 13174 act(fnInstant, node.value); 13175 }; 13176 13177 BX.bind(node, 'keyup', actI); 13178 BX.bind(node, 'change', actI); 13179 BX.bind(node, 'input', actI); 13180 } 13181 }; 13182 13183 BX.parseJSON = function(data, context) 13184 { 13185 var result = null; 13186 if (BX.type.isNotEmptyString(data)) 13187 { 13188 try { 13189 if (data.indexOf("\n") >= 0) 13190 eval('result = ' + data); 13191 else 13192 result = (new Function("return " + data))(); 13193 } catch(e) { 13194 BX.onCustomEvent(context, 'onParseJSONFailure', [data, context]) 13195 } 13196 } 13197 else if(BX.type.isPlainObject(data)) 13198 { 13199 return data; 13200 } 13201 13202 return result; 13203 }; 13204 13205 BX.submit = function(obForm, action_name, action_value, onAfterSubmit) 13206 { 13207 action_name = action_name || 'save'; 13208 if (!obForm['BXFormSubmit_' + action_name]) 13209 { 13210 obForm['BXFormSubmit_' + action_name] = obForm.appendChild(BX.create('INPUT', { 13211 'props': { 13212 'type': 'submit', 13213 'name': action_name, 13214 'value': action_value || 'Y' 13215 }, 13216 'style': { 13217 'display': 'none' 13218 } 13219 })); 13220 } 13221 13222 if (obForm.sessid) 13223 obForm.sessid.value = BX.bitrix_sessid(); 13224 13225 setTimeout(BX.delegate(function() {BX.fireEvent(this, 'click'); if (onAfterSubmit) onAfterSubmit();}, obForm['BXFormSubmit_' + action_name]), 10); 13226 }; 13227 13228 BX.show = function(ob, displayType) 13229 { 13230 if (ob.BXDISPLAY || !_checkDisplay(ob, displayType)) 13231 { 13232 ob.style.display = ob.BXDISPLAY; 13233 } 13234 }; 13235 13236 BX.hide = function(ob, displayType) 13237 { 13238 if (!ob.BXDISPLAY) 13239 _checkDisplay(ob, displayType); 13240 13241 ob.style.display = 'none'; 13242 }; 13243 13244 BX.toggle = function(ob, values) 13245 { 13246 if (!values && BX.type.isElementNode(ob)) 13247 { 13248 var bShow = true; 13249 if (ob.BXDISPLAY) 13250 bShow = !_checkDisplay(ob); 13251 else 13252 bShow = ob.style.display == 'none'; 13253 13254 if (bShow) 13255 BX.show(ob); 13256 else 13257 BX.hide(ob); 13258 } 13259 else if (BX.type.isArray(values)) 13260 { 13261 for (var i=0,len=values.length; i<len; i++) 13262 { 13263 if (ob == values[i]) 13264 { 13265 ob = values[i==len-1 ? 0 : i+1]; 13266 break; 13267 } 13268 } 13269 if (i==len) 13270 ob = values[0]; 13271 } 13272 13273 return ob; 13274 }; 13275 13276 function _checkDisplay(ob, displayType) 13277 { 13278 if (typeof displayType != 'undefined') 13279 ob.BXDISPLAY = displayType; 13280 13281 var d = ob.style.display || BX.style(ob, 'display'); 13282 if (d != 'none') 13283 { 13284 ob.BXDISPLAY = ob.BXDISPLAY || d; 13285 return true; 13286 } 13287 else 13288 { 13289 ob.BXDISPLAY = ob.BXDISPLAY || 'block'; 13290 return false; 13291 } 13292 } 13293 13294 /* some useful util functions */ 13295 13296 BX.util = { 13297 /** 13298 * @deprecated 13299 * @use [].filter(value => !BX.Type.isNil(value)) 13300 * @param ar 13301 * @return {*} 13302 */ 13303 array_values: function(ar) 13304 { 13305 if (!BX.type.isArray(ar)) 13306 return BX.util._array_values_ob(ar); 13307 var arv = []; 13308 for(var i=0,l=ar.length;i<l;i++) 13309 if (ar[i] !== null && typeof ar[i] != 'undefined') 13310 arv.push(ar[i]); 13311 return arv; 13312 }, 13313 13314 /** 13315 * @deprecated 13316 * @use Object.values([]).filter(value => !BX.Type.isNil(value)) 13317 * @param ar 13318 * @return {Array} 13319 * @private 13320 */ 13321 _array_values_ob: function(ar) 13322 { 13323 var arv = []; 13324 for(var i in ar) 13325 if (ar[i] !== null && typeof ar[i] != 'undefined') 13326 arv.push(ar[i]); 13327 return arv; 13328 }, 13329 13330 /** 13331 * @deprecated 13332 * @use 13333 * @param ar 13334 * @return {*} 13335 */ 13336 array_keys: function(ar) 13337 { 13338 if (!BX.type.isArray(ar)) 13339 return BX.util._array_keys_ob(ar); 13340 var arv = []; 13341 for(var i=0,l=ar.length;i<l;i++) 13342 if (ar[i] !== null && typeof ar[i] != 'undefined') 13343 arv.push(i); 13344 return arv; 13345 }, 13346 13347 _array_keys_ob: function(ar) 13348 { 13349 var arv = []; 13350 for(var i in ar) 13351 if (ar[i] !== null && typeof ar[i] != 'undefined') 13352 arv.push(i); 13353 return arv; 13354 }, 13355 13356 object_keys: function(obj) 13357 { 13358 var arv = []; 13359 for(var k in obj) 13360 { 13361 if(obj.hasOwnProperty(k)) 13362 { 13363 arv.push(k); 13364 } 13365 } 13366 return arv; 13367 }, 13368 13369 /** 13370 * @deprecated 13371 * @use firstArr.concat(secondArr); 13372 * @param first 13373 * @param second 13374 * @return {*[]} 13375 */ 13376 array_merge: function(first, second) 13377 { 13378 if (!BX.type.isArray(first)) first = []; 13379 if (!BX.type.isArray(second)) second = []; 13380 13381 var i = first.length, j = 0; 13382 13383 if (typeof second.length === "number") 13384 { 13385 for (var l = second.length; j < l; j++) 13386 { 13387 first[i++] = second[j]; 13388 } 13389 } 13390 else 13391 {
13392 while (second[j] !== undefined) 13393 { 13394 first[i++] = second[j++]; 13395 } 13396 } 13397 13398 first.length = i; 13399 13400 return first; 13401 }, 13402 13403 array_flip: function (object) 13404 { 13405 var newObject = {}; 13406 13407 for (var key in object) 13408 { 13409 newObject[object[key]] = key; 13410 } 13411 13412 return newObject; 13413 }, 13414 13415 array_diff: function(ar1, ar2, hash) 13416 { 13417 hash = BX.type.isFunction(hash) ? hash : null; 13418 var i, length, v, h, map = {}, result = []; 13419 for(i = 0, length = ar2.length; i < length; i++) 13420 { 13421 v = ar2[i]; 13422 h = hash ? hash(v) : v; 13423 map[h] = true; 13424 } 13425 13426 for(i = 0, length = ar1.length; i < length; i++) 13427 { 13428 v = ar1[i]; 13429 h = hash ? hash(v) : v; 13430 if(typeof(map[h]) === "undefined") 13431 { 13432 result.push(v); 13433 } 13434 } 13435 return result; 13436 }, 13437 13438 /** 13439 * @deprecated 13440 * @use Set 13441 */ 13442 array_unique: function(ar) 13443 { 13444 var i=0,j,len=ar.length; 13445 if(len<2) return ar; 13446 13447 for (; i<len-1;i++) 13448 { 13449 for (j=i+1; j<len;j++) 13450 { 13451 if (ar[i]==ar[j]) 13452 { 13453 ar.splice(j--,1); len--; 13454 } 13455 } 13456 } 13457 13458 return ar; 13459 }, 13460 13461 /** 13462 * @deprecated 13463 * @use myArr.includes(needle) 13464 */ 13465 in_array: function(needle, haystack) 13466 { 13467 for(var i=0; i<haystack.length; i++) 13468 { 13469 if(haystack[i] == needle) 13470 return true; 13471 } 13472 return false; 13473 }, 13474 13475 /** 13476 * @deprecated 13477 * @use myArr.findIndex(item => item === needle); 13478 */ 13479 array_search: function(needle, haystack) 13480 { 13481 for(var i=0; i<haystack.length; i++) 13482 { 13483 if(haystack[i] == needle) 13484 return i; 13485 } 13486 return -1; 13487 }, 13488 13489 object_search_key: function(needle, haystack) 13490 { 13491 if (typeof haystack[needle] != 'undefined') 13492 return haystack[needle]; 13493 13494 for(var i in haystack) 13495 { 13496 if (typeof haystack[i] == "object") 13497 { 13498 var result = BX.util.object_search_key(needle, haystack[i]); 13499 if (result !== false) 13500 return result; 13501 } 13502 } 13503 return false; 13504 }, 13505 13506 trim: function(s) 13507 { 13508 if (BX.type.isString(s)) 13509 { 13510 return s.trim(); 13511 } 13512 13513 return s; 13514 }, 13515 13516 urlencode: function(s){return encodeURIComponent(s);}, 13517 13518 // it may also be useful. via sVD. 13519 deleteFromArray: function(ar, ind) {return ar.slice(0, ind).concat(ar.slice(ind + 1));}, 13520 insertIntoArray: function(ar, ind, el) {return ar.slice(0, ind).concat([el]).concat(ar.slice(ind));}, 13521 13522 htmlspecialchars: function(str) 13523 { 13524 return BX.Text.encode(str); 13525 }, 13526 13527 htmlspecialcharsback: function(str) 13528 { 13529 return BX.Text.decode(str); 13530 }, 13531 13532 // Quote regular expression characters plus an optional character 13533 preg_quote: function(str, delimiter) 13534 { 13535 if(!str.replace) 13536 return str; 13537 return str.replace(new RegExp('[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\' + (delimiter || '') + '-]', 'g'), '\\$&'); 13538 }, 13539 13540 jsencode: function(str) 13541 { 13542 if (!str || !str.replace) 13543 return str; 13544 13545 var escapes = 13546 [ 13547 { c: "\\\\", r: "\\\\" }, // should be first 13548 { c: "\\t", r: "\\t" }, 13549 { c: "\\n", r: "\\n" }, 13550 { c: "\\r", r: "\\r" }, 13551 { c: "\"", r: "\\\"" }, 13552 { c: "'", r: "\\'" }, 13553 { c: "<", r: "\\x3C" }, 13554 { c: ">", r: "\\x3E" }, 13555 { c: "\\u2028", r: "\\u2028" }, 13556 { c: "\\u2029", r: "\\u2029" } 13557 ]; 13558 for (var i = 0; i < escapes.length; i++) 13559 str = str.replace(new RegExp(escapes[i].c, 'g'), escapes[i].r); 13560 return str; 13561 }, 13562 13563 getCssName: function(jsName) 13564 { 13565 if (!BX.type.isNotEmptyString(jsName)) 13566 { 13567 return ""; 13568 } 13569 13570 return jsName.replace(/[A-Z]/g, function(match) { 13571 return "-" + match.toLowerCase(); 13572 }); 13573 }, 13574 13575 getJsName: function(cssName) 13576 { 13577 var regex = /\-([a-z]){1}/g; 13578 if (regex.test(cssName)) 13579 { 13580 return cssName.replace(regex, function(match, letter) { 13581 return letter.toUpperCase(); 13582 }); 13583 } 13584 13585 return cssName; 13586 }, 13587 13588 nl2br: function(str) 13589 { 13590 if (!str || !str.replace) 13591 return str; 13592 13593 return str.replace(/([^>])\n/g, '$1<br/>'); 13594 }, 13595 13596 /** 13597 * @deprecated 13598 * @use .padStart() / .padEnd() 13599 * @param input 13600 * @param pad_length 13601 * @param pad_string 13602 * @param pad_type 13603 * @return {*} 13604 */ 13605 str_pad: function(input, pad_length, pad_string, pad_type) 13606 { 13607 pad_string = pad_string || ' '; 13608 pad_type = pad_type || 'right'; 13609 input = input.toString(); 13610 13611 if (pad_type === 'left') 13612 { 13613 return BX.util.str_pad_left(input, pad_length, pad_string); 13614 } 13615 13616 return BX.util.str_pad_right(input, pad_length, pad_string); 13617 }, 13618 13619 str_pad_left: function(input, pad_length, pad_string) 13620 { 13621 return input.toString().padStart(pad_length, pad_string); 13622 }, 13623 13624 str_pad_right: function(input, pad_length, pad_string) 13625 { 13626 return input.toString().padEnd(pad_length, pad_string); 13627 }, 13628 13629 strip_tags: function(str) 13630 { 13631 return str.split(/<[^>]+>/g).join(''); 13632 }, 13633 13634 strip_php_tags: function(str) 13635 { 13636 return str.replace(/<\?(.|[\r\n])*?\?>/g, ''); 13637 }, 13638 13639 popup: function(url, width, height) 13640 { 13641 var w, h; 13642 if(BX.browser.IsOpera()) 13643 { 13644 w = document.body.offsetWidth; 13645 h = document.body.offsetHeight; 13646 } 13647 else 13648 {
13649 w = screen.width; 13650 h = screen.height; 13651 } 13652 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)); 13653 }, 13654 13655 shuffle: function(array) 13656 { 13657 var temporaryValue, randomIndex; 13658 var currentIndex = array.length; 13659 13660 while (0 !== currentIndex) 13661 { 13662 randomIndex = Math.floor(Math.random() * currentIndex); 13663 currentIndex -= 1; 13664 13665 temporaryValue = array[currentIndex]; 13666 array[currentIndex] = array[randomIndex]; 13667 array[randomIndex] = temporaryValue; 13668 } 13669 13670 return array; 13671 }, 13672 13673 // BX.util.objectSort(object, sortBy, sortDir) - Sort object by property 13674 // function params: 1 - object for sort, 2 - sort by property, 3 - sort direction (asc/desc) 13675 // return: sort array [[objectElement], [objectElement]] in sortDir direction 13676 13677 // example: BX.util.objectSort({'L1': {'name': 'Last'}, 'F1': {'name': 'First'}}, 'name', 'asc'); 13678 // return: [{'name' : 'First'}, {'name' : 'Last'}] 13679 objectSort: function(object, sortBy, sortDir) 13680 { 13681 sortDir = sortDir == 'asc'? 'asc': 'desc'; 13682 13683 var arItems = [], i; 13684 for (i in object) 13685 { 13686 if (object.hasOwnProperty(i) && object[i][sortBy]) 13687 { 13688 arItems.push([i, object[i][sortBy]]); 13689 } 13690 } 13691 13692 if (sortDir == 'asc') 13693 { 13694 arItems.sort(function(i, ii) { 13695 var s1, s2; 13696 if (BX.type.isDate(i[1])) 13697 { 13698 s1 = i[1].getTime(); 13699 } 13700 else if (!isNaN(i[1])) 13701 { 13702 s1 = parseInt(i[1]); 13703 } 13704 else 13705 { 13706 s1 = i[1].toString().toLowerCase(); 13707 } 13708 13709 if (BX.type.isDate(ii[1])) 13710 { 13711 s2 = ii[1].getTime(); 13712 } 13713 else if (!isNaN(ii[1])) 13714 { 13715 s2 = parseInt(ii[1]); 13716 } 13717 else 13718 { 13719 s2 = ii[1].toString().toLowerCase(); 13720 } 13721 13722 if (s1 > s2) 13723 return 1; 13724 else if (s1 < s2) 13725 return -1; 13726 else 13727 return 0; 13728 }); 13729 } 13730 else 13731 { 13732 arItems.sort(function(i, ii) { 13733 var s1, s2; 13734 if (BX.type.isDate(i[1])) 13735 { 13736 s1 = i[1].getTime(); 13737 } 13738 else if (!isNaN(i[1])) 13739 { 13740 s1 = parseInt(i[1]); 13741 } 13742 else 13743 { 13744 s1 = i[1].toString().toLowerCase(); 13745 } 13746 13747 if (BX.type.isDate(ii[1])) 13748 { 13749 s2 = ii[1].getTime(); 13750 } 13751 else if (!isNaN(ii[1])) 13752 { 13753 s2 = parseInt(ii[1]); 13754 } 13755 else 13756 { 13757 s2 = ii[1].toString().toLowerCase(); 13758 } 13759 13760 if (s1 < s2) 13761 return 1; 13762 else if (s1 > s2) 13763 return -1; 13764 else 13765 return 0; 13766 }); 13767 } 13768 13769 var arReturnArray = Array(); 13770 for (i = 0; i < arItems.length; i++) 13771 { 13772 arReturnArray.push(object[arItems[i][0]]); 13773 } 13774 13775 return arReturnArray; 13776 }, 13777 13778 objectMerge: function() 13779 { 13780 return BX.mergeEx.apply(window, arguments); 13781 }, 13782 13783 objectClone : function(object) 13784 { 13785 return BX.clone(object, true); 13786 }, 13787 13788 // #fdf9e5 => {r=253, g=249, b=229} 13789 hex2rgb: function(color) 13790 { 13791 var rgb = color.replace(/[# ]/g,"").replace(/^(.)(.)(.)$/,'$1$1$2$2$3$3').match(/.{2}/g); 13792 for (var i=0; i<3; i++) 13793 { 13794 rgb[i] = parseInt(rgb[i], 16); 13795 } 13796 return {'r':rgb[0],'g':rgb[1],'b':rgb[2]}; 13797 }, 13798 13799 /** 13800 * @deprecated 13801 * @use BX.Uri 13802 * @param url 13803 * @param param 13804 * @return {string} 13805 */ 13806 remove_url_param: function(url, param) 13807 { 13808 return BX.Uri.removeParam(url, param); 13809 }, 13810 13811 /* 13812 {'param1': 'value1', 'param2': 'value2'} 13813 */ 13814 /** 13815 * @deprecated 13816 * @use BX.Uri 13817 * @param url 13818 * @param params 13819 * @return {string} 13820 */ 13821 add_url_param: function(url, params) 13822 { 13823 var preparedParams = Object.entries(params).reduce(function(acc, item) { 13824 acc[item[0]] = BX.type.isArray(item[1]) ? item[1].join() : item[1]; 13825 return acc; 13826 }, {}); 13827 13828 return BX.Uri.addParam(url, preparedParams); 13829 }, 13830 13831 /* 13832 {'param1': 'value1', 'param2': 'value2'} 13833 */ 13834 buildQueryString: function(params) 13835 { 13836 var result = ''; 13837 for (var key in params) 13838 { 13839 var value = params[key]; 13840 if(BX.type.isArray(value)) 13841 { 13842 value.forEach(function(valueElement, index) 13843 { 13844 result += encodeURIComponent(key + "[" + index + "]") + "=" + encodeURIComponent(valueElement) + "&"; 13845 }); 13846 } 13847 else 13848 { 13849 result += encodeURIComponent(key) + "=" + encodeURIComponent(value) + "&"; 13850 } 13851 } 13852 13853 if(result.length > 0) 13854 { 13855 result = result.substr(0, result.length - 1); 13856 } 13857 return result; 13858 }, 13859 13860 even: function(digit) 13861 { 13862 return (parseInt(digit) % 2 == 0); 13863 }, 13864 13865 hashCode: function(str) 13866 { 13867 if(!BX.type.isNotEmptyString(str)) 13868 { 13869 return 0; 13870 } 13871 13872 var hash = 0; 13873 for (var i = 0; i < str.length; i++) 13874 { 13875 var c = str.charCodeAt(i); 13876 hash = ((hash << 5) - hash) + c; 13877 hash = hash & hash; 13878 } 13879 return hash; 13880 }, 13881 13882 getRandomString: function (length) 13883 { 13884 return BX.Text.getRandom(length); 13885 }, 13886 13887 number_format: function(number, decimals, dec_point, thousands_sep) 13888 { 13889 var i, j, kw, kd, km, sign = ''; 13890 decimals = Math.abs(decimals); 13891 if (isNaN(decimals) || decimals < 0) 13892 { 13893 decimals = 2; 13894 } 13895 dec_point = dec_point || ','; 13896 if (typeof thousands_sep === 'undefined') 13897 thousands_sep = '.'; 13898 13899 number = (+number || 0).toFixed(decimals); 13900 if (number < 0) 13901 { 13902 sign = '-'; 13903 number = -number; 13904 } 13905 13906 i = parseInt(number, 10) + ''; 13907 j = (i.length > 3 ? i.length % 3 : 0); 13908 13909 km = (j ? i.substr(0, j) + thousands_sep : ''); 13910 kw = i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousands_sep); 13911 kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).replace(/-/, '0').slice(2) : ''); 13912 13913 return sign + km + kw + kd; 13914 }, 13915 13916 getExtension: function (url) 13917 { 13918 url = url || ""; 13919 var items = url.split("?")[0].split("."); 13920 return items[items.length-1].toLowerCase(); 13921 }, 13922 addObjectToForm: function(object, form, prefix) 13923 { 13924 if(!BX.type.isString(prefix)) 13925 { 13926 prefix = ""; 13927 } 13928 13929 for(var key in object) 13930 { 13931 if(!object.hasOwnProperty(key)) 13932 { 13933 continue; 13934 } 13935 13936 var value = object[key]; 13937 var name = prefix !== "" ? (prefix + "[" + key + "]") : key; 13938 if(BX.type.isArray(value)) 13939 { 13940 var obj = {}; 13941 for(var i = 0; i < value.length; i++) 13942 { 13943 obj[i] = value[i]; 13944 } 13945 13946 BX.util.addObjectToForm(obj, form, name); 13947 } 13948 else if(BX.type.isPlainObject(value)) 13949 { 13950 BX.util.addObjectToForm(value, form, name); 13951 } 13952 else 13953 { 13954 value = BX.type.isFunction(value.toString) ? value.toString() : ""; 13955 if(value !== "") 13956 { 13957 form.appendChild(BX.create("INPUT", { attrs: { type: "hidden", name: name, value: value } })); 13958 } 13959 } 13960 } 13961 }, 13962 13963 observe: function(object, enable) 13964 {
13965 console.error('BX.util.observe: function is no longer supported by browser.'); 13966 return false; 13967 }, 13968 13969 escapeRegExp: function(str) 13970 { 13971 return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); 13972 } 13973 }; 13974 13975 BX.validation = { 13976 checkIfEmail: function(s) 13977 { 13978 var atom = "[=a-z0-9_+~'!$&*^`|#%/?{}-]"; 13979 return (new RegExp('^\\s*'+atom+'+(\\.'+atom+'+)*@([a-z0-9-]+\\.)+[a-z0-9-]{2,20}\\s*$', 'i')).test(s); 13980 }, 13981 checkIfPhone: function(s) 13982 { 13983 var regexp = new RegExp( 13984 typeof(BX.PhoneNumber) === "undefined" 13985 ? BX.PhoneNumber.getValidNumberPattern() 13986 : '^\\s*\\+?\s*[0-9(-)\\s]+\\s*$', 13987 'i' 13988 ); 13989 return regexp.test(s); 13990 } 13991 }; 13992 13993 BX.prop = 13994 { 13995 get: function(object, key, defaultValue) 13996 { 13997 return object && object.hasOwnProperty(key) ? object[key] : defaultValue; 13998 }, 13999 getObject: function(object, key, defaultValue) 14000 { 14001 return object && BX.type.isPlainObject(object[key]) ? object[key] : defaultValue; 14002 }, 14003 getElementNode: function(object, key, defaultValue) 14004 { 14005 return object && BX.type.isElementNode(object[key]) ? object[key] : defaultValue; 14006 }, 14007 getArray: function(object, key, defaultValue) 14008 { 14009 return object && BX.type.isArray(object[key]) ? object[key] : defaultValue; 14010 }, 14011 getFunction: function(object, key, defaultValue) 14012 { 14013 return object && BX.type.isFunction(object[key]) ? object[key] : defaultValue; 14014 }, 14015 getNumber: function(object, key, defaultValue) 14016 { 14017 if(!(object && object.hasOwnProperty(key))) 14018 { 14019 return defaultValue; 14020 } 14021 14022 var value = object[key]; 14023 if(BX.type.isNumber(value)) 14024 { 14025 return value; 14026 } 14027 14028 value = parseFloat(value); 14029 return !isNaN(value) ? value : defaultValue; 14030 }, 14031 getInteger: function(object, key, defaultValue) 14032 { 14033 if(!(object && object.hasOwnProperty(key))) 14034 { 14035 return defaultValue; 14036 } 14037 14038 var value = object[key]; 14039 if(BX.type.isNumber(value)) 14040 { 14041 return value; 14042 } 14043 14044 value = parseInt(value); 14045 return !isNaN(value) ? value : defaultValue; 14046 }, 14047 getBoolean: function(object, key, defaultValue) 14048 { 14049 if(!(object && object.hasOwnProperty(key))) 14050 { 14051 return defaultValue; 14052 } 14053 14054 var value = object[key]; 14055 return (BX.type.isBoolean(value) 14056 ? value 14057 : (BX.type.isString(value) ? (value.toLowerCase() === "true") : !!value) 14058 ); 14059 }, 14060 getString: function(object, key, defaultValue) 14061 { 14062 if(!(object && object.hasOwnProperty(key))) 14063 { 14064 return defaultValue; 14065 } 14066 14067 var value = object[key]; 14068 return BX.type.isString(value) ? value : (value ? value.toString() : ''); 14069 }, 14070 extractDate: function(datetime) 14071 { 14072 if(!BX.type.isDate(datetime)) 14073 { 14074 datetime = new Date(); 14075 } 14076 14077 datetime.setHours(0); 14078 datetime.setMinutes(0); 14079 datetime.setSeconds(0); 14080 datetime.setMilliseconds(0); 14081 14082 return datetime; 14083 } 14084 }; 14085 14086 BX.isNodeInDom = function(node, doc) 14087 { 14088 return node === (doc || document) ? true : 14089 (node.parentNode ? BX.isNodeInDom(node.parentNode) : false); 14090 }; 14091 14092 BX.isNodeHidden = function(node) 14093 { 14094 if (node === document) 14095 return false; 14096 else if (BX.style(node, 'display') == 'none') 14097 return true; 14098 else 14099 return (node.parentNode ? BX.isNodeHidden(node.parentNode) : true); 14100 }; 14101 14102 BX.evalPack = function(code) 14103 { 14104 while (code.length > 0) 14105 { 14106 var c = code.shift(); 14107 14108 if (c.TYPE == 'SCRIPT_EXT' || c.TYPE == 'SCRIPT_SRC') 14109 { 14110 BX.loadScript(c.DATA, function() {BX.evalPack(code)}); 14111 return; 14112 } 14113 else if (c.TYPE == 'SCRIPT') 14114 { 14115 BX.evalGlobal(c.DATA); 14116 } 14117 } 14118 }; 14119 14120 BX.evalGlobal = function(data) 14121 { 14122 if (data) 14123 { 14124 var head = document.getElementsByTagName("head")[0] || document.documentElement, 14125 script = document.createElement("script"); 14126 14127 script.type = "text/javascript"; 14128 14129 if (!BX.browser.IsIE()) 14130 { 14131 script.appendChild(document.createTextNode(data)); 14132 } 14133 else 14134 { 14135 script.text = data; 14136 } 14137 14138 head.insertBefore(script, head.firstChild); 14139 head.removeChild(script); 14140 } 14141 }; 14142 14143 BX.garbage = function(call, thisObject) 14144 { 14145 garbageCollectors.push({callback: call, context: thisObject}); 14146 }; 14147 14148 BX.GetDocElement = function (pDoc) 14149 { 14150 pDoc = pDoc || document; 14151 return (BX.browser.IsDoctype(pDoc) ? pDoc.documentElement : pDoc.body); 14152 }; 14153 14154 BX.scrollTop = function(node, val){ 14155 if(typeof val != 'undefined'){ 14156 14157 if(node == window){ 14158 throw new Error('scrollTop() for window is not implemented'); 14159 }else 14160 node.scrollTop = parseInt(val); 14161 14162 }else{ 14163 14164 if(node == window) 14165 return BX.GetWindowScrollPos().scrollTop; 14166 14167 return node.scrollTop; 14168 } 14169 }; 14170 14171 BX.scrollLeft = function(node, val){ 14172 if(typeof val != 'undefined'){ 14173 14174 if(node == window){ 14175 throw new Error('scrollLeft() for window is not implemented'); 14176 }else 14177 node.scrollLeft = parseInt(val); 14178 14179 }else{ 14180 14181 if(node == window) 14182 return BX.GetWindowScrollPos().scrollLeft; 14183 14184 return node.scrollLeft; 14185 } 14186 }; 14187 14188 BX.hide_object = function(ob) 14189 { 14190 ob = BX(ob); 14191 ob.style.position = 'absolute'; 14192 ob.style.top = '-1000px'; 14193 ob.style.left = '-1000px'; 14194 ob.style.height = '10px'; 14195 ob.style.width = '10px'; 14196 }; 14197 14198 BX.is_relative = function(el) 14199 { 14200 var p = BX.style(el, 'position'); 14201 return p == 'relative' || p == 'absolute'; 14202 }; 14203 14204 BX.is_float = function(el) 14205 { 14206 var p = BX.style(el, 'float'); 14207 return p == 'right' || p == 'left'; 14208 }; 14209 14210 BX.is_fixed = function(el) 14211 { 14212 var p = BX.style(el, 'position'); 14213 return p == 'fixed'; 14214 }; 14215 14216 BX.width = function(node, val){ 14217 if(typeof val != 'undefined') 14218 BX.style(node, 'width', parseInt(val)+'px'); 14219 else{ 14220 14221 if(node == window) 14222 return window.innerWidth; 14223 14224 //return parseInt(BX.style(node, 'width')); 14225 return BX.pos(node).width; 14226 } 14227 }; 14228 14229 BX.height = function(node, val){ 14230 if(typeof val != 'undefined') 14231 BX.style(node, 'height', parseInt(val)+'px'); 14232 else{ 14233 14234 if(node == window) 14235 return window.innerHeight; 14236 14237 //return parseInt(BX.style(node, 'height')); 14238 return BX.pos(node).height; 14239 } 14240 }; 14241 14242 BX.align = function(pos, w, h, type) 14243 { 14244 if (type) 14245 type = type.toLowerCase(); 14246 else 14247 type = ''; 14248 14249 var pDoc = document; 14250 if (BX.type.isElementNode(pos)) 14251 { 14252 pDoc = pos.ownerDocument; 14253 pos = BX.pos(pos); 14254 } 14255 14256 var x = pos["left"], y = pos["bottom"]; 14257 14258 var scroll = BX.GetWindowScrollPos(pDoc); 14259 var size = BX.GetWindowInnerSize(pDoc); 14260 14261 if((size.innerWidth + scroll.scrollLeft) - (pos["left"] + w) < 0) 14262 { 14263 if(pos["right"] - w >= 0 ) 14264 x = pos["right"] - w; 14265 else 14266 x = scroll.scrollLeft; 14267 } 14268
14269 if(((size.innerHeight + scroll.scrollTop) - (pos["bottom"] + h) < 0) || ~type.indexOf('top')) 14270 { 14271 if(pos["top"] - h >= 0 || ~type.indexOf('top')) 14272 y = pos["top"] - h; 14273 else 14274 y = scroll.scrollTop; 14275 } 14276 14277 return {'left':x, 'top':y}; 14278 }; 14279 14280 BX.scrollToNode = function(node) 14281 { 14282 var obNode = BX(node); 14283 14284 if (obNode.scrollIntoView) 14285 obNode.scrollIntoView(true); 14286 else 14287 { 14288 var arNodePos = BX.pos(obNode); 14289 window.scrollTo(arNodePos.left, arNodePos.top); 14290 } 14291 }; 14292 14293 /* non-xhr loadings */ 14294 BX.showWait = function(node, msg) 14295 { 14296 node = BX(node) || document.body || document.documentElement; 14297 msg = msg || BX.message('JS_CORE_LOADING'); 14298 14299 var container_id = node.id || Math.random(); 14300 14301 var obMsg = node.bxmsg = document.body.appendChild(BX.create('DIV', { 14302 props: { 14303 id: 'wait_' + container_id 14304 }, 14305 style: { 14306 background: 'url("/bitrix/js/main/core/images/wait.gif") no-repeat scroll 10px center #fcf7d1', 14307 border: '1px solid #E1B52D', 14308 color: 'black', 14309 fontFamily: 'Verdana,Arial,sans-serif', 14310 fontSize: '11px', 14311 padding: '10px 30px 10px 37px', 14312 position: 'absolute', 14313 textAlign:'center' 14314 }, 14315 text: msg 14316 })); 14317 14318 BX.ZIndexManager.register(obMsg); 14319 BX.ZIndexManager.bringToFront(obMsg); 14320 14321 setTimeout(BX.delegate(_adjustWait, node), 10); 14322 14323 lastWait[lastWait.length] = obMsg; 14324 return obMsg; 14325 }; 14326 14327 BX.closeWait = function(node, obMsg) 14328 { 14329 if(node && !obMsg) 14330 obMsg = node.bxmsg; 14331 if(node && !obMsg && BX.hasClass(node, 'bx-core-waitwindow')) 14332 obMsg = node; 14333 if(node && !obMsg) 14334 obMsg = BX('wait_' + node.id); 14335 if(!obMsg) 14336 obMsg = lastWait.pop(); 14337 14338 if (obMsg && obMsg.parentNode) 14339 { 14340 for (var i=0,len=lastWait.length;i<len;i++) 14341 { 14342 if (obMsg == lastWait[i]) 14343 { 14344 lastWait = BX.util.deleteFromArray(lastWait, i); 14345 break; 14346 } 14347 } 14348 14349 BX.ZIndexManager.unregister(obMsg); 14350 obMsg.parentNode.removeChild(obMsg); 14351 if (node) node.bxmsg = null; 14352 BX.cleanNode(obMsg, true); 14353 } 14354 }; 14355 14356 BX.setJSList = function(scripts) 14357 { 14358 if (BX.type.isArray(scripts)) 14359 { 14360 scripts = scripts.map(function(script) { 14361 return normalizeUrl(script) 14362 }); 14363 14364 jsList = jsList.concat(scripts); 14365 } 14366 }; 14367 14368 BX.getJSList = function() 14369 { 14370 initJsList(); 14371 return jsList; 14372 }; 14373 14374 BX.setCSSList = function(cssFiles) 14375 { 14376 if (BX.type.isArray(cssFiles)) 14377 { 14378 cssFiles = cssFiles.map(function(cssFile) { 14379 return normalizeUrl(cssFile); 14380 }); 14381 14382 cssList = cssList.concat(cssFiles); 14383 } 14384 }; 14385 14386 BX.getCSSList = function() 14387 { 14388 initCssList(); 14389 return cssList; 14390 }; 14391 14392 BX.getJSPath = function(js) 14393 { 14394 return js.replace(/^(http[s]*:)*\/\/[^\/]+/i, ''); 14395 }; 14396 14397 BX.getCSSPath = function(css) 14398 { 14399 return css.replace(/^(http[s]*:)*\/\/[^\/]+/i, ''); 14400 }; 14401 14402 BX.getCDNPath = function(path) 14403 { 14404 return path; 14405 }; 14406 14407 BX.loadScript = function(script, callback, doc) 14408 { 14409 if (BX.type.isString(script)) 14410 { 14411 script = [script]; 14412 } 14413 14414 return BX.load(script, callback, doc); 14415 }; 14416 14417 BX.loadCSS = function(css, doc, win) 14418 { 14419 if (BX.type.isString(css)) 14420 { 14421 css = [css]; 14422 } 14423 14424 if (BX.type.isArray(css)) 14425 { 14426 css = css.map(function(url) { 14427 return { url: url, ext: "css" } 14428 }); 14429 14430 BX.load(css, null, doc); 14431 } 14432 }; 14433 14434 BX.load = function(items, callback, doc) 14435 { 14436 if (!BX.isReady) 14437 { 14438 var _args = arguments; 14439 BX.ready(function() { 14440 BX.load.apply(this, _args); 14441 }); 14442 return null; 14443 } 14444 14445 doc = doc || document; 14446 if (isAsync === null) 14447 { 14448 isAsync = "async" in doc.createElement("script") || "MozAppearance" in doc.documentElement.style || window.opera; 14449 } 14450 14451 return isAsync ? loadAsync(items, callback, doc) : loadAsyncEmulation(items, callback, doc); 14452 }; 14453 14454 BX.convert = 14455 { 14456 toNumber: function(value) 14457 { 14458 if(BX.type.isNumber(value)) 14459 { 14460 return value; 14461 } 14462 14463 value = Number(value); 14464 return !isNaN(value) ? value : 0; 14465 }, 14466 nodeListToArray: function(nodes) 14467 { 14468 try 14469 { 14470 return (Array.prototype.slice.call(nodes, 0)); 14471 } 14472 catch (ex) 14473 { 14474 var ary = []; 14475 for(var i = 0, l = nodes.length; i < l; i++) 14476 { 14477 ary.push(nodes[i]); 14478 } 14479 return ary; 14480 } 14481 } 14482 }; 14483 14484 function loadAsync(items, callback, doc) 14485 { 14486 if (!BX.type.isArray(items)) 14487 { 14488 return; 14489 } 14490 14491 function allLoaded(items) 14492 { 14493 items = items || assets; 14494 for (var name in items) 14495 { 14496 if (items.hasOwnProperty(name) && items[name].state !== LOADED) 14497 { 14498 return false;
14499 } 14500 } 14501 14502 return true; 14503 } 14504 14505 if (!BX.type.isFunction(callback)) 14506 { 14507 callback = null; 14508 } 14509 14510 var itemSet = {}, item, i; 14511 for (i = 0; i < items.length; i++) 14512 { 14513 item = items[i]; 14514 item = getAsset(item); 14515 itemSet[item.name] = item; 14516 } 14517 14518 var callbackWasCalled = false; 14519 if (items.length > 0) 14520 { 14521 for (i = 0; i < items.length; i++) 14522 { 14523 item = items[i]; 14524 item = getAsset(item); 14525 load(item, function () { 14526 if (allLoaded(itemSet)) 14527 { 14528 if (!callbackWasCalled) 14529 { 14530 callback && callback(); 14531 callbackWasCalled = true; 14532 } 14533 14534 } 14535 }, doc); 14536 } 14537 } 14538 else 14539 { 14540 if (typeof callback === 'function') 14541 { 14542 callback(); 14543 callbackWasCalled = true; 14544 } 14545 } 14546 } 14547 14548 function loadAsyncEmulation(items, callback, doc) 14549 { 14550 function onPreload(asset) 14551 { 14552 asset.state = PRELOADED; 14553 if (BX.type.isArray(asset.onpreload) && asset.onpreload) 14554 { 14555 for (var i = 0; i < asset.onpreload.length; i++) 14556 { 14557 asset.onpreload[i].call(); 14558 } 14559 } 14560 } 14561 14562 function preLoad(asset) 14563 { 14564 if (asset.state === undefined) 14565 { 14566 asset.state = PRELOADING; 14567 asset.onpreload = []; 14568 14569 loadAsset( 14570 { url: asset.url, type: "cache", ext: asset.ext}, 14571 function () { onPreload(asset); }, 14572 doc 14573 ); 14574 } 14575 } 14576 14577 if (!BX.type.isArray(items)) 14578 { 14579 return; 14580 } 14581 14582 if (!BX.type.isFunction(callback)) 14583 { 14584 callback = null; 14585 } 14586 14587 var rest = [].slice.call(items, 1); 14588 for (var i = 0; i < rest.length; i++) 14589 { 14590 preLoad(getAsset(rest[i])); 14591 } 14592 14593 load(getAsset(items[0]), items.length === 1 ? callback : function () { 14594 loadAsyncEmulation.apply(null, [rest, callback, doc]); 14595 }, doc); 14596 } 14597 14598 function load(asset, callback, doc) 14599 { 14600 callback = callback || BX.DoNothing; 14601 14602 if (asset.state === LOADED) 14603 { 14604 callback(); 14605 return; 14606 } 14607 14608 if (asset.state === PRELOADING) 14609 { 14610 asset.onpreload.push(function () { 14611 load(asset, callback, doc); 14612 }); 14613 return; 14614 } 14615 14616 asset.state = LOADING; 14617 14618 loadAsset( 14619 asset, 14620 function () { 14621 asset.state = LOADED; 14622 callback(); 14623 }, 14624 doc 14625 ); 14626 } 14627 14628 function loadAsset(asset, callback, doc) 14629 { 14630 callback = callback || BX.DoNothing; 14631 14632 function error(event) 14633 { 14634 ele.onload = ele.onreadystatechange = ele.onerror = null; 14635 callback(); 14636 } 14637 14638 function process(event) 14639 { 14640 event = event || window.event; 14641 if (event.type === "load" || (/loaded|complete/.test(ele.readyState) && (!doc.documentMode || doc.documentMode < 9))) 14642 { 14643 window.clearTimeout(asset.errorTimeout); 14644 window.clearTimeout(asset.cssTimeout); 14645 ele.onload = ele.onreadystatechange = ele.onerror = null; 14646 callback(); 14647 } 14648 } 14649 14650 function isCssLoaded() 14651 { 14652 if (asset.state !== LOADED && asset.cssRetries <= 20) 14653 { 14654 for (var i = 0, l = doc.styleSheets.length; i < l; i++) 14655 { 14656 if (doc.styleSheets[i].href === ele.href) 14657 { 14658 process({"type": "load"}); 14659 return; 14660 } 14661 } 14662 14663 asset.cssRetries++; 14664 asset.cssTimeout = window.setTimeout(isCssLoaded, 250); 14665 } 14666 } 14667 14668 var ele; 14669 var ext = BX.type.isNotEmptyString(asset.ext) ? asset.ext : BX.util.getExtension(asset.url); 14670 14671 if (ext === "css") 14672 { 14673 ele = doc.createElement("link"); 14674 ele.type = "text/" + (asset.type || "css"); 14675 ele.rel = "stylesheet"; 14676 ele.href = asset.url; 14677 14678 asset.cssRetries = 0; 14679 asset.cssTimeout = window.setTimeout(isCssLoaded, 500); 14680 } 14681 else 14682 { 14683 ele = doc.createElement("script"); 14684 ele.type = "text/" + (asset.type || "javascript"); 14685 ele.src = asset.url; 14686 } 14687 14688 ele.onload = ele.onreadystatechange = process; 14689 ele.onerror = error; 14690 14691 ele.async = false; 14692 ele.defer = false; 14693 14694 asset.errorTimeout = window.setTimeout(function () { 14695 error({type: "timeout"}); 14696 }, 7000); 14697 14698 if (ext === "css") 14699 { 14700 cssList.push(normalizeMinUrl(normalizeUrl(asset.url))); 14701 } 14702 else 14703 { 14704 jsList.push(normalizeMinUrl(normalizeUrl(asset.url))); 14705 } 14706 14707 var templateLink = null; 14708 var head = doc.head || doc.getElementsByTagName("head")[0]; 14709 if (ext === "css" && (templateLink = getTemplateLink(head)) !== null) 14710 { 14711 templateLink.parentNode.insertBefore(ele, templateLink); 14712 } 14713 else 14714 { 14715 head.insertBefore(ele, head.lastChild); 14716 } 14717 } 14718 14719 function getAsset(item) 14720 { 14721 var asset = {}; 14722 if (typeof item === "object") 14723 { 14724 asset = item; 14725 asset.name = asset.name ? asset.name : BX.util.hashCode(item.url); 14726 } 14727 else 14728 { 14729 asset = { name: BX.util.hashCode(item), url : item }; 14730 } 14731 14732 var ext = BX.type.isNotEmptyString(asset.ext) ? asset.ext : BX.util.getExtension(asset.url); 14733 if ((ext === "css" && isCssLoaded(asset.url)) || isScriptLoaded(asset.url)) 14734 { 14735 asset.state = LOADED; 14736 } 14737 14738 var existing = assets[asset.name]; 14739 if (existing && existing.url === asset.url) 14740 { 14741 return existing; 14742 } 14743 14744 assets[asset.name] = asset; 14745 return asset; 14746 } 14747 14748 function normalizeUrl(url) 14749 { 14750 if (!BX.type.isNotEmptyString(url)) 14751 { 14752 return ""; 14753 } 14754 14755 url = BX.getJSPath(url); 14756 url = url.replace(/\?[0-9]*$/, ""); 14757 14758 return url; 14759 } 14760 14761 function normalizeMinUrl(url) 14762 { 14763 if (!BX.type.isNotEmptyString(url)) 14764 { 14765 return ""; 14766 } 14767 14768 var minPos = url.indexOf(".min"); 14769 return minPos >= 0 ? url.substr(0, minPos) + url.substr(minPos + 4) : url; 14770 } 14771 14772 function isCssLoaded(fileSrc) 14773 { 14774 initCssList(); 14775 14776 fileSrc = normalizeUrl(fileSrc); 14777 var fileSrcMin = normalizeMinUrl(fileSrc); 14778 14779 return (fileSrc !== fileSrcMin && BX.util.in_array(fileSrcMin, cssList)) || BX.util.in_array(fileSrc, cssList); 14780 } 14781 14782 function initCssList() 14783 { 14784 if(!cssInit) 14785 { 14786 var linksCol = document.getElementsByTagName('link'); 14787 14788 if(!!linksCol && linksCol.length > 0) 14789 { 14790 for(var i = 0; i < linksCol.length; i++) 14791 { 14792 var href = linksCol[i].getAttribute('href'); 14793 if (BX.type.isNotEmptyString(href)) 14794 { 14795 href = normalizeMinUrl(normalizeUrl(href)); 14796 cssList.push(href); 14797 } 14798 } 14799 } 14800 cssInit = true; 14801 } 14802 } 14803 14804 function getTemplateLink(head) 14805 { 14806 var findLink = function(tag) 14807 { 14808 var links = head.getElementsByTagName(tag); 14809 for (var i = 0, length = links.length; i < length; i++) 14810 { 14811 var templateStyle = links[i].getAttribute("data-template-style"); 14812 if (BX.type.isNotEmptyString(templateStyle) && templateStyle == "true") 14813 { 14814 return links[i]; 14815 } 14816 } 14817 14818 return null; 14819 }; 14820 14821 var link = findLink("link"); 14822 if (link === null) 14823 { 14824 link = findLink("style"); 14825 } 14826 14827 return link; 14828 } 14829 14830 function isScriptLoaded(fileSrc) 14831 { 14832 initJsList(); 14833 14834 fileSrc = normalizeUrl(fileSrc); 14835 var fileSrcMin = normalizeMinUrl(fileSrc); 14836 14837 return (fileSrc !== fileSrcMin && BX.util.in_array(fileSrcMin, jsList)) || BX.util.in_array(fileSrc, jsList); 14838 } 14839 14840 function initJsList() 14841 { 14842 if(!jsInit) 14843 { 14844 var scriptCol = document.getElementsByTagName('script'); 14845 14846 if(!!scriptCol && scriptCol.length > 0) 14847 { 14848 for(var i=0; i<scriptCol.length; i++) 14849 { 14850 var src = scriptCol[i].getAttribute('src'); 14851 14852 if (BX.type.isNotEmptyString(src)) 14853 { 14854 src = normalizeMinUrl(normalizeUrl(src)); 14855 jsList.push(src); 14856 } 14857 } 14858 } 14859 jsInit = true; 14860 } 14861 } 14862 14863 function reloadInternal(back_url, bAddClearCache) 14864 { 14865 if (back_url === true) 14866 { 14867 bAddClearCache = true; 14868 back_url = null; 14869 } 14870 14871 var topWindow = (function() { 14872 if (BX.PageObject && BX.PageObject.getRootWindow) 14873 { 14874 return BX.PageObject.getRootWindow(); 14875 } 14876 14877 return window.top; 14878 })(); 14879 var new_href = back_url || topWindow.location.href; 14880 14881 var hashpos = new_href.indexOf('#'), hash = ''; 14882 14883 if (hashpos != -1) 14884 { 14885 hash = new_href.substr(hashpos); 14886 new_href = new_href.substr(0, hashpos); 14887 } 14888 14889 if (bAddClearCache && new_href.indexOf('clear_cache=Y') < 0) 14890 new_href += (new_href.indexOf('?') == -1 ? '?' : '&') + 'clear_cache=Y'; 14891 14892 if (hash) 14893 { 14894 // hack for clearing cache in ajax mode components with history emulation 14895 if (bAddClearCache && (hash.substr(0, 5) == 'view/' || hash.substr(0, 6) == '#view/') && hash.indexOf('clear_cache%3DY') < 0) 14896 hash += (hash.indexOf('%3F') == -1 ? '%3F' : '%26') + 'clear_cache%3DY'; 14897 14898 new_href = new_href.replace(/(\?|\&)_r=[\d]*/, ''); 14899 new_href += (new_href.indexOf('?') == -1 ? '?' : '&') + '_r='+Math.round(Math.random()*10000) + hash; 14900 } 14901 14902 topWindow.location.href = new_href; 14903 } 14904 14905 BX.reload = function(back_url, bAddClearCache) 14906 { 14907 if (window !== window.top) 14908 { 14909 BX.Runtime 14910 .loadExtension('main.pageobject') 14911 .then(function() { 14912 reloadInternal(back_url, bAddClearCache); 14913 }); 14914 } 14915 else 14916 { 14917 reloadInternal(back_url, bAddClearCache); 14918 } 14919 }; 14920 14921 BX.clearCache = function() 14922 { 14923 BX.showWait(); 14924 BX.reload(true); 14925 }; 14926 14927 BX.template = function(tpl, callback, bKillTpl) 14928 { 14929 BX.ready(function() { 14930 _processTpl(BX(tpl), callback, bKillTpl); 14931 }); 14932 }; 14933 14934 BX.isAmPmMode = function(returnConst) 14935 { 14936 if (returnConst === true) 14937 { 14938 return BX.message.AMPM_MODE; 14939 } 14940 return BX.message.AMPM_MODE !== false; 14941 }; 14942 14943 BX.formatDate = function(date, format) 14944 { 14945 date = date || new Date(); 14946 14947 var bTime = date.getHours() || date.getMinutes() || date.getSeconds(), 14948 str = !!format 14949 ? format : 14950 (bTime ? BX.message('FORMAT_DATETIME') : BX.message('FORMAT_DATE') 14951 ); 14952 14953 return str.replace(/YYYY/ig, date.getFullYear()) 14954 .replace(/MMMM/ig, BX.util.str_pad_left((date.getMonth()+1).toString(), 2, '0')) 14955 .replace(/MM/ig, BX.util.str_pad_left((date.getMonth()+1).toString(), 2, '0')) 14956 .replace(/DD/ig, BX.util.str_pad_left(date.getDate().toString(), 2, '0')) 14957 .replace(/HH/ig, BX.util.str_pad_left(date.getHours().toString(), 2, '0')) 14958 .replace(/MI/ig, BX.util.str_pad_left(date.getMinutes().toString(), 2, '0')) 14959 .replace(/SS/ig, BX.util.str_pad_left(date.getSeconds().toString(), 2, '0')); 14960 }; 14961 BX.formatName = function(user, template, login) 14962 { 14963 user = user || {}; 14964 template = (template || ''); 14965 var replacement = { 14966 TITLE : (user["TITLE"] || ''), 14967 NAME : (user["NAME"] || ''),
14968 LAST_NAME : (user["LAST_NAME"] || ''), 14969 SECOND_NAME : (user["SECOND_NAME"] || ''), 14970 LOGIN : (user["LOGIN"] || ''), 14971 NAME_SHORT : user["NAME"] ? user["NAME"].substr(0, 1) + '.' : '', 14972 LAST_NAME_SHORT : user["LAST_NAME"] ? user["LAST_NAME"].substr(0, 1) + '.' : '', 14973 SECOND_NAME_SHORT : user["SECOND_NAME"] ? user["SECOND_NAME"].substr(0, 1) + '.' : '', 14974 EMAIL : (user["EMAIL"] || ''), 14975 ID : (user["ID"] || ''), 14976 NOBR : "", 14977 '/NOBR' : "" 14978 }, result = template; 14979 for (var ii in replacement) 14980 { 14981 if (replacement.hasOwnProperty(ii)) 14982 { 14983 result = result.replace("#" + ii+ "#", replacement[ii]) 14984 } 14985 } 14986 result = result.replace(/([\s]+)/gi, " ").trim(); 14987 if (result == "") 14988 { 14989 result = (login == "Y" ? replacement["LOGIN"] : ""); 14990 result = (result == "" ? "Noname" : result); 14991 } 14992 return result; 14993 }; 14994 14995 BX.getNumMonth = function(month) 14996 { 14997 var wordMonthCut = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']; 14998 var wordMonth = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december']; 14999 15000 var q = month.toUpperCase(); 15001 for (i = 1; i <= 12; i++) 15002 { 15003 if (q == BX.message('MON_'+i).toUpperCase() || q == BX.message('MONTH_'+i).toUpperCase() || q == wordMonthCut[i-1].toUpperCase() || q == wordMonth[i-1].toUpperCase()) 15004 { 15005 return i; 15006 } 15007 } 15008 return month; 15009 }; 15010 15011 BX.parseDate = function(str, bUTC, formatDate, formatDatetime) 15012 { 15013 if (BX.type.isNotEmptyString(str)) 15014 { 15015 if (!formatDate) 15016 formatDate = BX.message('FORMAT_DATE'); 15017 if (!formatDatetime) 15018 formatDatetime = BX.message('FORMAT_DATETIME'); 15019 15020 var regMonths = ''; 15021 for (i = 1; i <= 12; i++) 15022 { 15023 regMonths = regMonths + '|' + BX.message('MON_'+i); 15024 } 15025
15026 var expr = new RegExp('([0-9]+|[a-z]+' + regMonths + ')', 'ig'); 15027 var aDate = str.match(expr), 15028 aFormat = formatDate.match(/(DD|MI|MMMM|MM|M|YYYY)/ig), 15029 i, cnt, 15030 aDateArgs=[], aFormatArgs=[], 15031 aResult={}; 15032 15033 if (!aDate) 15034 return null; 15035 15036 if(aDate.length > aFormat.length) 15037 { 15038 aFormat = formatDatetime.match(/(DD|MI|MMMM|MM|M|YYYY|HH|H|SS|TT|T|GG|G)/ig); 15039 } 15040 15041 for(i = 0, cnt = aDate.length; i < cnt; i++) 15042 { 15043 if(BX.util.trim(aDate[i]) != '') 15044 { 15045 aDateArgs[aDateArgs.length] = aDate[i]; 15046 } 15047 } 15048 15049 for(i = 0, cnt = aFormat.length; i < cnt; i++) 15050 { 15051 if(BX.util.trim(aFormat[i]) != '') 15052 { 15053 aFormatArgs[aFormatArgs.length] = aFormat[i]; 15054 } 15055 } 15056 15057 15058 var m = BX.util.array_search('MMMM', aFormatArgs); 15059 if (m > 0) 15060 { 15061 aDateArgs[m] = BX.getNumMonth(aDateArgs[m]); 15062 aFormatArgs[m] = "MM"; 15063 } 15064 else 15065 { 15066 m = BX.util.array_search('M', aFormatArgs); 15067 if (m > 0) 15068 { 15069 aDateArgs[m] = BX.getNumMonth(aDateArgs[m]); 15070 aFormatArgs[m] = "MM"; 15071 } 15072 } 15073 15074 for(i = 0, cnt = aFormatArgs.length; i < cnt; i++) 15075 { 15076 var k = aFormatArgs[i].toUpperCase(); 15077 aResult[k] = k == 'T' || k == 'TT' ? aDateArgs[i] : parseInt(aDateArgs[i], 10); 15078 } 15079 15080 if(aResult['DD'] > 0 && aResult['MM'] > 0 && aResult['YYYY'] > 0) 15081 { 15082 var d = new Date(); 15083 15084 if(bUTC) 15085 { 15086 d.setUTCDate(1); 15087 d.setUTCFullYear(aResult['YYYY']); 15088 d.setUTCMonth(aResult['MM'] - 1); 15089 d.setUTCDate(aResult['DD']); 15090 d.setUTCHours(0, 0, 0, 0); 15091 } 15092 else 15093 { 15094 d.setDate(1); 15095 d.setFullYear(aResult['YYYY']); 15096 d.setMonth(aResult['MM'] - 1); 15097 d.setDate(aResult['DD']); 15098 d.setHours(0, 0, 0, 0); 15099 } 15100 15101 if( 15102 (!isNaN(aResult['HH']) || !isNaN(aResult['GG']) || !isNaN(aResult['H']) || !isNaN(aResult['G'])) 15103 && !isNaN(aResult['MI']) 15104 ) 15105 { 15106 if (!isNaN(aResult['H']) || !isNaN(aResult['G'])) 15107 { 15108 var bPM = (aResult['T']||aResult['TT']||'am').toUpperCase()=='PM'; 15109 var h = parseInt(aResult['H']||aResult['G']||0, 10); 15110 if(bPM) 15111 { 15112 aResult['HH'] = h + (h == 12 ? 0 : 12); 15113 } 15114 else 15115 { 15116 aResult['HH'] = h < 12 ? h : 0; 15117 } 15118 } 15119 else 15120 { 15121 aResult['HH'] = parseInt(aResult['HH']||aResult['GG']||0, 10); 15122 } 15123 15124 if (isNaN(aResult['SS'])) 15125 aResult['SS'] = 0; 15126 15127 if(bUTC) 15128 { 15129 d.setUTCHours(aResult['HH'], aResult['MI'], aResult['SS']); 15130 } 15131 else 15132 { 15133 d.setHours(aResult['HH'], aResult['MI'], aResult['SS']); 15134 } 15135 } 15136 15137 return d; 15138 } 15139 } 15140 15141 return null; 15142 }; 15143 15144 BX.selectUtils = 15145 { 15146 addNewOption: function(oSelect, opt_value, opt_name, do_sort, check_unique) 15147 { 15148 oSelect = BX(oSelect); 15149 if(oSelect) 15150 { 15151 var n = oSelect.length; 15152 if(check_unique !== false) 15153 { 15154 for(var i=0;i<n;i++) 15155 { 15156 if(oSelect[i].value==opt_value) 15157 { 15158 return; 15159 } 15160 } 15161 } 15162 15163 oSelect.options[n] = new Option(opt_name, opt_value, false, false); 15164 } 15165 15166 if(do_sort === true) 15167 { 15168 this.sortSelect(oSelect); 15169 } 15170 }, 15171 15172 deleteOption: function(oSelect, opt_value) 15173 { 15174 oSelect = BX(oSelect); 15175 if(oSelect) 15176 { 15177 for(var i=0;i<oSelect.length;i++) 15178 { 15179 if(oSelect[i].value==opt_value) 15180 { 15181 oSelect.remove(i); 15182 break; 15183 } 15184 } 15185 } 15186 }, 15187 15188 deleteSelectedOptions: function(oSelect) 15189 { 15190 oSelect = BX(oSelect); 15191 if(oSelect) 15192 { 15193 var i=0; 15194 while(i<oSelect.length) 15195 { 15196 if(oSelect[i].selected) 15197 { 15198 oSelect[i].selected=false; 15199 oSelect.remove(i); 15200 } 15201 else 15202 { 15203 i++; 15204 } 15205 } 15206 } 15207 }, 15208 15209 deleteAllOptions: function(oSelect) 15210 { 15211 oSelect = BX(oSelect); 15212 if(oSelect) 15213 { 15214 for(var i=oSelect.length-1; i>=0; i--) 15215 { 15216 oSelect.remove(i); 15217 } 15218 } 15219 }, 15220 15221 optionCompare: function(record1, record2) 15222 { 15223 var value1 = record1.optText.toLowerCase(); 15224 var value2 = record2.optText.toLowerCase(); 15225 if (value1 > value2) return(1); 15226 if (value1 < value2) return(-1); 15227 return(0); 15228 }, 15229 15230 sortSelect: function(oSelect) 15231 { 15232 oSelect = BX(oSelect); 15233 if(oSelect) 15234 { 15235 var myOptions = []; 15236 var n = oSelect.options.length; 15237 var i; 15238 for (i=0;i<n;i++) 15239 { 15240 myOptions[i] = { 15241 optText:oSelect[i].text, 15242 optValue:oSelect[i].value 15243 }; 15244 } 15245 myOptions.sort(this.optionCompare); 15246 oSelect.length=0; 15247 n = myOptions.length; 15248 for(i=0;i<n;i++) 15249 { 15250 oSelect[i] = new Option(myOptions[i].optText, myOptions[i].optValue, false, false); 15251 } 15252 } 15253 }, 15254 15255 selectAllOptions: function(oSelect) 15256 { 15257 oSelect = BX(oSelect); 15258 if(oSelect) 15259 { 15260 var n = oSelect.length; 15261 for(var i=0;i<n;i++) 15262 { 15263 oSelect[i].selected=true; 15264 } 15265 } 15266 }, 15267 15268 selectOption: function(oSelect, opt_value) 15269 { 15270 oSelect = BX(oSelect); 15271 if(oSelect) 15272 { 15273 var n = oSelect.length; 15274 for(var i=0;i<n;i++) 15275 { 15276 oSelect[i].selected = (oSelect[i].value == opt_value); 15277 } 15278 } 15279 }, 15280 15281 addSelectedOptions: function(oSelect, to_select_id, check_unique, do_sort) 15282 { 15283 oSelect = BX(oSelect); 15284 if(!oSelect) 15285 return; 15286 var n = oSelect.length; 15287 for(var i=0; i<n; i++) 15288 if(oSelect[i].selected) 15289 this.addNewOption(to_select_id, oSelect[i].value, oSelect[i].text, do_sort, check_unique); 15290 }, 15291 15292 moveOptionsUp: function(oSelect) 15293 { 15294 oSelect = BX(oSelect); 15295 if(!oSelect) 15296 return; 15297 var n = oSelect.length; 15298 for(var i=0; i<n; i++) 15299 { 15300 if(oSelect[i].selected && i>0 && oSelect[i-1].selected == false) 15301 { 15302 var option = new Option(oSelect[i].text, oSelect[i].value); 15303 oSelect[i] = new Option(oSelect[i-1].text, oSelect[i-1].value); 15304 oSelect[i].selected = false;
15305 oSelect[i-1] = option; 15306 oSelect[i-1].selected = true; 15307 } 15308 } 15309 }, 15310 15311 moveOptionsDown: function(oSelect) 15312 { 15313 oSelect = BX(oSelect); 15314 if(!oSelect) 15315 return; 15316 var n = oSelect.length; 15317 for(var i=n-1; i>=0; i--) 15318 { 15319 if(oSelect[i].selected && i<n-1 && oSelect[i+1].selected == false) 15320 { 15321 var option = new Option(oSelect[i].text, oSelect[i].value); 15322 oSelect[i] = new Option(oSelect[i+1].text, oSelect[i+1].value); 15323 oSelect[i].selected = false; 15324 oSelect[i+1] = option; 15325 oSelect[i+1].selected = true; 15326 } 15327 } 15328 } 15329 }; 15330 15331 BX.getEventTarget = function(e) 15332 { 15333 if(e.target) 15334 { 15335 return e.target; 15336 } 15337 else if(e.srcElement) 15338 { 15339 return e.srcElement; 15340 } 15341 return null; 15342 }; 15343 15344 /******* HINT ***************/ 15345// if function has 2 params - the 2nd one is hint html. otherwise hint_html is third and hint_title - 2nd; 15346// '<div onmouseover="BX.hint(this, 'This is <b>Hint</b>')"'>; 15347// BX.hint(el, 'This is <b>Hint</b>') - this won't work, use constructor 15348 BX.hint = function(el, hint_title, hint_html, hint_id) 15349 { 15350 if (null == hint_html) 15351 { 15352 hint_html = hint_title; 15353 hint_title = ''; 15354 } 15355 15356 if (null == el.BXHINT) 15357 { 15358 el.BXHINT = new BX.CHint({ 15359 parent: el, hint: hint_html, title: hint_title, id: hint_id 15360 }); 15361 el.BXHINT.Show(); 15362 } 15363 }; 15364 15365 BX.hint_replace = function(el, hint_title, hint_html) 15366 { 15367 if (null == hint_html) 15368 { 15369 hint_html = hint_title; 15370 hint_title = ''; 15371 } 15372 15373 if (!el || !el.parentNode || !hint_html) 15374 return null; 15375 15376 var obHint = new BX.CHint({ 15377 hint: hint_html, 15378 title: hint_title 15379 }); 15380 15381 obHint.CreateParent(); 15382 15383 el.parentNode.insertBefore(obHint.PARENT, el); 15384 el.parentNode.removeChild(el); 15385 15386 obHint.PARENT.style.marginLeft = '5px'; 15387 15388 return el; 15389 }; 15390 15391 BX.CHint = function(params) 15392 { 15393 if (BX.CHint.cssLoaded === false) 15394 { 15395 BX.load(['/bitrix/js/main/core/css/core_hint.css']); 15396 BX.CHint.cssLoaded = true; 15397 } 15398 15399 this.PARENT = BX(params.parent); 15400 15401 this.HINT = params.hint; 15402 this.HINT_TITLE = params.title; 15403 15404 this.PARAMS = {}; 15405 for (var i in this.defaultSettings) 15406 { 15407 if (null == params[i]) 15408 this.PARAMS[i] = this.defaultSettings[i]; 15409 else 15410 this.PARAMS[i] = params[i]; 15411 } 15412 15413 if (null != params.id) 15414 this.ID = params.id; 15415 15416 this.timer = null; 15417 this.bInited = false; 15418 this.msover = true; 15419 15420 if (this.PARAMS.showOnce) 15421 { 15422 this.__show(); 15423 this.msover = false; 15424 this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout); 15425 } 15426 else if (this.PARENT) 15427 { 15428 BX.bind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 15429 BX.bind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 15430 } 15431 }; 15432 15433 BX.CHint.cssLoaded = false; 15434 15435 BX.CHint.openHints = new Set(); 15436 15437 BX.CHint.globalDisabled = false; 15438 15439 BX.CHint.handleMenuOpen = function() { 15440 BX.CHint.globalDisabled = true; 15441 15442 BX.CHint.openHints.forEach(function(hint) { 15443 hint.__hide_immediately(); 15444 }); 15445 }; 15446 15447 BX.CHint.handleMenuClose = function() { 15448 BX.CHint.globalDisabled = false; 15449 }; 15450 15451 BX.addCustomEvent('onMenuOpen', BX.CHint.handleMenuOpen); 15452 BX.addCustomEvent('onMenuClose', BX.CHint.handleMenuClose); 15453 15454 BX.CHint.prototype.defaultSettings = { 15455 show_timeout: 1000, 15456 hide_timeout: 500, 15457 dx: 2, 15458 showOnce: false, 15459 preventHide: true, 15460 min_width: 250 15461 }; 15462 15463 BX.CHint.prototype.CreateParent = function(element, params) 15464 { 15465 if (this.PARENT) 15466 { 15467 BX.unbind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 15468 BX.unbind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 15469 } 15470 15471 if (!params) params = {}; 15472 var type = 'icon'; 15473 15474 if (params.type && (params.type == "link" || params.type == "icon")) 15475 type = params.type; 15476 15477 if (element) 15478 type = "element"; 15479 15480 if (type == "icon") 15481 { 15482 element = BX.create('IMG', { 15483 props: { 15484 src: params.iconSrc 15485 ? params.iconSrc 15486 : "/bitrix/js/main/core/images/hint.gif" 15487 } 15488 }); 15489 } 15490 else if (type == "link") 15491 { 15492 element = BX.create("A", { 15493 props: {href: 'javascript:void(0)'}, 15494 html: '[?]' 15495 }); 15496 } 15497 15498 this.PARENT = element; 15499 15500 BX.bind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 15501 BX.bind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 15502 15503 return this.PARENT; 15504 }; 15505 15506 BX.CHint.prototype.Show = function() 15507 { 15508 this.msover = true; 15509 15510 if (null != this.timer) 15511 clearTimeout(this.timer); 15512 15513 this.timer = setTimeout(BX.proxy(this.__show, this), this.PARAMS.show_timeout); 15514 }; 15515 15516 BX.CHint.prototype.Hide = function() 15517 { 15518 this.msover = false;
15519 15520 if (null != this.timer) 15521 clearTimeout(this.timer); 15522 15523 this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout); 15524 }; 15525 15526 BX.CHint.prototype.__show = function() 15527 { 15528 if (!this.msover || this.disabled || BX.CHint.globalDisabled) return; 15529 if (!this.bInited) this.Init(); 15530 15531 if (this.prepareAdjustPos()) 15532 { 15533 this.DIV.style.display = 'block'; 15534 BX.ZIndexManager.bringToFront(this.DIV); 15535 15536 this.adjustPos(); 15537 15538 BX.CHint.openHints.add(this); 15539 15540 BX.bind(window, 'scroll', BX.proxy(this.__onscroll, this)); 15541 15542 if (this.PARAMS.showOnce) 15543 { 15544 this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout); 15545 } 15546 } 15547 }; 15548 15549 BX.CHint.prototype.__onscroll = function() 15550 { 15551 if (!BX.admin || !BX.admin.panel || !BX.admin.panel.isFixed()) return; 15552 15553 if (this.scrollTimer) clearTimeout(this.scrollTimer); 15554 15555 this.DIV.style.display = 'none'; 15556 this.scrollTimer = setTimeout(BX.proxy(this.Reopen, this), this.PARAMS.show_timeout); 15557 }; 15558 15559 BX.CHint.prototype.Reopen = function() 15560 { 15561 if (null != this.timer) clearTimeout(this.timer); 15562 this.timer = setTimeout(BX.proxy(this.__show, this), 50); 15563 }; 15564 15565 BX.CHint.prototype.__hide = function() 15566 { 15567 if (this.msover) return; 15568 if (!this.bInited) return; 15569 15570 BX.unbind(window, 'scroll', BX.proxy(this.Reopen, this)); 15571 15572 BX.CHint.openHints.delete(this); 15573 15574 if (this.PARAMS.showOnce) 15575 { 15576 this.Destroy(); 15577 } 15578 else 15579 { 15580 this.DIV.style.display = 'none'; 15581 } 15582 }; 15583 15584 BX.CHint.prototype.__hide_immediately = function() 15585 { 15586 this.msover = false; 15587 this.__hide(); 15588 }; 15589 15590 BX.CHint.prototype.Init = function() 15591 { 15592 this.DIV = document.body.appendChild(BX.create('DIV', { 15593 props: {className: 'bx-panel-tooltip'}, 15594 style: { 15595 display: 'none', 15596 position: 'absolute', 15597 visibility: 'hidden' 15598 }, 15599 children: [ 15600 (this.CONTENT = BX.create('DIV', { 15601 props: {className: 'bx-panel-tooltip-content'}, 15602 children: [ 15603 BX.create('DIV', { 15604 props: {className: 'bx-panel-tooltip-underlay'}, 15605 children: [ 15606 BX.create('DIV', {props: {className: 'bx-panel-tooltip-underlay-bg'}}) 15607 ] 15608 }) 15609 ] 15610 })) 15611 ] 15612 })); 15613 15614 BX.ZIndexManager.register(this.DIV); 15615 15616 if (this.ID) 15617 { 15618 this.CONTENT.insertBefore(BX.create('A', { 15619 attrs: {href: 'javascript:void(0)'}, 15620 props: {className: 'bx-panel-tooltip-close'}, 15621 events: {click: BX.delegate(this.Close, this)} 15622 }), this.CONTENT.firstChild); 15623 } 15624 15625 if (this.HINT_TITLE) 15626 { 15627 this.CONTENT.appendChild( 15628 BX.create('DIV', { 15629 props: {className: 'bx-panel-tooltip-title'}, 15630 text: this.HINT_TITLE 15631 }) 15632 ); 15633 } 15634 15635 if (this.HINT) 15636 { 15637 this.CONTENT_TEXT = this.CONTENT.appendChild(BX.create('DIV', {props: {className: 'bx-panel-tooltip-text'}})).appendChild(BX.create('SPAN', {html: this.HINT})); 15638 } 15639 15640 if (this.PARAMS.preventHide) 15641 { 15642 BX.bind(this.DIV, 'mouseout', BX.proxy(this.Hide, this)); 15643 BX.bind(this.DIV, 'mouseover', BX.proxy(this.Show, this)); 15644 } 15645 15646 this.bInited = true; 15647 }; 15648 15649 BX.CHint.prototype.setContent = function(content) 15650 { 15651 this.HINT = content; 15652 15653 if (this.CONTENT_TEXT) 15654 this.CONTENT_TEXT.innerHTML = this.HINT; 15655 else 15656 this.CONTENT_TEXT = this.CONTENT.appendChild(BX.create('DIV', {props: {className: 'bx-panel-tooltip-text'}})).appendChild(BX.create('SPAN', {html: this.HINT})); 15657 }; 15658 15659 BX.CHint.prototype.prepareAdjustPos = function() 15660 { 15661 this._wnd = {scrollPos: BX.GetWindowScrollPos(),scrollSize:BX.GetWindowScrollSize()}; 15662 return BX.style(this.PARENT, 'display') != 'none'; 15663 }; 15664 15665 BX.CHint.prototype.getAdjustPos = function() 15666 { 15667 var res = {}, pos = BX.pos(this.PARENT), min_top = 0; 15668 15669 res.top = pos.bottom + this.PARAMS.dx; 15670 15671 if (BX.admin && BX.admin.panel.DIV) 15672 { 15673 min_top = BX.admin.panel.DIV.offsetHeight + this.PARAMS.dx; 15674 15675 if (BX.admin.panel.isFixed()) 15676 { 15677 min_top += this._wnd.scrollPos.scrollTop; 15678 } 15679 } 15680 15681 if (res.top < min_top) 15682 res.top = min_top; 15683 else 15684 { 15685 if (res.top + this.DIV.offsetHeight > this._wnd.scrollSize.scrollHeight) 15686 res.top = pos.top - this.PARAMS.dx - this.DIV.offsetHeight; 15687 } 15688 15689 res.left = pos.left; 15690 if (pos.left < this.PARAMS.dx) 15691 pos.left = this.PARAMS.dx; 15692 else 15693 { 15694 var floatWidth = this.DIV.offsetWidth; 15695 15696 var max_left = this._wnd.scrollSize.scrollWidth - floatWidth - this.PARAMS.dx; 15697 15698 if (res.left > max_left) 15699 res.left = max_left; 15700 } 15701 15702 return res; 15703 }; 15704 15705 BX.CHint.prototype.adjustWidth = function() 15706 { 15707 if (this.bWidthAdjusted) return; 15708 15709 var w = this.DIV.offsetWidth, h = this.DIV.offsetHeight; 15710 15711 if (w > this.PARAMS.min_width) 15712 w = Math.round(Math.sqrt(1.618*w*h)); 15713 15714 if (w < this.PARAMS.min_width) 15715 w = this.PARAMS.min_width; 15716 15717 this.DIV.style.width = w + "px"; 15718 15719 if (this._adjustWidthInt) 15720 clearInterval(this._adjustWidthInt); 15721 this._adjustWidthInt = setInterval(BX.delegate(this._adjustWidthInterval, this), 5); 15722 15723 this.bWidthAdjusted = true; 15724 }; 15725 15726 BX.CHint.prototype._adjustWidthInterval = function() 15727 { 15728 if (!this.DIV || this.DIV.style.display == 'none') 15729 clearInterval(this._adjustWidthInt); 15730 15731 var
15732 dW = 20, 15733 maxWidth = 1500, 15734 w = this.DIV.offsetWidth, 15735 w1 = this.CONTENT_TEXT.offsetWidth; 15736 15737 if (w > 0 && w1 > 0 && w - w1 < dW && w < maxWidth) 15738 { 15739 this.DIV.style.width = (w + dW) + "px"; 15740 return; 15741 } 15742 15743 clearInterval(this._adjustWidthInt); 15744 }; 15745 15746 BX.CHint.prototype.adjustPos = function() 15747 { 15748 this.adjustWidth(); 15749 15750 var pos = this.getAdjustPos(); 15751 15752 this.DIV.style.top = pos.top + 'px'; 15753 this.DIV.style.left = pos.left + 'px'; 15754 }; 15755 15756 BX.CHint.prototype.Close = function() 15757 { 15758 if (this.ID && BX.WindowManager) 15759 BX.WindowManager.saveWindowOptions(this.ID, {display: 'off'}); 15760 this.__hide_immediately(); 15761 this.Destroy(); 15762 }; 15763 15764 BX.CHint.prototype.Destroy = function() 15765 { 15766 if (this.PARENT) 15767 { 15768 BX.unbind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 15769 BX.unbind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 15770 } 15771 15772 if (this.DIV) 15773 { 15774 BX.unbind(this.DIV, 'mouseover', BX.proxy(this.Show, this)); 15775 BX.unbind(this.DIV, 'mouseout', BX.proxy(this.Hide, this)); 15776 15777 BX.ZIndexManager.unregister(this.DIV); 15778 15779 BX.cleanNode(this.DIV, true); 15780 } 15781 }; 15782 15783 BX.CHint.prototype.enable = function(){this.disabled = false;}; 15784 BX.CHint.prototype.disable = function(){this.__hide_immediately(); this.disabled = true;}; 15785 15786 15787 function _adjustWait() 15788 { 15789 if (!this.bxmsg) return; 15790 15791 var arContainerPos = BX.pos(this), 15792 div_top = arContainerPos.top; 15793 15794 if (div_top < BX.GetDocElement().scrollTop) 15795 div_top = BX.GetDocElement().scrollTop + 5; 15796 15797 this.bxmsg.style.top = (div_top + 5) + 'px'; 15798 15799 if (this == BX.GetDocElement()) 15800 { 15801 this.bxmsg.style.right = '5px'; 15802 } 15803 else 15804 { 15805 this.bxmsg.style.left = (arContainerPos.right - this.bxmsg.offsetWidth - 5) + 'px'; 15806 } 15807 } 15808 15809 function _processTpl(tplNode, cb, bKillTpl) 15810 { 15811 if (tplNode) 15812 { 15813 if (bKillTpl) 15814 tplNode.parentNode.removeChild(tplNode); 15815 15816 var res = {}, nodes = BX.findChildren(tplNode, {attribute: 'data-role'}, true); 15817 15818 for (var i = 0, l = nodes.length; i < l; i++) 15819 { 15820 res[nodes[i].getAttribute('data-role')] = nodes[i]; 15821 } 15822 15823 cb.apply(tplNode, [res]); 15824 } 15825 } 15826 15827 function _checkNode(obj, params) 15828 { 15829 params = params || {}; 15830 15831 if (BX.type.isFunction(params)) 15832 return params.call(window, obj); 15833 15834 if (!params.allowTextNodes && !BX.type.isElementNode(obj)) 15835 return false; 15836 var i,j,len; 15837 for (i in params) 15838 { 15839 if(params.hasOwnProperty(i)) 15840 { 15841 switch(i) 15842 { 15843 case 'tag': 15844 case 'tagName': 15845 if (BX.type.isString(params[i])) 15846 { 15847 if (obj.tagName.toUpperCase() != params[i].toUpperCase()) 15848 return false; 15849 } 15850 else if (params[i] instanceof RegExp) 15851 { 15852 if (!params[i].test(obj.tagName)) 15853 return false; 15854 } 15855 break; 15856 15857 case 'class': 15858 case 'className': 15859 if (BX.type.isString(params[i])) 15860 { 15861 if (!BX.hasClass(obj, params[i])) 15862 return false; 15863 } 15864 else if (params[i] instanceof RegExp) 15865 { 15866 if (!BX.type.isString(obj.className) || !params[i].test(obj.className)) 15867 return false; 15868 } 15869 break; 15870 15871 case 'attr': 15872 case 'attrs': 15873 case 'attribute': 15874 if (BX.type.isString(params[i])) 15875 { 15876 if (!obj.getAttribute(params[i])) 15877 return false; 15878 } 15879 else if (BX.type.isArray(params[i])) 15880 { 15881 for (j = 0, len = params[i].length; j < len; j++) 15882 { 15883 if (params[i] && !obj.getAttribute(params[i])) 15884 return false; 15885 } 15886 } 15887 else 15888 { 15889 for (j in params[i]) 15890 { 15891 if(params[i].hasOwnProperty(j)) 15892 { 15893 var q = obj.getAttribute(j); 15894 if (params[i][j] instanceof RegExp) 15895 { 15896 if (!BX.type.isString(q) || !params[i][j].test(q)) 15897 { 15898 return false; 15899 } 15900 } 15901 else 15902 { 15903 if (q != '' + params[i][j]) 15904 { 15905 return false; 15906 } 15907 } 15908 } 15909 } 15910 } 15911 break; 15912 15913 case 'property': 15914 case 'props': 15915 if (BX.type.isString(params[i])) 15916 { 15917 if (!obj[params[i]]) 15918 return false; 15919 } 15920 else if (BX.type.isArray(params[i])) 15921 { 15922 for (j = 0, len = params[i].length; j < len; j++) 15923 { 15924 if (params[i] && !obj[params[i]]) 15925 return false;
15926 } 15927 } 15928 else 15929 { 15930 for (j in params[i]) 15931 { 15932 if (BX.type.isString(params[i][j])) 15933 { 15934 if (obj[j] != params[i][j]) 15935 return false; 15936 } 15937 else if (params[i][j] instanceof RegExp) 15938 { 15939 if (!BX.type.isString(obj[j]) || !params[i][j].test(obj[j])) 15940 return false; 15941 } 15942 } 15943 } 15944 break; 15945 15946 case 'callback': 15947 return params[i](obj); 15948 } 15949 } 15950 } 15951 15952 return true; 15953 } 15954 15955 /* garbage collector */ 15956 function Trash() 15957 { 15958 var i,len; 15959 15960 for (i = 0, len = garbageCollectors.length; i<len; i++) 15961 { 15962 try { 15963 garbageCollectors[i].callback.apply(garbageCollectors[i].context || window); 15964 delete garbageCollectors[i]; 15965 garbageCollectors[i] = null; 15966 } catch (e) {} 15967 } 15968 } 15969 15970 if(window.attachEvent) // IE 15971 window.attachEvent("onunload", Trash); 15972 else if(window.addEventListener) // Gecko / W3C 15973 window.addEventListener('unload', Trash, false); 15974 else 15975 window.onunload = Trash; 15976 /* \garbage collector */ 15977 15978// set empty ready handler 15979 BX(BX.DoNothing); 15980 window.BX = BX; 15981 15982 BX.browser.addGlobalClass(); 15983 15984 /* data storage */ 15985 BX.data = function(node, key, value) 15986 { 15987 if(typeof node == 'undefined') 15988 return undefined; 15989 15990 if(typeof key == 'undefined') 15991 return undefined; 15992 15993 if(typeof value != 'undefined') 15994 { 15995 // write to manager 15996 dataStorage.set(node, key, value); 15997 } 15998 else 15999 { 16000 var data; 16001 16002 // from manager 16003 if((data = dataStorage.get(node, key)) != undefined) 16004 { 16005 return data; 16006 } 16007 else 16008 { 16009 // from attribute data-* 16010 if('getAttribute' in node) 16011 { 16012 data = node.getAttribute('data-'+key.toString()); 16013 if(data === null) 16014 { 16015 return undefined; 16016 } 16017 return data; 16018 } 16019 } 16020 16021 return undefined; 16022 } 16023 }; 16024 16025 BX.DataStorage = function() 16026 { 16027 16028 this.keyOffset = 1; 16029 this.data = {}; 16030 this.uniqueTag = 'BX-'+Math.random(); 16031 16032 this.resolve = function(owner, create){ 16033 if(typeof owner[this.uniqueTag] == 'undefined') 16034 if(create) 16035 { 16036 try 16037 { 16038 Object.defineProperty(owner, this.uniqueTag, { 16039 value: this.keyOffset++ 16040 }); 16041 } 16042 catch(e) 16043 { 16044 owner[this.uniqueTag] = this.keyOffset++; 16045 } 16046 } 16047 else 16048 return undefined; 16049 16050 return owner[this.uniqueTag]; 16051 }; 16052 this.get = function(owner, key){ 16053 if((owner != document && !BX.type.isElementNode(owner)) || typeof key == 'undefined') 16054 return undefined; 16055 16056 owner = this.resolve(owner, false); 16057 16058 if(typeof owner == 'undefined' || typeof this.data[owner] == 'undefined') 16059 return undefined; 16060 16061 return this.data[owner][key]; 16062 }; 16063 this.set = function(owner, key, value){ 16064 16065 if((owner != document && !BX.type.isElementNode(owner)) || typeof value == 'undefined') 16066 return; 16067 16068 var o = this.resolve(owner, true); 16069 16070 if(typeof this.data[o] == 'undefined') 16071 this.data[o] = {}; 16072 16073 this.data[o][key] = value; 16074 }; 16075 }; 16076 16077// some internal variables for new logic 16078 var dataStorage = new BX.DataStorage(); // manager which BX.data() uses to keep data 16079})(window.BX); 16080 16081;(function(window) 16082{ 16083 /****************** ATTENTION ******************************* 16084 * Please do not use Bitrix CoreJS in this class. 16085 * This class can be called on page without Bitrix Framework 16086 *************************************************************/ 16087 16088 if (!window.BX) 16089 { 16090 window.BX = {}; 16091 } 16092 16093 var BX = window.BX; 16094 16095 BX.Promise = function(fn, ctx) // fn is future-reserved 16096 { 16097 this.state = null; 16098 this.value = null; 16099 this.reason = null; 16100 this.next = null; 16101 this.ctx = ctx || this; 16102 16103 this.onFulfilled = []; 16104 this.onRejected = []; 16105 }; 16106 BX.Promise.prototype.fulfill = function(value) 16107 { 16108 this.checkState(); 16109 16110 this.value = value; 16111 this.state = true; 16112 this.execute(); 16113 }; 16114 BX.Promise.prototype.reject = function(reason) 16115 { 16116 this.checkState(); 16117 16118 this.reason = reason; 16119 this.state = false; 16120 this.execute(); 16121 }; 16122 BX.Promise.prototype.then = function(onFulfilled, onRejected) 16123 { 16124 if(typeof (onFulfilled) == "function" || onFulfilled instanceof Function) 16125 { 16126 this.onFulfilled.push(onFulfilled); 16127 } 16128 if(typeof (onRejected) == "function" || onRejected instanceof Function) 16129 { 16130 this.onRejected.push(onRejected); 16131 } 16132 16133 if(this.next === null) 16134 { 16135 this.next = new BX.Promise(null, this.ctx); 16136 } 16137 16138 if(this.state !== null) // if promise was already resolved, execute immediately 16139 { 16140 this.execute(); 16141 } 16142 16143 return this.next; 16144 }; 16145 16146 BX.Promise.prototype.catch = function(onRejected) 16147 { 16148 if(typeof (onRejected) == "function" || onRejected instanceof Function) 16149 { 16150 this.onRejected.push(onRejected); 16151 } 16152 16153 if(this.next === null) 16154 { 16155 this.next = new BX.Promise(null, this.ctx); 16156 } 16157 16158 if(this.state !== null) // if promise was already resolved, execute immediately 16159 { 16160 this.execute(); 16161 } 16162 16163 return this.next; 16164 }; 16165 16166 BX.Promise.prototype.setAutoResolve = function(way, ms) 16167 { 16168 this.timer = setTimeout(function(){ 16169 if(this.state === null) 16170 { 16171 this[way ? 'fulfill' : 'reject'](); 16172 } 16173 }.bind(this), ms || 15); 16174 };
16175 BX.Promise.prototype.cancelAutoResolve = function() 16176 { 16177 clearTimeout(this.timer); 16178 }; 16179 /** 16180 * Resolve function. This function allows promise chaining, like ..then().then()... 16181 * Typical usage: 16182 * 16183 * var p = new Promise(); 16184 * 16185 * p.then(function(value){ 16186 * return someValue; // next promise in the chain will be fulfilled with someValue 16187 * }).then(function(value){ 16188 * 16189 * var p1 = new Promise(); 16190 * *** some async code here, that eventually resolves p1 *** 16191 * 16192 * return p1; // chain will resume when p1 resolved (fulfilled or rejected) 16193 * }).then(function(value){ 16194 * 16195 * // you can also do 16196 * var e = new Error(); 16197 * throw e; 16198 * // it will cause next promise to be rejected with e 16199 * 16200 * return someOtherValue; 16201 * }).then(function(value){ 16202 * ... 16203 * }, function(reason){ 16204 * // promise was rejected with reason 16205 * })...; 16206 * 16207 * p.fulfill('let`s start this chain'); 16208 * 16209 * @param x 16210 */ 16211 BX.Promise.prototype.resolve = function(x) 16212 { 16213 var this_ = this; 16214 16215 if(this === x) 16216 { 16217 this.reject(new TypeError('Promise cannot fulfill or reject itself')); // avoid recursion 16218 } 16219 // allow "pausing" promise chaining until promise x is fulfilled or rejected 16220 else if(x && x.toString() === "[object BX.Promise]") 16221 { 16222 x.then(function(value){ 16223 this_.fulfill(value); 16224 }, function(reason){ 16225 this_.reject(reason); 16226 }); 16227 } 16228 else // auto-fulfill this promise 16229 { 16230 this.fulfill(x); 16231 } 16232 }; 16233 16234 BX.Promise.prototype.toString = function() 16235 { 16236 return "[object BX.Promise]"; 16237 }; 16238 16239 BX.Promise.prototype.execute = function() 16240 { 16241 if(this.state === null) 16242 { 16243 //then() must not be called before BX.Promise resolve() happens 16244 return; 16245 } 16246 16247 var value = undefined; 16248 var reason = undefined; 16249 var x = undefined; 16250 var k; 16251 if(this.state === true) // promise was fulfill()-ed 16252 { 16253 if(this.onFulfilled.length) 16254 { 16255 try 16256 { 16257 for(k = 0; k < this.onFulfilled.length; k++) 16258 {
16259 x = this.onFulfilled[k].apply(this.ctx, [this.value]); 16260 if(typeof x != 'undefined') 16261 { 16262 value = x; 16263 } 16264 } 16265 } 16266 catch(e) 16267 { 16268 if('console' in window) 16269 { 16270 console.dir(e); 16271 } 16272 16273 if (typeof BX.debug !== 'undefined') 16274 { 16275 BX.debug(e); 16276 } 16277 16278 reason = e; // reject next 16279 } 16280 } 16281 else 16282 { 16283 value = this.value; // resolve next 16284 } 16285 } 16286 else if(this.state === false) // promise was reject()-ed 16287 { 16288 if(this.onRejected.length) 16289 { 16290 try 16291 { 16292 for(k = 0; k < this.onRejected.length; k++) 16293 { 16294 x = this.onRejected[k].apply(this.ctx, [this.reason]); 16295 if(typeof x != 'undefined') 16296 { 16297 value = x; 16298 } 16299 } 16300 } 16301 catch(e) 16302 { 16303 if('console' in window) 16304 { 16305 console.dir(e); 16306 } 16307 16308 if (typeof BX.debug !== 'undefined') 16309 { 16310 BX.debug(e); 16311 } 16312 16313 reason = e; // reject next 16314 } 16315 } 16316 else 16317 { 16318 reason = this.reason; // reject next 16319 } 16320 } 16321 16322 if(this.next !== null) 16323 { 16324 if(typeof reason != 'undefined') 16325 { 16326 this.next.reject(reason); 16327 } 16328 else if(typeof value != 'undefined') 16329 { 16330 this.next.resolve(value); 16331 } 16332 } 16333 }; 16334 BX.Promise.prototype.checkState = function() 16335 { 16336 if(this.state !== null) 16337 { 16338 throw new Error('You can not do fulfill() or reject() multiple times'); 16339 } 16340 }; 16341})(window); 16342 16343 16344 16345;(function(window){ 16346 16347if (window.BX.ajax) 16348 return; 16349 16350var 16351 BX = window.BX, 16352 16353 tempDefaultConfig = {}, 16354 defaultConfig = { 16355 method: 'GET', // request method: GET|POST 16356 dataType: 'html', // type of data loading: html|json|script 16357 timeout: 0, // request timeout in seconds. 0 for browser-default 16358 async: true, // whether request is asynchronous or not 16359 processData: true, // any data processing is disabled if false, only callback call 16360 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 16361 emulateOnload: true, 16362 skipAuthCheck: false, // whether to check authorization failure (SHOUD be set to true for CORS requests) 16363 start: true, // send request immediately (if false, request can be started manually via XMLHttpRequest object returned) 16364 cache: true, // whether NOT to add random addition to URL 16365 preparePost: true, // whether set Content-Type x-www-form-urlencoded in POST 16366 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'}] 16367 lsTimeout: 30, //local storage data TTL. useless without lsId. 16368 lsForce: false //wheter to force query instead of using localStorage data. useless without lsId. 16369/* 16370other parameters: 16371 url: url to get/post 16372 data: data to post 16373 onsuccess: successful request callback. BX.proxy may be used. 16374 onfailure: request failure callback. BX.proxy may be used. 16375 onprogress: request progress callback. BX.proxy may be used. 16376 16377 lsId: local storage id - for constantly updating queries which can communicate via localStorage. core_ls.js needed 16378 16379any of the default parameters can be overridden. defaults can be changed by BX.ajax.Setup() - for all further requests! 16380*/ 16381 }, 16382 loadedScripts = {}, 16383 loadedScriptsQueue = [], 16384 r = { 16385 'url_utf': /[^\034-\254]+/g, 16386 'script_self': /\/bitrix\/js\/main\/core\/core(_ajax)*.js$/i, 16387 'script_self_window': /\/bitrix\/js\/main\/core\/core_window.js$/i, 16388 'script_self_admin': /\/bitrix\/js\/main\/core\/core_admin.js$/i, 16389 'script_onload': /window.onload/g 16390 }; 16391 16392// low-level method 16393BX.ajax = function(config) 16394{ 16395 var status, data; 16396
16397 if (!config || !config.url || !BX.type.isString(config.url)) 16398 { 16399 return false; 16400 } 16401 16402 for (var i in tempDefaultConfig) 16403 if (typeof (config[i]) == "undefined") config[i] = tempDefaultConfig[i]; 16404 16405 tempDefaultConfig = {}; 16406 16407 for (i in defaultConfig) 16408 if (typeof (config[i]) == "undefined") config[i] = defaultConfig[i]; 16409 16410 config.method = config.method.toUpperCase(); 16411 16412 if (!BX.localStorage) 16413 config.lsId = null; 16414 16415 if (BX.browser.IsIE()) 16416 { 16417 var result = r.url_utf.exec(config.url); 16418 if (result) 16419 { 16420 do 16421 { 16422 config.url = config.url.replace(result, BX.util.urlencode(result)); 16423 result = r.url_utf.exec(config.url); 16424 } while (result); 16425 } 16426 } 16427 16428 if(config.dataType == 'json') 16429 config.emulateOnload = false; 16430 16431 if (!config.cache && config.method == 'GET') 16432 config.url = BX.ajax._uncache(config.url); 16433 16434 if (config.method == 'POST') 16435 { 16436 if (config.preparePost) 16437 { 16438 config.data = BX.ajax.prepareData(config.data); 16439 } 16440 else if (getLastContentTypeHeader(config.headers) === 'application/json') 16441 { 16442 config.data = JSON.stringify(config.data); 16443 } 16444 } 16445 16446 var bXHR = true; 16447 if (config.lsId && !config.lsForce) 16448 { 16449 var v = BX.localStorage.get('ajax-' + config.lsId); 16450 if (v !== null) 16451 { 16452 bXHR = false; 16453 16454 var lsHandler = function(lsData) { 16455 if (lsData.key == 'ajax-' + config.lsId && lsData.value != 'BXAJAXWAIT') 16456 { 16457 var data = lsData.value, 16458 bRemove = !!lsData.oldValue && data == null; 16459 if (!bRemove) 16460 BX.ajax.__run(config, data); 16461 else if (config.onfailure) 16462 config.onfailure("timeout"); 16463 16464 BX.removeCustomEvent('onLocalStorageChange', lsHandler); 16465 } 16466 }; 16467 16468 if (v == 'BXAJAXWAIT') 16469 { 16470 BX.addCustomEvent('onLocalStorageChange', lsHandler); 16471 } 16472 else 16473 { 16474 setTimeout(function() {lsHandler({key: 'ajax-' + config.lsId, value: v})}, 10); 16475 } 16476 } 16477 } 16478 16479 if (bXHR) 16480 { 16481 config.xhr = BX.ajax.xhr(); 16482 if (!config.xhr) return; 16483 16484 if (config.lsId) 16485 { 16486 BX.localStorage.set('ajax-' + config.lsId, 'BXAJAXWAIT', config.lsTimeout); 16487 } 16488 16489 if (BX.Type.isFunction(config.onprogress)) 16490 { 16491 BX.bind(config.xhr, 'progress', config.onprogress); 16492 } 16493 16494 if (BX.Type.isFunction(config.onprogressupload) && config.xhr.upload) 16495 { 16496 BX.bind(config.xhr.upload, 'progress', config.onprogressupload); 16497 } 16498 16499 config.xhr.open(config.method, config.url, config.async); 16500 16501 if (!config.skipBxHeader && !BX.ajax.isCrossDomain(config.url)) 16502 { 16503 config.xhr.setRequestHeader('Bx-ajax', 'true'); 16504 } 16505 16506 if (config.method == 'POST' && config.preparePost) 16507 { 16508 config.xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 16509 } 16510 if (typeof(config.headers) == "object") 16511 { 16512 for (i = 0; i < config.headers.length; i++) 16513 config.xhr.setRequestHeader(config.headers[i].name, config.headers[i].value); 16514 } 16515 16516 var bRequestCompleted = false; 16517 var onreadystatechange = config.xhr.onreadystatechange = function(additional) 16518 { 16519 if (bRequestCompleted) 16520 return; 16521 16522 if (additional === 'timeout') 16523 { 16524 if (config.onfailure) 16525 { 16526 config.onfailure('timeout', '', config); 16527 } 16528 16529 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['timeout', '', config]); 16530 16531 config.xhr.onreadystatechange = BX.DoNothing; 16532 config.xhr.abort(); 16533 16534 if (config.async) 16535 { 16536 config.xhr = null; 16537 } 16538 } 16539 else 16540 { 16541 if (config.xhr.readyState == 4 || additional == 'run') 16542 { 16543 status = BX.ajax.xhrSuccess(config.xhr) ? "success" : "error"; 16544 bRequestCompleted = true; 16545 config.xhr.onreadystatechange = BX.DoNothing; 16546 16547 if (status == 'success') 16548 { 16549 var authHeader = (!!config.skipAuthCheck || BX.ajax.isCrossDomain(config.url)) 16550 ? false 16551 : config.xhr.getResponseHeader('X-Bitrix-Ajax-Status'); 16552 16553 if(!!authHeader && authHeader == 'Authorize') 16554 { 16555 if (config.onfailure) 16556 { 16557 config.onfailure('auth', config.xhr.status, config); 16558 } 16559 16560 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['auth', config.xhr.status, config]); 16561 } 16562 else 16563 { 16564 var data = config.xhr.responseText; 16565 16566 if (config.lsId) 16567 { 16568 BX.localStorage.set('ajax-' + config.lsId, data, config.lsTimeout); 16569 } 16570 16571 BX.ajax.__run(config, data); 16572 } 16573 } 16574 else 16575 { 16576 if (config.onfailure) 16577 { 16578 config.onfailure('status', config.xhr.status, config); 16579 } 16580 16581 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['status', config.xhr.status, config]); 16582 } 16583 16584 if (config.async) 16585 { 16586 config.xhr = null; 16587 } 16588 } 16589 } 16590 }; 16591 16592 if (config.async && config.timeout > 0) 16593 { 16594 setTimeout(function() { 16595 if (config.xhr && !bRequestCompleted) 16596 { 16597 onreadystatechange("timeout"); 16598 } 16599 }, config.timeout * 1000); 16600 } 16601 16602 if (config.start) 16603 {
16604 config.xhr.send(config.data); 16605 16606 if (!config.async) 16607 { 16608 onreadystatechange('run'); 16609 } 16610 } 16611 16612 return config.xhr; 16613 } 16614}; 16615 16616BX.ajax.xhr = function() 16617{ 16618 if (window.XMLHttpRequest) 16619 { 16620 try {return new XMLHttpRequest();} catch(e){} 16621 } 16622 else if (window.ActiveXObject) 16623 { 16624 try { return new window.ActiveXObject("Msxml2.XMLHTTP.6.0"); } 16625 catch(e) {} 16626 try { return new window.ActiveXObject("Msxml2.XMLHTTP.3.0"); } 16627 catch(e) {} 16628 try { return new window.ActiveXObject("Msxml2.XMLHTTP"); } 16629 catch(e) {} 16630 try { return new window.ActiveXObject("Microsoft.XMLHTTP"); } 16631 catch(e) {} 16632 throw new Error("This browser does not support XMLHttpRequest."); 16633 } 16634 16635 return null; 16636}; 16637 16638BX.ajax.isCrossDomain = function(url, location) 16639{ 16640 location = location || window.location; 16641 16642 //Relative URL gets a current protocol 16643 if (url.indexOf("//") === 0) 16644 { 16645 url = location.protocol + url; 16646 } 16647 16648 //Fast check 16649 if (url.indexOf("http") !== 0) 16650 { 16651 return false; 16652 } 16653 16654 var link = window.document.createElement("a"); 16655 link.href = url; 16656 16657 return link.protocol !== location.protocol || 16658 link.hostname !== location.hostname || 16659 BX.ajax.getHostPort(link.protocol, link.host) !== BX.ajax.getHostPort(location.protocol, location.host); 16660}; 16661 16662BX.ajax.getHostPort = function(protocol, host) 16663{ 16664 var match = /:(\d+)$/.exec(host); 16665 if (match) 16666 { 16667 return match[1]; 16668 } 16669 else 16670 { 16671 if (protocol === "http:") 16672 { 16673 return "80"; 16674 } 16675 else if (protocol === "https:") 16676 { 16677 return "443"; 16678 } 16679 } 16680 16681 return ""; 16682}; 16683 16684BX.ajax.__prepareOnload = function(scripts, ajax_session) 16685{ 16686 if (scripts.length > 0) 16687 { 16688 BX.ajax['onload_' + ajax_session] = null; 16689 16690 for (var i=0,len=scripts.length;i<len;i++) 16691 { 16692 if (scripts[i].isInternal) 16693 { 16694 scripts[i].JS = scripts[i].JS.replace(r.script_onload, 'BX.aja
16694x.onload_' + ajax_session); 16695 } 16696 } 16697 } 16698 16699 BX.CaptureEventsGet(); 16700 BX.CaptureEvents(window, 'load'); 16701}; 16702 16703BX.ajax.__runOnload = function(ajax_session) 16704{ 16705 if (null != BX.ajax['onload_' + ajax_session]) 16706 { 16707 BX.ajax['onload_' + ajax_session].apply(window); 16708 BX.ajax['onload_' + ajax_session] = null; 16709 } 16710 16711 var h = BX.CaptureEventsGet(); 16712 16713 if (h) 16714 { 16715 for (var i=0; i<h.length; i++) 16716 h[i].apply(window); 16717 } 16718}; 16719 16720BX.ajax.__run = function(config, data) 16721{ 16722 if (!config.processData) 16723 { 16724 if (config.onsuccess) 16725 { 16726 config.onsuccess(data); 16727 } 16728 16729 BX.onCustomEvent(config.xhr, 'onAjaxSuccess', [data, config]); 16730 } 16731 else 16732 { 16733 data = BX.ajax.processRequestData(data, config); 16734 } 16735}; 16736 16737 16738BX.ajax._onParseJSONFailure = function(data) 16739{ 16740 this.jsonFailure = true; 16741 this.jsonResponse = data; 16742 this.jsonProactive = /^\[WAF\]/.test(data); 16743}; 16744 16745BX.ajax.processRequestData = function(data, config) 16746{ 16747 var result, scripts = [], styles = []; 16748 switch (config.dataType.toUpperCase()) 16749 { 16750 case 'JSON': 16751 16752 var context = config.xhr || {}; 16753 BX.addCustomEvent(context, 'onParseJSONFailure', BX.proxy(BX.ajax._onParseJSONFailure, config)); 16754 result = BX.parseJSON(data, context); 16755 BX.removeCustomEvent(context, 'onParseJSONFailure', BX.proxy(BX.ajax._onParseJSONFailure, config)); 16756 16757 if(!!result && BX.type.isArray(result['bxjs'])) 16758 { 16759 for(var i = 0; i < result['bxjs'].length; i++) 16760 { 16761 if(BX.type.isNotEmptyString(result['bxjs'][i])) 16762 { 16763 scripts.push({ 16764 "isInternal": false, 16765 "JS": result['bxjs'][i], 16766 "bRunFirst": config.scriptsRunFirst 16767 }); 16768 } 16769 else 16770 { 16771 scripts.push(result['bxjs'][i]) 16772 } 16773 } 16774 } 16775 16776 if(!!result && BX.type.isArray(result['bxcss'])) 16777 { 16778 styles = result['bxcss']; 16779 } 16780 16781 break; 16782 case 'SCRIPT': 16783 scripts.push({"isInternal": true, "JS": data, "bRunFirst": config.scriptsRunFirst}); 16784 result = data; 16785 break; 16786 16787 default: // HTML 16788 var ob = BX.processHTML(data, config.scriptsRunFirst); 16789 result = ob.HTML; scripts = ob.SCRIPT; styles = ob.STYLE; 16790 break; 16791 } 16792 16793 if (styles.length > 0) 16794 { 16795 BX.loadCSS(styles); 16796 } 16797 16798 let ajax_session = null; 16799 if (config.emulateOnload) 16800 { 16801 ajax_session = parseInt(Math.random() * 1000000); 16802 BX.ajax.__prepareOnload(scripts, ajax_session); 16803 } 16804 16805 const cb = BX.defer(function() 16806 { 16807 if (config.emulateOnload) 16808 { 16809 BX.ajax.__runOnload(ajax_session); 16810 } 16811 16812 BX.onCustomEvent(config.xhr, 'onAjaxSuccessFinish', [config]); 16813 }); 16814 16815 try 16816 { 16817 if (!!config.jsonFailure) 16818 { 16819 throw {type: 'json_failure', data: config.jsonResponse, bProactive: config.jsonProactive}; 16820 } 16821 16822 config.scripts = scripts; 16823 16824 BX.ajax.processScripts(config.scripts, true); 16825 16826 if (config.onsuccess) 16827 { 16828 config.onsuccess(result); 16829 } 16830 16831 BX.onCustomEvent(config.xhr, 'onAjaxSuccess', [result, config]); 16832 16833 BX.ajax.processScripts(config.scripts, false, cb); 16834 } 16835 catch (e) 16836 { 16837 if (config.onfailure) 16838 config.onfailure("processing", e); 16839 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['processing', e, config]); 16840 } 16841}; 16842 16843BX.ajax.processScripts = function(scripts, bRunFirst, cb) 16844{ 16845 var scriptsExt = [], scriptsInt = ''; 16846 16847 cb = cb || BX.DoNothing; 16848 16849 for (var i = 0, length = scripts.length; i < length; i++) 16850 { 16851 if (typeof bRunFirst != 'undefined' && bRunFirst != !!scripts[i].bRunFirst) 16852 continue; 16853 16854 if (scripts[i].isInternal) 16855 scriptsInt += ';' + scripts[i].JS; 16856 else 16857 scriptsExt.push(scripts[i].JS); 16858 } 16859 16860 scriptsExt = BX.util.array_unique(scriptsExt); 16861 var inlineScripts = scriptsInt.length > 0 ? function() { BX.evalGlobal(scriptsInt); } : BX.DoNothing; 16862 16863 if (scriptsExt.length > 0) 16864 { 16865 BX.load(scriptsExt, function() { 16866 inlineScripts(); 16867 cb(); 16868 }); 16869 } 16870 else 16871 { 16872 inlineScripts(); 16873 cb(); 16874 } 16875}; 16876 16877// TODO: extend this function to use with any data objects or forms 16878BX.ajax.prepareData = function(arData, prefix) 16879{ 16880 var data = ''; 16881 if (BX.type.isString(arData)) 16882 data = arData; 16883 else if (null != arData) 16884 { 16885 for(var i in arData) 16886 { 16887 if (arData.hasOwnProperty(i)) 16888 { 16889 if (data.length > 0) 16890 data += '&'; 16891 var name = BX.util.urlencode(i); 16892 if(prefix) 16893 name = prefix + '[' + name + ']'; 16894 if(typeof arData[i] == 'object') 16895 data += BX.ajax.prepareData(arData[i], name); 16896 else 16897 data += name + '=' + BX.util.urlencode(arData[i]); 16898 } 16899 } 16900 } 16901 return data; 16902}; 16903 16904BX.ajax.xhrSuccess = function(xhr) 16905{ 16906 return (xhr.status >= 200 && xhr.status < 300) || xhr.status === 304 || xhr.status === 1223 || xhr.status === 0; 16907}; 16908 16909BX.ajax.Setup = function(config, bTemp) 16910{ 16911 bTemp = !!bTemp; 16912 16913 for (var i in config) 16914 { 16915 if (bTemp) 16916 tempDefaultConfig[i] = config[i]; 16917 else 16918 defaultConfig[i] = config[i]; 16919 } 16920}; 16921 16922BX.ajax.replaceLocalStorageValue = function(lsId, data, ttl) 16923{ 16924 if (!!BX.localStorage) 16925 BX.localStorage.set('ajax-' + lsId, data, ttl); 16926}; 16927 16928 16929BX.ajax._uncache = function(url) 16930{ 16931 return url + ((url.indexOf('?') !== -1 ? "&" : "?") + '_=' + (new Date()).getTime()); 16932}; 16933 16934/* simple interface */ 16935BX.ajax.get = function(url, data, callback) 16936{ 16937 if (BX.type.isFunction(data)) 16938 { 16939 callback = data; 16940 data = ''; 16941 } 16942
16943 data = BX.ajax.prepareData(data); 16944 16945 if (data) 16946 { 16947 url += (url.indexOf('?') !== -1 ? "&" : "?") + data; 16948 data = ''; 16949 } 16950 16951 return BX.ajax({ 16952 'method': 'GET', 16953 'dataType': 'html', 16954 'url': url, 16955 'data': '', 16956 'onsuccess': callback 16957 }); 16958}; 16959 16960BX.ajax.getCaptcha = function(callback) 16961{ 16962 return BX.ajax.loadJSON('/bitrix/tools/ajax_captcha.php', callback); 16963}; 16964 16965BX.ajax.insertToNode = function(url, node) 16966{ 16967 node = BX(node); 16968 if (!!node) 16969 { 16970 var eventArgs = { cancel: false }; 16971 BX.onCustomEvent('onAjaxInsertToNode', [{ url: url, node: node, eventArgs: eventArgs }]); 16972 if(eventArgs.cancel === true) 16973 { 16974 return; 16975 } 16976 16977 var show = null; 16978 if (!tempDefaultConfig.denyShowWait) 16979 { 16980 show = BX.showWait(node); 16981 delete tempDefaultConfig.denyShowWait; 16982 } 16983 16984 return BX.ajax.get(url, function(data) { 16985 node.innerHTML = data; 16986 BX.closeWait(node, show); 16987 }); 16988 } 16989}; 16990 16991BX.ajax.post = function(url, data, callback) 16992{ 16993 data = BX.ajax.prepareData(data); 16994 16995 return BX.ajax({ 16996 'method': 'POST', 16997 'dataType': 'html', 16998 'url': url, 16999 'data': data, 17000 'onsuccess': callback 17001 }); 17002}; 17003 17004/** 17005 * BX.ajax with BX.Promise 17006 * 17007 * @param config 17008 * @returns {BX.Promise|false} 17009 */ 17010BX.ajax.promise = function(config) 17011{ 17012 var result = new BX.Promise(); 17013 17014 config.onsuccess = function(data) 17015 { 17016 result.fulfill(data); 17017 }; 17018 config.onfailure = function(reason, httpStatus, config) 17019 { 17020 result.reject({ 17021 reason: reason, 17022 data: httpStatus, 17023 ajaxConfig: config, 17024 xhr: config.xhr 17025 }); 17026 }; 17027 17028 var xhr = BX.ajax(config); 17029 if (xhr) 17030 { 17031 if (typeof config.onrequeststart === 'function') 17032 { 17033 config.onrequeststart(xhr); 17034 } 17035 } 17036 else 17037 { 17038 result.reject({ 17039 reason: "init", 17040 data: false 17041 }); 17042 } 17043 17044 return result; 17045}; 17046 17047/* load and execute external file script with onload emulation */ 17048BX.ajax.loadScriptAjax = function(script_src, callback, bPreload) 17049{ 17050 if (BX.type.isArray(script_src)) 17051 { 17052 for (var i=0,len=script_src.length;i<len;i++) 17053 { 17054 BX.ajax.loadScriptAjax(script_src[i], callback, bPreload); 17055 } 17056 } 17057 else 17058 { 17059 var script_src_test = script_src.replace(/\.js\?.*/, '.js'); 17060 17061 if (r.script_self.test(script_src_test)) return; 17062 if (r.script_self_window.test(script_src_test) && BX.CWindow) return; 17063 if (r.script_self_admin.test(script_src_test) && BX.admin) return; 17064 17065 if (typeof loadedScripts[script_src_test] == 'undefined') 17066 { 17067 if (!!bPreload) 17068 { 17069 loadedScripts[script_src_test] = ''; 17070 return BX.loadScript(script_src); 17071 } 17072 else 17073 { 17074 return BX.ajax({ 17075 url: script_src, 17076 method: 'GET', 17077 dataType: 'script', 17078 processData: true, 17079 emulateOnload: false, 17080 scriptsRunFirst: true, 17081 async: false, 17082 start: true, 17083 onsuccess: function(result) { 17084 loadedScripts[script_src_test] = result; 17085 if (callback) 17086 callback(result); 17087 } 17088 }); 17089 } 17090 } 17091 else if (callback) 17092 { 17093 callback(loadedScripts[script_src_test]); 17094 } 17095 } 17096}; 17097 17098/* non-xhr loadings */ 17099BX.ajax.loadJSON = function(url, data, callback, callback_failure) 17100{ 17101 if (BX.type.isFunction(data)) 17102 { 17103 callback_failure = callback; 17104 callback = data; 17105 data = ''; 17106 } 17107 17108 data = BX.ajax.prepareData(data); 17109 17110 if (data) 17111 { 17112 url += (url.indexOf('?') !== -1 ? "&" : "?") + data; 17113 data = ''; 17114 } 17115 17116 return BX.ajax({ 17117 'method': 'GET', 17118 'dataType': 'json', 17119 'url': url, 17120 'onsuccess': callback, 17121 'onfailure': callback_failure 17122 }); 17123}; 17124 17125var getLastContentTypeHeader = function (headers) { 17126 if (!BX.Type.isArray(headers)) 17127 { 17128 return null; 17129 } 17130 var lastHeader = headers 17131 .filter(function (header) { 17132 return header.name === 'Content-Type'; 17133 }) 17134 .pop(); 17135 17136 return lastHeader ? lastHeader.value : null; 17137}; 17138 17139var prepareAjaxGetParameters = function(config) 17140{ 17141 var getParameters = config.getParameters || {}; 17142 if (BX.type.isNotEmptyString(config.analyticsLabel)) 17143 { 17144 getParameters.analyticsLabel = config.analyticsLabel; 17145 } 17146 else if (BX.type.isNotEmptyObject(config.analyticsLabel)) 17147 { 17148 getParameters.analyticsLabel = config.analyticsLabel; 17149 } 17150 if (typeof config.mode !== 'undefined') 17151 { 17152 getParameters.mode = config.mode; 17153 } 17154 if (config.navigation) 17155 { 17156 if(config.navigation.page) 17157 { 17158 getParameters.nav = 'page-' + config.navigation.page; 17159 } 17160 if(config.navigation.size) 17161 { 17162 if(getParameters.nav) 17163 { 17164 getParameters.nav += '-'; 17165 } 17166 else 17167 {
17168 getParameters.nav = ''; 17169 } 17170 getParameters.nav += 'size-' + config.navigation.size; 17171 } 17172 } 17173 17174 return getParameters; 17175}; 17176 17177var prepareAjaxConfig = function(config) 17178{ 17179 config = BX.type.isPlainObject(config) ? config : {}; 17180 17181 config.headers = config.headers || []; 17182 config.headers.push({name: 'X-Bitrix-Csrf-Token', value: BX.bitrix_sessid()}); 17183 if (BX.message.SITE_ID) 17184 { 17185 config.headers.push({name: 'X-Bitrix-Site-Id', value: BX.message.SITE_ID}); 17186 } 17187 17188 if (typeof config.json !== 'undefined') 17189 { 17190 if (!BX.type.isPlainObject(config.json)) 17191 { 17192 throw new Error('Wrong `config.json`, plain object expected.') 17193 } 17194 17195 config.headers.push({name: 'Content-Type', value: 'application/json'}); 17196 config.data = config.json; 17197 config.preparePost = false; 17198 } 17199 else if (config.data instanceof FormData) 17200 { 17201 config.preparePost = false; 17202 if (typeof config.signedParameters !== 'undefined') 17203 { 17204 config.data.append('signedParameters', config.signedParameters); 17205 } 17206 } 17207 else if (BX.type.isPlainObject(config.data) || BX.Type.isNil(config.data)) 17208 { 17209 config.data = BX.type.isPlainObject(config.data) ? config.data : {}; 17210 if (typeof config.signedParameters !== 'undefined') 17211 { 17212 config.data.signedParameters = config.signedParameters; 17213 } 17214 } 17215 17216 if (!config.method) 17217 { 17218 config.method = 'POST' 17219 } 17220 17221 return config; 17222}; 17223 17224var buildAjaxPromiseToRestoreCsrf = function(config, withoutRestoringCsrf) 17225{ 17226 withoutRestoringCsrf = withoutRestoringCsrf || false; 17227 var originalConfig = BX.clone(config); 17228 var request = null; 17229 17230 var onrequeststart = config.onrequeststart; 17231 config.onrequeststart = function(xhr) { 17232 request = xhr; 17233 if (BX.type.isFunction(onrequeststart)) 17234 { 17235 onrequeststart(xhr); 17236 } 17237 }; 17238 var onrequeststartOrig = originalConfig.onrequeststart; 17239 originalConfig.onrequeststart = function(xhr) { 17240 request = xhr; 17241 if (BX.type.isFunction(onrequeststartOrig)) 17242 { 17243 onrequeststartOrig(xhr); 17244 } 17245 }; 17246 17247 var promise = BX.ajax.promise(config); 17248 17249 return promise.then(function(response) { 17250 if (!withoutRestoringCsrf && BX.type.isPlainObject(response) && BX.type.isArray(response.errors)) 17251 { 17252 var csrfProblem = false; 17253 response.errors.forEach(function(error) { 17254 if (error.code === 'invalid_csrf' && error.customData.csrf) 17255 { 17256 BX.message({'bitrix_sessid': error.customData.csrf}); 17257 17258 originalConfig.headers = originalConfig.headers || []; 17259 originalConfig.headers = originalConfig.headers.filter(function(header) { 17260 return header && header.name !== 'X-Bitrix-Csrf-Token'; 17261 }); 17262 originalConfig.headers.push({name: 'X-Bitrix-Csrf-Token', value: BX.bitrix_sessid()}); 17263 17264 csrfProblem = true; 17265 } 17266 }); 17267 17268 if (csrfProblem) 17269 { 17270 return buildAjaxPromiseToRestoreCsrf(originalConfig, true); 17271 } 17272 } 17273 17274 if (!BX.type.isPlainObject(response) || response.status !== 'success') 17275 { 17276 var errorPromise = new BX.Promise(); 17277 errorPromise.reject(response); 17278 17279 return errorPromise; 17280 } 17281 17282 return response; 17283 }).catch(function(data) { 17284 var ajaxReject = new BX.Promise(); 17285 17286 var originalJsonResponse; 17287 if (BX.type.isPlainObject(data) && data.xhr && data.xhr.responseText) 17288 { 17289 try 17290 { 17291 originalJsonResponse = JSON.parse(data.xhr.responseText); 17292 data = originalJsonResponse; 17293 } 17294 catch (err) 17295 {} 17296 } 17297 17298 if (BX.type.isPlainObject(data) && data.status && data.hasOwnProperty('data')) 17299 { 17300 ajaxReject.reject(data); 17301 } 17302 else 17303 { 17304 ajaxReject.reject({ 17305 status: 'error', 17306 data: { 17307 ajaxRejectData: data 17308 }, 17309 errors: [ 17310 { 17311 code: 'NETWORK_ERROR', 17312 message: 'Network error' 17313 } 17314 ] 17315 }); 17316 } 17317 17318 return ajaxReject; 17319 }).then(function(response){ 17320 17321 var assetsLoaded = new BX.Promise(); 17322 17323 var headers = request.getAllResponseHeaders().trim().split(/[\r\n]+/); 17324 var headerMap = {}; 17325 headers.forEach(function (line) { 17326 var parts = line.split(': '); 17327 var header = parts.shift().toLowerCase(); 17328 headerMap[header] = parts.join(': '); 17329 }); 17330 17331 if (!headerMap['x-process-assets']) 17332 { 17333 assetsLoaded.fulfill(response); 17334 17335 return assetsLoaded; 17336 } 17337 17338 var assets = BX.prop.getObject(BX.prop.getObject(response, "data", {}), "assets", {}); 17339 var promise = new Promise(function(resolve, reject) { 17340 var css = BX.prop.getArray(assets, "css", []); 17341 BX.load(css, function(){ 17342 BX.loadScript( 17343 BX.prop.getArray(assets, "js", []), 17344 resolve 17345 ); 17346 }); 17347 }); 17348 promise.then(function(){ 17349 var strings = BX.prop.getArray(assets, "string", []); 17350 var stringAsset = strings.join('\n'); 17351 BX.html(document.head, stringAsset, { useAdjacentHTML: true }).then(function(){ 17352 assetsLoaded.fulfill(response); 17353 }); 17354 }); 17355 17356 return assetsLoaded; 17357 }); 17358}; 17359 17360/** 17361 * 17362 * @param {string} action 17363 * @param {Object} config 17364 * @param {?string|?Object} [config.analyticsLabel] 17365 * @param {string} [config.method='POST'] 17366 * @param {Object} [config.data] 17367 * @param {?Object} [config.getParameters] 17368 * @param {?Object} [config.headers] 17369 * @param {?Object} [config.timeout] 17370 * @param {Object} [config.navigation] 17371 * @param {number} [config.navigation.page] 17372 */ 17373BX.ajax.runAction = function(action, config) 17374{ 17375 config = prepareAjaxConfig(config); 17376 var getParameters = prepareAjaxGetParameters(config); 17377 getParameters.action = action; 17378
17379 var url = '/bitrix/services/main/ajax.php?' + BX.ajax.prepareData(getParameters); 17380 return buildAjaxPromiseToRestoreCsrf({ 17381 method: config.method, 17382 dataType: 'json', 17383 url: url, 17384 data: config.data, 17385 timeout: config.timeout, 17386 preparePost: config.preparePost, 17387 headers: config.headers, 17388 onrequeststart: config.onrequeststart, 17389 onprogress: config.onprogress, 17390 onprogressupload: config.onprogressupload 17391 }); 17392}; 17393 17394/** 17395 * 17396 * @param {string} component 17397 * @param {string} action 17398 * @param {Object} config 17399 * @param {?string|?Object} [config.analyticsLabel] 17400 * @param {?string} [config.signedParameters] 17401 * @param {string} [config.method='POST'] 17402 * @param {string} [config.mode='ajax'] Ajax or class. 17403 * @param {Object} [config.data] 17404 * @param {?Object} [config.getParameters] 17405 * @param {?array} [config.headers] 17406 * @param {?number} [config.timeout] 17407 * @param {Object} [config.navigation] 17408 */ 17409BX.ajax.runComponentAction = function (component, action, config) 17410{ 17411 config = prepareAjaxConfig(config); 17412 config.mode = config.mode || 'ajax'; 17413 17414 var getParameters = prepareAjaxGetParameters(config); 17415 getParameters.c = component; 17416 getParameters.action = action; 17417
17418 var url = '/bitrix/services/main/ajax.php?' + BX.ajax.prepareData(getParameters); 17419 17420 return buildAjaxPromiseToRestoreCsrf({ 17421 method: config.method, 17422 dataType: 'json', 17423 url: url, 17424 data: config.data, 17425 timeout: config.timeout, 17426 preparePost: config.preparePost, 17427 headers: config.headers, 17428 onrequeststart: (config.onrequeststart ? config.onrequeststart : null), 17429 onprogress: config.onprogress, 17430 onprogressupload: config.onprogressupload 17431 }); 17432}; 17433 17434/* 17435arObs = [{ 17436 url: url, 17437 type: html|script|json|css, 17438 callback: function 17439}] 17440*/ 17441BX.ajax.load = function(arObs, callback) 17442{ 17443 if (!BX.type.isArray(arObs)) 17444 arObs = [arObs]; 17445 17446 var cnt = 0; 17447 17448 if (!BX.type.isFunction(callback)) 17449 callback = BX.DoNothing; 17450 17451 var handler = function(data) 17452 { 17453 if (BX.type.isFunction(this.callback)) 17454 this.callback(data); 17455 17456 if (++cnt >= len) 17457 callback(); 17458 }; 17459 17460 for (var i = 0, len = arObs.length; i<len; i++) 17461 { 17462 switch(arObs[i].type.toUpperCase()) 17463 { 17464 case 'SCRIPT': 17465 BX.loadScript([arObs[i].url], BX.proxy(handler, arObs[i])); 17466 break; 17467 case 'CSS': 17468 BX.loadCSS([arObs[i].url]); 17469 17470 if (++cnt >= len) 17471 callback(); 17472 break; 17473 case 'JSON': 17474 BX.ajax.loadJSON(arObs[i].url, BX.proxy(handler, arObs[i])); 17475 break; 17476 17477 default: 17478 BX.ajax.get(arObs[i].url, '', BX.proxy(handler, arObs[i])); 17479 break; 17480 } 17481 } 17482}; 17483 17484/* ajax form sending */ 17485BX.ajax.submit = function(obForm, callback) 17486{ 17487 if (!obForm.target) 17488 { 17489 if (null == obForm.BXFormTarget) 17490 { 17491 var frame_name = 'formTarget_' + Math.random(); 17492 obForm.BXFormTarget = document.body.appendChild(BX.create('IFRAME', { 17493 props: { 17494 name: frame_name, 17495 id: frame_name, 17496 src: 'javascript:void(0)' 17497 }, 17498 style: { 17499 display: 'none' 17500 } 17501 })); 17502 } 17503 17504 obForm.target = obForm.BXFormTarget.name; 17505 } 17506 17507 obForm.BXFormCallback = callback; 17508 BX.bind(obForm.BXFormTarget, 'load', BX.proxy(BX.ajax._submit_callback, obForm)); 17509 17510 BX.submit(obForm); 17511 17512 return false; 17513}; 17514 17515BX.ajax.submitComponentForm = function(obForm, container, bWait) 17516{ 17517 if (!obForm.target) 17518 { 17519 if (null == obForm.BXFormTarget) 17520 { 17521 var frame_name = 'formTarget_' + Math.random(); 17522 obForm.BXFormTarget = document.body.appendChild(BX.create('IFRAME', { 17523 props: { 17524 name: frame_name, 17525 id: frame_name, 17526 src: 'javascript:void(0)' 17527 }, 17528 style: { 17529 display: 'none' 17530 } 17531 })); 17532 } 17533 17534 obForm.target = obForm.BXFormTarget.name; 17535 } 17536 17537 if (!!bWait) 17538 var w = BX.showWait(container); 17539 17540 obForm.BXFormCallback = function(d) { 17541 if (!!bWait) 17542 BX.closeWait(w); 17543 17544 var callOnload = function(){ 17545 if(!!window.bxcompajaxframeonload) 17546 { 17547 setTimeout(function(){window.bxcompajaxframeonload();window.bxcompajaxframeonload=null;}, 10); 17548 } 17549 }; 17550 17551 BX(container).innerHTML = d; 17552 BX.onCustomEvent('onAjaxSuccess', [null,null,callOnload]); 17553 }; 17554 17555 BX.bind(obForm.BXFormTarget, 'load', BX.proxy(BX.ajax._submit_callback, obForm)); 17556 17557 return true; 17558}; 17559 17560// func will be executed in form context 17561BX.ajax._submit_callback = function() 17562{ 17563 //opera and IE8 triggers onload event even on empty iframe 17564 try 17565 { 17566 if(this.BXFormTarget.contentWindow.location.href.indexOf('http') != 0) 17567 return; 17568 } catch (e) { 17569 return; 17570 } 17571 17572 if (this.BXFormCallback) 17573 this.BXFormCallback.apply(this, [this.BXFormTarget.contentWindow.document.body.innerHTML]); 17574 17575 BX.unbindAll(this.BXFormTarget); 17576}; 17577 17578BX.ajax.prepareForm = function(obForm, data) 17579{ 17580 data = (!!data ? data : {}); 17581 var i, ii, el, 17582 _data = [], 17583 n = obForm.elements.length, 17584 files = 0, length = 0; 17585 if(!!obForm) 17586 { 17587 for (i = 0; i < n; i++) 17588 { 17589 el = obForm.elements[i]; 17590 if (el.disabled) 17591 continue; 17592 17593 if(!el.type) 17594 continue; 17595 17596 switch(el.type.toLowerCase()) 17597 { 17598 case 'text': 17599 case 'textarea': 17600 case 'password': 17601 case 'number': 17602 case 'hidden': 17603 case 'select-one': 17604 _data.push({name: el.name, value: el.value}); 17605 length += (el.name.length + el.value.length); 17606 break; 17607 case 'file': 17608 if (!!el.files) 17609 { 17610 for (ii = 0; ii < el.files.length; ii++) 17611 { 17612 files++; 17613 _data.push({name: el.name, value: el.files[ii], file : true}); 17614 length += el.files[ii].size; 17615 } 17616 } 17617 break; 17618 case 'radio':
17619 case 'checkbox': 17620 if(el.checked) 17621 { 17622 _data.push({name: el.name, value: el.value}); 17623 length += (el.name.length + el.value.length); 17624 } 17625 break; 17626 case 'select-multiple': 17627 for (var j = 0; j < el.options.length; j++) 17628 { 17629 if (el.options[j].selected) 17630 { 17631 _data.push({name : el.name, value : el.options[j].value}); 17632 length += (el.name.length + el.options[j].length); 17633 } 17634 } 17635 break; 17636 default: 17637 break; 17638 } 17639 } 17640 17641 i = 0; length = 0; 17642 var current = data, name, rest, pp, tmpKey; 17643 17644 while(i < _data.length) 17645 { 17646 var p = _data[i].name.indexOf('['); 17647 if (tmpKey) 17648 { 17649 current[_data[i].name] = {}; 17650 current[_data[i].name][tmpKey.replace(/\[|\]/gi, '')] = _data[i].value; 17651 current = data; 17652 tmpKey = null; 17653 i++; 17654 } 17655 else if (p == -1) 17656 { 17657 current[_data[i].name] = _data[i].value; 17658 current = data; 17659 i++; 17660 } 17661 else 17662 { 17663 name = _data[i].name.substring(0, p); 17664 rest = _data[i].name.substring(p+1); 17665 pp = rest.indexOf(']'); 17666 17667 if(pp == -1) 17668 { 17669 if (!current[name]) 17670 current[name] = []; 17671 current = data; 17672 i++; 17673 } 17674 else if(pp == 0) 17675 { 17676 if (!current[name]) 17677 current[name] = []; 17678 //No index specified - so take the next integer 17679 current = current[name]; 17680 _data[i].name = '' + current.length; 17681 if (rest.substring(pp+1).indexOf('[') === 0) 17682 tmpKey = rest.substring(0, pp) + rest.substring(pp+1); 17683 } 17684 else 17685 { 17686 if (!current[name]) 17687 current[name] = {}; 17688 //Now index name becomes and name and we go deeper into the array 17689 current = current[name]; 17690 _data[i].name = rest.substring(0, pp) + rest.substring(pp+1); 17691 } 17692 } 17693 } 17694 } 17695 return {data : data, filesCount : files, roughSize : length}; 17696}; 17697BX.ajax.submitAjax = function(obForm, config) 17698{ 17699 config = (config !== null && typeof config == "object" ? config : {}); 17700 config.url = (config["url"] || obForm.getAttribute("action")); 17701 17702 var additionalData = (config["data"] || {}); 17703 config.data = BX.ajax.prepareForm(obForm).data; 17704 for (var ii in additionalData) 17705 { 17706 if (additionalData.hasOwnProperty(ii)) 17707 { 17708 config.data[ii] = additionalData[ii]; 17709 } 17710 } 17711 17712 if (!window["FormData"]) 17713 { 17714 BX.ajax(config); 17715 } 17716 else 17717 { 17718 var isFile = function(item) 17719 { 17720 var res = Object.prototype.toString.call(item); 17721 return (res == '[object File]' || res == '[object Blob]'); 17722 }, 17723 appendToForm = function(fd, key, val) 17724 { 17725 if (!!val && typeof val == "object" && !isFile(val)) 17726 { 17727 for (var ii in val) 17728 { 17729 if (val.hasOwnProperty(ii)) 17730 { 17731 appendToForm(fd, (key == '' ? ii : key + '[' + ii + ']'), val[ii]); 17732 } 17733 } 17734 } 17735 else 17736 fd.append(key, (!!val ? val : '')); 17737 }, 17738 prepareData = function(arData) 17739 { 17740 var data = {}; 17741 if (null != arData) 17742 { 17743 if(typeof arData == 'object') 17744 { 17745 for(var i in arData) 17746 { 17747 if (arData.hasOwnProperty(i)) 17748 { 17749 var name = BX.util.urlencode(i); 17750 if(typeof arData[i] == 'object' && arData[i]["file"] !== true) 17751 data[name] = prepareData(arData[i]); 17752 else if (arData[i]["file"] === true) 17753 data[name] = arData[i]["value"]; 17754 else 17755 data[name] = BX.util.urlencode(arData[i]); 17756 } 17757 } 17758 } 17759 else 17760 data = BX.util.urlencode(arData); 17761 } 17762 return data; 17763 }, 17764 fd = new window.FormData(); 17765 17766 if (config.method !== 'POST') 17767 { 17768 config.data = BX.ajax.prepareData(config.data); 17769 if (config.data) 17770 { 17771 config.url += (config.url.indexOf('?') !== -1 ? "&" : "?") + config.data; 17772 config.data = ''; 17773 } 17774 } 17775 else 17776 { 17777 if (config.preparePost === true) 17778 config.data = prepareData(config.data); 17779 appendToForm(fd, '', config.data); 17780 config.data = fd; 17781 } 17782 17783 config.preparePost = false; 17784 config.start = false;
17785 17786 var xhr = BX.ajax(config); 17787 if (!!config["onprogress"]) 17788 xhr.upload.addEventListener( 17789 'progress', 17790 function(e){ 17791 var percent = null; 17792 if(e.lengthComputable && (e.total || e["totalSize"])) { 17793 percent = e.loaded * 100 / (e.total || e["totalSize"]); 17794 } 17795 config["onprogress"](e, percent); 17796 } 17797 ); 17798 xhr.send(fd); 17799 } 17800}; 17801 17802BX.ajax.UpdatePageData = function (arData) 17803{ 17804 if (arData.TITLE) 17805 BX.ajax.UpdatePageTitle(arData.TITLE); 17806 if (arData.WINDOW_TITLE || arData.TITLE) 17807 BX.ajax.UpdateWindowTitle(arData.WINDOW_TITLE || arData.TITLE); 17808 if (arData.NAV_CHAIN) 17809 BX.ajax.UpdatePageNavChain(arData.NAV_CHAIN); 17810 if (arData.CSS && arData.CSS.length > 0) 17811 BX.loadCSS(arData.CSS); 17812 if (arData.SCRIPTS && arData.SCRIPTS.length > 0) 17813 { 17814 var f = function(result,config,cb){ 17815 17816 if(!!config && BX.type.isArray(config.scripts)) 17817 { 17818 for(var i=0,l=arData.SCRIPTS.length;i<l;i++) 17819 { 17820 config.scripts.push({isInternal:false,JS:arData.SCRIPTS[i]}); 17821 } 17822 } 17823 else 17824 { 17825 BX.loadScript(arData.SCRIPTS,cb); 17826 } 17827 17828 BX.removeCustomEvent('onAjaxSuccess',f); 17829 }; 17830 BX.addCustomEvent('onAjaxSuccess',f); 17831 } 17832 else 17833 { 17834 var f1 = function(result,config,cb){ 17835 if(BX.type.isFunction(cb)) 17836 { 17837 cb(); 17838 } 17839 BX.removeCustomEvent('onAjaxSuccess',f1); 17840 }; 17841 BX.addCustomEvent('onAjaxSuccess', f1); 17842 } 17843}; 17844 17845BX.ajax.UpdatePageTitle = function(title) 17846{ 17847 var obTitle = BX('pagetitle'); 17848 if (obTitle) 17849 { 17850 BX.remove(obTitle.firstChild); 17851 if (!obTitle.firstChild) 17852 obTitle.appendChild(document.createTextNode(title)); 17853 else 17854 obTitle.insertBefore(document.createTextNode(title), obTitle.firstChild); 17855 } 17856}; 17857 17858BX.ajax.UpdateWindowTitle = function(title) 17859{ 17860 document.title = title; 17861}; 17862 17863BX.ajax.UpdatePageNavChain = function(nav_chain) 17864{ 17865 var obNavChain = BX('navigation'); 17866 if (obNavChain) 17867 { 17868 obNavChain.innerHTML = nav_chain; 17869 } 17870}; 17871 17872/* user options handling */ 17873BX.userOptions = { 17874 options: null, 17875 bSend: false, 17876 delay: 5000, 17877 path: '/bitrix/admin/user_options.php?' 17878}; 17879 17880BX.userOptions.setAjaxPath = function(url) 17881{ 17882 BX.userOptions.path = url.indexOf('?') == -1? url+'?': url+'&'; 17883} 17884BX.userOptions.save = function(sCategory, sName, sValName, sVal, bCommon) 17885{ 17886 if (null == BX.userOptions.options) 17887 BX.userOptions.options = {}; 17888 17889 bCommon = !!bCommon; 17890 BX.userOptions.options[sCategory+'.'+sName+'.'+sValName] = [sCategory, sName, sValName, sVal, bCommon]; 17891 17892 var sParam = BX.userOptions.__get(); 17893 if (sParam != '') 17894 document.cookie = BX.message('COOKIE_PREFIX')+"_LAST_SETTINGS=" + encodeURIComponent(sParam) + "&sessid="+BX.bitrix_sessid()+"; expires=Thu, 31 Dec " + ((new Date()).getFullYear() + 1) + " 23:59:59 GMT; path=/;"; 17895 17896 if(!BX.userOptions.bSend) 17897 { 17898 BX.userOptions.bSend = true; 17899 setTimeout(function(){BX.userOptions.send(null)}, BX.userOptions.delay); 17900 } 17901}; 17902 17903BX.userOptions.send = function(callback) 17904{ 17905 var sParam = BX.userOptions.__get(); 17906 BX.userOptions.options = null; 17907 BX.userOptions.bSend = false; 17908 17909 if (sParam != '') 17910 { 17911 document.cookie = BX.message('COOKIE_PREFIX') + "_LAST_SETTINGS=; path=/;"; 17912 BX.ajax({ 17913 'method': 'GET', 17914 'dataType': 'html', 17915 'processData': false, 17916 'cache': false, 17917 'url': BX.userOptions.path+sParam+'&sessid='+BX.bitrix_sessid(), 17918 'onsuccess': callback 17919 }); 17920 } 17921}; 17922 17923BX.userOptions.del = function(sCategory, sName, bCommon, callback) 17924{ 17925 BX.ajax.get(BX.userOptions.path+'action=delete&c='+sCategory+'&n='+sName+(bCommon == true? '&common=Y':'')+'&sessid='+BX.bitrix_sessid(), callback); 17926}; 17927 17928BX.userOptions.__get = function() 17929{ 17930 if (!BX.userOptions.options) return ''; 17931 17932 var sParam = '', n = -1, prevParam = '', aOpt, i; 17933 17934 for (i in BX.userOptions.options) 17935 { 17936 if(BX.userOptions.options.hasOwnProperty(i)) 17937 { 17938 aOpt = BX.userOptions.options[i]; 17939 17940 if (prevParam != aOpt[0]+'.'+aOpt[1]) 17941 { 17942 n++; 17943 sParam += '&p['+n+'][c]='+BX.util.urlencode(aOpt[0]); 17944 sParam += '&p['+n+'][n]='+BX.util.urlencode(aOpt[1]); 17945 if (aOpt[4] == true) 17946 sParam += '&p['+n+'][d]=Y'; 17947 prevParam = aOpt[0]+'.'+aOpt[1]; 17948 } 17949 17950 var valueName = aOpt[2]; 17951 var value = aOpt[3]; 17952 17953 if (valueName === null) 17954 { 17955 sParam += '&p['+n+'][v]='+BX.util.urlencode(value); 17956 } 17957 else 17958 {
17959 sParam += '&p['+n+'][v]['+BX.util.urlencode(valueName)+']='+BX.util.urlencode(value); 17960 } 17961 } 17962 } 17963 17964 return sParam.substr(1); 17965}; 17966 17967BX.ajax.history = { 17968 expected_hash: '', 17969 17970 obParams: null, 17971 17972 obFrame: null, 17973 obImage: null, 17974 17975 obTimer: null, 17976 17977 bInited: false, 17978 bHashCollision: false, 17979 bPushState: !!(history.pushState && BX.type.isFunction(history.pushState)), 17980 17981 startState: null, 17982 17983 init: function(obParams) 17984 { 17985 if (BX.ajax.history.bInited) 17986 return; 17987 17988 this.obParams = obParams; 17989 var obCurrentState = this.obParams.getState(); 17990 17991 if (BX.ajax.history.bPushState) 17992 { 17993 BX.ajax.history.expected_hash = window.location.pathname; 17994 if (window.location.search) 17995 BX.ajax.history.expected_hash += window.location.search; 17996 17997 BX.ajax.history.put(obCurrentState, BX.ajax.history.expected_hash, '', true); 17998 // due to some strange thing, chrome calls popstate event on page start. so we should delay it 17999 setTimeout(function(){BX.bind(window, 'popstate', BX.ajax.history.__hashListener);}, 500); 18000 } 18001 else 18002 { 18003 BX.ajax.history.expected_hash = window.location.hash; 18004 18005 if (!BX.ajax.history.expected_hash || BX.ajax.history.expected_hash == '#') 18006 BX.ajax.history.expected_hash = '__bx_no_hash__'; 18007 18008 jsAjaxHistoryContainer.put(BX.ajax.history.expected_hash, obCurrentState); 18009 BX.ajax.history.obTimer = setTimeout(BX.ajax.history.__hashListener, 500); 18010 18011 if (BX.browser.IsIE()) 18012 { 18013 BX.ajax.history.obFrame = document.createElement('IFRAME'); 18014 BX.hide_object(BX.ajax.history.obFrame); 18015 18016 document.body.appendChild(BX.ajax.history.obFrame); 18017 18018 BX.ajax.history.obFrame.contentWindow.document.open(); 18019 BX.ajax.history.obFrame.contentWindow.document.write(BX.ajax.history.expected_hash); 18020 BX.ajax.history.obFrame.contentWindow.document.close(); 18021 } 18022 else if (BX.browser.IsOpera()) 18023 { 18024 BX.ajax.history.obImage = document.createElement('IMG'); 18025 BX.hide_object(BX.ajax.history.obImage); 18026 18027 document.body.appendChild(BX.ajax.history.obImage); 18028 18029 BX.ajax.history.obImage.setAttribute('src', 'javascript:location.href = \'javascript:BX.ajax.history.__hashListener();\';'); 18030 } 18031 } 18032 18033 BX.ajax.history.bInited = true; 18034 }, 18035 18036 __hashListener: function(e) 18037 { 18038 e = e || window.event || {state:false}; 18039 18040 if (BX.ajax.history.bPushState) 18041 { 18042 BX.ajax.history.obParams.setState(e.state||BX.ajax.history.startState); 18043 } 18044 else 18045 { 18046 if (BX.ajax.history.obTimer) 18047 { 18048 window.clearTimeout(BX.ajax.history.obTimer); 18049 BX.ajax.history.obTimer = null; 18050 } 18051 18052 var current_hash; 18053 if (null != BX.ajax.history.obFrame) 18054 current_hash = BX.ajax.history.obFrame.contentWindow.document.body.innerText; 18055 else 18056 current_hash = window.location.hash; 18057 18058 if (!current_hash || current_hash == '#') 18059 current_hash = '__bx_no_hash__'; 18060 18061 if (current_hash.indexOf('#') == 0) 18062 current_hash = current_hash.substring(1); 18063 18064 if (current_hash != BX.ajax.history.expected_hash) 18065 { 18066 var state = jsAjaxHistoryContainer.get(current_hash); 18067 if (state) 18068 { 18069 BX.ajax.history.obParams.setState(state); 18070 18071 BX.ajax.history.expected_hash = current_hash; 18072 if (null != BX.ajax.history.obFrame) 18073 { 18074 var __hash = current_hash == '__bx_no_hash__' ? '' : current_hash; 18075 if (window.location.hash != __hash && window.location.hash != '#' + __hash) 18076 window.location.hash = __hash; 18077 } 18078 } 18079 } 18080 18081 BX.ajax.history.obTimer = setTimeout(BX.ajax.history.__hashListener, 500); 18082 } 18083 }, 18084 18085 put: function(state, new_hash, new_hash1, bStartState) 18086 { 18087 if (this.bPushState) 18088 { 18089 if(!bStartState) 18090 { 18091 history.pushState(state, '', new_hash); 18092 } 18093 else 18094 { 18095 BX.ajax.history.startState = state; 18096 } 18097 } 18098 else 18099 { 18100 if (typeof new_hash1 != 'undefined') 18101 new_hash = new_hash1; 18102 else 18103 new_hash = 'view' + new_hash; 18104 18105 jsAjaxHistoryContainer.put(new_hash, state); 18106 BX.ajax.history.expected_hash = new_hash; 18107 18108 window.location.hash = BX.util.urlencode(new_hash); 18109 18110 if (null != BX.ajax.history.obFrame) 18111 { 18112 BX.ajax.history.obFrame.contentWindow.document.open(); 18113 BX.ajax.history.obFrame.contentWindow.document.write(new_hash); 18114 BX.ajax.history.obFrame.contentWindow.document.close(); 18115 } 18116 } 18117 }, 18118 18119 checkRedirectStart: function(param_name, param_value) 18120 { 18121 var current_hash = window.location.hash; 18122 if (current_hash.substring(0, 1) == '#') current_hash = current_hash.substring(1); 18123 18124 var test = current_hash.substring(0, 5); 18125 if (test == 'view/' || test == 'view%') 18126 { 18127 BX.ajax.history.bHashCollision = true;
18128 document.write('<' + 'div id="__ajax_hash_collision_' + param_value + '" style="display: none;">'); 18129 } 18130 }, 18131 18132 checkRedirectFinish: function(param_name, param_value) 18133 { 18134 document.write('</div>'); 18135 18136 var current_hash = window.location.hash; 18137 if (current_hash.substring(0, 1) == '#') current_hash = current_hash.substring(1); 18138 18139 BX.ready(function () 18140 { 18141 var test = current_hash.substring(0, 5); 18142 if (test == 'view/' || test == 'view%') 18143 { 18144 var obColNode = BX('__ajax_hash_collision_' + param_value); 18145 var obNode = obColNode.firstChild; 18146 BX.cleanNode(obNode); 18147 obColNode.style.display = 'block'; 18148 18149 // IE, Opera and Chrome automatically modifies hash with urlencode, but FF doesn't ;-( 18150 if (test != 'view%') 18151 current_hash = BX.util.urlencode(current_hash); 18152 18153 current_hash += (current_hash.indexOf('%3F') == -1 ? '%3F' : '%26') + param_name + '=' + param_value; 18154 18155 var url = '/bitrix/tools/ajax_redirector.php?hash=' + current_hash; 18156 18157 BX.ajax.insertToNode(url, obNode); 18158 } 18159 }); 18160 } 18161}; 18162 18163BX.ajax.component = function(node) 18164{ 18165 this.node = node; 18166}; 18167 18168BX.ajax.component.prototype.getState = function() 18169{ 18170 var state = { 18171 'node': this.node, 18172 'title': window.document.title, 18173 'data': BX(this.node).innerHTML 18174 }; 18175 18176 var obNavChain = BX('navigation'); 18177 if (null != obNavChain) 18178 state.nav_chain = obNavChain.innerHTML; 18179 18180 BX.onCustomEvent(BX(state.node), "onComponentAjaxHistoryGetState", [state]); 18181 18182 return state; 18183}; 18184 18185BX.ajax.component.prototype.setState = function(state) 18186{ 18187 BX(state.node).innerHTML = state.data; 18188 BX.ajax.UpdatePageTitle(state.title); 18189 18190 if (state.nav_chain) 18191 { 18192 BX.ajax.UpdatePageNavChain(state.nav_chain); 18193 } 18194 18195 BX.onCustomEvent(BX(state.node), "onComponentAjaxHistorySetState", [state]); 18196}; 18197 18198var jsAjaxHistoryContainer = { 18199 arHistory: {}, 18200 18201 put: function(hash, state) 18202 { 18203 this.arHistory[hash] = state; 18204 }, 18205 18206 get: function(hash) 18207 { 18208 return this.arHistory[hash]; 18209 } 18210}; 18211 18212 18213BX.ajax.FormData = function() 18214{ 18215 this.elements = []; 18216 this.files = []; 18217 this.features = {}; 18218 this.isSupported(); 18219 this.log('BX FormData init'); 18220}; 18221 18222BX.ajax.FormData.isSupported = function() 18223{ 18224 var f = new BX.ajax.FormData(); 18225 var result = f.features.supported; 18226 f = null; 18227 return result; 18228}; 18229 18230BX.ajax.FormData.prototype.log = function(o) 18231{ 18232 if (false) { 18233 try { 18234 if (BX.browser.IsIE()) o = JSON.stringify(o); 18235 console.log(o); 18236 } catch(e) {} 18237 } 18238}; 18239 18240BX.ajax.FormData.prototype.isSupported = function() 18241{ 18242 var f = {}; 18243 f.fileReader = (window.FileReader && window.FileReader.prototype.readAsBinaryString); 18244 f.readFormData = f.sendFormData = !!(window.FormData); 18245 f.supported = !!(f.readFormData && f.sendFormData); 18246 this.features = f; 18247 this.log('features:'); 18248 this.log(f); 18249 18250 return f.supported; 18251}; 18252 18253BX.ajax.FormData.prototype.append = function(name, value) 18254{ 18255 if (typeof(value) === 'object') { // seems to be files element 18256 this.files.push({'name': name, 'value':value}); 18257 } else { 18258 this.elements.push({'name': name, 'value':value}); 18259 } 18260}; 18261 18262BX.ajax.FormData.prototype.send = function(url, callbackOk, callbackProgress, callbackError) 18263{ 18264 this.log('FD send'); 18265 this.xhr = BX.ajax({ 18266 'method': 'POST', 18267 'dataType': 'html', 18268 'url': url, 18269 'onsuccess': callbackOk, 18270 'onfailure': callbackError, 18271 'start': false, 18272 'preparePost':false 18273 }); 18274 18275 if (callbackProgress) 18276 { 18277 this.xhr.upload.addEventListener( 18278 'progress', 18279 function(e) { 18280 if (e.lengthComputable) 18281 callbackProgress(e.loaded / (e.total || e.totalSize)); 18282 }, 18283 false 18284 ); 18285 } 18286 18287 if (this.features.readFormData && this.features.sendFormData) 18288 { 18289 var fd = new FormData(); 18290 this.log('use browser formdata'); 18291 for (var i in this.elements) 18292 { 18293 if(this.elements.hasOwnProperty(i)) 18294 fd.append(this.elements[i].name,this.elements[i].value); 18295 } 18296 for (i in this.files) 18297 { 18298 if(this.files.hasOwnProperty(i)) 18299 fd.append(this.files[i].name, this.files[i].value); 18300 } 18301 this.xhr.send(fd); 18302 } 18303 18304 return this.xhr; 18305}; 18306 18307BX.addCustomEvent('onAjaxFailure', BX.debug); 18308})(window); 18309 18310 18311 18312(function (exports,main_core) { 18313 'use strict'; 18314 18315 var LazyLoad = { 18316 observer: null, 18317 images: {}, 18318 imageStatus: { 18319 hidden: -2, 18320 error: -1, 18321 "undefined": 0, 18322 inited: 1, 18323 loaded: 2 18324 }, 18325 imageTypes: { 18326 image: 1, 18327 background: 2 18328 },
18329 initObserver: function initObserver() { 18330 this.observer = new IntersectionObserver(this.onIntersection.bind(this), { 18331 rootMargin: '20% 0% 20% 0%', 18332 threshold: 0.10 18333 }); 18334 }, 18335 onIntersection: function onIntersection(entries) { 18336 entries.forEach(function (entry) { 18337 if (entry.isIntersecting) { 18338 this.showImage(entry.target); 18339 } 18340 }.bind(this)); 18341 }, 18342 registerImage: function registerImage(id, isImageVisibleCallback, options) { 18343 if (this.observer === null) { 18344 this.initObserver(); 18345 } 18346 18347 options = options || {}; 18348 18349 if (!main_core.Type.isStringFilled(id)) { 18350 return; 18351 } 18352 18353 if (main_core.Type.isObject(this.images[id])) { 18354 return; 18355 } 18356 18357 var element = document.getElementById(id); 18358 18359 if (!main_core.Type.isDomNode(element)) { 18360 return; 18361 } 18362 18363 this.observer.observe(element); 18364 this.images[id] = { 18365 id: id, 18366 node: null, 18367 src: null, 18368 dataSrcName: options.dataSrcName || 'src', 18369 type: null, 18370 func: main_core.Type.isFunction(isImageVisibleCallback) ? isImageVisibleCallback : null, 18371 status: this.imageStatus.undefined 18372 }; 18373 }, 18374 registerImages: function registerImages(ids, isImageVisibleCallback, options) { 18375 if (main_core.Type.isArray(ids)) { 18376 for (var i = 0, length = ids.length; i < length; i++) { 18377 this.registerImage(ids[i], isImageVisibleCallback, options); 18378 } 18379 } 18380 }, 18381 showImage: function showImage(imageNode) { 18382 var imageNodeId = imageNode.id; 18383 18384 if (!main_core.Type.isStringFilled(imageNodeId)) { 18385 return; 18386 } 18387 18388 var image = this.images[imageNodeId]; 18389 18390 if (!main_core.Type.isPlainObject(image)) { 18391 return; 18392 } 18393 18394 if (image.status == this.imageStatus.undefined) { 18395 this.initImage(image); 18396 } 18397 18398 if (image.status !== this.imageStatus.inited) { 18399 return; 18400 } 18401 18402 if (!image.node || !image.node.parentNode) { 18403 image.node = null; 18404 image.status = this.imageStatus.error; 18405 return; 18406 } 18407 18408 if (image.type == this.imageTypes.image) { 18409 image.node.src = image.src; 18410 } else { 18411 image.node.style.backgroundImage = "url('" + image.src + "')"; 18412 } 18413 18414 image.node.dataset[image.dataSrcName] = ""; 18415 image.status = this.imageStatus.loaded; 18416 }, 18417 showImages: function showImages(checkOwnVisibility) { 18418 checkOwnVisibility = checkOwnVisibility !== false; 18419 18420 for (var id in this.images) { 18421 if (!this.images.hasOwnProperty(id)) { 18422 continue; 18423 } 18424 18425 var image = this.images[id]; 18426 18427 if (image.status == this.imageStatus.undefined) { 18428 this.initImage(image); 18429 } 18430 18431 if (image.status !== this.imageStatus.inited) { 18432 continue; 18433 } 18434 18435 if (!image.node || !image.node.parentNode) { 18436 image.node = null; 18437 image.status = this.imageStatus.error; 18438 continue; 18439 } 18440 18441 var isImageVisible = true; 18442 18443 if (checkOwnVisibility && main_core.Type.isFunction(image.func)) { 18444 isImageVisible = image.func(image); 18445 } 18446 18447 if (isImageVisible === true && this.isElementVisibleOnScreen(image.node)) { 18448 if (image.type == this.imageTypes.image) { 18449 image.node.src = image.src; 18450 } else { 18451 image.node.style.backgroundImage = "url('" + image.src + "')"; 18452 } 18453 18454 image.node.dataset[image.dataSrcName] = ""; 18455 image.status = this.imageStatus.loaded; 18456 } 18457 } 18458 }, 18459 initImage: function initImage(image) { 18460 image.status = this.imageStatus.error; 18461 var node = document.getElementById(image.id); 18462 18463 if (!main_core.Type.isDomNode(node)) { 18464 return; 18465 } 18466 18467 var src = node.dataset[image.dataSrcName]; 18468 18469 if (main_core.Type.isStringFilled(src)) { 18470 image.node = node; 18471 image.src = src; 18472 image.status = this.imageStatus.inited; 18473 image.type = image.node.tagName.toLowerCase() == "img" ? this.imageTypes.image : this.imageTypes.background; 18474 } 18475 }, 18476 isElementVisibleOnScreen: function isElementVisibleOnScreen(element) { 18477 var coords = this.getElementCoords(element); 18478 var windowTop = window.pageYOffset || document.documentElement.scrollTop; 18479 var windowBottom = windowTop + document.documentElement.clientHeight; 18480 coords.bottom = coords.top + element.offsetHeight; 18481 return coords.top > windowTop && coords.top < windowBottom || // topVisible 18482 coords.bottom < windowBottom && coords.bottom > windowTop // bottomVisible 18483 ; 18484 }, 18485 isElementVisibleOn2Screens: function isElementVisibleOn2Screens(element) { 18486 var windowHeight = document.documentElement.clientHeight; 18487 var windowTop = window.pageYOffset || document.documentElement.scrollTop; 18488 var windowBottom = windowTop + windowHeight; 18489 var coords = this.getElementCoords(element); 18490 coords.bottom = coords.top + element.offsetHeight; 18491 windowTop -= windowHeight; 18492 windowBottom += windowHeight; 18493 return coords.top > windowTop && coords.top < windowBottom || // topVisible 18494 coords.bottom < windowBottom && coords.bottom > windowTop // bottomVisible 18495 ; 18496 }, 18497 getElementCoords: function getElementCoords(element) { 18498 var box = element.getBoundingClientRect(); 18499 return { 18500 originTop: box.top, 18501 originLeft: box.left, 18502 top: box.top + window.pageYOffset, 18503 left: box.left + window.pageXOffset 18504 }; 18505 }, 18506 onScroll: function onScroll() {}, 18507 clearImages: function clearImages() { 18508 this.images = []; 18509 } 18510 }; 18511 18512 exports.LazyLoad = LazyLoad; 18513 18514}((this.BX = this.BX || {}),BX)); 18515 18516 18517 18518(function (exports) { 18519 'use strict'; 18520 18521 var ParamBag = /*#__PURE__*/function () { 18522 function ParamBag() { 18523 var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 18524 babelHelpers.classCallCheck(this, ParamBag); 18525 18526 if (!!params && babelHelpers.typeof(params) === 'object') { 18527 this.params = new Map(Object.entries(params)); 18528 } else { 18529 this.params = new Map(); 18530 } 18531 } 18532 18533 babelHelpers.createClass(ParamBag, [{ 18534 key: "getParam", 18535 value: function getParam(key) { 18536 var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; 18537 18538 if (this.params.has(key)) { 18539 return this.params.get(key); 18540 } 18541 18542 return defaultValue; 18543 } 18544 }, { 18545 key: "setParam", 18546 value: function setParam(key, value) { 18547 this.params.set(key, value); 18548 } 18549 }, { 18550 key: "clear", 18551 value: function clear() { 18552 this.params.clear(); 18553 } 18554 }], [{ 18555 key: "create", 18556 value: function create() { 18557 var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 18558 return new ParamBag(params); 18559 } 18560 }]); 18561 return ParamBag; 18562 }(); 18563 18564 exports.ParamBag = ParamBag; 18565 18566}((this.BX = this.BX || {}))); 18567 18568 18569 18570(function() { 18571 BX.FixFontSize = function(params) 18572 { 18573 var widthNode, computedStyles, width; 18574 18575 this.node = null; 18576 this.prevWindowSize = 0; 18577 this.prevWrapperSize = 0; 18578 this.mainWrapper = null; 18579 this.textWrapper = null; 18580 this.objList = params.objList; 18581 this.minFontSizeList = []; 18582 this.minFontSize = 0; 18583 18584 if (params.onresize) 18585 { 18586 this.prevWindowSize = window.innerWidth || document.documentElement.clientWidth; 18587 BX.bind(window, 'resize', BX.throttle(this.onResize, 350, this)); 18588 } 18589 18590 if (params.onAdaptiveResize) 18591 { 18592 widthNode = this.objList[0].scaleBy || this.objList[0].node; 18593 computedStyles = getComputedStyle(widthNode); 18594 this.prevWrapperSize = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 18595 BX.bind(window, 'resize', BX.throttle(this.onAdaptiveResize, 350, this)); 18596 } 18597 18598 this.createTestNodes(); 18599 this.decrease(); 18600 }; 18601 18602 BX.FixFontSize.prototype = 18603 { 18604 createTestNodes: function() 18605 { 18606 this.textWrapper = BX.create('div',{ 18607 style : { 18608 display : 'inline-block', 18609 whiteSpace : 'nowrap' 18610 } 18611 }); 18612 18613 this.mainWrapper = BX.create('div',{ 18614 style : { 18615 height : 0, 18616 overflow : 'hidden' 18617 }, 18618 children : [this.textWrapper] 18619 }); 18620 18621 }, 18622 insertTestNodes: function() 18623 { 18624 document.body.appendChild(this.mainWrapper); 18625 }, 18626 removeTestNodes: function() 18627 { 18628 document.body.removeChild(this.mainWrapper); 18629 }, 18630 decrease: function() 18631 { 18632 var width, 18633 fontSize, 18634 widthNode, 18635 computedStyles; 18636 18637 this.insertTestNodes(); 18638
18639 for(var i=this.objList.length-1; i>=0; i--) 18640 { 18641 widthNode = this.objList[i].scaleBy || this.objList[i].node; 18642 computedStyles = getComputedStyle(widthNode); 18643 width = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 18644 fontSize = parseInt(getComputedStyle(this.objList[i].node)["font-size"]); 18645 18646 this.textWrapperSetStyle(this.objList[i].node); 18647 18648 if(this.textWrapperInsertText(this.objList[i].node)) 18649 { 18650 while(this.textWrapper.offsetWidth > width && fontSize > 0) 18651 { 18652 this.textWrapper.style.fontSize = --fontSize + 'px'; 18653 } 18654 18655 if(this.objList[i].smallestValue) 18656 { 18657 this.minFontSize = this.minFontSize ? Math.min(this.minFontSize, fontSize) : fontSize; 18658 18659 this.minFontSizeList.push(this.objList[i].node) 18660 } 18661 else 18662 { 18663 this.objList[i].node.style.fontSize = fontSize + 'px'; 18664 } 18665 } 18666 } 18667 18668 if(this.minFontSizeList.length > 0) 18669 this.setMinFont(); 18670 18671 this.removeTestNodes(); 18672 18673 }, 18674 increase: function() 18675 { 18676 this.insertTestNodes(); 18677 var width, 18678 fontSize, 18679 widthNode, 18680 computedStyles; 18681 18682 this.insertTestNodes(); 18683 18684 for(var i=this.objList.length-1; i>=0; i--) 18685 { 18686 widthNode = this.objList[i].scaleBy || this.objList[i].node; 18687 computedStyles = getComputedStyle(widthNode); 18688 width = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 18689 fontSize = parseInt(getComputedStyle(this.objList[i].node)["font-size"]); 18690 18691 this.textWrapperSetStyle(this.objList[i].node); 18692 18693 if(this.textWrapperInsertText(this.objList[i].node)) 18694 { 18695 while(this.textWrapper.offsetWidth < width && fontSize < this.objList[i].maxFontSize) 18696 { 18697 this.textWrapper.style.fontSize = ++fontSize + 'px'; 18698 } 18699 18700 fontSize--; 18701 18702 if(this.objList[i].smallestValue) 18703 { 18704 this.minFontSize = this.minFontSize ? Math.min(this.minFontSize, fontSize) : fontSize; 18705 18706 this.minFontSizeList.push(this.objList[i].node) 18707 } 18708 else 18709 { 18710 this.objList[i].node.style.fontSize = fontSize + 'px'; 18711 } 18712 } 18713 } 18714 18715 if(this.minFontSizeList.length > 0) 18716 this.setMinFont(); 18717 18718 this.removeTestNodes(); 18719 }, 18720 setMinFont : function() 18721 { 18722 for(var i = this.minFontSizeList.length-1; i>=0; i--) 18723 { 18724 this.minFontSizeList[i].style.fontSize = this.minFontSize + 'px'; 18725 } 18726 18727 this.minFontSize = 0; 18728 }, 18729 onResize : function() 18730 { 18731 var width = window.innerWidth || document.documentElement.clientWidth; 18732 18733 if(this.prevWindowSize > width) 18734 this.decrease(); 18735 18736 else if (this.prevWindowSize < width) 18737 this.increase(); 18738 18739 this.prevWindowSize = width; 18740 }, 18741 onAdaptiveResize : function() 18742 { 18743 var widthNode = this.objList[0].scaleBy || this.objList[0].node, 18744 computedStyles = getComputedStyle(widthNode), 18745 width = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 18746 18747 if (this.prevWrapperSize > width) 18748 this.decrease(); 18749 else if (this.prevWrapperSize < width) 18750 this.increase(); 18751 18752 this.prevWrapperSize = width; 18753 }, 18754 textWrapperInsertText : function(node) 18755 { 18756 if(node.textContent){ 18757 this.textWrapper.textContent = node.textContent; 18758 return true; 18759 } 18760 else if(node.innerText) 18761 { 18762 this.textWrapper.innerText = node.innerText; 18763 return true; 18764 } 18765 else { 18766 return false; 18767 } 18768 }, 18769 textWrapperSetStyle : function(node) 18770 { 18771 this.textWrapper.style.fontFamily = getComputedStyle(node)["font-family"]; 18772 this.textWrapper.style.fontSize = getComputedStyle(node)["font-size"]; 18773 this.textWrapper.style.fontStyle = getComputedStyle(node)["font-style"]; 18774 this.textWrapper.style.fontWeight = getComputedStyle(node)["font-weight"]; 18775 this.textWrapper.style.lineHeight = getComputedStyle(node)["line-height"]; 18776 } 18777 }; 18778 18779 BX.FixFontSize.init = function(params) 18780 { 18781 return new BX.FixFontSize(params); 18782 }; 18783})(); 18784 18785})(); 18786//# 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.