vendor: 78 bytes, lines 1-3
1/******/ (() => { // webpackBootstrap 2/******/ var __webpack_modules__ = ({ 3
vendor: 13,069 bytes, lines 4-554
4/***/ "./node_modules/@splidejs/splide-extension-auto-scroll/dist/js/splide-extension-auto-scroll.esm.js": 5/*!*********************************************************************************************************!*\ 6 !*** ./node_modules/@splidejs/splide-extension-auto-scroll/dist/js/splide-extension-auto-scroll.esm.js ***! 7 \*********************************************************************************************************/ 8/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 9 10"use strict"; 11__webpack_require__.r(__webpack_exports__); 12/* harmony export */ __webpack_require__.d(__webpack_exports__, { 13/* harmony export */ AutoScroll: () => (/* binding */ AutoScroll) 14/* harmony export */ }); 15/*! 16 * @splidejs/splide-extension-auto-scroll 17 * Version : 0.5.3 18 * License : MIT 19 * Copyright: 2022 Naotoshi Fujita 20 */ 21function empty(array) { 22 array.length = 0; 23} 24 25function slice$1(arrayLike, start, end) { 26 return Array.prototype.slice.call(arrayLike, start, end); 27} 28 29function apply$1(func) { 30 return func.bind.apply(func, [null].concat(slice$1(arguments, 1))); 31} 32 33function raf(func) { 34 return requestAnimationFrame(func); 35} 36 37function typeOf$1(type, subject) { 38 return typeof subject === type; 39} 40 41var isArray$1 = Array.isArray; 42apply$1(typeOf$1, "function"); 43apply$1(typeOf$1, "string"); 44apply$1(typeOf$1, "undefined"); 45 46function toArray$1(value) { 47 return isArray$1(value) ? value : [value]; 48} 49 50function forEach$1(values, iteratee) { 51 toArray$1(values).forEach(iteratee); 52} 53 54var ownKeys$1 = Object.keys; 55 56function forOwn$1(object, iteratee, right) { 57 if (object) { 58 var keys = ownKeys$1(object); 59 keys = right ? keys.reverse() : keys; 60 61 for (var i = 0; i < keys.length; i++) { 62 var key = keys[i]; 63 64 if (key !== "__proto__") { 65 if (iteratee(object[key], key) === false) { 66 break; 67 } 68 } 69 } 70 } 71 72 return object; 73} 74 75function assign$1(object) { 76 slice$1(arguments, 1).forEach(function (source) { 77 forOwn$1(source, function (value, key) { 78 object[key] = source[key]; 79 }); 80 }); 81 return object; 82} 83 84var min$1 = Math.min; 85 86function EventBinder() { 87 var listeners = []; 88 89 function bind(targets, events, callback, options) { 90 forEachEvent(targets, events, function (target, event, namespace) { 91 var isEventTarget = ("addEventListener" in target); 92 var remover = isEventTarget ? target.removeEventListener.bind(target, event, callback, options) : target["removeListener"].bind(target, callback); 93 isEventTarget ? target.addEventListener(event, callback, options) : target["addListener"](callback); 94 listeners.push([target, event, namespace, callback, remover]); 95 }); 96 } 97 98 function unbind(targets, events, callback) { 99 forEachEvent(targets, events, function (target, event, namespace) { 100 listeners = listeners.filter(function (listener) { 101 if (listener[0] === target && listener[1] === event && listener[2] === namespace && (!callback || listener[3] === callback)) { 102 listener[4](); 103 return false; 104 } 105 106 return true; 107 }); 108 }); 109 } 110 111 function dispatch(target, type, detail) { 112 var e; 113 var bubbles = true; 114 115 if (typeof CustomEvent === "function") { 116 e = new CustomEvent(type, { 117 bubbles: bubbles, 118 detail: detail 119 }); 120 } else { 121 e = document.createEvent("CustomEvent"); 122 e.initCustomEvent(type, bubbles, false, detail); 123 } 124 125 target.dispatchEvent(e); 126 return e; 127 } 128 129 function forEachEvent(targets, events, iteratee) { 130 forEach$1(targets, function (target) { 131 target && forEach$1(events, function (events2) { 132 events2.split(" ").forEach(function (eventNS) { 133 var fragment = eventNS.split("."); 134 iteratee(target, fragment[0], fragment[1]); 135 }); 136 }); 137 }); 138 } 139 140 function destroy() { 141 listeners.forEach(function (data) { 142 data[4](); 143 }); 144 empty(listeners); 145 } 146 147 return { 148 bind: bind, 149 unbind: unbind, 150 dispatch: dispatch, 151 destroy: destroy 152 }; 153} 154var EVENT_MOVE = "move"; 155var EVENT_MOVED = "moved"; 156var EVENT_UPDATED = "updated"; 157var EVENT_DRAG = "drag"; 158var EVENT_DRAGGED = "dragged"; 159var EVENT_SCROLL = "scroll"; 160var EVENT_SCROLLED = "scrolled"; 161var EVENT_DESTROY = "destroy"; 162 163function EventInterface(Splide2) { 164 var bus = Splide2 ? Splide2.event.bus : document.createDocumentFragment(); 165 var binder = EventBinder(); 166 167 function on(events, callback) { 168 binder.bind(bus, toArray$1(events).join(" "), function (e) { 169 callback.apply(callback, isArray$1(e.detail) ? e.detail : []); 170 }); 171 } 172 173 function emit(event) { 174 binder.dispatch(bus, event, slice$1(arguments, 1)); 175 } 176 177 if (Splide2) { 178 Splide2.event.on(EVENT_DESTROY, binder.destroy); 179 } 180 181 return assign$1(binder, { 182 bus: bus, 183 on: on, 184 off: apply$1(binder.unbind, bus), 185 emit: emit 186 }); 187} 188 189function RequestInterval(interval, onInterval, onUpdate, limit) { 190 var now = Date.now; 191 var startTime; 192 var rate = 0; 193 var id; 194 var paused = true; 195 var count = 0; 196 197 function update() { 198 if (!paused) { 199 rate = interval ? min$1((now() - startTime) / interval, 1) : 1; 200 onUpdate && onUpdate(rate); 201 202 if (rate >= 1) { 203 onInterval(); 204 startTime = now(); 205 206 if (limit && ++count >= limit) { 207 return pause(); 208 } 209 } 210 211 raf(update); 212 } 213 } 214 215 function start(resume) { 216 !resume && cancel(); 217 startTime = now() - (resume ? rate * interval : 0); 218 paused = false; 219 raf(update); 220 } 221 222 function pause() { 223 paused = true; 224 } 225 226 function rewind() { 227 startTime = now(); 228 rate = 0; 229 230 if (onUpdate) { 231 onUpdate(rate); 232 } 233 } 234 235 function cancel() { 236 id && cancelAnimationFrame(id); 237 rate = 0; 238 id = 0; 239 paused = true; 240 } 241 242 function set(time) { 243 interval = time; 244 } 245 246 function isPaused() { 247 return paused; 248 } 249 250 return { 251 start: start, 252 rewind: rewind, 253 pause: pause, 254 cancel: cancel, 255 set: set, 256 isPaused: isPaused 257 }; 258} 259 260function Throttle(func, duration) { 261 var interval; 262 263 function throttled() { 264 if (!interval) { 265 interval = RequestInterval(duration || 0, function () { 266 func(); 267 interval = null; 268 }, null, 1); 269 interval.start(); 270 } 271 } 272 273 return throttled; 274} 275var CLASS_ACTIVE = "is-active"; 276 277var SLIDE = "slide"; 278var FADE = "fade"; 279 280function slice(arrayLike, start, end) { 281 return Array.prototype.slice.call(arrayLike, start, end); 282} 283 284function apply(func) { 285 return func.bind(null, ...slice(arguments, 1)); 286} 287 288function typeOf(type, subject) { 289 return typeof subject === type; 290} 291function isObject(subject) { 292 return !isNull(subject) && typeOf("object", subject); 293} 294const isArray = Array.isArray; 295apply(typeOf, "function"); 296apply(typeOf, "string"); 297const isUndefined = apply(typeOf, "undefined"); 298function isNull(subject) { 299 return subject === null; 300} 301 302function toArray(value) { 303 return isArray(value) ? value : [value]; 304} 305 306function forEach(values, iteratee) { 307 toArray(values).forEach(iteratee); 308} 309 310function toggleClass(elm, classes, add) { 311 if (elm) { 312 forEach(classes, (name) => { 313 if (name) { 314 elm.classList[add ? "add" : "remove"](name); 315 } 316 }); 317 } 318} 319 320const ownKeys = Object.keys; 321 322function forOwn(object, iteratee, right) { 323 if (object) { 324 let keys = ownKeys(object); 325 keys = right ? keys.reverse() : keys; 326 for (let i = 0; i < keys.length; i++) { 327 const key = keys[i]; 328 if (key !== "__proto__") { 329 if (iteratee(object[key], key) === false) { 330 break; 331 } 332 } 333 } 334 } 335 return object; 336} 337 338function assign(object) { 339 slice(arguments, 1).forEach((source) => { 340 forOwn(source, (value, key) => { 341 object[key] = source[key]; 342 }); 343 }); 344 return object; 345} 346 347function removeAttribute(elms, attrs) { 348 forEach(elms, (elm) => { 349 forEach(attrs, (attr) => { 350 elm && elm.removeAttribute(attr); 351 }); 352 }); 353} 354 355function setAttribute(elms, attrs, value) { 356 if (isObject(attrs)) { 357 forOwn(attrs, (value2, name) => { 358 setAttribute(elms, name, value2); 359 }); 360 } else { 361 forEach(elms, (elm) => { 362 isNull(value) || value === "" ? removeAttribute(elm, attrs) : elm.setAttribute(attrs, String(value)); 363 }); 364 } 365} 366 367const { min, max, floor, ceil, abs } = Math; 368 369function clamp(number, x, y) { 370 const minimum = min(x, y); 371 const maximum = max(x, y); 372 return min(max(minimum, number), maximum); 373} 374 375const DEFAULTS = { 376 speed: 1, 377 autoStart: true, 378 pauseOnHover: true, 379 pauseOnFocus: true 380}; 381 382const I18N = { 383 startScroll: "Start auto scroll", 384 pauseScroll: "Pause auto scroll" 385}; 386 387function AutoScroll(Splide2, Components2, options) { 388 const { on, off, bind, unbind } = EventInterface(Splide2); 389 const { translate, getPosition, toIndex, getLimit } = Components2.Move; 390 const { setIndex, getIndex } = Components2.Controller; 391 const { orient } = Components2.Direction; 392 const { toggle } = Components2.Elements; 393 const { Live } = Components2; 394 const { root } = Splide2; 395 const throttledUpdateArrows = Throttle(Components2.Arrows.update, 500); 396 let autoScrollOptions = {}; 397 let interval; 398 let stopped; 399 let hovered; 400 let focused; 401 let busy; 402 let currPosition; 403 function setup() { 404 const { autoScroll } = options; 405 autoScrollOptions = assign({}, DEFAULTS, isObject(autoScroll) ? autoScroll : {}); 406 } 407 function mount() { 408 if (!Splide2.is(FADE)) { 409 if (!interval && options.autoScroll !== false) { 410 interval = RequestInterval(0, move); 411 listen(); 412 autoStart(); 413 } 414 } 415 } 416 function destroy() { 417 if (interval) { 418 interval.cancel(); 419 interval = null; 420 currPosition = void 0; 421 off([EVENT_MOVE, EVENT_DRAG, EVENT_SCROLL, EVENT_MOVED, EVENT_SCROLLED]); 422 unbind(root, "mouseenter mouseleave focusin focusout"); 423 unbind(toggle, "click"); 424 } 425 } 426 function listen() { 427 if (autoScrollOptions.pauseOnHover) { 428 bind(root, "mouseenter mouseleave", (e) => { 429 hovered = e.type === "mouseenter"; 430 autoToggle(); 431 }); 432 } 433 if (autoScrollOptions.pauseOnFocus) { 434 bind(root, "focusin focusout", (e) => { 435 focused = e.type === "focusin"; 436 autoToggle(); 437 }); 438 } 439 if (autoScrollOptions.useToggleButton) { 440 bind(toggle, "click", () => { 441 stopped ? play() : pause(); 442 }); 443 } 444 on(EVENT_UPDATED, update); 445 on([EVENT_MOVE, EVENT_DRAG, EVENT_SCROLL], () => { 446 busy = true; 447 pause(false); 448 }); 449 on([EVENT_MOVED, EVENT_DRAGGED, EVENT_SCROLLED], () => { 450 busy = false; 451 autoToggle(); 452 }); 453 } 454 function update() { 455 const { autoScroll } = options; 456 if (autoScroll !== false) { 457 autoScrollOptions = assign({}, autoScrollOptions, isObject(autoScroll) ? autoScroll : {}); 458 mount(); 459 } else { 460 destroy(); 461 } 462 if (interval && !isUndefined(currPosition)) { 463 translate(currPosition); 464 } 465 } 466 function autoStart() { 467 if (autoScrollOptions.autoStart) { 468 if (document.readyState === "complete") { 469 play(); 470 } else { 471 bind(window, "load", play); 472 } 473 } 474 } 475 function play() { 476 if (isPaused()) { 477 interval.start(true); 478 Live.disable(true); 479 focused = hovered = stopped = false; 480 updateButton(); 481 } 482 } 483 function pause(stop = true) { 484 if (!stopped) { 485 stopped = stop; 486 updateButton(); 487 if (!isPaused()) { 488 interval.pause(); 489 Live.disable(false); 490 } 491 } 492 } 493 function autoToggle() { 494 if (!stopped) { 495 hovered || focused || busy ? pause(false) : play(); 496 } 497 } 498 function move() { 499 const position = getPosition(); 500 const destination = computeDestination(position); 501 if (position !== destination) { 502 translate(destination); 503 updateIndex(currPosition = getPosition()); 504 } else { 505 pause(false); 506 if (autoScrollOptions.rewind) { 507 Splide2.go(autoScrollOptions.speed > 0 ? 0 : Components2.Controller.getEnd()); 508 } 509 } 510 throttledUpdateArrows(); 511 } 512 function computeDestination(position) { 513 const speed = autoScrollOptions.speed || 1; 514 position += orient(speed); 515 if (Splide2.is(SLIDE)) { 516 position = clamp(position, getLimit(false), getLimit(true)); 517 } 518 return position; 519 } 520 function updateIndex(position) { 521 const { length } = Splide2; 522 const index = (toIndex(position) + length) % length; 523 if (index !== getIndex()) { 524 setIndex(index); 525 Components2.Slides.update(); 526 Components2.Pagination.update(); 527 options.lazyLoad === "nearby" && Components2.LazyLoad.check(); 528 } 529 } 530 function updateButton() { 531 if (toggle) { 532 const key = stopped ? "startScroll" : "pauseScroll"; 533 toggleClass(toggle, CLASS_ACTIVE, !stopped); 534 setAttribute(toggle, "aria-label", options.i18n[key] || I18N[key]); 535 } 536 } 537 function isPaused() { 538 return !interval || interval.isPaused(); 539 } 540 return { 541 setup, 542 mount, 543 destroy, 544 play, 545 pause, 546 isPaused 547 }; 548} 549 550 551 552 553/***/ }), 554
vendor: 15,396 bytes, lines 555-1154
555/***/ "./node_modules/@splidejs/splide-extension-grid/dist/js/splide-extension-grid.esm.js": 556/*!*******************************************************************************************!*\ 557 !*** ./node_modules/@splidejs/splide-extension-grid/dist/js/splide-extension-grid.esm.js ***! 558 \*******************************************************************************************/ 559/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 560 561"use strict"; 562__webpack_require__.r(__webpack_exports__); 563/* harmony export */ __webpack_require__.d(__webpack_exports__, { 564/* harmony export */ Grid: () => (/* binding */ Grid) 565/* harmony export */ }); 566/*! 567 * @splidejs/splide-extension-grid 568 * Version : 0.4.1 569 * License : MIT 570 * Copyright: 2022 Naotoshi Fujita 571 */ 572function empty$1(array) { 573 array.length = 0; 574} 575 576function slice$1(arrayLike, start, end) { 577 return Array.prototype.slice.call(arrayLike, start, end); 578} 579 580function apply$1(func) { 581 return func.bind.apply(func, [null].concat(slice$1(arguments, 1))); 582} 583 584function typeOf$1(type, subject) { 585 return typeof subject === type; 586} 587 588var isArray$1 = Array.isArray; 589apply$1(typeOf$1, "function"); 590apply$1(typeOf$1, "string"); 591apply$1(typeOf$1, "undefined"); 592 593function toArray$1(value) { 594 return isArray$1(value) ? value : [value]; 595} 596 597function forEach$1(values, iteratee) { 598 toArray$1(values).forEach(iteratee); 599} 600 601var ownKeys$1 = Object.keys; 602 603function forOwn$1(object, iteratee, right) { 604 if (object) { 605 var keys = ownKeys$1(object); 606 keys = right ? keys.reverse() : keys; 607 608 for (var i = 0; i < keys.length; i++) { 609 var key = keys[i]; 610 611 if (key !== "__proto__") { 612 if (iteratee(object[key], key) === false) { 613 break; 614 } 615 } 616 } 617 } 618 619 return object; 620} 621 622function assign$1(object) { 623 slice$1(arguments, 1).forEach(function (source) { 624 forOwn$1(source, function (value, key) { 625 object[key] = source[key]; 626 }); 627 }); 628 return object; 629} 630 631var PROJECT_CODE$1 = "splide"; 632 633function EventBinder() { 634 var listeners = []; 635 636 function bind(targets, events, callback, options) { 637 forEachEvent(targets, events, function (target, event, namespace) { 638 var isEventTarget = ("addEventListener" in target); 639 var remover = isEventTarget ? target.removeEventListener.bind(target, event, callback, options) : target["removeListener"].bind(target, callback); 640 isEventTarget ? target.addEventListener(event, callback, options) : target["addListener"](callback); 641 listeners.push([target, event, namespace, callback, remover]); 642 }); 643 } 644 645 function unbind(targets, events, callback) { 646 forEachEvent(targets, events, function (target, event, namespace) { 647 listeners = listeners.filter(function (listener) { 648 if (listener[0] === target && listener[1] === event && listener[2] === namespace && (!callback || listener[3] === callback)) { 649 listener[4](); 650 return false; 651 } 652 653 return true; 654 }); 655 }); 656 } 657 658 function dispatch(target, type, detail) { 659 var e; 660 var bubbles = true; 661 662 if (typeof CustomEvent === "function") { 663 e = new CustomEvent(type, { 664 bubbles: bubbles, 665 detail: detail 666 }); 667 } else { 668 e = document.createEvent("CustomEvent"); 669 e.initCustomEvent(type, bubbles, false, detail); 670 } 671 672 target.dispatchEvent(e); 673 return e; 674 } 675 676 function forEachEvent(targets, events, iteratee) { 677 forEach$1(targets, function (target) { 678 target && forEach$1(events, function (events2) { 679 events2.split(" ").forEach(function (eventNS) { 680 var fragment = eventNS.split("."); 681 iteratee(target, fragment[0], fragment[1]); 682 }); 683 }); 684 }); 685 } 686 687 function destroy() { 688 listeners.forEach(function (data) { 689 data[4](); 690 }); 691 empty$1(listeners); 692 } 693 694 return { 695 bind: bind, 696 unbind: unbind, 697 dispatch: dispatch, 698 destroy: destroy 699 }; 700} 701var EVENT_VISIBLE = "visible"; 702var EVENT_HIDDEN = "hidden"; 703var EVENT_REFRESH = "refresh"; 704var EVENT_UPDATED = "updated"; 705var EVENT_DESTROY = "destroy"; 706 707function EventInterface(Splide2) { 708 var bus = Splide2 ? Splide2.event.bus : document.createDocumentFragment(); 709 var binder = EventBinder(); 710 711 function on(events, callback) { 712 binder.bind(bus, toArray$1(events).join(" "), function (e) { 713 callback.apply(callback, isArray$1(e.detail) ? e.detail : []); 714 }); 715 } 716 717 function emit(event) { 718 binder.dispatch(bus, event, slice$1(arguments, 1)); 719 } 720 721 if (Splide2) { 722 Splide2.event.on(EVENT_DESTROY, binder.destroy); 723 } 724 725 return assign$1(binder, { 726 bus: bus, 727 on: on, 728 off: apply$1(binder.unbind, bus), 729 emit: emit 730 }); 731} 732var CLASS_ROOT = PROJECT_CODE$1; 733var CLASS_SLIDE = PROJECT_CODE$1 + "__slide"; 734var CLASS_CONTAINER = CLASS_SLIDE + "__container"; 735 736function empty(array) { 737 array.length = 0; 738} 739 740function slice(arrayLike, start, end) { 741 return Array.prototype.slice.call(arrayLike, start, end); 742} 743 744function apply(func) { 745 return func.bind(null, ...slice(arguments, 1)); 746} 747 748function typeOf(type, subject) { 749 return typeof subject === type; 750} 751function isObject(subject) { 752 return !isNull(subject) && typeOf("object", subject); 753} 754const isArray = Array.isArray; 755apply(typeOf, "function"); 756const isString = apply(typeOf, "string"); 757const isUndefined = apply(typeOf, "undefined"); 758function isNull(subject) { 759 return subject === null; 760} 761function isHTMLElement(subject) { 762 return subject instanceof HTMLElement; 763} 764 765function toArray(value) { 766 return isArray(value) ? value : [value]; 767} 768 769function forEach(values, iteratee) { 770 toArray(values).forEach(iteratee); 771} 772 773function push(array, items) { 774 array.push(...toArray(items)); 775 return array; 776} 777 778function toggleClass(elm, classes, add) { 779 if (elm) { 780 forEach(classes, (name) => { 781 if (name) { 782 elm.classList[add ? "add" : "remove"](name); 783 } 784 }); 785 } 786} 787 788function addClass(elm, classes) { 789 toggleClass(elm, isString(classes) ? classes.split(" ") : classes, true); 790} 791 792function append(parent, children) { 793 forEach(children, parent.appendChild.bind(parent)); 794} 795 796function matches(elm, selector) { 797 return isHTMLElement(elm) && (elm["msMatchesSelector"] || elm.matches).call(elm, selector); 798} 799 800function children(parent, selector) { 801 const children2 = parent ? slice(parent.children) : []; 802 return selector ? children2.filter((child) => matches(child, selector)) : children2; 803} 804 805function child(parent, selector) { 806 return selector ? children(parent, selector)[0] : parent.firstElementChild; 807} 808 809const ownKeys = Object.keys; 810 811function forOwn(object, iteratee, right) { 812 if (object) { 813 let keys = ownKeys(object); 814 keys = right ? keys.reverse() : keys; 815 for (let i = 0; i < keys.length; i++) { 816 const key = keys[i]; 817 if (key !== "__proto__") { 818 if (iteratee(object[key], key) === false) { 819 break; 820 } 821 } 822 } 823 } 824 return object; 825} 826 827function assign(object) { 828 slice(arguments, 1).forEach((source) => { 829 forOwn(source, (value, key) => { 830 object[key] = source[key]; 831 }); 832 }); 833 return object; 834} 835 836function omit(object, keys) { 837 toArray(keys || ownKeys(object)).forEach((key) => { 838 delete object[key]; 839 }); 840} 841 842function removeAttribute(elms, attrs) { 843 forEach(elms, (elm) => { 844 forEach(attrs, (attr) => { 845 elm && elm.removeAttribute(attr); 846 }); 847 }); 848} 849 850function setAttribute(elms, attrs, value) { 851 if (isObject(attrs)) { 852 forOwn(attrs, (value2, name) => { 853 setAttribute(elms, name, value2); 854 }); 855 } else { 856 forEach(elms, (elm) => { 857 isNull(value) || value === "" ? removeAttribute(elm, attrs) : elm.setAttribute(attrs, String(value)); 858 }); 859 } 860} 861 862function create(tag, attrs, parent) { 863 const elm = document.createElement(tag); 864 if (attrs) { 865 isString(attrs) ? addClass(elm, attrs) : setAttribute(elm, attrs); 866 } 867 parent && append(parent, elm); 868 return elm; 869} 870 871function style(elm, prop, value) { 872 if (isUndefined(value)) { 873 return getComputedStyle(elm)[prop]; 874 } 875 if (!isNull(value)) { 876 elm.style[prop] = `${value}`; 877 } 878} 879 880function hasClass(elm, className) { 881 return elm && elm.classList.contains(className); 882} 883 884function remove(nodes) { 885 forEach(nodes, (node) => { 886 if (node && node.parentNode) { 887 node.parentNode.removeChild(node); 888 } 889 }); 890} 891 892function queryAll(parent, selector) { 893 return selector ? slice(parent.querySelectorAll(selector)) : []; 894} 895 896function removeClass(elm, classes) { 897 toggleClass(elm, classes, false); 898} 899 900function unit(value) { 901 return isString(value) ? value : value ? `${value}px` : ""; 902} 903 904const PROJECT_CODE = "splide"; 905 906function assert(condition, message) { 907 if (!condition) { 908 throw new Error(`[${PROJECT_CODE}] ${message || ""}`); 909 } 910} 911 912const { min, max, floor, ceil, abs } = Math; 913 914function pad(number) { 915 return number < 10 ? `0${number}` : `${number}`; 916} 917 918const CLASS_SLIDE_ROW = `${CLASS_SLIDE}__row`; 919const CLASS_SLIDE_COL = `${CLASS_SLIDE}--col`; 920 921const DEFAULTS = { 922 rows: 1, 923 cols: 1, 924 dimensions: [], 925 gap: {} 926}; 927 928function Dimension(options) { 929 function normalize() { 930 const { rows, cols, dimensions } = options; 931 return isArray(dimensions) && dimensions.length ? dimensions : [[rows, cols]]; 932 } 933 function get(index) { 934 const dimensions = normalize(); 935 return dimensions[min(index, dimensions.length - 1)]; 936 } 937 function getAt(index) { 938 const dimensions = normalize(); 939 let rows, cols, aggregator = 0; 940 for (let i = 0; i < dimensions.length; i++) { 941 const dimension = dimensions[i]; 942 rows = dimension[0] || 1; 943 cols = dimension[1] || 1; 944 aggregator += rows * cols; 945 if (index < aggregator) { 946 break; 947 } 948 } 949 assert(rows && cols, "Invalid dimension"); 950 return [rows, cols]; 951 } 952 return { 953 get, 954 getAt 955 }; 956} 957 958function Layout(Splide2, gridOptions, Dimension) { 959 const { on, destroy: destroyEvent } = EventInterface(Splide2); 960 const { Components, options } = Splide2; 961 const { resolve } = Components.Direction; 962 const { forEach } = Components.Slides; 963 function mount() { 964 layout(); 965 if (options.slideFocus) { 966 on(EVENT_VISIBLE, onVisible); 967 on(EVENT_HIDDEN, onHidden); 968 } 969 } 970 function destroy() { 971 forEach((Slide) => { 972 const { slide } = Slide; 973 toggleTabIndex(slide, false); 974 getRowsIn(slide).forEach((cell) => { 975 removeAttribute(cell, "style"); 976 }); 977 getColsIn(slide).forEach((colSlide) => { 978 cover(colSlide, true); 979 removeAttribute(colSlide, "style"); 980 }); 981 }); 982 destroyEvent(); 983 } 984 function layout() { 985 forEach((Slide) => { 986 const { slide } = Slide; 987 const [rows, cols] = Dimension.get(Slide.isClone ? Slide.slideIndex : Slide.index); 988 layoutRow(rows, slide); 989 layoutCol(cols, slide); 990 getColsIn(Slide.slide).forEach((colSlide, index) => { 991 colSlide.id = `${Slide.slide.id}-col${pad(index + 1)}`; 992 if (Splide2.options.cover) { 993 cover(colSlide); 994 } 995 }); 996 }); 997 } 998 function layoutRow(rows, slide) { 999 const { row: rowGap } = gridOptions.gap; 1000 const height = `calc(${100 / rows}%${rowGap ? ` - ${unit(rowGap)} * ${(rows - 1) / rows}` : ""})`; 1001 getRowsIn(slide).forEach((rowElm, index, rowElms) => { 1002 style(rowElm, "height", height); 1003 style(rowElm, "display", "flex"); 1004 style(rowElm, "margin", `0 0 ${unit(rowGap)} 0`); 1005 style(rowElm, "padding", 0); 1006 if (index === rowElms.length - 1) { 1007 style(rowElm, "marginBottom", 0); 1008 } 1009 }); 1010 } 1011 function layoutCol(cols, slide) { 1012 const { col: colGap } = gridOptions.gap; 1013 const width = `calc(${100 / cols}%${colGap ? ` - ${unit(colGap)} * ${(cols - 1) / cols}` : ""})`; 1014 getColsIn(slide).forEach((colElm, index, colElms) => { 1015 style(colElm, "width", width); 1016 if (index !== colElms.length - 1) { 1017 style(colElm, resolve("marginRight"), unit(colGap)); 1018 } 1019 }); 1020 } 1021 function cover(colSlide, uncover) { 1022 const container = child(colSlide, `.${CLASS_CONTAINER}`); 1023 const img = child(container || colSlide, "img"); 1024 if (img && img.src) { 1025 style(container || colSlide, "background", uncover ? "" : `center/cover no-repeat url("${img.src}")`); 1026 style(img, "display", uncover ? "" : "none"); 1027 } 1028 } 1029 function getRowsIn(slide) { 1030 return queryAll(slide, `.${CLASS_SLIDE_ROW}`); 1031 } 1032 function getColsIn(slide) { 1033 return queryAll(slide, `.${CLASS_SLIDE_COL}`); 1034 } 1035 function toggleTabIndex(slide, add) { 1036 getColsIn(slide).forEach((colSlide) => { 1037 setAttribute(colSlide, "tabindex", add ? 0 : null); 1038 }); 1039 } 1040 function onVisible(Slide) { 1041 toggleTabIndex(Slide.slide, true); 1042 } 1043 function onHidden(Slide) { 1044 toggleTabIndex(Slide.slide, false); 1045 } 1046 return { 1047 mount, 1048 destroy 1049 }; 1050} 1051 1052function Grid(Splide2, Components2, options) { 1053 const { on, off } = EventInterface(Splide2); 1054 const { Elements } = Components2; 1055 const gridOptions = {}; 1056 const Dimension$1 = Dimension(gridOptions); 1057 const Layout$1 = Layout(Splide2, gridOptions, Dimension$1); 1058 const modifier = `${CLASS_ROOT}--grid`; 1059 const originalSlides = []; 1060 function mount() { 1061 init(); 1062 on(EVENT_UPDATED, init); 1063 } 1064 function init() { 1065 omit(gridOptions); 1066 assign(gridOptions, DEFAULTS, options.grid || {}); 1067 if (shouldBuild()) { 1068 destroy(); 1069 push(originalSlides, Elements.slides); 1070 addClass(Splide2.root, modifier); 1071 append(Elements.list, build()); 1072 off(EVENT_REFRESH); 1073 on(EVENT_REFRESH, layout); 1074 refresh(); 1075 } else if (isActive()) { 1076 destroy(); 1077 refresh(); 1078 } 1079 } 1080 function destroy() { 1081 if (isActive()) { 1082 const { slides } = Elements; 1083 Layout$1.destroy(); 1084 originalSlides.forEach((slide) => { 1085 removeClass(slide, CLASS_SLIDE_COL); 1086 append(Elements.list, slide); 1087 }); 1088 remove(slides); 1089 removeClass(Splide2.root, modifier); 1090 empty(slides); 1091 push(slides, originalSlides); 1092 empty(originalSlides); 1093 off(EVENT_REFRESH); 1094 } 1095 } 1096 function refresh() { 1097 Splide2.refresh(); 1098 } 1099 function layout() { 1100 if (isActive()) { 1101 Layout$1.mount(); 1102 } 1103 } 1104 function build() { 1105 const outerSlides = []; 1106 let row = 0, col = 0; 1107 let outerSlide, rowSlide; 1108 originalSlides.forEach((slide, index) => { 1109 const [rows, cols] = Dimension$1.getAt(index); 1110 if (!col) { 1111 if (!row) { 1112 outerSlide = create(slide.tagName, CLASS_SLIDE); 1113 outerSlides.push(outerSlide); 1114 } 1115 rowSlide = buildRow(rows, slide, outerSlide); 1116 } 1117 buildCol(cols, slide, rowSlide); 1118 if (++col >= cols) { 1119 col = 0; 1120 row = ++row >= rows ? 0 : row; 1121 } 1122 }); 1123 return outerSlides; 1124 } 1125 function buildRow(rows, slide, outerSlide) { 1126 const tag = slide.tagName.toLowerCase() === "li" ? "ul" : "div"; 1127 return create(tag, CLASS_SLIDE_ROW, outerSlide); 1128 } 1129 function buildCol(cols, slide, rowSlide) { 1130 addClass(slide, CLASS_SLIDE_COL); 1131 append(rowSlide, slide); 1132 return slide; 1133 } 1134 function shouldBuild() { 1135 if (options.grid) { 1136 const { rows, cols, dimensions } = gridOptions; 1137 return rows > 1 || cols > 1 || isArray(dimensions) && dimensions.length > 0; 1138 } 1139 return false; 1140 } 1141 function isActive() { 1142 return hasClass(Splide2.root, modifier); 1143 } 1144 return { 1145 mount, 1146 destroy 1147 }; 1148} 1149 1150 1151 1152 1153/***/ }), 1154
vendor: 102,060 bytes, lines 1155-4920
1155/***/ "./node_modules/@splidejs/splide/dist/js/splide.esm.js": 1156/*!*************************************************************!*\ 1157 !*** ./node_modules/@splidejs/splide/dist/js/splide.esm.js ***! 1158 \*************************************************************/ 1159/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 1160 1161"use strict"; 1162__webpack_require__.r(__webpack_exports__); 1163/* harmony export */ __webpack_require__.d(__webpack_exports__, { 1164/* harmony export */ CLASSES: () => (/* binding */ CLASSES), 1165/* harmony export */ CLASS_ACTIVE: () => (/* binding */ CLASS_ACTIVE), 1166/* harmony export */ CLASS_ARROW: () => (/* binding */ CLASS_ARROW), 1167/* harmony export */ CLASS_ARROWS: () => (/* binding */ CLASS_ARROWS), 1168/* harmony export */ CLASS_ARROW_NEXT: () => (/* binding */ CLASS_ARROW_NEXT), 1169/* harmony export */ CLASS_ARROW_PREV: () => (/* binding */ CLASS_ARROW_PREV), 1170/* harmony export */ CLASS_CLONE: () => (/* binding */ CLASS_CLONE), 1171/* harmony export */ CLASS_CONTAINER: () => (/* binding */ CLASS_CONTAINER), 1172/* harmony export */ CLASS_FOCUS_IN: () => (/* binding */ CLASS_FOCUS_IN), 1173/* harmony export */ CLASS_INITIALIZED: () => (/* binding */ CLASS_INITIALIZED), 1174/* harmony export */ CLASS_LIST: () => (/* binding */ CLASS_LIST), 1175/* harmony export */ CLASS_LOADING: () => (/* binding */ CLASS_LOADING), 1176/* harmony export */ CLASS_NEXT: () => (/* binding */ CLASS_NEXT), 1177/* harmony export */ CLASS_OVERFLOW: () => (/* binding */ CLASS_OVERFLOW), 1178/* harmony export */ CLASS_PAGINATION: () => (/* binding */ CLASS_PAGINATION), 1179/* harmony export */ CLASS_PAGINATION_PAGE: () => (/* binding */ CLASS_PAGINATION_PAGE), 1180/* harmony export */ CLASS_PREV: () => (/* binding */ CLASS_PREV), 1181/* harmony export */ CLASS_PROGRESS: () => (/* binding */ CLASS_PROGRESS), 1182/* harmony export */ CLASS_PROGRESS_BAR: () => (/* binding */ CLASS_PROGRESS_BAR), 1183/* harmony export */ CLASS_ROOT: () => (/* binding */ CLASS_ROOT), 1184/* harmony export */ CLASS_SLIDE: () => (/* binding */ CLASS_SLIDE), 1185/* harmony export */ CLASS_SPINNER: () => (/* binding */ CLASS_SPINNER), 1186/* harmony export */ CLASS_SR: () => (/* binding */ CLASS_SR), 1187/* harmony export */ CLASS_TOGGLE: () => (/* binding */ CLASS_TOGGLE), 1188/* harmony export */ CLASS_TOGGLE_PAUSE: () => (/* binding */ CLASS_TOGGLE_PAUSE), 1189/* harmony export */ CLASS_TOGGLE_PLAY: () => (/* binding */ CLASS_TOGGLE_PLAY), 1190/* harmony export */ CLASS_TRACK: () => (/* binding */ CLASS_TRACK), 1191/* harmony export */ CLASS_VISIBLE: () => (/* binding */ CLASS_VISIBLE), 1192/* harmony export */ DEFAULTS: () => (/* binding */ DEFAULTS), 1193/* harmony export */ EVENT_ACTIVE: () => (/* binding */ EVENT_ACTIVE), 1194/* harmony export */ EVENT_ARROWS_MOUNTED: () => (/* binding */ EVENT_ARROWS_MOUNTED), 1195/* harmony export */ EVENT_ARROWS_UPDATED: () => (/* binding */ EVENT_ARROWS_UPDATED), 1196/* harmony export */ EVENT_AUTOPLAY_PAUSE: () => (/* binding */ EVENT_AUTOPLAY_PAUSE), 1197/* harmony export */ EVENT_AUTOPLAY_PLAY: () => (/* binding */ EVENT_AUTOPLAY_PLAY), 1198/* harmony export */ EVENT_AUTOPLAY_PLAYING: () => (/* binding */ EVENT_AUTOPLAY_PLAYING), 1199/* harmony export */ EVENT_CLICK: () => (/* binding */ EVENT_CLICK), 1200/* harmony export */ EVENT_DESTROY: () => (/* binding */ EVENT_DESTROY), 1201/* harmony export */ EVENT_DRAG: () => (/* binding */ EVENT_DRAG), 1202/* harmony export */ EVENT_DRAGGED: () => (/* binding */ EVENT_DRAGGED), 1203/* harmony export */ EVENT_DRAGGING: () => (/* binding */ EVENT_DRAGGING), 1204/* harmony export */ EVENT_END_INDEX_CHANGED: () => (/* binding */ EVENT_END_INDEX_CHANGED), 1205/* harmony export */ EVENT_HIDDEN: () => (/* binding */ EVENT_HIDDEN), 1206/* harmony export */ EVENT_INACTIVE: () => (/* binding */ EVENT_INACTIVE), 1207/* harmony export */ EVENT_LAZYLOAD_LOADED: () => (/* binding */ EVENT_LAZYLOAD_LOADED), 1208/* harmony export */ EVENT_MOUNTED: () => (/* binding */ EVENT_MOUNTED), 1209/* harmony export */ EVENT_MOVE: () => (/* binding */ EVENT_MOVE), 1210/* harmony export */ EVENT_MOVED: () => (/* binding */ EVENT_MOVED), 1211/* harmony export */ EVENT_NAVIGATION_MOUNTED: () => (/* binding */ EVENT_NAVIGATION_MOUNTED), 1212/* harmony export */ EVENT_OVERFLOW: () => (/* binding */ EVENT_OVERFLOW), 1213/* harmony export */ EVENT_PAGINATION_MOUNTED: () => (/* binding */ EVENT_PAGINATION_MOUNTED), 1214/* harmony export */ EVENT_PAGINATION_UPDATED: () => (/* binding */ EVENT_PAGINATION_UPDATED), 1215/* harmony export */ EVENT_READY: () => (/* binding */ EVENT_READY), 1216/* harmony export */ EVENT_REFRESH: () => (/* binding */ EVENT_REFRESH), 1217/* harmony export */ EVENT_RESIZE: () => (/* binding */ EVENT_RESIZE), 1218/* harmony export */ EVENT_RESIZED: () => (/* binding */ EVENT_RESIZED), 1219/* harmony export */ EVENT_SCROLL: () => (/* binding */ EVENT_SCROLL), 1220/* harmony export */ EVENT_SCROLLED: () => (/* binding */ EVENT_SCROLLED), 1221/* harmony export */ EVENT_SHIFTED: () => (/* binding */ EVENT_SHIFTED), 1222/* harmony export */ EVENT_SLIDE_KEYDOWN: () => (/* binding */ EVENT_SLIDE_KEYDOWN), 1223/* harmony export */ EVENT_UPDATED: () => (/* binding */ EVENT_UPDATED), 1224/* harmony export */ EVENT_VISIBLE: () => (/* binding */ EVENT_VISIBLE), 1225/* harmony export */ EventBinder: () => (/* binding */ EventBinder), 1226/* harmony export */ EventInterface: () => (/* binding */ EventInterface), 1227/* harmony export */ FADE: () => (/* binding */ FADE), 1228/* harmony export */ LOOP: () => (/* binding */ LOOP), 1229/* harmony export */ LTR: () => (/* binding */ LTR), 1230/* harmony export */ RTL: () => (/* binding */ RTL), 1231/* harmony export */ RequestInterval: () => (/* binding */ RequestInterval), 1232/* harmony export */ SLIDE: () => (/* binding */ SLIDE), 1233/* harmony export */ STATUS_CLASSES: () => (/* binding */ STATUS_CLASSES), 1234/* harmony export */ Splide: () => (/* binding */ Splide), 1235/* harmony export */ SplideRenderer: () => (/* binding */ SplideRenderer), 1236/* harmony export */ State: () => (/* binding */ State), 1237/* harmony export */ TTB: () => (/* binding */ TTB), 1238/* harmony export */ Throttle: () => (/* binding */ Throttle), 1239/* harmony export */ "default": () => (/* binding */ Splide) 1240/* harmony export */ }); 1241function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } 1242 1243function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 1244 1245/*! 1246 * Splide.js 1247 * Version : 4.1.4 1248 * License : MIT 1249 * Copyright: 2022 Naotoshi Fujita 1250 */ 1251var MEDIA_PREFERS_REDUCED_MOTION = "(prefers-reduced-motion: reduce)"; 1252var CREATED = 1; 1253var MOUNTED = 2; 1254var IDLE = 3; 1255var MOVING = 4; 1256var SCROLLING = 5; 1257var DRAGGING = 6; 1258var DESTROYED = 7; 1259var STATES = { 1260 CREATED: CREATED, 1261 MOUNTED: MOUNTED, 1262 IDLE: IDLE, 1263 MOVING: MOVING, 1264 SCROLLING: SCROLLING, 1265 DRAGGING: DRAGGING, 1266 DESTROYED: DESTROYED 1267}; 1268 1269function empty(array) { 1270 array.length = 0; 1271} 1272 1273function slice(arrayLike, start, end) { 1274 return Array.prototype.slice.call(arrayLike, start, end); 1275} 1276 1277function apply(func) { 1278 return func.bind.apply(func, [null].concat(slice(arguments, 1))); 1279} 1280 1281var nextTick = setTimeout; 1282 1283var noop = function noop() {}; 1284 1285function raf(func) { 1286 return requestAnimationFrame(func); 1287} 1288 1289function typeOf(type, subject) { 1290 return typeof subject === type; 1291} 1292 1293function isObject(subject) { 1294 return !isNull(subject) && typeOf("object", subject); 1295} 1296 1297var isArray = Array.isArray; 1298var isFunction = apply(typeOf, "function"); 1299var isString = apply(typeOf, "string"); 1300var isUndefined = apply(typeOf, "undefined"); 1301 1302function isNull(subject) { 1303 return subject === null; 1304} 1305 1306function isHTMLElement(subject) { 1307 try { 1308 return subject instanceof (subject.ownerDocument.defaultView || window).HTMLElement; 1309 } catch (e) { 1310 return false; 1311 } 1312} 1313 1314function toArray(value) { 1315 return isArray(value) ? value : [value]; 1316} 1317 1318function forEach(values, iteratee) { 1319 toArray(values).forEach(iteratee); 1320} 1321 1322function includes(array, value) { 1323 return array.indexOf(value) > -1; 1324} 1325 1326function push(array, items) { 1327 array.push.apply(array, toArray(items)); 1328 return array; 1329} 1330 1331function toggleClass(elm, classes, add) { 1332 if (elm) { 1333 forEach(classes, function (name) { 1334 if (name) { 1335 elm.classList[add ? "add" : "remove"](name); 1336 } 1337 }); 1338 } 1339} 1340 1341function addClass(elm, classes) { 1342 toggleClass(elm, isString(classes) ? classes.split(" ") : classes, true); 1343} 1344 1345function append(parent, children) { 1346 forEach(children, parent.appendChild.bind(parent)); 1347} 1348 1349function before(nodes, ref) { 1350 forEach(nodes, function (node) { 1351 var parent = (ref || node).parentNode; 1352 1353 if (parent) { 1354 parent.insertBefore(node, ref); 1355 } 1356 }); 1357} 1358 1359function matches(elm, selector) { 1360 return isHTMLElement(elm) && (elm["msMatchesSelector"] || elm.matches).call(elm, selector); 1361} 1362 1363function children(parent, selector) { 1364 var children2 = parent ? slice(parent.children) : []; 1365 return selector ? children2.filter(function (child) { 1366 return matches(child, selector); 1367 }) : children2; 1368} 1369 1370function child(parent, selector) { 1371 return selector ? children(parent, selector)[0] : parent.firstElementChild; 1372} 1373 1374var ownKeys = Object.keys; 1375 1376function forOwn(object, iteratee, right) { 1377 if (object) { 1378 (right ? ownKeys(object).reverse() : ownKeys(object)).forEach(function (key) { 1379 key !== "__proto__" && iteratee(object[key], key); 1380 }); 1381 } 1382 1383 return object; 1384} 1385 1386function assign(object) { 1387 slice(arguments, 1).forEach(function (source) { 1388 forOwn(source, function (value, key) { 1389 object[key] = source[key]; 1390 }); 1391 }); 1392 return object; 1393} 1394 1395function merge(object) { 1396 slice(arguments, 1).forEach(function (source) { 1397 forOwn(source, function (value, key) { 1398 if (isArray(value)) { 1399 object[key] = value.slice(); 1400 } else if (isObject(value)) { 1401 object[key] = merge({}, isObject(object[key]) ? object[key] : {}, value); 1402 } else { 1403 object[key] = value; 1404 } 1405 }); 1406 }); 1407 return object; 1408} 1409 1410function omit(object, keys) { 1411 forEach(keys || ownKeys(object), function (key) { 1412 delete object[key]; 1413 }); 1414} 1415 1416function removeAttribute(elms, attrs) { 1417 forEach(elms, function (elm) { 1418 forEach(attrs, function (attr) { 1419 elm && elm.removeAttribute(attr); 1420 }); 1421 }); 1422} 1423 1424function setAttribute(elms, attrs, value) { 1425 if (isObject(attrs)) { 1426 forOwn(attrs, function (value2, name) { 1427 setAttribute(elms, name, value2); 1428 }); 1429 } else { 1430 forEach(elms, function (elm) { 1431 isNull(value) || value === "" ? removeAttribute(elm, attrs) : elm.setAttribute(attrs, String(value)); 1432 }); 1433 } 1434} 1435 1436function create(tag, attrs, parent) { 1437 var elm = document.createElement(tag); 1438 1439 if (attrs) { 1440 isString(attrs) ? addClass(elm, attrs) : setAttribute(elm, attrs); 1441 } 1442 1443 parent && append(parent, elm); 1444 return elm; 1445} 1446 1447function style(elm, prop, value) { 1448 if (isUndefined(value)) { 1449 return getComputedStyle(elm)[prop]; 1450 } 1451 1452 if (!isNull(value)) { 1453 elm.style[prop] = "" + value; 1454 } 1455} 1456 1457function display(elm, display2) { 1458 style(elm, "display", display2); 1459} 1460 1461function focus(elm) { 1462 elm["setActive"] && elm["setActive"]() || elm.focus({ 1463 preventScroll: true 1464 }); 1465} 1466 1467function getAttribute(elm, attr) { 1468 return elm.getAttribute(attr); 1469} 1470 1471function hasClass(elm, className) { 1472 return elm && elm.classList.contains(className); 1473} 1474 1475function rect(target) { 1476 return target.getBoundingClientRect(); 1477} 1478 1479function remove(nodes) { 1480 forEach(nodes, function (node) { 1481 if (node && node.parentNode) { 1482 node.parentNode.removeChild(node); 1483 } 1484 }); 1485} 1486 1487function parseHtml(html) { 1488 return child(new DOMParser().parseFromString(html, "text/html").body); 1489} 1490 1491function prevent(e, stopPropagation) { 1492 e.preventDefault(); 1493 1494 if (stopPropagation) { 1495 e.stopPropagation(); 1496 e.stopImmediatePropagation(); 1497 } 1498} 1499 1500function query(parent, selector) { 1501 return parent && parent.querySelector(selector); 1502} 1503 1504function queryAll(parent, selector) { 1505 return selector ? slice(parent.querySelectorAll(selector)) : []; 1506} 1507 1508function removeClass(elm, classes) { 1509 toggleClass(elm, classes, false); 1510} 1511 1512function timeOf(e) { 1513 return e.timeStamp; 1514} 1515 1516function unit(value) { 1517 return isString(value) ? value : value ? value + "px" : ""; 1518} 1519 1520var PROJECT_CODE = "splide"; 1521var DATA_ATTRIBUTE = "data-" + PROJECT_CODE; 1522 1523function assert(condition, message) { 1524 if (!condition) { 1525 throw new Error("[" + PROJECT_CODE + "] " + (message || "")); 1526 } 1527} 1528 1529var min = Math.min, 1530 max = Math.max, 1531 floor = Math.floor, 1532 ceil = Math.ceil, 1533 abs = Math.abs; 1534 1535function approximatelyEqual(x, y, epsilon) { 1536 return abs(x - y) < epsilon; 1537} 1538 1539function between(number, x, y, exclusive) { 1540 var minimum = min(x, y); 1541 var maximum = max(x, y); 1542 return exclusive ? minimum < number && number < maximum : minimum <= number && number <= maximum; 1543} 1544 1545function clamp(number, x, y) { 1546 var minimum = min(x, y); 1547 var maximum = max(x, y); 1548 return min(max(minimum, number), maximum); 1549} 1550 1551function sign(x) { 1552 return +(x > 0) - +(x < 0); 1553} 1554 1555function camelToKebab(string) { 1556 return string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(); 1557} 1558 1559function format(string, replacements) { 1560 forEach(replacements, function (replacement) { 1561 string = string.replace("%s", "" + replacement); 1562 }); 1563 return string; 1564} 1565 1566function pad(number) { 1567 return number < 10 ? "0" + number : "" + number; 1568} 1569 1570var ids = {}; 1571 1572function uniqueId(prefix) { 1573 return "" + prefix + pad(ids[prefix] = (ids[prefix] || 0) + 1); 1574} 1575 1576function EventBinder() { 1577 var listeners = []; 1578 1579 function bind(targets, events, callback, options) { 1580 forEachEvent(targets, events, function (target, event, namespace) { 1581 var isEventTarget = ("addEventListener" in target); 1582 var remover = isEventTarget ? target.removeEventListener.bind(target, event, callback, options) : target["removeListener"].bind(target, callback); 1583 isEventTarget ? target.addEventListener(event, callback, options) : target["addListener"](callback); 1584 listeners.push([target, event, namespace, callback, remover]); 1585 }); 1586 } 1587 1588 function unbind(targets, events, callback) { 1589 forEachEvent(targets, events, function (target, event, namespace) { 1590 listeners = listeners.filter(function (listener) { 1591 if (listener[0] === target && listener[1] === event && listener[2] === namespace && (!callback || listener[3] === callback)) { 1592 listener[4](); 1593 return false; 1594 } 1595 1596 return true; 1597 }); 1598 }); 1599 } 1600 1601 function dispatch(target, type, detail) { 1602 var e; 1603 var bubbles = true; 1604 1605 if (typeof CustomEvent === "function") { 1606 e = new CustomEvent(type, { 1607 bubbles: bubbles, 1608 detail: detail 1609 }); 1610 } else { 1611 e = document.createEvent("CustomEvent"); 1612 e.initCustomEvent(type, bubbles, false, detail); 1613 } 1614 1615 target.dispatchEvent(e); 1616 return e; 1617 } 1618 1619 function forEachEvent(targets, events, iteratee) { 1620 forEach(targets, function (target) { 1621 target && forEach(events, function (events2) { 1622 events2.split(" ").forEach(function (eventNS) { 1623 var fragment = eventNS.split("."); 1624 iteratee(target, fragment[0], fragment[1]); 1625 }); 1626 }); 1627 }); 1628 } 1629 1630 function destroy() { 1631 listeners.forEach(function (data) { 1632 data[4](); 1633 }); 1634 empty(listeners); 1635 } 1636 1637 return { 1638 bind: bind, 1639 unbind: unbind, 1640 dispatch: dispatch, 1641 destroy: destroy 1642 }; 1643} 1644 1645var EVENT_MOUNTED = "mounted"; 1646var EVENT_READY = "ready"; 1647var EVENT_MOVE = "move"; 1648var EVENT_MOVED = "moved"; 1649var EVENT_CLICK = "click"; 1650var EVENT_ACTIVE = "active"; 1651var EVENT_INACTIVE = "inactive"; 1652var EVENT_VISIBLE = "visible"; 1653var EVENT_HIDDEN = "hidden"; 1654var EVENT_REFRESH = "refresh"; 1655var EVENT_UPDATED = "updated"; 1656var EVENT_RESIZE = "resize"; 1657var EVENT_RESIZED = "resized"; 1658var EVENT_DRAG = "drag"; 1659var EVENT_DRAGGING = "dragging"; 1660var EVENT_DRAGGED = "dragged"; 1661var EVENT_SCROLL = "scroll"; 1662var EVENT_SCROLLED = "scrolled"; 1663var EVENT_OVERFLOW = "overflow"; 1664var EVENT_DESTROY = "destroy"; 1665var EVENT_ARROWS_MOUNTED = "arrows:mounted"; 1666var EVENT_ARROWS_UPDATED = "arrows:updated"; 1667var EVENT_PAGINATION_MOUNTED = "pagination:mounted"; 1668var EVENT_PAGINATION_UPDATED = "pagination:updated"; 1669var EVENT_NAVIGATION_MOUNTED = "navigation:mounted"; 1670var EVENT_AUTOPLAY_PLAY = "autoplay:play"; 1671var EVENT_AUTOPLAY_PLAYING = "autoplay:playing"; 1672var EVENT_AUTOPLAY_PAUSE = "autoplay:pause"; 1673var EVENT_LAZYLOAD_LOADED = "lazyload:loaded"; 1674var EVENT_SLIDE_KEYDOWN = "sk"; 1675var EVENT_SHIFTED = "sh"; 1676var EVENT_END_INDEX_CHANGED = "ei"; 1677 1678function EventInterface(Splide2) { 1679 var bus = Splide2 ? Splide2.event.bus : document.createDocumentFragment(); 1680 var binder = EventBinder(); 1681 1682 function on(events, callback) { 1683 binder.bind(bus, toArray(events).join(" "), function (e) { 1684 callback.apply(callback, isArray(e.detail) ? e.detail : []); 1685 }); 1686 } 1687 1688 function emit(event) { 1689 binder.dispatch(bus, event, slice(arguments, 1)); 1690 } 1691 1692 if (Splide2) { 1693 Splide2.event.on(EVENT_DESTROY, binder.destroy); 1694 } 1695 1696 return assign(binder, { 1697 bus: bus, 1698 on: on, 1699 off: apply(binder.unbind, bus), 1700 emit: emit 1701 }); 1702} 1703 1704function RequestInterval(interval, onInterval, onUpdate, limit) { 1705 var now = Date.now; 1706 var startTime; 1707 var rate = 0; 1708 var id; 1709 var paused = true; 1710 var count = 0; 1711 1712 function update() { 1713 if (!paused) { 1714 rate = interval ? min((now() - startTime) / interval, 1) : 1; 1715 onUpdate && onUpdate(rate); 1716 1717 if (rate >= 1) { 1718 onInterval(); 1719 startTime = now(); 1720 1721 if (limit && ++count >= limit) { 1722 return pause(); 1723 } 1724 } 1725 1726 id = raf(update); 1727 } 1728 } 1729 1730 function start(resume) { 1731 resume || cancel(); 1732 startTime = now() - (resume ? rate * interval : 0); 1733 paused = false; 1734 id = raf(update); 1735 } 1736 1737 function pause() { 1738 paused = true; 1739 } 1740 1741 function rewind() { 1742 startTime = now(); 1743 rate = 0; 1744 1745 if (onUpdate) { 1746 onUpdate(rate); 1747 } 1748 } 1749 1750 function cancel() { 1751 id && cancelAnimationFrame(id); 1752 rate = 0; 1753 id = 0; 1754 paused = true; 1755 } 1756 1757 function set(time) { 1758 interval = time; 1759 } 1760 1761 function isPaused() { 1762 return paused; 1763 } 1764 1765 return { 1766 start: start, 1767 rewind: rewind, 1768 pause: pause, 1769 cancel: cancel, 1770 set: set, 1771 isPaused: isPaused 1772 }; 1773} 1774 1775function State(initialState) { 1776 var state = initialState; 1777 1778 function set(value) { 1779 state = value; 1780 } 1781 1782 function is(states) { 1783 return includes(toArray(states), state); 1784 } 1785 1786 return { 1787 set: set, 1788 is: is 1789 }; 1790} 1791 1792function Throttle(func, duration) { 1793 var interval = RequestInterval(duration || 0, func, null, 1); 1794 return function () { 1795 interval.isPaused() && interval.start(); 1796 }; 1797} 1798 1799function Media(Splide2, Components2, options) { 1800 var state = Splide2.state; 1801 var breakpoints = options.breakpoints || {}; 1802 var reducedMotion = options.reducedMotion || {}; 1803 var binder = EventBinder(); 1804 var queries = []; 1805 1806 function setup() { 1807 var isMin = options.mediaQuery === "min"; 1808 ownKeys(breakpoints).sort(function (n, m) { 1809 return isMin ? +n - +m : +m - +n; 1810 }).forEach(function (key) { 1811 register(breakpoints[key], "(" + (isMin ? "min" : "max") + "-width:" + key + "px)"); 1812 }); 1813 register(reducedMotion, MEDIA_PREFERS_REDUCED_MOTION); 1814 update(); 1815 } 1816 1817 function destroy(completely) { 1818 if (completely) { 1819 binder.destroy(); 1820 } 1821 } 1822 1823 function register(options2, query) { 1824 var queryList = matchMedia(query); 1825 binder.bind(queryList, "change", update); 1826 queries.push([options2, queryList]); 1827 } 1828 1829 function update() { 1830 var destroyed = state.is(DESTROYED); 1831 var direction = options.direction; 1832 var merged = queries.reduce(function (merged2, entry) { 1833 return merge(merged2, entry[1].matches ? entry[0] : {}); 1834 }, {}); 1835 omit(options); 1836 set(merged); 1837 1838 if (options.destroy) { 1839 Splide2.destroy(options.destroy === "completely"); 1840 } else if (destroyed) { 1841 destroy(true); 1842 Splide2.mount(); 1843 } else { 1844 direction !== options.direction && Splide2.refresh(); 1845 } 1846 } 1847 1848 function reduce(enable) { 1849 if (matchMedia(MEDIA_PREFERS_REDUCED_MOTION).matches) { 1850 enable ? merge(options, reducedMotion) : omit(options, ownKeys(reducedMotion)); 1851 } 1852 } 1853 1854 function set(opts, base, notify) { 1855 merge(options, opts); 1856 base && merge(Object.getPrototypeOf(options), opts); 1857 1858 if (notify || !state.is(CREATED)) { 1859 Splide2.emit(EVENT_UPDATED, options); 1860 } 1861 } 1862 1863 return { 1864 setup: setup, 1865 destroy: destroy, 1866 reduce: reduce, 1867 set: set 1868 }; 1869} 1870 1871var ARROW = "Arrow"; 1872var ARROW_LEFT = ARROW + "Left"; 1873var ARROW_RIGHT = ARROW + "Right"; 1874var ARROW_UP = ARROW + "Up"; 1875var ARROW_DOWN = ARROW + "Down"; 1876var LTR = "ltr"; 1877var RTL = "rtl"; 1878var TTB = "ttb"; 1879var ORIENTATION_MAP = { 1880 width: ["height"], 1881 left: ["top", "right"], 1882 right: ["bottom", "left"], 1883 x: ["y"], 1884 X: ["Y"], 1885 Y: ["X"], 1886 ArrowLeft: [ARROW_UP, ARROW_RIGHT], 1887 ArrowRight: [ARROW_DOWN, ARROW_LEFT] 1888}; 1889 1890function Direction(Splide2, Components2, options) { 1891 function resolve(prop, axisOnly, direction) { 1892 direction = direction || options.direction; 1893 var index = direction === RTL && !axisOnly ? 1 : direction === TTB ? 0 : -1; 1894 return ORIENTATION_MAP[prop] && ORIENTATION_MAP[prop][index] || prop.replace(/width|left|right/i, function (match, offset) { 1895 var replacement = ORIENTATION_MAP[match.toLowerCase()][index] || match; 1896 return offset > 0 ? replacement.charAt(0).toUpperCase() + replacement.slice(1) : replacement; 1897 }); 1898 } 1899 1900 function orient(value) { 1901 return value * (options.direction === RTL ? 1 : -1); 1902 } 1903 1904 return { 1905 resolve: resolve, 1906 orient: orient 1907 }; 1908} 1909 1910var ROLE = "role"; 1911var TAB_INDEX = "tabindex"; 1912var DISABLED = "disabled"; 1913var ARIA_PREFIX = "aria-"; 1914var ARIA_CONTROLS = ARIA_PREFIX + "controls"; 1915var ARIA_CURRENT = ARIA_PREFIX + "current"; 1916var ARIA_SELECTED = ARIA_PREFIX + "selected"; 1917var ARIA_LABEL = ARIA_PREFIX + "label"; 1918var ARIA_LABELLEDBY = ARIA_PREFIX + "labelledby"; 1919var ARIA_HIDDEN = ARIA_PREFIX + "hidden"; 1920var ARIA_ORIENTATION = ARIA_PREFIX + "orientation"; 1921var ARIA_ROLEDESCRIPTION = ARIA_PREFIX + "roledescription"; 1922var ARIA_LIVE = ARIA_PREFIX + "live"; 1923var ARIA_BUSY = ARIA_PREFIX + "busy"; 1924var ARIA_ATOMIC = ARIA_PREFIX + "atomic"; 1925var ALL_ATTRIBUTES = [ROLE, TAB_INDEX, DISABLED, ARIA_CONTROLS, ARIA_CURRENT, ARIA_LABEL, ARIA_LABELLEDBY, ARIA_HIDDEN, ARIA_ORIENTATION, ARIA_ROLEDESCRIPTION]; 1926var CLASS_PREFIX = PROJECT_CODE + "__"; 1927var STATUS_CLASS_PREFIX = "is-"; 1928var CLASS_ROOT = PROJECT_CODE; 1929var CLASS_TRACK = CLASS_PREFIX + "track"; 1930var CLASS_LIST = CLASS_PREFIX + "list"; 1931var CLASS_SLIDE = CLASS_PREFIX + "slide"; 1932var CLASS_CLONE = CLASS_SLIDE + "--clone"; 1933var CLASS_CONTAINER = CLASS_SLIDE + "__container"; 1934var CLASS_ARROWS = CLASS_PREFIX + "arrows"; 1935var CLASS_ARROW = CLASS_PREFIX + "arrow"; 1936var CLASS_ARROW_PREV = CLASS_ARROW + "--prev"; 1937var CLASS_ARROW_NEXT = CLASS_ARROW + "--next"; 1938var CLASS_PAGINATION = CLASS_PREFIX + "pagination"; 1939var CLASS_PAGINATION_PAGE = CLASS_PAGINATION + "__page"; 1940var CLASS_PROGRESS = CLASS_PREFIX + "progress"; 1941var CLASS_PROGRESS_BAR = CLASS_PROGRESS + "__bar"; 1942var CLASS_TOGGLE = CLASS_PREFIX + "toggle"; 1943var CLASS_TOGGLE_PLAY = CLASS_TOGGLE + "__play"; 1944var CLASS_TOGGLE_PAUSE = CLASS_TOGGLE + "__pause"; 1945var CLASS_SPINNER = CLASS_PREFIX + "spinner"; 1946var CLASS_SR = CLASS_PREFIX + "sr"; 1947var CLASS_INITIALIZED = STATUS_CLASS_PREFIX + "initialized"; 1948var CLASS_ACTIVE = STATUS_CLASS_PREFIX + "active"; 1949var CLASS_PREV = STATUS_CLASS_PREFIX + "prev"; 1950var CLASS_NEXT = STATUS_CLASS_PREFIX + "next"; 1951var CLASS_VISIBLE = STATUS_CLASS_PREFIX + "visible"; 1952var CLASS_LOADING = STATUS_CLASS_PREFIX + "loading"; 1953var CLASS_FOCUS_IN = STATUS_CLASS_PREFIX + "focus-in"; 1954var CLASS_OVERFLOW = STATUS_CLASS_PREFIX + "overflow"; 1955var STATUS_CLASSES = [CLASS_ACTIVE, CLASS_VISIBLE, CLASS_PREV, CLASS_NEXT, CLASS_LOADING, CLASS_FOCUS_IN, CLASS_OVERFLOW]; 1956var CLASSES = { 1957 slide: CLASS_SLIDE, 1958 clone: CLASS_CLONE, 1959 arrows: CLASS_ARROWS, 1960 arrow: CLASS_ARROW, 1961 prev: CLASS_ARROW_PREV, 1962 next: CLASS_ARROW_NEXT, 1963 pagination: CLASS_PAGINATION, 1964 page: CLASS_PAGINATION_PAGE, 1965 spinner: CLASS_SPINNER 1966}; 1967 1968function closest(from, selector) { 1969 if (isFunction(from.closest)) { 1970 return from.closest(selector); 1971 } 1972 1973 var elm = from; 1974 1975 while (elm && elm.nodeType === 1) { 1976 if (matches(elm, selector)) { 1977 break; 1978 } 1979 1980 elm = elm.parentElement; 1981 } 1982 1983 return elm; 1984} 1985 1986var FRICTION = 5; 1987var LOG_INTERVAL = 200; 1988var POINTER_DOWN_EVENTS = "touchstart mousedown"; 1989var POINTER_MOVE_EVENTS = "touchmove mousemove"; 1990var POINTER_UP_EVENTS = "touchend touchcancel mouseup click"; 1991 1992function Elements(Splide2, Components2, options) { 1993 var _EventInterface = EventInterface(Splide2), 1994 on = _EventInterface.on, 1995 bind = _EventInterface.bind; 1996 1997 var root = Splide2.root; 1998 var i18n = options.i18n; 1999 var elements = {}; 2000 var slides = []; 2001 var rootClasses = []; 2002 var trackClasses = []; 2003 var track; 2004 var list; 2005 var isUsingKey; 2006 2007 function setup() { 2008 collect(); 2009 init(); 2010 update(); 2011 } 2012 2013 function mount() { 2014 on(EVENT_REFRESH, destroy); 2015 on(EVENT_REFRESH, setup); 2016 on(EVENT_UPDATED, update); 2017 bind(document, POINTER_DOWN_EVENTS + " keydown", function (e) { 2018 isUsingKey = e.type === "keydown"; 2019 }, { 2020 capture: true 2021 }); 2022 bind(root, "focusin", function () { 2023 toggleClass(root, CLASS_FOCUS_IN, !!isUsingKey); 2024 }); 2025 } 2026 2027 function destroy(completely) { 2028 var attrs = ALL_ATTRIBUTES.concat("style"); 2029 empty(slides); 2030 removeClass(root, rootClasses); 2031 removeClass(track, trackClasses); 2032 removeAttribute([track, list], attrs); 2033 removeAttribute(root, completely ? attrs : ["style", ARIA_ROLEDESCRIPTION]); 2034 } 2035 2036 function update() { 2037 removeClass(root, rootClasses); 2038 removeClass(track, trackClasses); 2039 rootClasses = getClasses(CLASS_ROOT); 2040 trackClasses = getClasses(CLASS_TRACK); 2041 addClass(root, rootClasses); 2042 addClass(track, trackClasses); 2043 setAttribute(root, ARIA_LABEL, options.label); 2044 setAttribute(root, ARIA_LABELLEDBY, options.labelledby); 2045 } 2046 2047 function collect() { 2048 track = find("." + CLASS_TRACK); 2049 list = child(track, "." + CLASS_LIST); 2050 assert(track && list, "A track/list element is missing."); 2051 push(slides, children(list, "." + CLASS_SLIDE + ":not(." + CLASS_CLONE + ")")); 2052 forOwn({ 2053 arrows: CLASS_ARROWS, 2054 pagination: CLASS_PAGINATION, 2055 prev: CLASS_ARROW_PREV, 2056 next: CLASS_ARROW_NEXT, 2057 bar: CLASS_PROGRESS_BAR, 2058 toggle: CLASS_TOGGLE 2059 }, function (className, key) { 2060 elements[key] = find("." + className); 2061 }); 2062 assign(elements, { 2063 root: root, 2064 track: track, 2065 list: list, 2066 slides: slides 2067 }); 2068 } 2069 2070 function init() { 2071 var id = root.id || uniqueId(PROJECT_CODE); 2072 var role = options.role; 2073 root.id = id; 2074 track.id = track.id || id + "-track"; 2075 list.id = list.id || id + "-list"; 2076 2077 if (!getAttribute(root, ROLE) && root.tagName !== "SECTION" && role) { 2078 setAttribute(root, ROLE, role); 2079 } 2080 2081 setAttribute(root, ARIA_ROLEDESCRIPTION, i18n.carousel); 2082 setAttribute(list, ROLE, "presentation"); 2083 } 2084 2085 function find(selector) { 2086 var elm = query(root, selector); 2087 return elm && closest(elm, "." + CLASS_ROOT) === root ? elm : void 0; 2088 } 2089 2090 function getClasses(base) { 2091 return [base + "--" + options.type, base + "--" + options.direction, options.drag && base + "--draggable", options.isNavigation && base + "--nav", base === CLASS_ROOT && CLASS_ACTIVE]; 2092 } 2093 2094 return assign(elements, { 2095 setup: setup, 2096 mount: mount, 2097 destroy: destroy 2098 }); 2099} 2100 2101var SLIDE = "slide"; 2102var LOOP = "loop"; 2103var FADE = "fade"; 2104 2105function Slide$1(Splide2, index, slideIndex, slide) { 2106 var event = EventInterface(Splide2); 2107 var on = event.on, 2108 emit = event.emit, 2109 bind = event.bind; 2110 var Components = Splide2.Components, 2111 root = Splide2.root, 2112 options = Splide2.options; 2113 var isNavigation = options.isNavigation, 2114 updateOnMove = options.updateOnMove, 2115 i18n = options.i18n, 2116 pagination = options.pagination, 2117 slideFocus = options.slideFocus; 2118 var resolve = Components.Direction.resolve; 2119 var styles = getAttribute(slide, "style"); 2120 var label = getAttribute(slide, ARIA_LABEL); 2121 var isClone = slideIndex > -1; 2122 var container = child(slide, "." + CLASS_CONTAINER); 2123 var destroyed; 2124 2125 function mount() { 2126 if (!isClone) { 2127 slide.id = root.id + "-slide" + pad(index + 1); 2128 setAttribute(slide, ROLE, pagination ? "tabpanel" : "group"); 2129 setAttribute(slide, ARIA_ROLEDESCRIPTION, i18n.slide); 2130 setAttribute(slide, ARIA_LABEL, label || format(i18n.slideLabel, [index + 1, Splide2.length])); 2131 } 2132 2133 listen(); 2134 } 2135 2136 function listen() { 2137 bind(slide, "click", apply(emit, EVENT_CLICK, self)); 2138 bind(slide, "keydown", apply(emit, EVENT_SLIDE_KEYDOWN, self)); 2139 on([EVENT_MOVED, EVENT_SHIFTED, EVENT_SCROLLED], update); 2140 on(EVENT_NAVIGATION_MOUNTED, initNavigation); 2141 2142 if (updateOnMove) { 2143 on(EVENT_MOVE, onMove); 2144 } 2145 } 2146 2147 function destroy() { 2148 destroyed = true; 2149 event.destroy(); 2150 removeClass(slide, STATUS_CLASSES); 2151 removeAttribute(slide, ALL_ATTRIBUTES); 2152 setAttribute(slide, "style", styles); 2153 setAttribute(slide, ARIA_LABEL, label || ""); 2154 } 2155 2156 function initNavigation() { 2157 var controls = Splide2.splides.map(function (target) { 2158 var Slide2 = target.splide.Components.Slides.getAt(index); 2159 return Slide2 ? Slide2.slide.id : ""; 2160 }).join(" "); 2161 setAttribute(slide, ARIA_LABEL, format(i18n.slideX, (isClone ? slideIndex : index) + 1)); 2162 setAttribute(slide, ARIA_CONTROLS, controls); 2163 setAttribute(slide, ROLE, slideFocus ? "button" : ""); 2164 slideFocus && removeAttribute(slide, ARIA_ROLEDESCRIPTION); 2165 } 2166 2167 function onMove() { 2168 if (!destroyed) { 2169 update(); 2170 } 2171 } 2172 2173 function update() { 2174 if (!destroyed) { 2175 var curr = Splide2.index; 2176 updateActivity(); 2177 updateVisibility(); 2178 toggleClass(slide, CLASS_PREV, index === curr - 1); 2179 toggleClass(slide, CLASS_NEXT, index === curr + 1); 2180 } 2181 } 2182 2183 function updateActivity() { 2184 var active = isActive(); 2185 2186 if (active !== hasClass(slide, CLASS_ACTIVE)) { 2187 toggleClass(slide, CLASS_ACTIVE, active); 2188 setAttribute(slide, ARIA_CURRENT, isNavigation && active || ""); 2189 emit(active ? EVENT_ACTIVE : EVENT_INACTIVE, self); 2190 } 2191 } 2192 2193 function updateVisibility() { 2194 var visible = isVisible(); 2195 var hidden = !visible && (!isActive() || isClone); 2196 2197 if (!Splide2.state.is([MOVING, SCROLLING])) { 2198 setAttribute(slide, ARIA_HIDDEN, hidden || ""); 2199 } 2200 2201 setAttribute(queryAll(slide, options.focusableNodes || ""), TAB_INDEX, hidden ? -1 : ""); 2202 2203 if (slideFocus) { 2204 setAttribute(slide, TAB_INDEX, hidden ? -1 : 0); 2205 } 2206 2207 if (visible !== hasClass(slide, CLASS_VISIBLE)) { 2208 toggleClass(slide, CLASS_VISIBLE, visible); 2209 emit(visible ? EVENT_VISIBLE : EVENT_HIDDEN, self); 2210 } 2211 2212 if (!visible && document.activeElement === slide) { 2213 var Slide2 = Components.Slides.getAt(Splide2.index); 2214 Slide2 && focus(Slide2.slide); 2215 } 2216 } 2217 2218 function style$1(prop, value, useContainer) { 2219 style(useContainer && container || slide, prop, value); 2220 } 2221 2222 function isActive() { 2223 var curr = Splide2.index; 2224 return curr === index || options.cloneStatus && curr === slideIndex; 2225 } 2226 2227 function isVisible() { 2228 if (Splide2.is(FADE)) { 2229 return isActive(); 2230 } 2231 2232 var trackRect = rect(Components.Elements.track); 2233 var slideRect = rect(slide); 2234 var left = resolve("left", true); 2235 var right = resolve("right", true); 2236 return floor(trackRect[left]) <= ceil(slideRect[left]) && floor(slideRect[right]) <= ceil(trackRect[right]); 2237 } 2238 2239 function isWithin(from, distance) { 2240 var diff = abs(from - index); 2241 2242 if (!isClone && (options.rewind || Splide2.is(LOOP))) { 2243 diff = min(diff, Splide2.length - diff); 2244 } 2245 2246 return diff <= distance; 2247 } 2248 2249 var self = { 2250 index: index, 2251 slideIndex: slideIndex, 2252 slide: slide, 2253 container: container, 2254 isClone: isClone, 2255 mount: mount, 2256 destroy: destroy, 2257 update: update, 2258 style: style$1, 2259 isWithin: isWithin 2260 }; 2261 return self; 2262} 2263 2264function Slides(Splide2, Components2, options) { 2265 var _EventInterface2 = EventInterface(Splide2), 2266 on = _EventInterface2.on, 2267 emit = _EventInterface2.emit, 2268 bind = _EventInterface2.bind; 2269 2270 var _Components2$Elements = Components2.Elements, 2271 slides = _Components2$Elements.slides, 2272 list = _Components2$Elements.list; 2273 var Slides2 = []; 2274 2275 function mount() { 2276 init(); 2277 on(EVENT_REFRESH, destroy); 2278 on(EVENT_REFRESH, init); 2279 } 2280 2281 function init() { 2282 slides.forEach(function (slide, index) { 2283 register(slide, index, -1); 2284 }); 2285 } 2286 2287 function destroy() { 2288 forEach$1(function (Slide2) { 2289 Slide2.destroy(); 2290 }); 2291 empty(Slides2); 2292 } 2293 2294 function update() { 2295 forEach$1(function (Slide2) { 2296 Slide2.update(); 2297 }); 2298 } 2299 2300 function register(slide, index, slideIndex) { 2301 var object = Slide$1(Splide2, index, slideIndex, slide); 2302 object.mount(); 2303 Slides2.push(object); 2304 Slides2.sort(function (Slide1, Slide2) { 2305 return Slide1.index - Slide2.index; 2306 }); 2307 } 2308 2309 function get(excludeClones) { 2310 return excludeClones ? filter(function (Slide2) { 2311 return !Slide2.isClone; 2312 }) : Slides2; 2313 } 2314 2315 function getIn(page) { 2316 var Controller = Components2.Controller; 2317 var index = Controller.toIndex(page); 2318 var max = Controller.hasFocus() ? 1 : options.perPage; 2319 return filter(function (Slide2) { 2320 return between(Slide2.index, index, index + max - 1); 2321 }); 2322 } 2323 2324 function getAt(index) { 2325 return filter(index)[0]; 2326 } 2327 2328 function add(items, index) { 2329 forEach(items, function (slide) { 2330 if (isString(slide)) { 2331 slide = parseHtml(slide); 2332 } 2333 2334 if (isHTMLElement(slide)) { 2335 var ref = slides[index]; 2336 ref ? before(slide, ref) : append(list, slide); 2337 addClass(slide, options.classes.slide); 2338 observeImages(slide, apply(emit, EVENT_RESIZE)); 2339 } 2340 }); 2341 emit(EVENT_REFRESH); 2342 } 2343 2344 function remove$1(matcher) { 2345 remove(filter(matcher).map(function (Slide2) { 2346 return Slide2.slide; 2347 })); 2348 emit(EVENT_REFRESH); 2349 } 2350 2351 function forEach$1(iteratee, excludeClones) { 2352 get(excludeClones).forEach(iteratee); 2353 } 2354 2355 function filter(matcher) { 2356 return Slides2.filter(isFunction(matcher) ? matcher : function (Slide2) { 2357 return isString(matcher) ? matches(Slide2.slide, matcher) : includes(toArray(matcher), Slide2.index); 2358 }); 2359 } 2360 2361 function style(prop, value, useContainer) { 2362 forEach$1(function (Slide2) { 2363 Slide2.style(prop, value, useContainer); 2364 }); 2365 } 2366 2367 function observeImages(elm, callback) { 2368 var images = queryAll(elm, "img"); 2369 var length = images.length; 2370 2371 if (length) { 2372 images.forEach(function (img) { 2373 bind(img, "load error", function () { 2374 if (! --length) { 2375 callback(); 2376 } 2377 }); 2378 }); 2379 } else { 2380 callback(); 2381 } 2382 } 2383 2384 function getLength(excludeClones) { 2385 return excludeClones ? slides.length : Slides2.length; 2386 } 2387 2388 function isEnough() { 2389 return Slides2.length > options.perPage; 2390 } 2391 2392 return { 2393 mount: mount, 2394 destroy: destroy, 2395 update: update, 2396 register: register, 2397 get: get, 2398 getIn: getIn, 2399 getAt: getAt, 2400 add: add, 2401 remove: remove$1, 2402 forEach: forEach$1, 2403 filter: filter, 2404 style: style, 2405 getLength: getLength, 2406 isEnough: isEnough 2407 }; 2408} 2409 2410function Layout(Splide2, Components2, options) { 2411 var _EventInterface3 = EventInterface(Splide2), 2412 on = _EventInterface3.on, 2413 bind = _EventInterface3.bind, 2414 emit = _EventInterface3.emit; 2415 2416 var Slides = Components2.Slides; 2417 var resolve = Components2.Direction.resolve; 2418 var _Components2$Elements2 = Components2.Elements, 2419 root = _Components2$Elements2.root, 2420 track = _Components2$Elements2.track, 2421 list = _Components2$Elements2.list; 2422 var getAt = Slides.getAt, 2423 styleSlides = Slides.style; 2424 var vertical; 2425 var rootRect; 2426 var overflow; 2427 2428 function mount() { 2429 init(); 2430 bind(window, "resize load", Throttle(apply(emit, EVENT_RESIZE))); 2431 on([EVENT_UPDATED, EVENT_REFRESH], init); 2432 on(EVENT_RESIZE, resize); 2433 } 2434 2435 function init() { 2436 vertical = options.direction === TTB; 2437 style(root, "maxWidth", unit(options.width)); 2438 style(track, resolve("paddingLeft"), cssPadding(false)); 2439 style(track, resolve("paddingRight"), cssPadding(true)); 2440 resize(true); 2441 } 2442 2443 function resize(force) { 2444 var newRect = rect(root); 2445 2446 if (force || rootRect.width !== newRect.width || rootRect.height !== newRect.height) { 2447 style(track, "height", cssTrackHeight()); 2448 styleSlides(resolve("marginRight"), unit(options.gap)); 2449 styleSlides("width", cssSlideWidth()); 2450 styleSlides("height", cssSlideHeight(), true); 2451 rootRect = newRect; 2452 emit(EVENT_RESIZED); 2453 2454 if (overflow !== (overflow = isOverflow())) { 2455 toggleClass(root, CLASS_OVERFLOW, overflow); 2456 emit(EVENT_OVERFLOW, overflow); 2457 } 2458 } 2459 } 2460 2461 function cssPadding(right) { 2462 var padding = options.padding; 2463 var prop = resolve(right ? "right" : "left"); 2464 return padding && unit(padding[prop] || (isObject(padding) ? 0 : padding)) || "0px"; 2465 } 2466 2467 function cssTrackHeight() { 2468 var height = ""; 2469 2470 if (vertical) { 2471 height = cssHeight(); 2472 assert(height, "height or heightRatio is missing."); 2473 height = "calc(" + height + " - " + cssPadding(false) + " - " + cssPadding(true) + ")"; 2474 } 2475 2476 return height; 2477 } 2478 2479 function cssHeight() { 2480 return unit(options.height || rect(list).width * options.heightRatio); 2481 } 2482 2483 function cssSlideWidth() { 2484 return options.autoWidth ? null : unit(options.fixedWidth) || (vertical ? "" : cssSlideSize()); 2485 } 2486 2487 function cssSlideHeight() { 2488 return unit(options.fixedHeight) || (vertical ? options.autoHeight ? null : cssSlideSize() : cssHeight()); 2489 } 2490 2491 function cssSlideSize() { 2492 var gap = unit(options.gap); 2493 return "calc((100%" + (gap && " + " + gap) + ")/" + (options.perPage || 1) + (gap && " - " + gap) + ")"; 2494 } 2495 2496 function listSize() { 2497 return rect(list)[resolve("width")]; 2498 } 2499 2500 function slideSize(index, withoutGap) { 2501 var Slide = getAt(index || 0); 2502 return Slide ? rect(Slide.slide)[resolve("width")] + (withoutGap ? 0 : getGap()) : 0; 2503 } 2504 2505 function totalSize(index, withoutGap) { 2506 var Slide = getAt(index); 2507 2508 if (Slide) { 2509 var right = rect(Slide.slide)[resolve("right")]; 2510 var left = rect(list)[resolve("left")]; 2511 return abs(right - left) + (withoutGap ? 0 : getGap()); 2512 } 2513 2514 return 0; 2515 } 2516 2517 function sliderSize(withoutGap) { 2518 return totalSize(Splide2.length - 1) - totalSize(0) + slideSize(0, withoutGap); 2519 } 2520 2521 function getGap() { 2522 var Slide = getAt(0); 2523 return Slide && parseFloat(style(Slide.slide, resolve("marginRight"))) || 0; 2524 } 2525 2526 function getPadding(right) { 2527 return parseFloat(style(track, resolve("padding" + (right ? "Right" : "Left")))) || 0; 2528 } 2529 2530 function isOverflow() { 2531 return Splide2.is(FADE) || sliderSize(true) > listSize(); 2532 } 2533 2534 return { 2535 mount: mount, 2536 resize: resize, 2537 listSize: listSize, 2538 slideSize: slideSize, 2539 sliderSize: sliderSize, 2540 totalSize: totalSize, 2541 getPadding: getPadding, 2542 isOverflow: isOverflow 2543 }; 2544} 2545 2546var MULTIPLIER = 2; 2547 2548function Clones(Splide2, Components2, options) { 2549 var event = EventInterface(Splide2); 2550 var on = event.on; 2551 var Elements = Components2.Elements, 2552 Slides = Components2.Slides; 2553 var resolve = Components2.Direction.resolve; 2554 var clones = []; 2555 var cloneCount; 2556 2557 function mount() { 2558 on(EVENT_REFRESH, remount); 2559 on([EVENT_UPDATED, EVENT_RESIZE], observe); 2560 2561 if (cloneCount = computeCloneCount()) { 2562 generate(cloneCount); 2563 Components2.Layout.resize(true); 2564 } 2565 } 2566 2567 function remount() { 2568 destroy(); 2569 mount(); 2570 } 2571 2572 function destroy() { 2573 remove(clones); 2574 empty(clones); 2575 event.destroy(); 2576 } 2577 2578 function observe() { 2579 var count = computeCloneCount(); 2580 2581 if (cloneCount !== count) { 2582 if (cloneCount < count || !count) { 2583 event.emit(EVENT_REFRESH); 2584 } 2585 } 2586 } 2587 2588 function generate(count) { 2589 var slides = Slides.get().slice(); 2590 var length = slides.length; 2591 2592 if (length) { 2593 while (slides.length < count) { 2594 push(slides, slides); 2595 } 2596 2597 push(slides.slice(-count), slides.slice(0, count)).forEach(function (Slide, index) { 2598 var isHead = index < count; 2599 var clone = cloneDeep(Slide.slide, index); 2600 isHead ? before(clone, slides[0].slide) : append(Elements.list, clone); 2601 push(clones, clone); 2602 Slides.register(clone, index - count + (isHead ? 0 : length), Slide.index); 2603 }); 2604 } 2605 } 2606 2607 function cloneDeep(elm, index) { 2608 var clone = elm.cloneNode(true); 2609 addClass(clone, options.classes.clone); 2610 clone.id = Splide2.root.id + "-clone" + pad(index + 1); 2611 return clone; 2612 } 2613 2614 function computeCloneCount() { 2615 var clones2 = options.clones; 2616 2617 if (!Splide2.is(LOOP)) { 2618 clones2 = 0; 2619 } else if (isUndefined(clones2)) { 2620 var fixedSize = options[resolve("fixedWidth")] && Components2.Layout.slideSize(0); 2621 var fixedCount = fixedSize && ceil(rect(Elements.track)[resolve("width")] / fixedSize); 2622 clones2 = fixedCount || options[resolve("autoWidth")] && Splide2.length || options.perPage * MULTIPLIER; 2623 } 2624 2625 return clones2; 2626 } 2627 2628 return { 2629 mount: mount, 2630 destroy: destroy 2631 }; 2632} 2633 2634function Move(Splide2, Components2, options) { 2635 var _EventInterface4 = EventInterface(Splide2), 2636 on = _EventInterface4.on, 2637 emit = _EventInterface4.emit; 2638 2639 var set = Splide2.state.set; 2640 var _Components2$Layout = Components2.Layout, 2641 slideSize = _Components2$Layout.slideSize, 2642 getPadding = _Components2$Layout.getPadding, 2643 totalSize = _Components2$Layout.totalSize, 2644 listSize = _Components2$Layout.listSize, 2645 sliderSize = _Components2$Layout.sliderSize; 2646 var _Components2$Directio = Components2.Direction, 2647 resolve = _Components2$Directio.resolve, 2648 orient = _Components2$Directio.orient; 2649 var _Components2$Elements3 = Components2.Elements, 2650 list = _Components2$Elements3.list, 2651 track = _Components2$Elements3.track; 2652 var Transition; 2653 2654 function mount() { 2655 Transition = Components2.Transition; 2656 on([EVENT_MOUNTED, EVENT_RESIZED, EVENT_UPDATED, EVENT_REFRESH], reposition); 2657 } 2658 2659 function reposition() { 2660 if (!Components2.Controller.isBusy()) { 2661 Components2.Scroll.cancel(); 2662 jump(Splide2.index); 2663 Components2.Slides.update(); 2664 } 2665 } 2666 2667 function move(dest, index, prev, callback) { 2668 if (dest !== index && canShift(dest > prev)) { 2669 cancel(); 2670 translate(shift(getPosition(), dest > prev), true); 2671 } 2672 2673 set(MOVING); 2674 emit(EVENT_MOVE, index, prev, dest); 2675 Transition.start(index, function () { 2676 set(IDLE); 2677 emit(EVENT_MOVED, index, prev, dest); 2678 callback && callback(); 2679 }); 2680 } 2681 2682 function jump(index) { 2683 translate(toPosition(index, true)); 2684 } 2685 2686 function translate(position, preventLoop) { 2687 if (!Splide2.is(FADE)) { 2688 var destination = preventLoop ? position : loop(position); 2689 style(list, "transform", "translate" + resolve("X") + "(" + destination + "px)"); 2690 position !== destination && emit(EVENT_SHIFTED); 2691 } 2692 } 2693 2694 function loop(position) { 2695 if (Splide2.is(LOOP)) { 2696 var index = toIndex(position); 2697 var exceededMax = index > Components2.Controller.getEnd(); 2698 var exceededMin = index < 0; 2699 2700 if (exceededMin || exceededMax) { 2701 position = shift(position, exceededMax); 2702 } 2703 } 2704 2705 return position; 2706 } 2707 2708 function shift(position, backwards) { 2709 var excess = position - getLimit(backwards); 2710 var size = sliderSize(); 2711 position -= orient(size * (ceil(abs(excess) / size) || 1)) * (backwards ? 1 : -1); 2712 return position; 2713 } 2714 2715 function cancel() { 2716 translate(getPosition(), true); 2717 Transition.cancel(); 2718 } 2719 2720 function toIndex(position) { 2721 var Slides = Components2.Slides.get(); 2722 var index = 0; 2723 var minDistance = Infinity; 2724 2725 for (var i = 0; i < Slides.length; i++) { 2726 var slideIndex = Slides[i].index; 2727 var distance = abs(toPosition(slideIndex, true) - position); 2728 2729 if (distance <= minDistance) { 2730 minDistance = distance; 2731 index = slideIndex; 2732 } else { 2733 break; 2734 } 2735 } 2736 2737 return index; 2738 } 2739 2740 function toPosition(index, trimming) { 2741 var position = orient(totalSize(index - 1) - offset(index)); 2742 return trimming ? trim(position) : position; 2743 } 2744 2745 function getPosition() { 2746 var left = resolve("left"); 2747 return rect(list)[left] - rect(track)[left] + orient(getPadding(false)); 2748 } 2749 2750 function trim(position) { 2751 if (options.trimSpace && Splide2.is(SLIDE)) { 2752 position = clamp(position, 0, orient(sliderSize(true) - listSize())); 2753 } 2754 2755 return position; 2756 } 2757 2758 function offset(index) { 2759 var focus = options.focus; 2760 return focus === "center" ? (listSize() - slideSize(index, true)) / 2 : +focus * slideSize(index) || 0; 2761 } 2762 2763 function getLimit(max) { 2764 return toPosition(max ? Components2.Controller.getEnd() : 0, !!options.trimSpace); 2765 } 2766 2767 function canShift(backwards) { 2768 var shifted = orient(shift(getPosition(), backwards)); 2769 return backwards ? shifted >= 0 : shifted <= list[resolve("scrollWidth")] - rect(track)[resolve("width")]; 2770 } 2771 2772 function exceededLimit(max, position) { 2773 position = isUndefined(position) ? getPosition() : position; 2774 var exceededMin = max !== true && orient(position) < orient(getLimit(false)); 2775 var exceededMax = max !== false && orient(position) > orient(getLimit(true)); 2776 return exceededMin || exceededMax; 2777 } 2778 2779 return { 2780 mount: mount, 2781 move: move, 2782 jump: jump, 2783 translate: translate, 2784 shift: shift, 2785 cancel: cancel, 2786 toIndex: toIndex, 2787 toPosition: toPosition, 2788 getPosition: getPosition, 2789 getLimit: getLimit, 2790 exceededLimit: exceededLimit, 2791 reposition: reposition 2792 }; 2793} 2794 2795function Controller(Splide2, Components2, options) { 2796 var _EventInterface5 = EventInterface(Splide2), 2797 on = _EventInterface5.on, 2798 emit = _EventInterface5.emit; 2799 2800 var Move = Components2.Move; 2801 var getPosition = Move.getPosition, 2802 getLimit = Move.getLimit, 2803 toPosition = Move.toPosition; 2804 var _Components2$Slides = Components2.Slides, 2805 isEnough = _Components2$Slides.isEnough, 2806 getLength = _Components2$Slides.getLength; 2807 var omitEnd = options.omitEnd; 2808 var isLoop = Splide2.is(LOOP); 2809 var isSlide = Splide2.is(SLIDE); 2810 var getNext = apply(getAdjacent, false); 2811 var getPrev = apply(getAdjacent, true); 2812 var currIndex = options.start || 0; 2813 var endIndex; 2814 var prevIndex = currIndex; 2815 var slideCount; 2816 var perMove; 2817 var perPage; 2818 2819 function mount() { 2820 init(); 2821 on([EVENT_UPDATED, EVENT_REFRESH, EVENT_END_INDEX_CHANGED], init); 2822 on(EVENT_RESIZED, onResized); 2823 } 2824 2825 function init() { 2826 slideCount = getLength(true); 2827 perMove = options.perMove; 2828 perPage = options.perPage; 2829 endIndex = getEnd(); 2830 var index = clamp(currIndex, 0, omitEnd ? endIndex : slideCount - 1); 2831 2832 if (index !== currIndex) { 2833 currIndex = index; 2834 Move.reposition(); 2835 } 2836 } 2837 2838 function onResized() { 2839 if (endIndex !== getEnd()) { 2840 emit(EVENT_END_INDEX_CHANGED); 2841 } 2842 } 2843 2844 function go(control, allowSameIndex, callback) { 2845 if (!isBusy()) { 2846 var dest = parse(control); 2847 var index = loop(dest); 2848 2849 if (index > -1 && (allowSameIndex || index !== currIndex)) { 2850 setIndex(index); 2851 Move.move(dest, index, prevIndex, callback); 2852 } 2853 } 2854 } 2855 2856 function scroll(destination, duration, snap, callback) { 2857 Components2.Scroll.scroll(destination, duration, snap, function () { 2858 var index = loop(Move.toIndex(getPosition())); 2859 setIndex(omitEnd ? min(index, endIndex) : index); 2860 callback && callback(); 2861 }); 2862 } 2863 2864 function parse(control) { 2865 var index = currIndex; 2866 2867 if (isString(control)) { 2868 var _ref = control.match(/([+\-<>])(\d+)?/) || [], 2869 indicator = _ref[1], 2870 number = _ref[2]; 2871 2872 if (indicator === "+" || indicator === "-") { 2873 index = computeDestIndex(currIndex + +("" + indicator + (+number || 1)), currIndex); 2874 } else if (indicator === ">") { 2875 index = number ? toIndex(+number) : getNext(true); 2876 } else if (indicator === "<") { 2877 index = getPrev(true); 2878 } 2879 } else { 2880 index = isLoop ? control : clamp(control, 0, endIndex); 2881 } 2882 2883 return index; 2884 } 2885 2886 function getAdjacent(prev, destination) { 2887 var number = perMove || (hasFocus() ? 1 : perPage); 2888 var dest = computeDestIndex(currIndex + number * (prev ? -1 : 1), currIndex, !(perMove || hasFocus())); 2889 2890 if (dest === -1 && isSlide) { 2891 if (!approximatelyEqual(getPosition(), getLimit(!prev), 1)) { 2892 return prev ? 0 : endIndex; 2893 } 2894 } 2895 2896 return destination ? dest : loop(dest); 2897 } 2898 2899 function computeDestIndex(dest, from, snapPage) { 2900 if (isEnough() || hasFocus()) { 2901 var index = computeMovableDestIndex(dest); 2902 2903 if (index !== dest) { 2904 from = dest; 2905 dest = index; 2906 snapPage = false; 2907 } 2908 2909 if (dest < 0 || dest > endIndex) { 2910 if (!perMove && (between(0, dest, from, true) || between(endIndex, from, dest, true))) { 2911 dest = toIndex(toPage(dest)); 2912 } else { 2913 if (isLoop) { 2914 dest = snapPage ? dest < 0 ? -(slideCount % perPage || perPage) : slideCount : dest; 2915 } else if (options.rewind) { 2916 dest = dest < 0 ? endIndex : 0; 2917 } else { 2918 dest = -1; 2919 } 2920 } 2921 } else { 2922 if (snapPage && dest !== from) { 2923 dest = toIndex(toPage(from) + (dest < from ? -1 : 1)); 2924 } 2925 } 2926 } else { 2927 dest = -1; 2928 } 2929 2930 return dest; 2931 } 2932 2933 function computeMovableDestIndex(dest) { 2934 if (isSlide && options.trimSpace === "move" && dest !== currIndex) { 2935 var position = getPosition(); 2936 2937 while (position === toPosition(dest, true) && between(dest, 0, Splide2.length - 1, !options.rewind)) { 2938 dest < currIndex ? --dest : ++dest; 2939 } 2940 } 2941 2942 return dest; 2943 } 2944 2945 function loop(index) { 2946 return isLoop ? (index + slideCount) % slideCount || 0 : index; 2947 } 2948 2949 function getEnd() { 2950 var end = slideCount - (hasFocus() || isLoop && perMove ? 1 : perPage); 2951 2952 while (omitEnd && end-- > 0) { 2953 if (toPosition(slideCount - 1, true) !== toPosition(end, true)) { 2954 end++; 2955 break; 2956 } 2957 } 2958 2959 return clamp(end, 0, slideCount - 1); 2960 } 2961 2962 function toIndex(page) { 2963 return clamp(hasFocus() ? page : perPage * page, 0, endIndex); 2964 } 2965 2966 function toPage(index) { 2967 return hasFocus() ? min(index, endIndex) : floor((index >= endIndex ? slideCount - 1 : index) / perPage); 2968 } 2969 2970 function toDest(destination) { 2971 var closest = Move.toIndex(destination); 2972 return isSlide ? clamp(closest, 0, endIndex) : closest; 2973 } 2974 2975 function setIndex(index) { 2976 if (index !== currIndex) { 2977 prevIndex = currIndex; 2978 currIndex = index; 2979 } 2980 } 2981 2982 function getIndex(prev) { 2983 return prev ? prevIndex : currIndex; 2984 } 2985 2986 function hasFocus() { 2987 return !isUndefined(options.focus) || options.isNavigation; 2988 } 2989 2990 function isBusy() { 2991 return Splide2.state.is([MOVING, SCROLLING]) && !!options.waitForTransition; 2992 } 2993 2994 return { 2995 mount: mount, 2996 go: go, 2997 scroll: scroll, 2998 getNext: getNext, 2999 getPrev: getPrev, 3000 getAdjacent: getAdjacent, 3001 getEnd: getEnd, 3002 setIndex: setIndex, 3003 getIndex: getIndex, 3004 toIndex: toIndex, 3005 toPage: toPage, 3006 toDest: toDest, 3007 hasFocus: hasFocus, 3008 isBusy: isBusy 3009 }; 3010} 3011 3012var XML_NAME_SPACE = "http://www.w3.org/2000/svg"; 3013var PATH = "m15.5 0.932-4.3 4.38 14.5 14.6-14.5 14.5 4.3 4.4 14.6-14.6 4.4-4.3-4.4-4.4-14.6-14.6z"; 3014var SIZE = 40; 3015 3016function Arrows(Splide2, Components2, options) { 3017 var event = EventInterface(Splide2); 3018 var on = event.on, 3019 bind = event.bind, 3020 emit = event.emit; 3021 var classes = options.classes, 3022 i18n = options.i18n; 3023 var Elements = Components2.Elements, 3024 Controller = Components2.Controller; 3025 var placeholder = Elements.arrows, 3026 track = Elements.track; 3027 var wrapper = placeholder; 3028 var prev = Elements.prev; 3029 var next = Elements.next; 3030 var created; 3031 var wrapperClasses; 3032 var arrows = {}; 3033 3034 function mount() { 3035 init(); 3036 on(EVENT_UPDATED, remount); 3037 } 3038 3039 function remount() { 3040 destroy(); 3041 mount(); 3042 } 3043 3044 function init() { 3045 var enabled = options.arrows; 3046 3047 if (enabled && !(prev && next)) { 3048 createArrows(); 3049 } 3050 3051 if (prev && next) { 3052 assign(arrows, { 3053 prev: prev, 3054 next: next 3055 }); 3056 display(wrapper, enabled ? "" : "none"); 3057 addClass(wrapper, wrapperClasses = CLASS_ARROWS + "--" + options.direction); 3058 3059 if (enabled) { 3060 listen(); 3061 update(); 3062 setAttribute([prev, next], ARIA_CONTROLS, track.id); 3063 emit(EVENT_ARROWS_MOUNTED, prev, next); 3064 } 3065 } 3066 } 3067 3068 function destroy() { 3069 event.destroy(); 3070 removeClass(wrapper, wrapperClasses); 3071 3072 if (created) { 3073 remove(placeholder ? [prev, next] : wrapper); 3074 prev = next = null; 3075 } else { 3076 removeAttribute([prev, next], ALL_ATTRIBUTES); 3077 } 3078 } 3079 3080 function listen() { 3081 on([EVENT_MOUNTED, EVENT_MOVED, EVENT_REFRESH, EVENT_SCROLLED, EVENT_END_INDEX_CHANGED], update); 3082 bind(next, "click", apply(go, ">")); 3083 bind(prev, "click", apply(go, "<")); 3084 } 3085 3086 function go(control) { 3087 Controller.go(control, true); 3088 } 3089 3090 function createArrows() { 3091 wrapper = placeholder || create("div", classes.arrows); 3092 prev = createArrow(true); 3093 next = createArrow(false); 3094 created = true; 3095 append(wrapper, [prev, next]); 3096 !placeholder && before(wrapper, track); 3097 } 3098 3099 function createArrow(prev2) { 3100 var arrow = "<button class=\"" + classes.arrow + " " + (prev2 ? classes.prev : classes.next) + "\" type=\"button\"><svg xmlns=\"" + XML_NAME_SPACE + "\" viewBox=\"0 0 " + SIZE + " " + SIZE + "\" width=\"" + SIZE + "\" height=\"" + SIZE + "\" focusable=\"false\"><path d=\"" + (options.arrowPath || PATH) + "\" />"; 3101 return parseHtml(arrow); 3102 } 3103 3104 function update() { 3105 if (prev && next) { 3106 var index = Splide2.index; 3107 var prevIndex = Controller.getPrev(); 3108 var nextIndex = Controller.getNext(); 3109 var prevLabel = prevIndex > -1 && index < prevIndex ? i18n.last : i18n.prev; 3110 var nextLabel = nextIndex > -1 && index > nextIndex ? i18n.first : i18n.next; 3111 prev.disabled = prevIndex < 0; 3112 next.disabled = nextIndex < 0; 3113 setAttribute(prev, ARIA_LABEL, prevLabel); 3114 setAttribute(next, ARIA_LABEL, nextLabel); 3115 emit(EVENT_ARROWS_UPDATED, prev, next, prevIndex, nextIndex); 3116 } 3117 } 3118 3119 return { 3120 arrows: arrows, 3121 mount: mount, 3122 destroy: destroy, 3123 update: update 3124 }; 3125} 3126 3127var INTERVAL_DATA_ATTRIBUTE = DATA_ATTRIBUTE + "-interval"; 3128 3129function Autoplay(Splide2, Components2, options) { 3130 var _EventInterface6 = EventInterface(Splide2), 3131 on = _EventInterface6.on, 3132 bind = _EventInterface6.bind, 3133 emit = _EventInterface6.emit; 3134 3135 var interval = RequestInterval(options.interval, Splide2.go.bind(Splide2, ">"), onAnimationFrame); 3136 var isPaused = interval.isPaused; 3137 var Elements = Components2.Elements, 3138 _Components2$Elements4 = Components2.Elements, 3139 root = _Components2$Elements4.root, 3140 toggle = _Components2$Elements4.toggle; 3141 var autoplay = options.autoplay; 3142 var hovered; 3143 var focused; 3144 var stopped = autoplay === "pause"; 3145 3146 function mount() { 3147 if (autoplay) { 3148 listen(); 3149 toggle && setAttribute(toggle, ARIA_CONTROLS, Elements.track.id); 3150 stopped || play(); 3151 update(); 3152 } 3153 } 3154 3155 function listen() { 3156 if (options.pauseOnHover) { 3157 bind(root, "mouseenter mouseleave", function (e) { 3158 hovered = e.type === "mouseenter"; 3159 autoToggle(); 3160 }); 3161 } 3162 3163 if (options.pauseOnFocus) { 3164 bind(root, "focusin focusout", function (e) { 3165 focused = e.type === "focusin"; 3166 autoToggle(); 3167 }); 3168 } 3169 3170 if (toggle) { 3171 bind(toggle, "click", function () { 3172 stopped ? play() : pause(true); 3173 }); 3174 } 3175 3176 on([EVENT_MOVE, EVENT_SCROLL, EVENT_REFRESH], interval.rewind); 3177 on(EVENT_MOVE, onMove); 3178 } 3179 3180 function play() { 3181 if (isPaused() && Components2.Slides.isEnough()) { 3182 interval.start(!options.resetProgress); 3183 focused = hovered = stopped = false; 3184 update(); 3185 emit(EVENT_AUTOPLAY_PLAY); 3186 } 3187 } 3188 3189 function pause(stop) { 3190 if (stop === void 0) { 3191 stop = true; 3192 } 3193 3194 stopped = !!stop; 3195 update(); 3196 3197 if (!isPaused()) { 3198 interval.pause(); 3199 emit(EVENT_AUTOPLAY_PAUSE); 3200 } 3201 } 3202 3203 function autoToggle() { 3204 if (!stopped) { 3205 hovered || focused ? pause(false) : play(); 3206 } 3207 } 3208 3209 function update() { 3210 if (toggle) { 3211 toggleClass(toggle, CLASS_ACTIVE, !stopped); 3212 setAttribute(toggle, ARIA_LABEL, options.i18n[stopped ? "play" : "pause"]); 3213 } 3214 } 3215 3216 function onAnimationFrame(rate) { 3217 var bar = Elements.bar; 3218 bar && style(bar, "width", rate * 100 + "%"); 3219 emit(EVENT_AUTOPLAY_PLAYING, rate); 3220 } 3221 3222 function onMove(index) { 3223 var Slide = Components2.Slides.getAt(index); 3224 interval.set(Slide && +getAttribute(Slide.slide, INTERVAL_DATA_ATTRIBUTE) || options.interval); 3225 } 3226 3227 return { 3228 mount: mount, 3229 destroy: interval.cancel, 3230 play: play, 3231 pause: pause, 3232 isPaused: isPaused 3233 }; 3234} 3235 3236function Cover(Splide2, Components2, options) { 3237 var _EventInterface7 = EventInterface(Splide2), 3238 on = _EventInterface7.on; 3239 3240 function mount() { 3241 if (options.cover) { 3242 on(EVENT_LAZYLOAD_LOADED, apply(toggle, true)); 3243 on([EVENT_MOUNTED, EVENT_UPDATED, EVENT_REFRESH], apply(cover, true)); 3244 } 3245 } 3246 3247 function cover(cover2) { 3248 Components2.Slides.forEach(function (Slide) { 3249 var img = child(Slide.container || Slide.slide, "img"); 3250 3251 if (img && img.src) { 3252 toggle(cover2, img, Slide); 3253 } 3254 }); 3255 } 3256 3257 function toggle(cover2, img, Slide) { 3258 Slide.style("background", cover2 ? "center/cover no-repeat url(\"" + img.src + "\")" : "", true); 3259 display(img, cover2 ? "none" : ""); 3260 } 3261 3262 return { 3263 mount: mount, 3264 destroy: apply(cover, false) 3265 }; 3266} 3267 3268var BOUNCE_DIFF_THRESHOLD = 10; 3269var BOUNCE_DURATION = 600; 3270var FRICTION_FACTOR = 0.6; 3271var BASE_VELOCITY = 1.5; 3272var MIN_DURATION = 800; 3273 3274function Scroll(Splide2, Components2, options) { 3275 var _EventInterface8 = EventInterface(Splide2), 3276 on = _EventInterface8.on, 3277 emit = _EventInterface8.emit; 3278 3279 var set = Splide2.state.set; 3280 var Move = Components2.Move; 3281 var getPosition = Move.getPosition, 3282 getLimit = Move.getLimit, 3283 exceededLimit = Move.exceededLimit, 3284 translate = Move.translate; 3285 var isSlide = Splide2.is(SLIDE); 3286 var interval; 3287 var callback; 3288 var friction = 1; 3289 3290 function mount() { 3291 on(EVENT_MOVE, clear); 3292 on([EVENT_UPDATED, EVENT_REFRESH], cancel); 3293 } 3294 3295 function scroll(destination, duration, snap, onScrolled, noConstrain) { 3296 var from = getPosition(); 3297 clear(); 3298 3299 if (snap && (!isSlide || !exceededLimit())) { 3300 var size = Components2.Layout.sliderSize(); 3301 var offset = sign(destination) * size * floor(abs(destination) / size) || 0; 3302 destination = Move.toPosition(Components2.Controller.toDest(destination % size)) + offset; 3303 } 3304 3305 var noDistance = approximatelyEqual(from, destination, 1); 3306 friction = 1; 3307 duration = noDistance ? 0 : duration || max(abs(destination - from) / BASE_VELOCITY, MIN_DURATION); 3308 callback = onScrolled; 3309 interval = RequestInterval(duration, onEnd, apply(update, from, destination, noConstrain), 1); 3310 set(SCROLLING); 3311 emit(EVENT_SCROLL); 3312 interval.start(); 3313 } 3314 3315 function onEnd() { 3316 set(IDLE); 3317 callback && callback(); 3318 emit(EVENT_SCROLLED); 3319 } 3320 3321 function update(from, to, noConstrain, rate) { 3322 var position = getPosition(); 3323 var target = from + (to - from) * easing(rate); 3324 var diff = (target - position) * friction; 3325 translate(position + diff); 3326 3327 if (isSlide && !noConstrain && exceededLimit()) { 3328 friction *= FRICTION_FACTOR; 3329 3330 if (abs(diff) < BOUNCE_DIFF_THRESHOLD) { 3331 scroll(getLimit(exceededLimit(true)), BOUNCE_DURATION, false, callback, true); 3332 } 3333 } 3334 } 3335 3336 function clear() { 3337 if (interval) { 3338 interval.cancel(); 3339 } 3340 } 3341 3342 function cancel() { 3343 if (interval && !interval.isPaused()) { 3344 clear(); 3345 onEnd(); 3346 } 3347 } 3348 3349 function easing(t) { 3350 var easingFunc = options.easingFunc; 3351 return easingFunc ? easingFunc(t) : 1 - Math.pow(1 - t, 4); 3352 } 3353 3354 return { 3355 mount: mount, 3356 destroy: clear, 3357 scroll: scroll, 3358 cancel: cancel 3359 }; 3360} 3361 3362var SCROLL_LISTENER_OPTIONS = { 3363 passive: false, 3364 capture: true 3365}; 3366 3367function Drag(Splide2, Components2, options) { 3368 var _EventInterface9 = EventInterface(Splide2), 3369 on = _EventInterface9.on, 3370 emit = _EventInterface9.emit, 3371 bind = _EventInterface9.bind, 3372 unbind = _EventInterface9.unbind; 3373 3374 var state = Splide2.state; 3375 var Move = Components2.Move, 3376 Scroll = Components2.Scroll, 3377 Controller = Components2.Controller, 3378 track = Components2.Elements.track, 3379 reduce = Components2.Media.reduce; 3380 var _Components2$Directio2 = Components2.Direction, 3381 resolve = _Components2$Directio2.resolve, 3382 orient = _Components2$Directio2.orient; 3383 var getPosition = Move.getPosition, 3384 exceededLimit = Move.exceededLimit; 3385 var basePosition; 3386 var baseEvent; 3387 var prevBaseEvent; 3388 var isFree; 3389 var dragging; 3390 var exceeded = false; 3391 var clickPrevented; 3392 var disabled; 3393 var target; 3394 3395 function mount() { 3396 bind(track, POINTER_MOVE_EVENTS, noop, SCROLL_LISTENER_OPTIONS); 3397 bind(track, POINTER_UP_EVENTS, noop, SCROLL_LISTENER_OPTIONS); 3398 bind(track, POINTER_DOWN_EVENTS, onPointerDown, SCROLL_LISTENER_OPTIONS); 3399 bind(track, "click", onClick, { 3400 capture: true 3401 }); 3402 bind(track, "dragstart", prevent); 3403 on([EVENT_MOUNTED, EVENT_UPDATED], init); 3404 } 3405 3406 function init() { 3407 var drag = options.drag; 3408 disable(!drag); 3409 isFree = drag === "free"; 3410 } 3411 3412 function onPointerDown(e) { 3413 clickPrevented = false; 3414 3415 if (!disabled) { 3416 var isTouch = isTouchEvent(e); 3417 3418 if (isDraggable(e.target) && (isTouch || !e.button)) { 3419 if (!Controller.isBusy()) { 3420 target = isTouch ? track : window; 3421 dragging = state.is([MOVING, SCROLLING]); 3422 prevBaseEvent = null; 3423 bind(target, POINTER_MOVE_EVENTS, onPointerMove, SCROLL_LISTENER_OPTIONS); 3424 bind(target, POINTER_UP_EVENTS, onPointerUp, SCROLL_LISTENER_OPTIONS); 3425 Move.cancel(); 3426 Scroll.cancel(); 3427 save(e); 3428 } else { 3429 prevent(e, true); 3430 } 3431 } 3432 } 3433 } 3434 3435 function onPointerMove(e) { 3436 if (!state.is(DRAGGING)) { 3437 state.set(DRAGGING); 3438 emit(EVENT_DRAG); 3439 } 3440 3441 if (e.cancelable) { 3442 if (dragging) { 3443 Move.translate(basePosition + constrain(diffCoord(e))); 3444 var expired = diffTime(e) > LOG_INTERVAL; 3445 var hasExceeded = exceeded !== (exceeded = exceededLimit()); 3446 3447 if (expired || hasExceeded) { 3448 save(e); 3449 } 3450 3451 clickPrevented = true; 3452 emit(EVENT_DRAGGING); 3453 prevent(e); 3454 } else if (isSliderDirection(e)) { 3455 dragging = shouldStart(e); 3456 prevent(e); 3457 } 3458 } 3459 } 3460 3461 function onPointerUp(e) { 3462 if (state.is(DRAGGING)) { 3463 state.set(IDLE); 3464 emit(EVENT_DRAGGED); 3465 } 3466 3467 if (dragging) { 3468 move(e); 3469 prevent(e); 3470 } 3471 3472 unbind(target, POINTER_MOVE_EVENTS, onPointerMove); 3473 unbind(target, POINTER_UP_EVENTS, onPointerUp); 3474 dragging = false; 3475 } 3476 3477 function onClick(e) { 3478 if (!disabled && clickPrevented) { 3479 prevent(e, true); 3480 } 3481 } 3482 3483 function save(e) { 3484 prevBaseEvent = baseEvent; 3485 baseEvent = e; 3486 basePosition = getPosition(); 3487 } 3488 3489 function move(e) { 3490 var velocity = computeVelocity(e); 3491 var destination = computeDestination(velocity); 3492 var rewind = options.rewind && options.rewindByDrag; 3493 reduce(false); 3494 3495 if (isFree) { 3496 Controller.scroll(destination, 0, options.snap); 3497 } else if (Splide2.is(FADE)) { 3498 Controller.go(orient(sign(velocity)) < 0 ? rewind ? "<" : "-" : rewind ? ">" : "+"); 3499 } else if (Splide2.is(SLIDE) && exceeded && rewind) { 3500 Controller.go(exceededLimit(true) ? ">" : "<"); 3501 } else { 3502 Controller.go(Controller.toDest(destination), true); 3503 } 3504 3505 reduce(true); 3506 } 3507 3508 function shouldStart(e) { 3509 var thresholds = options.dragMinThreshold; 3510 var isObj = isObject(thresholds); 3511 var mouse = isObj && thresholds.mouse || 0; 3512 var touch = (isObj ? thresholds.touch : +thresholds) || 10; 3513 return abs(diffCoord(e)) > (isTouchEvent(e) ? touch : mouse); 3514 } 3515 3516 function isSliderDirection(e) { 3517 return abs(diffCoord(e)) > abs(diffCoord(e, true)); 3518 } 3519 3520 function computeVelocity(e) { 3521 if (Splide2.is(LOOP) || !exceeded) { 3522 var time = diffTime(e); 3523 3524 if (time && time < LOG_INTERVAL) { 3525 return diffCoord(e) / time; 3526 } 3527 } 3528 3529 return 0; 3530 } 3531 3532 function computeDestination(velocity) { 3533 return getPosition() + sign(velocity) * min(abs(velocity) * (options.flickPower || 600), isFree ? Infinity : Components2.Layout.listSize() * (options.flickMaxPages || 1)); 3534 } 3535 3536 function diffCoord(e, orthogonal) { 3537 return coordOf(e, orthogonal) - coordOf(getBaseEvent(e), orthogonal); 3538 } 3539 3540 function diffTime(e) { 3541 return timeOf(e) - timeOf(getBaseEvent(e)); 3542 } 3543 3544 function getBaseEvent(e) { 3545 return baseEvent === e && prevBaseEvent || baseEvent; 3546 } 3547 3548 function coordOf(e, orthogonal) { 3549 return (isTouchEvent(e) ? e.changedTouches[0] : e)["page" + resolve(orthogonal ? "Y" : "X")]; 3550 } 3551 3552 function constrain(diff) { 3553 return diff / (exceeded && Splide2.is(SLIDE) ? FRICTION : 1); 3554 } 3555 3556 function isDraggable(target2) { 3557 var noDrag = options.noDrag; 3558 return !matches(target2, "." + CLASS_PAGINATION_PAGE + ", ." + CLASS_ARROW) && (!noDrag || !matches(target2, noDrag)); 3559 } 3560 3561 function isTouchEvent(e) { 3562 return typeof TouchEvent !== "undefined" && e instanceof TouchEvent; 3563 } 3564 3565 function isDragging() { 3566 return dragging; 3567 } 3568 3569 function disable(value) { 3570 disabled = value; 3571 } 3572 3573 return { 3574 mount: mount, 3575 disable: disable, 3576 isDragging: isDragging 3577 }; 3578} 3579 3580var NORMALIZATION_MAP = { 3581 Spacebar: " ", 3582 Right: ARROW_RIGHT, 3583 Left: ARROW_LEFT, 3584 Up: ARROW_UP, 3585 Down: ARROW_DOWN 3586}; 3587 3588function normalizeKey(key) { 3589 key = isString(key) ? key : key.key; 3590 return NORMALIZATION_MAP[key] || key; 3591} 3592 3593var KEYBOARD_EVENT = "keydown"; 3594 3595function Keyboard(Splide2, Components2, options) { 3596 var _EventInterface10 = EventInterface(Splide2), 3597 on = _EventInterface10.on, 3598 bind = _EventInterface10.bind, 3599 unbind = _EventInterface10.unbind; 3600 3601 var root = Splide2.root; 3602 var resolve = Components2.Direction.resolve; 3603 var target; 3604 var disabled; 3605 3606 function mount() { 3607 init(); 3608 on(EVENT_UPDATED, destroy); 3609 on(EVENT_UPDATED, init); 3610 on(EVENT_MOVE, onMove); 3611 } 3612 3613 function init() { 3614 var keyboard = options.keyboard; 3615 3616 if (keyboard) { 3617 target = keyboard === "global" ? window : root; 3618 bind(target, KEYBOARD_EVENT, onKeydown); 3619 } 3620 } 3621 3622 function destroy() { 3623 unbind(target, KEYBOARD_EVENT); 3624 } 3625 3626 function disable(value) { 3627 disabled = value; 3628 } 3629 3630 function onMove() { 3631 var _disabled = disabled; 3632 disabled = true; 3633 nextTick(function () { 3634 disabled = _disabled; 3635 }); 3636 } 3637 3638 function onKeydown(e) { 3639 if (!disabled) { 3640 var key = normalizeKey(e); 3641 3642 if (key === resolve(ARROW_LEFT)) { 3643 Splide2.go("<"); 3644 } else if (key === resolve(ARROW_RIGHT)) { 3645 Splide2.go(">"); 3646 } 3647 } 3648 } 3649 3650 return { 3651 mount: mount, 3652 destroy: destroy, 3653 disable: disable 3654 }; 3655} 3656 3657var SRC_DATA_ATTRIBUTE = DATA_ATTRIBUTE + "-lazy"; 3658var SRCSET_DATA_ATTRIBUTE = SRC_DATA_ATTRIBUTE + "-srcset"; 3659var IMAGE_SELECTOR = "[" + SRC_DATA_ATTRIBUTE + "], [" + SRCSET_DATA_ATTRIBUTE + "]"; 3660 3661function LazyLoad(Splide2, Components2, options) { 3662 var _EventInterface11 = EventInterface(Splide2), 3663 on = _EventInterface11.on, 3664 off = _EventInterface11.off, 3665 bind = _EventInterface11.bind, 3666 emit = _EventInterface11.emit; 3667 3668 var isSequential = options.lazyLoad === "sequential"; 3669 var events = [EVENT_MOVED, EVENT_SCROLLED]; 3670 var entries = []; 3671 3672 function mount() { 3673 if (options.lazyLoad) { 3674 init(); 3675 on(EVENT_REFRESH, init); 3676 } 3677 } 3678 3679 function init() { 3680 empty(entries); 3681 register(); 3682 3683 if (isSequential) { 3684 loadNext(); 3685 } else { 3686 off(events); 3687 on(events, check); 3688 check(); 3689 } 3690 } 3691 3692 function register() { 3693 Components2.Slides.forEach(function (Slide) { 3694 queryAll(Slide.slide, IMAGE_SELECTOR).forEach(function (img) { 3695 var src = getAttribute(img, SRC_DATA_ATTRIBUTE); 3696 var srcset = getAttribute(img, SRCSET_DATA_ATTRIBUTE); 3697 3698 if (src !== img.src || srcset !== img.srcset) { 3699 var className = options.classes.spinner; 3700 var parent = img.parentElement; 3701 var spinner = child(parent, "." + className) || create("span", className, parent); 3702 entries.push([img, Slide, spinner]); 3703 img.src || display(img, "none"); 3704 } 3705 }); 3706 }); 3707 } 3708 3709 function check() { 3710 entries = entries.filter(function (data) { 3711 var distance = options.perPage * ((options.preloadPages || 1) + 1) - 1; 3712 return data[1].isWithin(Splide2.index, distance) ? load(data) : true; 3713 }); 3714 entries.length || off(events); 3715 } 3716 3717 function load(data) { 3718 var img = data[0]; 3719 addClass(data[1].slide, CLASS_LOADING); 3720 bind(img, "load error", apply(onLoad, data)); 3721 setAttribute(img, "src", getAttribute(img, SRC_DATA_ATTRIBUTE)); 3722 setAttribute(img, "srcset", getAttribute(img, SRCSET_DATA_ATTRIBUTE)); 3723 removeAttribute(img, SRC_DATA_ATTRIBUTE); 3724 removeAttribute(img, SRCSET_DATA_ATTRIBUTE); 3725 } 3726 3727 function onLoad(data, e) { 3728 var img = data[0], 3729 Slide = data[1]; 3730 removeClass(Slide.slide, CLASS_LOADING); 3731 3732 if (e.type !== "error") { 3733 remove(data[2]); 3734 display(img, ""); 3735 emit(EVENT_LAZYLOAD_LOADED, img, Slide); 3736 emit(EVENT_RESIZE); 3737 } 3738 3739 isSequential && loadNext(); 3740 } 3741 3742 function loadNext() { 3743 entries.length && load(entries.shift()); 3744 } 3745 3746 return { 3747 mount: mount, 3748 destroy: apply(empty, entries), 3749 check: check 3750 }; 3751} 3752 3753function Pagination(Splide2, Components2, options) { 3754 var event = EventInterface(Splide2); 3755 var on = event.on, 3756 emit = event.emit, 3757 bind = event.bind; 3758 var Slides = Components2.Slides, 3759 Elements = Components2.Elements, 3760 Controller = Components2.Controller; 3761 var hasFocus = Controller.hasFocus, 3762 getIndex = Controller.getIndex, 3763 go = Controller.go; 3764 var resolve = Components2.Direction.resolve; 3765 var placeholder = Elements.pagination; 3766 var items = []; 3767 var list; 3768 var paginationClasses; 3769 3770 function mount() { 3771 destroy(); 3772 on([EVENT_UPDATED, EVENT_REFRESH, EVENT_END_INDEX_CHANGED], mount); 3773 var enabled = options.pagination; 3774 placeholder && display(placeholder, enabled ? "" : "none"); 3775 3776 if (enabled) { 3777 on([EVENT_MOVE, EVENT_SCROLL, EVENT_SCROLLED], update); 3778 createPagination(); 3779 update(); 3780 emit(EVENT_PAGINATION_MOUNTED, { 3781 list: list, 3782 items: items 3783 }, getAt(Splide2.index)); 3784 } 3785 } 3786 3787 function destroy() { 3788 if (list) { 3789 remove(placeholder ? slice(list.children) : list); 3790 removeClass(list, paginationClasses); 3791 empty(items); 3792 list = null; 3793 } 3794 3795 event.destroy(); 3796 } 3797 3798 function createPagination() { 3799 var length = Splide2.length; 3800 var classes = options.classes, 3801 i18n = options.i18n, 3802 perPage = options.perPage; 3803 var max = hasFocus() ? Controller.getEnd() + 1 : ceil(length / perPage); 3804 list = placeholder || create("ul", classes.pagination, Elements.track.parentElement); 3805 addClass(list, paginationClasses = CLASS_PAGINATION + "--" + getDirection()); 3806 setAttribute(list, ROLE, "tablist"); 3807 setAttribute(list, ARIA_LABEL, i18n.select); 3808 setAttribute(list, ARIA_ORIENTATION, getDirection() === TTB ? "vertical" : ""); 3809 3810 for (var i = 0; i < max; i++) { 3811 var li = create("li", null, list); 3812 var button = create("button", { 3813 class: classes.page, 3814 type: "button" 3815 }, li); 3816 var controls = Slides.getIn(i).map(function (Slide) { 3817 return Slide.slide.id; 3818 }); 3819 var text = !hasFocus() && perPage > 1 ? i18n.pageX : i18n.slideX; 3820 bind(button, "click", apply(onClick, i)); 3821 3822 if (options.paginationKeyboard) { 3823 bind(button, "keydown", apply(onKeydown, i)); 3824 } 3825 3826 setAttribute(li, ROLE, "presentation"); 3827 setAttribute(button, ROLE, "tab"); 3828 setAttribute(button, ARIA_CONTROLS, controls.join(" ")); 3829 setAttribute(button, ARIA_LABEL, format(text, i + 1)); 3830 setAttribute(button, TAB_INDEX, -1); 3831 items.push({ 3832 li: li, 3833 button: button, 3834 page: i 3835 }); 3836 } 3837 } 3838 3839 function onClick(page) { 3840 go(">" + page, true); 3841 } 3842 3843 function onKeydown(page, e) { 3844 var length = items.length; 3845 var key = normalizeKey(e); 3846 var dir = getDirection(); 3847 var nextPage = -1; 3848 3849 if (key === resolve(ARROW_RIGHT, false, dir)) { 3850 nextPage = ++page % length; 3851 } else if (key === resolve(ARROW_LEFT, false, dir)) { 3852 nextPage = (--page + length) % length; 3853 } else if (key === "Home") { 3854 nextPage = 0; 3855 } else if (key === "End") { 3856 nextPage = length - 1; 3857 } 3858 3859 var item = items[nextPage]; 3860 3861 if (item) { 3862 focus(item.button); 3863 go(">" + nextPage); 3864 prevent(e, true); 3865 } 3866 } 3867 3868 function getDirection() { 3869 return options.paginationDirection || options.direction; 3870 } 3871 3872 function getAt(index) { 3873 return items[Controller.toPage(index)]; 3874 } 3875 3876 function update() { 3877 var prev = getAt(getIndex(true)); 3878 var curr = getAt(getIndex()); 3879 3880 if (prev) { 3881 var button = prev.button; 3882 removeClass(button, CLASS_ACTIVE); 3883 removeAttribute(button, ARIA_SELECTED); 3884 setAttribute(button, TAB_INDEX, -1); 3885 } 3886 3887 if (curr) { 3888 var _button = curr.button; 3889 addClass(_button, CLASS_ACTIVE); 3890 setAttribute(_button, ARIA_SELECTED, true); 3891 setAttribute(_button, TAB_INDEX, ""); 3892 } 3893 3894 emit(EVENT_PAGINATION_UPDATED, { 3895 list: list, 3896 items: items 3897 }, prev, curr); 3898 } 3899 3900 return { 3901 items: items, 3902 mount: mount, 3903 destroy: destroy, 3904 getAt: getAt, 3905 update: update 3906 }; 3907} 3908 3909var TRIGGER_KEYS = [" ", "Enter"]; 3910 3911function Sync(Splide2, Components2, options) { 3912 var isNavigation = options.isNavigation, 3913 slideFocus = options.slideFocus; 3914 var events = []; 3915 3916 function mount() { 3917 Splide2.splides.forEach(function (target) { 3918 if (!target.isParent) { 3919 sync(Splide2, target.splide); 3920 sync(target.splide, Splide2); 3921 } 3922 }); 3923 3924 if (isNavigation) { 3925 navigate(); 3926 } 3927 } 3928 3929 function destroy() { 3930 events.forEach(function (event) { 3931 event.destroy(); 3932 }); 3933 empty(events); 3934 } 3935 3936 function remount() { 3937 destroy(); 3938 mount(); 3939 } 3940 3941 function sync(splide, target) { 3942 var event = EventInterface(splide); 3943 event.on(EVENT_MOVE, function (index, prev, dest) { 3944 target.go(target.is(LOOP) ? dest : index); 3945 }); 3946 events.push(event); 3947 } 3948 3949 function navigate() { 3950 var event = EventInterface(Splide2); 3951 var on = event.on; 3952 on(EVENT_CLICK, onClick); 3953 on(EVENT_SLIDE_KEYDOWN, onKeydown); 3954 on([EVENT_MOUNTED, EVENT_UPDATED], update); 3955 events.push(event); 3956 event.emit(EVENT_NAVIGATION_MOUNTED, Splide2.splides); 3957 } 3958 3959 function update() { 3960 setAttribute(Components2.Elements.list, ARIA_ORIENTATION, options.direction === TTB ? "vertical" : ""); 3961 } 3962 3963 function onClick(Slide) { 3964 Splide2.go(Slide.index); 3965 } 3966 3967 function onKeydown(Slide, e) { 3968 if (includes(TRIGGER_KEYS, normalizeKey(e))) { 3969 onClick(Slide); 3970 prevent(e); 3971 } 3972 } 3973 3974 return { 3975 setup: apply(Components2.Media.set, { 3976 slideFocus: isUndefined(slideFocus) ? isNavigation : slideFocus 3977 }, true), 3978 mount: mount, 3979 destroy: destroy, 3980 remount: remount 3981 }; 3982} 3983 3984function Wheel(Splide2, Components2, options) { 3985 var _EventInterface12 = EventInterface(Splide2), 3986 bind = _EventInterface12.bind; 3987 3988 var lastTime = 0; 3989 3990 function mount() { 3991 if (options.wheel) { 3992 bind(Components2.Elements.track, "wheel", onWheel, SCROLL_LISTENER_OPTIONS); 3993 } 3994 } 3995 3996 function onWheel(e) { 3997 if (e.cancelable) { 3998 var deltaY = e.deltaY; 3999 var backwards = deltaY < 0; 4000 var timeStamp = timeOf(e); 4001 4002 var _min = options.wheelMinThreshold || 0; 4003 4004 var sleep = options.wheelSleep || 0; 4005 4006 if (abs(deltaY) > _min && timeStamp - lastTime > sleep) { 4007 Splide2.go(backwards ? "<" : ">"); 4008 lastTime = timeStamp; 4009 } 4010 4011 shouldPrevent(backwards) && prevent(e); 4012 } 4013 } 4014 4015 function shouldPrevent(backwards) { 4016 return !options.releaseWheel || Splide2.state.is(MOVING) || Components2.Controller.getAdjacent(backwards) !== -1; 4017 } 4018 4019 return { 4020 mount: mount 4021 }; 4022} 4023 4024var SR_REMOVAL_DELAY = 90; 4025 4026function Live(Splide2, Components2, options) { 4027 var _EventInterface13 = EventInterface(Splide2), 4028 on = _EventInterface13.on; 4029 4030 var track = Components2.Elements.track; 4031 var enabled = options.live && !options.isNavigation; 4032 var sr = create("span", CLASS_SR); 4033 var interval = RequestInterval(SR_REMOVAL_DELAY, apply(toggle, false)); 4034 4035 function mount() { 4036 if (enabled) { 4037 disable(!Components2.Autoplay.isPaused()); 4038 setAttribute(track, ARIA_ATOMIC, true); 4039 sr.textContent = "\u2026"; 4040 on(EVENT_AUTOPLAY_PLAY, apply(disable, true)); 4041 on(EVENT_AUTOPLAY_PAUSE, apply(disable, false)); 4042 on([EVENT_MOVED, EVENT_SCROLLED], apply(toggle, true)); 4043 } 4044 } 4045 4046 function toggle(active) { 4047 setAttribute(track, ARIA_BUSY, active); 4048 4049 if (active) { 4050 append(track, sr); 4051 interval.start(); 4052 } else { 4053 remove(sr); 4054 interval.cancel(); 4055 } 4056 } 4057 4058 function destroy() { 4059 removeAttribute(track, [ARIA_LIVE, ARIA_ATOMIC, ARIA_BUSY]); 4060 remove(sr); 4061 } 4062 4063 function disable(disabled) { 4064 if (enabled) { 4065 setAttribute(track, ARIA_LIVE, disabled ? "off" : "polite"); 4066 } 4067 } 4068 4069 return { 4070 mount: mount, 4071 disable: disable, 4072 destroy: destroy 4073 }; 4074} 4075 4076var ComponentConstructors = /*#__PURE__*/Object.freeze({ 4077 __proto__: null, 4078 Media: Media, 4079 Direction: Direction, 4080 Elements: Elements, 4081 Slides: Slides, 4082 Layout: Layout, 4083 Clones: Clones, 4084 Move: Move, 4085 Controller: Controller, 4086 Arrows: Arrows, 4087 Autoplay: Autoplay, 4088 Cover: Cover, 4089 Scroll: Scroll, 4090 Drag: Drag, 4091 Keyboard: Keyboard, 4092 LazyLoad: LazyLoad, 4093 Pagination: Pagination, 4094 Sync: Sync, 4095 Wheel: Wheel, 4096 Live: Live 4097}); 4098var I18N = { 4099 prev: "Previous slide", 4100 next: "Next slide", 4101 first: "Go to first slide", 4102 last: "Go to last slide", 4103 slideX: "Go to slide %s", 4104 pageX: "Go to page %s", 4105 play: "Start autoplay", 4106 pause: "Pause autoplay", 4107 carousel: "carousel", 4108 slide: "slide", 4109 select: "Select a slide to show", 4110 slideLabel: "%s of %s" 4111}; 4112var DEFAULTS = { 4113 type: "slide", 4114 role: "region", 4115 speed: 400, 4116 perPage: 1, 4117 cloneStatus: true, 4118 arrows: true, 4119 pagination: true, 4120 paginationKeyboard: true, 4121 interval: 5e3, 4122 pauseOnHover: true, 4123 pauseOnFocus: true, 4124 resetProgress: true, 4125 easing: "cubic-bezier(0.25, 1, 0.5, 1)", 4126 drag: true, 4127 direction: "ltr", 4128 trimSpace: true, 4129 focusableNodes: "a, button, textarea, input, select, iframe", 4130 live: true, 4131 classes: CLASSES, 4132 i18n: I18N, 4133 reducedMotion: { 4134 speed: 0, 4135 rewindSpeed: 0, 4136 autoplay: "pause" 4137 } 4138}; 4139 4140function Fade(Splide2, Components2, options) { 4141 var Slides = Components2.Slides; 4142 4143 function mount() { 4144 EventInterface(Splide2).on([EVENT_MOUNTED, EVENT_REFRESH], init); 4145 } 4146 4147 function init() { 4148 Slides.forEach(function (Slide) { 4149 Slide.style("transform", "translateX(-" + 100 * Slide.index + "%)"); 4150 }); 4151 } 4152 4153 function start(index, done) { 4154 Slides.style("transition", "opacity " + options.speed + "ms " + options.easing); 4155 nextTick(done); 4156 } 4157 4158 return { 4159 mount: mount, 4160 start: start, 4161 cancel: noop 4162 }; 4163} 4164 4165function Slide(Splide2, Components2, options) { 4166 var Move = Components2.Move, 4167 Controller = Components2.Controller, 4168 Scroll = Components2.Scroll; 4169 var list = Components2.Elements.list; 4170 var transition = apply(style, list, "transition"); 4171 var endCallback; 4172 4173 function mount() { 4174 EventInterface(Splide2).bind(list, "transitionend", function (e) { 4175 if (e.target === list && endCallback) { 4176 cancel(); 4177 endCallback(); 4178 } 4179 }); 4180 } 4181 4182 function start(index, done) { 4183 var destination = Move.toPosition(index, true); 4184 var position = Move.getPosition(); 4185 var speed = getSpeed(index); 4186 4187 if (abs(destination - position) >= 1 && speed >= 1) { 4188 if (options.useScroll) { 4189 Scroll.scroll(destination, speed, false, done); 4190 } else { 4191 transition("transform " + speed + "ms " + options.easing); 4192 Move.translate(destination, true); 4193 endCallback = done; 4194 } 4195 } else { 4196 Move.jump(index); 4197 done(); 4198 } 4199 } 4200 4201 function cancel() { 4202 transition(""); 4203 Scroll.cancel(); 4204 } 4205 4206 function getSpeed(index) { 4207 var rewindSpeed = options.rewindSpeed; 4208 4209 if (Splide2.is(SLIDE) && rewindSpeed) { 4210 var prev = Controller.getIndex(true); 4211 var end = Controller.getEnd(); 4212 4213 if (prev === 0 && index >= end || prev >= end && index === 0) { 4214 return rewindSpeed; 4215 } 4216 } 4217 4218 return options.speed; 4219 } 4220 4221 return { 4222 mount: mount, 4223 start: start, 4224 cancel: cancel 4225 }; 4226} 4227 4228var _Splide = /*#__PURE__*/function () { 4229 function _Splide(target, options) { 4230 this.event = EventInterface(); 4231 this.Components = {}; 4232 this.state = State(CREATED); 4233 this.splides = []; 4234 this._o = {}; 4235 this._E = {}; 4236 var root = isString(target) ? query(document, target) : target; 4237 assert(root, root + " is invalid."); 4238 this.root = root; 4239 options = merge({ 4240 label: getAttribute(root, ARIA_LABEL) || "", 4241 labelledby: getAttribute(root, ARIA_LABELLEDBY) || "" 4242 }, DEFAULTS, _Splide.defaults, options || {}); 4243 4244 try { 4245 merge(options, JSON.parse(getAttribute(root, DATA_ATTRIBUTE))); 4246 } catch (e) { 4247 assert(false, "Invalid JSON"); 4248 } 4249 4250 this._o = Object.create(merge({}, options)); 4251 } 4252 4253 var _proto = _Splide.prototype; 4254 4255 _proto.mount = function mount(Extensions, Transition) { 4256 var _this = this; 4257 4258 var state = this.state, 4259 Components2 = this.Components; 4260 assert(state.is([CREATED, DESTROYED]), "Already mounted!"); 4261 state.set(CREATED); 4262 this._C = Components2; 4263 this._T = Transition || this._T || (this.is(FADE) ? Fade : Slide); 4264 this._E = Extensions || this._E; 4265 var Constructors = assign({}, ComponentConstructors, this._E, { 4266 Transition: this._T 4267 }); 4268 forOwn(Constructors, function (Component, key) { 4269 var component = Component(_this, Components2, _this._o); 4270 Components2[key] = component; 4271 component.setup && component.setup(); 4272 }); 4273 forOwn(Components2, function (component) { 4274 component.mount && component.mount(); 4275 }); 4276 this.emit(EVENT_MOUNTED); 4277 addClass(this.root, CLASS_INITIALIZED); 4278 state.set(IDLE); 4279 this.emit(EVENT_READY); 4280 return this; 4281 }; 4282 4283 _proto.sync = function sync(splide) { 4284 this.splides.push({ 4285 splide: splide 4286 }); 4287 splide.splides.push({ 4288 splide: this, 4289 isParent: true 4290 }); 4291 4292 if (this.state.is(IDLE)) { 4293 this._C.Sync.remount(); 4294 4295 splide.Components.Sync.remount(); 4296 } 4297 4298 return this; 4299 }; 4300 4301 _proto.go = function go(control) { 4302 this._C.Controller.go(control); 4303 4304 return this; 4305 }; 4306 4307 _proto.on = function on(events, callback) { 4308 this.event.on(events, callback); 4309 return this; 4310 }; 4311 4312 _proto.off = function off(events) { 4313 this.event.off(events); 4314 return this; 4315 }; 4316 4317 _proto.emit = function emit(event) { 4318 var _this$event; 4319 4320 (_this$event = this.event).emit.apply(_this$event, [event].concat(slice(arguments, 1))); 4321 4322 return this; 4323 }; 4324 4325 _proto.add = function add(slides, index) { 4326 this._C.Slides.add(slides, index); 4327 4328 return this; 4329 }; 4330 4331 _proto.remove = function remove(matcher) { 4332 this._C.Slides.remove(matcher); 4333 4334 return this; 4335 }; 4336 4337 _proto.is = function is(type) { 4338 return this._o.type === type; 4339 }; 4340 4341 _proto.refresh = function refresh() { 4342 this.emit(EVENT_REFRESH); 4343 return this; 4344 }; 4345 4346 _proto.destroy = function destroy(completely) { 4347 if (completely === void 0) { 4348 completely = true; 4349 } 4350 4351 var event = this.event, 4352 state = this.state; 4353 4354 if (state.is(CREATED)) { 4355 EventInterface(this).on(EVENT_READY, this.destroy.bind(this, completely)); 4356 } else { 4357 forOwn(this._C, function (component) { 4358 component.destroy && component.destroy(completely); 4359 }, true); 4360 event.emit(EVENT_DESTROY); 4361 event.destroy(); 4362 completely && empty(this.splides); 4363 state.set(DESTROYED); 4364 } 4365 4366 return this; 4367 }; 4368 4369 _createClass(_Splide, [{ 4370 key: "options", 4371 get: function get() { 4372 return this._o; 4373 }, 4374 set: function set(options) { 4375 this._C.Media.set(options, true, true); 4376 } 4377 }, { 4378 key: "length", 4379 get: function get() { 4380 return this._C.Slides.getLength(true); 4381 } 4382 }, { 4383 key: "index", 4384 get: function get() { 4385 return this._C.Controller.getIndex(); 4386 } 4387 }]); 4388 4389 return _Splide; 4390}(); 4391 4392var Splide = _Splide; 4393Splide.defaults = {}; 4394Splide.STATES = STATES; 4395var CLASS_RENDERED = "is-rendered"; 4396var RENDERER_DEFAULT_CONFIG = { 4397 listTag: "ul", 4398 slideTag: "li" 4399}; 4400 4401var Style = /*#__PURE__*/function () { 4402 function Style(id, options) { 4403 this.styles = {}; 4404 this.id = id; 4405 this.options = options; 4406 } 4407 4408 var _proto2 = Style.prototype; 4409 4410 _proto2.rule = function rule(selector, prop, value, breakpoint) { 4411 breakpoint = breakpoint || "default"; 4412 var selectors = this.styles[breakpoint] = this.styles[breakpoint] || {}; 4413 var styles = selectors[selector] = selectors[selector] || {}; 4414 styles[prop] = value; 4415 }; 4416 4417 _proto2.build = function build() { 4418 var _this2 = this; 4419 4420 var css = ""; 4421 4422 if (this.styles.default) { 4423 css += this.buildSelectors(this.styles.default); 4424 } 4425 4426 Object.keys(this.styles).sort(function (n, m) { 4427 return _this2.options.mediaQuery === "min" ? +n - +m : +m - +n; 4428 }).forEach(function (breakpoint) { 4429 if (breakpoint !== "default") { 4430 css += "@media screen and (max-width: " + breakpoint + "px) {"; 4431 css += _this2.buildSelectors(_this2.styles[breakpoint]); 4432 css += "}"; 4433 } 4434 }); 4435 return css; 4436 }; 4437 4438 _proto2.buildSelectors = function buildSelectors(selectors) { 4439 var _this3 = this; 4440 4441 var css = ""; 4442 forOwn(selectors, function (styles, selector) { 4443 selector = ("#" + _this3.id + " " + selector).trim(); 4444 css += selector + " {"; 4445 forOwn(styles, function (value, prop) { 4446 if (value || value === 0) { 4447 css += prop + ": " + value + ";"; 4448 } 4449 }); 4450 css += "}"; 4451 }); 4452 return css; 4453 }; 4454 4455 return Style; 4456}(); 4457 4458var SplideRenderer = /*#__PURE__*/function () { 4459 function SplideRenderer(contents, options, config, defaults) { 4460 this.slides = []; 4461 this.options = {}; 4462 this.breakpoints = []; 4463 merge(DEFAULTS, defaults || {}); 4464 merge(merge(this.options, DEFAULTS), options || {}); 4465 this.contents = contents; 4466 this.config = assign({}, RENDERER_DEFAULT_CONFIG, config || {}); 4467 this.id = this.config.id || uniqueId("splide"); 4468 this.Style = new Style(this.id, this.options); 4469 this.Direction = Direction(null, null, this.options); 4470 assert(this.contents.length, "Provide at least 1 content."); 4471 this.init(); 4472 } 4473 4474 SplideRenderer.clean = function clean(splide) { 4475 var _EventInterface14 = EventInterface(splide), 4476 on = _EventInterface14.on; 4477 4478 var root = splide.root; 4479 var clones = queryAll(root, "." + CLASS_CLONE); 4480 on(EVENT_MOUNTED, function () { 4481 remove(child(root, "style")); 4482 }); 4483 remove(clones); 4484 }; 4485 4486 var _proto3 = SplideRenderer.prototype; 4487 4488 _proto3.init = function init() { 4489 this.parseBreakpoints(); 4490 this.initSlides(); 4491 this.registerRootStyles(); 4492 this.registerTrackStyles(); 4493 this.registerSlideStyles(); 4494 this.registerListStyles(); 4495 }; 4496 4497 _proto3.initSlides = function initSlides() { 4498 var _this4 = this; 4499 4500 push(this.slides, this.contents.map(function (content, index) { 4501 content = isString(content) ? { 4502 html: content 4503 } : content; 4504 content.styles = content.styles || {}; 4505 content.attrs = content.attrs || {}; 4506 4507 _this4.cover(content); 4508 4509 var classes = _this4.options.classes.slide + " " + (index === 0 ? CLASS_ACTIVE : ""); 4510 assign(content.attrs, { 4511 class: (classes + " " + (content.attrs.class || "")).trim(), 4512 style: _this4.buildStyles(content.styles) 4513 }); 4514 return content; 4515 })); 4516 4517 if (this.isLoop()) { 4518 this.generateClones(this.slides); 4519 } 4520 }; 4521 4522 _proto3.registerRootStyles = function registerRootStyles() { 4523 var _this5 = this; 4524 4525 this.breakpoints.forEach(function (_ref2) { 4526 var width = _ref2[0], 4527 options = _ref2[1]; 4528 4529 _this5.Style.rule(" ", "max-width", unit(options.width), width); 4530 }); 4531 }; 4532 4533 _proto3.registerTrackStyles = function registerTrackStyles() { 4534 var _this6 = this; 4535 4536 var Style2 = this.Style; 4537 var selector = "." + CLASS_TRACK; 4538 this.breakpoints.forEach(function (_ref3) { 4539 var width = _ref3[0], 4540 options = _ref3[1]; 4541 Style2.rule(selector, _this6.resolve("paddingLeft"), _this6.cssPadding(options, false), width); 4542 Style2.rule(selector, _this6.resolve("paddingRight"), _this6.cssPadding(options, true), width); 4543 Style2.rule(selector, "height", _this6.cssTrackHeight(options), width); 4544 }); 4545 }; 4546 4547 _proto3.registerListStyles = function registerListStyles() { 4548 var _this7 = this; 4549 4550 var Style2 = this.Style; 4551 var selector = "." + CLASS_LIST; 4552 this.breakpoints.forEach(function (_ref4) { 4553 var width = _ref4[0], 4554 options = _ref4[1]; 4555 Style2.rule(selector, "transform", _this7.buildTranslate(options), width); 4556 4557 if (!_this7.cssSlideHeight(options)) { 4558 Style2.rule(selector, "aspect-ratio", _this7.cssAspectRatio(options), width); 4559 } 4560 }); 4561 }; 4562 4563 _proto3.registerSlideStyles = function registerSlideStyles() { 4564 var _this8 = this; 4565 4566 var Style2 = this.Style; 4567 var selector = "." + CLASS_SLIDE; 4568 this.breakpoints.forEach(function (_ref5) { 4569 var width = _ref5[0], 4570 options = _ref5[1]; 4571 Style2.rule(selector, "width", _this8.cssSlideWidth(options), width); 4572 Style2.rule(selector, "height", _this8.cssSlideHeight(options) || "100%", width); 4573 Style2.rule(selector, _this8.resolve("marginRight"), unit(options.gap) || "0px", width); 4574 Style2.rule(selector + " > img", "display", options.cover ? "none" : "inline", width); 4575 }); 4576 }; 4577 4578 _proto3.buildTranslate = function buildTranslate(options) { 4579 var _this$Direction = this.Direction, 4580 resolve = _this$Direction.resolve, 4581 orient = _this$Direction.orient; 4582 var values = []; 4583 values.push(this.cssOffsetClones(options)); 4584 values.push(this.cssOffsetGaps(options)); 4585 4586 if (this.isCenter(options)) { 4587 values.push(this.buildCssValue(orient(-50), "%")); 4588 values.push.apply(values, this.cssOffsetCenter(options)); 4589 } 4590 4591 return values.filter(Boolean).map(function (value) { 4592 return "translate" + resolve("X") + "(" + value + ")"; 4593 }).join(" "); 4594 }; 4595 4596 _proto3.cssOffsetClones = function cssOffsetClones(options) { 4597 var _this$Direction2 = this.Direction, 4598 resolve = _this$Direction2.resolve, 4599 orient = _this$Direction2.orient; 4600 var cloneCount = this.getCloneCount(); 4601 4602 if (this.isFixedWidth(options)) { 4603 var _this$parseCssValue = this.parseCssValue(options[resolve("fixedWidth")]), 4604 value = _this$parseCssValue.value, 4605 unit2 = _this$parseCssValue.unit; 4606 4607 return this.buildCssValue(orient(value) * cloneCount, unit2); 4608 } 4609 4610 var percent = 100 * cloneCount / options.perPage; 4611 return orient(percent) + "%"; 4612 }; 4613 4614 _proto3.cssOffsetCenter = function cssOffsetCenter(options) { 4615 var _this$Direction3 = this.Direction, 4616 resolve = _this$Direction3.resolve, 4617 orient = _this$Direction3.orient; 4618 4619 if (this.isFixedWidth(options)) { 4620 var _this$parseCssValue2 = this.parseCssValue(options[resolve("fixedWidth")]), 4621 value = _this$parseCssValue2.value, 4622 unit2 = _this$parseCssValue2.unit; 4623 4624 return [this.buildCssValue(orient(value / 2), unit2)]; 4625 } 4626 4627 var values = []; 4628 var perPage = options.perPage, 4629 gap = options.gap; 4630 values.push(orient(50 / perPage) + "%"); 4631 4632 if (gap) { 4633 var _this$parseCssValue3 = this.parseCssValue(gap), 4634 _value = _this$parseCssValue3.value, 4635 _unit = _this$parseCssValue3.unit; 4636 4637 var gapOffset = (_value / perPage - _value) / 2; 4638 values.push(this.buildCssValue(orient(gapOffset), _unit)); 4639 } 4640 4641 return values; 4642 }; 4643 4644 _proto3.cssOffsetGaps = function cssOffsetGaps(options) { 4645 var cloneCount = this.getCloneCount(); 4646 4647 if (cloneCount && options.gap) { 4648 var orient = this.Direction.orient; 4649 4650 var _this$parseCssValue4 = this.parseCssValue(options.gap), 4651 value = _this$parseCssValue4.value, 4652 unit2 = _this$parseCssValue4.unit; 4653 4654 if (this.isFixedWidth(options)) { 4655 return this.buildCssValue(orient(value * cloneCount), unit2); 4656 } 4657 4658 var perPage = options.perPage; 4659 var gaps = cloneCount / perPage; 4660 return this.buildCssValue(orient(gaps * value), unit2); 4661 } 4662 4663 return ""; 4664 }; 4665 4666 _proto3.resolve = function resolve(prop) { 4667 return camelToKebab(this.Direction.resolve(prop)); 4668 }; 4669 4670 _proto3.cssPadding = function cssPadding(options, right) { 4671 var padding = options.padding; 4672 var prop = this.Direction.resolve(right ? "right" : "left", true); 4673 return padding && unit(padding[prop] || (isObject(padding) ? 0 : padding)) || "0px"; 4674 }; 4675 4676 _proto3.cssTrackHeight = function cssTrackHeight(options) { 4677 var height = ""; 4678 4679 if (this.isVertical()) { 4680 height = this.cssHeight(options); 4681 assert(height, '"height" is missing.'); 4682 height = "calc(" + height + " - " + this.cssPadding(options, false) + " - " + this.cssPadding(options, true) + ")"; 4683 } 4684 4685 return height; 4686 }; 4687 4688 _proto3.cssHeight = function cssHeight(options) { 4689 return unit(options.height); 4690 }; 4691 4692 _proto3.cssSlideWidth = function cssSlideWidth(options) { 4693 return options.autoWidth ? "" : unit(options.fixedWidth) || (this.isVertical() ? "" : this.cssSlideSize(options)); 4694 }; 4695 4696 _proto3.cssSlideHeight = function cssSlideHeight(options) { 4697 return unit(options.fixedHeight) || (this.isVertical() ? options.autoHeight ? "" : this.cssSlideSize(options) : this.cssHeight(options)); 4698 }; 4699 4700 _proto3.cssSlideSize = function cssSlideSize(options) { 4701 var gap = unit(options.gap); 4702 return "calc((100%" + (gap && " + " + gap) + ")/" + (options.perPage || 1) + (gap && " - " + gap) + ")"; 4703 }; 4704 4705 _proto3.cssAspectRatio = function cssAspectRatio(options) { 4706 var heightRatio = options.heightRatio; 4707 return heightRatio ? "" + 1 / heightRatio : ""; 4708 }; 4709 4710 _proto3.buildCssValue = function buildCssValue(value, unit2) { 4711 return "" + value + unit2; 4712 }; 4713 4714 _proto3.parseCssValue = function parseCssValue(value) { 4715 if (isString(value)) { 4716 var number = parseFloat(value) || 0; 4717 var unit2 = value.replace(/\d*(\.\d*)?/, "") || "px"; 4718 return { 4719 value: number, 4720 unit: unit2 4721 }; 4722 } 4723 4724 return { 4725 value: value, 4726 unit: "px" 4727 }; 4728 }; 4729 4730 _proto3.parseBreakpoints = function parseBreakpoints() { 4731 var _this9 = this; 4732 4733 var breakpoints = this.options.breakpoints; 4734 this.breakpoints.push(["default", this.options]); 4735 4736 if (breakpoints) { 4737 forOwn(breakpoints, function (options, width) { 4738 _this9.breakpoints.push([width, merge(merge({}, _this9.options), options)]); 4739 }); 4740 } 4741 }; 4742 4743 _proto3.isFixedWidth = function isFixedWidth(options) { 4744 return !!options[this.Direction.resolve("fixedWidth")]; 4745 }; 4746 4747 _proto3.isLoop = function isLoop() { 4748 return this.options.type === LOOP; 4749 }; 4750 4751 _proto3.isCenter = function isCenter(options) { 4752 if (options.focus === "center") { 4753 if (this.isLoop()) { 4754 return true; 4755 } 4756 4757 if (this.options.type === SLIDE) { 4758 return !this.options.trimSpace; 4759 } 4760 } 4761 4762 return false; 4763 }; 4764 4765 _proto3.isVertical = function isVertical() { 4766 return this.options.direction === TTB; 4767 }; 4768 4769 _proto3.buildClasses = function buildClasses() { 4770 var options = this.options; 4771 return [CLASS_ROOT, CLASS_ROOT + "--" + options.type, CLASS_ROOT + "--" + options.direction, options.drag && CLASS_ROOT + "--draggable", options.isNavigation && CLASS_ROOT + "--nav", CLASS_ACTIVE, !this.config.hidden && CLASS_RENDERED].filter(Boolean).join(" "); 4772 }; 4773 4774 _proto3.buildAttrs = function buildAttrs(attrs) { 4775 var attr = ""; 4776 forOwn(attrs, function (value, key) { 4777 attr += value ? " " + camelToKebab(key) + "=\"" + value + "\"" : ""; 4778 }); 4779 return attr.trim(); 4780 }; 4781 4782 _proto3.buildStyles = function buildStyles(styles) { 4783 var style = ""; 4784 forOwn(styles, function (value, key) { 4785 style += " " + camelToKebab(key) + ":" + value + ";"; 4786 }); 4787 return style.trim(); 4788 }; 4789 4790 _proto3.renderSlides = function renderSlides() { 4791 var _this10 = this; 4792 4793 var tag = this.config.slideTag; 4794 return this.slides.map(function (content) { 4795 return "<" + tag + " " + _this10.buildAttrs(content.attrs) + ">" + (content.html || "") + "</" + tag + ">"; 4796 }).join(""); 4797 }; 4798 4799 _proto3.cover = function cover(content) { 4800 var styles = content.styles, 4801 _content$html = content.html, 4802 html = _content$html === void 0 ? "" : _content$html; 4803 4804 if (this.options.cover && !this.options.lazyLoad) { 4805 var src = html.match(/<img.*?src\s*=\s*(['"])(.+?)\1.*?>/); 4806 4807 if (src && src[2]) { 4808 styles.background = "center/cover no-repeat url('" + src[2] + "')"; 4809 } 4810 } 4811 }; 4812 4813 _proto3.generateClones = function generateClones(contents) { 4814 var classes = this.options.classes; 4815 var count = this.getCloneCount(); 4816 var slides = contents.slice(); 4817 4818 while (slides.length < count) { 4819 push(slides, slides); 4820 } 4821 4822 push(slides.slice(-count).reverse(), slides.slice(0, count)).forEach(function (content, index) { 4823 var attrs = assign({}, content.attrs, { 4824 class: content.attrs.class + " " + classes.clone 4825 }); 4826 var clone = assign({}, content, { 4827 attrs: attrs 4828 }); 4829 index < count ? contents.unshift(clone) : contents.push(clone); 4830 }); 4831 }; 4832 4833 _proto3.getCloneCount = function getCloneCount() { 4834 if (this.isLoop()) { 4835 var options = this.options; 4836 4837 if (options.clones) { 4838 return options.clones; 4839 } 4840 4841 var perPage = max.apply(void 0, this.breakpoints.map(function (_ref6) { 4842 var options2 = _ref6[1]; 4843 return options2.perPage; 4844 })); 4845 return perPage * ((options.flickMaxPages || 1) + 1); 4846 } 4847 4848 return 0; 4849 }; 4850 4851 _proto3.renderArrows = function renderArrows() { 4852 var html = ""; 4853 html += "<div class=\"" + this.options.classes.arrows + "\">"; 4854 html += this.renderArrow(true); 4855 html += this.renderArrow(false); 4856 html += "</div>"; 4857 return html; 4858 }; 4859 4860 _proto3.renderArrow = function renderArrow(prev) { 4861 var _this$options = this.options, 4862 classes = _this$options.classes, 4863 i18n = _this$options.i18n; 4864 var attrs = { 4865 class: classes.arrow + " " + (prev ? classes.prev : classes.next), 4866 type: "button", 4867 ariaLabel: prev ? i18n.prev : i18n.next 4868 }; 4869 return "<button " + this.buildAttrs(attrs) + "><svg xmlns=\"" + XML_NAME_SPACE + "\" viewBox=\"0 0 " + SIZE + " " + SIZE + "\" width=\"" + SIZE + "\" height=\"" + SIZE + "\"><path d=\"" + (this.options.arrowPath || PATH) + "\" /></svg></button>"; 4870 }; 4871 4872 _proto3.html = function html() { 4873 var _this$config = this.config, 4874 rootClass = _this$config.rootClass, 4875 listTag = _this$config.listTag, 4876 arrows = _this$config.arrows, 4877 beforeTrack = _this$config.beforeTrack, 4878 afterTrack = _this$config.afterTrack, 4879 slider = _this$config.slider, 4880 beforeSlider = _this$config.beforeSlider, 4881 afterSlider = _this$config.afterSlider; 4882 var html = ""; 4883 html += "<div id=\"" + this.id + "\" class=\"" + this.buildClasses() + " " + (rootClass || "") + "\">"; 4884 html += "<style>" + this.Style.build() + "</style>"; 4885 4886 if (slider) { 4887 html += beforeSlider || ""; 4888 html += "<div class=\"splide__slider\">"; 4889 } 4890 4891 html += beforeTrack || ""; 4892 4893 if (arrows) { 4894 html += this.renderArrows(); 4895 } 4896 4897 html += "<div class=\"splide__track\">"; 4898 html += "<" + listTag + " class=\"splide__list\">"; 4899 html += this.renderSlides(); 4900 html += "</" + listTag + ">"; 4901 html += "</div>"; 4902 html += afterTrack || ""; 4903 4904 if (slider) { 4905 html += "</div>"; 4906 html += afterSlider || ""; 4907 } 4908 4909 html += "</div>"; 4910 return html; 4911 }; 4912 4913 return SplideRenderer; 4914}(); 4915 4916 4917 4918 4919/***/ }), 4920
vendor: 98,708 bytes, lines 4921-8172
4921/***/ "./node_modules/alpinejs/dist/module.esm.js": 4922/*!**************************************************!*\ 4923 !*** ./node_modules/alpinejs/dist/module.esm.js ***! 4924 \**************************************************/ 4925/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 4926 4927"use strict"; 4928__webpack_require__.r(__webpack_exports__); 4929/* harmony export */ __webpack_require__.d(__webpack_exports__, { 4930/* harmony export */ "default": () => (/* binding */ module_default) 4931/* harmony export */ }); 4932// packages/alpinejs/src/scheduler.js 4933var flushPending = false; 4934var flushing = false; 4935var queue = []; 4936var lastFlushedIndex = -1; 4937function scheduler(callback) { 4938 queueJob(callback); 4939} 4940function queueJob(job) { 4941 if (!queue.includes(job)) 4942 queue.push(job); 4943 queueFlush(); 4944} 4945function dequeueJob(job) { 4946 let index = queue.indexOf(job); 4947 if (index !== -1 && index > lastFlushedIndex) 4948 queue.splice(index, 1); 4949} 4950function queueFlush() { 4951 if (!flushing && !flushPending) { 4952 flushPending = true; 4953 queueMicrotask(flushJobs); 4954 } 4955} 4956function flushJobs() { 4957 flushPending = false; 4958 flushing = true; 4959 for (let i = 0; i < queue.length; i++) { 4960 queue[i](); 4961 lastFlushedIndex = i; 4962 } 4963 queue.length = 0; 4964 lastFlushedIndex = -1; 4965 flushing = false; 4966} 4967 4968// packages/alpinejs/src/reactivity.js 4969var reactive; 4970var effect; 4971var release; 4972var raw; 4973var shouldSchedule = true; 4974function disableEffectScheduling(callback) { 4975 shouldSchedule = false; 4976 callback(); 4977 shouldSchedule = true; 4978} 4979function setReactivityEngine(engine) { 4980 reactive = engine.reactive; 4981 release = engine.release; 4982 effect = (callback) => engine.effect(callback, { scheduler: (task) => { 4983 if (shouldSchedule) { 4984 scheduler(task); 4985 } else { 4986 task(); 4987 } 4988 } }); 4989 raw = engine.raw; 4990} 4991function overrideEffect(override) { 4992 effect = override; 4993} 4994function elementBoundEffect(el) { 4995 let cleanup2 = () => { 4996 }; 4997 let wrappedEffect = (callback) => { 4998 let effectReference = effect(callback); 4999 if (!el._x_effects) { 5000 el._x_effects = /* @__PURE__ */ new Set(); 5001 el._x_runEffects = () => { 5002 el._x_effects.forEach((i) => i()); 5003 }; 5004 } 5005 el._x_effects.add(effectReference); 5006 cleanup2 = () => { 5007 if (effectReference === void 0) 5008 return; 5009 el._x_effects.delete(effectReference); 5010 release(effectReference); 5011 }; 5012 return effectReference; 5013 }; 5014 return [wrappedEffect, () => { 5015 cleanup2(); 5016 }]; 5017} 5018 5019// packages/alpinejs/src/utils/dispatch.js 5020function dispatch(el, name, detail = {}) { 5021 el.dispatchEvent( 5022 new CustomEvent(name, { 5023 detail, 5024 bubbles: true, 5025 // Allows events to pass the shadow DOM barrier. 5026 composed: true, 5027 cancelable: true 5028 }) 5029 ); 5030} 5031 5032// packages/alpinejs/src/utils/walk.js 5033function walk(el, callback) { 5034 if (typeof ShadowRoot === "function" && el instanceof ShadowRoot) { 5035 Array.from(el.children).forEach((el2) => walk(el2, callback)); 5036 return; 5037 } 5038 let skip = false; 5039 callback(el, () => skip = true); 5040 if (skip) 5041 return; 5042 let node = el.firstElementChild; 5043 while (node) { 5044 walk(node, callback, false); 5045 node = node.nextElementSibling; 5046 } 5047} 5048 5049// packages/alpinejs/src/utils/warn.js 5050function warn(message, ...args) { 5051 console.warn(`Alpine Warning: ${message}`, ...args); 5052} 5053 5054// packages/alpinejs/src/lifecycle.js 5055var started = false; 5056function start() { 5057 if (started) 5058 warn("Alpine has already been initialized on this page. Calling Alpine.start() more than once can cause problems."); 5059 started = true; 5060 if (!document.body) 5061 warn("Unable to initialize. Trying to load Alpine before `<body>` is available. Did you forget to add `defer` in Alpine's `<script>` tag?"); 5062 dispatch(document, "alpine:init"); 5063 dispatch(document, "alpine:initializing"); 5064 startObservingMutations(); 5065 onElAdded((el) => initTree(el, walk)); 5066 onElRemoved((el) => destroyTree(el)); 5067 onAttributesAdded((el, attrs) => { 5068 directives(el, attrs).forEach((handle) => handle()); 5069 }); 5070 let outNestedComponents = (el) => !closestRoot(el.parentElement, true); 5071 Array.from(document.querySelectorAll(allSelectors())).filter(outNestedComponents).forEach((el) => { 5072 initTree(el); 5073 }); 5074 dispatch(document, "alpine:initialized"); 5075} 5076var rootSelectorCallbacks = []; 5077var initSelectorCallbacks = []; 5078function rootSelectors() { 5079 return rootSelectorCallbacks.map((fn) => fn()); 5080} 5081function allSelectors() { 5082 return rootSelectorCallbacks.concat(initSelectorCallbacks).map((fn) => fn()); 5083} 5084function addRootSelector(selectorCallback) { 5085 rootSelectorCallbacks.push(selectorCallback); 5086} 5087function addInitSelector(selectorCallback) { 5088 initSelectorCallbacks.push(selectorCallback); 5089} 5090function closestRoot(el, includeInitSelectors = false) { 5091 return findClosest(el, (element) => { 5092 const selectors = includeInitSelectors ? allSelectors() : rootSelectors(); 5093 if (selectors.some((selector) => element.matches(selector))) 5094 return true; 5095 }); 5096} 5097function findClosest(el, callback) { 5098 if (!el) 5099 return; 5100 if (callback(el)) 5101 return el; 5102 if (el._x_teleportBack) 5103 el = el._x_teleportBack; 5104 if (!el.parentElement) 5105 return; 5106 return findClosest(el.parentElement, callback); 5107} 5108function isRoot(el) { 5109 return rootSelectors().some((selector) => el.matches(selector)); 5110} 5111var initInterceptors = []; 5112function interceptInit(callback) { 5113 initInterceptors.push(callback); 5114} 5115function initTree(el, walker = walk, intercept = () => { 5116}) { 5117 deferHandlingDirectives(() => { 5118 walker(el, (el2, skip) => { 5119 intercept(el2, skip); 5120 initInterceptors.forEach((i) => i(el2, skip)); 5121 directives(el2, el2.attributes).forEach((handle) => handle()); 5122 el2._x_ignore && skip(); 5123 }); 5124 }); 5125} 5126function destroyTree(root) { 5127 walk(root, (el) => { 5128 cleanupAttributes(el); 5129 cleanupElement(el); 5130 }); 5131} 5132 5133// packages/alpinejs/src/mutation.js 5134var onAttributeAddeds = []; 5135var onElRemoveds = []; 5136var onElAddeds = []; 5137function onElAdded(callback) { 5138 onElAddeds.push(callback); 5139} 5140function onElRemoved(el, callback) { 5141 if (typeof callback === "function") { 5142 if (!el._x_cleanups) 5143 el._x_cleanups = []; 5144 el._x_cleanups.push(callback); 5145 } else { 5146 callback = el; 5147 onElRemoveds.push(callback); 5148 } 5149} 5150function onAttributesAdded(callback) { 5151 onAttributeAddeds.push(callback); 5152} 5153function onAttributeRemoved(el, name, callback) { 5154 if (!el._x_attributeCleanups) 5155 el._x_attributeCleanups = {}; 5156 if (!el._x_attributeCleanups[name]) 5157 el._x_attributeCleanups[name] = []; 5158 el._x_attributeCleanups[name].push(callback); 5159} 5160function cleanupAttributes(el, names) { 5161 if (!el._x_attributeCleanups) 5162 return; 5163 Object.entries(el._x_attributeCleanups).forEach(([name, value]) => { 5164 if (names === void 0 || names.includes(name)) { 5165 value.forEach((i) => i()); 5166 delete el._x_attributeCleanups[name]; 5167 } 5168 }); 5169} 5170function cleanupElement(el) { 5171 if (el._x_cleanups) { 5172 while (el._x_cleanups.length) 5173 el._x_cleanups.pop()(); 5174 } 5175} 5176var observer = new MutationObserver(onMutate); 5177var currentlyObserving = false; 5178function startObservingMutations() { 5179 observer.observe(document, { subtree: true, childList: true, attributes: true, attributeOldValue: true }); 5180 currentlyObserving = true; 5181} 5182function stopObservingMutations() { 5183 flushObserver(); 5184 observer.disconnect(); 5185 currentlyObserving = false; 5186} 5187var recordQueue = []; 5188var willProcessRecordQueue = false; 5189function flushObserver() { 5190 recordQueue = recordQueue.concat(observer.takeRecords()); 5191 if (recordQueue.length && !willProcessRecordQueue) { 5192 willProcessRecordQueue = true; 5193 queueMicrotask(() => { 5194 processRecordQueue(); 5195 willProcessRecordQueue = false; 5196 }); 5197 } 5198} 5199function processRecordQueue() { 5200 onMutate(recordQueue); 5201 recordQueue.length = 0; 5202} 5203function mutateDom(callback) { 5204 if (!currentlyObserving) 5205 return callback(); 5206 stopObservingMutations(); 5207 let result = callback(); 5208 startObservingMutations(); 5209 return result; 5210} 5211var isCollecting = false; 5212var deferredMutations = []; 5213function deferMutations() { 5214 isCollecting = true; 5215} 5216function flushAndStopDeferringMutations() { 5217 isCollecting = false; 5218 onMutate(deferredMutations); 5219 deferredMutations = []; 5220} 5221function onMutate(mutations) { 5222 if (isCollecting) { 5223 deferredMutations = deferredMutations.concat(mutations); 5224 return; 5225 } 5226 let addedNodes = []; 5227 let removedNodes = []; 5228 let addedAttributes = /* @__PURE__ */ new Map(); 5229 let removedAttributes = /* @__PURE__ */ new Map(); 5230 for (let i = 0; i < mutations.length; i++) { 5231 if (mutations[i].target._x_ignoreMutationObserver) 5232 continue; 5233 if (mutations[i].type === "childList") { 5234 mutations[i].addedNodes.forEach((node) => node.nodeType === 1 && addedNodes.push(node)); 5235 mutations[i].removedNodes.forEach((node) => node.nodeType === 1 && removedNodes.push(node)); 5236 } 5237 if (mutations[i].type === "attributes") { 5238 let el = mutations[i].target; 5239 let name = mutations[i].attributeName; 5240 let oldValue = mutations[i].oldValue; 5241 let add2 = () => { 5242 if (!addedAttributes.has(el)) 5243 addedAttributes.set(el, []); 5244 addedAttributes.get(el).push({ name, value: el.getAttribute(name) }); 5245 }; 5246 let remove = () => { 5247 if (!removedAttributes.has(el)) 5248 removedAttributes.set(el, []); 5249 removedAttributes.get(el).push(name); 5250 }; 5251 if (el.hasAttribute(name) && oldValue === null) { 5252 add2(); 5253 } else if (el.hasAttribute(name)) { 5254 remove(); 5255 add2(); 5256 } else { 5257 remove(); 5258 } 5259 } 5260 } 5261 removedAttributes.forEach((attrs, el) => { 5262 cleanupAttributes(el, attrs); 5263 }); 5264 addedAttributes.forEach((attrs, el) => { 5265 onAttributeAddeds.forEach((i) => i(el, attrs)); 5266 }); 5267 for (let node of removedNodes) { 5268 if (addedNodes.includes(node)) 5269 continue; 5270 onElRemoveds.forEach((i) => i(node)); 5271 destroyTree(node); 5272 } 5273 addedNodes.forEach((node) => { 5274 node._x_ignoreSelf = true; 5275 node._x_ignore = true; 5276 }); 5277 for (let node of addedNodes) { 5278 if (removedNodes.includes(node)) 5279 continue; 5280 if (!node.isConnected) 5281 continue; 5282 delete node._x_ignoreSelf; 5283 delete node._x_ignore; 5284 onElAddeds.forEach((i) => i(node)); 5285 node._x_ignore = true; 5286 node._x_ignoreSelf = true; 5287 } 5288 addedNodes.forEach((node) => { 5289 delete node._x_ignoreSelf; 5290 delete node._x_ignore; 5291 }); 5292 addedNodes = null; 5293 removedNodes = null; 5294 addedAttributes = null; 5295 removedAttributes = null; 5296} 5297 5298// packages/alpinejs/src/scope.js 5299function scope(node) { 5300 return mergeProxies(closestDataStack(node)); 5301} 5302function addScopeToNode(node, data2, referenceNode) { 5303 node._x_dataStack = [data2, ...closestDataStack(referenceNode || node)]; 5304 return () => { 5305 node._x_dataStack = node._x_dataStack.filter((i) => i !== data2); 5306 }; 5307} 5308function closestDataStack(node) { 5309 if (node._x_dataStack) 5310 return node._x_dataStack; 5311 if (typeof ShadowRoot === "function" && node instanceof ShadowRoot) { 5312 return closestDataStack(node.host); 5313 } 5314 if (!node.parentNode) { 5315 return []; 5316 } 5317 return closestDataStack(node.parentNode); 5318} 5319function mergeProxies(objects) { 5320 let thisProxy = new Proxy({}, { 5321 ownKeys: () => { 5322 return Array.from(new Set(objects.flatMap((i) => Object.keys(i)))); 5323 }, 5324 has: (target, name) => { 5325 return objects.some((obj) => obj.hasOwnProperty(name)); 5326 }, 5327 get: (target, name) => { 5328 return (objects.find((obj) => { 5329 if (obj.hasOwnProperty(name)) { 5330 let descriptor = Object.getOwnPropertyDescriptor(obj, name); 5331 if (descriptor.get && descriptor.get._x_alreadyBound || descriptor.set && descriptor.set._x_alreadyBound) { 5332 return true; 5333 } 5334 if ((descriptor.get || descriptor.set) && descriptor.enumerable) { 5335 let getter = descriptor.get; 5336 let setter = descriptor.set; 5337 let property = descriptor; 5338 getter = getter && getter.bind(thisProxy); 5339 setter = setter && setter.bind(thisProxy); 5340 if (getter) 5341 getter._x_alreadyBound = true; 5342 if (setter) 5343 setter._x_alreadyBound = true; 5344 Object.defineProperty(obj, name, { 5345 ...property, 5346 get: getter, 5347 set: setter 5348 }); 5349 } 5350 return true; 5351 } 5352 return false; 5353 }) || {})[name]; 5354 }, 5355 set: (target, name, value) => { 5356 let closestObjectWithKey = objects.find((obj) => obj.hasOwnProperty(name)); 5357 if (closestObjectWithKey) { 5358 closestObjectWithKey[name] = value; 5359 } else { 5360 objects[objects.length - 1][name] = value; 5361 } 5362 return true; 5363 } 5364 }); 5365 return thisProxy; 5366} 5367 5368// packages/alpinejs/src/interceptor.js 5369function initInterceptors2(data2) { 5370 let isObject2 = (val) => typeof val === "object" && !Array.isArray(val) && val !== null; 5371 let recurse = (obj, basePath = "") => { 5372 Object.entries(Object.getOwnPropertyDescriptors(obj)).forEach(([key, { value, enumerable }]) => { 5373 if (enumerable === false || value === void 0) 5374 return; 5375 let path = basePath === "" ? key : `${basePath}.${key}`; 5376 if (typeof value === "object" && value !== null && value._x_interceptor) { 5377 obj[key] = value.initialize(data2, path, key); 5378 } else { 5379 if (isObject2(value) && value !== obj && !(value instanceof Element)) { 5380 recurse(value, path); 5381 } 5382 } 5383 }); 5384 }; 5385 return recurse(data2); 5386} 5387function interceptor(callback, mutateObj = () => { 5388}) { 5389 let obj = { 5390 initialValue: void 0, 5391 _x_interceptor: true, 5392 initialize(data2, path, key) { 5393 return callback(this.initialValue, () => get(data2, path), (value) => set(data2, path, value), path, key); 5394 } 5395 }; 5396 mutateObj(obj); 5397 return (initialValue) => { 5398 if (typeof initialValue === "object" && initialValue !== null && initialValue._x_interceptor) { 5399 let initialize = obj.initialize.bind(obj); 5400 obj.initialize = (data2, path, key) => { 5401 let innerValue = initialValue.initialize(data2, path, key); 5402 obj.initialValue = innerValue; 5403 return initialize(data2, path, key); 5404 }; 5405 } else { 5406 obj.initialValue = initialValue; 5407 } 5408 return obj; 5409 }; 5410} 5411function get(obj, path) { 5412 return path.split(".").reduce((carry, segment) => carry[segment], obj); 5413} 5414function set(obj, path, value) { 5415 if (typeof path === "string") 5416 path = path.split("."); 5417 if (path.length === 1) 5418 obj[path[0]] = value; 5419 else if (path.length === 0) 5420 throw error; 5421 else { 5422 if (obj[path[0]]) 5423 return set(obj[path[0]], path.slice(1), value); 5424 else { 5425 obj[path[0]] = {}; 5426 return set(obj[path[0]], path.slice(1), value); 5427 } 5428 } 5429} 5430 5431// packages/alpinejs/src/magics.js 5432var magics = {}; 5433function magic(name, callback) { 5434 magics[name] = callback; 5435} 5436function injectMagics(obj, el) { 5437 Object.entries(magics).forEach(([name, callback]) => { 5438 let memoizedUtilities = null; 5439 function getUtilities() { 5440 if (memoizedUtilities) { 5441 return memoizedUtilities; 5442 } else { 5443 let [utilities, cleanup2] = getElementBoundUtilities(el); 5444 memoizedUtilities = { interceptor, ...utilities }; 5445 onElRemoved(el, cleanup2); 5446 return memoizedUtilities; 5447 } 5448 } 5449 Object.defineProperty(obj, `$${name}`, { 5450 get() { 5451 return callback(el, getUtilities()); 5452 }, 5453 enumerable: false 5454 }); 5455 }); 5456 return obj; 5457} 5458 5459// packages/alpinejs/src/utils/error.js 5460function tryCatch(el, expression, callback, ...args) { 5461 try { 5462 return callback(...args); 5463 } catch (e) { 5464 handleError(e, el, expression); 5465 } 5466} 5467function handleError(error2, el, expression = void 0) { 5468 Object.assign(error2, { el, expression }); 5469 console.warn(`Alpine Expression Error: ${error2.message} 5470 5471${expression ? 'Expression: "' + expression + '"\n\n' : ""}`, el); 5472 setTimeout(() => { 5473 throw error2; 5474 }, 0); 5475} 5476 5477// packages/alpinejs/src/evaluator.js 5478var shouldAutoEvaluateFunctions = true; 5479function dontAutoEvaluateFunctions(callback) { 5480 let cache = shouldAutoEvaluateFunctions; 5481 shouldAutoEvaluateFunctions = false; 5482 let result = callback(); 5483 shouldAutoEvaluateFunctions = cache; 5484 return result; 5485} 5486function evaluate(el, expression, extras = {}) { 5487 let result; 5488 evaluateLater(el, expression)((value) => result = value, extras); 5489 return result; 5490} 5491function evaluateLater(...args) { 5492 return theEvaluatorFunction(...args); 5493} 5494var theEvaluatorFunction = normalEvaluator; 5495function setEvaluator(newEvaluator) { 5496 theEvaluatorFunction = newEvaluator; 5497} 5498function normalEvaluator(el, expression) { 5499 let overriddenMagics = {}; 5500 injectMagics(overriddenMagics, el); 5501 let dataStack = [overriddenMagics, ...closestDataStack(el)]; 5502 let evaluator = typeof expression === "function" ? generateEvaluatorFromFunction(dataStack, expression) : generateEvaluatorFromString(dataStack, expression, el); 5503 return tryCatch.bind(null, el, expression, evaluator); 5504} 5505function generateEvaluatorFromFunction(dataStack, func) { 5506 return (receiver = () => { 5507 }, { scope: scope2 = {}, params = [] } = {}) => { 5508 let result = func.apply(mergeProxies([scope2, ...dataStack]), params); 5509 runIfTypeOfFunction(receiver, result); 5510 }; 5511} 5512var evaluatorMemo = {}; 5513function generateFunctionFromString(expression, el) { 5514 if (evaluatorMemo[expression]) { 5515 return evaluatorMemo[expression]; 5516 } 5517 let AsyncFunction = Object.getPrototypeOf(async function() { 5518 }).constructor; 5519 let rightSideSafeExpression = /^[\n\s]*if.*\(.*\)/.test(expression.trim()) || /^(let|const)\s/.test(expression.trim()) ? `(async()=>{ ${expression} })()` : expression; 5520 const safeAsyncFunction = () => { 5521 try { 5522 return new AsyncFunction(["__self", "scope"], `with (scope) { __self.result = ${rightSideSafeExpression} }; __self.finished = true; return __self.result;`); 5523 } catch (error2) { 5524 handleError(error2, el, expression); 5525 return Promise.resolve(); 5526 } 5527 }; 5528 let func = safeAsyncFunction(); 5529 evaluatorMemo[expression] = func; 5530 return func; 5531} 5532function generateEvaluatorFromString(dataStack, expression, el) { 5533 let func = generateFunctionFromString(expression, el); 5534 return (receiver = () => { 5535 }, { scope: scope2 = {}, params = [] } = {}) => { 5536 func.result = void 0; 5537 func.finished = false; 5538 let completeScope = mergeProxies([scope2, ...dataStack]); 5539 if (typeof func === "function") { 5540 let promise = func(func, completeScope).catch((error2) => handleError(error2, el, expression)); 5541 if (func.finished) { 5542 runIfTypeOfFunction(receiver, func.result, completeScope, params, el); 5543 func.result = void 0; 5544 } else { 5545 promise.then((result) => { 5546 runIfTypeOfFunction(receiver, result, completeScope, params, el); 5547 }).catch((error2) => handleError(error2, el, expression)).finally(() => func.result = void 0); 5548 } 5549 } 5550 }; 5551} 5552function runIfTypeOfFunction(receiver, value, scope2, params, el) { 5553 if (shouldAutoEvaluateFunctions && typeof value === "function") { 5554 let result = value.apply(scope2, params); 5555 if (result instanceof Promise) { 5556 result.then((i) => runIfTypeOfFunction(receiver, i, scope2, params)).catch((error2) => handleError(error2, el, value)); 5557 } else { 5558 receiver(result); 5559 } 5560 } else if (typeof value === "object" && value instanceof Promise) { 5561 value.then((i) => receiver(i)); 5562 } else { 5563 receiver(value); 5564 } 5565} 5566 5567// packages/alpinejs/src/directives.js 5568var prefixAsString = "x-"; 5569function prefix(subject = "") { 5570 return prefixAsString + subject; 5571} 5572function setPrefix(newPrefix) { 5573 prefixAsString = newPrefix; 5574} 5575var directiveHandlers = {}; 5576function directive(name, callback) { 5577 directiveHandlers[name] = callback; 5578 return { 5579 before(directive2) { 5580 if (!directiveHandlers[directive2]) { 5581 console.warn( 5582 "Cannot find directive `${directive}`. `${name}` will use the default order of execution" 5583 ); 5584 return; 5585 } 5586 const pos = directiveOrder.indexOf(directive2); 5587 directiveOrder.splice(pos >= 0 ? pos : directiveOrder.indexOf("DEFAULT"), 0, name); 5588 } 5589 }; 5590} 5591function directives(el, attributes, originalAttributeOverride) { 5592 attributes = Array.from(attributes); 5593 if (el._x_virtualDirectives) { 5594 let vAttributes = Object.entries(el._x_virtualDirectives).map(([name, value]) => ({ name, value })); 5595 let staticAttributes = attributesOnly(vAttributes); 5596 vAttributes = vAttributes.map((attribute) => { 5597 if (staticAttributes.find((attr) => attr.name === attribute.name)) { 5598 return { 5599 name: `x-bind:${attribute.name}`, 5600 value: `"${attribute.value}"` 5601 }; 5602 } 5603 return attribute; 5604 }); 5605 attributes = attributes.concat(vAttributes); 5606 } 5607 let transformedAttributeMap = {}; 5608 let directives2 = attributes.map(toTransformedAttributes((newName, oldName) => transformedAttributeMap[newName] = oldName)).filter(outNonAlpineAttributes).map(toParsedDirectives(transformedAttributeMap, originalAttributeOverride)).sort(byPriority); 5609 return directives2.map((directive2) => { 5610 return getDirectiveHandler(el, directive2); 5611 }); 5612} 5613function attributesOnly(attributes) { 5614 return Array.from(attributes).map(toTransformedAttributes()).filter((attr) => !outNonAlpineAttributes(attr)); 5615} 5616var isDeferringHandlers = false; 5617var directiveHandlerStacks = /* @__PURE__ */ new Map(); 5618var currentHandlerStackKey = Symbol(); 5619function deferHandlingDirectives(callback) { 5620 isDeferringHandlers = true; 5621 let key = Symbol(); 5622 currentHandlerStackKey = key; 5623 directiveHandlerStacks.set(key, []); 5624 let flushHandlers = () => { 5625 while (directiveHandlerStacks.get(key).length) 5626 directiveHandlerStacks.get(key).shift()(); 5627 directiveHandlerStacks.delete(key); 5628 }; 5629 let stopDeferring = () => { 5630 isDeferringHandlers = false; 5631 flushHandlers(); 5632 }; 5633 callback(flushHandlers); 5634 stopDeferring(); 5635} 5636function getElementBoundUtilities(el) { 5637 let cleanups = []; 5638 let cleanup2 = (callback) => cleanups.push(callback); 5639 let [effect3, cleanupEffect] = elementBoundEffect(el); 5640 cleanups.push(cleanupEffect); 5641 let utilities = { 5642 Alpine: alpine_default, 5643 effect: effect3, 5644 cleanup: cleanup2, 5645 evaluateLater: evaluateLater.bind(evaluateLater, el), 5646 evaluate: evaluate.bind(evaluate, el) 5647 }; 5648 let doCleanup = () => cleanups.forEach((i) => i()); 5649 return [utilities, doCleanup]; 5650} 5651function getDirectiveHandler(el, directive2) { 5652 let noop = () => { 5653 }; 5654 let handler4 = directiveHandlers[directive2.type] || noop; 5655 let [utilities, cleanup2] = getElementBoundUtilities(el); 5656 onAttributeRemoved(el, directive2.original, cleanup2); 5657 let fullHandler = () => { 5658 if (el._x_ignore || el._x_ignoreSelf) 5659 return; 5660 handler4.inline && handler4.inline(el, directive2, utilities); 5661 handler4 = handler4.bind(handler4, el, directive2, utilities); 5662 isDeferringHandlers ? directiveHandlerStacks.get(currentHandlerStackKey).push(handler4) : handler4(); 5663 }; 5664 fullHandler.runCleanups = cleanup2; 5665 return fullHandler; 5666} 5667var startingWith = (subject, replacement) => ({ name, value }) => { 5668 if (name.startsWith(subject)) 5669 name = name.replace(subject, replacement); 5670 return { name, value }; 5671}; 5672var into = (i) => i; 5673function toTransformedAttributes(callback = () => { 5674}) { 5675 return ({ name, value }) => { 5676 let { name: newName, value: newValue } = attributeTransformers.reduce((carry, transform) => { 5677 return transform(carry); 5678 }, { name, value }); 5679 if (newName !== name) 5680 callback(newName, name); 5681 return { name: newName, value: newValue }; 5682 }; 5683} 5684var attributeTransformers = []; 5685function mapAttributes(callback) { 5686 attributeTransformers.push(callback); 5687} 5688function outNonAlpineAttributes({ name }) { 5689 return alpineAttributeRegex().test(name); 5690} 5691var alpineAttributeRegex = () => new RegExp(`^${prefixAsString}([^:^.]+)\\b`); 5692function toParsedDirectives(transformedAttributeMap, originalAttributeOverride) { 5693 return ({ name, value }) => { 5694 let typeMatch = name.match(alpineAttributeRegex()); 5695 let valueMatch = name.match(/:([a-zA-Z0-9\-:]+)/); 5696 let modifiers = name.match(/\.[^.\]]+(?=[^\]]*$)/g) || []; 5697 let original = originalAttributeOverride || transformedAttributeMap[name] || name; 5698 return { 5699 type: typeMatch ? typeMatch[1] : null, 5700 value: valueMatch ? valueMatch[1] : null, 5701 modifiers: modifiers.map((i) => i.replace(".", "")), 5702 expression: value, 5703 original 5704 }; 5705 }; 5706} 5707var DEFAULT = "DEFAULT"; 5708var directiveOrder = [ 5709 "ignore", 5710 "ref", 5711 "data", 5712 "id", 5713 "bind", 5714 "init", 5715 "for", 5716 "model", 5717 "modelable", 5718 "transition", 5719 "show", 5720 "if", 5721 DEFAULT, 5722 "teleport" 5723]; 5724function byPriority(a, b) { 5725 let typeA = directiveOrder.indexOf(a.type) === -1 ? DEFAULT : a.type; 5726 let typeB = directiveOrder.indexOf(b.type) === -1 ? DEFAULT : b.type; 5727 return directiveOrder.indexOf(typeA) - directiveOrder.indexOf(typeB); 5728} 5729 5730// packages/alpinejs/src/nextTick.js 5731var tickStack = []; 5732var isHolding = false; 5733function nextTick(callback = () => { 5734}) { 5735 queueMicrotask(() => { 5736 isHolding || setTimeout(() => { 5737 releaseNextTicks(); 5738 }); 5739 }); 5740 return new Promise((res) => { 5741 tickStack.push(() => { 5742 callback(); 5743 res(); 5744 }); 5745 }); 5746} 5747function releaseNextTicks() { 5748 isHolding = false; 5749 while (tickStack.length) 5750 tickStack.shift()(); 5751} 5752function holdNextTicks() { 5753 isHolding = true; 5754} 5755 5756// packages/alpinejs/src/utils/classes.js 5757function setClasses(el, value) { 5758 if (Array.isArray(value)) { 5759 return setClassesFromString(el, value.join(" ")); 5760 } else if (typeof value === "object" && value !== null) { 5761 return setClassesFromObject(el, value); 5762 } else if (typeof value === "function") { 5763 return setClasses(el, value()); 5764 } 5765 return setClassesFromString(el, value); 5766} 5767function setClassesFromString(el, classString) { 5768 let split = (classString2) => classString2.split(" ").filter(Boolean); 5769 let missingClasses = (classString2) => classString2.split(" ").filter((i) => !el.classList.contains(i)).filter(Boolean); 5770 let addClassesAndReturnUndo = (classes) => { 5771 el.classList.add(...classes); 5772 return () => { 5773 el.classList.remove(...classes); 5774 }; 5775 }; 5776 classString = classString === true ? classString = "" : classString || ""; 5777 return addClassesAndReturnUndo(missingClasses(classString)); 5778} 5779function setClassesFromObject(el, classObject) { 5780 let split = (classString) => classString.split(" ").filter(Boolean); 5781 let forAdd = Object.entries(classObject).flatMap(([classString, bool]) => bool ? split(classString) : false).filter(Boolean); 5782 let forRemove = Object.entries(classObject).flatMap(([classString, bool]) => !bool ? split(classString) : false).filter(Boolean); 5783 let added = []; 5784 let removed = []; 5785 forRemove.forEach((i) => { 5786 if (el.classList.contains(i)) { 5787 el.classList.remove(i); 5788 removed.push(i); 5789 } 5790 }); 5791 forAdd.forEach((i) => { 5792 if (!el.classList.contains(i)) { 5793 el.classList.add(i); 5794 added.push(i); 5795 } 5796 }); 5797 return () => { 5798 removed.forEach((i) => el.classList.add(i)); 5799 added.forEach((i) => el.classList.remove(i)); 5800 }; 5801} 5802 5803// packages/alpinejs/src/utils/styles.js 5804function setStyles(el, value) { 5805 if (typeof value === "object" && value !== null) { 5806 return setStylesFromObject(el, value); 5807 } 5808 return setStylesFromString(el, value); 5809} 5810function setStylesFromObject(el, value) { 5811 let previousStyles = {}; 5812 Object.entries(value).forEach(([key, value2]) => { 5813 previousStyles[key] = el.style[key]; 5814 if (!key.startsWith("--")) { 5815 key = kebabCase(key); 5816 } 5817 el.style.setProperty(key, value2); 5818 }); 5819 setTimeout(() => { 5820 if (el.style.length === 0) { 5821 el.removeAttribute("style"); 5822 } 5823 }); 5824 return () => { 5825 setStyles(el, previousStyles); 5826 }; 5827} 5828function setStylesFromString(el, value) { 5829 let cache = el.getAttribute("style", value); 5830 el.setAttribute("style", value); 5831 return () => { 5832 el.setAttribute("style", cache || ""); 5833 }; 5834} 5835function kebabCase(subject) { 5836 return subject.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(); 5837} 5838 5839// packages/alpinejs/src/utils/once.js 5840function once(callback, fallback = () => { 5841}) { 5842 let called = false; 5843 return function() { 5844 if (!called) { 5845 called = true; 5846 callback.apply(this, arguments); 5847 } else { 5848 fallback.apply(this, arguments); 5849 } 5850 }; 5851} 5852 5853// packages/alpinejs/src/directives/x-transition.js 5854directive("transition", (el, { value, modifiers, expression }, { evaluate: evaluate2 }) => { 5855 if (typeof expression === "function") 5856 expression = evaluate2(expression); 5857 if (expression === false) 5858 return; 5859 if (!expression || typeof expression === "boolean") { 5860 registerTransitionsFromHelper(el, modifiers, value); 5861 } else { 5862 registerTransitionsFromClassString(el, expression, value); 5863 } 5864}); 5865function registerTransitionsFromClassString(el, classString, stage) { 5866 registerTransitionObject(el, setClasses, ""); 5867 let directiveStorageMap = { 5868 "enter": (classes) => { 5869 el._x_transition.enter.during = classes; 5870 }, 5871 "enter-start": (classes) => { 5872 el._x_transition.enter.start = classes; 5873 }, 5874 "enter-end": (classes) => { 5875 el._x_transition.enter.end = classes; 5876 }, 5877 "leave": (classes) => { 5878 el._x_transition.leave.during = classes; 5879 }, 5880 "leave-start": (classes) => { 5881 el._x_transition.leave.start = classes; 5882 }, 5883 "leave-end": (classes) => { 5884 el._x_transition.leave.end = classes; 5885 } 5886 }; 5887 directiveStorageMap[stage](classString); 5888} 5889function registerTransitionsFromHelper(el, modifiers, stage) { 5890 registerTransitionObject(el, setStyles); 5891 let doesntSpecify = !modifiers.includes("in") && !modifiers.includes("out") && !stage; 5892 let transitioningIn = doesntSpecify || modifiers.includes("in") || ["enter"].includes(stage); 5893 let transitioningOut = doesntSpecify || modifiers.includes("out") || ["leave"].includes(stage); 5894 if (modifiers.includes("in") && !doesntSpecify) { 5895 modifiers = modifiers.filter((i, index) => index < modifiers.indexOf("out")); 5896 } 5897 if (modifiers.includes("out") && !doesntSpecify) { 5898 modifiers = modifiers.filter((i, index) => index > modifiers.indexOf("out")); 5899 } 5900 let wantsAll = !modifiers.includes("opacity") && !modifiers.includes("scale"); 5901 let wantsOpacity = wantsAll || modifiers.includes("opacity"); 5902 let wantsScale = wantsAll || modifiers.includes("scale"); 5903 let opacityValue = wantsOpacity ? 0 : 1; 5904 let scaleValue = wantsScale ? modifierValue(modifiers, "scale", 95) / 100 : 1; 5905 let delay = modifierValue(modifiers, "delay", 0) / 1e3; 5906 let origin = modifierValue(modifiers, "origin", "center"); 5907 let property = "opacity, transform"; 5908 let durationIn = modifierValue(modifiers, "duration", 150) / 1e3; 5909 let durationOut = modifierValue(modifiers, "duration", 75) / 1e3; 5910 let easing = `cubic-bezier(0.4, 0.0, 0.2, 1)`; 5911 if (transitioningIn) { 5912 el._x_transition.enter.during = { 5913 transformOrigin: origin, 5914 transitionDelay: `${delay}s`, 5915 transitionProperty: property, 5916 transitionDuration: `${durationIn}s`, 5917 transitionTimingFunction: easing 5918 }; 5919 el._x_transition.enter.start = { 5920 opacity: opacityValue, 5921 transform: `scale(${scaleValue})` 5922 }; 5923 el._x_transition.enter.end = { 5924 opacity: 1, 5925 transform: `scale(1)` 5926 }; 5927 } 5928 if (transitioningOut) { 5929 el._x_transition.leave.during = { 5930 transformOrigin: origin, 5931 transitionDelay: `${delay}s`, 5932 transitionProperty: property, 5933 transitionDuration: `${durationOut}s`, 5934 transitionTimingFunction: easing 5935 }; 5936 el._x_transition.leave.start = { 5937 opacity: 1, 5938 transform: `scale(1)` 5939 }; 5940 el._x_transition.leave.end = { 5941 opacity: opacityValue, 5942 transform: `scale(${scaleValue})` 5943 }; 5944 } 5945} 5946function registerTransitionObject(el, setFunction, defaultValue = {}) { 5947 if (!el._x_transition) 5948 el._x_transition = { 5949 enter: { during: defaultValue, start: defaultValue, end: defaultValue }, 5950 leave: { during: defaultValue, start: defaultValue, end: defaultValue }, 5951 in(before = () => { 5952 }, after = () => { 5953 }) { 5954 transition(el, setFunction, { 5955 during: this.enter.during, 5956 start: this.enter.start, 5957 end: this.enter.end 5958 }, before, after); 5959 }, 5960 out(before = () => { 5961 }, after = () => { 5962 }) { 5963 transition(el, setFunction, { 5964 during: this.leave.during, 5965 start: this.leave.start, 5966 end: this.leave.end 5967 }, before, after); 5968 } 5969 }; 5970} 5971window.Element.prototype._x_toggleAndCascadeWithTransitions = function(el, value, show, hide) { 5972 const nextTick2 = document.visibilityState === "visible" ? requestAnimationFrame : setTimeout; 5973 let clickAwayCompatibleShow = () => nextTick2(show); 5974 if (value) { 5975 if (el._x_transition && (el._x_transition.enter || el._x_transition.leave)) { 5976 el._x_transition.enter && (Object.entries(el._x_transition.enter.during).length || Object.entries(el._x_transition.enter.start).length || Object.entries(el._x_transition.enter.end).length) ? el._x_transition.in(show) : clickAwayCompatibleShow(); 5977 } else { 5978 el._x_transition ? el._x_transition.in(show) : clickAwayCompatibleShow(); 5979 } 5980 return; 5981 } 5982 el._x_hidePromise = el._x_transition ? new Promise((resolve, reject) => { 5983 el._x_transition.out(() => { 5984 }, () => resolve(hide)); 5985 el._x_transitioning.beforeCancel(() => reject({ isFromCancelledTransition: true })); 5986 }) : Promise.resolve(hide); 5987 queueMicrotask(() => { 5988 let closest = closestHide(el); 5989 if (closest) { 5990 if (!closest._x_hideChildren) 5991 closest._x_hideChildren = []; 5992 closest._x_hideChildren.push(el); 5993 } else { 5994 nextTick2(() => { 5995 let hideAfterChildren = (el2) => { 5996 let carry = Promise.all([ 5997 el2._x_hidePromise, 5998 ...(el2._x_hideChildren || []).map(hideAfterChildren) 5999 ]).then(([i]) => i()); 6000 delete el2._x_hidePromise; 6001 delete el2._x_hideChildren; 6002 return carry; 6003 }; 6004 hideAfterChildren(el).catch((e) => { 6005 if (!e.isFromCancelledTransition) 6006 throw e; 6007 }); 6008 }); 6009 } 6010 }); 6011}; 6012function closestHide(el) { 6013 let parent = el.parentNode; 6014 if (!parent) 6015 return; 6016 return parent._x_hidePromise ? parent : closestHide(parent); 6017} 6018function transition(el, setFunction, { during, start: start2, end } = {}, before = () => { 6019}, after = () => { 6020}) { 6021 if (el._x_transitioning) 6022 el._x_transitioning.cancel(); 6023 if (Object.keys(during).length === 0 && Object.keys(start2).length === 0 && Object.keys(end).length === 0) { 6024 before(); 6025 after(); 6026 return; 6027 } 6028 let undoStart, undoDuring, undoEnd; 6029 performTransition(el, { 6030 start() { 6031 undoStart = setFunction(el, start2); 6032 }, 6033 during() { 6034 undoDuring = setFunction(el, during); 6035 }, 6036 before, 6037 end() { 6038 undoStart(); 6039 undoEnd = setFunction(el, end); 6040 }, 6041 after, 6042 cleanup() { 6043 undoDuring(); 6044 undoEnd(); 6045 } 6046 }); 6047} 6048function performTransition(el, stages) { 6049 let interrupted, reachedBefore, reachedEnd; 6050 let finish = once(() => { 6051 mutateDom(() => { 6052 interrupted = true; 6053 if (!reachedBefore) 6054 stages.before(); 6055 if (!reachedEnd) { 6056 stages.end(); 6057 releaseNextTicks(); 6058 } 6059 stages.after(); 6060 if (el.isConnected) 6061 stages.cleanup(); 6062 delete el._x_transitioning; 6063 }); 6064 }); 6065 el._x_transitioning = { 6066 beforeCancels: [], 6067 beforeCancel(callback) { 6068 this.beforeCancels.push(callback); 6069 }, 6070 cancel: once(function() { 6071 while (this.beforeCancels.length) { 6072 this.beforeCancels.shift()(); 6073 } 6074 ; 6075 finish(); 6076 }), 6077 finish 6078 }; 6079 mutateDom(() => { 6080 stages.start(); 6081 stages.during(); 6082 }); 6083 holdNextTicks(); 6084 requestAnimationFrame(() => { 6085 if (interrupted) 6086 return; 6087 let duration = Number(getComputedStyle(el).transitionDuration.replace(/,.*/, "").replace("s", "")) * 1e3; 6088 let delay = Number(getComputedStyle(el).transitionDelay.replace(/,.*/, "").replace("s", "")) * 1e3; 6089 if (duration === 0) 6090 duration = Number(getComputedStyle(el).animationDuration.replace("s", "")) * 1e3; 6091 mutateDom(() => { 6092 stages.before(); 6093 }); 6094 reachedBefore = true; 6095 requestAnimationFrame(() => { 6096 if (interrupted) 6097 return; 6098 mutateDom(() => { 6099 stages.end(); 6100 }); 6101 releaseNextTicks(); 6102 setTimeout(el._x_transitioning.finish, duration + delay); 6103 reachedEnd = true; 6104 }); 6105 }); 6106} 6107function modifierValue(modifiers, key, fallback) { 6108 if (modifiers.indexOf(key) === -1) 6109 return fallback; 6110 const rawValue = modifiers[modifiers.indexOf(key) + 1]; 6111 if (!rawValue) 6112 return fallback; 6113 if (key === "scale") { 6114 if (isNaN(rawValue)) 6115 return fallback; 6116 } 6117 if (key === "duration" || key === "delay") { 6118 let match = rawValue.match(/([0-9]+)ms/); 6119 if (match) 6120 return match[1]; 6121 } 6122 if (key === "origin") { 6123 if (["top", "right", "left", "center", "bottom"].includes(modifiers[modifiers.indexOf(key) + 2])) { 6124 return [rawValue, modifiers[modifiers.indexOf(key) + 2]].join(" "); 6125 } 6126 } 6127 return rawValue; 6128} 6129 6130// packages/alpinejs/src/clone.js 6131var isCloning = false; 6132function skipDuringClone(callback, fallback = () => { 6133}) { 6134 return (...args) => isCloning ? fallback(...args) : callback(...args); 6135} 6136function onlyDuringClone(callback) { 6137 return (...args) => isCloning && callback(...args); 6138} 6139function cloneNode(from, to) { 6140 if (from._x_dataStack) { 6141 to._x_dataStack = from._x_dataStack; 6142 to.setAttribute("data-has-alpine-state", true); 6143 } 6144 isCloning = true; 6145 dontRegisterReactiveSideEffects(() => { 6146 initTree(to, (el, callback) => { 6147 callback(el, () => { 6148 }); 6149 }); 6150 }); 6151 isCloning = false; 6152} 6153var isCloningLegacy = false; 6154function clone(oldEl, newEl) { 6155 if (!newEl._x_dataStack) 6156 newEl._x_dataStack = oldEl._x_dataStack; 6157 isCloning = true; 6158 isCloningLegacy = true; 6159 dontRegisterReactiveSideEffects(() => { 6160 cloneTree(newEl); 6161 }); 6162 isCloning = false; 6163 isCloningLegacy = false; 6164} 6165function cloneTree(el) { 6166 let hasRunThroughFirstEl = false; 6167 let shallowWalker = (el2, callback) => { 6168 walk(el2, (el3, skip) => { 6169 if (hasRunThroughFirstEl && isRoot(el3)) 6170 return skip(); 6171 hasRunThroughFirstEl = true; 6172 callback(el3, skip); 6173 }); 6174 }; 6175 initTree(el, shallowWalker); 6176} 6177function dontRegisterReactiveSideEffects(callback) { 6178 let cache = effect; 6179 overrideEffect((callback2, el) => { 6180 let storedEffect = cache(callback2); 6181 release(storedEffect); 6182 return () => { 6183 }; 6184 }); 6185 callback(); 6186 overrideEffect(cache); 6187} 6188function shouldSkipRegisteringDataDuringClone(el) { 6189 if (!isCloning) 6190 return false; 6191 if (isCloningLegacy) 6192 return true; 6193 return el.hasAttribute("data-has-alpine-state"); 6194} 6195 6196// packages/alpinejs/src/utils/bind.js 6197function bind(el, name, value, modifiers = []) { 6198 if (!el._x_bindings) 6199 el._x_bindings = reactive({}); 6200 el._x_bindings[name] = value; 6201 name = modifiers.includes("camel") ? camelCase(name) : name; 6202 switch (name) { 6203 case "value": 6204 bindInputValue(el, value); 6205 break; 6206 case "style": 6207 bindStyles(el, value); 6208 break; 6209 case "class": 6210 bindClasses(el, value); 6211 break; 6212 case "selected": 6213 case "checked": 6214 bindAttributeAndProperty(el, name, value); 6215 break; 6216 default: 6217 bindAttribute(el, name, value); 6218 break; 6219 } 6220} 6221function bindInputValue(el, value) { 6222 if (el.type === "radio") { 6223 if (el.attributes.value === void 0) { 6224 el.value = value; 6225 } 6226 if (window.fromModel) { 6227 el.checked = checkedAttrLooseCompare(el.value, value); 6228 } 6229 } else if (el.type === "checkbox") { 6230 if (Number.isInteger(value)) { 6231 el.value = value; 6232 } else if (!Array.isArray(value) && typeof value !== "boolean" && ![null, void 0].includes(value)) { 6233 el.value = String(value); 6234 } else { 6235 if (Array.isArray(value)) { 6236 el.checked = value.some((val) => checkedAttrLooseCompare(val, el.value)); 6237 } else { 6238 el.checked = !!value; 6239 } 6240 } 6241 } else if (el.tagName === "SELECT") { 6242 updateSelect(el, value); 6243 } else { 6244 if (el.value === value) 6245 return; 6246 el.value = value === void 0 ? "" : value; 6247 } 6248} 6249function bindClasses(el, value) { 6250 if (el._x_undoAddedClasses) 6251 el._x_undoAddedClasses(); 6252 el._x_undoAddedClasses = setClasses(el, value); 6253} 6254function bindStyles(el, value) { 6255 if (el._x_undoAddedStyles) 6256 el._x_undoAddedStyles(); 6257 el._x_undoAddedStyles = setStyles(el, value); 6258} 6259function bindAttributeAndProperty(el, name, value) { 6260 bindAttribute(el, name, value); 6261 setPropertyIfChanged(el, name, value); 6262} 6263function bindAttribute(el, name, value) { 6264 if ([null, void 0, false].includes(value) && attributeShouldntBePreservedIfFalsy(name)) { 6265 el.removeAttribute(name); 6266 } else { 6267 if (isBooleanAttr(name)) 6268 value = name; 6269 setIfChanged(el, name, value); 6270 } 6271} 6272function setIfChanged(el, attrName, value) { 6273 if (el.getAttribute(attrName) != value) { 6274 el.setAttribute(attrName, value); 6275 } 6276} 6277function setPropertyIfChanged(el, propName, value) { 6278 if (el[propName] !== value) { 6279 el[propName] = value; 6280 } 6281} 6282function updateSelect(el, value) { 6283 const arrayWrappedValue = [].concat(value).map((value2) => { 6284 return value2 + ""; 6285 }); 6286 Array.from(el.options).forEach((option) => { 6287 option.selected = arrayWrappedValue.includes(option.value); 6288 }); 6289} 6290function camelCase(subject) { 6291 return subject.toLowerCase().replace(/-(\w)/g, (match, char) => char.toUpperCase()); 6292} 6293function checkedAttrLooseCompare(valueA, valueB) { 6294 return valueA == valueB; 6295} 6296function isBooleanAttr(attrName) { 6297 const booleanAttributes = [ 6298 "disabled", 6299 "checked", 6300 "required", 6301 "readonly", 6302 "hidden", 6303 "open", 6304 "selected", 6305 "autofocus", 6306 "itemscope", 6307 "multiple", 6308 "novalidate", 6309 "allowfullscreen", 6310 "allowpaymentrequest", 6311 "formnovalidate", 6312 "autoplay", 6313 "controls", 6314 "loop", 6315 "muted", 6316 "playsinline", 6317 "default", 6318 "ismap", 6319 "reversed", 6320 "async", 6321 "defer", 6322 "nomodule" 6323 ]; 6324 return booleanAttributes.includes(attrName); 6325} 6326function attributeShouldntBePreservedIfFalsy(name) { 6327 return !["aria-pressed", "aria-checked", "aria-expanded", "aria-selected"].includes(name); 6328} 6329function getBinding(el, name, fallback) { 6330 if (el._x_bindings && el._x_bindings[name] !== void 0) 6331 return el._x_bindings[name]; 6332 return getAttributeBinding(el, name, fallback); 6333} 6334function extractProp(el, name, fallback, extract = true) { 6335 if (el._x_bindings && el._x_bindings[name] !== void 0) 6336 return el._x_bindings[name]; 6337 if (el._x_inlineBindings && el._x_inlineBindings[name] !== void 0) { 6338 let binding = el._x_inlineBindings[name]; 6339 binding.extract = extract; 6340 return dontAutoEvaluateFunctions(() => { 6341 return evaluate(el, binding.expression); 6342 }); 6343 } 6344 return getAttributeBinding(el, name, fallback); 6345} 6346function getAttributeBinding(el, name, fallback) { 6347 let attr = el.getAttribute(name); 6348 if (attr === null) 6349 return typeof fallback === "function" ? fallback() : fallback; 6350 if (attr === "") 6351 return true; 6352 if (isBooleanAttr(name)) { 6353 return !![name, "true"].includes(attr); 6354 } 6355 return attr; 6356} 6357 6358// packages/alpinejs/src/utils/debounce.js 6359function debounce(func, wait) { 6360 var timeout; 6361 return function() { 6362 var context = this, args = arguments; 6363 var later = function() { 6364 timeout = null; 6365 func.apply(context, args); 6366 }; 6367 clearTimeout(timeout); 6368 timeout = setTimeout(later, wait); 6369 }; 6370} 6371 6372// packages/alpinejs/src/utils/throttle.js 6373function throttle(func, limit) { 6374 let inThrottle; 6375 return function() { 6376 let context = this, args = arguments; 6377 if (!inThrottle) { 6378 func.apply(context, args); 6379 inThrottle = true; 6380 setTimeout(() => inThrottle = false, limit); 6381 } 6382 }; 6383} 6384 6385// packages/alpinejs/src/entangle.js 6386function entangle({ get: outerGet, set: outerSet }, { get: innerGet, set: innerSet }) { 6387 let firstRun = true; 6388 let outerHash, innerHash, outerHashLatest, innerHashLatest; 6389 let reference = effect(() => { 6390 let outer, inner; 6391 if (firstRun) { 6392 outer = outerGet(); 6393 innerSet(JSON.parse(JSON.stringify(outer))); 6394 inner = innerGet(); 6395 firstRun = false; 6396 } else { 6397 outer = outerGet(); 6398 inner = innerGet(); 6399 outerHashLatest = JSON.stringify(outer); 6400 innerHashLatest = JSON.stringify(inner); 6401 if (outerHashLatest !== outerHash) { 6402 inner = innerGet(); 6403 innerSet(outer); 6404 inner = outer; 6405 } else { 6406 outerSet(JSON.parse(innerHashLatest ?? null)); 6407 outer = inner; 6408 } 6409 } 6410 outerHash = JSON.stringify(outer); 6411 innerHash = JSON.stringify(inner); 6412 }); 6413 return () => { 6414 release(reference); 6415 }; 6416} 6417 6418// packages/alpinejs/src/plugin.js 6419function plugin(callback) { 6420 let callbacks = Array.isArray(callback) ? callback : [callback]; 6421 callbacks.forEach((i) => i(alpine_default)); 6422} 6423 6424// packages/alpinejs/src/store.js 6425var stores = {}; 6426var isReactive = false; 6427function store(name, value) { 6428 if (!isReactive) { 6429 stores = reactive(stores); 6430 isReactive = true; 6431 } 6432 if (value === void 0) { 6433 return stores[name]; 6434 } 6435 stores[name] = value; 6436 if (typeof value === "object" && value !== null && value.hasOwnProperty("init") && typeof value.init === "function") { 6437 stores[name].init(); 6438 } 6439 initInterceptors2(stores[name]); 6440} 6441function getStores() { 6442 return stores; 6443} 6444 6445// packages/alpinejs/src/binds.js 6446var binds = {}; 6447function bind2(name, bindings) { 6448 let getBindings = typeof bindings !== "function" ? () => bindings : bindings; 6449 if (name instanceof Element) { 6450 return applyBindingsObject(name, getBindings()); 6451 } else { 6452 binds[name] = getBindings; 6453 } 6454 return () => { 6455 }; 6456} 6457function injectBindingProviders(obj) { 6458 Object.entries(binds).forEach(([name, callback]) => { 6459 Object.defineProperty(obj, name, { 6460 get() { 6461 return (...args) => { 6462 return callback(...args); 6463 }; 6464 } 6465 }); 6466 }); 6467 return obj; 6468} 6469function applyBindingsObject(el, obj, original) { 6470 let cleanupRunners = []; 6471 while (cleanupRunners.length) 6472 cleanupRunners.pop()(); 6473 let attributes = Object.entries(obj).map(([name, value]) => ({ name, value })); 6474 let staticAttributes = attributesOnly(attributes); 6475 attributes = attributes.map((attribute) => { 6476 if (staticAttributes.find((attr) => attr.name === attribute.name)) { 6477 return { 6478 name: `x-bind:${attribute.name}`, 6479 value: `"${attribute.value}"` 6480 }; 6481 } 6482 return attribute; 6483 }); 6484 directives(el, attributes, original).map((handle) => { 6485 cleanupRunners.push(handle.runCleanups); 6486 handle(); 6487 }); 6488 return () => { 6489 while (cleanupRunners.length) 6490 cleanupRunners.pop()(); 6491 }; 6492} 6493 6494// packages/alpinejs/src/datas.js 6495var datas = {}; 6496function data(name, callback) { 6497 datas[name] = callback; 6498} 6499function injectDataProviders(obj, context) { 6500 Object.entries(datas).forEach(([name, callback]) => { 6501 Object.defineProperty(obj, name, { 6502 get() { 6503 return (...args) => { 6504 return callback.bind(context)(...args); 6505 }; 6506 }, 6507 enumerable: false 6508 }); 6509 }); 6510 return obj; 6511} 6512 6513// packages/alpinejs/src/alpine.js 6514var Alpine = { 6515 get reactive() { 6516 return reactive; 6517 }, 6518 get release() { 6519 return release; 6520 }, 6521 get effect() { 6522 return effect; 6523 }, 6524 get raw() { 6525 return raw; 6526 }, 6527 version: "3.13.0", 6528 flushAndStopDeferringMutations, 6529 dontAutoEvaluateFunctions, 6530 disableEffectScheduling, 6531 startObservingMutations, 6532 stopObservingMutations, 6533 setReactivityEngine, 6534 onAttributeRemoved, 6535 onAttributesAdded, 6536 closestDataStack, 6537 skipDuringClone, 6538 onlyDuringClone, 6539 addRootSelector, 6540 addInitSelector, 6541 addScopeToNode, 6542 deferMutations, 6543 mapAttributes, 6544 evaluateLater, 6545 interceptInit, 6546 setEvaluator, 6547 mergeProxies, 6548 extractProp, 6549 findClosest, 6550 onElRemoved, 6551 closestRoot, 6552 destroyTree, 6553 interceptor, 6554 // INTERNAL: not public API and is subject to change without major release. 6555 transition, 6556 // INTERNAL 6557 setStyles, 6558 // INTERNAL 6559 mutateDom, 6560 directive, 6561 entangle, 6562 throttle, 6563 debounce, 6564 evaluate, 6565 initTree, 6566 nextTick, 6567 prefixed: prefix, 6568 prefix: setPrefix, 6569 plugin, 6570 magic, 6571 store, 6572 start, 6573 clone, 6574 // INTERNAL 6575 cloneNode, 6576 // INTERNAL 6577 bound: getBinding, 6578 $data: scope, 6579 walk, 6580 data, 6581 bind: bind2 6582}; 6583var alpine_default = Alpine; 6584 6585// node_modules/@vue/shared/dist/shared.esm-bundler.js 6586function makeMap(str, expectsLowerCase) { 6587 const map = /* @__PURE__ */ Object.create(null); 6588 const list = str.split(","); 6589 for (let i = 0; i < list.length; i++) { 6590 map[list[i]] = true; 6591 } 6592 return expectsLowerCase ? (val) => !!map[val.toLowerCase()] : (val) => !!map[val]; 6593} 6594var specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`; 6595var isBooleanAttr2 = /* @__PURE__ */ makeMap(specialBooleanAttrs + `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`); 6596var EMPTY_OBJ = true ? Object.freeze({}) : 0; 6597var EMPTY_ARR = true ? Object.freeze([]) : 0; 6598var hasOwnProperty = Object.prototype.hasOwnProperty; 6599var hasOwn = (val, key) => hasOwnProperty.call(val, key); 6600var isArray = Array.isArray; 6601var isMap = (val) => toTypeString(val) === "[object Map]"; 6602var isString = (val) => typeof val === "string"; 6603var isSymbol = (val) => typeof val === "symbol"; 6604var isObject = (val) => val !== null && typeof val === "object"; 6605var objectToString = Object.prototype.toString; 6606var toTypeString = (value) => objectToString.call(value); 6607var toRawType = (value) => { 6608 return toTypeString(value).slice(8, -1); 6609}; 6610var isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key; 6611var cacheStringFunction = (fn) => { 6612 const cache = /* @__PURE__ */ Object.create(null); 6613 return (str) => { 6614 const hit = cache[str]; 6615 return hit || (cache[str] = fn(str)); 6616 }; 6617}; 6618var camelizeRE = /-(\w)/g; 6619var camelize = cacheStringFunction((str) => { 6620 return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : ""); 6621}); 6622var hyphenateRE = /\B([A-Z])/g; 6623var hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase()); 6624var capitalize = cacheStringFunction((str) => str.charAt(0).toUpperCase() + str.slice(1)); 6625var toHandlerKey = cacheStringFunction((str) => str ? `on${capitalize(str)}` : ``); 6626var hasChanged = (value, oldValue) => value !== oldValue && (value === value || oldValue === oldValue); 6627 6628// node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js 6629var targetMap = /* @__PURE__ */ new WeakMap(); 6630var effectStack = []; 6631var activeEffect; 6632var ITERATE_KEY = Symbol( true ? "iterate" : 0); 6633var MAP_KEY_ITERATE_KEY = Symbol( true ? "Map key iterate" : 0); 6634function isEffect(fn) { 6635 return fn && fn._isEffect === true; 6636} 6637function effect2(fn, options = EMPTY_OBJ) { 6638 if (isEffect(fn)) { 6639 fn = fn.raw; 6640 } 6641 const effect3 = createReactiveEffect(fn, options); 6642 if (!options.lazy) { 6643 effect3(); 6644 } 6645 return effect3; 6646} 6647function stop(effect3) { 6648 if (effect3.active) { 6649 cleanup(effect3); 6650 if (effect3.options.onStop) { 6651 effect3.options.onStop(); 6652 } 6653 effect3.active = false; 6654 } 6655} 6656var uid = 0; 6657function createReactiveEffect(fn, options) { 6658 const effect3 = function reactiveEffect() { 6659 if (!effect3.active) { 6660 return fn(); 6661 } 6662 if (!effectStack.includes(effect3)) { 6663 cleanup(effect3); 6664 try { 6665 enableTracking(); 6666 effectStack.push(effect3); 6667 activeEffect = effect3; 6668 return fn(); 6669 } finally { 6670 effectStack.pop(); 6671 resetTracking(); 6672 activeEffect = effectStack[effectStack.length - 1]; 6673 } 6674 } 6675 }; 6676 effect3.id = uid++; 6677 effect3.allowRecurse = !!options.allowRecurse; 6678 effect3._isEffect = true; 6679 effect3.active = true; 6680 effect3.raw = fn; 6681 effect3.deps = []; 6682 effect3.options = options; 6683 return effect3; 6684} 6685function cleanup(effect3) { 6686 const { deps } = effect3; 6687 if (deps.length) { 6688 for (let i = 0; i < deps.length; i++) { 6689 deps[i].delete(effect3); 6690 } 6691 deps.length = 0; 6692 } 6693} 6694var shouldTrack = true; 6695var trackStack = []; 6696function pauseTracking() { 6697 trackStack.push(shouldTrack); 6698 shouldTrack = false; 6699} 6700function enableTracking() { 6701 trackStack.push(shouldTrack); 6702 shouldTrack = true; 6703} 6704function resetTracking() { 6705 const last = trackStack.pop(); 6706 shouldTrack = last === void 0 ? true : last; 6707} 6708function track(target, type, key) { 6709 if (!shouldTrack || activeEffect === void 0) { 6710 return; 6711 } 6712 let depsMap = targetMap.get(target); 6713 if (!depsMap) { 6714 targetMap.set(target, depsMap = /* @__PURE__ */ new Map()); 6715 } 6716 let dep = depsMap.get(key); 6717 if (!dep) { 6718 depsMap.set(key, dep = /* @__PURE__ */ new Set()); 6719 } 6720 if (!dep.has(activeEffect)) { 6721 dep.add(activeEffect); 6722 activeEffect.deps.push(dep); 6723 if (activeEffect.options.onTrack) { 6724 activeEffect.options.onTrack({ 6725 effect: activeEffect, 6726 target, 6727 type, 6728 key 6729 }); 6730 } 6731 } 6732} 6733function trigger(target, type, key, newValue, oldValue, oldTarget) { 6734 const depsMap = targetMap.get(target); 6735 if (!depsMap) { 6736 return; 6737 } 6738 const effects = /* @__PURE__ */ new Set(); 6739 const add2 = (effectsToAdd) => { 6740 if (effectsToAdd) { 6741 effectsToAdd.forEach((effect3) => { 6742 if (effect3 !== activeEffect || effect3.allowRecurse) { 6743 effects.add(effect3); 6744 } 6745 }); 6746 } 6747 }; 6748 if (type === "clear") { 6749 depsMap.forEach(add2); 6750 } else if (key === "length" && isArray(target)) { 6751 depsMap.forEach((dep, key2) => { 6752 if (key2 === "length" || key2 >= newValue) { 6753 add2(dep); 6754 } 6755 }); 6756 } else { 6757 if (key !== void 0) { 6758 add2(depsMap.get(key)); 6759 } 6760 switch (type) { 6761 case "add": 6762 if (!isArray(target)) { 6763 add2(depsMap.get(ITERATE_KEY)); 6764 if (isMap(target)) { 6765 add2(depsMap.get(MAP_KEY_ITERATE_KEY)); 6766 } 6767 } else if (isIntegerKey(key)) { 6768 add2(depsMap.get("length")); 6769 } 6770 break; 6771 case "delete": 6772 if (!isArray(target)) { 6773 add2(depsMap.get(ITERATE_KEY)); 6774 if (isMap(target)) { 6775 add2(depsMap.get(MAP_KEY_ITERATE_KEY)); 6776 } 6777 } 6778 break; 6779 case "set": 6780 if (isMap(target)) { 6781 add2(depsMap.get(ITERATE_KEY)); 6782 } 6783 break; 6784 } 6785 } 6786 const run = (effect3) => { 6787 if (effect3.options.onTrigger) { 6788 effect3.options.onTrigger({ 6789 effect: effect3, 6790 target, 6791 key, 6792 type, 6793 newValue, 6794 oldValue, 6795 oldTarget 6796 }); 6797 } 6798 if (effect3.options.scheduler) { 6799 effect3.options.scheduler(effect3); 6800 } else { 6801 effect3(); 6802 } 6803 }; 6804 effects.forEach(run); 6805} 6806var isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`); 6807var builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol).map((key) => Symbol[key]).filter(isSymbol)); 6808var get2 = /* @__PURE__ */ createGetter(); 6809var readonlyGet = /* @__PURE__ */ createGetter(true); 6810var arrayInstrumentations = /* @__PURE__ */ createArrayInstrumentations(); 6811function createArrayInstrumentations() { 6812 const instrumentations = {}; 6813 ["includes", "indexOf", "lastIndexOf"].forEach((key) => { 6814 instrumentations[key] = function(...args) { 6815 const arr = toRaw(this); 6816 for (let i = 0, l = this.length; i < l; i++) { 6817 track(arr, "get", i + ""); 6818 } 6819 const res = arr[key](...args); 6820 if (res === -1 || res === false) { 6821 return arr[key](...args.map(toRaw)); 6822 } else { 6823 return res; 6824 } 6825 }; 6826 }); 6827 ["push", "pop", "shift", "unshift", "splice"].forEach((key) => { 6828 instrumentations[key] = function(...args) { 6829 pauseTracking(); 6830 const res = toRaw(this)[key].apply(this, args); 6831 resetTracking(); 6832 return res; 6833 }; 6834 }); 6835 return instrumentations; 6836} 6837function createGetter(isReadonly = false, shallow = false) { 6838 return function get3(target, key, receiver) { 6839 if (key === "__v_isReactive") { 6840 return !isReadonly; 6841 } else if (key === "__v_isReadonly") { 6842 return isReadonly; 6843 } else if (key === "__v_raw" && receiver === (isReadonly ? shallow ? shallowReadonlyMap : readonlyMap : shallow ? shallowReactiveMap : reactiveMap).get(target)) { 6844 return target; 6845 } 6846 const targetIsArray = isArray(target); 6847 if (!isReadonly && targetIsArray && hasOwn(arrayInstrumentations, key)) { 6848 return Reflect.get(arrayInstrumentations, key, receiver); 6849 } 6850 const res = Reflect.get(target, key, receiver); 6851 if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) { 6852 return res; 6853 } 6854 if (!isReadonly) { 6855 track(target, "get", key); 6856 } 6857 if (shallow) { 6858 return res; 6859 } 6860 if (isRef(res)) { 6861 const shouldUnwrap = !targetIsArray || !isIntegerKey(key); 6862 return shouldUnwrap ? res.value : res; 6863 } 6864 if (isObject(res)) { 6865 return isReadonly ? readonly(res) : reactive2(res); 6866 } 6867 return res; 6868 }; 6869} 6870var set2 = /* @__PURE__ */ createSetter(); 6871function createSetter(shallow = false) { 6872 return function set3(target, key, value, receiver) { 6873 let oldValue = target[key]; 6874 if (!shallow) { 6875 value = toRaw(value); 6876 oldValue = toRaw(oldValue); 6877 if (!isArray(target) && isRef(oldValue) && !isRef(value)) { 6878 oldValue.value = value; 6879 return true; 6880 } 6881 } 6882 const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key); 6883 const result = Reflect.set(target, key, value, receiver); 6884 if (target === toRaw(receiver)) { 6885 if (!hadKey) { 6886 trigger(target, "add", key, value); 6887 } else if (hasChanged(value, oldValue)) { 6888 trigger(target, "set", key, value, oldValue); 6889 } 6890 } 6891 return result; 6892 }; 6893} 6894function deleteProperty(target, key) { 6895 const hadKey = hasOwn(target, key); 6896 const oldValue = target[key]; 6897 const result = Reflect.deleteProperty(target, key); 6898 if (result && hadKey) { 6899 trigger(target, "delete", key, void 0, oldValue); 6900 } 6901 return result; 6902} 6903function has(target, key) { 6904 const result = Reflect.has(target, key); 6905 if (!isSymbol(key) || !builtInSymbols.has(key)) { 6906 track(target, "has", key); 6907 } 6908 return result; 6909} 6910function ownKeys(target) { 6911 track(target, "iterate", isArray(target) ? "length" : ITERATE_KEY); 6912 return Reflect.ownKeys(target); 6913} 6914var mutableHandlers = { 6915 get: get2, 6916 set: set2, 6917 deleteProperty, 6918 has, 6919 ownKeys 6920}; 6921var readonlyHandlers = { 6922 get: readonlyGet, 6923 set(target, key) { 6924 if (true) { 6925 console.warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target); 6926 } 6927 return true; 6928 }, 6929 deleteProperty(target, key) { 6930 if (true) { 6931 console.warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target); 6932 } 6933 return true; 6934 } 6935}; 6936var toReactive = (value) => isObject(value) ? reactive2(value) : value; 6937var toReadonly = (value) => isObject(value) ? readonly(value) : value; 6938var toShallow = (value) => value; 6939var getProto = (v) => Reflect.getPrototypeOf(v); 6940function get$1(target, key, isReadonly = false, isShallow = false) { 6941 target = target[ 6942 "__v_raw" 6943 /* RAW */ 6944 ]; 6945 const rawTarget = toRaw(target); 6946 const rawKey = toRaw(key); 6947 if (key !== rawKey) { 6948 !isReadonly && track(rawTarget, "get", key); 6949 } 6950 !isReadonly && track(rawTarget, "get", rawKey); 6951 const { has: has2 } = getProto(rawTarget); 6952 const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive; 6953 if (has2.call(rawTarget, key)) { 6954 return wrap(target.get(key)); 6955 } else if (has2.call(rawTarget, rawKey)) { 6956 return wrap(target.get(rawKey)); 6957 } else if (target !== rawTarget) { 6958 target.get(key); 6959 } 6960} 6961function has$1(key, isReadonly = false) { 6962 const target = this[ 6963 "__v_raw" 6964 /* RAW */ 6965 ]; 6966 const rawTarget = toRaw(target); 6967 const rawKey = toRaw(key); 6968 if (key !== rawKey) { 6969 !isReadonly && track(rawTarget, "has", key); 6970 } 6971 !isReadonly && track(rawTarget, "has", rawKey); 6972 return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey); 6973} 6974function size(target, isReadonly = false) { 6975 target = target[ 6976 "__v_raw" 6977 /* RAW */ 6978 ]; 6979 !isReadonly && track(toRaw(target), "iterate", ITERATE_KEY); 6980 return Reflect.get(target, "size", target); 6981} 6982function add(value) { 6983 value = toRaw(value); 6984 const target = toRaw(this); 6985 const proto = getProto(target); 6986 const hadKey = proto.has.call(target, value); 6987 if (!hadKey) { 6988 target.add(value); 6989 trigger(target, "add", value, value); 6990 } 6991 return this; 6992} 6993function set$1(key, value) { 6994 value = toRaw(value); 6995 const target = toRaw(this); 6996 const { has: has2, get: get3 } = getProto(target); 6997 let hadKey = has2.call(target, key); 6998 if (!hadKey) { 6999 key = toRaw(key); 7000 hadKey = has2.call(target, key); 7001 } else if (true) { 7002 checkIdentityKeys(target, has2, key); 7003 } 7004 const oldValue = get3.call(target, key); 7005 target.set(key, value); 7006 if (!hadKey) { 7007 trigger(target, "add", key, value); 7008 } else if (hasChanged(value, oldValue)) { 7009 trigger(target, "set", key, value, oldValue); 7010 } 7011 return this; 7012} 7013function deleteEntry(key) { 7014 const target = toRaw(this); 7015 const { has: has2, get: get3 } = getProto(target); 7016 let hadKey = has2.call(target, key); 7017 if (!hadKey) { 7018 key = toRaw(key); 7019 hadKey = has2.call(target, key); 7020 } else if (true) { 7021 checkIdentityKeys(target, has2, key); 7022 } 7023 const oldValue = get3 ? get3.call(target, key) : void 0; 7024 const result = target.delete(key); 7025 if (hadKey) { 7026 trigger(target, "delete", key, void 0, oldValue); 7027 } 7028 return result; 7029} 7030function clear() { 7031 const target = toRaw(this); 7032 const hadItems = target.size !== 0; 7033 const oldTarget = true ? isMap(target) ? new Map(target) : new Set(target) : 0; 7034 const result = target.clear(); 7035 if (hadItems) { 7036 trigger(target, "clear", void 0, void 0, oldTarget); 7037 } 7038 return result; 7039} 7040function createForEach(isReadonly, isShallow) { 7041 return function forEach(callback, thisArg) { 7042 const observed = this; 7043 const target = observed[ 7044 "__v_raw" 7045 /* RAW */ 7046 ]; 7047 const rawTarget = toRaw(target); 7048 const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive; 7049 !isReadonly && track(rawTarget, "iterate", ITERATE_KEY); 7050 return target.forEach((value, key) => { 7051 return callback.call(thisArg, wrap(value), wrap(key), observed); 7052 }); 7053 }; 7054} 7055function createIterableMethod(method, isReadonly, isShallow) { 7056 return function(...args) { 7057 const target = this[ 7058 "__v_raw" 7059 /* RAW */ 7060 ]; 7061 const rawTarget = toRaw(target); 7062 const targetIsMap = isMap(rawTarget); 7063 const isPair = method === "entries" || method === Symbol.iterator && targetIsMap; 7064 const isKeyOnly = method === "keys" && targetIsMap; 7065 const innerIterator = target[method](...args); 7066 const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive; 7067 !isReadonly && track(rawTarget, "iterate", isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY); 7068 return { 7069 // iterator protocol 7070 next() { 7071 const { value, done } = innerIterator.next(); 7072 return done ? { value, done } : { 7073 value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value), 7074 done 7075 }; 7076 }, 7077 // iterable protocol 7078 [Symbol.iterator]() { 7079 return this; 7080 } 7081 }; 7082 }; 7083} 7084function createReadonlyMethod(type) { 7085 return function(...args) { 7086 if (true) { 7087 const key = args[0] ? `on key "${args[0]}" ` : ``; 7088 console.warn(`${capitalize(type)} operation ${key}failed: target is readonly.`, toRaw(this)); 7089 } 7090 return type === "delete" ? false : this; 7091 }; 7092} 7093function createInstrumentations() { 7094 const mutableInstrumentations2 = { 7095 get(key) { 7096 return get$1(this, key); 7097 }, 7098 get size() { 7099 return size(this); 7100 }, 7101 has: has$1, 7102 add, 7103 set: set$1, 7104 delete: deleteEntry, 7105 clear, 7106 forEach: createForEach(false, false) 7107 }; 7108 const shallowInstrumentations2 = { 7109 get(key) { 7110 return get$1(this, key, false, true); 7111 }, 7112 get size() { 7113 return size(this); 7114 }, 7115 has: has$1, 7116 add, 7117 set: set$1, 7118 delete: deleteEntry, 7119 clear, 7120 forEach: createForEach(false, true) 7121 }; 7122 const readonlyInstrumentations2 = { 7123 get(key) { 7124 return get$1(this, key, true); 7125 }, 7126 get size() { 7127 return size(this, true); 7128 }, 7129 has(key) { 7130 return has$1.call(this, key, true); 7131 }, 7132 add: createReadonlyMethod( 7133 "add" 7134 /* ADD */ 7135 ), 7136 set: createReadonlyMethod( 7137 "set" 7138 /* SET */ 7139 ), 7140 delete: createReadonlyMethod( 7141 "delete" 7142 /* DELETE */ 7143 ), 7144 clear: createReadonlyMethod( 7145 "clear" 7146 /* CLEAR */ 7147 ), 7148 forEach: createForEach(true, false) 7149 }; 7150 const shallowReadonlyInstrumentations2 = { 7151 get(key) { 7152 return get$1(this, key, true, true); 7153 }, 7154 get size() { 7155 return size(this, true); 7156 }, 7157 has(key) { 7158 return has$1.call(this, key, true); 7159 }, 7160 add: createReadonlyMethod( 7161 "add" 7162 /* ADD */ 7163 ), 7164 set: createReadonlyMethod( 7165 "set" 7166 /* SET */ 7167 ), 7168 delete: createReadonlyMethod( 7169 "delete" 7170 /* DELETE */ 7171 ), 7172 clear: createReadonlyMethod( 7173 "clear" 7174 /* CLEAR */ 7175 ), 7176 forEach: createForEach(true, true) 7177 }; 7178 const iteratorMethods = ["keys", "values", "entries", Symbol.iterator]; 7179 iteratorMethods.forEach((method) => { 7180 mutableInstrumentations2[method] = createIterableMethod(method, false, false); 7181 readonlyInstrumentations2[method] = createIterableMethod(method, true, false); 7182 shallowInstrumentations2[method] = createIterableMethod(method, false, true); 7183 shallowReadonlyInstrumentations2[method] = createIterableMethod(method, true, true); 7184 }); 7185 return [ 7186 mutableInstrumentations2, 7187 readonlyInstrumentations2, 7188 shallowInstrumentations2, 7189 shallowReadonlyInstrumentations2 7190 ]; 7191} 7192var [mutableInstrumentations, readonlyInstrumentations, shallowInstrumentations, shallowReadonlyInstrumentations] = /* @__PURE__ */ createInstrumentations(); 7193function createInstrumentationGetter(isReadonly, shallow) { 7194 const instrumentations = shallow ? isReadonly ? shallowReadonlyInstrumentations : shallowInstrumentations : isReadonly ? readonlyInstrumentations : mutableInstrumentations; 7195 return (target, key, receiver) => { 7196 if (key === "__v_isReactive") { 7197 return !isReadonly; 7198 } else if (key === "__v_isReadonly") { 7199 return isReadonly; 7200 } else if (key === "__v_raw") { 7201 return target; 7202 } 7203 return Reflect.get(hasOwn(instrumentations, key) && key in target ? instrumentations : target, key, receiver); 7204 }; 7205} 7206var mutableCollectionHandlers = { 7207 get: /* @__PURE__ */ createInstrumentationGetter(false, false) 7208}; 7209var readonlyCollectionHandlers = { 7210 get: /* @__PURE__ */ createInstrumentationGetter(true, false) 7211}; 7212function checkIdentityKeys(target, has2, key) { 7213 const rawKey = toRaw(key); 7214 if (rawKey !== key && has2.call(target, rawKey)) { 7215 const type = toRawType(target); 7216 console.warn(`Reactive ${type} contains both the raw and reactive versions of the same object${type === `Map` ? ` as keys` : ``}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`); 7217 } 7218} 7219var reactiveMap = /* @__PURE__ */ new WeakMap(); 7220var shallowReactiveMap = /* @__PURE__ */ new WeakMap(); 7221var readonlyMap = /* @__PURE__ */ new WeakMap(); 7222var shallowReadonlyMap = /* @__PURE__ */ new WeakMap(); 7223function targetTypeMap(rawType) { 7224 switch (rawType) { 7225 case "Object": 7226 case "Array": 7227 return 1; 7228 case "Map": 7229 case "Set": 7230 case "WeakMap": 7231 case "WeakSet": 7232 return 2; 7233 default: 7234 return 0; 7235 } 7236} 7237function getTargetType(value) { 7238 return value[ 7239 "__v_skip" 7240 /* SKIP */ 7241 ] || !Object.isExtensible(value) ? 0 : targetTypeMap(toRawType(value)); 7242} 7243function reactive2(target) { 7244 if (target && target[ 7245 "__v_isReadonly" 7246 /* IS_READONLY */ 7247 ]) { 7248 return target; 7249 } 7250 return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap); 7251} 7252function readonly(target) { 7253 return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap); 7254} 7255function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) { 7256 if (!isObject(target)) { 7257 if (true) { 7258 console.warn(`value cannot be made reactive: ${String(target)}`); 7259 } 7260 return target; 7261 } 7262 if (target[ 7263 "__v_raw" 7264 /* RAW */ 7265 ] && !(isReadonly && target[ 7266 "__v_isReactive" 7267 /* IS_REACTIVE */ 7268 ])) { 7269 return target; 7270 } 7271 const existingProxy = proxyMap.get(target); 7272 if (existingProxy) { 7273 return existingProxy; 7274 } 7275 const targetType = getTargetType(target); 7276 if (targetType === 0) { 7277 return target; 7278 } 7279 const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers); 7280 proxyMap.set(target, proxy); 7281 return proxy; 7282} 7283function toRaw(observed) { 7284 return observed && toRaw(observed[ 7285 "__v_raw" 7286 /* RAW */ 7287 ]) || observed; 7288} 7289function isRef(r) { 7290 return Boolean(r && r.__v_isRef === true); 7291} 7292 7293// packages/alpinejs/src/magics/$nextTick.js 7294magic("nextTick", () => nextTick); 7295 7296// packages/alpinejs/src/magics/$dispatch.js 7297magic("dispatch", (el) => dispatch.bind(dispatch, el)); 7298 7299// packages/alpinejs/src/magics/$watch.js 7300magic("watch", (el, { evaluateLater: evaluateLater2, effect: effect3 }) => (key, callback) => { 7301 let evaluate2 = evaluateLater2(key); 7302 let firstTime = true; 7303 let oldValue; 7304 let effectReference = effect3(() => evaluate2((value) => { 7305 JSON.stringify(value); 7306 if (!firstTime) { 7307 queueMicrotask(() => { 7308 callback(value, oldValue); 7309 oldValue = value; 7310 }); 7311 } else { 7312 oldValue = value; 7313 } 7314 firstTime = false; 7315 })); 7316 el._x_effects.delete(effectReference); 7317}); 7318 7319// packages/alpinejs/src/magics/$store.js 7320magic("store", getStores); 7321 7322// packages/alpinejs/src/magics/$data.js 7323magic("data", (el) => scope(el)); 7324 7325// packages/alpinejs/src/magics/$root.js 7326magic("root", (el) => closestRoot(el)); 7327 7328// packages/alpinejs/src/magics/$refs.js 7329magic("refs", (el) => { 7330 if (el._x_refs_proxy) 7331 return el._x_refs_proxy; 7332 el._x_refs_proxy = mergeProxies(getArrayOfRefObject(el)); 7333 return el._x_refs_proxy; 7334}); 7335function getArrayOfRefObject(el) { 7336 let refObjects = []; 7337 let currentEl = el; 7338 while (currentEl) { 7339 if (currentEl._x_refs) 7340 refObjects.push(currentEl._x_refs); 7341 currentEl = currentEl.parentNode; 7342 } 7343 return refObjects; 7344} 7345 7346// packages/alpinejs/src/ids.js 7347var globalIdMemo = {}; 7348function findAndIncrementId(name) { 7349 if (!globalIdMemo[name]) 7350 globalIdMemo[name] = 0; 7351 return ++globalIdMemo[name]; 7352} 7353function closestIdRoot(el, name) { 7354 return findClosest(el, (element) => { 7355 if (element._x_ids && element._x_ids[name]) 7356 return true; 7357 }); 7358} 7359function setIdRoot(el, name) { 7360 if (!el._x_ids) 7361 el._x_ids = {}; 7362 if (!el._x_ids[name]) 7363 el._x_ids[name] = findAndIncrementId(name); 7364} 7365 7366// packages/alpinejs/src/magics/$id.js 7367magic("id", (el) => (name, key = null) => { 7368 let root = closestIdRoot(el, name); 7369 let id = root ? root._x_ids[name] : findAndIncrementId(name); 7370 return key ? `${name}-${id}-${key}` : `${name}-${id}`; 7371}); 7372 7373// packages/alpinejs/src/magics/$el.js 7374magic("el", (el) => el); 7375 7376// packages/alpinejs/src/magics/index.js 7377warnMissingPluginMagic("Focus", "focus", "focus"); 7378warnMissingPluginMagic("Persist", "persist", "persist"); 7379function warnMissingPluginMagic(name, magicName, slug) { 7380 magic(magicName, (el) => warn(`You can't use [$${directiveName}] without first installing the "${name}" plugin here: https://alpinejs.dev/plugins/${slug}`, el)); 7381} 7382 7383// packages/alpinejs/src/directives/x-modelable.js 7384directive("modelable", (el, { expression }, { effect: effect3, evaluateLater: evaluateLater2, cleanup: cleanup2 }) => { 7385 let func = evaluateLater2(expression); 7386 let innerGet = () => { 7387 let result; 7388 func((i) => result = i); 7389 return result; 7390 }; 7391 let evaluateInnerSet = evaluateLater2(`${expression} = __placeholder`); 7392 let innerSet = (val) => evaluateInnerSet(() => { 7393 }, { scope: { "__placeholder": val } }); 7394 let initialValue = innerGet(); 7395 innerSet(initialValue); 7396 queueMicrotask(() => { 7397 if (!el._x_model) 7398 return; 7399 el._x_removeModelListeners["default"](); 7400 let outerGet = el._x_model.get; 7401 let outerSet = el._x_model.set; 7402 let releaseEntanglement = entangle( 7403 { 7404 get() { 7405 return outerGet(); 7406 }, 7407 set(value) { 7408 outerSet(value); 7409 } 7410 }, 7411 { 7412 get() { 7413 return innerGet(); 7414 }, 7415 set(value) { 7416 innerSet(value); 7417 } 7418 } 7419 ); 7420 cleanup2(releaseEntanglement); 7421 }); 7422}); 7423 7424// packages/alpinejs/src/directives/x-teleport.js 7425var teleportContainerDuringClone = document.createElement("div"); 7426directive("teleport", (el, { modifiers, expression }, { cleanup: cleanup2 }) => { 7427 if (el.tagName.toLowerCase() !== "template") 7428 warn("x-teleport can only be used on a <template> tag", el); 7429 let target = skipDuringClone(() => { 7430 return document.querySelector(expression); 7431 }, () => { 7432 return teleportContainerDuringClone; 7433 })(); 7434 if (!target) 7435 warn(`Cannot find x-teleport element for selector: "${expression}"`); 7436 let clone2 = el.content.cloneNode(true).firstElementChild; 7437 el._x_teleport = clone2; 7438 clone2._x_teleportBack = el; 7439 if (el._x_forwardEvents) { 7440 el._x_forwardEvents.forEach((eventName) => { 7441 clone2.addEventListener(eventName, (e) => { 7442 e.stopPropagation(); 7443 el.dispatchEvent(new e.constructor(e.type, e)); 7444 }); 7445 }); 7446 } 7447 addScopeToNode(clone2, {}, el); 7448 mutateDom(() => { 7449 if (modifiers.includes("prepend")) { 7450 target.parentNode.insertBefore(clone2, target); 7451 } else if (modifiers.includes("append")) { 7452 target.parentNode.insertBefore(clone2, target.nextSibling); 7453 } else { 7454 target.appendChild(clone2); 7455 } 7456 initTree(clone2); 7457 clone2._x_ignore = true; 7458 }); 7459 cleanup2(() => clone2.remove()); 7460}); 7461 7462// packages/alpinejs/src/directives/x-ignore.js 7463var handler = () => { 7464}; 7465handler.inline = (el, { modifiers }, { cleanup: cleanup2 }) => { 7466 modifiers.includes("self") ? el._x_ignoreSelf = true : el._x_ignore = true; 7467 cleanup2(() => { 7468 modifiers.includes("self") ? delete el._x_ignoreSelf : delete el._x_ignore; 7469 }); 7470}; 7471directive("ignore", handler); 7472 7473// packages/alpinejs/src/directives/x-effect.js 7474directive("effect", (el, { expression }, { effect: effect3 }) => effect3(evaluateLater(el, expression))); 7475 7476// packages/alpinejs/src/utils/on.js 7477function on(el, event, modifiers, callback) { 7478 let listenerTarget = el; 7479 let handler4 = (e) => callback(e); 7480 let options = {}; 7481 let wrapHandler = (callback2, wrapper) => (e) => wrapper(callback2, e); 7482 if (modifiers.includes("dot")) 7483 event = dotSyntax(event); 7484 if (modifiers.includes("camel")) 7485 event = camelCase2(event); 7486 if (modifiers.includes("passive")) 7487 options.passive = true; 7488 if (modifiers.includes("capture")) 7489 options.capture = true; 7490 if (modifiers.includes("window")) 7491 listenerTarget = window; 7492 if (modifiers.includes("document")) 7493 listenerTarget = document; 7494 if (modifiers.includes("debounce")) { 7495 let nextModifier = modifiers[modifiers.indexOf("debounce") + 1] || "invalid-wait"; 7496 let wait = isNumeric(nextModifier.split("ms")[0]) ? Number(nextModifier.split("ms")[0]) : 250; 7497 handler4 = debounce(handler4, wait); 7498 } 7499 if (modifiers.includes("throttle")) { 7500 let nextModifier = modifiers[modifiers.indexOf("throttle") + 1] || "invalid-wait"; 7501 let wait = isNumeric(nextModifier.split("ms")[0]) ? Number(nextModifier.split("ms")[0]) : 250; 7502 handler4 = throttle(handler4, wait); 7503 } 7504 if (modifiers.includes("prevent")) 7505 handler4 = wrapHandler(handler4, (next, e) => { 7506 e.preventDefault(); 7507 next(e); 7508 }); 7509 if (modifiers.includes("stop")) 7510 handler4 = wrapHandler(handler4, (next, e) => { 7511 e.stopPropagation(); 7512 next(e); 7513 }); 7514 if (modifiers.includes("self")) 7515 handler4 = wrapHandler(handler4, (next, e) => { 7516 e.target === el && next(e); 7517 }); 7518 if (modifiers.includes("away") || modifiers.includes("outside")) { 7519 listenerTarget = document; 7520 handler4 = wrapHandler(handler4, (next, e) => { 7521 if (el.contains(e.target)) 7522 return; 7523 if (e.target.isConnected === false) 7524 return; 7525 if (el.offsetWidth < 1 && el.offsetHeight < 1) 7526 return; 7527 if (el._x_isShown === false) 7528 return; 7529 next(e); 7530 }); 7531 } 7532 if (modifiers.includes("once")) { 7533 handler4 = wrapHandler(handler4, (next, e) => { 7534 next(e); 7535 listenerTarget.removeEventListener(event, handler4, options); 7536 }); 7537 } 7538 handler4 = wrapHandler(handler4, (next, e) => { 7539 if (isKeyEvent(event)) { 7540 if (isListeningForASpecificKeyThatHasntBeenPressed(e, modifiers)) { 7541 return; 7542 } 7543 } 7544 next(e); 7545 }); 7546 listenerTarget.addEventListener(event, handler4, options); 7547 return () => { 7548 listenerTarget.removeEventListener(event, handler4, options); 7549 }; 7550} 7551function dotSyntax(subject) { 7552 return subject.replace(/-/g, "."); 7553} 7554function camelCase2(subject) { 7555 return subject.toLowerCase().replace(/-(\w)/g, (match, char) => char.toUpperCase()); 7556} 7557function isNumeric(subject) { 7558 return !Array.isArray(subject) && !isNaN(subject); 7559} 7560function kebabCase2(subject) { 7561 if ([" ", "_"].includes( 7562 subject 7563 )) 7564 return subject; 7565 return subject.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[_\s]/, "-").toLowerCase(); 7566} 7567function isKeyEvent(event) { 7568 return ["keydown", "keyup"].includes(event); 7569} 7570function isListeningForASpecificKeyThatHasntBeenPressed(e, modifiers) { 7571 let keyModifiers = modifiers.filter((i) => { 7572 return !["window", "document", "prevent", "stop", "once", "capture"].includes(i); 7573 }); 7574 if (keyModifiers.includes("debounce")) { 7575 let debounceIndex = keyModifiers.indexOf("debounce"); 7576 keyModifiers.splice(debounceIndex, isNumeric((keyModifiers[debounceIndex + 1] || "invalid-wait").split("ms")[0]) ? 2 : 1); 7577 } 7578 if (keyModifiers.includes("throttle")) { 7579 let debounceIndex = keyModifiers.indexOf("throttle"); 7580 keyModifiers.splice(debounceIndex, isNumeric((keyModifiers[debounceIndex + 1] || "invalid-wait").split("ms")[0]) ? 2 : 1); 7581 } 7582 if (keyModifiers.length === 0) 7583 return false; 7584 if (keyModifiers.length === 1 && keyToModifiers(e.key).includes(keyModifiers[0])) 7585 return false; 7586 const systemKeyModifiers = ["ctrl", "shift", "alt", "meta", "cmd", "super"]; 7587 const selectedSystemKeyModifiers = systemKeyModifiers.filter((modifier) => keyModifiers.includes(modifier)); 7588 keyModifiers = keyModifiers.filter((i) => !selectedSystemKeyModifiers.includes(i)); 7589 if (selectedSystemKeyModifiers.length > 0) { 7590 const activelyPressedKeyModifiers = selectedSystemKeyModifiers.filter((modifier) => { 7591 if (modifier === "cmd" || modifier === "super") 7592 modifier = "meta"; 7593 return e[`${modifier}Key`]; 7594 }); 7595 if (activelyPressedKeyModifiers.length === selectedSystemKeyModifiers.length) { 7596 if (keyToModifiers(e.key).includes(keyModifiers[0])) 7597 return false; 7598 } 7599 } 7600 return true; 7601} 7602function keyToModifiers(key) { 7603 if (!key) 7604 return []; 7605 key = kebabCase2(key); 7606 let modifierToKeyMap = { 7607 "ctrl": "control", 7608 "slash": "/", 7609 "space": " ", 7610 "spacebar": " ", 7611 "cmd": "meta", 7612 "esc": "escape", 7613 "up": "arrow-up", 7614 "down": "arrow-down", 7615 "left": "arrow-left", 7616 "right": "arrow-right", 7617 "period": ".", 7618 "equal": "=", 7619 "minus": "-", 7620 "underscore": "_" 7621 }; 7622 modifierToKeyMap[key] = key; 7623 return Object.keys(modifierToKeyMap).map((modifier) => { 7624 if (modifierToKeyMap[modifier] === key) 7625 return modifier; 7626 }).filter((modifier) => modifier); 7627} 7628 7629// packages/alpinejs/src/directives/x-model.js 7630directive("model", (el, { modifiers, expression }, { effect: effect3, cleanup: cleanup2 }) => { 7631 let scopeTarget = el; 7632 if (modifiers.includes("parent")) { 7633 scopeTarget = el.parentNode; 7634 } 7635 let evaluateGet = evaluateLater(scopeTarget, expression); 7636 let evaluateSet; 7637 if (typeof expression === "string") { 7638 evaluateSet = evaluateLater(scopeTarget, `${expression} = __placeholder`); 7639 } else if (typeof expression === "function" && typeof expression() === "string") { 7640 evaluateSet = evaluateLater(scopeTarget, `${expression()} = __placeholder`); 7641 } else { 7642 evaluateSet = () => { 7643 }; 7644 } 7645 let getValue = () => { 7646 let result; 7647 evaluateGet((value) => result = value); 7648 return isGetterSetter(result) ? result.get() : result; 7649 }; 7650 let setValue = (value) => { 7651 let result; 7652 evaluateGet((value2) => result = value2); 7653 if (isGetterSetter(result)) { 7654 result.set(value); 7655 } else { 7656 evaluateSet(() => { 7657 }, { 7658 scope: { "__placeholder": value } 7659 }); 7660 } 7661 }; 7662 if (typeof expression === "string" && el.type === "radio") { 7663 mutateDom(() => { 7664 if (!el.hasAttribute("name")) 7665 el.setAttribute("name", expression); 7666 }); 7667 } 7668 var event = el.tagName.toLowerCase() === "select" || ["checkbox", "radio"].includes(el.type) || modifiers.includes("lazy") ? "change" : "input"; 7669 let removeListener = isCloning ? () => { 7670 } : on(el, event, modifiers, (e) => { 7671 setValue(getInputValue(el, modifiers, e, getValue())); 7672 }); 7673 if (modifiers.includes("fill")) { 7674 if ([null, ""].includes(getValue()) || el.type === "checkbox" && Array.isArray(getValue())) { 7675 el.dispatchEvent(new Event(event, {})); 7676 } 7677 } 7678 if (!el._x_removeModelListeners) 7679 el._x_removeModelListeners = {}; 7680 el._x_removeModelListeners["default"] = removeListener; 7681 cleanup2(() => el._x_removeModelListeners["default"]()); 7682 if (el.form) { 7683 let removeResetListener = on(el.form, "reset", [], (e) => { 7684 nextTick(() => el._x_model && el._x_model.set(el.value)); 7685 }); 7686 cleanup2(() => removeResetListener()); 7687 } 7688 el._x_model = { 7689 get() { 7690 return getValue(); 7691 }, 7692 set(value) { 7693 setValue(value); 7694 } 7695 }; 7696 el._x_forceModelUpdate = (value) => { 7697 if (value === void 0 && typeof expression === "string" && expression.match(/\./)) 7698 value = ""; 7699 window.fromModel = true; 7700 mutateDom(() => bind(el, "value", value)); 7701 delete window.fromModel; 7702 }; 7703 effect3(() => { 7704 let value = getValue(); 7705 if (modifiers.includes("unintrusive") && document.activeElement.isSameNode(el)) 7706 return; 7707 el._x_forceModelUpdate(value); 7708 }); 7709}); 7710function getInputValue(el, modifiers, event, currentValue) { 7711 return mutateDom(() => { 7712 if (event instanceof CustomEvent && event.detail !== void 0) 7713 return event.detail ?? event.target.value; 7714 else if (el.type === "checkbox") { 7715 if (Array.isArray(currentValue)) { 7716 let newValue = modifiers.includes("number") ? safeParseNumber(event.target.value) : event.target.value; 7717 return event.target.checked ? currentValue.concat([newValue]) : currentValue.filter((el2) => !checkedAttrLooseCompare2(el2, newValue)); 7718 } else { 7719 return event.target.checked; 7720 } 7721 } else if (el.tagName.toLowerCase() === "select" && el.multiple) { 7722 return modifiers.includes("number") ? Array.from(event.target.selectedOptions).map((option) => { 7723 let rawValue = option.value || option.text; 7724 return safeParseNumber(rawValue); 7725 }) : Array.from(event.target.selectedOptions).map((option) => { 7726 return option.value || option.text; 7727 }); 7728 } else { 7729 let rawValue = event.target.value; 7730 return modifiers.includes("number") ? safeParseNumber(rawValue) : modifiers.includes("trim") ? rawValue.trim() : rawValue; 7731 } 7732 }); 7733} 7734function safeParseNumber(rawValue) { 7735 let number = rawValue ? parseFloat(rawValue) : null; 7736 return isNumeric2(number) ? number : rawValue; 7737} 7738function checkedAttrLooseCompare2(valueA, valueB) { 7739 return valueA == valueB; 7740} 7741function isNumeric2(subject) { 7742 return !Array.isArray(subject) && !isNaN(subject); 7743} 7744function isGetterSetter(value) { 7745 return value !== null && typeof value === "object" && typeof value.get === "function" && typeof value.set === "function"; 7746} 7747 7748// packages/alpinejs/src/directives/x-cloak.js 7749directive("cloak", (el) => queueMicrotask(() => mutateDom(() => el.removeAttribute(prefix("cloak"))))); 7750 7751// packages/alpinejs/src/directives/x-init.js 7752addInitSelector(() => `[${prefix("init")}]`); 7753directive("init", skipDuringClone((el, { expression }, { evaluate: evaluate2 }) => { 7754 if (typeof expression === "string") { 7755 return !!expression.trim() && evaluate2(expression, {}, false); 7756 } 7757 return evaluate2(expression, {}, false); 7758})); 7759 7760// packages/alpinejs/src/directives/x-text.js 7761directive("text", (el, { modifiers, expression }, { effect: effect3, evaluateLater: evaluateLater2 }) => { 7762 let evaluate2 = evaluateLater2(expression); 7763 let skippedFirstTime; 7764 effect3(() => { 7765 evaluate2((value) => { 7766 mutateDom(() => { 7767 if (modifiers.includes('sft') && !skippedFirstTime) return skippedFirstTime = true; 7768 el.textContent = value; 7769 }); 7770 }); 7771 }); 7772}); 7773 7774// packages/alpinejs/src/directives/x-html.js 7775directive("html", (el, { modifiers, expression }, { effect: effect3, evaluateLater: evaluateLater2 }) => { 7776 let evaluate2 = evaluateLater2(expression); 7777 let skippedFirstTime; 7778 effect3(() => { 7779 evaluate2((value) => { 7780 mutateDom(() => { 7781 if (modifiers.includes('sft') && !skippedFirstTime) return skippedFirstTime = true; 7782 el.innerHTML = value; 7783 el._x_ignoreSelf = true; 7784 initTree(el); 7785 delete el._x_ignoreSelf; 7786 }); 7787 }); 7788 }); 7789}); 7790 7791// packages/alpinejs/src/directives/x-bind.js 7792mapAttributes(startingWith(":", into(prefix("bind:")))); 7793var handler2 = (el, { value, modifiers, expression, original }, { effect: effect3 }) => { 7794 if (!value) { 7795 let bindingProviders = {}; 7796 injectBindingProviders(bindingProviders); 7797 let getBindings = evaluateLater(el, expression); 7798 getBindings((bindings) => { 7799 applyBindingsObject(el, bindings, original); 7800 }, { scope: bindingProviders }); 7801 return; 7802 } 7803 if (value === "key") 7804 return storeKeyForXFor(el, expression); 7805 if (el._x_inlineBindings && el._x_inlineBindings[value] && el._x_inlineBindings[value].extract) { 7806 return; 7807 } 7808 let evaluate2 = evaluateLater(el, expression); 7809 let skippedFirstTime; 7810 effect3(() => evaluate2((result) => { 7811 if (modifiers.includes('sft') && !skippedFirstTime) return skippedFirstTime = true; 7812 if (result === void 0 && typeof expression === "string" && expression.match(/\./)) { 7813 result = ""; 7814 } 7815 mutateDom(() => bind(el, value, result, modifiers)); 7816 })); 7817}; 7818handler2.inline = (el, { value, modifiers, expression }) => { 7819 if (!value) 7820 return; 7821 if (!el._x_inlineBindings) 7822 el._x_inlineBindings = {}; 7823 el._x_inlineBindings[value] = { expression, extract: false }; 7824}; 7825directive("bind", handler2); 7826function storeKeyForXFor(el, expression) { 7827 el._x_keyExpression = expression; 7828} 7829 7830// packages/alpinejs/src/directives/x-data.js 7831addRootSelector(() => `[${prefix("data")}]`); 7832directive("data", (el, { expression }, { cleanup: cleanup2 }) => { 7833 if (shouldSkipRegisteringDataDuringClone(el)) 7834 return; 7835 expression = expression === "" ? "{}" : expression; 7836 let magicContext = {}; 7837 injectMagics(magicContext, el); 7838 let dataProviderContext = {}; 7839 injectDataProviders(dataProviderContext, magicContext); 7840 let data2 = evaluate(el, expression, { scope: dataProviderContext }); 7841 if (data2 === void 0 || data2 === true) 7842 data2 = {}; 7843 injectMagics(data2, el); 7844 let reactiveData = reactive(data2); 7845 initInterceptors2(reactiveData); 7846 let undo = addScopeToNode(el, reactiveData); 7847 reactiveData["init"] && evaluate(el, reactiveData["init"]); 7848 cleanup2(() => { 7849 reactiveData["destroy"] && evaluate(el, reactiveData["destroy"]); 7850 undo(); 7851 }); 7852}); 7853 7854// packages/alpinejs/src/directives/x-show.js 7855directive("show", (el, { modifiers, expression }, { effect: effect3 }) => { 7856 let evaluate2 = evaluateLater(el, expression); 7857 if (!el._x_doHide) 7858 el._x_doHide = () => { 7859 mutateDom(() => { 7860 el.style.setProperty("display", "none", modifiers.includes("important") ? "important" : void 0); 7861 }); 7862 }; 7863 if (!el._x_doShow) 7864 el._x_doShow = () => { 7865 mutateDom(() => { 7866 if (el.style.length === 1 && el.style.display === "none") { 7867 el.removeAttribute("style"); 7868 } else { 7869 el.style.removeProperty("display"); 7870 } 7871 }); 7872 }; 7873 let hide = () => { 7874 el._x_doHide(); 7875 el._x_isShown = false; 7876 }; 7877 let show = () => { 7878 el._x_doShow(); 7879 el._x_isShown = true; 7880 }; 7881 let clickAwayCompatibleShow = () => setTimeout(show); 7882 let toggle = once( 7883 (value) => value ? show() : hide(), 7884 (value) => { 7885 if (typeof el._x_toggleAndCascadeWithTransitions === "function") { 7886 el._x_toggleAndCascadeWithTransitions(el, value, show, hide); 7887 } else { 7888 value ? clickAwayCompatibleShow() : hide(); 7889 } 7890 } 7891 ); 7892 let oldValue; 7893 let firstTime = true; 7894 effect3(() => evaluate2((value) => { 7895 if (!firstTime && value === oldValue) 7896 return; 7897 if (modifiers.includes("immediate")) 7898 value ? clickAwayCompatibleShow() : hide(); 7899 toggle(value); 7900 oldValue = value; 7901 firstTime = false; 7902 })); 7903}); 7904 7905// packages/alpinejs/src/directives/x-for.js 7906directive("for", (el, { expression }, { effect: effect3, cleanup: cleanup2 }) => { 7907 let iteratorNames = parseForExpression(expression); 7908 let evaluateItems = evaluateLater(el, iteratorNames.items); 7909 let evaluateKey = evaluateLater( 7910 el, 7911 // the x-bind:key expression is stored for our use instead of evaluated. 7912 el._x_keyExpression || "index" 7913 ); 7914 el._x_prevKeys = []; 7915 el._x_lookup = {}; 7916 effect3(() => loop(el, iteratorNames, evaluateItems, evaluateKey)); 7917 cleanup2(() => { 7918 Object.values(el._x_lookup).forEach((el2) => el2.remove()); 7919 delete el._x_prevKeys; 7920 delete el._x_lookup; 7921 }); 7922}); 7923function loop(el, iteratorNames, evaluateItems, evaluateKey) { 7924 let isObject2 = (i) => typeof i === "object" && !Array.isArray(i); 7925 let templateEl = el; 7926 evaluateItems((items) => { 7927 if (isNumeric3(items) && items >= 0) { 7928 items = Array.from(Array(items).keys(), (i) => i + 1); 7929 } 7930 if (items === void 0) 7931 items = []; 7932 let lookup = el._x_lookup; 7933 let prevKeys = el._x_prevKeys; 7934 let scopes = []; 7935 let keys = []; 7936 if (isObject2(items)) { 7937 items = Object.entries(items).map(([key, value]) => { 7938 let scope2 = getIterationScopeVariables(iteratorNames, value, key, items); 7939 evaluateKey((value2) => keys.push(value2), { scope: { index: key, ...scope2 } }); 7940 scopes.push(scope2); 7941 }); 7942 } else { 7943 for (let i = 0; i < items.length; i++) { 7944 let scope2 = getIterationScopeVariables(iteratorNames, items[i], i, items); 7945 evaluateKey((value) => keys.push(value), { scope: { index: i, ...scope2 } }); 7946 scopes.push(scope2); 7947 } 7948 } 7949 let adds = []; 7950 let moves = []; 7951 let removes = []; 7952 let sames = []; 7953 for (let i = 0; i < prevKeys.length; i++) { 7954 let key = prevKeys[i]; 7955 if (keys.indexOf(key) === -1) 7956 removes.push(key); 7957 } 7958 prevKeys = prevKeys.filter((key) => !removes.includes(key)); 7959 let lastKey = "template"; 7960 for (let i = 0; i < keys.length; i++) { 7961 let key = keys[i]; 7962 let prevIndex = prevKeys.indexOf(key); 7963 if (prevIndex === -1) { 7964 prevKeys.splice(i, 0, key); 7965 adds.push([lastKey, i]); 7966 } else if (prevIndex !== i) { 7967 let keyInSpot = prevKeys.splice(i, 1)[0]; 7968 let keyForSpot = prevKeys.splice(prevIndex - 1, 1)[0]; 7969 prevKeys.splice(i, 0, keyForSpot); 7970 prevKeys.splice(prevIndex, 0, keyInSpot); 7971 moves.push([keyInSpot, keyForSpot]); 7972 } else { 7973 sames.push(key); 7974 } 7975 lastKey = key; 7976 } 7977 for (let i = 0; i < removes.length; i++) { 7978 let key = removes[i]; 7979 if (!!lookup[key]._x_effects) { 7980 lookup[key]._x_effects.forEach(dequeueJob); 7981 } 7982 lookup[key].remove(); 7983 lookup[key] = null; 7984 delete lookup[key]; 7985 } 7986 for (let i = 0; i < moves.length; i++) { 7987 let [keyInSpot, keyForSpot] = moves[i]; 7988 let elInSpot = lookup[keyInSpot]; 7989 let elForSpot = lookup[keyForSpot]; 7990 let marker = document.createElement("div"); 7991 mutateDom(() => { 7992 if (!elForSpot) 7993 warn(`x-for ":key" is undefined or invalid`, templateEl); 7994 elForSpot.after(marker); 7995 elInSpot.after(elForSpot); 7996 elForSpot._x_currentIfEl && elForSpot.after(elForSpot._x_currentIfEl); 7997 marker.before(elInSpot); 7998 elInSpot._x_currentIfEl && elInSpot.after(elInSpot._x_currentIfEl); 7999 marker.remove(); 8000 }); 8001 elForSpot._x_refreshXForScope(scopes[keys.indexOf(keyForSpot)]); 8002 } 8003 for (let i = 0; i < adds.length; i++) { 8004 let [lastKey2, index] = adds[i]; 8005 let lastEl = lastKey2 === "template" ? templateEl : lookup[lastKey2]; 8006 if (lastEl._x_currentIfEl) 8007 lastEl = lastEl._x_currentIfEl; 8008 let scope2 = scopes[index]; 8009 let key = keys[index]; 8010 let clone2 = document.importNode(templateEl.content, true).firstElementChild; 8011 let reactiveScope = reactive(scope2); 8012 addScopeToNode(clone2, reactiveScope, templateEl); 8013 clone2._x_refreshXForScope = (newScope) => { 8014 Object.entries(newScope).forEach(([key2, value]) => { 8015 reactiveScope[key2] = value; 8016 }); 8017 }; 8018 mutateDom(() => { 8019 lastEl.after(clone2); 8020 initTree(clone2); 8021 }); 8022 if (typeof key === "object") { 8023 warn("x-for key cannot be an object, it must be a string or an integer", templateEl); 8024 } 8025 lookup[key] = clone2; 8026 } 8027 for (let i = 0; i < sames.length; i++) { 8028 lookup[sames[i]]._x_refreshXForScope(scopes[keys.indexOf(sames[i])]); 8029 } 8030 templateEl._x_prevKeys = keys; 8031 }); 8032} 8033function parseForExpression(expression) { 8034 let forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/; 8035 let stripParensRE = /^\s*\(|\)\s*$/g; 8036 let forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/; 8037 let inMatch = expression.match(forAliasRE); 8038 if (!inMatch) 8039 return; 8040 let res = {}; 8041 res.items = inMatch[2].trim(); 8042 let item = inMatch[1].replace(stripParensRE, "").trim(); 8043 let iteratorMatch = item.match(forIteratorRE); 8044 if (iteratorMatch) { 8045 res.item = item.replace(forIteratorRE, "").trim(); 8046 res.index = iteratorMatch[1].trim(); 8047 if (iteratorMatch[2]) { 8048 res.collection = iteratorMatch[2].trim(); 8049 } 8050 } else { 8051 res.item = item; 8052 } 8053 return res; 8054} 8055function getIterationScopeVariables(iteratorNames, item, index, items) { 8056 let scopeVariables = {}; 8057 if (/^\[.*\]$/.test(iteratorNames.item) && Array.isArray(item)) { 8058 let names = iteratorNames.item.replace("[", "").replace("]", "").split(",").map((i) => i.trim()); 8059 names.forEach((name, i) => { 8060 scopeVariables[name] = item[i]; 8061 }); 8062 } else if (/^\{.*\}$/.test(iteratorNames.item) && !Array.isArray(item) && typeof item === "object") { 8063 let names = iteratorNames.item.replace("{", "").replace("}", "").split(",").map((i) => i.trim()); 8064 names.forEach((name) => { 8065 scopeVariables[name] = item[name]; 8066 }); 8067 } else { 8068 scopeVariables[iteratorNames.item] = item; 8069 } 8070 if (iteratorNames.index) 8071 scopeVariables[iteratorNames.index] = index; 8072 if (iteratorNames.collection) 8073 scopeVariables[iteratorNames.collection] = items; 8074 return scopeVariables; 8075} 8076function isNumeric3(subject) { 8077 return !Array.isArray(subject) && !isNaN(subject); 8078} 8079 8080// packages/alpinejs/src/directives/x-ref.js 8081function handler3() { 8082} 8083handler3.inline = (el, { expression }, { cleanup: cleanup2 }) => { 8084 let root = closestRoot(el); 8085 if (!root._x_refs) 8086 root._x_refs = {}; 8087 root._x_refs[expression] = el; 8088 cleanup2(() => delete root._x_refs[expression]); 8089}; 8090directive("ref", handler3); 8091 8092// packages/alpinejs/src/directives/x-if.js 8093directive("if", (el, { expression }, { effect: effect3, cleanup: cleanup2 }) => { 8094 let evaluate2 = evaluateLater(el, expression); 8095 let show = () => { 8096 if (el._x_currentIfEl) 8097 return el._x_currentIfEl; 8098 let clone2 = el.content.cloneNode(true).firstElementChild; 8099 addScopeToNode(clone2, {}, el); 8100 mutateDom(() => { 8101 el.after(clone2); 8102 initTree(clone2); 8103 }); 8104 el._x_currentIfEl = clone2; 8105 el._x_undoIf = () => { 8106 walk(clone2, (node) => { 8107 if (!!node._x_effects) { 8108 node._x_effects.forEach(dequeueJob); 8109 } 8110 }); 8111 clone2.remove(); 8112 delete el._x_currentIfEl; 8113 }; 8114 return clone2; 8115 }; 8116 let hide = () => { 8117 if (!el._x_undoIf) 8118 return; 8119 el._x_undoIf(); 8120 delete el._x_undoIf; 8121 }; 8122 effect3(() => evaluate2((value) => { 8123 value ? show() : hide(); 8124 })); 8125 cleanup2(() => el._x_undoIf && el._x_undoIf()); 8126}); 8127 8128// packages/alpinejs/src/directives/x-id.js 8129directive("id", (el, { expression }, { evaluate: evaluate2 }) => { 8130 let names = evaluate2(expression); 8131 names.forEach((name) => setIdRoot(el, name)); 8132}); 8133 8134// packages/alpinejs/src/directives/x-on.js 8135mapAttributes(startingWith("@", into(prefix("on:")))); 8136directive("on", skipDuringClone((el, { value, modifiers, expression }, { cleanup: cleanup2 }) => { 8137 let evaluate2 = expression ? evaluateLater(el, expression) : () => { 8138 }; 8139 if (el.tagName.toLowerCase() === "template") { 8140 if (!el._x_forwardEvents) 8141 el._x_forwardEvents = []; 8142 if (!el._x_forwardEvents.includes(value)) 8143 el._x_forwardEvents.push(value); 8144 } 8145 let removeListener = on(el, value, modifiers, (e) => { 8146 evaluate2(() => { 8147 }, { scope: { "$event": e }, params: [e] }); 8148 }); 8149 cleanup2(() => removeListener()); 8150})); 8151 8152// packages/alpinejs/src/directives/index.js 8153warnMissingPluginDirective("Collapse", "collapse", "collapse"); 8154warnMissingPluginDirective("Intersect", "intersect", "intersect"); 8155warnMissingPluginDirective("Focus", "trap", "focus"); 8156warnMissingPluginDirective("Mask", "mask", "mask"); 8157function warnMissingPluginDirective(name, directiveName2, slug) { 8158 directive(directiveName2, (el) => warn(`You can't use [x-${directiveName2}] without first installing the "${name}" plugin here: https://alpinejs.dev/plugins/${slug}`, el)); 8159} 8160 8161// packages/alpinejs/src/index.js 8162alpine_default.setEvaluator(normalEvaluator); 8163alpine_default.setReactivityEngine({ reactive: reactive2, effect: effect2, release: stop, raw: toRaw }); 8164var src_default = alpine_default; 8165 8166// packages/alpinejs/builds/module.js 8167var module_default = src_default; 8168 8169 8170 8171/***/ }), 8172
8173/***/ "./theme/components/action/action.js": 8174/*!*******************************************!*\ 8175 !*** ./theme/components/action/action.js ***! 8176 \*******************************************/ 8177/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 8178 8179"use strict"; 8180__webpack_require__.r(__webpack_exports__); 8181/* harmony import */ var alpinejs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! alpinejs */ "./node_modules/alpinejs/dist/module.esm.js"); 8182 8183alpinejs__WEBPACK_IMPORTED_MODULE_0__["default"].data("action", () => ({ 8184 base: "gc-action", 8185 tabOpen: 1, 8186 visibleContent: 0, 8187 hasContents: false, 8188 init() { 8189 const urlParams = new URLSearchParams(window.location.search); 8190 const currentPageUrl = this.getBaseUrl(); 8191 if (urlParams.has("contents") && urlParams.get("contents") == "true") { 8192 this.hasContents = true; 8193 localStorage.setItem("hasContents", "true"); 8194 localStorage.setItem("pageUrl", currentPageUrl); 8195 this.showContent(); 8196 } else if (localStorage.getItem("hasContents") === "true") { 8197 const savedPageUrl = localStorage.getItem("pageUrl"); 8198 if (savedPageUrl === currentPageUrl) { 8199 this.hasContents = true; 8200 this.showContent(); 8201 } 8202 } 8203 if (!this.hasContents) { 8204 jQuery(document).on("gform_confirmation_loaded", (event, formId) => { 8205 const dataElement = this.$refs[formId]; 8206 this.processContent(dataElement, formId); 8207 this.hasContents = true; 8208 localStorage.setItem("hasContents", "true"); 8209 localStorage.setItem("formId", formId); 8210 localStorage.setItem("pageUrl", currentPageUrl); 8211 }); 8212 } 8213 }, 8214 getBaseUrl() { 8215 const url = new URL(window.location.href); 8216 return url.origin + url.pathname; 8217 }, 8218 showContent() { 8219 const savedFormId = localStorage.getItem("formId"); 8220 const currentPageUrl = this.getBaseUrl(); 8221 const savedPageUrl = localStorage.getItem("pageUrl"); 8222 if (savedFormId && savedPageUrl === currentPageUrl) { 8223 const dataElement = this.$refs[savedFormId]; 8224 if (dataElement) { 8225 this.processContent(dataElement, Number(savedFormId)); 8226 } 8227 } else { 8228 const contentDivs = document.querySelectorAll('[id^="item_"]'); 8229 contentDivs.forEach((div, index) => { 8230 const match = div.id.match(/^item_(\d+)$/); 8231 const number = match ? parseInt(match[1], 10) : 0; 8232 this.processContent(div, number); 8233 }); 8234 } 8235 }, 8236 processContent(div, visibleContent) { 8237 const jsonData = div.dataset.content; 8238 const contentData = JSON.parse(jsonData); 8239 let html = ""; 8240 contentData.forEach(data => { 8241 html += '<div class="gc-action__wrapper"><div>'; 8242 if (data.title) { 8243 html += '<div class="h2 gc-action__title">' + data.title + "</div>"; 8244 } 8245 html += data.description + "</div>"; 8246 if (data.video) { 8247 html += '<figure class="gc-cwv__video-container">' + data.video + "</figure>"; 8248 } 8249 html += "</div>"; 8250 }); 8251 div.innerHTML = html; 8252 this.visibleContent = visibleContent; 8253 }, 8254 open(index) { 8255 this.tabOpen = index; 8256 } 8257})); 8258 8259/***/ }), 8260
8261/***/ "./theme/components/cases/cases.js": 8262/*!*****************************************!*\ 8263 !*** ./theme/components/cases/cases.js ***! 8264 \*****************************************/ 8265/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 8266 8267"use strict"; 8268__webpack_require__.r(__webpack_exports__); 8269/* harmony import */ var alpinejs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! alpinejs */ "./node_modules/alpinejs/dist/module.esm.js"); 8270/* harmony import */ var _splidejs_splide__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @splidejs/splide */ "./node_modules/@splidejs/splide/dist/js/splide.esm.js"); 8271/* harmony import */ var _splidejs_splide_extension_grid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @splidejs/splide-extension-grid */ "./node_modules/@splidejs/splide-extension-grid/dist/js/splide-extension-grid.esm.js"); 8272 8273 8274 8275alpinejs__WEBPACK_IMPORTED_MODULE_0__["default"].data("cases", () => ({ 8276 base: "gc-cases", 8277 filterMore1: false, 8278 filterMore2: false, 8279 filterMore3: false, 8280 aside: "", 8281 content: "", 8282 logos: "", 8283 splide: false, 8284 filterMobileMenu: false, 8285 init() { 8286 window.onpopstate = event => { 8287 if (event.state) { 8288 this.updateContent(event.state.queryParameters, true); 8289 } else { 8290 this.updateContent("", true); 8291 } 8292 }; 8293 this.createSlider(); 8294 }, 8295 updateByLink(filterGroupId, queryParameters) { 8296 const currentSelected = jQuery(`.${this.base}__filter-list[data-id='${filterGroupId}'] .${this.base}__filter--current`); 8297 currentSelected.removeClass(`${this.base}__filter--current`); 8298 this.$el.classList.add(`${this.base}__filter--current`); 8299 this.updateContent(queryParameters); 8300 }, 8301 updateByForm(form) { 8302 let formParameters = new URLSearchParams(new FormData(jQuery(form)[0])).toString(); 8303 this.updateContent(formParameters); 8304 }, 8305 uncheck(element) { 8306 document.querySelector(`#${element}`).checked = false; 8307 // For some reason onchange won't trigger so we update manually 8308 this.updateByForm(`.${this.base}__types-form`); 8309 }, 8310 updateContent(queryParameters, historyMode) { 8311 const casesScrollPostion = document.querySelector(`.${this.base}__aside`).getBoundingClientRect().y; 8312 fetch(`/wp-json/growl/cases/get?${queryParameters}`).then(response => response.json()).then(data => { 8313 this.aside = data.aside; 8314 this.content = data.content; 8315 this.logos = data.logos; 8316 // Without setTimeout slider will be not recreated 8317 setTimeout(() => { 8318 this.destroySlider(); 8319 this.createSlider(); 8320 }, 0); 8321 if (!historyMode) { 8322 const historyUrl = new URL(`${window.location.href.split("?")[0]}?${queryParameters}`); 8323 window.history.pushState({ 8324 queryParameters 8325 }, "", historyUrl); 8326 } 8327 8328 // Back scroll postion after DOM rerender 8329 this.$nextTick(() => { 8330 window.scrollTo({ 8331 top: document.querySelector(`.${this.base}__aside`).offsetTop - casesScrollPostion 8332 }); 8333 }); 8334 }); 8335 }, 8336 createSlider() { 8337 if (document.querySelector(`.${this.base}__gallery`)) { 8338 let options; 8339 let include = {}; 8340 if (document.querySelector(`.${this.base}__gallery-list`).childElementCount > 6) { 8341 options = { 8342 pagination: false, 8343 arrows: false, 8344 grid: { 8345 dimensions: [[2, 5]], 8346 gap: { 8347 row: "2rem", 8348 col: "2rem" 8349 } 8350 }, 8351 breakpoints: { 8352 400: { 8353 grid: { 8354 dimensions: [[2, 2]], 8355 gap: { 8356 row: "1rem", 8357 col: "1rem" 8358 } 8359 } 8360 }, 8361 500: { 8362 grid: { 8363 dimensions: [[2, 3]], 8364 gap: { 8365 row: "1rem", 8366 col: "1rem" 8367 } 8368 } 8369 }, 8370 640: { 8371 grid: { 8372 dimensions: [[2, 4]], 8373 gap: { 8374 row: "1rem", 8375 col: "1rem" 8376 } 8377 } 8378 } 8379 } 8380 }; 8381 include = { 8382 Grid: _splidejs_splide_extension_grid__WEBPACK_IMPORTED_MODULE_2__.Grid 8383 }; 8384 } else { 8385 options = { 8386 pagination: false,
8387 arrows: false, 8388 perPage: 6, 8389 gap: "2rem" 8390 }; 8391 } 8392 this.splide = new _splidejs_splide__WEBPACK_IMPORTED_MODULE_1__["default"](`.${this.base}__gallery`, options).mount(include); 8393 } 8394 }, 8395 destroySlider() { 8396 if (this.splide) { 8397 this.splide.destroy(); 8398 } 8399 }, 8400 previousSliderPage() { 8401 this.splide.go("-"); 8402 }, 8403 nextSliderPage() { 8404 this.splide.go("+"); 8405 }, 8406 toggleFilterMobileMenu() { 8407 this.filterMobileMenu = !this.filterMobileMenu; 8408 } 8409})); 8410 8411/***/ }), 8412
8413/***/ "./theme/components/connectors/connectors.js": 8414/*!***************************************************!*\ 8415 !*** ./theme/components/connectors/connectors.js ***! 8416 \***************************************************/ 8417/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 8418 8419"use strict"; 8420__webpack_require__.r(__webpack_exports__); 8421/* harmony import */ var alpinejs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! alpinejs */ "./node_modules/alpinejs/dist/module.esm.js"); 8422 8423alpinejs__WEBPACK_IMPORTED_MODULE_0__["default"].data("connectors", () => ({ 8424 base: "gc-connectors", 8425 filterMore1: false, 8426 filterMore2: false, 8427 filterMore3: false, 8428 filterMobileMenu: false, 8429 content: "", 8430 init() { 8431 window.onpopstate = event => { 8432 if (event.state) { 8433 this.updateContent(event.state.queryParameters, true); 8434 } else { 8435 this.updateContent("", true); 8436 } 8437 }; 8438 }, 8439 updateByLink(filterGroupId, queryParameters) { 8440 const currentSelected = jQuery(`.${this.base}__filter-list[data-id='${filterGroupId}'] .${this.base}__filter--current`); 8441 currentSelected.removeClass(`${this.base}__filter--current`); 8442 this.$el.classList.add(`${this.base}__filter--current`); 8443 this.updateContent(queryParameters); 8444 }, 8445 updateByForm(form) { 8446 let formParameters = new URLSearchParams(new FormData(jQuery(form)[0])).toString(); 8447 this.updateContent(formParameters); 8448 }, 8449 uncheck(element) { 8450 document.querySelector(`#${element}`).checked = false; 8451 // For some reason onchange won't trigger so we update manually 8452 this.updateByForm(`.${this.base}__types-form`); 8453 }, 8454 updateContent(queryParameters, historyMode) { 8455 fetch(`/wp-json/growl/connectors/get?${queryParameters}`).then(response => response.json()).then(data => { 8456 this.content = data; 8457 if (!historyMode) { 8458 const historyUrl = new URL(`${window.location.href.split("?")[0]}?${queryParameters}`); 8459 window.history.pushState({ 8460 queryParameters 8461 }, "", historyUrl); 8462 } 8463 }); 8464 }, 8465 toggleFilterMobileMenu() { 8466 this.filterMobileMenu = !this.filterMobileMenu; 8467 }, 8468 onSearch() { 8469 if (this.$el.value == "") { 8470 // submit form after cleaning seach via x button 8471 this.updateByForm(`.${this.base}__form`); 8472 } 8473 } 8474})); 8475 8476/***/ }), 8477
8478/***/ "./theme/components/content-slider/content-slider.js": 8479/*!***********************************************************!*\ 8480 !*** ./theme/components/content-slider/content-slider.js ***! 8481 \***********************************************************/ 8482/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 8483 8484"use strict"; 8485__webpack_require__.r(__webpack_exports__); 8486/* harmony import */ var alpinejs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! alpinejs */ "./node_modules/alpinejs/dist/module.esm.js"); 8487/* harmony import */ var _splidejs_splide__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @splidejs/splide */ "./node_modules/@splidejs/splide/dist/js/splide.esm.js"); 8488 8489 8490alpinejs__WEBPACK_IMPORTED_MODULE_0__["default"].data("contentCarousel", () => ({ 8491 init() { 8492 this.splide = new _splidejs_splide__WEBPACK_IMPORTED_MODULE_1__["default"](this.$refs.slide, { 8493 type: 'slide', 8494 pagination: false, 8495 arrows: false, 8496 autoWidth: true, 8497 gap: "1rem", 8498 wheel: false, 8499 waitForTransition: true, 8500 breakpoints: { 8501 900: { 8502 destroy: true 8503 } 8504 } 8505 }).mount(); 8506 }, 8507 previousSlide() { 8508 this.splide.go("-"); 8509 }, 8510 nextSlide() { 8511 this.splide.go("+"); 8512 } 8513})); 8514 8515/***/ }), 8516
8517/***/ "./theme/components/content-with-visual/content-with-visual.js": 8518/*!*********************************************************************!*\ 8519 !*** ./theme/components/content-with-visual/content-with-visual.js ***! 8520 \*********************************************************************/ 8521/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 8522 8523"use strict"; 8524__webpack_require__.r(__webpack_exports__); 8525/* harmony import */ var glightbox__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! glightbox */ "./node_modules/glightbox/dist/js/glightbox.min.js"); 8526/* harmony import */ var glightbox__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(glightbox__WEBPACK_IMPORTED_MODULE_0__); 8527 8528glightbox__WEBPACK_IMPORTED_MODULE_0___default()({ 8529 selector: "data-gallery" 8530}); 8531jQuery(function ($) { 8532 setTimeout(() => { 8533 // without timeout video will not start 8534 $("video.wp-video-shortcode--autoplay").each(function () { 8535 this.muted = true; 8536 this.play(); 8537 }); 8538 }, 0); 8539}); 8540 8541/***/ }), 8542
8543/***/ "./theme/components/faq/faq.js": 8544/*!*************************************!*\ 8545 !*** ./theme/components/faq/faq.js ***! 8546 \*************************************/ 8547/***/ (() => { 8548 8549jQuery(function ($) { 8550 const base = "gc-faq"; 8551 $(`.${base}__question-title`).on("click", function () { 8552 $(`.${base}__question--active`).removeClass(`${base}__question--active`); 8553 $(this).parent().toggleClass(`${base}__question--active`); 8554 }); 8555}); 8556 8557/***/ }), 8558
8559/***/ "./theme/components/gallery-carousel/gallery-carousel.js": 8560/*!***************************************************************!*\ 8561 !*** ./theme/components/gallery-carousel/gallery-carousel.js ***! 8562 \***************************************************************/ 8563/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 8564 8565"use strict"; 8566__webpack_require__.r(__webpack_exports__); 8567/* harmony import */ var alpinejs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! alpinejs */ "./node_modules/alpinejs/dist/module.esm.js"); 8568/* harmony import */ var _splidejs_splide__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @splidejs/splide */ "./node_modules/@splidejs/splide/dist/js/splide.esm.js"); 8569/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js"); 8570/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_2__); 8571/* harmony import */ var glightbox__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! glightbox */ "./node_modules/glightbox/dist/js/glightbox.min.js"); 8572/* harmony import */ var glightbox__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(glightbox__WEBPACK_IMPORTED_MODULE_3__); 8573 8574 8575 8576 8577alpinejs__WEBPACK_IMPORTED_MODULE_0__["default"].data("galleryCarousel", () => ({ 8578 init() { 8579 this.splide = new _splidejs_splide__WEBPACK_IMPORTED_MODULE_1__["default"](this.$refs.slide, { 8580 type: 'loop', 8581 pagination: false, 8582 arrows: false, 8583 perPage: 4, 8584 perMove: 1, 8585 gap: "1rem", 8586 wheel: true, 8587 waitForTransition: true, 8588 breakpoints: { 8589 600: { 8590 perPage: 1 8591 }, 8592 900: { 8593 perPage: 2 8594 } 8595 } 8596 }).mount(); 8597 const handleWheelDebounced = (0,lodash__WEBPACK_IMPORTED_MODULE_2__.debounce)(event => { 8598 const direction = event.deltaY > 0 ? '>' : '<'; 8599 this.splide.go(direction); 8600 }, 200); 8601 this.$refs.slide.addEventListener('wheel', event => { 8602 handleWheelDebounced(event); 8603 event.preventDefault(); 8604 }); 8605 glightbox__WEBPACK_IMPORTED_MODULE_3___default()({ 8606 selector: "data-carousel" 8607 }); 8608 }, 8609 previousSlide() { 8610 this.splide.go("-"); 8611 }, 8612 nextSlide() { 8613 this.splide.go("+"); 8614 } 8615})); 8616 8617/***/ }), 8618
8619/***/ "./theme/components/icons/icons.js": 8620/*!*****************************************!*\ 8621 !*** ./theme/components/icons/icons.js ***! 8622 \*****************************************/ 8623/***/ (() => { 8624 8625jQuery(function ($) { 8626 const base = "gc-icons"; 8627 $(`.${base}__item`).on("click", function () { 8628 const isActive = $(this).hasClass(`${base}__item--active`); 8629 $(`.${base}__item`).removeClass(`${base}__item--active`); 8630 if (!isActive) { 8631 $(this).addClass(`${base}__item--active`); 8632 } 8633 }); 8634}); 8635 8636/***/ }), 8637
8638/***/ "./theme/components/jobs-carousel/jobs-carousel.js": 8639/*!*********************************************************!*\ 8640 !*** ./theme/components/jobs-carousel/jobs-carousel.js ***! 8641 \*********************************************************/ 8642/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 8643 8644"use strict"; 8645__webpack_require__.r(__webpack_exports__); 8646/* harmony import */ var alpinejs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! alpinejs */ "./node_modules/alpinejs/dist/module.esm.js"); 8647/* harmony import */ var _splidejs_splide__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @splidejs/splide */ "./node_modules/@splidejs/splide/dist/js/splide.esm.js"); 8648/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js"); 8649/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_2__); 8650 8651 8652 8653alpinejs__WEBPACK_IMPORTED_MODULE_0__["default"].data("jobsCarousel", () => ({ 8654 init() { 8655 this.splide = new _splidejs_splide__WEBPACK_IMPORTED_MODULE_1__["default"](this.$refs.slide, { 8656 pagination: false, 8657 arrows: false, 8658 perPage: 3, 8659 perMove: 1, 8660 gap: "2rem", 8661 wheel: true, 8662 waitForTransition: true, 8663 breakpoints: { 8664 600: { 8665 perPage: 1 8666 }, 8667 1200: { 8668 perPage: 2 8669 } 8670 } 8671 }).mount(); 8672 const handleWheelDebounced = (0,lodash__WEBPACK_IMPORTED_MODULE_2__.debounce)(event => { 8673 const direction = event.deltaY > 0 ? '>' : '<'; 8674 this.splide.go(direction); 8675 }, 200); 8676 this.$refs.slide.addEventListener('wheel', event => { 8677 handleWheelDebounced(event); 8678 event.preventDefault(); 8679 }); 8680 } 8681})); 8682 8683/***/ }), 8684
8685/***/ "./theme/components/jobs-overview/jobs-overview.js": 8686/*!*********************************************************!*\ 8687 !*** ./theme/components/jobs-overview/jobs-overview.js ***! 8688 \*********************************************************/ 8689/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 8690 8691"use strict"; 8692__webpack_require__.r(__webpack_exports__); 8693/* harmony import */ var alpinejs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! alpinejs */ "./node_modules/alpinejs/dist/module.esm.js"); 8694 8695alpinejs__WEBPACK_IMPORTED_MODULE_0__["default"].data("jobsOverview", () => ({ 8696 content: "", 8697 base: "gc-jobs-overview", 8698 init() { 8699 window.onpopstate = event => { 8700 if (event.state) { 8701 this.updateContent(event.state.queryParameters, true); 8702 } else { 8703 this.updateContent("", true); 8704 } 8705 }; 8706 }, 8707 updateByLink(filterGroupId, queryParameters) { 8708 const currentSelected = jQuery(`.${this.base}__filters[data-id='${filterGroupId}'] .${this.base}__filter--current`); 8709 currentSelected.removeClass(`${this.base}__filter--current`); 8710 this.$el.classList.add(`${this.base}__filter--current`); 8711 this.updateContent(queryParameters); 8712 }, 8713 updateContent(queryParameters, historyMode) { 8714 fetch(`/wp-json/growl/jobs/get?${queryParameters}`).then(response => response.json()).then(data => { 8715 this.content = data; 8716 if (!historyMode) { 8717 const historyUrl = new URL(`${window.location.href.split("?")[0]}?${queryParameters}`); 8718 window.history.pushState({ 8719 queryParameters 8720 }, "", historyUrl); 8721 } 8722 document.getElementById("overview").scrollIntoView({ 8723 behavior: "smooth" 8724 }); 8725 }); 8726 } 8727})); 8728 8729/***/ }), 8730
8731/***/ "./theme/components/logos/logos.js": 8732/*!*****************************************!*\ 8733 !*** ./theme/components/logos/logos.js ***! 8734 \*****************************************/ 8735/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 8736 8737"use strict"; 8738__webpack_require__.r(__webpack_exports__); 8739/* harmony import */ var alpinejs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! alpinejs */ "./node_modules/alpinejs/dist/module.esm.js"); 8740/* harmony import */ var _splidejs_splide__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @splidejs/splide */ "./node_modules/@splidejs/splide/dist/js/splide.esm.js"); 8741/* harmony import */ var _splidejs_splide_extension_auto_scroll__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @splidejs/splide-extension-auto-scroll */ "./node_modules/@splidejs/splide-extension-auto-scroll/dist/js/splide-extension-auto-scroll.esm.js"); 8742 8743 8744 8745alpinejs__WEBPACK_IMPORTED_MODULE_0__["default"].data("logos", () => ({ 8746 splide: false, 8747 init() { 8748 this.splide = new _splidejs_splide__WEBPACK_IMPORTED_MODULE_1__["default"](this.$refs.slide, { 8749 type: 'loop', 8750 drag: 'free', 8751 autoWidth: true, 8752 arrows: false, 8753 pagination: false, 8754 autoScroll: { 8755 speed: 1 8756 } 8757 }).mount({ 8758 AutoScroll: _splidejs_splide_extension_auto_scroll__WEBPACK_IMPORTED_MODULE_2__.AutoScroll 8759 }); 8760 } 8761})); 8762 8763/***/ }), 8764
8765/***/ "./theme/components/modal/modal.js": 8766/*!*****************************************!*\ 8767 !*** ./theme/components/modal/modal.js ***! 8768 \*****************************************/ 8769/***/ (() => { 8770 8771jQuery(function ($) { 8772 const base = "gc-modal"; 8773 8774 // Open 8775 $("[data-popup-trigger]").on("click", function (e) { 8776 e.preventDefault(); 8777 const target = $(this).attr("data-popup-trigger"); 8778 $(`[data-popup-name="${target}"]`).addClass(`${base}--visible`); 8779 $("body").addClass(`${base}-lock-body`); 8780 }); 8781 8782 // Close 8783 $(`.${base}`).on("click", function (event) { 8784 if ($(event.target).hasClass(`${base}`) || $(event.target).hasClass(`${base}__close`)) { 8785 $(this).removeClass(`${base}--visible`); 8786 $("body").removeClass(`${base}-lock-body`); 8787 } 8788 }); 8789 $(document).on("keyup", function (e) { 8790 if (e.key === "Escape") { 8791 $(`.${base}--visible`).removeClass(`${base}--visible`); 8792 } 8793 }); 8794}); 8795 8796/***/ }), 8797
8798/***/ "./theme/components/navbar/navbar.js": 8799/*!*******************************************!*\ 8800 !*** ./theme/components/navbar/navbar.js ***! 8801 \*******************************************/ 8802/***/ (() => { 8803 8804jQuery(function ($) { 8805 const base = "gc-navbar"; 8806 function makeNavbarSticky(transition) { 8807 if ($(window).scrollTop() >= 150) { 8808 $(`.${base}`).css("padding-top", "9.375rem"); 8809 $(`.${base}__container`).addClass(`${base}__container--sticky`); 8810 } else { 8811 $(`.${base}`).css("padding-top", 0); 8812 $(`.${base}__container`).removeClass(`${base}__container--sticky`); 8813 if (transition) { 8814 $(`.${base}__container`).css("transition", ""); 8815 } 8816 } 8817 if ($(window).scrollTop() >= 300) { 8818 if (transition) { 8819 $(`.${base}__container`).css("transition", "0.3s ease-in-out"); 8820 } 8821 $(`.${base}__container`).addClass(`${base}__container--sticky-show`); 8822 } else { 8823 $(`.${base}__container`).removeClass(`${base}__container--sticky-show`); 8824 } 8825 } 8826 $(`.${base}__burger`).on("click", function () { 8827 $(`.${base}`).toggleClass(`${base}--active`); 8828 }); 8829 $(`.${base}__expander`).on("click", function () { 8830 $(this).toggleClass(`${base}__expander--active`); 8831 $(this).next().toggleClass(`${base}__submenu-wrapper--active`); 8832 }); 8833 if (window.location.hash) { 8834 makeNavbarSticky(false); 8835 } 8836 $(window).on("scroll", () => makeNavbarSticky(true)); 8837}); 8838 8839/***/ }), 8840
8841/***/ "./theme/components/price-calculator/price-calculator.js": 8842/*!***************************************************************!*\ 8843 !*** ./theme/components/price-calculator/price-calculator.js ***! 8844 \***************************************************************/ 8845/***/ (() => { 8846 8847jQuery(function ($) { 8848 const base = "gc-price-calculator"; 8849 const consolidatedSteps = { 8850 eur: [5, 10, 15, 20, 25, 50, 75, 100, 125, 150, 175, 200, 250, 300, 350, 400, 500, 600, 700, 800, 900, 1000] 8851 }; 8852 $(`.${base}__consolidated`).on("input change", function () { 8853 $(`.${base} input[name=consolidated]`).val(consolidatedSteps["eur"][this.value]); 8854 $(`.${base}__consolidated-number`).text(consolidatedSteps["eur"][this.value]); 8855 }); 8856 $(`.${base}__features-toggle`).on("click", function () { 8857 $(`.${base}__features`).toggleClass(`${base}__features--hidden`); 8858 }); 8859 $(`.${base}__companies`).on("input change", function () { 8860 $(this).next().children().text($(this).val()); 8861 }); 8862 if ($(`.${base}--price`).length) { 8863 $(`.${base} input`).on("change", function () { 8864 const formData = $(`.${base}`).serializeArray(); 8865 let data = {}; 8866 $(formData).each(function (index, obj) { 8867 data[obj.name] = obj.value; 8868 }); 8869 fetch("/wp-json/growl/PriceCalculator/calculate", { 8870 method: "POST", 8871 headers: { 8872 "Content-Type": "application/json" 8873 }, 8874 body: JSON.stringify(data) 8875 }).then(response => response.json()).then(result => { 8876 $(`.${base}__price-number`).text(result); 8877 }); 8878 }); 8879 } 8880 if ($(`.${base}--form`).length) { 8881 $(`.${base} input`).on("change", function () { 8882 const formData = $(`.${base}`).serializeArray(); 8883 let data = {}; 8884 $(formData).each(function (index, obj) { 8885 data[obj.name] = obj.value; 8886 }); 8887 const fields = ["companies", "consolidated"]; 8888 fields.forEach((item, key) => { 8889 $(`.gc-price-calculator .gfield:nth-child(${key + 2}) input`).val(data[item]); 8890 }); 8891 }); 8892 } 8893}); 8894 8895/***/ }), 8896
8897/***/ "./theme/components/related-integrations/related-integrations.js": 8898/*!***********************************************************************!*\ 8899 !*** ./theme/components/related-integrations/related-integrations.js ***! 8900 \***********************************************************************/ 8901/***/ (() => { 8902 8903jQuery(function ($) { 8904 const base = "gc-related-integrations"; 8905 $(`.${base}__button`).on("click", function () { 8906 $(`.${base}__integration-hidden`).toggleClass(`${base}__integration-hidden--active`).toggleClass(``); 8907 }); 8908}); 8909 8910/***/ }), 8911
8912/***/ "./theme/components/templates-overview/templates-overview.js": 8913/*!*******************************************************************!*\ 8914 !*** ./theme/components/templates-overview/templates-overview.js ***! 8915 \*******************************************************************/ 8916/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 8917 8918"use strict"; 8919__webpack_require__.r(__webpack_exports__); 8920/* harmony import */ var alpinejs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! alpinejs */ "./node_modules/alpinejs/dist/module.esm.js"); 8921 8922alpinejs__WEBPACK_IMPORTED_MODULE_0__["default"].data("templatesOverview", () => ({ 8923 base: "gc-templates-overview", 8924 filterMore1: false, 8925 filterMore2: false, 8926 filterMore3: false, 8927 filterMobileMenu: false, 8928 content: "", 8929 init() { 8930 window.onpopstate = event => { 8931 if (event.state) { 8932 this.updateContent(event.state.queryParameters, true); 8933 } else { 8934 this.updateContent("", true); 8935 } 8936 }; 8937 this.scrollToAnchor(); 8938 }, 8939 updateByLink(filterGroupId, queryParameters) { 8940 const currentSelected = jQuery(`.${this.base}__filter-list[data-id='${filterGroupId}'] .${this.base}__filter--current`); 8941 currentSelected.removeClass(`${this.base}__filter--current`); 8942 this.$el.classList.add(`${this.base}__filter--current`); 8943 this.updateContent(queryParameters); 8944 }, 8945 updateByForm(form) { 8946 let formParameters = new URLSearchParams(new FormData(jQuery(form)[0])).toString(); 8947 this.updateContent(formParameters); 8948 }, 8949 uncheck(element) { 8950 document.querySelector(`#${element}`).checked = false; 8951 // For some reason onchange won't trigger so we update manually 8952 this.updateByForm(`.${this.base}__types-form`); 8953 }, 8954 updateContent(queryParameters, historyMode) { 8955 fetch(`/wp-json/growl/templates/get?${queryParameters}`).then(response => response.json()).then(data => { 8956 this.content = data; 8957 if (!historyMode) { 8958 const historyUrl = new URL(`${window.location.href.split("?")[0]}?${queryParameters}`); 8959 window.history.pushState({ 8960 queryParameters 8961 }, "", historyUrl); 8962 } 8963 }); 8964 }, 8965 toggleFilterMobileMenu() { 8966 this.filterMobileMenu = !this.filterMobileMenu; 8967 }, 8968 onSearch() { 8969 if (this.$el.value == "") { 8970 // submit form after cleaning seach via x button 8971 this.updateByForm(`.${this.base}__form`); 8972 } 8973 }, 8974 debounce(func, wait) { 8975 let timeout; 8976 return function (...args) { 8977 const later = () => { 8978 clearTimeout(timeout); 8979 func(...args); 8980 }; 8981 clearTimeout(timeout); 8982 timeout = setTimeout(later, wait); 8983 }; 8984 }, 8985 scrollToAnchor() { 8986 const executeScroll = () => { 8987 if (window.location.hash) { 8988 const element = document.querySelector(window.location.hash); 8989 if (element) { 8990 element.scrollIntoView({ 8991 behavior: 'smooth' 8992 }); 8993 } 8994 } 8995 }; 8996 this.debounce(executeScroll, 300)(); 8997 } 8998})); 8999 9000/***/ }), 9001
9002/***/ "./theme/components/webinar-registration/webinar-registration.js": 9003/*!***********************************************************************!*\ 9004 !*** ./theme/components/webinar-registration/webinar-registration.js ***! 9005 \***********************************************************************/ 9006/***/ (() => { 9007 9008jQuery(function ($) { 9009 const base = "gc-webinar-registration"; 9010 if (!$(`.${base}`).length) return; 9011 const currentTab = localStorage.getItem("currentTab"); 9012 if (currentTab) { 9013 switchTab(currentTab); 9014 localStorage.removeItem("currentTab"); 9015 } 9016 $(`.${base}__language`).on("click", function () { 9017 switchTab($(this).attr("data-language")); 9018 }); 9019 $(`.${base} form`).on("click", function () { 9020 const language = $(`.${base}__language--active`).attr("data-language"); 9021 localStorage.setItem("currentTab", language); 9022 }); 9023 function switchTab(language) { 9024 // Switch language 9025 $(`.${base}__language`).removeClass(`${base}__language--active`); 9026 $(`.${base}__language[data-language="${language}"]`).addClass(`${base}__language--active`); 9027 9028 // Switch content 9029 $(`.${base}__content`).removeClass(`${base}__content--active`); 9030 $(`.${base}__content[data-language="${language}"]`).addClass(`${base}__content--active`); 9031 } 9032}); 9033 9034/***/ }), 9035
9036/***/ "./theme/templates/single-connector.js": 9037/*!*********************************************!*\ 9038 !*** ./theme/templates/single-connector.js ***! 9039 \*********************************************/ 9040/***/ (() => { 9041 9042jQuery(function ($) { 9043 const base = "gp-connector"; 9044 if (!$(`.${base}`).length) return; 9045 function getCookie(name) { 9046 const value = `; ${document.cookie}`; 9047 const parts = value.split(`; ${name}=`); 9048 if (parts.length === 2) return parts.pop().split(";").shift(); 9049 } 9050 function getPostId() { 9051 const bodyClassList = $("body").attr("class").split(/\s+/); 9052 const postIdClass = bodyClassList.find(function (classname) { 9053 return classname.includes("postid-"); 9054 }); 9055 return postIdClass.split("postid-").pop(); 9056 } 9057 function checkVisit() { 9058 fetch("/wp-json/growl/connector/checkVisit", { 9059 method: "POST", 9060 headers: { 9061 "Content-Type": "application/json" 9062 }, 9063 body: JSON.stringify({ 9064 post: getPostId() 9065 }) 9066 }); 9067 } 9068 let visitedConnectors = []; 9069 const postId = getPostId(); 9070 if (getCookie("visitedConnectors") !== undefined) { 9071 visitedConnectors = JSON.parse(decodeURIComponent(getCookie("visitedConnectors"))); 9072 } 9073 const cookieName = "connector-" + postId; 9074 // first check is legacy can be remove remove after 2024-02-10 9075 if (document.cookie.indexOf(`${cookieName}=`) == -1 && !visitedConnectors.includes(postId)) { 9076 checkVisit(); 9077 } 9078 $(`.${base}__back`).on("click", function (event) { 9079 if (document.referrer.includes($(this).attr("href"))) { 9080 event.preventDefault(); 9081 history.back(); 9082 } 9083 }); 9084}); 9085 9086/***/ }), 9087
9088/***/ "./theme/templates/single-template.js": 9089/*!********************************************!*\ 9090 !*** ./theme/templates/single-template.js ***! 9091 \********************************************/ 9092/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 9093 9094"use strict"; 9095__webpack_require__.r(__webpack_exports__); 9096/* harmony import */ var alpinejs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! alpinejs */ "./node_modules/alpinejs/dist/module.esm.js"); 9097 9098alpinejs__WEBPACK_IMPORTED_MODULE_0__["default"].data("singleTemplate", initTab => ({ 9099 tab: window.location.hash.substring(1) || initTab, 9100 init() { 9101 this.updateTabFromHash(); 9102 this.$watch('tab', newTab => { 9103 window.location.hash = newTab; 9104 const element = document.getElementById(newTab); 9105 if (element) { 9106 requestAnimationFrame(() => element.scrollIntoView()); 9107 } 9108 }); 9109 window.addEventListener('hashchange', () => { 9110 this.updateTabFromHash(); 9111 }); 9112 }, 9113 updateTabFromHash() { 9114 const hash = window.location.hash.substring(1).split('?')[0]; 9115 if (hash) { 9116 this.tab = hash; 9117 const element = document.getElementById(hash); 9118 if (element) { 9119 requestAnimationFrame(() => element.scrollIntoView()); 9120 } 9121 } 9122 }, 9123 switchTab(tab) { 9124 $(`.gc-subpages`).addClass(`gc-subpages--fixed`); 9125 this.tab = tab; 9126 const element = document.getElementById(tab); 9127 if (element) { 9128 requestAnimationFrame(() => element.scrollIntoView()); 9129 } 9130 }, 9131 handleScroll() { 9132 if ($(`.gc-subpages`).hasClass(`gc-subpages--fixed`)) { 9133 if (window.scrollY <= 300) { 9134 $(`.gc-subpages`).addClass(`gc-subpages--fixed-out`); 9135 setTimeout(() => { 9136 $(`.gc-subpages`).css("transition", ""); 9137 $(`.gc-subpages`).removeClass(`gc-subpages--fixed-out`); 9138 $(`.gc-subpages`).removeClass(`gc-subpages--fixed`); 9139 }, 300); 9140 } 9141 } 9142 } 9143})); 9144 9145/***/ }), 9146
vendor: 56,048 bytes, lines 9147-9156
9147/***/ "./node_modules/glightbox/dist/js/glightbox.min.js": 9148/*!*********************************************************!*\ 9149 !*** ./node_modules/glightbox/dist/js/glightbox.min.js ***! 9150 \*********************************************************/ 9151/***/ (function(module) { 9152 9153!function(e,t){ true?module.exports=t():0}(this,(function(){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function n(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),e}var s=Date.now();function l(){var e={},t=!0,i=0,n=arguments.length;"[object Boolean]"===Object.prototype.toString.call(arguments[0])&&(t=arguments[0],i++);for(var s=function(i){for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t&&"[object Object]"===Object.prototype.toString.call(i[n])?e[n]=l(!0,e[n],i[n]):e[n]=i[n])};i<n;i++){var o=arguments[i];s(o)}return e}function o(e,t){if((k(e)||e===window||e===document)&&(e=[e]),A(e)||L(e)||(e=[e]),0!=P(e))if(A(e)&&!L(e))for(var i=e.length,n=0;n<i&&!1!==t.call(e[n],e[n],n,e);n++);else if(L(e))for(var s in e)if(O(e,s)&&!1===t.call(e[s],e[s],s,e))break}function r(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=e[s]=e[s]||[],l={all:n,evt:null,found:null};return t&&i&&P(n)>0&&o(n,(function(e,n){if(e.eventName==t&&e.fn.toString()==i.toString())return l.found=!0,l.evt=n,!1})),l}function a(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t.onElement,n=t.withCallback,s=t.avoidDuplicate,l=void 0===s||s,a=t.once,h=void 0!==a&&a,d=t.useCapture,c=void 0!==d&&d,u=arguments.length>2?arguments[2]:void 0,g=i||[];function v(e){T(n)&&n.call(u,e,this),h&&v.destroy()}return C(g)&&(g=document.querySelectorAll(g)),v.destroy=function(){o(g,(function(t){var i=r(t,e,v);i.found&&i.all.splice(i.evt,1),t.removeEventListener&&t.removeEventListener(e,v,c)}))},o(g,(function(t){var i=r(t,e,v);(t.addEventListener&&l&&!i.found||!l)&&(t.addEventListener(e,v,c),i.all.push({eventName:e,fn:v}))})),v}function h(e,t){o(t.split(" "),(function(t){return e.classList.add(t)}))}function d(e,t){o(t.split(" "),(function(t){return e.classList.remove(t)}))}function c(e,t){return e.classList.contains(t)}function u(e,t){for(;e!==document.body;){if(!(e=e.parentElement))return!1;if("function"==typeof e.matches?e.matches(t):e.msMatchesSelector(t))return e}}function g(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!e||""===t)return!1;if("none"===t)return T(i)&&i(),!1;var n=x(),s=t.split(" ");o(s,(function(t){h(e,"g"+t)})),a(n,{onElement:e,avoidDuplicate:!1,once:!0,withCallback:function(e,t){o(s,(function(e){d(t,"g"+e)})),T(i)&&i()}})}function v(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(""===t)return e.style.webkitTransform="",e.style.MozTransform="",e.style.msTransform="",e.style.OTransform="",e.style.transform="",!1;e.style.webkitTransform=t,e.style.MozTransform=t,e.style.msTransform=t,e.style.OTransform=t,e.style.transform=t}function f(e){e.style.display="block"}function p(e){e.style.display="none"}function m(e){var t=document.createDocumentFragment(),i=document.createElement("div");for(i.innerHTML=e;i.firstChild;)t.appendChild(i.firstChild);return t}function y(){return{width:window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,height:window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight}}function x(){var e,t=document.createElement("fakeelement"),i={animation:"animationend",OAnimation:"oAnimationEnd",MozAnimation:"animationend",WebkitAnimation:"webkitAnimationEnd"};for(e in i)if(void 0!==t.style[e])return i[e]}function b(e,t,i,n){if(e())t();else{var s;i||(i=100);var l=setInterval((function(){e()&&(clearInterval(l),s&&clearTimeout(s),t())}),i);n&&(s=setTimeout((function(){clearInterval(l)}),n))}}function S(e,t,i){if(I(e))console.error("Inject assets error");else if(T(t)&&(i=t,t=!1),C(t)&&t in window)T(i)&&i();else{var n;if(-1!==e.indexOf(".css")){if((n=document.querySelectorAll('link[href="'+e+'"]'))&&n.length>0)return void(T(i)&&i());var s=document.getElementsByTagName("head")[0],l=s.querySelectorAll('link[rel="stylesheet"]'),o=document.createElement("link");return o.rel="stylesheet",o.type="text/css",o.href=e,o.media="all",l?s.insertBefore(o,l[0]):s.appendChild(o),void(T(i)&&i())}if((n=document.querySelectorAll('script[src="'+e+'"]'))&&n.length>0){if(T(i)){if(C(t))return b((function(){return void 0!==window[t]}),(function(){i()})),!1;i()}}else{var r=document.createElement("script");r.type="text/javascript",r.src=e,r.onload=function(){if(T(i)){if(C(t))return b((function(){return void 0!==window[t]}),(function(){i()})),!1;i()}},document.body.appendChild(r)}}}function w(){return"navigator"in window&&window.navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)|(Android)|(PlayBook)|(BB10)|(BlackBerry)|(Opera Mini)|(IEMobile)|(webOS)|(MeeGo)/i)}function T(e){return"function"==typeof e}function C(e){return"string"==typeof e}function k(e){return!(!e||!e.nodeType||1!=e.nodeType)}function E(e){return Array.isArray(e)}function A(e){return e&&e.length&&isFinite(e.length)}function L(t){return"object"===e(t)&&null!=t&&!T(t)&&!E(t)}function I(e){return null==e}function O(e,t){return null!==e&&hasOwnProperty.call(e,t)}function P(e){if(L(e)){if(e.keys)return e.keys().length;var t=0;for(var i in e)O(e,i)&&t++;return t}return e.length}function M(e){return!isNaN(parseFloat(e))&&isFinite(e)}function z(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1,t=document.querySelectorAll(".gbtn[data-taborder]:not(.disabled)");if(!t.length)return!1;if(1==t.length)return t[0];"string"==typeof e&&(e=parseInt(e));var i=[];o(t,(function(e){i.push(e.getAttribute("data-taborder"))}));var n=Math.max.apply(Math,i.map((function(e){return parseInt(e)}))),s=e<0?1:e+1;s>n&&(s="1");var l=i.filter((function(e){return e>=parseInt(s)})),r=l.sort()[0];return document.querySelector('.gbtn[data-taborder="'.concat(r,'"]'))}function X(e){if(e.events.hasOwnProperty("keyboard"))return!1;e.events.keyboard=a("keydown",{onElement:window,withCallback:function(t,i){var n=(t=t||window.event).keyCode;if(9==n){var s=document.querySelector(".gbtn.focused");if(!s){var l=!(!document.activeElement||!document.activeElement.nodeName)&&document.activeElement.nodeName.toLocaleLowerCase();if("input"==l||"textarea"==l||"button"==l)return}t.preventDefault();var o=document.querySelectorAll(".gbtn[data-taborder]");if(!o||o.length<=0)return;if(!s){var r=z();return void(r&&(r.focus(),h(r,"focused")))}var a=z(s.getAttribute("data-taborder"));d(s,"focused"),a&&(a.focus(),h(a,"focused"))}39==n&&e.nextSlide(),37==n&&e.prevSlide(),27==n&&e.close()}})}function Y(e){return Math.sqrt(e.x*e.x+e.y*e.y)}function q(e,t){var i=function(e,t){var i=Y(e)*Y(t);if(0===i)return 0;var n=function(e,t){return e.x*t.x+e.y*t.y}(e,t)/i;return n>1&&(n=1),Math.acos(n)}(e,t);return function(e,t){return e.x*t.y-t.x*e.y}(e,t)>0&&(i*=-1),180*i/Math.PI}var N=function(){function e(i){t(this,e),this.handlers=[],this.el=i}return n(e,[{key:"add",value:function(e){this.handlers.push(e)}},{key:"del",value:function(e){e||(this.handlers=[]);for(var t=this.handlers.length;t>=0;t--)this.handlers[t]===e&&this.handlers.splice(t,1)}},{key:"dispatch",value:function(){for(var e=0,t=this.handlers.length;e<t;e++){var i=this.handlers[e];"function"==typeof i&&i.apply(this.el,arguments)}}}]),e}();function D(e,t){var i=new N(e);return i.add(t),i}var _=function(){function e(i,n){t(this,e),this.element="string"==typeof i?document.querySelector(i):i,this.start=this.start.bind(this),this.move=this.move.bind(this),this.end=this.end.bind(this),this.cancel=this.cancel.bind(this),this.element.addEventListener("touchstart",this.start,!1),this.element.addEventListener("touchmove",this.move,!1),this.element.addEventListener("touchend",this.end,!1),this.element.addEventListener("touchcancel",this.cancel,!1),this.preV={x:null,y:null},this.pinchStartLen=null,this.zoom=1,this.isDoubleTap=!1;var s=function(){};this.rotate=D(this.element,n.rotate||s),this.touchStart=D(this.element,n.touchStart||s),this.multipointStart=D(this.element,n.multipointStart||s),this.multipointEnd=D(this.element,n.multipointEnd||s),this.pinch=D(this.element,n.pinch||s),this.swipe=D(this.element,n.swipe||s),this.tap=D(this.element,n.tap||s),this.doubleTap=D(this.element,n.doubleTap||s),this.longTap=D(this.element,n.longTap||s),this.singleTap=D(this.element,n.singleTap||s),this.pressMove=D(this.element,n.pressMove||s),this.twoFingerPressMove=D(this.element,n.twoFingerPressMove||s),this.touchMove=D(this.element,n.touchMove||s),this.touchEnd=D(this.element,n.touchEnd||s),this.touchCancel=D(this.element,n.touchCancel||s),this.translateContainer=this.element,this._cancelAllHandler=this.cancelAll.bind(this),window.addEventListener("scroll",this._cancelAllHandler),this.delta=null,this.last=null,this.now=null,this.tapTimeout=null,this.singleTapTimeout=null,this.longTapTimeout=null,this.swipeTimeout=null,this.x1=this.x2=this.y1=this.y2=null,this.preTapPosition={x:null,y:null}}return n(e,[{key:"start",value:function(e){if(e.touches){if(e.target&&e.target.nodeName&&["a","button","input"].indexOf(e.target.nodeName.toLowerCase())>=0)console.log("ignore drag for this touched element",e.target.nodeName.toLowerCase());else{this.now=Date.now(),this.x1=e.touches[0].pageX,this.y1=e.touches[0].pageY,this.delta=this.now-(this.last||this.now),this.touchStart.dispatch(e,this.element),null!==this.preTapPosition.x&&(this.isDoubleTap=this.delta>0&&this.delta<=250&&Math.abs(this.preTapPosition.x-this.x1)<30&&Math.abs(this.preTapPosition.y-this.y1)<30,this.isDoubleTap&&clearTimeout(this.singleTapTimeout)),this.preTapPosition.x=this.x1,this.preTapPosition.y=this.y1,this.last=this.now;var t=this.preV;if(e.touches.length>1){this._cancelLongTap(),this._cancelSingleTap();var i={x:e.touches[1].pageX-this.x1,y:e.touches[1].pageY-this.y1};t.x=i.x,t.y=i.y,this.pinchStartLen=Y(t),this.multipointStart.dispatch(e,this.element)}this._preventTap=!1,this.longTapTimeout=setTimeout(function(){this.longTap.dispatch(e,this.element),this._preventTap=!0}.bind(this),750)}}}},{key:"move",value:function(e){if(e.touches){var t=this.preV,i=e.touches.length,n=e.touches[0].pageX,s=e.touches[0].pageY;if(this.isDoubleTap=!1,i>1){var l=e.touches[1].pageX,o=e.touches[1].pageY,r={x:e.touches[1].pageX-n,y:e.touches[1].pageY-s};null!==t.x&&(this.pinchStartLen>0&&(e.zoom=Y(r)/this.pinchStartLen,this.pinch.dispatch(e,this.element)),e.angle=q(r,t),this.rotate.dispatch(e,this.element)),t.x=r.x,t.y=r.y,null!==this.x2&&null!==this.sx2?(e.deltaX=(n-this.x2+l-this.sx2)/2,e.deltaY=(s-this.y2+o-this.sy2)/2):(e.deltaX=0,e.deltaY=0),this.twoFingerPressMove.dispatch(e,this.element),this.sx2=l,this.sy2=o}else{if(null!==this.x2){e.deltaX=n-this.x2,e.deltaY=s-this.y2;var a=Math.abs(this.x1-this.x2),h=Math.abs(this.y1-this.y2);(a>10||h>10)&&(this._preventTap=!0)}else e.deltaX=0,e.deltaY=0;this.pressMove.dispatch(e,this.element)}this.touchMove.dispatch(e,this.element),this._cancelLongTap(),this.x2=n,this.y2=s,i>1&&e.preventDefault()}}},{key:"end",value:function(e){if(e.changedTouches){this._cancelLongTap();var t=this;e.touches.length<2&&(this.multipointEnd.dispatch(e,this.element),this.sx2=this.sy2=null),this.x2&&Math.abs(this.x1-this.x2)>30||this.y2&&Math.abs(this.y1-this.y2)>30?(e.direction=this._swipeDirection(this.x1,this.x2,this.y1,this.y2),this.swipeTimeout=setTimeout((function(){t.swipe.dispatch(e,t.element)}),0)):(this.tapTimeout=setTimeout((function(){t._preventTap||t.tap.dispatch(e,t.element),t.isDoubleTap&&(t.doubleTap.dispatch(e,t.element),t.isDoubleTap=!1)}),0),t.isDoubleTap||(t.singleTapTimeout=setTimeout((function(){t.singleTap.dispatch(e,t.element)}),250))),this.touchEnd.dispatch(e,this.element),this.preV.x=0,this.preV.y=0,this.zoom=1,this.pinchStartLen=null,this.x1=this.x2=this.y1=this.y2=null}}},{key:"cancelAll",value:function(){this._preventTap=!0,clearTimeout(this.singleTapTimeout),clearTimeout(this.tapTimeout),clearTimeout(this.longTapTimeout),clearTimeout(this.swipeTimeout)}},{key:"cancel",value:function(e){this.cancelAll(),this.touchCancel.dispatch(e,this.element)}},{key:"_cancelLongTap",value:function(){clearTimeout(this.longTapTimeout)}},{key:"_cancelSingleTap",value:function(){clearTimeout(this.singleTapTimeout)}},{key:"_swipeDirection",value:function(e,t,i,n){return Math.abs(e-t)>=Math.abs(i-n)?e-t>0?"Left":"Right":i-n>0?"Up":"Down"}},{key:"on",value:function(e,t){this[e]&&this[e].add(t)}},{key:"off",value:function(e,t){this[e]&&this[e].del(t)}},{key:"destroy",value:function(){return this.singleTapTimeout&&clearTimeout(this.singleTapTimeout),this.tapTimeout&&clearTimeout(this.tapTimeout),this.longTapTimeout&&clearTimeout(this.longTapTimeout),this.swipeTimeout&&clearTimeout(this.swipeTimeout),this.element.removeEventListener("touchstart",this.start),this.element.removeEventListener("touchmove",this.move),this.element.removeEventListener("touchend",this.end),this.element.removeEventListener("touchcancel",this.cancel),this.rotate.del(),this.touchStart.del(),this.multipointStart.del(),this.multipointEnd.del(),this.pinch.del(),this.swipe.del(),this.tap.del(),this.doubleTap.del(),this.longTap.del(),this.singleTap.del(),this.pressMove.del(),this.twoFingerPressMove.del(),this.touchMove.del(),this.touchEnd.del(),this.touchCancel.del(),this.preV=this.pinchStartLen=this.zoom=this.isDoubleTap=this.delta=this.last=this.now=this.tapTimeout=this.singleTapTimeout=this.longTapTimeout=this.swipeTimeout=this.x1=this.x2=this.y1=this.y2=this.preTapPosition=this.rotate=this.touchStart=this.multipointStart=this.multipointEnd=this.pinch=this.swipe=this.tap=this.doubleTap=this.longTap=this.singleTap=this.pressMove=this.touchMove=this.touchEnd=this.touchCancel=this.twoFingerPressMove=null,window.removeEventListener("scroll",this._cancelAllHandler),null}}]),e}();function W(e){var t=function(){var e,t=document.createElement("fakeelement"),i={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(e in i)if(void 0!==t.style[e])return i[e]}(),i=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,n=c(e,"gslide-media")?e:e.querySelector(".gslide-media"),s=u(n,".ginner-container"),l=e.querySelector(".gslide-description");i>769&&(n=s),h(n,"greset"),v(n,"translate3d(0, 0, 0)"),a(t,{onElement:n,once:!0,withCallback:function(e,t){d(n,"greset")}}),n.style.opacity="",l&&(l.style.opacity="")}function B(e){if(e.events.hasOwnProperty("touch"))return!1;var t,i,n,s=y(),l=s.width,o=s.height,r=!1,a=null,g=null,f=null,p=!1,m=1,x=1,b=!1,S=!1,w=null,T=null,C=null,k=null,E=0,A=0,L=!1,I=!1,O={},P={},M=0,z=0,X=document.getElementById("glightbox-slider"),Y=document.querySelector(".goverlay"),q=new _(X,{touchStart:function(t){if(r=!0,(c(t.targetTouches[0].target,"ginner-container")||u(t.targetTouches[0].target,".gslide-desc")||"a"==t.targetTouches[0].target.nodeName.toLowerCase())&&(r=!1),u(t.targetTouches[0].target,".gslide-inline")&&!c(t.targetTouches[0].target.parentNode,"gslide-inline")&&(r=!1),r){if(P=t.targetTouches[0],O.pageX=t.targetTouches[0].pageX,O.pageY=t.targetTouches[0].pageY,M=t.targetTouches[0].clientX,z=t.targetTouches[0].clientY,a=e.activeSlide,g=a.querySelector(".gslide-media"),n=a.querySelector(".gslide-inline"),f=null,c(g,"gslide-image")&&(f=g.querySelector("img")),(window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth)>769&&(g=a.querySelector(".ginner-container")),d(Y,"greset"),t.pageX>20&&t.pageX<window.innerWidth-20)return;t.preventDefault()}},touchMove:function(s){if(r&&(P=s.targetTouches[0],!b&&!S)){if(n&&n.offsetHeight>o){var a=O.pageX-P.pageX;if(Math.abs(a)<=13)return!1}p=!0;var h,d=s.targetTouches[0].clientX,c=s.targetTouches[0].clientY,u=M-d,m=z-c;if(Math.abs(u)>Math.abs(m)?(L=!1,I=!0):(I=!1,L=!0),t=P.pageX-O.pageX,E=100*t/l,i=P.pageY-O.pageY,A=100*i/o,L&&f&&(h=1-Math.abs(i)/o,Y.style.opacity=h,e.settings.touchFollowAxis&&(E=0)),I&&(h=1-Math.abs(t)/l,g.style.opacity=h,e.settings.touchFollowAxis&&(A=0)),!f)return v(g,"translate3d(".concat(E,"%, 0, 0)"));v(g,"translate3d(".concat(E,"%, ").concat(A,"%, 0)"))}},touchEnd:function(){if(r){if(p=!1,S||b)return C=w,void(k=T);var t=Math.abs(parseInt(A)),i=Math.abs(parseInt(E));if(!(t>29&&f))return t<29&&i<25?(h(Y,"greset"),Y.style.opacity=1,W(g)):void 0;e.close()}},multipointEnd:function(){setTimeout((function(){b=!1}),50)},multipointStart:function(){b=!0,m=x||1},pinch:function(e){if(!f||p)return!1;b=!0,f.scaleX=f.scaleY=m*e.zoom;var t=m*e.zoom;if(S=!0,t<=1)return S=!1,t=1,k=null,C=null,w=null,T=null,void f.setAttribute("style","");t>4.5&&(t=4.5),f.style.transform="scale3d(".concat(t,", ").concat(t,", 1)"),x=t},pressMove:function(e){if(S&&!b){var t=P.pageX-O.pageX,i=P.pageY-O.pageY;C&&(t+=C),k&&(i+=k),w=t,T=i;var n="translate3d(".concat(t,"px, ").concat(i,"px, 0)");x&&(n+=" scale3d(".concat(x,", ").concat(x,", 1)")),v(f,n)}},swipe:function(t){if(!S)if(b)b=!1;else{if("Left"==t.direction){if(e.index==e.elements.length-1)return W(g);e.nextSlide()}if("Right"==t.direction){if(0==e.index)return W(g);e.prevSlide()}}}});e.events.touch=q}var H=function(){function e(i,n){var s=this,l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(t(this,e),this.img=i,this.slide=n,this.onclose=l,this.img.setZoomEvents)return!1;this.active=!1,this.zoomedIn=!1,this.dragging=!1,this.currentX=null,this.currentY=null,this.initialX=null,this.initialY=null,this.xOffset=0,this.yOffset=0,this.img.addEventListener("mousedown",(function(e){return s.dragStart(e)}),!1),this.img.addEventListener("mouseup",(function(e){return s.dragEnd(e)}),!1),this.img.addEventListener("mousemove",(function(e){return s.drag(e)}),!1),this.img.addEventListener("click",(function(e){return s.slide.classList.contains("dragging-nav")?(s.zoomOut(),!1):s.zoomedIn?void(s.zoomedIn&&!s.dragging&&s.zoomOut()):s.zoomIn()}),!1),this.img.setZoomEvents=!0}return n(e,[{key:"zoomIn",value:function(){var e=this.widowWidth();if(!(this.zoomedIn||e<=768)){var t=this.img;if(t.setAttribute("data-style",t.getAttribute("style")),t.style.maxWidth=t.naturalWidth+"px",t.style.maxHeight=t.naturalHeight+"px",t.naturalWidth>e){var i=e/2-t.naturalWidth/2;this.setTranslate(this.img.parentNode,i,0)}this.slide.classList.add("zoomed"),this.zoomedIn=!0}}},{key:"zoomOut",value:function(){this.img.parentNode.setAttribute("style",""),this.img.setAttribute("style",this.img.getAttribute("data-style")),this.slide.classList.remove("zoomed"),this.zoomedIn=!1,this.currentX=null,this.currentY=null,this.initialX=null,this.initialY=null,this.xOffset=0,this.yOffset=0,this.onclose&&"function"==typeof this.onclose&&this.onclose()}},{key:"dragStart",value:function(e){e.preventDefault(),this.zoomedIn?("touchstart"===e.type?(this.initialX=e.touches[0].clientX-this.xOffset,this.initialY=e.touches[0].clientY-this.yOffset):(this.initialX=e.clientX-this.xOffset,this.initialY=e.clientY-this.yOffset),e.target===this.img&&(this.active=!0,this.img.classList.add("dragging"))):this.active=!1}},{key:"dragEnd",value:function(e){var t=this;e.preventDefault(),this.initialX=this.currentX,this.initialY=this.currentY,this.active=!1,setTimeout((function(){t.dragging=!1,t.img.isDragging=!1,t.img.classList.remove("dragging")}),100)}},{key:"drag",value:function(e){this.active&&(e.preventDefault(),"touchmove"===e.type?(this.currentX=e.touches[0].clientX-this.initialX,this.currentY=e.touches[0].clientY-this.initialY):(this.currentX=e.clientX-this.initialX,this.currentY=e.clientY-this.initialY),this.xOffset=this.currentX,this.yOffset=this.currentY,this.img.isDragging=!0,this.dragging=!0,this.setTranslate(this.img,this.currentX,this.currentY))}},{key:"onMove",value:function(e){if(this.zoomedIn){var t=e.clientX-this.img.naturalWidth/2,i=e.clientY-this.img.naturalHeight/2;this.setTranslate(this.img,t,i)}}},{key:"setTranslate",value:function(e,t,i){e.style.transform="translate3d("+t+"px, "+i+"px, 0)"}},{key:"widowWidth",value:function(){return window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth}}]),e}(),V=function(){function e(){var i=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t(this,e);var s=n.dragEl,l=n.toleranceX,o=void 0===l?40:l,r=n.toleranceY,a=void 0===r?65:r,h=n.slide,d=void 0===h?null:h,c=n.instance,u=void 0===c?null:c;this.el=s,this.active=!1,this.dragging=!1,this.currentX=null,this.currentY=null,this.initialX=null,this.initialY=null,this.xOffset=0,this.yOffset=0,this.direction=null,this.lastDirection=null,this.toleranceX=o,this.toleranceY=a,this.toleranceReached=!1,this.dragContainer=this.el,this.slide=d,this.instance=u,this.el.addEventListener("mousedown",(function(e){return i.dragStart(e)}),!1),this.el.addEventListener("mouseup",(function(e){return i.dragEnd(e)}),!1),this.el.addEventListener("mousemove",(function(e){return i.drag(e)}),!1)}return n(e,[{key:"dragStart",value:function(e){if(this.slide.classList.contains("zoomed"))this.active=!1;else{"touchstart"===e.type?(this.initialX=e.touches[0].clientX-this.xOffset,this.initialY=e.touches[0].clientY-this.yOffset):(this.initialX=e.clientX-this.xOffset,this.initialY=e.clientY-this.yOffset);var t=e.target.nodeName.toLowerCase();e.target.classList.contains("nodrag")||u(e.target,".nodrag")||-1!==["input","select","textarea","button","a"].indexOf(t)?this.active=!1:(e.preventDefault(),(e.target===this.el||"img"!==t&&u(e.target,".gslide-inline"))&&(this.active=!0,this.el.classList.add("dragging"),this.dragContainer=u(e.target,".ginner-container")))}}},{key:"dragEnd",value:function(e){var t=this;e&&e.preventDefault(),this.initialX=0,this.initialY=0,this.currentX=null,this.currentY=null,this.initialX=null,this.initialY=null,this.xOffset=0,this.yOffset=0,this.active=!1,this.doSlideChange&&(this.instance.preventOutsideClick=!0,"right"==this.doSlideChange&&this.instance.prevSlide(),"left"==this.doSlideChange&&this.instance.nextSlide()),this.doSlideClose&&this.instance.close(),this.toleranceReached||this.setTranslate(this.dragContainer,0,0,!0),setTimeout((function(){t.instance.preventOutsideClick=!1,t.toleranceReached=!1,t.lastDirection=null,t.dragging=!1,t.el.isDragging=!1,t.el.classList.remove("dragging"),t.slide.classList.remove("dragging-nav"),t.dragContainer.style.transform="",t.dragContainer.style.transition=""}),100)}},{key:"drag",value:function(e){if(this.active){e.preventDefault(),this.slide.classList.add("dragging-nav"),"touchmove"===e.type?(this.currentX=e.touches[0].clientX-this.initialX,this.currentY=e.touches[0].clientY-this.initialY):(this.currentX=e.clientX-this.initialX,this.currentY=e.clientY-this.initialY),this.xOffset=this.currentX,this.yOffset=this.currentY,this.el.isDragging=!0,this.dragging=!0,this.doSlideChange=!1,this.doSlideClose=!1;var t=Math.abs(this.currentX),i=Math.abs(this.currentY);if(t>0&&t>=Math.abs(this.currentY)&&(!this.lastDirection||"x"==this.lastDirection)){this.yOffset=0,this.lastDirection="x",this.setTranslate(this.dragContainer,this.currentX,0);var n=this.shouldChange();if(!this.instance.settings.dragAutoSnap&&n&&(this.doSlideChange=n),this.instance.settings.dragAutoSnap&&n)return this.instance.preventOutsideClick=!0,this.toleranceReached=!0,this.active=!1,this.instance.preventOutsideClick=!0,this.dragEnd(null),"right"==n&&this.instance.prevSlide(),void("left"==n&&this.instance.nextSlide())}if(this.toleranceY>0&&i>0&&i>=t&&(!this.lastDirection||"y"==this.lastDirection)){this.xOffset=0,this.lastDirection="y",this.setTranslate(this.dragContainer,0,this.currentY);var s=this.shouldClose();return!this.instance.settings.dragAutoSnap&&s&&(this.doSlideClose=!0),void(this.instance.settings.dragAutoSnap&&s&&this.instance.close())}}}},{key:"shouldChange",value:function(){var e=!1;if(Math.abs(this.currentX)>=this.toleranceX){var t=this.currentX>0?"right":"left";("left"==t&&this.slide!==this.slide.parentNode.lastChild||"right"==t&&this.slide!==this.slide.parentNode.firstChild)&&(e=t)}return e}},{key:"shouldClose",value:function(){var e=!1;return Math.abs(this.currentY)>=this.toleranceY&&(e=!0),e}},{key:"setTranslate",value:function(e,t,i){var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];e.style.transition=n?"all .2s ease":"",e.style.transform="translate3d(".concat(t,"px, ").concat(i,"px, 0)")}}]),e}();function j(e,t,i,n){var s=e.querySelector(".gslide-media"),l=new Image,o="gSlideTitle_"+i,r="gSlideDesc_"+i;l.addEventListener("load",(function(){T(n)&&n()}),!1),l.src=t.href,""!=t.sizes&&""!=t.srcset&&(l.sizes=t.sizes,l.srcset=t.srcset),l.alt="",I(t.alt)||""===t.alt||(l.alt=t.alt),""!==t.title&&l.setAttribute("aria-labelledby",o),""!==t.description&&l.setAttribute("aria-describedby",r),t.hasOwnProperty("_hasCustomWidth")&&t._hasCustomWidth&&(l.style.width=t.width),t.hasOwnProperty("_hasCustomHeight")&&t._hasCustomHeight&&(l.style.height=t.height),s.insertBefore(l,s.firstChild)}function F(e,t,i,n){var s=this,l=e.querySelector(".ginner-container"),o="gvideo"+i,r=e.querySelector(".gslide-media"),a=this.getAllPlayers();h(l,"gvideo-container"),r.insertBefore(m('<div class="gvideo-wrapper"></div>'),r.firstChild);var d=e.querySelector(".gvideo-wrapper");S(this.settings.plyr.css,"Plyr");var c=t.href,u=null==t?void 0:t.videoProvider,g=!1;r.style.maxWidth=t.width,S(this.settings.plyr.js,"Plyr",(function(){if(!u&&c.match(/vimeo\.com\/([0-9]*)/)&&(u="vimeo"),!u&&(c.match(/(youtube\.com|youtube-nocookie\.com)\/watch\?v=([a-zA-Z0-9\-_]+)/)||c.match(/youtu\.be\/([a-zA-Z0-9\-_]+)/)||c.match(/(youtube\.com|youtube-nocookie\.com)\/embed\/([a-zA-Z0-9\-_]+)/))&&(u="youtube"),"local"===u||!u){u="local";var l='<video id="'+o+'" ';l+='style="background:#000; max-width: '.concat(t.width,';" '),l+='preload="metadata" ',l+='x-webkit-airplay="allow" ',l+="playsinline ",l+="controls ",l+='class="gvideo-local">',l+='<source src="'.concat(c,'">'),g=m(l+="</video>")}var r=g||m('<div id="'.concat(o,'" data-plyr-provider="').concat(u,'" data-plyr-embed-id="').concat(c,'"></div>'));h(d,"".concat(u,"-video gvideo")),d.appendChild(r),d.setAttribute("data-id",o),d.setAttribute("data-index",i);var v=O(s.settings.plyr,"config")?s.settings.plyr.config:{},f=new Plyr("#"+o,v);f.on("ready",(function(e){a[o]=e.detail.plyr,T(n)&&n()})),b((function(){return e.querySelector("iframe")&&"true"==e.querySelector("iframe").dataset.ready}),(function(){s.resize(e)})),f.on("enterfullscreen",R),f.on("exitfullscreen",R)}))}function R(e){var t=u(e.target,".gslide-media");"enterfullscreen"===e.type&&h(t,"fullscreen"),"exitfullscreen"===e.type&&d(t,"fullscreen")}function G(e,t,i,n){var s,l=this,o=e.querySelector(".gslide-media"),r=!(!O(t,"href")||!t.href)&&t.href.split("#").pop().trim(),d=!(!O(t,"content")||!t.content)&&t.content;if(d&&(C(d)&&(s=m('<div class="ginlined-content">'.concat(d,"</div>"))),k(d))){"none"==d.style.display&&(d.style.display="block");var c=document.createElement("div");c.className="ginlined-content",c.appendChild(d),s=c}if(r){var u=document.getElementById(r);if(!u)return!1;var g=u.cloneNode(!0);g.style.height=t.height,g.style.maxWidth=t.width,h(g,"ginlined-content"),s=g}if(!s)return console.error("Unable to append inline slide content",t),!1;o.style.height=t.height,o.style.width=t.width,o.appendChild(s),this.events["inlineclose"+r]=a("click",{onElement:o.querySelectorAll(".gtrigger-close"),withCallback:function(e){e.preventDefault(),l.close()}}),T(n)&&n()}function Z(e,t,i,n){var s=e.querySelector(".gslide-media"),l=function(e){var t=e.url,i=e.allow,n=e.callback,s=e.appendTo,l=document.createElement("iframe");return l.className="vimeo-video gvideo",l.src=t,l.style.width="100%",l.style.height="100%",i&&l.setAttribute("allow",i),l.onload=function(){l.onload=null,h(l,"node-ready"),T(n)&&n()},s&&s.appendChild(l),l}({url:t.href,callback:n});s.parentNode.style.maxWidth=t.width,s.parentNode.style.height=t.height,s.appendChild(l)}var U=function(){function e(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t(this,e),this.defaults={href:"",sizes:"",srcset:"",title:"",type:"",videoProvider:"",description:"",alt:"",descPosition:"bottom",effect:"",width:"",height:"",content:!1,zoomable:!0,draggable:!0},L(i)&&(this.defaults=l(this.defaults,i))}return n(e,[{key:"sourceType",value:function(e){var t=e;if(null!==(e=e.toLowerCase()).match(/\.(jpeg|jpg|jpe|gif|png|apn|webp|avif|svg)/))return"image";if(e.match(/(youtube\.com|youtube-nocookie\.com)\/watch\?v=([a-zA-Z0-9\-_]+)/)||e.match(/youtu\.be\/([a-zA-Z0-9\-_]+)/)||e.match(/(youtube\.com|youtube-nocookie\.com)\/embed\/([a-zA-Z0-9\-_]+)/))return"video";if(e.match(/vimeo\.com\/([0-9]*)/))return"video";if(null!==e.match(/\.(mp4|ogg|webm|mov)/))return"video";if(null!==e.match(/\.(mp3|wav|wma|aac|ogg)/))return"audio";if(e.indexOf("#")>-1&&""!==t.split("#").pop().trim())return"inline";return e.indexOf("goajax=true")>-1?"ajax":"external"}},{key:"parseConfig",value:function(e,t){var i=this,n=l({descPosition:t.descPosition},this.defaults);if(L(e)&&!k(e)){O(e,"type")||(O(e,"content")&&e.content?e.type="inline":O(e,"href")&&(e.type=this.sourceType(e.href)));var s=l(n,e);return this.setSize(s,t),s}var r="",a=e.getAttribute("data-glightbox"),h=e.nodeName.toLowerCase();if("a"===h&&(r=e.href),"img"===h&&(r=e.src,n.alt=e.alt),n.href=r,o(n,(function(s,l){O(t,l)&&"width"!==l&&(n[l]=t[l]);var o=e.dataset[l];I(o)||(n[l]=i.sanitizeValue(o))})),n.content&&(n.type="inline"),!n.type&&r&&(n.type=this.sourceType(r)),I(a)){if(!n.title&&"a"==h){var d=e.title;I(d)||""===d||(n.title=d)}if(!n.title&&"img"==h){var c=e.alt;I(c)||""===c||(n.title=c)}}else{var u=[];o(n,(function(e,t){u.push(";\\s?"+t)})),u=u.join("\\s?:|"),""!==a.trim()&&o(n,(function(e,t){var s=a,l=new RegExp("s?"+t+"s?:s?(.*?)("+u+"s?:|$)"),o=s.match(l);if(o&&o.length&&o[1]){var r=o[1].trim().replace(/;\s*$/,"");n[t]=i.sanitizeValue(r)}}))}if(n.description&&"."===n.description.substring(0,1)){var g;try{g=document.querySelector(n.description).innerHTML}catch(e){if(!(e instanceof DOMException))throw e}g&&(n.description=g)}if(!n.description){var v=e.querySelector(".glightbox-desc");v&&(n.description=v.innerHTML)}return this.setSize(n,t,e),this.slideConfig=n,n}},{key:"setSize",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n="video"==e.type?this.checkSize(t.videosWidth):this.checkSize(t.width),s=this.checkSize(t.height);return e.width=O(e,"width")&&""!==e.width?this.checkSize(e.width):n,e.height=O(e,"height")&&""!==e.height?this.checkSize(e.height):s,i&&"image"==e.type&&(e._hasCustomWidth=!!i.dataset.width,e._hasCustomHeight=!!i.dataset.height),e}},{key:"checkSize",value:function(e){return M(e)?"".concat(e,"px"):e}},{key:"sanitizeValue",value:function(e){return"true"!==e&&"false"!==e?e:"true"===e}}]),e}(),$=function(){function e(i,n,s){t(this,e),this.element=i,this.instance=n,this.index=s}return n(e,[{key:"setContent",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(c(t,"loaded"))return!1;var n=this.instance.settings,s=this.slideConfig,l=w();T(n.beforeSlideLoad)&&n.beforeSlideLoad({index:this.index,slide:t,player:!1});var o=s.type,r=s.descPosition,a=t.querySelector(".gslide-media"),d=t.querySelector(".gslide-title"),u=t.querySelector(".gslide-desc"),g=t.querySelector(".gdesc-inner"),v=i,f="gSlideTitle_"+this.index,p="gSlideDesc_"+this.index;if(T(n.afterSlideLoad)&&(v=function(){T(i)&&i(),n.afterSlideLoad({index:e.index,slide:t,player:e.instance.getSlidePlayerInstance(e.index)})}),""==s.title&&""==s.description?g&&g.parentNode.parentNode.removeChild(g.parentNode):(d&&""!==s.title?(d.id=f,d.innerHTML=s.title):d.parentNode.removeChild(d),u&&""!==s.description?(u.id=p,l&&n.moreLength>0?(s.smallDescription=this.slideShortDesc(s.description,n.moreLength,n.moreText),u.innerHTML=s.smallDescription,this.descriptionEvents(u,s)):u.innerHTML=s.description):u.parentNode.removeChild(u),h(a.parentNode,"desc-".concat(r)),h(g.parentNode,"description-".concat(r))),h(a,"gslide-".concat(o)),h(t,"loaded"),"video"!==o){if("external"!==o)return"inline"===o?(G.apply(this.instance,[t,s,this.index,v]),void(s.draggable&&new V({dragEl:t.querySelector(".gslide-inline"),toleranceX:n.dragToleranceX,toleranceY:n.dragToleranceY,slide:t,instance:this.instance}))):void("image"!==o?T(v)&&v():j(t,s,this.index,(function(){var i=t.querySelector("img");s.draggable&&new V({dragEl:i,toleranceX:n.dragToleranceX,toleranceY:n.dragToleranceY,slide:t,instance:e.instance}),s.zoomable&&i.naturalWidth>i.offsetWidth&&(h(i,"zoomable"),new H(i,t,(function(){e.instance.resize()}))),T(v)&&v()})));Z.apply(this,[t,s,this.index,v])}else F.apply(this.instance,[t,s,this.index,v])}},{key:"slideShortDesc",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:50,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=document.createElement("div");n.innerHTML=e;var s=n.innerText,l=i;if((e=s.trim()).length<=t)return e;var o=e.substr(0,t-1);return l?(n=null,o+'... <a href="#" class="desc-more">'+i+"</a>"):o}},{key:"descriptionEvents",value:function(e,t){var i=this,n=e.querySelector(".desc-more");if(!n)return!1;a("click",{onElement:n,withCallback:function(e,n){e.preventDefault();var s=document.body,l=u(n,".gslide-desc");if(!l)return!1;l.innerHTML=t.description,h(s,"gdesc-open");var o=a("click",{onElement:[s,u(l,".gslide-description")],withCallback:function(e,n){"a"!==e.target.nodeName.toLowerCase()&&(d(s,"gdesc-open"),h(s,"gdesc-closed"),l.innerHTML=t.smallDescription,i.descriptionEvents(l,t),setTimeout((function(){d(s,"gdesc-closed")}),400),o.destroy())}})}})}},{key:"create",value:function(){return m(this.instance.settings.slideHTML)}},{key:"getConfig",value:function(){k(this.element)||this.element.hasOwnProperty("draggable")||(this.element.draggable=this.instance.settings.draggable);var e=new U(this.instance.settings.slideExtraAttributes);return this.slideConfig=e.parseConfig(this.element,this.instance.settings),this.slideConfig}}]),e}(),J=w(),K=null!==w()||void 0!==document.createTouch||"ontouchstart"in window||"onmsgesturechange"in window||navigator.msMaxTouchPoints,Q=document.getElementsByTagName("html")[0],ee={selector:".glightbox",elements:null,skin:"clean",theme:"clean",closeButton:!0,startAt:null,autoplayVideos:!0,autofocusVideos:!0,descPosition:"bottom",width:"900px",height:"506px",videosWidth:"960px",beforeSlideChange:null,afterSlideChange:null,beforeSlideLoad:null,afterSlideLoad:null,slideInserted:null,slideRemoved:null,slideExtraAttributes:null,onOpen:null,onClose:null,loop:!1,zoomable:!0,draggable:!0,dragAutoSnap:!1,dragToleranceX:40,dragToleranceY:65,preload:!0,oneSlidePerOpen:!1,touchNavigation:!0,touchFollowAxis:!0,keyboardNavigation:!0,closeOnOutsideClick:!0,plugins:!1,plyr:{css:"https://cdn.plyr.io/3.6.12/plyr.css",js:"https://cdn.plyr.io/3.6.12/plyr.js",config:{ratio:"16:9",fullscreen:{enabled:!0,iosNative:!0},youtube:{noCookie:!0,rel:0,showinfo:0,iv_load_policy:3},vimeo:{byline:!1,portrait:!1,title:!1,transparent:!1}}},openEffect:"zoom",closeEffect:"zoom",slideEffect:"slide",moreText:"See more",moreLength:60,cssEfects:{fade:{in:"fadeIn",out:"fadeOut"},zoom:{in:"zoomIn",out:"zoomOut"},slide:{in:"slideInRight",out:"slideOutLeft"},slideBack:{in:"slideInLeft",out:"slideOutRight"},none:{in:"none",out:"none"}},svg:{close:'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 512 512" xml:space="preserve"><g><g><path d="M505.943,6.058c-8.077-8.077-21.172-8.077-29.249,0L6.058,476.693c-8.077,8.077-8.077,21.172,0,29.249C10.096,509.982,15.39,512,20.683,512c5.293,0,10.586-2.019,14.625-6.059L505.943,35.306C514.019,27.23,514.019,14.135,505.943,6.058z"/></g></g><g><g><path d="M505.942,476.694L35.306,6.059c-8.076-8.077-21.172-8.077-29.248,0c-8.077,8.076-8.077,21.171,0,29.248l470.636,470.636c4.038,4.039,9.332,6.058,14.625,6.058c5.293,0,10.587-2.019,14.624-6.057C514.018,497.866,514.018,484.771,505.942,476.694z"/></g></g></svg>',next:'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 477.175 477.175" xml:space="preserve"> <g><path d="M360.731,229.075l-225.1-225.1c-5.3-5.3-13.8-5.3-19.1,0s-5.3,13.8,0,19.1l215.5,215.5l-215.5,215.5c-5.3,5.3-5.3,13.8,0,19.1c2.6,2.6,6.1,4,9.5,4c3.4,0,6.9-1.3,9.5-4l225.1-225.1C365.931,242.875,365.931,234.275,360.731,229.075z"/></g></svg>',prev:'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 477.175 477.175" xml:space="preserve"><g><path d="M145.188,238.575l215.5-215.5c5.3-5.3,5.3-13.8,0-19.1s-13.8-5.3-19.1,0l-225.1,225.1c-5.3,5.3-5.3,13.8,0,19.1l225.1,225c2.6,2.6,6.1,4,9.5,4s6.9-1.3,9.5-4c5.3-5.3,5.3-13.8,0-19.1L145.188,238.575z"/></g></svg>'},slideHTML:'<div class="gslide">\n <div class="gslide-inner-content">\n <div class="ginner-container">\n <div class="gslide-media">\n </div>\n <div class="gslide-description">\n <div class="gdesc-inner">\n <h4 class="gslide-title"></h4>\n <div class="gslide-desc"></div>\n </div>\n </div>\n </div>\n </div>\n</div>',lightboxHTML:'<div id="glightbox-body" class="glightbox-container" tabindex="-1" role="dialog" aria-hidden="false">\n <div class="gloader visible"></div>\n <div class="goverlay"></div>\n <div class="gcontainer">\n <div id="glightbox-slider" class="gslider"></div>\n <button class="gclose gbtn" aria-label="Close" data-taborder="3">{closeSVG}</button>\n <button class="gprev gbtn" aria-label="Previous" data-taborder="2">{prevSVG}</button>\n <button class="gnext gbtn" aria-label="Next" data-taborder="1">{nextSVG}</button>\n</div>\n</div>'},te=function(){function e(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t(this,e),this.customOptions=i,this.settings=l(ee,i),this.effectsClasses=this.getAnimationClasses(),this.videoPlayers={},this.apiEvents=[],this.fullElementsList=!1}return n(e,[{key:"init",value:function(){var e=this,t=this.getSelector();t&&(this.baseEvents=a("click",{onElement:t,withCallback:function(t,i){t.preventDefault(),e.open(i)}})),this.elements=this.getElements()}},{key:"open",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(0===this.elements.length)return!1;this.activeSlide=null,this.prevActiveSlideIndex=null,this.prevActiveSlide=null;var i=M(t)?t:this.settings.startAt;if(k(e)){var n=e.getAttribute("data-gallery");n&&(this.fullElementsList=this.elements,this.elements=this.getGalleryElements(this.elements,n)),I(i)&&(i=this.getElementIndex(e))<0&&(i=0)}M(i)||(i=0),this.build(),g(this.overlay,"none"===this.settings.openEffect?"none":this.settings.cssEfects.fade.in);var s=document.body,l=window.innerWidth-document.documentElement.clientWidth;if(l>0){var o=document.createElement("style");o.type="text/css",o.className="gcss-styles",o.innerText=".gscrollbar-fixer {margin-right: ".concat(l,"px}"),document.head.appendChild(o),h(s,"gscrollbar-fixer")}h(s,"glightbox-open"),h(Q,"glightbox-open"),J&&(h(document.body,"glightbox-mobile"),this.settings.slideEffect="slide"),this.showSlide(i,!0),1===this.elements.length?(h(this.prevButton,"glightbox-button-hidden"),h(this.nextButton,"glightbox-button-hidden")):(d(this.prevButton,"glightbox-button-hidden"),d(this.nextButton,"glightbox-button-hidden")),this.lightboxOpen=!0,this.trigger("open"),T(this.settings.onOpen)&&this.settings.onOpen(),K&&this.settings.touchNavigation&&B(this),this.settings.keyboardNavigation&&X(this)}},{key:"openAt",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.open(null,e)}},{key:"showSlide",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];f(this.loader),this.index=parseInt(t);var n=this.slidesContainer.querySelector(".current");n&&d(n,"current"),this.slideAnimateOut();var s=this.slidesContainer.querySelectorAll(".gslide")[t];if(c(s,"loaded"))this.slideAnimateIn(s,i),p(this.loader);else{f(this.loader);var l=this.elements[t],o={index:this.index,slide:s,slideNode:s,slideConfig:l.slideConfig,slideIndex:this.index,trigger:l.node,player:null};this.trigger("slide_before_load",o),l.instance.setContent(s,(function(){p(e.loader),e.resize(),e.slideAnimateIn(s,i),e.trigger("slide_after_load",o)}))}this.slideDescription=s.querySelector(".gslide-description"),this.slideDescriptionContained=this.slideDescription&&c(this.slideDescription.parentNode,"gslide-media"),this.settings.preload&&(this.preloadSlide(t+1),this.preloadSlide(t-1)),this.updateNavigationClasses(),this.activeSlide=s}},{key:"preloadSlide",value:function(e){var t=this;if(e<0||e>this.elements.length-1)return!1;if(I(this.elements[e]))return!1;var i=this.slidesContainer.querySelectorAll(".gslide")[e];if(c(i,"loaded"))return!1;var n=this.elements[e],s=n.type,l={index:e,slide:i,slideNode:i,slideConfig:n.slideConfig,slideIndex:e,trigger:n.node,player:null};this.trigger("slide_before_load",l),"video"===s||"external"===s?setTimeout((function(){n.instance.setContent(i,(function(){t.trigger("slide_after_load",l)}))}),200):n.instance.setContent(i,(function(){t.trigger("slide_after_load",l)}))}},{key:"prevSlide",value:function(){this.goToSlide(this.index-1)}},{key:"nextSlide",value:function(){this.goToSlide(this.index+1)}},{key:"goToSlide",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.prevActiveSlide=this.activeSlide,this.prevActiveSlideIndex=this.index,!this.loop()&&(e<0||e>this.elements.length-1))return!1;e<0?e=this.elements.length-1:e>=this.elements.length&&(e=0),this.showSlide(e)}},{key:"insertSlide",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;t<0&&(t=this.elements.length);var i=new $(e,this,t),n=i.getConfig(),s=l({},n),o=i.create(),r=this.elements.length-1;s.index=t,s.node=!1,s.instance=i,s.slideConfig=n,this.elements.splice(t,0,s);var a=null,h=null;if(this.slidesContainer){if(t>r)this.slidesContainer.appendChild(o);else{var d=this.slidesContainer.querySelectorAll(".gslide")[t];this.slidesContainer.insertBefore(o,d)}(this.settings.preload&&0==this.index&&0==t||this.index-1==t||this.index+1==t)&&this.preloadSlide(t),0===this.index&&0===t&&(this.index=1),this.updateNavigationClasses(),a=this.slidesContainer.querySelectorAll(".gslide")[t],h=this.getSlidePlayerInstance(t),s.slideNode=a}this.trigger("slide_inserted",{index:t,slide:a,slideNode:a,slideConfig:n,slideIndex:t,trigger:null,player:h}),T(this.settings.slideInserted)&&this.settings.slideInserted({index:t,slide:a,player:h})}},{key:"removeSlide",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1;if(e<0||e>this.elements.length-1)return!1;var t=this.slidesContainer&&this.slidesContainer.querySelectorAll(".gslide")[e];t&&(this.getActiveSlideIndex()==e&&(e==this.elements.length-1?this.prevSlide():this.nextSlide()),t.parentNode.removeChild(t)),this.elements.splice(e,1),this.trigger("slide_removed",e),T(this.settings.slideRemoved)&&this.settings.slideRemoved(e)}},{key:"slideAnimateIn",value:function(e,t){var i=this,n=e.querySelector(".gslide-media"),s=e.querySelector(".gslide-description"),l={index:this.prevActiveSlideIndex,slide:this.prevActiveSlide,slideNode:this.prevActiveSlide,slideIndex:this.prevActiveSlide,slideConfig:I(this.prevActiveSlideIndex)?null:this.elements[this.prevActiveSlideIndex].slideConfig,trigger:I(this.prevActiveSlideIndex)?null:this.elements[this.prevActiveSlideIndex].node,player:this.getSlidePlayerInstance(this.prevActiveSlideIndex)},o={index:this.index,slide:this.activeSlide,slideNode:this.activeSlide,slideConfig:this.elements[this.index].slideConfig,slideIndex:this.index,trigger:this.elements[this.index].node,player:this.getSlidePlayerInstance(this.index)};if(n.offsetWidth>0&&s&&(p(s),s.style.display=""),d(e,this.effectsClasses),t)g(e,this.settings.cssEfects[this.settings.openEffect].in,(function(){i.settings.autoplayVideos&&i.slidePlayerPlay(e),i.trigger("slide_changed",{prev:l,current:o}),T(i.settings.afterSlideChange)&&i.settings.afterSlideChange.apply(i,[l,o])}));else{var r=this.settings.slideEffect,a="none"!==r?this.settings.cssEfects[r].in:r;this.prevActiveSlideIndex>this.index&&"slide"==this.settings.slideEffect&&(a=this.settings.cssEfects.slideBack.in),g(e,a,(function(){i.settings.autoplayVideos&&i.slidePlayerPlay(e),i.trigger("slide_changed",{prev:l,current:o}),T(i.settings.afterSlideChange)&&i.settings.afterSlideChange.apply(i,[l,o])}))}setTimeout((function(){i.resize(e)}),100),h(e,"current")}},{key:"slideAnimateOut",value:function(){if(!this.prevActiveSlide)return!1;var e=this.prevActiveSlide;d(e,this.effectsClasses),h(e,"prev");var t=this.settings.slideEffect,i="none"!==t?this.settings.cssEfects[t].out:t;this.slidePlayerPause(e),this.trigger("slide_before_change",{prev:{index:this.prevActiveSlideIndex,slide:this.prevActiveSlide,slideNode:this.prevActiveSlide,slideIndex:this.prevActiveSlideIndex,slideConfig:I(this.prevActiveSlideIndex)?null:this.elements[this.prevActiveSlideIndex].slideConfig,trigger:I(this.prevActiveSlideIndex)?null:this.elements[this.prevActiveSlideIndex].node,player:this.getSlidePlayerInstance(this.prevActiveSlideIndex)},current:{index:this.index,slide:this.activeSlide,slideNode:this.activeSlide,slideIndex:this.index,slideConfig:this.elements[this.index].slideConfig,trigger:this.elements[this.index].node,player:this.getSlidePlayerInstance(this.index)}}),T(this.settings.beforeSlideChange)&&this.settings.beforeSlideChange.apply(this,[{index:this.prevActiveSlideIndex,slide:this.prevActiveSlide,player:this.getSlidePlayerInstance(this.prevActiveSlideIndex)},{index:this.index,slide:this.activeSlide,player:this.getSlidePlayerInstance(this.index)}]),this.prevActiveSlideIndex>this.index&&"slide"==this.settings.slideEffect&&(i=this.settings.cssEfects.slideBack.out),g(e,i,(function(){var t=e.querySelector(".ginner-container"),i=e.querySelector(".gslide-media"),n=e.querySelector(".gslide-description");t.style.transform="",i.style.transform="",d(i,"greset"),i.style.opacity="",n&&(n.style.opacity=""),d(e,"prev")}))}},{key:"getAllPlayers",value:function(){return this.videoPlayers}},{key:"getSlidePlayerInstance",value:function(e){var t="gvideo"+e,i=this.getAllPlayers();return!(!O(i,t)||!i[t])&&i[t]}},{key:"stopSlideVideo",value:function(e){if(k(e)){var t=e.querySelector(".gvideo-wrapper");t&&(e=t.getAttribute("data-index"))}console.log("stopSlideVideo is deprecated, use slidePlayerPause");var i=this.getSlidePlayerInstance(e);i&&i.playing&&i.pause()}},{key:"slidePlayerPause",value:function(e){if(k(e)){var t=e.querySelector(".gvideo-wrapper");t&&(e=t.getAttribute("data-index"))}var i=this.getSlidePlayerInstance(e);i&&i.playing&&i.pause()}},{key:"playSlideVideo",value:function(e){if(k(e)){var t=e.querySelector(".gvideo-wrapper");t&&(e=t.getAttribute("data-index"))}console.log("playSlideVideo is deprecated, use slidePlayerPlay");var i=this.getSlidePlayerInstance(e);i&&!i.playing&&i.play()}},{key:"slidePlayerPlay",value:function(e){var t;if(!J||null!==(t=this.settings.plyr.config)&&void 0!==t&&t.muted){if(k(e)){var i=e.querySelector(".gvideo-wrapper");i&&(e=i.getAttribute("data-index"))}var n=this.getSlidePlayerInstance(e);n&&!n.playing&&(n.play(),this.settings.autofocusVideos&&n.elements.container.focus())}}},{key:"setElements",value:function(e){var t=this;this.settings.elements=!1;var i=[];e&&e.length&&o(e,(function(e,n){var s=new $(e,t,n),o=s.getConfig(),r=l({},o);r.slideConfig=o,r.instance=s,r.index=n,i.push(r)})),this.elements=i,this.lightboxOpen&&(this.slidesContainer.innerHTML="",this.elements.length&&(o(this.elements,(function(){var e=m(t.settings.slideHTML);t.slidesContainer.appendChild(e)})),this.showSlide(0,!0)))}},{key:"getElementIndex",value:function(e){var t=!1;return o(this.elements,(function(i,n){if(O(i,"node")&&i.node==e)return t=n,!0})),t}},{key:"getElements",value:function(){var e=this,t=[];this.elements=this.elements?this.elements:[],!I(this.settings.elements)&&E(this.settings.elements)&&this.settings.elements.length&&o(this.settings.elements,(function(i,n){var s=new $(i,e,n),o=s.getConfig(),r=l({},o);r.node=!1,r.index=n,r.instance=s,r.slideConfig=o,t.push(r)}));var i=!1;return this.getSelector()&&(i=document.querySelectorAll(this.getSelector())),i?(o(i,(function(i,n){var s=new $(i,e,n),o=s.getConfig(),r=l({},o);r.node=i,r.index=n,r.instance=s,r.slideConfig=o,r.gallery=i.getAttribute("data-gallery"),t.push(r)})),t):t}},{key:"getGalleryElements",value:function(e,t){return e.filter((function(e){return e.gallery==t}))}},{key:"getSelector",value:function(){return!this.settings.elements&&(this.settings.selector&&"data-"==this.settings.selector.substring(0,5)?"*[".concat(this.settings.selector,"]"):this.settings.selector)}},{key:"getActiveSlide",value:function(){return this.slidesContainer.querySelectorAll(".gslide")[this.index]}},{key:"getActiveSlideIndex",value:function(){return this.index}},{key:"getAnimationClasses",value:function(){var e=[];for(var t in this.settings.cssEfects)if(this.settings.cssEfects.hasOwnProperty(t)){var i=this.settings.cssEfects[t];e.push("g".concat(i.in)),e.push("g".concat(i.out))}return e.join(" ")}},{key:"build",value:function(){var e=this;if(this.built)return!1;var t=document.body.childNodes,i=[];o(t,(function(e){e.parentNode==document.body&&"#"!==e.nodeName.charAt(0)&&e.hasAttribute&&!e.hasAttribute("aria-hidden")&&(i.push(e),e.setAttribute("aria-hidden","true"))}));var n=O(this.settings.svg,"next")?this.settings.svg.next:"",s=O(this.settings.svg,"prev")?this.settings.svg.prev:"",l=O(this.settings.svg,"close")?this.settings.svg.close:"",r=this.settings.lightboxHTML;r=m(r=(r=(r=r.replace(/{nextSVG}/g,n)).replace(/{prevSVG}/g,s)).replace(/{closeSVG}/g,l)),document.body.appendChild(r);var d=document.getElementById("glightbox-body");this.modal=d;var g=d.querySelector(".gclose");this.prevButton=d.querySelector(".gprev"),this.nextButton=d.querySelector(".gnext"),this.overlay=d.querySelector(".goverlay"),this.loader=d.querySelector(".gloader"),this.slidesContainer=document.getElementById("glightbox-slider"),this.bodyHiddenChildElms=i,this.events={},h(this.modal,"glightbox-"+this.settings.skin),this.settings.closeButton&&g&&(this.events.close=a("click",{onElement:g,withCallback:function(t,i){t.preventDefault(),e.close()}})),g&&!this.settings.closeButton&&g.parentNode.removeChild(g),this.nextButton&&(this.events.next=a("click",{onElement:this.nextButton,withCallback:function(t,i){t.preventDefault(),e.nextSlide()}})),this.prevButton&&(this.events.prev=a("click",{onElement:this.prevButton,withCallback:function(t,i){t.preventDefault(),e.prevSlide()}})),this.settings.closeOnOutsideClick&&(this.events.outClose=a("click",{onElement:d,withCallback:function(t,i){e.preventOutsideClick||c(document.body,"glightbox-mobile")||u(t.target,".ginner-container")||u(t.target,".gbtn")||c(t.target,"gnext")||c(t.target,"gprev")||e.close()}})),o(this.elements,(function(t,i){e.slidesContainer.appendChild(t.instance.create()),t.slideNode=e.slidesContainer.querySelectorAll(".gslide")[i]})),K&&h(document.body,"glightbox-touch"),this.events.resize=a("resize",{onElement:window,withCallback:function(){e.resize()}}),this.built=!0}},{key:"resize",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if((e=e||this.activeSlide)&&!c(e,"zoomed")){var t=y(),i=e.querySelector(".gvideo-wrapper"),n=e.querySelector(".gslide-image"),s=this.slideDescription,l=t.width,o=t.height;if(l<=768?h(document.body,"glightbox-mobile"):d(document.body,"glightbox-mobile"),i||n){var r=!1;if(s&&(c(s,"description-bottom")||c(s,"description-top"))&&!c(s,"gabsolute")&&(r=!0),n)if(l<=768)n.querySelector("img");else if(r){var a=s.offsetHeight,u=n.querySelector("img");u.setAttribute("style","max-height: calc(100vh - ".concat(a,"px)")),s.setAttribute("style","max-width: ".concat(u.offsetWidth,"px;"))}if(i){var g=O(this.settings.plyr.config,"ratio")?this.settings.plyr.config.ratio:"";if(!g){var v=i.clientWidth,f=i.clientHeight,p=v/f;g="".concat(v/p,":").concat(f/p)}var m=g.split(":"),x=this.settings.videosWidth,b=this.settings.videosWidth,S=(b=M(x)||-1!==x.indexOf("px")?parseInt(x):-1!==x.indexOf("vw")?l*parseInt(x)/100:-1!==x.indexOf("vh")?o*parseInt(x)/100:-1!==x.indexOf("%")?l*parseInt(x)/100:parseInt(i.clientWidth))/(parseInt(m[0])/parseInt(m[1]));if(S=Math.floor(S),r&&(o-=s.offsetHeight),b>l||S>o||o<S&&l>b){var w=i.offsetWidth,T=i.offsetHeight,C=o/T,k={width:w*C,height:T*C};i.parentNode.setAttribute("style","max-width: ".concat(k.width,"px")),r&&s.setAttribute("style","max-width: ".concat(k.width,"px;"))}else i.parentNode.style.maxWidth="".concat(x),r&&s.setAttribute("style","max-width: ".concat(x,";"))}}}}},{key:"reload",value:function(){this.init()}},{key:"updateNavigationClasses",value:function(){var e=this.loop();d(this.nextButton,"disabled"),d(this.prevButton,"disabled"),0==this.index&&this.elements.length-1==0?(h(this.prevButton,"disabled"),h(this.nextButton,"disabled")):0!==this.index||e?this.index!==this.elements.length-1||e||h(this.nextButton,"disabled"):h(this.prevButton,"disabled")}},{key:"loop",value:function(){var e=O(this.settings,"loopAtEnd")?this.settings.loopAtEnd:null;return e=O(this.settings,"loop")?this.settings.loop:e,e}},{key:"close",value:function(){var e=this;if(!this.lightboxOpen){if(this.events){for(var t in this.events)this.events.hasOwnProperty(t)&&this.events[t].destroy();this.events=null}return!1}if(this.closing)return!1;this.closing=!0,this.slidePlayerPause(this.activeSlide),this.fullElementsList&&(this.elements=this.fullElementsList),this.bodyHiddenChildElms.length&&o(this.bodyHiddenChildElms,(function(e){e.removeAttribute("aria-hidden")})),h(this.modal,"glightbox-closing"),g(this.overlay,"none"==this.settings.openEffect?"none":this.settings.cssEfects.fade.out),g(this.activeSlide,this.settings.cssEfects[this.settings.closeEffect].out,(function(){if(e.activeSlide=null,e.prevActiveSlideIndex=null,e.prevActiveSlide=null,e.built=!1,e.events){for(var t in e.events)e.events.hasOwnProperty(t)&&e.events[t].destroy();e.events=null}var i=document.body;d(Q,"glightbox-open"),d(i,"glightbox-open touching gdesc-open glightbox-touch glightbox-mobile gscrollbar-fixer"),e.modal.parentNode.removeChild(e.modal),e.trigger("close"),T(e.settings.onClose)&&e.settings.onClose();var n=document.querySelector(".gcss-styles");n&&n.parentNode.removeChild(n),e.lightboxOpen=!1,e.closing=null}))}},{key:"destroy",value:function(){this.close(),this.clearAllEvents(),this.baseEvents&&this.baseEvents.destroy()}},{key:"on",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!e||!T(t))throw new TypeError("Event name and callback must be defined");this.apiEvents.push({evt:e,once:i,callback:t})}},{key:"once",value:function(e,t){this.on(e,t,!0)}},{key:"trigger",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=[];o(this.apiEvents,(function(t,s){var l=t.evt,o=t.once,r=t.callback;l==e&&(r(i),o&&n.push(s))})),n.length&&o(n,(function(e){return t.apiEvents.splice(e,1)}))}},{key:"clearAllEvents",value:function(){this.apiEvents.splice(0,this.apiEvents.length)}},{key:"version",value:function(){return"3.1.0"}}]),e}();return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=new te(e);return t.init(),t}})); 9154 9155/***/ }), 9156
vendor: 544,377 bytes, lines 9157-26367
9157/***/ "./node_modules/lodash/lodash.js": 9158/*!***************************************!*\ 9159 !*** ./node_modules/lodash/lodash.js ***! 9160 \***************************************/ 9161/***/ (function(module, exports, __webpack_require__) { 9162 9163/* module decorator */ module = __webpack_require__.nmd(module); 9164var __WEBPACK_AMD_DEFINE_RESULT__;/** 9165 * @license 9166 * Lodash <https://lodash.com/> 9167 * Copyright OpenJS Foundation and other contributors <https://openjsf.org/> 9168 * Released under MIT license <https://lodash.com/license> 9169 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> 9170 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors 9171 */ 9172;(function() { 9173 9174 /** Used as a safe reference for `undefined` in pre-ES5 environments. */ 9175 var undefined; 9176 9177 /** Used as the semantic version number. */ 9178 var VERSION = '4.17.21'; 9179 9180 /** Used as the size to enable large array optimizations. */ 9181 var LARGE_ARRAY_SIZE = 200; 9182 9183 /** Error message constants. */ 9184 var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.', 9185 FUNC_ERROR_TEXT = 'Expected a function', 9186 INVALID_TEMPL_VAR_ERROR_TEXT = 'Invalid `variable` option passed into `_.template`'; 9187 9188 /** Used to stand-in for `undefined` hash values. */ 9189 var HASH_UNDEFINED = '__lodash_hash_undefined__'; 9190 9191 /** Used as the maximum memoize cache size. */ 9192 var MAX_MEMOIZE_SIZE = 500; 9193 9194 /** Used as the internal argument placeholder. */ 9195 var PLACEHOLDER = '__lodash_placeholder__'; 9196 9197 /** Used to compose bitmasks for cloning. */ 9198 var CLONE_DEEP_FLAG = 1, 9199 CLONE_FLAT_FLAG = 2, 9200 CLONE_SYMBOLS_FLAG = 4; 9201 9202 /** Used to compose bitmasks for value comparisons. */ 9203 var COMPARE_PARTIAL_FLAG = 1, 9204 COMPARE_UNORDERED_FLAG = 2; 9205 9206 /** Used to compose bitmasks for function metadata. */ 9207 var WRAP_BIND_FLAG = 1, 9208 WRAP_BIND_KEY_FLAG = 2, 9209 WRAP_CURRY_BOUND_FLAG = 4, 9210 WRAP_CURRY_FLAG = 8, 9211 WRAP_CURRY_RIGHT_FLAG = 16, 9212 WRAP_PARTIAL_FLAG = 32, 9213 WRAP_PARTIAL_RIGHT_FLAG = 64, 9214 WRAP_ARY_FLAG = 128, 9215 WRAP_REARG_FLAG = 256, 9216 WRAP_FLIP_FLAG = 512; 9217 9218 /** Used as default options for `_.truncate`. */ 9219 var DEFAULT_TRUNC_LENGTH = 30, 9220 DEFAULT_TRUNC_OMISSION = '...'; 9221 9222 /** Used to detect hot functions by number of calls within a span of milliseconds. */ 9223 var HOT_COUNT = 800, 9224 HOT_SPAN = 16; 9225 9226 /** Used to indicate the type of lazy iteratees. */ 9227 var LAZY_FILTER_FLAG = 1, 9228 LAZY_MAP_FLAG = 2, 9229 LAZY_WHILE_FLAG = 3; 9230 9231 /** Used as references for various `Number` constants. */ 9232 var INFINITY = 1 / 0, 9233 MAX_SAFE_INTEGER = 9007199254740991, 9234 MAX_INTEGER = 1.7976931348623157e+308, 9235 NAN = 0 / 0; 9236 9237 /** Used as references for the maximum length and index of an array. */ 9238 var MAX_ARRAY_LENGTH = 4294967295, 9239 MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1, 9240 HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1; 9241 9242 /** Used to associate wrap methods with their bit flags. */ 9243 var wrapFlags = [ 9244 ['ary', WRAP_ARY_FLAG], 9245 ['bind', WRAP_BIND_FLAG], 9246 ['bindKey', WRAP_BIND_KEY_FLAG], 9247 ['curry', WRAP_CURRY_FLAG], 9248 ['curryRight', WRAP_CURRY_RIGHT_FLAG], 9249 ['flip', WRAP_FLIP_FLAG], 9250 ['partial', WRAP_PARTIAL_FLAG], 9251 ['partialRight', WRAP_PARTIAL_RIGHT_FLAG], 9252 ['rearg', WRAP_REARG_FLAG] 9253 ]; 9254 9255 /** `Object#toString` result references. */ 9256 var argsTag = '[object Arguments]', 9257 arrayTag = '[object Array]', 9258 asyncTag = '[object AsyncFunction]', 9259 boolTag = '[object Boolean]', 9260 dateTag = '[object Date]', 9261 domExcTag = '[object DOMException]', 9262 errorTag = '[object Error]', 9263 funcTag = '[object Function]', 9264 genTag = '[object GeneratorFunction]', 9265 mapTag = '[object Map]', 9266 numberTag = '[object Number]', 9267 nullTag = '[object Null]', 9268 objectTag = '[object Object]', 9269 promiseTag = '[object Promise]', 9270 proxyTag = '[object Proxy]', 9271 regexpTag = '[object RegExp]', 9272 setTag = '[object Set]', 9273 stringTag = '[object String]', 9274 symbolTag = '[object Symbol]', 9275 undefinedTag = '[object Undefined]', 9276 weakMapTag = '[object WeakMap]', 9277 weakSetTag = '[object WeakSet]'; 9278 9279 var arrayBufferTag = '[object ArrayBuffer]', 9280 dataViewTag = '[object DataView]', 9281 float32Tag = '[object Float32Array]', 9282 float64Tag = '[object Float64Array]', 9283 int8Tag = '[object Int8Array]', 9284 int16Tag = '[object Int16Array]', 9285 int32Tag = '[object Int32Array]', 9286 uint8Tag = '[object Uint8Array]', 9287 uint8ClampedTag = '[object Uint8ClampedArray]', 9288 uint16Tag = '[object Uint16Array]', 9289 uint32Tag = '[object Uint32Array]'; 9290 9291 /** Used to match empty string literals in compiled template source. */ 9292 var reEmptyStringLeading = /\b__p \+= '';/g, 9293 reEmptyStringMiddle = /\b(__p \+=) '' \+/g, 9294 reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g; 9295 9296 /** Used to match HTML entities and HTML characters. */ 9297 var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g, 9298 reUnescapedHtml = /[&<>"']/g, 9299 reHasEscapedHtml = RegExp(reEscapedHtml.source), 9300 reHasUnescapedHtml = RegExp(reUnescapedHtml.source); 9301 9302 /** Used to match template delimiters. */ 9303 var reEscape = /<%-([\s\S]+?)%>/g, 9304 reEvaluate = /<%([\s\S]+?)%>/g, 9305 reInterpolate = /<%=([\s\S]+?)%>/g; 9306 9307 /** Used to match property names within property paths. */ 9308 var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, 9309 reIsPlainProp = /^\w*$/, 9310 rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; 9311 9312 /** 9313 * Used to match `RegExp` 9314 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). 9315 */ 9316 var reRegExpChar = /[\\^$.*+?()[\]{}|]/g, 9317 reHasRegExpChar = RegExp(reRegExpChar.source); 9318 9319 /** Used to match leading whitespace. */ 9320 var reTrimStart = /^\s+/; 9321 9322 /** Used to match a single whitespace character. */ 9323 var reWhitespace = /\s/; 9324 9325 /** Used to match wrap detail comments. */ 9326 var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/, 9327 reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/, 9328 reSplitDetails = /,? & /; 9329 9330 /** Used to match words composed of alphanumeric characters. */ 9331 var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g; 9332 9333 /** 9334 * Used to validate the `validate` option in `_.template` variable. 9335 * 9336 * Forbids characters which could potentially change the meaning of the function argument definition: 9337 * - "()," (modification of function parameters) 9338 * - "=" (default value) 9339 * - "[]{}" (destructuring of function parameters) 9340 * - "/" (beginning of a comment) 9341 * - whitespace 9342 */ 9343 var reForbiddenIdentifierChars = /[()=,{}\[\]\/\s]/; 9344 9345 /** Used to match backslashes in property paths. */ 9346 var reEscapeChar = /\\(\\)?/g; 9347 9348 /** 9349 * Used to match 9350 * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components). 9351 */ 9352 var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; 9353 9354 /** Used to match `RegExp` flags from their coerced string values. */ 9355 var reFlags = /\w*$/; 9356 9357 /** Used to detect bad signed hexadecimal string values. */ 9358 var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; 9359 9360 /** Used to detect binary string values. */ 9361 var reIsBinary = /^0b[01]+$/i; 9362 9363 /** Used to detect host constructors (Safari). */ 9364 var reIsHostCtor = /^\[object .+?Constructor\]$/; 9365 9366 /** Used to detect octal string values. */ 9367 var reIsOctal = /^0o[0-7]+$/i; 9368 9369 /** Used to detect unsigned integer values. */ 9370 var reIsUint = /^(?:0|[1-9]\d*)$/; 9371 9372 /** Used to match Latin Unicode letters (excluding mathematical operators). */ 9373 var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g; 9374 9375 /** Used to ensure capturing order of template delimiters. */ 9376 var reNoMatch = /($^)/; 9377 9378 /** Used to match unescaped characters in compiled string literals. */ 9379 var reUnescapedString = /['\n\r\u2028\u2029\\]/g; 9380 9381 /** Used to compose unicode character classes. */ 9382 var rsAstralRange = '\\ud800-\\udfff', 9383 rsComboMarksRange = '\\u0300-\\u036f', 9384 reComboHalfMarksRange = '\\ufe20-\\ufe2f', 9385 rsComboSymbolsRange = '\\u20d0-\\u20ff', 9386 rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, 9387 rsDingbatRange = '\\u2700-\\u27bf', 9388 rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff', 9389 rsMathOpRange = '\\xac\\xb1\\xd7\\xf7', 9390 rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf', 9391 rsPunctuationRange = '\\u2000-\\u206f', 9392 rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000', 9393 rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde', 9394 rsVarRange = '\\ufe0e\\ufe0f', 9395 rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange; 9396 9397 /** Used to compose unicode capture groups. */ 9398 var rsApos = "['\u2019]", 9399 rsAstral = '[' + rsAstralRange + ']', 9400 rsBreak = '[' + rsBreakRange + ']', 9401 rsCombo = '[' + rsComboRange + ']', 9402 rsDigits = '\\d+', 9403 rsDingbat = '[' + rsDingbatRange + ']', 9404 rsLower = '[' + rsLowerRange + ']', 9405 rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']', 9406 rsFitz = '\\ud83c[\\udffb-\\udfff]', 9407 rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')', 9408 rsNonAstral = '[^' + rsAstralRange + ']', 9409 rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}', 9410 rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]', 9411 rsUpper = '[' + rsUpperRange + ']', 9412 rsZWJ = '\\u200d'; 9413 9414 /** Used to compose unicode regexes. */ 9415 var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')', 9416 rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')', 9417 rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?', 9418 rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?', 9419 reOptMod = rsModifier + '?', 9420 rsOptVar = '[' + rsVarRange + ']?', 9421 rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*', 9422 rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])', 9423 rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])', 9424 rsSeq = rsOptVar + reOptMod + rsOptJoin, 9425 rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq, 9426 rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; 9427 9428 /** Used to match apostrophes. */ 9429 var reApos = RegExp(rsApos, 'g'); 9430 9431 /** 9432 * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and 9433 * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols). 9434 */ 9435 var reComboMark = RegExp(rsCombo, 'g'); 9436 9437 /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ 9438 var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g'); 9439 9440 /** Used to match complex or compound words. */ 9441 var reUnicodeWord = RegExp([ 9442 rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')', 9443 rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')', 9444 rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower, 9445 rsUpper + '+' + rsOptContrUpper, 9446 rsOrdUpper, 9447 rsOrdLower, 9448 rsDigits, 9449 rsEmoji 9450 ].join('|'), 'g'); 9451 9452 /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */ 9453 var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']'); 9454 9455 /** Used to detect strings that need a more robust regexp to match words. */ 9456 var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/; 9457 9458 /** Used to assign default `context` object properties. */ 9459 var contextProps = [ 9460 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array', 9461 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object', 9462 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array', 9463 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap', 9464 '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout' 9465 ]; 9466 9467 /** Used to make template sourceURLs easier to identify. */ 9468 var templateCounter = -1; 9469 9470 /** Used to identify `toStringTag` values of typed arrays. */ 9471 var typedArrayTags = {}; 9472 typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = 9473 typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = 9474 typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = 9475 typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = 9476 typedArrayTags[uint32Tag] = true; 9477 typedArrayTags[argsTag] = typedArrayTags[arrayTag] = 9478 typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = 9479 typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = 9480 typedArrayTags[errorTag] = typedArrayTags[funcTag] = 9481 typedArrayTags[mapTag] = typedArrayTags[numberTag] = 9482 typedArrayTags[objectTag] = typedArrayTags[regexpTag] = 9483 typedArrayTags[setTag] = typedArrayTags[stringTag] = 9484 typedArrayTags[weakMapTag] = false; 9485 9486 /** Used to identify `toStringTag` values supported by `_.clone`. */ 9487 var cloneableTags = {}; 9488 cloneableTags[argsTag] = cloneableTags[arrayTag] = 9489 cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = 9490 cloneableTags[boolTag] = cloneableTags[dateTag] = 9491 cloneableTags[float32Tag] = cloneableTags[float64Tag] = 9492 cloneableTags[int8Tag] = cloneableTags[int16Tag] = 9493 cloneableTags[int32Tag] = cloneableTags[mapTag] = 9494 cloneableTags[numberTag] = cloneableTags[objectTag] = 9495 cloneableTags[regexpTag] = cloneableTags[setTag] = 9496 cloneableTags[stringTag] = cloneableTags[symbolTag] = 9497 cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = 9498 cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; 9499 cloneableTags[errorTag] = cloneableTags[funcTag] = 9500 cloneableTags[weakMapTag] = false; 9501 9502 /** Used to map Latin Unicode letters to basic Latin letters. */ 9503 var deburredLetters = { 9504 // Latin-1 Supplement block. 9505 '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A', 9506 '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a', 9507 '\xc7': 'C', '\xe7': 'c', 9508 '\xd0': 'D', '\xf0': 'd', 9509 '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E', 9510 '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e', 9511 '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I', 9512 '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i', 9513 '\xd1': 'N', '\xf1': 'n', 9514 '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O', 9515 '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o', 9516 '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U', 9517 '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u', 9518 '\xdd': 'Y', '\xfd': 'y', '\xff': 'y', 9519 '\xc6': 'Ae', '\xe6': 'ae', 9520 '\xde': 'Th', '\xfe': 'th', 9521 '\xdf': 'ss', 9522 // Latin Extended-A block. 9523 '\u0100': 'A', '\u0102': 'A', '\u0104': 'A', 9524 '\u0101': 'a', '\u0103': 'a', '\u0105': 'a', 9525 '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C', 9526 '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c', 9527 '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd', 9528 '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E', 9529 '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e', 9530 '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G', 9531 '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g', 9532 '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h', 9533 '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I', 9534 '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i', 9535 '\u0134': 'J', '\u0135': 'j', 9536 '\u0136': 'K', '\u0137': 'k', '\u0138': 'k', 9537 '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L', 9538 '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l', 9539 '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N', 9540 '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n', 9541 '\u014c': 'O', '\u014e': 'O', '\u0150': 'O', 9542 '\u014d': 'o', '\u014f': 'o', '\u0151': 'o', 9543 '\u0154': 'R', '\u0156': 'R', '\u0158': 'R', 9544 '\u0155': 'r', '\u0157': 'r', '\u0159': 'r', 9545 '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S', 9546 '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's', 9547 '\u0162': 'T', '\u0164': 'T', '\u0166': 'T', 9548 '\u0163': 't', '\u0165': 't', '\u0167': 't', 9549 '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U', 9550 '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u', 9551 '\u0174': 'W', '\u0175': 'w', 9552 '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y', 9553 '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z', 9554 '\u017a': 'z', '\u017c': 'z', '\u017e': 'z', 9555 '\u0132': 'IJ', '\u0133': 'ij', 9556 '\u0152': 'Oe', '\u0153': 'oe', 9557 '\u0149': "'n", '\u017f': 's' 9558 }; 9559 9560 /** Used to map characters to HTML entities. */ 9561 var htmlEscapes = { 9562 '&': '&', 9563 '<': '<', 9564 '>': '>', 9565 '"': '"', 9566 "'": ''' 9567 }; 9568 9569 /** Used to map HTML entities to characters. */ 9570 var htmlUnescapes = { 9571 '&': '&', 9572 '<': '<', 9573 '>': '>', 9574 '"': '"', 9575 ''': "'" 9576 }; 9577 9578 /** Used to escape characters for inclusion in compiled string literals. */ 9579 var stringEscapes = { 9580 '\\': '\\', 9581 "'": "'", 9582 '\n': 'n', 9583 '\r': 'r', 9584 '\u2028': 'u2028', 9585 '\u2029': 'u2029' 9586 }; 9587 9588 /** Built-in method references without a dependency on `root`. */ 9589 var freeParseFloat = parseFloat, 9590 freeParseInt = parseInt; 9591 9592 /** Detect free variable `global` from Node.js. */ 9593 var freeGlobal = typeof __webpack_require__.g == 'object' && __webpack_require__.g && __webpack_require__.g.Object === Object && __webpack_require__.g; 9594 9595 /** Detect free variable `self`. */ 9596 var freeSelf = typeof self == 'object' && self && self.Object === Object && self; 9597 9598 /** Used as a reference to the global object. */ 9599 var root = freeGlobal || freeSelf || Function('return this')(); 9600 9601 /** Detect free variable `exports`. */ 9602 var freeExports = true && exports && !exports.nodeType && exports; 9603 9604 /** Detect free variable `module`. */ 9605 var freeModule = freeExports && "object" == 'object' && module && !module.nodeType && module; 9606 9607 /** Detect the popular CommonJS extension `module.exports`. */ 9608 var moduleExports = freeModule && freeModule.exports === freeExports; 9609 9610 /** Detect free variable `process` from Node.js. */ 9611 var freeProcess = moduleExports && freeGlobal.process; 9612 9613 /** Used to access faster Node.js helpers. */ 9614 var nodeUtil = (function() { 9615 try { 9616 // Use `util.types` for Node.js 10+. 9617 var types = freeModule && freeModule.require && freeModule.require('util').types; 9618 9619 if (types) { 9620 return types; 9621 } 9622 9623 // Legacy `process.binding('util')` for Node.js < 10. 9624 return freeProcess && freeProcess.binding && freeProcess.binding('util'); 9625 } catch (e) {} 9626 }()); 9627 9628 /* Node.js helper references. */ 9629 var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer, 9630 nodeIsDate = nodeUtil && nodeUtil.isDate, 9631 nodeIsMap = nodeUtil && nodeUtil.isMap, 9632 nodeIsRegExp = nodeUtil && nodeUtil.isRegExp, 9633 nodeIsSet = nodeUtil && nodeUtil.isSet, 9634 nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; 9635 9636 /*--------------------------------------------------------------------------*/ 9637 9638 /** 9639 * A faster alternative to `Function#apply`, this function invokes `func` 9640 * with the `this` binding of `thisArg` and the arguments of `args`. 9641 * 9642 * @private 9643 * @param {Function} func The function to invoke. 9644 * @param {*} thisArg The `this` binding of `func`. 9645 * @param {Array} args The arguments to invoke `func` with. 9646 * @returns {*} Returns the result of `func`. 9647 */ 9648 function apply(func, thisArg, args) { 9649 switch (args.length) { 9650 case 0: return func.call(thisArg); 9651 case 1: return func.call(thisArg, args[0]); 9652 case 2: return func.call(thisArg, args[0], args[1]); 9653 case 3: return func.call(thisArg, args[0], args[1], args[2]); 9654 } 9655 return func.apply(thisArg, args); 9656 } 9657 9658 /** 9659 * A specialized version of `baseAggregator` for arrays. 9660 * 9661 * @private 9662 * @param {Array} [array] The array to iterate over. 9663 * @param {Function} setter The function to set `accumulator` values. 9664 * @param {Function} iteratee The iteratee to transform keys. 9665 * @param {Object} accumulator The initial aggregated object. 9666 * @returns {Function} Returns `accumulator`. 9667 */ 9668 function arrayAggregator(array, setter, iteratee, accumulator) { 9669 var index = -1, 9670 length = array == null ? 0 : array.length; 9671 9672 while (++index < length) { 9673 var value = array[index]; 9674 setter(accumulator, value, iteratee(value), array); 9675 } 9676 return accumulator; 9677 } 9678 9679 /** 9680 * A specialized version of `_.forEach` for arrays without support for 9681 * iteratee shorthands. 9682 * 9683 * @private 9684 * @param {Array} [array] The array to iterate over. 9685 * @param {Function} iteratee The function invoked per iteration. 9686 * @returns {Array} Returns `array`. 9687 */ 9688 function arrayEach(array, iteratee) { 9689 var index = -1, 9690 length = array == null ? 0 : array.length; 9691 9692 while (++index < length) { 9693 if (iteratee(array[index], index, array) === false) { 9694 break; 9695 } 9696 } 9697 return array; 9698 } 9699 9700 /** 9701 * A specialized version of `_.forEachRight` for arrays without support for 9702 * iteratee shorthands. 9703 * 9704 * @private 9705 * @param {Array} [array] The array to iterate over. 9706 * @param {Function} iteratee The function invoked per iteration. 9707 * @returns {Array} Returns `array`. 9708 */ 9709 function arrayEachRight(array, iteratee) { 9710 var length = array == null ? 0 : array.length; 9711 9712 while (length--) { 9713 if (iteratee(array[length], length, array) === false) { 9714 break; 9715 } 9716 } 9717 return array; 9718 } 9719 9720 /** 9721 * A specialized version of `_.every` for arrays without support for 9722 * iteratee shorthands. 9723 * 9724 * @private 9725 * @param {Array} [array] The array to iterate over. 9726 * @param {Function} predicate The function invoked per iteration. 9727 * @returns {boolean} Returns `true` if all elements pass the predicate check, 9728 * else `false`. 9729 */ 9730 function arrayEvery(array, predicate) { 9731 var index = -1, 9732 length = array == null ? 0 : array.length; 9733 9734 while (++index < length) { 9735 if (!predicate(array[index], index, array)) { 9736 return false; 9737 } 9738 } 9739 return true; 9740 } 9741 9742 /** 9743 * A specialized version of `_.filter` for arrays without support for 9744 * iteratee shorthands. 9745 * 9746 * @private 9747 * @param {Array} [array] The array to iterate over. 9748 * @param {Function} predicate The function invoked per iteration. 9749 * @returns {Array} Returns the new filtered array. 9750 */ 9751 function arrayFilter(array, predicate) { 9752 var index = -1, 9753 length = array == null ? 0 : array.length, 9754 resIndex = 0, 9755 result = []; 9756 9757 while (++index < length) { 9758 var value = array[index]; 9759 if (predicate(value, index, array)) { 9760 result[resIndex++] = value; 9761 } 9762 } 9763 return result; 9764 } 9765 9766 /** 9767 * A specialized version of `_.includes` for arrays without support for 9768 * specifying an index to search from. 9769 * 9770 * @private 9771 * @param {Array} [array] The array to inspect. 9772 * @param {*} target The value to search for. 9773 * @returns {boolean} Returns `true` if `target` is found, else `false`. 9774 */ 9775 function arrayIncludes(array, value) { 9776 var length = array == null ? 0 : array.length; 9777 return !!length && baseIndexOf(array, value, 0) > -1; 9778 } 9779 9780 /** 9781 * This function is like `arrayIncludes` except that it accepts a comparator. 9782 * 9783 * @private 9784 * @param {Array} [array] The array to inspect. 9785 * @param {*} target The value to search for. 9786 * @param {Function} comparator The comparator invoked per element. 9787 * @returns {boolean} Returns `true` if `target` is found, else `false`. 9788 */ 9789 function arrayIncludesWith(array, value, comparator) { 9790 var index = -1, 9791 length = array == null ? 0 : array.length; 9792 9793 while (++index < length) { 9794 if (comparator(value, array[index])) { 9795 return true; 9796 } 9797 } 9798 return false; 9799 } 9800 9801 /** 9802 * A specialized version of `_.map` for arrays without support for iteratee 9803 * shorthands. 9804 * 9805 * @private 9806 * @param {Array} [array] The array to iterate over. 9807 * @param {Function} iteratee The function invoked per iteration. 9808 * @returns {Array} Returns the new mapped array. 9809 */ 9810 function arrayMap(array, iteratee) { 9811 var index = -1, 9812 length = array == null ? 0 : array.length, 9813 result = Array(length); 9814 9815 while (++index < length) { 9816 result[index] = iteratee(array[index], index, array); 9817 } 9818 return result; 9819 } 9820 9821 /** 9822 * Appends the elements of `values` to `array`. 9823 * 9824 * @private 9825 * @param {Array} array The array to modify. 9826 * @param {Array} values The values to append. 9827 * @returns {Array} Returns `array`. 9828 */ 9829 function arrayPush(array, values) { 9830 var index = -1, 9831 length = values.length, 9832 offset = array.length; 9833 9834 while (++index < length) { 9835 array[offset + index] = values[index]; 9836 } 9837 return array; 9838 } 9839 9840 /** 9841 * A specialized version of `_.reduce` for arrays without support for 9842 * iteratee shorthands. 9843 * 9844 * @private 9845 * @param {Array} [array] The array to iterate over. 9846 * @param {Function} iteratee The function invoked per iteration. 9847 * @param {*} [accumulator] The initial value. 9848 * @param {boolean} [initAccum] Specify using the first element of `array` as 9849 * the initial value. 9850 * @returns {*} Returns the accumulated value. 9851 */ 9852 function arrayReduce(array, iteratee, accumulator, initAccum) { 9853 var index = -1, 9854 length = array == null ? 0 : array.length; 9855 9856 if (initAccum && length) { 9857 accumulator = array[++index]; 9858 } 9859 while (++index < length) { 9860 accumulator = iteratee(accumulator, array[index], index, array); 9861 } 9862 return accumulator; 9863 } 9864 9865 /** 9866 * A specialized version of `_.reduceRight` for arrays without support for 9867 * iteratee shorthands. 9868 * 9869 * @private 9870 * @param {Array} [array] The array to iterate over. 9871 * @param {Function} iteratee The function invoked per iteration. 9872 * @param {*} [accumulator] The initial value. 9873 * @param {boolean} [initAccum] Specify using the last element of `array` as 9874 * the initial value. 9875 * @returns {*} Returns the accumulated value. 9876 */ 9877 function arrayReduceRight(array, iteratee, accumulator, initAccum) { 9878 var length = array == null ? 0 : array.length; 9879 if (initAccum && length) { 9880 accumulator = array[--length]; 9881 } 9882 while (length--) { 9883 accumulator = iteratee(accumulator, array[length], length, array); 9884 } 9885 return accumulator; 9886 } 9887 9888 /** 9889 * A specialized version of `_.some` for arrays without support for iteratee 9890 * shorthands. 9891 * 9892 * @private 9893 * @param {Array} [array] The array to iterate over. 9894 * @param {Function} predicate The function invoked per iteration. 9895 * @returns {boolean} Returns `true` if any element passes the predicate check, 9896 * else `false`. 9897 */ 9898 function arraySome(array, predicate) { 9899 var index = -1, 9900 length = array == null ? 0 : array.length; 9901 9902 while (++index < length) { 9903 if (predicate(array[index], index, array)) { 9904 return true; 9905 } 9906 } 9907 return false; 9908 } 9909 9910 /** 9911 * Gets the size of an ASCII `string`. 9912 * 9913 * @private 9914 * @param {string} string The string inspect. 9915 * @returns {number} Returns the string size. 9916 */ 9917 var asciiSize = baseProperty('length'); 9918 9919 /** 9920 * Converts an ASCII `string` to an array. 9921 * 9922 * @private 9923 * @param {string} string The string to convert. 9924 * @returns {Array} Returns the converted array. 9925 */ 9926 function asciiToArray(string) { 9927 return string.split(''); 9928 } 9929 9930 /** 9931 * Splits an ASCII `string` into an array of its words. 9932 * 9933 * @private 9934 * @param {string} The string to inspect. 9935 * @returns {Array} Returns the words of `string`. 9936 */ 9937 function asciiWords(string) { 9938 return string.match(reAsciiWord) || []; 9939 } 9940 9941 /** 9942 * The base implementation of methods like `_.findKey` and `_.findLastKey`, 9943 * without support for iteratee shorthands, which iterates over `collection` 9944 * using `eachFunc`. 9945 * 9946 * @private 9947 * @param {Array|Object} collection The collection to inspect. 9948 * @param {Function} predicate The function invoked per iteration. 9949 * @param {Function} eachFunc The function to iterate over `collection`. 9950 * @returns {*} Returns the found element or its key, else `undefined`. 9951 */ 9952 function baseFindKey(collection, predicate, eachFunc) { 9953 var result; 9954 eachFunc(collection, function(value, key, collection) { 9955 if (predicate(value, key, collection)) { 9956 result = key; 9957 return false; 9958 } 9959 }); 9960 return result; 9961 } 9962 9963 /** 9964 * The base implementation of `_.findIndex` and `_.findLastIndex` without 9965 * support for iteratee shorthands. 9966 * 9967 * @private 9968 * @param {Array} array The array to inspect. 9969 * @param {Function} predicate The function invoked per iteration. 9970 * @param {number} fromIndex The index to search from. 9971 * @param {boolean} [fromRight] Specify iterating from right to left. 9972 * @returns {number} Returns the index of the matched value, else `-1`. 9973 */ 9974 function baseFindIndex(array, predicate, fromIndex, fromRight) { 9975 var length = array.length, 9976 index = fromIndex + (fromRight ? 1 : -1); 9977 9978 while ((fromRight ? index-- : ++index < length)) { 9979 if (predicate(array[index], index, array)) { 9980 return index; 9981 } 9982 } 9983 return -1; 9984 } 9985 9986 /** 9987 * The base implementation of `_.indexOf` without `fromIndex` bounds checks. 9988 * 9989 * @private 9990 * @param {Array} array The array to inspect. 9991 * @param {*} value The value to search for. 9992 * @param {number} fromIndex The index to search from. 9993 * @returns {number} Returns the index of the matched value, else `-1`. 9994 */ 9995 function baseIndexOf(array, value, fromIndex) { 9996 return value === value 9997 ? strictIndexOf(array, value, fromIndex) 9998 : baseFindIndex(array, baseIsNaN, fromIndex); 9999 } 10000 10001 /** 10002 * This function is like `baseIndexOf` except that it accepts a comparator. 10003 * 10004 * @private 10005 * @param {Array} array The array to inspect. 10006 * @param {*} value The value to search for. 10007 * @param {number} fromIndex The index to search from. 10008 * @param {Function} comparator The comparator invoked per element. 10009 * @returns {number} Returns the index of the matched value, else `-1`. 10010 */ 10011 function baseIndexOfWith(array, value, fromIndex, comparator) { 10012 var index = fromIndex - 1, 10013 length = array.length; 10014 10015 while (++index < length) { 10016 if (comparator(array[index], value)) { 10017 return index; 10018 } 10019 } 10020 return -1; 10021 } 10022 10023 /** 10024 * The base implementation of `_.isNaN` without support for number objects. 10025 * 10026 * @private 10027 * @param {*} value The value to check. 10028 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. 10029 */ 10030 function baseIsNaN(value) { 10031 return value !== value; 10032 } 10033 10034 /** 10035 * The base implementation of `_.mean` and `_.meanBy` without support for 10036 * iteratee shorthands. 10037 * 10038 * @private 10039 * @param {Array} array The array to iterate over. 10040 * @param {Function} iteratee The function invoked per iteration. 10041 * @returns {number} Returns the mean. 10042 */ 10043 function baseMean(array, iteratee) { 10044 var length = array == null ? 0 : array.length; 10045 return length ? (baseSum(array, iteratee) / length) : NAN; 10046 } 10047 10048 /** 10049 * The base implementation of `_.property` without support for deep paths. 10050 * 10051 * @private 10052 * @param {string} key The key of the property to get. 10053 * @returns {Function} Returns the new accessor function. 10054 */ 10055 function baseProperty(key) { 10056 return function(object) { 10057 return object == null ? undefined : object[key]; 10058 }; 10059 } 10060 10061 /** 10062 * The base implementation of `_.propertyOf` without support for deep paths. 10063 * 10064 * @private 10065 * @param {Object} object The object to query. 10066 * @returns {Function} Returns the new accessor function. 10067 */ 10068 function basePropertyOf(object) { 10069 return function(key) { 10070 return object == null ? undefined : object[key]; 10071 }; 10072 } 10073 10074 /** 10075 * The base implementation of `_.reduce` and `_.reduceRight`, without support 10076 * for iteratee shorthands, which iterates over `collection` using `eachFunc`. 10077 * 10078 * @private 10079 * @param {Array|Object} collection The collection to iterate over. 10080 * @param {Function} iteratee The function invoked per iteration. 10081 * @param {*} accumulator The initial value. 10082 * @param {boolean} initAccum Specify using the first or last element of 10083 * `collection` as the initial value. 10084 * @param {Function} eachFunc The function to iterate over `collection`. 10085 * @returns {*} Returns the accumulated value. 10086 */ 10087 function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) { 10088 eachFunc(collection, function(value, index, collection) { 10089 accumulator = initAccum 10090 ? (initAccum = false, value) 10091 : iteratee(accumulator, value, index, collection); 10092 }); 10093 return accumulator; 10094 } 10095 10096 /** 10097 * The base implementation of `_.sortBy` which uses `comparer` to define the 10098 * sort order of `array` and replaces criteria objects with their corresponding 10099 * values. 10100 * 10101 * @private 10102 * @param {Array} array The array to sort. 10103 * @param {Function} comparer The function to define sort order. 10104 * @returns {Array} Returns `array`. 10105 */ 10106 function baseSortBy(array, comparer) { 10107 var length = array.length; 10108 10109 array.sort(comparer); 10110 while (length--) { 10111 array[length] = array[length].value; 10112 } 10113 return array; 10114 } 10115 10116 /** 10117 * The base implementation of `_.sum` and `_.sumBy` without support for 10118 * iteratee shorthands. 10119 * 10120 * @private 10121 * @param {Array} array The array to iterate over. 10122 * @param {Function} iteratee The function invoked per iteration. 10123 * @returns {number} Returns the sum. 10124 */ 10125 function baseSum(array, iteratee) { 10126 var result, 10127 index = -1, 10128 length = array.length; 10129 10130 while (++index < length) { 10131 var current = iteratee(array[index]); 10132 if (current !== undefined) { 10133 result = result === undefined ? current : (result + current); 10134 } 10135 } 10136 return result; 10137 } 10138 10139 /** 10140 * The base implementation of `_.times` without support for iteratee shorthands 10141 * or max array length checks. 10142 * 10143 * @private 10144 * @param {number} n The number of times to invoke `iteratee`. 10145 * @param {Function} iteratee The function invoked per iteration. 10146 * @returns {Array} Returns the array of results. 10147 */ 10148 function baseTimes(n, iteratee) { 10149 var index = -1, 10150 result = Array(n); 10151 10152 while (++index < n) { 10153 result[index] = iteratee(index); 10154 } 10155 return result; 10156 } 10157 10158 /** 10159 * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array 10160 * of key-value pairs for `object` corresponding to the property names of `props`. 10161 * 10162 * @private 10163 * @param {Object} object The object to query. 10164 * @param {Array} props The property names to get values for. 10165 * @returns {Object} Returns the key-value pairs. 10166 */ 10167 function baseToPairs(object, props) { 10168 return arrayMap(props, function(key) { 10169 return [key, object[key]]; 10170 }); 10171 } 10172 10173 /** 10174 * The base implementation of `_.trim`. 10175 * 10176 * @private 10177 * @param {string} string The string to trim. 10178 * @returns {string} Returns the trimmed string. 10179 */ 10180 function baseTrim(string) { 10181 return string 10182 ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '') 10183 : string; 10184 } 10185 10186 /** 10187 * The base implementation of `_.unary` without support for storing metadata. 10188 * 10189 * @private 10190 * @param {Function} func The function to cap arguments for. 10191 * @returns {Function} Returns the new capped function. 10192 */ 10193 function baseUnary(func) { 10194 return function(value) { 10195 return func(value); 10196 }; 10197 } 10198 10199 /** 10200 * The base implementation of `_.values` and `_.valuesIn` which creates an 10201 * array of `object` property values corresponding to the property names 10202 * of `props`. 10203 * 10204 * @private 10205 * @param {Object} object The object to query. 10206 * @param {Array} props The property names to get values for. 10207 * @returns {Object} Returns the array of property values. 10208 */ 10209 function baseValues(object, props) { 10210 return arrayMap(props, function(key) { 10211 return object[key]; 10212 }); 10213 } 10214 10215 /** 10216 * Checks if a `cache` value for `key` exists. 10217 * 10218 * @private 10219 * @param {Object} cache The cache to query. 10220 * @param {string} key The key of the entry to check. 10221 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 10222 */ 10223 function cacheHas(cache, key) { 10224 return cache.has(key); 10225 } 10226 10227 /** 10228 * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol 10229 * that is not found in the character symbols. 10230 * 10231 * @private 10232 * @param {Array} strSymbols The string symbols to inspect. 10233 * @param {Array} chrSymbols The character symbols to find. 10234 * @returns {number} Returns the index of the first unmatched string symbol. 10235 */ 10236 function charsStartIndex(strSymbols, chrSymbols) { 10237 var index = -1, 10238 length = strSymbols.length; 10239 10240 while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} 10241 return index; 10242 } 10243 10244 /** 10245 * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol 10246 * that is not found in the character symbols. 10247 * 10248 * @private 10249 * @param {Array} strSymbols The string symbols to inspect. 10250 * @param {Array} chrSymbols The character symbols to find. 10251 * @returns {number} Returns the index of the last unmatched string symbol. 10252 */ 10253 function charsEndIndex(strSymbols, chrSymbols) { 10254 var index = strSymbols.length; 10255 10256 while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} 10257 return index; 10258 } 10259 10260 /** 10261 * Gets the number of `placeholder` occurrences in `array`. 10262 * 10263 * @private 10264 * @param {Array} array The array to inspect. 10265 * @param {*} placeholder The placeholder to search for. 10266 * @returns {number} Returns the placeholder count. 10267 */ 10268 function countHolders(array, placeholder) { 10269 var length = array.length, 10270 result = 0; 10271 10272 while (length--) { 10273 if (array[length] === placeholder) { 10274 ++result; 10275 } 10276 } 10277 return result; 10278 } 10279 10280 /** 10281 * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A 10282 * letters to basic Latin letters. 10283 * 10284 * @private 10285 * @param {string} letter The matched letter to deburr. 10286 * @returns {string} Returns the deburred letter. 10287 */ 10288 var deburrLetter = basePropertyOf(deburredLetters); 10289 10290 /** 10291 * Used by `_.escape` to convert characters to HTML entities. 10292 * 10293 * @private 10294 * @param {string} chr The matched character to escape. 10295 * @returns {string} Returns the escaped character. 10296 */ 10297 var escapeHtmlChar = basePropertyOf(htmlEscapes); 10298 10299 /** 10300 * Used by `_.template` to escape characters for inclusion in compiled string literals. 10301 * 10302 * @private 10303 * @param {string} chr The matched character to escape. 10304 * @returns {string} Returns the escaped character. 10305 */ 10306 function escapeStringChar(chr) { 10307 return '\\' + stringEscapes[chr]; 10308 } 10309 10310 /** 10311 * Gets the value at `key` of `object`. 10312 * 10313 * @private 10314 * @param {Object} [object] The object to query. 10315 * @param {string} key The key of the property to get. 10316 * @returns {*} Returns the property value. 10317 */ 10318 function getValue(object, key) { 10319 return object == null ? undefined : object[key]; 10320 } 10321 10322 /** 10323 * Checks if `string` contains Unicode symbols. 10324 * 10325 * @private 10326 * @param {string} string The string to inspect. 10327 * @returns {boolean} Returns `true` if a symbol is found, else `false`. 10328 */ 10329 function hasUnicode(string) { 10330 return reHasUnicode.test(string); 10331 } 10332 10333 /** 10334 * Checks if `string` contains a word composed of Unicode symbols. 10335 * 10336 * @private 10337 * @param {string} string The string to inspect. 10338 * @returns {boolean} Returns `true` if a word is found, else `false`. 10339 */ 10340 function hasUnicodeWord(string) { 10341 return reHasUnicodeWord.test(string); 10342 } 10343 10344 /** 10345 * Converts `iterator` to an array. 10346 * 10347 * @private 10348 * @param {Object} iterator The iterator to convert. 10349 * @returns {Array} Returns the converted array. 10350 */ 10351 function iteratorToArray(iterator) { 10352 var data, 10353 result = []; 10354 10355 while (!(data = iterator.next()).done) { 10356 result.push(data.value); 10357 } 10358 return result; 10359 } 10360 10361 /** 10362 * Converts `map` to its key-value pairs. 10363 * 10364 * @private 10365 * @param {Object} map The map to convert. 10366 * @returns {Array} Returns the key-value pairs. 10367 */ 10368 function mapToArray(map) { 10369 var index = -1, 10370 result = Array(map.size); 10371 10372 map.forEach(function(value, key) { 10373 result[++index] = [key, value]; 10374 }); 10375 return result; 10376 } 10377 10378 /** 10379 * Creates a unary function that invokes `func` with its argument transformed. 10380 * 10381 * @private 10382 * @param {Function} func The function to wrap. 10383 * @param {Function} transform The argument transform. 10384 * @returns {Function} Returns the new function. 10385 */ 10386 function overArg(func, transform) { 10387 return function(arg) { 10388 return func(transform(arg)); 10389 }; 10390 } 10391 10392 /** 10393 * Replaces all `placeholder` elements in `array` with an internal placeholder 10394 * and returns an array of their indexes. 10395 * 10396 * @private 10397 * @param {Array} array The array to modify. 10398 * @param {*} placeholder The placeholder to replace. 10399 * @returns {Array} Returns the new array of placeholder indexes. 10400 */ 10401 function replaceHolders(array, placeholder) { 10402 var index = -1, 10403 length = array.length, 10404 resIndex = 0, 10405 result = []; 10406 10407 while (++index < length) { 10408 var value = array[index]; 10409 if (value === placeholder || value === PLACEHOLDER) { 10410 array[index] = PLACEHOLDER; 10411 result[resIndex++] = index; 10412 } 10413 } 10414 return result; 10415 } 10416 10417 /** 10418 * Converts `set` to an array of its values. 10419 * 10420 * @private 10421 * @param {Object} set The set to convert. 10422 * @returns {Array} Returns the values. 10423 */ 10424 function setToArray(set) { 10425 var index = -1, 10426 result = Array(set.size); 10427 10428 set.forEach(function(value) { 10429 result[++index] = value; 10430 }); 10431 return result; 10432 } 10433 10434 /** 10435 * Converts `set` to its value-value pairs. 10436 * 10437 * @private 10438 * @param {Object} set The set to convert. 10439 * @returns {Array} Returns the value-value pairs. 10440 */ 10441 function setToPairs(set) { 10442 var index = -1, 10443 result = Array(set.size); 10444 10445 set.forEach(function(value) { 10446 result[++index] = [value, value]; 10447 }); 10448 return result; 10449 } 10450 10451 /** 10452 * A specialized version of `_.indexOf` which performs strict equality 10453 * comparisons of values, i.e. `===`. 10454 * 10455 * @private 10456 * @param {Array} array The array to inspect. 10457 * @param {*} value The value to search for. 10458 * @param {number} fromIndex The index to search from. 10459 * @returns {number} Returns the index of the matched value, else `-1`. 10460 */ 10461 function strictIndexOf(array, value, fromIndex) { 10462 var index = fromIndex - 1, 10463 length = array.length; 10464 10465 while (++index < length) { 10466 if (array[index] === value) { 10467 return index; 10468 } 10469 } 10470 return -1; 10471 } 10472 10473 /** 10474 * A specialized version of `_.lastIndexOf` which performs strict equality 10475 * comparisons of values, i.e. `===`. 10476 * 10477 * @private 10478 * @param {Array} array The array to inspect. 10479 * @param {*} value The value to search for. 10480 * @param {number} fromIndex The index to search from. 10481 * @returns {number} Returns the index of the matched value, else `-1`. 10482 */ 10483 function strictLastIndexOf(array, value, fromIndex) { 10484 var index = fromIndex + 1; 10485 while (index--) { 10486 if (array[index] === value) { 10487 return index; 10488 } 10489 } 10490 return index; 10491 } 10492 10493 /** 10494 * Gets the number of symbols in `string`. 10495 * 10496 * @private 10497 * @param {string} string The string to inspect. 10498 * @returns {number} Returns the string size. 10499 */ 10500 function stringSize(string) { 10501 return hasUnicode(string) 10502 ? unicodeSize(string) 10503 : asciiSize(string); 10504 } 10505 10506 /** 10507 * Converts `string` to an array. 10508 * 10509 * @private 10510 * @param {string} string The string to convert. 10511 * @returns {Array} Returns the converted array. 10512 */ 10513 function stringToArray(string) { 10514 return hasUnicode(string) 10515 ? unicodeToArray(string) 10516 : asciiToArray(string); 10517 } 10518 10519 /** 10520 * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace 10521 * character of `string`. 10522 * 10523 * @private 10524 * @param {string} string The string to inspect. 10525 * @returns {number} Returns the index of the last non-whitespace character. 10526 */ 10527 function trimmedEndIndex(string) { 10528 var index = string.length; 10529 10530 while (index-- && reWhitespace.test(string.charAt(index))) {} 10531 return index; 10532 } 10533 10534 /** 10535 * Used by `_.unescape` to convert HTML entities to characters. 10536 * 10537 * @private 10538 * @param {string} chr The matched character to unescape. 10539 * @returns {string} Returns the unescaped character. 10540 */ 10541 var unescapeHtmlChar = basePropertyOf(htmlUnescapes); 10542 10543 /** 10544 * Gets the size of a Unicode `string`. 10545 * 10546 * @private 10547 * @param {string} string The string inspect. 10548 * @returns {number} Returns the string size. 10549 */ 10550 function unicodeSize(string) { 10551 var result = reUnicode.lastIndex = 0; 10552 while (reUnicode.test(string)) { 10553 ++result; 10554 } 10555 return result; 10556 } 10557 10558 /** 10559 * Converts a Unicode `string` to an array. 10560 * 10561 * @private 10562 * @param {string} string The string to convert. 10563 * @returns {Array} Returns the converted array. 10564 */ 10565 function unicodeToArray(string) { 10566 return string.match(reUnicode) || []; 10567 } 10568 10569 /** 10570 * Splits a Unicode `string` into an array of its words. 10571 * 10572 * @private 10573 * @param {string} The string to inspect. 10574 * @returns {Array} Returns the words of `string`. 10575 */ 10576 function unicodeWords(string) { 10577 return string.match(reUnicodeWord) || []; 10578 } 10579 10580 /*--------------------------------------------------------------------------*/ 10581 10582 /** 10583 * Create a new pristine `lodash` function using the `context` object. 10584 * 10585 * @static 10586 * @memberOf _ 10587 * @since 1.1.0 10588 * @category Util 10589 * @param {Object} [context=root] The context object. 10590 * @returns {Function} Returns a new `lodash` function. 10591 * @example 10592 * 10593 * _.mixin({ 'foo': _.constant('foo') }); 10594 * 10595 * var lodash = _.runInContext(); 10596 * lodash.mixin({ 'bar': lodash.constant('bar') }); 10597 * 10598 * _.isFunction(_.foo); 10599 * // => true 10600 * _.isFunction(_.bar); 10601 * // => false 10602 * 10603 * lodash.isFunction(lodash.foo); 10604 * // => false 10605 * lodash.isFunction(lodash.bar); 10606 * // => true 10607 * 10608 * // Create a suped-up `defer` in Node.js. 10609 * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer; 10610 */ 10611 var runInContext = (function runInContext(context) { 10612 context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps)); 10613 10614 /** Built-in constructor references. */ 10615 var Array = context.Array, 10616 Date = context.Date, 10617 Error = context.Error, 10618 Function = context.Function, 10619 Math = context.Math, 10620 Object = context.Object, 10621 RegExp = context.RegExp, 10622 String = context.String, 10623 TypeError = context.TypeError; 10624 10625 /** Used for built-in method references. */ 10626 var arrayProto = Array.prototype, 10627 funcProto = Function.prototype, 10628 objectProto = Object.prototype; 10629 10630 /** Used to detect overreaching core-js shims. */ 10631 var coreJsData = context['__core-js_shared__']; 10632 10633 /** Used to resolve the decompiled source of functions. */ 10634 var funcToString = funcProto.toString; 10635 10636 /** Used to check objects for own properties. */ 10637 var hasOwnProperty = objectProto.hasOwnProperty; 10638 10639 /** Used to generate unique IDs. */ 10640 var idCounter = 0; 10641 10642 /** Used to detect methods masquerading as native. */ 10643 var maskSrcKey = (function() { 10644 var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); 10645 return uid ? ('Symbol(src)_1.' + uid) : ''; 10646 }()); 10647 10648 /** 10649 * Used to resolve the 10650 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) 10651 * of values. 10652 */ 10653 var nativeObjectToString = objectProto.toString; 10654 10655 /** Used to infer the `Object` constructor. */ 10656 var objectCtorString = funcToString.call(Object); 10657 10658 /** Used to restore the original `_` reference in `_.noConflict`. */ 10659 var oldDash = root._; 10660 10661 /** Used to detect if a method is native. */ 10662 var reIsNative = RegExp('^' + 10663 funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') 10664 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' 10665 ); 10666 10667 /** Built-in value references. */ 10668 var Buffer = moduleExports ? context.Buffer : undefined, 10669 Symbol = context.Symbol, 10670 Uint8Array = context.Uint8Array, 10671 allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined, 10672 getPrototype = overArg(Object.getPrototypeOf, Object), 10673 objectCreate = Object.create, 10674 propertyIsEnumerable = objectProto.propertyIsEnumerable, 10675 splice = arrayProto.splice, 10676 spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined, 10677 symIterator = Symbol ? Symbol.iterator : undefined, 10678 symToStringTag = Symbol ? Symbol.toStringTag : undefined; 10679 10680 var defineProperty = (function() { 10681 try { 10682 var func = getNative(Object, 'defineProperty'); 10683 func({}, '', {}); 10684 return func; 10685 } catch (e) {} 10686 }()); 10687 10688 /** Mocked built-ins. */ 10689 var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout, 10690 ctxNow = Date && Date.now !== root.Date.now && Date.now, 10691 ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout; 10692 10693 /* Built-in method references for those with the same name as other `lodash` methods. */ 10694 var nativeCeil = Math.ceil, 10695 nativeFloor = Math.floor, 10696 nativeGetSymbols = Object.getOwnPropertySymbols, 10697 nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined, 10698 nativeIsFinite = context.isFinite, 10699 nativeJoin = arrayProto.join, 10700 nativeKeys = overArg(Object.keys, Object), 10701 nativeMax = Math.max, 10702 nativeMin = Math.min, 10703 nativeNow = Date.now, 10704 nativeParseInt = context.parseInt, 10705 nativeRandom = Math.random, 10706 nativeReverse = arrayProto.reverse; 10707 10708 /* Built-in method references that are verified to be native. */ 10709 var DataView = getNative(context, 'DataView'), 10710 Map = getNative(context, 'Map'), 10711 Promise = getNative(context, 'Promise'), 10712 Set = getNative(context, 'Set'), 10713 WeakMap = getNative(context, 'WeakMap'), 10714 nativeCreate = getNative(Object, 'create'); 10715 10716 /** Used to store function metadata. */ 10717 var metaMap = WeakMap && new WeakMap; 10718 10719 /** Used to lookup unminified function names. */ 10720 var realNames = {}; 10721 10722 /** Used to detect maps, sets, and weakmaps. */ 10723 var dataViewCtorString = toSource(DataView), 10724 mapCtorString = toSource(Map), 10725 promiseCtorString = toSource(Promise), 10726 setCtorString = toSource(Set), 10727 weakMapCtorString = toSource(WeakMap); 10728 10729 /** Used to convert symbols to primitives and strings. */ 10730 var symbolProto = Symbol ? Symbol.prototype : undefined, 10731 symbolValueOf = symbolProto ? symbolProto.valueOf : undefined, 10732 symbolToString = symbolProto ? symbolProto.toString : undefined; 10733 10734 /*------------------------------------------------------------------------*/ 10735 10736 /** 10737 * Creates a `lodash` object which wraps `value` to enable implicit method 10738 * chain sequences. Methods that operate on and return arrays, collections, 10739 * and functions can be chained together. Methods that retrieve a single value 10740 * or may return a primitive value will automatically end the chain sequence 10741 * and return the unwrapped value. Otherwise, the value must be unwrapped 10742 * with `_#value`. 10743 * 10744 * Explicit chain sequences, which must be unwrapped with `_#value`, may be 10745 * enabled using `_.chain`. 10746 * 10747 * The execution of chained methods is lazy, that is, it's deferred until 10748 * `_#value` is implicitly or explicitly called. 10749 * 10750 * Lazy evaluation allows several methods to support shortcut fusion. 10751 * Shortcut fusion is an optimization to merge iteratee calls; this avoids 10752 * the creation of intermediate arrays and can greatly reduce the number of 10753 * iteratee executions. Sections of a chain sequence qualify for shortcut 10754 * fusion if the section is applied to an array and iteratees accept only 10755 * one argument. The heuristic for whether a section qualifies for shortcut 10756 * fusion is subject to change. 10757 * 10758 * Chaining is supported in custom builds as long as the `_#value` method is 10759 * directly or indirectly included in the build. 10760 * 10761 * In addition to lodash methods, wrappers have `Array` and `String` methods. 10762 * 10763 * The wrapper `Array` methods are: 10764 * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift` 10765 * 10766 * The wrapper `String` methods are: 10767 * `replace` and `split` 10768 * 10769 * The wrapper methods that support shortcut fusion are: 10770 * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`, 10771 * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`, 10772 * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray` 10773 * 10774 * The chainable wrapper methods are: 10775 * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`, 10776 * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`, 10777 * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, 10778 * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, 10779 * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`, 10780 * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`, 10781 * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`, 10782 * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`, 10783 * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`, 10784 * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`, 10785 * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`, 10786 * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`, 10787 * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`, 10788 * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`, 10789 * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`, 10790 * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`, 10791 * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`, 10792 * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`, 10793 * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`, 10794 * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`, 10795 * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`, 10796 * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`, 10797 * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, 10798 * `zipObject`, `zipObjectDeep`, and `zipWith` 10799 * 10800 * The wrapper methods that are **not** chainable by default are: 10801 * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`, 10802 * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`, 10803 * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`, 10804 * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`, 10805 * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`, 10806 * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`, 10807 * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`, 10808 * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`, 10809 * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`, 10810 * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`, 10811 * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, 10812 * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, 10813 * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`, 10814 * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`, 10815 * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`, 10816 * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`, 10817 * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, 10818 * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`, 10819 * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`, 10820 * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`, 10821 * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`, 10822 * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`, 10823 * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`, 10824 * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`, 10825 * `upperFirst`, `value`, and `words` 10826 * 10827 * @name _ 10828 * @constructor 10829 * @category Seq 10830 * @param {*} value The value to wrap in a `lodash` instance. 10831 * @returns {Object} Returns the new `lodash` wrapper instance. 10832 * @example 10833 * 10834 * function square(n) { 10835 * return n * n; 10836 * } 10837 * 10838 * var wrapped = _([1, 2, 3]); 10839 * 10840 * // Returns an unwrapped value. 10841 * wrapped.reduce(_.add); 10842 * // => 6 10843 * 10844 * // Returns a wrapped value. 10845 * var squares = wrapped.map(square); 10846 * 10847 * _.isArray(squares); 10848 * // => false 10849 * 10850 * _.isArray(squares.value()); 10851 * // => true 10852 */ 10853 function lodash(value) { 10854 if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) { 10855 if (value instanceof LodashWrapper) { 10856 return value; 10857 } 10858 if (hasOwnProperty.call(value, '__wrapped__')) { 10859 return wrapperClone(value); 10860 } 10861 } 10862 return new LodashWrapper(value); 10863 } 10864 10865 /** 10866 * The base implementation of `_.create` without support for assigning 10867 * properties to the created object. 10868 * 10869 * @private 10870 * @param {Object} proto The object to inherit from. 10871 * @returns {Object} Returns the new object. 10872 */ 10873 var baseCreate = (function() { 10874 function object() {} 10875 return function(proto) { 10876 if (!isObject(proto)) { 10877 return {}; 10878 } 10879 if (objectCreate) { 10880 return objectCreate(proto); 10881 } 10882 object.prototype = proto; 10883 var result = new object; 10884 object.prototype = undefined; 10885 return result; 10886 }; 10887 }()); 10888 10889 /** 10890 * The function whose prototype chain sequence wrappers inherit from. 10891 * 10892 * @private 10893 */ 10894 function baseLodash() { 10895 // No operation performed. 10896 } 10897 10898 /** 10899 * The base constructor for creating `lodash` wrapper objects. 10900 * 10901 * @private 10902 * @param {*} value The value to wrap. 10903 * @param {boolean} [chainAll] Enable explicit method chain sequences. 10904 */ 10905 function LodashWrapper(value, chainAll) { 10906 this.__wrapped__ = value; 10907 this.__actions__ = []; 10908 this.__chain__ = !!chainAll; 10909 this.__index__ = 0; 10910 this.__values__ = undefined; 10911 } 10912 10913 /** 10914 * By default, the template delimiters used by lodash are like those in 10915 * embedded Ruby (ERB) as well as ES2015 template strings. Change the 10916 * following template settings to use alternative delimiters. 10917 * 10918 * @static 10919 * @memberOf _ 10920 * @type {Object} 10921 */ 10922 lodash.templateSettings = { 10923 10924 /** 10925 * Used to detect `data` property values to be HTML-escaped. 10926 * 10927 * @memberOf _.templateSettings 10928 * @type {RegExp} 10929 */ 10930 'escape': reEscape, 10931 10932 /** 10933 * Used to detect code to be evaluated. 10934 * 10935 * @memberOf _.templateSettings 10936 * @type {RegExp} 10937 */ 10938 'evaluate': reEvaluate, 10939 10940 /** 10941 * Used to detect `data` property values to inject. 10942 * 10943 * @memberOf _.templateSettings 10944 * @type {RegExp} 10945 */ 10946 'interpolate': reInterpolate, 10947 10948 /** 10949 * Used to reference the data object in the template text. 10950 * 10951 * @memberOf _.templateSettings 10952 * @type {string} 10953 */ 10954 'variable': '', 10955 10956 /** 10957 * Used to import variables into the compiled template. 10958 * 10959 * @memberOf _.templateSettings 10960 * @type {Object} 10961 */ 10962 'imports': { 10963 10964 /** 10965 * A reference to the `lodash` function. 10966 * 10967 * @memberOf _.templateSettings.imports 10968 * @type {Function} 10969 */ 10970 '_': lodash 10971 } 10972 }; 10973 10974 // Ensure wrappers are instances of `baseLodash`. 10975 lodash.prototype = baseLodash.prototype; 10976 lodash.prototype.constructor = lodash; 10977 10978 LodashWrapper.prototype = baseCreate(baseLodash.prototype); 10979 LodashWrapper.prototype.constructor = LodashWrapper; 10980 10981 /*------------------------------------------------------------------------*/ 10982 10983 /** 10984 * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation. 10985 * 10986 * @private 10987 * @constructor 10988 * @param {*} value The value to wrap. 10989 */ 10990 function LazyWrapper(value) { 10991 this.__wrapped__ = value; 10992 this.__actions__ = []; 10993 this.__dir__ = 1; 10994 this.__filtered__ = false; 10995 this.__iteratees__ = []; 10996 this.__takeCount__ = MAX_ARRAY_LENGTH; 10997 this.__views__ = []; 10998 } 10999 11000 /** 11001 * Creates a clone of the lazy wrapper object. 11002 * 11003 * @private 11004 * @name clone 11005 * @memberOf LazyWrapper 11006 * @returns {Object} Returns the cloned `LazyWrapper` object. 11007 */ 11008 function lazyClone() { 11009 var result = new LazyWrapper(this.__wrapped__); 11010 result.__actions__ = copyArray(this.__actions__); 11011 result.__dir__ = this.__dir__; 11012 result.__filtered__ = this.__filtered__; 11013 result.__iteratees__ = copyArray(this.__iteratees__); 11014 result.__takeCount__ = this.__takeCount__; 11015 result.__views__ = copyArray(this.__views__); 11016 return result; 11017 } 11018 11019 /** 11020 * Reverses the direction of lazy iteration. 11021 * 11022 * @private 11023 * @name reverse 11024 * @memberOf LazyWrapper 11025 * @returns {Object} Returns the new reversed `LazyWrapper` object. 11026 */ 11027 function lazyReverse() { 11028 if (this.__filtered__) { 11029 var result = new LazyWrapper(this); 11030 result.__dir__ = -1; 11031 result.__filtered__ = true; 11032 } else { 11033 result = this.clone(); 11034 result.__dir__ *= -1; 11035 } 11036 return result; 11037 } 11038 11039 /** 11040 * Extracts the unwrapped value from its lazy wrapper. 11041 * 11042 * @private 11043 * @name value 11044 * @memberOf LazyWrapper 11045 * @returns {*} Returns the unwrapped value. 11046 */ 11047 function lazyValue() { 11048 var array = this.__wrapped__.value(), 11049 dir = this.__dir__, 11050 isArr = isArray(array), 11051 isRight = dir < 0, 11052 arrLength = isArr ? array.length : 0, 11053 view = getView(0, arrLength, this.__views__), 11054 start = view.start, 11055 end = view.end, 11056 length = end - start, 11057 index = isRight ? end : (start - 1), 11058 iteratees = this.__iteratees__, 11059 iterLength = iteratees.length, 11060 resIndex = 0, 11061 takeCount = nativeMin(length, this.__takeCount__); 11062 11063 if (!isArr || (!isRight && arrLength == length && takeCount == length)) { 11064 return baseWrapperValue(array, this.__actions__); 11065 } 11066 var result = []; 11067 11068 outer: 11069 while (length-- && resIndex < takeCount) { 11070 index += dir; 11071 11072 var iterIndex = -1, 11073 value = array[index]; 11074 11075 while (++iterIndex < iterLength) { 11076 var data = iteratees[iterIndex], 11077 iteratee = data.iteratee, 11078 type = data.type, 11079 computed = iteratee(value); 11080 11081 if (type == LAZY_MAP_FLAG) { 11082 value = computed; 11083 } else if (!computed) { 11084 if (type == LAZY_FILTER_FLAG) { 11085 continue outer; 11086 } else { 11087 break outer; 11088 } 11089 } 11090 } 11091 result[resIndex++] = value; 11092 } 11093 return result; 11094 } 11095 11096 // Ensure `LazyWrapper` is an instance of `baseLodash`. 11097 LazyWrapper.prototype = baseCreate(baseLodash.prototype); 11098 LazyWrapper.prototype.constructor = LazyWrapper; 11099 11100 /*------------------------------------------------------------------------*/ 11101 11102 /** 11103 * Creates a hash object. 11104 * 11105 * @private 11106 * @constructor 11107 * @param {Array} [entries] The key-value pairs to cache. 11108 */ 11109 function Hash(entries) { 11110 var index = -1, 11111 length = entries == null ? 0 : entries.length; 11112 11113 this.clear(); 11114 while (++index < length) { 11115 var entry = entries[index]; 11116 this.set(entry[0], entry[1]); 11117 } 11118 } 11119 11120 /** 11121 * Removes all key-value entries from the hash. 11122 * 11123 * @private 11124 * @name clear 11125 * @memberOf Hash 11126 */ 11127 function hashClear() { 11128 this.__data__ = nativeCreate ? nativeCreate(null) : {}; 11129 this.size = 0; 11130 } 11131 11132 /** 11133 * Removes `key` and its value from the hash. 11134 * 11135 * @private 11136 * @name delete 11137 * @memberOf Hash 11138 * @param {Object} hash The hash to modify. 11139 * @param {string} key The key of the value to remove. 11140 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 11141 */ 11142 function hashDelete(key) { 11143 var result = this.has(key) && delete this.__data__[key]; 11144 this.size -= result ? 1 : 0; 11145 return result; 11146 } 11147 11148 /** 11149 * Gets the hash value for `key`. 11150 * 11151 * @private 11152 * @name get 11153 * @memberOf Hash 11154 * @param {string} key The key of the value to get. 11155 * @returns {*} Returns the entry value. 11156 */ 11157 function hashGet(key) { 11158 var data = this.__data__; 11159 if (nativeCreate) { 11160 var result = data[key]; 11161 return result === HASH_UNDEFINED ? undefined : result; 11162 } 11163 return hasOwnProperty.call(data, key) ? data[key] : undefined; 11164 } 11165 11166 /** 11167 * Checks if a hash value for `key` exists. 11168 * 11169 * @private 11170 * @name has 11171 * @memberOf Hash 11172 * @param {string} key The key of the entry to check. 11173 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 11174 */ 11175 function hashHas(key) { 11176 var data = this.__data__; 11177 return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key); 11178 } 11179 11180 /** 11181 * Sets the hash `key` to `value`. 11182 * 11183 * @private 11184 * @name set 11185 * @memberOf Hash 11186 * @param {string} key The key of the value to set. 11187 * @param {*} value The value to set. 11188 * @returns {Object} Returns the hash instance. 11189 */ 11190 function hashSet(key, value) { 11191 var data = this.__data__; 11192 this.size += this.has(key) ? 0 : 1; 11193 data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; 11194 return this; 11195 } 11196 11197 // Add methods to `Hash`. 11198 Hash.prototype.clear = hashClear; 11199 Hash.prototype['delete'] = hashDelete; 11200 Hash.prototype.get = hashGet; 11201 Hash.prototype.has = hashHas; 11202 Hash.prototype.set = hashSet; 11203 11204 /*------------------------------------------------------------------------*/ 11205 11206 /** 11207 * Creates an list cache object. 11208 * 11209 * @private 11210 * @constructor 11211 * @param {Array} [entries] The key-value pairs to cache. 11212 */ 11213 function ListCache(entries) { 11214 var index = -1, 11215 length = entries == null ? 0 : entries.length; 11216 11217 this.clear(); 11218 while (++index < length) { 11219 var entry = entries[index]; 11220 this.set(entry[0], entry[1]); 11221 } 11222 } 11223 11224 /** 11225 * Removes all key-value entries from the list cache. 11226 * 11227 * @private 11228 * @name clear 11229 * @memberOf ListCache 11230 */ 11231 function listCacheClear() { 11232 this.__data__ = []; 11233 this.size = 0; 11234 } 11235 11236 /** 11237 * Removes `key` and its value from the list cache. 11238 * 11239 * @private 11240 * @name delete 11241 * @memberOf ListCache 11242 * @param {string} key The key of the value to remove. 11243 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 11244 */ 11245 function listCacheDelete(key) { 11246 var data = this.__data__, 11247 index = assocIndexOf(data, key); 11248 11249 if (index < 0) { 11250 return false; 11251 } 11252 var lastIndex = data.length - 1; 11253 if (index == lastIndex) { 11254 data.pop(); 11255 } else { 11256 splice.call(data, index, 1); 11257 } 11258 --this.size; 11259 return true; 11260 } 11261 11262 /** 11263 * Gets the list cache value for `key`. 11264 * 11265 * @private 11266 * @name get 11267 * @memberOf ListCache 11268 * @param {string} key The key of the value to get. 11269 * @returns {*} Returns the entry value. 11270 */ 11271 function listCacheGet(key) { 11272 var data = this.__data__, 11273 index = assocIndexOf(data, key); 11274 11275 return index < 0 ? undefined : data[index][1]; 11276 } 11277 11278 /** 11279 * Checks if a list cache value for `key` exists. 11280 * 11281 * @private 11282 * @name has 11283 * @memberOf ListCache 11284 * @param {string} key The key of the entry to check. 11285 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 11286 */ 11287 function listCacheHas(key) { 11288 return assocIndexOf(this.__data__, key) > -1; 11289 } 11290 11291 /** 11292 * Sets the list cache `key` to `value`. 11293 * 11294 * @private 11295 * @name set 11296 * @memberOf ListCache 11297 * @param {string} key The key of the value to set. 11298 * @param {*} value The value to set. 11299 * @returns {Object} Returns the list cache instance. 11300 */ 11301 function listCacheSet(key, value) { 11302 var data = this.__data__, 11303 index = assocIndexOf(data, key); 11304 11305 if (index < 0) { 11306 ++this.size; 11307 data.push([key, value]); 11308 } else { 11309 data[index][1] = value; 11310 } 11311 return this; 11312 } 11313 11314 // Add methods to `ListCache`. 11315 ListCache.prototype.clear = listCacheClear; 11316 ListCache.prototype['delete'] = listCacheDelete; 11317 ListCache.prototype.get = listCacheGet; 11318 ListCache.prototype.has = listCacheHas; 11319 ListCache.prototype.set = listCacheSet; 11320 11321 /*------------------------------------------------------------------------*/ 11322 11323 /** 11324 * Creates a map cache object to store key-value pairs. 11325 * 11326 * @private 11327 * @constructor 11328 * @param {Array} [entries] The key-value pairs to cache. 11329 */ 11330 function MapCache(entries) { 11331 var index = -1, 11332 length = entries == null ? 0 : entries.length; 11333 11334 this.clear(); 11335 while (++index < length) { 11336 var entry = entries[index]; 11337 this.set(entry[0], entry[1]); 11338 } 11339 } 11340 11341 /** 11342 * Removes all key-value entries from the map. 11343 * 11344 * @private 11345 * @name clear 11346 * @memberOf MapCache 11347 */ 11348 function mapCacheClear() { 11349 this.size = 0; 11350 this.__data__ = { 11351 'hash': new Hash, 11352 'map': new (Map || ListCache), 11353 'string': new Hash 11354 }; 11355 } 11356 11357 /** 11358 * Removes `key` and its value from the map. 11359 * 11360 * @private 11361 * @name delete 11362 * @memberOf MapCache 11363 * @param {string} key The key of the value to remove. 11364 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 11365 */ 11366 function mapCacheDelete(key) { 11367 var result = getMapData(this, key)['delete'](key); 11368 this.size -= result ? 1 : 0; 11369 return result; 11370 } 11371 11372 /** 11373 * Gets the map value for `key`. 11374 * 11375 * @private 11376 * @name get 11377 * @memberOf MapCache 11378 * @param {string} key The key of the value to get. 11379 * @returns {*} Returns the entry value. 11380 */ 11381 function mapCacheGet(key) { 11382 return getMapData(this, key).get(key); 11383 } 11384 11385 /** 11386 * Checks if a map value for `key` exists. 11387 * 11388 * @private 11389 * @name has 11390 * @memberOf MapCache 11391 * @param {string} key The key of the entry to check. 11392 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 11393 */ 11394 function mapCacheHas(key) { 11395 return getMapData(this, key).has(key); 11396 } 11397 11398 /** 11399 * Sets the map `key` to `value`. 11400 * 11401 * @private 11402 * @name set 11403 * @memberOf MapCache 11404 * @param {string} key The key of the value to set. 11405 * @param {*} value The value to set. 11406 * @returns {Object} Returns the map cache instance. 11407 */ 11408 function mapCacheSet(key, value) { 11409 var data = getMapData(this, key), 11410 size = data.size; 11411 11412 data.set(key, value); 11413 this.size += data.size == size ? 0 : 1; 11414 return this; 11415 } 11416 11417 // Add methods to `MapCache`. 11418 MapCache.prototype.clear = mapCacheClear; 11419 MapCache.prototype['delete'] = mapCacheDelete; 11420 MapCache.prototype.get = mapCacheGet; 11421 MapCache.prototype.has = mapCacheHas; 11422 MapCache.prototype.set = mapCacheSet; 11423 11424 /*------------------------------------------------------------------------*/ 11425 11426 /** 11427 * 11428 * Creates an array cache object to store unique values. 11429 * 11430 * @private 11431 * @constructor 11432 * @param {Array} [values] The values to cache. 11433 */ 11434 function SetCache(values) { 11435 var index = -1, 11436 length = values == null ? 0 : values.length; 11437 11438 this.__data__ = new MapCache; 11439 while (++index < length) { 11440 this.add(values[index]); 11441 } 11442 } 11443 11444 /** 11445 * Adds `value` to the array cache. 11446 * 11447 * @private 11448 * @name add 11449 * @memberOf SetCache 11450 * @alias push 11451 * @param {*} value The value to cache. 11452 * @returns {Object} Returns the cache instance. 11453 */ 11454 function setCacheAdd(value) { 11455 this.__data__.set(value, HASH_UNDEFINED); 11456 return this; 11457 } 11458 11459 /** 11460 * Checks if `value` is in the array cache. 11461 * 11462 * @private 11463 * @name has 11464 * @memberOf SetCache 11465 * @param {*} value The value to search for. 11466 * @returns {number} Returns `true` if `value` is found, else `false`. 11467 */ 11468 function setCacheHas(value) { 11469 return this.__data__.has(value); 11470 } 11471 11472 // Add methods to `SetCache`. 11473 SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; 11474 SetCache.prototype.has = setCacheHas; 11475 11476 /*------------------------------------------------------------------------*/ 11477 11478 /** 11479 * Creates a stack cache object to store key-value pairs. 11480 * 11481 * @private 11482 * @constructor 11483 * @param {Array} [entries] The key-value pairs to cache. 11484 */ 11485 function Stack(entries) { 11486 var data = this.__data__ = new ListCache(entries); 11487 this.size = data.size; 11488 } 11489 11490 /** 11491 * Removes all key-value entries from the stack. 11492 * 11493 * @private 11494 * @name clear 11495 * @memberOf Stack 11496 */ 11497 function stackClear() { 11498 this.__data__ = new ListCache; 11499 this.size = 0; 11500 } 11501 11502 /** 11503 * Removes `key` and its value from the stack. 11504 * 11505 * @private 11506 * @name delete 11507 * @memberOf Stack 11508 * @param {string} key The key of the value to remove. 11509 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 11510 */ 11511 function stackDelete(key) { 11512 var data = this.__data__, 11513 result = data['delete'](key); 11514 11515 this.size = data.size; 11516 return result; 11517 } 11518 11519 /** 11520 * Gets the stack value for `key`. 11521 * 11522 * @private 11523 * @name get 11524 * @memberOf Stack 11525 * @param {string} key The key of the value to get. 11526 * @returns {*} Returns the entry value. 11527 */ 11528 function stackGet(key) { 11529 return this.__data__.get(key); 11530 } 11531 11532 /** 11533 * Checks if a stack value for `key` exists. 11534 * 11535 * @private 11536 * @name has 11537 * @memberOf Stack 11538 * @param {string} key The key of the entry to check. 11539 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 11540 */ 11541 function stackHas(key) { 11542 return this.__data__.has(key); 11543 } 11544 11545 /** 11546 * Sets the stack `key` to `value`. 11547 * 11548 * @private 11549 * @name set 11550 * @memberOf Stack 11551 * @param {string} key The key of the value to set. 11552 * @param {*} value The value to set. 11553 * @returns {Object} Returns the stack cache instance. 11554 */ 11555 function stackSet(key, value) { 11556 var data = this.__data__; 11557 if (data instanceof ListCache) { 11558 var pairs = data.__data__; 11559 if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) { 11560 pairs.push([key, value]); 11561 this.size = ++data.size; 11562 return this; 11563 } 11564 data = this.__data__ = new MapCache(pairs); 11565 } 11566 data.set(key, value); 11567 this.size = data.size; 11568 return this; 11569 } 11570 11571 // Add methods to `Stack`. 11572 Stack.prototype.clear = stackClear; 11573 Stack.prototype['delete'] = stackDelete; 11574 Stack.prototype.get = stackGet; 11575 Stack.prototype.has = stackHas; 11576 Stack.prototype.set = stackSet; 11577 11578 /*------------------------------------------------------------------------*/ 11579 11580 /** 11581 * Creates an array of the enumerable property names of the array-like `value`. 11582 * 11583 * @private 11584 * @param {*} value The value to query. 11585 * @param {boolean} inherited Specify returning inherited property names. 11586 * @returns {Array} Returns the array of property names. 11587 */ 11588 function arrayLikeKeys(value, inherited) { 11589 var isArr = isArray(value), 11590 isArg = !isArr && isArguments(value), 11591 isBuff = !isArr && !isArg && isBuffer(value), 11592 isType = !isArr && !isArg && !isBuff && isTypedArray(value), 11593 skipIndexes = isArr || isArg || isBuff || isType, 11594 result = skipIndexes ? baseTimes(value.length, String) : [], 11595 length = result.length; 11596 11597 for (var key in value) { 11598 if ((inherited || hasOwnProperty.call(value, key)) && 11599 !(skipIndexes && ( 11600 // Safari 9 has enumerable `arguments.length` in strict mode. 11601 key == 'length' || 11602 // Node.js 0.10 has enumerable non-index properties on buffers. 11603 (isBuff && (key == 'offset' || key == 'parent')) || 11604 // PhantomJS 2 has enumerable non-index properties on typed arrays. 11605 (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) || 11606 // Skip index properties. 11607 isIndex(key, length) 11608 ))) { 11609 result.push(key); 11610 } 11611 } 11612 return result; 11613 } 11614 11615 /** 11616 * A specialized version of `_.sample` for arrays. 11617 * 11618 * @private 11619 * @param {Array} array The array to sample. 11620 * @returns {*} Returns the random element. 11621 */ 11622 function arraySample(array) { 11623 var length = array.length; 11624 return length ? array[baseRandom(0, length - 1)] : undefined; 11625 } 11626 11627 /** 11628 * A specialized version of `_.sampleSize` for arrays. 11629 * 11630 * @private 11631 * @param {Array} array The array to sample. 11632 * @param {number} n The number of elements to sample. 11633 * @returns {Array} Returns the random elements. 11634 */ 11635 function arraySampleSize(array, n) { 11636 return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length)); 11637 } 11638 11639 /** 11640 * A specialized version of `_.shuffle` for arrays. 11641 * 11642 * @private 11643 * @param {Array} array The array to shuffle. 11644 * @returns {Array} Returns the new shuffled array. 11645 */ 11646 function arrayShuffle(array) { 11647 return shuffleSelf(copyArray(array)); 11648 } 11649 11650 /** 11651 * This function is like `assignValue` except that it doesn't assign 11652 * `undefined` values. 11653 * 11654 * @private 11655 * @param {Object} object The object to modify. 11656 * @param {string} key The key of the property to assign. 11657 * @param {*} value The value to assign. 11658 */ 11659 function assignMergeValue(object, key, value) { 11660 if ((value !== undefined && !eq(object[key], value)) || 11661 (value === undefined && !(key in object))) { 11662 baseAssignValue(object, key, value); 11663 } 11664 } 11665 11666 /** 11667 * Assigns `value` to `key` of `object` if the existing value is not equivalent 11668 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 11669 * for equality comparisons. 11670 * 11671 * @private 11672 * @param {Object} object The object to modify. 11673 * @param {string} key The key of the property to assign. 11674 * @param {*} value The value to assign. 11675 */ 11676 function assignValue(object, key, value) { 11677 var objValue = object[key]; 11678 if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || 11679 (value === undefined && !(key in object))) { 11680 baseAssignValue(object, key, value); 11681 } 11682 } 11683 11684 /** 11685 * Gets the index at which the `key` is found in `array` of key-value pairs. 11686 * 11687 * @private 11688 * @param {Array} array The array to inspect. 11689 * @param {*} key The key to search for. 11690 * @returns {number} Returns the index of the matched value, else `-1`. 11691 */ 11692 function assocIndexOf(array, key) { 11693 var length = array.length; 11694 while (length--) { 11695 if (eq(array[length][0], key)) { 11696 return length; 11697 } 11698 } 11699 return -1; 11700 } 11701 11702 /** 11703 * Aggregates elements of `collection` on `accumulator` with keys transformed 11704 * by `iteratee` and values set by `setter`. 11705 * 11706 * @private 11707 * @param {Array|Object} collection The collection to iterate over. 11708 * @param {Function} setter The function to set `accumulator` values. 11709 * @param {Function} iteratee The iteratee to transform keys. 11710 * @param {Object} accumulator The initial aggregated object. 11711 * @returns {Function} Returns `accumulator`. 11712 */ 11713 function baseAggregator(collection, setter, iteratee, accumulator) { 11714 baseEach(collection, function(value, key, collection) { 11715 setter(accumulator, value, iteratee(value), collection); 11716 }); 11717 return accumulator; 11718 } 11719 11720 /** 11721 * The base implementation of `_.assign` without support for multiple sources 11722 * or `customizer` functions. 11723 * 11724 * @private 11725 * @param {Object} object The destination object. 11726 * @param {Object} source The source object. 11727 * @returns {Object} Returns `object`. 11728 */ 11729 function baseAssign(object, source) { 11730 return object && copyObject(source, keys(source), object); 11731 } 11732 11733 /** 11734 * The base implementation of `_.assignIn` without support for multiple sources 11735 * or `customizer` functions. 11736 * 11737 * @private 11738 * @param {Object} object The destination object. 11739 * @param {Object} source The source object. 11740 * @returns {Object} Returns `object`. 11741 */ 11742 function baseAssignIn(object, source) { 11743 return object && copyObject(source, keysIn(source), object); 11744 } 11745 11746 /** 11747 * The base implementation of `assignValue` and `assignMergeValue` without 11748 * value checks. 11749 * 11750 * @private 11751 * @param {Object} object The object to modify. 11752 * @param {string} key The key of the property to assign. 11753 * @param {*} value The value to assign. 11754 */ 11755 function baseAssignValue(object, key, value) { 11756 if (key == '__proto__' && defineProperty) { 11757 defineProperty(object, key, { 11758 'configurable': true, 11759 'enumerable': true, 11760 'value': value, 11761 'writable': true 11762 }); 11763 } else { 11764 object[key] = value; 11765 } 11766 } 11767 11768 /** 11769 * The base implementation of `_.at` without support for individual paths. 11770 * 11771 * @private 11772 * @param {Object} object The object to iterate over. 11773 * @param {string[]} paths The property paths to pick. 11774 * @returns {Array} Returns the picked elements. 11775 */ 11776 function baseAt(object, paths) { 11777 var index = -1, 11778 length = paths.length, 11779 result = Array(length), 11780 skip = object == null; 11781 11782 while (++index < length) { 11783 result[index] = skip ? undefined : get(object, paths[index]); 11784 } 11785 return result; 11786 } 11787 11788 /** 11789 * The base implementation of `_.clamp` which doesn't coerce arguments. 11790 * 11791 * @private 11792 * @param {number} number The number to clamp. 11793 * @param {number} [lower] The lower bound. 11794 * @param {number} upper The upper bound. 11795 * @returns {number} Returns the clamped number. 11796 */ 11797 function baseClamp(number, lower, upper) { 11798 if (number === number) { 11799 if (upper !== undefined) { 11800 number = number <= upper ? number : upper; 11801 } 11802 if (lower !== undefined) { 11803 number = number >= lower ? number : lower; 11804 } 11805 } 11806 return number; 11807 } 11808 11809 /** 11810 * The base implementation of `_.clone` and `_.cloneDeep` which tracks 11811 * traversed objects. 11812 * 11813 * @private 11814 * @param {*} value The value to clone. 11815 * @param {boolean} bitmask The bitmask flags. 11816 * 1 - Deep clone 11817 * 2 - Flatten inherited properties 11818 * 4 - Clone symbols 11819 * @param {Function} [customizer] The function to customize cloning. 11820 * @param {string} [key] The key of `value`. 11821 * @param {Object} [object] The parent object of `value`. 11822 * @param {Object} [stack] Tracks traversed objects and their clone counterparts. 11823 * @returns {*} Returns the cloned value. 11824 */ 11825 function baseClone(value, bitmask, customizer, key, object, stack) { 11826 var result, 11827 isDeep = bitmask & CLONE_DEEP_FLAG, 11828 isFlat = bitmask & CLONE_FLAT_FLAG, 11829 isFull = bitmask & CLONE_SYMBOLS_FLAG; 11830 11831 if (customizer) { 11832 result = object ? customizer(value, key, object, stack) : customizer(value); 11833 } 11834 if (result !== undefined) { 11835 return result; 11836 } 11837 if (!isObject(value)) { 11838 return value; 11839 } 11840 var isArr = isArray(value); 11841 if (isArr) { 11842 result = initCloneArray(value); 11843 if (!isDeep) { 11844 return copyArray(value, result); 11845 } 11846 } else { 11847 var tag = getTag(value), 11848 isFunc = tag == funcTag || tag == genTag; 11849 11850 if (isBuffer(value)) { 11851 return cloneBuffer(value, isDeep); 11852 } 11853 if (tag == objectTag || tag == argsTag || (isFunc && !object)) { 11854 result = (isFlat || isFunc) ? {} : initCloneObject(value); 11855 if (!isDeep) { 11856 return isFlat 11857 ? copySymbolsIn(value, baseAssignIn(result, value)) 11858 : copySymbols(value, baseAssign(result, value)); 11859 } 11860 } else { 11861 if (!cloneableTags[tag]) { 11862 return object ? value : {}; 11863 } 11864 result = initCloneByTag(value, tag, isDeep); 11865 } 11866 } 11867 // Check for circular references and return its corresponding clone. 11868 stack || (stack = new Stack); 11869 var stacked = stack.get(value); 11870 if (stacked) { 11871 return stacked; 11872 } 11873 stack.set(value, result); 11874 11875 if (isSet(value)) { 11876 value.forEach(function(subValue) { 11877 result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack)); 11878 }); 11879 } else if (isMap(value)) { 11880 value.forEach(function(subValue, key) { 11881 result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack)); 11882 }); 11883 } 11884 11885 var keysFunc = isFull 11886 ? (isFlat ? getAllKeysIn : getAllKeys) 11887 : (isFlat ? keysIn : keys); 11888 11889 var props = isArr ? undefined : keysFunc(value); 11890 arrayEach(props || value, function(subValue, key) { 11891 if (props) { 11892 key = subValue; 11893 subValue = value[key]; 11894 } 11895 // Recursively populate clone (susceptible to call stack limits). 11896 assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack)); 11897 }); 11898 return result; 11899 } 11900 11901 /** 11902 * The base implementation of `_.conforms` which doesn't clone `source`. 11903 * 11904 * @private 11905 * @param {Object} source The object of property predicates to conform to. 11906 * @returns {Function} Returns the new spec function. 11907 */ 11908 function baseConforms(source) { 11909 var props = keys(source); 11910 return function(object) { 11911 return baseConformsTo(object, source, props); 11912 }; 11913 } 11914 11915 /** 11916 * The base implementation of `_.conformsTo` which accepts `props` to check. 11917 * 11918 * @private 11919 * @param {Object} object The object to inspect. 11920 * @param {Object} source The object of property predicates to conform to. 11921 * @returns {boolean} Returns `true` if `object` conforms, else `false`. 11922 */ 11923 function baseConformsTo(object, source, props) { 11924 var length = props.length; 11925 if (object == null) { 11926 return !length; 11927 } 11928 object = Object(object); 11929 while (length--) { 11930 var key = props[length], 11931 predicate = source[key], 11932 value = object[key]; 11933 11934 if ((value === undefined && !(key in object)) || !predicate(value)) { 11935 return false; 11936 } 11937 } 11938 return true; 11939 } 11940 11941 /** 11942 * The base implementation of `_.delay` and `_.defer` which accepts `args` 11943 * to provide to `func`. 11944 * 11945 * @private 11946 * @param {Function} func The function to delay. 11947 * @param {number} wait The number of milliseconds to delay invocation. 11948 * @param {Array} args The arguments to provide to `func`. 11949 * @returns {number|Object} Returns the timer id or timeout object. 11950 */ 11951 function baseDelay(func, wait, args) { 11952 if (typeof func != 'function') { 11953 throw new TypeError(FUNC_ERROR_TEXT); 11954 } 11955 return setTimeout(function() { func.apply(undefined, args); }, wait); 11956 } 11957 11958 /** 11959 * The base implementation of methods like `_.difference` without support 11960 * for excluding multiple arrays or iteratee shorthands. 11961 * 11962 * @private 11963 * @param {Array} array The array to inspect. 11964 * @param {Array} values The values to exclude. 11965 * @param {Function} [iteratee] The iteratee invoked per element. 11966 * @param {Function} [comparator] The comparator invoked per element. 11967 * @returns {Array} Returns the new array of filtered values. 11968 */ 11969 function baseDifference(array, values, iteratee, comparator) { 11970 var index = -1, 11971 includes = arrayIncludes, 11972 isCommon = true, 11973 length = array.length, 11974 result = [], 11975 valuesLength = values.length; 11976 11977 if (!length) { 11978 return result; 11979 } 11980 if (iteratee) { 11981 values = arrayMap(values, baseUnary(iteratee)); 11982 } 11983 if (comparator) { 11984 includes = arrayIncludesWith; 11985 isCommon = false; 11986 } 11987 else if (values.length >= LARGE_ARRAY_SIZE) { 11988 includes = cacheHas; 11989 isCommon = false; 11990 values = new SetCache(values); 11991 } 11992 outer: 11993 while (++index < length) { 11994 var value = array[index], 11995 computed = iteratee == null ? value : iteratee(value); 11996 11997 value = (comparator || value !== 0) ? value : 0; 11998 if (isCommon && computed === computed) { 11999 var valuesIndex = valuesLength; 12000 while (valuesIndex--) { 12001 if (values[valuesIndex] === computed) { 12002 continue outer; 12003 } 12004 } 12005 result.push(value); 12006 } 12007 else if (!includes(values, computed, comparator)) { 12008 result.push(value); 12009 } 12010 } 12011 return result; 12012 } 12013 12014 /** 12015 * The base implementation of `_.forEach` without support for iteratee shorthands. 12016 * 12017 * @private 12018 * @param {Array|Object} collection The collection to iterate over. 12019 * @param {Function} iteratee The function invoked per iteration. 12020 * @returns {Array|Object} Returns `collection`. 12021 */ 12022 var baseEach = createBaseEach(baseForOwn); 12023 12024 /** 12025 * The base implementation of `_.forEachRight` without support for iteratee shorthands. 12026 * 12027 * @private 12028 * @param {Array|Object} collection The collection to iterate over. 12029 * @param {Function} iteratee The function invoked per iteration. 12030 * @returns {Array|Object} Returns `collection`. 12031 */ 12032 var baseEachRight = createBaseEach(baseForOwnRight, true); 12033 12034 /** 12035 * The base implementation of `_.every` without support for iteratee shorthands. 12036 * 12037 * @private 12038 * @param {Array|Object} collection The collection to iterate over. 12039 * @param {Function} predicate The function invoked per iteration. 12040 * @returns {boolean} Returns `true` if all elements pass the predicate check, 12041 * else `false` 12042 */ 12043 function baseEvery(collection, predicate) { 12044 var result = true; 12045 baseEach(collection, function(value, index, collection) { 12046 result = !!predicate(value, index, collection); 12047 return result; 12048 }); 12049 return result; 12050 } 12051 12052 /** 12053 * The base implementation of methods like `_.max` and `_.min` which accepts a 12054 * `comparator` to determine the extremum value. 12055 * 12056 * @private 12057 * @param {Array} array The array to iterate over. 12058 * @param {Function} iteratee The iteratee invoked per iteration. 12059 * @param {Function} comparator The comparator used to compare values. 12060 * @returns {*} Returns the extremum value. 12061 */ 12062 function baseExtremum(array, iteratee, comparator) { 12063 var index = -1, 12064 length = array.length; 12065 12066 while (++index < length) { 12067 var value = array[index], 12068 current = iteratee(value); 12069 12070 if (current != null && (computed === undefined 12071 ? (current === current && !isSymbol(current)) 12072 : comparator(current, computed) 12073 )) { 12074 var computed = current, 12075 result = value; 12076 } 12077 } 12078 return result; 12079 } 12080 12081 /** 12082 * The base implementation of `_.fill` without an iteratee call guard. 12083 * 12084 * @private 12085 * @param {Array} array The array to fill. 12086 * @param {*} value The value to fill `array` with. 12087 * @param {number} [start=0] The start position. 12088 * @param {number} [end=array.length] The end position. 12089 * @returns {Array} Returns `array`. 12090 */ 12091 function baseFill(array, value, start, end) { 12092 var length = array.length; 12093 12094 start = toInteger(start); 12095 if (start < 0) { 12096 start = -start > length ? 0 : (length + start); 12097 } 12098 end = (end === undefined || end > length) ? length : toInteger(end); 12099 if (end < 0) { 12100 end += length; 12101 } 12102 end = start > end ? 0 : toLength(end); 12103 while (start < end) { 12104 array[start++] = value; 12105 } 12106 return array; 12107 } 12108 12109 /** 12110 * The base implementation of `_.filter` without support for iteratee shorthands. 12111 * 12112 * @private 12113 * @param {Array|Object} collection The collection to iterate over. 12114 * @param {Function} predicate The function invoked per iteration. 12115 * @returns {Array} Returns the new filtered array. 12116 */ 12117 function baseFilter(collection, predicate) { 12118 var result = []; 12119 baseEach(collection, function(value, index, collection) { 12120 if (predicate(value, index, collection)) { 12121 result.push(value); 12122 } 12123 }); 12124 return result; 12125 } 12126 12127 /** 12128 * The base implementation of `_.flatten` with support for restricting flattening. 12129 * 12130 * @private 12131 * @param {Array} array The array to flatten. 12132 * @param {number} depth The maximum recursion depth. 12133 * @param {boolean} [predicate=isFlattenable] The function invoked per iteration. 12134 * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks. 12135 * @param {Array} [result=[]] The initial result value. 12136 * @returns {Array} Returns the new flattened array. 12137 */ 12138 function baseFlatten(array, depth, predicate, isStrict, result) { 12139 var index = -1, 12140 length = array.length; 12141 12142 predicate || (predicate = isFlattenable); 12143 result || (result = []); 12144 12145 while (++index < length) { 12146 var value = array[index]; 12147 if (depth > 0 && predicate(value)) { 12148 if (depth > 1) { 12149 // Recursively flatten arrays (susceptible to call stack limits). 12150 baseFlatten(value, depth - 1, predicate, isStrict, result); 12151 } else { 12152 arrayPush(result, value); 12153 } 12154 } else if (!isStrict) { 12155 result[result.length] = value; 12156 } 12157 } 12158 return result; 12159 } 12160 12161 /** 12162 * The base implementation of `baseForOwn` which iterates over `object` 12163 * properties returned by `keysFunc` and invokes `iteratee` for each property. 12164 * Iteratee functions may exit iteration early by explicitly returning `false`. 12165 * 12166 * @private 12167 * @param {Object} object The object to iterate over. 12168 * @param {Function} iteratee The function invoked per iteration. 12169 * @param {Function} keysFunc The function to get the keys of `object`. 12170 * @returns {Object} Returns `object`. 12171 */ 12172 var baseFor = createBaseFor(); 12173 12174 /** 12175 * This function is like `baseFor` except that it iterates over properties 12176 * in the opposite order. 12177 * 12178 * @private 12179 * @param {Object} object The object to iterate over. 12180 * @param {Function} iteratee The function invoked per iteration. 12181 * @param {Function} keysFunc The function to get the keys of `object`. 12182 * @returns {Object} Returns `object`. 12183 */ 12184 var baseForRight = createBaseFor(true); 12185 12186 /** 12187 * The base implementation of `_.forOwn` without support for iteratee shorthands. 12188 * 12189 * @private 12190 * @param {Object} object The object to iterate over. 12191 * @param {Function} iteratee The function invoked per iteration. 12192 * @returns {Object} Returns `object`. 12193 */ 12194 function baseForOwn(object, iteratee) { 12195 return object && baseFor(object, iteratee, keys); 12196 } 12197 12198 /** 12199 * The base implementation of `_.forOwnRight` without support for iteratee shorthands. 12200 * 12201 * @private 12202 * @param {Object} object The object to iterate over. 12203 * @param {Function} iteratee The function invoked per iteration. 12204 * @returns {Object} Returns `object`. 12205 */ 12206 function baseForOwnRight(object, iteratee) { 12207 return object && baseForRight(object, iteratee, keys); 12208 } 12209 12210 /** 12211 * The base implementation of `_.functions` which creates an array of 12212 * `object` function property names filtered from `props`. 12213 * 12214 * @private 12215 * @param {Object} object The object to inspect. 12216 * @param {Array} props The property names to filter. 12217 * @returns {Array} Returns the function names. 12218 */ 12219 function baseFunctions(object, props) { 12220 return arrayFilter(props, function(key) { 12221 return isFunction(object[key]); 12222 }); 12223 } 12224 12225 /** 12226 * The base implementation of `_.get` without support for default values. 12227 * 12228 * @private 12229 * @param {Object} object The object to query. 12230 * @param {Array|string} path The path of the property to get. 12231 * @returns {*} Returns the resolved value. 12232 */ 12233 function baseGet(object, path) { 12234 path = castPath(path, object); 12235 12236 var index = 0, 12237 length = path.length; 12238 12239 while (object != null && index < length) { 12240 object = object[toKey(path[index++])]; 12241 } 12242 return (index && index == length) ? object : undefined; 12243 } 12244 12245 /** 12246 * The base implementation of `getAllKeys` and `getAllKeysIn` which uses 12247 * `keysFunc` and `symbolsFunc` to get the enumerable property names and 12248 * symbols of `object`. 12249 * 12250 * @private 12251 * @param {Object} object The object to query. 12252 * @param {Function} keysFunc The function to get the keys of `object`. 12253 * @param {Function} symbolsFunc The function to get the symbols of `object`. 12254 * @returns {Array} Returns the array of property names and symbols. 12255 */ 12256 function baseGetAllKeys(object, keysFunc, symbolsFunc) { 12257 var result = keysFunc(object); 12258 return isArray(object) ? result : arrayPush(result, symbolsFunc(object)); 12259 } 12260 12261 /** 12262 * The base implementation of `getTag` without fallbacks for buggy environments. 12263 * 12264 * @private 12265 * @param {*} value The value to query. 12266 * @returns {string} Returns the `toStringTag`. 12267 */ 12268 function baseGetTag(value) { 12269 if (value == null) { 12270 return value === undefined ? undefinedTag : nullTag; 12271 } 12272 return (symToStringTag && symToStringTag in Object(value)) 12273 ? getRawTag(value) 12274 : objectToString(value); 12275 } 12276 12277 /** 12278 * The base implementation of `_.gt` which doesn't coerce arguments. 12279 * 12280 * @private 12281 * @param {*} value The value to compare. 12282 * @param {*} other The other value to compare. 12283 * @returns {boolean} Returns `true` if `value` is greater than `other`, 12284 * else `false`. 12285 */ 12286 function baseGt(value, other) { 12287 return value > other; 12288 } 12289 12290 /** 12291 * The base implementation of `_.has` without support for deep paths. 12292 * 12293 * @private 12294 * @param {Object} [object] The object to query. 12295 * @param {Array|string} key The key to check. 12296 * @returns {boolean} Returns `true` if `key` exists, else `false`. 12297 */ 12298 function baseHas(object, key) { 12299 return object != null && hasOwnProperty.call(object, key); 12300 } 12301 12302 /** 12303 * The base implementation of `_.hasIn` without support for deep paths. 12304 * 12305 * @private 12306 * @param {Object} [object] The object to query. 12307 * @param {Array|string} key The key to check. 12308 * @returns {boolean} Returns `true` if `key` exists, else `false`. 12309 */ 12310 function baseHasIn(object, key) { 12311 return object != null && key in Object(object); 12312 } 12313 12314 /** 12315 * The base implementation of `_.inRange` which doesn't coerce arguments. 12316 * 12317 * @private 12318 * @param {number} number The number to check. 12319 * @param {number} start The start of the range. 12320 * @param {number} end The end of the range. 12321 * @returns {boolean} Returns `true` if `number` is in the range, else `false`. 12322 */ 12323 function baseInRange(number, start, end) { 12324 return number >= nativeMin(start, end) && number < nativeMax(start, end); 12325 } 12326 12327 /** 12328 * The base implementation of methods like `_.intersection`, without support 12329 * for iteratee shorthands, that accepts an array of arrays to inspect. 12330 * 12331 * @private 12332 * @param {Array} arrays The arrays to inspect. 12333 * @param {Function} [iteratee] The iteratee invoked per element. 12334 * @param {Function} [comparator] The comparator invoked per element. 12335 * @returns {Array} Returns the new array of shared values. 12336 */ 12337 function baseIntersection(arrays, iteratee, comparator) { 12338 var includes = comparator ? arrayIncludesWith : arrayIncludes, 12339 length = arrays[0].length, 12340 othLength = arrays.length, 12341 othIndex = othLength, 12342 caches = Array(othLength), 12343 maxLength = Infinity, 12344 result = []; 12345 12346 while (othIndex--) { 12347 var array = arrays[othIndex]; 12348 if (othIndex && iteratee) { 12349 array = arrayMap(array, baseUnary(iteratee)); 12350 } 12351 maxLength = nativeMin(array.length, maxLength); 12352 caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120)) 12353 ? new SetCache(othIndex && array) 12354 : undefined; 12355 } 12356 array = arrays[0]; 12357 12358 var index = -1, 12359 seen = caches[0]; 12360 12361 outer: 12362 while (++index < length && result.length < maxLength) { 12363 var value = array[index], 12364 computed = iteratee ? iteratee(value) : value; 12365 12366 value = (comparator || value !== 0) ? value : 0; 12367 if (!(seen 12368 ? cacheHas(seen, computed) 12369 : includes(result, computed, comparator) 12370 )) { 12371 othIndex = othLength; 12372 while (--othIndex) { 12373 var cache = caches[othIndex]; 12374 if (!(cache 12375 ? cacheHas(cache, computed) 12376 : includes(arrays[othIndex], computed, comparator)) 12377 ) { 12378 continue outer; 12379 } 12380 } 12381 if (seen) { 12382 seen.push(computed); 12383 } 12384 result.push(value); 12385 } 12386 } 12387 return result; 12388 } 12389 12390 /** 12391 * The base implementation of `_.invert` and `_.invertBy` which inverts 12392 * `object` with values transformed by `iteratee` and set by `setter`. 12393 * 12394 * @private 12395 * @param {Object} object The object to iterate over. 12396 * @param {Function} setter The function to set `accumulator` values. 12397 * @param {Function} iteratee The iteratee to transform values. 12398 * @param {Object} accumulator The initial inverted object. 12399 * @returns {Function} Returns `accumulator`. 12400 */ 12401 function baseInverter(object, setter, iteratee, accumulator) { 12402 baseForOwn(object, function(value, key, object) { 12403 setter(accumulator, iteratee(value), key, object); 12404 }); 12405 return accumulator; 12406 } 12407 12408 /** 12409 * The base implementation of `_.invoke` without support for individual 12410 * method arguments. 12411 * 12412 * @private 12413 * @param {Object} object The object to query. 12414 * @param {Array|string} path The path of the method to invoke. 12415 * @param {Array} args The arguments to invoke the method with. 12416 * @returns {*} Returns the result of the invoked method. 12417 */ 12418 function baseInvoke(object, path, args) { 12419 path = castPath(path, object); 12420 object = parent(object, path); 12421 var func = object == null ? object : object[toKey(last(path))]; 12422 return func == null ? undefined : apply(func, object, args); 12423 } 12424 12425 /** 12426 * The base implementation of `_.isArguments`. 12427 * 12428 * @private 12429 * @param {*} value The value to check. 12430 * @returns {boolean} Returns `true` if `value` is an `arguments` object, 12431 */ 12432 function baseIsArguments(value) { 12433 return isObjectLike(value) && baseGetTag(value) == argsTag; 12434 } 12435 12436 /** 12437 * The base implementation of `_.isArrayBuffer` without Node.js optimizations. 12438 * 12439 * @private 12440 * @param {*} value The value to check. 12441 * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. 12442 */ 12443 function baseIsArrayBuffer(value) { 12444 return isObjectLike(value) && baseGetTag(value) == arrayBufferTag; 12445 } 12446 12447 /** 12448 * The base implementation of `_.isDate` without Node.js optimizations. 12449 * 12450 * @private 12451 * @param {*} value The value to check. 12452 * @returns {boolean} Returns `true` if `value` is a date object, else `false`. 12453 */ 12454 function baseIsDate(value) { 12455 return isObjectLike(value) && baseGetTag(value) == dateTag; 12456 } 12457 12458 /** 12459 * The base implementation of `_.isEqual` which supports partial comparisons 12460 * and tracks traversed objects. 12461 * 12462 * @private 12463 * @param {*} value The value to compare. 12464 * @param {*} other The other value to compare. 12465 * @param {boolean} bitmask The bitmask flags. 12466 * 1 - Unordered comparison 12467 * 2 - Partial comparison 12468 * @param {Function} [customizer] The function to customize comparisons. 12469 * @param {Object} [stack] Tracks traversed `value` and `other` objects. 12470 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 12471 */ 12472 function baseIsEqual(value, other, bitmask, customizer, stack) { 12473 if (value === other) { 12474 return true; 12475 } 12476 if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) { 12477 return value !== value && other !== other; 12478 } 12479 return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); 12480 } 12481 12482 /** 12483 * A specialized version of `baseIsEqual` for arrays and objects which performs 12484 * deep comparisons and tracks traversed objects enabling objects with circular 12485 * references to be compared. 12486 * 12487 * @private 12488 * @param {Object} object The object to compare. 12489 * @param {Object} other The other object to compare. 12490 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 12491 * @param {Function} customizer The function to customize comparisons. 12492 * @param {Function} equalFunc The function to determine equivalents of values. 12493 * @param {Object} [stack] Tracks traversed `object` and `other` objects. 12494 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 12495 */ 12496 function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { 12497 var objIsArr = isArray(object), 12498 othIsArr = isArray(other), 12499 objTag = objIsArr ? arrayTag : getTag(object), 12500 othTag = othIsArr ? arrayTag : getTag(other); 12501 12502 objTag = objTag == argsTag ? objectTag : objTag; 12503 othTag = othTag == argsTag ? objectTag : othTag; 12504 12505 var objIsObj = objTag == objectTag, 12506 othIsObj = othTag == objectTag, 12507 isSameTag = objTag == othTag; 12508 12509 if (isSameTag && isBuffer(object)) { 12510 if (!isBuffer(other)) { 12511 return false; 12512 } 12513 objIsArr = true; 12514 objIsObj = false; 12515 } 12516 if (isSameTag && !objIsObj) { 12517 stack || (stack = new Stack); 12518 return (objIsArr || isTypedArray(object)) 12519 ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) 12520 : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); 12521 } 12522 if (!(bitmask & COMPARE_PARTIAL_FLAG)) { 12523 var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), 12524 othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); 12525 12526 if (objIsWrapped || othIsWrapped) { 12527 var objUnwrapped = objIsWrapped ? object.value() : object, 12528 othUnwrapped = othIsWrapped ? other.value() : other; 12529 12530 stack || (stack = new Stack); 12531 return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); 12532 } 12533 } 12534 if (!isSameTag) { 12535 return false; 12536 } 12537 stack || (stack = new Stack); 12538 return equalObjects(object, other, bitmask, customizer, equalFunc, stack); 12539 } 12540 12541 /** 12542 * The base implementation of `_.isMap` without Node.js optimizations. 12543 * 12544 * @private 12545 * @param {*} value The value to check. 12546 * @returns {boolean} Returns `true` if `value` is a map, else `false`. 12547 */ 12548 function baseIsMap(value) { 12549 return isObjectLike(value) && getTag(value) == mapTag; 12550 } 12551 12552 /** 12553 * The base implementation of `_.isMatch` without support for iteratee shorthands. 12554 * 12555 * @private 12556 * @param {Object} object The object to inspect. 12557 * @param {Object} source The object of property values to match. 12558 * @param {Array} matchData The property names, values, and compare flags to match. 12559 * @param {Function} [customizer] The function to customize comparisons. 12560 * @returns {boolean} Returns `true` if `object` is a match, else `false`. 12561 */ 12562 function baseIsMatch(object, source, matchData, customizer) { 12563 var index = matchData.length, 12564 length = index, 12565 noCustomizer = !customizer; 12566 12567 if (object == null) { 12568 return !length; 12569 } 12570 object = Object(object); 12571 while (index--) { 12572 var data = matchData[index]; 12573 if ((noCustomizer && data[2]) 12574 ? data[1] !== object[data[0]] 12575 : !(data[0] in object) 12576 ) { 12577 return false; 12578 } 12579 } 12580 while (++index < length) { 12581 data = matchData[index]; 12582 var key = data[0], 12583 objValue = object[key], 12584 srcValue = data[1]; 12585 12586 if (noCustomizer && data[2]) { 12587 if (objValue === undefined && !(key in object)) { 12588 return false; 12589 } 12590 } else { 12591 var stack = new Stack; 12592 if (customizer) { 12593 var result = customizer(objValue, srcValue, key, object, source, stack); 12594 } 12595 if (!(result === undefined 12596 ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack) 12597 : result 12598 )) { 12599 return false; 12600 } 12601 } 12602 } 12603 return true; 12604 } 12605 12606 /** 12607 * The base implementation of `_.isNative` without bad shim checks. 12608 * 12609 * @private 12610 * @param {*} value The value to check. 12611 * @returns {boolean} Returns `true` if `value` is a native function, 12612 * else `false`. 12613 */ 12614 function baseIsNative(value) { 12615 if (!isObject(value) || isMasked(value)) { 12616 return false; 12617 } 12618 var pattern = isFunction(value) ? reIsNative : reIsHostCtor; 12619 return pattern.test(toSource(value)); 12620 } 12621 12622 /** 12623 * The base implementation of `_.isRegExp` without Node.js optimizations. 12624 * 12625 * @private 12626 * @param {*} value The value to check. 12627 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. 12628 */ 12629 function baseIsRegExp(value) { 12630 return isObjectLike(value) && baseGetTag(value) == regexpTag; 12631 } 12632 12633 /** 12634 * The base implementation of `_.isSet` without Node.js optimizations. 12635 * 12636 * @private 12637 * @param {*} value The value to check. 12638 * @returns {boolean} Returns `true` if `value` is a set, else `false`. 12639 */ 12640 function baseIsSet(value) { 12641 return isObjectLike(value) && getTag(value) == setTag; 12642 } 12643 12644 /** 12645 * The base implementation of `_.isTypedArray` without Node.js optimizations. 12646 * 12647 * @private 12648 * @param {*} value The value to check. 12649 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. 12650 */ 12651 function baseIsTypedArray(value) { 12652 return isObjectLike(value) && 12653 isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; 12654 } 12655 12656 /** 12657 * The base implementation of `_.iteratee`. 12658 * 12659 * @private 12660 * @param {*} [value=_.identity] The value to convert to an iteratee. 12661 * @returns {Function} Returns the iteratee. 12662 */ 12663 function baseIteratee(value) { 12664 // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9. 12665 // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. 12666 if (typeof value == 'function') { 12667 return value; 12668 } 12669 if (value == null) { 12670 return identity; 12671 } 12672 if (typeof value == 'object') { 12673 return isArray(value) 12674 ? baseMatchesProperty(value[0], value[1]) 12675 : baseMatches(value); 12676 } 12677 return property(value); 12678 } 12679 12680 /** 12681 * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. 12682 * 12683 * @private 12684 * @param {Object} object The object to query. 12685 * @returns {Array} Returns the array of property names. 12686 */ 12687 function baseKeys(object) { 12688 if (!isPrototype(object)) { 12689 return nativeKeys(object); 12690 } 12691 var result = []; 12692 for (var key in Object(object)) { 12693 if (hasOwnProperty.call(object, key) && key != 'constructor') { 12694 result.push(key); 12695 } 12696 } 12697 return result; 12698 } 12699 12700 /** 12701 * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense. 12702 * 12703 * @private 12704 * @param {Object} object The object to query. 12705 * @returns {Array} Returns the array of property names. 12706 */ 12707 function baseKeysIn(object) { 12708 if (!isObject(object)) { 12709 return nativeKeysIn(object); 12710 } 12711 var isProto = isPrototype(object), 12712 result = []; 12713 12714 for (var key in object) { 12715 if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { 12716 result.push(key); 12717 } 12718 } 12719 return result; 12720 } 12721 12722 /** 12723 * The base implementation of `_.lt` which doesn't coerce arguments. 12724 * 12725 * @private 12726 * @param {*} value The value to compare. 12727 * @param {*} other The other value to compare. 12728 * @returns {boolean} Returns `true` if `value` is less than `other`, 12729 * else `false`. 12730 */ 12731 function baseLt(value, other) { 12732 return value < other; 12733 } 12734 12735 /** 12736 * The base implementation of `_.map` without support for iteratee shorthands. 12737 * 12738 * @private 12739 * @param {Array|Object} collection The collection to iterate over. 12740 * @param {Function} iteratee The function invoked per iteration. 12741 * @returns {Array} Returns the new mapped array. 12742 */ 12743 function baseMap(collection, iteratee) { 12744 var index = -1, 12745 result = isArrayLike(collection) ? Array(collection.length) : []; 12746 12747 baseEach(collection, function(value, key, collection) { 12748 result[++index] = iteratee(value, key, collection); 12749 }); 12750 return result; 12751 } 12752 12753 /** 12754 * The base implementation of `_.matches` which doesn't clone `source`. 12755 * 12756 * @private 12757 * @param {Object} source The object of property values to match. 12758 * @returns {Function} Returns the new spec function. 12759 */ 12760 function baseMatches(source) { 12761 var matchData = getMatchData(source); 12762 if (matchData.length == 1 && matchData[0][2]) { 12763 return matchesStrictComparable(matchData[0][0], matchData[0][1]); 12764 } 12765 return function(object) { 12766 return object === source || baseIsMatch(object, source, matchData); 12767 }; 12768 } 12769 12770 /** 12771 * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`. 12772 * 12773 * @private 12774 * @param {string} path The path of the property to get. 12775 * @param {*} srcValue The value to match. 12776 * @returns {Function} Returns the new spec function. 12777 */ 12778 function baseMatchesProperty(path, srcValue) { 12779 if (isKey(path) && isStrictComparable(srcValue)) { 12780 return matchesStrictComparable(toKey(path), srcValue); 12781 } 12782 return function(object) { 12783 var objValue = get(object, path); 12784 return (objValue === undefined && objValue === srcValue) 12785 ? hasIn(object, path) 12786 : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG); 12787 }; 12788 } 12789 12790 /** 12791 * The base implementation of `_.merge` without support for multiple sources. 12792 * 12793 * @private 12794 * @param {Object} object The destination object. 12795 * @param {Object} source The source object. 12796 * @param {number} srcIndex The index of `source`. 12797 * @param {Function} [customizer] The function to customize merged values. 12798 * @param {Object} [stack] Tracks traversed source values and their merged 12799 * counterparts. 12800 */ 12801 function baseMerge(object, source, srcIndex, customizer, stack) { 12802 if (object === source) { 12803 return; 12804 } 12805 baseFor(source, function(srcValue, key) { 12806 stack || (stack = new Stack); 12807 if (isObject(srcValue)) { 12808 baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); 12809 } 12810 else { 12811 var newValue = customizer 12812 ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack) 12813 : undefined; 12814 12815 if (newValue === undefined) { 12816 newValue = srcValue; 12817 } 12818 assignMergeValue(object, key, newValue); 12819 } 12820 }, keysIn); 12821 } 12822 12823 /** 12824 * A specialized version of `baseMerge` for arrays and objects which performs 12825 * deep merges and tracks traversed objects enabling objects with circular 12826 * references to be merged. 12827 * 12828 * @private 12829 * @param {Object} object The destination object. 12830 * @param {Object} source The source object. 12831 * @param {string} key The key of the value to merge. 12832 * @param {number} srcIndex The index of `source`. 12833 * @param {Function} mergeFunc The function to merge values. 12834 * @param {Function} [customizer] The function to customize assigned values. 12835 * @param {Object} [stack] Tracks traversed source values and their merged 12836 * counterparts. 12837 */ 12838 function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { 12839 var objValue = safeGet(object, key), 12840 srcValue = safeGet(source, key), 12841 stacked = stack.get(srcValue); 12842 12843 if (stacked) { 12844 assignMergeValue(object, key, stacked); 12845 return; 12846 } 12847 var newValue = customizer 12848 ? customizer(objValue, srcValue, (key + ''), object, source, stack) 12849 : undefined; 12850 12851 var isCommon = newValue === undefined; 12852 12853 if (isCommon) { 12854 var isArr = isArray(srcValue), 12855 isBuff = !isArr && isBuffer(srcValue), 12856 isTyped = !isArr && !isBuff && isTypedArray(srcValue); 12857 12858 newValue = srcValue; 12859 if (isArr || isBuff || isTyped) { 12860 if (isArray(objValue)) { 12861 newValue = objValue; 12862 } 12863 else if (isArrayLikeObject(objValue)) { 12864 newValue = copyArray(objValue); 12865 } 12866 else if (isBuff) { 12867 isCommon = false; 12868 newValue = cloneBuffer(srcValue, true); 12869 } 12870 else if (isTyped) { 12871 isCommon = false; 12872 newValue = cloneTypedArray(srcValue, true); 12873 } 12874 else { 12875 newValue = []; 12876 } 12877 } 12878 else if (isPlainObject(srcValue) || isArguments(srcValue)) { 12879 newValue = objValue; 12880 if (isArguments(objValue)) { 12881 newValue = toPlainObject(objValue); 12882 } 12883 else if (!isObject(objValue) || isFunction(objValue)) { 12884 newValue = initCloneObject(srcValue); 12885 } 12886 } 12887 else { 12888 isCommon = false; 12889 } 12890 } 12891 if (isCommon) { 12892 // Recursively merge objects and arrays (susceptible to call stack limits). 12893 stack.set(srcValue, newValue); 12894 mergeFunc(newValue, srcValue, srcIndex, customizer, stack); 12895 stack['delete'](srcValue); 12896 } 12897 assignMergeValue(object, key, newValue); 12898 } 12899 12900 /** 12901 * The base implementation of `_.nth` which doesn't coerce arguments. 12902 * 12903 * @private 12904 * @param {Array} array The array to query. 12905 * @param {number} n The index of the element to return. 12906 * @returns {*} Returns the nth element of `array`. 12907 */ 12908 function baseNth(array, n) { 12909 var length = array.length; 12910 if (!length) { 12911 return; 12912 } 12913 n += n < 0 ? length : 0; 12914 return isIndex(n, length) ? array[n] : undefined; 12915 } 12916 12917 /** 12918 * The base implementation of `_.orderBy` without param guards. 12919 * 12920 * @private 12921 * @param {Array|Object} collection The collection to iterate over. 12922 * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by. 12923 * @param {string[]} orders The sort orders of `iteratees`. 12924 * @returns {Array} Returns the new sorted array. 12925 */ 12926 function baseOrderBy(collection, iteratees, orders) { 12927 if (iteratees.length) { 12928 iteratees = arrayMap(iteratees, function(iteratee) { 12929 if (isArray(iteratee)) { 12930 return function(value) { 12931 return baseGet(value, iteratee.length === 1 ? iteratee[0] : iteratee); 12932 } 12933 } 12934 return iteratee; 12935 }); 12936 } else { 12937 iteratees = [identity]; 12938 } 12939 12940 var index = -1; 12941 iteratees = arrayMap(iteratees, baseUnary(getIteratee())); 12942 12943 var result = baseMap(collection, function(value, key, collection) { 12944 var criteria = arrayMap(iteratees, function(iteratee) { 12945 return iteratee(value); 12946 }); 12947 return { 'criteria': criteria, 'index': ++index, 'value': value }; 12948 }); 12949 12950 return baseSortBy(result, function(object, other) { 12951 return compareMultiple(object, other, orders); 12952 }); 12953 } 12954 12955 /** 12956 * The base implementation of `_.pick` without support for individual 12957 * property identifiers. 12958 * 12959 * @private 12960 * @param {Object} object The source object. 12961 * @param {string[]} paths The property paths to pick. 12962 * @returns {Object} Returns the new object. 12963 */ 12964 function basePick(object, paths) { 12965 return basePickBy(object, paths, function(value, path) { 12966 return hasIn(object, path); 12967 }); 12968 } 12969 12970 /** 12971 * The base implementation of `_.pickBy` without support for iteratee shorthands. 12972 * 12973 * @private 12974 * @param {Object} object The source object. 12975 * @param {string[]} paths The property paths to pick. 12976 * @param {Function} predicate The function invoked per property. 12977 * @returns {Object} Returns the new object. 12978 */ 12979 function basePickBy(object, paths, predicate) { 12980 var index = -1, 12981 length = paths.length, 12982 result = {}; 12983 12984 while (++index < length) { 12985 var path = paths[index], 12986 value = baseGet(object, path); 12987 12988 if (predicate(value, path)) { 12989 baseSet(result, castPath(path, object), value); 12990 } 12991 } 12992 return result; 12993 } 12994 12995 /** 12996 * A specialized version of `baseProperty` which supports deep paths. 12997 * 12998 * @private 12999 * @param {Array|string} path The path of the property to get. 13000 * @returns {Function} Returns the new accessor function. 13001 */ 13002 function basePropertyDeep(path) { 13003 return function(object) { 13004 return baseGet(object, path); 13005 }; 13006 } 13007 13008 /** 13009 * The base implementation of `_.pullAllBy` without support for iteratee 13010 * shorthands. 13011 * 13012 * @private 13013 * @param {Array} array The array to modify. 13014 * @param {Array} values The values to remove. 13015 * @param {Function} [iteratee] The iteratee invoked per element. 13016 * @param {Function} [comparator] The comparator invoked per element. 13017 * @returns {Array} Returns `array`. 13018 */ 13019 function basePullAll(array, values, iteratee, comparator) { 13020 var indexOf = comparator ? baseIndexOfWith : baseIndexOf, 13021 index = -1, 13022 length = values.length, 13023 seen = array; 13024 13025 if (array === values) { 13026 values = copyArray(values); 13027 } 13028 if (iteratee) { 13029 seen = arrayMap(array, baseUnary(iteratee)); 13030 } 13031 while (++index < length) { 13032 var fromIndex = 0, 13033 value = values[index], 13034 computed = iteratee ? iteratee(value) : value; 13035 13036 while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) { 13037 if (seen !== array) { 13038 splice.call(seen, fromIndex, 1); 13039 } 13040 splice.call(array, fromIndex, 1); 13041 } 13042 } 13043 return array; 13044 } 13045 13046 /** 13047 * The base implementation of `_.pullAt` without support for individual 13048 * indexes or capturing the removed elements. 13049 * 13050 * @private 13051 * @param {Array} array The array to modify. 13052 * @param {number[]} indexes The indexes of elements to remove. 13053 * @returns {Array} Returns `array`. 13054 */ 13055 function basePullAt(array, indexes) { 13056 var length = array ? indexes.length : 0, 13057 lastIndex = length - 1; 13058 13059 while (length--) { 13060 var index = indexes[length]; 13061 if (length == lastIndex || index !== previous) { 13062 var previous = index; 13063 if (isIndex(index)) { 13064 splice.call(array, index, 1); 13065 } else { 13066 baseUnset(array, index); 13067 } 13068 } 13069 } 13070 return array; 13071 } 13072 13073 /** 13074 * The base implementation of `_.random` without support for returning 13075 * floating-point numbers. 13076 * 13077 * @private 13078 * @param {number} lower The lower bound. 13079 * @param {number} upper The upper bound. 13080 * @returns {number} Returns the random number. 13081 */ 13082 function baseRandom(lower, upper) { 13083 return lower + nativeFloor(nativeRandom() * (upper - lower + 1)); 13084 } 13085 13086 /** 13087 * The base implementation of `_.range` and `_.rangeRight` which doesn't 13088 * coerce arguments. 13089 * 13090 * @private 13091 * @param {number} start The start of the range. 13092 * @param {number} end The end of the range. 13093 * @param {number} step The value to increment or decrement by. 13094 * @param {boolean} [fromRight] Specify iterating from right to left. 13095 * @returns {Array} Returns the range of numbers. 13096 */ 13097 function baseRange(start, end, step, fromRight) { 13098 var index = -1, 13099 length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), 13100 result = Array(length); 13101 13102 while (length--) { 13103 result[fromRight ? length : ++index] = start; 13104 start += step; 13105 } 13106 return result; 13107 } 13108 13109 /** 13110 * The base implementation of `_.repeat` which doesn't coerce arguments. 13111 * 13112 * @private 13113 * @param {string} string The string to repeat. 13114 * @param {number} n The number of times to repeat the string. 13115 * @returns {string} Returns the repeated string. 13116 */ 13117 function baseRepeat(string, n) { 13118 var result = ''; 13119 if (!string || n < 1 || n > MAX_SAFE_INTEGER) { 13120 return result; 13121 } 13122 // Leverage the exponentiation by squaring algorithm for a faster repeat. 13123 // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details. 13124 do { 13125 if (n % 2) { 13126 result += string; 13127 } 13128 n = nativeFloor(n / 2); 13129 if (n) { 13130 string += string; 13131 } 13132 } while (n); 13133 13134 return result; 13135 } 13136 13137 /** 13138 * The base implementation of `_.rest` which doesn't validate or coerce arguments. 13139 * 13140 * @private 13141 * @param {Function} func The function to apply a rest parameter to. 13142 * @param {number} [start=func.length-1] The start position of the rest parameter. 13143 * @returns {Function} Returns the new function. 13144 */ 13145 function baseRest(func, start) { 13146 return setToString(overRest(func, start, identity), func + ''); 13147 } 13148 13149 /** 13150 * The base implementation of `_.sample`. 13151 * 13152 * @private 13153 * @param {Array|Object} collection The collection to sample. 13154 * @returns {*} Returns the random element. 13155 */ 13156 function baseSample(collection) { 13157 return arraySample(values(collection)); 13158 } 13159 13160 /** 13161 * The base implementation of `_.sampleSize` without param guards. 13162 * 13163 * @private 13164 * @param {Array|Object} collection The collection to sample. 13165 * @param {number} n The number of elements to sample. 13166 * @returns {Array} Returns the random elements. 13167 */ 13168 function baseSampleSize(collection, n) { 13169 var array = values(collection); 13170 return shuffleSelf(array, baseClamp(n, 0, array.length)); 13171 } 13172 13173 /** 13174 * The base implementation of `_.set`. 13175 * 13176 * @private 13177 * @param {Object} object The object to modify. 13178 * @param {Array|string} path The path of the property to set. 13179 * @param {*} value The value to set. 13180 * @param {Function} [customizer] The function to customize path creation. 13181 * @returns {Object} Returns `object`. 13182 */ 13183 function baseSet(object, path, value, customizer) { 13184 if (!isObject(object)) { 13185 return object; 13186 } 13187 path = castPath(path, object); 13188 13189 var index = -1, 13190 length = path.length, 13191 lastIndex = length - 1, 13192 nested = object; 13193 13194 while (nested != null && ++index < length) { 13195 var key = toKey(path[index]), 13196 newValue = value; 13197 13198 if (key === '__proto__' || key === 'constructor' || key === 'prototype') { 13199 return object; 13200 } 13201 13202 if (index != lastIndex) { 13203 var objValue = nested[key]; 13204 newValue = customizer ? customizer(objValue, key, nested) : undefined; 13205 if (newValue === undefined) { 13206 newValue = isObject(objValue) 13207 ? objValue 13208 : (isIndex(path[index + 1]) ? [] : {}); 13209 } 13210 } 13211 assignValue(nested, key, newValue); 13212 nested = nested[key]; 13213 } 13214 return object; 13215 } 13216 13217 /** 13218 * The base implementation of `setData` without support for hot loop shorting. 13219 * 13220 * @private 13221 * @param {Function} func The function to associate metadata with. 13222 * @param {*} data The metadata. 13223 * @returns {Function} Returns `func`. 13224 */ 13225 var baseSetData = !metaMap ? identity : function(func, data) { 13226 metaMap.set(func, data); 13227 return func; 13228 }; 13229 13230 /** 13231 * The base implementation of `setToString` without support for hot loop shorting. 13232 * 13233 * @private 13234 * @param {Function} func The function to modify. 13235 * @param {Function} string The `toString` result. 13236 * @returns {Function} Returns `func`. 13237 */ 13238 var baseSetToString = !defineProperty ? identity : function(func, string) { 13239 return defineProperty(func, 'toString', { 13240 'configurable': true, 13241 'enumerable': false, 13242 'value': constant(string), 13243 'writable': true 13244 }); 13245 }; 13246 13247 /** 13248 * The base implementation of `_.shuffle`. 13249 * 13250 * @private 13251 * @param {Array|Object} collection The collection to shuffle. 13252 * @returns {Array} Returns the new shuffled array. 13253 */ 13254 function baseShuffle(collection) { 13255 return shuffleSelf(values(collection)); 13256 } 13257 13258 /** 13259 * The base implementation of `_.slice` without an iteratee call guard. 13260 * 13261 * @private 13262 * @param {Array} array The array to slice. 13263 * @param {number} [start=0] The start position. 13264 * @param {number} [end=array.length] The end position. 13265 * @returns {Array} Returns the slice of `array`. 13266 */ 13267 function baseSlice(array, start, end) { 13268 var index = -1, 13269 length = array.length; 13270 13271 if (start < 0) { 13272 start = -start > length ? 0 : (length + start); 13273 } 13274 end = end > length ? length : end; 13275 if (end < 0) { 13276 end += length; 13277 } 13278 length = start > end ? 0 : ((end - start) >>> 0); 13279 start >>>= 0; 13280 13281 var result = Array(length); 13282 while (++index < length) { 13283 result[index] = array[index + start]; 13284 } 13285 return result; 13286 } 13287 13288 /** 13289 * The base implementation of `_.some` without support for iteratee shorthands. 13290 * 13291 * @private 13292 * @param {Array|Object} collection The collection to iterate over. 13293 * @param {Function} predicate The function invoked per iteration. 13294 * @returns {boolean} Returns `true` if any element passes the predicate check, 13295 * else `false`. 13296 */ 13297 function baseSome(collection, predicate) { 13298 var result; 13299 13300 baseEach(collection, function(value, index, collection) { 13301 result = predicate(value, index, collection); 13302 return !result; 13303 }); 13304 return !!result; 13305 } 13306 13307 /** 13308 * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which 13309 * performs a binary search of `array` to determine the index at which `value` 13310 * should be inserted into `array` in order to maintain its sort order. 13311 * 13312 * @private 13313 * @param {Array} array The sorted array to inspect. 13314 * @param {*} value The value to evaluate. 13315 * @param {boolean} [retHighest] Specify returning the highest qualified index. 13316 * @returns {number} Returns the index at which `value` should be inserted 13317 * into `array`. 13318 */ 13319 function baseSortedIndex(array, value, retHighest) { 13320 var low = 0, 13321 high = array == null ? low : array.length; 13322 13323 if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) { 13324 while (low < high) { 13325 var mid = (low + high) >>> 1, 13326 computed = array[mid]; 13327 13328 if (computed !== null && !isSymbol(computed) && 13329 (retHighest ? (computed <= value) : (computed < value))) { 13330 low = mid + 1; 13331 } else { 13332 high = mid; 13333 } 13334 } 13335 return high; 13336 } 13337 return baseSortedIndexBy(array, value, identity, retHighest); 13338 } 13339 13340 /** 13341 * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy` 13342 * which invokes `iteratee` for `value` and each element of `array` to compute 13343 * their sort ranking. The iteratee is invoked with one argument; (value). 13344 * 13345 * @private 13346 * @param {Array} array The sorted array to inspect. 13347 * @param {*} value The value to evaluate. 13348 * @param {Function} iteratee The iteratee invoked per element. 13349 * @param {boolean} [retHighest] Specify returning the highest qualified index. 13350 * @returns {number} Returns the index at which `value` should be inserted 13351 * into `array`. 13352 */ 13353 function baseSortedIndexBy(array, value, iteratee, retHighest) { 13354 var low = 0, 13355 high = array == null ? 0 : array.length; 13356 if (high === 0) { 13357 return 0; 13358 } 13359 13360 value = iteratee(value); 13361 var valIsNaN = value !== value, 13362 valIsNull = value === null, 13363 valIsSymbol = isSymbol(value), 13364 valIsUndefined = value === undefined; 13365 13366 while (low < high) { 13367 var mid = nativeFloor((low + high) / 2), 13368 computed = iteratee(array[mid]), 13369 othIsDefined = computed !== undefined, 13370 othIsNull = computed === null, 13371 othIsReflexive = computed === computed, 13372 othIsSymbol = isSymbol(computed); 13373 13374 if (valIsNaN) { 13375 var setLow = retHighest || othIsReflexive; 13376 } else if (valIsUndefined) { 13377 setLow = othIsReflexive && (retHighest || othIsDefined); 13378 } else if (valIsNull) { 13379 setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull); 13380 } else if (valIsSymbol) { 13381 setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol); 13382 } else if (othIsNull || othIsSymbol) { 13383 setLow = false; 13384 } else { 13385 setLow = retHighest ? (computed <= value) : (computed < value); 13386 } 13387 if (setLow) { 13388 low = mid + 1; 13389 } else { 13390 high = mid; 13391 } 13392 } 13393 return nativeMin(high, MAX_ARRAY_INDEX); 13394 } 13395 13396 /** 13397 * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without 13398 * support for iteratee shorthands. 13399 * 13400 * @private 13401 * @param {Array} array The array to inspect. 13402 * @param {Function} [iteratee] The iteratee invoked per element. 13403 * @returns {Array} Returns the new duplicate free array. 13404 */ 13405 function baseSortedUniq(array, iteratee) { 13406 var index = -1, 13407 length = array.length, 13408 resIndex = 0, 13409 result = []; 13410 13411 while (++index < length) { 13412 var value = array[index], 13413 computed = iteratee ? iteratee(value) : value; 13414 13415 if (!index || !eq(computed, seen)) { 13416 var seen = computed; 13417 result[resIndex++] = value === 0 ? 0 : value; 13418 } 13419 } 13420 return result; 13421 } 13422 13423 /** 13424 * The base implementation of `_.toNumber` which doesn't ensure correct 13425 * conversions of binary, hexadecimal, or octal string values. 13426 * 13427 * @private 13428 * @param {*} value The value to process. 13429 * @returns {number} Returns the number. 13430 */ 13431 function baseToNumber(value) { 13432 if (typeof value == 'number') { 13433 return value; 13434 } 13435 if (isSymbol(value)) { 13436 return NAN; 13437 } 13438 return +value; 13439 } 13440 13441 /** 13442 * The base implementation of `_.toString` which doesn't convert nullish 13443 * values to empty strings. 13444 * 13445 * @private 13446 * @param {*} value The value to process. 13447 * @returns {string} Returns the string. 13448 */ 13449 function baseToString(value) { 13450 // Exit early for strings to avoid a performance hit in some environments. 13451 if (typeof value == 'string') { 13452 return value; 13453 } 13454 if (isArray(value)) { 13455 // Recursively convert values (susceptible to call stack limits). 13456 return arrayMap(value, baseToString) + ''; 13457 } 13458 if (isSymbol(value)) { 13459 return symbolToString ? symbolToString.call(value) : ''; 13460 } 13461 var result = (value + ''); 13462 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; 13463 } 13464 13465 /** 13466 * The base implementation of `_.uniqBy` without support for iteratee shorthands. 13467 * 13468 * @private 13469 * @param {Array} array The array to inspect. 13470 * @param {Function} [iteratee] The iteratee invoked per element. 13471 * @param {Function} [comparator] The comparator invoked per element. 13472 * @returns {Array} Returns the new duplicate free array. 13473 */ 13474 function baseUniq(array, iteratee, comparator) { 13475 var index = -1, 13476 includes = arrayIncludes, 13477 length = array.length, 13478 isCommon = true, 13479 result = [], 13480 seen = result; 13481 13482 if (comparator) { 13483 isCommon = false; 13484 includes = arrayIncludesWith; 13485 } 13486 else if (length >= LARGE_ARRAY_SIZE) { 13487 var set = iteratee ? null : createSet(array); 13488 if (set) { 13489 return setToArray(set); 13490 } 13491 isCommon = false; 13492 includes = cacheHas; 13493 seen = new SetCache; 13494 } 13495 else { 13496 seen = iteratee ? [] : result; 13497 } 13498 outer: 13499 while (++index < length) { 13500 var value = array[index], 13501 computed = iteratee ? iteratee(value) : value; 13502 13503 value = (comparator || value !== 0) ? value : 0; 13504 if (isCommon && computed === computed) { 13505 var seenIndex = seen.length; 13506 while (seenIndex--) { 13507 if (seen[seenIndex] === computed) { 13508 continue outer; 13509 } 13510 } 13511 if (iteratee) { 13512 seen.push(computed); 13513 } 13514 result.push(value); 13515 } 13516 else if (!includes(seen, computed, comparator)) { 13517 if (seen !== result) { 13518 seen.push(computed); 13519 } 13520 result.push(value); 13521 } 13522 } 13523 return result; 13524 } 13525 13526 /** 13527 * The base implementation of `_.unset`. 13528 * 13529 * @private 13530 * @param {Object} object The object to modify. 13531 * @param {Array|string} path The property path to unset. 13532 * @returns {boolean} Returns `true` if the property is deleted, else `false`. 13533 */ 13534 function baseUnset(object, path) { 13535 path = castPath(path, object); 13536 object = parent(object, path); 13537 return object == null || delete object[toKey(last(path))]; 13538 } 13539 13540 /** 13541 * The base implementation of `_.update`. 13542 * 13543 * @private 13544 * @param {Object} object The object to modify. 13545 * @param {Array|string} path The path of the property to update. 13546 * @param {Function} updater The function to produce the updated value. 13547 * @param {Function} [customizer] The function to customize path creation. 13548 * @returns {Object} Returns `object`. 13549 */ 13550 function baseUpdate(object, path, updater, customizer) { 13551 return baseSet(object, path, updater(baseGet(object, path)), customizer); 13552 } 13553 13554 /** 13555 * The base implementation of methods like `_.dropWhile` and `_.takeWhile` 13556 * without support for iteratee shorthands. 13557 * 13558 * @private 13559 * @param {Array} array The array to query. 13560 * @param {Function} predicate The function invoked per iteration. 13561 * @param {boolean} [isDrop] Specify dropping elements instead of taking them. 13562 * @param {boolean} [fromRight] Specify iterating from right to left. 13563 * @returns {Array} Returns the slice of `array`. 13564 */ 13565 function baseWhile(array, predicate, isDrop, fromRight) { 13566 var length = array.length, 13567 index = fromRight ? length : -1; 13568 13569 while ((fromRight ? index-- : ++index < length) && 13570 predicate(array[index], index, array)) {} 13571 13572 return isDrop 13573 ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length)) 13574 : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index)); 13575 } 13576 13577 /** 13578 * The base implementation of `wrapperValue` which returns the result of 13579 * performing a sequence of actions on the unwrapped `value`, where each 13580 * successive action is supplied the return value of the previous. 13581 * 13582 * @private 13583 * @param {*} value The unwrapped value. 13584 * @param {Array} actions Actions to perform to resolve the unwrapped value. 13585 * @returns {*} Returns the resolved value. 13586 */ 13587 function baseWrapperValue(value, actions) { 13588 var result = value; 13589 if (result instanceof LazyWrapper) { 13590 result = result.value(); 13591 } 13592 return arrayReduce(actions, function(result, action) { 13593 return action.func.apply(action.thisArg, arrayPush([result], action.args)); 13594 }, result); 13595 } 13596 13597 /** 13598 * The base implementation of methods like `_.xor`, without support for 13599 * iteratee shorthands, that accepts an array of arrays to inspect. 13600 * 13601 * @private 13602 * @param {Array} arrays The arrays to inspect. 13603 * @param {Function} [iteratee] The iteratee invoked per element. 13604 * @param {Function} [comparator] The comparator invoked per element. 13605 * @returns {Array} Returns the new array of values. 13606 */ 13607 function baseXor(arrays, iteratee, comparator) { 13608 var length = arrays.length; 13609 if (length < 2) { 13610 return length ? baseUniq(arrays[0]) : []; 13611 } 13612 var index = -1, 13613 result = Array(length); 13614 13615 while (++index < length) { 13616 var array = arrays[index], 13617 othIndex = -1; 13618 13619 while (++othIndex < length) { 13620 if (othIndex != index) { 13621 result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator); 13622 } 13623 } 13624 } 13625 return baseUniq(baseFlatten(result, 1), iteratee, comparator); 13626 } 13627 13628 /** 13629 * This base implementation of `_.zipObject` which assigns values using `assignFunc`. 13630 * 13631 * @private 13632 * @param {Array} props The property identifiers. 13633 * @param {Array} values The property values. 13634 * @param {Function} assignFunc The function to assign values. 13635 * @returns {Object} Returns the new object. 13636 */ 13637 function baseZipObject(props, values, assignFunc) { 13638 var index = -1, 13639 length = props.length, 13640 valsLength = values.length, 13641 result = {}; 13642 13643 while (++index < length) { 13644 var value = index < valsLength ? values[index] : undefined; 13645 assignFunc(result, props[index], value); 13646 } 13647 return result; 13648 } 13649 13650 /** 13651 * Casts `value` to an empty array if it's not an array like object. 13652 * 13653 * @private 13654 * @param {*} value The value to inspect. 13655 * @returns {Array|Object} Returns the cast array-like object. 13656 */ 13657 function castArrayLikeObject(value) { 13658 return isArrayLikeObject(value) ? value : []; 13659 } 13660 13661 /** 13662 * Casts `value` to `identity` if it's not a function. 13663 * 13664 * @private 13665 * @param {*} value The value to inspect. 13666 * @returns {Function} Returns cast function. 13667 */ 13668 function castFunction(value) { 13669 return typeof value == 'function' ? value : identity; 13670 } 13671 13672 /** 13673 * Casts `value` to a path array if it's not one. 13674 * 13675 * @private 13676 * @param {*} value The value to inspect. 13677 * @param {Object} [object] The object to query keys on. 13678 * @returns {Array} Returns the cast property path array. 13679 */ 13680 function castPath(value, object) { 13681 if (isArray(value)) { 13682 return value; 13683 } 13684 return isKey(value, object) ? [value] : stringToPath(toString(value)); 13685 } 13686 13687 /** 13688 * A `baseRest` alias which can be replaced with `identity` by module 13689 * replacement plugins. 13690 * 13691 * @private 13692 * @type {Function} 13693 * @param {Function} func The function to apply a rest parameter to. 13694 * @returns {Function} Returns the new function. 13695 */ 13696 var castRest = baseRest; 13697 13698 /** 13699 * Casts `array` to a slice if it's needed. 13700 * 13701 * @private 13702 * @param {Array} array The array to inspect. 13703 * @param {number} start The start position. 13704 * @param {number} [end=array.length] The end position. 13705 * @returns {Array} Returns the cast slice. 13706 */ 13707 function castSlice(array, start, end) { 13708 var length = array.length; 13709 end = end === undefined ? length : end; 13710 return (!start && end >= length) ? array : baseSlice(array, start, end); 13711 } 13712 13713 /** 13714 * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout). 13715 * 13716 * @private 13717 * @param {number|Object} id The timer id or timeout object of the timer to clear. 13718 */ 13719 var clearTimeout = ctxClearTimeout || function(id) { 13720 return root.clearTimeout(id); 13721 }; 13722 13723 /** 13724 * Creates a clone of `buffer`. 13725 * 13726 * @private 13727 * @param {Buffer} buffer The buffer to clone. 13728 * @param {boolean} [isDeep] Specify a deep clone. 13729 * @returns {Buffer} Returns the cloned buffer. 13730 */ 13731 function cloneBuffer(buffer, isDeep) { 13732 if (isDeep) { 13733 return buffer.slice(); 13734 } 13735 var length = buffer.length, 13736 result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length); 13737 13738 buffer.copy(result); 13739 return result; 13740 } 13741 13742 /** 13743 * Creates a clone of `arrayBuffer`. 13744 * 13745 * @private 13746 * @param {ArrayBuffer} arrayBuffer The array buffer to clone. 13747 * @returns {ArrayBuffer} Returns the cloned array buffer. 13748 */ 13749 function cloneArrayBuffer(arrayBuffer) { 13750 var result = new arrayBuffer.constructor(arrayBuffer.byteLength); 13751 new Uint8Array(result).set(new Uint8Array(arrayBuffer)); 13752 return result; 13753 } 13754 13755 /** 13756 * Creates a clone of `dataView`. 13757 * 13758 * @private 13759 * @param {Object} dataView The data view to clone. 13760 * @param {boolean} [isDeep] Specify a deep clone. 13761 * @returns {Object} Returns the cloned data view. 13762 */ 13763 function cloneDataView(dataView, isDeep) { 13764 var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer; 13765 return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength); 13766 } 13767 13768 /** 13769 * Creates a clone of `regexp`. 13770 * 13771 * @private 13772 * @param {Object} regexp The regexp to clone. 13773 * @returns {Object} Returns the cloned regexp. 13774 */ 13775 function cloneRegExp(regexp) { 13776 var result = new regexp.constructor(regexp.source, reFlags.exec(regexp)); 13777 result.lastIndex = regexp.lastIndex; 13778 return result; 13779 } 13780 13781 /** 13782 * Creates a clone of the `symbol` object. 13783 * 13784 * @private 13785 * @param {Object} symbol The symbol object to clone. 13786 * @returns {Object} Returns the cloned symbol object. 13787 */ 13788 function cloneSymbol(symbol) { 13789 return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {}; 13790 } 13791 13792 /** 13793 * Creates a clone of `typedArray`. 13794 * 13795 * @private 13796 * @param {Object} typedArray The typed array to clone. 13797 * @param {boolean} [isDeep] Specify a deep clone. 13798 * @returns {Object} Returns the cloned typed array. 13799 */ 13800 function cloneTypedArray(typedArray, isDeep) { 13801 var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer; 13802 return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length); 13803 } 13804 13805 /** 13806 * Compares values to sort them in ascending order. 13807 * 13808 * @private 13809 * @param {*} value The value to compare. 13810 * @param {*} other The other value to compare. 13811 * @returns {number} Returns the sort order indicator for `value`. 13812 */ 13813 function compareAscending(value, other) { 13814 if (value !== other) { 13815 var valIsDefined = value !== undefined, 13816 valIsNull = value === null, 13817 valIsReflexive = value === value, 13818 valIsSymbol = isSymbol(value); 13819 13820 var othIsDefined = other !== undefined, 13821 othIsNull = other === null, 13822 othIsReflexive = other === other, 13823 othIsSymbol = isSymbol(other); 13824 13825 if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) || 13826 (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) || 13827 (valIsNull && othIsDefined && othIsReflexive) || 13828 (!valIsDefined && othIsReflexive) || 13829 !valIsReflexive) { 13830 return 1; 13831 } 13832 if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) || 13833 (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) || 13834 (othIsNull && valIsDefined && valIsReflexive) || 13835 (!othIsDefined && valIsReflexive) || 13836 !othIsReflexive) { 13837 return -1; 13838 } 13839 } 13840 return 0; 13841 } 13842 13843 /** 13844 * Used by `_.orderBy` to compare multiple properties of a value to another 13845 * and stable sort them. 13846 * 13847 * If `orders` is unspecified, all values are sorted in ascending order. Otherwise, 13848 * specify an order of "desc" for descending or "asc" for ascending sort order 13849 * of corresponding values. 13850 * 13851 * @private 13852 * @param {Object} object The object to compare. 13853 * @param {Object} other The other object to compare. 13854 * @param {boolean[]|string[]} orders The order to sort by for each property. 13855 * @returns {number} Returns the sort order indicator for `object`. 13856 */ 13857 function compareMultiple(object, other, orders) { 13858 var index = -1, 13859 objCriteria = object.criteria, 13860 othCriteria = other.criteria, 13861 length = objCriteria.length, 13862 ordersLength = orders.length; 13863 13864 while (++index < length) { 13865 var result = compareAscending(objCriteria[index], othCriteria[index]); 13866 if (result) { 13867 if (index >= ordersLength) { 13868 return result; 13869 } 13870 var order = orders[index]; 13871 return result * (order == 'desc' ? -1 : 1); 13872 } 13873 } 13874 // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications 13875 // that causes it, under certain circumstances, to provide the same value for 13876 // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247 13877 // for more details. 13878 // 13879 // This also ensures a stable sort in V8 and other engines. 13880 // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details. 13881 return object.index - other.index; 13882 } 13883 13884 /** 13885 * Creates an array that is the composition of partially applied arguments, 13886 * placeholders, and provided arguments into a single array of arguments. 13887 * 13888 * @private 13889 * @param {Array} args The provided arguments. 13890 * @param {Array} partials The arguments to prepend to those provided. 13891 * @param {Array} holders The `partials` placeholder indexes. 13892 * @params {boolean} [isCurried] Specify composing for a curried function. 13893 * @returns {Array} Returns the new array of composed arguments. 13894 */ 13895 function composeArgs(args, partials, holders, isCurried) { 13896 var argsIndex = -1, 13897 argsLength = args.length, 13898 holdersLength = holders.length, 13899 leftIndex = -1, 13900 leftLength = partials.length, 13901 rangeLength = nativeMax(argsLength - holdersLength, 0), 13902 result = Array(leftLength + rangeLength), 13903 isUncurried = !isCurried; 13904 13905 while (++leftIndex < leftLength) { 13906 result[leftIndex] = partials[leftIndex]; 13907 } 13908 while (++argsIndex < holdersLength) { 13909 if (isUncurried || argsIndex < argsLength) { 13910 result[holders[argsIndex]] = args[argsIndex]; 13911 } 13912 } 13913 while (rangeLength--) { 13914 result[leftIndex++] = args[argsIndex++]; 13915 } 13916 return result; 13917 } 13918 13919 /** 13920 * This function is like `composeArgs` except that the arguments composition 13921 * is tailored for `_.partialRight`. 13922 * 13923 * @private 13924 * @param {Array} args The provided arguments. 13925 * @param {Array} partials The arguments to append to those provided. 13926 * @param {Array} holders The `partials` placeholder indexes. 13927 * @params {boolean} [isCurried] Specify composing for a curried function. 13928 * @returns {Array} Returns the new array of composed arguments. 13929 */ 13930 function composeArgsRight(args, partials, holders, isCurried) { 13931 var argsIndex = -1, 13932 argsLength = args.length, 13933 holdersIndex = -1, 13934 holdersLength = holders.length, 13935 rightIndex = -1, 13936 rightLength = partials.length, 13937 rangeLength = nativeMax(argsLength - holdersLength, 0), 13938 result = Array(rangeLength + rightLength), 13939 isUncurried = !isCurried; 13940 13941 while (++argsIndex < rangeLength) { 13942 result[argsIndex] = args[argsIndex]; 13943 } 13944 var offset = argsIndex; 13945 while (++rightIndex < rightLength) { 13946 result[offset + rightIndex] = partials[rightIndex]; 13947 } 13948 while (++holdersIndex < holdersLength) { 13949 if (isUncurried || argsIndex < argsLength) { 13950 result[offset + holders[holdersIndex]] = args[argsIndex++]; 13951 } 13952 } 13953 return result; 13954 } 13955 13956 /** 13957 * Copies the values of `source` to `array`. 13958 * 13959 * @private 13960 * @param {Array} source The array to copy values from. 13961 * @param {Array} [array=[]] The array to copy values to. 13962 * @returns {Array} Returns `array`. 13963 */ 13964 function copyArray(source, array) { 13965 var index = -1, 13966 length = source.length; 13967 13968 array || (array = Array(length)); 13969 while (++index < length) { 13970 array[index] = source[index]; 13971 } 13972 return array; 13973 } 13974 13975 /** 13976 * Copies properties of `source` to `object`. 13977 * 13978 * @private 13979 * @param {Object} source The object to copy properties from. 13980 * @param {Array} props The property identifiers to copy. 13981 * @param {Object} [object={}] The object to copy properties to. 13982 * @param {Function} [customizer] The function to customize copied values. 13983 * @returns {Object} Returns `object`. 13984 */ 13985 function copyObject(source, props, object, customizer) { 13986 var isNew = !object; 13987 object || (object = {}); 13988 13989 var index = -1, 13990 length = props.length; 13991 13992 while (++index < length) { 13993 var key = props[index]; 13994 13995 var newValue = customizer 13996 ? customizer(object[key], source[key], key, object, source) 13997 : undefined; 13998 13999 if (newValue === undefined) { 14000 newValue = source[key]; 14001 } 14002 if (isNew) { 14003 baseAssignValue(object, key, newValue); 14004 } else { 14005 assignValue(object, key, newValue); 14006 } 14007 } 14008 return object; 14009 } 14010 14011 /** 14012 * Copies own symbols of `source` to `object`. 14013 * 14014 * @private 14015 * @param {Object} source The object to copy symbols from. 14016 * @param {Object} [object={}] The object to copy symbols to. 14017 * @returns {Object} Returns `object`. 14018 */ 14019 function copySymbols(source, object) { 14020 return copyObject(source, getSymbols(source), object); 14021 } 14022 14023 /** 14024 * Copies own and inherited symbols of `source` to `object`. 14025 * 14026 * @private 14027 * @param {Object} source The object to copy symbols from. 14028 * @param {Object} [object={}] The object to copy symbols to. 14029 * @returns {Object} Returns `object`. 14030 */ 14031 function copySymbolsIn(source, object) { 14032 return copyObject(source, getSymbolsIn(source), object); 14033 } 14034 14035 /** 14036 * Creates a function like `_.groupBy`. 14037 * 14038 * @private 14039 * @param {Function} setter The function to set accumulator values. 14040 * @param {Function} [initializer] The accumulator object initializer. 14041 * @returns {Function} Returns the new aggregator function. 14042 */ 14043 function createAggregator(setter, initializer) { 14044 return function(collection, iteratee) { 14045 var func = isArray(collection) ? arrayAggregator : baseAggregator, 14046 accumulator = initializer ? initializer() : {}; 14047 14048 return func(collection, setter, getIteratee(iteratee, 2), accumulator); 14049 }; 14050 } 14051 14052 /** 14053 * Creates a function like `_.assign`. 14054 * 14055 * @private 14056 * @param {Function} assigner The function to assign values. 14057 * @returns {Function} Returns the new assigner function. 14058 */ 14059 function createAssigner(assigner) { 14060 return baseRest(function(object, sources) { 14061 var index = -1, 14062 length = sources.length, 14063 customizer = length > 1 ? sources[length - 1] : undefined, 14064 guard = length > 2 ? sources[2] : undefined; 14065 14066 customizer = (assigner.length > 3 && typeof customizer == 'function') 14067 ? (length--, customizer) 14068 : undefined; 14069 14070 if (guard && isIterateeCall(sources[0], sources[1], guard)) { 14071 customizer = length < 3 ? undefined : customizer; 14072 length = 1; 14073 } 14074 object = Object(object); 14075 while (++index < length) { 14076 var source = sources[index]; 14077 if (source) { 14078 assigner(object, source, index, customizer); 14079 } 14080 } 14081 return object; 14082 }); 14083 } 14084 14085 /** 14086 * Creates a `baseEach` or `baseEachRight` function. 14087 * 14088 * @private 14089 * @param {Function} eachFunc The function to iterate over a collection. 14090 * @param {boolean} [fromRight] Specify iterating from right to left. 14091 * @returns {Function} Returns the new base function. 14092 */ 14093 function createBaseEach(eachFunc, fromRight) { 14094 return function(collection, iteratee) { 14095 if (collection == null) { 14096 return collection; 14097 } 14098 if (!isArrayLike(collection)) { 14099 return eachFunc(collection, iteratee); 14100 } 14101 var length = collection.length, 14102 index = fromRight ? length : -1, 14103 iterable = Object(collection); 14104 14105 while ((fromRight ? index-- : ++index < length)) { 14106 if (iteratee(iterable[index], index, iterable) === false) { 14107 break; 14108 } 14109 } 14110 return collection; 14111 }; 14112 } 14113 14114 /** 14115 * Creates a base function for methods like `_.forIn` and `_.forOwn`. 14116 * 14117 * @private 14118 * @param {boolean} [fromRight] Specify iterating from right to left. 14119 * @returns {Function} Returns the new base function. 14120 */ 14121 function createBaseFor(fromRight) { 14122 return function(object, iteratee, keysFunc) { 14123 var index = -1, 14124 iterable = Object(object), 14125 props = keysFunc(object), 14126 length = props.length; 14127 14128 while (length--) { 14129 var key = props[fromRight ? length : ++index]; 14130 if (iteratee(iterable[key], key, iterable) === false) { 14131 break; 14132 } 14133 } 14134 return object; 14135 }; 14136 } 14137 14138 /** 14139 * Creates a function that wraps `func` to invoke it with the optional `this` 14140 * binding of `thisArg`. 14141 * 14142 * @private 14143 * @param {Function} func The function to wrap. 14144 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 14145 * @param {*} [thisArg] The `this` binding of `func`. 14146 * @returns {Function} Returns the new wrapped function. 14147 */ 14148 function createBind(func, bitmask, thisArg) { 14149 var isBind = bitmask & WRAP_BIND_FLAG, 14150 Ctor = createCtor(func); 14151 14152 function wrapper() { 14153 var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; 14154 return fn.apply(isBind ? thisArg : this, arguments); 14155 } 14156 return wrapper; 14157 } 14158 14159 /** 14160 * Creates a function like `_.lowerFirst`. 14161 * 14162 * @private 14163 * @param {string} methodName The name of the `String` case method to use. 14164 * @returns {Function} Returns the new case function. 14165 */ 14166 function createCaseFirst(methodName) { 14167 return function(string) { 14168 string = toString(string); 14169 14170 var strSymbols = hasUnicode(string) 14171 ? stringToArray(string) 14172 : undefined; 14173 14174 var chr = strSymbols 14175 ? strSymbols[0] 14176 : string.charAt(0); 14177 14178 var trailing = strSymbols 14179 ? castSlice(strSymbols, 1).join('') 14180 : string.slice(1); 14181 14182 return chr[methodName]() + trailing; 14183 }; 14184 } 14185 14186 /** 14187 * Creates a function like `_.camelCase`. 14188 * 14189 * @private 14190 * @param {Function} callback The function to combine each word. 14191 * @returns {Function} Returns the new compounder function. 14192 */ 14193 function createCompounder(callback) { 14194 return function(string) { 14195 return arrayReduce(words(deburr(string).replace(reApos, '')), callback, ''); 14196 }; 14197 } 14198 14199 /** 14200 * Creates a function that produces an instance of `Ctor` regardless of 14201 * whether it was invoked as part of a `new` expression or by `call` or `apply`. 14202 * 14203 * @private 14204 * @param {Function} Ctor The constructor to wrap. 14205 * @returns {Function} Returns the new wrapped function. 14206 */ 14207 function createCtor(Ctor) { 14208 return function() { 14209 // Use a `switch` statement to work with class constructors. See 14210 // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist 14211 // for more details. 14212 var args = arguments; 14213 switch (args.length) { 14214 case 0: return new Ctor; 14215 case 1: return new Ctor(args[0]); 14216 case 2: return new Ctor(args[0], args[1]); 14217 case 3: return new Ctor(args[0], args[1], args[2]); 14218 case 4: return new Ctor(args[0], args[1], args[2], args[3]); 14219 case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]); 14220 case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]); 14221 case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]); 14222 } 14223 var thisBinding = baseCreate(Ctor.prototype), 14224 result = Ctor.apply(thisBinding, args); 14225 14226 // Mimic the constructor's `return` behavior. 14227 // See https://es5.github.io/#x13.2.2 for more details. 14228 return isObject(result) ? result : thisBinding; 14229 }; 14230 } 14231 14232 /** 14233 * Creates a function that wraps `func` to enable currying. 14234 * 14235 * @private 14236 * @param {Function} func The function to wrap. 14237 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 14238 * @param {number} arity The arity of `func`. 14239 * @returns {Function} Returns the new wrapped function. 14240 */ 14241 function createCurry(func, bitmask, arity) { 14242 var Ctor = createCtor(func); 14243 14244 function wrapper() { 14245 var length = arguments.length, 14246 args = Array(length), 14247 index = length, 14248 placeholder = getHolder(wrapper); 14249 14250 while (index--) { 14251 args[index] = arguments[index]; 14252 } 14253 var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder) 14254 ? [] 14255 : replaceHolders(args, placeholder); 14256 14257 length -= holders.length; 14258 if (length < arity) { 14259 return createRecurry( 14260 func, bitmask, createHybrid, wrapper.placeholder, undefined, 14261 args, holders, undefined, undefined, arity - length); 14262 } 14263 var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; 14264 return apply(fn, this, args); 14265 } 14266 return wrapper; 14267 } 14268 14269 /** 14270 * Creates a `_.find` or `_.findLast` function. 14271 * 14272 * @private 14273 * @param {Function} findIndexFunc The function to find the collection index. 14274 * @returns {Function} Returns the new find function. 14275 */ 14276 function createFind(findIndexFunc) { 14277 return function(collection, predicate, fromIndex) { 14278 var iterable = Object(collection); 14279 if (!isArrayLike(collection)) { 14280 var iteratee = getIteratee(predicate, 3); 14281 collection = keys(collection); 14282 predicate = function(key) { return iteratee(iterable[key], key, iterable); }; 14283 } 14284 var index = findIndexFunc(collection, predicate, fromIndex); 14285 return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined; 14286 }; 14287 } 14288 14289 /** 14290 * Creates a `_.flow` or `_.flowRight` function. 14291 * 14292 * @private 14293 * @param {boolean} [fromRight] Specify iterating from right to left. 14294 * @returns {Function} Returns the new flow function. 14295 */ 14296 function createFlow(fromRight) { 14297 return flatRest(function(funcs) { 14298 var length = funcs.length, 14299 index = length, 14300 prereq = LodashWrapper.prototype.thru; 14301 14302 if (fromRight) { 14303 funcs.reverse(); 14304 } 14305 while (index--) { 14306 var func = funcs[index]; 14307 if (typeof func != 'function') { 14308 throw new TypeError(FUNC_ERROR_TEXT); 14309 } 14310 if (prereq && !wrapper && getFuncName(func) == 'wrapper') { 14311 var wrapper = new LodashWrapper([], true); 14312 } 14313 } 14314 index = wrapper ? index : length; 14315 while (++index < length) { 14316 func = funcs[index]; 14317 14318 var funcName = getFuncName(func), 14319 data = funcName == 'wrapper' ? getData(func) : undefined; 14320 14321 if (data && isLaziable(data[0]) && 14322 data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) && 14323 !data[4].length && data[9] == 1 14324 ) { 14325 wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]); 14326 } else { 14327 wrapper = (func.length == 1 && isLaziable(func)) 14328 ? wrapper[funcName]() 14329 : wrapper.thru(func); 14330 } 14331 } 14332 return function() { 14333 var args = arguments, 14334 value = args[0]; 14335 14336 if (wrapper && args.length == 1 && isArray(value)) { 14337 return wrapper.plant(value).value(); 14338 } 14339 var index = 0, 14340 result = length ? funcs[index].apply(this, args) : value; 14341 14342 while (++index < length) { 14343 result = funcs[index].call(this, result); 14344 } 14345 return result; 14346 }; 14347 }); 14348 } 14349 14350 /** 14351 * Creates a function that wraps `func` to invoke it with optional `this` 14352 * binding of `thisArg`, partial application, and currying. 14353 * 14354 * @private 14355 * @param {Function|string} func The function or method name to wrap. 14356 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 14357 * @param {*} [thisArg] The `this` binding of `func`. 14358 * @param {Array} [partials] The arguments to prepend to those provided to 14359 * the new function. 14360 * @param {Array} [holders] The `partials` placeholder indexes. 14361 * @param {Array} [partialsRight] The arguments to append to those provided 14362 * to the new function. 14363 * @param {Array} [holdersRight] The `partialsRight` placeholder indexes. 14364 * @param {Array} [argPos] The argument positions of the new function. 14365 * @param {number} [ary] The arity cap of `func`. 14366 * @param {number} [arity] The arity of `func`. 14367 * @returns {Function} Returns the new wrapped function. 14368 */ 14369 function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) { 14370 var isAry = bitmask & WRAP_ARY_FLAG, 14371 isBind = bitmask & WRAP_BIND_FLAG, 14372 isBindKey = bitmask & WRAP_BIND_KEY_FLAG, 14373 isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG), 14374 isFlip = bitmask & WRAP_FLIP_FLAG, 14375 Ctor = isBindKey ? undefined : createCtor(func); 14376 14377 function wrapper() { 14378 var length = arguments.length, 14379 args = Array(length), 14380 index = length; 14381 14382 while (index--) { 14383 args[index] = arguments[index]; 14384 } 14385 if (isCurried) { 14386 var placeholder = getHolder(wrapper), 14387 holdersCount = countHolders(args, placeholder); 14388 } 14389 if (partials) { 14390 args = composeArgs(args, partials, holders, isCurried); 14391 } 14392 if (partialsRight) { 14393 args = composeArgsRight(args, partialsRight, holdersRight, isCurried); 14394 } 14395 length -= holdersCount; 14396 if (isCurried && length < arity) { 14397 var newHolders = replaceHolders(args, placeholder); 14398 return createRecurry( 14399 func, bitmask, createHybrid, wrapper.placeholder, thisArg, 14400 args, newHolders, argPos, ary, arity - length 14401 ); 14402 } 14403 var thisBinding = isBind ? thisArg : this, 14404 fn = isBindKey ? thisBinding[func] : func; 14405 14406 length = args.length; 14407 if (argPos) { 14408 args = reorder(args, argPos); 14409 } else if (isFlip && length > 1) { 14410 args.reverse(); 14411 } 14412 if (isAry && ary < length) { 14413 args.length = ary; 14414 } 14415 if (this && this !== root && this instanceof wrapper) { 14416 fn = Ctor || createCtor(fn); 14417 } 14418 return fn.apply(thisBinding, args); 14419 } 14420 return wrapper; 14421 } 14422 14423 /** 14424 * Creates a function like `_.invertBy`. 14425 * 14426 * @private 14427 * @param {Function} setter The function to set accumulator values. 14428 * @param {Function} toIteratee The function to resolve iteratees. 14429 * @returns {Function} Returns the new inverter function. 14430 */ 14431 function createInverter(setter, toIteratee) { 14432 return function(object, iteratee) { 14433 return baseInverter(object, setter, toIteratee(iteratee), {}); 14434 }; 14435 } 14436 14437 /** 14438 * Creates a function that performs a mathematical operation on two values. 14439 * 14440 * @private 14441 * @param {Function} operator The function to perform the operation. 14442 * @param {number} [defaultValue] The value used for `undefined` arguments. 14443 * @returns {Function} Returns the new mathematical operation function. 14444 */ 14445 function createMathOperation(operator, defaultValue) { 14446 return function(value, other) { 14447 var result; 14448 if (value === undefined && other === undefined) { 14449 return defaultValue; 14450 } 14451 if (value !== undefined) { 14452 result = value; 14453 } 14454 if (other !== undefined) { 14455 if (result === undefined) { 14456 return other; 14457 } 14458 if (typeof value == 'string' || typeof other == 'string') { 14459 value = baseToString(value); 14460 other = baseToString(other); 14461 } else { 14462 value = baseToNumber(value); 14463 other = baseToNumber(other); 14464 } 14465 result = operator(value, other); 14466 } 14467 return result; 14468 }; 14469 } 14470 14471 /** 14472 * Creates a function like `_.over`. 14473 * 14474 * @private 14475 * @param {Function} arrayFunc The function to iterate over iteratees. 14476 * @returns {Function} Returns the new over function. 14477 */ 14478 function createOver(arrayFunc) { 14479 return flatRest(function(iteratees) { 14480 iteratees = arrayMap(iteratees, baseUnary(getIteratee())); 14481 return baseRest(function(args) { 14482 var thisArg = this; 14483 return arrayFunc(iteratees, function(iteratee) { 14484 return apply(iteratee, thisArg, args); 14485 }); 14486 }); 14487 }); 14488 } 14489 14490 /** 14491 * Creates the padding for `string` based on `length`. The `chars` string 14492 * is truncated if the number of characters exceeds `length`. 14493 * 14494 * @private 14495 * @param {number} length The padding length. 14496 * @param {string} [chars=' '] The string used as padding. 14497 * @returns {string} Returns the padding for `string`. 14498 */ 14499 function createPadding(length, chars) { 14500 chars = chars === undefined ? ' ' : baseToString(chars); 14501 14502 var charsLength = chars.length; 14503 if (charsLength < 2) { 14504 return charsLength ? baseRepeat(chars, length) : chars; 14505 } 14506 var result = baseRepeat(chars, nativeCeil(length / stringSize(chars))); 14507 return hasUnicode(chars) 14508 ? castSlice(stringToArray(result), 0, length).join('') 14509 : result.slice(0, length); 14510 } 14511 14512 /** 14513 * Creates a function that wraps `func` to invoke it with the `this` binding 14514 * of `thisArg` and `partials` prepended to the arguments it receives. 14515 * 14516 * @private 14517 * @param {Function} func The function to wrap. 14518 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 14519 * @param {*} thisArg The `this` binding of `func`. 14520 * @param {Array} partials The arguments to prepend to those provided to 14521 * the new function. 14522 * @returns {Function} Returns the new wrapped function. 14523 */ 14524 function createPartial(func, bitmask, thisArg, partials) { 14525 var isBind = bitmask & WRAP_BIND_FLAG, 14526 Ctor = createCtor(func); 14527 14528 function wrapper() { 14529 var argsIndex = -1, 14530 argsLength = arguments.length, 14531 leftIndex = -1, 14532 leftLength = partials.length, 14533 args = Array(leftLength + argsLength), 14534 fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; 14535 14536 while (++leftIndex < leftLength) { 14537 args[leftIndex] = partials[leftIndex]; 14538 } 14539 while (argsLength--) { 14540 args[leftIndex++] = arguments[++argsIndex]; 14541 } 14542 return apply(fn, isBind ? thisArg : this, args); 14543 } 14544 return wrapper; 14545 } 14546 14547 /** 14548 * Creates a `_.range` or `_.rangeRight` function. 14549 * 14550 * @private 14551 * @param {boolean} [fromRight] Specify iterating from right to left. 14552 * @returns {Function} Returns the new range function. 14553 */ 14554 function createRange(fromRight) { 14555 return function(start, end, step) { 14556 if (step && typeof step != 'number' && isIterateeCall(start, end, step)) { 14557 end = step = undefined; 14558 } 14559 // Ensure the sign of `-0` is preserved. 14560 start = toFinite(start); 14561 if (end === undefined) { 14562 end = start; 14563 start = 0; 14564 } else { 14565 end = toFinite(end); 14566 } 14567 step = step === undefined ? (start < end ? 1 : -1) : toFinite(step); 14568 return baseRange(start, end, step, fromRight); 14569 }; 14570 } 14571 14572 /** 14573 * Creates a function that performs a relational operation on two values. 14574 * 14575 * @private 14576 * @param {Function} operator The function to perform the operation. 14577 * @returns {Function} Returns the new relational operation function. 14578 */ 14579 function createRelationalOperation(operator) { 14580 return function(value, other) { 14581 if (!(typeof value == 'string' && typeof other == 'string')) { 14582 value = toNumber(value); 14583 other = toNumber(other); 14584 } 14585 return operator(value, other); 14586 }; 14587 } 14588 14589 /** 14590 * Creates a function that wraps `func` to continue currying. 14591 * 14592 * @private 14593 * @param {Function} func The function to wrap. 14594 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 14595 * @param {Function} wrapFunc The function to create the `func` wrapper. 14596 * @param {*} placeholder The placeholder value. 14597 * @param {*} [thisArg] The `this` binding of `func`. 14598 * @param {Array} [partials] The arguments to prepend to those provided to 14599 * the new function. 14600 * @param {Array} [holders] The `partials` placeholder indexes. 14601 * @param {Array} [argPos] The argument positions of the new function. 14602 * @param {number} [ary] The arity cap of `func`. 14603 * @param {number} [arity] The arity of `func`. 14604 * @returns {Function} Returns the new wrapped function. 14605 */ 14606 function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) { 14607 var isCurry = bitmask & WRAP_CURRY_FLAG, 14608 newHolders = isCurry ? holders : undefined, 14609 newHoldersRight = isCurry ? undefined : holders, 14610 newPartials = isCurry ? partials : undefined, 14611 newPartialsRight = isCurry ? undefined : partials; 14612 14613 bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG); 14614 bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG); 14615 14616 if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) { 14617 bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG); 14618 } 14619 var newData = [ 14620 func, bitmask, thisArg, newPartials, newHolders, newPartialsRight, 14621 newHoldersRight, argPos, ary, arity 14622 ]; 14623 14624 var result = wrapFunc.apply(undefined, newData); 14625 if (isLaziable(func)) { 14626 setData(result, newData); 14627 } 14628 result.placeholder = placeholder; 14629 return setWrapToString(result, func, bitmask); 14630 } 14631 14632 /** 14633 * Creates a function like `_.round`. 14634 * 14635 * @private 14636 * @param {string} methodName The name of the `Math` method to use when rounding. 14637 * @returns {Function} Returns the new round function. 14638 */ 14639 function createRound(methodName) { 14640 var func = Math[methodName]; 14641 return function(number, precision) { 14642 number = toNumber(number); 14643 precision = precision == null ? 0 : nativeMin(toInteger(precision), 292); 14644 if (precision && nativeIsFinite(number)) { 14645 // Shift with exponential notation to avoid floating-point issues. 14646 // See [MDN](https://mdn.io/round#Examples) for more details. 14647 var pair = (toString(number) + 'e').split('e'), 14648 value = func(pair[0] + 'e' + (+pair[1] + precision)); 14649 14650 pair = (toString(value) + 'e').split('e'); 14651 return +(pair[0] + 'e' + (+pair[1] - precision)); 14652 } 14653 return func(number); 14654 }; 14655 } 14656 14657 /** 14658 * Creates a set object of `values`. 14659 * 14660 * @private 14661 * @param {Array} values The values to add to the set. 14662 * @returns {Object} Returns the new set. 14663 */ 14664 var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) { 14665 return new Set(values); 14666 }; 14667 14668 /** 14669 * Creates a `_.toPairs` or `_.toPairsIn` function. 14670 * 14671 * @private 14672 * @param {Function} keysFunc The function to get the keys of a given object. 14673 * @returns {Function} Returns the new pairs function. 14674 */ 14675 function createToPairs(keysFunc) { 14676 return function(object) { 14677 var tag = getTag(object); 14678 if (tag == mapTag) { 14679 return mapToArray(object); 14680 } 14681 if (tag == setTag) { 14682 return setToPairs(object); 14683 } 14684 return baseToPairs(object, keysFunc(object)); 14685 }; 14686 } 14687 14688 /** 14689 * Creates a function that either curries or invokes `func` with optional 14690 * `this` binding and partially applied arguments. 14691 * 14692 * @private 14693 * @param {Function|string} func The function or method name to wrap. 14694 * @param {number} bitmask The bitmask flags. 14695 * 1 - `_.bind` 14696 * 2 - `_.bindKey` 14697 * 4 - `_.curry` or `_.curryRight` of a bound function 14698 * 8 - `_.curry` 14699 * 16 - `_.curryRight` 14700 * 32 - `_.partial` 14701 * 64 - `_.partialRight` 14702 * 128 - `_.rearg` 14703 * 256 - `_.ary` 14704 * 512 - `_.flip` 14705 * @param {*} [thisArg] The `this` binding of `func`. 14706 * @param {Array} [partials] The arguments to be partially applied. 14707 * @param {Array} [holders] The `partials` placeholder indexes. 14708 * @param {Array} [argPos] The argument positions of the new function. 14709 * @param {number} [ary] The arity cap of `func`. 14710 * @param {number} [arity] The arity of `func`. 14711 * @returns {Function} Returns the new wrapped function. 14712 */ 14713 function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) { 14714 var isBindKey = bitmask & WRAP_BIND_KEY_FLAG; 14715 if (!isBindKey && typeof func != 'function') { 14716 throw new TypeError(FUNC_ERROR_TEXT); 14717 } 14718 var length = partials ? partials.length : 0; 14719 if (!length) { 14720 bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG); 14721 partials = holders = undefined; 14722 } 14723 ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0); 14724 arity = arity === undefined ? arity : toInteger(arity); 14725 length -= holders ? holders.length : 0; 14726 14727 if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) { 14728 var partialsRight = partials, 14729 holdersRight = holders; 14730 14731 partials = holders = undefined; 14732 } 14733 var data = isBindKey ? undefined : getData(func); 14734 14735 var newData = [ 14736 func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, 14737 argPos, ary, arity 14738 ]; 14739 14740 if (data) { 14741 mergeData(newData, data); 14742 } 14743 func = newData[0]; 14744 bitmask = newData[1]; 14745 thisArg = newData[2]; 14746 partials = newData[3]; 14747 holders = newData[4]; 14748 arity = newData[9] = newData[9] === undefined 14749 ? (isBindKey ? 0 : func.length) 14750 : nativeMax(newData[9] - length, 0); 14751 14752 if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) { 14753 bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG); 14754 } 14755 if (!bitmask || bitmask == WRAP_BIND_FLAG) { 14756 var result = createBind(func, bitmask, thisArg); 14757 } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) { 14758 result = createCurry(func, bitmask, arity); 14759 } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) { 14760 result = createPartial(func, bitmask, thisArg, partials); 14761 } else { 14762 result = createHybrid.apply(undefined, newData); 14763 } 14764 var setter = data ? baseSetData : setData; 14765 return setWrapToString(setter(result, newData), func, bitmask); 14766 } 14767 14768 /** 14769 * Used by `_.defaults` to customize its `_.assignIn` use to assign properties 14770 * of source objects to the destination object for all destination properties 14771 * that resolve to `undefined`. 14772 * 14773 * @private 14774 * @param {*} objValue The destination value. 14775 * @param {*} srcValue The source value. 14776 * @param {string} key The key of the property to assign. 14777 * @param {Object} object The parent object of `objValue`. 14778 * @returns {*} Returns the value to assign. 14779 */ 14780 function customDefaultsAssignIn(objValue, srcValue, key, object) { 14781 if (objValue === undefined || 14782 (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) { 14783 return srcValue; 14784 } 14785 return objValue; 14786 } 14787 14788 /** 14789 * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source 14790 * objects into destination objects that are passed thru. 14791 * 14792 * @private 14793 * @param {*} objValue The destination value. 14794 * @param {*} srcValue The source value. 14795 * @param {string} key The key of the property to merge. 14796 * @param {Object} object The parent object of `objValue`. 14797 * @param {Object} source The parent object of `srcValue`. 14798 * @param {Object} [stack] Tracks traversed source values and their merged 14799 * counterparts. 14800 * @returns {*} Returns the value to assign. 14801 */ 14802 function customDefaultsMerge(objValue, srcValue, key, object, source, stack) { 14803 if (isObject(objValue) && isObject(srcValue)) { 14804 // Recursively merge objects and arrays (susceptible to call stack limits). 14805 stack.set(srcValue, objValue); 14806 baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack); 14807 stack['delete'](srcValue); 14808 } 14809 return objValue; 14810 } 14811 14812 /** 14813 * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain 14814 * objects. 14815 * 14816 * @private 14817 * @param {*} value The value to inspect. 14818 * @param {string} key The key of the property to inspect. 14819 * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`. 14820 */ 14821 function customOmitClone(value) { 14822 return isPlainObject(value) ? undefined : value; 14823 } 14824 14825 /** 14826 * A specialized version of `baseIsEqualDeep` for arrays with support for 14827 * partial deep comparisons. 14828 * 14829 * @private 14830 * @param {Array} array The array to compare. 14831 * @param {Array} other The other array to compare. 14832 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 14833 * @param {Function} customizer The function to customize comparisons. 14834 * @param {Function} equalFunc The function to determine equivalents of values. 14835 * @param {Object} stack Tracks traversed `array` and `other` objects. 14836 * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. 14837 */ 14838 function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { 14839 var isPartial = bitmask & COMPARE_PARTIAL_FLAG, 14840 arrLength = array.length, 14841 othLength = other.length; 14842 14843 if (arrLength != othLength && !(isPartial && othLength > arrLength)) { 14844 return false; 14845 } 14846 // Check that cyclic values are equal. 14847 var arrStacked = stack.get(array); 14848 var othStacked = stack.get(other); 14849 if (arrStacked && othStacked) { 14850 return arrStacked == other && othStacked == array; 14851 } 14852 var index = -1, 14853 result = true, 14854 seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined; 14855 14856 stack.set(array, other); 14857 stack.set(other, array); 14858 14859 // Ignore non-index properties. 14860 while (++index < arrLength) { 14861 var arrValue = array[index], 14862 othValue = other[index]; 14863 14864 if (customizer) { 14865 var compared = isPartial 14866 ? customizer(othValue, arrValue, index, other, array, stack) 14867 : customizer(arrValue, othValue, index, array, other, stack); 14868 } 14869 if (compared !== undefined) { 14870 if (compared) { 14871 continue; 14872 } 14873 result = false; 14874 break; 14875 } 14876 // Recursively compare arrays (susceptible to call stack limits). 14877 if (seen) { 14878 if (!arraySome(other, function(othValue, othIndex) { 14879 if (!cacheHas(seen, othIndex) && 14880 (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { 14881 return seen.push(othIndex); 14882 } 14883 })) { 14884 result = false; 14885 break; 14886 } 14887 } else if (!( 14888 arrValue === othValue || 14889 equalFunc(arrValue, othValue, bitmask, customizer, stack) 14890 )) { 14891 result = false; 14892 break; 14893 } 14894 } 14895 stack['delete'](array); 14896 stack['delete'](other); 14897 return result; 14898 } 14899 14900 /** 14901 * A specialized version of `baseIsEqualDeep` for comparing objects of 14902 * the same `toStringTag`. 14903 * 14904 * **Note:** This function only supports comparing values with tags of 14905 * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. 14906 * 14907 * @private 14908 * @param {Object} object The object to compare. 14909 * @param {Object} other The other object to compare. 14910 * @param {string} tag The `toStringTag` of the objects to compare. 14911 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 14912 * @param {Function} customizer The function to customize comparisons. 14913 * @param {Function} equalFunc The function to determine equivalents of values. 14914 * @param {Object} stack Tracks traversed `object` and `other` objects. 14915 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 14916 */ 14917 function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { 14918 switch (tag) { 14919 case dataViewTag: 14920 if ((object.byteLength != other.byteLength) || 14921 (object.byteOffset != other.byteOffset)) { 14922 return false; 14923 } 14924 object = object.buffer; 14925 other = other.buffer; 14926 14927 case arrayBufferTag: 14928 if ((object.byteLength != other.byteLength) || 14929 !equalFunc(new Uint8Array(object), new Uint8Array(other))) { 14930 return false; 14931 } 14932 return true; 14933 14934 case boolTag: 14935 case dateTag: 14936 case numberTag: 14937 // Coerce booleans to `1` or `0` and dates to milliseconds. 14938 // Invalid dates are coerced to `NaN`. 14939 return eq(+object, +other); 14940 14941 case errorTag: 14942 return object.name == other.name && object.message == other.message; 14943 14944 case regexpTag: 14945 case stringTag: 14946 // Coerce regexes to strings and treat strings, primitives and objects, 14947 // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring 14948 // for more details. 14949 return object == (other + ''); 14950 14951 case mapTag: 14952 var convert = mapToArray; 14953 14954 case setTag: 14955 var isPartial = bitmask & COMPARE_PARTIAL_FLAG; 14956 convert || (convert = setToArray); 14957 14958 if (object.size != other.size && !isPartial) { 14959 return false; 14960 } 14961 // Assume cyclic values are equal. 14962 var stacked = stack.get(object); 14963 if (stacked) { 14964 return stacked == other; 14965 } 14966 bitmask |= COMPARE_UNORDERED_FLAG; 14967 14968 // Recursively compare objects (susceptible to call stack limits). 14969 stack.set(object, other); 14970 var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack); 14971 stack['delete'](object); 14972 return result; 14973 14974 case symbolTag: 14975 if (symbolValueOf) { 14976 return symbolValueOf.call(object) == symbolValueOf.call(other); 14977 } 14978 } 14979 return false; 14980 } 14981 14982 /** 14983 * A specialized version of `baseIsEqualDeep` for objects with support for 14984 * partial deep comparisons. 14985 * 14986 * @private 14987 * @param {Object} object The object to compare. 14988 * @param {Object} other The other object to compare. 14989 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 14990 * @param {Function} customizer The function to customize comparisons. 14991 * @param {Function} equalFunc The function to determine equivalents of values. 14992 * @param {Object} stack Tracks traversed `object` and `other` objects. 14993 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 14994 */ 14995 function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { 14996 var isPartial = bitmask & COMPARE_PARTIAL_FLAG, 14997 objProps = getAllKeys(object), 14998 objLength = objProps.length, 14999 othProps = getAllKeys(other), 15000 othLength = othProps.length; 15001 15002 if (objLength != othLength && !isPartial) { 15003 return false; 15004 } 15005 var index = objLength; 15006 while (index--) { 15007 var key = objProps[index]; 15008 if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) { 15009 return false; 15010 } 15011 } 15012 // Check that cyclic values are equal. 15013 var objStacked = stack.get(object); 15014 var othStacked = stack.get(other); 15015 if (objStacked && othStacked) { 15016 return objStacked == other && othStacked == object; 15017 } 15018 var result = true; 15019 stack.set(object, other); 15020 stack.set(other, object); 15021 15022 var skipCtor = isPartial; 15023 while (++index < objLength) { 15024 key = objProps[index]; 15025 var objValue = object[key], 15026 othValue = other[key]; 15027 15028 if (customizer) { 15029 var compared = isPartial 15030 ? customizer(othValue, objValue, key, other, object, stack) 15031 : customizer(objValue, othValue, key, object, other, stack); 15032 } 15033 // Recursively compare objects (susceptible to call stack limits). 15034 if (!(compared === undefined 15035 ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack)) 15036 : compared 15037 )) { 15038 result = false; 15039 break; 15040 } 15041 skipCtor || (skipCtor = key == 'constructor'); 15042 } 15043 if (result && !skipCtor) { 15044 var objCtor = object.constructor, 15045 othCtor = other.constructor; 15046 15047 // Non `Object` object instances with different constructors are not equal. 15048 if (objCtor != othCtor && 15049 ('constructor' in object && 'constructor' in other) && 15050 !(typeof objCtor == 'function' && objCtor instanceof objCtor && 15051 typeof othCtor == 'function' && othCtor instanceof othCtor)) { 15052 result = false; 15053 } 15054 } 15055 stack['delete'](object); 15056 stack['delete'](other); 15057 return result; 15058 } 15059 15060 /** 15061 * A specialized version of `baseRest` which flattens the rest array. 15062 * 15063 * @private 15064 * @param {Function} func The function to apply a rest parameter to. 15065 * @returns {Function} Returns the new function. 15066 */ 15067 function flatRest(func) { 15068 return setToString(overRest(func, undefined, flatten), func + ''); 15069 } 15070 15071 /** 15072 * Creates an array of own enumerable property names and symbols of `object`. 15073 * 15074 * @private 15075 * @param {Object} object The object to query. 15076 * @returns {Array} Returns the array of property names and symbols. 15077 */ 15078 function getAllKeys(object) { 15079 return baseGetAllKeys(object, keys, getSymbols); 15080 } 15081 15082 /** 15083 * Creates an array of own and inherited enumerable property names and 15084 * symbols of `object`. 15085 * 15086 * @private 15087 * @param {Object} object The object to query. 15088 * @returns {Array} Returns the array of property names and symbols. 15089 */ 15090 function getAllKeysIn(object) { 15091 return baseGetAllKeys(object, keysIn, getSymbolsIn); 15092 } 15093 15094 /** 15095 * Gets metadata for `func`. 15096 * 15097 * @private 15098 * @param {Function} func The function to query. 15099 * @returns {*} Returns the metadata for `func`. 15100 */ 15101 var getData = !metaMap ? noop : function(func) { 15102 return metaMap.get(func); 15103 }; 15104 15105 /** 15106 * Gets the name of `func`. 15107 * 15108 * @private 15109 * @param {Function} func The function to query. 15110 * @returns {string} Returns the function name. 15111 */ 15112 function getFuncName(func) { 15113 var result = (func.name + ''), 15114 array = realNames[result], 15115 length = hasOwnProperty.call(realNames, result) ? array.length : 0; 15116 15117 while (length--) { 15118 var data = array[length], 15119 otherFunc = data.func; 15120 if (otherFunc == null || otherFunc == func) { 15121 return data.name; 15122 } 15123 } 15124 return result; 15125 } 15126 15127 /** 15128 * Gets the argument placeholder value for `func`. 15129 * 15130 * @private 15131 * @param {Function} func The function to inspect. 15132 * @returns {*} Returns the placeholder value. 15133 */ 15134 function getHolder(func) { 15135 var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func; 15136 return object.placeholder; 15137 } 15138 15139 /** 15140 * Gets the appropriate "iteratee" function. If `_.iteratee` is customized, 15141 * this function returns the custom method, otherwise it returns `baseIteratee`. 15142 * If arguments are provided, the chosen function is invoked with them and 15143 * its result is returned. 15144 * 15145 * @private 15146 * @param {*} [value] The value to convert to an iteratee. 15147 * @param {number} [arity] The arity of the created iteratee. 15148 * @returns {Function} Returns the chosen function or its result. 15149 */ 15150 function getIteratee() { 15151 var result = lodash.iteratee || iteratee; 15152 result = result === iteratee ? baseIteratee : result; 15153 return arguments.length ? result(arguments[0], arguments[1]) : result; 15154 } 15155 15156 /** 15157 * Gets the data for `map`. 15158 * 15159 * @private 15160 * @param {Object} map The map to query. 15161 * @param {string} key The reference key. 15162 * @returns {*} Returns the map data. 15163 */ 15164 function getMapData(map, key) { 15165 var data = map.__data__; 15166 return isKeyable(key) 15167 ? data[typeof key == 'string' ? 'string' : 'hash'] 15168 : data.map; 15169 } 15170 15171 /** 15172 * Gets the property names, values, and compare flags of `object`. 15173 * 15174 * @private 15175 * @param {Object} object The object to query. 15176 * @returns {Array} Returns the match data of `object`. 15177 */ 15178 function getMatchData(object) { 15179 var result = keys(object), 15180 length = result.length; 15181 15182 while (length--) { 15183 var key = result[length], 15184 value = object[key]; 15185 15186 result[length] = [key, value, isStrictComparable(value)]; 15187 } 15188 return result; 15189 } 15190 15191 /** 15192 * Gets the native function at `key` of `object`. 15193 * 15194 * @private 15195 * @param {Object} object The object to query. 15196 * @param {string} key The key of the method to get. 15197 * @returns {*} Returns the function if it's native, else `undefined`. 15198 */ 15199 function getNative(object, key) { 15200 var value = getValue(object, key); 15201 return baseIsNative(value) ? value : undefined; 15202 } 15203 15204 /** 15205 * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. 15206 * 15207 * @private 15208 * @param {*} value The value to query. 15209 * @returns {string} Returns the raw `toStringTag`. 15210 */ 15211 function getRawTag(value) { 15212 var isOwn = hasOwnProperty.call(value, symToStringTag), 15213 tag = value[symToStringTag]; 15214 15215 try { 15216 value[symToStringTag] = undefined; 15217 var unmasked = true; 15218 } catch (e) {} 15219 15220 var result = nativeObjectToString.call(value); 15221 if (unmasked) { 15222 if (isOwn) { 15223 value[symToStringTag] = tag; 15224 } else { 15225 delete value[symToStringTag]; 15226 } 15227 } 15228 return result; 15229 } 15230 15231 /** 15232 * Creates an array of the own enumerable symbols of `object`. 15233 * 15234 * @private 15235 * @param {Object} object The object to query. 15236 * @returns {Array} Returns the array of symbols. 15237 */ 15238 var getSymbols = !nativeGetSymbols ? stubArray : function(object) { 15239 if (object == null) { 15240 return []; 15241 } 15242 object = Object(object); 15243 return arrayFilter(nativeGetSymbols(object), function(symbol) { 15244 return propertyIsEnumerable.call(object, symbol); 15245 }); 15246 }; 15247 15248 /** 15249 * Creates an array of the own and inherited enumerable symbols of `object`. 15250 * 15251 * @private 15252 * @param {Object} object The object to query. 15253 * @returns {Array} Returns the array of symbols. 15254 */ 15255 var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) { 15256 var result = []; 15257 while (object) { 15258 arrayPush(result, getSymbols(object)); 15259 object = getPrototype(object); 15260 } 15261 return result; 15262 }; 15263 15264 /** 15265 * Gets the `toStringTag` of `value`. 15266 * 15267 * @private 15268 * @param {*} value The value to query. 15269 * @returns {string} Returns the `toStringTag`. 15270 */ 15271 var getTag = baseGetTag; 15272 15273 // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6. 15274 if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || 15275 (Map && getTag(new Map) != mapTag) || 15276 (Promise && getTag(Promise.resolve()) != promiseTag) || 15277 (Set && getTag(new Set) != setTag) || 15278 (WeakMap && getTag(new WeakMap) != weakMapTag)) { 15279 getTag = function(value) { 15280 var result = baseGetTag(value), 15281 Ctor = result == objectTag ? value.constructor : undefined, 15282 ctorString = Ctor ? toSource(Ctor) : ''; 15283 15284 if (ctorString) { 15285 switch (ctorString) { 15286 case dataViewCtorString: return dataViewTag; 15287 case mapCtorString: return mapTag; 15288 case promiseCtorString: return promiseTag; 15289 case setCtorString: return setTag; 15290 case weakMapCtorString: return weakMapTag; 15291 } 15292 } 15293 return result; 15294 }; 15295 } 15296 15297 /** 15298 * Gets the view, applying any `transforms` to the `start` and `end` positions. 15299 * 15300 * @private 15301 * @param {number} start The start of the view. 15302 * @param {number} end The end of the view. 15303 * @param {Array} transforms The transformations to apply to the view. 15304 * @returns {Object} Returns an object containing the `start` and `end` 15305 * positions of the view. 15306 */ 15307 function getView(start, end, transforms) { 15308 var index = -1, 15309 length = transforms.length; 15310 15311 while (++index < length) { 15312 var data = transforms[index], 15313 size = data.size; 15314 15315 switch (data.type) { 15316 case 'drop': start += size; break; 15317 case 'dropRight': end -= size; break; 15318 case 'take': end = nativeMin(end, start + size); break; 15319 case 'takeRight': start = nativeMax(start, end - size); break; 15320 } 15321 } 15322 return { 'start': start, 'end': end }; 15323 } 15324 15325 /** 15326 * Extracts wrapper details from the `source` body comment. 15327 * 15328 * @private 15329 * @param {string} source The source to inspect. 15330 * @returns {Array} Returns the wrapper details. 15331 */ 15332 function getWrapDetails(source) { 15333 var match = source.match(reWrapDetails); 15334 return match ? match[1].split(reSplitDetails) : []; 15335 } 15336 15337 /** 15338 * Checks if `path` exists on `object`. 15339 * 15340 * @private 15341 * @param {Object} object The object to query. 15342 * @param {Array|string} path The path to check. 15343 * @param {Function} hasFunc The function to check properties. 15344 * @returns {boolean} Returns `true` if `path` exists, else `false`. 15345 */ 15346 function hasPath(object, path, hasFunc) { 15347 path = castPath(path, object); 15348 15349 var index = -1, 15350 length = path.length, 15351 result = false; 15352 15353 while (++index < length) { 15354 var key = toKey(path[index]); 15355 if (!(result = object != null && hasFunc(object, key))) { 15356 break; 15357 } 15358 object = object[key]; 15359 } 15360 if (result || ++index != length) { 15361 return result; 15362 } 15363 length = object == null ? 0 : object.length; 15364 return !!length && isLength(length) && isIndex(key, length) && 15365 (isArray(object) || isArguments(object)); 15366 } 15367 15368 /** 15369 * Initializes an array clone. 15370 * 15371 * @private 15372 * @param {Array} array The array to clone. 15373 * @returns {Array} Returns the initialized clone. 15374 */ 15375 function initCloneArray(array) { 15376 var length = array.length, 15377 result = new array.constructor(length); 15378 15379 // Add properties assigned by `RegExp#exec`. 15380 if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { 15381 result.index = array.index; 15382 result.input = array.input; 15383 } 15384 return result; 15385 } 15386 15387 /** 15388 * Initializes an object clone. 15389 * 15390 * @private 15391 * @param {Object} object The object to clone. 15392 * @returns {Object} Returns the initialized clone. 15393 */ 15394 function initCloneObject(object) { 15395 return (typeof object.constructor == 'function' && !isPrototype(object)) 15396 ? baseCreate(getPrototype(object)) 15397 : {}; 15398 } 15399 15400 /** 15401 * Initializes an object clone based on its `toStringTag`. 15402 * 15403 * **Note:** This function only supports cloning values with tags of 15404 * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`. 15405 * 15406 * @private 15407 * @param {Object} object The object to clone. 15408 * @param {string} tag The `toStringTag` of the object to clone. 15409 * @param {boolean} [isDeep] Specify a deep clone. 15410 * @returns {Object} Returns the initialized clone. 15411 */ 15412 function initCloneByTag(object, tag, isDeep) { 15413 var Ctor = object.constructor; 15414 switch (tag) { 15415 case arrayBufferTag: 15416 return cloneArrayBuffer(object); 15417 15418 case boolTag: 15419 case dateTag: 15420 return new Ctor(+object); 15421 15422 case dataViewTag: 15423 return cloneDataView(object, isDeep); 15424 15425 case float32Tag: case float64Tag: 15426 case int8Tag: case int16Tag: case int32Tag: 15427 case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag: 15428 return cloneTypedArray(object, isDeep); 15429 15430 case mapTag: 15431 return new Ctor; 15432 15433 case numberTag: 15434 case stringTag: 15435 return new Ctor(object); 15436 15437 case regexpTag: 15438 return cloneRegExp(object); 15439 15440 case setTag: 15441 return new Ctor; 15442 15443 case symbolTag: 15444 return cloneSymbol(object); 15445 } 15446 } 15447 15448 /** 15449 * Inserts wrapper `details` in a comment at the top of the `source` body. 15450 * 15451 * @private 15452 * @param {string} source The source to modify. 15453 * @returns {Array} details The details to insert. 15454 * @returns {string} Returns the modified source. 15455 */ 15456 function insertWrapDetails(source, details) { 15457 var length = details.length; 15458 if (!length) { 15459 return source; 15460 } 15461 var lastIndex = length - 1; 15462 details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex]; 15463 details = details.join(length > 2 ? ', ' : ' '); 15464 return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n'); 15465 } 15466 15467 /** 15468 * Checks if `value` is a flattenable `arguments` object or array. 15469 * 15470 * @private 15471 * @param {*} value The value to check. 15472 * @returns {boolean} Returns `true` if `value` is flattenable, else `false`. 15473 */ 15474 function isFlattenable(value) { 15475 return isArray(value) || isArguments(value) || 15476 !!(spreadableSymbol && value && value[spreadableSymbol]); 15477 } 15478 15479 /** 15480 * Checks if `value` is a valid array-like index. 15481 * 15482 * @private 15483 * @param {*} value The value to check. 15484 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. 15485 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. 15486 */ 15487 function isIndex(value, length) { 15488 var type = typeof value; 15489 length = length == null ? MAX_SAFE_INTEGER : length; 15490 15491 return !!length && 15492 (type == 'number' || 15493 (type != 'symbol' && reIsUint.test(value))) && 15494 (value > -1 && value % 1 == 0 && value < length); 15495 } 15496 15497 /** 15498 * Checks if the given arguments are from an iteratee call. 15499 * 15500 * @private 15501 * @param {*} value The potential iteratee value argument. 15502 * @param {*} index The potential iteratee index or key argument. 15503 * @param {*} object The potential iteratee object argument. 15504 * @returns {boolean} Returns `true` if the arguments are from an iteratee call, 15505 * else `false`. 15506 */ 15507 function isIterateeCall(value, index, object) { 15508 if (!isObject(object)) { 15509 return false; 15510 } 15511 var type = typeof index; 15512 if (type == 'number' 15513 ? (isArrayLike(object) && isIndex(index, object.length)) 15514 : (type == 'string' && index in object) 15515 ) { 15516 return eq(object[index], value); 15517 } 15518 return false; 15519 } 15520 15521 /** 15522 * Checks if `value` is a property name and not a property path. 15523 * 15524 * @private 15525 * @param {*} value The value to check. 15526 * @param {Object} [object] The object to query keys on. 15527 * @returns {boolean} Returns `true` if `value` is a property name, else `false`. 15528 */ 15529 function isKey(value, object) { 15530 if (isArray(value)) { 15531 return false; 15532 } 15533 var type = typeof value; 15534 if (type == 'number' || type == 'symbol' || type == 'boolean' || 15535 value == null || isSymbol(value)) { 15536 return true; 15537 } 15538 return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || 15539 (object != null && value in Object(object)); 15540 } 15541 15542 /** 15543 * Checks if `value` is suitable for use as unique object key. 15544 * 15545 * @private 15546 * @param {*} value The value to check. 15547 * @returns {boolean} Returns `true` if `value` is suitable, else `false`. 15548 */ 15549 function isKeyable(value) { 15550 var type = typeof value; 15551 return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') 15552 ? (value !== '__proto__') 15553 : (value === null); 15554 } 15555 15556 /** 15557 * Checks if `func` has a lazy counterpart. 15558 * 15559 * @private 15560 * @param {Function} func The function to check. 15561 * @returns {boolean} Returns `true` if `func` has a lazy counterpart, 15562 * else `false`. 15563 */ 15564 function isLaziable(func) { 15565 var funcName = getFuncName(func), 15566 other = lodash[funcName]; 15567 15568 if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) { 15569 return false; 15570 } 15571 if (func === other) { 15572 return true; 15573 } 15574 var data = getData(other); 15575 return !!data && func === data[0]; 15576 } 15577 15578 /** 15579 * Checks if `func` has its source masked. 15580 * 15581 * @private 15582 * @param {Function} func The function to check. 15583 * @returns {boolean} Returns `true` if `func` is masked, else `false`. 15584 */ 15585 function isMasked(func) { 15586 return !!maskSrcKey && (maskSrcKey in func); 15587 } 15588 15589 /** 15590 * Checks if `func` is capable of being masked. 15591 * 15592 * @private 15593 * @param {*} value The value to check. 15594 * @returns {boolean} Returns `true` if `func` is maskable, else `false`. 15595 */ 15596 var isMaskable = coreJsData ? isFunction : stubFalse; 15597 15598 /** 15599 * Checks if `value` is likely a prototype object. 15600 * 15601 * @private 15602 * @param {*} value The value to check. 15603 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. 15604 */ 15605 function isPrototype(value) { 15606 var Ctor = value && value.constructor, 15607 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; 15608 15609 return value === proto; 15610 } 15611 15612 /** 15613 * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. 15614 * 15615 * @private 15616 * @param {*} value The value to check. 15617 * @returns {boolean} Returns `true` if `value` if suitable for strict 15618 * equality comparisons, else `false`. 15619 */ 15620 function isStrictComparable(value) { 15621 return value === value && !isObject(value); 15622 } 15623 15624 /** 15625 * A specialized version of `matchesProperty` for source values suitable 15626 * for strict equality comparisons, i.e. `===`. 15627 * 15628 * @private 15629 * @param {string} key The key of the property to get. 15630 * @param {*} srcValue The value to match. 15631 * @returns {Function} Returns the new spec function. 15632 */ 15633 function matchesStrictComparable(key, srcValue) { 15634 return function(object) { 15635 if (object == null) { 15636 return false; 15637 } 15638 return object[key] === srcValue && 15639 (srcValue !== undefined || (key in Object(object))); 15640 }; 15641 } 15642 15643 /** 15644 * A specialized version of `_.memoize` which clears the memoized function's 15645 * cache when it exceeds `MAX_MEMOIZE_SIZE`. 15646 * 15647 * @private 15648 * @param {Function} func The function to have its output memoized. 15649 * @returns {Function} Returns the new memoized function. 15650 */ 15651 function memoizeCapped(func) { 15652 var result = memoize(func, function(key) { 15653 if (cache.size === MAX_MEMOIZE_SIZE) { 15654 cache.clear(); 15655 } 15656 return key; 15657 }); 15658 15659 var cache = result.cache; 15660 return result; 15661 } 15662 15663 /** 15664 * Merges the function metadata of `source` into `data`. 15665 * 15666 * Merging metadata reduces the number of wrappers used to invoke a function. 15667 * This is possible because methods like `_.bind`, `_.curry`, and `_.partial` 15668 * may be applied regardless of execution order. Methods like `_.ary` and 15669 * `_.rearg` modify function arguments, making the order in which they are 15670 * executed important, preventing the merging of metadata. However, we make 15671 * an exception for a safe combined case where curried functions have `_.ary` 15672 * and or `_.rearg` applied. 15673 * 15674 * @private 15675 * @param {Array} data The destination metadata. 15676 * @param {Array} source The source metadata. 15677 * @returns {Array} Returns `data`. 15678 */ 15679 function mergeData(data, source) { 15680 var bitmask = data[1], 15681 srcBitmask = source[1], 15682 newBitmask = bitmask | srcBitmask, 15683 isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG); 15684 15685 var isCombo = 15686 ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) || 15687 ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) || 15688 ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG)); 15689 15690 // Exit early if metadata can't be merged. 15691 if (!(isCommon || isCombo)) { 15692 return data; 15693 } 15694 // Use source `thisArg` if available. 15695 if (srcBitmask & WRAP_BIND_FLAG) { 15696 data[2] = source[2]; 15697 // Set when currying a bound function. 15698 newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG; 15699 } 15700 // Compose partial arguments. 15701 var value = source[3]; 15702 if (value) { 15703 var partials = data[3]; 15704 data[3] = partials ? composeArgs(partials, value, source[4]) : value; 15705 data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4]; 15706 } 15707 // Compose partial right arguments. 15708 value = source[5]; 15709 if (value) { 15710 partials = data[5]; 15711 data[5] = partials ? composeArgsRight(partials, value, source[6]) : value; 15712 data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6]; 15713 } 15714 // Use source `argPos` if available. 15715 value = source[7]; 15716 if (value) { 15717 data[7] = value; 15718 } 15719 // Use source `ary` if it's smaller. 15720 if (srcBitmask & WRAP_ARY_FLAG) { 15721 data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]); 15722 } 15723 // Use source `arity` if one is not provided. 15724 if (data[9] == null) { 15725 data[9] = source[9]; 15726 } 15727 // Use source `func` and merge bitmasks. 15728 data[0] = source[0]; 15729 data[1] = newBitmask; 15730 15731 return data; 15732 } 15733 15734 /** 15735 * This function is like 15736 * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) 15737 * except that it includes inherited enumerable properties. 15738 * 15739 * @private 15740 * @param {Object} object The object to query. 15741 * @returns {Array} Returns the array of property names. 15742 */ 15743 function nativeKeysIn(object) { 15744 var result = []; 15745 if (object != null) { 15746 for (var key in Object(object)) { 15747 result.push(key); 15748 } 15749 } 15750 return result; 15751 } 15752 15753 /** 15754 * Converts `value` to a string using `Object.prototype.toString`. 15755 * 15756 * @private 15757 * @param {*} value The value to convert. 15758 * @returns {string} Returns the converted string. 15759 */ 15760 function objectToString(value) { 15761 return nativeObjectToString.call(value); 15762 } 15763 15764 /** 15765 * A specialized version of `baseRest` which transforms the rest array. 15766 * 15767 * @private 15768 * @param {Function} func The function to apply a rest parameter to. 15769 * @param {number} [start=func.length-1] The start position of the rest parameter. 15770 * @param {Function} transform The rest array transform. 15771 * @returns {Function} Returns the new function. 15772 */ 15773 function overRest(func, start, transform) { 15774 start = nativeMax(start === undefined ? (func.length - 1) : start, 0); 15775 return function() { 15776 var args = arguments, 15777 index = -1, 15778 length = nativeMax(args.length - start, 0), 15779 array = Array(length); 15780 15781 while (++index < length) { 15782 array[index] = args[start + index]; 15783 } 15784 index = -1; 15785 var otherArgs = Array(start + 1); 15786 while (++index < start) { 15787 otherArgs[index] = args[index]; 15788 } 15789 otherArgs[start] = transform(array); 15790 return apply(func, this, otherArgs); 15791 }; 15792 } 15793 15794 /** 15795 * Gets the parent value at `path` of `object`. 15796 * 15797 * @private 15798 * @param {Object} object The object to query. 15799 * @param {Array} path The path to get the parent value of. 15800 * @returns {*} Returns the parent value. 15801 */ 15802 function parent(object, path) { 15803 return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1)); 15804 } 15805 15806 /** 15807 * Reorder `array` according to the specified indexes where the element at 15808 * the first index is assigned as the first element, the element at 15809 * the second index is assigned as the second element, and so on. 15810 * 15811 * @private 15812 * @param {Array} array The array to reorder. 15813 * @param {Array} indexes The arranged array indexes. 15814 * @returns {Array} Returns `array`. 15815 */ 15816 function reorder(array, indexes) { 15817 var arrLength = array.length, 15818 length = nativeMin(indexes.length, arrLength), 15819 oldArray = copyArray(array); 15820 15821 while (length--) { 15822 var index = indexes[length]; 15823 array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined; 15824 } 15825 return array; 15826 } 15827 15828 /** 15829 * Gets the value at `key`, unless `key` is "__proto__" or "constructor". 15830 * 15831 * @private 15832 * @param {Object} object The object to query. 15833 * @param {string} key The key of the property to get. 15834 * @returns {*} Returns the property value. 15835 */ 15836 function safeGet(object, key) { 15837 if (key === 'constructor' && typeof object[key] === 'function') { 15838 return; 15839 } 15840 15841 if (key == '__proto__') { 15842 return; 15843 } 15844 15845 return object[key]; 15846 } 15847 15848 /** 15849 * Sets metadata for `func`. 15850 * 15851 * **Note:** If this function becomes hot, i.e. is invoked a lot in a short 15852 * period of time, it will trip its breaker and transition to an identity 15853 * function to avoid garbage collection pauses in V8. See 15854 * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070) 15855 * for more details. 15856 * 15857 * @private 15858 * @param {Function} func The function to associate metadata with. 15859 * @param {*} data The metadata. 15860 * @returns {Function} Returns `func`. 15861 */ 15862 var setData = shortOut(baseSetData); 15863 15864 /** 15865 * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout). 15866 * 15867 * @private 15868 * @param {Function} func The function to delay. 15869 * @param {number} wait The number of milliseconds to delay invocation. 15870 * @returns {number|Object} Returns the timer id or timeout object. 15871 */ 15872 var setTimeout = ctxSetTimeout || function(func, wait) { 15873 return root.setTimeout(func, wait); 15874 }; 15875 15876 /** 15877 * Sets the `toString` method of `func` to return `string`. 15878 * 15879 * @private 15880 * @param {Function} func The function to modify. 15881 * @param {Function} string The `toString` result. 15882 * @returns {Function} Returns `func`. 15883 */ 15884 var setToString = shortOut(baseSetToString); 15885 15886 /** 15887 * Sets the `toString` method of `wrapper` to mimic the source of `reference` 15888 * with wrapper details in a comment at the top of the source body. 15889 * 15890 * @private 15891 * @param {Function} wrapper The function to modify. 15892 * @param {Function} reference The reference function. 15893 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 15894 * @returns {Function} Returns `wrapper`. 15895 */ 15896 function setWrapToString(wrapper, reference, bitmask) { 15897 var source = (reference + ''); 15898 return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask))); 15899 } 15900 15901 /** 15902 * Creates a function that'll short out and invoke `identity` instead 15903 * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN` 15904 * milliseconds. 15905 * 15906 * @private 15907 * @param {Function} func The function to restrict. 15908 * @returns {Function} Returns the new shortable function. 15909 */ 15910 function shortOut(func) { 15911 var count = 0, 15912 lastCalled = 0; 15913 15914 return function() { 15915 var stamp = nativeNow(), 15916 remaining = HOT_SPAN - (stamp - lastCalled); 15917 15918 lastCalled = stamp; 15919 if (remaining > 0) { 15920 if (++count >= HOT_COUNT) { 15921 return arguments[0]; 15922 } 15923 } else { 15924 count = 0; 15925 } 15926 return func.apply(undefined, arguments); 15927 }; 15928 } 15929 15930 /** 15931 * A specialized version of `_.shuffle` which mutates and sets the size of `array`. 15932 * 15933 * @private 15934 * @param {Array} array The array to shuffle. 15935 * @param {number} [size=array.length] The size of `array`. 15936 * @returns {Array} Returns `array`. 15937 */ 15938 function shuffleSelf(array, size) { 15939 var index = -1, 15940 length = array.length, 15941 lastIndex = length - 1; 15942 15943 size = size === undefined ? length : size; 15944 while (++index < size) { 15945 var rand = baseRandom(index, lastIndex), 15946 value = array[rand]; 15947 15948 array[rand] = array[index]; 15949 array[index] = value; 15950 } 15951 array.length = size; 15952 return array; 15953 } 15954 15955 /** 15956 * Converts `string` to a property path array. 15957 * 15958 * @private 15959 * @param {string} string The string to convert. 15960 * @returns {Array} Returns the property path array. 15961 */ 15962 var stringToPath = memoizeCapped(function(string) { 15963 var result = []; 15964 if (string.charCodeAt(0) === 46 /* . */) { 15965 result.push(''); 15966 } 15967 string.replace(rePropName, function(match, number, quote, subString) { 15968 result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match)); 15969 }); 15970 return result; 15971 }); 15972 15973 /** 15974 * Converts `value` to a string key if it's not a string or symbol. 15975 * 15976 * @private 15977 * @param {*} value The value to inspect. 15978 * @returns {string|symbol} Returns the key. 15979 */ 15980 function toKey(value) { 15981 if (typeof value == 'string' || isSymbol(value)) { 15982 return value; 15983 } 15984 var result = (value + ''); 15985 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; 15986 } 15987 15988 /** 15989 * Converts `func` to its source code. 15990 * 15991 * @private 15992 * @param {Function} func The function to convert. 15993 * @returns {string} Returns the source code. 15994 */ 15995 function toSource(func) { 15996 if (func != null) { 15997 try { 15998 return funcToString.call(func); 15999 } catch (e) {} 16000 try { 16001 return (func + ''); 16002 } catch (e) {} 16003 } 16004 return ''; 16005 } 16006 16007 /** 16008 * Updates wrapper `details` based on `bitmask` flags. 16009 * 16010 * @private 16011 * @returns {Array} details The details to modify. 16012 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 16013 * @returns {Array} Returns `details`. 16014 */ 16015 function updateWrapDetails(details, bitmask) { 16016 arrayEach(wrapFlags, function(pair) { 16017 var value = '_.' + pair[0]; 16018 if ((bitmask & pair[1]) && !arrayIncludes(details, value)) { 16019 details.push(value); 16020 } 16021 }); 16022 return details.sort(); 16023 } 16024 16025 /** 16026 * Creates a clone of `wrapper`. 16027 * 16028 * @private 16029 * @param {Object} wrapper The wrapper to clone. 16030 * @returns {Object} Returns the cloned wrapper. 16031 */ 16032 function wrapperClone(wrapper) { 16033 if (wrapper instanceof LazyWrapper) { 16034 return wrapper.clone(); 16035 } 16036 var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__); 16037 result.__actions__ = copyArray(wrapper.__actions__); 16038 result.__index__ = wrapper.__index__; 16039 result.__values__ = wrapper.__values__; 16040 return result; 16041 } 16042 16043 /*------------------------------------------------------------------------*/ 16044 16045 /** 16046 * Creates an array of elements split into groups the length of `size`. 16047 * If `array` can't be split evenly, the final chunk will be the remaining 16048 * elements. 16049 * 16050 * @static 16051 * @memberOf _ 16052 * @since 3.0.0 16053 * @category Array 16054 * @param {Array} array The array to process. 16055 * @param {number} [size=1] The length of each chunk 16056 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 16057 * @returns {Array} Returns the new array of chunks. 16058 * @example 16059 * 16060 * _.chunk(['a', 'b', 'c', 'd'], 2); 16061 * // => [['a', 'b'], ['c', 'd']] 16062 * 16063 * _.chunk(['a', 'b', 'c', 'd'], 3); 16064 * // => [['a', 'b', 'c'], ['d']] 16065 */ 16066 function chunk(array, size, guard) { 16067 if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) { 16068 size = 1; 16069 } else { 16070 size = nativeMax(toInteger(size), 0); 16071 } 16072 var length = array == null ? 0 : array.length; 16073 if (!length || size < 1) { 16074 return []; 16075 } 16076 var index = 0, 16077 resIndex = 0, 16078 result = Array(nativeCeil(length / size)); 16079 16080 while (index < length) { 16081 result[resIndex++] = baseSlice(array, index, (index += size)); 16082 } 16083 return result; 16084 } 16085 16086 /** 16087 * Creates an array with all falsey values removed. The values `false`, `null`, 16088 * `0`, `""`, `undefined`, and `NaN` are falsey. 16089 * 16090 * @static 16091 * @memberOf _ 16092 * @since 0.1.0 16093 * @category Array 16094 * @param {Array} array The array to compact. 16095 * @returns {Array} Returns the new array of filtered values. 16096 * @example 16097 * 16098 * _.compact([0, 1, false, 2, '', 3]); 16099 * // => [1, 2, 3] 16100 */ 16101 function compact(array) { 16102 var index = -1, 16103 length = array == null ? 0 : array.length, 16104 resIndex = 0, 16105 result = []; 16106 16107 while (++index < length) { 16108 var value = array[index]; 16109 if (value) { 16110 result[resIndex++] = value; 16111 } 16112 } 16113 return result; 16114 } 16115 16116 /** 16117 * Creates a new array concatenating `array` with any additional arrays 16118 * and/or values. 16119 * 16120 * @static 16121 * @memberOf _ 16122 * @since 4.0.0 16123 * @category Array 16124 * @param {Array} array The array to concatenate. 16125 * @param {...*} [values] The values to concatenate. 16126 * @returns {Array} Returns the new concatenated array. 16127 * @example 16128 * 16129 * var array = [1]; 16130 * var other = _.concat(array, 2, [3], [[4]]); 16131 * 16132 * console.log(other); 16133 * // => [1, 2, 3, [4]] 16134 * 16135 * console.log(array); 16136 * // => [1] 16137 */ 16138 function concat() { 16139 var length = arguments.length; 16140 if (!length) { 16141 return []; 16142 } 16143 var args = Array(length - 1), 16144 array = arguments[0], 16145 index = length; 16146 16147 while (index--) { 16148 args[index - 1] = arguments[index]; 16149 } 16150 return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1)); 16151 } 16152 16153 /** 16154 * Creates an array of `array` values not included in the other given arrays 16155 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 16156 * for equality comparisons. The order and references of result values are 16157 * determined by the first array. 16158 * 16159 * **Note:** Unlike `_.pullAll`, this method returns a new array. 16160 * 16161 * @static 16162 * @memberOf _ 16163 * @since 0.1.0 16164 * @category Array 16165 * @param {Array} array The array to inspect. 16166 * @param {...Array} [values] The values to exclude. 16167 * @returns {Array} Returns the new array of filtered values. 16168 * @see _.without, _.xor 16169 * @example 16170 * 16171 * _.difference([2, 1], [2, 3]); 16172 * // => [1] 16173 */ 16174 var difference = baseRest(function(array, values) { 16175 return isArrayLikeObject(array) 16176 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true)) 16177 : []; 16178 }); 16179 16180 /** 16181 * This method is like `_.difference` except that it accepts `iteratee` which 16182 * is invoked for each element of `array` and `values` to generate the criterion 16183 * by which they're compared. The order and references of result values are 16184 * determined by the first array. The iteratee is invoked with one argument: 16185 * (value). 16186 * 16187 * **Note:** Unlike `_.pullAllBy`, this method returns a new array. 16188 * 16189 * @static 16190 * @memberOf _ 16191 * @since 4.0.0 16192 * @category Array 16193 * @param {Array} array The array to inspect. 16194 * @param {...Array} [values] The values to exclude. 16195 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 16196 * @returns {Array} Returns the new array of filtered values. 16197 * @example 16198 * 16199 * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor); 16200 * // => [1.2] 16201 * 16202 * // The `_.property` iteratee shorthand. 16203 * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x'); 16204 * // => [{ 'x': 2 }] 16205 */ 16206 var differenceBy = baseRest(function(array, values) { 16207 var iteratee = last(values); 16208 if (isArrayLikeObject(iteratee)) { 16209 iteratee = undefined; 16210 } 16211 return isArrayLikeObject(array) 16212 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2)) 16213 : []; 16214 }); 16215 16216 /** 16217 * This method is like `_.difference` except that it accepts `comparator` 16218 * which is invoked to compare elements of `array` to `values`. The order and 16219 * references of result values are determined by the first array. The comparator 16220 * is invoked with two arguments: (arrVal, othVal). 16221 * 16222 * **Note:** Unlike `_.pullAllWith`, this method returns a new array. 16223 * 16224 * @static 16225 * @memberOf _ 16226 * @since 4.0.0 16227 * @category Array 16228 * @param {Array} array The array to inspect. 16229 * @param {...Array} [values] The values to exclude. 16230 * @param {Function} [comparator] The comparator invoked per element. 16231 * @returns {Array} Returns the new array of filtered values. 16232 * @example 16233 * 16234 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 16235 * 16236 * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual); 16237 * // => [{ 'x': 2, 'y': 1 }] 16238 */ 16239 var differenceWith = baseRest(function(array, values) { 16240 var comparator = last(values); 16241 if (isArrayLikeObject(comparator)) { 16242 comparator = undefined; 16243 } 16244 return isArrayLikeObject(array) 16245 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator) 16246 : []; 16247 }); 16248 16249 /** 16250 * Creates a slice of `array` with `n` elements dropped from the beginning. 16251 * 16252 * @static 16253 * @memberOf _ 16254 * @since 0.5.0 16255 * @category Array 16256 * @param {Array} array The array to query. 16257 * @param {number} [n=1] The number of elements to drop. 16258 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 16259 * @returns {Array} Returns the slice of `array`. 16260 * @example 16261 * 16262 * _.drop([1, 2, 3]); 16263 * // => [2, 3] 16264 * 16265 * _.drop([1, 2, 3], 2); 16266 * // => [3] 16267 * 16268 * _.drop([1, 2, 3], 5); 16269 * // => [] 16270 * 16271 * _.drop([1, 2, 3], 0); 16272 * // => [1, 2, 3] 16273 */ 16274 function drop(array, n, guard) { 16275 var length = array == null ? 0 : array.length; 16276 if (!length) { 16277 return []; 16278 } 16279 n = (guard || n === undefined) ? 1 : toInteger(n); 16280 return baseSlice(array, n < 0 ? 0 : n, length); 16281 } 16282 16283 /** 16284 * Creates a slice of `array` with `n` elements dropped from the end. 16285 * 16286 * @static 16287 * @memberOf _ 16288 * @since 3.0.0 16289 * @category Array 16290 * @param {Array} array The array to query. 16291 * @param {number} [n=1] The number of elements to drop. 16292 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 16293 * @returns {Array} Returns the slice of `array`. 16294 * @example 16295 * 16296 * _.dropRight([1, 2, 3]); 16297 * // => [1, 2] 16298 * 16299 * _.dropRight([1, 2, 3], 2); 16300 * // => [1] 16301 * 16302 * _.dropRight([1, 2, 3], 5); 16303 * // => [] 16304 * 16305 * _.dropRight([1, 2, 3], 0); 16306 * // => [1, 2, 3] 16307 */ 16308 function dropRight(array, n, guard) { 16309 var length = array == null ? 0 : array.length; 16310 if (!length) { 16311 return []; 16312 } 16313 n = (guard || n === undefined) ? 1 : toInteger(n); 16314 n = length - n; 16315 return baseSlice(array, 0, n < 0 ? 0 : n); 16316 } 16317 16318 /** 16319 * Creates a slice of `array` excluding elements dropped from the end. 16320 * Elements are dropped until `predicate` returns falsey. The predicate is 16321 * invoked with three arguments: (value, index, array). 16322 * 16323 * @static 16324 * @memberOf _ 16325 * @since 3.0.0 16326 * @category Array 16327 * @param {Array} array The array to query. 16328 * @param {Function} [predicate=_.identity] The function invoked per iteration. 16329 * @returns {Array} Returns the slice of `array`. 16330 * @example 16331 * 16332 * var users = [ 16333 * { 'user': 'barney', 'active': true }, 16334 * { 'user': 'fred', 'active': false }, 16335 * { 'user': 'pebbles', 'active': false } 16336 * ]; 16337 * 16338 * _.dropRightWhile(users, function(o) { return !o.active; }); 16339 * // => objects for ['barney'] 16340 * 16341 * // The `_.matches` iteratee shorthand. 16342 * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false }); 16343 * // => objects for ['barney', 'fred'] 16344 * 16345 * // The `_.matchesProperty` iteratee shorthand. 16346 * _.dropRightWhile(users, ['active', false]); 16347 * // => objects for ['barney'] 16348 * 16349 * // The `_.property` iteratee shorthand. 16350 * _.dropRightWhile(users, 'active'); 16351 * // => objects for ['barney', 'fred', 'pebbles'] 16352 */ 16353 function dropRightWhile(array, predicate) { 16354 return (array && array.length) 16355 ? baseWhile(array, getIteratee(predicate, 3), true, true) 16356 : []; 16357 } 16358 16359 /** 16360 * Creates a slice of `array` excluding elements dropped from the beginning. 16361 * Elements are dropped until `predicate` returns falsey. The predicate is 16362 * invoked with three arguments: (value, index, array). 16363 * 16364 * @static 16365 * @memberOf _ 16366 * @since 3.0.0 16367 * @category Array 16368 * @param {Array} array The array to query. 16369 * @param {Function} [predicate=_.identity] The function invoked per iteration. 16370 * @returns {Array} Returns the slice of `array`. 16371 * @example 16372 * 16373 * var users = [ 16374 * { 'user': 'barney', 'active': false }, 16375 * { 'user': 'fred', 'active': false }, 16376 * { 'user': 'pebbles', 'active': true } 16377 * ]; 16378 * 16379 * _.dropWhile(users, function(o) { return !o.active; }); 16380 * // => objects for ['pebbles'] 16381 * 16382 * // The `_.matches` iteratee shorthand. 16383 * _.dropWhile(users, { 'user': 'barney', 'active': false }); 16384 * // => objects for ['fred', 'pebbles'] 16385 * 16386 * // The `_.matchesProperty` iteratee shorthand. 16387 * _.dropWhile(users, ['active', false]); 16388 * // => objects for ['pebbles'] 16389 * 16390 * // The `_.property` iteratee shorthand. 16391 * _.dropWhile(users, 'active'); 16392 * // => objects for ['barney', 'fred', 'pebbles'] 16393 */ 16394 function dropWhile(array, predicate) { 16395 return (array && array.length) 16396 ? baseWhile(array, getIteratee(predicate, 3), true) 16397 : []; 16398 } 16399 16400 /** 16401 * Fills elements of `array` with `value` from `start` up to, but not 16402 * including, `end`. 16403 * 16404 * **Note:** This method mutates `array`. 16405 * 16406 * @static 16407 * @memberOf _ 16408 * @since 3.2.0 16409 * @category Array 16410 * @param {Array} array The array to fill. 16411 * @param {*} value The value to fill `array` with. 16412 * @param {number} [start=0] The start position. 16413 * @param {number} [end=array.length] The end position. 16414 * @returns {Array} Returns `array`. 16415 * @example 16416 * 16417 * var array = [1, 2, 3]; 16418 * 16419 * _.fill(array, 'a'); 16420 * console.log(array); 16421 * // => ['a', 'a', 'a'] 16422 * 16423 * _.fill(Array(3), 2); 16424 * // => [2, 2, 2] 16425 * 16426 * _.fill([4, 6, 8, 10], '*', 1, 3); 16427 * // => [4, '*', '*', 10] 16428 */ 16429 function fill(array, value, start, end) { 16430 var length = array == null ? 0 : array.length; 16431 if (!length) { 16432 return []; 16433 } 16434 if (start && typeof start != 'number' && isIterateeCall(array, value, start)) { 16435 start = 0; 16436 end = length; 16437 } 16438 return baseFill(array, value, start, end); 16439 } 16440 16441 /** 16442 * This method is like `_.find` except that it returns the index of the first 16443 * element `predicate` returns truthy for instead of the element itself. 16444 * 16445 * @static 16446 * @memberOf _ 16447 * @since 1.1.0 16448 * @category Array 16449 * @param {Array} array The array to inspect. 16450 * @param {Function} [predicate=_.identity] The function invoked per iteration. 16451 * @param {number} [fromIndex=0] The index to search from. 16452 * @returns {number} Returns the index of the found element, else `-1`. 16453 * @example 16454 * 16455 * var users = [ 16456 * { 'user': 'barney', 'active': false }, 16457 * { 'user': 'fred', 'active': false }, 16458 * { 'user': 'pebbles', 'active': true } 16459 * ]; 16460 * 16461 * _.findIndex(users, function(o) { return o.user == 'barney'; }); 16462 * // => 0 16463 * 16464 * // The `_.matches` iteratee shorthand. 16465 * _.findIndex(users, { 'user': 'fred', 'active': false }); 16466 * // => 1 16467 * 16468 * // The `_.matchesProperty` iteratee shorthand. 16469 * _.findIndex(users, ['active', false]); 16470 * // => 0 16471 * 16472 * // The `_.property` iteratee shorthand. 16473 * _.findIndex(users, 'active'); 16474 * // => 2 16475 */ 16476 function findIndex(array, predicate, fromIndex) { 16477 var length = array == null ? 0 : array.length; 16478 if (!length) { 16479 return -1; 16480 } 16481 var index = fromIndex == null ? 0 : toInteger(fromIndex); 16482 if (index < 0) { 16483 index = nativeMax(length + index, 0); 16484 } 16485 return baseFindIndex(array, getIteratee(predicate, 3), index); 16486 } 16487 16488 /** 16489 * This method is like `_.findIndex` except that it iterates over elements 16490 * of `collection` from right to left. 16491 * 16492 * @static 16493 * @memberOf _ 16494 * @since 2.0.0 16495 * @category Array 16496 * @param {Array} array The array to inspect. 16497 * @param {Function} [predicate=_.identity] The function invoked per iteration. 16498 * @param {number} [fromIndex=array.length-1] The index to search from. 16499 * @returns {number} Returns the index of the found element, else `-1`. 16500 * @example 16501 * 16502 * var users = [ 16503 * { 'user': 'barney', 'active': true }, 16504 * { 'user': 'fred', 'active': false }, 16505 * { 'user': 'pebbles', 'active': false } 16506 * ]; 16507 * 16508 * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; }); 16509 * // => 2 16510 * 16511 * // The `_.matches` iteratee shorthand. 16512 * _.findLastIndex(users, { 'user': 'barney', 'active': true }); 16513 * // => 0 16514 * 16515 * // The `_.matchesProperty` iteratee shorthand. 16516 * _.findLastIndex(users, ['active', false]); 16517 * // => 2 16518 * 16519 * // The `_.property` iteratee shorthand. 16520 * _.findLastIndex(users, 'active'); 16521 * // => 0 16522 */ 16523 function findLastIndex(array, predicate, fromIndex) { 16524 var length = array == null ? 0 : array.length; 16525 if (!length) { 16526 return -1; 16527 } 16528 var index = length - 1; 16529 if (fromIndex !== undefined) { 16530 index = toInteger(fromIndex); 16531 index = fromIndex < 0 16532 ? nativeMax(length + index, 0) 16533 : nativeMin(index, length - 1); 16534 } 16535 return baseFindIndex(array, getIteratee(predicate, 3), index, true); 16536 } 16537 16538 /** 16539 * Flattens `array` a single level deep. 16540 * 16541 * @static 16542 * @memberOf _ 16543 * @since 0.1.0 16544 * @category Array 16545 * @param {Array} array The array to flatten. 16546 * @returns {Array} Returns the new flattened array. 16547 * @example 16548 * 16549 * _.flatten([1, [2, [3, [4]], 5]]); 16550 * // => [1, 2, [3, [4]], 5] 16551 */ 16552 function flatten(array) { 16553 var length = array == null ? 0 : array.length; 16554 return length ? baseFlatten(array, 1) : []; 16555 } 16556 16557 /** 16558 * Recursively flattens `array`. 16559 * 16560 * @static 16561 * @memberOf _ 16562 * @since 3.0.0 16563 * @category Array 16564 * @param {Array} array The array to flatten. 16565 * @returns {Array} Returns the new flattened array. 16566 * @example 16567 * 16568 * _.flattenDeep([1, [2, [3, [4]], 5]]); 16569 * // => [1, 2, 3, 4, 5] 16570 */ 16571 function flattenDeep(array) { 16572 var length = array == null ? 0 : array.length; 16573 return length ? baseFlatten(array, INFINITY) : []; 16574 } 16575 16576 /** 16577 * Recursively flatten `array` up to `depth` times. 16578 * 16579 * @static 16580 * @memberOf _ 16581 * @since 4.4.0 16582 * @category Array 16583 * @param {Array} array The array to flatten. 16584 * @param {number} [depth=1] The maximum recursion depth. 16585 * @returns {Array} Returns the new flattened array. 16586 * @example 16587 * 16588 * var array = [1, [2, [3, [4]], 5]]; 16589 * 16590 * _.flattenDepth(array, 1); 16591 * // => [1, 2, [3, [4]], 5] 16592 * 16593 * _.flattenDepth(array, 2); 16594 * // => [1, 2, 3, [4], 5] 16595 */ 16596 function flattenDepth(array, depth) { 16597 var length = array == null ? 0 : array.length; 16598 if (!length) { 16599 return []; 16600 } 16601 depth = depth === undefined ? 1 : toInteger(depth); 16602 return baseFlatten(array, depth); 16603 } 16604 16605 /** 16606 * The inverse of `_.toPairs`; this method returns an object composed 16607 * from key-value `pairs`. 16608 * 16609 * @static 16610 * @memberOf _ 16611 * @since 4.0.0 16612 * @category Array 16613 * @param {Array} pairs The key-value pairs. 16614 * @returns {Object} Returns the new object. 16615 * @example 16616 * 16617 * _.fromPairs([['a', 1], ['b', 2]]); 16618 * // => { 'a': 1, 'b': 2 } 16619 */ 16620 function fromPairs(pairs) { 16621 var index = -1, 16622 length = pairs == null ? 0 : pairs.length, 16623 result = {}; 16624 16625 while (++index < length) { 16626 var pair = pairs[index]; 16627 result[pair[0]] = pair[1]; 16628 } 16629 return result; 16630 } 16631 16632 /** 16633 * Gets the first element of `array`. 16634 * 16635 * @static 16636 * @memberOf _ 16637 * @since 0.1.0 16638 * @alias first 16639 * @category Array 16640 * @param {Array} array The array to query. 16641 * @returns {*} Returns the first element of `array`. 16642 * @example 16643 * 16644 * _.head([1, 2, 3]); 16645 * // => 1 16646 * 16647 * _.head([]); 16648 * // => undefined 16649 */ 16650 function head(array) { 16651 return (array && array.length) ? array[0] : undefined; 16652 } 16653 16654 /** 16655 * Gets the index at which the first occurrence of `value` is found in `array` 16656 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 16657 * for equality comparisons. If `fromIndex` is negative, it's used as the 16658 * offset from the end of `array`. 16659 * 16660 * @static 16661 * @memberOf _ 16662 * @since 0.1.0 16663 * @category Array 16664 * @param {Array} array The array to inspect. 16665 * @param {*} value The value to search for. 16666 * @param {number} [fromIndex=0] The index to search from. 16667 * @returns {number} Returns the index of the matched value, else `-1`. 16668 * @example 16669 * 16670 * _.indexOf([1, 2, 1, 2], 2); 16671 * // => 1 16672 * 16673 * // Search from the `fromIndex`. 16674 * _.indexOf([1, 2, 1, 2], 2, 2); 16675 * // => 3 16676 */ 16677 function indexOf(array, value, fromIndex) { 16678 var length = array == null ? 0 : array.length; 16679 if (!length) { 16680 return -1; 16681 } 16682 var index = fromIndex == null ? 0 : toInteger(fromIndex); 16683 if (index < 0) { 16684 index = nativeMax(length + index, 0); 16685 } 16686 return baseIndexOf(array, value, index); 16687 } 16688 16689 /** 16690 * Gets all but the last element of `array`. 16691 * 16692 * @static 16693 * @memberOf _ 16694 * @since 0.1.0 16695 * @category Array 16696 * @param {Array} array The array to query. 16697 * @returns {Array} Returns the slice of `array`. 16698 * @example 16699 * 16700 * _.initial([1, 2, 3]); 16701 * // => [1, 2] 16702 */ 16703 function initial(array) { 16704 var length = array == null ? 0 : array.length; 16705 return length ? baseSlice(array, 0, -1) : []; 16706 } 16707 16708 /** 16709 * Creates an array of unique values that are included in all given arrays 16710 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 16711 * for equality comparisons. The order and references of result values are 16712 * determined by the first array. 16713 * 16714 * @static 16715 * @memberOf _ 16716 * @since 0.1.0 16717 * @category Array 16718 * @param {...Array} [arrays] The arrays to inspect. 16719 * @returns {Array} Returns the new array of intersecting values. 16720 * @example 16721 * 16722 * _.intersection([2, 1], [2, 3]); 16723 * // => [2] 16724 */ 16725 var intersection = baseRest(function(arrays) { 16726 var mapped = arrayMap(arrays, castArrayLikeObject); 16727 return (mapped.length && mapped[0] === arrays[0]) 16728 ? baseIntersection(mapped) 16729 : []; 16730 }); 16731 16732 /** 16733 * This method is like `_.intersection` except that it accepts `iteratee` 16734 * which is invoked for each element of each `arrays` to generate the criterion 16735 * by which they're compared. The order and references of result values are 16736 * determined by the first array. The iteratee is invoked with one argument: 16737 * (value). 16738 * 16739 * @static 16740 * @memberOf _ 16741 * @since 4.0.0 16742 * @category Array 16743 * @param {...Array} [arrays] The arrays to inspect. 16744 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 16745 * @returns {Array} Returns the new array of intersecting values. 16746 * @example 16747 * 16748 * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor); 16749 * // => [2.1] 16750 * 16751 * // The `_.property` iteratee shorthand. 16752 * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); 16753 * // => [{ 'x': 1 }] 16754 */ 16755 var intersectionBy = baseRest(function(arrays) { 16756 var iteratee = last(arrays), 16757 mapped = arrayMap(arrays, castArrayLikeObject); 16758 16759 if (iteratee === last(mapped)) { 16760 iteratee = undefined; 16761 } else { 16762 mapped.pop(); 16763 } 16764 return (mapped.length && mapped[0] === arrays[0]) 16765 ? baseIntersection(mapped, getIteratee(iteratee, 2)) 16766 : []; 16767 }); 16768 16769 /** 16770 * This method is like `_.intersection` except that it accepts `comparator` 16771 * which is invoked to compare elements of `arrays`. The order and references 16772 * of result values are determined by the first array. The comparator is 16773 * invoked with two arguments: (arrVal, othVal). 16774 * 16775 * @static 16776 * @memberOf _ 16777 * @since 4.0.0 16778 * @category Array 16779 * @param {...Array} [arrays] The arrays to inspect. 16780 * @param {Function} [comparator] The comparator invoked per element. 16781 * @returns {Array} Returns the new array of intersecting values. 16782 * @example 16783 * 16784 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 16785 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; 16786 * 16787 * _.intersectionWith(objects, others, _.isEqual); 16788 * // => [{ 'x': 1, 'y': 2 }] 16789 */ 16790 var intersectionWith = baseRest(function(arrays) { 16791 var comparator = last(arrays), 16792 mapped = arrayMap(arrays, castArrayLikeObject); 16793 16794 comparator = typeof comparator == 'function' ? comparator : undefined; 16795 if (comparator) { 16796 mapped.pop(); 16797 } 16798 return (mapped.length && mapped[0] === arrays[0]) 16799 ? baseIntersection(mapped, undefined, comparator) 16800 : []; 16801 }); 16802 16803 /** 16804 * Converts all elements in `array` into a string separated by `separator`. 16805 * 16806 * @static 16807 * @memberOf _ 16808 * @since 4.0.0 16809 * @category Array 16810 * @param {Array} array The array to convert. 16811 * @param {string} [separator=','] The element separator. 16812 * @returns {string} Returns the joined string. 16813 * @example 16814 * 16815 * _.join(['a', 'b', 'c'], '~'); 16816 * // => 'a~b~c' 16817 */ 16818 function join(array, separator) { 16819 return array == null ? '' : nativeJoin.call(array, separator); 16820 } 16821 16822 /** 16823 * Gets the last element of `array`. 16824 * 16825 * @static 16826 * @memberOf _ 16827 * @since 0.1.0 16828 * @category Array 16829 * @param {Array} array The array to query. 16830 * @returns {*} Returns the last element of `array`. 16831 * @example 16832 * 16833 * _.last([1, 2, 3]); 16834 * // => 3 16835 */ 16836 function last(array) { 16837 var length = array == null ? 0 : array.length; 16838 return length ? array[length - 1] : undefined; 16839 } 16840 16841 /** 16842 * This method is like `_.indexOf` except that it iterates over elements of 16843 * `array` from right to left. 16844 * 16845 * @static 16846 * @memberOf _ 16847 * @since 0.1.0 16848 * @category Array 16849 * @param {Array} array The array to inspect. 16850 * @param {*} value The value to search for. 16851 * @param {number} [fromIndex=array.length-1] The index to search from. 16852 * @returns {number} Returns the index of the matched value, else `-1`. 16853 * @example 16854 * 16855 * _.lastIndexOf([1, 2, 1, 2], 2); 16856 * // => 3 16857 * 16858 * // Search from the `fromIndex`. 16859 * _.lastIndexOf([1, 2, 1, 2], 2, 2); 16860 * // => 1 16861 */ 16862 function lastIndexOf(array, value, fromIndex) { 16863 var length = array == null ? 0 : array.length; 16864 if (!length) { 16865 return -1; 16866 } 16867 var index = length; 16868 if (fromIndex !== undefined) { 16869 index = toInteger(fromIndex); 16870 index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1); 16871 } 16872 return value === value 16873 ? strictLastIndexOf(array, value, index) 16874 : baseFindIndex(array, baseIsNaN, index, true); 16875 } 16876 16877 /** 16878 * Gets the element at index `n` of `array`. If `n` is negative, the nth 16879 * element from the end is returned. 16880 * 16881 * @static 16882 * @memberOf _ 16883 * @since 4.11.0 16884 * @category Array 16885 * @param {Array} array The array to query. 16886 * @param {number} [n=0] The index of the element to return. 16887 * @returns {*} Returns the nth element of `array`. 16888 * @example 16889 * 16890 * var array = ['a', 'b', 'c', 'd']; 16891 * 16892 * _.nth(array, 1); 16893 * // => 'b' 16894 * 16895 * _.nth(array, -2); 16896 * // => 'c'; 16897 */ 16898 function nth(array, n) { 16899 return (array && array.length) ? baseNth(array, toInteger(n)) : undefined; 16900 } 16901 16902 /** 16903 * Removes all given values from `array` using 16904 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 16905 * for equality comparisons. 16906 * 16907 * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove` 16908 * to remove elements from an array by predicate. 16909 * 16910 * @static 16911 * @memberOf _ 16912 * @since 2.0.0 16913 * @category Array 16914 * @param {Array} array The array to modify. 16915 * @param {...*} [values] The values to remove. 16916 * @returns {Array} Returns `array`. 16917 * @example 16918 * 16919 * var array = ['a', 'b', 'c', 'a', 'b', 'c']; 16920 * 16921 * _.pull(array, 'a', 'c'); 16922 * console.log(array); 16923 * // => ['b', 'b'] 16924 */ 16925 var pull = baseRest(pullAll); 16926 16927 /** 16928 * This method is like `_.pull` except that it accepts an array of values to remove. 16929 * 16930 * **Note:** Unlike `_.difference`, this method mutates `array`. 16931 * 16932 * @static 16933 * @memberOf _ 16934 * @since 4.0.0 16935 * @category Array 16936 * @param {Array} array The array to modify. 16937 * @param {Array} values The values to remove. 16938 * @returns {Array} Returns `array`. 16939 * @example 16940 * 16941 * var array = ['a', 'b', 'c', 'a', 'b', 'c']; 16942 * 16943 * _.pullAll(array, ['a', 'c']); 16944 * console.log(array); 16945 * // => ['b', 'b'] 16946 */ 16947 function pullAll(array, values) { 16948 return (array && array.length && values && values.length) 16949 ? basePullAll(array, values) 16950 : array; 16951 } 16952 16953 /** 16954 * This method is like `_.pullAll` except that it accepts `iteratee` which is 16955 * invoked for each element of `array` and `values` to generate the criterion 16956 * by which they're compared. The iteratee is invoked with one argument: (value). 16957 * 16958 * **Note:** Unlike `_.differenceBy`, this method mutates `array`. 16959 * 16960 * @static 16961 * @memberOf _ 16962 * @since 4.0.0 16963 * @category Array 16964 * @param {Array} array The array to modify. 16965 * @param {Array} values The values to remove. 16966 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 16967 * @returns {Array} Returns `array`. 16968 * @example 16969 * 16970 * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }]; 16971 * 16972 * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x'); 16973 * console.log(array); 16974 * // => [{ 'x': 2 }] 16975 */ 16976 function pullAllBy(array, values, iteratee) { 16977 return (array && array.length && values && values.length) 16978 ? basePullAll(array, values, getIteratee(iteratee, 2)) 16979 : array; 16980 } 16981 16982 /** 16983 * This method is like `_.pullAll` except that it accepts `comparator` which 16984 * is invoked to compare elements of `array` to `values`. The comparator is 16985 * invoked with two arguments: (arrVal, othVal). 16986 * 16987 * **Note:** Unlike `_.differenceWith`, this method mutates `array`. 16988 * 16989 * @static 16990 * @memberOf _ 16991 * @since 4.6.0 16992 * @category Array 16993 * @param {Array} array The array to modify. 16994 * @param {Array} values The values to remove. 16995 * @param {Function} [comparator] The comparator invoked per element. 16996 * @returns {Array} Returns `array`. 16997 * @example 16998 * 16999 * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }]; 17000 * 17001 * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual); 17002 * console.log(array); 17003 * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }] 17004 */ 17005 function pullAllWith(array, values, comparator) { 17006 return (array && array.length && values && values.length) 17007 ? basePullAll(array, values, undefined, comparator) 17008 : array; 17009 } 17010 17011 /** 17012 * Removes elements from `array` corresponding to `indexes` and returns an 17013 * array of removed elements. 17014 * 17015 * **Note:** Unlike `_.at`, this method mutates `array`. 17016 * 17017 * @static 17018 * @memberOf _ 17019 * @since 3.0.0 17020 * @category Array 17021 * @param {Array} array The array to modify. 17022 * @param {...(number|number[])} [indexes] The indexes of elements to remove. 17023 * @returns {Array} Returns the new array of removed elements. 17024 * @example 17025 * 17026 * var array = ['a', 'b', 'c', 'd']; 17027 * var pulled = _.pullAt(array, [1, 3]); 17028 * 17029 * console.log(array); 17030 * // => ['a', 'c'] 17031 * 17032 * console.log(pulled); 17033 * // => ['b', 'd'] 17034 */ 17035 var pullAt = flatRest(function(array, indexes) { 17036 var length = array == null ? 0 : array.length, 17037 result = baseAt(array, indexes); 17038 17039 basePullAt(array, arrayMap(indexes, function(index) { 17040 return isIndex(index, length) ? +index : index; 17041 }).sort(compareAscending)); 17042 17043 return result; 17044 }); 17045 17046 /** 17047 * Removes all elements from `array` that `predicate` returns truthy for 17048 * and returns an array of the removed elements. The predicate is invoked 17049 * with three arguments: (value, index, array). 17050 * 17051 * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull` 17052 * to pull elements from an array by value. 17053 * 17054 * @static 17055 * @memberOf _ 17056 * @since 2.0.0 17057 * @category Array 17058 * @param {Array} array The array to modify. 17059 * @param {Function} [predicate=_.identity] The function invoked per iteration. 17060 * @returns {Array} Returns the new array of removed elements. 17061 * @example 17062 * 17063 * var array = [1, 2, 3, 4]; 17064 * var evens = _.remove(array, function(n) { 17065 * return n % 2 == 0; 17066 * }); 17067 * 17068 * console.log(array); 17069 * // => [1, 3] 17070 * 17071 * console.log(evens); 17072 * // => [2, 4] 17073 */ 17074 function remove(array, predicate) { 17075 var result = []; 17076 if (!(array && array.length)) { 17077 return result; 17078 } 17079 var index = -1, 17080 indexes = [], 17081 length = array.length; 17082 17083 predicate = getIteratee(predicate, 3); 17084 while (++index < length) { 17085 var value = array[index]; 17086 if (predicate(value, index, array)) { 17087 result.push(value); 17088 indexes.push(index); 17089 } 17090 } 17091 basePullAt(array, indexes); 17092 return result; 17093 } 17094 17095 /** 17096 * Reverses `array` so that the first element becomes the last, the second 17097 * element becomes the second to last, and so on. 17098 * 17099 * **Note:** This method mutates `array` and is based on 17100 * [`Array#reverse`](https://mdn.io/Array/reverse). 17101 * 17102 * @static 17103 * @memberOf _ 17104 * @since 4.0.0 17105 * @category Array 17106 * @param {Array} array The array to modify. 17107 * @returns {Array} Returns `array`. 17108 * @example 17109 * 17110 * var array = [1, 2, 3]; 17111 * 17112 * _.reverse(array); 17113 * // => [3, 2, 1] 17114 * 17115 * console.log(array); 17116 * // => [3, 2, 1] 17117 */ 17118 function reverse(array) { 17119 return array == null ? array : nativeReverse.call(array); 17120 } 17121 17122 /** 17123 * Creates a slice of `array` from `start` up to, but not including, `end`. 17124 * 17125 * **Note:** This method is used instead of 17126 * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are 17127 * returned. 17128 * 17129 * @static 17130 * @memberOf _ 17131 * @since 3.0.0 17132 * @category Array 17133 * @param {Array} array The array to slice. 17134 * @param {number} [start=0] The start position. 17135 * @param {number} [end=array.length] The end position. 17136 * @returns {Array} Returns the slice of `array`. 17137 */ 17138 function slice(array, start, end) { 17139 var length = array == null ? 0 : array.length; 17140 if (!length) { 17141 return []; 17142 } 17143 if (end && typeof end != 'number' && isIterateeCall(array, start, end)) { 17144 start = 0; 17145 end = length; 17146 } 17147 else { 17148 start = start == null ? 0 : toInteger(start); 17149 end = end === undefined ? length : toInteger(end); 17150 } 17151 return baseSlice(array, start, end); 17152 } 17153 17154 /** 17155 * Uses a binary search to determine the lowest index at which `value` 17156 * should be inserted into `array` in order to maintain its sort order. 17157 * 17158 * @static 17159 * @memberOf _ 17160 * @since 0.1.0 17161 * @category Array 17162 * @param {Array} array The sorted array to inspect. 17163 * @param {*} value The value to evaluate. 17164 * @returns {number} Returns the index at which `value` should be inserted 17165 * into `array`. 17166 * @example 17167 * 17168 * _.sortedIndex([30, 50], 40); 17169 * // => 1 17170 */ 17171 function sortedIndex(array, value) { 17172 return baseSortedIndex(array, value); 17173 } 17174 17175 /** 17176 * This method is like `_.sortedIndex` except that it accepts `iteratee` 17177 * which is invoked for `value` and each element of `array` to compute their 17178 * sort ranking. The iteratee is invoked with one argument: (value). 17179 * 17180 * @static 17181 * @memberOf _ 17182 * @since 4.0.0 17183 * @category Array 17184 * @param {Array} array The sorted array to inspect. 17185 * @param {*} value The value to evaluate. 17186 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 17187 * @returns {number} Returns the index at which `value` should be inserted 17188 * into `array`. 17189 * @example 17190 * 17191 * var objects = [{ 'x': 4 }, { 'x': 5 }]; 17192 * 17193 * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); 17194 * // => 0 17195 * 17196 * // The `_.property` iteratee shorthand. 17197 * _.sortedIndexBy(objects, { 'x': 4 }, 'x'); 17198 * // => 0 17199 */ 17200 function sortedIndexBy(array, value, iteratee) { 17201 return baseSortedIndexBy(array, value, getIteratee(iteratee, 2)); 17202 } 17203 17204 /** 17205 * This method is like `_.indexOf` except that it performs a binary 17206 * search on a sorted `array`. 17207 * 17208 * @static 17209 * @memberOf _ 17210 * @since 4.0.0 17211 * @category Array 17212 * @param {Array} array The array to inspect. 17213 * @param {*} value The value to search for. 17214 * @returns {number} Returns the index of the matched value, else `-1`. 17215 * @example 17216 * 17217 * _.sortedIndexOf([4, 5, 5, 5, 6], 5); 17218 * // => 1 17219 */ 17220 function sortedIndexOf(array, value) { 17221 var length = array == null ? 0 : array.length; 17222 if (length) { 17223 var index = baseSortedIndex(array, value); 17224 if (index < length && eq(array[index], value)) { 17225 return index; 17226 } 17227 } 17228 return -1; 17229 } 17230 17231 /** 17232 * This method is like `_.sortedIndex` except that it returns the highest 17233 * index at which `value` should be inserted into `array` in order to 17234 * maintain its sort order. 17235 * 17236 * @static 17237 * @memberOf _ 17238 * @since 3.0.0 17239 * @category Array 17240 * @param {Array} array The sorted array to inspect. 17241 * @param {*} value The value to evaluate. 17242 * @returns {number} Returns the index at which `value` should be inserted 17243 * into `array`. 17244 * @example 17245 * 17246 * _.sortedLastIndex([4, 5, 5, 5, 6], 5); 17247 * // => 4 17248 */ 17249 function sortedLastIndex(array, value) { 17250 return baseSortedIndex(array, value, true); 17251 } 17252 17253 /** 17254 * This method is like `_.sortedLastIndex` except that it accepts `iteratee` 17255 * which is invoked for `value` and each element of `array` to compute their 17256 * sort ranking. The iteratee is invoked with one argument: (value). 17257 * 17258 * @static 17259 * @memberOf _ 17260 * @since 4.0.0 17261 * @category Array 17262 * @param {Array} array The sorted array to inspect. 17263 * @param {*} value The value to evaluate. 17264 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 17265 * @returns {number} Returns the index at which `value` should be inserted 17266 * into `array`. 17267 * @example 17268 * 17269 * var objects = [{ 'x': 4 }, { 'x': 5 }]; 17270 * 17271 * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); 17272 * // => 1 17273 * 17274 * // The `_.property` iteratee shorthand. 17275 * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x'); 17276 * // => 1 17277 */ 17278 function sortedLastIndexBy(array, value, iteratee) { 17279 return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true); 17280 } 17281 17282 /** 17283 * This method is like `_.lastIndexOf` except that it performs a binary 17284 * search on a sorted `array`. 17285 * 17286 * @static 17287 * @memberOf _ 17288 * @since 4.0.0 17289 * @category Array 17290 * @param {Array} array The array to inspect. 17291 * @param {*} value The value to search for. 17292 * @returns {number} Returns the index of the matched value, else `-1`. 17293 * @example 17294 * 17295 * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5); 17296 * // => 3 17297 */ 17298 function sortedLastIndexOf(array, value) { 17299 var length = array == null ? 0 : array.length; 17300 if (length) { 17301 var index = baseSortedIndex(array, value, true) - 1; 17302 if (eq(array[index], value)) { 17303 return index; 17304 } 17305 } 17306 return -1; 17307 } 17308 17309 /** 17310 * This method is like `_.uniq` except that it's designed and optimized 17311 * for sorted arrays. 17312 * 17313 * @static 17314 * @memberOf _ 17315 * @since 4.0.0 17316 * @category Array 17317 * @param {Array} array The array to inspect. 17318 * @returns {Array} Returns the new duplicate free array. 17319 * @example 17320 * 17321 * _.sortedUniq([1, 1, 2]); 17322 * // => [1, 2] 17323 */ 17324 function sortedUniq(array) { 17325 return (array && array.length) 17326 ? baseSortedUniq(array) 17327 : []; 17328 } 17329 17330 /** 17331 * This method is like `_.uniqBy` except that it's designed and optimized 17332 * for sorted arrays. 17333 * 17334 * @static 17335 * @memberOf _ 17336 * @since 4.0.0 17337 * @category Array 17338 * @param {Array} array The array to inspect. 17339 * @param {Function} [iteratee] The iteratee invoked per element. 17340 * @returns {Array} Returns the new duplicate free array. 17341 * @example 17342 * 17343 * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor); 17344 * // => [1.1, 2.3] 17345 */ 17346 function sortedUniqBy(array, iteratee) { 17347 return (array && array.length) 17348 ? baseSortedUniq(array, getIteratee(iteratee, 2)) 17349 : []; 17350 } 17351 17352 /** 17353 * Gets all but the first element of `array`. 17354 * 17355 * @static 17356 * @memberOf _ 17357 * @since 4.0.0 17358 * @category Array 17359 * @param {Array} array The array to query. 17360 * @returns {Array} Returns the slice of `array`. 17361 * @example 17362 * 17363 * _.tail([1, 2, 3]); 17364 * // => [2, 3] 17365 */ 17366 function tail(array) { 17367 var length = array == null ? 0 : array.length; 17368 return length ? baseSlice(array, 1, length) : []; 17369 } 17370 17371 /** 17372 * Creates a slice of `array` with `n` elements taken from the beginning. 17373 * 17374 * @static 17375 * @memberOf _ 17376 * @since 0.1.0 17377 * @category Array 17378 * @param {Array} array The array to query. 17379 * @param {number} [n=1] The number of elements to take. 17380 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 17381 * @returns {Array} Returns the slice of `array`. 17382 * @example 17383 * 17384 * _.take([1, 2, 3]); 17385 * // => [1] 17386 * 17387 * _.take([1, 2, 3], 2); 17388 * // => [1, 2] 17389 * 17390 * _.take([1, 2, 3], 5); 17391 * // => [1, 2, 3] 17392 * 17393 * _.take([1, 2, 3], 0); 17394 * // => [] 17395 */ 17396 function take(array, n, guard) { 17397 if (!(array && array.length)) { 17398 return []; 17399 } 17400 n = (guard || n === undefined) ? 1 : toInteger(n); 17401 return baseSlice(array, 0, n < 0 ? 0 : n); 17402 } 17403 17404 /** 17405 * Creates a slice of `array` with `n` elements taken from the end. 17406 * 17407 * @static 17408 * @memberOf _ 17409 * @since 3.0.0 17410 * @category Array 17411 * @param {Array} array The array to query. 17412 * @param {number} [n=1] The number of elements to take. 17413 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 17414 * @returns {Array} Returns the slice of `array`. 17415 * @example 17416 * 17417 * _.takeRight([1, 2, 3]); 17418 * // => [3] 17419 * 17420 * _.takeRight([1, 2, 3], 2); 17421 * // => [2, 3] 17422 * 17423 * _.takeRight([1, 2, 3], 5); 17424 * // => [1, 2, 3] 17425 * 17426 * _.takeRight([1, 2, 3], 0); 17427 * // => [] 17428 */ 17429 function takeRight(array, n, guard) { 17430 var length = array == null ? 0 : array.length; 17431 if (!length) { 17432 return []; 17433 } 17434 n = (guard || n === undefined) ? 1 : toInteger(n); 17435 n = length - n; 17436 return baseSlice(array, n < 0 ? 0 : n, length); 17437 } 17438 17439 /** 17440 * Creates a slice of `array` with elements taken from the end. Elements are 17441 * taken until `predicate` returns falsey. The predicate is invoked with 17442 * three arguments: (value, index, array). 17443 * 17444 * @static 17445 * @memberOf _ 17446 * @since 3.0.0 17447 * @category Array 17448 * @param {Array} array The array to query. 17449 * @param {Function} [predicate=_.identity] The function invoked per iteration. 17450 * @returns {Array} Returns the slice of `array`. 17451 * @example 17452 * 17453 * var users = [ 17454 * { 'user': 'barney', 'active': true }, 17455 * { 'user': 'fred', 'active': false }, 17456 * { 'user': 'pebbles', 'active': false } 17457 * ]; 17458 * 17459 * _.takeRightWhile(users, function(o) { return !o.active; }); 17460 * // => objects for ['fred', 'pebbles'] 17461 * 17462 * // The `_.matches` iteratee shorthand. 17463 * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false }); 17464 * // => objects for ['pebbles'] 17465 * 17466 * // The `_.matchesProperty` iteratee shorthand. 17467 * _.takeRightWhile(users, ['active', false]); 17468 * // => objects for ['fred', 'pebbles'] 17469 * 17470 * // The `_.property` iteratee shorthand. 17471 * _.takeRightWhile(users, 'active'); 17472 * // => [] 17473 */ 17474 function takeRightWhile(array, predicate) { 17475 return (array && array.length) 17476 ? baseWhile(array, getIteratee(predicate, 3), false, true) 17477 : []; 17478 } 17479 17480 /** 17481 * Creates a slice of `array` with elements taken from the beginning. Elements 17482 * are taken until `predicate` returns falsey. The predicate is invoked with 17483 * three arguments: (value, index, array). 17484 * 17485 * @static 17486 * @memberOf _ 17487 * @since 3.0.0 17488 * @category Array 17489 * @param {Array} array The array to query. 17490 * @param {Function} [predicate=_.identity] The function invoked per iteration. 17491 * @returns {Array} Returns the slice of `array`. 17492 * @example 17493 * 17494 * var users = [ 17495 * { 'user': 'barney', 'active': false }, 17496 * { 'user': 'fred', 'active': false }, 17497 * { 'user': 'pebbles', 'active': true } 17498 * ]; 17499 * 17500 * _.takeWhile(users, function(o) { return !o.active; }); 17501 * // => objects for ['barney', 'fred'] 17502 * 17503 * // The `_.matches` iteratee shorthand. 17504 * _.takeWhile(users, { 'user': 'barney', 'active': false }); 17505 * // => objects for ['barney'] 17506 * 17507 * // The `_.matchesProperty` iteratee shorthand. 17508 * _.takeWhile(users, ['active', false]); 17509 * // => objects for ['barney', 'fred'] 17510 * 17511 * // The `_.property` iteratee shorthand. 17512 * _.takeWhile(users, 'active'); 17513 * // => [] 17514 */ 17515 function takeWhile(array, predicate) { 17516 return (array && array.length) 17517 ? baseWhile(array, getIteratee(predicate, 3)) 17518 : []; 17519 } 17520 17521 /** 17522 * Creates an array of unique values, in order, from all given arrays using 17523 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 17524 * for equality comparisons. 17525 * 17526 * @static 17527 * @memberOf _ 17528 * @since 0.1.0 17529 * @category Array 17530 * @param {...Array} [arrays] The arrays to inspect. 17531 * @returns {Array} Returns the new array of combined values. 17532 * @example 17533 * 17534 * _.union([2], [1, 2]); 17535 * // => [2, 1] 17536 */ 17537 var union = baseRest(function(arrays) { 17538 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true)); 17539 }); 17540 17541 /** 17542 * This method is like `_.union` except that it accepts `iteratee` which is 17543 * invoked for each element of each `arrays` to generate the criterion by 17544 * which uniqueness is computed. Result values are chosen from the first 17545 * array in which the value occurs. The iteratee is invoked with one argument: 17546 * (value). 17547 * 17548 * @static 17549 * @memberOf _ 17550 * @since 4.0.0 17551 * @category Array 17552 * @param {...Array} [arrays] The arrays to inspect. 17553 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 17554 * @returns {Array} Returns the new array of combined values. 17555 * @example 17556 * 17557 * _.unionBy([2.1], [1.2, 2.3], Math.floor); 17558 * // => [2.1, 1.2] 17559 * 17560 * // The `_.property` iteratee shorthand. 17561 * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); 17562 * // => [{ 'x': 1 }, { 'x': 2 }] 17563 */ 17564 var unionBy = baseRest(function(arrays) { 17565 var iteratee = last(arrays); 17566 if (isArrayLikeObject(iteratee)) { 17567 iteratee = undefined; 17568 } 17569 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2)); 17570 }); 17571 17572 /** 17573 * This method is like `_.union` except that it accepts `comparator` which 17574 * is invoked to compare elements of `arrays`. Result values are chosen from 17575 * the first array in which the value occurs. The comparator is invoked 17576 * with two arguments: (arrVal, othVal). 17577 * 17578 * @static 17579 * @memberOf _ 17580 * @since 4.0.0 17581 * @category Array 17582 * @param {...Array} [arrays] The arrays to inspect. 17583 * @param {Function} [comparator] The comparator invoked per element. 17584 * @returns {Array} Returns the new array of combined values. 17585 * @example 17586 * 17587 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 17588 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; 17589 * 17590 * _.unionWith(objects, others, _.isEqual); 17591 * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] 17592 */ 17593 var unionWith = baseRest(function(arrays) { 17594 var comparator = last(arrays); 17595 comparator = typeof comparator == 'function' ? comparator : undefined; 17596 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator); 17597 }); 17598 17599 /** 17600 * Creates a duplicate-free version of an array, using 17601 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 17602 * for equality comparisons, in which only the first occurrence of each element 17603 * is kept. The order of result values is determined by the order they occur 17604 * in the array. 17605 * 17606 * @static 17607 * @memberOf _ 17608 * @since 0.1.0 17609 * @category Array 17610 * @param {Array} array The array to inspect. 17611 * @returns {Array} Returns the new duplicate free array. 17612 * @example 17613 * 17614 * _.uniq([2, 1, 2]); 17615 * // => [2, 1] 17616 */ 17617 function uniq(array) { 17618 return (array && array.length) ? baseUniq(array) : []; 17619 } 17620 17621 /** 17622 * This method is like `_.uniq` except that it accepts `iteratee` which is 17623 * invoked for each element in `array` to generate the criterion by which 17624 * uniqueness is computed. The order of result values is determined by the 17625 * order they occur in the array. The iteratee is invoked with one argument: 17626 * (value). 17627 * 17628 * @static 17629 * @memberOf _ 17630 * @since 4.0.0 17631 * @category Array 17632 * @param {Array} array The array to inspect. 17633 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 17634 * @returns {Array} Returns the new duplicate free array. 17635 * @example 17636 * 17637 * _.uniqBy([2.1, 1.2, 2.3], Math.floor); 17638 * // => [2.1, 1.2] 17639 * 17640 * // The `_.property` iteratee shorthand. 17641 * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); 17642 * // => [{ 'x': 1 }, { 'x': 2 }] 17643 */ 17644 function uniqBy(array, iteratee) { 17645 return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : []; 17646 } 17647 17648 /** 17649 * This method is like `_.uniq` except that it accepts `comparator` which 17650 * is invoked to compare elements of `array`. The order of result values is 17651 * determined by the order they occur in the array.The comparator is invoked 17652 * with two arguments: (arrVal, othVal). 17653 * 17654 * @static 17655 * @memberOf _ 17656 * @since 4.0.0 17657 * @category Array 17658 * @param {Array} array The array to inspect. 17659 * @param {Function} [comparator] The comparator invoked per element. 17660 * @returns {Array} Returns the new duplicate free array. 17661 * @example 17662 * 17663 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }]; 17664 * 17665 * _.uniqWith(objects, _.isEqual); 17666 * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }] 17667 */ 17668 function uniqWith(array, comparator) { 17669 comparator = typeof comparator == 'function' ? comparator : undefined; 17670 return (array && array.length) ? baseUniq(array, undefined, comparator) : []; 17671 } 17672 17673 /** 17674 * This method is like `_.zip` except that it accepts an array of grouped 17675 * elements and creates an array regrouping the elements to their pre-zip 17676 * configuration. 17677 * 17678 * @static 17679 * @memberOf _ 17680 * @since 1.2.0 17681 * @category Array 17682 * @param {Array} array The array of grouped elements to process. 17683 * @returns {Array} Returns the new array of regrouped elements. 17684 * @example 17685 * 17686 * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]); 17687 * // => [['a', 1, true], ['b', 2, false]] 17688 * 17689 * _.unzip(zipped); 17690 * // => [['a', 'b'], [1, 2], [true, false]] 17691 */ 17692 function unzip(array) { 17693 if (!(array && array.length)) { 17694 return []; 17695 } 17696 var length = 0; 17697 array = arrayFilter(array, function(group) { 17698 if (isArrayLikeObject(group)) { 17699 length = nativeMax(group.length, length); 17700 return true; 17701 } 17702 }); 17703 return baseTimes(length, function(index) { 17704 return arrayMap(array, baseProperty(index)); 17705 }); 17706 } 17707 17708 /** 17709 * This method is like `_.unzip` except that it accepts `iteratee` to specify 17710 * how regrouped values should be combined. The iteratee is invoked with the 17711 * elements of each group: (...group). 17712 * 17713 * @static 17714 * @memberOf _ 17715 * @since 3.8.0 17716 * @category Array 17717 * @param {Array} array The array of grouped elements to process. 17718 * @param {Function} [iteratee=_.identity] The function to combine 17719 * regrouped values. 17720 * @returns {Array} Returns the new array of regrouped elements. 17721 * @example 17722 * 17723 * var zipped = _.zip([1, 2], [10, 20], [100, 200]); 17724 * // => [[1, 10, 100], [2, 20, 200]] 17725 * 17726 * _.unzipWith(zipped, _.add); 17727 * // => [3, 30, 300] 17728 */ 17729 function unzipWith(array, iteratee) { 17730 if (!(array && array.length)) { 17731 return []; 17732 } 17733 var result = unzip(array); 17734 if (iteratee == null) { 17735 return result; 17736 } 17737 return arrayMap(result, function(group) { 17738 return apply(iteratee, undefined, group); 17739 }); 17740 } 17741 17742 /** 17743 * Creates an array excluding all given values using 17744 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 17745 * for equality comparisons. 17746 * 17747 * **Note:** Unlike `_.pull`, this method returns a new array. 17748 * 17749 * @static 17750 * @memberOf _ 17751 * @since 0.1.0 17752 * @category Array 17753 * @param {Array} array The array to inspect. 17754 * @param {...*} [values] The values to exclude. 17755 * @returns {Array} Returns the new array of filtered values. 17756 * @see _.difference, _.xor 17757 * @example 17758 * 17759 * _.without([2, 1, 2, 3], 1, 2); 17760 * // => [3] 17761 */ 17762 var without = baseRest(function(array, values) { 17763 return isArrayLikeObject(array) 17764 ? baseDifference(array, values) 17765 : []; 17766 }); 17767 17768 /** 17769 * Creates an array of unique values that is the 17770 * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference) 17771 * of the given arrays. The order of result values is determined by the order 17772 * they occur in the arrays. 17773 * 17774 * @static 17775 * @memberOf _ 17776 * @since 2.4.0 17777 * @category Array 17778 * @param {...Array} [arrays] The arrays to inspect. 17779 * @returns {Array} Returns the new array of filtered values. 17780 * @see _.difference, _.without 17781 * @example 17782 * 17783 * _.xor([2, 1], [2, 3]); 17784 * // => [1, 3] 17785 */ 17786 var xor = baseRest(function(arrays) { 17787 return baseXor(arrayFilter(arrays, isArrayLikeObject)); 17788 }); 17789 17790 /** 17791 * This method is like `_.xor` except that it accepts `iteratee` which is 17792 * invoked for each element of each `arrays` to generate the criterion by 17793 * which by which they're compared. The order of result values is determined 17794 * by the order they occur in the arrays. The iteratee is invoked with one 17795 * argument: (value). 17796 * 17797 * @static 17798 * @memberOf _ 17799 * @since 4.0.0 17800 * @category Array 17801 * @param {...Array} [arrays] The arrays to inspect. 17802 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 17803 * @returns {Array} Returns the new array of filtered values. 17804 * @example 17805 * 17806 * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor); 17807 * // => [1.2, 3.4] 17808 * 17809 * // The `_.property` iteratee shorthand. 17810 * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); 17811 * // => [{ 'x': 2 }] 17812 */ 17813 var xorBy = baseRest(function(arrays) { 17814 var iteratee = last(arrays); 17815 if (isArrayLikeObject(iteratee)) { 17816 iteratee = undefined; 17817 } 17818 return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2)); 17819 }); 17820 17821 /** 17822 * This method is like `_.xor` except that it accepts `comparator` which is 17823 * invoked to compare elements of `arrays`. The order of result values is 17824 * determined by the order they occur in the arrays. The comparator is invoked 17825 * with two arguments: (arrVal, othVal). 17826 * 17827 * @static 17828 * @memberOf _ 17829 * @since 4.0.0 17830 * @category Array 17831 * @param {...Array} [arrays] The arrays to inspect. 17832 * @param {Function} [comparator] The comparator invoked per element. 17833 * @returns {Array} Returns the new array of filtered values. 17834 * @example 17835 * 17836 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 17837 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; 17838 * 17839 * _.xorWith(objects, others, _.isEqual); 17840 * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] 17841 */ 17842 var xorWith = baseRest(function(arrays) { 17843 var comparator = last(arrays); 17844 comparator = typeof comparator == 'function' ? comparator : undefined; 17845 return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator); 17846 }); 17847 17848 /** 17849 * Creates an array of grouped elements, the first of which contains the 17850 * first elements of the given arrays, the second of which contains the 17851 * second elements of the given arrays, and so on. 17852 * 17853 * @static 17854 * @memberOf _ 17855 * @since 0.1.0 17856 * @category Array 17857 * @param {...Array} [arrays] The arrays to process. 17858 * @returns {Array} Returns the new array of grouped elements. 17859 * @example 17860 * 17861 * _.zip(['a', 'b'], [1, 2], [true, false]); 17862 * // => [['a', 1, true], ['b', 2, false]] 17863 */ 17864 var zip = baseRest(unzip); 17865 17866 /** 17867 * This method is like `_.fromPairs` except that it accepts two arrays, 17868 * one of property identifiers and one of corresponding values. 17869 * 17870 * @static 17871 * @memberOf _ 17872 * @since 0.4.0 17873 * @category Array 17874 * @param {Array} [props=[]] The property identifiers. 17875 * @param {Array} [values=[]] The property values. 17876 * @returns {Object} Returns the new object. 17877 * @example 17878 * 17879 * _.zipObject(['a', 'b'], [1, 2]); 17880 * // => { 'a': 1, 'b': 2 } 17881 */ 17882 function zipObject(props, values) { 17883 return baseZipObject(props || [], values || [], assignValue); 17884 } 17885 17886 /** 17887 * This method is like `_.zipObject` except that it supports property paths. 17888 * 17889 * @static 17890 * @memberOf _ 17891 * @since 4.1.0 17892 * @category Array 17893 * @param {Array} [props=[]] The property identifiers. 17894 * @param {Array} [values=[]] The property values. 17895 * @returns {Object} Returns the new object. 17896 * @example 17897 * 17898 * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]); 17899 * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } } 17900 */ 17901 function zipObjectDeep(props, values) { 17902 return baseZipObject(props || [], values || [], baseSet); 17903 } 17904 17905 /** 17906 * This method is like `_.zip` except that it accepts `iteratee` to specify 17907 * how grouped values should be combined. The iteratee is invoked with the 17908 * elements of each group: (...group). 17909 * 17910 * @static 17911 * @memberOf _ 17912 * @since 3.8.0 17913 * @category Array 17914 * @param {...Array} [arrays] The arrays to process. 17915 * @param {Function} [iteratee=_.identity] The function to combine 17916 * grouped values. 17917 * @returns {Array} Returns the new array of grouped elements. 17918 * @example 17919 * 17920 * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) { 17921 * return a + b + c; 17922 * }); 17923 * // => [111, 222] 17924 */ 17925 var zipWith = baseRest(function(arrays) { 17926 var length = arrays.length, 17927 iteratee = length > 1 ? arrays[length - 1] : undefined; 17928 17929 iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined; 17930 return unzipWith(arrays, iteratee); 17931 }); 17932 17933 /*------------------------------------------------------------------------*/ 17934 17935 /** 17936 * Creates a `lodash` wrapper instance that wraps `value` with explicit method 17937 * chain sequences enabled. The result of such sequences must be unwrapped 17938 * with `_#value`. 17939 * 17940 * @static 17941 * @memberOf _ 17942 * @since 1.3.0 17943 * @category Seq 17944 * @param {*} value The value to wrap. 17945 * @returns {Object} Returns the new `lodash` wrapper instance. 17946 * @example 17947 * 17948 * var users = [ 17949 * { 'user': 'barney', 'age': 36 }, 17950 * { 'user': 'fred', 'age': 40 }, 17951 * { 'user': 'pebbles', 'age': 1 } 17952 * ]; 17953 * 17954 * var youngest = _ 17955 * .chain(users) 17956 * .sortBy('age') 17957 * .map(function(o) { 17958 * return o.user + ' is ' + o.age; 17959 * }) 17960 * .head() 17961 * .value(); 17962 * // => 'pebbles is 1' 17963 */ 17964 function chain(value) { 17965 var result = lodash(value); 17966 result.__chain__ = true; 17967 return result; 17968 } 17969 17970 /** 17971 * This method invokes `interceptor` and returns `value`. The interceptor 17972 * is invoked with one argument; (value). The purpose of this method is to 17973 * "tap into" a method chain sequence in order to modify intermediate results. 17974 * 17975 * @static 17976 * @memberOf _ 17977 * @since 0.1.0 17978 * @category Seq 17979 * @param {*} value The value to provide to `interceptor`. 17980 * @param {Function} interceptor The function to invoke. 17981 * @returns {*} Returns `value`. 17982 * @example 17983 * 17984 * _([1, 2, 3]) 17985 * .tap(function(array) { 17986 * // Mutate input array. 17987 * array.pop(); 17988 * }) 17989 * .reverse() 17990 * .value(); 17991 * // => [2, 1] 17992 */ 17993 function tap(value, interceptor) { 17994 interceptor(value); 17995 return value; 17996 } 17997 17998 /** 17999 * This method is like `_.tap` except that it returns the result of `interceptor`. 18000 * The purpose of this method is to "pass thru" values replacing intermediate 18001 * results in a method chain sequence. 18002 * 18003 * @static 18004 * @memberOf _ 18005 * @since 3.0.0 18006 * @category Seq 18007 * @param {*} value The value to provide to `interceptor`. 18008 * @param {Function} interceptor The function to invoke. 18009 * @returns {*} Returns the result of `interceptor`. 18010 * @example 18011 * 18012 * _(' abc ') 18013 * .chain() 18014 * .trim() 18015 * .thru(function(value) { 18016 * return [value]; 18017 * }) 18018 * .value(); 18019 * // => ['abc'] 18020 */ 18021 function thru(value, interceptor) { 18022 return interceptor(value); 18023 } 18024 18025 /** 18026 * This method is the wrapper version of `_.at`. 18027 * 18028 * @name at 18029 * @memberOf _ 18030 * @since 1.0.0 18031 * @category Seq 18032 * @param {...(string|string[])} [paths] The property paths to pick. 18033 * @returns {Object} Returns the new `lodash` wrapper instance. 18034 * @example 18035 * 18036 * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; 18037 * 18038 * _(object).at(['a[0].b.c', 'a[1]']).value(); 18039 * // => [3, 4] 18040 */ 18041 var wrapperAt = flatRest(function(paths) { 18042 var length = paths.length, 18043 start = length ? paths[0] : 0, 18044 value = this.__wrapped__, 18045 interceptor = function(object) { return baseAt(object, paths); }; 18046 18047 if (length > 1 || this.__actions__.length || 18048 !(value instanceof LazyWrapper) || !isIndex(start)) { 18049 return this.thru(interceptor); 18050 } 18051 value = value.slice(start, +start + (length ? 1 : 0)); 18052 value.__actions__.push({ 18053 'func': thru, 18054 'args': [interceptor], 18055 'thisArg': undefined 18056 }); 18057 return new LodashWrapper(value, this.__chain__).thru(function(array) { 18058 if (length && !array.length) { 18059 array.push(undefined); 18060 } 18061 return array; 18062 }); 18063 }); 18064 18065 /** 18066 * Creates a `lodash` wrapper instance with explicit method chain sequences enabled. 18067 * 18068 * @name chain 18069 * @memberOf _ 18070 * @since 0.1.0 18071 * @category Seq 18072 * @returns {Object} Returns the new `lodash` wrapper instance. 18073 * @example 18074 * 18075 * var users = [ 18076 * { 'user': 'barney', 'age': 36 }, 18077 * { 'user': 'fred', 'age': 40 } 18078 * ]; 18079 * 18080 * // A sequence without explicit chaining. 18081 * _(users).head(); 18082 * // => { 'user': 'barney', 'age': 36 } 18083 * 18084 * // A sequence with explicit chaining. 18085 * _(users) 18086 * .chain() 18087 * .head() 18088 * .pick('user') 18089 * .value(); 18090 * // => { 'user': 'barney' } 18091 */ 18092 function wrapperChain() { 18093 return chain(this); 18094 } 18095 18096 /** 18097 * Executes the chain sequence and returns the wrapped result. 18098 * 18099 * @name commit 18100 * @memberOf _ 18101 * @since 3.2.0 18102 * @category Seq 18103 * @returns {Object} Returns the new `lodash` wrapper instance. 18104 * @example 18105 * 18106 * var array = [1, 2]; 18107 * var wrapped = _(array).push(3); 18108 * 18109 * console.log(array); 18110 * // => [1, 2] 18111 * 18112 * wrapped = wrapped.commit(); 18113 * console.log(array); 18114 * // => [1, 2, 3] 18115 * 18116 * wrapped.last(); 18117 * // => 3 18118 * 18119 * console.log(array); 18120 * // => [1, 2, 3] 18121 */ 18122 function wrapperCommit() { 18123 return new LodashWrapper(this.value(), this.__chain__); 18124 } 18125 18126 /** 18127 * Gets the next value on a wrapped object following the 18128 * [iterator protocol](https://mdn.io/iteration_protocols#iterator). 18129 * 18130 * @name next 18131 * @memberOf _ 18132 * @since 4.0.0 18133 * @category Seq 18134 * @returns {Object} Returns the next iterator value. 18135 * @example 18136 * 18137 * var wrapped = _([1, 2]); 18138 * 18139 * wrapped.next(); 18140 * // => { 'done': false, 'value': 1 } 18141 * 18142 * wrapped.next(); 18143 * // => { 'done': false, 'value': 2 } 18144 * 18145 * wrapped.next(); 18146 * // => { 'done': true, 'value': undefined } 18147 */ 18148 function wrapperNext() { 18149 if (this.__values__ === undefined) { 18150 this.__values__ = toArray(this.value()); 18151 } 18152 var done = this.__index__ >= this.__values__.length, 18153 value = done ? undefined : this.__values__[this.__index__++]; 18154 18155 return { 'done': done, 'value': value }; 18156 } 18157 18158 /** 18159 * Enables the wrapper to be iterable. 18160 * 18161 * @name Symbol.iterator 18162 * @memberOf _ 18163 * @since 4.0.0 18164 * @category Seq 18165 * @returns {Object} Returns the wrapper object. 18166 * @example 18167 * 18168 * var wrapped = _([1, 2]); 18169 * 18170 * wrapped[Symbol.iterator]() === wrapped; 18171 * // => true 18172 * 18173 * Array.from(wrapped); 18174 * // => [1, 2] 18175 */ 18176 function wrapperToIterator() { 18177 return this; 18178 } 18179 18180 /** 18181 * Creates a clone of the chain sequence planting `value` as the wrapped value. 18182 * 18183 * @name plant 18184 * @memberOf _ 18185 * @since 3.2.0 18186 * @category Seq 18187 * @param {*} value The value to plant. 18188 * @returns {Object} Returns the new `lodash` wrapper instance. 18189 * @example 18190 * 18191 * function square(n) { 18192 * return n * n; 18193 * } 18194 * 18195 * var wrapped = _([1, 2]).map(square); 18196 * var other = wrapped.plant([3, 4]); 18197 * 18198 * other.value(); 18199 * // => [9, 16] 18200 * 18201 * wrapped.value(); 18202 * // => [1, 4] 18203 */ 18204 function wrapperPlant(value) { 18205 var result, 18206 parent = this; 18207 18208 while (parent instanceof baseLodash) { 18209 var clone = wrapperClone(parent); 18210 clone.__index__ = 0; 18211 clone.__values__ = undefined; 18212 if (result) { 18213 previous.__wrapped__ = clone; 18214 } else { 18215 result = clone; 18216 } 18217 var previous = clone; 18218 parent = parent.__wrapped__; 18219 } 18220 previous.__wrapped__ = value; 18221 return result; 18222 } 18223 18224 /** 18225 * This method is the wrapper version of `_.reverse`. 18226 * 18227 * **Note:** This method mutates the wrapped array. 18228 * 18229 * @name reverse 18230 * @memberOf _ 18231 * @since 0.1.0 18232 * @category Seq 18233 * @returns {Object} Returns the new `lodash` wrapper instance. 18234 * @example 18235 * 18236 * var array = [1, 2, 3]; 18237 * 18238 * _(array).reverse().value() 18239 * // => [3, 2, 1] 18240 * 18241 * console.log(array); 18242 * // => [3, 2, 1] 18243 */ 18244 function wrapperReverse() { 18245 var value = this.__wrapped__; 18246 if (value instanceof LazyWrapper) { 18247 var wrapped = value; 18248 if (this.__actions__.length) { 18249 wrapped = new LazyWrapper(this); 18250 } 18251 wrapped = wrapped.reverse(); 18252 wrapped.__actions__.push({ 18253 'func': thru, 18254 'args': [reverse], 18255 'thisArg': undefined 18256 }); 18257 return new LodashWrapper(wrapped, this.__chain__); 18258 } 18259 return this.thru(reverse); 18260 } 18261 18262 /** 18263 * Executes the chain sequence to resolve the unwrapped value. 18264 * 18265 * @name value 18266 * @memberOf _ 18267 * @since 0.1.0 18268 * @alias toJSON, valueOf 18269 * @category Seq 18270 * @returns {*} Returns the resolved unwrapped value. 18271 * @example 18272 * 18273 * _([1, 2, 3]).value(); 18274 * // => [1, 2, 3] 18275 */ 18276 function wrapperValue() { 18277 return baseWrapperValue(this.__wrapped__, this.__actions__); 18278 } 18279 18280 /*------------------------------------------------------------------------*/ 18281 18282 /** 18283 * Creates an object composed of keys generated from the results of running 18284 * each element of `collection` thru `iteratee`. The corresponding value of 18285 * each key is the number of times the key was returned by `iteratee`. The 18286 * iteratee is invoked with one argument: (value). 18287 * 18288 * @static 18289 * @memberOf _ 18290 * @since 0.5.0 18291 * @category Collection 18292 * @param {Array|Object} collection The collection to iterate over. 18293 * @param {Function} [iteratee=_.identity] The iteratee to transform keys. 18294 * @returns {Object} Returns the composed aggregate object. 18295 * @example 18296 * 18297 * _.countBy([6.1, 4.2, 6.3], Math.floor); 18298 * // => { '4': 1, '6': 2 } 18299 * 18300 * // The `_.property` iteratee shorthand. 18301 * _.countBy(['one', 'two', 'three'], 'length'); 18302 * // => { '3': 2, '5': 1 } 18303 */ 18304 var countBy = createAggregator(function(result, value, key) { 18305 if (hasOwnProperty.call(result, key)) { 18306 ++result[key]; 18307 } else { 18308 baseAssignValue(result, key, 1); 18309 } 18310 }); 18311 18312 /** 18313 * Checks if `predicate` returns truthy for **all** elements of `collection`. 18314 * Iteration is stopped once `predicate` returns falsey. The predicate is 18315 * invoked with three arguments: (value, index|key, collection). 18316 * 18317 * **Note:** This method returns `true` for 18318 * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because 18319 * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of 18320 * elements of empty collections. 18321 * 18322 * @static 18323 * @memberOf _ 18324 * @since 0.1.0 18325 * @category Collection 18326 * @param {Array|Object} collection The collection to iterate over. 18327 * @param {Function} [predicate=_.identity] The function invoked per iteration. 18328 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 18329 * @returns {boolean} Returns `true` if all elements pass the predicate check, 18330 * else `false`. 18331 * @example 18332 * 18333 * _.every([true, 1, null, 'yes'], Boolean); 18334 * // => false 18335 * 18336 * var users = [ 18337 * { 'user': 'barney', 'age': 36, 'active': false }, 18338 * { 'user': 'fred', 'age': 40, 'active': false } 18339 * ]; 18340 * 18341 * // The `_.matches` iteratee shorthand. 18342 * _.every(users, { 'user': 'barney', 'active': false }); 18343 * // => false 18344 * 18345 * // The `_.matchesProperty` iteratee shorthand. 18346 * _.every(users, ['active', false]); 18347 * // => true 18348 * 18349 * // The `_.property` iteratee shorthand. 18350 * _.every(users, 'active'); 18351 * // => false 18352 */ 18353 function every(collection, predicate, guard) { 18354 var func = isArray(collection) ? arrayEvery : baseEvery; 18355 if (guard && isIterateeCall(collection, predicate, guard)) { 18356 predicate = undefined; 18357 } 18358 return func(collection, getIteratee(predicate, 3)); 18359 } 18360 18361 /** 18362 * Iterates over elements of `collection`, returning an array of all elements 18363 * `predicate` returns truthy for. The predicate is invoked with three 18364 * arguments: (value, index|key, collection). 18365 * 18366 * **Note:** Unlike `_.remove`, this method returns a new array. 18367 * 18368 * @static 18369 * @memberOf _ 18370 * @since 0.1.0 18371 * @category Collection 18372 * @param {Array|Object} collection The collection to iterate over. 18373 * @param {Function} [predicate=_.identity] The function invoked per iteration. 18374 * @returns {Array} Returns the new filtered array. 18375 * @see _.reject 18376 * @example 18377 * 18378 * var users = [ 18379 * { 'user': 'barney', 'age': 36, 'active': true }, 18380 * { 'user': 'fred', 'age': 40, 'active': false } 18381 * ]; 18382 * 18383 * _.filter(users, function(o) { return !o.active; }); 18384 * // => objects for ['fred'] 18385 * 18386 * // The `_.matches` iteratee shorthand. 18387 * _.filter(users, { 'age': 36, 'active': true }); 18388 * // => objects for ['barney'] 18389 * 18390 * // The `_.matchesProperty` iteratee shorthand. 18391 * _.filter(users, ['active', false]); 18392 * // => objects for ['fred'] 18393 * 18394 * // The `_.property` iteratee shorthand. 18395 * _.filter(users, 'active'); 18396 * // => objects for ['barney'] 18397 * 18398 * // Combining several predicates using `_.overEvery` or `_.overSome`. 18399 * _.filter(users, _.overSome([{ 'age': 36 }, ['age', 40]])); 18400 * // => objects for ['fred', 'barney'] 18401 */ 18402 function filter(collection, predicate) { 18403 var func = isArray(collection) ? arrayFilter : baseFilter; 18404 return func(collection, getIteratee(predicate, 3)); 18405 } 18406 18407 /** 18408 * Iterates over elements of `collection`, returning the first element 18409 * `predicate` returns truthy for. The predicate is invoked with three 18410 * arguments: (value, index|key, collection). 18411 * 18412 * @static 18413 * @memberOf _ 18414 * @since 0.1.0 18415 * @category Collection 18416 * @param {Array|Object} collection The collection to inspect. 18417 * @param {Function} [predicate=_.identity] The function invoked per iteration. 18418 * @param {number} [fromIndex=0] The index to search from. 18419 * @returns {*} Returns the matched element, else `undefined`. 18420 * @example 18421 * 18422 * var users = [ 18423 * { 'user': 'barney', 'age': 36, 'active': true }, 18424 * { 'user': 'fred', 'age': 40, 'active': false }, 18425 * { 'user': 'pebbles', 'age': 1, 'active': true } 18426 * ]; 18427 * 18428 * _.find(users, function(o) { return o.age < 40; }); 18429 * // => object for 'barney' 18430 * 18431 * // The `_.matches` iteratee shorthand. 18432 * _.find(users, { 'age': 1, 'active': true }); 18433 * // => object for 'pebbles' 18434 * 18435 * // The `_.matchesProperty` iteratee shorthand. 18436 * _.find(users, ['active', false]); 18437 * // => object for 'fred' 18438 * 18439 * // The `_.property` iteratee shorthand. 18440 * _.find(users, 'active'); 18441 * // => object for 'barney' 18442 */ 18443 var find = createFind(findIndex); 18444 18445 /** 18446 * This method is like `_.find` except that it iterates over elements of 18447 * `collection` from right to left. 18448 * 18449 * @static 18450 * @memberOf _ 18451 * @since 2.0.0 18452 * @category Collection 18453 * @param {Array|Object} collection The collection to inspect. 18454 * @param {Function} [predicate=_.identity] The function invoked per iteration. 18455 * @param {number} [fromIndex=collection.length-1] The index to search from. 18456 * @returns {*} Returns the matched element, else `undefined`. 18457 * @example 18458 * 18459 * _.findLast([1, 2, 3, 4], function(n) { 18460 * return n % 2 == 1; 18461 * }); 18462 * // => 3 18463 */ 18464 var findLast = createFind(findLastIndex); 18465 18466 /** 18467 * Creates a flattened array of values by running each element in `collection` 18468 * thru `iteratee` and flattening the mapped results. The iteratee is invoked 18469 * with three arguments: (value, index|key, collection). 18470 * 18471 * @static 18472 * @memberOf _ 18473 * @since 4.0.0 18474 * @category Collection 18475 * @param {Array|Object} collection The collection to iterate over. 18476 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 18477 * @returns {Array} Returns the new flattened array. 18478 * @example 18479 * 18480 * function duplicate(n) { 18481 * return [n, n]; 18482 * } 18483 * 18484 * _.flatMap([1, 2], duplicate); 18485 * // => [1, 1, 2, 2] 18486 */ 18487 function flatMap(collection, iteratee) { 18488 return baseFlatten(map(collection, iteratee), 1); 18489 } 18490 18491 /** 18492 * This method is like `_.flatMap` except that it recursively flattens the 18493 * mapped results. 18494 * 18495 * @static 18496 * @memberOf _ 18497 * @since 4.7.0 18498 * @category Collection 18499 * @param {Array|Object} collection The collection to iterate over. 18500 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 18501 * @returns {Array} Returns the new flattened array. 18502 * @example 18503 * 18504 * function duplicate(n) { 18505 * return [[[n, n]]]; 18506 * } 18507 * 18508 * _.flatMapDeep([1, 2], duplicate); 18509 * // => [1, 1, 2, 2] 18510 */ 18511 function flatMapDeep(collection, iteratee) { 18512 return baseFlatten(map(collection, iteratee), INFINITY); 18513 } 18514 18515 /** 18516 * This method is like `_.flatMap` except that it recursively flattens the 18517 * mapped results up to `depth` times. 18518 * 18519 * @static 18520 * @memberOf _ 18521 * @since 4.7.0 18522 * @category Collection 18523 * @param {Array|Object} collection The collection to iterate over. 18524 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 18525 * @param {number} [depth=1] The maximum recursion depth. 18526 * @returns {Array} Returns the new flattened array. 18527 * @example 18528 * 18529 * function duplicate(n) { 18530 * return [[[n, n]]]; 18531 * } 18532 * 18533 * _.flatMapDepth([1, 2], duplicate, 2); 18534 * // => [[1, 1], [2, 2]] 18535 */ 18536 function flatMapDepth(collection, iteratee, depth) { 18537 depth = depth === undefined ? 1 : toInteger(depth); 18538 return baseFlatten(map(collection, iteratee), depth); 18539 } 18540 18541 /** 18542 * Iterates over elements of `collection` and invokes `iteratee` for each element. 18543 * The iteratee is invoked with three arguments: (value, index|key, collection). 18544 * Iteratee functions may exit iteration early by explicitly returning `false`. 18545 * 18546 * **Note:** As with other "Collections" methods, objects with a "length" 18547 * property are iterated like arrays. To avoid this behavior use `_.forIn` 18548 * or `_.forOwn` for object iteration. 18549 * 18550 * @static 18551 * @memberOf _ 18552 * @since 0.1.0 18553 * @alias each 18554 * @category Collection 18555 * @param {Array|Object} collection The collection to iterate over. 18556 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 18557 * @returns {Array|Object} Returns `collection`. 18558 * @see _.forEachRight 18559 * @example 18560 * 18561 * _.forEach([1, 2], function(value) { 18562 * console.log(value); 18563 * }); 18564 * // => Logs `1` then `2`. 18565 * 18566 * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) { 18567 * console.log(key); 18568 * }); 18569 * // => Logs 'a' then 'b' (iteration order is not guaranteed). 18570 */ 18571 function forEach(collection, iteratee) { 18572 var func = isArray(collection) ? arrayEach : baseEach; 18573 return func(collection, getIteratee(iteratee, 3)); 18574 } 18575 18576 /** 18577 * This method is like `_.forEach` except that it iterates over elements of 18578 * `collection` from right to left. 18579 * 18580 * @static 18581 * @memberOf _ 18582 * @since 2.0.0 18583 * @alias eachRight 18584 * @category Collection 18585 * @param {Array|Object} collection The collection to iterate over. 18586 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 18587 * @returns {Array|Object} Returns `collection`. 18588 * @see _.forEach 18589 * @example 18590 * 18591 * _.forEachRight([1, 2], function(value) { 18592 * console.log(value); 18593 * }); 18594 * // => Logs `2` then `1`. 18595 */ 18596 function forEachRight(collection, iteratee) { 18597 var func = isArray(collection) ? arrayEachRight : baseEachRight; 18598 return func(collection, getIteratee(iteratee, 3)); 18599 } 18600 18601 /** 18602 * Creates an object composed of keys generated from the results of running 18603 * each element of `collection` thru `iteratee`. The order of grouped values 18604 * is determined by the order they occur in `collection`. The corresponding 18605 * value of each key is an array of elements responsible for generating the 18606 * key. The iteratee is invoked with one argument: (value). 18607 * 18608 * @static 18609 * @memberOf _ 18610 * @since 0.1.0 18611 * @category Collection 18612 * @param {Array|Object} collection The collection to iterate over. 18613 * @param {Function} [iteratee=_.identity] The iteratee to transform keys. 18614 * @returns {Object} Returns the composed aggregate object. 18615 * @example 18616 * 18617 * _.groupBy([6.1, 4.2, 6.3], Math.floor); 18618 * // => { '4': [4.2], '6': [6.1, 6.3] } 18619 * 18620 * // The `_.property` iteratee shorthand. 18621 * _.groupBy(['one', 'two', 'three'], 'length'); 18622 * // => { '3': ['one', 'two'], '5': ['three'] } 18623 */ 18624 var groupBy = createAggregator(function(result, value, key) { 18625 if (hasOwnProperty.call(result, key)) { 18626 result[key].push(value); 18627 } else { 18628 baseAssignValue(result, key, [value]); 18629 } 18630 }); 18631 18632 /** 18633 * Checks if `value` is in `collection`. If `collection` is a string, it's 18634 * checked for a substring of `value`, otherwise 18635 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 18636 * is used for equality comparisons. If `fromIndex` is negative, it's used as 18637 * the offset from the end of `collection`. 18638 * 18639 * @static 18640 * @memberOf _ 18641 * @since 0.1.0 18642 * @category Collection 18643 * @param {Array|Object|string} collection The collection to inspect. 18644 * @param {*} value The value to search for. 18645 * @param {number} [fromIndex=0] The index to search from. 18646 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. 18647 * @returns {boolean} Returns `true` if `value` is found, else `false`. 18648 * @example 18649 * 18650 * _.includes([1, 2, 3], 1); 18651 * // => true 18652 * 18653 * _.includes([1, 2, 3], 1, 2); 18654 * // => false 18655 * 18656 * _.includes({ 'a': 1, 'b': 2 }, 1); 18657 * // => true 18658 * 18659 * _.includes('abcd', 'bc'); 18660 * // => true 18661 */ 18662 function includes(collection, value, fromIndex, guard) { 18663 collection = isArrayLike(collection) ? collection : values(collection); 18664 fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0; 18665 18666 var length = collection.length; 18667 if (fromIndex < 0) { 18668 fromIndex = nativeMax(length + fromIndex, 0); 18669 } 18670 return isString(collection) 18671 ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1) 18672 : (!!length && baseIndexOf(collection, value, fromIndex) > -1); 18673 } 18674 18675 /** 18676 * Invokes the method at `path` of each element in `collection`, returning 18677 * an array of the results of each invoked method. Any additional arguments 18678 * are provided to each invoked method. If `path` is a function, it's invoked 18679 * for, and `this` bound to, each element in `collection`. 18680 * 18681 * @static 18682 * @memberOf _ 18683 * @since 4.0.0 18684 * @category Collection 18685 * @param {Array|Object} collection The collection to iterate over. 18686 * @param {Array|Function|string} path The path of the method to invoke or 18687 * the function invoked per iteration. 18688 * @param {...*} [args] The arguments to invoke each method with. 18689 * @returns {Array} Returns the array of results. 18690 * @example 18691 * 18692 * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort'); 18693 * // => [[1, 5, 7], [1, 2, 3]] 18694 * 18695 * _.invokeMap([123, 456], String.prototype.split, ''); 18696 * // => [['1', '2', '3'], ['4', '5', '6']] 18697 */ 18698 var invokeMap = baseRest(function(collection, path, args) { 18699 var index = -1, 18700 isFunc = typeof path == 'function', 18701 result = isArrayLike(collection) ? Array(collection.length) : []; 18702 18703 baseEach(collection, function(value) { 18704 result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args); 18705 }); 18706 return result; 18707 }); 18708 18709 /** 18710 * Creates an object composed of keys generated from the results of running 18711 * each element of `collection` thru `iteratee`. The corresponding value of 18712 * each key is the last element responsible for generating the key. The 18713 * iteratee is invoked with one argument: (value). 18714 * 18715 * @static 18716 * @memberOf _ 18717 * @since 4.0.0 18718 * @category Collection 18719 * @param {Array|Object} collection The collection to iterate over. 18720 * @param {Function} [iteratee=_.identity] The iteratee to transform keys. 18721 * @returns {Object} Returns the composed aggregate object. 18722 * @example 18723 * 18724 * var array = [ 18725 * { 'dir': 'left', 'code': 97 }, 18726 * { 'dir': 'right', 'code': 100 } 18727 * ]; 18728 * 18729 * _.keyBy(array, function(o) { 18730 * return String.fromCharCode(o.code); 18731 * }); 18732 * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } 18733 * 18734 * _.keyBy(array, 'dir'); 18735 * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } 18736 */ 18737 var keyBy = createAggregator(function(result, value, key) { 18738 baseAssignValue(result, key, value); 18739 }); 18740 18741 /** 18742 * Creates an array of values by running each element in `collection` thru 18743 * `iteratee`. The iteratee is invoked with three arguments: 18744 * (value, index|key, collection). 18745 * 18746 * Many lodash methods are guarded to work as iteratees for methods like 18747 * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`. 18748 * 18749 * The guarded methods are: 18750 * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`, 18751 * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`, 18752 * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`, 18753 * `template`, `trim`, `trimEnd`, `trimStart`, and `words` 18754 * 18755 * @static 18756 * @memberOf _ 18757 * @since 0.1.0 18758 * @category Collection 18759 * @param {Array|Object} collection The collection to iterate over. 18760 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 18761 * @returns {Array} Returns the new mapped array. 18762 * @example 18763 * 18764 * function square(n) { 18765 * return n * n; 18766 * } 18767 * 18768 * _.map([4, 8], square); 18769 * // => [16, 64] 18770 * 18771 * _.map({ 'a': 4, 'b': 8 }, square); 18772 * // => [16, 64] (iteration order is not guaranteed) 18773 * 18774 * var users = [ 18775 * { 'user': 'barney' }, 18776 * { 'user': 'fred' } 18777 * ]; 18778 * 18779 * // The `_.property` iteratee shorthand. 18780 * _.map(users, 'user'); 18781 * // => ['barney', 'fred'] 18782 */ 18783 function map(collection, iteratee) { 18784 var func = isArray(collection) ? arrayMap : baseMap; 18785 return func(collection, getIteratee(iteratee, 3)); 18786 } 18787 18788 /** 18789 * This method is like `_.sortBy` except that it allows specifying the sort 18790 * orders of the iteratees to sort by. If `orders` is unspecified, all values 18791 * are sorted in ascending order. Otherwise, specify an order of "desc" for 18792 * descending or "asc" for ascending sort order of corresponding values. 18793 * 18794 * @static 18795 * @memberOf _ 18796 * @since 4.0.0 18797 * @category Collection 18798 * @param {Array|Object} collection The collection to iterate over. 18799 * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]] 18800 * The iteratees to sort by. 18801 * @param {string[]} [orders] The sort orders of `iteratees`. 18802 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. 18803 * @returns {Array} Returns the new sorted array. 18804 * @example 18805 * 18806 * var users = [ 18807 * { 'user': 'fred', 'age': 48 }, 18808 * { 'user': 'barney', 'age': 34 }, 18809 * { 'user': 'fred', 'age': 40 }, 18810 * { 'user': 'barney', 'age': 36 } 18811 * ]; 18812 * 18813 * // Sort by `user` in ascending order and by `age` in descending order. 18814 * _.orderBy(users, ['user', 'age'], ['asc', 'desc']); 18815 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] 18816 */ 18817 function orderBy(collection, iteratees, orders, guard) { 18818 if (collection == null) { 18819 return []; 18820 } 18821 if (!isArray(iteratees)) { 18822 iteratees = iteratees == null ? [] : [iteratees]; 18823 } 18824 orders = guard ? undefined : orders; 18825 if (!isArray(orders)) { 18826 orders = orders == null ? [] : [orders]; 18827 } 18828 return baseOrderBy(collection, iteratees, orders); 18829 } 18830 18831 /** 18832 * Creates an array of elements split into two groups, the first of which 18833 * contains elements `predicate` returns truthy for, the second of which 18834 * contains elements `predicate` returns falsey for. The predicate is 18835 * invoked with one argument: (value). 18836 * 18837 * @static 18838 * @memberOf _ 18839 * @since 3.0.0 18840 * @category Collection 18841 * @param {Array|Object} collection The collection to iterate over. 18842 * @param {Function} [predicate=_.identity] The function invoked per iteration. 18843 * @returns {Array} Returns the array of grouped elements. 18844 * @example 18845 * 18846 * var users = [ 18847 * { 'user': 'barney', 'age': 36, 'active': false }, 18848 * { 'user': 'fred', 'age': 40, 'active': true }, 18849 * { 'user': 'pebbles', 'age': 1, 'active': false } 18850 * ]; 18851 * 18852 * _.partition(users, function(o) { return o.active; }); 18853 * // => objects for [['fred'], ['barney', 'pebbles']] 18854 * 18855 * // The `_.matches` iteratee shorthand. 18856 * _.partition(users, { 'age': 1, 'active': false }); 18857 * // => objects for [['pebbles'], ['barney', 'fred']] 18858 * 18859 * // The `_.matchesProperty` iteratee shorthand. 18860 * _.partition(users, ['active', false]); 18861 * // => objects for [['barney', 'pebbles'], ['fred']] 18862 * 18863 * // The `_.property` iteratee shorthand. 18864 * _.partition(users, 'active'); 18865 * // => objects for [['fred'], ['barney', 'pebbles']] 18866 */ 18867 var partition = createAggregator(function(result, value, key) { 18868 result[key ? 0 : 1].push(value); 18869 }, function() { return [[], []]; }); 18870 18871 /** 18872 * Reduces `collection` to a value which is the accumulated result of running 18873 * each element in `collection` thru `iteratee`, where each successive 18874 * invocation is supplied the return value of the previous. If `accumulator` 18875 * is not given, the first element of `collection` is used as the initial 18876 * value. The iteratee is invoked with four arguments: 18877 * (accumulator, value, index|key, collection). 18878 * 18879 * Many lodash methods are guarded to work as iteratees for methods like 18880 * `_.reduce`, `_.reduceRight`, and `_.transform`. 18881 * 18882 * The guarded methods are: 18883 * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`, 18884 * and `sortBy` 18885 * 18886 * @static 18887 * @memberOf _ 18888 * @since 0.1.0 18889 * @category Collection 18890 * @param {Array|Object} collection The collection to iterate over. 18891 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 18892 * @param {*} [accumulator] The initial value. 18893 * @returns {*} Returns the accumulated value. 18894 * @see _.reduceRight 18895 * @example 18896 * 18897 * _.reduce([1, 2], function(sum, n) { 18898 * return sum + n; 18899 * }, 0); 18900 * // => 3 18901 * 18902 * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { 18903 * (result[value] || (result[value] = [])).push(key); 18904 * return result; 18905 * }, {}); 18906 * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed) 18907 */ 18908 function reduce(collection, iteratee, accumulator) { 18909 var func = isArray(collection) ? arrayReduce : baseReduce, 18910 initAccum = arguments.length < 3; 18911 18912 return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach); 18913 } 18914 18915 /** 18916 * This method is like `_.reduce` except that it iterates over elements of 18917 * `collection` from right to left. 18918 * 18919 * @static 18920 * @memberOf _ 18921 * @since 0.1.0 18922 * @category Collection 18923 * @param {Array|Object} collection The collection to iterate over. 18924 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 18925 * @param {*} [accumulator] The initial value. 18926 * @returns {*} Returns the accumulated value. 18927 * @see _.reduce 18928 * @example 18929 * 18930 * var array = [[0, 1], [2, 3], [4, 5]]; 18931 * 18932 * _.reduceRight(array, function(flattened, other) { 18933 * return flattened.concat(other); 18934 * }, []); 18935 * // => [4, 5, 2, 3, 0, 1] 18936 */ 18937 function reduceRight(collection, iteratee, accumulator) { 18938 var func = isArray(collection) ? arrayReduceRight : baseReduce, 18939 initAccum = arguments.length < 3; 18940 18941 return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight); 18942 } 18943 18944 /** 18945 * The opposite of `_.filter`; this method returns the elements of `collection` 18946 * that `predicate` does **not** return truthy for. 18947 * 18948 * @static 18949 * @memberOf _ 18950 * @since 0.1.0 18951 * @category Collection 18952 * @param {Array|Object} collection The collection to iterate over. 18953 * @param {Function} [predicate=_.identity] The function invoked per iteration. 18954 * @returns {Array} Returns the new filtered array. 18955 * @see _.filter 18956 * @example 18957 * 18958 * var users = [ 18959 * { 'user': 'barney', 'age': 36, 'active': false }, 18960 * { 'user': 'fred', 'age': 40, 'active': true } 18961 * ]; 18962 * 18963 * _.reject(users, function(o) { return !o.active; }); 18964 * // => objects for ['fred'] 18965 * 18966 * // The `_.matches` iteratee shorthand. 18967 * _.reject(users, { 'age': 40, 'active': true }); 18968 * // => objects for ['barney'] 18969 * 18970 * // The `_.matchesProperty` iteratee shorthand. 18971 * _.reject(users, ['active', false]); 18972 * // => objects for ['fred'] 18973 * 18974 * // The `_.property` iteratee shorthand. 18975 * _.reject(users, 'active'); 18976 * // => objects for ['barney'] 18977 */ 18978 function reject(collection, predicate) { 18979 var func = isArray(collection) ? arrayFilter : baseFilter; 18980 return func(collection, negate(getIteratee(predicate, 3))); 18981 } 18982 18983 /** 18984 * Gets a random element from `collection`. 18985 * 18986 * @static 18987 * @memberOf _ 18988 * @since 2.0.0 18989 * @category Collection 18990 * @param {Array|Object} collection The collection to sample. 18991 * @returns {*} Returns the random element. 18992 * @example 18993 * 18994 * _.sample([1, 2, 3, 4]); 18995 * // => 2 18996 */ 18997 function sample(collection) { 18998 var func = isArray(collection) ? arraySample : baseSample; 18999 return func(collection); 19000 } 19001 19002 /** 19003 * Gets `n` random elements at unique keys from `collection` up to the 19004 * size of `collection`. 19005 * 19006 * @static 19007 * @memberOf _ 19008 * @since 4.0.0 19009 * @category Collection 19010 * @param {Array|Object} collection The collection to sample. 19011 * @param {number} [n=1] The number of elements to sample. 19012 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 19013 * @returns {Array} Returns the random elements. 19014 * @example 19015 * 19016 * _.sampleSize([1, 2, 3], 2); 19017 * // => [3, 1] 19018 * 19019 * _.sampleSize([1, 2, 3], 4); 19020 * // => [2, 3, 1] 19021 */ 19022 function sampleSize(collection, n, guard) { 19023 if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) { 19024 n = 1; 19025 } else { 19026 n = toInteger(n); 19027 } 19028 var func = isArray(collection) ? arraySampleSize : baseSampleSize; 19029 return func(collection, n); 19030 } 19031 19032 /** 19033 * Creates an array of shuffled values, using a version of the 19034 * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle). 19035 * 19036 * @static 19037 * @memberOf _ 19038 * @since 0.1.0 19039 * @category Collection 19040 * @param {Array|Object} collection The collection to shuffle. 19041 * @returns {Array} Returns the new shuffled array. 19042 * @example 19043 * 19044 * _.shuffle([1, 2, 3, 4]); 19045 * // => [4, 1, 3, 2] 19046 */ 19047 function shuffle(collection) { 19048 var func = isArray(collection) ? arrayShuffle : baseShuffle; 19049 return func(collection); 19050 } 19051 19052 /** 19053 * Gets the size of `collection` by returning its length for array-like 19054 * values or the number of own enumerable string keyed properties for objects. 19055 * 19056 * @static 19057 * @memberOf _ 19058 * @since 0.1.0 19059 * @category Collection 19060 * @param {Array|Object|string} collection The collection to inspect. 19061 * @returns {number} Returns the collection size. 19062 * @example 19063 * 19064 * _.size([1, 2, 3]); 19065 * // => 3 19066 * 19067 * _.size({ 'a': 1, 'b': 2 }); 19068 * // => 2 19069 * 19070 * _.size('pebbles'); 19071 * // => 7 19072 */ 19073 function size(collection) { 19074 if (collection == null) { 19075 return 0; 19076 } 19077 if (isArrayLike(collection)) { 19078 return isString(collection) ? stringSize(collection) : collection.length; 19079 } 19080 var tag = getTag(collection); 19081 if (tag == mapTag || tag == setTag) { 19082 return collection.size; 19083 } 19084 return baseKeys(collection).length; 19085 } 19086 19087 /** 19088 * Checks if `predicate` returns truthy for **any** element of `collection`. 19089 * Iteration is stopped once `predicate` returns truthy. The predicate is 19090 * invoked with three arguments: (value, index|key, collection). 19091 * 19092 * @static 19093 * @memberOf _ 19094 * @since 0.1.0 19095 * @category Collection 19096 * @param {Array|Object} collection The collection to iterate over. 19097 * @param {Function} [predicate=_.identity] The function invoked per iteration. 19098 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 19099 * @returns {boolean} Returns `true` if any element passes the predicate check, 19100 * else `false`. 19101 * @example 19102 * 19103 * _.some([null, 0, 'yes', false], Boolean); 19104 * // => true 19105 * 19106 * var users = [ 19107 * { 'user': 'barney', 'active': true }, 19108 * { 'user': 'fred', 'active': false } 19109 * ]; 19110 * 19111 * // The `_.matches` iteratee shorthand. 19112 * _.some(users, { 'user': 'barney', 'active': false }); 19113 * // => false 19114 * 19115 * // The `_.matchesProperty` iteratee shorthand. 19116 * _.some(users, ['active', false]); 19117 * // => true 19118 * 19119 * // The `_.property` iteratee shorthand. 19120 * _.some(users, 'active'); 19121 * // => true 19122 */ 19123 function some(collection, predicate, guard) { 19124 var func = isArray(collection) ? arraySome : baseSome; 19125 if (guard && isIterateeCall(collection, predicate, guard)) { 19126 predicate = undefined; 19127 } 19128 return func(collection, getIteratee(predicate, 3)); 19129 } 19130 19131 /** 19132 * Creates an array of elements, sorted in ascending order by the results of 19133 * running each element in a collection thru each iteratee. This method 19134 * performs a stable sort, that is, it preserves the original sort order of 19135 * equal elements. The iteratees are invoked with one argument: (value). 19136 * 19137 * @static 19138 * @memberOf _ 19139 * @since 0.1.0 19140 * @category Collection 19141 * @param {Array|Object} collection The collection to iterate over. 19142 * @param {...(Function|Function[])} [iteratees=[_.identity]] 19143 * The iteratees to sort by. 19144 * @returns {Array} Returns the new sorted array. 19145 * @example 19146 * 19147 * var users = [ 19148 * { 'user': 'fred', 'age': 48 }, 19149 * { 'user': 'barney', 'age': 36 }, 19150 * { 'user': 'fred', 'age': 30 }, 19151 * { 'user': 'barney', 'age': 34 } 19152 * ]; 19153 * 19154 * _.sortBy(users, [function(o) { return o.user; }]); 19155 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 30]] 19156 * 19157 * _.sortBy(users, ['user', 'age']); 19158 * // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]] 19159 */ 19160 var sortBy = baseRest(function(collection, iteratees) { 19161 if (collection == null) { 19162 return []; 19163 } 19164 var length = iteratees.length; 19165 if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) { 19166 iteratees = []; 19167 } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) { 19168 iteratees = [iteratees[0]]; 19169 } 19170 return baseOrderBy(collection, baseFlatten(iteratees, 1), []); 19171 }); 19172 19173 /*------------------------------------------------------------------------*/ 19174 19175 /** 19176 * Gets the timestamp of the number of milliseconds that have elapsed since 19177 * the Unix epoch (1 January 1970 00:00:00 UTC). 19178 * 19179 * @static 19180 * @memberOf _ 19181 * @since 2.4.0 19182 * @category Date 19183 * @returns {number} Returns the timestamp. 19184 * @example 19185 * 19186 * _.defer(function(stamp) { 19187 * console.log(_.now() - stamp); 19188 * }, _.now()); 19189 * // => Logs the number of milliseconds it took for the deferred invocation. 19190 */ 19191 var now = ctxNow || function() { 19192 return root.Date.now(); 19193 }; 19194 19195 /*------------------------------------------------------------------------*/ 19196 19197 /** 19198 * The opposite of `_.before`; this method creates a function that invokes 19199 * `func` once it's called `n` or more times. 19200 * 19201 * @static 19202 * @memberOf _ 19203 * @since 0.1.0 19204 * @category Function 19205 * @param {number} n The number of calls before `func` is invoked. 19206 * @param {Function} func The function to restrict. 19207 * @returns {Function} Returns the new restricted function. 19208 * @example 19209 * 19210 * var saves = ['profile', 'settings']; 19211 * 19212 * var done = _.after(saves.length, function() { 19213 * console.log('done saving!'); 19214 * }); 19215 * 19216 * _.forEach(saves, function(type) { 19217 * asyncSave({ 'type': type, 'complete': done }); 19218 * }); 19219 * // => Logs 'done saving!' after the two async saves have completed. 19220 */ 19221 function after(n, func) { 19222 if (typeof func != 'function') { 19223 throw new TypeError(FUNC_ERROR_TEXT); 19224 } 19225 n = toInteger(n); 19226 return function() { 19227 if (--n < 1) { 19228 return func.apply(this, arguments); 19229 } 19230 }; 19231 } 19232 19233 /** 19234 * Creates a function that invokes `func`, with up to `n` arguments, 19235 * ignoring any additional arguments. 19236 * 19237 * @static 19238 * @memberOf _ 19239 * @since 3.0.0 19240 * @category Function 19241 * @param {Function} func The function to cap arguments for. 19242 * @param {number} [n=func.length] The arity cap. 19243 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 19244 * @returns {Function} Returns the new capped function. 19245 * @example 19246 * 19247 * _.map(['6', '8', '10'], _.ary(parseInt, 1)); 19248 * // => [6, 8, 10] 19249 */ 19250 function ary(func, n, guard) { 19251 n = guard ? undefined : n; 19252 n = (func && n == null) ? func.length : n; 19253 return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n); 19254 } 19255 19256 /** 19257 * Creates a function that invokes `func`, with the `this` binding and arguments 19258 * of the created function, while it's called less than `n` times. Subsequent 19259 * calls to the created function return the result of the last `func` invocation. 19260 * 19261 * @static 19262 * @memberOf _ 19263 * @since 3.0.0 19264 * @category Function 19265 * @param {number} n The number of calls at which `func` is no longer invoked. 19266 * @param {Function} func The function to restrict. 19267 * @returns {Function} Returns the new restricted function. 19268 * @example 19269 * 19270 * jQuery(element).on('click', _.before(5, addContactToList)); 19271 * // => Allows adding up to 4 contacts to the list. 19272 */ 19273 function before(n, func) { 19274 var result; 19275 if (typeof func != 'function') { 19276 throw new TypeError(FUNC_ERROR_TEXT); 19277 } 19278 n = toInteger(n); 19279 return function() { 19280 if (--n > 0) { 19281 result = func.apply(this, arguments); 19282 } 19283 if (n <= 1) { 19284 func = undefined; 19285 } 19286 return result; 19287 }; 19288 } 19289 19290 /** 19291 * Creates a function that invokes `func` with the `this` binding of `thisArg` 19292 * and `partials` prepended to the arguments it receives. 19293 * 19294 * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds, 19295 * may be used as a placeholder for partially applied arguments. 19296 * 19297 * **Note:** Unlike native `Function#bind`, this method doesn't set the "length" 19298 * property of bound functions. 19299 * 19300 * @static 19301 * @memberOf _ 19302 * @since 0.1.0 19303 * @category Function 19304 * @param {Function} func The function to bind. 19305 * @param {*} thisArg The `this` binding of `func`. 19306 * @param {...*} [partials] The arguments to be partially applied. 19307 * @returns {Function} Returns the new bound function. 19308 * @example 19309 * 19310 * function greet(greeting, punctuation) { 19311 * return greeting + ' ' + this.user + punctuation; 19312 * } 19313 * 19314 * var object = { 'user': 'fred' }; 19315 * 19316 * var bound = _.bind(greet, object, 'hi'); 19317 * bound('!'); 19318 * // => 'hi fred!' 19319 * 19320 * // Bound with placeholders. 19321 * var bound = _.bind(greet, object, _, '!'); 19322 * bound('hi'); 19323 * // => 'hi fred!' 19324 */ 19325 var bind = baseRest(function(func, thisArg, partials) { 19326 var bitmask = WRAP_BIND_FLAG; 19327 if (partials.length) { 19328 var holders = replaceHolders(partials, getHolder(bind)); 19329 bitmask |= WRAP_PARTIAL_FLAG; 19330 } 19331 return createWrap(func, bitmask, thisArg, partials, holders); 19332 }); 19333 19334 /** 19335 * Creates a function that invokes the method at `object[key]` with `partials` 19336 * prepended to the arguments it receives. 19337 * 19338 * This method differs from `_.bind` by allowing bound functions to reference 19339 * methods that may be redefined or don't yet exist. See 19340 * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern) 19341 * for more details. 19342 * 19343 * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic 19344 * builds, may be used as a placeholder for partially applied arguments. 19345 * 19346 * @static 19347 * @memberOf _ 19348 * @since 0.10.0 19349 * @category Function 19350 * @param {Object} object The object to invoke the method on. 19351 * @param {string} key The key of the method. 19352 * @param {...*} [partials] The arguments to be partially applied. 19353 * @returns {Function} Returns the new bound function. 19354 * @example 19355 * 19356 * var object = { 19357 * 'user': 'fred', 19358 * 'greet': function(greeting, punctuation) { 19359 * return greeting + ' ' + this.user + punctuation; 19360 * } 19361 * }; 19362 * 19363 * var bound = _.bindKey(object, 'greet', 'hi'); 19364 * bound('!'); 19365 * // => 'hi fred!' 19366 * 19367 * object.greet = function(greeting, punctuation) { 19368 * return greeting + 'ya ' + this.user + punctuation; 19369 * }; 19370 * 19371 * bound('!'); 19372 * // => 'hiya fred!' 19373 * 19374 * // Bound with placeholders. 19375 * var bound = _.bindKey(object, 'greet', _, '!'); 19376 * bound('hi'); 19377 * // => 'hiya fred!' 19378 */ 19379 var bindKey = baseRest(function(object, key, partials) { 19380 var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG; 19381 if (partials.length) { 19382 var holders = replaceHolders(partials, getHolder(bindKey)); 19383 bitmask |= WRAP_PARTIAL_FLAG; 19384 } 19385 return createWrap(key, bitmask, object, partials, holders); 19386 }); 19387 19388 /** 19389 * Creates a function that accepts arguments of `func` and either invokes 19390 * `func` returning its result, if at least `arity` number of arguments have 19391 * been provided, or returns a function that accepts the remaining `func` 19392 * arguments, and so on. The arity of `func` may be specified if `func.length` 19393 * is not sufficient. 19394 * 19395 * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds, 19396 * may be used as a placeholder for provided arguments. 19397 * 19398 * **Note:** This method doesn't set the "length" property of curried functions. 19399 * 19400 * @static 19401 * @memberOf _ 19402 * @since 2.0.0 19403 * @category Function 19404 * @param {Function} func The function to curry. 19405 * @param {number} [arity=func.length] The arity of `func`. 19406 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 19407 * @returns {Function} Returns the new curried function. 19408 * @example 19409 * 19410 * var abc = function(a, b, c) { 19411 * return [a, b, c]; 19412 * }; 19413 * 19414 * var curried = _.curry(abc); 19415 * 19416 * curried(1)(2)(3); 19417 * // => [1, 2, 3] 19418 * 19419 * curried(1, 2)(3); 19420 * // => [1, 2, 3] 19421 * 19422 * curried(1, 2, 3); 19423 * // => [1, 2, 3] 19424 * 19425 * // Curried with placeholders. 19426 * curried(1)(_, 3)(2); 19427 * // => [1, 2, 3] 19428 */ 19429 function curry(func, arity, guard) { 19430 arity = guard ? undefined : arity; 19431 var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity); 19432 result.placeholder = curry.placeholder; 19433 return result; 19434 } 19435 19436 /** 19437 * This method is like `_.curry` except that arguments are applied to `func` 19438 * in the manner of `_.partialRight` instead of `_.partial`. 19439 * 19440 * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic 19441 * builds, may be used as a placeholder for provided arguments. 19442 * 19443 * **Note:** This method doesn't set the "length" property of curried functions. 19444 * 19445 * @static 19446 * @memberOf _ 19447 * @since 3.0.0 19448 * @category Function 19449 * @param {Function} func The function to curry. 19450 * @param {number} [arity=func.length] The arity of `func`. 19451 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 19452 * @returns {Function} Returns the new curried function. 19453 * @example 19454 * 19455 * var abc = function(a, b, c) { 19456 * return [a, b, c]; 19457 * }; 19458 * 19459 * var curried = _.curryRight(abc); 19460 * 19461 * curried(3)(2)(1); 19462 * // => [1, 2, 3] 19463 * 19464 * curried(2, 3)(1); 19465 * // => [1, 2, 3] 19466 * 19467 * curried(1, 2, 3); 19468 * // => [1, 2, 3] 19469 * 19470 * // Curried with placeholders. 19471 * curried(3)(1, _)(2); 19472 * // => [1, 2, 3] 19473 */ 19474 function curryRight(func, arity, guard) { 19475 arity = guard ? undefined : arity; 19476 var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity); 19477 result.placeholder = curryRight.placeholder; 19478 return result; 19479 } 19480 19481 /** 19482 * Creates a debounced function that delays invoking `func` until after `wait` 19483 * milliseconds have elapsed since the last time the debounced function was 19484 * invoked. The debounced function comes with a `cancel` method to cancel 19485 * delayed `func` invocations and a `flush` method to immediately invoke them. 19486 * Provide `options` to indicate whether `func` should be invoked on the 19487 * leading and/or trailing edge of the `wait` timeout. The `func` is invoked 19488 * with the last arguments provided to the debounced function. Subsequent 19489 * calls to the debounced function return the result of the last `func` 19490 * invocation. 19491 * 19492 * **Note:** If `leading` and `trailing` options are `true`, `func` is 19493 * invoked on the trailing edge of the timeout only if the debounced function 19494 * is invoked more than once during the `wait` timeout. 19495 * 19496 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred 19497 * until to the next tick, similar to `setTimeout` with a timeout of `0`. 19498 * 19499 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) 19500 * for details over the differences between `_.debounce` and `_.throttle`. 19501 * 19502 * @static 19503 * @memberOf _ 19504 * @since 0.1.0 19505 * @category Function 19506 * @param {Function} func The function to debounce. 19507 * @param {number} [wait=0] The number of milliseconds to delay. 19508 * @param {Object} [options={}] The options object. 19509 * @param {boolean} [options.leading=false] 19510 * Specify invoking on the leading edge of the timeout. 19511 * @param {number} [options.maxWait] 19512 * The maximum time `func` is allowed to be delayed before it's invoked. 19513 * @param {boolean} [options.trailing=true] 19514 * Specify invoking on the trailing edge of the timeout. 19515 * @returns {Function} Returns the new debounced function. 19516 * @example 19517 * 19518 * // Avoid costly calculations while the window size is in flux. 19519 * jQuery(window).on('resize', _.debounce(calculateLayout, 150)); 19520 * 19521 * // Invoke `sendMail` when clicked, debouncing subsequent calls. 19522 * jQuery(element).on('click', _.debounce(sendMail, 300, { 19523 * 'leading': true, 19524 * 'trailing': false 19525 * })); 19526 * 19527 * // Ensure `batchLog` is invoked once after 1 second of debounced calls. 19528 * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 }); 19529 * var source = new EventSource('/stream'); 19530 * jQuery(source).on('message', debounced); 19531 * 19532 * // Cancel the trailing debounced invocation. 19533 * jQuery(window).on('popstate', debounced.cancel); 19534 */ 19535 function debounce(func, wait, options) { 19536 var lastArgs, 19537 lastThis, 19538 maxWait, 19539 result, 19540 timerId, 19541 lastCallTime, 19542 lastInvokeTime = 0, 19543 leading = false, 19544 maxing = false, 19545 trailing = true; 19546 19547 if (typeof func != 'function') { 19548 throw new TypeError(FUNC_ERROR_TEXT); 19549 } 19550 wait = toNumber(wait) || 0; 19551 if (isObject(options)) { 19552 leading = !!options.leading; 19553 maxing = 'maxWait' in options; 19554 maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait; 19555 trailing = 'trailing' in options ? !!options.trailing : trailing; 19556 } 19557 19558 function invokeFunc(time) { 19559 var args = lastArgs, 19560 thisArg = lastThis; 19561 19562 lastArgs = lastThis = undefined; 19563 lastInvokeTime = time; 19564 result = func.apply(thisArg, args); 19565 return result; 19566 } 19567 19568 function leadingEdge(time) { 19569 // Reset any `maxWait` timer. 19570 lastInvokeTime = time; 19571 // Start the timer for the trailing edge. 19572 timerId = setTimeout(timerExpired, wait); 19573 // Invoke the leading edge. 19574 return leading ? invokeFunc(time) : result; 19575 } 19576 19577 function remainingWait(time) { 19578 var timeSinceLastCall = time - lastCallTime, 19579 timeSinceLastInvoke = time - lastInvokeTime, 19580 timeWaiting = wait - timeSinceLastCall; 19581 19582 return maxing 19583 ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) 19584 : timeWaiting; 19585 } 19586 19587 function shouldInvoke(time) { 19588 var timeSinceLastCall = time - lastCallTime, 19589 timeSinceLastInvoke = time - lastInvokeTime; 19590 19591 // Either this is the first call, activity has stopped and we're at the 19592 // trailing edge, the system time has gone backwards and we're treating 19593 // it as the trailing edge, or we've hit the `maxWait` limit. 19594 return (lastCallTime === undefined || (timeSinceLastCall >= wait) || 19595 (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait)); 19596 } 19597 19598 function timerExpired() { 19599 var time = now(); 19600 if (shouldInvoke(time)) { 19601 return trailingEdge(time); 19602 } 19603 // Restart the timer. 19604 timerId = setTimeout(timerExpired, remainingWait(time)); 19605 } 19606 19607 function trailingEdge(time) { 19608 timerId = undefined; 19609 19610 // Only invoke if we have `lastArgs` which means `func` has been 19611 // debounced at least once. 19612 if (trailing && lastArgs) { 19613 return invokeFunc(time); 19614 } 19615 lastArgs = lastThis = undefined; 19616 return result; 19617 } 19618 19619 function cancel() { 19620 if (timerId !== undefined) { 19621 clearTimeout(timerId); 19622 } 19623 lastInvokeTime = 0; 19624 lastArgs = lastCallTime = lastThis = timerId = undefined; 19625 } 19626 19627 function flush() { 19628 return timerId === undefined ? result : trailingEdge(now()); 19629 } 19630 19631 function debounced() { 19632 var time = now(), 19633 isInvoking = shouldInvoke(time); 19634 19635 lastArgs = arguments; 19636 lastThis = this; 19637 lastCallTime = time; 19638 19639 if (isInvoking) { 19640 if (timerId === undefined) { 19641 return leadingEdge(lastCallTime); 19642 } 19643 if (maxing) { 19644 // Handle invocations in a tight loop. 19645 clearTimeout(timerId); 19646 timerId = setTimeout(timerExpired, wait); 19647 return invokeFunc(lastCallTime); 19648 } 19649 } 19650 if (timerId === undefined) { 19651 timerId = setTimeout(timerExpired, wait); 19652 } 19653 return result; 19654 } 19655 debounced.cancel = cancel; 19656 debounced.flush = flush; 19657 return debounced; 19658 } 19659 19660 /** 19661 * Defers invoking the `func` until the current call stack has cleared. Any 19662 * additional arguments are provided to `func` when it's invoked. 19663 * 19664 * @static 19665 * @memberOf _ 19666 * @since 0.1.0 19667 * @category Function 19668 * @param {Function} func The function to defer. 19669 * @param {...*} [args] The arguments to invoke `func` with. 19670 * @returns {number} Returns the timer id. 19671 * @example 19672 * 19673 * _.defer(function(text) { 19674 * console.log(text); 19675 * }, 'deferred'); 19676 * // => Logs 'deferred' after one millisecond. 19677 */ 19678 var defer = baseRest(function(func, args) { 19679 return baseDelay(func, 1, args); 19680 }); 19681 19682 /** 19683 * Invokes `func` after `wait` milliseconds. Any additional arguments are 19684 * provided to `func` when it's invoked. 19685 * 19686 * @static 19687 * @memberOf _ 19688 * @since 0.1.0 19689 * @category Function 19690 * @param {Function} func The function to delay. 19691 * @param {number} wait The number of milliseconds to delay invocation. 19692 * @param {...*} [args] The arguments to invoke `func` with. 19693 * @returns {number} Returns the timer id. 19694 * @example 19695 * 19696 * _.delay(function(text) { 19697 * console.log(text); 19698 * }, 1000, 'later'); 19699 * // => Logs 'later' after one second. 19700 */ 19701 var delay = baseRest(function(func, wait, args) { 19702 return baseDelay(func, toNumber(wait) || 0, args); 19703 }); 19704 19705 /** 19706 * Creates a function that invokes `func` with arguments reversed. 19707 * 19708 * @static 19709 * @memberOf _ 19710 * @since 4.0.0 19711 * @category Function 19712 * @param {Function} func The function to flip arguments for. 19713 * @returns {Function} Returns the new flipped function. 19714 * @example 19715 * 19716 * var flipped = _.flip(function() { 19717 * return _.toArray(arguments); 19718 * }); 19719 * 19720 * flipped('a', 'b', 'c', 'd'); 19721 * // => ['d', 'c', 'b', 'a'] 19722 */ 19723 function flip(func) { 19724 return createWrap(func, WRAP_FLIP_FLAG); 19725 } 19726 19727 /** 19728 * Creates a function that memoizes the result of `func`. If `resolver` is 19729 * provided, it determines the cache key for storing the result based on the 19730 * arguments provided to the memoized function. By default, the first argument 19731 * provided to the memoized function is used as the map cache key. The `func` 19732 * is invoked with the `this` binding of the memoized function. 19733 * 19734 * **Note:** The cache is exposed as the `cache` property on the memoized 19735 * function. Its creation may be customized by replacing the `_.memoize.Cache` 19736 * constructor with one whose instances implement the 19737 * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) 19738 * method interface of `clear`, `delete`, `get`, `has`, and `set`. 19739 * 19740 * @static 19741 * @memberOf _ 19742 * @since 0.1.0 19743 * @category Function 19744 * @param {Function} func The function to have its output memoized. 19745 * @param {Function} [resolver] The function to resolve the cache key. 19746 * @returns {Function} Returns the new memoized function. 19747 * @example 19748 * 19749 * var object = { 'a': 1, 'b': 2 }; 19750 * var other = { 'c': 3, 'd': 4 }; 19751 * 19752 * var values = _.memoize(_.values); 19753 * values(object); 19754 * // => [1, 2] 19755 * 19756 * values(other); 19757 * // => [3, 4] 19758 * 19759 * object.a = 2; 19760 * values(object); 19761 * // => [1, 2] 19762 * 19763 * // Modify the result cache. 19764 * values.cache.set(object, ['a', 'b']); 19765 * values(object); 19766 * // => ['a', 'b'] 19767 * 19768 * // Replace `_.memoize.Cache`. 19769 * _.memoize.Cache = WeakMap; 19770 */ 19771 function memoize(func, resolver) { 19772 if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) { 19773 throw new TypeError(FUNC_ERROR_TEXT); 19774 } 19775 var memoized = function() { 19776 var args = arguments, 19777 key = resolver ? resolver.apply(this, args) : args[0], 19778 cache = memoized.cache; 19779 19780 if (cache.has(key)) { 19781 return cache.get(key); 19782 } 19783 var result = func.apply(this, args); 19784 memoized.cache = cache.set(key, result) || cache; 19785 return result; 19786 }; 19787 memoized.cache = new (memoize.Cache || MapCache); 19788 return memoized; 19789 } 19790 19791 // Expose `MapCache`. 19792 memoize.Cache = MapCache; 19793 19794 /** 19795 * Creates a function that negates the result of the predicate `func`. The 19796 * `func` predicate is invoked with the `this` binding and arguments of the 19797 * created function. 19798 * 19799 * @static 19800 * @memberOf _ 19801 * @since 3.0.0 19802 * @category Function 19803 * @param {Function} predicate The predicate to negate. 19804 * @returns {Function} Returns the new negated function. 19805 * @example 19806 * 19807 * function isEven(n) { 19808 * return n % 2 == 0; 19809 * } 19810 * 19811 * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven)); 19812 * // => [1, 3, 5] 19813 */ 19814 function negate(predicate) { 19815 if (typeof predicate != 'function') { 19816 throw new TypeError(FUNC_ERROR_TEXT); 19817 } 19818 return function() { 19819 var args = arguments; 19820 switch (args.length) { 19821 case 0: return !predicate.call(this); 19822 case 1: return !predicate.call(this, args[0]); 19823 case 2: return !predicate.call(this, args[0], args[1]); 19824 case 3: return !predicate.call(this, args[0], args[1], args[2]); 19825 } 19826 return !predicate.apply(this, args); 19827 }; 19828 } 19829 19830 /** 19831 * Creates a function that is restricted to invoking `func` once. Repeat calls 19832 * to the function return the value of the first invocation. The `func` is 19833 * invoked with the `this` binding and arguments of the created function. 19834 * 19835 * @static 19836 * @memberOf _ 19837 * @since 0.1.0 19838 * @category Function 19839 * @param {Function} func The function to restrict. 19840 * @returns {Function} Returns the new restricted function. 19841 * @example 19842 * 19843 * var initialize = _.once(createApplication); 19844 * initialize(); 19845 * initialize(); 19846 * // => `createApplication` is invoked once 19847 */ 19848 function once(func) { 19849 return before(2, func); 19850 } 19851 19852 /** 19853 * Creates a function that invokes `func` with its arguments transformed. 19854 * 19855 * @static 19856 * @since 4.0.0 19857 * @memberOf _ 19858 * @category Function 19859 * @param {Function} func The function to wrap. 19860 * @param {...(Function|Function[])} [transforms=[_.identity]] 19861 * The argument transforms. 19862 * @returns {Function} Returns the new function. 19863 * @example 19864 * 19865 * function doubled(n) { 19866 * return n * 2; 19867 * } 19868 * 19869 * function square(n) { 19870 * return n * n; 19871 * } 19872 * 19873 * var func = _.overArgs(function(x, y) { 19874 * return [x, y]; 19875 * }, [square, doubled]); 19876 * 19877 * func(9, 3); 19878 * // => [81, 6] 19879 * 19880 * func(10, 5); 19881 * // => [100, 10] 19882 */ 19883 var overArgs = castRest(function(func, transforms) { 19884 transforms = (transforms.length == 1 && isArray(transforms[0])) 19885 ? arrayMap(transforms[0], baseUnary(getIteratee())) 19886 : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee())); 19887 19888 var funcsLength = transforms.length; 19889 return baseRest(function(args) { 19890 var index = -1, 19891 length = nativeMin(args.length, funcsLength); 19892 19893 while (++index < length) { 19894 args[index] = transforms[index].call(this, args[index]); 19895 } 19896 return apply(func, this, args); 19897 }); 19898 }); 19899 19900 /** 19901 * Creates a function that invokes `func` with `partials` prepended to the 19902 * arguments it receives. This method is like `_.bind` except it does **not** 19903 * alter the `this` binding. 19904 * 19905 * The `_.partial.placeholder` value, which defaults to `_` in monolithic 19906 * builds, may be used as a placeholder for partially applied arguments. 19907 * 19908 * **Note:** This method doesn't set the "length" property of partially 19909 * applied functions. 19910 * 19911 * @static 19912 * @memberOf _ 19913 * @since 0.2.0 19914 * @category Function 19915 * @param {Function} func The function to partially apply arguments to. 19916 * @param {...*} [partials] The arguments to be partially applied. 19917 * @returns {Function} Returns the new partially applied function. 19918 * @example 19919 * 19920 * function greet(greeting, name) { 19921 * return greeting + ' ' + name; 19922 * } 19923 * 19924 * var sayHelloTo = _.partial(greet, 'hello'); 19925 * sayHelloTo('fred'); 19926 * // => 'hello fred' 19927 * 19928 * // Partially applied with placeholders. 19929 * var greetFred = _.partial(greet, _, 'fred'); 19930 * greetFred('hi'); 19931 * // => 'hi fred' 19932 */ 19933 var partial = baseRest(function(func, partials) { 19934 var holders = replaceHolders(partials, getHolder(partial)); 19935 return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders); 19936 }); 19937 19938 /** 19939 * This method is like `_.partial` except that partially applied arguments 19940 * are appended to the arguments it receives. 19941 * 19942 * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic 19943 * builds, may be used as a placeholder for partially applied arguments. 19944 * 19945 * **Note:** This method doesn't set the "length" property of partially 19946 * applied functions. 19947 * 19948 * @static 19949 * @memberOf _ 19950 * @since 1.0.0 19951 * @category Function 19952 * @param {Function} func The function to partially apply arguments to. 19953 * @param {...*} [partials] The arguments to be partially applied. 19954 * @returns {Function} Returns the new partially applied function. 19955 * @example 19956 * 19957 * function greet(greeting, name) { 19958 * return greeting + ' ' + name; 19959 * } 19960 * 19961 * var greetFred = _.partialRight(greet, 'fred'); 19962 * greetFred('hi'); 19963 * // => 'hi fred' 19964 * 19965 * // Partially applied with placeholders. 19966 * var sayHelloTo = _.partialRight(greet, 'hello', _); 19967 * sayHelloTo('fred'); 19968 * // => 'hello fred' 19969 */ 19970 var partialRight = baseRest(function(func, partials) { 19971 var holders = replaceHolders(partials, getHolder(partialRight)); 19972 return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders); 19973 }); 19974 19975 /** 19976 * Creates a function that invokes `func` with arguments arranged according 19977 * to the specified `indexes` where the argument value at the first index is 19978 * provided as the first argument, the argument value at the second index is 19979 * provided as the second argument, and so on. 19980 * 19981 * @static 19982 * @memberOf _ 19983 * @since 3.0.0 19984 * @category Function 19985 * @param {Function} func The function to rearrange arguments for. 19986 * @param {...(number|number[])} indexes The arranged argument indexes. 19987 * @returns {Function} Returns the new function. 19988 * @example 19989 * 19990 * var rearged = _.rearg(function(a, b, c) { 19991 * return [a, b, c]; 19992 * }, [2, 0, 1]); 19993 * 19994 * rearged('b', 'c', 'a') 19995 * // => ['a', 'b', 'c'] 19996 */ 19997 var rearg = flatRest(function(func, indexes) { 19998 return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes); 19999 }); 20000 20001 /** 20002 * Creates a function that invokes `func` with the `this` binding of the 20003 * created function and arguments from `start` and beyond provided as 20004 * an array. 20005 * 20006 * **Note:** This method is based on the 20007 * [rest parameter](https://mdn.io/rest_parameters). 20008 * 20009 * @static 20010 * @memberOf _ 20011 * @since 4.0.0 20012 * @category Function 20013 * @param {Function} func The function to apply a rest parameter to. 20014 * @param {number} [start=func.length-1] The start position of the rest parameter. 20015 * @returns {Function} Returns the new function. 20016 * @example 20017 * 20018 * var say = _.rest(function(what, names) { 20019 * return what + ' ' + _.initial(names).join(', ') + 20020 * (_.size(names) > 1 ? ', & ' : '') + _.last(names); 20021 * }); 20022 * 20023 * say('hello', 'fred', 'barney', 'pebbles'); 20024 * // => 'hello fred, barney, & pebbles' 20025 */ 20026 function rest(func, start) { 20027 if (typeof func != 'function') { 20028 throw new TypeError(FUNC_ERROR_TEXT); 20029 } 20030 start = start === undefined ? start : toInteger(start); 20031 return baseRest(func, start); 20032 } 20033 20034 /** 20035 * Creates a function that invokes `func` with the `this` binding of the 20036 * create function and an array of arguments much like 20037 * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply). 20038 * 20039 * **Note:** This method is based on the 20040 * [spread operator](https://mdn.io/spread_operator). 20041 * 20042 * @static 20043 * @memberOf _ 20044 * @since 3.2.0 20045 * @category Function 20046 * @param {Function} func The function to spread arguments over. 20047 * @param {number} [start=0] The start position of the spread. 20048 * @returns {Function} Returns the new function. 20049 * @example 20050 * 20051 * var say = _.spread(function(who, what) { 20052 * return who + ' says ' + what; 20053 * }); 20054 * 20055 * say(['fred', 'hello']); 20056 * // => 'fred says hello' 20057 * 20058 * var numbers = Promise.all([ 20059 * Promise.resolve(40), 20060 * Promise.resolve(36) 20061 * ]); 20062 * 20063 * numbers.then(_.spread(function(x, y) { 20064 * return x + y; 20065 * })); 20066 * // => a Promise of 76 20067 */ 20068 function spread(func, start) { 20069 if (typeof func != 'function') { 20070 throw new TypeError(FUNC_ERROR_TEXT); 20071 } 20072 start = start == null ? 0 : nativeMax(toInteger(start), 0); 20073 return baseRest(function(args) { 20074 var array = args[start], 20075 otherArgs = castSlice(args, 0, start); 20076 20077 if (array) { 20078 arrayPush(otherArgs, array); 20079 } 20080 return apply(func, this, otherArgs); 20081 }); 20082 } 20083 20084 /** 20085 * Creates a throttled function that only invokes `func` at most once per 20086 * every `wait` milliseconds. The throttled function comes with a `cancel` 20087 * method to cancel delayed `func` invocations and a `flush` method to 20088 * immediately invoke them. Provide `options` to indicate whether `func` 20089 * should be invoked on the leading and/or trailing edge of the `wait` 20090 * timeout. The `func` is invoked with the last arguments provided to the 20091 * throttled function. Subsequent calls to the throttled function return the 20092 * result of the last `func` invocation. 20093 * 20094 * **Note:** If `leading` and `trailing` options are `true`, `func` is 20095 * invoked on the trailing edge of the timeout only if the throttled function 20096 * is invoked more than once during the `wait` timeout. 20097 * 20098 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred 20099 * until to the next tick, similar to `setTimeout` with a timeout of `0`. 20100 * 20101 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) 20102 * for details over the differences between `_.throttle` and `_.debounce`. 20103 * 20104 * @static 20105 * @memberOf _ 20106 * @since 0.1.0 20107 * @category Function 20108 * @param {Function} func The function to throttle. 20109 * @param {number} [wait=0] The number of milliseconds to throttle invocations to. 20110 * @param {Object} [options={}] The options object. 20111 * @param {boolean} [options.leading=true] 20112 * Specify invoking on the leading edge of the timeout. 20113 * @param {boolean} [options.trailing=true] 20114 * Specify invoking on the trailing edge of the timeout. 20115 * @returns {Function} Returns the new throttled function. 20116 * @example 20117 * 20118 * // Avoid excessively updating the position while scrolling. 20119 * jQuery(window).on('scroll', _.throttle(updatePosition, 100)); 20120 * 20121 * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes. 20122 * var throttled = _.throttle(renewToken, 300000, { 'trailing': false }); 20123 * jQuery(element).on('click', throttled); 20124 * 20125 * // Cancel the trailing throttled invocation. 20126 * jQuery(window).on('popstate', throttled.cancel); 20127 */ 20128 function throttle(func, wait, options) { 20129 var leading = true, 20130 trailing = true; 20131 20132 if (typeof func != 'function') { 20133 throw new TypeError(FUNC_ERROR_TEXT); 20134 } 20135 if (isObject(options)) { 20136 leading = 'leading' in options ? !!options.leading : leading; 20137 trailing = 'trailing' in options ? !!options.trailing : trailing; 20138 } 20139 return debounce(func, wait, { 20140 'leading': leading, 20141 'maxWait': wait, 20142 'trailing': trailing 20143 }); 20144 } 20145 20146 /** 20147 * Creates a function that accepts up to one argument, ignoring any 20148 * additional arguments. 20149 * 20150 * @static 20151 * @memberOf _ 20152 * @since 4.0.0 20153 * @category Function 20154 * @param {Function} func The function to cap arguments for. 20155 * @returns {Function} Returns the new capped function. 20156 * @example 20157 * 20158 * _.map(['6', '8', '10'], _.unary(parseInt)); 20159 * // => [6, 8, 10] 20160 */ 20161 function unary(func) { 20162 return ary(func, 1); 20163 } 20164 20165 /** 20166 * Creates a function that provides `value` to `wrapper` as its first 20167 * argument. Any additional arguments provided to the function are appended 20168 * to those provided to the `wrapper`. The wrapper is invoked with the `this` 20169 * binding of the created function. 20170 * 20171 * @static 20172 * @memberOf _ 20173 * @since 0.1.0 20174 * @category Function 20175 * @param {*} value The value to wrap. 20176 * @param {Function} [wrapper=identity] The wrapper function. 20177 * @returns {Function} Returns the new function. 20178 * @example 20179 * 20180 * var p = _.wrap(_.escape, function(func, text) { 20181 * return '<p>' + func(text) + '</p>'; 20182 * }); 20183 * 20184 * p('fred, barney, & pebbles'); 20185 * // => '<p>fred, barney, & pebbles</p>' 20186 */ 20187 function wrap(value, wrapper) { 20188 return partial(castFunction(wrapper), value); 20189 } 20190 20191 /*------------------------------------------------------------------------*/ 20192 20193 /** 20194 * Casts `value` as an array if it's not one. 20195 * 20196 * @static 20197 * @memberOf _ 20198 * @since 4.4.0 20199 * @category Lang 20200 * @param {*} value The value to inspect. 20201 * @returns {Array} Returns the cast array. 20202 * @example 20203 * 20204 * _.castArray(1); 20205 * // => [1] 20206 * 20207 * _.castArray({ 'a': 1 }); 20208 * // => [{ 'a': 1 }] 20209 * 20210 * _.castArray('abc'); 20211 * // => ['abc'] 20212 * 20213 * _.castArray(null); 20214 * // => [null] 20215 * 20216 * _.castArray(undefined); 20217 * // => [undefined] 20218 * 20219 * _.castArray(); 20220 * // => [] 20221 * 20222 * var array = [1, 2, 3]; 20223 * console.log(_.castArray(array) === array); 20224 * // => true 20225 */ 20226 function castArray() { 20227 if (!arguments.length) { 20228 return []; 20229 } 20230 var value = arguments[0]; 20231 return isArray(value) ? value : [value]; 20232 } 20233 20234 /** 20235 * Creates a shallow clone of `value`. 20236 * 20237 * **Note:** This method is loosely based on the 20238 * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm) 20239 * and supports cloning arrays, array buffers, booleans, date objects, maps, 20240 * numbers, `Object` objects, regexes, sets, strings, symbols, and typed 20241 * arrays. The own enumerable properties of `arguments` objects are cloned 20242 * as plain objects. An empty object is returned for uncloneable values such 20243 * as error objects, functions, DOM nodes, and WeakMaps. 20244 * 20245 * @static 20246 * @memberOf _ 20247 * @since 0.1.0 20248 * @category Lang 20249 * @param {*} value The value to clone. 20250 * @returns {*} Returns the cloned value. 20251 * @see _.cloneDeep 20252 * @example 20253 * 20254 * var objects = [{ 'a': 1 }, { 'b': 2 }]; 20255 * 20256 * var shallow = _.clone(objects); 20257 * console.log(shallow[0] === objects[0]); 20258 * // => true 20259 */ 20260 function clone(value) { 20261 return baseClone(value, CLONE_SYMBOLS_FLAG); 20262 } 20263 20264 /** 20265 * This method is like `_.clone` except that it accepts `customizer` which 20266 * is invoked to produce the cloned value. If `customizer` returns `undefined`, 20267 * cloning is handled by the method instead. The `customizer` is invoked with 20268 * up to four arguments; (value [, index|key, object, stack]). 20269 * 20270 * @static 20271 * @memberOf _ 20272 * @since 4.0.0 20273 * @category Lang 20274 * @param {*} value The value to clone. 20275 * @param {Function} [customizer] The function to customize cloning. 20276 * @returns {*} Returns the cloned value. 20277 * @see _.cloneDeepWith 20278 * @example 20279 * 20280 * function customizer(value) { 20281 * if (_.isElement(value)) { 20282 * return value.cloneNode(false); 20283 * } 20284 * } 20285 * 20286 * var el = _.cloneWith(document.body, customizer); 20287 * 20288 * console.log(el === document.body); 20289 * // => false 20290 * console.log(el.nodeName); 20291 * // => 'BODY' 20292 * console.log(el.childNodes.length); 20293 * // => 0 20294 */ 20295 function cloneWith(value, customizer) { 20296 customizer = typeof customizer == 'function' ? customizer : undefined; 20297 return baseClone(value, CLONE_SYMBOLS_FLAG, customizer); 20298 } 20299 20300 /** 20301 * This method is like `_.clone` except that it recursively clones `value`. 20302 * 20303 * @static 20304 * @memberOf _ 20305 * @since 1.0.0 20306 * @category Lang 20307 * @param {*} value The value to recursively clone. 20308 * @returns {*} Returns the deep cloned value. 20309 * @see _.clone 20310 * @example 20311 * 20312 * var objects = [{ 'a': 1 }, { 'b': 2 }]; 20313 * 20314 * var deep = _.cloneDeep(objects); 20315 * console.log(deep[0] === objects[0]); 20316 * // => false 20317 */ 20318 function cloneDeep(value) { 20319 return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG); 20320 } 20321 20322 /** 20323 * This method is like `_.cloneWith` except that it recursively clones `value`. 20324 * 20325 * @static 20326 * @memberOf _ 20327 * @since 4.0.0 20328 * @category Lang 20329 * @param {*} value The value to recursively clone. 20330 * @param {Function} [customizer] The function to customize cloning. 20331 * @returns {*} Returns the deep cloned value. 20332 * @see _.cloneWith 20333 * @example 20334 * 20335 * function customizer(value) { 20336 * if (_.isElement(value)) { 20337 * return value.cloneNode(true); 20338 * } 20339 * } 20340 * 20341 * var el = _.cloneDeepWith(document.body, customizer); 20342 * 20343 * console.log(el === document.body); 20344 * // => false 20345 * console.log(el.nodeName); 20346 * // => 'BODY' 20347 * console.log(el.childNodes.length); 20348 * // => 20 20349 */ 20350 function cloneDeepWith(value, customizer) { 20351 customizer = typeof customizer == 'function' ? customizer : undefined; 20352 return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer); 20353 } 20354 20355 /** 20356 * Checks if `object` conforms to `source` by invoking the predicate 20357 * properties of `source` with the corresponding property values of `object`. 20358 * 20359 * **Note:** This method is equivalent to `_.conforms` when `source` is 20360 * partially applied. 20361 * 20362 * @static 20363 * @memberOf _ 20364 * @since 4.14.0 20365 * @category Lang 20366 * @param {Object} object The object to inspect. 20367 * @param {Object} source The object of property predicates to conform to. 20368 * @returns {boolean} Returns `true` if `object` conforms, else `false`. 20369 * @example 20370 * 20371 * var object = { 'a': 1, 'b': 2 }; 20372 * 20373 * _.conformsTo(object, { 'b': function(n) { return n > 1; } }); 20374 * // => true 20375 * 20376 * _.conformsTo(object, { 'b': function(n) { return n > 2; } }); 20377 * // => false 20378 */ 20379 function conformsTo(object, source) { 20380 return source == null || baseConformsTo(object, source, keys(source)); 20381 } 20382 20383 /** 20384 * Performs a 20385 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 20386 * comparison between two values to determine if they are equivalent. 20387 * 20388 * @static 20389 * @memberOf _ 20390 * @since 4.0.0 20391 * @category Lang 20392 * @param {*} value The value to compare. 20393 * @param {*} other The other value to compare. 20394 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 20395 * @example 20396 * 20397 * var object = { 'a': 1 }; 20398 * var other = { 'a': 1 }; 20399 * 20400 * _.eq(object, object); 20401 * // => true 20402 * 20403 * _.eq(object, other); 20404 * // => false 20405 * 20406 * _.eq('a', 'a'); 20407 * // => true 20408 * 20409 * _.eq('a', Object('a')); 20410 * // => false 20411 * 20412 * _.eq(NaN, NaN); 20413 * // => true 20414 */ 20415 function eq(value, other) { 20416 return value === other || (value !== value && other !== other); 20417 } 20418 20419 /** 20420 * Checks if `value` is greater than `other`. 20421 * 20422 * @static 20423 * @memberOf _ 20424 * @since 3.9.0 20425 * @category Lang 20426 * @param {*} value The value to compare. 20427 * @param {*} other The other value to compare. 20428 * @returns {boolean} Returns `true` if `value` is greater than `other`, 20429 * else `false`. 20430 * @see _.lt 20431 * @example 20432 * 20433 * _.gt(3, 1); 20434 * // => true 20435 * 20436 * _.gt(3, 3); 20437 * // => false 20438 * 20439 * _.gt(1, 3); 20440 * // => false 20441 */ 20442 var gt = createRelationalOperation(baseGt); 20443 20444 /** 20445 * Checks if `value` is greater than or equal to `other`. 20446 * 20447 * @static 20448 * @memberOf _ 20449 * @since 3.9.0 20450 * @category Lang 20451 * @param {*} value The value to compare. 20452 * @param {*} other The other value to compare. 20453 * @returns {boolean} Returns `true` if `value` is greater than or equal to 20454 * `other`, else `false`. 20455 * @see _.lte 20456 * @example 20457 * 20458 * _.gte(3, 1); 20459 * // => true 20460 * 20461 * _.gte(3, 3); 20462 * // => true 20463 * 20464 * _.gte(1, 3); 20465 * // => false 20466 */ 20467 var gte = createRelationalOperation(function(value, other) { 20468 return value >= other; 20469 }); 20470 20471 /** 20472 * Checks if `value` is likely an `arguments` object. 20473 * 20474 * @static 20475 * @memberOf _ 20476 * @since 0.1.0 20477 * @category Lang 20478 * @param {*} value The value to check. 20479 * @returns {boolean} Returns `true` if `value` is an `arguments` object, 20480 * else `false`. 20481 * @example 20482 * 20483 * _.isArguments(function() { return arguments; }()); 20484 * // => true 20485 * 20486 * _.isArguments([1, 2, 3]); 20487 * // => false 20488 */ 20489 var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) { 20490 return isObjectLike(value) && hasOwnProperty.call(value, 'callee') && 20491 !propertyIsEnumerable.call(value, 'callee'); 20492 }; 20493 20494 /** 20495 * Checks if `value` is classified as an `Array` object. 20496 * 20497 * @static 20498 * @memberOf _ 20499 * @since 0.1.0 20500 * @category Lang 20501 * @param {*} value The value to check. 20502 * @returns {boolean} Returns `true` if `value` is an array, else `false`. 20503 * @example 20504 * 20505 * _.isArray([1, 2, 3]); 20506 * // => true 20507 * 20508 * _.isArray(document.body.children); 20509 * // => false 20510 * 20511 * _.isArray('abc'); 20512 * // => false 20513 * 20514 * _.isArray(_.noop); 20515 * // => false 20516 */ 20517 var isArray = Array.isArray; 20518 20519 /** 20520 * Checks if `value` is classified as an `ArrayBuffer` object. 20521 * 20522 * @static 20523 * @memberOf _ 20524 * @since 4.3.0 20525 * @category Lang 20526 * @param {*} value The value to check. 20527 * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. 20528 * @example 20529 * 20530 * _.isArrayBuffer(new ArrayBuffer(2)); 20531 * // => true 20532 * 20533 * _.isArrayBuffer(new Array(2)); 20534 * // => false 20535 */ 20536 var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer; 20537 20538 /** 20539 * Checks if `value` is array-like. A value is considered array-like if it's 20540 * not a function and has a `value.length` that's an integer greater than or 20541 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. 20542 * 20543 * @static 20544 * @memberOf _ 20545 * @since 4.0.0 20546 * @category Lang 20547 * @param {*} value The value to check. 20548 * @returns {boolean} Returns `true` if `value` is array-like, else `false`. 20549 * @example 20550 * 20551 * _.isArrayLike([1, 2, 3]); 20552 * // => true 20553 * 20554 * _.isArrayLike(document.body.children); 20555 * // => true 20556 * 20557 * _.isArrayLike('abc'); 20558 * // => true 20559 * 20560 * _.isArrayLike(_.noop); 20561 * // => false 20562 */ 20563 function isArrayLike(value) { 20564 return value != null && isLength(value.length) && !isFunction(value); 20565 } 20566 20567 /** 20568 * This method is like `_.isArrayLike` except that it also checks if `value` 20569 * is an object. 20570 * 20571 * @static 20572 * @memberOf _ 20573 * @since 4.0.0 20574 * @category Lang 20575 * @param {*} value The value to check. 20576 * @returns {boolean} Returns `true` if `value` is an array-like object, 20577 * else `false`. 20578 * @example 20579 * 20580 * _.isArrayLikeObject([1, 2, 3]); 20581 * // => true 20582 * 20583 * _.isArrayLikeObject(document.body.children); 20584 * // => true 20585 * 20586 * _.isArrayLikeObject('abc'); 20587 * // => false 20588 * 20589 * _.isArrayLikeObject(_.noop); 20590 * // => false 20591 */ 20592 function isArrayLikeObject(value) { 20593 return isObjectLike(value) && isArrayLike(value); 20594 } 20595 20596 /** 20597 * Checks if `value` is classified as a boolean primitive or object. 20598 * 20599 * @static 20600 * @memberOf _ 20601 * @since 0.1.0 20602 * @category Lang 20603 * @param {*} value The value to check. 20604 * @returns {boolean} Returns `true` if `value` is a boolean, else `false`. 20605 * @example 20606 * 20607 * _.isBoolean(false); 20608 * // => true 20609 * 20610 * _.isBoolean(null); 20611 * // => false 20612 */ 20613 function isBoolean(value) { 20614 return value === true || value === false || 20615 (isObjectLike(value) && baseGetTag(value) == boolTag); 20616 } 20617 20618 /** 20619 * Checks if `value` is a buffer. 20620 * 20621 * @static 20622 * @memberOf _ 20623 * @since 4.3.0 20624 * @category Lang 20625 * @param {*} value The value to check. 20626 * @returns {boolean} Returns `true` if `value` is a buffer, else `false`. 20627 * @example 20628 * 20629 * _.isBuffer(new Buffer(2)); 20630 * // => true 20631 * 20632 * _.isBuffer(new Uint8Array(2)); 20633 * // => false 20634 */ 20635 var isBuffer = nativeIsBuffer || stubFalse; 20636 20637 /** 20638 * Checks if `value` is classified as a `Date` object. 20639 * 20640 * @static 20641 * @memberOf _ 20642 * @since 0.1.0 20643 * @category Lang 20644 * @param {*} value The value to check. 20645 * @returns {boolean} Returns `true` if `value` is a date object, else `false`. 20646 * @example 20647 * 20648 * _.isDate(new Date); 20649 * // => true 20650 * 20651 * _.isDate('Mon April 23 2012'); 20652 * // => false 20653 */ 20654 var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate; 20655 20656 /** 20657 * Checks if `value` is likely a DOM element. 20658 * 20659 * @static 20660 * @memberOf _ 20661 * @since 0.1.0 20662 * @category Lang 20663 * @param {*} value The value to check. 20664 * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`. 20665 * @example 20666 * 20667 * _.isElement(document.body); 20668 * // => true 20669 * 20670 * _.isElement('<body>'); 20671 * // => false 20672 */ 20673 function isElement(value) { 20674 return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value); 20675 } 20676 20677 /** 20678 * Checks if `value` is an empty object, collection, map, or set. 20679 * 20680 * Objects are considered empty if they have no own enumerable string keyed 20681 * properties. 20682 * 20683 * Array-like values such as `arguments` objects, arrays, buffers, strings, or 20684 * jQuery-like collections are considered empty if they have a `length` of `0`. 20685 * Similarly, maps and sets are considered empty if they have a `size` of `0`. 20686 * 20687 * @static 20688 * @memberOf _ 20689 * @since 0.1.0 20690 * @category Lang 20691 * @param {*} value The value to check. 20692 * @returns {boolean} Returns `true` if `value` is empty, else `false`. 20693 * @example 20694 * 20695 * _.isEmpty(null); 20696 * // => true 20697 * 20698 * _.isEmpty(true); 20699 * // => true 20700 * 20701 * _.isEmpty(1); 20702 * // => true 20703 * 20704 * _.isEmpty([1, 2, 3]); 20705 * // => false 20706 * 20707 * _.isEmpty({ 'a': 1 }); 20708 * // => false 20709 */ 20710 function isEmpty(value) { 20711 if (value == null) { 20712 return true; 20713 } 20714 if (isArrayLike(value) && 20715 (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' || 20716 isBuffer(value) || isTypedArray(value) || isArguments(value))) { 20717 return !value.length; 20718 } 20719 var tag = getTag(value); 20720 if (tag == mapTag || tag == setTag) { 20721 return !value.size; 20722 } 20723 if (isPrototype(value)) { 20724 return !baseKeys(value).length; 20725 } 20726 for (var key in value) { 20727 if (hasOwnProperty.call(value, key)) { 20728 return false; 20729 } 20730 } 20731 return true; 20732 } 20733 20734 /** 20735 * Performs a deep comparison between two values to determine if they are 20736 * equivalent. 20737 * 20738 * **Note:** This method supports comparing arrays, array buffers, booleans, 20739 * date objects, error objects, maps, numbers, `Object` objects, regexes, 20740 * sets, strings, symbols, and typed arrays. `Object` objects are compared 20741 * by their own, not inherited, enumerable properties. Functions and DOM 20742 * nodes are compared by strict equality, i.e. `===`. 20743 * 20744 * @static 20745 * @memberOf _ 20746 * @since 0.1.0 20747 * @category Lang 20748 * @param {*} value The value to compare. 20749 * @param {*} other The other value to compare. 20750 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 20751 * @example 20752 * 20753 * var object = { 'a': 1 }; 20754 * var other = { 'a': 1 }; 20755 * 20756 * _.isEqual(object, other); 20757 * // => true 20758 * 20759 * object === other; 20760 * // => false 20761 */ 20762 function isEqual(value, other) { 20763 return baseIsEqual(value, other); 20764 } 20765 20766 /** 20767 * This method is like `_.isEqual` except that it accepts `customizer` which 20768 * is invoked to compare values. If `customizer` returns `undefined`, comparisons 20769 * are handled by the method instead. The `customizer` is invoked with up to 20770 * six arguments: (objValue, othValue [, index|key, object, other, stack]). 20771 * 20772 * @static 20773 * @memberOf _ 20774 * @since 4.0.0 20775 * @category Lang 20776 * @param {*} value The value to compare. 20777 * @param {*} other The other value to compare. 20778 * @param {Function} [customizer] The function to customize comparisons. 20779 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 20780 * @example 20781 * 20782 * function isGreeting(value) { 20783 * return /^h(?:i|ello)$/.test(value); 20784 * } 20785 * 20786 * function customizer(objValue, othValue) { 20787 * if (isGreeting(objValue) && isGreeting(othValue)) { 20788 * return true; 20789 * } 20790 * } 20791 * 20792 * var array = ['hello', 'goodbye']; 20793 * var other = ['hi', 'goodbye']; 20794 * 20795 * _.isEqualWith(array, other, customizer); 20796 * // => true 20797 */ 20798 function isEqualWith(value, other, customizer) { 20799 customizer = typeof customizer == 'function' ? customizer : undefined; 20800 var result = customizer ? customizer(value, other) : undefined; 20801 return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result; 20802 } 20803 20804 /** 20805 * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`, 20806 * `SyntaxError`, `TypeError`, or `URIError` object. 20807 * 20808 * @static 20809 * @memberOf _ 20810 * @since 3.0.0 20811 * @category Lang 20812 * @param {*} value The value to check. 20813 * @returns {boolean} Returns `true` if `value` is an error object, else `false`. 20814 * @example 20815 * 20816 * _.isError(new Error); 20817 * // => true 20818 * 20819 * _.isError(Error); 20820 * // => false 20821 */ 20822 function isError(value) { 20823 if (!isObjectLike(value)) { 20824 return false; 20825 } 20826 var tag = baseGetTag(value); 20827 return tag == errorTag || tag == domExcTag || 20828 (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value)); 20829 } 20830 20831 /** 20832 * Checks if `value` is a finite primitive number. 20833 * 20834 * **Note:** This method is based on 20835 * [`Number.isFinite`](https://mdn.io/Number/isFinite). 20836 * 20837 * @static 20838 * @memberOf _ 20839 * @since 0.1.0 20840 * @category Lang 20841 * @param {*} value The value to check. 20842 * @returns {boolean} Returns `true` if `value` is a finite number, else `false`. 20843 * @example 20844 * 20845 * _.isFinite(3); 20846 * // => true 20847 * 20848 * _.isFinite(Number.MIN_VALUE); 20849 * // => true 20850 * 20851 * _.isFinite(Infinity); 20852 * // => false 20853 * 20854 * _.isFinite('3'); 20855 * // => false 20856 */ 20857 function isFinite(value) { 20858 return typeof value == 'number' && nativeIsFinite(value); 20859 } 20860 20861 /** 20862 * Checks if `value` is classified as a `Function` object. 20863 * 20864 * @static 20865 * @memberOf _ 20866 * @since 0.1.0 20867 * @category Lang 20868 * @param {*} value The value to check. 20869 * @returns {boolean} Returns `true` if `value` is a function, else `false`. 20870 * @example 20871 * 20872 * _.isFunction(_); 20873 * // => true 20874 * 20875 * _.isFunction(/abc/); 20876 * // => false 20877 */ 20878 function isFunction(value) { 20879 if (!isObject(value)) { 20880 return false; 20881 } 20882 // The use of `Object#toString` avoids issues with the `typeof` operator 20883 // in Safari 9 which returns 'object' for typed arrays and other constructors. 20884 var tag = baseGetTag(value); 20885 return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; 20886 } 20887 20888 /** 20889 * Checks if `value` is an integer. 20890 * 20891 * **Note:** This method is based on 20892 * [`Number.isInteger`](https://mdn.io/Number/isInteger). 20893 * 20894 * @static 20895 * @memberOf _ 20896 * @since 4.0.0 20897 * @category Lang 20898 * @param {*} value The value to check. 20899 * @returns {boolean} Returns `true` if `value` is an integer, else `false`. 20900 * @example 20901 * 20902 * _.isInteger(3); 20903 * // => true 20904 * 20905 * _.isInteger(Number.MIN_VALUE); 20906 * // => false 20907 * 20908 * _.isInteger(Infinity); 20909 * // => false 20910 * 20911 * _.isInteger('3'); 20912 * // => false 20913 */ 20914 function isInteger(value) { 20915 return typeof value == 'number' && value == toInteger(value); 20916 } 20917 20918 /** 20919 * Checks if `value` is a valid array-like length. 20920 * 20921 * **Note:** This method is loosely based on 20922 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). 20923 * 20924 * @static 20925 * @memberOf _ 20926 * @since 4.0.0 20927 * @category Lang 20928 * @param {*} value The value to check. 20929 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. 20930 * @example 20931 * 20932 * _.isLength(3); 20933 * // => true 20934 * 20935 * _.isLength(Number.MIN_VALUE); 20936 * // => false 20937 * 20938 * _.isLength(Infinity); 20939 * // => false 20940 * 20941 * _.isLength('3'); 20942 * // => false 20943 */ 20944 function isLength(value) { 20945 return typeof value == 'number' && 20946 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; 20947 } 20948 20949 /** 20950 * Checks if `value` is the 20951 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) 20952 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) 20953 * 20954 * @static 20955 * @memberOf _ 20956 * @since 0.1.0 20957 * @category Lang 20958 * @param {*} value The value to check. 20959 * @returns {boolean} Returns `true` if `value` is an object, else `false`. 20960 * @example 20961 * 20962 * _.isObject({}); 20963 * // => true 20964 * 20965 * _.isObject([1, 2, 3]); 20966 * // => true 20967 * 20968 * _.isObject(_.noop); 20969 * // => true 20970 * 20971 * _.isObject(null); 20972 * // => false 20973 */ 20974 function isObject(value) { 20975 var type = typeof value; 20976 return value != null && (type == 'object' || type == 'function'); 20977 } 20978 20979 /** 20980 * Checks if `value` is object-like. A value is object-like if it's not `null` 20981 * and has a `typeof` result of "object". 20982 * 20983 * @static 20984 * @memberOf _ 20985 * @since 4.0.0 20986 * @category Lang 20987 * @param {*} value The value to check. 20988 * @returns {boolean} Returns `true` if `value` is object-like, else `false`. 20989 * @example 20990 * 20991 * _.isObjectLike({}); 20992 * // => true 20993 * 20994 * _.isObjectLike([1, 2, 3]); 20995 * // => true 20996 * 20997 * _.isObjectLike(_.noop); 20998 * // => false 20999 * 21000 * _.isObjectLike(null); 21001 * // => false 21002 */ 21003 function isObjectLike(value) { 21004 return value != null && typeof value == 'object'; 21005 } 21006 21007 /** 21008 * Checks if `value` is classified as a `Map` object. 21009 * 21010 * @static 21011 * @memberOf _ 21012 * @since 4.3.0 21013 * @category Lang 21014 * @param {*} value The value to check. 21015 * @returns {boolean} Returns `true` if `value` is a map, else `false`. 21016 * @example 21017 * 21018 * _.isMap(new Map); 21019 * // => true 21020 * 21021 * _.isMap(new WeakMap); 21022 * // => false 21023 */ 21024 var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap; 21025 21026 /** 21027 * Performs a partial deep comparison between `object` and `source` to 21028 * determine if `object` contains equivalent property values. 21029 * 21030 * **Note:** This method is equivalent to `_.matches` when `source` is 21031 * partially applied. 21032 * 21033 * Partial comparisons will match empty array and empty object `source` 21034 * values against any array or object value, respectively. See `_.isEqual` 21035 * for a list of supported value comparisons. 21036 * 21037 * @static 21038 * @memberOf _ 21039 * @since 3.0.0 21040 * @category Lang 21041 * @param {Object} object The object to inspect. 21042 * @param {Object} source The object of property values to match. 21043 * @returns {boolean} Returns `true` if `object` is a match, else `false`. 21044 * @example 21045 * 21046 * var object = { 'a': 1, 'b': 2 }; 21047 * 21048 * _.isMatch(object, { 'b': 2 }); 21049 * // => true 21050 * 21051 * _.isMatch(object, { 'b': 1 }); 21052 * // => false 21053 */ 21054 function isMatch(object, source) { 21055 return object === source || baseIsMatch(object, source, getMatchData(source)); 21056 } 21057 21058 /** 21059 * This method is like `_.isMatch` except that it accepts `customizer` which 21060 * is invoked to compare values. If `customizer` returns `undefined`, comparisons 21061 * are handled by the method instead. The `customizer` is invoked with five 21062 * arguments: (objValue, srcValue, index|key, object, source). 21063 * 21064 * @static 21065 * @memberOf _ 21066 * @since 4.0.0 21067 * @category Lang 21068 * @param {Object} object The object to inspect. 21069 * @param {Object} source The object of property values to match. 21070 * @param {Function} [customizer] The function to customize comparisons. 21071 * @returns {boolean} Returns `true` if `object` is a match, else `false`. 21072 * @example 21073 * 21074 * function isGreeting(value) { 21075 * return /^h(?:i|ello)$/.test(value); 21076 * } 21077 * 21078 * function customizer(objValue, srcValue) { 21079 * if (isGreeting(objValue) && isGreeting(srcValue)) { 21080 * return true; 21081 * } 21082 * } 21083 * 21084 * var object = { 'greeting': 'hello' }; 21085 * var source = { 'greeting': 'hi' }; 21086 * 21087 * _.isMatchWith(object, source, customizer); 21088 * // => true 21089 */ 21090 function isMatchWith(object, source, customizer) { 21091 customizer = typeof customizer == 'function' ? customizer : undefined; 21092 return baseIsMatch(object, source, getMatchData(source), customizer); 21093 } 21094 21095 /** 21096 * Checks if `value` is `NaN`. 21097 * 21098 * **Note:** This method is based on 21099 * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as 21100 * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for 21101 * `undefined` and other non-number values. 21102 * 21103 * @static 21104 * @memberOf _ 21105 * @since 0.1.0 21106 * @category Lang 21107 * @param {*} value The value to check. 21108 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. 21109 * @example 21110 * 21111 * _.isNaN(NaN); 21112 * // => true 21113 * 21114 * _.isNaN(new Number(NaN)); 21115 * // => true 21116 * 21117 * isNaN(undefined); 21118 * // => true 21119 * 21120 * _.isNaN(undefined); 21121 * // => false 21122 */ 21123 function isNaN(value) { 21124 // An `NaN` primitive is the only value that is not equal to itself. 21125 // Perform the `toStringTag` check first to avoid errors with some 21126 // ActiveX objects in IE. 21127 return isNumber(value) && value != +value; 21128 } 21129 21130 /** 21131 * Checks if `value` is a pristine native function. 21132 * 21133 * **Note:** This method can't reliably detect native functions in the presence 21134 * of the core-js package because core-js circumvents this kind of detection. 21135 * Despite multiple requests, the core-js maintainer has made it clear: any 21136 * attempt to fix the detection will be obstructed. As a result, we're left 21137 * with little choice but to throw an error. Unfortunately, this also affects 21138 * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill), 21139 * which rely on core-js. 21140 * 21141 * @static 21142 * @memberOf _ 21143 * @since 3.0.0 21144 * @category Lang 21145 * @param {*} value The value to check. 21146 * @returns {boolean} Returns `true` if `value` is a native function, 21147 * else `false`. 21148 * @example 21149 * 21150 * _.isNative(Array.prototype.push); 21151 * // => true 21152 * 21153 * _.isNative(_); 21154 * // => false 21155 */ 21156 function isNative(value) { 21157 if (isMaskable(value)) { 21158 throw new Error(CORE_ERROR_TEXT); 21159 } 21160 return baseIsNative(value); 21161 } 21162 21163 /** 21164 * Checks if `value` is `null`. 21165 * 21166 * @static 21167 * @memberOf _ 21168 * @since 0.1.0 21169 * @category Lang 21170 * @param {*} value The value to check. 21171 * @returns {boolean} Returns `true` if `value` is `null`, else `false`. 21172 * @example 21173 * 21174 * _.isNull(null); 21175 * // => true 21176 * 21177 * _.isNull(void 0); 21178 * // => false 21179 */ 21180 function isNull(value) { 21181 return value === null; 21182 } 21183 21184 /** 21185 * Checks if `value` is `null` or `undefined`. 21186 * 21187 * @static 21188 * @memberOf _ 21189 * @since 4.0.0 21190 * @category Lang 21191 * @param {*} value The value to check. 21192 * @returns {boolean} Returns `true` if `value` is nullish, else `false`. 21193 * @example 21194 * 21195 * _.isNil(null); 21196 * // => true 21197 * 21198 * _.isNil(void 0); 21199 * // => true 21200 * 21201 * _.isNil(NaN); 21202 * // => false 21203 */ 21204 function isNil(value) { 21205 return value == null; 21206 } 21207 21208 /** 21209 * Checks if `value` is classified as a `Number` primitive or object. 21210 * 21211 * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are 21212 * classified as numbers, use the `_.isFinite` method. 21213 * 21214 * @static 21215 * @memberOf _ 21216 * @since 0.1.0 21217 * @category Lang 21218 * @param {*} value The value to check. 21219 * @returns {boolean} Returns `true` if `value` is a number, else `false`. 21220 * @example 21221 * 21222 * _.isNumber(3); 21223 * // => true 21224 * 21225 * _.isNumber(Number.MIN_VALUE); 21226 * // => true 21227 * 21228 * _.isNumber(Infinity); 21229 * // => true 21230 * 21231 * _.isNumber('3'); 21232 * // => false 21233 */ 21234 function isNumber(value) { 21235 return typeof value == 'number' || 21236 (isObjectLike(value) && baseGetTag(value) == numberTag); 21237 } 21238 21239 /** 21240 * Checks if `value` is a plain object, that is, an object created by the 21241 * `Object` constructor or one with a `[[Prototype]]` of `null`. 21242 * 21243 * @static 21244 * @memberOf _ 21245 * @since 0.8.0 21246 * @category Lang 21247 * @param {*} value The value to check. 21248 * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. 21249 * @example 21250 * 21251 * function Foo() { 21252 * this.a = 1; 21253 * } 21254 * 21255 * _.isPlainObject(new Foo); 21256 * // => false 21257 * 21258 * _.isPlainObject([1, 2, 3]); 21259 * // => false 21260 * 21261 * _.isPlainObject({ 'x': 0, 'y': 0 }); 21262 * // => true 21263 * 21264 * _.isPlainObject(Object.create(null)); 21265 * // => true 21266 */ 21267 function isPlainObject(value) { 21268 if (!isObjectLike(value) || baseGetTag(value) != objectTag) { 21269 return false; 21270 } 21271 var proto = getPrototype(value); 21272 if (proto === null) { 21273 return true; 21274 } 21275 var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor; 21276 return typeof Ctor == 'function' && Ctor instanceof Ctor && 21277 funcToString.call(Ctor) == objectCtorString; 21278 } 21279 21280 /** 21281 * Checks if `value` is classified as a `RegExp` object. 21282 * 21283 * @static 21284 * @memberOf _ 21285 * @since 0.1.0 21286 * @category Lang 21287 * @param {*} value The value to check. 21288 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. 21289 * @example 21290 * 21291 * _.isRegExp(/abc/); 21292 * // => true 21293 * 21294 * _.isRegExp('/abc/'); 21295 * // => false 21296 */ 21297 var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp; 21298 21299 /** 21300 * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754 21301 * double precision number which isn't the result of a rounded unsafe integer. 21302 * 21303 * **Note:** This method is based on 21304 * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger). 21305 * 21306 * @static 21307 * @memberOf _ 21308 * @since 4.0.0 21309 * @category Lang 21310 * @param {*} value The value to check. 21311 * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`. 21312 * @example 21313 * 21314 * _.isSafeInteger(3); 21315 * // => true 21316 * 21317 * _.isSafeInteger(Number.MIN_VALUE); 21318 * // => false 21319 * 21320 * _.isSafeInteger(Infinity); 21321 * // => false 21322 * 21323 * _.isSafeInteger('3'); 21324 * // => false 21325 */ 21326 function isSafeInteger(value) { 21327 return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER; 21328 } 21329 21330 /** 21331 * Checks if `value` is classified as a `Set` object. 21332 * 21333 * @static 21334 * @memberOf _ 21335 * @since 4.3.0 21336 * @category Lang 21337 * @param {*} value The value to check. 21338 * @returns {boolean} Returns `true` if `value` is a set, else `false`. 21339 * @example 21340 * 21341 * _.isSet(new Set); 21342 * // => true 21343 * 21344 * _.isSet(new WeakSet); 21345 * // => false 21346 */ 21347 var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet; 21348 21349 /** 21350 * Checks if `value` is classified as a `String` primitive or object. 21351 * 21352 * @static 21353 * @since 0.1.0 21354 * @memberOf _ 21355 * @category Lang 21356 * @param {*} value The value to check. 21357 * @returns {boolean} Returns `true` if `value` is a string, else `false`. 21358 * @example 21359 * 21360 * _.isString('abc'); 21361 * // => true 21362 * 21363 * _.isString(1); 21364 * // => false 21365 */ 21366 function isString(value) { 21367 return typeof value == 'string' || 21368 (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag); 21369 } 21370 21371 /** 21372 * Checks if `value` is classified as a `Symbol` primitive or object. 21373 * 21374 * @static 21375 * @memberOf _ 21376 * @since 4.0.0 21377 * @category Lang 21378 * @param {*} value The value to check. 21379 * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. 21380 * @example 21381 * 21382 * _.isSymbol(Symbol.iterator); 21383 * // => true 21384 * 21385 * _.isSymbol('abc'); 21386 * // => false 21387 */ 21388 function isSymbol(value) { 21389 return typeof value == 'symbol' || 21390 (isObjectLike(value) && baseGetTag(value) == symbolTag); 21391 } 21392 21393 /** 21394 * Checks if `value` is classified as a typed array. 21395 * 21396 * @static 21397 * @memberOf _ 21398 * @since 3.0.0 21399 * @category Lang 21400 * @param {*} value The value to check. 21401 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. 21402 * @example 21403 * 21404 * _.isTypedArray(new Uint8Array); 21405 * // => true 21406 * 21407 * _.isTypedArray([]); 21408 * // => false 21409 */ 21410 var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; 21411 21412 /** 21413 * Checks if `value` is `undefined`. 21414 * 21415 * @static 21416 * @since 0.1.0 21417 * @memberOf _ 21418 * @category Lang 21419 * @param {*} value The value to check. 21420 * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`. 21421 * @example 21422 * 21423 * _.isUndefined(void 0); 21424 * // => true 21425 * 21426 * _.isUndefined(null); 21427 * // => false 21428 */ 21429 function isUndefined(value) { 21430 return value === undefined; 21431 } 21432 21433 /** 21434 * Checks if `value` is classified as a `WeakMap` object. 21435 * 21436 * @static 21437 * @memberOf _ 21438 * @since 4.3.0 21439 * @category Lang 21440 * @param {*} value The value to check. 21441 * @returns {boolean} Returns `true` if `value` is a weak map, else `false`. 21442 * @example 21443 * 21444 * _.isWeakMap(new WeakMap); 21445 * // => true 21446 * 21447 * _.isWeakMap(new Map); 21448 * // => false 21449 */ 21450 function isWeakMap(value) { 21451 return isObjectLike(value) && getTag(value) == weakMapTag; 21452 } 21453 21454 /** 21455 * Checks if `value` is classified as a `WeakSet` object. 21456 * 21457 * @static 21458 * @memberOf _ 21459 * @since 4.3.0 21460 * @category Lang 21461 * @param {*} value The value to check. 21462 * @returns {boolean} Returns `true` if `value` is a weak set, else `false`. 21463 * @example 21464 * 21465 * _.isWeakSet(new WeakSet); 21466 * // => true 21467 * 21468 * _.isWeakSet(new Set); 21469 * // => false 21470 */ 21471 function isWeakSet(value) { 21472 return isObjectLike(value) && baseGetTag(value) == weakSetTag; 21473 } 21474 21475 /** 21476 * Checks if `value` is less than `other`. 21477 * 21478 * @static 21479 * @memberOf _ 21480 * @since 3.9.0 21481 * @category Lang 21482 * @param {*} value The value to compare. 21483 * @param {*} other The other value to compare. 21484 * @returns {boolean} Returns `true` if `value` is less than `other`, 21485 * else `false`. 21486 * @see _.gt 21487 * @example 21488 * 21489 * _.lt(1, 3); 21490 * // => true 21491 * 21492 * _.lt(3, 3); 21493 * // => false 21494 * 21495 * _.lt(3, 1); 21496 * // => false 21497 */ 21498 var lt = createRelationalOperation(baseLt); 21499 21500 /** 21501 * Checks if `value` is less than or equal to `other`. 21502 * 21503 * @static 21504 * @memberOf _ 21505 * @since 3.9.0 21506 * @category Lang 21507 * @param {*} value The value to compare. 21508 * @param {*} other The other value to compare. 21509 * @returns {boolean} Returns `true` if `value` is less than or equal to 21510 * `other`, else `false`. 21511 * @see _.gte 21512 * @example 21513 * 21514 * _.lte(1, 3); 21515 * // => true 21516 * 21517 * _.lte(3, 3); 21518 * // => true 21519 * 21520 * _.lte(3, 1); 21521 * // => false 21522 */ 21523 var lte = createRelationalOperation(function(value, other) { 21524 return value <= other; 21525 }); 21526 21527 /** 21528 * Converts `value` to an array. 21529 * 21530 * @static 21531 * @since 0.1.0 21532 * @memberOf _ 21533 * @category Lang 21534 * @param {*} value The value to convert. 21535 * @returns {Array} Returns the converted array. 21536 * @example 21537 * 21538 * _.toArray({ 'a': 1, 'b': 2 }); 21539 * // => [1, 2] 21540 * 21541 * _.toArray('abc'); 21542 * // => ['a', 'b', 'c'] 21543 * 21544 * _.toArray(1); 21545 * // => [] 21546 * 21547 * _.toArray(null); 21548 * // => [] 21549 */ 21550 function toArray(value) { 21551 if (!value) { 21552 return []; 21553 } 21554 if (isArrayLike(value)) { 21555 return isString(value) ? stringToArray(value) : copyArray(value); 21556 } 21557 if (symIterator && value[symIterator]) { 21558 return iteratorToArray(value[symIterator]()); 21559 } 21560 var tag = getTag(value), 21561 func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values); 21562 21563 return func(value); 21564 } 21565 21566 /** 21567 * Converts `value` to a finite number. 21568 * 21569 * @static 21570 * @memberOf _ 21571 * @since 4.12.0 21572 * @category Lang 21573 * @param {*} value The value to convert. 21574 * @returns {number} Returns the converted number. 21575 * @example 21576 * 21577 * _.toFinite(3.2); 21578 * // => 3.2 21579 * 21580 * _.toFinite(Number.MIN_VALUE); 21581 * // => 5e-324 21582 * 21583 * _.toFinite(Infinity); 21584 * // => 1.7976931348623157e+308 21585 * 21586 * _.toFinite('3.2'); 21587 * // => 3.2 21588 */ 21589 function toFinite(value) { 21590 if (!value) { 21591 return value === 0 ? value : 0; 21592 } 21593 value = toNumber(value); 21594 if (value === INFINITY || value === -INFINITY) { 21595 var sign = (value < 0 ? -1 : 1); 21596 return sign * MAX_INTEGER; 21597 } 21598 return value === value ? value : 0; 21599 } 21600 21601 /** 21602 * Converts `value` to an integer. 21603 * 21604 * **Note:** This method is loosely based on 21605 * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger). 21606 * 21607 * @static 21608 * @memberOf _ 21609 * @since 4.0.0 21610 * @category Lang 21611 * @param {*} value The value to convert. 21612 * @returns {number} Returns the converted integer. 21613 * @example 21614 * 21615 * _.toInteger(3.2); 21616 * // => 3 21617 * 21618 * _.toInteger(Number.MIN_VALUE); 21619 * // => 0 21620 * 21621 * _.toInteger(Infinity); 21622 * // => 1.7976931348623157e+308 21623 * 21624 * _.toInteger('3.2'); 21625 * // => 3 21626 */ 21627 function toInteger(value) { 21628 var result = toFinite(value), 21629 remainder = result % 1; 21630 21631 return result === result ? (remainder ? result - remainder : result) : 0; 21632 } 21633 21634 /** 21635 * Converts `value` to an integer suitable for use as the length of an 21636 * array-like object. 21637 * 21638 * **Note:** This method is based on 21639 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). 21640 * 21641 * @static 21642 * @memberOf _ 21643 * @since 4.0.0 21644 * @category Lang 21645 * @param {*} value The value to convert. 21646 * @returns {number} Returns the converted integer. 21647 * @example 21648 * 21649 * _.toLength(3.2); 21650 * // => 3 21651 * 21652 * _.toLength(Number.MIN_VALUE); 21653 * // => 0 21654 * 21655 * _.toLength(Infinity); 21656 * // => 4294967295 21657 * 21658 * _.toLength('3.2'); 21659 * // => 3 21660 */ 21661 function toLength(value) { 21662 return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0; 21663 } 21664 21665 /** 21666 * Converts `value` to a number. 21667 * 21668 * @static 21669 * @memberOf _ 21670 * @since 4.0.0 21671 * @category Lang 21672 * @param {*} value The value to process. 21673 * @returns {number} Returns the number. 21674 * @example 21675 * 21676 * _.toNumber(3.2); 21677 * // => 3.2 21678 * 21679 * _.toNumber(Number.MIN_VALUE); 21680 * // => 5e-324 21681 * 21682 * _.toNumber(Infinity); 21683 * // => Infinity 21684 * 21685 * _.toNumber('3.2'); 21686 * // => 3.2 21687 */ 21688 function toNumber(value) { 21689 if (typeof value == 'number') { 21690 return value; 21691 } 21692 if (isSymbol(value)) { 21693 return NAN; 21694 } 21695 if (isObject(value)) { 21696 var other = typeof value.valueOf == 'function' ? value.valueOf() : value; 21697 value = isObject(other) ? (other + '') : other; 21698 } 21699 if (typeof value != 'string') { 21700 return value === 0 ? value : +value; 21701 } 21702 value = baseTrim(value); 21703 var isBinary = reIsBinary.test(value); 21704 return (isBinary || reIsOctal.test(value)) 21705 ? freeParseInt(value.slice(2), isBinary ? 2 : 8) 21706 : (reIsBadHex.test(value) ? NAN : +value); 21707 } 21708 21709 /** 21710 * Converts `value` to a plain object flattening inherited enumerable string 21711 * keyed properties of `value` to own properties of the plain object. 21712 * 21713 * @static 21714 * @memberOf _ 21715 * @since 3.0.0 21716 * @category Lang 21717 * @param {*} value The value to convert. 21718 * @returns {Object} Returns the converted plain object. 21719 * @example 21720 * 21721 * function Foo() { 21722 * this.b = 2; 21723 * } 21724 * 21725 * Foo.prototype.c = 3; 21726 * 21727 * _.assign({ 'a': 1 }, new Foo); 21728 * // => { 'a': 1, 'b': 2 } 21729 * 21730 * _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); 21731 * // => { 'a': 1, 'b': 2, 'c': 3 } 21732 */ 21733 function toPlainObject(value) { 21734 return copyObject(value, keysIn(value)); 21735 } 21736 21737 /** 21738 * Converts `value` to a safe integer. A safe integer can be compared and 21739 * represented correctly. 21740 * 21741 * @static 21742 * @memberOf _ 21743 * @since 4.0.0 21744 * @category Lang 21745 * @param {*} value The value to convert. 21746 * @returns {number} Returns the converted integer. 21747 * @example 21748 * 21749 * _.toSafeInteger(3.2); 21750 * // => 3 21751 * 21752 * _.toSafeInteger(Number.MIN_VALUE); 21753 * // => 0 21754 * 21755 * _.toSafeInteger(Infinity); 21756 * // => 9007199254740991 21757 * 21758 * _.toSafeInteger('3.2'); 21759 * // => 3 21760 */ 21761 function toSafeInteger(value) { 21762 return value 21763 ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER) 21764 : (value === 0 ? value : 0); 21765 } 21766 21767 /** 21768 * Converts `value` to a string. An empty string is returned for `null` 21769 * and `undefined` values. The sign of `-0` is preserved. 21770 * 21771 * @static 21772 * @memberOf _ 21773 * @since 4.0.0 21774 * @category Lang 21775 * @param {*} value The value to convert. 21776 * @returns {string} Returns the converted string. 21777 * @example 21778 * 21779 * _.toString(null); 21780 * // => '' 21781 * 21782 * _.toString(-0); 21783 * // => '-0' 21784 * 21785 * _.toString([1, 2, 3]); 21786 * // => '1,2,3' 21787 */ 21788 function toString(value) { 21789 return value == null ? '' : baseToString(value); 21790 } 21791 21792 /*------------------------------------------------------------------------*/ 21793 21794 /** 21795 * Assigns own enumerable string keyed properties of source objects to the 21796 * destination object. Source objects are applied from left to right. 21797 * Subsequent sources overwrite property assignments of previous sources. 21798 * 21799 * **Note:** This method mutates `object` and is loosely based on 21800 * [`Object.assign`](https://mdn.io/Object/assign). 21801 * 21802 * @static 21803 * @memberOf _ 21804 * @since 0.10.0 21805 * @category Object 21806 * @param {Object} object The destination object. 21807 * @param {...Object} [sources] The source objects. 21808 * @returns {Object} Returns `object`. 21809 * @see _.assignIn 21810 * @example 21811 * 21812 * function Foo() { 21813 * this.a = 1; 21814 * } 21815 * 21816 * function Bar() { 21817 * this.c = 3; 21818 * } 21819 * 21820 * Foo.prototype.b = 2; 21821 * Bar.prototype.d = 4; 21822 * 21823 * _.assign({ 'a': 0 }, new Foo, new Bar); 21824 * // => { 'a': 1, 'c': 3 } 21825 */ 21826 var assign = createAssigner(function(object, source) { 21827 if (isPrototype(source) || isArrayLike(source)) { 21828 copyObject(source, keys(source), object); 21829 return; 21830 } 21831 for (var key in source) { 21832 if (hasOwnProperty.call(source, key)) { 21833 assignValue(object, key, source[key]); 21834 } 21835 } 21836 }); 21837 21838 /** 21839 * This method is like `_.assign` except that it iterates over own and 21840 * inherited source properties. 21841 * 21842 * **Note:** This method mutates `object`. 21843 * 21844 * @static 21845 * @memberOf _ 21846 * @since 4.0.0 21847 * @alias extend 21848 * @category Object 21849 * @param {Object} object The destination object. 21850 * @param {...Object} [sources] The source objects. 21851 * @returns {Object} Returns `object`. 21852 * @see _.assign 21853 * @example 21854 * 21855 * function Foo() { 21856 * this.a = 1; 21857 * } 21858 * 21859 * function Bar() { 21860 * this.c = 3; 21861 * } 21862 * 21863 * Foo.prototype.b = 2; 21864 * Bar.prototype.d = 4; 21865 * 21866 * _.assignIn({ 'a': 0 }, new Foo, new Bar); 21867 * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 } 21868 */ 21869 var assignIn = createAssigner(function(object, source) { 21870 copyObject(source, keysIn(source), object); 21871 }); 21872 21873 /** 21874 * This method is like `_.assignIn` except that it accepts `customizer` 21875 * which is invoked to produce the assigned values. If `customizer` returns 21876 * `undefined`, assignment is handled by the method instead. The `customizer` 21877 * is invoked with five arguments: (objValue, srcValue, key, object, source). 21878 * 21879 * **Note:** This method mutates `object`. 21880 * 21881 * @static 21882 * @memberOf _ 21883 * @since 4.0.0 21884 * @alias extendWith 21885 * @category Object 21886 * @param {Object} object The destination object. 21887 * @param {...Object} sources The source objects. 21888 * @param {Function} [customizer] The function to customize assigned values. 21889 * @returns {Object} Returns `object`. 21890 * @see _.assignWith 21891 * @example 21892 * 21893 * function customizer(objValue, srcValue) { 21894 * return _.isUndefined(objValue) ? srcValue : objValue; 21895 * } 21896 * 21897 * var defaults = _.partialRight(_.assignInWith, customizer); 21898 * 21899 * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); 21900 * // => { 'a': 1, 'b': 2 } 21901 */ 21902 var assignInWith = createAssigner(function(object, source, srcIndex, customizer) { 21903 copyObject(source, keysIn(source), object, customizer); 21904 }); 21905 21906 /** 21907 * This method is like `_.assign` except that it accepts `customizer` 21908 * which is invoked to produce the assigned values. If `customizer` returns 21909 * `undefined`, assignment is handled by the method instead. The `customizer` 21910 * is invoked with five arguments: (objValue, srcValue, key, object, source). 21911 * 21912 * **Note:** This method mutates `object`. 21913 * 21914 * @static 21915 * @memberOf _ 21916 * @since 4.0.0 21917 * @category Object 21918 * @param {Object} object The destination object. 21919 * @param {...Object} sources The source objects. 21920 * @param {Function} [customizer] The function to customize assigned values. 21921 * @returns {Object} Returns `object`. 21922 * @see _.assignInWith 21923 * @example 21924 * 21925 * function customizer(objValue, srcValue) { 21926 * return _.isUndefined(objValue) ? srcValue : objValue; 21927 * } 21928 * 21929 * var defaults = _.partialRight(_.assignWith, customizer); 21930 * 21931 * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); 21932 * // => { 'a': 1, 'b': 2 } 21933 */ 21934 var assignWith = createAssigner(function(object, source, srcIndex, customizer) { 21935 copyObject(source, keys(source), object, customizer); 21936 }); 21937 21938 /** 21939 * Creates an array of values corresponding to `paths` of `object`. 21940 * 21941 * @static 21942 * @memberOf _ 21943 * @since 1.0.0 21944 * @category Object 21945 * @param {Object} object The object to iterate over. 21946 * @param {...(string|string[])} [paths] The property paths to pick. 21947 * @returns {Array} Returns the picked values. 21948 * @example 21949 * 21950 * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; 21951 * 21952 * _.at(object, ['a[0].b.c', 'a[1]']); 21953 * // => [3, 4] 21954 */ 21955 var at = flatRest(baseAt); 21956 21957 /** 21958 * Creates an object that inherits from the `prototype` object. If a 21959 * `properties` object is given, its own enumerable string keyed properties 21960 * are assigned to the created object. 21961 * 21962 * @static 21963 * @memberOf _ 21964 * @since 2.3.0 21965 * @category Object 21966 * @param {Object} prototype The object to inherit from. 21967 * @param {Object} [properties] The properties to assign to the object. 21968 * @returns {Object} Returns the new object. 21969 * @example 21970 * 21971 * function Shape() { 21972 * this.x = 0; 21973 * this.y = 0; 21974 * } 21975 * 21976 * function Circle() { 21977 * Shape.call(this); 21978 * } 21979 * 21980 * Circle.prototype = _.create(Shape.prototype, { 21981 * 'constructor': Circle 21982 * }); 21983 * 21984 * var circle = new Circle; 21985 * circle instanceof Circle; 21986 * // => true 21987 * 21988 * circle instanceof Shape; 21989 * // => true 21990 */ 21991 function create(prototype, properties) { 21992 var result = baseCreate(prototype); 21993 return properties == null ? result : baseAssign(result, properties); 21994 } 21995 21996 /** 21997 * Assigns own and inherited enumerable string keyed properties of source 21998 * objects to the destination object for all destination properties that 21999 * resolve to `undefined`. Source objects are applied from left to right. 22000 * Once a property is set, additional values of the same property are ignored. 22001 * 22002 * **Note:** This method mutates `object`. 22003 * 22004 * @static 22005 * @since 0.1.0 22006 * @memberOf _ 22007 * @category Object 22008 * @param {Object} object The destination object. 22009 * @param {...Object} [sources] The source objects. 22010 * @returns {Object} Returns `object`. 22011 * @see _.defaultsDeep 22012 * @example 22013 * 22014 * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); 22015 * // => { 'a': 1, 'b': 2 } 22016 */ 22017 var defaults = baseRest(function(object, sources) { 22018 object = Object(object); 22019 22020 var index = -1; 22021 var length = sources.length; 22022 var guard = length > 2 ? sources[2] : undefined; 22023 22024 if (guard && isIterateeCall(sources[0], sources[1], guard)) { 22025 length = 1; 22026 } 22027 22028 while (++index < length) { 22029 var source = sources[index]; 22030 var props = keysIn(source); 22031 var propsIndex = -1; 22032 var propsLength = props.length; 22033 22034 while (++propsIndex < propsLength) { 22035 var key = props[propsIndex]; 22036 var value = object[key]; 22037 22038 if (value === undefined || 22039 (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) { 22040 object[key] = source[key]; 22041 } 22042 } 22043 } 22044 22045 return object; 22046 }); 22047 22048 /** 22049 * This method is like `_.defaults` except that it recursively assigns 22050 * default properties. 22051 * 22052 * **Note:** This method mutates `object`. 22053 * 22054 * @static 22055 * @memberOf _ 22056 * @since 3.10.0 22057 * @category Object 22058 * @param {Object} object The destination object. 22059 * @param {...Object} [sources] The source objects. 22060 * @returns {Object} Returns `object`. 22061 * @see _.defaults 22062 * @example 22063 * 22064 * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } }); 22065 * // => { 'a': { 'b': 2, 'c': 3 } } 22066 */ 22067 var defaultsDeep = baseRest(function(args) { 22068 args.push(undefined, customDefaultsMerge); 22069 return apply(mergeWith, undefined, args); 22070 }); 22071 22072 /** 22073 * This method is like `_.find` except that it returns the key of the first 22074 * element `predicate` returns truthy for instead of the element itself. 22075 * 22076 * @static 22077 * @memberOf _ 22078 * @since 1.1.0 22079 * @category Object 22080 * @param {Object} object The object to inspect. 22081 * @param {Function} [predicate=_.identity] The function invoked per iteration. 22082 * @returns {string|undefined} Returns the key of the matched element, 22083 * else `undefined`. 22084 * @example 22085 * 22086 * var users = { 22087 * 'barney': { 'age': 36, 'active': true }, 22088 * 'fred': { 'age': 40, 'active': false }, 22089 * 'pebbles': { 'age': 1, 'active': true } 22090 * }; 22091 * 22092 * _.findKey(users, function(o) { return o.age < 40; }); 22093 * // => 'barney' (iteration order is not guaranteed) 22094 * 22095 * // The `_.matches` iteratee shorthand. 22096 * _.findKey(users, { 'age': 1, 'active': true }); 22097 * // => 'pebbles' 22098 * 22099 * // The `_.matchesProperty` iteratee shorthand. 22100 * _.findKey(users, ['active', false]); 22101 * // => 'fred' 22102 * 22103 * // The `_.property` iteratee shorthand. 22104 * _.findKey(users, 'active'); 22105 * // => 'barney' 22106 */ 22107 function findKey(object, predicate) { 22108 return baseFindKey(object, getIteratee(predicate, 3), baseForOwn); 22109 } 22110 22111 /** 22112 * This method is like `_.findKey` except that it iterates over elements of 22113 * a collection in the opposite order. 22114 * 22115 * @static 22116 * @memberOf _ 22117 * @since 2.0.0 22118 * @category Object 22119 * @param {Object} object The object to inspect. 22120 * @param {Function} [predicate=_.identity] The function invoked per iteration. 22121 * @returns {string|undefined} Returns the key of the matched element, 22122 * else `undefined`. 22123 * @example 22124 * 22125 * var users = { 22126 * 'barney': { 'age': 36, 'active': true }, 22127 * 'fred': { 'age': 40, 'active': false }, 22128 * 'pebbles': { 'age': 1, 'active': true } 22129 * }; 22130 * 22131 * _.findLastKey(users, function(o) { return o.age < 40; }); 22132 * // => returns 'pebbles' assuming `_.findKey` returns 'barney' 22133 * 22134 * // The `_.matches` iteratee shorthand. 22135 * _.findLastKey(users, { 'age': 36, 'active': true }); 22136 * // => 'barney' 22137 * 22138 * // The `_.matchesProperty` iteratee shorthand. 22139 * _.findLastKey(users, ['active', false]); 22140 * // => 'fred' 22141 * 22142 * // The `_.property` iteratee shorthand. 22143 * _.findLastKey(users, 'active'); 22144 * // => 'pebbles' 22145 */ 22146 function findLastKey(object, predicate) { 22147 return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight); 22148 } 22149 22150 /** 22151 * Iterates over own and inherited enumerable string keyed properties of an 22152 * object and invokes `iteratee` for each property. The iteratee is invoked 22153 * with three arguments: (value, key, object). Iteratee functions may exit 22154 * iteration early by explicitly returning `false`. 22155 * 22156 * @static 22157 * @memberOf _ 22158 * @since 0.3.0 22159 * @category Object 22160 * @param {Object} object The object to iterate over. 22161 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 22162 * @returns {Object} Returns `object`. 22163 * @see _.forInRight 22164 * @example 22165 * 22166 * function Foo() { 22167 * this.a = 1; 22168 * this.b = 2; 22169 * } 22170 * 22171 * Foo.prototype.c = 3; 22172 * 22173 * _.forIn(new Foo, function(value, key) { 22174 * console.log(key); 22175 * }); 22176 * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed). 22177 */ 22178 function forIn(object, iteratee) { 22179 return object == null 22180 ? object 22181 : baseFor(object, getIteratee(iteratee, 3), keysIn); 22182 } 22183 22184 /** 22185 * This method is like `_.forIn` except that it iterates over properties of 22186 * `object` in the opposite order. 22187 * 22188 * @static 22189 * @memberOf _ 22190 * @since 2.0.0 22191 * @category Object 22192 * @param {Object} object The object to iterate over. 22193 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 22194 * @returns {Object} Returns `object`. 22195 * @see _.forIn 22196 * @example 22197 * 22198 * function Foo() { 22199 * this.a = 1; 22200 * this.b = 2; 22201 * } 22202 * 22203 * Foo.prototype.c = 3; 22204 * 22205 * _.forInRight(new Foo, function(value, key) { 22206 * console.log(key); 22207 * }); 22208 * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'. 22209 */ 22210 function forInRight(object, iteratee) { 22211 return object == null 22212 ? object 22213 : baseForRight(object, getIteratee(iteratee, 3), keysIn); 22214 } 22215 22216 /** 22217 * Iterates over own enumerable string keyed properties of an object and 22218 * invokes `iteratee` for each property. The iteratee is invoked with three 22219 * arguments: (value, key, object). Iteratee functions may exit iteration 22220 * early by explicitly returning `false`. 22221 * 22222 * @static 22223 * @memberOf _ 22224 * @since 0.3.0 22225 * @category Object 22226 * @param {Object} object The object to iterate over. 22227 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 22228 * @returns {Object} Returns `object`. 22229 * @see _.forOwnRight 22230 * @example 22231 * 22232 * function Foo() { 22233 * this.a = 1; 22234 * this.b = 2; 22235 * } 22236 * 22237 * Foo.prototype.c = 3; 22238 * 22239 * _.forOwn(new Foo, function(value, key) { 22240 * console.log(key); 22241 * }); 22242 * // => Logs 'a' then 'b' (iteration order is not guaranteed). 22243 */ 22244 function forOwn(object, iteratee) { 22245 return object && baseForOwn(object, getIteratee(iteratee, 3)); 22246 } 22247 22248 /** 22249 * This method is like `_.forOwn` except that it iterates over properties of 22250 * `object` in the opposite order. 22251 * 22252 * @static 22253 * @memberOf _ 22254 * @since 2.0.0 22255 * @category Object 22256 * @param {Object} object The object to iterate over. 22257 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 22258 * @returns {Object} Returns `object`. 22259 * @see _.forOwn 22260 * @example 22261 * 22262 * function Foo() { 22263 * this.a = 1; 22264 * this.b = 2; 22265 * } 22266 * 22267 * Foo.prototype.c = 3; 22268 * 22269 * _.forOwnRight(new Foo, function(value, key) { 22270 * console.log(key); 22271 * }); 22272 * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'. 22273 */ 22274 function forOwnRight(object, iteratee) { 22275 return object && baseForOwnRight(object, getIteratee(iteratee, 3)); 22276 } 22277 22278 /** 22279 * Creates an array of function property names from own enumerable properties 22280 * of `object`. 22281 * 22282 * @static 22283 * @since 0.1.0 22284 * @memberOf _ 22285 * @category Object 22286 * @param {Object} object The object to inspect. 22287 * @returns {Array} Returns the function names. 22288 * @see _.functionsIn 22289 * @example 22290 * 22291 * function Foo() { 22292 * this.a = _.constant('a'); 22293 * this.b = _.constant('b'); 22294 * } 22295 * 22296 * Foo.prototype.c = _.constant('c'); 22297 * 22298 * _.functions(new Foo); 22299 * // => ['a', 'b'] 22300 */ 22301 function functions(object) { 22302 return object == null ? [] : baseFunctions(object, keys(object)); 22303 } 22304 22305 /** 22306 * Creates an array of function property names from own and inherited 22307 * enumerable properties of `object`. 22308 * 22309 * @static 22310 * @memberOf _ 22311 * @since 4.0.0 22312 * @category Object 22313 * @param {Object} object The object to inspect. 22314 * @returns {Array} Returns the function names. 22315 * @see _.functions 22316 * @example 22317 * 22318 * function Foo() { 22319 * this.a = _.constant('a'); 22320 * this.b = _.constant('b'); 22321 * } 22322 * 22323 * Foo.prototype.c = _.constant('c'); 22324 * 22325 * _.functionsIn(new Foo); 22326 * // => ['a', 'b', 'c'] 22327 */ 22328 function functionsIn(object) { 22329 return object == null ? [] : baseFunctions(object, keysIn(object)); 22330 } 22331 22332 /** 22333 * Gets the value at `path` of `object`. If the resolved value is 22334 * `undefined`, the `defaultValue` is returned in its place. 22335 * 22336 * @static 22337 * @memberOf _ 22338 * @since 3.7.0 22339 * @category Object 22340 * @param {Object} object The object to query. 22341 * @param {Array|string} path The path of the property to get. 22342 * @param {*} [defaultValue] The value returned for `undefined` resolved values. 22343 * @returns {*} Returns the resolved value. 22344 * @example 22345 * 22346 * var object = { 'a': [{ 'b': { 'c': 3 } }] }; 22347 * 22348 * _.get(object, 'a[0].b.c'); 22349 * // => 3 22350 * 22351 * _.get(object, ['a', '0', 'b', 'c']); 22352 * // => 3 22353 * 22354 * _.get(object, 'a.b.c', 'default'); 22355 * // => 'default' 22356 */ 22357 function get(object, path, defaultValue) { 22358 var result = object == null ? undefined : baseGet(object, path); 22359 return result === undefined ? defaultValue : result; 22360 } 22361 22362 /** 22363 * Checks if `path` is a direct property of `object`. 22364 * 22365 * @static 22366 * @since 0.1.0 22367 * @memberOf _ 22368 * @category Object 22369 * @param {Object} object The object to query. 22370 * @param {Array|string} path The path to check. 22371 * @returns {boolean} Returns `true` if `path` exists, else `false`. 22372 * @example 22373 * 22374 * var object = { 'a': { 'b': 2 } }; 22375 * var other = _.create({ 'a': _.create({ 'b': 2 }) }); 22376 * 22377 * _.has(object, 'a'); 22378 * // => true 22379 * 22380 * _.has(object, 'a.b'); 22381 * // => true 22382 * 22383 * _.has(object, ['a', 'b']); 22384 * // => true 22385 * 22386 * _.has(other, 'a'); 22387 * // => false 22388 */ 22389 function has(object, path) { 22390 return object != null && hasPath(object, path, baseHas); 22391 } 22392 22393 /** 22394 * Checks if `path` is a direct or inherited property of `object`. 22395 * 22396 * @static 22397 * @memberOf _ 22398 * @since 4.0.0 22399 * @category Object 22400 * @param {Object} object The object to query. 22401 * @param {Array|string} path The path to check. 22402 * @returns {boolean} Returns `true` if `path` exists, else `false`. 22403 * @example 22404 * 22405 * var object = _.create({ 'a': _.create({ 'b': 2 }) }); 22406 * 22407 * _.hasIn(object, 'a'); 22408 * // => true 22409 * 22410 * _.hasIn(object, 'a.b'); 22411 * // => true 22412 * 22413 * _.hasIn(object, ['a', 'b']); 22414 * // => true 22415 * 22416 * _.hasIn(object, 'b'); 22417 * // => false 22418 */ 22419 function hasIn(object, path) { 22420 return object != null && hasPath(object, path, baseHasIn); 22421 } 22422 22423 /** 22424 * Creates an object composed of the inverted keys and values of `object`. 22425 * If `object` contains duplicate values, subsequent values overwrite 22426 * property assignments of previous values. 22427 * 22428 * @static 22429 * @memberOf _ 22430 * @since 0.7.0 22431 * @category Object 22432 * @param {Object} object The object to invert. 22433 * @returns {Object} Returns the new inverted object. 22434 * @example 22435 * 22436 * var object = { 'a': 1, 'b': 2, 'c': 1 }; 22437 * 22438 * _.invert(object); 22439 * // => { '1': 'c', '2': 'b' } 22440 */ 22441 var invert = createInverter(function(result, value, key) { 22442 if (value != null && 22443 typeof value.toString != 'function') { 22444 value = nativeObjectToString.call(value); 22445 } 22446 22447 result[value] = key; 22448 }, constant(identity)); 22449 22450 /** 22451 * This method is like `_.invert` except that the inverted object is generated 22452 * from the results of running each element of `object` thru `iteratee`. The 22453 * corresponding inverted value of each inverted key is an array of keys 22454 * responsible for generating the inverted value. The iteratee is invoked 22455 * with one argument: (value). 22456 * 22457 * @static 22458 * @memberOf _ 22459 * @since 4.1.0 22460 * @category Object 22461 * @param {Object} object The object to invert. 22462 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 22463 * @returns {Object} Returns the new inverted object. 22464 * @example 22465 * 22466 * var object = { 'a': 1, 'b': 2, 'c': 1 }; 22467 * 22468 * _.invertBy(object); 22469 * // => { '1': ['a', 'c'], '2': ['b'] } 22470 * 22471 * _.invertBy(object, function(value) { 22472 * return 'group' + value; 22473 * }); 22474 * // => { 'group1': ['a', 'c'], 'group2': ['b'] } 22475 */ 22476 var invertBy = createInverter(function(result, value, key) { 22477 if (value != null && 22478 typeof value.toString != 'function') { 22479 value = nativeObjectToString.call(value); 22480 } 22481 22482 if (hasOwnProperty.call(result, value)) { 22483 result[value].push(key); 22484 } else { 22485 result[value] = [key]; 22486 } 22487 }, getIteratee); 22488 22489 /** 22490 * Invokes the method at `path` of `object`. 22491 * 22492 * @static 22493 * @memberOf _ 22494 * @since 4.0.0 22495 * @category Object 22496 * @param {Object} object The object to query. 22497 * @param {Array|string} path The path of the method to invoke. 22498 * @param {...*} [args] The arguments to invoke the method with. 22499 * @returns {*} Returns the result of the invoked method. 22500 * @example 22501 * 22502 * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] }; 22503 * 22504 * _.invoke(object, 'a[0].b.c.slice', 1, 3); 22505 * // => [2, 3] 22506 */ 22507 var invoke = baseRest(baseInvoke); 22508 22509 /** 22510 * Creates an array of the own enumerable property names of `object`. 22511 * 22512 * **Note:** Non-object values are coerced to objects. See the 22513 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) 22514 * for more details. 22515 * 22516 * @static 22517 * @since 0.1.0 22518 * @memberOf _ 22519 * @category Object 22520 * @param {Object} object The object to query. 22521 * @returns {Array} Returns the array of property names. 22522 * @example 22523 * 22524 * function Foo() { 22525 * this.a = 1; 22526 * this.b = 2; 22527 * } 22528 * 22529 * Foo.prototype.c = 3; 22530 * 22531 * _.keys(new Foo); 22532 * // => ['a', 'b'] (iteration order is not guaranteed) 22533 * 22534 * _.keys('hi'); 22535 * // => ['0', '1'] 22536 */ 22537 function keys(object) { 22538 return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); 22539 } 22540 22541 /** 22542 * Creates an array of the own and inherited enumerable property names of `object`. 22543 * 22544 * **Note:** Non-object values are coerced to objects. 22545 * 22546 * @static 22547 * @memberOf _ 22548 * @since 3.0.0 22549 * @category Object 22550 * @param {Object} object The object to query. 22551 * @returns {Array} Returns the array of property names. 22552 * @example 22553 * 22554 * function Foo() { 22555 * this.a = 1; 22556 * this.b = 2; 22557 * } 22558 * 22559 * Foo.prototype.c = 3; 22560 * 22561 * _.keysIn(new Foo); 22562 * // => ['a', 'b', 'c'] (iteration order is not guaranteed) 22563 */ 22564 function keysIn(object) { 22565 return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object); 22566 } 22567 22568 /** 22569 * The opposite of `_.mapValues`; this method creates an object with the 22570 * same values as `object` and keys generated by running each own enumerable 22571 * string keyed property of `object` thru `iteratee`. The iteratee is invoked 22572 * with three arguments: (value, key, object). 22573 * 22574 * @static 22575 * @memberOf _ 22576 * @since 3.8.0 22577 * @category Object 22578 * @param {Object} object The object to iterate over. 22579 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 22580 * @returns {Object} Returns the new mapped object. 22581 * @see _.mapValues 22582 * @example 22583 * 22584 * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) { 22585 * return key + value; 22586 * }); 22587 * // => { 'a1': 1, 'b2': 2 } 22588 */ 22589 function mapKeys(object, iteratee) { 22590 var result = {}; 22591 iteratee = getIteratee(iteratee, 3); 22592 22593 baseForOwn(object, function(value, key, object) { 22594 baseAssignValue(result, iteratee(value, key, object), value); 22595 }); 22596 return result; 22597 } 22598 22599 /** 22600 * Creates an object with the same keys as `object` and values generated 22601 * by running each own enumerable string keyed property of `object` thru 22602 * `iteratee`. The iteratee is invoked with three arguments: 22603 * (value, key, object). 22604 * 22605 * @static 22606 * @memberOf _ 22607 * @since 2.4.0 22608 * @category Object 22609 * @param {Object} object The object to iterate over. 22610 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 22611 * @returns {Object} Returns the new mapped object. 22612 * @see _.mapKeys 22613 * @example 22614 * 22615 * var users = { 22616 * 'fred': { 'user': 'fred', 'age': 40 }, 22617 * 'pebbles': { 'user': 'pebbles', 'age': 1 } 22618 * }; 22619 * 22620 * _.mapValues(users, function(o) { return o.age; }); 22621 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) 22622 * 22623 * // The `_.property` iteratee shorthand. 22624 * _.mapValues(users, 'age'); 22625 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) 22626 */ 22627 function mapValues(object, iteratee) { 22628 var result = {}; 22629 iteratee = getIteratee(iteratee, 3); 22630 22631 baseForOwn(object, function(value, key, object) { 22632 baseAssignValue(result, key, iteratee(value, key, object)); 22633 }); 22634 return result; 22635 } 22636 22637 /** 22638 * This method is like `_.assign` except that it recursively merges own and 22639 * inherited enumerable string keyed properties of source objects into the 22640 * destination object. Source properties that resolve to `undefined` are 22641 * skipped if a destination value exists. Array and plain object properties 22642 * are merged recursively. Other objects and value types are overridden by 22643 * assignment. Source objects are applied from left to right. Subsequent 22644 * sources overwrite property assignments of previous sources. 22645 * 22646 * **Note:** This method mutates `object`. 22647 * 22648 * @static 22649 * @memberOf _ 22650 * @since 0.5.0 22651 * @category Object 22652 * @param {Object} object The destination object. 22653 * @param {...Object} [sources] The source objects. 22654 * @returns {Object} Returns `object`. 22655 * @example 22656 * 22657 * var object = { 22658 * 'a': [{ 'b': 2 }, { 'd': 4 }] 22659 * }; 22660 * 22661 * var other = { 22662 * 'a': [{ 'c': 3 }, { 'e': 5 }] 22663 * }; 22664 * 22665 * _.merge(object, other); 22666 * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] } 22667 */ 22668 var merge = createAssigner(function(object, source, srcIndex) { 22669 baseMerge(object, source, srcIndex); 22670 }); 22671 22672 /** 22673 * This method is like `_.merge` except that it accepts `customizer` which 22674 * is invoked to produce the merged values of the destination and source 22675 * properties. If `customizer` returns `undefined`, merging is handled by the 22676 * method instead. The `customizer` is invoked with six arguments: 22677 * (objValue, srcValue, key, object, source, stack). 22678 * 22679 * **Note:** This method mutates `object`. 22680 * 22681 * @static 22682 * @memberOf _ 22683 * @since 4.0.0 22684 * @category Object 22685 * @param {Object} object The destination object. 22686 * @param {...Object} sources The source objects. 22687 * @param {Function} customizer The function to customize assigned values. 22688 * @returns {Object} Returns `object`. 22689 * @example 22690 * 22691 * function customizer(objValue, srcValue) { 22692 * if (_.isArray(objValue)) { 22693 * return objValue.concat(srcValue); 22694 * } 22695 * } 22696 * 22697 * var object = { 'a': [1], 'b': [2] }; 22698 * var other = { 'a': [3], 'b': [4] }; 22699 * 22700 * _.mergeWith(object, other, customizer); 22701 * // => { 'a': [1, 3], 'b': [2, 4] } 22702 */ 22703 var mergeWith = createAssigner(function(object, source, srcIndex, customizer) { 22704 baseMerge(object, source, srcIndex, customizer); 22705 }); 22706 22707 /** 22708 * The opposite of `_.pick`; this method creates an object composed of the 22709 * own and inherited enumerable property paths of `object` that are not omitted. 22710 * 22711 * **Note:** This method is considerably slower than `_.pick`. 22712 * 22713 * @static 22714 * @since 0.1.0 22715 * @memberOf _ 22716 * @category Object 22717 * @param {Object} object The source object. 22718 * @param {...(string|string[])} [paths] The property paths to omit. 22719 * @returns {Object} Returns the new object. 22720 * @example 22721 * 22722 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 22723 * 22724 * _.omit(object, ['a', 'c']); 22725 * // => { 'b': '2' } 22726 */ 22727 var omit = flatRest(function(object, paths) { 22728 var result = {}; 22729 if (object == null) { 22730 return result; 22731 } 22732 var isDeep = false; 22733 paths = arrayMap(paths, function(path) { 22734 path = castPath(path, object); 22735 isDeep || (isDeep = path.length > 1); 22736 return path; 22737 }); 22738 copyObject(object, getAllKeysIn(object), result); 22739 if (isDeep) { 22740 result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone); 22741 } 22742 var length = paths.length; 22743 while (length--) { 22744 baseUnset(result, paths[length]); 22745 } 22746 return result; 22747 }); 22748 22749 /** 22750 * The opposite of `_.pickBy`; this method creates an object composed of 22751 * the own and inherited enumerable string keyed properties of `object` that 22752 * `predicate` doesn't return truthy for. The predicate is invoked with two 22753 * arguments: (value, key). 22754 * 22755 * @static 22756 * @memberOf _ 22757 * @since 4.0.0 22758 * @category Object 22759 * @param {Object} object The source object. 22760 * @param {Function} [predicate=_.identity] The function invoked per property. 22761 * @returns {Object} Returns the new object. 22762 * @example 22763 * 22764 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 22765 * 22766 * _.omitBy(object, _.isNumber); 22767 * // => { 'b': '2' } 22768 */ 22769 function omitBy(object, predicate) { 22770 return pickBy(object, negate(getIteratee(predicate))); 22771 } 22772 22773 /** 22774 * Creates an object composed of the picked `object` properties. 22775 * 22776 * @static 22777 * @since 0.1.0 22778 * @memberOf _ 22779 * @category Object 22780 * @param {Object} object The source object. 22781 * @param {...(string|string[])} [paths] The property paths to pick. 22782 * @returns {Object} Returns the new object. 22783 * @example 22784 * 22785 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 22786 * 22787 * _.pick(object, ['a', 'c']); 22788 * // => { 'a': 1, 'c': 3 } 22789 */ 22790 var pick = flatRest(function(object, paths) { 22791 return object == null ? {} : basePick(object, paths); 22792 }); 22793 22794 /** 22795 * Creates an object composed of the `object` properties `predicate` returns 22796 * truthy for. The predicate is invoked with two arguments: (value, key). 22797 * 22798 * @static 22799 * @memberOf _ 22800 * @since 4.0.0 22801 * @category Object 22802 * @param {Object} object The source object. 22803 * @param {Function} [predicate=_.identity] The function invoked per property. 22804 * @returns {Object} Returns the new object. 22805 * @example 22806 * 22807 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 22808 * 22809 * _.pickBy(object, _.isNumber); 22810 * // => { 'a': 1, 'c': 3 } 22811 */ 22812 function pickBy(object, predicate) { 22813 if (object == null) { 22814 return {}; 22815 } 22816 var props = arrayMap(getAllKeysIn(object), function(prop) { 22817 return [prop]; 22818 }); 22819 predicate = getIteratee(predicate); 22820 return basePickBy(object, props, function(value, path) { 22821 return predicate(value, path[0]); 22822 }); 22823 } 22824 22825 /** 22826 * This method is like `_.get` except that if the resolved value is a 22827 * function it's invoked with the `this` binding of its parent object and 22828 * its result is returned. 22829 * 22830 * @static 22831 * @since 0.1.0 22832 * @memberOf _ 22833 * @category Object 22834 * @param {Object} object The object to query. 22835 * @param {Array|string} path The path of the property to resolve. 22836 * @param {*} [defaultValue] The value returned for `undefined` resolved values. 22837 * @returns {*} Returns the resolved value. 22838 * @example 22839 * 22840 * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] }; 22841 * 22842 * _.result(object, 'a[0].b.c1'); 22843 * // => 3 22844 * 22845 * _.result(object, 'a[0].b.c2'); 22846 * // => 4 22847 * 22848 * _.result(object, 'a[0].b.c3', 'default'); 22849 * // => 'default' 22850 * 22851 * _.result(object, 'a[0].b.c3', _.constant('default')); 22852 * // => 'default' 22853 */ 22854 function result(object, path, defaultValue) { 22855 path = castPath(path, object); 22856 22857 var index = -1, 22858 length = path.length; 22859 22860 // Ensure the loop is entered when path is empty. 22861 if (!length) { 22862 length = 1; 22863 object = undefined; 22864 } 22865 while (++index < length) { 22866 var value = object == null ? undefined : object[toKey(path[index])]; 22867 if (value === undefined) { 22868 index = length; 22869 value = defaultValue; 22870 } 22871 object = isFunction(value) ? value.call(object) : value; 22872 } 22873 return object; 22874 } 22875 22876 /** 22877 * Sets the value at `path` of `object`. If a portion of `path` doesn't exist, 22878 * it's created. Arrays are created for missing index properties while objects 22879 * are created for all other missing properties. Use `_.setWith` to customize 22880 * `path` creation. 22881 * 22882 * **Note:** This method mutates `object`. 22883 * 22884 * @static 22885 * @memberOf _ 22886 * @since 3.7.0 22887 * @category Object 22888 * @param {Object} object The object to modify. 22889 * @param {Array|string} path The path of the property to set. 22890 * @param {*} value The value to set. 22891 * @returns {Object} Returns `object`. 22892 * @example 22893 * 22894 * var object = { 'a': [{ 'b': { 'c': 3 } }] }; 22895 * 22896 * _.set(object, 'a[0].b.c', 4); 22897 * console.log(object.a[0].b.c); 22898 * // => 4 22899 * 22900 * _.set(object, ['x', '0', 'y', 'z'], 5); 22901 * console.log(object.x[0].y.z); 22902 * // => 5 22903 */ 22904 function set(object, path, value) { 22905 return object == null ? object : baseSet(object, path, value); 22906 } 22907 22908 /** 22909 * This method is like `_.set` except that it accepts `customizer` which is 22910 * invoked to produce the objects of `path`. If `customizer` returns `undefined` 22911 * path creation is handled by the method instead. The `customizer` is invoked 22912 * with three arguments: (nsValue, key, nsObject). 22913 * 22914 * **Note:** This method mutates `object`. 22915 * 22916 * @static 22917 * @memberOf _ 22918 * @since 4.0.0 22919 * @category Object 22920 * @param {Object} object The object to modify. 22921 * @param {Array|string} path The path of the property to set. 22922 * @param {*} value The value to set. 22923 * @param {Function} [customizer] The function to customize assigned values. 22924 * @returns {Object} Returns `object`. 22925 * @example 22926 * 22927 * var object = {}; 22928 * 22929 * _.setWith(object, '[0][1]', 'a', Object); 22930 * // => { '0': { '1': 'a' } } 22931 */ 22932 function setWith(object, path, value, customizer) { 22933 customizer = typeof customizer == 'function' ? customizer : undefined; 22934 return object == null ? object : baseSet(object, path, value, customizer); 22935 } 22936 22937 /** 22938 * Creates an array of own enumerable string keyed-value pairs for `object` 22939 * which can be consumed by `_.fromPairs`. If `object` is a map or set, its 22940 * entries are returned. 22941 * 22942 * @static 22943 * @memberOf _ 22944 * @since 4.0.0 22945 * @alias entries 22946 * @category Object 22947 * @param {Object} object The object to query. 22948 * @returns {Array} Returns the key-value pairs. 22949 * @example 22950 * 22951 * function Foo() { 22952 * this.a = 1; 22953 * this.b = 2; 22954 * } 22955 * 22956 * Foo.prototype.c = 3; 22957 * 22958 * _.toPairs(new Foo); 22959 * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed) 22960 */ 22961 var toPairs = createToPairs(keys); 22962 22963 /** 22964 * Creates an array of own and inherited enumerable string keyed-value pairs 22965 * for `object` which can be consumed by `_.fromPairs`. If `object` is a map 22966 * or set, its entries are returned. 22967 * 22968 * @static 22969 * @memberOf _ 22970 * @since 4.0.0 22971 * @alias entriesIn 22972 * @category Object 22973 * @param {Object} object The object to query. 22974 * @returns {Array} Returns the key-value pairs. 22975 * @example 22976 * 22977 * function Foo() { 22978 * this.a = 1; 22979 * this.b = 2; 22980 * } 22981 * 22982 * Foo.prototype.c = 3; 22983 * 22984 * _.toPairsIn(new Foo); 22985 * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed) 22986 */ 22987 var toPairsIn = createToPairs(keysIn); 22988 22989 /** 22990 * An alternative to `_.reduce`; this method transforms `object` to a new 22991 * `accumulator` object which is the result of running each of its own 22992 * enumerable string keyed properties thru `iteratee`, with each invocation 22993 * potentially mutating the `accumulator` object. If `accumulator` is not 22994 * provided, a new object with the same `[[Prototype]]` will be used. The 22995 * iteratee is invoked with four arguments: (accumulator, value, key, object). 22996 * Iteratee functions may exit iteration early by explicitly returning `false`. 22997 * 22998 * @static 22999 * @memberOf _ 23000 * @since 1.3.0 23001 * @category Object 23002 * @param {Object} object The object to iterate over. 23003 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 23004 * @param {*} [accumulator] The custom accumulator value. 23005 * @returns {*} Returns the accumulated value. 23006 * @example 23007 * 23008 * _.transform([2, 3, 4], function(result, n) { 23009 * result.push(n *= n); 23010 * return n % 2 == 0; 23011 * }, []); 23012 * // => [4, 9] 23013 * 23014 * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { 23015 * (result[value] || (result[value] = [])).push(key); 23016 * }, {}); 23017 * // => { '1': ['a', 'c'], '2': ['b'] } 23018 */ 23019 function transform(object, iteratee, accumulator) { 23020 var isArr = isArray(object), 23021 isArrLike = isArr || isBuffer(object) || isTypedArray(object); 23022 23023 iteratee = getIteratee(iteratee, 4); 23024 if (accumulator == null) { 23025 var Ctor = object && object.constructor; 23026 if (isArrLike) { 23027 accumulator = isArr ? new Ctor : []; 23028 } 23029 else if (isObject(object)) { 23030 accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {}; 23031 } 23032 else { 23033 accumulator = {}; 23034 } 23035 } 23036 (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) { 23037 return iteratee(accumulator, value, index, object); 23038 }); 23039 return accumulator; 23040 } 23041 23042 /** 23043 * Removes the property at `path` of `object`. 23044 * 23045 * **Note:** This method mutates `object`. 23046 * 23047 * @static 23048 * @memberOf _ 23049 * @since 4.0.0 23050 * @category Object 23051 * @param {Object} object The object to modify. 23052 * @param {Array|string} path The path of the property to unset. 23053 * @returns {boolean} Returns `true` if the property is deleted, else `false`. 23054 * @example 23055 * 23056 * var object = { 'a': [{ 'b': { 'c': 7 } }] }; 23057 * _.unset(object, 'a[0].b.c'); 23058 * // => true 23059 * 23060 * console.log(object); 23061 * // => { 'a': [{ 'b': {} }] }; 23062 * 23063 * _.unset(object, ['a', '0', 'b', 'c']); 23064 * // => true 23065 * 23066 * console.log(object); 23067 * // => { 'a': [{ 'b': {} }] }; 23068 */ 23069 function unset(object, path) { 23070 return object == null ? true : baseUnset(object, path); 23071 } 23072 23073 /** 23074 * This method is like `_.set` except that accepts `updater` to produce the 23075 * value to set. Use `_.updateWith` to customize `path` creation. The `updater` 23076 * is invoked with one argument: (value). 23077 * 23078 * **Note:** This method mutates `object`. 23079 * 23080 * @static 23081 * @memberOf _ 23082 * @since 4.6.0 23083 * @category Object 23084 * @param {Object} object The object to modify. 23085 * @param {Array|string} path The path of the property to set. 23086 * @param {Function} updater The function to produce the updated value. 23087 * @returns {Object} Returns `object`. 23088 * @example 23089 * 23090 * var object = { 'a': [{ 'b': { 'c': 3 } }] }; 23091 * 23092 * _.update(object, 'a[0].b.c', function(n) { return n * n; }); 23093 * console.log(object.a[0].b.c); 23094 * // => 9 23095 * 23096 * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; }); 23097 * console.log(object.x[0].y.z); 23098 * // => 0 23099 */ 23100 function update(object, path, updater) { 23101 return object == null ? object : baseUpdate(object, path, castFunction(updater)); 23102 } 23103 23104 /** 23105 * This method is like `_.update` except that it accepts `customizer` which is 23106 * invoked to produce the objects of `path`. If `customizer` returns `undefined` 23107 * path creation is handled by the method instead. The `customizer` is invoked 23108 * with three arguments: (nsValue, key, nsObject). 23109 * 23110 * **Note:** This method mutates `object`. 23111 * 23112 * @static 23113 * @memberOf _ 23114 * @since 4.6.0 23115 * @category Object 23116 * @param {Object} object The object to modify. 23117 * @param {Array|string} path The path of the property to set. 23118 * @param {Function} updater The function to produce the updated value. 23119 * @param {Function} [customizer] The function to customize assigned values. 23120 * @returns {Object} Returns `object`. 23121 * @example 23122 * 23123 * var object = {}; 23124 * 23125 * _.updateWith(object, '[0][1]', _.constant('a'), Object); 23126 * // => { '0': { '1': 'a' } } 23127 */ 23128 function updateWith(object, path, updater, customizer) { 23129 customizer = typeof customizer == 'function' ? customizer : undefined; 23130 return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer); 23131 } 23132 23133 /** 23134 * Creates an array of the own enumerable string keyed property values of `object`. 23135 * 23136 * **Note:** Non-object values are coerced to objects. 23137 * 23138 * @static 23139 * @since 0.1.0 23140 * @memberOf _ 23141 * @category Object 23142 * @param {Object} object The object to query. 23143 * @returns {Array} Returns the array of property values. 23144 * @example 23145 * 23146 * function Foo() { 23147 * this.a = 1; 23148 * this.b = 2; 23149 * } 23150 * 23151 * Foo.prototype.c = 3; 23152 * 23153 * _.values(new Foo); 23154 * // => [1, 2] (iteration order is not guaranteed) 23155 * 23156 * _.values('hi'); 23157 * // => ['h', 'i'] 23158 */ 23159 function values(object) { 23160 return object == null ? [] : baseValues(object, keys(object)); 23161 } 23162 23163 /** 23164 * Creates an array of the own and inherited enumerable string keyed property 23165 * values of `object`. 23166 * 23167 * **Note:** Non-object values are coerced to objects. 23168 * 23169 * @static 23170 * @memberOf _ 23171 * @since 3.0.0 23172 * @category Object 23173 * @param {Object} object The object to query. 23174 * @returns {Array} Returns the array of property values. 23175 * @example 23176 * 23177 * function Foo() { 23178 * this.a = 1; 23179 * this.b = 2; 23180 * } 23181 * 23182 * Foo.prototype.c = 3; 23183 * 23184 * _.valuesIn(new Foo); 23185 * // => [1, 2, 3] (iteration order is not guaranteed) 23186 */ 23187 function valuesIn(object) { 23188 return object == null ? [] : baseValues(object, keysIn(object)); 23189 } 23190 23191 /*------------------------------------------------------------------------*/ 23192 23193 /** 23194 * Clamps `number` within the inclusive `lower` and `upper` bounds. 23195 * 23196 * @static 23197 * @memberOf _ 23198 * @since 4.0.0 23199 * @category Number 23200 * @param {number} number The number to clamp. 23201 * @param {number} [lower] The lower bound. 23202 * @param {number} upper The upper bound. 23203 * @returns {number} Returns the clamped number. 23204 * @example 23205 * 23206 * _.clamp(-10, -5, 5); 23207 * // => -5 23208 * 23209 * _.clamp(10, -5, 5); 23210 * // => 5 23211 */ 23212 function clamp(number, lower, upper) { 23213 if (upper === undefined) { 23214 upper = lower; 23215 lower = undefined; 23216 } 23217 if (upper !== undefined) { 23218 upper = toNumber(upper); 23219 upper = upper === upper ? upper : 0; 23220 } 23221 if (lower !== undefined) { 23222 lower = toNumber(lower); 23223 lower = lower === lower ? lower : 0; 23224 } 23225 return baseClamp(toNumber(number), lower, upper); 23226 } 23227 23228 /** 23229 * Checks if `n` is between `start` and up to, but not including, `end`. If 23230 * `end` is not specified, it's set to `start` with `start` then set to `0`. 23231 * If `start` is greater than `end` the params are swapped to support 23232 * negative ranges. 23233 * 23234 * @static 23235 * @memberOf _ 23236 * @since 3.3.0 23237 * @category Number 23238 * @param {number} number The number to check. 23239 * @param {number} [start=0] The start of the range. 23240 * @param {number} end The end of the range. 23241 * @returns {boolean} Returns `true` if `number` is in the range, else `false`. 23242 * @see _.range, _.rangeRight 23243 * @example 23244 * 23245 * _.inRange(3, 2, 4); 23246 * // => true 23247 * 23248 * _.inRange(4, 8); 23249 * // => true 23250 * 23251 * _.inRange(4, 2); 23252 * // => false 23253 * 23254 * _.inRange(2, 2); 23255 * // => false 23256 * 23257 * _.inRange(1.2, 2); 23258 * // => true 23259 * 23260 * _.inRange(5.2, 4); 23261 * // => false 23262 * 23263 * _.inRange(-3, -2, -6); 23264 * // => true 23265 */ 23266 function inRange(number, start, end) { 23267 start = toFinite(start); 23268 if (end === undefined) { 23269 end = start; 23270 start = 0; 23271 } else { 23272 end = toFinite(end); 23273 } 23274 number = toNumber(number); 23275 return baseInRange(number, start, end); 23276 } 23277 23278 /** 23279 * Produces a random number between the inclusive `lower` and `upper` bounds. 23280 * If only one argument is provided a number between `0` and the given number 23281 * is returned. If `floating` is `true`, or either `lower` or `upper` are 23282 * floats, a floating-point number is returned instead of an integer. 23283 * 23284 * **Note:** JavaScript follows the IEEE-754 standard for resolving 23285 * floating-point values which can produce unexpected results. 23286 * 23287 * @static 23288 * @memberOf _ 23289 * @since 0.7.0 23290 * @category Number 23291 * @param {number} [lower=0] The lower bound. 23292 * @param {number} [upper=1] The upper bound. 23293 * @param {boolean} [floating] Specify returning a floating-point number. 23294 * @returns {number} Returns the random number. 23295 * @example 23296 * 23297 * _.random(0, 5); 23298 * // => an integer between 0 and 5 23299 * 23300 * _.random(5); 23301 * // => also an integer between 0 and 5 23302 * 23303 * _.random(5, true); 23304 * // => a floating-point number between 0 and 5 23305 * 23306 * _.random(1.2, 5.2); 23307 * // => a floating-point number between 1.2 and 5.2 23308 */ 23309 function random(lower, upper, floating) { 23310 if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) { 23311 upper = floating = undefined; 23312 } 23313 if (floating === undefined) { 23314 if (typeof upper == 'boolean') { 23315 floating = upper; 23316 upper = undefined; 23317 } 23318 else if (typeof lower == 'boolean') { 23319 floating = lower; 23320 lower = undefined; 23321 } 23322 } 23323 if (lower === undefined && upper === undefined) { 23324 lower = 0; 23325 upper = 1; 23326 } 23327 else { 23328 lower = toFinite(lower); 23329 if (upper === undefined) { 23330 upper = lower; 23331 lower = 0; 23332 } else { 23333 upper = toFinite(upper); 23334 } 23335 } 23336 if (lower > upper) { 23337 var temp = lower; 23338 lower = upper; 23339 upper = temp; 23340 } 23341 if (floating || lower % 1 || upper % 1) { 23342 var rand = nativeRandom(); 23343 return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper); 23344 } 23345 return baseRandom(lower, upper); 23346 } 23347 23348 /*------------------------------------------------------------------------*/ 23349 23350 /** 23351 * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase). 23352 * 23353 * @static 23354 * @memberOf _ 23355 * @since 3.0.0 23356 * @category String 23357 * @param {string} [string=''] The string to convert. 23358 * @returns {string} Returns the camel cased string. 23359 * @example 23360 * 23361 * _.camelCase('Foo Bar'); 23362 * // => 'fooBar' 23363 * 23364 * _.camelCase('--foo-bar--'); 23365 * // => 'fooBar' 23366 * 23367 * _.camelCase('__FOO_BAR__'); 23368 * // => 'fooBar' 23369 */ 23370 var camelCase = createCompounder(function(result, word, index) { 23371 word = word.toLowerCase(); 23372 return result + (index ? capitalize(word) : word); 23373 }); 23374 23375 /** 23376 * Converts the first character of `string` to upper case and the remaining 23377 * to lower case. 23378 * 23379 * @static 23380 * @memberOf _ 23381 * @since 3.0.0 23382 * @category String 23383 * @param {string} [string=''] The string to capitalize. 23384 * @returns {string} Returns the capitalized string. 23385 * @example 23386 * 23387 * _.capitalize('FRED'); 23388 * // => 'Fred' 23389 */ 23390 function capitalize(string) { 23391 return upperFirst(toString(string).toLowerCase()); 23392 } 23393 23394 /** 23395 * Deburrs `string` by converting 23396 * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table) 23397 * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A) 23398 * letters to basic Latin letters and removing 23399 * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). 23400 * 23401 * @static 23402 * @memberOf _ 23403 * @since 3.0.0 23404 * @category String 23405 * @param {string} [string=''] The string to deburr. 23406 * @returns {string} Returns the deburred string. 23407 * @example 23408 * 23409 * _.deburr('déjàvu'); 23410 * // => 'deja vu' 23411 */ 23412 function deburr(string) { 23413 string = toString(string); 23414 return string && string.replace(reLatin, deburrLetter).replace(reComboMark, ''); 23415 } 23416 23417 /** 23418 * Checks if `string` ends with the given target string. 23419 * 23420 * @static 23421 * @memberOf _ 23422 * @since 3.0.0 23423 * @category String 23424 * @param {string} [string=''] The string to inspect. 23425 * @param {string} [target] The string to search for. 23426 * @param {number} [position=string.length] The position to search up to. 23427 * @returns {boolean} Returns `true` if `string` ends with `target`, 23428 * else `false`. 23429 * @example 23430 * 23431 * _.endsWith('abc', 'c'); 23432 * // => true 23433 * 23434 * _.endsWith('abc', 'b'); 23435 * // => false 23436 * 23437 * _.endsWith('abc', 'b', 2); 23438 * // => true 23439 */ 23440 function endsWith(string, target, position) { 23441 string = toString(string); 23442 target = baseToString(target); 23443 23444 var length = string.length; 23445 position = position === undefined 23446 ? length 23447 : baseClamp(toInteger(position), 0, length); 23448 23449 var end = position; 23450 position -= target.length; 23451 return position >= 0 && string.slice(position, end) == target; 23452 } 23453 23454 /** 23455 * Converts the characters "&", "<", ">", '"', and "'" in `string` to their 23456 * corresponding HTML entities. 23457 * 23458 * **Note:** No other characters are escaped. To escape additional 23459 * characters use a third-party library like [_he_](https://mths.be/he). 23460 * 23461 * Though the ">" character is escaped for symmetry, characters like 23462 * ">" and "/" don't need escaping in HTML and have no special meaning 23463 * unless they're part of a tag or unquoted attribute value. See 23464 * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands) 23465 * (under "semi-related fun fact") for more details. 23466 * 23467 * When working with HTML you should always 23468 * [quote attribute values](http://wonko.com/post/html-escaping) to reduce 23469 * XSS vectors. 23470 * 23471 * @static 23472 * @since 0.1.0 23473 * @memberOf _ 23474 * @category String 23475 * @param {string} [string=''] The string to escape. 23476 * @returns {string} Returns the escaped string. 23477 * @example 23478 * 23479 * _.escape('fred, barney, & pebbles'); 23480 * // => 'fred, barney, & pebbles' 23481 */ 23482 function escape(string) { 23483 string = toString(string); 23484 return (string && reHasUnescapedHtml.test(string)) 23485 ? string.replace(reUnescapedHtml, escapeHtmlChar) 23486 : string; 23487 } 23488 23489 /** 23490 * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+", 23491 * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`. 23492 * 23493 * @static 23494 * @memberOf _ 23495 * @since 3.0.0 23496 * @category String 23497 * @param {string} [string=''] The string to escape. 23498 * @returns {string} Returns the escaped string. 23499 * @example 23500 * 23501 * _.escapeRegExp('[lodash](https://lodash.com/)'); 23502 * // => '\[lodash\]\(https://lodash\.com/\)' 23503 */ 23504 function escapeRegExp(string) { 23505 string = toString(string); 23506 return (string && reHasRegExpChar.test(string)) 23507 ? string.replace(reRegExpChar, '\\$&') 23508 : string; 23509 } 23510 23511 /** 23512 * Converts `string` to 23513 * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles). 23514 * 23515 * @static 23516 * @memberOf _ 23517 * @since 3.0.0 23518 * @category String 23519 * @param {string} [string=''] The string to convert. 23520 * @returns {string} Returns the kebab cased string. 23521 * @example 23522 * 23523 * _.kebabCase('Foo Bar'); 23524 * // => 'foo-bar' 23525 * 23526 * _.kebabCase('fooBar'); 23527 * // => 'foo-bar' 23528 * 23529 * _.kebabCase('__FOO_BAR__'); 23530 * // => 'foo-bar' 23531 */ 23532 var kebabCase = createCompounder(function(result, word, index) { 23533 return result + (index ? '-' : '') + word.toLowerCase(); 23534 }); 23535 23536 /** 23537 * Converts `string`, as space separated words, to lower case. 23538 * 23539 * @static 23540 * @memberOf _ 23541 * @since 4.0.0 23542 * @category String 23543 * @param {string} [string=''] The string to convert. 23544 * @returns {string} Returns the lower cased string. 23545 * @example 23546 * 23547 * _.lowerCase('--Foo-Bar--'); 23548 * // => 'foo bar' 23549 * 23550 * _.lowerCase('fooBar'); 23551 * // => 'foo bar' 23552 * 23553 * _.lowerCase('__FOO_BAR__'); 23554 * // => 'foo bar' 23555 */ 23556 var lowerCase = createCompounder(function(result, word, index) { 23557 return result + (index ? ' ' : '') + word.toLowerCase(); 23558 }); 23559 23560 /** 23561 * Converts the first character of `string` to lower case. 23562 * 23563 * @static 23564 * @memberOf _ 23565 * @since 4.0.0 23566 * @category String 23567 * @param {string} [string=''] The string to convert. 23568 * @returns {string} Returns the converted string. 23569 * @example 23570 * 23571 * _.lowerFirst('Fred'); 23572 * // => 'fred' 23573 * 23574 * _.lowerFirst('FRED'); 23575 * // => 'fRED' 23576 */ 23577 var lowerFirst = createCaseFirst('toLowerCase'); 23578 23579 /** 23580 * Pads `string` on the left and right sides if it's shorter than `length`. 23581 * Padding characters are truncated if they can't be evenly divided by `length`. 23582 * 23583 * @static 23584 * @memberOf _ 23585 * @since 3.0.0 23586 * @category String 23587 * @param {string} [string=''] The string to pad. 23588 * @param {number} [length=0] The padding length. 23589 * @param {string} [chars=' '] The string used as padding. 23590 * @returns {string} Returns the padded string. 23591 * @example 23592 * 23593 * _.pad('abc', 8); 23594 * // => ' abc ' 23595 * 23596 * _.pad('abc', 8, '_-'); 23597 * // => '_-abc_-_' 23598 * 23599 * _.pad('abc', 3); 23600 * // => 'abc' 23601 */ 23602 function pad(string, length, chars) { 23603 string = toString(string); 23604 length = toInteger(length); 23605 23606 var strLength = length ? stringSize(string) : 0; 23607 if (!length || strLength >= length) { 23608 return string; 23609 } 23610 var mid = (length - strLength) / 2; 23611 return ( 23612 createPadding(nativeFloor(mid), chars) + 23613 string + 23614 createPadding(nativeCeil(mid), chars) 23615 ); 23616 } 23617 23618 /** 23619 * Pads `string` on the right side if it's shorter than `length`. Padding 23620 * characters are truncated if they exceed `length`. 23621 * 23622 * @static 23623 * @memberOf _ 23624 * @since 4.0.0 23625 * @category String 23626 * @param {string} [string=''] The string to pad. 23627 * @param {number} [length=0] The padding length. 23628 * @param {string} [chars=' '] The string used as padding. 23629 * @returns {string} Returns the padded string. 23630 * @example 23631 * 23632 * _.padEnd('abc', 6); 23633 * // => 'abc ' 23634 * 23635 * _.padEnd('abc', 6, '_-'); 23636 * // => 'abc_-_' 23637 * 23638 * _.padEnd('abc', 3); 23639 * // => 'abc' 23640 */ 23641 function padEnd(string, length, chars) { 23642 string = toString(string); 23643 length = toInteger(length); 23644 23645 var strLength = length ? stringSize(string) : 0; 23646 return (length && strLength < length) 23647 ? (string + createPadding(length - strLength, chars)) 23648 : string; 23649 } 23650 23651 /** 23652 * Pads `string` on the left side if it's shorter than `length`. Padding 23653 * characters are truncated if they exceed `length`. 23654 * 23655 * @static 23656 * @memberOf _ 23657 * @since 4.0.0 23658 * @category String 23659 * @param {string} [string=''] The string to pad. 23660 * @param {number} [length=0] The padding length. 23661 * @param {string} [chars=' '] The string used as padding. 23662 * @returns {string} Returns the padded string. 23663 * @example 23664 * 23665 * _.padStart('abc', 6); 23666 * // => ' abc' 23667 * 23668 * _.padStart('abc', 6, '_-'); 23669 * // => '_-_abc' 23670 * 23671 * _.padStart('abc', 3); 23672 * // => 'abc' 23673 */ 23674 function padStart(string, length, chars) { 23675 string = toString(string); 23676 length = toInteger(length); 23677 23678 var strLength = length ? stringSize(string) : 0; 23679 return (length && strLength < length) 23680 ? (createPadding(length - strLength, chars) + string) 23681 : string; 23682 } 23683 23684 /** 23685 * Converts `string` to an integer of the specified radix. If `radix` is 23686 * `undefined` or `0`, a `radix` of `10` is used unless `value` is a 23687 * hexadecimal, in which case a `radix` of `16` is used. 23688 * 23689 * **Note:** This method aligns with the 23690 * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`. 23691 * 23692 * @static 23693 * @memberOf _ 23694 * @since 1.1.0 23695 * @category String 23696 * @param {string} string The string to convert. 23697 * @param {number} [radix=10] The radix to interpret `value` by. 23698 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 23699 * @returns {number} Returns the converted integer. 23700 * @example 23701 * 23702 * _.parseInt('08'); 23703 * // => 8 23704 * 23705 * _.map(['6', '08', '10'], _.parseInt); 23706 * // => [6, 8, 10] 23707 */ 23708 function parseInt(string, radix, guard) { 23709 if (guard || radix == null) { 23710 radix = 0; 23711 } else if (radix) { 23712 radix = +radix; 23713 } 23714 return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0); 23715 } 23716 23717 /** 23718 * Repeats the given string `n` times. 23719 * 23720 * @static 23721 * @memberOf _ 23722 * @since 3.0.0 23723 * @category String 23724 * @param {string} [string=''] The string to repeat. 23725 * @param {number} [n=1] The number of times to repeat the string. 23726 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 23727 * @returns {string} Returns the repeated string. 23728 * @example 23729 * 23730 * _.repeat('*', 3); 23731 * // => '***' 23732 * 23733 * _.repeat('abc', 2); 23734 * // => 'abcabc' 23735 * 23736 * _.repeat('abc', 0); 23737 * // => '' 23738 */ 23739 function repeat(string, n, guard) { 23740 if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) { 23741 n = 1; 23742 } else { 23743 n = toInteger(n); 23744 } 23745 return baseRepeat(toString(string), n); 23746 } 23747 23748 /** 23749 * Replaces matches for `pattern` in `string` with `replacement`. 23750 * 23751 * **Note:** This method is based on 23752 * [`String#replace`](https://mdn.io/String/replace). 23753 * 23754 * @static 23755 * @memberOf _ 23756 * @since 4.0.0 23757 * @category String 23758 * @param {string} [string=''] The string to modify. 23759 * @param {RegExp|string} pattern The pattern to replace. 23760 * @param {Function|string} replacement The match replacement. 23761 * @returns {string} Returns the modified string. 23762 * @example 23763 * 23764 * _.replace('Hi Fred', 'Fred', 'Barney'); 23765 * // => 'Hi Barney' 23766 */ 23767 function replace() { 23768 var args = arguments, 23769 string = toString(args[0]); 23770 23771 return args.length < 3 ? string : string.replace(args[1], args[2]); 23772 } 23773 23774 /** 23775 * Converts `string` to 23776 * [snake case](https://en.wikipedia.org/wiki/Snake_case). 23777 * 23778 * @static 23779 * @memberOf _ 23780 * @since 3.0.0 23781 * @category String 23782 * @param {string} [string=''] The string to convert. 23783 * @returns {string} Returns the snake cased string. 23784 * @example 23785 * 23786 * _.snakeCase('Foo Bar'); 23787 * // => 'foo_bar' 23788 * 23789 * _.snakeCase('fooBar'); 23790 * // => 'foo_bar' 23791 * 23792 * _.snakeCase('--FOO-BAR--'); 23793 * // => 'foo_bar' 23794 */ 23795 var snakeCase = createCompounder(function(result, word, index) { 23796 return result + (index ? '_' : '') + word.toLowerCase(); 23797 }); 23798 23799 /** 23800 * Splits `string` by `separator`. 23801 * 23802 * **Note:** This method is based on 23803 * [`String#split`](https://mdn.io/String/split). 23804 * 23805 * @static 23806 * @memberOf _ 23807 * @since 4.0.0 23808 * @category String 23809 * @param {string} [string=''] The string to split. 23810 * @param {RegExp|string} separator The separator pattern to split by. 23811 * @param {number} [limit] The length to truncate results to. 23812 * @returns {Array} Returns the string segments. 23813 * @example 23814 * 23815 * _.split('a-b-c', '-', 2); 23816 * // => ['a', 'b'] 23817 */ 23818 function split(string, separator, limit) { 23819 if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) { 23820 separator = limit = undefined; 23821 } 23822 limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0; 23823 if (!limit) { 23824 return []; 23825 } 23826 string = toString(string); 23827 if (string && ( 23828 typeof separator == 'string' || 23829 (separator != null && !isRegExp(separator)) 23830 )) { 23831 separator = baseToString(separator); 23832 if (!separator && hasUnicode(string)) { 23833 return castSlice(stringToArray(string), 0, limit); 23834 } 23835 } 23836 return string.split(separator, limit); 23837 } 23838 23839 /** 23840 * Converts `string` to 23841 * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage). 23842 * 23843 * @static 23844 * @memberOf _ 23845 * @since 3.1.0 23846 * @category String 23847 * @param {string} [string=''] The string to convert. 23848 * @returns {string} Returns the start cased string. 23849 * @example 23850 * 23851 * _.startCase('--foo-bar--'); 23852 * // => 'Foo Bar' 23853 * 23854 * _.startCase('fooBar'); 23855 * // => 'Foo Bar' 23856 * 23857 * _.startCase('__FOO_BAR__'); 23858 * // => 'FOO BAR' 23859 */ 23860 var startCase = createCompounder(function(result, word, index) { 23861 return result + (index ? ' ' : '') + upperFirst(word); 23862 }); 23863 23864 /** 23865 * Checks if `string` starts with the given target string. 23866 * 23867 * @static 23868 * @memberOf _ 23869 * @since 3.0.0 23870 * @category String 23871 * @param {string} [string=''] The string to inspect. 23872 * @param {string} [target] The string to search for. 23873 * @param {number} [position=0] The position to search from. 23874 * @returns {boolean} Returns `true` if `string` starts with `target`, 23875 * else `false`. 23876 * @example 23877 * 23878 * _.startsWith('abc', 'a'); 23879 * // => true 23880 * 23881 * _.startsWith('abc', 'b'); 23882 * // => false 23883 * 23884 * _.startsWith('abc', 'b', 1); 23885 * // => true 23886 */ 23887 function startsWith(string, target, position) { 23888 string = toString(string); 23889 position = position == null 23890 ? 0 23891 : baseClamp(toInteger(position), 0, string.length); 23892 23893 target = baseToString(target); 23894 return string.slice(position, position + target.length) == target; 23895 } 23896 23897 /** 23898 * Creates a compiled template function that can interpolate data properties 23899 * in "interpolate" delimiters, HTML-escape interpolated data properties in 23900 * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data 23901 * properties may be accessed as free variables in the template. If a setting 23902 * object is given, it takes precedence over `_.templateSettings` values. 23903 * 23904 * **Note:** In the development build `_.template` utilizes 23905 * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) 23906 * for easier debugging. 23907 * 23908 * For more information on precompiling templates see 23909 * [lodash's custom builds documentation](https://lodash.com/custom-builds). 23910 * 23911 * For more information on Chrome extension sandboxes see 23912 * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval). 23913 * 23914 * @static 23915 * @since 0.1.0 23916 * @memberOf _ 23917 * @category String 23918 * @param {string} [string=''] The template string. 23919 * @param {Object} [options={}] The options object. 23920 * @param {RegExp} [options.escape=_.templateSettings.escape] 23921 * The HTML "escape" delimiter. 23922 * @param {RegExp} [options.evaluate=_.templateSettings.evaluate] 23923 * The "evaluate" delimiter. 23924 * @param {Object} [options.imports=_.templateSettings.imports] 23925 * An object to import into the template as free variables. 23926 * @param {RegExp} [options.interpolate=_.templateSettings.interpolate] 23927 * The "interpolate" delimiter. 23928 * @param {string} [options.sourceURL='lodash.templateSources[n]'] 23929 * The sourceURL of the compiled template. 23930 * @param {string} [options.variable='obj'] 23931 * The data object variable name. 23932 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 23933 * @returns {Function} Returns the compiled template function. 23934 * @example 23935 * 23936 * // Use the "interpolate" delimiter to create a compiled template. 23937 * var compiled = _.template('hello <%= user %>!'); 23938 * compiled({ 'user': 'fred' }); 23939 * // => 'hello fred!' 23940 * 23941 * // Use the HTML "escape" delimiter to escape data property values. 23942 * var compiled = _.template('<b><%- value %></b>'); 23943 * compiled({ 'value': '<script>' }); 23944 * // => '<b><script></b>' 23945 * 23946 * // Use the "evaluate" delimiter to execute JavaScript and generate HTML. 23947 * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>'); 23948 * compiled({ 'users': ['fred', 'barney'] }); 23949 * // => '<li>fred</li><li>barney</li>' 23950 * 23951 * // Use the internal `print` function in "evaluate" delimiters. 23952 * var compiled = _.template('<% print("hello " + user); %>!'); 23953 * compiled({ 'user': 'barney' }); 23954 * // => 'hello barney!' 23955 * 23956 * // Use the ES template literal delimiter as an "interpolate" delimiter. 23957 * // Disable support by replacing the "interpolate" delimiter. 23958 * var compiled = _.template('hello ${ user }!'); 23959 * compiled({ 'user': 'pebbles' }); 23960 * // => 'hello pebbles!' 23961 * 23962 * // Use backslashes to treat delimiters as plain text. 23963 * var compiled = _.template('<%= "\\<%- value %\\>" %>'); 23964 * compiled({ 'value': 'ignored' }); 23965 * // => '<%- value %>' 23966 * 23967 * // Use the `imports` option to import `jQuery` as `jq`. 23968 * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>'; 23969 * var compiled = _.template(text, { 'imports': { 'jq': jQuery } }); 23970 * compiled({ 'users': ['fred', 'barney'] }); 23971 * // => '<li>fred</li><li>barney</li>' 23972 * 23973 * // Use the `sourceURL` option to specify a custom sourceURL for the template. 23974 * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' }); 23975 * compiled(data); 23976 * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector. 23977 * 23978 * // Use the `variable` option to ensure a with-statement isn't used in the compiled template. 23979 * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' }); 23980 * compiled.source; 23981 * // => function(data) { 23982 * // var __t, __p = ''; 23983 * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!'; 23984 * // return __p; 23985 * // } 23986 * 23987 * // Use custom template delimiters. 23988 * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g; 23989 * var compiled = _.template('hello {{ user }}!'); 23990 * compiled({ 'user': 'mustache' }); 23991 * // => 'hello mustache!' 23992 * 23993 * // Use the `source` property to inline compiled templates for meaningful 23994 * // line numbers in error messages and stack traces. 23995 * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\ 23996 * var JST = {\ 23997 * "main": ' + _.template(mainText).source + '\ 23998 * };\ 23999 * '); 24000 */ 24001 function template(string, options, guard) { 24002 // Based on John Resig's `tmpl` implementation 24003 // (http://ejohn.org/blog/javascript-micro-templating/) 24004 // and Laura Doktorova's doT.js (https://github.com/olado/doT). 24005 var settings = lodash.templateSettings; 24006 24007 if (guard && isIterateeCall(string, options, guard)) { 24008 options = undefined; 24009 } 24010 string = toString(string); 24011 options = assignInWith({}, options, settings, customDefaultsAssignIn); 24012 24013 var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn), 24014 importsKeys = keys(imports), 24015 importsValues = baseValues(imports, importsKeys); 24016 24017 var isEscaping, 24018 isEvaluating, 24019 index = 0, 24020 interpolate = options.interpolate || reNoMatch, 24021 source = "__p += '"; 24022 24023 // Compile the regexp to match each delimiter. 24024 var reDelimiters = RegExp( 24025 (options.escape || reNoMatch).source + '|' + 24026 interpolate.source + '|' + 24027 (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' + 24028 (options.evaluate || reNoMatch).source + '|$' 24029 , 'g'); 24030 24031 // Use a sourceURL for easier debugging. 24032 // The sourceURL gets injected into the source that's eval-ed, so be careful 24033 // to normalize all kinds of whitespace, so e.g. newlines (and unicode versions of it) can't sneak in 24034 // and escape the comment, thus injecting code that gets evaled. 24035 var sourceURL = '//# sourceURL=' + 24036 (hasOwnProperty.call(options, 'sourceURL') 24037 ? (options.sourceURL + '').replace(/\s/g, ' ') 24038 : ('lodash.templateSources[' + (++templateCounter) + ']') 24039 ) + '\n'; 24040 24041 string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) { 24042 interpolateValue || (interpolateValue = esTemplateValue); 24043 24044 // Escape characters that can't be included in string literals. 24045 source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar); 24046 24047 // Replace delimiters with snippets. 24048 if (escapeValue) { 24049 isEscaping = true; 24050 source += "' +\n__e(" + escapeValue + ") +\n'"; 24051 } 24052 if (evaluateValue) { 24053 isEvaluating = true; 24054 source += "';\n" + evaluateValue + ";\n__p += '"; 24055 } 24056 if (interpolateValue) { 24057 source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'"; 24058 } 24059 index = offset + match.length; 24060 24061 // The JS engine embedded in Adobe products needs `match` returned in 24062 // order to produce the correct `offset` value. 24063 return match; 24064 }); 24065 24066 source += "';\n"; 24067 24068 // If `variable` is not specified wrap a with-statement around the generated 24069 // code to add the data object to the top of the scope chain. 24070 var variable = hasOwnProperty.call(options, 'variable') && options.variable; 24071 if (!variable) { 24072 source = 'with (obj) {\n' + source + '\n}\n'; 24073 } 24074 // Throw an error if a forbidden character was found in `variable`, to prevent 24075 // potential command injection attacks. 24076 else if (reForbiddenIdentifierChars.test(variable)) { 24077 throw new Error(INVALID_TEMPL_VAR_ERROR_TEXT); 24078 } 24079 24080 // Cleanup code by stripping empty strings. 24081 source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source) 24082 .replace(reEmptyStringMiddle, '$1') 24083 .replace(reEmptyStringTrailing, '$1;'); 24084 24085 // Frame code as the function body. 24086 source = 'function(' + (variable || 'obj') + ') {\n' + 24087 (variable 24088 ? '' 24089 : 'obj || (obj = {});\n' 24090 ) + 24091 "var __t, __p = ''" + 24092 (isEscaping 24093 ? ', __e = _.escape' 24094 : '' 24095 ) + 24096 (isEvaluating 24097 ? ', __j = Array.prototype.join;\n' + 24098 "function print() { __p += __j.call(arguments, '') }\n" 24099 : ';\n' 24100 ) + 24101 source + 24102 'return __p\n}'; 24103 24104 var result = attempt(function() { 24105 return Function(importsKeys, sourceURL + 'return ' + source) 24106 .apply(undefined, importsValues); 24107 }); 24108 24109 // Provide the compiled function's source by its `toString` method or 24110 // the `source` property as a convenience for inlining compiled templates. 24111 result.source = source; 24112 if (isError(result)) { 24113 throw result; 24114 } 24115 return result; 24116 } 24117 24118 /** 24119 * Converts `string`, as a whole, to lower case just like 24120 * [String#toLowerCase](https://mdn.io/toLowerCase). 24121 * 24122 * @static 24123 * @memberOf _ 24124 * @since 4.0.0 24125 * @category String 24126 * @param {string} [string=''] The string to convert. 24127 * @returns {string} Returns the lower cased string. 24128 * @example 24129 * 24130 * _.toLower('--Foo-Bar--'); 24131 * // => '--foo-bar--' 24132 * 24133 * _.toLower('fooBar'); 24134 * // => 'foobar' 24135 * 24136 * _.toLower('__FOO_BAR__'); 24137 * // => '__foo_bar__' 24138 */ 24139 function toLower(value) { 24140 return toString(value).toLowerCase(); 24141 } 24142 24143 /** 24144 * Converts `string`, as a whole, to upper case just like 24145 * [String#toUpperCase](https://mdn.io/toUpperCase). 24146 * 24147 * @static 24148 * @memberOf _ 24149 * @since 4.0.0 24150 * @category String 24151 * @param {string} [string=''] The string to convert. 24152 * @returns {string} Returns the upper cased string. 24153 * @example 24154 * 24155 * _.toUpper('--foo-bar--'); 24156 * // => '--FOO-BAR--' 24157 * 24158 * _.toUpper('fooBar'); 24159 * // => 'FOOBAR' 24160 * 24161 * _.toUpper('__foo_bar__'); 24162 * // => '__FOO_BAR__' 24163 */ 24164 function toUpper(value) { 24165 return toString(value).toUpperCase(); 24166 } 24167 24168 /** 24169 * Removes leading and trailing whitespace or specified characters from `string`. 24170 * 24171 * @static 24172 * @memberOf _ 24173 * @since 3.0.0 24174 * @category String 24175 * @param {string} [string=''] The string to trim. 24176 * @param {string} [chars=whitespace] The characters to trim. 24177 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 24178 * @returns {string} Returns the trimmed string. 24179 * @example 24180 * 24181 * _.trim(' abc '); 24182 * // => 'abc' 24183 * 24184 * _.trim('-_-abc-_-', '_-'); 24185 * // => 'abc' 24186 * 24187 * _.map([' foo ', ' bar '], _.trim); 24188 * // => ['foo', 'bar'] 24189 */ 24190 function trim(string, chars, guard) { 24191 string = toString(string); 24192 if (string && (guard || chars === undefined)) { 24193 return baseTrim(string); 24194 } 24195 if (!string || !(chars = baseToString(chars))) { 24196 return string; 24197 } 24198 var strSymbols = stringToArray(string), 24199 chrSymbols = stringToArray(chars), 24200 start = charsStartIndex(strSymbols, chrSymbols), 24201 end = charsEndIndex(strSymbols, chrSymbols) + 1; 24202 24203 return castSlice(strSymbols, start, end).join(''); 24204 } 24205 24206 /** 24207 * Removes trailing whitespace or specified characters from `string`. 24208 * 24209 * @static 24210 * @memberOf _ 24211 * @since 4.0.0 24212 * @category String 24213 * @param {string} [string=''] The string to trim. 24214 * @param {string} [chars=whitespace] The characters to trim. 24215 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 24216 * @returns {string} Returns the trimmed string. 24217 * @example 24218 * 24219 * _.trimEnd(' abc '); 24220 * // => ' abc' 24221 * 24222 * _.trimEnd('-_-abc-_-', '_-'); 24223 * // => '-_-abc' 24224 */ 24225 function trimEnd(string, chars, guard) { 24226 string = toString(string); 24227 if (string && (guard || chars === undefined)) { 24228 return string.slice(0, trimmedEndIndex(string) + 1); 24229 } 24230 if (!string || !(chars = baseToString(chars))) { 24231 return string; 24232 } 24233 var strSymbols = stringToArray(string), 24234 end = charsEndIndex(strSymbols, stringToArray(chars)) + 1; 24235 24236 return castSlice(strSymbols, 0, end).join(''); 24237 } 24238 24239 /** 24240 * Removes leading whitespace or specified characters from `string`. 24241 * 24242 * @static 24243 * @memberOf _ 24244 * @since 4.0.0 24245 * @category String 24246 * @param {string} [string=''] The string to trim. 24247 * @param {string} [chars=whitespace] The characters to trim. 24248 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 24249 * @returns {string} Returns the trimmed string. 24250 * @example 24251 * 24252 * _.trimStart(' abc '); 24253 * // => 'abc ' 24254 * 24255 * _.trimStart('-_-abc-_-', '_-'); 24256 * // => 'abc-_-' 24257 */ 24258 function trimStart(string, chars, guard) { 24259 string = toString(string); 24260 if (string && (guard || chars === undefined)) { 24261 return string.replace(reTrimStart, ''); 24262 } 24263 if (!string || !(chars = baseToString(chars))) { 24264 return string; 24265 } 24266 var strSymbols = stringToArray(string), 24267 start = charsStartIndex(strSymbols, stringToArray(chars)); 24268 24269 return castSlice(strSymbols, start).join(''); 24270 } 24271 24272 /** 24273 * Truncates `string` if it's longer than the given maximum string length. 24274 * The last characters of the truncated string are replaced with the omission 24275 * string which defaults to "...". 24276 * 24277 * @static 24278 * @memberOf _ 24279 * @since 4.0.0 24280 * @category String 24281 * @param {string} [string=''] The string to truncate. 24282 * @param {Object} [options={}] The options object. 24283 * @param {number} [options.length=30] The maximum string length. 24284 * @param {string} [options.omission='...'] The string to indicate text is omitted. 24285 * @param {RegExp|string} [options.separator] The separator pattern to truncate to. 24286 * @returns {string} Returns the truncated string. 24287 * @example 24288 * 24289 * _.truncate('hi-diddly-ho there, neighborino'); 24290 * // => 'hi-diddly-ho there, neighbo...' 24291 * 24292 * _.truncate('hi-diddly-ho there, neighborino', { 24293 * 'length': 24, 24294 * 'separator': ' ' 24295 * }); 24296 * // => 'hi-diddly-ho there,...' 24297 * 24298 * _.truncate('hi-diddly-ho there, neighborino', { 24299 * 'length': 24, 24300 * 'separator': /,? +/ 24301 * }); 24302 * // => 'hi-diddly-ho there...' 24303 * 24304 * _.truncate('hi-diddly-ho there, neighborino', { 24305 * 'omission': ' [...]' 24306 * }); 24307 * // => 'hi-diddly-ho there, neig [...]' 24308 */ 24309 function truncate(string, options) { 24310 var length = DEFAULT_TRUNC_LENGTH, 24311 omission = DEFAULT_TRUNC_OMISSION; 24312 24313 if (isObject(options)) { 24314 var separator = 'separator' in options ? options.separator : separator; 24315 length = 'length' in options ? toInteger(options.length) : length; 24316 omission = 'omission' in options ? baseToString(options.omission) : omission; 24317 } 24318 string = toString(string); 24319 24320 var strLength = string.length; 24321 if (hasUnicode(string)) { 24322 var strSymbols = stringToArray(string); 24323 strLength = strSymbols.length; 24324 } 24325 if (length >= strLength) { 24326 return string; 24327 } 24328 var end = length - stringSize(omission); 24329 if (end < 1) { 24330 return omission; 24331 } 24332 var result = strSymbols 24333 ? castSlice(strSymbols, 0, end).join('') 24334 : string.slice(0, end); 24335 24336 if (separator === undefined) { 24337 return result + omission; 24338 } 24339 if (strSymbols) { 24340 end += (result.length - end); 24341 } 24342 if (isRegExp(separator)) { 24343 if (string.slice(end).search(separator)) { 24344 var match, 24345 substring = result; 24346 24347 if (!separator.global) { 24348 separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g'); 24349 } 24350 separator.lastIndex = 0; 24351 while ((match = separator.exec(substring))) { 24352 var newEnd = match.index; 24353 } 24354 result = result.slice(0, newEnd === undefined ? end : newEnd); 24355 } 24356 } else if (string.indexOf(baseToString(separator), end) != end) { 24357 var index = result.lastIndexOf(separator); 24358 if (index > -1) { 24359 result = result.slice(0, index); 24360 } 24361 } 24362 return result + omission; 24363 } 24364 24365 /** 24366 * The inverse of `_.escape`; this method converts the HTML entities 24367 * `&`, `<`, `>`, `"`, and `'` in `string` to 24368 * their corresponding characters. 24369 * 24370 * **Note:** No other HTML entities are unescaped. To unescape additional 24371 * HTML entities use a third-party library like [_he_](https://mths.be/he). 24372 * 24373 * @static 24374 * @memberOf _ 24375 * @since 0.6.0 24376 * @category String 24377 * @param {string} [string=''] The string to unescape. 24378 * @returns {string} Returns the unescaped string. 24379 * @example 24380 * 24381 * _.unescape('fred, barney, & pebbles'); 24382 * // => 'fred, barney, & pebbles' 24383 */ 24384 function unescape(string) { 24385 string = toString(string); 24386 return (string && reHasEscapedHtml.test(string)) 24387 ? string.replace(reEscapedHtml, unescapeHtmlChar) 24388 : string; 24389 } 24390 24391 /** 24392 * Converts `string`, as space separated words, to upper case. 24393 * 24394 * @static 24395 * @memberOf _ 24396 * @since 4.0.0 24397 * @category String 24398 * @param {string} [string=''] The string to convert. 24399 * @returns {string} Returns the upper cased string. 24400 * @example 24401 * 24402 * _.upperCase('--foo-bar'); 24403 * // => 'FOO BAR' 24404 * 24405 * _.upperCase('fooBar'); 24406 * // => 'FOO BAR' 24407 * 24408 * _.upperCase('__foo_bar__'); 24409 * // => 'FOO BAR' 24410 */ 24411 var upperCase = createCompounder(function(result, word, index) { 24412 return result + (index ? ' ' : '') + word.toUpperCase(); 24413 }); 24414 24415 /** 24416 * Converts the first character of `string` to upper case. 24417 * 24418 * @static 24419 * @memberOf _ 24420 * @since 4.0.0 24421 * @category String 24422 * @param {string} [string=''] The string to convert. 24423 * @returns {string} Returns the converted string. 24424 * @example 24425 * 24426 * _.upperFirst('fred'); 24427 * // => 'Fred' 24428 * 24429 * _.upperFirst('FRED'); 24430 * // => 'FRED' 24431 */ 24432 var upperFirst = createCaseFirst('toUpperCase'); 24433 24434 /** 24435 * Splits `string` into an array of its words. 24436 * 24437 * @static 24438 * @memberOf _ 24439 * @since 3.0.0 24440 * @category String 24441 * @param {string} [string=''] The string to inspect. 24442 * @param {RegExp|string} [pattern] The pattern to match words. 24443 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 24444 * @returns {Array} Returns the words of `string`. 24445 * @example 24446 * 24447 * _.words('fred, barney, & pebbles'); 24448 * // => ['fred', 'barney', 'pebbles'] 24449 * 24450 * _.words('fred, barney, & pebbles', /[^, ]+/g); 24451 * // => ['fred', 'barney', '&', 'pebbles'] 24452 */ 24453 function words(string, pattern, guard) { 24454 string = toString(string); 24455 pattern = guard ? undefined : pattern; 24456 24457 if (pattern === undefined) { 24458 return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string); 24459 } 24460 return string.match(pattern) || []; 24461 } 24462 24463 /*------------------------------------------------------------------------*/ 24464 24465 /** 24466 * Attempts to invoke `func`, returning either the result or the caught error 24467 * object. Any additional arguments are provided to `func` when it's invoked. 24468 * 24469 * @static 24470 * @memberOf _ 24471 * @since 3.0.0 24472 * @category Util 24473 * @param {Function} func The function to attempt. 24474 * @param {...*} [args] The arguments to invoke `func` with. 24475 * @returns {*} Returns the `func` result or error object. 24476 * @example 24477 * 24478 * // Avoid throwing errors for invalid selectors. 24479 * var elements = _.attempt(function(selector) { 24480 * return document.querySelectorAll(selector); 24481 * }, '>_>'); 24482 * 24483 * if (_.isError(elements)) { 24484 * elements = []; 24485 * } 24486 */ 24487 var attempt = baseRest(function(func, args) { 24488 try { 24489 return apply(func, undefined, args); 24490 } catch (e) { 24491 return isError(e) ? e : new Error(e); 24492 } 24493 }); 24494 24495 /** 24496 * Binds methods of an object to the object itself, overwriting the existing 24497 * method. 24498 * 24499 * **Note:** This method doesn't set the "length" property of bound functions. 24500 * 24501 * @static 24502 * @since 0.1.0 24503 * @memberOf _ 24504 * @category Util 24505 * @param {Object} object The object to bind and assign the bound methods to. 24506 * @param {...(string|string[])} methodNames The object method names to bind. 24507 * @returns {Object} Returns `object`. 24508 * @example 24509 * 24510 * var view = { 24511 * 'label': 'docs', 24512 * 'click': function() { 24513 * console.log('clicked ' + this.label); 24514 * } 24515 * }; 24516 * 24517 * _.bindAll(view, ['click']); 24518 * jQuery(element).on('click', view.click); 24519 * // => Logs 'clicked docs' when clicked. 24520 */ 24521 var bindAll = flatRest(function(object, methodNames) { 24522 arrayEach(methodNames, function(key) { 24523 key = toKey(key); 24524 baseAssignValue(object, key, bind(object[key], object)); 24525 }); 24526 return object; 24527 }); 24528 24529 /** 24530 * Creates a function that iterates over `pairs` and invokes the corresponding 24531 * function of the first predicate to return truthy. The predicate-function 24532 * pairs are invoked with the `this` binding and arguments of the created 24533 * function. 24534 * 24535 * @static 24536 * @memberOf _ 24537 * @since 4.0.0 24538 * @category Util 24539 * @param {Array} pairs The predicate-function pairs. 24540 * @returns {Function} Returns the new composite function. 24541 * @example 24542 * 24543 * var func = _.cond([ 24544 * [_.matches({ 'a': 1 }), _.constant('matches A')], 24545 * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')], 24546 * [_.stubTrue, _.constant('no match')] 24547 * ]); 24548 * 24549 * func({ 'a': 1, 'b': 2 }); 24550 * // => 'matches A' 24551 * 24552 * func({ 'a': 0, 'b': 1 }); 24553 * // => 'matches B' 24554 * 24555 * func({ 'a': '1', 'b': '2' }); 24556 * // => 'no match' 24557 */ 24558 function cond(pairs) { 24559 var length = pairs == null ? 0 : pairs.length, 24560 toIteratee = getIteratee(); 24561 24562 pairs = !length ? [] : arrayMap(pairs, function(pair) { 24563 if (typeof pair[1] != 'function') { 24564 throw new TypeError(FUNC_ERROR_TEXT); 24565 } 24566 return [toIteratee(pair[0]), pair[1]]; 24567 }); 24568 24569 return baseRest(function(args) { 24570 var index = -1; 24571 while (++index < length) { 24572 var pair = pairs[index]; 24573 if (apply(pair[0], this, args)) { 24574 return apply(pair[1], this, args); 24575 } 24576 } 24577 }); 24578 } 24579 24580 /** 24581 * Creates a function that invokes the predicate properties of `source` with 24582 * the corresponding property values of a given object, returning `true` if 24583 * all predicates return truthy, else `false`. 24584 * 24585 * **Note:** The created function is equivalent to `_.conformsTo` with 24586 * `source` partially applied. 24587 * 24588 * @static 24589 * @memberOf _ 24590 * @since 4.0.0 24591 * @category Util 24592 * @param {Object} source The object of property predicates to conform to. 24593 * @returns {Function} Returns the new spec function. 24594 * @example 24595 * 24596 * var objects = [ 24597 * { 'a': 2, 'b': 1 }, 24598 * { 'a': 1, 'b': 2 } 24599 * ]; 24600 * 24601 * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } })); 24602 * // => [{ 'a': 1, 'b': 2 }] 24603 */ 24604 function conforms(source) { 24605 return baseConforms(baseClone(source, CLONE_DEEP_FLAG)); 24606 } 24607 24608 /** 24609 * Creates a function that returns `value`. 24610 * 24611 * @static 24612 * @memberOf _ 24613 * @since 2.4.0 24614 * @category Util 24615 * @param {*} value The value to return from the new function. 24616 * @returns {Function} Returns the new constant function. 24617 * @example 24618 * 24619 * var objects = _.times(2, _.constant({ 'a': 1 })); 24620 * 24621 * console.log(objects); 24622 * // => [{ 'a': 1 }, { 'a': 1 }] 24623 * 24624 * console.log(objects[0] === objects[1]); 24625 * // => true 24626 */ 24627 function constant(value) { 24628 return function() { 24629 return value; 24630 }; 24631 } 24632 24633 /** 24634 * Checks `value` to determine whether a default value should be returned in 24635 * its place. The `defaultValue` is returned if `value` is `NaN`, `null`, 24636 * or `undefined`. 24637 * 24638 * @static 24639 * @memberOf _ 24640 * @since 4.14.0 24641 * @category Util 24642 * @param {*} value The value to check. 24643 * @param {*} defaultValue The default value. 24644 * @returns {*} Returns the resolved value. 24645 * @example 24646 * 24647 * _.defaultTo(1, 10); 24648 * // => 1 24649 * 24650 * _.defaultTo(undefined, 10); 24651 * // => 10 24652 */ 24653 function defaultTo(value, defaultValue) { 24654 return (value == null || value !== value) ? defaultValue : value; 24655 } 24656 24657 /** 24658 * Creates a function that returns the result of invoking the given functions 24659 * with the `this` binding of the created function, where each successive 24660 * invocation is supplied the return value of the previous. 24661 * 24662 * @static 24663 * @memberOf _ 24664 * @since 3.0.0 24665 * @category Util 24666 * @param {...(Function|Function[])} [funcs] The functions to invoke. 24667 * @returns {Function} Returns the new composite function. 24668 * @see _.flowRight 24669 * @example 24670 * 24671 * function square(n) { 24672 * return n * n; 24673 * } 24674 * 24675 * var addSquare = _.flow([_.add, square]); 24676 * addSquare(1, 2); 24677 * // => 9 24678 */ 24679 var flow = createFlow(); 24680 24681 /** 24682 * This method is like `_.flow` except that it creates a function that 24683 * invokes the given functions from right to left. 24684 * 24685 * @static 24686 * @since 3.0.0 24687 * @memberOf _ 24688 * @category Util 24689 * @param {...(Function|Function[])} [funcs] The functions to invoke. 24690 * @returns {Function} Returns the new composite function. 24691 * @see _.flow 24692 * @example 24693 * 24694 * function square(n) { 24695 * return n * n; 24696 * } 24697 * 24698 * var addSquare = _.flowRight([square, _.add]); 24699 * addSquare(1, 2); 24700 * // => 9 24701 */ 24702 var flowRight = createFlow(true); 24703 24704 /** 24705 * This method returns the first argument it receives. 24706 * 24707 * @static 24708 * @since 0.1.0 24709 * @memberOf _ 24710 * @category Util 24711 * @param {*} value Any value. 24712 * @returns {*} Returns `value`. 24713 * @example 24714 * 24715 * var object = { 'a': 1 }; 24716 * 24717 * console.log(_.identity(object) === object); 24718 * // => true 24719 */ 24720 function identity(value) { 24721 return value; 24722 } 24723 24724 /** 24725 * Creates a function that invokes `func` with the arguments of the created 24726 * function. If `func` is a property name, the created function returns the 24727 * property value for a given element. If `func` is an array or object, the 24728 * created function returns `true` for elements that contain the equivalent 24729 * source properties, otherwise it returns `false`. 24730 * 24731 * @static 24732 * @since 4.0.0 24733 * @memberOf _ 24734 * @category Util 24735 * @param {*} [func=_.identity] The value to convert to a callback. 24736 * @returns {Function} Returns the callback. 24737 * @example 24738 * 24739 * var users = [ 24740 * { 'user': 'barney', 'age': 36, 'active': true }, 24741 * { 'user': 'fred', 'age': 40, 'active': false } 24742 * ]; 24743 * 24744 * // The `_.matches` iteratee shorthand. 24745 * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true })); 24746 * // => [{ 'user': 'barney', 'age': 36, 'active': true }] 24747 * 24748 * // The `_.matchesProperty` iteratee shorthand. 24749 * _.filter(users, _.iteratee(['user', 'fred'])); 24750 * // => [{ 'user': 'fred', 'age': 40 }] 24751 * 24752 * // The `_.property` iteratee shorthand. 24753 * _.map(users, _.iteratee('user')); 24754 * // => ['barney', 'fred'] 24755 * 24756 * // Create custom iteratee shorthands. 24757 * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) { 24758 * return !_.isRegExp(func) ? iteratee(func) : function(string) { 24759 * return func.test(string); 24760 * }; 24761 * }); 24762 * 24763 * _.filter(['abc', 'def'], /ef/); 24764 * // => ['def'] 24765 */ 24766 function iteratee(func) { 24767 return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG)); 24768 } 24769 24770 /** 24771 * Creates a function that performs a partial deep comparison between a given 24772 * object and `source`, returning `true` if the given object has equivalent 24773 * property values, else `false`. 24774 * 24775 * **Note:** The created function is equivalent to `_.isMatch` with `source` 24776 * partially applied. 24777 * 24778 * Partial comparisons will match empty array and empty object `source` 24779 * values against any array or object value, respectively. See `_.isEqual` 24780 * for a list of supported value comparisons. 24781 * 24782 * **Note:** Multiple values can be checked by combining several matchers 24783 * using `_.overSome` 24784 * 24785 * @static 24786 * @memberOf _ 24787 * @since 3.0.0 24788 * @category Util 24789 * @param {Object} source The object of property values to match. 24790 * @returns {Function} Returns the new spec function. 24791 * @example 24792 * 24793 * var objects = [ 24794 * { 'a': 1, 'b': 2, 'c': 3 }, 24795 * { 'a': 4, 'b': 5, 'c': 6 } 24796 * ]; 24797 * 24798 * _.filter(objects, _.matches({ 'a': 4, 'c': 6 })); 24799 * // => [{ 'a': 4, 'b': 5, 'c': 6 }] 24800 * 24801 * // Checking for several possible values 24802 * _.filter(objects, _.overSome([_.matches({ 'a': 1 }), _.matches({ 'a': 4 })])); 24803 * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }] 24804 */ 24805 function matches(source) { 24806 return baseMatches(baseClone(source, CLONE_DEEP_FLAG)); 24807 } 24808 24809 /** 24810 * Creates a function that performs a partial deep comparison between the 24811 * value at `path` of a given object to `srcValue`, returning `true` if the 24812 * object value is equivalent, else `false`. 24813 * 24814 * **Note:** Partial comparisons will match empty array and empty object 24815 * `srcValue` values against any array or object value, respectively. See 24816 * `_.isEqual` for a list of supported value comparisons. 24817 * 24818 * **Note:** Multiple values can be checked by combining several matchers 24819 * using `_.overSome` 24820 * 24821 * @static 24822 * @memberOf _ 24823 * @since 3.2.0 24824 * @category Util 24825 * @param {Array|string} path The path of the property to get. 24826 * @param {*} srcValue The value to match. 24827 * @returns {Function} Returns the new spec function. 24828 * @example 24829 * 24830 * var objects = [ 24831 * { 'a': 1, 'b': 2, 'c': 3 }, 24832 * { 'a': 4, 'b': 5, 'c': 6 } 24833 * ]; 24834 * 24835 * _.find(objects, _.matchesProperty('a', 4)); 24836 * // => { 'a': 4, 'b': 5, 'c': 6 } 24837 * 24838 * // Checking for several possible values 24839 * _.filter(objects, _.overSome([_.matchesProperty('a', 1), _.matchesProperty('a', 4)])); 24840 * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }] 24841 */ 24842 function matchesProperty(path, srcValue) { 24843 return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG)); 24844 } 24845 24846 /** 24847 * Creates a function that invokes the method at `path` of a given object. 24848 * Any additional arguments are provided to the invoked method. 24849 * 24850 * @static 24851 * @memberOf _ 24852 * @since 3.7.0 24853 * @category Util 24854 * @param {Array|string} path The path of the method to invoke. 24855 * @param {...*} [args] The arguments to invoke the method with. 24856 * @returns {Function} Returns the new invoker function. 24857 * @example 24858 * 24859 * var objects = [ 24860 * { 'a': { 'b': _.constant(2) } }, 24861 * { 'a': { 'b': _.constant(1) } } 24862 * ]; 24863 * 24864 * _.map(objects, _.method('a.b')); 24865 * // => [2, 1] 24866 * 24867 * _.map(objects, _.method(['a', 'b'])); 24868 * // => [2, 1] 24869 */ 24870 var method = baseRest(function(path, args) { 24871 return function(object) { 24872 return baseInvoke(object, path, args); 24873 }; 24874 }); 24875 24876 /** 24877 * The opposite of `_.method`; this method creates a function that invokes 24878 * the method at a given path of `object`. Any additional arguments are 24879 * provided to the invoked method. 24880 * 24881 * @static 24882 * @memberOf _ 24883 * @since 3.7.0 24884 * @category Util 24885 * @param {Object} object The object to query. 24886 * @param {...*} [args] The arguments to invoke the method with. 24887 * @returns {Function} Returns the new invoker function. 24888 * @example 24889 * 24890 * var array = _.times(3, _.constant), 24891 * object = { 'a': array, 'b': array, 'c': array }; 24892 * 24893 * _.map(['a[2]', 'c[0]'], _.methodOf(object)); 24894 * // => [2, 0] 24895 * 24896 * _.map([['a', '2'], ['c', '0']], _.methodOf(object)); 24897 * // => [2, 0] 24898 */ 24899 var methodOf = baseRest(function(object, args) { 24900 return function(path) { 24901 return baseInvoke(object, path, args); 24902 }; 24903 }); 24904 24905 /** 24906 * Adds all own enumerable string keyed function properties of a source 24907 * object to the destination object. If `object` is a function, then methods 24908 * are added to its prototype as well. 24909 * 24910 * **Note:** Use `_.runInContext` to create a pristine `lodash` function to 24911 * avoid conflicts caused by modifying the original. 24912 * 24913 * @static 24914 * @since 0.1.0 24915 * @memberOf _ 24916 * @category Util 24917 * @param {Function|Object} [object=lodash] The destination object. 24918 * @param {Object} source The object of functions to add. 24919 * @param {Object} [options={}] The options object. 24920 * @param {boolean} [options.chain=true] Specify whether mixins are chainable. 24921 * @returns {Function|Object} Returns `object`. 24922 * @example 24923 * 24924 * function vowels(string) { 24925 * return _.filter(string, function(v) { 24926 * return /[aeiou]/i.test(v); 24927 * }); 24928 * } 24929 * 24930 * _.mixin({ 'vowels': vowels }); 24931 * _.vowels('fred'); 24932 * // => ['e'] 24933 * 24934 * _('fred').vowels().value(); 24935 * // => ['e'] 24936 * 24937 * _.mixin({ 'vowels': vowels }, { 'chain': false }); 24938 * _('fred').vowels(); 24939 * // => ['e'] 24940 */ 24941 function mixin(object, source, options) { 24942 var props = keys(source), 24943 methodNames = baseFunctions(source, props); 24944 24945 if (options == null && 24946 !(isObject(source) && (methodNames.length || !props.length))) { 24947 options = source; 24948 source = object; 24949 object = this; 24950 methodNames = baseFunctions(source, keys(source)); 24951 } 24952 var chain = !(isObject(options) && 'chain' in options) || !!options.chain, 24953 isFunc = isFunction(object); 24954 24955 arrayEach(methodNames, function(methodName) { 24956 var func = source[methodName]; 24957 object[methodName] = func; 24958 if (isFunc) { 24959 object.prototype[methodName] = function() { 24960 var chainAll = this.__chain__; 24961 if (chain || chainAll) { 24962 var result = object(this.__wrapped__), 24963 actions = result.__actions__ = copyArray(this.__actions__); 24964 24965 actions.push({ 'func': func, 'args': arguments, 'thisArg': object }); 24966 result.__chain__ = chainAll; 24967 return result; 24968 } 24969 return func.apply(object, arrayPush([this.value()], arguments)); 24970 }; 24971 } 24972 }); 24973 24974 return object; 24975 } 24976 24977 /** 24978 * Reverts the `_` variable to its previous value and returns a reference to 24979 * the `lodash` function. 24980 * 24981 * @static 24982 * @since 0.1.0 24983 * @memberOf _ 24984 * @category Util 24985 * @returns {Function} Returns the `lodash` function. 24986 * @example 24987 * 24988 * var lodash = _.noConflict(); 24989 */ 24990 function noConflict() { 24991 if (root._ === this) { 24992 root._ = oldDash; 24993 } 24994 return this; 24995 } 24996 24997 /** 24998 * This method returns `undefined`. 24999 * 25000 * @static 25001 * @memberOf _ 25002 * @since 2.3.0 25003 * @category Util 25004 * @example 25005 * 25006 * _.times(2, _.noop); 25007 * // => [undefined, undefined] 25008 */ 25009 function noop() { 25010 // No operation performed. 25011 } 25012 25013 /** 25014 * Creates a function that gets the argument at index `n`. If `n` is negative, 25015 * the nth argument from the end is returned. 25016 * 25017 * @static 25018 * @memberOf _ 25019 * @since 4.0.0 25020 * @category Util 25021 * @param {number} [n=0] The index of the argument to return. 25022 * @returns {Function} Returns the new pass-thru function. 25023 * @example 25024 * 25025 * var func = _.nthArg(1); 25026 * func('a', 'b', 'c', 'd'); 25027 * // => 'b' 25028 * 25029 * var func = _.nthArg(-2); 25030 * func('a', 'b', 'c', 'd'); 25031 * // => 'c' 25032 */ 25033 function nthArg(n) { 25034 n = toInteger(n); 25035 return baseRest(function(args) { 25036 return baseNth(args, n); 25037 }); 25038 } 25039 25040 /** 25041 * Creates a function that invokes `iteratees` with the arguments it receives 25042 * and returns their results. 25043 * 25044 * @static 25045 * @memberOf _ 25046 * @since 4.0.0 25047 * @category Util 25048 * @param {...(Function|Function[])} [iteratees=[_.identity]] 25049 * The iteratees to invoke. 25050 * @returns {Function} Returns the new function. 25051 * @example 25052 * 25053 * var func = _.over([Math.max, Math.min]); 25054 * 25055 * func(1, 2, 3, 4); 25056 * // => [4, 1] 25057 */ 25058 var over = createOver(arrayMap); 25059 25060 /** 25061 * Creates a function that checks if **all** of the `predicates` return 25062 * truthy when invoked with the arguments it receives. 25063 * 25064 * Following shorthands are possible for providing predicates. 25065 * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate. 25066 * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them. 25067 * 25068 * @static 25069 * @memberOf _ 25070 * @since 4.0.0 25071 * @category Util 25072 * @param {...(Function|Function[])} [predicates=[_.identity]] 25073 * The predicates to check. 25074 * @returns {Function} Returns the new function. 25075 * @example 25076 * 25077 * var func = _.overEvery([Boolean, isFinite]); 25078 * 25079 * func('1'); 25080 * // => true 25081 * 25082 * func(null); 25083 * // => false 25084 * 25085 * func(NaN); 25086 * // => false 25087 */ 25088 var overEvery = createOver(arrayEvery); 25089 25090 /** 25091 * Creates a function that checks if **any** of the `predicates` return 25092 * truthy when invoked with the arguments it receives. 25093 * 25094 * Following shorthands are possible for providing predicates. 25095 * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate. 25096 * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them. 25097 * 25098 * @static 25099 * @memberOf _ 25100 * @since 4.0.0 25101 * @category Util 25102 * @param {...(Function|Function[])} [predicates=[_.identity]] 25103 * The predicates to check. 25104 * @returns {Function} Returns the new function. 25105 * @example 25106 * 25107 * var func = _.overSome([Boolean, isFinite]); 25108 * 25109 * func('1'); 25110 * // => true 25111 * 25112 * func(null); 25113 * // => true 25114 * 25115 * func(NaN); 25116 * // => false 25117 * 25118 * var matchesFunc = _.overSome([{ 'a': 1 }, { 'a': 2 }]) 25119 * var matchesPropertyFunc = _.overSome([['a', 1], ['a', 2]]) 25120 */ 25121 var overSome = createOver(arraySome); 25122 25123 /** 25124 * Creates a function that returns the value at `path` of a given object. 25125 * 25126 * @static 25127 * @memberOf _ 25128 * @since 2.4.0 25129 * @category Util 25130 * @param {Array|string} path The path of the property to get. 25131 * @returns {Function} Returns the new accessor function. 25132 * @example 25133 * 25134 * var objects = [ 25135 * { 'a': { 'b': 2 } }, 25136 * { 'a': { 'b': 1 } } 25137 * ]; 25138 * 25139 * _.map(objects, _.property('a.b')); 25140 * // => [2, 1] 25141 * 25142 * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b'); 25143 * // => [1, 2] 25144 */ 25145 function property(path) { 25146 return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path); 25147 } 25148 25149 /** 25150 * The opposite of `_.property`; this method creates a function that returns 25151 * the value at a given path of `object`. 25152 * 25153 * @static 25154 * @memberOf _ 25155 * @since 3.0.0 25156 * @category Util 25157 * @param {Object} object The object to query. 25158 * @returns {Function} Returns the new accessor function. 25159 * @example 25160 * 25161 * var array = [0, 1, 2], 25162 * object = { 'a': array, 'b': array, 'c': array }; 25163 * 25164 * _.map(['a[2]', 'c[0]'], _.propertyOf(object)); 25165 * // => [2, 0] 25166 * 25167 * _.map([['a', '2'], ['c', '0']], _.propertyOf(object)); 25168 * // => [2, 0] 25169 */ 25170 function propertyOf(object) { 25171 return function(path) { 25172 return object == null ? undefined : baseGet(object, path); 25173 }; 25174 } 25175 25176 /** 25177 * Creates an array of numbers (positive and/or negative) progressing from 25178 * `start` up to, but not including, `end`. A step of `-1` is used if a negative 25179 * `start` is specified without an `end` or `step`. If `end` is not specified, 25180 * it's set to `start` with `start` then set to `0`. 25181 * 25182 * **Note:** JavaScript follows the IEEE-754 standard for resolving 25183 * floating-point values which can produce unexpected results. 25184 * 25185 * @static 25186 * @since 0.1.0 25187 * @memberOf _ 25188 * @category Util 25189 * @param {number} [start=0] The start of the range. 25190 * @param {number} end The end of the range. 25191 * @param {number} [step=1] The value to increment or decrement by. 25192 * @returns {Array} Returns the range of numbers. 25193 * @see _.inRange, _.rangeRight 25194 * @example 25195 * 25196 * _.range(4); 25197 * // => [0, 1, 2, 3] 25198 * 25199 * _.range(-4); 25200 * // => [0, -1, -2, -3] 25201 * 25202 * _.range(1, 5); 25203 * // => [1, 2, 3, 4] 25204 * 25205 * _.range(0, 20, 5); 25206 * // => [0, 5, 10, 15] 25207 * 25208 * _.range(0, -4, -1); 25209 * // => [0, -1, -2, -3] 25210 * 25211 * _.range(1, 4, 0); 25212 * // => [1, 1, 1] 25213 * 25214 * _.range(0); 25215 * // => [] 25216 */ 25217 var range = createRange(); 25218 25219 /** 25220 * This method is like `_.range` except that it populates values in 25221 * descending order. 25222 * 25223 * @static 25224 * @memberOf _ 25225 * @since 4.0.0 25226 * @category Util 25227 * @param {number} [start=0] The start of the range. 25228 * @param {number} end The end of the range. 25229 * @param {number} [step=1] The value to increment or decrement by. 25230 * @returns {Array} Returns the range of numbers. 25231 * @see _.inRange, _.range 25232 * @example 25233 * 25234 * _.rangeRight(4); 25235 * // => [3, 2, 1, 0] 25236 * 25237 * _.rangeRight(-4); 25238 * // => [-3, -2, -1, 0] 25239 * 25240 * _.rangeRight(1, 5); 25241 * // => [4, 3, 2, 1] 25242 * 25243 * _.rangeRight(0, 20, 5); 25244 * // => [15, 10, 5, 0] 25245 * 25246 * _.rangeRight(0, -4, -1); 25247 * // => [-3, -2, -1, 0] 25248 * 25249 * _.rangeRight(1, 4, 0); 25250 * // => [1, 1, 1] 25251 * 25252 * _.rangeRight(0); 25253 * // => [] 25254 */ 25255 var rangeRight = createRange(true); 25256 25257 /** 25258 * This method returns a new empty array. 25259 * 25260 * @static 25261 * @memberOf _ 25262 * @since 4.13.0 25263 * @category Util 25264 * @returns {Array} Returns the new empty array. 25265 * @example 25266 * 25267 * var arrays = _.times(2, _.stubArray); 25268 * 25269 * console.log(arrays); 25270 * // => [[], []] 25271 * 25272 * console.log(arrays[0] === arrays[1]); 25273 * // => false 25274 */ 25275 function stubArray() { 25276 return []; 25277 } 25278 25279 /** 25280 * This method returns `false`. 25281 * 25282 * @static 25283 * @memberOf _ 25284 * @since 4.13.0 25285 * @category Util 25286 * @returns {boolean} Returns `false`. 25287 * @example 25288 * 25289 * _.times(2, _.stubFalse); 25290 * // => [false, false] 25291 */ 25292 function stubFalse() { 25293 return false; 25294 } 25295 25296 /** 25297 * This method returns a new empty object. 25298 * 25299 * @static 25300 * @memberOf _ 25301 * @since 4.13.0 25302 * @category Util 25303 * @returns {Object} Returns the new empty object. 25304 * @example 25305 * 25306 * var objects = _.times(2, _.stubObject); 25307 * 25308 * console.log(objects); 25309 * // => [{}, {}] 25310 * 25311 * console.log(objects[0] === objects[1]); 25312 * // => false 25313 */ 25314 function stubObject() { 25315 return {}; 25316 } 25317 25318 /** 25319 * This method returns an empty string. 25320 * 25321 * @static 25322 * @memberOf _ 25323 * @since 4.13.0 25324 * @category Util 25325 * @returns {string} Returns the empty string. 25326 * @example 25327 * 25328 * _.times(2, _.stubString); 25329 * // => ['', ''] 25330 */ 25331 function stubString() { 25332 return ''; 25333 } 25334 25335 /** 25336 * This method returns `true`. 25337 * 25338 * @static 25339 * @memberOf _ 25340 * @since 4.13.0 25341 * @category Util 25342 * @returns {boolean} Returns `true`. 25343 * @example 25344 * 25345 * _.times(2, _.stubTrue); 25346 * // => [true, true] 25347 */ 25348 function stubTrue() { 25349 return true; 25350 } 25351 25352 /** 25353 * Invokes the iteratee `n` times, returning an array of the results of 25354 * each invocation. The iteratee is invoked with one argument; (index). 25355 * 25356 * @static 25357 * @since 0.1.0 25358 * @memberOf _ 25359 * @category Util 25360 * @param {number} n The number of times to invoke `iteratee`. 25361 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 25362 * @returns {Array} Returns the array of results. 25363 * @example 25364 * 25365 * _.times(3, String); 25366 * // => ['0', '1', '2'] 25367 * 25368 * _.times(4, _.constant(0)); 25369 * // => [0, 0, 0, 0] 25370 */ 25371 function times(n, iteratee) { 25372 n = toInteger(n); 25373 if (n < 1 || n > MAX_SAFE_INTEGER) { 25374 return []; 25375 } 25376 var index = MAX_ARRAY_LENGTH, 25377 length = nativeMin(n, MAX_ARRAY_LENGTH); 25378 25379 iteratee = getIteratee(iteratee); 25380 n -= MAX_ARRAY_LENGTH; 25381 25382 var result = baseTimes(length, iteratee); 25383 while (++index < n) { 25384 iteratee(index); 25385 } 25386 return result; 25387 } 25388 25389 /** 25390 * Converts `value` to a property path array. 25391 * 25392 * @static 25393 * @memberOf _ 25394 * @since 4.0.0 25395 * @category Util 25396 * @param {*} value The value to convert. 25397 * @returns {Array} Returns the new property path array. 25398 * @example 25399 * 25400 * _.toPath('a.b.c'); 25401 * // => ['a', 'b', 'c'] 25402 * 25403 * _.toPath('a[0].b.c'); 25404 * // => ['a', '0', 'b', 'c'] 25405 */ 25406 function toPath(value) { 25407 if (isArray(value)) { 25408 return arrayMap(value, toKey); 25409 } 25410 return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value))); 25411 } 25412 25413 /** 25414 * Generates a unique ID. If `prefix` is given, the ID is appended to it. 25415 * 25416 * @static 25417 * @since 0.1.0 25418 * @memberOf _ 25419 * @category Util 25420 * @param {string} [prefix=''] The value to prefix the ID with. 25421 * @returns {string} Returns the unique ID. 25422 * @example 25423 * 25424 * _.uniqueId('contact_'); 25425 * // => 'contact_104' 25426 * 25427 * _.uniqueId(); 25428 * // => '105' 25429 */ 25430 function uniqueId(prefix) { 25431 var id = ++idCounter; 25432 return toString(prefix) + id; 25433 } 25434 25435 /*------------------------------------------------------------------------*/ 25436 25437 /** 25438 * Adds two numbers. 25439 * 25440 * @static 25441 * @memberOf _ 25442 * @since 3.4.0 25443 * @category Math 25444 * @param {number} augend The first number in an addition. 25445 * @param {number} addend The second number in an addition. 25446 * @returns {number} Returns the total. 25447 * @example 25448 * 25449 * _.add(6, 4); 25450 * // => 10 25451 */ 25452 var add = createMathOperation(function(augend, addend) { 25453 return augend + addend; 25454 }, 0); 25455 25456 /** 25457 * Computes `number` rounded up to `precision`. 25458 * 25459 * @static 25460 * @memberOf _ 25461 * @since 3.10.0 25462 * @category Math 25463 * @param {number} number The number to round up. 25464 * @param {number} [precision=0] The precision to round up to. 25465 * @returns {number} Returns the rounded up number. 25466 * @example 25467 * 25468 * _.ceil(4.006); 25469 * // => 5 25470 * 25471 * _.ceil(6.004, 2); 25472 * // => 6.01 25473 * 25474 * _.ceil(6040, -2); 25475 * // => 6100 25476 */ 25477 var ceil = createRound('ceil'); 25478 25479 /** 25480 * Divide two numbers. 25481 * 25482 * @static 25483 * @memberOf _ 25484 * @since 4.7.0 25485 * @category Math 25486 * @param {number} dividend The first number in a division. 25487 * @param {number} divisor The second number in a division. 25488 * @returns {number} Returns the quotient. 25489 * @example 25490 * 25491 * _.divide(6, 4); 25492 * // => 1.5 25493 */ 25494 var divide = createMathOperation(function(dividend, divisor) { 25495 return dividend / divisor; 25496 }, 1); 25497 25498 /** 25499 * Computes `number` rounded down to `precision`. 25500 * 25501 * @static 25502 * @memberOf _ 25503 * @since 3.10.0 25504 * @category Math 25505 * @param {number} number The number to round down. 25506 * @param {number} [precision=0] The precision to round down to. 25507 * @returns {number} Returns the rounded down number. 25508 * @example 25509 * 25510 * _.floor(4.006); 25511 * // => 4 25512 * 25513 * _.floor(0.046, 2); 25514 * // => 0.04 25515 * 25516 * _.floor(4060, -2); 25517 * // => 4000 25518 */ 25519 var floor = createRound('floor'); 25520 25521 /** 25522 * Computes the maximum value of `array`. If `array` is empty or falsey, 25523 * `undefined` is returned. 25524 * 25525 * @static 25526 * @since 0.1.0 25527 * @memberOf _ 25528 * @category Math 25529 * @param {Array} array The array to iterate over. 25530 * @returns {*} Returns the maximum value. 25531 * @example 25532 * 25533 * _.max([4, 2, 8, 6]); 25534 * // => 8 25535 * 25536 * _.max([]); 25537 * // => undefined 25538 */ 25539 function max(array) { 25540 return (array && array.length) 25541 ? baseExtremum(array, identity, baseGt) 25542 : undefined; 25543 } 25544 25545 /** 25546 * This method is like `_.max` except that it accepts `iteratee` which is 25547 * invoked for each element in `array` to generate the criterion by which 25548 * the value is ranked. The iteratee is invoked with one argument: (value). 25549 * 25550 * @static 25551 * @memberOf _ 25552 * @since 4.0.0 25553 * @category Math 25554 * @param {Array} array The array to iterate over. 25555 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 25556 * @returns {*} Returns the maximum value. 25557 * @example 25558 * 25559 * var objects = [{ 'n': 1 }, { 'n': 2 }]; 25560 * 25561 * _.maxBy(objects, function(o) { return o.n; }); 25562 * // => { 'n': 2 } 25563 * 25564 * // The `_.property` iteratee shorthand. 25565 * _.maxBy(objects, 'n'); 25566 * // => { 'n': 2 } 25567 */ 25568 function maxBy(array, iteratee) { 25569 return (array && array.length) 25570 ? baseExtremum(array, getIteratee(iteratee, 2), baseGt) 25571 : undefined; 25572 } 25573 25574 /** 25575 * Computes the mean of the values in `array`. 25576 * 25577 * @static 25578 * @memberOf _ 25579 * @since 4.0.0 25580 * @category Math 25581 * @param {Array} array The array to iterate over. 25582 * @returns {number} Returns the mean. 25583 * @example 25584 * 25585 * _.mean([4, 2, 8, 6]); 25586 * // => 5 25587 */ 25588 function mean(array) { 25589 return baseMean(array, identity); 25590 } 25591 25592 /** 25593 * This method is like `_.mean` except that it accepts `iteratee` which is 25594 * invoked for each element in `array` to generate the value to be averaged. 25595 * The iteratee is invoked with one argument: (value). 25596 * 25597 * @static 25598 * @memberOf _ 25599 * @since 4.7.0 25600 * @category Math 25601 * @param {Array} array The array to iterate over. 25602 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 25603 * @returns {number} Returns the mean. 25604 * @example 25605 * 25606 * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]; 25607 * 25608 * _.meanBy(objects, function(o) { return o.n; }); 25609 * // => 5 25610 * 25611 * // The `_.property` iteratee shorthand. 25612 * _.meanBy(objects, 'n'); 25613 * // => 5 25614 */ 25615 function meanBy(array, iteratee) { 25616 return baseMean(array, getIteratee(iteratee, 2)); 25617 } 25618 25619 /** 25620 * Computes the minimum value of `array`. If `array` is empty or falsey, 25621 * `undefined` is returned. 25622 * 25623 * @static 25624 * @since 0.1.0 25625 * @memberOf _ 25626 * @category Math 25627 * @param {Array} array The array to iterate over. 25628 * @returns {*} Returns the minimum value. 25629 * @example 25630 * 25631 * _.min([4, 2, 8, 6]); 25632 * // => 2 25633 * 25634 * _.min([]); 25635 * // => undefined 25636 */ 25637 function min(array) { 25638 return (array && array.length) 25639 ? baseExtremum(array, identity, baseLt) 25640 : undefined; 25641 } 25642 25643 /** 25644 * This method is like `_.min` except that it accepts `iteratee` which is 25645 * invoked for each element in `array` to generate the criterion by which 25646 * the value is ranked. The iteratee is invoked with one argument: (value). 25647 * 25648 * @static 25649 * @memberOf _ 25650 * @since 4.0.0 25651 * @category Math 25652 * @param {Array} array The array to iterate over. 25653 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 25654 * @returns {*} Returns the minimum value. 25655 * @example 25656 * 25657 * var objects = [{ 'n': 1 }, { 'n': 2 }]; 25658 * 25659 * _.minBy(objects, function(o) { return o.n; }); 25660 * // => { 'n': 1 } 25661 * 25662 * // The `_.property` iteratee shorthand. 25663 * _.minBy(objects, 'n'); 25664 * // => { 'n': 1 } 25665 */ 25666 function minBy(array, iteratee) { 25667 return (array && array.length) 25668 ? baseExtremum(array, getIteratee(iteratee, 2), baseLt) 25669 : undefined; 25670 } 25671 25672 /** 25673 * Multiply two numbers. 25674 * 25675 * @static 25676 * @memberOf _ 25677 * @since 4.7.0 25678 * @category Math 25679 * @param {number} multiplier The first number in a multiplication. 25680 * @param {number} multiplicand The second number in a multiplication. 25681 * @returns {number} Returns the product. 25682 * @example 25683 * 25684 * _.multiply(6, 4); 25685 * // => 24 25686 */ 25687 var multiply = createMathOperation(function(multiplier, multiplicand) { 25688 return multiplier * multiplicand; 25689 }, 1); 25690 25691 /** 25692 * Computes `number` rounded to `precision`. 25693 * 25694 * @static 25695 * @memberOf _ 25696 * @since 3.10.0 25697 * @category Math 25698 * @param {number} number The number to round. 25699 * @param {number} [precision=0] The precision to round to. 25700 * @returns {number} Returns the rounded number. 25701 * @example 25702 * 25703 * _.round(4.006); 25704 * // => 4 25705 * 25706 * _.round(4.006, 2); 25707 * // => 4.01 25708 * 25709 * _.round(4060, -2); 25710 * // => 4100 25711 */ 25712 var round = createRound('round'); 25713 25714 /** 25715 * Subtract two numbers. 25716 * 25717 * @static 25718 * @memberOf _ 25719 * @since 4.0.0 25720 * @category Math 25721 * @param {number} minuend The first number in a subtraction. 25722 * @param {number} subtrahend The second number in a subtraction. 25723 * @returns {number} Returns the difference. 25724 * @example 25725 * 25726 * _.subtract(6, 4); 25727 * // => 2 25728 */ 25729 var subtract = createMathOperation(function(minuend, subtrahend) { 25730 return minuend - subtrahend; 25731 }, 0); 25732 25733 /** 25734 * Computes the sum of the values in `array`. 25735 * 25736 * @static 25737 * @memberOf _ 25738 * @since 3.4.0 25739 * @category Math 25740 * @param {Array} array The array to iterate over. 25741 * @returns {number} Returns the sum. 25742 * @example 25743 * 25744 * _.sum([4, 2, 8, 6]); 25745 * // => 20 25746 */ 25747 function sum(array) { 25748 return (array && array.length) 25749 ? baseSum(array, identity) 25750 : 0; 25751 } 25752 25753 /** 25754 * This method is like `_.sum` except that it accepts `iteratee` which is 25755 * invoked for each element in `array` to generate the value to be summed. 25756 * The iteratee is invoked with one argument: (value). 25757 * 25758 * @static 25759 * @memberOf _ 25760 * @since 4.0.0 25761 * @category Math 25762 * @param {Array} array The array to iterate over. 25763 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 25764 * @returns {number} Returns the sum. 25765 * @example 25766 * 25767 * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]; 25768 * 25769 * _.sumBy(objects, function(o) { return o.n; }); 25770 * // => 20 25771 * 25772 * // The `_.property` iteratee shorthand. 25773 * _.sumBy(objects, 'n'); 25774 * // => 20 25775 */ 25776 function sumBy(array, iteratee) { 25777 return (array && array.length) 25778 ? baseSum(array, getIteratee(iteratee, 2)) 25779 : 0; 25780 } 25781 25782 /*------------------------------------------------------------------------*/ 25783 25784 // Add methods that return wrapped values in chain sequences. 25785 lodash.after = after; 25786 lodash.ary = ary; 25787 lodash.assign = assign; 25788 lodash.assignIn = assignIn; 25789 lodash.assignInWith = assignInWith; 25790 lodash.assignWith = assignWith; 25791 lodash.at = at; 25792 lodash.before = before; 25793 lodash.bind = bind; 25794 lodash.bindAll = bindAll; 25795 lodash.bindKey = bindKey; 25796 lodash.castArray = castArray; 25797 lodash.chain = chain; 25798 lodash.chunk = chunk; 25799 lodash.compact = compact; 25800 lodash.concat = concat; 25801 lodash.cond = cond; 25802 lodash.conforms = conforms; 25803 lodash.constant = constant; 25804 lodash.countBy = countBy; 25805 lodash.create = create; 25806 lodash.curry = curry; 25807 lodash.curryRight = curryRight; 25808 lodash.debounce = debounce; 25809 lodash.defaults = defaults; 25810 lodash.defaultsDeep = defaultsDeep; 25811 lodash.defer = defer; 25812 lodash.delay = delay; 25813 lodash.difference = difference; 25814 lodash.differenceBy = differenceBy; 25815 lodash.differenceWith = differenceWith; 25816 lodash.drop = drop; 25817 lodash.dropRight = dropRight; 25818 lodash.dropRightWhile = dropRightWhile; 25819 lodash.dropWhile = dropWhile; 25820 lodash.fill = fill; 25821 lodash.filter = filter; 25822 lodash.flatMap = flatMap; 25823 lodash.flatMapDeep = flatMapDeep; 25824 lodash.flatMapDepth = flatMapDepth; 25825 lodash.flatten = flatten; 25826 lodash.flattenDeep = flattenDeep; 25827 lodash.flattenDepth = flattenDepth; 25828 lodash.flip = flip; 25829 lodash.flow = flow; 25830 lodash.flowRight = flowRight; 25831 lodash.fromPairs = fromPairs; 25832 lodash.functions = functions; 25833 lodash.functionsIn = functionsIn; 25834 lodash.groupBy = groupBy; 25835 lodash.initial = initial; 25836 lodash.intersection = intersection; 25837 lodash.intersectionBy = intersectionBy; 25838 lodash.intersectionWith = intersectionWith; 25839 lodash.invert = invert; 25840 lodash.invertBy = invertBy; 25841 lodash.invokeMap = invokeMap; 25842 lodash.iteratee = iteratee; 25843 lodash.keyBy = keyBy; 25844 lodash.keys = keys; 25845 lodash.keysIn = keysIn; 25846 lodash.map = map; 25847 lodash.mapKeys = mapKeys; 25848 lodash.mapValues = mapValues; 25849 lodash.matches = matches; 25850 lodash.matchesProperty = matchesProperty; 25851 lodash.memoize = memoize; 25852 lodash.merge = merge; 25853 lodash.mergeWith = mergeWith; 25854 lodash.method = method; 25855 lodash.methodOf = methodOf; 25856 lodash.mixin = mixin; 25857 lodash.negate = negate; 25858 lodash.nthArg = nthArg; 25859 lodash.omit = omit; 25860 lodash.omitBy = omitBy; 25861 lodash.once = once; 25862 lodash.orderBy = orderBy; 25863 lodash.over = over; 25864 lodash.overArgs = overArgs; 25865 lodash.overEvery = overEvery; 25866 lodash.overSome = overSome; 25867 lodash.partial = partial; 25868 lodash.partialRight = partialRight; 25869 lodash.partition = partition; 25870 lodash.pick = pick; 25871 lodash.pickBy = pickBy; 25872 lodash.property = property; 25873 lodash.propertyOf = propertyOf; 25874 lodash.pull = pull; 25875 lodash.pullAll = pullAll; 25876 lodash.pullAllBy = pullAllBy; 25877 lodash.pullAllWith = pullAllWith; 25878 lodash.pullAt = pullAt; 25879 lodash.range = range; 25880 lodash.rangeRight = rangeRight; 25881 lodash.rearg = rearg; 25882 lodash.reject = reject; 25883 lodash.remove = remove; 25884 lodash.rest = rest; 25885 lodash.reverse = reverse; 25886 lodash.sampleSize = sampleSize; 25887 lodash.set = set; 25888 lodash.setWith = setWith; 25889 lodash.shuffle = shuffle; 25890 lodash.slice = slice; 25891 lodash.sortBy = sortBy; 25892 lodash.sortedUniq = sortedUniq; 25893 lodash.sortedUniqBy = sortedUniqBy; 25894 lodash.split = split; 25895 lodash.spread = spread; 25896 lodash.tail = tail; 25897 lodash.take = take; 25898 lodash.takeRight = takeRight; 25899 lodash.takeRightWhile = takeRightWhile; 25900 lodash.takeWhile = takeWhile; 25901 lodash.tap = tap; 25902 lodash.throttle = throttle; 25903 lodash.thru = thru; 25904 lodash.toArray = toArray; 25905 lodash.toPairs = toPairs; 25906 lodash.toPairsIn = toPairsIn; 25907 lodash.toPath = toPath; 25908 lodash.toPlainObject = toPlainObject; 25909 lodash.transform = transform; 25910 lodash.unary = unary; 25911 lodash.union = union; 25912 lodash.unionBy = unionBy; 25913 lodash.unionWith = unionWith; 25914 lodash.uniq = uniq; 25915 lodash.uniqBy = uniqBy; 25916 lodash.uniqWith = uniqWith; 25917 lodash.unset = unset; 25918 lodash.unzip = unzip; 25919 lodash.unzipWith = unzipWith; 25920 lodash.update = update; 25921 lodash.updateWith = updateWith; 25922 lodash.values = values; 25923 lodash.valuesIn = valuesIn; 25924 lodash.without = without; 25925 lodash.words = words; 25926 lodash.wrap = wrap; 25927 lodash.xor = xor; 25928 lodash.xorBy = xorBy; 25929 lodash.xorWith = xorWith; 25930 lodash.zip = zip; 25931 lodash.zipObject = zipObject; 25932 lodash.zipObjectDeep = zipObjectDeep; 25933 lodash.zipWith = zipWith; 25934 25935 // Add aliases. 25936 lodash.entries = toPairs; 25937 lodash.entriesIn = toPairsIn; 25938 lodash.extend = assignIn; 25939 lodash.extendWith = assignInWith; 25940 25941 // Add methods to `lodash.prototype`. 25942 mixin(lodash, lodash); 25943 25944 /*------------------------------------------------------------------------*/ 25945 25946 // Add methods that return unwrapped values in chain sequences. 25947 lodash.add = add; 25948 lodash.attempt = attempt; 25949 lodash.camelCase = camelCase; 25950 lodash.capitalize = capitalize; 25951 lodash.ceil = ceil; 25952 lodash.clamp = clamp; 25953 lodash.clone = clone; 25954 lodash.cloneDeep = cloneDeep; 25955 lodash.cloneDeepWith = cloneDeepWith; 25956 lodash.cloneWith = cloneWith; 25957 lodash.conformsTo = conformsTo; 25958 lodash.deburr = deburr; 25959 lodash.defaultTo = defaultTo; 25960 lodash.divide = divide; 25961 lodash.endsWith = endsWith; 25962 lodash.eq = eq; 25963 lodash.escape = escape; 25964 lodash.escapeRegExp = escapeRegExp; 25965 lodash.every = every; 25966 lodash.find = find; 25967 lodash.findIndex = findIndex; 25968 lodash.findKey = findKey; 25969 lodash.findLast = findLast; 25970 lodash.findLastIndex = findLastIndex; 25971 lodash.findLastKey = findLastKey; 25972 lodash.floor = floor; 25973 lodash.forEach = forEach; 25974 lodash.forEachRight = forEachRight; 25975 lodash.forIn = forIn; 25976 lodash.forInRight = forInRight; 25977 lodash.forOwn = forOwn; 25978 lodash.forOwnRight = forOwnRight; 25979 lodash.get = get; 25980 lodash.gt = gt; 25981 lodash.gte = gte; 25982 lodash.has = has; 25983 lodash.hasIn = hasIn; 25984 lodash.head = head; 25985 lodash.identity = identity; 25986 lodash.includes = includes; 25987 lodash.indexOf = indexOf; 25988 lodash.inRange = inRange; 25989 lodash.invoke = invoke; 25990 lodash.isArguments = isArguments; 25991 lodash.isArray = isArray; 25992 lodash.isArrayBuffer = isArrayBuffer; 25993 lodash.isArrayLike = isArrayLike; 25994 lodash.isArrayLikeObject = isArrayLikeObject; 25995 lodash.isBoolean = isBoolean; 25996 lodash.isBuffer = isBuffer; 25997 lodash.isDate = isDate; 25998 lodash.isElement = isElement; 25999 lodash.isEmpty = isEmpty; 26000 lodash.isEqual = isEqual; 26001 lodash.isEqualWith = isEqualWith; 26002 lodash.isError = isError; 26003 lodash.isFinite = isFinite; 26004 lodash.isFunction = isFunction; 26005 lodash.isInteger = isInteger; 26006 lodash.isLength = isLength; 26007 lodash.isMap = isMap; 26008 lodash.isMatch = isMatch; 26009 lodash.isMatchWith = isMatchWith; 26010 lodash.isNaN = isNaN; 26011 lodash.isNative = isNative; 26012 lodash.isNil = isNil; 26013 lodash.isNull = isNull; 26014 lodash.isNumber = isNumber; 26015 lodash.isObject = isObject; 26016 lodash.isObjectLike = isObjectLike; 26017 lodash.isPlainObject = isPlainObject; 26018 lodash.isRegExp = isRegExp; 26019 lodash.isSafeInteger = isSafeInteger; 26020 lodash.isSet = isSet; 26021 lodash.isString = isString; 26022 lodash.isSymbol = isSymbol; 26023 lodash.isTypedArray = isTypedArray; 26024 lodash.isUndefined = isUndefined; 26025 lodash.isWeakMap = isWeakMap; 26026 lodash.isWeakSet = isWeakSet; 26027 lodash.join = join; 26028 lodash.kebabCase = kebabCase; 26029 lodash.last = last; 26030 lodash.lastIndexOf = lastIndexOf; 26031 lodash.lowerCase = lowerCase; 26032 lodash.lowerFirst = lowerFirst; 26033 lodash.lt = lt; 26034 lodash.lte = lte; 26035 lodash.max = max; 26036 lodash.maxBy = maxBy; 26037 lodash.mean = mean; 26038 lodash.meanBy = meanBy; 26039 lodash.min = min; 26040 lodash.minBy = minBy; 26041 lodash.stubArray = stubArray; 26042 lodash.stubFalse = stubFalse; 26043 lodash.stubObject = stubObject; 26044 lodash.stubString = stubString; 26045 lodash.stubTrue = stubTrue; 26046 lodash.multiply = multiply; 26047 lodash.nth = nth; 26048 lodash.noConflict = noConflict; 26049 lodash.noop = noop; 26050 lodash.now = now; 26051 lodash.pad = pad; 26052 lodash.padEnd = padEnd; 26053 lodash.padStart = padStart; 26054 lodash.parseInt = parseInt; 26055 lodash.random = random; 26056 lodash.reduce = reduce; 26057 lodash.reduceRight = reduceRight; 26058 lodash.repeat = repeat; 26059 lodash.replace = replace; 26060 lodash.result = result; 26061 lodash.round = round; 26062 lodash.runInContext = runInContext; 26063 lodash.sample = sample; 26064 lodash.size = size; 26065 lodash.snakeCase = snakeCase; 26066 lodash.some = some; 26067 lodash.sortedIndex = sortedIndex; 26068 lodash.sortedIndexBy = sortedIndexBy; 26069 lodash.sortedIndexOf = sortedIndexOf; 26070 lodash.sortedLastIndex = sortedLastIndex; 26071 lodash.sortedLastIndexBy = sortedLastIndexBy; 26072 lodash.sortedLastIndexOf = sortedLastIndexOf; 26073 lodash.startCase = startCase; 26074 lodash.startsWith = startsWith; 26075 lodash.subtract = subtract; 26076 lodash.sum = sum; 26077 lodash.sumBy = sumBy; 26078 lodash.template = template; 26079 lodash.times = times; 26080 lodash.toFinite = toFinite; 26081 lodash.toInteger = toInteger; 26082 lodash.toLength = toLength; 26083 lodash.toLower = toLower; 26084 lodash.toNumber = toNumber; 26085 lodash.toSafeInteger = toSafeInteger; 26086 lodash.toString = toString; 26087 lodash.toUpper = toUpper; 26088 lodash.trim = trim; 26089 lodash.trimEnd = trimEnd; 26090 lodash.trimStart = trimStart; 26091 lodash.truncate = truncate; 26092 lodash.unescape = unescape; 26093 lodash.uniqueId = uniqueId; 26094 lodash.upperCase = upperCase; 26095 lodash.upperFirst = upperFirst; 26096 26097 // Add aliases. 26098 lodash.each = forEach; 26099 lodash.eachRight = forEachRight; 26100 lodash.first = head; 26101 26102 mixin(lodash, (function() { 26103 var source = {}; 26104 baseForOwn(lodash, function(func, methodName) { 26105 if (!hasOwnProperty.call(lodash.prototype, methodName)) { 26106 source[methodName] = func; 26107 } 26108 }); 26109 return source; 26110 }()), { 'chain': false }); 26111 26112 /*------------------------------------------------------------------------*/ 26113 26114 /** 26115 * The semantic version number. 26116 * 26117 * @static 26118 * @memberOf _ 26119 * @type {string} 26120 */ 26121 lodash.VERSION = VERSION; 26122 26123 // Assign default placeholders. 26124 arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) { 26125 lodash[methodName].placeholder = lodash; 26126 }); 26127 26128 // Add `LazyWrapper` methods for `_.drop` and `_.take` variants. 26129 arrayEach(['drop', 'take'], function(methodName, index) { 26130 LazyWrapper.prototype[methodName] = function(n) { 26131 n = n === undefined ? 1 : nativeMax(toInteger(n), 0); 26132 26133 var result = (this.__filtered__ && !index) 26134 ? new LazyWrapper(this) 26135 : this.clone(); 26136 26137 if (result.__filtered__) { 26138 result.__takeCount__ = nativeMin(n, result.__takeCount__); 26139 } else { 26140 result.__views__.push({ 26141 'size': nativeMin(n, MAX_ARRAY_LENGTH), 26142 'type': methodName + (result.__dir__ < 0 ? 'Right' : '') 26143 }); 26144 } 26145 return result; 26146 }; 26147 26148 LazyWrapper.prototype[methodName + 'Right'] = function(n) { 26149 return this.reverse()[methodName](n).reverse(); 26150 }; 26151 }); 26152 26153 // Add `LazyWrapper` methods that accept an `iteratee` value. 26154 arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) { 26155 var type = index + 1, 26156 isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG; 26157 26158 LazyWrapper.prototype[methodName] = function(iteratee) { 26159 var result = this.clone(); 26160 result.__iteratees__.push({ 26161 'iteratee': getIteratee(iteratee, 3), 26162 'type': type 26163 }); 26164 result.__filtered__ = result.__filtered__ || isFilter; 26165 return result; 26166 }; 26167 }); 26168 26169 // Add `LazyWrapper` methods for `_.head` and `_.last`. 26170 arrayEach(['head', 'last'], function(methodName, index) { 26171 var takeName = 'take' + (index ? 'Right' : ''); 26172 26173 LazyWrapper.prototype[methodName] = function() { 26174 return this[takeName](1).value()[0]; 26175 }; 26176 }); 26177 26178 // Add `LazyWrapper` methods for `_.initial` and `_.tail`. 26179 arrayEach(['initial', 'tail'], function(methodName, index) { 26180 var dropName = 'drop' + (index ? '' : 'Right'); 26181 26182 LazyWrapper.prototype[methodName] = function() { 26183 return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1); 26184 }; 26185 }); 26186 26187 LazyWrapper.prototype.compact = function() { 26188 return this.filter(identity); 26189 }; 26190 26191 LazyWrapper.prototype.find = function(predicate) { 26192 return this.filter(predicate).head(); 26193 }; 26194 26195 LazyWrapper.prototype.findLast = function(predicate) { 26196 return this.reverse().find(predicate); 26197 }; 26198 26199 LazyWrapper.prototype.invokeMap = baseRest(function(path, args) { 26200 if (typeof path == 'function') { 26201 return new LazyWrapper(this); 26202 } 26203 return this.map(function(value) { 26204 return baseInvoke(value, path, args); 26205 }); 26206 }); 26207 26208 LazyWrapper.prototype.reject = function(predicate) { 26209 return this.filter(negate(getIteratee(predicate))); 26210 }; 26211 26212 LazyWrapper.prototype.slice = function(start, end) { 26213 start = toInteger(start); 26214 26215 var result = this; 26216 if (result.__filtered__ && (start > 0 || end < 0)) { 26217 return new LazyWrapper(result); 26218 } 26219 if (start < 0) { 26220 result = result.takeRight(-start); 26221 } else if (start) { 26222 result = result.drop(start); 26223 } 26224 if (end !== undefined) { 26225 end = toInteger(end); 26226 result = end < 0 ? result.dropRight(-end) : result.take(end - start); 26227 } 26228 return result; 26229 }; 26230 26231 LazyWrapper.prototype.takeRightWhile = function(predicate) { 26232 return this.reverse().takeWhile(predicate).reverse(); 26233 }; 26234 26235 LazyWrapper.prototype.toArray = function() { 26236 return this.take(MAX_ARRAY_LENGTH); 26237 }; 26238 26239 // Add `LazyWrapper` methods to `lodash.prototype`. 26240 baseForOwn(LazyWrapper.prototype, function(func, methodName) { 26241 var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName), 26242 isTaker = /^(?:head|last)$/.test(methodName), 26243 lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName], 26244 retUnwrapped = isTaker || /^find/.test(methodName); 26245 26246 if (!lodashFunc) { 26247 return; 26248 } 26249 lodash.prototype[methodName] = function() { 26250 var value = this.__wrapped__, 26251 args = isTaker ? [1] : arguments, 26252 isLazy = value instanceof LazyWrapper, 26253 iteratee = args[0], 26254 useLazy = isLazy || isArray(value); 26255 26256 var interceptor = function(value) { 26257 var result = lodashFunc.apply(lodash, arrayPush([value], args)); 26258 return (isTaker && chainAll) ? result[0] : result; 26259 }; 26260 26261 if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) { 26262 // Avoid lazy use if the iteratee has a "length" value other than `1`. 26263 isLazy = useLazy = false; 26264 } 26265 var chainAll = this.__chain__, 26266 isHybrid = !!this.__actions__.length, 26267 isUnwrapped = retUnwrapped && !chainAll, 26268 onlyLazy = isLazy && !isHybrid; 26269 26270 if (!retUnwrapped && useLazy) { 26271 value = onlyLazy ? value : new LazyWrapper(this); 26272 var result = func.apply(value, args); 26273 result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined }); 26274 return new LodashWrapper(result, chainAll); 26275 } 26276 if (isUnwrapped && onlyLazy) { 26277 return func.apply(this, args); 26278 } 26279 result = this.thru(interceptor); 26280 return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result; 26281 }; 26282 }); 26283 26284 // Add `Array` methods to `lodash.prototype`. 26285 arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) { 26286 var func = arrayProto[methodName], 26287 chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru', 26288 retUnwrapped = /^(?:pop|shift)$/.test(methodName); 26289 26290 lodash.prototype[methodName] = function() { 26291 var args = arguments; 26292 if (retUnwrapped && !this.__chain__) { 26293 var value = this.value(); 26294 return func.apply(isArray(value) ? value : [], args); 26295 } 26296 return this[chainName](function(value) { 26297 return func.apply(isArray(value) ? value : [], args); 26298 }); 26299 }; 26300 }); 26301 26302 // Map minified method names to their real names. 26303 baseForOwn(LazyWrapper.prototype, function(func, methodName) { 26304 var lodashFunc = lodash[methodName]; 26305 if (lodashFunc) { 26306 var key = lodashFunc.name + ''; 26307 if (!hasOwnProperty.call(realNames, key)) { 26308 realNames[key] = []; 26309 } 26310 realNames[key].push({ 'name': methodName, 'func': lodashFunc }); 26311 } 26312 }); 26313 26314 realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{ 26315 'name': 'wrapper', 26316 'func': undefined 26317 }]; 26318 26319 // Add methods to `LazyWrapper`. 26320 LazyWrapper.prototype.clone = lazyClone; 26321 LazyWrapper.prototype.reverse = lazyReverse; 26322 LazyWrapper.prototype.value = lazyValue; 26323 26324 // Add chain sequence methods to the `lodash` wrapper. 26325 lodash.prototype.at = wrapperAt; 26326 lodash.prototype.chain = wrapperChain; 26327 lodash.prototype.commit = wrapperCommit; 26328 lodash.prototype.next = wrapperNext; 26329 lodash.prototype.plant = wrapperPlant; 26330 lodash.prototype.reverse = wrapperReverse; 26331 lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue; 26332 26333 // Add lazy aliases. 26334 lodash.prototype.first = lodash.prototype.head; 26335 26336 if (symIterator) { 26337 lodash.prototype[symIterator] = wrapperToIterator; 26338 } 26339 return lodash; 26340 }); 26341 26342 /*--------------------------------------------------------------------------*/ 26343 26344 // Export lodash. 26345 var _ = runInContext(); 26346 26347 // Some AMD build optimizers, like r.js, check for condition patterns like: 26348 if (true) { 26349 // Expose Lodash on the global object to prevent errors when Lodash is 26350 // loaded by a script tag in the presence of an AMD loader. 26351 // See http://requirejs.org/docs/errors.html#mismatch for more details. 26352 // Use `_.noConflict` to remove Lodash from the global object. 26353 root._ = _; 26354 26355 // Define as an anonymous module so, through path mapping, it can be 26356 // referenced as the "underscore" module. 26357 !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() { 26358 return _; 26359 }).call(exports, __webpack_require__, exports, module), 26360 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 26361 } 26362 // Check for `exports` after `define` in case a build optimizer adds it. 26363 else {} 26364}.call(this)); 26365 26366 26367/***/ })
vendor: 4,128 bytes, lines 26367-26452
26367, 26368 26369/***/ "./theme sync recursive \\.\\/(?%21(dist%7Cvendor)).*\\/(?%21.*-admin)([^/]+\\/)*.+\\.js$": 26370/*!**********************************************************************************!*\ 26371 !*** ./theme/ sync \.\/(?%21(dist%7Cvendor)).*\/(?%21.*-admin)([^/]+\/)*.+\.js$ ***! 26372 \**********************************************************************************/ 26373/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 26374 26375var map = { 26376 "./components/action/action.js": "./theme/components/action/action.js", 26377 "./components/cases/cases.js": "./theme/components/cases/cases.js", 26378 "./components/connectors/connectors.js": "./theme/components/connectors/connectors.js", 26379 "./components/content-slider/content-slider.js": "./theme/components/content-slider/content-slider.js", 26380 "./components/content-with-visual/content-with-visual.js": "./theme/components/content-with-visual/content-with-visual.js", 26381 "./components/faq/faq.js": "./theme/components/faq/faq.js", 26382 "./components/gallery-carousel/gallery-carousel.js": "./theme/components/gallery-carousel/gallery-carousel.js", 26383 "./components/icons/icons.js": "./theme/components/icons/icons.js", 26384 "./components/jobs-carousel/jobs-carousel.js": "./theme/components/jobs-carousel/jobs-carousel.js", 26385 "./components/jobs-overview/jobs-overview.js": "./theme/components/jobs-overview/jobs-overview.js", 26386 "./components/logos/logos.js": "./theme/components/logos/logos.js", 26387 "./components/modal/modal.js": "./theme/components/modal/modal.js", 26388 "./components/navbar/navbar.js": "./theme/components/navbar/navbar.js", 26389 "./components/price-calculator/price-calculator.js": "./theme/components/price-calculator/price-calculator.js", 26390 "./components/related-integrations/related-integrations.js": "./theme/components/related-integrations/related-integrations.js", 26391 "./components/templates-overview/templates-overview.js": "./theme/components/templates-overview/templates-overview.js", 26392 "./components/webinar-registration/webinar-registration.js": "./theme/components/webinar-registration/webinar-registration.js", 26393 "./templates/single-connector.js": "./theme/templates/single-connector.js", 26394 "./templates/single-template.js": "./theme/templates/single-template.js" 26395}; 26396 26397 26398function webpackContext(req) { 26399 var id = webpackContextResolve(req); 26400 return __webpack_require__(id); 26401} 26402function webpackContextResolve(req) { 26403 if(!__webpack_require__.o(map, req)) { 26404 var e = new Error("Cannot find module '" + req + "'"); 26405 e.code = 'MODULE_NOT_FOUND'; 26406 throw e; 26407 } 26408 return map[req]; 26409} 26410webpackContext.keys = function webpackContextKeys() { 26411 return Object.keys(map); 26412}; 26413webpackContext.resolve = webpackContextResolve; 26414module.exports = webpackContext; 26415webpackContext.id = "./theme sync recursive \\.\\/(?%21(dist%7Cvendor)).*\\/(?%21.*-admin)([^/]+\\/)*.+\\.js$"; 26416 26417/***/ }) 26418 26419/******/ }); 26420/************************************************************************/ 26421/******/ // The module cache 26422/******/ var __webpack_module_cache__ = {}; 26423/******/ 26424/******/ // The require function 26425/******/ function __webpack_require__(moduleId) { 26426/******/ // Check if module is in cache 26427/******/ var cachedModule = __webpack_module_cache__[moduleId]; 26428/******/ if (cachedModule !== undefined) { 26429/******/ return cachedModule.exports; 26430/******/ } 26431/******/ // Create a new module (and put it into the cache) 26432/******/ var module = __webpack_module_cache__[moduleId] = { 26433/******/ id: moduleId, 26434/******/ loaded: false, 26435/******/ exports: {} 26436/******/ }; 26437/******/ 26438/******/ // Execute the module function 26439/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__); 26440/******/ 26441/******/ // Flag the module as loaded 26442/******/ module.loaded = true; 26443/******/ 26444/******/ // Return the exports of the module 26445/******/ return module.exports; 26446/******/ } 26447/******/ 26448/************************************************************************/ 26449/******/ /* webpack/runtime/compat get default export */ 26450/******/ (() => { 26451/******/ // getDefaultExport function for compatibility with non-harmony modules 26452/******/ __webpack_require__.n = (module) => {
vendor: 3,030 bytes, lines 26453-26535
26453/******/ var getter = module && module.__esModule ? 26454/******/ () => (module['default']) : 26455/******/ () => (module); 26456/******/ __webpack_require__.d(getter, { a: getter }); 26457/******/ return getter; 26458/******/ }; 26459/******/ })(); 26460/******/ 26461/******/ /* webpack/runtime/define property getters */ 26462/******/ (() => { 26463/******/ // define getter functions for harmony exports 26464/******/ __webpack_require__.d = (exports, definition) => { 26465/******/ for(var key in definition) { 26466/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 26467/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 26468/******/ } 26469/******/ } 26470/******/ }; 26471/******/ })(); 26472/******/ 26473/******/ /* webpack/runtime/global */ 26474/******/ (() => { 26475/******/ __webpack_require__.g = (function() { 26476/******/ if (typeof globalThis === 'object') return globalThis; 26477/******/ try { 26478/******/ return this || new Function('return this')(); 26479/******/ } catch (e) { 26480/******/ if (typeof window === 'object') return window; 26481/******/ } 26482/******/ })(); 26483/******/ })(); 26484/******/ 26485/******/ /* webpack/runtime/hasOwnProperty shorthand */ 26486/******/ (() => { 26487/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) 26488/******/ })(); 26489/******/ 26490/******/ /* webpack/runtime/make namespace object */ 26491/******/ (() => { 26492/******/ // define __esModule on exports 26493/******/ __webpack_require__.r = (exports) => { 26494/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 26495/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 26496/******/ } 26497/******/ Object.defineProperty(exports, '__esModule', { value: true }); 26498/******/ }; 26499/******/ })(); 26500/******/ 26501/******/ /* webpack/runtime/node module decorator */ 26502/******/ (() => { 26503/******/ __webpack_require__.nmd = (module) => { 26504/******/ module.paths = []; 26505/******/ if (!module.children) module.children = []; 26506/******/ return module; 26507/******/ }; 26508/******/ })(); 26509/******/ 26510/************************************************************************/ 26511var __webpack_exports__ = {}; 26512// This entry need to be wrapped in an IIFE because it need to be in strict mode. 26513(() => { 26514"use strict"; 26515/*!**************************!*\ 26516 !*** ./theme/_loader.js ***! 26517 \**************************/ 26518__webpack_require__.r(__webpack_exports__); 26519/* harmony import */ var alpinejs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! alpinejs */ "./node_modules/alpinejs/dist/module.esm.js"); 26520 26521 26522/** 26523 * Pulls in all scripts 26524 */ 26525function requireAll(requireContext) { 26526 return requireContext.keys().map(requireContext); 26527} 26528requireAll(__webpack_require__("./theme sync recursive \\.\\/(?%21(dist%7Cvendor)).*\\/(?%21.*-admin)([^/]+\\/)*.+\\.js$")); 26529window.Alpine = alpinejs__WEBPACK_IMPORTED_MODULE_0__["default"]; 26530alpinejs__WEBPACK_IMPORTED_MODULE_0__["default"].start(); 26531})(); 26532 26533/******/ })() 26534; 26535//# sourceMappingURL=scripts.4b6baa2d44ecb439d3ed.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.