crmbonus-component-wake 2.1.36-homolog → 2.1.37-homolog
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/countdown-timer_11.cjs.entry.js +10 -5
- package/dist/cjs/countdown-timer_11.cjs.entry.js.map +1 -1
- package/dist/collection/components/crm-bonus/crm-bonus.js +3 -0
- package/dist/collection/components/crm-bonus/crm-bonus.js.map +1 -1
- package/dist/collection/components/giftback-form/giftback-form.js +7 -5
- package/dist/collection/components/giftback-form/giftback-form.js.map +1 -1
- package/dist/components/crm-bonus.js +4 -1
- package/dist/components/crm-bonus.js.map +1 -1
- package/dist/components/crm-giftback-form.js +1 -1
- package/dist/components/{p-a7d4e578.js → p-21d3aa06.js} +8 -6
- package/dist/components/p-21d3aa06.js.map +1 -0
- package/dist/crmbonus-component-wake/crmbonus-component-wake.esm.js +1 -1
- package/dist/crmbonus-component-wake/p-51552cbd.entry.js +2 -0
- package/dist/crmbonus-component-wake/{p-5d014ac9.entry.js.map → p-51552cbd.entry.js.map} +1 -1
- package/dist/esm/countdown-timer_11.entry.js +10 -5
- package/dist/esm/countdown-timer_11.entry.js.map +1 -1
- package/package.json +1 -1
- package/dist/components/p-a7d4e578.js.map +0 -1
- package/dist/crmbonus-component-wake/p-5d014ac9.entry.js +0 -2
@@ -1,2 +0,0 @@
|
|
1
|
-
import{r as t,h as i,H as e}from"./p-8c362346.js";import{C as o,U as s,g as n,a,b as r,c,p as d}from"./p-bea5a5c2.js";import{d as l,S as h,i as p,g as u,M as f}from"./p-b4f52f79.js";import{d as b,a as g}from"./p-af3ba015.js";const m=class{constructor(i){t(this,i);this.downtime=undefined;this.dataCriacao=undefined;this.minutos=6;this.segundos=60;this.tempoRestante=undefined}componentWillLoad(){const t=this.minutos*this.segundos*1e3;const i=new Date(this.dataCriacao);const e=new Date;const o=e.getTime()-i.getTime();if(o>=t){this.tempoRestante=0;this.onTempoEsgotado()}else{this.tempoRestante=t-o;this.startCountdown()}}disconnectedCallback(){clearInterval(this.intervalId)}startCountdown(){this.intervalId=setInterval((()=>{this.tempoRestante-=1e3;if(this.tempoRestante<=0){this.tempoRestante=0;clearInterval(this.intervalId);this.onTempoEsgotado()}}),1e3)}onTempoEsgotado(){console.log("Tempo esgotado! Executando ação...");this.downtime()}render(){const t=Math.floor(this.tempoRestante/6e4);const e=Math.floor(this.tempoRestante%6e4/1e3);const o=`${String(t).padStart(2,"0")}:${String(e).padStart(2,"0")}`;return i("label",{key:"ed1e0654cba5b152adcadb10cf9dfd6909c07a1f"}," ",o)}};var x;(function(t){t["P"]="Promocao";t["CC"]="ContaCorrente";t["PP"]="PromocaoProduto";t["F"]="Formula"})(x||(x={}));function y(t=[]){const i=[];for(const n of t){let t=v(n.Ajustes);var e=n.PrecoDe*n.Quantidade;var o=n.PrecoDe*n.Quantidade;var s=t*-1;const a=n.Ajustes.filter((t=>[x.PP].includes(t.Tipo)));const r=a.length>0;i.push({sku:n.SKU,value:e,originalValue:o,productVariantId:n.ProdutoVarianteId.toString(),quantity:n.Quantidade,discount:e<s?e:s,promotion_product:r})}return i}function v(t=[]){let i=0;for(const e of t){if([x.P,x.CC,x.PP].includes(e.Tipo)){i+=e.Valor}}return i}const w=".container-button{cursor:pointer;padding:5px 5px 5px 14px;}.section-crm{border:1px solid #dbd4d4;text-align:-webkit-center;margin-bottom:20px}.section-cart-crm{margin-top:10px}.section-cart-crm p{padding:0;margin:0px 0px 0px 15px}.button{top:50%;background-color:#6c6c7e;color:#fff;border:none;padding:15px;min-height:30px;min-width:120px;cursor:pointer;margin-left:10px;height:70px}.form-container{width:97%;display:flex;justify-content:space-around}.btn{display:inline-block;padding:6px 12px;margin-bottom:0;font-weight:400;line-height:1.42857143;text-align:center;white-space:nowrap;vertical-align:middle;-ms-touch-action:manipulation;touch-action:manipulation;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background-image:none;border:1px solid transparent;border-radius:0px}.form-container .btnCrm{background:#00162e;border-color:#00162e;width:30%;color:#fff}.message-alert{color:#df4d4d;margin-top:5px}";const k=w;const I=class{constructor(i){t(this,i);this.crmBonusService=o.getInstance();this.cart=undefined;this.canhidden=false;this.showModal=false;this.cartWake=undefined;this.customer={birthDate:"",document:"",name:"",phone:""};this.loading=false;this.message=undefined;this.phone=undefined;this.canCancel=false;this.amountCancel=undefined;this.sent=undefined;this.session=undefined;this.loading_reprocess=false;this.styles=l;this.reservedInfo=undefined}async resetBonus(){console.log("[CRMBONUS] - reset bonus");try{await this.crmBonusRef.processBonus(this.buildProducts(),true);console.log("[BONUS RESETADO]!!!!!")}catch(t){this.loading=false;console.log("[error ao reprocessar bonous]");await this.crmBonusRef.setStep(h.STEP_PHONE)}finally{this.loading=false}}async setloading(){this.loading_reprocess=!this.loading_reprocess}async reprocess(){console.log("[CRMBONUS] - reprocess");this.loading_reprocess=true;try{const t=localStorage.getItem(s);if(!t)return;this.cartWake=await n();await this.resetBonus()}catch(t){console.debug("[watchProducts]",t.message)}finally{this.loading_reprocess=false}}async componentWillLoad(){this.loading_reprocess=true;window.addEventListener("productRemovedFromCart",(async()=>{console.log("[CRMBONUS] - productRemovedFromCart");await this.reprocess()}));window.addEventListener("productAddedToCart",(async()=>{console.log("[CRMBONUS] - productAddedToCart");await this.reprocess()}));document.querySelectorAll("form").forEach((t=>{t.addEventListener("submit",(async()=>{console.log("[CRMBONUS] - Formulário está sendo submetido!");await this.reprocess()}))}));await this.observerHandle();p.changeLanguage(p.language)}async componentDidLoad(){try{await this.loadSession();this.handleLoad();await this.loadConfigStore()}catch(t){this.loading_reprocess=false}}async observerHandle(){const t=document.getElementsByTagName("a");for(let i of t){console.log("[el.href]",i.href);if(i.href.includes("Produto/Delete")){i.addEventListener("click",(async()=>{console.log("[CRMBONUS] - Produto removido do carrinho");setTimeout((async()=>{await this.reprocess();this.observerHandle()}),2e3)}))}if(i.href.includes("Produto/Add")){i.addEventListener("click",(async()=>{console.log("[CRMBONUS] - Produto adicionado ao carrinho");setTimeout((async()=>{await this.reprocess();this.observerHandle()}),2e3)}))}}}async loadConfigStore(){const[t,i]=await Promise.all([this.crmBonusService.getCustomization(this.cartWake.store.name),a(this.cartWake.id,this.cartWake.store.name)]);this.reservedInfo=i;if(t.keepStoreFrontStyle){this.styles=null}}async fetchCustomer(t,i){try{return await this.crmBonusService.getCustomer(t,i)}catch(t){console.error("[fetchCustomer] Error fetching customer:",t);return null}}async handleLoad(){try{if(this.cartWake.user.id){this.fetchCustomer(this.cartWake.user.id,this.cartWake.store.name).then((t=>{if(t){this.customer=t}}))}const t=localStorage.getItem(this.cartWake.id);if(t){this.canCancel=true;this.amountCancel=t}await this.buildAndGetProducts(this.cartWake.products)}catch(t){console.log("info customer")}}async loadSession(){this.cartWake=this.cart?new r(JSON.parse(this.cart)):await n();console.log("[bc:carregou carrinho]");this.session=await this.crmBonusService.getToken(this.cartWake.store.name);console.log("[bc:carregou session]");setTimeout((()=>{this.loadSession()}),15e5)}async buildAndGetProducts(t){console.log();const i=`bc-products:${this.cartWake.id}`;const e=JSON.stringify(t);localStorage.setItem(i,e);const o=JSON.parse(localStorage.getItem(i));const s=[];for(const i of t){const[t]=o.filter((t=>t.ProdutoVarianteId==i.ProdutoVarianteId));if(t){s.push(Object.assign(Object.assign({},i),{PrecoPor:t.PrecoPor,PrecoDe:t.PrecoDe,Quantidade:t.Quantidade,Ajustes:t.Ajustes}))}else{s.push(i)}}this.cartWake.products=s}async sendPin(t){var i,e;this.loading=true;this.message="";try{const i=t.replace(/\D/g,"");this.phone=Number(i);this.sent=await this.crmBonusService.sendPin(this.phone,this.customer.name,this.cartWake.store.name);await this.crmBonusRef.setStep(h.STEP_PIN);this.showModal=true}catch(t){this.message=(e=(i=t===null||t===void 0?void 0:t.response)===null||i===void 0?void 0:i.data)===null||e===void 0?void 0:e.message}finally{this.loading=false}}async sendPinName(t){var i,e;this.loading=true;this.message="";try{this.customer.name=t;this.sent=await this.crmBonusService.sendPin(this.phone,this.customer.name,this.cartWake.store.name);await this.crmBonusRef.setStep(h.STEP_PIN);this.showModal=true}catch(t){this.message=(e=(i=t===null||t===void 0?void 0:t.response)===null||i===void 0?void 0:i.data)===null||e===void 0?void 0:e.message}finally{this.loading=false}}buildProducts(){return y(this.cartWake.products)}handleCloseModal(){this.showModal=false}save(t){localStorage.setItem(this.cartWake.id,t.toString());this.canCancel=true;this.amountCancel=t.toString()}async cancel(){this.message="";this.loading=true;try{await this.crmBonusService.cancel(this.cartWake.id);this.canCancel=false;localStorage.removeItem(this.cartWake.id)}catch(t){this.message="Não consegui cancelar o bônus, tente novamente!"}finally{this.loading=false}}async handleSendPin(t){this.message="";if(!t){this.message="Informe seu telefone";return}this.customer.phone=t;const i=t.replace(/\D/g,"");this.phone=Number(i);if(this.customer.name){return this.sendPin(t)}await this.crmBonusRef.setStep(h.STEP_NAME);this.showModal=true}render(){if(this.canhidden){return null}return i("loading-container",{loading:this.loading_reprocess,text:"carregando..."},!this.loading_reprocess&&i("crm-giftback-form",{customStyles:this.styles,style:{position:"relative"},ref:t=>this.crmBonusRef=t,storeName:this.cartWake.store.name,products:this.buildProducts(),cartId:this.cartWake.id,customer:this.customer,loadProducts:()=>this.buildProducts(),loadAll:()=>this.handleLoad(),reservedInfo:this.reservedInfo}))}static get assetsDirs(){return["assets"]}};I.style=k;const M="input,button{margin:0;padding:10px;}.crm-contaner-button{height:auto;width:auto}.crm-button{height:48px;width:100%;border:1px solid #000;padding:14px 20px;background-color:#000;color:#fff;line-height:20px;font-weight:500;cursor:pointer}";const N=M;const D=class{constructor(i){t(this,i);this.txtBtn=undefined;this.loading=undefined;this.handleClick=undefined}render(){return i("div",{key:"785b4975fb6538dbe2cdb7b99d5801abc72c534a",class:"crm-contaner-button"},i("button",{key:"1e41951aa024e9f3b9b1836e8386bd369d022f76",class:"crm-button",onClick:()=>this.handleClick()},!this.loading?this.txtBtn:i("loading-spinner",{size:"15px",color:"#fff"})))}};D.style=N;const S="*{margin:0;padding:0;box-sizing:border-box}:host{--crmfont-sizebodymd:14px;--crmline-heightbodymd:20px;--crmletter-spacingtitle-md:0px}.container-message{font-weight:400;line-height:var(--crmline-heightbodymd);letter-spacing:var(--crmletter-spacingtitle-md);text-align:left;text-underline-position:from-font;text-decoration-skip-ink:none}.crm-container-form{display:flex;flex-direction:column;justify-content:space-around;height:auto;padding:20px 24px 20px 24px;border:1px solid #CCCC;writing-mode:horizontal-tb;gap:16px;border-top:1px solid #ccc !important;border-bottom:1px solid #ccc !important}.crm-phone-form{display:flex;flex-direction:column;height:100%;gap:16px}.crm-subtitle{font-size:.875rem;line-height:1.25rem}.crm-title{font-weight:700;line-height:20px;color:#262626;}.crm-message-info{color:#619013;font-weight:500;}.crm-message-error{color:#E11D48;font-weight:500;}";const C=S;const j=class{constructor(i){t(this,i);this.crmBonusService=o.getInstance();this.storeName=undefined;this.cartId=undefined;this.products=undefined;this.customer=undefined;this.loadProducts=undefined;this.loadAll=undefined;this.customStyles=undefined;this.reservedInfo=undefined;this.value=undefined;this.loading=false;this.message=undefined;this.phone=undefined;this.pinInfo=undefined;this.step=h.STEP_RESERVE;this.bonus=undefined;this.sucess="";this.error="";this.config=undefined;this.hasApplyBonus=false;this.loadingAllComponent=false}async setStep(t){this.step=t}async processBonus(t=[],i=false){await this.loadProducts();this.sucess="";if(i){this.products=t}const e=localStorage.getItem(c(this.cartId));if(e){const t=JSON.parse(e);this.bonus=t;this.phone=t.phone;this.pinInfo={storeId:t.storeId,userId:t.userId};await this.validateBonus("2018")}}async handleSendPin(t){await this.loadAll();this.message="";if(!t){this.message="Informe seu telefone";return}this.phone=t;this.sendPin()}async componentWillLoad(){this.sucess="";this.error="";this.config=u(this.storeName);const t=this.getPhoneNumberAgain();if(t){this.step=h.STEP_PHONE;return}await this.processBonus()}getPhoneNumberAgain(){const t=localStorage.getItem(c(this.cartId));if(!t)return true;const i=JSON.parse(t);return!i.hasBonus}convertStringToNumber(){var t;const i=(t=this.phone)===null||t===void 0?void 0:t.replace(/\D/g,"");return Number(i)}async sendPin(){var t,i,e;this.loading=true;this.message="";this.sucess="";this.error="";try{const i=this.convertStringToNumber();const e=localStorage.getItem(`bc:${this.phone}`);if(!e){this.pinInfo=await this.crmBonusService.sendPin(i,(t=this.customer)===null||t===void 0?void 0:t.name,this.storeName)}if(e){const t=JSON.parse(e);this.pinInfo={storeId:t.storeId,userId:t.userId};await this.validateBonus("2018")}else{this.step=h.STEP_PIN}}catch(t){this.message=(e=(i=t===null||t===void 0?void 0:t.response)===null||i===void 0?void 0:i.data)===null||e===void 0?void 0:e.message}finally{this.loading=false}}changePhone(){this.sucess="";this.error="";this.step=h.STEP_PHONE}async validateBonus(t){var i,e,o,n,a,r,d,l,p,u,f,b;this.loadingAllComponent=true;await this.loadProducts();const g=localStorage.getItem(s);if(g=="dontUse"){this.step=h.STEP_RESERVE;return}this.loading=true;this.sucess="";this.error="";const m=((i=this.pinInfo)===null||i===void 0?void 0:i.storeId)||((o=(e=this.reservedInfo)===null||e===void 0?void 0:e.metadata)===null||o===void 0?void 0:o.storeId);const x=((n=this.pinInfo)===null||n===void 0?void 0:n.userId)||((r=(a=this.reservedInfo)===null||a===void 0?void 0:a.metadata)===null||r===void 0?void 0:r.userId);const y=(l=(d=this.reservedInfo)===null||d===void 0?void 0:d.metadata)===null||l===void 0?void 0:l.cellphone;const v={pin:t,cellphone:y||this.convertStringToNumber(),storeId:m.toString(),userId:x.toString(),checkoutId:this.cartId,checkoutProducts:this.products,name:(p=this.customer)===null||p===void 0?void 0:p.name,storeName:this.storeName};try{this.bonus=await this.crmBonusService.validatePinBonus(v);if(!this.bonus.hasBonus){localStorage.setItem(c(this.cartId),JSON.stringify(Object.assign(Object.assign({},this.bonus),{phone:this.phone})));this.loading=false;this.step=h.STEP_NO_BONUS;return}this.sucess="Código validado com sucesso!";localStorage.setItem(c(this.cartId),JSON.stringify(Object.assign(Object.assign({},this.bonus),{phone:this.phone})));localStorage.setItem(`bc:${this.phone}`,JSON.stringify(this.bonus));localStorage.setItem(s,"use");localStorage.setItem(this.cartId,this.bonus.bonusBalance.toString());this.updateMetadata({storeId:Number(m),userId:Number(x)},v.cellphone);console.log("RESERVE",this.bonus);this.step=h.STEP_RESERVE}catch(t){const i=(f=(u=t===null||t===void 0?void 0:t.response)===null||u===void 0?void 0:u.data)===null||f===void 0?void 0:f.response;const e=(b=t===null||t===void 0?void 0:t.response)===null||b===void 0?void 0:b.data;if(i&&i.includes("Pin")){this.error="Código inválido!"}else if([403,500].includes(e.statusCode)){this.error="ocorreu um error, atualize a pagina e tente novamente!"}else{this.error=i;this.step=h.STEP_NO_BONUS}}finally{this.loading=false;this.loadingAllComponent=false}}async updateMetadata(t,i){try{if(this.reservedInfo.isExpired()){console.log("[CRM:updateMetadata]");await d(this.storeName,this.cartId,{createdAt:Date.now(),url:window.location.href,storeId:t.storeId,userId:t.userId,cellphone:i});localStorage.removeItem("bc:time")}else{await d(this.storeName,this.cartId,{url:window.location.href,storeId:t.storeId,userId:t.userId,cellphone:i})}}catch(t){console.error("[CRMBONUS:updateMetadata]: ",t)}}handleCancel(){this.cancel()}async cancel(){this.message="";this.loading=true;try{await this.crmBonusService.cancel(this.cartId);localStorage.setItem(s,"dontUse");await this.updateMetadata({storeId:null,userId:null},null)}catch(t){this.message="Não consegui cancelar o bônus, tente novamente!"}finally{this.loading=false}}async reserveApply(t){this.loading=true;this.message="";try{await this.reserve(t)}catch(t){this.message="ocorreu um error ao solicitar a aplicação do bonus! tente novamente";this.step=h.STEP_NO_BONUS;localStorage.removeItem(this.cartId)}finally{this.loading=false}}async reserve(t){await this.crmBonusService.reserve({redeemedBonus:t,cartId:this.cartId,ticket:this.cartId,grossValue:Number(this.bonus.totalValue),storeName:this.storeName,storeId:this.bonus.storeId.toString(),userId:this.bonus.userId})}render(){return i("div",{key:"939a74f8d91ab9c880ffb2486967a7800a6d2ce6",class:"crm-container-form fbits-responsive-carrinho-desconto",style:this.customStyles},i("label",{key:"b51c241a72ae22911293ad3dd28190f22982c8cb",class:"crm-title"},this.config.giftbackTitle),this.error&&i("label",{key:"9ca50e050603ad594b3086c82f2a31e08d8dec12",class:"crm-message-error"},this.error),this.step===h.STEP_PHONE&&i("phone-form",{key:"ab8cd8263aaf2729f9af29937a40e029bf17193d",value:this.customer.phone,config:this.config,loading:this.loading,handlerSubmit:t=>this.handleSendPin(t)}),this.step===h.STEP_PIN&&i("pin-form",{key:"da1680e62073ae2a3656fcef4ec85ec8b8d862cf",config:this.config,phone:this.phone,cancel:()=>this.changePhone(),resend:()=>this.sendPin(),validate:t=>this.validateBonus(t),loading:this.loading},this.sucess&&i("p",{key:"72486a002bbcb2cfad2f8ab32fbdda1e8dff143e",class:"crm-message-info"},this.sucess),this.error&&i("p",{key:"dcddaee2dd0e7b6d50ef0377ae7a721ba5c8256c",class:"crm-message-error"},this.error)),this.step===h.STEP_RESERVE&&i("giftback-info",{key:"b237add0b03aa26f20bdf42264b01ad890670145",storeName:this.storeName,infoBonus:this.reservedInfo,config:this.config,loading:this.loading,cancel:()=>this.handleCancel(),bonus:this.bonus,reserve:()=>this.processBonus(),cartId:this.cartId}),this.step===h.STEP_NO_BONUS&&i("div",{key:"6583e51ae1988bd5c797665e3119eed3aeb7a354",class:"container-message"},p.t("noGiftback",{storename:this.config.giftbackTitle})))}};j.style=C;const A="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPg0KPHN2ZyB3aWR0aD0iODAwcHgiIGhlaWdodD0iODAwcHgiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCjxwYXRoIGQ9Ik0xMiAxNy43NUMxMi40MTQyIDE3Ljc1IDEyLjc1IDE3LjQxNDIgMTIuNzUgMTdWMTFDMTIuNzUgMTAuNTg1OCAxMi40MTQyIDEwLjI1IDEyIDEwLjI1QzExLjU4NTggMTAuMjUgMTEuMjUgMTAuNTg1OCAxMS4yNSAxMVYxN0MxMS4yNSAxNy40MTQyIDExLjU4NTggMTcuNzUgMTIgMTcuNzVaIiBmaWxsPSIjMUMyNzRDIi8+DQo8cGF0aCBkPSJNMTIgN0MxMi41NTIzIDcgMTMgNy40NDc3MiAxMyA4QzEzIDguNTUyMjggMTIuNTUyMyA5IDEyIDlDMTEuNDQ3NyA5IDExIDguNTUyMjggMTEgOEMxMSA3LjQ0NzcyIDExLjQ0NzcgNyAxMiA3WiIgZmlsbD0iIzFDMjc0QyIvPg0KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xLjI1IDEyQzEuMjUgNi4wNjI5NCA2LjA2Mjk0IDEuMjUgMTIgMS4yNUMxNy45MzcxIDEuMjUgMjIuNzUgNi4wNjI5NCAyMi43NSAxMkMyMi43NSAxNy45MzcxIDE3LjkzNzEgMjIuNzUgMTIgMjIuNzVDNi4wNjI5NCAyMi43NSAxLjI1IDE3LjkzNzEgMS4yNSAxMlpNMTIgMi43NUM2Ljg5MTM3IDIuNzUgMi43NSA2Ljg5MTM3IDIuNzUgMTJDMi43NSAxNy4xMDg2IDYuODkxMzcgMjEuMjUgMTIgMjEuMjVDMTcuMTA4NiAyMS4yNSAyMS4yNSAxNy4xMDg2IDIxLjI1IDEyQzIxLjI1IDYuODkxMzcgMTcuMTA4NiAyLjc1IDEyIDIuNzVaIiBmaWxsPSIjMUMyNzRDIi8+DQo8L3N2Zz4=";const T=".crm-tooltip-container {\r\n display: flex;\r\n\r\n & img {\r\n width: 16px;\r\n margin-left: 3px;\r\n position: relative;\r\n }\r\n}\r\n\r\n.crm-tooltip {\r\n position: relative;\r\n display: inline-block;\r\n}\r\n\r\n.crm-tooltip .tooltiptext {\r\n visibility: hidden;\r\n background-color: black;\r\n color: #fff;\r\n text-align: center;\r\n padding: 8px 12px;\r\n border-radius: 0px;\r\n position: absolute;\r\n z-index: 1;\r\n min-width: 271px;\r\n top: 100%;\r\n left: 50%;\r\n margin-left: -238px;\r\n}\r\n\r\n@container (max-width: 410px) {\r\n .crm-tooltip .tooltiptext {\r\n margin-left: -14px;\r\n }\r\n\r\n .crm-tooltip #crm-role-description {\r\n margin-left: -151px;\r\n }\r\n}\r\n\r\n@container (max-width: 250px) {\r\n .crm-tooltip .tooltiptext {\r\n margin-left: -201px;\r\n }\r\n}\r\n\r\n.crm-tooltip:hover .tooltiptext {\r\n visibility: visible;\r\n}";const z=T;const P=class{constructor(i){t(this,i);this.text=undefined;this.identity=undefined}render(){return i("div",{key:"01d82d0172ca5f0dbb0b8ea278b4a5d438c13dd5",class:"crm-tooltip-container crm-tooltip"},i("img",{key:"3b632cc38e8ff206402a2bfaadba9f9d2d747095",src:A}),i("span",{key:"08310e35ac945bda0e9356ecad8742698016f262",id:this.identity,class:"tooltiptext"},this.text))}};P.style=z;const U=":host{--text-color:#6D6D5F}.giftback-container{display:flex;flex-direction:column;gap:14px}h3{margin-bottom:8px;color:#333}.container-description{display:flex;align-items:center;gap:5px;margin:0 0 10px 0}.container-description p{font-weight:400;margin:0px}p{color:#000}.value-display h2{color:#6D6D5F;margin:16px 0}input[type='range']{width:100%;margin:12px 0;-webkit-appearance:none;background:#ddd;height:4px;border-radius:4px;outline:none;padding:3px 0px 3px 3px}input[type=\"range\"]::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:20px;height:20px;background:rgb(109, 109, 95);border-radius:50%;cursor:pointer}.options{margin:0px 0;display:flex;gap:10px;flex-direction:column}.options label{display:flex;margin:0px 0;color:#333;align-items:center}.options input[type='radio']{margin-right:8px;height:16px;width:16px}.options input[type='radio']{appearance:none;-webkit-appearance:none;margin-right:8px;width:16px;height:16px;border:2px solid #ddd;border-radius:50%;background-color:#fff;cursor:pointer;transition:all 0.3s;padding:0px}.options input[type='radio']:checked{border-color:#000;background-color:#FAFAFA;border:4px solid #000}.info-box{background-color:#f9f9f9;border:1px solid #e0e0e0;border-radius:4px;padding:8px;color:#262626;line-height:20px}.info-icon{cursor:pointer;color:#888}h3{margin-bottom:8px;color:#333}.slider-wrapper{position:relative;margin:21px 0px 0px 0px}.slider{width:100%;-webkit-appearance:none;background:#ddd;height:4px;border-radius:2px;outline:none}.slider::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:16px;height:16px;background:var(--text-color);border-radius:50%;cursor:pointer}.slider-value{position:absolute;top:-30px;font-weight:700;color:var(--text-color);transform:translateX(-50%);white-space:nowrap;}.options-option{display:flex}";const E=U;const O=class{constructor(i){t(this,i);this.usedValue=0;this.selectedOption="none";this.cartId=undefined;this.loading=false;this.bonus={totalBonus:0,cartId:"",minimumPurchase:0,bonusBalance:0,calculatedValue:0,firstValidityDate:"",totalValue:0};this.reserve=undefined;this.cancel=undefined;this.config=undefined;this.infoBonus=undefined;this.storeName=undefined;this.sliderPosition=0;this.sliderValuePosition=0;this.loadingTime=false}changedBonus(){this.updateBonus()}updateBonus(){this.usedValue=this.bonus.bonusBalance;this.buildPositionSlider(0,this.bonus.totalBonus)}componentWillLoad(){this.updateBonus();this.selectedOption=localStorage.getItem(s)}handleSliderChange(t){const i=t.target;this.usedValue=parseFloat(i.value);this.buildPositionSlider(parseFloat(i.min),parseFloat(i.max))}componentDidLoad(){var t;if(this.bonus){this._refIinputRange.value=(t=this.bonus)===null||t===void 0?void 0:t.bonusBalance.toString()}}buildPositionSlider(t,i){const e=i*.1;const o=(this.usedValue-t)/(i-t)*100;this.sliderPosition=o;this.sliderValuePosition=o+(this.usedValue<=e?10:0)}async handleOptionChange(t){this.selectedOption=t;localStorage.setItem(s,t);await d(this.storeName,this.cartId,Object.assign(Object.assign({},this.infoBonus.metadata),{createdAt:null}));switch(this.selectedOption){case"use":await this.reserve(this.usedValue);break;case"dontUse":await this.cancel();break}}showTime(){if(!this.infoBonus)return false;return!this.infoBonus.isExpired()}getTime(){var t,i;const e=new Date((i=(t=this.infoBonus)===null||t===void 0?void 0:t.metadata)===null||i===void 0?void 0:i.createdAt);const o=new Date(e);o.setMinutes(o.getMinutes()+6);return{createdAt:e,expiration:o}}async downtime(){await d(this.storeName,this.bonus.cartId,{createdAt:null})}render(){var t,e,o,s,n,a,r;console.log("this.bonus",this.bonus);const c=this.bonus.minimumPurchase-this.bonus.totalValue;const d=p.t("giftDescription",{amount:`${(e=(t=this.bonus)===null||t===void 0?void 0:t.totalBonus)===null||e===void 0?void 0:e.toFixed(2).replace(".",",")}`,custom_name:"Giftback"});const l=b(c);return i("div",{key:"baf90a1de29b3275c1c3cfd31f9d004ca3187a84",class:"giftback-container"},i("div",{key:"57af5fe5b40b3292a275065f577a9444470f8bf0",class:"container-description"},i("p",{key:"fff28c85077c36854f37d5f23f2908fa47197dac",innerHTML:d}),i("crm-tooltip",{key:"b66b1914dfa5e0806f85a9695840fdd4bd52d21e",identity:"crm-role-description",text:p.t("labelUseGiftback",{minimumPurchase:this.bonus.minimumPurchase,expírationDate:g(this.bonus.firstValidityDate)})})),i("div",{key:"e13afe9428744084443697df22048ac05b41ffd0",class:"slider-wrapper"},i("div",{key:"1826a50e4e1b474322dbb0020db0154fe9ed5b80",class:"slider-value",style:{left:`calc(${this.sliderValuePosition}% - 20px)`}},"R$ ",this.usedValue.toFixed(2).replace(".",",")),i("input",{key:"73b42919b8e4e0223dc8490a6190697d1975e96d",ref:t=>this._refIinputRange=t,id:"position_value_id",disabled:true,type:"range",min:"0",max:this.bonus.totalBonus,value:this.usedValue,class:"slider",step:"0.01",onInput:t=>this.handleSliderChange(t),style:{background:`linear-gradient(to right, #6D6D5F ${this.sliderPosition}%, #ddd ${this.sliderPosition}%)`}})),l.isComplete&&i("p",{key:"b9b853490c112bf3e98d14c2ceee25d0b7604983"},p.t("maxAmount")),!l.isComplete&&i("div",{key:"50b23f6c4bde42ca12b077a33f0ffbde25601e3d",class:"container-description"},i("p",{key:"73bfbcc779b8775aecc63050816909ba9120af3e"},"Adicione ",i("strong",{key:"6d5a2ea943a1d3eee80b0f4d0cdda159a300bb25"},"R$ ",c<0?"0,00":c.toFixed(2).replace(".",","))," ao carrinho para atingir o valor máximo!"),i("crm-tooltip",{key:"5a5bbbeb32abd51fbfb84c63d3e7a06f8d459ea0",identity:"crm-max-description",text:p.t("labelamountPartial")})),i("div",{key:"ea3f6aa8f4668b759b912bac36d9780e183a6180",class:"options"},i("div",{key:"6f7f70930c8cd97f1215301d823f8631d071b472",class:"options-option"},i("input",{key:"35b4f8380f34becd4dc94c1bcb1572c2b3401db8",disabled:this.showTime(),type:"radio",name:"giftbackOption",value:"use",checked:this.selectedOption==="use",onChange:()=>this.handleOptionChange("use")}),i("p",{key:"228beeb474e10a67811925bee00e5c1d0f5d64b6"},"Usar o meu ",(o=this.config)===null||o===void 0?void 0:o.giftbackTitle)),i("div",{key:"2a9ad1052f869057d5e36c3eba0cf1a24af88e1b",class:"options-option"},i("input",{key:"3cc3fae293fda510873f9c5f4d906308affca8e1",disabled:this.showTime(),type:"radio",name:"giftbackOption",value:"dontUse",checked:this.selectedOption==="dontUse",onChange:()=>this.handleOptionChange("dontUse")}),i("p",{key:"364f7de414a6f536680f849fe3efdee803d9a596"},"Não usar o meu ",(s=this.config)===null||s===void 0?void 0:s.giftbackTitle))),this.showTime()&&i("div",{key:"8fe525904208e2fc13ebd80615bbe7856cc2dc2c",class:"info-box"},"Após ",i("countdown-timer",{key:"3913bc9060980620654f03a987f62f628d6ee440",dataCriacao:new Date((a=(n=this.infoBonus)===null||n===void 0?void 0:n.metadata)===null||a===void 0?void 0:a.createdAt).toString(),downtime:()=>{window.location.reload()}}),", você poderá alterar sua escolha de usar ou não o Giftback."),!((r=this===null||this===void 0?void 0:this.infoBonus)===null||r===void 0?void 0:r.isBonusProcessed)&&i("div",{key:"aecd80b9920c8b483d38a1c24a6b38ce03d52b64",class:"info-box"},"O Giftback será aplicado na próxima etapa."))}static get watchers(){return{bonus:["changedBonus"]}}};O.style=E;const L=".loading-container{position:absolute;top:0;left:0;width:100%;height:100%;background-color:rgba(0, 0, 0, 0.5);display:flex;justify-content:center;align-items:center;z-index:1000;flex-direction:column;}.loading-container p{margin:6px 0px;color:white;font-size:large}.loading-spinner{width:40px;height:40px;border:5px solid rgba(255, 255, 255, 0.3);border-top:5px solid white;border-radius:50%;animation:spin 1s linear infinite;}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.relative-xy{position:relative}";const B=L;const R=class{constructor(i){t(this,i);this.loading=true;this.text=null}render(){return i("div",{key:"5e323e6b562ee4d770bb2c9f786a23d6b47ce06e",class:"relative-xy"},this.loading&&i("div",{key:"31183c82285ec32c7de0348885d0fd30e4a82502",class:"loading-container"},i("div",{key:"1de235c7594a15e822d044364de0700d3c9e1fa4",class:"loading-spinner"}),this.text&&i("p",{key:"82daa6b96a1e14d83be2fc22fd879b3a41896d0e"},this.text)),i("slot",{key:"09c654783fde15f7b34c4a0804fcec07cfa28b30"}))}};R.style=B;const V=".spinner{display:inline-block;border:4px solid transparent;border-radius:50%;border-top-color:var(--color, #0078d7);animation:spin 1s linear infinite}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}";const F=V;const G=class{constructor(i){t(this,i);this.size="50px";this.color="#0078d7"}render(){return i("div",{key:"e1916d264937b0470cd5b1581c87184061b40c3a",class:"spinner",style:{width:this.size,height:this.size,borderColor:`${this.color} transparent transparent transparent`}})}};G.style=F;const $="*{margin:0;padding:0;box-sizing:border-box}:host{--crmfont-sizebodymd:14px;--crmline-heightbodymd:20px;--crmletter-spacingtitle-md:0px}.container-message{font-weight:400;line-height:var(--crmline-heightbodymd);letter-spacing:var(--crmletter-spacingtitle-md);text-align:left;text-underline-position:from-font;text-decoration-skip-ink:none}.crm-container-form{display:flex;flex-direction:column;justify-content:space-around;height:auto;padding:20px 24px 20px 24px;border:1px solid #CCCC;writing-mode:horizontal-tb;gap:16px;border-top:1px solid #ccc !important;border-bottom:1px solid #ccc !important}.crm-phone-form{display:flex;flex-direction:column;height:100%;gap:16px}.crm-subtitle{font-size:.875rem;line-height:1.25rem}.crm-title{font-weight:700;line-height:20px;color:#262626;}.crm-message-info{color:#619013;font-weight:500;}.crm-message-error{color:#E11D48;font-weight:500;}";const Q=$;const W=class{constructor(i){t(this,i);this.value=undefined;this.loading=undefined;this.handlerSubmit=undefined;this.config=undefined}async handlePhone(){const t=await this.phoneInputMask.getPhone();await this.handlerSubmit(t)}render(){var t;return i(e,{key:"b27f64d8464d4c6b259d2d5f0113f55a6f809afb",class:"crm-phone-form"},i("p",{key:"6f279841f43cd7f70f7a1b5340288b9c2d11c551",class:"crm-subtitle"},"Digite o seu celular para verificar se há desconto disponível nessa compra:"),i("phone-input-mask",{key:"7e86f63998a4f35d134b8f4e867a5e5c0b9df20a",initialValue:this.value,ref:t=>this.phoneInputMask=t}),i("crm-button",{key:"462b7cc91f166c8fc588a5c922ba943a6715dca5",txtBtn:((t=this.config)===null||t===void 0?void 0:t.btnApplyBonusLabel)||"Avançar",loading:this.loading,handleClick:()=>this.handlePhone()}))}};W.style=Q;const Z="*{margin:0;padding:0;box-sizing:border-box}.phone{display:block;width:100%;height:24px;padding:6px 12px;line-height:1.42857143;color:#555;background-color:#fff;background-image:none;border:1px solid #ccc;border-radius:0px;-webkit-box-shadow:inset 0 1px 1px rgba(0, 0, 0, .075);box-shadow:inset 0 1px 1px rgba(0, 0, 0, .075);-webkit-transition:border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s;-o-transition:border-color ease-in-out .15s, box-shadow ease-in-out .15s;transition:border-color ease-in-out .15s, box-shadow ease-in-out .15s}.phone-input-form{width:100%;height:48px;padding:13px 16px 13px 16px;border:1px solid #CCCCCC;}.crm-erro-msg{color:#E11D48;font-weight:500;margin-top:11px}";const _=Z;const J=class{constructor(i){t(this,i);this.phone="";this.message="";this.initialValue=undefined;this.disabled=undefined}componentWillLoad(){this.phone=this.initialValue}formatPhone(t){const i=t.replace(/\D/g,"");const e=i.match(/^(\d{0,2})(\d{0,5})(\d{0,4})$/);if(!e)return t;const o=e[1]?`(${e[1]}`:"";const s=e[2]?`) ${e[2]}`:"";const n=e[3]?` ${e[3]}`:"";return`${o}${s}${n}`}handleInput(t){const i=t.target;this.phone=this.formatPhone(i.value);if(!this.validatePhoneNumber(i.value)){this.message=f}else{this.message=""}console.log("phone",this.phone)}validatePhoneNumber(t){if(t.length<15){return true}const i=/^\(\d{2}\) \d{5} \d{4}$/;return i.test(t)}async getPhone(){return this.phone}render(){return i("div",{key:"bbb0389d0a7ccb8651b8ee20e92dd4cdc94e3617"},i("input",{key:"b36cc9e65314cb786c7f94fee6b4992ba30a82e6",disabled:this.disabled,id:"phone",type:"text",class:"phone-input-form",value:this.phone,onInput:t=>this.handleInput(t),placeholder:"(99) 99999 9999"}),i("p",{key:"81e48cda38cd9a8fc7d753d269425bd4288c57b1",class:"crm-erro-msg"},this.message))}};J.style=_;const H=":host{display:block}.form-container-pin{display:flex;flex-direction:column;align-items:center}.pin-container{display:flex;justify-content:start;gap:10px}.pin-container input{width:100%;height:48px;text-align:center;border:1px solid #ccc;border-radius:5px}button{padding:10px 20px;background-color:#ddd;border:none;border-radius:5px;cursor:pointer}.success{color:green;margin-top:10px}.button{top:50%;background-color:#6c6c7e;color:#fff;border:none;border-radius:10px;padding:15px;min-height:30px;min-width:120px;cursor:pointer}.button-cancel{top:50%;background-color:#ffffff;color:#1e1c1c;border:1px solid gray;border-radius:10px;padding:10px;min-height:30px;min-width:120px;cursor:pointer}.crm-description{width:100%;display:flex;gap:9px;flex-wrap:wrap}.crm-description a{font-weight:bold;cursor:pointer;text-decoration:underline}.crm-description div{display:flex;gap:5px}";const X=H;const Y="*{margin:0;padding:0;box-sizing:border-box}:host{--crmfont-sizebodymd:14px;--crmline-heightbodymd:20px;--crmletter-spacingtitle-md:0px}.container-message{font-weight:400;line-height:var(--crmline-heightbodymd);letter-spacing:var(--crmletter-spacingtitle-md);text-align:left;text-underline-position:from-font;text-decoration-skip-ink:none}.crm-container-form{display:flex;flex-direction:column;justify-content:space-around;height:auto;padding:20px 24px 20px 24px;border:1px solid #CCCC;writing-mode:horizontal-tb;gap:16px;border-top:1px solid #ccc !important;border-bottom:1px solid #ccc !important}.crm-phone-form{display:flex;flex-direction:column;height:100%;gap:16px}.crm-subtitle{font-size:.875rem;line-height:1.25rem}.crm-title{font-weight:700;line-height:20px;color:#262626;}.crm-message-info{color:#619013;font-weight:500;}.crm-message-error{color:#E11D48;font-weight:500;}";const K=Y;const q=class{constructor(i){t(this,i);this.validate=undefined;this.cancel=undefined;this.resend=undefined;this.sent=undefined;this.loading=false;this.phone=undefined;this.config=undefined;this.pin=["","","",""];this.isVerified=false;this.canResend=false}componentWillLoad(){this.canResend=false}handleInput(t,i){const e=t.target;const o=e.value.slice(0,1);this.pin[i]=o;if(o&&i<this.pin.length-1){const t=e.nextElementSibling;t===null||t===void 0?void 0:t.focus()}this.pin=[...this.pin]}validatePin(){localStorage.removeItem("bc:resend");this.validate(this.pin.join(""))}verifyPin(){const t=this.pin.join("");if(t==="9999"){this.isVerified=true}}handleTimeout(){localStorage.removeItem("bc:resend");this.canResend=true}async handleResend(){await this.resend();this.canResend=false;this.pin=["","","",""];localStorage.removeItem("bc:resend")}buildTime(){const t=localStorage.getItem("bc:resend");if(t){return t}const i=new Date;i.setSeconds(i.getSeconds()+30);localStorage.setItem("bc:resend",i.toString());return i.toString()}render(){var t;return i("div",{key:"3f60e4c74c925daf656092812f40ae0d1f3b5a99",class:"crm-phone-form"},i("label",{key:"d0c023e22ff7eb8978ee6cc0ca4ced8192c53c20",class:"crm-subtitle"},p.t("pin-sutitle")," ",i("strong",{key:"05bb0e2493c99abaa29031a7cc787260266bb417"},"+55 ",this.phone)),i("div",{key:"24c8eb55625f3b880741086c66decd96ecf40044",class:"pin-container"},this.pin.map(((t,e)=>i("input",{type:"text",maxLength:1,value:this.pin[e],onInput:t=>this.handleInput(t,e)})))),i("slot",{key:"02276aa80396d16f779a92a381e75506fa37d56d"}),i("p",{key:"27af068858b3ead8a70b8ec961d367c7beb04d94",class:"crm-description"}," Não recebeu?",!this.canResend&&i("label",{key:"8ef93baf6f92142292078e5e4bcc125ff12b80d7"}," Reenviar em",i("countdown-timer",{key:"f3a0c60c7a88229e37add445886c44b00c60913f",minutos:0,segundos:30,dataCriacao:this.buildTime(),downtime:()=>this.handleTimeout()})," "),this.canResend&&i("div",{key:"2d1b5b028a7085d912acb0d0c696436e8aa75a29"},i("a",{key:"ad9aea2c6f167f1270c75b8dbd2ee79879f7567d",onClick:()=>this.handleResend()},"Reenviar"),i("a",{key:"b0734ab0e472c5cf24fa083c0a712e4f29cf8d79",onClick:()=>this.cancel()},"Trocar número"))),i("crm-button",{key:"39095211d007c871f48971509c3ff52b0f257c29",txtBtn:((t=this.config)===null||t===void 0?void 0:t.btnApplyBonusLabel)||"Avançar",loading:this.loading,handleClick:()=>this.validatePin()}))}};q.style=X+K;export{m as countdown_timer,I as crm_bonus,D as crm_button,j as crm_giftback_form,P as crm_tooltip,O as giftback_info,R as loading_container,G as loading_spinner,W as phone_form,J as phone_input_mask,q as pin_form};
|
2
|
-
//# sourceMappingURL=p-5d014ac9.entry.js.map
|