PageSourceSearch

https://lucyeditai.ai/_next/static/chunks/4304-f6582b39ba996ff6.js

js lucyeditai.ai collected 2026-10-05 12:14:26 UTC 24,278 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4304],{64304:(e,s,t)=>{t.d(s,{f:()=>$});var a=t(88795),l=t(23716),i=t(40262),r=t(29877),n=t(42575),d=t(51968),c=t(68553),o=t(22946),m=t(50519),x=t(63051),u=t(40086),p=t(99966),h=t(92971),g=t(505),f=t(66517),v=t(68939),j=t(45663),b=t(50472),y=t(8780),N=t(27514),w=t(20877);function k(){let e=(0,f.c3)("components.previewArea");return(0,a.jsx)("div",{className:"flex justify-center py-4",children:(0,a.jsxs)("div",{className:"flex flex-col items-center gap-1.5 sm:gap-2",children:[(0,a.jsx)("div",{className:"w-6 h-6 sm:w-7 sm:h-7 rounded-full bg-blue-100 flex items-center justify-center",children:(0,a.jsx)(w.A,{className:"h-3 w-3 sm:h-3.5 sm:w-3.5 animate-spin text-blue-600"})}),(0,a.jsx)("span",{className:"text-xs sm:text-sm text-slate-600 font-medium",children:e("infiniteScroll.loadingMore")})]})})}function A(){let e=(0,f.c3)("components.previewArea");return(0,a.jsx)("div",{className:"text-center py-4",children:(0,a.jsxs)("div",{className:"flex items-center justify-center gap-1",children:[(0,a.jsx)("div",{className:"w-1.5 h-1.5 sm:w-2 sm:h-2 rounded-full bg-slate-300"}),(0,a.jsx)("span",{className:"text-xs sm:text-sm text-slate-500 font-medium",children:e("infiniteScroll.allContentDisplayed")})]})})}var C=t(3862),I=t(60338),D=t(58311),E=t(19519),S=t(21010),U=t(29340),P=t(87274),T=t(79469),M=t(75307),O=t(66389),F=t(78410),L=t(83867),K=t(98276),R=t(98445);function W(e){var s;let{output:t,taskId:l,maxDisplay:d=9,gridCols:c=3,className:o="",prompt:m,model:x,status:p,creditsUsed:h,createdAt:g,completedAt:j,error:b,metadata:N}=e,w=(0,f.c3)("components.previewArea.taskImageGallery"),k=(0,D.ev)(N),[A,C]=(0,v.useState)(new Set),[I,W]=(0,v.useState)(!1),[z,q]=(0,v.useState)(0),[Z,J]=(0,v.useState)(null),[$,_]=(0,v.useState)(!1),[B,G]=(0,v.useState)(!1),[H,Q]=(0,v.useState)(0),V=(0,v.useMemo)(()=>(0,R.Xw)(x||"",m||"",N||{}),[x,m,N]),X=(0,v.useMemo)(()=>(0,S.x)(t),[t]);if(0===X.length)return null;let Y=e=>{C(s=>new Set(s).add(e))},ee=e=>{q(e),W(!0)},es=e=>{Q(e),G(!0)},et=async(e,s)=>{try{let t,a="nano-banana-".concat(l,"-").concat(s+1,".png"),i=!1;try{t=await (0,P.addWatermarkToImage)(e)}catch(r){console.warn("Failed to add watermark, downloading original:",r);let s=await fetch("/api/download-image?url=".concat(encodeURIComponent(e),"&filename=").concat(a));if(!s.ok)throw Error(w("downloadFailed"));let l=await s.blob();t=window.URL.createObjectURL(l),i=!0}let r=document.createElement("a");r.href=t,r.download=a,document.body.appendChild(r),r.click(),document.body.removeChild(r),i&&window.URL.revokeObjectURL(t),K.o.success(w("downloadSuccess"))}catch(e){console.error("Download failed:",e),K.o.error(w("downloadFailed"))}},ea=async()=>{_(!0);let e=0,s=0;try{for(let t=0;t<X.length;t++)try{let s=await fetch("/api/download-image?url=".concat(encodeURIComponent(X[t]),"&filename=nano-banana-").concat(l,"-").concat(t+1,".png"));if(!s.ok)throw Error(w("downloadFailed"));let a=await s.blob(),i=window.URL.createObjectURL(a),r=document.createElement("a");r.href=i,r.download="nano-banana-".concat(l,"-").concat(t+1,".png"),document.body.appendChild(r),r.click(),document.body.removeChild(r),window.URL.revokeObjectURL(i),e++,t<X.length-1&&await new Promise(e=>setTimeout(e,500))}catch(e){console.error("Download failed for image ".concat(t+1,":"),e),s++}0===s?K.o.success(w("batchDownloadSuccess",{count:e})):K.o.warning(w("batchDownloadPartial",{success:e,failed:s}))}catch(e){console.error("Batch download failed:",e),K.o.error(w("batchDownloadFailed"))}finally{_(!1)}},el=X.slice(0,d),ei=X.length-d,er=X.length>1;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"grid gap-2 ".concat(o),style:{gridTemplateColumns:"repeat(".concat(c,", 1fr)")},children:[el.map((e,s)=>(0,a.jsx)(n.Zp,{className:"group cursor-pointer overflow-hidden hover:shadow-md transition-all duration-200",onClick:()=>ee(s),children:(0,a.jsxs)("div",{className:"aspect-square relative overflow-hidden",children:[A.has(s)?(0,a.jsx)("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:(0,a.jsx)(u.A,{className:"h-6 w-6"})}):(0,a.jsx)(P.D,{src:e,alt:"Task ".concat(l," result ").concat(s+1),fill:!0,className:"object-cover group-hover:scale-105 transition-transform duration-200",sizes:"(max-width: 768px) 100vw, (max-width: 1024px) 50vw, 33vw",unoptimized:!0,onError:()=>Y(s)}),er&&0===s&&(0,a.jsx)("div",{className:"absolute top-2 right-2",children:(0,a.jsxs)(i.E,{variant:"secondary",className:"bg-black/50 text-white border-0",children:["+",X.length-1]})})]})},"".concat(l,"-").concat(s))),ei>0&&(0,a.jsx)("div",{className:"aspect-square rounded border bg-muted flex items-center justify-center cursor-pointer hover:bg-muted/80 transition-colors",onClick:()=>ee(d),children:(0,a.jsxs)("span",{className:"text-xs text-muted-foreground",children:["+",ei]})})]}),(0,a.jsx)(U.M,{open:I,onOpenChange:W,media:X.map(e=>({url:e,type:"image"})),currentIndex:z,onIndexChange:q,inputMedia:k.map(e=>({url:e,type:"image",isInputMedia:!0})),taskId:l,downloadingIndex:Z,isBatchDownloading:$,onDownload:et,onBatchDownload:ea,detailsContent:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.Zp,{children:(0,a.jsxs)(n.Wu,{className:"px-2 sm:px-3 md:px-4 py-2 sm:py-3 md:py-4",children:[(0,a.jsx)("h3",{className:"text-sm sm:text-base md:text-lg font-semibold mb-1.5 sm:mb-2 md:mb-3",children:w("basicInfo")}),(0,a.jsxs)("div",{className:"grid gap-2 md:gap-3 text-xs md:text-sm",children:[void 0!==p&&(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("span",{className:"text-muted-foreground",children:[w("status"),":"]}),2===p?(0,a.jsx)(i.E,{variant:"secondary",className:"bg-green-100 text-green-700",children:w("statusCompleted")}):3===p?(0,a.jsx)(i.E,{variant:"destructive",children:w("statusFailed")}):1===p?(0,a.jsx)(i.E,{variant:"outline",children:w("statusProcessing")}):(0,a.jsx)(i.E,{variant:"outline",children:w("statusUnknown")})]}),g&&(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(M.A,{className:"h-3 w-3 md:h-4 md:w-4 text-muted-foreground"}),(0,a.jsxs)("span",{className:"text-muted-foreground",children:[w("createdAt"),":"]}),(0,a.jsx)("span",{className:"text-xs md:text-sm",children:new Date(g).toLocaleStr
1ing("zh-CN")})]}),void 0!==h&&(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(y.A,{className:"h-3 w-3 md:h-4 md:w-4 text-muted-foreground"}),(0,a.jsxs)("span",{className:"text-muted-foreground",children:[w("creditsUsed"),":"]}),(0,a.jsx)("span",{className:"font-medium",children:h})]}),j&&(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(O.A,{className:"h-3 w-3 md:h-4 md:w-4 text-muted-foreground"}),(0,a.jsxs)("span",{className:"text-muted-foreground",children:[w("completedAt"),":"]}),(0,a.jsx)("span",{className:"text-xs md:text-sm",children:new Date(j).toLocaleString("zh-CN")})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("span",{className:"text-muted-foreground",children:[w("imageCount"),":"]}),(0,a.jsx)("span",{children:X.length})]})]})]})}),(0,a.jsx)(n.Zp,{children:(0,a.jsxs)(n.Wu,{className:"px-2 sm:px-3 md:px-4 py-2 sm:py-3 md:py-4",children:[(0,a.jsx)("h3",{className:"text-sm sm:text-base md:text-lg font-semibold mb-1.5 sm:mb-2 md:mb-3",children:w("inputInfo")}),k.length>0&&(0,a.jsxs)("div",{className:"mb-2 sm:mb-3 md:mb-4",children:[(0,a.jsx)("h4",{className:"text-xs md:text-sm font-medium text-muted-foreground mb-2",children:w("inputImages")}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:k.map((e,s)=>(0,a.jsx)("div",{className:"relative w-16 h-16 rounded-lg overflow-hidden border bg-muted cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>es(s),children:(0,a.jsx)("img",{src:e,alt:"".concat(w("inputImage")," ").concat(s+1),className:"w-full h-full object-cover",loading:"lazy"})},s))})]}),(null===(s=V.prompt)||void 0===s?void 0:s.trim())&&(0,a.jsxs)("div",{className:"mb-2 sm:mb-3 md:mb-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.jsx)("h4",{className:"text-xs md:text-sm font-medium text-muted-foreground",children:w("prompt")}),(0,a.jsx)(E.i8,{text:V.prompt,label:w("prompt")})]}),(0,a.jsx)("div",{className:"p-2 md:p-3 bg-muted rounded-lg",children:(0,a.jsx)("p",{className:"text-xs md:text-sm whitespace-pre-wrap",children:V.prompt})})]}),(x||Object.keys(V.modelFields||{}).length>0)&&(0,a.jsx)("div",{className:"border-t border-border mb-2 sm:mb-3 md:mb-4"}),(x||Object.keys(V.modelFields||{}).length>0)&&(0,a.jsxs)("div",{children:[(0,a.jsx)("h4",{className:"text-xs md:text-sm font-medium text-muted-foreground mb-2",children:w("generationParams")}),(0,a.jsxs)("div",{className:"p-2 md:p-3 bg-muted rounded-lg space-y-1 md:space-y-2 text-xs",children:[x&&(0,a.jsxs)("div",{className:"flex justify-between",children:[(0,a.jsxs)("span",{className:"text-muted-foreground",children:[w("model"),":"]}),(0,a.jsx)("span",{children:(0,R.$L)(x)})]}),(0,R.tg)(x||"",V.modelFields||{}).map((e,s)=>(0,a.jsxs)("div",{className:"flex justify-between",children:[(0,a.jsxs)("span",{className:"text-muted-foreground",children:[e.label,":"]}),(0,a.jsx)("span",{children:e.value})]},s))]})]})]})}),(0,a.jsx)(n.Zp,{children:(0,a.jsxs)(n.Wu,{className:"px-2 sm:px-3 md:px-4 py-2 sm:py-3 md:py-4",children:[(0,a.jsx)("h3",{className:"text-sm sm:text-base md:text-lg font-semibold mb-1.5 sm:mb-2 md:mb-3",children:w("techInfo")}),(0,a.jsx)("div",{className:"grid gap-2 text-xs md:text-sm",children:(0,a.jsxs)("div",{className:"flex justify-between items-center",children:[(0,a.jsxs)("span",{className:"text-muted-foreground",children:[w("taskId"),":"]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"font-mono text-[10px] md:text-xs break-all",children:l}),(0,a.jsx)(E.i8,{text:l,label:w("taskId")})]})]})})]})}),b&&(0,a.jsx)(n.Zp,{className:"border-destructive/20",children:(0,a.jsxs)(n.Wu,{className:"px-2 sm:px-3 md:px-4 py-2 sm:py-3 md:py-4",children:[(0,a.jsx)("h3",{className:"text-sm sm:text-base md:text-lg font-semibold text-destructive mb-1.5 sm:mb-2 md:mb-3",children:w("errorInfo")}),(0,a.jsx)("div",{className:"p-2 md:p-3 bg-destructive/5 border border-destructive/20 rounded-lg",children:(0,a.jsx)("p",{className:"text-xs md:text-sm text-destructive",children:b})})]})})]})}),k.length>0&&(0,a.jsx)(T.lG,{open:B,onOpenChange:G,children:(0,a.jsxs)(T.Cf,{className:"max-w-[90vw] max-h-[90vh] p-6",children:[(0,a.jsx)(T.L3,{className:"sr-only",children:w("inputImagePreview")}),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("div",{className:"relative w-full h-[70vh] flex items-center justify-center bg-black/5 rounded-lg",children:(0,a.jsx)("img",{src:k[H],alt:"".concat(w("inputImage")," ").concat(H+1),loading:"lazy",className:"object-contain max-w-full max-h-full",sizes:"90vw"})}),k.length>1&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.$,{variant:"secondary",size:"icon",className:"absolute left-4 top-1/2 -translate-y-1/2 bg-black/50 hover:bg-black/70 text-white border-0",onClick:()=>{Q(H>0?H-1:k.length-1)},children:(0,a.jsx)(F.A,{className:"h-4 w-4"})}),(0,a.jsx)(r.$,{variant:"secondary",size:"icon",className:"absolute right-4 top-1/2 -translate-y-1/2 bg-black/50 hover:bg-black/70 text-white border-0",onClick:()=>{Q(H<k.length-1?H+1:0)},children:(0,a.jsx)(L.A,{className:"h-4 w-4"})})]}),k.length>1&&(0,a.jsx)("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 flex gap-1",children:k.map((e,s)=>(0,a.jsx)("button",{type:"button",className:"w-2 h-2 rounded-full transition-colors ".concat(H===s?"bg-white":"bg-white/40 hover:bg-white/60"),onClick:()=>Q(s)},s))})]})]})})]})}let z=(0,v.memo)(function(e){let{task:s}=e,t=(0,f.c3)("components.previewArea"),l=(0,I.Ym)(),r=(0,v.useMemo)(()=>{let e=(e=>{switch(e){case 2:return{variant:"default",text:"completed"};case 3:return{variant:"destructive",text:"failed"};default:return{variant:"secondary",text:"processing"}}})(s.status);return{...s,statusVariant:e.variant,statusText:e.text,displayPrompt:s.prompt||"image.imageUpscaleTask"}},[s]);(0,v.useEffect)(()=>(console.log("\uD83D\uDCCC TaskItem mounted"),()=>{console.log("❌ TaskItem unmounted")}),[]);let n=(0,v.useMemo)(()=>function(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"full";try{let t=new Date(e);if("short"===s)return t.toLocaleDateString(l,{year:"numeric",month:"short",day:"numeric"});
1return t.toLocaleString(l,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1})}catch(s){return console.error("Date formatting error:",s),e.toString()}},[l]);return(0,a.jsxs)("div",{className:"group relative bg-card border rounded-lg p-2 sm:p-3 hover:shadow-md transition-all duration-200",children:[(0,a.jsx)("div",{className:"flex items-start justify-between gap-2 mb-2",children:(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("div",{className:"flex items-center gap-2",children:(0,a.jsx)(i.E,{variant:r.statusVariant,className:"text-xs",children:t("status.".concat(r.statusText))})}),(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-1",children:[(0,a.jsx)(C.A,{className:"h-3 w-3"}),(0,a.jsx)("span",{children:n(r.createdAt,"full")}),r.creditsUsed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(y.A,{className:"h-3 w-3 ml-2"}),(0,a.jsxs)("span",{children:[r.creditsUsed," ",t("common.credits")]})]})]})]})}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:r.prompt||t(r.displayPrompt)}),2===r.status&&r.output&&(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)(W,{output:r.output,taskId:r.id,maxDisplay:6,gridCols:3,className:"mt-3",prompt:r.prompt,model:r.model,status:r.status,creditsUsed:r.creditsUsed,createdAt:r.createdAt,completedAt:r.completedAt,error:r.error,metadata:r.metadata})})]})},(e,s)=>{if(e.task===s.task)return console.log("[TaskItem] ✅ 任务 ".concat(e.task.id," 对象引用相同,跳过渲染")),!0;let t=e.task.id===s.task.id&&e.task.status===s.task.status&&e.task.updatedAt===s.task.updatedAt;return t||console.log("[TaskItem] \uD83D\uDD04 任务 ".concat(e.task.id," 需要重新渲染")),t});function q(e){let{dataList:s,fetchNextPage:t,hasNextPage:l,isGenerating:r,progress:n,totalCount:d}=e,c=(0,f.c3)("components.previewArea");return(0,a.jsxs)("div",{className:"space-y-3 h-full flex flex-col",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("h3",{className:"text-sm sm:text-base font-semibold",children:c("common.history")}),(0,a.jsxs)(i.E,{variant:"secondary",className:"text-xs",children:[d," ",c("common.tasks")]})]}),(0,a.jsx)("div",{className:"h-full overflow-y-auto",id:"scrollableDiv",children:(0,a.jsxs)(N.A,{dataLength:s.length,next:t,hasMore:l,loader:(0,a.jsx)(k,{}),endMessage:(0,a.jsx)(A,{}),className:"space-y-3 h-full",scrollableTarget:"scrollableDiv",scrollThreshold:"200px",children:[r&&(0,a.jsxs)("div",{className:"bg-primary/5 border border-primary/20 rounded-lg p-3 space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-primary",children:c("status.generating")}),(0,a.jsx)(i.E,{variant:"secondary",className:"text-xs bg-primary/20 text-primary",children:c("status.processing")})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,a.jsx)(y.A,{className:"h-3 w-3"}),(0,a.jsx)("span",{children:c("status.calculating")})]})]}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:c("image.usingRealEsrganToProcessImage")}),(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)(b.k,{value:n,className:"h-1.5 bg-primary/20 [&>div]:bg-gradient-to-r [&>div]:from-primary [&>div]:to-primary/80"}),(0,a.jsxs)("div",{className:"flex justify-between text-xs text-muted-foreground",children:[(0,a.jsxs)("span",{children:[Math.round(n),"% ",c("image.completed")]}),(0,a.jsxs)("span",{children:[c("image.estimatedTimeRemaining"),":"," ",Math.max(1,Math.round((100-n)/15))," ",c("actions.minutes")]})]})]})]}),s.map((e,s)=>(0,a.jsx)("div",{className:"task-wrapper",children:(0,a.jsx)(z,{task:e},e.id)},"task-wrapper-".concat(e.id)))]})})]})}let Z={"flux-kontext":{titleKey:"modelConfig.fluxKontext.title",descriptionKey:"modelConfig.fluxKontext.description",images:["https://f.anyvideo.ai/ai/images/flux-kontext/759bdc73-32e7-4df0-8c6b-311a4e86e133.png","https://f.anyvideo.ai/ai/images/flux-kontext/landscape-1.png","https://f.anyvideo.ai/ai/images/flux-kontext/portrait-1.png","https://f.anyvideo.ai/ai/images/flux-kontext/artistic-1.png","https://f.anyvideo.ai/ai/images/flux-kontext/creative-1.png","https://f.anyvideo.ai/ai/images/flux-kontext/realistic-1.png"]},"flux-schnell":{titleKey:"modelConfig.fluxSchnell.title",descriptionKey:"modelConfig.fluxSchnell.description",images:["https://f.anyvideo.ai/ai/images/flux-schnell/sample-1.png","https://f.anyvideo.ai/ai/images/flux-schnell/sample-2.png","https://f.anyvideo.ai/ai/images/flux-schnell/sample-3.png","https://f.anyvideo.ai/ai/images/flux-schnell/sample-4.png","https://f.anyvideo.ai/ai/images/flux-schnell/sample-5.png","https://f.anyvideo.ai/ai/images/flux-schnell/sample-6.png"]},"image-upscaler":{titleKey:"modelConfig.imageUpscaler.title",descriptionKey:"modelConfig.imageUpscaler.description",images:["https://f.anyvideo.ai/ai/images/upscaler/before-after-1.png","https://f.anyvideo.ai/ai/images/upscaler/before-after-2.png","https://f.anyvideo.ai/ai/images/upscaler/before-after-3.png","https://f.anyvideo.ai/ai/images/upscaler/face-enhance-1.png","https://f.anyvideo.ai/ai/images/upscaler/high-res-1.png","https://f.anyvideo.ai/ai/images/upscaler/comparison-1.png"]}},J=()=>(0,a.jsx)("div",{className:"space-y-3 h-full flex flex-col",children:(0,a.jsx)("div",{className:"flex-1 space-y-3",children:Array.from({length:3}).map((e,s)=>(0,a.jsxs)("div",{className:"bg-card border rounded-lg p-3 space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("div",{className:"flex items-center gap-2",children:(0,a.jsx)(d.E,{className:"h-4 w-16"})}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(d.E,{className:"h-3 w-3"}),(0,a.jsx)(d.E,{className:"h-4 w-12"})]})]}),(0,a.jsx)(d.E,{className:"h-3 w-3/4"}),(0,a.jsx)("div",{className:"grid grid-cols-3 gap-2",children:Array.from({length:3}).map((e,s)=>(0,a.jsx)(d.E,{className:"aspect-square w-full rounded"},s))}),(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)(d.E,{className:"h-3 w-24"}),(0,a.jsx)(d.E,{className:"h-3 w-24"})]})]},s))})}),$=(0,v.forwardRef)(function(e,s){var t;let{isGenerating:d,generationError:u,onRetry:b,showHistory:y=!0,modelId:N}=e,w=(0,f.c3)("components.previewArea"),[k,A]=(0,v.useState)(0),[C,I]=(0,v.useState)(!1);(0,o.w)();let D=(0,c.i)(),{user:E,isGuest:S}=(0,m.WK)(),U=(0,x.jE)();(0,v.useEffect)(()=>{I(!0)},[]);let P=(0,v.useMemo)(()=>(null==D?void 0:D.id)||(null==E?void 0:E.id)||(S?"guest":void 0),[null==D?void 0:D.id,null==E?void 0:E.id,S]),{data:T,fetchNextPage:M,hasNextPage:O,isFetchingNextPage:F,isLoading:L,isError:K,error:R,refetch:W}=(t=C?P:void 0,(0,j.q)({queryKey:["image-history",t],initialPageParam:1,queryFn:async e=>{let{pageParam:s}=e;if(!t)return{success:!0,data:{list:[],pagination:{currentPage:1,totalPages:0,totalTasks:0,hasNextPage:!1,hasPrevPage:!1,limit:10,offset:0},stats:{totalTasks:0,completedTasks:0,failedTasks:0,totalCreditsUsed:0}}};let a=new URLSearchParams;a.set("page",s.toString()),a.set("limit","10");let l=await fetch("/api/ai/image/history?".concat(a));if(!l.ok)throw Error("Failed to fetch image history");let i=await l.json(),r=(i.data.list||[]).map(e=>{try{return{...e,createdAt:new Date(e.createdAt),updatedAt:new Date(e.updatedAt),completedAt:e.completedAt?new Date(e.completedAt):null,refundedAt:e.refundedAt?new Date(e.refundedAt):null,output:"string"==typeof e.output?JSON.parse(e.output):e.output,metadata:"string"==typeof e.metadata?JSON.parse(e.metadata):e.metadata,r2OriginalImageUrls:"string"==typeof e.r2OriginalImageUrls?JSON.parse(e.r2OriginalImageUrls):e.r2OriginalImageUrls,r2WatermarkedImageUrls:"string"==typeof e.r2WatermarkedImageUrls?JSON.parse(e.r2WatermarkedImageUrls):e.r2WatermarkedImageUrls}}catch(s){return console.error("Error parsing task:",s),{...e,createdAt:new Date(e.createdAt),updatedAt:new Date(e.updatedAt),completedAt:e.completedAt?new Date(e.completedAt):null,refundedAt:e.refundedAt?new Date(e.refundedAt):null}}});return{...i,data:{...i.data,list:r}}},getNextPageParam:e=>{if(e.data.pagination.hasNextPage)return e.data.pagination.currentPage+1},enabled:!!t,staleTime:3e5,refetchOnWindowFocus:!1,refetchOnMount:!0})),z=(0,v.useMemo)(()=>{var e,s,t,a,l,i,r,n;return d?((null==T?void 0:null===(n=T.pages)||void 0===n?void 0:null===(r=n[0])||void 0===r?void 0:null===(i=r.data)||void 0===i?void 0:null===(l=i.stats)||void 0===l?void 0:l.totalTasks)||0)+1:(null==T?void 0:null===(a=T.pages)||void 0===a?void 0:null===(t=a[0])||void 0===t?void 0:null===(s=t.data)||void 0===s?void 0:null===(e=s.stats)||void 0===e?void 0:e.totalTasks)||0},[T]),$=(0,v.useMemo)(()=>(null==T?void 0:T.pages.flatMap(e=>e.data.list))||[],[T]),_=(0,v.useCallback)(e=>{P&&(console.log("[ImagePreviewArea] Adding new item to history:",{userId:P,isGuest:S,item:e}),U.removeQueries({queryKey:["image-history",P]}),U.invalidateQueries({queryKey:["image-history",P]}))},[P,S,U]);(0,v.useImperativeHandle)(s,()=>({refetch:e=>{W(e)},addNewItem:_}),[W,_]),(0,v.useEffect)(()=>
1{if(d){let e=setInterval(()=>{A(e=>e>=95?e:e+8*Math.random())},2e3);return()=>clearInterval(e)}A(0)},[d]);let B=(0,v.useMemo)(()=>(function(e){let s=Z[e];return s||{titleKey:"modelConfig.default.title",descriptionKey:"modelConfig.default.description",images:["https://f.anyvideo.ai/ai/images/default/placeholder-1.png","https://f.anyvideo.ai/ai/images/default/placeholder-2.png","https://f.anyvideo.ai/ai/images/default/placeholder-3.png","https://f.anyvideo.ai/ai/images/default/placeholder-4.png","https://f.anyvideo.ai/ai/images/default/placeholder-5.png","https://f.anyvideo.ai/ai/images/default/placeholder-6.png"]}})(N),[N]);return(0,a.jsx)(n.Zp,{className:"border-0 shadow-lg bg-card/70 backdrop-blur-sm h-full",children:(0,a.jsx)(n.Wu,{className:"p-2 sm:p-3 lg:p-4 h-full",children:!C||L?(0,a.jsx)(J,{}):$.length>0||d?(0,a.jsx)(q,{totalCount:z,dataList:$,fetchNextPage:M,hasNextPage:O,isGenerating:d,progress:k}):u?(0,a.jsx)(()=>(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center h-full text-center",children:[(0,a.jsx)("div",{className:"w-12 h-12 sm:w-16 sm:h-16 rounded-full bg-destructive/10 border border-destructive/20 flex items-center justify-center mb-3 sm:mb-4",children:(0,a.jsx)(p.A,{className:"h-6 w-6 sm:h-8 sm:w-8 text-destructive"})}),(0,a.jsxs)("div",{className:"space-y-2 max-w-md",children:[(0,a.jsx)("p",{className:"text-sm sm:text-base lg:text-lg font-semibold",children:w("image.processingFailed")}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-muted-foreground",children:(null==u?void 0:u.message)||w("image.anErrorOccurredDuringImageProcessing")})]}),(null==u?void 0:u.creditsRefunded)&&(0,a.jsxs)(i.E,{variant:"secondary",className:"mt-3 text-xs bg-green-50 text-green-700 border-green-200 dark:bg-green-500/10 dark:text-green-400 dark:border-green-500/30",children:[(0,a.jsx)(h.A,{className:"h-3 w-3 mr-1"}),w("image.creditsRefunded")]}),b&&(0,a.jsxs)(r.$,{onClick:b,variant:"outline",size:"sm",className:"mt-4 border-border hover:border-primary/50 hover:bg-primary/5 text-xs sm:text-sm",children:[(0,a.jsx)(g.A,{className:"h-3 w-3 sm:h-4 sm:w-4 mr-1.5"}),w("actions.retry")]})]}),{}):R?(0,a.jsx)(()=>(0,a.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,a.jsxs)("div",{className:"text-center text-destructive",children:[(0,a.jsx)(p.A,{className:"h-6 w-6 mx-auto mb-2"}),(0,a.jsxs)("p",{className:"text-sm",children:[w("image.loadingHistoryFailed"),":"," ",R instanceof Error?R.message:String(R)]})]})}),{}):(0,a.jsx)(l.D,{title:w(B.titleKey),description:w(B.descriptionKey),images:B.images})})})})}}]);

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.