(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3185],{912:function(e,t,r){Promise.resolve().then(r.bind(r,66719)),Promise.resolve().then(r.t.bind(r,52445,23)),Promise.resolve().then(r.bind(r,10982)),Promise.resolve().then(r.bind(r,99654)),Promise.resolve().then(r.bind(r,21574)),Promise.resolve().then(r.bind(r,10680)),Promise.resolve().then(r.bind(r,19274)),Promise.resolve().then(r.bind(r,28675)),Promise.resolve().then(r.bind(r,62191)),Promise.resolve().then(r.bind(r,64905)),Promise.resolve().then(r.bind(r,88146)),Promise.resolve().then(r.t.bind(r,85935,23)),Promise.resolve().then(r.t.bind(r,86087,23)),Promise.resolve().then(r.bind(r,18075))},66719:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return l}});var n=r(57437),s=r(2265),a=r(51367),o=r(18992);function l(){let[e,t]=(0,s.useState)(!1);return(0,s.useEffect)(()=>{localStorage.getItem("compliance-banner")?"accepted"===localStorage.getItem("compliance-banner")&&window.gtag("consent","update",{ad_user_data:"granted",ad_personalization:"granted",ad_storage:"granted",analytics_storage:"granted",functionality_storage:"granted",security_storage:"granted"}):t(!0)},[]),(0,n.jsxs)("div",{className:(0,a.m6)("fixed bottom-5 left-5 right-5 z-50 max-w-sm rounded border border-gray-300 bg-truewhite p-3 text-sm shadow-sm sm:left-auto",e?"block":"hidden"),children:[(0,n.jsx)("p",{children:"We use tracking cookies to understand how you use the product and help us improve it. Please accept cookies to help us improve."}),(0,n.jsxs)("div",{className:"mt-3 flex flex-row items-center justify-start space-x-3",children:[(0,n.jsx)("button",{className:"rounded bg-gray-800 px-3 py-1 text-base text-white",type:"button",onClick:()=>{(0,o.q)({name:"cookie_consent_yes",value:"accepted"}),localStorage.setItem("compliance-banner","accepted"),t(!1);try{window.gtag("consent","update",{ad_user_data:"granted",ad_personalization:"granted",ad_storage:"granted",analytics_storage:"granted",functionality_storage:"granted",security_storage:"granted"})}catch(e){}},children:"Accept"}),(0,n.jsx)("button",{className:"rounded bg-gray-100 px-3 text-base text-gray-500",type:"button",onClick:()=>{(0,o.q)({name:"cookie_consent_no",value:"denied"}),localStorage.setItem("compliance-banner","declined"),t(!1)},children:"Decline"})]})]})}},10982:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return f}});var n=r(57437),s=r(2265),a=r(8792),o=r(51367),l=r(47907),i=r(53879),c=r(53118),u=r(20970),d=r(18075),m=r(36437),h=r(18992),x=r(49079);function f(e){let{lang:t}=e;if(["platform","news"].includes("rerender"))return(0,n.jsx)(n.Fragment,{});let r=(0,l.usePathname)(),{state:f,dispatch:p}=(0,d.useAppContext)(),g=(0,m.O8)({lang:t}),[b,v]=(0,s.useState)("");(0,s.useEffect)(()=>{navigator.mediaDevices&&"getDisplayMedia"in navigator.mediaDevices?v("desktop"):v("headset")},[]);let w=["/tools/lego","/tools/restage"].some(e=>r.startsWith(e)),y=r.startsWith("/tools/restage");return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:(0,o.m6)("fixed left-0 right-0 top-0 z-30 flex h-14 select-none flex-row items-center justify-center border-b border-gray-300",y?"bg-truewhite":"bg-white"),children:(0,n.jsxs)("div",{className:(0,o.m6)("flex-rows mx-auto flex w-full items-center px-3",w?"":"max-w-7xl"),children:[w&&(0,n.jsx)(a.default,{href:"/",children:(0,n.jsx)(i.Z,{className:"mx-3 h-5 w-5"})}),(0,n.jsx)(a.default,{href:"/",className:"mr-4 flex items-center space-x-2",children:(0,n.jsxs)("div",{className:"text-3xl font-extrabold italic leading-4 tracking-normal text-black",children:["ReRoom"," ",-1===["wvp","hr","platform_tenant"].indexOf("rerender")&&(0,n.jsx)(n.Fragment,{children:"AI"})]})}),-1===["wvp","hr"].indexOf("rerender")&&""==f.user.uid&&(0,n.jsxs)("div",{className:"hidden flex-1 flex-row justify-end space-x-7 text-sm md:flex",children:[x.env.NEXT_PUBLIC_GALLERY_URL&&(0,n.jsx)(a.default,{href:"".concat(x.env.NEXT_PUBLIC_GALLERY_URL,"?ref=").concat("ReRoom"),target:"_blank",children:"Gallery"}),(0,n.jsx)(a.default,{href:"/support/pricing",children:"Pricing"}),(0,n.jsx)(a.default,{href:"/support/about",children:"About"}),(0,n.jsx)(a.default,{href:"/support/faq",children:"FAQs"})]}),-1!==["hr"].indexOf("rerender")&&(0,n.jsxs)("div",{className:"hidden flex-1 flex-row justify-end space-x-7 text-sm md:flex",children:[(0,n.jsx)(a.default,{href:"/#about",children:"關於我們"}),(0,n.jsx)(a.default,{href:"/#applications",children:"應用產業"}),(0,n.jsx)(a.default,{href:"/#jobs",children:"職缺"}),(0,n.jsx)(a.default,{href:"/#contact",children:"聯絡我們"})]}),-1===["hr"].indexOf("rerender")&&(0,n.jsxs)("div",{className:"ml-auto flex items-center",children:[""!==f.user.uid&&(0,n.jsx)(a.default,{href:"/account/user",className:(0,o.m6)("router-link px-3 hover:bg-gray-200",r.startsWith("/account/user")&&"border-zinc-800 font-bold text-zinc-800",!r.startsWith("/account/user")&&"border-transparent text-zinc-500"),children:(0,n.jsx)(c.Z,{className:"h-5 w-5"})}),f.user.uid&&(0,n.jsxs)("div",{className:"mx-3 cursor-pointer text-sm leading-4",onClick:()=>{p({type:"OPEN_SUB_SETTINGS"}),(0,h.q)({name:"open_pricing",value:"navbar_plan"})},children:[(0,n.jsxs)("div",{className:"flex flex-row items-center",children:[(0,n.jsx)("span",{className:"text-sm md:text-base",children:f.user.is_plus?(0,n.jsx)(n.Fragment,{children:g.subscription.proPlan}):(0,n.jsx)(n.Fragment,{children:g.subscription.freeTrial})}),f.user.is_plus&&(0,n.jsx)(u.Z,{className:"ml-1 h-4 w-4 text-green-600"})]}),(0,n.jsxs)("div",{className:"text-xs text-gray-500",children:["credit:"," ",f.user.is_plus?"unlimited ":f.user.num_credit]})]}),f.user.uid?(0,n.jsx)(n.Fragment,{}):(0,n.jsx)(a.default,{href:"/sign-in",children:(0,n.jsxs)("button",{className:"ml-6 rounded-lg bg-blue-600 px-4 py-2 text-sm font-bold text-white",children:[" ",g.components.navbar.signIn," "]})})]})]})}),(0,n.jsx)("div",{className:"h-14"})]})}},99654:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return P}});var n=r(57437),s=r(2265),a=r(47907),o=r(51367),l=r(18075),i=r(4009),c=r(18992),u=r(8792),d=r(20703),m=r(42527),h=r(51770),x=r(13031),f=r(40213),p=r(78031),g=r(77329),b=r(68754),v=r(88382),w=r(86509),y=r(56874),j=r(12882),N=r(7435),k=r(27554),E=r(85715),_=r(18727),C=r(58390),S=r(53118),R=r(52235),D=r(12161),Z=r(31075);function I(e){let{wording:t}=e,{state:r,dispatch:i}=(0,l.useAppContext)(),c=(0,a.usePathname)(),[I,P]=(0,s.useState)(!1),[T,M]=(0,s.useState)(""),[z,L]=(0,s.useState)(!1),O=[{name:t.tools.home||"Home",path:"/",target:"_self",icon:(0,n.jsx)(m.Z,{className:"mx-2 h-5 w-5"}),showPopup:!1}];(0,s.useEffect)(()=>{L("true"===localStorage.getItem("dontShow"))},[]);let A=(e,t)=>{t.showPopup&&(e.preventDefault(),P(!0),M(t.path))};for(let e of Object.keys(t.tools)){let r=(0,n.jsx)(h.Z,{});"remake"===e?r=(0,n.jsx)(x.Z,{className:"mx-2 h-5 w-5"}):"inpaint"===e?r=(0,n.jsx)(f.Z,{className:"mx-2 h-5 w-5"}):"sketch"===e?r=(0,n.jsx)(p.Z,{className:"mx-2 h-5 w-5"}):"copywrite"===e?r=(0,n.jsx)(g.Z,{className:"mx-2 h-5 w-5"}):"img23d"===e?r=(0,n.jsx)(b.Z,{className:"mx-2 h-5 w-5"}):"txt23d"===e?r=(0,n.jsx)(v.Z,{className:"mx-2 h-5 w-5"}):"gallery"===e?r=(0,n.jsx)(w.Z,{className:"mx-2 h-5 w-5"}):"txt2img"===e?r=(0,n.jsx)(y.Z,{className:"mx-2 h-5 w-5"}):"texture"===e?r=(0,n.jsx)(j.Z,{className:"mx-2 h-5 w-5"}):"restage"===e?r=(0,n.jsx)(N.Z,{className:"mx-2 h-5 w-5"}):"lego"===e?r=(0,n.jsx)(k.Z,{className:"mx-2 h-5 w-5"}):"expression"===e?r=(0,n.jsx)(E.Z,{className:"mx-2 h-5 w-5"}):"imagine"===e?r=(0,n.jsx)(_.Z,{className:"mx-2 h-5 w-5"}):"img2vid"===e?r=(0,n.jsx)(d.default,{src:"/fonts/drone.svg",width:20,height:20,alt:"Drone icon",className:"mx-2"}):"enhance"===e&&(r=(0,n.jsx)(_.Z,{className:"mx-2 h-5 w-5"})),("remake"===e||"inpaint"===e||"sketch"===e||"copywrite"===e||"img23d"===e||"txt23d"===e||"gallery"===e||"txt2img"===e||"texture"===e||"restage"===e||"lego"===e||"expression"===e||"imagine"===e||"img2vid"===e||"enhance"===e)&&O.push({name:t.tools[e]||"",path:"/tools/".concat(e),target:"_self",icon:r,showPopup:"inpaint"===e&&["ReRoom","ReRender"].includes("ReRoom")})}let B=[{name:t.tools.history||"History",path:"/account/history",target:"_self",icon:(0,n.jsx)(C.Z,{className:"mx-2 h-5 w-5"})},{name:t.tools.account||"Account",path:"/account/user",target:"_self",icon:(0,n.jsx)(S.Z,{className:"mx-2 h-5 w-5"})}];return(0,n.jsxs)(n.Fragment,{children:[I&&(0,n.jsx)("div",{onClick:()=>P(!1),className:"fixed inset-0 z-50 flex flex-col items-center justify-center bg-black bg-opacity-70",children:(0,n.jsxs)("div",{onClick:e=>e.stopPropagation(),className:"w-3/5 rounded-lg border-2 border-gray-500 bg-truewhite",children:[(0,n.jsxs)("div",{className:"mb-5 flex items-center justify-between border-b-1 border-gray-500 p-3 text-2xl",children:[(0,n.jsx)("h1",{children:r.wording.features.common.tag}),(0,n.jsx)(R.Z,{onClick:()=>P(!1),className:"cursor-pointer"})]}),(0,n.jsx)("div",{className:"mx-10",children:(0,n.jsx)(Z.Z,{})}),(0,n.jsxs)("div",{className:"my-3 flex flex-col justify-center md:flex-row",children:[(0,n.jsxs)("label",{className:"mr-5 flex items-center",children:[(0,n.jsx)("input",{type:"checkbox",checked:z,onChange:e=>{let t=e.target.checked;L(t),t?localStorage.setItem("dontShow","true"):localStorage.removeItem("dontShow")},className:"mr-2 h-5 w-5 text-blue-500"}),(0,n.jsx)("span",{children:r.wording.features.popup.dontShow})]}),(0,n.jsx)("button",{className:"gap-4 rounded-md border-1 bg-green-600 p-2 text-white shadow-[rgba(0,_0,_0,_0.1)_1px_1px_2px]",onClick:()=>{T&&(window.location.href=T)},children:(0,n.jsxs)("div",{className:"mx-10 flex",children:[(0,n.jsx)(_.Z,{className:"mr-1 w-5"}),(0,n.jsx)("div",{className:"ml-1",children:r.wording.features.common.start})]})})]})]})}),(0,n.jsxs)("div",{className:"fixed top-14 flex h-full flex-col items-stretch space-y-2 px-3 pb-20 pt-7 text-sm lg:w-[200px]",children:[O.map(e=>(0,n.jsx)(u.default,{href:e.path,target:e.target,children:(0,n.jsxs)("button",{onClick:z?void 0:t=>A(t,e),className:(0,o.m6)("flex flex-row items-center rounded-full border p-2 lg:w-full",c.startsWith(e.path)&&"/"!==e.path||"/"===e.path&&(""===c||"/"===c)?"border-lime-500 bg-lime-50 font-bold text-lime-700":"border-transparent hover:bg-gray-200"),children:[e.icon,(0,n.jsx)("span",{className:"hidden lg:inline",children:e.name})]})},e.path)),(0,n.jsx)(u.default,{href:"https://restageai.com?hello=reroom",target:"_blank",children:(0,n.jsxs)("button",{className:(0,o.m6)("flex flex-row items-center rounded-full border p-2 lg:w-full","border-transparent hover:bg-gray-200"),children:[(0,n.jsx)(D.Z,{className:"mx-2 h-5 w-5"}),(0,n.jsx)("span",{className:"hidden lg:inline",children:"Furniture Photo"})]})}),!1,(0,n.jsx)("div",{className:"flex-1"}),B.map(e=>(0,n.jsx)(u.default,{href:e.path,target:e.target,children:(0,n.jsxs)("button",{className:(0,o.m6)("flex flex-row items-center rounded-full border p-2 lg:w-full",c.startsWith(e.path)?"bg-gray-700 font-bold text-gray-200":"border-transparent hover:bg-gray-200"),children:[e.icon,(0,n.jsx)("span",{className:"hidden lg:inline",children:e.name})]})},e.path))]})]})}function P(e){let{children:t}=e,{state:r,dispatch:u}=(0,l.useAppContext)(),d=(0,a.usePathname)(),m=["/wait-stripe","/wait-watermark","/legal/privacy-policy","/legal/terms-of-service","/support/about","/support/faq","/support/pricing","/tools/lego","/tools/restage","/features/inpaint","/blog"],h=["/tools/portrait"],[x,f]=(0,s.useState)(0),[p,g]=(0,s.useState)({hours:0,minutes:0,seconds:0});(0,s.useEffect)(()=>{let e=!0,t=setTimeout(()=>{if(e){let e=(0,i.D4)();f(e);let{hours:t,minutes:r,seconds:n}=(0,i.WX)({seconds:e});g({hours:t,minutes:r,seconds:n})}},1e3);return()=>{e=!1,clearTimeout(t)}},[x]);let b=null;!(r.user.num_credit<=0)||r.user.is_plus||!r.user.uid||d.startsWith("/wait-stripe")||d.startsWith("/support")||(b=(0,n.jsx)("div",{className:(0,o.m6)("z-20 flex items-center justify-center rounded border border-yellow-600 bg-yellow-100 p-2 text-sm text-black","/tools/restage"===d&&"absolute left-0 top-0 w-full"),children:(0,n.jsxs)("div",{className:"flex flex-col",children:[(0,n.jsx)("div",{className:"text-center",children:r.wording.components.navbar.creditZeroForToday}),(0,n.jsxs)("div",{className:"text-center text-xl",children:[p.hours,"h ",p.minutes,"m ",p.seconds,"s"]}),(0,n.jsx)("div",{className:"text-center",children:r.wording.components.navbar.untilRefresh}),(0,n.jsx)("a",{href:"/support/pricing",onClick:()=>{(0,c.q)({name:"open_pricing",value:"no_credit"})},className:"mt-3 rounded border border-yellow-800 bg-yellow-200 p-3 text-center text-xl font-bold text-black",children:r.wording.components.navbar.upgradeToPlus})]})}));let v=(0,s.useMemo)(()=>{if(["wvp","platform"].includes("rerender"))return!0;for(let e of m)if(d.startsWith(e)||"/"===d&&!r.user.uid)return!0;return!1},[d,r.user.uid,m]),w=(0,s.useMemo)(()=>{for(let e of h)if(d.startsWith(e))return!0;return!1},[d,h]);return(0,n.jsxs)("div",{className:(0,o.m6)("relative mx-auto w-full",!v&&"max-w-7xl","/tools/restage"!==d&&"flex"),children:[!!r.user.uid&&!v&&!["wvp","platform"].includes("rerender")&&(0,n.jsx)("div",{className:"h-screen-minus-14 relative hidden w-[80px] md:block lg:w-[240px]",children:(0,n.jsx)(I,{wording:r.wording})}),(0,n.jsxs)("div",{className:(0,o.m6)("relative flex flex-1 flex-col",w&&"h-screen-minus-14 overflow-hidden"),children:[b,t]})]})}},21574:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return i}});var n=r(2265),s=r(87136),a=r(18075),o=r(46619),l=r(81362);function i(){let{state:e,dispatch:t}=(0,a.useAppContext)();return(0,n.useEffect)(()=>{e.user.uid&&e.webPushToken&&(0,l.v3)({token:e.webPushToken})},[e.user.uid,e.webPushToken]),(0,n.useEffect)(()=>{"serviceWorker"in navigator&&navigator.serviceWorker.register("/firebase-messaging-sw.js").then(e=>(console.log("Service Worker registered with scope:",e.scope),Notification.requestPermission())).then(e=>{}).catch(e=>{console.error("Service Worker registration failed:",e)}),(0,s.Gb)().then(e=>{if(e){let e=(0,o.Vg)();(0,s.LP)(e,{vapidKey:"BA62g99IEOu-WJOiwc4cXmrq3zLVXP-tBVx4-VylFQ1dwOo_z4Aq-tmWvgYquRwCbrKnJkvnzXZqeFZ2fxEJrOM"}).then(e=>{e&&t({type:"SET_WEB_PUSH_TOKEN",payload:{token:e}})}).catch(e=>{})}else console.log("Firebase messaging is not supported in this browser.")})},[]),(0,n.useEffect)(()=>{"declined"===localStorage.getItem("compliance-banner")&&e.user.email&&(console.log("unsubscribing marketing"),(0,l.v9)({email:e.user.email}))},[e.user.email]),null}},10680:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return l}});var n=r(2265),s=r(47907),a=r(18075),o=r(81362);function l(){let{state:e,dispatch:t}=(0,a.useAppContext)(),r=(0,s.usePathname)(),l=async()=>{try{let{err:e,res:r}=await (0,o.Yt)();e||t({type:"SET_GEOLOCATION",payload:{geolocation:r}})}catch(e){}},i=async()=>{let n=localStorage.getItem("device_id");n||(n="".concat(new Date().getTime(),"-").concat(Math.floor(1e6*Math.random())),localStorage.setItem("device_id",n));try{let{err:s,res:a}=await (0,o.c2)({device_id:n||"",device_ua:navigator.userAgent||"",path:r,...e.tracker});s||t({type:"SET_BREADCRUMB_ID",payload:{breadcrumb_id:a._id}})}catch(e){}},c=async()=>{try{let{err:t,res:r}=await (0,o.Eb)({_id:e.breadcrumb_id,geolocation:e.geolocation})}catch(e){}},u=async()=>{try{await (0,o.ym)(e.geolocation)}catch(e){}};return(0,n.useEffect)(()=>{e.user.email.endsWith("@architech.tw")||(l(),i())},[]),(0,n.useEffect)(()=>{if(e.user.uid&&e.geolocation.ip_address)try{u()}catch(e){}},[e.geolocation.ip_address,e.user.uid]),(0,n.useEffect)(()=>{if(e.user.uid&&e.geolocation.ip_address&&e.breadcrumb_id)try{c()}catch(e){}},[e.geolocation.ip_address,e.user.uid,e.breadcrumb_id]),null}},99520:function(e,t,r){"use strict";var n=r(57437);r(2265);var s=r(51367);t.Z=e=>{let{Icon:t,selected:r=!1,disabled:a,onClick:o,shape:l="rectangle",shadow:i=!1,initialBgClassName:c="bg-truewhite",className:u=""}=e,d=(0,s.m6)(c,"p-2 flex items-center justify-center text-black",a?"cursor-not-allowed text-stone-200":r?"bg-gray-600 text-truewhite":"hover:bg-stone-200 active:bg-gray-600 active:text-truewhite","rectangle"===l?"rounded":"rounded-full",i&&"shadow-[0_0_4px_0.5px_rgb(0,0,0,0.2)]",u);return(0,n.jsx)("button",{onMouseDown:e=>{e.stopPropagation(),e.preventDefault(),o(e)},className:d,disabled:a,children:(0,n.jsx)(t,{})})}},19274:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return d}});var n=r(57437),s=r(2265),a=r(85754),o=r(45179),l=r(52235),i=r(79990),c=r(67366),u=r(81362);function d(){let[e,t]=(0,s.useState)(!1),[r,d]=(0,s.useState)([{id:1,text:"Hello! How can I help you today?",sender:"bot"}]),[m,h]=(0,s.useState)(""),x=(0,s.useRef)(null),f=()=>t(!e),[p,g]=(0,s.useState)(!1),b=async e=>{if(e.preventDefault(),m.trim()){let e={id:r.length+1,text:m,sender:"user"};d([...r,e]),h("");let{err:t,res:n}=await (0,u.xM)({message:m});if(t){console.error(t);return}p||setTimeout(()=>{let e={id:r.length+2,text:"Thank you for your message. We will get back to you as soon as possible. For direct messaging, please send an email to ".concat("feedback@reroom.ai"),sender:"bot"};d(t=>[...t,e]),g(!0)},1e3)}};return(0,s.useEffect)(()=>{var e;null===(e=x.current)||void 0===e||e.scrollIntoView({behavior:"smooth"})},[r]),(0,n.jsx)("div",{className:"fixed bottom-4 right-4 z-30",children:e?(0,n.jsxs)("div",{className:"flex h-[32rem] w-80 flex-col rounded-lg border bg-background shadow-lg sm:w-96",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between border-b p-4",children:[(0,n.jsx)("h2",{className:"text-lg font-semibold",children:"Chat Support"}),(0,n.jsx)(a.z,{variant:"ghost",size:"icon",onClick:f,"aria-label":"Close chat",children:(0,n.jsx)(l.Z,{className:"h-4 w-4"})})]}),(0,n.jsxs)("div",{className:"flex-grow overflow-y-auto p-4",children:[r.map(e=>(0,n.jsx)("div",{className:"mb-4 ".concat("user"===e.sender?"text-right":"text-left"),children:(0,n.jsx)("span",{className:"inline-block rounded-lg p-2 ".concat("user"===e.sender?"bg-primary text-primary-foreground":"bg-muted"),children:e.text})},e.id)),(0,n.jsx)("div",{ref:x})]}),(0,n.jsxs)("form",{onSubmit:b,className:"flex border-t p-4",children:[(0,n.jsx)(o.I,{type:"text",placeholder:"Type a message...",value:m,onChange:e=>h(e.target.value),className:"mr-2 flex-grow"}),(0,n.jsx)(a.z,{type:"submit",size:"icon","aria-label":"Send message",children:(0,n.jsx)(i.Z,{className:"h-4 w-4"})})]})]}):(0,n.jsx)(a.z,{onClick:f,className:"flex h-12 w-12 items-center justify-center rounded-full","aria-label":"Open chat",children:(0,n.jsx)(c.Z,{className:"h-6 w-6"})})})}},28675:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return R}});var n=r(57437),s=r(18075),a=r(2265),o=r(20703),l=r(52235),i=r(79580),c=r(9014),u=r(88382),d=r(51367),m=r(57979),h=r(15927),x=r(3528),f=r(18992),p=r(53348),g=r(15566),b=r(40992),v=e=>{let{text:t,icon:r,disabled:s,onClick:a}=e;return(0,n.jsxs)("button",{className:(0,d.m6)("flex-1 border  rounded py-1 text-xs flex flex-row items-center justify-center",s?"opacity-50 cursor-not-allowed border-gray-400 text-gray-400":"hover:border-gray-500 border-gray-200"),onClick:a,disabled:s,children:[r,t]})};function w(e){let{canvasRef:t,maskHistory:r,setMaskHistory:s}=e,o=(0,a.useRef)(null),[l,i]=(0,a.useState)(42),[c,u]=(0,a.useState)(!1),m=(0,a.useRef)(!1),h=(0,a.useRef)({x:0,y:0});(0,a.useEffect)(()=>{if(o.current){let e=()=>{o.current&&t.current&&(t.current.width=o.current.offsetWidth,t.current.height=o.current.offsetHeight)};return window.addEventListener("resize",e),e(),window.scrollTo(0,0),()=>{window.removeEventListener("resize",e)}}},[]);let x=(e,t,r,n)=>{e.strokeStyle="#22C55E",e.lineJoin="round",e.lineCap="round",e.lineWidth=n,e.beginPath(),e.moveTo(t.x,t.y),e.lineTo(r.x,r.y+.001),e.stroke(),e.closePath()};return(0,a.useEffect)(()=>{var e,r,n,a,o,i;let c=e=>{var r;m.current=!0;let n=null===(r=t.current)||void 0===r?void 0:r.getContext("2d");n&&(h.current={x:e.offsetX,y:e.offsetY},x(n,h.current,h.current,l))},u=e=>{var r;if(!m.current)return;let n=null===(r=t.current)||void 0===r?void 0:r.getContext("2d");if(!n)return;let s={x:e.offsetX,y:e.offsetY};x(n,h.current,s,l),h.current={x:e.offsetX,y:e.offsetY}},d=()=>{var e;m.current=!1;let r=null===(e=t.current)||void 0===e?void 0:e.getContext("2d");if(r){let e=r.getImageData(0,0,t.current.width,t.current.height);s(t=>[...t,e])}},f=e=>{var r,n;e.preventDefault(),m.current=!0;let s=null===(r=t.current)||void 0===r?void 0:r.getContext("2d"),a=null===(n=t.current)||void 0===n?void 0:n.getBoundingClientRect();if(!s||!a)return;let o=e.touches[0].clientX-a.left,i=e.touches[0].clientY-a.top;h.current={x:o,y:i},x(s,h.current,h.current,l)},p=e=>{var r,n;if(e.preventDefault(),!m.current)return;let s=null===(r=t.current)||void 0===r?void 0:r.getContext("2d"),a=null===(n=t.current)||void 0===n?void 0:n.getBoundingClientRect();if(!s||!a)return;let o=e.touches[0].clientX-a.left,i=e.touches[0].clientY-a.top;x(s,h.current,{x:o,y:i},l),h.current={x:o,y:i}};return null===(e=t.current)||void 0===e||e.addEventListener("mousedown",c),null===(r=t.current)||void 0===r||r.addEventListener("mousemove",u),null===(n=t.current)||void 0===n||n.addEventListener("mouseup",d),null===(a=t.current)||void 0===a||a.addEventListener("touchstart",f),null===(o=t.current)||void 0===o||o.addEventListener("touchmove",p),null===(i=t.current)||void 0===i||i.addEventListener("touchend",d),()=>{var e,r,n,s,a,o;null===(e=t.current)||void 0===e||e.removeEventListener("mousedown",c),null===(r=t.current)||void 0===r||r.removeEventListener("mousemove",u),null===(n=t.current)||void 0===n||n.removeEventListener("mouseup",d),null===(s=t.current)||void 0===s||s.removeEventListener("touchstart",f),null===(a=t.current)||void 0===a||a.removeEventListener("touchmove",p),null===(o=t.current)||void 0===o||o.removeEventListener("touchend",d)}},[l]),(0,a.useEffect)(()=>{if(42==l)return;u(!0);let e=setTimeout(()=>{u(!1)},500);return()=>{clearTimeout(e)}},[l]),(0,n.jsxs)("div",{className:"z-40 absolute inset-0",ref:o,children:[(0,n.jsx)("canvas",{id:"c",ref:t,className:"absolute inset-0 opacity-70"}),c&&(0,n.jsx)("div",{className:(0,d.m6)("absolute inset-0 z-20 flex flex-col items-center justify-center bg-black bg-opacity-30 text-white"),children:(0,n.jsx)("div",{className:"rounded-full bg-green-500",style:{width:l,height:l}})}),(0,n.jsxs)("div",{className:"flex flex-col space-y-2 rounded border border-gray-300 bg-gray-50 p-2 md:w-[250px] absolute left-5 bottom-5",children:[(0,n.jsxs)("div",{className:"rounded bg-gray-200 p-2 px-1 text-sm",children:[(0,n.jsxs)("div",{className:"mb-1 flex flex-row justify-between",children:[(0,n.jsx)("span",{children:"Stroke width"}),(0,n.jsxs)("span",{children:[l," px"]})]}),(0,n.jsx)(b.i,{max:72,min:5,step:1,value:[l],onValueChange:e=>{i(e[0])}})]}),(0,n.jsxs)("div",{className:"flex flex-row space-x-2",children:[(0,n.jsx)(v,{text:"Reset",icon:(0,n.jsx)(p.Z,{className:"mr-1 h-4 w-4"}),disabled:0==r.length,onClick:()=>{var e;let r=null===(e=t.current)||void 0===e?void 0:e.getContext("2d");r&&r.clearRect(0,0,t.current.width,t.current.height),s([])}}),(0,n.jsx)(v,{text:"Undo",icon:(0,n.jsx)(g.Z,{className:"mr-1 h-4 w-4"}),disabled:0==r.length,onClick:()=>{var e;let n=null===(e=t.current)||void 0===e?void 0:e.getContext("2d");if(n&&n.clearRect(0,0,t.current.width,t.current.height),1==r.length){s([]);return}{let e=r[r.length-2];null==n||n.putImageData(e,0,0),s(r.slice(0,r.length-1))}}})]})]})]})}var y=r(51652),j=r(44715),N=r(59968),k=r(14510),E=r(36437);function _(e){let{roomId:t,onClose:r}=e,[s,o]=(0,a.useState)(null);return((0,a.useEffect)(()=>{let e=async()=>{let{err:e,res:r}=await (0,N.tR)({_id:t});e?console.error("Error fetching room:",e):o(r)};t&&e()},[t]),t&&s)?(0,n.jsx)(C,{initRoom:s,onClose:r}):null}function C(e){let{initRoom:t,onClose:r}=e,[s,i]=(0,a.useState)(0),[c,u]=(0,a.useState)({...t,nonce:new Date(t.updated_at).getTime()});return((0,a.useEffect)(()=>{let e;if(["painted","paint_error","dead"].includes(c.phase))return;let t=async()=>{console.log("polling...");try{let{err:r,res:n}=await (0,N.tR)({_id:c._id});!r&&["painted","paint_error","dead"].includes(n.phase)?u({...n,nonce:new Date().getTime()}):"not_found"===r?u(e=>({...e,phase:"paint_error"})):e=setTimeout(t,1e3)}catch(e){console.error("Error fetching room:",e),u(e=>({...e,phase:"paint_error"}))}};return t(),()=>{e&&clearTimeout(e)}},[c.phase]),"painted"!==c.phase)?(0,n.jsxs)("div",{className:"absolute inset-0 flex flex-col justify-center items-center bg-black bg-opacity-50 z-40 text-white",children:["Generating 4 solutions...",(0,n.jsx)(k.Z,{seconds:c.is_plus?120:30,isDark:!0})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(o.default,{src:"".concat(E.We,"/render/").concat(c._id,"/").concat(c.key,"-").concat(c.outputs[s].seed,"-").concat(c.outputs[s].subseed,".").concat(c.outputs[s].ext,"?nonce=").concat(c.nonce),alt:"Result Images",width:c.width,height:c.height,className:"absolute inset-0 z-40"}),(0,n.jsxs)("div",{className:"absolute left-5 top-5 p-2 flex flex-col items-center space-y-2 z-50",children:[c.outputs.map((e,t)=>(0,n.jsx)("button",{onClick:()=>i(t),className:(0,d.m6)("border-4 rounded overflow-hidden",t===s?"bg-gray-200 border-green-600":"hover:bg-gray-100 border-gray-300"),children:(0,n.jsx)(o.default,{src:"".concat(E.We,"/render/").concat(c._id,"/").concat(c.key,"-").concat(e.seed,"-").concat(e.subseed,".").concat(e.ext,"?nonce=").concat(c.nonce),alt:"Result Images",width:128,height:Math.round(128*c.height/c.width),className:"object-cover w-16 h-16"})},t)),!c.is_plus&&c.outputs.length&&(0,n.jsx)(n.Fragment,{children:[1,2,3].map(e=>(0,n.jsxs)("a",{href:"/support/pricing",target:"_blank",className:(0,d.m6)("border-4 rounded overflow-hidden hover:bg-gray-100 border-gray-300 relative"),children:[(0,n.jsx)(o.default,{src:"".concat(E.We,"/render/").concat(c._id,"/").concat(c.key,"-").concat(c.outputs[0].seed,"-").concat(c.outputs[0].subseed,".").concat(c.outputs[0].ext,"?nonce=").concat(c.nonce),alt:"Result Images",width:128,height:Math.round(128*c.height/c.width),className:"object-cover w-16 h-16"}),(0,n.jsx)("div",{className:"absolute bg-black bg-opacity-80 inset-0 flex items-center justify-center",children:(0,n.jsx)(y.Z,{className:"text-white w-5 h-5"})})]},e))})]}),(0,n.jsx)("div",{className:"absolute bottom-5 w-full flex flex-row justify-center",children:(0,n.jsxs)("a",{href:"".concat(E.We,"/render/").concat(c._id,"/").concat(c.key,"-").concat(c.outputs[s].seed,"-").concat(c.outputs[s].subseed,".").concat(c.outputs[s].ext,"?nonce=").concat(c.nonce),download:!0,className:" bg-gray-200 p-2 rounded z-50 w-[120px] text-center text-sm",children:[(0,n.jsx)(j.Z,{className:"w-4 h-4 inline-block"}),"\xa0 Download"]})}),(0,n.jsxs)("button",{onClick:()=>{r()},className:"absolute top-5 right-5 text-white text-sm z-50",children:["Done \xa0",(0,n.jsx)(l.Z,{className:"w-4 h-4 inline-block"})]})]})}function S(e){let{onClose:t}=e,{state:r,dispatch:p}=(0,s.useAppContext)(),g=(0,a.useRef)(null),[b,v]=(0,a.useState)("move"),[y,j]=(0,a.useState)(null),[N,k]=(0,a.useState)(null),E=(0,a.useRef)(null),{uploadToS3:C,isUploading:S,uploadProgress:R,uploadError:D}=(0,x.F)(),[Z,I]=(0,a.useState)(!0);(0,a.useEffect)(()=>{let e=e=>{let t=e.data;"screenshot"===t.type&&(t.error?(k(t.error),console.log("Error: ".concat(t.error))):(j(t.data),console.log("Screenshot received")))};return window.addEventListener("message",e),()=>{window.removeEventListener("message",e)}},[]);let P=()=>{var e;k(null),j(null),console.log("Capturing screenshot..."),(null===(e=g.current)||void 0===e?void 0:e.contentWindow)?(g.current.contentWindow.postMessage("captureScreenshot","*"),console.log("Message sent to iframe")):(k("Unable to communicate with the map. Please try again."),console.log("Error: Unable to communicate with iframe"))};(0,a.useEffect)(()=>{"select"===b&&P()},[b]);let T=()=>{if(!E.current)return"";let e=document.createElement("canvas");e.width=E.current.width,e.height=E.current.height;let t=e.getContext("2d");t.clearRect(0,0,e.width,e.height),t.drawImage(E.current,0,0,e.width,e.height);let r=t.getImageData(0,0,e.width,e.height),n=r.data;for(let e=0;e<n.length;e+=4)0!==n[e+3]?(n[e]=255,n[e+1]=255,n[e+2]=255,n[e+3]=255):(n[e]=0,n[e+1]=0,n[e+2]=0,n[e+3]=0);return t.putImageData(r,0,0),e.toDataURL("image/png")},[M,z]=(0,a.useState)(!1),[L,O]=(0,a.useState)(!1),[A,B]=(0,a.useState)(""),[q,U]=(0,a.useState)(""),[G,F]=(0,a.useState)([]);return(0,n.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center overflow-y-scroll bg-black bg-opacity-80 p-12",onClick:()=>{M||t()},children:(0,n.jsx)("div",{className:"relative h-full w-full max-w-7xl overflow-hidden rounded bg-black",onClick:e=>e.stopPropagation(),children:Z?(0,n.jsxs)("div",{className:"z-60 absolute inset-0 flex flex-col items-center justify-center bg-black bg-opacity-90",children:[(0,n.jsx)("video",{className:"w-full max-w-3xl",src:"/earth_gif.mp4",autoPlay:!0,muted:!0,loop:!0,playsInline:!0}),(0,n.jsx)("button",{className:"mt-4 rounded bg-white px-4 py-2 text-black",onClick:()=>I(!1),children:"Got it!"})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("iframe",{id:"earth-map",ref:g,src:"https://earth.rerenderai.com",className:"h-full w-full overflow-hidden"}),(0,n.jsxs)("button",{onClick:t,className:"absolute right-12 top-2 z-50 rounded-full bg-black bg-opacity-50 px-5 py-1 text-sm text-white",children:["Close \xa0",(0,n.jsx)(l.Z,{className:"inline-block h-4 w-4"})]}),"select"===b&&(0,n.jsxs)(n.Fragment,{children:[y&&(0,n.jsx)("img",{src:y,alt:"screenshot",className:"absolute inset-0",crossOrigin:"anonymous"}),(0,n.jsx)(w,{canvasRef:E,maskHistory:G,setMaskHistory:F}),M&&(0,n.jsxs)("div",{className:"absolute inset-0 z-50 flex flex-col items-center justify-center bg-black bg-opacity-50 text-white",children:[(0,n.jsx)(i.Z,{className:"h-8 w-8 animate-spin"}),(0,n.jsx)("span",{className:"mt-2",children:"Uploading..."})]}),!L&&(0,n.jsxs)("div",{className:(0,d.m6)("absolute inset-0 z-50 flex flex-col items-center justify-center bg-black bg-opacity-70 text-white"),children:[(0,n.jsx)(o.default,{src:"/finger-painting-white.svg",width:60,height:60,alt:"Finger painting"}),(0,n.jsx)("span",{className:"my-3 text-lg text-truewhite",children:"Select the area you want to build."}),(0,n.jsx)("button",{className:"rounded border border-gray-400 px-3 py-1 text-gray-300",onClick:()=>O(!0),children:"Ok"})]})]}),(0,n.jsxs)("div",{className:"absolute bottom-5 right-5 z-40 flex w-[400px] flex-col items-end",children:[(0,n.jsxs)("div",{className:"flex flex-row space-x-2 rounded bg-white p-1 text-sm",children:[(0,n.jsxs)("button",{className:(0,d.m6)("flex flex-row items-center rounded p-2 text-xs","move"===b&&"bg-gray-800 text-white"),onClick:()=>v("move"),children:[(0,n.jsx)(c.Z,{className:"mr-1 h-4 w-4"})," Move mode"]}),(0,n.jsxs)("button",{className:(0,d.m6)("flex flex-row items-center rounded p-2 text-xs","select"===b&&"bg-gray-800 text-white"),onClick:()=>v("select"),children:[(0,n.jsx)(u.Z,{className:"mr-1 h-4 w-4"})," Edit mode"]})]}),(0,n.jsxs)("div",{className:"relative mt-2 flex w-full max-w-sm flex-col items-end rounded bg-truewhite p-2",children:[(0,n.jsx)("textarea",{className:"w-full resize-none bg-transparent text-sm outline-none",placeholder:"describe your architecture",value:A,onChange:e=>B(e.target.value),disabled:M||0===G.length}),(0,n.jsxs)("div",{className:"flex w-full flex-row justify-between",children:[!r.user.is_plus&&r.user.num_credit<=0&&(0,n.jsxs)("span",{className:"text-xs text-red-500",children:[r.wording.submit.errorNoCreditsLeft,"\xa0\xa0",(0,n.jsx)("a",{href:"/support/pricing",className:"font-bold text-gray-800 underline",children:"Click here to Upgrade"})]}),(0,n.jsx)("button",{className:(0,d.m6)("ml-auto rounded bg-green-600 p-1 text-xs text-white",("select"!==b||M||0==G.length||!A)&&"cursor-not-allowed bg-opacity-50"),disabled:"select"!==b||!y||M||!A,onClick:async()=>{if(!y)return;if(!1==r.user.is_plus&&r.user.num_credit<1){k(r.wording.submit.errorNoCreditsLeft),p({type:"OPEN_SUB_SETTINGS"});return}z(!0);let e=await C(y);console.log("File uploaded successfully: ".concat(e)),p({type:"CONSUME_CREDIT"});try{(0,f.q)({name:"earth_generate",value:r.user.is_plus?"plus":"credit"})}catch(e){}let{err:t,res:n}=await (0,h.Gg)({settings:{tool:"inpaint",main_image:e,masks:[{...m.z7,prompt:A,mask:T(),misc:{...m.z7.misc,mode:"earth"}}],model:m.pk,type:"no-type",style:"no-style",tags:[],lighting:"",color:"",texture:"",is_render:!1,is_sketch:!1,is_floorplan:!1,is_public:!0,is_detailed:!1,is_furnish:!1,is_repaint:!1,width:E.current.width,height:E.current.height}});console.log(t,n),t||U(n),z(!1)},children:"Generate"})]})]})]}),!!q&&(0,n.jsxs)("div",{style:{zIndex:60},className:"absolute inset-0",children:[(0,n.jsx)("img",{src:y,className:"absolute inset-0",crossOrigin:"anonymous"}),(0,n.jsx)(_,{roomId:q,onClose:()=>U("")})]})]})})})}function R(){let{state:e,dispatch:t}=(0,s.useAppContext)();return e.is_open_earth?(0,n.jsx)(S,{onClose:()=>{console.log("toggle onboard settings"),t({type:"TOGGLE_EARTH",payload:{open:!1}})}}):null}},62191:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return u}});var n=r(57437),s=r(2265),a=r(18075),o=r(81362),l=r(52235),i=r(79580);function c(e){let{user:t,setUser:r,updating:s,onClose:a,onUpdate:o}=e;return(0,n.jsx)("div",{className:"fixed left-0 right-0 top-0 bottom-0 bg-black bg-opacity-80 z-50 flex items-center justify-center",onClick:a,children:(0,n.jsxs)("div",{className:"border border-gray-300 rounded bg-truewhite",onClick:e=>e.stopPropagation(),children:[(0,n.jsxs)("div",{className:"p-3 border-gray-300 border-b flex flex-row justify-between items-center",children:[(0,n.jsxs)("span",{children:["Welcome to ","ReRoom","!"]}),(0,n.jsx)("button",{onClick:a,children:(0,n.jsx)(l.Z,{className:"w-5 h-5"})})]}),(0,n.jsx)("div",{className:"flex flex-col md:flex-row",children:(0,n.jsxs)("div",{className:" border-gray-300 border-b md:border-l w-[310px] p-3 space-y-3",children:[(0,n.jsx)("div",{className:"font-medium text-sm flex flex-row justify-between items-end bg-amber-100 rounded p-3 border-amber-500 border",children:(0,n.jsx)("span",{className:"text-black",children:"\uD83D\uDC4B Hello, please tell us about yourself"})}),(0,n.jsxs)("div",{className:"flex flex-col",children:[(0,n.jsx)("span",{className:"text-sm",children:"Your Name"}),(0,n.jsx)("input",{className:"p-1 rounded border-gray-300 border",value:t.name,onChange:e=>r({...t,name:e.target.value})})]}),(0,n.jsxs)("div",{className:"flex flex-col",children:[(0,n.jsx)("span",{className:"text-sm",children:"Company Name"}),(0,n.jsx)("input",{className:"p-1 rounded border-gray-300 border",value:t.company,onChange:e=>r({...t,company:e.target.value})})]})]})}),(0,n.jsxs)("div",{className:"p-3 border-gray-300 flex flex-row justify-between items-center",children:[(0,n.jsx)("button",{onClick:a,className:"text-gray-500 text-sm",children:"Skip"}),(0,n.jsx)("button",{onClick:o,className:"text-white bg-green-600 px-2 py-1 text-base rounded text-center w-[100px]",children:s?(0,n.jsx)(i.Z,{className:"w-6 h-6 animate-spin mx-auto"}):(0,n.jsx)("span",{children:"Save"})})]})]})})}function u(){let{state:e,dispatch:t}=(0,a.useAppContext)(),[r,l]=(0,s.useState)({name:e.user.name,company:e.user.company}),[i,u]=(0,s.useState)(!1);return e.is_open_onboard?(0,n.jsx)(c,{user:r,setUser:l,updating:i,onClose:()=>{console.log("toggle onboard settings"),t({type:"TOGGLE_ONBOARD_SETTINGS",payload:{open:!1}})},onUpdate:async()=>{if(i)return;u(!0);let{err:e,result:n}=await (0,o.Nq)(r);u(!1),t({type:"TOGGLE_ONBOARD_SETTINGS",payload:{open:!1}})}}):null}},64905:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return f}});var n=r(57437),s=r(2265),a=r(18075),o=r(81362),l=r(18992),i=r(8792),c=r(52235),u=r(51367),d=r(90029),m=r(34187);function h(e){let{isPlus:t,text:r}=e;return(0,n.jsxs)("div",{className:"flex flex-row items-center my-1",children:[(0,n.jsx)(m.Z,{className:(0,u.m6)("w-4 h-4 mr-2 shrink-0 text-gray-500",t&&"text-green-500")})," ",r]})}function x(e){let{wording:t,user:r,loading:s,isAnnual:a,setIsAnnual:o,onClose:l,onSignOut:m,onUpgrade:x}=e,f=t.subscription.freeFeatures,p=t.subscription.plusFeatures,g=parseInt("25"),b="mo";return a&&(g=parseInt("250")/12,b="mo"),(0,n.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center overflow-y-scroll bg-black bg-opacity-80",onClick:l,children:(0,n.jsxs)("div",{className:"rounded border border-gray-300 bg-truewhite",onClick:e=>e.stopPropagation(),children:[(0,n.jsxs)("div",{className:"flex flex-row items-center justify-between border-b border-gray-300 p-3",children:[(0,n.jsx)("span",{children:""!==r.uid?t.subscription.yourAccount:"Pricing"}),(0,n.jsx)("button",{onClick:l,children:(0,n.jsx)(c.Z,{className:"h-5 w-5"})})]}),r.uid&&r.is_plus&&(0,n.jsxs)("div",{className:"border-b border-gray-300 p-3",children:[(0,n.jsxs)("div",{className:"flex flex-row items-center justify-between text-xs",children:[(0,n.jsx)("span",{children:r.is_plus?(0,n.jsx)("div",{className:"-ml-1 rounded bg-green-200 px-1 font-bold text-green-700",children:"Pro account"}):(0,n.jsx)("div",{className:"-ml-1 rounded bg-gray-100 px-1 text-gray-700",children:"Free account"})}),(0,n.jsx)("button",{onClick:m,className:"text-gray-500 underline",children:"sign out"})]}),(0,n.jsx)("div",{className:"text-sm font-medium",children:r.email})]}),(0,n.jsxs)("div",{className:"flex flex-col md:flex-row",children:[!r.is_plus&&(0,n.jsxs)("div",{className:"w-[310px] border-b border-gray-300 p-3 md:border-l",children:[(0,n.jsx)("div",{className:"mb-3 flex flex-row items-end justify-between text-lg font-medium",children:(0,n.jsx)("span",{className:"text-black",children:t.subscription.freeTrial})}),""!==r.uid&&(0,n.jsx)(d.Z,{text:t.subscription.currentPlan,icon:null,onClick:()=>{},color:"bg-slate-600",disabled:!0,isAnnual:a,loading:!1}),(0,n.jsx)("div",{className:(0,u.m6)("mt-3",f.length<=4?"text-base":"text-sm"),children:f.map((e,t)=>(0,n.jsx)(h,{isPlus:!1,text:e},t))})]}),(0,n.jsxs)("div",{className:"w-[310px] border-b border-gray-300 p-3 md:border-l",children:[(0,n.jsxs)("div",{className:"mb-3 flex flex-row items-end justify-between text-lg font-bold",children:[-1!==["wvp"].indexOf("rerender")?(0,n.jsx)("span",{className:"text-black",children:"Pro Plan"}):(0,n.jsxs)("span",{className:"text-black",children:["ReRoom"," Pro"]}),!r.is_plus&&(0,n.jsxs)("div",{className:"text-right text-gray-500",children:["USD $",g%1==0?g:g.toFixed(2),(0,n.jsxs)(n.Fragment,{children:["/",b]})]})]}),""!==r.uid&&(0,n.jsx)(n.Fragment,{children:r.is_plus?(0,n.jsx)(d.Z,{text:t.subscription.currentPlan,icon:null,onClick:()=>{},color:"bg-slate-600",disabled:!0,isAnnual:a,loading:s}):(0,n.jsx)(d.Z,{text:t.subscription.upgradePlan,icon:null,onClick:x,color:"bg-green-600",disabled:!1,isAnnual:a,loading:s})}),(0,n.jsx)("div",{className:(0,u.m6)("mt-3",f.length<=4?"text-base":"text-sm"),children:p.map((e,t)=>(0,n.jsx)(h,{isPlus:!0,text:e},t))}),r.is_plus&&(0,n.jsx)(i.default,{target:"_blank",href:"https://billing.stripe.com/p/login/dR6dUcaL0eBF7F63cc",children:(0,n.jsx)("div",{className:"mt-1 w-full text-center text-sm text-slate-500",children:(0,n.jsx)("span",{className:"text-center underline",children:t.subscription.manageMySubscription})})})]})]}),!r.is_plus&&(0,n.jsxs)("div",{className:"bg-gray-50 p-2 text-center text-sm",children:[(0,n.jsx)("div",{children:t.subscription.annualCta}),(0,n.jsx)("div",{className:"mt-2",children:(0,n.jsxs)("label",{className:"relative inline-flex cursor-pointer items-center",children:[(0,n.jsx)("input",{type:"checkbox",value:"",className:"peer sr-only",checked:a,onChange:e=>{o(e.target.checked)}}),(0,n.jsx)("div",{className:"peer h-6 w-11 rounded-full bg-gray-200 after:absolute after:left-[2px] after:top-[2px] after:h-5 after:w-5 after:rounded-full after:border after:border-gray-300 after:bg-white after:transition-all after:content-[''] peer-checked:bg-blue-600 peer-checked:after:translate-x-full peer-checked:after:border-white peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 dark:border-gray-600 dark:bg-gray-700 dark:peer-focus:ring-blue-800"})]})})]})]})})}function f(){let{state:e,dispatch:t}=(0,a.useAppContext)(),[r,i]=(0,s.useState)(!1),[c,u]=(0,s.useState)(!1);return e.is_open_subscription?(0,n.jsx)(x,{user:e.user,loading:r,wording:e.wording,isAnnual:c,setIsAnnual:u,onUpgrade:async()=>{try{window.fbq("track","AddPaymentInfo",{external_id:e.user.uid})}catch(e){console.log(e)}if((0,l.q)({name:"add_payment_info",value:c?"annual":"monthly"}),r)return;i(!0);let{err:t,res:n}=await (0,o.CH)({is_annual:c});t?i(!1):window.location.href=n.url},onClose:()=>{t({type:"CLOSE_SUB_SETTINGS"})},onSignOut:()=>{(0,l.q)({name:"sign_out",value:""}),document.cookie="authToken=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/; domain=".concat(".reroom.ai","; secure;"),window.location.reload()}}):null}},39849:function(e,t,r){"use strict";var n=r(57437),s=r(2265);t.Z=e=>{let{duration:t,barHeight:r,textColor:a,showTime:o=!0}=e,l=s.useRef(null),[i,c]=(0,s.useState)(0);return(0,s.useEffect)(()=>{let e=Date.now();l.current=e;let r=setInterval(()=>{let n=Math.min((Date.now()-e)/t*100,99);n>=99?(c(99),clearInterval(r)):c(n)},20);return()=>clearInterval(r)},[t]),(0,n.jsxs)("div",{className:"flex w-full flex-col items-center gap-2",children:[o&&(0,n.jsxs)("span",{className:"text-lg ".concat(a||"text-gray-700"),children:[i.toFixed(0),"%"]}),(0,n.jsx)("div",{className:"flex w-full rounded bg-gray-300 ".concat(r||"h-1"),children:(0,n.jsx)("div",{className:"h-full rounded bg-gray-600",style:{width:"".concat(i,"%"),transition:"width 0.1s ease-in-out"}})})]})}},14510:function(e,t,r){"use strict";var n=r(57437),s=r(2265),a=r(51367),o=r(79580),l=r(10500);t.Z=e=>{let{seconds:t,isDark:r,processing:i}=e,[c,u]=(0,s.useState)(i?Math.min(i/t*99,99):5*Math.random());return(0,s.useEffect)(()=>{let e=setInterval(()=>{u(r=>r>=99?(clearInterval(e),99):Math.min(r+99/t,99))},1e3);return()=>clearInterval(e)},[]),(0,n.jsxs)("div",{className:(0,a.m6)("my-10 flex w-full flex-col items-center justify-center",r?"text-white":"text-black"),children:[r&&(0,n.jsx)(o.Z,{className:"h-10 w-10 animate-spin"}),(0,n.jsxs)("span",{className:"text-lg",children:[c.toFixed(2),"%"]}),!r&&(0,n.jsx)("div",{className:"w-1/2",children:(0,n.jsx)(l.E,{value:c})})]})}},31075:function(e,t,r){"use strict";r.d(t,{Z:function(){return s}});var n=r(57437);function s(){return(0,n.jsx)(n.Fragment,{children:(0,n.jsx)("div",{className:"",children:(0,n.jsx)("video",{width:"",height:"360",autoPlay:!0,loop:!0,muted:!0,playsInline:!0,preload:"none",poster:"https://".concat("ReRoom",".s3.amazonaws.com/assets/inpaint_intro_v0.jpg"),children:(0,n.jsx)("source",{src:"https://".concat("ReRoom",".s3.eu-central-1.amazonaws.com/assets/inpaint_draw.mp4"),type:"video/mp4"})})})})}},98235:function(e,t,r){"use strict";var n=r(57437),s=r(51367);t.Z=e=>{let{onClick:t,disabled:r,icon:a,title:o,className:l,shape:i="rectangle",direction:c="horizontal",variant:u="green",fullWidth:d=!0}=e,m=(0,s.m6)("flex items-center justify-center","gap-2 px-3 py-3","rectangle"===i?"rounded-md":"rounded-full",r?"text-truewhite bg-stone-200 cursor-not-allowed":"green"===u?"text-truewhite transition-bg bg-green-600 hover:bg-green-700 active:bg-green-800":"white"===u?"text-black bg-truewhite border border-gray-200 hover:bg-gray-100 active:bg-gray-200":"transition-bg bg-blue-600 hover:bg-blue-700 active:bg-blue-800",d?"w-full":"","vertical"===c?"flex-col":"",l);return(0,n.jsxs)("button",{className:m,onClick:t,disabled:r,children:[!!a&&a,!!o&&(0,n.jsx)("span",{children:o})]})}},90029:function(e,t,r){"use strict";r.d(t,{Z:function(){return o}});var n=r(57437),s=r(51367),a=r(79580);function o(e){let{icon:t,text:r,onClick:o,color:l,disabled:i,isAnnual:c,loading:u}=e,d=(0,n.jsx)(a.Z,{className:"h-5 w-5 animate-spin"});return(0,n.jsxs)("button",{className:(0,s.m6)("flex flex-row items-center justify-center p-2 rounded cursor-pointer text-slate-50 w-full",l,(i||u)&&"opacity-50"),onClick:o,disabled:i||u,children:[u?d:t,(0,n.jsx)("span",{className:"ml-2 font-bold text-base",children:r})]})}},19231:function(e,t,r){"use strict";r.d(t,{$n:function(){return i},LK:function(){return u},X0:function(){return c},Zu:function(){return m},gP:function(){return h},h6:function(){return o},kg:function(){return l},vn:function(){return d}});var n=r(57437),s=r(62985),a=r(18075);let o=()=>{let{state:{wording:{toast:{noMask:e}}}}=(0,a.useAppContext)();return(0,n.jsxs)("div",{className:"flex items-center rounded-md",children:[(0,n.jsx)(s.Z,{className:"mr-2 h-4 w-4"}),(0,n.jsx)("span",{children:e})]})},l=()=>{let{state:{wording:{toast:{hasMask:e}}}}=(0,a.useAppContext)();return(0,n.jsxs)("div",{className:"flex items-center rounded-md",children:[(0,n.jsx)(s.Z,{className:"mr-2 h-4 w-4"}),(0,n.jsx)("span",{children:e})]})},i=()=>{let{state:{wording:{toast:{noTypeOrStyle:e}}}}=(0,a.useAppContext)();return(0,n.jsxs)("div",{className:"flex items-center rounded-md",children:[(0,n.jsx)(s.Z,{className:"mr-2 h-4 w-4"}),(0,n.jsx)("span",{children:e})]})},c=()=>{let{state:{wording:{toast:{noPrompt:e}}}}=(0,a.useAppContext)();return(0,n.jsxs)("div",{className:"flex items-center rounded-md",children:[(0,n.jsx)(s.Z,{className:"mr-2 h-4 w-4"}),(0,n.jsx)("span",{children:e})]})},u=()=>{let{state:{wording:{toast:{noOptionOrPrompt:e}}}}=(0,a.useAppContext)();return(0,n.jsxs)("div",{className:"flex items-center rounded-md",children:[(0,n.jsx)(s.Z,{className:"mr-2 h-4 w-4"}),(0,n.jsx)("span",{children:e})]})},d=()=>{let{state:{wording:{toast:{submitError:e}}}}=(0,a.useAppContext)();return(0,n.jsxs)("div",{className:"flex items-center rounded-md",children:[(0,n.jsx)(s.Z,{className:"mr-2 h-4 w-4"}),(0,n.jsx)("span",{children:e})]})},m=()=>{let{state:{wording:{toast:{isProcessing:e}}}}=(0,a.useAppContext)();return(0,n.jsxs)("div",{className:"flex items-center rounded-md",children:[(0,n.jsx)(s.Z,{className:"mr-2 h-4 w-4"}),(0,n.jsx)("span",{children:e})]})},h=()=>{let{state:{wording:{toast:{noImageToRender:e}}}}=(0,a.useAppContext)();return(0,n.jsxs)("div",{className:"flex items-center rounded-md",children:[(0,n.jsx)(s.Z,{className:"mr-2 h-4 w-4"}),(0,n.jsx)("span",{children:e})]})}},85754:function(e,t,r){"use strict";r.d(t,{d:function(){return i},z:function(){return c}});var n=r(57437),s=r(2265),a=r(59143),o=r(57742),l=r(4009);let i=(0,o.j)("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),c=s.forwardRef((e,t)=>{let{className:r,variant:s,size:o,asChild:c=!1,...u}=e,d=c?a.g7:"button";return(0,n.jsx)(d,{className:(0,l.cn)(i({variant:s,size:o,className:r})),ref:t,...u})});c.displayName="Button"},45179:function(e,t,r){"use strict";r.d(t,{I:function(){return o}});var n=r(57437),s=r(2265),a=r(4009);let o=s.forwardRef((e,t)=>{let{className:r,type:s,...o}=e;return(0,n.jsx)("input",{type:s,className:(0,a.cn)("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",r),ref:t,...o})});o.displayName="Input"},10500:function(e,t,r){"use strict";r.d(t,{E:function(){return l}});var n=r(57437),s=r(2265),a=r(91632),o=r(4009);let l=s.forwardRef((e,t)=>{let{className:r,value:s,...l}=e;return(0,n.jsx)(a.fC,{ref:t,className:(0,o.cn)("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",r),...l,children:(0,n.jsx)(a.z$,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:"translateX(-".concat(100-(s||0),"%)")}})})});l.displayName=a.fC.displayName},40992:function(e,t,r){"use strict";r.d(t,{i:function(){return l}});var n=r(57437),s=r(2265),a=r(91819),o=r(4009);let l=s.forwardRef((e,t)=>{let{className:r,...s}=e;return(0,n.jsxs)(a.fC,{ref:t,className:(0,o.cn)("relative flex w-full touch-none select-none items-center",r),...s,children:[(0,n.jsx)(a.fQ,{className:"relative h-1.5 w-full grow overflow-hidden rounded-full bg-primary/20",children:(0,n.jsx)(a.e6,{className:"absolute h-full bg-primary"})}),(0,n.jsx)(a.bU,{className:"block h-4 w-4 rounded-full border border-primary/50 bg-background shadow transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"})]})});l.displayName=a.fC.displayName},2828:function(e,t,r){"use strict";r.d(t,{x:function(){return g}});var n=r(57437),s=r(2265),a=r(62177),o=r(18962),l=r(57742),i=r(4009);let c=o.zt,u=s.forwardRef((e,t)=>{let{className:r,position:s="bottom-left",...a}=e;return(0,n.jsx)(o.l_,{ref:t,className:(0,i.cn)("fixed z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:max-w-[420px]","top-left"===s&&"left-0 top-0","top-right"===s&&"right-0 top-0","bottom-left"===s&&"bottom-0 left-0","bottom-right"===s&&"bottom-0 right-0","bottom-center"===s&&"bottom-0 left-1/2 -translate-x-1/2",r),...a})});u.displayName=o.l_.displayName;let d=(0,l.j)("group pointer-events-auto relative flex w-full items-center justify-between space-x-2 overflow-hidden rounded-md border p-4 pr-6 shadow-lg transition-all data-[swipe=cancel]:translate-y-0 data-[swipe=end]:translate-y-[var(--radix-toast-swipe-end-y)] data-[swipe=move]:translate-y-[var(--radix-toast-swipe-move-y)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-bottom-full data-[state=open]:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),m=s.forwardRef((e,t)=>{let{className:r,variant:s,...a}=e;return(0,n.jsx)(o.fC,{ref:t,className:(0,i.cn)(d({variant:s}),r),...a})});m.displayName=o.fC.displayName,s.forwardRef((e,t)=>{let{className:r,...s}=e;return(0,n.jsx)(o.aU,{ref:t,className:(0,i.cn)("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium transition-colors hover:bg-secondary focus:outline-none focus:ring-1 focus:ring-ring disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",r),...s})}).displayName=o.aU.displayName;let h=s.forwardRef((e,t)=>{let{className:r,...s}=e;return(0,n.jsx)(o.x8,{ref:t,className:(0,i.cn)("absolute right-1 top-1 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-1 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",r),"toast-close":"",...s,children:(0,n.jsx)(a.Pxu,{className:"h-4 w-4"})})});h.displayName=o.x8.displayName;let x=s.forwardRef((e,t)=>{let{className:r,...s}=e;return(0,n.jsx)(o.Dx,{ref:t,className:(0,i.cn)("text-sm font-semibold [&+div]:text-xs",r),...s})});x.displayName=o.Dx.displayName;let f=s.forwardRef((e,t)=>{let{className:r,...s}=e;return(0,n.jsx)(o.dk,{ref:t,className:(0,i.cn)("text-sm opacity-90",r),...s})});f.displayName=o.dk.displayName;var p=r(47788);function g(){var e;let{toasts:t}=(0,p.pm)();return(0,n.jsxs)(c,{children:[t.map(function(e){let{id:t,title:r,description:s,action:a,position:o,...l}=e;return(0,n.jsxs)(m,{...l,children:[(0,n.jsxs)("div",{className:"grid gap-1",children:[r&&(0,n.jsx)(x,{children:r}),s&&(0,n.jsx)(f,{children:s})]}),a,(0,n.jsx)(h,{})]},t)}),(0,n.jsx)(u,{position:(null===(e=t[0])||void 0===e?void 0:e.position)||"bottom-left"})," "]})}},47788:function(e,t,r){"use strict";r.d(t,{pm:function(){return m}});var n=r(2265);let s=0,a=new Map,o=e=>{if(a.has(e))return;let t=setTimeout(()=>{a.delete(e),u({type:"REMOVE_TOAST",toastId:e})},1e6);a.set(e,t)},l=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,1)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(e=>e.id===t.toast.id?{...e,...t.toast}:e)};case"DISMISS_TOAST":{let{toastId:r}=t;return r?o(r):e.toasts.forEach(e=>{o(e.id)}),{...e,toasts:e.toasts.map(e=>e.id===r||void 0===r?{...e,open:!1}:e)}}case"REMOVE_TOAST":if(void 0===t.toastId)return{...e,toasts:[]};return{...e,toasts:e.toasts.filter(e=>e.id!==t.toastId)}}},i=[],c={toasts:[]};function u(e){c=l(c,e),i.forEach(e=>{e(c)})}function d(e){let{...t}=e,r=(s=(s+1)%Number.MAX_VALUE).toString(),n=()=>u({type:"DISMISS_TOAST",toastId:r});return u({type:"ADD_TOAST",toast:{...t,id:r,open:!0,onOpenChange:e=>{e||n()}}}),{id:r,dismiss:n,update:e=>u({type:"UPDATE_TOAST",toast:{...e,id:r}})}}function m(){let[e,t]=n.useState(c);return n.useEffect(()=>(i.push(t),()=>{let e=i.indexOf(t);e>-1&&i.splice(e,1)}),[e]),{...e,toast:d,dismiss:e=>u({type:"DISMISS_TOAST",toastId:e})}}},88146:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return eA}});var n=r(57437),s=r(2265),a=r(51367),o=r(18075),l=r(20703),i=r(57759),c=r(53879),u=r(45751),d=r(96396),m=r(74395),h=r(70712),x=r(68584),f=r(15652),p=r(53931),g=r(9689),b=r(49578),v=r(60784),w=r(53348),y=r(51652),j=r(52235),N=r(80037),k=r(44715),E=r(85270),_=r(57979),C=r(18992),S=r(23362),R=r(36437),D=e=>{let{position:t,children:r,className:s}=e;return(0,n.jsx)("div",{id:"whiteboard-side-menu",className:(0,a.m6)("relative z-40 flex h-full flex-col items-center border-gray-100 bg-truewhite","left"===t?"left-0 flex justify-center rounded-bl-lg border-r-2 px-3":"right-0 hidden min-w-60 justify-start rounded-br-lg border-l-2 p-4 md:flex md:min-w-72",s),children:r})},Z=r(42527),I=r(12882),P=r(51675),T=r(12161),M=r(10702),z=r(4009),L=r(85159),O=r(23441);let A=(e,t)=>{for(let r of t)for(let t in r)if(t===e)return r[t];return""};var B=e=>{let{title:t,Icon:r,currentKey:o,options:l,onSelect:i,disabled:c=!1,device:u="desktop",zIndex:d=40}=e,[m,h]=(0,s.useState)(""),[x,f]=(0,s.useState)(!1),p=(0,s.useRef)(null),g=(0,s.useRef)(null);(0,s.useEffect)(()=>{h(o?A(o,l):"")},[o]),(0,s.useEffect)(()=>{let e=e=>{var t,r;(null===(t=p.current)||void 0===t?void 0:t.contains(e.target))||(null===(r=g.current)||void 0===r?void 0:r.contains(e.target))||f(!1)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[]);let b=m&&!x?"bg-stone-200":"bg-truewhite",v=c?"text-stone-200":"text-black";return 0===Object.keys(l).length?null:(0,n.jsx)(n.Fragment,{children:(0,n.jsx)("div",{className:(0,a.m6)("relative min-h-10 w-full rounded-md text-sm font-medium",b),style:{zIndex:d},children:(0,n.jsxs)("div",{className:(0,a.m6)("group absolute left-0 top-0 flex w-full flex-col justify-start text-nowrap rounded-md border-1 shadow-[rgba(0,_0,_0,_0.1)_1px_1px_2px] focus:outline-none",m&&!x?"border-gray-500":"border-stone-200"),onClick:""===m?()=>{f(e=>!e)}:()=>{i(""),h("")},children:[(0,n.jsxs)("button",{ref:g,className:(0,a.m6)("flex w-full items-center justify-between gap-2 rounded-md px-2 py-2",v,b),disabled:c,children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 px-1",children:[r,(0,n.jsx)("p",{className:(0,a.m6)("text-sm",v),children:m||t})]}),""===m?x?(0,n.jsx)(L.Z,{className:(0,a.m6)("pointer-events-none h-5 w-5",v)}):(0,n.jsx)(O.Z,{className:(0,a.m6)("pointer-events-none h-5 w-5",v)}):(0,n.jsx)(j.Z,{className:(0,a.m6)("pointer-events-none h-5 w-5",v)})]}),x&&(0,n.jsx)(n.Fragment,{children:(0,n.jsx)("div",{ref:p,className:(0,a.m6)("z-40 w-full overflow-y-auto rounded-md bg-truewhite px-2 py-1","mobile"===u?"max-h-40":"max-h-80"),children:l.map((e,t)=>(0,n.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,n.jsx)("div",{className:"mx-2 border-t-[1px] border-stone-200"}),Object.entries(e).map(e=>{let[r,s]=e;return(0,n.jsx)("div",{className:(0,a.m6)("text-sx mx-2 cursor-pointer rounded-md bg-truewhite px-3 py-1",r!==o&&"hover:bg-stone-200/50",r===o&&"bg-stone-200"),onClick:()=>{i(r),h(s)},children:s},"item-".concat(t,"-").concat(r))})]},"option-".concat(t)))})})]})})})},q=e=>{let{misc:t,prompt:r,typeStyle:l,setMisc:i,setPrompt:c,setTypeStyle:u,device:d="desktop"}=e,{state:{wording:m}}=(0,o.useAppContext)(),h=(0,s.useMemo)(()=>{let e=""!==r;for(let r of Object.keys(m.editor.dropdown||{}))if(""!==t[(0,z.a1)(r)]){e=!0;break}return e},[t,r]);return(0,n.jsx)(n.Fragment,{children:(0,n.jsxs)("div",{className:(0,a.m6)("flex w-full flex-col items-center justify-start","mobile"===d?"gap-3":"gap-4",t.mode===E.Gt.Change&&"flex-grow"),children:[t.mode===E.Gt.Style&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(B,{title:m.editor.mode.style.dropdown.type.title,Icon:(0,n.jsx)(Z.Z,{}),currentKey:l.type===_.w6?"":l.type,options:[m.renderTypes],onSelect:e=>{u({type:""===e?_.w6:e,style:l.style})},disabled:!1,device:d,zIndex:9}),(0,n.jsx)(B,{title:m.editor.mode.style.dropdown.style.title,Icon:(0,n.jsx)(I.Z,{}),currentKey:l.style===_.UU?"":l.style,options:[m.renderStyles],onSelect:e=>{u({type:l.type,style:""===e?_.UU:e})},disabled:!1,device:d,zIndex:8})]}),"desktop"===d&&(0,n.jsx)(n.Fragment,{children:t.mode===E.Gt.Change&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(B,{title:m.editor.dropdown.decoration.title,Icon:(0,n.jsx)(P.Z,{}),currentKey:t.decoration,options:[m.editor.dropdown.decoration.content],onSelect:e=>{i(t=>({...t,decoration:e}))},disabled:h&&""===t.decoration,zIndex:10}),(0,n.jsx)(B,{title:m.editor.dropdown.furniture.title,Icon:(0,n.jsx)(T.Z,{}),currentKey:t.furniture,options:[m.editor.dropdown.furniture.content],onSelect:e=>{i(t=>({...t,furniture:e}))},disabled:h&&""===t.furniture,zIndex:9}),(0,n.jsx)(B,{title:m.editor.dropdown.creature.title,Icon:(0,n.jsx)(M.Z,{}),currentKey:t.creature,options:[m.editor.dropdown.creature.content],onSelect:e=>{i(t=>({...t,creature:e}))},disabled:h&&""===t.creature,zIndex:8}),(0,n.jsxs)("div",{className:"flex h-3 w-full items-center gap-2",children:[(0,n.jsx)("div",{className:"flex-grow border-t-2 border-stone-200"}),(0,n.jsx)("span",{className:"text-gray-500",children:m.or}),(0,n.jsx)("div",{className:"flex-grow border-t-2 border-stone-200"})]})]}),!1]})}),t.mode===E.Gt.Change&&(0,n.jsx)(n.Fragment,{children:(0,n.jsx)("textarea",{value:r,onChange:e=>c(e.target.value),className:(0,a.m6)("w-full flex-grow resize-none rounded-md border-0 border-1 border-gray-200 bg-truewhite p-4 text-gray-500 focus:border-gray-200 focus:outline-none focus:ring-0","mobile"===d?"min-h-20 text-base":"min-h-20 text-sm",h&&""===r?"placeholder-stone-200":""),placeholder:m.editor.mode.change.placeholder,disabled:h&&""===r})})]})})},U=r(50489),G=r(52547),F=r(98235),W=e=>{let{remove:t,empty:r,device:s="desktop"}=e,{state:{wording:{or:l}}}=(0,o.useAppContext)();return(0,n.jsx)(n.Fragment,{children:(0,n.jsxs)("div",{className:(0,a.m6)("flex w-full flex-col gap-3","mobile"===s?"gap-1":"gap-3"),children:[(0,n.jsx)(F.Z,{onClick:t.fcn,disabled:t.disabled,icon:(0,n.jsx)(U.Z,{className:"h-5 w-5",color:"white"}),title:t.title}),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"flex w-full items-center gap-2",children:[(0,n.jsx)("div",{className:"flex-grow border-t-2 border-stone-200"}),(0,n.jsx)("span",{className:"text-gray-500",children:l}),(0,n.jsx)("div",{className:"flex-grow border-t-2 border-stone-200"})]}),(0,n.jsx)(F.Z,{onClick:r.fcn,disabled:r.disabled,icon:(0,n.jsx)(G.UV,{className:"h-5 w-5",color:"white"}),title:r.title})]})]})})};function X(e){let{name:t,selected:r,disabled:o,onClick:l,renderIcon:i,renderControl:c,className:u=""}=e,[d,m]=(0,s.useState)(!1),[h,x]=(0,s.useState)(!1),f=(0,s.useRef)(null),p=(0,s.useRef)(null),g=i((0,a.m6)(o?"text-black":r?"text-stone-200":"text-black group-active:text-white"));return(0,s.useEffect)(()=>{function e(e){p.current&&!p.current.contains(e.target)&&f.current&&!f.current.contains(e.target)&&m(!1)}return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}},[]),(0,n.jsxs)("div",{ref:f,className:(0,a.m6)("group relative flex aspect-square w-7 cursor-pointer items-center justify-center rounded-sm p-1 lg:w-8",o?"cursor-not-allowed":r?"bg-gray-600":"bg-transparent hover:bg-stone-200 active:bg-gray-600",u),onClick:e=>{o||(l(),p.current&&!p.current.contains(e.target)&&m(e=>!e))},onMouseEnter:()=>!d&&x(!0),onMouseLeave:()=>x(!1),children:[g,!!c&&c(p,d?"block":"hidden"),h&&!d&&(0,n.jsx)("div",{className:"absolute -right-6 z-50 translate-x-full select-none text-nowrap rounded border-1 border-gray-200 bg-truewhite px-1 py-[0.5px] text-xs text-black",children:t})]})}var Y=e=>{let{mode:t,modeName:r,isCurrentMode:s,setEditMode:o}=e;return(0,n.jsx)("button",{className:(0,a.m6)("flex h-8 items-center justify-center rounded-md text-xs font-medium",s?"bg-gray-600 text-white":"text-black hover:bg-stone-200"),onClick:()=>o(t),children:r})},Q=e=>{let{editMode:t,modeNames:r,setEditMode:s}=e;return(0,n.jsxs)("div",{className:"mb-4 grid w-full grid-cols-3 gap-1 rounded-md border-1 border-gray-200 p-1",children:[(0,n.jsx)(Y,{mode:E.Gt.Style,modeName:r.style,isCurrentMode:t===E.Gt.Style,setEditMode:s}),(0,n.jsx)(Y,{mode:E.Gt.Change,modeName:r.change,isCurrentMode:t===E.Gt.Change,setEditMode:s}),(0,n.jsx)(Y,{mode:E.Gt.Remove,modeName:r.remove,isCurrentMode:t===E.Gt.Remove||t===E.Gt.EmptyMyRoom,setEditMode:s})]})},J=r(99520),H=r(39849),K=r(49108),V=r(37805),$=e=>{let{slides:t,nShow:r,startId:o=1,selectedId:i,onSelect:c,onDownload:u,disabled:d,device:m="desktop"}=e,[h,x]=(0,s.useState)(o),f=(0,s.useCallback)(()=>{x(e=>Math.min(e+1,t.length-r))},[t.length]),p=(0,s.useCallback)(()=>{x(e=>Math.max(e-1,o))},[o]),g=(0,s.useMemo)(()=>e=>e?"text-stone-300":"text-stone-600 hover:text-stone-800",[]);(0,s.useEffect)(()=>{t.length>r&&x(t.length-r)},[t.length,r]);let b=(0,s.useMemo)(()=>t.slice(h,h+r),[t,h,r]),v=(0,s.useMemo)(()=>(0,a.m6)("relative flex h-full max-w-2xl flex-row justify-center items-center","desktop"===m&&"w-full lg:w-auto xl:px-6","mobile"===m&&""),[m]),w=(0,s.useMemo)(()=>(0,a.m6)("border-3 relative overflow-hidden rounded-md border-stone-200 bg-stone-50 select-none","desktop"===m&&"flex-1 aspect-auto lg:aspect-square h-full","mobile"===m&&"aspect-square h-20 w-20"),[m]),y=h===o,j=h+r>=t.length;return(0,n.jsxs)("div",{className:v,children:[(0,n.jsx)("button",{onClick:p,className:(0,a.m6)("z-10",g(y)),"aria-label":"Previous Slide",disabled:y,children:(0,n.jsx)(K.Z,{className:"h-12 w-12"})}),(0,n.jsxs)("div",{className:"flex h-full w-full flex-1 space-x-2 overflow-hidden",children:[b.map((e,t)=>{let r=i===h+t;return(0,n.jsxs)("div",{className:(0,a.m6)(d?"cursor-not-allowed":"cursor-pointer",w,r&&"border-gray-600"),onClick:()=>{d||c(h+t)},children:[(0,n.jsx)(l.default,{src:e.url,sizes:"(max-width: 600px) 100vw, 25vw",width:e.width/6,height:e.height/6,alt:"Slide ".concat(e.url),className:(0,a.m6)("h-full w-full object-cover")}),(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),u(e.url)},className:(0,a.m6)("absolute rounded-full bg-white shadow-md hover:bg-stone-200 active:bg-stone-200","desktop"===m&&"bottom-2 right-2 p-2","mobile"===m&&"bottom-1 right-1 p-1"),children:(0,n.jsx)(k.Z,{className:"h-3 w-3"})})]},"".concat(e.url,"-").concat(t))}),Array(r-b.length).fill(null).map((e,t)=>(0,n.jsx)("div",{className:w},"blank-".concat(t)))]}),(0,n.jsx)("button",{onClick:f,className:(0,a.m6)("z-10",g(j)),"aria-label":"Next Slide",disabled:j,children:(0,n.jsx)(V.Z,{className:"h-12 w-12"})})]})},ee=e=>{let{children:t,className:r=""}=e;return(0,n.jsx)("div",{className:(0,a.m6)("absolute inset-0 z-50 flex flex-col items-center justify-center bg-black bg-opacity-40 text-white",r),children:t})},et=e=>{let{maskMode:t,hints:r}=e,{state:{wording:{ok:a}}}=(0,o.useAppContext)(),[i,c]=(0,s.useState)(()=>Object.values(E.ED).reduce((e,t)=>(t!==E.ED.None&&(e[t]=!1),e),{})),u=e=>{c(t=>({...t,[e]:!0}))};return t===E.ED.None||i[t]?null:(0,n.jsx)(ee,{children:(0,n.jsxs)("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 p-8 text-center",children:[(0,n.jsx)("div",{className:"min-w-1/2 relative h-2/3 w-full max-w-[500px]",children:(0,n.jsx)(l.default,{src:S.SE[t],fill:!0,sizes:"(max-width: 600px) 550px, 800px",alt:"Hint Image",className:"object-contain"})}),(0,n.jsx)("span",{className:"mb-4 text-2xl text-truewhite",children:r[t]}),(0,n.jsx)("button",{className:"rounded border-2 border-gray-200 px-8 py-2 text-gray-200",onClick:()=>u(t),children:a})]})})},er=r(69102),en=r.n(er);function es(e){let{min:t,max:r,step:a,val:o,onChange:l}=e,[i,c]=(0,s.useState)(o),u=(i-t)/(r-t)*100;return(0,n.jsxs)("div",{className:"jsx-18334e4f8c3dfc2b relative mx-auto flex w-full flex-col gap-2",children:[(0,n.jsx)("div",{style:{left:"".concat(u,"%")},className:"jsx-18334e4f8c3dfc2b pointer-events-none rounded-md px-2 py-1 text-center text-xs text-white"}),(0,n.jsx)("input",{type:"range",min:t,max:r,step:a,value:i,onChange:e=>{let t=Number(e.target.value);c(t),l(t)},style:{background:"linear-gradient(to right, #6b7280 0%, #6b7280 ".concat(u,"%, #e7e5e4 ").concat(u,"%, #e7e5e4 100%)")},className:"jsx-18334e4f8c3dfc2b h-1 w-full cursor-pointer appearance-none rounded-lg bg-gray-200"}),(0,n.jsx)(en(),{id:"18334e4f8c3dfc2b",children:'input[type="range"].jsx-18334e4f8c3dfc2b::-webkit-slider-thumb{-webkit-appearance:none;-moz-appearance:none;-ms-appearance:none;appearance:none;width:24px;height:24px;background-color:#fff;-webkit-border-radius:50%;-moz-border-radius:50%;border-radius:50%;cursor:pointer;-webkit-transition:background-color.15s ease-in-out;-moz-transition:background-color.15s ease-in-out;-o-transition:background-color.15s ease-in-out;transition:background-color.15s ease-in-out;-webkit-box-shadow:rgba(0,0,0,.35).2px .2px 1px 1.4px;-moz-box-shadow:rgba(0,0,0,.35).2px .2px 1px 1.4px;box-shadow:rgba(0,0,0,.35).2px .2px 1px 1.4px}input[type="range"].jsx-18334e4f8c3dfc2b::-webkit-slider-thumb:hover{background-color:#fff}input[type="range"].jsx-18334e4f8c3dfc2b::-moz-range-thumb{width:24px;height:24px;background-color:#fff;-webkit-border-radius:50%;-moz-border-radius:50%;border-radius:50%;border:2px solid white;cursor:pointer;-webkit-transition:background-color.15s ease-in-out;-moz-transition:background-color.15s ease-in-out;-o-transition:background-color.15s ease-in-out;transition:background-color.15s ease-in-out;-webkit-box-shadow:rgba(0,0,0,.35).2px .2px 1px 1.4px;-moz-box-shadow:rgba(0,0,0,.35).2px .2px 1px 1.4px;box-shadow:rgba(0,0,0,.35).2px .2px 1px 1.4px}input[type="range"].jsx-18334e4f8c3dfc2b::-moz-range-thumb:hover{background-color:#969696}'})]})}var ea=e=>{let{children:t,controlRef:r,className:s=""}=e;return(0,n.jsx)("div",{ref:r,className:(0,a.m6)("absolute -right-7 w-60 translate-x-full transform rounded-md border-1 bg-stone-200 bg-truewhite p-2",s),children:t})},eo=e=>{let{min:t,max:r,step:s=1,value:o,onChange:l,className:i,controlRef:c,title:u,Icon:d}=e;return(0,n.jsxs)(ea,{controlRef:c,className:(0,a.m6)(i,"pb-4"),children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(d,{className:"h-4 w-4"}),(0,n.jsx)("span",{className:"select-none text-sm",children:u})]}),(0,n.jsx)(es,{max:r,min:t,step:s,val:o,onChange:e=>{l(e)}})]})},el=e=>{let{containerRef:t,radius:r}=e,a=(0,s.useRef)({x:0,y:0}),[o,l]=(0,s.useState)(!1),[i,c]=(0,s.useState)({x:0,y:0}),u=(0,s.useCallback)((e,r)=>{let n=t.current;if(!n)return;let s=n.getBoundingClientRect();c({x:(e-s.left)/s.width,y:(r-s.top)/s.height})},[]);if((0,s.useEffect)(()=>{let e=t.current;if(!e)return;let r=e=>{l(!0),a.current={x:e.clientX,y:e.clientY},u(e.clientX,e.clientY)},n=()=>{l(!1)},s=()=>{l(!1)},o=()=>{u(a.current.x,a.current.y)};return e.addEventListener("mousemove",r),e.addEventListener("mouseout",n),e.addEventListener("mouseleave",s),e.addEventListener("resize",o),()=>{e.removeEventListener("mousemove",r),e.removeEventListener("mouseout",n),e.removeEventListener("mouseleave",s),e.removeEventListener("resize",o)}},[]),!t.current)return null;let{width:d,height:m}=t.current.getBoundingClientRect();return(0,n.jsx)("svg",{style:{position:"absolute",pointerEvents:"none",left:0,top:0,width:"100%",height:"100%",zIndex:9999,opacity:o?1:0},children:(0,n.jsx)("circle",{cx:i.x*d,cy:i.y*m,r:r,fill:"rgba(".concat(S.Of.r,", ").concat(S.Of.g,", ").concat(S.Of.b,", 0.5)")})})},ei=r(85332),ec=r(426);ec.OB.wasm.wasmPaths={"ort-wasm.wasm":"/onnxruntime/ort-wasm.wasm","ort-wasm-threaded.wasm":"/onnxruntime/ort-wasm-threaded.wasm","ort-wasm-simd.wasm":"/onnxruntime/ort-wasm-simd.wasm","ort-wasm-simd-threaded.wasm":"/onnxruntime/ort-wasm-simd-threaded.wasm"};let eu=(e,t)=>({height:t,width:e,samScale:1024/Math.max(e,t)}),ed=e=>{let t,r,n,s,{clicks:a,tensor:o,modelScale:l}=e;if(a){let e=a.length;t=new Float32Array(2*(e+1)),r=new Float32Array(e+1);for(let n=0;n<e;n++)t[2*n]=a[n].x*l.samScale,t[2*n+1]=a[n].y*l.samScale,r[n]=a[n].clickType;t[2*e]=0,t[2*e+1]=0,r[e]=-1,n=new ec.es("float32",t,[1,e+1,2]),s=new ec.es("float32",r,[1,e+1])}let i=new ec.es("float32",[l.height,l.width]);if(void 0!==n&&void 0!==s)return{image_embeddings:o,point_coords:n,point_labels:s,mask_input:new ec.es("float32",new Float32Array(65536),[1,1,256,256]),has_mask_input:new ec.es("float32",[0]),orig_im_size:i}},em=(e,t,r,n,s)=>{let a=e.data,o=new Uint8ClampedArray(4*r*n).fill(0);if(s)for(let e=0;e<t.length;e++){let r=4*e;t[e]>0?(o[r+0]=S.Of.r,o[r+1]=S.Of.g,o[r+2]=S.Of.b,o[r+3]=255):o.set(a.subarray(r,r+4),r)}else for(let e=0;e<t.length;e++){let r=4*e;t[e]>0?(o[r+0]=S.Of.r,o[r+1]=S.Of.g,o[r+2]=S.Of.b,o[r+3]=0):o.set(a.subarray(r,r+4),r)}return new ImageData(o,n,r)},eh=e=>{let{brushStrokeWidth:t,eraserStrokeWidth:r}=e,n=(0,s.useRef)(!1),a=(0,s.useRef)(S.tA.default),o=(0,s.useRef)(S.tA.default),l=(0,s.useRef)(null);return(0,s.useEffect)(()=>{a.current=t},[t]),(0,s.useEffect)(()=>{o.current=r},[r]),{paintOrEraseMouseDown:(e,t,r,s)=>{n.current=!0;let{width:i,height:c}=e,u=t/i,d=r/c,m={x:u,y:d},h=s===E.ED.PaintBrush?a.current:o.current;(0,ei.aS)(e,m,m,s,h),l.current={x:u,y:d}},paintOrEraseMouseMove:(e,t,r,s)=>{if(!n.current)return;let{width:i,height:c}=e,u=t/i,d=r/c;if(l.current){let t=l.current,r=s===E.ED.PaintBrush?a.current:o.current;(0,ei.aS)(e,t,{x:u,y:d},s,r)}l.current={x:u,y:d}},paintOrEraseMouseUp:e=>{n.current=!1}}},ex=e=>{let{maskMode:t}=e,r=(0,s.useRef)(!1),n=(0,s.useRef)([]);return(0,s.useEffect)(()=>{t!==E.ED.Lasso&&(n.current=[])},[t]),{lassoMouseDown:(e,t,s,a)=>{r.current=!0,n.current=[{x:s/e.width,y:a/e.height}];let o=t.getContext("2d");o&&(o.beginPath(),o.moveTo(s,a),o.lineWidth=1,o.lineCap="round",o.lineJoin="round",o.setLineDash([3,5]))},lassoMouseMove:(e,t,s)=>{if(!r.current)return;let a=e.getContext("2d"),o=n.current;if(!a||!o)return;let{width:l,height:i}=e,c=t/l,u=s/i;if(o.length){let e=o[o.length-1],t=(e.x+c)/2,r=(e.y+u)/2;a.quadraticCurveTo(e.x*l,e.y*i,t*l,r*i),a.stroke()}n.current.push({x:c,y:u})},lassoMouseUp:async(e,t,s)=>{r.current=!1;let a=t.getContext("2d");if(!a||(a.closePath(),a.clearRect(0,0,t.width,t.height),!e.getContext("2d")))return;let o=n.current;o.length>=3&&(0,ei.jJ)({canvas:e,points:o,positiveMode:s})},resetLasso:(0,s.useCallback)(()=>{r.current=!1,n.current=[]},[])}},ef=e=>{let{width:t,height:r,imageUrl:n,canvasImagePosition:a,magicWandTolerance:o}=e,l=(0,s.useRef)(null),i=(0,s.useRef)(o/2.5);return(0,s.useEffect)(()=>{i.current=o/2.5},[o]),(0,s.useEffect)(()=>{let e=async e=>{try{let t=await (0,z.yc)(e);l.current=t}catch(e){console.error("Error fetching image:",e)}};n&&e(n)},[n]),{magicWandMouseDown:(e,t,r,n,s)=>{let o=l.current;if(!o)return;let{x:c,y:u,width:d,height:m}=a,h=Math.round((t-c)/d*o.width),x=Math.round((r-u)/m*o.height),f=document.createElement("canvas"),p=f.getContext("2d");if(f.width=o.width,f.height=o.height,!p)return;n&&p.drawImage(n,0,0,n.width,n.height,0,0,o.width,o.height),(0,ei.V8)(f,o,{x:h,y:x},i.current,s);let g=e.getContext("2d");if(g)return g.clearRect(0,0,e.width,e.height),g.drawImage(f,0,0,o.width,o.height,c,u,d,m),f}}},ep=e=>{let{width:t,height:r,imageUrl:n,refreshCanvas:a}=e,o=(0,s.useRef)(null),l=(0,s.useRef)(null),i=(0,s.useRef)(null);(0,s.useRef)("");let[c,u]=(0,s.useState)(!1);return{pointPromptMouseDown:async(e,t,r)=>{if(!i.current)return;let n=e.getContext("2d");n&&n.putImageData(i.current,0,0)},pointPromptMouseMove:async(e,n,s)=>{if(!o.current||!l.current)return;let c=eu(t,r),u=ed({clicks:[{x:n,y:s,clickType:1}],tensor:l.current,modelScale:c});if(u)try{let t=(await o.current.run(u))[o.current.outputNames[0]],r=e.getContext("2d");if(!r)return;a();let l=r.getImageData(0,0,e.width,e.height),c=r.getImageData(n,s,1,1).data,d=c[0]||c[1]||c[2]||c[3],m=em(l,t.data,t.dims[2],t.dims[3],!d);r.putImageData(m,0,0),i.current=m}catch(e){console.log("error running result:",e)}}}},eg=e=>{let{maskMode:t}=e,r=(0,s.useRef)(!1),n=(0,s.useRef)(null),a=(0,s.useRef)({x1:0,y1:0,x2:0,y2:0});(0,s.useEffect)(()=>{t!==E.ED.Rectangle&&(n.current=null,a.current={x1:0,y1:0,x2:0,y2:0})},[t]);let o=(0,s.useCallback)(()=>{r.current=!1,n.current=null,a.current={x1:0,y1:0,x2:0,y2:0}},[]);return{rectangleMouseDown:(e,t)=>{r.current=!0,n.current={x:e,y:t}},rectangleMouseMove:async(e,t,s,o)=>{if(!r.current||!n.current)return;let l=n.current.x,i=n.current.y,c=t,u=s;if(o){let e=Math.min(Math.abs(c-l),Math.abs(u-i));c=l+(c>=l?e:-e),u=i+(u>=i?e:-e)}let d=Math.min(l,c),m=Math.min(i,u),h=Math.max(l,c),x=Math.max(i,u);a.current={x1:d,y1:m,x2:h,y2:x},(0,ei.P8)(e,a.current)},rectangleMouseUp:(e,t,n)=>{r.current=!1;let s=t.getContext("2d");s&&(s.clearRect(0,0,t.width,t.height),(0,ei.U)(e,a.current,n),o())},resetRectangle:o}},eb=e=>{let{maskMode:t,storeCanvas:r}=e,n=(0,s.useRef)(!1),a=(0,s.useRef)([]),o=(0,s.useRef)(null);(0,s.useEffect)(()=>{t!==E.ED.Polyline&&(a.current=[])},[t]);let l=(0,s.useCallback)(()=>{n.current=!1,a.current=[],o.current=null},[]),i=async(e,t,s)=>{n.current=!1;let o=t.getContext("2d");if(o){if(a.current.length>=3){let t=a.current[0];a.current.push({x:t.x,y:t.y}),(0,ei.jJ)({canvas:e,points:a.current,positiveMode:s}),r(e)}o.clearRect(0,0,t.width,t.height),a.current=[]}};return{polylineMouseDown:(e,t,r,s,l)=>{n.current=!0;let{width:c,height:u}=t;o.current?(a.current.push({...o.current}),o.current=null,i(e,t,l)):(a.current.push({x:r/c,y:s/u}),a.current.length>1&&(0,ei.LL)({canvas:t,points:a.current}))},polylineMouseMove:async(e,t,r,s)=>{if(!n.current||!a.current.length)return;let l=t.getContext("2d");if(!l)return;let{width:i,height:c}=t;l.clearRect(0,0,i,c),a.current.length>1&&(0,ei.LL)({canvas:t,points:a.current,removeAll:!1});let u={...a.current[a.current.length-1]},d={x:r/i,y:s/c};a.current.length>=3&&10>Math.sqrt((a.current[0].x*i-r)**2+(a.current[0].y*c-s)**2)?(d={x:a.current[0].x,y:a.current[0].y},o.current={...d}):o.current=null,(0,ei.pS)({canvas:t,startPoint:u,endPoint:d,removeAll:!1})},polylineMouseUp:(e,t)=>{},finishPolyline:i,resetPolyline:l}},ev=(e,t)=>{let r=t.getBoundingClientRect();return{x:e.clientX-r.left,y:e.clientY-r.top}},ew=(e,t)=>{let r=t.getBoundingClientRect();return{x:e.touches[0].clientX-r.left,y:e.touches[0].clientY-r.top}};function ey(e){let{size:t,maskMode:r,containerRef:a,maskRef:o,imageUrl:l,imagePosition:i,positiveMode:c,brushStrokeWidth:u,eraserStrokeWidth:d,magicWandTolerance:m,setLoadingImageState:h,disabled:x=!1}=e,{width:f,height:p}=t,g=(0,s.useRef)(null),b=(0,s.useRef)(null),v=(0,s.useRef)(null),w=(0,s.useRef)(r),y=(0,s.useRef)(null),j=(0,s.useRef)(null),N=(0,s.useRef)([]),k=(0,s.useRef)(-1),[_,C]=(0,s.useState)(!1),S=(0,s.useMemo)(()=>{let{offsetX:e,offsetY:r,width:n,height:s,scale:a}=i,o=n*a,l=s*a;return{x:(t.width-o)/2+e,y:(t.height-l)/2+r,width:o,height:l}},[t,i]),R=(0,s.useCallback)(()=>{let e=y.current;if(!e)return;let t=b.current;t&&(0,ei.lx)(e,t,S)},[t,S]),D=(0,s.useCallback)(()=>{let e=v.current,t=null==e?void 0:e.getContext("2d");if(!e||!t)return;let r=N.current[k.current];if(r){let{x:n,y:s,width:a,height:o}=S;t.clearRect(0,0,e.width,e.height),t.drawImage(r,n,s,a,o)}else t.clearRect(0,0,e.width,e.height)},[S]);(0,s.useEffect)(()=>{R()},[R]),(0,s.useEffect)(()=>{D()},[D]),(0,s.useEffect)(()=>{let e=y.current;if(!e)return;let t=g.current;l?t!==l&&(0,ei.Vg)(e,S):(0,ei.r7)(e),g.current=l},[l,S]),(0,s.useEffect)(()=>{if(!l){b.current=null;return}return(()=>{let e=new Image;return e.crossOrigin="Anonymous",e.onload=()=>{b.current=e,R(),null==h||h("loaded")},e.onerror=()=>{console.error("Failed to load image from URL:",l),b.current=null,null==h||h("error")},e.src=l,()=>{b.current=null,e.onerror=null,e.onload=null}})()},[l,R]);let Z=(0,s.useCallback)(e=>{k.current<N.current.length-1&&(N.current=N.current.slice(0,k.current+1)),N.current.push(e),k.current=k.current+1},[]),I=(0,s.useCallback)(e=>{let t=e.getContext("2d");if(!t)return;let{x:r,y:n,width:s,height:a}=S;r>0&&t.clearRect(0,0,r,e.height),n>0&&t.clearRect(0,0,e.width,n),r+s<e.width&&t.clearRect(r+s,0,e.width,e.height),n+a<e.height&&t.clearRect(0,n+a,e.width,e.height);let o=document.createElement("canvas");o.width=s,o.height=a;let l=o.getContext("2d");if(!l)return;let i=N.current[k.current];i&&l.drawImage(i,0,0,i.width,i.height,0,0,s,a);let c=Math.max(r,0),u=Math.max(n,0),d=Math.min(r+s,e.width),m=Math.min(n+a,e.height);if(c>=d||u>=m)return;let h=d-c,x=m-u,f=r>=0?0:-r,p=n>=0?0:-n;l.clearRect(f,p,h,x),l.drawImage(e,c,u,h,x,f,p,h,x),Z(o)},[S,Z]),{paintOrEraseMouseDown:P,paintOrEraseMouseMove:T,paintOrEraseMouseUp:M}=eh({brushStrokeWidth:u*i.scale,eraserStrokeWidth:d*i.scale}),{lassoMouseDown:z,lassoMouseMove:L,lassoMouseUp:O,resetLasso:A}=ex({maskMode:r}),{magicWandMouseDown:B}=ef({width:S.width,height:S.height,imageUrl:l,canvasImagePosition:S,magicWandTolerance:m}),{pointPromptMouseDown:q,pointPromptMouseMove:U}=ep({width:f,height:p,imageUrl:l,refreshCanvas:D}),{resetRectangle:G,rectangleMouseDown:F,rectangleMouseMove:W,rectangleMouseUp:X}=eg({maskMode:r}),{polylineMouseDown:Y,polylineMouseMove:Q,polylineMouseUp:J,finishPolyline:H,resetPolyline:K}=eb({maskMode:r,storeCanvas:I});return(0,s.useEffect)(()=>{w.current=r,j.current&&(0,ei.r7)(j.current)},[r]),(0,s.useEffect)(()=>{let e=e=>{"Escape"===e.key&&(G(),K(),A(),j.current&&(0,ei.r7)(j.current))};return window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e)}},[]),(0,s.useEffect)(()=>{let e=a.current;if(!e)return;let t=()=>{k.current>=0&&(k.current-=1,D())},r=()=>{k.current<N.current.length-1&&(k.current+=1,D())},n=()=>{N.current=[],k.current=-1,D()},s=()=>{let e=N.current[k.current];if(e){let t=(0,ei.fV)(e);o.current=t||""}else o.current=""};return e.addEventListener("undomask",t),e.addEventListener("redomask",r),e.addEventListener("resetmask",n),e.addEventListener("getmask",s),()=>{e.removeEventListener("undomask",t),e.removeEventListener("redomask",r),e.removeEventListener("resetmask",n),e.removeEventListener("getmask",s)}},[D,ei.fV]),(0,s.useEffect)(()=>{let e=a.current,t=v.current,r=j.current;if(!e||!t||!r)return;let n=async e=>{if(x||0!==e.button)return;let{x:n,y:s}=ev(e,t);if(w.current===E.ED.PaintBrush||w.current===E.ED.Eraser)P(t,n,s,w.current);else if(w.current===E.ED.Rectangle)F(n,s);else if(w.current===E.ED.PointPrompt)q(t,n,s),I(t);else if(w.current===E.ED.Lasso)z(t,r,n,s);else if(w.current===E.ED.MagicWand){let e=B(t,n,s,N.current[k.current],c);e&&Z(e)}else w.current===E.ED.Polyline&&Y(t,r,n,s,c)},s=async e=>{if(x||0!==e.button)return;let n=e.shiftKey,{x:s,y:a}=ev(e,t);w.current===E.ED.PaintBrush||w.current===E.ED.Eraser?T(t,s,a,w.current):w.current===E.ED.Rectangle?W(r,s,a,n):w.current===E.ED.PointPrompt?U(t,s,a):w.current===E.ED.Lasso?L(r,s,a):w.current===E.ED.Polyline&&Q(t,r,s,a)},o=async e=>{x||0!==e.button||(w.current===E.ED.PaintBrush||w.current===E.ED.Eraser?(M(t),I(t)):w.current===E.ED.Rectangle?(X(t,r,c),I(t)):w.current===E.ED.PointPrompt||(w.current===E.ED.Lasso?(O(t,r,c),I(t)):w.current===E.ED.Polyline&&J(t,r)))},l=async e=>{},i=async e=>{if(x)return;e.preventDefault();let{x:r,y:n}=ew(e,t);w.current===E.ED.PaintBrush?P(t,r,n,w.current):console.log("Mode not supported")},u=async e=>{if(x)return;e.preventDefault();let{x:r,y:n}=ew(e,t);w.current===E.ED.PaintBrush?T(t,r,n,w.current):console.log("Mode not supported")},d=async e=>{x||(e.preventDefault(),w.current===E.ED.PaintBrush?(M(t),I(t)):console.log("Mode not supported"))},m=async e=>{if(x)return;let{x:t,y:r,width:n,height:s}=S,a=document.createElement("canvas");a.width=n,a.height=s;let o=a.getContext("2d");if(!o)return;let l=N.current[k.current];l&&o.drawImage(l,0,0,l.width,l.height,0,0,n,s),(0,ei.W3)(a);let i=v.current,c=null==i?void 0:i.getContext("2d");i&&c&&(c.clearRect(0,0,i.width,i.height),c.drawImage(a,0,0,a.width,a.height,t,r,n,s),Z(a))},h=e=>{"Enter"===e.key&&w.current===E.ED.Polyline&&H(t,r,c)},f=e=>{w.current===E.ED.Polyline&&H(t,r,c)},p=e=>(e.preventDefault(),!1);return e.addEventListener("mousedown",n),e.addEventListener("mousemove",s),e.addEventListener("mouseup",o),e.addEventListener("mouseleave",l),e.addEventListener("touchstart",i),e.addEventListener("touchmove",u),e.addEventListener("touchend",d),e.addEventListener("inversemask",m),e.addEventListener("contextmenu",p),e.addEventListener("dblclick",f),e.addEventListener("keydown",h),()=>{e.removeEventListener("mousedown",n),e.removeEventListener("mousemove",s),e.removeEventListener("mouseup",o),e.removeEventListener("mouseleave",l),e.removeEventListener("touchstart",i),e.removeEventListener("touchmove",u),e.removeEventListener("touchend",d),e.removeEventListener("inversemask",m),e.removeEventListener("contextmenu",p),e.removeEventListener("dblclick",f),e.removeEventListener("keydown",h)}},[l,x,c,S,D]),(0,n.jsx)(n.Fragment,{children:(0,n.jsxs)("div",{id:"mask-canvas-container",tabIndex:0,ref:a,style:{width:t.width,height:t.height,cursor:x?"inherit":[E.ED.PaintBrush,E.ED.Eraser,E.ED.Lasso,E.ED.Polyline,E.ED.Rectangle].includes(r)?"crosshair":"default"},className:"absolute left-0 top-0 z-30 focus:outline-none",children:[(0,n.jsx)("canvas",{id:"image-canvas",ref:y,width:t.width,height:t.height,className:"absolute z-30"}),(0,n.jsx)("canvas",{id:"editor-canvas",ref:v,width:t.width,height:t.height,className:"absolute left-0 top-0 z-30 opacity-50 focus:outline-none",onContextMenu:e=>e.preventDefault()}),(0,n.jsx)("canvas",{id:"mouse-canvas",ref:j,width:t.width,height:t.height,className:"absolute z-30"})]})})}var ej=r(19231);let eN={width:0,height:0,offsetX:0,offsetY:0,scale:1},ek=(e,t)=>{let{width:r,height:n}=e,s=t.width/t.height,a=0,o=0;return r/n>s?a=(o=Math.min(t.height,.7*n))*s:o=(a=Math.min(t.width,.7*r))/s,{width:a,height:o}},eE=e=>{let{imgSize:t,containerRef:r,containerSize:n}=e,[a,o]=(0,s.useState)({...eN,width:t.width,height:t.height}),[l,i]=(0,s.useState)(E.qf.None),[c,u]=(0,s.useState)(E.g1[E.qf.None]),d=(0,s.useRef)(null),m=(0,s.useRef)(!1),h=(0,s.useRef)(!1),x=(0,s.useRef)({x:0,y:0}),f=(0,s.useCallback)(e=>{u(E.g1[e])},[]),p=(0,s.useCallback)((e,t,r)=>{o(n=>{let s=n.scale*e;return s<S.PQ.min||s>S.PQ.max?n:{...n,scale:s,offsetX:void 0!==t?t:n.offsetX,offsetY:void 0!==r?r:n.offsetY}})},[]),g=(0,s.useCallback)((e,t,r)=>{let{left:s,top:o}=e.getBoundingClientRect(),{width:l,height:i}=n,{offsetX:c,offsetY:u}=a,d=t.x-s-l/2-c,m=t.y-o-i/2-u;return{x:r?c-d*S.xK:c+S.xK*d/(1+S.xK),y:r?u-m*S.xK:u+S.xK*m/(1+S.xK)}},[n,a.offsetX,a.offsetY]),b=(0,s.useCallback)(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,{width:r,height:s}=ek(n,t);(e||r!==a.width||s!==a.height)&&o(t=>({...t,...e||{},...r!==t.width||s!==t.height?{width:r,height:s}:{}}))},[n,t]);(0,s.useEffect)(()=>{b()},[b]),(0,s.useEffect)(()=>{let e=r.current;if(!e)return;let t=(0,z.P2)(t=>{if(clearTimeout(d.current),t.stopPropagation(),t.preventDefault(),0===t.deltaY)return;let r=t.deltaY<0;f(r?E.qf.ZoomIn:E.qf.ZoomOut);let n=g(e,{x:t.clientX,y:t.clientY},r);p(r?1+S.xK:1-S.xK,n.x,n.y),d.current=setTimeout(()=>{f(l)},300)},100);return e.addEventListener("wheel",t,{passive:!1}),()=>{e.removeEventListener("wheel",t),d.current&&clearTimeout(d.current)}},[l,g,n,p,f]);let v=(0,s.useCallback)(e=>{let t=r.current;if(t){if(l!==E.qf.None&&(e.preventDefault(),e.stopPropagation()),l===E.qf.Pan&&0===e.button||1===e.button||2===e.button)h.current=!0,x.current={x:e.screenX,y:e.screenY},f(E.qf.Panning),(1===e.button||2===e.button)&&(m.current=!0);else if(l===E.qf.ZoomIn){let r=g(t,{x:e.clientX,y:e.clientY},!0);p(1+S.xK,r.x,r.y),f(E.qf.ZoomIn)}else if(l===E.qf.ZoomOut){let r=g(t,{x:e.clientX,y:e.clientY},!1);p(1-S.xK,r.x,r.y),f(E.qf.ZoomOut)}}},[p,l,g,f]),w=(0,s.useCallback)(e=>{if(l!==E.qf.None&&(e.preventDefault(),e.stopPropagation()),l===E.qf.Pan||m.current){if(!h.current)return;let t=e.screenX-x.current.x,r=e.screenY-x.current.y;o(e=>({...e,offsetX:e.offsetX+t,offsetY:e.offsetY+r})),x.current={x:e.screenX,y:e.screenY}}},[l]),y=(0,s.useCallback)(e=>{l!==E.qf.None&&(e.preventDefault(),e.stopPropagation()),(l===E.qf.Pan||m.current)&&(h.current=!1,m.current=!1,l===E.qf.Pan?f(E.qf.Pan):f(E.qf.None))},[l]),j=(0,s.useCallback)(e=>{f(l)},[l]),N=(0,s.useCallback)(e=>{f(E.qf.None)},[]),k=(0,s.useCallback)(e=>(e.preventDefault(),e.stopPropagation(),!1),[]);return(0,s.useEffect)(()=>{f(l)},[f,l]),{cursor:c,imagePosition:a,viewportControl:l,setViewportControl:i,handleMouseDown:v,handleMouseMove:w,handleMouseUp:y,handleMouseOver:j,handleMouseLeave:N,handleContextMenu:k,handleAdjustImageSizeAndPosition:b}};var e_=r(15927),eC=r(59968);let eS=e=>{let t=e.match(/^([0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})-(\d+)-(\d+)$/i);if(t){let[,e,r,n]=t,s=parseInt(r,10),a=parseInt(n,10);if(!isNaN(s)&&!isNaN(a))return{key:e,seed:s,subseed:a}}return null};var eR=r(47788),eD=r(2828),eZ=r(84588);function eI(e){let{onEnable:t,initValue:r}=e,[o,l]=(0,s.useState)(null!=r&&r);return(0,n.jsxs)(eZ.r,{checked:o,onChange:e=>{t(e),l(e)},className:"group relative inline-flex h-5 w-[42px] flex-shrink-0 cursor-pointer items-center justify-center rounded-full",children:[(0,n.jsx)("span",{"aria-hidden":"true",className:(0,a.m6)(o?"bg-gray-600":"bg-gray-200","pointer-events-none absolute mx-auto h-6 w-[42px] rounded-full transition-colors duration-200 ease-in-out")}),(0,n.jsx)("span",{"aria-hidden":"true",className:(0,a.m6)(o?"translate-x-5":"translate-x-1","pointer-events-none absolute left-0 inline-block h-[18px] w-[18px] transform rounded-full bg-white shadow-md ring-0 transition-transform duration-200 ease-in-out")})]})}var eP=e=>{let{title:t,className:r,controlRef:s,onChange:o,Icon:l}=e;return(0,n.jsxs)(ea,{controlRef:s,className:(0,a.m6)(r,"w-35"),children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 pb-2",children:[(0,n.jsx)(l,{className:"h-4 w-4"}),(0,n.jsx)("span",{className:"select-none text-nowrap text-sm",children:t})]}),(0,n.jsx)(eI,{onEnable:o,initValue:!0})]})},eT=e=>{let{changeTitle:t,booleanTitle:r,ChangeIcon:s,BooleanIcon:o,controlRef:l,min:i,max:c,step:u=1,value:d,onChange:m,onToggle:h,className:x}=e;return(0,n.jsxs)(ea,{controlRef:l,className:(0,a.m6)(x,"space-y-4"),children:[(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)(s,{className:"h-4 w-4"}),(0,n.jsx)("span",{className:"select-none text-sm",children:t})]}),(0,n.jsx)(es,{max:c,min:i,step:u,val:d,onChange:e=>{m(e)}})]}),(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"flex items-center gap-1 pb-2",children:[(0,n.jsx)(o,{className:"h-4 w-4"}),(0,n.jsx)("span",{className:"select-none text-sm",children:r})]}),(0,n.jsx)(eI,{onEnable:h,initValue:!0})]})]})};function eM(e){var t;let{roomId:r,name:Z,imgSize:I,wording:P,isOpen:T}=e,{state:M,dispatch:L}=(0,o.useAppContext)(),[O,A]=(0,s.useState)(""),B=(0,s.useRef)(null),U=(0,s.useRef)(null),[Y,K]=(0,s.useState)({..._.sr}),[V,er]=(0,s.useState)(""),[en,es]=(0,s.useState)({..._.BS}),[ea,ei]=(0,s.useState)({type:_.w6,style:_.UU}),[ec,eu]=(0,s.useState)([]),[ed,em]=(0,s.useState)(null),[eh,ex]=(0,s.useState)(0),[ef,ep]=(0,s.useState)(-1),[eg,eb]=(0,s.useState)("loading"),[ev,ew]=(0,s.useState)(!1),[eN,ek]=(0,s.useState)("idle"),eZ=(0,s.useRef)(null),[eI,eM]=(0,s.useState)({width:0,height:0}),ez=(0,s.useRef)(null),[eL,eO]=(0,s.useState)(E.ED.PaintBrush),eA=(0,s.useRef)(""),[eB,eq]=(0,s.useState)(!1),[eU,eG]=(0,s.useState)(S.tA.default),[eF,eW]=(0,s.useState)(S.tA.default),[eX,eY]=(0,s.useState)(S.ZR.default),[eQ,eJ]=(0,s.useState)(!0),eH="".concat(R.We,"/render/").concat(r),{toast:eK}=(0,eR.pm)(),eV=()=>{var e;return null===(e=ez.current)||void 0===e||e.dispatchEvent(new CustomEvent("getmask",{})),eA.current},e$=()=>{var e;null===(e=ez.current)||void 0===e||e.dispatchEvent(new CustomEvent("undomask",{}))},e0=()=>{var e;null===(e=ez.current)||void 0===e||e.dispatchEvent(new CustomEvent("redomask",{}))},e1=()=>{var e;null===(e=ez.current)||void 0===e||e.dispatchEvent(new CustomEvent("resetmask",{}))},{cursor:e2,imagePosition:e5,viewportControl:e3,setViewportControl:e4,handleMouseDown:e6,handleMouseMove:e7,handleMouseUp:e8,handleMouseOver:e9,handleMouseLeave:te,handleContextMenu:tt,handleAdjustImageSizeAndPosition:tr}=eE({imgSize:I,containerRef:eZ,containerSize:eI}),tn=()=>{e1(),ew(!1)},ts=()=>{U.current=null,ex(0),em(null),ek("idle")},ta=(e,t)=>{let r=ec[ef].url.split("/").pop();if(!r){A("Bug: error extracting editFileName.");return}let n=ec.map(t=>{let n=t.url.split("/").pop();return n?n.includes("-source.")?t:n===r?{...t,key:e.key,url:"".concat(eH,"/").concat(e.key,"-source.").concat(e.ext)}:t:(A("Bug: error extracting historyFileName."),t)});n.push({width:I.width,height:I.height,key:e.key,ext:t.ext,url:"".concat(eH,"/").concat(e.key,"-").concat(t.seed,"-").concat(t.subseed,".").concat(t.ext)}),eu(n),ep(n.length-1)},to=async()=>{if("decided"===eN){eK({variant:"destructive",description:(0,n.jsx)(ej.Zu,{}),duration:S.QE});return}ek("decided"),localStorage.removeItem("roomData_".concat(r));let{input:e,outputs:t}=null!=ed?ed:{};if(!e||!t){A("Bug: no input or outputs to confirm.");return}let s=U.current;if(!s){A("Bug: no pending room to confirm.");return}let a=t[eh].output,{err:o,res:l}=await (0,eC.rc)({_id:r,outputs:[a]});if(o){A("Error confirming room.");return}l&&(ta(e,a),K({...s,main_image:"".concat(e.key,"-").concat(a.seed,"-").concat(a.subseed,".").concat(a.ext),outputs:[a]}),ts())},tl=async()=>{if("decided"===eN){eK({variant:"destructive",description:(0,n.jsx)(ej.Zu,{}),duration:S.QE});return}ek("decided"),localStorage.removeItem("roomData_".concat(r));let e=B.current;if(!e){A("Bug: no last room to revert.");return}let{key:t,key_history:s,outputs:a}=e,{err:o,res:l}=await (0,eC.ht)({_id:r,key:t,key_history:s,outputs:a});if(o){A("Error reverting room.");return}l&&(K(e),ts())},ti=async()=>{var e;let{err:t,res:s}=await (0,e_.tR)({_id:r});if(t||["paint_error","dead"].includes(null!==(e=null==s?void 0:s.phase)&&void 0!==e?e:"")){eK({variant:"destructive",description:(0,n.jsx)(ej.vn,{}),duration:S.QE}),tn();return}if((null==s?void 0:s.phase)==="painted"){let e=s.key_history.find(e=>e.key===s.key);if(!e){A("Bug: error finding key."),tn();return}U.current=s;let t={key:s.key,key_history:s.key_history,outputs:s.outputs};localStorage.setItem("roomData_".concat(r),JSON.stringify(t));let n=s.outputs.map(t=>({output:{...t},url:"".concat(eH,"/").concat(e.key,"-").concat(t.seed,"-").concat(t.subseed,".").concat(t.ext)}));if(!M.user.is_plus)for(n=n.slice(0,1);n.length<2;)n.push(n[0]);em({input:e,outputs:n}),tn(),ek("deciding"),tr({scale:1,offsetX:0,offsetY:0})}else setTimeout(ti,1e3)},tc=async e=>{if(A(""),!1==M.user.is_plus&&M.user.num_credit<1){A(M.wording.submit.errorNoCreditsLeft),L({type:"OPEN_SUB_SETTINGS"});return}if(ev)return;ew(!0),L({type:"CONSUME_CREDIT"}),K(e);let{main_image:t,masks:n,model:s,type:a,style:o,tags:l,lighting:i,color:c,texture:u,version:d,width:m,height:h,is_detailed:x,is_furnish:f}=e,{err:p,res:g}=await (0,e_.$X)({_id:r,submission:{tool:"inpaint",main_image:t,masks:n,model:s,type:a,style:o,tags:l,lighting:i,color:c,texture:u,version:d,width:m,height:h,is_detailed:x,is_furnish:f}});p?(ew(!1),A("Error submitting room.")):(B.current=e,ti())},tu=e=>{let t=e.split(".").pop();(0,z.GN)("".concat(e,"?t=").concat(new Date().getTime()),"".concat(new Date().getTime(),".").concat(t))},td=e=>{if(!Y||e===ef)return;eb("loading"),ep(e);let t=ec[e].url.split("/").pop(),r=null==t?void 0:t.split(".");if(!r){A("Bug: error extracting image name.");return}let[n,s]=r;if(n.includes("-source")){let e=n.split("-source")[0];K({...Y,key:e,main_image:"".concat(e,".").concat(s)})}else{let e=eS(n);if(!e){A("Bug: error extracting image name.");return}let{key:t,seed:r,subseed:a}=e;K({...Y,key:t,main_image:"".concat(t,"-").concat(r,"-").concat(a,".").concat(s)})}e1()},tm=()=>{if(ev){eK({variant:"destructive",description:(0,n.jsx)(ej.Zu,{}),duration:S.QE});return}let e=eV();if(!e){eK({variant:"destructive",description:(0,n.jsx)(ej.h6,{}),duration:S.QE});return}if(en.mode===E.Gt.Style&&ea.type===_.w6&&ea.style===_.UU){eK({variant:"destructive",description:(0,n.jsx)(ej.$n,{}),duration:S.QE});return}if(en.mode===E.Gt.Change){let e=""!==V;for(let t of Object.keys(P.editor.dropdown||{}))if(""!==en[(0,z.a1)(t)]){e=!0;break}if(!e){eK({variant:"destructive",description:(0,n.jsx)(ej.LK,{}),duration:S.QE});return}}tc({...Y,...ea,masks:[{..._.z7,mask:e,prompt:V,misc:{...en}}]})};(0,s.useEffect)(()=>{let e=eZ.current;if(!e)return;let t=()=>{eM({width:e.clientWidth,height:e.clientHeight})};return t(),window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}},[M.is_open_whiteboard]),(0,s.useEffect)(()=>{let e=eZ.current;if(!e)return;let{width:t,height:r}=e.getBoundingClientRect();eM({width:t,height:r})},[M.is_open_whiteboard]),(0,s.useEffect)(()=>{let e=e=>e.map(e=>{let{key:t,ext:r}=e;return{width:I.width,height:I.height,key:t,ext:r,url:"".concat(eH,"/").concat(t,"-source.").concat(r)}}),t=(e,t,r)=>{let{seed:n,subseed:s,ext:a}=t;e.push({width:I.width,height:I.height,key:r,ext:a,url:"".concat(eH,"/").concat(r,"-").concat(n,"-").concat(s,".").concat(a)}),K(e=>({...e,main_image:"".concat(r,"-").concat(n,"-").concat(s,".").concat(a)}))},n=(e,t)=>{U.current=e;let r=t.key_history.find(e=>e.key===t.key);if(!r){A("No last input found.");return}if(B.current={...e,...t},!M.user.is_plus)for(;t.outputs.length<2;)t.outputs.push(t.outputs[0]);em({input:{...r},outputs:t.outputs.map(e=>({output:e,url:"".concat(eH,"/").concat(t.key,"-").concat(e.seed,"-").concat(e.subseed,".").concat(e.ext)}))}),ek("deciding")},s=async s=>{let{key:a,key_history:o,outputs:l}=s;if(!o.length){A("No key history found.");return}K(s);let i=e(o),c=localStorage.getItem("roomData_".concat(r));c?n(s,JSON.parse(c)):1===l.length?t(i,l[0],a):l.length>1&&K({...s,outputs:[s.outputs[0]]}),eu(i),ep(i.length-1)};(async()=>{let{err:e,res:t}=await (0,e_.tR)({_id:r});if(e||!t){A(e?"Error getting room.":"No room found.");return}s(t)})()},[r]),(0,s.useEffect)(()=>{eL!==E.ED.None&&(e4(E.qf.None),eJ(!0))},[eL]),(0,s.useEffect)(()=>{e3!==E.qf.None&&eO(E.ED.None)},[e3]),(0,s.useEffect)(()=>{if(![E.ED.PaintBrush,E.ED.Eraser].includes(eL))return;eq(!0);let e=setTimeout(()=>{eq(!1)},500);return()=>clearTimeout(e)},[eU,eF]);let th=ev||"default"!==e2,tx=ev||"idle"!==eN,tf="idle"===eN?null===(t=ec[ef])||void 0===t?void 0:t.url:"",tp=(0,s.useMemo)(()=>{let{offsetX:e,offsetY:t,width:r,height:n,scale:s}=e5,a=r*s,o=n*s;return{x:(eI.width-a)/2+e,y:(eI.height-o)/2+t,width:a,height:o}},[eI,e5]);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"grid h-full w-full grid-cols-1 grid-rows-[65px_1fr]",children:[(0,n.jsxs)("div",{className:"z-30 flex w-full items-center justify-between gap-3 rounded-t-lg border-b-2 border-gray-300 bg-truewhite px-3 py-2",children:[(0,n.jsxs)("div",{className:"my-auto flex gap-4",children:[(0,n.jsx)("button",{className:(0,a.m6)(ev&&"cursor-not-allowed text-stone-200"),onClick:()=>{L({type:"TOGGLE_WHITEBOARD",payload:{open:!1}})},disabled:ev,children:(0,n.jsx)(c.Z,{className:"h-4 w-4"})}),(0,n.jsx)("div",{className:"hidden font-bold sm:block sm:text-xl lg:text-2xl",children:M.wording.whiteboardTitle})]}),(0,n.jsxs)("div",{className:"flex gap-0 md:gap-2",children:[(0,n.jsx)(J.Z,{Icon:u.Z,onClick:()=>{(0,C.q)({name:"inpaint_canvas_pan",value:""}),e4(E.qf.Pan)},selected:e3===E.qf.Pan,disabled:!1}),(0,n.jsx)(J.Z,{Icon:d.Z,onClick:()=>{(0,C.q)({name:"inpaint_canvas_zoom_in",value:""}),e4(E.qf.ZoomIn)},selected:e3===E.qf.ZoomIn,disabled:!1}),(0,n.jsx)(J.Z,{Icon:m.Z,onClick:()=>{(0,C.q)({name:"inpaint_canvas_zoom_out",value:""}),e4(E.qf.ZoomOut)},selected:e3===E.qf.ZoomOut,disabled:!1})]}),(0,n.jsx)("button",{className:(0,a.m6)("rounded-md border-2 border-gray-200 px-4 py-1 text-base font-semibold md:px-12",ev||ec.length<=1?"cursor-not-allowed text-stone-200":"hover:border-blue-600 hover:bg-gray-600 hover:text-truewhite"),onClick:()=>{(0,C.q)({name:"inpaint_canvas_done",value:""}),window.location.href="/r/".concat(r)},disabled:ev||ec.length<=1,children:M.wording.done})]}),(0,n.jsxs)("div",{className:"flex",children:[(0,n.jsx)(D,{position:"left",children:(0,n.jsxs)("div",{className:"relative my-auto flex flex-col gap-[calc(var(--vh,1vh)*1.5)]",children:[(0,n.jsx)(X,{name:M.wording.maskMode.name.paintBrush,selected:eL===E.ED.PaintBrush,disabled:tx,onClick:()=>{(0,C.q)({name:"inpaint_canvas_paint_brush",value:""}),eO(E.ED.PaintBrush)},renderIcon:e=>(0,n.jsx)(h.Z,{className:e}),renderControl:(e,t)=>(0,n.jsx)(eo,{controlRef:e,title:M.wording.maskMode.control.brushWidth,max:S.tA.max,min:S.tA.min,value:eU,onChange:e=>eG(e),Icon:h.Z,className:t})}),(0,n.jsx)(X,{name:M.wording.maskMode.name.eraser,selected:eL===E.ED.Eraser,disabled:tx,onClick:()=>{(0,C.q)({name:"inpaint_canvas_eraser",value:""}),eO(E.ED.Eraser)},renderIcon:e=>(0,n.jsx)(x.Z,{className:e}),renderControl:(e,t)=>(0,n.jsx)(eo,{controlRef:e,title:M.wording.maskMode.control.eraserWidth,max:S.tA.max,min:S.tA.min,value:eF,onChange:e=>eW(e),Icon:x.Z,className:t})}),(0,n.jsx)(X,{name:M.wording.maskMode.name.lasso,selected:eL===E.ED.Lasso,disabled:tx,onClick:()=>{(0,C.q)({name:"inpaint_canvas_lasso",value:""}),eO(E.ED.Lasso)},renderIcon:e=>(0,n.jsx)(f.Z,{className:e}),renderControl:(e,t)=>(0,n.jsx)(eP,{title:M.wording.maskMode.control.boolean,className:t,controlRef:e,Icon:e=>(0,n.jsx)(G.xA,{...e,className:"stroke-black"}),onChange:e=>{eJ(e)}})}),(0,n.jsx)(X,{name:M.wording.maskMode.name.polyline,selected:eL===E.ED.Polyline,disabled:tx,onClick:()=>{(0,C.q)({name:"inpaint_canvas_polyline",value:""}),eO(E.ED.Polyline)},renderIcon:e=>(0,n.jsx)(G.sL,{className:(0,a.m6)(tx?"stroke-black":eL===E.ED.Polyline?"stroke-stone-200":"stroke-black group-active:stroke-white")}),renderControl:(e,t)=>(0,n.jsx)(eP,{title:M.wording.maskMode.control.boolean,className:t,controlRef:e,Icon:e=>(0,n.jsx)(G.xA,{...e,className:"stroke-black"}),onChange:e=>{eJ(e)}})}),(0,n.jsx)(X,{name:M.wording.maskMode.name.rectangle,selected:eL===E.ED.Rectangle,disabled:tx,onClick:()=>{(0,C.q)({name:"inpaint_canvas_rectangle",value:""}),eO(E.ED.Rectangle)},renderIcon:e=>(0,n.jsx)(p.Z,{className:e}),renderControl:(e,t)=>(0,n.jsx)(eP,{title:M.wording.maskMode.control.boolean,className:t,controlRef:e,Icon:e=>(0,n.jsx)(G.xA,{...e,className:"stroke-black"}),onChange:e=>{eJ(e)}})}),(0,n.jsx)(X,{name:M.wording.maskMode.name.magicWand,selected:eL===E.ED.MagicWand,disabled:tx,onClick:()=>{(0,C.q)({name:"inpaint_canvas_magic_wand",value:""}),eO(E.ED.MagicWand)},renderIcon:e=>(0,n.jsx)(g.Z,{className:e}),renderControl:(e,t)=>(0,n.jsx)(eT,{changeTitle:M.wording.maskMode.control.colorTolerance,booleanTitle:M.wording.maskMode.control.boolean,ChangeIcon:g.Z,BooleanIcon:e=>(0,n.jsx)(G.xA,{...e,className:"stroke-black"}),controlRef:e,max:S.ZR.max,min:S.ZR.min,value:eX,onChange:e=>{eY(e)},onToggle:e=>{eJ(e)},className:t})}),(0,n.jsx)("div",{className:"w-full border-b-2 border-gray-300"}),(0,n.jsx)(X,{name:M.wording.undo,selected:!1,disabled:tx,onClick:()=>{(0,C.q)({name:"inpaint_canvas_undo",value:""}),e$()},renderIcon:e=>(0,n.jsx)(b.Z,{className:e})}),(0,n.jsx)(X,{name:M.wording.redo,selected:!1,disabled:tx,onClick:()=>{(0,C.q)({name:"inpaint_canvas_redo",value:""}),e0()},renderIcon:e=>(0,n.jsx)(v.Z,{className:e})}),(0,n.jsx)(X,{name:M.wording.reset,selected:!1,disabled:tx,onClick:()=>{(0,C.q)({name:"inpaint_canvas_reset",value:""}),e1()},renderIcon:e=>(0,n.jsx)(w.Z,{className:e})})]})}),(0,n.jsxs)("div",{className:"flex flex-1 flex-col",children:[(0,n.jsxs)("div",{ref:eZ,onMouseDown:e6,onMouseMove:e7,onMouseUp:e8,onMouseOver:e9,onMouseLeave:te,onContextMenu:tt,className:"relative z-30 flex-grow overflow-hidden bg-stone-50",style:{cursor:e2},children:[eZ.current&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(ey,{size:eI,maskMode:eL,containerRef:ez,maskRef:eA,imageUrl:tf,imagePosition:e5,positiveMode:eQ,brushStrokeWidth:eU,eraserStrokeWidth:eF,magicWandTolerance:eX,setLoadingImageState:eb,disabled:th}),eL===E.ED.PaintBrush&&!th&&(0,n.jsx)(el,{containerRef:ez,radius:eU/2*e5.scale}),eL===E.ED.Eraser&&!th&&(0,n.jsx)(el,{containerRef:ez,radius:eF/2*e5.scale})]}),ed&&(0,n.jsxs)(ee,{children:[(0,n.jsx)("div",{className:"absolute",style:{left:tp.x,top:tp.y,width:tp.width,height:tp.height},children:(0,n.jsx)(l.default,{src:ed.outputs[eh].url,alt:"output image",height:I.height,width:I.width,className:"h-full w-full select-none object-cover"})}),(0,n.jsxs)("div",{className:"absolute bottom-2 left-1/2 z-50 flex -translate-x-1/2 transform items-center justify-center gap-8 rounded-md border-2 border-stone-200 bg-truewhite px-4 py-2",children:[(0,n.jsx)("div",{className:"flex gap-4",children:ed.outputs.map((e,t)=>(0,n.jsxs)("button",{className:(0,a.m6)("relative h-16 w-16 overflow-hidden rounded-md border-3 border-stone-200",t===eh&&"border-gray-600"),onClick:()=>{M.user.is_plus||0===t?(eb("loading"),ex(t)):L({type:"OPEN_SUB_SETTINGS"})},children:[(0,n.jsx)(l.default,{src:e.url,alt:"output image ".concat(t),sizes:"(max-width: 600px) 100vw, 25vw",height:I.height/6,width:I.width/6,className:"z-0 h-full w-full select-none object-cover"}),!M.user.is_plus&&0!==t&&(0,n.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-black bg-opacity-50",children:(0,n.jsx)(y.Z,{color:"white",size:24})})]},t))}),(0,n.jsxs)("div",{className:"flex h-full items-center gap-4",children:[(0,n.jsx)(F.Z,{onClick:()=>{if("decided"===eN){eK({variant:"destructive",description:(0,n.jsx)(ej.Zu,{}),duration:S.QE});return}ek("decided"),localStorage.removeItem("roomData_".concat(r));let e=B.current;if(!e){A("Bug: no last room to regenerate.");return}ts(),tc({...e})},disabled:"decided"===eN,icon:(0,n.jsx)(i.Z,{className:"h-5 w-5"}),title:M.wording.regenerate,className:"px-4 py-2"}),(0,n.jsxs)("div",{className:"flex h-full items-center gap-2",children:[(0,n.jsx)(J.Z,{Icon:j.Z,disabled:"decided"===eN,onClick:tl,shape:"rectangle",className:"h-8 w-8 p-1"}),(0,n.jsx)(J.Z,{Icon:N.Z,disabled:"decided"===eN,onClick:to,shape:"rectangle",className:"h-8 w-8 p-1"})]})]})]})]}),(0,n.jsx)("div",{className:"absolute bottom-3 right-3 z-50",children:(0,n.jsx)(J.Z,{Icon:k.Z,disabled:ev,onClick:()=>{(0,C.q)({name:"inpaint_download_main",value:""}),tu(ed?ed.outputs[eh].url:ec[ef].url)},shape:"circle",shadow:!0})}),(0,n.jsx)(et,{maskMode:eL,hints:M.wording.maskMode.hint}),eB&&(0,n.jsx)(ee,{children:(0,n.jsx)("div",{className:"rounded-full",style:{width:eL===E.ED.PaintBrush?eU:eF,height:eL===E.ED.PaintBrush?eU:eF,backgroundColor:"rgba(".concat(S.Of.r,", ").concat(S.Of.g,", ").concat(S.Of.b,", 0.5)")}})}),ev&&(0,n.jsx)("div",{className:"relative z-50 flex h-full w-full items-center justify-center bg-black/60 p-8 md:p-28 lg:p-40",children:(0,n.jsx)(H.Z,{duration:3e4,textColor:"text-gray-300",barHeight:"h-2"})})]}),(0,n.jsxs)("div",{className:"relative flex h-[14vh] min-h-[80px] w-full items-center justify-center gap-2 border-t-2 p-2",children:[(0,n.jsx)("div",{className:(0,a.m6)("relative hidden aspect-square h-full overflow-hidden rounded-md border-3 border-stone-200 bg-stone-50 lg:block",0===ef&&"border-gray-600"),children:ec.length>0&&(0,n.jsx)(l.default,{src:ec[0].url,alt:"source image",sizes:"(max-width: 600px) 100vw, 25vw",height:I.height/6,width:I.width/6,className:(0,a.m6)("z-0 h-full w-full select-none object-cover",tx?"cursor-not-allowed":"cursor-pointer"),onClick:()=>{tx||td(0)}})}),(0,n.jsx)($,{slides:ec,nShow:3,startId:1,selectedId:ef,onSelect:td,onDownload:e=>{(0,C.q)({name:"inpaint_download_history",value:""}),tu(e)},disabled:tx})]})]}),(0,n.jsxs)(D,{position:"right",children:[(0,n.jsx)(Q,{modeNames:{[E.Gt.Style]:M.wording.editor.mode.style.title,[E.Gt.Change]:M.wording.editor.mode.change.title,[E.Gt.Remove]:M.wording.editor.mode.remove.title},editMode:en.mode,setEditMode:e=>{ei({type:_.w6,style:_.UU}),es({..._.BS,mode:e}),er("")}}),en.mode===E.Gt.Change&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"workbench-settings-scrollbar flex h-[calc(100vh-250px)] max-h-[calc(100vh-328px)] w-full overflow-y-scroll",children:(0,n.jsx)(q,{misc:en,prompt:V,typeStyle:ea,setMisc:es,setPrompt:er,setTypeStyle:ei})}),(0,n.jsxs)("div",{className:"absolute bottom-0 flex w-full flex-col gap-4 bg-truewhite p-4",children:[(0,n.jsx)("button",{className:"flex w-full items-center justify-center gap-4 rounded-md border-1 bg-truewhite px-2 py-2 text-black shadow-[rgba(0,_0,_0,_0.1)_1px_1px_2px] hover:bg-stone-200 hover:shadow-none",onClick:()=>{es({..._.BS,mode:en.mode}),er("")},children:(0,n.jsxs)("div",{className:"flex items-center text-sm",children:[(0,n.jsx)(w.Z,{size:16,className:"mr-2"}),(0,n.jsx)("p",{children:P.resetOptions})]})}),(0,n.jsx)("div",{className:"w-full border-t-2"}),(0,n.jsx)(F.Z,{onClick:tm,disabled:"idle"!==eN,icon:(0,n.jsx)(i.Z,{className:"h-5 w-5"}),title:M.wording.render})]})]}),en.mode===E.Gt.Style&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(q,{misc:en,prompt:V,typeStyle:ea,setMisc:es,setPrompt:er,setTypeStyle:ei}),(0,n.jsx)("div",{className:"my-4 w-full border-t-2"}),(0,n.jsx)(F.Z,{onClick:tm,disabled:"idle"!==eN,icon:(0,n.jsx)(i.Z,{className:"h-5 w-5"}),title:M.wording.render})]}),[E.Gt.Remove,E.Gt.EmptyMyRoom].includes(en.mode)&&(0,n.jsx)(W,{remove:{title:M.wording.removeObjects,disabled:"idle"!==eN,fcn:()=>{if(ev){eK({variant:"destructive",description:(0,n.jsx)(ej.Zu,{}),duration:S.QE});return}let e=eV();if(!e){eK({variant:"destructive",description:(0,n.jsx)(ej.h6,{}),duration:S.QE});return}let t={...en,mode:E.Gt.Remove};es(t),tc({...Y,...ea,masks:[{..._.z7,mask:e,prompt:V,misc:{...t}}]})}},empty:{title:M.wording.emptyMyRoom,disabled:"idle"!==eN,fcn:()=>{if(ev){eK({variant:"destructive",description:(0,n.jsx)(ej.Zu,{}),duration:S.QE});return}let e=eV();if(e){eK({variant:"destructive",description:(0,n.jsx)(ej.kg,{}),duration:S.QE});return}let t={...en,mode:E.Gt.EmptyMyRoom};es(t),tc({...Y,...ea,masks:[{..._.z7,mask:e,prompt:V,misc:{...t}}]})}}})]})]})]}),(0,n.jsx)(eD.x,{})]})}r(52445);var ez=r(40213),eL=e=>{let{width:t="100%",height:r="100%"}=e;return(0,n.jsx)("div",{className:"animate-pulse-slow bg-gray-200",style:{width:t,height:r}})};function eO(e){var t,r;let{roomId:c,name:u,imgSize:d,wording:m,isOpen:x}=e,{state:f,dispatch:p}=(0,o.useAppContext)(),[g,v]=(0,s.useState)(""),D=(0,s.useRef)(null),Z=(0,s.useRef)(null),[I,P]=(0,s.useState)({..._.sr}),[T,M]=(0,s.useState)("loading"),[L,O]=(0,s.useState)({type:_.w6,style:_.UU}),[A,B]=(0,s.useState)(!1),[U,G]=(0,s.useState)("idle"),[X,Y]=(0,s.useState)([]),[K,V]=(0,s.useState)(null),[er,en]=(0,s.useState)(0),[es,ea]=(0,s.useState)(-1),el=(0,s.useRef)(""),ei=(0,s.useRef)(null),ec=(0,s.useRef)(null),[eu,ed]=(0,s.useState)({width:0,height:0}),[em,eh]=(0,s.useState)(E.ED.PaintBrush),[ex,ef]=(0,s.useState)(!1),[ep,eg]=(0,s.useState)(S.tA.default),[eb,ev]=(0,s.useState)(S.tA.default),[ew,eN]=(0,s.useState)(S.ZR.default),[ek,eE]=(0,s.useState)(""),[eZ,eI]=(0,s.useState)({..._.BS}),[eP,eT]=(0,s.useState)(!0),eM=(0,s.useRef)(!0),eO="".concat(R.We,"/render/").concat(c),{toast:eA}=(0,eR.pm)(),eB=()=>{var e;return null===(e=ei.current)||void 0===e||e.dispatchEvent(new CustomEvent("getmask",{})),el.current},eq=()=>{var e;null===(e=ei.current)||void 0===e||e.dispatchEvent(new CustomEvent("undomask",{}))},eU=()=>{var e;null===(e=ei.current)||void 0===e||e.dispatchEvent(new CustomEvent("resetmask",{}))},eG=()=>{eU(),B(!1)},eF=()=>{Z.current=null,en(0),V(null),G("idle")},eW=(e,t)=>{let r=X[es].url.split("/").pop();if(!r){v("Bug: error extracting editFileName.");return}let n=X.map(t=>{let n=t.url.split("/").pop();return n?n.includes("-source.")?t:n===r?{...t,key:e.key,url:"".concat(eO,"/").concat(e.key,"-source.").concat(e.ext)}:t:(v("Bug: error extracting historyFileName."),t)});n.push({width:d.width,height:d.height,key:e.key,ext:t.ext,url:"".concat(eO,"/").concat(e.key,"-").concat(t.seed,"-").concat(t.subseed,".").concat(t.ext)}),Y(n),ea(n.length-1)},eX=async()=>{if("decided"===U){eA({variant:"destructive",description:(0,n.jsx)(ej.Zu,{}),duration:S.QE});return}G("decided"),localStorage.removeItem("roomData_".concat(c));let{input:e,outputs:t}=null!=K?K:{};if(!e||!t){v("Bug: no input or outputs to confirm.");return}let r=Z.current;if(!r){v("Bug: no pending room to confirm.");return}let s=t[er].output,{err:a,res:o}=await (0,eC.rc)({_id:c,outputs:[s]});if(a){v("Error confirming room.");return}o&&(eW(e,s),P({...r,main_image:"".concat(e.key,"-").concat(s.seed,"-").concat(s.subseed,".").concat(s.ext),outputs:[s]}),eF())},eY=async()=>{if("decided"===U){eA({variant:"destructive",description:(0,n.jsx)(ej.Zu,{}),duration:S.QE});return}G("decided"),localStorage.removeItem("roomData_".concat(c));let e=D.current;if(!e){v("Bug: no last room to revert.");return}let{key:t,key_history:r,outputs:s}=e,{err:a,res:o}=await (0,eC.ht)({_id:c,key:t,key_history:r,outputs:s});if(a){v("Error reverting room.");return}o&&(P(e),eF())},eQ=async()=>{var e;let{err:t,res:r}=await (0,e_.tR)({_id:c});if(t||["paint_error","dead"].includes(null!==(e=null==r?void 0:r.phase)&&void 0!==e?e:"")){eA({variant:"destructive",description:(0,n.jsx)(ej.vn,{}),duration:S.QE,position:"bottom-center"}),eG();return}if((null==r?void 0:r.phase)==="painted"){let e=r.key_history.find(e=>e.key===r.key);if(!e){v("Bug: error finding key."),eG();return}Z.current=r;let t={key:r.key,key_history:r.key_history,outputs:r.outputs};localStorage.setItem("roomData_".concat(c),JSON.stringify(t));let n=r.outputs.map(t=>({output:{...t},url:"".concat(eO,"/").concat(e.key,"-").concat(t.seed,"-").concat(t.subseed,".").concat(t.ext)}));if(!f.user.is_plus)for(n=n.slice(0,1);n.length<2;)n.push(n[0]);V({input:e,outputs:n}),eG(),G("deciding")}else setTimeout(eQ,1e3)},eJ=async e=>{if(v(""),!1==f.user.is_plus&&f.user.num_credit<1){v(f.wording.submit.errorNoCreditsLeft),p({type:"OPEN_SUB_SETTINGS"});return}if(A)return;B(!0),p({type:"CONSUME_CREDIT"}),P(e);let{main_image:t,masks:r,model:n,type:s,style:a,tags:o,lighting:l,color:i,texture:u,version:d,width:m,height:h,is_detailed:x,is_furnish:g}=e,{err:b,res:w}=await (0,e_.$X)({_id:c,submission:{tool:"inpaint",main_image:t,masks:r,model:n,type:s,style:a,tags:o,lighting:l,color:i,texture:u,version:d,width:m,height:h,is_detailed:x,is_furnish:g}});b?(B(!1),v("Error submitting room.")):(D.current=e,eQ())},eH=e=>{let t=e.split(".").pop();(0,z.GN)("".concat(e,"?t=").concat(new Date().getTime()),"".concat(new Date().getTime(),".").concat(t))},eK=e=>{if(!I||e===es)return;M("loading"),ea(e);let t=X[e].url.split("/").pop(),r=null==t?void 0:t.split(".");if(!r){v("Bug: error extracting image name.");return}let[n,s]=r;if(n.includes("-source")){let e=n.split("-source")[0];P({...I,key:e,main_image:"".concat(e,".").concat(s)})}else{let e=eS(n);if(!e){v("Bug: error extracting image name.");return}let{key:t,seed:r,subseed:a}=e;P({...I,key:t,main_image:"".concat(t,"-").concat(r,"-").concat(a,".").concat(s)})}eU()};(0,s.useEffect)(()=>{let e=ec.current;if(!e)return;let t=()=>{let t,r;let n=e.clientWidth,s=e.clientHeight,a=d.width/d.height;n/s>a?t=(r=s)*a:r=(t=n)/a,ed({width:t,height:r})};return t(),e.addEventListener("resize",t),()=>{e.removeEventListener("resize",t)}},[d.width,d.height]),(0,s.useEffect)(()=>{let e=e=>e.map(e=>{let{key:t,ext:r}=e;return{width:d.width,height:d.height,key:t,ext:r,url:"".concat(eO,"/").concat(t,"-source.").concat(r)}}),t=(e,t,r)=>{let{seed:n,subseed:s,ext:a}=t;e.push({width:d.width,height:d.height,key:r,ext:a,url:"".concat(eO,"/").concat(r,"-").concat(n,"-").concat(s,".").concat(a)}),P(e=>({...e,main_image:"".concat(r,"-").concat(n,"-").concat(s,".").concat(a)}))},r=(e,t)=>{Z.current=e;let r=t.key_history.find(e=>e.key===t.key);if(!r){v("No last input found.");return}if(D.current={...e,...t},!f.user.is_plus)for(;t.outputs.length<2;)t.outputs.push(t.outputs[0]);V({input:{...r},outputs:t.outputs.map(e=>({output:e,url:"".concat(eO,"/").concat(t.key,"-").concat(e.seed,"-").concat(e.subseed,".").concat(e.ext)}))}),G("deciding")},n=async n=>{let{key:s,key_history:a,outputs:o}=n;if(!a.length){v("No key history found.");return}P(n);let l=e(a),i=localStorage.getItem("roomData_".concat(c));i?r(n,JSON.parse(i)):1===o.length?t(l,o[0],s):o.length>1&&P({...n,outputs:[n.outputs[0]]}),Y(l),ea(l.length-1)};(async()=>{let{err:e,res:t}=await (0,e_.tR)({_id:c});if(e||!t){v(e?"Error getting room.":"No room found.");return}n(t)})()},[c]),(0,s.useEffect)(()=>{if(eM.current){eM.current=!1;return}if(![E.ED.PaintBrush,E.ED.Eraser].includes(em))return;ef(!0);let e=setTimeout(()=>{ef(!1)},500);return()=>clearTimeout(e)},[ep,eb]);let eV=A||"idle"!==U,e$="idle"===U?null===(t=X[es])||void 0===t?void 0:t.url:"";return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"fixed left-0 right-0 top-14 z-30 flex h-screen flex-col bg-white",children:(0,n.jsxs)("div",{className:(0,a.m6)("mx-auto flex w-full flex-grow flex-col gap-3 overflow-y-auto overflow-x-hidden p-3 pb-40"),style:{height:"calc(var(--vh, 1vh) * 100 - 0rem)"},children:[(0,n.jsxs)("div",{className:"flex flex-row items-center justify-between",children:[(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsx)(ez.Z,{className:"h-6 w-6"}),(0,n.jsx)("div",{className:"font-bold",children:f.wording.tools.inpaint})]}),(null===(r=X[es])||void 0===r?void 0:r.url)&&(0,n.jsxs)("button",{className:(0,a.m6)("rounded-full border border-transparent bg-gray-200 px-3 py-1 text-sm hover:border-gray-300",A&&"text-white"),onClick:()=>{window.location.href="/tools/inpaint",Y([]),ea(-1),p({type:"TOGGLE_WHITEBOARD",payload:{open:!1}})},disabled:A,children:[(0,n.jsx)(j.Z,{className:"mr-1 inline h-4 w-4"}),f.wording.uploadAgain]})]}),(0,n.jsxs)("div",{className:(0,a.m6)("relative flex min-h-80 w-full flex-col items-center justify-start justify-center overflow-hidden rounded border-1 border-stone-200 bg-truewhite"),ref:ec,children:[(0,n.jsxs)("div",{style:{width:eu.width,height:eu.height,maxWidth:"100%",maxHeight:"100%"},className:"relative",children:[(0,n.jsx)(ey,{size:eu,maskMode:em,containerRef:ei,maskRef:el,imageUrl:e$,imagePosition:{width:eu.width,height:eu.height,scale:1,offsetX:0,offsetY:0},positiveMode:eP,brushStrokeWidth:ep,eraserStrokeWidth:eb,magicWandTolerance:ew,setLoadingImageState:M,disabled:A}),"loading"===T&&(0,n.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-gray-300",children:(0,n.jsx)(eL,{})}),K&&(0,n.jsx)("div",{className:"absolute z-50",style:{width:eu.width,height:eu.height,maxWidth:"100%",maxHeight:"100%"},children:(0,n.jsx)(l.default,{src:K.outputs[er].url,alt:"output image",height:eu.height,width:eu.width,className:"h-full w-full select-none object-cover"})}),(0,n.jsx)(et,{maskMode:em,hints:f.wording.maskMode.hint}),ex&&(0,n.jsx)(ee,{children:(0,n.jsx)("div",{className:"rounded-full",style:{width:em===E.ED.PaintBrush?ep:eb,height:em===E.ED.PaintBrush?ep:eb,backgroundColor:"rgba(".concat(S.Of.r,", ").concat(S.Of.g,", ").concat(S.Of.b,", 0.5)")}})})]}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),(0,C.q)({name:"inpaint_download_main",value:""}),eH(K?K.outputs[er].url:X[es].url)},className:"absolute bottom-2 right-2 z-50 rounded-full bg-truewhite p-1 shadow-md active:bg-stone-200",style:{boxShadow:"rgba(0, 0, 0, 0.35) 0.1px 0.1px 1px 1.4px"},children:(0,n.jsx)(k.Z,{className:"h-3 w-3"})}),A&&(0,n.jsx)(ee,{className:"px-10",children:(0,n.jsx)(H.Z,{duration:3e4,textColor:"text-gray-300"})})]}),K&&(0,n.jsx)(n.Fragment,{children:(0,n.jsxs)("div",{className:"relative flex w-full items-center justify-between gap-4 rounded-md border-1 border-gray-200 bg-truewhite p-2",children:[K.outputs.map((e,t)=>(0,n.jsxs)("button",{className:(0,a.m6)("relative h-16 w-16 overflow-hidden rounded-md border-3 border-stone-200",t===er&&"border-gray-600"),onClick:()=>{f.user.is_plus||0===t?(M("loading"),en(t)):p({type:"OPEN_SUB_SETTINGS"})},children:[(0,n.jsx)(l.default,{src:e.url,alt:"output image ".concat(t),sizes:"(max-width: 600px) 100vw, 25vw",height:d.height/6,width:d.width/6,className:"z-0 h-full w-full select-none object-cover"}),!f.user.is_plus&&0!==t&&(0,n.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-black bg-opacity-50",children:(0,n.jsx)(y.Z,{color:"white",size:24})})]},t)),(0,n.jsxs)("div",{className:"flex h-full items-center gap-4",children:[(0,n.jsx)(F.Z,{onClick:()=>{if("decided"===U){eA({variant:"destructive",description:(0,n.jsx)(ej.Zu,{}),duration:S.QE});return}G("decided"),localStorage.removeItem("roomData_".concat(c));let e=D.current;if(!e){v("Bug: no last room to regenerate.");return}eF(),eJ({...e})},disabled:"decided"===U,icon:(0,n.jsx)(i.Z,{className:"h-5 w-5"}),title:f.wording.regenerate,className:"px-4 py-2"}),(0,n.jsxs)("div",{className:"flex h-full items-center gap-2",children:[(0,n.jsx)(J.Z,{Icon:j.Z,disabled:"decided"===U,onClick:eY,shape:"rectangle",className:"h-8 w-8 p-1"}),(0,n.jsx)(J.Z,{Icon:N.Z,disabled:"decided"===U,onClick:eX,shape:"rectangle",className:"h-8 w-8 p-1"})]})]})]})}),(0,n.jsx)(eo,{title:f.wording.maskMode.control.brushWidth,max:S.tA.max,min:S.tA.min,value:ep,onChange:e=>{eg(e)},Icon:h.Z,className:"relative left-0 top-0 w-full translate-x-0 translate-y-0"}),(0,n.jsxs)("div",{className:"flex w-full gap-2",children:[(0,n.jsxs)("button",{className:(0,a.m6)("flex flex-1 items-center justify-center gap-2 rounded-md border-1 border-gray-200 py-2 text-base font-semibold shadow",A&&"cursor-not-allowed text-stone-200"),onClick:()=>{(0,C.q)({name:"inpaint_canvas_reset",value:""}),eU()},disabled:eV,children:[(0,n.jsx)(w.Z,{className:"h-4 w-4"}),(0,n.jsx)("span",{className:"text-xs font-medium",children:m.reset})]}),(0,n.jsxs)("button",{className:(0,a.m6)("flex flex-1 items-center justify-center gap-2 rounded-md border-1 border-gray-200 py-2 text-base font-semibold shadow",A&&"cursor-not-allowed text-stone-200"),onClick:()=>{(0,C.q)({name:"inpaint_canvas_undo",value:""}),eq()},disabled:eV,children:[(0,n.jsx)(b.Z,{className:"h-4 w-4"}),(0,n.jsx)("span",{className:"text-xs font-medium",children:m.undo})]})]}),(0,n.jsxs)("div",{className:"relative flex h-20 min-h-20 w-full justify-center",children:[(0,n.jsx)("div",{className:(0,a.m6)("relative block aspect-square overflow-hidden rounded-md border-3 border-stone-200 bg-stone-50",0===es&&"border-gray-600"),children:X.length>0&&(0,n.jsx)(l.default,{src:X[0].url,alt:"source image",height:eu.height/6,width:eu.width/6,className:(0,a.m6)("z-0 h-20 w-20 cursor-pointer object-cover",eV?"cursor-not-allowed":"cursor-pointer"),onClick:()=>{eV||eK(0)}})}),(0,n.jsx)($,{slides:X,nShow:2,startId:1,selectedId:es,onSelect:eK,onDownload:e=>{(0,C.q)({name:"inpaint_download_history",value:""}),eH(e)},disabled:eV,device:"mobile"})]}),(0,n.jsx)("div",{children:(0,n.jsx)(Q,{modeNames:{[E.Gt.Style]:f.wording.editor.mode.style.title,[E.Gt.Change]:f.wording.editor.mode.change.title,[E.Gt.Remove]:f.wording.editor.mode.remove.title},editMode:eZ.mode,setEditMode:e=>{O({type:_.w6,style:_.UU}),eI({..._.BS,mode:e}),eE("")}})}),[E.Gt.Style,E.Gt.Change].includes(eZ.mode)&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(q,{misc:eZ,prompt:ek,typeStyle:L,setMisc:eI,setPrompt:eE,setTypeStyle:O,device:"mobile"}),(0,n.jsx)("div",{className:"w-full border-t-2"}),(0,n.jsx)(F.Z,{onClick:()=>{if(A){eA({variant:"destructive",description:(0,n.jsx)(ej.Zu,{}),duration:S.QE,position:"bottom-center"});return}let e=eB();if(!e){eA({variant:"destructive",description:(0,n.jsx)(ej.h6,{}),duration:S.QE,position:"bottom-center"});return}if(eZ.mode===E.Gt.Style&&L.type===_.w6&&L.style===_.UU){eA({variant:"destructive",description:(0,n.jsx)(ej.$n,{}),duration:S.QE,position:"bottom-center"});return}if(eZ.mode===E.Gt.Change&&!ek){eA({variant:"destructive",description:(0,n.jsx)(ej.X0,{}),duration:S.QE,position:"bottom-center"});return}eJ({...I,...L,masks:[{..._.z7,mask:e,prompt:ek,misc:{...eZ}}]})},disabled:"idle"!==U,icon:(0,n.jsx)(i.Z,{className:"h-5 w-5"}),title:f.wording.render})]}),eZ.mode===E.Gt.Remove&&(0,n.jsx)(W,{remove:{title:f.wording.removeObjects,disabled:"idle"!==U,fcn:()=>{if(A){eA({variant:"destructive",description:(0,n.jsx)(ej.Zu,{}),duration:S.QE,position:"bottom-center"});return}let e=eB();if(!e){eA({variant:"destructive",description:(0,n.jsx)(ej.h6,{}),duration:S.QE,position:"bottom-center"});return}let t={...eZ,mode:E.Gt.Remove};eI(t),eJ({...I,...L,masks:[{..._.z7,mask:e,prompt:ek,misc:{...t}}]})}},empty:{title:f.wording.emptyMyRoom,disabled:"idle"!==U,fcn:()=>{if(A){eA({variant:"destructive",description:(0,n.jsx)(ej.Zu,{}),duration:S.QE,position:"bottom-center"});return}let e=eB();if(e){eA({variant:"destructive",description:(0,n.jsx)(ej.kg,{}),duration:S.QE,position:"bottom-center"});return}let t={...eZ,mode:E.Gt.EmptyMyRoom};eI(t),eJ({...I,...L,masks:[{..._.z7,mask:e,prompt:ek,misc:{...t}}]})}},device:"mobile"}),(0,n.jsx)("div",{className:"w-full border-t-2"}),(0,n.jsx)("div",{className:"flex w-full justify-center",children:(0,n.jsx)("button",{className:(0,a.m6)("rounded-md border-2 border-gray-200 bg-truewhite px-12 py-2 text-base font-semibold shadow",(A||X.length<=1)&&"cursor-not-allowed text-stone-200"),onClick:()=>{window.location.href="/r/".concat(c)},disabled:A||X.length<=1,children:f.wording.done})})]})}),(0,n.jsx)(eD.x,{})]})}var eA=()=>{let{state:{wording:e,is_open_whiteboard:t,whiteboard_images:r}}=(0,o.useAppContext)(),l=(0,z.YQ)();if((0,s.useEffect)(()=>{let e=()=>{let e=.01*window.innerHeight;document.documentElement.style.setProperty("--vh","".concat(e,"px"))};return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}},[]),0===r.length||!t)return null;let{id:i,name:c,width:u,height:d}=r[r.length-1];return l?(0,n.jsx)(eO,{roomId:i,name:c,imgSize:{width:u,height:d},wording:e,isOpen:t},i):(0,n.jsx)("div",{className:(0,a.m6)("fixed inset-0 z-30 flex h-screen w-screen items-center justify-center bg-white bg-opacity-80 px-6 py-4 backdrop-blur-[2px]"),children:(0,n.jsx)("div",{className:"mx-auto flex h-full w-full max-w-[1600px] flex-col overflow-hidden rounded-lg border-2 border-gray-400 bg-truewhite shadow-lg",children:(0,n.jsx)(eM,{roomId:i,name:c,imgSize:{width:u,height:d},wording:e,isOpen:t},i)})})}},3528:function(e,t,r){"use strict";r.d(t,{F:function(){return a}});var n=r(2265),s=r(4009);let a=()=>{let[e,t]=(0,n.useState)(!1),[r,a]=(0,n.useState)(0),[o,l]=(0,n.useState)(null);return{uploadToS3:(0,n.useCallback)(async e=>{t(!0),a(0),l(null),console.log("Uploading file to S3...");try{let t,r;if("string"==typeof e){let n=(0,s.Jr)(e,"image/png");r="image_".concat(Date.now(),".png"),t=new File([n],r,{type:"image/png"})}else r=(t=e).name;let n=await fetch("/api/upload",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fileName:r})});if(!n.ok)throw Error("Failed to get upload URL");let{uploadUrl:o,fileName:l}=await n.json();return await new Promise((e,r)=>{let n=new XMLHttpRequest;n.open("PUT",o,!0),n.upload.onprogress=e=>{if(e.lengthComputable){let t=Math.round(e.loaded/e.total*100);a(t)}},n.onload=()=>{n.status>=200&&n.status<300?(console.log("File successfully uploaded"),e()):r(Error("Failed to upload file"))},n.onerror=()=>{r(Error("Failed to upload file"))},n.send(t)}),l}catch(e){throw console.error(e),l(e instanceof Error?e.message:"Unknown error occurred"),e}finally{t(!1)}},[]),isUploading:e,uploadProgress:r,uploadError:o}}},81362:function(e,t,r){"use strict";r.d(t,{CH:function(){return o},DJ:function(){return g},Eb:function(){return d},Jh:function(){return w},Nq:function(){return n},R9:function(){return v},X8:function(){return i},Yt:function(){return m},bG:function(){return c},c2:function(){return u},lo:function(){return l},mY:function(){return a},r4:function(){return s},sA:function(){return p},v3:function(){return x},v9:function(){return f},xM:function(){return b},ym:function(){return h}}),r(92730),r(46619),r(49079);let n=async e=>{let{name:t,company:r}=e;try{let e=await fetch("/api/users",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,company:r})}),n=await e.json();if(!e.ok)return{err:n.err||n,result:null};return{err:null,res:n}}catch(e){return{err:e,res:null}}},s=async e=>{let{token:t,source:r,campaign:n}=e;try{let e=await fetch("/api/users",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t,source:r,campaign:n})}),s=await e.json();if(!e.ok)return{err:s.err||s,res:null};return{err:null,res:s}}catch(e){return{err:e,res:null}}},a=async()=>{try{let e=await fetch("/api/users/renders",{method:"GET",headers:{"Content-Type":"application/json"}}),t=await e.json();if(!e.ok)return{err:t.err||t,result:null};return{err:null,res:t}}catch(e){return{err:e,res:null}}},o=async e=>{let{is_annual:t}=e;try{let e=await fetch("/api/users/upgrade-plus",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({referral:"",is_annual:t})}),r=await e.json();if(!e.ok)return{err:r.err||r,result:null};return{err:null,res:r}}catch(e){return{err:e,res:null}}},l=async()=>{try{let e=await fetch("/api/users/stripe-charge",{method:"GET",headers:{"Content-Type":"application/json"}}),t=await e.json();if(!e.ok)return{err:t.err||t,result:null};return{err:null,res:t}}catch(e){return{err:e,res:null}}},i=async e=>!!(await fetch("".concat("https://reroom.ai","/api/users/unsubscribe?email=").concat(encodeURIComponent(e)))).ok,c=async()=>{try{let e=await fetch("/api/users/get-info",{method:"GET",headers:{"Content-Type":"application/json"}}),t=await e.json();if(!e.ok)return{err:t.err||t,result:null};return{err:null,res:t}}catch(e){return{err:e,res:null}}},u=async e=>{try{let t=await fetch("/api/breadcrumbs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),r=await t.json();if(!t.ok)return{err:r,res:null};return{err:null,res:r}}catch(e){return{err:e,res:null}}},d=async e=>{let{_id:t,geolocation:r}=e;try{let e=await fetch("/api/breadcrumbs/".concat(t),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}),n=await e.json();if(!e.ok)return{err:n,res:null};return{err:null,res:n}}catch(e){return{err:e,res:null}}},m=async()=>{try{let e=await fetch("https://ipv4-check-perf.radar.cloudflare.com/api/info"),t=await e.json();if(!e.ok)return{err:t,result:null};return{err:null,res:t}}catch(e){return{err:e,res:null}}},h=async e=>{try{let t=await fetch("/api/users/geolocation",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),r=await t.json();if(!t.ok)return{err:r.err||r,result:null};return{err:null,res:r}}catch(e){return{err:e,res:null}}},x=async e=>{let{token:t}=e;try{let e=await fetch("/api/users/web-push",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t})}),r=await e.json();if(!e.ok)return{err:r.err||r,result:null};return{err:null,res:r}}catch(e){return{err:e,res:null}}},f=async e=>{let{email:t}=e;try{let e=await fetch("/api/users/unsubscribe?email=".concat(encodeURIComponent(t))),r=await e.json();if(!e.ok)return{err:r,result:null};return{err:null,res:r}}catch(e){return{err:e,res:null}}},p=async()=>{try{let e=await fetch("/api/users/get-invoices",{method:"GET",headers:{"Content-Type":"application/json"}}),t=await e.json();if(!e.ok)return{err:t.err||t,result:null};return{err:null,res:t}}catch(e){return{err:e,res:null}}},g=async e=>{let{discountCode:t,instagramAccount:r}=e;try{let e=await fetch("/api/users/join-program",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({discount_code:t,instagram_account:r})}),n=await e.json();if(!e.ok)return{err:n.err||n,result:null};return{err:null,res:n}}catch(e){return{err:e,res:null}}},b=async e=>{let{message:t}=e;try{let e=await fetch("/api/chatrooms",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:t})}),r=await e.json();if(!e.ok)return{err:r,result:null};return{err:null,res:r}}catch(e){return{err:e,res:null}}},v=async()=>{try{let e=await fetch("/api/users/get-affiliate-code",{method:"GET",headers:{"Content-Type":"application/json"}}),t=await e.json();if(!e.ok)return{err:t.err||t,result:null};return{err:null,res:t}}catch(e){return{err:e,res:null}}},w=async e=>{let{type:t}=e;try{let e=await fetch("/api/users/credits",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:t})}),r=await e.json();if(!e.ok)return{err:r,result:null};return{err:null,res:r}}catch(e){return{err:e,res:null}}}},52445:function(){}},function(e){e.O(0,[6807,8310,8154,875,1501,703,1367,5250,3663,3710,1682,662,6437,952,5541,5332,2547,8124,2971,8069,1744],function(){return e(e.s=912)}),_N_E=e.O()}]);