1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[842],{6002:function(t,e,n){n.d(e,{BG:function(){return p},CM:function(){return R},FZ:function(){return A},Nm:function(){return h},WV:function(){return S},checkPrediction:function(){return m},dn:function(){return P},getPrediction:function(){return f},jo:function(){return I},qq:function(){return s},sU:function(){return d},savePhotoVersion:function(){return v},t6:function(){return T},v6:function(){return b},wP:function(){return u}});var o=n(5978);n(48878);var r=n(45569),i=n(48190),a=n(85434),c=n(91907),l=n(29486);let s=async(t,e)=>{let n={url:e,createdAt:o.Timestamp.now()},i=await (0,o.addDoc)((0,o.collection)(r.db,"users/".concat(t.uid,"/photos")),n);return(0,c.e)("upload"),i.id},u=async function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:50,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(!(null==t?void 0:t.uid))throw Error("User must be authenticated");try{let i=(0,o.IO)((0,o.collection)(r.db,"users/".concat(t.uid,"/photos")),(0,o.Xo)("createdAt","desc"));e&&(i=(0,o.IO)(i,(0,o.b9)(e))),n&&(i=(0,o.IO)(i,(0,o.TQ)(n)));let a=await (0,o.PL)(i);return{photos:a.docs.map(t=>({id:t.id,...t.data()})),lastDoc:a.docs.length>0?a.docs[a.docs.length-1]:null}}catch(t){throw console.error("Error fetching photos:",t),t}},d=async(t,e)=>(await (0,o.getDoc)((0,o.doc)(r.db,"users/".concat(t.uid,"/photos/").concat(e)))).data(),h=async(t,e)=>{await (0,o.oe)((0,o.doc)(r.db,"users/".concat(t.uid,"/photos/").concat(e)))},f=async function(t,e,o,r,a,c){let s,u=arguments.length>6&&void 0!==arguments[6]?arguments[6]:null,d=arguments.length>7&&void 0!==arguments[7]?arguments[7]:null,h=arguments.length>8&&void 0!==arguments[8]&&arguments[8],f=arguments.length>9&&void 0!==arguments[9]?arguments[9]:"free",m=arguments.length>10&&void 0!==arguments[10]?arguments[10]:null,p=arguments.length>11&&void 0!==arguments[11]?arguments[11]:null,g=arguments.length>12&&void 0!==arguments[12]&&arguments[12],w=arguments.length>13&&void 0!==arguments[13]&&arguments[13],y=arguments.length>14&&void 0!==arguments[14]?arguments[14]:null,v=arguments.length>15&&void 0!==arguments[15]?arguments[15]:null,b=v?(0,l.po)(v):l.SA;if("builder"===e){if(r)s=r;else{let t=o.toLowerCase();s="Redesign this ".concat(t," with a custom style. ").concat(b)}}else if(e&&"builder"!==e){let{getStyle:t}=n(53086),a=n(65344).Z,c=t(e),l=u&&(e&&e.startsWith("furniture-")||r&&(r.includes("Add furniture to this room")||r.includes("Place the exact furniture")||r.includes("Place this")||r.includes("Keep all existing"))),h=d&&r&&r.includes("Clone the design"),f=o.toLowerCase(),m=i.FILTERS.map(t=>t.filters).flat().find(t=>t.id===e);if(m&&m.prompt){let t=a(m.prompt);s=l?r:h?r:"Redesign this ".concat(f," to ").concat(t,". ").concat(b)}else if(c&&c.prompt){let t=a(c.prompt);s=l?r:h?r:"Redesign this ".concat(f," to ").concat(t,". ").concat(b)}else if(e&&e.startsWith("custom-")&&r)s=r;else if(e&&e.startsWith("custom-")){if(window.customStylePrompts&&window.customStylePrompts[e])s=a(window.customStylePrompts[e]);else{let t=e.replace("custom-","").replace(/-/g," ");s="Redesign this ".concat(f," to ").concat(t," style. ").concat(b)}}else if(e){let t=e.replace(/-/g," ");s=l?r:"Redesign this ".concat(f," to ").concat(t," style. ").concat(b)}else s=l?r:"Redesign this ".concat(f,". ").concat(b)}else if(r)s=r;else{let t=o.toLowerCase();s="Redesign this ".concat(t,". ").concat(b)}let I=u&&(e&&e.startsWith("furniture-")||r&&(r.includes("Add furniture to this room")||r.includes("Place the exact furniture")||r.includes("Place this")||r.includes("Keep all existing"))),P=d&&r&&r.includes("Clone the design");I||P||!s||s.includes(l.nR)||s.includes(l.Pc)||(s+=". "+l.nR);let R={image:t,version:a,prompt:s,model:c||"arrange",qualityTier:f,...m&&{imageModel:m},...h&&{useFallback:!0},...p&&{photoId:p},...g&&{firstFreeAutoGeneration:!0},...w&&{isQualityRegenerate:!0}};u&&(R.furnitureImage=u),d&&(R.furnitureImage=d),y&&(R.referenceImage=y,R.referenceRole="same-room-angle");let A=null;try{let{auth:t}=n(45569);t.currentUser&&(A=await t.currentUser.getIdToken())}catch(t){}let S=await fetch("".concat("","/api/interior"),{method:"POST",headers:{"Content-Type":"application/json",...A&&{Authorization:"Bearer ".concat(A)}},body:JSON.stringify(R)});if(!S.ok){let t=await S.json();return console.error("API call failed:",S.status,t),{error:t.detail||"API call failed"}}return await S.json()},m=async t=>{try{if((null==t?void 0:t.status)==="succeeded"||(null==t?void 0:t.status)==="failed")return t;let e=await fetch("/api/interior?id="+t.id,{method:"GET"});if(!e.ok)return console.error("Check prediction failed:",e.status,e.statusText),null;return await e.json()}catch(t){return console.error("Error checking prediction:",t),null}},p=async(t,e,n)=>{try{await (0,o.addDoc)((0,o.collection)(r.db,"feedback"),{email:t,type:e,text:n,createdAt:o.Timestamp.now()});let i=(0,a.V1)(r.functions,"sendReviewEmail");return await i({email:t,rating:e,text:n}),!0}catch(t){return console.error("Error saving feedback: ",t),!1}},g=async(t,e,n,o)=>{try{let e=r.auth.currentUser;if(!e)throw Error("Not authenticated");let o=await e.getIdToken(),i=await fetch("/api/rehost-image",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(o)},body:JSON.stringify({imageUrl:t,photoId:n})});if(!i.ok)throw Error("Rehost request failed: ".concat(i.status));let{url:a}=await i.json();return a||t}catch(e){return console.error("Error uploading image to storage:",e),t}},w=t=>{try{let e=new URL(t);return["firebasestorage.googleapis.com","storage.googleapis.com"].includes(e.hostname)}catch(t){return!1}},y=t=>!!t&&"string"==typeof t&&(!!t.startsWith("data:")||/^https?:\/\//.test(t)&&!w(t)),v=async function(t,e,n){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},a="version_".concat(Date.now()),c=n;y(n)&&(c=await g(n,t.uid,e,a));let l={id:a,url:c,photoId:e,isFavorite:i.isFavorite||!1,style:i.style||null,model:i.model||null,imageModel:i.imageModel||null,prompt:i.prompt||null,createdAt:o.Timestamp.now(),...i};return await (0,o.setDoc)((0,o.doc)(r.db,"users/".concat(t.uid,"/photos/").concat(e,"/versions/").concat(a)),l),(0,o.setDoc)((0,o.doc)(r.db,"users/".concat(t.uid,"/recentGenerations/").concat(a)),{id:a,url:c,photoId:e,style:i.style||null,model:i.model||null,imageModel:i.imageModel||null,createdAt:o.Timestamp.now()}).catch(()=>{}),{versionId:a,url:c}},b=async(t,e,n)=>{await (0,o.updateDoc)((0,o.doc)(r.db,"users/".concat(t.uid,"/photos/").concat(e,"/versions/").concat(n)),{isFavorite:!0})},I=async function(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:50,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,a=(0,o.IO)((0,o.collection)(r.db,"users/".concat(t.uid,"/photos/").concat(e,"/versions")),(0,o.Xo)("createdAt","desc"));return n&&(a=(0,o.IO)(a,(0,o.b9)(n))),i&&(a=(0,o.IO)(a,(0,o.TQ)(i))),(await (0,o.PL)(a)).docs.map(t=>({...t.data(),id:t.id}))},P=async(t,e,n,i)=>{await (0,o.updateDoc)((0,o.doc)(r.db,"users/".concat(t.uid,"/photos/").concat(e,"/versions/").concat(n)),{isFavorite:i})},R=async(t,e,n)=>{await (0,o.oe)((0,o.doc)(r.db,"users/".concat(t.uid,"/photos/").concat(e,"/versions/").concat(n)))},A=async function(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i="photo_".concat(Date.now()),a=e;!1!==n.forceUpload&&y(e)&&(a=await g(e,t.uid,i,"main"));let{forceUpload:c,...l}=n,s={url:a,name:l.name||"New Room Design",source:"redesign",originalPhotoId:l.originalPhotoId||null,style:l.style||null,model:l.model||null,imageModel:l.imageModel||null,createdAt:o.Timestamp.now(),...l};return(await (0,o.addDoc)((0,o.collection)(r.db,"users/".concat(t.uid,"/photos")),s)).id},S=async(t,e,n)=>{let i=await (0,o.getDoc)((0,o.doc)(r.db,"users/".concat(t.uid,"/photos/").concat(e,"/versions/").concat(n)));return i.exists()?{id:i.id,...i.data()}:null},T=async function(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:12;if(!(null==t?void 0:t.uid))return[];let i=Date.now()-36e5*n;try{let e=(0,o.IO)((0,o.collection)(r.db,"users/".concat(t.uid,"/recentGenerations")),(0,o.Xo)("createdAt","desc"),(0,o.b9)(20));return(await (0,o.PL)(e)).docs.map(t=>({...t.data(),id:t.id})).filter(t=>{var e,n,o,r;return((null===(e=t.createdAt)||void 0===e?void 0:e.seconds)?1e3*t.createdAt.seconds:null!==(r=null===(o=t.createdAt)||void 0===o?void 0:null===(n=o.toMillis)||void 0===n?void 0:n.call(o))&&void 0!==r?r:0)>=i})}catch(t){return console.error("Error fetching recent generations:",t),[]}}},46990:function(t,e,n){n.d(e,{C_:function(){return c},iG:function(){return a},rd:function(){return l}});var o=n(45569),r=n(5978);let i=t=>
1(0,r.collection)(o.db,"users/".concat(t,"/customStyles"));async function a(t){let e=(0,r.IO)(i(t),(0,r.Xo)("createdAt","desc"),(0,r.b9)(50));return(await (0,r.PL)(e)).docs.map(t=>({id:t.id,...t.data()}))}async function c(t,e){let{name:n,prompt:o,source:a}=e;return(await (0,r.addDoc)(i(t),{name:n,prompt:o,source:a,createdAt:r.Timestamp.now()})).id}async function l(t,e){await (0,r.oe)((0,r.doc)(o.db,"users/".concat(t,"/customStyles"),e))}},59057:function(t,e,n){let o=(0,n(59625).Ue)(t=>({image:"",isLoading:!0,prompt:"",hideGlobalWidgets:!1,promptLabel:null,promptChips:null,lastResultUrl:null,lastResultStyle:null,lastResultPhotoId:null,roomGenerationCounts:{},setImage:e=>t({image:e}),setIsLoading:e=>t({isLoading:e}),setPrompt:function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return t({prompt:e,promptLabel:n,promptChips:o})},setHideGlobalWidgets:e=>t({hideGlobalWidgets:e}),setLastResult:function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return t({lastResultUrl:e,lastResultStyle:n,lastResultPhotoId:o})},incrementRoomGenerationCount:e=>t(t=>({roomGenerationCounts:{...t.roomGenerationCounts,[e]:(t.roomGenerationCounts[e]||0)+1}}))}));e.Z=o},53086:function(t,e,n){n.r(e),n.d(e,{getAllStyles:function(){return l},getFilterCategoryForStyle:function(){return c},getLastPercentage:function(){return i},getStyle:function(){return a},normalizeStyleImage:function(){return r}});var o=n(48190);let r=t=>!t||t.startsWith("/images/")?t:"/images/".concat(t.replace(/^\//,"")),i=t=>{let e=t.match(/(\d+)%[^%]*$/);return e?parseInt(e[1],10):-1},a=t=>o.FILTERS.map(t=>t.filters).flat().filter(e=>e.id===t)[0],c=t=>{for(let e of o.FILTERS)if(e.filters.some(e=>e.id===t))return e.id;return null},l=()=>o.FILTERS.flatMap(t=>t.filters.filter(t=>"weekly-special"!==t.id).map(t=>({id:t.id,label:t.label,prompt:t.prompt,image:r(t.image),free:!0===t.free,popular:t.popular||!1})))},65344:function(t,e,n){var o=n(36974);e.Z=t=>{if(t&&t.startsWith("import:")){let e=t.replace("import:","");return({weeklySpecialPrompt:o.Z})[e]||t}return t}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.