/*!! * VtexUtils.js v1.18.1 * https://github.com/zeindelf/vtex-utils * * Copyright (c) 2017-2018 Zeindelf * Released under the MIT license * * Date: 2018-09-17T18:32:03.664Z */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e.VTEX=e.VTEX||{},e.VTEX.VtexUtils=t())}(this,function(){"use strict";var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var f,t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},n=function(){function n(e,t){for(var r=0;rk.length(this._area)&&(n--,r--)}return t||this},keys:function(e){return this.each(function(e,t){t.push(e)},e||[])},get:function(e,t){var r=k.get(this._area,this._in(e));return null!==r?k.parse(r):t||r},getAll:function(e){return this.each(function(e,t){t[e]=this.get(e)},e||{})},transact:function(e,t,r){var n=this.get(e,r),i=t(n);return this.set(e,void 0===i?n:i),this},set:function(e,t,r){var n=this.get(e);return null!=n&&!1===r?t:k.set(this._area,this._in(e),k.stringify(t),r)||n},setAll:function(e,t){var r,n;for(var i in e)n=e[i],this.set(i,n,t)!==n&&(r=!0);return r},add:function(e,t){var r=this.get(e);if(r instanceof Array)t=r.concat(t);else if(null!==r){var n=void 0===r?"undefined":m(r);if(n===(void 0===t?"undefined":m(t))&&"object"===n){for(var i in t)r[i]=t[i];t=r}else t=r+t}return k.set(this._area,this._in(e),k.stringify(t)),t},remove:function(e){var t=this.get(e);return k.remove(this._area,this._in(e)),t},clear:function(){return this._ns?this.each(function(e){k.remove(this._area,this._in(e))},1):k.clear(this._area),this},clearAll:function(){var e=this._area;for(var t in k.areas)k.areas.hasOwnProperty(t)&&(this._area=k.areas[t],this.clear());return this._area=e,this},_in:function(e){return"string"!=typeof e&&(e=k.stringify(e)),this._ns?this._ns+e:e},_out:function(e){return this._ns?e&&0===e.indexOf(this._ns)?e.substring(this._ns.length):void 0:e}},storageAPI:{length:0,has:function(e){return this.items.hasOwnProperty(e)},key:function(e){var t=0;for(var r in this.items)if(this.has(r)&&e===t++)return r},setItem:function(e,t){this.has(e)||this.length++,this.items[e]=t},removeItem:function(e){this.has(e)&&(delete this.items[e],this.length--)},getItem:function(e){return this.has(e)?this.items[e]:null},clear:function(){for(var e in this.items)this.removeItem(e)},toString:function(){return this.length+" items in "+this.name+"Storage"}}},S=k.Store("local",function(){try{return localStorage}catch(e){}}());(S.local=S)._=k,S.area("session",function(){try{return sessionStorage}catch(e){}}()),a=(o=S)._,e=a.set,n=a.get,g=a.remove,p=a.key,d=a.length,r=a.clear,a.overflow=function(e,t){var r=e===a.areas.local?"+local+":e===a.areas.session&&"+session+";if(r){var n=a.areas[r];return t&&!n?n=o.area(r)._area:!1===t&&(delete a.areas[r],delete o[r]),n}},a.set=function(t,r,n){try{e.apply(this,arguments)}catch(e){if("QUOTA_EXCEEDED_ERR"===e.name||"NS_ERROR_DOM_QUOTA_REACHED"===e.name||-1!==e.toString().indexOf("QUOTA_EXCEEDED_ERR")||-1!==e.toString().indexOf("QuotaExceededError"))return a.set(a.overflow(t,!0),r,n);throw e}},a.get=function(e,t){var r=a.overflow(e);return r&&n.call(this,r,t)||n.apply(this,arguments)},a.remove=function(e,t){var r=a.overflow(e);r&&g.call(this,r,t),g.apply(this,arguments)},a.key=function(e,t){var r=a.overflow(e);if(r){var n=d.call(this,e);if(n<=t){t-=n;for(var i=0,o=d.call(this,r);i=n?e.removeItem(t):r},s.get=function(e,t){var r=s.cache(e,t);return void 0===r?null:r},s.set=function(t,r,e,n){try{n&&(e=l+(s.when()+n)+";"+e),f(t,r,e)}catch(e){if("QUOTA_EXCEEDED_ERR"===e.name||"NS_ERROR_DOM_QUOTA_REACHED"===e.name){for(var i=!1,o=0,a=t.length;o/g,">").replace(/\//g,"/").replace(/\\/g,"\").replace(/`/g,"`")},normalizeText:function(e){var t,r=this,n=/(^|[.!?]\s+)([a-z])/g;return t=e,r.strCompact(t.replace(/[,.!?:;]+(?=\S)/g,"$& ")).toLowerCase().replace(n,function(e,t,r){return t+r.toUpperCase()})},pad:function(e,t){for(var r=String(e);r.length<(t||2);)r="0"+r;return r},removeAccent:function(e){var t=/[àáâãäçèéêëìíîïñòóôõöùúûüýÿÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝ]/g;return e.replace(t,function(e){return"_aaaaaceeeeiiiinooooouuuuyyAAAAACEEEEIIIINOOOOOUUUUY"[t.source.indexOf(e)]})},slugifyText:function(e){e=e.replace(/^\s+|\s+$/g,"").toLowerCase().replace(/\./g,"-").replace(/\*/g,"-").replace(/\+/g,"-");for(var t="àáäâãèéëêìíïîòóöôõùúüûýÿñç·/_,:;",r=0,n=t.length;r").replace(///g,"/").replace(/\/g,"\\").replace(/`/g,"`")}},P={camelize:function(n){var i=this,o=function(e){return e=j.underscore(e),(e=j.slugifyText(e)).replace(/[_.-\s](\w|$)/g,function(e,t){return t.toUpperCase()})};return _.isDate(n)||_.isRegExp(n)?n:_.isArray(n)?n.map(function(e,t){return _.isObject(e)?i.camelize(e):e}):_.isString(n)?o(n):Object.keys(n).reduce(function(e,t){var r=o(t);return e[r]=n[t],_.isObject(n[t])&&(e[r]=i.camelize(n[t])),e},{})},contains:function(e,t){if(_.isArray(t))for(var r=0,n=t.length;r/g)||[]).join(""),j.strCompact(e.replace(/|<\?(?:php)?[\s\S]*?\?>/gi,"").replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi,function(e,t){return-1")?e:" "}))},throttle:function(e,t,r){var n=!0,i=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return _.isObject(r)&&(n="leading"in r?!!r.leading:n,i="trailing"in r?!!r.trailing:i),this.debounce(e,t,{leading:n,maxWait:t,trailing:i})},times:function(e,t){var r=4294967295;if(e<1||9007199254740991>>0===e&&4294967295!==e},isBoolean:function(e){return!0===e||!1===e||"[object Boolean]"===O.call(e)},isChar:function(e){return this.isString(e)&&1===e.length},isCnpj:function(e){var t=this._stripNumber(e),r=this._verifierEqualDigits(t);if(!t||14!==t.length||r)return!1;var n=t.substr(0,12);return n+=this._verifierCnpjDigit(n),(n+=this._verifierCnpjDigit(n)).substr(-2)===t.substr(-2)},isCpf:function(e){var t=this._stripNumber(e),r=this._verifierEqualDigits(t);if(!t||11!==t.length||r)return!1;var n=t.substr(0,9);return n+=this._verifierCpfDigit(n),(n+=this._verifierCpfDigit(n)).substr(-2)===t.substr(-2)},isDate:function(e){return"[object Date]"===O.call(e)},isDomNode:function(e){return this.isObject(e)&&0=r&&n.push(n.splice(r-1).join(t)),n},implode:function(e,t){if(_.isArray(e))return e.join(t||",");if(_.isObject(e)){var r=[];for(var n in e)object.hasOwnProperty(n)&&r.push(e[n]);return r.join(t||",")}return""},indexOfAll:function(e,n){return e.reduce(function(e,t,r){return t===n?[].concat(w(e),[r]):e},[])},shuffleArray:function(e){for(var t=0,r=[],n=[],i=e.length-1;0>>0,t>>>=0;for(var i=-1,o=new Array(n);++i tr"),i={fullResponse:e};return r.find(".valor").length&&(i.error=!0,i.formattedResponse={shippingText:s.strCompact((t=e,t.replace(/<\/?[^>]+(>|$)/g,"")))}),n.length&&(i.error=!1,i.formattedResponse=n.map(function(e,t){var r=$(t).children("td"),n=r.eq(1).text().split(","),i=r.eq(0).text(),o=n[0];return{shippingValue:i,shippingText:s.ucfirst(s.strCompact(n[1])),shippingType:o}}).toArray()),o.resolve(i)}).fail(function(e){return o.reject(e)})}).promise()},sortProductSearch:function(e,t,r){var n=3"):""},stringIdsToArray:function(e){var t=1