· 8 years ago · Dec 22, 2017, 08:52 AM
1/**
2 * @param {string} dataAndEvents
3 * @return {undefined}
4 */
5function _evercookie_flash_var(dataAndEvents) {
6 /** @type {string} */
7 _ec_lso = dataAndEvents;
8 /** @type {(HTMLElement|null)} */
9 var tabPage = document.getElementById(_ec_lso_id);
10 if (tabPage) {
11 if (tabPage.parentNode) {
12 tabPage.parentNode.removeChild(tabPage);
13 }
14 }
15}
16/** @type {number} */
17var _ec_tests = 5;
18/** @type {number} */
19var _ec_pause = 500;
20var _ec_lso = undefined;
21/** @type {string} */
22var _ec_lso_container_id = "swfcontainer";
23/** @type {string} */
24var _ec_lso_id = "myswf";
25/** @type {string} */
26var _ec_db_id = "mydb";
27var evercookie = function(w) {
28 /** @type {Document} */
29 var doc = w.document;
30 try {
31 /** @type {(Storage|null)} */
32 var localStorage = w.localStorage;
33 } catch (e) {}
34 try {
35 var sessionStorage = w.sessionStorage;
36 } catch (e) {}
37 try {
38 var walk = w.openDatabase;
39 } catch (e) {}
40 return this._class = function() {
41 var self = this;
42 this._ec = {};
43 /**
44 * @return {undefined}
45 */
46 this.log = function() {};
47 /**
48 * @param {string} namespace
49 * @param {Function} errback
50 * @param {boolean} deepDataAndEvents
51 * @return {undefined}
52 */
53 this.get = function(namespace, errback, deepDataAndEvents) {
54 self._evercookie(namespace, undefined, errback, 0, deepDataAndEvents);
55 };
56 /**
57 * @param {string} name
58 * @param {string} value
59 * @param {Object} deepDataAndEvents
60 * @return {undefined}
61 */
62 this.set = function(name, value, deepDataAndEvents) {
63 self._evercookie(name, value, function() {}, 0, deepDataAndEvents);
64 };
65 /**
66 * @param {string} name
67 * @param {string} value
68 * @return {?}
69 */
70 this.evercookie_cookie = function(name, value) {
71 if (value === undefined) {
72 return value = this._getQueryStringValue(name, doc.cookie), self.log("evercookie_cookie/read: " + name + " => " + value), value;
73 }
74 /** @type {string} */
75 doc.cookie = name + "=; expires=Mon, 20 Sep 2010 00:00:00 UTC; path=/";
76 /** @type {string} */
77 doc.cookie = name + "=" + value + "; expires=Tue, 31 Dec 2030 00:00:00 UTC; path=/";
78 self.log("evercookie_cookie/write: " + name + " => " + value);
79 };
80 /**
81 * @param {string} name
82 * @param {string} value
83 * @return {?}
84 */
85 this.evercookie_window = function(name, value) {
86 try {
87 if (value === undefined) {
88 return value = this._getQueryStringValue(name, w.name), self.log("evercookie_window/read: " + name + " => " + value), value;
89 }
90 w.name = this._setQueryStringValue(w.name, name, value);
91 self.log("evercookie_window/write: " + name + " => " + value);
92 } catch (error) {
93 self.log("evercookie_window threw " + error);
94 }
95 };
96 /**
97 * @param {string} name
98 * @param {string} value
99 * @return {?}
100 */
101 this.evercookie_local_storage = function(name, value) {
102 if (!localStorage) {
103 return void self.log("localStorage is not supported");
104 }
105 try {
106 if (value === undefined) {
107 return value = localStorage.getItem(name), self.log("evercookie_local_storage/read: " + name + " => " + value), value;
108 }
109 localStorage.setItem(name, value);
110 self.log("evercookie_local_storage/write: " + name + " => " + value);
111 } catch (error) {
112 self.log("evercookie_local_storage threw " + error);
113 }
114 };
115 /**
116 * @param {string} name
117 * @param {string} value
118 * @return {?}
119 */
120 this.evercookie_session_storage = function(name, value) {
121 if (!sessionStorage) {
122 return void self.log("sessionStorage is not supported");
123 }
124 try {
125 if (value === undefined) {
126 return value = sessionStorage.getItem(name), self.log("evercookie_session_storage/read: " + name + " => " + value), value;
127 }
128 sessionStorage.setItem(name, value);
129 self.log("evercookie_session_storage/write: " + name + " => " + value);
130 } catch (error) {
131 self.log("evercookie_session_storage threw " + error);
132 }
133 };
134 /**
135 * @param {string} name
136 * @param {string} value
137 * @return {?}
138 */
139 this.evercookie_database_storage = function(name, value) {
140 if (!walk) {
141 return void self.log("databaseStorage is not supported");
142 }
143 try {
144 var database = w.openDatabase(_ec_db_id, "", "evercookie", 1048576);
145 if (value !== undefined) {
146 database.transaction(function(tx) {
147 tx.executeSql("CREATE TABLE IF NOT EXISTS cache(id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, value TEXT NOT NULL, UNIQUE (name))", [], function(tx) {
148 self.log("executeSql 'CREATE TABLE IF NOT EXISTS cache' succeeded");
149 tx.executeSql("INSERT OR REPLACE INTO cache(name, value) VALUES(?, ?)", [name, value], function() {
150 /** @type {string} */
151 self._ec.dbData = value;
152 self.log("executeSql 'INSERT OR REPLACE INTO cache' succeeded");
153 self.log("evercookie_database_storage/write: " + name + " => " + value);
154 }, function(dataAndEvents, err) {
155 /** @type {string} */
156 self._ec.dbData = "";
157 self.log("executeSql 'INSERT OR REPLACE INTO cache' failed with error " + err.code + ": " + err.message);
158 });
159 }, function(dataAndEvents, err) {
160 /** @type {string} */
161 self._ec.dbData = "";
162 self.log("executeSql 'CREATE TABLE IF NOT EXISTS cache' failed with error " + err.code + ": " + err.message);
163 });
164 });
165 } else {
166 database.transaction(function(tx) {
167 tx.executeSql("SELECT value FROM cache WHERE name=?", [name], function(dataAndEvents, results) {
168 self._ec.dbData = results.rows.length >= 1 ? results.rows.item(0).value : "";
169 self.log("executeSql 'SELECT value FROM cache' succeeded");
170 self.log("evercookie_database_storage/read: " + name + " => " + self._ec.dbData);
171 }, function(dataAndEvents, err) {
172 /** @type {string} */
173 self._ec.dbData = "";
174 self.log("executeSql 'SELECT value FROM cache' failed with error " + err.code + ": " + err.message);
175 });
176 });
177 }
178 } catch (error) {
179 self.log("evercookie_database_storage threw " + error);
180 }
181 };
182 /**
183 * @param {string} name
184 * @param {string} value
185 * @return {undefined}
186 */
187 this.evercookie_lso = function(name, value) {
188 /** @type {(HTMLElement|null)} */
189 var element = doc.getElementById(_ec_lso_container_id);
190 if (!(null !== element && (element !== undefined && element.length))) {
191 /** @type {Element} */
192 element = doc.createElement("div");
193 element.setAttribute("id", _ec_lso_container_id);
194 doc.body.appendChild(element);
195 }
196 var flashvars = {};
197 if (value !== undefined) {
198 /** @type {string} */
199 flashvars.everdata = name + "=" + value;
200 self.log("evercookie_lso/write: " + name + " => " + value);
201 }
202 };
203 /**
204 * @param {string} name
205 * @param {string} value
206 * @param {Function} cb
207 * @param {number} i
208 * @param {Object} deepDataAndEvents
209 * @return {?}
210 */
211 this._evercookie = function(name, value, cb, i, deepDataAndEvents) {
212 self.log("_evercookie called with name=" + name + ", value=" + value + ", attempt=" + i);
213 /** @type {string} */
214 var requestType = value === undefined ? "read" : "write";
215 /** @type {string} */
216 var key = requestType + " '" + name + "': ";
217 if (0 == i && (deepDataAndEvents || (self.evercookie_database_storage(name, value), self.evercookie_lso(name, value)), self._ec.cookieData = self.evercookie_cookie(name, value), self._ec.localData = self.evercookie_local_storage(name, value), self._ec.sessionData = self.evercookie_session_storage(name, value), self._ec.windowData = self.evercookie_window(name, value)), !deepDataAndEvents) {
218 if (walk && ("undefined" == typeof self._ec.dbData && i++ < _ec_tests)) {
219 return self.log(key + "database is not ready, retrying in " + _ec_pause + "ms"), void setTimeout(function() {
220 self._evercookie(name, value, cb, i, deepDataAndEvents);
221 }, _ec_pause);
222 }
223 self.log(key + (i < _ec_tests ? "completed" : "timed out"));
224 }
225 if (value !== undefined) {
226 self.log(key + "set value " + value);
227 } else {
228 self._ec.lsoData = self._getQueryStringValue(name, _ec_lso);
229 _ec_lso = undefined;
230 var prop = self._ec;
231 self._ec = {};
232 /** @type {Array} */
233 var obj = [];
234 var n;
235 for (n in prop) {
236 var p = prop[n];
237 if (p) {
238 if ("null" !== p) {
239 if ("undefined" !== p) {
240 obj[p] = obj[p] === undefined ? 1 : obj[p] + 1;
241 }
242 }
243 }
244 }
245 var val = undefined;
246 /** @type {number} */
247 var last = 0;
248 for (p in obj) {
249 var next = obj[p];
250 if (next > last) {
251 last = next;
252 /** @type {string} */
253 val = p;
254 }
255 }
256 if (val !== undefined) {
257 self.log(key + "got value " + val);
258 } else {
259 self.log(key + "not set");
260 }
261 if (obj[val] < 2) {
262 self.set(name, val, deepDataAndEvents);
263 }
264 if ("function" == typeof cb) {
265 cb(val);
266 }
267 }
268 };
269 /**
270 * @param {string} message
271 * @param {string} file
272 * @param {string} putativeSpy
273 * @return {?}
274 */
275 this._setQueryStringValue = function(message, file, putativeSpy) {
276 if (message.indexOf("&" + file + "=") > -1 || 0 === message.indexOf(file + "=")) {
277 var i;
278 var spaceIdx = message.indexOf("&" + file + "=");
279 return -1 === spaceIdx && (spaceIdx = message.indexOf(file + "=")), i = message.indexOf("&", spaceIdx + 1), -1 !== i ? message.substr(0, spaceIdx) + message.substr(i + (spaceIdx ? 0 : 1)) + "&" + file + "=" + putativeSpy : message.substr(0, spaceIdx) + "&" + file + "=" + putativeSpy;
280 }
281 return message + "&" + file + "=" + putativeSpy;
282 };
283 /**
284 * @param {string} keepData
285 * @param {string} line
286 * @return {?}
287 */
288 this._getQueryStringValue = function(keepData, line) {
289 if ("string" == typeof line) {
290 var i;
291 var target;
292 /** @type {string} */
293 var part = keepData + "=";
294 /** @type {Array.<string>} */
295 var codeSegments = line.split(/[;&]/);
296 /** @type {number} */
297 i = 0;
298 for (; i < codeSegments.length; i++) {
299 /** @type {string} */
300 target = codeSegments[i];
301 for (;
302 " " === target.charAt(0);) {
303 /** @type {string} */
304 target = target.substring(1, target.length);
305 }
306 if (0 === target.indexOf(part)) {
307 return target.substring(part.length, target.length);
308 }
309 }
310 }
311 };
312 }, this._class;
313}(window);
314! function($) {
315 /**
316 * @param {Error} options
317 * @return {undefined}
318 */
319 $.fn.charCount = function(options) {
320 /**
321 * @param {?} item
322 * @return {undefined}
323 */
324 function handle(item) {
325 var n = $(item).val().length;
326 /** @type {number} */
327 var i = options.allowed - n;
328 if (i <= options.warning && i >= 0) {
329 $(item).next().addClass(options.cssWarning);
330 } else {
331 $(item).next().removeClass(options.cssWarning);
332 }
333 if (i < 0) {
334 $(item).next().addClass(options.cssExceeded);
335 } else {
336 $(item).next().removeClass(options.cssExceeded);
337 }
338 $(item).next().html(options.counterText + i);
339 }
340 var settings = {
341 allowed: 140,
342 warning: 25,
343 css: "counter",
344 counterElement: "span",
345 cssWarning: "warning",
346 cssExceeded: "exceeded",
347 counterText: ""
348 };
349 options = $.extend(settings, options);
350 this.each(function() {
351 $(this).after("<" + options.counterElement + ' class="' + options.css + '">' + options.counterText + "</" + options.counterElement + ">");
352 $(this).parent().css("position", "relative");
353 handle(this);
354 $(this).keyup(function() {
355 handle(this);
356 });
357 $(this).change(function() {
358 handle(this);
359 });
360 });
361 };
362}(jQuery),
363function($) {
364 /**
365 * @param {Object} config
366 * @return {?}
367 */
368 $.fn.confirm = function(config) {
369 return void 0 === config && (config = {}), this.click(function(msg) {
370 msg.preventDefault();
371 var str = $.extend({
372 button: $(this)
373 }, config);
374 $.confirm(str, msg);
375 }), this;
376 };
377 /**
378 * @param {?} opts
379 * @param {Object} data
380 * @return {undefined}
381 */
382 $.confirm = function(opts, data) {
383 if (!($(".confirmation-modal").length > 0)) {
384 var elemOptions = {};
385 if (opts.button) {
386 var defaults = {
387 title: "title",
388 text: "text",
389 "confirm-button": "confirmButton",
390 "cancel-button": "cancelButton",
391 "confirm-button-class": "confirmButtonClass",
392 "cancel-button-class": "cancelButtonClass",
393 "dialog-class": "dialogClass"
394 };
395 $.each(defaults, function(parentNode, path) {
396 var root = opts.button.data(parentNode);
397 if (root) {
398 elemOptions[path] = root;
399 }
400 });
401 }
402 var options = $.extend({}, $.confirm.options, {
403 /**
404 * @return {undefined}
405 */
406 confirm: function() {
407 var value = data && ("string" == typeof data && data || data.currentTarget && data.currentTarget.attributes.href.value);
408 if (value) {
409 if (opts.post) {
410 var $form = $('<form method="post" class="hide" action="' + value + '"></form>');
411 $("body").append($form);
412 $form.submit();
413 } else {
414 window.location = value;
415 }
416 }
417 },
418 /**
419 * @return {undefined}
420 */
421 cancel: function() {},
422 button: null
423 }, elemOptions, opts);
424 /** @type {string} */
425 var optsData = "";
426 if ("" !== options.title) {
427 /** @type {string} */
428 optsData = '<div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button><h4 class="modal-title">' + options.title + "</h4></div>";
429 }
430 /** @type {string} */
431 var template = '<div class="confirmation-modal modal fade" tabindex="-1" role="dialog"><div class="' + options.dialogClass + '"><div class="modal-content">' + optsData + '<div class="modal-body">' + options.text + '</div><div class="modal-footer"><button class="confirm btn ' + options.confirmButtonClass + '" type="button" data-dismiss="modal">' + options.confirmButton + '</button><button class="cancel btn ' + options.cancelButtonClass + '" type="button" data-dismiss="modal">' + options.cancelButton +
432 "</button></div></div></div></div>";
433 var $modal = $(template);
434 $modal.on("shown.bs.modal", function() {
435 $modal.find(".btn-primary:first").focus();
436 });
437 $modal.on("hidden.bs.modal", function() {
438 $modal.remove();
439 });
440 $modal.find(".confirm").click(function() {
441 options.confirm(options.button);
442 });
443 $modal.find(".cancel").click(function() {
444 options.cancel(options.button);
445 });
446 $("body").append($modal);
447 $modal.modal("show");
448 }
449 };
450 $.confirm.options = {
451 text: "Are you sure?",
452 title: "",
453 confirmButton: "Yes",
454 cancelButton: "Cancel",
455 post: false,
456 confirmButtonClass: "btn-primary",
457 cancelButtonClass: "btn-default",
458 dialogClass: "modal-dialog"
459 };
460}(jQuery),
461function(elems, doc, $) {
462 /**
463 * @param {Object} elem
464 * @return {?}
465 */
466 function args(elem) {
467 var newAttrs = {};
468 /** @type {RegExp} */
469 var rinlinejQuery = /^jQuery\d+$/;
470 return $.each(elem.attributes, function(dataAndEvents, attr) {
471 if (attr.specified) {
472 if (!rinlinejQuery.test(attr.name)) {
473 newAttrs[attr.name] = attr.value;
474 }
475 }
476 }), newAttrs;
477 }
478 /**
479 * @param {boolean} event
480 * @param {?} value
481 * @return {?}
482 */
483 function clearPlaceholder(event, value) {
484 var input = this;
485 var $input = $(input);
486 if (input.value == $input.attr("placeholder") && $input.hasClass("placeholder")) {
487 if ($input.data("placeholder-password")) {
488 if ($input = $input.hide().next().show().attr("id", $input.removeAttr("id").data("placeholder-id")), true === event) {
489 return $input[0].value = value;
490 }
491 $input.focus();
492 } else {
493 /** @type {string} */
494 input.value = "";
495 $input.removeClass("placeholder");
496 if (input == doc.activeElement) {
497 input.select();
498 }
499 }
500 }
501 }
502 /**
503 * @return {undefined}
504 */
505 function setPlaceholder() {
506 var $replacement;
507 var input = this;
508 var $input = $(input);
509 var id = this.id;
510 if ("" == input.value) {
511 if ("password" == input.type) {
512 if (!$input.data("placeholder-textinput")) {
513 try {
514 $replacement = $input.clone().attr({
515 type: "text"
516 });
517 } catch (t) {
518 $replacement = $("<input>").attr($.extend(args(this), {
519 type: "text"
520 }));
521 }
522 $replacement.removeAttr("name").data({
523 "placeholder-password": true,
524 "placeholder-id": id
525 }).bind("focus.placeholder", clearPlaceholder);
526 $input.data({
527 "placeholder-textinput": $replacement,
528 "placeholder-id": id
529 }).before($replacement);
530 }
531 $input = $input.removeAttr("id").hide().prev().attr("id", id).show();
532 }
533 $input.addClass("placeholder");
534 $input[0].value = $input.attr("placeholder");
535 } else {
536 $input.removeClass("placeholder");
537 }
538 }
539 var hooks;
540 var placeholder;
541 /** @type {boolean} */
542 var isInputSupported = "placeholder" in doc.createElement("input");
543 /** @type {boolean} */
544 var isTextareaSupported = "placeholder" in doc.createElement("textarea");
545 var prototype = $.fn;
546 var valHooks = $.valHooks;
547 if (isInputSupported && isTextareaSupported) {
548 /** @type {function (): ?} */
549 placeholder = prototype.placeholder = function() {
550 return this;
551 };
552 /** @type {boolean} */
553 placeholder.input = placeholder.textarea = true;
554 } else {
555 /** @type {function (): ?} */
556 placeholder = prototype.placeholder = function() {
557 var contextElem = this;
558 return contextElem.filter((isInputSupported ? "textarea" : ":input") + "[placeholder]").not(".placeholder").bind({
559 /** @type {function (boolean, ?): ?} */
560 "focus.placeholder": clearPlaceholder,
561 /** @type {function (): undefined} */
562 "blur.placeholder": setPlaceholder
563 }).data("placeholder-enabled", true).trigger("blur.placeholder"), contextElem;
564 };
565 /** @type {boolean} */
566 placeholder.input = isInputSupported;
567 /** @type {boolean} */
568 placeholder.textarea = isTextareaSupported;
569 hooks = {
570 /**
571 * @param {string} elem
572 * @return {?}
573 */
574 get: function(elem) {
575 var $elem = $(elem);
576 return $elem.data("placeholder-enabled") && $elem.hasClass("placeholder") ? "" : elem.value;
577 },
578 /**
579 * @param {string} element
580 * @param {string} value
581 * @return {?}
582 */
583 set: function(element, value) {
584 var $element = $(element);
585 return $element.data("placeholder-enabled") ? ("" == value ? (element.value = value, element != doc.activeElement && setPlaceholder.call(element)) : $element.hasClass("placeholder") ? clearPlaceholder.call(element, true, value) || (element.value = value) : element.value = value, $element) : element.value = value;
586 }
587 };
588 if (!isInputSupported) {
589 valHooks.input = hooks;
590 }
591 if (!isTextareaSupported) {
592 valHooks.textarea = hooks;
593 }
594 $(function() {
595 $(doc).delegate("form", "submit.placeholder", function() {
596 var $inputs = $(".placeholder", this).each(clearPlaceholder);
597 setTimeout(function() {
598 $inputs.each(setPlaceholder);
599 }, 10);
600 });
601 });
602 $(elems).bind("beforeunload.placeholder", function() {
603 $(".placeholder").each(function() {
604 /** @type {string} */
605 this.value = "";
606 });
607 });
608 }
609}(this, document, jQuery),
610function(factory) {
611 if ("function" == typeof define && define.amd) {
612 define(["jquery"], factory);
613 } else {
614 if ("undefined" != typeof module && module.exports) {
615 module.exports = factory(require("jquery"));
616 } else {
617 factory(jQuery);
618 }
619 }
620}(function($) {
621 /**
622 * @param {Node} target
623 * @return {?}
624 */
625 function init(target) {
626 return !target.nodeName || -1 !== $.inArray(target.nodeName.toLowerCase(), ["iframe", "#document", "html", "body"]);
627 }
628 /**
629 * @param {number} val
630 * @return {?}
631 */
632 function both(val) {
633 return $.isFunction(val) || $.isPlainObject(val) ? val : {
634 top: val,
635 left: val
636 };
637 }
638 /** @type {function (Object, number, number): ?} */
639 var $scrollTo = $.scrollTo = function(deepDataAndEvents, duration, settings) {
640 return $(window).scrollTo(deepDataAndEvents, duration, settings);
641 };
642 return $scrollTo.defaults = {
643 axis: "xy",
644 duration: 0,
645 limit: true
646 }, $.fn.scrollTo = function(deepDataAndEvents, duration, settings) {
647 if ("object" == typeof duration) {
648 /** @type {number} */
649 settings = duration;
650 /** @type {number} */
651 duration = 0;
652 }
653 if ("function" == typeof settings) {
654 settings = {
655 onAfter: settings
656 };
657 }
658 if ("max" === deepDataAndEvents) {
659 /** @type {number} */
660 deepDataAndEvents = 9E9;
661 }
662 settings = $.extend({}, $scrollTo.defaults, settings);
663 duration = duration || settings.duration;
664 var s = settings.queue && 1 < settings.axis.length;
665 return s && (duration /= 2), settings.offset = both(settings.offset), settings.over = both(settings.over), this.each(function() {
666 /**
667 * @param {Function} callback
668 * @return {undefined}
669 */
670 function animate(callback) {
671 var options = $.extend({}, settings, {
672 queue: true,
673 duration: duration,
674 complete: callback && function() {
675 callback.call(elem, targ, settings);
676 }
677 });
678 to.animate(o, options);
679 }
680 if (null !== deepDataAndEvents) {
681 var prevSources;
682 var checkdom = init(this);
683 var elem = checkdom ? this.contentWindow || window : this;
684 var to = $(elem);
685 var targ = deepDataAndEvents;
686 var o = {};
687 switch (typeof targ) {
688 case "number":
689 ;
690 case "string":
691 if (/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(targ)) {
692 targ = both(targ);
693 break;
694 }
695 targ = checkdom ? $(targ) : $(targ, elem);
696 case "object":
697 if (0 === targ.length) {
698 return;
699 }
700 if (targ.is || targ.style) {
701 prevSources = (targ = $(targ)).offset();
702 };
703 }
704 var groupedSelectors = $.isFunction(settings.offset) && settings.offset(elem, targ) || settings.offset;
705 $.each(settings.axis.split(""), function(dataAndEvents, y) {
706 /** @type {string} */
707 var e = "x" === y ? "Left" : "Top";
708 /** @type {string} */
709 var i = e.toLowerCase();
710 /** @type {string} */
711 var key = "scroll" + e;
712 var val = to[key]();
713 var hash = $scrollTo.max(elem, y);
714 if (prevSources) {
715 o[key] = prevSources[i] + (checkdom ? 0 : val - to.offset()[i]);
716 if (settings.margin) {
717 o[key] -= parseInt(targ.css("margin" + e), 10) || 0;
718 o[key] -= parseInt(targ.css("border" + e + "Width"), 10) || 0;
719 }
720 o[key] += groupedSelectors[i] || 0;
721 if (settings.over[i]) {
722 o[key] += targ["x" === y ? "width" : "height"]() * settings.over[i];
723 }
724 } else {
725 e = targ[i];
726 o[key] = e.slice && "%" === e.slice(-1) ? parseFloat(e) / 100 * hash : e;
727 }
728 if (settings.limit) {
729 if (/^\d+$/.test(o[key])) {
730 /** @type {number} */
731 o[key] = 0 >= o[key] ? 0 : Math.min(o[key], hash);
732 }
733 }
734 if (!dataAndEvents) {
735 if (1 < settings.axis.length) {
736 if (val === o[key]) {
737 o = {};
738 } else {
739 if (s) {
740 animate(settings.onAfterFirst);
741 o = {};
742 }
743 }
744 }
745 }
746 });
747 animate(settings.onAfter);
748 }
749 });
750 }, $scrollTo.max = function(el, y) {
751 /** @type {string} */
752 var c = "x" === y ? "Width" : "Height";
753 /** @type {string} */
754 var scroll = "scroll" + c;
755 if (!init(el)) {
756 return el[scroll] - $(el)[c.toLowerCase()]();
757 }
758 /** @type {string} */
759 c = "client" + c;
760 var result = el.ownerDocument || el.document;
761 var html = result.documentElement;
762 result = result.body;
763 return Math.max(html[scroll], result[scroll]) - Math.min(html[c], result[c]);
764 }, $.Tween.propHooks.scrollLeft = $.Tween.propHooks.scrollTop = {
765 /**
766 * @param {Object} obj
767 * @return {?}
768 */
769 get: function(obj) {
770 return $(obj.elem)[obj.prop]();
771 },
772 /**
773 * @param {string} options
774 * @return {?}
775 */
776 set: function(options) {
777 var lang = this.get(options);
778 if (options.options.interrupt && (options._last && options._last !== lang)) {
779 return $(options.elem).stop();
780 }
781 /** @type {number} */
782 var de = Math.round(options.now);
783 if (lang !== de) {
784 $(options.elem)[options.prop](de);
785 options._last = this.get(options);
786 }
787 }
788 }, $scrollTo;
789}),
790function(mod) {
791 if ("function" == typeof define && define.amd) {
792 define(["jquery"], mod);
793 } else {
794 mod("object" == typeof exports ? require("jquery") : jQuery);
795 }
796}(function($) {
797 /**
798 * @param {string} s
799 * @return {?}
800 */
801 function encode(s) {
802 return config.raw ? s : encodeURIComponent(s);
803 }
804 /**
805 * @param {(Image|string)} s
806 * @return {?}
807 */
808 function decode(s) {
809 return config.raw ? s : decodeURIComponent(s);
810 }
811 /**
812 * @param {string} value
813 * @return {?}
814 */
815 function stringifyCookieValue(value) {
816 return encode(config.json ? JSON.stringify(value) : String(value));
817 }
818 /**
819 * @param {string} s
820 * @return {?}
821 */
822 function parseCookieValue(s) {
823 if (0 === s.indexOf('"')) {
824 s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, "\\");
825 }
826 try {
827 return s = decodeURIComponent(s.replace(rSlash, " ")), config.json ? JSON.parse(s) : s;
828 } catch (e) {}
829 }
830 /**
831 * @param {(Array|string)} s
832 * @param {string} converter
833 * @return {?}
834 */
835 function read(s, converter) {
836 var value = config.raw ? s : parseCookieValue(s);
837 return $.isFunction(converter) ? converter(value) : value;
838 }
839 /** @type {RegExp} */
840 var rSlash = /\+/g;
841 /** @type {function (boolean, string, Object): ?} */
842 var config = $.cookie = function(key, value, options) {
843 if (arguments.length > 1 && !$.isFunction(value)) {
844 if (options = $.extend({}, config.defaults, options), "number" == typeof options.expires) {
845 var days = options.expires;
846 /** @type {Date} */
847 var self = options.expires = new Date;
848 self.setTime(+self + 864E5 * days);
849 }
850 return document.cookie = [encode(key), "=", stringifyCookieValue(value), options.expires ? "; expires=" + options.expires.toUTCString() : "", options.path ? "; path=" + options.path : "", options.domain ? "; domain=" + options.domain : "", options.secure ? "; secure" : ""].join("");
851 }
852 /** @type {(undefined|{})} */
853 var result = key ? undefined : {};
854 /** @type {Array} */
855 var values = document.cookie ? document.cookie.split("; ") : [];
856 /** @type {number} */
857 var i = 0;
858 /** @type {number} */
859 var valuesLen = values.length;
860 for (; i < valuesLen; i++) {
861 var namespaces = values[i].split("=");
862 var name = decode(namespaces.shift());
863 var cookie = namespaces.join("=");
864 if (key && key === name) {
865 result = read(cookie, value);
866 break;
867 }
868 if (!key) {
869 if (!((cookie = read(cookie)) === undefined)) {
870 result[name] = cookie;
871 }
872 }
873 }
874 return result;
875 };
876 config.defaults = {};
877 /**
878 * @param {boolean} key
879 * @param {Object} options
880 * @return {?}
881 */
882 $.removeCookie = function(key, options) {
883 return $.cookie(key) !== undefined && ($.cookie(key, "", $.extend({}, options, {
884 expires: -1
885 })), !$.cookie(key));
886 };
887}),
888function() {
889 /**
890 * @param {Object} settings
891 * @return {undefined}
892 */
893 function init(settings) {
894 var dest;
895 /** @type {boolean} */
896 var quat = false;
897 var self = jQuery(settings.element);
898 self.on("scroll", function() {
899 /** @type {boolean} */
900 quat = self.scrollTop() + 60 > self.prop("scrollHeight") - self.innerHeight();
901 if (dest !== quat) {
902 if (quat) {
903 settings.callback();
904 }
905 }
906 /** @type {boolean} */
907 dest = quat;
908 });
909 }
910 /**
911 * @param {Object} inst
912 * @return {?}
913 */
914 jQuery.fn.infiniteScroll = function(inst) {
915 return this.each(function(dataAndEvents, element) {
916 /** @type {Object} */
917 inst.element = element;
918 new init(inst);
919 });
920 };
921}(),
922function() {
923 var jQuery;
924 var parse;
925 var _forEach;
926 var nodes;
927 var HEREGEX_OMIT;
928 var trigger;
929 var remove;
930 var listener;
931 var run;
932 var select;
933 var get;
934 var _hasTextSelected;
935 var _luhnCheck;
936 var init;
937 var refresh;
938 var start;
939 var success;
940 var each;
941 var _restrictCardNumber;
942 var write;
943 var update;
944 var func;
945 var $;
946 var fn;
947 /** @type {function (this:(Array.<T>|string|{length: number}), *=, *=): Array.<T>} */
948 var __slice = [].slice;
949 /** @type {function (this:(Array.<T>|string|{length: number}), T, number=): number} */
950 var test = [].indexOf || function(key) {
951 /** @type {number} */
952 var i = 0;
953 var l = this.length;
954 for (; l > i; i++) {
955 if (i in this && this[i] === key) {
956 return i;
957 }
958 }
959 return -1;
960 };
961 jQuery = window.jQuery || (window.Zepto || window.$);
962 jQuery.payment = {};
963 jQuery.payment.fn = {};
964 /**
965 * @return {?}
966 */
967 jQuery.fn.payment = function() {
968 var applyArgs;
969 var method;
970 return method = arguments[0], applyArgs = 2 <= arguments.length ? __slice.call(arguments, 1) : [], jQuery.payment.fn[method].apply(this, applyArgs);
971 };
972 /** @type {RegExp} */
973 HEREGEX_OMIT = /(\d{1,4})/g;
974 /** @type {Array} */
975 jQuery.payment.cards = nodes = [{
976 type: "maestro",
977 patterns: [5018, 502, 503, 506, 56, 58, 639, 6220, 67],
978 format: HEREGEX_OMIT,
979 length: [12, 13, 14, 15, 16, 17, 18, 19],
980 cvcLength: [3],
981 luhn: true
982 }, {
983 type: "forbrugsforeningen",
984 patterns: [600],
985 format: HEREGEX_OMIT,
986 length: [16],
987 cvcLength: [3],
988 luhn: true
989 }, {
990 type: "dankort",
991 patterns: [5019],
992 format: HEREGEX_OMIT,
993 length: [16],
994 cvcLength: [3],
995 luhn: true
996 }, {
997 type: "visa",
998 patterns: [4],
999 format: HEREGEX_OMIT,
1000 length: [13, 16],
1001 cvcLength: [3],
1002 luhn: true
1003 }, {
1004 type: "mastercard",
1005 patterns: [51, 52, 53, 54, 55, 22, 23, 24, 25, 26, 27],
1006 format: HEREGEX_OMIT,
1007 length: [16],
1008 cvcLength: [3],
1009 luhn: true
1010 }, {
1011 type: "amex",
1012 patterns: [34, 37],
1013 format: /(\d{1,4})(\d{1,6})?(\d{1,5})?/,
1014 length: [15],
1015 cvcLength: [3, 4],
1016 luhn: true
1017 }, {
1018 type: "dinersclub",
1019 patterns: [30, 36, 38, 39],
1020 format: /(\d{1,4})(\d{1,6})?(\d{1,4})?/,
1021 length: [14],
1022 cvcLength: [3],
1023 luhn: true
1024 }, {
1025 type: "discover",
1026 patterns: [60, 64, 65, 622],
1027 format: HEREGEX_OMIT,
1028 length: [16],
1029 cvcLength: [3],
1030 luhn: true
1031 }, {
1032 type: "unionpay",
1033 patterns: [62, 88],
1034 format: HEREGEX_OMIT,
1035 length: [16, 17, 18, 19],
1036 cvcLength: [3],
1037 luhn: false
1038 }, {
1039 type: "jcb",
1040 patterns: [35],
1041 format: HEREGEX_OMIT,
1042 length: [16],
1043 cvcLength: [3],
1044 luhn: true
1045 }];
1046 /**
1047 * @param {string} target
1048 * @return {?}
1049 */
1050 parse = function(target) {
1051 var node;
1052 var p;
1053 var x;
1054 var i;
1055 var _i;
1056 var len;
1057 var _len;
1058 var xs;
1059 /** @type {string} */
1060 target = (target + "").replace(/\D/g, "");
1061 /** @type {number} */
1062 i = 0;
1063 len = nodes.length;
1064 for (; len > i; i++) {
1065 node = nodes[i];
1066 xs = node.patterns;
1067 /** @type {number} */
1068 _i = 0;
1069 _len = xs.length;
1070 for (; _len > _i; _i++) {
1071 if (x = xs[_i], p = x + "", target.substr(0, p.length) === p) {
1072 return node;
1073 }
1074 }
1075 }
1076 };
1077 /**
1078 * @param {?} type
1079 * @return {?}
1080 */
1081 _forEach = function(type) {
1082 var node;
1083 var i;
1084 var len;
1085 /** @type {number} */
1086 i = 0;
1087 len = nodes.length;
1088 for (; len > i; i++) {
1089 if (node = nodes[i], node.type === type) {
1090 return node;
1091 }
1092 }
1093 };
1094 /**
1095 * @param {string} num
1096 * @return {?}
1097 */
1098 _luhnCheck = function(num) {
1099 var chr;
1100 var rawParams;
1101 var perm;
1102 var s;
1103 var i;
1104 var len;
1105 /** @type {boolean} */
1106 perm = true;
1107 /** @type {number} */
1108 s = 0;
1109 rawParams = (num + "").split("").reverse();
1110 /** @type {number} */
1111 i = 0;
1112 len = rawParams.length;
1113 for (; len > i; i++) {
1114 chr = rawParams[i];
1115 /** @type {number} */
1116 chr = parseInt(chr, 10);
1117 if (perm = !perm) {
1118 chr *= 2;
1119 }
1120 if (chr > 9) {
1121 chr -= 9;
1122 }
1123 s += chr;
1124 }
1125 return s % 10 == 0;
1126 };
1127 /**
1128 * @param {?} $target
1129 * @return {?}
1130 */
1131 _hasTextSelected = function($target) {
1132 var selection;
1133 return null != $target.prop("selectionStart") && $target.prop("selectionStart") !== $target.prop("selectionEnd") || !(null == ("undefined" != typeof document && (null !== document && null != (selection = document.selection)) ? selection.createRange : void 0) || !document.selection.createRange().text);
1134 };
1135 /**
1136 * @param {string} name
1137 * @param {string} element
1138 * @return {?}
1139 */
1140 $ = function(name, element) {
1141 var x;
1142 var i;
1143 var part;
1144 var parts;
1145 var j;
1146 try {
1147 i = element.prop("selectionStart");
1148 } catch (e) {
1149 e;
1150 /** @type {null} */
1151 i = null;
1152 }
1153 return parts = element.val(), element.val(name), null !== i && element.is(":focus") ? (i === parts.length && (i = name.length), parts !== name && (j = parts.slice(i - 1, +i + 1 || 9E9), x = name.slice(i - 1, +i + 1 || 9E9), part = name[i], /\d/.test(part) && (j === part + " " && (x === " " + part && (i += 1)))), element.prop("selectionStart", i), element.prop("selectionEnd", i)) : void 0;
1154 };
1155 /**
1156 * @param {string} a
1157 * @return {?}
1158 */
1159 each = function(a) {
1160 var _ref;
1161 var token;
1162 var me;
1163 var tokens;
1164 var m;
1165 var obj;
1166 var _j;
1167 var _len;
1168 if (null == a) {
1169 /** @type {string} */
1170 a = "";
1171 }
1172 /** @type {string} */
1173 me = "\uff10\uff11\uff12\uff13\uff14\uff15\uff16\uff17\uff18\uff19";
1174 /** @type {string} */
1175 tokens = "0123456789";
1176 /** @type {string} */
1177 obj = "";
1178 _ref = a.split("");
1179 /** @type {number} */
1180 _j = 0;
1181 _len = _ref.length;
1182 for (; _len > _j; _j++) {
1183 token = _ref[_j];
1184 /** @type {number} */
1185 m = me.indexOf(token);
1186 if (m > -1) {
1187 token = tokens[m];
1188 }
1189 obj += token;
1190 }
1191 return obj;
1192 };
1193 /**
1194 * @param {Event} event
1195 * @return {?}
1196 */
1197 success = function(event) {
1198 var $element;
1199 return $element = jQuery(event.currentTarget), setTimeout(function() {
1200 var r;
1201 return r = $element.val(), r = each(r), r = r.replace(/\D/g, ""), $(r, $element);
1202 });
1203 };
1204 /**
1205 * @param {Event} event
1206 * @return {?}
1207 */
1208 refresh = function(event) {
1209 var $element;
1210 return $element = jQuery(event.currentTarget), setTimeout(function() {
1211 var r;
1212 return r = $element.val(), r = each(r), r = jQuery.payment.formatCardNumber(r), $(r, $element);
1213 });
1214 };
1215 /**
1216 * @param {Event} e
1217 * @return {?}
1218 */
1219 listener = function(e) {
1220 var $target;
1221 var src;
1222 var digit;
1223 var valsLength;
1224 var re;
1225 var match;
1226 var value;
1227 return digit = String.fromCharCode(e.which), !/^\d+$/.test(digit) || ($target = jQuery(e.currentTarget), value = $target.val(), src = parse(value + digit), valsLength = (value.replace(/\D/g, "") + digit).length, match = 16, src && (match = src.length[src.length.length - 1]), valsLength >= match || null != $target.prop("selectionStart") && $target.prop("selectionStart") !== value.length) ? void 0 : (re = src && "amex" === src.type ? /^(\d{4}|\d{4}\s\d{6})$/ : /(?:^|\s)(\d{4})$/, re.test(value) ?
1228 (e.preventDefault(), setTimeout(function() {
1229 return $target.val(value + " " + digit);
1230 })) : re.test(value + digit) ? (e.preventDefault(), setTimeout(function() {
1231 return $target.val(value + digit + " ");
1232 })) : void 0);
1233 };
1234 /**
1235 * @param {Event} event
1236 * @return {?}
1237 */
1238 trigger = function(event) {
1239 var $target;
1240 var requestUrl;
1241 return $target = jQuery(event.currentTarget), requestUrl = $target.val(), 8 !== event.which || null != $target.prop("selectionStart") && $target.prop("selectionStart") !== requestUrl.length ? void 0 : /\d\s$/.test(requestUrl) ? (event.preventDefault(), setTimeout(function() {
1242 return $target.val(requestUrl.replace(/\d\s$/, ""));
1243 })) : /\s\d?$/.test(requestUrl) ? (event.preventDefault(), setTimeout(function() {
1244 return $target.val(requestUrl.replace(/\d$/, ""));
1245 })) : void 0;
1246 };
1247 /**
1248 * @param {Event} event
1249 * @return {?}
1250 */
1251 start = function(event) {
1252 var $element;
1253 return $element = jQuery(event.currentTarget), setTimeout(function() {
1254 var r;
1255 return r = $element.val(), r = each(r), r = jQuery.payment.formatExpiry(r), $(r, $element);
1256 });
1257 };
1258 /**
1259 * @param {Event} e
1260 * @return {?}
1261 */
1262 run = function(e) {
1263 var context;
1264 var last;
1265 var str;
1266 return last = String.fromCharCode(e.which), /^\d+$/.test(last) ? (context = jQuery(e.currentTarget), str = context.val() + last, /^\d$/.test(str) && ("0" !== str && "1" !== str) ? (e.preventDefault(), setTimeout(function() {
1267 return context.val("0" + str + " / ");
1268 })) : /^\d\d$/.test(str) ? (e.preventDefault(), setTimeout(function() {
1269 var nDigit;
1270 var id;
1271 return nDigit = parseInt(str[0], 10), id = parseInt(str[1], 10), id > 2 && 0 !== nDigit ? context.val("0" + nDigit + " / " + id) : context.val(str + " / ");
1272 })) : void 0) : void 0;
1273 };
1274 /**
1275 * @param {Event} event
1276 * @return {?}
1277 */
1278 select = function(event) {
1279 var $this;
1280 var nType;
1281 var prefix;
1282 return nType = String.fromCharCode(event.which), /^\d+$/.test(nType) ? ($this = jQuery(event.currentTarget), prefix = $this.val(), /^\d\d$/.test(prefix) ? $this.val(prefix + " / ") : void 0) : void 0;
1283 };
1284 /**
1285 * @param {Event} e
1286 * @return {?}
1287 */
1288 get = function(e) {
1289 var j;
1290 var x;
1291 var value;
1292 return value = String.fromCharCode(e.which), "/" === value || " " === value ? (j = jQuery(e.currentTarget), x = j.val(), /^\d$/.test(x) && "0" !== x ? j.val("0" + x + " / ") : void 0) : void 0;
1293 };
1294 /**
1295 * @param {Event} event
1296 * @return {?}
1297 */
1298 remove = function(event) {
1299 var $target;
1300 var requestUrl;
1301 return $target = jQuery(event.currentTarget), requestUrl = $target.val(), 8 !== event.which || null != $target.prop("selectionStart") && $target.prop("selectionStart") !== requestUrl.length ? void 0 : /\d\s\/\s$/.test(requestUrl) ? (event.preventDefault(), setTimeout(function() {
1302 return $target.val(requestUrl.replace(/\d\s\/\s$/, ""));
1303 })) : void 0;
1304 };
1305 /**
1306 * @param {Event} element
1307 * @return {?}
1308 */
1309 init = function(element) {
1310 var $element;
1311 return $element = jQuery(element.currentTarget), setTimeout(function() {
1312 var r;
1313 return r = $element.val(), r = each(r), r = r.replace(/\D/g, "").slice(0, 4), $(r, $element);
1314 });
1315 };
1316 /**
1317 * @param {KeyboardEvent} e
1318 * @return {?}
1319 */
1320 func = function(e) {
1321 var nType;
1322 return !(!e.metaKey && !e.ctrlKey) || 32 !== e.which && (0 === e.which || (e.which < 33 || (nType = String.fromCharCode(e.which), !!/[\d\s]/.test(nType))));
1323 };
1324 /**
1325 * @param {Event} event
1326 * @return {?}
1327 */
1328 write = function(event) {
1329 var $target;
1330 var result;
1331 var digit;
1332 var arg;
1333 return $target = jQuery(event.currentTarget), digit = String.fromCharCode(event.which), /^\d+$/.test(digit) && !_hasTextSelected($target) ? (arg = ($target.val() + digit).replace(/\D/g, ""), result = parse(arg), result ? arg.length <= result.length[result.length.length - 1] : arg.length <= 16) : void 0;
1334 };
1335 /**
1336 * @param {Event} event
1337 * @return {?}
1338 */
1339 update = function(event) {
1340 var $target;
1341 var nType;
1342 var phone_number;
1343 return $target = jQuery(event.currentTarget), nType = String.fromCharCode(event.which), /^\d+$/.test(nType) && !_hasTextSelected($target) ? (phone_number = $target.val() + nType, phone_number = phone_number.replace(/\D/g, ""), !(phone_number.length > 6) && void 0) : void 0;
1344 };
1345 /**
1346 * @param {Event} e
1347 * @return {?}
1348 */
1349 _restrictCardNumber = function(e) {
1350 var $target;
1351 var nType;
1352 var codeSegments;
1353 return $target = jQuery(e.currentTarget), nType = String.fromCharCode(e.which), /^\d+$/.test(nType) && !_hasTextSelected($target) ? (codeSegments = $target.val() + nType, codeSegments.length <= 4) : void 0;
1354 };
1355 /**
1356 * @param {Event} event
1357 * @return {?}
1358 */
1359 fn = function(event) {
1360 var self;
1361 var dig;
1362 var node;
1363 var active;
1364 var udataCur;
1365 return self = jQuery(event.currentTarget), udataCur = self.val(), active = jQuery.payment.cardType(udataCur) || "unknown", self.hasClass(active) ? void 0 : (dig = function() {
1366 var i;
1367 var len;
1368 var xml;
1369 /** @type {Array} */
1370 xml = [];
1371 /** @type {number} */
1372 i = 0;
1373 len = nodes.length;
1374 for (; len > i; i++) {
1375 node = nodes[i];
1376 xml.push(node.type);
1377 }
1378 return xml;
1379 }(), self.removeClass("unknown"), self.removeClass(dig.join(" ")), self.addClass(active), self.toggleClass("identified", "unknown" !== active), self.trigger("payment.cardType", active));
1380 };
1381 /**
1382 * @return {?}
1383 */
1384 jQuery.payment.fn.formatCardCVC = function() {
1385 return this.on("keypress", func), this.on("keypress", _restrictCardNumber), this.on("paste", init), this.on("change", init), this.on("input", init), this;
1386 };
1387 /**
1388 * @return {?}
1389 */
1390 jQuery.payment.fn.formatCardExpiry = function() {
1391 return this.on("keypress", func), this.on("keypress", update), this.on("keypress", run), this.on("keypress", get), this.on("keypress", select), this.on("keydown", remove), this.on("change", start), this.on("input", start), this;
1392 };
1393 /**
1394 * @return {?}
1395 */
1396 jQuery.payment.fn.formatCardNumber = function() {
1397 return this.on("keypress", func), this.on("keypress", write), this.on("keypress", listener), this.on("keydown", trigger), this.on("keyup", fn), this.on("paste", refresh), this.on("change", refresh), this.on("input", refresh), this.on("input", fn), this;
1398 };
1399 /**
1400 * @return {?}
1401 */
1402 jQuery.payment.fn.restrictNumeric = function() {
1403 return this.on("keypress", func), this.on("paste", success), this.on("change", success), this.on("input", success), this;
1404 };
1405 /**
1406 * @return {?}
1407 */
1408 jQuery.payment.fn.cardExpiryVal = function() {
1409 return jQuery.payment.cardExpiryVal(jQuery(this).val());
1410 };
1411 /**
1412 * @param {string} pair
1413 * @return {?}
1414 */
1415 jQuery.payment.cardExpiryVal = function(pair) {
1416 var mode;
1417 var line;
1418 var code;
1419 var _ref;
1420 return _ref = pair.split(/[\s\/]+/, 2), mode = _ref[0], code = _ref[1], 2 === (null != code ? code.length : void 0) && (/^\d+$/.test(code) && (line = (new Date).getFullYear(), line = line.toString().slice(0, 2), code = line + code)), mode = parseInt(mode, 10), code = parseInt(code, 10), {
1421 month: mode,
1422 year: code
1423 };
1424 };
1425 /**
1426 * @param {string} value
1427 * @return {?}
1428 */
1429 jQuery.payment.validateCardNumber = function(value) {
1430 var result;
1431 var actual;
1432 return value = (value + "").replace(/\s+|-/g, ""), !!/^\d+$/.test(value) && (!!(result = parse(value)) && (actual = value.length, test.call(result.length, actual) >= 0 && (false === result.luhn || _luhnCheck(value))));
1433 };
1434 /**
1435 * @param {number} n
1436 * @param {string} value
1437 * @return {?}
1438 */
1439 jQuery.payment.validateCardExpiry = function(n, value) {
1440 var b;
1441 var a;
1442 var result;
1443 return "object" == typeof n && ("month" in n && (result = n, n = result.month, value = result.year)), !(!n || !value) && (n = jQuery.trim(n), value = jQuery.trim(value), !!(/^\d+$/.test(n) && (/^\d+$/.test(value) && (n >= 1 && 12 >= n))) && (2 === value.length && (value = 70 > value ? "20" + value : "19" + value), 4 === value.length && (a = new Date(value, n), b = new Date, a.setMonth(a.getMonth() - 1), a.setMonth(a.getMonth() + 1, 1), a > b)));
1444 };
1445 /**
1446 * @param {string} value
1447 * @param {?} data
1448 * @return {?}
1449 */
1450 jQuery.payment.validateCardCVC = function(value, data) {
1451 var message;
1452 var actual;
1453 return value = jQuery.trim(value), !!/^\d+$/.test(value) && (message = _forEach(data), null != message ? (actual = value.length, test.call(message.cvcLength, actual) >= 0) : value.length >= 3 && value.length <= 4);
1454 };
1455 /**
1456 * @param {boolean} value
1457 * @return {?}
1458 */
1459 jQuery.payment.cardType = function(value) {
1460 var src;
1461 return value ? (null != (src = parse(value)) ? src.type : void 0) || null : null;
1462 };
1463 /**
1464 * @param {string} value
1465 * @return {?}
1466 */
1467 jQuery.payment.formatCardNumber = function(value) {
1468 var card;
1469 var parts;
1470 var i;
1471 var dig;
1472 return value = value.replace(/\D/g, ""), (card = parse(value)) ? (i = card.length[card.length.length - 1], value = value.slice(0, i), card.format.global ? null != (dig = value.match(card.format)) ? dig.join(" ") : void 0 : (parts = card.format.exec(value), null != parts ? (parts.shift(), parts = jQuery.grep(parts, function(dataAndEvents) {
1473 return dataAndEvents;
1474 }), parts.join(" ")) : void 0)) : value;
1475 };
1476 /**
1477 * @param {string} first
1478 * @return {?}
1479 */
1480 jQuery.payment.formatExpiry = function(first) {
1481 var b;
1482 var segmentMatch;
1483 var p;
1484 var w;
1485 return (segmentMatch = first.match(/^\D*(\d{1,2})(\D+)?(\d{1,4})?/)) ? (b = segmentMatch[1] || "", p = segmentMatch[2] || "", w = segmentMatch[3] || "", w.length > 0 ? p = " / " : " /" === p ? (b = b.substring(0, 1), p = "") : 2 === b.length || p.length > 0 ? p = " / " : 1 === b.length && ("0" !== b && ("1" !== b && (b = "0" + b, p = " / "))), b + p + w) : "";
1486 };
1487}.call(this),
1488 function($, id) {
1489 if ($.rails !== id) {
1490 $.error("jquery-ujs has already been loaded!");
1491 }
1492 var rails;
1493 var $document = $(document);
1494 $.rails = rails = {
1495 linkClickSelector: "a[data-confirm], a[data-method], a[data-remote], a[data-disable-with], a[data-disable]",
1496 buttonClickSelector: "button[data-remote]:not(form button), button[data-confirm]:not(form button)",
1497 inputChangeSelector: "select[data-remote], input[data-remote], textarea[data-remote]",
1498 formSubmitSelector: "form",
1499 formInputClickSelector: "form input[type=submit], form input[type=image], form button[type=submit], form button:not([type]), input[type=submit][form], input[type=image][form], button[type=submit][form], button[form]:not([type])",
1500 disableSelector: "input[data-disable-with]:enabled, button[data-disable-with]:enabled, textarea[data-disable-with]:enabled, input[data-disable]:enabled, button[data-disable]:enabled, textarea[data-disable]:enabled",
1501 enableSelector: "input[data-disable-with]:disabled, button[data-disable-with]:disabled, textarea[data-disable-with]:disabled, input[data-disable]:disabled, button[data-disable]:disabled, textarea[data-disable]:disabled",
1502 requiredInputSelector: "input[name][required]:not([disabled]),textarea[name][required]:not([disabled])",
1503 fileInputSelector: "input[type=file]",
1504 linkDisableSelector: "a[data-disable-with], a[data-disable]",
1505 buttonDisableSelector: "button[data-remote][data-disable-with], button[data-remote][data-disable]",
1506 /**
1507 * @param {Object} xhr
1508 * @return {undefined}
1509 */
1510 CSRFProtection: function(xhr) {
1511 var token = $('meta[name="csrf-token"]').attr("content");
1512 if (token) {
1513 xhr.setRequestHeader("X-CSRF-Token", token);
1514 }
1515 },
1516 /**
1517 * @return {undefined}
1518 */
1519 refreshCSRFTokens: function() {
1520 var csrfToken = $("meta[name=csrf-token]").attr("content");
1521 var outputReCompress = $("meta[name=csrf-param]").attr("content");
1522 $('form input[name="' + outputReCompress + '"]').val(csrfToken);
1523 },
1524 /**
1525 * @param {Object} obj
1526 * @param {string} name
1527 * @param {Array} data
1528 * @return {?}
1529 */
1530 fire: function(obj, name, data) {
1531 var type = $.Event(name);
1532 return obj.trigger(type, data), false !== type.result;
1533 },
1534 /**
1535 * @param {?} message
1536 * @return {?}
1537 */
1538 confirm: function(message) {
1539 return confirm(message);
1540 },
1541 /**
1542 * @param {?} opt_attributes
1543 * @return {?}
1544 */
1545 ajax: function(opt_attributes) {
1546 return $.ajax(opt_attributes);
1547 },
1548 /**
1549 * @param {Object} node
1550 * @return {?}
1551 */
1552 href: function(node) {
1553 return node.attr("href");
1554 },
1555 /**
1556 * @param {Object} element
1557 * @return {?}
1558 */
1559 handleRemote: function(element) {
1560 var method;
1561 var url;
1562 var m;
1563 var elCrossDomain;
1564 var crossDomain;
1565 var cors_creds;
1566 var type;
1567 var options;
1568 if (rails.fire(element, "ajax:before")) {
1569 if (elCrossDomain = element.data("cross-domain"), crossDomain = elCrossDomain === id ? null : elCrossDomain, cors_creds = element.data("with-credentials") || null, type = element.data("type") || $.ajaxSettings && $.ajaxSettings.dataType, element.is("form")) {
1570 method = element.attr("method");
1571 url = element.attr("action");
1572 m = element.serializeArray();
1573 var attributes = element.data("ujs:submit-button");
1574 if (attributes) {
1575 m.push(attributes);
1576 element.data("ujs:submit-button", null);
1577 }
1578 } else {
1579 if (element.is(rails.inputChangeSelector)) {
1580 method = element.data("method");
1581 url = element.data("url");
1582 m = element.serialize();
1583 if (element.data("params")) {
1584 m = m + "&" + element.data("params");
1585 }
1586 } else {
1587 if (element.is(rails.buttonClickSelector)) {
1588 method = element.data("method") || "get";
1589 url = element.data("url");
1590 m = element.serialize();
1591 if (element.data("params")) {
1592 m = m + "&" + element.data("params");
1593 }
1594 } else {
1595 method = element.data("method");
1596 url = rails.href(element);
1597 m = element.data("params") || null;
1598 }
1599 }
1600 }
1601 return options = {
1602 type: method || "GET",
1603 data: m,
1604 dataType: type,
1605 /**
1606 * @param {Object} xhr
1607 * @param {Object} settings
1608 * @return {?}
1609 */
1610 beforeSend: function(xhr, settings) {
1611 if (settings.dataType === id && xhr.setRequestHeader("accept", "*/*;q=0.5, " + settings.accepts.script), !rails.fire(element, "ajax:beforeSend", [xhr, settings])) {
1612 return false;
1613 }
1614 element.trigger("ajax:send", xhr);
1615 },
1616 /**
1617 * @param {?} data
1618 * @param {?} status
1619 * @param {?} error
1620 * @return {undefined}
1621 */
1622 success: function(data, status, error) {
1623 element.trigger("ajax:success", [data, status, error]);
1624 },
1625 /**
1626 * @param {Function} xhr
1627 * @param {?} status
1628 * @return {undefined}
1629 */
1630 complete: function(xhr, status) {
1631 element.trigger("ajax:complete", [xhr, status]);
1632 },
1633 /**
1634 * @param {Function} xhr
1635 * @param {?} status
1636 * @param {?} error
1637 * @return {undefined}
1638 */
1639 error: function(xhr, status, error) {
1640 element.trigger("ajax:error", [xhr, status, error]);
1641 },
1642 crossDomain: crossDomain
1643 }, cors_creds && (options.xhrFields = {
1644 withCredentials: cors_creds
1645 }), url && (options.url = url), rails.ajax(options);
1646 }
1647 return false;
1648 },
1649 /**
1650 * @param {Object} link
1651 * @return {undefined}
1652 */
1653 handleMethod: function(link) {
1654 var links = rails.href(link);
1655 var method = link.data("method");
1656 var t = link.attr("target");
1657 var prop = $("meta[name=csrf-token]").attr("content");
1658 var actual = $("meta[name=csrf-param]").attr("content");
1659 var form = $('<form method="post" action="' + links + '"></form>');
1660 /** @type {string} */
1661 var metadata_input = '<input name="_method" value="' + method + '" type="hidden" />';
1662 if (actual !== id) {
1663 if (prop !== id) {
1664 metadata_input += '<input name="' + actual + '" value="' + prop + '" type="hidden" />';
1665 }
1666 }
1667 if (t) {
1668 form.attr("target", t);
1669 }
1670 form.hide().append(metadata_input).appendTo("body");
1671 form.submit();
1672 },
1673 /**
1674 * @param {Object} element
1675 * @param {?} form
1676 * @return {?}
1677 */
1678 formElements: function(element, form) {
1679 return element.is("form") ? $(element[0].elements).filter(form) : element.find(form);
1680 },
1681 /**
1682 * @param {Object} form
1683 * @return {undefined}
1684 */
1685 disableFormElements: function(form) {
1686 rails.formElements(form, rails.disableSelector).each(function() {
1687 rails.disableFormElement($(this));
1688 });
1689 },
1690 /**
1691 * @param {Object} input
1692 * @return {undefined}
1693 */
1694 disableFormElement: function(input) {
1695 var type;
1696 var nextStack;
1697 /** @type {string} */
1698 type = input.is("button") ? "html" : "val";
1699 nextStack = input.data("disable-with");
1700 input.data("ujs:enable-with", input[type]());
1701 if (nextStack !== id) {
1702 input[type](nextStack);
1703 }
1704 input.prop("disabled", true);
1705 },
1706 /**
1707 * @param {Object} form
1708 * @return {undefined}
1709 */
1710 enableFormElements: function(form) {
1711 rails.formElements(form, rails.enableSelector).each(function() {
1712 rails.enableFormElement($(this));
1713 });
1714 },
1715 /**
1716 * @param {Object} element
1717 * @return {undefined}
1718 */
1719 enableFormElement: function(element) {
1720 /** @type {string} */
1721 var method = element.is("button") ? "html" : "val";
1722 if (element.data("ujs:enable-with")) {
1723 element[method](element.data("ujs:enable-with"));
1724 }
1725 element.prop("disabled", false);
1726 },
1727 /**
1728 * @param {?} element
1729 * @return {?}
1730 */
1731 allowAction: function(element) {
1732 var callback;
1733 var message = element.data("confirm");
1734 /** @type {boolean} */
1735 var answer = false;
1736 return !message || (rails.fire(element, "confirm") && (answer = rails.confirm(message), callback = rails.fire(element, "confirm:complete", [answer])), answer && callback);
1737 },
1738 /**
1739 * @param {Object} form
1740 * @param {string} specifiedSelector
1741 * @param {boolean} dataAndEvents
1742 * @return {?}
1743 */
1744 blankInputs: function(form, specifiedSelector, dataAndEvents) {
1745 var $el;
1746 var o;
1747 var $div = $();
1748 var selector = specifiedSelector || "input,textarea";
1749 var elem = form.find(selector);
1750 return elem.each(function() {
1751 if ($el = $(this), !(o = $el.is("input[type=checkbox],input[type=radio]") ? $el.is(":checked") : $el.val()) == !dataAndEvents) {
1752 if ($el.is("input[type=radio]") && elem.filter('input[type=radio]:checked[name="' + $el.attr("name") + '"]').length) {
1753 return true;
1754 }
1755 $div = $div.add($el);
1756 }
1757 }), !!$div.length && $div;
1758 },
1759 /**
1760 * @param {Object} form
1761 * @param {string} specifiedSelector
1762 * @return {?}
1763 */
1764 nonBlankInputs: function(form, specifiedSelector) {
1765 return rails.blankInputs(form, specifiedSelector, true);
1766 },
1767 /**
1768 * @param {Object} e
1769 * @return {?}
1770 */
1771 stopEverything: function(e) {
1772 return $(e.target).trigger("ujs:everythingStopped"), e.stopImmediatePropagation(), false;
1773 },
1774 /**
1775 * @param {Object} element
1776 * @return {undefined}
1777 */
1778 disableElement: function(element) {
1779 var n = element.data("disable-with");
1780 element.data("ujs:enable-with", element.html());
1781 if (n !== id) {
1782 element.html(n);
1783 }
1784 element.bind("click.railsDisable", function(e) {
1785 return rails.stopEverything(e);
1786 });
1787 },
1788 /**
1789 * @param {Object} element
1790 * @return {undefined}
1791 */
1792 enableElement: function(element) {
1793 if (element.data("ujs:enable-with") !== id) {
1794 element.html(element.data("ujs:enable-with"));
1795 element.removeData("ujs:enable-with");
1796 }
1797 element.unbind("click.railsDisable");
1798 }
1799 };
1800 if (rails.fire($document, "rails:attachBindings")) {
1801 $.ajaxPrefilter(function(s, dataAndEvents, xhr) {
1802 if (!s.crossDomain) {
1803 rails.CSRFProtection(xhr);
1804 }
1805 });
1806 $document.delegate(rails.linkDisableSelector, "ajax:complete", function() {
1807 rails.enableElement($(this));
1808 });
1809 $document.delegate(rails.buttonDisableSelector, "ajax:complete", function() {
1810 rails.enableFormElement($(this));
1811 });
1812 $document.delegate(rails.linkClickSelector, "click.rails", function(e) {
1813 var link = $(this);
1814 var method = link.data("method");
1815 var queryString = link.data("params");
1816 var s = e.metaKey || e.ctrlKey;
1817 if (!rails.allowAction(link)) {
1818 return rails.stopEverything(e);
1819 }
1820 if (!s && (link.is(rails.linkDisableSelector) && rails.disableElement(link)), link.data("remote") !== id) {
1821 if (s && ((!method || "GET" === method) && !queryString)) {
1822 return true;
1823 }
1824 var nodes = rails.handleRemote(link);
1825 return false === nodes ? rails.enableElement(link) : nodes.error(function() {
1826 rails.enableElement(link);
1827 }), false;
1828 }
1829 return link.data("method") ? (rails.handleMethod(link), false) : void 0;
1830 });
1831 $document.delegate(rails.buttonClickSelector, "click.rails", function(e) {
1832 var link = $(this);
1833 if (!rails.allowAction(link)) {
1834 return rails.stopEverything(e);
1835 }
1836 if (link.is(rails.buttonDisableSelector)) {
1837 rails.disableFormElement(link);
1838 }
1839 var nodes = rails.handleRemote(link);
1840 return false === nodes ? rails.enableFormElement(link) : nodes.error(function() {
1841 rails.enableFormElement(link);
1842 }), false;
1843 });
1844 $document.delegate(rails.inputChangeSelector, "change.rails", function(e) {
1845 var link = $(this);
1846 return rails.allowAction(link) ? (rails.handleRemote(link), false) : rails.stopEverything(e);
1847 });
1848 $document.delegate(rails.formSubmitSelector, "submit.rails", function(e) {
1849 var answer;
1850 var xhr;
1851 var form = $(this);
1852 /** @type {boolean} */
1853 var s = form.data("remote") !== id;
1854 if (!rails.allowAction(form)) {
1855 return rails.stopEverything(e);
1856 }
1857 if (form.attr("novalidate") == id && ((answer = rails.blankInputs(form, rails.requiredInputSelector)) && rails.fire(form, "ajax:aborted:required", [answer]))) {
1858 return rails.stopEverything(e);
1859 }
1860 if (s) {
1861 if (xhr = rails.nonBlankInputs(form, rails.fileInputSelector)) {
1862 setTimeout(function() {
1863 rails.disableFormElements(form);
1864 }, 13);
1865 var $form = rails.fire(form, "ajax:aborted:file", [xhr]);
1866 return $form || setTimeout(function() {
1867 rails.enableFormElements(form);
1868 }, 13), $form;
1869 }
1870 return rails.handleRemote(form), false;
1871 }
1872 setTimeout(function() {
1873 rails.disableFormElements(form);
1874 }, 13);
1875 });
1876 $document.delegate(rails.formInputClickSelector, "click.rails", function(e) {
1877 var button = $(this);
1878 if (!rails.allowAction(button)) {
1879 return rails.stopEverything(e);
1880 }
1881 var name = button.attr("name");
1882 /** @type {(null|{name: ??, value: ?})} */
1883 var index = name ? {
1884 name: name,
1885 value: button.val()
1886 } : null;
1887 button.closest("form").data("ujs:submit-button", index);
1888 });
1889 $document.delegate(rails.formSubmitSelector, "ajax:send.rails", function(opt_e) {
1890 if (this == opt_e.target) {
1891 rails.disableFormElements($(this));
1892 }
1893 });
1894 $document.delegate(rails.formSubmitSelector, "ajax:complete.rails", function(opt_e) {
1895 if (this == opt_e.target) {
1896 rails.enableFormElements($(this));
1897 }
1898 });
1899 $(function() {
1900 rails.refreshCSRFTokens();
1901 });
1902 }
1903 }(jQuery),
1904 function(root, factory) {
1905 if ("function" == typeof define && define.amd) {
1906 define([], factory);
1907 } else {
1908 if ("object" == typeof exports) {
1909 module.exports = factory();
1910 } else {
1911 root.salvattore = factory();
1912 }
1913 }
1914 }(this, function() {
1915 return window.matchMedia || (window.matchMedia = function() {
1916 var styleMedia = window.styleMedia || window.media;
1917 if (!styleMedia) {
1918 /** @type {Element} */
1919 var style = document.createElement("style");
1920 var insertAt = document.getElementsByTagName("script")[0];
1921 /** @type {null} */
1922 var innerSize = null;
1923 /** @type {string} */
1924 style.type = "text/css";
1925 /** @type {string} */
1926 style.id = "matchmediajs-test";
1927 insertAt.parentNode.insertBefore(style, insertAt);
1928 innerSize = "getComputedStyle" in window && window.getComputedStyle(style, null) || style.currentStyle;
1929 styleMedia = {
1930 /**
1931 * @param {string} dataAndEvents
1932 * @return {?}
1933 */
1934 matchMedium: function(dataAndEvents) {
1935 /** @type {string} */
1936 var text = "@media " + dataAndEvents + "{ #matchmediajs-test { width: 1px; } }";
1937 return style.styleSheet ? style.styleSheet.cssText = text : style.textContent = text, "1px" === innerSize.width;
1938 }
1939 };
1940 }
1941 return function(media) {
1942 return {
1943 matches: styleMedia.matchMedium(media || "all"),
1944 media: media || "all"
1945 };
1946 };
1947 }()),
1948 function() {
1949 if (window.matchMedia && window.matchMedia("all").addListener) {
1950 return false;
1951 }
1952 /** @type {function (string): (MediaQueryList|null)} */
1953 var localMatchMedia = window.matchMedia;
1954 /** @type {boolean} */
1955 var hasMediaQueries = localMatchMedia("only all").matches;
1956 /** @type {boolean} */
1957 var n = false;
1958 /** @type {number} */
1959 var tref = 0;
1960 /** @type {Array} */
1961 var queries = [];
1962 /**
1963 * @return {undefined}
1964 */
1965 var handleChange = function() {
1966 clearTimeout(tref);
1967 /** @type {number} */
1968 tref = setTimeout(function() {
1969 /** @type {number} */
1970 var i = 0;
1971 /** @type {number} */
1972 var len = queries.length;
1973 for (; len > i; i++) {
1974 var mql = queries[i].mql;
1975 var special = queries[i].listeners || [];
1976 /** @type {boolean} */
1977 var matches = localMatchMedia(mql.media).matches;
1978 if (matches !== mql.matches) {
1979 /** @type {boolean} */
1980 mql.matches = matches;
1981 /** @type {number} */
1982 var type = 0;
1983 var cnl = special.length;
1984 for (; cnl > type; type++) {
1985 special[type].call(window, mql);
1986 }
1987 }
1988 }
1989 }, 30);
1990 };
1991 /**
1992 * @param {string} media
1993 * @return {(MediaQueryList|null)}
1994 */
1995 window.matchMedia = function(media) {
1996 /** @type {(MediaQueryList|null)} */
1997 var mql = localMatchMedia(media);
1998 /** @type {Array} */
1999 var listeners = [];
2000 /** @type {number} */
2001 var l = 0;
2002 return mql.addListener = function(listener) {
2003 if (hasMediaQueries) {
2004 if (!n) {
2005 /** @type {boolean} */
2006 n = true;
2007 window.addEventListener("resize", handleChange, true);
2008 }
2009 if (0 === l) {
2010 /** @type {number} */
2011 l = queries.push({
2012 mql: mql,
2013 listeners: listeners
2014 });
2015 }
2016 listeners.push(listener);
2017 }
2018 }, mql.removeListener = function(fn) {
2019 /** @type {number} */
2020 var i = 0;
2021 /** @type {number} */
2022 var l = listeners.length;
2023 for (; l > i; i++) {
2024 if (listeners[i] === fn) {
2025 listeners.splice(i, 1);
2026 }
2027 }
2028 }, mql;
2029 };
2030 }(),
2031 function() {
2032 /** @type {number} */
2033 var lastTime = 0;
2034 /** @type {Array} */
2035 var vendors = ["ms", "moz", "webkit", "o"];
2036 /** @type {number} */
2037 var x = 0;
2038 for (; x < vendors.length && !window.requestAnimationFrame; ++x) {
2039 window.requestAnimationFrame = window[vendors[x] + "RequestAnimationFrame"];
2040 window.cancelAnimationFrame = window[vendors[x] + "CancelAnimationFrame"] || window[vendors[x] + "CancelRequestAnimationFrame"];
2041 }
2042 if (!window.requestAnimationFrame) {
2043 /**
2044 * @param {function (number): ?} callback
2045 * @return {number}
2046 */
2047 window.requestAnimationFrame = function(callback) {
2048 /** @type {number} */
2049 var currTime = (new Date).getTime();
2050 /** @type {number} */
2051 var timeToCall = Math.max(0, 16 - (currTime - lastTime));
2052 /** @type {number} */
2053 var id = window.setTimeout(function() {
2054 callback(currTime + timeToCall);
2055 }, timeToCall);
2056 return lastTime = currTime + timeToCall, id;
2057 };
2058 }
2059 if (!window.cancelAnimationFrame) {
2060 /**
2061 * @param {number} id
2062 * @return {?}
2063 */
2064 window.cancelAnimationFrame = function(id) {
2065 clearTimeout(id);
2066 };
2067 }
2068 }(), "function" != typeof window.CustomEvent && function() {
2069 /**
2070 * @param {?} event
2071 * @param {Object} params
2072 * @return {?}
2073 */
2074 function CustomEvent(event, params) {
2075 params = params || {
2076 bubbles: false,
2077 cancelable: false,
2078 detail: void 0
2079 };
2080 /** @type {(Event|null)} */
2081 var evt = document.createEvent("CustomEvent");
2082 return evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail), evt;
2083 }
2084 CustomEvent.prototype = window.Event.prototype;
2085 /** @type {function (?, Object): ?} */
2086 window.CustomEvent = CustomEvent;
2087 }(),
2088 function(global, doc) {
2089 var self = {};
2090 /** @type {Array} */
2091 var uniqs = [];
2092 /** @type {Array} */
2093 var ret = [];
2094 /** @type {Array} */
2095 var arr = [];
2096 /**
2097 * @param {Element} element
2098 * @param {string} key
2099 * @param {string} value
2100 * @return {undefined}
2101 */
2102 var add_to_dataset = function(element, key, value) {
2103 if (element.dataset) {
2104 /** @type {string} */
2105 element.dataset[key] = value;
2106 } else {
2107 element.setAttribute("data-" + key, value);
2108 }
2109 };
2110 return self.obtainGridSettings = function(value) {
2111 /** @type {(CSSStyleDeclaration|null)} */
2112 var cur = global.getComputedStyle(value, ":before");
2113 /** @type {string} */
2114 var segment = cur.getPropertyValue("content").slice(1, -1);
2115 /** @type {(Array.<string>|null)} */
2116 var matchResult = segment.match(/^\s*(\d+)(?:\s?\.(.+))?\s*$/);
2117 /** @type {number} */
2118 var numberOfColumns = 1;
2119 /** @type {Array} */
2120 var columnClasses = [];
2121 return matchResult ? (numberOfColumns = matchResult[1], columnClasses = matchResult[2], columnClasses = columnClasses ? columnClasses.split(".") : ["column"]) : (matchResult = segment.match(/^\s*\.(.+)\s+(\d+)\s*$/)) && (columnClasses = matchResult[1], (numberOfColumns = matchResult[2]) && (numberOfColumns = numberOfColumns.split("."))), {
2122 numberOfColumns: numberOfColumns,
2123 columnClasses: columnClasses
2124 };
2125 }, self.addColumns = function(grid, element) {
2126 var expression;
2127 var settings = self.obtainGridSettings(grid);
2128 var numberOfColumns = settings.numberOfColumns;
2129 var columnClasses = settings.columnClasses;
2130 /** @type {Array} */
2131 var row = new Array(+numberOfColumns);
2132 /** @type {DocumentFragment} */
2133 var columnsFragment = doc.createDocumentFragment();
2134 var i = numberOfColumns;
2135 for (; 0 != i--;) {
2136 /** @type {string} */
2137 expression = "[data-columns] > *:nth-child(" + numberOfColumns + "n-" + i + ")";
2138 row.push(element.querySelectorAll(expression));
2139 }
2140 row.forEach(function(next_scope) {
2141 /** @type {Element} */
2142 var column = doc.createElement("div");
2143 /** @type {DocumentFragment} */
2144 var el = doc.createDocumentFragment();
2145 column.className = columnClasses.join(" ");
2146 Array.prototype.forEach.call(next_scope, function(child) {
2147 el.appendChild(child);
2148 });
2149 column.appendChild(el);
2150 columnsFragment.appendChild(column);
2151 });
2152 grid.appendChild(columnsFragment);
2153 add_to_dataset(grid, "columns", numberOfColumns);
2154 }, self.removeColumns = function(text) {
2155 /** @type {(Range|null)} */
2156 var range = doc.createRange();
2157 range.selectNodeContents(text);
2158 /** @type {Array.<?>} */
2159 var ar = Array.prototype.filter.call(range.extractContents().childNodes, function(node) {
2160 return node instanceof global.HTMLElement;
2161 });
2162 /** @type {number} */
2163 var j = ar.length;
2164 var numberOfRowsInFirstColumn = ar[0].childNodes.length;
2165 /** @type {Array} */
2166 var items = new Array(numberOfRowsInFirstColumn * j);
2167 Array.prototype.forEach.call(ar, function(chunk, i) {
2168 Array.prototype.forEach.call(chunk.children, function(accessToken, h) {
2169 items[h * j + i] = accessToken;
2170 });
2171 });
2172 /** @type {Element} */
2173 var container = doc.createElement("div");
2174 return add_to_dataset(container, "columns", 0), items.filter(function(dataAndEvents) {
2175 return !!dataAndEvents;
2176 }).forEach(function(region) {
2177 container.appendChild(region);
2178 }), container;
2179 }, self.recreateColumns = function(html) {
2180 global.requestAnimationFrame(function() {
2181 self.addColumns(html, self.removeColumns(html));
2182 /** @type {CustomEvent} */
2183 var event = new CustomEvent("columnsChange");
2184 html.dispatchEvent(event);
2185 });
2186 }, self.mediaQueryChange = function(matcher) {
2187 if (matcher.matches) {
2188 Array.prototype.forEach.call(uniqs, self.recreateColumns);
2189 }
2190 }, self.getCSSRules = function(node) {
2191 var t;
2192 try {
2193 t = node.sheet.cssRules || node.sheet.rules;
2194 } catch (e) {
2195 return [];
2196 }
2197 return t || [];
2198 }, self.getStylesheets = function() {
2199 /** @type {Array.<?>} */
2200 var xs = Array.prototype.slice.call(doc.querySelectorAll("style"));
2201 return xs.forEach(function(statement, x) {
2202 if ("text/css" !== statement.type) {
2203 if ("" !== statement.type) {
2204 xs.splice(x, 1);
2205 }
2206 }
2207 }), Array.prototype.concat.call(xs, Array.prototype.slice.call(doc.querySelectorAll("link[rel='stylesheet']")));
2208 }, self.mediaRuleHasColumnsSelector = function(rules) {
2209 var index;
2210 var rule;
2211 try {
2212 index = rules.length;
2213 } catch (e) {
2214 /** @type {number} */
2215 index = 0;
2216 }
2217 for (; index--;) {
2218 if (rule = rules[index], rule.selectorText && rule.selectorText.match(/\[data-columns\](.*)::?before$/)) {
2219 return true;
2220 }
2221 }
2222 return false;
2223 }, self.scanMediaQueries = function() {
2224 /** @type {Array} */
2225 var array = [];
2226 if (global.matchMedia) {
2227 self.getStylesheets().forEach(function(m) {
2228 Array.prototype.forEach.call(self.getCSSRules(m), function(item) {
2229 try {
2230 if (item.media) {
2231 if (item.cssRules) {
2232 if (self.mediaRuleHasColumnsSelector(item.cssRules)) {
2233 array.push(item);
2234 }
2235 }
2236 }
2237 } catch (e) {}
2238 });
2239 });
2240 var classes = ret.filter(function(methods) {
2241 return -1 === array.indexOf(methods);
2242 });
2243 arr.filter(function(event) {
2244 return -1 !== classes.indexOf(event.rule);
2245 }).forEach(function(set) {
2246 set.mql.removeListener(self.mediaQueryChange);
2247 });
2248 arr = arr.filter(function(event) {
2249 return -1 === classes.indexOf(event.rule);
2250 });
2251 array.filter(function(key) {
2252 return -1 == ret.indexOf(key);
2253 }).forEach(function(rule) {
2254 /** @type {(MediaQueryList|null)} */
2255 var mql = global.matchMedia(rule.media.mediaText);
2256 mql.addListener(self.mediaQueryChange);
2257 arr.push({
2258 rule: rule,
2259 mql: mql
2260 });
2261 });
2262 /** @type {number} */
2263 ret.length = 0;
2264 /** @type {Array} */
2265 ret = array;
2266 }
2267 }, self.rescanMediaQueries = function() {
2268 self.scanMediaQueries();
2269 Array.prototype.forEach.call(uniqs, self.recreateColumns);
2270 }, self.nextElementColumnIndex = function(element, elm) {
2271 var child;
2272 var maxDelay;
2273 var i;
2274 var children = element.children;
2275 var l = children.length;
2276 /** @type {number} */
2277 var delay = 0;
2278 /** @type {number} */
2279 var foundI = 0;
2280 /** @type {number} */
2281 i = 0;
2282 for (; l > i; i++) {
2283 child = children[i];
2284 maxDelay = child.children.length + (elm[i].children || elm[i].childNodes).length;
2285 if (0 === delay) {
2286 delay = maxDelay;
2287 }
2288 if (delay > maxDelay) {
2289 /** @type {number} */
2290 foundI = i;
2291 delay = maxDelay;
2292 }
2293 }
2294 return foundI;
2295 }, self.createFragmentsList = function(count) {
2296 /** @type {Array} */
2297 var map = new Array(count);
2298 /** @type {number} */
2299 var objUid = 0;
2300 for (; objUid !== count;) {
2301 /** @type {DocumentFragment} */
2302 map[objUid] = doc.createDocumentFragment();
2303 objUid++;
2304 }
2305 return map;
2306 }, self.appendElements = function(slide, next_scope) {
2307 var arr = slide.children;
2308 var e = arr.length;
2309 var n = self.createFragmentsList(e);
2310 Array.prototype.forEach.call(next_scope, function(stat) {
2311 var e = self.nextElementColumnIndex(slide, n);
2312 n[e].appendChild(stat);
2313 });
2314 Array.prototype.forEach.call(arr, function(s, i) {
2315 s.appendChild(n[i]);
2316 });
2317 }, self.prependElements = function(div, assertions) {
2318 var nodes = div.children;
2319 var count = nodes.length;
2320 var prevSources = self.createFragmentsList(count);
2321 /** @type {number} */
2322 var i = count - 1;
2323 assertions.forEach(function(fragment) {
2324 var cell = prevSources[i];
2325 cell.insertBefore(fragment, cell.firstChild);
2326 if (0 === i) {
2327 /** @type {number} */
2328 i = count - 1;
2329 } else {
2330 i--;
2331 }
2332 });
2333 Array.prototype.forEach.call(nodes, function(cell, i) {
2334 cell.insertBefore(prevSources[i], cell.firstChild);
2335 });
2336 /** @type {DocumentFragment} */
2337 var el = doc.createDocumentFragment();
2338 /** @type {number} */
2339 var next = assertions.length % count;
2340 for (; 0 != next--;) {
2341 el.appendChild(div.lastChild);
2342 }
2343 div.insertBefore(el, div.firstChild);
2344 }, self.registerGrid = function(grid) {
2345 if ("none" !== global.getComputedStyle(grid).display) {
2346 /** @type {(Range|null)} */
2347 var range = doc.createRange();
2348 range.selectNodeContents(grid);
2349 /** @type {Element} */
2350 var wrapper = doc.createElement("div");
2351 wrapper.appendChild(range.extractContents());
2352 add_to_dataset(wrapper, "columns", 0);
2353 self.addColumns(grid, wrapper);
2354 uniqs.push(grid);
2355 }
2356 }, self.init = function() {
2357 /** @type {Element} */
2358 var styles = doc.createElement("style");
2359 /** @type {string} */
2360 styles.innerHTML = "[data-columns]::before{display:block;visibility:hidden;position:absolute;font-size:1px;}";
2361 doc.head.appendChild(styles);
2362 /** @type {NodeList} */
2363 var uniqs = doc.querySelectorAll("[data-columns]");
2364 Array.prototype.forEach.call(uniqs, self.registerGrid);
2365 self.scanMediaQueries();
2366 }, self.init(), {
2367 /** @type {function (Object, ?): undefined} */
2368 appendElements: self.appendElements,
2369 /** @type {function (Element, Array): undefined} */
2370 prependElements: self.prependElements,
2371 /** @type {function (Element): undefined} */
2372 registerGrid: self.registerGrid,
2373 /** @type {function (Element): undefined} */
2374 recreateColumns: self.recreateColumns,
2375 /** @type {function (): undefined} */
2376 rescanMediaQueries: self.rescanMediaQueries,
2377 /** @type {function (): undefined} */
2378 init: self.init,
2379 /** @type {function (Object, ?): undefined} */
2380 append_elements: self.appendElements,
2381 /** @type {function (Element, Array): undefined} */
2382 prepend_elements: self.prependElements,
2383 /** @type {function (Element): undefined} */
2384 register_grid: self.registerGrid,
2385 /** @type {function (Element): undefined} */
2386 recreate_columns: self.recreateColumns,
2387 /** @type {function (): undefined} */
2388 rescan_media_queries: self.rescanMediaQueries
2389 };
2390 }(window, window.document);
2391 }),
2392 function(root, value) {
2393 /** @type {string} */
2394 var EMPTY = "";
2395 /** @type {string} */
2396 var string = "?";
2397 /** @type {string} */
2398 var FUNC_TYPE = "function";
2399 /** @type {string} */
2400 var UNDEF_TYPE = "undefined";
2401 /** @type {string} */
2402 var OBJ_TYPE = "object";
2403 /** @type {string} */
2404 var list = "string";
2405 /** @type {string} */
2406 var attrs = "model";
2407 /** @type {string} */
2408 var info = "name";
2409 /** @type {string} */
2410 var t = "type";
2411 /** @type {string} */
2412 var VENDOR = "vendor";
2413 /** @type {string} */
2414 var VERSION = "version";
2415 /** @type {string} */
2416 var ARCHITECTURE = "architecture";
2417 /** @type {string} */
2418 var CONSOLE = "console";
2419 /** @type {string} */
2420 var MOBILE = "mobile";
2421 /** @type {string} */
2422 var TABLET = "tablet";
2423 /** @type {string} */
2424 var SMARTTV = "smarttv";
2425 /** @type {string} */
2426 var WEARABLE = "wearable";
2427 var util = {
2428 /**
2429 * @param {?} opt_attributes
2430 * @param {Object} b
2431 * @return {?}
2432 */
2433 extend: function(opt_attributes, b) {
2434 var dest = {};
2435 var name;
2436 for (name in opt_attributes) {
2437 if (b[name] && b[name].length % 2 == 0) {
2438 dest[name] = b[name].concat(opt_attributes[name]);
2439 } else {
2440 dest[name] = opt_attributes[name];
2441 }
2442 }
2443 return dest;
2444 },
2445 /**
2446 * @param {Object} fn
2447 * @param {Object} property
2448 * @return {?}
2449 */
2450 has: function(fn, property) {
2451 return "string" == typeof fn && -1 !== property.toLowerCase().indexOf(fn.toLowerCase());
2452 },
2453 /**
2454 * @param {Object} str
2455 * @return {?}
2456 */
2457 lowerize: function(str) {
2458 return str.toLowerCase();
2459 },
2460 /**
2461 * @param {string} lastLine
2462 * @return {?}
2463 */
2464 major: function(lastLine) {
2465 return typeof lastLine === list ? lastLine.replace(/[^\d\.]/g, "").split(".")[0] : value;
2466 },
2467 /**
2468 * @param {string} value
2469 * @return {?}
2470 */
2471 trim: function(value) {
2472 return value.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
2473 }
2474 };
2475 var mapper = {
2476 /**
2477 * @return {?}
2478 */
2479 rgx: function() {
2480 var numNodesProcessed;
2481 var resLength;
2482 var i;
2483 var q;
2484 var res;
2485 var match;
2486 var result = {};
2487 /** @type {number} */
2488 var j = 0;
2489 /** @type {Arguments} */
2490 var b = arguments;
2491 /** @type {number} */
2492 i = 0;
2493 for (; i < b[1].length; i++) {
2494 q = b[1][i];
2495 /** @type {string} */
2496 result[typeof q === OBJ_TYPE ? q[0] : q] = value;
2497 }
2498 for (; j < b.length && !res;) {
2499 var nodeList = b[j];
2500 var codeSegments = b[j + 1];
2501 /** @type {number} */
2502 numNodesProcessed = resLength = 0;
2503 for (; numNodesProcessed < nodeList.length && !res;) {
2504 if (res = nodeList[numNodesProcessed++].exec(this.getUA())) {
2505 /** @type {number} */
2506 i = 0;
2507 for (; i < codeSegments.length; i++) {
2508 match = res[++resLength];
2509 q = codeSegments[i];
2510 if (typeof q === OBJ_TYPE && q.length > 0) {
2511 if (2 == q.length) {
2512 if (typeof q[1] == FUNC_TYPE) {
2513 result[q[0]] = q[1].call(this, match);
2514 } else {
2515 result[q[0]] = q[1];
2516 }
2517 } else {
2518 if (3 == q.length) {
2519 if (typeof q[1] !== FUNC_TYPE || q[1].exec && q[1].test) {
2520 result[q[0]] = match ? match.replace(q[1], q[2]) : value;
2521 } else {
2522 result[q[0]] = match ? q[1].call(this, match, q[2]) : value;
2523 }
2524 } else {
2525 if (4 == q.length) {
2526 result[q[0]] = match ? q[3].call(this, match.replace(q[1], q[2])) : value;
2527 }
2528 }
2529 }
2530 } else {
2531 result[q] = match || value;
2532 }
2533 }
2534 }
2535 }
2536 j += 2;
2537 }
2538 return result;
2539 },
2540 /**
2541 * @param {Object} s
2542 * @param {Object} map
2543 * @return {?}
2544 */
2545 str: function(s, map) {
2546 var type;
2547 for (type in map) {
2548 if (typeof map[type] === OBJ_TYPE && map[type].length > 0) {
2549 /** @type {number} */
2550 var j = 0;
2551 for (; j < map[type].length; j++) {
2552 if (util.has(map[type][j], s)) {
2553 return type === string ? value : type;
2554 }
2555 }
2556 } else {
2557 if (util.has(map[type], s)) {
2558 return type === string ? value : type;
2559 }
2560 }
2561 }
2562 return s;
2563 }
2564 };
2565 var maps = {
2566 browser: {
2567 oldsafari: {
2568 version: {
2569 "1.0": "/8",
2570 "1.2": "/1",
2571 "1.3": "/3",
2572 "2.0": "/412",
2573 "2.0.2": "/416",
2574 "2.0.3": "/417",
2575 "2.0.4": "/419",
2576 "?": "/"
2577 }
2578 }
2579 },
2580 device: {
2581 amazon: {
2582 model: {
2583 "Fire Phone": ["SD", "KF"]
2584 }
2585 },
2586 sprint: {
2587 model: {
2588 "Evo Shift 4G": "7373KT"
2589 },
2590 vendor: {
2591 HTC: "APA",
2592 Sprint: "Sprint"
2593 }
2594 }
2595 },
2596 os: {
2597 windows: {
2598 version: {
2599 ME: "4.90",
2600 "NT 3.11": "NT3.51",
2601 "NT 4.0": "NT4.0",
2602 2E3: "NT 5.0",
2603 XP: ["NT 5.1", "NT 5.2"],
2604 Vista: "NT 6.0",
2605 7: "NT 6.1",
2606 8: "NT 6.2",
2607 "8.1": "NT 6.3",
2608 10: ["NT 6.4", "NT 10.0"],
2609 RT: "ARM"
2610 }
2611 }
2612 }
2613 };
2614 var ret = {
2615 browser: [
2616 [/(opera\smini)\/([\w\.-]+)/i, /(opera\s[mobiletab]+).+version\/([\w\.-]+)/i, /(opera).+version\/([\w\.]+)/i, /(opera)[\/\s]+([\w\.]+)/i],
2617 [info, VERSION],
2618 [/(opios)[\/\s]+([\w\.]+)/i],
2619 [
2620 [info, "Opera Mini"], VERSION
2621 ],
2622 [/\s(opr)\/([\w\.]+)/i],
2623 [
2624 [info, "Opera"], VERSION
2625 ],
2626 [/(kindle)\/([\w\.]+)/i, /(lunascape|maxthon|netfront|jasmine|blazer)[\/\s]?([\w\.]+)*/i, /(avant\s|iemobile|slim|baidu)(?:browser)?[\/\s]?([\w\.]*)/i, /(?:ms|\()(ie)\s([\w\.]+)/i, /(rekonq)\/([\w\.]+)*/i, /(chromium|flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs)\/([\w\.-]+)/i],
2627 [info, VERSION],
2628 [/(trident).+rv[:\s]([\w\.]+).+like\sgecko/i],
2629 [
2630 [info, "IE"], VERSION
2631 ],
2632 [/(edge)\/((\d+)?[\w\.]+)/i],
2633 [info, VERSION],
2634 [/(yabrowser)\/([\w\.]+)/i],
2635 [
2636 [info, "Yandex"], VERSION
2637 ],
2638 [/(comodo_dragon)\/([\w\.]+)/i],
2639 [
2640 [info, /_/g, " "], VERSION
2641 ],
2642 [/(micromessenger)\/([\w\.]+)/i],
2643 [
2644 [info, "WeChat"], VERSION
2645 ],
2646 [/xiaomi\/miuibrowser\/([\w\.]+)/i],
2647 [VERSION, [info, "MIUI Browser"]],
2648 [/\swv\).+(chrome)\/([\w\.]+)/i],
2649 [
2650 [info, /(.+)/, "$1 WebView"], VERSION
2651 ],
2652 [/android.+samsungbrowser\/([\w\.]+)/i,
2653 /android.+version\/([\w\.]+)\s+(?:mobile\s?safari|safari)*/i
2654 ],
2655 [VERSION, [info, "Android Browser"]],
2656 [/(chrome|omniweb|arora|[tizenoka]{5}\s?browser)\/v?([\w\.]+)/i, /(qqbrowser)[\/\s]?([\w\.]+)/i],
2657 [info, VERSION],
2658 [/(uc\s?browser)[\/\s]?([\w\.]+)/i, /ucweb.+(ucbrowser)[\/\s]?([\w\.]+)/i, /juc.+(ucweb)[\/\s]?([\w\.]+)/i],
2659 [
2660 [info, "UCBrowser"], VERSION
2661 ],
2662 [/(dolfin)\/([\w\.]+)/i],
2663 [
2664 [info, "Dolphin"], VERSION
2665 ],
2666 [/((?:android.+)crmo|crios)\/([\w\.]+)/i],
2667 [
2668 [info, "Chrome"], VERSION
2669 ],
2670 [/;fbav\/([\w\.]+);/i],
2671 [VERSION, [info, "Facebook"]],
2672 [/fxios\/([\w\.-]+)/i],
2673 [VERSION, [info, "Firefox"]],
2674 [/version\/([\w\.]+).+?mobile\/\w+\s(safari)/i],
2675 [VERSION, [info, "Mobile Safari"]],
2676 [/version\/([\w\.]+).+?(mobile\s?safari|safari)/i],
2677 [VERSION, info],
2678 [/webkit.+?(mobile\s?safari|safari)(\/[\w\.]+)/i],
2679 [info, [VERSION, mapper.str, maps.browser.oldsafari.version]],
2680 [/(konqueror)\/([\w\.]+)/i, /(webkit|khtml)\/([\w\.]+)/i],
2681 [info, VERSION],
2682 [/(navigator|netscape)\/([\w\.-]+)/i],
2683 [
2684 [info, "Netscape"], VERSION
2685 ],
2686 [/(swiftfox)/i, /(icedragon|iceweasel|camino|chimera|fennec|maemo\sbrowser|minimo|conkeror)[\/\s]?([\w\.\+]+)/i, /(firefox|seamonkey|k-meleon|icecat|iceape|firebird|phoenix)\/([\w\.-]+)/i, /(mozilla)\/([\w\.]+).+rv\:.+gecko\/\d+/i, /(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir)[\/\s]?([\w\.]+)/i, /(links)\s\(([\w\.]+)/i, /(gobrowser)\/?([\w\.]+)*/i, /(ice\s?browser)\/v?([\w\._]+)/i, /(mosaic)[\/\s]([\w\.]+)/i],
2687 [info, VERSION]
2688 ],
2689 cpu: [
2690 [/(?:(amd|x(?:(?:86|64)[_-])?|wow|win)64)[;\)]/i],
2691 [
2692 [ARCHITECTURE, "amd64"]
2693 ],
2694 [/(ia32(?=;))/i],
2695 [
2696 [ARCHITECTURE, util.lowerize]
2697 ],
2698 [/((?:i[346]|x)86)[;\)]/i],
2699 [
2700 [ARCHITECTURE, "ia32"]
2701 ],
2702 [/windows\s(ce|mobile);\sppc;/i],
2703 [
2704 [ARCHITECTURE, "arm"]
2705 ],
2706 [/((?:ppc|powerpc)(?:64)?)(?:\smac|;|\))/i],
2707 [
2708 [ARCHITECTURE, /ower/, "", util.lowerize]
2709 ],
2710 [/(sun4\w)[;\)]/i],
2711 [
2712 [ARCHITECTURE, "sparc"]
2713 ],
2714 [/((?:avr32|ia64(?=;))|68k(?=\))|arm(?:64|(?=v\d+;))|(?=atmel\s)avr|(?:irix|mips|sparc)(?:64)?(?=;)|pa-risc)/i],
2715 [
2716 [ARCHITECTURE, util.lowerize]
2717 ]
2718 ],
2719 device: [
2720 [/\((ipad|playbook);[\w\s\);-]+(rim|apple)/i],
2721 [attrs, VENDOR, [t, TABLET]],
2722 [/applecoremedia\/[\w\.]+ \((ipad)/],
2723 [attrs, [VENDOR, "Apple"],
2724 [t, TABLET]
2725 ],
2726 [/(apple\s{0,1}tv)/i],
2727 [
2728 [attrs, "Apple TV"],
2729 [VENDOR, "Apple"]
2730 ],
2731 [/(archos)\s(gamepad2?)/i, /(hp).+(touchpad)/i, /(hp).+(tablet)/i, /(kindle)\/([\w\.]+)/i, /\s(nook)[\w\s]+build\/(\w+)/i, /(dell)\s(strea[kpr\s\d]*[\dko])/i],
2732 [VENDOR, attrs, [t, TABLET]],
2733 [/(kf[A-z]+)\sbuild\/[\w\.]+.*silk\//i],
2734 [attrs, [VENDOR, "Amazon"],
2735 [t, TABLET]
2736 ],
2737 [/(sd|kf)[0349hijorstuw]+\sbuild\/[\w\.]+.*silk\//i],
2738 [
2739 [attrs, mapper.str, maps.device.amazon.model],
2740 [VENDOR, "Amazon"],
2741 [t, MOBILE]
2742 ],
2743 [/\((ip[honed|\s\w*]+);.+(apple)/i],
2744 [attrs, VENDOR, [t, MOBILE]],
2745 [/\((ip[honed|\s\w*]+);/i],
2746 [attrs, [VENDOR, "Apple"],
2747 [t, MOBILE]
2748 ],
2749 [/(blackberry)[\s-]?(\w+)/i, /(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|huawei|meizu|motorola|polytron)[\s_-]?([\w-]+)*/i, /(hp)\s([\w\s]+\w)/i, /(asus)-?(\w+)/i],
2750 [VENDOR, attrs, [t, MOBILE]],
2751 [/\(bb10;\s(\w+)/i],
2752 [attrs, [VENDOR, "BlackBerry"],
2753 [t, MOBILE]
2754 ],
2755 [/android.+(transfo[prime\s]{4,10}\s\w+|eeepc|slider\s\w+|nexus 7|padfone)/i],
2756 [attrs, [VENDOR, "Asus"],
2757 [t, TABLET]
2758 ],
2759 [/(sony)\s(tablet\s[ps])\sbuild\//i, /(sony)?(?:sgp.+)\sbuild\//i],
2760 [
2761 [VENDOR, "Sony"],
2762 [attrs, "Xperia Tablet"],
2763 [t, TABLET]
2764 ],
2765 [/(?:sony)?(?:(?:(?:c|d)\d{4})|(?:so[-l].+))\sbuild\//i],
2766 [
2767 [VENDOR, "Sony"],
2768 [attrs, "Xperia Phone"],
2769 [t, MOBILE]
2770 ],
2771 [/\s(ouya)\s/i, /(nintendo)\s([wids3u]+)/i],
2772 [VENDOR, attrs, [t, CONSOLE]],
2773 [/android.+;\s(shield)\sbuild/i],
2774 [attrs, [VENDOR, "Nvidia"],
2775 [t, CONSOLE]
2776 ],
2777 [/(playstation\s[34portablevi]+)/i],
2778 [attrs, [VENDOR, "Sony"],
2779 [t, CONSOLE]
2780 ],
2781 [/(sprint\s(\w+))/i],
2782 [
2783 [VENDOR, mapper.str, maps.device.sprint.vendor],
2784 [attrs, mapper.str, maps.device.sprint.model],
2785 [t, MOBILE]
2786 ],
2787 [/(lenovo)\s?(S(?:5000|6000)+(?:[-][\w+]))/i],
2788 [VENDOR, attrs, [t, TABLET]],
2789 [/(htc)[;_\s-]+([\w\s]+(?=\))|\w+)*/i, /(zte)-(\w+)*/i, /(alcatel|geeksphone|huawei|lenovo|nexian|panasonic|(?=;\s)sony)[_\s-]?([\w-]+)*/i],
2790 [VENDOR, [attrs, /_/g, " "],
2791 [t, MOBILE]
2792 ],
2793 [/(nexus\s9)/i],
2794 [attrs, [VENDOR, "HTC"],
2795 [t, TABLET]
2796 ],
2797 [/(nexus\s6p)/i],
2798 [attrs, [VENDOR, "Huawei"],
2799 [t, MOBILE]
2800 ],
2801 [/(microsoft);\s(lumia[\s\w]+)/i],
2802 [VENDOR, attrs, [t, MOBILE]],
2803 [/[\s\(;](xbox(?:\sone)?)[\s\);]/i],
2804 [attrs, [VENDOR, "Microsoft"],
2805 [t, CONSOLE]
2806 ],
2807 [/(kin\.[onetw]{3})/i],
2808 [
2809 [attrs, /\./g, " "],
2810 [VENDOR, "Microsoft"],
2811 [t, MOBILE]
2812 ],
2813 [/\s(milestone|droid(?:[2-4x]|\s(?:bionic|x2|pro|razr))?(:?\s4g)?)[\w\s]+build\//i, /mot[\s-]?(\w+)*/i, /(XT\d{3,4}) build\//i, /(nexus\s6)/i],
2814 [attrs, [VENDOR, "Motorola"],
2815 [t, MOBILE]
2816 ],
2817 [/android.+\s(mz60\d|xoom[\s2]{0,2})\sbuild\//i],
2818 [attrs, [VENDOR, "Motorola"],
2819 [t, TABLET]
2820 ],
2821 [/hbbtv\/\d+\.\d+\.\d+\s+\([\w\s]*;\s*(\w[^;]*);([^;]*)/i],
2822 [
2823 [VENDOR, util.trim],
2824 [attrs, util.trim],
2825 [t, SMARTTV]
2826 ],
2827 [/hbbtv.+maple;(\d+)/i],
2828 [
2829 [attrs, /^/, "SmartTV"],
2830 [VENDOR, "Samsung"],
2831 [t, SMARTTV]
2832 ],
2833 [/\(dtv[\);].+(aquos)/i],
2834 [attrs, [VENDOR, "Sharp"],
2835 [t, SMARTTV]
2836 ],
2837 [/android.+((sch-i[89]0\d|shw-m380s|gt-p\d{4}|gt-n\d+|sgh-t8[56]9|nexus 10))/i, /((SM-T\w+))/i],
2838 [
2839 [VENDOR, "Samsung"], attrs, [t, TABLET]
2840 ],
2841 [/smart-tv.+(samsung)/i],
2842 [VENDOR, [t, SMARTTV], attrs],
2843 [/((s[cgp]h-\w+|gt-\w+|galaxy\snexus|sm-\w[\w\d]+))/i, /(sam[sung]*)[\s-]*(\w+-?[\w-]*)*/i, /sec-((sgh\w+))/i],
2844 [
2845 [VENDOR, "Samsung"], attrs, [t, MOBILE]
2846 ],
2847 [/sie-(\w+)*/i],
2848 [attrs, [VENDOR, "Siemens"],
2849 [t, MOBILE]
2850 ],
2851 [/(maemo|nokia).*(n900|lumia\s\d+)/i, /(nokia)[\s_-]?([\w-]+)*/i],
2852 [
2853 [VENDOR, "Nokia"], attrs, [t, MOBILE]
2854 ],
2855 [/android\s3\.[\s\w;-]{10}(a\d{3})/i],
2856 [attrs, [VENDOR, "Acer"],
2857 [t, TABLET]
2858 ],
2859 [/android\s3\.[\s\w;-]{10}(lg?)-([06cv9]{3,4})/i],
2860 [
2861 [VENDOR, "LG"], attrs, [t, TABLET]
2862 ],
2863 [/(lg) netcast\.tv/i],
2864 [VENDOR, attrs, [t, SMARTTV]],
2865 [/(nexus\s[45])/i, /lg[e;\s\/-]+(\w+)*/i],
2866 [attrs, [VENDOR, "LG"],
2867 [t, MOBILE]
2868 ],
2869 [/android.+(ideatab[a-z0-9\-\s]+)/i],
2870 [attrs, [VENDOR, "Lenovo"],
2871 [t, TABLET]
2872 ],
2873 [/linux;.+((jolla));/i],
2874 [VENDOR, attrs, [t, MOBILE]],
2875 [/((pebble))app\/[\d\.]+\s/i],
2876 [VENDOR, attrs, [t, WEARABLE]],
2877 [/android.+;\s(glass)\s\d/i],
2878 [attrs, [VENDOR, "Google"],
2879 [t, WEARABLE]
2880 ],
2881 [/android.+;\s(pixel c)\s/i],
2882 [attrs, [VENDOR, "Google"],
2883 [t, TABLET]
2884 ],
2885 [/android.+;\s(pixel xl|pixel)\s/i],
2886 [attrs, [VENDOR, "Google"],
2887 [t, MOBILE]
2888 ],
2889 [/android.+(\w+)\s+build\/hm\1/i, /android.+(hm[\s\-_]*note?[\s_]*(?:\d\w)?)\s+build/i, /android.+(mi[\s\-_]*(?:one|one[\s_]plus|note lte)?[\s_]*(?:\d\w)?)\s+build/i],
2890 [
2891 [attrs, /_/g, " "],
2892 [VENDOR, "Xiaomi"],
2893 [t, MOBILE]
2894 ],
2895 [/android.+a000(1)\s+build/i],
2896 [attrs, [VENDOR, "OnePlus"],
2897 [t, MOBILE]
2898 ],
2899 [/\s(tablet)[;\/]/i, /\s(mobile)(?:[;\/]|\ssafari)/i],
2900 [
2901 [t, util.lowerize], VENDOR,
2902 attrs
2903 ]
2904 ],
2905 engine: [
2906 [/windows.+\sedge\/([\w\.]+)/i],
2907 [VERSION, [info, "EdgeHTML"]],
2908 [/(presto)\/([\w\.]+)/i, /(webkit|trident|netfront|netsurf|amaya|lynx|w3m)\/([\w\.]+)/i, /(khtml|tasman|links)[\/\s]\(?([\w\.]+)/i, /(icab)[\/\s]([23]\.[\d\.]+)/i],
2909 [info, VERSION],
2910 [/rv\:([\w\.]+).*(gecko)/i],
2911 [VERSION, info]
2912 ],
2913 os: [
2914 [/microsoft\s(windows)\s(vista|xp)/i],
2915 [info, VERSION],
2916 [/(windows)\snt\s6\.2;\s(arm)/i, /(windows\sphone(?:\sos)*)[\s\/]?([\d\.\s]+\w)*/i, /(windows\smobile|windows)[\s\/]?([ntce\d\.\s]+\w)/i],
2917 [info, [VERSION, mapper.str, maps.os.windows.version]],
2918 [/(win(?=3|9|n)|win\s9x\s)([nt\d\.]+)/i],
2919 [
2920 [info, "Windows"],
2921 [VERSION, mapper.str, maps.os.windows.version]
2922 ],
2923 [/\((bb)(10);/i],
2924 [
2925 [info, "BlackBerry"], VERSION
2926 ],
2927 [/(blackberry)\w*\/?([\w\.]+)*/i, /(tizen)[\/\s]([\w\.]+)/i, /(android|webos|palm\sos|qnx|bada|rim\stablet\sos|meego|contiki)[\/\s-]?([\w\.]+)*/i,
2928 /linux;.+(sailfish);/i
2929 ],
2930 [info, VERSION],
2931 [/(symbian\s?os|symbos|s60(?=;))[\/\s-]?([\w\.]+)*/i],
2932 [
2933 [info, "Symbian"], VERSION
2934 ],
2935 [/\((series40);/i],
2936 [info],
2937 [/mozilla.+\(mobile;.+gecko.+firefox/i],
2938 [
2939 [info, "Firefox OS"], VERSION
2940 ],
2941 [/(nintendo|playstation)\s([wids34portablevu]+)/i, /(mint)[\/\s\(]?(\w+)*/i, /(mageia|vectorlinux)[;\s]/i, /(joli|[kxln]?ubuntu|debian|[open]*suse|gentoo|(?=\s)arch|slackware|fedora|mandriva|centos|pclinuxos|redhat|zenwalk|linpus)[\/\s-]?(?!chrom)([\w\.-]+)*/i, /(hurd|linux)\s?([\w\.]+)*/i,
2942 /(gnu)\s?([\w\.]+)*/i
2943 ],
2944 [info, VERSION],
2945 [/(cros)\s[\w]+\s([\w\.]+\w)/i],
2946 [
2947 [info, "Chromium OS"], VERSION
2948 ],
2949 [/(sunos)\s?([\w\.]+\d)*/i],
2950 [
2951 [info, "Solaris"], VERSION
2952 ],
2953 [/\s([frentopc-]{0,4}bsd|dragonfly)\s?([\w\.]+)*/i],
2954 [info, VERSION],
2955 [/(haiku)\s(\w+)/i],
2956 [info, VERSION],
2957 [/(ip[honead]+)(?:.*os\s([\w]+)*\slike\smac|;\sopera)/i],
2958 [
2959 [info, "iOS"],
2960 [VERSION, /_/g, "."]
2961 ],
2962 [/(mac\sos\sx)\s?([\w\s\.]+\w)*/i, /(macintosh|mac(?=_powerpc)\s)/i],
2963 [
2964 [info, "Mac OS"],
2965 [VERSION, /_/g, "."]
2966 ],
2967 [/((?:open)?solaris)[\/\s-]?([\w\.]+)*/i,
2968 /(aix)\s((\d)(?=\.|\)|\s)[\w\.]*)*/i, /(plan\s9|minix|beos|os\/2|amigaos|morphos|risc\sos|openvms)/i, /(unix)\s?([\w\.]+)*/i
2969 ],
2970 [info, VERSION]
2971 ]
2972 };
2973 /**
2974 * @param {string} uastring
2975 * @param {string} item
2976 * @return {?}
2977 */
2978 var UAParser = function(uastring, item) {
2979 if (!(this instanceof UAParser)) {
2980 return (new UAParser(uastring, item)).getResult();
2981 }
2982 var ua = uastring || (root && (root.navigator && root.navigator.userAgent) ? root.navigator.userAgent : EMPTY);
2983 var data = item ? util.extend(ret, item) : ret;
2984 return this.getBrowser = function() {
2985 var self = mapper.rgx.apply(this, data.browser);
2986 return self.major = util.major(self.version), self;
2987 }, this.getCPU = function() {
2988 return mapper.rgx.apply(this, data.cpu);
2989 }, this.getDevice = function() {
2990 return mapper.rgx.apply(this, data.device);
2991 }, this.getEngine = function() {
2992 return mapper.rgx.apply(this, data.engine);
2993 }, this.getOS = function() {
2994 return mapper.rgx.apply(this, data.os);
2995 }, this.getResult = function() {
2996 return {
2997 ua: this.getUA(),
2998 browser: this.getBrowser(),
2999 engine: this.getEngine(),
3000 os: this.getOS(),
3001 device: this.getDevice(),
3002 cpu: this.getCPU()
3003 };
3004 }, this.getUA = function() {
3005 return ua;
3006 }, this.setUA = function(dataAndEvents) {
3007 return ua = dataAndEvents, this;
3008 }, this;
3009 };
3010 /** @type {string} */
3011 UAParser.VERSION = "0.7.12";
3012 UAParser.BROWSER = {
3013 NAME: info,
3014 MAJOR: "major",
3015 VERSION: VERSION
3016 };
3017 UAParser.CPU = {
3018 ARCHITECTURE: ARCHITECTURE
3019 };
3020 UAParser.DEVICE = {
3021 MODEL: attrs,
3022 VENDOR: VENDOR,
3023 TYPE: t,
3024 CONSOLE: CONSOLE,
3025 MOBILE: MOBILE,
3026 SMARTTV: SMARTTV,
3027 TABLET: TABLET,
3028 WEARABLE: WEARABLE,
3029 EMBEDDED: "embedded"
3030 };
3031 UAParser.ENGINE = {
3032 NAME: info,
3033 VERSION: VERSION
3034 };
3035 UAParser.OS = {
3036 NAME: info,
3037 VERSION: VERSION
3038 };
3039 if (typeof exports !== UNDEF_TYPE) {
3040 if (typeof module !== UNDEF_TYPE) {
3041 if (module.exports) {
3042 /** @type {function (string, string): ?} */
3043 exports = module.exports = UAParser;
3044 }
3045 }
3046 /** @type {function (string, string): ?} */
3047 exports.UAParser = UAParser;
3048 } else {
3049 if (typeof define === FUNC_TYPE && define.amd) {
3050 define(function() {
3051 return UAParser;
3052 });
3053 } else {
3054 /** @type {function (string, string): ?} */
3055 root.UAParser = UAParser;
3056 }
3057 }
3058 var self = root.jQuery || root.Zepto;
3059 if (typeof self !== UNDEF_TYPE) {
3060 var parser = new UAParser;
3061 self.ua = parser.getResult();
3062 /**
3063 * @return {?}
3064 */
3065 self.ua.get = function() {
3066 return parser.getUA();
3067 };
3068 /**
3069 * @param {string} node
3070 * @return {undefined}
3071 */
3072 self.ua.set = function(node) {
3073 parser.setUA(node);
3074 var iterable = parser.getResult();
3075 var key;
3076 for (key in iterable) {
3077 self.ua[key] = iterable[key];
3078 }
3079 };
3080 }
3081 }("object" == typeof window ? window : this),
3082 function($) {
3083 /**
3084 * @param {?} data
3085 * @return {?}
3086 */
3087 $.fn.idle = function(data) {
3088 var fn;
3089 var call;
3090 var config = {
3091 idle: 6E4,
3092 events: "mousemove keydown mousedown touchstart",
3093 /**
3094 * @return {undefined}
3095 */
3096 onIdle: function() {},
3097 /**
3098 * @return {undefined}
3099 */
3100 onActive: function() {},
3101 /**
3102 * @return {undefined}
3103 */
3104 onHide: function() {},
3105 /**
3106 * @return {undefined}
3107 */
3108 onShow: function() {},
3109 keepTracking: true,
3110 startAtIdle: false,
3111 recurIdleCall: false
3112 };
3113 var o = data.startAtIdle || false;
3114 /** @type {boolean} */
3115 var a = !data.startAtIdle || true;
3116 var conf = $.extend({}, config, data);
3117 /** @type {null} */
3118 var form = null;
3119 return $(this).on("idle:stop", {}, function() {
3120 $(this).off(conf.events);
3121 /** @type {boolean} */
3122 conf.keepTracking = false;
3123 fn(form, conf);
3124 }), fn = function(t, callbacks) {
3125 if (o && (o = false, callbacks.onActive.call()), clearTimeout(t), callbacks.keepTracking) {
3126 return call(callbacks);
3127 }
3128 }, call = function(options) {
3129 /** @type {function ((Function|null|string), number): number} */
3130 var timer_func = options.recurIdleCall ? setInterval : setTimeout;
3131 return timer_func(function() {
3132 /** @type {boolean} */
3133 o = true;
3134 options.onIdle.call();
3135 }, options.idle);
3136 }, this.each(function() {
3137 form = call(conf);
3138 $(this).on(conf.events, function() {
3139 form = fn(form, conf);
3140 });
3141 if (conf.onShow || conf.onHide) {
3142 $(document).on("visibilitychange webkitvisibilitychange mozvisibilitychange msvisibilitychange", function() {
3143 if (document.hidden || (document.webkitHidden || (document.mozHidden || document.msHidden))) {
3144 if (a) {
3145 /** @type {boolean} */
3146 a = false;
3147 conf.onHide.call();
3148 }
3149 } else {
3150 if (!a) {
3151 /** @type {boolean} */
3152 a = true;
3153 conf.onShow.call();
3154 }
3155 }
3156 });
3157 }
3158 });
3159 };
3160 }(jQuery),
3161 function($) {
3162 $.ajaxPrefilter(function(a) {
3163 if (a.iframe) {
3164 return "iframe";
3165 }
3166 });
3167 $.ajaxTransport("iframe", function(options, dataAndEvents, o) {
3168 /**
3169 * @return {undefined}
3170 */
3171 function destroy() {
3172 tabs.each(function(i) {
3173 $(this).replaceWith(hidden[i]);
3174 tabs.splice(i, 1);
3175 });
3176 form.remove();
3177 iframe.bind("load", function() {
3178 iframe.remove();
3179 });
3180 iframe.attr("src", "about:blank");
3181 }
3182 var imgSrc;
3183 /** @type {null} */
3184 var form = null;
3185 /** @type {null} */
3186 var iframe = null;
3187 var name = "iframe-" + $.now();
3188 var hidden = $(options.files).filter(":file:enabled");
3189 /** @type {null} */
3190 var tabs = null;
3191 if (options.dataTypes.shift(), hidden.length) {
3192 return form = $("<form enctype='multipart/form-data' method='post'></form>").hide().attr({
3193 action: options.url,
3194 target: name
3195 }), "string" == typeof options.data && (options.data.length > 0 && $.error("data must not be serialized")), $.each(options.data || {}, function(name, option) {
3196 if ($.isPlainObject(option)) {
3197 name = option.name;
3198 option = option.value;
3199 }
3200 $("<input type='hidden' />").attr({
3201 name: name,
3202 value: option
3203 }).appendTo(form);
3204 }), $("<input type='hidden' value='IFrame' name='X-Requested-With' />").appendTo(form), imgSrc = options.dataTypes[0] && options.accepts[options.dataTypes[0]] ? options.accepts[options.dataTypes[0]] + ("*" !== options.dataTypes[0] ? ", */*; q=0.01" : "") : options.accepts["*"], $("<input type='hidden' name='X-Http-Accept'>").attr("value", imgSrc).appendTo(form), tabs = hidden.after(function() {
3205 return $(this).clone().prop("disabled", true);
3206 }).next(), hidden.appendTo(form), {
3207 /**
3208 * @param {?} opt_noCache
3209 * @param {?} completeCallback
3210 * @return {undefined}
3211 */
3212 send: function(opt_noCache, completeCallback) {
3213 iframe = $("<iframe src='about:blank' name='" + name + "' id='" + name + "' style='display:none'></iframe>");
3214 iframe.bind("load", function() {
3215 iframe.unbind("load").bind("load", function() {
3216 var doc = this.contentWindow ? this.contentWindow.document : this.contentDocument ? this.contentDocument : this.document;
3217 var root = doc.documentElement ? doc.documentElement : doc.body;
3218 var textarea = root.getElementsByTagName("textarea")[0];
3219 var type = textarea && textarea.getAttribute("data-type") || null;
3220 var r20 = textarea && textarea.getAttribute("data-status") || 200;
3221 var statusText = textarea && textarea.getAttribute("data-statusText") || "OK";
3222 var defaults = {
3223 html: root.innerHTML,
3224 text: type ? textarea.value : root ? root.textContent || root.innerText : null
3225 };
3226 destroy();
3227 if (!o.responseText) {
3228 o.responseText = defaults.text;
3229 }
3230 completeCallback(r20, statusText, defaults, type ? "Content-Type: " + type : null);
3231 });
3232 form[0].submit();
3233 });
3234 $("body").append(form, iframe);
3235 },
3236 /**
3237 * @return {undefined}
3238 */
3239 abort: function() {
3240 if (null !== iframe) {
3241 iframe.unbind("load").attr("src", "javascript:false;");
3242 destroy();
3243 }
3244 }
3245 };
3246 }
3247 });
3248 }(jQuery),
3249 function($) {
3250 var options;
3251 $.remotipart = options = {
3252 /**
3253 * @param {Object} el
3254 * @return {undefined}
3255 */
3256 setup: function(el) {
3257 var attributes = el.data("ujs:submit-button");
3258 var csrf_param = $('meta[name="csrf-param"]').attr("content");
3259 var param = $('meta[name="csrf-token"]').attr("content");
3260 var cnl = el.find('input[name="' + csrf_param + '"]').length;
3261 el.one("ajax:beforeSend.remotipart", function(dataAndEvents, inWhy, settings) {
3262 return delete settings.beforeSend, settings.iframe = true, settings.files = $($.rails.fileInputSelector, el), settings.data = el.serializeArray(), attributes && settings.data.push(attributes), settings.files.each(function(dataAndEvents, cookie) {
3263 /** @type {number} */
3264 var a = settings.data.length - 1;
3265 for (; a >= 0; a--) {
3266 if (settings.data[a].name == cookie.name) {
3267 settings.data.splice(a, 1);
3268 }
3269 }
3270 }), settings.processData = false, settings.dataType === undefined && (settings.dataType = "script *"), settings.data.push({
3271 name: "remotipart_submitted",
3272 value: true
3273 }), param && (csrf_param && (!cnl && settings.data.push({
3274 name: csrf_param,
3275 value: param
3276 }))), $.rails.fire(el, "ajax:remotipartSubmit", [inWhy, settings]) && ($.rails.ajax(settings).complete(function(inWhy) {
3277 $.rails.fire(el, "ajax:remotipartComplete", [inWhy]);
3278 }), setTimeout(function() {
3279 $.rails.disableFormElements(el);
3280 }, 20)), options.teardown(el), false;
3281 }).data("remotipartSubmitted", true);
3282 },
3283 /**
3284 * @param {Object} el
3285 * @return {undefined}
3286 */
3287 teardown: function(el) {
3288 el.unbind("ajax:beforeSend.remotipart").removeData("remotipartSubmitted");
3289 }
3290 };
3291 $(document).on("ajax:aborted:file", "form", function() {
3292 var target = $(this);
3293 return options.setup(target), $.rails.handleRemote(target), false;
3294 });
3295 }(jQuery),
3296 function($) {
3297 /**
3298 * @param {?} selector
3299 * @return {?}
3300 */
3301 function remove(selector) {
3302 return $(selector).filter(function() {
3303 return $(this).is(":appeared");
3304 });
3305 }
3306 /**
3307 * @return {undefined}
3308 */
3309 function process() {
3310 /** @type {boolean} */
3311 a = false;
3312 /** @type {number} */
3313 var i = 0;
3314 /** @type {number} */
3315 var valuesLen = configList.length;
3316 for (; i < valuesLen; i++) {
3317 var $appeared = remove(configList[i]);
3318 if ($appeared.trigger("appear", [$appeared]), oSpace[i]) {
3319 var $disappeared = oSpace[i].not($appeared);
3320 $disappeared.trigger("disappear", [$disappeared]);
3321 }
3322 oSpace[i] = $appeared;
3323 }
3324 }
3325 /**
3326 * @param {?} attributes
3327 * @return {undefined}
3328 */
3329 function make(attributes) {
3330 configList.push(attributes);
3331 oSpace.push();
3332 }
3333 /** @type {Array} */
3334 var configList = [];
3335 /** @type {boolean} */
3336 var o = false;
3337 /** @type {boolean} */
3338 var a = false;
3339 var defaults = {
3340 interval: 250,
3341 force_process: false
3342 };
3343 var $win = $(window);
3344 /** @type {Array} */
3345 var oSpace = [];
3346 /**
3347 * @param {?} element
3348 * @return {?}
3349 */
3350 $.expr[":"].appeared = function(element) {
3351 var $element = $(element);
3352 if (!$element.is(":visible")) {
3353 return false;
3354 }
3355 var window_left = $win.scrollLeft();
3356 var window_top = $win.scrollTop();
3357 var iframeXY = $element.offset();
3358 var left = iframeXY.left;
3359 var top = iframeXY.top;
3360 return top + $element.height() >= window_top && (top - ($element.data("appear-top-offset") || 0) <= window_top + $win.height() && (left + $element.width() >= window_left && left - ($element.data("appear-left-offset") || 0) <= window_left + $win.width()));
3361 };
3362 $.fn.extend({
3363 /**
3364 * @param {Object} options
3365 * @return {?}
3366 */
3367 appear: function(options) {
3368 var opts = $.extend({}, defaults, options || {});
3369 var hash = this.selector || this;
3370 if (!o) {
3371 /**
3372 * @return {undefined}
3373 */
3374 var on_check = function() {
3375 if (!a) {
3376 /** @type {boolean} */
3377 a = true;
3378 setTimeout(process, opts.interval);
3379 }
3380 };
3381 $(window).load(on_check).scroll(on_check).resize(on_check);
3382 /** @type {boolean} */
3383 o = true;
3384 }
3385 return opts.force_process && setTimeout(process, opts.interval), make(hash), $(hash);
3386 }
3387 });
3388 $.extend({
3389 /**
3390 * @return {?}
3391 */
3392 force_appear: function() {
3393 return !!o && (process(), true);
3394 }
3395 });
3396 }(function() {
3397 return "undefined" != typeof module ? require("jquery") : jQuery;
3398 }()),
3399 function(factory) {
3400 if ("function" == typeof define && define.amd) {
3401 define(["jquery"], factory);
3402 } else {
3403 if ("object" == typeof exports) {
3404 module.exports = factory(require("jquery"));
3405 } else {
3406 factory(jQuery);
3407 }
3408 }
3409 }(function($) {
3410 /**
3411 * @return {?}
3412 */
3413 function getViewportSize() {
3414 var CSS1Compat;
3415 var domObject;
3416 var dimensions = {
3417 height: win.innerHeight,
3418 width: win.innerWidth
3419 };
3420 return dimensions.height || (!(CSS1Compat = doc.compatMode) && $.support.boxModel || (domObject = "CSS1Compat" === CSS1Compat ? documentElement : doc.body, dimensions = {
3421 height: domObject.clientHeight,
3422 width: domObject.clientWidth
3423 })), dimensions;
3424 }
3425 /**
3426 * @return {?}
3427 */
3428 function getViewportOffset() {
3429 return {
3430 top: win.pageYOffset || (documentElement.scrollTop || doc.body.scrollTop),
3431 left: win.pageXOffset || (documentElement.scrollLeft || doc.body.scrollLeft)
3432 };
3433 }
3434 /**
3435 * @return {undefined}
3436 */
3437 function checkInView() {
3438 if (data.length) {
3439 /** @type {number} */
3440 var i = 0;
3441 var texts = $.map(data, function(inviewObject) {
3442 var selector = inviewObject.data.selector;
3443 var $element = inviewObject.$element;
3444 return selector ? $element.find(selector) : $element;
3445 });
3446 viewportSize = viewportSize || getViewportSize();
3447 viewportOffset = viewportOffset || getViewportOffset();
3448 for (; i < data.length; i++) {
3449 if ($.contains(documentElement, texts[i][0])) {
3450 var $el = $(texts[i]);
3451 var size = {
3452 height: $el[0].offsetHeight,
3453 width: $el[0].offsetWidth
3454 };
3455 var offset = $el.offset();
3456 var inView = $el.data("inview");
3457 if (!viewportOffset || !viewportSize) {
3458 return;
3459 }
3460 if (offset.top + size.height > viewportOffset.top && (offset.top < viewportOffset.top + viewportSize.height && (offset.left + size.width > viewportOffset.left && offset.left < viewportOffset.left + viewportSize.width))) {
3461 if (!inView) {
3462 $el.data("inview", true).trigger("inview", [true]);
3463 }
3464 } else {
3465 if (inView) {
3466 $el.data("inview", false).trigger("inview", [false]);
3467 }
3468 }
3469 }
3470 }
3471 }
3472 }
3473 var viewportSize;
3474 var viewportOffset;
3475 var scrollIntervalId;
3476 /** @type {Array} */
3477 var data = [];
3478 /** @type {HTMLDocument} */
3479 var doc = document;
3480 /** @type {Window} */
3481 var win = window;
3482 /** @type {Element} */
3483 var documentElement = doc.documentElement;
3484 $.event.special.inview = {
3485 /**
3486 * @param {string} context
3487 * @return {undefined}
3488 */
3489 add: function(context) {
3490 data.push({
3491 data: context,
3492 $element: $(this),
3493 element: this
3494 });
3495 if (!scrollIntervalId) {
3496 if (data.length) {
3497 /** @type {number} */
3498 scrollIntervalId = setInterval(checkInView, 250);
3499 }
3500 }
3501 },
3502 /**
3503 * @param {Object} handleObj
3504 * @return {undefined}
3505 */
3506 remove: function(handleObj) {
3507 /** @type {number} */
3508 var i = 0;
3509 for (; i < data.length; i++) {
3510 var e = data[i];
3511 if (e.element === this && e.data.guid === handleObj.guid) {
3512 data.splice(i, 1);
3513 break;
3514 }
3515 }
3516 if (!data.length) {
3517 clearInterval(scrollIntervalId);
3518 /** @type {null} */
3519 scrollIntervalId = null;
3520 }
3521 }
3522 };
3523 $(win).on("scroll resize scrollstop", function() {
3524 /** @type {null} */
3525 viewportSize = viewportOffset = null;
3526 });
3527 if (!documentElement.addEventListener) {
3528 if (documentElement.attachEvent) {
3529 documentElement.attachEvent("onfocusin", function() {
3530 /** @type {null} */
3531 viewportOffset = null;
3532 });
3533 }
3534 }
3535 }),
3536 function() {
3537 window.Config = function() {
3538 /**
3539 * @return {undefined}
3540 */
3541 function load() {
3542 /** @type {string} */
3543 this.environment = "production";
3544 /** @type {string} */
3545 this.host = "" + window.location.host;
3546 /** @type {string} */
3547 this.apiPath = "/api/v1/";
3548 /** @type {string} */
3549 this.analyticsPath = "https://tophatter.com/api/v1/analytics.json";
3550 this.pubnub = {
3551 uid: "b3f5bc5c-1d37-11e2-805a-ddf6519e9623",
3552 "default": {
3553 publish: "pub-274d7316-88d6-4dc4-9fbb-496ca1e93f97",
3554 subscribe: "sub-b3f5c075-1d37-11e2-995e-ddf6519e9623"
3555 },
3556 channel_per_lot: {
3557 publish: "pub-c-672e784f-2d86-44aa-ae63-1c993d2082ca",
3558 subscribe: "sub-c-4cb8cb8e-9e32-11e7-a3e4-2e10596cd186"
3559 },
3560 android_channel_per_lot: {
3561 publish: "pub-c-a6fd8e02-4932-4449-af5b-eec82ef1b2b2",
3562 subscribe: "sub-c-58aea1b2-ce47-11e7-b07a-4e4fd9aca72d"
3563 },
3564 origin: "ps.pndsn.com",
3565 client_idle_timeout_seconds: 1800,
3566 announcements_channel: "lot_announcements",
3567 universal_channel: "pubnubchannel.universal.pubsub.pubnub.com",
3568 lot_channel_prefix: "lot.",
3569 subscribe_timeout: 15
3570 };
3571 this.criteo = {
3572 account_id: 36409
3573 };
3574 }
3575 return load.sharedInstance = function() {
3576 return null != this._sharedInstance ? this._sharedInstance : this._sharedInstance = new load;
3577 }, load;
3578 }();
3579 }.call(this),
3580 function() {
3581 /** @type {function (this:(Array.<T>|string|{length: number}), *=, *=): Array.<T>} */
3582 var __slice = [].slice;
3583 /**
3584 * @param {boolean} ctrl
3585 * @param {boolean} alt
3586 * @return {?}
3587 */
3588 Date.prototype.toDayAndMonth = function(ctrl, alt) {
3589 var iterable;
3590 var months;
3591 var iterDate;
3592 return null == ctrl && (ctrl = true), null == alt && (alt = true), iterDate = new Date(this), iterable = window.t.web.date.days, months = window.t.web.date.months, (ctrl ? iterable[iterDate.getDay()] + ", " : "") + (alt ? months[iterDate.getMonth()] + " " : "") + (ctrl ? iterDate.getDate() : "");
3593 };
3594 /**
3595 * @param {(number|string)} n
3596 * @return {?}
3597 */
3598 String.prototype.truncate = function(n) {
3599 return this.length > n ? this.substring(0, n) + "..." : this.substring(0, this.length);
3600 };
3601 /**
3602 * @return {?}
3603 */
3604 String.prototype.format = function() {
3605 return this.replace(/\n/g, "<br />");
3606 };
3607 /**
3608 * @return {?}
3609 */
3610 String.prototype.escapeTags = function() {
3611 return this.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
3612 };
3613 /**
3614 * @return {?}
3615 */
3616 String.prototype.autoLink = function() {
3617 var name;
3618 var buf;
3619 var codeSegments;
3620 var options;
3621 var r20;
3622 var copy;
3623 if (codeSegments = 1 <= arguments.length ? __slice.call(arguments, 0) : [], r20 = /(\b(https?):\/\/[\-A-Z0-9+&@#\/%?=~_|!:,.;]*[\-A-Z0-9+&@#\/%=~_|])/gi, codeSegments.length > 0) {
3624 /** @type {string} */
3625 buf = "";
3626 options = codeSegments[0];
3627 for (name in options) {
3628 copy = options[name];
3629 buf += " " + name + "='" + copy + "'";
3630 }
3631 return this.replace(r20, "<a href='$1' " + buf.trim() + ">$1</a>");
3632 }
3633 return this.replace(r20, "<a href='$1'>$1</a>");
3634 };
3635 /**
3636 * @return {?}
3637 */
3638 String.prototype.titleize = function() {
3639 var expires;
3640 var part;
3641 var i;
3642 var l;
3643 /** @type {string} */
3644 expires = "";
3645 /** @type {number} */
3646 i = 0;
3647 /** @type {number} */
3648 l = this.length;
3649 for (; i < l;) {
3650 part = this[i];
3651 if (part === part.toUpperCase()) {
3652 expires += " ";
3653 }
3654 expires += part;
3655 i++;
3656 }
3657 return expires;
3658 };
3659 /**
3660 * @return {?}
3661 */
3662 Number.prototype.isEven = function() {
3663 return this % 2 == 0;
3664 };
3665 /**
3666 * @param {boolean} i
3667 * @param {?} deepDataAndEvents
3668 * @param {string} t
3669 * @return {?}
3670 */
3671 Number.prototype.formatMoney = function(i, deepDataAndEvents, t) {
3672 var number;
3673 var j;
3674 var n;
3675 var ret;
3676 return n = this, i = isNaN(i = Math.abs(i)) ? 0 : i, deepDataAndEvents = void 0 === deepDataAndEvents ? "." : deepDataAndEvents, t = void 0 === t ? "," : t, ret = n < 0 ? "-" : "", number = parseInt(n = Math.abs(+n || 0).toFixed(i)) + "", j = (j = number.length) > 3 ? j % 3 : 0, ret + (j ? number.substr(0, j) + t : "") + number.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (i ? deepDataAndEvents + Math.abs(n - number).toFixed(i).slice(2) : "");
3677 };
3678 /**
3679 * @return {?}
3680 */
3681 Number.prototype.formatNumber = function() {
3682 return this.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
3683 };
3684 /**
3685 * @return {?}
3686 */
3687 $.fn.serializeObject = function() {
3688 var formAsArray;
3689 var out;
3690 return out = {}, formAsArray = this.serializeArray(), $.each(formAsArray, function() {
3691 if (void 0 !== out[this.name]) {
3692 if (!out[this.name].push) {
3693 /** @type {Array} */
3694 out[this.name] = [out[this.name]];
3695 }
3696 out[this.name].push(this.value || "");
3697 } else {
3698 out[this.name] = this.value || "";
3699 }
3700 }), out;
3701 };
3702 }.call(this),
3703 function() {
3704 /**
3705 * @param {string} deepDataAndEvents
3706 * @param {Object} dataAndEvents
3707 * @param {Object} ignoreMethodDoesntExist
3708 * @return {?}
3709 */
3710 window.showBuyNowModal = function(deepDataAndEvents, dataAndEvents, ignoreMethodDoesntExist) {
3711 return null == dataAndEvents && (dataAndEvents = null), null == ignoreMethodDoesntExist && (ignoreMethodDoesntExist = {}), window.isLoggedIn() ? window.mobileBrowser ? void(window.location = "/lots/" + deepDataAndEvents + "/buy_now") : void($("#pay-flow").length > 0 ? PayFlow.buyNow(deepDataAndEvents, function() {
3712 return window.safelyOpenModal(function() {
3713 return $("#pay-flow-modal").modal("show");
3714 });
3715 }) : window.location = "/lots/" + deepDataAndEvents + "/buy_now") : void window.safelyOpenModal(function() {
3716 return $("#register-modal").modal("show");
3717 });
3718 };
3719 /**
3720 * @param {Object} name
3721 * @return {?}
3722 */
3723 window.showPayModalIfUnpaid = function(name) {
3724 return $.ajax({
3725 method: "get",
3726 url: "/api/v1/invoices.json",
3727 /**
3728 * @param {Array} fn
3729 * @return {?}
3730 */
3731 success: function(fn) {
3732 var tmp;
3733 if (null != (tmp = fn[0])) {
3734 return window.mobileBrowser ? (null == name && (name = window.t.web.pay_modal.title), void $.confirm({
3735 text: name,
3736 confirmButton: window.t.web.pay_modal.confirm_button,
3737 cancelButton: window.t.web.pay_modal.cancel_button,
3738 confirmButtonClass: "btn-primary",
3739 cancelButtonClass: null != window.currentUser.first_lot_paid_at ? "btn-default" : "hide",
3740 /**
3741 * @return {?}
3742 */
3743 confirm: function() {
3744 return window.location = "/invoices/" + tmp.id + "/pay";
3745 },
3746 dialogClass: "modal-dialog modal-sm"
3747 })) : void($("#pay-flow").length > 0 && PayFlow.pay(tmp.id, function() {
3748 return window.safelyOpenModal(function() {
3749 return $("#pay-flow-modal").modal("show");
3750 });
3751 }));
3752 }
3753 }
3754 });
3755 };
3756 /**
3757 * @param {Function} $sanitize
3758 * @return {?}
3759 */
3760 window.safelyOpenModal = function($sanitize) {
3761 var popup;
3762 return popup = $(".modal.in"), popup.length > 0 ? (popup.one("hidden.bs.modal", function() {
3763 return $sanitize();
3764 }), popup.modal("hide")) : $sanitize();
3765 };
3766 /**
3767 * @return {?}
3768 */
3769 window.isLoggedIn = function() {
3770 return null != window.currentUser && null != window.currentUser.id;
3771 };
3772 /**
3773 * @param {?} res
3774 * @param {string} next
3775 * @return {?}
3776 */
3777 window.googleSignIn = function(res, next) {
3778 var req;
3779 return req = {
3780 scope: "profile email",
3781 clientid: res,
3782 redirecturi: "postmessage",
3783 accesstype: "offline",
3784 approvalprompt: "force",
3785 cookiepolicy: "single_host_origin",
3786 callback: "googleSignInCallback"
3787 }, (null != next ? next.length : void 0) && (req.apppackagename = next), "undefined" != typeof gapi && null !== gapi ? gapi.auth.signIn(req) : void 0;
3788 };
3789 /**
3790 * @param {Object} res
3791 * @return {?}
3792 */
3793 window.googleSignInCallback = function(res) {
3794 if (!res.error || "immediate_failed" !== res.error && "access_denied" !== res.error) {
3795 return res.error ? void alert(res.error) : res.code ? $.ajax({
3796 type: "post",
3797 url: "/api/v1/users/fetch_access_token.json",
3798 data: {
3799 authorization_code: res.code,
3800 redirect_uri: "postmessage"
3801 },
3802 /**
3803 * @param {Object} response
3804 * @return {?}
3805 */
3806 success: function(response) {
3807 return $.ajax({
3808 type: "post",
3809 url: "/api/v1/users/authenticate.json",
3810 data: {
3811 code: response.access_token
3812 },
3813 /**
3814 * @return {?}
3815 */
3816 success: function() {
3817 var destinationFile;
3818 return destinationFile = $("a[data-destination]").data("destination"), window.location = null != destinationFile ? destinationFile : {
3819 dst: "/"
3820 };
3821 },
3822 /**
3823 * @param {string} xhr
3824 * @return {?}
3825 */
3826 error: function(xhr) {
3827 return alert(xhr.responseText);
3828 }
3829 });
3830 },
3831 /**
3832 * @param {string} xhr
3833 * @return {?}
3834 */
3835 error: function(xhr) {
3836 return alert(xhr.responseText);
3837 }
3838 }) : void 0;
3839 }
3840 };
3841 /**
3842 * @param {?} arg
3843 * @return {?}
3844 */
3845 window.notify = function(arg) {
3846 return window.notifySuccess(arg);
3847 };
3848 /**
3849 * @return {?}
3850 */
3851 window.notifyHide = function() {
3852 return $("#flash-message").hide();
3853 };
3854 /**
3855 * @param {?} value
3856 * @return {?}
3857 */
3858 window.notifySuccess = function(value) {
3859 return $("#flash-icon").removeClass("fa-check fa-exclamation").addClass("fa-check"), $("#flash-text").html(value), $("#flash-message-inner").removeClass("alert-danger alert-success alert-warning").addClass("alert-success"), $("#flash-message").show().addClass("pop-in");
3860 };
3861 /**
3862 * @param {?} value
3863 * @return {?}
3864 */
3865 window.notifyError = function(value) {
3866 return $("#flash-icon").removeClass("fa-check fa-exclamation").addClass("fa-exclamation"), $("#flash-text").html(value), $("#flash-message-inner").removeClass("alert-danger alert-success alert-warning").addClass("alert-danger"), $("#flash-message").show().addClass("pop-in");
3867 };
3868 /**
3869 * @param {?} $match
3870 * @return {?}
3871 */
3872 window.notifyWarning = function($match) {
3873 return $("#flash-icon").removeClass("fa-check fa-exclamation").addClass("fa-exclamation"), $("#flash-text").html($match), $("#flash-message-inner").removeClass("alert-danger alert-success alert-warning").addClass("alert-warning"), $("#flash-message").show().addClass("pop-in");
3874 };
3875 /**
3876 * @param {Object} data
3877 * @param {Object} opt_attributes
3878 * @return {?}
3879 */
3880 window.translate = function(data, opt_attributes) {
3881 var hasErrorField;
3882 var x;
3883 var _i;
3884 var expr;
3885 var _len;
3886 var text;
3887 var xs;
3888 var tokenizeEvaluate;
3889 if ("string" != typeof data && "object" != typeof data) {
3890 return data;
3891 }
3892 if ("string" == typeof data) {
3893 /** @type {Object} */
3894 text = data;
3895 } else {
3896 hasErrorField = function() {
3897 switch (opt_attributes.count) {
3898 case 0:
3899 return "zero";
3900 case 1:
3901 return "one";
3902 default:
3903 return "other";
3904 }
3905 }();
3906 text = data[hasErrorField] || data.other;
3907 }
3908 xs = text.match(/%{([a-zA-Z_]+)}/g);
3909 /** @type {number} */
3910 _i = 0;
3911 _len = xs.length;
3912 for (; _i < _len; _i++) {
3913 x = xs[_i];
3914 expr = x.replace("%{", "").replace("}", "");
3915 if (null != (tokenizeEvaluate = opt_attributes[expr])) {
3916 text = text.replace(x, tokenizeEvaluate);
3917 }
3918 }
3919 return text;
3920 };
3921 window.Store = function() {
3922 var ondata;
3923 var get;
3924 return get = function() {
3925 try {
3926 return "undefined" != typeof localStorage && null !== localStorage;
3927 } catch (e) {
3928 return e, false;
3929 }
3930 }(), get ? (ondata = function(name, val) {
3931 var i;
3932 try {
3933 return localStorage.setItem(name, val), val;
3934 } catch (r) {
3935 r;
3936 /** @type {number} */
3937 i = 0;
3938 for (; i <= 5; ++i) {
3939 localStorage.removeItem(localStorage.key(localStorage.length - 1));
3940 }
3941 return ondata(name, val);
3942 }
3943 }, {
3944 /** @type {function (string, string): ?} */
3945 set: ondata,
3946 /**
3947 * @param {string} namespace
3948 * @return {?}
3949 */
3950 get: function(namespace) {
3951 return localStorage[namespace];
3952 },
3953 /**
3954 * @param {?} key
3955 * @return {?}
3956 */
3957 expire: function(key) {
3958 var result;
3959 return result = localStorage[key], localStorage.removeItem(key), result;
3960 }
3961 }) : {
3962 /**
3963 * @param {string} name
3964 * @param {string} value
3965 * @param {number} expectedNumberOfNonCommentArgs
3966 * @return {?}
3967 */
3968 _set: function(name, value, expectedNumberOfNonCommentArgs) {
3969 return window.CookieStore._set(name, value, expectedNumberOfNonCommentArgs);
3970 },
3971 /**
3972 * @param {string} name
3973 * @param {string} now
3974 * @return {?}
3975 */
3976 set: function(name, now) {
3977 return window.CookieStore.set(name, now);
3978 },
3979 /**
3980 * @param {string} options
3981 * @return {?}
3982 */
3983 get: function(options) {
3984 return window.CookieStore.get(options);
3985 },
3986 /**
3987 * @param {?} key
3988 * @return {?}
3989 */
3990 expire: function(key) {
3991 return window.CookieStore.expire(key);
3992 }
3993 };
3994 }();
3995 window.CookieStore = function() {
3996 return {
3997 /**
3998 * @param {string} name
3999 * @param {string} value
4000 * @param {number} expectedNumberOfNonCommentArgs
4001 * @return {?}
4002 */
4003 _set: function(name, value, expectedNumberOfNonCommentArgs) {
4004 var exp;
4005 var expires;
4006 return expectedNumberOfNonCommentArgs ? (exp = new Date, exp.setTime(exp.getTime() + 24 * expectedNumberOfNonCommentArgs * 60 * 60 * 1E3), expires = "; expires=" + exp.toGMTString()) : expires = "", document.cookie = name + "=" + value + expires + "; path=/", value;
4007 },
4008 /**
4009 * @param {string} name
4010 * @param {string} value
4011 * @return {?}
4012 */
4013 set: function(name, value) {
4014 return this._set(name, value, 1);
4015 },
4016 /**
4017 * @param {string} namespace
4018 * @return {?}
4019 */
4020 get: function(namespace) {
4021 var i;
4022 var il;
4023 var key;
4024 var tmp_keys;
4025 namespace += "=";
4026 /** @type {Array.<string>} */
4027 tmp_keys = document.cookie.split(/\s*;\s*/);
4028 /** @type {number} */
4029 i = 0;
4030 /** @type {number} */
4031 il = tmp_keys.length;
4032 for (; i < il; i++) {
4033 if (key = tmp_keys[i], 0 === key.indexOf(namespace)) {
4034 return key.substring(namespace.length, key.length);
4035 }
4036 }
4037 return null;
4038 },
4039 /**
4040 * @param {string} options
4041 * @return {?}
4042 */
4043 expire: function(options) {
4044 var element;
4045 return element = this.get(options), this._set(options, "", -1), element;
4046 }
4047 };
4048 }();
4049 if (window.isLoggedIn()) {
4050 $.ajaxSetup({
4051 headers: {
4052 "X-Country": window.currentUser.country,
4053 "X-User-Secret": window.currentUser.secret
4054 }
4055 });
4056 }
4057 }.call(this),
4058 function() {
4059 $(function() {
4060 var e;
4061 var data_user;
4062 var development;
4063 var ret;
4064 return "development" !== (development = Config.sharedInstance().environment) && "test" !== development || (e = false, $("[id]").each(function() {
4065 var $col;
4066 $col = $('[id="' + this.id + '"]');
4067 if ($col.length > 1) {
4068 if ($col[0] === this) {
4069 console.warn("#" + this.id);
4070 /** @type {boolean} */
4071 e = true;
4072 }
4073 }
4074 }), e && ("undefined" != typeof console && (null !== console && console.log("[Debug] Please check the console for duplicate DOM element ids.")))), $(".modalize").on("click", function(types) {
4075 return types.preventDefault(), new Modal({
4076 title: $(this).data("title"),
4077 body: $(this).data("body"),
4078 bodySafe: $(this).data("body-safe")
4079 });
4080 }), $("[rel=tooltip]").tooltip({
4081 html: true
4082 }), $("[rel=tooltip-delayed]").tooltip({
4083 html: true,
4084 delay: {
4085 hide: 1E3
4086 }
4087 }), $(".btn").on("mouseup", function() {
4088 return $(this).blur();
4089 }), $("input", "#navbar-search").on("focus", function() {
4090 if (!$("input", "#navbar-search").val()) {
4091 return $("#navbar-search").animate({
4092 width: 350
4093 });
4094 }
4095 }), $("input", "#navbar-search").on("blur", function() {
4096 if (!$("input", "#navbar-search").val()) {
4097 return $("#navbar-search").animate({
4098 width: 250
4099 });
4100 }
4101 }), $("a", "#categories").on("click", function(types) {
4102 return types.preventDefault(), $("input[name='taxonomy_category']").val($(this).data("category")), $("#category > span:first").html($(this).text() + " <i class='caret'></i>"), $("#categories > li").removeClass("active"), $(this).parent().addClass("active");
4103 }), $.isFunction($.fn.tablesorter) && $(".table-sortable").tablesorter(), void 0 !== evercookie && (null !== evercookie && ((null != (ret = window.currentUser) ? ret.id : void 0) && (!window.Store.get("machine_id_" + window.currentUser.id) && ((!document.cookie || document.cookie.indexOf("admin") < 0) && (data_user = new evercookie, data_user.get("machine_id", function(key) {
4104 if (key || (key = window.currentUser.id, data_user.set("machine_id", key, false)), key && jQuery.isNumeric(key)) {
4105 return $.post("/users/register_machine", {
4106 machine_id: key
4107 });
4108 }
4109 }, false), window.Store.set("machine_id_" + window.currentUser.id, true, 1)))))), $("#soft-prompt-modal").on("hidden.bs.modal", function() {
4110 return $("#lot-modal").css("z-index", 1050);
4111 }), $(document).on("click", ".lot-show", function(event) {
4112 var template;
4113 var f;
4114 var e;
4115 if (event.preventDefault(), event.stopPropagation(), null != (template = $(this).data("lot-id"))) {
4116 return e = $(this).closest(".panel"), f = void 0 === $(this).data("clicked"), window.safelyOpenModal(function() {
4117 return window.LotModal.getSharedInstance().show(template), $("#lot-modal").scrollTop(0);
4118 }), f ? (THAnalytics.sharedInstance().emit({
4119 name: "product_parent_click",
4120 product_parent_id: e.data("product-parent-id"),
4121 product_parent_catalog_only: e.data("catalog-only"),
4122 catalog_id: e.data("catalog-id"),
4123 click_type: "lot-show"
4124 }), $(this).data("clicked", true)) : void 0;
4125 }
4126 }), $(document).on("click", ".lot-show-related", function(event) {
4127 var template;
4128 var browserEvent;
4129 var tracking;
4130 if (event.preventDefault(), event.stopPropagation(), null != (template = $(this).data("lot-id"))) {
4131 return tracking = {}, browserEvent = $(this).closest(".panel"), browserEvent.data("position-id") && (tracking["position-id"] = browserEvent.data("position-id")), browserEvent.data("view-section") && (tracking["view-section"] = browserEvent.data("view-section")), browserEvent.data("category-rank") && (tracking["category-rank"] = browserEvent.data("category-rank")), browserEvent.data("catalog-id") && (tracking["catalog-id"] = browserEvent.data("catalog-id")), browserEvent.data("catalog-type") &&
4132 (tracking["catalog-type"] = browserEvent.data("catalog-type")), window.safelyOpenModal(function() {
4133 return window.LotModal.getSharedInstance().show(template, {
4134 tracking: tracking,
4135 related: true
4136 }), $("#lot-modal").scrollTop(0);
4137 });
4138 }
4139 }), $(document).on("click", ".sign-up", function(evt) {
4140 if ($("#register-modal").length > 0) {
4141 return evt.preventDefault(), $("#register-modal").modal("show"), $(evt.target).is(".volume") && $("#return_path").val("/partner_auction_requests/new"), $("#sign-up").show(), $("#sign-in, #reset-password").hide();
4142 }
4143 }), $(document).on("click", ".sign-in", function(types) {
4144 if ($("#register-modal").length > 0) {
4145 return types.preventDefault(), $("#register-modal").modal("show"), $("#sign-up, #reset-password").hide(), $("#sign-in").show();
4146 }
4147 }), $("body").on("click", ".remind-me", function(types) {
4148 var n;
4149 var script;
4150 var timeoutKey;
4151 var r;
4152 var t;
4153 return types.preventDefault(), timeoutKey = $(this).data("lot-id"), window.isLoggedIn() ? null != timeoutKey ? (t = $(this).closest(".panel"), n = $(this).parent().find(".remind-me"), script = n.parent().find(".reminder-count"), r = void 0 === $(this).data("clicked"), timeoutKey = $(this).data("lot-id"), n.hasClass("reminded") ? (n.removeClass("fa-heart reminded").addClass("fa-heart-o"), window.LotModal.getSharedInstance().unsetReminder(timeoutKey), script.text(parseInt(script.text()) - 1),
4154 n.parents(".panel-body").find(".reminder-btn") && $(".reminder-btn").removeClass("btn-default").addClass("btn-primary").find("span").text(window.t.web.lot_modal.set_a_reminder), $.ajax({
4155 type: "delete",
4156 url: "/api/v1/alerts/" + timeoutKey + ".json",
4157 /**
4158 * @param {string} xhr
4159 * @return {?}
4160 */
4161 error: function(xhr) {
4162 return window.notifyError(xhr.responseText);
4163 }
4164 })) : (n.removeClass("fa-heart-o").addClass("fa-heart reminded"), window.LotModal.getSharedInstance().setReminder(timeoutKey), script.text(parseInt(script.text()) + 1).show(), n.parents(".panel-body").find(".reminder-btn") && $(".reminder-btn").removeClass("btn-primary").addClass("btn-default").find("span").text(window.t.web.lot_modal.will_remind_you), $.ajax({
4165 type: "post",
4166 url: "/api/v1/alerts.json",
4167 data: {
4168 alert: {
4169 as_hash: true,
4170 lot_id: timeoutKey,
4171 product_parent_id: t.data("product-parent-id")
4172 }
4173 },
4174 /**
4175 * @param {?} textStatus
4176 * @return {?}
4177 */
4178 success: function(textStatus) {
4179 return null == AppBoy.sharedInstance().appboy || (null != currentUser.shownAlertModal || (AppBoy.sharedInstance().appboy.isPushBlocked() || (AppBoy.sharedInstance().appboy.isPushPermissionGranted() || !AppBoy.sharedInstance().appboy.isPushSupported()))) ? null != AppBoy.sharedInstance().appboy || (null != currentUser.phone_number && 0 !== currentUser.phone_number.length || (null != currentUser.shownAlertModal || textStatus.has_active_device_tokens)) ? void 0 : ($("#alert_lot_id").val(timeoutKey),
4180 $("#alert-modal").modal("show"), currentUser.shownAlertModal = true) : ($("#alert-main").attr("src", $(".main", LotModal.getSharedInstance().container).attr("src") || t.find("img").prop("src").replace("large", "square")), $("#soft-prompt-modal").modal("show"), $("#lot-modal").css("z-index", 1039), $(".modal-backdrop").length > 1 && $($(".modal-backdrop")[1]).fadeTo(0, 0.2), currentUser.shownAlertModal = true);
4181 },
4182 /**
4183 * @param {Object} xhr
4184 * @return {?}
4185 */
4186 error: function(xhr) {
4187 if (501 !== xhr.status) {
4188 return n.removeClass("fa-heart reminded").addClass("fa-heart-o"), window.LotModal.getSharedInstance().unsetReminder(timeoutKey), script.text(parseInt(script.text()) - 1), window.notifyError(xhr.responseText);
4189 }
4190 }
4191 })), r ? (THAnalytics.sharedInstance().emit({
4192 name: "product_parent_click",
4193 product_parent_id: t.data("product-parent-id"),
4194 product_parent_catalog_only: t.data("catalog-only"),
4195 catalog_id: t.data("catalog-id"),
4196 click_type: "remind-me"
4197 }), $(this).data("clicked", true)) : void 0) : void 0 : (UserActionQueue.sharedInstance().addUserAction({
4198 action_type: "alert",
4199 action_id: timeoutKey
4200 }), void window.safelyOpenModal(function() {
4201 return $("#register-modal").modal("show");
4202 }));
4203 }), $("#alert-modal form").on("ajax:success", function() {
4204 return currentUser.phone_number = $("#alert_phone_number").val() || currentUser.id, $("#alert-modal").modal("hide"), window.notifySuccess(window.t.web.alert_modal.success);
4205 }), $("#alert-modal form").on("ajax:error", function(dataAndEvents, obj) {
4206 return window.notifyError(obj.responseText);
4207 }), $(document).on("click", "#enable-push", function() {
4208 return AppBoy.sharedInstance().appboy.registerAppboyPushMessages(function() {
4209 return $("#soft-prompt-modal").modal("hide");
4210 }, function() {
4211 return $("#soft-prompt-modal").modal("hide");
4212 });
4213 }), $(document).on("click", ".buy-it-now", function(types) {
4214 var marginDiv;
4215 var n;
4216 var browserEvent;
4217 if (types.preventDefault(), marginDiv = $(this).data("lot-id"), browserEvent = $(this).closest(".panel"), n = void 0 === $(this).data("clicked"), null != marginDiv && window.currentUser.id !== $(this).data("lot-user-id")) {
4218 return window.showBuyNowModal(marginDiv), n && (THAnalytics.sharedInstance().emit({
4219 name: "product_parent_click",
4220 product_parent_id: browserEvent.data("product-parent-id"),
4221 product_parent_catalog_only: browserEvent.data("catalog-only"),
4222 catalog_id: browserEvent.data("catalog-id"),
4223 click_type: "buy-it-now"
4224 }), $(this).data("clicked", true)), window.isLoggedIn() ? void 0 : UserActionQueue.sharedInstance().addUserAction({
4225 action_type: "buy_now",
4226 action_id: $(this).data("lot-id")
4227 });
4228 }
4229 }), $(".buy-it-now").appear(), $(".buy-it-now").on("appear", function(dataAndEvents, cursor) {
4230 cursor.each(function() {
4231 var browserEvent;
4232 if (!$(this).data("analyzed")) {
4233 browserEvent = $(this).closest(".panel");
4234 THAnalytics.sharedInstance().enqueue({
4235 name: "product_parent_impression",
4236 product_parent_id: browserEvent.data("product-parent-id"),
4237 product_parent_catalog_only: browserEvent.data("catalog-only"),
4238 catalog_id: browserEvent.data("catalog-id")
4239 });
4240 $(this).data("analyzed", true);
4241 }
4242 });
4243 }), $(document).on("click", ".report", function(types) {
4244 var sel;
4245 var j;
4246 return types.preventDefault(), j = $(this).data("reportable-type"), $("#report_reportable_type").val(j), $("#report_reportable_id").val($(this).data("reportable-id")), $("#user-staff-actions, #lot-staff-actions").hide(), "User" === j && (null != currentUser.admin && $("#user-staff-actions").show()), "Lot" === j && (null != currentUser.admin && $("#lot-staff-actions").show()), $("#report_comment").val(""), $("." + j.toLowerCase(), "#report-modal").show(), $(".alert", "#report-modal").hide(),
4247 sel = $("#report-modal .reasons"), sel.empty(), $.each(window.t.reasons.report[j], function(dataAndEvents, deepDataAndEvents) {
4248 return sel.append($("<div class='radio'><label><input type='radio' name='reason' value='" + dataAndEvents + "' /> " + deepDataAndEvents + "</label></div>"));
4249 }), $("#report-modal").modal("show");
4250 }), $("#new_report").on("ajax:beforeSend", function() {
4251 return $(".alert", "#new_report").hide();
4252 }), $("#new_report").on("ajax:error", function(dataAndEvents, jqXHR) {
4253 return $(".alert", "#new_report").text(jqXHR.responseText + ".").show();
4254 }), $("#new_report").on("ajax:success", function() {
4255 return $("#report-modal").modal("hide"), $("#report-feedback-modal .feedback").hide(), $("#report-feedback-modal .feedback." + $("#report_reportable_type").val().toLowerCase()).show(), $("#report-feedback-modal").modal("show");
4256 });
4257 });
4258 }.call(this),
4259 function() {
4260 window.THAnalytics = function() {
4261 /**
4262 * @return {undefined}
4263 */
4264 function init() {
4265 var _self;
4266 var image;
4267 var time;
4268 var name;
4269 var _ref1;
4270 var display;
4271 var location;
4272 var ret;
4273 var options;
4274 _self = new UAParser;
4275 options = _self.getResult();
4276 /** @type {Array} */
4277 this.queue = [];
4278 this.config = {
4279 queue_max: 20,
4280 shared_interval_timer: 2E3
4281 };
4282 this.properties = {
4283 app: window.app,
4284 platform: "web",
4285 os: null != options && null != (image = options.os) ? image.name : void 0,
4286 os_version: null != options && null != (time = options.os) ? time.version : void 0,
4287 device: null != options && null != (name = options.device) ? name.type : void 0,
4288 screen_width: $(window).width(),
4289 screen_height: $(window).height(),
4290 browser: null != options && null != (_ref1 = options.browser) ? _ref1.name : void 0,
4291 browser_version: null != options && null != (display = options.browser) ? display.major : void 0,
4292 url: null != (location = window.location) ? location.href : void 0,
4293 user_id: null != (ret = window.currentUser) ? ret.id : void 0
4294 };
4295 }
4296 return init.sharedInstance = function() {
4297 return null != this._sharedInstance ? this._sharedInstance : this._sharedInstance = new init;
4298 }, init.prototype.emit = function(events) {
4299 var x;
4300 var _i;
4301 var _len;
4302 var index;
4303 var iteratee;
4304 var value;
4305 if (!$.isArray(events)) {
4306 /** @type {Array} */
4307 events = [].concat(events);
4308 }
4309 /** @type {number} */
4310 _i = 0;
4311 _len = events.length;
4312 for (; _i < _len; _i++) {
4313 x = events[_i];
4314 iteratee = this.properties;
4315 for (index in iteratee) {
4316 value = iteratee[index];
4317 x[index] = value;
4318 }
4319 }
4320 return 0 !== events.length && $.ajax({
4321 method: "post",
4322 url: Config.sharedInstance().analyticsPath,
4323 dataType: "json",
4324 contentType: "application/json",
4325 data: JSON.stringify({
4326 events: events
4327 })
4328 }), true;
4329 }, init.prototype.setSharedInterval = function() {
4330 return this.sharedInterval = setInterval(function() {
4331 init.sharedInstance().flush();
4332 }, this.config.shared_interval_timer);
4333 }, init.prototype.enqueue = function(task) {
4334 return this.queue.push(task), null != this.sharedInterval ? this.queue.length >= this.config.queue_max ? this.flush() : (clearInterval(this.sharedInterval), this.setSharedInterval()) : this.setSharedInterval();
4335 }, init.prototype.flush = function() {
4336 return null != this.sharedInterval && clearInterval(this.sharedInterval), this.emit(this.queue), this.queue = [];
4337 }, init;
4338 }();
4339 $(window).unload(function() {
4340 return THAnalytics.sharedInstance().flush();
4341 });
4342 }.call(this),
4343 function() {
4344 window.Modal = function() {
4345 /**
4346 * @param {Object} options
4347 * @return {undefined}
4348 */
4349 function render(options) {
4350 var activeItem;
4351 var loading;
4352 var form;
4353 this.template = $("#modal");
4354 form = $(".modal-header", this.template);
4355 activeItem = $(".modal-body", this.template);
4356 loading = $(".modal-footer", this.template);
4357 if (null != options.title) {
4358 form.show();
4359 $(".title", form).show().html(String(options.title));
4360 } else {
4361 form.hide();
4362 $(".title", form).hide().empty();
4363 }
4364 if (null != options.noclose) {
4365 if (true === options.noclose) {
4366 $(".close", form).hide();
4367 }
4368 }
4369 if (null != options.bodySafe) {
4370 activeItem.show().html(options.bodySafe.format());
4371 } else {
4372 activeItem.show().html(String(options.body).escapeTags().format());
4373 }
4374 if (null != options.footer) {
4375 loading.show().html(options.footer);
4376 } else {
4377 loading.hide().empty();
4378 }
4379 this.template.one("show.bs.modal", function() {
4380 if (null != options.callback) {
4381 return options.callback();
4382 }
4383 });
4384 if (null != options.backdrop) {
4385 this.template.modal({
4386 show: true,
4387 backdrop: options.backdrop
4388 });
4389 } else {
4390 this.template.modal("show");
4391 }
4392 }
4393 return render.close = function() {
4394 return $("#modal").modal("hide");
4395 }, render;
4396 }();
4397 }.call(this),
4398 function() {
4399 window.Element = function() {
4400 /**
4401 * @param {Object} opt_parent
4402 * @param {Object} options
4403 * @return {undefined}
4404 */
4405 function Node(opt_parent, options) {
4406 /** @type {Object} */
4407 this.slot = opt_parent;
4408 this.id = options.id;
4409 this.template = this.slot.template.find("." + this.id);
4410 /** @type {boolean} */
4411 this.isPainted = false;
4412 this.priority = options.priority || 0;
4413 this.embedded = SlotClient.sharedInstance().embedded;
4414 }
4415 return Node.prototype.paint = function(context, v11, time) {
4416 var value;
4417 return null == v11 && (v11 = false), null == time && (time = false), value = function() {
4418 var theEvent;
4419 if ("luxejoy" !== (theEvent = window.app) && "dollarstart" !== theEvent || "text" !== context.type) {
4420 if ("text" !== context.type || "tophatter" !== window.app) {
4421 return context.color;
4422 }
4423 switch (context.id) {
4424 case "state":
4425 switch (context.text_key) {
4426 case "th.slots.auction_slot.open":
4427 return "#4524a0";
4428 case "th.slots.auction_slot.going_once":
4429 return "#fcbf01";
4430 case "th.slots.auction_slot.going_twice":
4431 return "#ce0061";
4432 default:
4433 return "#999999";
4434 }
4435 break;
4436 case "discount":
4437 return "#00c5b4";
4438 case "scarcity":
4439 return "#fff";
4440 case "universal-badge":
4441 return null;
4442 default:
4443 return "#999999";
4444 }
4445 } else {
4446 switch (context.id) {
4447 case "state":
4448 return "#000000";
4449 case "discount":
4450 return "#FF3300";
4451 case "high-bidder":
4452 return "th.slots.auction_slot.high_bidder" === context.text_key ? "#000000" : "#CCCCCC";
4453 case "scarcity":
4454 return "#fff";
4455 case "universal-badge":
4456 return null;
4457 default:
4458 return "#999999";
4459 }
4460 }
4461 }(), null != value && ("universal-badge" !== context.id && this.template.css("color", value)), this._activateClass(this.template, context.element_class), this._activateClass(this.slot.template, context.slot_class), null == context.pulse || (true !== context.pulse || (this.embedded || this.pulse())), null != this.timeout && clearTimeout(this.timeout), null != context.transition && (this.timeout = setTimeout(function(system) {
4462 return function() {
4463 return system.paint(context.transition, true);
4464 };
4465 }(this), 1E3 * context.transition.wait)), this.isPainted = true;
4466 }, Node.prototype.isPaintable = function() {
4467 return this.template.length > 0;
4468 }, Node.prototype.pulse = function() {
4469 var child;
4470 if (!window.mobileBrowser && this.slot.isVisible()) {
4471 return child = new TimelineLite, child.to(this.template, 0.4, {
4472 scaleX: 1.1,
4473 scaleY: 1.1,
4474 ease: Power0.easeNone
4475 }).to(this.template, 0.4, {
4476 scaleX: 1,
4477 scaleY: 1,
4478 ease: Power0.easeNone
4479 }).set(this.template, {
4480 clearProps: "all"
4481 });
4482 }
4483 }, Node.prototype.translate = function(aX, opt_attributes, args) {
4484 var target;
4485 var s;
4486 var _i;
4487 var _len;
4488 var arg;
4489 var cursor;
4490 var list;
4491 var stack;
4492 var str;
4493 if (target = SlotClient.sharedInstance(), null == (str = target.translations[opt_attributes])) {
4494 return opt_attributes;
4495 }
4496 if (null != args && (null != (list = stack = str.match(/%{([a-zA-Z_]+)}/g)) ? list.length : void 0) > 0) {
4497 /** @type {number} */
4498 _i = 0;
4499 _len = stack.length;
4500 for (; _i < _len; _i++) {
4501 s = stack[_i];
4502 cursor = s.replace("%{", "").replace("}", "");
4503 if (null != (arg = args[cursor])) {
4504 if ("string" == typeof arg) {
4505 str = str.replace(s, arg);
4506 } else {
4507 if ("object" == typeof arg) {
4508 str = str.replace(s, arg[target.parameterKey]);
4509 }
4510 }
4511 }
4512 }
4513 }
4514 return str;
4515 }, Node.prototype._activateClass = function(results, value) {
4516 var elem;
4517 if (null != (elem = results.data("active_class")) && results.removeClass(elem), null != value) {
4518 return $.isArray(value) && (value = value.join(" ")), results.data("active_class", value), results.addClass(value);
4519 }
4520 }, Node;
4521 }();
4522 }.call(this),
4523 function() {
4524 /**
4525 * @param {Function} child
4526 * @param {Object} parent
4527 * @return {?}
4528 */
4529 var __extends = function(child, parent) {
4530 /**
4531 * @return {undefined}
4532 */
4533 function ctor() {
4534 /** @type {Function} */
4535 this.constructor = child;
4536 }
4537 var key;
4538 for (key in parent) {
4539 if (__hasProp.call(parent, key)) {
4540 child[key] = parent[key];
4541 }
4542 }
4543 return ctor.prototype = parent.prototype, child.prototype = new ctor, child.__super__ = parent.prototype, child;
4544 };
4545 /** @type {function (this:Object, *): boolean} */
4546 var __hasProp = {}.hasOwnProperty;
4547 window.TextElement = function(_super) {
4548 /**
4549 * @return {?}
4550 */
4551 function FutureMessage() {
4552 return FutureMessage.__super__.constructor.apply(this, arguments);
4553 }
4554 return __extends(FutureMessage, _super), FutureMessage.prototype.paint = function(params, v11, time) {
4555 return null == v11 && (v11 = false), null == time && (time = false), null != params.text_key ? this.text = this.translate("text_element.text_key", params.text_key, params.parameters) : this.text = params.text, this.template.text(this.text || ""), FutureMessage.__super__.paint.call(this, params, time);
4556 }, FutureMessage;
4557 }(window.Element);
4558 }.call(this),
4559 function() {
4560 /**
4561 * @param {Function} child
4562 * @param {Object} parent
4563 * @return {?}
4564 */
4565 var __extends = function(child, parent) {
4566 /**
4567 * @return {undefined}
4568 */
4569 function ctor() {
4570 /** @type {Function} */
4571 this.constructor = child;
4572 }
4573 var key;
4574 for (key in parent) {
4575 if (__hasProp.call(parent, key)) {
4576 child[key] = parent[key];
4577 }
4578 }
4579 return ctor.prototype = parent.prototype, child.prototype = new ctor, child.__super__ = parent.prototype, child;
4580 };
4581 /** @type {function (this:Object, *): boolean} */
4582 var __hasProp = {}.hasOwnProperty;
4583 window.ImageElement = function(_super) {
4584 /**
4585 * @return {?}
4586 */
4587 function FutureMessage() {
4588 return FutureMessage.__super__.constructor.apply(this, arguments);
4589 }
4590 return __extends(FutureMessage, _super), FutureMessage.prototype.paint = function(e, v11, time) {
4591 return null == v11 && (v11 = false), null == time && (time = false), this.src = e.src, this.isPainted ? this.template.attr("src") !== this.src && (window.mobileBrowser ? this.template.attr("src", this.src) : ($("<img />")[0].src = this.src, null != e.skip_animation && true === e.skip_animation || !this.slot.isVisible() ? this.template.attr("src", this.src) : TweenLite.to(this.template, 0.4, {
4592 opacity: 0,
4593 onComplete: function(self) {
4594 return function() {
4595 return self.template.attr("src", self.src), TweenLite.to(self.template, 0.6, {
4596 opacity: 1
4597 });
4598 };
4599 }(this)
4600 }))) : this.template.attr("src", this.src), FutureMessage.__super__.paint.call(this, e, time);
4601 }, FutureMessage;
4602 }(window.Element);
4603 }.call(this),
4604 function() {
4605 /**
4606 * @param {Function} child
4607 * @param {Object} parent
4608 * @return {?}
4609 */
4610 var __extends = function(child, parent) {
4611 /**
4612 * @return {undefined}
4613 */
4614 function ctor() {
4615 /** @type {Function} */
4616 this.constructor = child;
4617 }
4618 var key;
4619 for (key in parent) {
4620 if (__hasProp.call(parent, key)) {
4621 child[key] = parent[key];
4622 }
4623 }
4624 return ctor.prototype = parent.prototype, child.prototype = new ctor, child.__super__ = parent.prototype, child;
4625 };
4626 /** @type {function (this:Object, *): boolean} */
4627 var __hasProp = {}.hasOwnProperty;
4628 window.BidButtonElement = function(_super) {
4629 /**
4630 * @param {?} config
4631 * @param {?} chart
4632 * @return {undefined}
4633 */
4634 function constructor(config, chart) {
4635 constructor.__super__.constructor.call(this, config, chart);
4636 /** @type {null} */
4637 this.timerStartedAt = null;
4638 this.$lotId = this.template.find(".bid-button-lot-id");
4639 this.$amount = this.template.find(".bid-button-amount");
4640 this.$title = this.template.find(".bid-button-title");
4641 this.$subtitle = this.template.find(".bid-button-subtitle");
4642 this.template.on("click", function(item) {
4643 return function(event) {
4644 if (window.isLoggedIn() && (event.preventDefault(), event.stopPropagation(), item.template.hasClass("btn-ready"))) {
4645 return item.lotId && item.amount ? (item._bid(), item.slot.sticky(), item.template.addClass("listening")) : void("undefined" != typeof console && (null !== console && console.log("Trying to bid, but the form isn't valid: lotId=" + item.lotId + ", amount=" + item.amount)));
4646 }
4647 };
4648 }(this));
4649 }
4650 return __extends(constructor, _super), constructor.prototype.paint = function(e, v11, time) {
4651 var map;
4652 var self;
4653 var key;
4654 var amount;
4655 var s;
4656 var pos;
4657 var title;
4658 var fromIndex;
4659 var y;
4660 var val;
4661 if (null == v11) {
4662 /** @type {boolean} */
4663 v11 = false;
4664 }
4665 if (null == time) {
4666 /** @type {boolean} */
4667 time = false;
4668 }
4669 amount = this.translate("bid_button_element.amount_key", e.amount_key, e.parameters);
4670 title = this.translate("bid_button_element.title_key", e.title_key, e.parameters);
4671 y = e.subtitle_key;
4672 if (null != e.subtitle_count_key) {
4673 if (/\.other$/.test(y)) {
4674 self = SlotClient.sharedInstance();
4675 fromIndex = this.translate("bid_button_element.subtitle_count", e.subtitle_count_key, e.parameters);
4676 s = function() {
4677 switch (Number(fromIndex)) {
4678 case 0:
4679 return y.replace(".other", ".zero");
4680 case 1:
4681 return y.replace(".other", ".one");
4682 default:
4683 return y;
4684 }
4685 }();
4686 if (null != self.translations[s]) {
4687 y = s;
4688 }
4689 }
4690 }
4691 pos = this.translate("bid_button_element.subtitle_key", y, e.parameters);
4692 map = {
4693 lot_id: [this.lotId, e.lot_id],
4694 state: [this.state, e.state],
4695 timer: [this.timer, e.timer],
4696 amount: [this.amount, amount],
4697 title: [this.title, title],
4698 subtitle: [this.subtitle, title],
4699 product_parent_id: [this.productId, e.product_parent_id]
4700 };
4701 for (key in map) {
4702 val = map[key];
4703 if (!(val[0] !== val[1] && (val[0] || val[1]))) {
4704 delete map[key];
4705 }
4706 }
4707 if (this.lotId = e.lot_id, this.productId = e.product_parent_id, this.state = e.state, this.timer = e.timer, this.amount = amount, this.title = title, this.subtitle = pos, time) {
4708 for (key in map) {
4709 val = map[key];
4710 if ("undefined" != typeof console) {
4711 if (null !== console) {
4712 console.log(Date() + " [" + this.slot.id + ", " + this.id + "] " + key + ": " + (val[0] || "") + " => " + (val[1] || ""));
4713 }
4714 }
4715 }
4716 }
4717 return this.$lotId.val(this.lotId), this.$amount.val(this.amount), this._setState(this.state), v11 || (null == this.slot.nextMessageIn || this._timer(this.slot.nextMessageIn)), this.isPainted && (null != map.state && ("won" === this.state && (0 === window.currentUser.lots_won_count && null === window.subdomain ? $.ajax({
4718 method: "get",
4719 url: "/api/v1/invoices.json",
4720 /**
4721 * @param {Array} fn
4722 * @return {?}
4723 */
4724 success: function(fn) {
4725 var tmp;
4726 return null != (tmp = fn[0]) ? window.location = "/invoices/" + tmp.id + "/pay?pixel=true" : window.showPayModalIfUnpaid(window.t.slots.page.pay_now);
4727 },
4728 /**
4729 * @return {?}
4730 */
4731 error: function() {
4732 return window.showPayModalIfUnpaid(window.t.slots.page.pay_now);
4733 }
4734 }) : window.showPayModalIfUnpaid(window.t.slots.page.pay_now)))), constructor.__super__.paint.call(this, e, time);
4735 }, constructor.prototype.pause = function() {
4736 return this._setState("paused");
4737 }, constructor.prototype.resume = function() {
4738 return this._setState(this.state);
4739 }, constructor.prototype._setState = function(state) {
4740 switch (state) {
4741 case "enabled":
4742 return this._button({
4743 "class": "btn-ready"
4744 });
4745 case "winning":
4746 return this._button({
4747 "class": "btn-winning"
4748 });
4749 case "won":
4750 return this._button({
4751 "class": "btn-won"
4752 });
4753 case "outbid":
4754 return this._button({
4755 "class": "btn-outbid"
4756 });
4757 case "bidding":
4758 return this._button({
4759 "class": "btn-ready",
4760 disabled: true
4761 });
4762 case "disabled":
4763 return this._button({
4764 "class": "btn-disabled",
4765 disabled: true
4766 });
4767 case "paused":
4768 return this._button({
4769 disabled: true,
4770 loading: true
4771 });
4772 case "loading":
4773 return this._button({
4774 "class": "btn-ready",
4775 disabled: true,
4776 loading: true
4777 });
4778 case "confirm":
4779 return this._button({
4780 "class": "btn-ready confirm",
4781 title: "Confirm",
4782 subtitle: ""
4783 });
4784 default:
4785 return "undefined" != typeof console && null !== console ? console.log("Unhandled BidButtonElement 'state' value: " + state) : void 0;
4786 }
4787 }, constructor.prototype._button = function(opt_attributes) {
4788 return null == opt_attributes && (opt_attributes = {}), opt_attributes["class"] && this.template.removeClass("btn-ready btn-winning btn-won btn-outbid btn-disabled confirm").addClass(opt_attributes["class"]), opt_attributes.disabled ? this.template.attr("disabled", true) : this.template.removeAttr("disabled"), opt_attributes.loading ? (this.$title.addClass("style-if-no-subtitle").html("<div style='padding-top: 5px;'><span class='fa fa-circle-o-notch fa-lg fa-spin'></span></div>"), this.$subtitle.hide()) :
4789 (this.$title.removeClass("style-if-no-subtitle").text(null != opt_attributes.title ? opt_attributes.title : this.title || ""), this.$subtitle.text(null != opt_attributes.subtitle ? opt_attributes.subtitle : this.subtitle || "").show(), 0 === this.$subtitle.text().length ? this.template.find(".bid-button-title").addClass("style-if-no-subtitle") : this.template.find(".bid-button-title").removeClass("style-if-no-subtitle")), this.template;
4790 }, constructor.prototype._timer = function(callback, key) {
4791 if (null == key && (key = 100), this.slot.isVisible()) {
4792 return null == this._bidButtonTimer && (this._bidButtonTimer = this.template.find(".bid-button-timer")), this._bidButtonTimer.removeClass("active open going_once going_twice closed reset").addClass(this.timer), TweenLite.set(this._bidButtonTimer, {
4793 x: "-" + (100 - key) + "%"
4794 }), TweenLite.to(this._bidButtonTimer, callback, {
4795 x: "-100%",
4796 ease: Power0.easeNone
4797 }), this.timerStartedAt = Math.round((new Date).getTime() / 1E3);
4798 }
4799 }, constructor.prototype._copyTimer = function($rootElement) {
4800 var t;
4801 var d;
4802 var pdataOld;
4803 var camelKey;
4804 var events;
4805 if (pdataOld = $rootElement._getBidButtonElement(), null != (d = $rootElement.nextMessageIn) && (null != (events = pdataOld.timerStartedAt) && (t = d - (SlotClient.now() - events), camelKey = Math.round(t / d * 100), t > 0))) {
4806 return this._timer(t, camelKey);
4807 }
4808 }, constructor.prototype._userEvent = function() {
4809 return {
4810 name: "user_bid",
4811 lot_id: this.lotId,
4812 product_parent_id: this.productId,
4813 timer: this.timer,
4814 amount: this.amount
4815 };
4816 }, constructor.prototype._bid = function() {
4817 var price;
4818 var theEvent;
4819 return price = this.amount, null == (theEvent = window.currentUser).bids_count && (theEvent.bids_count = 0), window.currentUser.bids_count += 1, $.ajax({
4820 method: "post",
4821 url: "/api/v1/bids.json",
4822 data: {
4823 bid: {
4824 lot_id: this.lotId,
4825 amount_local: price,
4826 country: window.currentUser.country,
4827 confirmed: true
4828 }
4829 },
4830 beforeSend: function(dataAndEvents) {
4831 return function() {
4832 return dataAndEvents._setState("loading");
4833 };
4834 }(this),
4835 success: function(dataAndEvents) {
4836 return function() {
4837 return THAnalytics.sharedInstance().emit(dataAndEvents._userEvent()), "outbrain" === window.currentUser.ad_campaign && ("undefined" != typeof obApi && (null !== obApi && obApi("track", "Bids"))), window.Criteo.sharedInstance().push({
4838 event: "viewBasket",
4839 item: [{
4840 id: dataAndEvents.productId,
4841 price: price,
4842 quantity: 1
4843 }]
4844 });
4845 };
4846 }(this),
4847 error: function(entity) {
4848 return function(xhr) {
4849 var re;
4850 var nDigit;
4851 var reFormat;
4852 if (entity._setState(entity.state), nDigit = parseInt(xhr.getResponseHeader("X-Error-Code")), re = xhr.getResponseHeader("X-Error-Acknowledge"), reFormat = xhr.getResponseHeader("X-Error-Obtrusive"), xhr.getResponseHeader("X-Error-Confirm"), 2 !== nDigit) {
4853 return 8 === nDigit ? window.showPayModalIfUnpaid(window.t.slots.page.unpaid_invoice) : re || reFormat ? $.confirm({
4854 title: window.t.slots.errors.cannot_place_bid,
4855 text: "" + (re || reFormat),
4856 confirmButton: "OKAY",
4857 confirmButtonClass: "btn-primary btn-block",
4858 cancelButtonClass: "hide",
4859 dialogClass: "modal-dialog modal-sm"
4860 }) : window.notifyError(xhr.responseText);
4861 }
4862 };
4863 }(this)
4864 });
4865 }, constructor;
4866 }(window.Element);
4867 }.call(this),
4868 function() {
4869 window.Slot = function() {
4870 /**
4871 * @param {?} config
4872 * @param {Object} delta
4873 * @return {undefined}
4874 */
4875 function constructor(config, delta) {
4876 this.template = this.newTemplate();
4877 this.abandonAfterSeconds = SlotClient.sharedInstance()._slotAbandonedAfterSeconds;
4878 this._elements = {};
4879 this.pauseOrResumeHook = delta.pauseOrResumeHook;
4880 /** @type {boolean} */
4881 this.paused = true;
4882 this.initialize(delta);
4883 this.paint(delta);
4884 if (!(null != this.id && null != this.template)) {
4885 if ("undefined" != typeof console) {
4886 if (null !== console) {
4887 console.log("Warning: A slot was instantiated without an @id or @template!");
4888 }
4889 }
4890 }
4891 }
4892 return constructor.prototype.initialize = function(data) {
4893 var metadata;
4894 var dataText;
4895 var file;
4896 return this.id = null != (metadata = data.metadata) ? metadata.lot_id : void 0, this._is_sticky = false, this.abandoned = false, this.template.attr("id", this._domId()), this.template.data({
4897 "lot-id": null != (dataText = data.metadata) ? dataText.lot_id : void 0,
4898 "auction-id": null != (file = data.metadata) ? file.auction_id : void 0
4899 }), this.template.find(".slot-wrapper").off("inview"), this.template.find(".slot-wrapper").on("inview", function(t) {
4900 return function(dataAndEvents, deepDataAndEvents) {
4901 return deepDataAndEvents ? t.resume() : t.pause();
4902 };
4903 }(this));
4904 }, constructor.prototype.pause = function(dataAndEvents) {
4905 if (null == dataAndEvents) {
4906 /** @type {boolean} */
4907 dataAndEvents = false;
4908 }
4909 }, constructor.prototype.resume = function() {}, constructor.prototype.sticky = function() {}, constructor.prototype.paint = function(data, v11) {
4910 var item;
4911 var m;
4912 var el;
4913 var _i;
4914 var _len;
4915 var items;
4916 var _ref;
4917 var cells;
4918 if (null == v11) {
4919 /** @type {boolean} */
4920 v11 = false;
4921 }
4922 /** @type {Object} */
4923 this.data = data;
4924 this.sequenceNumber = data.sequence_number;
4925 this.nextMessageIn = data.next_message_in;
4926 if (null != this.nextMessageIn) {
4927 this.abandonSlotAt = SlotClient.now() + (2 * this.nextMessageIn + 1);
4928 } else {
4929 this.abandonSlotAt = SlotClient.now() + this.abandonAfterSeconds;
4930 }
4931 items = this._processOverrides(data);
4932 _ref = data.elements;
4933 /** @type {number} */
4934 _i = 0;
4935 _len = _ref.length;
4936 for (; _i < _len; _i++) {
4937 if (item = _ref[_i], el = this._elements[item.id], null != items[item.id] && (item = items[item.id], delete items[item.id], null != item.subtitle && (null != item.transition && (null != item.transition.subtitle && (item.transition.subtitle = item.subtitle)))), null == el) {
4938 switch (item.type) {
4939 case "text":
4940 el = new TextElement(this, item);
4941 break;
4942 case "image":
4943 el = new ImageElement(this, item);
4944 break;
4945 case "bid-button":
4946 el = new BidButtonElement(this, item);
4947 }
4948 }
4949 if (null != el) {
4950 this._elements[item.id] = el;
4951 if (el.isPaintable()) {
4952 el.paint(item, v11);
4953 }
4954 }
4955 }
4956 /** @type {Array} */
4957 cells = [];
4958 for (m in items) {
4959 item = items[m];
4960 el = this._elements[item.id];
4961 if (null != el && el.isPaintable()) {
4962 cells.push(el.paint(item, v11));
4963 } else {
4964 cells.push(void 0);
4965 }
4966 }
4967 return cells;
4968 }, constructor.prototype._domId = function() {
4969 return this.id;
4970 }, constructor.prototype._processOverrides = function(value) {
4971 var cursor;
4972 var bProperties;
4973 var reserved;
4974 var contentMap;
4975 var pathConfig;
4976 return contentMap = {}, reserved = SlotClient.sharedInstance().overrideGroups, bProperties = value.overrides.slice(0).filter(function(div) {
4977 var childNodes;
4978 var codeSegments;
4979 return (null != (childNodes = div.override_groups) ? childNodes.length : void 0) > 0 && ((null != reserved ? reserved.length : void 0) > 0 && (null != (codeSegments = div.override_groups.filter(function(i) {
4980 return (null != reserved ? reserved.indexOf(i) : void 0) >= 0;
4981 })) ? codeSegments.length : void 0) > 0);
4982 }), pathConfig = bProperties.sort(function(options, item) {
4983 return (item.priority || 0) - (options.priority || 0);
4984 }), (cursor = null != pathConfig ? pathConfig.shift() : void 0) && (contentMap[cursor.id] = cursor), contentMap;
4985 }, constructor;
4986 }();
4987 }.call(this),
4988 function() {
4989 /**
4990 * @param {Object} child
4991 * @param {Object} parent
4992 * @return {?}
4993 */
4994 var __extends = function(child, parent) {
4995 /**
4996 * @return {undefined}
4997 */
4998 function ctor() {
4999 /** @type {Object} */
5000 this.constructor = child;
5001 }
5002 var key;
5003 for (key in parent) {
5004 if (__hasProp.call(parent, key)) {
5005 child[key] = parent[key];
5006 }
5007 }
5008 return ctor.prototype = parent.prototype, child.prototype = new ctor, child.__super__ = parent.prototype, child;
5009 };
5010 /** @type {function (this:Object, *): boolean} */
5011 var __hasProp = {}.hasOwnProperty;
5012 window.AuctionSlot = function(_super) {
5013 /**
5014 * @return {?}
5015 */
5016 function self() {
5017 return self.__super__.constructor.apply(this, arguments);
5018 }
5019 return __extends(self, _super), self.prototype.newTemplate = function() {
5020 return $("#slot-auction").clone().removeAttr("id");
5021 }, self.prototype.replaceWith = function(value) {
5022 var paused;
5023 return paused = this.paused, this.pause(true), this.initialize(value), this.paused = paused;
5024 }, self.prototype.repaint = function(delta) {
5025 return this.paint(delta), this.isVisible() ? this.resume() : this.pause();
5026 }, self.prototype.sticky = function() {
5027 return this._is_sticky = true;
5028 }, self.prototype.prune = function() {
5029 return this.pause(true), this.template.remove();
5030 }, self.prototype.pause = function(dataAndEvents) {
5031 if (null == dataAndEvents && (dataAndEvents = false), dataAndEvents || !this._is_sticky) {
5032 return this.paused = true, "function" == typeof this.pauseOrResumeHook ? this.pauseOrResumeHook("pause", this.id, function(dataAndEvents) {
5033 return function() {
5034 var anim;
5035 return null != (anim = dataAndEvents._getBidButtonElement()) ? anim.pause() : void 0;
5036 };
5037 }(this)) : void 0;
5038 }
5039 }, self.prototype.resume = function() {
5040 return this.paused = false, "function" == typeof this.pauseOrResumeHook ? this.pauseOrResumeHook("resume", this.id, function(dataAndEvents) {
5041 return function() {
5042 var res;
5043 return null != (res = dataAndEvents._getBidButtonElement()) ? res.resume() : void 0;
5044 };
5045 }(this)) : void 0;
5046 }, self.prototype.isVisible = function() {
5047 return !this.paused;
5048 }, self.prototype.isReplaceable = function() {
5049 var test;
5050 return test = this._getBidButtonElement(), !!(this.abandoned || (null == test || null != test.state && ("disabled" === test.state && (null != test.timer && "closed" === test.timer))));
5051 }, self.prototype._getBidButtonElement = function() {
5052 var elem;
5053 var i;
5054 var elems;
5055 elems = this._elements;
5056 for (i in elems) {
5057 if (elem = elems[i], "bid-button" === i) {
5058 return elem;
5059 }
5060 }
5061 return null;
5062 }, self;
5063 }(window.Slot);
5064 }.call(this),
5065 function() {
5066 /**
5067 * @param {Function} child
5068 * @param {Object} parent
5069 * @return {?}
5070 */
5071 var __extends = function(child, parent) {
5072 /**
5073 * @return {undefined}
5074 */
5075 function ctor() {
5076 /** @type {Function} */
5077 this.constructor = child;
5078 }
5079 var key;
5080 for (key in parent) {
5081 if (__hasProp.call(parent, key)) {
5082 child[key] = parent[key];
5083 }
5084 }
5085 return ctor.prototype = parent.prototype, child.prototype = new ctor, child.__super__ = parent.prototype, child;
5086 };
5087 /** @type {function (this:Object, *): boolean} */
5088 var __hasProp = {}.hasOwnProperty;
5089 window.LotModalAuctionSlot = function(_super) {
5090 /**
5091 * @return {?}
5092 */
5093 function FutureMessage() {
5094 return FutureMessage.__super__.constructor.apply(this, arguments);
5095 }
5096 return __extends(FutureMessage, _super), FutureMessage.prototype.newTemplate = function() {
5097 return $("#lot-modal-slot-auction");
5098 }, FutureMessage.prototype._domId = function() {
5099 return "lot-modal-slot-auction";
5100 }, FutureMessage.buildFrom = function($rootElement) {
5101 var body;
5102 var media;
5103 return media = new FutureMessage(null, $rootElement.data), media.paused = false, null != (body = media._getBidButtonElement()) && body._copyTimer($rootElement), media;
5104 }, FutureMessage;
5105 }(window.AuctionSlot);
5106 }.call(this),
5107 function() {
5108 window.LotModal = function() {
5109 /**
5110 * @return {undefined}
5111 */
5112 function $() {
5113 this.template = $("#lot-modal");
5114 /** @type {null} */
5115 this.lotId = null;
5116 this.$bidContainer = this.template.find("#lot-modal-slot-auction");
5117 /** @type {null} */
5118 this.bodyHeight = null;
5119 /** @type {null} */
5120 this.bidButton = null;
5121 /** @type {null} */
5122 this.bidCount = null;
5123 /** @type {null} */
5124 this.retail = null;
5125 /** @type {null} */
5126 this.discount = null;
5127 /** @type {null} */
5128 this.nextMessageIn = null;
5129 }
5130 return $.getSharedInstance = function() {
5131 return null == window.lotModal && (window.lotModal = new window.LotModal), window.lotModal;
5132 }, $.prototype.show = function(msg, options, animated) {
5133 return null == options && (options = {}), null == animated && (animated = null), this.related = null != options ? options.related : void 0, this.tracking = null != options ? options.tracking : void 0, this._show(msg, animated);
5134 }, $.prototype.setSource = function(layer) {
5135 return this.source = layer;
5136 }, $.prototype.setSiblings = function(oSequence2, inplace) {
5137 var body;
5138 var nIndex;
5139 var nLength;
5140 var oItem;
5141 if (null == inplace && (inplace = null), this._siblings = [], 0 === oSequence2.length) {
5142 $(".inner", this.container()).empty().css("width", 0);
5143 $(".next, .prev, .siblings", this.container()).hide();
5144 } else {
5145 body = $(".inner", this.container()).empty().css("width", oSequence2.length * this._trayItemWidth());
5146 /** @type {number} */
5147 nIndex = 0;
5148 nLength = oSequence2.length;
5149 for (; nIndex < nLength; nIndex++) {
5150 oItem = oSequence2[nIndex];
5151 this._siblings[oItem.id] = oItem;
5152 if (null != oItem.image_urls && null != oItem.image_urls[0]) {
5153 body.append("<img src='" + oItem.image_urls[0].replace("thumbnail", "medium") + "' data-lot-id='" + oItem.id + "' />");
5154 } else {
5155 if (null != oItem.main_image) {
5156 body.append("<img src='" + oItem.main_image.replace("thumbnail", "medium") + "' data-lot-id='" + oItem.id + "' />");
5157 }
5158 }
5159 }
5160 $(".next, .prev", this.container()).show();
5161 if ($(".siblings", this.container()).is(":hidden")) {
5162 $(".siblings", this.container()).slideDown();
5163 }
5164 }
5165 if (null != inplace) {
5166 return this._setCursor(inplace);
5167 }
5168 }, $.prototype.getSibling = function(event) {
5169 if (null != this._siblings) {
5170 return this._siblings[event];
5171 }
5172 }, $.prototype.hasReminderSet = function(timeoutKey) {
5173 return null != this._reminders && this._reminders[timeoutKey];
5174 }, $.prototype.setReminder = function(timeoutKey) {
5175 return null == this._reminders && (this._reminders = []), this._reminders[timeoutKey] = true;
5176 }, $.prototype.unsetReminder = function(timeoutKey) {
5177 return null == this._reminders && (this._reminders = []), this._reminders[timeoutKey] = false;
5178 }, $.prototype.reminderButtonOff = function() {
5179 return $("#reminder-btn").removeClass("btn-primary").addClass("btn-default").find("span").text(window.t.web.lot_modal.will_remind_you), $(".remind-me", "#lot-modal-content").removeClass("fa-heart-o").addClass("reminded fa-heart");
5180 }, $.prototype.reminderButtonOn = function(item) {
5181 return $("#reminder-btn").data("lot-id", item.id).removeClass("btn-default").addClass("btn-primary").find("span").text(window.t.web.lot_modal.set_a_reminder), $(".remind-me", "#lot-modal-content").removeClass("reminded fa-heart").addClass("fa-heart-o");
5182 }, $.prototype.setImage = function(tag) {
5183 return null == this._imageCache && (this._imageCache = []), this._imageCache[tag] = true;
5184 }, $.prototype.hasImage = function(value) {
5185 var clt;
5186 return null != (clt = this._imageCache) ? clt[value] : void 0;
5187 }, $.prototype.container = function() {
5188 return null != this._container ? this._container : this._container = $("#lot-modal");
5189 }, $.prototype._show = function(x, animated) {
5190 var lineSeparator;
5191 var pdataCur;
5192 var h;
5193 var gurl;
5194 return null == animated && (animated = null), this.lotId = parseInt(x), $(window).width() < 768 && (null == this.bodyHeight && (this.bodyHeight = $(window).height() - 200), this.template.find(".modal-body").css("height", this.bodyHeight)), this._setEventHandlers(), this.container().hasClass("modal") && (!this.container().hasClass("in") && this.container().modal()), lineSeparator = this.template.children(), this.template.empty().append(lineSeparator), $(".popover").hide(), h = this.source ?
5195 "?source=" + this.source : "", gurl = "/api/v1/lots/" + x + h, null != (pdataCur = this.getSibling(x)) ? (this._populateShallow(pdataCur), this._setCursor(pdataCur), $.getJSON(gurl, function(dataAndEvents) {
5196 return function(defs) {
5197 if (dataAndEvents._populateDeep(defs), null != animated) {
5198 return animated();
5199 }
5200 };
5201 }(this))) : $.getJSON(gurl, function(dataAndEvents) {
5202 return function(response) {
5203 if (dataAndEvents._populateShallow(response), dataAndEvents._populateDeep(response), dataAndEvents._setCursor(response), null != animated) {
5204 return animated();
5205 }
5206 };
5207 }(this));
5208 }, $.prototype._setEventHandlers = function() {
5209 if (null == this._listening) {
5210 return this._listening = true, $(document).on("hidden.bs.modal", ".modal", function() {
5211 return $(".modal:visible").length && $(document.body).addClass("modal-open");
5212 }), $(this.container()).on("click", ".prev", function(op) {
5213 return function() {
5214 var selected;
5215 var $col;
5216 if (!$(".inner", op.container()).is(":animated")) {
5217 return selected = $(".inner > img.current", op.container()), selected.length > 0 ? ($col = selected.prev(), 0 === $col.length && ($col = $(".inner > img:last", op.container()))) : $col = $(".inner > img:last", op.container()), op.show($col.data("lot-id"));
5218 }
5219 };
5220 }(this)), $(this.container()).on("click", ".next", function(op) {
5221 return function() {
5222 var $next;
5223 var $col;
5224 if (!$(".inner", op.container()).is(":animated")) {
5225 return $next = $(".inner > img.current", op.container()), $next.length > 0 ? ($col = $next.next(), 0 === $col.length && ($col = $(".inner > img:first", op.container()))) : $col = $(".inner > img:first", op.container()), op.show($col.data("lot-id"));
5226 }
5227 };
5228 }(this)), $(window).keyup(function(dataAndEvents) {
5229 return function(event) {
5230 if (37 === event.keyCode && ($("#lot-modal").is(":visible") && $(".prev", dataAndEvents.container()).trigger("click")), 39 === event.keyCode && $("#lot-modal").is(":visible")) {
5231 return $(".next", dataAndEvents.container()).trigger("click");
5232 }
5233 };
5234 }(this)), $(this.container()).on("click", ".siblings > .fa-chevron-left", function(dataAndEvents) {
5235 return function() {
5236 var a;
5237 var b;
5238 var wrapper;
5239 if (wrapper = $(".inner", dataAndEvents.container()), !wrapper.is(":animated")) {
5240 return a = parseInt(wrapper.css("left"), 10), b = dataAndEvents._trayWidth(), a + b > 0 && (b = Math.abs(a)), a < 0 ? wrapper.animate({
5241 left: "+=" + b + "px"
5242 }, 250) : wrapper.animate({
5243 left: -1 * wrapper.width() + dataAndEvents._trayItemWidth()
5244 }, 500);
5245 }
5246 };
5247 }(this)), $(this.container()).on("click", ".siblings > .fa-chevron-right", function(dataAndEvents) {
5248 return function() {
5249 var j;
5250 var left;
5251 var wrapper;
5252 var x;
5253 if (wrapper = $(".inner", dataAndEvents.container()), !wrapper.is(":animated")) {
5254 return j = parseInt(wrapper.css("left"), 10), x = -1 * wrapper.width() + dataAndEvents._trayItemWidth(), left = dataAndEvents._trayWidth(), j - left + 1 >= x ? wrapper.animate({
5255 left: "-=" + left + "px"
5256 }, 250) : wrapper.animate({
5257 left: 0
5258 }, 500);
5259 }
5260 };
5261 }(this)), $(this.container()).on("click", ".inner > img", function(dataAndEvents) {
5262 return function(e) {
5263 var current;
5264 if (1 === e.which) {
5265 return current = $(e.currentTarget), current.parent().find(".current").removeClass("current"), current.addClass("current"), dataAndEvents.show(current.data("lot-id"));
5266 }
5267 };
5268 }(this)), $(this.container()).on("click", ".thumbnails > img", function(_this) {
5269 return function(e) {
5270 var el;
5271 var img;
5272 if (1 === e.which) {
5273 if ($(e.currentTarget).hasClass("selected")) {
5274 return;
5275 }
5276 return img = $(e.currentTarget).attr("src").replace("thumbnail", "large"), $(".thumbnails > img", _this.container()).removeClass("selected"), $(e.currentTarget).addClass("selected"), el = $(".main", _this.container()), el.attr("src", img), el.one("load", function() {
5277 return _this.setImage(img);
5278 });
5279 }
5280 };
5281 }(this)), $(this.container()).on("click", ".facebook-send", function(dataAndEvents) {
5282 return function(ev) {
5283 return -1 !== navigator.userAgent.indexOf("MSIE") && dataAndEvents.container().modal("hide"), FB.ui($.extend({
5284 method: "feed"
5285 }, $(ev.currentTarget).data()));
5286 };
5287 }(this)), $(this.container()).on("click", "#reminder-btn", function(types) {
5288 return types.preventDefault(), $(this).parent().find(".remind-me").trigger("click");
5289 });
5290 }
5291 }, $.prototype._setCursor = function(data) {
5292 var next;
5293 if (next = $(".inner > img[data-lot-id=" + data.id + "]", this.container()), next.length > 0) {
5294 return $(".inner > img.current", this.container()).removeClass("current"), next.addClass("current"), $(".inner", this.container()).animate({
5295 left: -1 * next.position().left
5296 }, 250);
5297 }
5298 }, $.prototype._trayItemWidth = function() {
5299 return 86;
5300 }, $.prototype._trayWidth = function() {
5301 return 8 * this._trayItemWidth();
5302 }, $.prototype._populateShallow = function(value) {
5303 return this._populateHeaderAndFooter(value), this._populateMainImage(value);
5304 }, $.prototype._populateDeep = function(a) {
5305 var r20;
5306 if (this._populateThumbnails(a), this._populateSharing(a), this._populateSizing(a), this._populateActions(a), this._populateDescription(a), this.related && this._populateRelated(a), null != window.slotClient && this._listenForSlotClientEvents(a), r20 = null != ("undefined" != typeof current_user && null !== current_user ? current_user.email : void 0) ? current_user.email.toLowerCase() : null, null == window.fbq && ("undefined" != typeof facebookPixelInit && (null !== facebookPixelInit && facebookPixelInit("1472889202927380",
5307 r20))), null != a.product_parent_id && (null != window.fbq && window.fbq("track", "ViewContent", {
5308 content_ids: [String(a.product_parent_id)],
5309 content_type: "product"
5310 }), null != window.twq)) {
5311 return window.twq("track", "ViewContent", {
5312 content_ids: [String(a.product_parent_id)],
5313 content_type: "product"
5314 });
5315 }
5316 }, $.prototype._populateHeaderAndFooter = function(item) {
5317 var ret;
5318 var oSpace;
5319 var j;
5320 var n;
5321 var _j;
5322 var rreturn;
5323 var _ref1;
5324 var i;
5325 if (null != item.title && $(".title", this.container()).text(item.title), null != item.condition && (ret = $(".condition", this.container()), ret.text(item.condition).removeClass("label-primary label-warning label-info label-danger label-default"), rreturn = function() {
5326 switch (item.condition) {
5327 case "New":
5328 return "label-warning";
5329 case "New with Tags":
5330 return "label-primary";
5331 case "New with Defects":
5332 return "label-danger";
5333 case "Used":
5334 ;
5335 case "Used - Excellent":
5336 ;
5337 case "Used - Good":
5338 ;
5339 case "Used - Fair":
5340 return "label-info";
5341 case "Refurbished":
5342 ;
5343 case "Refurbished - Manufacturer":
5344 ;
5345 case "Refurbished - Seller":
5346 return "label-danger";
5347 default:
5348 return "label-default";
5349 }
5350 }(), ret.addClass(rreturn)), window.isLoggedIn() && (null == item.bidding_started_at && null == item.bidding_ended_at) ? $(".report", this.container()).data("reportable-id", item.id) : $(".report", this.container()).hide(), $(".r-stars.lot-modal-stars").find(".fa").removeClass("fa-star fa-star-o fa-star-half-o").addClass("fa-star-o"), null != item.ratings_average && (item.ratings_average > 0 && (null != item.ratings_total && item.ratings_total > 0))) {
5351 if (i = parseInt(item.ratings_average), j = parseFloat(item.ratings_average) % 1 >= 0, oSpace = $(".r-stars.lot-modal-stars").find(".fa"), i > 0) {
5352 /** @type {number} */
5353 n = _j = 0;
5354 /** @type {number} */
5355 _ref1 = i - 1;
5356 for (; 0 <= _ref1 ? _j <= _ref1 : _j >= _ref1; n = 0 <= _ref1 ? ++_j : --_j) {
5357 $(oSpace[n]).removeClass("fa-star-o").addClass("fa-star");
5358 }
5359 }
5360 return j && $(oSpace[i]).removeClass("fa-star-o").addClass("fa-star-half-o"), $(".r-stars.lot-modal-stars").show().find(".rating").text("(" + item.ratings_count + ")");
5361 }
5362 return $(".r-stars.lot-modal-stars").hide();
5363 }, $.prototype._populateMainImage = function(xs) {
5364 var wrapper;
5365 var text;
5366 var _len;
5367 var output;
5368 return this.imageIndex = 0, text = null != (null != (_len = xs.image_urls) ? _len[this.imageIndex] : void 0) ? xs.image_urls[this.imageIndex].replace("thumbnail", "large") : null != (output = xs.main_image) ? output.replace("thumbnail", "large") : void 0, wrapper = $(".main", this.container()), wrapper.attr("src", text), wrapper.one("load", function(_this) {
5369 return function() {
5370 return _this.setImage(text);
5371 };
5372 }(this)), $(".main", this.container()).show();
5373 }, $.prototype._populateThumbnails = function(result) {
5374 var j;
5375 var n;
5376 var subLn;
5377 var width;
5378 var source;
5379 var dirNames;
5380 var messages;
5381 var name;
5382 if ($(".thumbnails img", this.container()).remove(), null != result.image_urls) {
5383 dirNames = result.image_urls;
5384 /** @type {number} */
5385 j = 0;
5386 subLn = dirNames.length;
5387 for (; j < subLn; j++) {
5388 name = dirNames[j];
5389 $(".thumbnails", this.container()).append($("<img />").attr("src", name));
5390 }
5391 }
5392 if ($(".thumbnails > img:eq(" + this.imageIndex + ")", this.container()).addClass("selected"), source = $(".inner > img[data-lot-id=" + result.id + "]")) {
5393 /** @type {Array} */
5394 messages = [];
5395 /** @type {number} */
5396 n = 1;
5397 for (; n <= 5 && (source = source.next()).length > 0; ++n) {
5398 width = source.attr("src").replace("medium", "large");
5399 if (!this.hasImage(width)) {
5400 this.setImage(width);
5401 messages.push($("<img />").attr("src", width));
5402 }
5403 }
5404 return messages;
5405 }
5406 }, $.prototype._populateSharing = function(object) {
5407 var baseUrl;
5408 var h;
5409 var g;
5410 var b;
5411 return h = $(".main", this.container()).attr("src"), g = window.isLoggedIn() ? window.currentUser.id : -1, b = this.source ? "&source=" + this.source : "", baseUrl = "http://" + Config.sharedInstance().host + "/lots/" + object.id + "?ref=" + g + b, $(".facebook-send", this.container()).data({
5412 name: object.title,
5413 link: baseUrl + "&campaign=facebook-lot-modal",
5414 picture: h,
5415 description: object.description
5416 }), $(".twitter-send", this.container()).off("click"), $(".twitter-send", this.container()).on("click", function() {
5417 return window.open("https://twitter.com/share?url=" + (baseUrl + encodeURIComponent("&campaign=twitter-share")) + "&text=" + encodeURIComponent(object.title.replace(/'/g, "\\'")), "tweet", "height=300,width=665");
5418 }), $(".pinterest-send", this.container()).off("click"), $(".pinterest-send", this.container()).on("click", function() {
5419 return window.open("http://pinterest.com/pin/create/button/?url=" + (baseUrl + encodeURIComponent("&source=pinterest&campaign=pinterest-share&ad_group=web")) + "&media=" + encodeURIComponent(h) + "&description=" + encodeURIComponent(object.title.replace(/'/g, "\\'") + ". Starting at $" + object.starting_bid_amount), "signin", "height=300,width=665");
5420 }), $(".fa-paperclip", this.container()).attr("href", baseUrl), $(".sharing", this.container()).show();
5421 }, $.prototype._populateSizing = function(v02) {
5422 var i;
5423 var ln;
5424 var name;
5425 var configList;
5426 var eventPath;
5427 if ($("#sizing-lot-modal").toggle(null != v02.sizing_ratings), null != v02.sizing_ratings) {
5428 /** @type {Array} */
5429 configList = ["small", "right", "large"];
5430 /** @type {Array} */
5431 eventPath = [];
5432 /** @type {number} */
5433 i = 0;
5434 /** @type {number} */
5435 ln = configList.length;
5436 for (; i < ln; i++) {
5437 name = configList[i];
5438 $(".sizing-bar." + name).css("width", v02.sizing_ratings[name + "_percent"] + "%");
5439 eventPath.push($(".total-ratings." + name).html(v02.sizing_ratings[name + "_count"]));
5440 }
5441 return eventPath;
5442 }
5443 }, $.prototype._populateActions = function(item) {
5444 var fn1;
5445 var parentNode;
5446 var discount;
5447 var basket;
5448 var test_strings;
5449 var ret;
5450 return parentNode = {
5451 "lot-id": item.id,
5452 "product-parent-id": item.product_parent_id,
5453 page: this.source
5454 }, $(".buy-it-now").data(parentNode), $(".remind-me", "#lot-modal-content").data(parentNode), window.Criteo.sharedInstance().push({
5455 event: "viewItem",
5456 item: item.product_parent_id
5457 }), item.alert || (null != (basket = this._reminders) ? basket[item.id] : void 0) ? this.reminderButtonOff(item) : this.reminderButtonOn(item), $("#set-reminder .starting-bid-amount").text(window.translate(window.t.web.lot_modal.starting_bid, {
5458 amount_with_symbol: item.starting_bid_amount_with_symbol
5459 })), $("#set-reminder .reminder-count").text((null != (test_strings = this._reminders) ? test_strings[item.id] : void 0) ? item.alerts_count + 1 : item.alerts_count), discount = null != item.retail_price && (null != item.buy_now_price_local && parseInt(item.retail_price_local) > parseInt(item.buy_now_price_local)) ? parseInt((parseFloat(item.retail_price_local) - parseFloat(item.buy_now_price_local)) / parseFloat(item.retail_price_local) * 100) : 0, (null != (ret = window.currentUser) ? ret.id :
5460 void 0) === item.user_id && $("#buy-btn").attr("disabled", "disabled"), $("#buy-btn span").text(window.translate(window.t.web.lot_modal.buy_now_for, {
5461 price_with_symbol: item.buy_now_price_with_symbol
5462 })), $("#buy .buy-now").text("" + item.buy_now_price_with_symbol), $("#buy .msrp").text("" + item.retail_price_with_partial_symbol), $("#buy .discount").text(window.translate(window.t.web.lot_modal.discount, {
5463 discount: discount
5464 })), $("#buy .row").toggle(discount > 0), this.$bidContainer.toggle(null != item.activated_at && (null == item.buyer_id && null == item.bidding_ended_at)), $("#set-reminder").toggle(null == item.activated_at && null == item.buyer_id), $("#buy").toggle(null != item.buy_now_price_local), fn1 = $(".panel-body", "#actions").children(':not([style*="display: none"])').length > 0, $("#actions").toggle(fn1);
5465 }, $.prototype._populateDescription = function(data) {
5466 var attributes;
5467 var n;
5468 var res;
5469 var j;
5470 var i;
5471 var axis;
5472 var jl;
5473 var l;
5474 var not;
5475 var employees;
5476 var photos;
5477 var _ref;
5478 var normals;
5479 var root;
5480 var user;
5481 var globals;
5482 var _ref26;
5483 var theEvent;
5484 var employee;
5485 var renderedContent;
5486 var str;
5487 if (null == data.activated_at && (null == data.buyer_id && null != data.buy_now_price_local) ? $("#details").css({
5488 height: "200px"
5489 }) : null == data.activated_at && null == data.buyer_id ? $("#details").css({
5490 height: "300px"
5491 }) : $("#details").css({
5492 height: "400px"
5493 }), $("#shipping-lot-modal, #description-lot-modal, #protection-lot-modal, #seller-lot-modal").hide(), ((null != (not = data.shipping_description_local) ? not.length : void 0) || null != data.expedited_shipping) && $("#shipping-lot-modal").show(), (null != (photos = data.shipping_description_local) ? photos.length : void 0) ? $("#shipping-lot-modal").find("p.shipping").show().text(data.shipping_description_local) : $("#shipping-lot-modal").find("p.shipping").hide().empty(), null != data.expedited_shipping ?
5494 (attributes = {
5495 deliver_in_days: data.expedited_shipping.estimated_days_to_deliver,
5496 count: data.expedited_shipping.estimated_days_to_deliver
5497 }, $("#shipping-lot-modal").find("p.expedited").show().html(window.translate(window.t.web.lot_modal.expedited_shipping, attributes))) : $("#shipping-lot-modal").find("p.expedited").hide().empty(), null != (_ref = data.description) ? _ref.length : void 0) {
5498 if (data.alternate_title || data.facets) {
5499 if (res = "", data.alternate_title && (res += window.t.web.lot_modal.brand + ": <b>" + data.alternate_title + "</b><br />"), data.facets && $.isArray(data.facets)) {
5500 normals = data.facets;
5501 /** @type {number} */
5502 j = 0;
5503 jl = normals.length;
5504 for (; j < jl; j++) {
5505 n = normals[j];
5506 axis = n[0];
5507 str = n[1];
5508 res += axis + ": <b>" + str.escapeTags() + "</b><br />";
5509 }
5510 }
5511 if (null != (root = window.currentUser) ? root.admin : void 0) {
5512 res += window.t.web.lot_modal.item + " #: <a href='/lots/" + data.id + "'>" + data.id + "</a><br />";
5513 }
5514 if (null != (user = window.currentUser) ? user.admin : void 0) {
5515 res += window.t.web.lot_modal.admin + " #: <a href='/admin/lots/" + data.id + "'>" + data.id + "</a><br />";
5516 }
5517 res += "<br />";
5518 } else {
5519 /** @type {string} */
5520 res = "";
5521 }
5522 $("#description-lot-modal").show().find("p").html("" + res + data.description.escapeTags().format());
5523 }
5524 if ((null != (globals = data.new_guarantee) ? globals.length : void 0) ? $("#protection-lot-modal").show().find("p").text("" + data.new_guarantee) : (null != (_ref26 = data.guarantee) ? _ref26.length : void 0) && $("#protection-lot-modal").show().find("p").text("" + data.guarantee), null != data.seller_name && null != data.user_id) {
5525 if (attributes = {
5526 user_id: data.user_id,
5527 seller_name: data.seller_name,
5528 lots_sold: data.seller_lots_sold.toLocaleString()
5529 }, (null != (theEvent = window.currentUser) ? theEvent.admin : void 0) ? $("#seller-lot-modal").show().find("p").html(window.translate(window.t.web.lot_modal.items_sold_admin, attributes)) : $("#seller-lot-modal").show().find("p").html(window.translate(window.t.web.lot_modal.items_sold, attributes)), null != data.lot_upsells && data.lot_upsells.length) {
5530 /** @type {string} */
5531 renderedContent = "";
5532 employees = data.lot_upsells;
5533 /** @type {number} */
5534 i = 0;
5535 l = employees.length;
5536 for (; i < l; i++) {
5537 employee = employees[i];
5538 renderedContent += "· " + employee.full_description.escapeTags() + "<br />";
5539 }
5540 $("#upsell-lot-modal").show().find("p").html(renderedContent);
5541 } else {
5542 $("#upsell-lot-modal").hide().find("p").html("");
5543 }
5544 }
5545 return $("#details").scrollTop(0);
5546 }, $.prototype._populateRelated = function(result) {
5547 return $("#lot-modal-related").hide(), $.getJSON("/api/v1/similarities/" + result.id + "/related_products.json", function(data) {
5548 var which;
5549 var key;
5550 var $items;
5551 var errorClass;
5552 var not;
5553 var map;
5554 var node;
5555 var eventPath;
5556 if (null != (null != (not = data.related) ? not.length : void 0)) {
5557 $("#lot-modal-related").show();
5558 $(".panel", "#lot-modal-related").hide();
5559 map = data.related;
5560 /** @type {Array} */
5561 eventPath = [];
5562 for (key in map) {
5563 node = map[key];
5564 /** @type {number} */
5565 errorClass = parseInt(key) + 1;
5566 $items = $("#lot-modal-related .panel-catalog-" + errorClass);
5567 if (0 !== $items.length) {
5568 which = {
5569 "data-lot-id": node.id,
5570 "data-product-parent-id": node.product_parent_id
5571 };
5572 $items.find("img").attr(which);
5573 $items.find(".buy-it-now").attr(which);
5574 $items.find(".remind-me").attr(which);
5575 $items.find("img").attr("src", node.main_image.replace("thumbnail", "medium"));
5576 $items.find(".msrp").toggle(null != node.retail_price_with_partial_symbol);
5577 $items.find(".price").toggle(null != node.buy_now_price);
5578 $items.find(".buy-it-now").toggle(null != node.buy_now_price);
5579 if (null != node.retail_price_with_partial_symbol) {
5580 $items.find(".msrp").text(node.retail_price_with_partial_symbol);
5581 }
5582 if (null != node.buy_now_price) {
5583 $items.find(".price").text(node.buy_now_price_with_symbol);
5584 }
5585 if (node.alert) {
5586 $items.find(".remind-me").removeClass("fa-heart-o").addClass("reminded fa-heart");
5587 } else {
5588 $items.find(".remind-me").removeClass("reminded fa-heart").addClass("fa-heart-o");
5589 }
5590 $items.find(".reminder-count").text(node.alerts_count);
5591 eventPath.push($items.show());
5592 }
5593 }
5594 return eventPath;
5595 }
5596 });
5597 }, $.prototype._listenForSlotClientEvents = function(data) {
5598 var linkRootElement;
5599 if (this.bidButton = null, this.bidCount = null, this.retail = null, this.discount = null, this.nextMessageIn = null, window.slotClient.removeListener("lot-modal"), null != (linkRootElement = SlotClient.sharedInstance()._slots[data.id])) {
5600 return this.slot = LotModalAuctionSlot.buildFrom(linkRootElement), window.slotClient.addListener("lot-modal", function(dataAndEvents) {
5601 return function(opt_e) {
5602 return dataAndEvents._handleSlotClientEvent(data, opt_e);
5603 };
5604 }(this)), this.template.one("hidden.bs.modal", function() {
5605 return window.slotClient.removeListener("lot-modal");
5606 });
5607 }
5608 }, $.prototype._handleSlotClientEvent = function(head, val) {
5609 var name;
5610 if (head.id === (null != (name = val.metadata) ? name.lot_id : void 0)) {
5611 return this.slot.paint(val);
5612 }
5613 }, $;
5614 }();
5615 }.call(this),
5616 function() {
5617 /** @type {function (this:(Array.<T>|string|{length: number}), T, number=): number} */
5618 var callback = [].indexOf || function(key) {
5619 /** @type {number} */
5620 var i = 0;
5621 var l = this.length;
5622 for (; i < l; i++) {
5623 if (i in this && this[i] === key) {
5624 return i;
5625 }
5626 }
5627 return -1;
5628 };
5629 window.PayFlow = function() {
5630 /**
5631 * @return {undefined}
5632 */
5633 function self() {}
5634 return self.start = function(data, persistent) {
5635 if (this.product = data.product, this.pricing = data.pricing, this.variations = data.variations, this.upsells = data.upsells, this.expeditedShipping = data.expedited_shipping, this.paymentMethods = data.payment_methods, this.shippingAddresses = data.shipping_addresses, this.paypalData = data.paypal, this.token = data.token, this.error = data.error, this.variants = data.variants, this.paypalEnabled = callback.call(data.supported_payment_methods, "paypal") >= 0, this.sizingRating = data.product.sizing_ratings,
5636 this.container = $("#pay-flow"), this.addressChangeAllowed = this.shippingAddresses.length > 0, this.hosted_fields_instance = null, this.invoiceId = null, this.lotId = null, this.payingWithPaypal = null, this.paypalEnabled || (this.payingWithPaypal = false), this.shippingAddressOverride = null, this.variationId = null, this.paymentMethodToken = null, this.shippingAddressId = null, this.upsellIds = {}, this.expeditedShippingId = null, this.setInvoiceId(data.invoice_id), this.setLotId(data.lot_id),
5637 this.events(), this.ui(), this.goToNext(), null != persistent) {
5638 return persistent();
5639 }
5640 }, self.reset = function() {
5641 return this.product = null, this.pricing = null, this.variations = null, this.upsells = null, this.expeditedShipping = null, this.paymentMethods = null, this.shippingAddresses = null, this.paypalData = null, this.token = null, this.error = null, this.variants = null, this.sizingRating = null, this.container = null, this.addressChangeAllowed = null, this.hosted_fields_instance = null, this.invoiceId = null, this.lotId = null, this.payingWithPaypal = null, this.shippingAddressOverride = null,
5642 this.variationId = null, this.paymentMethodToken = null, this.shippingAddressId = null, this.upsellIds = null, this.expeditedShippingId = null;
5643 }, self.hostedFields = function() {
5644 return this.hosted_fields_instance && ($(".new-credit-card-button").off("click"), $(".new-credit-card-button").val(window.t.common.actions["continue"]), $(".new-credit-card-button").prop("disabled", false), this.hosted_fields_instance.teardown(), this.hosted_fields_instance = null), "undefined" != typeof braintree && null !== braintree ? braintree.client.create({
5645 authorization: this.token
5646 }, function(obj) {
5647 return function(err, client) {
5648 return err ? (console.error(err.message), void Rollbar.warning("Failed to create Braintree hosted fields client instance", {
5649 error: err
5650 })) : braintree.hostedFields.create({
5651 client: client,
5652 styles: {
5653 input: {
5654 "@include box-shadow(none)": "@include box-shadow(none)",
5655 height: "42px",
5656 "font-size": "16px",
5657 padding: "10px",
5658 "border-width": "2px"
5659 }
5660 },
5661 fields: {
5662 number: {
5663 selector: "#payment-method-number",
5664 placeholder: "\u2022\u2022\u2022\u2022 \u2022\u2022\u2022\u2022 \u2022\u2022\u2022\u2022 \u2022\u2022\u2022\u2022"
5665 },
5666 expirationDate: {
5667 selector: "#payment-method-expiration-date",
5668 placeholder: "MM/YY"
5669 },
5670 cvv: {
5671 selector: "#payment-method-cvv",
5672 placeholder: "\u2022\u2022\u2022"
5673 },
5674 postalCode: {
5675 selector: "#payment-method-postal-code",
5676 placeholder: obj.shippingAddressOverride ? obj.shippingAddressOverride.postalCode : "12345"
5677 }
5678 }
5679 }, function(err, state) {
5680 return err ? (console.error(err.message), void Rollbar.warning("Failed to create Braintree hosted fields instance", {
5681 error: err
5682 })) : (obj.hosted_fields_instance = state, state.on("validityChange", function(expression) {
5683 var e;
5684 e = expression.fields[expression.emittedBy];
5685 if (e.isValid) {
5686 $(e.container).removeClass("braintree-hosted-fields-invalid-custom");
5687 }
5688 }), state.on("inputSubmitRequest", function() {
5689 $(".new-credit-card-button").click();
5690 }), $(".new-credit-card-button").on("click", function(types) {
5691 var tagNameArr;
5692 var e;
5693 var o;
5694 var _i;
5695 var errors;
5696 var name;
5697 var _len;
5698 var testSource;
5699 var me;
5700 var index;
5701 types.preventDefault();
5702 $("#new-payment-method-error").empty().hide();
5703 me = state.getState();
5704 /** @type {Array} */
5705 errors = [];
5706 /** @type {boolean} */
5707 o = true;
5708 /** @type {Array.<string>} */
5709 testSource = Object.keys(me.fields);
5710 for (name in testSource) {
5711 /** @type {string} */
5712 index = testSource[name];
5713 e = me.fields[index];
5714 if (!e.isValid) {
5715 /** @type {boolean} */
5716 o = false;
5717 errors.push(e);
5718 }
5719 }
5720 if (o) {
5721 return $(".new-credit-card-button").prop("disabled", true), $(".new-credit-card-button").val(window.t.common.wait_messages.loading), state.tokenize(function(err, artifacts) {
5722 return err ? (console.error(err.message), void Rollbar.error("Failed to tokenize credit card", {
5723 error: err
5724 })) : $.ajax({
5725 type: "POST",
5726 url: "/api/v1/payment_methods.json",
5727 data: {
5728 nonce: artifacts.nonce
5729 },
5730 /**
5731 * @return {?}
5732 */
5733 beforeSend: function() {
5734 return $("#new-payment-method-error").empty().hide();
5735 },
5736 /**
5737 * @param {?} doc
5738 * @return {?}
5739 */
5740 success: function(doc) {
5741 return obj.paymentMethods.push(doc), obj.addPaymentMethod(doc), obj.setPaymentMethod(doc), obj.goToNext();
5742 },
5743 /**
5744 * @param {string} xhr
5745 * @return {?}
5746 */
5747 error: function(xhr) {
5748 var err;
5749 return err = JSON && JSON.parse(xhr.responseText) || $.parseJSON(xhr.responseText), $("#new-payment-method-error").text(err.message + ".").show(), console.error(err.message), obj.resetHostedFieldsFormSubmit();
5750 }
5751 });
5752 });
5753 }
5754 /** @type {Array} */
5755 tagNameArr = [];
5756 /** @type {number} */
5757 _i = 0;
5758 /** @type {number} */
5759 _len = errors.length;
5760 for (; _i < _len; _i++) {
5761 e = errors[_i];
5762 $(e.container).addClass("braintree-hosted-fields-invalid-custom");
5763 tagNameArr.push($(e.container).prev().text().toLowerCase());
5764 }
5765 return $("#new-payment-method-error").html(window.translate(window.t.payflow.problem_with_field_html, {
5766 field: tagNameArr.join(", ")
5767 })).show();
5768 }));
5769 });
5770 };
5771 }(this)) : void 0;
5772 }, self.dropInPayPal = function() {
5773 var lifecycle;
5774 return $(document).on("click", ".sofort", function(dataAndEvents) {
5775 return function() {
5776 var dat;
5777 var n;
5778 return dataAndEvents.disablePayments(), dat = window.location.protocol + "//" + window.location.host + "/invoices/" + window.PayFlow.invoiceId + "/authorize", n = window.open(dat, "", "height=500,width=500"), n.onbeforeunload = function() {
5779 return dataAndEvents.enablePayments();
5780 };
5781 };
5782 }(this)), null != (null != (lifecycle = this.integration) ? lifecycle.teardown : void 0) ? this.integration.teardown(function(dataAndEvents) {
5783 return function() {
5784 return dataAndEvents.integration = null, dataAndEvents.dropInPayPal();
5785 };
5786 }(this)) : "undefined" != typeof braintree && null !== braintree ? braintree.setup(this.token, "custom", {
5787 onReady: function(dataAndEvents) {
5788 return function(deepDataAndEvents) {
5789 return dataAndEvents.integration = deepDataAndEvents, $(".paypal").removeAttr("disabled").prop("disabled", false);
5790 };
5791 }(this),
5792 /**
5793 * @return {undefined}
5794 */
5795 onUnsupported: function() {},
5796 /**
5797 * @return {undefined}
5798 */
5799 onCancelled: function() {},
5800 /**
5801 * @return {undefined}
5802 */
5803 onAuthorizationDismissed: function() {},
5804 /**
5805 * @param {Error} e
5806 * @return {?}
5807 */
5808 onError: function(e) {
5809 return window.notifyError(e.message);
5810 },
5811 onPaymentMethodReceived: function(self) {
5812 return function(data) {
5813 var item;
5814 return $("#pay_flow_nonce").val(data.nonce), self.disablePayments(), $("#new_payment_method .new-credit-card-button").val(window.t.web.pay_flow.paypal.completing_payment), $(".processing-notice").show(), null != data.details && ($("#pay_flow_payer_id").val(data.details.payerId), null != (item = data.details.shippingAddress) && ($("#pay_flow_name").val(item.recipientName), $("#pay_flow_address1").val(item.streetAddress), $("#pay_flow_address2").val(item.extendedAddress), $("#pay_flow_city").val(item.locality),
5815 $("#pay_flow_state").val(item.region), $("#pay_flow_zip").val(item.postalCode), $("#pay_flow_country").val(item.countryCodeAlpha2), $("#pay_flow_phone").val(item.phone), "US" !== item.countryCodeAlpha2)) ? void self.paypalConfirm(item, data.details.email) : $("form", "#confirm").submit();
5816 };
5817 }(this),
5818 paypal: {
5819 displayName: null != window.app ? self.capitalize(window.app) : "",
5820 singleUse: true,
5821 amount: this.paypalData.total,
5822 currency: this.paypalData.currency_code,
5823 locale: "en_us",
5824 enableShippingAddress: true,
5825 shippingAddressOverride: this.shippingAddressOverride,
5826 headless: true
5827 }
5828 }) : void 0;
5829 }, self.disablePayments = function() {
5830 return $("#new_payment_method input, .btn-back, .easy-paypal, .sofort").attr("disabled", "disabled").prop("disabled", true);
5831 }, self.enablePayments = function() {
5832 return $("#new_payment_method input, .btn-back, .easy-paypal, .sofort").removeAttr("disabled", "").prop("disabled", false);
5833 }, self.resetHostedFieldsFormSubmit = function() {
5834 return $(".new-credit-card-button").val(window.t.common.actions["continue"]), $(".new-credit-card-button").prop("disabled", false);
5835 }, self.events = function() {
5836 if (!this.container.hasClass("pay-flow-initialized")) {
5837 return this.container.addClass("pay-flow-initialized"), $(document).on("click", ".go-to-select-variation", function(dataAndEvents) {
5838 return function(types) {
5839 return types.preventDefault(), dataAndEvents.goTo("select-variation");
5840 };
5841 }(this)), $(document).on("click", ".go-to-new-payment-method", function(dataAndEvents) {
5842 return function(types) {
5843 return types.preventDefault(), dataAndEvents.goTo("new-payment-method"), dataAndEvents.resetHostedFieldsFormSubmit();
5844 };
5845 }(this)), $(document).on("click", ".go-to-select-payment-method", function(dataAndEvents) {
5846 return function(types) {
5847 return types.preventDefault(), dataAndEvents.setPaymentMethod(null), dataAndEvents.goToNext();
5848 };
5849 }(this)), $(document).on("click", ".leave-new-payment-method", function(first) {
5850 return function(types) {
5851 return types.preventDefault(), first.setPaymentMethod(null), 0 === first.paymentMethods.length ? first.goTo("select-shipping-address") : first.goToNext();
5852 };
5853 }(this)), $(document).on("click", ".go-to-new-shipping-address", function(dataAndEvents) {
5854 return function(types) {
5855 return types.preventDefault(), dataAndEvents.goTo("new-shipping-address");
5856 };
5857 }(this)), $(document).on("click", ".go-to-select-shipping-address", function(first) {
5858 return function(types) {
5859 return types.preventDefault(), first.shippingAddresses.length > 0 ? first.goTo("select-shipping-address") : first.goTo("select-credit-card-or-paypal");
5860 };
5861 }(this)), $(document).on("click", ".go-to-next", function(dataAndEvents) {
5862 return function() {
5863 return dataAndEvents.goToNext();
5864 };
5865 }(this)), $(document).on("click", ".did-select-credit-card", function(dataAndEvents) {
5866 return function(types) {
5867 return types.preventDefault(), dataAndEvents.setPayingWithPaypal(false), dataAndEvents.goToNext();
5868 };
5869 }(this)), $(document).on("click", ".easy-paypal", function(protoProps) {
5870 return function(types) {
5871 var child;
5872 return types.preventDefault(), protoProps.setPayingWithPaypal(true), null != (null != (child = protoProps.integration) ? child.paypal : void 0) && protoProps.integration.paypal.initAuthFlow(), $("#pay-with-credit-card").hide();
5873 };
5874 }(this)), $(document).on("click", ".did-select-variation", function(dataAndEvents) {
5875 return function(event) {
5876 return event.preventDefault(), dataAndEvents.setVariation($(event.currentTarget).data("variation")), dataAndEvents.goToNext();
5877 };
5878 }(this)), $(document).on("click", ".did-select-payment-method", function(dataAndEvents) {
5879 return function(event) {
5880 return event.preventDefault(), dataAndEvents.setPaymentMethod($(event.currentTarget).data("payment-method")), dataAndEvents.goToNext();
5881 };
5882 }(this)), $(document).on("click", ".did-select-shipping-address", function(dataAndEvents) {
5883 return function(event) {
5884 return event.preventDefault(), dataAndEvents.setShippingAddress($(event.currentTarget).data("shipping-address")), dataAndEvents.goToNext();
5885 };
5886 }(this)), $("#new_mailing_address").on("ajax:success", function(that) {
5887 return function(dataAndEvents, k) {
5888 return that.shippingAddresses.push(k), $("#new-shipping-address-back").show(), that.addShippingAddress(k), that.setShippingAddress(k), that.goToNext();
5889 };
5890 }(this)), $("#new_payment_method").on("ajax:success", function(a) {
5891 return function(dataAndEvents, next_scope) {
5892 return a.paymentMethods.push(next_scope), a.addPaymentMethod(next_scope), a.setPaymentMethod(next_scope), a.goToNext();
5893 };
5894 }(this)), $(document).on("click", ".did-select-upsell", function(dataAndEvents) {
5895 return function(event) {
5896 return event.preventDefault(), dataAndEvents.addUpsellId($(event.currentTarget).data("upsell-id")), $(event.currentTarget).removeClass("did-select-upsell btn-success").addClass("did-unselect-upsell btn-danger"), $(event.currentTarget).find(".fa-plus-circle").removeClass("fa-plus-circle").addClass("fa-minus-circle");
5897 };
5898 }(this)), $(document).on("click", ".did-unselect-upsell", function(dataAndEvents) {
5899 return function(event) {
5900 return event.preventDefault(), dataAndEvents.removeUpsellId($(event.currentTarget).data("upsell-id")), $(event.currentTarget).removeClass("did-unselect-upsell btn-danger").addClass("did-select-upsell btn-success"), $(event.currentTarget).find(".fa-minus-circle").removeClass("fa-minus-circle").addClass("fa-plus-circle");
5901 };
5902 }(this)), $(document).on("click", ".did-select-expedited", function(dataAndEvents) {
5903 return function(event) {
5904 return event.preventDefault(), dataAndEvents.setExpeditedShippingId($(event.currentTarget).data("expedited-shipping-id")), $(event.currentTarget).removeClass("did-select-expedited btn-success").addClass("did-unselect-expedited btn-danger"), $(event.currentTarget).find(".fa-plus-circle").removeClass("fa-plus-circle").addClass("fa-minus-circle");
5905 };
5906 }(this)), $(document).on("click", ".did-unselect-expedited", function(dataAndEvents) {
5907 return function(event) {
5908 return event.preventDefault(), dataAndEvents.setExpeditedShippingId(null), $(event.currentTarget).removeClass("did-unselect-expedited btn-danger").addClass("did-select-expedited btn-success"), $(event.currentTarget).find(".fa-minus-circle").removeClass("fa-minus-circle").addClass("fa-plus-circle");
5909 };
5910 }(this)), $("#new_mailing_address").on("ajax:beforeSend", function() {
5911 return $("#new-shipping-address-error").empty().hide();
5912 }), $("#new_mailing_address").on("ajax:error", function(dataAndEvents, transport) {
5913 var message;
5914 var r;
5915 return message = null != (null != (r = transport.responseJSON) ? r.error_info : void 0) ? transport.responseJSON.error_info.message : transport.responseText, $("#new-shipping-address-error").text(message).show();
5916 }), $("#country").on("change", function() {
5917 var _this;
5918 var GBR;
5919 return $(".regions").removeAttr("name").removeAttr("required").hide(), $("#regions-" + $(this).val()).length > 0 ? (_this = $("#regions-" + $(this).val()), $("label.mailing-address-state").text(_this.data("label")).show(), _this.attr({
5920 required: true,
5921 name: "state"
5922 }).show()) : (_this = $("#regions-OTHER"), $("label.mailing-address-state").text(_this.data("label")).show(), "GBR" === (GBR = $(this).val()) || ("NZL" === GBR || "ZAF" === GBR) ? $("label.mailing-address-state").hide() : _this.attr({
5923 required: true,
5924 name: "state"
5925 }).show());
5926 }), $("#new_payment_method").on("ajax:beforeSend", function() {
5927 return $("#new-payment-method-error").empty().hide();
5928 }), $("#new_payment_method").on("ajax:error", function(dataAndEvents, transport) {
5929 var message;
5930 var r;
5931 return message = null != (null != (r = transport.responseJSON) ? r.error_info : void 0) ? transport.responseJSON.error_info.message : transport.responseText, $("#new-payment-method-error").text(message).show();
5932 }), $("form", "#confirm").on("ajax:success", function(dataAndEvents, params) {
5933 return $("#pay-with-credit-card").addClass("hidden"), window.Criteo.sharedInstance().push({
5934 event: "trackTransaction",
5935 id: params.payment_id,
5936 new_customer: params.first_time_payer ? 1 : 0,
5937 item: [{
5938 id: params.product_parent_id,
5939 price: params.amount_total,
5940 quantity: 1
5941 }]
5942 }), window.location = params.payment_url;
5943 }), $("form", "#confirm").on("ajax:error", function(dataAndEvents) {
5944 return function(deepDataAndEvents, transport) {
5945 var udataCur;
5946 var r;
5947 return udataCur = null != (null != (r = transport.responseJSON) ? r.error_info : void 0) ? transport.responseJSON.error_info.message : transport.responseText, window.notifyError(udataCur), dataAndEvents.enablePayments(), $("#new_payment_method .new-credit-card-button").val(window.t.web.pay_flow.common["continue"]), $(".processing-notice").hide();
5948 };
5949 }(this));
5950 }
5951 }, self.ui = function() {
5952 var index;
5953 var i;
5954 var j;
5955 var parent;
5956 var quantity;
5957 var ln;
5958 var subLn;
5959 var _len;
5960 var _len3;
5961 var _i;
5962 var _l;
5963 var name;
5964 var part;
5965 var sourceKeys;
5966 var configList;
5967 var parts;
5968 var xs;
5969 var files;
5970 var lineSeparator;
5971 var $rootElement;
5972 var x;
5973 var file;
5974 var key;
5975 if (this.container.find(".name").text(this.product.name), this.container.find(".seller").text(this.product.seller), this.container.find(".estimated-delivery").text(this.product.estimated_delivery), this.container.find(".image").attr("src", this.product.image.thumbnail), null != this.product.payment_due_at && this.container.find("#payment-required").show().find(".date").text(this.product.payment_due_at), this.updatePricing(this.pricing), $(".radios", "#select-variation").empty(), this.variations.length >
5976 0) {
5977 sourceKeys = this.variations;
5978 /** @type {number} */
5979 index = 0;
5980 quantity = sourceKeys.length;
5981 for (; index < quantity; index++) {
5982 key = sourceKeys[index];
5983 this.addVariation(key);
5984 }
5985 }
5986 if ($(".go-to-select-variation").toggle(this.variations.length > 0), $(".selected-variation").toggle(this.variations.length > 0), null != this.sizingRating) {
5987 $("#sizing-ratings").show();
5988 /** @type {Array} */
5989 configList = ["small", "right", "large"];
5990 /** @type {number} */
5991 i = 0;
5992 /** @type {number} */
5993 ln = configList.length;
5994 for (; i < ln; i++) {
5995 name = configList[i];
5996 $(".sizing-bar." + name).css("width", this.sizingRating[name + "_percent"] + "%");
5997 $(".total-ratings." + name).html(this.sizingRating[name + "_count"]);
5998 }
5999 } else {
6000 $("#sizing-ratings").hide();
6001 }
6002 if ($(".radios", "#select-payment-method").empty(), this.paymentMethods.length > 0) {
6003 parts = this.paymentMethods;
6004 /** @type {number} */
6005 j = 0;
6006 subLn = parts.length;
6007 for (; j < subLn; j++) {
6008 part = parts[j];
6009 this.addPaymentMethod(part);
6010 }
6011 this.setPaymentMethod(this.paymentMethods[0]);
6012 }
6013 if ($(".paypal").attr("disabled", "disabled").prop("disabled", true), $(".radios", "#select-shipping-address").empty(), this.shippingAddresses.length > 0) {
6014 xs = this.shippingAddresses;
6015 /** @type {number} */
6016 _i = 0;
6017 _len = xs.length;
6018 for (; _i < _len; _i++) {
6019 x = xs[_i];
6020 this.addShippingAddress(x);
6021 }
6022 this.setShippingAddress(this.shippingAddresses[0], true);
6023 } else {
6024 if (!this.paypalEnabled) {
6025 $("#new-shipping-address-back").hide();
6026 }
6027 this.dropInPayPal();
6028 }
6029 if (!this.paypalEnabled) {
6030 $("#select-shipping-address-back").hide();
6031 }
6032 $("#country option").filter(function() {
6033 return $(this).text() === window.currentUser.country;
6034 }).prop("selected", true);
6035 $("#country").trigger("change");
6036 $("#upsells").hide();
6037 $("#confirm-upsells").empty();
6038 files = this.upsells;
6039 /** @type {number} */
6040 _l = 0;
6041 _len3 = files.length;
6042 for (; _l < _len3; _l++) {
6043 file = files[_l];
6044 $("#upsells").show();
6045 $rootElement = $("<div class='row top10' />");
6046 parent = $("<div class='col-xs-9' />").text(file.description);
6047 lineSeparator = $("<div class='col-xs-3' />").html($("<a href='#' class='btn btn-success btn-sm btn-block did-select-upsell' />").html("<span class='fa fa-plus-circle'></span>").data("upsell-id", file.id));
6048 $rootElement.append(parent).append(lineSeparator);
6049 $("#confirm-upsells").append($rootElement);
6050 }
6051 return null != this.expeditedShipping && (file = this.expeditedShipping, $("#upsells").show(), $rootElement = $("<div class='row top10' />"), parent = $("<div class='col-xs-9' />").text(file.description), lineSeparator = $("<div class='col-xs-3' />").html($("<a href='#' class='btn btn-success btn-sm btn-block did-select-expedited' />").html("<span class='fa fa-plus-circle'></span>").data("expedited-shipping-id", file.id)), $rootElement.append(parent).append(lineSeparator), $("#confirm-upsells").append($rootElement)),
6052 this.container.show();
6053 }, self.goToNext = function() {
6054 return this.variations.length > 0 && null == this.variationId ? this.goTo("select-variation") : null != this.shippingAddressId && null != this.paymentMethodToken || null !== this.payingWithPaypal ? null == this.shippingAddressId ? (this.goTo("new-shipping-address"), this.hostedFields()) : null == this.paymentMethodToken ? this.paymentMethods.length > 0 ? this.goTo("select-payment-method") : this.goTo("new-payment-method") : (this.payingWithPaypal = false, this.goTo("confirm"), $("#pay-with-credit-card").show()) :
6055 this.goTo("select-credit-card-or-paypal");
6056 }, self.goTo = function(action) {
6057 return $(".page").hide(), $("#" + action).show();
6058 }, self.addVariation = function(key) {
6059 var input;
6060 return input = $("<a class='btn btn-default btn-block btn-select did-select-variation'>" + key.name + " <span class='fa fa-chevron-right'></span></a>"), input.data("variation", key), $(".radios", "#select-variation").append(input);
6061 }, self.addPaymentMethod = function(scope) {
6062 var html;
6063 return html = $("<a class='btn btn-default btn-block btn-select did-select-payment-method'>" + scope.description + " <span class='fa fa-chevron-right'></span></a>"), html.data("payment-method", scope), $(".radios", "#select-payment-method").append(html);
6064 }, self.addShippingAddress = function(data) {
6065 var handle;
6066 var desc;
6067 return desc = null != data.state ? data.state + "," : "", handle = $("<div class='btn btn-default btn-block btn-select did-select-shipping-address'><div>" + data.name + "</div><div>" + data.address1 + "</div><div>" + data.city + ", " + desc + " " + data.zip + " " + data.country + "</div><span class='fa fa-chevron-right'></span></div>"), handle.data("shipping-address", data), $(".radios", "#select-shipping-address").append(handle);
6068 }, self.updatePricing = function(worlds) {
6069 var i;
6070 var max;
6071 var part;
6072 var paths;
6073 var after;
6074 /** @type {string} */
6075 this.pricing = worlds;
6076 $("#pricing").empty();
6077 /** @type {Array} */
6078 paths = [];
6079 /** @type {number} */
6080 i = 0;
6081 max = worlds.length;
6082 for (; i < max; i++) {
6083 switch (part = worlds[i], part.type) {
6084 case "credit":
6085 after = $("<tr class='text-success'><td class='text-muted' style='width: 33%;'>" + part.line_item + "</td><td class='text-strong'>-" + part.value + "</td></tr>");
6086 break;
6087 default:
6088 after = $("<tr><td class='text-muted' style='width: 33%;'>" + part.line_item + "</td><td class='text-strong'>" + part.value + "</td></tr>");
6089 }
6090 paths.push($("#pricing").append(after));
6091 }
6092 return paths;
6093 }, self.setInvoiceId = function(coords) {
6094 if (this.invoiceId = coords, $("#pay_flow_invoice_id").val(coords), !coords) {
6095 return $(".sofort").hide();
6096 }
6097 }, self.setLotId = function(coords) {
6098 return this.lotId = coords, $("#pay_flow_lot_id").val(coords);
6099 }, self.setPayingWithPaypal = function(recurring) {
6100 if (this.payingWithPaypal = recurring, recurring) {
6101 return this.setPaymentMethod(null), $("#confirm-payment-method").text("PayPal");
6102 }
6103 }, self.setVariation = function(map) {
6104 return this.variationId = map.id, $("#confirm-variation").text(map.name), $("#pay_flow_variation_id").val(this.variationId);
6105 }, self.setPaymentMethod = function(scope) {
6106 return scope ? (this.paymentMethodToken = scope.token, $("#confirm-payment-method").text(scope.description), $("#pay_flow_token").val(this.paymentMethodToken)) : (this.paymentMethodToken = null, $("#confirm-payment-method").text(""), $("#pay_flow_token").val(""));
6107 }, self.setShippingAddress = function(data, recurring) {
6108 var not;
6109 var desc;
6110 if (null == recurring && (recurring = false), this.shippingAddressId = data.id, $("#confirm-shipping-address").empty(), $("#confirm-shipping-address").append("<div>" + data.name + "</div>"), $("#confirm-shipping-address").append("<div>" + data.address1 + "</div>"), (null != (not = data.address2) ? not.length : void 0) > 0 && $("#confirm-shipping-address").append("<div>" + data.address2 + "</div>"), desc = null != data.state ? data.state + "," : "", $("#confirm-shipping-address").append("<div>" +
6111 data.city + ", " + desc + " " + data.zip + " " + data.country + "</div>"), $("#pay_flow_mailing_address_id").val(this.shippingAddressId), this.shippingAddressOverride = {
6112 recipientName: data.name,
6113 streetAddress: data.address1,
6114 extendedAddress: data.address2,
6115 locality: data.city,
6116 countryCodeAlpha2: data.country_code_alpha2,
6117 postalCode: data.zip,
6118 region: data.state,
6119 editable: this.addressChangeAllowed
6120 }, $(".paypal").attr("disabled", "disabled").prop("disabled", true), this.dropInPayPal(), this.hosted_fields_instance || this.hostedFields(), !recurring) {
6121 return this.refresh();
6122 }
6123 }, self.addUpsellId = function(timeoutKey) {
6124 var testSource;
6125 var name;
6126 /** @type {boolean} */
6127 this.upsellIds[timeoutKey] = true;
6128 $("#pay_flow_upsell_ids").empty();
6129 testSource = this.upsellIds;
6130 for (name in testSource) {
6131 testSource[name];
6132 $("#pay_flow_upsell_ids").append($("<input type='hidden' name='upsell_ids[]' />").val(name));
6133 }
6134 return this.refresh();
6135 }, self.removeUpsellId = function(timeoutKey) {
6136 var testSource;
6137 var name;
6138 delete this.upsellIds[timeoutKey];
6139 $("#pay_flow_upsell_ids").empty();
6140 testSource = this.upsellIds;
6141 for (name in testSource) {
6142 testSource[name];
6143 $("#pay_flow_upsell_ids").append($("<input type='hidden' name='upsell_ids[]' />").val(name));
6144 }
6145 return this.refresh();
6146 }, self.setExpeditedShippingId = function(recurring) {
6147 return this.expeditedShippingId = recurring, $("#pay_flow_expedited_shipping_id").val(this.expeditedShippingId), this.refresh();
6148 }, self.capitalize = function(token) {
6149 return null == token && (token = ""), token.charAt(0).toUpperCase() + token.slice(1);
6150 }, self.pay = function(timestamp, persistent) {
6151 return $.getJSON("/api/v1/payments/summary.json?invoice_id=" + timestamp, function(record) {
6152 return function(x) {
6153 return record.reset(), record.start(x, persistent);
6154 };
6155 }(this));
6156 }, self.authorize = function(path) {
6157 return $.post("/api/v1/payments/authorize.json?invoice_id=" + path, function(match) {
6158 if (match.redirect_url) {
6159 return window.location.replace(match.redirect_url);
6160 }
6161 });
6162 }, self.authorizeCallback = function(dataAndEvents, coords, cookie) {
6163 if ("authorize_done" === dataAndEvents) {
6164 return self.disablePayments(), $(".processing-notice").show(), $("#stripe-source-id").val(coords), $("#stripe-client-secret").val(cookie), $("form", "#confirm").submit();
6165 }
6166 }, self.buyNow = function(deepDataAndEvents, persistent) {
6167 return $.getJSON("/api/v1/payments/summary.json?lot_id=" + deepDataAndEvents, function(record) {
6168 return function(x) {
6169 return record.reset(), record.start(x, persistent);
6170 };
6171 }(this));
6172 }, self.refresh = function() {
6173 var gurl;
6174 return gurl = "/api/v1/payments/summary.json?" + $("#confirm > form:first").serialize(), $.getJSON(gurl, function(b) {
6175 return function(a) {
6176 if (b.paypalData = a.paypal, b.updatePricing(a.pricing), null != a.error) {
6177 return window.notifyError(a.error);
6178 }
6179 };
6180 }(this));
6181 }, self.paypalConfirm = function(obj, email) {
6182 var gurl;
6183 return $("#pay_flow_mailing_address_id").removeAttr("value"), gurl = "/api/v1/payments/summary.json?" + $("#confirm > form:first").serialize(), $.getJSON(gurl, function(self) {
6184 return function(data) {
6185 var pdataCur;
6186 return (pdataCur = function() {
6187 var _i;
6188 var _len;
6189 var _ref2;
6190 var readyList;
6191 _ref2 = data.shipping_addresses;
6192 /** @type {Array} */
6193 readyList = [];
6194 /** @type {number} */
6195 _i = 0;
6196 _len = _ref2.length;
6197 for (; _i < _len; _i++) {
6198 obj = _ref2[_i];
6199 if (obj.id === data.current_address_id) {
6200 readyList.push(obj);
6201 }
6202 }
6203 return readyList;
6204 }()[0]) && self.setShippingAddress(pdataCur, false), self.updatePricing(data.pricing), null != data.error && window.notifyError(data.error), $(".go-to-select-shipping-address").hide(), $(".go-to-select-payment-method").hide(), $(".go-to-select-variation").hide(), $("#upsells").hide(), $("#confirm-payment-method").text(window.translate(window.t.web.pay_flow.paypal.account, {
6205 email: email
6206 })), $("#pay-with-credit-card").show(), self.goTo("confirm");
6207 };
6208 }(this));
6209 }, self;
6210 }();
6211 }.call(this),
6212 function() {
6213 window.UserActionQueue = function() {
6214 /**
6215 * @return {undefined}
6216 */
6217 function copy() {
6218 var cellData;
6219 /** @type {*} */
6220 this.queue = null != (cellData = window.Store.get("user-actions")) ? JSON.parse(cellData) : [];
6221 }
6222 return copy.sharedInstance = function() {
6223 return null != this._sharedInstance ? this._sharedInstance : this._sharedInstance = new copy;
6224 }, copy.prototype.addUserAction = function(opt_attributes) {
6225 return this.queue.push(opt_attributes), window.Store.set("user-actions", JSON.stringify(this.queue));
6226 }, copy.prototype.flushUserActions = function() {
6227 var action;
6228 var collection;
6229 var _i;
6230 var _len;
6231 var name;
6232 var timeoutKey;
6233 var _ref;
6234 if (this.queue.length > 0) {
6235 /** @type {null} */
6236 name = null;
6237 /** @type {null} */
6238 collection = null;
6239 _ref = this.queue;
6240 /** @type {number} */
6241 _i = 0;
6242 _len = _ref.length;
6243 for (; _i < _len; _i++) {
6244 if (action = _ref[_i], "buy_now" === action.action_type) {
6245 window.showBuyNowModal(action.action_id);
6246 collection = action.action_id;
6247 break;
6248 }
6249 if ("view" === action.action_type) {
6250 name = action.action_id;
6251 } else {
6252 if ("alert" === action.action_type) {
6253 timeoutKey = action.action_id;
6254 window.LotModal.getSharedInstance().setReminder(timeoutKey);
6255 }
6256 }
6257 }
6258 return null != name && (null == collection && window.LotModal.getSharedInstance().show(name)), window.Store.set("user-actions", JSON.stringify([])), $.post("/api/v1/users/actions.json", {
6259 actions: this.queue
6260 });
6261 }
6262 }, copy;
6263 }();
6264 if (window.isLoggedIn()) {
6265 UserActionQueue.sharedInstance().flushUserActions();
6266 }
6267 }.call(this),
6268 function() {
6269 window.AppBoy = function() {
6270 /**
6271 * @return {undefined}
6272 */
6273 function Type() {}
6274 return Type.sharedInstance = function() {
6275 return null != this._sharedInstance ? this._sharedInstance : this._sharedInstance = new Type;
6276 }, Type.prototype.openSession = function(dataAndEvents, xml, ignoreMethodDoesntExist, deepDataAndEvents) {
6277 return this.appboy = dataAndEvents, this.appboy.initialize(xml, {
6278 enableHtmlInAppMessages: true,
6279 safariWebsitePushId: ignoreMethodDoesntExist
6280 }), this.appboy.changeUser(deepDataAndEvents), this.appboy.openSession();
6281 }, Type;
6282 }();
6283 }.call(this),
6284 function() {
6285 window.Criteo = function() {
6286 /**
6287 * @return {undefined}
6288 */
6289 function Text() {}
6290 return Text.sharedInstance = function() {
6291 return null != this._sharedInstance ? this._sharedInstance : this._sharedInstance = new Text;
6292 }, Text.prototype.push = function(opt_attributes) {
6293 if (window.isLoggedIn()) {
6294 return window.criteo_q = window.criteo_q || [], window.criteo_q.push({
6295 event: "setAccount",
6296 account: Config.sharedInstance().criteo.account_id
6297 }, {
6298 event: "setEmail",
6299 email: window.currentUser.hashed_email
6300 }, {
6301 event: "setSiteType",
6302 type: window.mobileBrowser ? "m" : "d"
6303 }, opt_attributes);
6304 }
6305 }, Text;
6306 }();
6307 }.call(this),
6308 function() {}.call(this);