1/** 2 * @license lea v0.1.0 3 * (c) 2026 Luca Zampetti 4 * License: ISC 5 */ 6 7(function (factory) { 8 typeof define === 'function' && define.amd ? define(factory) : 9 factory(); 10}((function () { 'use strict'; 11 12 /* jshint esversion: 6 */ 13 function generaGtmEventId() { 14 // i. e. 1637860718213.bx64i1n69gm 15 var timestamp = Date.now(); 16 var caratteriPossibili = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; 17 var stringaCasuale = ''; 18 19 for (var i = 0; i < 11; i++) { 20 stringaCasuale += caratteriPossibili.charAt(Math.floor(Math.random() * caratteriPossibili.length)); 21 } 22 23 return timestamp + '.' + stringaCasuale; 24 } 25 26 function push_(event) { 27 var dataLayer = window.dataLayer || []; 28 event["ss_event_id"] = generaGtmEventId(); 29 dataLayer.push(event); 30 console.log('GtmService.dataLayer', dataLayer); 31 } 32 33 var GtmService = /*#__PURE__*/function () { 34 function GtmService() {} 35 36 GtmService.pageSetup = function pageSetup(data) { 37 return push_(data); 38 }; 39 40 GtmService.pageView = function pageView() { 41 // console.log("pageview1()"); 42 //const view = Array.prototype.slice.call(document.querySelectorAll('.view')).pop(); 43 return push_( // JSON.parse(view.dataset.gtmPageview) 44 { 45 event: 'virtual_pageview', 46 pageTitle: document.title, 47 documentLocation: window.location.href, 48 originalLocation: window.location.href, 49 pagePath: window.location.pathname // hostname: window.location.hostname, 50 51 }); 52 }; 53 54 GtmService.pageView = function pageView(pathname) { 55 //console.log("pageviewpath()"); 56 //const view = Array.prototype.slice.call(document.querySelectorAll('.view')).pop(); 57 //return push_( 58 // JSON.parse(view.dataset.gtmPageview) 59 //); 60 var obj = { 61 event: 'virtual_pageview', 62 pageTitle: document.title, 63 documentLocation: window.location.href, 64 originalLocation: window.location.href, 65 pagePath: 66 /* pathname ||*/ 67 window.location.pathname + window.location.search // hostname: window.location.hostname, 68 69 }; 70 Object.assign(obj, window.dataLayerData); 71 return push_(obj); 72 }; 73 74 GtmService.pageViewFilters = function pageViewFilters(cat, filters) { 75 76 var _loop = function _loop(key) { 77 var textValue = ''; 78 var filterValue = filters[key].value; 79 80 if (filterValue) { 81 var selectedOption = filters[key].options.find(function (option) { 82 return option.value === filterValue; 83 }); 84 85 if (selectedOption) { 86 textValue = selectedOption.label; 87 } 88 } 89 var name = filters[key].key 90 /* se array di filtri */ 91 || key 92 /* se oggetto filtro */ 93 ; 94 if (name) name = encodeURIComponent(name) + '-'; 95 }; 96 97 for (var key in filters) { 98 _loop(key); 99 } //const pathname = any ? `?cat=${cat}&s=${values.join('_')}` : ''; 100 // console.log("..." + cat + "-" + ss); 101 // GtmService.pageView(window.location.pathname + pathname); 102 103 }; 104 105 GtmService.push = function push(event) { 106 return push_(event); 107 }; 108 109 return GtmService; 110 }(); 111 112 /* jshint esversion: 6 */ 113 114 var CollectionsCtrl = /*#__PURE__*/function () { 115 function CollectionsCtrl($scope, $timeout, LocationService) { 116 this.$scope = $scope; 117 this.$timeout = $timeout; 118 this.locationService = LocationService; 119 this.filters = window.filters || {}; 120 this.collections = window.collections || []; 121 this.selectedFilters = []; // this.initData__(); 122 123 this.deserializeFilters(); 124 this.applyFilters(); 125 this.$scope.toggle = true; 126 } 127 128 var _proto = CollectionsCtrl.prototype; 129 130 _proto.deserializeFilters = function deserializeFilters() { 131 var _this = this; 132 133 var locationFilters = this.locationService.deserialize('filters') || {}; 134 Object.keys(this.filters).forEach(function (x) { 135 var filter = _this.filters[x]; 136 137 switch (x) { 138 default: 139 filter.doFilter = function (item, value) { 140 var features = item[x]; 141 return features.indexOf(value) !== -1; 142 }; 143 144 } 145 146 filter.options.unshift({ 147 label: _this.filters[x].placeholder, 148 value: null 149 }); 150 var selectedValue = locationFilters[x] || filter.value || null; 151 var selectedOption = filter.options.find(function (o) { 152 return Boolean(o.value === selectedValue); 153 }); 154 filter.value = selectedOption.value; 155 filter.placeholder = selectedOption.label; 156 }); 157 return filters; 158 }; 159 160 _proto.serializeFilters = function serializeFilters() { 161 var _this2 = this; 162 163 var filters = {};
164 Object.keys(this.filters).forEach(function (x) { 165 var filter = _this2.filters[x]; 166 167 if (filter.value !== null) { 168 filters[x] = filter.value; 169 } 170 }); // console.log('ReferenceCtrl.serializeFilters', filters); 171 // this.locationService.serialize('filters', filters); 172 173 return filters; 174 }; 175 176 _proto.setFilteredImage = function setFilteredImage(item, filter) { 177 var filteredImage = Object.keys(item.filter_images).reduce(function (p, image) { 178 var imageFeatures = item.filter_images[image]; 179 var hasImageFeature = imageFeatures.indexOf(filter.value) !== -1; 180 /* 181 if (hasImageFeature) { 182 console.log(hasImageFeature, filter.value, imageFeatures); 183 } 184 */ 185 186 return hasImageFeature ? image : p; 187 }, undefined); 188 item.filteredImage = filteredImage || item.filteredImage; 189 }; 190 191 _proto.applyFilters = function applyFilters() { 192 var _this3 = this; 193 194 this.serializeFilters(); 195 var selectedFilters = Object.keys(this.filters).map(function (x) { 196 return _this3.filters[x]; 197 }).filter(function (x) { 198 return x.value !== null; 199 }); 200 var filteredItems = this.collections.slice(); // console.log('selectedFilters', selectedFilters.map(x => x.value).join(', ')); 201 202 if (selectedFilters.length) { 203 filteredItems = filteredItems.filter(function (item) { 204 item.filteredImage = item.image; 205 var has = true; 206 selectedFilters.forEach(function (filter) { 207 var hasFilter = filter.doFilter(item, filter.value); 208 209 if (hasFilter) { 210 _this3.setFilteredImage(item, filter); 211 } 212 213 has = has && hasFilter; 214 }); 215 return has; 216 }); 217 } else { 218 filteredItems.forEach(function (item) { 219 return item.filteredImage = item.image; 220 }); 221 } // console.log(filteredItems, selectedFilters); 222 223 224 this.selectedFilters = selectedFilters; 225 this.filteredItems = []; 226 this.$timeout(function () { 227 _this3.filteredItems = filteredItems; 228 229 _this3.updateFilterStates(filteredItems); // delayer for image update 230 231 }, 50); //GtmService.pageViewFilters(GTM_CAT, this.filters); 232 }; 233 234 _proto.updateFilterStates = function updateFilterStates(items) { 235 var _this4 = this; 236 237 // console.log('updateFilterStates', items); 238 Object.keys(this.filters).forEach(function (x) { 239 var filter = _this4.filters[x]; 240 filter.options.forEach(function (option) { 241 var has = false; 242 243 if (option.value) { 244 var i = 0; 245 246 while (i < items.length && !has) { 247 var item = items[i]; 248 has = filter.doFilter(item, option.value); 249 i++; 250 } 251 } else { 252 has = true; 253 } 254 255 option.disabled = !has; 256 }); // console.log(filter.options); 257 }); 258 }; 259 260 _proto.setFilter = function setFilter(item, filter) { 261 item = item || filter.options[0]; 262 filter.value = item.value; 263 filter.placeholder = item.label; 264 this.applyFilters(); 265 this.$scope.$broadcast('onCloseDropdown'); 266 }; 267 268 _proto.removeFilter = function removeFilter(filter) { 269 console.log('removeFilter called with:', filter); 270 this.setFilter(null, filter); 271 } // Gestisce eventi tastiera per la rimozione dei filtri 272 ; 273 274 _proto.handleFilterKeyDown = function handleFilterKeyDown(event, filter, action) { 275 if (action === void 0) { 276 action = 'remove'; 277 } 278 279 console.log('handleFilterKeyDown called:', event.key, action, filter); 280 281 if (event.key === 'Enter' || event.key === ' ') { 282 event.preventDefault(); 283 event.stopPropagation(); 284 console.log('Key pressed, executing action:', action); 285 286 if (action === 'remove') { 287 this.removeFilter(filter); 288 } else if (action === 'removeAll') { 289 this.removeAll(); 290 } 291 } 292 }; 293 294 _proto.removeAll = function removeAll() { 295 var _this5 = this; 296 297 var removing = {}; 298 Object.keys(this.filters).forEach(function (key) { 299 removing[key] = _this5.filters[key]; 300 }); 301 Object.keys(removing).forEach(function (key) { 302 var filter = removing[key]; 303 304 _this5.removeFilter(filter); 305 }); 306 this.applyFilters(); 307 }; 308 309 _proto.initData__ = function initData__() { 310 var _this6 = this; 311 312 // options > label, value (id) 313 var uid = 1; 314 315 var getStoredValue = function getStoredValue(items, label) { 316 return items.find(function (x) { 317 return x.label === label; 318 }); 319 }; 320 321 var toTitleCase = function toTitleCase(text) { 322 return text.replace(/-/g, ' ').replace(/\w\S*/g, function (txt) { 323 return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); 324 }); 325 }; 326
327 Object.keys(this.filters).forEach(function (key) { 328 var filter = _this6.filters[key]; 329 var options = filter.options; 330 331 _this6.collections.forEach(function (x) { 332 var values = x[key]; 333 334 if (values) { 335 x[key] = values.map(function (value) { 336 var label = toTitleCase(value); 337 var storedValue = getStoredValue(options, label); 338 var id; 339 340 if (storedValue !== undefined) { 341 id = storedValue.value; 342 } else { 343 id = uid++; 344 options.push({ 345 label: label, 346 value: id 347 }); 348 } 349 350 return id; 351 }); 352 } 353 }); 354 }); 355 console.log(JSON.stringify(this.filters)); 356 console.log(JSON.stringify(this.collections)); 357 }; 358 359 _proto.toggleFilter = function toggleFilter() { 360 this.$scope.toggle = this.$scope.toggle === false ? true : false; 361 }; 362 363 return CollectionsCtrl; 364 }(); 365 366 CollectionsCtrl.$inject = ['$scope', '$timeout', 'LocationService']; 367 368 function _defineProperties(target, props) { 369 for (var i = 0; i < props.length; i++) { 370 var descriptor = props[i]; 371 descriptor.enumerable = descriptor.enumerable || false; 372 descriptor.configurable = true; 373 if ("value" in descriptor) descriptor.writable = true; 374 Object.defineProperty(target, descriptor.key, descriptor); 375 } 376 } 377 378 function _createClass(Constructor, protoProps, staticProps) { 379 if (protoProps) _defineProperties(Constructor.prototype, protoProps); 380 if (staticProps) _defineProperties(Constructor, staticProps); 381 Object.defineProperty(Constructor, "prototype", { 382 writable: false 383 }); 384 return Constructor; 385 } 386 387 function _defineProperty(obj, key, value) { 388 if (key in obj) { 389 Object.defineProperty(obj, key, { 390 value: value, 391 enumerable: true, 392 configurable: true, 393 writable: true 394 }); 395 } else { 396 obj[key] = value; 397 } 398 399 return obj; 400 } 401 402 function _inheritsLoose(subClass, superClass) { 403 subClass.prototype = Object.create(superClass.prototype); 404 subClass.prototype.constructor = subClass; 405 406 _setPrototypeOf(subClass, superClass); 407 } 408 409 function _setPrototypeOf(o, p) { 410 _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { 411 o.__proto__ = p; 412 return o; 413 }; 414 415 return _setPrototypeOf(o, p); 416 } 417 418 function _unsupportedIterableToArray(o, minLen) { 419 if (!o) return; 420 if (typeof o === "string") return _arrayLikeToArray(o, minLen); 421 var n = Object.prototype.toString.call(o).slice(8, -1); 422 if (n === "Object" && o.constructor) n = o.constructor.name; 423 if (n === "Map" || n === "Set") return Array.from(o); 424 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); 425 } 426 427 function _arrayLikeToArray(arr, len) { 428 if (len == null || len > arr.length) len = arr.length; 429 430 for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; 431 432 return arr2; 433 } 434 435 function _createForOfIteratorHelperLoose(o, allowArrayLike) { 436 var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; 437 if (it) return (it = it.call(o)).next.bind(it); 438 439 if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { 440 if (it) o = it; 441 var i = 0; 442 return function () { 443 if (i >= o.length) return { 444 done: true 445 }; 446 return { 447 done: false, 448 value: o[i++] 449 }; 450 }; 451 } 452 453 throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); 454 } 455 456 /*! ***************************************************************************** 457 Copyright (c) Microsoft Corporation. All rights reserved. 458 Licensed under the Apache License, Version 2.0 (the "License"); you may not use 459 this file except in compliance with the License. You may obtain a copy of the 460 License at http://www.apache.org/licenses/LICENSE-2.0 461 462 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 463 KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 464 WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 465 MERCHANTABLITY OR NON-INFRINGEMENT. 466 467 See the Apache Version 2.0 License for specific language governing permissions 468 and limitations under the License. 469 ***************************************************************************** */ 470 471 /* global Reflect, Promise */ 472 var _extendStatics = function extendStatics(d, b) { 473 _extendStatics = Object.setPrototypeOf || { 474 __proto__: [] 475 } instanceof Array && function (d, b) { 476 d.__proto__ = b; 477 } || function (d, b) { 478 for (var p in b) { 479 if (b.hasOwnProperty(p)) d[p] = b[p]; 480 } 481 }; 482 483 return _extendStatics(d, b); 484 }; 485 486 function __extends(d, b) { 487 _extendStatics(d, b); 488 489 function __() { 490 this.constructor = d; 491 } 492 493 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 494 } 495 496 /** PURE_IMPORTS_START PURE_IMPORTS_END */ 497 function isFunction(x) { 498 return typeof x === 'function'; 499 } 500 501 /** PURE_IMPORTS_START PURE_IMPORTS_END */ 502 var _enable_super_gross_mode_that_will_cause_bad_things = false;
503 var config = { 504 Promise: undefined, 505 506 set useDeprecatedSynchronousErrorHandling(value) { 507 if (value) { 508 var error = /*@__PURE__*/new Error(); 509 /*@__PURE__*/ 510 511 console.warn('DEPRECATED! RxJS was set to use deprecated synchronous error handling behavior by code at: \n' + error.stack); 512 } 513 514 _enable_super_gross_mode_that_will_cause_bad_things = value; 515 }, 516 517 get useDeprecatedSynchronousErrorHandling() { 518 return _enable_super_gross_mode_that_will_cause_bad_things; 519 } 520 521 }; 522 523 /** PURE_IMPORTS_START PURE_IMPORTS_END */ 524 function hostReportError(err) { 525 setTimeout(function () { 526 throw err; 527 }); 528 } 529 530 /** PURE_IMPORTS_START _config,_util_hostReportError PURE_IMPORTS_END */ 531 var empty = { 532 closed: true, 533 next: function next(value) {}, 534 error: function error(err) { 535 if (config.useDeprecatedSynchronousErrorHandling) { 536 throw err; 537 } else { 538 hostReportError(err); 539 } 540 }, 541 complete: function complete() {} 542 }; 543 544 /** PURE_IMPORTS_START PURE_IMPORTS_END */ 545 var isArray = Array.isArray || function (x) { 546 return x && typeof x.length === 'number'; 547 }; 548 549 /** PURE_IMPORTS_START PURE_IMPORTS_END */ 550 function isObject(x) { 551 return x !== null && typeof x === 'object'; 552 } 553 554 /** PURE_IMPORTS_START PURE_IMPORTS_END */ 555 function UnsubscriptionErrorImpl(errors) { 556 Error.call(this); 557 this.message = errors ? errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) { 558 return i + 1 + ") " + err.toString(); 559 }).join('\n ') : ''; 560 this.name = 'UnsubscriptionError'; 561 this.errors = errors; 562 return this; 563 } 564 565 UnsubscriptionErrorImpl.prototype = /*@__PURE__*/Object.create(Error.prototype); 566 var UnsubscriptionError = UnsubscriptionErrorImpl; 567 568 /** PURE_IMPORTS_START _util_isArray,_util_isObject,_util_isFunction,_util_UnsubscriptionError PURE_IMPORTS_END */ 569 570 var Subscription = /*@__PURE__*/function () { 571 function Subscription(unsubscribe) { 572 this.closed = false; 573 this._parent = null; 574 this._parents = null; 575 this._subscriptions = null; 576 577 if (unsubscribe) { 578 this._unsubscribe = unsubscribe; 579 } 580 } 581 582 Subscription.prototype.unsubscribe = function () { 583 var hasErrors = false; 584 var errors; 585 586 if (this.closed) { 587 return; 588 } 589 590 var _a = this, 591 _parent = _a._parent, 592 _parents = _a._parents, 593 _unsubscribe = _a._unsubscribe, 594 _subscriptions = _a._subscriptions; 595 596 this.closed = true; 597 this._parent = null; 598 this._parents = null; 599 this._subscriptions = null; 600 var index = -1; 601 var len = _parents ? _parents.length : 0; 602 603 while (_parent) { 604 _parent.remove(this); 605 606 _parent = ++index < len && _parents[index] || null; 607 } 608 609 if (isFunction(_unsubscribe)) { 610 try { 611 _unsubscribe.call(this); 612 } catch (e) { 613 hasErrors = true; 614 errors = e instanceof UnsubscriptionError ? flattenUnsubscriptionErrors(e.errors) : [e]; 615 } 616 } 617 618 if (isArray(_subscriptions)) { 619 index = -1; 620 len = _subscriptions.length; 621 622 while (++index < len) { 623 var sub = _subscriptions[index]; 624 625 if (isObject(sub)) { 626 try { 627 sub.unsubscribe(); 628 } catch (e) { 629 hasErrors = true; 630 errors = errors || []; 631 632 if (e instanceof UnsubscriptionError) { 633 errors = errors.concat(flattenUnsubscriptionErrors(e.errors)); 634 } else { 635 errors.push(e); 636 } 637 } 638 } 639 } 640 } 641 642 if (hasErrors) { 643 throw new UnsubscriptionError(errors); 644 } 645 }; 646 647 Subscription.prototype.add = function (teardown) { 648 var subscription = teardown; 649 650 switch (typeof teardown) { 651 case 'function': 652 subscription = new Subscription(teardown); 653 654 case 'object': 655 if (subscription === this || subscription.closed || typeof subscription.unsubscribe !== 'function') { 656 return subscription; 657 } else if (this.closed) { 658 subscription.unsubscribe(); 659 return subscription; 660 } else if (!(subscription instanceof Subscription)) { 661 var tmp = subscription; 662 subscription = new Subscription(); 663 subscription._subscriptions = [tmp]; 664 } 665 666 break; 667 668 default: 669 { 670 if (!teardown) { 671 return Subscription.EMPTY; 672 } 673 674 throw new Error('unrecognized teardown ' + teardown + ' added to Subscription.'); 675 } 676 } 677 678 if (subscription._addParent(this)) { 679 var subscriptions = this._subscriptions; 680 681 if (subscriptions) { 682 subscriptions.push(subscription); 683 } else { 684 this._subscriptions = [subscription]; 685 } 686 } 687 688 return subscription; 689 }; 690 691 Subscription.prototype.remove = function (subscription) { 692 var subscriptions = this._subscriptions; 693 694 if (subscriptions) { 695 var subscriptionIndex = subscriptions.indexOf(subscription); 696 697 if (subscriptionIndex !== -1) { 698 subscriptions.splice(subscriptionIndex, 1); 699 } 700 } 701 }; 702 703 Subscription.prototype._addParent = function (parent) { 704 var _a = this, 705 _parent = _a._parent, 706 _parents = _a._parents; 707 708 if (_parent === parent) { 709 return false;
vendor: 7,768 bytes, lines 710-1003
710 } else if (!_parent) { 711 this._parent = parent; 712 return true; 713 } else if (!_parents) { 714 this._parents = [parent]; 715 return true; 716 } else if (_parents.indexOf(parent) === -1) { 717 _parents.push(parent); 718 719 return true; 720 } 721 722 return false; 723 }; 724 725 Subscription.EMPTY = function (empty) { 726 empty.closed = true; 727 return empty; 728 }(new Subscription()); 729 730 return Subscription; 731 }(); 732 733 function flattenUnsubscriptionErrors(errors) { 734 return errors.reduce(function (errs, err) { 735 return errs.concat(err instanceof UnsubscriptionError ? err.errors : err); 736 }, []); 737 } 738 739 /** PURE_IMPORTS_START PURE_IMPORTS_END */ 740 var rxSubscriber = typeof Symbol === 'function' ? /*@__PURE__*/Symbol('rxSubscriber') : '@@rxSubscriber_' + /*@__PURE__*/Math.random(); 741 742 /** PURE_IMPORTS_START tslib,_util_isFunction,_Observer,_Subscription,_internal_symbol_rxSubscriber,_config,_util_hostReportError PURE_IMPORTS_END */ 743 744 var Subscriber = /*@__PURE__*/function (_super) { 745 __extends(Subscriber, _super); 746 747 function Subscriber(destinationOrNext, error, complete) { 748 var _this = _super.call(this) || this; 749 750 _this.syncErrorValue = null; 751 _this.syncErrorThrown = false; 752 _this.syncErrorThrowable = false; 753 _this.isStopped = false; 754 755 switch (arguments.length) { 756 case 0: 757 _this.destination = empty; 758 break; 759 760 case 1: 761 if (!destinationOrNext) { 762 _this.destination = empty; 763 break; 764 } 765 766 if (typeof destinationOrNext === 'object') { 767 if (destinationOrNext instanceof Subscriber) { 768 _this.syncErrorThrowable = destinationOrNext.syncErrorThrowable; 769 _this.destination = destinationOrNext; 770 destinationOrNext.add(_this); 771 } else { 772 _this.syncErrorThrowable = true; 773 _this.destination = new SafeSubscriber(_this, destinationOrNext); 774 } 775 776 break; 777 } 778 779 default: 780 _this.syncErrorThrowable = true; 781 _this.destination = new SafeSubscriber(_this, destinationOrNext, error, complete); 782 break; 783 } 784 785 return _this; 786 } 787 788 Subscriber.prototype[rxSubscriber] = function () { 789 return this; 790 }; 791 792 Subscriber.create = function (next, error, complete) { 793 var subscriber = new Subscriber(next, error, complete); 794 subscriber.syncErrorThrowable = false; 795 return subscriber; 796 }; 797 798 Subscriber.prototype.next = function (value) { 799 if (!this.isStopped) { 800 this._next(value); 801 } 802 }; 803 804 Subscriber.prototype.error = function (err) { 805 if (!this.isStopped) { 806 this.isStopped = true; 807 808 this._error(err); 809 } 810 }; 811 812 Subscriber.prototype.complete = function () { 813 if (!this.isStopped) { 814 this.isStopped = true; 815 816 this._complete(); 817 } 818 }; 819 820 Subscriber.prototype.unsubscribe = function () { 821 if (this.closed) { 822 return; 823 } 824 825 this.isStopped = true; 826 827 _super.prototype.unsubscribe.call(this); 828 }; 829 830 Subscriber.prototype._next = function (value) { 831 this.destination.next(value); 832 }; 833 834 Subscriber.prototype._error = function (err) { 835 this.destination.error(err); 836 this.unsubscribe(); 837 }; 838 839 Subscriber.prototype._complete = function () { 840 this.destination.complete(); 841 this.unsubscribe(); 842 }; 843 844 Subscriber.prototype._unsubscribeAndRecycle = function () { 845 var _a = this, 846 _parent = _a._parent, 847 _parents = _a._parents; 848 849 this._parent = null; 850 this._parents = null; 851 this.unsubscribe(); 852 this.closed = false; 853 this.isStopped = false; 854 this._parent = _parent; 855 this._parents = _parents; 856 return this; 857 }; 858 859 return Subscriber; 860 }(Subscription); 861 862 var SafeSubscriber = /*@__PURE__*/function (_super) { 863 __extends(SafeSubscriber, _super); 864 865 function SafeSubscriber(_parentSubscriber, observerOrNext, error, complete) { 866 var _this = _super.call(this) || this; 867 868 _this._parentSubscriber = _parentSubscriber; 869 var next; 870 var context = _this; 871 872 if (isFunction(observerOrNext)) { 873 next = observerOrNext; 874 } else if (observerOrNext) { 875 next = observerOrNext.next; 876 error = observerOrNext.error; 877 complete = observerOrNext.complete; 878 879 if (observerOrNext !== empty) { 880 context = Object.create(observerOrNext); 881 882 if (isFunction(context.unsubscribe)) { 883 _this.add(context.unsubscribe.bind(context)); 884 } 885 886 context.unsubscribe = _this.unsubscribe.bind(_this); 887 } 888 } 889 890 _this._context = context; 891 _this._next = next; 892 _this._error = error; 893 _this._complete = complete; 894 return _this; 895 } 896 897 SafeSubscriber.prototype.next = function (value) { 898 if (!this.isStopped && this._next) { 899 var _parentSubscriber = this._parentSubscriber; 900 901 if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) { 902 this.__tryOrUnsub(this._next, value); 903 } else if (this.__tryOrSetError(_parentSubscriber, this._next, value)) { 904 this.unsubscribe(); 905 } 906 } 907 }; 908 909 SafeSubscriber.prototype.error = function (err) { 910 if (!this.isStopped) { 911 var _parentSubscriber = this._parentSubscriber; 912 var useDeprecatedSynchronousErrorHandling = config.useDeprecatedSynchronousErrorHandling; 913 914 if (this._error) { 915 if (!useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) { 916 this.__tryOrUnsub(this._error, err); 917 918 this.unsubscribe(); 919 } else { 920 this.__tryOrSetError(_parentSubscriber, this._error, err); 921 922 this.unsubscribe(); 923 } 924 } else if (!_parentSubscriber.syncErrorThrowable) { 925 this.unsubscribe(); 926 927 if (useDeprecatedSynchronousErrorHandling) { 928 throw err; 929 } 930 931 hostReportError(err); 932 } else { 933 if (useDeprecatedSynchronousErrorHandling) { 934 _parentSubscriber.syncErrorValue = err; 935 _parentSubscriber.syncErrorThrown = true; 936 } else { 937 hostReportError(err); 938 } 939 940 this.unsubscribe(); 941 } 942 } 943 }; 944 945 SafeSubscriber.prototype.complete = function () { 946 var _this = this; 947 948 if (!this.isStopped) { 949 var _parentSubscriber = this._parentSubscriber; 950 951 if (this._complete) { 952 var wrappedComplete = function wrappedComplete() { 953 return _this._complete.call(_this._context); 954 }; 955 956 if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) { 957 this.__tryOrUnsub(wrappedComplete); 958 959 this.unsubscribe(); 960 } else { 961 this.__tryOrSetError(_parentSubscriber, wrappedComplete); 962 963 this.unsubscribe(); 964 } 965 } else { 966 this.unsubscribe(); 967 } 968 } 969 }; 970 971 SafeSubscriber.prototype.__tryOrUnsub = function (fn, value) { 972 try { 973 fn.call(this._context, value); 974 } catch (err) { 975 this.unsubscribe(); 976 977 if (config.useDeprecatedSynchronousErrorHandling) { 978 throw err; 979 } else { 980 hostReportError(err); 981 } 982 } 983 }; 984 985 SafeSubscriber.prototype.__tryOrSetError = function (parent, fn, value) { 986 if (!config.useDeprecatedSynchronousErrorHandling) { 987 throw new Error('bad call'); 988 } 989 990 try { 991 fn.call(this._context, value); 992 } catch (err) { 993 if (config.useDeprecatedSynchronousErrorHandling) { 994 parent.syncErrorValue = err; 995 parent.syncErrorThrown = true; 996 return true; 997 } else { 998 hostReportError(err); 999 return true; 1000 } 1001 } 1002 1003 return false;
1004 }; 1005 1006 SafeSubscriber.prototype._unsubscribe = function () { 1007 var _parentSubscriber = this._parentSubscriber; 1008 this._context = null; 1009 this._parentSubscriber = null; 1010 1011 _parentSubscriber.unsubscribe(); 1012 }; 1013 1014 return SafeSubscriber; 1015 }(Subscriber); 1016 1017 /** PURE_IMPORTS_START _Subscriber PURE_IMPORTS_END */ 1018 function canReportError(observer) { 1019 while (observer) { 1020 var _a = observer, 1021 closed_1 = _a.closed, 1022 destination = _a.destination, 1023 isStopped = _a.isStopped; 1024 1025 if (closed_1 || isStopped) { 1026 return false; 1027 } else if (destination && destination instanceof Subscriber) { 1028 observer = destination; 1029 } else { 1030 observer = null; 1031 } 1032 } 1033 1034 return true; 1035 } 1036 1037 /** PURE_IMPORTS_START _Subscriber,_symbol_rxSubscriber,_Observer PURE_IMPORTS_END */ 1038 function toSubscriber(nextOrObserver, error, complete) { 1039 if (nextOrObserver) { 1040 if (nextOrObserver instanceof Subscriber) { 1041 return nextOrObserver; 1042 } 1043 1044 if (nextOrObserver[rxSubscriber]) { 1045 return nextOrObserver[rxSubscriber](); 1046 } 1047 } 1048 1049 if (!nextOrObserver && !error && !complete) { 1050 return new Subscriber(empty); 1051 } 1052 1053 return new Subscriber(nextOrObserver, error, complete); 1054 } 1055 1056 /** PURE_IMPORTS_START PURE_IMPORTS_END */ 1057 var observable = typeof Symbol === 'function' && Symbol.observable || '@@observable'; 1058 1059 /** PURE_IMPORTS_START PURE_IMPORTS_END */ 1060 function noop() {} 1061 1062 /** PURE_IMPORTS_START _noop PURE_IMPORTS_END */ 1063 function pipeFromArray(fns) { 1064 if (!fns) { 1065 return noop; 1066 } 1067 1068 if (fns.length === 1) { 1069 return fns[0]; 1070 } 1071 1072 return function piped(input) { 1073 return fns.reduce(function (prev, fn) { 1074 return fn(prev); 1075 }, input); 1076 }; 1077 } 1078 1079 /** PURE_IMPORTS_START _util_canReportError,_util_toSubscriber,_internal_symbol_observable,_util_pipe,_config PURE_IMPORTS_END */ 1080 1081 var Observable = /*@__PURE__*/function () { 1082 function Observable(subscribe) { 1083 this._isScalar = false; 1084 1085 if (subscribe) { 1086 this._subscribe = subscribe; 1087 } 1088 } 1089 1090 Observable.prototype.lift = function (operator) { 1091 var observable = new Observable(); 1092 observable.source = this; 1093 observable.operator = operator; 1094 return observable; 1095 }; 1096 1097 Observable.prototype.subscribe = function (observerOrNext, error, complete) { 1098 var operator = this.operator; 1099 var sink = toSubscriber(observerOrNext, error, complete); 1100 1101 if (operator) { 1102 sink.add(operator.call(sink, this.source)); 1103 } else { 1104 sink.add(this.source || config.useDeprecatedSynchronousErrorHandling && !sink.syncErrorThrowable ? this._subscribe(sink) : this._trySubscribe(sink)); 1105 } 1106 1107 if (config.useDeprecatedSynchronousErrorHandling) { 1108 if (sink.syncErrorThrowable) { 1109 sink.syncErrorThrowable = false; 1110 1111 if (sink.syncErrorThrown) { 1112 throw sink.syncErrorValue; 1113 } 1114 } 1115 } 1116 1117 return sink; 1118 }; 1119 1120 Observable.prototype._trySubscribe = function (sink) { 1121 try { 1122 return this._subscribe(sink); 1123 } catch (err) { 1124 if (config.useDeprecatedSynchronousErrorHandling) { 1125 sink.syncErrorThrown = true; 1126 sink.syncErrorValue = err; 1127 } 1128 1129 if (canReportError(sink)) { 1130 sink.error(err); 1131 } else { 1132 console.warn(err); 1133 } 1134 } 1135 }; 1136 1137 Observable.prototype.forEach = function (next, promiseCtor) { 1138 var _this = this; 1139 1140 promiseCtor = getPromiseCtor(promiseCtor); 1141 return new promiseCtor(function (resolve, reject) { 1142 var subscription; 1143 subscription = _this.subscribe(function (value) { 1144 try { 1145 next(value); 1146 } catch (err) { 1147 reject(err); 1148 1149 if (subscription) { 1150 subscription.unsubscribe(); 1151 } 1152 } 1153 }, reject, resolve); 1154 }); 1155 }; 1156 1157 Observable.prototype._subscribe = function (subscriber) { 1158 var source = this.source; 1159 return source && source.subscribe(subscriber); 1160 }; 1161 1162 Observable.prototype[observable] = function () { 1163 return this; 1164 }; 1165 1166 Observable.prototype.pipe = function () { 1167 var operations = []; 1168 1169 for (var _i = 0; _i < arguments.length; _i++) { 1170 operations[_i] = arguments[_i]; 1171 } 1172 1173 if (operations.length === 0) { 1174 return this; 1175 } 1176 1177 return pipeFromArray(operations)(this); 1178 }; 1179 1180 Observable.prototype.toPromise = function (promiseCtor) { 1181 var _this = this; 1182 1183 promiseCtor = getPromiseCtor(promiseCtor); 1184 return new promiseCtor(function (resolve, reject) { 1185 var value; 1186 1187 _this.subscribe(function (x) { 1188 return value = x; 1189 }, function (err) { 1190 return reject(err); 1191 }, function () { 1192 return resolve(value); 1193 }); 1194 }); 1195 }; 1196 1197 Observable.create = function (subscribe) { 1198 return new Observable(subscribe); 1199 }; 1200 1201 return Observable; 1202 }(); 1203 1204 function getPromiseCtor(promiseCtor) { 1205 if (!promiseCtor) { 1206 promiseCtor = Promise; 1207 } 1208 1209 if (!promiseCtor) { 1210 throw new Error('no Promise impl found'); 1211 } 1212 1213 return promiseCtor; 1214 } 1215 1216 /** PURE_IMPORTS_START PURE_IMPORTS_END */ 1217 function ObjectUnsubscribedErrorImpl() { 1218 Error.call(this); 1219 this.message = 'object unsubscribed'; 1220 this.name = 'ObjectUnsubscribedError'; 1221 return this; 1222 } 1223 1224 ObjectUnsubscribedErrorImpl.prototype = /*@__PURE__*/Object.create(Error.prototype); 1225 var ObjectUnsubscribedError = ObjectUnsubscribedErrorImpl; 1226 1227 /** PURE_IMPORTS_START tslib,_Subscription PURE_IMPORTS_END */ 1228 1229 var SubjectSubscription = /*@__PURE__*/function (_super) { 1230 __extends(SubjectSubscription, _super); 1231 1232 function SubjectSubscription(subject, subscriber) { 1233 var _this = _super.call(this) || this; 1234 1235 _this.subject = subject; 1236 _this.subscriber = subscriber; 1237 _this.closed = false;
vendor: 11,093 bytes, lines 1238-1701
1238 return _this; 1239 } 1240 1241 SubjectSubscription.prototype.unsubscribe = function () { 1242 if (this.closed) { 1243 return; 1244 } 1245 1246 this.closed = true; 1247 var subject = this.subject; 1248 var observers = subject.observers; 1249 this.subject = null; 1250 1251 if (!observers || observers.length === 0 || subject.isStopped || subject.closed) { 1252 return; 1253 } 1254 1255 var subscriberIndex = observers.indexOf(this.subscriber); 1256 1257 if (subscriberIndex !== -1) { 1258 observers.splice(subscriberIndex, 1); 1259 } 1260 }; 1261 1262 return SubjectSubscription; 1263 }(Subscription); 1264 1265 /** PURE_IMPORTS_START tslib,_Observable,_Subscriber,_Subscription,_util_ObjectUnsubscribedError,_SubjectSubscription,_internal_symbol_rxSubscriber PURE_IMPORTS_END */ 1266 1267 var SubjectSubscriber = /*@__PURE__*/function (_super) { 1268 __extends(SubjectSubscriber, _super); 1269 1270 function SubjectSubscriber(destination) { 1271 var _this = _super.call(this, destination) || this; 1272 1273 _this.destination = destination; 1274 return _this; 1275 } 1276 1277 return SubjectSubscriber; 1278 }(Subscriber); 1279 1280 var Subject = /*@__PURE__*/function (_super) { 1281 __extends(Subject, _super); 1282 1283 function Subject() { 1284 var _this = _super.call(this) || this; 1285 1286 _this.observers = []; 1287 _this.closed = false; 1288 _this.isStopped = false; 1289 _this.hasError = false; 1290 _this.thrownError = null; 1291 return _this; 1292 } 1293 1294 Subject.prototype[rxSubscriber] = function () { 1295 return new SubjectSubscriber(this); 1296 }; 1297 1298 Subject.prototype.lift = function (operator) { 1299 var subject = new AnonymousSubject(this, this); 1300 subject.operator = operator; 1301 return subject; 1302 }; 1303 1304 Subject.prototype.next = function (value) { 1305 if (this.closed) { 1306 throw new ObjectUnsubscribedError(); 1307 } 1308 1309 if (!this.isStopped) { 1310 var observers = this.observers; 1311 var len = observers.length; 1312 var copy = observers.slice(); 1313 1314 for (var i = 0; i < len; i++) { 1315 copy[i].next(value); 1316 } 1317 } 1318 }; 1319 1320 Subject.prototype.error = function (err) { 1321 if (this.closed) { 1322 throw new ObjectUnsubscribedError(); 1323 } 1324 1325 this.hasError = true; 1326 this.thrownError = err; 1327 this.isStopped = true; 1328 var observers = this.observers; 1329 var len = observers.length; 1330 var copy = observers.slice(); 1331 1332 for (var i = 0; i < len; i++) { 1333 copy[i].error(err); 1334 } 1335 1336 this.observers.length = 0; 1337 }; 1338 1339 Subject.prototype.complete = function () { 1340 if (this.closed) { 1341 throw new ObjectUnsubscribedError(); 1342 } 1343 1344 this.isStopped = true; 1345 var observers = this.observers; 1346 var len = observers.length; 1347 var copy = observers.slice(); 1348 1349 for (var i = 0; i < len; i++) { 1350 copy[i].complete(); 1351 } 1352 1353 this.observers.length = 0; 1354 }; 1355 1356 Subject.prototype.unsubscribe = function () { 1357 this.isStopped = true; 1358 this.closed = true; 1359 this.observers = null; 1360 }; 1361 1362 Subject.prototype._trySubscribe = function (subscriber) { 1363 if (this.closed) { 1364 throw new ObjectUnsubscribedError(); 1365 } else { 1366 return _super.prototype._trySubscribe.call(this, subscriber); 1367 } 1368 }; 1369 1370 Subject.prototype._subscribe = function (subscriber) { 1371 if (this.closed) { 1372 throw new ObjectUnsubscribedError(); 1373 } else if (this.hasError) { 1374 subscriber.error(this.thrownError); 1375 return Subscription.EMPTY; 1376 } else if (this.isStopped) { 1377 subscriber.complete(); 1378 return Subscription.EMPTY; 1379 } else { 1380 this.observers.push(subscriber); 1381 return new SubjectSubscription(this, subscriber); 1382 } 1383 }; 1384 1385 Subject.prototype.asObservable = function () { 1386 var observable = new Observable(); 1387 observable.source = this; 1388 return observable; 1389 }; 1390 1391 Subject.create = function (destination, source) { 1392 return new AnonymousSubject(destination, source); 1393 }; 1394 1395 return Subject; 1396 }(Observable); 1397 1398 var AnonymousSubject = /*@__PURE__*/function (_super) { 1399 __extends(AnonymousSubject, _super); 1400 1401 function AnonymousSubject(destination, source) { 1402 var _this = _super.call(this) || this; 1403 1404 _this.destination = destination; 1405 _this.source = source; 1406 return _this; 1407 } 1408 1409 AnonymousSubject.prototype.next = function (value) { 1410 var destination = this.destination; 1411 1412 if (destination && destination.next) { 1413 destination.next(value); 1414 } 1415 }; 1416 1417 AnonymousSubject.prototype.error = function (err) { 1418 var destination = this.destination; 1419 1420 if (destination && destination.error) { 1421 this.destination.error(err); 1422 } 1423 }; 1424 1425 AnonymousSubject.prototype.complete = function () { 1426 var destination = this.destination; 1427 1428 if (destination && destination.complete) { 1429 this.destination.complete(); 1430 } 1431 }; 1432 1433 AnonymousSubject.prototype._subscribe = function (subscriber) { 1434 var source = this.source; 1435 1436 if (source) { 1437 return this.source.subscribe(subscriber); 1438 } else { 1439 return Subscription.EMPTY; 1440 } 1441 }; 1442 1443 return AnonymousSubject; 1444 }(Subject); 1445 1446 /** PURE_IMPORTS_START tslib,_Subject,_util_ObjectUnsubscribedError PURE_IMPORTS_END */ 1447 1448 var BehaviorSubject = /*@__PURE__*/function (_super) { 1449 __extends(BehaviorSubject, _super); 1450 1451 function BehaviorSubject(_value) { 1452 var _this = _super.call(this) || this; 1453 1454 _this._value = _value; 1455 return _this; 1456 } 1457 1458 Object.defineProperty(BehaviorSubject.prototype, "value", { 1459 get: function get() { 1460 return this.getValue(); 1461 }, 1462 enumerable: true, 1463 configurable: true 1464 }); 1465 1466 BehaviorSubject.prototype._subscribe = function (subscriber) { 1467 var subscription = _super.prototype._subscribe.call(this, subscriber); 1468 1469 if (subscription && !subscription.closed) { 1470 subscriber.next(this._value); 1471 } 1472 1473 return subscription; 1474 }; 1475 1476 BehaviorSubject.prototype.getValue = function () { 1477 if (this.hasError) { 1478 throw this.thrownError; 1479 } else if (this.closed) { 1480 throw new ObjectUnsubscribedError(); 1481 } else { 1482 return this._value; 1483 } 1484 }; 1485 1486 BehaviorSubject.prototype.next = function (value) { 1487 _super.prototype.next.call(this, this._value = value); 1488 }; 1489 1490 return BehaviorSubject; 1491 }(Subject); 1492 1493 /** PURE_IMPORTS_START tslib,_Subscription PURE_IMPORTS_END */ 1494 1495 var Action = /*@__PURE__*/function (_super) { 1496 __extends(Action, _super); 1497 1498 function Action(scheduler, work) { 1499 return _super.call(this) || this; 1500 } 1501 1502 Action.prototype.schedule = function (state, delay) { 1503 1504 return this; 1505 }; 1506 1507 return Action; 1508 }(Subscription); 1509 1510 /** PURE_IMPORTS_START tslib,_Action PURE_IMPORTS_END */ 1511 1512 var AsyncAction = /*@__PURE__*/function (_super) { 1513 __extends(AsyncAction, _super); 1514 1515 function AsyncAction(scheduler, work) { 1516 var _this = _super.call(this, scheduler, work) || this; 1517 1518 _this.scheduler = scheduler; 1519 _this.work = work; 1520 _this.pending = false; 1521 return _this; 1522 } 1523 1524 AsyncAction.prototype.schedule = function (state, delay) { 1525 if (delay === void 0) { 1526 delay = 0; 1527 } 1528 1529 if (this.closed) { 1530 return this; 1531 } 1532 1533 this.state = state; 1534 var id = this.id; 1535 var scheduler = this.scheduler; 1536 1537 if (id != null) { 1538 this.id = this.recycleAsyncId(scheduler, id, delay); 1539 } 1540 1541 this.pending = true; 1542 this.delay = delay; 1543 this.id = this.id || this.requestAsyncId(scheduler, this.id, delay); 1544 return this; 1545 }; 1546 1547 AsyncAction.prototype.requestAsyncId = function (scheduler, id, delay) { 1548 if (delay === void 0) { 1549 delay = 0; 1550 } 1551 1552 return setInterval(scheduler.flush.bind(scheduler, this), delay); 1553 }; 1554 1555 AsyncAction.prototype.recycleAsyncId = function (scheduler, id, delay) { 1556 if (delay === void 0) { 1557 delay = 0; 1558 } 1559 1560 if (delay !== null && this.delay === delay && this.pending === false) { 1561 return id; 1562 } 1563 1564 clearInterval(id); 1565 return undefined; 1566 }; 1567 1568 AsyncAction.prototype.execute = function (state, delay) { 1569 if (this.closed) { 1570 return new Error('executing a cancelled action'); 1571 } 1572 1573 this.pending = false; 1574 1575 var error = this._execute(state, delay); 1576 1577 if (error) { 1578 return error; 1579 } else if (this.pending === false && this.id != null) { 1580 this.id = this.recycleAsyncId(this.scheduler, this.id, null); 1581 } 1582 }; 1583 1584 AsyncAction.prototype._execute = function (state, delay) { 1585 var errored = false; 1586 var errorValue = undefined; 1587 1588 try { 1589 this.work(state); 1590 } catch (e) { 1591 errored = true; 1592 errorValue = !!e && e || new Error(e); 1593 } 1594 1595 if (errored) { 1596 this.unsubscribe(); 1597 return errorValue; 1598 } 1599 }; 1600 1601 AsyncAction.prototype._unsubscribe = function () { 1602 var id = this.id; 1603 var scheduler = this.scheduler; 1604 var actions = scheduler.actions; 1605 var index = actions.indexOf(this); 1606 this.work = null; 1607 this.state = null; 1608 this.pending = false; 1609 this.scheduler = null; 1610 1611 if (index !== -1) { 1612 actions.splice(index, 1); 1613 } 1614 1615 if (id != null) { 1616 this.id = this.recycleAsyncId(scheduler, id, null); 1617 } 1618 1619 this.delay = null; 1620 }; 1621 1622 return AsyncAction; 1623 }(Action); 1624 1625 /** PURE_IMPORTS_START tslib,_AsyncAction PURE_IMPORTS_END */ 1626 1627 var QueueAction = /*@__PURE__*/function (_super) { 1628 __extends(QueueAction, _super); 1629 1630 function QueueAction(scheduler, work) { 1631 var _this = _super.call(this, scheduler, work) || this; 1632 1633 _this.scheduler = scheduler; 1634 _this.work = work; 1635 return _this; 1636 } 1637 1638 QueueAction.prototype.schedule = function (state, delay) { 1639 if (delay === void 0) { 1640 delay = 0; 1641 } 1642 1643 if (delay > 0) { 1644 return _super.prototype.schedule.call(this, state, delay); 1645 } 1646 1647 this.delay = delay; 1648 this.state = state; 1649 this.scheduler.flush(this); 1650 return this; 1651 }; 1652 1653 QueueAction.prototype.execute = function (state, delay) { 1654 return delay > 0 || this.closed ? _super.prototype.execute.call(this, state, delay) : this._execute(state, delay); 1655 }; 1656 1657 QueueAction.prototype.requestAsyncId = function (scheduler, id, delay) { 1658 if (delay === void 0) { 1659 delay = 0; 1660 } 1661 1662 if (delay !== null && delay > 0 || delay === null && this.delay > 0) { 1663 return _super.prototype.requestAsyncId.call(this, scheduler, id, delay); 1664 } 1665 1666 return scheduler.flush(this); 1667 }; 1668 1669 return QueueAction; 1670 }(AsyncAction); 1671 1672 var Scheduler = /*@__PURE__*/function () { 1673 function Scheduler(SchedulerAction, now) { 1674 if (now === void 0) { 1675 now = Scheduler.now; 1676 } 1677 1678 this.SchedulerAction = SchedulerAction; 1679 this.now = now; 1680 } 1681 1682 Scheduler.prototype.schedule = function (work, delay, state) { 1683 if (delay === void 0) { 1684 delay = 0; 1685 } 1686 1687 return new this.SchedulerAction(this, work).schedule(state, delay); 1688 }; 1689 1690 Scheduler.now = function () { 1691 return Date.now(); 1692 }; 1693 1694 return Scheduler; 1695 }(); 1696 1697 /** PURE_IMPORTS_START tslib,_Scheduler PURE_IMPORTS_END */ 1698 1699 var AsyncScheduler = /*@__PURE__*/function (_super) { 1700 __extends(AsyncScheduler, _super); 1701
1702 function AsyncScheduler(SchedulerAction, now) { 1703 if (now === void 0) { 1704 now = Scheduler.now; 1705 } 1706 1707 var _this = _super.call(this, SchedulerAction, function () { 1708 if (AsyncScheduler.delegate && AsyncScheduler.delegate !== _this) { 1709 return AsyncScheduler.delegate.now(); 1710 } else { 1711 return now(); 1712 } 1713 }) || this; 1714 1715 _this.actions = []; 1716 _this.active = false; 1717 _this.scheduled = undefined; 1718 return _this; 1719 } 1720 1721 AsyncScheduler.prototype.schedule = function (work, delay, state) { 1722 if (delay === void 0) { 1723 delay = 0; 1724 } 1725 1726 if (AsyncScheduler.delegate && AsyncScheduler.delegate !== this) { 1727 return AsyncScheduler.delegate.schedule(work, delay, state); 1728 } else { 1729 return _super.prototype.schedule.call(this, work, delay, state); 1730 } 1731 }; 1732 1733 AsyncScheduler.prototype.flush = function (action) { 1734 var actions = this.actions; 1735 1736 if (this.active) { 1737 actions.push(action); 1738 return; 1739 } 1740 1741 var error; 1742 this.active = true; 1743 1744 do { 1745 if (error = action.execute(action.state, action.delay)) { 1746 break; 1747 } 1748 } while (action = actions.shift()); 1749 1750 this.active = false; 1751 1752 if (error) { 1753 while (action = actions.shift()) { 1754 action.unsubscribe(); 1755 } 1756 1757 throw error; 1758 } 1759 }; 1760 1761 return AsyncScheduler; 1762 }(Scheduler); 1763 1764 /** PURE_IMPORTS_START tslib,_AsyncScheduler PURE_IMPORTS_END */ 1765 1766 var QueueScheduler = /*@__PURE__*/function (_super) { 1767 __extends(QueueScheduler, _super); 1768 1769 function QueueScheduler() { 1770 return _super !== null && _super.apply(this, arguments) || this; 1771 } 1772 1773 return QueueScheduler; 1774 }(AsyncScheduler); 1775 1776 /** PURE_IMPORTS_START _QueueAction,_QueueScheduler PURE_IMPORTS_END */ 1777 var queue = /*@__PURE__*/new QueueScheduler(QueueAction); 1778 1779 /** PURE_IMPORTS_START _Observable PURE_IMPORTS_END */ 1780 var EMPTY = /*@__PURE__*/new Observable(function (subscriber) { 1781 return subscriber.complete(); 1782 }); 1783 function empty$1(scheduler) { 1784 return scheduler ? emptyScheduled(scheduler) : EMPTY; 1785 } 1786 function emptyScheduled(scheduler) { 1787 return new Observable(function (subscriber) { 1788 return scheduler.schedule(function () { 1789 return subscriber.complete(); 1790 }); 1791 }); 1792 } 1793 1794 /** PURE_IMPORTS_START PURE_IMPORTS_END */ 1795 function isScheduler(value) { 1796 return value && typeof value.schedule === 'function'; 1797 } 1798 1799 /** PURE_IMPORTS_START PURE_IMPORTS_END */ 1800 var subscribeToArray = function subscribeToArray(array) { 1801 return function (subscriber) { 1802 for (var i = 0, len = array.length; i < len && !subscriber.closed; i++) { 1803 subscriber.next(array[i]); 1804 } 1805 1806 if (!subscriber.closed) { 1807 subscriber.complete(); 1808 } 1809 }; 1810 }; 1811 1812 /** PURE_IMPORTS_START _Observable,_Subscription,_util_subscribeToArray PURE_IMPORTS_END */ 1813 function fromArray(input, scheduler) { 1814 if (!scheduler) { 1815 return new Observable(subscribeToArray(input)); 1816 } else { 1817 return new Observable(function (subscriber) { 1818 var sub = new Subscription(); 1819 var i = 0; 1820 sub.add(scheduler.schedule(function () { 1821 if (i === input.length) { 1822 subscriber.complete(); 1823 return; 1824 } 1825 1826 subscriber.next(input[i++]); 1827 1828 if (!subscriber.closed) { 1829 sub.add(this.schedule()); 1830 } 1831 })); 1832 return sub; 1833 }); 1834 } 1835 } 1836 1837 /** PURE_IMPORTS_START _Observable PURE_IMPORTS_END */ 1838 function scalar(value) { 1839 var result = new Observable(function (subscriber) { 1840 subscriber.next(value); 1841 subscriber.complete(); 1842 }); 1843 result._isScalar = true; 1844 result.value = value; 1845 return result; 1846 } 1847 1848 /** PURE_IMPORTS_START _util_isScheduler,_fromArray,_empty,_scalar PURE_IMPORTS_END */ 1849 function of() { 1850 var args = []; 1851 1852 for (var _i = 0; _i < arguments.length; _i++) { 1853 args[_i] = arguments[_i]; 1854 } 1855 1856 var scheduler = args[args.length - 1]; 1857 1858 if (isScheduler(scheduler)) { 1859 args.pop(); 1860 } else { 1861 scheduler = undefined; 1862 } 1863 1864 switch (args.length) { 1865 case 0: 1866 return empty$1(scheduler); 1867 1868 case 1: 1869 return scheduler ? fromArray(args, scheduler) : scalar(args[0]); 1870 1871 default: 1872 return fromArray(args, scheduler); 1873 } 1874 } 1875
vendor: 13,073 bytes, lines 1876-2369
1876 /** PURE_IMPORTS_START _Observable PURE_IMPORTS_END */ 1877 function throwError(error, scheduler) { 1878 if (!scheduler) { 1879 return new Observable(function (subscriber) { 1880 return subscriber.error(error); 1881 }); 1882 } else { 1883 return new Observable(function (subscriber) { 1884 return scheduler.schedule(dispatch, 0, { 1885 error: error, 1886 subscriber: subscriber 1887 }); 1888 }); 1889 } 1890 } 1891 1892 function dispatch(_a) { 1893 var error = _a.error, 1894 subscriber = _a.subscriber; 1895 subscriber.error(error); 1896 } 1897 1898 /** PURE_IMPORTS_START _observable_empty,_observable_of,_observable_throwError PURE_IMPORTS_END */ 1899 1900 var Notification = /*@__PURE__*/function () { 1901 function Notification(kind, value, error) { 1902 this.kind = kind; 1903 this.value = value; 1904 this.error = error; 1905 this.hasValue = kind === "N"; 1906 } 1907 1908 Notification.prototype.observe = function (observer) { 1909 switch (this.kind) { 1910 case "N": 1911 return observer.next && observer.next(this.value); 1912 1913 case "E": 1914 return observer.error && observer.error(this.error); 1915 1916 case "C": 1917 return observer.complete && observer.complete(); 1918 } 1919 }; 1920 1921 Notification.prototype.do = function (next, error, complete) { 1922 var kind = this.kind; 1923 1924 switch (kind) { 1925 case "N": 1926 return next && next(this.value); 1927 1928 case "E": 1929 return error && error(this.error); 1930 1931 case "C": 1932 return complete && complete(); 1933 } 1934 }; 1935 1936 Notification.prototype.accept = function (nextOrObserver, error, complete) { 1937 if (nextOrObserver && typeof nextOrObserver.next === 'function') { 1938 return this.observe(nextOrObserver); 1939 } else { 1940 return this.do(nextOrObserver, error, complete); 1941 } 1942 }; 1943 1944 Notification.prototype.toObservable = function () { 1945 var kind = this.kind; 1946 1947 switch (kind) { 1948 case "N": 1949 return of(this.value); 1950 1951 case "E": 1952 return throwError(this.error); 1953 1954 case "C": 1955 return empty$1(); 1956 } 1957 1958 throw new Error('unexpected notification kind value'); 1959 }; 1960 1961 Notification.createNext = function (value) { 1962 if (typeof value !== 'undefined') { 1963 return new Notification("N", value); 1964 } 1965 1966 return Notification.undefinedValueNotification; 1967 }; 1968 1969 Notification.createError = function (err) { 1970 return new Notification("E", undefined, err); 1971 }; 1972 1973 Notification.createComplete = function () { 1974 return Notification.completeNotification; 1975 }; 1976 1977 Notification.completeNotification = new Notification("C"); 1978 Notification.undefinedValueNotification = new Notification("N", undefined); 1979 return Notification; 1980 }(); 1981 1982 /** PURE_IMPORTS_START tslib,_Subscriber,_Notification PURE_IMPORTS_END */ 1983 1984 var ObserveOnSubscriber = /*@__PURE__*/function (_super) { 1985 __extends(ObserveOnSubscriber, _super); 1986 1987 function ObserveOnSubscriber(destination, scheduler, delay) { 1988 if (delay === void 0) { 1989 delay = 0; 1990 } 1991 1992 var _this = _super.call(this, destination) || this; 1993 1994 _this.scheduler = scheduler; 1995 _this.delay = delay; 1996 return _this; 1997 } 1998 1999 ObserveOnSubscriber.dispatch = function (arg) { 2000 var notification = arg.notification, 2001 destination = arg.destination; 2002 notification.observe(destination); 2003 this.unsubscribe(); 2004 }; 2005 2006 ObserveOnSubscriber.prototype.scheduleMessage = function (notification) { 2007 var destination = this.destination; 2008 destination.add(this.scheduler.schedule(ObserveOnSubscriber.dispatch, this.delay, new ObserveOnMessage(notification, this.destination))); 2009 }; 2010 2011 ObserveOnSubscriber.prototype._next = function (value) { 2012 this.scheduleMessage(Notification.createNext(value)); 2013 }; 2014 2015 ObserveOnSubscriber.prototype._error = function (err) { 2016 this.scheduleMessage(Notification.createError(err)); 2017 this.unsubscribe(); 2018 }; 2019 2020 ObserveOnSubscriber.prototype._complete = function () { 2021 this.scheduleMessage(Notification.createComplete()); 2022 this.unsubscribe(); 2023 }; 2024 2025 return ObserveOnSubscriber; 2026 }(Subscriber); 2027 2028 var ObserveOnMessage = /*@__PURE__*/function () { 2029 function ObserveOnMessage(notification, destination) { 2030 this.notification = notification; 2031 this.destination = destination; 2032 } 2033 2034 return ObserveOnMessage; 2035 }(); 2036 2037 /** PURE_IMPORTS_START tslib,_Subject,_scheduler_queue,_Subscription,_operators_observeOn,_util_ObjectUnsubscribedError,_SubjectSubscription PURE_IMPORTS_END */ 2038 2039 var ReplaySubject = /*@__PURE__*/function (_super) { 2040 __extends(ReplaySubject, _super); 2041 2042 function ReplaySubject(bufferSize, windowTime, scheduler) { 2043 if (bufferSize === void 0) { 2044 bufferSize = Number.POSITIVE_INFINITY; 2045 } 2046 2047 if (windowTime === void 0) { 2048 windowTime = Number.POSITIVE_INFINITY; 2049 } 2050 2051 var _this = _super.call(this) || this; 2052 2053 _this.scheduler = scheduler; 2054 _this._events = []; 2055 _this._infiniteTimeWindow = false; 2056 _this._bufferSize = bufferSize < 1 ? 1 : bufferSize; 2057 _this._windowTime = windowTime < 1 ? 1 : windowTime; 2058 2059 if (windowTime === Number.POSITIVE_INFINITY) { 2060 _this._infiniteTimeWindow = true; 2061 _this.next = _this.nextInfiniteTimeWindow; 2062 } else { 2063 _this.next = _this.nextTimeWindow; 2064 } 2065 2066 return _this; 2067 } 2068 2069 ReplaySubject.prototype.nextInfiniteTimeWindow = function (value) { 2070 var _events = this._events; 2071 2072 _events.push(value); 2073 2074 if (_events.length > this._bufferSize) { 2075 _events.shift(); 2076 } 2077 2078 _super.prototype.next.call(this, value); 2079 }; 2080 2081 ReplaySubject.prototype.nextTimeWindow = function (value) { 2082 this._events.push(new ReplayEvent(this._getNow(), value)); 2083 2084 this._trimBufferThenGetEvents(); 2085 2086 _super.prototype.next.call(this, value); 2087 }; 2088 2089 ReplaySubject.prototype._subscribe = function (subscriber) { 2090 var _infiniteTimeWindow = this._infiniteTimeWindow; 2091 2092 var _events = _infiniteTimeWindow ? this._events : this._trimBufferThenGetEvents(); 2093 2094 var scheduler = this.scheduler; 2095 var len = _events.length; 2096 var subscription; 2097 2098 if (this.closed) { 2099 throw new ObjectUnsubscribedError(); 2100 } else if (this.isStopped || this.hasError) { 2101 subscription = Subscription.EMPTY; 2102 } else { 2103 this.observers.push(subscriber); 2104 subscription = new SubjectSubscription(this, subscriber); 2105 } 2106 2107 if (scheduler) { 2108 subscriber.add(subscriber = new ObserveOnSubscriber(subscriber, scheduler)); 2109 } 2110 2111 if (_infiniteTimeWindow) { 2112 for (var i = 0; i < len && !subscriber.closed; i++) { 2113 subscriber.next(_events[i]); 2114 } 2115 } else { 2116 for (var i = 0; i < len && !subscriber.closed; i++) { 2117 subscriber.next(_events[i].value); 2118 } 2119 } 2120 2121 if (this.hasError) { 2122 subscriber.error(this.thrownError); 2123 } else if (this.isStopped) { 2124 subscriber.complete(); 2125 } 2126 2127 return subscription; 2128 }; 2129 2130 ReplaySubject.prototype._getNow = function () { 2131 return (this.scheduler || queue).now(); 2132 }; 2133 2134 ReplaySubject.prototype._trimBufferThenGetEvents = function () { 2135 var now = this._getNow(); 2136 2137 var _bufferSize = this._bufferSize; 2138 var _windowTime = this._windowTime; 2139 var _events = this._events; 2140 var eventsCount = _events.length; 2141 var spliceCount = 0; 2142 2143 while (spliceCount < eventsCount) { 2144 if (now - _events[spliceCount].time < _windowTime) { 2145 break; 2146 } 2147 2148 spliceCount++; 2149 } 2150 2151 if (eventsCount > _bufferSize) { 2152 spliceCount = Math.max(spliceCount, eventsCount - _bufferSize); 2153 } 2154 2155 if (spliceCount > 0) { 2156 _events.splice(0, spliceCount); 2157 } 2158 2159 return _events; 2160 }; 2161 2162 return ReplaySubject; 2163 }(Subject); 2164 2165 var ReplayEvent = /*@__PURE__*/function () { 2166 function ReplayEvent(time, value) { 2167 this.time = time; 2168 this.value = value; 2169 } 2170 2171 return ReplayEvent; 2172 }(); 2173 2174 /** PURE_IMPORTS_START _AsyncAction,_AsyncScheduler PURE_IMPORTS_END */ 2175 var async = /*@__PURE__*/new AsyncScheduler(AsyncAction); 2176 2177 /** PURE_IMPORTS_START PURE_IMPORTS_END */ 2178 function identity(x) { 2179 return x; 2180 } 2181 2182 /** PURE_IMPORTS_START PURE_IMPORTS_END */ 2183 function ArgumentOutOfRangeErrorImpl() { 2184 Error.call(this); 2185 this.message = 'argument out of range'; 2186 this.name = 'ArgumentOutOfRangeError'; 2187 return this; 2188 } 2189 2190 ArgumentOutOfRangeErrorImpl.prototype = /*@__PURE__*/Object.create(Error.prototype); 2191 var ArgumentOutOfRangeError = ArgumentOutOfRangeErrorImpl; 2192 2193 /** PURE_IMPORTS_START PURE_IMPORTS_END */ 2194 function EmptyErrorImpl() { 2195 Error.call(this); 2196 this.message = 'no elements in sequence'; 2197 this.name = 'EmptyError'; 2198 return this; 2199 } 2200 2201 EmptyErrorImpl.prototype = /*@__PURE__*/Object.create(Error.prototype); 2202 var EmptyError = EmptyErrorImpl; 2203 2204 /** PURE_IMPORTS_START tslib,_Subscriber PURE_IMPORTS_END */ 2205 function map(project, thisArg) { 2206 return function mapOperation(source) { 2207 if (typeof project !== 'function') { 2208 throw new TypeError('argument is not a function. Are you looking for `mapTo()`?'); 2209 } 2210 2211 return source.lift(new MapOperator(project, thisArg)); 2212 }; 2213 } 2214 2215 var MapOperator = /*@__PURE__*/function () { 2216 function MapOperator(project, thisArg) { 2217 this.project = project; 2218 this.thisArg = thisArg; 2219 } 2220 2221 MapOperator.prototype.call = function (subscriber, source) { 2222 return source.subscribe(new MapSubscriber(subscriber, this.project, this.thisArg)); 2223 }; 2224 2225 return MapOperator; 2226 }(); 2227 2228 var MapSubscriber = /*@__PURE__*/function (_super) { 2229 __extends(MapSubscriber, _super); 2230 2231 function MapSubscriber(destination, project, thisArg) { 2232 var _this = _super.call(this, destination) || this; 2233 2234 _this.project = project; 2235 _this.count = 0; 2236 _this.thisArg = thisArg || _this; 2237 return _this; 2238 } 2239 2240 MapSubscriber.prototype._next = function (value) { 2241 var result; 2242 2243 try { 2244 result = this.project.call(this.thisArg, value, this.count++); 2245 } catch (err) { 2246 this.destination.error(err); 2247 return; 2248 } 2249 2250 this.destination.next(result); 2251 }; 2252 2253 return MapSubscriber; 2254 }(Subscriber); 2255 2256 /** PURE_IMPORTS_START tslib,_Subscriber PURE_IMPORTS_END */ 2257 2258 var OuterSubscriber = /*@__PURE__*/function (_super) { 2259 __extends(OuterSubscriber, _super); 2260 2261 function OuterSubscriber() { 2262 return _super !== null && _super.apply(this, arguments) || this; 2263 } 2264 2265 OuterSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { 2266 this.destination.next(innerValue); 2267 }; 2268 2269 OuterSubscriber.prototype.notifyError = function (error, innerSub) { 2270 this.destination.error(error); 2271 }; 2272 2273 OuterSubscriber.prototype.notifyComplete = function (innerSub) { 2274 this.destination.complete(); 2275 }; 2276 2277 return OuterSubscriber; 2278 }(Subscriber); 2279 2280 /** PURE_IMPORTS_START tslib,_Subscriber PURE_IMPORTS_END */ 2281 2282 var InnerSubscriber = /*@__PURE__*/function (_super) { 2283 __extends(InnerSubscriber, _super); 2284 2285 function InnerSubscriber(parent, outerValue, outerIndex) { 2286 var _this = _super.call(this) || this; 2287 2288 _this.parent = parent; 2289 _this.outerValue = outerValue; 2290 _this.outerIndex = outerIndex; 2291 _this.index = 0; 2292 return _this; 2293 } 2294 2295 InnerSubscriber.prototype._next = function (value) { 2296 this.parent.notifyNext(this.outerValue, value, this.outerIndex, this.index++, this); 2297 }; 2298 2299 InnerSubscriber.prototype._error = function (error) { 2300 this.parent.notifyError(error, this); 2301 this.unsubscribe(); 2302 }; 2303 2304 InnerSubscriber.prototype._complete = function () { 2305 this.parent.notifyComplete(this); 2306 this.unsubscribe(); 2307 }; 2308 2309 return InnerSubscriber; 2310 }(Subscriber); 2311 2312 /** PURE_IMPORTS_START _hostReportError PURE_IMPORTS_END */ 2313 var subscribeToPromise = function subscribeToPromise(promise) { 2314 return function (subscriber) { 2315 promise.then(function (value) { 2316 if (!subscriber.closed) { 2317 subscriber.next(value); 2318 subscriber.complete(); 2319 } 2320 }, function (err) { 2321 return subscriber.error(err); 2322 }).then(null, hostReportError); 2323 return subscriber; 2324 }; 2325 }; 2326 2327 /** PURE_IMPORTS_START PURE_IMPORTS_END */ 2328 function getSymbolIterator() { 2329 if (typeof Symbol !== 'function' || !Symbol.iterator) { 2330 return '@@iterator'; 2331 } 2332 2333 return Symbol.iterator; 2334 } 2335 var iterator = /*@__PURE__*/getSymbolIterator(); 2336 2337 /** PURE_IMPORTS_START _symbol_iterator PURE_IMPORTS_END */ 2338 var subscribeToIterable = function subscribeToIterable(iterable) { 2339 return function (subscriber) { 2340 var iterator$1 = iterable[iterator](); 2341 2342 do { 2343 var item = iterator$1.next(); 2344 2345 if (item.done) { 2346 subscriber.complete(); 2347 break; 2348 } 2349 2350 subscriber.next(item.value); 2351 2352 if (subscriber.closed) { 2353 break; 2354 } 2355 } while (true); 2356 2357 if (typeof iterator$1.return === 'function') { 2358 subscriber.add(function () { 2359 if (iterator$1.return) { 2360 iterator$1.return(); 2361 } 2362 }); 2363 } 2364 2365 return subscriber; 2366 }; 2367 }; 2368 2369 /** PURE_IMPORTS_START _symbol_observable PURE_IMPORTS_END */
2370 var subscribeToObservable = function subscribeToObservable(obj) { 2371 return function (subscriber) { 2372 var obs = obj[observable](); 2373 2374 if (typeof obs.subscribe !== 'function') { 2375 throw new TypeError('Provided object does not correctly implement Symbol.observable'); 2376 } else { 2377 return obs.subscribe(subscriber); 2378 } 2379 }; 2380 }; 2381 2382 /** PURE_IMPORTS_START PURE_IMPORTS_END */ 2383 var isArrayLike = function isArrayLike(x) { 2384 return x && typeof x.length === 'number' && typeof x !== 'function'; 2385 }; 2386 2387 /** PURE_IMPORTS_START PURE_IMPORTS_END */ 2388 function isPromise(value) { 2389 return !!value && typeof value.subscribe !== 'function' && typeof value.then === 'function'; 2390 } 2391 2392 /** PURE_IMPORTS_START _Observable,_subscribeToArray,_subscribeToPromise,_subscribeToIterable,_subscribeToObservable,_isArrayLike,_isPromise,_isObject,_symbol_iterator,_symbol_observable PURE_IMPORTS_END */ 2393 var subscribeTo = function subscribeTo(result) { 2394 if (result instanceof Observable) { 2395 return function (subscriber) { 2396 if (result._isScalar) { 2397 subscriber.next(result.value); 2398 subscriber.complete(); 2399 return undefined; 2400 } else { 2401 return result.subscribe(subscriber); 2402 } 2403 }; 2404 } else if (!!result && typeof result[observable] === 'function') { 2405 return subscribeToObservable(result); 2406 } else if (isArrayLike(result)) { 2407 return subscribeToArray(result); 2408 } else if (isPromise(result)) { 2409 return subscribeToPromise(result); 2410 } else if (!!result && typeof result[iterator] === 'function') { 2411 return subscribeToIterable(result); 2412 } else { 2413 var value = isObject(result) ? 'an invalid object' : "'" + result + "'"; 2414 var msg = "You provided " + value + " where a stream was expected." + ' You can provide an Observable, Promise, Array, or Iterable.'; 2415 throw new TypeError(msg); 2416 } 2417 }; 2418 2419 /** PURE_IMPORTS_START _InnerSubscriber,_subscribeTo PURE_IMPORTS_END */ 2420 function subscribeToResult(outerSubscriber, result, outerValue, outerIndex, destination) { 2421 if (destination === void 0) { 2422 destination = new InnerSubscriber(outerSubscriber, outerValue, outerIndex); 2423 } 2424 2425 if (destination.closed) { 2426 return; 2427 } 2428 2429 return subscribeTo(result)(destination); 2430 } 2431 2432 /** PURE_IMPORTS_START tslib,_util_isScheduler,_util_isArray,_OuterSubscriber,_util_subscribeToResult,_fromArray PURE_IMPORTS_END */ 2433 var NONE = {}; 2434 function combineLatest() { 2435 var observables = []; 2436 2437 for (var _i = 0; _i < arguments.length; _i++) { 2438 observables[_i] = arguments[_i]; 2439 } 2440 2441 var resultSelector = null; 2442 var scheduler = null; 2443 2444 if (isScheduler(observables[observables.length - 1])) { 2445 scheduler = observables.pop(); 2446 } 2447 2448 if (typeof observables[observables.length - 1] === 'function') { 2449 resultSelector = observables.pop(); 2450 } 2451 2452 if (observables.length === 1 && isArray(observables[0])) { 2453 observables = observables[0]; 2454 } 2455 2456 return fromArray(observables, scheduler).lift(new CombineLatestOperator(resultSelector)); 2457 } 2458 2459 var CombineLatestOperator = /*@__PURE__*/function () { 2460 function CombineLatestOperator(resultSelector) { 2461 this.resultSelector = resultSelector; 2462 } 2463 2464 CombineLatestOperator.prototype.call = function (subscriber, source) { 2465 return source.subscribe(new CombineLatestSubscriber(subscriber, this.resultSelector)); 2466 }; 2467 2468 return CombineLatestOperator; 2469 }(); 2470 2471 var CombineLatestSubscriber = /*@__PURE__*/function (_super) { 2472 __extends(CombineLatestSubscriber, _super); 2473 2474 function CombineLatestSubscriber(destination, resultSelector) { 2475 var _this = _super.call(this, destination) || this; 2476 2477 _this.resultSelector = resultSelector; 2478 _this.active = 0; 2479 _this.values = []; 2480 _this.observables = []; 2481 return _this; 2482 } 2483 2484 CombineLatestSubscriber.prototype._next = function (observable) { 2485 this.values.push(NONE); 2486 this.observables.push(observable); 2487 }; 2488 2489 CombineLatestSubscriber.prototype._complete = function () { 2490 var observables = this.observables; 2491 var len = observables.length; 2492 2493 if (len === 0) { 2494 this.destination.complete(); 2495 } else { 2496 this.active = len; 2497 this.toRespond = len; 2498 2499 for (var i = 0; i < len; i++) { 2500 var observable = observables[i]; 2501 this.add(subscribeToResult(this, observable, observable, i)); 2502 } 2503 } 2504 }; 2505 2506 CombineLatestSubscriber.prototype.notifyComplete = function (unused) { 2507 if ((this.active -= 1) === 0) { 2508 this.destination.complete(); 2509 } 2510 }; 2511 2512 CombineLatestSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { 2513 var values = this.values; 2514 var oldVal = values[outerIndex]; 2515 var toRespond = !this.toRespond ? 0 : oldVal === NONE ? --this.toRespond : this.toRespond; 2516 values[outerIndex] = innerValue; 2517 2518 if (toRespond === 0) { 2519 if (this.resultSelector) { 2520 this._tryResultSelector(values); 2521 } else { 2522 this.destination.next(values.slice()); 2523 } 2524 } 2525 }; 2526 2527 CombineLatestSubscriber.prototype._tryResultSelector = function (values) { 2528 var result; 2529 2530 try { 2531 result = this.resultSelector.apply(this, values); 2532 } catch (err) { 2533 this.destination.error(err); 2534 return; 2535 } 2536 2537 this.destination.next(result); 2538 }; 2539 2540 return CombineLatestSubscriber; 2541 }(OuterSubscriber); 2542 2543 /** PURE_IMPORTS_START _symbol_observable PURE_IMPORTS_END */ 2544 function isInteropObservable(input) { 2545 return input && typeof input[observable] === 'function'; 2546 } 2547 2548 /** PURE_IMPORTS_START _symbol_iterator PURE_IMPORTS_END */ 2549 function isIterable(input) { 2550 return input && typeof input[iterator] === 'function'; 2551 } 2552 2553 /** PURE_IMPORTS_START _Observable,_Subscription,_util_subscribeToPromise PURE_IMPORTS_END */ 2554 function fromPromise(input, scheduler) { 2555 if (!scheduler) { 2556 return new Observable(subscribeToPromise(input)); 2557 } else { 2558 return new Observable(function (subscriber) { 2559 var sub = new Subscription(); 2560 sub.add(scheduler.schedule(function () { 2561 return input.then(function (value) { 2562 sub.add(scheduler.schedule(function () { 2563 subscriber.next(value); 2564 sub.add(scheduler.schedule(function () { 2565 return subscriber.complete(); 2566 })); 2567 })); 2568 }, function (err) { 2569 sub.add(scheduler.schedule(function () { 2570 return subscriber.error(err); 2571 })); 2572 }); 2573 })); 2574 return sub; 2575 }); 2576 } 2577 } 2578
vendor: 10,883 bytes, lines 2579-2951
2579 /** PURE_IMPORTS_START _Observable,_Subscription,_symbol_iterator,_util_subscribeToIterable PURE_IMPORTS_END */ 2580 function fromIterable(input, scheduler) { 2581 if (!input) { 2582 throw new Error('Iterable cannot be null'); 2583 } 2584 2585 if (!scheduler) { 2586 return new Observable(subscribeToIterable(input)); 2587 } else { 2588 return new Observable(function (subscriber) { 2589 var sub = new Subscription(); 2590 var iterator$1; 2591 sub.add(function () { 2592 if (iterator$1 && typeof iterator$1.return === 'function') { 2593 iterator$1.return(); 2594 } 2595 }); 2596 sub.add(scheduler.schedule(function () { 2597 iterator$1 = input[iterator](); 2598 sub.add(scheduler.schedule(function () { 2599 if (subscriber.closed) { 2600 return; 2601 } 2602 2603 var value; 2604 var done; 2605 2606 try { 2607 var result = iterator$1.next(); 2608 value = result.value; 2609 done = result.done; 2610 } catch (err) { 2611 subscriber.error(err); 2612 return; 2613 } 2614 2615 if (done) { 2616 subscriber.complete(); 2617 } else { 2618 subscriber.next(value); 2619 this.schedule(); 2620 } 2621 })); 2622 })); 2623 return sub; 2624 }); 2625 } 2626 } 2627 2628 /** PURE_IMPORTS_START _Observable,_Subscription,_symbol_observable,_util_subscribeToObservable PURE_IMPORTS_END */ 2629 function fromObservable(input, scheduler) { 2630 if (!scheduler) { 2631 return new Observable(subscribeToObservable(input)); 2632 } else { 2633 return new Observable(function (subscriber) { 2634 var sub = new Subscription(); 2635 sub.add(scheduler.schedule(function () { 2636 var observable$1 = input[observable](); 2637 sub.add(observable$1.subscribe({ 2638 next: function next(value) { 2639 sub.add(scheduler.schedule(function () { 2640 return subscriber.next(value); 2641 })); 2642 }, 2643 error: function error(err) { 2644 sub.add(scheduler.schedule(function () { 2645 return subscriber.error(err); 2646 })); 2647 }, 2648 complete: function complete() { 2649 sub.add(scheduler.schedule(function () { 2650 return subscriber.complete(); 2651 })); 2652 } 2653 })); 2654 })); 2655 return sub; 2656 }); 2657 } 2658 } 2659 2660 /** PURE_IMPORTS_START _Observable,_util_isPromise,_util_isArrayLike,_util_isInteropObservable,_util_isIterable,_fromArray,_fromPromise,_fromIterable,_fromObservable,_util_subscribeTo PURE_IMPORTS_END */ 2661 function from(input, scheduler) { 2662 if (!scheduler) { 2663 if (input instanceof Observable) { 2664 return input; 2665 } 2666 2667 return new Observable(subscribeTo(input)); 2668 } 2669 2670 if (input != null) { 2671 if (isInteropObservable(input)) { 2672 return fromObservable(input, scheduler); 2673 } else if (isPromise(input)) { 2674 return fromPromise(input, scheduler); 2675 } else if (isArrayLike(input)) { 2676 return fromArray(input, scheduler); 2677 } else if (isIterable(input) || typeof input === 'string') { 2678 return fromIterable(input, scheduler); 2679 } 2680 } 2681 2682 throw new TypeError((input !== null && typeof input || input) + ' is not observable'); 2683 } 2684 2685 /** PURE_IMPORTS_START tslib,_util_subscribeToResult,_OuterSubscriber,_InnerSubscriber,_map,_observable_from PURE_IMPORTS_END */ 2686 function mergeMap(project, resultSelector, concurrent) { 2687 if (concurrent === void 0) { 2688 concurrent = Number.POSITIVE_INFINITY; 2689 } 2690 2691 if (typeof resultSelector === 'function') { 2692 return function (source) { 2693 return source.pipe(mergeMap(function (a, i) { 2694 return from(project(a, i)).pipe(map(function (b, ii) { 2695 return resultSelector(a, b, i, ii); 2696 })); 2697 }, concurrent)); 2698 }; 2699 } else if (typeof resultSelector === 'number') { 2700 concurrent = resultSelector; 2701 } 2702 2703 return function (source) { 2704 return source.lift(new MergeMapOperator(project, concurrent)); 2705 }; 2706 } 2707 2708 var MergeMapOperator = /*@__PURE__*/function () { 2709 function MergeMapOperator(project, concurrent) { 2710 if (concurrent === void 0) { 2711 concurrent = Number.POSITIVE_INFINITY; 2712 } 2713 2714 this.project = project; 2715 this.concurrent = concurrent; 2716 } 2717 2718 MergeMapOperator.prototype.call = function (observer, source) { 2719 return source.subscribe(new MergeMapSubscriber(observer, this.project, this.concurrent)); 2720 }; 2721 2722 return MergeMapOperator; 2723 }(); 2724 2725 var MergeMapSubscriber = /*@__PURE__*/function (_super) { 2726 __extends(MergeMapSubscriber, _super); 2727 2728 function MergeMapSubscriber(destination, project, concurrent) { 2729 if (concurrent === void 0) { 2730 concurrent = Number.POSITIVE_INFINITY; 2731 } 2732 2733 var _this = _super.call(this, destination) || this; 2734 2735 _this.project = project; 2736 _this.concurrent = concurrent; 2737 _this.hasCompleted = false; 2738 _this.buffer = []; 2739 _this.active = 0; 2740 _this.index = 0; 2741 return _this; 2742 } 2743 2744 MergeMapSubscriber.prototype._next = function (value) { 2745 if (this.active < this.concurrent) { 2746 this._tryNext(value); 2747 } else { 2748 this.buffer.push(value); 2749 } 2750 }; 2751 2752 MergeMapSubscriber.prototype._tryNext = function (value) { 2753 var result; 2754 var index = this.index++; 2755 2756 try { 2757 result = this.project(value, index); 2758 } catch (err) { 2759 this.destination.error(err); 2760 return; 2761 } 2762 2763 this.active++; 2764 2765 this._innerSub(result, value, index); 2766 }; 2767 2768 MergeMapSubscriber.prototype._innerSub = function (ish, value, index) { 2769 var innerSubscriber = new InnerSubscriber(this, undefined, undefined); 2770 var destination = this.destination; 2771 destination.add(innerSubscriber); 2772 subscribeToResult(this, ish, value, index, innerSubscriber); 2773 }; 2774 2775 MergeMapSubscriber.prototype._complete = function () { 2776 this.hasCompleted = true; 2777 2778 if (this.active === 0 && this.buffer.length === 0) { 2779 this.destination.complete(); 2780 } 2781 2782 this.unsubscribe(); 2783 }; 2784 2785 MergeMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { 2786 this.destination.next(innerValue); 2787 }; 2788 2789 MergeMapSubscriber.prototype.notifyComplete = function (innerSub) { 2790 var buffer = this.buffer; 2791 this.remove(innerSub); 2792 this.active--; 2793 2794 if (buffer.length > 0) { 2795 this._next(buffer.shift()); 2796 } else if (this.active === 0 && this.hasCompleted) { 2797 this.destination.complete(); 2798 } 2799 }; 2800 2801 return MergeMapSubscriber; 2802 }(OuterSubscriber); 2803 2804 /** PURE_IMPORTS_START _mergeMap,_util_identity PURE_IMPORTS_END */ 2805 function mergeAll(concurrent) { 2806 if (concurrent === void 0) { 2807 concurrent = Number.POSITIVE_INFINITY; 2808 } 2809 2810 return mergeMap(identity, concurrent); 2811 } 2812 2813 /** PURE_IMPORTS_START _mergeAll PURE_IMPORTS_END */ 2814 function concatAll() { 2815 return mergeAll(1); 2816 } 2817 2818 /** PURE_IMPORTS_START _of,_operators_concatAll PURE_IMPORTS_END */ 2819 function concat() { 2820 var observables = []; 2821 2822 for (var _i = 0; _i < arguments.length; _i++) { 2823 observables[_i] = arguments[_i]; 2824 } 2825 2826 return concatAll()(of.apply(void 0, observables)); 2827 } 2828 2829 /** PURE_IMPORTS_START _Observable,_util_isArray,_util_isFunction,_operators_map PURE_IMPORTS_END */ 2830 function fromEvent(target, eventName, options, resultSelector) { 2831 if (isFunction(options)) { 2832 resultSelector = options; 2833 options = undefined; 2834 } 2835 2836 if (resultSelector) { 2837 return fromEvent(target, eventName, options).pipe(map(function (args) { 2838 return isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); 2839 })); 2840 } 2841 2842 return new Observable(function (subscriber) { 2843 function handler(e) { 2844 if (arguments.length > 1) { 2845 subscriber.next(Array.prototype.slice.call(arguments)); 2846 } else { 2847 subscriber.next(e); 2848 } 2849 } 2850 2851 setupSubscription(target, eventName, handler, subscriber, options); 2852 }); 2853 } 2854 2855 function setupSubscription(sourceObj, eventName, handler, subscriber, options) { 2856 var unsubscribe; 2857 2858 if (isEventTarget(sourceObj)) { 2859 var source_1 = sourceObj; 2860 sourceObj.addEventListener(eventName, handler, options); 2861 2862 unsubscribe = function unsubscribe() { 2863 return source_1.removeEventListener(eventName, handler, options); 2864 }; 2865 } else if (isJQueryStyleEventEmitter(sourceObj)) { 2866 var source_2 = sourceObj; 2867 sourceObj.on(eventName, handler); 2868 2869 unsubscribe = function unsubscribe() { 2870 return source_2.off(eventName, handler); 2871 }; 2872 } else if (isNodeStyleEventEmitter(sourceObj)) { 2873 var source_3 = sourceObj; 2874 sourceObj.addListener(eventName, handler); 2875 2876 unsubscribe = function unsubscribe() { 2877 return source_3.removeListener(eventName, handler); 2878 }; 2879 } else if (sourceObj && sourceObj.length) { 2880 for (var i = 0, len = sourceObj.length; i < len; i++) { 2881 setupSubscription(sourceObj[i], eventName, handler, subscriber, options); 2882 } 2883 } else { 2884 throw new TypeError('Invalid event target'); 2885 } 2886 2887 subscriber.add(unsubscribe); 2888 } 2889 2890 function isNodeStyleEventEmitter(sourceObj) { 2891 return sourceObj && typeof sourceObj.addListener === 'function' && typeof sourceObj.removeListener === 'function'; 2892 } 2893 2894 function isJQueryStyleEventEmitter(sourceObj) { 2895 return sourceObj && typeof sourceObj.on === 'function' && typeof sourceObj.off === 'function'; 2896 } 2897 2898 function isEventTarget(sourceObj) { 2899 return sourceObj && typeof sourceObj.addEventListener === 'function' && typeof sourceObj.removeEventListener === 'function'; 2900 } 2901 2902 /** PURE_IMPORTS_START _isArray PURE_IMPORTS_END */ 2903 function isNumeric(val) { 2904 return !isArray(val) && val - parseFloat(val) + 1 >= 0; 2905 } 2906 2907 /** PURE_IMPORTS_START _Observable,_util_isScheduler,_operators_mergeAll,_fromArray PURE_IMPORTS_END */ 2908 function merge() { 2909 var observables = []; 2910 2911 for (var _i = 0; _i < arguments.length; _i++) { 2912 observables[_i] = arguments[_i]; 2913 } 2914 2915 var concurrent = Number.POSITIVE_INFINITY; 2916 var scheduler = null; 2917 var last = observables[observables.length - 1]; 2918 2919 if (isScheduler(last)) { 2920 scheduler = observables.pop(); 2921 2922 if (observables.length > 1 && typeof observables[observables.length - 1] === 'number') { 2923 concurrent = observables.pop(); 2924 } 2925 } else if (typeof last === 'number') { 2926 concurrent = observables.pop(); 2927 } 2928 2929 if (scheduler === null && observables.length === 1 && observables[0] instanceof Observable) { 2930 return observables[0]; 2931 } 2932 2933 return mergeAll(concurrent)(fromArray(observables, scheduler)); 2934 } 2935 2936 /** PURE_IMPORTS_START _Observable PURE_IMPORTS_END */ 2937 function range(start, count, scheduler) { 2938 if (start === void 0) { 2939 start = 0; 2940 } 2941 2942 return new Observable(function (subscriber) { 2943 if (count === undefined) { 2944 count = start; 2945 start = 0; 2946 } 2947 2948 var index = 0; 2949 var current = start; 2950 2951 if (scheduler) {
2952 return scheduler.schedule(dispatch$1, 0, { 2953 index: index, 2954 count: count, 2955 start: start, 2956 subscriber: subscriber 2957 }); 2958 } else { 2959 do { 2960 if (index++ >= count) { 2961 subscriber.complete(); 2962 break; 2963 } 2964 2965 subscriber.next(current++); 2966 2967 if (subscriber.closed) { 2968 break; 2969 } 2970 } while (true); 2971 } 2972 2973 return undefined; 2974 }); 2975 } 2976 function dispatch$1(state) { 2977 var start = state.start, 2978 index = state.index, 2979 count = state.count, 2980 subscriber = state.subscriber; 2981 2982 if (index >= count) { 2983 subscriber.complete(); 2984 return; 2985 } 2986 2987 subscriber.next(start); 2988 2989 if (subscriber.closed) { 2990 return; 2991 } 2992 2993 state.index = index + 1; 2994 state.start = start + 1; 2995 this.schedule(state); 2996 } 2997 2998 /** PURE_IMPORTS_START _Observable,_scheduler_async,_util_isNumeric,_util_isScheduler PURE_IMPORTS_END */ 2999 function timer(dueTime, periodOrScheduler, scheduler) { 3000 if (dueTime === void 0) { 3001 dueTime = 0; 3002 } 3003 3004 var period = -1; 3005 3006 if (isNumeric(periodOrScheduler)) { 3007 period = Number(periodOrScheduler) < 1 && 1 || Number(periodOrScheduler); 3008 } else if (isScheduler(periodOrScheduler)) { 3009 scheduler = periodOrScheduler; 3010 } 3011 3012 if (!isScheduler(scheduler)) { 3013 scheduler = async; 3014 } 3015 3016 return new Observable(function (subscriber) { 3017 var due = isNumeric(dueTime) ? dueTime : +dueTime - scheduler.now(); 3018 return scheduler.schedule(dispatch$2, due, { 3019 index: 0, 3020 period: period, 3021 subscriber: subscriber 3022 }); 3023 }); 3024 } 3025 3026 function dispatch$2(state) { 3027 var index = state.index, 3028 period = state.period, 3029 subscriber = state.subscriber; 3030 subscriber.next(index); 3031 3032 if (subscriber.closed) { 3033 return; 3034 } else if (period === -1) { 3035 return subscriber.complete(); 3036 } 3037 3038 state.index = index + 1; 3039 this.schedule(state, period); 3040 } 3041 3042 var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; 3043 3044 function createCommonjsModule(fn, basedir, module) { 3045 return module = { 3046 path: basedir, 3047 exports: {}, 3048 require: function (path, base) { 3049 return commonjsRequire(path, (base === undefined || base === null) ? module.path : base); 3050 } 3051 }, fn(module, module.exports), module.exports; 3052 } 3053 3054 function commonjsRequire () { 3055 throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs'); 3056 } 3057 3058 var isArray$1 = createCommonjsModule(function (module, exports) { 3059 3060 Object.defineProperty(exports, "__esModule", { 3061 value: true 3062 }); 3063 3064 exports.isArray = Array.isArray || function (x) { 3065 return x && typeof x.length === 'number'; 3066 }; 3067 }); 3068 3069 var isObject_1 = createCommonjsModule(function (module, exports) { 3070 3071 Object.defineProperty(exports, "__esModule", { 3072 value: true 3073 }); 3074 3075 function isObject(x) { 3076 return x !== null && typeof x === 'object'; 3077 } 3078 3079 exports.isObject = isObject; 3080 }); 3081 3082 var isFunction_1 = createCommonjsModule(function (module, exports) { 3083 3084 Object.defineProperty(exports, "__esModule", { 3085 value: true 3086 }); 3087 3088 function isFunction(x) { 3089 return typeof x === 'function'; 3090 } 3091 3092 exports.isFunction = isFunction; 3093 }); 3094 3095 var UnsubscriptionError$1 = createCommonjsModule(function (module, exports) { 3096 3097 Object.defineProperty(exports, "__esModule", { 3098 value: true 3099 }); 3100 3101 function UnsubscriptionErrorImpl(errors) { 3102 Error.call(this); 3103 this.message = errors ? errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) { 3104 return i + 1 + ") " + err.toString(); 3105 }).join('\n ') : ''; 3106 this.name = 'UnsubscriptionError'; 3107 this.errors = errors; 3108 return this; 3109 } 3110 3111 UnsubscriptionErrorImpl.prototype = Object.create(Error.prototype); 3112 exports.UnsubscriptionError = UnsubscriptionErrorImpl; 3113 }); 3114 3115 var Subscription_1 = createCommonjsModule(function (module, exports) { 3116 3117 Object.defineProperty(exports, "__esModule", { 3118 value: true 3119 }); 3120 3121 var Subscription = function () { 3122 function Subscription(unsubscribe) { 3123 this.closed = false;
3124 this._parent = null; 3125 this._parents = null; 3126 this._subscriptions = null; 3127 3128 if (unsubscribe) { 3129 this._unsubscribe = unsubscribe; 3130 } 3131 } 3132 3133 Subscription.prototype.unsubscribe = function () { 3134 var hasErrors = false; 3135 var errors; 3136 3137 if (this.closed) { 3138 return; 3139 } 3140 3141 var _a = this, 3142 _parent = _a._parent, 3143 _parents = _a._parents, 3144 _unsubscribe = _a._unsubscribe, 3145 _subscriptions = _a._subscriptions; 3146 3147 this.closed = true; 3148 this._parent = null; 3149 this._parents = null; 3150 this._subscriptions = null; 3151 var index = -1; 3152 var len = _parents ? _parents.length : 0; 3153 3154 while (_parent) { 3155 _parent.remove(this); 3156 3157 _parent = ++index < len && _parents[index] || null; 3158 } 3159 3160 if (isFunction_1.isFunction(_unsubscribe)) { 3161 try { 3162 _unsubscribe.call(this); 3163 } catch (e) { 3164 hasErrors = true; 3165 errors = e instanceof UnsubscriptionError$1.UnsubscriptionError ? flattenUnsubscriptionErrors(e.errors) : [e]; 3166 } 3167 } 3168 3169 if (isArray$1.isArray(_subscriptions)) { 3170 index = -1; 3171 len = _subscriptions.length; 3172 3173 while (++index < len) { 3174 var sub = _subscriptions[index]; 3175 3176 if (isObject_1.isObject(sub)) { 3177 try { 3178 sub.unsubscribe(); 3179 } catch (e) { 3180 hasErrors = true; 3181 errors = errors || []; 3182 3183 if (e instanceof UnsubscriptionError$1.UnsubscriptionError) { 3184 errors = errors.concat(flattenUnsubscriptionErrors(e.errors)); 3185 } else { 3186 errors.push(e); 3187 } 3188 } 3189 } 3190 } 3191 } 3192 3193 if (hasErrors) { 3194 throw new UnsubscriptionError$1.UnsubscriptionError(errors); 3195 } 3196 }; 3197 3198 Subscription.prototype.add = function (teardown) { 3199 var subscription = teardown; 3200 3201 switch (typeof teardown) { 3202 case 'function': 3203 subscription = new Subscription(teardown); 3204 3205 case 'object': 3206 if (subscription === this || subscription.closed || typeof subscription.unsubscribe !== 'function') { 3207 return subscription; 3208 } else if (this.closed) { 3209 subscription.unsubscribe(); 3210 return subscription; 3211 } else if (!(subscription instanceof Subscription)) { 3212 var tmp = subscription; 3213 subscription = new Subscription(); 3214 subscription._subscriptions = [tmp]; 3215 } 3216 3217 break; 3218 3219 default: 3220 { 3221 if (!teardown) { 3222 return Subscription.EMPTY; 3223 } 3224 3225 throw new Error('unrecognized teardown ' + teardown + ' added to Subscription.'); 3226 } 3227 } 3228 3229 if (subscription._addParent(this)) { 3230 var subscriptions = this._subscriptions; 3231 3232 if (subscriptions) { 3233 subscriptions.push(subscription); 3234 } else { 3235 this._subscriptions = [subscription]; 3236 } 3237 } 3238 3239 return subscription; 3240 }; 3241 3242 Subscription.prototype.remove = function (subscription) { 3243 var subscriptions = this._subscriptions; 3244 3245 if (subscriptions) { 3246 var subscriptionIndex = subscriptions.indexOf(subscription); 3247 3248 if (subscriptionIndex !== -1) { 3249 subscriptions.splice(subscriptionIndex, 1); 3250 } 3251 } 3252 }; 3253 3254 Subscription.prototype._addParent = function (parent) { 3255 var _a = this, 3256 _parent = _a._parent, 3257 _parents = _a._parents; 3258 3259 if (_parent === parent) { 3260 return false; 3261 } else if (!_parent) { 3262 this._parent = parent; 3263 return true; 3264 } else if (!_parents) { 3265 this._parents = [parent]; 3266 return true; 3267 } else if (_parents.indexOf(parent) === -1) { 3268 _parents.push(parent); 3269 3270 return true; 3271 } 3272 3273 return false; 3274 }; 3275 3276 Subscription.EMPTY = function (empty) { 3277 empty.closed = true; 3278 return empty; 3279 }(new Subscription()); 3280 3281 return Subscription; 3282 }(); 3283 3284 exports.Subscription = Subscription; 3285 3286 function flattenUnsubscriptionErrors(errors) { 3287 return errors.reduce(function (errs, err) { 3288 return errs.concat(err instanceof UnsubscriptionError$1.UnsubscriptionError ? err.errors : err); 3289 }, []); 3290 } 3291 }); 3292
3293 var Action_1 = createCommonjsModule(function (module, exports) { 3294 3295 var __extends = commonjsGlobal && commonjsGlobal.__extends || function () { 3296 var _extendStatics = function extendStatics(d, b) { 3297 _extendStatics = Object.setPrototypeOf || { 3298 __proto__: [] 3299 } instanceof Array && function (d, b) { 3300 d.__proto__ = b; 3301 } || function (d, b) { 3302 for (var p in b) { 3303 if (b.hasOwnProperty(p)) d[p] = b[p]; 3304 } 3305 }; 3306 3307 return _extendStatics(d, b); 3308 }; 3309 3310 return function (d, b) { 3311 _extendStatics(d, b); 3312 3313 function __() { 3314 this.constructor = d; 3315 } 3316 3317 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 3318 }; 3319 }(); 3320 3321 Object.defineProperty(exports, "__esModule", { 3322 value: true 3323 }); 3324 3325 var Action = function (_super) { 3326 __extends(Action, _super); 3327 3328 function Action(scheduler, work) { 3329 return _super.call(this) || this; 3330 } 3331 3332 Action.prototype.schedule = function (state, delay) { 3333 3334 return this; 3335 }; 3336 3337 return Action; 3338 }(Subscription_1.Subscription); 3339 3340 exports.Action = Action; 3341 }); 3342 3343 var AsyncAction_1 = createCommonjsModule(function (module, exports) { 3344 3345 var __extends = commonjsGlobal && commonjsGlobal.__extends || function () { 3346 var _extendStatics = function extendStatics(d, b) { 3347 _extendStatics = Object.setPrototypeOf || { 3348 __proto__: [] 3349 } instanceof Array && function (d, b) { 3350 d.__proto__ = b; 3351 } || function (d, b) { 3352 for (var p in b) { 3353 if (b.hasOwnProperty(p)) d[p] = b[p]; 3354 } 3355 }; 3356 3357 return _extendStatics(d, b); 3358 }; 3359 3360 return function (d, b) { 3361 _extendStatics(d, b); 3362 3363 function __() { 3364 this.constructor = d; 3365 } 3366 3367 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 3368 }; 3369 }(); 3370 3371 Object.defineProperty(exports, "__esModule", { 3372 value: true 3373 }); 3374 3375 var AsyncAction = function (_super) { 3376 __extends(AsyncAction, _super); 3377 3378 function AsyncAction(scheduler, work) { 3379 var _this = _super.call(this, scheduler, work) || this; 3380 3381 _this.scheduler = scheduler; 3382 _this.work = work; 3383 _this.pending = false; 3384 return _this; 3385 } 3386 3387 AsyncAction.prototype.schedule = function (state, delay) { 3388 if (delay === void 0) { 3389 delay = 0; 3390 } 3391 3392 if (this.closed) { 3393 return this; 3394 } 3395 3396 this.state = state; 3397 var id = this.id; 3398 var scheduler = this.scheduler; 3399 3400 if (id != null) { 3401 this.id = this.recycleAsyncId(scheduler, id, delay); 3402 } 3403 3404 this.pending = true; 3405 this.delay = delay; 3406 this.id = this.id || this.requestAsyncId(scheduler, this.id, delay); 3407 return this; 3408 }; 3409 3410 AsyncAction.prototype.requestAsyncId = function (scheduler, id, delay) { 3411 if (delay === void 0) { 3412 delay = 0; 3413 } 3414 3415 return setInterval(scheduler.flush.bind(scheduler, this), delay); 3416 }; 3417 3418 AsyncAction.prototype.recycleAsyncId = function (scheduler, id, delay) { 3419 if (delay === void 0) { 3420 delay = 0; 3421 } 3422 3423 if (delay !== null && this.delay === delay && this.pending === false) { 3424 return id; 3425 } 3426 3427 clearInterval(id); 3428 return undefined; 3429 }; 3430 3431 AsyncAction.prototype.execute = function (state, delay) { 3432 if (this.closed) { 3433 return new Error('executing a cancelled action'); 3434 } 3435 3436 this.pending = false; 3437 3438 var error = this._execute(state, delay); 3439 3440 if (error) { 3441 return error; 3442 } else if (this.pending === false && this.id != null) { 3443 this.id = this.recycleAsyncId(this.scheduler, this.id, null); 3444 } 3445 }; 3446 3447 AsyncAction.prototype._execute = function (state, delay) { 3448 var errored = false; 3449 var errorValue = undefined; 3450 3451 try { 3452 this.work(state); 3453 } catch (e) { 3454 errored = true; 3455 errorValue = !!e && e || new Error(e); 3456 } 3457 3458 if (errored) { 3459 this.unsubscribe(); 3460 return errorValue; 3461 } 3462 }; 3463 3464 AsyncAction.prototype._unsubscribe = function () { 3465 var id = this.id; 3466 var scheduler = this.scheduler; 3467 var actions = scheduler.actions; 3468 var index = actions.indexOf(this); 3469 this.work = null; 3470 this.state = null; 3471 this.pending = false;
3472 this.scheduler = null; 3473 3474 if (index !== -1) { 3475 actions.splice(index, 1); 3476 } 3477 3478 if (id != null) { 3479 this.id = this.recycleAsyncId(scheduler, id, null); 3480 } 3481 3482 this.delay = null; 3483 }; 3484 3485 return AsyncAction; 3486 }(Action_1.Action); 3487 3488 exports.AsyncAction = AsyncAction; 3489 }); 3490 3491 var AnimationFrameAction_1 = createCommonjsModule(function (module, exports) { 3492 3493 var __extends = commonjsGlobal && commonjsGlobal.__extends || function () { 3494 var _extendStatics = function extendStatics(d, b) { 3495 _extendStatics = Object.setPrototypeOf || { 3496 __proto__: [] 3497 } instanceof Array && function (d, b) { 3498 d.__proto__ = b; 3499 } || function (d, b) { 3500 for (var p in b) { 3501 if (b.hasOwnProperty(p)) d[p] = b[p]; 3502 } 3503 }; 3504 3505 return _extendStatics(d, b); 3506 }; 3507 3508 return function (d, b) { 3509 _extendStatics(d, b); 3510 3511 function __() { 3512 this.constructor = d; 3513 } 3514 3515 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 3516 }; 3517 }(); 3518 3519 Object.defineProperty(exports, "__esModule", { 3520 value: true 3521 }); 3522 3523 var AnimationFrameAction = function (_super) { 3524 __extends(AnimationFrameAction, _super); 3525 3526 function AnimationFrameAction(scheduler, work) { 3527 var _this = _super.call(this, scheduler, work) || this; 3528 3529 _this.scheduler = scheduler; 3530 _this.work = work; 3531 return _this; 3532 } 3533 3534 AnimationFrameAction.prototype.requestAsyncId = function (scheduler, id, delay) { 3535 if (delay === void 0) { 3536 delay = 0; 3537 } 3538 3539 if (delay !== null && delay > 0) { 3540 return _super.prototype.requestAsyncId.call(this, scheduler, id, delay); 3541 } 3542 3543 scheduler.actions.push(this); 3544 return scheduler.scheduled || (scheduler.scheduled = requestAnimationFrame(function () { 3545 return scheduler.flush(null); 3546 })); 3547 }; 3548 3549 AnimationFrameAction.prototype.recycleAsyncId = function (scheduler, id, delay) { 3550 if (delay === void 0) { 3551 delay = 0; 3552 } 3553 3554 if (delay !== null && delay > 0 || delay === null && this.delay > 0) { 3555 return _super.prototype.recycleAsyncId.call(this, scheduler, id, delay); 3556 } 3557 3558 if (scheduler.actions.length === 0) { 3559 cancelAnimationFrame(id); 3560 scheduler.scheduled = undefined; 3561 } 3562 3563 return undefined; 3564 }; 3565 3566 return AnimationFrameAction; 3567 }(AsyncAction_1.AsyncAction); 3568 3569 exports.AnimationFrameAction = AnimationFrameAction; 3570 }); 3571 3572 var Scheduler_1 = createCommonjsModule(function (module, exports) { 3573 3574 Object.defineProperty(exports, "__esModule", { 3575 value: true 3576 }); 3577 3578 var Scheduler = function () { 3579 function Scheduler(SchedulerAction, now) { 3580 if (now === void 0) { 3581 now = Scheduler.now; 3582 } 3583 3584 this.SchedulerAction = SchedulerAction; 3585 this.now = now; 3586 } 3587 3588 Scheduler.prototype.schedule = function (work, delay, state) { 3589 if (delay === void 0) { 3590 delay = 0; 3591 } 3592 3593 return new this.SchedulerAction(this, work).schedule(state, delay); 3594 }; 3595 3596 Scheduler.now = function () { 3597 return Date.now(); 3598 }; 3599 3600 return Scheduler; 3601 }(); 3602 3603 exports.Scheduler = Scheduler; 3604 }); 3605 3606 var AsyncScheduler_1 = createCommonjsModule(function (module, exports) { 3607 3608 var __extends = commonjsGlobal && commonjsGlobal.__extends || function () { 3609 var _extendStatics = function extendStatics(d, b) { 3610 _extendStatics = Object.setPrototypeOf || { 3611 __proto__: [] 3612 } instanceof Array && function (d, b) { 3613 d.__proto__ = b; 3614 } || function (d, b) { 3615 for (var p in b) { 3616 if (b.hasOwnProperty(p)) d[p] = b[p]; 3617 } 3618 }; 3619 3620 return _extendStatics(d, b); 3621 }; 3622 3623 return function (d, b) { 3624 _extendStatics(d, b); 3625 3626 function __() { 3627 this.constructor = d; 3628 } 3629 3630 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 3631 }; 3632 }(); 3633 3634 Object.defineProperty(exports, "__esModule", { 3635 value: true 3636 }); 3637 3638 var AsyncScheduler = function (_super) { 3639 __extends(AsyncScheduler, _super); 3640
3641 function AsyncScheduler(SchedulerAction, now) { 3642 if (now === void 0) { 3643 now = Scheduler_1.Scheduler.now; 3644 } 3645 3646 var _this = _super.call(this, SchedulerAction, function () { 3647 if (AsyncScheduler.delegate && AsyncScheduler.delegate !== _this) { 3648 return AsyncScheduler.delegate.now(); 3649 } else { 3650 return now(); 3651 } 3652 }) || this; 3653 3654 _this.actions = []; 3655 _this.active = false; 3656 _this.scheduled = undefined; 3657 return _this; 3658 } 3659 3660 AsyncScheduler.prototype.schedule = function (work, delay, state) { 3661 if (delay === void 0) { 3662 delay = 0; 3663 } 3664 3665 if (AsyncScheduler.delegate && AsyncScheduler.delegate !== this) { 3666 return AsyncScheduler.delegate.schedule(work, delay, state); 3667 } else { 3668 return _super.prototype.schedule.call(this, work, delay, state); 3669 } 3670 }; 3671 3672 AsyncScheduler.prototype.flush = function (action) { 3673 var actions = this.actions; 3674 3675 if (this.active) { 3676 actions.push(action); 3677 return; 3678 } 3679 3680 var error; 3681 this.active = true; 3682 3683 do { 3684 if (error = action.execute(action.state, action.delay)) { 3685 break; 3686 } 3687 } while (action = actions.shift()); 3688 3689 this.active = false; 3690 3691 if (error) { 3692 while (action = actions.shift()) { 3693 action.unsubscribe(); 3694 } 3695 3696 throw error; 3697 } 3698 }; 3699 3700 return AsyncScheduler; 3701 }(Scheduler_1.Scheduler); 3702 3703 exports.AsyncScheduler = AsyncScheduler; 3704 }); 3705 3706 var AnimationFrameScheduler_1 = createCommonjsModule(function (module, exports) { 3707 3708 var __extends = commonjsGlobal && commonjsGlobal.__extends || function () { 3709 var _extendStatics = function extendStatics(d, b) { 3710 _extendStatics = Object.setPrototypeOf || { 3711 __proto__: [] 3712 } instanceof Array && function (d, b) { 3713 d.__proto__ = b; 3714 } || function (d, b) { 3715 for (var p in b) { 3716 if (b.hasOwnProperty(p)) d[p] = b[p]; 3717 } 3718 }; 3719 3720 return _extendStatics(d, b); 3721 }; 3722 3723 return function (d, b) { 3724 _extendStatics(d, b); 3725 3726 function __() { 3727 this.constructor = d; 3728 } 3729 3730 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 3731 }; 3732 }(); 3733 3734 Object.defineProperty(exports, "__esModule", { 3735 value: true 3736 }); 3737 3738 var AnimationFrameScheduler = function (_super) { 3739 __extends(AnimationFrameScheduler, _super); 3740 3741 function AnimationFrameScheduler() { 3742 return _super !== null && _super.apply(this, arguments) || this; 3743 } 3744 3745 AnimationFrameScheduler.prototype.flush = function (action) { 3746 this.active = true; 3747 this.scheduled = undefined; 3748 var actions = this.actions; 3749 var error; 3750 var index = -1; 3751 var count = actions.length; 3752 action = action || actions.shift(); 3753 3754 do { 3755 if (error = action.execute(action.state, action.delay)) { 3756 break; 3757 } 3758 } while (++index < count && (action = actions.shift())); 3759 3760 this.active = false; 3761 3762 if (error) { 3763 while (++index < count && (action = actions.shift())) { 3764 action.unsubscribe(); 3765 } 3766 3767 throw error; 3768 } 3769 }; 3770 3771 return AnimationFrameScheduler; 3772 }(AsyncScheduler_1.AsyncScheduler); 3773 3774 exports.AnimationFrameScheduler = AnimationFrameScheduler; 3775 }); 3776 3777 var animationFrame = createCommonjsModule(function (module, exports) { 3778 3779 Object.defineProperty(exports, "__esModule", { 3780 value: true 3781 }); 3782 exports.animationFrame = new AnimationFrameScheduler_1.AnimationFrameScheduler(AnimationFrameAction_1.AnimationFrameAction); 3783 }); 3784 3785 /** PURE_IMPORTS_START tslib,_OuterSubscriber,_util_subscribeToResult PURE_IMPORTS_END */ 3786 function audit(durationSelector) { 3787 return function auditOperatorFunction(source) { 3788 return source.lift(new AuditOperator(durationSelector)); 3789 }; 3790 } 3791 3792 var AuditOperator = /*@__PURE__*/function () { 3793 function AuditOperator(durationSelector) { 3794 this.durationSelector = durationSelector; 3795 } 3796 3797 AuditOperator.prototype.call = function (subscriber, source) { 3798 return source.subscribe(new AuditSubscriber(subscriber, this.durationSelector)); 3799 }; 3800 3801 return AuditOperator; 3802 }(); 3803 3804 var AuditSubscriber = /*@__PURE__*/function (_super) { 3805 __extends(AuditSubscriber, _super); 3806 3807 function AuditSubscriber(destination, durationSelector) { 3808 var _this = _super.call(this, destination) || this; 3809 3810 _this.durationSelector = durationSelector; 3811 _this.hasValue = false;
3812 return _this; 3813 } 3814 3815 AuditSubscriber.prototype._next = function (value) { 3816 this.value = value; 3817 this.hasValue = true; 3818 3819 if (!this.throttled) { 3820 var duration = void 0; 3821 3822 try { 3823 var durationSelector = this.durationSelector; 3824 duration = durationSelector(value); 3825 } catch (err) { 3826 return this.destination.error(err); 3827 } 3828 3829 var innerSubscription = subscribeToResult(this, duration); 3830 3831 if (!innerSubscription || innerSubscription.closed) { 3832 this.clearThrottle(); 3833 } else { 3834 this.add(this.throttled = innerSubscription); 3835 } 3836 } 3837 }; 3838 3839 AuditSubscriber.prototype.clearThrottle = function () { 3840 var _a = this, 3841 value = _a.value, 3842 hasValue = _a.hasValue, 3843 throttled = _a.throttled; 3844 3845 if (throttled) { 3846 this.remove(throttled); 3847 this.throttled = null; 3848 throttled.unsubscribe(); 3849 } 3850 3851 if (hasValue) { 3852 this.value = null; 3853 this.hasValue = false; 3854 this.destination.next(value); 3855 } 3856 }; 3857 3858 AuditSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex) { 3859 this.clearThrottle(); 3860 }; 3861 3862 AuditSubscriber.prototype.notifyComplete = function () { 3863 this.clearThrottle(); 3864 }; 3865 3866 return AuditSubscriber; 3867 }(OuterSubscriber); 3868 3869 /** PURE_IMPORTS_START _scheduler_async,_audit,_observable_timer PURE_IMPORTS_END */ 3870 function auditTime(duration, scheduler) { 3871 if (scheduler === void 0) { 3872 scheduler = async; 3873 } 3874 3875 return audit(function () { 3876 return timer(duration, scheduler); 3877 }); 3878 } 3879 3880 /** PURE_IMPORTS_START tslib,_Subscriber,_scheduler_async PURE_IMPORTS_END */ 3881 function debounceTime(dueTime, scheduler) { 3882 if (scheduler === void 0) { 3883 scheduler = async; 3884 } 3885 3886 return function (source) { 3887 return source.lift(new DebounceTimeOperator(dueTime, scheduler)); 3888 }; 3889 } 3890 3891 var DebounceTimeOperator = /*@__PURE__*/function () { 3892 function DebounceTimeOperator(dueTime, scheduler) { 3893 this.dueTime = dueTime; 3894 this.scheduler = scheduler; 3895 } 3896 3897 DebounceTimeOperator.prototype.call = function (subscriber, source) { 3898 return source.subscribe(new DebounceTimeSubscriber(subscriber, this.dueTime, this.scheduler)); 3899 }; 3900 3901 return DebounceTimeOperator; 3902 }(); 3903 3904 var DebounceTimeSubscriber = /*@__PURE__*/function (_super) { 3905 __extends(DebounceTimeSubscriber, _super); 3906 3907 function DebounceTimeSubscriber(destination, dueTime, scheduler) { 3908 var _this = _super.call(this, destination) || this; 3909 3910 _this.dueTime = dueTime; 3911 _this.scheduler = scheduler; 3912 _this.debouncedSubscription = null; 3913 _this.lastValue = null; 3914 _this.hasValue = false; 3915 return _this; 3916 } 3917 3918 DebounceTimeSubscriber.prototype._next = function (value) { 3919 this.clearDebounce(); 3920 this.lastValue = value; 3921 this.hasValue = true; 3922 this.add(this.debouncedSubscription = this.scheduler.schedule(dispatchNext, this.dueTime, this)); 3923 }; 3924 3925 DebounceTimeSubscriber.prototype._complete = function () { 3926 this.debouncedNext(); 3927 this.destination.complete(); 3928 }; 3929 3930 DebounceTimeSubscriber.prototype.debouncedNext = function () { 3931 this.clearDebounce(); 3932 3933 if (this.hasValue) { 3934 var lastValue = this.lastValue; 3935 this.lastValue = null; 3936 this.hasValue = false; 3937 this.destination.next(lastValue); 3938 } 3939 }; 3940 3941 DebounceTimeSubscriber.prototype.clearDebounce = function () { 3942 var debouncedSubscription = this.debouncedSubscription; 3943 3944 if (debouncedSubscription !== null) { 3945 this.remove(debouncedSubscription); 3946 debouncedSubscription.unsubscribe(); 3947 this.debouncedSubscription = null; 3948 } 3949 }; 3950 3951 return DebounceTimeSubscriber; 3952 }(Subscriber); 3953 3954 function dispatchNext(subscriber) { 3955 subscriber.debouncedNext(); 3956 } 3957 3958 /** PURE_IMPORTS_START tslib,_Subscriber PURE_IMPORTS_END */ 3959 function defaultIfEmpty(defaultValue) { 3960 if (defaultValue === void 0) { 3961 defaultValue = null; 3962 } 3963 3964 return function (source) { 3965 return source.lift(new DefaultIfEmptyOperator(defaultValue)); 3966 }; 3967 } 3968 3969 var DefaultIfEmptyOperator = /*@__PURE__*/function () {
3970 function DefaultIfEmptyOperator(defaultValue) { 3971 this.defaultValue = defaultValue; 3972 } 3973 3974 DefaultIfEmptyOperator.prototype.call = function (subscriber, source) { 3975 return source.subscribe(new DefaultIfEmptySubscriber(subscriber, this.defaultValue)); 3976 }; 3977 3978 return DefaultIfEmptyOperator; 3979 }(); 3980 3981 var DefaultIfEmptySubscriber = /*@__PURE__*/function (_super) { 3982 __extends(DefaultIfEmptySubscriber, _super); 3983 3984 function DefaultIfEmptySubscriber(destination, defaultValue) { 3985 var _this = _super.call(this, destination) || this; 3986 3987 _this.defaultValue = defaultValue; 3988 _this.isEmpty = true; 3989 return _this; 3990 } 3991 3992 DefaultIfEmptySubscriber.prototype._next = function (value) { 3993 this.isEmpty = false; 3994 this.destination.next(value); 3995 }; 3996 3997 DefaultIfEmptySubscriber.prototype._complete = function () { 3998 if (this.isEmpty) { 3999 this.destination.next(this.defaultValue); 4000 } 4001 4002 this.destination.complete(); 4003 }; 4004 4005 return DefaultIfEmptySubscriber; 4006 }(Subscriber); 4007 4008 /** PURE_IMPORTS_START tslib,_Subscriber PURE_IMPORTS_END */ 4009 function distinctUntilChanged(compare, keySelector) { 4010 return function (source) { 4011 return source.lift(new DistinctUntilChangedOperator(compare, keySelector)); 4012 }; 4013 } 4014 4015 var DistinctUntilChangedOperator = /*@__PURE__*/function () { 4016 function DistinctUntilChangedOperator(compare, keySelector) { 4017 this.compare = compare; 4018 this.keySelector = keySelector; 4019 } 4020 4021 DistinctUntilChangedOperator.prototype.call = function (subscriber, source) { 4022 return source.subscribe(new DistinctUntilChangedSubscriber(subscriber, this.compare, this.keySelector)); 4023 }; 4024 4025 return DistinctUntilChangedOperator; 4026 }(); 4027 4028 var DistinctUntilChangedSubscriber = /*@__PURE__*/function (_super) { 4029 __extends(DistinctUntilChangedSubscriber, _super); 4030 4031 function DistinctUntilChangedSubscriber(destination, compare, keySelector) { 4032 var _this = _super.call(this, destination) || this; 4033 4034 _this.keySelector = keySelector; 4035 _this.hasKey = false; 4036 4037 if (typeof compare === 'function') { 4038 _this.compare = compare; 4039 } 4040 4041 return _this; 4042 } 4043 4044 DistinctUntilChangedSubscriber.prototype.compare = function (x, y) { 4045 return x === y; 4046 }; 4047 4048 DistinctUntilChangedSubscriber.prototype._next = function (value) { 4049 var key; 4050 4051 try { 4052 var keySelector = this.keySelector; 4053 key = keySelector ? keySelector(value) : value; 4054 } catch (err) { 4055 return this.destination.error(err); 4056 } 4057 4058 var result = false;
4059 4060 if (this.hasKey) { 4061 try { 4062 var compare = this.compare; 4063 result = compare(this.key, key); 4064 } catch (err) { 4065 return this.destination.error(err); 4066 } 4067 } else { 4068 this.hasKey = true; 4069 } 4070 4071 if (!result) { 4072 this.key = key; 4073 this.destination.next(value); 4074 } 4075 }; 4076 4077 return DistinctUntilChangedSubscriber; 4078 }(Subscriber); 4079 4080 /** PURE_IMPORTS_START tslib,_Subscriber PURE_IMPORTS_END */ 4081 function filter(predicate, thisArg) { 4082 return function filterOperatorFunction(source) { 4083 return source.lift(new FilterOperator(predicate, thisArg)); 4084 }; 4085 } 4086 4087 var FilterOperator = /*@__PURE__*/function () { 4088 function FilterOperator(predicate, thisArg) { 4089 this.predicate = predicate; 4090 this.thisArg = thisArg; 4091 } 4092 4093 FilterOperator.prototype.call = function (subscriber, source) { 4094 return source.subscribe(new FilterSubscriber(subscriber, this.predicate, this.thisArg)); 4095 }; 4096 4097 return FilterOperator; 4098 }(); 4099 4100 var FilterSubscriber = /*@__PURE__*/function (_super) { 4101 __extends(FilterSubscriber, _super); 4102 4103 function FilterSubscriber(destination, predicate, thisArg) { 4104 var _this = _super.call(this, destination) || this; 4105 4106 _this.predicate = predicate; 4107 _this.thisArg = thisArg; 4108 _this.count = 0; 4109 return _this; 4110 } 4111 4112 FilterSubscriber.prototype._next = function (value) { 4113 var result; 4114 4115 try { 4116 result = this.predicate.call(this.thisArg, value, this.count++); 4117 } catch (err) { 4118 this.destination.error(err); 4119 return; 4120 } 4121 4122 if (result) { 4123 this.destination.next(value); 4124 } 4125 }; 4126 4127 return FilterSubscriber; 4128 }(Subscriber); 4129 4130 /** PURE_IMPORTS_START tslib,_Subscriber,_util_noop,_util_isFunction PURE_IMPORTS_END */ 4131 function tap(nextOrObserver, error, complete) { 4132 return function tapOperatorFunction(source) { 4133 return source.lift(new DoOperator(nextOrObserver, error, complete)); 4134 }; 4135 } 4136 4137 var DoOperator = /*@__PURE__*/function () { 4138 function DoOperator(nextOrObserver, error, complete) { 4139 this.nextOrObserver = nextOrObserver; 4140 this.error = error; 4141 this.complete = complete; 4142 } 4143 4144 DoOperator.prototype.call = function (subscriber, source) { 4145 return source.subscribe(new TapSubscriber(subscriber, this.nextOrObserver, this.error, this.complete)); 4146 }; 4147 4148 return DoOperator; 4149 }(); 4150 4151 var TapSubscriber = /*@__PURE__*/function (_super) { 4152 __extends(TapSubscriber, _super); 4153 4154 function TapSubscriber(destination, observerOrNext, error, complete) { 4155 var _this = _super.call(this, destination) || this; 4156 4157 _this._tapNext = noop; 4158 _this._tapError = noop; 4159 _this._tapComplete = noop; 4160 _this._tapError = error || noop; 4161 _this._tapComplete = complete || noop; 4162 4163 if (isFunction(observerOrNext)) { 4164 _this._context = _this; 4165 _this._tapNext = observerOrNext; 4166 } else if (observerOrNext) { 4167 _this._context = observerOrNext; 4168 _this._tapNext = observerOrNext.next || noop; 4169 _this._tapError = observerOrNext.error || noop; 4170 _this._tapComplete = observerOrNext.complete || noop; 4171 } 4172 4173 return _this; 4174 } 4175 4176 TapSubscriber.prototype._next = function (value) { 4177 try { 4178 this._tapNext.call(this._context, value); 4179 } catch (err) { 4180 this.destination.error(err); 4181 return; 4182 } 4183 4184 this.destination.next(value); 4185 }; 4186 4187 TapSubscriber.prototype._error = function (err) { 4188 try { 4189 this._tapError.call(this._context, err); 4190 } catch (err) { 4191 this.destination.error(err); 4192 return; 4193 } 4194 4195 this.destination.error(err); 4196 }; 4197 4198 TapSubscriber.prototype._complete = function () { 4199 try { 4200 this._tapComplete.call(this._context); 4201 } catch (err) { 4202 this.destination.error(err); 4203 return; 4204 } 4205 4206 return this.destination.complete(); 4207 }; 4208 4209 return TapSubscriber; 4210 }(Subscriber); 4211 4212 /** PURE_IMPORTS_START _tap,_util_EmptyError PURE_IMPORTS_END */ 4213 var throwIfEmpty = function throwIfEmpty(errorFactory) { 4214 if (errorFactory === void 0) { 4215 errorFactory = defaultErrorFactory; 4216 } 4217 4218 return tap({ 4219 hasValue: false, 4220 next: function next() { 4221 this.hasValue = true; 4222 }, 4223 complete: function complete() { 4224 if (!this.hasValue) { 4225 throw errorFactory(); 4226 } 4227 } 4228 }); 4229 }; 4230 4231 function defaultErrorFactory() { 4232 return new EmptyError(); 4233 } 4234 4235 /** PURE_IMPORTS_START tslib,_Subscriber,_util_ArgumentOutOfRangeError,_observable_empty PURE_IMPORTS_END */ 4236 function take(count) { 4237 return function (source) { 4238 if (count === 0) { 4239 return empty$1(); 4240 } else { 4241 return source.lift(new TakeOperator(count)); 4242 } 4243 }; 4244 } 4245 4246 var TakeOperator = /*@__PURE__*/function () { 4247 function TakeOperator(total) { 4248 this.total = total; 4249 4250 if (this.total < 0) { 4251 throw new ArgumentOutOfRangeError(); 4252 } 4253 } 4254 4255 TakeOperator.prototype.call = function (subscriber, source) { 4256 return source.subscribe(new TakeSubscriber(subscriber, this.total)); 4257 }; 4258 4259 return TakeOperator; 4260 }(); 4261 4262 var TakeSubscriber = /*@__PURE__*/function (_super) { 4263 __extends(TakeSubscriber, _super); 4264 4265 function TakeSubscriber(destination, total) { 4266 var _this = _super.call(this, destination) || this; 4267 4268 _this.total = total; 4269 _this.count = 0; 4270 return _this; 4271 } 4272 4273 TakeSubscriber.prototype._next = function (value) { 4274 var total = this.total; 4275 var count = ++this.count; 4276 4277 if (count <= total) { 4278 this.destination.next(value); 4279 4280 if (count === total) { 4281 this.destination.complete(); 4282 this.unsubscribe(); 4283 } 4284 } 4285 }; 4286 4287 return TakeSubscriber; 4288 }(Subscriber); 4289 4290 /** PURE_IMPORTS_START tslib,_Subscriber,_Subscription PURE_IMPORTS_END */ 4291 function finalize(callback) { 4292 return function (source) { 4293 return source.lift(new FinallyOperator(callback)); 4294 }; 4295 } 4296 4297 var FinallyOperator = /*@__PURE__*/function () { 4298 function FinallyOperator(callback) { 4299 this.callback = callback; 4300 } 4301 4302 FinallyOperator.prototype.call = function (subscriber, source) { 4303 return source.subscribe(new FinallySubscriber(subscriber, this.callback)); 4304 }; 4305 4306 return FinallyOperator; 4307 }(); 4308 4309 var FinallySubscriber = /*@__PURE__*/function (_super) { 4310 __extends(FinallySubscriber, _super); 4311 4312 function FinallySubscriber(destination, callback) { 4313 var _this = _super.call(this, destination) || this; 4314 4315 _this.add(new Subscription(callback)); 4316 4317 return _this; 4318 } 4319 4320 return FinallySubscriber; 4321 }(Subscriber); 4322 4323 /** PURE_IMPORTS_START _util_EmptyError,_filter,_take,_defaultIfEmpty,_throwIfEmpty,_util_identity PURE_IMPORTS_END */ 4324 function first(predicate, defaultValue) { 4325 var hasDefaultValue = arguments.length >= 2; 4326 return function (source) { 4327 return source.pipe(predicate ? filter(function (v, i) { 4328 return predicate(v, i, source); 4329 }) : identity, take(1), hasDefaultValue ? defaultIfEmpty(defaultValue) : throwIfEmpty(function () { 4330 return new EmptyError(); 4331 })); 4332 }; 4333 } 4334 4335 /** PURE_IMPORTS_START _ReplaySubject PURE_IMPORTS_END */ 4336 function shareReplay(configOrBufferSize, windowTime, scheduler) { 4337 var config; 4338 4339 if (configOrBufferSize && typeof configOrBufferSize === 'object') { 4340 config = configOrBufferSize; 4341 } else { 4342 config = { 4343 bufferSize: configOrBufferSize, 4344 windowTime: windowTime, 4345 refCount: false, 4346 scheduler: scheduler 4347 }; 4348 } 4349 4350 return function (source) { 4351 return source.lift(shareReplayOperator(config)); 4352 }; 4353 } 4354 4355 function shareReplayOperator(_a) { 4356 var _b = _a.bufferSize, 4357 bufferSize = _b === void 0 ? Number.POSITIVE_INFINITY : _b, 4358 _c = _a.windowTime, 4359 windowTime = _c === void 0 ? Number.POSITIVE_INFINITY : _c, 4360 useRefCount = _a.refCount, 4361 scheduler = _a.scheduler; 4362 var subject; 4363 var refCount = 0; 4364 var subscription; 4365 var hasError = false;
4366 var isComplete = false; 4367 return function shareReplayOperation(source) { 4368 refCount++; 4369 4370 if (!subject || hasError) { 4371 hasError = false; 4372 subject = new ReplaySubject(bufferSize, windowTime, scheduler); 4373 subscription = source.subscribe({ 4374 next: function next(value) { 4375 subject.next(value); 4376 }, 4377 error: function error(err) { 4378 hasError = true; 4379 subject.error(err); 4380 }, 4381 complete: function complete() { 4382 isComplete = true; 4383 subject.complete(); 4384 } 4385 }); 4386 } 4387 4388 var innerSub = subject.subscribe(this); 4389 this.add(function () { 4390 refCount--; 4391 innerSub.unsubscribe(); 4392 4393 if (subscription && !isComplete && useRefCount && refCount === 0) { 4394 subscription.unsubscribe(); 4395 subscription = undefined; 4396 subject = undefined; 4397 } 4398 }); 4399 }; 4400 } 4401 4402 /** PURE_IMPORTS_START _observable_fromArray,_observable_scalar,_observable_empty,_observable_concat,_util_isScheduler PURE_IMPORTS_END */ 4403 function startWith() { 4404 var array = []; 4405 4406 for (var _i = 0; _i < arguments.length; _i++) { 4407 array[_i] = arguments[_i]; 4408 } 4409 4410 return function (source) { 4411 var scheduler = array[array.length - 1]; 4412 4413 if (isScheduler(scheduler)) { 4414 array.pop(); 4415 } else { 4416 scheduler = null; 4417 } 4418 4419 var len = array.length; 4420 4421 if (len === 1 && !scheduler) { 4422 return concat(scalar(array[0]), source); 4423 } else if (len > 0) { 4424 return concat(fromArray(array, scheduler), source); 4425 } else { 4426 return concat(empty$1(scheduler), source); 4427 } 4428 }; 4429 } 4430 4431 /** PURE_IMPORTS_START tslib,_OuterSubscriber,_InnerSubscriber,_util_subscribeToResult,_map,_observable_from PURE_IMPORTS_END */ 4432 function switchMap(project, resultSelector) { 4433 if (typeof resultSelector === 'function') { 4434 return function (source) { 4435 return source.pipe(switchMap(function (a, i) { 4436 return from(project(a, i)).pipe(map(function (b, ii) { 4437 return resultSelector(a, b, i, ii); 4438 })); 4439 })); 4440 }; 4441 } 4442 4443 return function (source) { 4444 return source.lift(new SwitchMapOperator(project)); 4445 }; 4446 } 4447 4448 var SwitchMapOperator = /*@__PURE__*/function () { 4449 function SwitchMapOperator(project) { 4450 this.project = project; 4451 } 4452 4453 SwitchMapOperator.prototype.call = function (subscriber, source) { 4454 return source.subscribe(new SwitchMapSubscriber(subscriber, this.project)); 4455 }; 4456 4457 return SwitchMapOperator; 4458 }(); 4459 4460 var SwitchMapSubscriber = /*@__PURE__*/function (_super) { 4461 __extends(SwitchMapSubscriber, _super); 4462 4463 function SwitchMapSubscriber(destination, project) { 4464 var _this = _super.call(this, destination) || this; 4465 4466 _this.project = project; 4467 _this.index = 0; 4468 return _this; 4469 } 4470 4471 SwitchMapSubscriber.prototype._next = function (value) { 4472 var result; 4473 var index = this.index++; 4474 4475 try { 4476 result = this.project(value, index); 4477 } catch (error) { 4478 this.destination.error(error); 4479 return; 4480 } 4481 4482 this._innerSub(result, value, index); 4483 }; 4484 4485 SwitchMapSubscriber.prototype._innerSub = function (result, value, index) { 4486 var innerSubscription = this.innerSubscription; 4487 4488 if (innerSubscription) { 4489 innerSubscription.unsubscribe(); 4490 } 4491 4492 var innerSubscriber = new InnerSubscriber(this, undefined, undefined); 4493 var destination = this.destination; 4494 destination.add(innerSubscriber); 4495 this.innerSubscription = subscribeToResult(this, result, value, index, innerSubscriber); 4496 }; 4497 4498 SwitchMapSubscriber.prototype._complete = function () { 4499 var innerSubscription = this.innerSubscription; 4500 4501 if (!innerSubscription || innerSubscription.closed) { 4502 _super.prototype._complete.call(this); 4503 } 4504 4505 this.unsubscribe(); 4506 }; 4507 4508 SwitchMapSubscriber.prototype._unsubscribe = function () { 4509 this.innerSubscription = null; 4510 }; 4511 4512 SwitchMapSubscriber.prototype.notifyComplete = function (innerSub) { 4513 var destination = this.destination; 4514 destination.remove(innerSub); 4515 this.innerSubscription = null; 4516 4517 if (this.isStopped) { 4518 _super.prototype._complete.call(this); 4519 } 4520 }; 4521 4522 SwitchMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { 4523 this.destination.next(innerValue); 4524 }; 4525 4526 return SwitchMapSubscriber; 4527 }(OuterSubscriber); 4528 4529 /** PURE_IMPORTS_START tslib,_OuterSubscriber,_util_subscribeToResult PURE_IMPORTS_END */ 4530 function takeUntil(notifier) { 4531 return function (source) { 4532 return source.lift(new TakeUntilOperator(notifier)); 4533 }; 4534 } 4535 4536 var TakeUntilOperator = /*@__PURE__*/function () { 4537 function TakeUntilOperator(notifier) { 4538 this.notifier = notifier; 4539 } 4540 4541 TakeUntilOperator.prototype.call = function (subscriber, source) { 4542 var takeUntilSubscriber = new TakeUntilSubscriber(subscriber); 4543 var notifierSubscription = subscribeToResult(takeUntilSubscriber, this.notifier); 4544 4545 if (notifierSubscription && !takeUntilSubscriber.seenValue) { 4546 takeUntilSubscriber.add(notifierSubscription); 4547 return source.subscribe(takeUntilSubscriber); 4548 } 4549 4550 return takeUntilSubscriber; 4551 }; 4552 4553 return TakeUntilOperator; 4554 }(); 4555 4556 var TakeUntilSubscriber = /*@__PURE__*/function (_super) { 4557 __extends(TakeUntilSubscriber, _super); 4558 4559 function TakeUntilSubscriber(destination) { 4560 var _this = _super.call(this, destination) || this; 4561 4562 _this.seenValue = false;
4563 return _this; 4564 } 4565 4566 TakeUntilSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { 4567 this.seenValue = true; 4568 this.complete(); 4569 }; 4570 4571 TakeUntilSubscriber.prototype.notifyComplete = function () {}; 4572 4573 return TakeUntilSubscriber; 4574 }(OuterSubscriber); 4575 4576 /* jshint esversion: 6 */ 4577 var Rect = /*#__PURE__*/function () { 4578 function Rect(rect) { 4579 this.top = 0; 4580 this.right = 0; 4581 this.bottom = 0; 4582 this.left = 0; 4583 this.width = 0; 4584 this.height = 0; 4585 this.set(rect); 4586 } 4587 4588 Rect.contains = function contains(rect, left, top) { 4589 return rect.top <= top && top <= rect.bottom && rect.left <= left && left <= rect.right; 4590 }; 4591 4592 Rect.intersectRect = function intersectRect(r1, r2) { 4593 return !(r2.left > r1.right || r2.right < r1.left || r2.top > r1.bottom || r2.bottom < r1.top); 4594 }; 4595 4596 Rect.fromNode = function fromNode(node) { 4597 if (!node) { 4598 return; 4599 } 4600 4601 var rect = node.rect_ || (node.rect_ = new Rect()); 4602 var rects = node.getClientRects(); 4603 4604 if (!rects.length) { 4605 // console.log(rects, node); 4606 return rect; 4607 } 4608 4609 var boundingRect = node.getBoundingClientRect(); // rect.top: boundingRect.top + defaultView.pageYOffset, 4610 // rect.left: boundingRect.left + defaultView.pageXOffset, 4611 4612 rect.top = boundingRect.top; 4613 rect.left = boundingRect.left; 4614 rect.width = boundingRect.width; 4615 rect.height = boundingRect.height; 4616 rect.setCenter(); 4617 return rect; 4618 }; 4619 4620 var _proto = Rect.prototype; 4621 4622 _proto.set = function set(rect) { 4623 if (rect) { 4624 Object.assign(this, rect); 4625 this.right = this.left + this.width; 4626 this.bottom = this.top + this.height; 4627 } 4628 4629 this.setCenter(); 4630 }; 4631 4632 _proto.setCenter = function setCenter() { 4633 var center = this.center || (this.center = {}); 4634 center.top = this.top + this.height / 2; 4635 center.left = this.left + this.width / 2; 4636 center.x = center.left; 4637 center.y = center.top; 4638 }; 4639 4640 _proto.contains = function contains(left, top) { 4641 return Rect.contains(this, left, top); 4642 }; 4643 4644 _proto.intersect = function intersect(rect) { 4645 return Rect.intersectRect(this, rect); 4646 }; 4647 4648 _proto.intersection = function intersection(rect) { 4649 var intersection = this.intersection_ || (this.intersection_ = { 4650 center: {} 4651 }); 4652 intersection.center.x = (this.center.x - rect.center.x) / (rect.width / 2); 4653 intersection.center.y = (this.center.y - rect.center.y) / (rect.height / 2); 4654 var dx = this.left > rect.left ? 0 : Math.abs(rect.left - this.left); 4655 var dy = this.top > rect.top ? 0 : Math.abs(rect.top - this.top); 4656 var x = dx ? 1 - dx / this.width : (rect.left + rect.width - this.left) / this.width; 4657 var y = dy ? 1 - dy / this.height : (rect.top + rect.height - this.top) / this.height; // console.log(this.top, this.height, rect.top, rect.height); 4658 4659 intersection.x = x; 4660 intersection.y = y; 4661 return intersection; 4662 }; 4663 4664 return Rect; 4665 }(); 4666 4667 function tween(from, to, friction) { 4668 if (from === to || Math.abs(to - from) < 0.02) { 4669 return to; 4670 } 4671 4672 return from + (to - from) / friction; 4673 } 4674 4675 var DomService = /*#__PURE__*/function () { 4676 function DomService() { 4677 var hasPassiveEvents = function hasPassiveEvents() { 4678 var has = false; 4679 4680 try { 4681 var options = Object.defineProperty({}, 'passive', { 4682 get: function get() { 4683 has = true; 4684 } 4685 }); 4686 4687 var noop = function noop() {}; 4688 4689 window.addEventListener('testPassiveEventSupport', noop, options); 4690 window.removeEventListener('testPassiveEventSupport', noop, options); 4691 } catch (e) {} 4692 4693 return has; 4694 }; 4695 4696 this.hasPassiveEvents = hasPassiveEvents(); 4697 } 4698 4699 var _proto = DomService.prototype; 4700 4701 _proto.scrollTo = function scrollTo(left, top) { 4702 DomService.DEFAULT_SCROLL_TARGET.scrollTo(0, top); 4703 }; 4704 4705 _proto.scroll = function scroll(options) { 4706 DomService.DEFAULT_SCROLL_TARGET.scroll(options); 4707 }; 4708 4709 _proto.hasWebglSupport = function hasWebglSupport() { 4710 if (this.isIE()) { 4711 return false;
4712 } 4713 4714 if (!this.hasWebgl()) { 4715 return false; 4716 } 4717 4718 return true; 4719 }; 4720 4721 _proto.isIE = function isIE() { 4722 var ua = window.navigator.userAgent; 4723 var msie = ua.indexOf('MSIE '); 4724 4725 if (msie > 0) { 4726 // IE 10 or older => return version number 4727 return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10); 4728 } 4729 4730 var trident = ua.indexOf('Trident/'); 4731 4732 if (trident > 0) { 4733 // IE 11 => return version number 4734 var rv = ua.indexOf('rv:'); 4735 return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10); 4736 } 4737 4738 var edge = ua.indexOf('Edge/'); 4739 4740 if (edge > 0) { 4741 // Edge (IE 12+) => return version number 4742 return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10); 4743 } // other browser 4744 4745 4746 return false; 4747 }; 4748 4749 _proto.hasWebgl = function hasWebgl() { 4750 var gl, 4751 debugInfo, 4752 vendor, 4753 renderer, 4754 has = false; 4755 4756 try { 4757 var canvas = document.createElement('canvas'); 4758 4759 if (!!window.WebGLRenderingContext) { 4760 gl = canvas.getContext('webgl', { 4761 failIfMajorPerformanceCaveat: true 4762 }) || canvas.getContext('experimental-webgl', { 4763 failIfMajorPerformanceCaveat: true 4764 }); 4765 } 4766 } catch (e) { 4767 console.log('no webgl'); 4768 } 4769 4770 if (gl) { 4771 debugInfo = gl.getExtension('WEBGL_debug_renderer_info'); 4772 vendor = gl.getParameter(debugInfo.UNMASKED_VENDOR_WEBGL); 4773 renderer = gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL); 4774 has = true; 4775 } 4776 4777 console.log("WebGLCapabilities debugInfo: " + debugInfo + " vendor: " + vendor + " renderer: " + renderer + " "); 4778 return has; 4779 }; 4780 4781 _proto.getOuterHeight = function getOuterHeight(node) { 4782 var height = node.clientHeight; 4783 var computedStyle = window.getComputedStyle(node); 4784 height += parseInt(computedStyle.marginTop, 10); 4785 height += parseInt(computedStyle.marginBottom, 10); 4786 height += parseInt(computedStyle.borderTopWidth, 10); 4787 height += parseInt(computedStyle.borderBottomWidth, 10); 4788 return height; 4789 }; 4790 4791 _proto.getOuterWidth = function getOuterWidth(node) { 4792 var width = node.clientWidth; 4793 var computedStyle = window.getComputedStyle(node); 4794 width += parseInt(computedStyle.marginLeft, 10); 4795 width += parseInt(computedStyle.marginRight, 10); 4796 width += parseInt(computedStyle.borderLeftWidth, 10); 4797 width += parseInt(computedStyle.borderRightWidth, 10); 4798 return width; 4799 }; 4800 4801 _proto.raf$ = function raf$() { 4802 return DomService.raf$; 4803 }; 4804 4805 _proto.windowRect$ = function windowRect$() { 4806 return DomService.windowRect$; 4807 }; 4808 4809 _proto.rafAndRect$ = function rafAndRect$() { 4810 return DomService.rafAndRect$; 4811 }; 4812 4813 _proto.scroll$ = function scroll$() { 4814 return DomService.scroll$; 4815 }; 4816 4817 _proto.secondaryScroll$ = function secondaryScroll$(target) { 4818 return DomService.secondaryScroll$(target); 4819 }; 4820 4821 _proto.scrollAndRect$ = function scrollAndRect$() { 4822 return DomService.scrollAndRect$; 4823 }; 4824 4825 _proto.smoothScroll$ = function smoothScroll$(selector, friction) { 4826 var _this = this; 4827 4828 if (friction === void 0) { 4829 friction = 6; 4830 } 4831 4832 var target = document.querySelector('.smooth-scroll'); 4833 var node = document.querySelector(selector); 4834 return this.raf$().pipe(map(function () { 4835 // const outerHeight = this.getOuterHeight(node); 4836 var innerHeight = node.lastElementChild.offsetTop + node.lastElementChild.offsetHeight; 4837 4838 if (parseInt(target.style.height) !== innerHeight) { 4839 target.style.height = innerHeight + "px"; 4840 DomService.IMMEDIATE_SCROLL = true; 4841 } 4842 4843 var top = DomService.IMMEDIATE_SCROLL ? -_this.scrollTop : tween(node.top || 0, -_this.scrollTop, DomService.IMMEDIATE_SCROLL ? 1 : friction); 4844 var left = (node.parentNode.offsetWidth - node.offsetWidth) / 2; 4845 4846 if (node.left !== left) { 4847 node.left = left; 4848 node.style.left = left + "px"; 4849 } 4850 4851 if (node.top !== top) { 4852 node.top = top; // node.style.transform = `translateX(-50%) translateY(${top}px)`; 4853 // node.style.top = `${top}px`; 4854 4855 node.scrollTop = -top; 4856 DomService.IMMEDIATE_SCROLL = false;
4857 return top; 4858 } else { 4859 return null; 4860 } 4861 }), filter(function (y) { 4862 return y !== null; 4863 }), distinctUntilChanged(function (a, b) { 4864 return Math.round(a * 100) === Math.round(b * 100); 4865 }), tap(function (y) { 4866 return DomService.smoothScroll$_.next(y); 4867 }), shareReplay()); 4868 }; 4869 4870 _proto.getStyleSheet = function getStyleSheet() { 4871 for (var i = 0; i < document.styleSheets.length; i++) { 4872 var sheet = document.styleSheets[i]; 4873 return sheet; 4874 } 4875 }; 4876 4877 _proto.virtualScroll$ = function virtualScroll$(selector, friction) { 4878 var _this2 = this; 4879 4880 if (friction === void 0) { 4881 friction = 10; 4882 } 4883 4884 var style = this.getStyleSheet(); 4885 var ruleIndex = style.insertRule(".virtual-scroll:after { content: ''; display:block; width: 100%; height: 1px; }", style.cssRules.length); 4886 var rule = style.cssRules[ruleIndex]; // console.log('rule', style.cssRules.length, rule.cssText); 4887 4888 var outerHeight_ = 0; 4889 var node = document.querySelector(selector); 4890 node.addEventListener('wheel', function (event) { 4891 // console.log('wheel', event); 4892 _this2.scrollTo(0, _this2.scrollTop + event.deltaY); 4893 }); 4894 return this.raf$().pipe(map(function () { 4895 var outerHeight = _this2.getOuterHeight(node); 4896 4897 if (outerHeight_ !== outerHeight) { 4898 outerHeight_ = outerHeight; 4899 rule.style.height = outerHeight_ + "px"; // console.log(rule.style.height); 4900 } 4901 4902 var top = tween(node.top || 0, -_this2.scrollTop, DomService.IMMEDIATE_SCROLL ? 1 : friction); 4903 4904 if (node.top !== top) { 4905 node.top = top; 4906 node.style.transform = "translateX(-50%) translateY(" + top + "px)"; // node.style = `position: fixed; top: 0; transform: translateX(-50%) translateY(${top}px)`; 4907 4908 DomService.IMMEDIATE_SCROLL = false; 4909 return top; 4910 } else { 4911 return null; 4912 } 4913 }), filter(function (y) { 4914 return y !== null; 4915 }), distinctUntilChanged(function (a, b) { 4916 return Math.round(a * 100) === Math.round(b * 100); 4917 }), tap(function (y) { 4918 return DomService.virtualScroll$_.next(y); 4919 }), shareReplay()); 4920 }; 4921 4922 _proto.rafIntersection$ = function rafIntersection$(node) { 4923 return this.rafAndRect$().pipe(map(function (datas) { 4924 // const scrollTop = datas[0]; 4925 var windowRect = datas[1]; 4926 var rect = Rect.fromNode(node); 4927 4928 if (rect.height) { 4929 var intersection = rect.intersection(windowRect); 4930 var response = DomService.rafIntersection_; 4931 response.scroll = datas[0]; 4932 response.windowRect = datas[1]; 4933 response.rect = rect; 4934 response.intersection = intersection; 4935 return response; 4936 } 4937 }), filter(function (response) { 4938 return response !== undefined; 4939 })); 4940 }; 4941 4942 _proto.scrollIntersection$ = function scrollIntersection$(node) { 4943 var o = this.scrollAndRect$().pipe(map(function (datas) { 4944 // const scrollTop = datas[0]; 4945 var windowRect = datas[1]; 4946 var rect = Rect.fromNode(node); 4947 4948 if (rect.height) { 4949 var intersection = rect.intersection(windowRect); 4950 var response = DomService.scrollIntersection_; 4951 response.scroll = datas[0]; 4952 response.windowRect = datas[1]; 4953 response.rect = rect; 4954 response.intersection = intersection; 4955 return response; 4956 } 4957 }), filter(function (response) { 4958 return response !== undefined; 4959 })); 4960 DomService.secondaryScroll$_.next({ 4961 target: window 4962 }); 4963 return o; 4964 }; 4965 4966 _proto.appearOnLoad$ = function appearOnLoad$(node, value) { 4967 var _this3 = this; 4968 4969 if (value === void 0) { 4970 value = 0.0; 4971 } 4972 4973 // -0.5 4974 var isCover = node.hasAttribute('cover'); 4975 return this.rafIntersection$(node).pipe(filter(function (x) { 4976 return (_this3.ready || isCover) && x.intersection.y > value && x.intersection.x > 0; 4977 }), first()); 4978 }; 4979 4980 _proto.appear$ = function appear$(node, value) { 4981 if (value === void 0) { 4982 value = 0.0; 4983 } 4984 4985 // -0.5
4986 return this.rafIntersection$(node).pipe(filter(function (x) { 4987 return x.intersection.y > value; 4988 }), first()); 4989 }; 4990 4991 _proto.visibility$ = function visibility$(node, value) { 4992 if (value === void 0) { 4993 value = 0.5; 4994 } 4995 4996 return this.scrollIntersection$(node).pipe(map(function (x) { 4997 return x.intersection.y > value; 4998 }), distinctUntilChanged()); 4999 }; 5000 5001 _proto.firstVisibility$ = function firstVisibility$(node, value) { 5002 if (value === void 0) { 5003 value = 0.5; 5004 } 5005 5006 return this.visibility$(node, value).pipe(filter(function (visible) { 5007 return visible; 5008 }), first()); 5009 }; 5010 5011 _proto.addCustomRules = function addCustomRules() { 5012 var sheet = this.addCustomSheet(); 5013 var body = document.querySelector('body'); 5014 var node = document.createElement('div'); 5015 node.style.width = '100px'; 5016 node.style.height = '100px'; 5017 node.style.overflow = 'auto'; 5018 node.style.visibility = 'hidden'; 5019 node.style.msOverflowStyle = 'scrollbar'; // needed for WinJS apps 5020 5021 var inner = document.createElement('div'); 5022 inner.style.width = 'auto'; 5023 inner.style.height = '200px'; 5024 node.appendChild(inner); 5025 body.appendChild(node); 5026 var scrollBarWidth = node.offsetWidth - inner.offsetWidth; 5027 body.removeChild(node); 5028 /* 5029 const sheet = this.addCustomSheet(); 5030 const body = document.querySelector('body'); 5031 const scrollBarWidth = window.innerWidth - body.clientWidth; 5032 let rule = `body.droppin-in { padding-right: ${scrollBarWidth}px; }`; 5033 sheet.insertRule(rule, 0); 5034 rule = `body.droppin-in header { width: calc(100% - ${scrollBarWidth}px); }`; 5035 sheet.insertRule(rule, 1); 5036 rule = `body.droppin-in menu--product { width: calc(100% - ${scrollBarWidth}px); }`; 5037 sheet.insertRule(rule, 2); 5038 */ 5039 }; 5040 5041 _proto.addCustomSheet = function addCustomSheet() { 5042 var style = document.createElement('style'); 5043 style.appendChild(document.createTextNode('')); 5044 document.head.appendChild(style); 5045 return style.sheet; 5046 }; 5047 5048 _proto.isDescendantOf = function isDescendantOf(node, target) { 5049 return DomService.isDescendantOf(node, target); 5050 }; 5051 5052 DomService.factory = function factory() { 5053 return new DomService(); 5054 }; 5055 5056 DomService.getScrollTop = function getScrollTop(node) { 5057 if (!node) { 5058 return 0; 5059 } 5060 5061 if (node === document || node === window) { 5062 return this.getScrollTop(document.scrollingElement || document.documentElement || document.body); 5063 } 5064 5065 return node.pageYOffset || node.scrollY || node.scrollTop || 0; 5066 }; 5067 5068 DomService.getScrollLeft = function getScrollLeft(node) { 5069 if (!node) { 5070 return 0; 5071 } 5072 5073 if (node === document || node === window) { 5074 return this.getScrollLeft(document.scrollingElement || document.documentElement || document.body); 5075 } 5076 5077 return node.pageXOffset || node.scrollX || node.scrollLeft || 0; 5078 }; 5079 5080 DomService.detect = function detect() { 5081 var userAgent = navigator.userAgent.toLowerCase(); 5082 var msie = userAgent.indexOf('msie') > -1; 5083 var trident = userAgent.indexOf('trident') > -1; 5084 var explorer = msie || trident; 5085 var firefox = userAgent.indexOf('firefox') > -1; 5086 var opera = userAgent.toLowerCase().indexOf('op') > -1; 5087 var chrome = userAgent.indexOf('chrome') > -1; 5088 var safari = userAgent.indexOf('safari') > -1; 5089 5090 if (chrome && safari) { 5091 safari = false; 5092 } 5093 5094 if (chrome && opera) { 5095 chrome = false; 5096 } 5097 5098 var android = userAgent.match(/android/i); 5099 var blackberry = userAgent.match(/blackberry/i); 5100 var ios = userAgent.match(/iphone|ipad|ipod/i); 5101 var operamini = userAgent.match(/opera mini/i); 5102 var iemobile = userAgent.match(/iemobile/i) || navigator.userAgent.match(/wpdesktop/i); 5103 var mobile = android || blackberry || ios || operamini || iemobile; 5104 var overscroll = navigator.platform === 'MacIntel' && typeof navigator.getBattery === 'function'; 5105 var agent = this.agent = { 5106 chrome: chrome, 5107 msie: msie, 5108 trident: trident, 5109 explorer: explorer, 5110 firefox: firefox, 5111 safari: safari, 5112 opera: opera, 5113 android: android, 5114 blackberry: blackberry, 5115 ios: ios, 5116 operamini: operamini, 5117 iemobile: iemobile, 5118 mobile: mobile, 5119 overscroll: overscroll 5120 }; // Object.assign(DomService, agent); 5121 5122 var html = document.querySelector('html'); 5123 Object.keys(agent).forEach(function (x) { 5124 if (agent[x]) { 5125 html.classList.add(x); 5126 } 5127 }); 5128 return this.agent; 5129 }; 5130 5131 DomService.isDescendantOf = function isDescendantOf(node, target) { 5132 if (node === document) { 5133 return false;
5134 } 5135 5136 if (node === target) { 5137 return true; 5138 } else if (node.parentNode) { 5139 return this.isDescendantOf(node.parentNode, target); 5140 } 5141 }; 5142 5143 DomService.secondaryScroll$ = function secondaryScroll$(target) { 5144 return fromEvent(target, 'scroll').pipe(tap(function (event) { 5145 return DomService.secondaryScroll$_.next(event); 5146 })); 5147 }; 5148 5149 _createClass(DomService, [{ 5150 key: "ready", 5151 get: function get() { 5152 return this.ready_; 5153 }, 5154 set: function set(ready) { 5155 this.ready_ = ready; 5156 } 5157 }, { 5158 key: "scrollTop", 5159 get: function get() { 5160 return DomService.getScrollTop(DomService.DEFAULT_SCROLL_TARGET); 5161 } 5162 }, { 5163 key: "scrollLeft", 5164 get: function get() { 5165 return DomService.getScrollLeft(DomService.DEFAULT_SCROLL_TARGET); 5166 } 5167 }, { 5168 key: "agent", 5169 get: function get() { 5170 return DomService.agent || DomService.detect(); 5171 } 5172 }]); 5173 5174 return DomService; 5175 }(); 5176 DomService.IMMEDIATE_SCROLL = true; 5177 DomService.DEFAULT_SCROLL_TARGET = window; 5178 DomService.factory.$inject = []; 5179 DomService.rafIntersection_ = {}; 5180 DomService.scrollIntersection_ = {}; 5181 DomService.raf$ = range(0, Number.POSITIVE_INFINITY, animationFrame.animationFrame); 5182 5183 DomService.windowRect$ = function () { 5184 var windowRect = new Rect({ 5185 width: window.innerWidth, 5186 height: window.innerHeight 5187 }); 5188 return fromEvent(window, 'resize').pipe(map(function (originalEvent) { 5189 windowRect.width = window.innerWidth; 5190 windowRect.height = window.innerHeight; 5191 return windowRect; 5192 }), startWith(windowRect), shareReplay()); 5193 }(); 5194 5195 DomService.rafAndRect$ = combineLatest(DomService.raf$, DomService.windowRect$).pipe(shareReplay()); 5196 5197 DomService.mainScroll$ = function () { 5198 var target = DomService.DEFAULT_SCROLL_TARGET; 5199 return fromEvent(target, 'scroll').pipe(shareReplay()); 5200 }(); 5201 5202 DomService.smoothScroll$_ = new Subject(); 5203 DomService.virtualScroll$_ = new Subject(); 5204 DomService.secondaryScroll$_ = new Subject(); 5205 5206 DomService.scroll$ = function () { 5207 var target = DomService.DEFAULT_SCROLL_TARGET; 5208 var previousTop = DomService.getScrollTop(target); 5209 var event = { 5210 scrollTop: previousTop, 5211 scrollLeft: DomService.getScrollLeft(target), 5212 direction: 0, 5213 originalEvent: null 5214 }; 5215 return merge(DomService.smoothScroll$_, DomService.secondaryScroll$_).pipe(auditTime(1000 / 60), map(function (originalEvent) { 5216 event.scrollTop = DomService.getScrollTop(originalEvent.target); 5217 event.scrollLeft = DomService.getScrollLeft(originalEvent.target); 5218 var diff = event.scrollTop - previousTop; 5219 event.direction = diff ? diff / Math.abs(diff) : 0; 5220 previousTop = event.scrollTop; 5221 event.originalEvent = originalEvent; 5222 return event; 5223 }), startWith(event), shareReplay()); 5224 }(); 5225 5226 DomService.scrollAndRect$ = combineLatest(DomService.scroll$, DomService.windowRect$).pipe(shareReplay()); 5227 5228 /* jshint esversion: 6 */ 5229 5230 var ColorsCtrl = /*#__PURE__*/function () { 5231 function ColorsCtrl($scope, $timeout, $location, DomService) { 5232 var _this = this; 5233 5234 this.$scope = $scope; 5235 this.$timeout = $timeout; 5236 this.$location = $location; 5237 this.domService = DomService; 5238 this.onWindowResize = this.onWindowResize.bind(this); 5239 this.onKeyDown = this.onKeyDown.bind(this); 5240 this.onShareKeyDown = this.onShareKeyDown.bind(this); 5241 this.onWishlistKeyDown = this.onWishlistKeyDown.bind(this); 5242 this.onViewWishlistKeyDown = this.onViewWishlistKeyDown.bind(this); 5243 this.navigateToWishlist = this.navigateToWishlist.bind(this); 5244 window.addEventListener('resize', this.onWindowResize); 5245 $scope.$on('$destroy', function () { 5246 window.removeEventListener('resize', _this.onWindowResize); 5247 }); 5248 var hash = this.$location.hash(); // const search = this.$location.search(); 5249 // console.log(search); 5250 // if (search.color) { 5251 5252 if (hash.indexOf('color-') === 0) { 5253 window.onload = function () { 5254 setTimeout(function () { 5255 // const color = document.getElementById(`color-${search.color}`); 5256 var color = document.getElementById(hash); // console.log(color); 5257 5258 if (color) { 5259 var colors = Array.prototype.slice.call(document.querySelectorAll('.card--color')); 5260 var index = colors.indexOf(color); 5261 5262 if (index !== -1) { 5263 _this.active = index; 5264 5265 _this.onOpen(color, true); 5266 } // color.scrollIntoView(); 5267 // this.scrollIntoView(color); 5268 5269 } 5270 }, 150); 5271 }; 5272 } 5273 } 5274 5275 var _proto = ColorsCtrl.prototype; 5276 5277 _proto.onKeyDown = function onKeyDown(event) { 5278 // Gestisce la navigazione da tastiera per le card colore 5279 if (event.key === 'Enter' || event.key === ' ') { 5280 event.preventDefault(); 5281 var target = event.currentTarget; 5282 var colors = Array.prototype.slice.call(document.querySelectorAll('.group--colors > .card--color')); 5283 var index = colors.indexOf(target); 5284 5285 if (index !== -1) { 5286 // Marca l'evento come navigazione da tastiera per evitare lo scroll 5287 event.isKeyboardNavigation = true; 5288 this.onToggle(index, event); 5289 } 5290 } 5291 }; 5292 5293 _proto.onShareKeyDown = function onShareKeyDown(event) { 5294 // Gestisce il tasto Enter sul pulsante Share 5295 if (event.key === 'Enter') { 5296 event.preventDefault(); 5297 event.stopPropagation(); 5298 this.$scope.root.share = true; 5299 this.$scope.$apply(); 5300 } 5301 }; 5302 5303 _proto.onWishlistKeyDown = function onWishlistKeyDown(event, wishlistId) { 5304 // Gestisce il tasto Enter sui pulsanti wishlist 5305 if (event.key === 'Enter') { 5306 event.preventDefault(); 5307 event.stopPropagation(); 5308 this.$scope.root.wishlistToggle(wishlistId); 5309 this.$scope.$apply(); 5310 } 5311 }; 5312 5313 _proto.onViewWishlistKeyDown = function onViewWishlistKeyDown(event, href) { 5314 // Gestisce il tasto Enter sul pulsante View Wishlist 5315 if (event.key === 'Enter') { 5316 event.preventDefault(); 5317 event.stopPropagation(); 5318 window.location.href = href; 5319 } 5320 }; 5321 5322 _proto.navigateToWishlist = function navigateToWishlist(href) { 5323 // Gestisce il click sul pulsante View Wishlist 5324 window.location.href = href; 5325 }; 5326 5327 _proto.scrollIntoView = function scrollIntoView(node) { 5328 // Calcola la posizione target prima di scrollare 5329 this.$timeout(function () { 5330 var _document$querySelect; 5331 5332 var headerHeight = ((_document$querySelect = document.querySelector('header')) == null ? void 0 : _document$querySelect.offsetHeight) || 0; 5333 var elementTop = node.getBoundingClientRect().top + window.pageYOffset; 5334 var scrollTarget = elementTop - headerHeight - 20; // 20px di margine aggiuntivo 5335 5336 var currentScroll = window.pageYOffset || document.documentElement.scrollTop; // Controlla se l'elemento è già nella posizione corretta (con tolleranza di 10px) 5337 5338 if (Math.abs(currentScroll - scrollTarget) > 10) { 5339 window.scrollTo({ 5340 top: scrollTarget, 5341 behavior: 'smooth' 5342 }); 5343 } 5344 }, 50); // console.log('ColorsController.scrollIntoView', node); 5345 5346 DomService.IMMEDIATE_SCROLL = true; 5347 }; 5348 5349 _proto.onWindowResize = function onWindowResize() { 5350 var colors = Array.prototype.slice.call(document.querySelectorAll('.group--colors > .card--color')); 5351 /*
5352 colors.forEach((x, i) => { 5353 TweenMax.set(x, { marginBottom: 0, height: 'auto' }); 5354 }); 5355 */ 5356 5357 if (this.active !== undefined) { 5358 var color = colors[this.active]; 5359 var detail = color.querySelector('.card__detail'); 5360 5361 if (detail) { 5362 TweenMax.set(detail, { 5363 height: 'auto' 5364 }); 5365 var rect = Rect.fromNode(detail); 5366 TweenMax.set(detail, { 5367 left: -color.offsetLeft, 5368 height: rect.height 5369 }); 5370 } 5371 } 5372 }; 5373 5374 _proto.onToggle = function onToggle(active, event) { 5375 if (this.active === active) { 5376 //this.onClose(); 5377 //this.active = undefined; 5378 //return; 5379 var colors = Array.prototype.slice.call(document.querySelectorAll('.group--colors > .card--color')); 5380 var color = colors[this.active]; 5381 var detail = color.querySelector('.card__detail'); 5382 var classList = event.target.parentNode.classList; 5383 var classNames = ['btn--share', 'btn--roomvo', 'icon--facebook', 'btn--facebook', 'icon--twitter', 'btn--twitter', 'icon--linkedin', 'btn--linkedin', 'icon--pinterest', 'btn--pinterest', 'icon--remove', 'btn--remove']; 5384 5385 if (event.target.parentNode && classNames.some(function (className) { 5386 return classList.contains(className); 5387 }) || event.target.classList.contains('group--share') || DomService.isDescendantOf(event.target, detail)) { 5388 return; 5389 } 5390 5391 this.onClose(); 5392 this.active = undefined; 5393 } else { 5394 var skipScroll = true; 5395 5396 if (this.active !== undefined) { 5397 // Verifica se il colore precedente e il nuovo colore sono sulla stessa riga 5398 var _colors = Array.prototype.slice.call(document.querySelectorAll('.group--colors > .card--color')); 5399 5400 var oldColor = _colors[this.active]; 5401 var newColor = event.currentTarget; 5402 5403 if (oldColor && newColor) { 5404 var oldRect = oldColor.getBoundingClientRect(); 5405 var newRect = newColor.getBoundingClientRect(); // Se sono sulla stessa riga (stesso top), non fare scroll 5406 5407 if (Math.abs(oldRect.top - newRect.top) < 5) { 5408 skipScroll = true; 5409 } 5410 } 5411 } 5412 5413 this.active = active; // console.log(event.target, event.currentTarget); 5414 5415 var isKeyboardNav = event && event.isKeyboardNavigation; 5416 this.onOpen(event.currentTarget, false, isKeyboardNav, skipScroll); 5417 } 5418 }; 5419 5420 _proto.onOpen = function onOpen(node, immediate, isKeyboardNavigation, skipScroll) { 5421 var _this2 = this; 5422 5423 if (isKeyboardNavigation === void 0) { 5424 isKeyboardNavigation = false; 5425 } 5426 5427 if (skipScroll === void 0) { 5428 skipScroll = false; 5429 } 5430 5431 var colors = Array.prototype.slice.call(document.querySelectorAll('.group--colors > .card--color')); 5432 colors.forEach(function (x, i) { 5433 if (i === _this2.active) { 5434 x.classList.add('active'); 5435 x.setAttribute('aria-expanded', 'true'); 5436 } else { 5437 x.classList.remove('active'); 5438 x.setAttribute('aria-expanded', 'false'); 5439 TweenMax.set(x, { 5440 marginBottom: 0, 5441 height: 'auto' 5442 }); 5443 } 5444 }); 5445 var color = colors[this.active]; 5446 var detail = color.querySelector('.card__detail'); 5447 5448 if (detail) { 5449 TweenMax.set(detail, { 5450 height: 'auto' 5451 }); 5452 var rect = Rect.fromNode(detail); 5453 TweenMax.set(detail, { 5454 left: -color.offsetLeft, 5455 height: 0, 5456 overflow: 'hidden', 5457 zIndex: -1 5458 }); 5459 5460 if (immediate) { 5461 TweenMax.set(color, { 5462 marginBottom: rect.height 5463 }); 5464 TweenMax.set(detail, { 5465 height: rect.height, 5466 zIndex: 1 5467 }); // Fai lo scroll subito per immediate 5468 5469 if (!isKeyboardNavigation && !skipScroll) { 5470 this.scrollIntoView(color); 5471 } 5472 } else { 5473 var from = { 5474 value: 0 5475 }; 5476 TweenMax.to(from, 0.6, { 5477 value: 1, 5478 overwrite: 'all', 5479 ease: Power2.easeInOut, 5480 onUpdate: function onUpdate() { 5481 TweenMax.set(color, { 5482 marginBottom: rect.height * from.value 5483 }); 5484 TweenMax.set(detail, { 5485 height: rect.height * from.value 5486 }); 5487 }, 5488 onComplete: function onComplete() { 5489 TweenMax.set(detail, { 5490 zIndex: 1 5491 }); // Fai lo scroll DOPO l'animazione 5492 5493 if (!isKeyboardNavigation && !skipScroll) { 5494 _this2.scrollIntoView(color); 5495 } 5496 } 5497 }); 5498 } 5499 } // Aggiorna hash DOPO il scroll, con delay per evitare conflitti 5500 // Ma non aggiornare l'hash se skipScroll è true (cioè quando si clicca, non quando si carica la pagina) 5501 5502 5503 if (node.id && !skipScroll) { 5504 var hash = node.id; 5505 this.$timeout(function () { 5506 _this2.$location.hash(hash).replace(); 5507 }, 800); 5508 } 5509 }; 5510 5511 _proto.onClose = function onClose(immediate) { 5512 var _this3 = this; 5513 5514 var colors = Array.prototype.slice.call(document.querySelectorAll('.group--colors > .card--color'));
5515 colors.forEach(function (x, i) { 5516 if (i === _this3.active) { 5517 x.classList.add('active'); 5518 } else { 5519 x.classList.remove('active'); 5520 TweenMax.set(x, { 5521 marginBottom: 0, 5522 height: 'auto' 5523 }); 5524 } 5525 }); 5526 var color = colors[this.active]; 5527 5528 if (color) { 5529 color.setAttribute('aria-expanded', 'false'); 5530 } 5531 5532 var detail = color.querySelector('.card__detail'); 5533 5534 if (detail) { 5535 TweenMax.set(detail, { 5536 height: 'auto' 5537 }); 5538 var rect = Rect.fromNode(detail); 5539 TweenMax.set(detail, { 5540 left: -color.offsetLeft, 5541 height: rect.height, 5542 overflow: 'hidden', 5543 zIndex: -1 5544 }); 5545 5546 if (immediate) { 5547 TweenMax.set(color, { 5548 marginBottom: 0 5549 }); 5550 TweenMax.set(detail, { 5551 height: 0 5552 }); 5553 color.classList.remove('active'); 5554 } else { 5555 var from = { 5556 value: 1 5557 }; 5558 TweenMax.to(from, 0.6, { 5559 value: 0, 5560 overwrite: 'all', 5561 ease: Power2.easeInOut, 5562 onUpdate: function onUpdate() { 5563 TweenMax.set(color, { 5564 marginBottom: rect.height * from.value 5565 }); 5566 TweenMax.set(detail, { 5567 height: rect.height * from.value 5568 }); 5569 }, 5570 onComplete: function onComplete() { 5571 color.classList.remove('active'); 5572 } 5573 }); 5574 } 5575 } 5576 }; 5577 5578 return ColorsCtrl; 5579 }(); 5580 5581 ColorsCtrl.$inject = ['$scope', '$timeout', '$location', 'DomService']; 5582 5583 /* jshint esversion: 6 */ 5584 5585 var ContactStoreCtrl = /*#__PURE__*/function () { 5586 function ContactStoreCtrl($scope, $location, $timeout, $http, StateService) { 5587 this.$scope = $scope; 5588 this.$location = $location; 5589 this.$timeout = $timeout; 5590 this.$http = $http; 5591 this.data = window.data || {}; 5592 this.model = { 5593 Collections: [] 5594 }; 5595 5596 if (this.$location.search() && this.$location.search().email) { 5597 this.model.email = this.$location.search().email; 5598 } 5599 5600 this.state = StateService.getState(); 5601 this.state.ready(); 5602 } 5603 5604 var _proto = ContactStoreCtrl.prototype; 5605 5606 _proto.onSubmit = function onSubmit() { 5607 var _this = this; 5608 5609 console.log('ContactStoreCtrl.onSubmit', this.model); 5610 var data = this.model; 5611 data.Collections = data.Collections.join(','); 5612 var inputCaptcha = document.getElementById('g-recaptcha-response'); 5613 5614 if (inputCaptcha) { 5615 data.Captcha = inputCaptcha.value; 5616 } else { 5617 data.Captcha = ''; 5618 } 5619 5620 if (this.state.busy()) { 5621 this.$http.post('/WS/wsUsers.asmx/ContactStore', { 5622 data: data 5623 }).then(function (success) { 5624 if (success.data.d.Status) { 5625 _this.state.success(); // GtmService.push({ "event": "Action Complete" }); 5626 5627 } else { 5628 _this.state.error(); 5629 } 5630 }, function (error) { 5631 _this.error = error; 5632 }); 5633 this.$timeout(function () {// this.state.ready(); 5634 }, 2000); 5635 } 5636 }; 5637 5638 _proto.onInvalid = function onInvalid() { 5639 console.log(this.model, this); 5640 this.$scope.$broadcast('onInvalid'); 5641 }; 5642 5643 return ContactStoreCtrl; 5644 }(); 5645 5646 ContactStoreCtrl.$inject = ['$scope', '$location', '$timeout', '$http', 'StateService']; 5647 5648 /* jshint esversion: 6 */ 5649 5650 var ContactsCtrl = /*#__PURE__*/function () { 5651 function ContactsCtrl($scope, $location, $timeout, $http, StateService) { 5652 this.$scope = $scope; 5653 this.$location = $location; 5654 this.$timeout = $timeout; 5655 this.$http = $http; 5656 this.data = window.data || {}; 5657 this.model = {}; 5658 5659 if (this.$location.search() && this.$location.search().email) { 5660 this.model.email = this.$location.search().email; 5661 } 5662 5663 this.state = StateService.getState(); 5664 this.state.ready(); 5665 } 5666 5667 var _proto = ContactsCtrl.prototype; 5668 5669 _proto.setProvinces = function setProvinces() { 5670 var _this = this; 5671 5672 this.$timeout(function () { 5673 _this.provinces = _this.data.provinces.filter(function (x) { 5674 return x.countryId === _this.model.Nazione; 5675 }); 5676 }); 5677 }; 5678 5679 _proto.onSubmit = function onSubmit() { 5680 var _this2 = this; 5681 5682 var inputCaptcha = document.getElementById('g-recaptcha-response'); 5683 5684 if (inputCaptcha) { 5685 this.model.Captcha = inputCaptcha.value; 5686 } else { 5687 this.model.Captcha = ''; 5688 } 5689 5690 console.log('ContactsCtrl.onSubmit', this.model); 5691 5692 if (this.state.busy()) { 5693 this.$http.post('/WS/wsUsers.asmx/Contact', { 5694 data: this.model 5695 }).then(function (success) { 5696 if (success.data.d.Status) { 5697 _this2.state.success(); 5698 5699 var obj = Object.assign({}, window.objDataLayerInfo); 5700 obj["eventname"] = "contact_us_request_sent"; 5701 obj["label"] = success.data.d.Props.motivoEN; 5702 GtmService.push(obj); 5703 } else { 5704 _this2.state.error(); 5705 } 5706 }, function (error) { 5707 _this2.error = error; 5708 }); 5709 this.$timeout(function () {// this.state.ready(); 5710 }, 2000); 5711 } 5712 }; 5713 5714 _proto.onInvalid = function onInvalid() { 5715 this.$scope.$broadcast('onInvalid'); 5716 }; 5717 5718 return ContactsCtrl; 5719 }(); 5720 5721 ContactsCtrl.$inject = ['$scope', '$location', '$timeout', '$http', 'StateService']; 5722 5723 /* jshint esversion: 6 */ 5724 5725 var CalcoloCFPCtrl = /*#__PURE__*/function () { 5726 function CalcoloCFPCtrl($scope, $location, $timeout, $http, StateService) { 5727 this.$scope = $scope; 5728 this.$location = $location; 5729 this.$timeout = $timeout; 5730 this.$http = $http; 5731 this.data = window.data || {}; 5732 this.model = {}; 5733 5734 if (this.$location.search() && this.$location.search().email) { 5735 this.model.email = this.$location.search().email; 5736 } 5737 5738 this.state = StateService.getState(); 5739 this.state.ready(); 5740 } 5741 5742 var _proto = CalcoloCFPCtrl.prototype; 5743 5744 _proto.setProvinces = function setProvinces() { 5745 var _this = this; 5746 5747 this.$timeout(function () { 5748 _this.provinces = _this.data.provinces.filter(function (x) { 5749 return x.countryId === _this.model.Nazione; 5750 }); 5751 }); 5752 }; 5753 5754 _proto.setColori = function setColori() { 5755 var _this2 = this; 5756 5757 this.$timeout(function () { 5758 var aa = _this2; 5759 _this2.colori = _this2.data.colors.filter(function (x) { 5760 return x.serie === _this2.model.Collezione; 5761 }); // console.log = "Colore " + this.model.Colore; 5762 5763 _this2.model.Colore = null; 5764 _this2.spessorif = _this2.data.spessori.filter(function (x) { 5765 return x.colore === 0; 5766 }); 5767 _this2.formatif = _this2.data.formati.filter(function (x) { 5768 return x.colore === 0; 5769 }); 5770 _this2.finituref = _this2.data.finiture.filter(function (x) { 5771 return x.colore === 0; 5772 }); 5773 _this2.prodf = _this2.model.Collezione; 5774 _this2.nomeColl = aa.data.collections.filter(function (x) { 5775 return x.id == aa.model.Collezione; 5776 })[0].name; 5777 _this2.model.Prodotto = _this2.nomeColl; 5778 }); 5779 }; 5780 5781 _proto.setSpessori = function setSpessori() { 5782 var _this3 = this; 5783 5784 this.$timeout(function () { 5785 console.log = "2Colore " + _this3.model.Colore + " spessore" + _this3.model.Spessore; 5786 _this3.nomeCol = _this3.data.colors.filter(function (x) { 5787 return x.id == _this3.model.Colore; 5788 })[0].name; 5789 _this3.model.Spessore = null; 5790 _this3.spessorif = _this3.data.spessori.filter(function (x) { 5791 return x.colore === _this3.model.Colore; 5792 }); 5793 _this3.formatif = _this3.data.formati.filter(function (x) { 5794 return x.colore === 0; 5795 }); 5796 _this3.finituref = _this3.data.finiture.filter(function (x) { 5797 return x.colore === 0; 5798 }); 5799 _this3.model.Prodotto = _this3.nomeColl + "-" + _this3.nomeCol; 5800 }); 5801 }; 5802 5803 _proto.setFormati = function setFormati() { 5804 var _this4 = this; 5805 5806 this.$timeout(function () { 5807 _this4.nomeSp = _this4.data.spessori.filter(function (x) { 5808 return x.id == _this4.model.Spessore; 5809 })[0].name; 5810 _this4.model.Formato = null; 5811 _this4.formatif = _this4.data.formati.filter(function (x) { 5812 return x.colore === _this4.model.Colore && x.spessore === _this4.model.Spessore || x.colore == -1; 5813 }); 5814 _this4.finituref = _this4.data.finiture.filter(function (x) { 5815 return x.colore === 0; 5816 }); 5817 _this4.model.Prodotto = _this4.nomeColl + "-" + _this4.nomeCol + "-" + _this4.nomeSp; 5818 }); 5819 }; 5820
5821 _proto.setFiniture = function setFiniture() { 5822 var _this5 = this; 5823 5824 this.$timeout(function () { 5825 _this5.nomeForm = _this5.data.formati.filter(function (x) { 5826 return x.id == _this5.model.Formato; 5827 })[0].name; 5828 _this5.model.Finitura = null; 5829 _this5.finituref = _this5.data.finiture.filter(function (x) { 5830 return x.colore === _this5.model.Colore && x.spessore === _this5.model.Spessore && x.formato === _this5.model.Formato || x.colore == -1; 5831 }); 5832 _this5.model.Prodotto = _this5.nomeColl + "-" + _this5.nomeCol + "-" + _this5.nomeSp + "-" + _this5.nomeForm; 5833 }); 5834 }; 5835 5836 _proto.setNomeFinitura = function setNomeFinitura() { 5837 var _this6 = this; 5838 5839 this.$timeout(function () { 5840 _this6.nomeFin = _this6.data.finiture.filter(function (x) { 5841 return x.id == _this6.model.Finitura; 5842 })[0].name; 5843 _this6.model.Prodotto = _this6.nomeColl + "-" + _this6.nomeCol + "-" + _this6.nomeSp + "-" + _this6.nomeForm + "-" + _this6.nomeFin; 5844 }); 5845 }; 5846 5847 _proto.onSubmit = function onSubmit() { 5848 var _this7 = this; 5849 5850 var inputCaptcha = document.getElementById('g-recaptcha-response'); 5851 5852 if (inputCaptcha) { 5853 this.model.Captcha = inputCaptcha.value; 5854 } else { 5855 this.model.Captcha = ''; 5856 } 5857 5858 if (this.state.busy()) { 5859 this.$http.post('/WS/wsUsers.asmx/RichiestaCFP', { 5860 data: this.model 5861 }).then(function (success) { 5862 if (success.data.d.Status) { 5863 _this7.state.success(); 5864 5865 var obj = Object.assign({}, window.objDataLayerInfo); 5866 obj["eventname"] = "contact_us_cfp_request_sent"; 5867 obj["label"] = "cfp_request"; 5868 GtmService.push(obj); 5869 } else { 5870 _this7.state.error(); 5871 } 5872 }, function (error) { 5873 _this7.error = error; 5874 }); 5875 this.$timeout(function () {// this.state.ready(); 5876 }, 2000); 5877 } 5878 }; 5879 5880 _proto.onInvalid = function onInvalid() { 5881 this.$scope.$broadcast('onInvalid'); 5882 }; 5883 5884 return CalcoloCFPCtrl; 5885 }(); 5886 5887 CalcoloCFPCtrl.$inject = ['$scope', '$location', '$timeout', '$http', 'StateService']; 5888 5889 /* jshint esversion: 6 */ 5890 5891 var LoginCtrl = /*#__PURE__*/function () { 5892 function LoginCtrl($window, $scope, $location, $timeout, $http, StateService) { 5893 this.$window = $window; 5894 this.$scope = $scope; 5895 this.$location = $location; 5896 this.$timeout = $timeout; 5897 this.$http = $http; 5898 this.data = window.data || {}; 5899 this.model = {}; 5900 5901 if (this.$location.search() && this.$location.search().email) { 5902 this.model.email = this.$location.search().email; 5903 } 5904 5905 this.state = StateService.getState(); 5906 this.state.ready(); 5907 } 5908 5909 var _proto = LoginCtrl.prototype; 5910 5911 _proto.setProvinces = function setProvinces() { 5912 var _this = this; 5913 5914 this.$timeout(function () { 5915 _this.provinces = _this.data.provinces.filter(function (x) { 5916 return x.countryId === _this.model.Nazione; 5917 }); 5918 }); 5919 }; 5920 5921 _proto.onSubmit = function onSubmit() { 5922 var _this2 = this; 5923 5924 console.log('LoginCtrl.onSubmit', this.model); 5925 5926 if (this.state.busy()) { 5927 this.$http.post('/ws/wsUsers.asmx/Login', this.model).then(function (success) { 5928 //console.log(success.data.d.Status); 5929 //console.log(success.data.d.HTML); 5930 if (success.data.d.Status) { 5931 _this2.state.success(); 5932 5933 var obj = Object.assign({}, window.objDataLayerInfo); 5934 obj["eventname"] = "login"; 5935 GtmService.push(obj); 5936 } else { 5937 _this2.state.error(success.data.d.HTML); 5938 } 5939 }, function (error) { 5940 _this2.error = error; 5941 }); 5942 this.$timeout(function () {// this.state.ready(); 5943 }, 2000); 5944 } //console.log(this.state); 5945 5946 5947 this.$timeout(function () { 5948 // this.state.ready(); 5949 if (_this2.state.isReady && _this2.state.isSuccess) { 5950 _this2.$window.location.href = '/download'; 5951 } 5952 }, 2000); 5953 }; 5954 5955 _proto.onInvalid = function onInvalid() { 5956 this.$scope.$broadcast('onInvalid'); 5957 }; 5958 5959 return LoginCtrl; 5960 }(); 5961 5962 LoginCtrl.$inject = ['$window', '$scope', '$location', '$timeout', '$http', 'StateService']; 5963 5964 /* jshint esversion: 6 */ 5965 var AbstractDirective = /*#__PURE__*/function () { 5966 function AbstractDirective() { 5967 this.restrict = 'A'; 5968 } 5969 5970 var _proto = AbstractDirective.prototype; 5971 5972 _proto.link = function link(scope, element, attributes, controller) { 5973 var node = element[0]; 5974 var abstractText = node.innerHTML; 5975 5976 if (node.getAttribute('href') != undefined) { 5977 var link = document.createElement('a'); 5978 link.setAttribute('href', node.getAttribute('href')); 5979 link.setAttribute('target', '_blank'); 5980 link.innerHTML = abstractText; 5981 node.replaceWith(link); 5982 link.setAttribute('data-abstract', link.outerHTML); 5983 } else { 5984 node.setAttribute('data-abstract', abstractText); 5985 } 5986 }; 5987 5988 AbstractDirective.factory = function factory() { 5989 return new AbstractDirective(); 5990 }; 5991 5992 return AbstractDirective; 5993 }(); 5994 AbstractDirective.factory.$inject = []; 5995 5996 /* jshint esversion: 6 */ 5997 5998 var AppearDirective = /*#__PURE__*/function () { 5999 function AppearDirective(IntersectionService) { 6000 this.intersectionService = IntersectionService; 6001 this.restrict = 'A'; 6002 } 6003 6004 var _proto = AppearDirective.prototype; 6005 6006 _proto.link = function link(scope, element, attributes, controller) { 6007 var node = element[0];
6008 var section = this.getSection(node); 6009 var index = [].slice.call(section.querySelectorAll('[appear]')).indexOf(node); 6010 var subscription = this.intersectionService.intersection$(node).pipe(first()).subscribe(function (event) { 6011 // -0.05 6012 // console.log(event.rect.top); 6013 6014 /* 6015 const rect = event.rect; 6016 const x = rect.left; 6017 const y = 0; // event.rect.top; 6018 const index = Math.floor(y / 320) * Math.floor(window.innerWidth / 320) + Math.floor(x / 320); 6019 */ 6020 var timeout = index * 100; 6021 setTimeout(function () { 6022 node.classList.add('appeared'); 6023 }, timeout); // (i - firstVisibleIndex)); 6024 6025 /* 6026 if (index > 0) { 6027 setTimeout(() => { 6028 node.classList.add('appeared'); 6029 }, timeout); // (i - firstVisibleIndex)); 6030 } else { 6031 node.classList.add('appeared'); 6032 } 6033 */ 6034 }); 6035 var img = node.querySelector('img'); 6036 6037 if (img) { 6038 img.setAttribute('ondragstart', 'return false;'); 6039 } 6040 6041 scope.$on('$destroy', function () { 6042 subscription.unsubscribe(); 6043 }); 6044 }; 6045 6046 _proto.getSection = function getSection(node) { 6047 var section = node.parentNode; 6048 var p = node; 6049 6050 while (p) { 6051 p = p.parentNode; 6052 6053 if (p && p.classList && p.classList.contains('section')) { 6054 section = p; 6055 p = null; 6056 } 6057 } 6058 6059 return section; 6060 }; 6061 6062 AppearDirective.factory = function factory(IntersectionService) { 6063 return new AppearDirective(IntersectionService); 6064 }; 6065 6066 return AppearDirective; 6067 }(); 6068 AppearDirective.factory.$inject = ['IntersectionService']; 6069 6070 var HasDropdownDirective = /*#__PURE__*/function () { 6071 function HasDropdownDirective($timeout) { 6072 this.$timeout = $timeout; 6073 this.restrict = 'A'; 6074 this.scope = false;
6075 } 6076 6077 var _proto = HasDropdownDirective.prototype; 6078 6079 _proto.link = function link(scope, element, attributes, controller) { 6080 var _this = this; 6081 6082 var node = element[0]; 6083 var opened_ = null; 6084 var previouslyFocusedElement = null; // Store the element that had focus before opening dropdown 6085 6086 var isHandlingKeyEvent = false; // Flag to prevent double handling 6087 // const consumer = attributes.hasDropdownConsumer !== undefined ? scope.$eval(attributes.hasDropdownConsumer) : null; 6088 6089 var trigger = attributes.hasDropdown !== '' ? node.querySelector(attributes.hasDropdown) : node; // Ensure trigger element exists 6090 6091 if (!trigger) { 6092 console.warn('HasDropdownDirective: Trigger element not found for selector:', attributes.hasDropdown); 6093 return; 6094 } // Get focusable elements within the dropdown 6095 6096 6097 var getFocusableElements = function getFocusableElements() { 6098 var dropdown = node.querySelector('[dropdown]'); 6099 if (!dropdown) return []; // For custom-select, focus on .option elements specifically 6100 6101 var customSelectOptions = dropdown.querySelectorAll('.option'); 6102 6103 if (customSelectOptions.length > 0) { 6104 return Array.from(customSelectOptions).filter(function (el) { 6105 // Check if element is visible 6106 if (el.offsetParent === null) return false; // Check if parent li has disabled class or if any parent has disabled/ng-disabled 6107 6108 var parentLi = el.closest('li'); 6109 if (parentLi && parentLi.classList.contains('disabled')) return false; // Check for ng-disabled or other disabled attributes 6110 6111 if (el.closest('.disabled, [ng-disabled="true"], [disabled]')) return false; 6112 return true; 6113 }); 6114 } // Fallback to standard focusable elements for other dropdown types 6115 6116 6117 var selectors = ['a[href]:not([disabled]):not([tabindex="-1"])', 'button:not([disabled]):not([tabindex="-1"])', 'textarea:not([disabled]):not([tabindex="-1"])', 'input:not([disabled]):not([tabindex="-1"]):not([style*="opacity: 0"])', 'select:not([disabled]):not([tabindex="-1"])', 'label[tabindex]:not([tabindex="-1"]):not([disabled])', '[tabindex]:not([tabindex="-1"]):not([disabled])']; 6118 return Array.from(dropdown.querySelectorAll(selectors.join(', '))).filter(function (el) { 6119 // Only visible elements and not disabled 6120 if (el.offsetParent === null || el.closest('.disabled')) return false; // Exclude hidden radio inputs 6121 6122 if (el.type === 'radio' && (el.style.opacity === '0' || el.style.visibility === 'hidden' || el.getAttribute('tabindex') === '-1')) return false; 6123 return true; 6124 }); 6125 }; // Manage tabindex of dropdown elements for keyboard navigation 6126 6127 6128 var setDropdownTabIndex = function setDropdownTabIndex(tabIndex) { 6129 var dropdown = node.querySelector('[dropdown]'); 6130 if (!dropdown) return; // First check if we have custom-select options 6131 6132 var customSelectOptions = dropdown.querySelectorAll('.option'); 6133 6134 if (customSelectOptions.length > 0) { 6135 // For custom-select, manage tabindex on .option elements 6136 customSelectOptions.forEach(function (element) { 6137 if (tabIndex === -1) { 6138 element.setAttribute('tabindex', '-1'); 6139 } else { 6140 // Check if parent li is disabled 6141 var parentLi = element.closest('li'); 6142 6143 if (parentLi && parentLi.classList.contains('disabled')) { 6144 element.setAttribute('tabindex', '-1'); 6145 } else { 6146 element.setAttribute('tabindex', '0'); 6147 } 6148 } 6149 }); 6150 return; 6151 } // Fallback for other dropdown types 6152 6153 6154 var focusableElements = dropdown.querySelectorAll('a, button, input, select, textarea, label[tabindex], [tabindex], li[ng-click], span[ng-click]'); 6155 focusableElements.forEach(function (element) { 6156 // Skip hidden radio inputs 6157 if (element.type === 'radio' && (element.style.opacity === '0' || element.style.visibility === 'hidden' || element.getAttribute('tabindex') === '-1')) { 6158 element.setAttribute('tabindex', '-1'); 6159 return; 6160 } // Skip elements that are disabled via Angular 6161 6162 6163 var angularDisabled = element.hasAttribute('ng-disabled') && element.getAttribute('ng-disabled').includes('item.disabled'); 6164 6165 if (tabIndex === -1) { 6166 // Store original tabindex if it exists 6167 var originalTabIndex = element.getAttribute('tabindex'); 6168 6169 if (originalTabIndex !== null) { 6170 element.setAttribute('data-original-tabindex', originalTabIndex); 6171 } 6172 6173 element.setAttribute('tabindex', '-1'); 6174 } else { 6175 // Restore original tabindex or set to 0 for focusable elements 6176 var _originalTabIndex = element.getAttribute('data-original-tabindex'); 6177 6178 if (_originalTabIndex !== null) { 6179 element.setAttribute('tabindex', _originalTabIndex); 6180 element.removeAttribute('data-original-tabindex'); 6181 } else if (element.tagName === 'LABEL' || element.hasAttribute('ng-click')) { 6182 // For label elements and clickable elements, set tabindex to 0 6183 element.setAttribute('tabindex', '0'); 6184 } else { 6185 element.removeAttribute('tabindex'); 6186 } 6187 } 6188 }); 6189 }; 6190 6191 var onClick = function onClick(event) {
6192 // Prevent default behavior for anchor links with javascript: href 6193 if (event.target.tagName === 'A' && event.target.href && event.target.href.startsWith('javascript:')) { 6194 event.preventDefault(); 6195 } 6196 6197 if (opened_ === null) { 6198 previouslyFocusedElement = document.activeElement; 6199 openDropdown(); 6200 } else if (event.target !== trigger && !trigger.contains(event.target)) { 6201 closeDropdown(true); 6202 } 6203 }; 6204 6205 var onKeyDown = function onKeyDown(event) { 6206 // Prevent double handling 6207 if (isHandlingKeyEvent) return; 6208 isHandlingKeyEvent = true; 6209 6210 try { 6211 if (event.key === 'Enter' || event.key === ' ') { 6212 // Open dropdown with Enter or Space 6213 if (opened_ === null) { 6214 event.preventDefault(); 6215 previouslyFocusedElement = event.target; 6216 openDropdown(); 6217 } else { 6218 // If dropdown is open and we're focused on an option, activate it and close 6219 var focusedElement = document.activeElement; 6220 6221 if (focusedElement && focusedElement.classList.contains('option')) { 6222 event.preventDefault(); 6223 focusedElement.click(); // Small delay to ensure the click event is processed first 6224 6225 setTimeout(function () { 6226 closeDropdown(true); 6227 }, 10); 6228 } 6229 } 6230 } else if (event.key === 'Escape') { 6231 // Close dropdown with Escape 6232 if (opened_ !== null) { 6233 event.preventDefault(); 6234 closeDropdown(true); 6235 } 6236 } else if (opened_ !== null) { 6237 // Handle arrow keys within open dropdown 6238 var focusableElements = getFocusableElements(); 6239 if (focusableElements.length === 0) return; 6240 var currentIndex = focusableElements.indexOf(document.activeElement); 6241 6242 if (event.key === 'ArrowDown') { 6243 event.preventDefault(); 6244 event.stopPropagation(); // Prevent event bubbling 6245 6246 var nextIndex = currentIndex < focusableElements.length - 1 ? currentIndex + 1 : 0; // Ensure we don't get stuck in an infinite loop 6247 6248 var attempts = 0; 6249 6250 while (attempts < focusableElements.length && focusableElements[nextIndex] && focusableElements[nextIndex].closest('.disabled, [ng-disabled="true"]')) { 6251 nextIndex = nextIndex < focusableElements.length - 1 ? nextIndex + 1 : 0; 6252 attempts++; 6253 } 6254 6255 if (focusableElements[nextIndex]) { 6256 focusableElements[nextIndex].focus(); 6257 } 6258 } else if (event.key === 'ArrowUp') { 6259 event.preventDefault(); 6260 event.stopPropagation(); // Prevent event bubbling 6261 6262 var prevIndex = currentIndex > 0 ? currentIndex - 1 : focusableElements.length - 1; // Ensure we don't get stuck in an infinite loop 6263 6264 var _attempts = 0; 6265 6266 while (_attempts < focusableElements.length && focusableElements[prevIndex] && focusableElements[prevIndex].closest('.disabled, [ng-disabled="true"]')) { 6267 prevIndex = prevIndex > 0 ? prevIndex - 1 : focusableElements.length - 1; 6268 _attempts++; 6269 } 6270 6271 if (focusableElements[prevIndex]) { 6272 focusableElements[prevIndex].focus(); 6273 } 6274 } else if (event.key === 'Tab') { 6275 // Allow tab to move between dropdown items 6276 if (!event.shiftKey) { 6277 // Tab forward 6278 var _nextIndex = currentIndex < focusableElements.length - 1 ? currentIndex + 1 : -1; 6279 6280 if (_nextIndex === -1) { 6281 // Let tab exit the dropdown naturally 6282 closeDropdown(false); 6283 } else { 6284 event.preventDefault(); 6285 6286 focusableElements[_nextIndex].focus(); 6287 } 6288 } else { 6289 // Shift+Tab backward 6290 var _prevIndex = currentIndex > 0 ? currentIndex - 1 : -1; 6291 6292 if (_prevIndex === -1) { 6293 // Let shift+tab exit the dropdown naturally 6294 closeDropdown(false); 6295 } else { 6296 event.preventDefault(); 6297 6298 focusableElements[_prevIndex].focus(); 6299 } 6300 } 6301 } 6302 } 6303 } finally { 6304 // Reset flag after a short delay 6305 setTimeout(function () { 6306 isHandlingKeyEvent = false;
6307 }, 10); 6308 } 6309 }; 6310 6311 var onDropdownKeyDown = function onDropdownKeyDown(event) { 6312 // Prevent double handling 6313 if (isHandlingKeyEvent) return; 6314 6315 if (event.key === 'Escape') { 6316 event.preventDefault(); 6317 closeDropdown(true); 6318 } else if (event.key === 'Enter' || event.key === ' ') { 6319 // Handle Enter and Space to activate the focused element 6320 var focusedElement = document.activeElement; 6321 6322 if (focusedElement && node.contains(focusedElement)) { 6323 event.preventDefault(); // Trigger click on the focused element 6324 6325 focusedElement.click(); // For custom-select options, close the dropdown after selection 6326 6327 if (focusedElement.classList.contains('option')) { 6328 // Small delay to ensure the click event is processed first 6329 setTimeout(function () { 6330 closeDropdown(true); 6331 }, 10); 6332 } 6333 } 6334 } // Remove delegation to prevent double handling 6335 6336 }; 6337 6338 var onDocumentClick = function onDocumentClick(event) { 6339 var clickedInside = node === event.target || node.contains(event.target); 6340 6341 if (!clickedInside) { 6342 closeDropdown(); 6343 } 6344 }; 6345 6346 var openDropdown = function openDropdown() { 6347 if (opened_ === null) { 6348 opened_ = true; 6349 addDocumentListeners(); 6350 scope.$root.$broadcast('onDroppedIn', node); 6351 var callback = attributes.droppedIn !== undefined ? scope.$eval(attributes.droppedIn) : function () {}; 6352 callback(node, node.querySelector('[dropdown]')); // Set aria-expanded to true for accessibility 6353 6354 trigger.setAttribute('aria-expanded', 'true'); // Enable keyboard navigation for dropdown elements 6355 6356 setDropdownTabIndex(0); // Focus management: move focus to first focusable element in dropdown 6357 6358 _this.$timeout(function () { 6359 var focusableElements = getFocusableElements(); 6360 6361 if (focusableElements.length > 0) { 6362 focusableElements[0].focus(); 6363 } 6364 }, 50); // Small delay to ensure dropdown is rendered 6365 6366 } 6367 }; 6368 6369 var closeDropdown = function closeDropdown(restoreFocus) { 6370 if (restoreFocus === void 0) { 6371 restoreFocus = false; 6372 } 6373 6374 if (opened_ !== null) { 6375 opened_ = null; 6376 removeDocumentListeners(); 6377 scope.$root.$broadcast('onDroppedOut', node); 6378 var callback = attributes.droppedOut !== undefined ? scope.$eval(attributes.droppedOut) : function () {}; 6379 callback(node, node.querySelector('[dropdown]')); // Set aria-expanded to false for accessibility 6380 6381 trigger.setAttribute('aria-expanded', 'false'); // Disable keyboard navigation for dropdown elements 6382 6383 setDropdownTabIndex(-1); // Focus management: restore focus to trigger element 6384 6385 if (restoreFocus && previouslyFocusedElement) { 6386 _this.$timeout(function () { 6387 previouslyFocusedElement.focus(); 6388 previouslyFocusedElement = null; 6389 }, 10); 6390 } 6391 } 6392 }; 6393 6394 scope.$on('onDroppedOut', function ($scope, $node) { 6395 if ($node === node) { 6396 node.classList.remove('opened'); 6397 } 6398 }); 6399 scope.$on('onDroppedIn', function ($scope, $node) { 6400 var opened = $node === node || node.contains($node); 6401 6402 if (opened) { 6403 node.classList.add('opened'); 6404 6405 if (node.parentNode) { 6406 node.parentNode.classList.add('has-dropdown--opened'); 6407 } 6408 } else { 6409 node.classList.remove('opened'); 6410 6411 if (node.parentNode) { 6412 node.parentNode.classList.remove('has-dropdown--opened'); 6413 } 6414 } 6415 }); 6416 scope.$on('onCloseDropdown', closeDropdown); 6417 scope.$on('onNavigateOut', closeDropdown); 6418 scope.$on('onNavigationTransitionIn', closeDropdown); 6419 6420 var addListeners = function addListeners() { 6421 trigger.addEventListener('click', onClick); 6422 trigger.addEventListener('keydown', onKeyDown); // Make trigger focusable if it's not already 6423 6424 if (!trigger.hasAttribute('tabindex') && trigger.tagName !== 'A' && trigger.tagName !== 'BUTTON') { 6425 trigger.setAttribute('tabindex', '0'); 6426 } // Initialize aria-expanded attribute for accessibility 6427 6428 6429 if (!trigger.hasAttribute('aria-expanded')) { 6430 trigger.setAttribute('aria-expanded', 'false'); 6431 } 6432 }; 6433 6434 var addDocumentListeners = function addDocumentListeners() { 6435 document.addEventListener('click', onDocumentClick); 6436 var dropdown = node.querySelector('[dropdown]'); 6437 6438 if (dropdown) { 6439 dropdown.addEventListener('keydown', onDropdownKeyDown); 6440 } 6441 }; 6442 6443 var removeListeners = function removeListeners() { 6444 trigger.removeEventListener('click', onClick); 6445 trigger.removeEventListener('keydown', onKeyDown); 6446 }; 6447 6448 var removeDocumentListeners = function removeDocumentListeners() { 6449 document.removeEventListener('click', onDocumentClick); 6450 var dropdown = node.querySelector('[dropdown]'); 6451 6452 if (dropdown) { 6453 dropdown.removeEventListener('keydown', onDropdownKeyDown); 6454 } 6455 }; 6456 6457 addListeners(); // Initialize: disable keyboard navigation for dropdown elements when closed 6458 6459 setDropdownTabIndex(-1); 6460 scope.$on('$destroy', function () { 6461 removeListeners(); 6462 removeDocumentListeners(); 6463 }); 6464 }; 6465 6466 HasDropdownDirective.factory = function factory($timeout) { 6467 return new HasDropdownDirective($timeout); 6468 }; 6469 6470 return HasDropdownDirective; 6471 }(); 6472 HasDropdownDirective.dropDownUid = 0; 6473 HasDropdownDirective.factory.$inject = ['$timeout']; 6474 6475 /* jshint esversion: 6 */ 6476 6477 var AutocompleteDirective = /*#__PURE__*/function () { 6478 function AutocompleteDirective($timeout) { 6479 this.$timeout = $timeout; 6480 this.restrict = 'A'; 6481 this.scope = { 6482 filter: '=selectWithAutocomplete', 6483 handler: '=', 6484 onSetItem: '=?', 6485 onRemoveItem: '=?' 6486 }; 6487 this.template = "\n\t\t<div class=\"dropdown\">\n\t\t\t<ul class=\"nav nav--select\">\n\t\t\t\t<li ng-repeat=\"item in items track by $index\" ng-class=\"{ active: item.value == filter.value, disabled: item.disabled }\">\n\t\t\t\t\t<span class=\"option\" ng-class=\"{ 'option--picture': item.image }\" ng-click=\"setItem(item)\">\n\t\t\t\t\t\t<img ng-src=\"{{item.image}}\" ng-if=\"item.image\" /> <span class=\"icon--check\" ng-if=\"!item.image\"></span> <span ng-bind=\"item.label\"></span>\n\t\t\t\t\t</span>\n\t\t\t\t</li>\n\t\t\t</ul>\n\t\t</div>\n\t\t<label class=\"label\" ng-bind=\"filter.label\"></label>\n\t\t<div class=\"control control--select\" ng-class=\"{ selected: filter.value }\">\n\t\t\t<div class=\"input\">\n\t\t\t\t<svg class=\"icon icon--search\" ng-if=\"!filter.value\"><use xlink:href=\"#icon--search\"></use></svg>\n\t\t\t\t<svg class=\"icon icon--remove\" ng-if=\"filter.value\" ng-click=\"removeItem()\"><use xlink:href=\"#icon--remove\"></use></svg>\n\t\t\t\t<input type=\"text\" class=\"value\" ng-model=\"autocomplete.query\" ng-model-options=\"{ debounce: 200 }\" ng-disabled=\"filter.value\" placeholder=\"{{filter.placeholder}}\" ng-change=\"onChange($event)\" ng-click=\"onClick($event)\"></input>\n\t\t\t\t<svg class=\"icon icon--caret-down\"><use xlink:href=\"#icon--caret-down\"></use></svg>\n\t\t\t</div>\n\t\t</div>\n\t\t"; 6488 } 6489 6490 var _proto = AutocompleteDirective.prototype; 6491 6492 _proto.link = function link(scope, element, attributes, controller) { 6493 var _this = this; 6494 6495 var node = element[0]; 6496 var input = node.querySelector('input'); 6497 var uid = HasDropdownDirective.dropDownUid++; 6498 var autocomplete = scope.autocomplete = { 6499 query: null 6500 }; 6501 var filter = scope.filter; 6502 scope.items = scope.filter.options; 6503 node.initialFocus = null; // scope.$parent.hasDropdown = null; 6504 6505 scope.setItem = function (item) { 6506 filter.value = item.value; 6507 autocomplete.query = null; 6508 6509 if (scope.handler) { 6510 scope.handler.setFilter(item, filter); 6511 } 6512 }; 6513 6514 scope.removeItem = function (item) { 6515 filter.value = null; 6516 autocomplete.query = null; 6517 6518 if (scope.handler) { 6519 scope.handler.removeFilter(filter); 6520 } 6521 }; 6522 6523 scope.onChange = function (event) { 6524 autocomplete.results = filter.options.filter(function (x) { 6525 return x.label.toLowerCase().indexOf(autocomplete.query.toLowerCase()) !== -1; 6526 }); 6527 6528 if (autocomplete.results) { 6529 scope.items = autocomplete.results; 6530 scope.$parent.hasDropdown = uid; 6531 node.initialFocus = true; 6532 } else { 6533 scope.items = filter.options; 6534 scope.$parent.hasDropdown = null; 6535 } // console.log('onChange', autocomplete.query, autocomplete.results); 6536 6537 }; 6538 6539 var onClickInput = function onClickInput(event) { 6540 event.stopPropagation(); // console.log('onClickInput', event); 6541 }; 6542 6543 var onClick = function onClick(event) { 6544 var clickedInside = node === event.target || node.contains(event.target); // || !document.contains(event.target) 6545 6546 if (clickedInside) { 6547 node.initialFocus = true; 6548 6549 _this.$timeout(function () { 6550 if (scope.$parent.hasDropdown === uid) { 6551 scope.$parent.hasDropdown = null; 6552 } else { 6553 scope.$parent.hasDropdown = uid; 6554 } 6555 6556 scope.items = filter.options; 6557 autocomplete.query = null; 6558 autocomplete.results = []; 6559 }); // console.log(node, clickedInside, scope.$parent.hasDropdown); 6560 6561 } else if (node.initialFocus !== null) { 6562 node.initialFocus = false;
6563 6564 _this.$timeout(function () { 6565 if (scope.$parent.hasDropdown === uid) { 6566 scope.$parent.hasDropdown = null; 6567 scope.items = filter.options; 6568 autocomplete.query = null; 6569 autocomplete.results = []; 6570 } 6571 }); 6572 } 6573 }; 6574 6575 scope.$parent.$watch('hasDropdown', function (value) { 6576 // console.log('hasDropdown', value, uid); 6577 if (scope.$parent.hasDropdown === uid) { 6578 node.classList.add('opened'); 6579 } else { 6580 node.classList.remove('opened'); 6581 } 6582 }); 6583 6584 var addListeners = function addListeners() { 6585 input.addEventListener('click', onClickInput); 6586 document.addEventListener('click', onClick); // element.on('click', onClick); 6587 }; 6588 6589 var removeListeners = function removeListeners() { 6590 input.removeEventListener('click', onClickInput); 6591 document.removeEventListener('click', onClick); // element.off('click', onClick); 6592 }; 6593 6594 addListeners(); 6595 scope.$on('$destroy', function () { 6596 removeListeners(); 6597 }); 6598 }; 6599 6600 AutocompleteDirective.factory = function factory($timeout) { 6601 return new AutocompleteDirective($timeout); 6602 }; 6603 6604 return AutocompleteDirective; 6605 }(); 6606 AutocompleteDirective.factory.$inject = ['$timeout']; 6607 6608 /* jshint esversion: 6 */ 6609 var GalleryCounter = /*#__PURE__*/function () { 6610 function GalleryCounter() { 6611 this.restrict = 'A'; 6612 } 6613 6614 var _proto = GalleryCounter.prototype; 6615 6616 _proto.link = function link(scope, element, attributes, controller) { 6617 var items = element[0].querySelectorAll('.gallery__item'); 6618 var counterLabel = element[0].querySelector('.counter-label'); 6619 6620 if (items.length && counterLabel) { 6621 counterLabel.textContent = items.length; 6622 } 6623 }; 6624 6625 GalleryCounter.factory = function factory() { 6626 return new GalleryCounter(); 6627 }; 6628 6629 return GalleryCounter; 6630 }(); 6631 GalleryCounter.factory.$inject = []; 6632 6633 /* jshint esversion: 6 */ 6634 var JournalCtrl = /*#__PURE__*/function () { 6635 function JournalCtrl($scope, $timeout, LocationService) { 6636 this.$scope = $scope; 6637 this.$timeout = $timeout; 6638 this.locationService = LocationService; 6639 this.filters = window.filters || {}; 6640 this.journals = window.journals || []; 6641 this.selectedFilters = []; 6642 this.deserializeFilters(); 6643 this.applyFilters(); 6644 this.$scope.toggle = true; 6645 } 6646 6647 var _proto = JournalCtrl.prototype; 6648 6649 _proto.deserializeFilters = function deserializeFilters() { 6650 var _this = this; 6651 6652 var locationFilters = this.locationService.deserialize('filters') || {}; 6653 Object.keys(this.filters).forEach(function (x) { 6654 var filter = _this.filters[x]; 6655 6656 switch (x) { 6657 default: 6658 filter.doFilter = function (item, value) { 6659 return item[x] === value; 6660 }; 6661 6662 } 6663 6664 filter.options.unshift({ 6665 label: _this.filters[x].placeholder, 6666 value: null 6667 }); 6668 var selectedOption = filter.options.find(function (o) { 6669 return Boolean(o.value === (locationFilters[x] || null)); 6670 }); 6671 filter.value = selectedOption.value; 6672 filter.placeholder = selectedOption.label; 6673 }); 6674 return filters; 6675 }; 6676 6677 _proto.serializeFilters = function serializeFilters() { 6678 var _this2 = this; 6679 6680 var filters = {}; 6681 Object.keys(this.filters).forEach(function (x) { 6682 var filter = _this2.filters[x]; 6683 6684 if (filter.value !== null) { 6685 filters[x] = filter.value; 6686 } 6687 }); // console.log('ReferenceCtrl.serializeFilters', filters); 6688 //--this.locationService.serialize('filters', filters); 6689 6690 return filters; 6691 }; 6692 6693 _proto.setFilteredImage = function setFilteredImage(item, filter) {// nope 6694 }; 6695 6696 _proto.applyFilters = function applyFilters() { 6697 var _this3 = this; 6698 6699 this.serializeFilters(); 6700 var selectedFilters = Object.keys(this.filters).map(function (x) { 6701 return _this3.filters[x]; 6702 }).filter(function (x) { 6703 return x.value !== null; 6704 }); 6705 var filteredItems = this.journals.slice(); // console.log('selectedFilters', selectedFilters.map(x => x.value).join(', ')); 6706 6707 if (selectedFilters.length) { 6708 filteredItems = filteredItems.filter(function (item) { 6709 item.filteredImage = item.image; 6710 var has = true;
6711 selectedFilters.forEach(function (filter) { 6712 var hasFilter = filter.doFilter(item, filter.value); 6713 6714 if (hasFilter) { 6715 _this3.setFilteredImage(item, filter); 6716 } 6717 6718 has = has && hasFilter; 6719 }); 6720 return has; 6721 }); 6722 } else { 6723 filteredItems.forEach(function (item) { 6724 return item.filteredImage = item.image; 6725 }); 6726 } // console.log(filteredItems, selectedFilters); 6727 6728 6729 this.selectedFilters = selectedFilters; 6730 this.filteredItems = []; 6731 this.$timeout(function () { 6732 _this3.filteredItems = filteredItems; 6733 6734 _this3.updateFilterStates(filteredItems); // delayer for image update 6735 6736 }, 50); 6737 }; 6738 6739 _proto.updateFilterStates = function updateFilterStates(items) { 6740 var _this4 = this; 6741 6742 // console.log('updateFilterStates', items); 6743 Object.keys(this.filters).forEach(function (x) { 6744 var filter = _this4.filters[x]; 6745 filter.options.forEach(function (option) { 6746 var has = false; 6747 6748 if (option.value) { 6749 var i = 0; 6750 6751 while (i < items.length && !has) { 6752 var item = items[i]; 6753 has = filter.doFilter(item, option.value); 6754 i++; 6755 } 6756 } else { 6757 has = true; 6758 } 6759 6760 option.disabled = !has; 6761 }); // console.log(filter.options); 6762 }); 6763 }; 6764 6765 _proto.setFilter = function setFilter(item, filter) { 6766 item = item || filter.options[0]; 6767 filter.value = item.value; 6768 filter.placeholder = item.label; 6769 this.applyFilters(); 6770 }; 6771 6772 _proto.toggleFilter = function toggleFilter(item, filter) { 6773 if (filter.value === item.value) { 6774 filter.value = null; 6775 filter.placeholder = item.label; 6776 } else { 6777 filter.value = item.value; 6778 filter.placeholder = filter.options[0].label; 6779 } 6780 6781 this.applyFilters(); 6782 }; 6783 6784 _proto.removeFilter = function removeFilter(filter) { 6785 this.setFilter(null, filter); 6786 }; 6787 6788 _proto.removeAll = function removeAll() { 6789 var _this5 = this; 6790 6791 var removing = {}; 6792 Object.keys(this.filters).forEach(function (key) { 6793 removing[key] = _this5.filters[key]; 6794 }); 6795 Object.keys(removing).forEach(function (key) { 6796 var filter = removing[key]; 6797 6798 _this5.removeFilter(filter); 6799 }); 6800 this.applyFilters(); 6801 }; 6802 6803 return JournalCtrl; 6804 }(); 6805 6806 JournalCtrl.$inject = ['$scope', '$timeout', 'LocationService']; 6807 6808 /* jshint esversion: 6 */ 6809 var GALLERY_TYPES = Object.freeze({ 6810 PICTURE: 0, 6811 VIDEO: 1 6812 }); 6813 6814 var GalleryItemDirective = /*#__PURE__*/function () { 6815 function GalleryItemDirective($timeout, DomService) { 6816 this.$timeout = $timeout; 6817 this.domService = DomService; 6818 this.restrict = 'A'; 6819 } 6820 6821 var _proto = GalleryItemDirective.prototype; 6822 6823 _proto.link = function link(scope, element, attributes, controller) { 6824 6825 // Rivisto comportamento gallery: ora apre le immagini si aprono con Flexbox 6826 return; 6827 }; 6828 6829 GalleryItemDirective.factory = function factory($timeout, DomService) { 6830 return new GalleryItemDirective($timeout, DomService); 6831 }; 6832 6833 return GalleryItemDirective; 6834 }(); 6835 GalleryItemDirective.factory.$inject = ['$timeout', 'DomService']; 6836 6837 /* jshint esversion: 6 */ 6838 var CookiesDirective = /*#__PURE__*/function () { 6839 function CookiesDirective($timeout, StorageService) { 6840 this.$timeout = $timeout; 6841 this.storage = StorageService; 6842 this.restrict = 'A'; 6843 } 6844 6845 var _proto = CookiesDirective.prototype; 6846 6847 _proto.link = function link(scope, element, attributes, controller) { 6848 var _this = this; 6849 6850 var node = element[0]; 6851 var cookiesAccepted = this.storage.get('cookiesAccepted'); 6852 6853 if (!cookiesAccepted) { 6854 node.classList.add('show-banner'); 6855 } 6856 6857 scope.onAcceptCookies = function (event) { 6858 _this.storage.set('cookiesAccepted', true, 365); // accept(); 6859 6860 6861 TweenMax.to(node, 0.5, { 6862 bottom: '-100%', 6863 ease: Power2.easeInOut, 6864 delay: 0.15, 6865 onComplete: function onComplete() { 6866 node.classList.remove('show-banner'); 6867 } 6868 }); 6869 }; 6870 }; 6871 6872 CookiesDirective.factory = function factory($timeout, StorageService) { 6873 return new CookiesDirective($timeout, StorageService); 6874 }; 6875 6876 return CookiesDirective; 6877 }(); 6878 CookiesDirective.factory.$inject = ['$timeout', 'CookieService']; 6879 6880 /* jshint esversion: 6 */ 6881 var FancyboxGalleryDirective = /*#__PURE__*/function () { 6882 function FancyboxGalleryDirective() { 6883 this.restrict = 'A'; 6884 } 6885 6886 var _proto = FancyboxGalleryDirective.prototype; 6887 6888 _proto.link = function link(scope, element, attributes, controller) { 6889 // Intercetta i click sui pulsanti `data-fancybox-trigger` prima che 6890 // arrivino al gestore delegato di Fancybox sul document: quel gestore 6891 // passa il pulsante come `$trigger`, con la conseguenza che Fancybox 6892 // usa l'immagine dentro il pulsante (es. icon-gallery.svg) come 6893 // thumbnail â animando l'apertura da quell'icona ingrandita e 6894 // impedendo il ritrovamento dei pin (che sono siblings dell'immagine 6895 // della gallery, non dell'icona del pulsante). 6896 element.on('click.fancybox-gallery-trigger', '[data-fancybox-trigger]', function (e) { 6897 e.preventDefault(); 6898 e.stopPropagation(); 6899 var name = $(this).attr('data-fancybox-trigger'); 6900 var idx = parseInt($(this).attr('data-fancybox-index') || '0', 10) || 0; 6901 $('[data-fancybox="' + name + '"]').eq(idx).trigger('click.fb-start'); 6902 }); 6903 $('.fancybox', element).fancybox({ 6904 closeBtn: false, 6905 hash: false, 6906 // Disabilita la modifica dell'URL 6907 touch: false, 6908 zoom: false, 6909 baseClass: 'fancybox-custom', 6910 // Aggiungi una classe base per identificare il fancybox 6911 afterLoad: function afterLoad() { 6912 var $pin = this.$thumb ? this.$thumb.siblings('.label') : $(); 6913 6914 if (!$pin.length) { 6915 return; 6916 } 6917 6918 var _this = this; 6919 6920 $pin.each(function (i, el) { 6921 _this.$content.append($(el).clone()[0]); 6922 }); 6923 }, 6924 afterClose: function afterClose() { 6925 history.pushState("", document.title, window.location.pathname + window.location.search); 6926 } 6927 }).addClass('fancyboxed'); 6928 $('.anchor-link').on('click', function (e) { 6929 // e.preventDefault(); 6930 var target = this.hash, 6931 $target = $(target); 6932 $('html, body').stop().animate({ 6933 'scrollTop': $target.offset().top - 100 6934 }, 900, 'swing', function () {}); // console.log(window.location); 6935 6936 return false;
6937 }); 6938 }; 6939 6940 FancyboxGalleryDirective.factory = function factory() { 6941 return new FancyboxGalleryDirective(); 6942 }; 6943 6944 return FancyboxGalleryDirective; 6945 }(); 6946 FancyboxGalleryDirective.factory.$inject = []; 6947 6948 /* jshint esversion: 6 */ 6949 var FaqDirective = /*#__PURE__*/function () { 6950 function FaqDirective(DomService) { 6951 this.domService = DomService; 6952 this.restrict = 'A'; 6953 } 6954 6955 var _proto = FaqDirective.prototype; 6956 6957 _proto.link = function link(scope, element, attributes, controller) { 6958 var node = element[0]; 6959 var abstract = node.querySelector('.abstract'); 6960 var content = node.querySelector('.content'); 6961 var more = node.querySelector('.btn--discover'); 6962 var isSeoAccordion = node.classList.contains('seo-section__accordion'); 6963 6964 var getCollapsedHeight = function getCollapsedHeight() { 6965 if (!isSeoAccordion) { 6966 return 0; 6967 } 6968 6969 var maxHeight = window.getComputedStyle(content).maxHeight; 6970 var collapsedHeight = parseFloat(maxHeight); 6971 return Number.isFinite(collapsedHeight) ? collapsedHeight : 0; 6972 }; 6973 6974 var collapsedHeight = getCollapsedHeight(); 6975 TweenMax.set(content, { 6976 height: collapsedHeight 6977 }); // Inizializza attributi ARIA per l'accessibilità 6978 6979 var initializeAccessibility = function initializeAccessibility() { 6980 var faqId = "faq-" + Math.random().toString(36).substr(2, 9); 6981 var contentId = faqId + "-content"; 6982 abstract.setAttribute('aria-expanded', 'false'); 6983 abstract.setAttribute('aria-controls', contentId); 6984 content.setAttribute('id', contentId); 6985 content.setAttribute('aria-hidden', 'true'); // Rendi i link dentro al contenuto non navigabili inizialmente 6986 6987 setLinksTabIndex(false); 6988 }; // Gestisce la navigabilità dei link interni 6989 6990 6991 var setLinksTabIndex = function setLinksTabIndex(isNavigable) { 6992 var links = content.querySelectorAll('a, button, input, select, textarea, [tabindex]'); 6993 links.forEach(function (link) { 6994 if (isNavigable) { 6995 // Ripristina il tabindex originale o rimuovilo se era 0 6996 var originalTabIndex = link.getAttribute('data-original-tabindex'); 6997 6998 if (originalTabIndex !== null) { 6999 if (originalTabIndex === '0' || originalTabIndex === '') { 7000 link.removeAttribute('tabindex'); 7001 } else { 7002 link.setAttribute('tabindex', originalTabIndex); 7003 } 7004 7005 link.removeAttribute('data-original-tabindex'); 7006 } 7007 } else { 7008 // Salva il tabindex originale e imposta -1 7009 var currentTabIndex = link.getAttribute('tabindex'); 7010 7011 if (currentTabIndex !== '-1') { 7012 link.setAttribute('data-original-tabindex', currentTabIndex || '0'); 7013 link.setAttribute('tabindex', '-1'); 7014 } 7015 } 7016 }); 7017 }; 7018 7019 var toggleFaq = function toggleFaq() { 7020 if (node.classList.contains('active')) { 7021 // Chiudi la FAQ 7022 node.classList.remove('active'); 7023 if (more) more.classList.remove('active'); 7024 abstract.setAttribute('aria-expanded', 'false'); 7025 content.setAttribute('aria-hidden', 'true'); // Rendi i link non navigabili 7026 7027 setLinksTabIndex(false); 7028 TweenMax.to(content, 0.7, { 7029 height: collapsedHeight, 7030 ease: Power2.easeInOut, 7031 onComplete: function onComplete() {// content.removeAttribute('style'); 7032 } 7033 }); 7034 } else { 7035 // Apri la FAQ 7036 node.classList.add('active'); 7037 abstract.setAttribute('aria-expanded', 'true'); 7038 content.setAttribute('aria-hidden', 'false'); // Rendi i link navigabili 7039 7040 setLinksTabIndex(true); 7041 TweenMax.set(content, { 7042 height: 'auto' 7043 }); 7044 var height = content.offsetHeight; 7045 TweenMax.set(content, { 7046 height: collapsedHeight 7047 }); 7048 TweenMax.to(content, 0.7, { 7049 height: height, 7050 ease: Power2.easeInOut, 7051 onComplete: function onComplete() { 7052 content.removeAttribute('style'); 7053 } 7054 }); 7055 } 7056 }; 7057 7058 var onAbstractClicked = toggleFaq; 7059 7060 var onKeyDown = function onKeyDown(event) {
7061 // Supporta Enter (13) e Spazio (32) per attivare la FAQ 7062 if (event.keyCode === 13 || event.keyCode === 32) { 7063 event.preventDefault(); 7064 event.stopPropagation(); 7065 toggleFaq(); 7066 } 7067 }; 7068 7069 var addListeners = function addListeners() { 7070 // Listener per il click sull'abstract 7071 abstract.addEventListener('click', onAbstractClicked); // Listener per la tastiera sull'elemento principale (node) 7072 7073 node.addEventListener('keydown', onKeyDown); // more.addEventListener('click', onMoreClicked); 7074 }; 7075 7076 var removeListeners = function removeListeners() { 7077 abstract.removeEventListener('click', onAbstractClicked); 7078 node.removeEventListener('keydown', onKeyDown); // more.removeEventListener('click', onMoreClicked); 7079 }; 7080 7081 initializeAccessibility(); 7082 addListeners(); 7083 scope.$on('destroy', function () { 7084 removeListeners(); 7085 }); 7086 }; 7087 7088 FaqDirective.factory = function factory(DomService) { 7089 return new FaqDirective(DomService); 7090 }; 7091 7092 return FaqDirective; 7093 }(); 7094 FaqDirective.factory.$inject = ['DomService']; 7095 7096 /* jshint esversion: 6 */ 7097 7098 var GtmDirective = /*#__PURE__*/function () { 7099 function GtmDirective() { 7100 this.restrict = 'A'; 7101 this.scope = { 7102 eventname: "@?gtmEventname", 7103 searchterm: "@?gtmSearchterm", 7104 position: "@?gtmPosition", 7105 label: "@?gtmLabel", 7106 sottomenu: "@?gtmSottomenu", 7107 nomecontenuto: "@?gtmNomecontenuto", 7108 pagetype: "@?gtmPagetype", 7109 pagecategory: "@?gtmPagecategory", 7110 language: "@?gtmLanguage", 7111 firstlevelcategory: "@?gtmFirstlevelcategory", 7112 secondlevelcategory: "@?gtmSecondlevelcategory", 7113 thirdlevelcategory: "@?gtmThirdlevelcategory" 7114 }; 7115 } 7116 7117 var _proto = GtmDirective.prototype; 7118 7119 _proto.link = function link(scope, element, attributes, controller) { 7120 var node = element[0]; 7121 7122 var onClick = function onClick(event) { 7123 var gtmObj = { 7124 event: "GA4event", 7125 eventname: "", 7126 searchterm: "", 7127 position: "", 7128 label: "", 7129 sottomenu: "", 7130 nomecontenuto: "", 7131 pagetype: "", 7132 pagecategory: "", 7133 language: "", 7134 firstlevelcategory: "", 7135 secondlevelcategory: "", 7136 thirdlevelcategory: "" 7137 }; 7138 7139 for (var key in gtmObj) { 7140 if (scope[key]) gtmObj[key] = scope[key]; 7141 } 7142 7143 GtmService.push(gtmObj); 7144 console.log('GtmService.dataLayer2 ', dataLayer); 7145 }; 7146 7147 node.addEventListener('click', onClick); 7148 scope.$on('$destroy', function () { 7149 node.removeEventListener('click', onClick); 7150 }); 7151 }; 7152 7153 GtmDirective.factory = function factory() { 7154 return new GtmDirective(); 7155 }; 7156 7157 return GtmDirective; 7158 }(); 7159 7160 /* jshint esversion: 6 */ 7161 7162 var HeaderDirective = /*#__PURE__*/function () { 7163 function HeaderDirective(DomService) { 7164 this.domService = DomService; 7165 this.restrict = 'E'; 7166 } 7167 7168 var _proto = HeaderDirective.prototype; 7169 7170 _proto.link = function link(scope, element, attributes, controller) { 7171 var _this = this; 7172 7173 var node = element[0]; 7174 setTimeout(function () { 7175 _this.init(scope, element, attributes, controller); 7176 }, 1); 7177 this.addListeners(node); 7178 scope.$on('destroy', function () { 7179 _this.removeListeners(node); 7180 }); 7181 }; 7182 7183 _proto.init = function init(scope, element, attributes, controller) { 7184 var node = element[0]; //const brand = node.querySelector('.brand'); 7185 7186 var primary = Array.prototype.slice.call(node.querySelectorAll('.nav--primary > li')); 7187 var secondary = Array.prototype.slice.call(node.querySelectorAll('.nav--secondary > li')); 7188 var tertiary = Array.prototype.slice.call(node.querySelectorAll('.nav--tertiary > li')); 7189 var menus = [primary, secondary, tertiary]; 7190 var scrollTop = document.body.scrollTop || document.documentElement.scrollTop; 7191 7192 if (scrollTop === 0) { 7193 //TweenMax.set(brand { opacity: 1 }); 7194 scope.$on('onCoverStart', function ($scope) { 7195 var rect = Rect.fromNode(brand); 7196 var x = (window.innerWidth - rect.width) / 2 - rect.left; 7197 var y = window.innerHeight / 2 - rect.top - 80; 7198 /*TweenMax.set(brand, { 7199 x: x, 7200 y: y, 7201 opacity: 1 7202 });*/ 7203 }); 7204 scope.$on('onCoverEnd', function ($scope) { 7205 /*TweenMax.to(brand, 0.65, { 7206 x: 0, 7207 y: 0, 7208 opacity: 1, 7209 ease: Power2.easeInOut 7210 });*/
7211 menus.forEach(function (m, i) { 7212 m.forEach(function (l, j) { 7213 TweenMax.to(l, 0.45, { 7214 opacity: 1, 7215 delay: 1 + 0.2 * i + 0.1 * j, 7216 ease: Power2.easeInOut 7217 }); 7218 }); 7219 }); 7220 }); 7221 } else { 7222 /*TweenMax.set(brand, { 7223 opacity: 1 7224 });*/ 7225 menus.forEach(function (m, i) { 7226 m.forEach(function (l, j) { 7227 TweenMax.set(l, { 7228 opacity: 1 7229 }); 7230 }); 7231 }); 7232 } 7233 }; 7234 7235 _proto.onOver = function onOver(event) { 7236 TweenMax.to(event.currentTarget, 0.3, { 7237 x: 15, 7238 ease: Power2.easeOut 7239 }); 7240 }; 7241 7242 _proto.onOut = function onOut(event) { 7243 TweenMax.to(event.currentTarget, 0.3, { 7244 x: 0, 7245 ease: Power2.easeOut 7246 }); 7247 }; 7248 7249 _proto.addListeners = function addListeners(node) { 7250 var _this2 = this; 7251 7252 var lis = Array.prototype.slice.call(node.querySelectorAll('.nav--submenu li > a, .nav--submenu li > span')); 7253 lis.forEach(function (li) { 7254 li.addEventListener('mouseover', _this2.onOver); 7255 li.addEventListener('mouseout', _this2.onOut); 7256 }); 7257 }; 7258 7259 _proto.removeListeners = function removeListeners(node) { 7260 var _this3 = this; 7261 7262 var lis = Array.prototype.slice.call(node.querySelectorAll('.nav--submenu li > a, .nav--submenu li > span')); 7263 lis.forEach(function (li) { 7264 li.removeEventListener('mouseover', _this3.onOver); 7265 li.removeEventListener('mouseout', _this3.onOut); 7266 }); 7267 }; 7268 7269 HeaderDirective.factory = function factory(DomService) { 7270 return new HeaderDirective(DomService); 7271 }; 7272 7273 return HeaderDirective; 7274 }(); 7275 HeaderDirective.factory.$inject = ['DomService']; 7276 7277 /* jshint esversion: 6 */ 7278 var first$1 = true; 7279 7280 var HeroDirective = /*#__PURE__*/function () { 7281 function HeroDirective(DomService) { 7282 this.domService = DomService; 7283 this.restrict = 'A'; 7284 } 7285 7286 var _proto = HeroDirective.prototype; 7287 7288 _proto.link = function link(scope, element, attributes, controller) { 7289 var _this = this; 7290 7291 // console.log('HeroDirective'); 7292 setTimeout(function () { 7293 _this.init(scope, element, attributes, controller); 7294 }, 1); 7295 }; 7296 7297 _proto.init = function init(scope, element, attributes, controller) { 7298 var _this2 = this; 7299 7300 var node = element[0]; 7301 var cover = node.querySelector('.picture--cover'); 7302 7303 if (cover != null && cover.length && first$1 && (document.body.scrollTop || document.documentElement.scrollTop) === 0) { 7304 first$1 = false; 7305 scope.$root.$broadcast('onCoverInit'); // const brand = document.querySelector('.section--header .brand'); 7306 7307 cover.classList.add('appeared'); // TweenMax.set(brand, { opacity: 0 }); 7308 7309 TweenMax.set(cover, { 7310 opacity: 0 7311 }); 7312 var img = node.querySelector('img'); 7313 7314 if (img) { 7315 img.onload = function () { 7316 _this2.onLoad(scope, cover); 7317 }; 7318 7319 img.src = img.src; 7320 } else { 7321 this.onLoad(scope, cover); 7322 } 7323 } else { 7324 scope.$root.$broadcast('onCoverEnd'); 7325 } 7326 }; 7327 7328 _proto.onLoad = function onLoad(scope, cover) { 7329 var _this3 = this; 7330 7331 // this.animateBrand(brand); 7332 setTimeout(function () { 7333 scope.$root.$broadcast('onCoverStart'); 7334 7335 _this3.animateCover(cover, function () { 7336 scope.$root.$broadcast('onCoverEnd'); 7337 }); 7338 }, 100); 7339 } 7340 /* 7341 animateBrand(node) { 7342 const rect = Rect.fromNode(node); 7343 const x = (window.innerWidth - rect.width) / 2 - rect.left; 7344 const y = window.innerHeight / 2 - rect.bottom - 40; 7345 TweenMax.set(node, { 7346 x: x, 7347 y: y, 7348 opacity: 1 7349 }); 7350 TweenMax.to(node, 0.65, { 7351 x: 0, 7352 y: 0, 7353 delay: 1.5, 7354 ease: Power2.easeInOut 7355 }); 7356 } 7357 */ 7358 ; 7359 7360 _proto.animateCover = function animateCover(node, callback) { 7361 var rect = Rect.fromNode(node); 7362 var x = (window.innerWidth - rect.width) / 2 - rect.left; 7363 var y = window.innerHeight / 2 - rect.top + 40 - rect.height * 0.25; // console.log('pos', x, y, window.innerWidth, rect.width); 7364 7365 TweenMax.set(node, { 7366 x: x, 7367 y: y, 7368 scaleX: 0.5, 7369 scaleY: 0.5, 7370 opacity: 1 7371 }); 7372 TweenMax.to(node, 0.5, { 7373 x: 0, 7374 y: 0, 7375 scaleX: 1, 7376 scaleY: 1, 7377 delay: 1.5, 7378 ease: Power2.easeInOut, 7379 onComplete: function onComplete() { 7380 if (typeof callback === 'function') { 7381 callback(); 7382 } 7383 } 7384 }); 7385 }; 7386 7387 HeroDirective.factory = function factory(DomService) { 7388 return new HeroDirective(DomService); 7389 }; 7390 7391 return HeroDirective; 7392 }(); 7393 HeroDirective.factory.$inject = ['DomService']; 7394 7395 /* jshint esversion: 6 */ 7396 var HilightDirective = /*#__PURE__*/function () { 7397 function HilightDirective() { 7398 this.restrict = 'A'; 7399 } 7400 7401 var _proto = HilightDirective.prototype; 7402 7403 _proto.link = function link(scope, element, attributes, controller) { 7404 var node = element[0]; 7405 var hilight, query; 7406
7407 var update = function update() { 7408 if (hilight) { 7409 if (query) { 7410 var index = hilight.toLowerCase().indexOf(query); 7411 7412 if (index !== -1) { 7413 node.innerHTML = hilight.substring(0, index) + "<span class=\"hilight\">" + hilight.substring(index, index + query.length) + "</span>" + hilight.substring(index + query.length, hilight.length); 7414 } else { 7415 node.innerHTML = hilight; 7416 } 7417 } else { 7418 node.innerHTML = hilight; 7419 } 7420 } // console.log(hilight, query, node.innerHTML); 7421 7422 }; 7423 7424 scope.$watch(attributes.hilight, function (current, previous) { 7425 // console.log('HilightDirective.hilight', current, previous); 7426 hilight = current; 7427 update(); 7428 }); 7429 scope.$watch(attributes.query, function (current, previous) { 7430 // console.log('HilightDirective.query', current, previous); 7431 query = current; 7432 update(); 7433 }); 7434 return; 7435 }; 7436 7437 HilightDirective.factory = function factory() { 7438 return new HilightDirective(); 7439 }; 7440 7441 return HilightDirective; 7442 }(); 7443 HilightDirective.factory.$inject = []; 7444 7445 /* jshint esversion: 6 */ 7446 7447 var HrefDirective = /*#__PURE__*/function () { 7448 function HrefDirective() { 7449 this.restrict = 'A'; 7450 } 7451 7452 var _proto = HrefDirective.prototype; 7453 7454 _proto.link = function link(scope, element, attributes, controller) { 7455 7456 var node = element[0]; 7457 7458 if (attributes.href.indexOf('#') === 0) { 7459 var _node = element[0]; 7460 7461 if (_node.classList.contains('fancybox')) { 7462 var _onClick = function _onClick(event) { 7463 event.preventDefault(); 7464 event.stopPropagation(); 7465 }; 7466 7467 _node.addEventListener('click', _onClick); 7468 7469 return; 7470 } 7471 7472 var href = window.location.pathname + _node.getAttribute('href'); 7473 7474 setTimeout(function () { 7475 _node.setAttribute('href', href); 7476 }); // console.log('HrefDirective', href, node.getAttribute('href')); 7477 } 7478 7479 if (attributes.target === '_blank' || attributes.download !== undefined) { 7480 return; 7481 } 7482 7483 var onClick = function onClick() { 7484 console.log(attributes.href); // window.location.href = attributes.href; 7485 }; // console.log('USE_HIGHWAY', USE_HIGHWAY, attributes.href, attributes.routerDisabled); 7486 7487 7488 { 7489 if (attributes.routerDisabled === undefined) { 7490 scope.$emit('onHrefNode', node); 7491 } else { 7492 // console.log(attributes.routerDisabled, node); 7493 node.addEventListener('click', onClick); 7494 } 7495 7496 return; 7497 } 7498 }; 7499 7500 _proto.getDomain = function getDomain(text) { 7501 var domainRegexp = /([[a-zA-Z0-9-_]+\.]*[a-zA-Z0-9][a-zA-Z0-9-_]+\.[a-zA-Z]{2,11})/; 7502 var matches = text.match(domainRegexp); 7503 return matches && matches.length > 1 ? matches[1] : null; 7504 }; 7505 7506 _proto.getMarket = function getMarket(text) { 7507 var marketRegexp = /(^|[^\/])\/([^\/]+)/; 7508 var matches = text.match(marketRegexp); 7509 return matches && matches.length > 2 ? matches[2] : null; 7510 }; 7511 7512 HrefDirective.factory = function factory() { 7513 return new HrefDirective(); 7514 }; 7515 7516 return HrefDirective; 7517 }(); 7518 HrefDirective.factory.$inject = []; 7519 7520 /* jshint esversion: 6 */ 7521 var LabelDirective = /*#__PURE__*/function () { 7522 function LabelDirective() { 7523 this.restrict = 'A'; 7524 this.scope = { 7525 item: '=?abstract' 7526 }; 7527 } 7528 7529 var _proto = LabelDirective.prototype; 7530 7531 _proto.link = function link(scope, element, attributes, controller) { 7532 scope.item = scope.item || { 7533 top: 0.5, 7534 left: 0.5 7535 }; 7536 var node = element[0]; 7537 node.setAttribute('style', "left: " + scope.item.left * 100 + "%; top: " + scope.item.top * 100 + "%;"); 7538 scope.$on('$destroy', function () {}); 7539 }; 7540 7541 LabelDirective.factory = function factory() { 7542 return new LabelDirective(); 7543 }; 7544 7545 return LabelDirective; 7546 }(); 7547 LabelDirective.factory.$inject = []; 7548 7549 /* jshint esversion: 6 */ 7550 var LastItemDirective = /*#__PURE__*/function () { 7551 function LastItemDirective($timeout) { 7552 this.$timeout = $timeout; 7553 this.restrict = 'A'; 7554 } 7555 7556 var _proto = LastItemDirective.prototype; 7557 7558 _proto.link = function link(scope, element, attributes, controller) { 7559 if (scope.$last === true) { 7560 this.$timeout(function () { 7561 scope.$emit('lastItem', element); 7562 }); 7563 } 7564 }; 7565 7566 LastItemDirective.factory = function factory($timeout) {
7567 return new LastItemDirective($timeout); 7568 }; 7569 7570 return LastItemDirective; 7571 }(); 7572 LastItemDirective.factory.$inject = ['$timeout']; 7573 7574 /* jshint esversion: 6 */ 7575 var LazyScriptDirective = /*#__PURE__*/function () { 7576 function LazyScriptDirective() { 7577 this.restrict = 'A'; 7578 this.scope = false; 7579 } 7580 7581 var _proto = LazyScriptDirective.prototype; 7582 7583 _proto.link = function link(scope, element, attributes, controller) { 7584 // if (attributes.type === 'text/javascript-lazy') { 7585 if (attributes.src !== undefined) { 7586 fetch(attributes.src, { 7587 mode: 'no-cors' 7588 }).then(function (response) { 7589 var code = response.text(); 7590 7591 try { 7592 new Function(code)(); 7593 } catch (error) { 7594 console.log('LazyScriptDirective.error', error); 7595 } 7596 }); 7597 } else { 7598 var code = element.text(); 7599 7600 try { 7601 new Function(code)(); 7602 } catch (error) { 7603 console.log('LazyScriptDirective.error', error); 7604 } 7605 } // } 7606 // scope.$on('$destroy', () => {}); 7607 7608 }; 7609 7610 LazyScriptDirective.factory = function factory() { 7611 return new LazyScriptDirective(); 7612 }; 7613 7614 return LazyScriptDirective; 7615 }(); 7616 LazyScriptDirective.factory.$inject = []; 7617 7618 /* jshint esversion: 6 */ 7619 7620 var LazyDirective = /*#__PURE__*/function () { 7621 // src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" lazy lazy-src=" 7622 function LazyDirective(IntersectionService) { 7623 this.intersectionService = IntersectionService; 7624 this.restrict = 'A'; 7625 this.scope = { 7626 src: "@?", 7627 srcset: "@?", 7628 backgroundSrc: "@?" 7629 }; 7630 } 7631 7632 var _proto = LazyDirective.prototype; 7633 7634 _proto.link = function link(scope, element, attributes, controller) { 7635 var _this = this; 7636 7637 var image = element[0]; 7638 image.classList.remove('lazying', 'lazyed'); 7639 var subscription = this.intersectionService.intersection$(image).pipe(first()).subscribe(function (event) { 7640 if (!image.classList.contains('lazying')) { 7641 image.classList.add('lazying'); 7642 7643 _this.onAppearsInViewport(image, scope, attributes); 7644 } 7645 }); 7646 scope.$on('$destroy', function () { 7647 subscription.unsubscribe(); 7648 }); 7649 }; 7650 7651 _proto.onAppearsInViewport = function onAppearsInViewport(image, scope, attributes) { 7652 if (scope.srcset) { 7653 // attributes.$set('srcset', scope.srcset); 7654 image.setAttribute('srcset', scope.srcset); 7655 image.removeAttribute('data-srcset'); 7656 7657 if (scope.src) { 7658 // attributes.$set('src', scope.src); 7659 image.setAttribute('src', scope.src); 7660 image.removeAttribute('data-src'); 7661 } 7662 7663 image.classList.remove('lazying'); 7664 image.classList.add('lazyed'); 7665 } else if (scope.src) { 7666 image.removeAttribute('data-src'); 7667 this.onImagePreload(image, scope.src, function (srcOrUndefined) { 7668 // image.setAttribute('src', src); 7669 image.classList.remove('lazying'); 7670 image.classList.add('lazyed'); 7671 }); 7672 } else if (scope.backgroundSrc) { 7673 image.setStyle('background-image', "url(" + scope.backgroundSrc + ")"); 7674 image.removeAttribute('data-background-src'); 7675 image.classList.remove('lazying'); 7676 image.classList.add('lazyed'); 7677 } 7678 } 7679 /* 7680 lazy$(node) { 7681 return this.intersectionService.rafAndRect$().pipe( 7682 map(datas => { 7683 const windowRect = datas[1]; 7684 const rect = Rect.fromNode(node); 7685 const intersection = rect.intersection(windowRect); 7686 return intersection; 7687 }) 7688 ); 7689 } 7690 */ 7691 ; 7692 7693 _proto.onImagePreload = function onImagePreload(image, src, callback) { 7694 // const img = new Image(); 7695 image.onload = function () { 7696 image.onload = image.onerror = null; 7697 7698 if (typeof callback === 'function') { 7699 // setTimeout(() => { 7700 callback(image.src); // }, 10); 7701 } 7702 }; 7703 7704 image.onerror = function (e) { 7705 image.onload = image.onerror = null; 7706 image.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQgAAAC/CAMAAAA1kLK0AAAATlBMVEX////MzMyZmZn39/fHx8fPz8+Ojo7FxcXDw8Pn5+fS0tLq6url5eX8/PyUlJTi4uLX19fv7++JiYm9vb3d3d2FhYWtra2qqqqAgICdnZ2sCR5lAAAJUElEQVR4nO2d6YKzKgyGa7VaN1zqdL7e/42eigERkGobrM7J+2umM3V5DEkICKeQxHUKT6SnCASIQIAIBIhAgAgEiECACASIQIAIBIhAgAgEiECACASIQIAIBIhAgAgEiECACASIQIAIBIhAgAgEiECACASIQIAIBIhAgAgE6NsgynFcvvzqhXwNRBk2RVdnQRBEXM8fsrormm/x+AqIsqnqAO5+Iv5ZXTVfgLE9iLDoIegIpjiCutj8srYFUaaZG8III0s3tYtNQTT1MgqCRd1sd20bgkiDZDmFQUmQbnV1m4Go5owhimTYsP612ub6NgKRWm60v/lL1nVF+lQfSi+BjUcUbWIVm4BogshkUKdmlCybtL4YNKJgA1+xAYiwjjQKQZc78qYw7/T4GtX+r9I7CK1VPCm8zpfKppsakf/24RtEmUWT+8nyhdlBmU9jbZT5TSs8g2jUm4lWWnhYT7/t1VP4BVFdlRtJ1jf0sEsUFFefkdQriFrJoK7v+btQPUZSY1+hciJ/IErF30XR26cJlfYRBd4chT8QoWLUyUdGXSlG8T7QF/IGIlSf44fnCFXb8nW9nkAoHJLuY3suu8Q3CU8gVA45xgFz3zbhB0Sp+Aek4yvNI/LhMf2AUJwbij30Ki8jXaxjKvIC4qIGDDQS42GjC9oxpXyA6Cb9pSseCdlviTq0Ywp5AJFqFTkfJBL0zig+iMaoTCKSkK0jwe6BoYMoFUcp/QTa81PSduTQgQ5ClqOiskjwScgEJULugGGDaFTbTT2QkCdALk8ggyind17IegReFB3pojYOZBAicgrDHUngeUzR+HBjKC6IUDwtmQWPfgKNhMzfE9RLRwWRiZse22+FT6IRZpYhHbAXKgiRQkw8ugcSonFgJhOoIKRnnLgxfD8xdm5xjtcLE4Q0CC1WpmPsQIqiInIgmgQmiMvcczJINGnuUPr6ksTx8LqhiCCkQZgNQCdR/cQOtffF58IzCUQQtcOX6ySK+OxQ/NqXiH4oWqKNB0LkEPbUN9VyTCcJ9tokRA0TLZfAA1FFzmarZ1ZOEgtMAhwS2oQaPBCBPWRIGSTaj0wiFSEU6fLRQMh6zGxXSM+sUgeJ9qUTFN07LHeJBgK6W66ekG4T+c/w+PtIwTQSr01iwQnXCAuEeECW0Zfq9tTQGrQcM29Zy36vWV1n19/nj2r
7706juE1lugJZosHpjWOBEJd1MS8raBlj7dAa9HzipnjFJmBKY2ETtRZXcJlF/9YNIIGAmGFz4hceH+wkNNVsJpbElljkOOUbwgKRzYf1AQSExFf9juvUg8Zs8B42ECJxwemMI4EIHcEMQJxjfuc2EmpzStnoKtj5kha3dgaEDNg4d4ADonG4cAHizHQS3EbK2/33936TE9CbhyTx4J9l8QwIETdQAigSiAKuyZYRShBAQqny83/vemf6jKD3Yvj/5gwkYsD6y+wgIM2OCow7QAIBNSNr5j+CMEkMNjL4Bdbeh6/n8AUGR8tmQICTwBnhQAIhQpn1b0okGDymkllxEpBZnSHInmrwmHBpdWwHcXL3btYJB4RIp6wOXAUBUVTJrCYkzv8GM7+z0bvy3+wgRK0YI6XCARG60t0JCCOfuPJbz8EGHj/c8zX8V/bg36/nnKX0lii3gAJCBA1rajAFYWZWnEQqQwt/vDc2hM+6aa6z4VP0QFHCBg4IuCJ7T1ADcW75GedIxNzPCAsR3TE7COjxoszcxwFROYKGAWIweINEMYkVj+l37CBE2MBIsnFAQGNNrF5LA8Gu8HmqeUwgEfPsNGELQJSJwzWtFA6I2hE9DR8hn1+a2Eiw3/7nql0A4oRYwf0CiP6EIaeh5xODn+BtIzwmCBHQrX/UQMT9Z+mPlmNCPsEjBA8r8RIQrvRlpbYHwfrPungmx2xFF2OJj/gTIMzMSpD4v4GYyazy+P8CgvsI3sGcyTEH93FMH7E+aii9Kp1EdeCosT6P+B1IDDZgqd4dNI9YlVkm/YcBpJEaiasgcT1mZrm+rxGKctzQz0h0Egfta6zrfXIfGU1q2zoJzUUcpve5ph5xZrf+01LYvp1EvsRH7K8esaJCdRZD3c3PQ7UQo3rXvgaxvwrV8polN4lhqLv4B7//OKt3DhD7q1kurmJzPdoh3uVi/FsnIXLMVyD2V8VeOq4h72so24d3QNEOmVUyJZEyN4g9jmssG+kaG8cZ/Ftx76uSjLXcu+SzJA4z0rVo7FMl8ZBDnfUw9snbea5XapgLxB7HPpeMhk9JMGuo1at3srZ9lNHwBfMjdLVX819NEuAxDzM/4vWMGVMxs3k5g0Q7B2KfM2bC+VA2B+JpFExdaisfZoxZSVhAlPucQ+WYVTcPoh//VmfVDTmm4jF5POgHQi0gdjqrzjHt0QWCwxjnWQ6ZVa5lVo11WsBO51k6Zt5e9MmkDg2ZlUKCt5aGmSB2O/N2fi524Hw5Q9O/IbPSs21znuVu52LPz87PL9kKDRZlkDDw7nd2vnxfA2dNGaNmNZV4M3qH72vICi5OgqNHUU2iB77DN3iw37NykpAv8Ozxna75t/zek4uE+Msu3/IbTQL57U6TRIpuEH7eBMZaKCrXqndCpSSEc55e/t8N/0R6ZgXa/bvhttUCPpOVxP5XC7CsH/Gp9MzqdIz1I4wVRT6X6SeOsKKIvsYMhoyK7iHWmPGxKNB07SLZy933qkPqOlRoB1bHO6SD2Ps6VGPjQFyodyShLAe495XJFNvFy39HjyltY/dr1SnPD6kf2ksncYTVC5X1LL2ROMZ6ln6WIh2j6HFWOFXWvI0s74q/KWUd5MOseassFPXx4uBCoWIQx1kFebJOOnIN81DrYtNK6cqBae18cWTaTQFE+2tITXdLeetEYX1Vj4F9hcqJfILQ9uDpVp8qrP/GHjy0K9MofZ+uevk+Xdlf2qfrRDu3Kaew7uU3++/lX93L72Tf3fEyt7ujudflX9ndsdf8fp+12O+z+x/s99mLdoCVoj2BpWiXaCnaN1w5I+0kL1U2FY+SBg7+WV29zrjw9RUQvcqw6bfIDkTYeP7Qh9LGsWuyV30NBKgMpb5EAPRtELsRgQARCBCBABEIEIEAEQgQgQARCBCBABEIEIEAEQgQgQARCBCBABEIEIEAEQgQgQARCBCBABEIEIEAEQgQgQARCBCBABEIEIEAPUGQuP4DT2RwhyUkgc4AAAAASUVORK5CYII='; // setTimeout(() => { 7707 7708 callback(); // }, 10); 7709 }; 7710 7711 image.src = src; 7712 }; 7713 7714 LazyDirective.factory = function factory(IntersectionService) { 7715 return new LazyDirective(IntersectionService); 7716 }; 7717 7718 return LazyDirective; 7719 }(); 7720 LazyDirective.factory.$inject = ['IntersectionService']; 7721 7722 /* jshint esversion: 6 */ 7723 var MediaDirective = /*#__PURE__*/function () { 7724 function MediaDirective($timeout, WishlistService) { 7725 this.$timeout = $timeout; 7726 this.wishlistService = WishlistService; 7727 this.restrict = 'A'; 7728 this.transclude = true; 7729 this.template = "<div class=\"media\">\n\t<ng-transclude></ng-transclude>\n</div>\n<div class=\"group--share\">\n\t<div class=\"group--share__label\">Share</div>\n\t<div class=\"group--actions\">\n\t\t<div class=\"btn btn--facebook\" ng-click=\"onFacebook()\" ng-if=\"onFacebook\">\n\t\t\t<svg class=\"icon icon--facebook\"><use xlink:href=\"#icon--facebook\"></use></svg>\n\t\t</div>\n\t\t<div class=\"btn btn--linkedin\" ng-click=\"onLinkedin()\" ng-if=\"onLinkedin\">\n\t\t\t<svg class=\"icon icon--linkedin\"><use xlink:href=\"#icon--linkedin\"></use></svg>\n\t\t</div>\n\t\t<div class=\"btn btn--pinterest\" ng-click=\"onPinterest()\" ng-if=\"onPinterest\">\n\t\t\t<svg class=\"icon icon--pinterest\"><use xlink:href=\"#icon--pinterest\"></use></svg>\n\t\t</div>\n\t</div>\n</div>\n"; 7730 this.scope = { 7731 item: '=?media' 7732 }; 7733 } 7734 7735 var _proto = MediaDirective.prototype; 7736 7737 _proto.link = function link(scope, element, attributes, controller) { 7738 scope.item = scope.item || {}; 7739 var node = element[0]; 7740 var img = node.querySelector('img'); 7741 7742 if (img) { 7743 var pageTitle = document.title; 7744 var pageUrl = window.location.href + "?imageId=" + scope.item.id; 7745 7746 scope.onFacebook = function (event) { 7747 console.log('ShareDirective.onFacebook', event); 7748 var url = "https://www.facebook.com/sharer/sharer.php?u=" + encodeURIComponent(pageUrl); 7749 window.open(url, 'facebookShareWindow', "height=450, width=550, top=" + (window.innerHeight / 2 - 275) + ", left=" + (window.innerWidth / 2 - 225) + ", toolbar=0, location=0, menubar=0, directories=0, scrollbars=0"); // event.preventDefault(); 7750 }; 7751 7752 scope.onTwitter = function (event) { 7753 console.log('ShareDirective.onTwitter', event); 7754 var url = "https://twitter.com/intent/tweet?url=" + encodeURIComponent(pageUrl) + "&via=LeaCeramiche&text=" + encodeURIComponent(pageTitle); 7755 window.open(url, 'twitterShareWindow', "height=450, width=550, top=" + (window.innerHeight / 2 - 275) + ", left=" + (window.innerWidth / 2 - 225) + ", toolbar=0, location=0, menubar=0, directories=0, scrollbars=0"); // event.preventDefault(); 7756 }; 7757 7758 scope.onLinkedin = function (event) { 7759 console.log('ShareDirective.onLinkedin', event); 7760 var url = "http://www.linkedin.com/shareArticle?mini=true&url=" + encodeURIComponent(pageUrl) + "&via=LeaCeramiche&text=" + encodeURIComponent(pageTitle); 7761 window.open(url, 'linkedinShareWindow', "height=450, width=550, top=" + (window.innerHeight / 2 - 275) + ", left=" + (window.innerWidth / 2 - 225) + ", toolbar=0, location=0, menubar=0, directories=0, scrollbars=0"); // event.preventDefault(); 7762 }; 7763 7764 scope.onPinterest = function () { 7765 var pin = { 7766 url: pageUrl, 7767 media: img.src || pageSrc, 7768 description: img.title || pageTitle 7769 }; 7770 console.log('ShareDirective.onPin', pin); 7771 PinUtils.pinOne(pin); 7772 }; 7773 } 7774 /* 7775 scope.$watch(() => { 7776 return this.wishlistService.has(scope.item); 7777 }, (current, previous) => { 7778 // console.log(current, previous, node); 7779 if (scope.wishlistActive !== current) { 7780 scope.wishlistActive = current; 7781 if (current) { 7782 scope.wishlistActivated = true; 7783 this.$timeout(() => { 7784 scope.wishlistActivated = false; 7785 }, 2000); 7786 } else { 7787 scope.wishlistDeactivated = true; 7788 this.$timeout(() => { 7789 scope.wishlistDeactivated = false; 7790 }, 2000); 7791 } 7792 } 7793 }); 7794 scope.onClickWishlist = (event) => { 7795 this.wishlistService.toggle(scope.item).then( 7796 (has) => { 7797 console.log('MediaDirective.onClickWishlist', has); 7798 }, 7799 (error) => { 7800 console.log(error); 7801 } 7802 ); 7803 event.preventDefault(); 7804 event.stopPropagation(); 7805 }; 7806 */ 7807 7808 7809 scope.$on('$destroy', function () {}); 7810 }; 7811 7812 MediaDirective.factory = function factory($timeout, WishlistService) { 7813 return new MediaDirective($timeout, WishlistService); 7814 }; 7815 7816 return MediaDirective; 7817 }(); 7818 MediaDirective.factory.$inject = ['$timeout', 'WishlistService']; 7819 7820 /* jshint esversion: 6 */ 7821 var MuuriDirective = /*#__PURE__*/function () { 7822 function MuuriDirective() { 7823 this.restrict = 'A'; 7824 } 7825 7826 var _proto = MuuriDirective.prototype; 7827 7828 _proto.link = function link(scope, element, attributes, controller) { 7829 var _this = this; 7830 7831 var node = element[0]; 7832 var target = attributes.muuri ? node.querySelector(attributes.muuri) || node : node; 7833 scope.$on('lastItem', function (slide) { 7834 // console.log('MuuriDirective.lastItem', slide); 7835 _this.onMuuri(scope, element, attributes); 7836 }); 7837 setTimeout(function () { 7838 _this.onMuuri(scope, element, attributes); 7839 }, 1); 7840 /* 7841 todo 7842 onResize as subscription debounced 7843 */ 7844 7845 scope.$on('$destroy', function () { 7846 if (element.muuri) { 7847 element.muuri.destroy(); 7848 } 7849 7850 window.removeEventListener('resize', element.onResize); 7851 7852 if (element.onLoad) { 7853 // window.removeEventListener('load', element.onLoad); 7854 var images = Array.prototype.slice.call(target.querySelectorAll('img'));
7855 images.forEach(function (x) { 7856 x.onload = null; 7857 }); 7858 } 7859 }); 7860 }; 7861 7862 _proto.onMuuri = function onMuuri(scope, element, attributes) { 7863 var _this2 = this; 7864 7865 var node = element[0]; 7866 var target = attributes.muuri ? node.querySelector(attributes.muuri) || node : node; 7867 7868 if (element.muuri) { 7869 // const items = scope.$eval(attributes.muuri); 7870 var previousItems = element.muuri.getItems().map(function (x) { 7871 return x.getElement(); 7872 }); // console.log('MuuriDirective.previousItems', previousItems); 7873 7874 var items = Array.prototype.slice.call(target.querySelectorAll('.listing__item')); // console.log('MuuriDirective.newItems', items); 7875 7876 var newItems = items.filter(function (x) { 7877 return previousItems.indexOf(x) === -1; 7878 }); 7879 var removeItems = previousItems.filter(function (x) { 7880 return items.indexOf(x) === -1; 7881 }); 7882 element.muuri.remove(removeItems); 7883 element.muuri.add(newItems); 7884 element.onResize(); // element.muuri.refreshItems(items).layout(); 7885 } else { 7886 // The layout data object. Muuri will read this data and position the items 7887 // based on it. 7888 7889 /* 7890 const layout = { 7891 // The layout's item slots (left/top coordinates). 7892 slots: [], 7893 // The layout's total width. 7894 width: 0, 7895 // The layout's total height. 7896 height: 0, 7897 // Should Muuri set the grid's width after layout? 7898 setWidth: false, 7899 // Should Muuri set the grid's height after layout? 7900 setHeight: true 7901 }; 7902 */ 7903 element.muuri = new Muuri(target, { 7904 layoutDuration: 0, 7905 // 400 7906 layoutEasing: 'ease', 7907 layout: { 7908 fillGaps: true, 7909 horizontal: false, 7910 alignRight: false, 7911 alignBottom: false, 7912 rounding: false 7913 } 7914 /* 7915 sortData: { 7916 order: function(item, element) { 7917 const style = window.getComputedStyle(element); 7918 console.log(style.order); 7919 return 100 - style.order; 7920 }, 7921 } 7922 */ 7923 7924 /* 7925 layout: function(items, gridWidth, gridHeight) { 7926 console.log(items, gridWidth, gridHeight); 7927 // Calculate the slots. 7928 let x = 0, 7929 y = 0, 7930 w = 0, 7931 h = 0; 7932 layout.slots.length = 0; 7933 for (let i = 0; i < items.length; i++) { 7934 const item = items[i]; 7935 x += w; 7936 y += h; 7937 const m = item.getMargin(); 7938 w = item.getWidth() + m.left + m.right; 7939 h = item.getHeight() + m.top + m.bottom; 7940 layout.slots.push(x, y); 7941 } 7942 // Calculate the layout's total width and height. 7943 layout.width = x + w; 7944 layout.height = y + h; 7945 return layout; 7946 } 7947 */ 7948 7949 }); 7950 7951 element.onLoad = function () { 7952 element.muuri.refreshItems().layout(); 7953 }; // window.addEventListener('load', element.onLoad); 7954 7955 7956 var images = Array.prototype.slice.call(target.querySelectorAll('img')); 7957 images.forEach(function (x) { 7958 x.onload = element.onLoad; 7959 }); 7960 element.addClass('muuri-init'); 7961 7962 element.onResize = function () { 7963 return _this2.onResize(element); 7964 }; 7965 7966 element.onResize(); 7967 window.addEventListener('resize', element.onResize); 7968 } 7969 }; 7970 7971 _proto.onResize = function onResize(element) { 7972 // element.muuri.refreshSortData(); 7973 // element.muuri.sort('order'); 7974 element.muuri.sort(function (itemA, itemB) { 7975 var styleA = window.getComputedStyle(itemA._element); 7976 var styleB = window.getComputedStyle(itemB._element); 7977 return (styleA.order || itemA._id) - (styleB.order || itemB._id); 7978 }); 7979 }; 7980 7981 MuuriDirective.factory = function factory() { 7982 return new MuuriDirective(); 7983 }; 7984 7985 return MuuriDirective; 7986 }(); 7987 MuuriDirective.factory.$inject = []; 7988 7989 /* jshint esversion: 6 */ 7990 var NoBounceDirective = /*#__PURE__*/function () { 7991 function NoBounceDirective(DomService) { 7992 this.domService = DomService; 7993 this.restrict = 'A'; 7994 } 7995 7996 var _proto = NoBounceDirective.prototype; 7997 7998 _proto.link = function link(scope, element, attributes, controller) { 7999 var supportsPassiveOption = this.supportPassiveOption(); 8000 8001 var supportSmoothScroll = this.supportSmoothScroll(); 8002 8003 }; 8004 8005 _proto.supportPassiveOption = function supportPassiveOption() { 8006 var supportsPassiveOption = false;
8007 8008 try { 8009 var opts = Object.defineProperty({}, 'passive', { 8010 get: function get() { 8011 supportsPassiveOption = true; 8012 } 8013 }); 8014 window.addEventListener('test', null, opts); 8015 } catch (e) {} 8016 8017 return supportsPassiveOption; 8018 }; 8019 8020 _proto.supportSmoothScroll = function supportSmoothScroll() { 8021 // Enable by default if the browser supports -webkit-overflow-scrolling 8022 // Test this by setting the property with JavaScript on an node that exists in the DOM 8023 // Then, see if the property is reflected in the computed style 8024 var testDiv = document.createElement('div'); 8025 document.documentElement.appendChild(testDiv); 8026 testDiv.style.WebkitOverflowScrolling = 'touch'; 8027 var supportSmoothScroll = 'getComputedStyle' in window && window.getComputedStyle(testDiv)['-webkit-overflow-scrolling'] === 'touch'; 8028 document.documentElement.removeChild(testDiv); 8029 return supportSmoothScroll; 8030 }; 8031 8032 NoBounceDirective.factory = function factory(DomService) { 8033 return new NoBounceDirective(DomService); 8034 }; 8035 8036 return NoBounceDirective; 8037 }(); 8038 NoBounceDirective.factory.$inject = ['DomService']; 8039 8040 /* jshint esversion: 6 */ 8041 var NoHeroDirective = /*#__PURE__*/function () { 8042 function NoHeroDirective(DomService) { 8043 this.domService = DomService; 8044 this.restrict = 'A'; 8045 } 8046 8047 var _proto = NoHeroDirective.prototype; 8048 8049 _proto.link = function link(scope, element, attributes, controller) { 8050 var _this = this; 8051 8052 // console.log('NoHeroDirective'); 8053 setTimeout(function () { 8054 _this.init(scope, element, attributes, controller); 8055 }, 1); 8056 }; 8057 8058 _proto.init = function init(scope, element, attributes, controller) { 8059 scope.$root.$broadcast('onCoverEnd'); 8060 }; 8061 8062 NoHeroDirective.factory = function factory(DomService) { 8063 return new NoHeroDirective(DomService); 8064 }; 8065 8066 return NoHeroDirective; 8067 }(); 8068 NoHeroDirective.factory.$inject = ['DomService']; 8069 8070 function navSecondary() { 8071 return { 8072 restrict: 'C', 8073 link: function link(scope, element, attrs) { 8074 var links = element[0].querySelectorAll('a'); 8075 links.forEach(function (link) { 8076 link.addEventListener('click', function () { 8077 document.querySelector('html').classList.remove('droppin-in'); 8078 var header = document.querySelector('.section--header'); 8079 8080 if (header) { 8081 header.classList.remove('dropped'); 8082 } 8083 }); 8084 }); 8085 } 8086 }; 8087 } 8088 8089 /* jshint esversion: 6 */ 8090 8091 function tween$1(from, to, friction) { 8092 if (from === to || Math.abs(to - from) < 0.02) { 8093 return to; 8094 } 8095 8096 return from + (to - from) / friction; 8097 } 8098 8099 var mx = { 8100 x: 0, 8101 y: 0 8102 }; 8103 window.addEventListener('mousemove', function (e) { 8104 // const x = e.clientX / window.innerWidth * 2 - 1; 8105 // const y = e.clientY / window.innerHeight * 2 - 1; 8106 mx.x = e.clientX; 8107 mx.y = e.clientY; 8108 }); 8109 var i = 0; 8110 8111 var ParallaxOuterDirective = /*#__PURE__*/function () { 8112 function ParallaxOuterDirective(DomService) { 8113 this.domService = DomService; 8114 this.restrict = 'A'; 8115 } 8116 8117 var _proto = ParallaxOuterDirective.prototype; 8118 8119 _proto.link = function link(scope, element, attributes, controller) { 8120 8121 return; 8122 }; 8123 8124 _proto.init = function init(scope, element, attributes, controller) { 8125 var _this2 = this; 8126 8127 var node = element[0]; 8128 node.top = 0; 8129 node.rx = 0; 8130 node.ry = 0; // const childNode = node.querySelector('img, video'); 8131 // if (childNode) { 8132 8133 var style = window.getComputedStyle(node); 8134 var position = style.position; 8135 var parallax = (parseInt(attributes.parallaxOuter) || 5) * 2; 8136 var subscription = this.parallax$(node, parallax, i).subscribe(function (top) { 8137 /* 8138 node.top = tween(node.top, top, 10); 8139 if (node.top !== top) { 8140 node.setAttribute('style', `transform: translateY(${node.top}%);`); 8141 } 8142 */ 8143 _this2.parallaxAndSkew(node, node.rect, top); 8144 }); 8145 scope.$on('$destroy', function () { 8146 subscription.unsubscribe(); 8147 }); // } 8148 8149 i++; 8150 }; 8151 8152 _proto.parallaxAndSkew = function parallaxAndSkew(node, rect, top) { 8153 node.rect = rect; 8154 var angle = 300 / rect.width; 8155 var maxAngle = 300 / rect.width; 8156 var dx = mx.x - rect.center.x; 8157 var dy = mx.y - rect.center.y; 8158 var ex, ey; 8159 8160 if (Math.abs(dx) < rect.width * 0.6 && Math.abs(dy) < rect.height * 0.6) { 8161 ey = Math.min(maxAngle, Math.max(-maxAngle, angle * 2 * dx / re
8161ct.width)); 8162 ex = Math.min(maxAngle, Math.max(-maxAngle, -angle * dy / rect.height)); 8163 } else { 8164 ey = 0; 8165 ex = 0; 8166 } 8167 8168 node.top = tween$1(node.top, top, 10); 8169 node.rx = tween$1(node.rx, ex, 20); 8170 node.ry = tween$1(node.ry, ey, 20); 8171 8172 if (node.top !== top || node.rx !== ex || node.ry !== ey) { 8173 // console.log(node.top, top, node.rx, ex, node.ry, ey); 8174 node.setAttribute('style', "transform: translateY(" + node.top + "%) rotateX(" + node.rx + "deg) rotateY(" + node.ry + "deg);"); 8175 } 8176 }; 8177 8178 _proto.units = function units(value, decimals) { 8179 if (decimals === void 0) { 8180 decimals = 4; 8181 } 8182 8183 var pow = Math.pow(10, decimals) / 10; 8184 return Math.round(value * pow) / pow; 8185 }; 8186 8187 _proto.parallax$ = function parallax$(node, parallax, i) { 8188 var _this3 = this; 8189 8190 return this.domService.rafAndRect$().pipe(map(function (datas) { 8191 var windowRect = datas[1]; 8192 var rect = Rect.fromNode(node); 8193 8194 _this3.parallaxAndSkew(node, rect, 0); 8195 8196 return null; 8197 }), filter(function (y) { 8198 return y !== null && _this3.domService.ready; 8199 }), distinctUntilChanged(), map(function (y) { 8200 return 0; 8201 })); 8202 }; 8203 8204 _proto.parallax$___ = function parallax$___(node, parallax, i) { 8205 var _this4 = this; 8206 8207 return this.domService.rafAndRect$().pipe(map(function (datas) { 8208 var windowRect = datas[1]; 8209 var rect = Rect.fromNode(node); 8210 8211 _this4.parallaxAndSkew(node, rect, node.top); 8212 8213 var intersection = rect.intersection(windowRect); 8214 8215 if (intersection.y > 0) { 8216 return Math.min(1, Math.max(-1, intersection.center.y)); // intersection.center.y; 8217 } else { 8218 return null; 8219 } 8220 }), filter(function (y) { 8221 return y !== null && _this4.domService.ready; 8222 }), distinctUntilChanged(), map(function (y) { 8223 var direction = i % 2 === 0 ? 1 : -1; 8224 var p = y * parallax * direction; 8225 return _this4.units(p); 8226 })); 8227 }; 8228 8229 ParallaxOuterDirective.factory = function factory(DomService) { 8230 return new ParallaxOuterDirective(DomService); 8231 }; 8232 8233 return ParallaxOuterDirective; 8234 }(); 8235 ParallaxOuterDirective.factory.$inject = ['DomService']; 8236 8237 /* jshint esversion: 6 */ 8238 8239 var ParallaxDirective = /*#__PURE__*/function () { 8240 function ParallaxDirective(DomService) { 8241 this.domService = DomService; 8242 this.restrict = 'A'; 8243 } 8244 8245 var _proto = ParallaxDirective.prototype; 8246 8247 _proto.link = function link(scope, element, attributes, controller) { 8248 var node = element[0]; 8249 var childNode = node.querySelector('img, video'); 8250 8251 if (childNode) { 8252 var style = window.getComputedStyle(node); 8253 var position = style.position; 8254 var parallax = (parseInt(attributes.parallax) || 5) * 2; 8255 var subscription = this.parallax$(node, parallax).subscribe(function (parallax) { 8256 if (position === 'absolute') { 8257 childNode.setAttribute('style', "top: 50%; left: 50%; transform: translateX(-50%) translateY(" + parallax.p + "%) scale(" + parallax.s + ", " + parallax.s + ");"); 8258 } else { 8259 childNode.setAttribute('style', "transform: translateX(0) translateY(" + (parallax.p + 50) + "%) scale(" + parallax.s + ", " + parallax.s + ");"); 8260 } 8261 }); 8262 scope.$on('$destroy', function () { 8263 subscription.unsubscribe(); 8264 }); 8265 } 8266 }; 8267 8268 _proto.units = function units(value, decimals) { 8269 if (decimals === void 0) { 8270 decimals = 4; 8271 } 8272 8273 var pow = Math.pow(10, decimals) / 10; 8274 return Math.round(value * pow) / pow; 8275 }; 8276 8277 _proto.parallax$ = function parallax$(node, parallax) { 8278 var _this = this; 8279 8280 return this.domService.rafAndRect$().pipe(map(function (datas) { 8281 var windowRect = datas[1]; 8282 var rect = Rect.fromNode(node); 8283 var intersection = rect.intersection(windowRect); 8284 8285 if (intersection.y > 0) { 8286 return Math.min(1, Math.max(-1, intersection.center.y)); // intersection.center.y; 8287 } else { 8288 return null; 8289 } 8290 }), filter(function (y) { 8291 return y !== null; 8292 }), distinctUntilChanged(), map(function (y) { 8293 var direction = 1; // i % 2 === 0 ? 1 : -1; 8294 8295 var s = (100 + parallax * 2) / 100; 8296 var p = -50 + y * parallax * direction; // .toFixed(3); 8297 // const y = Math.min(1, Math.max(-1, intersection.center.y)); 8298 // const s = (100 + parallax * 2) / 100; 8299 // const p = (-50 + (y * parallax * direction)); // .toFixed(3); 8300 8301 return { 8302 s: _this.units(s), 8303 p: _this.units(p) 8304 }; 8305 })); 8306 }; 8307 8308 ParallaxDirective.factory = function factory(DomService) { 8309 return new ParallaxDirective(DomService); 8310 }; 8311 8312 return ParallaxDirective; 8313 }(); 8314 ParallaxDirective.factory.$inject = ['DomService']; 8315 8316 /* jshint esversion: 6 */ 8317 var ScrollDirective = /*#__PURE__*/function () { 8318 // @Output() public scroll = new EventEmitter(); 8319 function ScrollDirective(DomService) { 8320 this.domService = DomService; // this.require = 'ngModel'; 8321 8322 this.restrict = 'A'; 8323 } 8324 8325 var _proto = ScrollDirective.prototype; 8326 8327 _proto.link = function link(scope, element, attributes, controller) { 8328 if (attributes.scroll !== undefined) { 8329 var node = element[0]; 8330 var subscription = this.domService.scrollIntersection$(node).subscribe(function (event) { 8331 scope.$eval(attributes.scroll, { 8332 $event: event 8333 }); 8334 }); 8335 scope.$on('$destroy', function () { 8336 subscription.unsubscribe(); 8337 }); 8338 } 8339 /* 8340 const callback = scope.$eval(attributes.scroll); 8341 if (typeof callback === 'function') { 8342 const subscription = this.domService.scroll$().subscribe(event => callback(event)); 8343 scope.$on('$destroy', () => { 8344 subscription.unsubscribe(); 8345 });
8346 } 8347 */ 8348 8349 }; 8350 8351 ScrollDirective.factory = function factory(DomService) { 8352 return new ScrollDirective(DomService); 8353 }; 8354 8355 return ScrollDirective; 8356 }(); 8357 ScrollDirective.factory.$inject = ['DomService']; 8358 8359 /* jshint esversion: 6 */ 8360 var DragListener = /*#__PURE__*/function () { 8361 function DragListener(currentTarget, downCallback, moveCallback, upCallback) { 8362 this.currentTarget = currentTarget || document; 8363 8364 this.downCallback = downCallback || function (e) { 8365 console.log('DragListener.downCallback not setted', e); 8366 }; 8367 8368 this.moveCallback = moveCallback || function (e) { 8369 console.log('DragListener.moveCallback not setted', e); 8370 }; 8371 8372 this.upCallback = upCallback || function (e) { 8373 console.log('DragListener.upCallback not setted', e); 8374 }; 8375 8376 this.dragging = false; 8377 this.onMouseDown = this.onMouseDown.bind(this); 8378 this.onMouseMove = this.onMouseMove.bind(this); 8379 this.onMouseUp = this.onMouseUp.bind(this); 8380 this.onTouchStart = this.onTouchStart.bind(this); 8381 this.onTouchMove = this.onTouchMove.bind(this); 8382 this.onTouchEnd = this.onTouchEnd.bind(this); 8383 this.addListeners(); 8384 } 8385 8386 var _proto = DragListener.prototype; 8387 8388 _proto.addListeners = function addListeners() { 8389 this.currentTarget.addEventListener('touchstart', this.onTouchStart, this.options); 8390 this.currentTarget.addEventListener('mousedown', this.onMouseDown, this.options); 8391 }; 8392 8393 _proto.destroy = function destroy() { 8394 this.currentTarget.removeEventListener('touchstart', this.onTouchStart); 8395 this.currentTarget.removeEventListener('mousedown', this.onMouseDown); 8396 this.removeMouseListeners(); 8397 this.removeTouchListeners(); 8398 }; 8399 8400 _proto.onDown = function onDown(down) { 8401 this.down = down; 8402 this.strength = { 8403 x: 0, 8404 y: 0 8405 }; 8406 this.distance = this.distance || { 8407 x: 0, 8408 y: 0 8409 }; 8410 this.speed = { 8411 x: 0, 8412 y: 0 8413 }; 8414 this.downCallback(this); 8415 }; 8416 8417 _proto.onDrag = function onDrag(position) { 8418 this.dragging = position && this.down !== undefined; 8419 8420 if (this.dragging) { 8421 var currentTarget = this.currentTarget; 8422 var distance = { 8423 x: position.x - this.down.x, 8424 y: position.y - this.down.y 8425 }; 8426 var strength = { 8427 x: distance.x / window.innerWidth * 2, 8428 y: distance.y / window.innerHeight * 2 8429 }; 8430 var speed = { 8431 x: this.speed.x + (strength.x - this.strength.x) * 0.1, 8432 y: this.speed.y + (strength.y - this.strength.y) * 1 8433 }; 8434 this.position = position; 8435 this.distance = distance; 8436 this.strength = strength; 8437 this.speed = speed; 8438 this.moveCallback({ 8439 position: position, 8440 distance: distance, 8441 strength: strength, 8442 speed: speed, 8443 currentTarget: currentTarget 8444 }); 8445 } 8446 }; 8447 8448 _proto.onUp = function onUp() { 8449 this.down = undefined; 8450 this.dragging = false; 8451 this.upCallback(this); 8452 }; 8453 8454 _proto.onMouseDown = function onMouseDown(e) { 8455 this.originalEvent = e; 8456 this.target = e.target; 8457 this.currentTarget.removeEventListener('touchstart', this.onTouchStart); 8458 this.onDown({ 8459 x: e.clientX, 8460 y: e.clientY 8461 }); 8462 this.addMouseListeners(); 8463 }; 8464 8465 _proto.onMouseMove = function onMouseMove(e) { 8466 this.originalEvent = e; 8467 this.target = e.target; 8468 this.onDrag({ 8469 x: e.clientX, 8470 y: e.clientY 8471 }); 8472 }; 8473 8474 _proto.onMouseUp = function onMouseUp(e) { 8475 this.originalEvent = e; 8476 this.target = e.target; 8477 this.removeMouseListeners(); 8478 /* 8479 this.onDrag({ 8480 x: e.clientX, 8481 y: e.clientY 8482 }); 8483 */ 8484 8485 this.onUp(); 8486 }; 8487 8488 _proto.onTouchStart = function onTouchStart(e) { 8489 this.originalEvent = e; 8490 this.target = e.target; 8491 this.currentTarget.removeEventListener('mousedown', this.onMouseDown); 8492 8493 if (e.touches.length > 0) { 8494 // e.preventDefault(); 8495 this.onDown({ 8496 x: e.touches[0].pageX, 8497 y: e.touches[0].pageY 8498 }); 8499 this.addTouchListeners(); 8500 } 8501 }; 8502 8503 _proto.onTouchMove = function onTouchMove(e) { 8504 this.originalEvent = e; 8505 this.target = e.target; 8506 8507 if (e.touches.length > 0) { 8508 // e.preventDefault(); 8509 this.onDrag({ 8510 x: e.touches[0].pageX, 8511 y: e.touches[0].pageY 8512 }); 8513 } 8514 }; 8515 8516 _proto.onTouchEnd = function onTouchEnd(e) { 8517 this.originalEvent = e; 8518 this.target = e.target; 8519 this.removeTouchListeners(); 8520 this.onDrag(this.position); 8521 this.onUp(); 8522 }; 8523 8524 _proto.addMouseListeners = function addMouseListeners() { 8525 document.addEventListener('mousemove', this.onMouseMove, this.options); 8526 document.addEventListener('mouseup', this.onMouseUp, this.options); 8527 }; 8528 8529 _proto.addTouchListeners = function addTouchListeners() { 8530 document.addEventListener('touchend', this.onTouchEnd, this.options); 8531 document.addEventListener('touchmove', this.onTouchMove, this.options); 8532 }; 8533 8534 _proto.removeMouseListeners = function removeMouseListeners() { 8535 document.removeEventListener('mousemove', this.onMouseMove); 8536 document.removeEventListener('mouseup', this.onMouseUp); 8537 }; 8538 8539 _proto.removeTouchListeners = function removeTouchListeners() { 8540 document.removeEventListener('touchend', this.onTouchEnd); 8541 document.removeEventListener('touchmove', this.onTouchMove); 8542 }; 8543 8544 _createClass(DragListener, [{ 8545 key: "passive", 8546 get: function get() { 8547 var _this = this; 8548 8549 if (this.passive_ !== undefined) { 8550 return this.passive_; 8551 } else { 8552 this.passive_ = false;
8553 8554 try { 8555 var options = Object.defineProperty({}, 'passive', { 8556 get: function get() { 8557 _this.passive_ = !0; 8558 } 8559 }); 8560 window.addEventListener('test', null, options); 8561 } catch (err) {} 8562 8563 return this.passive_; 8564 } 8565 } 8566 }, { 8567 key: "options", 8568 get: function get() { 8569 if (this.passive) { 8570 return { 8571 passive: false, 8572 capture: true 8573 }; 8574 } else { 8575 return false; 8576 } 8577 } 8578 }]); 8579 8580 return DragListener; 8581 }(); 8582 8583 /* jshint esversion: 6 */ 8584 8585 var ScrollableDirective = /*#__PURE__*/function () { 8586 function ScrollableDirective(DomService) { 8587 this.domService = DomService; 8588 this.restrict = 'A'; 8589 } 8590 8591 var _proto = ScrollableDirective.prototype; 8592 8593 _proto.link = function link(scope, element, attributes, controller) { 8594 var node = element[0]; 8595 var scrollable = attributes.scrollable !== undefined ? node.querySelector(attributes.scrollable) : null; 8596 var scrollableInner = attributes.scrollableInner !== undefined ? node.querySelector(attributes.scrollableInner) : null; 8597 var scrollableTrack = attributes.scrollableTrack !== undefined ? node.querySelector(attributes.scrollableTrack) : null; 8598 var scrollableThumb = attributes.scrollableThumb !== undefined ? node.querySelector(attributes.scrollableThumb) : null; 8599 8600 if (scrollable && scrollableInner && scrollableTrack && scrollableThumb) { 8601 var subscription = this.scrollable$(node, scrollable, scrollableInner, scrollableTrack, scrollableThumb).subscribe(function () {}); 8602 scope.$on('destroy', function () { 8603 // draglistener.destroy(); 8604 subscription.unsubscribe(); 8605 }); 8606 } 8607 }; 8608 8609 _proto.scrollable$ = function scrollable$(node, scrollable, scrollableInner, scrollableTrack, scrollableThumb, friction) { 8610 var _this = this; 8611 8612 if (friction === void 0) { 8613 friction = 1; 8614 } 8615 8616 // const pow$ = new BehaviorSubject(0); 8617 var computedStyle = window.getComputedStyle(scrollableThumb); 8618 var pow = 0, 8619 down, 8620 move = 0, 8621 x = 0, 8622 target, 8623 offset = parseInt(computedStyle.left); 8624 8625 var onMove = function onMove($move) { 8626 var width = scrollableTrack.offsetWidth - offset * 2; 8627 move = Math.max(0, Math.min(width, $move)); 8628 TweenMax.set(scrollableThumb, { 8629 x: move 8630 }); 8631 pow = move / width; // pow$.next(pow); 8632 }; 8633 8634 var onSnap = function onSnap(swipe) { 8635 /* 8636 const firstChild = scrollableInner.firstElementChild; 8637 const itemOuterWidth = this.domService.getOuterWidth(firstChild); 8638 const itemWidth = firstChild.offsetWidth; 8639 const gutter = itemOuterWidth - itemWidth; 8640 const newx = Math.round(-x / (itemWidth + gutter)) * (itemWidth + gutter); 8641 */ 8642 var children = Array.prototype.slice.call(scrollableInner.children); 8643 var newx = children.reduce(function (p, c, i) { 8644 var prevLeft = x * -1; 8645 var currLeft = c.offsetLeft; 8646 var newDist = Math.abs(currLeft - prevLeft); 8647 var prevDist = Math.abs(p - prevLeft); 8648 8649 if (newDist < prevDist) { 8650 return currLeft; 8651 } else { 8652 return p; 8653 } 8654 }, Number.POSITIVE_INFINITY); 8655 8656 if (newx !== Number.POSITIVE_INFINITY) { 8657 var outerWidth = _this.domService.getOuterWidth(scrollable); 8658 8659 var innerWidth = scrollableInner.lastElementChild.offsetLeft + _this.domService.getOuterWidth(scrollableInner.lastElementChild); 8660 8661 var ePow = newx / (innerWidth - outerWidth); 8662 ePow = Math.max(0, Math.min(1, ePow)); 8663 var item = { 8664 pow: pow 8665 }; 8666 var width = scrollableTrack.offsetWidth - offset * 2; 8667 TweenMax.to(item, 0.5, { 8668 pow: ePow, 8669 onUpdate: function onUpdate() { 8670 pow = item.pow; 8671 var width = scrollableTrack.offsetWidth - offset * 2; 8672 move = pow * width; 8673 TweenMax.set(scrollableThumb, { 8674 x: width * pow 8675 }); 8676 }, 8677 ease: Power2.easeInOut 8678 }); 8679 } // pow$.next(pow); 8680 8681 }; 8682 8683 var draglistener = new DragListener(node, function (e) { 8684 // console.log('down', e); 8685 target = e.target; 8686 down = move; 8687 /* 8688 e.originalEvent.preventDefault(); 8689 e.originalEvent.stopPropagation(); 8690 e.originalEvent.stopImmediatePropagation(); 8691 */ 8692 }, function (e) { 8693 // console.log('move', e); 8694 var distance = e.distance.x; // console.log(target === scrollableThumb); 8695 8696 if (target !== scrollableThumb) { 8697 var width = scrollableTrack.offsetWidth - offset * 2; 8698 distance = -distance / scrollable.offsetWidth * width; 8699 8700 if (window.innerWidth < 1024) { 8701 distance /= scrollableInner.children.length; 8702 } 8703 8704 onMove(down + distance); 8705 } else { 8706 onMove(down + distance); 8707 } 8708 }, function (e) { 8709 // console.log('up', e.originalEvent); 8710 setTimeout(onSnap, 300); 8711 /* 8712 e.originalEvent.preventDefault(); 8713 e.originalEvent.stopPropagation(); 8714 e.originalEvent.stopImmediatePropagation(); 8715 */ 8716 }); 8717 /* 8718 node.addEventListener('mousewheel', (e) => { 8719 const direction = e.deltaY / Math.abs(e.deltaY); 8720 if (direction < 0 && pow > 0 || direction > 0 && pow < 1) { 8721 e.stopPropagation(); 8722 e.preventDefault(); 8723 onMove(move + direction * 100); 8724 } 8725 }, this.domService.hasPassiveEvents ? { passive: false } : false); 8726 */ 8727 8728 return this.domService.raf$().pipe(map(function () { 8729 var outerWidth = _this.domService.getOuterWidth(scrollable); 8730 8731 var innerWidth = scrollableInner.lastElementChild.offsetLeft + _this.domService.getOuterWidth(scrollableInner.lastElementChild); 8732 8733 var endx = (outerWidth - innerWidth) * pow; 8734 var newx = x + (endx - x) / friction; 8735 newx = Math.round(newx * 1000) / 1000; 8736 8737 if (x !== newx) { 8738 x = newx; // TweenMax.set(scrollableInner, { x: x }); 8739
8740 scrollableInner.style.transform = "translateX(" + x + "px)"; 8741 return x; 8742 } else { 8743 return null; 8744 } 8745 }), filter(function (x) { 8746 return x !== null; 8747 }), distinctUntilChanged(function (a, b) { 8748 return Math.round(a * 100) === Math.round(b * 100); 8749 }), shareReplay()); 8750 }; 8751 8752 ScrollableDirective.factory = function factory(DomService) { 8753 return new ScrollableDirective(DomService); 8754 }; 8755 8756 return ScrollableDirective; 8757 }(); 8758 ScrollableDirective.factory.$inject = ['DomService']; 8759 8760 /* jshint esversion: 6 */ 8761 8762 var ShareDirective = /*#__PURE__*/function () { 8763 function ShareDirective($timeout) { 8764 this.$timeout = $timeout; 8765 this.restrict = 'A'; 8766 8767 this.template = function (element, attributes) { 8768 var template = "\n\t\t\t<div role=\"button\" tabindex=\"0\" class=\"btn btn--facebook\" ng-click=\"onFacebook()\" ng-keydown=\"onKeyDown($event, 'facebook')\">\n\t\t\t\t<svg class=\"icon icon--facebook\"><use xlink:href=\"#icon--facebook\"></use></svg>\n\t\t\t</div>\n\t\t\t<div role=\"button\" tabindex=\"0\" class=\"btn btn--linkedin\" ng-click=\"onLinkedin()\" ng-keydown=\"onKeyDown($event, 'linkedin')\">\n\t\t\t\t<svg class=\"icon icon--linkedin\"><use xlink:href=\"#icon--linkedin\"></use></svg>\n\t\t\t</div>\n\t\t\t<div role=\"button\" tabindex=\"0\" class=\"btn btn--pinterest\" ng-click=\"onPinterest()\" ng-keydown=\"onKeyDown($event, 'pinterest')\">\n\t\t\t\t<svg class=\"icon icon--pinterest\"><use xlink:href=\"#icon--pinterest\"></use></svg>\n\t\t\t</div>"; 8769 8770 if (attributes.shareToggle !== undefined) { 8771 template += "\n\t\t\t\t<div role=\"button\" tabindex=\"0\" class=\"btn btn--remove\" ng-click=\"onRemove()\" ng-keydown=\"onKeyDown($event, 'remove')\">\n\t\t\t\t\t<svg class=\"icon icon--remove\"><use xlink:href=\"#icon--remove\"></use></svg>\n\t\t\t\t</div>"; 8772 } 8773 8774 return template; 8775 }; 8776 8777 this.scope = { 8778 item: '=?share' 8779 }; 8780 } 8781 8782 var _proto = ShareDirective.prototype; 8783 8784 _proto.link = function link(scope, element, attributes, controller) { 8785 scope.item = scope.item || {}; 8786 var node = element[0]; 8787 var img = node.querySelector('img'); 8788 var pageSrc = scope.item.src; 8789 var nomecontenuto = scope.item.nomecontenuto + ''; 8790 var label = scope.item.label; 8791 var position = scope.item.position; 8792 var eventname = scope.item.eventname; 8793 var pageTitle = scope.item.title || document.title; 8794 8795 if (img) { 8796 pageSrc = img.src; 8797 pageTitle = img.title || pageTitle; 8798 } 8799 8800 var pageUrl = scope.item.url || window.location.href + "?imageId=" + scope.item.id; 8801 8802 scope.onFacebook = function (event) { 8803 var obj = Object.assign({}, window.objDataLayerInfo); 8804 obj["eventname"] = eventname; 8805 obj["position"] = position != null ? position : "share_facebook"; 8806 obj["label"] = label != null ? label : "facebook"; 8807 obj["nomecontenuto"] = nomecontenuto; 8808 GtmService.push(obj); //console.log('ShareDirective.onFacebook', event); 8809 8810 var url = "https://www.facebook.com/sharer/sharer.php?u=" + encodeURIComponent(pageUrl); 8811 window.open(url, 'facebookShareWindow', "height=450, width=550, top=" + (window.innerHeight / 2 - 275) + ", left=" + (window.innerWidth / 2 - 225) + ", toolbar=0, location=0, menubar=0, directories=0, scrollbars=0"); // event.preventDefault(); 8812 }; 8813 8814 scope.onLinkedin = function (event) { 8815 var obj = Object.assign({}, window.objDataLayerInfo); 8816 obj["eventname"] = eventname; 8817 obj["position"] = position != null ? position : "share_linkedin"; 8818 obj["label"] = label != null ? label : "linkedin"; 8819 obj["nomecontenuto"] = nomecontenuto; 8820 GtmService.push(obj); //console.log('ShareDirective.onLinkedin', event); 8821 8822 var url = "http://www.linkedin.com/shareArticle?mini=true&url=" + encodeURIComponent(pageUrl) + "&via=LeaCeramiche&text=" + encodeURIComponent(pageTitle); 8823 window.open(url, 'linkedinShareWindow', "height=450, width=550, top=" + (window.innerHeight / 2 - 275) + ", left=" + (window.innerWidth / 2 - 225) + ", toolbar=0, location=0, menubar=0, directories=0, scrollbars=0"); // event.preventDefault(); 8824 }; 8825 8826 scope.onTwitter = function (event) { 8827 // console.log('ShareDirective.onTwitter', event); 8828 var obj = Object.assign({}, window.objDataLayerInfo); 8829 obj["eventname"] = eventname; 8830 obj["position"] = position != null ? position : "share_twitter"; 8831 obj["label"] = label != null ? label : "twitter"; 8832 obj["nomecontenuto"] = nomecontenuto; 8833 GtmService.push(obj); 8834 var url = "https://twitter.com/intent/tweet?url=" + encodeURIComponent(pageUrl) + "&via=LeaCeramiche&text=" + encodeURIComponent(pageTitle); 8835 window.open(url, 'twitterShareWindow', "height=450, width=550, top=" + (window.innerHeight / 2 - 275) + ", left=" + (window.innerWidth / 2 - 225) + ", toolbar=0, location=0, menubar=0, directories=0, scrollbars=0"); // event.preventDefault(); 8836 }; 8837 8838 scope.onPinterest = function () { 8839 var pin = { 8840 url: pageUrl, 8841 media: pageSrc, 8842 description: pageTitle 8843 }; 8844 var obj = Object.assign({}, window.objDataLayerInfo); 8845 obj["eventname"] = eventname; 8846 obj["position"] = position != null ? position : "share_pinterest"; 8847 obj["label"] = label != null ? label : "pinterest"; 8848 obj["nomecontenuto"] = nomecontenuto; 8849 GtmService.push(obj); // console.log('ShareDirective.onPin', pin); 8850 8851 PinUtils.pinOne(pin); 8852 }; 8853 8854 scope.onRemove = function () {
8855 // Chiude il pannello di share 8856 scope.$parent.root.share = false; 8857 }; 8858 8859 scope.onKeyDown = function (event, action) { 8860 if (event.key === 'Enter') { 8861 event.preventDefault(); 8862 event.stopPropagation(); 8863 8864 switch (action) { 8865 case 'facebook': 8866 scope.onFacebook(event); 8867 break; 8868 8869 case 'linkedin': 8870 scope.onLinkedin(event); 8871 break; 8872 8873 case 'pinterest': 8874 scope.onPinterest(event); 8875 break; 8876 8877 case 'remove': 8878 scope.onRemove(); 8879 break; 8880 } 8881 } 8882 }; 8883 8884 scope.$on('$destroy', function () {}); 8885 }; 8886 8887 ShareDirective.factory = function factory($timeout) { 8888 return new ShareDirective($timeout); 8889 }; 8890 8891 return ShareDirective; 8892 }(); 8893 ShareDirective.factory.$inject = ['$timeout']; 8894 8895 /* jshint esversion: 6 */ 8896 8897 var SliderDirective = /*#__PURE__*/function () { 8898 function SliderDirective(DomService) { 8899 this.domService = DomService; 8900 this.restrict = 'A'; 8901 } 8902 8903 var _proto = SliderDirective.prototype; 8904 8905 _proto.link = function link(scope, element, attributes, controller) { 8906 var _this = this; 8907 8908 var node = element[0]; 8909 var slider = attributes.slider !== undefined ? node.querySelector(attributes.slider) : null; 8910 var sliderInner = attributes.sliderInner !== undefined ? node.querySelector(attributes.sliderInner) : null; 8911 var sliderLeft = attributes.sliderLeft !== undefined ? node.querySelector(attributes.sliderLeft) : null; 8912 var sliderRight = attributes.sliderRight !== undefined ? node.querySelector(attributes.sliderRight) : null; 8913 var sliderBullets = attributes.sliderBullets !== undefined ? node.querySelector(attributes.sliderBullets) : null; 8914 var index = 0, 8915 slides = 1, 8916 outerWidth = 1, 8917 innerWidth = 1, 8918 itemWidth = 1, 8919 itemOuterWidth = 1, 8920 gutter = 0, 8921 x_ = 0; 8922 8923 var toggleStates = function toggleStates() { 8924 var first = index === 0; 8925 var last = index === slides - 1; 8926 8927 if (first) { 8928 sliderLeft.classList.add('disabled'); 8929 } else { 8930 sliderLeft.classList.remove('disabled'); 8931 } 8932 8933 if (last) { 8934 sliderRight.classList.add('disabled'); 8935 } else { 8936 sliderRight.classList.remove('disabled'); 8937 } 8938 8939 if (sliderBullets) { 8940 Array.from(sliderBullets.children).forEach(function (x, i) { 8941 if (i === index) { 8942 x.classList.add('active'); 8943 } else { 8944 x.classList.remove('active'); 8945 } 8946 }); 8947 } 8948 }; 8949 8950 var slideToIndex = function slideToIndex(index) { 8951 var x = -(outerWidth + gutter) * index; 8952 8953 if (x_ !== x) { 8954 var distance = Math.abs(x_ - x); 8955 var time = Math.min(1.4, distance / (outerWidth + gutter) * 0.7); 8956 x_ = x; // console.log(outerWidth, innerWidth, slides, index); 8957 8958 TweenMax.to(sliderInner, time, { 8959 x: x, 8960 ease: Power2.easeInOut, 8961 onComplete: function onComplete() { 8962 toggleStates(); 8963 } 8964 }); 8965 } else { 8966 toggleStates(); 8967 } 8968 }; 8969 8970 var onResize = function onResize(event) { 8971 var firstChild = sliderInner.firstElementChild; 8972 itemOuterWidth = _this.domService.getOuterWidth(firstChild); // this.domService.getOuterWidth(sliderInner.lastElementChild); 8973 8974 itemWidth = firstChild.offsetWidth; 8975 gutter = itemOuterWidth - itemWidth; 8976 innerWidth = sliderInner.lastElementChild.offsetLeft + itemWidth; 8977 outerWidth = _this.domService.getOuterWidth(slider); 8978 slides = Math.ceil(innerWidth / (outerWidth + gutter)); 8979 index = Math.max(0, Math.min(slides - 1, index)); // console.log('itemWidth', itemWidth, itemOuterWidth); 8980 8981 if (sliderBullets) { 8982 while (sliderBullets.childElementCount > slides) { 8983 sliderBullets.removeChild(sliderBullets.firstElementChild); 8984 } 8985 8986 while (sliderBullets.childElementCount < slides) { 8987 var div = document.createElement('div'); 8988 sliderBullets.appendChild(div); 8989 } 8990 } 8991 8992 slideToIndex(index); 8993 }; 8994 8995 var onLeft = function onLeft(event) { 8996 index = Math.max(0, index - 1); 8997 slideToIndex(index); 8998 }; 8999 9000 var onRight = function onRight(event) { 9001 index = Math.min(slides - 1, index + 1); 9002 slideToIndex(index); 9003 }; 9004 9005 var onBullet = function onBullet(event) { 9006 index = Array.from(sliderBullets.children).indexOf(event.target); 9007 slideToIndex(index); 9008 }; 9009 9010 var onSnap = function onSnap() { 9011 var children = Array.prototype.slice.call(sliderInner.children); 9012 var newIndex = children.reduce(function (p, c, i) { 9013 var x = x_ * -1; 9014 var prevLeft = children[index].offsetLeft; 9015 var currLeft = c.offsetLeft; 9016 var newDist = Math.abs(currLeft - x); 9017 var prevDist = Math.abs(prevLeft - x); 9018 9019 if (newDist < prevDist) { 9020 return i; 9021 } else { 9022 return p; 9023 } 9024 }, index); 9025 index = newIndex; 9026 slideToIndex(newIndex); 9027 }; 9028 9029 var down; 9030 var draglistener = new DragListener(node, function (e) { 9031 down = x_; 9032 }, function (e) { 9033 if (window.innerWidth < 1024 && down !== undefined && Math.abs(e.distance.x) > Math.abs(e.distance.y)) { 9034 var x = e.distance.x; 9035 x_ = down + x; 9036 TweenMax.set(sliderInner, { 9037 x: x_ 9038 }); 9039 } 9040 }, function (e) { 9041 down = undefined; 9042 9043 if (window.innerWidth < 1024) { 9044 onSnap(); 9045 } 9046 }); 9047 9048 var addListeners = function addListeners() { 9049 window.addEventListener('resize', onResize); 9050 sliderLeft.addEventListener('click', onLeft); 9051 sliderRight.addEventListener('click', onRight); 9052 9053 if (sliderBullets) { 9054 sliderBullets.addEventListener('click', onBullet); 9055 } 9056 }; 9057 9058 var removeListeners = function removeListeners() { 9059 window.removeEventListener('resize', onResize); 9060 sliderLeft.removeEventListener('click', onLeft); 9061 sliderRight.removeEventListener('click', onRight); 9062 9063 if (sliderBullets) { 9064 sliderBullets.removeEventListener('click', onBullet); 9065 } 9066 }; 9067 9068 if (slider && sliderInner && sliderLeft && sliderRight) { 9069 addListeners(); 9070 onResize(); 9071 /* 9072 const subscription = this.slider$(node, slider, sliderInner, sliderLeft, sliderRight).subscribe(() => { 9073 });
9074 */ 9075 9076 scope.$on('destroy', function () { 9077 removeListeners(); 9078 draglistener.destroy(); // subscription.unsubscribe(); 9079 }); 9080 } 9081 }; 9082 9083 _proto.slider$ = function slider$(node, slider, sliderInner, sliderLeft, sliderRight, friction) { 9084 var _this2 = this; 9085 9086 if (friction === void 0) { 9087 friction = 0; 9088 } 9089 9090 // const pow$ = new BehaviorSubject(0); 9091 var pow = 0, 9092 down, 9093 move = 0, 9094 x = 0, 9095 target, 9096 offset = parseInt(sliderRight.offsetLeft); 9097 9098 var onMove = function onMove($move) { 9099 console.log('onMove', $move); 9100 var width = sliderLeft.offsetWidth - offset * 2; 9101 move = Math.max(0, Math.min(width, $move)); 9102 TweenMax.set(sliderRight, { 9103 x: move 9104 }); 9105 pow = move / width; // pow$.next(pow); 9106 }; 9107 9108 var draglistener = new DragListener(node, function (e) { 9109 // console.log('down', e); 9110 target = e.target; 9111 down = move; 9112 }, function (e) { 9113 // console.log('move', e); 9114 var distance = e.distance.x; // console.log(target === sliderRight); 9115 9116 if (target !== sliderRight) { 9117 var width = sliderLeft.offsetWidth - offset * 2; 9118 distance = -distance / slider.offsetWidth * width; 9119 9120 if (window.innerWidth < 1024) { 9121 distance /= sliderInner.children.length; 9122 } 9123 } 9124 9125 onMove(down + distance); 9126 }, function (e) {// console.log('up', e.originalEvent); 9127 }); 9128 /* 9129 node.addEventListener('mousewheel', (e) => { 9130 const direction = e.deltaY / Math.abs(e.deltaY); 9131 if (direction < 0 && pow > 0 || direction > 0 && pow < 1) { 9132 e.stopPropagation(); 9133 e.preventDefault(); 9134 onMove(move + direction * 100); 9135 } 9136 }, this.domService.hasPassiveEvents ? { passive: false } : false); 9137 */ 9138 9139 return this.domService.raf$().pipe(map(function () { 9140 var outerWidth = _this2.domService.getOuterWidth(slider); 9141 9142 var innerWidth = sliderInner.lastElementChild.offsetLeft + _this2.domService.getOuterWidth(sliderInner.lastElementChild); 9143 9144 var endx = (outerWidth - innerWidth) * pow; 9145 var newx = x + (endx - x) / friction; 9146 newx = Math.round(newx * 1000) / 1000; 9147 9148 if (x !== newx) { 9149 x = newx; // TweenMax.set(sliderInner, { x: x }); 9150 9151 sliderInner.style.transform = "translateX(" + x + "px)"; 9152 return x; 9153 } else { 9154 return null; 9155 } 9156 }), filter(function (x) { 9157 return x !== null; 9158 }), shareReplay()); 9159 }; 9160 9161 SliderDirective.factory = function factory(DomService) { 9162 return new SliderDirective(DomService); 9163 }; 9164 9165 return SliderDirective; 9166 }(); 9167 SliderDirective.factory.$inject = ['DomService']; 9168 9169 /* jshint esversion: 6 */ 9170 9171 var SplitDirective = /*#__PURE__*/function () { 9172 function SplitDirective(IntersectionService) { 9173 this.intersectionService = IntersectionService; 9174 this.restrict = 'A'; 9175 } 9176 9177 var _proto = SplitDirective.prototype; 9178 9179 _proto.link = function link(scope, element, attributes, controller) { 9180 var _this = this; 9181 9182 var node = element[0]; 9183 node.setAttribute('data-title', node.innerHTML); 9184 var section = this.getSection(node); 9185 var index = [].slice.call(section.querySelectorAll('[title]')).indexOf(node); 9186 var subscription = this.intersectionService.intersection$(node).pipe(first()).subscribe(function (event) { 9187 var timeout = index * 100; 9188 setTimeout(function () { 9189 // node.classList.add('titled'); 9190 _this.animate(node); 9191 }, timeout); 9192 }); 9193 scope.$on('$destroy', function () { 9194 subscription.unsubscribe(); 9195 }); 9196 }; 9197 9198 _proto.animate = function animate(node) { 9199 var splitting = Splitting({ 9200 target: node, 9201 by: 'lines', 9202 key: null 9203 })[0]; // console.log('words', splitting.words); 9204 9205 var tweens = splitting.words.map(function (word) { 9206 var line = getComputedStyle(word).getPropertyValue('--line-index'); 9207 TweenMax.set(word, { 9208 x: -node.offsetWidth 9209 }); 9210 return TweenMax.to(word, 0.9, { 9211 x: 0, 9212 delay: 0.5 + 0.2 * line, 9213 ease: Power2.easeInOut 9214 }); 9215 }); 9216 }; 9217 9218 _proto.getSection = function getSection(node) { 9219 var section = node.parentNode; 9220 var p = node; 9221 9222 while (p) { 9223 p = p.parentNode; 9224 9225 if (p && p.classList && p.classList.contains('section')) { 9226 section = p; 9227 p = null; 9228 } 9229 } 9230 9231 return section; 9232 }; 9233 9234 SplitDirective.factory = function factory(IntersectionService) { 9235 return new SplitDirective(IntersectionService); 9236 }; 9237 9238 return SplitDirective; 9239 }(); 9240 SplitDirective.factory.$inject = ['IntersectionService']; 9241 9242 /* jshint esversion: 6 */ 9243 9244 var StickyDirective = /*#__PURE__*/function () { 9245 function StickyDirective($timeout, DomService) { 9246 this.$timeout = $timeout; 9247 this.domService = DomService; 9248 this.restrict = 'A'; 9249 } 9250 9251 var _proto = StickyDirective.prototype; 9252 9253 _proto.link = function link(scope, element, attributes, controller) { 9254 var _this = this; 9255 9256 this.$timeout(function () { 9257 var subscription = _this.scroll$(element, attributes).subscribe(); 9258 9259 scope.$on('$destroy', function () { 9260 subscription.unsubscribe(); 9261 }); 9262 }); 9263 }; 9264 9265 _proto.scroll$ = function scroll$(element, attributes) { 9266 var node = element[0]; 9267 var content = node.querySelector('[sticky-content]'); 9268 var stickyTop = parseInt(attributes.sticky) || 0; 9269 return this.domService.scroll$().pipe(tap(function (scroll) { 9270 var rect = Rect.fromNode(node); // const maxtop = node.offsetHeight - content.offsetHeight; 9271 // top = Math.max(0, Math.min(maxtop, top - rect.top)); 9272 9273 var maxTop = Math.max(0, stickyTop - rect.top); // content.setAttribute('style', `transform: translateY(${maxTop}px);`); 9274 9275 var sticky = maxTop > 0; 9276 9277 if (sticky !== element.sticky) {
9278 element.sticky = sticky; 9279 9280 if (sticky) { 9281 node.classList.add('sticky'); 9282 } else { 9283 node.classList.remove('sticky'); 9284 } 9285 } 9286 })); 9287 }; 9288 9289 _proto.scroll$_ = function scroll$_(element, attributes) { 9290 var node = element[0]; 9291 var content = node.querySelector('[sticky-content]'); 9292 var stickyTop = parseInt(attributes.sticky) || 0; 9293 return this.domService.raf$().pipe(tap(function (datas) { 9294 var rect = Rect.fromNode(node); // const maxtop = node.offsetHeight - content.offsetHeight; 9295 // top = Math.max(0, Math.min(maxtop, top - rect.top)); 9296 9297 var maxTop = Math.max(0, stickyTop - rect.top); 9298 content.setAttribute('style', "transform: translateY(" + maxTop + "px);"); 9299 var sticky = maxTop > 0; 9300 9301 if (sticky !== element.sticky) { 9302 element.sticky = sticky; 9303 9304 if (sticky) { 9305 node.classList.add('sticky'); 9306 } else { 9307 node.classList.remove('sticky'); 9308 } 9309 } 9310 })); 9311 }; 9312 9313 StickyDirective.factory = function factory($timeout, DomService) { 9314 return new StickyDirective($timeout, DomService); 9315 }; 9316 9317 return StickyDirective; 9318 }(); 9319 StickyDirective.factory.$inject = ['$timeout', 'DomService']; 9320 9321 /* jshint esversion: 6 */ 9322 var DEFAULT_SWIPER_OPTIONS = { 9323 //slidesPerView: 'auto', 9324 spaceBetween: 1, 9325 centeredSlides: true, 9326 loop: false, 9327 loopAdditionalSlides: 100, 9328 //speed: 600, 9329 //autoplay: { 9330 //delay: 8000, 9331 //}, 9332 keyboard: { 9333 enabled: true, 9334 onlyInViewport: true 9335 }, 9336 mousewheelControl: false, 9337 onSlideClick: function onSlideClick(swiper) { 9338 angular.element(swiper.clickedSlide).scope().clicked(angular.element(swiper.clickedSlide).scope().$index); 9339 }, 9340 pagination: { 9341 el: '.swiper-pagination', 9342 clickable: true 9343 }, 9344 a11y: { 9345 enabled: true, 9346 prevSlideMessage: 'Slide precedente', 9347 nextSlideMessage: 'Slide successiva', 9348 firstSlideMessage: 'Questa è la prima slide', 9349 lastSlideMessage: 'Questa è l\'ultima slide', 9350 paginationBulletMessage: 'Vai alla slide {{index}}' 9351 } 9352 }; 9353 var SwiperDirective = /*#__PURE__*/function () { 9354 function SwiperDirective() { 9355 this.restrict = 'A'; 9356 this.options = DEFAULT_SWIPER_OPTIONS; 9357 } 9358 9359 var _proto = SwiperDirective.prototype; 9360 9361 _proto.link = function link(scope, element, attributes, controller) { 9362 var _this = this; 9363 9364 scope.$on('lastItem', function (slide) { 9365 _this.onSwiper(element); 9366 }); 9367 scope.$on('$destroy', function () { 9368 if (element.swiper) { 9369 element.swiper.destroy(); // console.log('swiper.destroy'); 9370 } 9371 }); 9372 scope.$watch('$viewContentLoaded', function () { 9373 _this.onSwiper(element); 9374 }); 9375 scope.$on('onResize', function ($scope) { 9376 if (element.swiper) { 9377 element.swiper.update(); 9378 } 9379 }); 9380 }; 9381 9382 _proto.onSwiper = function onSwiper(element) { 9383 if (element.swiper) { 9384 element.swiper.update(); 9385 } else { 9386 element.swiper = new Swiper(element, this.options); 9387 element.addClass('swiper-init'); 9388 } 9389 }; 9390 9391 SwiperDirective.factory = function factory() { 9392 return new SwiperDirective(); 9393 }; 9394 9395 return SwiperDirective; 9396 }(); 9397 SwiperDirective.factory.$inject = []; 9398 var SwiperHeroDirective = /*#__PURE__*/function (_SwiperDirective) { 9399 _inheritsLoose(SwiperHeroDirective, _SwiperDirective); 9400 9401 function SwiperHeroDirective() { 9402 var _this2; 9403 9404 _this2 = _SwiperDirective.call(this) || this; 9405 _this2.options = { 9406 loop: false, 9407 spaceBetween: 0, 9408 keyboard: { 9409 enabled: true, 9410 onlyInViewport: true 9411 }, 9412 mousewheelControl: false, 9413 onSlideClick: function onSlideClick(swiper) { 9414 angular.element(swiper.clickedSlide).scope().clicked(angular.element(swiper.clickedSlide).scope().$index); 9415 }, 9416 on: { 9417 setTransition: function setTransition() {} 9418 }, 9419 pagination: { 9420 el: '.swiper-pagination', 9421 clickable: true 9422 }, 9423 a11y: { 9424 enabled: true, 9425 prevSlideMessage: 'Slide precedente', 9426 nextSlideMessage: 'Slide successiva', 9427 firstSlideMessage: 'Questa è la prima slide', 9428 lastSlideMessage: 'Questa è l\'ultima slide', 9429 paginationBulletMessage: 'Vai alla slide {{index}}' 9430 } 9431 }; 9432 return _this2; 9433 } 9434 9435 SwiperHeroDirective.factory = function factory() { 9436 return new SwiperHeroDirective(); 9437 }; 9438 9439 return SwiperHeroDirective; 9440 }(SwiperDirective); 9441 SwiperHeroDirective.factory.$inject = [];
9442 var SwiperNewsDirective = /*#__PURE__*/function (_SwiperDirective2) { 9443 _inheritsLoose(SwiperNewsDirective, _SwiperDirective2); 9444 9445 function SwiperNewsDirective() { 9446 var _this3; 9447 9448 _this3 = _SwiperDirective2.call(this) || this; 9449 _this3.options = { 9450 slidesPerView: 1, 9451 spaceBetween: 30, 9452 loop: false, 9453 keyboard: { 9454 enabled: true, 9455 onlyInViewport: true 9456 }, 9457 mousewheelControl: false, 9458 onSlideClick: function onSlideClick(swiper) { 9459 angular.element(swiper.clickedSlide).scope().clicked(angular.element(swiper.clickedSlide).scope().$index); 9460 }, 9461 on: { 9462 setTransition: function setTransition() {} 9463 }, 9464 pagination: { 9465 el: '.swiper-pagination-2', 9466 clickable: true 9467 }, 9468 a11y: { 9469 enabled: true, 9470 prevSlideMessage: 'Slide precedente', 9471 nextSlideMessage: 'Slide successiva', 9472 firstSlideMessage: 'Questa è la prima slide', 9473 lastSlideMessage: 'Questa è l\'ultima slide', 9474 paginationBulletMessage: 'Vai alla slide {{index}}' 9475 }, 9476 breakpoints: { 9477 640: { 9478 slidesPerView: 1, 9479 spaceBetween: 20 9480 }, 9481 768: { 9482 slidesPerView: 2, 9483 spaceBetween: 40 9484 }, 9485 1024: { 9486 slidesPerView: 3, 9487 spaceBetween: 50 9488 } 9489 } 9490 }; 9491 return _this3; 9492 } 9493 9494 SwiperNewsDirective.factory = function factory() { 9495 return new SwiperNewsDirective(); 9496 }; 9497 9498 return SwiperNewsDirective; 9499 }(SwiperDirective); 9500 var SwiperColorsDirective = /*#__PURE__*/function (_SwiperDirective3) { 9501 _inheritsLoose(SwiperColorsDirective, _SwiperDirective3); 9502 9503 function SwiperColorsDirective() { 9504 var _this4; 9505 9506 _this4 = _SwiperDirective3.call(this) || this; 9507 _this4.options = { 9508 slidesPerView: 1, 9509 spaceBetween: 30, 9510 centeredSlides: false, 9511 simulateTouch: true, 9512 allowTouchMove: true, 9513 pagination: { 9514 el: '.swiper-pagination', 9515 clickable: true 9516 }, 9517 a11y: { 9518 enabled: true, 9519 prevSlideMessage: 'Slide precedente', 9520 nextSlideMessage: 'Slide successiva', 9521 firstSlideMessage: 'Questa è la prima slide', 9522 lastSlideMessage: 'Questa è l\'ultima slide', 9523 paginationBulletMessage: 'Vai alla slide {{index}}' 9524 }, 9525 breakpoints: { 9526 640: { 9527 slidesPerView: 1, 9528 spaceBetween: 20 9529 }, 9530 768: { 9531 slidesPerView: 3, 9532 spaceBetween: 20, 9533 centeredSlides: false 9534 } 9535 } 9536 }; 9537 return _this4; 9538 } 9539 9540 SwiperColorsDirective.factory = function factory() { 9541 return new SwiperColorsDirective(); 9542 }; 9543 9544 return SwiperColorsDirective; 9545 }(SwiperDirective); 9546 SwiperColorsDirective.factory.$inject = []; 9547 var SwiperIconsDirective = /*#__PURE__*/function (_SwiperDirective4) { 9548 _inheritsLoose(SwiperIconsDirective, _SwiperDirective4); 9549 9550 function SwiperIconsDirective() { 9551 var _this5; 9552 9553 _this5 = _SwiperDirective4.call(this) || this; 9554 _this5.options = { 9555 slidesPerView: 1, 9556 spaceBetween: 30, 9557 watchOverflow: true, 9558 pagination: { 9559 el: '.swiper-pagination', 9560 clickable: true 9561 }, 9562 a11y: { 9563 enabled: true, 9564 prevSlideMessage: 'Slide precedente', 9565 nextSlideMessage: 'Slide successiva', 9566 firstSlideMessage: 'Questa è la prima slide', 9567 lastSlideMessage: 'Questa è l\'ultima slide', 9568 paginationBulletMessage: 'Vai alla slide {{index}}' 9569 }, 9570 breakpoints: { 9571 640: { 9572 slidesPerView: 1, 9573 spaceBetween: 20 9574 }, 9575 768: { 9576 slidesPerView: 5, 9577 spaceBetween: 20 9578 } 9579 } 9580 }; 9581 return _this5; 9582 } 9583 9584 SwiperIconsDirective.factory = function factory() { 9585 return new SwiperIconsDirective(); 9586 }; 9587 9588 return SwiperIconsDirective; 9589 }(SwiperDirective); 9590 SwiperIconsDirective.factory.$inject = [];
9591 var SwiperCollectionsDirective = /*#__PURE__*/function (_SwiperDirective5) { 9592 _inheritsLoose(SwiperCollectionsDirective, _SwiperDirective5); 9593 9594 function SwiperCollectionsDirective() { 9595 var _this6; 9596 9597 _this6 = _SwiperDirective5.call(this) || this; 9598 _this6.options = { 9599 slidesPerView: 1, 9600 slidesPerGroup: 1, 9601 // Aggiungi questa opzione per specificare quanti elementi scorrono alla volta 9602 spaceBetween: 30, 9603 pagination: { 9604 el: '.swiper-pagination', 9605 clickable: true 9606 }, 9607 a11y: { 9608 enabled: true, 9609 prevSlideMessage: 'Slide precedente', 9610 nextSlideMessage: 'Slide successiva', 9611 firstSlideMessage: 'Questa è la prima slide', 9612 lastSlideMessage: 'Questa è l\'ultima slide', 9613 paginationBulletMessage: 'Vai alla slide {{index}}' 9614 }, 9615 breakpoints: { 9616 640: { 9617 slidesPerView: 1, 9618 slidesPerGroup: 1, 9619 // Anche qui, assicurati che sia 1 su dispositivi mobili 9620 spaceBetween: 20 9621 }, 9622 768: { 9623 slidesPerView: 3, 9624 slidesPerGroup: 3, 9625 // Imposta questo su 3 per desktop 9626 spaceBetween: 20 9627 } 9628 } 9629 }; 9630 return _this6; 9631 } 9632 9633 SwiperCollectionsDirective.factory = function factory() { 9634 return new SwiperCollectionsDirective(); 9635 }; 9636 9637 return SwiperCollectionsDirective; 9638 }(SwiperDirective); 9639 SwiperCollectionsDirective.factory.$inject = []; 9640 9641 /* jshint esversion: 6 */ 9642 9643 var VideoDirective = /*#__PURE__*/function () { 9644 function VideoDirective($timeout, WishlistService) { 9645 this.$timeout = $timeout; 9646 this.wishlistService = WishlistService; 9647 this.restrict = 'A'; 9648 this.transclude = true; 9649 this.template = 9650 /* html */ 9651 "\n\t\t\t<div class=\"media\">\n\t\t\t\t<ng-transclude></ng-transclude>\n\t\t\t</div>\n\t\t\t<div class=\"overlay\" ng-click=\"onOverlay($event)\"></div>\n\t\t\t<div class=\"btn btn--play\" ng-class=\"{ playing: playing }\">\n\t\t\t\t<svg class=\"icon icon--play-progress-background\" viewBox=\"0 0 196 196\">\n\t\t\t\t\t<path xmlns=\"http://www.w3.org/2000/svg\" stroke-width=\"2px\" d=\"M195.5,98c0,53.8-43.7,97.5-97.5,97.5S0.5,151.8,0.5,98S44.2,0.5,98,0.5S195.5,44.2,195.5,98z\"/>\n\t\t\t\t</svg>\n\t\t\t\t<svg class=\"icon icon--play-progress\" viewBox=\"0 0 196 196\">\n\t\t\t\t\t<path xmlns=\"http://www.w3.org/2000/svg\" stroke-width=\"2px\" stroke-dasharray=\"1\" stroke-dashoffset=\"1\" pathLength=\"1\" stroke-linecap=\"square\" d=\"M195.5,98c0,53.8-43.7,97.5-97.5,97.5S0.5,151.8,0.5,98S44.2,0.5,98,0.5S195.5,44.2,195.5,98z\"/>\n\t\t\t\t</svg>\n\t\t\t\t<svg class=\"icon icon--play\" ng-if=\"!playing\" viewBox=\"0 0 16 20\">\n\t\t\t\t\t<path xmlns=\"http://www.w3.org/2000/svg\" fill-rule=\"evenodd\" d=\"M0,0v19.8l15.4-11L0,0z\" clip-rule=\"evenodd\" />\n\t\t\t\t</svg>\n\t\t\t\t<svg class=\"icon icon--play\" ng-if=\"playing\" viewBox=\"0 0 16 20\">\n\t\t\t\t\t<path xmlns=\"http://www.w3.org/2000/svg\" d=\"M0 0.9H4V18.9H0z\"/>\n\t\t\t\t\t<path xmlns=\"http://www.w3.org/2000/svg\" d=\"M11.4 0.9H15.4V18.9H11.4z\"/>\n\t\t\t\t</svg>\n\t\t\t</div>\n\t\t\t<!--\n\t\t\t<div class=\"btn btn--pinterest\" ng-click=\"onPin()\" ng-if=\"onPin\">\n\t\t\t\t<svg class=\"icon icon--pinterest\"><use xlink:href=\"#pinterest\"></use></svg>\n\t\t\t</div>\n\t\t\t<div class=\"btn btn--wishlist\" ng-class=\"{ active: wishlistActive, activated: wishlistActivated, deactivated: wishlistDeactivated }\" ng-click=\"onClickWishlist($event)\">\n\t\t\t\t<svg class=\"icon icon--wishlist\" ng-if=\"!wishlistActive\"><use xlink:href=\"#wishlist\"></use></svg>\n\t\t\t\t<svg class=\"icon icon--wishlist\" ng-if=\"wishlistActive\"><use xlink:href=\"#wishlist-added\"></use></svg>\n\t\t\t</div>\n\t\t\t<div class=\"btn btn--zoom\" ng-click=\"onClickZoom($event)\">\n\t\t\t\t<svg class=\"icon icon--zoom\"><use xlink:href=\"#zoom\"></use></svg>\n\t\t\t</div>\n\t\t\t-->\n"; 9652 this.scope = { 9653 item: '=?video' 9654 }; 9655 } 9656 9657 var _proto = VideoDirective.prototype; 9658 9659 _proto.link = function link(scope, element, attributes, controller) { 9660 var _this = this; 9661 9662 scope.item = scope.item || {}; 9663 var node = element[0]; 9664 var video = node.querySelector('video'); 9665 9666 if (video) { 9667 var pageTitle = document.title; 9668 9669 scope.onPin = function () { 9670 var pin = { 9671 url: window.location.href, 9672 media: video.poster, 9673 description: video.title || pageTitle 9674 }; 9675 GtmService.push({ 9676 event: 'Pinterest', 9677 wish_name: scope.item.name || scope.item.coId, 9678 wish_type: scope.item.typeName || scope.item.type 9679 }); // console.log('VideoDirective.onPin', pin); 9680 9681 PinUtils.pinOne(pin); 9682 }; 9683 } 9684 9685 var progress = node.querySelector('.icon--play-progress path'); 9686 scope.item = scope.item || {}; 9687 9688 scope.onOverlay = function (event) { 9689 if (video) { 9690 if (video.paused) { 9691 var gallery = document.querySelector('.section--gallery'); 9692 video.muted = gallery ? false : true; 9693 video.play(); 9694 } else { 9695 video.pause(); 9696 } 9697 } 9698 /* 9699 event.preventDefault(); 9700 event.stopImmediatePropagation(); 9701 */ 9702 9703 }; 9704 9705 var onPlay = function onPlay() { 9706 _this.$timeout(function () { 9707 scope.playing = true; 9708 }); 9709 }; 9710 9711 var onPlayGtm = function onPlayGtm() { 9712 var sources = video.querySelectorAll('source'); 9713 9714 if (sources.length) { 9715 var src = sources[sources.length - 1].getAttribute('src'); 9716 9717 if (src) { 9718 GtmService.push({ 9719 event: 'video play', 9720 video_name: src 9721 }); 9722 } 9723 } 9724 }; 9725 9726 var onPause = function onPause() { 9727 _this.$timeout(function () { 9728 scope.playing = false;
9729 }); 9730 }; 9731 9732 var onEnded = function onEnded() { 9733 _this.$timeout(function () { 9734 scope.playing = false; 9735 }); 9736 }; 9737 9738 var onTimeUpdate = function onTimeUpdate() { 9739 // console.log(video.currentTime, video.duration); 9740 progress.style.strokeDashoffset = 1 - video.currentTime / video.duration; 9741 }; 9742 9743 scope.$watch(function () { 9744 return _this.wishlistService.has(scope.item); 9745 }, function (current, previous) { 9746 // console.log(current, previous, node); 9747 if (scope.wishlistActive !== current) { 9748 scope.wishlistActive = current; 9749 9750 if (current) { 9751 scope.wishlistActivated = true; 9752 9753 _this.$timeout(function () { 9754 scope.wishlistActivated = false; 9755 }, 2000); 9756 } else { 9757 scope.wishlistDeactivated = true; 9758 9759 _this.$timeout(function () { 9760 scope.wishlistDeactivated = false; 9761 }, 2000); 9762 } 9763 } 9764 }); 9765 9766 scope.onClickWishlist = function (event) { 9767 _this.wishlistService.toggle(scope.item).then(function (has) { 9768 console.log('VideoDirective.onClickWishlist', has); 9769 }, function (error) { 9770 console.log(error); 9771 }); // event.preventDefault(); 9772 // event.stopPropagation(); 9773 9774 }; 9775 9776 scope.onClickZoom = function (event) { 9777 if (scope.$root.gallery) { 9778 _this.$timeout(function () { 9779 scope.$root.gallery = null; 9780 }); 9781 } else if (node.classList.contains('picture--vertical') || node.classList.contains('picture--horizontal')) { 9782 _this.$timeout(function () { 9783 var index = 0; 9784 var items = Array.prototype.slice.call(document.querySelectorAll('.picture--vertical[media], .picture--vertical[video], .picture--horizontal[media], .picture--horizontal[video]')).map(function (itemNode, i) { 9785 if (itemNode == node) { 9786 index = i; 9787 } 9788 9789 var item = {}; 9790 item.type = itemNode.hasAttribute('media') ? 'media' : 'video'; 9791 9792 if (item.type === 'media') { 9793 var img = itemNode.querySelector('img'); 9794 item.src = img.getAttribute('src') || img.getAttribute('data-src'); 9795 item.title = img.getAttribute('alt'); 9796 var wishlist = itemNode.getAttribute('media'); 9797 9798 if (wishlist) { 9799 item.wishlist = JSON.parse(wishlist.indexOf('"') === -1 ? wishlist.split(/[^\d\W]+/g).join('"') : wishlist); 9800 } 9801 } else { 9802 var _video = itemNode.querySelector('video'); 9803 9804 var sources = _video.querySelectorAll('source'); 9805 9806 item.poster = _video.getAttribute('poster'); 9807 item.src = sources[sources.length - 1].getAttribute('src'); 9808 item.title = _video.getAttribute('alt'); 9809 9810 var _wishlist = itemNode.getAttribute('video'); 9811 9812 if (_wishlist) { 9813 item.wishlist = JSON.parse(_wishlist.indexOf('"') === -1 ? _wishlist.split(/[^\d\W]+/g).join('"') : _wishlist); 9814 } 9815 } 9816 9817 return item; 9818 }); 9819 scope.$root.gallery = { 9820 index: index, 9821 items: items 9822 }; 9823 }); 9824 } // event.preventDefault(); 9825 // event.stopPropagation(); 9826 9827 }; 9828 9829 if (video) { 9830 video.addEventListener('play', onPlay); 9831 video.addEventListener('play', onPlayGtm); 9832 video.addEventListener('pause', onPause); 9833 video.addEventListener('ended', onEnded); 9834 video.addEventListener('timeupdate', onTimeUpdate); 9835 } 9836 9837 scope.$on('$destroy', function () { 9838 if (video) { 9839 // console.log('VideoDirective.$destroy'); 9840 video.removeEventListener('play', onPlay); 9841 video.removeEventListener('play', onPlayGtm); 9842 video.removeEventListener('pause', onPause); 9843 video.removeEventListener('ended', onEnded); 9844 video.removeEventListener('timeupdate', onTimeUpdate); 9845 } 9846 }); 9847 }; 9848 9849 VideoDirective.factory = function factory($timeout, WishlistService) { 9850 return new VideoDirective($timeout, WishlistService); 9851 }; 9852 9853 return VideoDirective; 9854 }(); 9855 VideoDirective.factory.$inject = ['$timeout', 'WishlistService']; 9856 9857 /* jshint esversion: 6 */ 9858 var VIRTUAL_SCROLL_ENABLED = false;
9859 9860 var VirtualScrollDirective = /*#__PURE__*/function () { 9861 function VirtualScrollDirective(DomService) { 9862 this.domService = DomService; 9863 this.restrict = 'A'; 9864 } 9865 9866 var _proto = VirtualScrollDirective.prototype; 9867 9868 _proto.link = function link(scope, element, attributes, controller) { 9869 if (!this.domService.agent.mobile && VIRTUAL_SCROLL_ENABLED) { 9870 var node = element[0]; 9871 node.classList.add('virtual-scroll'); 9872 DomService.DEFAULT_SCROLL_TARGET = node; 9873 var target = node.querySelector(attributes.virtualScroll); 9874 target.classList.add('virtual-scroll-target'); 9875 9876 if (node !== document.body) { 9877 document.querySelector('html').classList.add('virtual-scrolled'); 9878 } 9879 9880 var subscription = this.domService.virtualScroll$(attributes.virtualScroll).subscribe(function (top) {}); 9881 scope.$on('$destroy', function () { 9882 subscription.unsubscribe(); 9883 }); 9884 } 9885 }; 9886 9887 VirtualScrollDirective.factory = function factory(DomService) { 9888 return new VirtualScrollDirective(DomService); 9889 }; 9890 9891 return VirtualScrollDirective; 9892 }(); 9893 VirtualScrollDirective.factory.$inject = ['DomService']; 9894 9895 /* jshint esversion: 6 */ 9896 9897 var VisibilityDirective = /*#__PURE__*/function () { 9898 function VisibilityDirective(DomService) { 9899 this.domService = DomService; 9900 this.restrict = 'A'; 9901 } 9902 9903 var _proto = VisibilityDirective.prototype; 9904 9905 _proto.link = function link(scope, element, attributes, controller) { 9906 var node = element[0]; 9907 var subscription = this.domService.firstVisibility$(node).subscribe(function (visible) { 9908 // console.log('visibility', attributes.visibility, node.classList); 9909 var gtmEvent = { 9910 event: 'ElementVisibilityCustomEvent', 9911 element: attributes.visibility, 9912 classes: node.getAttribute('class') 9913 }; // console.log(gtmEvent); 9914 9915 GtmService.push(gtmEvent); 9916 }); 9917 scope.$on('$destroy', function () { 9918 subscription.unsubscribe(); 9919 }); 9920 }; 9921 9922 VisibilityDirective.factory = function factory(DomService) { 9923 return new VisibilityDirective(DomService); 9924 }; 9925 9926 return VisibilityDirective; 9927 }(); 9928 VisibilityDirective.factory.$inject = ['DomService']; 9929 9930 /* jshint esversion: 6 */ 9931 var WishlistDirective = /*#__PURE__*/function () { 9932 function WishlistDirective(WishlistService) { 9933 this.wishlistService = WishlistService; 9934 this.restrict = 'E'; 9935 this.scope = { 9936 item: '=' 9937 }; 9938 this.template = "<div class=\"btn btn--wishlist\" ng-class=\"{ added: item.added }\" ng-click=\"onWishlist()\">\n\t\t\t\t<svg class=\"icon icon--wishlist\" ng-if=\"!item.added\"><use xlink:href=\"#wishlist\"></use></svg>\n\t\t\t\t<svg class=\"icon icon--wishlist\" ng-if=\"item.added\"><use xlink:href=\"#wishlist-added\"></use></svg>\n\t\t\t</div>"; 9939 } 9940 9941 var _proto = WishlistDirective.prototype; 9942 9943 _proto.link = function link(scope, element, attributes, controller) { 9944 var _this = this; 9945 9946 var node = element[0]; 9947 scope.item = scope.item || {}; 9948 9949 scope.onWishlist = function () { 9950 _this.wishlistService.toggle(scope.item).then(function (item) { 9951 Object.assign(scope.item, item); 9952 }, function (error) { 9953 return console.log(error); 9954 }); 9955 }; 9956 9957 scope.$on('$destroy', function () {}); 9958 }; 9959 9960 WishlistDirective.factory = function factory(WishlistService) { 9961 return new WishlistDirective(WishlistService); 9962 }; 9963 9964 return WishlistDirective; 9965 }(); 9966 WishlistDirective.factory.$inject = ['WishlistService']; 9967 9968 /* jshint esversion: 6 */ 9969 9970 var ZoomableDirective = /*#__PURE__*/function () { 9971 // src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" lazy lazy-src=" 9972 function ZoomableDirective($timeout, DomService) { 9973 this.$timeout = $timeout; 9974 this.domService = DomService; 9975 this.restrict = 'A'; 9976 } 9977 9978 var _proto = ZoomableDirective.prototype; 9979 9980 _proto.link = function link(scope, element, attributes, controller) { 9981 var _this = this; 9982 9983 var triggers, rect; 9984 var node = element[0]; 9985 var content = node.querySelector('.zoomable__content'); 9986 9987 var onClick = function onClick() { 9988 // console.log(scope); 9989 var slides = Array.prototype.slice.call(node.querySelectorAll('.swiper-slide')); 9990 9991 if (node.classList.contains('zoomed')) { 9992 TweenMax.to(content, 0.3, { 9993 left: rect.left, 9994 top: rect.top, 9995 width: rect.width, 9996 height: rect.height, 9997 ease: Expo.easeInOut, 9998 // ease: CustomEase.create('custom', 'M0,0,C0.596,0,0.346,1,1,1'), 9999 onUpdate: function onUpdate() { 10000 scope.$broadcast('onResize'); 10001 }, 10002 onComplete: function onComplete() { 10003 TweenMax.set(node, { 10004 height: 'auto' 10005 }); 10006 TweenMax.set(content, { 10007 left: rect.left, 10008 top: rect.top, 10009 width: rect.width, 10010 height: rect.height 10011 }); 10012 node.classList.remove('zoomed'); 10013 scope.$emit('onDroppinIn', false); 10014 } 10015 }); 10016 } else { 10017 rect = Rect.fromNode(node); 10018 TweenMax.set(node, { 10019 height: rect.height 10020 }); 10021 TweenMax.set(content, { 10022 left: rect.left, 10023 top: rect.top, 10024 width: rect.width, 10025 height: rect.height 10026 }); 10027 node.classList.add('zoomed'); 10028 scope.$emit('onDroppinIn', true); 10029 TweenMax.to(content, 0.3, { 10030 left: 0, 10031 top: 0, 10032 width: '100%', 10033 height: '100%', 10034 ease: Expo.easeInOut, 10035 // ease: CustomEase.create('custom', 'M0,0,C0.596,0,0.346,1,1,1'), 10036 onUpdate: function onUpdate() { 10037 // window.dispatchEvent(new Event('resize'));
10038 // slides.forEach(x => x.style.width = content.style.width); 10039 scope.$broadcast('onResize'); 10040 }, 10041 onComplete: function onComplete() {// scope.$broadcast('onResize'); 10042 } 10043 }); 10044 } 10045 }; 10046 10047 var addListeners = function addListeners() { 10048 triggers = Array.prototype.slice.call(node.querySelectorAll('.zoomable__trigger')); // console.log('ZoomableDirective', node, content, triggers); 10049 10050 triggers.forEach(function (x) { 10051 return x.addEventListener('click', onClick); 10052 }); 10053 }; 10054 10055 var removeListeners = function removeListeners() { 10056 if (triggers) { 10057 triggers.forEach(function (x) { 10058 return x.removeEventListener('click', onClick); 10059 }); 10060 } 10061 }; 10062 10063 scope.$on('lastItem', function ($scope, item) { 10064 // console.log('lastItem'); 10065 removeListeners(); 10066 addListeners(); 10067 }); 10068 addListeners(); 10069 scope.$on('$destroy', function () { 10070 triggers.forEach(function (x) { 10071 return x.removeEventListener('click', onClick); 10072 }); 10073 }); 10074 10075 scope.onZoom = function (item) { 10076 var rect = Rect.fromNode(content); // console.log(rect); 10077 10078 TweenMax.set(node, { 10079 height: rect.height 10080 }); 10081 _this.scope.zoomed = !_this.scope.zoomed; 10082 /* 10083 TweenMax.to(u, 0.50, { 10084 scaleX: 1, 10085 transformOrigin: '0 50%', 10086 delay: 0, 10087 ease: Power3.easeInOut, 10088 overwrite: 'all', 10089 onComplete: () => { 10090 TweenMax.set(u, { transformOrigin: '100% 50%', scaleX: 1 }); 10091 TweenMax.to(u, 0.50, { 10092 scaleX: 0, 10093 transformOrigin: '100% 50%', 10094 delay: 1.0, 10095 ease: Power3.easeInOut, 10096 overwrite: 'all', 10097 onComplete: () => { 10098 animate(); 10099 } 10100 }); 10101 } 10102 }); 10103 */ 10104 }; 10105 }; 10106 10107 ZoomableDirective.factory = function factory($timeout, DomService) { 10108 return new ZoomableDirective($timeout, DomService); 10109 }; 10110 10111 return ZoomableDirective; 10112 }(); 10113 ZoomableDirective.factory.$inject = ['$timeout', 'DomService']; 10114 10115 var DownloadsCtrl = /*#__PURE__*/function () { 10116 function DownloadsCtrl($scope, $timeout, LocationService) { 10117 this.$scope = $scope; 10118 this.$timeout = $timeout; 10119 this.locationService = LocationService; 10120 } 10121 10122 var _proto = DownloadsCtrl.prototype; 10123 10124 _proto.onIndexItemClick = function onIndexItemClick(categoryId) { 10125 var $target = $("[data-index-id='" + categoryId + "']"); 10126 $('html, body').stop().animate({ 10127 'scrollTop': $target.offset().top 10128 }, 750, 'swing', function () {}); 10129 }; 10130 10131 return DownloadsCtrl; 10132 }(); 10133 10134 DownloadsCtrl.$inject = ['$scope', '$timeout', 'LocationService']; 10135 10136 /* jshint esversion: 6 */ 10137 function ImageWithFeatures() { 10138 return function (images, features) { 10139 if (!images) { 10140 return null; 10141 } 10142 10143 if (!images.length) { 10144 return null; 10145 } 10146 10147 if (images.length === 1 || !features || features[0] === null) { 10148 return images[0].url; 10149 } 10150 10151 var image = images.find(function (image) { 10152 var has = true; 10153 features.forEach(function (f) { 10154 return has = has && image.features.indexOf(f) !== -1; 10155 }); 10156 return has; 10157 }); 10158 10159 if (image) { 10160 return image.url; 10161 } else { 10162 return images[0].url; 10163 } 10164 }; 10165 } 10166 10167 /* jshint esversion: 6 */ 10168 function NotInFilter($filter) { 10169 return function (array, filters, element) { 10170 if (filters) { 10171 return $filter('filter')(array, function (item) { 10172 for (var i = 0; i < filters.length; i++) { 10173 var filter = filters[i]; 10174 10175 if (typeof filter === 'object') { 10176 if (filter[element] === item[element]) return false; 10177 } else { 10178 if (filter === item[element]) return false; 10179 } 10180 } 10181 10182 return true; 10183 }); 10184 } 10185 }; 10186 } 10187 10188 /* jshint esversion: 6 */ 10189 function TrustedFilter($sce) { 10190 return function (url) { 10191 return $sce.trustAsResourceUrl(url); 10192 }; 10193 } 10194 10195 /* jshint esversion: 6 */ 10196 var ControlMessagesDirective = /*#__PURE__*/function () { 10197 function ControlMessagesDirective() { 10198 this.restrict = 'E'; 10199 this.templateUrl = 'templates/forms/messages.html'; 10200 this.transclude = { 10201 'message': '?messageItems' 10202 }; 10203 } 10204 10205 var _proto = ControlMessagesDirective.prototype; 10206 10207 _proto.link = function link(scope, element, attributes, model) {}; 10208 10209 ControlMessagesDirective.factory = function factory() { 10210 return new ControlMessagesDirective(); 10211 }; 10212 10213 return ControlMessagesDirective; 10214 }(); 10215 ControlMessagesDirective.factory.$inject = []; 10216 10217 /* jshint esversion: 6 */ 10218 // CSS styles for keyboard navigation are in app/forms/custom-select.css 10219 // (imported via HTML/SCSS pipeline, not directly in JS) 10220 var formatLabel = function formatLabel(string, prepend, expression) { 10221 if (string === void 0) { 10222 string = ''; 10223 } 10224 10225 if (prepend === void 0) { 10226 prepend = ''; 10227 } 10228 10229 if (expression === void 0) { 10230 expression = undefined; 10231 } 10232 10233 var splitted = string.split(','); 10234 10235 if (splitted.length > 1) { 10236 var formatted = splitted.shift(); 10237 splitted.forEach(function (value, index) { 10238 if (expression) { 10239 formatted = formatted.split('{' + index + '}').join('\' + ' + prepend + value + ' + \''); 10240 } else { 10241 formatted = formatted.split('{' + index + '}').join(prepend + value); 10242 } 10243 }); 10244 10245 if (expression) { 10246 return '\'' + formatted + '\''; 10247 } else { 10248 return formatted; 10249 } 10250 } else { 10251 return prepend + string; 10252 } 10253 }; 10254 10255 var uniqueId = 0; 10256 var errorElements = [], 10257 to; 10258 10259 var ControlDirective = /*#__PURE__*/function () { 10260 function ControlDirective($parse, DomService) { 10261 var _this = this; 10262 10263 this.$parse = $parse; 10264 this.domService = DomService; 10265 this.restrict = 'A'; 10266 10267 this.templateUrl = function (element, attributes) { 10268 var template = 'templates/forms/text.html'; 10269 10270 switch (attributes.control) { 10271 case 'checkbox': 10272 template = 'templates/forms/checkbox.html'; 10273 break; 10274 10275 case 'password': 10276 template = 'templates/forms/password.html'; 10277 break; 10278 10279 case 'select': 10280 template = 'templates/forms/select.html'; 10281 break; 10282 10283 case 'custom-select': 10284 template = 'templates/forms/custom-select.html'; 10285 break; 10286 10287 case 'autocomplete': 10288 template = 'templates/forms/autocomplete.html'; 10289 break; 10290 10291 case 'autocomplete-single-option': 10292 template = 'templates/forms/autocomplete-single-option.html'; 10293 break; 10294 10295 case 'textarea': 10296 template = 'templates/forms/textarea.html'; 10297 break; 10298 10299 case 'textlocked': 10300 template = 'templates/forms/textlocked.html'; 10301 break; 10302 } 10303 10304 return template; 10305 }; 10306 10307 this.scope = { 10308 ngModel: '=', 10309 required: '=', 10310 form: '@', 10311 title: '@', 10312 placeholder: '@',
10313 source: '=?', 10314 key: '@?', 10315 label: '@?' 10316 }; 10317 this.require = 'ngModel'; 10318 this.transclude = true; 10319 this.link = { 10320 pre: function pre(scope, element, attributes, controller, transclude) { 10321 _this.linkMethod(scope, element, attributes, controller, transclude); 10322 } 10323 }; 10324 } 10325 10326 var _proto = ControlDirective.prototype; 10327 10328 _proto.linkMethod = function linkMethod(scope, element, attributes, controller, transclude) { 10329 var _this2 = this; 10330 10331 var label = scope.label = scope.label ? scope.label : 'name'; 10332 var key = scope.key = scope.key ? scope.key : 'id'; 10333 10334 if (attributes.control === 'select') { 10335 var filter = attributes.filter ? '| ' + attributes.filter : ''; 10336 var optionLabel = formatLabel(label, 'item.', true); 10337 10338 scope.getOptions = function () { 10339 return attributes.number ? 'item.' + key + ' as ' + optionLabel + ' disable when item.disabled for item in source ' + filter : optionLabel + ' disable when item.disabled for item in source ' + filter + ' track by item.' + key; 10340 }; 10341 } 10342 10343 if (attributes.autofocus !== undefined) { 10344 var input = element[0].querySelector('input'); 10345 10346 if (input) { 10347 input.setAttribute('autofocus', true); 10348 setTimeout(function () { 10349 input.focus(); 10350 }, 500); 10351 } 10352 } 10353 10354 var type = scope.type = attributes.control; 10355 var form = scope.form = scope.form || 'form'; 10356 var title = scope.title = scope.title || 'untitled'; 10357 var placeholder = scope.placeholder = scope.placeholder || title; 10358 var field = scope.field = title.replace(/[^0-9a-zA-Z]/g, "").split(' ').join('') + ++uniqueId; 10359 scope.format = attributes.format || null; 10360 scope.precision = attributes.precision || null; 10361 scope.validate = attributes.validate || attributes.control; 10362 scope.minLength = attributes.minLength || 0; 10363 scope.maxLength = attributes.maxLength || Number.POSITIVE_INFINITY; 10364 scope.min = attributes.min || null; 10365 scope.max = attributes.max || null; 10366 scope.options = this.$parse(attributes.options)(scope) || {}; 10367 scope.focus = false; 10368 scope.visible = false; 10369 10370 scope.updateView = function (value) { 10371 controller.$viewValue = value; 10372 controller.$render(); 10373 }; 10374 10375 scope.updateModel = function (value) { 10376 controller.$setViewValue(value); // controller.$modelValue = value; 10377 10378 scope.ngModel = value; // overwrites ngModel value 10379 }; 10380 10381 scope.optionName = function (id) { 10382 if (id) { 10383 var option = scope.source.find(function (x) { 10384 return x.id === id; 10385 }); 10386 10387 if (option) { 10388 return option.name; 10389 } 10390 } 10391 10392 if (Array.isArray(scope.ngModel)) { 10393 return scope.ngModel.map(function (x) { 10394 return scope.source.find(function (s) { 10395 return s.id === x; 10396 }).name; 10397 }).join(', '); 10398 } else { 10399 var _option = scope.source.find(function (x) { 10400 return x.id === scope.ngModel; 10401 }); 10402 10403 if (_option) { 10404 return _option.name; 10405 } 10406 } 10407 }; 10408 10409 scope.onModelAdd = function (value) { 10410 var items = controller.$viewValue || []; 10411 var index = items.indexOf(value); 10412 10413 if (index === -1) { 10414 items.push(value); 10415 controller.$setViewValue(items); // console.log(controller); 10416 10417 scope.ngModel = items; // overwrites ngModel value 10418 } 10419 10420 scope.query = null; 10421 }; 10422 10423 scope.onModelRemove = function (value) { 10424 var items = controller.$viewValue || []; 10425 var index = items.indexOf(value); 10426 10427 if (index !== -1) { 10428 items.splice(index, 1); 10429 controller.$setViewValue(items); 10430 scope.ngModel = items; // overwrites ngModel value 10431 } 10432 10433 scope.query = null; 10434 }; 10435 10436 scope.searchQuery = function () { 10437 return function (item) { 10438 // console.log(item, scope.query); 10439 if (scope.query) { 10440 return item.name.toLowerCase().indexOf(scope.query.toLowerCase()) !== -1; 10441 } else { 10442 return true; 10443 } 10444 }; 10445 }; 10446 10447 scope.modelValue = function () { 10448 var value = controller.$viewValue || []; // console.log(value); 10449 10450 return value; 10451 }; 10452 10453 scope.onChange = function (model) { 10454 // console.log('ControlDirective.onChange'); 10455 _this2.$parse(attributes.onChange)(scope.$parent); 10456 }; 10457 10458 scope.onFilter = function (model) { 10459 _this2.$parse(attributes.onFilter)(scope.$parent); 10460 }; 10461 10462 scope.getType = function () { 10463 var type = 'text'; 10464 10465 switch (attributes.control) { 10466 case 'password': 10467 type = scope.visible ? 'text' : 'password'; 10468 break; 10469 10470 case 'textlocked': 10471 type = 'text'; 10472 break; 10473 10474 default: 10475 type = attributes.control; 10476 } 10477 10478 return type; 10479 }; 10480 10481 scope.onFocus = function () {
10482 scope.focus = true; // console.log('ControlDirective.onFocus', scope.focus); 10483 }; 10484 10485 scope.onBlur = function () { 10486 scope.focus = false; // console.log('ControlDirective.onBlur', scope.focus); 10487 10488 _this2.scrollToError(); 10489 }; 10490 10491 scope.getClasses = function () { 10492 var field = controller; // this.$parse(scope.form + '.' + scope.field)(scope.$parent); 10493 10494 if (field) { 10495 var focus = scope.focus; 10496 var success = field.$valid; 10497 10498 var _form = _this2.$parse(scope.form)(scope.$parent); 10499 10500 var error = field.$invalid && (_form.$submitted || field.$touched); 10501 var empty = !field.$viewValue; 10502 10503 if (error) { 10504 _this2.onError(element); 10505 10506 if (scope.error !== error) { 10507 scope.error = error; 10508 10509 _this2.scrollToError(); 10510 } 10511 } else { 10512 scope.error = false; 10513 } 10514 10515 return { 10516 focus: focus, 10517 success: success, 10518 error: error, 10519 empty: empty 10520 }; 10521 } 10522 }; 10523 10524 scope.getMessages = function () { 10525 var form = _this2.$parse(scope.form)(scope.$parent); 10526 10527 var field = _this2.$parse(scope.form + '.' + scope.field)(scope.$parent); 10528 10529 return (form.$submitted || field.$touched) && field.$error; 10530 }; 10531 10532 scope.toggleVisibility = function () { 10533 scope.visible = !scope.visible; 10534 }; // Add keyboard navigation for custom-select 10535 10536 10537 scope.dropdownVisible = false; 10538 scope.highlightedIndex = -1; 10539 10540 scope.toggleDropdown = function () { 10541 scope.dropdownVisible = !scope.dropdownVisible; 10542 10543 if (scope.dropdownVisible) { 10544 // Open the dropdown 10545 scope.$root.$broadcast('onDroppedIn', element[0]); // Determine which option should be highlighted 10546 10547 if (scope._openedFromKeyboard || scope.ngModel === null || scope.ngModel === undefined) { 10548 // Find first non-disabled option 10549 scope.highlightedIndex = scope.source.findIndex(function (item) { 10550 return !item.disabled; 10551 }); 10552 } else { 10553 // Find currently selected option 10554 scope.highlightedIndex = scope.source.findIndex(function (item) { 10555 return item.id === scope.ngModel; 10556 }); 10557 10558 if (scope.highlightedIndex === -1) { 10559 // Fallback to first non-disabled option 10560 scope.highlightedIndex = scope.source.findIndex(function (item) { 10561 return !item.disabled; 10562 }); 10563 } 10564 } 10565 10566 if (scope.ngModel === null || scope.ngModel === undefined || scope._openedFromKeyboard) { 10567 // Find first non-disabled option 10568 scope.highlightedIndex = scope.source.findIndex(function (item) { 10569 return !item.disabled; 10570 }); 10571 } else { 10572 // Find currently selected option 10573 scope.highlightedIndex = scope.source.findIndex(function (item) { 10574 return item.id === scope.ngModel; 10575 }); // Fallback to first option if selected item not found 10576 10577 if (scope.highlightedIndex === -1) { 10578 scope.highlightedIndex = scope.source.findIndex(function (item) { 10579 return !item.disabled; 10580 }); 10581 } 10582 } // Set focus on the highlighted option with a small delay to ensure DOM is ready 10583 10584 10585 setTimeout(function () { 10586 var dropdown = element[0].querySelector('.dropdown'); 10587 10588 if (dropdown) { 10589 var options = dropdown.querySelectorAll('li:not(.disabled)'); // Ensure highlightedIndex is valid 10590 10591 if (scope.highlightedIndex < 0 || scope.highlightedIndex >= options.length) { 10592 scope.highlightedIndex = 0; 10593 } 10594 10595 if (options.length > 0) { 10596 var optionToFocus = options[scope.highlightedIndex]; // Make sure the option is visible in the dropdown 10597 10598 optionToFocus.scrollIntoView({ 10599 block: 'nearest' 10600 }); // Apply focus to the option directly if opened from keyboard 10601 10602 if (scope._openedFromKeyboard) { 10603 // Focus on the option 10604 optionToFocus.focus(); // Apply keyboard-focused class for visual indication 10605 10606 scope.$apply(function () {// This will trigger the class to be applied through ng-class binding 10607 }); 10608 } 10609 } 10610 } 10611 }, 50); // Call toggleDropdown method on the parent has-dropdown directive (if available) 10612 10613 var hasDropdownScope = angular.element(element[0].closest('[has-dropdown]')).scope(); 10614 10615 if (hasDropdownScope && typeof hasDropdownScope.toggleDropdown === 'function') { 10616 hasDropdownScope.toggleDropdown(); 10617 } // Reset the keyboard flag after handling 10618 10619 10620 scope._openedFromKeyboard = false;
10621 } else { 10622 // Close the dropdown 10623 scope.$root.$broadcast('onDroppedOut', element[0]); 10624 scope.highlightedIndex = -1; // Remove any keyboard focus indicators 10625 10626 var dropdown = element[0].querySelector('.dropdown'); 10627 10628 if (dropdown) { 10629 var focusedElements = dropdown.querySelectorAll('.keyboard-focused'); 10630 Array.from(focusedElements).forEach(function (el) { 10631 return el.classList.remove('keyboard-focused'); 10632 }); 10633 } // Call toggleDropdown method on the parent has-dropdown directive (if available) 10634 10635 10636 var _hasDropdownScope = angular.element(element[0].closest('[has-dropdown]')).scope(); 10637 10638 if (_hasDropdownScope && typeof _hasDropdownScope.toggleDropdown === 'function') { 10639 _hasDropdownScope.toggleDropdown(); 10640 } // Return focus to the select control 10641 10642 10643 var control = element[0].querySelector('.form__control'); 10644 10645 if (control) { 10646 control.focus(); 10647 } 10648 } // Need to apply changes since we're updating outside of Angular's knowledge 10649 10650 10651 if (!scope.$root.$$phase) { 10652 scope.$apply(); 10653 } 10654 }; 10655 10656 scope.selectOption = function (itemId, index, event) { 10657 // For touch events, prevent the subsequent click event 10658 if (event && event.type === 'touchend') { 10659 event.preventDefault(); 10660 event.stopPropagation(); // Set a flag to prevent duplicate execution from click event 10661 10662 scope._touchEndHandled = true; 10663 setTimeout(function () { 10664 delete scope._touchEndHandled; 10665 }, 100); 10666 } else if (event && event.type === 'click' && scope._touchEndHandled) { 10667 // Skip click event if touchend was already handled 10668 return; 10669 } 10670 10671 scope.updateModel(itemId); 10672 scope.onChange(); 10673 scope.toggleDropdown(); // Return focus to the select control 10674 10675 element[0].querySelector('.form__control').focus(); 10676 10677 if (event) { 10678 event.preventDefault(); 10679 event.stopPropagation(); 10680 } 10681 }; // Handle keydown events on options in the dropdown 10682 10683 10684 scope.onOptionKeyDown = function (event, itemId, index) { 10685 var options = scope.source.filter(function (item) { 10686 return !item.disabled; 10687 }); 10688 10689 switch (event.keyCode) { 10690 case 13: // Enter 10691 10692 case 32: 10693 // Space 10694 // Select the option and close dropdown 10695 scope.updateModel(itemId); 10696 scope.onChange(); 10697 scope.toggleDropdown(); // Return focus to the select control 10698 10699 element[0].querySelector('.form__control').focus(); 10700 event.preventDefault(); 10701 event.stopPropagation(); 10702 break; 10703 10704 case 38: 10705 // Arrow Up 10706 if (index > 0) { 10707 scope.highlightedIndex = index - 1; 10708 var prevOption = element[0].querySelector('#option-' + field + '-' + scope.highlightedIndex); 10709 10710 if (prevOption) { 10711 prevOption.focus(); 10712 prevOption.scrollIntoView({ 10713 block: 'nearest' 10714 }); 10715 } 10716 } else { 10717 // Loop to the last item when at the first item 10718 scope.highlightedIndex = options.length - 1; 10719 var lastOption = element[0].querySelector('#option-' + field + '-' + scope.highlightedIndex); 10720 10721 if (lastOption) { 10722 lastOption.focus(); 10723 lastOption.scrollIntoView({ 10724 block: 'nearest' 10725 }); 10726 } 10727 } 10728 10729 event.preventDefault(); 10730 event.stopPropagation(); 10731 break; 10732 10733 case 40: 10734 // Arrow Down 10735 if (index < options.length - 1) { 10736 scope.highlightedIndex = index + 1; 10737 var nextOption = element[0].querySelector('#option-' + field + '-' + scope.highlightedIndex); 10738 10739 if (nextOption) { 10740 nextOption.focus(); 10741 nextOption.scrollIntoView({ 10742 block: 'nearest' 10743 }); 10744 } 10745 } else { 10746 // Loop to the first item when at the last item 10747 scope.highlightedIndex = 0; 10748 var firstOption = element[0].querySelector('#option-' + field + '-0'); 10749 10750 if (firstOption) { 10751 firstOption.focus(); 10752 firstOption.scrollIntoView({ 10753 block: 'nearest' 10754 }); 10755 } 10756 } 10757 10758 event.preventDefault(); 10759 event.stopPropagation(); 10760 break; 10761 10762 case 27: 10763 // Escape 10764 scope.toggleDropdown(); 10765 element[0].querySelector('.form__control').focus(); 10766 event.preventDefault(); 10767 event.stopPropagation(); 10768 break; 10769 10770 case 9: 10771 // Tab 10772 // Handle tab key to navigate between options 10773 if (event.shiftKey) { 10774 // Shift+Tab - move to previous option 10775 if (index > 0) { 10776 scope.highlightedIndex = index - 1; 10777 10778 var _prevOption = element[0].querySelector('#option-' + field + '-' + scope.highlightedIndex); 10779 10780 if (_prevOption) { 10781 _prevOption.focus(); 10782 10783 _prevOption.scrollIntoView({ 10784 block: 'nearest' 10785 }); 10786 } 10787 } else { 10788 // Loop to the last item when at the first item 10789 scope.highlightedIndex = options.length - 1; 10790 10791 var _lastOption = element[0].querySelector('#option-' + field + '-' + scope.highlightedIndex); 10792 10793 if (_lastOption) { 10794 _lastOption.focus(); 10795 10796 _lastOption.scrollIntoView({ 10797 block: 'nearest' 10798 }); 10799 } 10800 } 10801 } else { 10802 // Regular Tab - move to next option 10803 if (index < options.length - 1) { 10804 scope.highlightedIndex = index + 1; 10805 10806 var _nextOption = element[0].querySelector('#option-' + field + '-' + scope.highlightedIndex); 10807 10808 if (_nextOption) { 10809 _nextOption.focus(); 10810 10811 _nextOption.scrollIntoView({ 10812 block: 'nearest' 10813 }); 10814 } 10815 } else { 10816 // Loop to the first item when at the last item 10817 scope.highlightedIndex = 0; 10818 10819 var _firstOption = element[0].querySelector('#option-' + field + '-0'); 10820 10821 if (_firstOption) { 10822 _firstOption.focus(); 10823 10824 _firstOption.scrollIntoView({ 10825 block: 'nearest' 10826 }); 10827 } 10828 } 10829 } 10830 10831 event.preventDefault(); 10832 event.stopPropagation(); 10833 break; 10834 } // Apply changes to update the UI 10835 10836 10837 if (!scope.$root.$$phase) { 10838 scope.$apply(); 10839 } 10840 }; 10841 10842 scope.onKeyDown = function (event) { 10843 // Check if this is a regular select or custom-select 10844 var isCustomSelect = attributes.control === 'custom-select'; 10845 var dropdown = isCustomSelect ? element[0].querySelector('.dropdown') : null; 10846 var options = scope.source ? scope.source.filter(function (item) { 10847 return !item.disabled; 10848 }) : []; // Handle keyboard navigation differently based on select type 10849 10850 if (isCustomSelect) { 10851 // Custom select keyboard handling 10852 switch (event.keyCode) { 10853 case 13: // Enter 10854 10855 case 32: 10856 // Space 10857 if (scope.dropdownVisible) { 10858 if (scope.highlightedIndex >= 0 && scope.highlightedIndex < options.length) { 10859 scope.updateModel(options[scope.highlightedIndex].id); 10860 scope.onChange(); 10861 scope.toggleDropdown(); 10862 } 10863 } else { 10864 // Flag that we're opening from keyboard to properly set focus on first option 10865 scope._openedFromKeyboard = true; // Toggling dropdown when Enter is pressed, just like when clicking with the mouse 10866 10867 scope.toggleDropdown(); // Ensure focus moves to the first option in the dropdown 10868 10869 setTimeout(function () { 10870 var dropdown = element[0].querySelector('.dropdown'); 10871 10872 if (dropdown) { 10873 var firstOption = dropdown.querySelector('li:not(.disabled)'); 10874 10875 if (firstOption) { 10876 firstOption.focus(); 10877 } 10878 } 10879 }, 100); // Force digest cycle to update the UI immediately 10880 10881 if (!scope.$root.$$phase) { 10882 scope.$apply(); 10883 } 10884 } 10885 10886 event.preventDefault(); 10887 break; 10888 10889 case 27: 10890 // Escape 10891 if (scope.dropdownVisible) { 10892 scope.toggleDropdown(); 10893 event.preventDefault(); 10894 } 10895 10896 break; 10897 10898 case 38: 10899 // Arrow Up 10900 if (scope.dropdownVisible) { 10901 if (scope.highlightedIndex <= 0) { 10902 scope.highlightedIndex = options.length - 1; 10903 } else { 10904 scope.highlightedIndex--; 10905 } // Ensure highlighted item is visible 10906 10907 10908 setTimeout(function () { 10909 var highlighted = dropdown.querySelector("li:nth-child(" + (scope.highlightedIndex + 1) + ")"); 10910 10911 if (highlighted) { 10912 highlighted.scrollIntoView({ 10913 block: 'nearest' 10914 }); 10915 } 10916 }, 0); 10917 event.preventDefault(); // Apply changes 10918 10919 if (!scope.$root.$$phase) { 10920 scope.$apply(); 10921 } 10922 } 10923 10924 break; 10925 10926 case 40: 10927 // Arrow Down 10928 if (scope.dropdownVisible) { 10929 if (scope.highlightedIndex >= options.length - 1) { 10930 scope.highlightedIndex = 0; 10931 } else { 10932 scope.highlightedIndex++; 10933 } // Ensure highlighted item is visible 10934 10935 10936 setTimeout(function () { 10937 var highlighted = dropdown.querySelector("li:nth-child(" + (scope.highlightedIndex + 1) + ")"); 10938 10939 if (highlighted) { 10940 highlighted.scrollIntoView({ 10941 block: 'nearest' 10942 }); 10943 } 10944 }, 0); 10945 event.preventDefault(); // Apply changes 10946 10947 if (!scope.$root.$$phase) { 10948 scope.$apply(); 10949 } 10950 } else { 10951 scope.toggleDropdown(); 10952 event.preventDefault(); 10953 } 10954 10955 break; 10956 10957 case 9: 10958 // Tab 10959 if (scope.dropdownVisible) { 10960 // When dropdown is open, and Tab is pressed on the main control, 10961 // focus the first option instead of closing the dropdown 10962 event.preventDefault(); // Prevent default tab behavior 10963 // Focus on the first non-disabled option 10964 10965 var firstOption = element[0].querySelector('li:not(.disabled)'); 10966 10967 if (firstOption) { 10968 scope.highlightedIndex = parseInt(firstOption.getAttribute('id').split('-').pop(), 10); 10969 firstOption.focus(); 10970 firstOption.scrollIntoView({ 10971 block: 'nearest' 10972 }); // Apply changes 10973 10974 if (!scope.$root.$$phase) { 10975 scope.$apply(); 10976 } 10977 } 10978 } // If dropdown is not visible, allow default tab behavior 10979 10980 10981 break; 10982 10983 default: 10984 // Handle first-letter navigation 10985 if (scope.dropdownVisible && event.key && event.key.length === 1) { 10986 var char = event.key.toLowerCase(); 10987 10988 var _loop = function _loop(i) { 10989 var option = options[i]; 10990 10991 if (option.name && option.name.toLowerCase().startsWith(char)) { 10992 scope.highlightedIndex = i; 10993 setTimeout(function () { 10994 var highlighted = dropdown.querySelector("li:nth-child(" + (i + 1) + ")"); 10995 10996 if (highlighted) { 10997 highlighted.scrollIntoView({ 10998 block: 'nearest' 10999 }); 11000 } 11001 }, 0); // Apply changes 11002 11003 if (!scope.$root.$$phase) { 11004 scope.$apply(); 11005 } 11006 11007 return "break"; 11008 } 11009 }; 11010 11011 for (var i = 0; i < options.length; i++) { 11012 var _ret = _loop(i); 11013 11014 if (_ret === "break") break; 11015 } 11016 } 11017 11018 break; 11019 } 11020 } else if (attributes.control === 'select') { 11021 // Regular select keyboard handling - most of it is handled natively by the browser, 11022 // but we need to ensure focus state and other behaviors are consistent 11023 switch (event.keyCode) { 11024 case 13: 11025 // Enter 11026 // Just ensure change event fires as expected 11027 scope.onChange(); 11028 break; 11029 11030 case 32: 11031 // Space 11032 // For native selects, space usually toggles the dropdown 11033 // Let the browser handle the default behavior 11034 break; 11035 11036 case 38: // Arrow Up 11037 11038 case 40: 11039 // Arrow Down 11040 // Let the browser handle the default navigation behavior 11041 // but update the focus state
11042 scope.focus = true; 11043 11044 if (!scope.$root.$$phase) { 11045 scope.$apply(); 11046 } 11047 11048 break; 11049 } 11050 } 11051 }; 11052 11053 scope.$on('onInvalid', function () { 11054 _this2.scrollToError(); 11055 }); 11056 }; 11057 11058 _proto.onError = function onError(element) { 11059 if (errorElements.indexOf(element) === -1) { 11060 errorElements.push(element); 11061 } 11062 }; 11063 11064 _proto.scrollToError = function scrollToError() { 11065 if (errorElements.length) { 11066 if (to) { 11067 clearTimeout(to); 11068 } 11069 11070 to = setTimeout(function () { 11071 var top = errorElements.reduce(function (previous, current, index, array) { 11072 var node = current[0]; 11073 return Math.min(previous, node.getBoundingClientRect().top); 11074 }, Number.POSITIVE_INFINITY); 11075 window.scrollTo(0, (document.body.scrollTop || document.documentElement.scrollTop) + top - 10); 11076 /* 11077 window.scroll({ 11078 top: (document.body.scrollTop || document.documentElement.scrollTop) + top - 10, 11079 left: 0, 11080 behavior: 'smooth' 11081 }); 11082 */ 11083 11084 errorElements = []; 11085 }, 100); 11086 } 11087 }; 11088 11089 _proto.link = function link(scope, element, attributes, controller) {}; 11090 11091 ControlDirective.factory = function factory($parse, DomService) { 11092 return new ControlDirective($parse, DomService); 11093 }; 11094 11095 return ControlDirective; 11096 }(); 11097 ControlDirective.factory.$inject = ['$parse', 'DomService']; 11098 11099 /* jshint esversion: 6 */ 11100 var ValidateDirective = /*#__PURE__*/function () { 11101 function ValidateDirective($filter) { 11102 this.$filter = $filter; 11103 this.require = 'ngModel'; 11104 } 11105 11106 var _proto = ValidateDirective.prototype; 11107 11108 _proto.link = function link(scope, element, attributes, model) { 11109 var type = attributes.validate; 11110 var format = attributes.format || ''; 11111 var precision = attributes.precision || 2; 11112 11113 switch (type) { 11114 case 'date': 11115 case 'datetime': 11116 case 'datetime-local': 11117 model.$formatters.push(function (value) { 11118 if (value) { 11119 return $filter('date')(value, format); 11120 } else { 11121 return null; 11122 } 11123 }); 11124 break; 11125 11126 case 'number': 11127 model.$parsers.unshift(function (value) { 11128 var valid = false; 11129 11130 if (value !== undefined && value !== "") { 11131 valid = String(value).indexOf(Number(value).toString()) !== -1; // isFinite(value); // 11132 11133 value = Number(value); 11134 model.$setValidity('number', valid); 11135 11136 if (valid) { 11137 model.$setValidity('positive', value >= 0.01); 11138 11139 if (attributes.min !== undefined) { 11140 model.$setValidity('range', value >= Number(attributes.min)); 11141 } 11142 11143 if (attributes.max !== undefined) { 11144 model.$setValidity('range', value <= Number(attributes.max)); 11145 } 11146 } 11147 } else { 11148 valid = true; 11149 value = Number(value); 11150 model.$setValidity('number', true); 11151 model.$setValidity('positive', true); 11152 11153 if (attributes.min !== undefined) { 11154 model.$setValidity('range', true); 11155 } 11156 11157 if (attributes.max !== undefined) { 11158 model.$setValidity('range', true); 11159 } 11160 } 11161 11162 return value; 11163 }); 11164 model.$formatters.push(function (value) { 11165 if (value) { 11166 return $filter('number')(value, precision) + ' ' + format; 11167 } else { 11168 return null; 11169 } 11170 }); 11171 break; 11172 11173 case 'anynumber': 11174 model.$parsers.unshift(function (value) { 11175 var valid = false; 11176 11177 if (value !== undefined && value !== "") { 11178 valid = String(value).indexOf(Number(value).toString()) !== -1; // isFinite(value); // 11179 11180 value = Number(value); 11181 model.$setValidity('number', valid); 11182 11183 if (valid) { 11184 if (attributes.min !== undefined) { 11185 model.$setValidity('range', value >= Number(attributes.min)); 11186 } 11187 11188 if (attributes.max !== undefined) { 11189 model.$setValidity('range', value <= Number(attributes.max)); 11190 } 11191 } 11192 } else { 11193 valid = true; 11194 value = Number(value); 11195 model.$setValidity('number', true); 11196 11197 if (attributes.min !== undefined) { 11198 model.$setValidity('range', true); 11199 } 11200 11201 if (attributes.max !== undefined) { 11202 model.$setValidity('range', true); 11203 } 11204 } 11205 11206 return value; 11207 }); 11208 model.$formatters.push(function (value) { 11209 if (value || value === 0) { 11210 return $filter('number')(value, precision) + ' ' + format; 11211 } else { 11212 return null; 11213 } 11214 }); 11215 break; 11216 } 11217 11218 var onFocus = function onFocus() { 11219 11220 if (format) { 11221 element[0].value = model.$modelValue || null; 11222 11223 if (!model.$modelValue) { 11224 model.$setViewValue(null); 11225 } 11226 } 11227 }; 11228 11229 var doBlur = function doBlur() {
11230 if (format && !model.$invalid) { 11231 switch (type) { 11232 case 'date': 11233 case 'datetime': 11234 case 'datetime-local': 11235 element[0].value = model.$modelValue ? $filter('date')(model.$modelValue, format) : ' '; 11236 break; 11237 11238 default: 11239 element[0].value = model.$modelValue ? $filter('number')(model.$modelValue, precision) + ' ' + format : ' '; 11240 break; 11241 } 11242 } 11243 }; 11244 11245 var onBlur = function onBlur() { 11246 doBlur(); 11247 }; 11248 11249 var addListeners = function addListeners() { 11250 element.on('focus', onFocus); 11251 element.on('blur', onBlur); 11252 }; 11253 11254 var removeListeners = function removeListeners() { 11255 element.off('focus', onFocus); 11256 element.off('blur', onBlur); 11257 }; 11258 11259 scope.$on('$destroy', function () { 11260 removeListeners(); 11261 }); 11262 addListeners(); 11263 }; 11264 11265 ValidateDirective.factory = function factory($filter) { 11266 return new ValidateDirective($filter); 11267 }; 11268 11269 return ValidateDirective; 11270 }(); 11271 ValidateDirective.factory.$inject = ['$filter']; 11272 11273 /* jshint esversion: 6 */ 11274 11275 var GalleryCtrl = /*#__PURE__*/function () { 11276 function GalleryCtrl($scope, $timeout, $element) { 11277 this.$scope = $scope; 11278 this.$timeout = $timeout; 11279 this.$element = $element; 11280 this.types = GALLERY_TYPES; 11281 var node = $element[0]; 11282 TweenMax.set(node, { 11283 // opacity: 0, 11284 // overflow: 'hidden', 11285 height: 0 11286 }); 11287 TweenMax.to(node, 0.6, { 11288 // opacity: 1, 11289 height: '100%', 11290 delay: 0.1, 11291 ease: Power2.easeInOut, 11292 onComplete: function onComplete() { 11293 node.setAttribute('style', ''); 11294 setTimeout(function () {// video ??? 11295 11296 /* 11297 const items = Array.prototype.slice.call(node.querySelectorAll('.picture')); 11298 const item = items[$scope.$root.galleryIndex]; 11299 // console.log(items, item, $scope.$root.galleryIndex); 11300 if (item) { 11301 const rect = Rect.fromNode(item); 11302 node.scrollTo(0, rect.top - 70); 11303 } 11304 */ 11305 }, 1500); 11306 } 11307 }); 11308 } 11309 11310 var _proto = GalleryCtrl.prototype; 11311 11312 _proto.onClose = function onClose() { 11313 var _this = this; 11314 11315 var node = this.$element[0]; 11316 TweenMax.set(node, { 11317 // opacity: 1, 11318 // overflow: 'hidden', 11319 height: '100%' 11320 }); 11321 TweenMax.to(node, 0.6, { 11322 // opacity: 0, 11323 height: 0, 11324 delay: 0.1, 11325 ease: Power2.easeInOut, 11326 onComplete: function onComplete() { 11327 _this.$timeout(function () { 11328 _this.$scope.$root.gallery = null; 11329 }); 11330 } 11331 }); 11332 }; 11333 11334 return GalleryCtrl; 11335 }(); 11336 11337 GalleryCtrl.$inject = ['$scope', '$timeout', '$element']; 11338 11339 function t() {} 11340 11341 t.prototype = { 11342 on: function on(t, e, r) { 11343 var i = this.e || (this.e = {}); 11344 return (i[t] || (i[t] = [])).push({ 11345 fn: e, 11346 ctx: r 11347 }), this; 11348 }, 11349 once: function once(t, e, r) { 11350 var i = this; 11351 11352 function n() { 11353 i.off(t, n), e.apply(r, arguments); 11354 } 11355 11356 return n._ = e, this.on(t, n, r); 11357 }, 11358 emit: function emit(t) { 11359 for (var e = [].slice.call(arguments, 1), r = ((this.e || (this.e = {}))[t] || []).slice(), i = 0, n = r.length; i < n; i++) { 11360 r[i].fn.apply(r[i].ctx, e); 11361 } 11362 11363 return this; 11364 }, 11365 off: function off(t, e) { 11366 var r = this.e || (this.e = {}), 11367 i = r[t], 11368 n = []; 11369 if (i && e) for (var o = 0, s = i.length; o < s; o++) { 11370 i[o].fn !== e && i[o].fn._ !== e && n.push(i[o]); 11371 } 11372 return n.length ? r[t] = n : delete r[t], this; 11373 } 11374 }; 11375 var e = t; 11376 e.TinyEmitter = t; 11377 11378 var r = function r(t) { 11379 this.wrap = document.querySelector("[data-router-wrapper]"), this.properties = t, this.Transition = t.transition ? new t.transition.class(this.wrap, t.transition.name) : null; 11380 }; 11381 11382 r.prototype.setup = function () { 11383 this.onEnter && this.onEnter(), this.onEnterCompleted && this.onEnterCompleted(); 11384 }, r.prototype.add = function () { 11385 this.wrap.insertAdjacentHTML("beforeend", this.properties.view.outerHTML); 11386 }, r.prototype.update = function () { 11387 document.title = this.properties.page.title; 11388 }, r.prototype.show = function (t) { 11389 var e = this; 11390 return new Promise(function (r) { 11391 try { 11392 var _i = function _i(t) { 11393 e.onEnterCompleted && e.onEnterCompleted(), r(); 11394 }; 11395
11396 return e.update(), e.onEnter && e.onEnter(), Promise.resolve(e.Transition ? Promise.resolve(e.Transition.show(t)).then(_i) : _i()); 11397 } catch (t) { 11398 return Promise.reject(t); 11399 } 11400 }); 11401 }, r.prototype.hide = function (t) { 11402 var e = this; 11403 return new Promise(function (r) { 11404 try { 11405 var _i2 = function _i2(t) { 11406 e.onLeaveCompleted && e.onLeaveCompleted(), r(); 11407 }; 11408 11409 return e.onLeave && e.onLeave(), Promise.resolve(e.Transition ? Promise.resolve(e.Transition.hide(t)).then(_i2) : _i2()); 11410 } catch (t) { 11411 return Promise.reject(t); 11412 } 11413 }); 11414 }; 11415 11416 var i$1 = new window.DOMParser(), 11417 n = function n(t, e) { 11418 this.renderers = t, this.transitions = e; 11419 }; 11420 11421 n.prototype.getOrigin = function (t) { 11422 var e = t.match(/(https?:\/\/[\w\-.]+)/); 11423 return e ? e[1].replace(/https?:\/\//, "") : null; 11424 }, n.prototype.getPathname = function (t) { 11425 var e = t.match(/https?:\/\/.*?(\/[\w_\-./]+)/); 11426 return e ? e[1] : "/"; 11427 }, n.prototype.getAnchor = function (t) { 11428 var e = t.match(/(#.*)$/); 11429 return e ? e[1] : null; 11430 }, n.prototype.getParams = function (t) { 11431 var e = t.match(/\?([\w_\-.=&]+)/); 11432 if (!e) return null; 11433 11434 for (var r = e[1].split("&"), i = {}, n = 0; n < r.length; n++) { 11435 var o = r[n].split("="); 11436 i[o[0]] = o[1]; 11437 } 11438 11439 return i; 11440 }, n.prototype.getDOM = function (t) { 11441 return "string" == typeof t ? i$1.parseFromString(t, "text/html") : t; 11442 }, n.prototype.getView = function (t) { 11443 return t.querySelector("[data-router-view]"); 11444 }, n.prototype.getSlug = function (t) { 11445 return t.getAttribute("data-router-view"); 11446 }, n.prototype.getRenderer = function (t) { 11447 if (!this.renderers) return Promise.resolve(r); 11448 11449 if (t in this.renderers) { 11450 var e = this.renderers[t]; 11451 return "function" != typeof e || r.isPrototypeOf(e) ? "function" == typeof e.then ? Promise.resolve(e).then(function (t) { 11452 return t.default; 11453 }) : Promise.resolve(e) : Promise.resolve(e()).then(function (t) { 11454 return t.default; 11455 }); 11456 } 11457 11458 return Promise.resolve(r); 11459 }, n.prototype.getTransition = function (t) { 11460 return this.transitions ? t in this.transitions ? {
11461 class: this.transitions[t], 11462 name: t 11463 } : "default" in this.transitions ? { 11464 class: this.transitions.default, 11465 name: "default" 11466 } : null : null; 11467 }, n.prototype.getProperties = function (t) { 11468 var e = this.getDOM(t), 11469 r = this.getView(e), 11470 i = this.getSlug(r); 11471 return { 11472 page: e, 11473 view: r, 11474 slug: i, 11475 renderer: this.getRenderer(i, this.renderers), 11476 transition: this.getTransition(i, this.transitions) 11477 }; 11478 }, n.prototype.getLocation = function (t) { 11479 return { 11480 href: t, 11481 anchor: this.getAnchor(t), 11482 origin: this.getOrigin(t), 11483 params: this.getParams(t), 11484 pathname: this.getPathname(t) 11485 }; 11486 }; 11487 11488 var o = function (t) { 11489 function e(e) { 11490 var r = this; 11491 void 0 === e && (e = {}); 11492 var i = e.renderers, 11493 o = e.transitions; 11494 t.call(this), this.Helpers = new n(i, o), this.Transitions = o, this.Contextual = !1, this.location = this.Helpers.getLocation(window.location.href), this.properties = this.Helpers.getProperties(document.cloneNode(!0)), this.popping = !1, this.running = !1, this.trigger = null, this.cache = new Map(), this.cache.set(this.location.href, this.properties), this.properties.renderer.then(function (t) { 11495 r.From = new t(r.properties), r.From.setup(); 11496 }), this._navigate = this.navigate.bind(this), window.addEventListener("popstate", this.popState.bind(this)), this.links = document.querySelectorAll("a:not([target]):not([data-router-disabled])"), this.attach(this.links); 11497 } 11498 11499 return t && (e.__proto__ = t), (e.prototype = Object.create(t && t.prototype)).constructor = e, e.prototype.attach = function (t) { 11500 for (var e = 0, r = t; e < r.length; e += 1) { 11501 r[e].addEventListener("click", this._navigate); 11502 } 11503 }, e.prototype.detach = function (t) { 11504 for (var e = 0, r = t; e < r.length; e += 1) { 11505 r[e].removeEventListener("click", this._navigate); 11506 } 11507 }, e.prototype.navigate = function (t) { 11508 if (!t.metaKey && !t.ctrlKey) { 11509 t.preventDefault(); 11510 var e = !!t.currentTarget.hasAttribute("data-transition") && t.currentTarget.dataset.transition; 11511 this.redirect(t.currentTarget.href, e, t.currentTarget); 11512 } 11513 }, e.prototype.redirect = function (t, e, r) { 11514 if (void 0 === e && (e = !1), void 0 === r && (r = "script"), this.trigger = r, !this.running && t !== this.location.href) { 11515 var i = this.Helpers.getLocation(t); 11516 this.Contextual = !1, e && (this.Contextual = this.Transitions.contextual[e].prototype, this.Contextual.name = e), i.origin !== this.location.origin || i.anchor && i.pathname === this.location.pathname ? window.location.href = t : (this.location = i, this.beforeFetch()); 11517 } 11518 }, e.prototype.popState = function () { 11519 this.trigger = "popstate", this.Contextual = !1; 11520 var t = this.Helpers.getLocation(window.location.href); 11521 this.location.pathname !== t.pathname || !this.location.anchor && !t.anchor ? (this.popping = !0, this.location = t, this.beforeFetch()) : this.location = t; 11522 }, e.prototype.pushState = function () { 11523 this.popping || window.history.pushState(this.location, "", this.location.href); 11524 }, e.prototype.fetch = function () { 11525 try { 11526 var t = this; 11527 return Promise.resolve(fetch(t.location.href, { 11528 mode: "same-origin", 11529 method: "GET", 11530 headers: { 11531 "X-Requested-With": "Highway" 11532 }, 11533 credentials: "same-origin" 11534 })).then(function (e) { 11535 if (e.status >= 200 && e.status < 300) return e.text(); 11536 window.location.href = t.location.href; 11537 }); 11538 } catch (t) { 11539 return Promise.reject(t); 11540 } 11541 }, e.prototype.beforeFetch = function () { 11542 try { 11543 var _e = function _e() { 11544 t.afterFetch(); 11545 }; 11546 11547 var t = this; 11548 t.pushState(), t.running = !0, t.emit("NAVIGATE_OUT", { 11549 from: { 11550 page: t.From.properties.page, 11551 view: t.From.properties.view 11552 }, 11553 trigger: t.trigger, 11554 location: t.location 11555 }); 11556 var r = { 11557 trigger: t.trigger, 11558 contextual: t.Contextual 11559 }, 11560 i = t.cache.has(t.location.href) ? Promise.resolve(t.From.hide(r)).then(function () { 11561 t.properties = t.cache.get(t.location.href); 11562 }) : Promise.resolve(Promise.all([t.fetch(), t.From.hide(r)])).then(function (e) {
11563 t.properties = t.Helpers.getProperties(e[0]), t.cache.set(t.location.href, t.properties); 11564 }); 11565 return Promise.resolve(i && i.then ? i.then(_e) : _e()); 11566 } catch (t) { 11567 return Promise.reject(t); 11568 } 11569 }, e.prototype.afterFetch = function () { 11570 try { 11571 var t = this; 11572 return Promise.resolve(t.properties.renderer).then(function (e) { 11573 return t.To = new e(t.properties), t.To.add(), t.emit("NAVIGATE_IN", { 11574 to: { 11575 page: t.To.properties.page, 11576 view: t.To.wrap.lastElementChild 11577 }, 11578 trigger: t.trigger, 11579 location: t.location 11580 }), Promise.resolve(t.To.show({ 11581 trigger: t.trigger, 11582 contextual: t.Contextual 11583 })).then(function () { 11584 t.popping = !1, t.running = !1, t.detach(t.links), t.links = document.querySelectorAll("a:not([target]):not([data-router-disabled])"), t.attach(t.links), t.emit("NAVIGATE_END", { 11585 to: { 11586 page: t.To.properties.page, 11587 view: t.To.wrap.lastElementChild 11588 }, 11589 from: { 11590 page: t.From.properties.page, 11591 view: t.From.properties.view 11592 }, 11593 trigger: t.trigger, 11594 location: t.location 11595 }), t.From = t.To, t.trigger = null; 11596 }); 11597 }); 11598 } catch (t) { 11599 return Promise.reject(t); 11600 } 11601 }, e; 11602 }(e), 11603 s = function s(t, e) { 11604 this.wrap = t, this.name = e; 11605 }; 11606 11607 s.prototype.show = function (t) { 11608 var e = this, 11609 r = t.trigger, 11610 i = t.contextual, 11611 n = this.wrap.lastElementChild, 11612 o = this.wrap.firstElementChild; 11613 return new Promise(function (t) { 11614 i ? (n.setAttribute("data-transition-in", i.name), n.removeAttribute("data-transition-out", i.name), i.in && i.in({ 11615 to: n, 11616 from: o, 11617 trigger: r, 11618 done: t 11619 })) : (n.setAttribute("data-transition-in", e.name), n.removeAttribute("data-transition-out", e.name), e.in && e.in({ 11620 to: n, 11621 from: o, 11622 trigger: r, 11623 done: t 11624 })); 11625 }); 11626 }, s.prototype.hide = function (t) { 11627 var e = this, 11628 r = t.trigger, 11629 i = t.contextual, 11630 n = this.wrap.firstElementChild; 11631 return new Promise(function (t) { 11632 i ? (n.setAttribute("data-transition-out", i.name), n.removeAttribute("data-transition-in", i.name), i.out && i.out({ 11633 from: n, 11634 trigger: r, 11635 done: t 11636 })) : (n.setAttribute("data-transition-out", e.name), n.removeAttribute("data-transition-in", e.name), e.out && e.out({ 11637 from: n, 11638 trigger: r, 11639 done: t 11640 })); 11641 }); 11642 }, console.log("Highway v2.2.0"); 11643 var Highway = { 11644 Core: o, 11645 Helpers: n, 11646 Renderer: r, 11647 Transition: s 11648 }; 11649 11650 var first$2 = true, 11651 $newScope; 11652 11653 var CustomRenderer = /*#__PURE__*/function (_Highway$Renderer) { 11654 _inheritsLoose(CustomRenderer, _Highway$Renderer); 11655 11656 function CustomRenderer() { 11657 return _Highway$Renderer.apply(this, arguments) || this; 11658 } 11659 11660 var _proto = CustomRenderer.prototype; 11661 11662 // Definisci la funzione isValidJson all'interno della classe 11663 _proto.isValidJson = function isValidJson(str) { 11664 try { 11665 JSON.parse(str); 11666 } catch (e) { 11667 return false; 11668 } 11669 11670 return true; 11671 }; 11672 11673 _proto.update = function update() { 11674 document.title = this.properties.page.title; 11675 var page = this.properties.page; 11676 this.updateCanonical(page); 11677 var body = page.querySelector('body'); 11678 document.querySelector('body').setAttribute('class', body.getAttribute('class')); 11679 }; 11680 11681 _proto.updateCanonical = function updateCanonical(page) { 11682 var head = document.querySelector('head'); 11683 Array.from(head.querySelectorAll('[rel="canonical"], [rel="alternate"]')).forEach(function (node) { 11684 return node.parentNode.removeChild(node); 11685 }); 11686 var pageHead = page.querySelector('head'); 11687 Array.from(pageHead.querySelectorAll('[rel="canonical"], [rel="alternate"]')).forEach(function (node) { 11688 head.appendChild(node); 11689 11690 if (node.hasAttribute('hreflang')) { 11691 var target = document.querySelector("[hreflang-target=\"" + node.getAttribute('hreflang') + "\"]"); 11692 11693 if (target) { 11694 target.href = node.href; 11695 } 11696 } 11697 }); 11698 }; 11699 11700 _proto.onEnter = function onEnter() { 11701 var _this = this; 11702 11703 if (!first$2) { 11704 var $timeout = CustomRenderer.$timeout; 11705 $timeout(function () { 11706 var $compile = CustomRenderer.$compile; 11707 var view = Array.prototype.slice.call(document.querySelectorAll('.view')).pop(); // Usa la funzione isValidJson definita all'interno della classe 11708 11709 var gtmSetupData = view.dataset.gtmSetup; 11710 11711 if (_this.isValidJson(gtmSetupData)) { 11712 GtmService.pageSetup(JSON.parse(gtmSetupData)); 11713 } else { 11714 console.error("Invalid JSON data in view.dataset.gtmSetup:", gtmSetupData); 11715 } 11716 11717 var element = angular.element(view.childNodes); 11718 CustomRenderer.scope.root.menuOpened = false;
11719 CustomRenderer.scope.root.menuProductOpened = false; 11720 11721 if ($newScope) { 11722 $newScope.$destroy(); 11723 } 11724 11725 $newScope = CustomRenderer.scope.$new(); 11726 var content = $compile(element)($newScope); 11727 CustomRenderer.$newScope = $newScope; 11728 CustomRenderer.content = content; 11729 GtmService.pageView(); 11730 $newScope.$on('$destroy', function (event) { 11731 console.log('.view -> $destroy', event); 11732 }); 11733 }); 11734 } 11735 }; 11736 11737 _proto.onLeave = function onLeave() { 11738 if (first$2) { 11739 first$2 = false; 11740 var view = Array.prototype.slice.call(document.querySelectorAll('.view')).shift(); 11741 var element = angular.element(view.childNodes); 11742 element.on('$destroy', function (event) { 11743 console.log('.view -> $destroy', event); 11744 }); 11745 } 11746 }; 11747 11748 _proto.onEnterCompleted = function onEnterCompleted() {// Metodo vuoto, puoi aggiungere logica se necessario 11749 }; 11750 11751 _proto.onLeaveCompleted = function onLeaveCompleted() {// Metodo vuoto, puoi aggiungere logica se necessario 11752 }; 11753 11754 CustomRenderer.$destroy = function $destroy(from) { 11755 if (CustomRenderer.scope && CustomRenderer.scope.$root && CustomRenderer.scope.$root.first) { 11756 CustomRenderer.$timeout(function () { 11757 CustomRenderer.scope.$root.first = null; 11758 }); 11759 } else { 11760 if (this.content && this.content.parentNode) { 11761 this.content.parentNode.removeChild(this.content); 11762 this.content = null; 11763 } 11764 11765 if (this.$newScope) { 11766 this.$newScope.$destroy(); 11767 this.$newScope = null; 11768 } 11769 11770 if (from.parentNode) { 11771 from.parentNode.removeChild(from); 11772 } 11773 } 11774 }; 11775 11776 CustomRenderer.collectScopes = function collectScopes(scope, scopes) { 11777 scopes = scopes || []; 11778 11779 if (scope) { 11780 var child = scope && scope.$$childHead; 11781 11782 while (child) { 11783 scopes.push(child); 11784 scopes = this.collectScopes(child, scopes); 11785 child = child.$$nextSibling; 11786 } 11787 } 11788 11789 return scopes; 11790 }; 11791 11792 return CustomRenderer; 11793 }(Highway.Renderer); 11794 11795 var PageTransition = /*#__PURE__*/function (_Highway$Transition) { 11796 _inheritsLoose(PageTransition, _Highway$Transition); 11797 11798 function PageTransition() { 11799 return _Highway$Transition.apply(this, arguments) || this; 11800 } 11801 11802 var _proto = PageTransition.prototype; 11803 11804 _proto.in = function _in(_ref) { 11805 var from = _ref.from, 11806 to = _ref.to, 11807 done = _ref.done; 11808 var preloader = document.querySelector('.preloader'); 11809 TweenMax.to(preloader, 0.3, { 11810 opacity: 0, 11811 visibility: 'hidden' 11812 }); // console.log('PageTransition.in'); 11813 11814 TweenMax.set(to, { 11815 opacity: 0, 11816 minHeight: from.offsetHeight 11817 }); 11818 window.scrollTo(0, 0); 11819 CustomRenderer.$destroy(from); 11820 TweenMax.to(to, 0.6, { 11821 opacity: 1, 11822 delay: 0.250, 11823 overwrite: 'all', 11824 onComplete: function onComplete() { 11825 setTimeout(function () { 11826 TweenMax.set(to, { 11827 minHeight: 0 11828 }); 11829 done(); 11830 }, 50); 11831 } 11832 }); 11833 }; 11834 11835 _proto.out = function out(_ref2) { 11836 var from = _ref2.from, 11837 done = _ref2.done; 11838 // console.log('PageTransition.out'); 11839 var preloader = document.querySelector('.preloader'); 11840 TweenMax.to(preloader, 0.3, { 11841 opacity: 1, 11842 visibility: 'visible' 11843 }); 11844 var headerMenu = document.querySelector('.header__menu'); 11845 11846 if (headerMenu) { 11847 headerMenu.classList.remove('opened'); 11848 } 11849 11850 TweenMax.to(from, 0.6, { 11851 opacity: 0, 11852 delay: 0.150, 11853 overwrite: 'all', 11854 onComplete: function onComplete() { 11855 setTimeout(done, 500); 11856 } 11857 }); 11858 }; 11859 11860 return PageTransition; 11861 }(Highway.Transition); 11862 11863 /* jshint esversion: 6 */ 11864 // See: https://github.com/GoogleChromeLabs/quicklink 11865 // import Quicklink from 'quicklink/dist/quicklink.mjs'; 11866 11867 var HighwayDirective = /*#__PURE__*/function () { 11868 function HighwayDirective($compile, $timeout) { 11869 this.$compile = $compile; 11870 this.$timeout = $timeout; 11871 this.restrict = 'A'; 11872 this.link$ = new Subject(); 11873 } 11874 11875 var _proto = HighwayDirective.prototype; 11876 11877 _proto.onLink$ = function onLink$() { 11878 return this.link$.pipe(debounceTime(50)); 11879 }; 11880 11881 _proto.link = function link(scope, element, attributes, controller) { 11882 var _this = this; 11883 11884 this.$timeout(function () { 11885 _this.init(scope, element, attributes, controller); 11886 }); 11887 }; 11888 11889 _proto.init = function init(scope, element, attributes, controller) { 11890 var _this2 = this; 11891 11892 CustomRenderer.$compile = this.$compile; 11893 CustomRenderer.$timeout = this.$timeout; 11894 CustomRenderer.scope = scope; 11895 var H = new Highway.Core({ 11896 renderers: { 11897 view: CustomRenderer 11898 }, 11899 transitions: { 11900 view: PageTransition 11901 } 11902 }); 11903 this.H = H; 11904 CustomRenderer.H = H; 11905 scope.$on('onHrefNode', function ($scope, node) { 11906 _this2.link$.next(); 11907 }); 11908 var subscription = this.onLink$().subscribe(function (x) { 11909 H.detach(H.links); 11910 var links = document.querySelectorAll('a:not([target]):not([data-router-disabled])'); 11911 H.links = links; 11912 H.attach(links); 11913 }); 11914 var properties = H.cache.get(H.location.href); 11915 properties.view = scope.$root.firstView; 11916 H.cache.set(H.location.href, properties); 11917 H.on('NAVIGATE_OUT', function (_ref) { 11918 var to = _ref.to, 11919 trigger = _ref.trigger, 11920 location = _ref.location; 11921 scope.$broadcast('onNavigateOut', location); 11922 }); 11923 H.on('NAVIGATE_IN', function (_ref2) { 11924 var to = _ref2.to, 11925 trigger = _ref2.trigger, 11926 location = _ref2.location; 11927 H.detach(H.links); 11928 }); 11929 H.on('NAVIGATE_END', function (_ref3) { 11930 var location = _ref3.location; 11931 11932 if (location.anchor) { 11933 // console.log('location.anchor', location.anchor); 11934 setTimeout(function () { 11935 var element = document.querySelector(location.anchor); 11936 11937 if (element) { 11938 window.scrollTo(0, element.offsetTop); 11939 } 11940 }, 1); 11941 } 11942 }); 11943 scope.$on('$destroy', function () { 11944 subscription.unsubscribe(); 11945 }); 11946 GtmService.pageView(); 11947 }; 11948 11949 HighwayDirective.factory = function factory($compile, $timeout) { 11950 return new HighwayDirective($compile, $timeout); 11951 }; 11952 11953 return HighwayDirective; 11954 }(); 11955 HighwayDirective.factory.$inject = ['$compile', '$timeout']; 11956 11957 /* jshint esversion: 6 */ 11958 var MoodboardDropdownDirective = /*#__PURE__*/function () { 11959 function MoodboardDropdownDirective($compile) { 11960 this.$compile = $compile; 11961 this.restrict = 'A'; 11962 this.template = "\n<span has-dropdown=\".moodboard__value\">\n\t<span class=\"dropdown\">\n\t\t<ul class=\"nav nav--select\">\n\t\t\t<li ng-repeat=\"item in filter.options track by $index\" ng-class=\"{ active: filter.value == item.value, disabled: item.disabled }\">\n\t\t\t\t<span class=\"option\" ng-class=\"{ 'option--picture': item.image }\" ng-click=\"setFilter(item, filter)\">\n\t\t\t\t\t<img ng-src=\"{{item.image}}\" ng-if=\"item.image\" />\n\t\t\t\t\t<span ng-bind=\"item.label\"></span>\n\t\t\t\t</span>\n\t\t\t</li>\n\t\t</ul>
11962\n\t</span>\n\t<span class=\"moodboard__value\" ng-class=\"{ active: filter.value }\">\n\t\t<span class=\"moodboard__underline\"></span>\n\t\t<span class=\"moodboard__text\">{{filter.placeholder}}</span>\n\t</span>\n</span>\n"; // this.require = 'ngModel'; 11963 11964 this.scope = { 11965 filter: '=?moodboardDropdown' 11966 }; 11967 } 11968 11969 var _proto = MoodboardDropdownDirective.prototype; 11970 11971 _proto.link = function link(scope, element, attributes, controller) { 11972 var _this = this; 11973 11974 // console.log('MoodboardDropdownDirective', this.filter); 11975 var filter = scope.filter; 11976 11977 if (filter.value) { 11978 filter.placeholder = filter.options.find(function (x) { 11979 return x.value === filter.value; 11980 }).label; 11981 } 11982 11983 scope.setFilter = function (item, filter) { 11984 item = item || filter.options[0]; 11985 filter.value = item.value; 11986 filter.placeholder = item.label; 11987 11988 if (typeof filter.doFilter === 'function') { 11989 filter.doFilter(item, item.value); 11990 } 11991 11992 scope.$broadcast('onCloseDropdown'); 11993 }; 11994 11995 scope.removeFilter = function (filter) { 11996 _this.setFilter(null, filter); 11997 }; 11998 11999 scope.$on('$destroy', function () {}); 12000 }; 12001 12002 MoodboardDropdownDirective.factory = function factory($compile) { 12003 return new MoodboardDropdownDirective($compile); 12004 }; 12005 12006 return MoodboardDropdownDirective; 12007 }(); 12008 MoodboardDropdownDirective.factory.$inject = ['$compile']; 12009 12010 /* jshint esversion: 6 */ 12011 var MoodboardSearchDirective = /*#__PURE__*/function () { 12012 function MoodboardSearchDirective($compile) { 12013 this.$compile = $compile; 12014 this.restrict = 'A'; 12015 this.scope = { 12016 filters: '=moodboardSearch', 12017 model: '=model' 12018 }; 12019 } 12020 12021 var _proto = MoodboardSearchDirective.prototype; 12022 12023 _proto.link = function link(scope, element, attributes, controller) { 12024 var _this = this; 12025 12026 scope.filters = scope.filters || {}; 12027 var node = element[0]; 12028 var html = node.innerText; 12029 var keys = Object.keys(scope.filters); 12030 keys.forEach(function (x) { 12031 // console.log(x); 12032 html = html.replace("$" + x + "$", "<span class=\"moodboard__dropdown " + x + "\" moodboard-dropdown=\"filters." + x + "\" ng-click=\"animateOff()\"></span>"); 12033 }); // console.log('MoodboardSearchDirective', html); 12034 12035 node.innerHTML = html; 12036 this.$compile(element.contents())(scope); 12037 var hasFilter = Object.keys(scope.filters).map(function (x) { 12038 return scope.filters[x]; 12039 }).find(function (x) { 12040 return x.value !== null; 12041 }) !== undefined; 12042 12043 if (!hasFilter) { 12044 this.animateUnderlines(node); 12045 } 12046 12047 scope.animateOff = function () { 12048 _this.animateOff(node); 12049 }; 12050 12051 scope.$on('$destroy', function () {}); 12052 }; 12053 12054 _proto.animateUnderlines = function animateUnderlines(node) { 12055 this.animated = true; 12056 var values = Array.prototype.slice.call(node.querySelectorAll('.moodboard__underline')); 12057 values.forEach(function (x) { 12058 TweenMax.set(x, { 12059 transformOrigin: '0 50%', 12060 scaleX: 0 12061 }); 12062 }); 12063 var i = -1; 12064 12065 var animate = function animate() { 12066 i++; 12067 i = i % values.length; 12068 var u = values[i]; 12069 TweenMax.set(u, { 12070 transformOrigin: '0 50%', 12071 scaleX: 0 12072 }); 12073 TweenMax.to(u, 0.50, { 12074 scaleX: 1, 12075 transformOrigin: '0 50%', 12076 delay: 0, 12077 ease: Power3.easeInOut, 12078 overwrite: 'all', 12079 onComplete: function onComplete() { 12080 TweenMax.set(u, { 12081 transformOrigin: '100% 50%', 12082 scaleX: 1 12083 }); 12084 TweenMax.to(u, 0.50, { 12085 scaleX: 0, 12086 transformOrigin: '100% 50%', 12087 delay: 1.0, 12088 ease: Power3.easeInOut, 12089 overwrite: 'all', 12090 onComplete: function onComplete() { 12091 animate(); 12092 } 12093 }); 12094 } 12095 }); 12096 }; 12097 12098 animate(); 12099 }; 12100 12101 _proto.animateOff = function animateOff(node) { 12102 if (this.animated) { 12103 this.animated = false; // console.log('animateOff'); 12104 // TweenMax.killAll(); 12105 12106 var values = Array.prototype.slice.call(node.querySelectorAll('.moodboard__underline')); 12107 TweenMax.set(values, { 12108 transformOrigin: '0 50%', 12109 scaleX: 0 12110 }); 12111 TweenMax.to(values, 0.50, { 12112 scaleX: 1, 12113 transformOrigin: '0 50%', 12114 delay: 0, 12115 ease: Power3.easeInOut, 12116 overwrite: 'all' 12117 }); 12118 } 12119 }; 12120 12121 MoodboardSearchDirective.factory = function factory($compile) { 12122 return new MoodboardSearchDirective($compile); 12123 }; 12124 12125 return MoodboardSearchDirective; 12126 }(); 12127 MoodboardSearchDirective.factory.$inject = ['$compile']; 12128 12129 /* jshint esversion: 6 */ 12130 12131 var NewsletterCtrl = /*#__PURE__*/function () { 12132 function NewsletterCtrl($scope, $location, $timeout, $http, StateService) { 12133 this.$scope = $scope; 12134 this.$location = $location; 12135 this.$timeout = $timeout; 12136 this.$http = $http; 12137 this.data = window.data || {}; 12138 this.model = {}; 12139 12140 if (this.$location.search() && this.$location.search().email) { 12141 this.model.email = this.$location.search().email; 12142 } 12143 12144 this.state = StateService.getState(); 12145 this.state.ready(); 12146 } 12147 12148 var _proto = NewsletterCtrl.prototype; 12149 12150 _proto.setProvinces = function setProvinces() { 12151 var _this = this; 12152 12153 this.$timeout(function () { 12154 _this.provinces = _this.data.provinces.filter(function (x) { 12155 return x.countryId === _this.model.Nazione; 12156 }); 12157 }); 12158 }; 12159 12160 _proto.onSubmit = function onSubmit() { 12161 var _this2 = this; 12162 12163 var inputCaptcha = document.getElementById('g-recaptcha-response'); 12164 12165 if (inputCaptcha) { 12166 this.model.Captcha = inputCaptcha.value; 12167 } else { 12168 this.model.Captcha = ''; 12169 } 12170 12171 console.log('NewsletterCtrl.onSubmit', this.model); 12172 12173 if (this.state.busy()) { 12174 this.$http.post('/WS/wsUsers.asmx/NewsletterSubscribe', { 12175 data: this.model 12176 }).then(function (success) { 12177 if (success.data.d.Status) { 12178 _this2.state.success(); //NewsletterSubscribe 12179 12180 12181 var obj = Object.assign({}, window.objDataLayerInfo); 12182 obj["eventname"] = "newsletter_subscription_ok"; 12183 GtmService.push(obj); //GtmService.push({"event": "Action Complete"}); 12184 } else { 12185 _this2.state.error(); 12186 } 12187 }, function (error) { 12188 _this2.error = error; 12189 }); 12190 this.$timeout(function () {// this.state.ready(); 12191 }, 2000); 12192 } 12193 }; 12194 12195 _proto.onNewsletter = function onNewsletter() { 12196 console.log('NewsletterCtrl.onNewsletter', this.model); 12197 var obj = Object.assign({}, window.objDataLayerInfo); 12198 obj["eventname"] = "newsletter_subscription_start"; 12199 GtmService.push(obj); 12200 window.location.href = this.newsletterHref + "?email=" + this.model.email; 12201 }; 12202 12203 _proto.onInvalid = function onInvalid() { 12204 this.$scope.$broadcast('onInvalid'); 12205 }; 12206 12207 return NewsletterCtrl; 12208 }(); 12209 12210 NewsletterCtrl.$inject = ['$scope', '$location', '$timeout', '$http', 'StateService']; 12211 12212 /* jshint esversion: 6 */ 12213 var GTM_CAT = 'projects'; 12214 var ITEMS_PER_PAGE = 15; 12215 12216 var ProjectsCtrl = /*#__PURE__*/function () { 12217 function ProjectsCtrl($scope, $timeout, LocationService) { 12218 this.$scope = $scope; 12219 this.$timeout = $timeout; 12220 this.locationService = LocationService; 12221 this.filters = window.filters || {}; 12222 this.projects = window.projects || []; 12223 this.selectedFilters = []; // this.initData__(); 12224 12225 this.deserializeFilters(); 12226 this.applyFilters(); 12227 } 12228 12229 var _proto = ProjectsCtrl.prototype; 12230 12231 _proto.deserializeFilters = function deserializeFilters() { 12232 var _this = this; 12233 12234 var locationFilters = this.locationService.deserialize('filters') || {};
12235 Object.keys(this.filters).forEach(function (x) { 12236 var filter = _this.filters[x]; 12237 12238 switch (x) { 12239 default: 12240 filter.doFilter = function (item, value) { 12241 var features = item[x]; 12242 12243 if (isNaN(features)) { 12244 return JSON.parse(features).includes(value); 12245 } else { 12246 return parseInt(features) === value; 12247 } 12248 }; 12249 12250 } 12251 12252 filter.options.unshift({ 12253 label: _this.filters[x].placeholder, 12254 value: null 12255 }); 12256 var selectedOption = filter.options.find(function (o) { 12257 return Boolean(o.value === (locationFilters[x] || _this.filters[x].value || null)); 12258 }); 12259 filter.value = selectedOption.value; 12260 filter.placeholder = selectedOption.label; 12261 }); 12262 return filters; 12263 }; 12264 12265 _proto.serializeFilters = function serializeFilters() { 12266 var _this2 = this; 12267 12268 var filters = {}; 12269 Object.keys(this.filters).forEach(function (x) { 12270 var filter = _this2.filters[x]; 12271 12272 if (filter.value !== null) { 12273 filters[x] = filter.value; 12274 } 12275 }); // console.log('ReferenceCtrl.serializeFilters', filters); 12276 //this.locationService.serialize('filters', filters); 12277 12278 return filters; 12279 }; 12280 12281 _proto.applyFilters = function applyFilters() { 12282 var _this3 = this; 12283 12284 this.serializeFilters(); 12285 var selectedFilters = Object.keys(this.filters).map(function (x) { 12286 return _this3.filters[x]; 12287 }).filter(function (x) { 12288 return x.value !== null; 12289 }); 12290 var filteredItems = this.projects.slice(); // console.log(filteredItems); 12291 12292 if (selectedFilters.length) { 12293 filteredItems = filteredItems.filter(function (reference) { 12294 var has = true; 12295 selectedFilters.forEach(function (filter) { 12296 has = has && filter.doFilter(reference, filter.value); 12297 }); 12298 return has; 12299 }); 12300 } // console.log(filteredItems, selectedFilters); 12301 12302 12303 this.selectedFilters = selectedFilters; 12304 this.filteredItems = []; 12305 this.visibleItems = []; 12306 this.maxItems = ITEMS_PER_PAGE; 12307 this.$timeout(function () { 12308 _this3.filteredItems = filteredItems; 12309 _this3.visibleItems = filteredItems.slice(0, _this3.maxItems); 12310 12311 _this3.updateFilterStates(filteredItems); // delayer for image update 12312 12313 }, 50); 12314 GtmService.pageViewFilters(GTM_CAT, this.filters); 12315 }; 12316 12317 _proto.updateFilterStates = function updateFilterStates(projects) { 12318 var _this4 = this; 12319 12320 // console.log('updateFilterStates', projects); 12321 Object.keys(this.filters).forEach(function (x) { 12322 var filter = _this4.filters[x]; 12323 filter.options.forEach(function (option) { 12324 var has = false; 12325 12326 if (option.value) { 12327 var i = 0; 12328 12329 while (i < projects.length && !has) { 12330 var reference = projects[i]; 12331 has = filter.doFilter(reference, option.value); 12332 i++; 12333 } 12334 } else { 12335 has = true; 12336 } 12337 12338 option.disabled = !has; 12339 }); // console.log(filter.options); 12340 }); 12341 }; 12342 12343 _proto.setFilter = function setFilter(item, filter) { 12344 item = item || filter.options[0]; 12345 filter.value = item.value; 12346 filter.placeholder = item.label; 12347 this.applyFilters(); 12348 this.$scope.$broadcast('onCloseDropdown'); 12349 }; 12350 12351 _proto.removeFilter = function removeFilter(filter) { 12352 this.setFilter(null, filter); 12353 } // Gestisce eventi tastiera per la rimozione dei filtri 12354 ; 12355 12356 _proto.handleFilterKeyDown = function handleFilterKeyDown(event, filter, action) { 12357 if (action === void 0) { 12358 action = 'remove'; 12359 } 12360 12361 console.log('handleFilterKeyDown called:', event.key, action, filter); 12362 12363 if (event.key === 'Enter' || event.key === ' ') { 12364 event.preventDefault(); 12365 event.stopPropagation(); 12366 console.log('Key pressed, executing action:', action); 12367 12368 if (action === 'remove') { 12369 this.removeFilter(filter); 12370 } else if (action === 'removeAll') { 12371 this.removeAll(); 12372 } 12373 } 12374 }; 12375 12376 _proto.removeAll = function removeAll() { 12377 var _this5 = this; 12378 12379 var removing = {};
12380 Object.keys(this.filters).forEach(function (key) { 12381 removing[key] = _this5.filters[key]; 12382 }); 12383 Object.keys(removing).forEach(function (key) { 12384 var filter = removing[key]; 12385 12386 _this5.removeFilter(filter); 12387 }); 12388 this.applyFilters(); 12389 }; 12390 12391 _proto.onScroll = function onScroll(event) { 12392 var _this6 = this; 12393 12394 if (event.rect.top + event.rect.height < event.windowRect.bottom) { 12395 if (!this.busy && this.maxItems < this.filteredItems.length) { 12396 console.log('more!!'); 12397 this.$timeout(function () { 12398 _this6.busy = true; 12399 12400 _this6.$timeout(function () { 12401 _this6.maxItems += ITEMS_PER_PAGE; 12402 _this6.visibleItems = _this6.filteredItems.slice(0, _this6.maxItems); 12403 _this6.busy = false; // console.log(this.visibleItems.length); 12404 }, 1000); 12405 }, 0); 12406 } 12407 } 12408 }; 12409 12410 _proto.initData__ = function initData__() { 12411 var _this7 = this; 12412 12413 // options > label, value (id) 12414 var uid = 1; 12415 12416 var getStoredValue = function getStoredValue(items, label) { 12417 return items.find(function (x) { 12418 return x.label === label; 12419 }); 12420 }; 12421 12422 var toTitleCase = function toTitleCase(text) { 12423 return text.replace(/-/g, ' ').replace(/\w\S*/g, function (txt) { 12424 return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); 12425 }); 12426 }; 12427 12428 Object.keys(this.filters).forEach(function (key) { 12429 var filter = _this7.filters[key]; 12430 var options = filter.options; 12431 12432 _this7.projects.forEach(function (x) { 12433 var values = x[key]; 12434 12435 if (values) { 12436 x[key] = values.map(function (value) { 12437 var label = toTitleCase(value); 12438 var storedValue = getStoredValue(options, label); 12439 var id; 12440 12441 if (storedValue !== undefined) { 12442 id = storedValue.value; 12443 } else { 12444 id = uid++; 12445 options.push({ 12446 label: label, 12447 value: id 12448 }); 12449 } 12450 12451 return id; 12452 }); 12453 } 12454 }); 12455 }); 12456 console.log(JSON.stringify(this.filters)); 12457 console.log(JSON.stringify(this.projects)); 12458 }; 12459 12460 return ProjectsCtrl; 12461 }(); 12462 12463 ProjectsCtrl.$inject = ['$scope', '$timeout', 'LocationService']; 12464 12465 /* jshint esversion: 6 */ 12466 12467 var RootCtrl = /*#__PURE__*/function () { 12468 function RootCtrl($scope, $element, $timeout, IntersectionService, DomService, ApiService, WishlistService) { 12469 var _this = this; 12470 12471 this.$scope = $scope; 12472 this.$element = $element; 12473 this.$timeout = $timeout; 12474 this.intersectionService = IntersectionService; 12475 this.domService = DomService; 12476 this.apiService = ApiService; 12477 this.wishlistService = WishlistService; 12478 DomService.addCustomRules(); 12479 this.unsubscribe = new Subject(); 12480 this.wishlistService.count$.pipe(takeUntil(this.unsubscribe)).subscribe(function (count) { 12481 $timeout(function () { 12482 _this.wishlistCount = count; 12483 }); 12484 }); 12485 this.loadingAnimation(); 12486 this.onMenuToggle = this.onMenuToggle.bind(this); 12487 this.onPrimaryDroppedIn = this.onPrimaryDroppedIn.bind(this); 12488 this.onPrimaryDroppedOut = this.onPrimaryDroppedOut.bind(this); 12489 this.onSecondaryDroppedIn = this.onSecondaryDroppedIn.bind(this); 12490 this.onScroll = this.onScroll.bind(this); // $scope.$on('onDroppinIn', this.onDroppingIn.bind(this)); 12491 12492 $scope.$on('destroy', function () { 12493 // console.log('destroy'); 12494 _this.unsubscribe.next(); 12495 12496 _this.unsubscribe.complete(); 12497 }); 12498 $scope.simulateSearchClick = this.simulateSearchClick.bind(this); 12499 } 12500 12501 var _proto = RootCtrl.prototype; 12502 12503 _proto.simulateSearchClick = function simulateSearchClick() { 12504 var targetButton = document.querySelector('.o-3'); 12505 var header = document.querySelector('.section--header'); 12506 var html = document.querySelector('html'); 12507 12508 if (targetButton) { 12509 console.log('Target button found:', targetButton); 12510 targetButton.classList.add('opened'); // Aggiunge la classe 12511 12512 header.classList.add('dropped'); // Aggiunge la classe 12513 12514 html.classList.add('droppin-in'); // Aggiunge la classe 12515 // Trova il div .group--text 12516 12517 var groupText = targetButton.querySelector('.group--text'); 12518 var control = targetButton.querySelector('.control'); 12519 12520 if (groupText) { 12521 groupText.classList.add('focus'); // Aggiunge la classe focus 12522 // Trova l'input all'interno di .group--text 12523 12524 var input = groupText.querySelector('input'); 12525 12526 if (input) { 12527 input.focus(); // Imposta il focus sull'input 12528 12529 console.log('Focused on input:', input); 12530 } else { 12531 console.warn('Input not found inside group--text'); 12532 }
12532 // Aggiungi un evento per chiudere il search quando si clicca fuori 12533 12534 12535 var handleOutsideClick = function handleOutsideClick(event) { 12536 if (!control.contains(event.target)) { 12537 targetButton.classList.remove('opened'); // Rimuove la classe opened 12538 12539 html.classList.remove('droppin-in'); // Aggiunge la classe 12540 12541 groupText.classList.remove('focus'); // Rimuove la classe focus 12542 12543 document.removeEventListener('click', handleOutsideClick); // Rimuovi il listener 12544 12545 console.log('Search closed due to outside click'); 12546 } 12547 }; // Aggiungi il listener per il click al di fuori 12548 12549 12550 setTimeout(function () { 12551 document.addEventListener('click', handleOutsideClick); 12552 }, 0); // Timeout per evitare il trigger immediato 12553 } else { 12554 console.warn('group--text not found inside .o-3'); 12555 } 12556 } else { 12557 console.warn('Target button .o-3 not found'); 12558 } 12559 }; 12560 12561 _proto.loadingAnimation = function loadingAnimation() { 12562 var _this2 = this; 12563 12564 this.init = true; 12565 setTimeout(function () { 12566 var view = document.querySelector('.view'); 12567 TweenMax.set(view, { 12568 opacity: 1 12569 }); 12570 12571 _this2.setClasses(); 12572 }, 1); 12573 /* 12574 this.$timeout(() => { 12575 }, 1); 12576 */ 12577 12578 this.$scope.$on('onCoverEnd', function (scope) { 12579 setTimeout(function () { 12580 _this2.ready = true; 12581 12582 _this2.intersectionService.readySubject_.next(true); 12583 12584 _this2.domService.ready = true; 12585 12586 _this2.setClasses(); 12587 }, 100); 12588 /* 12589 this.$timeout(() => { 12590 this.ready = true; 12591 this.domService.ready = true; 12592 }, 100); 12593 */ 12594 }); 12595 }; 12596 12597 _proto.onMenuToggle = function onMenuToggle() { 12598 if (this.menuOpened || this.primary) { 12599 this.menuOpened = false; 12600 this.primary = false; 12601 document.querySelector('.section--header').classList.remove('dropped'); 12602 document.querySelector('html').classList.remove('droppin-in'); 12603 } else { 12604 this.menuOpened = true; 12605 document.querySelector('html').classList.add('droppin-in'); 12606 } 12607 12608 if (this.menuOpened) { 12609 var primary = document.querySelector('.nav--primary'); 12610 var secondary = document.querySelector('.nav--secondary'); 12611 var items = Array.prototype.slice.call(primary.querySelectorAll('li')).filter(function (x) { 12612 return x.parentNode === primary; 12613 }); 12614 var items_sec = Array.prototype.slice.call(secondary.querySelectorAll('li')).filter(function (x) { 12615 return x.parentNode === secondary; 12616 }); 12617 TweenMax.set(items, { 12618 opacity: 0 12619 }); 12620 TweenMax.set(items_sec, { 12621 opacity: 0 12622 }); 12623 items.forEach(function (x, i) { 12624 var s = x.querySelector('a, span'); 12625 TweenMax.set(s, { 12626 x: '-100%', 12627 transition: 'none' 12628 }); 12629 TweenMax.to(x, 0.8, { 12630 opacity: 1, 12631 delay: 0.1 + 0.08 * i, 12632 ease: Power2.easeInOut, 12633 onUpdate: function onUpdate() { 12634 TweenMax.set(s, { 12635 x: (1 - x.style.opacity) * -100 + "%" 12636 }); 12637 }, 12638 onComplete: function onComplete() { 12639 s.removeAttribute('style'); 12640 } 12641 }); 12642 }); 12643 items_sec.forEach(function (x, i) { 12644 var s = x.querySelector('a, span'); 12645 TweenMax.set(s, { 12646 x: '-100%', 12647 transition: 'none' 12648 }); 12649 TweenMax.to(x, 0.8, { 12650 opacity: 1, 12651 delay: 0.1 + 0.08 * i, 12652 ease: Power2.easeInOut, 12653 onUpdate: function onUpdate() { 12654 TweenMax.set(s, { 12655 x: (1 - x.style.opacity) * -100 + "%" 12656 }); 12657 }, 12658 onComplete: function onComplete() { 12659 s.removeAttribute('style'); 12660 } 12661 }); 12662 }); 12663 } 12664 }; 12665 12666 _proto.onPrimaryDroppedIn = function onPrimaryDroppedIn(node, dropdown) { 12667 //console.log('RootCtrl.onPrimaryDroppedIn', node.innerHTML, dropdown); 12668 var input = node.querySelector('input'); 12669 12670 if (input) { 12671 input.focus(); 12672 } 12673 12674 this.primary = dropdown; 12675 document.querySelector('html').classList.add('droppin-in'); 12676 document.querySelector('.section--header').classList.remove('opened'); 12677 document.querySelector('.section--header').classList.add('dropped'); 12678 /* 12679 TweenMax.set(dropdown, { width: 0, overflow: 'hidden' }); 12680 TweenMax.to(dropdown, 0.8, { 12681 width: '100%', 12682 ease: Power2.easeInOut, 12683 overwrite: 'all', 12684 onComplete: () => { 12685 delete node.style.overflow; 12686 TweenMax.set(node, { width: '100%' }); 12687 } 12688 }); 12689 */ 12690 12691 var items = Array.prototype.slice.call(dropdown.querySelectorAll('li')).filter(function (x) { 12692 return x.parentNode === dropdown; 12693 }); 12694 TweenMax.set(items, { 12695 opacity: 0 12696 });
12697 items.forEach(function (x, i) { 12698 var s = x.querySelector('a, span'); 12699 TweenMax.set(s, { 12700 x: '-100%', 12701 transition: 'none' 12702 }); 12703 TweenMax.to(x, 0.8, { 12704 opacity: 1, 12705 delay: 0.1 + 0.08 * i, 12706 ease: Power2.easeInOut, 12707 onUpdate: function onUpdate() { 12708 TweenMax.set(s, { 12709 x: (1 - x.style.opacity) * -100 + "%" 12710 }); 12711 }, 12712 onComplete: function onComplete() { 12713 s.removeAttribute('style'); 12714 } 12715 }); 12716 }); 12717 }; 12718 12719 _proto.onPrimaryDroppedOut = function onPrimaryDroppedOut(node, dropdown) { 12720 // console.log('RootCtrl.onPrimaryDroppedOut', node, dropdown); 12721 if (dropdown === this.primary) { 12722 document.querySelector('html').classList.remove('droppin-in'); 12723 document.querySelector('.section--header').classList.remove('dropped'); 12724 } 12725 }; 12726 12727 _proto.onSecondaryDroppedIn = function onSecondaryDroppedIn(node, dropdown) { 12728 // console.log('RootCtrl.onSecondaryDroppedIn', node, dropdown); 12729 TweenMax.set(dropdown, { 12730 width: 0, 12731 overflow: 'hidden' 12732 }); 12733 TweenMax.to(dropdown, 0.8, { 12734 width: '100%', 12735 ease: Power2.easeInOut, 12736 overwrite: 'all', 12737 onComplete: function onComplete() { 12738 delete node.style.overflow; 12739 TweenMax.set(node, { 12740 width: '100%' 12741 }); 12742 } 12743 }); 12744 var items = Array.prototype.slice.call(dropdown.querySelectorAll('li')).filter(function (x) { 12745 return x.parentNode === dropdown; 12746 }); 12747 TweenMax.set(items, { 12748 opacity: 0 12749 }); 12750 items.forEach(function (x, i) { 12751 var s = x.querySelector('a, span'); 12752 TweenMax.set(s, { 12753 x: '-100%', 12754 transition: 'none' 12755 }); 12756 TweenMax.to(x, 0.8, { 12757 opacity: 1, 12758 delay: 0.1 + 0.08 * i, 12759 ease: Power2.easeInOut, 12760 overwrite: 'all', 12761 onUpdate: function onUpdate() { 12762 TweenMax.set(s, { 12763 x: (1 - x.style.opacity) * -100 + "%" 12764 }); 12765 }, 12766 onComplete: function onComplete() { 12767 s.removeAttribute('style'); 12768 } 12769 }); 12770 }); 12771 }; 12772 12773 _proto.onScroll = function onScroll(event) { 12774 var scrolled = event.scroll.scrollTop > 40; 12775 12776 if (this.scrolled !== scrolled || this.direction !== event.scroll.direction) { 12777 this.scrolled = scrolled; 12778 this.direction = event.scroll.direction; 12779 this.setClasses(); 12780 /* 12781 this.$timeout(() => { 12782 this.scrolled = scrolled; 12783 this.direction = event.scroll.direction; 12784 }); 12785 */ 12786 } 12787 }; 12788 12789 _proto.wishlistToggle = function wishlistToggle(item) { 12790 var _this3 = this; 12791 12792 // console.log('RootController.wishlistToggle'); 12793 return this.wishlistService.toggle(item).pipe(first()).subscribe(function (value) { 12794 _this3.$timeout(function () {// console.log('RootController.wishlistToggle', value); 12795 }); 12796 }); 12797 }; 12798 12799 _proto.wishlistClearAll = function wishlistClearAll() { 12800 var _this4 = this; 12801 12802 // console.log('RootController.wishlistClearAll'); 12803 return this.wishlistService.clearAll().pipe(first()).subscribe(function (success) { 12804 _this4.$timeout(function () { 12805 _this4.wishlistCount = 0; // console.log('RootController.wishlistClearAll', this.wishlistCount); 12806 }); 12807 }); 12808 }; 12809 12810 _proto.wishlistHas = function wishlistHas(item) { 12811 return this.wishlistService.has(item); 12812 }; 12813 12814 _proto.setClasses = function setClasses() { 12815 var node = this.$element[0]; 12816 12817 if (this.init) { 12818 node.classList.add('init'); 12819 } else { 12820 node.classList.remove('init'); 12821 } 12822 12823 if (this.ready) { 12824 node.classList.add('ready'); 12825 } else { 12826 node.classList.remove('ready'); 12827 } 12828 12829 if (this.scrolled) { 12830 node.classList.add('scrolled'); 12831 } else { 12832 node.classList.remove('scrolled'); 12833 } 12834 12835 if (this.direction === -1) { 12836 node.classList.add('scrolled-up'); 12837 } else { 12838 node.classList.remove('scrolled-up'); 12839 } 12840 12841 if (this.direction === 1) { 12842 node.classList.add('scrolled-down'); 12843 } else { 12844 node.classList.remove('scrolled-down'); 12845 } 12846 }; 12847 12848 _proto.getClasses = function getClasses() { 12849 var classes = {}; 12850 12851 if (this.init) { 12852 classes.init = true; 12853 } 12854 12855 if (this.ready) { 12856 classes.ready = true; 12857 } 12858 12859 if (this.direction === -1) { 12860 classes['scrolled-up'] = true; 12861 } 12862 12863 if (this.direction === 1) { 12864 classes['scrolled-down'] = true; 12865 } 12866 12867 return classes; 12868 }; 12869 12870 _proto.pad = function pad(index) { 12871 return index < 10 ? '0' + index : index; 12872 }; 12873 12874 _proto.hasHash = function hasHash(hash) { 12875 return window.location.hash.indexOf(hash) !== -1; 12876 }; 12877 12878 return RootCtrl; 12879 }(); 12880 12881 RootCtrl.$inject = ['$scope', '$element', '$timeout', 'IntersectionService', 'DomService', 'ApiService', 'WishlistService']; 12882 12883 /* jshint esversion: 6 */ 12884 var IS_DEV$1 = window.location.pathname.match(/\.html$/i); 12885 var QUERYSTRING_KEY = 'q'; 12886 12887 var SearchCtrl = /*#__PURE__*/function () { 12888 function SearchCtrl($scope, $location, $timeout, $http, StateService) { 12889 this.$scope = $scope; 12890 this.$location = $location; 12891 this.$timeout = $timeout; 12892 this.$http = $http; 12893 this.data = window.data || {}; 12894 this.model = {}; 12895 this.state = StateService.getState(); 12896 this.state.ready(); 12897 12898 if (this.$location.search() && this.$location.search()[QUERYSTRING_KEY]) { 12899 this.model.search = this.$location.search()[QUERYSTRING_KEY]; 12900 this.onSubmit(); 12901 } 12902 } 12903 12904 var _proto = SearchCtrl.prototype; 12905 12906 _proto.onSubmit = function onSubmit() { 12907 var _this = this; 12908 12909 // console.log('SearchCtrl.onSubmit', this.model); 12910 this.results = []; 12911 12912 if (this.state.busy()) { 12913 (IS_DEV$1 ? this.$http.get('./data/search-results.json') : this.$http.post(window.location.pathname + "?" + QUERYSTRING_KEY + "=" + encodeURIComponent(this.model.search))).then(function (success) { 12914 var results = success.data; // console.log(results); 12915 12916 _this.results = results; 12917 12918 _this.state.success(); 12919 12920 _this.$location.search(QUERYSTRING_KEY, _this.model.search); 12921 12922 var obj = Object.assign({}, window.objDataLayerInfo); 12923 obj["eventname"] = "search"; 12924 obj["searchterm"] = encodeURIComponent(_this.model.search); 12925 GtmService.push(obj); 12926 }, function (error) { 12927 _this.error = error; 12928 }); 12929 this.$timeout(function () {// this.state.ready(); 12930 }, 2000); 12931 } 12932 } //onSearch() { 12933 // //console.log("--search" + encodeURIComponent(this.model.search)); 12934 // //const obj = Object.assign({}, window.objDataLayerInfo); 12935 // //obj["eventname"] = "search"; 12936 // //obj["searchterm"] = encodeURIComponent(this.model.search); 12937 // //GtmService.push(obj); 12938 // // console.log('SearchCtrl.onSearch', this.model); 12939 // //window.location.href = `${this.searchHref}?${QUERYSTRING_KEY}=${this.model.search}`; 12940 //} 12941 ; 12942 12943 _proto.onInvalid = function onInvalid() { 12944 this.$scope.$broadcast('onInvalid'); 12945 }; 12946 12947 return SearchCtrl; 12948 }(); 12949 12950 SearchCtrl.$inject = ['$scope', '$location', '$timeout', '$http', 'StateService']; 12951 12952 /* jshint esversion: 6 */ 12953 var IS_DEV$2 = window.location.pathname.match(/\.html$/i); 12954 var QUERYSTRING_KEY$1 = 'q'; 12955 12956 var SearchbarCtrl = /*#__PURE__*/function () { 12957 function SearchbarCtrl($scope, $location, $timeout, $http, StateService) { 12958 this.$scope = $scope; 12959 this.$location = $location; 12960 this.$timeout = $timeout; 12961 this.$http = $http; 12962 this.data = window.data || {}; 12963 this.model = {}; 12964 this.state = StateService.getState(); 12965 this.state.ready(); //if (this.$location.search() && this.$location.search()[QUERYSTRING_KEY]) { 12966 // this.model.search = this.$location.search()[QUERYSTRING_KEY]; 12967 // this.onSubmit(); 12968 //} 12969 } 12970 12971 var _proto = SearchbarCtrl.prototype; 12972 12973 _proto.onSearch = function onSearch() { 12974 // Don't search if the search term is empty or undefined 12975 if (!this.model.search || this.model.search.trim() === '') { 12976 return; 12977 } //console.log("--search" + encodeURIComponent(this.model.search)); 12978 //const obj = Object.assign({}, window.objDataLayerInfo); 12979 //obj["eventname"] = "search"; 12980 //obj["searchterm"] = encodeURIComponent(this.model.search); 12981 //GtmService.push(obj); 12982 // console.log('SearchCtrl.onSearch', this.model); 12983 12984 12985 window.location.href = this.searchHref + "?" + QUERYSTRING_KEY$1 + "=" + this.model.search; 12986 }; 12987 12988 _proto.onInvalid = function onInvalid() { 12989 this.$scope.$broadcast('onInvalid'); 12990 }; 12991 12992 return SearchbarCtrl; 12993 }(); 12994 12995 SearchbarCtrl.$inject = ['$scope', '$location', '$timeout', '$http', 'StateService']; 12996 12997 /* jshint esversion: 6 */ 12998 var STATIC = window.location.port === '9966' || window.location.href.indexOf('actarian.github.io/lea/') !== -1; 12999 13000 var ApiService = /*#__PURE__*/function () { 13001 function ApiService($http) { 13002 this.http = $http; 13003 var api = { 13004 advancedSearch: { 13005 get: function get() { 13006 return from($http.get('data/advanced-search.json')); // return from($http.get(API_HREF + '/api/advanced-search/json')); 13007 } 13008 }, 13009 wishlist: { 13010 get: function get() { 13011 return from($http.get('data/moodboard.json')); 13012 }, 13013 toggle: function toggle(item) { 13014 item.added = !item.added; 13015 return Promise.resolve(item); 13016 }, 13017 clearAll: function clearAll() { 13018 return Promise.resolve(); 13019 } 13020 }, 13021 moodboard: { 13022 filter: function filter(filters) { 13023 // return from($http.post(API_HREF + '/api/moodboard/json', filters)); 13024 return from($http.get('data/moodboard.json')); 13025 } 13026 }, 13027 storeLocator: { 13028 all: function all() { 13029 if (STATIC) { 13030 return $http.get('data/store-locator.json'); 13031 } else { 13032 return $http.post('/ws/wsUsers.asmx/StoreList', {}); 13033 } 13034 } 13035 } 13036 }; 13037 Object.assign(this, api); 13038 } 13039 13040 ApiService.factory = function factory($http) { 13041 return new ApiService($http); 13042 }; 13043 13044 return ApiService; 13045 }(); 13046 ApiService.factory.$inject = ['$http']; 13047 13048 var IntersectionService = /*#__PURE__*/function () { 13049 function IntersectionService() { 13050 this.readySubject_ = new BehaviorSubject(false); 13051 this.observerSubject_ = new Subject(); 13052 } 13053 13054 var _proto = IntersectionService.prototype; 13055 13056 _proto.intersection$ = function intersection$(node) { 13057 var _this = this; 13058 13059 var init = false;
13060 13061 if ('IntersectionObserver' in window) { 13062 return this.readySubject_.pipe(filter(function (value) { 13063 if (value && !init) { 13064 _this.observer.observe(node); 13065 13066 init = true; 13067 } 13068 13069 return value; 13070 }), switchMap(function () { 13071 return _this.observerSubject_; 13072 }), // tap(entries => console.log(entries.length)), 13073 map(function (entries) { 13074 return entries.find(function (entry) { 13075 return entry.target === node; 13076 }); 13077 }), filter(function (entry) { 13078 return entry !== undefined && entry.isIntersecting; 13079 }), // entry.intersectionRatio > 0), 13080 first(), finalize(function () { 13081 return _this.observer.unobserve(node); 13082 })); 13083 } else { 13084 return of({ 13085 target: node 13086 }); 13087 } 13088 }; 13089 13090 IntersectionService.factory = function factory() { 13091 return new IntersectionService(); 13092 }; 13093 13094 _createClass(IntersectionService, [{ 13095 key: "observer", 13096 get: function get() { 13097 var _this2 = this; 13098 13099 if (!this.observer_) { 13100 this.observer_ = new IntersectionObserver(function (entries) { 13101 _this2.observerSubject_.next(entries); 13102 }); 13103 } 13104 13105 return this.observer_; 13106 } 13107 }]); 13108 13109 return IntersectionService; 13110 }(); 13111 13112 var key$1 = 'pwishList'; 13113 13114 var WishlistService = /*#__PURE__*/function () { 13115 function WishlistService($http, PromiseService, //StorageService, 13116 ApiService) { 13117 this.$http = $http; 13118 this.promise = PromiseService; //this.storage = StorageService; 13119 13120 this.api = ApiService; 13121 this.count$ = WishlistService.count$; 13122 this.count$.next(this.wishlist.length); // console.log('WishlistService', this.storage); 13123 } 13124 13125 var _proto = WishlistService.prototype; 13126 13127 /* 13128 indexOf(item) { 13129 const index = this.wishlist.reduce((p, c, i) => { 13130 if (p === -1) { 13131 return c.id* === item.id && c.coId === item.coId ? i : p; 13132 } else { 13133 return p; 13134 } 13135 }, -1); 13136 return index; 13137 } 13138 */ 13139 _proto.has = function has(item) { 13140 return this.wishlist.indexOf(item) !== -1; 13141 }; 13142 13143 _proto.add = function add(item) { 13144 var _this = this; 13145 13146 return from(this.promise.make(function (promise) { 13147 if (!_this.has(item)) { 13148 var wishlist = _this.wishlist; 13149 wishlist.push( 13150 /*{ id: item.id, coId: item.coId }*/ 13151 item); 13152 _this.wishlist = wishlist; 13153 promise.resolve(true); 13154 } 13155 })); 13156 }; 13157 13158 _proto.remove = function remove(item) { 13159 var _this2 = this; 13160 13161 return from(this.promise.make(function (promise) { 13162 var index = _this2.wishlist.indexOf(item); 13163 13164 if (index !== -1) { 13165 var wishlist = _this2.wishlist; 13166 wishlist.splice(index, 1); 13167 _this2.wishlist = wishlist; 13168 } 13169 13170 promise.resolve(false); 13171 })); 13172 }; 13173 13174 _proto.toggle = function toggle(item) { 13175 if (this.has(item)) { 13176 return this.remove(item); 13177 } else { 13178 return this.add(item); 13179 } 13180 }; 13181 13182 _proto.clearAll = function clearAll() { 13183 var _this3 = this; 13184 13185 return from(this.promise.make(function (promise) { 13186 var wishlist = []; 13187 _this3.wishlist = wishlist; 13188 promise.resolve(wishlist); 13189 })); 13190 }; 13191 13192 _proto.get = function get() { 13193 var _this4 = this; 13194 13195 return from(this.$http.get('data/moodboard.json').then(function (success) { 13196 if (success.data) { 13197 _this4.wishlist = success.data; 13198 } 13199 13200 return success; 13201 })); 13202 }; 13203 13204 WishlistService.factory = function factory($http, PromiseService, 13205 /*StorageService,*/ 13206 ApiService) { 13207 return new WishlistService($http, PromiseService, 13208 /*StorageService,*/ 13209 ApiService); 13210 }; 13211 13212 _createClass(WishlistService, [{ 13213 key: "wishlist", 13214 get: function get() { 13215 if (!this.wishlist_) { 13216 //const wishlist = this.storage.get('wishlist'); 13217 //this.wishlist_ = wishlist || []; 13218 this.wishlist_ = []; 13219 var str = document.cookie.match(new RegExp("(^|; )" + key$1 + "=([^;]+)")); 13220 13221 if (str) { 13222 this.wishlist_ = str[2].match(/([0-9 ]+)/g); 13223 } 13224 13225 WishlistService.count$.next(this.wishlist_.length); 13226 } 13227 13228 return this.wishlist_; 13229 }, 13230 set: function set(wishlist) { 13231 this.wishlist_ = wishlist || []; //this.storage.set('wishlist', this.wishlist_); 13232 13233 var dt = new Date(); 13234 dt.setDate(dt.getDate() + 30);
13235 document.cookie = key$1 + '=' + this.wishlist_.join(',') + '; path=/; expires=' + dt.toUTCString(); 13236 WishlistService.count$.next(this.wishlist_.length); 13237 } 13238 }]); 13239 13240 return WishlistService; 13241 }(); 13242 WishlistService.count$ = new BehaviorSubject(0); 13243 WishlistService.factory.$inject = ['$http', 'PromiseService', 13244 /*'LocalStorageService',*/ 13245 'ApiService']; 13246 13247 /* jshint esversion: 6 */ 13248 var LocationService = /*#__PURE__*/function () { 13249 function LocationService($location) { 13250 this.$location = $location; 13251 } 13252 13253 var _proto = LocationService.prototype; 13254 13255 _proto.get = function get(key) { 13256 return this.$location.search()[key]; 13257 }; 13258 13259 _proto.set = function set(keyOrValue, value) { 13260 if (typeof keyOrValue === 'string') { 13261 this.$location.search(keyOrValue, value).replace(); 13262 } else { 13263 this.$location.search(keyOrValue).replace(); 13264 } 13265 }; 13266 13267 _proto.deserialize = function deserialize(key) { 13268 var value = null; 13269 var serialized = this.get('q'); // console.log(serialized); 13270 13271 if (serialized) { 13272 var json = window.atob(serialized); 13273 value = JSON.parse(json); 13274 } // console.log(value); 13275 13276 13277 if (key && value) { 13278 value = value[key]; 13279 } 13280 13281 return value || null; 13282 }; 13283 13284 _proto.serialize = function serialize(keyOrValue, value) { 13285 var serialized = null; 13286 var q = this.deserialize() || {}; 13287 13288 if (typeof keyOrValue === 'string') { 13289 q[keyOrValue] = value; 13290 } else { 13291 q = keyOrValue; 13292 } 13293 13294 var json = JSON.stringify(q); 13295 serialized = window.btoa(json); 13296 this.set('q', serialized); 13297 }; 13298 13299 _proto.getSerialization = function getSerialization(keyOrValue, value) { 13300 var serialized = null; 13301 var q = {}; 13302 13303 if (typeof keyOrValue === 'string') { 13304 q[keyOrValue] = value; 13305 } else { 13306 q = keyOrValue; 13307 } 13308 13309 var json = JSON.stringify(q); 13310 serialized = window.btoa(json); 13311 return serialized; 13312 }; 13313 13314 LocationService.factory = function factory($location) { 13315 return new LocationService($location); 13316 }; 13317 13318 return LocationService; 13319 }(); 13320 LocationService.factory.$inject = ['$location']; 13321 13322 /* jshint esversion: 6 */ 13323 var PromiseService = /*#__PURE__*/function () { 13324 function PromiseService($q) { 13325 this.$q = $q; 13326 } 13327 13328 var _proto = PromiseService.prototype; 13329 13330 _proto.make = function make(callback) { 13331 if (typeof callback !== 'function') { 13332 throw 'promise resolve callback missing'; 13333 } 13334 13335 var deferred = this.$q.defer(); 13336 callback(deferred); 13337 return deferred.promise; 13338 }; 13339 13340 _proto.all = function all(promises) { 13341 return this.$q.all(promises); 13342 }; 13343 13344 PromiseService.factory = function factory($q) { 13345 return new PromiseService($q); 13346 }; 13347 13348 return PromiseService; 13349 }(); 13350 PromiseService.factory.$inject = ['$q']; 13351 13352 /* jshint esversion: 6 */ 13353 var DELAY = 2000; 13354 var State = /*#__PURE__*/function () { 13355 function State($timeout, $rootScope) { 13356 this.$timeout = $timeout; 13357 this.$rootScope = $rootScope; 13358 this.idle(); 13359 } 13360 13361 var _proto = State.prototype; 13362 13363 _proto.idle = function idle() { 13364 this.isBusy = false; 13365 this.isError = false; 13366 this.isErroring = false; 13367 this.isSuccess = false; 13368 this.isSuccessing = false; 13369 this.button = null; 13370 this.errors = []; 13371 }; 13372 13373 _proto.busy = function busy() { 13374 if (!this.isBusy) { 13375 this.isBusy = true; 13376 this.isError = false; 13377 this.isErroring = false; 13378 this.isSuccess = false; 13379 this.isSuccessing = false; 13380 this.errors = []; 13381 return true; 13382 } else { 13383 return false; 13384 } 13385 }; 13386 13387 _proto.classes = function classes(addons) { 13388 var classes = { 13389 ready: this.isReady, 13390 busy: this.isBusy, 13391 successing: this.isSuccessing, 13392 success: this.isSuccess, 13393 errorring: this.isErroring, 13394 error: this.isError 13395 }; 13396 13397 if (addons) { 13398 Object.keys(addons).forEach(function (key) { 13399 classes[addons[key]] = classes[key]; 13400 }); 13401 } 13402 13403 return classes; 13404 }; 13405 13406 _proto.enabled = function enabled() { 13407 return !this.isBusy && !this.isErroring && !this.isSuccessing; 13408 }; 13409 13410 _proto.error = function error(_error) { 13411 var _this = this; 13412 13413 console.log('State.error', _error); 13414 this.isBusy = false;
13415 this.isError = true; 13416 this.isErroring = true; 13417 this.isSuccess = false; 13418 this.isSuccessing = false; 13419 this.errors.push(_error); 13420 this.$timeout(function () { 13421 _this.isErroring = false; 13422 }, DELAY); 13423 }; 13424 13425 _proto.errorMessage = function errorMessage() { 13426 return this.isError ? this.errors[this.errors.length - 1] : null; 13427 }; 13428 13429 _proto.labels = function labels(addons) { 13430 var defaults = { 13431 ready: 'submit', 13432 busy: 'sending', 13433 error: 'error', 13434 success: 'success' 13435 }; 13436 13437 if (addons) { 13438 angular.extend(defaults, addons); 13439 } 13440 13441 var label = defaults.ready; 13442 13443 if (this.isBusy) { 13444 label = defaults.busy; 13445 } else if (this.isSuccess) { 13446 label = defaults.success; 13447 } else if (this.isError) { 13448 label = defaults.error; 13449 } 13450 13451 return label; 13452 }; 13453 13454 _proto.ready = function ready() { 13455 this.idle(); 13456 this.isReady = true; 13457 this.$rootScope.$broadcast('$thisReady', this); 13458 }; 13459 13460 _proto.submitClass = function submitClass() { 13461 return { 13462 busy: this.isBusy, 13463 ready: this.isReady, 13464 successing: this.isSuccessing, 13465 success: this.isSuccess, 13466 errorring: this.isErroring, 13467 error: this.isError 13468 }; 13469 }; 13470 13471 _proto.success = function success() { 13472 var _this2 = this; 13473 13474 this.isBusy = false; 13475 this.isError = false; 13476 this.isErroring = false; 13477 this.isSuccess = true; 13478 this.isSuccessing = true; 13479 this.errors = []; 13480 this.$timeout(function () { 13481 _this2.isSuccessing = false; 13482 }, DELAY); 13483 }; 13484 13485 return State; 13486 }(); 13487 13488 var StateService = /*#__PURE__*/function () { 13489 function StateService($timeout, $rootScope) { 13490 this.$timeout = $timeout; 13491 this.$rootScope = $rootScope; 13492 } 13493 13494 var _proto2 = StateService.prototype; 13495 13496 _proto2.getState = function getState() { 13497 return new State(this.$timeout, this.$rootScope); 13498 }; 13499 13500 StateService.factory = function factory($timeout, $rootScope) { 13501 return new StateService($timeout, $rootScope); 13502 }; 13503 13504 return StateService; 13505 }(); 13506 StateService.factory.$inject = ['$timeout', '$rootScope']; 13507 13508 /* jshint esversion: 6 */ 13509 var TIMEOUT = 5 * 60 * 1000; // five minutes 13510 13511 var CookieService = /*#__PURE__*/function () { 13512 function CookieService(PromiseService) { 13513 this.promise = PromiseService; 13514 } 13515 13516 var _proto = CookieService.prototype; 13517 13518 _proto.delete = function _delete(name) { 13519 setter(name, '', -1); 13520 }; 13521 13522 _proto.exist = function exist(name) { 13523 return document.cookie.indexOf(';' + name + '=') !== -1 || document.cookie.indexOf(name + '=') === 0; 13524 }; 13525 13526 _proto.get = function get(name) { 13527 var cookieName = name + "="; 13528 var ca = document.cookie.split(';'); 13529 13530 for (var i = 0; i < ca.length; i++) { 13531 var c = ca[i]; 13532 13533 while (c.charAt(0) == ' ') { 13534 c = c.substring(1, c.length); 13535 } 13536 13537 if (c.indexOf(cookieName) === 0) { 13538 var value = c.substring(cookieName.length, c.length); 13539 var model = null; 13540 13541 try { 13542 model = JSON.parse(decodeURIComponent(atob(value))); 13543 } catch (e) { 13544 console.log('CookieService.get.error parsing', key, e); 13545 } 13546 13547 return model; 13548 } 13549 } 13550 13551 return null; 13552 }; 13553 13554 _proto.on = function on(name) { 13555 var _this = this; 13556 13557 return this.promise.make(function (promise) { 13558 var i, 13559 interval = 1000, 13560 elapsed = 0, 13561 timeout = TIMEOUT; 13562 13563 var checkCookie = function checkCookie() { 13564 if (elapsed > timeout) { 13565 promise.reject('timeout'); 13566 } else { 13567 var c = _this.get(name); 13568 13569 if (c) { 13570 promise.resolve(c); 13571 } else { 13572 elapsed += interval; 13573 i = setTimeout(checkCookie, interval); 13574 } 13575 } 13576 }; 13577 13578 checkCookie(); 13579 }); 13580 }; 13581 13582 _proto.set = function set(name, value, days) { 13583 try { 13584 var cache = []; 13585 var json = JSON.stringify(value, function (key, value) { 13586 if (key === 'pool') { 13587 return; 13588 } 13589 13590 if (typeof value === 'object' && value !== null) { 13591 if (cache.indexOf(value) !== -1) { 13592 // Circular reference found, discard key 13593 return; 13594 } 13595 13596 cache.push(value); 13597 } 13598 13599 return value; 13600 }); 13601 this.setter(name, btoa(encodeURIComponent(json)), days); 13602 } catch (e) { 13603 console.log('CookieService.error serializing', name, value, e); 13604 } 13605 }; 13606 13607 _proto.setter = function setter(name, value, days) { 13608 var expires; 13609 13610 if (days) { 13611 var date = new Date(); 13612 date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000); 13613 expires = '; expires=' + date.toGMTString(); 13614 } else { 13615 expires = ''; 13616 } 13617 13618 document.cookie = name + '=' + value + expires + '; path=/'; 13619 }; 13620 13621 CookieService.factory = function factory(PromiseService) { 13622 return new CookieService(PromiseService); 13623 }; 13624 13625 return CookieService; 13626 }(); 13627 CookieService.factory.$inject = ['PromiseService']; 13628 var LocalStorageService = /*#__PURE__*/function () { 13629 function LocalStorageService(PromiseService) { 13630 this.promise = PromiseService; 13631 } 13632 13633 var _proto2 = LocalStorageService.prototype; 13634 13635 _proto2.delete = function _delete(name) { 13636 window.localStorage.removeItem(name); 13637 }; 13638 13639 _proto2.exist = function exist(name) { 13640 return window.localStorage[name] !== undefined; 13641 }; 13642 13643 _proto2.get = function get(name) { 13644 var value = null; 13645 13646 if (window.localStorage[name] !== undefined) { 13647 try { 13648 value = JSON.parse(window.localStorage[name]); 13649 } catch (e) { 13650 console.log('LocalStorageService.get.error parsing', name, e); 13651 } 13652 } 13653 13654 return value; 13655 }; 13656 13657 _proto2.set = function set(name, value) { 13658 try { 13659 var cache = []; 13660 var json = JSON.stringify(value, function (key, value) { 13661 if (key === 'pool') { 13662 return; 13663 } 13664 13665 if (typeof value === 'object' && value !== null) { 13666 if (cache.indexOf(value) !== -1) { 13667 // Circular reference found, discard key 13668 return; 13669 } 13670 13671 cache.push(value); 13672 } 13673 13674 return value; 13675 }); 13676 window.localStorage.setItem(name, json); 13677 } catch (e) { 13678 console.log('LocalStorageService.set.error serializing', name, value, e); 13679 } 13680 }; 13681 13682 _proto2.on = function on(name) { 13683 return this.promise.make(function (promise) { 13684 var i, 13685 timeout = TIMEOUT;
13686 13687 var storageEvent = function storageEvent(e) { 13688 if (i) { 13689 clearTimeout(i); 13690 } 13691 13692 if (e.originalEvent.key == name) { 13693 try { 13694 var value = JSON.parse(e.originalEvent.newValue); // , e.originalEvent.oldValue 13695 13696 promise.resolve(value); 13697 } catch (error) { 13698 console.log('LocalStorageService.on.error parsing', name, error); 13699 promise.reject('error parsing ' + name); 13700 } 13701 } 13702 }; 13703 13704 angular.element(window).on('storage', storageEvent); 13705 i = setTimeout(function () { 13706 promise.reject('timeout'); 13707 }, timeout); 13708 }); 13709 }; 13710 13711 LocalStorageService.isLocalStorageSupported = function isLocalStorageSupported() { 13712 var supported = false; 13713 13714 try { 13715 supported = 'localStorage' in window && window.localStorage !== null; 13716 13717 if (supported) { 13718 window.localStorage.setItem('test', '1'); 13719 window.localStorage.removeItem('test'); 13720 } else { 13721 supported = false; 13722 } 13723 } catch (e) { 13724 supported = false; 13725 } 13726 13727 return supported; 13728 }; 13729 13730 LocalStorageService.factory = function factory(PromiseService) { 13731 if (LocalStorageService.isLocalStorageSupported()) { 13732 return new LocalStorageService(PromiseService); 13733 } else { 13734 return new CookieService(PromiseService); 13735 } 13736 }; 13737 13738 return LocalStorageService; 13739 }(); 13740 LocalStorageService.factory.$inject = ['PromiseService']; 13741 var SessionStorageService = /*#__PURE__*/function () { 13742 function SessionStorageService(PromiseService) { 13743 this.promise = PromiseService; 13744 } 13745 13746 var _proto3 = SessionStorageService.prototype; 13747 13748 _proto3.delete = function _delete(name) { 13749 window.sessionStorage.removeItem(name); 13750 }; 13751 13752 _proto3.exist = function exist(name) { 13753 return window.sessionStorage[name] !== undefined; 13754 }; 13755 13756 _proto3.get = function get(name) { 13757 var value = null; 13758 13759 if (window.sessionStorage[name] !== undefined) { 13760 try { 13761 value = JSON.parse(window.sessionStorage[name]); 13762 } catch (e) { 13763 console.log('SessionStorageService.get.error parsing', name, e); 13764 } 13765 } 13766 13767 return value; 13768 }; 13769 13770 _proto3.set = function set(name, value) { 13771 try { 13772 var cache = []; 13773 var json = JSON.stringify(value, function (key, value) { 13774 if (key === 'pool') { 13775 return; 13776 } 13777 13778 if (typeof value === 'object' && value !== null) { 13779 if (cache.indexOf(value) !== -1) { 13780 // Circular reference found, discard key 13781 return; 13782 } 13783 13784 cache.push(value); 13785 } 13786 13787 return value; 13788 }); 13789 window.sessionStorage.setItem(name, json); 13790 } catch (e) { 13791 console.log('SessionStorageService.set.error serializing', name, value, e); 13792 } 13793 }; 13794 13795 _proto3.on = function on(name) { 13796 return this.promise.make(function (promise) { 13797 var i, 13798 timeout = TIMEOUT; 13799 13800 var storageEvent = function storageEvent(e) { 13801 if (i) { 13802 clearTimeout(i); 13803 } 13804 13805 if (e.originalEvent.key == name) { 13806 try { 13807 var value = JSON.parse(e.originalEvent.newValue); // , e.originalEvent.oldValue 13808 13809 promise.resolve(value); 13810 } catch (error) { 13811 console.log('SessionStorageService.on.error parsing', name, error); 13812 promise.reject('error parsing ' + name); 13813 } 13814 } 13815 }; 13816 13817 angular.element(window).on('storage', storageEvent); 13818 i = setTimeout(function () { 13819 promise.reject('timeout'); 13820 }, timeout); 13821 }); 13822 }; 13823 13824 SessionStorageService.isSessionStorageSupported = function isSessionStorageSupported() { 13825 var supported = false; 13826 13827 try { 13828 supported = 'sessionStorage' in window && window.sessionStorage !== null; 13829 13830 if (supported) { 13831 window.sessionStorage.setItem('test', '1'); 13832 window.localsessionStorageStorage.removeItem('test'); 13833 } else { 13834 supported = false; 13835 } 13836 } catch (e) { 13837 supported = false;
13838 } 13839 13840 return supported; 13841 }; 13842 13843 SessionStorageService.factory = function factory(PromiseService) { 13844 if (SessionStorageService.isSessionStorageSupported()) { 13845 return new SessionStorageService(PromiseService); 13846 } else { 13847 return new CookieService(PromiseService); 13848 } 13849 }; 13850 13851 return SessionStorageService; 13852 }(); 13853 SessionStorageService.factory.$inject = ['PromiseService']; 13854 13855 /* jshint esversion: 6 */ 13856 var IS_DEV$3 = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1' || window.location.hostname === '0.0.0.0'; 13857 var BASEPATH = window.location.hostname === '0.0.0.0' ? './img/store-locator/' : '/client/docs/img/store-locator/'; 13858 var ZOOM_LEVEL = 13; 13859 var MAX_DISTANCE = 1000; 13860 var GOOGLE_MAPS = null; 13861 var ITEMS_PER_PAGE$1 = 6; 13862 13863 var StoreLocatorCtrl = /*#__PURE__*/function () { 13864 function StoreLocatorCtrl($scope, $timeout, DomService, ApiService) { 13865 var _this = this; 13866 13867 this.$scope = $scope; 13868 this.$timeout = $timeout; 13869 this.domService = DomService; 13870 this.apiService = ApiService; 13871 13872 if (!window.storeLocatorSettings.apiKey && !IS_DEV$3) { 13873 throw "Missing Google Map Api Key"; 13874 } 13875 13876 this.apiKey = window.storeLocatorSettings.apiKey; 13877 this.model = {}; 13878 this.busyFind = false; 13879 this.busyLocation = false; 13880 this.busyCity = false; 13881 this.busyInfoAgents = false; 13882 this.requiredAddress = false; //this.$timeout(() => { 13883 // angular.element('#address-input').addClass('disabled'); 13884 // angular.element('#address-input input').attr('disabled', true); 13885 // angular.element('#address-input input').attr('readonly', true); 13886 //}, 500); 13887 13888 this.maxSearch = -1; 13889 this.countSearch = 0; 13890 this.searchCountry = ""; 13891 this.visibleStores = []; 13892 this.visibleAgents = []; 13893 this.searchProvinceCode = ""; 13894 this.searchCity = ""; 13895 this.searchArea = ""; 13896 this.mapCenter$ = new Subject(); 13897 this.labels = window.labels || { 13898 approximately: window.storeLocatorSettings.localizedStrings.LBL_DISTANZA_STORE, 13899 moreInfo: "More Info", 13900 reachStore: window.storeLocatorSettings.localizedStrings.LBL_RAGGIUNGERE_STORE, 13901 contactStore: window.storeLocatorSettings.localizedStrings.LBL_CONTATTA_STORE, 13902 contactAgent: window.storeLocatorSettings.localizedStrings.LBL_CONTATTA_AGENTE 13903 }; 13904 13905 if (GOOGLE_MAPS !== null) { 13906 this.initMap(); 13907 } else { 13908 window.onGoogleMapsLoaded = function () { 13909 GOOGLE_MAPS = google.maps; 13910 13911 _this.initMap(); 13912 }; 13913 13914 var script = document.createElement('script'); 13915 script.setAttribute('type', 'text/javascript'); 13916 script.setAttribute('src', "https://maps.googleapis.com/maps/api/js?callback=onGoogleMapsLoaded" + (this.apiKey ? "&key=" + this.apiKey : '') + "&libraries=places&language=" + $('html').attr('lang')); 13917 (document.getElementsByTagName('head')[0] || document.documentElement).appendChild(script); 13918 } 13919 13920 this.unsubscribe = new Subject(); 13921 this.mapCenter$.pipe(debounceTime(1000), takeUntil(this.unsubscribe)).subscribe(function (position) { 13922 _this.$timeout(function () { 13923 _this.visibleStores = _this.getStoresByViewport(); 13924 }, 1); 13925 }); 13926 $scope.$on('destroy', function () { 13927 _this.unsubscribe.next(); 13928 13929 _this.unsubscribe.complete(); 13930 }); 13931 } 13932 13933 var _proto = StoreLocatorCtrl.prototype; 13934 13935 _proto.initMap = function initMap() { 13936 var _this2 = this; 13937 13938 var mapOptions = { 13939 zoom: 17, 13940 center: new google.maps.LatLng(44.5416713, 10.8259022), 13941 // prima ricerca vicino a casa madre 13942 styles: [{ 13943 "featureType": "water", 13944 "elementType": "geometry", 13945 "stylers": [{ 13946 "color": "#e9e9e9" 13947 }, { 13948 "lightness": 17 13949 }] 13950 }, { 13951 "featureType": "landscape", 13952 "elementType": "geometry", 13953 "stylers": [{ 13954 "color": "#f5f5f5" 13955 }, { 13956 "lightness": 20 13957 }] 13958 }, { 13959 "featureType": "road.highway", 13960 "elementType": "geometry.fill", 13961 "stylers": [{ 13962 "color": "#ffffff" 13963 }, { 13964 "lightness": 17 13965 }] 13966 }, { 13967 "featureType": "road.highway", 13968 "elementType": "geometry.stroke", 13969 "stylers": [{ 13970 "color": "#ffffff" 13971 }, { 13972 "lightness": 29 13973 }, { 13974 "weight": 0.2 13975 }] 13976 }, { 13977 "featureType": "road.arterial", 13978 "elementType": "geometry", 13979 "stylers": [{ 13980 "color": "#ffffff" 13981 }, { 13982 "lightness": 18 13983 }] 13984 }, { 13985 "featureType": "road.local", 13986 "elementType": "geometry", 13987 "stylers": [{ 13988 "color": "#ffffff" 13989 }, { 13990 "lightness": 16 13991 }] 13992 }, { 13993 "featureType": "poi", 13994 "elementType": "geometry", 13995 "stylers": [{ 13996 "color": "#f5f5f5" 13997 }, { 13998 "lightness": 21 13999 }] 14000 }, { 14001 "featureType": "poi.park", 14002 "elementType": "geometry", 14003 "stylers": [{ 14004 "color": "#dedede" 14005 }, { 14006 "lightness": 21 14007 }] 14008 }, { 14009 "elementType": "labels.text.stroke", 14010 "stylers": [{ 14011 "visibility": "on" 14012 }, { 14013 "color": "#ffffff" 14014 }, { 14015 "lightness": 16 14016 }] 14017 }, { 14018 "elementType": "labels.text.fill", 14019 "stylers": [{ 14020 "saturation": 36 14021 }, { 14022 "color": "#333333" 14023 }, { 14024 "lightness": 40 14025 }] 14026 }, { 14027 "elementType": "labels.icon", 14028 "stylers": [{ 14029 "visibility": "off" 14030 }] 14031 }, { 14032 "featureType": "transit", 14033 "elementType": "geometry", 14034 "stylers": [{ 14035 "color": "#f2f2f2" 14036 }, { 14037 "lightness": 19 14038 }] 14039 }, { 14040 "featureType": "administrative", 14041 "elementType": "geometry.fill", 14042 "stylers": [{ 14043 "color": "#fefefe" 14044 }, { 14045 "lightness": 20 14046 }] 14047 }, { 14048 "featureType": "administrative", 14049 "elementType": "geometry.stroke", 14050 "stylers": [{ 14051 "color": "#fefefe" 14052 }, { 14053 "lightness": 17 14054 }, { 14055 "weight": 1.2 14056 }] 14057 }] 14058 }; 14059 var mapElement = document.getElementById('map'); 14060 14061 if (!mapElement) { 14062 return; 14063 } 14064 14065 var map = new google.maps.Map(mapElement, mapOptions); 14066 var startingMapBounds; 14067 14068 if (window.storeLocatorSettings.currMkt === 2) { 14069 // Centramento Italia 14070 startingMapBounds = this.getItalyBounds(); 14071 } else if (window.storeLocatorSettings.currMkt === 6) { 14072 // Centramento Francia 14073 startingMapBounds = this.getFranceBounds(); 14074 } else { 14075 startingMapBounds = this.getWorldBounds(); 14076 } 14077 14078 map.fitBounds(startingMapBounds); 14079 map.addListener('bounds_changed', function () { 14080 var position = map.getCenter(); 14081 14082 _this2.mapCenter$.next(position); 14083 14084 _this2.visibleItems = _this2.getStoresByViewport(); 14085 }); 14086 this.position = mapOptions.center; 14087 this.$timeout(function () { 14088 _this2.map = map; 14089 window.gmap = map; 14090 }); 14091 var autocompleteUnique = new google.maps.places.Autocomplete(document.querySelector('#cities-input input')); 14092 document.querySelector('#cities-input input').addEventListener('keydown', function (e) { 14093 _this2.model.address = undefined; 14094 _this2.busyCity = false;
14095 }, false); 14096 google.maps.event.addListener(autocompleteUnique, 'place_changed', function () { 14097 var city = autocompleteUnique.getPlace(); 14098 var filteredInfoCity = []; 14099 14100 if (city.address_components !== undefined) { 14101 filteredInfoCity = city.address_components.filter(function (address_component) { 14102 return address_component.types.includes("country"); 14103 }); 14104 } // per l'Italia controllo se c'è il dato che serve a me tra i livelli (indirizzo con almeno la via 14105 // se poi non lo trovo faccio lo show del messaggio per richiedere anche l'indirizzo, nel caso italiano 14106 14107 14108 var country = filteredInfoCity.length ? filteredInfoCity[0].short_name : ''; 14109 _this2.requiredAddress = country === 'IT' ? true : false; 14110 14111 if (_this2.requiredAddress) { 14112 var address = []; 14113 14114 if (city.address_components !== undefined) { 14115 address = city.address_components.filter(function (address_component) { 14116 return address_component.types.includes("route"); 14117 }); 14118 } 14119 14120 if (address.length !== 0) { 14121 _this2.model.address = angular.element('#cities-input input').val(); 14122 $("#errorNotes").hide(); 14123 } else { 14124 //$("#errorNotes").html('*Complete address is required for this country!'); 14125 $("#errorNotes").show(); 14126 } 14127 } //if (country === 'IT') { 14128 // this.model.address = city.formatted_address; 14129 //} 14130 14131 14132 _this2.busyCity = true; 14133 }); 14134 document.querySelector('#cities-input input').addEventListener('blur', function () { 14135 var geocoder = _this2.geocoder || new google.maps.Geocoder(); 14136 _this2.geocoder = geocoder; 14137 geocoder.geocode({ 14138 address: _this2.model.city 14139 }, function (results, status) { 14140 if (status == 'OK') { 14141 var filteredInfoCity = results[0].address_components.filter(function (address_component) { 14142 return address_component.types.includes("country"); 14143 }); 14144 var country = filteredInfoCity.length ? filteredInfoCity[0].short_name : ''; 14145 _this2.requiredAddress = country === 'IT' ? true : false; 14146 14147 if (_this2.requiredAddress) { 14148 var city = autocompleteUnique.getPlace(); 14149 var address = []; 14150 14151 if (city.address_components !== undefined) { 14152 address = city.address_components.filter(function (address_component) { 14153 return address_component.types.includes("route"); 14154 }); 14155 } 14156 14157 if (address.length !== 0) { 14158 _this2.model.address = angular.element('#cities-input input').val(); 14159 $("#errorNotes").hide(); 14160 } else { 14161 //$("#errorNotes").html('*Complete address is required for this country!'); 14162 $("#errorNotes").show(); 14163 } 14164 } 14165 14166 _this2.busyCity = true; 14167 14168 _this2.$scope.$apply(); 14169 } 14170 }); 14171 }); 14172 this.loadAllStores(); 14173 this.loadAllAgents(); 14174 }; 14175 14176 _proto.calculateDistance = function calculateDistance(lat1, lon1, lat2, lon2, unit) { 14177 if (lat1 == lat2 && lon1 == lon2) { 14178 return 0; 14179 } else { 14180 var radlat1 = Math.PI * lat1 / 180; 14181 var radlat2 = Math.PI * lat2 / 180; 14182 var theta = lon1 - lon2; 14183 var radtheta = Math.PI * theta / 180; 14184 var dist = Math.sin(radlat1) * Math.sin(radlat2) + Math.cos(radlat1) * Math.cos(radlat2) * Math.cos(radtheta); 14185 14186 if (dist > 1) { 14187 dist = 1; 14188 } 14189 14190 dist = Math.acos(dist); 14191 dist = dist * 180 / Math.PI; 14192 dist = dist * 60 * 1.1515; 14193 14194 if (unit == "K") { 14195 dist = dist * 1.609344; 14196 } 14197 14198 if (unit == "N") { 14199 dist = dist * 0.8684; 14200 } 14201 14202 return dist; 14203 } 14204 }; 14205 14206 _proto.clearMarkers = function clearMarkers() { 14207 if (this.markerCluster) { 14208 this.markerCluster.clearMarkers(); 14209 } 14210 14211 for (var i = 0; i < this.stores.length; i++) { 14212 if (this.stores[i].marker) { 14213 this.stores[i].marker.setMap(null); 14214 this.stores[i].marker = null; 14215 } 14216 } 14217 14218 if (this.markerAgentCluster) { 14219 this.markerAgentCluster.clearMarkers(); 14220 } 14221 14222 for (var _i = 0; _i < this.agents.length; _i++) { 14223 if (this.agents[_i].marker) { 14224 this.agents[_i].marker.setMap(null); 14225 14226 this.agents[_i].marker = null; 14227 } 14228 } 14229 }; 14230 14231 _proto.addMarkers = function addMarkers(stores) { 14232 var _this3 = this; 14233 14234 var markers = stores.map(function (store) { 14235 var nomeContenutoGA4 = store.title; 14236 if (window.data.province && !window.data.searchByTextBox) nomeContenutoGA4 = nomeContenutoGA4 + "_" + window.data.provinciaGA4; 14237 var position = new google.maps.LatLng(store.latitude, store.longitude); 14238 var content = "<div class=\"marker__content\">\n\t\t\t\t<div class=\"title\"><span>" + store.title + "</span></div>\n\t\t\t\t<div class=\"group group--info\">\n\t\t\t\t\t<div class=\"address\">\n\t\t\t\t\t\t" + store.address + "<br>\n\t\t\t\t\t\t" + store.zip + " " + store.city + " " + store.provinceCode + " " + store.countryCode + "<br>\n\t\t\t\t\t\t" + (store.telephone ? "<span class=\"dtEventSend\" gtm data-gtm-eventname=\"store_locator_interactions\" data-gtm-position=\"map\" data-gtm-label=\"get_call\" data-gtm-nomecontenuto=\"" + store.title + "\"><a href=\"tel:" + store.telephone + "\">" + store.telephone + "</a><br></span>" : '') + "\n\t\t\t\t\t\t" + (store.website ? "<span><a target=\"_blank\" href=\"" + store.website + "\">" + store.website + "</a></span>" : '') + "\n\t\t\t\t\t</div>\n\t\t\t\t\t" + (store.address !== '' ? "<div class=\"distance\">" + _this3.labels.approximately + " <b>" + Math.floor(store.distance) + " km</b></div>" : "") + "\n\t\t\t\t</div>\n\t\t\t\t<div class=\"group group--cta\">\n\t\t\t\t\t" + (store.address !== '' ? "<a id=\"locator-marker\" href=\"https://www.google.it/maps/dir/" + position.lat() + "," + position.lng() + "/" + store.title + "/@" + store.latitude + "," + store.longitude + "/\" target=\"_blank\" class=\"btn btn--link dtEventSend\" gtm data-gtm-eventname=\"store_locator_interactions\" data-gtm-position=\"map\" data-gtm-label=\"get_direction\" data-gtm-nomecontenuto=\"" + store.title + "\"><span>" + _this3.labels.reachStore + "</span></a>" : "") + "\n\n\t\t\t\t\t" + (store.type === 8 || store.type === 9 ? "<a id=\"contact-store\" href=\"" + window.storeLocatorSettings.urlStoreContact + "?store=" + store.id + "\" target=\"_blank\" class=\"btn btn--link dtEventSend\" gtm data-gtm-eventname=\"store_locator_interactions\" data-gtm-position=\"map\" data-gtm-label=\"contact_store\" data-gtm-nomecontenuto=" + nomeContenutoGA4 + ("><span>" + _this3.labels.contactStore + "</span></a>") : '') + "\n\t\t\t\t</div>\n\t\t\t</div>"; 14239 var icon = ['pin-showroom.png', 'pin-top-store.png', 'pin-reseller.png'][store.type - 8]; 14240 var marker = new google.maps.Marker({ 14241 position: position, 14242 // map: this.map, 14243 icon: "" + BASEPATH + icon, 14244 title: store.title, 14245 store: store, 14246 content: content 14247 }); 14248 marker.addListener('click', function () { 14249 _this3.setMarkerWindow(marker.position, content); 14250 14251 _this3.scrollToStore(store); // GtmService.push({ event: 'dealerlocator', action: 'marker-click', label: store.title }); 14252 14253 }); 14254 store.marker = marker; 14255 return marker; 14256 }); 14257 var markerCluster = new MarkerClusterer(this.map, markers, { 14258 imagePath: BASEPATH + "cluster-" 14259 }); 14260 var styles = markerCluster.getStyles();
14261 styles.forEach(function (style) { 14262 return style.textColor = '#ffffff'; 14263 }); 14264 markerCluster.setStyles(styles); 14265 this.markers = markers; 14266 this.markerCluster = markerCluster; 14267 }; 14268 14269 _proto.addAgentsMarkers = function addAgentsMarkers(agents) { 14270 var _this4 = this; 14271 14272 var markers = agents.map(function (agent) { 14273 //console.log('agent.latitude ', agent.latitude, ' agent.longitude ', agent.longitude, ' this.position.lat() ', this.position.lat(), ' this.position.lng() ', this.position.lng()); 14274 var position = new google.maps.LatLng(agent.latitude === null ? _this4.position.lat() : agent.latitude, agent.longitude === null ? _this4.position.lng() : agent.longitude); 14275 var content = "<div class=\"marker__content\">\n\t\t\t\t<div class=\"title\"><span>" + agent.title + "</span></div>\n\t\t\t\t<div class=\"group group--info\">\n\t\t\t\t\t<div class=\"address\">\n\t\t\t\t\t\t" + (agent.address ? "" + agent.address : '') + "<br>\n\t\t\t\t\t\t" + (agent.zip ? "" + agent.zip : '') + " " + (agent.city ? "" + agent.city : '') + " " + (agent.province ? "" + agent.province : '') + " " + agent.countries + "<br>\n\t\t\t\t\t\t" + (agent.telephone ? "<span class=\"dtEventSend\" gtm data-gtm-eventname=\"store_locator_interactions\" data-gtm-position=\"map\" data-gtm-label=\"get_call\" data-gtm-nomecontenuto=\"" + store.title + "\"><a href=\"tel:" + agent.telephone + "\">" + agent.telephone + "</a><br></span>" : '') + "\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t<div class=\"group group--cta\">\n\t\t\t\t\t<a id=\"contact-store\" href=\"" + window.storeLocatorSettings.urlStoreContact + "?agent=" + agent.id + "\" target=\"_blank\" class=\"btn btn--link\"><span>" + _this4.labels.contactAgent + "</span></a>\n\t\t\t\t</div>\n\t\t\t</div>"; 14276 var icon = 'pin-reseller.png'; 14277 var marker = new google.maps.Marker({ 14278 position: position, 14279 // map: this.map, 14280 icon: "" + BASEPATH + icon, 14281 title: agent.title, 14282 store: agent, 14283 content: content 14284 }); 14285 marker.addListener('click', function () { 14286 _this4.setMarkerWindow(marker.position, content); //this.scrollToStore(store); 14287 // GtmService.push({ event: 'dealerlocator', action: 'marker-click', label: store.title }); 14288 14289 }); 14290 agent.marker = marker; 14291 return marker; 14292 }); 14293 var markerCluster = new MarkerClusterer(this.map, markers, { 14294 imagePath: BASEPATH + "cluster-" 14295 }); 14296 var styles = markerCluster.getStyles(); 14297 styles.forEach(function (style) { 14298 return style.textColor = '#ffffff'; 14299 }); 14300 markerCluster.setStyles(styles); 14301 this.markers = markers; 14302 this.markerAgentCluster = markerCluster; 14303 }; 14304 14305 _proto.getGeolocation = function getGeolocation(map) { 14306 var _this5 = this; 14307 14308 this.error = null; 14309 this.busyLocation = true; 14310 var position = this.map.getCenter(); // Try HTML5 geolocation. 14311 14312 if (navigator.geolocation) { 14313 navigator.geolocation.getCurrentPosition(function (location) { 14314 position = new google.maps.LatLng(location.coords.latitude, location.coords.longitude); 14315 var geocoder = _this5.geocoder || new google.maps.Geocoder(); 14316 _this5.geocoder = geocoder; 14317 geocoder.geocode({ 14318 'location': position 14319 }, function (results, status) { 14320 if (status == 'OK') { 14321 var filteredInfoCity = results.filter(function (address_component) { 14322 return address_component.types.includes("locality"); 14323 }); 14324 _this5.model.city = filteredInfoCity.length ? filteredInfoCity[0].formatted_address : undefined; 14325 _this5.model.address = results[0].formatted_address; 14326 14327 for (var i = 0; i < results[0].address_components.length; i++) { 14328 if (results[0].address_components[i].types[0] == "country" || results[0].address_components[i].types[0] == "political") { 14329 _this5.searchCountry = results[0].address_components[i].short_name; 14330 } 14331 } 14332 14333 _this5.setInfoWindow(position, 1); 14334 14335 _this5.searchPosition(position).finally(function () { 14336 return _this5.busyLocation = false;
14337 }); 14338 14339 _this5.map.setCenter(position); 14340 14341 _this5.map.setZoom(ZOOM_LEVEL); 14342 } 14343 }); 14344 }, function () { 14345 _this5.setInfoWindow(position, 2); 14346 14347 _this5.searchPosition(position).finally(function () { 14348 return _this5.busyLocation = false; 14349 }); 14350 }); 14351 } else { 14352 // Browser doesn't support Geolocation 14353 this.setInfoWindow(position, 3); 14354 this.searchPosition(position).finally(function () { 14355 return _this5.busyLocation = false; 14356 }); 14357 } 14358 }; 14359 14360 _proto.loadAllStores = function loadAllStores() { 14361 var _this6 = this; 14362 14363 //if (this.stores) { 14364 // return Promise.resolve(this.stores); 14365 //} 14366 // this.loadFakeStores(); 14367 var isStatic = false; 14368 return this.apiService.storeLocator.all(isStatic).then(function (success) { 14369 var stores = success.data.d.storeList; //success.data; // success.data.d.storeList; 14370 14371 stores.forEach(function (store) { 14372 return store.distance = _this6.position ? _this6.calculateDistance(store.latitude, store.longitude, _this6.position.lat(), _this6.position.lng(), 'K') : ''; 14373 }); 14374 _this6.visibleItems = []; 14375 _this6.maxItems = ITEMS_PER_PAGE$1; 14376 _this6.stores = stores; 14377 _this6.visibleItems = _this6.getStoresByViewport(); 14378 return stores; 14379 }); 14380 }; 14381 14382 _proto.loadAllAgents = function loadAllAgents() { 14383 14384 this.agents = []; 14385 return this.agents; 14386 }; 14387 14388 _proto.loadFakeStores = function loadFakeStores() { 14389 return fetch("https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=Ceramiche&inputtype=textquery&fields=name,formatted_address,address_components,formatted_phone_number,geometry" + (this.apiKey ? "&key=" + this.apiKey : ''), { 14390 mode: 'cors' 14391 }).then(function (response) { 14392 return response.json(); 14393 }).then(function (json) { 14394 console.log('json', json); 14395 return json.candidates.map(function (x, i) { 14396 return { 14397 id: i + 1, 14398 latitude: x.geometry.location.lat, 14399 longitude: x.geometry.location.lng, 14400 title: x.name, 14401 address: x.formatted_address, 14402 type: 1 + Math.floor(Math.random() * 3) 14403 }; 14404 }); 14405 /* 14406 { 14407 id: 2, 14408 latitude: 44.5902807, 14409 longitude: 10.721454, 14410 title: 'Lea Ceramiche', 14411 abstract: 'Negozio di piastrelle ceramiche', 14412 address: 'Via Statale, 127', 14413 zip: '42013', 14414 city: 'Casalgrande', 14415 province: 'Reggio Emilia', 14416 provinceCode: 'RE', 14417 country: 'Italia', 14418 countryCode: 'IT', 14419 telephone: '+39 0536 837811', 14420 email: '[email protected]', 14421 website: 'https://www.ceramichelea.it/', 14422 image: './img/store-locator/[email protected]', 14423 type: 3 14424 } 14425 */ 14426 }); 14427 }; 14428 14429 _proto.fitBounds = function fitBounds(stores) { 14430 if (stores.length) { 14431 var bounds = new google.maps.LatLngBounds(); 14432 stores.forEach(function (store) { 14433 var position = new google.maps.LatLng(store.latitude, store.longitude); 14434 bounds.extend(position); 14435 }); 14436 this.map.fitBounds(bounds); // console.log('fitBounds'); 14437 } 14438 }; 14439 14440 _proto.findNearStores = function findNearStores(stores, position) { 14441 var _this8 = this; 14442 14443 if (stores) { 14444 stores.forEach(function (store) { 14445 store.distance = _this8.calculateDistance(store.latitude, store.longitude, position.lat(), position.lng(), 'K'); 14446 store.visible = (store.cod_stato == window.userCountry || !window.userCountry) && store.distance <= MAX_DISTANCE 14447 /* Km */ 14448 ; 14449 14450 if (store.visible) { 14451 if (store.removed) _this8.markerCluster.addMarker(store.marker); 14452 delete store.removed; 14453 } else { 14454 _this8.markerCluster.removeMarker(store.marker); 14455 14456 store.removed = true; 14457 } 14458 }); 14459 stores = stores.slice(); 14460 stores.sort(function (a, b) { 14461 //return a.distance * (a.importante ? 0.5 : 1) - b.distance * (b.importante ? 0.5 : 1); 14462 return a.distance - b.distance; 14463 }); 14464 var visibleStores = stores.filter(function (store) { 14465 return store.visible; 14466 }).slice(0, 50); 14467 this.$timeout(function () { 14468 _this8.visibleStores = visibleStores; 14469 }, 1); // console.log('findNearStores', visibleStores); 14470 14471 return visibleStores; 14472 } 14473 }; 14474 14475 _proto.searchPosition = function searchPosition(position, viewport) { 14476 var _this9 = this; 14477 14478 this.position = position; 14479 this.viewport = viewport; 14480 this.map.setCenter(position); 14481 this.map.setZoom(ZOOM_LEVEL); 14482 this.setInfoWindow(position, 1); 14483 return this.loadAllStores().then(function (success) { 14484 _this9.clearMarkers(); 14485 14486 _this9.closeMarkerWindow(); 14487
14488 _this9.stores.forEach(function (store) { 14489 return store.distance = _this9.position ? _this9.calculateDistance(store.latitude, store.longitude, _this9.position.lat(), _this9.position.lng(), 'K') : ''; 14490 }); 14491 14492 _this9.stores = _this9.stores.sort(function (a, b) { 14493 if (a.type === b.type) { 14494 return a.distance - b.distance; 14495 } else { 14496 return a.type - b.type; 14497 } 14498 }); // if (continentAmerica[this.searchCountry] === undefined) { 14499 // //Ricerca negli altri continenti 14500 // if (this.countryContainsStores(this.searchCountry)) { 14501 // //console.log('#1'); 14502 // // Vengono aggiunti solo i marker del paese ricercato. 14503 // var storesByCountry = this.getStoresByCountry(this.searchCountry); 14504 // //console.log('storesByCountry ', storesByCountry); 14505 // if (storesByCountry.length > 6) { 14506 // storesByCountry = storesByCountry.sort((a, b) => { 14507 // return a.distance - b.distance; 14508 // }); 14509 // storesByCountry = storesByCountry.filter(function (store) { 14510 // //console.log('store ', store); 14511 // return store.distance <= 150; 14512 // }).slice(0, 6); 14513 // } 14514 // this.addMarkers(storesByCountry); 14515 // // 2a. Cerco i pin in un raggio di 50Km, eventualmente lo estendo se non c'è nulla. 14516 // for (let searchRadius = 50000; searchRadius <= 600000; searchRadius += 50000) { 14517 // var searchBounds = new google.maps.Circle({ center: position, radius: searchRadius }).getBounds(); 14518 // if (this.boundsContainsStores(searchBounds)) { 14519 // break; 14520 // } 14521 // } 14522 // if (searchBounds) { 14523 // //console.log('this.searchCountry ', this.searchCountry, ' searchBounds ', searchBounds, ' this.viewport ', this.viewport); 14524 // if (storesByCountry.length === 1 && this.searchCountry !== 'AU') { 14525 // //console.log('#1.1'); 14526 // this.map.fitBounds(this.viewport); 14527 // this.map.setZoom(6); 14528 // } else { 14529 // //console.log('#1.2'); 14530 // if (this.searchCountry === 'AU') { 14531 // const geocoder = this.geocoder || new google.maps.Geocoder(); 14532 // this.geocoder = geocoder; 14533 // geocoder.geocode({ address: 'Australia' }, (results, status) => { 14534 // if (status == 'OK') { 14535 // const viewportUS = results[0].geometry.viewport; 14536 // this.map.fitBounds(viewportUS); 14537 // } 14538 // }); 14539 // } else { 14540 // this.map.fitBounds(searchBounds, 0); 14541 // } 14542 // this.map.fitBounds(searchBounds, 0); 14543 // } 14544 // this.map.panToBounds(searchBounds); 14545 // } 14546 // } else { 14547 // //console.log('#2'); 14548 // // Se non ci sono store nel paese ricercato allora mostro il mondo intero e il PIN Showroom Italia. 14549 // let italyMainStore = this.stores[1]; 14550 // this.addMarkers([italyMainStore]); 14551 // this.map.fitBounds(this.getWorldBounds()); 14552 // this.map.panTo(new google.maps.LatLng(italyMainStore.latitude, italyMainStore.longitude)); 14553 // this.setMarkerWindow(italyMainStore.marker.position, italyMainStore.marker.content); 14554 // } 14555 // } else { 14556 // //console.log('#3'); 14557 // //Ricerca nel continente americano 14558 // let USAMainStore = this.stores[0]; 14559 // this.addMarkers([USAMainStore]); 14560 // this.map.fitBounds(this.getWorldBounds()); 14561 // this.map.panTo(new google.maps.LatLng(USAMainStore.latitude, USAMainStore.longitude)); 14562 // this.setMarkerWindow(USAMainStore.marker.position, USAMainStore.marker.content); 14563 // } 14564 // const visibleStores = this.findNearStores(stores, position); 14565 14566 /* 14567 if (visibleStores) { 14568 this.fitBounds(visibleStores); 14569 } 14570 */ 14571 }); 14572 }; 14573 14574 _proto.panTo = function panTo(store) { 14575 var position = new google.maps.LatLng(store.latitude, store.longitude); 14576 this.map.setZoom(ZOOM_LEVEL); 14577 this.map.panTo(position); 14578 var marker = this.markers.find(function (x) { 14579 return x.store === store; 14580 }); 14581 this.setMarkerWindow(marker.position, marker.content); 14582 }; 14583 14584 _proto.onSubmit = function onSubmit() { 14585 var _this10 = this; 14586 14587 var target = document.getElementById("results"); 14588 target.scrollIntoView({ 14589 behavior: "smooth", 14590 block: "start" 14591 }); 14592 this.$timeout(function () { 14593 if (_this10.busyCity) { 14594 _this10.error = null; 14595 _this10.busyFind = true; 14596 /* 14597 const fakeFilter = {
14598 '': { 14599 value: this.model.address, 14600 options: [ 14601 { 14602 value: this.model.address, 14603 key: this.model.address 14604 } 14605 ] 14606 } 14607 }; 14608 GtmService.pageViewFilters(GTM_CAT, fakeFilter); 14609 */ 14610 14611 var geocoder = _this10.geocoder || new google.maps.Geocoder(); 14612 _this10.geocoder = geocoder; 14613 geocoder.geocode({ 14614 address: _this10.requiredAddress ? _this10.model.address : _this10.model.city 14615 }, function (results, status) { 14616 _this10.model = { 14617 city: _this10.model.city, 14618 address: _this10.model.address 14619 }; 14620 14621 if (status == 'OK') { 14622 var position = results[0].geometry.location; 14623 var viewport = results[0].geometry.viewport; 14624 console.log('results ', results); 14625 14626 for (var i = 0; i < results[0].address_components.length; i++) { 14627 if (results[0].address_components[i].types[0] == "country" || results[0].address_components[i].types[0] == "political") { 14628 _this10.searchCountry = results[0].address_components[i].short_name; 14629 } 14630 } 14631 14632 for (var _i2 = 0; _i2 < results[0].address_components.length; _i2++) { 14633 if (results[0].address_components[_i2].types[0] == "administrative_area_level_2") { 14634 _this10.searchProvinceCode = results[0].address_components[_i2].short_name; 14635 } 14636 } 14637 14638 for (var _i3 = 0; _i3 < results[0].address_components.length; _i3++) { 14639 if (results[0].address_components[_i3].types[0] == "administrative_area_level_3" || results[0].address_components[_i3].types[0] == "locality") { 14640 _this10.searchCity = results[0].address_components[_i3].short_name; 14641 } 14642 } 14643 14644 for (var _i4 = 0; _i4 < results[0].address_components.length; _i4++) { 14645 if (results[0].address_components[_i4].types[0] == "administrative_area_level_1") { 14646 _this10.searchArea = results[0].address_components[_i4].short_name; 14647 } 14648 } //console.log('this.searchProvinceCode ', this.searchProvinceCode, ' this.searchCity ', this.searchCity); 14649 14650 14651 var obj = Object.assign({}, window.objDataLayerInfo); 14652 obj["eventname"] = "store_locator_search"; 14653 obj["searchterm"] = results.length > 0 ? results[0].formatted_address : ""; 14654 GtmService.push(obj); // console.log('location', location); 14655 // const position = new google.maps.LatLng(location); 14656 14657 _this10.searchPosition(position, viewport).finally(function () { 14658 return _this10.busyFind = false; 14659 }, _this10.model.address = _this10.model.address, _this10.countSearch++); 14660 } else { 14661 _this10.$timeout(function () { 14662 var message = 'Geocode was not successful for the following reason: ' + status; // console.log('StoreLocatorCtrl.onSubmit.error', message); 14663 14664 _this10.error = { 14665 message: message 14666 }; 14667 _this10.busyFind = false; 14668 }); 14669 } 14670 }); 14671 } 14672 }, 500); 14673 }; 14674 14675 _proto.setInfoWindow = function setInfoWindow(position, mode) { 14676 }; 14677 14678 _proto.setMarkerWindow = function setMarkerWindow(position, content) { 14679 if (position) { 14680 var markerWindow = this.markerWindow || new google.maps.InfoWindow({ 14681 pixelOffset: new google.maps.Size(0, -35) 14682 }); 14683 this.markerWindow = markerWindow; 14684 markerWindow.setPosition(position); 14685 markerWindow.setContent(content); 14686 markerWindow.open(this.map); 14687 } else { 14688 this.closeMarkerWindow(); 14689 } 14690 }; 14691 14692 _proto.closeMarkerWindow = function closeMarkerWindow() { 14693 if (this.markerWindow) { 14694 this.markerWindow.close(); 14695 } 14696 }; 14697 14698 _proto.getWorldBounds = function getWorldBounds() { 14699 return new google.maps.LatLngBounds(new google.maps.LatLng(61, 60), new google.maps.LatLng(-37, -92)); 14700 }; 14701 14702 _proto.getItalyBounds = function getItalyBounds() { 14703 return new google.maps.LatLngBounds(new google.maps.LatLng(46.4657567, 5.233972), new google.maps.LatLng(36.8257773, 18.963541)); 14704 }; 14705 14706 _proto.getFranceBounds = function getFranceBounds() { 14707 return new google.maps.LatLngBounds(new google.maps.LatLng(51.15040672463023, -5.271186534462046), new google.maps.LatLng(42.191156239056426, 7.84728980702387)); 14708 }; 14709 14710 _proto.scrollToStore = function scrollToStore(store) { 14711 var storesNode = document.querySelector('.section--stores'); 14712 var storeNode = document.querySelector("#store-" + store.id); // console.log(storesNode, storeNode); 14713 14714 storesNode.scrollTo(0, storeNode.offsetTop); 14715 }; 14716 14717 _proto.onScroll = function onScroll(event) { 14718 var _this11 = this; 14719 14720 if (this.visibleItems && this.visibleItems.length !== this.maxItems) { 14721 if (event.rect.top + event.rect.height < event.windowRect.bottom) { 14722 var _this$stores; 14723 14724 if (!this.busy && this.maxItems < ((_this$stores = this.stores) == null ? void 0 : _this$stores.length)) { 14725 this.$timeout(function () { 14726 _this11.busy = true; 14727 14728 _this11.$timeout(function () {
14729 _this11.maxItems += ITEMS_PER_PAGE$1; 14730 _this11.visibleItems = _this11.getStoresByViewport(); 14731 _this11.busy = false; 14732 console.log(_this11.visibleItems.length); 14733 }, 1000); 14734 }, 0); 14735 } 14736 } 14737 } 14738 }; 14739 14740 _proto.getStoresByCountry = function getStoresByCountry(countryCode) { 14741 var stores = []; 14742 14743 if (this.stores) { 14744 for (var i = 0; i < this.stores.length; i++) { 14745 if (this.stores[i].countryCode === countryCode) { 14746 stores.push(this.stores[i]); 14747 } 14748 } 14749 } 14750 14751 return stores; 14752 }; 14753 14754 _proto.getAgentsByInfo = function getAgentsByInfo(countryCode) { 14755 var agents = []; 14756 var provinceCode = this.searchProvinceCode !== '' ? this.searchProvinceCode : this.stores.length > 0 && this.stores[1].province ? this.stores[1].province : ''; // level_2 - provincia 14757 14758 var cityCode = this.searchCity !== '' ? this.searchCity : this.stores.length > 0 && this.stores[1].city ? this.stores[1].city : ''; // level_3 - città 14759 14760 var areaCode = this.searchArea !== '' ? this.searchArea : this.stores.length > 0 && this.stores[1].city ? this.stores[1].city : ''; // level_1 - area 14761 14762 if (countryCode !== '') { 14763 if (countryCode === 'IT' || countryCode === 'FR' || countryCode === 'DE') { 14764 //facendo così, mentre per l'Italia riceviamo un provinceCode del tipo 'RM' (indipendente dalla lingua), per la Francia ci viene restituito 'Parigi' o 'Paris' 14765 //a seconda della lingua quindi per trovare il match dobbiamo registrare più "coperture" per gli agenti, in tutte le lingue 14766 agents = _.filter(this.agents, function (o) { 14767 return o.countries_detail !== null && o.countries_detail.indexOf(countryCode) !== -1 && (o.administrative_area_level_2_detail !== null && o.administrative_area_level_2_detail.map(function (el) { 14768 return el.trim(); 14769 }).indexOf(provinceCode.trim()) !== -1 || // controllo anche se google mi ha passato l'informazione che cerco (copertura agente administrative_level_2) 14770 // in un altro campo: administrative_level_1, administrative_level_3... Fondamentale per la Germania! 14771 o.administrative_area_level_2_detail !== null && o.administrative_area_level_2_detail.map(function (el) { 14772 return el.trim(); 14773 }).indexOf(cityCode.trim()) !== -1 || o.administrative_area_level_2_detail !== null && o.administrative_area_level_2_detail.map(function (el) { 14774 return el.trim(); 14775 }).indexOf(areaCode.trim()) !== -1); 14776 }); 14777 } else { 14778 agents = _.filter(this.agents, function (o) { 14779 return o.countries_detail !== null && o.countries_detail.indexOf(countryCode) !== -1; 14780 }); 14781 } 14782 } //non mettiamo il market per l'agente 14783 //agents.forEach((agent) => { 14784 // const geocoder = this.geocoder || new google.maps.Geocoder(); 14785 // this.geocoder = geocoder; 14786 // geocoder.geocode({ address: agent.administrative_area_level_1 }, (results, status) => { 14787 // if (status == 'OK') { 14788 // agent.latitude = results[0].geometry.location.lat(); 14789 // agent.longitude = results[0].geometry.location.lng(); 14790 // } else { 14791 // agent.latitude = null; 14792 // agent.longitude = null; 14793 // } 14794 // }); 14795 //}); 14796 14797 14798 agents = _.sortBy(agents, function (o) { 14799 return o.order; 14800 }); 14801 return agents; 14802 }; 14803 14804 _proto.countryContainsStores = function countryContainsStores(countryCode) { 14805 if (this.stores) { 14806 for (var i = 0; i < this.stores.length; i++) { 14807 if (this.stores[i].countryCode === countryCode) { 14808 return true; 14809 } 14810 } 14811 } 14812 14813 return false; 14814 }; 14815 14816 _proto.boundsContainsStores = function boundsContainsStores(bounds) { 14817 if (this.stores) { 14818 for (var i = 0; i < this.stores.length; i++) { 14819 if (this.stores[i].marker && bounds.contains(this.stores[i].marker.getPosition())) { 14820 return true; 14821 } 14822 } 14823 } 14824 14825 return false; 14826 }; 14827 14828 _proto.getStoresByViewport = function getStoresByViewport() { 14829 var visibleItems = []; 14830 14831 if (this.stores) { 14832 for (var i = 0; i < this.stores.length; i++) { 14833 if (this.stores[i].marker && this.map.getBounds().contains(this.stores[i].marker.getPosition())) { 14834 visibleItems.push(this.stores[i]); 14835 } 14836 } 14837 } 14838 14839 visibleItems = visibleItems.sort(function (a, b) { 14840 //if (a.type === b.type) { 14841 return a.distance - b.distance; //} else { 14842 // return a.type - b.type; 14843 //} 14844 }); 14845 return visibleItems; //.slice(0, 3); 14846 }; 14847 14848 return StoreLocatorCtrl; 14849 }(); 14850 14851 StoreLocatorCtrl.$inject = ['$scope', '$timeout', 'DomService', 'ApiService']; 14852 14853 var fastDeepEqual = function equal(a, b) {
14854 if (a === b) return true; 14855 14856 if (a && b && typeof a == 'object' && typeof b == 'object') { 14857 if (a.constructor !== b.constructor) return false; 14858 var length, i, keys; 14859 14860 if (Array.isArray(a)) { 14861 length = a.length; 14862 if (length != b.length) return false; 14863 14864 for (i = length; i-- !== 0;) { 14865 if (!equal(a[i], b[i])) return false; 14866 } 14867 14868 return true; 14869 } 14870 14871 if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags; 14872 if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf(); 14873 if (a.toString !== Object.prototype.toString) return a.toString() === b.toString(); 14874 keys = Object.keys(a); 14875 length = keys.length; 14876 if (length !== Object.keys(b).length) return false; 14877 14878 for (i = length; i-- !== 0;) { 14879 if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false; 14880 } 14881 14882 for (i = length; i-- !== 0;) { 14883 var key = keys[i]; 14884 if (!equal(a[key], b[key])) return false; 14885 } 14886 14887 return true; 14888 } // true if both NaN, false otherwise 14889 14890 14891 return a !== a && b !== b; 14892 }; 14893 14894 var ARRAY_TYPES = [Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array]; 14895 /** @typedef {Int8ArrayConstructor | Uint8ArrayConstructor | Uint8ClampedArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor} TypedArrayConstructor */ 14896 14897 var VERSION = 1; // serialized format version 14898 14899 var HEADER_SIZE = 8; 14900 14901 var KDBush = /*#__PURE__*/function () { 14902 /** 14903 * Creates an index from raw `ArrayBuffer` data. 14904 * @param {ArrayBuffer} data 14905 */ 14906 KDBush.from = function from(data) { 14907 if (!(data instanceof ArrayBuffer)) { 14908 throw new Error('Data must be an instance of ArrayBuffer.'); 14909 } 14910 14911 var _Uint8Array = new Uint8Array(data, 0, 2), 14912 magic = _Uint8Array[0], 14913 versionAndType = _Uint8Array[1]; 14914 14915 if (magic !== 0xdb) { 14916 throw new Error('Data does not appear to be in a KDBush format.'); 14917 } 14918 14919 var version = versionAndType >> 4; 14920 14921 if (version !== VERSION) { 14922 throw new Error("Got v" + version + " data when expected v" + VERSION + "."); 14923 } 14924 14925 var ArrayType = ARRAY_TYPES[versionAndType & 0x0f]; 14926 14927 if (!ArrayType) { 14928 throw new Error('Unrecognized array type.'); 14929 } 14930 14931 var _Uint16Array = new Uint16Array(data, 2, 1), 14932 nodeSize = _Uint16Array[0]; 14933 14934 var _Uint32Array = new Uint32Array(data, 4, 1), 14935 numItems = _Uint32Array[0]; 14936 14937 return new KDBush(numItems, nodeSize, ArrayType, data); 14938 } 14939 /** 14940 * Creates an index that will hold a given number of items. 14941 * @param {number} numItems 14942 * @param {number} [nodeSize=64] Size of the KD-tree node (64 by default). 14943 * @param {TypedArrayConstructor} [ArrayType=Float64Array] The array type used for coordinates storage (`Float64Array` by default). 14944 * @param {ArrayBuffer} [data] (For internal use only) 14945 */ 14946 ; 14947 14948 function KDBush(numItems, nodeSize, ArrayType, data) { 14949 if (nodeSize === void 0) { 14950 nodeSize = 64; 14951 } 14952 14953 if (ArrayType === void 0) { 14954 ArrayType = Float64Array; 14955 } 14956 14957 if (isNaN(numItems) || numItems < 0) throw new Error("Unpexpected numItems value: " + numItems + "."); 14958 this.numItems = +numItems; 14959 this.nodeSize = Math.min(Math.max(+nodeSize, 2), 65535); 14960 this.ArrayType = ArrayType; 14961 this.IndexArrayType = numItems < 65536 ? Uint16Array : Uint32Array; 14962 var arrayTypeIndex = ARRAY_TYPES.indexOf(this.ArrayType); 14963 var coordsByteSize = numItems * 2 * this.ArrayType.BYTES_PER_ELEMENT; 14964 var idsByteSize = numItems * this.IndexArrayType.BYTES_PER_ELEMENT; 14965 var padCoords = (8 - idsByteSize % 8) % 8; 14966 14967 if (arrayTypeIndex < 0) { 14968 throw new Error("Unexpected typed array class: " + ArrayType + "."); 14969 } 14970 14971 if (data && data instanceof ArrayBuffer) { 14972 // reconstruct an index from a buffer 14973 this.data = data; 14974 this.ids = new this.IndexArrayType(this.data, HEADER_SIZE, numItems); 14975 this.coords = new this.ArrayType(this.data, HEADER_SIZE + idsByteSize + padCoords, numItems * 2); 14976 this._pos = numItems * 2; 14977 this._finished = true; 14978 } else { 14979 // initialize a new index 14980 this.data = new ArrayBuffer(HEADER_SIZE + coordsByteSize + idsByteSize + padCoords); 14981 this.ids = new this.IndexArrayType(this.data, HEADER_SIZE, numItems); 14982 this.coords = new this.ArrayType(this.data, HEADER_SIZE + idsByteSize + padCoords, numItems * 2); 14983 this._pos = 0; 14984 this._finished = false; // set header 14985 14986 new Uint8Array(this.data, 0, 2).set([0xdb, (VERSION << 4) + arrayTypeIndex]); 14987 new Uint16Array(this.data, 2, 1)[0] = nodeSize; 14988 new Uint32Array(this.data, 4, 1)[0] = numItems; 14989 } 14990 } 14991 /** 14992 * Add a point to the index. 14993 * @param {number} x 14994 * @param {number} y 14995 * @returns {number} An incremental index associated with the added item (starting from `0`). 14996 */ 14997 14998 14999 var _proto = KDBush.prototype; 15000 15001 _proto.add = function add(x, y) { 15002 var index = this._pos >> 1; 15003 this.ids[index] = index; 15004 this.coords[this._pos++] = x; 15005 this.coords[this._pos++] = y; 15006 return index; 15007 } 15008 /** 15009 * Perform indexing of the added points. 15010 */ 15011 ; 15012 15013 _proto.finish = function finish() { 15014 var numAdded = this._pos >> 1; 15015 15016 if (numAdded !== this.numItems) { 15017 throw new Error("Added " + numAdded + " items when expected " + this.numItems + "."); 15018 } // kd-sort both arrays for efficient search 15019 15020 15021 sort(this.ids, this.coords, this.nodeSize, 0, this.numItems - 1, 0); 15022 this._finished = true; 15023 return this; 15024 } 15025 /** 15026 * Search the index for items within a given bounding box. 15027 * @param {number} minX 15028 * @param {number} minY 15029 * @param {number} maxX 15030 * @param {number} maxY 15031 * @returns {number[]} An array of indices correponding to the found items. 15032 */ 15033 ; 15034 15035 _proto.range = function range(minX, minY, maxX, maxY) { 15036 if (!this._finished) throw new Error('Data not yet indexed - call index.finish().'); 15037 var ids = this.ids, 15038 coords = this.coords, 15039 nodeSize = this.nodeSize; 15040 var stack = [0, ids.length - 1, 0]; 15041 var result = []; // recursively search for items in range in the kd-sorted arrays 15042 15043 while (stack.length) { 15044 var axis = stack.pop() || 0; 15045 var right = stack.pop() || 0; 15046 var left = stack.pop() || 0; // if we reached "tree node", search linearly 15047 15048 if (right - left <= nodeSize) { 15049 for (var i = left; i <= right; i++) { 15050 var _x = coords[2 * i]; 15051 var _y = coords[2 * i + 1]; 15052 if (_x >= minX && _x <= maxX && _y >= minY && _y <= maxY) result.push(ids[i]); 15053 } 15054 15055 continue; 15056 } // otherwise find the middle index 15057 15058 15059 var m = left + right >> 1; // include the middle item if it's in range 15060 15061 var x = coords[2 * m]; 15062 var y = coords[2 * m + 1]; 15063 if (x >= minX && x <= maxX && y >= minY && y <= maxY) result.push(ids[m]); // queue search in halves that intersect the query 15064 15065 if (axis === 0 ? minX <= x : minY <= y) { 15066 stack.push(left); 15067 stack.push(m - 1); 15068 stack.push(1 - axis); 15069 } 15070 15071 if (axis === 0 ? maxX >= x : maxY >= y) { 15072 stack.push(m + 1); 15073 stack.push(right); 15074 stack.push(1 - axis); 15075 } 15076 } 15077 15078 return result; 15079 } 15080 /** 15081 * Search the index for items within a given radius. 15082 * @param {number} qx 15083 * @param {number} qy 15084 * @param {number}
15084 r Query radius. 15085 * @returns {number[]} An array of indices correponding to the found items. 15086 */ 15087 ; 15088 15089 _proto.within = function within(qx, qy, r) { 15090 if (!this._finished) throw new Error('Data not yet indexed - call index.finish().'); 15091 var ids = this.ids, 15092 coords = this.coords, 15093 nodeSize = this.nodeSize; 15094 var stack = [0, ids.length - 1, 0]; 15095 var result = []; 15096 var r2 = r * r; // recursively search for items within radius in the kd-sorted arrays 15097 15098 while (stack.length) { 15099 var axis = stack.pop() || 0; 15100 var right = stack.pop() || 0; 15101 var left = stack.pop() || 0; // if we reached "tree node", search linearly 15102 15103 if (right - left <= nodeSize) { 15104 for (var i = left; i <= right; i++) { 15105 if (sqDist(coords[2 * i], coords[2 * i + 1], qx, qy) <= r2) result.push(ids[i]); 15106 } 15107 15108 continue; 15109 } // otherwise find the middle index 15110 15111 15112 var m = left + right >> 1; // include the middle item if it's in range 15113 15114 var x = coords[2 * m]; 15115 var y = coords[2 * m + 1]; 15116 if (sqDist(x, y, qx, qy) <= r2) result.push(ids[m]); // queue search in halves that intersect the query 15117 15118 if (axis === 0 ? qx - r <= x : qy - r <= y) { 15119 stack.push(left); 15120 stack.push(m - 1); 15121 stack.push(1 - axis); 15122 } 15123 15124 if (axis === 0 ? qx + r >= x : qy + r >= y) { 15125 stack.push(m + 1); 15126 stack.push(right); 15127 stack.push(1 - axis); 15128 } 15129 } 15130 15131 return result; 15132 }; 15133 15134 return KDBush; 15135 }(); 15136 15137 function sort(ids, coords, nodeSize, left, right, axis) { 15138 if (right - left <= nodeSize) return; 15139 var m = left + right >> 1; // middle index 15140 // sort ids and coords around the middle index so that the halves lie 15141 // either left/right or top/bottom correspondingly (taking turns) 15142 15143 select(ids, coords, m, left, right, axis); // recursively kd-sort first half and second half on the opposite axis 15144 15145 sort(ids, coords, nodeSize, left, m - 1, 1 - axis); 15146 sort(ids, coords, nodeSize, m + 1, right, 1 - axis); 15147 } 15148 /** 15149 * Custom Floyd-Rivest selection algorithm: sort ids and coords so that 15150 * [left..k-1] items are smaller than k-th item (on either x or y axis) 15151 * @param {Uint16Array | Uint32Array} ids 15152 * @param {InstanceType<TypedArrayConstructor>} coords 15153 * @param {number} k 15154 * @param {number} left 15155 * @param {number} right 15156 * @param {number} axis 15157 */ 15158 15159 15160 function select(ids, coords, k, left, right, axis) { 15161 while (right > left) { 15162 if (right - left > 600) { 15163 var n = right - left + 1; 15164 var m = k - left + 1; 15165 var z = Math.log(n); 15166 var s = 0.5 * Math.exp(2 * z / 3); 15167 var sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1); 15168 var newLeft = Math.max(left, Math.floor(k - m * s / n + sd)); 15169 var newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd)); 15170 select(ids, coords, k, newLeft, newRight, axis); 15171 } 15172 15173 var t = coords[2 * k + axis]; 15174 var i = left; 15175 var j = right; 15176 swapItem(ids, coords, left, k); 15177 if (coords[2 * right + axis] > t) swapItem(ids, coords, left, right); 15178 15179 while (i < j) { 15180 swapItem(ids, coords, i, j); 15181 i++; 15182 j--; 15183 15184 while (coords[2 * i + axis] < t) { 15185 i++; 15186 } 15187 15188 while (coords[2 * j + axis] > t) { 15189 j--; 15190 } 15191 } 15192 15193 if (coords[2 * left + axis] === t) swapItem(ids, coords, left, j);else { 15194 j++; 15195 swapItem(ids, coords, j, right); 15196 } 15197 if (j <= k) left = j + 1; 15198 if (k <= j) right = j - 1; 15199 } 15200 } 15201 /** 15202 * @param {Uint16Array | Uint32Array} ids 15203 * @param {InstanceType<TypedArrayConstructor>} coords 15204 * @param {number} i 15205 * @param {number} j 15206 */ 15207 15208 15209 function swapItem(ids, coords, i, j) { 15210 swap(ids, i, j); 15211 swap(coords, 2 * i, 2 * j); 15212 swap(coords, 2 * i + 1, 2 * j + 1); 15213 } 15214 /** 15215 * @param {InstanceType<TypedArrayConstructor>} arr 15216 * @param {number} i 15217 * @param {number} j 15218 */ 15219 15220 15221 function swap(arr, i, j) { 15222 var tmp = arr[i]; 15223 arr[i] = arr[j]; 15224 arr[j] = tmp; 15225 } 15226 /** 15227 * @param {number} ax 15228 * @param {number} ay 15229 * @param {number} bx 15230 * @param {number} by 15231 */ 15232 15233 15234 function sqDist(ax, ay, bx, by) { 15235 var dx = ax - bx; 15236 var dy = ay - by; 15237 return dx * dx + dy * dy; 15238 } 15239 15240 var defaultOptions = { 15241 minZoom: 0,
15242 // min zoom to generate clusters on 15243 maxZoom: 16, 15244 // max zoom level to cluster the points on 15245 minPoints: 2, 15246 // minimum points to form a cluster 15247 radius: 40, 15248 // cluster radius in pixels 15249 extent: 512, 15250 // tile extent (radius is calculated relative to it) 15251 nodeSize: 64, 15252 // size of the KD-tree leaf node, affects performance 15253 log: false, 15254 // whether to log timing info 15255 // whether to generate numeric ids for input features (in vector tiles) 15256 generateId: false, 15257 // a reduce function for calculating custom cluster properties 15258 reduce: null, 15259 // (accumulated, props) => { accumulated.sum += props.sum; } 15260 // properties to use for individual points when running the reducer 15261 map: function map(props) { 15262 return props; 15263 } // props => ({sum: props.my_value}) 15264 15265 }; 15266 15267 var fround = Math.fround || function (tmp) { 15268 return function (x) { 15269 tmp[0] = +x; 15270 return tmp[0]; 15271 }; 15272 }(new Float32Array(1)); 15273 15274 var OFFSET_ZOOM = 2; 15275 var OFFSET_ID = 3; 15276 var OFFSET_PARENT = 4; 15277 var OFFSET_NUM = 5; 15278 var OFFSET_PROP = 6; 15279 15280 var Supercluster = /*#__PURE__*/function () { 15281 function Supercluster(options) { 15282 this.options = Object.assign(Object.create(defaultOptions), options); 15283 this.trees = new Array(this.options.maxZoom + 1); 15284 this.stride = this.options.reduce ? 7 : 6; 15285 this.clusterProps = []; 15286 } 15287 15288 var _proto = Supercluster.prototype; 15289 15290 _proto.load = function load(points) { 15291 var _this$options = this.options, 15292 log = _this$options.log, 15293 minZoom = _this$options.minZoom, 15294 maxZoom = _this$options.maxZoom; 15295 if (log) console.time('total time'); 15296 var timerId = "prepare " + points.length + " points"; 15297 if (log) console.time(timerId); 15298 this.points = points; // generate a cluster object for each point and index input points into a KD-tree 15299 15300 var data = []; 15301 15302 for (var i = 0; i < points.length; i++) { 15303 var p = points[i]; 15304 if (!p.geometry) continue; 15305 var _p$geometry$coordinat = p.geometry.coordinates, 15306 lng = _p$geometry$coordinat[0], 15307 lat = _p$geometry$coordinat[1]; 15308 var x = fround(lngX(lng)); 15309 var y = fround(latY(lat)); // store internal point/cluster data in flat numeric arrays for performance 15310 15311 data.push(x, y, // projected point coordinates 15312 Infinity, // the last zoom the point was processed at 15313 i, // index of the source feature in the original input array 15314 -1, // parent cluster id 15315 1 // number of points in a cluster 15316 ); 15317 if (this.options.reduce) data.push(0); // noop 15318 } 15319 15320 var tree = this.trees[maxZoom + 1] = this._createTree(data); 15321 15322 if (log) console.timeEnd(timerId); // cluster points on max zoom, then cluster the results on previous zoom, etc.; 15323 // results in a cluster hierarchy across zoom levels 15324 15325 for (var z = maxZoom; z >= minZoom; z--) { 15326 var now = +Date.now(); // create a new set of clusters for the zoom and index them with a KD-tree 15327 15328 tree = this.trees[z] = this._createTree(this._cluster(tree, z)); 15329 if (log) console.log('z%d: %d clusters in %dms', z, tree.numItems, +Date.now() - now); 15330 } 15331 15332 if (log) console.timeEnd('total time'); 15333 return this; 15334 }; 15335 15336 _proto.getClusters = function getClusters(bbox, zoom) { 15337 var minLng = ((bbox[0] + 180) % 360 + 360) % 360 - 180; 15338 var minLat = Math.max(-90, Math.min(90, bbox[1])); 15339 var maxLng = bbox[2] === 180 ? 180 : ((bbox[2] + 180) % 360 + 360) % 360 - 180; 15340 var maxLat = Math.max(-90, Math.min(90, bbox[3])); 15341 15342 if (bbox[2] - bbox[0] >= 360) { 15343 minLng = -180; 15344 maxLng = 180; 15345 } else if (minLng > maxLng) { 15346 var easternHem = this.getClusters([minLng, minLat, 180, maxLat], zoom); 15347 var westernHem = this.getClusters([-180, minLat, maxLng, maxLat], zoom); 15348 return easternHem.concat(westernHem); 15349 } 15350 15351 var tree = this.trees[this._limitZoom(zoom)]; 15352 15353 var ids = tree.range(lngX(minLng), latY(maxLat), lngX(maxLng), latY(minLat)); 15354 var data = tree.data; 15355 var clusters = []; 15356 15357 for (var _iterator = _createForOfIteratorHelperLoose(ids), _step; !(_step = _iterator()).done;) { 15358 var id = _step.value; 15359 var k = this.stride * id;
15360 clusters.push(data[k + OFFSET_NUM] > 1 ? getClusterJSON(data, k, this.clusterProps) : this.points[data[k + OFFSET_ID]]); 15361 } 15362 15363 return clusters; 15364 }; 15365 15366 _proto.getChildren = function getChildren(clusterId) { 15367 var originId = this._getOriginId(clusterId); 15368 15369 var originZoom = this._getOriginZoom(clusterId); 15370 15371 var errorMsg = 'No cluster with the specified id.'; 15372 var tree = this.trees[originZoom]; 15373 if (!tree) throw new Error(errorMsg); 15374 var data = tree.data; 15375 if (originId * this.stride >= data.length) throw new Error(errorMsg); 15376 var r = this.options.radius / (this.options.extent * Math.pow(2, originZoom - 1)); 15377 var x = data[originId * this.stride]; 15378 var y = data[originId * this.stride + 1]; 15379 var ids = tree.within(x, y, r); 15380 var children = []; 15381 15382 for (var _iterator2 = _createForOfIteratorHelperLoose(ids), _step2; !(_step2 = _iterator2()).done;) { 15383 var id = _step2.value; 15384 var k = id * this.stride; 15385 15386 if (data[k + OFFSET_PARENT] === clusterId) { 15387 children.push(data[k + OFFSET_NUM] > 1 ? getClusterJSON(data, k, this.clusterProps) : this.points[data[k + OFFSET_ID]]); 15388 } 15389 } 15390 15391 if (children.length === 0) throw new Error(errorMsg); 15392 return children; 15393 }; 15394 15395 _proto.getLeaves = function getLeaves(clusterId, limit, offset) { 15396 limit = limit || 10; 15397 offset = offset || 0; 15398 var leaves = []; 15399 15400 this._appendLeaves(leaves, clusterId, limit, offset, 0); 15401 15402 return leaves; 15403 }; 15404 15405 _proto.getTile = function getTile(z, x, y) { 15406 var tree = this.trees[this._limitZoom(z)]; 15407 15408 var z2 = Math.pow(2, z); 15409 var _this$options2 = this.options, 15410 extent = _this$options2.extent, 15411 radius = _this$options2.radius; 15412 var p = radius / extent; 15413 var top = (y - p) / z2; 15414 var bottom = (y + 1 + p) / z2; 15415 var tile = { 15416 features: [] 15417 }; 15418 15419 this._addTileFeatures(tree.range((x - p) / z2, top, (x + 1 + p) / z2, bottom), tree.data, x, y, z2, tile); 15420 15421 if (x === 0) { 15422 this._addTileFeatures(tree.range(1 - p / z2, top, 1, bottom), tree.data, z2, y, z2, tile); 15423 } 15424 15425 if (x === z2 - 1) { 15426 this._addTileFeatures(tree.range(0, top, p / z2, bottom), tree.data, -1, y, z2, tile); 15427 } 15428 15429 return tile.features.length ? tile : null; 15430 }; 15431 15432 _proto.getClusterExpansionZoom = function getClusterExpansionZoom(clusterId) { 15433 var expansionZoom = this._getOriginZoom(clusterId) - 1; 15434 15435 while (expansionZoom <= this.options.maxZoom) { 15436 var children = this.getChildren(clusterId); 15437 expansionZoom++; 15438 if (children.length !== 1) break; 15439 clusterId = children[0].properties.cluster_id; 15440 } 15441 15442 return expansionZoom; 15443 }; 15444 15445 _proto._appendLeaves = function _appendLeaves(result, clusterId, limit, offset, skipped) { 15446 var children = this.getChildren(clusterId); 15447 15448 for (var _iterator3 = _createForOfIteratorHelperLoose(children), _step3; !(_step3 = _iterator3()).done;) { 15449 var child = _step3.value; 15450 var props = child.properties; 15451 15452 if (props && props.cluster) { 15453 if (skipped + props.point_count <= offset) { 15454 // skip the whole cluster 15455 skipped += props.point_count; 15456 } else { 15457 // enter the cluster 15458 skipped = this._appendLeaves(result, props.cluster_id, limit, offset, skipped); // exit the cluster 15459 } 15460 } else if (skipped < offset) { 15461 // skip a single point 15462 skipped++; 15463 } else { 15464 // add a single point 15465 result.push(child); 15466 } 15467 15468 if (result.length === limit) break; 15469 } 15470 15471 return skipped; 15472 }; 15473 15474 _proto._createTree = function _createTree(data) { 15475 var tree = new KDBush(data.length / this.stride | 0, this.options.nodeSize, Float32Array); 15476 15477 for (var i = 0; i < data.length; i += this.stride) { 15478 tree.add(data[i], data[i + 1]); 15479 } 15480 15481 tree.finish(); 15482 tree.data = data; 15483 return tree; 15484 }; 15485 15486 _proto._addTileFeatures = function _addTileFeatures(ids, data, x, y, z2, tile) { 15487 for (var _iterator4 = _createForOfIteratorHelperLoose(ids), _step4; !(_step4 = _iterator4()).done;) { 15488 var i = _step4.value; 15489 var k = i * this.stride; 15490 var isCluster = data[k + OFFSET_NUM] > 1; 15491 var tags = void 0, 15492 px = void 0, 15493 py = void 0; 15494 15495 if (isCluster) { 15496 tags = getClusterProperties(data, k, this.clusterProps); 15497 px = data[k]; 15498 py = data[k + 1]; 15499 } else { 15500 var p = this.points[data[k + OFFSET_ID]]; 15501 tags = p.properties; 15502 var _p$geometry$coordinat2 = p.geometry.coordinates, 15503 lng = _p$geometry$coordinat2[0], 15504 lat = _p$geometry$coordinat2[1]; 15505 px = lngX(lng); 15506 py = latY(lat); 15507 } 15508 15509 var f = { 15510 type: 1, 15511 geometry: [[Math.round(this.options.extent * (px * z2 - x)), Math.round(this.options.extent * (py * z2 - y))]], 15512 tags: tags 15513 }; // assign id 15514 15515 var id = void 0; 15516 15517 if (isCluster || this.options.generateId) { 15518 // optionally generate id for points 15519 id = data[k + OFFSET_ID]; 15520 } else { 15521 // keep id if already assigned 15522 id = this.points[data[k + OFFSET_ID]].id; 15523 } 15524 15525 if (id !== undefined) f.id = id; 15526 tile.features.push(f); 15527 } 15528 }; 15529 15530 _proto._limitZoom = function _limitZoom(z) { 15531 return Math.max(this.options.minZoom, Math.min(Math.floor(+z), this.options.maxZoom + 1)); 15532 }; 15533 15534 _proto._cluster = function _cluster(tree, zoom) { 15535 var _this$options3 = this.options, 15536 radius = _this$options3.radius, 15537 extent = _this$options3.extent, 15538 reduce = _this$options3.reduce, 15539 minPoints = _this$options3.minPoints; 15540 var r = radius / (extent * Math.pow(2, zoom)); 15541 var data = tree.data; 15542 var nextData = []; 15543 var stride = this.stride; // loop through each point 15544 15545 for (var i = 0; i < data.length; i += stride) { 15546 // if we've already visited the point at this zoom level, skip it 15547 if (data[i + OFFSET_ZOOM] <= zoom) continue; 15548 data[i + OFFSET_ZOOM] = zoom; // find all nearby points 15549 15550 var x = data[i]; 15551 var y = data[i + 1]; 15552 var neighborIds = tree.within(data[i], data[i + 1], r); 15553 var numPointsOrigin = data[i + OFFSET_NUM]; 15554 var numPoints = numPointsOrigin; // count the number of points in a potential cluster 15555 15556 for (var _iterator5 = _createForOfIteratorHelperLoose(neighborIds), _step5; !(_step5 = _iterator5()).done;) { 15557 var _neighborId2 = _step5.value; 15558 15559 var _k2 = _neighborId2 * stride; // filter out neighbors that are already processed 15560 15561 15562 if (data[_k2 + OFFSET_ZOOM] > zoom) numPoints += data[_k2 + OFFSET_NUM]; 15563 } // if there were neighbors to merge, and there are enough points to form a cluster 15564 15565 15566 if (numPoints > numPointsOrigin && numPoints >= minPoints) { 15567 var wx = x * numPointsOrigin; 15568 var wy = y * numPointsOrigin; 15569 var clusterProperties = void 0; 15570 var clusterPropIndex = -1; // encode both zoom and point index on which the cluster originated -- offset by total length of features 15571 15572 var id = ((i / stride | 0) << 5) + (zoom + 1) + this.points.length; 15573 15574 for (var _iterator6 = _createForOfIteratorHelperLoose(neighborIds), _step6; !(_step6 = _iterator6()).done;) { 15575 var neighborId = _step6.value;
15576 var k = neighborId * stride; 15577 if (data[k + OFFSET_ZOOM] <= zoom) continue; 15578 data[k + OFFSET_ZOOM] = zoom; // save the zoom (so it doesn't get processed twice) 15579 15580 var numPoints2 = data[k + OFFSET_NUM]; 15581 wx += data[k] * numPoints2; // accumulate coordinates for calculating weighted center 15582 15583 wy += data[k + 1] * numPoints2; 15584 data[k + OFFSET_PARENT] = id; 15585 15586 if (reduce) { 15587 if (!clusterProperties) { 15588 clusterProperties = this._map(data, i, true); 15589 clusterPropIndex = this.clusterProps.length; 15590 this.clusterProps.push(clusterProperties); 15591 } 15592 15593 reduce(clusterProperties, this._map(data, k)); 15594 } 15595 } 15596 15597 data[i + OFFSET_PARENT] = id; 15598 nextData.push(wx / numPoints, wy / numPoints, Infinity, id, -1, numPoints); 15599 if (reduce) nextData.push(clusterPropIndex); 15600 } else { 15601 // left points as unclustered 15602 for (var j = 0; j < stride; j++) { 15603 nextData.push(data[i + j]); 15604 } 15605 15606 if (numPoints > 1) { 15607 for (var _iterator7 = _createForOfIteratorHelperLoose(neighborIds), _step7; !(_step7 = _iterator7()).done;) { 15608 var _neighborId = _step7.value; 15609 15610 var _k = _neighborId * stride; 15611 15612 if (data[_k + OFFSET_ZOOM] <= zoom) continue; 15613 data[_k + OFFSET_ZOOM] = zoom; 15614 15615 for (var _j = 0; _j < stride; _j++) { 15616 nextData.push(data[_k + _j]); 15617 } 15618 } 15619 } 15620 } 15621 } 15622 15623 return nextData; 15624 } // get index of the point from which the cluster originated 15625 ; 15626 15627 _proto._getOriginId = function _getOriginId(clusterId) { 15628 return clusterId - this.points.length >> 5; 15629 } // get zoom of the point from which the cluster originated 15630 ; 15631 15632 _proto._getOriginZoom = function _getOriginZoom(clusterId) { 15633 return (clusterId - this.points.length) % 32; 15634 }; 15635 15636 _proto._map = function _map(data, i, clone) { 15637 if (data[i + OFFSET_NUM] > 1) { 15638 var props = this.clusterProps[data[i + OFFSET_PROP]]; 15639 return clone ? Object.assign({}, props) : props; 15640 } 15641 15642 var original = this.points[data[i + OFFSET_ID]].properties; 15643 var result = this.options.map(original); 15644 return clone && result === original ? Object.assign({}, result) : result; 15645 }; 15646 15647 return Supercluster; 15648 }(); 15649 15650 function getClusterJSON(data, i, clusterProps) { 15651 return { 15652 type: 'Feature', 15653 id: data[i + OFFSET_ID], 15654 properties: getClusterProperties(data, i, clusterProps), 15655 geometry: { 15656 type: 'Point', 15657 coordinates: [xLng(data[i]), yLat(data[i + 1])] 15658 } 15659 }; 15660 } 15661 15662 function getClusterProperties(data, i, clusterProps) { 15663 var count = data[i + OFFSET_NUM]; 15664 var abbrev = count >= 10000 ? Math.round(count / 1000) + "k" : count >= 1000 ? Math.round(count / 100) / 10 + "k" : count; 15665 var propIndex = data[i + OFFSET_PROP]; 15666 var properties = propIndex === -1 ? {} : Object.assign({}, clusterProps[propIndex]); 15667 return Object.assign(properties, { 15668 cluster: true, 15669 cluster_id: data[i + OFFSET_ID], 15670 point_count: count, 15671 point_count_abbreviated: abbrev 15672 }); 15673 } // longitude/latitude to spherical mercator in [0..1] range 15674 15675 15676 function lngX(lng) { 15677 return lng / 360 + 0.5; 15678 } 15679 15680 function latY(lat) { 15681 var sin = Math.sin(lat * Math.PI / 180); 15682 var y = 0.5 - 0.25 * Math.log((1 + sin) / (1 - sin)) / Math.PI; 15683 return y < 0 ? 0 : y > 1 ? 1 : y; 15684 } // spherical mercator to longitude/latitude 15685 15686 15687 function xLng(x) { 15688 return (x - 0.5) * 360; 15689 } 15690 15691 function yLat(y) { 15692 var y2 = (180 - y * 360) * Math.PI / 180; 15693 return 360 * Math.atan(Math.exp(y2)) / Math.PI - 90; 15694 } 15695 15696 /*! ***************************************************************************** 15697 Copyright (c) Microsoft Corporation. 15698 15699 Permission to use, copy, modify, and/or distribute this software for any 15700 purpose with or without fee is hereby granted. 15701 15702 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 15703 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 15704 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 15705 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 15706 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 15707 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 15708 PERFORMANCE OF THIS SOFTWARE. 15709 ***************************************************************************** */ 15710 15711 function __rest(s, e) { 15712 var t = {}; 15713 15714 for (var p in s) { 15715 if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; 15716 } 15717 15718 if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { 15719 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; 15720 } 15721 return t; 15722 }
15723 /** 15724 * Copyright 2023 Google LLC 15725 * 15726 * Licensed under the Apache License, Version 2.0 (the "License"); 15727 * you may not use this file except in compliance with the License. 15728 * You may obtain a copy of the License at 15729 * 15730 * http://www.apache.org/licenses/LICENSE-2.0 15731 * 15732 * Unless required by applicable law or agreed to in writing, software 15733 * distributed under the License is distributed on an "AS IS" BASIS, 15734 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15735 * See the License for the specific language governing permissions and 15736 * limitations under the License. 15737 */ 15738 15739 /** 15740 * util class that creates a common set of convenience functions to wrap 15741 * shared behavior of Advanced Markers and Markers. 15742 */ 15743 15744 15745 var MarkerUtils = /*#__PURE__*/function () { 15746 function MarkerUtils() {} 15747 15748 MarkerUtils.isAdvancedMarkerAvailable = function isAdvancedMarkerAvailable(map) { 15749 return google.maps.marker && map.getMapCapabilities().isAdvancedMarkersAvailable === true; 15750 }; 15751 15752 MarkerUtils.isAdvancedMarker = function isAdvancedMarker(marker) { 15753 return google.maps.marker && marker instanceof google.maps.marker.AdvancedMarkerElement; 15754 }; 15755 15756 MarkerUtils.setMap = function setMap(marker, map) { 15757 if (this.isAdvancedMarker(marker)) { 15758 marker.map = map; 15759 } else { 15760 marker.setMap(map); 15761 } 15762 }; 15763 15764 MarkerUtils.getPosition = function getPosition(marker) { 15765 // SuperClusterAlgorithm.calculate expects a LatLng instance so we fake it for Adv Markers 15766 if (this.isAdvancedMarker(marker)) { 15767 if (marker.position) { 15768 if (marker.position instanceof google.maps.LatLng) { 15769 return marker.position; 15770 } // since we can't cast to LatLngLiteral for reasons =( 15771 15772 15773 if (marker.position.lat && marker.position.lng) { 15774 return new google.maps.LatLng(marker.position.lat, marker.position.lng); 15775 } 15776 } 15777 15778 return new google.maps.LatLng(null); 15779 } 15780 15781 return marker.getPosition(); 15782 }; 15783 15784 MarkerUtils.getVisible = function getVisible(marker) { 15785 if (this.isAdvancedMarker(marker)) { 15786 /** 15787 * Always return true for Advanced Markers because the clusterer 15788 * uses getVisible as a way to count legacy markers not as an actual 15789 * indicator of visibility for some reason. Even when markers are hidden 15790 * Marker.getVisible returns `true` and this is used to set the marker count 15791 * on the cluster. See the behavior of Cluster.count 15792 */ 15793 return true; 15794 } 15795 15796 return marker.getVisible(); 15797 }; 15798 15799 return MarkerUtils; 15800 }(); 15801 /** 15802 * Copyright 2021 Google LLC 15803 * 15804 * Licensed under the Apache License, Version 2.0 (the "License"); 15805 * you may not use this file except in compliance with the License. 15806 * You may obtain a copy of the License at 15807 * 15808 * http://www.apache.org/licenses/LICENSE-2.0 15809 * 15810 * Unless required by applicable law or agreed to in writing, software 15811 * distributed under the License is distributed on an "AS IS" BASIS, 15812 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15813 * See the License for the specific language governing permissions and 15814 * limitations under the License. 15815 */ 15816 15817 15818 var Cluster = /*#__PURE__*/function () { 15819 function Cluster(_ref) { 15820 var markers = _ref.markers, 15821 position = _ref.position; 15822 this.markers = markers; 15823 15824 if (position) { 15825 if (position instanceof google.maps.LatLng) { 15826 this._position = position; 15827 } else { 15828 this._position = new google.maps.LatLng(position); 15829 } 15830 } 15831 } 15832 15833 var _proto = Cluster.prototype; 15834 15835 /** 15836 * Add a marker to the cluster. 15837 */ 15838 _proto.push = function push(marker) { 15839 this.markers.push(marker); 15840 } 15841 /** 15842 * Cleanup references and remove marker from map. 15843 */ 15844 ; 15845 15846 _proto.delete = function _delete() { 15847 if (this.marker) { 15848 MarkerUtils.setMap(this.marker, null); 15849 this.marker = undefined; 15850 } 15851 15852 this.markers.length = 0; 15853 }; 15854 15855 _createClass(Cluster, [{ 15856 key: "bounds", 15857 get: function get() { 15858 if (this.markers.length === 0 && !this._position) { 15859 return; 15860 } 15861 15862 var bounds = new google.maps.LatLngBounds(this._position, this._position); 15863 15864 for (var _iterator = _createForOfIteratorHelperLoose(this.markers), _step; !(_step = _iterator()).done;) { 15865 var marker = _step.value; 15866 bounds.extend(MarkerUtils.getPosition(marker)); 15867 } 15868 15869 return bounds; 15870 } 15871 }, { 15872 key: "position", 15873 get: function get() { 15874 return this._position || this.bounds.getCenter(); 15875 } 15876 /** 15877 * Get the count of **visible** markers. 15878 */ 15879 15880 }, { 15881 key: "count", 15882 get: function get() { 15883 return this.markers.filter(function (m) { 15884 return MarkerUtils.getVisible(m); 15885 }).length; 15886 } 15887 }]); 15888 15889 return Cluster; 15890 }(); 15891 /** 15892 * Copyright 2021 Google LLC 15893 * 15894 * Licensed under the Apache License, Version 2.0 (the "License");
15895 * you may not use this file except in compliance with the License. 15896 * You may obtain a copy of the License at 15897 * 15898 * http://www.apache.org/licenses/LICENSE-2.0 15899 * 15900 * Unless required by applicable law or agreed to in writing, software 15901 * distributed under the License is distributed on an "AS IS" BASIS, 15902 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15903 * See the License for the specific language governing permissions and 15904 * limitations under the License. 15905 */ 15906 15907 /** 15908 * @hidden 15909 */ 15910 15911 15912 var AbstractAlgorithm = /*#__PURE__*/function () { 15913 function AbstractAlgorithm(_ref4) { 15914 var _ref4$maxZoom = _ref4.maxZoom, 15915 maxZoom = _ref4$maxZoom === void 0 ? 16 : _ref4$maxZoom; 15916 this.maxZoom = maxZoom; 15917 } 15918 /** 15919 * Helper function to bypass clustering based upon some map state such as 15920 * zoom, number of markers, etc. 15921 * 15922 * ```typescript 15923 * cluster({markers, map}: AlgorithmInput): Cluster[] { 15924 * if (shouldBypassClustering(map)) { 15925 * return this.noop({markers}) 15926 * } 15927 * } 15928 * ``` 15929 */ 15930 15931 15932 var _proto2 = AbstractAlgorithm.prototype; 15933 15934 _proto2.noop = function noop(_ref5) { 15935 var markers = _ref5.markers; 15936 return _noop(markers); 15937 }; 15938 15939 return AbstractAlgorithm; 15940 }(); 15941 /** 15942 * @hidden 15943 */ 15944 15945 15946 var _noop = function _noop(markers) { 15947 var clusters = markers.map(function (marker) { 15948 return new Cluster({ 15949 position: MarkerUtils.getPosition(marker), 15950 markers: [marker] 15951 }); 15952 }); 15953 return clusters; 15954 }; 15955 /** 15956 * Copyright 2021 Google LLC 15957 * 15958 * Licensed under the Apache License, Version 2.0 (the "License"); 15959 * you may not use this file except in compliance with the License. 15960 * You may obtain a copy of the License at 15961 * 15962 * http://www.apache.org/licenses/LICENSE-2.0 15963 * 15964 * Unless required by applicable law or agreed to in writing, software 15965 * distributed under the License is distributed on an "AS IS" BASIS, 15966 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15967 * See the License for the specific language governing permissions and 15968 * limitations under the License. 15969 */ 15970 15971 /** 15972 * A very fast JavaScript algorithm for geospatial point clustering using KD trees. 15973 * 15974 * @see https://www.npmjs.com/package/supercluster for more information on options. 15975 */ 15976 15977 15978 var SuperClusterAlgorithm = /*#__PURE__*/function (_AbstractAlgorithm3) { 15979 _inheritsLoose(SuperClusterAlgorithm, _AbstractAlgorithm3); 15980 15981 function SuperClusterAlgorithm(_a) { 15982 var _this4; 15983 15984 var maxZoom = _a.maxZoom, 15985 _a$radius = _a.radius, 15986 radius = _a$radius === void 0 ? 60 : _a$radius, 15987 options = __rest(_a, ["maxZoom", "radius"]); 15988 15989 _this4 = _AbstractAlgorithm3.call(this, { 15990 maxZoom: maxZoom 15991 }) || this; 15992 _this4.state = { 15993 zoom: -1 15994 }; 15995 _this4.superCluster = new Supercluster(Object.assign({ 15996 maxZoom: _this4.maxZoom, 15997 radius: radius 15998 }, options)); 15999 return _this4; 16000 } 16001 16002 var _proto6 = SuperClusterAlgorithm.prototype; 16003 16004 _proto6.calculate = function calculate(input) { 16005 var changed = false; 16006 var state = { 16007 zoom: input.map.getZoom() 16008 }; 16009 16010 if (!fastDeepEqual(input.markers, this.markers)) { 16011 changed = true; // TODO use proxy to avoid copy? 16012 16013 this.markers = [].concat(input.markers); 16014 var points = this.markers.map(function (marker) { 16015 var position = MarkerUtils.getPosition(marker); 16016 var coordinates = [position.lng(), position.lat()]; 16017 return { 16018 type: "Feature", 16019 geometry: { 16020 type: "Point", 16021 coordinates: coordinates 16022 }, 16023 properties: { 16024 marker: marker 16025 } 16026 }; 16027 }); 16028 this.superCluster.load(points); 16029 } 16030 16031 if (!changed) { 16032 if (this.state.zoom <= this.maxZoom || state.zoom <= this.maxZoom) { 16033 changed = !fastDeepEqual(this.state, state); 16034 } 16035 } 16036 16037 this.state = state; 16038 16039 if (changed) { 16040 this.clusters = this.cluster(input); 16041 } 16042 16043 return {
16044 clusters: this.clusters, 16045 changed: changed 16046 }; 16047 }; 16048 16049 _proto6.cluster = function cluster(_ref10) { 16050 var _this5 = this; 16051 16052 var map = _ref10.map; 16053 return this.superCluster.getClusters([-180, -90, 180, 90], Math.round(map.getZoom())).map(function (feature) { 16054 return _this5.transformCluster(feature); 16055 }); 16056 }; 16057 16058 _proto6.transformCluster = function transformCluster(_ref11) { 16059 var _ref11$geometry$coord = _ref11.geometry.coordinates, 16060 lng = _ref11$geometry$coord[0], 16061 lat = _ref11$geometry$coord[1], 16062 properties = _ref11.properties; 16063 16064 if (properties.cluster) { 16065 return new Cluster({ 16066 markers: this.superCluster.getLeaves(properties.cluster_id, Infinity).map(function (leaf) { 16067 return leaf.properties.marker; 16068 }), 16069 position: { 16070 lat: lat, 16071 lng: lng 16072 } 16073 }); 16074 } 16075 16076 var marker = properties.marker; 16077 return new Cluster({ 16078 markers: [marker], 16079 position: MarkerUtils.getPosition(marker) 16080 }); 16081 }; 16082 16083 return SuperClusterAlgorithm; 16084 }(AbstractAlgorithm); 16085 /** 16086 * Copyright 2021 Google LLC 16087 * 16088 * Licensed under the Apache License, Version 2.0 (the "License"); 16089 * you may not use this file except in compliance with the License. 16090 * You may obtain a copy of the License at 16091 * 16092 * http://www.apache.org/licenses/LICENSE-2.0 16093 * 16094 * Unless required by applicable law or agreed to in writing, software 16095 * distributed under the License is distributed on an "AS IS" BASIS, 16096 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16097 * See the License for the specific language governing permissions and 16098 * limitations under the License. 16099 */ 16100 16101 /** 16102 * Provides statistics on all clusters in the current render cycle for use in {@link Renderer.render}. 16103 */ 16104 16105 16106 var ClusterStats = function ClusterStats(markers, clusters) { 16107 this.markers = { 16108 sum: markers.length 16109 }; 16110 var clusterMarkerCounts = clusters.map(function (a) { 16111 return a.count; 16112 }); 16113 var clusterMarkerSum = clusterMarkerCounts.reduce(function (a, b) { 16114 return a + b; 16115 }, 0); 16116 this.clusters = { 16117 count: clusters.length, 16118 markers: { 16119 mean: clusterMarkerSum / clusters.length, 16120 sum: clusterMarkerSum, 16121 min: Math.min.apply(Math, clusterMarkerCounts), 16122 max: Math.max.apply(Math, clusterMarkerCounts) 16123 } 16124 }; 16125 }; 16126 16127 var DefaultRenderer = /*#__PURE__*/function () { 16128 function DefaultRenderer() {} 16129 16130 var _proto8 = DefaultRenderer.prototype; 16131 16132 /** 16133 * The default render function for the library used by {@link MarkerClusterer}. 16134 * 16135 * Currently set to use the following: 16136 * 16137 * ```typescript 16138 * // change color if this cluster has more markers than the mean cluster 16139 * const color = 16140 * count > Math.max(10, stats.clusters.markers.mean) 16141 * ? "#ff0000" 16142 * : "#0000ff"; 16143 * 16144 * // create svg url with fill color 16145 * const svg = window.btoa(` 16146 * <svg fill="${color}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 240"> 16147 * <circle cx="120" cy="120" opacity=".6" r="70" /> 16148 * <circle cx="120" cy="120" opacity=".3" r="90" /> 16149 * <circle cx="120" cy="120" opacity=".2" r="110" /> 16150 * <circle cx="120" cy="120" opacity=".1" r="130" /> 16151 * </svg>`); 16152 * 16153 * // create marker using svg icon 16154 * return new google.maps.Marker({ 16155 * position, 16156 * icon: { 16157 * url: `data:image/svg+xml;base64,${svg}`, 16158 * scaledSize: new google.maps.Size(45, 45), 16159 * }, 16160 * label: { 16161 * text: String(count), 16162 * color: "rgba(255,255,255,0.9)", 16163 * fontSize: "12px", 16164 * }, 16165 * // adjust zIndex to be above other markers 16166 * zIndex: 1000 + count, 16167 * }); 16168 * ``` 16169 */ 16170 _proto8.render = function render(_ref14, stats, map) { 16171 var count = _ref14.count, 16172 position = _ref14.position; 16173 // change color if this cluster has more markers than the mean cluster 16174 var color = count > Math.max(10, stats.clusters.markers.mean) ? "#ff0000" : "#0000ff"; // create svg literal with fill color 16175 16176 var svg = "<svg fill=\"" + color + "\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 240 240\" width=\"50\" height=\"50\">\n<circle cx=\"120\" cy=\"120\" opacity=\".6\" r=\"70\" />\n<circle cx=\"120\" cy=\"120\" opacity=\".3\" r=\"90\" />\n<circle cx=\"120\" cy=\"120\" opacity=\".2\" r=\"110\" />\n<text x=\"50%\" y=\"50%\" style=\"fill:#fff\" text-anchor=\"middle\" font-size=\"50\" dominant-baseline=\"middle\" font-family=\"roboto,arial,sans-serif\">" + count + "</text>\n</svg>"; 16177 var title = "Cluster of " + count + " markers", 16178 // adjust zIndex to be above other markers 16179 zIndex = Number(google.maps.Marker.MAX_ZINDEX) + count; 16180 16181 if (MarkerUtils.isAdvancedMarkerAvailable(map)) { 16182 // create cluster SVG element 16183 var parser = new DOMParser(); 16184 var svgEl = parser.parseFromString(svg, "image/svg+xml").documentElement; 16185 svgEl.setAttribute("transform", "translate(0 25)"); 16186 var _clusterOptions = { 16187 map: map, 16188 position: position, 16189 zIndex: zIndex, 16190 title: title, 16191 content: svgEl 16192 }; 16193 return new google.maps.marker.AdvancedMarkerElement(_clusterOptions); 16194 } 16195 16196 var clusterOptions = { 16197 position: position, 16198 zIndex: zIndex, 16199 title: title, 16200 icon: { 16201 url: "data:image/svg+xml;base64," + btoa(svg), 16202 anchor: new google.maps.Point(25, 25) 16203 } 16204 }; 16205 return new google.maps.Marker(clusterOptions); 16206 }; 16207 16208 return DefaultRenderer; 16209 }(); 16210 /** 16211 * Copyright 2019 Google LLC. All Rights Reserved. 16212 * 16213 * Licensed under the Apache License, Version 2.0 (the "License");
16214 * you may not use this file except in compliance with the License. 16215 * You may obtain a copy of the License at 16216 * 16217 * http://www.apache.org/licenses/LICENSE-2.0 16218 * 16219 * Unless required by applicable law or agreed to in writing, software 16220 * distributed under the License is distributed on an "AS IS" BASIS, 16221 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16222 * See the License for the specific language governing permissions and 16223 * limitations under the License. 16224 */ 16225 16226 /** 16227 * Extends an object's prototype by another's. 16228 * 16229 * @param type1 The Type to be extended. 16230 * @param type2 The Type to extend with. 16231 * @ignore 16232 */ 16233 // eslint-disable-next-line @typescript-eslint/no-explicit-any 16234 16235 16236 function extend(type1, type2) { 16237 /* istanbul ignore next */ 16238 // eslint-disable-next-line prefer-const 16239 for (var property in type2.prototype) { 16240 type1.prototype[property] = type2.prototype[property]; 16241 } 16242 } 16243 /** 16244 * @ignore 16245 */ 16246 16247 16248 var OverlayViewSafe = function OverlayViewSafe() { 16249 // MarkerClusterer implements google.maps.OverlayView interface. We use the 16250 // extend function to extend MarkerClusterer with google.maps.OverlayView 16251 // because it might not always be available when the code is defined so we 16252 // look for it at the last possible moment. If it doesn't exist now then 16253 // there is no point going ahead :) 16254 extend(OverlayViewSafe, google.maps.OverlayView); 16255 }; 16256 /** 16257 * Copyright 2021 Google LLC 16258 * 16259 * Licensed under the Apache License, Version 2.0 (the "License"); 16260 * you may not use this file except in compliance with the License. 16261 * You may obtain a copy of the License at 16262 * 16263 * http://www.apache.org/licenses/LICENSE-2.0 16264 * 16265 * Unless required by applicable law or agreed to in writing, software 16266 * distributed under the License is distributed on an "AS IS" BASIS, 16267 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16268 * See the License for the specific language governing permissions and 16269 * limitations under the License. 16270 */ 16271 16272 16273 var MarkerClustererEvents; 16274 16275 (function (MarkerClustererEvents) { 16276 MarkerClustererEvents["CLUSTERING_BEGIN"] = "clusteringbegin"; 16277 MarkerClustererEvents["CLUSTERING_END"] = "clusteringend"; 16278 MarkerClustererEvents["CLUSTER_CLICK"] = "click"; 16279 })(MarkerClustererEvents || (MarkerClustererEvents = {})); 16280 16281 var defaultOnClusterClickHandler = function defaultOnClusterClickHandler(_, cluster, map) { 16282 map.fitBounds(cluster.bounds); 16283 }; 16284 /** 16285 * MarkerClusterer creates and manages per-zoom-level clusters for large amounts 16286 * of markers. See {@link MarkerClustererOptions} for more details. 16287 * 16288 */ 16289 16290 16291 var MarkerClusterer$1 = /*#__PURE__*/function (_OverlayViewSafe) { 16292 _inheritsLoose(MarkerClusterer, _OverlayViewSafe); 16293 16294 function MarkerClusterer(_ref15) { 16295 var _this8; 16296 16297 var map = _ref15.map, 16298 _ref15$markers = _ref15.markers, 16299 markers = _ref15$markers === void 0 ? [] : _ref15$markers, 16300 _ref15$algorithmOptio = _ref15.algorithmOptions, 16301 algorithmOptions = _ref15$algorithmOptio === void 0 ? {} : _ref15$algorithmOptio, 16302 _ref15$algorithm = _ref15.algorithm, 16303 algorithm = _ref15$algorithm === void 0 ? new SuperClusterAlgorithm(algorithmOptions) : _ref15$algorithm, 16304 _ref15$renderer = _ref15.renderer, 16305 renderer = _ref15$renderer === void 0 ? new DefaultRenderer() : _ref15$renderer, 16306 _ref15$onClusterClick = _ref15.onClusterClick, 16307 onClusterClick = _ref15$onClusterClick === void 0 ? defaultOnClusterClickHandler : _ref15$onClusterClick; 16308 _this8 = _OverlayViewSafe.call(this) || this; 16309 _this8.markers = [].concat(markers); 16310 _this8.clusters = []; 16311 _this8.algorithm = algorithm; 16312 _this8.renderer = renderer; 16313 _this8.onClusterClick = onClusterClick; 16314 16315 if (map) { 16316 _this8.setMap(map); 16317 } 16318 16319 return _this8; 16320 } 16321 16322 var _proto9 = MarkerClusterer.prototype; 16323 16324 _proto9.addMarker = function addMarker(marker, noDraw) { 16325 if (this.markers.includes(marker)) { 16326 return; 16327 } 16328 16329 this.markers.push(marker); 16330 16331 if (!noDraw) { 16332 this.render(); 16333 } 16334 }; 16335 16336 _proto9.addMarkers = function addMarkers(markers, noDraw) { 16337 var _this9 = this; 16338
16339 markers.forEach(function (marker) { 16340 _this9.addMarker(marker, true); 16341 }); 16342 16343 if (!noDraw) { 16344 this.render(); 16345 } 16346 }; 16347 16348 _proto9.removeMarker = function removeMarker(marker, noDraw) { 16349 var index = this.markers.indexOf(marker); 16350 16351 if (index === -1) { 16352 // Marker is not in our list of markers, so do nothing: 16353 return false; 16354 } 16355 16356 MarkerUtils.setMap(marker, null); 16357 this.markers.splice(index, 1); // Remove the marker from the list of managed markers 16358 16359 if (!noDraw) { 16360 this.render(); 16361 } 16362 16363 return true; 16364 }; 16365 16366 _proto9.removeMarkers = function removeMarkers(markers, noDraw) { 16367 var _this10 = this; 16368 16369 var removed = false; 16370 markers.forEach(function (marker) { 16371 removed = _this10.removeMarker(marker, true) || removed; 16372 }); 16373 16374 if (removed && !noDraw) { 16375 this.render(); 16376 } 16377 16378 return removed; 16379 }; 16380 16381 _proto9.clearMarkers = function clearMarkers(noDraw) { 16382 this.markers.length = 0; 16383 16384 if (!noDraw) { 16385 this.render(); 16386 } 16387 } 16388 /**
16389 * Recalculates and draws all the marker clusters. 16390 */ 16391 ; 16392 16393 _proto9.render = function render() { 16394 var map = this.getMap(); 16395 16396 if (map instanceof google.maps.Map && map.getProjection()) { 16397 google.maps.event.trigger(this, MarkerClustererEvents.CLUSTERING_BEGIN, this); 16398 16399 var _this$algorithm$calcu = this.algorithm.calculate({ 16400 markers: this.markers, 16401 map: map, 16402 mapCanvasProjection: this.getProjection() 16403 }), 16404 clusters = _this$algorithm$calcu.clusters, 16405 changed = _this$algorithm$calcu.changed; // Allow algorithms to return flag on whether the clusters/markers have changed. 16406 16407 16408 if (changed || changed == undefined) { 16409 // Accumulate the markers of the clusters composed of a single marker. 16410 // Those clusters directly use the marker. 16411 // Clusters with more than one markers use a group marker generated by a renderer. 16412 var singleMarker = new Set(); 16413 16414 for (var _iterator2 = _createForOfIteratorHelperLoose(clusters), _step2; !(_step2 = _iterator2()).done;) { 16415 var cluster = _step2.value; 16416 16417 if (cluster.markers.length == 1) { 16418 singleMarker.add(cluster.markers[0]); 16419 } 16420 } 16421 16422 var groupMarkers = []; // Iterate the clusters that are currently rendered. 16423 16424 for (var _iterator3 = _createForOfIteratorHelperLoose(this.cluster
16424s), _step3; !(_step3 = _iterator3()).done;) { 16425 var _cluster2 = _step3.value; 16426 16427 if (_cluster2.marker == null) { 16428 continue; 16429 } 16430 16431 if (_cluster2.markers.length == 1) { 16432 if (!singleMarker.has(_cluster2.marker)) { 16433 // The marker: 16434 // - was previously rendered because it is from a cluster with 1 marker, 16435 // - should no more be rendered as it is not in singleMarker. 16436 MarkerUtils.setMap(_cluster2.marker, null); 16437 } 16438 } else { 16439 // Delay the removal of old group markers to avoid flickering. 16440 groupMarkers.push(_cluster2.marker); 16441 } 16442 } 16443 16444 this.clusters = clusters; 16445 this.renderClusters(); // Delayed removal of the markers of the former groups. 16446 16447 requestAnimationFrame(function () { 16448 return groupMarkers.forEach(function (marker) { 16449 return MarkerUtils.setMap(marker, null); 16450 }); 16451 }); 16452 } 16453 16454 google.maps.event.trigger(this, MarkerClustererEvents.CLUSTERING_END, this); 16455 } 16456 }; 16457 16458 _proto9.onAdd = function onAdd() { 16459 this.idleListener = this.getMap().addListener("idle", this.render.bind(this)); 16460 this.render(); 16461 }; 16462 16463 _proto9.onRemove = function onRemove() { 16464 google.maps.event.removeListener(this.idleListener); 16465 this.reset(); 16466 }; 16467 16468 _proto9.reset = function reset() { 16469 this.markers.forEach(function (marker) { 16470 return MarkerUtils.setMap(marker, null); 16471 }); 16472 this.clusters.forEach(function (cluster) { 16473 return cluster.delete(); 16474 }); 16475 this.clusters = []; 16476 }; 16477 16478 _proto9.renderClusters = function renderClusters() { 16479 var _this11 = this; 16480 16481 // Generate stats to pass to renderers. 16482 var stats = new ClusterStats(this.markers, this.clusters); 16483 var map = this.getMap(); 16484 this.clusters.forEach(function (cluster) { 16485 if (cluster.markers.length === 1) { 16486 cluster.marker = cluster.markers[0]; 16487 } else { 16488 // Generate the marker to represent the group. 16489 cluster.marker = _this11.renderer.render(cluster, stats, map); // Make sure all individual markers are removed from the map. 16490 16491 cluster.markers.forEach(function (marker) { 16492 return MarkerUtils.setMap(marker, null); 16493 }); 16494 16495 if (_this11.onClusterClick) { 16496 cluster.marker.addListener("click", 16497 /* istanbul ignore next */ 16498 function (event) { 16499 google.maps.event.trigger(_this11, MarkerClustererEvents.CLUSTER_CLICK, cluster); 16500 16501 _this11.onClusterClick(event, cluster, map); 16502 }); 16503 } 16504 } 16505 16506 MarkerUtils.setMap(cluster.marker, map); 16507 }); 16508 }; 16509 16510 return MarkerClusterer; 16511 }(OverlayViewSafe); 16512 16513 var MapCtrl = /*#__PURE__*/function () { 16514 function MapCtrl($scope, $location, $timeout, $document, $window, $http, StateService, $compile) { 16515 var _this = this; 16516 16517 _defineProperty(this, "weekActiveList", {}); 16518 16519 _defineProperty(this, "touchStarted", false); 16520 16521 _defineProperty(this, "lastTouchId", null); 16522 16523 _defineProperty(this, "ordinatiS", { 16524 "street_number": true, 16525 "route": true, 16526 "locality": true, 16527 "administrative_area_level_1": true, 16528 "administrative_area_level_2": true, 16529 "administrative_area_level_3": true, 16530 "country": true, 16531 "postal_code": true 16532 }); 16533 16534 _defineProperty(this, "listCountryCode", []); 16535 16536 this.$scope = $scope; 16537 this.$location = $location; 16538 this.$timeout = $timeout; 16539 this.$document = $document; 16540 this.$window = $window; 16541 this.$http = $http; 16542 this.$compile = $compile; 16543 this.data = window.data || {}; 16544 this.model = {}; 16545 this.isLoadingMap = true; // Variabile per tracciare lo stato di caricamento della mappa 16546 16547 if (this.$location.search() && this.$location.search().email) { 16548 this.model.email = this.$location.search().email; 16549 } 16550 16551 this.state = StateService.getState(); 16552 this.state.ready(); 16553 this.formSubmitted = false; 16554 this.unsubscribe = new Subject(); 16555 this.stores = []; 16556 this.filteredStores = []; 16557 this.showResults = false;
16558 this.showMap = true; // Stato di default attivo 16559 16560 this.sortCriteria = 'rilevanza'; // default sorting criteria 16561 16562 this.activeStore = null; // currently active store 16563 16564 this.searchLocation = null; // store the location of the search 16565 16566 this.searchQuery = ''; // Bind search query 16567 16568 this.fancyStore = null; // store for fancybox 16569 16570 this.fancyAgent = null; // agent for fancybox 16571 16572 this.showBtnTop = false; // Flag to show/hide .btn-top 16573 16574 this.centerMapOnStore = this.centerMapOnStore.bind(this); 16575 this.infoWindow = null; 16576 this.searchLocationLat = null; 16577 this.searchLocationLng = null; // Utilizzare storeLocatorSettings dal contesto globale 16578 16579 this.storeLocatorSettings = window.storeLocatorSettings || {}; 16580 this.headquarter = { 16581 name: "LEA CERAMICHE", 16582 address: "Via Cameazzo 21, Fiorano Modenese", 16583 lat: 44.5325, 16584 lng: 10.8326, 16585 type: "Sede Centrale", 16586 country: "IT", 16587 phone: "0536 837811", 16588 hours: null 16589 }; 16590 this.loadStores(); 16591 this.loadGoogleMaps(); //this.addSearchButtonClickListener(); 16592 16593 this.addProvinceClickListener(); 16594 this.setupTabletTouchHandlers(); // Aggiungi event listeners nativi 16595 // Ascolta i cambiamenti di $location 16596 16597 $scope.$on('$locationChangeSuccess', function () { 16598 _this.checkAndPerformSearch(); 16599 }); 16600 $scope.$on('destroy', function () { 16601 _this.unsubscribe.next(); 16602 16603 _this.unsubscribe.complete(); 16604 }); // $scope.$watch(() => this.sortCriteria, () => { 16605 // this.sortStores(); 16606 // }); 16607 16608 angular.element($document).on('scroll', this.handleScroll.bind(this)); 16609 } // Aggiungi il listener per il click sul bottone di ricerca 16610 16611 16612 var _proto = MapCtrl.prototype; 16613 16614 _proto.addSearchButtonClickListener = function addSearchButtonClickListener() { 16615 var _this2 = this; 16616 16617 var searchButton = document.getElementById('btn-search'); 16618 16619 if (searchButton) { 16620 searchButton.addEventListener('click', function () { 16621 window.data.searchByTextBox = true; 16622 16623 _this2.handleSearchButtonClick(); 16624 }); 16625 } 16626 } // Funzione per gestire il click del bottone di ricerca 16627 ; 16628 16629 _proto.handleSearchButtonClick = function handleSearchButtonClick() { 16630 var _this3 = this; 16631 16632 var searchQuery = document.getElementById('searchBox').value; 16633 16634 if (searchQuery) { 16635 var geocoder = new google.maps.Geocoder(); 16636 geocoder.geocode({ 16637 address: this.addressForGeocoder(searchQuery) 16638 }, function (results, status) { 16639 if (status === google.maps.GeocoderStatus.OK && results[0]) { 16640 var _results$0$address_co; 16641 16642 var location = results[0].geometry.location; 16643 var formattedAddress = results[0].formatted_address; 16644 var country = ((_results$0$address_co = results[0].address_components.find(function (component) { 16645 return component.types.includes("country"); 16646 })) == null ? void 0 : _results$0$address_co.short_name) || ''; 16647 country = country.toUpperCase(); 16648 16649 if (!_this3.listCountryCode.find(function (c) { 16650 return c.toUpperCase() == country; 16651 })) { 16652 document.getElementById('searchBox').value = ""; 16653 return; 16654 } 16655 16656 document.getElementById('searchBox').value = formattedAddress; // Completa il campo di ricerca con il nome completo della città 16657 16658 _this3.performSearchWithLocation(location, formattedAddress); // Avvia la ricerca 16659 16660 } else { 16661 console.error('Geocoder failed due to: ' + status); 16662 } 16663 }); 16664 } else { 16665 console.warn('Il campo di ricerca è vuoto.'); 16666 } 16667 }; 16668 16669 _proto.handleScroll = function handleScroll() { 16670 var _this4 = this; 16671 16672 var wrapMap = this.$document[0].querySelector('.wrap-map'); 16673 var listStore = this.$document[0].querySelector('.listStore'); 16674 16675 if (wrapMap && listStore) { 16676 var wrapMapRect = wrapMap.getBoundingClientRect(); 16677 var listStoreRect = listStore.getBoundingClientRect(); 16678 16679 if (wrapMapRect.bottom < 0 && listStoreRect.top < window.innerHeight) { 16680 this.$timeout(function () { 16681 _this4.showBtnTop = true; 16682 }); 16683 } else { 16684 this.$timeout(function () { 16685 _this4.showBtnTop = false;
16686 }); 16687 } 16688 } 16689 }; 16690 16691 _proto.addProvinceClickListener = function addProvinceClickListener() { 16692 var _this5 = this; 16693 16694 // Assicurati che il DOM sia completamente caricato 16695 this.$timeout(function () { 16696 var provinceLinks = document.querySelectorAll('.wrap-provincie .item ul li a'); 16697 provinceLinks.forEach(function (link) { 16698 link.addEventListener('click', function (event) { 16699 window.data.searchByTextBox = false; 16700 var titleElement = link.querySelector('span'); 16701 16702 if (titleElement) { 16703 // Usa il testo del titolo come nome provincia 16704 var selectedProvince = titleElement.textContent; 16705 localStorage.setItem('selectedProvince', selectedProvince); 16706 var provGA4 = link.getAttribute("data-title"); // Emissione unica dell'evento "store_locator_province" 16707 16708 _this5.emitProvinceEventOnce(provGA4); 16709 } 16710 }); 16711 }); 16712 }, 0); 16713 }; 16714 16715 _proto.addressForGeocoder = function addressForGeocoder(address) { 16716 var addressToSearch = address; // La mappa per Cotto d'este è impostata sempre su lingua EN. 16717 // Questo impedisce di trovare risultati quando si cerca solo il CAP. 16718 // 16719 // Questa modifica quando sto in Italiano e cerco una sola parola 16720 // aggiunge "Italy" alla ricerca. 16721 // (Aiuta per la ricerca del cap, ma dovebbre essere utile anche per i nomi di città ) 16722 16723 if (!(addressToSearch + "").match(" ")) { 16724 var locale = this.getCurrentLocale(); 16725 16726 var _this$getCountryAndCe = this.getCountryAndCenter(locale), 16727 country = _this$getCountryAndCe.country; 16728 16729 if (country === "IT") addressToSearch += ", Italy"; 16730 } 16731 16732 return addressToSearch; 16733 }; 16734 16735 _proto.getCountryAndCenter = function getCountryAndCenter(locale) { 16736 var mapSettings = { 16737 it_IT: { 16738 country: 'IT', 16739 center: { 16740 lat: 41.9028, 16741 lng: 12.4964 16742 } 16743 }, 16744 fr_FR: { 16745 country: 'FR', 16746 center: { 16747 lat: 48.8566, 16748 lng: 2.3522 16749 } 16750 }, 16751 de_DE: { 16752 country: 'DE', 16753 center: { 16754 lat: 52.5200, 16755 lng: 13.4050 16756 } 16757 }, 16758 de_AT: { 16759 country: 'AT', 16760 center: { 16761 lat: 48.2082, 16762 lng: 16.3738 16763 } 16764 }, 16765 nl_BE: { 16766 country: 'BE', 16767 center: { 16768 lat: 50.8503, 16769 lng: 4.3517 16770 } 16771 }, 16772 de_CH: { 16773 country: 'CH', 16774 center: { 16775 lat: 46.2044, 16776 lng: 6.1432 16777 } 16778 }, 16779 fr_CH: { 16780 country: 'CH', 16781 center: { 16782 lat: 46.2044, 16783 lng: 6.1432 16784 } 16785 } 16786 }; 16787 return mapSettings[locale] || { 16788 country: 'US', 16789 center: { 16790 lat: 37.7749, 16791 lng: -122.4194 16792 } 16793 }; 16794 }; 16795 16796 _proto.emitProvinceEventOnce = function emitProvinceEventOnce(provincia) { 16797 if (!this.provinceEventEmitted) { 16798 // Verifica che l'evento non sia già stato emesso 16799 var obj = Object.assign({}, window.objDataLayerInfo); 16800 obj["eventname"] = "store_locator_province"; 16801 obj["label"] = provincia; 16802 GtmService.push(obj); // Disabilita l'emissione dell'evento per i click successivi 16803 16804 this.provinceEventEmitted = true; 16805 } 16806 }; 16807 16808 _proto.checkAndPerformSearch = function checkAndPerformSearch() { 16809 var _this6 = this; 16810 16811 var path = this.$location.path(); 16812 var selectedProvince = window.data.provincia; 16813 16814 if (path === '/punti-vendita') {
16815 // Siamo sulla pagina principale, quindi puliamo il campo di ricerca 16816 this.searchQuery = ''; 16817 localStorage.removeItem('selectedProvince'); 16818 var searchBox = document.getElementById('searchBox'); 16819 16820 if (searchBox) { 16821 searchBox.value = ''; 16822 } 16823 16824 var searchBoxBottom = document.getElementById('searchBoxBottom'); 16825 16826 if (searchBoxBottom) { 16827 searchBoxBottom.value = ''; 16828 } 16829 16830 this.$timeout(function () { 16831 _this6.filteredStores = []; 16832 _this6.showResults = false; 16833 }); 16834 } else if (selectedProvince) { 16835 this.searchQuery = selectedProvince; // Aspetta che la mappa sia caricata prima di eseguire la ricerca 16836 16837 this.$timeout(function () { 16838 if (_this6.map) { 16839 _this6.performSearch(); 16840 } else { 16841 _this6.$timeout(_this6.checkAndPerformSearch.bind(_this6), 100); // Riprova finché la mappa non è pronta 16842 16843 } 16844 }, 0); 16845 } 16846 }; 16847 16848 _proto.getListCountryRestriction = function getListCountryRestriction() { 16849 var countryRestriction = this.getCountryRestriction(); 16850 var autocompleteOptions = { 16851 types: ['geocode'] 16852 }; 16853 16854 if (countryRestriction.country === "it") // Per l'Italia faccio una ricerca più estesa, per prendere anche San Marino e Vaticano 16855 { 16856 autocompleteOptions.componentRestrictions = { 16857 country: [countryRestriction.country, "sm", "va"] 16858 }; 16859 } else if (countryRestriction.country === "fr") { 16860 autocompleteOptions.componentRestrictions = { 16861 country: [countryRestriction.country, 'gp', 're', 'mq', 'gf', 'nc', 'yt', 'pf'] 16862 }; 16863 } else { 16864 autocompleteOptions.componentRestrictions = { 16865 country: [countryRestriction.country] 16866 }; 16867 } 16868 16869 this.listCountryCode = autocompleteOptions.componentRestrictions.country; 16870 return autocompleteOptions; 16871 }; 16872 16873 _proto.getCurrentLocale = function getCurrentLocale() { 16874 var metaLocale = document.querySelector('meta[property="og:locale"]').getAttribute('content'); 16875 return metaLocale; 16876 }; 16877 16878 _proto.getCountryRestriction = function getCountryRestriction() { 16879 var locale = this.getCurrentLocale(); 16880 16881 if (locale === 'fr_FR') { 16882 return { 16883 country: 'fr', 16884 center: { 16885 lat: 48.8566, 16886 lng: 2.3522 16887 } 16888 }; // Center of France 16889 } else { 16890 return { 16891 country: 'it', 16892 center: { 16893 lat: 41.8719, 16894 lng: 12.5674 16895 } 16896 }; // Center of Italy 16897 } 16898 }; 16899 16900 _proto.setProvinces = function setProvinces() { 16901 var _this7 = this; 16902 16903 this.$timeout(function () { 16904 _this7.provinces = _this7.data.provinces.filter(function (x) { 16905 return x.countryId === _this7.model.Nazione; 16906 }); 16907 }); 16908 }; 16909 16910 _proto.filterProvinces = function filterProvinces() { 16911 var _this8 = this; 16912 16913 this.$timeout(function () { 16914 _this8.data.filteredProvinces = _this8.data.provinces.filter(function (province) { 16915 return province.countryId === _this8.model.Nazione; 16916 }); 16917 }); 16918 }; 16919 16920 _proto.openInfoWindow = function openInfoWindow(marker, store) { 16921 var _this9 = this; 16922 16923 var storeStatus = this.isStoreOpen(store); 16924 var hoursHtml = this.generateHoursHtml(store); 16925 var directionsUrl = "https://www.google.com/maps/dir/?api=1&destination=" + marker.getPosition().lat() + "," + marker.getPosition().lng(); 16926 var currentDay = this.getCurrentDay(); 16927 var nomeSt = store.name; 16928 16929 if (!nomeSt) { 16930 nomeSt = "-"; 16931 } else { 16932 nomeSt = nomeSt.replaceAll(" ", "_").toLowerCase() + "_"; 16933 nomeSt = nomeSt.replaceAll("_-_", "_"); 16934 } 16935 16936 if (window.data.provinciaGA4 && !window.data.searchByTextBox) { 16937 nomeSt = nomeSt + window.data.provinciaGA4; 16938 } else { 16939 nomeSt += "-"; 16940 } 16941 16942 store.nomeContenuto = nomeSt; 16943 var wrapClass = store.type === 'Fidelity' ? 'wrap no-wrap' : 'wrap'; 16944 var content = "\n\t\t<div class=\"infoWindowContent\">\n\t\t\t<div class=\"infoHeader\">\n\t\t\t\t<div class=\"" + wrapClass + "\">\n\t\t\t\t\t<div class=\"storeType\" ng-if=\"store.type !== 'Fidelity'\">\n\t\t\t\t\t\t<div class=\"storeIcon\">\n\t\t\t\t\t\t\t<svg ng-if=\"store.type === 'Lea Ceramiche Ambassador'\" width=\"12\" height=\"13\" viewBox=\"0 0 12 13\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n\t\t\t\t\t\t\t\t<path d=\"M6 0.5L11.1962 3.5V9.5L6 12.5L0.803848 9.5V3.5L6 0.5Z\" fill=\"#404040\" />\n\t\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t\t<svg ng-if=\"store.type === 'Partner Lea Ceramiche'\" width=\"12\" height=\"13\" viewBox=\"0 0 12 13\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n\t\t\t\t\t\t\t\t<path d=\"M6 0.5L12 6.5L6 12.5L0 6.5L6 0.5Z\" fill=\"#D6D2CE\" />\n\t\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t{{ store.type }}\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"storeDistance\">" + store.distance + " km</div>\n\t\t\t\t\t<div class=\"storeName\">" + store.name + "</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<div class=\"infoBody\">\n\t\t\t\t<div class=\"storeAddress\">" + store.address + ", " + store.city + "</div>\n\t\t\t\t" + (hoursHtml ? "\t\t\t\t<div class=\"storeHours\">\n\t\t\t\t\t<div class=\"hoursTitle\">Orari</div>\n\t\t\t\t\t<div class=\"today\">\n\t\t\t\t\t\t<div role=\"button\" tabindex=\"0\" class=\"wrap-today\" ng-click=\"ctrl.toggleWeek($event);ctrl.storeSelezionatoSmall(store,'orari_map')\" ng-keydown=\"$event.keyCode === 13 && ctrl.toggleWeek()\">\n\t\t\t\t\t\t\t<svg class=\"iconHours\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n\t\t\t\t\t\t\t\t<circle cx=\"8\" cy=\"8\" r=\"6.67\" stroke=\"#2B3F6C\"></circle>\n\t\t\t\t\t\t\t\t<path d=\"M8 5.33V7.82c0 .11.056.215.148.277L10 9.33\" stroke=\"#2B3F6C\" stroke-linecap=\"round\"></path>\n\t\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t\t<strong>" + storeStatus.status + "</strong>\n\t\t\t\t\t\t\t\t" + (storeStatus.status === this.storeLocatorSettings.localizedStrings.L
16944BL_APERTO ? " \xB7 " + this.storeLocatorSettings.localizedStrings.LBL_CHIUDEA + " " + storeStatus.closesAt : storeStatus.status === this.storeLocatorSettings.localizedStrings.LBL_CHIUSO ? " \xB7 " + this.storeLocatorSettings.localizedStrings.LBL_APREA + " " + storeStatus.nextOpen : '') + "\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t<svg class=\"iconArrow\" width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n\t\t\t\t\t\t\t\t<rect width=\"20\" height=\"20\" fill=\"#F0F3F7\" />\n\t\t\t\t\t\t\t\t<path d=\"M6 8L10 12L14 8\" stroke=\"#232120\" stroke-width=\"1.33\" stroke-linecap=\"round\" stroke-linejoin=\"round\" />\n\t\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<ul class=\"week\" ng-class=\"{ 'active': ctrl.isWeekActive }\">\n\t\t\t\t\t\t" + store.hours.map(function (dayEntry) { 16945 var isCurrentDay = currentDay.toLowerCase().startsWith(dayEntry.day.toLowerCase()) ? 'current-day' : ''; 16946 var orari = dayEntry.orari.includes(_this9.storeLocatorSettings.localizedStrings.LBL_CHIUSO) ? _this9.storeLocatorSettings.localizedStrings.LBL_CHIUSO : dayEntry.orari.join(' / '); 16947 return "<li class=\"" + isCurrentDay + "\"><div class=\"wrap-hours\"><div class=\"item\">" + dayEntry.day + ":</div> <div class=\"item item-orario\">" + orari + "</div></div></li>"; 16948 }).join('') + "\n\t\t\t\t\t</ul>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t" : '') + "\n\t\t\t\t<div class=\"storePhone\">\n\t\t\t\t\t<div class=\"phoneTitle\">Telefono</div>\n\t\t\t\t\t<div class=\"phoneNumber\">\n\t\t\t\t\t\t<svg class=\"iconPhone\" width=\"14\" height=\"14\" viewBox=\"0 0 14 14\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n\t\t\t\t\t\t\t<path d=\"M11.708 12.48c-1.303 1.303-4.64.078-7.453-2.735C1.442 6.93.218 3.595 1.52 2.292L2.38 1.434c.593-.592 1.568-.577 2.18.034l1.33 1.329c.611.611.626 1.587.034 2.18L5.738 5.162c-.32.32-.352.836-.054 1.196.287.348.596.694.931 1.029.335.335.681.644 1.028.93.36.298.875.265 1.195-.055l.185-.184c.592-.593 1.568-.577 2.18.034l1.33 1.329c.612.612.628 1.587.034 2.18l-.858.858z\" stroke=\"#2B3F6C\"></path>\n\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t<a href=\"tel:" + store.phone + "\" ng-click=\"ctrl.storeSelezionatoSmall(store,'tel_map')\"\n\t\t\t\t\t\t\tclass=\"dtEventSend\"\n\t\t\t\t\t\t\tdata-gtm-eventname=\"store_locator_interactions\"\n data-gtm-position=\"mappa\"\n data-gtm-label=\"get_call\"\n data-gtm-nomecontenuto=\"" + store.nomeContenuto + "\"\n\t\t\t\t\t\t>" + store.phone + "</a>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<div class=\"infoFooter\">\n\t\t\t\t<a class=\"btn btn--outline dtEventSend\" data-gtm-eventname=\"store_locator_interactions\" data-gtm-position=\"mappa\"\n\t\t\t\tdata-gtm-label=\"get_direction\" data-gtm-nomecontenuto=\"" + store.nomeContenuto + "\" href=\"" + directionsUrl + "\" target=\"_blank\"\n\t\t\t\tonclick=\"storeSelezionato(" + store.id + ",'" + store.name4GA + "','" + store.indirizzo4GA + "','" + store.type + "','" + store.citta4GA + "','" + store.agenteRif + "','indica')\">Ottieni indicazioni</a>\n\t\t\t</div>\n\t\t</div>\n\t\t"; 16949 var compiledContent = this.$compile(content)(Object.assign(this.$scope, { 16950 store: store 16951 })); 16952 this.infoWindow.setContent(compiledContent[0]); 16953 this.$scope.$applyAsync(); 16954 this.infoWindow.open(this.map, marker); 16955 this.$timeout(function () { 16956 _this9.activeStore = store; 16957 16958 _this9.updateMarkerIcons(store); 16959 }); 16960 }; 16961 16962 _proto.toggleWeek = function toggleWeek() { 16963 this.isWeekActive = !this.isWeekActive; 16964 }; 16965 16966 _proto.resetForm = function resetForm() { 16967 this.model = {}; // Resetta il modello 16968 16969 this.formSubmitted = false; // Assicurati che formSubmitted sia false 16970 16971 if (this.$scope.ctrlForm) { 16972 this.$scope.ctrlForm.$setPristine(); // Resetta lo stato del form a pristine 16973 16974 this.$scope.ctrlForm.$setUntouched(); // Resetta lo stato del form a untoched 16975 } 16976 16977 this.fancyStore = null; // Resetta fancyStore 16978 16979 this.fancyAgent = null; // Resetta fancyAgent 16980 16981 this.state.ready(); // Assicurati che lo stato sia pronto per una nuova operazione 16982 }; 16983 16984 _proto.onSubmit = function onSubmit() { 16985 var _this10 = this; 16986 16987 var inputCaptcha = document.querySelector('.g-recaptcha-response'); 16988 16989 if (inputCaptcha) { 16990 this.model.Captcha = inputCaptcha.value; 16991 } else { 16992 this.model.Captcha = ''; 16993 } // Se il CAPTCHA non è valido, mostra un messaggio di errore persistente 16994 16995 16996 if (!this.model.Captcha) { 16997 this.showCaptchaError = true; // Variabile per controllare la visualizzazione del messaggio di errore 16998 16999 this.$timeout(function () { 17000 var errorMessageElement = document.getElementById('captcha-error-message'); 17001 17002 if (errorMessageElement) { 17003 errorMessageElement.style.display = 'block'; // Mostra il messaggio di errore 17004 } 17005 }, 0); 17006 return; // Esci dalla funzione per evitare ulteriori processi finché CAPTCHA non è completato 17007 } else { 17008 this.showCaptchaError = false; // Nasconde il messaggio di errore quando CAPTCHA è valido 17009 } // Procedura di invio standard se il CAPTCHA è valido 17010 17011 17012 if (this.fancyStore) { 17013 this.model.storeID = this.fancyStore.id; 17014 } // console.log('ContactsCtrl.onSubmit', this.model); 17015 17016 17017 if (this.state.busy()) { 17018 this.$http.post('/WS/wsUsers.asmx/ContactStore', { 17019 data: this.model 17020 }).then(function (success) { 17021 if (success.data.d.Status) { 17022 _this10.state.success(); 17023 17024 GtmService.push({ 17025 "event": "Action Complete" 17026 }); 17027 _this10.formSubmitted = true; //this.resetFormAndHideMessage(); 17028 17029 var obj = Object.assign({}, window.objDataLayerInfo); 17030 obj["eventname"] = "store_locator_request_sent"; 17031 obj["nomecontenuto"] = success.data.d.Props.StoreName; 17032 GtmService.push(obj); 17033 } else { 17034 _this10.state.error(); 17035 } 17036 }, function (error) { 17037 _this10.error = error; 17038 }); 17039 this.$timeout(function () { 17040 _this10.state.ready(); 17041 }, 2000); 17042 } 17043 }; 17044 17045 _proto.onSubmitAgent = function onSubmitAgent() { 17046 var _this11 = this; 17047 17048 var inputCaptcha = document.querySelector('.g-recaptcha-response'); 17049 17050 if (inputCaptcha) { 17051 this.model.Captcha = inputCaptcha.value; 17052 } else { 17053 this.model.Captcha = ''; 17054 } 17055 17056 if (this.fancyAgent) { 17057 this.model.agentID = this.fancyAgent.id; 17058 } // console.log('ContactsCtrl.onSubmit', this.model); 17059 17060 17061 if (this.state.busy()) { 17062 this.$http.post('/WS/wsUsers.asmx/ContactAgente', { 17063 data: this.model 17064 }).then(function (success) { 17065 if (success.data.d.Status) { 17066 _this11.state.success(); 17067 17068 GtmService.push({ 17069 "event": "Action Complete" 17070 }); 17071 _this11.formSubmitted = true; 17072 var prov = ""; 17073 if (window.data.provinciaGA4 && !window.data.searchByTextBox) prov = "_" + window.data.provinciaGA4;else prov = "_-"; 17074 var obj = Object.assign({}, window.objDataLayerInfo); 17075 obj["eventname"] = "store_locator_request_sent"; 17076 obj["nomecontenuto"] = success.data.d.Props.AgentName + prov; 17077 GtmService.push(obj); 17078 } else { 17079 _this11.state.error(); 17080 } 17081 }, function (error) { 17082 _this11.error = error; 17083 }); 17084 this.$timeout(function () { 17085 _this11.state.ready(); 17086 }, 2000); 17087 } 17088 }; 17089 17090 _proto.onInvalid = function onInvalid() { 17091 this.$scope.$broadcast('onInvalid'); 17092 }; 17093 17094 _proto.toggleWeekActive = function toggleWeekActive(event, storeId) { 17095 if (event && event.stopPropagation) event.stopPropagation(); 17096 17097 if (storeId) { 17098 this.weekActiveList[storeId] = !this.weekActiveList[storeId]; 17099 } else { 17100 this.weekActive = !this.weekActive; 17101 } 17102 }; 17103 17104 _proto.handleTabletTouch = function handleTabletTouch(event, toggleId) { 17105 var _this12 = this; 17106 17107 // Funzione per rilevare se siamo su un tablet grande (>= 768px e touch device) 17108 var isLargeTablet = function isLargeTablet() { 17109 return _this12.$window.innerWidth >= 768 && ('ontouchstart' in _this12.$window || _this12.$window.navigator.maxTouchPoints > 0); 17110 }; // Solo su tablet grandi 17111 17112 17113 if (!isLargeTablet()) { 17114 return; 17115 } // Previeni eventi duplicati 17116 17117 17118 if (event) { 17119 event.preventDefault(); 17120 event.stopPropagation(); 17121 } // Gestisci il toggle 17122 17123 17124 if (toggleId === 'fancy-store') { 17125 this.weekActive = !this.weekActive; 17126 } else if (toggleId && toggleId.startsWith('store-')) { 17127 var storeId = toggleId.replace('store-', ''); 17128 17129 if (!this.weekActiveList) { 17130 this.weekActiveList = {}; 17131 } 17132 17133 this.weekActiveList[storeId] = !this.weekActiveList[storeId]; 17134 } // Forza l'aggiornamento del DOM 17135 17136 17137 try { 17138 this.$scope.$apply(); 17139 } catch (e) {// $scope.$apply() già in corso 17140 } 17141 }; 17142 17143 _proto.setupTabletTouchHandlers = function setupTabletTouchHandlers() { 17144 var _this13 = this; 17145 17146 // Aspetta un po' per assicurarsi che il DOM sia completamente renderizzato 17147 this.$timeout(function () { 17148 // Handler per fancy-store 17149 var fancyStoreElement = document.getElementById('fancy-store-toggle'); 17150 17151 if (fancyStoreElement) { 17152 // Rimuovi vecchi listeners se esistono per evitare duplicati 17153 var oldTouchStart = fancyStoreElement._touchStartHandler; 17154 var oldTouchEnd = fancyStoreElement._touchEndHandler; 17155 var oldClick = fancyStoreElement._clickHandler; 17156 if (oldTouchStart) fancyStoreElement.removeEventListener('touchstart', oldTouchStart); 17157 if (oldTouchEnd) fancyStoreElement.removeEventListener('touchend', oldTouchEnd); 17158 if (oldClick) fancyStoreElement.removeEventListener('click', oldClick); // Crea nuovi handlers e salvali come proprietà dell'elemento 17159 17160 var touchStartHandler = function touchStartHandler(e) { 17161 return _this13.handleTouchStart(e, 'fancy-store'); 17162 }; 17163 17164 var touchEndHandler = function touchEndHandler(e) { 17165 return _this13.handleTouchEnd(e, 'fancy-store'); 17166 }; 17167 17168 var clickHandler = function clickHandler(e) { 17169 return _this13.handleClick(e, 'fancy-store'); 17170 }; 17171 17172 fancyStoreElement._touchStartHandler = touchStartHandler; 17173 fancyStoreElement._touchEndHandler = touchEndHandler; 17174 fancyStoreElement._clickHandler = clickHandler; // Aggiungi nuovi listeners 17175 17176 fancyStoreElement.addEventListener('touchstart', touchStartHandler, { 17177 passive: false 17178 }); 17179 fancyStoreElement.addEventListener('touchend', touchEndHandler, { 17180 passive: false 17181 }); 17182 fancyStoreElement.addEventListener('click', clickHandler, { 17183 passive: false 17184 }); 17185 } // Handler per store individuali (questi potrebbero già esistere) 17186 17187 17188 var storeToggles = document.querySelectorAll('[data-tablet-toggle^="store-"]');
17189 storeToggles.forEach(function (element) { 17190 var toggleId = element.getAttribute('data-tablet-toggle'); // Rimuovi vecchi listeners 17191 17192 var oldTouchStart = element._touchStartHandler; 17193 var oldTouchEnd = element._touchEndHandler; 17194 var oldClick = element._clickHandler; 17195 if (oldTouchStart) element.removeEventListener('touchstart', oldTouchStart); 17196 if (oldTouchEnd) element.removeEventListener('touchend', oldTouchEnd); 17197 if (oldClick) element.removeEventListener('click', oldClick); // Crea nuovi handlers 17198 17199 var touchStartHandler = function touchStartHandler(e) { 17200 return _this13.handleTouchStart(e, toggleId); 17201 }; 17202 17203 var touchEndHandler = function touchEndHandler(e) { 17204 return _this13.handleTouchEnd(e, toggleId); 17205 }; 17206 17207 var clickHandler = function clickHandler(e) { 17208 return _this13.handleClick(e, toggleId); 17209 }; 17210 17211 element._touchStartHandler = touchStartHandler; 17212 element._touchEndHandler = touchEndHandler; 17213 element._clickHandler = clickHandler; 17214 element.addEventListener('touchstart', touchStartHandler, { 17215 passive: false 17216 }); 17217 element.addEventListener('touchend', touchEndHandler, { 17218 passive: false 17219 }); 17220 element.addEventListener('click', clickHandler, { 17221 passive: false 17222 }); 17223 }); 17224 }, 500); 17225 }; 17226 17227 _proto.handleTouchStart = function handleTouchStart(event, toggleId) { 17228 this.touchStarted = true; 17229 this.lastTouchId = toggleId; 17230 }; 17231 17232 _proto.handleTouchEnd = function handleTouchEnd(event, toggleId) { 17233 if (!this.touchStarted || this.lastTouchId !== toggleId) { 17234 return; 17235 } 17236 17237 this.touchStarted = false; 17238 var isLargeTablet = this.$window.innerWidth >= 768 && ('ontouchstart' in this.$window || this.$window.navigator.maxTouchPoints > 0); 17239 17240 if (isLargeTablet) { 17241 event.preventDefault(); 17242 event.stopPropagation(); 17243 this.performToggle(toggleId); 17244 } 17245 }; 17246 17247 _proto.handleClick = function handleClick(event, toggleId) { 17248 // Se abbiamo appena gestito un touch, non gestire anche il click 17249 if (this.touchStarted) { 17250 event.preventDefault(); 17251 event.stopPropagation(); 17252 return; 17253 } 17254 17255 var isLargeTablet = this.$window.innerWidth >= 768 && ('ontouchstart' in this.$window || this.$window.navigator.maxTouchPoints > 0); 17256 17257 if (!isLargeTablet) { 17258 // Desktop o tablet piccoli - usa il normale toggleWeekActive 17259 this.toggleWeekActive(event, toggleId === 'fancy-store' ? null : toggleId.replace('store-', '')); 17260 } 17261 }; 17262 17263 _proto.performToggle = function performToggle(toggleId) { 17264 if (toggleId === 'fancy-store') { 17265 this.weekActive = !this.weekActive; 17266 } else if (toggleId && toggleId.startsWith('store-')) { 17267 var storeId = toggleId.replace('store-', ''); 17268 17269 if (!this.weekActiveList) { 17270 this.weekActiveList = {}; 17271 } 17272 17273 this.weekActiveList[storeId] = !this.weekActiveList[storeId]; 17274 } // Forza l'aggiornamento del DOM 17275 17276 17277 this.$scope.$apply(); 17278 }; 17279 17280 _proto.getCurrentDay = function getCurrentDay() { 17281 var language = this.getCurrentLocale().includes('fr') ? 'fr' : 'it'; 17282 var today = new Date(); 17283 var dayMapping = { 17284 "lunedì": "Lun", 17285 "martedì": "Mar", 17286 "mercoledì": "Merc", 17287 "giovedì": "Gio", 17288 "venerdì": "Ven", 17289 "sabato": "Sab", 17290 "domenica": "Dom" 17291 }; 17292 var fullDay = today.toLocaleDateString(language === 'fr' ? 'fr-FR' : 'it-IT', { 17293 weekday: 'long' 17294 }).toLowerCase(); 17295 return dayMapping[fullDay] || fullDay; 17296 }; 17297 17298 _proto.getIsCurrentDay = function getIsCurrentDay(day) { 17299 return this.getCurrentDay.startsWith(day); 17300 }; 17301 17302 _proto.isStoreOpen = function isStoreOpen(store) { 17303 var closedStatus = this.storeLocatorSettings.localizedStrings.LBL_CHIUSO; 17304 var openStatus = this.storeLocatorSettings.localizedStrings.LBL_APERTO; 17305 17306 if (!store || !store.hours) { 17307 return { 17308 status: closedStatus, 17309 closesAt: null, 17310 nextOpen: null 17311 }; 17312 } 17313 17314 var today = new Date(); 17315 var day = this.getCurrentDay(); 17316 var hoursEntry = store.hours.find(function (entry) { 17317 return day.toLowerCase().startsWith(entry.day.toLowerCase()); 17318 }); //(entry => entry.day === day); 17319 17320 if (!hoursEntry || hoursEntry.orari.includes(closedStatus)) { 17321 return { 17322 status: closedStatus, 17323 closesAt: null, 17324 nextOpen: this.findNextOpenTodayOrFuture(store.hours, day) 17325 }; 17326 } 17327 17328 var currentTime = today.getHours() * 60 + today.getMinutes(); 17329 var times = hoursEntry.orari.map(function (range) { 17330 var _range$trim$split$map = range.trim().split('â').map(function (time) { 17331 var _time$split$map = time.split(':').map(Number), 17332 hours = _time$split$map[0], 17333 minutes = _time$split$map[1]; 17334 17335 return hours * 60 + minutes; 17336 }), 17337 open = _range$trim$split$map[0], 17338 close = _range$trim$split$map[1]; 17339 17340 return { 17341 open: open, 17342 close: close 17343 }; 17344 }); 17345 17346 for (var _iterator = _createForOfIteratorHelperLoose(times), _step; !(_step = _iterator()).done;) { 17347 var _step$value = _step.value, 17348 open = _step$value.open, 17349 close = _step$value.close; 17350 17351 if (currentTime >= open && currentTime <= close) { 17352 return { 17353 status: openStatus, 17354 closesAt: this.minutesToTime(close), 17355 nextOpen: null 17356 }; 17357 } 17358 } // Se è chiuso, trova il prossimo orario di apertura 17359 17360 17361 return { 17362 status: closedStatus, 17363 closesAt: null, 17364 nextOpen: this.findNextOpenTodayOrFuture(store.hours, day, currentTime) 17365 }; 17366 }; 17367 17368 _proto.findNextOpenTodayOrFuture = function findNextOpenTodayOrFuture(hours, currentDay, currentTime) { 17369 var _this14 = this; 17370 17371 if (currentTime === void 0) { 17372 currentTime = 0; 17373 } 17374 17375 var daysOfWeek = ["Lun", "Mar", "Merc", "Gio", "Ven", "Sab", "Dom"]; 17376 var startIndex = daysOfWeek.indexOf(currentDay); // Controlla prima per eventuali orari di apertura più tardi oggi 17377 17378 var todayEntry = hours.find(function (entry) { 17379 return currentDay.toLowerCase().startsWith(entry.day.toLowerCase()); 17380 }); 17381 17382 if (todayEntry) { 17383 var nextOpeningToday = todayEntry.orari.find(function (range) { 17384 var _range$split$map = range.split('â').map(function (time) { 17385 var _time$split$map2 = time.split(':').map(Number), 17386 hours = _time$split$map2[0], 17387 minutes = _time$split$map2[1]; 17388 17389 return hours * 60 + minutes; 17390 }), 17391 open = _range$split$map[0]; 17392 17393 return open > currentTime; 17394 }); 17395 17396 if (nextOpeningToday) { 17397 return " " + nextOpeningToday.split('â')[0]; 17398 } 17399 } // Se non ci sono più orari oggi, cerca nel giorno successivo 17400 17401 17402 var _loop = function _loop(i) {
17403 var dayIndex = (startIndex + i) % 7; 17404 var nextDay = daysOfWeek[dayIndex]; 17405 var nextEntry = hours.find(function (entry) { 17406 return entry.day === nextDay && !entry.orari.includes(_this14.storeLocatorSettings.localizedStrings.LBL_CHIUSO); 17407 }); 17408 17409 if (nextEntry) { 17410 var openTime = nextEntry.orari[0].split('â')[0]; 17411 return { 17412 v: nextDay + " " + openTime 17413 }; 17414 } 17415 }; 17416 17417 for (var i = 1; i < 7; i++) { 17418 var _ret = _loop(i); 17419 17420 if (typeof _ret === "object") return _ret.v; 17421 } 17422 17423 return null; 17424 }; 17425 17426 _proto.minutesToTime = function minutesToTime(minutes) { 17427 var hours = Math.floor(minutes / 60); 17428 var mins = minutes % 60; 17429 return hours.toString().padStart(2, '0') + ":" + mins.toString().padStart(2, '0'); 17430 }; 17431 17432 _proto.loadAgentData = function loadAgentData(tipo, countrycode, province, city, areac, shortn, storeTrovati) { 17433 var _this15 = this; 17434 17435 var stringaChiamata = "/api/store-locator/agenti-by-coords?tipo=" + tipo + "&countrycode=" + countrycode + "&provcode=" + province + "&citycode=" + city + "&areacode=" + areac + "&shortname=" + shortn; 17436 this.$http.get(stringaChiamata).then(function (response) { 17437 var agents = response.data; 17438 _this15.agents = agents; //console.log('Agents data fetched:', agents); 17439 // Assuming the API returns an array of agents, you can assign the first one 17440 17441 _this15.agent = agents[0] || null; 17442 17443 if (_this15.agent) { 17444 _this15.agent.nomeContenuto += "_agente_di_zona"; 17445 if (window.data.provinciaGA4 && !window.data.searchByTextBox) _this15.agent.nomeContenuto += "_" + window.data.provinciaGA4;else _this15.agent.nomeContenuto += "_-"; 17446 } // commento per forzare la compilazione 17447 17448 17449 if (!_this15.agent) { 17450 console.warn('No agent found for the provided location parameters.'); 17451 } 17452 17453 _this15.$scope.$applyAsync(); 17454 17455 if (window.ultimaRicerca != stringaChiamata) { 17456 scriviListaGA4(storeTrovati, agents); 17457 window.ultimaRicerca = stringaChiamata; 17458 } 17459 }).catch(function (error) { 17460 console.error('Error fetching agent data:', error); 17461 }); 17462 }; 17463 17464 _proto.loadStores = function loadStores() { 17465 var _this16 = this; 17466 17467 var countryRestriction = this.getCountryRestriction(); 17468 this.$http.get('/api/store-locator/all').then(function (response) { 17469 // Filtra i negozi per includere solo quelli nel paese corretto 17470 _this16.stores = response.data.filter(function (store) { 17471 return store && store.country === countryRestriction.country.toUpperCase(); 17472 }); 17473 17474 _this16.initMap(); 17475 }, function (error) { 17476 console.error('Failed to load store data:', error); 17477 }); 17478 }; 17479 17480 _proto.loadGoogleMaps = function loadGoogleMaps() { 17481 var _this17 = this; 17482 17483 if (!window.storeLocatorSettings.apiKey && !IS_DEV) { 17484 throw "Missing Google Map Api Key"; 17485 } // Controlla se l'API di Google Maps è già stata caricata 17486 17487 17488 if (typeof google !== 'undefined' && google.maps) { 17489 this.initMap(); 17490 return; 17491 } 17492 17493 var script = this.$document[0].createElement('script'); 17494 script.src = "https://maps.googleapis.com/maps/api/js?key=" + window.storeLocatorSettings.apiKey + "&libraries=places®ion=EN&language=en"; 17495 script.async = true; 17496 17497 script.onload = function () { 17498 return _this17.initMap(); 17499 }; 17500 17501 this.$document[0].body.appendChild(script); 17502 }; 17503 17504 _proto.initMap = function initMap() { 17505 var _this18 = this; 17506 17507 if (!this.stores.length) { 17508 this.isLoadingMap = false; 17509 return; 17510 } 17511 17512 this.infoWindow = new google.maps.InfoWindow(); 17513 var countryRestriction = this.getCountryRestriction(); 17514 this.$http.get('/client/docs/data/mapStyle.json').then(function (response) { 17515 var isMobile = window.innerWidth <= 768; // You can adjust the width as per your needs 17516 17517 var zoomLevel = isMobile ? 5 : 6; 17518 var mapOptions = { 17519 zoom: zoomLevel, 17520 center: new google.maps.LatLng(countryRestriction.center.lat, countryRestriction.center.lng), 17521 // Center map based on locale 17522 mapTypeId: google.maps.MapTypeId.ROADMAP, 17523 styles: response.data // Apply custom map style 17524 17525 }; 17526 _this18.map = new google.maps.Map(document.getElementById('map'), mapOptions); 17527 17528 var autocompleteOptions = _this18.getListCountryRestriction(); // { types: ['geocode'] }; 17529 17530 17531 var autocompleteTop = new google.maps.places.Autocomplete(document.getElementById('searchBox'), autocompleteOptions); 17532 autocompleteTop.addListener('place_changed', function () { 17533 var place = autocompleteTop.getPlace(); 17534 17535 if (place.geometry) { 17536 var location = place.geometry.location; 17537 var formattedAddress = place.formatted_address; 17538 17539 if (window.data.searchTraced == false) { 17540 var label = "-"; 17541 var position = "search_bar"; 17542 17543 if (window.data.provinciaGA4) { 17544 label = window.data.provinciaGA4; 17545 if (!window.data.searchByTextBox) position = "listing_province"; 17546 } 17547 17548 var searchTerm = document.getElementById('searchBox').value; //alert("place_changed - 1"); 17549 17550 _this18.manageGA4StoreLocatorSearchEvent("store_locator_search", position, label, searchTerm); // Event "store_locator_search - fin" 17551 17552 } 17553 17554 _this18.performSearchWithLocation(location, formattedAddress); 17555 } else { 17556 console.error('Autocomplete returned place with no geometry'); 17557 } 17558 }); 17559 var autocompleteBottom = new google.maps.places.Autocomplete(document.getElementById('searchBoxBottom'), autocompleteOptions); 17560 autocompleteBottom.addListener('place_changed', function () { 17561 var place = autocompleteBottom.getPlace(); 17562 17563 if (place.geometry) { 17564 var location = place.geometry.location; // Event "store_locator_search - ini" 17565 17566 var label = "-"; 17567 var position = "search_bar"; 17568 17569 if (window.data.provinciaGA4) { 17570 label = window.data.provinciaGA4; 17571 if (!window.data.searchByTextBox) position = "listing_province"; 17572 } 17573 17574 var searchTerm = document.getElementById('searchBox').value; //alert("place_changed - 2"); 17575 17576 _this18.manageGA4StoreLocatorSearchEvent("store_locator_search", position, label, searchTerm); // Event "store_locator_search - fin" 17577 17578 17579 _this18.performSearchWithLocation(location, ""); 17580 } else { 17581 console.error('Autocomplete returned place with no geometry'); 17582 } 17583 }); 17584 _this18.markers = _this18.stores.map(function (store) { 17585 var marker = new google.maps.Marker({ 17586 position: new google.maps.LatLng(store.lat, store.lng), 17587 title: store.name, 17588 icon: _this18.getMarkerIcon(store) 17589 }); 17590 marker.store = store; // Associa lo store al marker 17591 17592 marker.addListener('click', function () { 17593 _this18.map.setCenter(marker.getPosition()); 17594 17595 _this18.$timeout(function () { 17596 _this18.activeStore = store; 17597 17598 _this18.updateMarkerIcons(store); 17599 }); 17600 17601 _this18.scrollToStore(store); 17602 }); 17603 marker.setMap(_this18.map); 17604 return marker; 17605 }); 17606 var renderer = { 17607 render: function render(_ref) { 17608 var count = _ref.count, 17609 position = _ref.position; 17610 var svg = window.btoa("\n\t\t\t\t\t\t<svg width=\"48\" height=\"48\" viewBox=\"0 0 48 48\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n\t\t\t\t\t\t<rect width=\"48\" height=\"48\" rx=\"24\" fill=\"#404040\"/>\n\t\t\t\t\t\t</svg>\n\t\t\t\t\t"); 17611 return new google.maps.Marker({ 17612 position: position, 17613 icon: { 17614 url: "data:image/svg+xml;base64," + svg, 17615 anchor: new google.maps.Point(24, 24) 17616 }, 17617 label: { 17618 text: String(count), 17619 color: "white", 17620 fontSize: "14px", 17621 fontWeight: "bold" 17622 }, 17623 zIndex: Number(google.maps.Marker.MAX_ZINDEX) + count 17624 }); 17625 } 17626 }; 17627 _this18.markerClusterer = new MarkerClusterer$1({ 17628 map: _this18.map, 17629 markers: _this18.markers, 17630 renderer: renderer 17631 }); 17632 _this18.isLoadingMap = false;
17633 }, function (error) { 17634 console.error('Failed to load map style:', error); 17635 _this18.isLoadingMap = false; 17636 }); //var provList = $('ul.provList>li a'); 17637 //$.each(provList, function (index, node) { 17638 // $(this).on("click", function () { 17639 // var provincia = $(this).data("title"); 17640 // const obj = Object.assign({}, window.objDataLayerInfo); 17641 // obj["eventname"] = "store_locator_province"; 17642 // obj["label"] = provincia; 17643 // GtmService.push(obj); 17644 // }); 17645 //}) 17646 }; 17647 17648 _proto.getMarkerIcon = function getMarkerIcon(store) { 17649 if (store.type === 'Lea Ceramiche Ambassador') { 17650 return '/client/docs/img/pin/ambassador-pin.png'; 17651 } else if (store.type === 'Partner Lea Ceramiche') { 17652 return '/client/docs/img/pin/rivenditore-pin.png'; 17653 } else if (store.type === 'Fidelity' || store.type === '' || store.type === null) { 17654 return '/client/docs/img/pin/default-pin.png'; 17655 } else if (store.type === 'Sede Centrale') { 17656 return '/client/docs/img/pin/default-pin.png'; 17657 } 17658 }; 17659 17660 _proto.centerMapOnStore = function centerMapOnStore(store) { 17661 if (store) { 17662 var marker = this.markers.find(function (m) { 17663 return m.store.id === store.id; 17664 }); 17665 17666 if (marker) { 17667 this.map.setCenter(marker.getPosition()); 17668 this.openInfoWindow(marker, store); 17669 } else { 17670 console.warn("Marker not found for the selected store."); 17671 } 17672 } 17673 }; 17674 17675 _proto.updateMarkerIcons = function updateMarkerIcons(selectedStore) { 17676 var _this19 = this; 17677 17678 this.markers.forEach(function (marker) { 17679 var store = marker.store; // Access the store associated with the marker 17680 17681 if (store) { 17682 marker.setIcon(store === selectedStore ? _this19.getSelectedMarkerIcon(store) : _this19.getMarkerIcon(store)); 17683 } 17684 }); 17685 }; 17686 17687 _proto.getSelectedMarkerIcon = function getSelectedMarkerIcon(store) { 17688 if (store.type === 'Lea Ceramiche Ambassador') { 17689 return '/client/docs/img/pin/ambassador-pin-selected.png'; 17690 } else if (store.type === 'Partner Lea Ceramiche') { 17691 return '/client/docs/img/pin/rivenditore-pin-selected.png'; 17692 } else if (store.type === 'Fidelity' || store.type === '' || store.type === null) { 17693 return '/client/docs/img/pin/default-pin-selected.png'; 17694 } else if (store.type === 'Sede Centrale') { 17695 return '/client/docs/img/pin/default-pin-selected.png'; 17696 } 17697 }; 17698 17699 _proto.calculateDistance = function calculateDistance(lat1, lng1, lat2, lng2) { 17700 var toRad = function toRad(value) { 17701 return value * Math.PI / 180; 17702 }; 17703 17704 var R = 6371; // Radius of the Earth in km 17705 17706 var dLat = toRad(lat2 - lat1); 17707 var dLng = toRad(lng2 - lng1); 17708 var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(toRad(lat1)) * Math.cos(toRad(lat2)) * Math.sin(dLng / 2) * Math.sin(dLng / 2); 17709 var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); 17710 return R * c; 17711 }; 17712 17713 _proto.filterStoresByRadius = function filterStoresByRadius(searchLocation, radius) { 17714 var _this20 = this; 17715 17716 return this.stores.filter(function (store) { 17717 var distance = _this20.calculateDistance(searchLocation.lat(), searchLocation.lng(), store.lat, store.lng); 17718 17719 store.distance = distance.toFixed(2); // Save the distance to the store object 17720 17721 return distance <= radius; 17722 }); 17723 }; 17724 17725 _proto.sortStoresByDistance = function sortStoresByDistance(stores) { 17726 return stores.sort(function (a, b) { 17727 return a.distance - b.distance; 17728 }); 17729 }; 17730 17731 _proto.sortStores = function sortStores(registerGa4Event) { 17732 var _this21 = this; 17733 17734 if (this.searchLocationLat && this.searchLocationLng) { 17735 // Calculate distances for filteredStores 17736 this.filteredStores.forEach(function (store) { 17737 var distance = _this21.calculateDistance(_this21.searchLocationLat, _this21.searchLocationLng, store.lat, store.lng); 17738 17739 store.distance = distance.toFixed(2); 17740 }); 17741 } 17742 17743 if (this.sortCriteria === 'distanza') { 17744 // Sort by distance 17745 this.filteredStores.sort(function (a, b) { 17746 return a.distance - b.distance; 17747 }); 17748 17749 if (registerGa4Event) { 17750 var obj = Object.assign({}, window.objDataLayerInfo); 17751 obj["eventname"] = "store_locator_order"; 17752 obj["label"] = "distanza"; 17753 GtmService.push(obj); 17754 } 17755 } else if (this.sortCriteria === 'rilevanza' || !this.sortCriteria) { 17756 if (registerGa4Event) { 17757 var _obj = Object.assign({}, window.objDataLayerInfo); 17758 17759 _obj["eventname"] = "store_locator_order"; 17760 _obj["label"] = "rilevanza"; 17761 GtmService.push(_obj); 17762 } // Sort by relevance and then by distance 17763 17764 17765 this.filteredStores.sort(function (a, b) { 17766 if (a.type === 'Lea Ceramiche Ambassador' && b.type !== 'Lea Ceramiche Ambassador') { 17767 return -1; 17768 } 17769 17770 if (a.type !== 'Lea Ceramiche Ambassador' && b.type === 'Lea Ceramiche Ambassador') { 17771 return 1; 17772 } 17773 17774 if (a.type === 'Partner Lea Ceramiche' && b.type !== 'Partner Lea Ceramiche') { 17775 return -1; 17776 } 17777 17778 if (a.type !== 'Partner Lea Ceramiche' && b.type === 'Partner Lea Ceramiche') { 17779 return 1; 17780 } 17781 17782 if (a.type === 'Fidelity' && b.type !== 'Fidelity') { 17783 return -1; 17784 } 17785 17786 if (a.type !== 'Fidelity' && b.type === 'Fidelity') { 17787 return 1; 17788 } // If they are of the same type, sort by distance 17789 17790 17791 return a.distance - b.distance; 17792 }); 17793 } 17794 17795 this.$scope.$applyAsync(); 17796 }; 17797 17798 _proto.scrollToStore = function scrollToStore(store) { 17799 var _this22 = this; 17800 17801 this.$timeout(function () { 17802 var storeElement = _this22.$document[0].querySelector("li[data-store-id='" + store.id + "']"); 17803 17804 if (storeElement) { 17805 storeElement.scrollIntoView({ 17806 behavior: 'smooth', 17807 block: 'center' 17808 }); 17809 } 17810 }, 0); 17811 }; 17812 17813 _proto.handleEnterKey = function handleEnterKey(event) { 17814 document.getElementById('map-overlay').classList.remove('active'); // Rimuove l'overlay 17815 17816 window.data.searchByTextBox = true; 17817 window.data.searchTraced = false;
17818 17819 if (event.key === 'Enter') { 17820 var label = "-"; 17821 if (window.data.provinciaGA4) label = window.data.provinciaGA4; 17822 var searchTerm = document.getElementById('searchBox').value; // determina la posizione per il tracciamento 17823 17824 var position = "search_bar"; //alert("place_changed - 1"); 17825 17826 this.manageGA4StoreLocatorSearchEvent("store_locator_search", position, label, searchTerm); // Event "store_locator_search - fin" 17827 17828 window.data.searchTraced = true; 17829 this.handleSearchButtonClick(); // Chiama la funzione di ricerca con il bottone 17830 } 17831 }; 17832 17833 _proto.performSearch = function performSearch(traceGA4) { 17834 var _this23 = this; 17835 17836 document.getElementById('map-overlay').classList.remove('active'); // Rimuove l'overlay 17837 17838 var input = document.getElementById('searchBox').value; //this.searchQuery; 17839 // console.log('Performing search for:', input); // Log per il debug 17840 17841 var geocoder = new google.maps.Geocoder(); 17842 var isZipCode = /^\d{4,6}$/.test(input); 17843 var geocodeRequest = { 17844 'address': input 17845 }; 17846 17847 if (isZipCode) { 17848 // Restrizione della ricerca ai soli CAP italiani 17849 geocodeRequest.componentRestrictions = { 17850 country: 'IT' 17851 }; 17852 } 17853 17854 geocoder.geocode(this.addressForGeocoder(geocodeRequest), function (results, status) { 17855 if (status === google.maps.GeocoderStatus.OK) { 17856 var _results$0$address_co2; 17857 17858 // console.log('Geocode results:', results); // Log per il debug 17859 var location = results[0].geometry.location; 17860 var country = ((_results$0$address_co2 = results[0].address_components.find(function (component) { 17861 return component.types.includes("country"); 17862 })) == null ? void 0 : _results$0$address_co2.short_name) || ''; 17863 country = country.toUpperCase(); 17864 17865 if (!_this23.listCountryCode.find(function (c) { 17866 return c.toUpperCase() == country; 17867 })) { 17868 document.getElementById('searchBox').value = ""; 17869 return; 17870 } 17871 17872 if (traceGA4) { 17873 // Event "store_locator_search - ini" 17874 var label = "-"; 17875 var position = "search_bar"; 17876 17877 if (window.data.provinciaGA4) { 17878 label = window.data.provinciaGA4; 17879 if (!window.data.searchByTextBox) position = "listing_province"; 17880 } 17881 17882 var searchTerm = document.getElementById('searchBox').value; //alert("performSearch"); 17883 17884 _this23.manageGA4StoreLocatorSearchEvent("store_locator_search", position, label, searchTerm); // Event "store_locator_search - fin" 17885 17886 } 17887 17888 _this23.performSearchWithLocation(location, ""); 17889 } else { 17890 console.error('Geocoder failed due to: ' + status); 17891 } 17892 }); 17893 }; 17894 17895 _proto.performSearchWithLocation = function performSearchWithLocation(location, formattedAddress) { 17896 var _this24 = this; 17897 17898 document.getElementById('map-overlay').classList.remove('active'); // Rimuove l'overlay 17899 17900 this.searchLocation = location; // Gestisce entrambi i casi in cui 'location.lat' è una funzione o una proprietà 17901 17902 this.searchLocationLat = typeof location.lat === 'function' ? location.lat() : location.lat; 17903 this.searchLocationLng = typeof location.lng === 'function' ? location.lng() : location.lng; // console.log('Search Location Set:', this.searchLocationLat, this.searchLocationLng); // Debug log 17904 17905 var geocoder = new google.maps.Geocoder(); 17906 var address = document.querySelector('.search-input').value; // Se l'indirizzo è vuoto, utilizza 'formattedAddress' o effettua il reverse geocoding 17907 17908 if (!address) { 17909 if (formattedAddress) { 17910 address = formattedAddress; // Aggiorna il campo di input della ricerca 17911 17912 document.querySelector('.search-input').value = address; 17913 } else { 17914 // Effettua il reverse geocoding per ottenere l'indirizzo 17915 geocoder.geocode({ 17916 location: { 17917 lat: this.searchLocationLat, 17918 lng: this.searchLocationLng 17919 } 17920 }, function (results, status) { 17921 if (status === google.maps.GeocoderStatus.OK && results[0]) { 17922 address = results[0].formatted_address; 17923 _this24.searchQuery = address; 17924 document.querySelector('.search-input').value = address; // Procedi con il resto della funzione utilizzando l'indirizzo ottenuto 17925 17926 _this24.processGeocodingResults(results[0], { 17927 lat: _this24.searchLocationLat, 17928 lng: _this24.searchLocationLng 17929 }); 17930 } else { 17931 console.error('Geocoder failed due to:', status); 17932 } 17933 }); 17934 return; // Esci dalla funzione qui; il resto verrà eseguito nel callback 17935 } 17936 } // Procede se l'indirizzo è disponibile 17937 17938 17939 geocoder.geocode({ 17940 address: this.addressForGeocoder(address) 17941 }, function (results, status) { 17942 if (status === google.maps.GeocoderStatus.OK && results[0]) { 17943 _this24.processGeocodingResults(results[0], { 17944 lat: _this24.searchLocationLat, 17945 lng: _this24.searchLocationLng 17946 }); 17947 } else { 17948 console.error('Geocoder failed due to:', status); 17949 } 17950 }); 17951 }; 17952 17953 _proto.processGeocodingResults = function processGeocodingResults(result, location) { 17954 var _addressComponents$fi, 17955 _addressComponents$fi2, 17956 _addressComponents$fi3, 17957 _addressComponents$fi4, 17958 _this25 = this; 17959 var addressComponents = result.address_components; // Estrai i componenti dell'indirizzo 17960 17961 var country = ((_addressComponents$fi = addressComponents.find(function (component) { 17962 return component.types.includes("country"); 17963 })) == null ? void 0 : _addressComponents$fi.short_name) || ''; 17964 var province = ((_addressComponents$fi2 = addressComponents.find(function (component) { 17965 return component.types.includes("administrative_area_level_2"); 17966 })) == null ? void 0 : _addressComponents$fi2.short_name) || ''; 17967 var city = ((_addressComponents$fi3 = addressComponents.find(function (component) { 17968 return component.types.includes("administrative_area_level_3"); 17969 })) == null ? void 0 : _addressComponents$fi3.short_name) || ''; 17970 var areac = ((_addressComponents$fi4 = addressComponents.find(function (component) { 17971 return component.types.includes("administrative_area_level_1"); 17972 })) == null ? void 0 : _addressComponents$fi4.short_name) || ''; 17973 var tipo = ''; 17974 var shortn = ''; 17975 17976 for (var i = addressComponents.length - 1; i >= 0; i--) { 17977 var componente = addressComponents[i]; 17978 17979 for (var j = 0; j < componente.types.length; j++) { 17980 if (this.ordinatiS[componente.types[j]]) { 17981 tipo = componente.types[j]; 17982 shortn = componente.short_name; 17983 break; 17984 } 17985 } // if (tipo) break; 17986 17987 } // console.log('tipo:', tipo, '- shortn:', shortn, '- country:', country, '- province:', province, '- city:', city, '- areac:', areac); 17988 // Effettua la chiamata API al nuovo endpoint con i parametri corretti 17989 17990 17991 this.$http.get("/api/store-locator/by-coords?lat=" + this.searchLocationLat + "&lng=" + this.searchLocationLng + "&tipo=" + tipo + "&countrycode=" + country + "&provcode=" + province + "&citycode=" + city + "&areacode=" + areac + "&shortname=" + shortn).then(function (response) { 17992 var filteredStores = response.data; // console.log('Filtered Stores:', filteredStores); 17993 17994 if (filteredStores.length === 0) { 17995 console.warn('No stores found within the specified radius.'); 17996 var noStoreElement = document.querySelector('.no-store'); 17997 var storeFiltersElement = document.querySelector('.storeFilters'); 17998 17999 if (noStoreElement) { 18000 noStoreElement.style.display = 'block'; 18001 } 18002 18003 if (storeFiltersElement) { 18004 storeFiltersElement.style.display = 'none'; 18005 } 18006 } else { 18007 var _noStoreElement = document.querySelector('.no-store'); 18008 18009 var _storeFiltersElement = document.querySelector('.storeFilters'); 18010 18011 if (_noStoreElement) { 18012 _noStoreElement.style.display = 'none'; 18013 } 18014 18015 if (_storeFiltersElement) { 18016 _storeFiltersElement.style.display = 'block'; 18017 } 18018 } 18019 18020 _this25.filteredStores = filteredStores; 18021 18022 _this25.sortStores(); 18023 18024 _this25.updateMapMarkers(); 18025 18026 var bounds = new google.maps.LatLngBounds(); 18027
18028 _this25.filteredStores.forEach(function (store) { 18029 var storeLocation = new google.maps.LatLng(store.lat, store.lng); 18030 bounds.extend(storeLocation); 18031 }); 18032 18033 if (_this25.filteredStores.length > 0) { 18034 if (_this25.map) { 18035 _this25.map.fitBounds(bounds); 18036 } 18037 } else { 18038 _this25.map.setCenter(location); 18039 18040 _this25.map.setZoom(14); 18041 } // Carica i dati dell'agente in base alla nuova posizione 18042 18043 18044 _this25.loadAgentData(tipo, country, province, city, areac, shortn, filteredStores); 18045 18046 _this25.$timeout(function () { 18047 _this25.showResults = true; 18048 18049 _this25.scrollToMapSection(); 18050 }); 18051 }).catch(function (error) { 18052 console.error('Failed to fetch filtered stores:', error); 18053 }); 18054 }; 18055 18056 _proto.scrollToMapSection = function scrollToMapSection() { 18057 var _this26 = this; 18058 18059 this.$timeout(function () { 18060 var mapSection = _this26.$document[0].querySelector('.section--map'); 18061 18062 if (mapSection) { 18063 _this26.$window.scrollTo({ 18064 top: mapSection.offsetTop, 18065 behavior: 'smooth' 18066 }); 18067 } 18068 }, 0); 18069 }; 18070 18071 _proto.generateHoursHtml = function generateHoursHtml(store) { 18072 var openLabel = this.storeLocatorSettings.localizedStrings.LBL_APERTO; 18073 var closedLabel = this.storeLocatorSettings.localizedStrings.LBL_CHIUSO; // Mappa ogni giorno della settimana con gli orari 18074 18075 return store.hours.map(function (dayEntry) { 18076 var day = dayEntry.day; 18077 var orari = dayEntry.orari.includes(closedLabel) ? closedLabel : dayEntry.orari.join(' / '); 18078 return "<li>" + day + ": " + orari + "</li>"; 18079 }).join(''); 18080 }; 18081 18082 _proto.updateMapMarkers = function updateMapMarkers() { 18083 var _this27 = this; 18084 18085 if (this.markerClusterer) { 18086 this.markerClusterer.clearMarkers(); 18087 } // Remove existing markers from the map 18088 18089 18090 if (this.markers) { 18091 this.markers.forEach(function (marker) { 18092 return marker.setMap(null); 18093 }); 18094 } // Create new markers for filteredStores 18095 18096 18097 this.markers = this.filteredStores.map(function (store) { 18098 var marker = new google.maps.Marker({ 18099 position: new google.maps.LatLng(store.lat, store.lng), 18100 title: store.name, 18101 icon: _this27.getMarkerIcon(store), 18102 map: _this27.map 18103 }); 18104 marker.store = store; 18105 marker.addListener('click', function () { 18106 _this27.openInfoWindow(marker, store); // Existing code for event tracking and UI updates 18107 18108 18109 var obj = Object.assign({}, window.objDataLayerInfo); 18110 var nomeSt = store.name; 18111 18112 if (!nomeSt) { 18113 nomeSt = "-"; 18114 } else { 18115 nomeSt = nomeSt.replaceAll(" ", "_").toLowerCase() + "_"; 18116 nomeSt = nomeSt.replaceAll("_-_", "_"); 18117 } 18118 18119 if (window.data.provinciaGA4 && !window.data.searchByTextBox) { 18120 nomeSt = nomeSt + window.data.provinciaGA4; 18121 } else { 18122 nomeSt += "-"; 18123 } 18124 18125 obj["eventname"] = "store_locator_interactions"; 18126 obj["position"] = "mappa"; 18127 obj["label"] = "seleziona_store"; 18128 obj["nomecontenuto"] = nomeSt; 18129 GtmService.push(obj); 18130 storeSelezionato2(store, 'click_map'); 18131 18132 _this27.map.setCenter(marker.getPosition()); 18133 18134 _this27.$timeout(function () { 18135 _this27.activeStore = store; 18136 _this27.showBtnTop = true; 18137 18138 _this27.updateMarkerIcons(store); 18139 }); 18140 18141 _this27.scrollToStore(store); 18142 }); 18143 return marker; 18144 }); // Use MarkerClusterer to cluster the new markers 18145 18146 this.markerClusterer = new MarkerClusterer$1({ 18147 map: this.map, 18148 markers: this.markers, 18149 renderer: { 18150 render: function render(_ref2) { 18151 var count = _ref2.count, 18152 position = _ref2.position; 18153 var svg = window.btoa("\n\t\t\t\t\t\t<svg width=\"48\" height=\"48\" viewBox=\"0 0 48 48\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n\t\t\t\t\t\t<rect width=\"48\" height=\"48\" rx=\"24\" fill=\"#404040\"/>\n\t\t\t\t\t\t</svg>\n\t\t\t\t\t"); 18154 return new google.maps.Marker({ 18155 position: position, 18156 icon: { 18157 url: "data:image/svg+xml;base64," + svg, 18158 anchor: new google.maps.Point(24, 24) 18159 }, 18160 label: { 18161 text: String(count), 18162 color: "white", 18163 fontSize: "14px", 18164 fontWeight: "bold" 18165 }, 18166 zIndex: Number(google.maps.Marker.MAX_ZINDEX) + count 18167 }); 18168 } 18169 } 18170 }); 18171 }; 18172 18173 _proto.useMyPosition = function useMyPosition() { 18174 var _this28 = this; 18175 18176 document.getElementById('map-overlay').classList.remove('active'); 18177 18178 if (navigator.geolocation) { 18179 navigator.geolocation.getCurrentPosition(function (position) { 18180 var latLng = { 18181 lat: position.coords.latitude, 18182 lng: position.coords.longitude 18183 }; 18184 var geocoder = new google.maps.Geocoder(); 18185 geocoder.geocode({ 18186 location: latLng 18187 }, function (results, status) { 18188 if (status === google.maps.GeocoderStatus.OK && results[0]) { 18189 var address = results[0].formatted_address; 18190 _this28.searchQuery = address; 18191 document.querySelector('.search-input').value = address; // Update input field 18192 // Event "store_locator_find_position - ini" 18193 18194 var label = "-"; 18195 if (window.data.provinciaGA4) label = window.data.provinciaGA4; 18196 var searchTerm = ""; 18197 if (address !== undefined && address != "") searchTerm = address; // Voce scelta nella lista 18198 else searchTerm = document.getElementById('searchBox').value; 18199 18200 _this28.manageGA4StoreLocatorSearchEvent("store_locator_find_position", "search_bar", label, searchTerm); // Event "store_locator_find_position - fin" 18201 18202 18203 _this28.performSearchWithLocation(latLng, address); 18204 } else { 18205 console.error('Geocoder failed due to:', status); 18206 } 18207 }); 18208 }, function (error) { 18209 console.error('Geolocation error:', error); 18210 alert('Unable to retrieve your location.'); 18211 }); 18212 } else { 18213 alert('Geolocation is not supported by this browser.'); 18214 } 18215 }; 18216 18217 _proto.setFancyStoreData = function setFancyStoreData(store) { 18218 var _this29 = this; 18219 18220 this.fancyStore = store; 18221 this.$timeout(function () { 18222 $('body').css('overflow', 'hidden'); 18223 $('html').css('overflow', 'hidden'); 18224 $.fancybox.open({ 18225 src: '#fancy-store', 18226 type: 'inline', 18227 opts: { 18228 afterShow: function afterShow() { 18229 // Configura i touch handlers dopo che il fancy store è visibile 18230 _this29.setupTabletTouchHandlers(); 18231 18232 if (typeof window.captchaOK === 'function') { 18233 window.captchaOK(); 18234 } 18235 18236 _this29.$scope.$applyAsync(); 18237 }, 18238 afterClose: function afterClose() { 18239 $('body').css('overflow', 'auto'); 18240 $('html').css('overflow', 'auto'); 18241 18242 _this29.resetForm(); 18243 } 18244 } 18245 }); 18246 }, 0); 18247 }; 18248 18249 _proto.setFancyAgentData = function setFancyAgentData(agent) { 18250 var _this30 = this; 18251 18252 this.fancyAgent = agent; 18253 this.$timeout(function () { 18254 $('body').css('overflow', 'hidden'); 18255 $('html').css('overflow', 'hidden'); 18256 $.fancybox.open({ 18257 src: '#fancy-agent', 18258 type: 'inline', 18259 opts: { 18260 afterShow: function afterShow() { 18261 _this30.$scope.$applyAsync(); 18262 }, 18263 afterClose: function afterClose() { 18264 $('body').css('overflow', 'auto'); 18265 $('html').css('overflow', 'auto'); 18266 18267 _this30.resetForm(); 18268 } 18269 } 18270 }); 18271 }, 0); 18272 }; 18273 18274 _proto.toggleMap = function toggleMap() { 18275 this.showMap = !this.showMap; 18276 }; 18277 18278 _proto.scrollToMap = function scrollToMap() { 18279 var _this31 = this; 18280 18281 this.$timeout(function () { 18282 var mapElement = _this31.$document[0].querySelector('.section--map'); 18283 18284 if (mapElement) { 18285 _this31.$window.scrollTo({ 18286 top: mapElement.offsetTop, 18287 behavior: 'smooth' 18288 }); 18289 18290 _this31.showBtnTop = false; // Hide the button after scrolling 18291 } 18292 }, 0); 18293 }; 18294 18295 _proto.resetFormAndHideMessage = function resetFormAndHideMessage() { 18296 this.resetForm(); // Resetta il form 18297 18298 this.formSubmitted = false; // Nasconde il messaggio di successo 18299 18300 $.fancybox.close(); // Chiude la fancybox 18301 }; 18302 18303 _proto.manageGA4StoreLocatorSearchEvent = function manageGA4StoreLocatorSearchEvent(eventName, position, label, searchTerm) { 18304 var obj = Object.assign({}, window.objDataLayerInfo); 18305 obj["eventname"] = eventName; 18306 if (position != "") obj["position"] = position; 18307 obj["label"] = label; 18308 obj["searchterm"] = searchTerm; 18309 GtmService.push(obj); 18310 }; 18311 18312 _proto.getProvinceGA4 = function getProvinceGA4() { 18313 return window.data.provinciaGA4 && !window.data.searchByTextBox ? window.data.provinciaGA4 : "-"; 18314 }; 18315 18316 _proto.getStoreNameWithProvinceManage = function getStoreNameWithProvinceManage(storeName) { 18317 return window.data.provinciaGA4 ? storeName : storeName += "_-"; 18318 }; 18319 18320 _proto.storeSelezionatoSmall = function storeSelezionatoSmall(store, azione) { 18321 storeSelezionato2(store, azione); 18322 }; 18323 18324 return MapCtrl; 18325 }(); 18326 18327 MapCtrl.$inject = ['$scope', '$location', '$timeout', '$document', '$window', '$http', 'StateService', '$compile']; 18328 18329 /* jshint esversion: 6 */
18330 var MODULE_NAME = 'lea'; 18331 var app = angular.module(MODULE_NAME, ['ngSanitize', 'jsonFormatter']); 18332 app.config(['$locationProvider', function ($locationProvider) { 18333 $locationProvider.html5Mode(true).hashPrefix('*'); 18334 }]); 18335 app.factory('ApiService', ApiService.factory).factory('DomService', DomService.factory).factory('IntersectionService', IntersectionService.factory).factory('LocationService', LocationService.factory).factory('PromiseService', PromiseService.factory).factory('StateService', StateService.factory).factory('CookieService', CookieService.factory).factory('LocalStorageService', LocalStorageService.factory).factory('SessionStorageService', SessionStorageService.factory).factory('WishlistService', WishlistService.factory); 18336 app.directive('abstract', AbstractDirective.factory).directive('appear', AppearDirective.factory).directive('galleryCounter', GalleryCounter.factory).directive('control', ControlDirective.factory).directive('controlMessages', ControlMessagesDirective.factory).directive('cookies', CookiesDirective.factory).directive('fancyboxGallery', FancyboxGalleryDirective.factory).directive('faq', FaqDirective.factory).directive('galleryItem', GalleryItemDirective.factory).directive('hasDropdown', HasDropdownDirective.factory).directive('header', HeaderDirective.factory).directive('hero', HeroDirective.factory).directive('noHero', NoHeroDirective.factory).directive('gtm', GtmDirective.factory).directive('highway', HighwayDirective.factory).directive('hilight', HilightDirective.factory).directive('href', HrefDirective.factory).directive('label', LabelDirective.factory).directive('navSecondary', function () { 18337 return navSecondary(); 18338 }).directive('lastItem', LastItemDirective.factory).directive('lazy', LazyDirective.factory).directive('lazyScript', LazyScriptDirective.factory).directive('media', MediaDirective.factory).directive('moodboardDropdown', MoodboardDropdownDirective.factory).directive('moodboardSearch', MoodboardSearchDirective.factory).directive('muuri', MuuriDirective.factory).directive('noBounce', NoBounceDirective.factory).directive('parallax', ParallaxDirective.factory).directive('parallaxOuter', ParallaxOuterDirective.factory).directive('scroll', ScrollDirective.factory).directive('scrollable', ScrollableDirective.factory).directive('selectWithAutocomplete', AutocompleteDirective.factory).directive('share', ShareDirective.factory).directive('slider', SliderDirective.factory).directive('sticky', StickyDirective.factory).directive('split', SplitDirective.factory).directive('swiper', SwiperDirective.factory).directive('swiperHero', SwiperHeroDirective.factory).directive('swiperNews', SwiperNewsDirective.factory).directive('swiperColors', SwiperColorsDirective.factory).directive('swiperIcons', SwiperIconsDirective.factory).directive('swiperCollections', SwiperCollectionsDirective.factory).directive('validate', ValidateDirective.factory).directive('video', VideoDirective.factory).directive('virtualScroll', VirtualScrollDirective.factory) // .directive('smoothScroll', SmoothScrollDirective.factory) 18339 .directive('visibility', VisibilityDirective.factory).directive('wishlist', WishlistDirective.factory).directive('zoomable', ZoomableDirective.factory); 18340 app.controller('RootCtrl', RootCtrl).controller('ContactsCtrl', ContactsCtrl).controller('CalcoloCFPCtrl', CalcoloCFPCtrl).controller('ContactStoreCtrl', ContactStoreCtrl).controller('LoginCtrl', LoginCtrl).controller('CollectionsCtrl', CollectionsCtrl).controller('ColorsCtrl', ColorsCtrl).controller('GalleryCtrl', GalleryCtrl).controller('JournalCtrl', JournalCtrl).controller('NewsletterCtrl', NewsletterCtrl).controller('ProjectsCtrl', ProjectsCtrl).controller('DownloadsCtrl', DownloadsCtrl).controller('SearchCtrl', SearchCtrl).controller('SearchbarCtrl', SearchbarCtrl).controller('StoreLocatorCtrl', StoreLocatorCtrl).controller('MapCtrl', MapCtrl); 18341 app.filter('imageWithFeatures', [ImageWithFeatures]).filter('notIn', ['$filter', NotInFilter]).filter('trusted', ['$sce', TrustedFilter]); // app.run(['$compile', '$timeout', '$rootScope', function($compile, $timeout, $rootScope) {}]); 18342 18343 app.run(['$compile', '$timeout', '$rootScope', function ($compile, $timeout, $rootScope) { 18344 DomService.detect(); 18345 $rootScope.first = true; 18346 $rootScope.firstView = document.querySelector('.view').cloneNode(true); 18347 }]); 18348 18349 /* jshint esversion: 6 */ 18350 angular.bootstrap(document, [MODULE_NAME]); 18351 18352}))); 18353//# sourceMappingURL=app.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.