PageSourceSearch

https://app.stoqui.com.br/assets/BrandScreen-BQN8vLZH.js

js stoqui.com.br collected 2026-10-01 15:18:16 UTC 9,911 bytes, 1 lines download raw bytes

1import{j as e,a7 as t,ad as N,a6 as ie,I as P,T as v,X as Z,ai as K,Z as Y,O as J,N as U,ab as ne}from"./mui-CRsYZxVY.js";import{r as a}from"./vendor-Dwao9eNC.js";import{dM as le,aG as V,t as ce,l as de,y as pe,z as ue,b as fe,C as ge,cZ as me,D as he,bf as xe,F as be}from"./index-TALscxEc.js";import{z as H,e as Q,D as Ce,b as ye}from"./icons-D8aatgQ4.js";import{S as je}from"./SettingsScreenLayout-BWFwVJu5.js";import{u as we}from"./useWebCatalogSettingsSave-Byg91ItV.js";import{g as $}from"./colorUtils-BVXQm18B.js";import{F as B,C as G}from"./appearanceTokens-DaF_sGil.js";import"./query-8ViTdhdk.js";import"./datePickers-BIJXYOKG.js";import"./lab-DSem1Osk.js";import"./UnsavedChangesDialog-gqy_t4YT.js";(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};i.SENTRY_RELEASE={id:"2ad85febf9735404429b0670d4acf56a0af5a0a2"}}catch{}})();try{(function(){var i=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},r=new i.Error().stack;r&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[r]="5a89465a-29b7-4424-bd2f-949006e292a6",i._sentryDebugIdIdentifier="sentry-dbid-5a89465a-29b7-4424-bd2f-949006e292a6")})()}catch{}const ve=5*1024*1024,Se=({imageUrl:i,onImageChange:r,onImageUpload:I})=>{const[m,u]=a.useState(i),[F,L]=a.useState(!1),[h,c]=a.useState(!1),[d,y]=a.useState(!1),[C,j]=a.useState(null),[S,E]=a.useState(!1),D=le(),k=l=>{const s=new Image;s.onload=()=>{const x=s.width/s.height;L(x<1.7)},s.src=l};a.useEffect(()=>{m&&k(m)},[m]);const A=async l=>{var x;const s=(x=l.target.files)==null?void 0:x[0];if(s){if(s.size>ve){c(!0),ce(de.REGISTRATION.LOGO_UPLOAD_ERROR,{errorMessage:"Logo file size exceeds 5MB limit",errorCode:"size_limit_exceeded",fileName:s.name,fileSize:s.size,fileType:s.type,stage:"web_catalog_form",timestamp:new Date().toISOString()});return}c(!1),j(null),y(!0);try{const f=await D.mutateAsync(s);u(f),I&&I(f),r(s)}catch(f){console.error("Logo upload failed:",f);const R=f instanceof Error?f.message:"Erro ao fazer upload do logo";if(j(R),R.includes("Formato de arquivo não suportado"))return;const w=s.type.toLowerCase();if(w.includes("jpeg")||w.includes("jpg")||w.includes("png")||w.includes("webp")){const T=URL.createObjectURL(s);u(T),r(s)}}finally{y(!1)}}},O=l=>{l.stopPropagation(),l.preventDefault(),u(""),L(!1),c(!1),j(null),r(null)};return e.jsxs(t,{sx:{width:"100%",...h&&{"& .image-container":{borderColor:"warning.main",boxShadow:"0 0 0 1px warning.main"}}},children:[h&&e.jsx(V.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},children:e.jsx(N,{severity:"warning",sx:{mb:2},onClose:()=>c(!1),children:"A imagem excede o limite de 5MB. Escolha uma imagem menor ou continue sem logo. Você poderá adicionar ou alterar o logotipo depois."})}),C&&e.jsx(V.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},children:e.jsx(N,{severity:"error",sx:{mb:2},onClose:()=>j(null),children:C})}),e.jsxs(t,{display:"flex",justifyContent:"center",alignItems:"center",className:"image-container",sx:{width:"100%",height:120,cursor:d?"wait":"pointer",border:"1px solid #ddd",borderRadius:1,backgroundColor:"white",position:"relative",padding:1,transition:"all 0.2s ease",borderColor:h?"warning.main":"#ddd"},children:[e.jsx("input",{type:"file",accept:"image/jpeg,image/jpg,image/png,image/webp,image/heic,image/heif,.jpg,.jpeg,.png,.webp,.heic,.heif",style:{display:"none"},id:"image-upload",onChange:A,disabled:d}),e.jsxs("label",{htmlFor:"image-upload",style:{width:"100%",height:"100%"},children:[m&&!h?e.jsxs(t,{sx:{position:"relative",width:"100%",height:"100%"},children:[e.jsx(t,{component:"img",src:m,alt:"Image Preview",sx:{width:"100%",height:"100%",objectFit:"contain",borderRadius:1,opacity:d?.5:1}}),d&&e.jsx(t,{sx:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)"},children:e.jsx(ie,{size:24})}),F&&e.jsx(P,{size:"small",onClick:l=>{l.preventDefault(),l.stopPropagation(),E(!0)},sx:{position:"absolute",top:8,left:8,backgroundColor:"rgba(255, 184, 46, 0.9)",color:"white",width:24,height:24,"&:hover":{backgroundColor:"#FFB82E"}},children:e.jsx(H,{sx:{fontSize:16}})})]}):e.jsxs(t,{display:"flex",alignItems:"center",justifyContent:"center",sx:{width:"100%",height:"100%",backgroundColor:"#f5f5f5",border:"1px dashed #ddd",borderRadius:1,padding:5},children:[e.jsx(Q,{sx:{fontSize:48,color:"#bbb"}}),e.jsxs(t,{children:[e.jsx(v,{variant:"body2",color:"text.secondary",fontWeight:"bold",children:"Adicionar logotipo"}),e.jsx(v,{variant:"caption",color:"text.secondary",children:"Tamanho recomendado: 300x100px (máx. 5MB)"})]})]}),m&&!h&&!d&&e.jsxs(t,{sx:{position:"absolute",bottom:0,right:0,display:"flex",gap:.5,padding:1,backgroundColor:"rgba(255, 255, 255, 0.8)",borderRadius:1},children:[e.jsx(P,{size:"small",onClick:O,children:e.jsx(Ce,{fontSize:"small"})}),e.jsx(P,{size:"small",component:"span",children:e.jsx(ye,{fontSize:"small"})})]})]})]}),e.jsxs(Z,{open:S,onClose:()=>E(!1),maxWidth:"sm",fullWidth:!0,children:[e.jsxs(K,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(H,{sx:{color:"#FFB82E"}}),"Proporção da imagem"]}),e.jsx(Y,{children:e.jsx(v,{variant:"body2",color:"text.secondary",children:"Esta imagem pode parecer muito pequena ou não se encaixar bem. Sugerimos usar uma imagem mais larga, idealmente 300x100px."})}),e.jsx(J,{children:e.jsx(U,{onClick:()=>E(!1),children:"Entendi"})})]})]})},X=1.5,ee=["#212121","#424242","#455A64","#0B0B45","#3F51B5","#5E6638","#795548","#880E4F","#C30010","#FF4F00","#FF6F61","#FF9800","#FFC107","#CDDC39","#E75480","#9C27B0","#6546CF","#4CAF50","#8BC34A","#009688","#00BCD4","#2196F3"],Ee=pe({cor_principal:ue().matches(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"Cor inválida").required("Cor principal obrigatória")}),W=i=>ee.some(r=>r.toUpperCase()===i.toUpperCase()),Ue=()=>{const i=fe(),{catalog:r,isLoading:I,save:m}
1=we(),[u,F]=a.useState(!1),[L,h]=a.useState(null),[c,d]=a.useState(null),[y,C]=a.useState(!1),[j,S]=a.useState(!1),{control:E,handleSubmit:D,reset:k,setValue:A,formState:{errors:O,isDirty:l}}=ge({resolver:be(Ee),defaultValues:{cor_principal:B}}),s=r==null?void 0:r.id,x=(r==null?void 0:r.cor_principal)||B,[f,R]=a.useState(()=>x&&!W(x)?x.toUpperCase():null);a.useEffect(()=>{const o=(r==null?void 0:r.cor_principal)||B;k({cor_principal:o}),d(null),C(!1),R(o&&!W(o)?o.toUpperCase():null)},[s]);const w=l||!!c||y,T=a.useRef(null),oe=()=>{var n;const o=(n=T.current)==null?void 0:n.querySelector(".MuiColorInput-Button");o==null||o.click()},z=a.useRef(null),_=a.useRef(null),re=()=>new Promise((o,n)=>{D(async b=>{if($(b.cor_principal,"#ffffff")<X){z.current=o,_.current=n,S(!0);return}await M(b,o,n)},()=>n(new Error("validation failed")))()}),M=async(o,n,b)=>{h(null),F(!0);try{const g={cor_principal:o.cor_principal};y&&!c?g.logo_url=null:c&&(g.logo_url=c),await m(g,"appearance_brand"),k(o),d(null),C(!1),n()}catch(g){h("Não foi possível salvar. Tente novamente."),b(g instanceof Error?g:new Error("save failed"))}finally{F(!1)}},se=()=>re(),ae=()=>{S(!1),D(async o=>{const n=z.current,b=_.current;z.current=null,_.current=null,!(!n||!b)&&await M(o,n,b)})()},q=()=>{S(!1);const o=_.current;z.current=null,_.current=null,o==null||o(new Error("low contrast cancelled"))};return e.jsxs(je,{title:"Logo e cor",isLoading:I,isDirty:w,isSaving:u,onSave:se,saveError:L,children:[e.jsxs(ne,{spacing:2,children:[e.jsxs(t,{sx:G,children:[e.jsx(v,{variant:"body1",sx:{fontWeight:600,mb:1.5},children:"Logo"}),e.jsx(U,{fullWidth:!0,variant:"contained",startIcon:e.jsx(me,{}),onClick:()=>i("/profile/store-appearance/brand/ai-logo"),sx:{mb:1.5,borderRadius:2,py:1.25},children:"Criar logo com IA"}),e.jsx(Se,{imageUrl:y?"":c??(r==null?void 0:r.logo_url)??"",onImageChange:o=>{o===null&&(C(!0),d(null))},onImageUpload:o=>{d(o),C(!1)}})]}),e.jsxs(t,{sx:G,children:[e.jsx(v,{variant:"body1",sx:{fontWeight:600,mb:1.5},children:"Cor principal"}),e.jsx(he,{name:"cor_principal",control:E,render:({field:o})=>{const n=(o.value||"").toUpperCase(),g=$(o.value||B,"#ffffff")<X;return e.jsxs(t,{children:[e.jsxs(t,{sx:{display:"grid",gridTemplateColumns:"repeat(6, 1fr)",gap:1},children:[[...ee,...f?[f]:[]].map(p=>{const te=n===p.toUpperCase();return e.jsx(t,{onClick:()=>!u&&A("cor_principal",p,{shouldDirty:!0,shouldValidate:!0}),sx:{height:40,borderRadius:1,backgroundColor:p,cursor:u?"default":"pointer",position:"relative","&::after":te?{content:'""',position:"absolute",inset:0,borderRadius:"inherit",border:"2px solid white",outline:`2px solid ${p}`,outlineOffset:"0px",pointerEvents:"none"}:{}}},p)}),e.jsx(t,{onClick:()=>!u&&oe(),sx:{height:40,borderRadius:1,bgcolor:"#f5f5f5",cursor:u?"default":"pointer",display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed",borderColor:"divider"},children:e.jsx(Q,{sx:{fontSize:20,color:"text.secondary"}})})]}),e.jsx(t,{ref:T,sx:{position:"absolute",width:0,height:0,overflow:"hidden"},children:e.jsx(xe,{value:o.value,onChange:p=>{A("cor_principal",p,{shouldDirty:!0,shouldValidate:!0}),p&&!W(p)&&R(p.toUpperCase())},format:"hex"})}),O.cor_principal&&e.jsx(v,{variant:"caption",color:"error",sx:{display:"block",mt:1},children:O.cor_principal.message}),g&&e.jsx(N,{severity:"warning",sx:{mt:2},children:"Essa cor é muito clara e pode ficar difícil de ler sobre o fundo branco da sua loja. Considere escolher uma cor mais escura."})]})}})]})]}),e.jsxs(Z,{open:j,onClose:q,PaperProps:{sx:{mx:2,width:"100%"}},children:[e.jsx(K,{children:"Cor com pouco contraste"}),e.jsx(Y,{children:"A cor escolhida é muito clara e pode ficar difícil de ler sobre o fundo branco da sua loja. Tem certeza que deseja usar essa cor?"}),e.jsxs(J,{sx:{px:2,pb:2,gap:1},children:[e.jsx(U,{onClick:q,color:"primary",children:"Escolher outra cor"}),e.jsx(U,{onClick:ae,color:"primary",variant:"contained",children:"Usar mesmo assim"})]})]})]})};export{Ue 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.