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('webkit'); 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() { 9385 let globalClass = 'bx-core'; 9386 9387 if (Dom.hasClass(document.documentElement, globalClass)) { 9388 return; 9389 } 9390 9391 if (Browser.isIOS()) { 9392 globalClass += ' bx-ios'; 9393 } else if (Browser.isWin()) { 9394 globalClass += ' bx-win'; 9395 } else if (Browser.isMac()) { 9396 globalClass += ' bx-mac'; 9397 } else if (Browser.isLinux()) { 9398 globalClass += ' bx-linux'; 9399 } else if (Browser.isAndroid()) { 9400 globalClass += ' bx-android'; 9401 } 9402 9403 globalClass += Browser.isMobile() ? ' bx-touch' : ' bx-no-touch'; 9404 globalClass += Browser.isRetina() ? ' bx-retina' : ' bx-no-retina'; 9405 let ieVersion = -1; 9406 9407 if (/AppleWebKit/.test(navigator.userAgent)) { 9408 globalClass += ' bx-chrome'; 9409 } else if (Browser.detectIEVersion() > 0) { 9410 ieVersion = Browser.detectIEVersion(); 9411 globalClass += ` bx-ie bx-ie${ieVersion}`; 9412 9413 if (ieVersion > 7 && ieVersion < 10 && !Browser.isDoctype()) { 9414 globalClass += ' bx-quirks'; 9415 } 9416 } else if (/Opera/.test(navigator.userAgent)) { 9417 globalClass += ' bx-opera'; 9418 } else if (/Gecko/.test(navigator.userAgent)) { 9419 globalClass += ' bx-firefox'; 9420 } 9421 9422 Dom.addClass(document.documentElement, globalClass); 9423 } 9424 }, { 9425 key: "detectAndroidVersion", 9426 value: function detectAndroidVersion() { 9427 const re = new RegExp('Android ([0-9]+[.0-9]*)'); 9428 9429 if (re.exec(navigator.userAgent) != null) { 9430 const res = navigator.userAgent.match(re); 9431 9432 if (Type.isArrayLike(res) && res.length > 0) { 9433 return parseFloat(res[1]); 9434 } 9435 } 9436 9437 return 0; 9438 } 9439 }, { 9440 key: "isPropertySupported", 9441 value: function isPropertySupported(jsProperty, returnCSSName) { 9442 if (jsProperty === '') { 9443 return false; 9444 } 9445 9446 function getCssName(propertyName) { 9447 return propertyName.replace(/([A-Z])/g, (...args) => `-${args[1].toLowerCase()}`); 9448 } 9449 9450 function getJsName(cssName) { 9451 const reg = /(\\-([a-z]))/g; 9452 9453 if (reg.test(cssName)) { 9454 return cssName.replace(reg, (...args) => args[2].toUpperCase()); 9455 } 9456 9457 return cssName; 9458 } 9459 9460 const property = jsProperty.includes('-') ? getJsName(jsProperty) : jsProperty; 9461 const bReturnCSSName = !!returnCSSName; 9462 const ucProperty = property.charAt(0).toUpperCase() + property.slice(1); 9463 const props = ['Webkit', 'Moz', 'O', 'ms'].join(`${ucProperty} `); 9464 const properties = `${property} ${props} ${ucProperty}`.split(' '); 9465 const obj = document.body || document.documentElement; 9466 9467 for (let i = 0; i < properties.length; i += 1) { 9468 const prop = properties[i]; 9469 9470 if (obj && 'style' in obj && prop in obj.style) { 9471 const lowerProp = prop.substr(0, prop.length - property.length).toLowerCase(); 9472 const prefix = prop === property ? '' : `-${lowerProp}-`; 9473 return bReturnCSSName ? prefix + getCssName(property) : prop; 9474 } 9475 } 9476 9477 return false; 9478 } 9479 }, { 9480 key: "addGlobalFeatures", 9481 value: function addGlobalFeatures(features) { 9482 if (!Type.isArray(features)) { 9483 return; 9484 } 9485 9486 const classNames = []; 9487 9488 for (let i = 0; i < features.length; i += 1) { 9489 const support = !!Browser.isPropertySupported(features[i]); 9490 classNames.push(`bx-${support ? '' : 'no-'}${features[i].toLowerCase()}`); 9491 } 9492 9493 Dom.addClass(document.documentElement, classNames.join(' ')); 9494 } 9495 }]); 9496 return Browser; 9497 }(); 9498 9499 let Cookie = /*#__PURE__*/function () { 9500 function Cookie() { 9501 babelHelpers.classCallCheck(this, Cookie); 9502 } 9503 9504 babelHelpers.createClass(Cookie, null, [{ 9505 key: "getList", 9506 9507 /** 9508 * Gets cookies list for current domain 9509 * @return {object} 9510 */ 9511 value: function getList() { 9512 return document.cookie.split(';').map(item => item.split('=')).map(item => item.map(subItem => subItem.trim())).reduce((acc, item) => { 9513 const [key, value] = item; 9514 acc[decodeURIComponent(key)] = decodeURIComponent(value); 9515 return acc; 9516 }, {}); 9517 } 9518 /** 9519 * Gets cookie value 9520 * @param {string} name 9521 * @return {*} 9522 */ 9523 9524 }, { 9525 key: "get", 9526 value: function get(name) { 9527 const cookiesList = Cookie.getList(); 9528 9529 if (name in cookiesList) { 9530 return cookiesList[name]; 9531 } 9532 9533 return undefined; 9534 } 9535 /** 9536 * Sets cookie 9537 * @param {string} name 9538 * @param {*} value 9539 * @param {object} [options] 9540 */ 9541 9542 }, { 9543 key: "set", 9544 value: function set(name, value, options = {}) { 9545 const attributes = { 9546 expires: '', 9547 ...options 9548 }; 9549 9550 if (Type.isNumber(attributes.expires)) { 9551 const now = +new Date(); 9552 const days = attributes.expires; 9553 const dayInMs = 864e+5; 9554 attributes.expires = new Date(now + days * dayInMs); 9555 } 9556 9557 if (Type.isDate(attributes.expires)) { 9558 attributes.expires = attributes.expires.toUTCString(); 9559 } 9560 9561 const safeName = decodeURIComponent(String(name)).replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape); 9562 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); 9563 const stringifiedAttributes = Object.keys(attributes).reduce((acc, key) => { 9564 const attributeValue = attributes[key]; 9565 9566 if (!attributeValue) { 9567 return acc; 9568 } 9569 9570 if (attributeValue === true) { 9571 return `${acc}; ${key}`; 9572 } 9573 /** 9574 * Considers RFC 6265 section 5.2: 9575 * ... 9576 * 3. If the remaining unparsed-attributes contains a %x3B (';') 9577 * character: 9578 * Consume the characters of the unparsed-attributes up to, 9579 * not including, the first %x3B (';') character. 9580 */ 9581 9582 9583 return `${acc}; ${key}=${attributeValue.split(';')[0]}`; 9584 }, ''); 9585 document.cookie = `${safeName}=${safeValue}${stringifiedAttributes}`; 9586 } 9587 /** 9588 * Removes cookie 9589 * @param {string} name 9590 * @param {object} [options] 9591 */ 9592 9593 }, { 9594 key: "remove", 9595 value: function remove(name, options = {}) { 9596 Cookie.set(name, '', { ...options, 9597 expires: -1 9598 }); 9599 } 9600 }]); 9601 return Cookie; 9602 }(); 9603 9604 function objectToFormData(source, formData = new FormData(), pre = null) { 9605 if (Type.isUndefined(source)) { 9606 return formData; 9607 } 9608 9609 if (Type.isNull(source)) { 9610 formData.append(pre, ''); 9611 } else if (Type.isArray(source)) { 9612 if (!source.length) {
9613 const key = `${pre}[]`; 9614 formData.append(key, ''); 9615 } else { 9616 source.forEach((value, index) => { 9617 const key = `${pre}[${index}]`; 9618 objectToFormData(value, formData, key); 9619 }); 9620 } 9621 } else if (Type.isDate(source)) { 9622 formData.append(pre, source.toISOString()); 9623 } else if (Type.isObject(source) && !Type.isFile(source) && !Type.isBlob(source)) { 9624 Object.keys(source).forEach(property => { 9625 const value = source[property]; 9626 let preparedProperty = property; 9627 9628 if (Type.isArray(value)) { 9629 while (property.length > 2 && property.lastIndexOf('[]') === property.length - 2) { 9630 preparedProperty = property.substring(0, property.length - 2); 9631 } 9632 } 9633 9634 const key = pre ? `${pre}[${preparedProperty}]` : preparedProperty; 9635 objectToFormData(value, formData, key); 9636 }); 9637 } else { 9638 formData.append(pre, source); 9639 } 9640 9641 return formData; 9642 } 9643 9644 let Data = /*#__PURE__*/function () { 9645 function Data() { 9646 babelHelpers.classCallCheck(this, Data); 9647 } 9648 9649 babelHelpers.createClass(Data, null, [{ 9650 key: "convertObjectToFormData", 9651 9652 /** 9653 * Converts object to FormData 9654 * @param source 9655 * @return {FormData} 9656 */ 9657 value: function convertObjectToFormData(source) { 9658 return objectToFormData(source); 9659 } 9660 }]); 9661 return Data; 9662 }(); 9663 9664 /** 9665 * @memberOf BX 9666 */ 9667 9668 let Http = function Http() { 9669 babelHelpers.classCallCheck(this, Http); 9670 }; 9671 9672 babelHelpers.defineProperty(Http, "Cookie", Cookie); 9673 babelHelpers.defineProperty(Http, "Data", Data); 9674 9675 function message(value) { 9676 if (Type.isString(value)) { 9677 if (Type.isNil(message[value])) { 9678 // eslint-disable-next-line 9679 EventEmitter.emit('onBXMessageNotFound', new BaseEvent({ 9680 compatData: [value] 9681 })); 9682 9683 if (Type.isNil(message[value])) { 9684 Runtime.debug(`message undefined: ${value}`); 9685 message[value] = ''; 9686 } 9687 } 9688 } 9689 9690 if (Type.isPlainObject(value)) { 9691 Object.keys(value).forEach(key => { 9692 message[key] = value[key]; 9693 }); 9694 } 9695 9696 return message[value]; 9697 } 9698 9699 if (!Type.isNil(window.BX) && Type.isFunction(window.BX.message)) { 9700 Object.keys(window.BX.message).forEach(key => { 9701 message({ 9702 [key]: window.BX.message[key] 9703 }); 9704 }); 9705 } 9706 9707 /** 9708 * Implements interface for works with language messages 9709 * @memberOf BX 9710 */ 9711 9712 let Loc = /*#__PURE__*/function () { 9713 function Loc() { 9714 babelHelpers.classCallCheck(this, Loc); 9715 } 9716 9717 babelHelpers.createClass(Loc, null, [{ 9718 key: "getMessage", 9719 9720 /** 9721 * Gets message by id 9722 * @param {string} messageId 9723 * @param {object} replacements 9724 * @return {?string} 9725 */ 9726 value: function getMessage(messageId, replacements = null) { 9727 let mess = message(messageId); 9728 9729 if (Type.isString(mess) && Type.isPlainObject(replacements)) { 9730 Object.keys(replacements).forEach(replacement => { 9731 const globalRegexp = new RegExp(replacement, 'gi'); 9732 mess = mess.replace(globalRegexp, () => { 9733 return Type.isNil(replacements[replacement]) ? '' : String(replacements[replacement]); 9734 }); 9735 }); 9736 } 9737 9738 return mess; 9739 } 9740 }, { 9741 key: "hasMessage", 9742 value: function hasMessage(messageId) { 9743 return Type.isString(messageId) && !Type.isNil(message[messageId]); 9744 } 9745 /** 9746 * Sets message or messages 9747 * @param {string | Object<string, string>} id 9748 * @param {string} [value] 9749 */ 9750 9751 }, { 9752 key: "setMessage", 9753 value: function setMessage(id, value) { 9754 if (Type.isString(id) && Type.isString(value)) { 9755 message({ 9756 [id]: value 9757 }); 9758 } 9759 9760 if (Type.isObject(id)) { 9761 message(id); 9762 } 9763 } 9764 /** 9765 * Gets plural message by id and number 9766 * @param {string} messageId 9767 * @param {number} value 9768 * @param {object} [replacements] 9769 * @return {?string} 9770 */ 9771 9772 }, { 9773 key: "getMessagePlural", 9774 value: function getMessagePlural(messageId, value, replacements = null) { 9775 let result = ''; 9776 9777 if (Type.isNumber(value)) { 9778 if (this.hasMessage(`${messageId}_PLURAL_${this.getPluralForm(value)}`)) { 9779 result = this.getMessage(`${messageId}_PLURAL_${this.getPluralForm(value)}`, replacements); 9780 } else { 9781 result = this.getMessage(`${messageId}_PLURAL_1`, replacements); 9782 } 9783 } else { 9784 result = this.getMessage(messageId, replacements); 9785 } 9786 9787 return result; 9788 } 9789 /** 9790 * Gets language plural form id by number 9791 * see http://docs.translatehouse.org/projects/localization-guide/en/latest/l10n/pluralforms.html 9792 * @param {number} value 9793 * @param {string} [languageId] 9794 * @return {?number} 9795 */ 9796 9797 }, { 9798 key: "getPluralForm", 9799 value: function getPluralForm(value, languageId) { 9800 let pluralForm; 9801 9802 if (!Type.isStringFilled(languageId)) { 9803 languageId = message('LANGUAGE_ID'); 9804 } 9805 9806 if (value < 0) { 9807 value = -1 * value; 9808 } 9809 9810 switch (languageId) { 9811 case 'ar': 9812 pluralForm = value !== 1 ? 1 : 0; 9813 /* 9814 if (value === 0) 9815 { 9816 pluralForm = 0; 9817 } 9818 else if (value === 1) 9819 { 9820 pluralForm = 1; 9821 } 9822 else if (value === 2) 9823 { 9824 pluralForm = 2; 9825 } 9826 else if ( 9827 value % 100 >= 3 9828 && value % 100 <= 10 9829 ) 9830 { 9831 pluralForm = 3; 9832 } 9833 else if (value % 100 >= 11) 9834 { 9835 pluralForm = 4; 9836 } 9837 else 9838 { 9839 pluralForm = 5; 9840 } 9841 */ 9842 9843 break; 9844 9845 case 'br': 9846 case 'fr': 9847 case 'tr': 9848 pluralForm = value > 1 ? 1 : 0; 9849 break; 9850 9851 case 'de': 9852 case 'en': 9853 case 'hi': 9854 case 'it': 9855 case 'la': 9856 pluralForm = value !== 1 ? 1 : 0; 9857 break; 9858 9859 case 'ru': 9860 case 'ua': 9861 if (value % 10 === 1 && value % 100 !== 11) { 9862 pluralForm = 0; 9863 } else if (value % 10 >= 2 && value % 10 <= 4 && (value % 100 < 10 || value % 100 >= 20)) { 9864 pluralForm = 1; 9865 } else { 9866 pluralForm = 2; 9867 } 9868 9869 break; 9870 9871 case 'pl': 9872 if (value === 1) { 9873 pluralForm = 0; 9874 } else if (value % 10 >= 2 && value % 10 <= 4 && (value % 100 < 10 || value % 100 >= 20)) { 9875 pluralForm = 1; 9876 } else { 9877 pluralForm = 2; 9878 } 9879 9880 break; 9881 9882 case 'id': 9883 case 'ja': 9884 case 'ms': 9885 case 'sc': 9886 case 'tc': 9887 case 'th': 9888 case 'vn': 9889 pluralForm = 0; 9890 break; 9891 9892 default: 9893 pluralForm = 1; 9894 break; 9895 } 9896 9897 return pluralForm; 9898 } 9899 }]); 9900 return Loc; 9901 }(); 9902 9903 const voidElements = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr']; 9904 function isVoidElement(element) { 9905 return voidElements.includes(element); 9906 } 9907 9908 const matchers = { 9909 tag: /<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>|{{uid[0-9]+}}/g, 9910 comment: /<!--(?!<!)[^\[>].*?-->/g, 9911 tagName: /<\/?([^\s]+?)[/\s>]/, 9912 attributes: /\s([\w\-_:.]+)\s?\n?=\s?\n?"([^"]+)?"|\s([\w\-_:.]+)\s?\n?=\s?\n?'([^']+)?'|\s([\w\-_:.]+)/gs, 9913 placeholder: /{{uid[0-9]+}}/g 9914 }; 9915 9916 function parseTag(tag) { 9917 const tagResult = { 9918 type: 'tag', 9919 name: '', 9920 svg: false, 9921 attrs: {}, 9922 children: [], 9923 voidElement: false 9924 }; 9925 9926 if (tag.startsWith('<!--')) { 9927 const endIndex = tag.indexOf('-->'); 9928 const openTagLength = '<!--'.length; 9929 return { 9930 type: 'comment', 9931 content: endIndex !== -1 ? tag.slice(openTagLength, endIndex) : '' 9932 }; 9933 } 9934
9935 const tagNameMatch = tag.match(matchers.tagName); 9936 9937 if (Type.isArrayFilled(tagNameMatch)) { 9938 const [, tagName] = tagNameMatch; 9939 tagResult.name = tagName; 9940 tagResult.svg = tagName === 'svg'; 9941 tagResult.voidElement = isVoidElement(tagName) || tag.trim().endsWith('/>'); 9942 } 9943 9944 const reg = new RegExp(matchers.attributes); 9945 9946 for (;;) { 9947 const result = reg.exec(tag); 9948 9949 if (!Type.isNil(result)) { 9950 // Attributes with double quotes 9951 const [, attrName, attrValue] = result; 9952 9953 if (!Type.isNil(attrName)) { 9954 tagResult.attrs[attrName] = Type.isStringFilled(attrValue) ? attrValue : ''; 9955 } else { 9956 // Attributes with single quotes 9957 const [,,, attrName, attrValue] = result; 9958 9959 if (!Type.isNil(attrName)) { 9960 tagResult.attrs[attrName] = Type.isStringFilled(attrValue) ? attrValue : ''; 9961 } else { 9962 // Attributes without value 9963 const [,,,,, attrName] = result; 9964 tagResult.attrs[attrName] = ''; 9965 } 9966 } 9967 } else { 9968 break; 9969 } 9970 } 9971 9972 return tagResult; 9973 } 9974 9975 function parseText(input) { 9976 const preparedText = input.replace(/[\n\r\t]$/, ''); 9977 const placeholders = preparedText.match(matchers.placeholder); 9978 return preparedText.split(matchers.placeholder).reduce((acc, item, index) => { 9979 if (Type.isStringFilled(item)) { 9980 acc.push(...item.split(/\n/).reduce((textAcc, text) => { 9981 const preparedItemText = text.replace(/[\t\r]/g, ''); 9982 9983 if (Type.isStringFilled(preparedItemText)) { 9984 textAcc.push({ 9985 type: 'text', 9986 content: preparedItemText 9987 }); 9988 } 9989 9990 return textAcc; 9991 }, [])); 9992 } 9993 9994 if (placeholders && placeholders[index]) { 9995 acc.push({ 9996 type: 'placeholder', 9997 uid: parseInt(placeholders[index].replace(/{{uid|}}/, '')) 9998 }); 9999 } 10000 10001 return acc; 10002 }, []); 10003 } 10004 10005 function parse(html, substitutions) { 10006 const result = []; 10007 10008 if (html.indexOf('<') !== 0 && !html.startsWith('{{')) { 10009 const end = html.indexOf('<'); 10010 result.push(...parseText(end === -1 ? html : html.slice(0, end))); 10011 } 10012 10013 const commentsContent = []; 10014 let commentIndex = -1; 10015 html = html.replace(matchers.comment, tag => { 10016 commentIndex += 1; 10017 commentsContent.push(tag.replace(/^<!--|-->$/g, '')); 10018 return `<!--{{cUid${commentIndex}}}-->`; 10019 }); 10020 const arr = []; 10021 let level = -1; 10022 let current; 10023 html.replace(matchers.tag, (tag, index) => { 10024 const start = index + tag.length; 10025 const nextChar = html.charAt(start); 10026 let parent; 10027 10028 if (tag.startsWith('<!--')) { 10029 const comment = parseTag(tag, substitutions); 10030 comment.content = commentsContent[tag.replace(/<!--{{cUid|}}-->/g, '')]; 10031 10032 if (level < 0) { 10033 result.push(comment); 10034 return result; 10035 } 10036 10037 parent = arr[level]; 10038 parent.children.push(comment); 10039 return result; 10040 } 10041 10042 if (tag.startsWith('{{')) { 10043 const [placeholder] = parseText(tag); 10044 10045 if (level < 0) { 10046 result.push(placeholder); 10047 return result; 10048 } 10049 10050 parent = arr[level]; 10051 parent.children.push(placeholder); 10052 return result; 10053 } 10054 10055 if (!tag.startsWith('</')) { 10056 level++; 10057 current = parseTag(tag, substitutions); 10058 10059 if (!current.voidElement && nextChar && nextChar !== '<') { 10060 current.children.push(...parseText(html.slice(start, html.indexOf('<', start)))); 10061 } 10062 10063 if (level === 0) { 10064 result.push(current); 10065 } 10066 10067 parent = arr[level - 1]; 10068 10069 if (parent) { 10070 if (!current.svg) { 10071 current.svg = parent.svg; 10072 } 10073 10074 parent.children.push(current); 10075 } 10076 10077 arr[level] = current; 10078 } 10079 10080 if (tag.startsWith('</') || current.voidElement) { 10081 if (level > -1 && (current.voidElement || current.name === tag.slice(2, -1))) { 10082 level--; 10083 current = level === -1 ? result : arr[level]; 10084 } 10085 10086 if (nextChar && nextChar !== '<') { 10087 parent = level === -1 ? result : arr[level].children; 10088 const end = html.indexOf('<', start); 10089 const content = html.slice(start, end === -1 ? undefined : end); 10090 10091 if (end >
10091 -1 && level + parent.length >= 0 || content !== ' ') { 10092 parent.push(...parseText(content)); 10093 } 10094 } 10095 } 10096 }); 10097 return result; 10098 } 10099 10100 const appendElement = (current, target) => { 10101 if (Type.isDomNode(current) && Type.isDomNode(target)) { 10102 if (target.nodeName !== 'TEMPLATE') { 10103 Dom.append(current, target); 10104 } else { 10105 // eslint-disable-next-line bitrix-rules/no-native-dom-methods 10106 target.content.append(current); 10107 } 10108 } 10109 }; 10110 10111 function renderNode(options) { 10112 const { 10113 node, 10114 parentElement, 10115 substitutions 10116 } = options; 10117 10118 if (node.type === 'tag') { 10119 const element = (() => { 10120 if (node.svg) { 10121 return document.createElementNS('http://www.w3.org/2000/svg', node.name); 10122 } 10123 10124 return document.createElement(node.name); 10125 })(); 10126 10127 Object.entries(node.attrs).forEach(([key, value]) => { 10128 if (key.startsWith('on') && new RegExp(matchers.placeholder).test(value)) { 10129 const substitution = substitutions[parseInt(value.replace(/{{uid|}}/, '')) - 1]; 10130 10131 if (Type.isFunction(substitution)) { 10132 const bindFunctionName = key.endsWith('once') ? 'bindOnce' : 'bind'; 10133 Event[bindFunctionName](element, key.replace(/^on|once$/g, ''), substitution); 10134 } else { 10135 element.setAttribute(key, substitution); 10136 } 10137 } else { 10138 if (new RegExp(matchers.placeholder).test(value)) { 10139 const preparedValue = value.split(/{{|}}/).reduce((acc, item) => { 10140 if (item.startsWith('uid')) { 10141 const substitution = substitutions[parseInt(item.replace('uid', '')) - 1]; 10142 return `${acc}${substitution}`; 10143 } 10144 10145 return `${acc}${item}`; 10146 }, ''); 10147 element.setAttribute(key, preparedValue); 10148 } else { 10149 element.setAttribute(key, Text.decode(value)); 10150 } 10151 } 10152 }); 10153 node.children.forEach(childNode => { 10154 const result = renderNode({ 10155 node: childNode, 10156 parentElement: element, 10157 substitutions 10158 }); 10159 10160 if (Type.isArray(result)) { 10161 result.forEach(subChildElement => { 10162 appendElement(subChildElement, element); 10163 }); 10164 } else { 10165 appendElement(result, element); 10166 } 10167 }); 10168 return element; 10169 } 10170 10171 if (node.type === 'comment') { 10172 return document.createComment(node.content); 10173 } 10174 10175 if (node.type === 'text') { 10176 if (parentElement) { 10177 if (parentElement.nodeName !== 'TEMPLATE') { 10178 parentElement.insertAdjacentHTML('beforeend', node.content); 10179 } else { 10180 parentElement.content.append(node.content); 10181 } 10182 10183 return; 10184 } 10185 10186 return document.createTextNode(node.content); 10187 } 10188 10189 if (node.type === 'placeholder') { 10190 return substitutions[node.uid - 1]; 10191 } 10192 } 10193 10194 function render(sections, ...substitutions) { 10195 const html = sections.reduce((acc, item, index) => { 10196 if (index > 0) { 10197 const substitution = substitutions[index - 1]; 10198 10199 if (Type.isString(substitution) || Type.isNumber(substitution)) { 10200 return `${acc}${substitution}${item}`; 10201 } 10202 10203 return `${acc}{{uid${index}}}${item}`; 10204 } 10205 10206 return acc; 10207 }, sections[0]).replace(/^[\r\n\t\s]+/gm, '').replace(/>[\n]+/g, '>').replace(/[}][\n]+/g, '}'); 10208 const ast = parse(html); 10209 10210 if (ast.length === 1) { 10211 return renderNode({ 10212 node: ast[0], 10213 substitutions 10214 }); 10215 } 10216 10217 if (ast.length > 1) { 10218 return ast.map(node => { 10219 return renderNode({ 10220 node, 10221 substitutions 10222 }); 10223 }); 10224 } 10225 10226 return false; 10227 } 10228 10229 function parseProps(sections, ...substitutions) { 10230 return substitutions.reduce((acc, item, index) => { 10231 const nextSectionIndex = index + 1; 10232 10233 if (!Type.isPlainObject(item) && !Type.isArray(item)) { 10234 return acc + item + sections[nextSectionIndex]; 10235 } 10236 10237 return `${acc}__s${index}${sections[nextSectionIndex]}`; 10238 }, sections[0]).replace(/[\r\t]/gm, '').split(';\n').map(item => item.replace(/\n/, '')).reduce((acc, item) => { 10239 if (item !== '') { 10240 const matches = item.match(/^[\w-. ]+:/); 10241 const splitted = item.split(/^[\w-. ]+:/);
10242 const key = matches[0].replace(':', '').trim(); 10243 const value = splitted[1].trim(); 10244 const substitutionPlaceholderExp = /^__s\d+/; 10245 10246 if (substitutionPlaceholderExp.test(value)) { 10247 acc[key] = substitutions[value.replace('__s', '')]; 10248 return acc; 10249 } 10250 10251 acc[key] = value; 10252 } 10253 10254 return acc; 10255 }, {}); 10256 } 10257 /** 10258 * @memberOf BX 10259 */ 10260 10261 10262 let Tag = /*#__PURE__*/function () { 10263 function Tag() { 10264 babelHelpers.classCallCheck(this, Tag); 10265 } 10266 10267 babelHelpers.createClass(Tag, null, [{ 10268 key: "safe", 10269 10270 /** 10271 * Encodes all substitutions 10272 * @param sections 10273 * @param substitutions 10274 * @return {string} 10275 */ 10276 value: function safe(sections, ...substitutions) { 10277 return substitutions.reduce((acc, item, index) => acc + Text.encode(item) + sections[index + 1], sections[0]); 10278 } 10279 /** 10280 * Decodes all substitutions 10281 * @param sections 10282 * @param substitutions 10283 * @return {string} 10284 */ 10285 10286 }, { 10287 key: "unsafe", 10288 value: function unsafe(sections, ...substitutions) { 10289 return substitutions.reduce((acc, item, index) => acc + Text.decode(item) + sections[index + 1], sections[0]); 10290 } 10291 /** 10292 * Adds styles to specified element 10293 * @param {HTMLElement} element 10294 * @return {Function} 10295 */ 10296 10297 }, { 10298 key: "style", 10299 value: function style(element) { 10300 if (!Type.isDomNode(element)) { 10301 throw new Error('element is not HTMLElement'); 10302 } 10303 10304 return function styleTagHandler(...args) { 10305 Dom.style(element, parseProps(...args)); 10306 }; 10307 } 10308 /** 10309 * Replace all messages identifiers to real messages 10310 * @param sections 10311 * @param substitutions 10312 * @return {string} 10313 */ 10314 10315 }, { 10316 key: "message", 10317 value: function message(sections, ...substitutions) { 10318 return substitutions.reduce((acc, item, index) => acc + Loc.getMessage(item) + sections[index + 1], sections[0]); 10319 } 10320 }, { 10321 key: "attrs", 10322 10323 /** 10324 * Adds attributes to specified element 10325 * @param element 10326 * @return {Function} 10327 */ 10328 value: function attrs(element) { 10329 if (!Type.isDomNode(element)) { 10330 throw new Error('element is not HTMLElement'); 10331 } 10332 10333 return function attrsTagHandler(...args) { 10334 Dom.attr(element, parseProps(...args)); 10335 }; 10336 } 10337 }]); 10338 return Tag; 10339 }(); 10340 10341 babelHelpers.defineProperty(Tag, "render", render); 10342 babelHelpers.defineProperty(Tag, "attr", Tag.attrs); 10343 10344 function getParser(format) { 10345 switch (format) { 10346 case 'index': 10347 return (sourceKey, value, accumulator) => { 10348 const result = /\[(\w*)\]$/.exec(sourceKey); 10349 const key = sourceKey.replace(/\[\w*\]$/, ''); 10350 10351 if (Type.isNil(result)) { 10352 accumulator[key] = value; 10353 return; 10354 } 10355 10356 if (Type.isUndefined(accumulator[key])) { 10357 accumulator[key] = {}; 10358 } 10359 10360 accumulator[key][result[1]] = value; 10361 }; 10362 10363 case 'bracket': 10364 return (sourceKey, value, accumulator) => { 10365 const result = /(\[\])$/.exec(sourceKey); 10366 const key = sourceKey.replace(/\[\]$/, ''); 10367 10368 if (Type.isNil(result)) { 10369 accumulator[key] = value; 10370 return; 10371 } 10372 10373 if (Type.isUndefined(accumulator[key])) { 10374 accumulator[key] = [value]; 10375 return; 10376 } 10377 10378 accumulator[key] = [].concat(accumulator[key], value); 10379 }; 10380 10381 default: 10382 return (sourceKey, value, accumulator) => { 10383 const key = sourceKey.replace(/\[\]$/, ''); 10384 accumulator[key] = value; 10385 }; 10386 } 10387 } 10388 10389 function getKeyFormat(key) { 10390 if (/^\w+\[([\w]+)\]$/.test(key)) { 10391 return 'index'; 10392 } 10393 10394 if (/^\w+\[\]$/.test(key)) { 10395 return 'bracket'; 10396 } 10397 10398 return 'default'; 10399 } 10400 10401 function parseQuery(input) { 10402 if (!Type.isString(input)) { 10403 return {}; 10404 } 10405 10406 const url = input.trim().replace(/^[?#&]/, ''); 10407 10408 if (!url) { 10409 return {}; 10410 } 10411 10412 return url.split('&').reduce((acc, param) => { 10413 const [key, value] = param.replace(/\+/g, ' ').split('=');
10414 const keyFormat = getKeyFormat(key); 10415 const formatter = getParser(keyFormat); 10416 formatter(key, value, acc); 10417 return acc; 10418 }, {}); 10419 } 10420 10421 const urlExp = /^((\w+):)?(\/\/((\w+)?(:(\w+))?@)?([^\/\?:]+)(:(\d+))?)?(\/?([^\/\?#][^\?#]*)?)?(\?([^#]+))?(#(\w*))?/; 10422 function parseUrl(url) { 10423 const result = url.match(urlExp); 10424 10425 if (Type.isArray(result)) { 10426 const queryParams = parseQuery(result[14]); 10427 return { 10428 useShort: /^\/\//.test(url), 10429 href: result[0] || '', 10430 schema: result[2] || '', 10431 host: result[8] || '', 10432 port: result[10] || '', 10433 path: result[11] || '', 10434 query: result[14] || '', 10435 queryParams, 10436 hash: result[16] || '', 10437 username: result[5] || '', 10438 password: result[7] || '', 10439 origin: result[8] || '' 10440 }; 10441 } 10442 10443 return {}; 10444 } 10445 10446 function buildQueryString(params = {}) { 10447 const queryString = Object.keys(params).reduce((acc, key) => { 10448 if (Type.isArray(params[key])) { 10449 params[key].forEach(paramValue => { 10450 acc.push(`${key}[]=${paramValue}`); 10451 }, ''); 10452 } 10453 10454 if (Type.isPlainObject(params[key])) { 10455 Object.keys(params[key]).forEach(paramIndex => { 10456 acc.push(`${key}[${paramIndex}]=${params[key][paramIndex]}`); 10457 }, ''); 10458 } 10459 10460 if (!Type.isObject(params[key]) && !Type.isArray(params[key])) { 10461 acc.push(`${key}=${params[key]}`); 10462 } 10463 10464 return acc; 10465 }, []).join('&'); 10466 10467 if (queryString.length > 0) { 10468 return `?${queryString}`; 10469 } 10470 10471 return queryString; 10472 } 10473 10474 function prepareParamValue(value) { 10475 if (Type.isArray(value)) { 10476 return value.map(item => String(item)); 10477 } 10478 10479 if (Type.isPlainObject(value)) { 10480 return { ...value 10481 }; 10482 } 10483 10484 return String(value); 10485 } 10486 10487 const map = new WeakMap(); 10488 /** 10489 * Implements interface for works with URI 10490 * @memberOf BX 10491 */ 10492 10493 let Uri = /*#__PURE__*/function () { 10494 babelHelpers.createClass(Uri, null, [{ 10495 key: "addParam", 10496 value: function addParam(url, params = {}) { 10497 return new Uri(url).setQueryParams(params).toString(); 10498 } 10499 }, { 10500 key: "removeParam", 10501 value: function removeParam(url, params) { 10502 const removableParams = Type.isArray(params) ? params : [params]; 10503 return new Uri(url).removeQueryParam(...removableParams).toString(); 10504 } 10505 }]); 10506 10507 function Uri(url = '') { 10508 babelHelpers.classCallCheck(this, Uri); 10509 map.set(this, parseUrl(url)); 10510 } 10511 /** 10512 * Gets schema 10513 * @return {?string} 10514 */ 10515 10516 10517 babelHelpers.createClass(Uri, [{ 10518 key: "getSchema", 10519 value: function getSchema() { 10520 return map.get(this).schema; 10521 } 10522 /** 10523 * Sets schema 10524 * @param {string} schema 10525 * @return {Uri} 10526 */ 10527 10528 }, { 10529 key: "setSchema", 10530 value: function setSchema(schema) { 10531 map.get(this).schema = String(schema); 10532 return this; 10533 } 10534 /** 10535 * Gets host 10536 * @return {?string} 10537 */ 10538 10539 }, { 10540 key: "getHost", 10541 value: function getHost() { 10542 return map.get(this).host; 10543 } 10544 /** 10545 * Sets host 10546 * @param {string} host 10547 * @return {Uri} 10548 */ 10549 10550 }, { 10551 key: "setHost", 10552 value: function setHost(host) { 10553 map.get(this).host = String(host); 10554 return this; 10555 } 10556 /** 10557 * Gets port 10558 * @return {?string} 10559 */ 10560 10561 }, { 10562 key: "getPort", 10563 value: function getPort() { 10564 return map.get(this).port; 10565 } 10566 /** 10567 * Sets port 10568 * @param {String | Number} port 10569 * @return {Uri} 10570 */ 10571 10572 }, { 10573 key: "setPort", 10574 value: function setPort(port) { 10575 map.get(this).port = String(port); 10576 return this; 10577 } 10578 /** 10579 * Gets path 10580 * @return {?string} 10581 */ 10582 10583 }, { 10584 key: "getPath", 10585 value: function getPath() { 10586 return map.get(this).path; 10587 } 10588 /** 10589 * Sets path 10590 * @param {string} path 10591 * @return {Uri} 10592 */ 10593 10594 }, { 10595 key: "setPath", 10596 value: function setPath(path) { 10597 if (!/^\//.test(path)) { 10598 map.get(this).path = `/${String(path)}`; 10599 return this; 10600 } 10601 10602 map.get(this).path = String(path); 10603 return this; 10604 } 10605 /** 10606 * Gets query 10607 * @return {?string} 10608 */ 10609 10610 }, { 10611 key: "getQuery", 10612 value: function getQuery() { 10613 return buildQueryString(map.get(this).queryParams); 10614 } 10615 /** 10616 * Gets query param value by name 10617 * @param {string} key 10618 * @return {?string} 10619 */ 10620 10621 }, { 10622 key: "getQueryParam", 10623 value: function getQueryParam(key) { 10624 const params = this.getQueryParams(); 10625 10626 if (key in params) { 10627 return params[key]; 10628 } 10629 10630 return null; 10631 } 10632 /** 10633 * Sets query param 10634 * @param {string} key 10635 * @param [value] 10636 * @return {Uri} 10637 */ 10638 10639 }, { 10640 key: "setQueryParam", 10641 value: function setQueryParam(key, value = '') { 10642 map.get(this).queryParams[key] = prepareParamValue(value); 10643 return this; 10644 } 10645 /** 10646 * Gets query params 10647 * @return {Object<string, any>} 10648 */ 10649 10650 }, { 10651 key: "getQueryParams", 10652 value: function getQueryParams() { 10653 return { ...map.get(this).queryParams 10654 }; 10655 } 10656 /** 10657 * Sets query params 10658 * @param {Object<string, any>} params 10659 * @return {Uri} 10660 */ 10661 10662 }, { 10663 key: "setQueryParams", 10664 value: function setQueryParams(params = {}) {
10665 const currentParams = this.getQueryParams(); 10666 const newParams = { ...currentParams, 10667 ...params 10668 }; 10669 Object.keys(newParams).forEach(key => { 10670 newParams[key] = prepareParamValue(newParams[key]); 10671 }); 10672 map.get(this).queryParams = newParams; 10673 return this; 10674 } 10675 /** 10676 * Removes query params by name 10677 * @param keys 10678 * @return {Uri} 10679 */ 10680 10681 }, { 10682 key: "removeQueryParam", 10683 value: function removeQueryParam(...keys) { 10684 const currentParams = { ...map.get(this).queryParams 10685 }; 10686 keys.forEach(key => { 10687 if (key in currentParams) { 10688 delete currentParams[key]; 10689 } 10690 }); 10691 map.get(this).queryParams = currentParams; 10692 return this; 10693 } 10694 /** 10695 * Gets fragment 10696 * @return {?string} 10697 */ 10698 10699 }, { 10700 key: "getFragment", 10701 value: function getFragment() { 10702 return map.get(this).hash; 10703 } 10704 /** 10705 * Sets fragment 10706 * @param {string} hash 10707 * @return {Uri} 10708 */ 10709 10710 }, { 10711 key: "setFragment", 10712 value: function setFragment(hash) { 10713 map.get(this).hash = String(hash); 10714 return this; 10715 } 10716 /** 10717 * Serializes URI 10718 * @return {Object} 10719 */ 10720 10721 }, { 10722 key: "serialize", 10723 value: function serialize() { 10724 const serialized = { ...map.get(this) 10725 }; 10726 serialized.href = this.toString(); 10727 return serialized; 10728 } 10729 /** 10730 * Gets URI string 10731 * @return {string} 10732 */ 10733 10734 }, { 10735 key: "toString", 10736 value: function toString() { 10737 const data = { ...map.get(this) 10738 }; 10739 let protocol = data.schema ? `${data.schema}://` : ''; 10740 10741 if (data.useShort) { 10742 protocol = '//'; 10743 } 10744 10745 const port = (() => { 10746 if (Type.isString(data.port) && !['', '80'].includes(data.port)) { 10747 return `:${data.port}`; 10748 } 10749 10750 return ''; 10751 })(); 10752 10753 const host = this.getHost(); 10754 const path = this.getPath(); 10755 const query = buildQueryString(data.queryParams); 10756 const hash = data.hash ? `#${data.hash}` : ''; 10757 return `${host ? protocol : ''}${host}${host ? port : ''}${path}${query}${hash}`; 10758 } 10759 }]); 10760 return Uri; 10761 }(); 10762 10763 /** 10764 * @memberOf BX 10765 */ 10766 let Validation = /*#__PURE__*/function () { 10767 function Validation() { 10768 babelHelpers.classCallCheck(this, Validation); 10769 } 10770 10771 babelHelpers.createClass(Validation, null, [{ 10772 key: "isEmail", 10773 10774 /** 10775 * Checks that value is valid email 10776 * @param value 10777 * @return {boolean} 10778 */ 10779 value: function isEmail(value) { 10780 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])?)*$/; 10781 return exp.test(String(value).toLowerCase()); 10782 } 10783 }]); 10784 return Validation; 10785 }(); 10786 10787 let BaseCache = /*#__PURE__*/function () { 10788 function BaseCache() { 10789 babelHelpers.classCallCheck(this, BaseCache); 10790 babelHelpers.defineProperty(this, "storage", new Map()); 10791 } 10792 10793 babelHelpers.createClass(BaseCache, [{ 10794 key: "get", 10795 10796 /** 10797 * Gets cached value or default value 10798 */ 10799 value: function get(key, defaultValue) { 10800 if (!this.storage.has(key)) { 10801 if (Type.isFunction(defaultValue)) { 10802 return defaultValue(); 10803 } 10804 10805 if (!Type.isUndefined(defaultValue)) { 10806 return defaultValue; 10807 } 10808 } 10809 10810 return this.storage.get(key); 10811 } 10812 /** 10813 * Sets cache entry 10814 */ 10815 10816 }, { 10817 key: "set", 10818 value: function set(key, value) { 10819 this.storage.set(key, value); 10820 } 10821 /** 10822 * Deletes cache entry 10823 */ 10824 10825 }, { 10826 key: "delete", 10827 value: function _delete(key) { 10828 this.storage.delete(key); 10829 } 10830 /** 10831 * Checks that storage contains entry with specified key 10832 */ 10833 10834 }, { 10835 key: "has", 10836 value: function has(key) { 10837 return this.storage.has(key); 10838 } 10839 /** 10840 * Gets cached value if exists, 10841 */ 10842 10843 }, { 10844 key: "remember", 10845 value: function remember(key, defaultValue) { 10846 if (!this.storage.has(key)) { 10847 if (Type.isFunction(defaultValue)) { 10848 this.storage.set(key, defaultValue()); 10849 } else if (!Type.isUndefined(defaultValue)) { 10850 this.storage.set(key, defaultValue); 10851 } 10852 } 10853 10854 return this.storage.get(key); 10855 } 10856 /** 10857 * Gets storage size 10858 */ 10859 10860 }, { 10861 key: "size", 10862 value: function size() { 10863 return this.storage.size; 10864 } 10865 /** 10866 * Gets storage keys 10867 */ 10868 10869 }, { 10870 key: "keys", 10871 value: function keys() { 10872 return [...this.storage.keys()]; 10873 } 10874 /** 10875 * Gets storage values 10876 */ 10877 10878 }, { 10879 key: "values", 10880 value: function values() { 10881 return [...this.storage.values()]; 10882 } 10883 }]); 10884 return BaseCache; 10885 }(); 10886 10887 let MemoryCache = /*#__PURE__*/function (_BaseCache) { 10888 babelHelpers.inherits(MemoryCache, _BaseCache); 10889 10890 function MemoryCache(...args) { 10891 var _this; 10892 10893 babelHelpers.classCallCheck(this, MemoryCache); 10894 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(MemoryCache).call(this, ...args)); 10895 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "storage", new Map()); 10896 return _this; 10897 } 10898 10899 return MemoryCache; 10900 }(BaseCache); 10901 10902 let LsStorage = /*#__PURE__*/function () { 10903 function LsStorage() { 10904 babelHelpers.classCallCheck(this, LsStorage); 10905 babelHelpers.defineProperty(this, "stackKey", 'BX.Cache.Storage.LsStorage.stack'); 10906 babelHelpers.defineProperty(this, "stack", null); 10907 } 10908 10909 babelHelpers.createClass(LsStorage, [{ 10910 key: "getStack", 10911 10912 /** 10913 * @private 10914 */ 10915 value: function getStack() { 10916 if (Type.isPlainObject(this.stack)) { 10917 return this.stack; 10918 } 10919 10920 const stack = localStorage.getItem(this.stackKey); 10921 10922 if (Type.isString(stack) && stack !== '') { 10923 const parsedStack = JSON.parse(stack); 10924 10925 if (Type.isPlainObject(parsedStack)) { 10926 this.stack = parsedStack; 10927 return this.stack; 10928 } 10929 } 10930 10931 this.stack = {}; 10932 return this.stack; 10933 } 10934 /** 10935 * @private 10936 */ 10937 10938 }, { 10939 key: "saveStack", 10940 value: function saveStack() { 10941 if (Type.isPlainObject(this.stack)) { 10942 const preparedStack = JSON.stringify(this.stack); 10943 localStorage.setItem(this.stackKey, preparedStack); 10944 } 10945 } 10946 }, { 10947 key: "get", 10948 value: function get(key) {
10949 const stack = this.getStack(); 10950 return stack[key]; 10951 } 10952 }, { 10953 key: "set", 10954 value: function set(key, value) { 10955 const stack = this.getStack(); 10956 stack[key] = value; 10957 this.saveStack(); 10958 } 10959 }, { 10960 key: "delete", 10961 value: function _delete(key) { 10962 const stack = this.getStack(); 10963 10964 if (key in stack) { 10965 delete stack[key]; 10966 } 10967 } 10968 }, { 10969 key: "has", 10970 value: function has(key) { 10971 const stack = this.getStack(); 10972 return key in stack; 10973 } 10974 }, { 10975 key: "keys", 10976 value: function keys() { 10977 const stack = this.getStack(); 10978 return Object.keys(stack); 10979 } 10980 }, { 10981 key: "values", 10982 value: function values() { 10983 const stack = this.getStack(); 10984 return Object.values(stack); 10985 } 10986 }, { 10987 key: "size", 10988 get: function () { 10989 const stack = this.getStack(); 10990 return Object.keys(stack).length; 10991 } 10992 }]); 10993 return LsStorage; 10994 }(); 10995 10996 let LocalStorageCache = /*#__PURE__*/function (_BaseCache) { 10997 babelHelpers.inherits(LocalStorageCache, _BaseCache); 10998 10999 function LocalStorageCache(...args) { 11000 var _this; 11001 11002 babelHelpers.classCallCheck(this, LocalStorageCache); 11003 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(LocalStorageCache).call(this, ...args)); 11004 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "storage", new LsStorage()); 11005 return _this; 11006 } 11007 11008 return LocalStorageCache; 11009 }(BaseCache); 11010 11011 /** 11012 * @memberOf BX 11013 */ 11014 11015 let Cache = function Cache() { 11016 babelHelpers.classCallCheck(this, Cache); 11017 }; 11018 11019 babelHelpers.defineProperty(Cache, "MemoryCache", MemoryCache); 11020 babelHelpers.defineProperty(Cache, "LocalStorageCache", LocalStorageCache); 11021 11022 function convertPath(path) { 11023 if (Type.isStringFilled(path)) { 11024 return path.split('.').reduce((acc, item) => { 11025 item.split(/\[['"]?(.+?)['"]?\]/g).forEach(key => { 11026 if (Type.isStringFilled(key)) { 11027 acc.push(key); 11028 } 11029 }); 11030 return acc; 11031 }, []); 11032 } 11033 11034 return []; 11035 } 11036 11037 let SettingsCollection = /*#__PURE__*/function () { 11038 function SettingsCollection(options = {}) { 11039 babelHelpers.classCallCheck(this, SettingsCollection); 11040 11041 if (Type.isPlainObject(options)) { 11042 Object.assign(this, options); 11043 } 11044 } 11045 11046 babelHelpers.createClass(SettingsCollection, [{ 11047 key: "get", 11048 value: function get(path, defaultValue = null) { 11049 const convertedPath = convertPath(path); 11050 return convertedPath.reduce((acc, key) => { 11051 if (!Type.isNil(acc) && acc !== defaultValue) { 11052 if (!Type.isUndefined(acc[key])) { 11053 return acc[key]; 11054 } 11055 11056 return defaultValue; 11057 } 11058 11059 return acc; 11060 }, this); 11061 } 11062 }]); 11063 return SettingsCollection; 11064 }(); 11065 11066 function deepFreeze(target) { 11067 if (Type.isObject(target)) { 11068 Object.values(target).forEach(value => { 11069 deepFreeze(value); 11070 }); 11071 return Object.freeze(target); 11072 } 11073 11074 return target; 11075 } 11076 11077 const settingsStorage = new Map(); 11078 11079 let Extension$1 = /*#__PURE__*/function () { 11080 function Extension() { 11081 babelHelpers.classCallCheck(this, Extension); 11082 } 11083 11084 babelHelpers.createClass(Extension, null, [{ 11085 key: "getSettings", 11086 value: function getSettings(extensionName) { 11087 if (Type.isStringFilled(extensionName)) { 11088 if (settingsStorage.has(extensionName)) { 11089 return settingsStorage.get(extensionName); 11090 } 11091 11092 const settingsScriptNode = document.querySelector(`script[data-extension="${extensionName}"]`); 11093 11094 if (Type.isDomNode(settingsScriptNode)) { 11095 const decodedSettings = (() => { 11096 try { 11097 return new SettingsCollection(JSON.parse(settingsScriptNode.innerHTML)); 11098 } catch (error) { 11099 return new SettingsCollection(); 11100 } 11101 })(); 11102 11103 const frozenSettings = deepFreeze(decodedSettings); 11104 settingsStorage.set(extensionName, frozenSettings); 11105 return frozenSettings; 11106 } 11107 } 11108 11109 return deepFreeze(new SettingsCollection()); 11110 } 11111 }]); 11112 return Extension; 11113 }(); 11114 11115 let _Symbol$iterator; 11116 11117 function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); } 11118 11119 function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } } 11120 11121 function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; } 11122 11123 var _searchIndexToInsert = /*#__PURE__*/new WeakSet(); 11124 11125 _Symbol$iterator = Symbol.iterator; 11126 11127 let OrderedArray = /*#__PURE__*/function () { 11128 function OrderedArray(comparator = null) { 11129 babelHelpers.classCallCheck(this, OrderedArray); 11130 11131 _classPrivateMethodInitSpec(this, _searchIndexToInsert); 11132 11133 babelHelpers.defineProperty(this, "comparator", null); 11134 babelHelpers.defineProperty(this, "items", []); 11135 this.comparator = Type.isFunction(comparator) ? comparator : null; 11136 } 11137 11138 babelHelpers.createClass(OrderedArray, [{ 11139 key: "add", 11140 value: function add(item) { 11141 let index = -1; 11142 11143 if (this.comparator) { 11144 index = _classPrivateMethodGet(this, _searchIndexToInsert, _searchIndexToInsert2).call(this, item); 11145 this.items.splice(index, 0, item); 11146 } else { 11147 this.items.push(item); 11148 } 11149 11150 return index; 11151 } 11152 }, { 11153 key: "has", 11154 value: function has(item) { 11155 return this.items.includes(item); 11156 } 11157 }, { 11158 key: "getIndex", 11159 value: function getIndex(item) { 11160 return this.items.indexOf(item); 11161 } 11162 }, { 11163 key: "getByIndex", 11164 value: function getByIndex(index) { 11165 if (Type.isNumber(index) && index >= 0) { 11166 const item = this.items[index]; 11167 return Type.isUndefined(item) ? null : item; 11168 } 11169 11170 return null; 11171 } 11172 }, { 11173 key: "getFirst", 11174 value: function getFirst() { 11175 const first = this.items[0]; 11176 return Type.isUndefined(first) ? null : first; 11177 } 11178 }, { 11179 key: "getLast", 11180 value: function getLast() { 11181 const last = this.items[this.count() - 1]; 11182 return Type.isUndefined(last) ? null : last; 11183 } 11184 }, { 11185 key: "count", 11186 value: function count() { 11187 return this.items.length; 11188 } 11189 }, { 11190 key: "delete", 11191 value: function _delete(item) { 11192 const index = this.getIndex(item); 11193 11194 if (index !== -1) { 11195 this.items.splice(index, 1); 11196 return true; 11197 } 11198 11199 return false;
11200 } 11201 }, { 11202 key: "clear", 11203 value: function clear() { 11204 this.items = []; 11205 } 11206 }, { 11207 key: _Symbol$iterator, 11208 value: function () { 11209 return this.items[Symbol.iterator](); 11210 } 11211 }, { 11212 key: "forEach", 11213 value: function forEach(callbackfn, thisArg) { 11214 return this.items.forEach(callbackfn, thisArg); 11215 } 11216 }, { 11217 key: "getAll", 11218 value: function getAll() { 11219 return this.items; 11220 } 11221 }, { 11222 key: "getComparator", 11223 value: function getComparator() { 11224 return this.comparator; 11225 } 11226 }, { 11227 key: "sort", 11228 value: function sort() { 11229 const comparator = this.getComparator(); 11230 11231 if (comparator === null) { 11232 return; 11233 } 11234 /* 11235 Simple implementation 11236 this.items.sort((item1, item2) => { 11237 return comparator(item1, item2); 11238 }); 11239 */ 11240 // For stable sorting https://v8.dev/features/stable-sort 11241 11242 11243 const length = this.items.length; 11244 const indexes = new Array(length); 11245 11246 for (let i = 0; i < length; i++) { 11247 indexes[i] = i; 11248 } // If the comparator returns zero, use the original indexes 11249 11250 11251 indexes.sort((index1, index2) => { 11252 return comparator(this.items[index1], this.items[index2]) || index1 - index2; 11253 }); 11254 11255 for (let i = 0; i < length; i++) { 11256 indexes[i] = this.items[indexes[i]]; 11257 } 11258 11259 for (let i = 0; i < length; i++) { 11260 this.items[i] = indexes[i]; 11261 } 11262 } 11263 }]); 11264 return OrderedArray; 11265 }(); 11266 11267 function _searchIndexToInsert2(value) { 11268 let low = 0; 11269 let high = this.items.length; 11270 11271 while (low < high) { 11272 const mid = Math.floor((low + high) / 2); 11273 11274 if (this.comparator(this.items[mid], value) >= 0) { 11275 high = mid; 11276 } else { 11277 low = mid + 1; 11278 } 11279 } 11280 11281 return low; 11282 } 11283 11284 let ZIndexComponent = /*#__PURE__*/function (_EventEmitter) { 11285 babelHelpers.inherits(ZIndexComponent, _EventEmitter); 11286 11287 function ZIndexComponent(element, componentOptions = {}) { 11288 var _this; 11289 11290 babelHelpers.classCallCheck(this, ZIndexComponent); 11291 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(ZIndexComponent).call(this)); 11292 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "sort", 0); 11293 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "alwaysOnTop", false); 11294 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "zIndex", 0); 11295 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "element", null); 11296 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "overlay", null); 11297 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "overlayGap", -5); 11298 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "stack", null); 11299 11300 _this.setEventNamespace('BX.Main.ZIndexManager.Component'); 11301 11302 if (!Type.isElementNode(element)) { 11303 throw new Error('ZIndexManager.Component: The argument \'element\' must be a DOM element.'); 11304 } 11305 11306 _this.element = element; 11307 const options = Type.isPlainObject(componentOptions) ? componentOptions : {}; 11308 11309 _this.setAlwaysOnTop(options.alwaysOnTop); 11310 11311 _this.setOverlay(options.overlay); 11312 11313 _this.setOverlayGap(options.overlayGap); 11314 11315 _this.subscribeFromOptions(options.events); 11316 11317 return _this; 11318 } 11319 11320 babelHelpers.createClass(ZIndexComponent, [{ 11321 key: "getSort", 11322 value: function getSort() { 11323 return this.sort; 11324 } 11325 /** 11326 * @internal 11327 * @param sort 11328 */ 11329 11330 }, { 11331 key: "setSort", 11332 value: function setSort(sort) { 11333 if (Type.isNumber(sort)) { 11334 this.sort = sort; 11335 } 11336 } 11337 /** 11338 * @internal 11339 * @param stack 11340 */ 11341 11342 }, { 11343 key: "setStack", 11344 value: function setStack(stack) { 11345 this.stack = stack; 11346 } 11347 }, { 11348 key: "getStack", 11349 value: function getStack() { 11350 return this.stack; 11351 } 11352 }, { 11353 key: "getZIndex", 11354 value: function getZIndex() { 11355 return this.zIndex; 11356 } 11357 /** 11358 * @internal 11359 */ 11360 11361 }, { 11362 key: "setZIndex", 11363 value: function setZIndex(zIndex) { 11364 const changed = this.getZIndex() !== zIndex; 11365 this.getElement().style.setProperty('z-index', zIndex, 'important'); 11366 this.zIndex = zIndex; 11367 11368 if (this.getOverlay() !== null) { 11369 this.getOverlay().style.setProperty('z-index', zIndex + this.getOverlayGap(), 'important'); 11370 } 11371 11372 if (changed) {
11373 this.emit('onZIndexChange', { 11374 component: this 11375 }); 11376 } 11377 } 11378 }, { 11379 key: "getAlwaysOnTop", 11380 value: function getAlwaysOnTop() { 11381 return this.alwaysOnTop; 11382 } 11383 }, { 11384 key: "setAlwaysOnTop", 11385 value: function setAlwaysOnTop(value) { 11386 if (Type.isNumber(value) || Type.isBoolean(value)) { 11387 this.alwaysOnTop = value; 11388 } 11389 } 11390 }, { 11391 key: "getElement", 11392 value: function getElement() { 11393 return this.element; 11394 } 11395 }, { 11396 key: "setOverlay", 11397 value: function setOverlay(overlay, gap) { 11398 if (Type.isElementNode(overlay) || overlay === null) { 11399 this.overlay = overlay; 11400 this.setOverlayGap(gap); 11401 11402 if (this.getStack()) { 11403 this.getStack().sort(); 11404 } 11405 } 11406 } 11407 }, { 11408 key: "getOverlay", 11409 value: function getOverlay() { 11410 return this.overlay; 11411 } 11412 }, { 11413 key: "setOverlayGap", 11414 value: function setOverlayGap(gap) { 11415 if (Type.isNumber(gap)) { 11416 this.overlayGap = gap; 11417 } 11418 } 11419 }, { 11420 key: "getOverlayGap", 11421 value: function getOverlayGap() { 11422 return this.overlayGap; 11423 } 11424 }]); 11425 return ZIndexComponent; 11426 }(EventEmitter); 11427 11428 let ZIndexStack = /*#__PURE__*/function () { 11429 function ZIndexStack(container) { 11430 babelHelpers.classCallCheck(this, ZIndexStack); 11431 babelHelpers.defineProperty(this, "container", null); 11432 babelHelpers.defineProperty(this, "components", null); 11433 babelHelpers.defineProperty(this, "elements", new WeakMap()); 11434 babelHelpers.defineProperty(this, "baseIndex", 1000); 11435 babelHelpers.defineProperty(this, "baseStep", 50); 11436 babelHelpers.defineProperty(this, "sortCount", 0); 11437 11438 if (!Type.isDomNode(container)) { 11439 throw new Error('ZIndexManager.Stack: The \'container\' argument must be a DOM element.'); 11440 } 11441 11442 this.container = container; 11443 11444 const comparator = (componentA, componentB) => { 11445 let result = (componentA.getAlwaysOnTop() || 0) - (componentB.getAlwaysOnTop() || 0); 11446 11447 if (!result) { 11448 result = componentA.getSort() - componentB.getSort(); 11449 } 11450 11451 return result; 11452 }; 11453 11454 this.components = new OrderedArray(comparator); 11455 } 11456 11457 babelHelpers.createClass(ZIndexStack, [{ 11458 key: "getBaseIndex", 11459 value: function getBaseIndex() { 11460 return this.baseIndex; 11461 } 11462 }, { 11463 key: "setBaseIndex", 11464 value: function setBaseIndex(index) { 11465 if (Type.isNumber(index) && index >= 0) { 11466 this.baseIndex = index; 11467 this.sort(); 11468 } 11469 } 11470 }, { 11471 key: "setBaseStep", 11472 value: function setBaseStep(step) { 11473 if (Type.isNumber(step) && step > 0) { 11474 this.baseStep = step; 11475 this.sort(); 11476 } 11477 } 11478 }, { 11479 key: "getBaseStep", 11480 value: function getBaseStep() { 11481 return this.baseStep; 11482 } 11483 }, { 11484 key: "register", 11485 value: function register(element, options = {}) { 11486 if (this.getComponent(element)) { 11487 console.warn('ZIndexManager: You cannot register the element twice.', element); 11488 return this.getComponent(element); 11489 } 11490 11491 const component = new ZIndexComponent(element, options); 11492 component.setStack(this); 11493 component.setSort(++this.sortCount); 11494 this.elements.set(element, component); 11495 this.components.add(component); 11496 this.sort(); 11497 return component; 11498 } 11499 }, { 11500 key: "unregister", 11501 value: function unregister(element) { 11502 const component = this.elements.get(element); 11503 this.components.delete(component); 11504 this.elements.delete(element); 11505 this.sort(); 11506 } 11507 }, { 11508 key: "getComponent", 11509 value: function getComponent(element) { 11510 return this.elements.get(element) || null; 11511 } 11512 }, { 11513 key: "getComponents", 11514 value: function getComponents() { 11515 return this.components.getAll(); 11516 } 11517 }, { 11518 key: "getMaxZIndex", 11519 value: function getMaxZIndex() { 11520 const last = this.components.getLast(); 11521 return last ? last.getZIndex() : this.baseIndex; 11522 } 11523 }, { 11524 key: "sort", 11525 value: function sort() { 11526 this.components.sort(); 11527 let zIndex = this.baseIndex;
11528 this.components.forEach(component => { 11529 component.setZIndex(zIndex); 11530 zIndex += this.baseStep; 11531 }); 11532 } 11533 }, { 11534 key: "bringToFront", 11535 value: function bringToFront(element) { 11536 const component = this.getComponent(element); 11537 11538 if (!component) { 11539 console.error('ZIndexManager: element was not found in the stack.', element); 11540 return null; 11541 } 11542 11543 component.setSort(++this.sortCount); 11544 this.sort(); 11545 return component; 11546 } 11547 }]); 11548 return ZIndexStack; 11549 }(); 11550 11551 function _classStaticPrivateMethodGet(receiver, classConstructor, method) { _classCheckPrivateStaticAccess(receiver, classConstructor); return method; } 11552 11553 function _classCheckPrivateStaticAccess(receiver, classConstructor) { if (receiver !== classConstructor) { throw new TypeError("Private static access of wrong provenance"); } } 11554 11555 /** 11556 * @memberof BX 11557 */ 11558 let ZIndexManager = /*#__PURE__*/function () { 11559 function ZIndexManager() { 11560 babelHelpers.classCallCheck(this, ZIndexManager); 11561 } 11562 11563 babelHelpers.createClass(ZIndexManager, null, [{ 11564 key: "register", 11565 value: function register(element, options = {}) { 11566 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element); 11567 11568 if (!parentNode) { 11569 return null; 11570 } 11571 11572 const stack = this.getOrAddStack(parentNode); 11573 return stack.register(element, options); 11574 } 11575 }, { 11576 key: "unregister", 11577 value: function unregister(element) { 11578 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element); 11579 11580 const stack = this.getStack(parentNode); 11581 11582 if (stack) { 11583 stack.unregister(element); 11584 } 11585 } 11586 }, { 11587 key: "addStack", 11588 value: function addStack(container) { 11589 const stack = new ZIndexStack(container); 11590 this.stacks.set(container, stack); 11591 return stack; 11592 } 11593 }, { 11594 key: "getStack", 11595 value: function getStack(container) { 11596 return this.stacks.get(container) || null; 11597 } 11598 }, { 11599 key: "getOrAddStack", 11600 value: function getOrAddStack(container) { 11601 return this.getStack(container) || this.addStack(container); 11602 } 11603 }, { 11604 key: "getComponent", 11605 value: function getComponent(element) { 11606 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element, true); 11607 11608 if (!parentNode) { 11609 return null; 11610 } 11611 11612 const stack = this.getStack(parentNode); 11613 return stack ? stack.getComponent(element) : null; 11614 } 11615 }, { 11616 key: "bringToFront", 11617 value: function bringToFront(element) { 11618 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element); 11619 11620 const stack = this.getStack(parentNode); 11621 11622 if (stack) { 11623 return stack.bringToFront(element); 11624 } 11625 11626 return null; 11627 } 11628 }]); 11629 return ZIndexManager; 11630 }(); 11631 11632 function _getParentNode(element, suppressWarnings = false) { 11633 if (!Type.isElementNode(element)) { 11634 if (!suppressWarnings) { 11635 console.error('ZIndexManager: The argument \'element\' must be a DOM element.', element); 11636 } 11637 11638 return null; 11639 } else if (!Type.isElementNode(element.parentNode)) { 11640 if (!suppressWarnings) { 11641 console.error('ZIndexManager: The \'element\' doesn\'t have a parent node.', element); 11642 } 11643 11644 return null; 11645 } 11646 11647 return element.parentNode; 11648 } 11649 11650 babelHelpers.defineProperty(ZIndexManager, "stacks", new WeakMap()); 11651 11652 var collections = { 11653 OrderedArray 11654 }; 11655 11656 function getElement(element) { 11657 if (Type.isString(element)) { 11658 return document.getElementById(element); 11659 } 11660 11661 return element; 11662 } 11663 11664 function getWindow(element) { 11665 if (Type.isElementNode(element)) { 11666 return element.ownerDocument.parentWindow || element.ownerDocument.defaultView || window; 11667 } 11668 11669 if (Type.isDomNode(element)) { 11670 return element.parentWindow || element.defaultView || window; 11671 } 11672 11673 return window; 11674 } 11675 11676 /* eslint-disable prefer-rest-params */ 11677 11678 const { 11679 getClass, 11680 namespace 11681 } = Reflection; 11682 const message$1 = message; 11683 /** 11684 * @memberOf BX 11685 */ 11686 11687 const { 11688 replace, 11689 remove, 11690 clean, 11691 insertBefore, 11692 insertAfter, 11693 append, 11694 prepend, 11695 style, 11696 adjust, 11697 create, 11698 isShown 11699 } = Dom; 11700 const addClass = function addClass() { 11701 Dom.addClass(...Runtime.merge([], Array.from(arguments), [getElement(arguments[0])])); 11702 }; 11703 const removeClass = function removeClass() { 11704 Dom.removeClass(...Runtime.merge(Array.from(arguments), [getElement(arguments[0])])); 11705 }; 11706 const hasClass = function hasClass() { 11707 return Dom.hasClass(...Runtime.merge(Array.from(arguments), [getElement(arguments[0])])); 11708 }; 11709 const toggleClass = function toggleClass() { 11710 Dom.toggleClass(...Runtime.merge(Array.from(arguments), [getElement(arguments[0])])); 11711 }; 11712 const cleanNode = (element, removeElement = false) => { 11713 const currentElement = getElement(element); 11714 11715 if (Type.isDomNode(currentElement)) { 11716 Dom.clean(currentElement); 11717 11718 if (removeElement) { 11719 Dom.remove(currentElement); 11720 return currentElement; 11721 } 11722 } 11723 11724 return currentElement; 11725 }; 11726 const getCookie = Http.Cookie.get;
11727 const setCookie = (name, value, options = {}) => { 11728 const attributes = { ...options 11729 }; 11730 11731 if (Type.isNumber(attributes.expires)) { 11732 attributes.expires /= 3600 * 24; 11733 } 11734 11735 Http.Cookie.set(name, value, attributes); 11736 }; 11737 const { 11738 bind: bind$1, 11739 unbind: unbind$1, 11740 unbindAll: unbindAll$1, 11741 bindOnce: bindOnce$1, 11742 ready: ready$1 11743 } = Event; 11744 const { 11745 debugState: debugEnableFlag, 11746 isDebugEnabled: debugStatus, 11747 default: debug$1 11748 } = debugNs; 11749 const debugEnable = value => { 11750 if (value) { 11751 enableDebug(); 11752 } else { 11753 disableDebug(); 11754 } 11755 }; 11756 const { 11757 clone: clone$1, 11758 loadExtension: loadExt, 11759 debounce, 11760 throttle, 11761 html 11762 } = Runtime; // BX.type 11763 11764 const type = { ...Object.getOwnPropertyNames(Type).filter(key => !['name', 'length', 'prototype', 'caller', 'arguments'].includes(key)).reduce((acc, key) => { 11765 acc[key] = Type[key]; 11766 return acc; 11767 }, {}), 11768 isNotEmptyString: value => Type.isString(value) && value !== '', 11769 isNotEmptyObject: value => Type.isObjectLike(value) && Object.keys(value).length > 0, 11770 isMapKey: Type.isObject, 11771 stringToInt: value => { 11772 const parsed = parseInt(value); 11773 return !Number.isNaN(parsed) ? parsed : 0; 11774 } 11775 }; // BX.browser 11776 11777 const browser = { 11778 IsOpera: Browser.isOpera, 11779 IsIE: Browser.isIE, 11780 IsIE6: Browser.isIE6, 11781 IsIE7: Browser.isIE7, 11782 IsIE8: Browser.isIE8, 11783 IsIE9: Browser.isIE9, 11784 IsIE10: Browser.isIE10, 11785 IsIE11: Browser.isIE11, 11786 IsSafari: Browser.isSafari, 11787 IsFirefox: Browser.isFirefox, 11788 IsChrome: Browser.isChrome, 11789 DetectIeVersion: Browser.detectIEVersion, 11790 IsMac: Browser.isMac, 11791 IsAndroid: Browser.isAndroid, 11792 isIPad: Browser.isIPad, 11793 isIPhone: Browser.isIPhone, 11794 IsIOS: Browser.isIOS, 11795 IsMobile: Browser.isMobile, 11796 isRetina: Browser.isRetina, 11797 IsDoctype: Browser.isDoctype, 11798 SupportLocalStorage: Browser.isLocalStorageSupported, 11799 addGlobalClass: Browser.addGlobalClass, 11800 DetectAndroidVersion: Browser.detectAndroidVersion, 11801 isPropertySupported: Browser.isPropertySupported, 11802 addGlobalFeatures: Browser.addGlobalFeatures 11803 }; // eslint-disable-next-line 11804 11805 const ajax = window.BX ? window.BX.ajax : () => {}; 11806 function GetWindowScrollSize(doc = document) { 11807 return { 11808 scrollWidth: doc.documentElement.scrollWidth, 11809 scrollHeight: doc.documentElement.scrollHeight 11810 }; 11811 } 11812 function GetWindowScrollPos(doc = document) { 11813 const win = getWindow(doc); 11814 return { 11815 scrollLeft: win.pageXOffset, 11816 scrollTop: win.pageYOffset 11817 }; 11818 } 11819 function GetWindowInnerSize(doc = document) { 11820 const win = getWindow(doc); 11821 return { 11822 innerWidth: win.innerWidth, 11823 innerHeight: win.innerHeight 11824 }; 11825 } 11826 function GetWindowSize(doc = document) { 11827 return { ...GetWindowInnerSize(doc), 11828 ...GetWindowScrollPos(doc), 11829 ...GetWindowScrollSize(doc) 11830 }; 11831 } 11832 function GetContext(node) { 11833 return getWindow(node); 11834 } 11835 function pos(element, relative = false) { 11836 if (!element) { 11837 return new DOMRect().toJSON(); 11838 } 11839 11840 if (element.ownerDocument === document && !relative) { 11841 const clientRect = element.getBoundingClientRect(); 11842 const root = document.documentElement; 11843 const { 11844 body 11845 } = document; 11846 return { 11847 top: Math.round(clientRect.top + (root.scrollTop || body.scrollTop)), 11848 left: Math.round(clientRect.left + (root.scrollLeft || body.scrollLeft)), 11849 width: Math.round(clientRect.right - clientRect.left), 11850 height: Math.round(clientRect.bottom - clientRect.top), 11851 right: Math.round(clientRect.right + (root.scrollLeft || body.scrollLeft)), 11852 bottom: Math.round(clientRect.bottom + (root.scrollTop || body.scrollTop)) 11853 }; 11854 } 11855 11856 let x = 0; 11857 let y = 0; 11858 const w = element.offsetWidth; 11859 const h = element.offsetHeight; 11860 let first = true; // eslint-disable-next-line no-param-reassign 11861 11862 for (; element != null; element = element.offsetParent) { 11863 if (!first && relative && BX.is_relative(element)) { 11864 break; 11865 } 11866 11867 x += element.offsetLeft; 11868 y += element.offsetTop; 11869 11870 if (first) { 11871 first = false; // eslint-disable-next-line no-continue 11872 11873 continue; 11874 } 11875 11876 x += Text.toNumber(Dom.style(element, 'border-left-width')); 11877 y += Text.toNumber(Dom.style(element, 'border-top-width')); 11878 } 11879 11880 return new DOMRect(x, y, w, h).toJSON(); 11881 } 11882 function addCustomEvent(eventObject, eventName, eventHandler) { 11883 if (Type.isString(eventObject)) { 11884 eventHandler = eventName; 11885 eventName = eventObject; 11886 eventObject = EventEmitter.GLOBAL_TARGET;
11887 } 11888 11889 if (eventObject === window) { 11890 eventObject = EventEmitter.GLOBAL_TARGET; 11891 } 11892 11893 if (!Type.isObject(eventObject)) { 11894 console.error('The "eventObject" argument must be an object. Received type ' + typeof eventObject + '.'); 11895 return; 11896 } 11897 11898 if (!Type.isStringFilled(eventName)) { 11899 console.error('The "eventName" argument must be a string.'); 11900 return; 11901 } 11902 11903 if (!Type.isFunction(eventHandler)) { 11904 console.error('The "eventHandler" argument must be a function. Received type ' + typeof eventHandler + '.'); 11905 return; 11906 } 11907 11908 eventName = eventName.toLowerCase(); 11909 EventEmitter.subscribe(eventObject, eventName, eventHandler, { 11910 compatMode: true, 11911 useGlobalNaming: true 11912 }); 11913 } 11914 function onCustomEvent(eventObject, eventName, eventParams, secureParams) { 11915 if (Type.isString(eventObject)) { 11916 secureParams = eventParams; 11917 eventParams = eventName; 11918 eventName = eventObject; 11919 eventObject = EventEmitter.GLOBAL_TARGET; 11920 } 11921 11922 if (!Type.isObject(eventObject) || eventObject === window) { 11923 eventObject = EventEmitter.GLOBAL_TARGET;
11924 } 11925 11926 if (!eventParams) { 11927 eventParams = []; 11928 } 11929 11930 eventName = eventName.toLowerCase(); 11931 const event = new BaseEvent(); 11932 event.setData(eventParams); 11933 event.setCompatData(eventParams); 11934 EventEmitter.emit(eventObject, eventName, event, { 11935 cloneData: secureParams === true, 11936 useGlobalNaming: true 11937 }); 11938 } 11939 function removeCustomEvent(eventObject, eventName, eventHandler) { 11940 if (Type.isString(eventObject)) { 11941 eventHandler = eventName; 11942 eventName = eventObject; 11943 eventObject = EventEmitter.GLOBAL_TARGET; 11944 } 11945 11946 if (!Type.isFunction(eventHandler)) { 11947 console.error('The "eventHandler" argument must be a function. Received type ' + typeof eventHandler + '.'); 11948 return; 11949 } 11950 11951 if (eventObject === window) { 11952 eventObject = EventEmitter.GLOBAL_TARGET; 11953 } 11954 11955 eventName = eventName.toLowerCase(); 11956 EventEmitter.unsubscribe(eventObject, eventName, eventHandler, { 11957 useGlobalNaming: true 11958 }); 11959 } 11960 function removeAllCustomEvents(eventObject, eventName) { 11961 if (Type.isString(eventObject)) { 11962 eventName = eventObject; 11963 eventObject = EventEmitter.GLOBAL_TARGET;
11964 } 11965 11966 if (eventObject === window) { 11967 eventObject = EventEmitter.GLOBAL_TARGET; 11968 } 11969 11970 eventName = eventName.toLowerCase(); 11971 EventEmitter.unsubscribeAll(eventObject, eventName, { 11972 useGlobalNaming: true 11973 }); 11974 } 11975 11976 if (typeof global === 'object' && global.window && global.window.BX) { 11977 Object.assign(global.window.BX, exports); 11978 } 11979 11980 exports.Type = Type; 11981 exports.Reflection = Reflection; 11982 exports.Text = Text; 11983 exports.Dom = Dom; 11984 exports.Browser = Browser; 11985 exports.Event = Event; 11986 exports.Http = Http; 11987 exports.Runtime = Runtime; 11988 exports.Loc = Loc; 11989 exports.Tag = Tag; 11990 exports.Uri = Uri; 11991 exports.Validation = Validation; 11992 exports.Cache = Cache; 11993 exports.BaseError = BaseError; 11994 exports.Extension = Extension$1; 11995 exports.ZIndexManager = ZIndexManager; 11996 exports.Collections = collections; 11997 exports.getClass = getClass; 11998 exports.namespace = namespace; 11999 exports.message = message$1; 12000 exports.replace = replace; 12001 exports.remove = remove; 12002 exports.clean = clean; 12003 exports.insertBefore = insertBefore; 12004 exports.insertAfter = insertAfter; 12005 exports.append = append; 12006 exports.prepend = prepend; 12007 exports.style = style; 12008 exports.adjust = adjust; 12009 exports.create = create; 12010 exports.isShown = isShown; 12011 exports.addClass = addClass; 12012 exports.removeClass = removeClass; 12013 exports.hasClass = hasClass; 12014 exports.toggleClass = toggleClass; 12015 exports.cleanNode = cleanNode; 12016 exports.getCookie = getCookie; 12017 exports.setCookie = setCookie; 12018 exports.bind = bind$1; 12019 exports.unbind = unbind$1; 12020 exports.unbindAll = unbindAll$1; 12021 exports.bindOnce = bindOnce$1; 12022 exports.ready = ready$1; 12023 exports.debugEnableFlag = debugEnableFlag; 12024 exports.debugStatus = debugStatus; 12025 exports.debug = debug$1; 12026 exports.debugEnable = debugEnable; 12027 exports.clone = clone$1; 12028 exports.loadExt = loadExt; 12029 exports.debounce = debounce; 12030 exports.throttle = throttle; 12031 exports.html = html; 12032 exports.type = type; 12033 exports.browser = browser; 12034 exports.ajax = ajax; 12035 exports.GetWindowScrollSize = GetWindowScrollSize; 12036 exports.GetWindowScrollPos = GetWindowScrollPos; 12037 exports.GetWindowInnerSize = GetWindowInnerSize; 12038 exports.GetWindowSize = GetWindowSize; 12039 exports.GetContext = GetContext; 12040 exports.pos = pos; 12041 exports.addCustomEvent = addCustomEvent; 12042 exports.onCustomEvent = onCustomEvent; 12043 exports.removeCustomEvent = removeCustomEvent; 12044 exports.removeAllCustomEvents = removeAllCustomEvents; 12045 12046}((this.BX = this.BX || {}))); 12047 12048 12049 12050(function(BX) { 12051 /* list of registered proxy functions */ 12052 var proxyList = new WeakMap(); 12053 var deferList = new WeakMap(); 12054 12055 /* List of denied event handlers */ 12056 var deniedEvents = []; 12057 12058 /* list of registered custom events */ 12059 var customEvents = new WeakMap(); 12060 var customEventsCnt = 0; 12061 12062 /* list of external garbage collectors */ 12063 var garbageCollectors = []; 12064 12065 /* list of loaded CSS files */ 12066 var cssList = []; 12067 var cssInit = false; 12068 12069 /* list of loaded JS files */ 12070 var jsList = []; 12071 var jsInit = false; 12072 12073 var eventTypes = { 12074 click: 'MouseEvent', 12075 dblclick: 'MouseEvent', 12076 mousedown: 'MouseEvent', 12077 mousemove: 'MouseEvent', 12078 mouseout: 'MouseEvent', 12079 mouseover: 'MouseEvent', 12080 mouseup: 'MouseEvent', 12081 focus: 'MouseEvent', 12082 blur: 'MouseEvent' 12083 }; 12084 12085 var lastWait = []; 12086 12087 var CHECK_FORM_ELEMENTS = {tagName: /^INPUT|SELECT|TEXTAREA|BUTTON$/i}; 12088 12089 var PRELOADING = 1; 12090 var PRELOADED = 2; 12091 var LOADING = 3; 12092 var LOADED = 4; 12093 var assets = {}; 12094 var isAsync = null; 12095 12096 BX.MSLEFT = 1; 12097 BX.MSMIDDLE = 2; 12098 BX.MSRIGHT = 4; 12099 12100 BX.AM_PM_UPPER = 1; 12101 BX.AM_PM_LOWER = 2; 12102 BX.AM_PM_NONE = false; 12103 12104 BX.ext = function(ob) 12105 { 12106 for (var i in ob) 12107 { 12108 if(ob.hasOwnProperty(i)) 12109 { 12110 this[i] = ob[i]; 12111 } 12112 } 12113 }; 12114 12115 var r = { 12116 script: /<script([^>]*)>/ig, 12117 script_end: /<\/script>/ig, 12118 script_src: /src=["\']([^"\']+)["\']/i, 12119 script_type: /type=["\']([^"\']+)["\']/i, 12120 space: /\s+/, 12121 ltrim: /^[\s\r\n]+/g, 12122 rtrim: /[\s\r\n]+$/g, 12123 style: /<link.*?(rel="stylesheet"|type="text\/css")[^>]*>/i, 12124 style_href: /href=["\']([^"\']+)["\']/i 12125 }; 12126 12127 BX.processHTML = function(data, scriptsRunFirst) 12128 { 12129 var matchScript, matchStyle, matchSrc, matchHref, matchType, scripts = [], styles = []; 12130 var textIndexes = []; 12131 var lastIndex = r.script.lastIndex = r.script_end.lastIndex = 0; 12132 12133 while ((matchScript = r.script.exec(data)) !== null) 12134 { 12135 r.script_end.lastIndex = r.script.lastIndex; 12136 var matchScriptEnd = r.script_end.exec(data); 12137 if (matchScriptEnd === null) 12138 { 12139 break; 12140 } 12141 12142 // skip script tags of special types 12143 var skipTag = false;
12144 if ((matchType = matchScript[1].match(r.script_type)) !== null) 12145 { 12146 if( 12147 matchType[1] == 'text/html' 12148 || matchType[1] == 'text/template' 12149 || matchType[1] == 'extension/settings' 12150 ) 12151 { 12152 skipTag = true; 12153 } 12154 } 12155 12156 if(skipTag) 12157 { 12158 textIndexes.push([lastIndex, r.script_end.lastIndex - lastIndex]); 12159 } 12160 else 12161 { 12162 textIndexes.push([lastIndex, matchScript.index - lastIndex]); 12163 12164 var bRunFirst = scriptsRunFirst || (matchScript[1].indexOf('bxrunfirst') != '-1'); 12165 12166 if ((matchSrc = matchScript[1].match(r.script_src)) !== null) 12167 { 12168 scripts.push({"bRunFirst": bRunFirst, "isInternal": false, "JS": matchSrc[1]}); 12169 } 12170 else 12171 { 12172 var start = matchScript.index + matchScript[0].length; 12173 var js = data.substr(start, matchScriptEnd.index-start); 12174 12175 scripts.push({"bRunFirst": bRunFirst, "isInternal": true, "JS": js}); 12176 } 12177 } 12178 12179 lastIndex = matchScriptEnd.index + 9; 12180 r.script.lastIndex = lastIndex; 12181 } 12182 12183 textIndexes.push([lastIndex, lastIndex === 0 ? data.length : data.length - lastIndex]); 12184 var pureData = ""; 12185 for (var i = 0, length = textIndexes.length; i < length; i++) 12186 { 12187 if (BX.type.isString(data) && BX.type.isFunction(data.substr)) 12188 { 12189 pureData += data.substr(textIndexes[i][0], textIndexes[i][1]); 12190 } 12191 } 12192 12193 while ((matchStyle = pureData.match(r.style)) !== null) 12194 { 12195 if ((matchHref = matchStyle[0].match(r.style_href)) !== null && matchStyle[0].indexOf('media="') < 0) 12196 { 12197 styles.push(matchHref[1]); 12198 } 12199 12200 pureData = pureData.replace(matchStyle[0], ''); 12201 } 12202 12203 return {'HTML': pureData, 'SCRIPT': scripts, 'STYLE': styles}; 12204 }; 12205 12206 /* OO emulation utility */ 12207 BX.extend = function(child, parent) 12208 { 12209 var f = function() {}; 12210 f.prototype = parent.prototype; 12211 12212 child.prototype = new f(); 12213 child.prototype.constructor = child; 12214 12215 child.superclass = parent.prototype; 12216 child.prototype.superclass = parent.prototype; 12217 if(parent.prototype.constructor == Object.prototype.constructor) 12218 { 12219 parent.prototype.constructor = parent; 12220 } 12221 }; 12222 12223 BX.is_subclass_of = function(ob, parent_class) 12224 { 12225 if (ob instanceof parent_class) 12226 return true; 12227 12228 if (parent_class.superclass) 12229 return BX.is_subclass_of(ob, parent_class.superclass); 12230 12231 return false; 12232 }; 12233 12234 BX.clearNodeCache = function() 12235 { 12236 return false; 12237 }; 12238 12239 BX.bitrix_sessid = function() {return BX.message("bitrix_sessid"); }; 12240 12241 /** 12242 * Creates document fragment with child nodes. 12243 * 12244 * @param {Node[]} nodes 12245 * @return {DocumentFragment} 12246 */ 12247 BX.createFragment = function(nodes) 12248 { 12249 var fragment = document.createDocumentFragment(); 12250 12251 if(!BX.type.isArray(nodes)) 12252 { 12253 return fragment; 12254 } 12255 for(var i = 0; i < nodes.length; i++) 12256 { 12257 fragment.appendChild(nodes[i]); 12258 } 12259 12260 return fragment; 12261 }; 12262 12263 /** 12264 * @deprecated 12265 * @use BX.style 12266 * @param element 12267 * @param opacity 12268 */ 12269 BX.setOpacity = function(element, opacity) 12270 { 12271 var opacityValue = parseFloat(opacity); 12272 12273 if (!isNaN(opacityValue) && BX.type.isDomNode(element)) 12274 { 12275 opacityValue = opacityValue < 1 ? opacityValue : opacityValue / 100; 12276 BX.style(element, 'opacity', opacityValue); 12277 } 12278 }; 12279 12280 /** 12281 * @deprecated 12282 * @param el 12283 * @return {*} 12284 */ 12285 BX.hoverEvents = function(el) 12286 { 12287 if (el) 12288 return BX.adjust(el, {events: BX.hoverEvents()}); 12289 else 12290 return {mouseover: BX.hoverEventsHover, mouseout: BX.hoverEventsHout}; 12291 }; 12292 12293 /** 12294 * @deprecated 12295 */ 12296 BX.hoverEventsHover = function(){BX.addClass(this,'bx-hover');this.BXHOVER=true;}; 12297 /** 12298 * @deprecated 12299 */ 12300 BX.hoverEventsHout = function(){BX.removeClass(this,'bx-hover');this.BXHOVER=false;}; 12301 12302 /** 12303 * @deprecated 12304 */ 12305 BX.focusEvents = function(el) 12306 { 12307 if (el) 12308 return BX.adjust(el, {events: BX.focusEvents()}); 12309 else 12310 return {mouseover: BX.focusEventsFocus, mouseout: BX.focusEventsBlur}; 12311 }; 12312 12313 /** 12314 * @deprecated 12315 */ 12316 BX.focusEventsFocus = function(){BX.addClass(this,'bx-focus');this.BXFOCUS=true;}; 12317 /** 12318 * @deprecated 12319 */ 12320 BX.focusEventsBlur = function(){BX.removeClass(this,'bx-focus');this.BXFOCUS=false;}; 12321 12322 BX.setUnselectable = function(node) 12323 { 12324 BX.style(node, { 12325 'userSelect': 'none', 12326 'MozUserSelect': 'none', 12327 'WebkitUserSelect': 'none', 12328 'KhtmlUserSelect': 'none', 12329 }); 12330 node.setAttribute('unSelectable', 'on'); 12331 }; 12332 12333 BX.setSelectable = function(node) 12334 { 12335 BX.style(node, { 12336 'userSelect': null, 12337 'MozUserSelect': null, 12338 'WebkitUserSelect': null, 12339 'KhtmlUserSelect': null, 12340 }); 12341 node.removeAttribute('unSelectable'); 12342 }; 12343 12344 BX.styleIEPropertyName = function(name) 12345 { 12346 if (name == 'float') 12347 name = BX.browser.IsIE() ? 'styleFloat' : 'cssFloat'; 12348 else 12349 { 12350 var res = BX.browser.isPropertySupported(name); 12351 if (res) 12352 { 12353 name = res; 12354 } 12355 else 12356 {
12357 var reg = /(\-([a-z]){1})/g; 12358 if (reg.test(name)) 12359 { 12360 name = name.replace(reg, function () {return arguments[2].toUpperCase();}); 12361 } 12362 } 12363 } 12364 return name; 12365 }; 12366 12367 BX.focus = function(el) 12368 { 12369 try 12370 { 12371 el.focus(); 12372 return true; 12373 } 12374 catch (e) 12375 { 12376 return false; 12377 } 12378 }; 12379 12380 BX.firstChild = function(el) 12381 { 12382 return BX.type.isDomNode(el) ? el.firstElementChild : null; 12383 }; 12384 12385 BX.lastChild = function(el) 12386 { 12387 return BX.type.isDomNode(el) ? el.lastElementChild : null; 12388 }; 12389 12390 BX.previousSibling = function(el) 12391 { 12392 return BX.type.isDomNode(el) ? el.previousElementSibling : null; 12393 }; 12394 12395 BX.nextSibling = function(el) 12396 { 12397 return BX.type.isDomNode(el) ? el.nextElementSibling : null; 12398 }; 12399 12400 /* 12401 params: { 12402 obj : html node 12403 className : className value 12404 recursive : used only for older browsers to optimize the tree traversal, in new browsers the search is always recursively, default - true 12405 } 12406 12407 Search all nodes with className 12408 */ 12409 /** 12410 * @deprecated 12411 * @use .querySelectorAll 12412 * @param obj 12413 * @param className 12414 * @param recursive 12415 * @return {*} 12416 */ 12417 BX.findChildrenByClassName = function(obj, className, recursive) 12418 { 12419 if(!obj || !obj.childNodes) return null; 12420 12421 var result = []; 12422 if (typeof(obj.getElementsByClassName) == 'undefined') 12423 { 12424 recursive = recursive !== false; 12425 result = BX.findChildren(obj, {className : className}, recursive); 12426 } 12427 else 12428 { 12429 var col = obj.getElementsByClassName(className); 12430 for (i=0,l=col.length;i<l;i++) 12431 { 12432 result[i] = col[i]; 12433 } 12434 } 12435 return result; 12436 }; 12437 12438 /* 12439 params: { 12440 obj : html node 12441 className : className value 12442 recursive : used only for older browsers to optimize the tree traversal, in new browsers the search is always recursively, default - true 12443 } 12444 12445 Search first node with className 12446 */ 12447 /** 12448 * @deprecated 12449 * @use .querySelector 12450 * @param obj 12451 * @param className 12452 * @param recursive 12453 * @return {*} 12454 */ 12455 BX.findChildByClassName = function(obj, className, recursive) 12456 { 12457 if(!obj || !obj.childNodes) return null; 12458 12459 var result = null; 12460 if (typeof(obj.getElementsByClassName) == 'undefined') 12461 { 12462 recursive = recursive !== false; 12463 result = BX.findChild(obj, {className : className}, recursive); 12464 } 12465 else 12466 { 12467 var col = obj.getElementsByClassName(className); 12468 if (col && typeof(col[0]) != 'undefined') 12469 { 12470 result = col[0]; 12471 } 12472 else 12473 { 12474 result = null; 12475 } 12476 } 12477 return result; 12478 }; 12479 12480 /* 12481 params: { 12482 tagName|tag : 'tagName', 12483 className|class : 'className', 12484 attribute : {attribute : value, attribute : value} | attribute | [attribute, attribute....], 12485 property : {prop: value, prop: value} | prop | [prop, prop] 12486 } 12487 12488 all values can be RegExps or strings 12489 */ 12490 /** 12491 * @deprecated 12492 * @use .querySelectorAll 12493 * @param obj 12494 * @param params 12495 * @param recursive 12496 * @return {*|Node} 12497 */ 12498 BX.findChildren = function(obj, params, recursive) 12499 { 12500 return BX.findChild(obj, params, recursive, true); 12501 }; 12502 12503 /** 12504 * @deprecated 12505 * @use .querySelectorAll 12506 * @param obj 12507 * @param params 12508 * @param recursive 12509 * @param get_all 12510 * @return {*} 12511 */ 12512 BX.findChild = function(obj, params, recursive, get_all) 12513 { 12514 if(!obj || !obj.childNodes) return null; 12515 12516 recursive = !!recursive; get_all = !!get_all; 12517 12518 var n = obj.childNodes.length, result = []; 12519 12520 for (var j=0; j<n; j++) 12521 { 12522 var child = obj.childNodes[j]; 12523 12524 if (_checkNode(child, params)) 12525 { 12526 if (get_all) 12527 result.push(child); 12528 else 12529 return child; 12530 } 12531 12532 if(recursive == true) 12533 { 12534 var res = BX.findChild(child, params, recursive, get_all); 12535 if (res) 12536 { 12537 if (get_all) 12538 result = BX.util.array_merge(result, res); 12539 else 12540 return res; 12541 } 12542 } 12543 } 12544 12545 if (get_all || result.length > 0) 12546 return result; 12547 else 12548 return null; 12549 }; 12550 12551 /** 12552 * @deprecated 12553 * @use .closest() 12554 * @param obj 12555 * @param params 12556 * @param maxParent 12557 * @return {*} 12558 */ 12559 BX.findParent = function(obj, params, maxParent) 12560 { 12561 if(!obj) 12562 return null; 12563 12564 var o = obj; 12565 while(o.parentNode) 12566 { 12567 var parent = o.parentNode; 12568 12569 if (_checkNode(parent, params)) 12570 return parent; 12571 12572 o = parent; 12573 12574 if (!!maxParent &&
12575 (BX.type.isFunction(maxParent) 12576 || typeof maxParent == 'object')) 12577 { 12578 if (BX.type.isElementNode(maxParent)) 12579 { 12580 if (o == maxParent) 12581 break; 12582 } 12583 else 12584 { 12585 if (_checkNode(o, maxParent)) 12586 break; 12587 } 12588 } 12589 } 12590 return null; 12591 }; 12592 12593 /** 12594 * @deprecated 12595 * @use .querySelector 12596 * @param obj 12597 * @param params 12598 * @return {*} 12599 */ 12600 BX.findNextSibling = function(obj, params) 12601 { 12602 if(!obj) 12603 return null; 12604 var o = obj; 12605 while(o.nextSibling) 12606 { 12607 var sibling = o.nextSibling; 12608 if (_checkNode(sibling, params)) 12609 return sibling; 12610 o = sibling; 12611 } 12612 return null; 12613 }; 12614 12615 /** 12616 * @deprecated 12617 * @use .querySelector 12618 * @param obj 12619 * @param params 12620 * @return {*} 12621 */ 12622 BX.findPreviousSibling = function(obj, params) 12623 { 12624 if(!obj) 12625 return null; 12626 12627 var o = obj; 12628 while(o.previousSibling) 12629 { 12630 var sibling = o.previousSibling; 12631 if(_checkNode(sibling, params)) 12632 return sibling; 12633 o = sibling; 12634 } 12635 return null; 12636 }; 12637 12638 BX.checkNode = function(obj, params) 12639 { 12640 return _checkNode(obj, params); 12641 }; 12642 12643 /** 12644 * @deprecated 12645 * @use .querySelectorAll 12646 * @param form 12647 * @return {Array} 12648 */ 12649 BX.findFormElements = function(form) 12650 { 12651 if (BX.type.isString(form)) 12652 form = document.forms[form]||BX(form); 12653 12654 var res = []; 12655 12656 if (BX.type.isElementNode(form)) 12657 { 12658 if (form.tagName.toUpperCase() == 'FORM') 12659 { 12660 res = form.elements; 12661 } 12662 else 12663 { 12664 res = BX.findChildren(form, CHECK_FORM_ELEMENTS, true); 12665 } 12666 } 12667 12668 return res; 12669 }; 12670 12671 /** 12672 * @deprecated 12673 * @use .contains() 12674 * @param whichNode 12675 * @param forNode 12676 * @return {boolean} 12677 */ 12678 BX.isParentForNode = function(whichNode, forNode) 12679 { 12680 if (BX.type.isDomNode(whichNode) && BX.type.isDomNode(forNode)) 12681 { 12682 return whichNode.contains(forNode); 12683 } 12684 12685 return false; 12686 }; 12687 12688 BX.getCaretPosition = function(node) 12689 { 12690 var pos = 0; 12691 12692 if(node.selectionStart || node.selectionStart == 0) 12693 { 12694 pos = node.selectionStart; 12695 } 12696 else if(document.selection) 12697 { 12698 node.focus(); 12699 var selection = document.selection.createRange(); 12700 selection.moveStart('character', -node.value.length); 12701 pos = selection.text.length; 12702 } 12703 12704 return (pos); 12705 }; 12706 12707 BX.setCaretPosition = function(node, pos) 12708 { 12709 if(!BX.isNodeInDom(node) || BX.isNodeHidden(node) || node.disabled) 12710 { 12711 return; 12712 } 12713 12714 if(node.setSelectionRange) 12715 { 12716 node.focus(); 12717 node.setSelectionRange(pos, pos); 12718 } 12719 else if(node.createTextRange) 12720 { 12721 var range = node.createTextRange(); 12722 range.collapse(true); 12723 range.moveEnd('character', pos); 12724 range.moveStart('character', pos); 12725 range.select(); 12726 } 12727 }; 12728 12729 // access private. use BX.mergeEx instead. 12730 // todo: refactor BX.merge, make it work through BX.mergeEx 12731 BX.merge = function(){ 12732 var arg = Array.prototype.slice.call(arguments); 12733 12734 if(arg.length < 2) 12735 return {}; 12736 12737 var result = arg.shift(); 12738 12739 for(var i = 0; i < arg.length; i++) 12740 { 12741 for(var k in arg[i]){ 12742 12743 if(typeof arg[i] == 'undefined' || arg[i] == null) 12744 continue; 12745 12746 if(arg[i].hasOwnProperty(k)){ 12747 12748 if(typeof arg[i][k] == 'undefined' || arg[i][k] == null) 12749 continue; 12750 12751 if(typeof arg[i][k] == 'object' && !BX.type.isDomNode(arg[i][k]) && (typeof arg[i][k]['isUIWidget'] == 'undefined')){ 12752 12753 // go deeper 12754 12755 var isArray = 'length' in arg[i][k]; 12756 12757 if(typeof result[k] != 'object') 12758 result[k] = isArray ? [] : {}; 12759 12760 if(isArray) 12761 BX.util.array_merge(result[k], arg[i][k]); 12762 else 12763 BX.merge(result[k], arg[i][k]); 12764 12765 }else 12766 result[k] = arg[i][k]; 12767 } 12768 } 12769 } 12770 12771 return result; 12772 }; 12773 12774 BX.mergeEx = function() 12775 { 12776 var arg = Array.prototype.slice.call(arguments); 12777 if(arg.length < 2) 12778 { 12779 return {}; 12780 } 12781 12782 var result = arg.shift(); 12783 for (var i = 0; i < arg.length; i++) 12784 { 12785 for (var k in arg[i]) 12786 { 12787 if (typeof arg[i] == "undefined" || arg[i] == null || !arg[i].hasOwnProperty(k)) 12788 { 12789 continue; 12790 } 12791 12792 if (BX.type.isPlainObject(arg[i][k]) && BX.type.isPlainObject(result[k])) 12793 { 12794 BX.mergeEx(result[k], arg[i][k]); 12795 } 12796 else 12797 { 12798 result[k] = BX.type.isPlainObject(arg[i][k]) ? BX.clone(arg[i][k]) : arg[i][k]; 12799 } 12800 } 12801 } 12802 12803 return result; 12804 }; 12805 12806 BX.getEventButton = function(e) 12807 { 12808 e = e || window.event; 12809 12810 var flags = 0; 12811 12812 if (typeof e.which != 'undefined') 12813 { 12814 switch (e.which) 12815 { 12816 case 1: flags = flags|BX.MSLEFT; break; 12817 case 2: flags = flags|BX.MSMIDDLE; break; 12818 case 3: flags = flags|BX.MSRIGHT; break; 12819 } 12820 } 12821 else if (typeof e.button != 'undefined') 12822 { 12823 flags = event.button; 12824 } 12825 12826 return flags || BX.MSLEFT; 12827 }; 12828 12829 var captured_events = null, _bind = null; 12830 BX.CaptureEvents = function(el_c, evname_c) 12831 { 12832 if (_bind) 12833 return; 12834 12835 _bind = BX.bind; 12836 captured_events = []; 12837 12838 BX.bind = function(el, evname, func) 12839 { 12840 if (el === el_c && evname === evname_c) 12841 captured_events.push(func); 12842 12843 _bind.apply(this, arguments); 12844 } 12845 }; 12846 12847 BX.CaptureEventsGet = function() 12848 { 12849 if (_bind) 12850 { 12851 BX.bind = _bind; 12852 12853 var captured = captured_events; 12854 12855 _bind = null; 12856 captured_events = null; 12857 return captured; 12858 } 12859 return null; 12860 }; 12861 12862 // Don't even try to use it for submit event! 12863 BX.fireEvent = function(ob,ev) 12864 { 12865 var result = false, e = null; 12866 if (BX.type.isDomNode(ob)) 12867 { 12868 result = true; 12869 if (document.createEventObject) 12870 { 12871 // IE 12872 if (eventTypes[ev] != 'MouseEvent') 12873 { 12874 e = document.createEventObject(); 12875 e.type = ev; 12876 result = ob.fireEvent('on' + ev, e); 12877 } 12878 12879 if (ob[ev]) 12880 { 12881 ob[ev](); 12882 } 12883 } 12884 else 12885 {
12886 // non-IE 12887 e = null; 12888 12889 switch (eventTypes[ev]) 12890 { 12891 case 'MouseEvent': 12892 e = document.createEvent('MouseEvent'); 12893 try 12894 { 12895 e.initMouseEvent(ev, true, true, top, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, null); 12896 } 12897 catch (initException) 12898 { 12899 e.initMouseEvent(ev, true, true, window, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, null); 12900 } 12901 12902 break; 12903 default: 12904 e = document.createEvent('Event'); 12905 e.initEvent(ev, true, true); 12906 } 12907 12908 result = ob.dispatchEvent(e); 12909 } 12910 } 12911 12912 return result; 12913 }; 12914 12915 BX.getWheelData = function(e) 12916 { 12917 e = e || window.event; 12918 e.wheelData = e.detail ? e.detail * -1 : e.wheelDelta / 40; 12919 return e.wheelData; 12920 }; 12921 12922 BX.proxy_context = null; 12923 12924 BX.delegate = function (func, thisObject) 12925 { 12926 if (!func || !thisObject) 12927 return func; 12928 12929 return function() { 12930 var cur = BX.proxy_context; 12931 BX.proxy_context = this; 12932 var res = func.apply(thisObject, arguments); 12933 BX.proxy_context = cur; 12934 return res; 12935 } 12936 }; 12937 12938 BX.delegateLater = function (func_name, thisObject, contextObject) 12939 { 12940 return function() 12941 { 12942 if (thisObject[func_name]) 12943 { 12944 var cur = BX.proxy_context; 12945 BX.proxy_context = this; 12946 var res = thisObject[func_name].apply(contextObject||thisObject, arguments); 12947 BX.proxy_context = cur; 12948 return res; 12949 } 12950 return null; 12951 } 12952 }; 12953 12954 BX.proxy = function(func, thisObject) 12955 { 12956 return getObjectDelegate(func, thisObject, proxyList); 12957 }; 12958 12959 BX.defer = function(func, thisObject) 12960 { 12961 if (!!thisObject) 12962 return BX.defer_proxy(func, thisObject); 12963 else 12964 return function() { 12965 var arg = arguments; 12966 setTimeout(function(){func.apply(this,arg)}, 10); 12967 }; 12968 }; 12969 12970 BX.defer_proxy = function(func, thisObject) 12971 { 12972 return getObjectDelegate(func, thisObject, deferList, BX.defer); 12973 }; 12974 12975 /** 12976 * 12977 * @private 12978 */ 12979 function getObjectDelegate(func, thisObject, collection, decorator) 12980 { 12981 if (!BX.type.isFunction(func) || !BX.type.isMapKey(thisObject)) 12982 { 12983 return func; 12984 } 12985 12986 var objectDelegates = collection.get(thisObject); 12987 if (!objectDelegates) 12988 { 12989 objectDelegates = new WeakMap(); 12990 collection.set(thisObject, objectDelegates); 12991 } 12992 12993 var delegate = objectDelegates.get(func); 12994 if (!delegate) 12995 { 12996 delegate = decorator ? decorator(BX.delegate(func, thisObject)) : BX.delegate(func, thisObject); 12997 objectDelegates.set(func, delegate); 12998 } 12999 13000 return delegate; 13001 } 13002 13003 BX.once = function(el, evname, func) 13004 { 13005 var fn = function() 13006 { 13007 BX.unbind(el, evname, fn); 13008 func.apply(this, arguments); 13009 }; 13010 13011 return fn; 13012 }; 13013 13014 BX.bindDelegate = function (elem, eventName, isTarget, handler) 13015 { 13016 var h = BX.delegateEvent(isTarget, handler); 13017 BX.bind(elem, eventName, h); 13018 return h; 13019 }; 13020 13021 BX.delegateEvent = function(isTarget, handler) 13022 { 13023 return function(e) 13024 { 13025 e = e || window.event; 13026 var target = e.target || e.srcElement; 13027 13028 while (target != this) 13029 { 13030 if (_checkNode(target, isTarget)) 13031 { 13032 return handler.call(target, e); 13033 } 13034 if (target && target.parentNode) 13035 target = target.parentNode; 13036 else 13037 break; 13038 } 13039 return null; 13040 } 13041 }; 13042 13043 BX.False = function() {return false;}; 13044 BX.DoNothing = function() {}; 13045 13046 // TODO: also check event handlers set via BX.bind() 13047 BX.denyEvent = function(el, ev) 13048 { 13049 deniedEvents.push([el, ev, el['on' + ev]]); 13050 el['on' + ev] = BX.DoNothing; 13051 }; 13052 13053 BX.allowEvent = function(el, ev) 13054 { 13055 for(var i=0, len=deniedEvents.length; i<len; i++) 13056 { 13057 if (deniedEvents[i][0] == el && deniedEvents[i][1] == ev) 13058 { 13059 el['on' + ev] = deniedEvents[i][2]; 13060 BX.util.deleteFromArray(deniedEvents, i); 13061 return; 13062 } 13063 } 13064 }; 13065 13066 BX.fixEventPageXY = function(event) 13067 { 13068 BX.fixEventPageX(event); 13069 BX.fixEventPageY(event); 13070 return event; 13071 }; 13072 13073 BX.fixEventPageX = function(event) 13074 { 13075 if (event.pageX == null && event.clientX != null) 13076 { 13077 event.pageX = 13078 event.clientX + 13079 (document.documentElement && document.documentElement.scrollLeft || document.body && document.body.scrollLeft || 0) - 13080 (document.documentElement.clientLeft || 0); 13081 } 13082 13083 return event; 13084 }; 13085 13086 BX.fixEventPageY = function(event) 13087 { 13088 if (event.pageY == null && event.clientY != null) 13089 { 13090 event.pageY = 13091 event.clientY + 13092 (document.documentElement && document.documentElement.scrollTop || document.body && document.body.scrollTop || 0) - 13093 (document.documentElement.clientTop || 0); 13094 } 13095 13096 return event; 13097 }; 13098 13099 /** 13100 * @deprecated 13101 * @see e.preventDefault() 13102 */ 13103 BX.PreventDefault = function(e) 13104 { 13105 if(!e) e = window.event; 13106 if(e.stopPropagation) 13107 { 13108 e.preventDefault(); 13109 e.stopPropagation(); 13110 } 13111 else 13112 { 13113 e.cancelBubble = true; 13114 e.returnValue = false;
13115 } 13116 return false; 13117 }; 13118 13119 /** 13120 * @deprecated 13121 * @see e.preventDefault(); 13122 * 13123 * @param e 13124 * @return {boolean} 13125 */ 13126 BX.eventReturnFalse = function(e) 13127 { 13128 e=e||window.event; 13129 if (e && e.preventDefault) e.preventDefault(); 13130 else e.returnValue = false; 13131 return false; 13132 }; 13133 13134 /** 13135 * @deprecated 13136 * @see e.stopPropagation() 13137 * @param e 13138 */ 13139 BX.eventCancelBubble = function(e) 13140 { 13141 e=e||window.event; 13142 if(e && e.stopPropagation) 13143 e.stopPropagation(); 13144 else 13145 e.cancelBubble = true; 13146 }; 13147 13148 BX.bindDebouncedChange = function(node, fn, fnInstant, timeout, ctx) 13149 { 13150 ctx = ctx || window; 13151 timeout = timeout || 300; 13152 13153 var dataTag = 'bx-dc-previous-value'; 13154 BX.data(node, dataTag, node.value); 13155 13156 var act = function(fn, val){ 13157 13158 var pVal = BX.data(node, dataTag); 13159 13160 if(typeof pVal == 'undefined' || pVal != val){ 13161 if(typeof ctx != 'object') 13162 fn(val); 13163 else 13164 fn.apply(ctx, [val]); 13165 } 13166 }; 13167 13168 var actD = BX.debounce(function(){ 13169 var val = node.value; 13170 act(fn, val); 13171 BX.data(node, dataTag, val); 13172 }, timeout); 13173 13174 BX.bind(node, 'keyup', actD); 13175 BX.bind(node, 'change', actD); 13176 BX.bind(node, 'input', actD); 13177 13178 if(BX.type.isFunction(fnInstant)){ 13179 13180 var actI = function(){ 13181 act(fnInstant, node.value); 13182 }; 13183 13184 BX.bind(node, 'keyup', actI); 13185 BX.bind(node, 'change', actI); 13186 BX.bind(node, 'input', actI); 13187 } 13188 }; 13189 13190 BX.parseJSON = function(data, context) 13191 { 13192 var result = null; 13193 if (BX.type.isNotEmptyString(data)) 13194 { 13195 try { 13196 if (data.indexOf("\n") >= 0) 13197 eval('result = ' + data); 13198 else 13199 result = (new Function("return " + data))(); 13200 } catch(e) { 13201 BX.onCustomEvent(context, 'onParseJSONFailure', [data, context]) 13202 } 13203 } 13204 else if(BX.type.isPlainObject(data)) 13205 { 13206 return data; 13207 } 13208 13209 return result; 13210 }; 13211 13212 BX.submit = function(obForm, action_name, action_value, onAfterSubmit) 13213 { 13214 action_name = action_name || 'save'; 13215 if (!obForm['BXFormSubmit_' + action_name]) 13216 { 13217 obForm['BXFormSubmit_' + action_name] = obForm.appendChild(BX.create('INPUT', { 13218 'props': { 13219 'type': 'submit', 13220 'name': action_name, 13221 'value': action_value || 'Y' 13222 }, 13223 'style': { 13224 'display': 'none' 13225 } 13226 })); 13227 } 13228 13229 if (obForm.sessid) 13230 obForm.sessid.value = BX.bitrix_sessid(); 13231 13232 setTimeout(BX.delegate(function() {BX.fireEvent(this, 'click'); if (onAfterSubmit) onAfterSubmit();}, obForm['BXFormSubmit_' + action_name]), 10); 13233 }; 13234 13235 BX.show = function(ob, displayType) 13236 { 13237 if (ob.BXDISPLAY || !_checkDisplay(ob, displayType)) 13238 { 13239 ob.style.display = ob.BXDISPLAY; 13240 } 13241 }; 13242 13243 BX.hide = function(ob, displayType) 13244 { 13245 if (!ob.BXDISPLAY) 13246 _checkDisplay(ob, displayType); 13247 13248 ob.style.display = 'none'; 13249 }; 13250 13251 BX.toggle = function(ob, values) 13252 { 13253 if (!values && BX.type.isElementNode(ob)) 13254 { 13255 var bShow = true; 13256 if (ob.BXDISPLAY) 13257 bShow = !_checkDisplay(ob); 13258 else 13259 bShow = ob.style.display == 'none'; 13260 13261 if (bShow) 13262 BX.show(ob); 13263 else 13264 BX.hide(ob); 13265 } 13266 else if (BX.type.isArray(values)) 13267 { 13268 for (var i=0,len=values.length; i<len; i++) 13269 { 13270 if (ob == values[i]) 13271 { 13272 ob = values[i==len-1 ? 0 : i+1]; 13273 break; 13274 } 13275 } 13276 if (i==len) 13277 ob = values[0]; 13278 } 13279 13280 return ob; 13281 }; 13282 13283 function _checkDisplay(ob, displayType) 13284 { 13285 if (typeof displayType != 'undefined') 13286 ob.BXDISPLAY = displayType; 13287 13288 var d = ob.style.display || BX.style(ob, 'display'); 13289 if (d != 'none') 13290 { 13291 ob.BXDISPLAY = ob.BXDISPLAY || d; 13292 return true; 13293 } 13294 else 13295 { 13296 ob.BXDISPLAY = ob.BXDISPLAY || 'block'; 13297 return false; 13298 } 13299 } 13300 13301 /* some useful util functions */ 13302 13303 BX.util = { 13304 /** 13305 * @deprecated 13306 * @use [].filter(value => !BX.Type.isNil(value)) 13307 * @param ar 13308 * @return {*} 13309 */ 13310 array_values: function(ar) 13311 { 13312 if (!BX.type.isArray(ar)) 13313 return BX.util._array_values_ob(ar); 13314 var arv = []; 13315 for(var i=0,l=ar.length;i<l;i++) 13316 if (ar[i] !== null && typeof ar[i] != 'undefined') 13317 arv.push(ar[i]); 13318 return arv; 13319 }, 13320 13321 /** 13322 * @deprecated 13323 * @use Object.values([]).filter(value => !BX.Type.isNil(value)) 13324 * @param ar 13325 * @return {Array} 13326 * @private 13327 */ 13328 _array_values_ob: function(ar) 13329 { 13330 var arv = []; 13331 for(var i in ar) 13332 if (ar[i] !== null && typeof ar[i] != 'undefined') 13333 arv.push(ar[i]); 13334 return arv; 13335 }, 13336 13337 /** 13338 * @deprecated 13339 * @use 13340 * @param ar 13341 * @return {*} 13342 */ 13343 array_keys: function(ar) 13344 { 13345 if (!BX.type.isArray(ar)) 13346 return BX.util._array_keys_ob(ar); 13347 var arv = []; 13348 for(var i=0,l=ar.length;i<l;i++) 13349 if (ar[i] !== null && typeof ar[i] != 'undefined') 13350 arv.push(i); 13351 return arv; 13352 }, 13353 13354 _array_keys_ob: function(ar) 13355 { 13356 var arv = []; 13357 for(var i in ar) 13358 if (ar[i] !== null && typeof ar[i] != 'undefined') 13359 arv.push(i); 13360 return arv; 13361 }, 13362 13363 object_keys: function(obj) 13364 { 13365 var arv = []; 13366 for(var k in obj) 13367 { 13368 if(obj.hasOwnProperty(k)) 13369 { 13370 arv.push(k); 13371 } 13372 } 13373 return arv; 13374 }, 13375 13376 /** 13377 * @deprecated 13378 * @use firstArr.concat(secondArr); 13379 * @param first 13380 * @param second 13381 * @return {*[]} 13382 */ 13383 array_merge: function(first, second) 13384 { 13385 if (!BX.type.isArray(first)) first = []; 13386 if (!BX.type.isArray(second)) second = []; 13387 13388 var i = first.length, j = 0; 13389 13390 if (typeof second.length === "number") 13391 { 13392 for (var l = second.length; j < l; j++) 13393 { 13394 first[i++] = second[j]; 13395 } 13396 } 13397 else 13398 {
13399 while (second[j] !== undefined) 13400 { 13401 first[i++] = second[j++]; 13402 } 13403 } 13404 13405 first.length = i; 13406 13407 return first; 13408 }, 13409 13410 array_flip: function (object) 13411 { 13412 var newObject = {}; 13413 13414 for (var key in object) 13415 { 13416 newObject[object[key]] = key; 13417 } 13418 13419 return newObject; 13420 }, 13421 13422 array_diff: function(ar1, ar2, hash) 13423 { 13424 hash = BX.type.isFunction(hash) ? hash : null; 13425 var i, length, v, h, map = {}, result = []; 13426 for(i = 0, length = ar2.length; i < length; i++) 13427 { 13428 v = ar2[i]; 13429 h = hash ? hash(v) : v; 13430 map[h] = true; 13431 } 13432 13433 for(i = 0, length = ar1.length; i < length; i++) 13434 { 13435 v = ar1[i]; 13436 h = hash ? hash(v) : v; 13437 if(typeof(map[h]) === "undefined") 13438 { 13439 result.push(v); 13440 } 13441 } 13442 return result; 13443 }, 13444 13445 /** 13446 * @deprecated 13447 * @use Set 13448 */ 13449 array_unique: function(ar) 13450 { 13451 var i=0,j,len=ar.length; 13452 if(len<2) return ar; 13453 13454 for (; i<len-1;i++) 13455 { 13456 for (j=i+1; j<len;j++) 13457 { 13458 if (ar[i]==ar[j]) 13459 { 13460 ar.splice(j--,1); len--; 13461 } 13462 } 13463 } 13464 13465 return ar; 13466 }, 13467 13468 /** 13469 * @deprecated 13470 * @use myArr.includes(needle) 13471 */ 13472 in_array: function(needle, haystack) 13473 { 13474 for(var i=0; i<haystack.length; i++) 13475 { 13476 if(haystack[i] == needle) 13477 return true; 13478 } 13479 return false; 13480 }, 13481 13482 /** 13483 * @deprecated 13484 * @use myArr.findIndex(item => item === needle); 13485 */ 13486 array_search: function(needle, haystack) 13487 { 13488 for(var i=0; i<haystack.length; i++) 13489 { 13490 if(haystack[i] == needle) 13491 return i; 13492 } 13493 return -1; 13494 }, 13495 13496 object_search_key: function(needle, haystack) 13497 { 13498 if (typeof haystack[needle] != 'undefined') 13499 return haystack[needle]; 13500 13501 for(var i in haystack) 13502 { 13503 if (typeof haystack[i] == "object") 13504 { 13505 var result = BX.util.object_search_key(needle, haystack[i]); 13506 if (result !== false) 13507 return result; 13508 } 13509 } 13510 return false; 13511 }, 13512 13513 trim: function(s) 13514 { 13515 if (BX.type.isString(s)) 13516 { 13517 return s.trim(); 13518 } 13519 13520 return s; 13521 }, 13522 13523 urlencode: function(s){return encodeURIComponent(s);}, 13524 13525 // it may also be useful. via sVD. 13526 deleteFromArray: function(ar, ind) {return ar.slice(0, ind).concat(ar.slice(ind + 1));}, 13527 insertIntoArray: function(ar, ind, el) {return ar.slice(0, ind).concat([el]).concat(ar.slice(ind));}, 13528 13529 htmlspecialchars: function(str) 13530 { 13531 return BX.Text.encode(str); 13532 }, 13533 13534 htmlspecialcharsback: function(str) 13535 { 13536 return BX.Text.decode(str); 13537 }, 13538 13539 // Quote regular expression characters plus an optional character 13540 preg_quote: function(str, delimiter) 13541 { 13542 if(!str.replace) 13543 return str; 13544 return str.replace(new RegExp('[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\' + (delimiter || '') + '-]', 'g'), '\\$&'); 13545 }, 13546 13547 jsencode: function(str) 13548 { 13549 if (!str || !str.replace) 13550 return str; 13551 13552 var escapes = 13553 [ 13554 { c: "\\\\", r: "\\\\" }, // should be first 13555 { c: "\\t", r: "\\t" }, 13556 { c: "\\n", r: "\\n" }, 13557 { c: "\\r", r: "\\r" }, 13558 { c: "\"", r: "\\\"" }, 13559 { c: "'", r: "\\'" }, 13560 { c: "<", r: "\\x3C" }, 13561 { c: ">", r: "\\x3E" }, 13562 { c: "\\u2028", r: "\\u2028" }, 13563 { c: "\\u2029", r: "\\u2029" } 13564 ]; 13565 for (var i = 0; i < escapes.length; i++) 13566 str = str.replace(new RegExp(escapes[i].c, 'g'), escapes[i].r); 13567 return str; 13568 }, 13569 13570 getCssName: function(jsName) 13571 { 13572 if (!BX.type.isNotEmptyString(jsName)) 13573 { 13574 return ""; 13575 } 13576 13577 return jsName.replace(/[A-Z]/g, function(match) { 13578 return "-" + match.toLowerCase(); 13579 }); 13580 }, 13581 13582 getJsName: function(cssName) 13583 { 13584 var regex = /\-([a-z]){1}/g; 13585 if (regex.test(cssName)) 13586 { 13587 return cssName.replace(regex, function(match, letter) { 13588 return letter.toUpperCase(); 13589 }); 13590 } 13591 13592 return cssName; 13593 }, 13594 13595 nl2br: function(str) 13596 { 13597 if (!str || !str.replace) 13598 return str; 13599 13600 return str.replace(/([^>])\n/g, '$1<br/>'); 13601 }, 13602 13603 /** 13604 * @deprecated 13605 * @use .padStart() / .padEnd() 13606 * @param input 13607 * @param pad_length 13608 * @param pad_string 13609 * @param pad_type 13610 * @return {*} 13611 */ 13612 str_pad: function(input, pad_length, pad_string, pad_type) 13613 { 13614 pad_string = pad_string || ' '; 13615 pad_type = pad_type || 'right'; 13616 input = input.toString(); 13617 13618 if (pad_type === 'left') 13619 { 13620 return BX.util.str_pad_left(input, pad_length, pad_string); 13621 } 13622 13623 return BX.util.str_pad_right(input, pad_length, pad_string); 13624 }, 13625 13626 str_pad_left: function(input, pad_length, pad_string) 13627 { 13628 return input.toString().padStart(pad_length, pad_string); 13629 }, 13630 13631 str_pad_right: function(input, pad_length, pad_string) 13632 { 13633 return input.toString().padEnd(pad_length, pad_string); 13634 }, 13635 13636 strip_tags: function(str) 13637 { 13638 return str.split(/<[^>]+>/g).join(''); 13639 }, 13640 13641 strip_php_tags: function(str) 13642 { 13643 return str.replace(/<\?(.|[\r\n])*?\?>/g, ''); 13644 }, 13645 13646 popup: function(url, width, height) 13647 { 13648 var w, h; 13649 if(BX.browser.IsOpera()) 13650 { 13651 w = document.body.offsetWidth; 13652 h = document.body.offsetHeight; 13653 } 13654 else 13655 {
13656 w = screen.width; 13657 h = screen.height; 13658 } 13659 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)); 13660 }, 13661 13662 shuffle: function(array) 13663 { 13664 var temporaryValue, randomIndex; 13665 var currentIndex = array.length; 13666 13667 while (0 !== currentIndex) 13668 { 13669 randomIndex = Math.floor(Math.random() * currentIndex); 13670 currentIndex -= 1; 13671 13672 temporaryValue = array[currentIndex]; 13673 array[currentIndex] = array[randomIndex]; 13674 array[randomIndex] = temporaryValue; 13675 } 13676 13677 return array; 13678 }, 13679 13680 // BX.util.objectSort(object, sortBy, sortDir) - Sort object by property 13681 // function params: 1 - object for sort, 2 - sort by property, 3 - sort direction (asc/desc) 13682 // return: sort array [[objectElement], [objectElement]] in sortDir direction 13683 13684 // example: BX.util.objectSort({'L1': {'name': 'Last'}, 'F1': {'name': 'First'}}, 'name', 'asc'); 13685 // return: [{'name' : 'First'}, {'name' : 'Last'}] 13686 objectSort: function(object, sortBy, sortDir) 13687 { 13688 sortDir = sortDir == 'asc'? 'asc': 'desc'; 13689 13690 var arItems = [], i; 13691 for (i in object) 13692 { 13693 if (object.hasOwnProperty(i) && object[i][sortBy]) 13694 { 13695 arItems.push([i, object[i][sortBy]]); 13696 } 13697 } 13698 13699 if (sortDir == 'asc') 13700 { 13701 arItems.sort(function(i, ii) { 13702 var s1, s2; 13703 if (BX.type.isDate(i[1])) 13704 { 13705 s1 = i[1].getTime(); 13706 } 13707 else if (!isNaN(i[1])) 13708 { 13709 s1 = parseInt(i[1]); 13710 } 13711 else 13712 { 13713 s1 = i[1].toString().toLowerCase(); 13714 } 13715 13716 if (BX.type.isDate(ii[1])) 13717 { 13718 s2 = ii[1].getTime(); 13719 } 13720 else if (!isNaN(ii[1])) 13721 { 13722 s2 = parseInt(ii[1]); 13723 } 13724 else 13725 { 13726 s2 = ii[1].toString().toLowerCase(); 13727 } 13728 13729 if (s1 > s2) 13730 return 1; 13731 else if (s1 < s2) 13732 return -1; 13733 else 13734 return 0; 13735 }); 13736 } 13737 else 13738 { 13739 arItems.sort(function(i, ii) { 13740 var s1, s2; 13741 if (BX.type.isDate(i[1])) 13742 { 13743 s1 = i[1].getTime(); 13744 } 13745 else if (!isNaN(i[1])) 13746 { 13747 s1 = parseInt(i[1]); 13748 } 13749 else 13750 { 13751 s1 = i[1].toString().toLowerCase(); 13752 } 13753 13754 if (BX.type.isDate(ii[1])) 13755 { 13756 s2 = ii[1].getTime(); 13757 } 13758 else if (!isNaN(ii[1])) 13759 { 13760 s2 = parseInt(ii[1]); 13761 } 13762 else 13763 { 13764 s2 = ii[1].toString().toLowerCase(); 13765 } 13766 13767 if (s1 < s2) 13768 return 1; 13769 else if (s1 > s2) 13770 return -1; 13771 else 13772 return 0; 13773 }); 13774 } 13775 13776 var arReturnArray = Array(); 13777 for (i = 0; i < arItems.length; i++) 13778 { 13779 arReturnArray.push(object[arItems[i][0]]); 13780 } 13781 13782 return arReturnArray; 13783 }, 13784 13785 objectMerge: function() 13786 { 13787 return BX.mergeEx.apply(window, arguments); 13788 }, 13789 13790 objectClone : function(object) 13791 { 13792 return BX.clone(object, true); 13793 }, 13794 13795 // #fdf9e5 => {r=253, g=249, b=229} 13796 hex2rgb: function(color) 13797 { 13798 var rgb = color.replace(/[# ]/g,"").replace(/^(.)(.)(.)$/,'$1$1$2$2$3$3').match(/.{2}/g); 13799 for (var i=0; i<3; i++) 13800 { 13801 rgb[i] = parseInt(rgb[i], 16); 13802 } 13803 return {'r':rgb[0],'g':rgb[1],'b':rgb[2]}; 13804 }, 13805 13806 /** 13807 * @deprecated 13808 * @use BX.Uri 13809 * @param url 13810 * @param param 13811 * @return {string} 13812 */ 13813 remove_url_param: function(url, param) 13814 { 13815 return BX.Uri.removeParam(url, param); 13816 }, 13817 13818 /* 13819 {'param1': 'value1', 'param2': 'value2'} 13820 */ 13821 /** 13822 * @deprecated 13823 * @use BX.Uri 13824 * @param url 13825 * @param params 13826 * @return {string} 13827 */ 13828 add_url_param: function(url, params) 13829 { 13830 var preparedParams = Object.entries(params).reduce(function(acc, item) { 13831 acc[item[0]] = BX.type.isArray(item[1]) ? item[1].join() : item[1]; 13832 return acc; 13833 }, {}); 13834 13835 return BX.Uri.addParam(url, preparedParams); 13836 }, 13837 13838 /* 13839 {'param1': 'value1', 'param2': 'value2'} 13840 */ 13841 buildQueryString: function(params) 13842 { 13843 var result = ''; 13844 for (var key in params) 13845 { 13846 var value = params[key]; 13847 if(BX.type.isArray(value)) 13848 { 13849 value.forEach(function(valueElement, index) 13850 { 13851 result += encodeURIComponent(key + "[" + index + "]") + "=" + encodeURIComponent(valueElement) + "&"; 13852 }); 13853 } 13854 else 13855 { 13856 result += encodeURIComponent(key) + "=" + encodeURIComponent(value) + "&"; 13857 } 13858 } 13859 13860 if(result.length > 0) 13861 { 13862 result = result.substr(0, result.length - 1); 13863 } 13864 return result; 13865 }, 13866 13867 even: function(digit) 13868 { 13869 return (parseInt(digit) % 2 == 0); 13870 }, 13871 13872 hashCode: function(str) 13873 { 13874 if(!BX.type.isNotEmptyString(str)) 13875 { 13876 return 0; 13877 } 13878 13879 var hash = 0; 13880 for (var i = 0; i < str.length; i++) 13881 { 13882 var c = str.charCodeAt(i); 13883 hash = ((hash << 5) - hash) + c; 13884 hash = hash & hash; 13885 } 13886 return hash; 13887 }, 13888 13889 getRandomString: function (length) 13890 { 13891 return BX.Text.getRandom(length); 13892 }, 13893 13894 number_format: function(number, decimals, dec_point, thousands_sep) 13895 { 13896 var i, j, kw, kd, km, sign = ''; 13897 decimals = Math.abs(decimals); 13898 if (isNaN(decimals) || decimals < 0) 13899 { 13900 decimals = 2; 13901 } 13902 dec_point = dec_point || ','; 13903 if (typeof thousands_sep === 'undefined') 13904 thousands_sep = '.'; 13905 13906 number = (+number || 0).toFixed(decimals); 13907 if (number < 0) 13908 { 13909 sign = '-'; 13910 number = -number; 13911 } 13912 13913 i = parseInt(number, 10) + ''; 13914 j = (i.length > 3 ? i.length % 3 : 0); 13915 13916 km = (j ? i.substr(0, j) + thousands_sep : ''); 13917 kw = i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousands_sep); 13918 kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).replace(/-/, '0').slice(2) : ''); 13919 13920 return sign + km + kw + kd; 13921 }, 13922 13923 getExtension: function (url) 13924 { 13925 url = url || ""; 13926 var items = url.split("?")[0].split("."); 13927 return items[items.length-1].toLowerCase(); 13928 }, 13929 addObjectToForm: function(object, form, prefix) 13930 { 13931 if(!BX.type.isString(prefix)) 13932 { 13933 prefix = ""; 13934 } 13935 13936 for(var key in object) 13937 { 13938 if(!object.hasOwnProperty(key)) 13939 { 13940 continue; 13941 } 13942 13943 var value = object[key]; 13944 var name = prefix !== "" ? (prefix + "[" + key + "]") : key; 13945 if(BX.type.isArray(value)) 13946 { 13947 var obj = {}; 13948 for(var i = 0; i < value.length; i++) 13949 { 13950 obj[i] = value[i]; 13951 } 13952 13953 BX.util.addObjectToForm(obj, form, name); 13954 } 13955 else if(BX.type.isPlainObject(value)) 13956 { 13957 BX.util.addObjectToForm(value, form, name); 13958 } 13959 else 13960 { 13961 value = BX.type.isFunction(value.toString) ? value.toString() : ""; 13962 if(value !== "") 13963 { 13964 form.appendChild(BX.create("INPUT", { attrs: { type: "hidden", name: name, value: value } })); 13965 } 13966 } 13967 } 13968 }, 13969 13970 observe: function(object, enable) 13971 {
13972 console.error('BX.util.observe: function is no longer supported by browser.'); 13973 return false; 13974 }, 13975 13976 escapeRegExp: function(str) 13977 { 13978 return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); 13979 } 13980 }; 13981 13982 BX.validation = { 13983 checkIfEmail: function(s) 13984 { 13985 var atom = "[=a-z0-9_+~'!$&*^`|#%/?{}-]"; 13986 return (new RegExp('^\\s*'+atom+'+(\\.'+atom+'+)*@([a-z0-9-]+\\.)+[a-z0-9-]{2,20}\\s*$', 'i')).test(s); 13987 }, 13988 checkIfPhone: function(s) 13989 { 13990 var regexp = new RegExp( 13991 typeof(BX.PhoneNumber) === "undefined" 13992 ? BX.PhoneNumber.getValidNumberPattern() 13993 : '^\\s*\\+?\s*[0-9(-)\\s]+\\s*$', 13994 'i' 13995 ); 13996 return regexp.test(s); 13997 } 13998 }; 13999 14000 BX.prop = 14001 { 14002 get: function(object, key, defaultValue) 14003 { 14004 return object && object.hasOwnProperty(key) ? object[key] : defaultValue; 14005 }, 14006 getObject: function(object, key, defaultValue) 14007 { 14008 return object && BX.type.isPlainObject(object[key]) ? object[key] : defaultValue; 14009 }, 14010 getElementNode: function(object, key, defaultValue) 14011 { 14012 return object && BX.type.isElementNode(object[key]) ? object[key] : defaultValue; 14013 }, 14014 getArray: function(object, key, defaultValue) 14015 { 14016 return object && BX.type.isArray(object[key]) ? object[key] : defaultValue; 14017 }, 14018 getFunction: function(object, key, defaultValue) 14019 { 14020 return object && BX.type.isFunction(object[key]) ? object[key] : defaultValue; 14021 }, 14022 getNumber: function(object, key, defaultValue) 14023 { 14024 if(!(object && object.hasOwnProperty(key))) 14025 { 14026 return defaultValue; 14027 } 14028 14029 var value = object[key]; 14030 if(BX.type.isNumber(value)) 14031 { 14032 return value; 14033 } 14034 14035 value = parseFloat(value); 14036 return !isNaN(value) ? value : defaultValue; 14037 }, 14038 getInteger: function(object, key, defaultValue) 14039 { 14040 if(!(object && object.hasOwnProperty(key))) 14041 { 14042 return defaultValue; 14043 } 14044 14045 var value = object[key]; 14046 if(BX.type.isNumber(value)) 14047 { 14048 return value; 14049 } 14050 14051 value = parseInt(value); 14052 return !isNaN(value) ? value : defaultValue; 14053 }, 14054 getBoolean: function(object, key, defaultValue) 14055 { 14056 if(!(object && object.hasOwnProperty(key))) 14057 { 14058 return defaultValue; 14059 } 14060 14061 var value = object[key]; 14062 return (BX.type.isBoolean(value) 14063 ? value 14064 : (BX.type.isString(value) ? (value.toLowerCase() === "true") : !!value) 14065 ); 14066 }, 14067 getString: function(object, key, defaultValue) 14068 { 14069 if(!(object && object.hasOwnProperty(key))) 14070 { 14071 return defaultValue; 14072 } 14073 14074 var value = object[key]; 14075 return BX.type.isString(value) ? value : (value ? value.toString() : ''); 14076 }, 14077 extractDate: function(datetime) 14078 { 14079 if(!BX.type.isDate(datetime)) 14080 { 14081 datetime = new Date(); 14082 } 14083 14084 datetime.setHours(0); 14085 datetime.setMinutes(0); 14086 datetime.setSeconds(0); 14087 datetime.setMilliseconds(0); 14088 14089 return datetime; 14090 } 14091 }; 14092 14093 BX.isNodeInDom = function(node, doc) 14094 { 14095 return node === (doc || document) ? true : 14096 (node.parentNode ? BX.isNodeInDom(node.parentNode) : false); 14097 }; 14098 14099 BX.isNodeHidden = function(node) 14100 { 14101 if (node === document) 14102 return false; 14103 else if (BX.style(node, 'display') == 'none') 14104 return true; 14105 else 14106 return (node.parentNode ? BX.isNodeHidden(node.parentNode) : true); 14107 }; 14108 14109 BX.evalPack = function(code) 14110 { 14111 while (code.length > 0) 14112 { 14113 var c = code.shift(); 14114 14115 if (c.TYPE == 'SCRIPT_EXT' || c.TYPE == 'SCRIPT_SRC') 14116 { 14117 BX.loadScript(c.DATA, function() {BX.evalPack(code)}); 14118 return; 14119 } 14120 else if (c.TYPE == 'SCRIPT') 14121 { 14122 BX.evalGlobal(c.DATA); 14123 } 14124 } 14125 }; 14126 14127 BX.evalGlobal = function(data) 14128 { 14129 if (data) 14130 { 14131 var head = document.getElementsByTagName("head")[0] || document.documentElement, 14132 script = document.createElement("script"); 14133 14134 script.type = "text/javascript"; 14135 14136 if (!BX.browser.IsIE()) 14137 { 14138 script.appendChild(document.createTextNode(data)); 14139 } 14140 else 14141 { 14142 script.text = data; 14143 } 14144 14145 head.insertBefore(script, head.firstChild); 14146 head.removeChild(script); 14147 } 14148 }; 14149 14150 BX.garbage = function(call, thisObject) 14151 { 14152 garbageCollectors.push({callback: call, context: thisObject}); 14153 }; 14154 14155 BX.GetDocElement = function (pDoc) 14156 { 14157 pDoc = pDoc || document; 14158 return (BX.browser.IsDoctype(pDoc) ? pDoc.documentElement : pDoc.body); 14159 }; 14160 14161 BX.scrollTop = function(node, val){ 14162 if(typeof val != 'undefined'){ 14163 14164 if(node == window){ 14165 throw new Error('scrollTop() for window is not implemented'); 14166 }else 14167 node.scrollTop = parseInt(val); 14168 14169 }else{ 14170 14171 if(node == window) 14172 return BX.GetWindowScrollPos().scrollTop; 14173 14174 return node.scrollTop; 14175 } 14176 }; 14177 14178 BX.scrollLeft = function(node, val){ 14179 if(typeof val != 'undefined'){ 14180 14181 if(node == window){ 14182 throw new Error('scrollLeft() for window is not implemented'); 14183 }else 14184 node.scrollLeft = parseInt(val); 14185 14186 }else{ 14187 14188 if(node == window) 14189 return BX.GetWindowScrollPos().scrollLeft; 14190 14191 return node.scrollLeft; 14192 } 14193 }; 14194 14195 BX.hide_object = function(ob) 14196 { 14197 ob = BX(ob); 14198 ob.style.position = 'absolute'; 14199 ob.style.top = '-1000px'; 14200 ob.style.left = '-1000px'; 14201 ob.style.height = '10px'; 14202 ob.style.width = '10px'; 14203 }; 14204 14205 BX.is_relative = function(el) 14206 { 14207 var p = BX.style(el, 'position'); 14208 return p == 'relative' || p == 'absolute'; 14209 }; 14210 14211 BX.is_float = function(el) 14212 { 14213 var p = BX.style(el, 'float'); 14214 return p == 'right' || p == 'left'; 14215 }; 14216 14217 BX.is_fixed = function(el) 14218 { 14219 var p = BX.style(el, 'position'); 14220 return p == 'fixed'; 14221 }; 14222 14223 BX.width = function(node, val){ 14224 if(typeof val != 'undefined') 14225 BX.style(node, 'width', parseInt(val)+'px'); 14226 else{ 14227 14228 if(node == window) 14229 return window.innerWidth; 14230 14231 //return parseInt(BX.style(node, 'width')); 14232 return BX.pos(node).width; 14233 } 14234 }; 14235 14236 BX.height = function(node, val){ 14237 if(typeof val != 'undefined') 14238 BX.style(node, 'height', parseInt(val)+'px'); 14239 else{ 14240 14241 if(node == window) 14242 return window.innerHeight; 14243 14244 //return parseInt(BX.style(node, 'height')); 14245 return BX.pos(node).height; 14246 } 14247 }; 14248 14249 BX.align = function(pos, w, h, type) 14250 { 14251 if (type) 14252 type = type.toLowerCase(); 14253 else 14254 type = ''; 14255 14256 var pDoc = document; 14257 if (BX.type.isElementNode(pos)) 14258 { 14259 pDoc = pos.ownerDocument; 14260 pos = BX.pos(pos); 14261 } 14262 14263 var x = pos["left"], y = pos["bottom"]; 14264 14265 var scroll = BX.GetWindowScrollPos(pDoc); 14266 var size = BX.GetWindowInnerSize(pDoc); 14267 14268 if((size.innerWidth + scroll.scrollLeft) - (pos["left"] + w) < 0) 14269 { 14270 if(pos["right"] - w >= 0 ) 14271 x = pos["right"] - w; 14272 else 14273 x = scroll.scrollLeft; 14274 } 14275
14276 if(((size.innerHeight + scroll.scrollTop) - (pos["bottom"] + h) < 0) || ~type.indexOf('top')) 14277 { 14278 if(pos["top"] - h >= 0 || ~type.indexOf('top')) 14279 y = pos["top"] - h; 14280 else 14281 y = scroll.scrollTop; 14282 } 14283 14284 return {'left':x, 'top':y}; 14285 }; 14286 14287 BX.scrollToNode = function(node) 14288 { 14289 var obNode = BX(node); 14290 14291 if (obNode.scrollIntoView) 14292 obNode.scrollIntoView(true); 14293 else 14294 { 14295 var arNodePos = BX.pos(obNode); 14296 window.scrollTo(arNodePos.left, arNodePos.top); 14297 } 14298 }; 14299 14300 /* non-xhr loadings */ 14301 BX.showWait = function(node, msg) 14302 { 14303 node = BX(node) || document.body || document.documentElement; 14304 msg = msg || BX.message('JS_CORE_LOADING'); 14305 14306 var container_id = node.id || Math.random(); 14307 14308 var obMsg = node.bxmsg = document.body.appendChild(BX.create('DIV', { 14309 props: { 14310 id: 'wait_' + container_id 14311 }, 14312 style: { 14313 background: 'url("/bitrix/js/main/core/images/wait.gif") no-repeat scroll 10px center #fcf7d1', 14314 border: '1px solid #E1B52D', 14315 color: 'black', 14316 fontFamily: 'Verdana,Arial,sans-serif', 14317 fontSize: '11px', 14318 padding: '10px 30px 10px 37px', 14319 position: 'absolute', 14320 textAlign:'center' 14321 }, 14322 text: msg 14323 })); 14324 14325 BX.ZIndexManager.register(obMsg); 14326 BX.ZIndexManager.bringToFront(obMsg); 14327 14328 setTimeout(BX.delegate(_adjustWait, node), 10); 14329 14330 lastWait[lastWait.length] = obMsg; 14331 return obMsg; 14332 }; 14333 14334 BX.closeWait = function(node, obMsg) 14335 { 14336 if(node && !obMsg) 14337 obMsg = node.bxmsg; 14338 if(node && !obMsg && BX.hasClass(node, 'bx-core-waitwindow')) 14339 obMsg = node; 14340 if(node && !obMsg) 14341 obMsg = BX('wait_' + node.id); 14342 if(!obMsg) 14343 obMsg = lastWait.pop(); 14344 14345 if (obMsg && obMsg.parentNode) 14346 { 14347 for (var i=0,len=lastWait.length;i<len;i++) 14348 { 14349 if (obMsg == lastWait[i]) 14350 { 14351 lastWait = BX.util.deleteFromArray(lastWait, i); 14352 break; 14353 } 14354 } 14355 14356 BX.ZIndexManager.unregister(obMsg); 14357 obMsg.parentNode.removeChild(obMsg); 14358 if (node) node.bxmsg = null; 14359 BX.cleanNode(obMsg, true); 14360 } 14361 }; 14362 14363 BX.setJSList = function(scripts) 14364 { 14365 if (BX.type.isArray(scripts)) 14366 { 14367 scripts = scripts.map(function(script) { 14368 return normalizeUrl(script) 14369 }); 14370 14371 jsList = jsList.concat(scripts); 14372 } 14373 }; 14374 14375 BX.getJSList = function() 14376 { 14377 initJsList(); 14378 return jsList; 14379 }; 14380 14381 BX.setCSSList = function(cssFiles) 14382 { 14383 if (BX.type.isArray(cssFiles)) 14384 { 14385 cssFiles = cssFiles.map(function(cssFile) { 14386 return normalizeUrl(cssFile); 14387 }); 14388 14389 cssList = cssList.concat(cssFiles); 14390 } 14391 }; 14392 14393 BX.getCSSList = function() 14394 { 14395 initCssList(); 14396 return cssList; 14397 }; 14398 14399 BX.getJSPath = function(js) 14400 { 14401 return js.replace(/^(http[s]*:)*\/\/[^\/]+/i, ''); 14402 }; 14403 14404 BX.getCSSPath = function(css) 14405 { 14406 return css.replace(/^(http[s]*:)*\/\/[^\/]+/i, ''); 14407 }; 14408 14409 BX.getCDNPath = function(path) 14410 { 14411 return path; 14412 }; 14413 14414 BX.loadScript = function(script, callback, doc) 14415 { 14416 if (BX.type.isString(script)) 14417 { 14418 script = [script]; 14419 } 14420 14421 return BX.load(script, callback, doc); 14422 }; 14423 14424 BX.loadCSS = function(css, doc, win) 14425 { 14426 if (BX.type.isString(css)) 14427 { 14428 css = [css]; 14429 } 14430 14431 if (BX.type.isArray(css)) 14432 { 14433 css = css.map(function(url) { 14434 return { url: url, ext: "css" } 14435 }); 14436 14437 BX.load(css, null, doc); 14438 } 14439 }; 14440 14441 BX.load = function(items, callback, doc) 14442 { 14443 if (!BX.isReady) 14444 { 14445 var _args = arguments; 14446 BX.ready(function() { 14447 BX.load.apply(this, _args); 14448 }); 14449 return null; 14450 } 14451 14452 doc = doc || document; 14453 if (isAsync === null) 14454 { 14455 isAsync = "async" in doc.createElement("script") || "MozAppearance" in doc.documentElement.style || window.opera; 14456 } 14457 14458 return isAsync ? loadAsync(items, callback, doc) : loadAsyncEmulation(items, callback, doc); 14459 }; 14460 14461 BX.convert = 14462 { 14463 toNumber: function(value) 14464 { 14465 if(BX.type.isNumber(value)) 14466 { 14467 return value; 14468 } 14469 14470 value = Number(value); 14471 return !isNaN(value) ? value : 0; 14472 }, 14473 nodeListToArray: function(nodes) 14474 { 14475 try 14476 { 14477 return (Array.prototype.slice.call(nodes, 0)); 14478 } 14479 catch (ex) 14480 { 14481 var ary = []; 14482 for(var i = 0, l = nodes.length; i < l; i++) 14483 { 14484 ary.push(nodes[i]); 14485 } 14486 return ary; 14487 } 14488 } 14489 }; 14490 14491 function loadAsync(items, callback, doc) 14492 { 14493 if (!BX.type.isArray(items)) 14494 { 14495 return; 14496 } 14497 14498 function allLoaded(items) 14499 { 14500 items = items || assets; 14501 for (var name in items) 14502 { 14503 if (items.hasOwnProperty(name) && items[name].state !== LOADED) 14504 { 14505 return false;
14506 } 14507 } 14508 14509 return true; 14510 } 14511 14512 if (!BX.type.isFunction(callback)) 14513 { 14514 callback = null; 14515 } 14516 14517 var itemSet = {}, item, i; 14518 for (i = 0; i < items.length; i++) 14519 { 14520 item = items[i]; 14521 item = getAsset(item); 14522 itemSet[item.name] = item; 14523 } 14524 14525 var callbackWasCalled = false; 14526 if (items.length > 0) 14527 { 14528 for (i = 0; i < items.length; i++) 14529 { 14530 item = items[i]; 14531 item = getAsset(item); 14532 load(item, function () { 14533 if (allLoaded(itemSet)) 14534 { 14535 if (!callbackWasCalled) 14536 { 14537 callback && callback(); 14538 callbackWasCalled = true; 14539 } 14540 14541 } 14542 }, doc); 14543 } 14544 } 14545 else 14546 { 14547 if (typeof callback === 'function') 14548 { 14549 callback(); 14550 callbackWasCalled = true; 14551 } 14552 } 14553 } 14554 14555 function loadAsyncEmulation(items, callback, doc) 14556 { 14557 function onPreload(asset) 14558 { 14559 asset.state = PRELOADED; 14560 if (BX.type.isArray(asset.onpreload) && asset.onpreload) 14561 { 14562 for (var i = 0; i < asset.onpreload.length; i++) 14563 { 14564 asset.onpreload[i].call(); 14565 } 14566 } 14567 } 14568 14569 function preLoad(asset) 14570 { 14571 if (asset.state === undefined) 14572 { 14573 asset.state = PRELOADING; 14574 asset.onpreload = []; 14575 14576 loadAsset( 14577 { url: asset.url, type: "cache", ext: asset.ext}, 14578 function () { onPreload(asset); }, 14579 doc 14580 ); 14581 } 14582 } 14583 14584 if (!BX.type.isArray(items)) 14585 { 14586 return; 14587 } 14588 14589 if (!BX.type.isFunction(callback)) 14590 { 14591 callback = null; 14592 } 14593 14594 var rest = [].slice.call(items, 1); 14595 for (var i = 0; i < rest.length; i++) 14596 { 14597 preLoad(getAsset(rest[i])); 14598 } 14599 14600 load(getAsset(items[0]), items.length === 1 ? callback : function () { 14601 loadAsyncEmulation.apply(null, [rest, callback, doc]); 14602 }, doc); 14603 } 14604 14605 function load(asset, callback, doc) 14606 { 14607 callback = callback || BX.DoNothing; 14608 14609 if (asset.state === LOADED) 14610 { 14611 callback(); 14612 return; 14613 } 14614 14615 if (asset.state === PRELOADING) 14616 { 14617 asset.onpreload.push(function () { 14618 load(asset, callback, doc); 14619 }); 14620 return; 14621 } 14622 14623 asset.state = LOADING; 14624 14625 loadAsset( 14626 asset, 14627 function () { 14628 asset.state = LOADED; 14629 callback(); 14630 }, 14631 doc 14632 ); 14633 } 14634 14635 function loadAsset(asset, callback, doc) 14636 { 14637 callback = callback || BX.DoNothing; 14638 14639 function error(event) 14640 { 14641 ele.onload = ele.onreadystatechange = ele.onerror = null; 14642 callback(); 14643 } 14644 14645 function process(event) 14646 { 14647 event = event || window.event; 14648 if (event.type === "load" || (/loaded|complete/.test(ele.readyState) && (!doc.documentMode || doc.documentMode < 9))) 14649 { 14650 window.clearTimeout(asset.errorTimeout); 14651 window.clearTimeout(asset.cssTimeout); 14652 ele.onload = ele.onreadystatechange = ele.onerror = null; 14653 callback(); 14654 } 14655 } 14656 14657 function isCssLoaded() 14658 { 14659 if (asset.state !== LOADED && asset.cssRetries <= 20) 14660 { 14661 for (var i = 0, l = doc.styleSheets.length; i < l; i++) 14662 { 14663 if (doc.styleSheets[i].href === ele.href) 14664 { 14665 process({"type": "load"}); 14666 return; 14667 } 14668 } 14669 14670 asset.cssRetries++; 14671 asset.cssTimeout = window.setTimeout(isCssLoaded, 250); 14672 } 14673 } 14674 14675 var ele; 14676 var ext = BX.type.isNotEmptyString(asset.ext) ? asset.ext : BX.util.getExtension(asset.url); 14677 14678 if (ext === "css") 14679 { 14680 ele = doc.createElement("link"); 14681 ele.type = "text/" + (asset.type || "css"); 14682 ele.rel = "stylesheet"; 14683 ele.href = asset.url; 14684 14685 asset.cssRetries = 0; 14686 asset.cssTimeout = window.setTimeout(isCssLoaded, 500); 14687 } 14688 else 14689 { 14690 ele = doc.createElement("script"); 14691 ele.type = "text/" + (asset.type || "javascript"); 14692 ele.src = asset.url; 14693 } 14694 14695 ele.onload = ele.onreadystatechange = process; 14696 ele.onerror = error; 14697 14698 ele.async = false; 14699 ele.defer = false; 14700 14701 asset.errorTimeout = window.setTimeout(function () { 14702 error({type: "timeout"}); 14703 }, 7000); 14704 14705 if (ext === "css") 14706 { 14707 cssList.push(normalizeMinUrl(normalizeUrl(asset.url))); 14708 } 14709 else 14710 { 14711 jsList.push(normalizeMinUrl(normalizeUrl(asset.url))); 14712 } 14713 14714 var templateLink = null; 14715 var head = doc.head || doc.getElementsByTagName("head")[0]; 14716 if (ext === "css" && (templateLink = getTemplateLink(head)) !== null) 14717 { 14718 templateLink.parentNode.insertBefore(ele, templateLink); 14719 } 14720 else 14721 { 14722 head.insertBefore(ele, head.lastChild); 14723 } 14724 } 14725 14726 function getAsset(item) 14727 { 14728 var asset = {}; 14729 if (typeof item === "object") 14730 { 14731 asset = item; 14732 asset.name = asset.name ? asset.name : BX.util.hashCode(item.url); 14733 } 14734 else 14735 { 14736 asset = { name: BX.util.hashCode(item), url : item }; 14737 } 14738 14739 var ext = BX.type.isNotEmptyString(asset.ext) ? asset.ext : BX.util.getExtension(asset.url); 14740 if ((ext === "css" && isCssLoaded(asset.url)) || isScriptLoaded(asset.url)) 14741 { 14742 asset.state = LOADED; 14743 } 14744 14745 var existing = assets[asset.name]; 14746 if (existing && existing.url === asset.url) 14747 { 14748 return existing; 14749 } 14750 14751 assets[asset.name] = asset; 14752 return asset; 14753 } 14754 14755 function normalizeUrl(url) 14756 { 14757 if (!BX.type.isNotEmptyString(url)) 14758 { 14759 return ""; 14760 } 14761 14762 url = BX.getJSPath(url); 14763 url = url.replace(/\?[0-9]*$/, ""); 14764 14765 return url; 14766 } 14767 14768 function normalizeMinUrl(url) 14769 { 14770 if (!BX.type.isNotEmptyString(url)) 14771 { 14772 return ""; 14773 } 14774 14775 var minPos = url.indexOf(".min"); 14776 return minPos >= 0 ? url.substr(0, minPos) + url.substr(minPos + 4) : url; 14777 } 14778 14779 function isCssLoaded(fileSrc) 14780 { 14781 initCssList(); 14782 14783 fileSrc = normalizeUrl(fileSrc); 14784 var fileSrcMin = normalizeMinUrl(fileSrc); 14785 14786 return (fileSrc !== fileSrcMin && BX.util.in_array(fileSrcMin, cssList)) || BX.util.in_array(fileSrc, cssList); 14787 } 14788 14789 function initCssList() 14790 { 14791 if(!cssInit) 14792 { 14793 var linksCol = document.getElementsByTagName('link'); 14794 14795 if(!!linksCol && linksCol.length > 0) 14796 { 14797 for(var i = 0; i < linksCol.length; i++) 14798 { 14799 var href = linksCol[i].getAttribute('href'); 14800 if (BX.type.isNotEmptyString(href)) 14801 { 14802 href = normalizeMinUrl(normalizeUrl(href)); 14803 cssList.push(href); 14804 } 14805 } 14806 } 14807 cssInit = true; 14808 } 14809 } 14810 14811 function getTemplateLink(head) 14812 { 14813 var findLink = function(tag) 14814 { 14815 var links = head.getElementsByTagName(tag); 14816 for (var i = 0, length = links.length; i < length; i++) 14817 { 14818 var templateStyle = links[i].getAttribute("data-template-style"); 14819 if (BX.type.isNotEmptyString(templateStyle) && templateStyle == "true") 14820 { 14821 return links[i]; 14822 } 14823 } 14824 14825 return null; 14826 }; 14827 14828 var link = findLink("link"); 14829 if (link === null) 14830 { 14831 link = findLink("style"); 14832 } 14833 14834 return link; 14835 } 14836 14837 function isScriptLoaded(fileSrc) 14838 { 14839 initJsList(); 14840 14841 fileSrc = normalizeUrl(fileSrc); 14842 var fileSrcMin = normalizeMinUrl(fileSrc); 14843 14844 return (fileSrc !== fileSrcMin && BX.util.in_array(fileSrcMin, jsList)) || BX.util.in_array(fileSrc, jsList); 14845 } 14846 14847 function initJsList() 14848 { 14849 if(!jsInit) 14850 { 14851 var scriptCol = document.getElementsByTagName('script'); 14852 14853 if(!!scriptCol && scriptCol.length > 0) 14854 { 14855 for(var i=0; i<scriptCol.length; i++) 14856 { 14857 var src = scriptCol[i].getAttribute('src'); 14858 14859 if (BX.type.isNotEmptyString(src)) 14860 { 14861 src = normalizeMinUrl(normalizeUrl(src)); 14862 jsList.push(src); 14863 } 14864 } 14865 } 14866 jsInit = true; 14867 } 14868 } 14869 14870 function reloadInternal(back_url, bAddClearCache) 14871 { 14872 if (back_url === true) 14873 { 14874 bAddClearCache = true; 14875 back_url = null; 14876 } 14877 14878 var topWindow = (function() { 14879 if (BX.PageObject && BX.PageObject.getRootWindow) 14880 { 14881 return BX.PageObject.getRootWindow(); 14882 } 14883 14884 return window.top; 14885 })(); 14886 var new_href = back_url || topWindow.location.href; 14887 14888 var hashpos = new_href.indexOf('#'), hash = ''; 14889 14890 if (hashpos != -1) 14891 { 14892 hash = new_href.substr(hashpos); 14893 new_href = new_href.substr(0, hashpos); 14894 } 14895 14896 if (bAddClearCache && new_href.indexOf('clear_cache=Y') < 0) 14897 new_href += (new_href.indexOf('?') == -1 ? '?' : '&') + 'clear_cache=Y'; 14898 14899 if (hash) 14900 { 14901 // hack for clearing cache in ajax mode components with history emulation 14902 if (bAddClearCache && (hash.substr(0, 5) == 'view/' || hash.substr(0, 6) == '#view/') && hash.indexOf('clear_cache%3DY') < 0) 14903 hash += (hash.indexOf('%3F') == -1 ? '%3F' : '%26') + 'clear_cache%3DY'; 14904 14905 new_href = new_href.replace(/(\?|\&)_r=[\d]*/, ''); 14906 new_href += (new_href.indexOf('?') == -1 ? '?' : '&') + '_r='+Math.round(Math.random()*10000) + hash; 14907 } 14908 14909 topWindow.location.href = new_href; 14910 } 14911 14912 BX.reload = function(back_url, bAddClearCache) 14913 { 14914 if (window !== window.top) 14915 { 14916 BX.Runtime 14917 .loadExtension('main.pageobject') 14918 .then(function() { 14919 reloadInternal(back_url, bAddClearCache); 14920 }); 14921 } 14922 else 14923 { 14924 reloadInternal(back_url, bAddClearCache); 14925 } 14926 }; 14927 14928 BX.clearCache = function() 14929 { 14930 BX.showWait(); 14931 BX.reload(true); 14932 }; 14933 14934 BX.template = function(tpl, callback, bKillTpl) 14935 { 14936 BX.ready(function() { 14937 _processTpl(BX(tpl), callback, bKillTpl); 14938 }); 14939 }; 14940 14941 BX.isAmPmMode = function(returnConst) 14942 { 14943 if (returnConst === true) 14944 { 14945 return BX.message.AMPM_MODE; 14946 } 14947 return BX.message.AMPM_MODE !== false; 14948 }; 14949 14950 BX.formatDate = function(date, format) 14951 { 14952 date = date || new Date(); 14953 14954 var bTime = date.getHours() || date.getMinutes() || date.getSeconds(), 14955 str = !!format 14956 ? format : 14957 (bTime ? BX.message('FORMAT_DATETIME') : BX.message('FORMAT_DATE') 14958 ); 14959 14960 return str.replace(/YYYY/ig, date.getFullYear()) 14961 .replace(/MMMM/ig, BX.util.str_pad_left((date.getMonth()+1).toString(), 2, '0')) 14962 .replace(/MM/ig, BX.util.str_pad_left((date.getMonth()+1).toString(), 2, '0')) 14963 .replace(/DD/ig, BX.util.str_pad_left(date.getDate().toString(), 2, '0')) 14964 .replace(/HH/ig, BX.util.str_pad_left(date.getHours().toString(), 2, '0')) 14965 .replace(/MI/ig, BX.util.str_pad_left(date.getMinutes().toString(), 2, '0')) 14966 .replace(/SS/ig, BX.util.str_pad_left(date.getSeconds().toString(), 2, '0')); 14967 }; 14968 BX.formatName = function(user, template, login) 14969 { 14970 user = user || {}; 14971 template = (template || ''); 14972 var replacement = { 14973 TITLE : (user["TITLE"] || ''), 14974 NAME : (user["NAME"] || ''),
14975 LAST_NAME : (user["LAST_NAME"] || ''), 14976 SECOND_NAME : (user["SECOND_NAME"] || ''), 14977 LOGIN : (user["LOGIN"] || ''), 14978 NAME_SHORT : user["NAME"] ? user["NAME"].substr(0, 1) + '.' : '', 14979 LAST_NAME_SHORT : user["LAST_NAME"] ? user["LAST_NAME"].substr(0, 1) + '.' : '', 14980 SECOND_NAME_SHORT : user["SECOND_NAME"] ? user["SECOND_NAME"].substr(0, 1) + '.' : '', 14981 EMAIL : (user["EMAIL"] || ''), 14982 ID : (user["ID"] || ''), 14983 NOBR : "", 14984 '/NOBR' : "" 14985 }, result = template; 14986 for (var ii in replacement) 14987 { 14988 if (replacement.hasOwnProperty(ii)) 14989 { 14990 result = result.replace("#" + ii+ "#", replacement[ii]) 14991 } 14992 } 14993 result = result.replace(/([\s]+)/gi, " ").trim(); 14994 if (result == "") 14995 { 14996 result = (login == "Y" ? replacement["LOGIN"] : ""); 14997 result = (result == "" ? "Noname" : result); 14998 } 14999 return result; 15000 }; 15001 15002 BX.getNumMonth = function(month) 15003 { 15004 var wordMonthCut = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']; 15005 var wordMonth = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december']; 15006 15007 var q = month.toUpperCase(); 15008 for (i = 1; i <= 12; i++) 15009 { 15010 if (q == BX.message('MON_'+i).toUpperCase() || q == BX.message('MONTH_'+i).toUpperCase() || q == wordMonthCut[i-1].toUpperCase() || q == wordMonth[i-1].toUpperCase()) 15011 { 15012 return i; 15013 } 15014 } 15015 return month; 15016 }; 15017 15018 BX.parseDate = function(str, bUTC, formatDate, formatDatetime) 15019 { 15020 if (BX.type.isNotEmptyString(str)) 15021 { 15022 if (!formatDate) 15023 formatDate = BX.message('FORMAT_DATE'); 15024 if (!formatDatetime) 15025 formatDatetime = BX.message('FORMAT_DATETIME'); 15026 15027 var regMonths = ''; 15028 for (i = 1; i <= 12; i++) 15029 { 15030 regMonths = regMonths + '|' + BX.message('MON_'+i); 15031 } 15032
15033 var expr = new RegExp('([0-9]+|[a-z]+' + regMonths + ')', 'ig'); 15034 var aDate = str.match(expr), 15035 aFormat = formatDate.match(/(DD|MI|MMMM|MM|M|YYYY)/ig), 15036 i, cnt, 15037 aDateArgs=[], aFormatArgs=[], 15038 aResult={}; 15039 15040 if (!aDate) 15041 return null; 15042 15043 if(aDate.length > aFormat.length) 15044 { 15045 aFormat = formatDatetime.match(/(DD|MI|MMMM|MM|M|YYYY|HH|H|SS|TT|T|GG|G)/ig); 15046 } 15047 15048 for(i = 0, cnt = aDate.length; i < cnt; i++) 15049 { 15050 if(BX.util.trim(aDate[i]) != '') 15051 { 15052 aDateArgs[aDateArgs.length] = aDate[i]; 15053 } 15054 } 15055 15056 for(i = 0, cnt = aFormat.length; i < cnt; i++) 15057 { 15058 if(BX.util.trim(aFormat[i]) != '') 15059 { 15060 aFormatArgs[aFormatArgs.length] = aFormat[i]; 15061 } 15062 } 15063 15064 15065 var m = BX.util.array_search('MMMM', aFormatArgs); 15066 if (m > 0) 15067 { 15068 aDateArgs[m] = BX.getNumMonth(aDateArgs[m]); 15069 aFormatArgs[m] = "MM"; 15070 } 15071 else 15072 { 15073 m = BX.util.array_search('M', aFormatArgs); 15074 if (m > 0) 15075 { 15076 aDateArgs[m] = BX.getNumMonth(aDateArgs[m]); 15077 aFormatArgs[m] = "MM"; 15078 } 15079 } 15080 15081 for(i = 0, cnt = aFormatArgs.length; i < cnt; i++) 15082 { 15083 var k = aFormatArgs[i].toUpperCase(); 15084 aResult[k] = k == 'T' || k == 'TT' ? aDateArgs[i] : parseInt(aDateArgs[i], 10); 15085 } 15086 15087 if(aResult['DD'] > 0 && aResult['MM'] > 0 && aResult['YYYY'] > 0) 15088 { 15089 var d = new Date(); 15090 15091 if(bUTC) 15092 { 15093 d.setUTCDate(1); 15094 d.setUTCFullYear(aResult['YYYY']); 15095 d.setUTCMonth(aResult['MM'] - 1); 15096 d.setUTCDate(aResult['DD']); 15097 d.setUTCHours(0, 0, 0, 0); 15098 } 15099 else 15100 { 15101 d.setDate(1); 15102 d.setFullYear(aResult['YYYY']); 15103 d.setMonth(aResult['MM'] - 1); 15104 d.setDate(aResult['DD']); 15105 d.setHours(0, 0, 0, 0); 15106 } 15107 15108 if( 15109 (!isNaN(aResult['HH']) || !isNaN(aResult['GG']) || !isNaN(aResult['H']) || !isNaN(aResult['G'])) 15110 && !isNaN(aResult['MI']) 15111 ) 15112 { 15113 if (!isNaN(aResult['H']) || !isNaN(aResult['G'])) 15114 { 15115 var bPM = (aResult['T']||aResult['TT']||'am').toUpperCase()=='PM'; 15116 var h = parseInt(aResult['H']||aResult['G']||0, 10); 15117 if(bPM) 15118 { 15119 aResult['HH'] = h + (h == 12 ? 0 : 12); 15120 } 15121 else 15122 { 15123 aResult['HH'] = h < 12 ? h : 0; 15124 } 15125 } 15126 else 15127 { 15128 aResult['HH'] = parseInt(aResult['HH']||aResult['GG']||0, 10); 15129 } 15130 15131 if (isNaN(aResult['SS'])) 15132 aResult['SS'] = 0; 15133 15134 if(bUTC) 15135 { 15136 d.setUTCHours(aResult['HH'], aResult['MI'], aResult['SS']); 15137 } 15138 else 15139 { 15140 d.setHours(aResult['HH'], aResult['MI'], aResult['SS']); 15141 } 15142 } 15143 15144 return d; 15145 } 15146 } 15147 15148 return null; 15149 }; 15150 15151 BX.selectUtils = 15152 { 15153 addNewOption: function(oSelect, opt_value, opt_name, do_sort, check_unique) 15154 { 15155 oSelect = BX(oSelect); 15156 if(oSelect) 15157 { 15158 var n = oSelect.length; 15159 if(check_unique !== false) 15160 { 15161 for(var i=0;i<n;i++) 15162 { 15163 if(oSelect[i].value==opt_value) 15164 { 15165 return; 15166 } 15167 } 15168 } 15169 15170 oSelect.options[n] = new Option(opt_name, opt_value, false, false); 15171 } 15172 15173 if(do_sort === true) 15174 { 15175 this.sortSelect(oSelect); 15176 } 15177 }, 15178 15179 deleteOption: function(oSelect, opt_value) 15180 { 15181 oSelect = BX(oSelect); 15182 if(oSelect) 15183 { 15184 for(var i=0;i<oSelect.length;i++) 15185 { 15186 if(oSelect[i].value==opt_value) 15187 { 15188 oSelect.remove(i); 15189 break; 15190 } 15191 } 15192 } 15193 }, 15194 15195 deleteSelectedOptions: function(oSelect) 15196 { 15197 oSelect = BX(oSelect); 15198 if(oSelect) 15199 { 15200 var i=0; 15201 while(i<oSelect.length) 15202 { 15203 if(oSelect[i].selected) 15204 { 15205 oSelect[i].selected=false; 15206 oSelect.remove(i); 15207 } 15208 else 15209 { 15210 i++; 15211 } 15212 } 15213 } 15214 }, 15215 15216 deleteAllOptions: function(oSelect) 15217 { 15218 oSelect = BX(oSelect); 15219 if(oSelect) 15220 { 15221 for(var i=oSelect.length-1; i>=0; i--) 15222 { 15223 oSelect.remove(i); 15224 } 15225 } 15226 }, 15227 15228 optionCompare: function(record1, record2) 15229 { 15230 var value1 = record1.optText.toLowerCase(); 15231 var value2 = record2.optText.toLowerCase(); 15232 if (value1 > value2) return(1); 15233 if (value1 < value2) return(-1); 15234 return(0); 15235 }, 15236 15237 sortSelect: function(oSelect) 15238 { 15239 oSelect = BX(oSelect); 15240 if(oSelect) 15241 { 15242 var myOptions = []; 15243 var n = oSelect.options.length; 15244 var i; 15245 for (i=0;i<n;i++) 15246 { 15247 myOptions[i] = { 15248 optText:oSelect[i].text, 15249 optValue:oSelect[i].value 15250 }; 15251 } 15252 myOptions.sort(this.optionCompare); 15253 oSelect.length=0; 15254 n = myOptions.length; 15255 for(i=0;i<n;i++) 15256 { 15257 oSelect[i] = new Option(myOptions[i].optText, myOptions[i].optValue, false, false); 15258 } 15259 } 15260 }, 15261 15262 selectAllOptions: function(oSelect) 15263 { 15264 oSelect = BX(oSelect); 15265 if(oSelect) 15266 { 15267 var n = oSelect.length; 15268 for(var i=0;i<n;i++) 15269 { 15270 oSelect[i].selected=true; 15271 } 15272 } 15273 }, 15274 15275 selectOption: function(oSelect, opt_value) 15276 { 15277 oSelect = BX(oSelect); 15278 if(oSelect) 15279 { 15280 var n = oSelect.length; 15281 for(var i=0;i<n;i++) 15282 { 15283 oSelect[i].selected = (oSelect[i].value == opt_value); 15284 } 15285 } 15286 }, 15287 15288 addSelectedOptions: function(oSelect, to_select_id, check_unique, do_sort) 15289 { 15290 oSelect = BX(oSelect); 15291 if(!oSelect) 15292 return; 15293 var n = oSelect.length; 15294 for(var i=0; i<n; i++) 15295 if(oSelect[i].selected) 15296 this.addNewOption(to_select_id, oSelect[i].value, oSelect[i].text, do_sort, check_unique); 15297 }, 15298 15299 moveOptionsUp: function(oSelect) 15300 { 15301 oSelect = BX(oSelect); 15302 if(!oSelect) 15303 return; 15304 var n = oSelect.length; 15305 for(var i=0; i<n; i++) 15306 { 15307 if(oSelect[i].selected && i>0 && oSelect[i-1].selected == false) 15308 { 15309 var option = new Option(oSelect[i].text, oSelect[i].value); 15310 oSelect[i] = new Option(oSelect[i-1].text, oSelect[i-1].value); 15311 oSelect[i].selected = false;
15312 oSelect[i-1] = option; 15313 oSelect[i-1].selected = true; 15314 } 15315 } 15316 }, 15317 15318 moveOptionsDown: function(oSelect) 15319 { 15320 oSelect = BX(oSelect); 15321 if(!oSelect) 15322 return; 15323 var n = oSelect.length; 15324 for(var i=n-1; i>=0; i--) 15325 { 15326 if(oSelect[i].selected && i<n-1 && oSelect[i+1].selected == false) 15327 { 15328 var option = new Option(oSelect[i].text, oSelect[i].value); 15329 oSelect[i] = new Option(oSelect[i+1].text, oSelect[i+1].value); 15330 oSelect[i].selected = false; 15331 oSelect[i+1] = option; 15332 oSelect[i+1].selected = true; 15333 } 15334 } 15335 } 15336 }; 15337 15338 BX.getEventTarget = function(e) 15339 { 15340 if(e.target) 15341 { 15342 return e.target; 15343 } 15344 else if(e.srcElement) 15345 { 15346 return e.srcElement; 15347 } 15348 return null; 15349 }; 15350 15351 /******* HINT ***************/ 15352// if function has 2 params - the 2nd one is hint html. otherwise hint_html is third and hint_title - 2nd; 15353// '<div onmouseover="BX.hint(this, 'This is <b>Hint</b>')"'>; 15354// BX.hint(el, 'This is <b>Hint</b>') - this won't work, use constructor 15355 BX.hint = function(el, hint_title, hint_html, hint_id) 15356 { 15357 if (null == hint_html) 15358 { 15359 hint_html = hint_title; 15360 hint_title = ''; 15361 } 15362 15363 if (null == el.BXHINT) 15364 { 15365 el.BXHINT = new BX.CHint({ 15366 parent: el, hint: hint_html, title: hint_title, id: hint_id 15367 }); 15368 el.BXHINT.Show(); 15369 } 15370 }; 15371 15372 BX.hint_replace = function(el, hint_title, hint_html) 15373 { 15374 if (null == hint_html) 15375 { 15376 hint_html = hint_title; 15377 hint_title = ''; 15378 } 15379 15380 if (!el || !el.parentNode || !hint_html) 15381 return null; 15382 15383 var obHint = new BX.CHint({ 15384 hint: hint_html, 15385 title: hint_title 15386 }); 15387 15388 obHint.CreateParent(); 15389 15390 el.parentNode.insertBefore(obHint.PARENT, el); 15391 el.parentNode.removeChild(el); 15392 15393 obHint.PARENT.style.marginLeft = '5px'; 15394 15395 return el; 15396 }; 15397 15398 BX.CHint = function(params) 15399 { 15400 if (BX.CHint.cssLoaded === false) 15401 { 15402 BX.load(['/bitrix/js/main/core/css/core_hint.css']); 15403 BX.CHint.cssLoaded = true; 15404 } 15405 15406 this.PARENT = BX(params.parent); 15407 15408 this.HINT = params.hint; 15409 this.HINT_TITLE = params.title; 15410 15411 this.PARAMS = {}; 15412 for (var i in this.defaultSettings) 15413 { 15414 if (null == params[i]) 15415 this.PARAMS[i] = this.defaultSettings[i]; 15416 else 15417 this.PARAMS[i] = params[i]; 15418 } 15419 15420 if (null != params.id) 15421 this.ID = params.id; 15422 15423 this.timer = null; 15424 this.bInited = false; 15425 this.msover = true; 15426 15427 if (this.PARAMS.showOnce) 15428 { 15429 this.__show(); 15430 this.msover = false; 15431 this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout); 15432 } 15433 else if (this.PARENT) 15434 { 15435 BX.bind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 15436 BX.bind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 15437 } 15438 }; 15439 15440 BX.CHint.cssLoaded = false; 15441 15442 BX.CHint.openHints = new Set(); 15443 15444 BX.CHint.globalDisabled = false; 15445 15446 BX.CHint.handleMenuOpen = function() { 15447 BX.CHint.globalDisabled = true; 15448 15449 BX.CHint.openHints.forEach(function(hint) { 15450 hint.__hide_immediately(); 15451 }); 15452 }; 15453 15454 BX.CHint.handleMenuClose = function() { 15455 BX.CHint.globalDisabled = false; 15456 }; 15457 15458 BX.addCustomEvent('onMenuOpen', BX.CHint.handleMenuOpen); 15459 BX.addCustomEvent('onMenuClose', BX.CHint.handleMenuClose); 15460 15461 BX.CHint.prototype.defaultSettings = { 15462 show_timeout: 1000, 15463 hide_timeout: 500, 15464 dx: 2, 15465 showOnce: false, 15466 preventHide: true, 15467 min_width: 250 15468 }; 15469 15470 BX.CHint.prototype.CreateParent = function(element, params) 15471 { 15472 if (this.PARENT) 15473 { 15474 BX.unbind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 15475 BX.unbind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 15476 } 15477 15478 if (!params) params = {}; 15479 var type = 'icon'; 15480 15481 if (params.type && (params.type == "link" || params.type == "icon")) 15482 type = params.type; 15483 15484 if (element) 15485 type = "element"; 15486 15487 if (type == "icon") 15488 { 15489 element = BX.create('IMG', { 15490 props: { 15491 src: params.iconSrc 15492 ? params.iconSrc 15493 : "/bitrix/js/main/core/images/hint.gif" 15494 } 15495 }); 15496 } 15497 else if (type == "link") 15498 { 15499 element = BX.create("A", { 15500 props: {href: 'javascript:void(0)'}, 15501 html: '[?]' 15502 }); 15503 } 15504 15505 this.PARENT = element; 15506 15507 BX.bind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 15508 BX.bind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 15509 15510 return this.PARENT; 15511 }; 15512 15513 BX.CHint.prototype.Show = function() 15514 { 15515 this.msover = true; 15516 15517 if (null != this.timer) 15518 clearTimeout(this.timer); 15519 15520 this.timer = setTimeout(BX.proxy(this.__show, this), this.PARAMS.show_timeout); 15521 }; 15522 15523 BX.CHint.prototype.Hide = function() 15524 { 15525 this.msover = false;
15526 15527 if (null != this.timer) 15528 clearTimeout(this.timer); 15529 15530 this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout); 15531 }; 15532 15533 BX.CHint.prototype.__show = function() 15534 { 15535 if (!this.msover || this.disabled || BX.CHint.globalDisabled) return; 15536 if (!this.bInited) this.Init(); 15537 15538 if (this.prepareAdjustPos()) 15539 { 15540 this.DIV.style.display = 'block'; 15541 BX.ZIndexManager.bringToFront(this.DIV); 15542 15543 this.adjustPos(); 15544 15545 BX.CHint.openHints.add(this); 15546 15547 BX.bind(window, 'scroll', BX.proxy(this.__onscroll, this)); 15548 15549 if (this.PARAMS.showOnce) 15550 { 15551 this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout); 15552 } 15553 } 15554 }; 15555 15556 BX.CHint.prototype.__onscroll = function() 15557 { 15558 if (!BX.admin || !BX.admin.panel || !BX.admin.panel.isFixed()) return; 15559 15560 if (this.scrollTimer) clearTimeout(this.scrollTimer); 15561 15562 this.DIV.style.display = 'none'; 15563 this.scrollTimer = setTimeout(BX.proxy(this.Reopen, this), this.PARAMS.show_timeout); 15564 }; 15565 15566 BX.CHint.prototype.Reopen = function() 15567 { 15568 if (null != this.timer) clearTimeout(this.timer); 15569 this.timer = setTimeout(BX.proxy(this.__show, this), 50); 15570 }; 15571 15572 BX.CHint.prototype.__hide = function() 15573 { 15574 if (this.msover) return; 15575 if (!this.bInited) return; 15576 15577 BX.unbind(window, 'scroll', BX.proxy(this.Reopen, this)); 15578 15579 BX.CHint.openHints.delete(this); 15580 15581 if (this.PARAMS.showOnce) 15582 { 15583 this.Destroy(); 15584 } 15585 else 15586 { 15587 this.DIV.style.display = 'none'; 15588 } 15589 }; 15590 15591 BX.CHint.prototype.__hide_immediately = function() 15592 { 15593 this.msover = false; 15594 this.__hide(); 15595 }; 15596 15597 BX.CHint.prototype.Init = function() 15598 { 15599 this.DIV = document.body.appendChild(BX.create('DIV', { 15600 props: {className: 'bx-panel-tooltip'}, 15601 style: { 15602 display: 'none', 15603 position: 'absolute', 15604 visibility: 'hidden' 15605 }, 15606 children: [ 15607 (this.CONTENT = BX.create('DIV', { 15608 props: {className: 'bx-panel-tooltip-content'}, 15609 children: [ 15610 BX.create('DIV', { 15611 props: {className: 'bx-panel-tooltip-underlay'}, 15612 children: [ 15613 BX.create('DIV', {props: {className: 'bx-panel-tooltip-underlay-bg'}}) 15614 ] 15615 }) 15616 ] 15617 })) 15618 ] 15619 })); 15620 15621 BX.ZIndexManager.register(this.DIV); 15622 15623 if (this.ID) 15624 { 15625 this.CONTENT.insertBefore(BX.create('A', { 15626 attrs: {href: 'javascript:void(0)'}, 15627 props: {className: 'bx-panel-tooltip-close'}, 15628 events: {click: BX.delegate(this.Close, this)} 15629 }), this.CONTENT.firstChild); 15630 } 15631 15632 if (this.HINT_TITLE) 15633 { 15634 this.CONTENT.appendChild( 15635 BX.create('DIV', { 15636 props: {className: 'bx-panel-tooltip-title'}, 15637 text: this.HINT_TITLE 15638 }) 15639 ); 15640 } 15641 15642 if (this.HINT) 15643 { 15644 this.CONTENT_TEXT = this.CONTENT.appendChild(BX.create('DIV', {props: {className: 'bx-panel-tooltip-text'}})).appendChild(BX.create('SPAN', {html: this.HINT})); 15645 } 15646 15647 if (this.PARAMS.preventHide) 15648 { 15649 BX.bind(this.DIV, 'mouseout', BX.proxy(this.Hide, this)); 15650 BX.bind(this.DIV, 'mouseover', BX.proxy(this.Show, this)); 15651 } 15652 15653 this.bInited = true; 15654 }; 15655 15656 BX.CHint.prototype.setContent = function(content) 15657 { 15658 this.HINT = content; 15659 15660 if (this.CONTENT_TEXT) 15661 this.CONTENT_TEXT.innerHTML = this.HINT; 15662 else 15663 this.CONTENT_TEXT = this.CONTENT.appendChild(BX.create('DIV', {props: {className: 'bx-panel-tooltip-text'}})).appendChild(BX.create('SPAN', {html: this.HINT})); 15664 }; 15665 15666 BX.CHint.prototype.prepareAdjustPos = function() 15667 { 15668 this._wnd = {scrollPos: BX.GetWindowScrollPos(),scrollSize:BX.GetWindowScrollSize()}; 15669 return BX.style(this.PARENT, 'display') != 'none'; 15670 }; 15671 15672 BX.CHint.prototype.getAdjustPos = function() 15673 { 15674 var res = {}, pos = BX.pos(this.PARENT), min_top = 0; 15675 15676 res.top = pos.bottom + this.PARAMS.dx; 15677 15678 if (BX.admin && BX.admin.panel.DIV) 15679 { 15680 min_top = BX.admin.panel.DIV.offsetHeight + this.PARAMS.dx; 15681 15682 if (BX.admin.panel.isFixed()) 15683 { 15684 min_top += this._wnd.scrollPos.scrollTop; 15685 } 15686 } 15687 15688 if (res.top < min_top) 15689 res.top = min_top; 15690 else 15691 { 15692 if (res.top + this.DIV.offsetHeight > this._wnd.scrollSize.scrollHeight) 15693 res.top = pos.top - this.PARAMS.dx - this.DIV.offsetHeight; 15694 } 15695 15696 res.left = pos.left; 15697 if (pos.left < this.PARAMS.dx) 15698 pos.left = this.PARAMS.dx; 15699 else 15700 { 15701 var floatWidth = this.DIV.offsetWidth; 15702 15703 var max_left = this._wnd.scrollSize.scrollWidth - floatWidth - this.PARAMS.dx; 15704 15705 if (res.left > max_left) 15706 res.left = max_left; 15707 } 15708 15709 return res; 15710 }; 15711 15712 BX.CHint.prototype.adjustWidth = function() 15713 { 15714 if (this.bWidthAdjusted) return; 15715 15716 var w = this.DIV.offsetWidth, h = this.DIV.offsetHeight; 15717 15718 if (w > this.PARAMS.min_width) 15719 w = Math.round(Math.sqrt(1.618*w*h)); 15720 15721 if (w < this.PARAMS.min_width) 15722 w = this.PARAMS.min_width; 15723 15724 this.DIV.style.width = w + "px"; 15725 15726 if (this._adjustWidthInt) 15727 clearInterval(this._adjustWidthInt); 15728 this._adjustWidthInt = setInterval(BX.delegate(this._adjustWidthInterval, this), 5); 15729 15730 this.bWidthAdjusted = true; 15731 }; 15732 15733 BX.CHint.prototype._adjustWidthInterval = function() 15734 { 15735 if (!this.DIV || this.DIV.style.display == 'none') 15736 clearInterval(this._adjustWidthInt); 15737 15738 var
15739 dW = 20, 15740 maxWidth = 1500, 15741 w = this.DIV.offsetWidth, 15742 w1 = this.CONTENT_TEXT.offsetWidth; 15743 15744 if (w > 0 && w1 > 0 && w - w1 < dW && w < maxWidth) 15745 { 15746 this.DIV.style.width = (w + dW) + "px"; 15747 return; 15748 } 15749 15750 clearInterval(this._adjustWidthInt); 15751 }; 15752 15753 BX.CHint.prototype.adjustPos = function() 15754 { 15755 this.adjustWidth(); 15756 15757 var pos = this.getAdjustPos(); 15758 15759 this.DIV.style.top = pos.top + 'px'; 15760 this.DIV.style.left = pos.left + 'px'; 15761 }; 15762 15763 BX.CHint.prototype.Close = function() 15764 { 15765 if (this.ID && BX.WindowManager) 15766 BX.WindowManager.saveWindowOptions(this.ID, {display: 'off'}); 15767 this.__hide_immediately(); 15768 this.Destroy(); 15769 }; 15770 15771 BX.CHint.prototype.Destroy = function() 15772 { 15773 if (this.PARENT) 15774 { 15775 BX.unbind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 15776 BX.unbind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 15777 } 15778 15779 if (this.DIV) 15780 { 15781 BX.unbind(this.DIV, 'mouseover', BX.proxy(this.Show, this)); 15782 BX.unbind(this.DIV, 'mouseout', BX.proxy(this.Hide, this)); 15783 15784 BX.ZIndexManager.unregister(this.DIV); 15785 15786 BX.cleanNode(this.DIV, true); 15787 } 15788 }; 15789 15790 BX.CHint.prototype.enable = function(){this.disabled = false;}; 15791 BX.CHint.prototype.disable = function(){this.__hide_immediately(); this.disabled = true;}; 15792 15793 15794 function _adjustWait() 15795 { 15796 if (!this.bxmsg) return; 15797 15798 var arContainerPos = BX.pos(this), 15799 div_top = arContainerPos.top; 15800 15801 if (div_top < BX.GetDocElement().scrollTop) 15802 div_top = BX.GetDocElement().scrollTop + 5; 15803 15804 this.bxmsg.style.top = (div_top + 5) + 'px'; 15805 15806 if (this == BX.GetDocElement()) 15807 { 15808 this.bxmsg.style.right = '5px'; 15809 } 15810 else 15811 { 15812 this.bxmsg.style.left = (arContainerPos.right - this.bxmsg.offsetWidth - 5) + 'px'; 15813 } 15814 } 15815 15816 function _processTpl(tplNode, cb, bKillTpl) 15817 { 15818 if (tplNode) 15819 { 15820 if (bKillTpl) 15821 tplNode.parentNode.removeChild(tplNode); 15822 15823 var res = {}, nodes = BX.findChildren(tplNode, {attribute: 'data-role'}, true); 15824 15825 for (var i = 0, l = nodes.length; i < l; i++) 15826 { 15827 res[nodes[i].getAttribute('data-role')] = nodes[i]; 15828 } 15829 15830 cb.apply(tplNode, [res]); 15831 } 15832 } 15833 15834 function _checkNode(obj, params) 15835 { 15836 params = params || {}; 15837 15838 if (BX.type.isFunction(params)) 15839 return params.call(window, obj); 15840 15841 if (!params.allowTextNodes && !BX.type.isElementNode(obj)) 15842 return false; 15843 var i,j,len; 15844 for (i in params) 15845 { 15846 if(params.hasOwnProperty(i)) 15847 { 15848 switch(i) 15849 { 15850 case 'tag': 15851 case 'tagName': 15852 if (BX.type.isString(params[i])) 15853 { 15854 if (obj.tagName.toUpperCase() != params[i].toUpperCase()) 15855 return false; 15856 } 15857 else if (params[i] instanceof RegExp) 15858 { 15859 if (!params[i].test(obj.tagName)) 15860 return false; 15861 } 15862 break; 15863 15864 case 'class': 15865 case 'className': 15866 if (BX.type.isString(params[i])) 15867 { 15868 if (!BX.hasClass(obj, params[i])) 15869 return false; 15870 } 15871 else if (params[i] instanceof RegExp) 15872 { 15873 if (!BX.type.isString(obj.className) || !params[i].test(obj.className)) 15874 return false; 15875 } 15876 break; 15877 15878 case 'attr': 15879 case 'attrs': 15880 case 'attribute': 15881 if (BX.type.isString(params[i])) 15882 { 15883 if (!obj.getAttribute(params[i])) 15884 return false; 15885 } 15886 else if (BX.type.isArray(params[i])) 15887 { 15888 for (j = 0, len = params[i].length; j < len; j++) 15889 { 15890 if (params[i] && !obj.getAttribute(params[i])) 15891 return false; 15892 } 15893 } 15894 else 15895 { 15896 for (j in params[i]) 15897 { 15898 if(params[i].hasOwnProperty(j)) 15899 { 15900 var q = obj.getAttribute(j); 15901 if (params[i][j] instanceof RegExp) 15902 { 15903 if (!BX.type.isString(q) || !params[i][j].test(q)) 15904 { 15905 return false; 15906 } 15907 } 15908 else 15909 { 15910 if (q != '' + params[i][j]) 15911 { 15912 return false; 15913 } 15914 } 15915 } 15916 } 15917 } 15918 break; 15919 15920 case 'property': 15921 case 'props': 15922 if (BX.type.isString(params[i])) 15923 { 15924 if (!obj[params[i]]) 15925 return false; 15926 } 15927 else if (BX.type.isArray(params[i])) 15928 { 15929 for (j = 0, len = params[i].length; j < len; j++) 15930 { 15931 if (params[i] && !obj[params[i]]) 15932 return false;
15933 } 15934 } 15935 else 15936 { 15937 for (j in params[i]) 15938 { 15939 if (BX.type.isString(params[i][j])) 15940 { 15941 if (obj[j] != params[i][j]) 15942 return false; 15943 } 15944 else if (params[i][j] instanceof RegExp) 15945 { 15946 if (!BX.type.isString(obj[j]) || !params[i][j].test(obj[j])) 15947 return false; 15948 } 15949 } 15950 } 15951 break; 15952 15953 case 'callback': 15954 return params[i](obj); 15955 } 15956 } 15957 } 15958 15959 return true; 15960 } 15961 15962 /* garbage collector */ 15963 function Trash() 15964 { 15965 var i,len; 15966 15967 for (i = 0, len = garbageCollectors.length; i<len; i++) 15968 { 15969 try { 15970 garbageCollectors[i].callback.apply(garbageCollectors[i].context || window); 15971 delete garbageCollectors[i]; 15972 garbageCollectors[i] = null; 15973 } catch (e) {} 15974 } 15975 } 15976 15977 if(window.attachEvent) // IE 15978 window.attachEvent("onunload", Trash); 15979 else if(window.addEventListener) // Gecko / W3C 15980 window.addEventListener('unload', Trash, false); 15981 else 15982 window.onunload = Trash; 15983 /* \garbage collector */ 15984 15985// set empty ready handler 15986 BX(BX.DoNothing); 15987 window.BX = BX; 15988 15989 BX.browser.addGlobalClass(); 15990 15991 /* data storage */ 15992 BX.data = function(node, key, value) 15993 { 15994 if(typeof node == 'undefined') 15995 return undefined; 15996 15997 if(typeof key == 'undefined') 15998 return undefined; 15999 16000 if(typeof value != 'undefined') 16001 { 16002 // write to manager 16003 dataStorage.set(node, key, value); 16004 } 16005 else 16006 { 16007 var data; 16008 16009 // from manager 16010 if((data = dataStorage.get(node, key)) != undefined) 16011 { 16012 return data; 16013 } 16014 else 16015 { 16016 // from attribute data-* 16017 if('getAttribute' in node) 16018 { 16019 data = node.getAttribute('data-'+key.toString()); 16020 if(data === null) 16021 { 16022 return undefined; 16023 } 16024 return data; 16025 } 16026 } 16027 16028 return undefined; 16029 } 16030 }; 16031 16032 BX.DataStorage = function() 16033 { 16034 16035 this.keyOffset = 1; 16036 this.data = {}; 16037 this.uniqueTag = 'BX-'+Math.random(); 16038 16039 this.resolve = function(owner, create){ 16040 if(typeof owner[this.uniqueTag] == 'undefined') 16041 if(create) 16042 { 16043 try 16044 { 16045 Object.defineProperty(owner, this.uniqueTag, { 16046 value: this.keyOffset++ 16047 }); 16048 } 16049 catch(e) 16050 { 16051 owner[this.uniqueTag] = this.keyOffset++; 16052 } 16053 } 16054 else 16055 return undefined; 16056 16057 return owner[this.uniqueTag]; 16058 }; 16059 this.get = function(owner, key){ 16060 if((owner != document && !BX.type.isElementNode(owner)) || typeof key == 'undefined') 16061 return undefined; 16062 16063 owner = this.resolve(owner, false); 16064 16065 if(typeof owner == 'undefined' || typeof this.data[owner] == 'undefined') 16066 return undefined; 16067 16068 return this.data[owner][key]; 16069 }; 16070 this.set = function(owner, key, value){ 16071 16072 if((owner != document && !BX.type.isElementNode(owner)) || typeof value == 'undefined') 16073 return; 16074 16075 var o = this.resolve(owner, true); 16076 16077 if(typeof this.data[o] == 'undefined') 16078 this.data[o] = {}; 16079 16080 this.data[o][key] = value; 16081 }; 16082 }; 16083 16084// some internal variables for new logic 16085 var dataStorage = new BX.DataStorage(); // manager which BX.data() uses to keep data 16086})(window.BX); 16087 16088;(function(window) 16089{ 16090 /****************** ATTENTION ******************************* 16091 * Please do not use Bitrix CoreJS in this class. 16092 * This class can be called on page without Bitrix Framework 16093 *************************************************************/ 16094 16095 if (!window.BX) 16096 { 16097 window.BX = {}; 16098 } 16099 16100 var BX = window.BX; 16101 16102 BX.Promise = function(fn, ctx) // fn is future-reserved 16103 { 16104 this.state = null; 16105 this.value = null; 16106 this.reason = null; 16107 this.next = null; 16108 this.ctx = ctx || this; 16109 16110 this.onFulfilled = []; 16111 this.onRejected = []; 16112 }; 16113 BX.Promise.prototype.fulfill = function(value) 16114 { 16115 this.checkState(); 16116 16117 this.value = value; 16118 this.state = true; 16119 this.execute(); 16120 }; 16121 BX.Promise.prototype.reject = function(reason) 16122 { 16123 this.checkState(); 16124 16125 this.reason = reason; 16126 this.state = false; 16127 this.execute(); 16128 }; 16129 BX.Promise.prototype.then = function(onFulfilled, onRejected) 16130 { 16131 if(typeof (onFulfilled) == "function" || onFulfilled instanceof Function) 16132 { 16133 this.onFulfilled.push(onFulfilled); 16134 } 16135 if(typeof (onRejected) == "function" || onRejected instanceof Function) 16136 { 16137 this.onRejected.push(onRejected); 16138 } 16139 16140 if(this.next === null) 16141 { 16142 this.next = new BX.Promise(null, this.ctx); 16143 } 16144 16145 if(this.state !== null) // if promise was already resolved, execute immediately 16146 { 16147 this.execute(); 16148 } 16149 16150 return this.next; 16151 }; 16152 16153 BX.Promise.prototype.catch = function(onRejected) 16154 { 16155 if(typeof (onRejected) == "function" || onRejected instanceof Function) 16156 { 16157 this.onRejected.push(onRejected); 16158 } 16159 16160 if(this.next === null) 16161 { 16162 this.next = new BX.Promise(null, this.ctx); 16163 } 16164 16165 if(this.state !== null) // if promise was already resolved, execute immediately 16166 { 16167 this.execute(); 16168 } 16169 16170 return this.next; 16171 }; 16172 16173 BX.Promise.prototype.setAutoResolve = function(way, ms) 16174 { 16175 this.timer = setTimeout(function(){ 16176 if(this.state === null) 16177 { 16178 this[way ? 'fulfill' : 'reject'](); 16179 } 16180 }.bind(this), ms || 15); 16181 };
16182 BX.Promise.prototype.cancelAutoResolve = function() 16183 { 16184 clearTimeout(this.timer); 16185 }; 16186 /** 16187 * Resolve function. This function allows promise chaining, like ..then().then()... 16188 * Typical usage: 16189 * 16190 * var p = new Promise(); 16191 * 16192 * p.then(function(value){ 16193 * return someValue; // next promise in the chain will be fulfilled with someValue 16194 * }).then(function(value){ 16195 * 16196 * var p1 = new Promise(); 16197 * *** some async code here, that eventually resolves p1 *** 16198 * 16199 * return p1; // chain will resume when p1 resolved (fulfilled or rejected) 16200 * }).then(function(value){ 16201 * 16202 * // you can also do 16203 * var e = new Error(); 16204 * throw e; 16205 * // it will cause next promise to be rejected with e 16206 * 16207 * return someOtherValue; 16208 * }).then(function(value){ 16209 * ... 16210 * }, function(reason){ 16211 * // promise was rejected with reason 16212 * })...; 16213 * 16214 * p.fulfill('let`s start this chain'); 16215 * 16216 * @param x 16217 */ 16218 BX.Promise.prototype.resolve = function(x) 16219 { 16220 var this_ = this; 16221 16222 if(this === x) 16223 { 16224 this.reject(new TypeError('Promise cannot fulfill or reject itself')); // avoid recursion 16225 } 16226 // allow "pausing" promise chaining until promise x is fulfilled or rejected 16227 else if(x && x.toString() === "[object BX.Promise]") 16228 { 16229 x.then(function(value){ 16230 this_.fulfill(value); 16231 }, function(reason){ 16232 this_.reject(reason); 16233 }); 16234 } 16235 else // auto-fulfill this promise 16236 { 16237 this.fulfill(x); 16238 } 16239 }; 16240 16241 BX.Promise.prototype.toString = function() 16242 { 16243 return "[object BX.Promise]"; 16244 }; 16245 16246 BX.Promise.prototype.execute = function() 16247 { 16248 if(this.state === null) 16249 { 16250 //then() must not be called before BX.Promise resolve() happens 16251 return; 16252 } 16253 16254 var value = undefined; 16255 var reason = undefined; 16256 var x = undefined; 16257 var k; 16258 if(this.state === true) // promise was fulfill()-ed 16259 { 16260 if(this.onFulfilled.length) 16261 { 16262 try 16263 { 16264 for(k = 0; k < this.onFulfilled.length; k++) 16265 {
16266 x = this.onFulfilled[k].apply(this.ctx, [this.value]); 16267 if(typeof x != 'undefined') 16268 { 16269 value = x; 16270 } 16271 } 16272 } 16273 catch(e) 16274 { 16275 if('console' in window) 16276 { 16277 console.dir(e); 16278 } 16279 16280 if (typeof BX.debug !== 'undefined') 16281 { 16282 BX.debug(e); 16283 } 16284 16285 reason = e; // reject next 16286 } 16287 } 16288 else 16289 { 16290 value = this.value; // resolve next 16291 } 16292 } 16293 else if(this.state === false) // promise was reject()-ed 16294 { 16295 if(this.onRejected.length) 16296 { 16297 try 16298 { 16299 for(k = 0; k < this.onRejected.length; k++) 16300 { 16301 x = this.onRejected[k].apply(this.ctx, [this.reason]); 16302 if(typeof x != 'undefined') 16303 { 16304 value = x; 16305 } 16306 } 16307 } 16308 catch(e) 16309 { 16310 if('console' in window) 16311 { 16312 console.dir(e); 16313 } 16314 16315 if (typeof BX.debug !== 'undefined') 16316 { 16317 BX.debug(e); 16318 } 16319 16320 reason = e; // reject next 16321 } 16322 } 16323 else 16324 { 16325 reason = this.reason; // reject next 16326 } 16327 } 16328 16329 if(this.next !== null) 16330 { 16331 if(typeof reason != 'undefined') 16332 { 16333 this.next.reject(reason); 16334 } 16335 else if(typeof value != 'undefined') 16336 { 16337 this.next.resolve(value); 16338 } 16339 } 16340 }; 16341 BX.Promise.prototype.checkState = function() 16342 { 16343 if(this.state !== null) 16344 { 16345 throw new Error('You can not do fulfill() or reject() multiple times'); 16346 } 16347 }; 16348})(window); 16349 16350 16351 16352;(function(window){ 16353 16354if (window.BX.ajax) 16355 return; 16356 16357var 16358 BX = window.BX, 16359 16360 tempDefaultConfig = {}, 16361 defaultConfig = { 16362 method: 'GET', // request method: GET|POST 16363 dataType: 'html', // type of data loading: html|json|script 16364 timeout: 0, // request timeout in seconds. 0 for browser-default 16365 async: true, // whether request is asynchronous or not 16366 processData: true, // any data processing is disabled if false, only callback call 16367 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 16368 emulateOnload: true, 16369 skipAuthCheck: false, // whether to check authorization failure (SHOUD be set to true for CORS requests) 16370 start: true, // send request immediately (if false, request can be started manually via XMLHttpRequest object returned) 16371 cache: true, // whether NOT to add random addition to URL 16372 preparePost: true, // whether set Content-Type x-www-form-urlencoded in POST 16373 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'}] 16374 lsTimeout: 30, //local storage data TTL. useless without lsId. 16375 lsForce: false //wheter to force query instead of using localStorage data. useless without lsId. 16376/* 16377other parameters: 16378 url: url to get/post 16379 data: data to post 16380 onsuccess: successful request callback. BX.proxy may be used. 16381 onfailure: request failure callback. BX.proxy may be used. 16382 onprogress: request progress callback. BX.proxy may be used. 16383 16384 lsId: local storage id - for constantly updating queries which can communicate via localStorage. core_ls.js needed 16385 16386any of the default parameters can be overridden. defaults can be changed by BX.ajax.Setup() - for all further requests! 16387*/ 16388 }, 16389 loadedScripts = {}, 16390 loadedScriptsQueue = [], 16391 r = { 16392 'url_utf': /[^\034-\254]+/g, 16393 'script_self': /\/bitrix\/js\/main\/core\/core(_ajax)*.js$/i, 16394 'script_self_window': /\/bitrix\/js\/main\/core\/core_window.js$/i, 16395 'script_self_admin': /\/bitrix\/js\/main\/core\/core_admin.js$/i, 16396 'script_onload': /window.onload/g 16397 }; 16398 16399// low-level method 16400BX.ajax = function(config) 16401{ 16402 var status, data; 16403
16404 if (!config || !config.url || !BX.type.isString(config.url)) 16405 { 16406 return false; 16407 } 16408 16409 for (var i in tempDefaultConfig) 16410 if (typeof (config[i]) == "undefined") config[i] = tempDefaultConfig[i]; 16411 16412 tempDefaultConfig = {}; 16413 16414 for (i in defaultConfig) 16415 if (typeof (config[i]) == "undefined") config[i] = defaultConfig[i]; 16416 16417 config.method = config.method.toUpperCase(); 16418 16419 if (!BX.localStorage) 16420 config.lsId = null; 16421 16422 if (BX.browser.IsIE()) 16423 { 16424 var result = r.url_utf.exec(config.url); 16425 if (result) 16426 { 16427 do 16428 { 16429 config.url = config.url.replace(result, BX.util.urlencode(result)); 16430 result = r.url_utf.exec(config.url); 16431 } while (result); 16432 } 16433 } 16434 16435 if(config.dataType == 'json') 16436 config.emulateOnload = false; 16437 16438 if (!config.cache && config.method == 'GET') 16439 config.url = BX.ajax._uncache(config.url); 16440 16441 if (config.method == 'POST') 16442 { 16443 if (config.preparePost) 16444 { 16445 config.data = BX.ajax.prepareData(config.data); 16446 } 16447 else if (getLastContentTypeHeader(config.headers) === 'application/json') 16448 { 16449 config.data = JSON.stringify(config.data); 16450 } 16451 } 16452 16453 var bXHR = true; 16454 if (config.lsId && !config.lsForce) 16455 { 16456 var v = BX.localStorage.get('ajax-' + config.lsId); 16457 if (v !== null) 16458 { 16459 bXHR = false; 16460 16461 var lsHandler = function(lsData) { 16462 if (lsData.key == 'ajax-' + config.lsId && lsData.value != 'BXAJAXWAIT') 16463 { 16464 var data = lsData.value, 16465 bRemove = !!lsData.oldValue && data == null; 16466 if (!bRemove) 16467 BX.ajax.__run(config, data); 16468 else if (config.onfailure) 16469 config.onfailure("timeout"); 16470 16471 BX.removeCustomEvent('onLocalStorageChange', lsHandler); 16472 } 16473 }; 16474 16475 if (v == 'BXAJAXWAIT') 16476 { 16477 BX.addCustomEvent('onLocalStorageChange', lsHandler); 16478 } 16479 else 16480 { 16481 setTimeout(function() {lsHandler({key: 'ajax-' + config.lsId, value: v})}, 10); 16482 } 16483 } 16484 } 16485 16486 if (bXHR) 16487 { 16488 config.xhr = BX.ajax.xhr(); 16489 if (!config.xhr) return; 16490 16491 if (config.lsId) 16492 { 16493 BX.localStorage.set('ajax-' + config.lsId, 'BXAJAXWAIT', config.lsTimeout); 16494 } 16495 16496 if (BX.Type.isFunction(config.onprogress)) 16497 { 16498 BX.bind(config.xhr, 'progress', config.onprogress); 16499 } 16500 16501 if (BX.Type.isFunction(config.onprogressupload) && config.xhr.upload) 16502 { 16503 BX.bind(config.xhr.upload, 'progress', config.onprogressupload); 16504 } 16505 16506 config.xhr.open(config.method, config.url, config.async); 16507 16508 if (!config.skipBxHeader && !BX.ajax.isCrossDomain(config.url)) 16509 { 16510 config.xhr.setRequestHeader('Bx-ajax', 'true'); 16511 } 16512 16513 if (config.method == 'POST' && config.preparePost) 16514 { 16515 config.xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 16516 } 16517 if (typeof(config.headers) == "object") 16518 { 16519 for (i = 0; i < config.headers.length; i++) 16520 config.xhr.setRequestHeader(config.headers[i].name, config.headers[i].value); 16521 } 16522 16523 var bRequestCompleted = false; 16524 var onreadystatechange = config.xhr.onreadystatechange = function(additional) 16525 { 16526 if (bRequestCompleted) 16527 return; 16528 16529 if (additional === 'timeout') 16530 { 16531 if (config.onfailure) 16532 { 16533 config.onfailure('timeout', '', config); 16534 } 16535 16536 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['timeout', '', config]); 16537 16538 config.xhr.onreadystatechange = BX.DoNothing; 16539 config.xhr.abort(); 16540 16541 if (config.async) 16542 { 16543 config.xhr = null; 16544 } 16545 } 16546 else 16547 { 16548 if (config.xhr.readyState == 4 || additional == 'run') 16549 { 16550 status = BX.ajax.xhrSuccess(config.xhr) ? "success" : "error"; 16551 bRequestCompleted = true; 16552 config.xhr.onreadystatechange = BX.DoNothing; 16553 16554 if (status == 'success') 16555 { 16556 var authHeader = (!!config.skipAuthCheck || BX.ajax.isCrossDomain(config.url)) 16557 ? false 16558 : config.xhr.getResponseHeader('X-Bitrix-Ajax-Status'); 16559 16560 if(!!authHeader && authHeader == 'Authorize') 16561 { 16562 if (config.onfailure) 16563 { 16564 config.onfailure('auth', config.xhr.status, config); 16565 } 16566 16567 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['auth', config.xhr.status, config]); 16568 } 16569 else 16570 { 16571 var data = config.xhr.responseText; 16572 16573 if (config.lsId) 16574 { 16575 BX.localStorage.set('ajax-' + config.lsId, data, config.lsTimeout); 16576 } 16577 16578 BX.ajax.__run(config, data); 16579 } 16580 } 16581 else 16582 { 16583 if (config.onfailure) 16584 { 16585 config.onfailure('status', config.xhr.status, config); 16586 } 16587 16588 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['status', config.xhr.status, config]); 16589 } 16590 16591 if (config.async) 16592 { 16593 config.xhr = null; 16594 } 16595 } 16596 } 16597 }; 16598 16599 if (config.async && config.timeout > 0) 16600 { 16601 setTimeout(function() { 16602 if (config.xhr && !bRequestCompleted) 16603 { 16604 onreadystatechange("timeout"); 16605 } 16606 }, config.timeout * 1000); 16607 } 16608 16609 if (config.start) 16610 {
16611 config.xhr.send(config.data); 16612 16613 if (!config.async) 16614 { 16615 onreadystatechange('run'); 16616 } 16617 } 16618 16619 return config.xhr; 16620 } 16621}; 16622 16623BX.ajax.xhr = function() 16624{ 16625 if (window.XMLHttpRequest) 16626 { 16627 try {return new XMLHttpRequest();} catch(e){} 16628 } 16629 else if (window.ActiveXObject) 16630 { 16631 try { return new window.ActiveXObject("Msxml2.XMLHTTP.6.0"); } 16632 catch(e) {} 16633 try { return new window.ActiveXObject("Msxml2.XMLHTTP.3.0"); } 16634 catch(e) {} 16635 try { return new window.ActiveXObject("Msxml2.XMLHTTP"); } 16636 catch(e) {} 16637 try { return new window.ActiveXObject("Microsoft.XMLHTTP"); } 16638 catch(e) {} 16639 throw new Error("This browser does not support XMLHttpRequest."); 16640 } 16641 16642 return null; 16643}; 16644 16645BX.ajax.isCrossDomain = function(url, location) 16646{ 16647 location = location || window.location; 16648 16649 //Relative URL gets a current protocol 16650 if (url.indexOf("//") === 0) 16651 { 16652 url = location.protocol + url; 16653 } 16654 16655 //Fast check 16656 if (url.indexOf("http") !== 0) 16657 { 16658 return false; 16659 } 16660 16661 var link = window.document.createElement("a"); 16662 link.href = url; 16663 16664 return link.protocol !== location.protocol || 16665 link.hostname !== location.hostname || 16666 BX.ajax.getHostPort(link.protocol, link.host) !== BX.ajax.getHostPort(location.protocol, location.host); 16667}; 16668 16669BX.ajax.getHostPort = function(protocol, host) 16670{ 16671 var match = /:(\d+)$/.exec(host); 16672 if (match) 16673 { 16674 return match[1]; 16675 } 16676 else 16677 { 16678 if (protocol === "http:") 16679 { 16680 return "80"; 16681 } 16682 else if (protocol === "https:") 16683 { 16684 return "443"; 16685 } 16686 } 16687 16688 return ""; 16689}; 16690 16691BX.ajax.__prepareOnload = function(scripts, ajax_session) 16692{ 16693 if (scripts.length > 0) 16694 { 16695 BX.ajax['onload_' + ajax_session] = null; 16696 16697 for (var i=0,len=scripts.length;i<len;i++) 16698 { 16699 if (scripts[i].isInternal) 16700 { 16701 scripts[i].JS = scripts[i].JS.replace(r.script_onload, 'BX.aja
16701x.onload_' + ajax_session); 16702 } 16703 } 16704 } 16705 16706 BX.CaptureEventsGet(); 16707 BX.CaptureEvents(window, 'load'); 16708}; 16709 16710BX.ajax.__runOnload = function(ajax_session) 16711{ 16712 if (null != BX.ajax['onload_' + ajax_session]) 16713 { 16714 BX.ajax['onload_' + ajax_session].apply(window); 16715 BX.ajax['onload_' + ajax_session] = null; 16716 } 16717 16718 var h = BX.CaptureEventsGet(); 16719 16720 if (h) 16721 { 16722 for (var i=0; i<h.length; i++) 16723 h[i].apply(window); 16724 } 16725}; 16726 16727BX.ajax.__run = function(config, data) 16728{ 16729 if (!config.processData) 16730 { 16731 if (config.onsuccess) 16732 { 16733 config.onsuccess(data); 16734 } 16735 16736 BX.onCustomEvent(config.xhr, 'onAjaxSuccess', [data, config]); 16737 } 16738 else 16739 { 16740 data = BX.ajax.processRequestData(data, config); 16741 } 16742}; 16743 16744 16745BX.ajax._onParseJSONFailure = function(data) 16746{ 16747 this.jsonFailure = true; 16748 this.jsonResponse = data; 16749 this.jsonProactive = /^\[WAF\]/.test(data); 16750}; 16751 16752BX.ajax.processRequestData = function(data, config) 16753{ 16754 var result, scripts = [], styles = []; 16755 switch (config.dataType.toUpperCase()) 16756 { 16757 case 'JSON': 16758 16759 var context = config.xhr || {}; 16760 BX.addCustomEvent(context, 'onParseJSONFailure', BX.proxy(BX.ajax._onParseJSONFailure, config)); 16761 result = BX.parseJSON(data, context); 16762 BX.removeCustomEvent(context, 'onParseJSONFailure', BX.proxy(BX.ajax._onParseJSONFailure, config)); 16763 16764 if(!!result && BX.type.isArray(result['bxjs'])) 16765 { 16766 for(var i = 0; i < result['bxjs'].length; i++) 16767 { 16768 if(BX.type.isNotEmptyString(result['bxjs'][i])) 16769 { 16770 scripts.push({ 16771 "isInternal": false, 16772 "JS": result['bxjs'][i], 16773 "bRunFirst": config.scriptsRunFirst 16774 }); 16775 } 16776 else 16777 { 16778 scripts.push(result['bxjs'][i]) 16779 } 16780 } 16781 } 16782 16783 if(!!result && BX.type.isArray(result['bxcss'])) 16784 { 16785 styles = result['bxcss']; 16786 } 16787 16788 break; 16789 case 'SCRIPT': 16790 scripts.push({"isInternal": true, "JS": data, "bRunFirst": config.scriptsRunFirst}); 16791 result = data; 16792 break; 16793 16794 default: // HTML 16795 var ob = BX.processHTML(data, config.scriptsRunFirst); 16796 result = ob.HTML; scripts = ob.SCRIPT; styles = ob.STYLE; 16797 break; 16798 } 16799 16800 if (styles.length > 0) 16801 { 16802 BX.loadCSS(styles); 16803 } 16804 16805 let ajax_session = null; 16806 if (config.emulateOnload) 16807 { 16808 ajax_session = parseInt(Math.random() * 1000000); 16809 BX.ajax.__prepareOnload(scripts, ajax_session); 16810 } 16811 16812 const cb = BX.defer(function() 16813 { 16814 if (config.emulateOnload) 16815 { 16816 BX.ajax.__runOnload(ajax_session); 16817 } 16818 16819 BX.onCustomEvent(config.xhr, 'onAjaxSuccessFinish', [config]); 16820 }); 16821 16822 try 16823 { 16824 if (!!config.jsonFailure) 16825 { 16826 throw {type: 'json_failure', data: config.jsonResponse, bProactive: config.jsonProactive}; 16827 } 16828 16829 config.scripts = scripts; 16830 16831 BX.ajax.processScripts(config.scripts, true); 16832 16833 if (config.onsuccess) 16834 { 16835 config.onsuccess(result); 16836 } 16837 16838 BX.onCustomEvent(config.xhr, 'onAjaxSuccess', [result, config]); 16839 16840 BX.ajax.processScripts(config.scripts, false, cb); 16841 } 16842 catch (e) 16843 { 16844 if (config.onfailure) 16845 config.onfailure("processing", e); 16846 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['processing', e, config]); 16847 } 16848}; 16849 16850BX.ajax.processScripts = function(scripts, bRunFirst, cb) 16851{ 16852 var scriptsExt = [], scriptsInt = ''; 16853 16854 cb = cb || BX.DoNothing; 16855 16856 for (var i = 0, length = scripts.length; i < length; i++) 16857 { 16858 if (typeof bRunFirst != 'undefined' && bRunFirst != !!scripts[i].bRunFirst) 16859 continue; 16860 16861 if (scripts[i].isInternal) 16862 scriptsInt += ';' + scripts[i].JS; 16863 else 16864 scriptsExt.push(scripts[i].JS); 16865 } 16866 16867 scriptsExt = BX.util.array_unique(scriptsExt); 16868 var inlineScripts = scriptsInt.length > 0 ? function() { BX.evalGlobal(scriptsInt); } : BX.DoNothing; 16869 16870 if (scriptsExt.length > 0) 16871 { 16872 BX.load(scriptsExt, function() { 16873 inlineScripts(); 16874 cb(); 16875 }); 16876 } 16877 else 16878 { 16879 inlineScripts(); 16880 cb(); 16881 } 16882}; 16883 16884// TODO: extend this function to use with any data objects or forms 16885BX.ajax.prepareData = function(arData, prefix) 16886{ 16887 var data = ''; 16888 if (BX.type.isString(arData)) 16889 data = arData; 16890 else if (null != arData) 16891 { 16892 for(var i in arData) 16893 { 16894 if (arData.hasOwnProperty(i)) 16895 { 16896 if (data.length > 0) 16897 data += '&'; 16898 var name = BX.util.urlencode(i); 16899 if(prefix) 16900 name = prefix + '[' + name + ']'; 16901 if(typeof arData[i] == 'object') 16902 data += BX.ajax.prepareData(arData[i], name); 16903 else 16904 data += name + '=' + BX.util.urlencode(arData[i]); 16905 } 16906 } 16907 } 16908 return data; 16909}; 16910 16911BX.ajax.xhrSuccess = function(xhr) 16912{ 16913 return (xhr.status >= 200 && xhr.status < 300) || xhr.status === 304 || xhr.status === 1223 || xhr.status === 0; 16914}; 16915 16916BX.ajax.Setup = function(config, bTemp) 16917{ 16918 bTemp = !!bTemp; 16919 16920 for (var i in config) 16921 { 16922 if (bTemp) 16923 tempDefaultConfig[i] = config[i]; 16924 else 16925 defaultConfig[i] = config[i]; 16926 } 16927}; 16928 16929BX.ajax.replaceLocalStorageValue = function(lsId, data, ttl) 16930{ 16931 if (!!BX.localStorage) 16932 BX.localStorage.set('ajax-' + lsId, data, ttl); 16933}; 16934 16935 16936BX.ajax._uncache = function(url) 16937{ 16938 return url + ((url.indexOf('?') !== -1 ? "&" : "?") + '_=' + (new Date()).getTime()); 16939}; 16940 16941/* simple interface */ 16942BX.ajax.get = function(url, data, callback) 16943{ 16944 if (BX.type.isFunction(data)) 16945 { 16946 callback = data; 16947 data = ''; 16948 } 16949
16950 data = BX.ajax.prepareData(data); 16951 16952 if (data) 16953 { 16954 url += (url.indexOf('?') !== -1 ? "&" : "?") + data; 16955 data = ''; 16956 } 16957 16958 return BX.ajax({ 16959 'method': 'GET', 16960 'dataType': 'html', 16961 'url': url, 16962 'data': '', 16963 'onsuccess': callback 16964 }); 16965}; 16966 16967BX.ajax.getCaptcha = function(callback) 16968{ 16969 return BX.ajax.loadJSON('/bitrix/tools/ajax_captcha.php', callback); 16970}; 16971 16972BX.ajax.insertToNode = function(url, node) 16973{ 16974 node = BX(node); 16975 if (!!node) 16976 { 16977 var eventArgs = { cancel: false }; 16978 BX.onCustomEvent('onAjaxInsertToNode', [{ url: url, node: node, eventArgs: eventArgs }]); 16979 if(eventArgs.cancel === true) 16980 { 16981 return; 16982 } 16983 16984 var show = null; 16985 if (!tempDefaultConfig.denyShowWait) 16986 { 16987 show = BX.showWait(node); 16988 delete tempDefaultConfig.denyShowWait; 16989 } 16990 16991 return BX.ajax.get(url, function(data) { 16992 node.innerHTML = data; 16993 BX.closeWait(node, show); 16994 }); 16995 } 16996}; 16997 16998BX.ajax.post = function(url, data, callback) 16999{ 17000 data = BX.ajax.prepareData(data); 17001 17002 return BX.ajax({ 17003 'method': 'POST', 17004 'dataType': 'html', 17005 'url': url, 17006 'data': data, 17007 'onsuccess': callback 17008 }); 17009}; 17010 17011/** 17012 * BX.ajax with BX.Promise 17013 * 17014 * @param config 17015 * @returns {BX.Promise|false} 17016 */ 17017BX.ajax.promise = function(config) 17018{ 17019 var result = new BX.Promise(); 17020 17021 config.onsuccess = function(data) 17022 { 17023 result.fulfill(data); 17024 }; 17025 config.onfailure = function(reason, httpStatus, config) 17026 { 17027 result.reject({ 17028 reason: reason, 17029 data: httpStatus, 17030 ajaxConfig: config, 17031 xhr: config.xhr 17032 }); 17033 }; 17034 17035 var xhr = BX.ajax(config); 17036 if (xhr) 17037 { 17038 if (typeof config.onrequeststart === 'function') 17039 { 17040 config.onrequeststart(xhr); 17041 } 17042 } 17043 else 17044 { 17045 result.reject({ 17046 reason: "init", 17047 data: false 17048 }); 17049 } 17050 17051 return result; 17052}; 17053 17054/* load and execute external file script with onload emulation */ 17055BX.ajax.loadScriptAjax = function(script_src, callback, bPreload) 17056{ 17057 if (BX.type.isArray(script_src)) 17058 { 17059 for (var i=0,len=script_src.length;i<len;i++) 17060 { 17061 BX.ajax.loadScriptAjax(script_src[i], callback, bPreload); 17062 } 17063 } 17064 else 17065 { 17066 var script_src_test = script_src.replace(/\.js\?.*/, '.js'); 17067 17068 if (r.script_self.test(script_src_test)) return; 17069 if (r.script_self_window.test(script_src_test) && BX.CWindow) return; 17070 if (r.script_self_admin.test(script_src_test) && BX.admin) return; 17071 17072 if (typeof loadedScripts[script_src_test] == 'undefined') 17073 { 17074 if (!!bPreload) 17075 { 17076 loadedScripts[script_src_test] = ''; 17077 return BX.loadScript(script_src); 17078 } 17079 else 17080 { 17081 return BX.ajax({ 17082 url: script_src, 17083 method: 'GET', 17084 dataType: 'script', 17085 processData: true, 17086 emulateOnload: false, 17087 scriptsRunFirst: true, 17088 async: false, 17089 start: true, 17090 onsuccess: function(result) { 17091 loadedScripts[script_src_test] = result; 17092 if (callback) 17093 callback(result); 17094 } 17095 }); 17096 } 17097 } 17098 else if (callback) 17099 { 17100 callback(loadedScripts[script_src_test]); 17101 } 17102 } 17103}; 17104 17105/* non-xhr loadings */ 17106BX.ajax.loadJSON = function(url, data, callback, callback_failure) 17107{ 17108 if (BX.type.isFunction(data)) 17109 { 17110 callback_failure = callback; 17111 callback = data; 17112 data = ''; 17113 } 17114 17115 data = BX.ajax.prepareData(data); 17116 17117 if (data) 17118 { 17119 url += (url.indexOf('?') !== -1 ? "&" : "?") + data; 17120 data = ''; 17121 } 17122 17123 return BX.ajax({ 17124 'method': 'GET', 17125 'dataType': 'json', 17126 'url': url, 17127 'onsuccess': callback, 17128 'onfailure': callback_failure 17129 }); 17130}; 17131 17132var getLastContentTypeHeader = function (headers) { 17133 if (!BX.Type.isArray(headers)) 17134 { 17135 return null; 17136 } 17137 var lastHeader = headers 17138 .filter(function (header) { 17139 return header.name === 'Content-Type'; 17140 }) 17141 .pop(); 17142 17143 return lastHeader ? lastHeader.value : null; 17144}; 17145 17146var prepareAjaxGetParameters = function(config) 17147{ 17148 var getParameters = config.getParameters || {}; 17149 if (BX.type.isNotEmptyString(config.analyticsLabel)) 17150 { 17151 getParameters.analyticsLabel = config.analyticsLabel; 17152 } 17153 else if (BX.type.isNotEmptyObject(config.analyticsLabel)) 17154 { 17155 getParameters.analyticsLabel = config.analyticsLabel; 17156 } 17157 if (typeof config.mode !== 'undefined') 17158 { 17159 getParameters.mode = config.mode; 17160 } 17161 if (config.navigation) 17162 { 17163 if(config.navigation.page) 17164 { 17165 getParameters.nav = 'page-' + config.navigation.page; 17166 } 17167 if(config.navigation.size) 17168 { 17169 if(getParameters.nav) 17170 { 17171 getParameters.nav += '-'; 17172 } 17173 else 17174 {
17175 getParameters.nav = ''; 17176 } 17177 getParameters.nav += 'size-' + config.navigation.size; 17178 } 17179 } 17180 17181 return getParameters; 17182}; 17183 17184var prepareAjaxConfig = function(config) 17185{ 17186 config = BX.type.isPlainObject(config) ? config : {}; 17187 17188 config.headers = config.headers || []; 17189 config.headers.push({name: 'X-Bitrix-Csrf-Token', value: BX.bitrix_sessid()}); 17190 if (BX.message.SITE_ID) 17191 { 17192 config.headers.push({name: 'X-Bitrix-Site-Id', value: BX.message.SITE_ID}); 17193 } 17194 17195 if (typeof config.json !== 'undefined') 17196 { 17197 if (!BX.type.isPlainObject(config.json)) 17198 { 17199 throw new Error('Wrong `config.json`, plain object expected.') 17200 } 17201 17202 config.headers.push({name: 'Content-Type', value: 'application/json'}); 17203 config.data = config.json; 17204 config.preparePost = false; 17205 } 17206 else if (config.data instanceof FormData) 17207 { 17208 config.preparePost = false; 17209 if (typeof config.signedParameters !== 'undefined') 17210 { 17211 config.data.append('signedParameters', config.signedParameters); 17212 } 17213 } 17214 else if (BX.type.isPlainObject(config.data) || BX.Type.isNil(config.data)) 17215 { 17216 config.data = BX.type.isPlainObject(config.data) ? config.data : {}; 17217 if (typeof config.signedParameters !== 'undefined') 17218 { 17219 config.data.signedParameters = config.signedParameters; 17220 } 17221 } 17222 17223 if (!config.method) 17224 { 17225 config.method = 'POST' 17226 } 17227 17228 return config; 17229}; 17230 17231var buildAjaxPromiseToRestoreCsrf = function(config, withoutRestoringCsrf) 17232{ 17233 withoutRestoringCsrf = withoutRestoringCsrf || false; 17234 var originalConfig = BX.clone(config); 17235 var request = null; 17236 17237 var onrequeststart = config.onrequeststart; 17238 config.onrequeststart = function(xhr) { 17239 request = xhr; 17240 if (BX.type.isFunction(onrequeststart)) 17241 { 17242 onrequeststart(xhr); 17243 } 17244 }; 17245 var onrequeststartOrig = originalConfig.onrequeststart; 17246 originalConfig.onrequeststart = function(xhr) { 17247 request = xhr; 17248 if (BX.type.isFunction(onrequeststartOrig)) 17249 { 17250 onrequeststartOrig(xhr); 17251 } 17252 }; 17253 17254 var promise = BX.ajax.promise(config); 17255 17256 return promise.then(function(response) { 17257 if (!withoutRestoringCsrf && BX.type.isPlainObject(response) && BX.type.isArray(response.errors)) 17258 { 17259 var csrfProblem = false; 17260 response.errors.forEach(function(error) { 17261 if (error.code === 'invalid_csrf' && error.customData.csrf) 17262 { 17263 BX.message({'bitrix_sessid': error.customData.csrf}); 17264 17265 originalConfig.headers = originalConfig.headers || []; 17266 originalConfig.headers = originalConfig.headers.filter(function(header) { 17267 return header && header.name !== 'X-Bitrix-Csrf-Token'; 17268 }); 17269 originalConfig.headers.push({name: 'X-Bitrix-Csrf-Token', value: BX.bitrix_sessid()}); 17270 17271 csrfProblem = true; 17272 } 17273 }); 17274 17275 if (csrfProblem) 17276 { 17277 return buildAjaxPromiseToRestoreCsrf(originalConfig, true); 17278 } 17279 } 17280 17281 if (!BX.type.isPlainObject(response) || response.status !== 'success') 17282 { 17283 var errorPromise = new BX.Promise(); 17284 errorPromise.reject(response); 17285 17286 return errorPromise; 17287 } 17288 17289 return response; 17290 }).catch(function(data) { 17291 var ajaxReject = new BX.Promise(); 17292 17293 var originalJsonResponse; 17294 if (BX.type.isPlainObject(data) && data.xhr && data.xhr.responseText) 17295 { 17296 try 17297 { 17298 originalJsonResponse = JSON.parse(data.xhr.responseText); 17299 data = originalJsonResponse; 17300 } 17301 catch (err) 17302 {} 17303 } 17304 17305 if (BX.type.isPlainObject(data) && data.status && data.hasOwnProperty('data')) 17306 { 17307 ajaxReject.reject(data); 17308 } 17309 else 17310 { 17311 ajaxReject.reject({ 17312 status: 'error', 17313 data: { 17314 ajaxRejectData: data 17315 }, 17316 errors: [ 17317 { 17318 code: 'NETWORK_ERROR', 17319 message: 'Network error' 17320 } 17321 ] 17322 }); 17323 } 17324 17325 return ajaxReject; 17326 }).then(function(response){ 17327 17328 var assetsLoaded = new BX.Promise(); 17329 17330 var headers = request.getAllResponseHeaders().trim().split(/[\r\n]+/); 17331 var headerMap = {}; 17332 headers.forEach(function (line) { 17333 var parts = line.split(': '); 17334 var header = parts.shift().toLowerCase(); 17335 headerMap[header] = parts.join(': '); 17336 }); 17337 17338 if (!headerMap['x-process-assets']) 17339 { 17340 assetsLoaded.fulfill(response); 17341 17342 return assetsLoaded; 17343 } 17344 17345 var assets = BX.prop.getObject(BX.prop.getObject(response, "data", {}), "assets", {}); 17346 var promise = new Promise(function(resolve, reject) { 17347 var css = BX.prop.getArray(assets, "css", []); 17348 BX.load(css, function(){ 17349 BX.loadScript( 17350 BX.prop.getArray(assets, "js", []), 17351 resolve 17352 ); 17353 }); 17354 }); 17355 promise.then(function(){ 17356 var strings = BX.prop.getArray(assets, "string", []); 17357 var stringAsset = strings.join('\n'); 17358 BX.html(document.head, stringAsset, { useAdjacentHTML: true }).then(function(){ 17359 assetsLoaded.fulfill(response); 17360 }); 17361 }); 17362 17363 return assetsLoaded; 17364 }); 17365}; 17366 17367/** 17368 * 17369 * @param {string} action 17370 * @param {Object} config 17371 * @param {?string|?Object} [config.analyticsLabel] 17372 * @param {string} [config.method='POST'] 17373 * @param {Object} [config.data] 17374 * @param {?Object} [config.getParameters] 17375 * @param {?Object} [config.headers] 17376 * @param {?Object} [config.timeout] 17377 * @param {Object} [config.navigation] 17378 * @param {number} [config.navigation.page] 17379 */ 17380BX.ajax.runAction = function(action, config) 17381{ 17382 config = prepareAjaxConfig(config); 17383 var getParameters = prepareAjaxGetParameters(config); 17384 getParameters.action = action; 17385
17386 var url = '/bitrix/services/main/ajax.php?' + BX.ajax.prepareData(getParameters); 17387 return buildAjaxPromiseToRestoreCsrf({ 17388 method: config.method, 17389 dataType: 'json', 17390 url: url, 17391 data: config.data, 17392 timeout: config.timeout, 17393 preparePost: config.preparePost, 17394 headers: config.headers, 17395 onrequeststart: config.onrequeststart, 17396 onprogress: config.onprogress, 17397 onprogressupload: config.onprogressupload 17398 }); 17399}; 17400 17401/** 17402 * 17403 * @param {string} component 17404 * @param {string} action 17405 * @param {Object} config 17406 * @param {?string|?Object} [config.analyticsLabel] 17407 * @param {?string} [config.signedParameters] 17408 * @param {string} [config.method='POST'] 17409 * @param {string} [config.mode='ajax'] Ajax or class. 17410 * @param {Object} [config.data] 17411 * @param {?Object} [config.getParameters] 17412 * @param {?array} [config.headers] 17413 * @param {?number} [config.timeout] 17414 * @param {Object} [config.navigation] 17415 */ 17416BX.ajax.runComponentAction = function (component, action, config) 17417{ 17418 config = prepareAjaxConfig(config); 17419 config.mode = config.mode || 'ajax'; 17420 17421 var getParameters = prepareAjaxGetParameters(config); 17422 getParameters.c = component; 17423 getParameters.action = action; 17424
17425 var url = '/bitrix/services/main/ajax.php?' + BX.ajax.prepareData(getParameters); 17426 17427 return buildAjaxPromiseToRestoreCsrf({ 17428 method: config.method, 17429 dataType: 'json', 17430 url: url, 17431 data: config.data, 17432 timeout: config.timeout, 17433 preparePost: config.preparePost, 17434 headers: config.headers, 17435 onrequeststart: (config.onrequeststart ? config.onrequeststart : null), 17436 onprogress: config.onprogress, 17437 onprogressupload: config.onprogressupload 17438 }); 17439}; 17440 17441/* 17442arObs = [{ 17443 url: url, 17444 type: html|script|json|css, 17445 callback: function 17446}] 17447*/ 17448BX.ajax.load = function(arObs, callback) 17449{ 17450 if (!BX.type.isArray(arObs)) 17451 arObs = [arObs]; 17452 17453 var cnt = 0; 17454 17455 if (!BX.type.isFunction(callback)) 17456 callback = BX.DoNothing; 17457 17458 var handler = function(data) 17459 { 17460 if (BX.type.isFunction(this.callback)) 17461 this.callback(data); 17462 17463 if (++cnt >= len) 17464 callback(); 17465 }; 17466 17467 for (var i = 0, len = arObs.length; i<len; i++) 17468 { 17469 switch(arObs[i].type.toUpperCase()) 17470 { 17471 case 'SCRIPT': 17472 BX.loadScript([arObs[i].url], BX.proxy(handler, arObs[i])); 17473 break; 17474 case 'CSS': 17475 BX.loadCSS([arObs[i].url]); 17476 17477 if (++cnt >= len) 17478 callback(); 17479 break; 17480 case 'JSON': 17481 BX.ajax.loadJSON(arObs[i].url, BX.proxy(handler, arObs[i])); 17482 break; 17483 17484 default: 17485 BX.ajax.get(arObs[i].url, '', BX.proxy(handler, arObs[i])); 17486 break; 17487 } 17488 } 17489}; 17490 17491/* ajax form sending */ 17492BX.ajax.submit = function(obForm, callback) 17493{ 17494 if (!obForm.target) 17495 { 17496 if (null == obForm.BXFormTarget) 17497 { 17498 var frame_name = 'formTarget_' + Math.random(); 17499 obForm.BXFormTarget = document.body.appendChild(BX.create('IFRAME', { 17500 props: { 17501 name: frame_name, 17502 id: frame_name, 17503 src: 'javascript:void(0)' 17504 }, 17505 style: { 17506 display: 'none' 17507 } 17508 })); 17509 } 17510 17511 obForm.target = obForm.BXFormTarget.name; 17512 } 17513 17514 obForm.BXFormCallback = callback; 17515 BX.bind(obForm.BXFormTarget, 'load', BX.proxy(BX.ajax._submit_callback, obForm)); 17516 17517 BX.submit(obForm); 17518 17519 return false; 17520}; 17521 17522BX.ajax.submitComponentForm = function(obForm, container, bWait) 17523{ 17524 if (!obForm.target) 17525 { 17526 if (null == obForm.BXFormTarget) 17527 { 17528 var frame_name = 'formTarget_' + Math.random(); 17529 obForm.BXFormTarget = document.body.appendChild(BX.create('IFRAME', { 17530 props: { 17531 name: frame_name, 17532 id: frame_name, 17533 src: 'javascript:void(0)' 17534 }, 17535 style: { 17536 display: 'none' 17537 } 17538 })); 17539 } 17540 17541 obForm.target = obForm.BXFormTarget.name; 17542 } 17543 17544 if (!!bWait) 17545 var w = BX.showWait(container); 17546 17547 obForm.BXFormCallback = function(d) { 17548 if (!!bWait) 17549 BX.closeWait(w); 17550 17551 var callOnload = function(){ 17552 if(!!window.bxcompajaxframeonload) 17553 { 17554 setTimeout(function(){window.bxcompajaxframeonload();window.bxcompajaxframeonload=null;}, 10); 17555 } 17556 }; 17557 17558 BX(container).innerHTML = d; 17559 BX.onCustomEvent('onAjaxSuccess', [null,null,callOnload]); 17560 }; 17561 17562 BX.bind(obForm.BXFormTarget, 'load', BX.proxy(BX.ajax._submit_callback, obForm)); 17563 17564 return true; 17565}; 17566 17567// func will be executed in form context 17568BX.ajax._submit_callback = function() 17569{ 17570 //opera and IE8 triggers onload event even on empty iframe 17571 try 17572 { 17573 if(this.BXFormTarget.contentWindow.location.href.indexOf('http') != 0) 17574 return; 17575 } catch (e) { 17576 return; 17577 } 17578 17579 if (this.BXFormCallback) 17580 this.BXFormCallback.apply(this, [this.BXFormTarget.contentWindow.document.body.innerHTML]); 17581 17582 BX.unbindAll(this.BXFormTarget); 17583}; 17584 17585BX.ajax.prepareForm = function(obForm, data) 17586{ 17587 data = (!!data ? data : {}); 17588 var i, ii, el, 17589 _data = [], 17590 n = obForm.elements.length, 17591 files = 0, length = 0; 17592 if(!!obForm) 17593 { 17594 for (i = 0; i < n; i++) 17595 { 17596 el = obForm.elements[i]; 17597 if (el.disabled) 17598 continue; 17599 17600 if(!el.type) 17601 continue; 17602 17603 switch(el.type.toLowerCase()) 17604 { 17605 case 'text': 17606 case 'textarea': 17607 case 'password': 17608 case 'number': 17609 case 'hidden': 17610 case 'select-one': 17611 _data.push({name: el.name, value: el.value}); 17612 length += (el.name.length + el.value.length); 17613 break; 17614 case 'file': 17615 if (!!el.files) 17616 { 17617 for (ii = 0; ii < el.files.length; ii++) 17618 { 17619 files++; 17620 _data.push({name: el.name, value: el.files[ii], file : true}); 17621 length += el.files[ii].size; 17622 } 17623 } 17624 break; 17625 case 'radio':
17626 case 'checkbox': 17627 if(el.checked) 17628 { 17629 _data.push({name: el.name, value: el.value}); 17630 length += (el.name.length + el.value.length); 17631 } 17632 break; 17633 case 'select-multiple': 17634 for (var j = 0; j < el.options.length; j++) 17635 { 17636 if (el.options[j].selected) 17637 { 17638 _data.push({name : el.name, value : el.options[j].value}); 17639 length += (el.name.length + el.options[j].length); 17640 } 17641 } 17642 break; 17643 default: 17644 break; 17645 } 17646 } 17647 17648 i = 0; length = 0; 17649 var current = data, name, rest, pp, tmpKey; 17650 17651 while(i < _data.length) 17652 { 17653 var p = _data[i].name.indexOf('['); 17654 if (tmpKey) 17655 { 17656 current[_data[i].name] = {}; 17657 current[_data[i].name][tmpKey.replace(/\[|\]/gi, '')] = _data[i].value; 17658 current = data; 17659 tmpKey = null; 17660 i++; 17661 } 17662 else if (p == -1) 17663 { 17664 current[_data[i].name] = _data[i].value; 17665 current = data; 17666 i++; 17667 } 17668 else 17669 { 17670 name = _data[i].name.substring(0, p); 17671 rest = _data[i].name.substring(p+1); 17672 pp = rest.indexOf(']'); 17673 17674 if(pp == -1) 17675 { 17676 if (!current[name]) 17677 current[name] = []; 17678 current = data; 17679 i++; 17680 } 17681 else if(pp == 0) 17682 { 17683 if (!current[name]) 17684 current[name] = []; 17685 //No index specified - so take the next integer 17686 current = current[name]; 17687 _data[i].name = '' + current.length; 17688 if (rest.substring(pp+1).indexOf('[') === 0) 17689 tmpKey = rest.substring(0, pp) + rest.substring(pp+1); 17690 } 17691 else 17692 { 17693 if (!current[name]) 17694 current[name] = {}; 17695 //Now index name becomes and name and we go deeper into the array 17696 current = current[name]; 17697 _data[i].name = rest.substring(0, pp) + rest.substring(pp+1); 17698 } 17699 } 17700 } 17701 } 17702 return {data : data, filesCount : files, roughSize : length}; 17703}; 17704BX.ajax.submitAjax = function(obForm, config) 17705{ 17706 config = (config !== null && typeof config == "object" ? config : {}); 17707 config.url = (config["url"] || obForm.getAttribute("action")); 17708 17709 var additionalData = (config["data"] || {}); 17710 config.data = BX.ajax.prepareForm(obForm).data; 17711 for (var ii in additionalData) 17712 { 17713 if (additionalData.hasOwnProperty(ii)) 17714 { 17715 config.data[ii] = additionalData[ii]; 17716 } 17717 } 17718 17719 if (!window["FormData"]) 17720 { 17721 BX.ajax(config); 17722 } 17723 else 17724 { 17725 var isFile = function(item) 17726 { 17727 var res = Object.prototype.toString.call(item); 17728 return (res == '[object File]' || res == '[object Blob]'); 17729 }, 17730 appendToForm = function(fd, key, val) 17731 { 17732 if (!!val && typeof val == "object" && !isFile(val)) 17733 { 17734 for (var ii in val) 17735 { 17736 if (val.hasOwnProperty(ii)) 17737 { 17738 appendToForm(fd, (key == '' ? ii : key + '[' + ii + ']'), val[ii]); 17739 } 17740 } 17741 } 17742 else 17743 fd.append(key, (!!val ? val : '')); 17744 }, 17745 prepareData = function(arData) 17746 { 17747 var data = {}; 17748 if (null != arData) 17749 { 17750 if(typeof arData == 'object') 17751 { 17752 for(var i in arData) 17753 { 17754 if (arData.hasOwnProperty(i)) 17755 { 17756 var name = BX.util.urlencode(i); 17757 if(typeof arData[i] == 'object' && arData[i]["file"] !== true) 17758 data[name] = prepareData(arData[i]); 17759 else if (arData[i]["file"] === true) 17760 data[name] = arData[i]["value"]; 17761 else 17762 data[name] = BX.util.urlencode(arData[i]); 17763 } 17764 } 17765 } 17766 else 17767 data = BX.util.urlencode(arData); 17768 } 17769 return data; 17770 }, 17771 fd = new window.FormData(); 17772 17773 if (config.method !== 'POST') 17774 { 17775 config.data = BX.ajax.prepareData(config.data); 17776 if (config.data) 17777 { 17778 config.url += (config.url.indexOf('?') !== -1 ? "&" : "?") + config.data; 17779 config.data = ''; 17780 } 17781 } 17782 else 17783 { 17784 if (config.preparePost === true) 17785 config.data = prepareData(config.data); 17786 appendToForm(fd, '', config.data); 17787 config.data = fd; 17788 } 17789 17790 config.preparePost = false; 17791 config.start = false;
17792 17793 var xhr = BX.ajax(config); 17794 if (!!config["onprogress"]) 17795 xhr.upload.addEventListener( 17796 'progress', 17797 function(e){ 17798 var percent = null; 17799 if(e.lengthComputable && (e.total || e["totalSize"])) { 17800 percent = e.loaded * 100 / (e.total || e["totalSize"]); 17801 } 17802 config["onprogress"](e, percent); 17803 } 17804 ); 17805 xhr.send(fd); 17806 } 17807}; 17808 17809BX.ajax.UpdatePageData = function (arData) 17810{ 17811 if (arData.TITLE) 17812 BX.ajax.UpdatePageTitle(arData.TITLE); 17813 if (arData.WINDOW_TITLE || arData.TITLE) 17814 BX.ajax.UpdateWindowTitle(arData.WINDOW_TITLE || arData.TITLE); 17815 if (arData.NAV_CHAIN) 17816 BX.ajax.UpdatePageNavChain(arData.NAV_CHAIN); 17817 if (arData.CSS && arData.CSS.length > 0) 17818 BX.loadCSS(arData.CSS); 17819 if (arData.SCRIPTS && arData.SCRIPTS.length > 0) 17820 { 17821 var f = function(result,config,cb){ 17822 17823 if(!!config && BX.type.isArray(config.scripts)) 17824 { 17825 for(var i=0,l=arData.SCRIPTS.length;i<l;i++) 17826 { 17827 config.scripts.push({isInternal:false,JS:arData.SCRIPTS[i]}); 17828 } 17829 } 17830 else 17831 { 17832 BX.loadScript(arData.SCRIPTS,cb); 17833 } 17834 17835 BX.removeCustomEvent('onAjaxSuccess',f); 17836 }; 17837 BX.addCustomEvent('onAjaxSuccess',f); 17838 } 17839 else 17840 { 17841 var f1 = function(result,config,cb){ 17842 if(BX.type.isFunction(cb)) 17843 { 17844 cb(); 17845 } 17846 BX.removeCustomEvent('onAjaxSuccess',f1); 17847 }; 17848 BX.addCustomEvent('onAjaxSuccess', f1); 17849 } 17850}; 17851 17852BX.ajax.UpdatePageTitle = function(title) 17853{ 17854 var obTitle = BX('pagetitle'); 17855 if (obTitle) 17856 { 17857 BX.remove(obTitle.firstChild); 17858 if (!obTitle.firstChild) 17859 obTitle.appendChild(document.createTextNode(title)); 17860 else 17861 obTitle.insertBefore(document.createTextNode(title), obTitle.firstChild); 17862 } 17863}; 17864 17865BX.ajax.UpdateWindowTitle = function(title) 17866{ 17867 document.title = title; 17868}; 17869 17870BX.ajax.UpdatePageNavChain = function(nav_chain) 17871{ 17872 var obNavChain = BX('navigation'); 17873 if (obNavChain) 17874 { 17875 obNavChain.innerHTML = nav_chain; 17876 } 17877}; 17878 17879/* user options handling */ 17880BX.userOptions = { 17881 options: null, 17882 bSend: false, 17883 delay: 5000, 17884 path: '/bitrix/admin/user_options.php?' 17885}; 17886 17887BX.userOptions.setAjaxPath = function(url) 17888{ 17889 BX.userOptions.path = url.indexOf('?') == -1? url+'?': url+'&'; 17890} 17891BX.userOptions.save = function(sCategory, sName, sValName, sVal, bCommon) 17892{ 17893 if (null == BX.userOptions.options) 17894 BX.userOptions.options = {}; 17895 17896 bCommon = !!bCommon; 17897 BX.userOptions.options[sCategory+'.'+sName+'.'+sValName] = [sCategory, sName, sValName, sVal, bCommon]; 17898 17899 var sParam = BX.userOptions.__get(); 17900 if (sParam != '') 17901 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=/;"; 17902 17903 if(!BX.userOptions.bSend) 17904 { 17905 BX.userOptions.bSend = true; 17906 setTimeout(function(){BX.userOptions.send(null)}, BX.userOptions.delay); 17907 } 17908}; 17909 17910BX.userOptions.send = function(callback) 17911{ 17912 var sParam = BX.userOptions.__get(); 17913 BX.userOptions.options = null; 17914 BX.userOptions.bSend = false; 17915 17916 if (sParam != '') 17917 { 17918 document.cookie = BX.message('COOKIE_PREFIX') + "_LAST_SETTINGS=; path=/;"; 17919 BX.ajax({ 17920 'method': 'GET', 17921 'dataType': 'html', 17922 'processData': false, 17923 'cache': false, 17924 'url': BX.userOptions.path+sParam+'&sessid='+BX.bitrix_sessid(), 17925 'onsuccess': callback 17926 }); 17927 } 17928}; 17929 17930BX.userOptions.del = function(sCategory, sName, bCommon, callback) 17931{ 17932 BX.ajax.get(BX.userOptions.path+'action=delete&c='+sCategory+'&n='+sName+(bCommon == true? '&common=Y':'')+'&sessid='+BX.bitrix_sessid(), callback); 17933}; 17934 17935BX.userOptions.__get = function() 17936{ 17937 if (!BX.userOptions.options) return ''; 17938 17939 var sParam = '', n = -1, prevParam = '', aOpt, i; 17940 17941 for (i in BX.userOptions.options) 17942 { 17943 if(BX.userOptions.options.hasOwnProperty(i)) 17944 { 17945 aOpt = BX.userOptions.options[i]; 17946 17947 if (prevParam != aOpt[0]+'.'+aOpt[1]) 17948 { 17949 n++; 17950 sParam += '&p['+n+'][c]='+BX.util.urlencode(aOpt[0]); 17951 sParam += '&p['+n+'][n]='+BX.util.urlencode(aOpt[1]); 17952 if (aOpt[4] == true) 17953 sParam += '&p['+n+'][d]=Y'; 17954 prevParam = aOpt[0]+'.'+aOpt[1]; 17955 } 17956 17957 var valueName = aOpt[2]; 17958 var value = aOpt[3]; 17959 17960 if (valueName === null) 17961 { 17962 sParam += '&p['+n+'][v]='+BX.util.urlencode(value); 17963 } 17964 else 17965 {
17966 sParam += '&p['+n+'][v]['+BX.util.urlencode(valueName)+']='+BX.util.urlencode(value); 17967 } 17968 } 17969 } 17970 17971 return sParam.substr(1); 17972}; 17973 17974BX.ajax.history = { 17975 expected_hash: '', 17976 17977 obParams: null, 17978 17979 obFrame: null, 17980 obImage: null, 17981 17982 obTimer: null, 17983 17984 bInited: false, 17985 bHashCollision: false, 17986 bPushState: !!(history.pushState && BX.type.isFunction(history.pushState)), 17987 17988 startState: null, 17989 17990 init: function(obParams) 17991 { 17992 if (BX.ajax.history.bInited) 17993 return; 17994 17995 this.obParams = obParams; 17996 var obCurrentState = this.obParams.getState(); 17997 17998 if (BX.ajax.history.bPushState) 17999 { 18000 BX.ajax.history.expected_hash = window.location.pathname; 18001 if (window.location.search) 18002 BX.ajax.history.expected_hash += window.location.search; 18003 18004 BX.ajax.history.put(obCurrentState, BX.ajax.history.expected_hash, '', true); 18005 // due to some strange thing, chrome calls popstate event on page start. so we should delay it 18006 setTimeout(function(){BX.bind(window, 'popstate', BX.ajax.history.__hashListener);}, 500); 18007 } 18008 else 18009 { 18010 BX.ajax.history.expected_hash = window.location.hash; 18011 18012 if (!BX.ajax.history.expected_hash || BX.ajax.history.expected_hash == '#') 18013 BX.ajax.history.expected_hash = '__bx_no_hash__'; 18014 18015 jsAjaxHistoryContainer.put(BX.ajax.history.expected_hash, obCurrentState); 18016 BX.ajax.history.obTimer = setTimeout(BX.ajax.history.__hashListener, 500); 18017 18018 if (BX.browser.IsIE()) 18019 { 18020 BX.ajax.history.obFrame = document.createElement('IFRAME'); 18021 BX.hide_object(BX.ajax.history.obFrame); 18022 18023 document.body.appendChild(BX.ajax.history.obFrame); 18024 18025 BX.ajax.history.obFrame.contentWindow.document.open(); 18026 BX.ajax.history.obFrame.contentWindow.document.write(BX.ajax.history.expected_hash); 18027 BX.ajax.history.obFrame.contentWindow.document.close(); 18028 } 18029 else if (BX.browser.IsOpera()) 18030 { 18031 BX.ajax.history.obImage = document.createElement('IMG'); 18032 BX.hide_object(BX.ajax.history.obImage); 18033 18034 document.body.appendChild(BX.ajax.history.obImage); 18035 18036 BX.ajax.history.obImage.setAttribute('src', 'javascript:location.href = \'javascript:BX.ajax.history.__hashListener();\';'); 18037 } 18038 } 18039 18040 BX.ajax.history.bInited = true; 18041 }, 18042 18043 __hashListener: function(e) 18044 { 18045 e = e || window.event || {state:false}; 18046 18047 if (BX.ajax.history.bPushState) 18048 { 18049 BX.ajax.history.obParams.setState(e.state||BX.ajax.history.startState); 18050 } 18051 else 18052 { 18053 if (BX.ajax.history.obTimer) 18054 { 18055 window.clearTimeout(BX.ajax.history.obTimer); 18056 BX.ajax.history.obTimer = null; 18057 } 18058 18059 var current_hash; 18060 if (null != BX.ajax.history.obFrame) 18061 current_hash = BX.ajax.history.obFrame.contentWindow.document.body.innerText; 18062 else 18063 current_hash = window.location.hash; 18064 18065 if (!current_hash || current_hash == '#') 18066 current_hash = '__bx_no_hash__'; 18067 18068 if (current_hash.indexOf('#') == 0) 18069 current_hash = current_hash.substring(1); 18070 18071 if (current_hash != BX.ajax.history.expected_hash) 18072 { 18073 var state = jsAjaxHistoryContainer.get(current_hash); 18074 if (state) 18075 { 18076 BX.ajax.history.obParams.setState(state); 18077 18078 BX.ajax.history.expected_hash = current_hash; 18079 if (null != BX.ajax.history.obFrame) 18080 { 18081 var __hash = current_hash == '__bx_no_hash__' ? '' : current_hash; 18082 if (window.location.hash != __hash && window.location.hash != '#' + __hash) 18083 window.location.hash = __hash; 18084 } 18085 } 18086 } 18087 18088 BX.ajax.history.obTimer = setTimeout(BX.ajax.history.__hashListener, 500); 18089 } 18090 }, 18091 18092 put: function(state, new_hash, new_hash1, bStartState) 18093 { 18094 if (this.bPushState) 18095 { 18096 if(!bStartState) 18097 { 18098 history.pushState(state, '', new_hash); 18099 } 18100 else 18101 { 18102 BX.ajax.history.startState = state; 18103 } 18104 } 18105 else 18106 { 18107 if (typeof new_hash1 != 'undefined') 18108 new_hash = new_hash1; 18109 else 18110 new_hash = 'view' + new_hash; 18111 18112 jsAjaxHistoryContainer.put(new_hash, state); 18113 BX.ajax.history.expected_hash = new_hash; 18114 18115 window.location.hash = BX.util.urlencode(new_hash); 18116 18117 if (null != BX.ajax.history.obFrame) 18118 { 18119 BX.ajax.history.obFrame.contentWindow.document.open(); 18120 BX.ajax.history.obFrame.contentWindow.document.write(new_hash); 18121 BX.ajax.history.obFrame.contentWindow.document.close(); 18122 } 18123 } 18124 }, 18125 18126 checkRedirectStart: function(param_name, param_value) 18127 { 18128 var current_hash = window.location.hash; 18129 if (current_hash.substring(0, 1) == '#') current_hash = current_hash.substring(1); 18130 18131 var test = current_hash.substring(0, 5); 18132 if (test == 'view/' || test == 'view%') 18133 { 18134 BX.ajax.history.bHashCollision = true;
18135 document.write('<' + 'div id="__ajax_hash_collision_' + param_value + '" style="display: none;">'); 18136 } 18137 }, 18138 18139 checkRedirectFinish: function(param_name, param_value) 18140 { 18141 document.write('</div>'); 18142 18143 var current_hash = window.location.hash; 18144 if (current_hash.substring(0, 1) == '#') current_hash = current_hash.substring(1); 18145 18146 BX.ready(function () 18147 { 18148 var test = current_hash.substring(0, 5); 18149 if (test == 'view/' || test == 'view%') 18150 { 18151 var obColNode = BX('__ajax_hash_collision_' + param_value); 18152 var obNode = obColNode.firstChild; 18153 BX.cleanNode(obNode); 18154 obColNode.style.display = 'block'; 18155 18156 // IE, Opera and Chrome automatically modifies hash with urlencode, but FF doesn't ;-( 18157 if (test != 'view%') 18158 current_hash = BX.util.urlencode(current_hash); 18159 18160 current_hash += (current_hash.indexOf('%3F') == -1 ? '%3F' : '%26') + param_name + '=' + param_value; 18161 18162 var url = '/bitrix/tools/ajax_redirector.php?hash=' + current_hash; 18163 18164 BX.ajax.insertToNode(url, obNode); 18165 } 18166 }); 18167 } 18168}; 18169 18170BX.ajax.component = function(node) 18171{ 18172 this.node = node; 18173}; 18174 18175BX.ajax.component.prototype.getState = function() 18176{ 18177 var state = { 18178 'node': this.node, 18179 'title': window.document.title, 18180 'data': BX(this.node).innerHTML 18181 }; 18182 18183 var obNavChain = BX('navigation'); 18184 if (null != obNavChain) 18185 state.nav_chain = obNavChain.innerHTML; 18186 18187 BX.onCustomEvent(BX(state.node), "onComponentAjaxHistoryGetState", [state]); 18188 18189 return state; 18190}; 18191 18192BX.ajax.component.prototype.setState = function(state) 18193{ 18194 BX(state.node).innerHTML = state.data; 18195 BX.ajax.UpdatePageTitle(state.title); 18196 18197 if (state.nav_chain) 18198 { 18199 BX.ajax.UpdatePageNavChain(state.nav_chain); 18200 } 18201 18202 BX.onCustomEvent(BX(state.node), "onComponentAjaxHistorySetState", [state]); 18203}; 18204 18205var jsAjaxHistoryContainer = { 18206 arHistory: {}, 18207 18208 put: function(hash, state) 18209 { 18210 this.arHistory[hash] = state; 18211 }, 18212 18213 get: function(hash) 18214 { 18215 return this.arHistory[hash]; 18216 } 18217}; 18218 18219 18220BX.ajax.FormData = function() 18221{ 18222 this.elements = []; 18223 this.files = []; 18224 this.features = {}; 18225 this.isSupported(); 18226 this.log('BX FormData init'); 18227}; 18228 18229BX.ajax.FormData.isSupported = function() 18230{ 18231 var f = new BX.ajax.FormData(); 18232 var result = f.features.supported; 18233 f = null; 18234 return result; 18235}; 18236 18237BX.ajax.FormData.prototype.log = function(o) 18238{ 18239 if (false) { 18240 try { 18241 if (BX.browser.IsIE()) o = JSON.stringify(o); 18242 console.log(o); 18243 } catch(e) {} 18244 } 18245}; 18246 18247BX.ajax.FormData.prototype.isSupported = function() 18248{ 18249 var f = {}; 18250 f.fileReader = (window.FileReader && window.FileReader.prototype.readAsBinaryString); 18251 f.readFormData = f.sendFormData = !!(window.FormData); 18252 f.supported = !!(f.readFormData && f.sendFormData); 18253 this.features = f; 18254 this.log('features:'); 18255 this.log(f); 18256 18257 return f.supported; 18258}; 18259 18260BX.ajax.FormData.prototype.append = function(name, value) 18261{ 18262 if (typeof(value) === 'object') { // seems to be files element 18263 this.files.push({'name': name, 'value':value}); 18264 } else { 18265 this.elements.push({'name': name, 'value':value}); 18266 } 18267}; 18268 18269BX.ajax.FormData.prototype.send = function(url, callbackOk, callbackProgress, callbackError) 18270{ 18271 this.log('FD send'); 18272 this.xhr = BX.ajax({ 18273 'method': 'POST', 18274 'dataType': 'html', 18275 'url': url, 18276 'onsuccess': callbackOk, 18277 'onfailure': callbackError, 18278 'start': false, 18279 'preparePost':false 18280 }); 18281 18282 if (callbackProgress) 18283 { 18284 this.xhr.upload.addEventListener( 18285 'progress', 18286 function(e) { 18287 if (e.lengthComputable) 18288 callbackProgress(e.loaded / (e.total || e.totalSize)); 18289 }, 18290 false 18291 ); 18292 } 18293 18294 if (this.features.readFormData && this.features.sendFormData) 18295 { 18296 var fd = new FormData(); 18297 this.log('use browser formdata'); 18298 for (var i in this.elements) 18299 { 18300 if(this.elements.hasOwnProperty(i)) 18301 fd.append(this.elements[i].name,this.elements[i].value); 18302 } 18303 for (i in this.files) 18304 { 18305 if(this.files.hasOwnProperty(i)) 18306 fd.append(this.files[i].name, this.files[i].value); 18307 } 18308 this.xhr.send(fd); 18309 } 18310 18311 return this.xhr; 18312}; 18313 18314BX.addCustomEvent('onAjaxFailure', BX.debug); 18315})(window); 18316 18317 18318 18319(function (exports,main_core) { 18320 'use strict'; 18321 18322 var LazyLoad = { 18323 observer: null, 18324 images: {}, 18325 imageStatus: { 18326 hidden: -2, 18327 error: -1, 18328 "undefined": 0, 18329 inited: 1, 18330 loaded: 2 18331 }, 18332 imageTypes: { 18333 image: 1, 18334 background: 2 18335 },
18336 initObserver: function initObserver() { 18337 this.observer = new IntersectionObserver(this.onIntersection.bind(this), { 18338 rootMargin: '20% 0% 20% 0%', 18339 threshold: 0.10 18340 }); 18341 }, 18342 onIntersection: function onIntersection(entries) { 18343 entries.forEach(function (entry) { 18344 if (entry.isIntersecting) { 18345 this.showImage(entry.target); 18346 } 18347 }.bind(this)); 18348 }, 18349 registerImage: function registerImage(id, isImageVisibleCallback, options) { 18350 if (this.observer === null) { 18351 this.initObserver(); 18352 } 18353 18354 options = options || {}; 18355 18356 if (!main_core.Type.isStringFilled(id)) { 18357 return; 18358 } 18359 18360 if (main_core.Type.isObject(this.images[id])) { 18361 return; 18362 } 18363 18364 var element = document.getElementById(id); 18365 18366 if (!main_core.Type.isDomNode(element)) { 18367 return; 18368 } 18369 18370 this.observer.observe(element); 18371 this.images[id] = { 18372 id: id, 18373 node: null, 18374 src: null, 18375 dataSrcName: options.dataSrcName || 'src', 18376 type: null, 18377 func: main_core.Type.isFunction(isImageVisibleCallback) ? isImageVisibleCallback : null, 18378 status: this.imageStatus.undefined 18379 }; 18380 }, 18381 registerImages: function registerImages(ids, isImageVisibleCallback, options) { 18382 if (main_core.Type.isArray(ids)) { 18383 for (var i = 0, length = ids.length; i < length; i++) { 18384 this.registerImage(ids[i], isImageVisibleCallback, options); 18385 } 18386 } 18387 }, 18388 showImage: function showImage(imageNode) { 18389 var imageNodeId = imageNode.id; 18390 18391 if (!main_core.Type.isStringFilled(imageNodeId)) { 18392 return; 18393 } 18394 18395 var image = this.images[imageNodeId]; 18396 18397 if (!main_core.Type.isPlainObject(image)) { 18398 return; 18399 } 18400 18401 if (image.status == this.imageStatus.undefined) { 18402 this.initImage(image); 18403 } 18404 18405 if (image.status !== this.imageStatus.inited) { 18406 return; 18407 } 18408 18409 if (!image.node || !image.node.parentNode) { 18410 image.node = null; 18411 image.status = this.imageStatus.error; 18412 return; 18413 } 18414 18415 if (image.type == this.imageTypes.image) { 18416 image.node.src = image.src; 18417 } else { 18418 image.node.style.backgroundImage = "url('" + image.src + "')"; 18419 } 18420 18421 image.node.dataset[image.dataSrcName] = ""; 18422 image.status = this.imageStatus.loaded; 18423 }, 18424 showImages: function showImages(checkOwnVisibility) { 18425 checkOwnVisibility = checkOwnVisibility !== false; 18426 18427 for (var id in this.images) { 18428 if (!this.images.hasOwnProperty(id)) { 18429 continue; 18430 } 18431 18432 var image = this.images[id]; 18433 18434 if (image.status == this.imageStatus.undefined) { 18435 this.initImage(image); 18436 } 18437 18438 if (image.status !== this.imageStatus.inited) { 18439 continue; 18440 } 18441 18442 if (!image.node || !image.node.parentNode) { 18443 image.node = null; 18444 image.status = this.imageStatus.error; 18445 continue; 18446 } 18447 18448 var isImageVisible = true; 18449 18450 if (checkOwnVisibility && main_core.Type.isFunction(image.func)) { 18451 isImageVisible = image.func(image); 18452 } 18453 18454 if (isImageVisible === true && this.isElementVisibleOnScreen(image.node)) { 18455 if (image.type == this.imageTypes.image) { 18456 image.node.src = image.src; 18457 } else { 18458 image.node.style.backgroundImage = "url('" + image.src + "')"; 18459 } 18460 18461 image.node.dataset[image.dataSrcName] = ""; 18462 image.status = this.imageStatus.loaded; 18463 } 18464 } 18465 }, 18466 initImage: function initImage(image) { 18467 image.status = this.imageStatus.error; 18468 var node = document.getElementById(image.id); 18469 18470 if (!main_core.Type.isDomNode(node)) { 18471 return; 18472 } 18473 18474 var src = node.dataset[image.dataSrcName]; 18475 18476 if (main_core.Type.isStringFilled(src)) { 18477 image.node = node; 18478 image.src = src; 18479 image.status = this.imageStatus.inited; 18480 image.type = image.node.tagName.toLowerCase() == "img" ? this.imageTypes.image : this.imageTypes.background; 18481 } 18482 }, 18483 isElementVisibleOnScreen: function isElementVisibleOnScreen(element) { 18484 var coords = this.getElementCoords(element); 18485 var windowTop = window.pageYOffset || document.documentElement.scrollTop; 18486 var windowBottom = windowTop + document.documentElement.clientHeight; 18487 coords.bottom = coords.top + element.offsetHeight; 18488 return coords.top > windowTop && coords.top < windowBottom || // topVisible 18489 coords.bottom < windowBottom && coords.bottom > windowTop // bottomVisible 18490 ; 18491 }, 18492 isElementVisibleOn2Screens: function isElementVisibleOn2Screens(element) { 18493 var windowHeight = document.documentElement.clientHeight; 18494 var windowTop = window.pageYOffset || document.documentElement.scrollTop; 18495 var windowBottom = windowTop + windowHeight; 18496 var coords = this.getElementCoords(element); 18497 coords.bottom = coords.top + element.offsetHeight; 18498 windowTop -= windowHeight; 18499 windowBottom += windowHeight; 18500 return coords.top > windowTop && coords.top < windowBottom || // topVisible 18501 coords.bottom < windowBottom && coords.bottom > windowTop // bottomVisible 18502 ; 18503 }, 18504 getElementCoords: function getElementCoords(element) { 18505 var box = element.getBoundingClientRect(); 18506 return { 18507 originTop: box.top, 18508 originLeft: box.left, 18509 top: box.top + window.pageYOffset, 18510 left: box.left + window.pageXOffset 18511 }; 18512 }, 18513 onScroll: function onScroll() {}, 18514 clearImages: function clearImages() { 18515 this.images = []; 18516 } 18517 }; 18518 18519 exports.LazyLoad = LazyLoad; 18520 18521}((this.BX = this.BX || {}),BX)); 18522 18523 18524 18525(function (exports) { 18526 'use strict'; 18527 18528 var ParamBag = /*#__PURE__*/function () { 18529 function ParamBag() { 18530 var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 18531 babelHelpers.classCallCheck(this, ParamBag); 18532 18533 if (!!params && babelHelpers.typeof(params) === 'object') { 18534 this.params = new Map(Object.entries(params)); 18535 } else { 18536 this.params = new Map(); 18537 } 18538 } 18539 18540 babelHelpers.createClass(ParamBag, [{ 18541 key: "getParam", 18542 value: function getParam(key) { 18543 var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; 18544 18545 if (this.params.has(key)) { 18546 return this.params.get(key); 18547 } 18548 18549 return defaultValue; 18550 } 18551 }, { 18552 key: "setParam", 18553 value: function setParam(key, value) { 18554 this.params.set(key, value); 18555 } 18556 }, { 18557 key: "clear", 18558 value: function clear() { 18559 this.params.clear(); 18560 } 18561 }], [{ 18562 key: "create", 18563 value: function create() { 18564 var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 18565 return new ParamBag(params); 18566 } 18567 }]); 18568 return ParamBag; 18569 }(); 18570 18571 exports.ParamBag = ParamBag; 18572 18573}((this.BX = this.BX || {}))); 18574 18575 18576 18577(function() { 18578 BX.FixFontSize = function(params) 18579 { 18580 var widthNode, computedStyles, width; 18581 18582 this.node = null; 18583 this.prevWindowSize = 0; 18584 this.prevWrapperSize = 0; 18585 this.mainWrapper = null; 18586 this.textWrapper = null; 18587 this.objList = params.objList; 18588 this.minFontSizeList = []; 18589 this.minFontSize = 0; 18590 18591 if (params.onresize) 18592 { 18593 this.prevWindowSize = window.innerWidth || document.documentElement.clientWidth; 18594 BX.bind(window, 'resize', BX.throttle(this.onResize, 350, this)); 18595 } 18596 18597 if (params.onAdaptiveResize) 18598 { 18599 widthNode = this.objList[0].scaleBy || this.objList[0].node; 18600 computedStyles = getComputedStyle(widthNode); 18601 this.prevWrapperSize = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 18602 BX.bind(window, 'resize', BX.throttle(this.onAdaptiveResize, 350, this)); 18603 } 18604 18605 this.createTestNodes(); 18606 this.decrease(); 18607 }; 18608 18609 BX.FixFontSize.prototype = 18610 { 18611 createTestNodes: function() 18612 { 18613 this.textWrapper = BX.create('div',{ 18614 style : { 18615 display : 'inline-block', 18616 whiteSpace : 'nowrap' 18617 } 18618 }); 18619 18620 this.mainWrapper = BX.create('div',{ 18621 style : { 18622 height : 0, 18623 overflow : 'hidden' 18624 }, 18625 children : [this.textWrapper] 18626 }); 18627 18628 }, 18629 insertTestNodes: function() 18630 { 18631 document.body.appendChild(this.mainWrapper); 18632 }, 18633 removeTestNodes: function() 18634 { 18635 document.body.removeChild(this.mainWrapper); 18636 }, 18637 decrease: function() 18638 { 18639 var width, 18640 fontSize, 18641 widthNode, 18642 computedStyles; 18643 18644 this.insertTestNodes(); 18645
18646 for(var i=this.objList.length-1; i>=0; i--) 18647 { 18648 widthNode = this.objList[i].scaleBy || this.objList[i].node; 18649 computedStyles = getComputedStyle(widthNode); 18650 width = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 18651 fontSize = parseInt(getComputedStyle(this.objList[i].node)["font-size"]); 18652 18653 this.textWrapperSetStyle(this.objList[i].node); 18654 18655 if(this.textWrapperInsertText(this.objList[i].node)) 18656 { 18657 while(this.textWrapper.offsetWidth > width && fontSize > 0) 18658 { 18659 this.textWrapper.style.fontSize = --fontSize + 'px'; 18660 } 18661 18662 if(this.objList[i].smallestValue) 18663 { 18664 this.minFontSize = this.minFontSize ? Math.min(this.minFontSize, fontSize) : fontSize; 18665 18666 this.minFontSizeList.push(this.objList[i].node) 18667 } 18668 else 18669 { 18670 this.objList[i].node.style.fontSize = fontSize + 'px'; 18671 } 18672 } 18673 } 18674 18675 if(this.minFontSizeList.length > 0) 18676 this.setMinFont(); 18677 18678 this.removeTestNodes(); 18679 18680 }, 18681 increase: function() 18682 { 18683 this.insertTestNodes(); 18684 var width, 18685 fontSize, 18686 widthNode, 18687 computedStyles; 18688 18689 this.insertTestNodes(); 18690 18691 for(var i=this.objList.length-1; i>=0; i--) 18692 { 18693 widthNode = this.objList[i].scaleBy || this.objList[i].node; 18694 computedStyles = getComputedStyle(widthNode); 18695 width = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 18696 fontSize = parseInt(getComputedStyle(this.objList[i].node)["font-size"]); 18697 18698 this.textWrapperSetStyle(this.objList[i].node); 18699 18700 if(this.textWrapperInsertText(this.objList[i].node)) 18701 { 18702 while(this.textWrapper.offsetWidth < width && fontSize < this.objList[i].maxFontSize) 18703 { 18704 this.textWrapper.style.fontSize = ++fontSize + 'px'; 18705 } 18706 18707 fontSize--; 18708 18709 if(this.objList[i].smallestValue) 18710 { 18711 this.minFontSize = this.minFontSize ? Math.min(this.minFontSize, fontSize) : fontSize; 18712 18713 this.minFontSizeList.push(this.objList[i].node) 18714 } 18715 else 18716 { 18717 this.objList[i].node.style.fontSize = fontSize + 'px'; 18718 } 18719 } 18720 } 18721 18722 if(this.minFontSizeList.length > 0) 18723 this.setMinFont(); 18724 18725 this.removeTestNodes(); 18726 }, 18727 setMinFont : function() 18728 { 18729 for(var i = this.minFontSizeList.length-1; i>=0; i--) 18730 { 18731 this.minFontSizeList[i].style.fontSize = this.minFontSize + 'px'; 18732 } 18733 18734 this.minFontSize = 0; 18735 }, 18736 onResize : function() 18737 { 18738 var width = window.innerWidth || document.documentElement.clientWidth; 18739 18740 if(this.prevWindowSize > width) 18741 this.decrease(); 18742 18743 else if (this.prevWindowSize < width) 18744 this.increase(); 18745 18746 this.prevWindowSize = width; 18747 }, 18748 onAdaptiveResize : function() 18749 { 18750 var widthNode = this.objList[0].scaleBy || this.objList[0].node, 18751 computedStyles = getComputedStyle(widthNode), 18752 width = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 18753 18754 if (this.prevWrapperSize > width) 18755 this.decrease(); 18756 else if (this.prevWrapperSize < width) 18757 this.increase(); 18758 18759 this.prevWrapperSize = width; 18760 }, 18761 textWrapperInsertText : function(node) 18762 { 18763 if(node.textContent){ 18764 this.textWrapper.textContent = node.textContent; 18765 return true; 18766 } 18767 else if(node.innerText) 18768 { 18769 this.textWrapper.innerText = node.innerText; 18770 return true; 18771 } 18772 else { 18773 return false; 18774 } 18775 }, 18776 textWrapperSetStyle : function(node) 18777 { 18778 this.textWrapper.style.fontFamily = getComputedStyle(node)["font-family"]; 18779 this.textWrapper.style.fontSize = getComputedStyle(node)["font-size"]; 18780 this.textWrapper.style.fontStyle = getComputedStyle(node)["font-style"]; 18781 this.textWrapper.style.fontWeight = getComputedStyle(node)["font-weight"]; 18782 this.textWrapper.style.lineHeight = getComputedStyle(node)["line-height"]; 18783 } 18784 }; 18785 18786 BX.FixFontSize.init = function(params) 18787 { 18788 return new BX.FixFontSize(params); 18789 }; 18790})(); 18791 18792})(); 18793//# 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.