1 2/* source: <[email protected]> */ 3// TRINIO script start 4// This script is owned by Trinio, please do not modify it without consent 5function trinioInitialize() { 6 var TrinioPluginVTEXInitializer=function(o){"use strict";var k=Object.defineProperty;var T=(o,i,s)=>i in o?k(o,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):o[i]=s;var u=(o,i,s)=>(T(o,typeof i!="symbol"?i+"":i,s),s);function i(n){if(!n||typeof n!="function")throw new TypeError("callback must be a function");const t=document.readyState;(t==="interactive"||t==="complete")&&document.body?n():document.addEventListener("DOMContentLoaded",n)}const s="trinio-smart-checkout-styles";function m(n){const t=document.getElementById(s),e=t==null?void 0:t.sheet;e&&e.insertRule(n,e.cssRules.length)}function y(n){const t=document.getElementById(s);if(t){const e=t.sheet;if(e!=null&&e.cssRules){for(let r=0;r<e.cssRules.length;r++)if(e.cssRules[r].selectorText===`.${n}`){e.deleteRule(r);return}}}}function b(){return` 7 .trinio-checkout-button--disabled { 8 color: transparent !important; 9 text-shadow: none !important; 10 font-size: 12px !important; 11 pointer-events: none; 12 } 13 .trinio-spinner { 14 position: relative; 15 overflow: hidden; 16 } 17 .trinio-spinner::after { 18 content: "" !important; 19 display: block; 20 position: absolute; 21 top: 50%; 22 left: 50%; 23 transform: translate(-50%, -50%); 24 width: 14px; 25 height: 14px; 26 border-radius: 50%; 27 border: 2px solid transparent; 28 animation: trinio-spin 0.9s linear infinite; 29 } 30 .trinio-spinner:before { 31 content: "" !important; 32 } 33 @keyframes trinio-spin { 34 0% { 35 transform: translate(-50%, -50%) rotate(0deg); 36 } 37 100% { 38 transform: translate(-50%, -50%) rotate(360deg); 39 } 40 } 41 `}class f{constructor(t){u(this,"checkoutButtons",[]);u(this,"injectTrinioHeaderStyles",()=>{const t=document.createElement("style");t.setAttribute("id",s),t.setAttribute("type","text/css"),t.textContent=b(),document.head.appendChild(t)});u(this,"disableCheckoutButtons",()=>{this.checkoutButtons.forEach((t,e)=>{const r=`trinio-spinner-color-${e}`,a=window.getComputedStyle(t).color,l=` 42 .${r}::after { 43 border-color: ${a} ${a} ${a} transparent; 44 } 45 `;m(l),t.setAttribute("disabled","true"),t.classList.add("trinio-spinner","trinio-checkout-button--disabled",r)}),setTimeout(()=>{this.enableCheckoutButtons()},6e3)});u(this,"enableCheckoutButtons",()=>{this.checkoutButtons.forEach((t,e)=>{t.removeAttribute("disabled"),t.classList.remove("trinio-spinner","trinio-checkout-button--disabled",`trinio-spinner-color-${e}`),y(`trinio-spinner-color-${e}::after`)})});u(this,"init",async()=>{try{const t=await this.gatherAllCheckoutButtons();if(!t.length)return;this.checkoutButtons=t,this.disableCheckoutButtons()}catch(t){console.log("[Trinio-Initializer] ",t)}});this.vtexPlugin=t,this.injectTrinioHeaderStyles()}async gatherAllCheckoutButtons(){const{btnCheckoutQuantity:t,btnCheckoutRetryAttempt:e=3,enableExponentialBackOffRetry:r}=this.vtexPlugin.options,a=[this.vtexPlugin.options.btnCheckoutIdOnCart,...this.vtexPlugin.options.btnCheckoutIds],l=async(d=0)=>{const C=a.map(c=>Array.from(document.querySelectorAll(`[id="${c}"]`))).reduce((c,p)=>c.concat(p),[]),g=(this.vtexPlugin.options.btnCheckoutClasses||[]).map(c=>Array.from(document.querySelectorAll(`.${c}`))).reduce((c,p)=>c.concat(p),[]),h=[...C,...g];if((t?h.length===t:h.length>0)||d>=e)return h;const B=r?100*Math.pow(2,d+1):200;return await new Promise(c=>setTimeout(c,B)),l(d+1)};return await l()}}return i(()=>{const n=window.TRINIO_PLUGIN_CONFIG;try{window.TrinioVTEXInitializer=new f(n),window.TrinioVTEXInitializer.init()}catch(t){console.log(t)}}),o.TrinioVTEXInitializer=f,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),o}({}); 46 } 47 const BASE_URL = 'cdn.trinio.co' 48 function setPluginScript() { 49 const scriptPlugin = document.createElement('script') 50 scriptPlugin.src = `https://${BASE_URL}/static/trinio-plugin-vtex.iife.js` 51 scriptPlugin.async = true 52 document.body.appendChild(scriptPlugin) 53 } 54 function setCssScript() { 55 const linkStylesheetTrinioCss = document.createElement('link') 56 linkStylesheetTrinioCss.rel = 'stylesheet' 57 linkStylesheetTrinioCss.type = 'text/css' 58 linkStylesheetTrinioCss.className = 'override_link' 59 linkStylesheetTrinioCss.href = `https://${BASE_URL}/static/css/style.css` 60 document.head.appendChild(linkStylesheetTrinioCss) 61 } 62 window.TRINIO_PLUGIN_CONFIG = { 63 merchantId: '01K6NGX5V7FXAFKC513SPS0VE7', 64 options: { 65 checkoutPollingInterval: 100,
66 btnCheckoutClasses: ['modal-checkout-button-confirm', '_keepBuying'], 67 btnCheckoutIds: [], 68 btnCheckoutIdOnCart: 'cart-to-orderform', 69 btnCheckoutQuantity: 2, 70 enableExponentialBackOffRetry: true, 71 cashbackProvider: undefined 72 }, 73 } 74 trinioInitialize() 75 setPluginScript() 76 setCssScript() 77 console.log('[TRINIO VTEX] all js and css add to DOM') 78 // TRINIO script end 79 ; 80 81/* source: <[email protected]> */ 82/*! jquery.livequery - v1.3.6 - 2016-12-09 83 * Copyright (c) 84 * (c) 2010, Brandon Aaron (http://brandonaaron.net) 85 * (c) 2012 - 2016, Alexander Zaytsev (https://alexzaytsev.me) 86 * Dual licensed under the MIT (MIT_LICENSE.txt) 87 * and GPL Version 2 (GPL_LICENSE.txt) licenses. 88 */ 89!(function (e) { 90 'function' == typeof define && define.amd 91 ? define(['jquery'], e) 92 : e('object' == typeof exports ? require('jquery') : jQuery) 93})(function (e, t) { 94 function n(e, t, n, i) { 95 return !( 96 e.selector != t.selector || 97 e.context != t.context || 98 (n && n.$lqguid != t.fn.$lqguid) || 99 (i && i.$lqguid != t.fn2.$lqguid) 100 ) 101 } 102 e.extend(e.fn, { 103 livequery: function (t, o) { 104 var s, 105 a = this 106 return ( 107 e.each(i.queries, function (e, i) { 108 if (n(a, i, t, o)) return (s = i) && !1 109 }), 110 ((s = s || new i(a.selector, a.context, t, o)).stopped = !1), 111 s.run(), 112 a 113 ) 114 }, 115 expire: function (t, o) { 116 var s = this 117 return ( 118 e.each(i.queries, function (e, a) { 119 n(s, a, t, o) && !s.stopped && i.stop(a.id) 120 }), 121 s 122 ) 123 }, 124 }) 125 var i = (e.livequery = function (t, n, o, s) { 126 var a = this 127 return ( 128 (a.selector = t), 129 (a.context = n), 130 (a.fn = o), 131 (a.fn2 = s), 132 (a.elements = e([])), 133 (a.stopped = !1), 134 (a.id = i.queries.push(a) - 1), 135 (o.$lqguid = o.$lqguid || i.guid++), 136 s && (s.$lqguid = s.$lqguid || i.guid++), 137 a 138 ) 139 }) 140 ;(i.prototype = { 141 stop: function () { 142 var t = this 143 t.stopped || (t.fn2 && t.elements.each(t.fn2), (t.elements = e([])), (t.stopped = !0)) 144 }, 145 run: function () { 146 var t = this 147 if (!t.stopped) { 148 var n = t.elements, 149 i = e(t.selector, t.context), 150 o = i.not(n), 151 s = n.not(i) 152 ;(t.elements = i), o.each(t.fn), t.fn2 && s.each(t.fn2) 153 } 154 }, 155 }), 156 e.extend(i, { 157 guid: 0, 158 queries: [], 159 queue: [], 160 running: !1, 161 timeout: null, 162 registered: [], 163 checkQueue: function () { 164 if (i.running && i.queue.length) for (var e = i.queue.length; e--; ) i.queries[i.queue.shift()].run() 165 }, 166 pause: function () { 167 i.running = !1 168 }, 169 play: function () { 170 ;(i.running = !0), i.run() 171 }, 172 registerPlugin: function () { 173 e.each(arguments, function (t, n) { 174 if (e.fn[n] && !(e.inArray(n, i.registered) > 0)) { 175 var o = e.fn[n] 176 ;(e.fn[n] = function () { 177 var e = o.apply(this, arguments) 178 return i.run(), e 179 }), 180 i.registered.push(n) 181 } 182 }) 183 }, 184 run: function (n) { 185 n !== t 186 ? e.inArray(n, i.queue) < 0 && i.queue.push(n) 187 : e.each(i.queries, function (t) { 188 e.inArray(t, i.queue) < 0 && i.queue.push(t) 189 }), 190 i.timeout && clearTimeout(i.timeout), 191 (i.timeout = setTimeout(i.checkQueue, 20)) 192 }, 193 stop: function (n) { 194 n !== t ? i.queries[n].stop() : e.each(i.queries, i.prototype.stop) 195 }, 196 }), 197 i.registerPlugin( 198 'append', 199 'prepend', 200 'after', 201 'before', 202 'wrap', 203 'attr', 204 'removeAttr', 205 'addClass', 206 'removeClass', 207 'toggleClass', 208 'empty', 209 'remove', 210 'html', 211 'prop', 212 'removeProp' 213 ), 214 e(function () { 215 i.play() 216 }) 217}), 218 (function (e, t) { 219 'object' == typeof exports && 'undefined' != typeof module 220 ? t(exports) 221 : 'function' == typeof define && define.amd 222 ? define(['exports'], t) 223 : t(((e = 'undefined' != typeof globalThis ? globalThis : e || self).IMask = {})) 224 })(this, function (e) { 225 'use strict' 226 var t = 227 'undefined' != typeof globalThis 228 ? globalThis 229 : 'undefined' != typeof window 230 ? window 231 : 'undefined' != typeof global 232 ? global 233 : 'undefined' != typeof self 234 ? self 235 : {} 236 function n(e) { 237 var t = { 238 exports: {}, 239 } 240 return e(t, t.exports), t.exports 241 } 242 var i = function (e) { 243 return e && e.Math == Math && e 244 }, 245 o = 246 i('object' == typeof globalThis && globalThis) || 247 i('object' == typeof window && window) || 248 i('object' == typeof self && self) || 249 i('object' == typeof t && t) || 250 (function () { 251 return this 252 })() || 253 Function('return this')(), 254 s = function (e) { 255 try { 256 return !!e() 257 } catch (e) { 258 return !0 259 } 260 }, 261 a = !s(function () { 262 return ( 263 7 != 264 Object.defineProperty({}, 1, { 265 get: function () { 266 return 7 267 }, 268 })[1] 269 ) 270 }), 271 r = {}.propertyIsEnumerable, 272 c = Object.getOwnPropertyDescriptor, 273 u = { 274 f: 275 c && 276 !r.call( 277 { 278 1: 2, 279 }, 280 1 281 ) 282 ? function (e) { 283 var t = c(this, e) 284 return !!t && t.enumerable 285 } 286 : r, 287 }, 288 l = function (e, t) { 289 return { 290 enumerable: !(1 & e), 291 configurable: !(2 & e), 292 writable: !(4 & e), 293 value: t, 294 } 295 }, 296 d = {}.toString, 297 p = ''.split, 298 h = s(function () { 299 return !Object('z').propertyIsEnumerable(0) 300 }) 301 ? function (e) { 302 return 'String' == 303 (function (e) { 304 return d.call(e).slice(8, -1) 305 })(e) 306 ? p.call(e, '') 307 : Object(e) 308 } 309 : Object, 310 m = function (e) { 311 if (null == e) throw TypeError("Can't call method on " + e) 312 return e 313 }, 314 f = function (e) { 315 return h(m(e)) 316 }, 317 y = function (e) { 318 return 'object' == typeof e ? null !== e : 'function' == typeof e 319 }, 320 v = function (e, t) { 321 if (!y(e)) return e 322 var n, i 323 if (t && 'function' == typeof (n = e.toString) && !y((i = n.call(e)))) return i 324 if ('function' == typeof (n = e.valueOf) && !y((i = n.call(e)))) return i 325 if (!t && 'function' == typeof (n = e.toString) && !y((i = n.call(e)))) return i 326 throw TypeError("Can't convert object to primitive value") 327 }, 328 g = {}.hasOwnProperty, 329 b = function (e, t) { 330 return g.call(e, t) 331 }, 332 k = o.document, 333 S = y(k) && y(k.createElement), 334 C = 335 !a && 336 !s(function () { 337 return ( 338 7 != 339 Object.defineProperty(((e = 'div'), S ? k.createElement(e) : {}), 'a', { 340 get: function () { 341 return 7 342 }, 343 }).a 344 ) 345 var e 346 }), 347 w = Object.getOwnPropertyDescriptor, 348 _ = { 349 f: a 350 ? w 351 : function (e, t) { 352 if (((e = f(e)), (t = v(t, !0)), C)) 353 try { 354 return w(e, t) 355 } catch (e) {} 356 if (b(e, t)) return l(!u.f.call(e, t), e[t]) 357 }, 358 }, 359 x = function (e) { 360 if (!y(e)) throw TypeError(String(e) + ' is not an object') 361 return e 362 }, 363 A = Object.defineProperty, 364 q = { 365 f: a 366 ? A 367 : function (e, t, n) { 368 if ((x(e), (t = v(t, !0)), x(n), C)) 369 try { 370 return A(e, t, n) 371 } catch (e) {} 372 if ('get' in n || 'set' in n) throw TypeError('Accessors not supported') 373 return 'value' in n && (e[t] = n.value), e 374 }, 375 }, 376 $ = a 377 ? function (e, t, n) { 378 return q.f(e, t, l(1, n)) 379 } 380 : function (e, t, n) { 381 return (e[t] = n), e 382 }, 383 T = function (e, t) { 384 try { 385 $(o, e, t) 386 } catch (n) { 387 o[e] = t 388 } 389 return t 390 }, 391 B = o['__core-js_shared__'] || T('__core-js_shared__', {}), 392 M = Function.toString 393 'function' != typeof B.inspectSource && 394 (B.inspectSource = function (e) { 395 return M.call(e) 396 }) 397 var E, 398 L, 399 F, 400 I, 401 D = B.inspectSource, 402 O = o.WeakMap, 403 P = 'function' == typeof O && /native code/.test(D(O)), 404 j = n(function (e) { 405 ;(e.exports = function (e, t) { 406 return B[e] || (B[e] = void 0 !== t ? t : {}) 407 })('versions', []).push({ 408 version: '3.8.3', 409 mode: 'global', 410 copyright: 'é 2021 Denis Pushkarev (zloirock.ru)', 411 }) 412 }), 413 R = 0, 414 N = Math.random(), 415 H = j('keys'), 416 V = {}, 417 z = o.WeakMap 418 if (P) { 419 var U = B.state || (B.state = new z()), 420 W = U.get, 421 Q = U.has, 422 Y = U.set 423 ;(E = function (e, t) { 424 return (t.facade = e), Y.call(U, e, t), t 425 }), 426 (L = function (e) { 427 return W.call(U, e) || {} 428 }), 429 (F = function (e) { 430 return Q.call(U, e) 431 }) 432 } else { 433 var K = 434 H[(I = 'state')] || 435 (H[I] = (function (e) { 436 return 'Symbol(' + String(void 0 === e ? '' : e) + ')_' + (++R + N).toString(36) 437 })(I)) 438 ;(V[K] = !0), 439 (E = function (e, t) { 440 return (t.facade = e), $(e, K, t), t 441 }), 442 (L = function (e) { 443 return b(e, K) ? e[K] : {} 444 }), 445 (F = function (e) { 446 return b(e, K) 447 }) 448 } 449 var J = { 450 set: E, 451 get: L, 452 has: F, 453 enforce: function (e) { 454 return F(e) ? L(e) : E(e, {}) 455 }, 456 getterFor: function (e) { 457 return function (t) { 458 var n 459 if (!y(t) || (n = L(t)).type !== e) throw TypeError('Incompatible receiver, ' + e + ' required') 460 return n 461 } 462 }, 463 }, 464 G = n(function (e) { 465 var t = J.get, 466 n = J.enforce,
467 i = String(String).split('String') 468 ;(e.exports = function (e, t, s, a) { 469 var r, 470 c = !!a && !!a.unsafe, 471 u = !!a && !!a.enumerable, 472 l = !!a && !!a.noTargetGet 473 'function' == typeof s && 474 ('string' != typeof t || b(s, 'name') || $(s, 'name', t), 475 (r = n(s)).source || (r.source = i.join('string' == typeof t ? t : ''))), 476 e !== o ? (c ? !l && e[t] && (u = !0) : delete e[t], u ? (e[t] = s) : $(e, t, s)) : u ? (e[t] = s) : T(t, s) 477 })(Function.prototype, 'toString', function () { 478 return ('function' == typeof this && t(this).source) || D(this) 479 }) 480 }), 481 X = o, 482 Z = function (e) { 483 return 'function' == typeof e ? e : void 0 484 }, 485 ee = function (e, t) { 486 return arguments.length < 2 ? Z(X[e]) || Z(o[e]) : (X[e] && X[e][t]) || (o[e] && o[e][t]) 487 }, 488 te = Math.ceil, 489 ne = Math.floor, 490 ie = function (e) { 491 return isNaN((e = +e)) ? 0 : (e > 0 ? ne : te)(e) 492 }, 493 oe = Math.min, 494 se = function (e) { 495 return e > 0 ? oe(ie(e), 9007199254740991) : 0 496 }, 497 ae = Math.max, 498 re = Math.min, 499 ce = function (e) { 500 return function (t, n, i) { 501 var o, 502 s = f(t), 503 a = se(s.length), 504 r = (function (e, t) { 505 var n = ie(e) 506 return n < 0 ? ae(n + t, 0) : re(n, t) 507 })(i, a) 508 if (e && n != n) { 509 for (; a > r; ) if ((o = s[r++]) != o) return !0 510 } else for (; a > r; r++) if ((e || r in s) && s[r] === n) return e || r || 0 511 return !e && -1 512 } 513 }, 514 ue = { 515 includes: ce(!0), 516 indexOf: ce(!1), 517 }.indexOf, 518 le = function (e, t) { 519 var n, 520 i = f(e), 521 o = 0, 522 s = [] 523 for (n in i) !b(V, n) && b(i, n) && s.push(n) 524 for (; t.length > o; ) b(i, (n = t[o++])) && (~ue(s, n) || s.push(n)) 525 return s 526 }, 527 de = [ 528 'constructor', 529 'hasOwnProperty', 530 'isPrototypeOf', 531 'propertyIsEnumerable', 532 'toLocaleString', 533 'toString', 534 'valueOf', 535 ], 536 pe = de.concat('length', 'prototype'), 537 he = { 538 f: 539 Object.getOwnPropertyNames || 540 function (e) { 541 return le(e, pe) 542 }, 543 }, 544 me = { 545 f: Object.getOwnPropertySymbols, 546 }, 547 fe = 548 ee('Reflect', 'ownKeys') || 549 function (e) { 550 var t = he.f(x(e)), 551 n = me.f 552 return n ? t.concat(n(e)) : t 553 }, 554 ye = function (e, t) { 555 for (var n = fe(t), i = q.f, o = _.f, s = 0; s < n.length; s++) { 556 var a = n[s] 557 b(e, a) || i(e, a, o(t, a)) 558 } 559 }, 560 ve = /#|\.prototype\./, 561 ge = function (e, t) { 562 var n = ke[be(e)] 563 return n == Ce || (n != Se && ('function' == typeof t ? s(t) : !!t)) 564 }, 565 be = (ge.normalize = function (e) { 566 return String(e).replace(ve, '.').toLowerCase() 567 }), 568 ke = (ge.data = {}), 569 Se = (ge.NATIVE = 'N'), 570 Ce = (ge.POLYFILL = 'P'), 571 we = ge, 572 _e = _.f, 573 xe = function (e, t) { 574 var n, 575 i, 576 s, 577 a, 578 r, 579 c = e.target, 580 u = e.global, 581 l = e.stat 582 if ((n = u ? o : l ? o[c] || T(c, {}) : (o[c] || {}).prototype)) 583 for (i in t) { 584 if ( 585 ((a = t[i]), 586 (s = e.noTargetGet ? (r = _e(n, i)) && r.value : n[i]), 587 !we(u ? i : c + (l ? '.' : '#') + i, e.forced) && void 0 !== s) 588 ) { 589 if (typeof a == typeof s) continue 590 ye(a, s) 591 } 592 ;(e.sham || (s && s.sham)) && $(a, 'sham', !0), G(n, i, a, e) 593 } 594 }, 595 Ae = 596 Object.keys || 597 function (e) { 598 return le(e, de) 599 }, 600 qe = function (e) { 601 return Object(m(e)) 602 }, 603 $e = Object.assign, 604 Te = Object.defineProperty, 605 Be = 606 !$e || 607 s(function () { 608 if ( 609 a && 610 1 !== 611 $e( 612 { 613 b: 1, 614 }, 615 $e( 616 Te({}, 'a', { 617 enumerable: !0, 618 get: function () { 619 Te(this, 'b', { 620 value: 3, 621 enumerable: !1, 622 }) 623 }, 624 }), 625 { 626 b: 2, 627 } 628 ) 629 ).b 630 ) 631 return !0 632 var e = {}, 633 t = {}, 634 n = Symbol() 635 return ( 636 (e[n] = 7), 637 'abcdefghijklmnopqrst'.split('').forEach(function (e) { 638 t[e] = e 639 }), 640 7 != $e({}, e)[n] || 'abcdefghijklmnopqrst' != Ae($e({}, t)).join('') 641 ) 642 }) 643 ? function (e, t) { 644 for (var n = qe(e), i = arguments.length, o = 1, s = me.f, r = u.f; i > o; ) 645 for (var c, l = h(arguments[o++]), d = s ? Ae(l).concat(s(l)) : Ae(l), p = d.length, m = 0; p > m; ) 646 (c = d[m++]), (a && !r.call(l, c)) || (n[c] = l[c]) 647 return n 648 } 649 : $e 650 xe( 651 { 652 target: 'Object', 653 stat: !0, 654 forced: Object.assign !== Be, 655 }, 656 { 657 assign: Be, 658 } 659 ) 660 var Me = 661 ''.repeat || 662 function (e) { 663 var t = String(m(this)), 664 n = '', 665 i = ie(e) 666 if (i < 0 || i == 1 / 0) throw RangeError('Wrong number of repetitions') 667 for (; i > 0; (i >>>= 1) && (t += t)) 1 & i && (n += t) 668 return n 669 },
670 Ee = Math.ceil, 671 Le = function (e) { 672 return function (t, n, i) { 673 var o, 674 s, 675 a = String(m(t)), 676 r = a.length, 677 c = void 0 === i ? ' ' : String(i), 678 u = se(n) 679 return u <= r || '' == c 680 ? a 681 : ((o = u - r), (s = Me.call(c, Ee(o / c.length))).length > o && (s = s.slice(0, o)), e ? a + s : s + a) 682 } 683 }, 684 Fe = { 685 start: Le(!1), 686 end: Le(!0), 687 }, 688 Ie = ee('navigator', 'userAgent') || '', 689 De = /Version\/10\.\d+(\.\d+)?( Mobile\/\w+)? Safari\//.test(Ie), 690 Oe = Fe.end 691 xe( 692 { 693 target: 'String', 694 proto: !0, 695 forced: De, 696 }, 697 { 698 padEnd: function (e) { 699 return Oe(this, e, arguments.length > 1 ? arguments[1] : void 0) 700 }, 701 } 702 ) 703 var Pe = Fe.start 704 function je(e) { 705 return (je = 706 'function' == typeof Symbol && 'symbol' == typeof Symbol.iterator 707 ? function (e) { 708 return typeof e 709 } 710 : function (e) { 711 return e && 'function' == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype 712 ? 'symbol' 713 : typeof e 714 })(e) 715 } 716 function Re(e, t) { 717 if (!(e instanceof t)) throw new TypeError('Cannot call a class as a function') 718 } 719 function Ne(e, t) { 720 for (var n = 0; n < t.length; n++) { 721 var i = t[n] 722 ;(i.enumerable = i.enumerable || !1), 723 (i.configurable = !0), 724 'value' in i && (i.writable = !0), 725 Object.defineProperty(e, i.key, i) 726 } 727 } 728 function He(e, t, n) { 729 return t && Ne(e.prototype, t), n && Ne(e, n), e 730 } 731 function Ve(e, t) { 732 if ('function' != typeof t && null !== t) 733 throw new TypeError('Super expression must either be null or a function') 734 ;(e.prototype = Object.create(t && t.prototype, { 735 constructor: { 736 value: e, 737 writable: !0, 738 configurable: !0, 739 }, 740 })), 741 t && Ue(e, t) 742 } 743 function ze(e) { 744 return (ze = Object.setPrototypeOf 745 ? Object.getPrototypeOf 746 : function (e) { 747 return e.__proto__ || Object.getPrototypeOf(e) 748 })(e) 749 } 750 function Ue(e, t) { 751 return (Ue = 752 Object.setPrototypeOf || 753 function (e, t) { 754 return (e.__proto__ = t), e 755 })(e, t) 756 } 757 function We(e, t) { 758 if (null == e) return {} 759 var n, 760 i, 761 o = (function (e, t) { 762 if (null == e) return {} 763 var n, 764 i, 765 o = {}, 766 s = Object.keys(e) 767 for (i = 0; i < s.length; i++) (n = s[i]), t.indexOf(n) >= 0 || (o[n] = e[n]) 768 return o 769 })(e, t) 770 if (Object.getOwnPropertySymbols) { 771 var s = Object.getOwnPropertySymbols(e) 772 for (i = 0; i < s.length; i++) 773 (n = s[i]), t.indexOf(n) >= 0 || (Object.prototype.propertyIsEnumerable.call(e, n) && (o[n] = e[n])) 774 } 775 return o 776 } 777 function Qe(e, t) { 778 return !t || ('object' != typeof t && 'function' != typeof t) 779 ? (function (e) { 780 if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called") 781 return e 782 })(e) 783 : t 784 } 785 function Ye(e) { 786 var t = (function () { 787 if ('undefined' == typeof Reflect || !Reflect.construct) return !1 788 if (Reflect.construct.sham) return !1 789 if ('function' == typeof Proxy) return !0 790 try { 791 return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})), !0 792 } catch (e) { 793 return !1 794 } 795 })() 796 return function () { 797 var n, 798 i = ze(e) 799 if (t) { 800 var o = ze(this).constructor 801 n = Reflect.construct(i, arguments, o) 802 } else n = i.apply(this, arguments) 803 return Qe(this, n) 804 } 805 } 806 function Ke(e, t) { 807 for (; !Object.prototype.hasOwnProperty.call(e, t) && null !== (e = ze(e)); ); 808 return e 809 } 810 function Je(e, t, n) { 811 return (Je = 812 'undefined' != typeof Reflect && Reflect.get 813 ? Reflect.get 814 : function (e, t, n) { 815 var i = Ke(e, t) 816 if (i) { 817 var o = Object.getOwnPropertyDescriptor(i, t) 818 return o.get ? o.get.call(n) : o.value 819 } 820 })(e, t, n || e) 821 } 822 function Ge(e, t, n, i) { 823 return (Ge = 824 'undefined' != typeof Reflect && Reflect.set 825 ? Reflect.set 826 : function (e, t, n, i) { 827 var o, 828 s = Ke(e, t) 829 if (s) { 830 if ((o = Object.getOwnPropertyDescriptor(s, t)).set) return o.set.call(i, n), !0 831 if (!o.writable) return !1 832 } 833 if ((o = Object.getOwnPropertyDescriptor(i, t))) { 834 if (!o.writable) return !1 835 ;
835(o.value = n), Object.defineProperty(i, t, o) 836 } else 837 !(function (e, t, n) { 838 t in e 839 ? Object.defineProperty(e, t, { 840 value: n, 841 enumerable: !0, 842 configurable: !0, 843 writable: !0, 844 }) 845 : (e[t] = n) 846 })(i, t, n) 847 return !0 848 })(e, t, n, i) 849 } 850 function Xe(e, t, n, i, o) { 851 if (!Ge(e, t, n, i || e) && o) throw new Error('failed to set property') 852 return n 853 } 854 function Ze(e, t) { 855 return ( 856 (function (e) { 857 if (Array.isArray(e)) return e 858 })(e) || 859 (function (e, t) { 860 if ('undefined' == typeof Symbol || !(Symbol.iterator in Object(e))) return 861 var n = [], 862 i = !0, 863 o = !1, 864 s = void 0 865 try { 866 for ( 867 var a, r = e[Symbol.iterator](); 868 !(i = (a = r.next()).done) && (n.push(a.value), !t || n.length !== t); 869 i = !0 870 ); 871 } catch (e) { 872 ;(o = !0), (s = e) 873 } finally { 874 try { 875 i || null == r.return || r.return() 876 } finally { 877 if (o) throw s 878 } 879 } 880 return n 881 })(e, t) || 882 (function (e, t) { 883 if (!e) return 884 if ('string' == typeof e) return et(e, t) 885 var n = Object.prototype.toString.call(e).slice(8, -1) 886 'Object' === n && e.constructor && (n = e.constructor.name) 887 if ('Map' === n || 'Set' === n) return Array.from(e) 888 if ('Arguments' === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return et(e, t) 889 })(e, t) || 890 (function () { 891 throw new TypeError( 892 'Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.' 893 ) 894 })() 895 ) 896 } 897 function et(e, t) { 898 ;(null == t || t > e.length) && (t = e.length) 899 for (var n = 0, i = new Array(t); n < t; n++) i[n] = e[n] 900 return i 901 } 902 function tt(e) { 903 return 'string' == typeof e || e instanceof String 904 } 905 xe( 906 { 907 target: 'String', 908 proto: !0, 909 forced: De, 910 }, 911 { 912 padStart: function (e) { 913 return Pe(this, e, arguments.length > 1 ? arguments[1] : void 0) 914 }, 915 } 916 ), 917 xe( 918 { 919 target: 'String', 920 proto: !0, 921 }, 922 { 923 repeat: Me, 924 } 925 ), 926 xe( 927 { 928 global: !0, 929 }, 930 { 931 globalThis: o, 932 } 933 ) 934 var nt = 'NONE', 935 it = 'LEFT', 936 ot = 'FORCE_LEFT', 937 st = 'RIGHT', 938 at = 'FORCE_RIGHT' 939 function rt(e) { 940 switch (e) { 941 case it: 942 return ot 943 case st: 944 return at 945 default: 946 return e 947 } 948 } 949 function ct(e) { 950 return e.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1') 951 } 952 var ut = (function () { 953 function e(t, n, i, o) { 954 for (
955 Re(this, e), this.value = t, this.cursorPos = n, this.oldValue = i, this.oldSelection = o; 956 this.value.slice(0, this.startChangePos) !== this.oldValue.slice(0, this.startChangePos); 957 958 ) 959 --this.oldSelection.start 960 } 961 return ( 962 He(e, [ 963 { 964 key: 'startChangePos', 965 get: function () { 966 return Math.min(this.cursorPos, this.oldSelection.start) 967 }, 968 }, 969 { 970 key: 'insertedCount', 971 get: function () { 972 return this.cursorPos - this.startChangePos 973 }, 974 }, 975 { 976 key: 'inserted', 977 get: function () { 978 return this.value.substr(this.startChangePos, this.insertedCount) 979 }, 980 }, 981 { 982 key: 'removedCount', 983 get: function () { 984 return Math.max( 985 this.oldSelection.end - this.startChangePos || this.oldValue.length - this.value.length, 986 0 987 ) 988 }, 989 }, 990 { 991 key: 'removed', 992 get: function () { 993 return this.oldValue.substr(this.startChangePos, this.removedCount) 994 }, 995 }, 996 { 997 key: 'head', 998 get: function () { 999 return this.value.substring(0, this.startChangePos) 1000 }, 1001 }, 1002 { 1003 key: 'tail', 1004 get: function () { 1005 return this.value.substring(this.startChangePos + this.insertedCount) 1006 }, 1007 }, 1008 { 1009 key: 'removeDirection', 1010 get: function () { 1011 return !this.removedCount || this.insertedCount 1012 ? nt 1013 : this.oldSelection.end === this.cursorPos || this.oldSelection.start === this.cursorPos 1014 ? st 1015 : it 1016 }, 1017 }, 1018 ]), 1019 e 1020 ) 1021 })(), 1022 lt = (function () { 1023 function e(t) { 1024 Re(this, e), 1025 Object.assign( 1026 this, 1027 { 1028 inserted: '', 1029 rawInserted: '', 1030 skip: !1, 1031 tailShift: 0, 1032 }, 1033 t 1034 ) 1035 } 1036 return ( 1037 He(e, [ 1038 { 1039 key: 'aggregate', 1040 value: function (e) { 1041 return ( 1042 (this.rawInserted += e.rawInserted), 1043 (this.skip = this.skip || e.skip), 1044 (this.inserted += e.inserted), 1045 (this.tailShift += e.tailShift), 1046 this 1047 ) 1048 }, 1049 }, 1050 { 1051 key: 'offset', 1052 get: function () { 1053 return this.tailShift + this.inserted.length 1054 }, 1055 }, 1056 ]), 1057 e 1058 ) 1059 })(), 1060 dt = (function () { 1061 function e() { 1062 var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : '', 1063 n = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 0, 1064 i = arguments.length > 2 ? arguments[2] : void 0 1065 Re(this, e), (this.value = t), (this.from = n), (this.stop = i) 1066 } 1067 return ( 1068 He(e, [ 1069 { 1070 key: 'toString', 1071 value: function () { 1072 return this.value 1073 }, 1074 }, 1075 { 1076 key: 'extend', 1077 value: function (e) { 1078 this.value += String(e) 1079 }, 1080 }, 1081 { 1082 key: 'appendTo', 1083 value: function (e) { 1084 return e 1085 .append(this.toString(), { 1086 tail: !0, 1087 }) 1088 .aggregate(e._appendPlaceholder()) 1089 }, 1090 }, 1091 { 1092 key: 'state', 1093 get: function () { 1094 return { 1095 value: this.value, 1096 from: this.from, 1097 stop: this.stop, 1098 } 1099 }, 1100 set: function (e) { 1101 Object.assign(this, e) 1102 }, 1103 }, 1104 { 1105 key: 'shiftBefore', 1106 value: function (e) { 1107 if (this.from >= e || !this.value.length) return '' 1108 var t = this.value[0] 1109 return (this.value = this.value.slice(1)), t 1110 }, 1111 }, 1112 ]), 1113 e 1114 ) 1115 })() 1116 function pt(e) { 1117 var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {} 1118 return new pt.InputMask(e, t) 1119 } 1120 var ht = (function () { 1121 function e(t) { 1122 Re(this, e), (this._value = ''), this._update(Object.assign({}, e.DEFAULTS, t)), (this.isInitialized = !0) 1123 } 1124 return ( 1125 He(e, [ 1126 { 1127 key: 'updateOptions', 1128 value: function (e) { 1129 Object.keys(e).length && this.withValueRefresh(this._update.bind(this, e)) 1130 }, 1131 }, 1132 { 1133 key: '_update', 1134 value: function (e) { 1135 Object.assign(this, e) 1136 }, 1137 }, 1138 { 1139 key: 'state', 1140 get: function () { 1141 return { 1142 _value: this.value, 1143 } 1144 }, 1145 set: function (e) { 1146 this._value = e._value 1147 }, 1148 }, 1149 { 1150 key: 'reset', 1151 value: function () { 1152 this._value = '' 1153 }, 1154 }, 1155 { 1156 key: 'value', 1157 get: function () { 1158 return this._value 1159 }, 1160 set: function (e) { 1161 this.resolve(e) 1162 }, 1163 }, 1164 { 1165 key: 'resolve', 1166 value: function (e) { 1167 return ( 1168 this.reset(), 1169 this.append( 1170 e, 1171 { 1172 input: !0, 1173 }, 1174 '' 1175 ), 1176 this.doCommit(), 1177 this.value 1178 ) 1179 }, 1180 }, 1181 { 1182 key: 'unmaskedValue', 1183 get: function () { 1184 return this.value 1185 }, 1186 set: function (e) { 1187 this.reset(), this.append(e, {}, ''), this.doCommit() 1188 }, 1189 }, 1190 { 1191 key: 'typedValue', 1192 get: function () { 1193 return this.doParse(this.value) 1194 }, 1195 set: function (e) { 1196 this.value = this.doFormat(e) 1197 }, 1198 }, 1199 { 1200 key: 'rawInputValue', 1201 get: function () { 1202 return this.extractInput(0, this.value.length, { 1203 raw: !0, 1204 }) 1205 }, 1206 set: function (e) { 1207 this.reset(), 1208 this.append( 1209 e, 1210 { 1211 raw: !0, 1212 }, 1213 '' 1214 ), 1215 this.doCommit() 1216 }, 1217 }, 1218 { 1219 key: 'isComplete', 1220 get: function () { 1221 return !0 1222 }, 1223 }, 1224 { 1225 key: 'nearestInputPos', 1226 value: function (e, t) { 1227 return e 1228 }, 1229 }, 1230 { 1231 key: 'extractInput', 1232 value: function () { 1233 var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 0, 1234 t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : this.value.length 1235 return this.value.slice(e, t) 1236 }, 1237 }, 1238 { 1239 key: 'extractTail', 1240 value: function () { 1241 var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 0, 1242 t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : this.value.length 1243 return new dt(this.extractInput(e, t), e) 1244 }, 1245 }, 1246 { 1247 key: 'appendTail', 1248 value: function (e) { 1249 return tt(e) && (e = new dt(String(e))), e.appendTo(this) 1250 }, 1251 }, 1252 { 1253 key: '_appendCharRaw', 1254 value: function (e) { 1255 return e 1256 ? ((this._value += e), 1257 new lt({ 1258 inserted: e, 1259 rawInserted: e, 1260 })) 1261 : new lt() 1262 }, 1263 }, 1264 { 1265 key: '_appendChar', 1266 value: function (e) { 1267 var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}, 1268 n = arguments.length > 2 ? arguments[2] : void 0, 1269 i = this.state, 1270 o = this._appendCharRaw(this.doPrepare(e, t), t) 1271 if (o.inserted) { 1272 var s, 1273 a = !1 !== this.doValidate(t) 1274 if (a && null != n) { 1275 var r = this.state 1276 this.overwrite && ((s = n.state), n.shiftBefore(this.value.length)) 1277 var c = this.appendTail(n) 1278 ;(a = c.rawInserted === n.toString()) && c.inserted && (this.state = r) 1279 } 1280 a || ((o = new lt()), (this.state = i), n && s && (n.state = s)) 1281 } 1282 return o 1283 }, 1284 }, 1285 { 1286 key: '_appendPlaceholder', 1287 value: function () { 1288 return new lt() 1289 }, 1290 }, 1291 { 1292 key: 'append', 1293 value: function (e, t, n) { 1294 if (!tt(e)) throw new Error('value should be string') 1295 var i = new lt(), 1296 o = tt(n) ? new dt(String(n)) : n 1297 t && t.tail && (t._beforeTailState = this.state) 1298 for (var s = 0; s < e.length; ++s) i.aggregate(this._appendChar(e[s], t, o)) 1299 return null != o && (i.tailShift += this.appendTail(o).tailShift), i 1300 }, 1301 }, 1302 { 1303 key: 'remove', 1304 value: function () { 1305 var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 0, 1306 t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : this.value.length 1307 return (this._value = this.value.slice(0, e) + this.value.slice(t)), new lt() 1308 }, 1309 }, 1310 { 1311 key: 'withValueRefresh', 1312 value: function (e) { 1313 if (this._refreshing || !this.isInitialized) return e() 1314 this._refreshing = !0 1315 var t = this.rawInputValue, 1316 n = this.value, 1317 i = e() 1318 return ( 1319 (this.rawInputValue = t), 1320 this.value && 1321 this.value !== n && 1322 0 === n.indexOf(this.value) && 1323 this.append(n.slice(this.value.length), {}, ''), 1324 delete this._refreshing, 1325 i 1326 ) 1327 }, 1328 }, 1329 { 1330 key: 'runIsolated', 1331 value: function (e) { 1332 if (this._isolated || !this.isInitialized) return e(this) 1333 this._isolated = !0 1334 var t = this.state, 1335 n = e(this) 1336 return (this.state = t), delete this._isolated, n 1337 }, 1338 }, 1339 { 1340 key: 'doPrepare', 1341 value: function (e) { 1342 var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {} 1343 return this.prepare ? this.prepare(e, this, t) : e 1344 }, 1345 }, 1346 { 1347 key: 'doValidate', 1348 value: function (e) { 1349 return ( 1350 (!this.validate || this.validate(this.value, this, e)) && (!this.parent || this.parent.doValidate(e)) 1351 ) 1352 }, 1353 }, 1354 { 1355 key: 'doCommit', 1356 value: function () { 1357 this.commit && this.commit(this.value, this) 1358 }, 1359 }, 1360 { 1361 key: 'doFormat', 1362 value: function (e) { 1363 return this.format ? this.format(e, this) : e 1364 }, 1365 }, 1366 { 1367 key: 'doParse', 1368 value: function (e) { 1369 return this.parse ? this.parse(e, this) : e 1370 }, 1371 }, 1372 { 1373 key: 'splice', 1374 value: function (e, t, n, i) { 1375 var o = e + t, 1376 s = this.extractTail(o), 1377 a = this.nearestInputPos(e, i) 1378 return new lt({ 1379 tailShift: a - e, 1380 }) 1381 .aggregate(this.remove(a)) 1382 .aggregate( 1383 this.append( 1384 n, 1385 { 1386 input: !0, 1387 }, 1388 s 1389 ) 1390 ) 1391 }, 1392 }, 1393 ]), 1394 e 1395 ) 1396 })() 1397 function mt(e) { 1398 if (null == e) throw new Error('mask property should be defined') 1399 return e instanceof RegExp 1400 ? pt.MaskedRegExp 1401 : tt(e) 1402 ? pt.MaskedPattern 1403 : e instanceof Date || e === Date 1404 ? pt.MaskedDate 1405 : e instanceof Number || 'number' == typeof e || e === Number 1406 ? pt.MaskedNumber 1407 : Array.isArray(e) || e === Array 1408 ? pt.MaskedDynamic 1409 : pt.Masked && e.prototype instanceof pt.Masked 1410 ? e 1411 : e instanceof Function 1412 ? pt.MaskedFunction 1413 : e instanceof pt.Masked 1414 ? e.constructor 1415 : (console.warn('Mask not found for mask', e), pt.Masked) 1416 } 1417 function ft(e) { 1418 if (pt.Masked && e instanceof pt.Masked) return e 1419 var t = (e = Object.assign({}, e)).mask 1420 if (pt.Masked && t instanceof pt.Masked) return t 1421 var n = mt(t) 1422 if (!n) 1423 throw new Error( 1424 'Masked class is not found for provided mask, appropriate module needs to be import manually before creating mask.'
1425 ) 1426 return new n(e) 1427 } 1428 ;(ht.DEFAULTS = { 1429 format: function (e) { 1430 return e 1431 }, 1432 parse: function (e) { 1433 return e 1434 }, 1435 }), 1436 (pt.Masked = ht), 1437 (pt.createMask = ft) 1438 var yt = { 1439 0: /\d/, 1440 a: /[\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFB
1440D3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/, 1441 '*': /./, 1442 }, 1443 vt = (function () { 1444 function e(t) { 1445 Re(this, e) 1446 var n = t.mask, 1447 i = We(t, ['mask']) 1448 ;(this.masked = ft({ 1449 mask: n, 1450 })), 1451 Object.assign(this, i) 1452 } 1453 return ( 1454 He(e, [ 1455 { 1456 key: 'reset', 1457 value: function () { 1458 ;(this._isFilled = !1), this.masked.reset() 1459 }, 1460 }, 1461 { 1462 key: 'remove', 1463 value: function () { 1464 var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 0, 1465 t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : this.value.length 1466 return 0 === e && t >= 1 ? ((this._isFilled = !1), this.masked.remove(e, t)) : new lt() 1467 }, 1468 }, 1469 { 1470 key: 'value', 1471 get: function () { 1472 return this.masked.value || (this._isFilled && !this.isOptional ? this.placeholderChar : '') 1473 }, 1474 }, 1475 { 1476 key: 'unmaskedValue', 1477 get: function () { 1478 return this.masked.unmaskedValue 1479 }, 1480 }, 1481 { 1482 key: 'isComplete', 1483 get: function () { 1484 return Boolean(this.masked.value) || this.isOptional 1485 }, 1486 }, 1487 { 1488 key: '_appendChar', 1489 value: function (e) { 1490 var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {} 1491 if (this._isFilled) return new lt() 1492 var n = this.masked.state, 1493 i = this.masked._appendChar(e, t) 1494 return ( 1495 i.inserted && 1496 !1 === this.doValidate(t) && 1497 ((i.inserted = i.rawInserted = ''), (this.masked.state = n)), 1498 i.inserted || this.isOptional || this.lazy || t.input || (i.inserted = this.placeholderChar), 1499 (i.skip = !i.inserted && !this.isOptional), 1500 (this._isFilled = Boolean(i.inserted)), 1501 i 1502 ) 1503 }, 1504 }, 1505 { 1506 key: 'append', 1507 value: function () { 1508 var e 1509 return (e = this.masked).append.apply(e, arguments) 1510 }, 1511 }, 1512 { 1513 key: '_appendPlaceholder', 1514 value: function () { 1515 var e = new lt() 1516 return ( 1517 this._isFilled || this.isOptional || ((this._isFilled = !0), (e.inserted = this.placeholderChar)), e 1518 ) 1519 }, 1520 }, 1521 { 1522 key: 'extractTail', 1523 value: function () { 1524 var e 1525 return (e = this.masked).extractTail.apply(e, arguments) 1526 }, 1527 }, 1528 { 1529 key: 'appendTail', 1530 value: function () { 1531 var e 1532 return (e = this.masked).appendTail.apply(e, arguments) 1533 }, 1534 }, 1535 { 1536 key: 'extractInput', 1537 value: function () { 1538 var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 0, 1539 t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : this.value.length, 1540 n = arguments.length > 2 ? arguments[2] : void 0 1541 return this.masked.extractInput(e, t, n) 1542 }, 1543 }, 1544 { 1545 key: 'nearestInputPos', 1546 value: function (e) { 1547 var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : nt, 1548 n = 0, 1549 i = this.value.length, 1550 o = Math.min(Math.max(e, n), i) 1551 switch (t) { 1552 case it: 1553 case ot: 1554 return this.isComplete ? o : n 1555 case st: 1556 case at: 1557 return this.isComplete ? o : i 1558 case nt: 1559 default: 1560 return o 1561 } 1562 }, 1563 }, 1564 { 1565 key: 'doValidate', 1566 value: function () { 1567 var e, t 1568 return ( 1569 (e = this.masked).doValidate.apply(e, arguments) && 1570 (!this.parent || (t = this.parent).doValidate.apply(t, arguments)) 1571 ) 1572 }, 1573 }, 1574 { 1575 key: 'doCommit', 1576 value: function () { 1577 this.masked.doCommit() 1578 }, 1579 }, 1580 { 1581 key: 'state', 1582 get: function () { 1583 return { 1584 masked: this.masked.state, 1585 _isFilled: this._isFilled, 1586 } 1587 }, 1588 set: function (e) { 1589 ;(this.masked.state = e.masked), (this._isFilled = e._isFilled) 1590 }, 1591 }, 1592 ]), 1593 e 1594 ) 1595 })(), 1596 gt = (function () { 1597 function e(t) { 1598 Re(this, e), Object.assign(this, t), (this._value = '') 1599 } 1600 return ( 1601 He(e, [ 1602 { 1603 key: 'value', 1604 get: function () { 1605 return this._value 1606 }, 1607 }, 1608 { 1609 key: 'unmaskedValue', 1610 get: function () { 1611 return this.isUnmasking ? this.value : '' 1612 }, 1613 }, 1614 { 1615 key: 'reset', 1616 value: function () { 1617 ;(this._isRawInput = !1), (this._value = '') 1618 }, 1619 }, 1620 { 1621 key: 'remove', 1622 value: function () { 1623 var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 0, 1624 t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : this._value.length 1625 return ( 1626 (this._value = this._value.slice(0, e) + this._value.slice(t)), 1627 this._value || (this._isRawInput = !1), 1628 new lt() 1629 ) 1630 }, 1631 }, 1632 { 1633 key: 'nearestInputPos', 1634 value: function (e) { 1635 var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : nt, 1636 n = 0, 1637 i = this._value.length 1638 switch (t) { 1639 case it: 1640 case ot: 1641 return n 1642 case nt: 1643 case st: 1644 case at: 1645 default: 1646 return i 1647 } 1648 }, 1649 }, 1650 { 1651 key: 'extractInput', 1652 value: function () { 1653 var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 0, 1654 t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : this._value.length, 1655 n = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {} 1656 return (n.raw && this._isRawInput && this._value.slice(e, t)) || '' 1657 }, 1658 }, 1659 { 1660 key: 'isComplete', 1661 get: function () { 1662 return !0 1663 }, 1664 }, 1665 { 1666 key: '_appendChar', 1667 value: function (e) { 1668 var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}, 1669 n = new lt() 1670 if (this._value) return n 1671 var i = this.char === e[0], 1672 o = i && (this.isUnmasking || t.input || t.raw) && !t.tail 1673 return ( 1674 o && (n.rawInserted = this.char), 1675 (this._value = n.inserted = this.char), 1676 (this._isRawInput = o && (t.raw || t.input)), 1677 n 1678 ) 1679 }, 1680 }, 1681 { 1682 key: '_appendPlaceholder', 1683 value: function () { 1684 var e = new lt() 1685 return this._value || (this._value = e.inserted = this.char), e 1686 }, 1687 }, 1688 { 1689 key: 'extractTail', 1690 value: function () { 1691 return (arguments.length > 1 && void 0 !== arguments[1]) || this.value.length, new dt('') 1692 }, 1693 }, 1694 { 1695 key: 'appendTail', 1696 value: function (e) { 1697 return tt(e) && (e = new dt(String(e))), e.appendTo(this) 1698 }, 1699 }, 1700 { 1701 key: 'append', 1702 value: function (e, t, n) { 1703 var i = this._appendChar(e, t) 1704 return null != n && (i.tailShift += this.appendTail(n).tailShift), i 1705 }, 1706 }, 1707 { 1708 key: 'doCommit', 1709 value: function () {}, 1710 }, 1711 { 1712 key: 'state', 1713 get: function () { 1714 return { 1715 _value: this._value, 1716 _isRawInput: this._isRawInput, 1717 } 1718 }, 1719 set: function (e) { 1720 Object.assign(this, e) 1721 }, 1722 }, 1723 ]), 1724 e 1725 ) 1726 })(), 1727 bt = (function () { 1728 function e() { 1729 var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : [], 1730 n = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 0 1731 Re(this, e), (this.chunks = t), (this.from = n) 1732 } 1733 return ( 1734 He(e, [ 1735 { 1736 key: 'toString', 1737 value: function () { 1738 return this.chunks.map(String).join('') 1739 }, 1740 }, 1741 { 1742 key: 'extend', 1743 value: function (t) { 1744 if (String(t)) { 1745 tt(t) && (t = new dt(String(t))) 1746 var n = this.chunks[this.chunks.length - 1], 1747 i = n && (n.stop === t.stop || null == t.stop) && t.from === n.from + n.toString().length 1748 if (t instanceof dt) i ? n.extend(t.toString()) : this.chunks.push(t) 1749 else if (t instanceof e) { 1750 if (null == t.stop) 1751 for (var o; t.chunks.length && null == t.chunks[0].stop; ) 1752 ((o = t.chunks.shift()).from += t.from), this.extend(o) 1753 t.toString() && ((t.stop = t.blockIndex), this.chunks.push(t)) 1754 } 1755 } 1756 }, 1757 }, 1758 { 1759 key: 'appendTo', 1760 value: function (t) { 1761 if (!(t instanceof pt.MaskedPattern)) return new dt(this.toString()).appendTo(t) 1762 for (var n = new lt(), i = 0; i < this.chunks.length && !n.skip; ++i) { 1763 var o = this.chunks[i], 1764 s = t._mapPosToBlock(t.value.length), 1765 a = o.stop, 1766 r = void 0 1767 if ( 1768 (null != a && 1769 (!s || s.index <= a) && 1770 ((o instanceof e || t._stops.indexOf(a) >= 0) && n.aggregate(t._appendPlaceholder(a)), 1771 (r = o instanceof e && t._blocks[a])), 1772 r) 1773 ) { 1774 var c = r.appendTail(o) 1775 ;(c.skip = !1), n.aggregate(c), (t._value += c.inserted) 1776 var u = o.toString().slice(c.rawInserted.length) 1777 u && 1778 n.aggregate( 1779 t.append(u, { 1780 tail: !0, 1781 }) 1782 ) 1783 } else 1784 n.aggregate( 1785 t.append(o.toString(), { 1786 tail: !0, 1787 }) 1788 ) 1789 } 1790 return n 1791 }, 1792 }, 1793 { 1794 key: 'state', 1795 get: function () { 1796 return { 1797 chunks: this.chunks.map(function (e) { 1798 return e.state 1799 }), 1800 from: this.from, 1801 stop: this.stop, 1802 blockIndex: this.blockIndex, 1803 } 1804 }, 1805 set: function (t) { 1806 var n = t.chunks, 1807 i = We(t, ['chunks']) 1808 Object.assign(this, i), 1809 (this.chunks = n.map(function (t) { 1810 var n = 'chunks' in t ? new e() : new dt() 1811 return (n.state = t), n 1812 })) 1813 }, 1814 }, 1815 { 1816 key: 'shiftBefore', 1817 value: function (e) { 1818 if (this.from >= e || !this.chunks.length) return '' 1819 for (var t = e - this.from, n = 0; n < this.chunks.length; ) { 1820 var i = this.chunks[n], 1821 o = i.shiftBefore(t) 1822 if (i.toString()) { 1823 if (!o) break 1824 ++n 1825 } else this.chunks.splice(n, 1) 1826 if (o) return o 1827 } 1828 return '' 1829 }, 1830 }, 1831 ]), 1832 e 1833 ) 1834 })(), 1835 kt = (function (e) { 1836 Ve(n, e) 1837 var t = Ye(n) 1838 function n() { 1839 return Re(this, n), t.apply(this, arguments) 1840 } 1841 return ( 1842 He(n, [ 1843 { 1844 key: '_update', 1845 value: function (e) { 1846 e.mask && 1847 (e.validate = function (t) { 1848 return t.search(e.mask) >= 0 1849 }), 1850 Je(ze(n.prototype), '_update', this).call(this, e) 1851 }, 1852 }, 1853 ]), 1854 n 1855 ) 1856 })(ht) 1857 pt.MaskedRegExp = kt 1858 var St = (function (e) { 1859 Ve(n, e) 1860 var t = Ye(n) 1861 function n() { 1862 var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {} 1863 return ( 1864 Re(this, n), 1865 (e.definitions = Object.assign({}, yt, e.definitions)), 1866 t.call(this, Object.assign({}, n.DEFAULTS, e)) 1867 ) 1868 } 1869 return ( 1870 He(n, [ 1871 { 1872 key: '_update', 1873 value: function () { 1874 var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {} 1875 ;(e.definitions = Object.assign({}, this.definitions, e.definitions)), 1876 Je(ze(n.prototype), '_update', this).call(this, e), 1877 this._rebuildMask() 1878 }, 1879 }, 1880 { 1881 key: '_rebuildMask', 1882 value: function () { 1883 var e = this, 1884 t = this.definitions 1885 ;(this._blocks = []), (this._stops = []), (this._maskedBlocks = {}) 1886 var i = this.mask 1887 if (i && t) 1888 for (var o = !1, s = !1, a = 0; a < i.length; ++a) { 1889 if (this.blocks) 1890 if ( 1891 'continue' === 1892 (function () { 1893 var t = i.slice(a), 1894 n = Object.keys(e.blocks).filter(function (e) { 1895 return 0 === t.indexOf(e) 1896 }) 1897 n.sort(function (e, t) { 1898 return t.length - e.length 1899
1899 }) 1900 var o = n[0] 1901 if (o) { 1902 var s = ft( 1903 Object.assign( 1904 { 1905 parent: e, 1906 lazy: e.lazy, 1907 placeholderChar: e.placeholderChar, 1908 overwrite: e.overwrite, 1909 }, 1910 e.blocks[o] 1911 ) 1912 ) 1913 return ( 1914 s && 1915 (e._blocks.push(s), 1916 e._maskedBlocks[o] || (e._maskedBlocks[o] = []), 1917 e._maskedBlocks[o].push(e._blocks.length - 1)), 1918 (a += o.length - 1), 1919 'continue' 1920 ) 1921 } 1922 })() 1923 ) 1924 continue 1925 var r = i[a], 1926 c = r in t 1927 if (r !== n.STOP_CHAR) 1928 if ('{' !== r && '}' !== r) 1929 if ('[' !== r && ']' !== r) { 1930 if (r === n.ESCAPE_CHAR) { 1931 if ((++a, !(r = i[a]))) break 1932 c = !1 1933 } 1934 var u = c 1935 ? new vt({ 1936 parent: this, 1937 lazy: this.lazy, 1938 placeholderChar: this.placeholderChar, 1939 mask: t[r], 1940 isOptional: s, 1941 }) 1942 : new gt({ 1943 char: r, 1944 isUnmasking: o, 1945 }) 1946 this._blocks.push(u) 1947 } else s = !s 1948 else o = !o 1949 else this._stops.push(this._blocks.length) 1950 } 1951 }, 1952 }, 1953 { 1954 key: 'state', 1955 get: function () { 1956 return Object.assign({}, Je(ze(n.prototype), 'state', this), { 1957 _blocks: this._blocks.map(function (e) { 1958 return e.state 1959 }), 1960 }) 1961 }, 1962 set: function (e) { 1963 var t = e._blocks, 1964 i = We(e, ['_blocks']) 1965 this._blocks.forEach(function (e, n) { 1966 return (e.state = t[n]) 1967 }), 1968 Xe(ze(n.prototype), 'state', i, this, !0) 1969 }, 1970 }, 1971 { 1972 key: 'reset', 1973 value: function () { 1974 Je(ze(n.prototype), 'reset', this).call(this), 1975 this._blocks.forEach(function (e) { 1976 return e.reset() 1977 }) 1978 }, 1979 }, 1980 { 1981 key: 'isComplete', 1982 get: function () { 1983 return this._blocks.every(function (e) { 1984 return e.isComplete 1985 }) 1986 }, 1987 }, 1988 { 1989 key: 'doCommit', 1990 value: function () { 1991 this._blocks.forEach(function (e) { 1992 return e.doCommit() 1993 }), 1994 Je(ze(n.prototype), 'doCommit', this).call(this) 1995 }, 1996 }, 1997 { 1998 key: 'unmaskedValue', 1999 get: function () { 2000 return this._blocks.reduce(function (e, t) { 2001 return e + t.unmaskedValue 2002 }, '') 2003 }, 2004 set: function (e) { 2005 Xe(ze(n.prototype), 'unmaskedValue', e, this, !0) 2006 }, 2007 }, 2008 { 2009 key: 'value', 2010 get: function () { 2011 return this._blocks.reduce(function (e, t) { 2012 return e + t.value 2013 }, '') 2014 }, 2015 set: function (e) { 2016 Xe(ze(n.prototype), 'value', e, this, !0) 2017 }, 2018 }, 2019 { 2020 key: 'appendTail', 2021 value: function (e) { 2022 return Je(ze(n.prototype), 'appendTail', this).call(this, e).aggregate(this._appendPlaceholder()) 2023 }, 2024 }, 2025 { 2026 key: '_appendCharRaw', 2027 value: function (e) { 2028 var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}, 2029 n = this._mapPosToBlock(this.value.length), 2030 i = new lt() 2031 if (!n) return i 2032 for (var o = n.index; ; ++o) { 2033 var s = this._blocks[o] 2034 if (!s) break 2035 var a = s._appendChar(e, t), 2036 r = a.skip 2037 if ((i.aggregate(a), r || a.rawInserted)) break 2038 } 2039 return i 2040 }, 2041 }, 2042 { 2043 key: 'extractTail', 2044 value: function () { 2045 var e = this, 2046 t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 0, 2047 n = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : this.value.length, 2048 i = new bt() 2049 return ( 2050 t === n ||
2051 this._forEachBlocksInRange(t, n, function (t, n, o, s) { 2052 var a = t.extractTail(o, s) 2053 ;(a.stop = e._findStopBefore(n)), 2054 (a.from = e._blockStartPos(n)), 2055 a instanceof bt && (a.blockIndex = n), 2056 i.extend(a) 2057 }), 2058 i 2059 ) 2060 }, 2061 }, 2062 { 2063 key: 'extractInput', 2064 value: function () { 2065 var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 0, 2066 t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : this.value.length, 2067 n = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {} 2068 if (e === t) return '' 2069 var i = '' 2070 return ( 2071 this._forEachBlocksInRange(e, t, function (e, t, o, s) { 2072 i += e.extractInput(o, s, n) 2073 }), 2074 i 2075 ) 2076 }, 2077 }, 2078 { 2079 key: '_findStopBefore', 2080 value: function (e) { 2081 for (var t, n = 0; n < this._stops.length; ++n) { 2082 var i = this._stops[n] 2083 if (!(i <= e)) break 2084 t = i 2085 } 2086 return t 2087 }, 2088 }, 2089 { 2090 key: '_appendPlaceholder', 2091 value: function (e) { 2092 var t = this, 2093 n = new lt() 2094 if (this.lazy && null == e) return n 2095 var i = this._mapPosToBlock(this.value.length) 2096 if (!i) return n 2097 var o = i.index, 2098 s = null != e ? e : this._blocks.length 2099 return ( 2100 this._blocks.slice(o, s).forEach(function (i) { 2101 if (!i.lazy || null != e) { 2102 var o = null != i._blocks ? [i._blocks.length] : [], 2103 s = i._appendPlaceholder.apply(i, o) 2104 ;(t._value += s.inserted), n.aggregate(s) 2105 } 2106 }), 2107 n 2108 ) 2109 }, 2110 }, 2111 { 2112 key: '_mapPosToBlock', 2113 value: function (e) { 2114 for (var t = '', n = 0; n < this._blocks.length; ++n) { 2115 var i = this._blocks[n], 2116 o = t.length 2117 if (e <= (t += i.value).length) 2118 return { 2119 index: n, 2120 offset: e - o, 2121 } 2122 } 2123 }, 2124 }, 2125 { 2126 key: '_blockStartPos', 2127 value: function (e) { 2128 return this._blocks.slice(0, e).reduce(function (e, t) { 2129 return e + t.value.length 2130 }, 0) 2131 }, 2132 }, 2133 { 2134 key: '_forEachBlocksInRange', 2135 value: function (e) { 2136 var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : this.value.length, 2137 n = arguments.length > 2 ? arguments[2] : void 0, 2138 i = this._mapPosToBlock(e) 2139 if (i) { 2140 var o = this._mapPosToBlock(t), 2141 s = o && i.index === o.index, 2142 a = i.offset, 2143 r = o && s ? o.offset : this._blocks[i.index].value.length 2144 if ((n(this._blocks[i.index], i.index, a, r), o && !s)) { 2145 for (var c = i.index + 1; c < o.index; ++c) n(this._blocks[c], c, 0, this._blocks[c].value.length) 2146 n(this._blocks[o.index], o.index, 0, o.offset) 2147 } 2148 } 2149 }, 2150 }, 2151 { 2152 key: 'remove', 2153 value: function () { 2154 var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 0, 2155 t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : this.value.length, 2156 i = Je(ze(n.prototype), 'remove', this).call(this, e, t) 2157 return (
2158 this._forEachBlocksInRange(e, t, function (e, t, n, o) { 2159 i.aggregate(e.remove(n, o)) 2160 }), 2161 i 2162 ) 2163 }, 2164 }, 2165 { 2166 key: 'nearestInputPos', 2167 value: function (e) { 2168 var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : nt, 2169 n = this._mapPosToBlock(e) || { 2170 index: 0, 2171 offset: 0, 2172 }, 2173 i = n.offset, 2174 o = n.index, 2175 s = this._blocks[o] 2176 if (!s) return e 2177 var a = i 2178 0 !== a && a < s.value.length && (a = s.nearestInputPos(i, rt(t))) 2179 var r = a === s.value.length, 2180 c = 0 === a 2181 if (!c && !r) return this._blockStartPos(o) + a 2182 var u = r ? o + 1 : o 2183 if (t === nt) { 2184 if (u > 0) { 2185 var l = u - 1, 2186 d = this._blocks[l], 2187 p = d.nearestInputPos(0, nt) 2188 if (!d.value.length || p !== d.value.length) return this._blockStartPos(u) 2189 } 2190 for (var h = u, m = h; m < this._blocks.length; ++m) { 2191 var f = this._blocks[m], 2192 y = f.nearestInputPos(0, nt) 2193 if (!f.value.length || y !== f.value.length) return this._blockStartPos(m) + y 2194 } 2195 for (var v = u - 1; v >= 0; --v) { 2196 var g = this._blocks[v], 2197 b = g.nearestInputPos(0, nt) 2198 if (!g.value.length || b !== g.value.length) return this._blockStartPos(v) + g.value.length 2199 } 2200 return e 2201 } 2202 if (t === it || t === ot) { 2203 for (var k, S = u; S < this._blocks.length; ++S) 2204 if (this._blocks[S].value) { 2205 k = S 2206 break 2207 } 2208 if (null != k) { 2209 var C = this._blocks[k], 2210 w = C.nearestInputPos(0, st) 2211 if (0 === w && C.unmaskedValue.length) return this._blockStartPos(k) + w 2212 } 2213 for (var _, x = -1, A = u - 1; A >= 0; --A) { 2214 var q = this._blocks[A], 2215 $ = q.nearestInputPos(q.value.length, ot) 2216 if (((q.value && 0 === $) || (_ = A), 0 !== $)) { 2217 if ($ !== q.value.length) return this._blockStartPos(A) + $ 2218 x = A 2219 break 2220 } 2221 } 2222 if (t === it) 2223 for (var T = x + 1; T <= Math.min(u, this._blocks.length - 1); ++T) { 2224 var B = this._blocks[T], 2225 M = B.nearestInputPos(0, nt), 2226 E = this._blockStartPos(T) + M 2227 if (E > e) break 2228 if (M !== B.value.length) return E 2229 } 2230 if (x >= 0) return this._blockStartPos(x) + this._blocks[x].value.length 2231 if (t === ot || (this.lazy && !this.extractInput() && !Ct(this._blocks[u]))) return 0 2232 if (null != _) return this._blockStartPos(_) 2233 for (var L = u; L < this._blocks.length; ++L) { 2234 var F = this._blocks[L], 2235 I = F.nearestInputPos(0, nt) 2236 if (!F.value.length || I !== F.value.length) return this._blockStartPos(L) + I 2237 } 2238 return 0 2239 } 2240 if (t === st || t === at) { 2241 for (var D, O, P = u; P < this._blocks.length; ++P) { 2242 var j = this._blocks[P], 2243 R = j.nearestInputPos(0, nt) 2244 if (R !== j.value.length) { 2245 ;(O = this._blockStartPos(P) + R), (D = P) 2246 break 2247 } 2248 } 2249 if (null != D && null != O) { 2250 for (var N = D; N < this._blocks.length; ++N) { 2251 var H = this._blocks[N], 2252 V = H.nearestInputPos(0, at) 2253 if (V !== H.value.length) return this._blockStartPos(N) + V 2254 } 2255 return t === at ? this.value.length : O 2256 } 2257 for (var z = Math.min(u, this._blocks.length - 1); z >= 0; --z) { 2258 var U = this._blocks[z], 2259 W = U.nearestInputPos(U.value.length, it) 2260 if (0 !== W) { 2261 var Q = this._blockStartPos(z) + W 2262 if (Q >= e) return Q 2263 break 2264 } 2265 } 2266 } 2267 return e 2268 }, 2269 }, 2270 { 2271 key: 'maskedBlock', 2272 value: function (e) { 2273 return this.maskedBlocks(e)[0] 2274 }, 2275 }, 2276 { 2277 key: 'maskedBlocks', 2278 value: function (e) { 2279 var t = this, 2280 n = this._maskedBlocks[e] 2281 return n 2282 ? n.map(function (e) { 2283 return t._blocks[e] 2284 }) 2285 : [] 2286 }, 2287 }, 2288 ]), 2289 n 2290 ) 2291 })(ht) 2292 function Ct(e) { 2293 if (!e) return !1 2294 var t = e.value 2295 return !t || e.nearestInputPos(0, nt) !== t.length 2296 } 2297 ;(St.DEFAULTS = { 2298 lazy: !0, 2299 placeholderChar: '_', 2300 }), 2301 (St.STOP_CHAR = '`'), 2302 (St.ESCAPE_CHAR = '\\'), 2303 (St.InputDefinition = vt), 2304 (St.FixedDefinition = gt), 2305 (pt.MaskedPattern = St) 2306 var wt = (function (e) { 2307 Ve(n, e) 2308 var t = Ye(n) 2309 function n() { 2310 return Re(this, n), t.apply(this, arguments) 2311 } 2312 return ( 2313 He(n, [ 2314 { 2315 key: '_matchFrom', 2316 get: function () { 2317 return this.maxLength - String(this.from).length 2318 }, 2319 }, 2320 { 2321 key: '_update', 2322 value: function (e) { 2323 e = Object.assign( 2324 { 2325 to: this.to || 0, 2326 from: this.from || 0, 2327 }, 2328 e 2329 ) 2330 var t = String(e.to).length 2331 null != e.maxLength && (t = Math.max(t, e.maxLength)), (e.maxLength = t) 2332 for ( 2333 var i = String(e.from).padStart(t, '0'), o = String(e.to).padStart(t, '0'), s = 0; 2334 s < o.length && o[s] === i[s]; 2335 2336 ) 2337 ++s 2338 ;(e.mask = o.slice(0, s).replace(/0/g, '\\0') + '0'.repeat(t - s)), 2339 Je(ze(n.prototype), '_update', this).call(this, e) 2340 }, 2341 }, 2342 { 2343 key: 'isComplete', 2344 get: function () { 2345 return Je(ze(n.prototype), 'isComplete', this) && Boolean(this.value) 2346 }, 2347 }, 2348 { 2349 key: 'boundaries', 2350 value: function (e) { 2351 var t = '', 2352 n = '', 2353 i = Ze(e.match(/^(\D*)(\d*)(\D*)/) || [], 3), 2354 o = i[1], 2355 s = i[2] 2356 return ( 2357 s && ((t = '0'.repeat(o.length) + s), (n = '9'.repeat(o.length) + s)), 2358 [(t = t.padEnd(this.maxLength, '0')), (n = n.padEnd(this.maxLength, '9'))] 2359 ) 2360 }, 2361 }, 2362 { 2363 key: 'doPrepare', 2364 value: function (e) { 2365 var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {} 2366 if (((e = Je(ze(n.prototype), 'doPrepare', this).call(this, e, t).replace(/\D/g, '')), !this.autofix)) 2367 return e 2368 for ( 2369 var i = String(this.from).padStart(this.maxLength, '0'), 2370 o = String(this.to).padStart(this.maxLength, '0'), 2371 s = this.value, 2372 a = '', 2373 r = 0; 2374 r < e.length; 2375 ++r 2376 ) { 2377 var c = s + a + e[r], 2378 u = this.boundaries(c), 2379 l = Ze(u, 2), 2380 d = l[0], 2381 p = l[1] 2382 Number(p) < this.from 2383 ? (a += i[c.length - 1]) 2384 : Number(d) > this.to 2385 ? (a += o[c.length - 1]) 2386 : (a += e[r]) 2387 } 2388 return a 2389 }, 2390 }, 2391 { 2392 key: 'doValidate', 2393 value: function () { 2394 var e, 2395 t = this.value, 2396 i = t.search(/[^0]/) 2397 if (-1 === i && t.length <= this._matchFrom) return !0 2398 for ( 2399 var o = this.boundaries(t), 2400 s = Ze(o, 2), 2401 a = s[0], 2402 r = s[1], 2403 c = arguments.length, 2404 u = new Array(c), 2405 l = 0; 2406 l < c; 2407 l++ 2408 ) 2409 u[l] = arguments[l] 2410 return ( 2411 this.from <= Number(r) && 2412 Number(a) <= this.to && 2413 (e = Je(ze(n.prototype), 'doValidate', this)).call.apply(e, [this].concat(u)) 2414 ) 2415 }, 2416 }, 2417 ]), 2418 n 2419 ) 2420 })(St) 2421 pt.MaskedRange = wt 2422 var _t = (function (e) { 2423 Ve(n, e) 2424 var t = Ye(n) 2425 function n(e) { 2426 return Re(this, n), t.call(this, Object.assign({}, n.DEFAULTS, e)) 2427 } 2428 return ( 2429 He(n, [ 2430 { 2431 key: '_update', 2432 value: function (e) { 2433 e.mask === Date && delete e.mask, e.pattern && (e.mask = e.pattern) 2434 var t = e.blocks 2435 ;(e.blocks = Object.assign({}, n.GET_DEFAULT_BLOCKS())), 2436 e.min && (e.blocks.Y.from = e.min.getFullYear()), 2437 e.max && (e.blocks.Y.to = e.max.getFullYear()), 2438 e.min && 2439 e.max && 2440 e.blocks.Y.from === e.blocks.Y.to && 2441 ((e.blocks.m.from = e.min.getMonth() + 1), 2442 (e.blocks.m.to = e.max.getMonth() + 1), 2443 e.blocks.m.from === e.blocks.m.to && 2444 ((e.blocks.d.from = e.min.getDate()), (e.blocks.d.to = e.max.getDate()))), 2445 Object.assign(e.blocks, t),
2446 Object.keys(e.blocks).forEach(function (t) { 2447 var n = e.blocks[t] 2448 'autofix' in n || (n.autofix = e.autofix) 2449 }), 2450 Je(ze(n.prototype), '_update', this).call(this, e) 2451 }, 2452 }, 2453 { 2454 key: 'doValidate', 2455 value: function () { 2456 for (var e, t = this.date, i = arguments.length, o = new Array(i), s = 0; s < i; s++) o[s] = arguments[s] 2457 return ( 2458 (e = Je(ze(n.prototype), 'doValidate', this)).call.apply(e, [this].concat(o)) && 2459 (!this.isComplete || 2460 (this.isDateExist(this.value) && 2461 null != t && 2462 (null == this.min || this.min <= t) && 2463 (null == this.max || t <= this.max))) 2464 ) 2465 }, 2466 }, 2467 { 2468 key: 'isDateExist', 2469 value: function (e) { 2470 return this.format(this.parse(e, this), this).indexOf(e) >= 0 2471 }, 2472 }, 2473 { 2474 key: 'date', 2475 get: function () { 2476 return this.typedValue 2477 }, 2478 set: function (e) { 2479 this.typedValue = e 2480 }, 2481 }, 2482 { 2483 key: 'typedValue', 2484 get: function () { 2485 return this.isComplete ? Je(ze(n.prototype), 'typedValue', this) : null 2486 }, 2487 set: function (e) { 2488 Xe(ze(n.prototype), 'typedValue', e, this, !0) 2489 }, 2490 }, 2491 ]), 2492 n 2493 ) 2494 })(St) 2495 ;(_t.DEFAULTS = { 2496 pattern: 'd{.}`m{.}`Y', 2497 format: function (e) { 2498 return [String(e.getDate()).padStart(2, '0'), String(e.getMonth() + 1).padStart(2, '0'), e.getFullYear()].join( 2499 '.' 2500 ) 2501 }, 2502 parse: function (e) { 2503 var t = Ze(e.split('.'), 3), 2504 n = t[0], 2505 i = t[1], 2506 o = t[2] 2507 return new Date(o, i - 1, n) 2508 }, 2509 }), 2510 (_t.GET_DEFAULT_BLOCKS = function () { 2511 return { 2512 d: { 2513 mask: wt, 2514 from: 1, 2515 to: 31, 2516 maxLength: 2, 2517 }, 2518 m: { 2519 mask: wt, 2520 from: 1, 2521 to: 12, 2522 maxLength: 2, 2523 }, 2524 Y: { 2525 mask: wt, 2526 from: 1900, 2527 to: 9999, 2528 }, 2529 } 2530 }), 2531 (pt.MaskedDate = _t) 2532 var xt = (function () { 2533 function e() { 2534 Re(this, e) 2535 } 2536 return ( 2537 He(e, [ 2538 { 2539 key: 'selectionStart', 2540 get: function () { 2541 var e 2542 try { 2543 e = this._unsafeSelectionStart 2544 } catch (e) {} 2545 return null != e ? e : this.value.length 2546 }, 2547 }, 2548 { 2549 key: 'selectionEnd', 2550 get: function () { 2551 var e 2552 try { 2553 e = this._unsafeSelectionEnd 2554 } catch (e) {} 2555 return null != e ? e : this.value.length 2556 }, 2557 }, 2558 { 2559 key: 'select', 2560 value: function (e, t) { 2561 if (null != e && null != t && (e !== this.selectionStart || t !== this.selectionEnd)) 2562 try { 2563 this._unsafeSelect(e, t) 2564 } catch (e) {} 2565 }, 2566 }, 2567 { 2568 key: '_unsafeSelect', 2569 value: function (e, t) {}, 2570 }, 2571 { 2572 key: 'isActive', 2573 get: function () { 2574 return !1 2575 }, 2576 }, 2577 { 2578 key: 'bindEvents', 2579 value: function (e) {}, 2580 }, 2581 { 2582 key: 'unbindEvents', 2583 value: function () {}, 2584 }, 2585 ]), 2586 e 2587 ) 2588 })() 2589 pt.MaskElement = xt 2590 var At = (function (e) { 2591 Ve(n, e) 2592 var t = Ye(n) 2593 function n(e) { 2594 var i 2595 return Re(this, n), ((i = t.call(this)).input = e), (i._handlers = {}), i 2596 } 2597 return ( 2598 He(n, [ 2599 { 2600 key: 'rootElement', 2601 get: function () { 2602 return this.input.getRootNode ? this.input.getRootNode() : document 2603 }, 2604 }, 2605 { 2606 key: 'isActive', 2607 get: function () { 2608 return this.input === this.rootElement.activeElement 2609 }, 2610 }, 2611 { 2612 key: '_unsafeSelectionStart', 2613 get: function () { 2614 return this.input.selectionStart 2615 }, 2616 }, 2617 { 2618 key: '_unsafeSelectionEnd', 2619 get: function () { 2620 return this.input.selectionEnd 2621 }, 2622 }, 2623 { 2624 key: '_unsafeSelect', 2625 value: function (e, t) { 2626 this.input.setSelectionRange(e, t) 2627 }, 2628 }, 2629 { 2630 key: 'value', 2631 get: function () { 2632 return this.input.value 2633 }, 2634 set: function (e) { 2635 this.input.value = e 2636 }, 2637 }, 2638 { 2639 key: 'bindEvents', 2640 value: function (e) { 2641 var t = this 2642 Object.keys(e).forEach(function (i) { 2643 return t._toggleEventHandler(n.EVENTS_MAP[i], e[i]) 2644 }) 2645 }, 2646 }, 2647 { 2648 key: 'unbindEvents', 2649 value: function () { 2650 var e = this
2651 Object.keys(this._handlers).forEach(function (t) { 2652 return e._toggleEventHandler(t) 2653 }) 2654 }, 2655 }, 2656 { 2657 key: '_toggleEventHandler', 2658 value: function (e, t) { 2659 this._handlers[e] && (this.input.removeEventListener(e, this._handlers[e]), delete this._handlers[e]), 2660 t && (this.input.addEventListener(e, t), (this._handlers[e] = t)) 2661 }, 2662 }, 2663 ]), 2664 n 2665 ) 2666 })(xt) 2667 ;(At.EVENTS_MAP = { 2668 selectionChange: 'keydown', 2669 input: 'input', 2670 drop: 'drop', 2671 click: 'click', 2672 focus: 'focus', 2673 commit: 'blur', 2674 }), 2675 (pt.HTMLMaskElement = At) 2676 var qt = (function (e) { 2677 Ve(n, e) 2678 var t = Ye(n) 2679 function n() { 2680 return Re(this, n), t.apply(this, arguments) 2681 } 2682 return ( 2683 He(n, [ 2684 { 2685 key: '_unsafeSelectionStart', 2686 get: function () { 2687 var e = this.rootElement, 2688 t = e.getSelection && e.getSelection() 2689 return t && t.anchorOffset 2690 }, 2691 }, 2692 { 2693 key: '_unsafeSelectionEnd', 2694 get: function () { 2695 var e = this.rootElement, 2696 t = e.getSelection && e.getSelection() 2697 return t && this._unsafeSelectionStart + String(t).length 2698 }, 2699 }, 2700 { 2701 key: '_unsafeSelect', 2702 value: function (e, t) { 2703 if (this.rootElement.createRange) { 2704 var n = this.rootElement.createRange() 2705 n.setStart(this.input.firstChild || this.input, e), n.setEnd(this.input.lastChild || this.input, t) 2706 var i = this.rootElement, 2707 o = i.getSelection && i.getSelection() 2708 o && (o.removeAllRanges(), o.addRange(n)) 2709 } 2710 }, 2711 }, 2712 { 2713 key: 'value', 2714 get: function () { 2715 return this.input.textContent 2716 }, 2717 set: function (e) { 2718 this.input.textContent = e 2719 }, 2720 }, 2721 ]), 2722 n 2723 ) 2724 })(At) 2725 pt.HTMLContenteditableMaskElement = qt 2726 var $t = (function () { 2727 function e(t, n) { 2728 Re(this, e), 2729 (this.el = 2730 t instanceof xt 2731 ? t 2732 : t.isContentEditable && 'INPUT' !== t.tagName && 'TEXTAREA' !== t.tagName 2733 ? new qt(t) 2734 : new At(t)), 2735 (this.masked = ft(n)), 2736 (this._listeners = {}), 2737 (this._value = ''), 2738 (this._unmaskedValue = ''), 2739 (this._saveSelection = this._saveSelection.bind(this)), 2740 (this._onInput = this._onInput.bind(this)), 2741 (this._onChange = this._onChange.bind(this)), 2742 (this._onDrop = this._onDrop.bind(this)), 2743 (this._onFocus = this._onFocus.bind(this)), 2744 (this._onClick = this._onClick.bind(this)), 2745 (this.alignCursor = this.alignCursor.bind(this)), 2746 (this.alignCursorFriendly = this.alignCursorFriendly.bind(this)), 2747 this._bindEvents(), 2748 this.updateValue(), 2749 this._onChange() 2750 } 2751 return ( 2752 He(e, [ 2753 { 2754 key: 'mask', 2755 get: function () { 2756 return this.masked.mask 2757 }, 2758 set: function (e) { 2759 if (!this.maskEquals(e)) 2760 if (e instanceof pt.Masked || this.masked.constructor !== mt(e)) { 2761 var t = ft({ 2762 mask: e, 2763 }) 2764 ;(t.unmaskedValue = this.masked.unmaskedValue), (this.masked = t) 2765 } else 2766 this.masked.updateOptions({ 2767 mask: e, 2768 }) 2769 }, 2770 }, 2771 { 2772 key: 'maskEquals', 2773 value: function (e) { 2774 return null == e || e === this.masked.mask || (e === Date && this.masked instanceof _t) 2775 }, 2776 }, 2777 { 2778 key: 'value', 2779 get: function () { 2780 return this._value 2781 }, 2782 set: function (e) { 2783 ;(this.masked.value = e), this.updateControl(), this.alignCursor() 2784 }, 2785 }, 2786 { 2787 key: 'unmaskedValue', 2788 get: function () { 2789 return this._unmaskedValue 2790 }, 2791 set: function (e) { 2792 ;(this.masked.unmaskedValue = e), this.updateControl(), this.alignCursor() 2793 }, 2794 }, 2795 { 2796 key: 'typedValue', 2797 get: function () { 2798 return this.masked.typedValue 2799 }, 2800 set: function (e) { 2801 ;(this.masked.typedValue = e), this.updateControl(), this.alignCursor() 2802 }, 2803 }, 2804 { 2805 key: '_bindEvents', 2806 value: function () { 2807 this.el.bindEvents({ 2808 selectionChange: this._saveSelection, 2809 input: this._onInput, 2810 drop: this._onDrop, 2811 click: this._onClick, 2812 focus: this._onFocus, 2813 commit: this._onChange, 2814 }) 2815 }, 2816 }, 2817 { 2818 key: '_unbindEvents', 2819 value: function () { 2820 this.el && this.el.unbindEvents() 2821 }, 2822 }, 2823 { 2824 key: '_fireEvent', 2825 value: function (e) { 2826 for (var t = arguments.length, n = new Array(t > 1 ? t - 1 : 0), i = 1; i < t; i++) 2827 n[i - 1] = arguments[i] 2828 var o = this._listeners[e] 2829 o && 2830 o.forEach(function (e) { 2831 return e.apply(void 0, n) 2832 }) 2833 }, 2834 }, 2835 { 2836 key: 'selectionStart', 2837 get: function () { 2838 return this._cursorChanging ? this._changingCursorPos : this.el.selectionStart 2839 }, 2840 }, 2841 { 2842 key: 'cursorPos', 2843 get: function () { 2844 return this._cursorChanging ? this._changingCursorPos : this.el.selectionEnd 2845 }, 2846 set: function (e) { 2847 this.el && this.el.isActive && (this.el.select(e, e), this._saveSelection()) 2848 }, 2849 }, 2850 { 2851 key: '_saveSelection', 2852 value: function () { 2853 this.value !== this.el.value && 2854 console.warn( 2855 'Element value was changed outside of mask. Syncronize mask using `mask.updateV
2855alue()` to work properly.' 2856 ), 2857 (this._selection = { 2858 start: this.selectionStart, 2859 end: this.cursorPos, 2860 }) 2861 }, 2862 }, 2863 { 2864 key: 'updateValue', 2865 value: function () { 2866 ;(this.masked.value = this.el.value), (this._value = this.masked.value) 2867 }, 2868 }, 2869 { 2870 key: 'updateControl', 2871 value: function () { 2872 var e = this.masked.unmaskedValue, 2873 t = this.masked.value, 2874 n = this.unmaskedValue !== e || this.value !== t 2875 ;(this._unmaskedValue = e), 2876 (this._value = t), 2877 this.el.value !== t && (this.el.value = t), 2878 n && this._fireChangeEvents() 2879 }, 2880 }, 2881 { 2882 key: 'updateOptions', 2883 value: function (e) { 2884 var t = e.mask, 2885 n = We(e, ['mask']), 2886 i = !this.maskEquals(t), 2887 o = !(function e(t, n) { 2888 if (n === t) return !0 2889 var i, 2890 o = Array.isArray(n), 2891 s = Array.isArray(t) 2892 if (o && s) { 2893 if (n.length != t.length) return !1 2894 for (i = 0; i < n.length; i++) if (!e(n[i], t[i])) return !1 2895 return !0 2896 } 2897 if (o != s) return !1 2898 if (n && t && 'object' === je(n) && 'object' === je(t)) { 2899 var a = n instanceof Date, 2900 r = t instanceof Date 2901 if (a && r) return n.getTime() == t.getTime() 2902 if (a != r) return !1 2903 var c = n instanceof RegExp, 2904 u = t instanceof RegExp 2905 if (c && u) return n.toString() == t.toString() 2906 if (c != u) return !1 2907 var l = Object.keys(n) 2908 for (i = 0; i < l.length; i++) if (!Object.prototype.hasOwnProperty.call(t, l[i])) return !1 2909 for (i = 0; i < l.length; i++) if (!e(t[l[i]], n[l[i]])) return !1 2910 return !0 2911 } 2912 return ( 2913 !(!n || !t || 'function' != typeof n || 'function' != typeof t) && n.toString() === t.toString() 2914 ) 2915 })(this.masked, n) 2916 i && (this.mask = t), o && this.masked.updateOptions(n), (i || o) && this.updateControl() 2917 }, 2918 }, 2919 { 2920 key: 'updateCursor', 2921 value: function (e) {
2922 null != e && ((this.cursorPos = e), this._delayUpdateCursor(e)) 2923 }, 2924 }, 2925 { 2926 key: '_delayUpdateCursor', 2927 value: function (e) { 2928 var t = this 2929 this._abortUpdateCursor(), 2930 (this._changingCursorPos = e), 2931 (this._cursorChanging = setTimeout(function () { 2932 t.el && ((t.cursorPos = t._changingCursorPos), t._abortUpdateCursor()) 2933 }, 10)) 2934 }, 2935 }, 2936 { 2937 key: '_fireChangeEvents', 2938 value: function () { 2939 this._fireEvent('accept', this._inputEvent), 2940 this.masked.isComplete && this._fireEvent('complete', this._inputEvent) 2941 }, 2942 }, 2943 { 2944 key: '_abortUpdateCursor', 2945 value: function () { 2946 this._cursorChanging && (clearTimeout(this._cursorChanging), delete this._cursorChanging) 2947 }, 2948 }, 2949 { 2950 key: 'alignCursor', 2951 value: function () {
2952 this.cursorPos = this.masked.nearestInputPos(this.cursorPos, it) 2953 }, 2954 }, 2955 { 2956 key: 'alignCursorFriendly', 2957 value: function () { 2958 this.selectionStart === this.cursorPos && this.alignCursor() 2959 }, 2960 }, 2961 { 2962 key: 'on', 2963 value: function (e, t) { 2964 return this._listeners[e] || (this._listeners[e] = []), this._listeners[e].push(t), this 2965 }, 2966 }, 2967 { 2968 key: 'off', 2969 value: function (e, t) { 2970 if (!this._listeners[e]) return this 2971 if (!t) return delete this._listeners[e], this 2972 var n = this._listeners[e].indexOf(t) 2973 return n >= 0 && this._listeners[e].splice(n, 1), this 2974 }, 2975 }, 2976 { 2977 key: '_onInput', 2978 value: function (e) { 2979 if (((this._inputEvent = e), this._abortUpdateCursor(), !this._selection)) return this.updateValue() 2980 var t = new ut(this.el.value, this.cursorPos, this.value, this._selection), 2981 n = this.masked.rawInputValue, 2982 i = this.masked.splice(t.startChangePos, t.removed.length, t.inserted, t.removeDirection).offset, 2983 o = n === this.masked.rawInputValue ? t.removeDirection : nt, 2984 s = this.masked.nearestInputPos(t.startChangePos + i, o) 2985 this.updateControl(), this.updateCursor(s), delete this._inputEvent 2986 }, 2987 }, 2988 { 2989 key: '_onChange', 2990 value: function () { 2991 this.value !== this.el.value && this.updateValue(), 2992 this.masked.doCommit(), 2993 this.updateControl(), 2994 this._saveSelection() 2995 }, 2996 }, 2997 { 2998 key: '_onDrop', 2999 value: function (e) { 3000 e.preventDefault(), e.stopPropagation() 3001 }, 3002 }, 3003 { 3004 key: '_onFocus', 3005 value: function (e) { 3006 this.alignCursorFriendly() 3007 }, 3008 }, 3009 { 3010 key: '_onClick', 3011 value: function (e) { 3012 this.alignCursorFriendly() 3013 }, 3014 }, 3015 { 3016 key: 'destroy', 3017 value: function () { 3018 this._unbindEvents(), (this._listeners.length = 0), delete this.el 3019 }, 3020 }, 3021 ]), 3022 e 3023 ) 3024 })() 3025 pt.InputMask = $t 3026 var Tt = (function (e) { 3027 Ve(n, e) 3028 var t = Ye(n) 3029 function n() { 3030 return Re(this, n), t.apply(this, arguments) 3031 } 3032 return ( 3033 He(n, [ 3034 { 3035 key: '_update', 3036 value: function (e) { 3037 e.enum && (e.mask = '*'.repeat(e.enum[0].length)), Je(ze(n.prototype), '_update', this).call(this, e) 3038 }, 3039 }, 3040 { 3041 key: 'doValidate', 3042 value: function () { 3043 for (var e, t = this, i = arguments.length, o = new Array(i), s = 0; s < i; s++) o[s] = arguments[s] 3044 return ( 3045 this.enum.some(function (e) { 3046 return e.indexOf(t.unmaskedValue) >= 0 3047 }) && (e = Je(ze(n.prototype), 'doValidate', this)).call.apply(e, [this].concat(o)) 3048 ) 3049 }, 3050 }, 3051 ]), 3052 n 3053 ) 3054 })(St) 3055 pt.MaskedEnum = Tt 3056 var Bt = (function (e) { 3057 Ve(n, e) 3058 var t = Ye(n) 3059 function n(e) { 3060 return Re(this, n), t.call(this, Object.assign({}, n.DEFAULTS, e)) 3061 } 3062 return ( 3063 He(n, [ 3064 { 3065 key: '_update', 3066 value: function (e) { 3067 Je(ze(n.prototype), '_update', this).call(this, e), this._updateRegExps() 3068 }, 3069 }, 3070 { 3071 key: '_updateRegExps', 3072 value: function () { 3073 var e = '^' + (this.allowNegative ? '[+|\\-]?' : ''), 3074 t = (this.scale ? '(' + ct(this.radix) + '\\d{0,' + this.scale + '})?' : '') + '$' 3075 ;(this._numberRegExpInput = new RegExp(e + '(0|([1-9]+\\d*))?' + t)), 3076 (this._numberRegExp = new RegExp(e + '\\d*' + t)), 3077 (this._mapToRadixRegExp = new RegExp('[' + this.mapToRadix.map(ct).join('') + ']', 'g')), 3078 (this._thousandsSeparatorRegExp = new RegExp(ct(this.thousandsSeparator), 'g')) 3079 }, 3080 }, 3081 { 3082 key: '_removeThousandsSeparators', 3083 value: function (e) { 3084 return e.replace(this._thousandsSeparatorRegExp, '') 3085 }, 3086 }, 3087 { 3088 key: '_insertThousandsSeparators', 3089 value: function (e) { 3090 var t = e.split(this.radix) 3091 return (t[0] = t[0].replace(/\B(?=(\d{3})+(?!\d))/g, this.thousandsSeparator)), t.join(this.radix) 3092 }, 3093 }, 3094 { 3095 key: 'doPrepare', 3096 value: function (e) { 3097 for (var t, i = arguments.length, o = new Array(i > 1 ? i - 1 : 0), s = 1; s < i; s++) 3098 o[s - 1] = arguments[s] 3099 return (t = Je(ze(n.prototype), 'doPrepare', this)).call.apply( 3100 t, 3101 [this, this._removeThousandsSeparators(e.replace(this._mapToRadixRegExp, this.radix))].concat(o) 3102 ) 3103 }, 3104 }, 3105 { 3106 key: '_separatorsCount', 3107 value: function (e) { 3108 for (var t = arguments.length > 1 && void 0 !== arguments[1] && arguments[1], n = 0, i = 0; i < e; ++i) 3109 this._value.indexOf(this.thousandsSeparator, i) === i && 3110 (++n, t && (e += this.thousandsSeparator.length)) 3111 return n 3112 }, 3113 }, 3114 { 3115 key: '_separatorsCountFromSlice', 3116 value: function () { 3117 var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : this._value 3118 return this._separatorsCount(this._removeThousandsSeparators(e).length, !0) 3119 }, 3120 }, 3121 { 3122 key: 'extractInput', 3123 value: function () { 3124 var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 0, 3125 t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : this.value.length, 3126 i = arguments.length > 2 ? arguments[2] : void 0, 3127 o = this._adjustRangeWithSeparators(e, t), 3128 s = Ze(o, 2) 3129 return ( 3130 (e = s[0]), 3131 (t = s[1]), 3132 this._removeThousandsSeparators(Je(ze(n.prototype), 'extractInput', this).call(this, e, t, i)) 3133 ) 3134 }, 3135 }, 3136 { 3137 key: '_appendCharRaw', 3138 value: function (e) { 3139 var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {} 3140 if (!this.thousandsSeparator) return Je(ze(n.prototype), '_appendCharRaw', this).call(this, e, t) 3141 var i = t.tail && t._beforeTailState ? t._beforeTailState._value : this._value, 3142 o = this._separatorsCountFromSlice(i) 3143 this._value = this._removeThousandsSeparators(this.value) 3144 var s = Je(ze(n.prototype), '_appendCharRaw', this).call(this, e, t) 3145 this._value = this._insertThousandsSeparators(this._value) 3146 var a = t.tail && t._beforeTailState ? t._beforeTailState._value : this._value, 3147 r = this._separatorsCountFromSlice(a) 3148 return ( 3149 (s.tailShift += (r - o) * this.thousandsSeparator.length), 3150 (s.skip = !s.rawInserted && e === this.thousandsSeparator), 3151 s 3152 ) 3153 }, 3154 }, 3155 { 3156 key: '_findSeparatorAround', 3157 value: function (e) { 3158 if (this.thousandsSeparator) { 3159 var t = e - this.thousandsSeparator.length + 1, 3160 n = this.value.indexOf(this.thousandsSeparator, t) 3161 if (n <= e) return n 3162 } 3163 return -1 3164 }, 3165 }, 3166 { 3167 key: '_adjustRangeWithSeparators', 3168 value: function (e, t) { 3169 var n = this._findSeparatorAround(e) 3170 n >= 0 && (e = n) 3171 var i = this._findSeparatorAround(t) 3172 return i >= 0 && (t = i + this.thousandsSeparator.length), [e, t] 3173 }, 3174 }, 3175 { 3176 key: 'remove', 3177 value: function () { 3178 var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 0, 3179 t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : this.value.length, 3180 n = this._adjustRangeWithSeparators(e, t), 3181 i = Ze(n, 2) 3182 ;(e = i[0]), (t = i[1]) 3183 var o = this.value.slice(0, e), 3184 s = this.value.slice(t), 3185 a = this._separatorsCount(o.length) 3186 this._value = this._insertThousandsSeparators(this._removeThousandsSeparators(o + s)) 3187 var r = this._separatorsCountFromSlice(o) 3188 return new lt({ 3189 tailShift: (r - a) * this.thousandsSeparator.length, 3190 }) 3191 }, 3192 }, 3193 { 3194 key: 'nearestInputPos', 3195 value: function (e, t) { 3196 if (!this.thousandsSeparator) return e 3197 switch (t) { 3198 case nt: 3199 case it: 3200 case ot: 3201 var n = this._findSeparatorAround(e - 1) 3202 if (n >= 0) { 3203 var i = n + this.thousandsSeparator.length 3204 if (e < i || this.value.length <= i || t === ot) return n 3205 } 3206 break 3207 case st: 3208 case at: 3209 var o = this._findSeparatorAround(e) 3210 if (o >= 0) return o + this.thousandsSeparator.length 3211 } 3212 return e 3213 }, 3214 }, 3215 { 3216 key: 'doValidate', 3217 value: function (e) { 3218 var t = (e.input ? this._numberRegExpInput : this._numberRegExp).test( 3219 this._removeThousandsSeparators(this.value) 3220 ) 3221 if (t) { 3222 var i = this.number 3223 t = 3224 t && 3225 !isNaN(i) && 3226 (null == this.min || this.min >= 0 || this.min <= this.number) && 3227 (null == this.max || this.max <= 0 || this.number <= this.max) 3228 } 3229 return t && Je(ze(n.prototype), 'doValidate', this).call(this, e) 3230 }, 3231 }, 3232 { 3233 key: 'doCommit', 3234 value: function () { 3235 if (this.value) { 3236 var e = this.number, 3237 t = e 3238 null != this.min && (t = Math.max(t, this.min)), 3239 null != this.max && (t = Math.min(t, this.max)), 3240 t !== e && (this.unmaskedValue = String(t)) 3241 var i = this.value 3242 this.normalizeZeros && (i = this._normalizeZeros(i)), 3243 this.padFractionalZeros && (i = this._padFractionalZeros(i)), 3244 (this._value = i) 3245 } 3246 Je(ze(n.prototype), 'doCommit', this).call(this) 3247 }, 3248 }, 3249 { 3250 key: '_normalizeZeros', 3251 value: function (e) { 3252 var t = this._removeThousandsSeparators(e).split(this.radix) 3253 return ( 3254 (t[0] = t[0].replace(/^(\D*)(0*)(\d*)/, function (e, t, n, i) { 3255 return t + i 3256 })), 3257 e.length && !/\d$/.test(t[0]) && (t[0] = t[0] + '0'), 3258 t.length > 1 && ((t[1] = t[1].replace(/0*$/, '')), t[1].length || (t.length = 1)), 3259 this._insertThousandsSeparators(t.join(this.radix)) 3260 ) 3261 }, 3262 }, 3263 { 3264 key: '_padFractionalZeros', 3265 value: function (e) { 3266 if (!e) return e 3267 var t = e.split(this.radix) 3268 return t.length < 2 && t.push(''), (t[1] = t[1].padEnd(this.scale, '0')), t.join(this.radix) 3269 }, 3270 }, 3271 { 3272 key: 'unmaskedValue', 3273 get: function () { 3274 return this._removeThousandsSeparators(this._normalizeZeros(this.value)).replace(this.radix, '.') 3275 }, 3276 set: function (e) { 3277 Xe(ze(n.prototype), 'unmaskedValue', e.replace('.', this.radix), this, !0) 3278 }, 3279 }, 3280 { 3281 key: 'typedValue', 3282 get: function () { 3283 return Number(this.unmaskedValue) 3284 }, 3285 set: function (e) { 3286 Xe(ze(n.prototype), 'unmaskedValue', String(e), this, !0) 3287 }, 3288 }, 3289 { 3290 key: 'number', 3291 get: function () { 3292 return this.typedValue 3293 }, 3294 set: function (e) { 3295 this.typedValue = e 3296 }, 3297 }, 3298 { 3299 key: 'allowNegative', 3300 get: function () { 3301 return this.signed || (null != this.min && this.min < 0) || (null != this.max && this.max < 0) 3302 }, 3303 }, 3304 ]), 3305 n 3306 ) 3307 })(ht) 3308 ;(Bt.DEFAULTS = { 3309 radix: ',', 3310 thousandsSeparator: '', 3311 mapToRadix: ['.'], 3312 scale: 2, 3313 signed: !1, 3314 normalizeZeros: !0, 3315 padFractionalZeros: !1, 3316 }), 3317 (pt.MaskedNumber = Bt) 3318 var Mt = (function (e) { 3319 Ve(n, e) 3320 var t = Ye(n) 3321 function n() { 3322 return Re(this, n), t.apply(this, arguments) 3323 } 3324 return ( 3325 He(n, [ 3326 { 3327 key: '_update', 3328 value: function (e) { 3329 e.mask && (e.validate = e.mask), Je(ze(n.prototype), '_update', this).call(this, e) 3330 }, 3331 }, 3332 ]), 3333 n 3334 ) 3335 })(ht) 3336 pt.MaskedFunction = Mt 3337 var Et = (function (e) { 3338 Ve(n, e) 3339 var t = Ye(n) 3340 function n(e) { 3341 var i 3342 return Re(this, n), ((i = t.call(this, Object.assign({}, n.DEFAULTS, e))).currentMask = null), i 3343 } 3344 return ( 3345 He(n, [ 3346 { 3347 key: '_update', 3348 value: function (e) { 3349 Je(ze(n.prototype), '_update', this).call(this, e), 3350 'mask' in e && 3351 (this.compiledMasks = Array.isArray(e.mask) 3352 ? e.mask.map(function (e) { 3353 return ft(e) 3354 }) 3355 : []) 3356 }, 3357 }, 3358 { 3359 key: '_appendCharRaw', 3360 value: function (e) { 3361 var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}, 3362 n = this._applyDispatch(e, t) 3363 return this.currentMask && n.aggregate(this.currentMask._appendChar(e, t)), n 3364 }, 3365 }, 3366 { 3367 key: '_applyDispatch', 3368 value: function () { 3369 var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : '', 3370 t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}, 3371 n = t.tail && null != t._beforeTailState ? t._beforeTailState._value : this.value, 3372 i = this.rawInputValue, 3373 o = t.tail && null != t._beforeTailState ? t._beforeTailState._rawInputValue : i, 3374 s = i.slice(o.length), 3375 a = this.currentMask, 3376 r = new lt(), 3377 c = a && a.state
3378 if (((this.currentMask = this.doDispatch(e, Object.assign({}, t))), this.currentMask)) 3379 if (this.currentMask !== a) { 3380 if ((this.currentMask.reset(), o)) { 3381 var u = this.currentMask.append(o, { 3382 raw: !0, 3383 }) 3384 r.tailShift = u.inserted.length - n.length 3385 } 3386 s && 3387 (r.tailShift += this.currentMask.append(s, { 3388 raw: !0, 3389 tail: !0, 3390 }).tailShift) 3391 } else this.currentMask.state = c 3392 return r 3393 }, 3394 }, 3395 { 3396 key: '_appendPlaceholder', 3397 value: function () { 3398 var e = this._applyDispatch.apply(this, arguments) 3399 return this.currentMask && e.aggregate(this.currentMask._appendPlaceholder()), e 3400 }, 3401 }, 3402 { 3403 key: 'doDispatch', 3404 value: function (e) { 3405 var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {} 3406 return this.dispatch(e, this, t) 3407 }, 3408 }, 3409 { 3410 key: 'doValidate', 3411 value: function () { 3412 for (var e, t, i = arguments.length, o = new Array(i), s = 0; s < i; s++) o[s] = arguments[s] 3413 return ( 3414 (e = Je(ze(n.prototype), 'doValidate', this)).call.apply(e, [this].concat(o)) && 3415 (!this.currentMask || (t = this.currentMask).doValidate.apply(t, o)) 3416 ) 3417 }, 3418 }, 3419 { 3420 key: 'reset', 3421 value: function () { 3422 this.currentMask && this.currentMask.reset(), 3423 this.compiledMasks.forEach(function (e) { 3424 return e.reset() 3425 }) 3426 }, 3427 }, 3428 { 3429 key: 'value', 3430 get: function () { 3431 return this.currentMask ? this.currentMask.value : '' 3432 }, 3433 set: function (e) { 3434 Xe(ze(n.prototype), 'value', e, this, !0) 3435 }, 3436 }, 3437 { 3438 key: 'unmaskedValue', 3439 get: function () { 3440 return this.currentMask ? this.currentMask.unmaskedValue : '' 3441 }, 3442 set: function (e) { 3443 Xe(ze(n.prototype), 'unmaskedValue', e, this, !0) 3444 }, 3445 }, 3446 { 3447 key: 'typedValue', 3448 get: function () { 3449 return this.currentMask ? this.currentMask.typedValue : '' 3450 }, 3451 set: function (e) { 3452 var t = String(e) 3453 this.currentMask && ((this.currentMask.typedValue = e), (t = this.currentMask.unmaskedValue)), 3454 (this.unmaskedValue = t) 3455 }, 3456 }, 3457 { 3458 key: 'isComplete', 3459 get: function () { 3460 return !!this.currentMask && this.currentMask.isComplete 3461 }, 3462 }, 3463 { 3464 key: 'remove', 3465 value: function () { 3466 var e, 3467 t = new lt() 3468 this.currentMask && 3469 t.aggregate((e = this.currentMask).remove.apply(e, arguments)).aggregate(this._applyDispatch()) 3470 return t 3471 }, 3472 }, 3473 { 3474 key: 'state', 3475 get: function () { 3476 return Object.assign({}, Je(ze(n.prototype), 'state', this), { 3477 _rawInputValue: this.rawInputValue, 3478 compiledMasks: this.compiledMasks.map(function (e) { 3479 return e.state 3480 }), 3481 currentMaskRef: this.currentMask, 3482 currentMask: this.currentMask && this.currentMask.state, 3483 }) 3484 }, 3485 set: function (e) { 3486 var t = e.compiledMasks, 3487 i = e.currentMaskRef, 3488 o = e.currentMask, 3489 s = We(e, ['compiledMasks', 'currentMaskRef', 'currentMask']) 3490 this.compiledMasks.forEach(function (e, n) { 3491 return (e.state = t[n]) 3492 }), 3493 null != i && ((this.currentMask = i), (this.currentMask.state = o)), 3494 Xe(ze(n.prototype), 'state', s, this, !0) 3495 }, 3496 }, 3497 { 3498 key: 'extractInput', 3499 value: function () { 3500 var e 3501 return this.currentMask ? (e = this.currentMask).extractInput.apply(e, arguments) : '' 3502 }, 3503 }, 3504 { 3505 key: 'extractTail', 3506 value: function () { 3507 for (var e, t, i = arguments.length, o = new Array(i), s = 0; s < i; s++) o[s] = arguments[s] 3508 return this.currentMask 3509 ? (e = this.currentMask).extractTail.apply(e, o) 3510 : (t = Je(ze(n.prototype), 'extractTail', this)).call.apply(t, [this].concat(o)) 3511 }, 3512 }, 3513 { 3514 key: 'doCommit', 3515 value: function () { 3516 this.currentMask && this.currentMask.doCommit(), Je(ze(n.prototype), 'doCommit', this).call(this) 3517 }, 3518 }, 3519 { 3520 key: 'nearestInputPos', 3521 value: function () { 3522 for (var e, t, i = arguments.length, o = new Array(i), s = 0; s < i; s++) o[s] = arguments[s] 3523 return this.currentMask 3524 ? (e = this.currentMask).nearestInputPos.apply(e, o) 3525 : (t = Je(ze(n.prototype), 'nearestInputPos', this)).call.apply(t, [this].concat(o)) 3526 }, 3527 }, 3528 { 3529 key: 'overwrite', 3530 get: function () { 3531 return this.currentMask ? this.currentMask.overwrite : Je(ze(n.prototype), 'overwrite', this) 3532 }, 3533 set: function (e) { 3534 console.warn('"overwrite" option is not available in dynamic mask, use this option in siblings') 3535 }, 3536 }, 3537 ]), 3538 n 3539 ) 3540 })(ht) 3541 ;(Et.DEFAULTS = { 3542 dispatch: function (e, t, n) { 3543 if (t.compiledMasks.length) { 3544 var i = t.rawInputValue, 3545 o = t.compiledMasks.map(function (t, o) { 3546 return ( 3547 t.reset(), 3548 t.append(i, { 3549 raw: !0, 3550 }), 3551 t.append(e, n), 3552 { 3553 weight: t.rawInputValue.length, 3554 index: o, 3555 } 3556 ) 3557 }) 3558 return ( 3559 o.sort(function (e, t) { 3560 return t.weight - e.weight 3561 }), 3562 t.compiledMasks[o[0].index] 3563 ) 3564 } 3565 }, 3566 }), 3567 (pt.MaskedDynamic = Et) 3568 var Lt = { 3569 MASKED: 'value', 3570 UNMASKED: 'unmaskedValue', 3571 TYPED: 'typedValue', 3572 } 3573 function Ft(e) { 3574 var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : Lt.MASKED, 3575 n = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : Lt.MASKED, 3576 i = ft(e) 3577 return function (e) { 3578 return i.runIsolated(function (i) { 3579 return (i[t] = e), i[n] 3580 }) 3581 } 3582 } 3583 function It(e) { 3584 for (var t = arguments.length, n = new Array(t > 1 ? t - 1 : 0), i = 1; i < t; i++) n[i - 1] = arguments[i] 3585 return Ft.apply(void 0, n)(e) 3586 } 3587 ;(pt.PIPE_TYPE = Lt), (pt.createPipe = Ft), (pt.pipe = It) 3588 try { 3589 globalThis.IMask = pt 3590 } catch (e) {} 3591 ;(e.HTMLContenteditableMaskElement = qt), 3592 (e.HTMLMaskElement = At), 3593 (e.InputMask = $t), 3594 (e.MaskElement = xt), 3595 (e.Masked = ht), 3596 (e.MaskedDate = _t), 3597 (e.MaskedDynamic = Et), 3598 (e.MaskedEnum = Tt), 3599 (e.MaskedFunction = Mt), 3600 (e.MaskedNumber = Bt), 3601 (e.MaskedPattern = St), 3602 (e.MaskedRange = wt), 3603 (e.MaskedRegExp = kt), 3604 (e.PIPE_TYPE = Lt), 3605 (e.createMask = ft), 3606 (e.createPipe = Ft), 3607 (e.default = pt), 3608 (e.pipe = It), 3609 Object.defineProperty(e, '__esModule', { 3610 value: !0, 3611 }) 3612 }), 3613 (function (e, t) { 3614 'object' == typeof exports && 'object' == typeof module 3615 ? (module.exports = t()) 3616 : 'function' == typeof define && define.amd 3617 ? define([], t) 3618 : 'object' == typeof exports 3619 ? (exports.axios = t()) 3620 : (e.axios = t()) 3621 })(this, function () { 3622 return (function (e) { 3623 var t = {} 3624 function n(i) { 3625 if (t[i]) return t[i].exports 3626 var o = (t[i] = { 3627 exports: {}, 3628 id: i, 3629 loaded: !1, 3630 }) 3631 return e[i].call(o.exports, o, o.exports, n), (o.loaded = !0), o.exports 3632 } 3633 return (n.m = e), (n.c = t), (n.p = ''), n(0) 3634 })([ 3635 function (e, t, n) { 3636 e.exports = n(1) 3637 }, 3638 function (e, t, n) { 3639 'use strict' 3640 var i = n(2), 3641 o = n(3), 3642 s = n(4), 3643 a = n(22) 3644 function r(e) { 3645 var t = new s(e), 3646 n = o(s.prototype.request, t) 3647 return i.extend(n, s.prototype, t), i.extend(n, t), n 3648 } 3649 var c = r(n(10)) 3650 ;(c.Axios = s), 3651 (c.create = function (e) { 3652 return r(a(c.defaults, e)) 3653 }), 3654 (c.Cancel = n(23)), 3655 (c.CancelToken = n(24)), 3656 (c.isCancel = n(9)), 3657 (c.all = function (e) { 3658 return Promise.all(e) 3659 }), 3660 (c.spread = n(25)), 3661 (c.isAxiosError = n(26)), 3662 (e.exports = c), 3663 (e.exports.default = c) 3664 }, 3665 function (e, t, n) { 3666 'use strict' 3667 var i = n(3), 3668 o = Object.prototype.toString 3669 function s(e) { 3670 return '[object Array]' === o.call(e) 3671 } 3672 function a(e) { 3673 return void 0 === e 3674 } 3675 function r(e) { 3676 return null !== e && 'object' == typeof e 3677 } 3678 function c(e) { 3679 if ('[object Object]' !== o.call(e)) return !1 3680 var t = Object.getPrototypeOf(e) 3681 return null === t || t === Object.prototype 3682 } 3683 function u(e) { 3684 return '[object Function]' === o.call(e) 3685 } 3686 function l(e, t) { 3687 if (null != e) 3688 if (('object' != typeof e && (e = [e]), s(e))) 3689 for (var n = 0, i = e.length; n < i; n++) t.call(null, e[n], n, e) 3690 else for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && t.call(null, e[o], o, e) 3691 } 3692 e.exports = { 3693 isArray: s, 3694 isArrayBuffer: function (e) { 3695 return '[object ArrayBuffer]' === o.call(e) 3696 }, 3697 isBuffer: function (e) { 3698 return ( 3699 null !== e && 3700 !a(e) && 3701 null !== e.constructor && 3702 !a(e.constructor) && 3703 'function' == typeof e.constructor.isBuffer && 3704 e.constructor.isBuffer(e) 3705 ) 3706 }, 3707 isFormData: function (e) { 3708 return 'undefined' != typeof FormData && e instanceof FormData 3709 }, 3710 isArrayBufferView: function (e) { 3711 return 'undefined' != typeof ArrayBuffer && ArrayBuffer.isView 3712 ? ArrayBuffer.isView(e) 3713 : e && e.buffer && e.buffer instanceof ArrayBuffer 3714 }, 3715 isString: function (e) { 3716 return 'string' == typeof e 3717 }, 3718 isNumber: function (e) { 3719 return 'number' == typeof e 3720 }, 3721 isObject: r, 3722 isPlainObject: c, 3723 isUndefined: a, 3724 isDate: function (e) { 3725 return '[object Date]' === o.call(e) 3726 }, 3727 isFile: function (e) { 3728 return '[object File]' === o.call(e) 3729 }, 3730 isBlob: function (e) { 3731 return '[object Blob]' === o.call(e) 3732 }, 3733 isFunction: u, 3734 isStream: function (e) { 3735 return r(e) && u(e.pipe) 3736 }, 3737 isURLSearchParams: function (e) { 3738 return 'undefined' != typeof URLSearchParams && e instanceof URLSearchParams 3739 }, 3740 isStandardBrowserEnv: function () { 3741 return ( 3742 ('undefined' == typeof navigator || 3743 ('ReactNative' !== navigator.product &&
3744 'NativeScript' !== navigator.product && 3745 'NS' !== navigator.product)) && 3746 'undefined' != typeof window && 3747 'undefined' != typeof document 3748 ) 3749 }, 3750 forEach: l, 3751 merge: function e() { 3752 var t = {} 3753 function n(n, i) { 3754 c(t[i]) && c(n) ? (t[i] = e(t[i], n)) : c(n) ? (t[i] = e({}, n)) : s(n) ? (t[i] = n.slice()) : (t[i] = n) 3755 } 3756 for (var i = 0, o = arguments.length; i < o; i++) l(arguments[i], n) 3757 return t 3758 }, 3759 extend: function (e, t, n) { 3760 return ( 3761 l(t, function (t, o) { 3762 e[o] = n && 'function' == typeof t ? i(t, n) : t 3763 }), 3764 e 3765 ) 3766 }, 3767 trim: function (e) { 3768 return e.replace(/^\s*/, '').replace(/\s*$/, '') 3769 }, 3770 stripBOM: function (e) { 3771 return 65279 === e.charCodeAt(0) && (e = e.slice(1)), e 3772 }, 3773 } 3774 }, 3775 function (e, t) { 3776 'use strict' 3777 e.exports = function (e, t) { 3778 return function () { 3779 for (var n = new Array(arguments.length), i = 0; i < n.length; i++) n[i] = arguments[i] 3780 return e.apply(t, n) 3781 } 3782 } 3783 }, 3784 function (e, t, n) { 3785 'use strict' 3786 var i = n(2), 3787 o = n(5), 3788 s = n(6), 3789 a = n(7), 3790 r = n(22) 3791 function c(e) { 3792 ;(this.defaults = e), 3793 (this.interceptors = { 3794 request: new s(), 3795 response: new s(), 3796 }) 3797 } 3798 ;(c.prototype.request = function (e) { 3799 'string' == typeof e ? ((e = arguments[1] || {}).url = arguments[0]) : (e = e || {}), 3800 (e = r(this.defaults, e)).method 3801 ? (e.method = e.method.toLowerCase()) 3802 : this.defaults.method 3803 ? (e.method = this.defaults.method.toLowerCase()) 3804 : (e.method = 'get') 3805 var t = [a, void 0], 3806 n = Promise.resolve(e) 3807 for ( 3808 this.interceptors.request.forEach(function (e) { 3809 t.unshift(e.fulfilled, e.rejected) 3810 }), 3811 this.interceptors.response.forEach(function (e) { 3812 t.push(e.fulfilled, e.rejected) 3813 }); 3814 t.length; 3815 3816 ) 3817 n = n.then(t.shift(), t.shift()) 3818 return n 3819 }), 3820 (c.prototype.getUri = function (e) { 3821 return (e = r(this.defaults, e)), o(e.url, e.params, e.paramsSerializer).replace(/^\?/, '') 3822 }), 3823 i.forEach(['delete', 'get', 'head', 'options'], function (e) { 3824 c.prototype[e] = function (t, n) { 3825 return this.request( 3826 r(n || {}, { 3827 method: e, 3828 url: t, 3829 data: (n || {}).data, 3830 }) 3831 ) 3832 } 3833 }), 3834 i.forEach(['post', 'put', 'patch'], function (e) { 3835 c.prototype[e] = function (t, n, i) { 3836 return this.request( 3837 r(i || {}, { 3838 method: e, 3839 url: t, 3840 data: n, 3841 }) 3842 ) 3843 } 3844 }), 3845 (e.exports = c) 3846 }, 3847 function (e, t, n) { 3848 'use strict' 3849 var i = n(2) 3850 function o(e) { 3851 return encodeURIComponent(e) 3852 .replace(/%3A/gi, ':') 3853 .replace(/%24/g, '$') 3854 .replace(/%2C/gi, ',') 3855 .replace(/%20/g, '+') 3856 .replace(/%5B/gi, '[') 3857 .replace(/%5D/gi, ']') 3858 } 3859 e.exports = function (e, t, n) { 3860 if (!t) return e 3861 var s 3862 if (n) s = n(t) 3863 else if (i.isURLSearchParams(t)) s = t.toString() 3864 else { 3865 var a = [] 3866 i.forEach(t, function (e, t) { 3867 null != e && 3868 (i.isArray(e) ? (t += '[]') : (e = [e]),
3869 i.forEach(e, function (e) { 3870 i.isDate(e) ? (e = e.toISOString()) : i.isObject(e) && (e = JSON.stringify(e)), 3871 a.push(o(t) + '=' + o(e)) 3872 })) 3873 }), 3874 (s = a.join('&')) 3875 } 3876 if (s) { 3877 var r = e.indexOf('#') 3878 ;-1 !== r && (e = e.slice(0, r)), (e += (-1 === e.indexOf('?') ? '?' : '&') + s) 3879 } 3880 return e 3881 } 3882 }, 3883 function (e, t, n) { 3884 'use strict' 3885 var i = n(2) 3886 function o() { 3887 this.handlers = [] 3888 } 3889 ;(o.prototype.use = function (e, t) { 3890 return ( 3891 this.handlers.push({ 3892 fulfilled: e, 3893 rejected: t, 3894 }), 3895 this.handlers.length - 1 3896 ) 3897 }), 3898 (o.prototype.eject = function (e) { 3899 this.handlers[e] && (this.handlers[e] = null) 3900 }), 3901 (o.prototype.forEach = function (e) { 3902 i.forEach(this.handlers, function (t) { 3903 null !== t && e(t) 3904 }) 3905 }), 3906 (e.exports = o) 3907 }, 3908 function (e, t, n) { 3909 'use strict' 3910 var i = n(2), 3911 o = n(8), 3912 s = n(9), 3913 a = n(10) 3914 function r(e) { 3915 e.cancelToken && e.cancelToken.throwIfRequested() 3916 } 3917 e.exports = function (e) { 3918 return ( 3919 r(e), 3920 (e.headers = e.headers || {}), 3921 (e.data = o(e.data, e.headers, e.transformRequest)), 3922 (e.headers = i.merge(e.headers.common || {}, e.headers[e.method] || {}, e.headers)), 3923 i.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], function (t) { 3924 delete e.headers[t] 3925 }), 3926 (e.adapter || a.adapter)(e).then( 3927 function (t) { 3928 return r(e), (t.data = o(t.data, t.headers, e.transformResponse)), t 3929 }, 3930 function (t) { 3931 return ( 3932 s(t) || 3933 (r(e), 3934 t && t.response && (t.response.data = o(t.response.data, t.response.headers, e.transformResponse))), 3935 Promise.reject(t) 3936 ) 3937 } 3938 ) 3939 ) 3940 } 3941 }, 3942 function (e, t, n) { 3943 'use strict' 3944 var i = n(2) 3945 e.exports = function (e, t, n) { 3946 return ( 3947 i.forEach(n, function (n) { 3948 e = n(e, t) 3949 }), 3950 e 3951 ) 3952 } 3953 }, 3954 function (e, t) { 3955 'use strict' 3956 e.exports = function (e) { 3957 return !(!e || !e.__CANCEL__) 3958 } 3959 }, 3960 function (e, t, n) { 3961 'use strict' 3962 var i = n(2), 3963 o = n(11), 3964 s = { 3965 'Content-Type': 'application/x-www-form-urlencoded', 3966 } 3967 function a(e, t) { 3968 !i.isUndefined(e) && i.isUndefined(e['Content-Type']) && (e['Content-Type'] = t) 3969 } 3970 var r, 3971 c = { 3972 adapter: 3973 (('undefined' != typeof XMLHttpRequest || 3974 ('undefined' != typeof process && '[object process]' === Object.prototype.toString.call(process))) && 3975 (r = n(12)), 3976 r), 3977 transformRequest: [ 3978 function (e, t) { 3979 return ( 3980 o(t, 'Accept'), 3981 o(t, 'Content-Type'), 3982 i.isFormData(e) || i.isArrayBuffer(e) || i.isBuffer(e) || i.isStream(e) || i.isFile(e) || i.isBlob(e) 3983 ? e 3984 : i.isArrayBufferView(e) 3985 ? e.buffer 3986 : i.isURLSearchParams(e) 3987 ? (a(t, 'application/x-www-form-urlencoded;charset=utf-8'), e.toString()) 3988 : i.isObject(e) 3989 ? (a(t, 'application/json;charset=utf-8'), JSON.stringify(e)) 3990 : e 3991 ) 3992 }, 3993 ], 3994 transformResponse: [ 3995 function (e) { 3996 if ('string' == typeof e) 3997 try { 3998 e = JSON.parse(e) 3999 } catch (e) {} 4000 return e 4001 }, 4002 ], 4003 timeout: 0, 4004 xsrfCookieName: 'XSRF-TOKEN', 4005 xsrfHeaderName: 'X-XSRF-TOKEN', 4006 maxContentLength: -1,
4007 maxBodyLength: -1, 4008 validateStatus: function (e) { 4009 return e >= 200 && e < 300 4010 }, 4011 } 4012 ;(c.headers = { 4013 common: { 4014 Accept: 'application/json, text/plain, */*', 4015 }, 4016 }), 4017 i.forEach(['delete', 'get', 'head'], function (e) { 4018 c.headers[e] = {} 4019 }), 4020 i.forEach(['post', 'put', 'patch'], function (e) { 4021 c.headers[e] = i.merge(s) 4022 }), 4023 (e.exports = c) 4024 }, 4025 function (e, t, n) { 4026 'use strict' 4027 var i = n(2) 4028 e.exports = function (e, t) { 4029 i.forEach(e, function (n, i) { 4030 i !== t && i.toUpperCase() === t.toUpperCase() && ((e[t] = n), delete e[i]) 4031 }) 4032 } 4033 }, 4034 function (e, t, n) { 4035 'use strict' 4036 var i = n(2), 4037 o = n(13), 4038 s = n(16), 4039 a = n(5), 4040 r = n(17), 4041 c = n(20), 4042 u = n(21), 4043 l = n(14) 4044 e.exports = function (e) { 4045 return new Promise(function (t, n) { 4046 var d = e.data, 4047 p = e.headers 4048 i.isFormData(d) && delete p['Content-Type'] 4049 var h = new XMLHttpRequest() 4050 if (e.auth) { 4051 var m = e.auth.username || '', 4052 f = e.auth.password ? unescape(encodeURIComponent(e.auth.password)) : '' 4053 p.Authorization = 'Basic ' + btoa(m + ':' + f) 4054 } 4055 var y = r(e.baseURL, e.url) 4056 if ( 4057 (h.open(e.method.toUpperCase(), a(y, e.params, e.paramsSerializer), !0), 4058 (h.timeout = e.timeout), 4059 (h.onreadystatechange = function () { 4060 if ( 4061 h && 4062 4 === h.readyState && 4063 (0 !== h.status || (h.responseURL && 0 === h.responseURL.indexOf('file:'))) 4064 ) { 4065 var i = 'getAllResponseHeaders' in h ? c(h.getAllResponseHeaders()) : null, 4066 s = { 4067 data: e.responseType && 'text' !== e.responseType ? h.response : h.responseText, 4068 status: h.status, 4069 statusText: h.statusText, 4070 headers: i, 4071 config: e, 4072 request: h, 4073 } 4074 o(t, n, s), (h = null) 4075 } 4076 }), 4077 (h.onabort = function () { 4078 h && (n(l('Request aborted', e, 'ECONNABORTED', h)), (h = null)) 4079 }), 4080 (h.onerror = function () { 4081 n(l('Network Error', e, null, h)), (h = null) 4082 }), 4083 (h.ontimeout = function () { 4084 var t = 'timeout of ' + e.timeout + 'ms exceeded' 4085 e.timeoutErrorMessage && (t = e.timeoutErrorMessage), n(l(t, e, 'ECONNABORTED', h)), (h = null) 4086 }), 4087 i.isStandardBrowserEnv()) 4088 ) { 4089 var v = (e.withCredentials || u(y)) && e.xsrfCookieName ? s.read(e.xsrfCookieName) : void 0 4090 v && (p[e.xsrfHeaderName] = v) 4091 } 4092 if ( 4093 ('setRequestHeader' in h && 4094 i.forEach(p, function (e, t) { 4095 void 0 === d && 'content-type' === t.toLowerCase() ? delete p[t] : h.setRequestHeader(t, e) 4096 }), 4097 i.isUndefined(e.withCredentials) || (h.withCredentials = !!e.withCredentials), 4098 e.responseType) 4099 ) 4100 try { 4101 h.responseType = e.responseType 4102 } catch (t) { 4103 if ('json' !== e.responseType) throw t 4104 } 4105 'function' == typeof e.onDownloadProgress && h.addEventListener('progress', e.onDownloadProgress), 4106 'function' == typeof e.onUploadProgress && 4107 h.upload && 4108 h.upload.addEventListener('progress', e.onUploadProgress), 4109 e.cancelToken && 4110 e.cancelToken.promise.then(function (e) { 4111 h && (h.abort(), n(e), (h = null)) 4112 }), 4113 d || (d = null), 4114 h.send(d) 4115 }) 4116 } 4117 }, 4118 function (e, t, n) { 4119 'use strict' 4120 var i = n(14) 4121 e.exports = function (e, t, n) { 4122 var o = n.config.validateStatus 4123 n.status && o && !o(n.status) 4124 ? t(i('Request failed with status code ' + n.status, n.config, null, n.request, n)) 4125 : e(n) 4126 } 4127 }, 4128 function (e, t, n) { 4129 'use strict' 4130 var i = n(15) 4131 e.exports = function (e, t, n, o, s) { 4132 var a = new Error(e) 4133 return i(a, t, n, o, s) 4134 } 4135 }, 4136 function (e, t) { 4137 'use strict' 4138 e.exports = function (e, t, n, i, o) { 4139 return ( 4140 (e.config = t), 4141 n && (e.code = n), 4142 (e.request = i), 4143 (e.response = o), 4144 (e.isAxiosError = !0), 4145 (e.toJSON = function () { 4146 return { 4147 message: this.message, 4148 name: this.name, 4149 description: this.description, 4150 number: this.number, 4151 fileName: this.fileName, 4152 lineNumber: this.lineNumber, 4153 columnNumber: this.columnNumber, 4154 stack: this.stack, 4155 config: this.config,
4156 code: this.code, 4157 } 4158 }), 4159 e 4160 ) 4161 } 4162 }, 4163 function (e, t, n) { 4164 'use strict' 4165 var i = n(2) 4166 e.exports = i.isStandardBrowserEnv() 4167 ? { 4168 write: function (e, t, n, o, s, a) { 4169 var r = [] 4170 r.push(e + '=' + encodeURIComponent(t)), 4171 i.isNumber(n) && r.push('expires=' + new Date(n).toGMTString()), 4172 i.isString(o) && r.push('path=' + o), 4173 i.isString(s) && r.push('domain=' + s), 4174 !0 === a && r.push('secure'), 4175 (document.cookie = r.join('; ')) 4176 }, 4177 read: function (e) { 4178 var t = document.cookie.match(new RegExp('(^|;\\s*)(' + e + ')=([^;]*)')) 4179 return t ? decodeURIComponent(t[3]) : null 4180 }, 4181 remove: function (e) { 4182 this.write(e, '', Date.now() - 864e5) 4183 }, 4184 } 4185 : { 4186 write: function () {}, 4187 read: function () { 4188 return null 4189 }, 4190 remove: function () {}, 4191 } 4192 }, 4193 function (e, t, n) { 4194 'use strict' 4195 var i = n(18), 4196 o = n(19) 4197 e.exports = function (e, t) { 4198 return e && !i(t) ? o(e, t) : t 4199 } 4200 }, 4201 function (e, t) { 4202 'use strict' 4203 e.exports = function (e) { 4204 return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e) 4205 } 4206 }, 4207 function (e, t) { 4208 'use strict' 4209 e.exports = function (e, t) { 4210 return t ? e.replace(/\/+$/, '') + '/' + t.replace(/^\/+/, '') : e 4211 } 4212 }, 4213 function (e, t, n) { 4214 'use strict' 4215 var i = n(2), 4216 o = [ 4217 'age', 4218 'authorization', 4219 'content-length', 4220 'content-type', 4221 'etag', 4222 'expires', 4223 'from', 4224 'host', 4225 'if-modified-since', 4226 'if-unmodified-since', 4227 'last-modified', 4228 'location', 4229 'max-forwards', 4230 'proxy-authorization', 4231 'referer', 4232 'retry-after', 4233 'user-agent', 4234 ] 4235 e.exports = function (e) { 4236 var t, 4237 n, 4238 s, 4239 a = {} 4240 return e 4241 ? (i.forEach(e.split('\n'), function (e) { 4242 if ( 4243 ((s = e.indexOf(':')), (t = i.trim(e.substr(0, s)).toLowerCase()), (n = i.trim(e.substr(s + 1))), t) 4244 ) { 4245 if (a[t] && o.indexOf(t) >= 0) return 4246 a[t] = 'set-cookie' === t ? (a[t] ? a[t] : []).concat([n]) : a[t] ? a[t] + ', ' + n : n 4247 } 4248 }), 4249 a) 4250 : a 4251 } 4252 }, 4253 function (e, t, n) { 4254 'use strict' 4255 var i = n(2) 4256 e.exports = i.isStandardBrowserEnv() 4257 ? (function () { 4258 var e, 4259 t = /(msie|trident)/i.test(navigator.userAgent), 4260 n = document.createElement('a') 4261 function o(e) { 4262 var i = e 4263 return ( 4264 t && (n.setAttribute('href', i), (i = n.href)), 4265 n.setAttribute('href', i), 4266 { 4267 href: n.href, 4268 protocol: n.protocol ? n.protocol.replace(/:$/, '') : '', 4269 host: n.host, 4270 search: n.search ? n.search.replace(/^\?/, '') : '', 4271 hash: n.hash ? n.hash.replace(/^#/, '') : '', 4272 hostname: n.hostname, 4273 port: n.port, 4274 pathname: '/' === n.pathname.charAt(0) ? n.pathname : '/' + n.pathname, 4275 } 4276 ) 4277 } 4278 return ( 4279 (e = o(window.location.href)), 4280 function (t) { 4281 var n = i.isString(t) ? o(t) : t 4282 return n.protocol === e.protocol && n.host === e.host 4283 } 4284 ) 4285 })() 4286 : function () { 4287 return !0 4288 } 4289 }, 4290 function (e, t, n) { 4291 'use strict' 4292 var i = n(2) 4293 e.exports = function (e, t) { 4294 t = t || {} 4295 var n = {}, 4296 o = ['url', 'method', 'data'], 4297 s = ['headers', 'auth', 'proxy', 'params'], 4298 a = [ 4299 'baseURL', 4300 'transformRequest', 4301 'transformResponse', 4302 'paramsSerializer', 4303 'timeout', 4304 'timeoutMessage', 4305 'withCredentials', 4306 'adapter', 4307 'responseType', 4308 'xsrfCookieName', 4309 'xsrfHeaderName', 4310 'onUploadProgress', 4311 'onDownloadProgress', 4312 'decompress', 4313 'maxContentLength', 4314 'maxBodyLength', 4315 'maxRedirects', 4316 'transport', 4317 'httpAgent', 4318 'httpsAgent', 4319 'cancelToken', 4320 'socketPath', 4321 'responseEncoding', 4322 ], 4323 r = ['validateStatus'] 4324 function c(e, t) { 4325 return i.isPlainObject(e) && i.isPlainObject(t) 4326 ? i.merge(e, t) 4327 : i.isPlainObject(t) 4328 ? i.merge({}, t) 4329 : i.isArray(t) 4330 ? t.slice() 4331 : t 4332 } 4333 function u(o) { 4334 i.isUndefined(t[o]) ? i.isUndefined(e[o]) || (n[o] = c(void 0, e[o])) : (n[o] = c(e[o], t[o])) 4335 }
4336 i.forEach(o, function (e) { 4337 i.isUndefined(t[e]) || (n[e] = c(void 0, t[e])) 4338 }), 4339 i.forEach(s, u), 4340 i.forEach(a, function (o) { 4341 i.isUndefined(t[o]) ? i.isUndefined(e[o]) || (n[o] = c(void 0, e[o])) : (n[o] = c(void 0, t[o])) 4342 }), 4343 i.forEach(r, function (i) { 4344 i in t ? (n[i] = c(e[i], t[i])) : i in e && (n[i] = c(void 0, e[i])) 4345 }) 4346 var l = o.concat(s).concat(a).concat(r), 4347 d = Object.keys(e) 4348 .concat(Object.keys(t)) 4349 .filter(function (e) { 4350 return -1 === l.indexOf(e) 4351 }) 4352 return i.forEach(d, u), n 4353 } 4354 }, 4355 function (e, t) { 4356 'use strict' 4357 function n(e) { 4358 this.message = e 4359 } 4360 ;(n.prototype.toString = function () { 4361 return 'Cancel' + (this.message ? ': ' + this.message : '') 4362 }), 4363 (n.prototype.__CANCEL__ = !0), 4364 (e.exports = n) 4365 }, 4366 function (e, t, n) { 4367 'use strict' 4368 var i = n(23) 4369 function o(e) { 4370 if ('function' != typeof e) throw new TypeError('executor must be a function.') 4371 var t 4372 this.promise = new Promise(function (e) { 4373 t = e 4374 }) 4375 var n = this 4376 e(function (e) { 4377 n.reason || ((n.reason = new i(e)), t(n.reason)) 4378 }) 4379 } 4380 ;(o.prototype.throwIfRequested = function () { 4381 if (this.reason) throw this.reason 4382 }), 4383 (o.source = function () { 4384 var e 4385 return { 4386 token: new o(function (t) { 4387 e = t 4388 }), 4389 cancel: e, 4390 } 4391 }), 4392 (e.exports = o) 4393 }, 4394 function (e, t) { 4395 'use strict' 4396 e.exports = function (e) { 4397 return function (t) { 4398 return e.apply(null, t) 4399 } 4400 } 4401 }, 4402 function (e, t) { 4403 'use strict' 4404 e.exports = function (e) { 4405 return 'object' == typeof e && !0 === e.isAxiosError 4406 } 4407 }, 4408 ]) 4409 }), 4410 (function (e) { 4411 'use strict' 4412 'function' == typeof define && define.amd 4413 ? define(['jquery'], e) 4414 : 'undefined' != typeof exports 4415 ? (module.exports = e(require('jquery'))) 4416 : e(jQuery) 4417 })(function (e) { 4418 'use strict' 4419 var t, 4420 n = window.Slick || {} 4421 ;(t = 0), 4422 ((n = function (n, i) { 4423 var o, 4424 s = this 4425 ;(s.defaults = { 4426 accessibility: !0, 4427 adaptiveHeight: !1, 4428 appendArrows: e(n), 4429 appendDots: e(n), 4430 arrows: !0, 4431 asNavFor: null, 4432 prevArrow: '<button class="slick-prev" aria-label="Previous" type="button">Previous</button>', 4433 nextArrow: '<button class="slick-next" aria-label="Next" type="button">Next</button>', 4434 autoplay: !1, 4435 autoplaySpeed: 3e3, 4436 centerMode: !1, 4437 centerPadding: '50px', 4438 cssEase: 'ease', 4439 customPaging: function (t, n) { 4440 return e('<button type="button" />').text(n + 1) 4441 }, 4442 dots: !1, 4443 dotsClass: 'slick-dots', 4444 draggable: !0, 4445 easing: 'linear', 4446 edgeFriction: 0.35, 4447 fade: !1, 4448 focusOnSelect: !1, 4449 focusOnChange: !1, 4450 infinite: !0, 4451 initialSlide: 0, 4452 lazyLoad: 'ondemand', 4453 mobileFirst: !1, 4454 pauseOnHover: !0, 4455 pauseOnFocus: !0, 4456 pauseOnDotsHover: !1, 4457 respondTo: 'window', 4458 responsive: null, 4459 rows: 1, 4460 rtl: !1, 4461 slide: '', 4462 slidesPerRow: 1, 4463 slidesToShow: 1, 4464 slidesToScroll: 1, 4465 speed: 500, 4466 swipe: !0, 4467 swipeToSlide: !1, 4468 touchMove: !0, 4469 touchThreshold: 5, 4470 useCSS: !0, 4471 useTransform: !0, 4472 variableWidth: !1, 4473 vertical: !1, 4474 verticalSwiping: !1, 4475 waitForAnimate: !0, 4476 zIndex: 1e3, 4477 }), 4478 (s.initials = { 4479 animating: !1, 4480 dragging: !1, 4481 autoPlayTimer: null, 4482 currentDirection: 0, 4483 currentLeft: null, 4484 currentSlide: 0, 4485 direction: 1, 4486 $dots: null, 4487 listWidth: null, 4488 listHeight: null, 4489 loadIndex: 0, 4490 $nextArrow: null, 4491 $prevArrow: null, 4492 scrolling: !1, 4493 slideCount: null, 4494 slideWidth: null, 4495 $slideTrack: null, 4496 $slides: null, 4497 sliding: !1, 4498 slideOffset: 0, 4499 swipeLeft: null, 4500 swiping: !1, 4501 $list: null, 4502 touchObject: {}, 4503 transformsEnabled: !1, 4504 unslicked: !1, 4505 }), 4506 e.extend(s, s.initials), 4507 (s.activeBreakpoint = null), 4508 (s.animType = null), 4509 (s.animProp = null), 4510 (s.breakpoints = []), 4511 (s.breakpointSettings = []), 4512 (s.cssTransitions = !1), 4513 (s.focussed = !1), 4514 (s.interrupted = !1), 4515 (s.hidden = 'hidden'), 4516 (s.paused = !0), 4517 (s.positionProp = null), 4518 (s.respondTo = null), 4519 (s.rowCount = 1), 4520 (s.shouldClick = !0), 4521 (s.$slider = e(n)), 4522 (s.$slidesCache = null), 4523 (s.transformType = null), 4524 (s.transitionType = null), 4525 (s.visibilityChange = 'visibilitychange'), 4526 (s.windowWidth = 0), 4527 (s.windowTimer = null), 4528 (o = e(n).data('slick') || {}), 4529 (s.options = e.extend({}, s.defaults, i, o)), 4530 (s.currentSlide = s.options.initialSlide), 4531 (s.originalSettings = s.options), 4532 void 0 !== document.mozHidden 4533 ? ((s.hidden = 'mozHidden'), (s.visibilityChange = 'mozvisibilitychange')) 4534 : void 0 !== document.webkitHidden && 4535 ((s.hidden = 'webkitHidden'), (s.visibilityChange = 'webkitvisibilitychange')), 4536 (s.autoPlay = e.proxy(s.autoPlay, s)), 4537 (s.autoPlayClear = e.proxy(s.autoPlayClear, s)), 4538 (s.autoPlayIterator = e.proxy(s.autoPlayIterator, s)), 4539 (s.changeSlide = e.proxy(s.changeSlide, s)), 4540 (s.clickHandler = e.proxy(s.clickHandler, s)), 4541 (s.selectHandler = e.proxy(s.selectHandler, s)), 4542 (s.setPosition = e.proxy(s.setPosition, s)), 4543 (s.swipeHandler = e.proxy(s.swipeHandler, s)), 4544 (s.dragHandler = e.proxy(s.dragHandler, s)), 4545 (s.keyHandler = e.proxy(s.keyHandler, s)), 4546 (s.instanceUid = t++), 4547 (s.htmlExpr = /^(?:\s*(<[\w\W]+>)[^>]*)$/), 4548 s.registerBreakpoints(), 4549 s.init(!0) 4550 }).prototype.activateADA = function () { 4551 this.$slideTrack 4552 .find('.slick-active') 4553 .attr({ 4554 'aria-hidden': 'false', 4555 }) 4556 .find('a, input, button, select') 4557 .attr({ 4558 tabindex: '0', 4559 }) 4560 }), 4561 (n.prototype.addSlide = n.prototype.slickAdd = 4562 function (t, n, i) { 4563 var o = this 4564 if ('boolean' == typeof n) (i = n), (n = null) 4565 else if (n < 0 || n >= o.slideCount) return !1 4566 o.unload(), 4567 'number' == typeof n 4568 ? 0 === n && 0 === o.$slides.length 4569 ? e(t).appendTo(o.$slideTrack) 4570 : i 4571 ? e(t).insertBefore(o.$slides.eq(n)) 4572 : e(t).insertAfter(o.$slides.eq(n)) 4573 : !0 === i 4574 ? e(t).prependTo(o.$slideTrack) 4575 : e(t).appendTo(o.$slideTrack), 4576 (o.$slides = o.$slideTrack.children(this.options.slide)), 4577 o.$slideTrack.children(this.options.slide).detach(), 4578 o.$slideTrack.append(o.$slides), 4579 o.$slides.each(function (t, n) { 4580 e(n).attr('data-slick-index', t) 4581 }), 4582 (o.$slidesCache = o.$slides), 4583 o.reinit() 4584 }), 4585 (n.prototype.animateHeight = function () { 4586 var e = this 4587 if (1 === e.options.slidesToShow && !0 === e.options.adaptiveHeight && !1 === e.options.vertical) { 4588 var t = e.$slides.eq(e.currentSlide).outerHeight(!0) 4589 e.$list.animate( 4590 { 4591 height: t, 4592 }, 4593 e.options.speed 4594 ) 4595 } 4596 }), 4597 (n.prototype.animateSlide = function (t, n) { 4598 var i = {}, 4599 o = this 4600 o.animateHeight(), 4601 !0 === o.options.rtl && !1 === o.options.vertical && (t = -t), 4602 !1 === o.transformsEnabled 4603 ? !1 === o.options.vertical 4604 ? o.$slideTrack.animate( 4605 { 4606 left: t, 4607 }, 4608 o.options.speed, 4609 o.options.easing, 4610 n 4611 ) 4612 : o.$slideTrack.animate( 4613 { 4614 top: t, 4615 }, 4616 o.options.speed, 4617 o.options.easing, 4618 n 4619 ) 4620 : !1 === o.cssTransitions 4621 ? (!0 === o.options.rtl && (o.currentLeft = -o.currentLeft), 4622 e({ 4623 animStart: o.currentLeft, 4624 }).animate( 4625 { 4626 animStart: t, 4627 }, 4628 { 4629 duration: o.options.speed, 4630 easing: o.options.easing, 4631 step: function (e) { 4632 ;
4632(e = Math.ceil(e)), 4633 !1 === o.options.vertical 4634 ? ((i[o.animType] = 'translate(' + e + 'px, 0px)'), o.$slideTrack.css(i)) 4635 : ((i[o.animType] = 'translate(0px,' + e + 'px)'), o.$slideTrack.css(i)) 4636 }, 4637 complete: function () { 4638 n && n.call() 4639 }, 4640 } 4641 )) 4642 : (o.applyTransition(), 4643 (t = Math.ceil(t)), 4644 !1 === o.options.vertical 4645 ? (i[o.animType] = 'translate3d(' + t + 'px, 0px, 0px)') 4646 : (i[o.animType] = 'translate3d(0px,' + t + 'px, 0px)'), 4647 o.$slideTrack.css(i), 4648 n && 4649 setTimeout(function () { 4650 o.disableTransition(), n.call() 4651 }, o.options.speed)) 4652 }), 4653 (n.prototype.getNavTarget = function () { 4654 var t = this.options.asNavFor 4655 return t && null !== t && (t = e(t).not(this.$slider)), t 4656 }), 4657 (n.prototype.asNavFor = function (t) { 4658 var n = this.getNavTarget() 4659 null !== n && 4660 'object' == typeof n && 4661 n.each(function () { 4662 var n = e(this).slick('getSlick') 4663 n.unslicked || n.slideHandler(t, !0) 4664 }) 4665 }), 4666 (n.prototype.applyTransition = function (e) { 4667 var t = this, 4668 n = {} 4669 !1 === t.options.fade 4670 ? (n[t.transitionType] = t.transformType + ' ' + t.options.speed + 'ms ' + t.options.cssEase) 4671 : (n[t.transitionType] = 'opacity ' + t.options.speed + 'ms ' + t.options.cssEase), 4672 !1 === t.options.fade ? t.$slideTrack.css(n) : t.$slides.eq(e).css(n) 4673 }), 4674 (n.prototype.autoPlay = function () { 4675 var e = this 4676 e.autoPlayClear(), 4677 e.slideCount > e.options.slidesToShow && 4678 (e.autoPlayTimer = setInterval(e.autoPlayIterator, e.options.autoplaySpeed)) 4679 }), 4680 (n.prototype.autoPlayClear = function () { 4681 this.autoPlayTimer && clearInterval(this.autoPlayTimer) 4682 }), 4683 (n.prototype.autoPlayIterator = function () { 4684 var e = this, 4685 t = e.currentSlide + e.options.slidesToScroll 4686 e.paused || 4687 e.interrupted || 4688 e.focussed || 4689 (!1 === e.options.infinite && 4690 (1 === e.direction && e.currentSlide + 1 === e.slideCount - 1 4691 ? (e.direction = 0) 4692 : 0 === e.direction && 4693 ((t = e.currentSlide - e.options.slidesToScroll), e.currentSlide - 1 == 0 && (e.direction = 1))), 4694 e.slideHandler(t)) 4695 }), 4696 (n.prototype.buildArrows = function () { 4697 var t = this 4698 !0 === t.options.arrows && 4699 ((t.$prevArrow = e(t.options.prevArrow).addClass('slick-arrow')), 4700 (t.$nextArrow = e(t.options.nextArrow).addClass('slick-arrow')), 4701 t.slideCount > t.options.slidesToShow 4702 ? (t.$prevArrow.removeClass('slick-hidden').removeAttr('aria-hidden tabindex'), 4703 t.$nextArrow.removeClass('slick-hidden').removeAttr('aria-hidden tabindex'), 4704 t.htmlExpr.test(t.options.prevArrow) && t.$prevArrow.prependTo(t.options.appendArrows), 4705 t.htmlExpr.test(t.options.nextArrow) && t.$nextArrow.appendTo(t.options.appendArrows), 4706 !0 !== t.options.infinite && t.$prevArrow.addClass('slick-disabled').attr('aria-disabled', 'true')) 4707 : t.$prevArrow.add(t.$nextArrow).addClass('slick-hidden').attr({ 4708 'aria-disabled': 'true', 4709 tabindex: '-1', 4710 })) 4711 }), 4712 (n.prototype.buildDots = function () { 4713 var t, 4714 n, 4715 i = this 4716 if (!0 === i.options.dots && i.slideCount > i.options.slidesToShow) { 4717 for ( 4718 i.$slider.addClass('slick-dotted'), n = e('<ul />').addClass(i.options.dotsClass), t = 0; 4719 t <= i.getDotCount(); 4720 t += 1 4721 ) 4722 n.append(e('<li />').append(i.options.customPaging.call(this, i, t))) 4723 ;(i.$dots = n.appendTo(i.options.appendDots)), i.$dots.find('li').first().addClass('slick-active') 4724 } 4725 }), 4726 (n.prototype.buildOut = function () { 4727 var t = this 4728 ;(t.$slides = t.$slider.children(t.options.slide + ':not(.slick-cloned)').addClass('slick-slide')), 4729 (t.slideCount = t.$slides.length), 4730 t.$slides.each(function (t, n) { 4731 e(n) 4732 .attr('data-slick-index', t) 4733 .data('originalStyling', e(n).attr('style') || '') 4734 }), 4735 t.$slider.addClass('slick-slider'), 4736 (t.$slideTrack = 4737 0 === t.slideCount 4738 ? e('<div class="slick-track"/>').appendTo(t.$slider) 4739 : t.$slides.wrapAll('<div class="slick-track"/>').parent()), 4740 (t.$list = t.$slideTrack.wrap('<div class="slick-list"/>').parent()), 4741 t.$slideTrack.css('opacity', 0), 4742 (!0 !== t.options.centerMode && !0 !== t.options.swipeToSlide) || (t.options.slidesToScroll = 1), 4743 e('img[data-lazy]', t.$slider).not('[src]').addClass('slick-loading'), 4744 t.setupInfinite(), 4745 t.buildArrows(), 4746 t.buildDots(), 4747 t.updateDots(), 4748 t.setSlideClasses('number' == typeof t.currentSlide ? t.currentSlide : 0), 4749 !0 === t.options.draggable && t.$list.addClass('draggable') 4750 }), 4751 (n.prototype.buildRows = function () { 4752 var e, 4753 t, 4754 n, 4755 i, 4756 o, 4757 s, 4758 a, 4759 r = this 4760 if (((i = document.createDocumentFragment()), (s = r.$slider.children()), r.options.rows > 0)) { 4761 for (a = r.options.slidesPerRow * r.options.rows, o = Math.ceil(s.length / a), e = 0; e < o; e++) { 4762 var c = document.createElement('div') 4763 for (t = 0; t < r.options.rows; t++) { 4764 var u = document.createElement('div') 4765 for (n = 0; n < r.options.slidesPerRow; n++) { 4766 var l = e * a + (t * r.options.slidesPerRow + n) 4767 s.get(l) && u.appendChild(s.get(l)) 4768 } 4769 c.appendChild(u) 4770 } 4771 i.appendChild(c) 4772 } 4773 r.$slider.empty().append(i), 4774 r.$slider 4775 .children() 4776 .children() 4777 .children() 4778 .css({ 4779 width: 100 / r.options.slidesPerRow + '%', 4780 display: 'inline-block', 4781 }) 4782 } 4783 }), 4784 (n.prototype.checkResponsive = function (t, n) { 4785 var i, 4786 o, 4787 s, 4788 a = this, 4789 r = !1, 4790 c = a.$slider.width(), 4791 u = window.innerWidth || e(window).width() 4792 if ( 4793 ('window' === a.respondTo 4794 ? (s = u) 4795 : 'slider' === a.respondTo 4796 ? (s = c) 4797 : 'min' === a.respondTo && (s = Math.min(u, c)), 4798 a.options.responsive && a.options.responsive.length && null !== a.options.responsive) 4799 ) { 4800 for (i in ((o = null), a.breakpoints)) 4801 a.breakpoints.hasOwnProperty(i) && 4802 (!1 === a.originalSettings.mobileFirst 4803 ? s < a.breakpoints[i] && (o = a.breakpoints[i]) 4804 : s > a.breakpoints[i] && (o = a.breakpoints[i])) 4805 null !== o 4806 ? null !== a.activeBreakpoint 4807 ? (o !== a.activeBreakpoint || n) && 4808 ((a.activeBreakpoint = o),
4809 'unslick' === a.breakpointSettings[o] 4810 ? a.unslick(o) 4811 : ((a.options = e.extend({}, a.originalSettings, a.breakpointSettings[o])), 4812 !0 === t && (a.currentSlide = a.options.initialSlide), 4813 a.refresh(t)), 4814 (r = o)) 4815 : ((a.activeBreakpoint = o), 4816 'unslick' === a.breakpointSettings[o] 4817 ? a.unslick(o) 4818 : ((a.options = e.extend({}, a.originalSettings, a.breakpointSettings[o])), 4819 !0 === t && (a.currentSlide = a.options.initialSlide), 4820 a.refresh(t)), 4821 (r = o)) 4822 : null !== a.activeBreakpoint && 4823 ((a.activeBreakpoint = null), 4824 (a.options = a.originalSettings), 4825 !0 === t && (a.currentSlide = a.options.initialSlide), 4826 a.refresh(t), 4827 (r = o)), 4828 t || !1 === r || a.$slider.trigger('breakpoint', [a, r]) 4829 } 4830 }), 4831 (n.prototype.changeSlide = function (t, n) { 4832 var i, 4833 o, 4834 s = this, 4835 a = e(t.currentTarget) 4836 switch ( 4837 (a.is('a') && t.preventDefault(), 4838 a.is('li') || (a = a.closest('li')), 4839 (i = 4840 s.slideCount % s.options.slidesToScroll != 0 4841 ? 0 4842 : (s.slideCount - s.currentSlide) % s.options.slidesToScroll), 4843 t.data.message) 4844 ) { 4845 case 'previous': 4846 ;(o = 0 === i ? s.options.slidesToScroll : s.options.slidesToShow - i), 4847 s.slideCount > s.options.slidesToShow && s.slideHandler(s.currentSlide - o, !1, n) 4848 break 4849 case 'next': 4850 ;(o = 0 === i ? s.options.slidesToScroll : i), 4851 s.slideCount > s.options.slidesToShow && s.slideHandler(s.currentSlide + o, !1, n) 4852 break 4853 case 'index': 4854 var r = 0 === t.data.index ? 0 : t.data.index || a.index() * s.options.slidesToScroll 4855 s.slideHandler(s.checkNavigable(r), !1, n), a.children().trigger('focus') 4856 break 4857 default: 4858 return 4859 } 4860 }), 4861 (n.prototype.checkNavigable = function (e) { 4862 var t, n 4863 if (((n = 0), e > (t = this.getNavigableIndexes())[t.length - 1])) e = t[t.length - 1] 4864 else 4865 for (var i in t) { 4866 if (e < t[i]) { 4867 e = n 4868 break 4869 } 4870 n = t[i] 4871 } 4872 return e 4873 }), 4874 (n.prototype.cleanUpEvents = function () { 4875 var t = this 4876 t.options.dots && 4877 null !== t.$dots && 4878 (e('li', t.$dots) 4879 .off('click.slick', t.changeSlide) 4880 .off('mouseenter.slick', e.proxy(t.interrupt, t, !0)) 4881 .off('mouseleave.slick', e.proxy(t.interrupt, t, !1)), 4882 !0 === t.options.accessibility && t.$dots.off('keydown.slick', t.keyHandler)), 4883 t.$slider.off('focus.slick blur.slick'), 4884 !0 === t.options.arrows && 4885 t.slideCount > t.options.slidesToShow && 4886 (t.$prevArrow && t.$prevArrow.off('click.slick', t.changeSlide), 4887 t.$nextArrow && t.$nextArrow.off('click.slick', t.changeSlide), 4888 !0 === t.options.accessibility && 4889 (t.$prevArrow && t.$prevArrow.off('keydown.slick', t.keyHandler), 4890 t.$nextArrow && t.$nextArrow.off('keydown.slick', t.keyHandler))), 4891 t.$list.off('touchstart.slick mousedown.slick', t.swipeHandler), 4892 t.$list.off('touchmove.slick mousemove.slick', t.swipeHandler), 4893 t.$list.off('touchend.slick mouseup.slick', t.swipeHandler),
4894 t.$list.off('touchcancel.slick mouseleave.slick', t.swipeHandler), 4895 t.$list.off('click.slick', t.clickHandler), 4896 e(document).off(t.visibilityChange, t.visibility), 4897 t.cleanUpSlideEvents(), 4898 !0 === t.options.accessibility && t.$list.off('keydown.slick', t.keyHandler), 4899 !0 === t.options.focusOnSelect && e(t.$slideTrack).children().off('click.slick', t.selectHandler), 4900 e(window).off('orientationchange.slick.slick-' + t.instanceUid, t.orientationChange), 4901 e(window).off('resize.slick.slick-' + t.instanceUid, t.resize), 4902 e('[draggable!=true]', t.$slideTrack).off('dragstart', t.preventDefault), 4903 e(window).off('load.slick.slick-' + t.instanceUid, t.setPosition) 4904 }), 4905 (n.prototype.cleanUpSlideEvents = function () { 4906 var t = this 4907 t.$list.off('mouseenter.slick', e.proxy(t.interrupt, t, !0)), 4908 t.$list.off('mouseleave.slick', e.proxy(t.interrupt, t, !1)) 4909 }), 4910 (n.prototype.cleanUpRows = function () { 4911 var e, 4912 t = this 4913 t.options.rows > 0 && ((e = t.$slides.children().children()).removeAttr('style'), t.$slider.empty().append(e)) 4914 }), 4915 (n.prototype.clickHandler = function (e) { 4916 !1 === this.shouldClick && (e.stopImmediatePropagation(), e.stopPropagation(), e.preventDefault()) 4917 }), 4918 (n.prototype.destroy = function (t) { 4919 var n = this 4920 n.autoPlayClear(), 4921 (n.touchObject = {}), 4922 n.cleanUpEvents(), 4923 e('.slick-cloned', n.$slider).detach(), 4924 n.$dots && n.$dots.remove(), 4925 n.$prevArrow && 4926 n.$prevArrow.length && 4927 (n.$prevArrow 4928 .removeClass('slick-disabled slick-arrow slick-hidden') 4929 .removeAttr('aria-hidden aria-disabled tabindex') 4930 .css('display', ''), 4931 n.htmlExpr.test(n.options.prevArrow) && n.$prevArrow.remove()), 4932 n.$nextArrow && 4933 n.$nextArrow.length && 4934 (n.$nextArrow 4935 .removeClass('slick-disabled slick-arrow slick-hidden') 4936 .removeAttr('aria-hidden aria-disabled tabindex') 4937 .css('display', ''), 4938 n.htmlExpr.test(n.options.nextArrow) && n.$nextArrow.remove()), 4939 n.$slides && 4940 (n.$slides 4941 .removeClass('slick-slide slick-active slick-center slick-visible slick-current') 4942 .removeAttr('aria-hidden') 4943 .removeAttr('data-slick-index') 4944 .each(function () { 4945 e(this).attr('style', e(this).data('originalStyling')) 4946 }), 4947 n.$slideTrack.children(this.options.slide).detach(), 4948 n.$slideTrack.detach(), 4949 n.$list.detach(), 4950 n.$slider.append(n.$slides)), 4951 n.cleanUpRows(), 4952 n.$slider.removeClass('slick-slider'), 4953 n.$slider.removeClass('slick-initialized'), 4954 n.$slider.removeClass('slick-dotted'), 4955 (n.unslicked = !0), 4956 t || n.$slider.trigger('destroy', [n]) 4957 }), 4958 (n.prototype.disableTransition = function (e) { 4959 var t = this, 4960 n = {} 4961 ;(n[t.transitionType] = ''), !1 === t.options.fade ? t.$slideTrack.css(n) : t.$slides.eq(e).css(n) 4962 }), 4963 (n.prototype.fadeSlide = function (e, t) { 4964 var n = this 4965 !1 === n.cssTransitions 4966 ? (n.$slides.eq(e).css({ 4967 zIndex: n.options.zIndex, 4968 }), 4969 n.$slides.eq(e).animate( 4970 { 4971 opacity: 1, 4972 }, 4973 n.options.speed, 4974 n.options.easing, 4975 t 4976 )) 4977 : (n.applyTransition(e), 4978 n.$slides.eq(e).css({ 4979 opacity: 1, 4980 zIndex: n.options.zIndex, 4981 }), 4982 t && 4983 setTimeout(function () { 4984 n.disableTransition(e), t.call() 4985 }, n.options.speed)) 4986 }), 4987 (n.prototype.fadeSlideOut = function (e) { 4988 var t = this 4989 !1 === t.cssTransitions 4990 ? t.$slides.eq(e).animate( 4991 { 4992 opacity: 0, 4993 zIndex: t.options.zIndex - 2, 4994 }, 4995 t.options.speed, 4996 t.options.easing 4997 ) 4998 : (t.applyTransition(e), 4999 t.$slides.eq(e).css({ 5000 opacity: 0, 5001 zIndex: t.options.zIndex - 2, 5002 })) 5003 }),
5004 (n.prototype.filterSlides = n.prototype.slickFilter = 5005 function (e) { 5006 var t = this 5007 null !== e && 5008 ((t.$slidesCache = t.$slides), 5009 t.unload(), 5010 t.$slideTrack.children(this.options.slide).detach(), 5011 t.$slidesCache.filter(e).appendTo(t.$slideTrack), 5012 t.reinit()) 5013 }), 5014 (n.prototype.focusHandler = function () { 5015 var t = this 5016 t.$slider 5017 .off('focus.slick blur.slick') 5018 .on('focus.slick', '*', function (n) { 5019 var i = e(this) 5020 setTimeout(function () { 5021 t.options.pauseOnFocus && i.is(':focus') && ((t.focussed = !0), t.autoPlay()) 5022 }, 0) 5023 }) 5024 .on('blur.slick', '*', function (n) { 5025 e(this) 5026 t.options.pauseOnFocus && ((t.focussed = !1), t.autoPlay()) 5027 }) 5028 }), 5029 (n.prototype.getCurrent = n.prototype.slickCurrentSlide = 5030 function () { 5031 return this.currentSlide 5032 }), 5033 (n.prototype.getDotCount = function () { 5034 var e = this, 5035 t = 0, 5036 n = 0, 5037 i = 0 5038 if (!0 === e.options.infinite) 5039 if (e.slideCount <= e.options.slidesToShow) ++i 5040 else 5041 for (; t < e.slideCount; ) 5042 ++i, 5043 (t = n + e.options.slidesToScroll), 5044 (n += 5045 e.options.slidesToScroll <= e.options.slidesToShow 5046 ? e.options.slidesToScroll 5047 : e.options.slidesToShow) 5048 else if (!0 === e.options.centerMode) i = e.slideCount 5049 else if (e.options.asNavFor) 5050 for (; t < e.slideCount; ) 5051 ++i, 5052 (t = n + e.options.slidesToScroll), 5053 (n += 5054 e.options.slidesToScroll <= e.options.slidesToShow ? e.options.slidesToScroll : e.options.slidesToShow) 5055 else i = 1 + Math.ceil((e.slideCount - e.options.slidesToShow) / e.options.slidesToScroll) 5056 return i - 1 5057 }), 5058 (n.prototype.getLeft = function (e) { 5059 var t, 5060 n, 5061 i, 5062 o, 5063 s = this, 5064 a = 0 5065 return ( 5066 (s.slideOffset = 0), 5067 (n = s.$slides.first().outerHeight(!0)), 5068 !0 === s.options.infinite 5069 ? (s.slideCount > s.options.slidesToShow && 5070 ((s.slideOffset = s.slideWidth * s.options.slidesToShow * -1), 5071 (o = -1), 5072 !0 === s.options.vertical && 5073 !0 === s.options.centerMode && 5074 (2 === s.options.slidesToShow ? (o = -1.5) : 1 === s.options.slidesToShow && (o = -2)), 5075 (a = n * s.options.slidesToShow * o)), 5076 s.slideCount % s.options.slidesToScroll != 0 && 5077 e + s.options.slidesToScroll > s.slideCount && 5078 s.slideCount > s.options.slidesToShow && 5079 (e > s.slideCount 5080 ? ((s.slideOffset = (s.options.slidesToShow - (e - s.slideCount)) * s.slideWidth * -1), 5081 (a = (s.options.slidesToShow - (e - s.slideCount)) * n * -1)) 5082 : ((s.slideOffset = (s.slideCount % s.options.slidesToScroll) * s.slideWidth * -1), 5083 (a = (s.slideCount % s.options.slidesToScroll) * n * -1)))) 5084 : e + s.options.slidesToShow > s.slideCount && 5085 ((s.slideOffset = (e + s.options.slidesToShow - s.slideCount) * s.slideWidth), 5086 (a = (e + s.options.slidesToShow - s.slideCount) * n)), 5087 s.slideCount <= s.options.slidesToShow && ((s.slideOffset = 0), (a = 0)), 5088 !0 === s.options.centerMode && s.slideCount <= s.options.slidesToShow 5089 ? (s.slideOffset = 5090 (s.slideWidth * Math.floor(s.options.slidesToShow)) / 2 - (s.slideWidth * s.slideCount) / 2) 5091 : !0 === s.options.centerMode && !0 === s.options.infinite 5092 ? (s.slideOffset += s.slideWidth * Math.floor(s.options.slidesToShow / 2) - s.slideWidth) 5093 : !0 === s.options.centerMode && 5094 ((s.slideOffset = 0), (s.slideOffset += s.slideWidth * Math.floor(s.options.slidesToShow / 2))), 5095 (t = !1 === s.options.vertical ? e * s.slideWidth * -1 + s.slideOffset : e * n * -1 + a), 5096 !0 === s.options.variableWidth && 5097 ((i = 5098 s.slideCount <= s.options.slidesToShow || !1 === s.options.infinite 5099 ? s.$slideTrack.children('.slick-slide').eq(e) 5100 : s.$slideTrack.children('.slick-slide').eq(e + s.options.slidesToShow)), 5101 (t = 5102 !0 === s.options.rtl 5103 ? i[0] 5104 ? -1 * (s.$slideTrack.width() - i[0].offsetLeft - i.width()) 5105 : 0 5106 : i[0] 5107 ? -1 * i[0].offsetLeft 5108 : 0), 5109 !0 === s.options.centerMode && 5110 ((i = 5111 s.slideCount <= s.options.slidesToShow || !1 === s.options.infinite 5112 ? s.$slideTrack.children('.slick-slide').eq(e) 5113 : s.$slideTrack.children('.slick-slide').eq(e + s.options.slidesToShow + 1)), 5114 (t = 5115 !0 === s.options.rtl 5116 ? i[0] 5117 ? -1 * (s.$slideTrack.width() - i[0].offsetLeft - i.width()) 5118 : 0 5119 : i[0] 5120 ? -1 * i[0].offsetLeft 5121 : 0), 5122 (t += (s.$list.width() - i.outerWidth()) / 2))), 5123 t 5124 ) 5125 }), 5126 (n.prototype.getOption = n.prototype.slickGetOption = 5127 function (e) { 5128 return this.options[e] 5129 }), 5130 (n.prototype.getNavigableIndexes = function () { 5131 var e, 5132 t = this, 5133 n = 0, 5134 i = 0, 5135 o = [] 5136 for ( 5137 !1 === t.options.infinite 5138 ? (e = t.slideCount) 5139 : ((n = -1 * t.options.slidesToScroll), (i = -1 * t.options.slidesToScroll), (e = 2 * t.slideCount)); 5140 n < e; 5141 5142 ) 5143 o.push(n), 5144 (n = i + t.options.slidesToScroll), 5145 (i += 5146 t.options.slidesToScroll <= t.options.slidesToShow ? t.options.slidesToScroll : t.options.slidesToShow) 5147 return o 5148 }), 5149 (n.prototype.getSlick = function () { 5150 return this 5151 }), 5152 (n.prototype.getSlideCount = function () { 5153 var t, 5154 n, 5155 i, 5156 o = this 5157 return ( 5158 (i = !0 === o.options.centerMode ? Math.floor(o.$list.width() / 2) : 0), 5159 (n = -1 * o.swipeLeft + i), 5160 !0 === o.options.swipeToSlide 5161 ? (o.$slideTrack.find('.slick-slide').each(function (i, s) { 5162 var a, r 5163 if ( 5164 ((a = e(s).outerWidth()), (r = s.offsetLeft), !0 !== o.options.centerMode && (r += a / 2), n < r + a) 5165 ) 5166 return (t = s), !1 5167 }), 5168 Math.abs(e(t).attr('data-slick-index') - o.currentSlide) || 1) 5169 : o.options.slidesToScroll 5170 ) 5171 }), 5172 (n.prototype.goTo = n.prototype.slickGoTo = 5173 function (e, t) { 5174 this.changeSlide( 5175 { 5176 data: { 5177 message: 'index', 5178 index: parseInt(e), 5179 }, 5180 }, 5181 t 5182 ) 5183 }), 5184 (n.prototype.init = function (t) { 5185 var n = this 5186 e(n.$slider).hasClass('slick-initialized') || 5187 (e(n.$slider).addClass('slick-initialized'), 5188 n.buildRows(), 5189 n.buildOut(), 5190 n.setProps(), 5191 n.startLoad(), 5192 n.loadSlider(), 5193 n.initializeEvents(), 5194 n.updateArrows(), 5195 n.updateDots(), 5196 n.checkResponsive(!0), 5197 n.focusHandler()), 5198 t && n.$slider.trigger('init', [n]), 5199 !0 === n.options.accessibility && n.initADA(), 5200 n.options.autoplay && ((n.paused = !1), n.autoPlay()) 5201 }), 5202 (n.prototype.initADA = function () { 5203 var t = this, 5204 n = Math.ceil(t.slideCount / t.options.slidesToShow), 5205 i = t.getNavigableIndexes().filter(function (e) { 5206 return e >= 0 && e < t.slideCount 5207 }) 5208 t.$slides 5209 .add(t.$slideTrack.find('.slick-cloned')) 5210 .attr({ 5211 'aria-hidden': 'true', 5212 tabindex: '-1', 5213 }) 5214 .find('a, input, button, select') 5215 .attr({ 5216 tabindex: '-1', 5217 }), 5218 null !== t.$dots && 5219 (t.$slides.not(t.$slideTrack.find('.slick-cloned')).each(function (n) { 5220 var o = i.indexOf(n) 5221 if ( 5222 (e(this).attr({ 5223 role: 'tabpanel', 5224 id: 'slick-slide' + t.instanceUid + n, 5225 tabindex: -1, 5226 }), 5227 -1 !== o) 5228 ) { 5229 var s = 'slick-slide-control' + t.instanceUid + o
5230 e('#' + s).length && 5231 e(this).attr({ 5232 'aria-describedby': s, 5233 }) 5234 } 5235 }), 5236 t.$dots 5237 .attr('role', 'tablist') 5238 .find('li') 5239 .each(function (o) { 5240 var s = i[o] 5241 e(this).attr({ 5242 role: 'presentation', 5243 }), 5244 e(this) 5245 .find('button') 5246 .first() 5247 .attr({ 5248 role: 'tab', 5249 id: 'slick-slide-control' + t.instanceUid + o, 5250 'aria-controls': 'slick-slide' + t.instanceUid + s, 5251 'aria-label': o + 1 + ' of ' + n, 5252 'aria-selected': null, 5253 tabindex: '-1', 5254 }) 5255 }) 5256 .eq(t.currentSlide) 5257 .find('button') 5258 .attr({ 5259 'aria-selected': 'true', 5260 tabindex: '0', 5261 }) 5262 .end()) 5263 for (var o = t.currentSlide, s = o + t.options.slidesToShow; o < s; o++) 5264 t.options.focusOnChange 5265 ? t.$slides.eq(o).attr({ 5266 tabindex: '0', 5267 }) 5268 : t.$slides.eq(o).removeAttr('tabindex') 5269 t.activateADA() 5270 }), 5271 (n.prototype.initArrowEvents = function () { 5272 var e = this 5273 !0 === e.options.arrows && 5274 e.slideCount > e.options.slidesToShow && 5275 (e.$prevArrow.off('click.slick').on( 5276 'click.slick', 5277 { 5278 message: 'previous', 5279 }, 5280 e.changeSlide 5281 ), 5282 e.$nextArrow.off('click.slick').on( 5283 'click.slick', 5284 { 5285 message: 'next', 5286 }, 5287 e.changeSlide 5288 ), 5289 !0 === e.options.accessibility && 5290 (e.$prevArrow.on('keydown.slick', e.keyHandler), e.$nextArrow.on('keydown.slick', e.keyHandler))) 5291 }), 5292 (n.prototype.initDotEvents = function () { 5293 var t = this 5294 !0 === t.options.dots && 5295 t.slideCount > t.options.slidesToShow && 5296 (e('li', t.$dots).on( 5297 'click.slick', 5298 { 5299 message: 'index', 5300 }, 5301 t.changeSlide 5302 ), 5303 !0 === t.options.accessibility && t.$dots.on('keydown.slick', t.keyHandler)), 5304 !0 === t.options.dots && 5305 !0 === t.options.pauseOnDotsHover && 5306 t.slideCount > t.options.slidesToShow && 5307 e('li', t.$dots) 5308 .on('mouseenter.slick', e.proxy(t.interrupt, t, !0)) 5309 .on('mouseleave.slick', e.proxy(t.interrupt, t, !1)) 5310 }), 5311 (n.prototype.initSlideEvents = function () { 5312 var t = this 5313 t.options.pauseOnHover && 5314 (t.$list.on('mouseenter.slick', e.proxy(t.interrupt, t, !0)), 5315 t.$list.on('mouseleave.slick', e.proxy(t.interrupt, t, !1))) 5316 }), 5317 (n.prototype.initializeEvents = function () { 5318 var t = this 5319 t.initArrowEvents(), 5320 t.initDotEvents(), 5321 t.initSlideEvents(), 5322 t.$list.on( 5323 'touchstart.slick mousedown.slick', 5324 { 5325 action: 'start', 5326 }, 5327 t.swipeHandler 5328 ), 5329 t.$list.on( 5330 'touchmove.slick mousemove.slick', 5331 { 5332 action: 'move', 5333 }, 5334 t.swipeHandler 5335 ), 5336 t.$list.on( 5337 'touchend.slick mouseup.slick', 5338 { 5339 action: 'end', 5340 }, 5341 t.swipeHandler 5342 ), 5343 t.$list.on(
5344 'touchcancel.slick mouseleave.slick', 5345 { 5346 action: 'end', 5347 }, 5348 t.swipeHandler 5349 ), 5350 t.$list.on('click.slick', t.clickHandler), 5351 e(document).on(t.visibilityChange, e.proxy(t.visibility, t)), 5352 !0 === t.options.accessibility && t.$list.on('keydown.slick', t.keyHandler), 5353 !0 === t.options.focusOnSelect && e(t.$slideTrack).children().on('click.slick', t.selectHandler), 5354 e(window).on('orientationchange.slick.slick-' + t.instanceUid, e.proxy(t.orientationChange, t)), 5355 e(window).on('resize.slick.slick-' + t.instanceUid, e.proxy(t.resize, t)), 5356 e('[draggable!=true]', t.$slideTrack).on('dragstart', t.preventDefault), 5357 e(window).on('load.slick.slick-' + t.instanceUid, t.setPosition), 5358 e(t.setPosition) 5359 }), 5360 (n.prototype.initUI = function () { 5361 var e = this 5362 !0 === e.options.arrows && e.slideCount > e.options.slidesToShow && (e.$prevArrow.show(), e.$nextArrow.show()), 5363 !0 === e.options.dots && e.slideCount > e.options.slidesToShow && e.$dots.show() 5364 }), 5365 (n.prototype.keyHandler = function (e) { 5366 var t = this 5367 e.target.tagName.match('TEXTAREA|INPUT|SELECT') || 5368 (37 === e.keyCode && !0 === t.options.accessibility 5369 ? t.changeSlide({ 5370 data: { 5371 message: !0 === t.options.rtl ? 'next' : 'previous', 5372 }, 5373 }) 5374 : 39 === e.keyCode && 5375 !0 === t.options.accessibility && 5376 t.changeSlide({ 5377 data: { 5378 message: !0 === t.options.rtl ? 'previous' : 'next', 5379 }, 5380 })) 5381 }), 5382 (n.prototype.lazyLoad = function () { 5383 var t, 5384 n, 5385 i, 5386 o = this 5387 function s(t) { 5388 e('img[data-lazy]', t).each(function () { 5389 var t = e(this), 5390 n = e(this).attr('data-lazy'), 5391 i = e(this).attr('data-srcset'), 5392 s = e(this).attr('data-sizes') || o.$slider.attr('data-sizes'), 5393 a = document.createElement('img') 5394 ;(a.onload = function () { 5395 t.animate( 5396 { 5397 opacity: 0, 5398 }, 5399 100, 5400 function () { 5401 i && (t.attr('srcset', i), s && t.attr('sizes', s)), 5402 t.attr('src', n).animate( 5403 { 5404 opacity: 1, 5405 }, 5406 200, 5407 function () { 5408 t.removeAttr('data-lazy data-srcset data-sizes').removeClass('slick-loading') 5409 } 5410 ), 5411 o.$slider.trigger('lazyLoaded', [o, t, n]) 5412 } 5413 ) 5414 }), 5415 (a.onerror = function () { 5416 t.removeAttr('data-lazy').removeClass('slick-loading').addClass('slick-lazyload-error'), 5417 o.$slider.trigger('lazyLoadError', [o, t, n]) 5418 }), 5419 (a.src = n) 5420 }) 5421 } 5422 if ( 5423 (!0 === o.options.centerMode 5424 ? !0 === o.options.infinite 5425 ? (i = (n = o.currentSlide + (o.options.slidesToShow / 2 + 1)) + o.options.slidesToShow + 2) 5426 : ((n = Math.max(0, o.currentSlide - (o.options.slidesToShow / 2 + 1))), 5427 (i = o.options.slidesToShow / 2 + 1 + 2 + o.currentSlide)) 5428 : ((n = o.options.infinite ? o.options.slidesToShow + o.currentSlide : o.currentSlide), 5429 (i = Math.ceil(n + o.options.slidesToShow)), 5430 !0 === o.options.fade && (n > 0 && n--, i <= o.slideCount && i++)), 5431 (t = o.$slider.find('.slick-slide').slice(n, i)), 5432 'anticipated' === o.options.lazyLoad) 5433 ) 5434 for (var a = n - 1, r = i, c = o.$slider.find('.slick-slide'), u = 0; u < o.options.slidesToScroll; u++) 5435 a < 0 && (a = o.slideCount - 1), (t = (t = t.add(c.eq(a))).add(c.eq(r))), a--, r++ 5436 s(t), 5437 o.slideCount <= o.options.slidesToShow 5438 ? s(o.$slider.find('.slick-slide')) 5439 : o.currentSlide >= o.slideCount - o.options.slidesToShow 5440 ? s(o.$slider.find('.slick-cloned').slice(0, o.options.slidesToShow)) 5441 : 0 === o.currentSlide && s(o.$slider.find('.slick-cloned').slice(-1 * o.options.slidesToShow)) 5442 }), 5443 (n.prototype.loadSlider = function () { 5444 var e = this 5445 e.setPosition(), 5446 e.$slideTrack.css({ 5447 opacity: 1, 5448 }), 5449 e.$slider.removeClass('slick-loading'), 5450 e.initUI(), 5451 'progressive' === e.options.lazyLoad && e.progressiveLazyLoad() 5452 }), 5453 (n.prototype.next = n.prototype.slickNext = 5454 function () { 5455 this.changeSlide({ 5456 data: { 5457 message: 'next', 5458 }, 5459 }) 5460 }), 5461 (n.prototype.orientationChange = function () { 5462 this.checkResponsive(), this.setPosition() 5463 }), 5464 (n.prototype.pause = n.prototype.slickPause = 5465 function () { 5466 this.autoPlayClear(), (this.paused = !0) 5467 }), 5468 (n.prototype.play = n.prototype.slickPlay = 5469 function () { 5470 var e = this 5471 e.autoPlay(), (e.options.autoplay = !0), (e.paused = !1), (e.focussed = !1), (e.interrupted = !1) 5472 }), 5473 (n.prototype.postSlide = function (t) { 5474 var n = this 5475 n.unslicked || 5476 (n.$slider.trigger('afterChange', [n, t]), 5477 (n.animating = !1), 5478 n.slideCount > n.options.slidesToShow && n.setPosition(), 5479 (n.swipeLeft = null), 5480 n.options.autoplay && n.autoPlay(), 5481 !0 === n.options.accessibility && 5482 (n.initADA(), n.options.focusOnChange && e(n.$slides.get(n.currentSlide)).attr('tabindex', 0).focus())) 5483 }), 5484 (n.prototype.prev = n.prototype.slickPrev = 5485 function () { 5486 this.changeSlide({ 5487 data: { 5488 message: 'previous', 5489 }, 5490 }) 5491 }), 5492 (n.prototype.preventDefault = function (e) { 5493 e.preventDefault() 5494 }), 5495 (n.prototype.progressiveLazyLoad = function (t) { 5496 t = t || 1 5497 var n, 5498 i, 5499 o, 5500 s, 5501 a, 5502 r = this, 5503 c = e('img[data-lazy]', r.$slider) 5504 c.length 5505 ? ((n = c.first()), 5506 (i = n.attr('data-lazy')), 5507 (o = n.attr('data-srcset')), 5508 (s = n.attr('data-sizes') || r.$slider.attr('data-sizes')), 5509 ((a = document.createElement('img')).onload = function () { 5510 o && (n.attr('srcset', o), s && n.attr('sizes', s)), 5511 n.attr('src', i).removeAttr('data-lazy data-srcset data-sizes').removeClass('slick-loading'), 5512 !0 === r.options.adaptiveHeight && r.setPosition(), 5513 r.$slider.trigger('lazyLoaded', [r, n, i]), 5514 r.progressiveLazyLoad() 5515 }), 5516 (a.onerror = function () { 5517 t < 3 5518 ? setTimeout(function () { 5519 r.progressiveLazyLoad(t + 1) 5520 }, 500) 5521 : (n.removeAttr('data-lazy').removeClass('slick-loading').addClass('slick-lazyload-error'), 5522 r.$slider.trigger('lazyLoadError', [r, n, i]), 5523 r.progressiveLazyLoad()) 5524 }), 5525 (a.src = i)) 5526 : r.$slider.trigger('allImagesLoaded', [r]) 5527 }), 5528 (n.prototype.refresh = function (t) { 5529 var n, 5530 i, 5531 o = this 5532 ;(i = o.slideCount - o.options.slidesToShow), 5533 !o.options.infinite && o.currentSlide > i && (o.currentSlide = i),
5534 o.slideCount <= o.options.slidesToShow && (o.currentSlide = 0), 5535 (n = o.currentSlide), 5536 o.destroy(!0), 5537 e.extend(o, o.initials, { 5538 currentSlide: n, 5539 }), 5540 o.init(), 5541 t || 5542 o.changeSlide( 5543 { 5544 data: { 5545 message: 'index', 5546 index: n, 5547 }, 5548 }, 5549 !1 5550 ) 5551 }), 5552 (n.prototype.registerBreakpoints = function () { 5553 var t, 5554 n, 5555 i, 5556 o = this, 5557 s = o.options.responsive || null 5558 if ('array' === e.type(s) && s.length) { 5559 for (t in ((o.respondTo = o.options.respondTo || 'window'), s)) 5560 if (((i = o.breakpoints.length - 1), s.hasOwnProperty(t))) { 5561 for (n = s[t].breakpoint; i >= 0; ) 5562 o.breakpoints[i] && o.breakpoints[i] === n && o.breakpoints.splice(i, 1), i-- 5563 o.breakpoints.push(n), (o.breakpointSettings[n] = s[t].settings) 5564 } 5565 o.breakpoints.sort(function (e, t) { 5566 return o.options.mobileFirst ? e - t : t - e 5567 }) 5568 } 5569 }), 5570 (n.prototype.reinit = function () { 5571 var t = this 5572 ;(t.$slides = t.$slideTrack.children(t.options.slide).addClass('slick-slide')), 5573 (t.slideCount = t.$slides.length), 5574 t.currentSlide >= t.slideCount && 5575 0 !== t.currentSlide && 5576 (t.currentSlide = t.currentSlide - t.options.slidesToScroll), 5577 t.slideCount <= t.options.slidesToShow && (t.currentSlide = 0), 5578 t.registerBreakpoints(), 5579 t.setProps(), 5580 t.setupInfinite(), 5581 t.buildArrows(), 5582 t.updateArrows(), 5583 t.initArrowEvents(), 5584 t.buildDots(), 5585 t.updateDots(), 5586 t.initDotEvents(), 5587 t.cleanUpSlideEvents(), 5588 t.initSlideEvents(), 5589 t.checkResponsive(!1, !0), 5590 !0 === t.options.focusOnSelect && e(t.$slideTrack).children().on('click.slick', t.selectHandler), 5591 t.setSlideClasses('number' == typeof t.currentSlide ? t.currentSlide : 0), 5592 t.setPosition(), 5593 t.focusHandler(), 5594 (t.paused = !t.options.autoplay), 5595 t.autoPlay(), 5596 t.$slider.trigger('reInit', [t]) 5597 }), 5598 (n.prototype.resize = function () { 5599 var t = this 5600 e(window).width() !== t.windowWidth && 5601 (clearTimeout(t.windowDelay), 5602 (t.windowDelay = window.setTimeout(function () { 5603 ;(t.windowWidth = e(window).width()), t.checkResponsive(), t.unslicked || t.setPosition() 5604 }, 50))) 5605 }), 5606 (n.prototype.removeSlide = n.prototype.slickRemove = 5607 function (e, t, n) { 5608 var i = this 5609 if ( 5610 ((e = 'boolean' == typeof e ? (!0 === (t = e) ? 0 : i.slideCount - 1) : !0 === t ? --e : e), 5611 i.slideCount < 1 || e < 0 || e > i.slideCount - 1) 5612 ) 5613 return !1 5614 i.unload(), 5615 !0 === n ? i.$slideTrack.children().remove() : i.$slideTrack.children(this.options.slide).eq(e).remove(), 5616 (i.$slides = i.$slideTrack.children(this.options.slide)), 5617 i.$slideTrack.children(this.options.slide).detach(), 5618 i.$slideTrack.append(i.$slides), 5619 (i.$slidesCache = i.$slides), 5620 i.reinit() 5621 }), 5622 (n.prototype.setCSS = function (e) { 5623 var t, 5624 n, 5625 i = this, 5626 o = {} 5627 !0 === i.options.rtl && (e = -e), 5628 (t = 'left' == i.positionProp ? Math.ceil(e) + 'px' : '0px'), 5629 (n = 'top' == i.positionProp ? Math.ceil(e) + 'px' : '0px'), 5630 (o[i.positionProp] = e), 5631 !1 === i.transformsEnabled 5632 ? i.$slideTrack.css(o) 5633 : ((o = {}), 5634 !1 === i.cssTransitions 5635 ? ((o[i.animType] = 'translate(' + t + ', ' + n + ')'), i.$slideTrack.css(o)) 5636 : ((o[i.animType] = 'translate3d(' + t + ', ' + n + ', 0px)'), i.$slideTrack.css(o))) 5637 }), 5638 (n.prototype.setDimensions = function () { 5639 var e = this 5640 !1 === e.options.vertical 5641 ? !0 === e.options.centerMode && 5642 e.$list.css({ 5643 padding: '0px ' + e.options.centerPadding, 5644 }) 5645 : (e.$list.height(e.$slides.first().outerHeight(!0) * e.options.slidesToShow), 5646 !0 === e.options.centerMode && 5647 e.$list.css({ 5648 padding: e.options.centerPadding + ' 0px', 5649 })), 5650 (e.listWidth = e.$list.width()), 5651 (e.listHeight = e.$list.height()), 5652 !1 === e.options.vertical && !1 === e.options.variableWidth 5653 ? ((e.slideWidth = Math.ceil(e.listWidth / e.options.slidesToShow)), 5654 e.$slideTrack.width(Math.ceil(e.slideWidth * e.$slideTrack.children('.slick-slide').length))) 5655 : !0 === e.options.variableWidth 5656 ? e.$slideTrack.width(5e3 * e.slideCount) 5657 : ((e.slideWidth = Math.ceil(e.listWidth)), 5658 e.$slideTrack.height( 5659 Math.ceil(e.$slides.first().outerHeight(!0) * e.$slideTrack.children('.slick-slide').length) 5660 )) 5661 var t = e.$slides.first().outerWidth(!0) - e.$slides.first().width() 5662 !1 === e.options.variableWidth && e.$slideTrack.children('.slick-slide').width(e.slideWidth - t) 5663 }), 5664 (n.prototype.setFade = function () { 5665 var t, 5666 n = this 5667 n.$slides.each(function (i, o) { 5668 ;(t = n.slideWidth * i * -1), 5669 !0 === n.options.rtl 5670 ? e(o).css({ 5671 position: 'relative', 5672 right: t, 5673 top: 0, 5674 zIndex: n.options.zIndex - 2, 5675 opacity: 0, 5676 }) 5677 : e(o).css({ 5678 position: 'relative', 5679 left: t, 5680 top: 0, 5681 zIndex: n.options.zIndex - 2, 5682 opacity: 0, 5683 }) 5684 }), 5685 n.$slides.eq(n.currentSlide).css({ 5686 zIndex: n.options.zIndex - 1, 5687 opacity: 1, 5688 }) 5689 }), 5690 (n.prototype.setHeight = function () { 5691 var e = this 5692 if (1 === e.options.slidesToShow && !0 === e.options.adaptiveHeight && !1 === e.options.vertical) { 5693 var t = e.$slides.eq(e.currentSlide).outerHeight(!0) 5694 e.$list.css('height', t) 5695 } 5696 }), 5697 (n.prototype.setOption = n.prototype.slickSetOption = 5698 function () { 5699 var t, 5700 n, 5701 i, 5702 o, 5703 s, 5704 a = this, 5705 r = !1 5706 if ( 5707 ('object' === e.type(arguments[0]) 5708 ? ((i = arguments[0]), (r = arguments[1]), (s = 'multiple')) 5709 : 'string' === e.type(arguments[0]) && 5710 ((i = arguments[0]), 5711 (o = arguments[1]), 5712 (r = arguments[2]), 5713 'responsive' === arguments[0] && 'array' === e.type(arguments[1]) 5714 ? (s = 'responsive') 5715 : void 0 !== arguments[1] && (s = 'single')), 5716 'single' === s) 5717 ) 5718 a.options[i] = o 5719 else if ('multiple' === s) 5720 e.each(i, function (e, t) { 5721 a.options[e] = t 5722 }) 5723 else if ('responsive' === s) 5724 for (n in o) 5725 if ('array' !== e.type(a.options.responsive)) a.options.responsive = [o[n]] 5726 else { 5727 for (t = a.options.responsive.length - 1; t >= 0; ) 5728 a.options.responsive[t].breakpoint === o[n].breakpoint && a.options.responsive.splice(t, 1), t-- 5729 a.options.responsive.push(o[n]) 5730 } 5731 r && (a.unload(), a.reinit()) 5732 }), 5733 (n.prototype.setPosition = function () { 5734 var e = this 5735 e.setDimensions(), 5736 e.setHeight(), 5737 !1 === e.options.fade ? e.setCSS(e.getLeft(e.currentSlide)) : e.setFade(), 5738 e.$slider.trigger('setPosition', [e]) 5739 }), 5740 (n.prototype.setProps = function () { 5741 var e = this, 5742 t = document.body.style 5743 ;(e.positionProp = !0 === e.options.vertical ? 'top' : 'left'), 5744 'top' === e.positionProp ? e.$slider.addClass('slick-vertical')
5744: e.$slider.removeClass('slick-vertical'), 5745 (void 0 === t.WebkitTransition && void 0 === t.MozTransition && void 0 === t.msTransition) || 5746 (!0 === e.options.useCSS && (e.cssTransitions = !0)), 5747 e.options.fade && 5748 ('number' == typeof e.options.zIndex 5749 ? e.options.zIndex < 3 && (e.options.zIndex = 3) 5750 : (e.options.zIndex = e.defaults.zIndex)), 5751 void 0 !== t.OTransform && 5752 ((e.animType = 'OTransform'), 5753 (e.transformType = '-o-transform'), 5754 (e.transitionType = 'OTransition'), 5755 void 0 === t.perspectiveProperty && void 0 === t.webkitPerspective && (e.animType = !1)), 5756 void 0 !== t.MozTransform && 5757 ((e.animType = 'MozTransform'), 5758 (e.transformType = '-moz-transform'), 5759 (e.transitionType = 'MozTransition'), 5760 void 0 === t.perspectiveProperty && void 0 === t.MozPerspective && (e.animType = !1)), 5761 void 0 !== t.webkitTransform && 5762 ((e.animType = 'webkitTransform'), 5763 (e.transformType = '-webkit-transform'), 5764 (e.transitionType = 'webkitTransition'), 5765 void 0 === t.perspectiveProperty && void 0 === t.webkitPerspective && (e.animType = !1)), 5766 void 0 !== t.msTransform && 5767 ((e.animType = 'msTransform'), 5768 (e.transformType = '-ms-transform'), 5769 (e.transitionType = 'msTransition'), 5770 void 0 === t.msTransform && (e.animType = !1)), 5771 void 0 !== t.transform && 5772 !1 !== e.animType && 5773 ((e.animType = 'transform'), (e.transformType = 'transform'), (e.transitionType = 'transition')), 5774 (e.transformsEnabled = e.options.useTransform && null !== e.animType && !1 !== e.animType) 5775 }), 5776 (n.prototype.setSlideClasses = function (e) { 5777 var t, 5778 n, 5779 i, 5780 o, 5781 s = this 5782 if ( 5783 ((n = s.$slider 5784 .find('.slick-slide') 5785 .removeClass('slick-active slick-center slick-current') 5786 .attr('aria-hidden', 'true')), 5787 s.$slides.eq(e).addClass('slick-current'), 5788 !0 === s.options.centerMode) 5789 ) { 5790 var a = s.options.slidesToShow % 2 == 0 ? 1 : 0 5791 ;(t = Math.floor(s.options.slidesToShow / 2)), 5792 !0 === s.options.infinite && 5793 (e >= t && e <= s.slideCount - 1 - t 5794 ? s.$slides 5795 .slice(e - t + a, e + t + 1) 5796 .addClass('slick-active') 5797 .attr('aria-hidden', 'false') 5798 : ((i = s.options.slidesToShow + e), 5799 n 5800 .slice(i - t + 1 + a, i + t + 2) 5801 .addClass('slick-active') 5802 .attr('aria-hidden', 'false')), 5803 0 === e 5804 ? n.eq(s.options.slidesToShow + s.slideCount + 1).addClass('slick-center') 5805 : e === s.slideCount - 1 && n.eq(s.options.slidesToShow).addClass('slick-center')), 5806 s.$slides.eq(e).addClass('slick-center') 5807 } else 5808 e >= 0 && e <= s.slideCount - s.options.slidesToShow 5809 ? s.$slides 5810 .slice(e, e + s.options.slidesToShow) 5811 .addClass('slick-active') 5812 .attr('aria-hidden', 'false') 5813 : n.length <= s.options.slidesToShow 5814 ? n.addClass('slick-active').attr('aria-hidden', 'false') 5815 : ((o = s.slideCount % s.options.slidesToShow), 5816 (i = !0 === s.options.infinite ? s.options.slidesToShow + e : e), 5817 s.options.slidesToShow == s.options.slidesToScroll && s.slideCount - e < s.options.slidesToShow 5818 ? n 5819 .slice(i - (s.options.slidesToShow - o), i + o) 5820 .addClass('slick-active') 5821 .attr('aria-hidden', 'false') 5822 : n 5823 .slice(i, i + s.options.slidesToShow) 5824 .addClass('slick-active') 5825 .attr('aria-hidden', 'false')) 5826 ;('ondemand' !== s.options.lazyLoad && 'anticipated' !== s.options.lazyLoad) || s.lazyLoad() 5827 }), 5828 (n.prototype.setupInfinite = function () { 5829 var t, 5830 n, 5831 i, 5832 o = this 5833 if ( 5834 (!0 === o.options.fade && (o.options.centerMode = !1), 5835 !0 === o.options.infinite && !1 === o.options.fade && ((n = null), o.slideCount > o.options.slidesToShow)) 5836 ) { 5837 for ( 5838 i = !0 === o.options.centerMode ? o.options.slidesToShow + 1 : o.options.slidesToShow, t = o.slideCount; 5839 t > o.slideCount - i; 5840 t -= 1 5841 ) 5842 (n = t - 1), 5843 e(o.$slides[n]) 5844 .clone(!0) 5845 .attr('id', '') 5846 .attr('data-slick-index', n - o.slideCount) 5847 .prependTo(o.$slideTrack) 5848 .addClass('slick-cloned') 5849 for (t = 0; t < i + o.slideCount; t += 1) 5850 (n = t), 5851 e(o.$slides[n]) 5852 .clone(!0) 5853 .attr('id', '') 5854 .attr('data-slick-index', n + o.slideCount) 5855 .appendTo(o.$slideTrack) 5856 .addClass('slick-cloned') 5857 o.$slideTrack 5858 .find('.slick-cloned') 5859 .find('[id]') 5860 .each(function () { 5861 e(this).attr('id', '') 5862 }) 5863 } 5864 }), 5865 (n.prototype.interrupt = function (e) { 5866 e || this.autoPlay(), (this.interrupted = e) 5867 }), 5868 (n.prototype.selectHandler = function (t) { 5869 var n = this, 5870 i = e(t.target).is('.slick-slide') ? e(t.target) : e(t.target).parents('.slick-slide'), 5871 o = parseInt(i.attr('data-slick-index')) 5872 o || (o = 0), n.slideCount <= n.options.slidesToShow ? n.slideHandler(o, !1, !0) : n.slideHandler(o) 5873 }), 5874 (n.prototype.slideHandler = function (e, t, n) { 5875 var i, 5876 o, 5877 s, 5878 a, 5879 r, 5880 c, 5881 u = this 5882 if ( 5883 ((t = t || !1), 5884 !((!0 === u.animating && !0 === u.options.waitForAnimate) || (!0 === u.options.fade && u.currentSlide === e))) 5885 ) 5886 if ( 5887 (!1 === t && u.asNavFor(e), 5888 (i = e), 5889 (r = u.getLeft(i)), 5890 (a = u.getLeft(u.currentSlide)), 5891 (u.currentLeft = null === u.swipeLeft ? a : u.swipeLeft), 5892 !1 === u.options.infinite && 5893 !1 === u.options.centerMode && 5894 (e < 0 || e > u.getDotCount() * u.options.slidesToScroll)) 5895 ) 5896 !1 === u.options.fade && 5897 ((i = u.currentSlide), 5898 !0 !== n && u.slideCount > u.options.slidesToShow 5899 ? u.animateSlide(a, function () { 5900 u.postSlide(i) 5901 }) 5902 : u.postSlide(i)) 5903 else if ( 5904 !1 === u.options.infinite && 5905 !0 === u.options.centerMode && 5906 (e < 0 || e > u.slideCount - u.options.slidesToScroll) 5907 ) 5908 !1 === u.options.fade && 5909 ((i = u.currentSlide), 5910 !0 !== n && u.slideCount > u.options.slidesToShow 5911 ? u.animateSlide(a, function () { 5912 u.postSlide(i) 5913 }) 5914 : u.postSlide(i)) 5915 else { 5916 if ( 5917 (u.options.autoplay && clearInterval(u.autoPlayTimer), 5918 (o = 5919 i < 0 5920 ? u.slideCount % u.options.slidesToScroll != 0 5921 ? u.slideCount - (u.slideCount % u.options.slidesToScroll) 5922 : u.slideCount + i 5923 : i >= u.slideCount 5924 ? u.slideCount % u.options.slidesToScroll != 0 5925 ? 0 5926 : i - u.slideCount 5927 : i), 5928 (u.animating = !0), 5929 u.$slider.trigger('beforeChange', [u, u.currentSlide, o]), 5930 (s = u.currentSlide), 5931 (u.currentSlide = o), 5932 u.setSlideClasses(u.currentSlide), 5933 u.options.asNavFor && 5934 (c = (c = u.getNavTarget()).slick('getSlick')).slideCount <= c.options.slidesToShow && 5935 c.setSlideClasses(u.currentSlide), 5936 u.updateDots(), 5937 u.updateArrows(), 5938 !0 === u.options.fade) 5939 ) 5940 return ( 5941 !0 !== n 5942 ? (u.fadeSlideOut(s), 5943 u.fadeSlide(o, function () { 5944 u.postSlide(o) 5945 })) 5946 : u.postSlide(o), 5947 void u.animateHeight() 5948 ) 5949 !0 !== n && u.slideCount > u.options.slidesToShow 5950 ? u.animateSlide(r, function () { 5951 u.postSlide(o) 5952 }) 5953 : u.postSlide(o) 5954 } 5955 }), 5956 (n.prototype.startLoad = function () { 5957 var e = this 5958 !0 === e.options.arrows && e.slideCount > e.options.slidesToShow && (e.$prevArrow.hide(), e.$nextArrow.hide()), 5959 !0 === e.options.dots && e.slideCount > e.options.slidesToShow && e.$dots.hide(), 5960 e.$slider.addClass('slick-loading') 5961 }), 5962 (n.prototype.swipeDirection = function () { 5963 var e, 5964 t, 5965 n, 5966 i, 5967 o = this 5968 return ( 5969 (e = o.touchObject.startX - o.touchObject.curX), 5970 (t = o.touchObject.startY - o.touchObject.curY), 5971 (n = Math.atan2(t, e)), 5972 (i = Math.round((180 * n) / Math.PI)) < 0 && (i = 360 - Math.abs(i)), 5973 (i <= 45 && i >= 0) || (i <= 360 && i >= 315) 5974 ? !1 === o.options.rtl 5975 ? 'left' 5976 : 'right' 5977 : i >= 135 && i <= 225 5978 ? !1 === o.options.rtl 5979 ? 'right' 5980 : 'left' 5981 : !0 === o.options.verticalSwiping 5982 ? i >= 35 && i <= 135 5983 ? 'down' 5984 : 'up' 5985 : 'vertical' 5986 ) 5987 }), 5988 (n.prototype.swipeEnd = function (e) { 5989 var t, 5990 n, 5991 i = this 5992 if (((i.dragging = !1), (i.swiping = !1), i.scrolling)) return (i.scrolling = !1), !1 5993 if (((i.interrupted = !1), (i.shouldClick = !(i.touchObject.swipeLength > 10)), void 0 === i.touchObject.curX)) 5994 return !1 5995 if ( 5996 (!0 === i.touchObject.edgeHit && i.$slider.trigger('edge', [i, i.swipeDirection()]), 5997 i.touchObject.swipeLength >= i.touchObject.minSwipe) 5998 ) { 5999 switch ((n = i.swipeDirection())) { 6000 case 'left': 6001 case 'down': 6002 ;(t = i.options.swipeToSlide 6003 ? i.checkNavigable(i.currentSlide + i.getSlideCount()) 6004 : i.currentSlide + i.getSlideCount()), 6005 (i.currentDirection = 0) 6006 break 6007 case 'right': 6008 case 'up': 6009 ;(t = i.options.swipeToSlide 6010 ? i.checkNavigable(i.currentSlide - i.getSlideCount()) 6011 : i.currentSlide - i.getSlideCount()), 6012 (i.currentDirection = 1) 6013 } 6014 'vertical' != n && (i.slideHandler(t), (i.touchObject = {}), i.$slider.trigger('swipe', [i, n])) 6015 } else i.touchObject.startX !== i.touchObject.curX && (i.slideHandler(i.currentSlide), (i.touchObject = {})) 6016 }), 6017 (n.prototype.swipeHandler = function (e) { 6018 var t = this 6019 if ( 6020 !( 6021 !1 === t.options.swipe || 6022 ('ontouchend' in document && !1 === t.options.swipe) || 6023 (!1 === t.options.draggable && -1 !== e.type.indexOf('mouse')) 6024 ) 6025 ) 6026 switch ( 6027 ((t.touchObject.fingerCount = 6028 e.originalEvent && void 0 !== e.originalEvent.touches ? e.originalEvent.touches.length : 1), 6029 (t.touchObject.minSwipe = t.listWidth / t.options.touchThreshold), 6030 !0 === t.options.verticalSwiping && (t.touchObject.minSwipe = t.listHeight / t.options.touchThreshold), 6031 e.data.action) 6032 ) { 6033 case 'start': 6034 t.swipeStart(e) 6035 break 6036 case 'move': 6037 t.swipeMove(e) 6038 break 6039 case 'end': 6040 t.swipeEnd(e) 6041 } 6042 }), 6043 (n.prototype.swipeMove = function (e) { 6044 var t, 6045 n, 6046 i, 6047 o, 6048 s, 6049 a, 6050 r = this 6051 return ( 6052 (s = void 0 !== e.originalEvent ? e.originalEvent.touches : null), 6053 !(!r.dragging || r.scrolling || (s && 1 !== s.length)) && 6054 ((t = r.getLeft(r.currentSlide)), 6055 (r.touchObject.curX = void 0 !== s ? s[0].pageX : e.clientX), 6056 (r.touchObject.curY = void 0 !== s ? s[0].pageY : e.clientY), 6057 (r.touchObject.swipeLength = Math.round(Math.sqrt(Math.pow(r.touchObject.curX - r.touchObject.startX, 2)))
6057), 6058 (a = Math.round(Math.sqrt(Math.pow(r.touchObject.curY - r.touchObject.startY, 2)))), 6059 !r.options.verticalSwiping && !r.swiping && a > 4 6060 ? ((r.scrolling = !0), !1) 6061 : (!0 === r.options.verticalSwiping && (r.touchObject.swipeLength = a), 6062 (n = r.swipeDirection()), 6063 void 0 !== e.originalEvent && r.touchObject.swipeLength > 4 && ((r.swiping = !0), e.preventDefault()), 6064 (o = (!1 === r.options.rtl ? 1 : -1) * (r.touchObject.curX > r.touchObject.startX ? 1 : -1)), 6065 !0 === r.options.verticalSwiping && (o = r.touchObject.curY > r.touchObject.startY ? 1 : -1), 6066 (i = r.touchObject.swipeLength), 6067 (r.touchObject.edgeHit = !1), 6068 !1 === r.options.infinite && 6069 ((0 === r.currentSlide && 'right' === n) || (r.currentSlide >= r.getDotCount() && 'left' === n)) && 6070 ((i = r.touchObject.swipeLength * r.options.edgeFriction), (r.touchObject.edgeHit = !0)), 6071 !1 === r.options.vertical 6072 ? (r.swipeLeft = t + i * o) 6073 : (r.swipeLeft = t + i * (r.$list.height() / r.listWidth) * o), 6074 !0 === r.options.verticalSwiping && (r.swipeLeft = t + i * o), 6075 !0 !== r.options.fade && 6076 !1 !== r.options.touchMove && 6077 (!0 === r.animating ? ((r.swipeLeft = null), !1) : void r.setCSS(r.swipeLeft)))) 6078 ) 6079 }), 6080 (n.prototype.swipeStart = function (e) { 6081 var t, 6082 n = this 6083 if (((n.interrupted = !0), 1 !== n.touchObject.fingerCount || n.slideCount <= n.options.slidesToShow)) 6084 return (n.touchObject = {}), !1 6085 void 0 !== e.originalEvent && void 0 !== e.originalEvent.touches && (t = e.originalEvent.touches[0]), 6086 (n.touchObject.startX = n.touchObject.curX = void 0 !== t ? t.pageX : e.clientX), 6087 (n.touchObject.startY = n.touchObject.curY = void 0 !== t ? t.pageY : e.clientY), 6088 (n.dragging = !0) 6089 }), 6090 (n.prototype.unfilterSlides = n.prototype.slickUnfilter = 6091 function () { 6092 var e = this 6093 null !== e.$slidesCache && 6094 (e.unload(), 6095 e.$slideTrack.children(this.options.slide).detach(), 6096 e.$slidesCache.appendTo(e.$slideTrack), 6097 e.reinit()) 6098 }), 6099 (n.prototype.unload = function () { 6100 var t = this 6101 e('.slick-cloned', t.$slider).remove(), 6102 t.$dots && t.$dots.remove(), 6103 t.$prevArrow && t.htmlExpr.test(t.options.prevArrow) && t.$prevArrow.remove(), 6104 t.$nextArrow && t.htmlExpr.test(t.options.nextArrow) && t.$nextArrow.remove(), 6105 t.$slides 6106 .removeClass('slick-slide slick-active slick-visible slick-current') 6107 .attr('aria-hidden', 'true') 6108 .css('width', '') 6109 }), 6110 (n.prototype.unslick = function (e) { 6111 var t = this 6112 t.$slider.trigger('unslick', [t, e]), t.destroy() 6113 }), 6114 (n.prototype.updateArrows = function () { 6115 var e = this 6116 Math.floor(e.options.slidesToShow / 2), 6117 !0 === e.options.arrows && 6118 e.slideCount > e.options.slidesToShow && 6119 !e.options.infinite && 6120 (e.$prevArrow.removeClass('slick-disabled').attr('aria-disabled', 'false'), 6121 e.$nextArrow.removeClass('slick-disabled').attr('aria-disabled', 'false'), 6122 0 === e.currentSlide 6123 ? (e.$prevArrow.addClass('slick-disabled').attr('aria-disabled', 'true'), 6124 e.$nextArrow.removeClass('slick-disabled').attr('aria-disabled', 'false')) 6125 : ((e.currentSlide >= e.slideCount - e.options.slidesToShow && !1 === e.options.centerMode) || 6126 (e.currentSlide >= e.slideCount - 1 && !0 === e.options.centerMode)) && 6127 (e.$nextArrow.addClass('slick-disabled').attr('aria-disabled', 'true'), 6128 e.$prevArrow.removeClass('slick-disabled').attr('aria-disabled', 'false'))) 6129 }), 6130 (n.prototype.updateDots = function () { 6131 var e = this 6132 null !== e.$dots && 6133 (e.$dots.find('li').removeClass('slick-active').end(), 6134 e.$dots 6135 .find('li') 6136 .eq(Math.floor(e.currentSlide / e.options.slidesToScroll)) 6137 .addClass('slick-active')) 6138 }), 6139 (n.prototype.visibility = function () { 6140 var e = this 6141 e.options.autoplay && (document[e.hidden] ? (e.interrupted = !0) : (e.interrupted = !1)) 6142 }), 6143 (e.fn.slick = function () { 6144 var e, 6145 t, 6146 i = this, 6147 o = arguments[0], 6148 s = Array.prototype.slice.call(arguments, 1), 6149 a = i.length 6150 for (e = 0; e < a; e++) 6151 if ( 6152 ('object' == typeof o || void 0 === o 6153 ? (i[e].slick = new n(i[e], o)) 6154 : (t = i[e].slick[o].apply(i[e].slick, s)), 6155 void 0 !== t) 6156 ) 6157 return t 6158 return i 6159 }) 6160 }) 6161const setDataTagging = ({ 6162 event: e = 'event', 6163 eventCategory: t = 'bblend:geral', 6164 eventAction: n, 6165 eventLabel: i, 6166 otherProps: o, 6167 }) => { 6168 window.dataLayer = window.dataLayer || [] 6169 const s = formatProps(o), 6170 a = { 6171 event: e, 6172 eventCategory: t, 6173 eventAction: n, 6174 eventLabel: i ? formatProps(i) : void 0, 6175 ...s, 6176 } 6177 window.dataLayer.push(a) 6178 }, 6179 formatProps = (e) => { 6180 if ('string' == typeof e) 6181 return e 6182 ? e 6183 .toLowerCase() 6184 .replace('r$', '') 6185 .replace(/\//g, '-') 6186 .replace(/\s+/g, '-') 6187 .normalize('NFD') 6188 .replace(/[\u0300-\u036f]/g, '')
6189 .replace(/[^\w:%,\-+]/g, '') 6190 .replace(/^[^\w]+|[^\w]+$/g, '') 6191 .trim() 6192 : e 6193 if ('object' == typeof e) for (const t in e) 'products' !== t && 'impressions' !== t && (e[t] = formatProps(e[t])) 6194 return e 6195 }, 6196 addItemPay2bAttachment = async ({ productSku: e, productCartIndex: t, frequencyKey: n } = {}) => { 6197 try { 6198 if (!e && 0 !== e && !t && 0 !== t) 6199 return void console.alert('At least one of the parameters is obrigatory to addItemAttachment') 6200 t || (t = vtexjs.checkout.orderForm.items.findIndex((t) => Number(t.id) === Number(e))) 6201 const i = ALL_FREQUENCY_OPTIONS.find((e) => e.key === n) 6202 if (!i) return void console.alert('frequencyKey does not exist') 6203 const o = await vtexjs.checkout.addItemAttachment( 6204 t, 6205 'pay2b.subscription', 6206 { 6207 'pay2b.subscription.recurring.value': i.pay2bKey, 6208 }, 6209 null, 6210 !1 6211 ) 6212 MiniCart.subscriptionDataUpdate(o), MiniCart.updateOrderForm(o) 6213 let s = (await vtexjs.checkout.getOrderForm()).marketingData 6214 return ( 6215 s || 6216 (s = { 6217 marketingTags: [], 6218 }), 6219 (s.marketingTags = [...s.marketingTags, i.pay2bKey]), 6220 (s.attachmentId = 'pay2b.subscription'), 6221 (s.utmiCampaign = 'pay2b.subscription'), 6222 vtexjs.checkout.sendAttachment('marketingData', s) 6223 ) 6224 } catch (e) { 6225 console.error(e) 6226 } 6227 }, 6228 removeItemPay2bAttachment = async ({ productSku: e, productCartIndex: t } = {}) => { 6229 try { 6230 if (!e && 0 !== e && !t && 0 !== t) 6231 return void console.alert('At least one of the parameters is obrigatory to addItemAttachment') 6232 t || (t = vtexjs.checkout.orderForm.items.findIndex((t) => t.id == e)) 6233 const n = vtexjs.checkout.orderForm.items[t] 6234 if (!n) return 6235 if (!n.attachments.find((e) => (e.name = 'pay2b.subscription'))) return 6236 const i = await vtexjs.checkout.removeItemAttachment( 6237 t, 6238 'pay2b.subscription', 6239 { 6240 'pay2b.subscription.recurring.value': null, 6241 }, 6242 null, 6243 !1 6244 ) 6245 MiniCart.subscriptionDataUpdate(i), MiniCart.updateOrderForm(i) 6246 } catch (e) { 6247 console.error(e) 6248 } 6249 }, 6250 addItemToCart = async (e, t, n = 'bblend', i) => { 6251 window.location.pathname 6252 try { 6253 const o = vtexjs.checkout.orderForm.items.findIndex((t) => t.id == e && null === t.parentItemIndex) 6254 if (o >= 0) { 6255 const e = [ 6256 { 6257 index: o, 6258 quantity: t, 6259 }, 6260 ] 6261 await vtexjs.checkout.updateItems(e, null, !1) 6262 } else { 6263 const o = [ 6264 { 6265 id: e, 6266 quantity: t, 6267 seller: n, 6268 }, 6269 ], 6270 s = i || getCurrentSalesChannel() 6271 await vtexjs.checkout.addToCart(o, null, s) 6272 } 6273 const s = await vtexjs.checkout.getOrderForm() 6274 return ( 6275 window.location.pathname.includes('checkout') && addToCartDataLayer(e, t), 6276 MiniCart.updateOrderForm(vtexjs.checkout.orderForm), 6277 s 6278 ) 6279 } catch (e) { 6280 console.error(e) 6281 } 6282 }, 6283 getCurrentSalesChannel = () => { 6284 let e 6285 return ( 6286 vtexjs.checkout.orderForm.salesChannel 6287 ? (e = vtexjs.checkout.orderForm.salesChannel) 6288 : document.cookie 6289 .split(';') 6290 .find((e) => e.match('VTEXSC')) 6291 .replace('VTEXSC=', '') 6292 .trim() 6293 .replace('sc=', ''), 6294 e 6295 ) 6296 }, 6297 fetchProductById = async (e) => { 6298 try { 6299 const t = await fetch('/api/catalog_system/pub/products/search?fq=productId:' + e) 6300 return await t.json() 6301 } catch (e) { 6302 throw (console.error(e), e) 6303 } 6304 }, 6305 fetchProductBySku = async (e) => { 6306 try { 6307 const t = await fetch('/api/catalog_system/pub/products/search?fq=skuId:' + e) 6308 return await t.json() 6309 } catch (e) { 6310 throw (console.error(e), e) 6311 } 6312 }, 6313 fetchSkuSubscriptionPrice = (() => { 6314 // Cache de Promises em voo + concluÃdas, por skuId|segmento|seller. 6315 // orderFormUpdated.vtex dispara em rajada; o coalescing evita requests duplicadas. 6316 // Falhas não são cacheadas (espelha theme/react/Helpers/skuPriceService.ts). 6317 const cache = new Map() 6318 const getVtexSegment = () => { 6319 const match = document.cookie.match(/(?:^|;\s*)vtex_segment=([^;
6319]+)/) 6320 return match ? decodeURIComponent(match[1]) : '' 6321 } 6322 return (skuId, seller) => { 6323 const segment = getVtexSegment() 6324 const key = `${skuId}|${segment}|${seller}` 6325 const hit = cache.get(key) 6326 if (hit) return hit 6327 const promise = (async () => { 6328 try { 6329 const qs = new URLSearchParams({ skuId, seller, vtexSegment: segment }) 6330 const res = await fetch(`/_v/skuSubscriptionPrice?${qs}`) 6331 if (!res.ok) { 6332 cache.delete(key) 6333 return null 6334 } 6335 return await res.json() 6336 } catch (e) { 6337 cache.delete(key) 6338 return null 6339 } 6340 })() 6341 cache.set(key, promise) 6342 return promise 6343 } 6344 })(), 6345 toBrazilianNumberFormat = (e) => { 6346 if (typeof e !== 'number' || isNaN(e)) { 6347 throw 'toBrazilianNumberFormat expects a valid number, but received ' + (isNaN(e) ? 'NaN' : typeof e) 6348 } 6349 // Arredonda sempre para baixo nas casas decimais 6350 const roundedDown = Math.floor(e * 100) / 100 6351 return new Intl.NumberFormat('pt-BR', { 6352 minimumFractionDigits: 2, 6353 maximumFractionDigits: 2, 6354 }).format(roundedDown) 6355 }, 6356 formatCategoriesIds = (e) => { 6357 let t = e.split('/') 6358 return (t = t.filter((e) => e).map((e) => parseInt(e))), t 6359 }, 6360 isValid = { 6361 email: (e) => 6362 /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test( 6363 String(e).toLowerCase() 6364 ), 6365 cnpj: (e) => { 6366 function t(e, t) { 6367 const n = 6368 e 6369 .split('') 6370 .map((e, n) => e * t[n]) 6371 .reduce((e, t) => e + t) % 11 6372 return n < 2 ? 0 : 11 - n 6373 } 6374 if (14 !== (e = e.replace(/\D/g, '')).length) return !1 6375 if (/^(\d)\1+$/.test(e)) return !1 6376 const n = t(e.substring(0, 12), [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]), 6377 i = t(e.substring(0, 12) + n, [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]) 6378 return e.substring(12) === n.toString() + i.toString() 6379 }, 6380 }, 6381 extractFunctionFromString = (string) => { 6382 const formattedString = string.replace(/\(\)$/, '').replace(/"/g, '\\"'), 6383 functionReference = eval(formattedString) 6384 return functionReference 6385 } 6386document.querySelectorAll('a[href^="#"]._scroll-smooth').forEach((e) => { 6387 e.addEventListener('click', function (e) { 6388 e.preventDefault(), 6389 document.querySelector(this.getAttribute('href')).scrollIntoView({ 6390 behavior: 'smooth', 6391 }) 6392 }) 6393}) 6394const setFrequencyOptions = (e) => { 6395 const t = e || window.currentProductId 6396 if (!t) return FREQUENCY_OPTIONS 6397 return '68' == t ? CILINDER_FREQUENCY_OPTIONS : '38' == t ? FILTER_FREQUENCY_OPTIONS : FREQUENCY_OPTIONS 6398 }, 6399 addToCartDataLayer = async (e, t) => { 6400 const [n] = await fetchProductBySku(e), 6401 i = n.categories, 6402 o = i[i.length - 1].replace(/\//g, '').trim(), 6403 s = document.location.pathname.includes('checkout'), 6404 a = { 6405 event: 'addToCart', 6406 eventCategory: 'enhanced-ecommerce', 6407 eventAction: 'addToCart', 6408 otherProps: { 6409 ecommerce: { 6410 add: { 6411 products: [ 6412 { 6413 name: n.productName, 6414 id: n.productId, 6415 price: 'R$ ' + toBrazilianNumberFormat(n.items[0].sellers[0].commertialOffer.ListPrice), 6416 brand: n.brand, 6417 category: o, 6418 variant: n.items[0].itemId, 6419 quantity: t, 6420 list: s ? 'checkout' : void 0, 6421 }, 6422 ], 6423 }, 6424 }, 6425 }, 6426 } 6427 setDataTagging(a) 6428 }, 6429 CATEGORY_ID = { 6430 ACCESSORY: 4, 6431 CAPSULE: 2, 6432 COMBO: 19, 6433 DRINK: 6, 6434 }, 6435 FREQUENCY_OPTIONS = [ 6436 { 6437 key: '1-month', 6438 text: 'mês', 6439 interval: 1, 6440 periodicity: 'MONTH', 6441 vtexFrequencyKey: '1 month', 6442 pay2bKey: 'a cada 1 mês', 6443 }, 6444 { 6445 key: '2-month', 6446 text: 'meses', 6447 interval: 2, 6448 periodicity: 'MONTH', 6449 vtexFrequencyKey: '2 month', 6450 pay2bKey: 'a cada 2 meses', 6451 }, 6452 { 6453 key: '3-month', 6454 text: 'meses', 6455 interval: 3, 6456 periodicity: 'MONTH', 6457 vtexFrequencyKey: '3 month', 6458 pay2bKey: 'a cada 3 meses', 6459 }, 6460 ], 6461 FILTER_FREQUENCY_OPTIONS = [ 6462 { 6463 key: '3-month', 6464 text: 'meses', 6465 interval: 3, 6466 periodicity: 'MONTH', 6467 vtexFrequencyKey: '3 month', 6468 pay2bKey: 'a cada 3 meses', 6469 }, 6470 { 6471 key: '6-month', 6472 text: 'meses', 6473 interval: 6, 6474 periodicity: 'MONTH', 6475 vtexFrequencyKey: '6 month', 6476 pay2bKey: 'a cada 6 meses', 6477 }, 6478 ], 6479 CILINDER_FREQUENCY_OPTIONS = [ 6480 { 6481 key: '1-month', 6482 text: 'mês', 6483 interval: 1, 6484 periodicity: 'MONTH', 6485 vtexFrequencyKey: '1 month', 6486 pay2bKey: 'a cada 1 mês', 6487 }, 6488 { 6489 key: '3-month', 6490 text: 'meses', 6491 interval: 3, 6492 periodicity: 'MONTH', 6493 vtexFrequencyKey: '3 month', 6494 pay2bKey: 'a cada 3 meses', 6495 }, 6496 { 6497 key: '6-month', 6498 text: 'meses', 6499 interval: 6, 6500 periodicity: 'MONTH', 6501 vtexFrequencyKey: '6 month', 6502 pay2bKey: 'a cada 6 meses', 6503 }, 6504 ], 6505 ALL_FREQUENCY_OPTIONS = [ 6506 { 6507 key: '1-month', 6508 text: 'mês', 6509 interval: 1, 6510 periodicity: 'MONTH', 6511 vtexFrequencyKey: '1 month', 6512 pay2bKey: 'a cada 1 mês', 6513 }, 6514 { 6515 key: '2-month', 6516 text: 'meses', 6517 interval: 2, 6518 periodicity: 'MONTH', 6519 vtexFrequencyKey: '2 month', 6520 pay2bKey: 'a cada 2 meses', 6521 }, 6522 { 6523 key: '3-month', 6524 text: 'meses', 6525 interval: 3, 6526 periodicity: 'MONTH', 6527 vtexFrequencyKey: '3 month', 6528 pay2bKey: 'a cada 3 meses', 6529 }, 6530 { 6531 key: '6-month', 6532 text: 'meses', 6533 interval: 6, 6534 periodicity: 'MONTH', 6535 vtexFrequencyKey: '6 month', 6536 pay2bKey: 'a cada 6 meses', 6537 }, 6538 ], 6539 SKUS = { 6540 WELCOME_KIT: 384, 6541 WELCOME_KIT_PREMIUM: 451, 6542 }, 6543 MACHINES_INFOS_BY_SKU = { 6544 525: { 6545 id: '503', 6546 color: 'preta', 6547 voltage: '110', 6548 }, 6549 526: { 6550 id: '503', 6551 color: 'preta', 6552 voltage: '220', 6553 }, 6554 523: { 6555 id: '502', 6556 color: 'grafite', 6557 voltage: '110', 6558 }, 6559 524: { 6560 id: '502', 6561 color: 'grafite', 6562 voltage: '220', 6563 }, 6564 528: { 6565 id: '504', 6566 color: 'vermelha', 6567 voltage: '220', 6568 }, 6569 527: { 6570 id: '504', 6571 color: 'vermelha', 6572 voltage: '110', 6573 }, 6574 472: { 6575 id: '458', 6576 color: 'preta', 6577 voltage: '220', 6578 }, 6579 471: { 6580 id: '458', 6581 color: 'preta', 6582 voltage: '110', 6583 }, 6584 }, 6585 currentPage = window.location.pathname 6586let couponData = null 6587const hash = window.location.hash, 6588 cartClass = '__cart', 6589 emailClass = '__email', 6590 profileClass = '__profile', 6591 shippingClass = '__shipping',
6592 paymentClass = '__payment', 6593 salesChannelLogin = () => { 6594 $('body').on('DOMNodeInserted', '.vtexIdUI-providers-list', function () { 6595 setTimeout(() => { 6596 '4' === vtexjs.checkout.orderForm.salesChannel 6597 ? ((document.querySelector('#vtexIdUI-google-plus').style.display = 'none'), 6598 (document.querySelector('#vtexIdUI-facebook').style.display = 'none')) 6599 : ((document.querySelector('#vtexIdUI-google-plus').style.display = 'revert'), 6600 (document.querySelector('#vtexIdUI-facebook').style.display = 'revert')) 6601 }, 100) 6602 }) 6603 } 6604function checkHasBenefits() { 6605 document.querySelectorAll('#payment-data-submit').forEach((e) => { 6606 e.addEventListener('click', (e) => { 6607 e.preventDefault() 6608 const t = vtexjs.checkout.orderForm.ratesAndBenefitsData.rateAndBenefitsIdentifiers.find( 6609 (e) => '9e576275-1cd2-4868-8f19-abe340f3eb97' === e.id 6610 ) 6611 t 6612 ? localStorage.setItem('signature-promotion', JSON.stringify(t)) 6613 : localStorage.setItem('signature-promotion', '') 6614 }) 6615 }) 6616} 6617const fixAddressInputs = () => { 6618 $('.vtex-omnishipping-1-x-addressForm') 6619 .find('input:text') 6620 .toArray() 6621 .forEach((e) => { 6622 e.onkeypress = function (e) { 6623 const t = String.fromCharCode(e.which) 6624 if ("'_/*-".indexOf(t) >= 0) return !1 6625 } 6626 }), 6627 document.querySelector('#ship-complement').setAttribute('maxlength', 750) 6628 }, 6629 addressInputObserver = () => { 6630 $('body').on('DOMNodeInserted', '.vtex-omnishipping-1-x-addressForm', function () { 6631 setTimeout(() => { 6632 fixAddressInputs() 6633 }, 100) 6634 }) 6635 } 6636$(document).ready(function () { 6637 '#/cart' === hash && $('body').addClass(cartClass), 6638 '#/email' === hash && $('body').addClass(emailClass), 6639 '#/profile' === hash && $('body').addClass(profileClass), 6640 '#/shipping' === hash && 6641 ($('body').addClass(shippingClass), 6642 setTimeout(() => { 6643 document.querySelector('.vtex-omnishipping-1-x-addressForm') && fixAddressInputs() 6644 }, 4e3)), 6645 '#/payment' === hash && $('body').addClass(paymentClass), 6646 salesChannelLogin(), 6647 addressInputObserver() 6648}), 6649 $(window).on('hashchange', function () { 6650 const e = window.location.hash 6651 '#/cart' === e && 6652 ($('body').removeClass(emailClass), 6653 $('body').removeClass(profileClass), 6654 $('body').removeClass(shippingClass), 6655 $('body').removeClass(paymentClass), 6656 $('body').addClass(cartClass)), 6657 '#/email' !== e && showSignatureDiscounts(vtexjs.checkout.orderForm), 6658 '#/email' === e && 6659 ($('body').removeClass(cartClass), 6660 $('body').removeClass(profileClass), 6661 $('body').removeClass(shippingClass), 6662 $('body').removeClass(paymentClass), 6663 $('body').addClass(emailClass)), 6664 '#/profile' === e && 6665 ($('body').removeClass(cartClass), 6666 $('body').removeClass(emailClass), 6667 $('body').removeClass(shippingClass), 6668 $('body').removeClass(paymentClass), 6669 $('body').addClass(profileClass)), 6670 '#/shipping' === e && 6671 ($('body').removeClass(cartClass), 6672 $('body').removeClass(emailClass), 6673 $('body').removeClass(profileClass), 6674 $('body').removeClass(paymentClass), 6675 $('body').addClass(shippingClass), 6676 setInterval(() => { 6677 document.querySelector('.vtex-omnishipping-1-x-addressForm') && (fixAddressInputs(), clearInterval()) 6678 }, 100)), 6679 '#/payment' === e && 6680 ($('body').removeClass(cartClass), 6681 $('body').removeClass(emailClass), 6682 $('body').removeClass(profileClass), 6683 $('body').removeClass(shippingClass), 6684 $('body').addClass(paymentClass), 6685 checkHasBenefits()) 6686 }) 6687const formatter = new Intl.NumberFormat('pt-BR', { 6688 minimumFractionDigits: 2, 6689 }), 6690 addCilindroToCart = () => { 6691 vtexjs.checkout 6692 .addToCart( 6693 [ 6694 { 6695 id: 69, 6696 quantity: 1, 6697 seller: '1', 6698 }, 6699 ], 6700 null, 6701 1 6702 ) 6703 .done(function (e) {}) 6704 }, 6705 sendDataLayer = (e) => { 6706 window.dataLayer.push(e) 6707 } 6708function customCartUpdate(e) { 6709 ;(window.customCart = []), 6710 (window.customCart.items = []), 6711 (window.customCart.items.vouncher = []), 6712 (window.customCart.items.prime = []), 6713 (window.customCart.items.b2c = []), 6714 (window.customCart.items.machine = []), 6715 (window.customCart.items.caps = []), 6716 (window.customCart.items.caps.normal = []), 6717 (window.customCart.items.caps.drink = []), 6718 (window.customCart.items.mix = []), 6719 (window.customCart.items.mix.normal = []), 6720 (window.customCart.items.mix.welcome = []), 6721 (window.customCart.items.notCategorized = []), 6722 (window.customCart.items.accessories = []),
6723 e.items.forEach(function (t, n) { 6724 if ('/29/' === t.productCategoryIds) 6725 '45' === t.productId 6726 ? window.customCart.items.vouncher.push({ 6727 index: n, 6728 item: t, 6729 }) 6730 : '455' === t.productId 6731 ? window.customCart.items.b2c.push({ 6732 index: n, 6733 item: t, 6734 }) 6735 : window.customCart.items.prime.push({ 6736 index: n, 6737 item: t, 6738 }) 6739 else if (t.productCategoryIds.includes('/1/')) 6740 window.customCart.items.machine.push({ 6741 index: n, 6742 item: t, 6743 }) 6744 else if (t.productCategoryIds.includes('/4/')) 6745 window.customCart.items.accessories.push({ 6746 index: n, 6747 item: t, 6748 }) 6749 else if (t.productCategoryIds.includes('/2/') && t.productId !== '290') 6750 t.productCategoryIds.includes('/2/6/') 6751 ? window.customCart.items.caps.drink.push({ 6752 index: n, 6753 item: t, 6754 }) 6755 : window.customCart.items.caps.normal.push({ 6756 index: n, 6757 item: t, 6758 }) 6759 6760 else if (t.productCategoryIds.includes('/20/') || t.productId === '290') 6761 if ('375' === t.productId) 6762 window.customCart.items.mix.welcome.push({ 6763 index: n, 6764 item: t, 6765 }) 6766 else if ('440' === t.productId) 6767 window.customCart.items.mix.welcome.push({ 6768 index: n, 6769 item: t, 6770 }) 6771 else { 6772 const i = [] 6773 e.items.forEach(function (e, t) { 6774 e.productCategoryIds.includes('/2/') && 6775 e.parentItemIndex === n && 6776 i.push({ 6777 indexB: t, 6778 itemB: e, 6779 }) 6780 }), 6781 window.customCart.items.mix.normal.push({ 6782 index: n, 6783 item: t, 6784 caps: i, 6785 }) 6786 } 6787 else 6788 window.customCart.items.notCategorized.push({ 6789 index: n, 6790 item: t, 6791 }) 6792 }) 6793} 6794function subscriptionDataUpdate(e) { 6795 const t = [] 6796 return ( 6797 (subscriptions = e.items 6798 .map(function (e, n) { 6799 const i = e.attachments.find(function (e, t) { 6800 return 'pay2b.subscription' === e.name 6801 }) 6802 if (i) { 6803 const o = i.content['pay2b.subscription.recurring.value'] 6804 let s, a 6805 return ( 6806 '45 day' == o 6807 ? ((s = 'DAY'), (a = '45')) 6808 : '1 month' == o 6809 ? ((s = 'MONTH'), (a = '1')) 6810 : '75 days' == o && ((s = 'DAY'), (a = '75')), 6811 '2 day' == o ? ((s = 'DAY'), (a = '2')) : ((s = 'MONTH'), (a = '2')), 6812 t.push(e.id), 6813 { 6814 executionCount: 0, 6815 itemIndex: n, 6816 plan: { 6817 frequency: { 6818 interval: a, 6819 periodicity: s, 6820 type: 'RECURRING_PAYMENT', 6821 }, 6822 }, 6823 } 6824 ) 6825 } 6826 }) 6827 .filter(function (e) { 6828 return e 6829 })), 6830 vtexjs.checkout 6831 .sendAttachment('subscriptionData', { 6832 subscriptions: subscriptions, 6833 }) 6834 .fail((e) => { 6835 sendDataLayer({ 6836 event: 'errorWithoutSubscriptionData', 6837 skus: t.join('|'), 6838 }) 6839 }) 6840 ) 6841} 6842function fixCapsQuantity(e) { 6843 const t = [], 6844 n = document.querySelector('.available-gift .available-gift-item.active') 6845 e.caps.normal.forEach(function (e) { 6846 if ('vtex.assembly-option.CaixaMix20_NEW' !== e.item.parentAssemblyBinding) { 6847 if (n && n.dataset.itemId === e.item.id) return 6848 if (e.item.quantity < 10) { 6849 const n = { 6850 content: { 6851 detail: `Produto ${e.item.name} retirado do carrinho, pois não há quantidade disponÃÂvel o suficiente`, 6852 }, 6853 type: 'error', 6854 } 6855 $(window).trigger('addMessage', n), 6856 sendDataLayer({ 6857 event: 'errorCartOOS', 6858 skus: e.item.id, 6859 }), 6860 t.push({ 6861 index: e.index, 6862 quantity: 0, 6863 }) 6864 } else { 6865 const n = e.item.quantity < 10 ? -Math.abs(10 - (e.item.quantity % 10)) : e.item.quantity % 10 6866 let i 6867 if ((0 !== n && (i = e.item.quantity - n), i)) { 6868 const n = { 6869 content: { 6870 detail: 6871 'Quantidade do ' + 6872 e.item.name + 6873 ' atualizado no carrinho, pois não há quantidade disponÃÂvel o suficiente', 6874 }, 6875 type: 'error', 6876 } 6877 $(window).trigger('addMessage', n), 6878 sendDataLayer({ 6879 event: 'errorCartQty', 6880 skus: e.item.id, 6881 quantity: i, 6882 }), 6883 t.push({ 6884 index: e.index, 6885 quantity: i, 6886 }) 6887 } 6888 } 6889 } 6890 }), 6891 e.caps.drink.forEach(function (e) { 6892 if ('vtex.assembly-option.CaixaMix20_NEW' !== e.item.parentAssemblyBinding) { 6893 if (n && n.dataset.itemId === e.item.id) return 6894 if (e.item.quantity < 5) { 6895 const n = { 6896 content: { 6897 detail: `Produto ${e.item.name} retirado do carrinho, pois não há quantidade disponÃÂvel o suficiente`, 6898 }, 6899 type: 'error', 6900 } 6901 $(window).trigger('addMessage', n), 6902 sendDataLayer({ 6903 event: 'errorCartOOS', 6904 skus: e.item.id, 6905 }), 6906 t.push({ 6907 index: e.index, 6908 quantity: 0, 6909 }) 6910 } else { 6911 const n = e.item.quantity < 5 ? -Math.abs(10 - (e.item.quantity % 5)) : e.item.quantity % 5 6912 let i 6913 if ((0 !== n && (i = e.item.quantity - n), i)) { 6914 const n = { 6915 content: { 6916 detail: `Quantidade do ${e.item.name} atualizado no carrinho, pois não há quantidade disponÃÂvel o suficiente`, 6917 }, 6918 type: 'error', 6919 } 6920 $(window).trigger('addMessage', n), 6921 sendDataLayer({ 6922 event: 'errorCartQty', 6923 skus: e.item.id, 6924 quantity: i, 6925 }), 6926 t.push({ 6927 index: e.index, 6928 quantity: i, 6929 }) 6930 } 6931 } 6932 } 6933 }), 6934 t.length && vtexjs.checkout.updateItems(t, null, !1) 6935} 6936function checkAvaliability(e) { 6937 const t = e.items.filter((e) => 'available' !== e.availability), 6938 n = Array.from(document.querySelectorAll('tr.product-item.unavailable.lookatme')) 6939 for (const e of t) { 6940 const t = n.find((t) => t.dataset.sku === e.id) 6941 if ('withoutStock' === e.availability) { 6942 const e = document.createElement('td') 6943 e.classList.add('shipping-date'), 6944 (e.innerHTML = '<p>Produto sem estoque</p>'), 6945 t.querySelector('.shipping-date.empty').replaceWith(e) 6946 const n = document.createElement('p') 6947 n.classList.add('unavailableMob'),
6948 (n.innerHTML = 'Produto sem estoque'), 6949 t.querySelector('a.item-quantity-change.item-quantity-change-increment').after(n), 6950 setTimeout(() => { 6951 const e = document.createElement('td') 6952 e.classList.add('shipping-date'), 6953 (e.innerHTML = '<p>Produto sem estoque</p>'), 6954 t.querySelector('.shipping-date.empty').replaceWith(e) 6955 const n = document.createElement('p') 6956 n.classList.add('unavailableMob'), 6957 (n.innerHTML = 'Produto sem estoque'), 6958 t.querySelector('a.item-quantity-change.item-quantity-change-increment').after(n) 6959 }, 1e3) 6960 } else if ('cannotBeDelivered' === e.availability) { 6961 const e = document.createElement('td') 6962 e.classList.add('shipping-date'), 6963 (e.innerHTML = '<p>Região não atendida</p>'), 6964 t.querySelector('.shipping-date.empty').replaceWith(e) 6965 const n = document.createElement('p') 6966 n.classList.add('unavailableMob'), 6967 (n.innerHTML = 'Região não atendida'), 6968 t.querySelector('a.item-quantity-change.item-quantity-change-increment').after(n), 6969 setTimeout(() => { 6970 const e = document.createElement('td') 6971 e.classList.add('shipping-date'), 6972 (e.innerHTML = '<p>Região não atendida</p>'), 6973 t.querySelector('.shipping-date.empty').replaceWith(e) 6974 const n = document.createElement('p') 6975 n.classList.add('unavailableMob'), 6976 (n.innerHTML = 'Região não atendida'), 6977 t.querySelector('a.item-quantity-change.item-quantity-change-increment').after(n) 6978 }, 1e3) 6979 } 6980 } 6981} 6982function checkBoxCapsQuantity(e) { 6983 const t = [] 6984 let n = 0 6985 e.mix.normal.forEach(function (e) { 6986 ;(n = 0), 6987 e.caps.forEach(function (e) { 6988 n += e.itemB.quantity 6989 }), 6990 n < 20 && 6991 t.push({ 6992 index: e.index, 6993 quantity: 1, 6994 }) 6995 }), 6996 t.length && 6997 vtexjs.checkout.removeItems(t).done(function () { 6998 $(window).trigger('addMessage', { 6999 content: { 7000 detail: 'Caixa Mix retirada pois é necessário ter pelo menos 20 unidades de cápsulas dentro de cada uma', 7001 }, 7002 type: 'error', 7003 }) 7004 }) 7005} 7006function checkBoxWelcomeQuantity(e) { 7007 const t = [] 7008 e.mix.welcome.length > 2 * e.machine.length && 7009 t.push({ 7010 index: e.mix.welcome[0].index, 7011 quantity: 1, 7012 }), 7013 t.length && 7014 vtexjs.checkout.removeItems(t).done(function () { 7015 $(window).trigger('addMessage', { 7016 content: { 7017 detail: 7018 'A compra do kit boas vindas é vinculada a compra de máquina, sendo limitado 1 kit boas vindas por máquina', 7019 }, 7020 type: 'error', 7021 }) 7022 }) 7023} 7024function mountB2bModal() { 7025 $('._modal-b2b').length || 7026 ($('footer').append( 7027 '\n <div class="_modal-b2b">\n <div>\n <p>\n Para finalizar a compra de máquina para clientes corporativos, precisamos retirar a máquina do carrinho e te direcionar para página de B.blend Business. Podemos continuar?\n </p>\n <p style="font-size: 12px;" id="b2bTimer">\n Você será redirecionado em 15 segundos\n </p>\n <a href="#" class="_yes" id="b2b_yes">Sim</a>\n </div>\n </div>\n ' 7028 ), 7029 $('._modal-b2b ._yes').on('click', function (e) { 7030 e.preventDefault(), 7031 $('._modal-b2b').addClass('_loading'), 7032 (itemsToRemove = []), 7033 $.each(customCart.items.machine, function (e, t) { 7034 itemsToRemove.push({ 7035 index: t.index, 7036 quantity: 1, 7037 }) 7038 }), 7039 vtexjs.checkout.removeItems(itemsToRemove).done(function () { 7040 window.location.href = '/empresas' 7041 }) 7042 })) 7043} 7044function checkNewUser() { 7045 return !vtexjs.checkout.orderForm.clientProfileData || !vtexjs.checkout.orderForm.clientProfileData.document 7046} 7047function b2bRules() { 7048 customCart.items.vouncher.length && 7049 (customCart.items.vouncher.forEach(function (e) { 7050 e.item.attachments.length || 7051 ((itemsToRemove = []), 7052 itemsToRemove.push({ 7053 index: e.index, 7054 quantity: 1, 7055 }), 7056 vtexjs.checkout.removeItems(itemsToRemove).done(function () { 7057 let t 7058 ;(messages = new window.vtex.Messages.getInstance({ 7059 ajaxError: !0, 7060 })), 7061 (t = { 7062 content: { 7063 detail: 'O produto ' + e.item.name + ' só pode ser adquirido em forma de assinatura mensal"', 7064 }, 7065 type: 'error', 7066 }), 7067 $(window).trigger('addMessage', t), 7068 console.error(e.index, 'O produto ' + e.item.name + ' só pode ser adquirido em forma de assinatura mensal"') 7069 })) 7070 }), 7071 $('.cinclude-pj').hide(), 7072 $('.box-client-info-pj').show(), 7073 $('#edit-profile-data').click(function () { 7074 $('.cinclude-pj').hide(), $('.box-client-info-pj').show() 7075 }), 7076 $('#client-company-document').livequery(function () { 7077 const e = $('#client-company-document').attr('value') 7078 '' !== e 7079 ? ($("span:contains('Finalizar compra')").parent().removeClass('disabled'), $('.info-b2b-alert.cnpj').remove()) 7080 : '' === e && 7081 ($("span:contains('Finalizar compra')").parent().addClass('disabled'), 7082 $('.info-b2b-alert.cnpj').remove(), 7083 $( 7084 '<div class="info-b2b-alert cnpj"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 13 11"><defs></defs><path fill="#D70A55" d="M7.286 9.012V7.845a.181.181 0 00-.062-.14.175.175 0 00-.135-.062H5.911c-.053 0-.1.02-.141.061a.191.191 0 00-.056.141v1.167c0 .057.019.106.056.147.04.037.088.055.14.055h1.18a.184.184 0 00.
7084134-.055.2.2 0 00.062-.147zm-.013-2.296l.11-2.818c0-.049-.02-.088-.06-.116-.054-.045-.103-.068-.148-.068h-1.35c-.045 0-.094.023-.148.068-.04.028-.06.071-.06.129l.103 2.805c0 .04.02.076.062.104.04.025.09.037.147.037h1.136a.25.25 0 00.14-.037c.042-.028.064-.063.068-.104zM7.188.983l4.714 8.643a.732.732 0 01-.012.773.765.765 0 01-.289.282.752.752 0 01-.387.105H1.786a.779.779 0 01-.675-.387.732.732 0 01-.013-.773L5.813.983A.784.784 0 016.899.682a.784.784 0 01.288.3z"></path></svg>Para finalizar seu pedido, por favor preencha seus dados de pessoa jurÃÂdica (CNPJ)</div>' 7085 ).insertBefore('.payment-submit-wrap')) 7086 })) 7087} 7088function checkB2bAttachmentOfferings() { 7089 orderForm = vtexjs.checkout.orderForm || orderForm 7090 const e = [] 7091 if ( 7092 ((subscriptions = orderForm.items 7093 .map(function (t, n) { 7094 if ('45' != t.productId); 7095 else { 7096 if (t.attachmentOfferings && t.attachmentOfferings.length) return 7097 if ( 7098 t.attachments.find(function (e, t) { 7099 return 'vtex.subscription.b2b' === e.name 7100 }) 7101 ) { 7102 const i = 'MONTH', 7103 o = '1' 7104 return ( 7105 e.push(t.id), 7106 { 7107 executionCount: 0, 7108 itemIndex: n, 7109 plan: { 7110 frequency: { 7111 interval: o, 7112 periodicity: i, 7113 type: 'RECURRING_PAYMENT', 7114 }, 7115 }, 7116 } 7117 ) 7118 } 7119 } 7120 }) 7121 .filter(function (e) { 7122 return e 7123 })), 7124 subscription) 7125 ) 7126 return vtexjs.checkout 7127 .sendAttachment('subscriptionData', { 7128 subscriptions: subscriptions, 7129 }) 7130 .fail(() => { 7131 sendDataLayer({ 7132 event: 'errorAddB2BWithoutSubscription', 7133 skus: e.join('|'), 7134 }) 7135 }) 7136} 7137function shippingAlert() { 7138 $('shipping-contnet, .shipping-text').remove() 7139 $('#checkadressLabel').after( 7140 '<div class="shipping-content">\n <p class="shipping-text">\n Tentativas de Entrega: <strong>Caso sejam realizadas 3 tentativas de entrega sem sucesso, o pedido será devolvido ao nosso centro de distribuição, e o reembolso do valor será processado.</strong> </p>\n <p class="shipping-text">\n Para que sua experiência de compra seja mais agradável e prática possÃÂvel, certifique-se o cartão utilizado: <strong>senha limite/saldo disponÃÂvel; não esteja bloqueado; e tenha o modo de compra escolhido habilitada.</strong>\n </p>\n </div>' 7141 ) 7142} 7143function addressConfirmationCheckbox() { 7144 $('#checkadress, #checkadressLabel').remove(), 7145 $('.mini-cart > div').append( 7146 '<input type="checkbox" id="checkadress" class="checkbox" autocomplete="off" style="vertical-align:sub" checked> <label id="checkadressLabel">Confirmo que o endereço de entrega está atualizado e devidamente preenchido. <strong>Pedidos expressos aprovados até à s 11:00 serão entregues no mesmo dia útil, com previsão de entrega entre 17:00 e 22:00.</strong></label>' 7147 ), 7148 $('#checkadress').on('click', function () { 7149 this.checked 7150 ? $("span:contains('Finalizar compra')").parent().removeClass('disabled') 7151 : $("span:contains('Finalizar compra')").parent().addClass('disabled') 7152 }) 7153} 7154function updateBoxSignature(e) { 7155 e.forEach(function (e) { 7156 e.item.attachments[1] 7157 ? e.caps.forEach(function (t) { 7158 t.itemB.attachments[0] 7159 ? t.itemB.attachments[0].content['pay2b.subscription.recurring.value'] != 7160 e.item.attachments[1].content['pay2b.subscription.recurring.value'] && 7161 vtexjs.checkout 7162 .addItemAttachment(t.indexB, 'pay2b.subscription', e.item.attachments[1].content, null, !1) 7163 .done(function (e) { 7164 subscriptionDataUpdate(e) 7165 }) 7166 .fail(() => { 7167 sendDataLayer({ 7168 event: 'errorWithoutSubscription', 7169 skus: e.item.id, 7170 }) 7171 }) 7172 : vtexjs.checkout 7173 .addItemAttachment(t.indexB, 'pay2b.subscription', e.item.attachments[1].content, null, !1) 7174 .done(function (e) { 7175 subscriptionDataUpdate(e) 7176 }) 7177 .fail(() => { 7178 sendDataLayer({ 7179 event: 'errorWithoutSubscription', 7180 skus: e.item.id, 7181 }) 7182 }) 7183 }) 7184 : e.caps.forEach(function (e) { 7185 e.itemB.attachments[0] && 7186 vtexjs.checkout.removeItemAttachment(e.indexB, 'pay2b.subscription', null, null, !1).done(function (e) { 7187 subscriptionDataUpdate(e) 7188 }) 7189 }) 7190 }) 7191} 7192function boxCustomApp(e, t) { 7193 const n = {}, 7194 i = t.items, 7195 o = t.items.filter(function (e) { 7196 return e.attachments.find(function (e) { 7197 return 'Box Name' === e.name 7198 }) 7199 }) 7200 return ( 7201 i.map(function (e) { 7202 e.attachments.find(function (e) { 7203 return 'Box Name' === e.name 7204 }) && (n['Caixa ' + o.indexOf(e)] = []) 7205 }), 7206 i.map(function (e) { 7207 const t = i[e.parentItemIndex] 7208 if (!t) return 7209 t.attachments.find(function (e) { 7210 return 'Box Name' === e.name 7211 }) && 7212 (null != e.parentItemIndex && e.components.length > 0 7213 ? n['Caixa ' + o.indexOf(t)].push({ 7214 id: e.components[0].id, 7215 qty: e.quantity, 7216 }) 7217 : n['Caixa ' + o.indexOf(t)].push({ 7218 id: e.id, 7219 qty: e.quantity, 7220 })) 7221 }), 7222 (e = JSON.stringify(n)), 7223 $.ajax({
7224 type: 'PUT', 7225 url: '/api/checkout/pub/orderForm/' + vtexjs.checkout.orderForm.orderFormId + '/customData/capsulasSortidas/data', 7226 contentType: 'application/json', 7227 data: JSON.stringify({ 7228 value: e, 7229 }), 7230 error: function (e) { 7231 console.error(JSON.parse(e.responseText)) 7232 }, 7233 }), 7234 e 7235 ) 7236} 7237function listProducts(e) { 7238 let t, n 7239 if (e.customData) { 7240 t = e.customData.customApps.find(function (e) { 7241 return 'capsulassortidas' === e.id 7242 }) 7243 let n = e.items.filter(function (e) { 7244 return e.attachments.find(function (e) { 7245 return 'Box Name' === e.name 7246 }) 7247 }) 7248 n = n.map(function (e) { 7249 return 'Caixa ' + n.indexOf(e) 7250 }) 7251 const i = Object.keys(JSON.parse(t.fields.data)) 7252 if (n.join('-') === i.join('-')) return e.customData 7253 } 7254 n = boxCustomApp(n, e) 7255} 7256function hideMixCaps(e) { 7257 e.items.forEach(function (e, t) { 7258 null !== e.parentAssemblyBinding && $('.product-item').eq(t).hide() 7259 }) 7260} 7261function customizeCart(e) { 7262 const t = (e = vtexjs.checkout.orderForm || e).items 7263 hideMixCaps(e), 7264 t.forEach(function (e, n) { 7265 if (e.productId === '290') { 7266 const i = t.filter(function (e) { 7267 return 'vtex.assembly-option.CaixaMix20_NEW' === e.parentAssemblyBinding && n === e.parentItemIndex 7268 }) 7269 if (!i.length) return 7270 const o = i 7271 .map(function (e) { 7272 return e.sellingPrice * e.quantity 7273 }) 7274 .reduce(function (e, t) { 7275 return e + t 7276 }) 7277 let s = $('.product-item') 7278 if ((s.length && (s = s[n]), !s.matches(`.cart-items .product-item[data-sku='${e.id}']`))) return 7279 $(s) 7280 .find('.product-price') 7281 .html( 7282 `\n <span class="old-product-price-label">\n Caixa:\n R$ ${formatter.format( 7283 e.sellingPrice / 100 7284 )}\n </span>\n\n <span class="new-product-price-label">Itens: </span>\n <span class="new-product-price">\n R$ ${formatter.format( 7285 o / e.quantity / 100 7286 )}\n </span>\n ` 7287 ), 7288 $(s) 7289 .find('.quantity-price .total-selling-price') 7290 .html('R$ ' + formatter.format((o + e.sellingPrice) / 100)) 7291 const a = i 7292 .map(function (e) { 7293 return `<li><span>${e.quantity}</span>${e.skuName}</li>` 7294 }) 7295 .join('') 7296 $(s).find('.product-name').append(`<ul class="capsulas-sortidas-items">${a}</ul>`), 7297 $('a#product-name' + e.id).after(`<span class='caixa-dropdown' id='${e.id}'></span>`), 7298 $('a#product-name' + e.id).attr('href') && 7299 $('a#product-name' + e.id) 7300 .attr('href') 7301 .includes('/caixa-2/p') && 7302 $('a#product-name' + e.id).removeAttr('href'), 7303 $('body').addClass('caixa'), 7304 $('tr.product-item td.product-name').each(function () { 7305 $(this).find('.capsulas-sortidas-items:eq(1)').addClass('hide-wrong') 7306 }) 7307 } 7308 }), 7309 $('body').addClass('isloaded') 7310} 7311function addQuantityBtn(e) { 7312 $('.item-quantity-change-decrement').remove(), 7313 $('tbody .quantity').prepend( 7314 '<a class="item-quantity-change item-quantity-change-decrement" href="javascript:void(0);" data-i18n="[title]cart.decrement" title="Diminuir a quantidade"><i class="icon icon-minus-sign"></i></a>' 7315 ), 7316 $('.item-quantity-change-increment').remove(), 7317 $('tbody .quantity').append( 7318 '<a class="item-quantity-change item-quantity-change-increment" href="javascript:void(0);" data-i18n="[title]cart.increment" title="Aumentar a quantidade"><i class="icon icon-plus-sign"></i></a>' 7319 ), 7320 e.caps.normal && 7321 e.caps.normal.forEach(function (e) { 7322 $('.product-item[data-sku=' + e.item.id + ']').attr('data-multiplier', 10) 7323 }), 7324 e.caps.drink && 7325 e.caps.drink.forEach(function (e) { 7326 $('.product-item:nth-child(' + (e.index + 1) + ')').attr('data-multiplier', 5) 7327 }) 7328} 7329$('#client-document').livequery(function () { 7330 IMask(document.getElementById('client-document'), { 7331 mask: '000.000.000-000', 7332 }) 7333}), 7334 $('#client-phone').livequery(function () { 7335 IMask(document.getElementById('client-phone'), { 7336 mask: '(00) 00000-0000', 7337 }) 7338 }), 7339 $('#ship-postalCode').livequery(function () { 7340 IMask(document.getElementById('ship-postalCode'), { 7341 mask: '00000-000', 7342 }) 7343 }), 7344 $('#ship-number').livequery(function () { 7345 IMask(document.getElementById('ship-number'), { 7346 mask: Number, 7347 signed: !0, 7348 min: 0, 7349 }) 7350 }), 7351 $('#client-company-document').livequery(function () { 7352 IMask(document.getElementById('client-company-document'), { 7353 mask: '00.000.000/0000-00', 7354 }) 7355 }), 7356 $('.gift-card-friendly-name, .gift-card-section').livequery(function () { 7357 $('.gift-card-friendly-name:contains(global.b2b), .code span:contains(global.b2b)').text('B.blend Business'), 7358 $('.gift-card-friendly-name:contains(global.referral), .code span:contains(global.referral)').text( 7359 'Indique e Ganhe' 7360 ), 7361 $('.gift-card-friendly-name:contains(global.refund), .code span:contains(global.refund)').text( 7362 'Créditos B.blend' 7363 ), 7364 $( 7365 '.gift-card-friendly-name:contains(B.blend Indique e Ganhe), .code span:contains(B.blend Indique e Ganhe)' 7366 ).text('Outros Créditos') 7367 }), 7368 $('.item-quantity-change').livequery(function (e) { 7369 $(this).click(function (e) { 7370 $(this).addClass('_btn-loading'), 7371 e.stopPropagation(), 7372 (currentMultiplier = $(this).parent().parent().attr('data-multiplier') 7373 ? parseInt($(this).parent().parent().attr('data-multiplier')) 7374 : 1), 7375 (currentQuantity = parseInt($(this).parent().find('input').val())), 7376 (currentSku = $(this).parent().parent().attr('data-sku')), 7377 (currentIndex = vtexjs.checkout.orderForm.items.findIndex((e) => e.id == currentSku)), 7378 $(this).hasClass('item-quantity-change-decrement') 7379 ? (currentQuantity -= currentMultiplier) 7380 : (currentQuantity += currentMultiplier), 7381 vtexjs.checkout 7382 .updateItems( 7383 [ 7384 { 7385 index: currentIndex, 7386 quantity: currentQuantity, 7387 }, 7388 ], 7389 null, 7390 !1 7391 ) 7392 .done(function () { 7393 $(this).removeClass('_btn-loading') 7394 }) 7395 }) 7396 }) 7397const currentOrderForm = [] 7398;(currentOrderForm.items = []), 7399 $(window).on('orderFormUpdated.vtex', async function (e, t) { 7400 // Verificar dados mascarados e forçar habilitação de campos a cada atualização 7401 if (t?.clientProfileData?.isCorporate) { 7402 Checkout.cnpjEnableFields() 7403 } 7404 Checkout.fixCorporateDocumentType(t) 7405 // Verificar dados mascarados para todos os usuários (PF e PJ) 7406 Checkout.checkMaskedData() 7407 7408 if ( 7409 (couponCta(t), 7410 PaymentMessage.init(t), 7411 hideSignatureButton(t), 7412 JSON.stringify(currentOrderForm) != JSON.stringify(t) && 7413 JSON.stringify(currentOrderForm.items) != JSON.stringify(t.items)) 7414 ) { 7415 await customCartUpdate(t) 7416 customCart.items && 7417 (checkBoxWelcomeQuantity(customCart.items), 7418 checkBoxCapsQuantity(customCart.items), 7419 fixCapsQuantity(customCart.items), 7420 customCart.items.mix.normal.length >= 1 && updateBoxSignature(customCart.items.mix.normal), 7421 listProducts(t), 7422 addQuantityBtn(customCart.items), 7423 waitingModalOpen(), 7424 hideMixCaps(t), 7425 customizeCart(t), 7426 b2bRules(), 7427 addressConfirmationCheckbox(), 7428 shippingAlert(), 7429 changeText(t), 7430 Checkout.b2cVouncherRules(), 7431 customCart.items.vouncher.length && checkB2bAttachmentOffer
7431ings(), 7432 checkAvaliability(t)) 7433 //BenchSelector.openBench() 7434 } 7435 }), 7436 $('body').on('click', '#btn-identified-user-button', function () { 7437 if ( 7438 customCart.items.machine.length >= 1 && 7439 vtexjs.checkout.orderForm.items.find((e) => 'brastemp' === e.seller) && 7440 (vtexjs.checkout.orderForm.clientProfileData.corporateDocument || 7441 vtexjs.checkout.orderForm.clientProfileData.corporateName) 7442 ) { 7443 mountB2bModal(), $('._modal-b2b').addClass('_open') 7444 let e = 15 7445 const t = setInterval(() => { 7446 e <= 0 && (clearInterval(t), document.querySelector('#b2b_yes').click()), 7447 (document.getElementById('b2bTimer').innerText = `Você será redirecionado em ${e} segundos`), 7448 (e -= 1) 7449 }, 1e3) 7450 } 7451 }), 7452 $('.product-item[data-sku="397"]').livequery(function (e) { 7453 $(this).find('.add-item-attachment').click() 7454 }), 7455 $('.product-item[data-sku="398"]').livequery(function (e) { 7456 $(this).find('.add-item-attachment').click() 7457 }) 7458const Checkout = { 7459 init: async () => { 7460 Checkout.changeServicesNames(), 7461 Checkout.changeServiceBox(), 7462 Checkout.insertFreeShippingBar(), 7463 Checkout.insertSummaryButtons(), 7464 Checkout.insertFixedBuyButton(), 7465 // Configurar sincronização dos campos de perfil 7466 Checkout.setupCNPJSync(), 7467 Checkout.setupPersonalFieldsSync(), 7468 $('.box-client-info').livequery(function () { 7469 Checkout.cnpjEnableFields(), 7470 // Verificar dados mascarados ao carregar box de cliente 7471 Checkout.checkMaskedData(), 7472 $('#client-company-document').keyup(function () { 7473 //Checkout.cnpjValidate() 7474 }), 7475 $('#is-corporate-client').click(function () { 7476 // Checkout.cnpjValidate() 7477 }) 7478 }), 7479 $('#edit-profile-data').click(function () { 7480 //Checkout.cnpjValidate() 7481 }), 7482 $(document).on('click', '#not-corporate-client', function () { 7483 ;(document.getElementById('client-company-document').value = ''), 7484 (document.getElementById('client-company-name').value = ''), 7485 (document.getElementById('client-company-ie').value = ''), 7486 document.querySelector('#go-to-shipping, #go-to-payment').classList.remove('disabled'), 7487 document.querySelector('.box-client-info .corporate-info-box').classList.remove('_loading'), 7488 Checkout.revertDocumentTypeToPersonal() 7489 }) 7490 }, 7491 changeServicesNames: () => { 7492 $('.item-service .bundle-item-name > span').livequery(function () { 7493 document.querySelectorAll('.item-service .bundle-item-name > span').forEach((e) => { 7494 const t = e.innerText 7495 if (t.indexOf('Seguro Garantia Estendida Original') > -1) { 7496 const n = e.innerText.substring(t.lastIndexOf('-') + 1, t.length) 7497 ;(e.innerText = 'Garantia estendida de ' + n), e.classList.add('_show'), e.classList.add('extended-warranty') 7498 } 7499 }) 7500 }), 7501 $('.cart-items .service-item .product-name').livequery(function () { 7502 document.querySelectorAll('.cart-items .service-item .product-name').forEach((e) => { 7503 const t = e.innerText 7504 if (t.indexOf('Seguro Garantia Estendida Original') > -1) { 7505 const n = e.innerText.substring(t.lastIndexOf('-') + 1, t.length) 7506 ;(e.innerText = 'Garantia estendida de ' + n), e.classList.add('_show') 7507 } 7508 }) 7509 }) 7510 }, 7511 changeServiceBox: () => { 7512 $('form.product-service').livequery(function () { 7513 if ($(this).parent().parent().hasClass('_has-service')) return 7514 let e = '' 7515 const t = $(this).parent().parent().attr('data-sku') 7516 $(this) 7517 .find('select option') 7518 .each(function (n, i) { 7519 const o = i.innerText, 7520 s = o.substring(0, o.indexOf('-')), 7521 a = o.substring(o.lastIndexOf('-') + 1, o.length).split(':') 7522 e += `\n <div class="type-${s}" onclick="Checkout.servicesSelect(${t},${n})">\n Garantia de ${a[0].trim()} - <strong>${a[1] 7523 .replace('R$', '') 7524 .trim()}</strong>\n </div>` 7525 }), 7526 $(this) 7527 .parent() 7528 .parent() 7529 .find('.product-image') 7530 .append( 7531 '<div class="_services"><div class="_add" onclick="Checkout.servicesToggle(' + 7532 t + 7533 ')">Adicionar garantia estendida<div class="_options">' + 7534 e + 7535 '</div></div>' 7536 ), 7537 $(this).parent().parent().addClass('_has-service'), 7538 $(this).parent().parent().next().hasClass('item-service') && 7539 $(this).parent().parent().next().find('.extended-warranty').length && 7540 $(this).parent().parent().addClass('hide-extended-warranty') 7541 }) 7542 }, 7543 createCNAEbox: () => { 7544 if (!document.querySelector('.box-client-info-pj .corporate-info-box')) return 7545 if ($('.client-cnae').length) return 7546 $('.box-client-info-pj .corporate-info-box').append( 7547 '<p class="client-cnae input pull-left text mask">\n <label for="client-cnae">Ramo CNAE</label>\n\n <select id="client-cnae" class="input-small"><option value="" disabled="true" selected="true" hidden="true">Ramo</option><option value="Varejo">Varejo</option><option value="Construção Civil">Construção Civil</option><option value="Saúde">Saúde</option><option value="Educação">Educação</option><option value="Hotelaria">Hotelaria</option><option value="Lazer">Lazer</option><option value="Indústria">Indústria</option><option value="Imobiliária">Imobiliária</option><option value="TI e atividades relacionadas">TI e atividades relacionadas</option><option value="Alimentação">Alimentação</option><option value="Turismo">Turismo</option><option value="Estética">Estética</option><option value="Inovações">Inovações</option><option value="Advocacia">Advocacia</option></select>\n\n </p>' 7548 ) 7549 }, 7550 servicesToggle: (e) => { 7551 document 7552 .querySelector('.cart .cart-items .product-item[data-sku="' + e + '"] ._services ._add') 7553 .classList.toggle('_open') 7554 }, 7555 servicesSelect: (e, t) => { 7556 ;(document.querySelector( 7557 '.cart .cart-items .product-item[data-sku="' + e + '"] .product-service select' 7558 ).options.selectedIndex = t), 7559 document 7560 .querySelector('.cart .cart-items .product-item[data-sku="' + e + '"] .product-service select') 7561 .dispatchEvent(new Event('change')), 7562 document.querySelector('.cart .cart-items .product-item[data-sku="' + e + '"] .product-service input').click() 7563 }, 7564 cnpjDisableFields: () => {}, 7565 cnpjEnableFields: () => { 7566 ;(document.getElementById('client-company-name').disabled = !1), 7567 (document.getElementById('client-company-document2').disabled = !1), 7568 (document.getElementById('client-company-nickname').disabled = !1), 7569 (document.getElementById('client-company-ie').disabled = !1), 7570 document.getElementById('client-company-ie').removeAttribute('disabled') 7571 }, 7572 setDocumentTypeFromCorporate: (cpd) => { 7573 if (!cpd) return cpd 7574 cpd.documentType = cpd.isCorporate ? 'cnpj' : 'cpf' 7575 return cpd 7576 }, 7577 fixCorporateDocumentType: (orderForm) => { 7578 const cpd = orderForm?.clientProfileData 7579 if (!cpd?.isCorporate || cpd.documentType === 'cnpj') return 7580 if (!orderForm.canEditData) return 7581 if (window._documentTypeFixInProgress) return 7582 7583 const maskedCheckFields = [ 7584 cpd.email, 7585 cpd.corporateDocument, 7586 cpd.corporateName, 7587 cpd.tradeName, 7588 cpd.stateInscription, 7589 cpd.corporatePhone, 7590 cpd.document, 7591 cpd.firstName, 7592 cpd.lastName,
7593 cpd.phone 7594 ] 7595 if (maskedCheckFields.some((value) => value && value.includes('*'))) return 7596 7597 window._documentTypeFixInProgress = true 7598 7599 vtexjs.checkout.sendAttachment('clientProfileData', Checkout.setDocumentTypeFromCorporate({ ...cpd })) 7600 .fail(function(err) { 7601 console.error('[Profile Debug] Erro ao corrigir documentType:', err) 7602 }) 7603 .always(function() { 7604 window._documentTypeFixInProgress = false 7605 }) 7606 }, 7607 revertDocumentTypeToPersonal: () => { 7608 return vtexjs.checkout.getOrderForm().then(function(orderForm) { 7609 const cpd = { ...orderForm.clientProfileData } 7610 if (!cpd.isCorporate && cpd.documentType === 'cpf') return orderForm 7611 7612 cpd.isCorporate = false 7613 return vtexjs.checkout.sendAttachment('clientProfileData', Checkout.setDocumentTypeFromCorporate(cpd)) 7614 }).fail(function(err) { 7615 console.error('[Profile Debug] Erro ao reverter documentType para cpf:', err) 7616 }) 7617 }, 7618 isCorporateModeActive: () => { 7619 const title = document.querySelector('.box-client-info-pj .corporate-title') 7620 if (title && title.classList.contains('visible')) return true 7621 7622 const discardLink = document.getElementById('not-corporate-client') 7623 if (discardLink && $(discardLink).is(':visible')) return true 7624 7625 const corporateBox = document.querySelector('.box-client-info-pj .corporate-info-box') 7626 return corporateBox ? $(corporateBox).is(':visible') : false 7627 }, 7628 /** 7629 * Verifica se os dados do clientProfileData estão mascarados (contém ***) 7630 * e força limpeza para solicitar repreenchimento 7631 */ 7632 checkMaskedData: () => { 7633 const orderForm = vtexjs.checkout.orderForm 7634 const cpd = orderForm?.clientProfileData 7635 7636 if (!cpd) return false 7637 7638 // Evitar chamadas repetidas em curto intervalo (debounce manual) 7639 if (window._checkMaskedDataInProgress) { 7640 return false 7641 } 7642 7643 // Verificar dados mascarados em todos os campos relevantes (PJ) 7644 const hasMaskedCorporateDocument = cpd.corporateDocument && cpd.corporateDocument.includes('*') 7645 const hasMaskedCorporateName = cpd.corporateName && cpd.corporateName.includes('*') 7646 const hasMaskedTradeName = cpd.tradeName && cpd.tradeName.includes('*') 7647 const hasMaskedStateInscription = cpd.stateInscription && cpd.stateInscription.includes('*') 7648 const hasMaskedCorporatePhone = cpd.corporatePhone && cpd.corporatePhone.includes('*') 7649 7650 // Verificar dados mascarados em campos de pessoa fÃsica (PF) 7651 const hasMaskedDocument = cpd.document && cpd.document.includes('*') 7652 const hasMaskedFirstName = cpd.firstName && cpd.firstName.includes('*') 7653 const hasMaskedLastName = cpd.lastName && cpd.lastName.includes('*') 7654 const hasMaskedPhone = cpd.phone && cpd.phone.includes('*') 7655 7656 const hasMaskedCorporateData = hasMaskedCorporateDocument || hasMaskedCorporateName || hasMaskedTradeName || hasMaskedStateInscription || hasMaskedCorporatePhone 7657 const hasMaskedPersonalData = hasMaskedDocument || hasMaskedFirstName || hasMaskedLastName || hasMaskedPhone 7658 const hasMaskedData = hasMaskedCorporateData || hasMaskedPersonalData 7659 7660 if (hasMaskedData) { 7661 // Se canEditData é true, podemos limpar e forçar repreenchimento 7662 if (orderForm.canEditData) { 7663 window._checkMaskedDataInProgress = true 7664 7665 const newCpd = { ...cpd } 7666 7667 // Limpar campos mascarados e campos visuais correspondentes 7668 if (hasMaskedCorporateDocument) { 7669 newCpd.corporateDocument = '' 7670 const field2 = document.getElementById('client-company-document2') 7671 const field1 = document.getElementById('client-company-document') 7672 if (field2) field2.value = '' 7673 if (field1) field1.value = '' 7674 } 7675 7676 if (hasMaskedCorporateName) { 7677 newCpd.corporateName = '' 7678 const field = document.getElementById('client-company-name') 7679 if (field) field.value = '' 7680 } 7681 7682 if (hasMaskedTradeName) { 7683 newCpd.tradeName = '' 7684 const field = document.getElementById('client-company-nickname') 7685 if (field) field.value = '' 7686 } 7687 7688 if (hasMaskedStateInscription) { 7689 newCpd.stateInscription = '' 7690 const field = document.getElementById('client-company-ie') 7691 if (field) field.value = '' 7692 } 7693 7694 if (hasMaskedCorporatePhone) { 7695 newCpd.corporatePhone = '' 7696 } 7697 7698 // Limpar campos pessoais mascarados 7699 if (hasMaskedDocument) { 7700 newCpd.document = '' 7701 const field = document.getElementById('client-document') 7702 if (field) field.value = '' 7703 } 7704 7705 if (hasMaskedFirstName) { 7706 newCpd.firstName = '' 7707 const field = document.getElementById('client-first-name') 7708 if (field) field.value = '' 7709 } 7710 7711 if (hasMaskedLastName) { 7712 newCpd.lastName = '' 7713 const field = document.getElementById('client-last-name') 7714 if (field) field.value = '' 7715 } 7716 7717 if (hasMaskedPhone) { 7718 newCpd.phone = '' 7719 const field = document.getElementById('client-phone') 7720 if (field) field.value = '' 7721 } 7722 7723 vtexjs.checkout.sendAttachment('clientProfileData', Checkout.setDocumentTypeFromCorporate(newCpd)) 7724 .done(function() { 7725 // Forçar abertura da etapa de perfil 7726 $('#edit-profile-data').click() 7727 7728 // Liberar flag após 2 segundos 7729 setTimeout(function() { 7730 window._checkMaskedDataInProgress = false 7731 }, 2000) 7732 }) 7733 .fail(function(err) { 7734 console.error('[Profile Debug] Erro ao limpar dados mascarados:', err) 7735 window._checkMaskedDataInProgress = false 7736 }) 7737 7738 return true 7739 } 7740 } 7741 7742 return false 7743 }, 7744 /** 7745 * Sincroniza o valor do campo customizado #client-company-document2 com o orderForm 7746 */ 7747 syncCNPJToOrderForm: (cnpjValue) => { 7748 if (!Checkout.isCorporateModeActive()) { 7749 return Promise.resolve(null) 7750 } 7751 7752 if (!cnpjValue) { 7753 const fieldAlt = document.getElementById('client-company-document2') 7754 const fieldMain = document.getElementById('client-company-document') 7755 const altValue = fieldAlt?.value || '' 7756 const mainValue = fieldMain?.value || '' 7757 7758 if (fieldAlt && $(fieldAlt).is(':visible') && altValue) { 7759 cnpjValue = altValue 7760 } else { 7761 cnpjValue = mainValue || altValue 7762 } 7763 } 7764 7765 // Remover máscara para enviar apenas números 7766 const cleanCNPJ = cnpjValue.replace(/\D/g, '') 7767 7768 if (cleanCNPJ.length !== 14) { 7769 return Promise.resolve(null) 7770 } 7771 7772 return vtexjs.checkout.getOrderForm().then(function(orderForm) { 7773 const cpd = orderForm.clientProfileData 7774 7775 // Verificar se o valor já é o mesmo (evitar chamadas desnecessárias) 7776 if (cpd.corporateDocument === cleanCNPJ && cpd.documentType === 'cnpj') { 7777 return orderForm 7778 } 7779 7780 cpd.corporateDocument = cleanCNPJ 7781 if (!cpd.isCorporate) { 7782 cpd.isCorporate = true 7783 } 7784 7785 return vtexjs.checkout.sendAttachment('clientProfileData', Checkout.setDocumentTypeFromCorporate(cpd)) 7786 }).fail(function(err) { 7787 console.error('[Profile Debug] Erro ao sincronizar CNPJ:', err) 7788 }) 7789 }, 7790 /** 7791 * Sincroniza todos os campos corporativos com o orderForm 7792 */ 7793 syncCorporateFieldsToOrderForm: () => { 7794 const isCorporateModeActive = Checkout.isCorporateModeActive() 7795 if (!isCorporateModeActive) { 7796 return Promise.resolve(null) 7797 } 7798 7799 // Evitar chamadas simultâneas 7800 if (window._syncCorporateFieldsInProgress) { 7801 return Promise.resolve(null) 7802 } 7803 7804 const corporateNameField = document.getElementById('client-company-name') 7805 const tradeNameField = document.getElementById('client-company-nickname') 7806 const stateInscriptionField = document.getElementById('client-company-ie') 7807 const cnpjField = document.getElementById('client-company-document2') || document.getElementById('client-company-document') 7808 const phoneField = document.getElementById('client-phone') 7809 7810 const corporateName = corporateNameField?.value?.trim() || '' 7811 const tradeName = tradeNameField?.value?.trim() || '' 7812 const stateInscription = stateInscriptionField?.value?.trim() || '' 7813 const cnpjValue = cnpjField?.value?.replace(/\D/g, '') || '' 7814 const phoneValue = phoneField?.value?.replace(/\D/g, '') || '' 7815 7816 window._syncCorporateFieldsInProgress = true 7817 7818 return vtexjs.checkout.getOrderForm().then(function(orderForm) { 7819 const cpd = { ...orderForm.clientProfileData } 7820 let hasChanges = false 7821 7822 // Verificar se é cliente corporativo 7823 const isCorporate = cpd.isCorporate 7824 if (isCorporateModeActive && !isCorporate) { 7825 cpd.isCorporate = true 7826 hasChanges = true 7827 } 7828 7829 if (cpd.isCorporate && cpd.documentType !== 'cnpj') { 7830 hasChanges = true 7831 } 7832 7833 // Sincronizar CNPJ se válido 7834 if (cnpjValue.length === 14 && cpd.corporateDocument !== cnpjValue) { 7835 cpd.corporateDocument = cnpjValue 7836 hasChanges = true 7837 } 7838 7839 // Sincronizar Razão Social 7840 if (corporateName && cpd.corporateName !== corporateName) { 7841 cpd.corporateName = corporateName 7842 hasChanges = true 7843 } 7844 7845 // Sincronizar Nome Fantasia 7846 if (tradeName && cpd.tradeName !== tradeName) { 7847 cpd.tradeName = tradeName 7848 hasChanges = true 7849 } 7850 7851 // Sincronizar Inscrição Estadual 7852 if (stateInscription && cpd.stateInscription !== stateInscription) { 7853 cpd.stateInscription = stateInscription 7854 hasChanges = true 7855 } 7856 7857 // Sincronizar Telefone Corporativo (quando é PJ) 7858 if (isCorporate && phoneValue.length >= 10 && cpd.corporatePhone !== phoneValue) { 7859 cpd.corporatePhone = phoneValue 7860 hasChanges = true 7861 } 7862 7863 if (!hasChanges) { 7864 window._syncCorporateFieldsInProgress = false 7865 return orderForm 7866 } 7867 7868 return vtexjs.checkout.sendAttachment('clientProfileData', Checkout.setDocumentTypeFromCorporate(cpd)) 7869 }).done(function() { 7870 window._syncCorporateFieldsInProgress = false 7871 }).fail(function(err) { 7872 console.error('[Profile Debug] Erro ao sincronizar campos corporativos:', err) 7873 window._syncCorporateFieldsInProgress = false 7874 }) 7875 }, 7876 /** 7877 * Sincroniza todos os campos pessoais (PF) com o orderForm 7878 */ 7879 syncPersonalFieldsToOrderForm: () => { 7880 // Evitar chamadas simultâneas 7881 if (window._syncPersonalFieldsInProgress) { 7882 return Promise.resolve(null) 7883 } 7884 7885 const firstNameField = document.getElementById('client-first-name') 7886 const lastNameField = document.getElementById('client-last-name') 7887 const phoneField = document.getElementById('client-phone') 7888 const documentField = document.getElementById('client-document') 7889 const emailField = document.getElementById('client-email') 7890 7891 const firstName = firstNameField?.value?.trim() || '' 7892 const lastName = lastNameField?.value?.trim() || '' 7893 const phone = phoneField?.value?.replace(/\D/g, '') || '' 7894 const email = emailField?.value?.trim() || '' 7895 const documentValue = documentField?.value?.replace(/\D/g, '') || '' 7896 7897 window._syncPersonalFieldsInProgress = true 7898 7899 return vtexjs.checkout.getOrderForm().then(function(orderForm) { 7900 const cpd = { ...orderForm.clientProfileData } 7901 let hasChanges = false 7902 7903 // Sincronizar Nome 7904 if (firstName && cpd.firstName !== firstName) { 7905 cpd.firstName = firstName 7906 hasChanges = true 7907 } 7908 7909 // Sincronizar Sobrenome 7910 if (lastName && cpd.lastName !== lastName) { 7911 cpd.lastName = lastName 7912 hasChanges = true 7913 } 7914 7915 // Sincronizar Telefone (mÃnimo 10 dÃgitos) 7916 if (phone.length >
7916= 10 && cpd.phone !== phone) { 7917 cpd.phone = phone 7918 hasChanges = true 7919 } 7920 7921 // Sincronizar CPF (11 dÃgitos) 7922 if (documentValue.length === 11 && cpd.document !== documentValue) { 7923 cpd.document = documentValue 7924 hasChanges = true 7925 } 7926 7927 // Sincronizar Email (se válido) 7928 if (email && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email) && cpd.email !== email) { 7929 cpd.email = email 7930 hasChanges = true 7931 } 7932 7933 if (!hasChanges) { 7934 window._syncPersonalFieldsInProgress = false 7935 return orderForm 7936 } 7937 7938 return vtexjs.checkout.sendAttachment('clientProfileData', Checkout.setDocumentTypeFromCorporate(cpd)) 7939 }).done(function() { 7940 window._syncPersonalFieldsInProgress = false 7941 }).fail(function(err) { 7942 console.error('[Profile Debug] Erro ao sincronizar campos pessoais:', err) 7943 window._syncPersonalFieldsInProgress = false 7944 }) 7945 }, 7946 /** 7947 * Configura listeners para sincronizar campos pessoais com o orderForm 7948 */ 7949 setupPersonalFieldsSync: () => { 7950 // Evitar múltiplos bindings 7951 if (window._personalFieldsSyncSetup) return 7952 window._personalFieldsSyncSetup = true 7953 7954 7955 // Listeners via livequery para campos pessoais 7956 $('#client-first-name, #client-last-name, #client-phone, #client-document').livequery(function() { 7957 const field = this 7958 $(field).off('blur.personalSyncDirect').on('blur.personalSyncDirect', function() { 7959 Checkout.syncPersonalFieldsToOrderForm() 7960 }) 7961 7962 }) 7963 7964 // Sincronizar quando o usuário avança de etapa - usar mousedown para garantir que a sincronização aconteça antes do click 7965 $(document).off('mousedown.personalSync', '#go-to-shipping, #go-to-payment').on('mousedown.personalSync', '#go-to-shipping, #go-to-payment', function() { 7966 window._syncPersonalFieldsInProgress = false 7967 Checkout.syncPersonalFieldsToOrderForm() 7968 }) 7969 }, 7970 /** 7971 * Configura listeners para sincronizar campos corporativos com o orderForm 7972 */ 7973 setupCNPJSync: () => { 7974 // Evitar múltiplos bindings 7975 if (window._cnpjSyncSetup) return 7976 window._cnpjSyncSetup = true 7977 7978 // Lista de campos corporativos para sincronizar 7979 const corporateFields = [ 7980 '#client-company-document2', 7981 '#client-company-document', 7982 '#client-company-name', 7983 '#client-company-nickname', 7984 '#client-company-ie' 7985 ] 7986 7987 // Usar delegação de eventos para campos criados dinamicamente 7988 // Sincronizar CNPJ no blur 7989 $(document).off('blur.cnpjSync', '#client-company-document2').on('blur.cnpjSync', '#client-company-document2', function() { 7990 const value = this.value 7991 if (value && value.length >= 14) { 7992 Checkout.syncCNPJToOrderForm(value) 7993 } 7994 }) 7995 7996 $(document).off('blur.cnpjSyncMain', '#client-company-document').on('blur.cnpjSyncMain', '#client-company-document', function() { 7997 const value = this.value 7998 if (value && value.length >= 14) { 7999 Checkout.syncCNPJToOrderForm(value) 8000 } 8001 }) 8002 8003 // Sincronizar todos os campos corporativos no blur 8004 $(document).off('blur.corporateSync', '#client-company-name, #client-company-nickname, #client-company-ie') 8005 .on('blur.corporateSync', '#client-company-name, #client-company-nickname, #client-company-ie', function() { 8006 // Sincronizar imediatamente (sem delay) para evitar problemas de timing 8007 Checkout.syncCorporateFieldsToOrderForm() 8008 }) 8009 8010 // Também sincronizar no input para capturar mudanças em tempo real 8011 $(document).off('input.corporateSync', '#client-company-name, #client-company-nickname, #client-company-ie') 8012 .on('input.corporateSync', '#client-company-name, #client-company-nickname, #client-company-ie', function() { 8013 // Sincronizar com delay para não sobrecarregar 8014 clearTimeout(window._corporateFieldSyncTimer) 8015 window._corporateFieldSyncTimer = setTimeout(function() { 8016 Checkout.syncCorporateFieldsToOrderForm() 8017 }, 500) 8018 }) 8019 8020 // Listener adicional via livequery para garantir 8021 $('#client-company-document2').livequery(function() { 8022 const field = this 8023 $(field).off('blur.cnpjSyncDirect').on('blur.cnpjSyncDirect', function() { 8024 const value = this.value 8025 if (value && value.length >= 14) { 8026 Checkout.syncCNPJToOrderForm(value) 8027 } 8028 }) 8029 }) 8030 8031 $('#client-company-document').livequery(function() { 8032 const field = this 8033 $(field).off('blur.cnpjSyncDirectMain').on('blur.cnpjSyncDirectMain', function() { 8034 const value = this.value 8035 if (value && value.length >= 14) { 8036 Checkout.syncCNPJToOrderForm(value) 8037 } 8038 }) 8039 }) 8040 8041 // Listeners via livequery para campos corporativos 8042 $('#client-company-name, #client-company-nickname, #client-company-ie').livequery(function() { 8043 const field = this 8044 $(field).off('blur.corporateSyncDirect').on('blur.corporateSyncDirect', function() { 8045 Checkout.syncCorporateFieldsToOrderForm() 8046 }) 8047 8048 // Também no input 8049 $(field).off('input.corporateSyncDirect').on('input.corporateSyncDirect', function() { 8050 clearTimeout(window._corporateFieldSyncTimer) 8051 window._corporateFieldSyncTimer = setTimeout(function() { 8052 Checkout.syncCorporateFieldsToOrderForm() 8053 }, 500) 8054 }) 8055 }) 8056 8057 // Sincronizar quando o usuário avança de etapa - usar mousedown para garantir que a sincronização aconteça antes do click 8058 $(document).off('mousedown.corporateSync', '#go-to-shipping, #go-to-payment').on('mousedown.corporateSync', '#go-to-shipping, #go-to-payment', function(e) { 8059 // Sincronizar CNPJ 8060 const cnpjField = document.getElementById('client-company-document2') 8061 if (cnpjField && cnpjField.value && cnpjField.value.length >= 14) { 8062 Checkout.syncCNPJToOrderForm(cnpjField.value) 8063 } 8064 8065 // Sincronizar outros campos (forçar reset do flag para permitir sincronização) 8066 window._syncCorporateFieldsInProgress = false 8067 Checkout.syncCorporateFieldsToOrderForm() 8068 }) 8069 }, 8070 cnpjValidate: async () => { 8071 if (window.currentCNPJCount) return Checkout.cnpjEnableFields(), null 8072 if (!document.querySelector('.corporate-title').classList.contains('visible')) 8073 return document.querySelector('#go-to-shipping, #go-to-payment').classList.remove('disabled'), null 8074 const e = document.getElementById('client-company-document') 8075 if (e.value.length > 14 && e.value.length < 17 && !Checkout.cnpjValidation(e.value)) 8076 return ( 8077 document.querySelector('#go-to-shipping, #go-to-payment').classList.add('disabled'), 8078 (document.getElementById('client-company-name').value = ''), 8079 (document.getElementById('client-company-ie').value = ''), 8080 $('.client-company-document').append('<div class="_error">Digite um CNPJ válido</div>'), 8081 null 8082 ) 8083 if (e.value.length < 17) 8084 return ( 8085 document.querySelector('#go-to-shipping, #go-to-payment').classList.add('disabled'), 8086 (document.getElementById('client-company-name').value = ''), 8087 (document.getElementById('client-company-ie').value = ''), 8088 null 8089 ) 8090 if (window.currentCNPJ === e.value) return null 8091 ;(window.currentCNPJ = e.value), 8092 document.querySelector('.box-client-info .corporate-info-box').classList.add('_loading'), 8093 document.querySelector('#go-to-shipping, #go-to-payment').classList.add('disabled'), 8094 $('.client-company-document ._error').remove() 8095 try { 8096 const t = await axios({ 8097 method: 'get', 8098 url: 'https://us-central1-bblend-data-warehouse-dev.cloudfunctions.net/cnpj?id=' + e.value, 8099 }) 8100 if ( 8101 (('ATIVO - HABILITADO' !== t.data.status && 8102 'ATIVA - HABILITADO' !== t.data.status && 8103 'ATIVO - HABILITADA' !== t.data.status && 8104 'ATIVA - HABILITADA' !== t.data.status && 8105 'HABILITADA' !== t.data.status && 8106 'HABILITADO' !== t.data.status) || 8107 (t.data.status = 'ATIVA'), 8108 'ATIVA' !== t.data.status && $('._modal').length < 1) 8109 ) 8110 return ( 8111 $('.__profile').append( 8112 `<div class="_modal">\n <div class="modal-content">\n <div class="modal-close">\n <button onclick="closeModalCNPJ()">x</button>\n </div>\n <div class="modal-attention">\n <p class="att-title"> Ops! Ocorreu algum problema com o seu CNPJ</p>\n <p class="att-content"> Sugiro que você confirme se digitou o CNPJ corretamente e tente novamente. Caso o problema continue, entre em contato conosco: </p>\n <div class="att-contact">\n <p><a href="https://wa.me/5511933430190?text=Ol%C3%A1">Whatsapp (11) 93343-0190</a></p>\n </div>\n <p class="att-reason">Motivo:</p>\n <p class="att-reason-status">- CNPJ com status não previsto na receita federal: <span class="consultStatus"> ${t.data.status} </span></p>\n <p class="att-reason-doubt">Sinto muito ter ocorrido esse problema e espero que você possa efetuar sua compra em breve. Até mais.</p>\n </div>\n </div>\n </div>` 8113 ), 8114 (window.currentCNPJCount = !0), 8115 $('#client-company-document-modal').livequery(function () { 8116 IMask(document.getElementById('client-company-document-modal'), { 8117 mask: '00.000.000/0000-00', 8118 }) 8119 }), 8120 document.querySelector('#go-to-shipping, #go-to-payment').classList.add('disabled'), 8121 document.querySelector('.box-client-info .corporate-info-box').classList.remove('_loading'), 8122 null 8123 ) 8124 ;(window.currentCNPJData = t.data), 8125 (document.getElementById('client-company-name').value = t.data.razaoSocial), 8126 $('#client-company-name').keyup(), 8127 $('#client-company-name').trigger('change'), 8128 $('#client-company-name').blur(), 8129 t.data.nomeFantasia && 8130 ((document.getElementById('client-company-nickname').value = t.data.nomeFantasia), 8131 $('.client-company-nickname').keyup(), 8132 $('#client-company-nickname').trigger('change'),
8133 $('.client-company-nickname').blur()), 8134 t.data.inscricaoEstadual 8135 ? ((document.getElementById('client-company-ie').value = t.data.inscricaoEstadual), 8136 $('.client-company-ie').keyup(), 8137 $('#client-company-ie').trigger('change'), 8138 $('.client-company-ie').blur(), 8139 document.getElementById('state-inscription').checked && 8140 document.getElementById('state-inscription').click()) 8141 : document.getElementById('state-inscription').checked || 8142 document.getElementById('state-inscription').click(), 8143 document.querySelector('#go-to-shipping, #go-to-payment').classList.remove('disabled'), 8144 document.querySelector('.box-client-info .corporate-info-box').classList.remove('_loading') 8145 } catch (e) { 8146 console.error(e), 8147 document.querySelector('#go-to-shipping, #go-to-payment').classList.add('disabled'), 8148 document.querySelector('.box-client-info .corporate-info-box').classList.remove('_loading') 8149 } 8150 }, 8151 cnpjValidation: async (e) => { 8152 if (!e) return !1 8153 const t = 'string' == typeof e 8154 if (!(t || Number.isInteger(e) || Array.isArray(e))) return !1 8155 if (t) { 8156 if (e.length > 18) return !1 8157 const t = /^\d{14}$/.test(e), 8158 n = /^\d{2}.\d{3}.\d{3}\/\d{4}-\d{2}$/.test(e) 8159 if (!t && !n) return !1 8160 } 8161 const n = e.toString().match(/\d/g), 8162 i = Array.isArray(n) ? n.map(Number) : [] 8163 if (14 !== i.length) return !1 8164 if (1 === [...new Set(i)].length) return !1 8165 const o = (e) => { 8166 const t = i.slice(0, e) 8167 let n = e - 7, 8168 o = 0 8169 for (let i = e; i >= 1; i--) { 8170 ;(o += t[e - i] * n--), n < 2 && (n = 9) 8171 } 8172 const s = 11 - (o % 11) 8173 return s > 9 ? 0 : s 8174 }, 8175 s = i.slice(12) 8176 if (o(12) !== s[0]) return !1 8177 return o(13) === s[1] 8178 }, 8179 b2cVouncherRules: async () => { 8180 window.customCart.items.b2c.length && 8181 window.customCart.items.b2c.forEach(function (e) { 8182 e.item.attachments.length || 8183 vtexjs.checkout 8184 .removeItems([ 8185 { 8186 index: e.index, 8187 quantity: 1, 8188 }, 8189 ]) 8190 .done(function () { 8191 $(window).trigger('addMessage', { 8192 content: { 8193 detail: 'O produto ' + e.item.name + ' só pode ser adquirido em forma de assinatura mensal', 8194 }, 8195 type: 'error', 8196 }) 8197 }) 8198 }) 8199 }, 8200 changeSalesChannel: () => { 8201 const e = vtexjs.checkout.orderForm, 8202 t = e.items, 8203 n = e.salesChannel, 8204 i = e.marketingData.marketingTags.some((e) => 'APP' === e), 8205 o = t.some((e) => e.attachments.some((e) => 'pay2b.subscription' === e.name)), 8206 s = o ? 5 : i ? 4 : 1 8207 n != s && vtexjs.checkout.addToCart(t, null, s) 8208 }, 8209 insertSummaryButtons: () => { 8210 const e = $('.__cart .cart-totalizers') 8211 e.livequery(function () { 8212 const e = $('.summary-buttons') 8213 $(this).find(e).length || 8214 $(this).append( 8215 '\n <div class="summary-buttons">\n <a href="#/orderform" class="_keepBuying">Finalizar pedido</a>\n <a href="/" class="_backToHome">Continuar comprando</a>\n </div>\n ' 8216 ) 8217 }) 8218 }, 8219 insertFreeShippingBar: () => { 8220 const e = $('.__cart .cart-totalizers') 8221 e.livequery(function () { 8222 const e = $('._cashback') 8223 $(this).find(e).length || 8224 $(this).append( 8225 '\n <div class="_cashback">\n <p class="_text-promo"></p>\n <div class="progress">\n <div class="progress-bar"></div>\n </div>\n </div>\n ' 8226 ) 8227 cashBackTopBar.updateShippingRuleLogic() 8228 }) 8229 }, 8230 insertFixedBuyButton: () => { 8231 const e = $('.__cart') 8232 e.livequery(function () { 8233 const e = $('.empty-cart-content').is(':visible'), 8234 t = $('._fixed-buy-button') 8235 e && t.remove(), 8236 $(this).find(t).length || 8237 e || 8238 $(this).append( 8239 '\n <div class="_fixed-buy-button">\n <a href="#/orderform" class="_keepBuying">Finalizar pedido</a>\n </div>\n ' 8240 ) 8241 }) 8242 }, 8243} 8244Checkout.init() 8245const waitForElm = (e) => 8246 new Promise((t) => { 8247 if (document.querySelector(e)) return t(document.querySelector(e)) 8248 const n = new MutationObserver((i) => { 8249 document.querySelector(e) && (t(document.querySelector(e)), n.disconnect()) 8250 }) 8251 n.observe(document.body, { 8252 childList: !0, 8253 subtree: !0, 8254 }) 8255 }) 8256const waitForVtexjs = (e = 5e3) => 8257 new Promise((t, n) => { 8258 if (window.vtexjs && window.vtexjs.checkout) return t() 8259 const i = Date.now() 8260 const o = setInterval(() => { 8261 if (window.vtexjs && window.vtexjs.checkout) return clearInterval(o), t() 8262 Date.now() - i >= e && (clearInterval(o), n(new Error('vtexjs not available'))) 8263 }, 50) 8264 }) 8265function showSignatureDiscounts(e) { 8266 const t = e.totalizers.find((e) => 'Discounts' === e.id), 8267 n = e.items.filter((e) => e.attachments.find((e) =>
8267 'pay2b.subscription' === e.name)) 8268 n.length || t 8269 ? setTimeout(() => { 8270 const e = n.reduce((e, t) => { 8271 const n = t.priceTags.find((e) => 'Assinatura 10%' === e.ratesAndBenefitsIdentifier.name) 8272 return n ? n.value + e : e 8273 }, 0) 8274 if (0 === e) return 8275 const i = document.querySelectorAll('tr.Discounts') 8276 if (!i) return 8277 const o = t.value - e 8278 i.forEach((t) => { 8279 t.parentNode.querySelector('._signature-discounts') 8280 ? (t.parentNode.querySelector('._signature-discounts .monetary').innerText = 8281 'R$ ' + 8282 (e / 100).toLocaleString('pt-BR', { 8283 minimumFractionDigits: 2, 8284 })) 8285 : t.insertAdjacentHTML( 8286 'beforebegin', 8287 `<tr class="_signature-discounts">\n <td class="info" data-bind="{text: label()}">Descontos de assinante</td>\n <td class="space"></td>\n <td class="monetary" data-bind="text: valueLabel">\n R$ ${( 8288 e / 100 8289 ).toLocaleString('pt-BR', { 8290 minimumFractionDigits: 2, 8291 })}\n </td>\n <td class="empty"></td>\n </tr>` 8292 ) 8293 }), 8294 0 === o 8295 ? i.forEach((e) => e.classList.add('hidden')) 8296 : i.forEach((e) => { 8297 ;(e.querySelector('td.monetary').innerText = 8298 'R$ ' + 8299 (o / 100).toLocaleString('pt-BR', { 8300 minimumFractionDigits: 2, 8301 })), 8302 (e.querySelector('td.info').innerText = 'Outros descontos') 8303 }) 8304 }, 500) 8305 : document.querySelector('tr._signature-discounts') && 8306 document.querySelector('tr._signature-discounts').classList.add('hidden') 8307} 8308function shouldShowSubscriptionOnItem(item, itemIndex) { 8309 if (!vtexjs.checkout.orderForm || !vtexjs.checkout.orderForm.items) { 8310 return true 8311 } 8312 const items = vtexjs.checkout.orderForm.items 8313 const productId = item.productId 8314 if (!productId) { 8315 return true 8316 } 8317 const duplicates = items.filter((t, n) => { 8318 return t.productId === productId && n !== itemIndex && null === t.parentItemIndex && null === item.parentItemIndex 8319 }) 8320 if (duplicates.length === 0) { 8321 return true 8322 } 8323 const allDuplicates = [ 8324 { index: itemIndex, pricePerUnit: item.price }, 8325 ...duplicates.map((t, n) => { 8326 const originalIndex = items.findIndex((i) => i === t) 8327 return { index: originalIndex, pricePerUnit: t.price } 8328 }), 8329 ] 8330 allDuplicates.sort((a, b) => { 8331 if (b.pricePerUnit !== a.pricePerUnit) { 8332 return b.pricePerUnit - a.pricePerUnit 8333 } 8334 return a.index - b.index 8335 }) 8336 return allDuplicates[0].index === itemIndex 8337} 8338async function changeText(e) { 8339 for (const [t, item] of e.items.entries()) { 8340 if (!shouldShowSubscriptionOnItem(item, t)) { 8341 continue 8342 } 8343 const skuPriceData = await fetchSkuSubscriptionPrice(item.id, item.seller || '1') 8344 const n = skuPriceData?.precoFinal ?? (item.price - (10 * item.price) / 100) / 100 8345 $('.product-item').each((t, i) => { 8346 $(i).attr('data-sku') == item.id && 8347 $(i) 8348 .find('.add-item-attachment') 8349 .html( 8350 'Assine e pague apenas <span class="btn-signature">' + 8351 n.toLocaleString('pt-br', { 8352 style: 'currency', 8353 currency: 'BRL', 8354 }) + 8355 '</span>' 8356 ) 8357 }) 8358 } 8359} 8360function ObservableElement(e, t) { 8361 const n = new MutationObserver((e) => { 8362 e.forEach((e) => { 8363 t && t(e) 8364 }) 8365 }), 8366 i = document.querySelector(e) 8367 i && 8368 n.observe(i, { 8369 childList: !0, 8370 subtree: !0, 8371 }) 8372} 8373async function reloadSignature() { 8374 const items = vtexjs.checkout.orderForm.items 8375 if (!items || items.length === 0) return 8376 for (const [t, item] of items.entries()) { 8377 if (!shouldShowSubscriptionOnItem(item, t)) { 8378 const el = $('.product-item').filter((i, el) => $(el).attr('data-sku') == item.id) 8379 el.find('.add-item-attachment').remove() 8380 continue 8381 } 8382 const skuPriceData = await fetchSkuSubscriptionPrice(item.id, item.seller || '1') 8383 const n = skuPriceData?.precoFinal ?? (item.price - (10 * item.price) / 100) / 100 8384 $('.product-item').each((t, i) => { 8385 $(i).attr('data-sku') == item.id && 8386 (i.querySelector('.add-item-attachment-container .btn-signature') || 8387 $(i) 8388 .find('.add-item-attachment') 8389 .html( 8390 'Assine e pague apenas <span class="btn-signature">' +
8391 n.toLocaleString('pt-br', { 8392 style: 'currency', 8393 currency: 'BRL', 8394 }) + 8395 '</span>' 8396 )) 8397 }) 8398 } 8399} 8400function rafAsync() { 8401 return new Promise((e) => { 8402 requestAnimationFrame(e) 8403 }) 8404} 8405function checkElement(e) { 8406 return null === document.querySelector(e) ? rafAsync().then(() => checkElement(e)) : Promise.resolve(!0) 8407} 8408function handleSubscriptionModal() { 8409 const e = document.querySelector('._assinatura-btn') 8410 if (!e) return 8411 const t = document.querySelector('#signature-modal'), 8412 n = document.querySelectorAll('.frequencyTime li'), 8413 i = document.querySelector('.closeHref') 8414 t.querySelector('._buy').addEventListener('click', (e) => { 8415 handleSubscriptionToAllCartItems() 8416 }), 8417 i.addEventListener('click', (e) => { 8418 t.classList.add('_hide') 8419 }), 8420 e.addEventListener('click', (e) => { 8421 const n = document.querySelector('#modal-waiting') 8422 n && n.classList.add('_hide'), t.classList.remove('_hide') 8423 }),
8424 n.forEach((e) => { 8425 e.addEventListener('click', (t) => { 8426 document.querySelector('.frequencyTime ._selected').classList.remove('_selected'), e.classList.add('_selected') 8427 }) 8428 }) 8429} 8430async function handleSubscriptionToAllCartItems() { 8431 const e = document.querySelector('.frequencyTime ._selected').dataset.frequency, 8432 t = vtexjs.checkout.orderForm.items.reduce((e, t, n) => { 8433 if ('290' == t.productId) return e 8434 if (t.parentAssemblyBinding && t.parentAssemblyBinding.indexOf('Caixa_Caixa') > -1) return e 8435 if (!shouldShowSubscriptionOnItem(t, n)) return e 8436 return t.attachmentOfferings.find((e) => 'pay2b.subscription' === e.name) && e.push(n), e 8437 }, []), 8438 n = document.querySelector('#signature-modal'), 8439 i = document.querySelector('#modal-waiting'), 8440 o = document.querySelector('.spinner-3'), 8441 s = document.querySelector('._loading-3') 8442 try { 8443 if ((o && ((o.style.display = 'block'), (s.style.display = 'block')), t.length < 1)) return 8444 const a = t.map((t) => 8445 vtexjs.checkout.addItemAttachment( 8446 t, 8447 'pay2b.subscription', 8448 { 8449 'pay2b.subscription.recurring.value': e, 8450 }, 8451 null, 8452 !1 8453 ) 8454 ), 8455 r = await Promise.all(a), 8456 c = r.length - 1 8457 await subscriptionDataUpdate(r[c]) 8458 } finally { 8459 o && ((o.style.display = 'none'), (s.style.display = 'none')), n.classList.add('_hide'), i.classList.add('_hide') 8460 } 8461} 8462function waitingModalOpen() { 8463 const e = document.querySelector('._buy'), 8464 t = document.querySelector('#modal-waiting') 8465 e.addEventListener('click', (e) => { 8466 t.classList.remove('_hide') 8467 }) 8468} 8469function getCouponsData() { 8470 return fetch('/api/dataentities/SV/search?_fields=coupon,skuid', { 8471 headers: { 8472 contentType: 'application/json', 8473 }, 8474 }) 8475} 8476function loadCouponData() { 8477 getCouponsData() 8478 .then((e) => e.json()) 8479 .then((e) => { 8480 couponData = e 8481 }) 8482 .catch((e) => { 8483 console.error(e), (couponData = null) 8484 }) 8485} 8486async function couponCta(e) { 8487 if (!couponData) 8488 try { 8489 const e = await getCouponsData(), 8490 t = await e.json() 8491 t && (couponData = t) 8492 } catch (e) { 8493 return console.error(e), void (couponData = null) 8494 } 8495 if ('Forbidden' != couponData.Message) { 8496 const t = couponData.map((e) => e.skuid), 8497 n = e.items.filter((e) => t.includes(e.id)) 8498 checkElement('.product-item .product-name').then((e) => { 8499 n.forEach((t) => { 8500 if (e) { 8501 const e = couponData.find((e) => e.skuid === t.id), 8502 n = document.querySelector(`tr[data-sku="${t.id}"]`) 8503 if (!n) return 8504 const i = document.createElement('div') 8505 ;(i.className = 'coupon-cta coupon-' + t.id), 8506 (i.innerHTML = `<div class="coupon-cta-content">INSIRA O CUPOM:<strong> ${e.coupon}</strong><div class="loader"></div></div>`), 8507 i.addEventListener('click', async (e) => { 8508 try { 8509 i.classList.add('loading') 8510 const e = couponData.find((e) => e.skuid === t.id) 8511 await vtexjs.checkout.removeDiscountCoupon(), 8512 await vtexjs.checkout.addDiscountCoupon(e.coupon), 8513 sendDataLayer({ 8514 event: 'clique-tag-cupom', 8515 }), 8516 i.classList.remove('loading') 8517 } catch (e) { 8518 i.classList.remove('loading'), console.error(e) 8519 } 8520 }), 8521 n.querySelector('.product-name').append(i) 8522 } 8523 }) 8524 }) 8525 } 8526} 8527function hideSignatureButton(e) { 8528 const t = e.items.reduce((e, t) => (Object.keys(t.productCategories).includes('2') && (e = !0), e), !1) 8529 if (0 === e.items.length || !t) { 8530 const e = document.querySelector('._assinatura-pedido') 8531 e && e.remove() 8532 } 8533} 8534async function showSubscriptionBenefitsbanner(e) { 8535 if ((hasCaps(e) || hasAcessoriesInputs(e)) && !hasSubscription(e)) { 8536 const discountValue = await calcSubscriptionDiscounts(e) 8537 const t = document.createElement('div') 8538 ;(t.className = 'subscription-banner _hide'), 8539 (t.innerHTML = `\n <div class="subscription-benefits-container">\n <div class="info">\n <p>Comprando as bebidas com uma Assinatura, <span>você economizará</span></p>
8539\n <span class="subscription-discount-value">R$${discountValue}</span>\n </div>\n <a href="https://loja.bblend.com.br/assinatura">Conheça a Assinatura B.blend</a>\n </div>\n `) 8540 document.querySelector('footer').prepend(t), t.classList.remove('_hide') 8541 } 8542} 8543;(() => { 8544 const e = () => { 8545 const e = document.querySelector('._frete-gratis-sp') 8546 e && e.remove() 8547 }, 8548 t = () => { 8549 const t = new Date(), 8550 n = `\n <section class="_frete-gratis-sp">\n <div class="container">\n <div class="_wrapper">\n <div>\n\t\t\t\t\t\t<strong class="_yellow">Entrega expressa</strong> \n\t\t\t\t\t\t<span>*</span>\n\n </div>\n\n <div>\n\t\t\t\t\t\t${ 8551 60 * (t.getHours() + t.getMinutes() / 60) > 580 8552 ? '<p>Toda a praticidade B.blend, até na entrega. **</p>' 8553 : '<p>Pediu hoje? Chegou hoje. **</p>' 8554 }\n\t\t\t\n \n </div>\n </div>\n </div>\n </section>\n ` 8555 e(), 8556 $('#cartLoadedDiv').livequery(function (e) { 8557 $(this).after(n) 8558 }) 8559 } 8560 $(window).on('orderFormUpdated.vtex', function (n, i) { 8561 if (!i.shippingData) return 8562 const { logisticsInfo: o } = i.shippingData 8563 if (!o) return 8564 o.filter(({ slas: e }) => e.some(({ deliveryIds: e }) => e.some(({ courierId: e }) => '16d8633' === e))).length 8565 ? t() 8566 : e(), 8567 showSignatureDiscounts(i) 8568 }) 8569})(), 8570 $(document).ready(function () { 8571 '#/payment' === window.location.hash && checkHasBenefits() 8572 }), 8573 window.addEventListener('load', function () { 8574 ObservableElement('.cart-template-holder .cart-items tbody', reloadSignature) 8575 }), 8576 checkElement('._assinatura-btn').then((e) => { 8577 e && handleSubscriptionModal() 8578 }), 8579 loadCouponData(), 8580 (window.onload = async () => { 8581 const { items: e } = await vtexjs.checkout.orderForm 8582 await showSubscriptionBenefitsbanner(e) 8583 }) 8584const insetBanner = (e, t) => { 8585 t.parentNode.insertBefore(e, t.nextSibling) 8586} 8587function hasAcessoriesInputs(e) { 8588 const t = e.find((e) => '69' == e.id), 8589 n = e.find((e) => '43' == e.id) 8590 return t || n 8591} 8592function hasSubscription(e) { 8593 let t = !1 8594 return ( 8595 e.forEach((e) => { 8596 e.attachments.find((e) => 'pay2b.subscription' === e.name) && (t = !0) 8597 }), 8598 t 8599 ) 8600} 8601function hasCaps(e) { 8602 let t = !1 8603 return ( 8604 e.forEach((e) => { 8605 e.productCategoryIds.includes('/2/') && (t = !0) 8606 }), 8607 t 8608 ) 8609} 8610async function calcSubscriptionDiscounts(items) { 8611 let total = 0 8612 8613 for (const item of items) { 8614 // SKUs 69/43 (acessórios): desconto fixo de R$20 8615 if (item.id === '69' || item.id === '43') { 8616 total += 20 * item.quantity 8617 continue 8618 } 8619 8620 // Bebidas (categoria /2/): busca desconto da API 8621 if (item.productCategoryIds.includes('/2/')) { 8622 try { 8623 const product = await fetchProductBySku(item.id) 8624 if (product && product[0] && product[0].valor_desconto_recorrencia) { 8625 const discountPercent = Number(product[0].valor_desconto_recorrencia[0]) || 0 8626 total += item.quantity * (item.sellingPrice / 100) * (discountPercent / 100) 8627 } else { 8628 // Fallback para 10% se não encontrar o valor na API 8629 total += item.quantity * (item.sellingPrice / 100) * 0.1 8630 } 8631 } catch (error) { 8632 console.error('Erro ao buscar desconto de subscription para SKU:', item.id, error) 8633 // Fallback para 10% em caso de erro 8634 total += item.quantity * (item.sellingPrice / 100) * 0.1 8635 } 8636 } 8637 } 8638 8639 return total.toFixed(2) 8640} 8641function groupById(e) { 8642 const t = {} 8643 return ( 8644 e.forEach((e) => { 8645 e.slas.forEach((e) => { 8646 t[e.id] || (t[e.id] = 0), (t[e.id] += e.price) 8647 }) 8648 }), 8649 t 8650 ) 8651} 8652function createShippingSlaSelectorHtml(e) { 8653 const t = e 8654 .map((e) => e.slas) 8655 .flat() 8656 .filter((e) => 'delivery' === e.deliveryChannel) 8657 .reduce((e, t) => { 8658 const n = e.find((e) => e.id === t.id) 8659 return ( 8660 n 8661 ? (n.price += t.price) 8662 : e.push({ 8663 ...t, 8664 }), 8665 e 8666 ) 8667 }, []), 8668 n = document.querySelectorAll('#shipping-sla-selector')
8669 n.length && n.forEach((e) => e.remove()), 8670 checkElement('#shipping-preview-container .srp-delivery-select-container').then((e) => { 8671 if (e) { 8672 const e = document.querySelector('.srp-delivery-select').value 8673 let n = '' 8674 for (sla of t) { 8675 const t = Number(sla.shippingEstimate.replace('bd', '')) 8676 let i = '1 dia útil' 8677 t || (i = 'No mesmo dia'), 8678 t > 1 && (i = t + ' dias úteis'), 8679 (n += `<div class='sla-option ${sla.id == e && 'active'}' data-id="${ 8680 sla.id 8681 }">\n <div class='sla-text'>\n <span class='title'>${ 8682 sla.name 8683 }</span>\n <span class='time'>${i}</span>\n </div>\n <span class='price'>R$ ${formatter.format( 8684 sla.price / 100 8685 )}</span>\n </div>`) 8686 } 8687 const i = `<div id="shipping-sla-selector">${n}</div>`, 8688 o = document.querySelector('#shipping-preview-container .srp-content .srp-result') 8689 o && o.insertAdjacentHTML('beforeend', i), shippingSlaSelectorActions() 8690 } 8691 }) 8692} 8693function shippingSlaSelectorActions() { 8694 document.querySelectorAll('#shipping-sla-selector .sla-option').forEach((e) => { 8695 e.addEventListener('click', function () { 8696 const t = document.querySelector('#shipping-sla-selector .sla-option.active') 8697 t && t.classList.remove('active'), e.classList.add('active') 8698 const n = e.getAttribute('data-id'), 8699 i = JSON.parse(JSON.stringify(vtexjs.checkout.orderForm.shippingData)) 8700 i.logisticsInfo.forEach((e) => { 8701 e.selectedSla = n 8702 }), 8703 vtexjs.checkout.sendAttachment('shippingData', i) 8704 }) 8705 }) 8706} 8707function createShippingSlaSelector() { 8708 const orderForm = vtexjs.checkout.orderForm 8709 8710 if (!orderForm || !orderForm.shippingData || !orderForm.shippingData.logisticsInfo) { 8711 console.warn('shippingData ou logisticsInfo ainda não estão disponÃÂveis.') 8712 return 8713 } 8714 8715 const deliveryItems = orderForm.shippingData.logisticsInfo.filter((e) => e.selectedDeliveryChannel === 'delivery') 8716 8717 if (deliveryItems.length) { 8718 createShippingSlaSelectorHtml(deliveryItems) 8719 } 8720} 8721 8722// function createShippingSlaSelector() { 8723// const e = vtexjs.checkout.orderForm.shippingData.logisticsInfo.filter(e => "delivery" == //e.selectedDeliveryChannel); 8724// e.length && createShippingSlaSelectorHtml(e) 8725//} 8726 8727function countP2bItemsAndUpdateOrderForm(e) { 8728 const t = e.items.reduce((e, t) => { 8729 const n = t.attachments 8730 if (!n.length) return e 8731 return n.find((e) => 'pay2b.subscription' === e.name) && e++, e 8732 }, 0) 8733 e.subscriptionData && t != e.subscriptionData.length && subscriptionDataUpdate(e) 8734} 8735window.addEventListener('load', function () { 8736 createShippingSlaSelector() 8737}), 8738 $(window).on('orderFormUpdated.vtex', async function (e, t) { 8739 createShippingSlaSelector(), Checkout.insertFixedBuyButton() 8740 }), 8741 $('#item-attachment-0-pay2bpsubscription-pay2bpsubscriptionprecurringpvalue').livequery(function (e) { 8742 $('[value="1 month"]').text('A cada 1 mês'), 8743 $('[value="45 day"]').text('A cada 45 dias'), 8744 $('[value="2 month"]').text('A cada 2 meses'), 8745 $('[value="75 days"]').text('A cada 75 dias'), 8746 $('[value="3 month"]').text('A cada 3 meses') 8747 }) 8748const p2bAttachmentButtonActions = { 8749 init: async () => { 8750 await p2bAttachmentButtonActions.getProductLinesElementsWithAttachment(), 8751 p2bAttachmentButtonActions.hideItem0Message() 8752 }, 8753 addP2bAttachments: (e) => { 8754 vtexjs.checkout 8755 .addItemAttachment( 8756 e, 8757 'pay2b.subscription', 8758 { 8759 'pay2b.subscription.recurring.value': 'a cada 1 mês', 8760 }, 8761 null, 8762 !1 8763 ) 8764 .done(function (e) { 8765 subscriptionDataUpdate(e).done(function () { 8766 5 != e.salesChannel && p2bAttachmentButtonActions.changeP2bSalesChannel() 8767 }) 8768 }) 8769 }, 8770 getProductLinesElementsWithAttachment: async () => { 8771 const e = []
8772 vtexjs.checkout.orderForm.items.forEach((t, n) => { 8773 if (!shouldShowSubscriptionOnItem(t, n)) return 8774 const i = t.attachmentOfferings 8775 if (!i.length) return 8776 const o = i.find((e) => 'pay2b.subscription' === e.name), 8777 s = t.attachments 8778 let a = !1 8779 s.length && (a = s.find((e) => 'pay2b.subscription' === e.name)), 8780 o && 8781 e.push({ 8782 skuId: t.id, 8783 index: n, 8784 hasP2bActive: a, 8785 seller: t.seller || '1', 8786 price: t.price, // centavos â fallback quando a API falhar 8787 }) 8788 }), 8789 e.length && 8790 e.forEach(async ({ skuId: e, index: t, hasP2bActive: n, seller: s, price: p }) => { 8791 const i = document.querySelector(`.product-item[data-sku='${e}']`) 8792 if (!i || n || i.querySelector('.add-p2b-attachment')) return 8793 const skuPriceData = await fetchSkuSubscriptionPrice(e, s) 8794 const isValidPrice = (v) => typeof v === 'number' && isFinite(v) && v > 0 8795 // Fallback: preço original do item (orderForm, centavos â reais) 8796 const finalPrice = isValidPrice(skuPriceData?.precoFinal) ? skuPriceData.precoFinal : p / 100 8797 const hasValidPrice = isValidPrice(finalPrice) 8798 hasValidPrice || console.warn('[P2B Button] Preço inválido para SKU:', e, skuPriceData, p) 8799 // Re-checa após o await: outra execução pode ter inserido o botão com o fetch em voo. 8800 if (i.querySelector('.add-p2b-attachment') || !document.body.contains(i)) return 8801 const productName = i.querySelector('.product-name') 8802 if (!productName) return 8803 productName.insertAdjacentHTML( 8804 'beforeend', 8805 `\n <button class="add-p2b-attachment" onclick="p2bAttachmentButtonActions.addP2bAttachments(${t})" data-item-id="${e}" data-item-index="${t}">\n <strong>ou</strong> <span>assine agora${ 8806 hasValidPrice ? ` e pague apenas R$ ${toBrazilianNumberFormat(finalPrice)}` : '' 8807 }</span>\n <img src="https://bblend.vteximg.com.br/arquivos/compra-programada-logo4.png" alt="Compra Programada"/> </button>\n ` 8808 ) 8809 }) 8810 }, 8811 normalizeSubscriptionDiscount: (discountArray) => { 8812 /** 8813 * Normalizes valor_desconto_recorrencia to discount object 8814 * @param {Array} discountArray - e.g., ['10'] or ['R$50'] or ['R$ 50'] 8815 * @returns {{ type: 'percentage' | 'fixed', value: number }} or null 8816 */ 8817 if (!discountArray || !Array.isArray(discountArray) || discountArray.length === 0) { 8818 return null 8819 } 8820 8821 const rawValue = String(discountArray[0]).trim() 8822 8823 // Check if it's a monetary value (starts with R$ or has currency symbol) 8824 if (rawValue.startsWith('R$') || rawValue.includes('R$')) { 8825 // Extract numeric value: "R$ 50" â 50 8826 const numericValue = parseFloat(rawValue.replace(/[^\d.,]/g, '').replace(',', '.')) 8827 if (isNaN(numericValue)) return null 8828 return { type: 'fixed', value: numericValue } 8829 } 8830 8831 // Otherwise, treat as percentage 8832 const percentValue = parseFloat(rawValue) 8833 if (isNaN(percentValue)) return null 8834 return { type: 'percentage', value: percentValue } 8835 }, 8836 getValueDiscountMultiplier: (e) => { 8837 /** 8838 * DEPRECATED: Use normalizeSubscriptionDiscount for new code 8839 * Returns multiplier for percentage discount (backward compatibility) 8840 */ 8841 try { 8842 let t = e[0].valor_desconto_recorrencia 8843 if (!t) return 1 8844 8845 const discountInfo = p2bAttachmentButtonActions.normalizeSubscriptionDiscount(t) 8846 if (!discountInfo) return 1 8847 8848 // Only support percentage type for backward compatibility 8849 if (discountInfo.type === 'percentage') { 8850 return (100 - discountInfo.value) / 100 8851 } 8852 8853 // For fixed type, return 1 (no multiplier, handled differently) 8854 return 1 8855 } catch (e) { 8856 return console.error('[P2B] Error in getValueDiscountMultiplier:', e), 1 8857 } 8858 }, 8859 countP2bItemsAndUpdateOrderForm(e) { 8860 e.items.reduce((e, t) => { 8861 const n = t.attachments 8862 if (!n.length) return e 8863 return n.find((e) =>
8863 'pay2b.subscription' === e.name) && e++, e 8864 }, 0) != e.subscriptionData.length && subscriptionDataUpdate(e) 8865 }, 8866 changeP2bSalesChannel: () => { 8867 vtexjs.checkout.addToCart( 8868 [ 8869 { 8870 id: 0, 8871 quantity: 1, 8872 seller: '1', 8873 }, 8874 ], 8875 null, 8876 5 8877 ) 8878 }, 8879 hideItem0Message() { 8880 checkElement('.vtex-front-messages-template .vtex-front-messages-detail').then((e) => { 8881 if (e) { 8882 const e = document.querySelector('.vtex-front-messages-template .vtex-front-messages-detail') 8883 e.innerText.includes('Item 0') && e.parentNode.remove() 8884 } 8885 }) 8886 }, 8887} 8888$(window).on('orderFormUpdated.vtex', async function (e, t) { 8889 checkElement('.table.cart-items').then(p2bAttachmentButtonActions.init) 8890}), 8891 $(document).on('click', '.item-link-remove', function () { 8892 setTimeout(() => { 8893 p2bAttachmentButtonActions.countP2bItemsAndUpdateOrderForm(vtexjs.checkout.orderForm) 8894 }, 1e3) 8895 }), 8896 $(window).on('hashchange', function () { 8897 p2bAttachmentButtonActions.countP2bItemsAndUpdateOrderForm(vtexjs.checkout.orderForm) 8898 window.location.hash.includes('payment') && Checkout.changeSalesChannel() 8899 }) 8900const PaymentMessage = { 8901 message: 8902 'Para que sua experiência de compra seja a mais agradável e prática possÃÂvel, certifique-se que <br/> o cartão utilizado:', 8903 wrapperSelector: '#payment-data .accordion-heading', 8904 containerName: 'payment-messages-container', 8905 init: (e) => { 8906 PaymentMessage.hasCreditCardSelected(e) 8907 }, 8908 hasMessage: () => { 8909 try { 8910 return !!document.querySelector('.' + PaymentMessage.containerName) 8911 } catch (e) { 8912 console.error(e) 8913 } 8914 }, 8915 hasCreditCardSelected: (e) => { 8916 try { 8917 e.paymentData.payments.forEach(function (t) { 8918 if ( 8919 '1' == t.paymentSystem || 8920 '2' == t.paymentSystem || 8921 '3' == t.paymentSystem || 8922 '4' == t.paymentSystem || 8923 '8' == t.paymentSystem || 8924 '9' == t.paymentSystem 8925 ) { 8926 if (PaymentMessage.hasMessage()) return 8927 PaymentMessage.buildMessage(e) 8928 } else { 8929 if (!PaymentMessage.hasMessage()) return 8930 PaymentMessage.removeMessage() 8931 } 8932 }) 8933 } catch (e) { 8934 console.error(e) 8935 } 8936 }, 8937 buildMessage: () => { 8938 try { 8939 const e = document.querySelector(PaymentMessage.wrapperSelector) 8940 let t = document.createElement('div') 8941 t.classList.add(PaymentMessage.containerName), 8942 (t.innerHTML = 8943 ' <div class="_title">\n <p> ' + 8944 PaymentMessage.message + 8945 '</p>\n </div>\n <ul class="_steps">\n <li>\n <p>\n Tenha limite/saldo disponÃÂvel\n </p>\n </li>\n <li>\n <p>\n Não esteja bloqueado\n </p>\n </li>\n <li>\n <p>\n Tenha o modo de compra escolhido habilitada.\n </p>\n </li>\n </div>\n '), 8946 e.after(t) 8947 } catch (e) { 8948 console.error(e) 8949 } 8950 }, 8951 removeMessage: () => { 8952 try { 8953 let e = document.querySelector('.' + PaymentMessage.containerName) 8954 e && e.remove() 8955 } catch (e) { 8956 console.error(e) 8957 } 8958 }, 8959 }, 8960 DataLayerMethods = { 8961 oldItems: [], 8962 newItems: [], 8963 init: () => { 8964 DataLayerMethods.sendCheckoutShippingDataLayer(), DataLayerMethods.sendCheckoutPaymentDataLayer() 8965 }, 8966 sendCheckoutShippingDataLayer: () => { 8967 $(document).on('click', '#cart-shipping-calculate', function () { 8968 const e = { 8969 eventCategory: 'bblend:checkout', 8970 eventAction: 'clique:botao', 8971 eventLabel: this.textContent, 8972 } 8973 setDataTagging(e) 8974 }) 8975 const e = ({ ...e }) => { 8976 const t = { 8977 event: 'checkoutOption', 8978 eventCategory: 'enhanced-ecommerce', 8979 eventAction: 'checkoutOption', 8980 eventLabel: 'shipping-method', 8981 otherProps: { 8982 ecommerce: { 8983 checkout_option: { 8984 ...e, 8985 }, 8986 }, 8987 }, 8988 } 8989 setDataTagging(t) 8990 } 8991 $(document).on('click', '#shipping-sla-selector .sla-option', function (t) { 8992 const n = this.querySelector('.sla-text .title'), 8993 i = this.querySelector('.sla-text .time') 8994 t.stopPropagation() 8995 e({ 8996 actionField: { 8997 step: '1', 8998 option: `shipping:${n.textContent}:${i.textContent}`, 8999 }, 9000 }) 9001 }), 9002 $(document).on('change', '#delivery-packages-options .shp-lean-option input', function (t) { 9003 const n = $(this).closest('label') 9004 if (n.length > 0) { 9005 const i = n.find('.shp-option-text-label'), 9006 o = n.find('.shp-option-text-package span') 9007 t.stopPropagation() 9008 e({ 9009 actionField: { 9010 step: '3', 9011 option: `shipping:${i.text()}:${o.text()}`, 9012 }, 9013 }) 9014 } 9015 }) 9016 }, 9017 sendCheckoutPaymentDataLayer: () => { 9018 $(document).on('click', '.payment-group-list-btn a', function () { 9019 const e = this.querySelector('span').textContent 9020 setDataTagging({ 9021 event: 'checkoutOption', 9022 eventCategory: 'enhanced-ecommerce', 9023 eventAction: 'checkoutOption', 9024 eventLabel: 'payment-method', 9025 otherProps: { 9026 ecommerce: { 9027 checkout_option: { 9028 actionField: { 9029 step: '3', 9030 option: 'payment:' + e, 9031 }, 9032 }, 9033 }, 9034 }, 9035 }) 9036 }) 9037 }, 9038 sendCheckoutStepsDataLayer: async () => {
9039 const e = window.location.hash.replace(/[^\w:%,\-+]/g, '') 9040 if ('email' == e) return 9041 const t = ['cart', 'profile', 'shipping', 'payment'].indexOf(e) 9042 let n = [] 9043 vtexjs.checkout.orderForm.items.forEach((e) => { 9044 if (e.productCategories) { 9045 const t = e.productCategories, 9046 i = Object.values(t)[0].replace(/\//g, '').trim() 9047 n.push({ 9048 name: e.name, 9049 id: e.productId, 9050 price: 'R$ ' + toBrazilianNumberFormat(e.price / 100), 9051 brand: e.additionalInfo.brandName, 9052 category: i, 9053 variant: e.id, 9054 quantity: e.quantity, 9055 }) 9056 } 9057 }), 9058 (({ ...e }) => { 9059 const t = { 9060 event: 'checkout', 9061 eventCategory: 'enhanced-ecommerce', 9062 eventAction: 'checkout', 9063 ...e, 9064 } 9065 setDataTagging(t) 9066 })({ 9067 eventLabel: e, 9068 otherProps: { 9069 noInteraction: '1', 9070 ecommerce: { 9071 checkout: { 9072 actionField: { 9073 step: t + 1, 9074 }, 9075 products: n, 9076 }, 9077 }, 9078 }, 9079 }) 9080 }, 9081 sendAddRemoveFromCartDataLayer: () => { 9082 const e = DataLayerMethods.newItems 9083 .map((e) => { 9084 const t = DataLayerMethods.oldItems.find((t) => t.id === e.id) 9085 let n = 0, 9086 i = '' 9087 return ( 9088 t ? ((n = e.quantity - t.quantity), (i = n > 0 ? 'addToCart' : 'removeFromCart')) : (i = 'addToCart'), 9089 { 9090 ...e, 9091 quantityDiff: n, 9092 action: i, 9093 } 9094 ) 9095 }) 9096 .filter((e) => 0 !== e.quantityDiff), 9097 t = DataLayerMethods.oldItems 9098 .filter((e) => !DataLayerMethods.newItems.some((t) => t.id === e.id)) 9099 .map((e) => ({ 9100 ...e, 9101 action: 'removeFromCart', 9102 })) 9103 DataLayerMethods.oldItems = DataLayerMethods.newItems.slice() 9104 const n = [...e, ...t] 9105 n.map((e) => { 9106 const t = e.productCategories, 9107 n = Object.values(t)[0] 9108 ;(({ ...e }, t) => { 9109 const n = { 9110 event: t, 9111 eventCategory: 'enhanced-ecommerce', 9112 eventAction: t, 9113 eventLabel: 'carrinho', 9114 otherProps: { 9115 ecommerce: { 9116 ['addToCart' === t ? 'add' : 'remove']: { 9117 products: [ 9118 { 9119 ...e, 9120 }, 9121 ], 9122 }, 9123 }, 9124 }, 9125 } 9126 setDataTagging(n) 9127 })( 9128 { 9129 name: e.name, 9130 id: e.productId, 9131 price: 'R$ ' + toBrazilianNumberFormat(e.listPrice / 100), 9132 brand: e.additionalInfo.brandName, 9133 category: n, 9134 variant: e.id, 9135 quantity: Math.abs(e.quantityDiff || e.quantity), 9136 }, 9137 e.action 9138 ) 9139 }) 9140 }, 9141 sendReactNativeMessage: () => { 9142 const e = window.location.hash, 9143 t = (e) => window.dataLayer.find((t) => t.event === e), 9144 n = t('view_cart'), 9145 i = t('begin_checkout'), 9146 o = t('add_shipping_info'), 9147 s = t('add_payment_info') 9148 window.ReactNativeWebView && 9149 (e.includes('cart') && n && window.ReactNativeWebView.postMessage(JSON.stringify(n)), 9150 e.includes('email') && i && window.ReactNativeWebView.postMessage(JSON.stringify(i)), 9151 e.includes('payment') && o && window.ReactNativeWebView.postMessage(JSON.stringify(o)), 9152 e.includes('payment') && s && window.ReactNativeWebView.postMessage(JSON.stringify(s))) 9153 }, 9154 } 9155DataLayerMethods.init(), 9156 $(window).on('orderFormUpdated.vtex', async function (e, t) { 9157 ;(DataLayerMethods.newItems = vtexjs.checkout.orderForm.items), DataLayerMethods.sendAddRemoveFromCartDataLayer() 9158 }) 9159 9160let lastItemCount = null 9161let lastCartProductIds = [] // Armazena os IDs dos produtos do último carrinho processado 9162 9163$(window).on('orderFormUpdated.vtex', function (event, orderForm) { 9164 const currentItemCount = orderForm.items.length 9165 const currentProductIds = orderForm.items.map(item => item.productId).sort().join(',') 9166 const lastProductIdsStr = [...lastCartProductIds].sort().join(',') 9167 9168 // Atualiza cross-sell se: quantidade mudou OU os produtos no carrinho mudaram 9169 const itemCountChanged = currentItemCount !== lastItemCount 9170 const productsChanged = currentProductIds !== lastProductIdsStr 9171 9172 if (itemCountChanged || productsChanged) { 9173 // Salva os IDs anteriores ANTES de atualizar 9174 const previousCartProductIds = [...lastCartProductIds] 9175 9176 lastItemCount = currentItemCount 9177 lastCartProductIds = orderForm.items.map(item => item.productId) 9178 9179 $('.show-case-container').empty('') 9180 9181 setTimeout(function () { 9182 montarCrossSelling(orderForm, previousCartProductIds) 9183 9184 // BuyTogether.buildCarousel(); 9185 }, 200) 9186 } 9187}) 9188 9189// Função auxiliar para extrair IDs dos produtos do carrinho 9190// Retorna array com o produto mais recente primeiro, seguido dos demais 9191function getCartProductIds(orderForm, previousCartProductIds = []) { 9192 if (!orderForm || !orderForm.items || orderForm.items.length === 0) { 9193 return [] 9194 } 9195 9196 const currentProductIds = orderForm.items.map(item => item.productId) 9197 9198 // Encontra os produtos NOVOS (que não estavam no carrinho anterior) 9199 const newProductIds = currentProductIds.filter(id => !previousCartProductIds.includes(id)) 9200
9201 // Se há produtos novos, coloca-os primeiro; caso contrário, mantém a ordem reversa (último da lista primeiro) 9202 if (newProductIds.length > 0) { 9203 // Produtos novos primeiro, depois os antigos (na ordem reversa) 9204 const oldProductIds = currentProductIds.filter(id => previousCartProductIds.includes(id)).reverse() 9205 return [...newProductIds.reverse(), ...oldProductIds] 9206 } 9207 9208 // Fallback: ordem reversa (último da lista primeiro) 9209 return currentProductIds.reverse() 9210} 9211 9212// Função para buscar produtos de cross-selling via API "Who Bought Also Bought" 9213async function fetchCrossSellingProducts(productId) { 9214 try { 9215 const { data } = await axios.get(`/api/catalog_system/pub/products/crossselling/whoboughtalsobought/${productId}`) 9216 return data || [] 9217 } catch (error) { 9218 console.error(`Erro ao buscar cross-selling para produto ${productId}:`, error) 9219 return [] 9220 } 9221} 9222 9223// Função para buscar produtos da categoria Bebidas (fallback) 9224async function fetchCategoryProducts() { 9225 try { 9226 const { data } = await axios.get('/api/catalog_system/pub/products/search?_from=1&_to=10&fq=C:/2/&O=OrderByReleaseDateDESC') 9227 return data || [] 9228 } catch (error) { 9229 console.error('Erro ao buscar produtos da categoria Bebidas:', error) 9230 return [] 9231 } 9232} 9233 9234// Função para filtrar produtos de cross-selling com base nos critérios 9235function filterCrossSellingProducts(products, cartProductIds) { 9236 if (!products || products.length === 0) { 9237 return [] 9238 } 9239 9240 return products.filter(product => { 9241 // 1. Verificar se é da categoria "Bebidas" 9242 const categories = Object.values(product.categories || {}) 9243 const isBebida = categories.some(cat => cat === '/Bebidas/')
9244 if (!isBebida) return false 9245 9246 // 2. Verificar disponibilidade (pelo menos 1 seller com estoque) 9247 const isAvailable = product.items && product.items.some(item => { 9248 return item.sellers && item.sellers.some(seller => { 9249 return seller.commertialOffer && seller.commertialOffer.IsAvailable === true 9250 }) 9251 }) 9252 if (!isAvailable) return false 9253 9254 // 3. Não retornar produtos que já estão no carrinho 9255 const isInCart = cartProductIds.includes(product.productId) 9256 if (isInCart) return false 9257 9258 return true 9259 }) 9260} 9261 9262// Função para filtrar produtos da categoria (fallback) - apenas disponibilidade e duplicatas 9263function filterCategoryProducts(products, cartProductIds, existingCrossSellIds) { 9264 if (!products || products.length === 0) { 9265 return [] 9266 } 9267 9268 return products.filter(product => { 9269 // 1. Verificar disponibilidade (pelo menos 1 seller com estoque) 9270 const isAvailable = product.items && product.items.some(item => { 9271 return item.sellers && item.sellers.some(seller => { 9272 return seller.commertialOffer && seller.commertialOffer.IsAvailable === true 9273 }) 9274 }) 9275 if (!isAvailable) return false 9276 9277 // 2. Não retornar produtos que já estão no carrinho 9278 const isInCart = cartProductIds.includes(product.productId) 9279 if (isInCart) return false 9280 9281 // 3. Não retornar produtos que já estão no cross-sell 9282 const isInCrossSell = existingCrossSellIds.includes(product.productId) 9283 if (isInCrossSell) return false 9284 9285 return true 9286 }) 9287} 9288 9289async function montarCrossSelling(orderForm, previousCartProductIds = []) { 9290 try { 9291 // 1. Extrair productIds do carrinho (produto mais recente primeiro) 9292 const cartProductIds = getCartProductIds(orderForm, previousCartProductIds) 9293 9294 9295 if (cartProductIds.length === 0) { 9296 // Sem produtos no carrinho, ocultar cross-sell 9297 $('.show-case-container').remove() 9298 return 9299 } 9300 9301 let crossSellProducts = [] 9302 9303 // 2. Buscar cross-sell do último produto adicionado 9304 const lastProductId = cartProductIds[0] 9305 9306 const productCrossSell = await fetchCrossSellingProducts(lastProductId) 9307 const filteredProducts = filterCrossSellingProducts(productCrossSell, cartProductIds) 9308 9309 // Adicionar produtos filtrados 9310 filteredProducts.forEach(product => { 9311 if (crossSellProducts.length < 4) { 9312 crossSellProducts.push(product) 9313 } 9314 }) 9315 9316 9317 // 3. Se < 4 produtos, buscar fallback na categoria Bebidas 9318 if (crossSellProducts.length < 4) { 9319 9320 const categoryProducts = await fetchCategoryProducts() 9321 const existingCrossSellIds = crossSellProducts.map(p => p.productId) 9322 const filteredCategoryProducts = filterCategoryProducts(categoryProducts, cartProductIds, existingCrossSellIds) 9323 9324 // Completar até 4 produtos 9325 filteredCategoryProducts.forEach(product => { 9326 if (crossSellProducts.length < 4) { 9327 crossSellProducts.push(product) 9328 } 9329 }) 9330 9331 } 9332 9333 // 4. Limitar a 4 produtos 9334 crossSellProducts = crossSellProducts.slice(0, 4) 9335 9336 // 5. Se 0 produtos: não renderizar (ocultar seção) 9337 if (crossSellProducts.length === 0) { 9338 $('.show-case-container').remove() 9339 return 9340 } 9341 9342 // 6. Se > 0 produtos: renderizar 9343 await renderizarCrossSelling(crossSellProducts) 9344 } catch (error) { 9345 console.error('Erro ao montar cross-selling:', error) 9346 $('.show-case-container').remove() 9347 } 9348} 9349 9350async function renderizarCrossSelling(products) { 9351 try { 9352 // Verificar se há produtos para exibir 9353 if (!products || products.length === 0) { 9354 $('.show-case-container').remove() 9355 return 9356 } 9357 9358 // Remove container antigo se existir 9359 $('.show-case-container').remove() 9360 9361 const t = $('.cart-template-holder') 9362 const n = $("<div class='show-case-container'></div>") 9363 const i = $("<div class='accordion-container'></div>") 9364 const o = $("<button class='accordion-title'>QUE TAL COMPLETAR SEU PEDIDO?</button>") 9365 const s = $("<div class='accordion-content'></div>") 9366 const a = $('<h2>Aproveite o frete para experimentar mais sabores.</h2>') 9367 const r = $("<ul class='show-case-slick'></ul>") 9368 9369 s.append(a, r) 9370 i.append(o, s) 9371 t.after(n) 9372 n.append(i) 9373 9374 await Promise.all(products.map(async (prod) => { 9375 const el = await BuyTogether.createProductElement(prod) 9376 r.append(el) 9377 })) 9378
9379 // Usa scroll nativo ao invés do Slick Carousel 9380 r.addClass('native-scroll') 9381 9382 // Inicializa accordion aberto (sem classe 'active' = aberto) 9383 s.show() 9384 9385 o.off('click').on('click', function () { 9386 BuyTogether.toggleAccordionContent(this) 9387 }) 9388 9389 // Inicializa o módulo de modais 9390 CrossSellingModal.init() 9391 9392 BuyButtonsReformuled.init() 9393 } catch (error) { 9394 console.error('Erro ao carregar cross-selling:', error) 9395 $('.show-case-container').remove() 9396 } 9397} 9398 9399// Módulo para gerenciar os modais de seleção de quantidade 9400const CrossSellingModal = { 9401 currentProductId: null, 9402 currentSku: null, 9403 currentSeller: null, 9404 currentModalType: null, // 'onetime' ou 'subscription' 9405 currentProductCategory: null, // 'drink', 'capsule', 'filter', 'cilinder', 'other' 9406 selectedQuantity: 10, 9407 selectedFrequency: '1-month', 9408 9409 init: () => { 9410 // Cria os modais no DOM se ainda não existirem 9411 if (!document.getElementById('cross-selling-modal-onetime')) { 9412 CrossSellingModal.createModals() 9413 } 9414 }, 9415 9416 // Define opções de quantidade baseado no tipo de produto 9417 getQuantityOptions: (category) => { 9418 if (category === 'drink') { 9419 return [10, 20, 30, 40, 50, 60, 70, 80, 90, 100] 9420 } else if (category === 'capsule') { 9421 return [10, 20, 30, 40, 50, 60, 70, 80, 90, 100] 9422 } else { 9423 // Acessórios (filtro, cilindro, etc) 9424 return [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 9425 } 9426 }, 9427 9428 // Define opções de frequência baseado no tipo de produto 9429 getFrequencyOptions: (category) => { 9430 if (category === 'filter') { 9431 return [ 9432 { key: '3-month', text: '3 meses', value: 3 }, 9433 { key: '6-month', text: '6 meses', value: 6 } 9434 ] 9435 } else if (category === 'cilinder') { 9436 return [ 9437 { key: '1-month', text: '1 mês', value: 1 }, 9438 { key: '3-month', text: '3 meses', value: 3 }, 9439 { key: '6-month', text: '6 meses', value: 6 } 9440 ] 9441 } else { 9442 // Bebidas e cápsulas (padrão) 9443 return [ 9444 { key: '1-month', text: '1 mês', value: 1 }, 9445 { key: '2-month', text: '2 meses', value: 2 }, 9446 { key: '3-month', text: '3 meses', value: 3 } 9447 ] 9448 } 9449 }, 9450 9451 createModals: () => { 9452 // Modais serão criados dentro de cada container de produto 9453 }, 9454 9455 attachEventListeners: () => { 9456 // Clique nas opções de quantidade e frequência 9457 $('.bblend-select-amount-modal-option').on('click', function() { 9458 const $this = $(this) 9459 const $parent = $this.closest('.bblend-select-amount-modal-options') 9460 9461 $parent.find('.bblend-select-amount-modal-option').removeClass('bblend-select-amount-modal-option-selected') 9462 $this.addClass('bblend-select-amount-modal-option-selected') 9463 9464 const type = $parent.data('type') 9465 const value = $this.data('value') 9466 9467 if (type === 'quantity') { 9468 CrossSellingModal.selectedQuantity = value 9469 } else if (type === 'frequency') { 9470 CrossSellingModal.selectedFrequency = value 9471 } 9472 }) 9473 9474 // Botão adicionar ao carrinho 9475 $('.bblend-select-amount-modal-button-add').on('click', function() { 9476 CrossSellingModal.addToCart() 9477 }) 9478 9479 // Botão voltar 9480 $('.bblend-select-amount-modal-button-back').on('click', function() { 9481 CrossSellingModal.closeModal() 9482 }) 9483 9484 // Clique no wrapper (fora do modal) para fechar 9485 $('.bblend-select-amount-modal-wrapper').on('click', function(e) { 9486 if ($(e.target).hasClass('bblend-select-amount-modal-wrapper')) { 9487 CrossSellingModal.closeModal() 9488 } 9489 }) 9490 }, 9491 9492 openModal: (buttonElement, type, productId, sku, seller, categoriesIds) => { 9493 CrossSellingModal.currentModalType = type 9494 CrossSellingModal.currentProductId = productId 9495 CrossSellingModal.currentSku = sku 9496 CrossSellingModal.currentSeller = seller 9497 9498 // Detecta o tipo de produto baseado no ID ou categorias 9499 let productCategory = 'capsule' // padrão 9500 const idNum = parseInt(productId) 9501 9502 if (idNum === 38 || idNum === 404 || idNum === 579) { 9503 productCategory = 'filter' 9504 } else if (idNum === 68 || idNum === 573) { 9505 productCategory = 'cilinder' 9506 } else if (categoriesIds) { 9507 const categories = categoriesIds.toString().toLowerCase() 9508 if (categories.includes('bebida')) { 9509 productCategory = 'drink' 9510 } else if (categories.includes('capsula')) { 9511 productCategory = 'capsule' 9512 } else if (categories.includes('acessorio')) { 9513 productCategory = 'other' 9514 } 9515 } 9516 9517 CrossSellingModal.currentProductCategory = productCategory 9518 9519 // Define opções baseadas no produto 9520 const quantityOptions = CrossSellingModal.getQuantityOptions(productCategory) 9521 const frequencyOptions = CrossSellingModal.getFrequencyOptions(productCategory) 9522 9523 CrossSellingModal.selectedQuantity = quantityOptions[0] 9524 CrossSellingModal.selectedFrequency = frequencyOptions[0].key 9525 9526 // Encontra o container e o modal dentro dele 9527 const $container = $(buttonElement).closest('.bblend-shelf-buy-container') 9528 const modalClass = type === 'subscription' ? '.modal-subscription' : '.modal-onetime' 9529 const $modal = $container.find(modalClass) 9530 9531 // Preenche opções de quantidade 9532 const $quantityContainer = $modal.find('.bblend-select-amount-modal-options[data-type="quantity"]') 9533 $quantityContainer.html( 9534 quantityOptions.map((qty, idx) => 9535 `<button type="button" class="bblend-select-amount-modal-option ${idx === 0 ? 'bblend-select-amount-modal-option-selected' : ''}" data-value="${qty}">${qty}</button>` 9536 ).join('') 9537 ) 9538 9539 // Preenche opções de frequência (só para modal de subscription) 9540 if (type === 'subscription') { 9541 const $frequencyContainer = $modal.find('.bblend-select-amount-modal-options[data-type="frequency"]') 9542 $frequencyContainer.html( 9543 frequencyOptions.map((freq, idx) => 9544 `<button class="bblend-select-amount-modal-option ${idx === 0 ? 'bblend-select-amount-modal-option-selected' : ''}" type="button" data-value="${freq.key}">${freq.text}</button>` 9545 ).join('') 9546 ) 9547 } 9548 9549 // Re-anexa event listeners 9550 CrossSellingModal.attachEventListeners() 9551 9552 // Mostra o modal 9553 $modal.fadeIn(200) 9554 }, 9555 9556 closeModal: () => { 9557 $('.bblend-select-amount-modal-wrapper').fadeOut(200) 9558 CrossSellingModal.currentProductId = null 9559 CrossSellingModal.currentSku = null 9560 CrossSellingModal.currentSeller = null 9561 CrossSellingModal.currentModalType = null 9562 }, 9563 9564 addToCart: async () => { 9565 if (!CrossSellingModal.currentSku || !CrossSellingModal.currentSeller) { 9566 console.error('Dados do produto não encontrados') 9567 return 9568 } 9569 9570 const items = [{ 9571 id: CrossSellingModal.currentSku, 9572 quantity: CrossSellingModal.selectedQuantity, 9573 seller: CrossSellingModal.currentSeller 9574 }] 9575 9576 try { 9577 // Adiciona ao carrinho 9578 const orderForm = await vtexjs.checkout.addToCart(items, null, CrossSellingModal.currentSeller) 9579 9580 // Se for compra programada, adiciona o attachment de frequência 9581 let finalOrderForm = orderForm 9582 if (CrossSellingModal.currentModalType === 'subscription') { 9583 const frequencyOption = ALL_FREQUENCY_OPTIONS.find(f => f.key === CrossSellingModal.selectedFrequency) 9584 9585 if (frequencyOption) { 9586 const itemIndex = orderForm.items.findIndex(item => item.id === CrossSellingModal.currentSku) 9587 9588 if (itemIndex !== -1) { 9589 const attachmentOrderForm = await vtexjs.checkout.addItemAttachment( 9590 itemIndex, 9591 'pay2b.subscription', 9592 { 9593 'pay2b.subscription.recurring.value': frequencyOption.pay2bKey 9594 }, 9595 null, 9596 false 9597 ) 9598 9599 // Chama subscriptionDataUpdate para sincronizar os dados de subscription 9600 // com o VTEX e fazer o backend calcular os descontos corretamente 9601 await subscriptionDataUpdate(attachmentOrderForm) 9602 9603 // Busca orderForm atualizado após o subscriptionData ser processado 9604 finalOrderForm = await vtexjs.checkout.getOrderForm() 9605 } 9606 } 9607 } 9608 9609 CrossSellingModal.closeModal() 9610 9611 // Trigger do evento de atualização com orderForm que contém os descontos 9612 $(window).trigger('orderFormUpdated.vtex', [finalOrderForm]) 9613 9614 } catch (error) { 9615 console.error('Erro ao adicionar produto', error) 9616 alert('Erro ao adicionar produto ao carrinho. Tente novamente.') 9617 } 9618 } 9619} 9620 9621const BuyTogether = { 9622 init: () => { 9623 //BuyTogether.buildCarousel() 9624 }, 9625 createProductElement: async (e) => { 9626 const { 9627 link: t, 9628 productId: n, 9629 productName: i, 9630 brand: o, 9631 items: [ 9632 { 9633 itemId: skuId, 9634 sellers: [ 9635 { 9636 commertialOffer: { Price: s, ListPrice: a }, 9637 sellerId: sellerId, 9638 }, 9639 ], 9640 images: r, 9641 }, 9642 ], 9643 Validade: c, 9644 'Shelf Description': u, 9645 'Quantity (ML)': l, 9646 categories: productCategories, 9647 } = e, 9648 d = s < a, 9649 p = n.includes('38'), 9650 h = n.includes('68'), 9651 { imageUrl: m } = r.find((e) => 'TopFoil' === e.imageLabel) || r[0] 9652 9653 const skuPriceData = await fetchSkuSubscriptionPrice(skuId, sellerId) 9654 const subscriptionPrice = skuPriceData?.precoFinal ?? null 9655 const hasSubscriptionPrice = subscriptionPrice !== null 9656 9657 // Pega categorias para passar ao modal 9658 const categoriesStr = productCategories ? productCategories.join(',') : '' 9659 9660 return `\n <li>\n <div class="_product-card Checkout _new" data-id="${n}" data-name="${i}"\n data-category="" data-department="" data-oldprice="${a}"\n data-price="${s}" data-brand="${o}">\n\n\n <div class="_newProduct">Novo</div>\n \x3c!-- CONDIÃÃO SE TIVER MELHOR PREÃâ¡O --\x3e\n ${ 9661 d 9662 ? '\n <div class="_tag only-discount">\n <p class="_text">\n </p>\n <img src="/arquivos/discount-flag-icon.svg" alt="Icone Desconto">\n </div>\n ' 9663 : '' 9664 }\n \n <div class="_img">\n <img src="${m}"/>\n <a class="_product-button" href="${t}" name="product-image">\n </a>\n </div>\n\n <div class="_info">\n\n <div class="_name">\n <p class="_product-button" href="${t}" name="product-name">\n ${i}\n </p>\n ${ 9665 u ? `\n <p class="_product-description">\n ${u}\n </p>` : '' 9666 }\n </div>\n\n <div class="_price-buy">\n\n \x3c!-- CONDIÃÃO SE TIVER ESTOQUE --\x3e\n <div class="_price">\n <div class="bblend-shelf-price-container">\n <p class="bblend-shelf-price-main">\n ${ 9667 d 9668 ? `<span class="bblend-shelf-price-discount">R$ ${toBrazilianNumberFormat( 9669 a 9670 )}</span>` 9671 : '' 9672 }\n R$ ${toBrazilianNumberFormat( 9673 s 9674 )}\n </p>\n ${ 9675 hasSubscriptionPrice 9676 ? `<p class="bblend-shelf-price-subscription">
9676\n <span>Por</span> R$ ${toBrazilianNumberFormat(subscriptionPrice)} \n <svg width="10" height="11" viewBox="0 0 10 11" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M8.9375 0.8125H7.71875V0.40625C7.71875 0.298506 7.67595 0.195175 7.59976 0.118988C7.52358 0.0428012 7.42024 0 7.3125 0C7.20476 0 7.10142 0.0428012 7.02524 0.118988C6.94905 0.195175 6.90625 0.298506 6.90625 0.40625V0.8125H2.84375V0.40625C2.84375 0.298506 2.80095 0.195175 2.72476 0.118988C2.64858 0.0428012 2.54524 0 2.4375 0C2.32976 0 2.22642 0.0428012 2.15024 0.118988C2.07405 0.195175 2.03125 0.298506 2.03125 0.40625V0.8125H0.8125C0.597012 0.8125 0.390349 0.898102 0.237976 1.05048C0.0856024 1.20285 0 1.40951 0 1.625V9.75C0 9.96549 0.0856024 10.1722 0.237976 10.3245C0.390349 10.4769 0.597012 10.5625 0.8125 10.5625H8.9375C9.15299 10.5625 9.35965 10.4769 9.51202 10.3245C9.6644 10.1722 9.75 9.96549 9.75 9.75V1.625C9.75 1.40951 9.6644 1.20285 9.51202 1.05048C9.35965 0.898102 9.15299 0.8125 8.9375 0.8125ZM2.03125 1.625V2.03125C2.03125 2.13899 2.07405 2.24233 2.15024 2.31851C2.22642 2.3947 2.32976 2.4375 2.4375 2.4375C2.54524 2.4375 2.64858 2.3947 2.72476 2.31851C2.80095 2.24233 2.84375 2.13899 2.84375 2.03125V1.625H6.90625V2.03125C6.90625 2.13899 6.94905 2.24233 7.02524 2.31851C7.10142 2.3947 7.20476 2.4375 7.3125 2.4375C7.42024 2.4375 7.52358 2.3947 7.59976 2.31851C7.67595 2.24233 7.71875 2.13899 7.71875 2.03125V1.625H8.9375V3.25H0.8125V1.625H2.03125ZM8.9375 9.75H0.8125V4.0625H8.9375V9.75ZM6.99055 5.40008C7.02832 5.43781 7.05828 5.48261 7.07873 5.53193C7.09917 5.58125 7.10969 5.63411 7.10969 5.6875C7.10969 5.74089 7.09917 5.79375 7.07873 5.84307C7.05828 5.89239 7.02832 5.93719 6.99055 5.97492L4.55305 8.41242C4.51532 8.45019 4.47051 8.48016 4.42119 8.5006C4.37188 8.52105 4.31901 8.53157 4.26562 8.53157C4.21224 8.53157 4.15937 8.52105 4.11006 8.5006C4.06074 8.48016 4.01593 8.45019 3.9782 8.41242L2.75945 7.19367C2.68322 7.11744 2.6404 7.01405 2.6404 6.90625C2.6404 6.79845 2.68322 6.69506 2.75945 6.61883C2.83568 6.5426 2.93907 6.49977 3.04688 6.49977C3.15468 6.49977 3.25807 6.5426 3.3343 6.61883L4.26562 7.55066L6.4157 5.40008C6.45343 5.36231 6.49824 5.33234 6.54756 5.3119C6.59687 5.29145 6.64974 5.28093 6.70312 5.28093C6.75651 5.28093 6.80938 5.29145 6.85869 5.3119C6.90801 5.33234 6.95282 5.36231 6.99055 5.40008Z" fill="#787281"></path></svg> \n programada\n </p>` 9677 : '' 9678 }\n </div>\n </div>\n <div class="buy-button-wrapper" data-product-id="${n}" customBuyButtonText="Comprar"\n customRemindMeButtonText="Avise-me" defaultModal="false" data-product-available="$product.IsInStock"\n data-product-categories-ids="$product.CategoryName">\n <div class="_hide default-modal-info">\n $product.ProductField(61)\n </div>\n \n <div class="bblend-shelf-buy-container">\n <button class="bblend-shelf-buy-button bblend-shelf-buy-button-onetime" type="button"\n onclick="CrossSellingModal.openModal(this, 'onetime', '${n}', '${skuId}', '${sellerId}', '${categoriesStr}')">\n Comprar uma vez\n </button>\n <div class="bblend-shelf-buy-button-wrapper">\n <button class="bblend-shelf-buy-button" type="button"\n onclick="CrossSellingModal.openModal(this, 'subscription', '${n}', '${skuId}', '${sellerId}', '${categoriesStr}')">\n Compra programada\n </button>\n </div>\n \n <div class="bblend-select-amount-modal-wrapper modal-onetime" style="display: none;">\n <div class="bblend-select-amount-modal-modal" role="dialog" aria-modal="true" aria-labelledby="modal-title-onetime" tabindex="-1">\n <h4 id="modal-title-onetime" class="bblend-select-amount-modal-title">Comprar uma vez</h4>\n <p class="bblend-select-amount-modal-description">Quantas unidades você deseja adicionar?</p>\n <div class="bblend-select-amount-modal-options" data-type="quantity"></div>\n <div class="bblend-select-amount-modal-footer">\n <button type="button" class="bblend-select-amount-modal-button-add">Adicionar ao carrinho</button>\n <button type="button" class="bblend-select-amount-modal-button-back">Voltar</button>\n </div>\n </div>\n </div>\n \n <div class="bblend-select-amount-modal-wrapper modal-subscription" style="display: none;">\n <div class="bblend-select-amount-modal-modal" role="dialog" aria-modal="true" aria-labelledby="modal-title-subscription" tabindex="-1">\n <h4 id="modal-title-subscription" class="bblend-select-amount-modal-title">Compra programada</h4>\n <p class="bblend-select-amount-modal-description">Quantas unidades você deseja adicionar?</p>\n <div class="bblend-select-amount-modal-options" data-type="quantity"></div>\n <p class="bblend-select-amount-modal-description">Escolha a frequência que deseja receber:</p>\n <div class="bblend-select-amount-modal-options bblend-select-amount-modal-options-subscription" data-type="frequency"></div>\n <div class="bblend-select-amount-modal-footer">\n <button type="button" class="bblend-select-amount-modal-button-add">Adicionar ao carrinho</button>\n <button type="button" class="bblend-select-amount-modal-button-back">Voltar</button>\n </div>\n </div>\n </div>\n </div>\n\n <button class="remind-me-button _product-button _hide" name="avise-me"\n onclick="RemindMeModalReformuled.open(this.parentNode)">\n <img src="/arquivos/alert-button-icon.svg" alt="Icone alerta">
9678\n <span class="remind-me-button-text">Avise-me</span>\n </button>\n </div>\n </div>\n\n </div>\n\n \x3c!-- SE TIVER ESTOQUE --\x3e\n <div class="_about">\n ${ 9679 l ? `<div class="_measure">${l}</div>` : '' 9680 }\n ${c ? `<div class="_val">${c}</div>` : ''}\n </div>\n </div>\n</li>\n ` 9681 }, 9682 buildCarousel: async () => { 9683 const { data: e } = await axios.get('/api/catalog_system/pub/products/search?fq=productClusterIds:400'), 9684 t = $('.cart-template-holder'), 9685 n = $("<div class='show-case-container'></div>"), 9686 i = $("<div class='accordion-container'></div>"), 9687 o = $("<button class='accordion-title'>QUE TAL COMPLETAR SEU PEDIDO?</button>"), 9688 s = $("<div class='accordion-content'></div>"), 9689 a = $('<h2>Aproveite o frete para experimentar <b>mais sabores</b>.</h2>'), 9690 r = $("<ul class='show-case-slick'></ul>") 9691 s.append(a, r), 9692 i.append(o, s), 9693 t.after(n), 9694 n.append(i), 9695 await Promise.all(e.map(async (e) => { 9696 const t = await BuyTogether.createProductElement(e) 9697 r.append(t) 9698 })), 9699 // Usa scroll nativo ao invés do Slick Carousel 9700 r.addClass('native-scroll'), 9701 $('.accordion-title').click(function () { 9702 BuyTogether.toggleAccordionContent(this) 9703 }), 9704 BuyButtonsReformuled.init() 9705 }, 9706 toggleAccordionContent: (e) => { 9707 $(e).toggleClass('active').next('.accordion-content').slideToggle(500) 9708 }, 9709 }, 9710 CilynderAndFilterModal = { 9711 init: () => { 9712 CilynderAndFilterModal.buildModal(), 9713 CilynderAndFilterModal.validateButtonText(), 9714 CilynderAndFilterModal.handleNextPage() 9715 }, 9716 addToCart: async (e, t, n) => { 9717 try { 9718 addItemToCart(e, 1, t, 1), CilynderAndFilterModal.updateAddButtonText(n) 9719 } catch (e) { 9720 console.error(e) 9721 } 9722 }, 9723 updateAddButtonText: (e) => { 9724 const t = $(`.modal-checkout-button[data-product-id="${e}"] span`) 9725 t.parent().hasClass('added') || (t.text('1 adicionado'), t.parent().addClass('added')) 9726 }, 9727 createProductElementModal: (e) => { 9728 const { 9729 link: t, 9730 productId: n, 9731 productName: i, 9732 items: [ 9733 { 9734 itemId: o, 9735 sellers: [ 9736 { 9737 commertialOffer: { Price: s, ListPrice: a }, 9738 sellerId: r, 9739 }, 9740 ], 9741 images: c, 9742 }, 9743 ], 9744 } = e, 9745 u = s < a, 9746 { imageUrl: l } = c.find((e) => 'TopFoil' === e.imageLabel) || c[0] 9747 return `\n <div class="modal-checkout-container">\n <div class="modal-checkout-content">\n <div class="modal-checkout-image">\n <img src="${l}"/>\n <a href="${t}" name="product-image"></a>\n </div>\n <div class="modal-checkout-description _info">\n <div class="_name">\n <p class="_product-button" href="${t}" name="product-name">${i}</p>\n </div>\n <div class="_price-buy">\n <div class="_price">\n ${ 9748 u ? `<div class="_old">De R$ ${toBrazilianNumberFormat(a)}</div>` : '' 9749 }\n <div class="_new">Por R$ ${toBrazilianNumberFormat( 9750 s 9751 )}</div>\n </div>\n <div class="modal-checkout-button" data-product-id="${n}">\n <button onclick="CilynderAndFilterModal.addToCart(${o}, ${r}, ${n})">\n <span>Adicionar</span>\n </button>\n </div>\n </div>\n </div>\n </div>\n </div>\n ` 9752 }, 9753 buildModal: async () => { 9754 const { data: e } = await axios.get('/api/catalog_system/pub/products/search?fq=productClusterIds:359'), 9755 t = $('<div class="modal-checkout-section-overlay _hide"></div>'), 9756 n = $("<div id='modal-checkout-section-wrapper' class='modal-checkout-section _hide'></div>").appendTo(t) 9757 $('.cart-template-holder').after(t) 9758 const i = $("<h2 class='modal-checkout-button-title'>APROVEITE O FRETE<br>GRÃTIS E LEVE TAMBÃM</h2>"), 9759 o = $("<a class='modal-checkout-button-confirm' href='#/orderform'>Continuar sem adicionar</a>"), 9760 s = $("<button class='modal-checkout-button-back _hide'>voltar</button>") 9761 n.append(i, o, s), 9762 $(window).on('orderFormUpdated.vtex', function (e, i) { 9763 if (!i.items) return 9764 i.items.some((e) => ['38', '68'].includes(e.productId)) 9765 ? o.addClass('_complete-order').text('Finalizar pedido') && s.removeClass('_hide') 9766 : o.removeClass('_complete-order').text('Continuar sem adicionar') && s.addClass('_hide'), 9767 s.on('click', function () { 9768 n.addClass('_hide'), t.addClass('_hide') 9769 }), 9770 'Continuar sem adicionar' === o.text() 9771 ? o.on('click', function () { 9772 n.addClass('_hide'), t.addClass('_hide') 9773 }) 9774 : o.on('click', function () { 9775 window.location.hash = '#/orderform' 9776 }) 9777 }), 9778 e.forEach((e) => { 9779 const t = CilynderAndFilterModal.createProductElementModal(e) 9780 n.append(t) 9781 }) 9782 }, 9783 validateButtonText: () => { 9784 $(window).on('orderFormUpdated.vtex', function (e, t) { 9785 t.items &&
9786 t.items.forEach((e) => { 9787 const t = $(`.modal-checkout-button[data-product-id="${e.productId}"] span`) 9788 t.text('1 adicionado'), t.parent().addClass('added') 9789 }) 9790 }) 9791 }, 9792 handleNextPage: () => { 9793 $('a._keepBuying').attr('href', '#'), 9794 $('a._keepBuying').on('click', function () { 9795 const e = vtexjs.checkout.orderForm, 9796 t = e.items.some((e) => ['38', '68'].includes(e.productId)), 9797 n = e.items.some((e) => e.quantity >= 90) 9798 if ((console.log('>>> validFilterOrCilinder', t), t)) return $(this).attr('href', '#/orderform') 9799 e.items.forEach((e) => { 9800 const t = $(`.modal-checkout-button[data-product-id="${e.productId}"] span`) 9801 t.length 9802 ? (t.text('1 adicionado'), t.parent().addClass('added')) 9803 : ($('button.added span').text('Adicionar'), $('button.added').removeClass('added')) 9804 }), 9805 n || t 9806 ? ($('a._keepBuying').attr('href', '#'), 9807 $('.modal-checkout-section').removeClass('_hide'), 9808 $('.modal-checkout-section-overlay').removeClass('_hide')) 9809 : ($('a._keepBuying').attr('href', '#/orderform'), 9810 $('.modal-checkout-section').addClass('_hide'), 9811 $('.modal-checkout-section-overlay').addClass('_hide')) 9812 }) 9813 }, 9814 } 9815$(document).ready(() => { 9816 BuyTogether.init(), CilynderAndFilterModal.init() 9817}), 9818 $(document).ready(Checkout.createCNAEbox), 9819 window.addEventListener('load', function () { 9820 DataLayerMethods.sendCheckoutStepsDataLayer(), 9821 DataLayerMethods.sendReactNativeMessage(), 9822 (DataLayerMethods.oldItems = vtexjs.checkout.orderForm.items), 9823 //BuyTogether.toggleAccordionContent($(".accordion-title")), 9824 CilynderAndFilterModal.handleNextPage() 9825 const e = $('.payment-submit-wrap button') 9826 $(document).on('click', e, DataLayerMethods.sendReactNativeMessage) 9827 }), 9828 window.addEventListener('hashchange', function () { 9829 setTimeout(() => DataLayerMethods.sendReactNativeMessage(), 2e3), DataLayerMethods.sendCheckoutStepsDataLayer() 9830 }) 9831const BenchSelector = { 9832 openBench: () => { 9833 const e = $('.product-item') 9834 e.each(function () { 9835 const e = $(this).find('.quantity') 9836 if ($(this).find('.quantity input').val() >= 100) return 9837 const t = $('<div class="bench-backdrop"></div>') 9838 e.append(t) 9839 }), 9840 e.on('click', '.bench-backdrop', function () { 9841 const e = $(this).closest('.product-item').data('multiplier') || 1, 9842 t = $(this).closest('.product-item').data('sku'), 9843 n = vtexjs.checkout.orderForm.items.findIndex((e) => e.id == t), 9844 i = $(this).closest('.product-item').find('input').val(), 9845 o = 10 == e ? 100 : 10, 9846 s = Array.from( 9847 { 9848 length: o / e, 9849 }, 9850 (t, n) => (n + 1) * e 9851 ), 9852 a = $(this).parent() 9853 let r = a.find('.bench-container') 9854 r.length || 9855 ((r = $('<div class="bench-container"></div>')), 9856 a.append(r), 9857 ((e, t, n) => { 9858 t.forEach((t) => { 9859 e.append(`<button class="quantity-button ${n == t ? '_active' : ''}" data-quantity="${t}">${t}</button>`) 9860 }) 9861 })(r, s, i), 9862 r.on( 9863 'click', 9864 '.quantity-button', 9865 ((e) => (t) => { 9866 const n = parseInt($(t.currentTarget).data('quantity')) 9867 $(t.currentTarget).addClass('_btn-loading'), 9868 vtexjs.checkout.updateItems( 9869 [ 9870 { 9871 index: e, 9872 quantity: n, 9873 }, 9874 ], 9875 null, 9876 !1 9877 ) 9878 })(n) 9879 ), 9880 $(document).one( 9881 'mousedown', 9882 ((e) => (t) => { 9883 $(t.target).closest('.bench-container').length || e.remove() 9884 })(r) 9885 )) 9886 }) 9887 }, 9888} 9889//BenchSelector.openBench(); 9890const MiniCart = { 9891 init: async () => { 9892 await MiniCart.getOrderform(), 9893 MiniCart.updateProductList(), 9894 MiniCart.onOrderformUpdate(), 9895 MiniCart.closeCilindroPromo() 9896 const e = new URLSearchParams(window.location.search) 9897 e.get('coupon') && (await MiniCart.changeCoupon(e.get('coupon'))) 9898 }, 9899 addCilindroToCart: () => { 9900 $('._btnAddCilindro').on('click', function () { 9901 vtexjs.checkout 9902 .addToCart( 9903 [ 9904 { 9905 id: 69, 9906 quantity: 1, 9907 seller: '1', 9908 }, 9909 ], 9910 null, 9911 1 9912 ) 9913 .done(function (e) {}) 9914 }) 9915 }, 9916 closeCilindroPromo: () => { 9917 $('._close-cilindro').on('click', function () { 9918 $('._cilindro-promo').addClass('_hide') 9919 }) 9920 }, 9921 openCart: () => { 9922 document.querySelector('._cart').classList.add('_open'), 9923 (cep = document.querySelector('._mini-cart ._shipping input').value), 9924 cep 9925 ? document.querySelector('._cart ._add._shipping ._alert').classList.remove('_hide') 9926 : document.querySelector('._cart ._add._shipping ._alert').classList.add('_hide') 9927 }, 9928 closeCart: () => { 9929 document.querySelector('._cart').classList.remove('_open') 9930 }, 9931 openPopup: () => { 9932 document.querySelector('._user #_miniCartPop').classList.add('_open'), 9933 document.querySelector('._bottom-menu #_miniCartPop').classList.add('_open'), 9934 setTimeout(function () { 9935 MiniCart.closePopup() 9936 }, 3e3) 9937 }, 9938 openPopupCilindro: () => { 9939 document.querySelector('._user #_cilindroPop').classList.add('_open'), 9940 document.querySelector('._bottom-menu #_cilindroPop').classList.add('_open') 9941 }, 9942 openPopupFiltro: () => { 9943 document.querySelector('._user #_filterPop').classList.add('_open'), 9944 document.querySelector('._bottom-menu #_filterPop').classList.add('_open') 9945 }, 9946 openModalCilindro: async () => { 9947 document.querySelectorAll('#_cilindroModal').forEach((e) => { 9948 e.querySelector('.normal-price > div > em').innerText = 'R$ 149,00' 9949 }), 9950 document.querySelector('._user #_cilindroModal').classList.add('_open'), 9951 document.querySelector('._bottom-menu #_cilindroModal').classList.add('_open') 9952 }, 9953 openModalFiltro: async () => { 9954 await vtexjs.catalog.getProductWithVariations('38') 9955 document.querySelectorAll('#_filterModal').forEach((e) => { 9956 e.querySelector('.normal-price > div > em').innerText = 'R$ 149,00' 9957 }), 9958 document.querySelector('._user #_filterModal').classList.add('_open'), 9959 document.querySelector('._bottom-menu #_filterModal').classList.add('_open') 9960 }, 9961 closePopup: () => { 9962 document.querySelector('._user #_miniCartPop').classList.remove('_open'), 9963 document.querySelector('._bottom-menu #_miniCartPop').classList.remove('_open') 9964 }, 9965 closePopupCilindro: () => { 9966 document.querySelector('._user #_cilindroPop').classList.remove('_open'), 9967 document.querySelector('._bottom-menu #_cilindroPop').classList.remove('_open') 9968 }, 9969 closePopupFiltro: () => { 9970 document.querySelector('._user #_filterPop').classList.remove('_open'), 9971 document.querySelector('._bottom-menu #_filterPop').classList.remove('_open') 9972 },
9973 closeModalCilindro: () => { 9974 document.querySelector('._user #_cilindroModal').classList.remove('_open'), 9975 document.querySelector('._bottom-menu #_cilindroModal').classList.remove('_open') 9976 }, 9977 closeModalFiltro: () => { 9978 document.querySelector('._user #_filterModal').classList.remove('_open'), 9979 document.querySelector('._bottom-menu #_filterModal').classList.remove('_open') 9980 }, 9981 clearProducts: async () => { 9982 document.querySelector('._mini-cart ._items').classList.add('_loading') 9983 try { 9984 const e = await axios.post( 9985 '/api/checkout/pub/orderForm/' + vtexjs.checkout.orderForm.orderFormId + '/items/removeAll', 9986 { 9987 data: [{}], 9988 } 9989 ) 9990 $(window).trigger('orderFormUpdated.vtex', [e]), 9991 await MiniCart.getOrderform(), 9992 document.querySelector('._mini-cart ._items').classList.remove('_loading') 9993 } catch (e) { 9994 console.error(e), document.querySelector('._mini-cart ._items').classList.remove('_loading') 9995 } 9996 }, 9997 clearUser: async () => { 9998 try { 9999 await axios.post('/api/checkout/changeToAnonymousUser/' + vtexjs.checkout.orderForm.orderFormId), 10000 MiniCart.updateProductList() 10001 } catch (e) { 10002 console.error(e) 10003 } 10004 }, 10005 getItems: async (e) => { 10006 ;(window.customCart = []), 10007 (customCart.items = []), 10008 (customCart.items.vouncher = []), 10009 (customCart.items.prime = []), 10010 (customCart.items.machine = []), 10011 (customCart.items.caps = []), 10012 (customCart.items.caps.normal = []), 10013 (customCart.items.caps.drink = []), 10014 (customCart.items.mix = []), 10015 (customCart.items.mix.normal = []), 10016 (customCart.items.mix.welcome = []), 10017 (customCart.items.notCategorized = []), 10018 (customCart.items.accessories = []), 10019 e.items.forEach(function (t, n) { 10020 if ('/29/' === t.productCategoryIds) 10021 '45' === t.productId 10022 ? customCart.items.vouncher.push({ 10023 index: n, 10024 item: t, 10025 }) 10026 : customCart.items.prime.push({ 10027 index: n, 10028 item: t, 10029 }) 10030 else if (t.productCategoryIds.includes('/1/')) 10031 customCart.items.machine.push({ 10032 index: n, 10033 item: t, 10034 }) 10035 else if (t.productCategoryIds.includes('/4/')) 10036 customCart.items.accessories.push({ 10037 index: n, 10038 item: t, 10039 }) 10040 else if (t.productCategoryIds.includes('/2/')) 10041 t.productCategoryIds.includes('/2/6/') 10042 ? customCart.items.caps.drink.push({ 10043 index: n, 10044 item: t, 10045 }) 10046 : customCart.items.caps.normal.push({ 10047 index: n, 10048 item: t, 10049 }) 10050 else if (t.productCategoryIds.includes('/20/')) 10051 if ('375' === t.productId) 10052 customCart.items.mix.welcome.push({ 10053 index: n, 10054 item: t, 10055 }) 10056 else { 10057 const i = [] 10058 e.items.forEach(function (e, t) { 10059 e.productCategoryIds.includes('/2/') && 10060 e.parentItemIndex === n && 10061 i.push({ 10062 indexB: t, 10063 itemB: e, 10064 }) 10065 }), 10066 customCart.items.mix.normal.push({ 10067 index: n, 10068 item: t, 10069 caps: i, 10070 }) 10071 } 10072 else 10073 console.alert('Not include on custom cart:', n, t.productCategoryIds, t), 10074 customCart.items.notCategorized.push({ 10075 index: n, 10076 item: t, 10077 }) 10078 }) 10079 }, 10080 onOrderformUpdate: () => { 10081 let e = [] 10082 $(window).on('orderFormUpdated.vtex', async function (t, n) { 10083 e !== n.items && (MiniCart.updateProductList(), (e = n.items)) 10084 }) 10085 }, 10086 getOrderform: async () => { 10087 try { 10088 await waitForVtexjs() 10089 await vtexjs.checkout.getOrderForm() 10090 } catch (e) { 10091 console.error(e) 10092 } 10093 }, 10094 updateProductList: () => { 10095 if (document.querySelector('._buy-btn'))
10096 try { 10097 Buy.updateQuantityBtn() 10098 } catch (e) {} 10099 if (!document.querySelector('._mini-cart')) return null 10100 const e = new Intl.NumberFormat('pt-BR', { 10101 style: 'currency', 10102 currency: 'BRL', 10103 minimumFractionDigits: 2, 10104 }) 10105 let t = '' 10106 if ( 10107 (vtexjs.checkout.orderForm.items.forEach(function (n, i) { 10108 var o = e.format((n.price * n.quantity) / 100), 10109 s = e.format((n.listPrice * n.quantity) / 100) 10110 let a = n.listPrice > n.price 10111 var u = '' 10112 if (shouldShowSubscriptionOnItem(n, i)) { 10113 const r = n.attachments.find((e) => 'pay2b.subscription' === e.name) 10114 if (r) { 10115 const e = r.content['pay2b.subscription.recurring.value'] 10116 if ('a cada 1 mês' === e) var c = 'Frequência mensal' 10117 else if ('a cada 2 meses' === e) c = 'A cada 2 meses' 10118 else if ('a cada 45 dias' === e) c = 'A cada 45 dias' 10119 else if ('a cada 75 dias' === e) c = 'A cada 75 dias' 10120 else if ('a cada 3 meses' === e) c = 'A cada 3 meses' 10121 else if ('a cada 6 meses' === e) c = 'A cada 6 meses' 10122 u = '<div class="_sub">' + c + '</div>' 10123 } 10124 } 10125 if ('290' === n.productId) { 10126 let s = '', 10127 a = 0 10128 vtexjs.checkout.orderForm.items.forEach(function (e, t) { 10129 e.parentItemIndex === parseInt(i) && 10130 ((s = s + '<div><span>' + e.quantity + '</span> ' + e.name + '</div>'), (a += e.price * e.quantity)) 10131 }) 10132 o = e.format((a + n.price) / 100) 10133 t += `\n <div data-index="${i}" data-sku="${n.productId}">\n <div class="_img">\n <a href="/caixa-capsulas-sortidas-monte-a-sua">\n <img src="${n.imageUrl}" alt="${n.name}" />\n </a>\n </div>\n <div class="_info">\n <div class="_name">\n <a href="/caixa-capsulas-sortidas-monte-a-sua">\n ${n.name}\n </a>\n ${u}\n </div>\n \n <div class="_summary">\n <details class="_box">\n <summary>Ver itens</summary>\n ${s}\n </details>\n <div class="_price">\n ${o}\n </div>\n </div>\n </div>\n \n <div class="_del" onclick="MiniCart.removeItemIndex(${i})">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M2.25 4.5H3.75H15.75" stroke="#ABABAB" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"/>\n <path d="M14.25 4.5V15C14.25 15.3978 14.092 15.7794 13.8107 16.0607C13.5294 16.342 13.1478 16.5 12.75 16.5H5.25C4.85218 16.5 4.47064 16.342 4.18934 16.0607C3.90804 15.7794 3.75 15.3978 3.75 15V4.5M6 4.5V3C6 2.60218 6.15804 2.22064 6.43934 1.93934C6.72064 1.65804 7.10218 1.5 7.5 1.5H10.5C10.8978 1.5 11.2794 1.65804 11.5607 1.93934C11.842 2.22064 12 2.60218 12 3V4.5" stroke="#ABABAB" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"/>\n <path d="M7.5 8.25V12.75" stroke="#ABABAB" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"/>\n <path d="M10.5 8.25V12.75" stroke="#ABABAB" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"/>\n </svg>\n </div>\n </div>\n ` 10134 } else n.parentItemIndex || (t += `\n <div data-index="${i}" data-sku="${n.productId}">\n <div class="_img">\n <a href="${n.detailUrl}">\n <img src="${n.imageUrl}" alt="${n.name}" />\n </a>\n </div>\n <div class="_info">\n <div class="_name">\n <a href="${n.detailUrl}">\n ${n.name}\n </a>\n </div>\n ${u}\n <div class="_value">\n <div class="_amt">\n ${n.quantity} ${n.quantity > 1 ? 'unidades' : 'unidade'}:\n </div>\n <div class="_listPrice">\n ${n.isGift || !a ? '' : s}\n </div>\n ${a ? '<span>ââ¬Â¢</span>' : ''}\n <div class="_price ${n.isGift ? '_gift' : ''}">\n ${n.isGift ? 'Brinde' : o}\n </div>\n </div>\n </div>\n <div class="_del" onclick="MiniCart.removeItemIndex(${i})">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M2.25 4.5H3.75H15.75" stroke="#ABABAB" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"/>\n <path d="M14.25 4.5V15C14.25 15.3978 14.092 15.7794 13.8107 16.0607C13.5294 16.342 13.1478 16.5 12.75 16.5H5.25C4.85218 16.5 4.47064 16.342 4.18934 16.0607C3.90804 15.7794 3.75 15.3978 3.75 15V4.5M6 4.5V3C6 2.60218 6.15804 2.22064 6.43934 1.93934C6.72064 1.65804 7.10218 1.5 7.5 1.5H10.5C10.8978 1.5 11.2794 1.65804 11.5607 1.93934C11.842 2.22064 12 2.60218 12 3V4.5" stroke="#ABABAB" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"/>\n <path d="M7.5 8.25V12.75" stroke="#ABABAB" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"/>\n <path d="M10.5 8.25V12.75" stroke="#ABABAB" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"/>\n </svg>\n </div>\n </div>\n `) 10135 }), 10136 t.length <= 0 10137 ? ((document.querySelector('._mini-cart ._items').innerHTML = 10138 '\n <div class="_empty-cart-message">\n <svg width="82" height="77" viewBox="0 0 82 77" fill="none" xmlns="http://www.w3.org/2000/svg">\n <g opacity="0.5">\n <path d="M40.833 67.3664C40.833 70.8418 38.0137 73.6433 34.5561 73.6433C31.0808 73.6433 28.2793 70.824 28.2793 67.3664C28.2793 63.8911 31.0986 61.0896 34.5561 61.0896C38.0315 61.0896 40.833 63.9089 40.833 67.3664Z" stroke="#D9693B" stroke-width="5" stroke-linecap="round" stroke-linejoin="round"/>\n <path d="M69.7315 67.3664C69.7315 70.8418 66.9122 73.6433 63.4546 73.6433C59.9793 73.6433 57.1777 70.824 57.1777 67.3664C57.1777 63.8911 59.997 61.0896 63.4546 61.0896C66.9299 61.0896 69.7315 63.9089 69.7315 67.3664Z" stroke="#D9693B" stroke-width="5" stroke-linecap="round" stroke-linejoin="round"/>\n <path d="M18.5444 16.3537H79.4512L69.3975 52.2416H28.598L14.9095 3.35669H2.55078" stroke="#D9693B" stroke-width="5" stroke-linecap="round" stroke-linejoin="round"/>\n </g>\n </svg> \n <p>Seu carrinho está vazio</p>
10138\n <span>Adicione itens em seu carrinho</span>\n <a href="javascript:void(0)"\n\t\t\t\t\t\t\t\tonclick="MiniCart.closeCart()">Continuar comprando</a>\n </div>'), 10139 document.querySelector('._mini-cart footer').classList.add('_hide'), 10140 document.querySelector('._mini-cart ._items').classList.add('_empty')) 10141 : ((document.querySelector('._mini-cart ._items').innerHTML = t), 10142 document.querySelector('._mini-cart footer').classList.remove('_hide'), 10143 document.querySelector('._mini-cart ._items').classList.remove('_empty')), 10144 !vtexjs.checkout.orderForm) 10145 ) 10146 return null 10147 const n = vtexjs.checkout.orderForm.totalizers[2] 10148 ? e.format(vtexjs.checkout.orderForm.totalizers[2].value / 100) 10149 : e.format(0) 10150 let i = 0 10151 vtexjs.checkout.orderForm.items.forEach(function (e, t) { 10152 null === e.parentItemIndex && i++ 10153 }), 10154 (document.querySelector('._mini-cart ._totals ._total div small span').innerHTML = 10155 i < 1 ? i + ' produto' : i + ' produtos') 10156 const o = document.querySelector('#_cartQuantity') 10157 i > 0 10158 ? ((document.querySelector('#_miniCart div').innerHTML = '<span>' + (i > 99 ? '99+' : i) + '</span>'), 10159 o && (o.innerHTML = '<span>' + (i > 99 ? '99+' : i) + '</span>'), 10160 (document.querySelector('.navbar-item.minicart ._cartQuantity').innerHTML = i > 99 ? '99+' : i)) 10161 : ((document.querySelector('#_miniCart div').innerHTML = ''), 10162 o && (o.innerHTML = ''), 10163 (document.querySelector('.navbar-item.minicart ._cartQuantity').innerHTML = '')), 10164 vtexjs.checkout.orderForm.shippingData && 10165 vtexjs.checkout.orderForm.shippingData.address && 10166 vtexjs.checkout.orderForm.shippingData.address.postalCode 10167 ? ((document.querySelectorAll('._mini-cart ._totals ._shipping div')[1].innerHTML = n), 10168 (document.querySelector('._mini-cart ._totals ._shipping div small').innerHTML = 10169 '(' + 10170 vtexjs.checkout.orderForm.shippingData.address.postalCode.replace(/(\d{5})(\d{3})/, '$1-$2') + 10171 ') <small><a href="#" onclick="MiniCart.calcShipping()">alterar</a></small>')) 10172 : ((document.querySelectorAll('._mini-cart ._totals ._shipping div')[1].innerHTML = 10173 '<a href="#" onclick="MiniCart.calcShipping()">Calcular</a>'), 10174 (document.querySelector('._mini-cart ._totals ._shipping div small').innerHTML = '')), 10175 vtexjs.checkout.orderForm.marketingData && vtexjs.checkout.orderForm.marketingData.coupon 10176 ? (document.querySelectorAll('._mini-cart ._totals ._coupon div')[1].innerHTML = 10177 '<small><a href="#" onclick="MiniCart.removeCoupon()">remover</a></small> <strong><code>' + 10178 vtexjs.checkout.orderForm.marketingData.coupon + 10179 '</strong></code>') 10180 : (document.querySelectorAll('._mini-cart ._totals ._coupon div')[1].innerHTML = 10181 '<a href="#" onclick="MiniCart.editCoupon()">Adicionar</a>') 10182 const s = e.format( 10183 vtexjs.checkout.orderForm.items.reduce((e, t) => e + (t.listPrice || 0) * (t.quantity || 1), 0) / 100 10184 ) 10185 document.querySelectorAll('._mini-cart ._totals ._sub div')[1].innerHTML = s 10186 const a = vtexjs.checkout.orderForm.totalizers.find((e) => 'Discounts' === e.id) 10187 ? e.format(vtexjs.checkout.orderForm.totalizers.find((e) => 'Discounts' === e.id).value / 100) 10188 : e.format(0) 10189 document.querySelectorAll('._mini-cart ._totals ._dsc div')[1].innerHTML = a 10190 const r = vtexjs.checkout.orderForm.totalizers.find((e) => 'Shipping' === e.id) 10191 ? e.format(vtexjs.checkout.orderForm.totalizers.find((e) => 'Shipping' === e.id).value / 100) 10192 : e.format(0) 10193 document.querySelectorAll('._mini-cart ._totals ._shipping div')[1].innerHTML = r 10194 e.format(vtexjs.checkout.orderForm.value / 100) 10195 const c = e.format( 10196 vtexjs.checkout.orderForm.items.reduce((e, t) => e + (t.price || 0) * (t.quantity || 1), 0) / 100 10197 ) 10198 ;(document.querySelector('._mini-cart ._totals ._total p').innerHTML = c), FreteExpress.banner() 10199 }, 10200 changeShipping: async (e = null) => { 10201 if ( 10202 (e || (e = document.querySelector('._mini-cart ._shipping input').value), 10203 document.querySelector('._cart ._add._shipping').classList.add('_loading'), 10204 document.querySelector('._cart ._add._shipping ._alert').classList.add('_hide'), 10205 !e) 10206 ) 10207 return ( 10208 document.querySelector('._cart ._add._shipping ._alert').classList.remove('_hide'), 10209 document.querySelector('._cart ._add._shipping').classList.remove('_loading'), 10210 null 10211 ) 10212 try { 10213 await vtexjs.checkout.calculateShipping({ 10214 postalCode: e, 10215 country: 'BRA', 10216 }), 10217 document.querySelector('._cart ._add._shipping').classList.add('_hide'), 10218 document.querySelector('._cart ._add._shipping').classList.remove('_loading'), 10219 (document.querySelector('._cart ._mini-cart ._items').style.maxHeight = 'calc(100vh - 350px)'), 10220 MiniCart.updateProductList() 10221 } catch (e) { 10222 console.error(e), 10223 document.querySelector('._cart ._add._shipping ._alert').classList.remove('_hide'), 10224 document.querySelector('._cart ._add._shipping').classList.remove('_loading') 10225 } 10226 }, 10227 changeCoupon: async (e = null) => { 10228 if ( 10229 (e || (e = document.querySelector('._mini-cart ._coupon input').value), 10230 document.querySelector('._cart ._add._coupon').classList.add('_loading'), 10231 !e) 10232 ) 10233 return ( 10234 document.querySelector('._cart ._add._coupon ._alert').classList.remove('_hide'), 10235 document.querySelector('._cart ._add._coupon').classList.remove('_loading'), 10236 null 10237 ) 10238 try { 10239 await vtexjs.checkout.addDiscountCoupon(e), 10240 document.querySelector('._cart ._add._coupon').classList.add('_hide'), 10241 document.querySelector('._cart ._add._coupon').classList.remove('_loading'), 10242 (document.querySelector('._cart ._mini-cart ._items').style.maxHeight = 'calc(100vh - 350px)'), 10243 MiniCart.updateProductList() 10244 } catch (e) { 10245 console.error(e), 10246 document.querySelector('._cart ._add._coupon ._alert').classList.remove('_hide'), 10247 document.querySelector('._cart ._add._coupon').classList.remove('_loading') 10248 } 10249 }, 10250 editCoupon: () => { 10251 document.querySelector('._cart ._add._coupon').classList.remove('_hide'), 10252 (document.querySelector('._cart ._mini-cart ._items').style.maxHeight = 'calc(100vh - 455px)') 10253 }, 10254 calcShipping: () => { 10255 document.querySelector('._cart ._add._shipping').classList.remove('_hide'), 10256 (document.querySelector('._cart ._mini-cart ._items').style.maxHeight = 'calc(100vh - 455px)') 10257 }, 10258 removeCoupon: async () => { 10259 try { 10260 await vtexjs.checkout.removeDiscountCoupon(), MiniCart.updateProductList() 10261 } catch (e) { 10262 console.error(e) 10263 } 10264 }, 10265 updateOrderForm: async (e = null) => { 10266 if (e) vtexjs.checkout.orderForm = e 10267 else
10268 try { 10269 ;(vtexjs.checkout.orderForm = await vtexjs.checkout.getOrderForm()), 10270 $(window).trigger('orderFormUpdated.vtex', [vtexjs.checkout.orderForm]) 10271 } catch (e) { 10272 console.error(e) 10273 } 10274 MiniCart.updateProductList(), MiniCart.couponData() 10275 }, 10276 removeItemIndex: async (e) => { 10277 document.querySelector('._mini-cart ._items div[data-index="' + e + '"]').classList.add('_loading') 10278 try { 10279 const t = await vtexjs.checkout.removeItems([ 10280 { 10281 index: e, 10282 quantity: 0, 10283 }, 10284 ]) 10285 MiniCart.updateOrderForm(t) 10286 } catch (t) { 10287 console.error(t), 10288 document.querySelector('._mini-cart ._items div[data-index="' + e + '"]').classList.remove('_loading') 10289 } 10290 }, 10291 couponData: async () => { 10292 const e = new URLSearchParams(window.location.search) 10293 e.get('coupon') && vtexjs.checkout.addDiscountCoupon(e.get('coupon')) 10294 }, 10295 subscriptionDataUpdate: async (e) => { 10296 const t = [], 10297 n = e.items 10298 .map((e, n) => { 10299 const i = e.attachments.find((e, t) => 'pay2b.subscription' === e.name) 10300 if (!i) return 10301 const o = i.content['pay2b.subscription.recurring.value'], 10302 s = FREQUENCY_OPTIONS.find((e) => e.pay2bKey === o) 10303 return ( 10304 t.push(e.id), 10305 { 10306 executionCount: 0, 10307 itemIndex: n, 10308 plan: { 10309 frequency: { 10310 interval: s.interval, 10311 periodicity: s.periodicity, 10312 type: 'RECURRING_PAYMENT', 10313 }, 10314 }, 10315 } 10316 ) 10317 }) 10318 .filter((e) => e) 10319 return vtexjs.checkout 10320 .sendAttachment('subscriptionData', { 10321 subscriptions: n, 10322 }) 10323 .fail((e) => { 10324 Main.sendDataLayer({ 10325 event: 'errorWithoutSubscriptionData', 10326 skus: t.join('|'), 10327 }) 10328 }) 10329 }, 10330} 10331MiniCart.init() 10332const documentBody = document.body, 10333 currentButtonPage = window.location.pathname, 10334 isCheckout = currentButtonPage.includes('checkout'), 10335 isBebidas = currentButtonPage.includes('bebida'), 10336 isCollectionNew = documentBody.id.includes('collection'), 10337 isCategoryNew = documentBody.id.includes('category'), 10338 isHome = documentBody.id.includes('home'), 10339 isNewHomeB = currentButtonPage.includes('home'), 10340 isCilinder = documentBody.classList.contains('CODEBY-product-cilinder'), 10341 isFilter = documentBody.classList.contains('CODEBY-product-filter') 10342isNewHomeB && !documentBody.classList.contains('home-b') && documentBody.classList.add('home-b') 10343const addAttributeListener = (e, t, n) => { 10344 const i = new MutationObserver(function (e) { 10345 e.forEach(function (e) { 10346 e.attributeName === t && (i.disconnect(), n()) 10347 }) 10348 }) 10349 i.observe(e, { 10350 attributes: !0, 10351 }) 10352 }, 10353 BuyButton = { 10354 onClickHandler: async (e) => { 10355 e.classList.add('_loading') 10356 const t = await BuyButton.getProductInfo(e) 10357 if (t.onButtonClick) { 10358 if ((e.classList.remove('_loading'), 'string' == typeof t.onButtonClick)) { 10359 const e = extractFunctionFromString(t.onButtonClick) 10360 'function' == typeof e && e(t) 10361 } 10362 return 10363 } 10364 window.currentProductId = t.id 10365 const n = '68' === t.id, 10366 i = '38' === t.id 10367 e.classList.contains('subscription') 10368 ? ($('#product-buy-modal-with-subscription-wrapper .occurrence-selection').hide(), 10369 $('#product-buy-modal-with-subscription-wrapper .quantity-options-list-title').text( 10370 'Quantos acessórios você deseja adicionar?' 10371 )) 10372 : ($('#product-buy-modal-with-subscription-wrapper .occurrence-selection').show(), 10373 $('#product-buy-modal-with-subscription-wrapper .quantity-options-list-title').text( 10374 'Quantas bebidas você deseja adicionar?' 10375 )), 10376 t.showDefaultModal || 10377 (!t.category.isCapsule && !n && !i) || 10378 (t.subscriptionPrice == null && !n && !i) || 10379 e.classList.contains('unique') 10380 ? BuyModal.open(t) 10381 : BuyModalWithSubscripition.open(t), 10382 e.classList.remove('_loading') 10383 }, 10384 getProductInfo: async (e, t = !1) => { 10385 BuyButton.validateWrapperData(e) 10386 let n = e.getAttribute('data-product-id') || skuJson.productId, 10387 i = e.getAttribute('data-product-sku'), 10388 o = e.getAttribute('data-product-name'), 10389 s = e.getAttribute('data-product-seller'), 10390 a = e.getAttribute('data-current-quantity'), 10391 r = e.getAttribute('data-product-price'), 10392 c = e.getAttribute('data-product-old-price'), 10393 u = e.getAttribute('data-product-categories-ids'), 10394 l = e.getAttribute('data-product-available'), 10395 d = e.getAttribute('defaultModal'), 10396 p = e.getAttribute('data-product-subscription-discount'), 10397 h = e.getAttribute('data-frequency-key'), 10398 m = e.getAttribute('onSelectQuantity'), 10399 f = e.getAttribute('defaultOccurenceSelected'), 10400 y = e.getAttribute('hideOccurenceSelection'), 10401 v = e.getAttribute('onButtonClick') 10402 if ( 10403 ('subscription' !== f && 'one-tile' !== f && (f = void 0), 10404 (d = 'true' == d), 10405 (y = 'true' == y), 10406 (l = 'true' == l || 'false' == l ? 'true' == l : void 0), 10407 (r = Number.isNaN(r) ? null : Number(r)), 10408 !(o && u && n && i && r && 'boolean' == typeof l && c)) 10409 ) { 10410 let t 10411 n ? (t = await fetchProductById(n)) : i && (t = await fetchProductBySku(i)) 10412 const a = t[0].items[0], 10413 d = a.sellers.find((e) => e.sellerDefault) 10414 ;(r = d.commertialOffer.Price), 10415 (c = d.commertialOffer.ListPrice), 10416 (n = t[0].productId), 10417 (i = a.itemId), 10418 (o = a.name), 10419 (s = d ? d.sellerId : 'bblend'), 10420 (u = t[0].categoriesIds[0]), 10421 (l = d.commertialOffer.IsAvailable), 10422 BuyButton.setButtonWrapperProductData(e, t[0]), 10423 BuyButton.validateWrapperData(e) 10424 } 10425 const subscriptionPriceData = await fetchSkuSubscriptionPrice(i, s || 'bblend') 10426 let g = formatCategoriesIds(u), 10427 b = g.includes(CATEGORY_ID.CAPSULE), 10428 k = g.includes(CATEGORY_ID.DRINK), 10429 S = g.includes(CATEGORY_ID.ACCESSORY), 10430 C = g.includes(CATEGORY_ID.COMBO) 10431 return { 10432 id: n, 10433 sku: i, 10434 name: o, 10435 seller: s, 10436 categoriesIds: g, 10437 quantity: a, 10438 isAvailable: l, 10439 showDefaultModal: d, 10440 price: r, 10441 oldPrice: c, 10442 frequencyKey: h || !1, 10443 subscriptionPrice: subscriptionPriceData?.precoFinal ?? null, 10444 onSelectQuantity: m, 10445 defaultOccurenceSelected: f, 10446 hideOccurenceSelection: y, 10447 category: { 10448 isCapsule: b, 10449 isDrink: k, 10450 isAccessory: S, 10451 isCombo: C, 10452 }, 10453 onButtonClick: v, 10454 } 10455 }, 10456 validateWrapperData: (e) => { 10457 const t = 'undefined' != typeof skuJson 10458 let n = e.getAttribute('data-product-id'), 10459 i = e.getAttribute('data-product-sku') 10460 t && ((n = skuJson.productId), (i = skuJson.skus[0].sku)) 10461 const o = e.getAttribute('data-product-categories-ids') 10462 if ((!n && !i) || !o) return e.classList.add('_invisible'), e 10463 e.classList.remove('_invisible') 10464 }, 10465 updateAccordingToOrderForm: (e, t) => { 10466 const n = e.querySelector('.buy-button-text'), 10467 i = e.querySelector('.buy-button-update-text'), 10468 o = e.querySelector('.buy-button-update-text .quantity'), 10469 s = document.querySelector('._fix-buy-button') 10470 if (!t) 10471 return ( 10472 e.parentNode.removeAttribute('data-current-quantity'), 10473 e.parentNode.removeAttribute('data-frequency-key'), 10474 e.parentNode.classList.remove('_is-in-cart'), 10475 n.classList.remove('_hide'), 10476 i.classList.add('_hide'), 10477 void (s && (s.innerHTML = 'Selecionar Quantidade')) 10478 ) 10479 const a = t.quantity, 10480 r = t.attachments.find((e) =>
10480 'pay2b.subscription' === e.name) 10481 if (r) { 10482 const t = ALL_FREQUENCY_OPTIONS.find((e) => e.pay2bKey === r.content['pay2b.subscription.recurring.value']) 10483 e.parentNode.setAttribute('data-frequency-key', t.key) 10484 } else e.parentNode.removeAttribute('data-frequency-key') 10485 e.parentNode.setAttribute('data-current-quantity', a), 10486 e.parentNode.classList.add('_is-in-cart'), 10487 n.classList.add('_hide'), 10488 i.classList.remove('_hide'), 10489 (o.innerHTML = a), 10490 s && (s.innerHTML = a + ' adicionados') 10491 }, 10492 updateAccordingToAvailability: (e, t) => { 10493 const n = e.parentNode, 10494 i = n.querySelector('.remind-me-button') 10495 t 10496 ? (n.classList.remove('_not-available'), i.classList.add('_hide'), e.classList.remove('_hide')) 10497 : (n.classList.add('_not-available'), i.classList.remove('_hide'), e.classList.add('_hide')) 10498 }, 10499 updateDefaultModalValue: (e) => { 10500 let t = !1 10501 t = !(!t || 'false' == t) 10502 e.parentNode.setAttribute('defaultmodal', t) 10503 }, 10504 setButtonWrapperProductData: (e, t) => { 10505 if (!e || !t) 10506 return ( 10507 e || console.log('buyButtonWrapperElement not found'), void (t || console.log('productInfo not provided')) 10508 ) 10509 const n = t.items[0].sellers.find((e) => e.sellerDefault), 10510 i = t.productId, 10511 o = t.items[0].itemId, 10512 s = t.productName, 10513 a = n.sellerId, 10514 r = t.categoriesIds[0], 10515 c = n.commertialOffer.IsAvailable, 10516 u = n.commertialOffer.Price, 10517 l = t.valor_desconto_recorrencia ? t.valor_desconto_recorrencia[0] : null 10518 BuyButton.changeButtonBuyCombo(e, t), 10519 e.setAttribute('data-product-id', i), 10520 e.setAttribute('data-product-sku', o), 10521 e.setAttribute('data-product-name', s), 10522 e.setAttribute('data-product-seller', a), 10523 e.setAttribute('data-product-categories-ids', r), 10524 e.setAttribute('data-product-available', c), 10525 e.setAttribute('data-product-price', u), 10526 e.setAttribute('data-product-subscription-discount', l) 10527 }, 10528 changeButtonBuyCombo: (e, t) => { 10529 const n = t.categories[0].includes('combos'), 10530 i = e.parentNode.querySelector('._buy') 10531 if (n && i) { 10532 ;(t['Botão CTA'] || []).length > 0 10533 ? (i.remove(), e.classList.remove('_hide'), e.classList.add('_combo')) 10534 : e.remove() 10535 } 10536 }, 10537 appendProductDataToFloatingButton: async () => { 10538 const e = document.querySelector('.occurrence-name.subscription'), 10539 t = await fetchProductById(window.skuJson.productId) 10540 BuyButton.setButtonWrapperProductData(e, t[0]) 10541 }, 10542 }, 10543 BuyButtons = { 10544 data: { 10545 buyButtonElements: [], 10546 }, 10547 init: () => { 10548 BuyButtons.getBuyButtonElements(), 10549 BuyButtons.data.buyButtonElements.length && 10550 (BuyButtons.loadInnerTexts(), 10551 BuyButtons.updateAccordingToOrderForm(), 10552 BuyButtons.updateAccordingToAvailability(), 10553 BuyButtons.updateDefaultModalValue()) 10554 }, 10555 getBuyButtonElements: () => { 10556 const e = document.querySelectorAll('.buy-button-wrapper .buy-button') 10557 BuyButtons.data.buyButtonElements = e 10558 }, 10559 loadInnerTexts: () => { 10560 const { buyButtonElements: e } = BuyButtons.data 10561 e.forEach((e) => { 10562 const t = e.parentNode, 10563 n = e.querySelector('.buy-button-text'), 10564 i = t.querySelector('.remind-me-button-text'), 10565 o = t.getAttribute('customBuyButtonText'), 10566 s = t.getAttribute('customRemindMeButtonText') 10567 ;(n.innerHTML = o || 'Comprar'), (i.innerHTML = s || 'Avise-me') 10568 }) 10569 }, 10570 updateAccordingToAvailability: async () => { 10571 const { buyButtonElements: e } = BuyButtons.data 10572 for (const t of e) { 10573 const e = t.parentNode 10574 e.classList.add('_loading') 10575 const n = BuyButton.validateWrapperData(e), 10576 i = async () => { 10577 const n = await BuyButton.getProductInfo(e, !0) 10578 BuyButton.updateAccordingToAvailability(t, n.isAvailable) 10579 } 10580 n 10581 ? (addAttributeListener(n, 'data-product-id', i), 10582 addAttributeListener(n, 'data-product-sku', i), 10583 e.classList.remove('_loading')) 10584 : (i(), e.classList.remove('_loading')) 10585 } 10586 }, 10587 updateAccordingToOrderForm: async (e) => { 10588 e || (e = vtexjs.checkout.orderForm), e || (e = await vtexjs.checkout.getOrderForm()) 10589 const t = e.items, 10590 { buyButtonElements: n } = BuyButtons.data, 10591 i = [...n] 10592 t.forEach((e) => { 10593 const t = e.id, 10594 o = e.productId
10595 n.forEach((n) => { 10596 ;(buyButtonProductSku = n.parentNode.getAttribute('data-product-sku')), 10597 (buyButtonProductId = n.parentNode.getAttribute('data-product-id')), 10598 (buyButtonProductId != o && buyButtonProductSku != t) || 10599 (BuyButton.updateAccordingToOrderForm(n, e), i.splice(i.indexOf(n), 1)) 10600 }) 10601 }), 10602 i.forEach((e) => { 10603 BuyButton.updateAccordingToOrderForm(e) 10604 }) 10605 }, 10606 updateDefaultModalValue: () => { 10607 const { buyButtonElements: e } = BuyButtons.data 10608 e.forEach((e) => { 10609 const t = e.parentNode.querySelector('.default-modal-info') 10610 t && BuyButton.updateDefaultModalValue(t) 10611 }) 10612 }, 10613 } 10614isBebidas || 10615 isCheckout || 10616 isCategoryNew || 10617 isCollectionNew || 10618 isHome || 10619 (BuyButtons.init(), BuyButton.appendProductDataToFloatingButton()) 10620 10621const RemindMeModal = { 10622 close: () => { 10623 document.getElementById('product-remind-me-modal-wrapper').remove() 10624 }, 10625 open: async (e) => { 10626 const t = await BuyButton.getProductInfo(e), 10627 n = document.querySelector('body'), 10628 i = document.createElement('div') 10629 ;(i.id = 'product-remind-me-modal-wrapper'), 10630 (i.innerHTML = `\n <div class="remind-me-modal">\n <header class="header">\n <button class="close-icon" onclick="RemindMeModal.close()">\n <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 17 17"><defs></defs><path fill="#000" d="M10.795 8.625L16.068 3.4c.293-.293.293-.83 0-1.123l-1.22-1.22c-.293-.293-.83-.293-1.123 0L8.5 6.33 3.227 1.057c-.293-.293-.83-.293-1.123 0L.883 2.277c-.293.293-.293.83 0 1.123l5.273 5.225-5.273 5.273c-.293.293-.293.83 0 1.123l1.22 1.221c.293.293.83.293 1.124 0L8.5 10.97l5.225 5.273c.293.293.83.293 1.123 0l1.22-1.22c.293-.293.293-.83 0-1.124l-5.273-5.273z"></path></svg>\n </button>\n \n <p class="form-tittle">Ops, este produto está temporariamente indisponÃÂvel</p>\n <p class="success-message _hide">Cadastrado com sucesso!</p>\n </header>\n <div class="body">\n <div class="form-wrapper">\n <p>\n <span class="warning-text">!</span>\n <span>Seja avisado quando sua ${t.name} voltar ao estoque!</span>\n </p>\n \n <form onsubmit="RemindMeModal.onSubmit(event, ${t.sku})">\n <input id="remind-me-name-input" placeholder="Digite seu nome..." />\n <input id="remind-me-email-input" placeholder="Digite seu e-mail..." />\n \n <div class="invalid-warning _invisible">Informe um <span class="invalid-field"></span> válido</div>\n <button class="submit-button" type="submit" name="remind-me-form-submit">Avise-me</button>\n </form>\n </div>\n \n <div class="success-message _hide">\n Assim que o produto for disponibilizado você receberá um email avisando.\n </div>\n </div>\n </div>\n <div class="backdrop" onclick="RemindMeModal.close()"></div>\n `), 10631 n.append(i) 10632 }, 10633 onSubmit: (e, t) => { 10634 e.preventDefault() 10635 const n = e.target, 10636 i = n.querySelector('#remind-me-name-input'), 10637 o = n.querySelector('#remind-me-email-input'), 10638 s = n.querySelector('.invalid-warning'), 10639 a = s.querySelector('.invalid-field'), 10640 r = o.value, 10641 c = i.value 10642 if (!(c.length > 2)) 10643 return i.classList.add('_invalid'), s.classList.remove('_invisible'), void (a.innerHTML = 'nome') 10644 if ((i.classList.remove('_invalid'), s.classList.add('_invisible'), !isValid.email(r))) 10645 return o.classList.add('_invalid'), s.classList.remove('_invisible'), void (a.innerHTML = 'e-mail') 10646 o.classList.remove('_invalid'), s.classList.add('_invisible') 10647 n.querySelector('.submit-button').classList.add('_loading') 10648 RemindMeModal.sendNotifyRequest({ 10649 productSku: t, 10650 name: c, 10651 email: r, 10652 successCallback: () => { 10653 RemindMeModal.loadSuccessMessage() 10654 }, 10655 failCallback: () => { 10656 alert('Não foi possÃÂvel realizar seu cadastro'), RemindMeModal.close() 10657 }, 10658 }) 10659 }, 10660 sendNotifyRequest: async ({ productSku: e, name: t, email: n, successCallback: i, failCallback: o }) => { 10661 const s = new FormData() 10662 s.append('notifymeClientName', t), s.append('notifymeClientEmail', n), s.append('notifymeIdSku', e)
10663 try { 10664 200 === 10665 ( 10666 await fetch('/no-cache/AviseMe.aspx', { 10667 method: 'POST', 10668 body: s, 10669 }) 10670 ).status 10671 ? i() 10672 : o() 10673 } catch (e) { 10674 console.error(e), o() 10675 } 10676 }, 10677 loadSuccessMessage: () => { 10678 const e = document.querySelector('#product-remind-me-modal-wrapper .remind-me-modal'), 10679 t = e.querySelector('header .success-message') 10680 e.querySelector('header .form-tittle').classList.add('_hide'), t.classList.remove('_hide') 10681 const n = e.querySelector('.body .form-wrapper'), 10682 i = e.querySelector('.body .success-message') 10683 n.classList.add('_hide'), i.classList.remove('_hide') 10684 }, 10685 }, 10686 BuyButtonReformuled = { 10687 onClickHandler: async (e) => { 10688 e.classList.add('_loading') 10689 const t = await BuyButtonReformuled.getProductInfo(e) 10690 if (t.onButtonClick) { 10691 if ((e.classList.remove('_loading'), 'string' == typeof t.onButtonClick)) { 10692 const e = extractFunctionFromString(t.onButtonClick) 10693 'function' == typeof e && e(t) 10694 } 10695 return 10696 } 10697 const n = e.getAttribute('data-product-id'), 10698 i = '68' === n, 10699 o = '38' === n 10700 e.classList.contains('subscription') 10701 ? ($('#product-buy-modal-with-subscription-wrapper .occurrence-selection').hide(), 10702 $('#product-buy-modal-with-subscription-wrapper .quantity-options-list-title').text( 10703 'Quantos acessórios você deseja adicionar?' 10704 )) 10705 : ($('#product-buy-modal-with-subscription-wrapper .occurrence-selection').show(), 10706 $('#product-buy-modal-with-subscription-wrapper .quantity-options-list-title').text( 10707 'Quantas bebidas você deseja adicionar?' 10708 )), 10709 t.showDefaultModal || (!t.category.isCapsule && !i && !o) || (t.subscriptionPrice == null && !i && !o) 10710 ? BuyModalReformuled.open(t) 10711 : BuyModalWithSubscripitionReformuled.open(t), 10712 e.classList.remove('_loading') 10713 10714 let timer = setInterval(() => { 10715 $('input#one-time').click() 10716 10717 setTimeout(function () { 10718 clearInterval(timer) 10719 }, 2000) 10720 }, 100) 10721 }, 10722 getProductInfo: async (e, t = !1) => { 10723 BuyButtonReformuled.validateWrapperData(e) 10724 let n = e.getAttribute('data-product-id'), 10725 i = e.getAttribute('data-product-sku'), 10726 o = e.getAttribute('data-product-name'), 10727 s = e.getAttribute('data-product-seller'), 10728 a = e.getAttribute('data-current-quantity'), 10729 r = e.getAttribute('data-product-image'), 10730 c = e.getAttribute('data-product-price'), 10731 u = e.getAttribute('data-product-old-price'), 10732 l = e.getAttribute('data-product-categories-ids'), 10733 d = e.getAttribute('data-product-available'), 10734 p = e.getAttribute('defaultModal'), 10735 h = e.getAttribute('data-product-subscription-discount'), 10736 m = e.getAttribute('data-frequency-key'), 10737 f = e.getAttribute('onSelectQuantity'), 10738 y = e.getAttribute('defaultOccurenceSelected'), 10739 v = e.getAttribute('hideOccurenceSelection'), 10740 g = e.getAttribute('onButtonClick') 10741 if ( 10742 ('subscription' !== y && 'one-tile' !== y && (y = void 0), 10743 (p = 'true' == p), 10744 (v = 'true' == v), 10745 (d = 'true' == d || 'false' == d ? 'true' == d : void 0), 10746 (c = Number.isNaN(c) ? null : Number(c)), 10747 !(o && l && n && i && c && 'boolean' == typeof d && u)) 10748 ) { 10749 let t 10750 n ? (t = await fetchProductById(n)) : i && (t = await fetchProductBySku(i)) 10751 const a = t[0].items[0], 10752 p = a.sellers.find((e) => e.sellerDefault) 10753 ;(c = p.commertialOffer.Price), 10754 (u = p.commertialOffer.ListPrice), 10755 (n = t[0].productId), 10756 (i = a.itemId), 10757 (o = a.name), 10758 (r = a.images.find((e) => 'TopFoil' === e.imageLabel) || a.images[0]), 10759 (s = p ? p.sellerId : 'bblend'), 10760 (l = t[0].categoriesIds[0]), 10761 (d = p.commertialOffer.IsAvailable), 10762 BuyButtonReformuled.setButtonWrapperProductData(e, t[0]) 10763 } 10764 const subscriptionPriceData = await fetchSkuSubscriptionPrice(i, s || 'bblend') 10765 let b = formatCategoriesIds(l), 10766 k = b.includes(CATEGORY_ID.CAPSULE), 10767 S = b.includes(CATEGORY_ID.DRINK), 10768 C = b.includes(CATEGORY_ID.ACCESSORY), 10769 w = b.includes(CATEGORY_ID.COMBO) 10770 return { 10771 id: n, 10772 sku: i, 10773 name: o, 10774 seller: s, 10775 categoriesIds: b, 10776 quantity: a, 10777 isAvailable: d, 10778 showDefaultModal: p, 10779 price: c, 10780 img: r, 10781 oldPrice: u, 10782 frequencyKey: m || !1, 10783 subscriptionPrice: subscriptionPriceData?.precoFinal ?? null, 10784 onSelectQuantity: f, 10785 defaultOccurenceSelected: y, 10786 hideOccurenceSelection: v, 10787 category: { 10788 isCapsule: k, 10789 isDrink: S, 10790 isAccessory: C, 10791 isCombo: w, 10792 }, 10793 onButtonClick: g, 10794 } 10795 }, 10796 validateWrapperData: (e) => { 10797 const t = e.getAttribute('data-product-id'), 10798 n = e.getAttribute('data-product-sku'), 10799 i = e.getAttribute('data-product-categories-ids') 10800 if ((!t && !n) || !i) return e.classList.add('_invisible'), e 10801 e.classList.remove('_invisible') 10802 }, 10803 updateAccordingToOrderForm: (e, t) => { 10804 const n = e.parentNode.parentNode.parentNode.parentNode.parentNode.querySelector('._product-card'), 10805 i = document.querySelector('.quantity-options-list-title'), 10806 o = n.getAttribute('data-department').toLowerCase(), 10807 s = e.parentNode.parentNode.parentNode.querySelector('._name'), 10808 a = e.parentNode.parentNode.parentNode.parentNode.querySelector('._about'), 10809 r = e.parentNode.parentNode.parentNode.querySelector('._info ._price'), 10810 c = e.querySelector('.buy-button-text'), 10811 u = e.querySelector('.buy-button-update-text'), 10812 l = e.querySelector('.buy-button-update-text .quantity'), 10813 d = e.querySelector('.buy-button-update-text .alterar-text') 10814 if (!t) 10815 return ( 10816 e.parentNode.removeAttribute('data-current-quantity'), 10817 e.parentNode.removeAttribute('data-frequency-key'), 10818 e.parentNode.classList.remove('_is-in-cart'), 10819 c.classList.remove('_hide'), 10820 u.classList.add('_hide'), 10821 s.classList.remove('_hide'), 10822 void (r && (a.classList.remove('_hide'), r.classList.remove('_hide'))) 10823 ) 10824 const p = t.quantity, 10825 h = t.attachments.find((e) =>
10825 'pay2b.subscription' === e.name) 10826 if (h) { 10827 const t = ALL_FREQUENCY_OPTIONS.find((e) => e.pay2bKey === h.content['pay2b.subscription.recurring.value']) 10828 e.parentNode.setAttribute('data-frequency-key', t.key) 10829 } else e.parentNode.removeAttribute('data-frequency-key') 10830 isNewHomeB 10831 ? (d.innerHTML = ' ' + ('bebidas' == o ? 'adicionadas' : 'adicionados')) 10832 : (e.parentNode.classList.add('_is-in-cart'), 10833 s.classList.add('_hide'), 10834 r && r.classList.add('_hide'), 10835 a && a.classList.add('_hide'), 10836 (d.innerHTML = `${'b.combos' == o ? 'combos' : o} ${ 10837 'bebidas' == o ? 'adicionadas' : 'adicionados' 10838 } com sucesso`)), 10839 (i.innerHTML = `${'bebidas' == o ? 'Quantas' : 'Quantos'} ${ 10840 'b.combos' == o ? 'combos' : o 10841 } você deseja adicionar?`), 10842 e.parentNode.setAttribute('data-current-quantity', p), 10843 c.classList.add('_hide'), 10844 u.classList.remove('_hide'), 10845 (l.innerHTML = p) 10846 }, 10847 updateAccordingToAvailability: (e, t) => { 10848 const n = e.parentNode, 10849 i = n.querySelector('.remind-me-button') 10850 t 10851 ? (n.classList.remove('_not-available'), i.classList.add('_hide'), e.classList.remove('_hide')) 10852 : (n.classList.add('_not-available'), i.classList.remove('_hide'), e.classList.add('_hide')) 10853 }, 10854 updateDefaultModalValue: (e) => { 10855 let t = !1 10856 t = !(!t || 'false' == t) 10857 e.parentNode.setAttribute('defaultmodal', t) 10858 }, 10859 setButtonWrapperProductData: (e, t) => { 10860 if (!e || !t) 10861 return ( 10862 e || console.alert('buyButtonWrapperElement not found'), void (t || console.alert('productInfo not provided')) 10863 ) 10864 const n = t.items[0].sellers.find((e) => e.sellerDefault), 10865 i = t.productId, 10866 o = t.items[0].itemId, 10867 s = t.productName, 10868 a = n.sellerId, 10869 r = t.categoriesIds[0], 10870 c = n.commertialOffer.IsAvailable, 10871 u = n.commertialOffer.Price, 10872 l = t.valor_desconto_recorrencia ? t.valor_desconto_recorrencia[0] : null, 10873 d = t['URL imagem capsula'] 10874 e.setAttribute('data-product-id', i), 10875 e.setAttribute('data-product-sku', o), 10876 e.setAttribute('data-product-name', s), 10877 e.setAttribute('data-product-seller', a), 10878 e.setAttribute('data-product-categories-ids', r), 10879 e.setAttribute('data-product-available', c), 10880 e.setAttribute('data-product-price', u), 10881 e.setAttribute('data-product-subscription-discount', l), 10882 e.setAttribute('data-product-iamgem', d) 10883 }, 10884 }, 10885 BuyButtonsReformuled = { 10886 data: { 10887 buyButtonElements: [], 10888 }, 10889 init: () => { 10890 BuyButtonsReformuled.getBuyButtonElements(), 10891 BuyButtonsReformuled.data.buyButtonElements.length && 10892 (BuyButtonsReformuled.loadInnerTexts(), 10893 BuyButtonsReformuled.updateAccordingToOrderForm(), 10894 BuyButtonsReformuled.updateAccordingToAvailability(), 10895 BuyButtonsReformuled.updateDefaultModalValue()) 10896 }, 10897 getBuyButtonElements: () => { 10898 const e = document.querySelectorAll('.buy-button-wrapper .buy-button') 10899 BuyButtonsReformuled.data.buyButtonElements = e 10900 }, 10901 loadInnerTexts: () => { 10902 const { buyButtonElements: e } = BuyButtonsReformuled.data 10903 e.forEach((e) => { 10904 const t = e.parentNode, 10905 n = e.querySelector('.buy-button-text'), 10906 i = t.querySelector('.remind-me-button-text'), 10907 o = t.getAttribute('customBuyButtonText'), 10908 s = t.getAttribute('customRemindMeButtonText') 10909 ;(n.innerHTML = o || 'Comprar'), (i.innerHTML = s || 'Avise-me') 10910 }) 10911 }, 10912 updateAccordingToAvailability: async () => { 10913 const { buyButtonElements: e } = BuyButtonsReformuled.data 10914 for (const t of e) { 10915 const e = t.parentNode 10916 e.classList.add('_loading') 10917 const n = BuyButtonReformuled.validateWrapperData(e), 10918 i = async () => { 10919 const n = await BuyButtonReformuled.getProductInfo(e, !0) 10920 BuyButtonReformuled.updateAccordingToAvailability(t, n.isAvailable) 10921 } 10922 n 10923 ? (addAttributeListener(n, 'data-product-id', i), 10924 addAttributeListener(n, 'data-product-sku', i), 10925 e.classList.remove('_loading')) 10926 : (i(), e.classList.remove('_loading')) 10927 } 10928 }, 10929 updateAccordingToOrderForm: async (e) => { 10930 e || (e = vtexjs.checkout.orderForm), e || (e = await vtexjs.checkout.getOrderForm()) 10931 const t = e.items, 10932 { buyButtonElements: n } = BuyButtonsReformuled.data, 10933 i = [...n] 10934 t.forEach((e) => { 10935 const t = e.id, 10936 o = e.productId
10937 n.forEach((n) => { 10938 ;(buyButtonProductSku = n.parentNode.getAttribute('data-product-sku')), 10939 (buyButtonProductId = n.parentNode.getAttribute('data-product-id')), 10940 (buyButtonProductId != o && buyButtonProductSku != t) || 10941 (BuyButtonReformuled.updateAccordingToOrderForm(n, e), i.splice(i.indexOf(n), 1)) 10942 }) 10943 }), 10944 i.forEach((e) => { 10945 BuyButtonReformuled.updateAccordingToOrderForm(e) 10946 }) 10947 }, 10948 updateDefaultModalValue: () => { 10949 const { buyButtonElements: e } = BuyButtonsReformuled.data 10950 e.forEach((e) => { 10951 const t = e.parentNode.querySelector('.default-modal-info') 10952 t && BuyButtonReformuled.updateDefaultModalValue(t) 10953 }) 10954 }, 10955 } 10956;(isBebidas || isCategoryNew || isCollectionNew || isCheckout || isHome) && BuyButtonsReformuled.init() 10957const BuyModalReformuled = { 10958 init: () => { 10959 BuyModalReformuled.createModalElement() 10960 }, 10961 appendQuantityListOptions: (e, t) => { 10962 let n = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 10963 t.category.isDrink 10964 ? (n = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) 10965 : t.category.isCapsule && (n = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) 10966 e.querySelector('.body .quantity-options-list').innerHTML = n 10967 .map( 10968 (e) => 10969 `\n <li>\n <input \n id="default-modal-quantity-option-${e}" \n value="${e}" \n name="product-quantity" \n type="radio" \n onchange="BuyModalReformuled.onQuantityOptionClick(${e}, ${ 10970 t.sku 10971 }, '${t.seller}', ${t.onSelectQuantity})"\n ${ 10972 e == t.quantity ? "checked='true'" : '' 10973 }"\n />\n <label \n class="_product-button" \n for="default-modal-quantity-option-${e}" \n name="quantidade-${e}"\n >\n ${e}\n </label>\n </li>\n ` 10974 ) 10975 .join('') 10976 }, 10977 appendProductNameToModal: (e, t) => { 10978 e.querySelector('.header .name').innerHTML = t 10979 }, 10980 createModalElement: () => { 10981 const e = document.querySelector('body'), 10982 t = document.createElement('div') 10983 ;(t.id = 'product-buy-modal-wrapper'), 10984 t.classList.add('_hide'), 10985 (t.innerHTML = `\n <div class="buy-modal">\n <header class="header _hide">\n <div class="name"></div>\n </header>\n <div class="body">\n <div class="question-message">Quantos ${ 10986 isCollectionNew ? 'produtos' : '' 10987 } você deseja adicionar?</div>\n \n <ul class="quantity-options-list">\n </ul>\n </div>\n </div>\n <div class="backdrop" onclick="BuyModalReformuled.close()"></div>\n `), 10988 e.append(t) 10989 }, 10990 close: () => { 10991 document.querySelector('#product-buy-modal-wrapper').classList.add('_hide') 10992 }, 10993 open: (e) => { 10994 BuyModalReformuled.setIsLoading(!1) 10995 const t = document.querySelector('#product-buy-modal-wrapper') 10996 BuyModalReformuled.appendQuantityListOptions(t, e), 10997 BuyModalReformuled.appendProductNameToModal(t, e.name), 10998 BuyModalReformuled.changeModalTitle(t, e), 10999 t.classList.remove('_hide') 11000 }, 11001 onQuantityOptionClick: async (e, t, n, i) => { 11002 BuyModalReformuled.setIsLoading(!0), 11003 'string' == typeof i && (i = extractFunctionFromString(i)), 11004 'function' == typeof i 11005 ? i(e, t, n) 11006 : (await removeItemPay2bAttachment({ 11007 productSku: t, 11008 }), 11009 await addItemToCart(t, e, n)), 11010 BuyModalReformuled.setIsLoading(!1), 11011 BuyModalReformuled.close() 11012 }, 11013 setIsLoading: (e) => { 11014 const t = document.querySelector('#product-buy-modal-wrapper .body') 11015 e ? t.classList.add('_loading') : t.classList.remove('_loading') 11016 }, 11017 changeModalTitle: (e, t) => { 11018 e.querySelector('.question-message').innerHTML = 11019 (() => { 11020 const e = t.category 11021 switch (!0) { 11022 case e.isCapsule: 11023 return 'Quantas cápsulas' 11024 case e.isDrink: 11025 return 'Quantos drinks' 11026 case e.isAccessory: 11027 return 'Quantos acessórios' 11028 case e.isCombo: 11029 return 'Quantos combos' 11030 default: 11031 return 'Quantos' 11032 } 11033 })() + ' você deseja adicionar?' 11034 }, 11035} 11036;(isBebidas || isCheckout || isCategoryNew || isCollectionNew || isHome) && BuyModalReformuled.init()
11037const BuyModalWithSubscripitionReformuled = { 11038 init: () => { 11039 BuyModalWithSubscripitionReformuled.createModalElement() 11040 }, 11041 appendQuantityListOptions: (e, t) => { 11042 let n = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 11043 t.category.isDrink 11044 ? (n = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) 11045 : t.category.isCapsule && (n = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) 11046 e.querySelector('.body .quantity-options-list').innerHTML = n 11047 .map( 11048 (e) => 11049 `\n <li>\n <input \n id="quantity-option-${e}" \n value="${e}" \n name="product-quantity" \n type="radio" \n ${ 11050 e == t.quantity ? "checked='true'" : '' 11051 }\n />\n <label \n class="_product-button" \n for="quantity-option-${e}" \n name="quantidade-${e}"\n >\n ${e}\n </label>\n </li>\n ` 11052 ) 11053 .join('') 11054 }, 11055 appendProductDataToModal: (e, t) => { 11056 const n = e.querySelector('.body'), 11057 i = e.querySelector('.header .name'), 11058 o = e.querySelector('.occurrence-selection .product-image'), 11059 s = document.querySelector('#product-buy-modal-with-subscription-wrapper .occurrence-selection') 11060 '38' === t.id || '68' === t.id ? s.classList.add('_cilinder-filter') : s.classList.remove('_cilinder-filter'), 11061 t.img && (o.src = t.img.imageUrl) 11062 const a = e.querySelector('.discount-warning'), 11063 r = a.querySelector('.discount-value'), 11064 c = n.querySelectorAll('.occurrence-selection .price .value'), 11065 [u, l, d] = c 11066 i.innerHTML = t.name 11067 n.setAttribute('data-product-sku', t.sku) 11068 n.setAttribute('data-product-seller', t.seller) 11069 const subPrice = t.subscriptionPrice ?? null 11070 const discountPct = 11071 subPrice != null && subPrice < t.price ? Math.round((1 - subPrice / t.price) * 100) : null 11072 discountPct 11073 ? (a.classList.remove('_invisible'), (r.innerHTML = discountPct)) 11074 : a.classList.add('_invisible') 11075 const p = t.price, 11076 h = t.oldPrice 11077 const m = subPrice != null ? subPrice : p 11078 h === p ? u.parentNode.classList.add('_hide') : u.parentNode.classList.remove('_hide') 11079 u.innerHTML = toBrazilianNumberFormat(h) 11080 l.innerHTML = toBrazilianNumberFormat(p) 11081 d.innerHTML = toBrazilianNumberFormat(m) 11082 }, 11083 createModalElement: () => { 11084 const e = document.querySelector('body'), 11085 t = document.createElement('div') 11086 ;(t.id = 'product-buy-modal-with-subscription-wrapper'), t.classList.add('_hide') 11087 const n = `\n <div class="buy-modal-with-subscription">\n <header class="header">\n <div>Você está adicionando:</div>\n <div class="name"></div>\n </header>\n <div class="body _subscription-option-selected">\n <div class="quantity-options-list-title">Quantas bebidas você deseja adicionar?</div>\n <ul class="quantity-options-list">\n </ul>\n <span class="_error-message _quantity _hide">Selecione a quantidade para continuar</span>\n <div class="current-quantity">\n <span>\n <strong class="quantity">10</strong><strong>bebidas</strong> adicionadas\n </span>\n\n <button class="_product-button" onclick="BuyModalWithSubscripitionReformuled.removeQuantitySelected()">Alterar</button>\n </div>\n\n <div class="occurrence-selection">\n <label class="one-time-label">\n <div class="name-wrapper">\n <input id="one-time" name="occurrence-selection" type="radio" onchange="BuyModalWithSubscripitionReformuled.onChangeOccurence(this)" />\n <div class="selector-controller"></div>\n <div class="_text">Comprar uma vez</div>\n </div>\n\n <div class="price">\n <div class="old-price">De:R$<span class="value">00,00</span></div>\n <div class="current-price">Por <strong>R$<span class="value">00,00</span></strong></div>\n </div>\n </label>\n\n <label class="subscription-label _selected">\n <div class="name-wrapper">\n <input id="subscription" name="occurrence-selection" type="radio" checked="true" onchange="BuyModalWithSubscripitionReformuled.onChangeOccurence(this)"/>\n </div>\n <img class="subscription-icon" src="/arquivos/compra-programada-modal-icon.svg" alt="">\n <div class="discount-warning"><span class="discount-value">10</span>% off</div>\n <div class="price">\n <div>Por <strong>R$<span class="value">00,00</span></strong></div>\n </div>\n \n <div class="benefits">\n <div>\n <img src="/arquivos/frequency-icon-new.svg" alt="">\n Frequência personalizada\n </div>\n \n <div>\n <img src="/arquivos/confirm-icon-new.svg" alt="">\n Sem mensalidade ou fidelidade\n </div>\n\n <div>\n <img src="/arquivos/free-shipping-icon-new.svg" alt="">\n Frete Grátis a partir da 2ê entrega*\n </div>\n </div>\n </label>\n <img class="product-image" src=""/>\n </div>\n\n <div class="frequency-options-list-title">Escolha a frequência que deseja receber:</div>\n <ul class="frequency-options-list">\n ${FREQUENCY_OPTIONS.map( 11088 (e) => 11089 `\n <li>\n <input \n id="frequency-option-${ 11090 e.key 11091 }" \n value="${ 11092 e.key 11093 }" \n name="frequency" \n type="radio"\n />\n <label class="_product-button" for="frequency-option-${ 11094 e.key 11095 }" name="${e.key}-frequency">${e.text.replace( 11096 'dias', 11097 '<span> dias</span>' 11098 )}\n </label></label>\n </li>\n ` 11099 ).join( 11100 ' ' 11101 )}\n </ul>
11101\n <span class="_error-message _frequency _hide">Selecione a frequência</span>\n <div class="action-buttons">\n <div class="confirm-button-wrapper">\n <button class="confirm-button" onclick="BuyModalWithSubscripitionReformuled.onConfirmClick()"> <img src="/arquivos/buy-button-bag-icon.svg" alt="Icone sacola"> Adicionar ao carrinho</button>\n </div>\n <div class="close-button-wrapper">\n <button class="_product-button" onclick="BuyModalWithSubscripitionReformuled.close()">Voltar</button>\n </div>\n </div>\n </div>\n </div>\n <div class="backdrop" onclick="BuyModalWithSubscripitionReformuled.close()"></div>\n `, 11102 i = `\n <div class="buy-modal-with-subscription">\n <header class="header">\n <div>Você está adicionando:</div>\n <div class="name"></div>\n </header>\n <div class="body _subscription-option-selected">\n <div class="quantity-options-list-title">Escolha a quantidade:</div>\n <ul class="quantity-options-list">\n </ul>
11102\n <span class="_error-message _quantity _hide">Selecione a quantidade para continuar</span>\n <div class="current-quantity">\n <span>\n <strong class="quantity">10</strong><strong>bebidas</strong> adicionadas\n </span>\n\n <button class="_product-button" onclick="BuyModalWithSubscripitionReformuled.removeQuantitySelected()">Alterar</button>\n </div>\n\n <div class="occurrence-selection">\n <label class="one-time-label">\n <section class="_type">\n <div class="name-wrapper">\n <input id="one-time" name="occurrence-selection" type="radio" onchange="BuyModalWithSubscripitionReformuled.onChangeOccurence(this)" />\n <div class="selector-controller"></div>\n </div>\n <div class="_text">Comprar Uma única vez</div>\n\n <div class="price">\n <div class="old-price">De:R$<span class="value">00,00</span></div>\n <div class="current-price">Por <strong>R$<span class="value">00,00</span></strong> <span>Preço por unidade</span></div>\n </div>\n </section>\n </label>\n <hr/>\n <label class="subscription-label _selected">\n <section class="_type">\n <div class="name-wrapper">\n <input id="subscription" name="occurrence-selection" type="radio" checked="true" onchange="BuyModalWithSubscripitionReformuled.onChangeOccurence(this)"/>\n </div>\n <div class="_text">Programar compra</div>\n <div class="discount-warning">Ganhe <b>+<span class="discount-value">10</span>% OFF</b></div>\n <div class="price">\n <div>Por <strong>R$<span class="value">00,00</span></strong> <span>Preço por unidade</span></div>\n </div>\n \n <ul class="benefits">\n <li>\n ââ¬Â¢ Frete grátis*\n </li>\n\n <li>\n ââ¬Â¢ Frequência personalizada\n </li>\n \n <li>\n ââ¬Â¢ Sem fidelidade\n </li>\n </ul>\n </section>\n </label>\n <img class="product-image" src=""/>\n </div>\n\n <div class="frequency-options-list-title">Escolha a frequência que deseja receber:</div>\n <ul class="frequency-options-list">\n ${FREQUENCY_OPTIONS.map( 11103 (e) => 11104 `\n <li>\n <input \n id="frequency-option-${e.key}" \n value="${ 11105 e.key 11106 }" \n name="frequency" \n type="radio"\n />\n <label class="_product-button" for="frequency-option-${ 11107 e.key 11108 }" name="${e.key}-frequency">${e.text.replace( 11109 'dias', 11110 '<span> dias</span>' 11111 )}\n </label></label>\n </li>\n ` 11112 ).join( 11113 ' ' 11114 )}\n </ul>
11114\n <span class="_error-message _frequency _hide">Selecione a frequência</span>\n <div class="action-buttons">\n <div class="confirm-button-wrapper">\n <button class="confirm-button" onclick="BuyModalWithSubscripitionReformuled.onConfirmClick()">Adicionar ao carrinho</button>\n </div>\n <div class="close-button-wrapper">\n <button class="_product-button" onclick="BuyModalWithSubscripitionReformuled.close()">Voltar</button>\n </div>\n </div>\n </div>\n </div>\n <div class="backdrop" onclick="BuyModalWithSubscripitionReformuled.close()"></div>\n` 11115 ;(t.innerHTML = isNewHomeB ? i : n), e.append(t) 11116 }, 11117 changeOccurenceSelectionVisibility: (e) => { 11118 const t = document.querySelector('#product-buy-modal-with-subscription-wrapper .occurrence-selection'), 11119 n = document.querySelector('#product-buy-modal-with-subscription-wrapper .frequency-options-list') 11120 e ? (t.classList.add('_hide'), (n.style = 'display: flex')) : (t.classList.remove('_hide'), (n.style = '')) 11121 }, 11122 close: () => { 11123 document.querySelector('#product-buy-modal-with-subscription-wrapper').classList.add('_hide') 11124 }, 11125 onChangeOccurence: (e) => { 11126 const t = document.querySelector('#product-buy-modal-with-subscription-wrapper .body') 11127 t.querySelector('.occurrence-selection') 11128 .querySelectorAll('input[name="occurrence-selection"]') 11129 .forEach((e) => { 11130 e.parentNode.parentNode.classList.remove('_selected') 11131 }) 11132 e.parentNode.parentNode.classList.add('_selected') 11133 const n = document.querySelector('._error-message._frequency') 11134 'subscription' === e.id 11135 ? t.classList.add('_subscription-option-selected') 11136 : (n.classList.add('_hide'), t.classList.remove('_subscription-option-selected')), 11137 BuyModalWithSubscripitionReformuled.changeButtonVisibility() 11138 }, 11139 onConfirmClick: async () => { 11140 const e = document.querySelector('#product-buy-modal-with-subscription-wrapper .body'), 11141 t = e.getAttribute('data-product-sku'), 11142 n = e.getAttribute('data-product-seller'), 11143 i = e.querySelector('.occurrence-selection input:checked').id, 11144 o = e.querySelector('.frequency-options-list input:checked'), 11145 s = e.querySelector('.quantity-options-list input:checked'), 11146 a = o ? o.value : null, 11147 r = s ? Number(s.value) : null, 11148 c = document.querySelector('._error-message._quantity'), 11149 u = document.querySelector('._error-message._frequency') 11150 if (!a && !r && 'subscription' === i) return c.classList.remove('_hide'), void u.classList.remove('_hide') 11151 if (!r) return void c.classList.remove('_hide') 11152 if (!a && 'subscription' === i) return void u.classList.remove('_hide') 11153 const l = vtexjs.checkout.orderForm.items.map((e) => { 11154 const t = e.attachments 11155 if (!t.length) return !1 11156 return !!t.find((e) => 'pay2b.subscription' === e.name) 11157 }), 11158 d = 'subscription' === i || l.includes(!0) ? 5 : 1 11159 BuyModalWithSubscripitionReformuled.setIsLoading(!0), 11160 await addItemToCart(t, r, n, d), 11161 'subscription' === i 11162 ? await addItemPay2bAttachment({ 11163 productSku: t, 11164 frequencyKey: a, 11165 }) 11166 : await removeItemPay2bAttachment({ 11167 productSku: t, 11168 }), 11169 BuyModalWithSubscripitionReformuled.setIsLoading(!1), 11170 BuyModalWithSubscripitionReformuled.close() 11171 }, 11172 open: (e) => { 11173 BuyModalWithSubscripitionReformuled.changeFrequencyOptionsList(e), 11174 BuyModalWithSubscripitionReformuled.setIsLoading(!1) 11175 const t = document.querySelector('#product-buy-modal-with-subscription-wrapper') 11176 BuyModalWithSubscripitionReformuled.changeModalTitle(t, e), 11177 BuyModalWithSubscripitionReformuled.changeOccurenceSelectionVisibility(e.hideOccurenceSelection), 11178 BuyModalWithSubscripitionReformuled.selectCurrentFrequencyOption(t, e), 11179 BuyModalWithSubscripitionReformuled.appendQuantityListOptions(t, e), 11180 BuyModalWithSubscripitionReformuled.appendProductDataToModal(t, e), 11181 BuyModalWithSubscripitionReformuled.updateQuantitySelected(e.quantity), 11182 BuyModalWithSubscripitionReformuled.onSelectOptions(t), 11183 BuyModalWithSubscripitionReformuled.changeButtonVisibility(t) 11184 const n = document.querySelector('._error-message._quantity'), 11185 i = document.querySelector('._error-message._frequency') 11186 n && n.classList.add('_hide'), i && i.classList.add('_hide'), t.classList.remove('_hide') 11187 }, 11188 onSelectOptions: (e) => { 11189 const t = () => { 11190 BuyModalWithSubscripitionReformuled.changeButtonVisibility(e) 11191 } 11192 e.querySelectorAll('.frequency-options-list li, .quantity-options-list li').forEach((e) => 11193 e.addEventListener('click', t) 11194 ) 11195 }, 11196 changeButtonVisibility: (e) => { 11197 const t = e || document.querySelector('#product-buy-modal-with-subscription-wrapper'), 11198 n = t.querySelector('.body').classList.contains('_subscription-option-selected'), 11199 i = t.querySelector('.confirm-button') 11200 i.classList.add('_disable') 11201 const o = (e) => { 11202 const n = t.querySelectorAll(`[name="${e}"]`) 11203 return Array.from(n).some((e) => e.checked) 11204 }, 11205 s = o('product-quantity'), 11206 a = o('frequency') 11207 n && s && a && i.classList.remove('_disable'), !n && s && i.classList.remove('_disable') 11208 const r = document.querySelector('._error-message._quantity'), 11209 c = document.querySelector('._error-message._frequency') 11210 s && r.classList.add('_hide'), a && c.classList.add('_hide') 11211 }, 11212 updateQuantitySelected: (e) => { 11213 const t = document.querySelector('#product-buy-modal-with-subscription-wrapper .body') 11214 e ? t.classList.add('_quantity-selected') : t.classList.remove('_quantity-selected') 11215 }, 11216 removeQuantitySelected: () => { 11217 document.querySelector('#product-buy-modal-with-subscription-wrapper .body').classList.remove('_quantity-selected') 11218 }, 11219 selectCurrentFrequencyOption: (e, t) => { 11220 let n = !0 11221 let i = setFrequencyOptions(t.id)[0].key 11222 const { frequencyKey: o } = t 11223 o 11224 ? ((n = !0), (i = o)) 11225 : 'subscription' === t.defaultOccurenceSelected 11226 ? (n = !0) 11227 : 'one-time' === t.defaultOccurenceSelected && (n = !1) 11228 const s = document.getElementById('one-time'), 11229 a = document.getElementById('subscription'), 11230 r = e.querySelector('.frequency-options-list') 11231 n 11232 ? (BuyModalWithSubscripitionReformuled.onChangeOccurence(a), 11233 (a.checked = !0), 11234 o && (r.querySelector(`[value="${i}"]`).checked = !0)) 11235 : (BuyModalWithSubscripitionReformuled.onChangeOccurence(s), (s.checked = !0)) 11236 }, 11237 setIsLoading: (e) => { 11238 const t = document.querySelector('#product-buy-modal-with-subscription-wrapper .body') 11239 e ? t.classList.add('_loading') : t.classList.remove('_loading') 11240 }, 11241 changeFrequencyOptionsList: (e) => { 11242 const t = document.querySelector('#product-buy-modal-with-subscription-wrapper .frequency-options-list'), 11243 n = setFrequencyOptions(e.id) 11244 t.innerHTML = 11245 '' + 11246 n 11247 .map( 11248 (e) => 11249 `\n <li>\n <input \n id="frequency-option-${e.key}-subscription-modal" \n value="${e.key}" \n name="frequency" \n type="radio"\n />\n <label class="_product-button" for="frequency-option-${e.key}-subscription-modal" name="${e.key}-frequency">${e.interval}<br/> ${e.text}\n </label></label>\n </li>\n ` 11250 ) 11251 .join(' ') 11252 }, 11253 changeModalTitle: (e, t) => { 11254 e.querySelector('.quantity-options-list-title').innerHTML = 11255 (() => { 11256 const e = t.category 11257 switch (!0) { 11258 case e.isCapsule: 11259 return 'Quantas bebidas' 11260 case e.isDrink: 11261 return 'Quantos drinks' 11262 case e.isAccessory: 11263 return 'Quantos acessórios' 11264 case e.isCombo: 11265 return 'Quantos combos' 11266 default: 11267 return 'Quantos' 11268 } 11269 })() + ' você deseja adicionar?' 11270 }, 11271} 11272;(isBebidas || isCheckout || isCategoryNew || isCollectionNew || isHome || isCilinder || isFilter) && 11273 BuyModalWithSubscripitionReformuled.init() 11274const RemindMeModalReformuled = { 11275 close: () => { 11276 document.getElementById('product-remind-me-modal-wrapper').remove() 11277 }, 11278 open: async (e) => { 11279 const t = await BuyButtonReformuled.getProductInfo(e), 11280 n = document.querySelector('body'), 11281 i = document.createElement('div') 11282 ;(i.id = 'product-remind-me-modal-wrapper'), 11283 (i.innerHTML = `\n <div class="remind-me-modal">\n <header class="header">\n <button class="close-icon" onclick="RemindMeModalReformuled.close()">\n <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 17 17"><defs></defs><path fill="#000" d="M10.795 8.625L16.068 3.4c.293-.293.293-.83 0-1.123l-1.22-1.22c-.293-.293-.83-.293-1.123 0L8.5 6.33 3.227 1.057c-.293-.293-.83-.293-1.123 0L.883 2.277c-.293.293-.293.83 0 1.123l5.273 5.225-5.273 5.273c-.293.293-.293.83 0 1.123l1.22 1.221c.293.293.83.293 1.124 0L8.5 10.97l5.225 5.273c.293.293.83.293 1.123 0l1.22-1.22c.293-.293.293-.83 0-1.124l-5.273-5.273z"></path></svg>\n </button>\n \n <h2 class="form-tittle">Este produto está temporariamente indisponÃÂvel.<br/> Seja avisado quando o produto estiver disponÃÂvel novamente.</h2>\n <h2 class="success-message _hide">Cadastrado com sucesso!</h2>\n </header>\n <div class="body">\n <div class="form-wrapper">\n <form onsubmit="RemindMeModalReformuled.onSubmit(event, ${t.sku})">\n <input id="remind-me-name-input" placeholder="Nome" />\n <input id="remind-me-email-input" placeholder="E-mail" />\n \n <div class="invalid-warning _invisible">Informe um <span class="invalid-field"></span> válido</div>\n <button class="submit-button" type="submit" name="remind-me-form-submit"> <img src="/arquivos/send-form-icon.svg" alt="Enviar"></button>\n </form>\n </div>\n \n <div class="success-message _hide">\n Assim que o produto for disponibilizado você receberá um email avisando.\n </div>\n </div>\n </div>\n <div class="backdrop" onclick="RemindMeModalReformuled.close()"></div>\n `), 11284 n.append(i) 11285 }, 11286 onSubmit: (e, t) => { 11287 e.preventDefault() 11288 const n = e.target, 11289 i = n.querySelector('#remind-me-name-input'), 11290 o = n.querySelector('#remind-me-email-input'),
11291 s = n.querySelector('.invalid-warning'), 11292 a = s.querySelector('.invalid-field'), 11293 r = o.value, 11294 c = i.value 11295 if (!(c.length > 2)) 11296 return i.classList.add('_invalid'), s.classList.remove('_invisible'), void (a.innerHTML = 'nome') 11297 if ((i.classList.remove('_invalid'), s.classList.add('_invisible'), !isValid.email(r))) 11298 return o.classList.add('_invalid'), s.classList.remove('_invisible'), void (a.innerHTML = 'e-mail') 11299 o.classList.remove('_invalid'), s.classList.add('_invisible') 11300 n.querySelector('.submit-button').classList.add('_loading') 11301 RemindMeModalReformuled.sendNotifyRequest({ 11302 productSku: t, 11303 name: c, 11304 email: r, 11305 successCallback: () => { 11306 RemindMeModalReformuled.loadSuccessMessage() 11307 }, 11308 failCallback: () => { 11309 alert('Não foi possÃÂvel realizar seu cadastro'), RemindMeModalReformuled.close() 11310 }, 11311 }) 11312 }, 11313 sendNotifyRequest: async ({ productSku: e, name: t, email: n, successCallback: i, failCallback: o }) => { 11314 const s = new FormData() 11315 s.append('notifymeClientName', t), s.append('notifymeClientEmail', n), s.append('notifymeIdSku', e) 11316 try { 11317 200 === 11318 ( 11319 await fetch('/no-cache/AviseMe.aspx', { 11320 method: 'POST', 11321 body: s, 11322 }) 11323 ).status 11324 ? i() 11325 : o() 11326 } catch (e) { 11327 console.error(e), o() 11328 } 11329 }, 11330 loadSuccessMessage: () => { 11331 const e = document.querySelector('#product-remind-me-modal-wrapper .remind-me-modal'), 11332 t = e.querySelector('header .success-message') 11333 e.querySelector('header .form-tittle').classList.add('_hide'), t.classList.remove('_hide') 11334 const n = e.querySelector('.body .form-wrapper'), 11335 i = e.querySelector('.body .success-message') 11336 n.classList.add('_hide'), i.classList.remove('_hide') 11337 }, 11338} 11339try { 11340 $(window).on('orderFormUpdated.vtex', async function (e, t) { 11341 isBebidas || isCheckout || isCategoryNew || isCollectionNew || isHome 11342 ? BuyButtonsReformuled.updateAccordingToOrderForm(t) 11343 : BuyButtons.updateAccordingToOrderForm(t) 11344 }) 11345} catch (e) { 11346 console.error(e) 11347} 11348const ProductShelf = { 11349 init: () => { 11350 ProductShelf.fillSubscriptionDiscountValue(), ProductShelf.isNewProduct(), ProductShelf.hasProductField() 11351 }, 11352 fillSubscriptionDiscountValue: () => { 11353 const e = document.querySelectorAll('._product-card ._sig ._product-field') 11354 for (const t of e) { 11355 const e = t.parentNode.querySelector('._product-field-value'), 11356 n = t.querySelector('ul') 11357 if (!n) continue 11358 const i = n.firstElementChild.textContent.trim() 11359 if (Number(i)) { 11360 e.parentNode.parentNode.classList.remove('_invisible') 11361 } 11362 e.innerHTML = i 11363 } 11364 }, 11365 isNewProduct: async () => { 11366 const e = document.querySelectorAll('._product-card') 11367 for (const t of e) { 11368 const e = t.getAttribute('data-id'), 11369 n = (await fetchProductById(e))[0].releaseDate 11370 ProductShelf.hasProductField(t) 11371 const i = 90 11372 if ((new Date() - new Date(n)) / 864e5 < i) { 11373 const e = t.querySelector('._newProduct') 11374 if (!e) return 11375 e.style.display = 'block' 11376 } 11377 } 11378 }, 11379 hasProductField: (e) => { 11380 if (!e) return 11381 const t = e.querySelector('._tag ._star'), 11382 n = e.querySelector('._tag img') 11383 n && (t || n.parentNode.classList.add('only-discount')) 11384 }, 11385} 11386ProductShelf.init() 11387 11388// Códigos Simples. Inovação 11389 11390function getCartItems() { 11391 fetch('/api/checkout/pub/orderForm/') 11392 .then((res) => res.json()) 11393 .then((data) => { 11394 const items = data.items 11395 getItemData(items) 11396 }) 11397} 11398 11399getCartItems() 11400 11401function getItemData(items) { 11402 // use map() to perform a fetch and handle the response for each url 11403 Promise.all( 11404 items.map((item) => 11405 fetch(`/api/catalog_system/pub/products/search/?fq=productId:${item.productId}`) 11406 .then((res) => res.json()) 11407 .catch((error) => console.error(error)) 11408 ) 11409 ).then((data) => {
11410 // do something with the data 11411 const machines = data.filter((item) => item[0].categories.includes('/Máquinas/')) 11412 machines.length ? sessionStorage.setItem('hasMachine', true) : sessionStorage.setItem('hasMachine', false) 11413 11414 // pixMessage(); 11415 }) 11416} 11417 11418function pixMessage() { 11419 const hasMachine = sessionStorage.getItem('hasMachine') 11420 const pixElement = document.querySelector( 11421 '.payment-group-list-btn a#payment-group-instantPaymentPaymentGroup[data-name="Pix"]' 11422 ) 11423 11424 if (pixElement) { 11425 const p = document.createElement('p') 11426 p.textContent = '(5% OFF)' 11427 p.classList.add('pix-discount') 11428 11429 if (hasMachine == 'true') { 11430 if (pixElement.querySelector('.pix-discount') == null) pixElement.append(p) 11431 11432 pixElement.classList.add('has-discount') 11433 } else if (pixElement.querySelector('.pix-discount') != null) { 11434 pixElement.querySelector('.pix-discount').remove() 11435 pixElement.classList.remove('has-discount') 11436 } 11437 } 11438} 11439 11440window.addEventListener('load', () => { 11441 ;(function () { 11442 'use strict' 11443 var oldXHR, stateChangeHandler, prop 11444 11445 oldXHR = window.XMLHttpRequest 11446 11447 stateChangeHandler = function (evt) { 11448 switch (this.readyState) { 11449 case oldXHR.OPENED: 11450 break 11451 case oldXHR.DONE: 11452 //console.log(this.responseURL) 11453 if (this.responseURL.indexOf('/api/checkout/pub/orderForm') != -1) getCartItems() 11454 break 11455 } 11456 } 11457 11458 function newXHR() { 11459 var xhr = new oldXHR() 11460 xhr.addEventListener('readystatechange', stateChangeHandler) 11461 return xhr 11462 } 11463 11464 // Copy original states and toString 11465 for (prop in oldXHR) newXHR[prop] = oldXHR[prop] 11466 11467 window.XMLHttpRequest = newXHR 11468 })() 11469}) 11470 11471// tag insider 11472 11473window.insider_object = window.insider_object || {} 11474 11475const insiderInstallTags = { 11476 SELECTORS: { 11477 MAIN_CHECKBOX: '#opt-in-newsletter', 11478 CHANNEL_EMAIL: '#channel-email', 11479 CHANNEL_WHATSAPP: '#channel-whatsapp', 11480 CHANNEL_SMS: '#channel-sms', 11481 }, 11482 11483 getCommunicationPreferences() { 11484 const { SELECTORS } = this 11485 11486 const mainCheckbox = $(SELECTORS.MAIN_CHECKBOX) 11487 if (!mainCheckbox.length) { 11488 return this._getDefaultPreferences() 11489 } 11490 11491 const mainCheckboxChecked = mainCheckbox.prop('checked') 11492 11493 const elements = { 11494 email: $(SELECTORS.CHANNEL_EMAIL), 11495 whatsapp: $(SELECTORS.CHANNEL_WHATSAPP), 11496 sms: $(SELECTORS.CHANNEL_SMS), 11497 } 11498 11499 const preferences = { 11500 email_optin: mainCheckboxChecked ? elements.email.prop('checked') : false, 11501 whatsapp_optin: mainCheckboxChecked ? elements.whatsapp.prop('checked') : false, 11502 sms_optin: mainCheckboxChecked ? elements.sms.prop('checked') : false, 11503 } 11504 return preferences 11505 }, 11506 11507 _getDefaultPreferences() { 11508 return { 11509 email_optin: true, 11510 whatsapp_optin: true, 11511 sms_optin: true, 11512 } 11513 }, 11514 11515 converterParaFloat: (valor) => { 11516 // Garante que o valor seja uma string 11517 valor = valor.toString() 11518 11519 // // Verifica se o valor contém vÃÂrgula, se sim, substitui por ponto 11520 if (valor.includes(',')) { 11521 valor = valor.replace(',', '.') 11522 } else { 11523 // Se o valor é um número inteiro, divide os dois últimos dÃÂgitos como centavos 11524 valor = valor.slice(0, -2) + '.' + valor.slice(-2) 11525 } 11526 11527 // Converte para float 11528 return parseFloat(valor) 11529 }, 11530 11531 categorySplit: (categories) => { 11532 let categorySplitado = categories.map(function (item) { 11533 let category = item.split('/') 11534 category.pop() 11535 category.shift() 11536 11537 return category.pop() 11538 }) 11539 11540 return categorySplitado 11541 }, 11542 11543 // Identidade sempre; opt-ins só quando includeDefaultOptins=true, e nesse caso vão 11544 // hardcoded true (nunca lidos do DOM aqui) â é só o valor inicial esperado, já que os 11545 // checkboxes nascem marcados (setOptinNewsletterDefault). Depois desse 1º envio, quem 11546 // manda no consentimento é exclusivamente updateInsiderCommunicationPrefs(), a partir do 11547 // change real dos checkboxes (R6) â por isso os disparos passivos seguintes não 11548 // recalculam opt-in a partir do DOM, pra um re-render transitório nunca rebaixar o 11549 // consentimento sozinho (D7). 11550 prepareUserData(orderForm, { includeDefaultOptins = false } = {}) { 11551 if (!orderForm) { 11552 console.error('OrderForm not found') 11553 return {} 11554 } 11555 11556 const defaultOptins = includeDefaultOptins 11557 ? { email_optin: true, whatsapp_optin: true, sms_optin: true } 11558 : {} 11559 11560 const clientData = orderForm.clientProfileData 11561 11562 if (!clientData) { 11563 return { ...defaultOptins, gdpr_optin: true } 11564 } 11565 11566 return { 11567 ...defaultOptins, 11568 firstname: clientData.firstName, 11569 lastname: clientData.lastName, 11570 email: clientData.email, 11571 phone_number: clientData.phone, 11572 uuid: orderForm.userProfileId, 11573 gdpr_optin: true, 11574 } 11575 }, 11576 11577 // includeDefaultOptins só deve ser true no evento de identificação inicial â os demais 11578 // disparos (hashchange, orderFormUpdated, clique em go-to-*) são passivos e não recalculam 11579 // consentimento (R6). 11580 sendUserDataToInsider({ includeDefaultOptins = false } = {}) { 11581 try { 11582 const orderForm = vtexjs && vtexjs.checkout && vtexjs.checkout.orderForm 11583 if (!orderForm) { 11584 console.error('VTEX orderForm not available') 11585 return 11586 } 11587 11588 const userObject = this.prepareUserData(orderForm, { includeDefaultOptins }) 11589 11590 // Verificar se objeto Insider existe 11591 if (!window.insider_object) { 11592 window.insider_object = {} 11593 } 11594 11595 // Mesclar com dados existentes para não perder informações 11596 window.insider_object.user = { 11597 ...window.insider_object.user, 11598 ...userObject, 11599 } 11600 11601 // Não há chamada de envio aqui de propósito: a ins.js lê o insider_object por conta 11602 // própria. window.insider.identify() não existe (verificado em produção, com o SDK 11603 // inicializado) e nunca existiu â não é API da Insider. 11604 } catch (error) { 11605 console.error('Erro ao enviar dados para Insider:', error) 11606 } 11607 }, 11608 11609 insiderObjectBasket: () => { 11610 $(window).on('orderFormUpdated.vtex', function (event, orderForm) { 11611 // basket cart 11612 let cartItems = [] 11613 let orderItems = orderForm.items 11614 11615 let appVerification = localStorage.getItem('isApp') === 'true' 11616
11617 orderItems.forEach(function (cart) { 11618 let itemSubtotal = cart.quantity * insiderInstallTags.converterParaFloat(cart.price) 11619 11620 let data = { 11621 product: { 11622 id: cart.productId, 11623 name: cart.name, 11624 taxonomy: Object.values(cart.productCategories), 11625 currency: 'BRL', 11626 unit_price: insiderInstallTags.converterParaFloat(cart.price), 11627 unit_sale_price: insiderInstallTags.converterParaFloat(cart.listPrice), 11628 url: 'https://loja.bblend.com.br' + cart.detailUrl, 11629 product_image_url: cart.imageUrl, 11630 custom: { 11631 appuser: appVerification, 11632 }, 11633 }, 11634 quantity: cart.quantity, 11635 subtotal: itemSubtotal, 11636 } 11637 11638 cartItems.push(data) 11639 }) 11640 11641 let shipping = orderForm.totalizers.find((item) => item.id === 'Shipping') 11642 11643 // Verifica se o item "Shipping" existe e retorna o valor, caso contrário retorna undefined ou outro valor padrão 11644 let shippingValue = shipping ? shipping.value : 0 11645 11646 window.insider_object.basket = { 11647 currency: 'BRL', 11648 total: insiderInstallTags.converterParaFloat(orderForm.value), 11649 shipping_cost: insiderInstallTags.converterParaFloat(shippingValue), 11650 line_items: cartItems, 11651 } 11652 11653 if ( 11654 window.location.href == 'https://loja.bblend.com.br/checkout#/payment' || 11655 window.location.href == 'https://loja.bblend.com.br/checkout#/profile' || 11656 window.location.href == 'https://loja.bblend.com.br/checkout#/shipping' 11657 ) { 11658 localStorage.setItem('pageConfirmationInsider', 0) 11659 } 11660 }) 11661 }, 11662 11663 insiderPageTypes: () => { 11664 $(window).on('orderFormUpdated.vtex', function (event, orderForm) { 11665 // cart 11666 if (window.location.hash == '#/cart') { 11667 window.insider_object.page = { 11668 type: 'Basket', 11669 } 11670 } 11671 // checkout 11672 if ( 11673 window.location.hash == '#/payment' || 11674 window.location.hash == '#/profile' || 11675 window.location.hash == '#/shipping' 11676 ) { 11677 window.insider_object.page = { 11678 type: 'Checkout', 11679 } 11680 } 11681 }) 11682 }, 11683 11684 // A ins.js é carregada exclusivamente pela IIFE oficial (/insider/checkout-script, 11685 // mais abaixo neste arquivo) â a injeção manual foi removida para não haver duas tags 11686 // concorrentes (R5). 11687 11688 init: function () { 11689 insiderInstallTags.insiderObjectBasket() 11690 insiderInstallTags.insiderPageTypes() 11691 }, 11692} 11693 11694// Persiste no cadastro do cliente (CL) o opt-in de newsletter coletado no checkout. 11695// Até aqui o consentimento ia somente para o insider_object e para o log na entidade IN: 11696// nem o campo nativo do orderForm nem o perfil do cliente eram escritos, então o CRM 11697// ficava com o valor antigo (normalmente false/null em perfis novos). 11698const NewsletterOptinSync = { 11699 OPTIN_URL: '/_v/private/bblend-data/newsletter-optin', 11700 11701 hasSynced: false, 11702 11703 // Precedência deliberada: o insider_object vem primeiro porque 11704 // getCommunicationPreferences() cai no default (tudo true) quando o checkbox principal 11705 // não está no DOM â e na etapa de pagamento ele pode já não estar renderizado, o que 11706 // reportaria true mesmo para quem desmarcou. O insider_object nasce true na 11707 // identificação inicial e só muda no change real do checkbox. 11708 readEmailOptin() { 11709 const insiderUser = window.insider_object && window.insider_object.user 11710 const insiderOptin = insiderUser && insiderUser.email_optin 11711 11712 if (typeof insiderOptin === 'boolean') { 11713 return insiderOptin 11714 } 11715 11716 if ($(insiderInstallTags.SELECTORS.MAIN_CHECKBOX).length) { 11717 return insiderInstallTags.getCommunicationPreferences().email_optin 11718 } 11719 11720 return null 11721 }, 11722 11723 // Campo nativo da VTEX. Escrito de forma condicional porque todo attachment muta o 11724 // orderForm, e na etapa de pagamento uma mutação desnecessária pode reprocessar parcelas. 11725 syncNativeOptin(orderForm) { 11726 const preferences = orderForm.clientPreferencesData 11727 11728 if (preferences && preferences.optinNewsLetter === true) { 11729 return 11730 } 11731 11732 vtexjs.checkout.sendAttachment('clientPreferencesData', { optinNewsLetter: true }) 11733 }, 11734 11735 // A escrita no CL passa pelo app bblend.storefront-data-api: o navegador não fala com 11736 // /api/dataentities/* (as entidades estão fechadas desde a task 66277). Não há payload â o 11737 // e-mail é derivado da sessão no servidor e o valor é sempre true, então nada vindo daqui 11738 // é confiado. O path /_v/private/ e o credentials same-origin são o que garantem o cookie 11739 // de sessão chegando no app. 11740 async syncMasterData() { 11741 const response = await fetch(this.OPTIN_URL, { 11742 method: 'POST', 11743 credentials: 'same-origin', 11744 headers: { Accept: 'application/json' }, 11745 }) 11746 11747 // 401 é esperado em compra sem login: não há perfil no CL para atualizar 11748 if (response.status === 401) { 11749 return 11750 } 11751 11752 if (!response.ok) { 11753 throw new Error(`newsletter optin sync error: ${response.status}`) 11754 } 11755 }, 11756 11757 async run() { 11758 if (this.hasSynced) { 11759 return 11760 } 11761 11762 try { 11763 // grava apenas true: desmarcar não rebaixa o CL (decisão "never downgrade") 11764 if (this.readEmailOptin() !== true) { 11765 return 11766 } 11767 11768 const orderForm = vtexjs && vtexjs.checkout && vtexjs.checkout.orderForm 11769 const clientData = orderForm && orderForm.clientProfileData 11770 const email = clientData && clientData.email 11771 11772 if (!email) { 11773 return 11774 } 11775 11776 // marcado antes das escritas para que hashchanges em sequência não dupliquem 11777 this.hasSynced = true 11778 11779 this.syncNativeOptin(orderForm) 11780 11781 await this.syncMasterData() 11782 } catch (error) { 11783 // degradação silenciosa: o consentimento já foi registrado na Insider e no orderForm, 11784 // e nada aqui pode interromper o checkout 11785 console.error('Erro ao sincronizar opt-in de newsletter no CL:', error) 11786 } 11787 }, 11788 11789 init() { 11790 const runOnPaymentStep = () => { 11791 if (window.location.hash === '#/payment') { 11792 this.run() 11793 } 11794 } 11795 11796 runOnPaymentStep() 11797 11798 $(window).on('hashchange', runOnPaymentStep) 11799 11800 // rede de segurança para quem recarrega a página já em #/payment: no ready o orderForm 11801 // ainda não está carregado, então run() sai sem e-mail e nenhum hashchange acontece 11802 // depois. A guarda hasSynced garante que isto não gere escrita repetida. 11803 $(window).on('orderFormUpdated.vtex', runOnPaymentStep) 11804 }, 11805} 11806 11807$(document).ready(function () { 11808 insiderInstallTags.init() 11809 NewsletterOptinSync.init() 11810 11811 const CHECKOUT_BUTTONS = '#go-to-shipping, #go-to-payment' 11812 11813 // Identificação inicial assim que o usuário chega no checkout: identidade + opt-ins 11814 // default true (o cliente ainda não interagiu com os checkboxes). 11815 // Navegações seguintes (hashchange) só atualizam identidade, sem mexer em consentimento. 11816 let hasSentInitialIdentification = false 11817 11818 const initializeInsiderData = () => { 11819 const currentHash = window.location.hash 11820 // Se estiver em profile, shipping ou payment, inicializar dados 11821 if (currentHash === '#/profile' || currentHash === '#/shipping' || currentHash === '#/payment') { 11822 setTimeout(() => { 11823 insiderInstallTags.sendUserDataToInsider({ 11824 includeDefaultOptins: !hasSentInitialIdentification, 11825 }) 11826 hasSentInitialIdentification = true 11827 }, 500) 11828 } 11829 } 11830 11831 // Executar na carga inicial 11832 initializeInsiderData() 11833 11834 // Monitorar mudanças de hash (quando usuário navega entre etapas) 11835 $(window).on('hashchange', function () { 11836 initializeInsiderData() 11837 }) 11838 11839 // Enviar dados ao clicar nos botões de navegação do checkout 11840 $(document).on('click', CHECKOUT_BUTTONS, function () { 11841 requestAnimationFrame(() => { 11842 insiderInstallTags.sendUserDataToInsider() 11843 }) 11844 }) 11845 11846 // Também atualizar quando o orderForm é atualizado (caso os dad
11846os mudem) 11847 $(window).on('orderFormUpdated.vtex', function (event, orderForm) { 11848 // Pequeno delay para garantir que os checkboxes estejam atualizados 11849 setTimeout(() => { 11850 insiderInstallTags.sendUserDataToInsider() 11851 }, 100) 11852 }) 11853}) 11854 11855function limitarCarecteres() { 11856 var maxLength = 50 11857 // Definindo o limite para 50 caracteres 11858 11859 // Função para limitar o número de caracteres e adicionar/ocultar o aviso 11860 function limitInputLength(selector) { 11861 var input = $(selector) 11862 11863 // Exibe ou oculta o aviso e limita os caracteres enquanto o usuário digita 11864 input.on('input', function () { 11865 var currentValue = $(this).val() 11866 11867 // Adiciona o aviso de limite de caracteres se o campo não estiver vazio 11868 if (currentValue.length > 0) { 11869 if (!$(this).siblings('.char-limit-warning').length) { 11870 $(this).after( 11871 `<div class="char-limit-warning" style="color: #ae4d15; font-size: 12px;">Máximo de ${maxLength} caracteres</div>` 11872 ) 11873 } 11874 } else { 11875 // Remove o aviso se o campo estiver vazio 11876 $(this).siblings('.char-limit-warning').remove() 11877 } 11878 11879 // Verifica se o valor excede o limite de caracteres e corta o excesso 11880 if (currentValue.length > maxLength) { 11881 $(this).val(currentValue.slice(0, maxLength)) 11882 } 11883 }) 11884 } 11885 11886 // Limitar os dois inputs e adicionar o aviso 11887 limitInputLength('#client-first-name') 11888 limitInputLength('#client-last-name') 11889} 11890 11891// Executa a função quando o evento 'orderFormUpdated' da VTEX for disparado 11892$(window).on('orderFormUpdated.vtex', function (event, orderForm) { 11893 limitarCarecteres() 11894}) 11895 11896// Executa a função ao carregar a página 11897window.addEventListener('load', () => { 11898 limitarCarecteres() 11899}) 11900 11901window.addEventListener('message', function (event) { 11902 if (event.data.key === 'sendMsgApp') { 11903 let data = { 11904 user: insider_object.user, 11905 basket: insider_object.basket, 11906 pageType: insider_object.page, 11907 } 11908 11909 // retorna o objeto com os dados da insider 11910 event.source.postMessage({ key: 'responseFromWebCart', data: data }, event.origin) 11911 } 11912}) 11913 11914function checkMyVTEX() { 11915 let domain = window.location.hostname 11916 if (domain === 'bblend.myvtex.com') { 11917 document.body.classList.add('teste') 11918 } 11919} 11920 11921$(window).on('orderFormUpdated.vtex', function (event, orderForm) { 11922 checkMyVTEX() 11923}) 11924 11925 11926// Espelhos deste valor em apps VTEX separados (sem import cruzado possÃvel): 11927// theme/react/Helpers/freeShipping.ts 11928// store-components/react/utils/freeShipping.ts 11929const FREE_SHIPPING_THRESHOLD_CENTS = 49900 11930const freeShippingCurrency = new Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }) 11931 11932// Un.plug (/1/26/) e En.joy (/1/27/) â os dois só aparecem juntos com outros 11933// itens em carrinhos mistos; aqui só nos importa o caso "só máquina". 11934const MACHINE_CATEGORY_PATHS = ['/1/26/', '/1/27/'] 11935 11936const isMachineItem = ({ productCategoryIds }) => 11937 MACHINE_CATEGORY_PATHS.some((categoryPath) => productCategoryIds.includes(categoryPath)) 11938 11939const isMachinesOnlyCart = (items) => items.length > 0 && items.every(isMachineItem) 11940 11941const cashBackTopBar = { 11942 getOrderForm: async () => { 11943 try { 11944 const response = await fetch(`/api/checkout/pub/orderForm`, { 11945 method: 'POST', 11946 headers: { 11947 Accept: 'application/json', 11948 'Content-Type': 'application/json', 11949 }, 11950 }) 11951 return await response.json() 11952 } catch (err) { 11953 console.error('Erro no checkout:', err) 11954 throw err 11955 } 11956 }, 11957 11958 updateShippingRuleLogic: async (orderForm) => { 11959 const resolvedOrderForm = orderForm || (await cashBackTopBar.getOrderForm()) 11960 11961 const totalPriceCents = resolvedOrderForm.items.reduce( 11962 (total, { sellingPrice, quantity }) => total + sellingPrice * quantity, 11963 0 11964 ) 11965 const hideForMachinesOnly = isMachinesOnlyCart(resolvedOrderForm.items) 11966 11967 document.querySelectorAll(`._cashback`).forEach((cashbackElement) => { 11968 cashBackTopBar.updateShippingRule(totalPriceCents, hideForMachinesOnly, cashbackElement) 11969 }) 11970 }, 11971 11972 updateShippingRule: (totalPriceCents, hideForMachinesOnly, cashbackElement) => { 11973 if (hideForMachinesOnly) { 11974 cashbackElement.style.setProperty('display', 'none', 'important') 11975 return 11976 } 11977 11978 cashbackElement.style.removeProperty('display') 11979 11980 const textProgress = cashbackElement.querySelector(`._text-promo`) 11981 const progressBarElement = cashbackElement.querySelector(`.progress-bar`) 11982 11983 if (progressBarElement) { 11984 progressBarElement.style.width = `${Math.min(totalPriceCents / FREE_SHIPPING_THRESHOLD_CENTS, 1) * 100}%` 11985 } 11986 11987 if (!textProgress) return 11988 11989 if (totalPriceCents >= FREE_SHIPPING_THRESHOLD_CENTS) { 11990 textProgress.innerHTML = `
11991 <span>Parabéns!</span> Você conseguiu frete grátis no seu pedido. <span class="_disclaimer">*Não válido para máquinas.</span> 11992 ` 11993 } else { 11994 const priceRemaining = (FREE_SHIPPING_THRESHOLD_CENTS - totalPriceCents) / 100 11995 textProgress.innerHTML = ` 11996 Faltam <span>${freeShippingCurrency.format(priceRemaining)}</span> para conseguir frete grátis. <span class="_disclaimer">*Não válido para máquinas.</span> 11997 ` 11998 } 11999 }, 12000} 12001 12002$(window).on('orderFormUpdated.vtex', function (event, orderForm) { 12003 cashBackTopBar.updateShippingRuleLogic(orderForm) 12004}) 12005 12006function formatPrice(value) { 12007 return new Intl.NumberFormat('pt-BR', { 12008 style: 'currency', 12009 currency: 'BRL', 12010 }).format(value / 100) 12011} 12012 12013function pixDiscountCheckout(orderForm) { 12014 let existsMachines = 12015 orderForm && 12016 orderForm.items && 12017 orderForm.items.some((item) => parseInt(item.productId) == 504 || parseInt(item.productId) == 458) 12018 12019 if (existsMachines === false) { 12020 let methodSelected = $('.payment-group-item.active').attr('data-name') 12021 12022 if (methodSelected !== undefined) { 12023 let totalCarrinhoSemDesconto = orderForm.totalizers.find((item) => item.id === 'Items') 12024 12025 let valorDesconto = totalCarrinhoSemDesconto.value * 0.05 12026 12027 let totalCarrinhoComDesconto = 12028 methodSelected == 'Pix' ? orderForm.value : totalCarrinhoSemDesconto.value - valorDesconto 12029 12030 if (methodSelected == 'Pix') { 12031 setTimeout(function () { 12032 $('.desconto_total_pix').remove() 12033 12034 $('.totalizers-list:eq(1) tr:first-child').after(` 12035 12036 <tr class="tr-desconto-pix" data-bind="visible: visible, attr: { 'class': id }" class="Discounts"> 12037 <td class="info" data-bind="{text: label()}">Desconto Pix</td> 12038 <td class="space"></td> 12039 <td class="monetary" data-bind="text: valueLabel">${formatPrice(valorDesconto)}</td> 12040 <td class="empty"></td> 12041 </tr> 12042 12043 12044 `) 12045 12046 let priceElement = $('.tr-desconto-pix .monetary') 12047 let priceText = priceElement.html() 12048 let priceFormatted = priceText.replace(`R$ `, 'R$ -') 12049 12050 $(priceElement).html(priceFormatted) 12051 12052 $('.totalizers-list:eq(1) tr:eq(2) .info').html('Desconto Total') 12053 }, 500) 12054 } else { 12055 $('.desconto_total_pix').remove() 12056 12057 $('.row-fluid.orderform-template.span12.active .span5.totalizers.summary-totalizers.cart-totalizers.pull-right') 12058 .after(` 12059 12060 12061 <div class="desconto_total_pix"> 12062 12063 12064 <div class=""> 12065 <span class="desconto_pix_texto"> 12066 <p>Quer economizar <b class="uppercase">${formatPrice( 12067 valorDesconto 12068 )}?</b> Pague com <b>Pix</b> e <b>ganhe 5% de desconto</b></p> 12069 <small>*Não aplicável para máquinas</small> 12070 </span> 12071 </div> 12072 12073 12074 12075 </div> 12076 12077 12078 `) 12079 } 12080 } 12081 } else { 12082 $('.payment-group-list-btn a#payment-group-instantPaymentPaymentGroup[data-name=Pix]').addClass('tem-maquina') 12083 } 12084} 12085 12086$(window).on('orderFormUpdated.vtex', function (event, orderForm) { 12087 pixDiscountCheckout(orderForm) 12088}) 12089 12090$(window).on('orderFormUpdated.vtex', function (event, orderForm) { 12091 pixDiscountCheckout(orderForm) 12092 12093 if (document.querySelector('.srp-delivery-select') == null) { 12094 setTimeout(function () { 12095 const $select = $('.srp-delivery-select') 12096 12097 $select.val('Expresso') 12098 $select[0]?.dispatchEvent(new Event('change', { bubbles: true })) 12099 $select[0]?.dispatchEvent(new Event('input', { bubbles: true })) 12100 }, 500) 12101 } 12102}) 12103 12104$(window).load(function () { 12105 const $select = $('.srp-delivery-select') 12106 12107 $select.val('Expresso') 12108 $select[0].dispatchEvent(new Event('change', { bubbles: true })) 12109 $select[0].dispatchEvent(new Event('input', { bubbles: true })) 12110}) 12111 12112const NewsletterCustomizer = { 12113 SELECTORS: { 12114 NEWSLETTER_SPAN: 'span.newsletter-text[data-i18n="global.optinNewsLetter"]', 12115 OPT_IN_CHECKBOX: '#opt-in-newsletter', 12116 CHANNEL_PREFERENCES: '#channel-preferences', 12117 SELECT_ALL_CHANNELS: '#select-all-channels', 12118 TOGGLE_ARROW: '.channel-toggle-arrow', 12119 }, 12120 12121 TEXT_CONFIG: { 12122 OLD_TEXT: 'Quero receber e-mails com promoções.',
12123 NEW_TEXT: 'Quero receber comunicações de promoções', 12124 }, 12125 12126 updateNewsletterText() { 12127 const newsletterSpan = $(this.SELECTORS.NEWSLETTER_SPAN) 12128 if (newsletterSpan.length && newsletterSpan.text().includes(this.TEXT_CONFIG.OLD_TEXT)) { 12129 newsletterSpan.text(this.TEXT_CONFIG.NEW_TEXT) 12130 12131 // Adicionar setinha ao lado do texto após alterá-lo 12132 if (!newsletterSpan.find('.channel-toggle-arrow').length) { 12133 newsletterSpan.append('<span class="channel-toggle-arrow"></span>') 12134 } 12135 } 12136 }, 12137 12138 createChannelCheckboxes() { 12139 const { OPT_IN_CHECKBOX, CHANNEL_PREFERENCES } = this.SELECTORS 12140 12141 const optinCheckbox = $(OPT_IN_CHECKBOX) 12142 if (!optinCheckbox.length || $(CHANNEL_PREFERENCES).length) { 12143 return 12144 } 12145 12146 const channels = [ 12147 { id: 'channel-email', label: 'E-mail', class: 'channel-option' }, 12148 { id: 'channel-whatsapp', label: 'WhatsApp', class: 'channel-option' }, 12149 { id: 'channel-sms', label: 'SMS', class: 'channel-option' }, 12150 ] 12151 12152 const checkboxItems = channels 12153 .map( 12154 (channel) => ` 12155 <div class="channel-item"> 12156 <input type="checkbox" id="${channel.id}" class="${channel.class}" checked> 12157 <label for="${channel.id}">${channel.label}</label> 12158 </div> 12159 ` 12160 ) 12161 .join('') 12162 12163 const channelCheckboxesHTML = ` 12164 <div id="channel-preferences" class="channel-preferences"> 12165 <div class="channel-item select-all-item"> 12166 <input type="checkbox" id="select-all-channels" class="select-all-channels" checked> 12167 <label for="select-all-channels">Selecionar todos os canais</label> 12168 </div> 12169 ${checkboxItems} 12170 </div> 12171 ` 12172 12173 optinCheckbox.closest('.checkbox').after(channelCheckboxesHTML) 12174 12175 this.seedChannelDefaults() 12176 }, 12177 12178 // Os canais nascem marcados no HTML acima, mas esse estado não chegava ao insider_object: 12179 // a validação mostrou sms_optin/whatsapp_optin como undefined mesmo com o DOM marcado, o 12180 // que faz o SDK omitir so/wo do payload. Semeia aqui, junto da criação dos checkboxes, que 12181 // é o momento em que o estado passa a existir â em vez de depender da identificação 12182 // inicial, que corre por timeout e pode não rodar. 12183 // Preenche apenas o que está ausente e nunca grava false: não pode rebaixar consentimento 12184 // nem sobrescrever escolha já feita pelo cliente (R6). 12185 seedChannelDefaults() { 12186 window.insider_object = window.insider_object || {} 12187 12188 const user = window.insider_object.user || {} 12189 12190 if (typeof user.email_optin !== 'boolean') { 12191 user.email_optin = true 12192 } 12193 12194 if (typeof user.sms_optin !== 'boolean') { 12195 user.sms_optin = true 12196 } 12197 12198 if (typeof user.whatsapp_optin !== 'boolean') { 12199 user.whatsapp_optin = true 12200 } 12201 12202 // exigido pela Insider sempre que qualquer outra chave do user tem valor 12203 user.gdpr_optin = true 12204 12205 window.insider_object.user = user 12206 }, 12207 12208 manageChannelVisibility() { 12209 const { CHANNEL_PREFERENCES, TOGGLE_ARROW } = this.SELECTORS 12210 const channelPreferences = $(CHANNEL_PREFERENCES) 12211 const toggleArrow = $(TOGGLE_ARROW) 12212 12213 // Por padrão, os canais ficam escondidos 12214 if (channelPreferences.length) { 12215 channelPreferences.hide() 12216 } 12217 12218 // Atualizar rotação da seta 12219 if (toggleArrow.length) { 12220 const isVisible = channelPreferences.is(':visible') 12221 toggleArrow.css( 12222 'transform', 12223 isVisible ? 'translate(-20%, -50%) rotate(225deg)' : 'translate(-20%, -65%) rotate(315deg)' 12224 ) 12225 } 12226 }, 12227 12228 toggleChannelVisibility() { 12229 const { CHANNEL_PREFERENCES, TOGGLE_ARROW } = this.SELECTORS 12230 const channelPreferences = $(CHANNEL_PREFERENCES) 12231 const toggleArrow = $(TOGGLE_ARROW) 12232 12233 if (channelPreferences.length) { 12234 const isCurrentlyVisible = channelPreferences.is(':visible') 12235 12236 if (isCurrentlyVisible) { 12237 channelPreferences.slideUp(200) 12238 toggleArrow.css('transform', 'translate(-20%, -65%) rotate(315deg)') 12239 } else { 12240 channelPreferences.slideDown(200) 12241 toggleArrow.css('transform', 'translate(-20%, -50%) rotate(225deg)') 12242 } 12243 } 12244 }, 12245 12246 setupOptinListener() { 12247 const { OPT_IN_CHECKBOX, TOGGLE_ARROW, SELECT_ALL_CHANNELS } = this.SELECTORS 12248 12249 $(document).on('change', OPT_IN_CHECKBOX, () => { 12250 this.createChannelCheckboxes() 12251 this.manageChannelVisibility() 12252 this.setupChannelListeners() 12253 }) 12254 12255 // Listener para a setinha 12256 $(document).on('click', TOGGLE_ARROW, (e) => { 12257 e.preventDefault() 12258 e.stopPropagation() 12259 this.toggleChannelVisibility() 12260 }) 12261 12262 // Consentimento só é gravado em interação real do cliente (R6). Evento real do browser 12263 // carrega originalEvent; .trigger('change') programático não. Sem essa distinção, o 12264 // trigger sintético de setOptinNewsletterDefault() â que o MutationObserver dispara a cada 12265 // re-render do checkout â fazia getCommunicationPreferences() ler um DOM incompleto 12266 // (principal recriado desmarcado, ou #channel-preferences ainda não recriado) e rebaixar 12267 // email_optin para false sem o cliente ter tocado em nada. 12268 const isUserInteraction = (event) => Boolean(event && event.originalEvent) 12269 12270 // Listener para "Selecionar todos os canais" 12271 $(document).on('change', SELECT_ALL_CHANNELS, (event) => { 12272 this.handleSelectAllChannels() 12273 12274 // handleSelectAllChannels propaga com trigger('change'), então os eventos por canal são 12275 // sintéticos: a gravação do conjunto acontece aqui, uma vez. 12276 if (isUserInteraction(event)) { 12277 this.updateInsiderCommunicationPrefs() 12278 } 12279 }) 12280 12281 // Listener para checkboxes individuais dos canais 12282 $(document).on('change', '.channel-option', (event) => { 12283 this.updateSelectAllState() 12284 12285 if (isUserInteraction(event)) { 12286 this.updateInsiderCommunicationPrefs() 12287 } 12288 }) 12289 12290 $(document).on('change', OPT_IN_CHECKBOX, (event) => { 12291 if (isUserInteraction(event)) { 12292 this.updateInsiderCommunicationPrefs() 12293 } 12294 }) 12295 }, 12296 12297 setupChannelListeners() {
12298 // Esta função é chamada após criar os checkboxes para garantir que os listeners estejam ativos 12299 this.updateSelectAllState() 12300 }, 12301 12302 handleSelectAllChannels() { 12303 const { SELECT_ALL_CHANNELS } = this.SELECTORS 12304 const selectAllCheckbox = $(SELECT_ALL_CHANNELS) 12305 const channelOptions = $('.channel-option') 12306 12307 if (selectAllCheckbox.length && channelOptions.length) { 12308 const isChecked = selectAllCheckbox.is(':checked') 12309 channelOptions.prop('checked', isChecked) 12310 12311 // Disparar evento de mudança para cada checkbox individual 12312 channelOptions.trigger('change') 12313 } 12314 }, 12315 12316 updateSelectAllState() { 12317 const { SELECT_ALL_CHANNELS } = this.SELECTORS 12318 const selectAllCheckbox = $(SELECT_ALL_CHANNELS) 12319 const channelOptions = $('.channel-option') 12320 12321 if (selectAllCheckbox.length && channelOptions.length) { 12322 const checkedChannels = channelOptions.filter(':checked').length 12323 const totalChannels = channelOptions.length 12324 12325 // Se todos estão selecionados, marcar "Selecionar todos" 12326 // Se nenhum está selecionado, desmarcar "Selecionar todos" 12327 // Se alguns estão selecionados, deixar "Selecionar todos" desmarcado 12328 selectAllCheckbox.prop('checked', checkedChannels === totalChannels) 12329 12330 // Adicionar estado indeterminado se alguns estão selecionados 12331 selectAllCheckbox.prop('indeterminate', checkedChannels > 0 && checkedChannels < totalChannels) 12332 } 12333 }, 12334 12335 updateInsiderCommunicationPrefs() { 12336 // Garantir que o objeto Insider existe 12337 if (!window.insider_object) { 12338 window.insider_object = {} 12339 } 12340 12341 // Garantir que o objeto user existe 12342 if (!window.insider_object.user) { 12343 window.insider_object.user = {} 12344 } 12345 12346 const communicationPrefs = insiderInstallTags.getCommunicationPreferences() 12347 12348 // Atualizar preferências de comunicação 12349 Object.assign(window.insider_object.user, { 12350 email_optin: communicationPrefs.email_optin, 12351 whatsapp_optin: communicationPrefs.whatsapp_optin, 12352 sms_optin: communicationPrefs.sms_optin, 12353 gdpr_optin: true, 12354 }) 12355 12356 // Sem chamada de envio: ver a nota em sendUserDataToInsider. 12357 }, 12358 12359 setOptinNewsletterDefault() { 12360 const { OPT_IN_CHECKBOX } = this.SELECTORS 12361 const optinCheckbox = $(OPT_IN_CHECKBOX) 12362 12363 if (optinCheckbox.length && !optinCheckbox.is(':checked')) { 12364 optinCheckbox.prop('checked', true).trigger('change') 12365 } 12366 }, 12367 12368 init() { 12369 this.updateNewsletterText() 12370 this.setOptinNewsletterDefault() 12371 this.createChannelCheckboxes() 12372 12373 this.manageChannelVisibility() 12374 this.setupChannelListeners() 12375 this.setupOptinListener() 12376 12377 const observer = new MutationObserver((mutations) => { 12378 mutations.forEach((mutation) => { 12379 if (mutation.type === 'childList') { 12380 this.updateNewsletterText() 12381 this.setOptinNewsletterDefault() 12382 if ($(this.SELECTORS.OPT_IN_CHECKBOX).length && !$(this.SELECTORS.CHANNEL_PREFERENCES).length) { 12383 this.createChannelCheckboxes() 12384 this.manageChannelVisibility() 12385 this.setupChannelListeners() 12386 } 12387 } 12388 }) 12389 }) 12390 12391 observer.observe(document.body, { 12392 childList: true, 12393 subtree: true, 12394 }) 12395 }, 12396} 12397 12398NewsletterCustomizer.init() 12399 12400;(function (window) { 12401 const partnerId = '10010710' 12402 const partnerName = 'bblendbr' 12403 12404 const domainName = window.location.origin 12405 const insiderUrl = 12406 domainName + 12407 '/insider/checkout-script?partnerId=' + 12408 partnerId + 12409 '&partnerName=' + 12410 partnerName 12411 12412 const xmlHttp = new XMLHttpRequest() 12413 xmlHttp.open('GET', insiderUrl, false) 12414 xmlHttp.send(null) 12415 12416 const importScript = document.createElement('script') 12417 importScript.type = 'text/javascript' 12418 importScript.id = 'insider-checkout' 12419 importScript.text = xmlHttp.responseText 12420 document.head.appendChild(importScript) 12421})(window) 12422 12423const CardAliases = { 12424 // Apelidos de cartões salvos (task 61432). Kill-switch: app setting `enabled` 12425 // do bblend.card-aliases (sem redeploy) + window.__CARD_ALIASES_OFF__ (emergência). 12426 // Qualquer falha degrada em silêncio: o apelido apenas não aparece. 12427 API: { 12428 CONFIG: '/_v/card-aliases/config', 12429 CARDS: '/_v/card-aliases/cards', 12430 ALIASES: '/_v/card-aliases', 12431 }, 12432 LABEL_CLASS: '_card-alias', 12433 FIELD_CLASS: '_card-alias-field', 12434 OVERLAY_CLASS: '_card-alias-overlay', 12435 ROW_CLASS: '_card-alias-overlay-row', 12436 IFRAME_SELECTOR: 'iframe[src*="vtexpayments"]', 12437 // lista e form vivem DENTRO do iframe PCI; a vista é inferida pela altura 12438 // (o CSS injetado no iframe fixa a altura das linhas â ver checkout6-custom.css) 12439 FORM_MIN_HEIGHT: 300, 12440 LIST_ROW_HEIGHT: 56, 12441 LIST_TOP_OFFSET: 0, 12442 LIST_LABEL_LEFT: 58, 12443 STORAGE_KEY: 'card-alias-pending', 12444 PENDING_TTL_MS: 30 * 60 * 1000, 12445 MAX_LENGTH: 40, 12446 DEBOUNCE_MS: 300, 12447 cardsPromise: null, 12448 knownAccountIds: null, 12449 debounceTimer: null, 12450 iframeObserver: null, 12451 observedIframe: null, 12452 12453 isKilled: () => window.__CARD_ALIASES_OFF__ === true, 12454 12455 fetchConfig: async () => { 12456 try { 12457 const res = await fetch(CardAliases.API.CONFIG, { credentials: 'same-origin' }) 12458 if (!res.ok) return false 12459 const data = await res.json() 12460 return !!data && data.enabled === true 12461 } catch (e) { 12462 return false 12463 } 12464 }, 12465 12466 fetchCards: (force) => { 12467 if (!force && CardAliases.cardsPromise) return CardAliases.cardsPromise 12468 const promise = (async () => {
12469 try { 12470 const res = await fetch(CardAliases.API.CARDS, { credentials: 'same-origin' }) 12471 if (!res.ok) { 12472 CardAliases.cardsPromise = null 12473 return null 12474 } 12475 const data = await res.json() 12476 if (!data || data.enabled !== true || !Array.isArray(data.cards)) { 12477 CardAliases.cardsPromise = null 12478 return null 12479 } 12480 return data.cards 12481 } catch (e) { 12482 CardAliases.cardsPromise = null 12483 return null 12484 } 12485 })() 12486 CardAliases.cardsPromise = promise 12487 return promise 12488 }, 12489 12490 saveAlias: async (accountId, alias) => { 12491 const res = await fetch(CardAliases.API.ALIASES, { 12492 method: 'PUT', 12493 credentials: 'same-origin', 12494 headers: { 'Content-Type': 'application/json' }, 12495 body: JSON.stringify({ accountId, alias }), 12496 }) 12497 if (!res.ok) throw new Error('CardAliases PUT HTTP ' + res.status) 12498 }, 12499 12500 readPending: () => { 12501 try { 12502 const raw = window.sessionStorage.getItem(CardAliases.STORAGE_KEY) 12503 if (!raw) return null 12504 const pending = JSON.parse(raw) 12505 if (!pending || !pending.alias) return null 12506 if (Date.now() - (pending.savedAt || 0) > CardAliases.PENDING_TTL_MS) { 12507 window.sessionStorage.removeItem(CardAliases.STORAGE_KEY) 12508 return null 12509 } 12510 return pending 12511 } catch (e) { 12512 return null 12513 } 12514 }, 12515 12516 writePending: (value) => { 12517 try { 12518 const alias = String(value || '') 12519 .trim() 12520 .slice(0, CardAliases.MAX_LENGTH) 12521 if (alias) { 12522 window.sessionStorage.setItem( 12523 CardAliases.STORAGE_KEY, 12524 JSON.stringify({ alias, savedAt: Date.now() }) 12525 ) 12526 } else { 12527 window.sessionStorage.removeItem(CardAliases.STORAGE_KEY) 12528 } 12529 } catch (e) {} 12530 }, 12531 12532 clearPending: () => { 12533 try { 12534 window.sessionStorage.removeItem(CardAliases.STORAGE_KEY) 12535 } catch (e) {} 12536 }, 12537 12538 reconcilePending: async (cards, pending) => { 12539 try { 12540 if (!pending || !Array.isArray(CardAliases.knownAccountIds)) return 12541 const fresh = cards.find( 12542 (card) => CardAliases.knownAccountIds.indexOf(card.accountId) === -1 && !card.alias 12543 ) 12544 if (!fresh) return 12545 await CardAliases.saveAlias(fresh.accountId, pending.alias) 12546 fresh.alias = pending.alias 12547 CardAliases.clearPending() 12548 } catch (e) { 12549 console.error('CardAliases reconcile:', e) 12550 } 12551 }, 12552 12553 findCardLabel: (container, card) => { 12554 const brand = (card.brand || '').toLowerCase() 12555 const nodes = container.querySelectorAll('label, span, p, li, div') 12556 for (let i = 0; i < nodes.length; i++) { 12557 const el = nodes[i] 12558 if (el.childElementCount > 0) continue 12559 if (el.classList.contains(CardAliases.LABEL_CLASS)) continue 12560 if (el.closest('.' + CardAliases.FIELD_CLASS)) continue 12561 const text = (el.textContent || '').toLowerCase() 12562 if (!text || text.length > 120) continue 12563 if (text.indexOf(card.lastDigits) === -1) continue 12564 if (brand && text.indexOf(brand) === -1 && !/(final|terminado|\*{2,}|â¢{2,})/.test(text)) { 12565 continue 12566 } 12567 return el 12568 } 12569 return null 12570 }, 12571 12572 applyAliasTo: (target, card) => { 12573 const existing = target.querySelector( 12574 '.' + CardAliases.LABEL_CLASS + '[data-account-id="' + card.accountId + '"]' 12575 ) 12576 if (existing) { 12577 if (!card.alias) existing.remove() 12578 else if (existing.textContent !== card.alias) existing.textContent = card.alias 12579 return 12580 } 12581 if (!card.alias) return 12582 const span = document.createElement('span') 12583 span.className = CardAliases.LABEL_CLASS 12584 span.setAttribute('data-account-id', card.accountId) 12585 span.textContent = card.alias 12586 target.appendChild(span) 12587 }, 12588 12589 decorate: (cards) => { 12590 try { 12591 // Escopo no document: o form/lista de cartões pode renderizar em modal fora do #payment-data 12592 const container = document 12593 cards.forEach((card) => { 12594 if (!card.accountId) return
12595 // Casamento primário: o value do radio da SavedCardsList é o próprio accountId 12596 const inputs = container.querySelectorAll( 12597 '.SavedCardsList input[value="' + card.accountId + '"]' 12598 ) 12599 if (inputs.length > 0) { 12600 inputs.forEach((input) => { 12601 const label = input.closest('label') 12602 if (!label) return 12603 const target = 12604 label.querySelector('.card-label') || label.querySelector('.card-list-element') || label 12605 CardAliases.applyAliasTo(target, card) 12606 }) 12607 return 12608 } 12609 // Fallback: casamento por texto (lastDigits + bandeira) 12610 if (!card.lastDigits) return 12611 const existing = container.querySelector( 12612 '.' + CardAliases.LABEL_CLASS + '[data-account-id="' + card.accountId + '"]' 12613 ) 12614 if (existing) { 12615 if (!card.alias) existing.remove() 12616 else if (existing.textContent !== card.alias) existing.textContent = card.alias 12617 return 12618 } 12619 if (!card.alias) return 12620 const target = CardAliases.findCardLabel(container, card) 12621 if (!target) return 12622 CardAliases.applyAliasTo(target, card) 12623 }) 12624 } catch (e) { 12625 console.error('CardAliases decorate:', e) 12626 } 12627 }, 12628 12629 getIframe: () => 12630 document.querySelector('#payment-data ' + CardAliases.IFRAME_SELECTOR) || 12631 document.querySelector(CardAliases.IFRAME_SELECTOR), 12632 12633 // A lista do iframe renderiza o paymentData.availableAccounts do orderForm: 12634 // é a fonte da verdade para QUAIS cartões aparecem e em QUAL ordem 12635 getAvailableAccounts: () => { 12636 try { 12637 const orderForm = window.vtexjs && window.vtexjs.checkout && window.vtexjs.checkout.orderForm 12638 const paymentData = orderForm && orderForm.paymentData 12639 return (paymentData && paymentData.availableAccounts) || null 12640 } catch (e) { 12641 return null 12642 } 12643 }, 12644 12645 isFormOpen: (iframe, cardsCount) => { 12646 if (!iframe) return false 12647 const listHeight = (cardsCount + 1) * CardAliases.LIST_ROW_HEIGHT + 100 12648 return iframe.offsetHeight >= Math.max(CardAliases.FORM_MIN_HEIGHT, listHeight) 12649 }, 12650 12651 observeIframe: (iframe) => { 12652 try { 12653 if (!iframe || CardAliases.observedIframe === iframe) return 12654 if (typeof ResizeObserver === 'undefined') return 12655 if (CardAliases.iframeObserver) CardAliases.iframeObserver.disconnect() 12656 CardAliases.iframeObserver = new ResizeObserver(CardAliases.refresh) 12657 CardAliases.iframeObserver.observe(iframe) 12658 CardAliases.observedIframe = iframe 12659 } catch (e) { 12660 console.error('CardAliases observeIframe:', e) 12661 } 12662 }, 12663 12664 syncNewCardField: (iframe, formOpen) => { 12665 try { 12666 let wrapper = document.querySelector('.' + CardAliases.FIELD_CLASS) 12667 if (!iframe || !iframe.parentElement) { 12668 if (wrapper) wrapper.style.display = 'none' 12669 return 12670 } 12671 if (!wrapper) { 12672 const pending = CardAliases.readPending() 12673 wrapper = document.createElement('div') 12674 wrapper.className = CardAliases.FIELD_CLASS 12675 const label = document.createElement('label') 12676 label.textContent = 'Apelido do cartão (opcional)' 12677 const input = document.createElement('input') 12678 input.type = 'text' 12679 input.maxLength = CardAliases.MAX_LENGTH 12680 input.placeholder = 'Ex.: Cartão do trabalho' 12681 input.autocomplete = 'off' 12682 if (pending) input.value = pending.alias 12683 input.addEventListener('input', () => CardAliases.writePending(input.value)) 12684 wrapper.appendChild(label) 12685 wrapper.appendChild(input) 12686 iframe.insertAdjacentElement('beforebegin', wrapper) 12687 } 12688 wrapper.style.display = formOpen ? '' : 'none' 12689 } catch (e) { 12690 console.error('CardAliases field:', e) 12691 } 12692 }, 12693 12694 syncOverlay: (cards, iframe, formOpen) => { 12695 try { 12696 const existing = document.querySelector('.' + CardAliases.OVERLAY_CLASS) 12697 const withAlias = cards.filter((card) => card.alias) 12698 if (!iframe || !iframe.parentElement || formOpen || withAlias.length === 0) { 12699 if (existing) existing.remove() 12700 return 12701 } 12702 const parent = iframe.parentElement 12703 const signature = JSON.stringify([ 12704 iframe.offsetTop, 12705 iframe.offsetLeft, 12706 iframe.offsetWidth, 12707 cards.map((card) => (card.alias ? card.accountId + ':' + card.alias : '')), 12708 ]) 12709 if (existing && existing.getAttribute('data-signature') === signature) return 12710 if (existing) existing.remove() 12711 if (window.getComputedStyle(parent).position === 'static') { 12712 parent.style.position = 'relative' 12713 }
12714 const overlay = document.createElement('div') 12715 overlay.className = CardAliases.OVERLAY_CLASS 12716 overlay.setAttribute('data-signature', signature) 12717 overlay.style.top = iframe.offsetTop + CardAliases.LIST_TOP_OFFSET + 'px' 12718 overlay.style.left = iframe.offsetLeft + 'px' 12719 overlay.style.width = iframe.offsetWidth + 'px' 12720 // uma linha por cartão, na MESMA ordem em que a lista renderiza no iframe 12721 cards.forEach((card, index) => { 12722 if (!card.alias) return 12723 const row = document.createElement('div') 12724 row.className = CardAliases.ROW_CLASS 12725 row.style.top = index * CardAliases.LIST_ROW_HEIGHT + 'px' 12726 row.style.height = CardAliases.LIST_ROW_HEIGHT + 'px' 12727 row.style.paddingLeft = CardAliases.LIST_LABEL_LEFT + 'px' 12728 const span = document.createElement('span') 12729 span.className = CardAliases.LABEL_CLASS 12730 span.setAttribute('data-account-id', card.accountId) 12731 span.textContent = card.alias 12732 row.appendChild(span) 12733 overlay.appendChild(row) 12734 }) 12735 parent.appendChild(overlay) 12736 } catch (e) { 12737 console.error('CardAliases overlay:', e) 12738 } 12739 }, 12740 12741 isPaymentStep: () => window.location.hash.indexOf('payment') !== -1, 12742 12743 refresh: () => { 12744 clearTimeout(CardAliases.debounceTimer) 12745 CardAliases.debounceTimer = setTimeout(async () => { 12746 try { 12747 if (CardAliases.isKilled() || !CardAliases.isPaymentStep()) return 12748 const pending = CardAliases.readPending() 12749 const cards = await CardAliases.fetchCards(!!pending) 12750 if (!cards) return 12751 await CardAliases.reconcilePending(cards, pending) 12752 if (!Array.isArray(CardAliases.knownAccountIds) || pending === null) { 12753 CardAliases.knownAccountIds = cards.map((card) => card.accountId) 12754 } 12755 CardAliases.decorate(cards) 12756 const iframe = CardAliases.getIframe() 12757 CardAliases.observeIframe(iframe) 12758 const accounts = CardAliases.getAvailableAccounts() 12759 const rows = accounts 12760 ? accounts.map((account) => { 12761 const match = cards.find((card) => card.accountId === account.accountId) 12762 return { accountId: account.accountId, alias: match ? match.alias : null } 12763 }) 12764 : cards 12765 const formOpen = CardAliases.isFormOpen(iframe, rows.length) 12766 CardAliases.syncNewCardField(iframe, formOpen) 12767 CardAliases.syncOverlay(rows, iframe, formOpen) 12768 } catch (e) { 12769 console.error('CardAliases refresh:', e) 12770 } 12771 }, CardAliases.DEBOUNCE_MS) 12772 }, 12773 12774 init: async () => { 12775 try { 12776 if (CardAliases.isKilled()) return 12777 const enabled = await CardAliases.fetchConfig() 12778 if (!enabled || CardAliases.isKilled()) return 12779 await waitForElm('#payment-data') 12780 const observer = new MutationObserver(CardAliases.refresh) 12781 observer.observe(document.body, { childList: true, subtree: true }) 12782 window.addEventListener('hashchange', CardAliases.refresh) 12783 CardAliases.refresh() 12784 } catch (e) { 12785 console.error('CardAliases init:', e) 12786 } 12787 }, 12788} 12789 12790CardAliases.init() 12791;
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.