1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1119],{71738:(e,t,r)=>{r.d(t,{A:()=>h});var a=r(95155),n=r(12115),o=r(65229),i=r(71629),s=r(34904),l=r(97624),c=r(37354),d=r(48314),u=r(5917);function h(e){let{file:t,aspectRatio:r=1,fitMode:h,minScale:m=.1,maxScale:p=5,title:g="Ajustar imagem",description:x="Arraste a imagem para reposicionar. Use o zoom para aproximar ou afastar. A \xe1rea clara \xe9 o que ser\xe1 salvo.",confirmLabel:w="Confirmar",previewLabel:f="Preview final",showPreview:v=!0,outputWidth:b,outputHeight:y,outputMimeType:j="image/jpeg",onConfirm:k,onCancel:N}=e,R=(0,n.useMemo)(()=>URL.createObjectURL(t),[t]),[E,M]=(0,n.useState)({w:0,h:0}),[L,U]=(0,n.useState)({w:1,h:1}),[z,C]=(0,n.useState)(!1),[S,O]=(0,n.useState)(1),[P,W]=(0,n.useState)({x:0,y:0}),[A,_]=(0,n.useState)(!1),H=(0,n.useRef)(null),q=(0,n.useRef)(null),T=(0,n.useRef)(null),F=(0,n.useRef)(null),I=(0,n.useRef)(null),B=(0,n.useMemo)(()=>{if(!r)return{w:L.w,h:L.h};if(L.w/L.h>r){let e=.9*L.h;return{w:e*r,h:e}}let e=.9*L.w;return{w:e,h:e/r}},[r,L]),D=(0,n.useMemo)(()=>E.w&&E.h&&B.w&&B.h?Math.min(B.w/E.w,B.h/E.h):1,[E,B]),V=(0,n.useMemo)(()=>({w:E.w*D*S,h:E.h*D*S}),[E,D,S]);(0,n.useEffect)(()=>{let e=()=>{q.current&&U({w:q.current.clientWidth||1,h:q.current.clientHeight||1})};e();let t=new ResizeObserver(e);return q.current&&t.observe(q.current),()=>t.disconnect()},[]),(0,n.useEffect)(()=>()=>URL.revokeObjectURL(R),[R]);let X=(0,n.useCallback)(e=>{if(!A||!H.current)return;let t=e.clientX-H.current.mx,r=e.clientY-H.current.my;W({x:H.current.px+t,y:H.current.py+r})},[A]),Y=()=>_(!1),Q={position:"absolute",left:"calc(50% + ".concat(P.x,"px)"),top:"calc(50% + ".concat(P.y,"px)"),width:"".concat(V.w,"px"),height:"".concat(V.h,"px"),transform:"translate(-50%, -50%)",pointerEvents:"none",userSelect:"none",maxWidth:"none"},$={position:"absolute",left:"50%",top:"50%",width:"".concat(B.w,"px"),height:"".concat(B.h,"px"),transform:"translate(-50%, -50%)",pointerEvents:"none"};return(0,a.jsxs)("div",{className:"fixed inset-0 z-[80] bg-black/85 backdrop-blur-sm flex flex-col items-center justify-center p-4",children:[(0,a.jsxs)("div",{className:"bg-white rounded-3xl overflow-hidden shadow-2xl w-full max-w-5xl flex flex-col max-h-[95vh]",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between px-5 py-4 border-b border-slate-100 shrink-0",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"font-black text-slate-900 text-[15px]",children:g}),(0,a.jsx)("p",{className:"mt-1 text-[11px] font-medium text-slate-500",children:x})]}),(0,a.jsx)("button",{onClick:N,className:"flex h-9 w-9 items-center justify-center rounded-full bg-slate-100 text-slate-600 hover:bg-slate-200 cursor-pointer transition-colors",children:(0,a.jsx)(o.A,{size:16})})]}),(0,a.jsxs)("div",{className:"grid gap-5 px-5 py-5 overflow-y-auto ".concat(v?"lg:grid-cols-[minmax(0,1fr)_260px]":""),children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{ref:q,className:"relative bg-[#1a1a1a] overflow-hidden mx-auto rounded-2xl select-none touch-none",style:{width:"100%",height:"60vh",maxHeight:520,minHeight:320,cursor:A?"grabbing":"grab"},onPointerDown:e=>{e.currentTarget.setPointerCapture(e.pointerId),_(!0),H.current={mx:e.clientX,my:e.clientY,px:P.x,py:P.y}},onPointerMove:X,onPointerUp:Y,onPointerCancel:Y,onWheel:e=>{e.preventDefault();let t=-(.0015*e.deltaY);O(e=>Math.max(m,Math.min(p,e+t)))},children:[R&&(0,a.jsx)("img",{ref:I,src:R,alt:"crop preview",onLoad:e=>{let t=e.currentTarget;M({w:t.naturalWidth,h:t.naturalHeight}),C(!0),O(1),W({x:0,y:0})},style:{...Q,opacity:.35}}),(0,a.jsx)("div",{style:$,className:"overflow-hidden",children:R&&z&&(0,a.jsx)("img",{src:R,alt:"crop area",style:{position:"absolute",left:"calc(50% + ".concat(P.x,"px)"),top:"calc(50% + ".concat(P.y,"px)"),width:"".concat(V.w,"px"),height:"".concat(V.h,"px"),transform:"translate(-50%, -50%)",pointerEvents:"none",userSelect:"none",maxWidth:"none"}})}),(0,a.jsxs)("div",{ref:T,style:$,className:"border-2 border-white shadow-[0_0_0_9999px_rgba(0,0,0,0.55)] pointer-events-none",children:[(0,a.jsx)("div",{className:"absolute inset-0 pointer-events-none",style:{backgroundImage:"linear-gradient(rgba(255,255,255,0.25) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.25) 1px, transparent 1px)",backgroundSize:"calc(100%/3) calc(100%/3)",backgroundPosition:"0 0"}}),["tl","tr","bl","br"].map(e=>(0,a.jsx)("div",{className:"absolute w-3 h-3 border-white ".concat("tl"===e?"top-0 left-0 border-t-[3px] border-l-[3px]":"tr"===e?"top-0 right-0 border-t-[3px] border-r-[3px]":"bl"===e?"bottom-0 left-0 border-b-[3px] border-l-[3px]":"bottom-0 right-0 border-b-[3px] border-r-[3px]")},e))]}),!z&&(0,a.jsx)("div",{className:"absolute inset-0 flex items-center justify-center text-white/60 text-xs font-medium",children:"Carregando imagem..."})]}),z&&(0,a.jsxs)("div",{className:"mt-2 flex items-center justify-between text-[10px] font-medium text-slate-400",children:[(0,a.jsxs)("span",{children:["Original: ",E.w," \xd7 ",E.h,"px"]}),(0,a.jsxs)("span",{children:["Zoom: ",Math.round(100*S),"%"]})]})]}),v&&(0,a.jsxs)("div",{className:"rounded-2xl border border-slate-200 bg-slate-50 p-4 flex flex-col",children:[(0,a.jsx)("p",{className:"text-[11px] font-black uppercase tracking-widest text-slate-400",children:f}),(0,a.jsx)("div",{className:"relative mt-3 overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm",style:{aspectRatio:r?String(r):"14 / 5"},children:R&&z&&(0,a.jsx)("img",{src:R,alt:"preview final",style:{position:"absolute",left:"calc(50% + ".concat(P.x/B.w*100,"%)"),top:"calc(50% + ".concat(P.y/B.h*100,"%)"),width:"".concat(V.w/B.w*100,"%"),height:"".concat(V.h/B.h*100,"%"),transform:"translate(-50%, -50%)",pointerEvents:"none",userSelect:"none",maxWidth:"none",opacity:1}})}),(0,a.jsx)("p",{className:"mt-3 text-[11px] text-slate-400",children:"Esse \xe9 o resultado final que ser\xe1 salvo."})]})]}),(0,a.jsxs)("div",{className:"px-5 py-4 space-y-3 border-t border-slate-100 shrink-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("button",{onClick:()=>O(e=>Math.max(m,e-.1)),className:"text-slate-400 hover:text-slate-700 cursor-pointer shrink-0",title:"Diminuir zoom",children:(0,a.jsx)(i.A,{size:18})}),(0,a.jsx)("input",{type:"range",min:m,max:p,step:.01,value:S,onChange:e=>O(Number(e.target.value)),className:"flex-1 accent-slate-900"}),(0,a.jsx)("button",{onClick:()=>O(e=>Math.min(p,e+.1)),className:"text-slate-400 hover:text-slate-700 cursor-pointer shrink-0",title:"Aumentar zoom",children:(0,a.jsx)(s.A,{size:18})}),(0,a.jsx)("button",{onClick:()=>{O(1),W({x:0,y:0})},className:"text-slate-400 hover:text-slate-700 cursor-pointer shrink-0",title:"Encaixar imagem inteira",children:(0,a.jsx)(l.A,{size:16})}),(0,a.jsx)("button",{onClick:()=>{E.w&&B.w&&(O(Math.max(B.w/E.w,B.h/E.h)/D),W({x:0,y:0}))},className:"text-slate-400 hover:text-slate-700 cursor-pointer shrink-0",title:"Preencher \xe1rea de corte",children:(0,a.jsx)(c.A,{size:16})}),(0,a.jsx)("button",{onClick:()=>{O(1),W({x:0,y:0})},title:"Resetar",className:"text-slate-400 hover:text-slate-700 cursor-pointer shrink-0",children:(0,a.jsx)(d.A,{size:16})})]}),(0,a.jsx)("p",{className:"text-[11px] text-slate-400 text-center",children:"Arraste para reposicionar ⢠Rolar = zoom ⢠Encaixar / Preencher acima"})]}),(0,a.jsxs)("div",{className:"flex gap-3 px-5 pb-5 shrink-0",children:[(0,a.jsx)("button",{onClick:N,className:"flex-1 rounded-xl border-2 border-slate-200 py-3 text-sm font-black text-slate-600 hover:bg-slate-50 cursor-pointer transition-colors",children:"Cancelar"}),(0,a.jsxs)("button",{onClick:()=>
1{if(!E.w||!E.h)return;let e=null!=b?b:Math.round(B.w),r=null!=y?y:Math.round(B.h),a=F.current;if(!a)return;a.width=e,a.height=r;let n=a.getContext("2d");if(!n)return;"image/jpeg"===j?(n.fillStyle="#ffffff",n.fillRect(0,0,e,r)):n.clearRect(0,0,e,r);let o=P.x-V.w/2+B.w/2,i=P.y-V.h/2+B.h/2,s=e/B.w,l=r/B.h,c=I.current;c&&(n.drawImage(c,o*s,i*l,V.w*s,V.h*l),a.toBlob(e=>{if(!e)return;let r="image/png"===j?"png":"jpg";k(new File([e],t.name.replace(/\.[^.]+$/,".".concat(r)),{type:j}))},j,"image/png"===j?void 0:.95))},disabled:!z,className:"flex-1 flex items-center justify-center gap-2 rounded-xl bg-blue-600 py-3 text-sm font-black text-white hover:bg-blue-700 cursor-pointer transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,a.jsx)(u.A,{size:16})," ",w]})]})]}),(0,a.jsx)("canvas",{ref:F,className:"hidden"})]})}},84807:(e,t,r)=>{r.d(t,{Cd:()=>o,Jq:()=>h,Xv:()=>s,lw:()=>i,tg:()=>l});var a=r(56775);let n={largura:1024,altura:368},o={largura:1080,altura:360},i={largura:720,altura:840};class s extends Error{}function l(){return void 0!==window.VideoEncoder}function c(e,t,r){return new Promise((a,n)=>{let o=()=>{e.removeEventListener(t,i),e.removeEventListener("error",l),clearTimeout(c)},i=()=>{o(),a()},l=()=>{o(),n(new s("N\xe3o consegui abrir este v\xeddeo."))},c=setTimeout(()=>{o(),n(new s("O v\xeddeo demorou demais para responder."))},r);e.addEventListener(t,i,{once:!0}),e.addEventListener("error",l,{once:!0})})}async function d(e){let t=URL.createObjectURL(e),r=document.createElement("video");
1r.muted=!0,r.playsInline=!0,r.preload="auto",r.src=t;try{await c(r,"loadedmetadata",2e4)}catch(e){throw URL.revokeObjectURL(t),e}if(!r.videoWidth||!r.videoHeight)throw URL.revokeObjectURL(t),new s("Este arquivo n\xe3o tem imagem de v\xeddeo que este navegador consiga abrir. Tente um MP4.");if(!Number.isFinite(r.duration)||r.duration<1.5)throw URL.revokeObjectURL(t),new s("O v\xeddeo \xe9 curto demais. Use pelo menos 2 segundos.");return{el:r,url:t}}async function u(e,t){.001>Math.abs(e.currentTime-t)||(e.currentTime=t,await c(e,"seeked",8e3))}async function h(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:n;if(!l())throw new s("Este navegador n\xe3o sabe converter v\xeddeo. Use o Chrome, o Edge ou o Safari atualizado.");if(e.size>0x6400000)throw new s("O v\xeddeo \xe9 grande demais (m\xe1ximo 100 MB). Envie um trecho mais curto.");null==t||t({etapa:"lendo",pct:0});let{el:o,url:i}=await d(e);null==t||t({etapa:"lendo",pct:1});let c=document.createElement("canvas");c.width=r.largura,c.height=r.altura;let h=c.getContext("2d",{alpha:!1});if(!h)throw URL.revokeObjectURL(i),new s("N\xe3o consegui preparar a convers\xe3o neste navegador.");let m=Math.min(6,o.duration),p=Math.max(1,Math.round(24*m)),g=new a.T9,x=new a._j({target:g,video:{codec:"avc",width:r.largura,height:r.altura,frameRate:24},fastStart:"in-memory"}),w=null,f=new VideoEncoder({output:(e,t)=>x.addVideoChunk(e,t),error:e=>{w=e}}),v={codec:"avc1.42001f",width:r.largura,height:r.altura,bitrate:5e5,framerate:24,avc:{format:"avc"}};try{if(!(await VideoEncoder.isConfigSupported(v)).supported)throw new s("Este navegador n\xe3o consegue gerar o v\xeddeo no formato necess\xe1rio. Use o Chrome ou o Edge atualizado.");f.configure(v);let e=null;null==t||t({etapa:"convertendo",pct:0});for(let a=0;a<p;a++){if(w)throw w;await u(o,a/24);let n=Math.max(r.largura/o.videoWidth,r.altura/o.videoHeight),i=o.videoWidth*n,l=o.videoHeight*n;h.drawImage(o,(r.largura-i)/2,(r.altura-l)/2,i,l),0===a&&(e=await function(e,t,r,a){return new Promise((a,n)=>{e.toBlob(e=>{if(!e)return n(new s("N\xe3o consegui gerar a imagem de capa do v\xeddeo."));a(new File([e],t,{type:r}))},r,.8)})}(c,"poster.webp","image/webp",0));let d=new VideoFrame(c,{timestamp:Math.round(a/24*1e6),duration:Math.round(41666.666666666664)});f.encode(d,{keyFrame:a%48==0}),d.close(),f.encodeQueueSize>8&&await new Promise(e=>{let t=()=>f.encodeQueueSize<=4?e():setTimeout(t,10);t()}),null==t||t({etapa:"convertendo",pct:(a+1)/p})}if(null==t||t({etapa:"finalizando",pct:0}),await f.flush(),w)throw w;x.finalize();let a=g.buffer;if(!a||0===a.byteLength)throw new s("A convers\xe3o terminou sem gerar v\xeddeo. Tente outro arquivo.");if(!e)throw new s("N\xe3o consegui extrair a imagem de capa do v\xeddeo.");return null==t||t({etapa:"finalizando",pct:1}),{video:new File([a],"video.mp4",{type:"video/mp4"}),poster:e,duracaoS:m,bytes:a.byteLength}}catch(e){if(e instanceof s)throw e;throw new s("N\xe3o consegui converter este v\xeddeo. Tente outro arquivo, de prefer\xeancia MP4.")}finally{try{"closed"!==f.state&&f.close()}catch(e){}URL.revokeObjectURL(i),o.removeAttribute("src"),o.load()}}},87234:(e,t,r)=>{r.d(t,{V:()=>l,t:()=>c});var a=r(14272);let n={products:{maxWidth:1200,maxHeight:1200,quality:.75},covers:{maxWidth:1920,maxHeight:1080,quality:.82},logos:{maxWidth:800,maxHeight:800,quality:.88},team:{maxWidth:600,maxHeight:600,quality:.85},uploads:{maxWidth:1400,maxHeight:1400,quality:.8}},o={maxWidth:1400,maxHeight:1400,quality:.8};async function i(e,t,r){var a,i;let s=null!=(a=n[t])?a:o;if((!e.type.startsWith("image/")?{skip:!0,reason:"not_image"}:"image/gif"===e.type?{skip:!0,reason:"animated_gif"}:"image/svg+xml"===e.type?{skip:!0,reason:"svg_vector"}:e.size<307200?{skip:!0,reason:"already_small"}:{skip:!1}).skip)return null==r||r({stage:"done",progress:1}),e;try{null==r||r({stage:"preparing",progress:.1});let{bitmap:t,width:a,height:n}=await new Promise((t,r)=>{if("function"==typeof createImageBitmap)return void createImageBitmap(e).then(e=>t({bitmap:e,width:e.width,height:e.height})).catch(r);let a=URL.createObjectURL(e),n=new Image;n.onload=()=>
1{URL.revokeObjectURL(a),t({bitmap:n,width:n.naturalWidth,height:n.naturalHeight})},n.onerror=e=>{URL.revokeObjectURL(a),r(e)},n.src=a});null==r||r({stage:"compressing",progress:.4});let{width:o,height:l}=function(e,t,r,a){if(e<=r&&t<=a)return{width:e,height:t};let n=Math.min(r/e,a/t);return{width:Math.round(e*n),height:Math.round(t*n)}}(a,n,s.maxWidth,s.maxHeight),c=document.createElement("canvas");c.width=o,c.height=l;let d=c.getContext("2d");if(!d)return null==r||r({stage:"done",progress:1}),e;d.drawImage(t,0,0,o,l),null==r||r({stage:"compressing",progress:.8});let u=await (i=s.quality,new Promise(e=>{c.toBlob(t=>e(t),"image/webp",i)}));if(!u||u.size>=e.size)return null==r||r({stage:"done",progress:1}),e;let h=e.name.replace(/\.[^.]+$/,"")+".webp",m=new File([u],h,{type:"image/webp",lastModified:Date.now()});return null==r||r({stage:"done",progress:1}),m}catch(t){return null==r||r({stage:"done",progress:1}),e}}async function s(){try{var e,t;let r=(0,a.U)("admin"),{data:n}=await r.auth.getSession();return null!=(t=null==(e=n.session)?void 0:e.access_token)?t:""}catch(e){return""}}async function l(e,t,r,a){var n,o;try{let o=await i(e,t,e=>{let t="done"===e.stage?.5:Math.min(.5,.5*e.progress);null==a||a({stage:"compressing",progress:t})});null==a||a({stage:"uploading",progress:.5});let l=await s(),c=new FormData;c.append("file",o),c.append("folder",t),r&&c.append("restaurant_id",r);let d=await fetch("/api/upload",{method:"POST",headers:l?{Authorization:"Bearer ".concat(l)}:{},body:c}),u=await d.json();if(!d.ok||u.error)return null==a||a({stage:"done",progress:1}),{url:null,error:null!=(n=u.error)?n:"Erro desconhecido no upload"};return null==a||a({stage:"done",progress:1}),{url:u.url,error:null}}catch(e){return null==a||a({stage:"done",progress:1}),{url:null,error:null!=(o=e.message)?o:"Erro de rede no upload"}}}async function c(e,t){var r,a;let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"covers-video";try{null==t||t({stage:"uploading",progress:.5});let a=await s(),o=new FormData;o.append("file",e),o.append("folder",n);let i=await fetch("/api/upload/video",{method:"POST",headers:a?{Authorization:"Bearer ".concat(a)}:{},body:o}),l=await i.json();if(null==t||t({stage:"done",progress:1}),!i.ok||l.error)return{url:null,error:null!=(r=l.error)?r:"Erro desconhecido no upload do v\xeddeo"};return{url:l.url,error:null}}catch(e){return null==t||t({stage:"done",progress:1}),{url:null,error:null!=(a=null==e?void 0:e.message)?a:"Erro no upload do v\xeddeo"}}}}}]);
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.