1import{j as o,a7 as s,T as h,X as z,ai as G,Z as K,O as U,N as j,ab as k,z as Y,S as Z}from"./mui-CRsYZxVY.js";import{r as _}from"./vendor-Dwao9eNC.js";import{y as J,z as R,e as Q,x as oo,C as eo,D as A,F as ao}from"./index-TALscxEc.js";import{S as ro}from"./SettingsScreenLayout-BWFwVJu5.js";import{u as to}from"./useWebCatalogSettingsSave-Byg91ItV.js";import{c as io}from"./colorUtils-BVXQm18B.js";import{P as so}from"./PromoStripColorPicker-Cz54nEaL.js";import{F as no,C as I}from"./appearanceTokens-DaF_sGil.js";import"./query-8ViTdhdk.js";import"./datePickers-BIJXYOKG.js";import"./icons-D8aatgQ4.js";import"./lab-DSem1Osk.js";import"./UnsavedChangesDialog-gqy_t4YT.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};e.SENTRY_RELEASE={id:"2ad85febf9735404429b0670d4acf56a0af5a0a2"}}catch{}})();try{(function(){var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},r=new e.Error().stack;r&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[r]="a11cccb3-2e76-4c6d-a1d7-25d13fabde66",e._sentryDebugIdIdentifier="sentry-dbid-a11cccb3-2e76-4c6d-a1d7-25d13fabde66")})()}catch{}const lo=({text:e,backgroundColor:r,className:i})=>{if(!e)return null;const x=r||"#000000",b=io(x);return o.jsx(s,{className:i,sx:{width:"100%",backgroundColor:x,color:b,py:1,px:2,textAlign:"center",borderRadius:0,overflow:"hidden"},children:o.jsx(h,{variant:"body2",sx:{fontWeight:700,fontSize:"0.875rem",wordBreak:"break-word"},children:e})})},co=({open:e,onConfirm:r,onCancel:i})=>o.jsxs(z,{open:e,onClose:i,PaperProps:{sx:{mx:2,width:"100%",borderRadius:2}},children:[o.jsx(G,{sx:{fontWeight:600},children:"Desativar faixa?"}),o.jsx(K,{children:o.jsx(h,{variant:"body2",color:"text.secondary",children:"A faixa some do topo da sua loja. Você pode ativar de novo a qualquer momento escrevendo uma nova mensagem."})}),o.jsxs(U,{sx:{px:2,pb:2,gap:1},children:[o.jsx(j,{onClick:i,children:"Cancelar"}),o.jsx(j,{onClick:r,color:"error",variant:"contained",sx:{borderRadius:2},children:"Desativar"})]})]}),l=75,xo="Sua mensagem aparece aqui",po=["ð¥ Frete grátis acima de R$ 200","â¡ 10% off no PIX","ð Cupom BEMVINDO no checkout","ð¦ Entrega em todo o Brasil","â° Só hoje: descontos especiais"],fo=J({faixa_promocional_texto:R().nullable().max(l,`Máximo de ${l} caracteres`),faixa_promocional_cor:R().nullable().matches(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,{message:"Cor inválida",excludeEmptyString:!0})}),Po=()=>{var P;const{catalog:e,isLoading:r,save:i}=to(),{data:x}=Q(),b=oo(x),[c,p]=_.useState(!1),[L,f]=_.useState(null),[B,g]=_.useState(!1),W=e==null?void 0:e.id,n=(e==null?void 0:e.cor_principal)||no,{control:w,handleSubmit:F,reset:v,watch:D,setValue:y,formState:{errors:S,isDirty:E}}=eo({resolver:ao(fo),defaultValues:{faixa_promocional_texto:"",faixa_promocional_cor:""}});_.useEffect(()=>{e&&v({faixa_promocional_texto:e.faixa_promocional_texto||"",faixa_promocional_cor:e.faixa_promocional_cor||n})},[W]);const m=D("faixa_promocional_texto")||"",O=D("faixa_promocional_cor")||"",N=m.trim().length>0?m:xo,V=O||n,X=!!((P=e==null?void 0:e.faixa_promocional_texto)!=null&&P.trim())&&!E,$=a=>{const t=a.slice(0,l);y("faixa_promocional_texto",t,{shouldDirty:!0,shouldValidate:!0})},H=()=>new Promise((a,t)=>{F(async u=>{f(null),p(!0);try{const d=(u.faixa_promocional_texto||"").trim(),C={faixa_promocional_texto:d,faixa_promocional_cor:d?u.faixa_promocional_cor||n:null};await i(C,"appearance_promo_strip"),v({faixa_promocional_texto:C.faixa_promocional_texto,faixa_promocional_cor:C.faixa_promocional_cor||n}),a()}catch(d){f("Não foi possÃvel salvar. Tente novamente."),t(d instanceof Error?d:new Error("save failed"))}finally{p(!1)}},()=>t(new Error("validation failed")))()}),M=async()=>{g(!1),y("faixa_promocional_texto","",{shouldDirty:!0,shouldValidate:!0});try{f(null),p(!0),await i({faixa_promocional_texto:"",faixa_promocional_cor:null},"appearance_promo_strip_disable"),v({faixa_promocional_texto:"",faixa_promocional_cor:n})}catch{f("Não foi possÃvel desativar a faixa. Tente novamente.")}finally{p(!1)}},T=!r&&!b?{plan:"pro",trigger:"promo_strip"}:void 0,q=!!T;return o.jsxs(ro,{title:"Faixa promocional",isLoading:r,isDirty:E,isSaving:c,onSave:H,saveError:L,lock:T,children:[o.jsxs(k,{spacing:2,children:[o.jsx(lo,{text:N,backgroundColor:V}),o.jsx(s,{children:o.jsxs(k,{spacing:2,children:[o.jsxs(s,{sx:I,children:[o.jsx(A,{name:"faixa_promocional_texto",control:w,render:({field:a})=>{var t;return o.jsx(Y,{...a,value:a.value??"",label:"Texto da faixa",placeholder:"Ex: 10% off no PIX",fullWidth:!0,multiline:!0,minRows:2,maxRows:4,disabled:c,error:!!S.faixa_promocional_texto,helperText:(t=S.faixa_promocional_texto)==null?void 0:t.message,inputProps:{maxLength:l},InputLabelProps:{shrink:!0}})}}),o.jsxs(h,{variant:"caption",color:m.length>
1=l?"error.main":"text.secondary",sx:{display:"block",textAlign:"right",mt:.5,pr:.5},children:[m.length.toLocaleString("pt-BR")," /"," ",l.toLocaleString("pt-BR")]}),o.jsxs(s,{sx:{mt:1.5},children:[o.jsx(h,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.75,fontWeight:600},children:"Sugestões"}),o.jsx(s,{sx:{display:"flex",flexWrap:"wrap",gap:.75},children:po.map(a=>o.jsx(Z,{label:a,onClick:()=>$(a),disabled:c,sx:{bgcolor:"grey.50",fontWeight:500,"&:hover":{bgcolor:"grey.100"}}},a))})]})]}),o.jsx(s,{sx:I,children:o.jsx(A,{name:"faixa_promocional_cor",control:w,render:({field:a})=>{var t;return o.jsx(so,{brandColor:n,value:a.value||"",onChange:u=>y("faixa_promocional_cor",u,{shouldDirty:!0,shouldValidate:!0}),disabled:c,errorMessage:(t=S.faixa_promocional_cor)==null?void 0:t.message})}})}),X&&!q&&o.jsx(s,{sx:{px:.5},children:o.jsx(j,{fullWidth:!0,color:"error",onClick:()=>g(!0),disabled:c,sx:{borderRadius:2,py:1.25,fontWeight:600},children:"Desativar faixa"})})]})})]}),o.jsx(co,{open:B,onConfirm:M,onCancel:()=>g(!1)})]})};export{Po as default};
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.