PageSourceSearch

https://udois.com/_next/static/chunks/pages/studio/editar-template/[shortId]-a10a4baa9797f5d8.js

js udois.com collected 2026-09-26 08:06:47 UTC 14,676 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[80587],{81592:function(e,t,a){(window.__NEXT_P=window.__NEXT_P||[]).push(["/studio/editar-template/[shortId]",function(){return a(73584)}])},58163:function(e,t,a){"use strict";a.d(t,{Z:function(){return w}});var n=a(85893),r=a(40076),i=a(42037),l=a(57531),s=a(88791),o=a(48228),c=a(37871),d=a(67294),u=a(55678),m=a(34577),g=a(80473),h=a(25675),p=a.n(h);function f(e){let{imageUrl:t,label:a,ariaLabel:r,isApplied:i,isDisabled:l,widthClass:s,onSelect:o}=e;return(0,n.jsxs)("button",{type:"button",role:"radio","aria-label":r,"aria-checked":i,disabled:l,onClick:()=>o(t),className:"group flex ".concat(s," flex-col items-center gap-1 focus:outline-none disabled:cursor-not-allowed disabled:opacity-60"),children:[(0,n.jsx)(p(),{src:t,alt:r,width:160,height:284,unoptimized:!0,className:"aspect-[9/16] w-full rounded-lg border-2 border-gray-200 bg-gray-100 object-cover transition-all group-hover:border-gray-300 group-aria-checked:border-[#625AFA] group-aria-checked:group-hover:border-[#625AFA]"}),(0,n.jsx)("span",{className:"text-xs font-semibold text-[#625AFA]",children:a})]})}function x(e){let{images:t,appliedImageUrl:a,isApplying:r,stacked:i=!1,onSelect:l}=e,{t:s}=(0,c.$G)();return 0===t.length?null:(0,n.jsx)("div",{role:"radiogroup","aria-label":s("aiPersonalizeGenerationLabel"),className:i?"flex flex-row flex-wrap justify-center gap-3 sm:flex-col sm:flex-nowrap":"flex flex-wrap items-start justify-center gap-4",children:t.map((e,t)=>(0,n.jsx)(f,{imageUrl:e,label:"#".concat(t+1),ariaLabel:"".concat(s("aiPersonalizeGenerationLabel")," ").concat(t+1),isApplied:e===a,isDisabled:r,widthClass:i?"w-16 sm:w-24":"w-40 sm:w-52",onSelect:l},e))})}var v=a(73223),b=a(52982);function w(e){var t,a;let{isOpen:h,onClose:p,personalizeRequest:f,aiEditsUsed:w,onGenerated:y,generatedImages:j,appliedImageUrl:N}=e,{t:S}=(0,c.$G)(),[A,I]=(0,d.useState)(null);(0,d.useEffect)(()=>{h||I(null)},[h]);let E=void 0!==w,k=2-(null!=w?w:0),z=E&&k<=0,O=(null!==(t=null==j?void 0:j.length)&&void 0!==t?t:0)>0,R=(0,o.D)(async()=>A?f(await (0,b.Z)(A,1024,1024,"JPEG","file")):null,{onSuccess:async e=>{e&&(await y(e),I(null),p())},onError:e=>{var t,a,n;if((null===(t=e.response)||void 0===t?void 0:t.status)===422){u.Am.error("N\xe3o foi poss\xedvel gerar a imagem. Tente outra foto.");return}u.Am.error((null===(n=e.response)||void 0===n?void 0:null===(a=n.data)||void 0===a?void 0:a.message)||"Erro ao gerar a imagem. Tente novamente.")}}),C=(0,o.D)(async e=>{await y({imageUrl:e})},{onSuccess:()=>{p()},onError:()=>{u.Am.error("N\xe3o foi poss\xedvel aplicar a imagem. Tente novamente.")}});return h&&(0,n.jsx)(r.w,{onClose:p,className:"remove-close-button ai-personalize-modal",style:{width:O?720:520,maxWidth:"92vw"},children:(0,n.jsx)(i.D,{children:(0,n.jsxs)("div",{className:"relative flex min-h-full flex-col justify-center gap-3 p-4 sm:px-6 sm:py-3",children:[(0,n.jsx)(l.N4,{"aria-label":"Fechar",iconType:g.Z,onClick:p,size:"s",color:"text",className:"!absolute !right-2 !top-2"}),(0,n.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(m.Z,{className:"h-6 w-6 [&_path]:fill-[#625AFA]"}),(0,n.jsx)("p",{className:"text-[20px] font-bold text-eui-text-text",children:S("aiPersonalizeTitle")})]}),!z&&(0,n.jsx)("p",{className:"text-center text-sm text-gray-400",children:S("aiPersonalizeSubtitle")})]}),z?(0,n.jsx)(x,{images:null!=j?j:[],appliedImageUrl:N,isApplying:C.isLoading,onSelect:e=>C.mutate(e)}):(0,n.jsxs)("div",{className:"flex flex-col items-center gap-4 sm:grid sm:grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] sm:items-center sm:gap-4",children:[(0,n.jsx)("div",{className:"sm:col-start-2",children:(0,n.jsx)(v.Z,{onPhotoChange:I,hasGallery:(null!==(a=null==j?void 0:j.length)&&void 0!==a?a:0)>0})}),(0,n.jsx)("div",{className:"sm:col-start-3",children:(0,n.jsx)(x,{images:null!=j?j:[],appliedImageUrl:N,isApplying:C.isLoading,stacked:!0,onSelect:e=>C.mutate(e)})})]}),z&&(0,n.jsx)("p",{className:"rounded-xl bg-gray-100 p-4 text-center text-sm font-medium text-gray-500",children:S("aiPersonalizeLimitReached",{max:2})}),!z&&(0,n.jsxs)(n.Fragment,{children:[E&&(0,n.jsx)("p",{className:"text-center text-xs text-gray-400",children:S("aiPersonalizeFooter",{max:2})}),(0,n.jsx)(s.g2,{fullWidth:!0,className:"!h-[52px] !rounded-[12px] !font-bold ".concat(A?"!bg
1-[#625AFA] !text-white":"!bg-[#E4E3FB] !text-[#A5A0EF]"),isLoading:R.isLoading,isDisabled:!A||R.isLoading||C.isLoading,onClick:()=>R.mutate(),children:(0,n.jsxs)("span",{className:"relative flex w-full items-center justify-center",children:[S("aiPersonalizeButton"),E&&(0,n.jsxs)("span",{className:"absolute right-0 font-normal",children:["(",k,")"]})]})})]})]})})})}},73223:function(e,t,a){"use strict";a.d(t,{Z:function(){return m}});var n=a(85893);a(63025);var r=a(57531),i=a(55781),l=a(88791),s=a(37871),o=a(67294),c=a(42016),d=a(44524);let u="aspect-[9/16] sm:min-h-[14rem] sm:max-h-[860px] sm:w-auto";function m(e){let{onPhotoChange:t,hasGallery:a=!1}=e,{t:m}=(0,s.$G)(),g=a?"w-[min(74vw,calc((100vh-420px)*9/16))]":"w-[min(74vw,calc((100vh-288px)*9/16))]",h="".concat(u," ").concat("sm:h-[calc(98vh-198px)]"," ").concat(g),p="".concat(u," ").concat("sm:h-[calc(98vh-266px)]"," ").concat(g),[f,x]=(0,o.useState)("empty"),[v,b]=(0,o.useState)(""),[w,y]=(0,o.useState)(""),[j,N]=(0,o.useState)(0),S=(0,o.useRef)(null),A=e=>{b(URL.createObjectURL(e)),N(0),x("cropping"),t(null)},{getRootProps:I,getInputProps:E}=(0,d.uI)({multiple:!1,maxFiles:1,accept:{"image/*":[]},onDrop:e=>{let t=e[0];t&&A(t)}}),k=e=>{var t;let a=Number(e);null===(t=S.current)||void 0===t||t.cropper.zoom(a-j),N(a)};return(0,n.jsxs)("div",{className:"flex w-fit flex-col items-stretch gap-3",children:[(0,n.jsx)("input",{...E()}),(0,n.jsxs)("div",{className:"relative",children:["empty"!==f&&(0,n.jsx)(r.N4,{"aria-label":m("excluir"),iconType:"trash",display:"fill",color:"danger",size:"xs",onClick:()=>{b(""),y(""),N(0),x("empty"),t(null)},className:"!absolute right-2 top-2 z-10"}),"empty"===f&&(0,n.jsx)("div",{className:"".concat(h," flex cursor-pointer items-center justify-center rounded-2xl border-2 border-dashed border-gray-200 bg-white p-4 text-center text-sm text-gray-400 transition-all hover:bg-gray-50"),...I(),children:(0,n.jsx)("span",{children:m("aiPersonalizeDropHint")})}),"cropping"===f&&(0,n.jsx)("div",{className:"".concat(p," overflow-hidden rounded-2xl"),children:(0,n.jsx)(c.Z,{ref:S,src:v,className:"h-full w-full",viewMode:0,dragMode:"move",background:!1,guides:!1,autoCropArea:1,cropBoxResizable:!0,cropBoxMovable:!0,toggleDragModeOnDblclick:!1,minContainerWidth:0,minContainerHeight:0})}),"done"===f&&(0,n.jsx)("img",{src:w,alt:"preview",className:"".concat(h," rounded-2xl object-contain")})]}),"cropping"===f&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(i.k,{min:-.5,max:1.5,step:.02,value:String(j),onChange:e=>k(e.currentTarget.value),"aria-label":"Zoom",fullWidth:!0}),(0,n.jsx)(l.g2,{fullWidth:!0,size:"s",className:"!bg-[#625AFA] !font-bold !text-white",onClick:()=>{var e;let a=null===(e=S.current)||void 0===e?void 0:e.cropper;a&&a.getCroppedCanvas().toBlob(e=>{if(!e)return;let a=new File([e],"foto.jpg",{type:"image/jpeg"});y(URL.createObjectURL(e)),x("done"),t(a)},"image/jpeg")},children:m("confirmar")})]})]})}},18674:function(e,t,a){"use strict";a.d(t,{Z:function(){return r}});var n=a(11163);function r(e){var t,a;let{routeId:r}=e,i=(0,n.useRouter)();return i.query[r]&&"string"==typeof i.query[r]&&null!==(a=null===(t=i.query[r])||void 0===t?void 0:t.toString())&&void 0!==a?a:""}},73584:function(e,t,a){"use strict";a.r(t),a.d(t,{__N_SSP:function(){return S},default:function(){return A}});var n=a(85893),r=a(88791),i=a(36492),l=a(73206),s=a(5152),o=a.n(s),c=a(9008),d=a.n(c),u=a(11163),m=a(67294),g=a(55678),h=a(94438),p=a(58163),f=a(43115),x=a(19365),v=a(18674),b=a(30209),w=a(30784);let y=o()(()=>Promise.all([a.e(52603),a.e(98410),a.e(93001)]).then(a.bind(a,93001)),{loadableGenerated:{webpack:()=>[93001]},ssr:!1}),j=["ADMIN","ART_DIRECTOR"],N=[...j,"INTERNAL_DESIGNER"];var S=!0;function A(){let e=(0,u.useRouter)(),{user:t,isAuthenticating:a}=(0,h.aC)(),{canvas:s,actions:o,states:c,setStates:S,imageAttachableDropzone:A}=(0,x.Z)({mode:"DESIGNER"}),I=(0,v.Z)({routeId:"shortId"}),[E,k]=(0,m.useState)(!1),[z,O]=(0,m.useState)(!1),[R,C]=(0,m.useState)([]),[_,F]=(0,m.useState)(""),P=(0,m.useRef)(null),{data:D,refetch:Z}=(0,i.a)(["findTemplateByShortIdInternal",I],()=>w.Z.findByShortIdInternal(I),{enabled:!!I});(0,m.useEffect)(()=>{var n;if(a||!D)return;if(!t){e.push(b.Z.auth.LOGIN());return}if(!N.includes(t.role)){e.push(b.Z.HOMEPAGE);return}let r=j.includes(t.role),i=null===(n=D.user)||void 0===n?void 0:n._id,l=i===t._id,s=!i;
1if(!r&&!l&&!s){e.push(b.Z.admin.templates.studio.LIST);return}s&&w.Z.enter(D._id).catch(()=>{e.push(b.Z.admin.templates.studio.LIST)})},[D,t,a]);let L=()=>{if(!s||!(null==D?void 0:D.aiEditableObjectId))return null;let e=s.getObjects().find(e=>{var t;return(null===(t=e.data)||void 0===t?void 0:t.objectId)===D.aiEditableObjectId});return e&&e instanceof l.I?e:null},T=async e=>{let t=L();if(!s||!t){g.Am.error("N\xe3o foi poss\xedvel localizar a camada marcada no template.");return}let a=t.width*t.scaleX,n=t.height*t.scaleY;P.current||(P.current={src:t.getSrc(),scaleX:t.scaleX,scaleY:t.scaleY}),await t.setSrc(e.imageUrl,{crossOrigin:"anonymous"}),t.set({scaleX:a/t.width,scaleY:n/t.height}),s.renderAll(),C(t=>t.includes(e.imageUrl)?t:[...t,e.imageUrl]),F(e.imageUrl)},U=async()=>{let e=P.current,t=L();e&&s&&t&&(await t.setSrc(e.src,{crossOrigin:"anonymous"}),t.set({scaleX:e.scaleX,scaleY:e.scaleY}),s.renderAll(),P.current=null,F(""))},M=async()=>{await U(),k(!0),o.closeAllObjectsSettings(),S.setDrawAreaSettingsIsOpen(!1)};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(d(),{children:(0,n.jsx)("title",{children:"UDOIS - Studio"})}),(0,n.jsxs)("main",{className:"custom-scrollbar h-screen w-full overflow-y-auto bg-[#393939]",children:[(0,n.jsx)(f.Z,{canvas:s,actions:o,states:c,setStates:S,initialValue:null==D?void 0:D.canvas,resetCanvas:null==D?void 0:D.canvas,status:null==D?void 0:D.status,exitUrl:b.Z.admin.templates.studio.LIST,updateOriginalDimensions:!0,imageAttachableDropzone:A,onAiPersonalizeClick:(null==D?void 0:D.aiEditableEnabled)&&(null==D?void 0:D.aiEditableObjectId)?()=>O(!0):void 0,children:(0,n.jsx)(r.g2,{className:"!w-full !max-w-[634px] !rounded-xl !bg-eui-core-success !p-1 !text-[10px] !font-bold !uppercase !text-white sm:!text-sm",color:"success",style:{minInlineSize:"0"},onClick:M,children:"Salvar"})}),D&&(0,n.jsx)(y,{canvas:s,templateData:D,isOpen:E,onClose:()=>{k(!1),Z()},hasVideo:c.hasVideo}),D&&(0,n.jsx)(p.Z,{isOpen:z,onClose:()=>O(!1),personalizeRequest:e=>w.Z.aiPersonalizeTestInternal(D._id,e),onGenerated:T,generatedImages:R,appliedImageUrl:_||void 0})]})]})}},52982:function(e,t,a){"use strict";a.d(t,{Z:function(){return i}});var n=a(76770),r=a.n(n);let i=function(e,t,a,n,i,l,s){let o=arguments.length>7&&void 0!==arguments[7]?arguments[7]:100;return new Promise(c=>{r().imageFileResizer(e,t,a,n,o,0,e=>{"blob"===i&&c(e),"file"===i&&c(e)},i,l,s)})}},9008:function(e,t,a){e.exports=a(23867)},76770:function(e){(()=>{"use strict";var t={d:(e,a)=>{for(var n in a)t.o(a,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:a[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},a={};t.r(a),t.d(a,{default:()=>r});var n=function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"changeHeightWidth",value:function(e,t,a,n,r,i){return a>n&&(e=Math.round(e*n/a),a=n),e>t&&(a=Math.round(a*t/e),e=t),r&&a<r&&(e=Math.round(e*r/a),a=r),i&&e<i&&(a=Math.round(a*i/e),e=i),{height:e,width:a}}},{key:"resizeAndRotateImage",value:function(e,t,a,n,r){var i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"jpeg",l=arguments.length>6&&void 0!==arguments[6]?arguments[6]:100,s=arguments.length>7&&void 0!==arguments[7]?arguments[7]:0,o=document.createElement("canvas"),c=e.width,d=e.height,u=this.changeHeightWidth(d,a,c,t,n,r);s&&(90===s||270===s)?(o.width=u.height,o.height=u.width):(o.width=u.width,o.height=u.height),c=u.width,d=u.height;var m=o.getContext("2d");return m.fillStyle="rgba(0, 0, 0, 0)",m.fillRect(0,0,c,d),m.imageSmoothingEnabled&&m.imageSmoothingQuality&&(m.imageSmoothingQuality="high"),s&&(m.rotate(s*Math.PI/180),90===s?m.translate(0,-o.width):180===s?m.translate(-o.width,-o.height):270===s?m.translate(-o.height,0):0!==s&&360!==s||m.translate(0,0)),m.drawImage(e,0,0,c,d),o.toDataURL("image/".concat(i),l/100)}},{key:"b64toByteArrays",value:function(e,t){t=t||"image/jpeg";for(var a=atob(e.toString().replace(/^data:image\/(png|jpeg|jpg|webp);base64,/,"")),n=[],r=0;r<a.length;r+=512){for(var i=a.slice(r,r+512),l=Array(i.length),s=0;s<i.length;s++)l[s]=i.charCodeAt(s);var o=new Uint8Array(l);n.push(o)}return n}},{key:"b64toBlob",value:function(e,t){return new Blob(this.b64toByteArrays(e,t),{type:t,lastModified:new Date})}},{key:"b64toFile",value:function(e,t,a){return new File(this.b64toByteArrays(e,a),t,{type:a,lastModified:new Date})}},{key:"createResizedImage",value:function(e,a,n,r,i,l,s){var o=arguments.length>7&&void 0!==arguments[7]?arguments[7]:"base64",c=arguments.length>8&&void 0!==arguments[8]?arguments[8]:null,d=arguments.length>9&&void 0!==arguments[9]?arguments[9]:null,u=new FileReader;if(!e)throw Error("File Not Found!");if(e.type&&!e.type.includes("image"))throw Error("File Is NOT Image!");
1u.readAsDataURL(e),u.onload=function(){var m=new Image;m.src=u.result,m.onload=function(){var u=t.resizeAndRotateImage(m,a,n,c,d,r,i,l),g="image/".concat(r);switch(o){case"blob":s(t.b64toBlob(u,g));break;case"base64":default:s(u);break;case"file":var h=e.name.toString().replace(/(png|jpeg|jpg|webp)$/i,"").concat(r.toString());s(t.b64toFile(u,h,g))}}},u.onerror=function(e){throw Error(e)}}}],function(e,t){for(var a=0;a<t.length;a++){var n=t[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t,e),t}();let r={imageFileResizer:function(e,t,a,r,i,l,s,o,c,d){return n.createResizedImage(e,t,a,r,i,l,s,o,c,d)}};e.exports=a})()}},function(e){e.O(0,[74885,52140,5947,9751,95329,61153,63716,85786,3394,46130,72208,325,17525,50270,95638,28867,18674,25675,77947,55781,81679,1049,22004,44524,57973,24496,98290,40521,18434,60688,92888,49774,40179],function(){return e(e.s=81592)}),_N_E=e.O()}]);

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.