1/*! For license information please see 463.498ea648.chunk.js.LICENSE.txt */ 2"use strict";(self.webpackChunkfrontend=self.webpackChunkfrontend||[]).push([[463],{5463(e,t,a){a.r(t),a.d(t,{default:()=>le});var i=a(9379),r=a(5043),s=a(9722),n=a(6328),o=a(5258),l=a(6099),d=a(7784);const c=(0,d.A)("heart",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}]]),u=(0,d.A)("boxes",[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]]);var h=a(9856),m=a(1161),g=a(8326),p=a(2024),x=a(9292),f=a(614),b=a(2382),v=a(6210),w=a(737),y=a(67),j=a(73),N=a(7365),k=a(1680),A=a(5598),_=a(5844),C=a(342),S=a(9311),R=a(8011),T=a(4489),E=a(4247),D=a(1360),P=a(797),M=a(5731),O=a(629),I=a(6797),L=a(5517),U=a(579);function z(e){let{api:t,authUser:a,format:r,style:s,colorsOverride:o,onChangeColorsOverride:d,cards:c,settings:u,onChangeSettings:m,onChangeCards:x,makeBlankCard:f,onOpenStructurePicker:b,run:v,onGenerateAll:w}=e;const y=c.filter(e=>e.variation&&(e.content||"").trim().length>0).length,j=c.length,N=y>=2&&"running"!==v.phase,k=5*y;return(0,U.jsxs)("div",{className:"mx-auto w-full max-w-[1380px]",children:[s?(()=>{const e=s.thumbnail||(s.preview_image_base64?s.preview_image_base64.startsWith("data:")?s.preview_image_base64:"data:image/png;base64,".concat(s.preview_image_base64):null)||(s.image_base64?s.image_base64.startsWith("data:")?s.image_base64:"data:image/png;base64,".concat(s.image_base64):null),t=Array.isArray(s.colors)?s.colors.filter(Boolean).slice(0,6):[],a=Array.isArray(o)&&o.length>0?o.slice(0,6):t,i=Array.isArray(o)&&o.length>0;return(0,U.jsxs)("div",{className:"mt-1 flex flex-col gap-3 rounded-2xl border border-white/12 bg-white/[0.03] p-3 sm:flex-row sm:items-center sm:gap-4 sm:p-4","data-testid":"ai-editor-bulk-style-context",children:[e?(0,U.jsx)("img",{src:e,alt:s.name,className:"aspect-video w-40 shrink-0 rounded-lg border border-white/10 object-cover shadow-[0_8px_22px_-10px_rgba(0,0,0,0.6)] sm:w-52",loading:"lazy"}):(0,U.jsx)("div",{className:"flex aspect-video w-40 shrink-0 items-center justify-center rounded-lg border border-white/10 bg-black/40 sm:w-52",children:(0,U.jsx)(h.A,{className:"h-6 w-6 text-white/40"})}),(0,U.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,U.jsx)("div",{className:"text-[10px] font-semibold uppercase tracking-[0.18em] text-white/45",children:"Selected style for this batch"}),(0,U.jsx)("div",{className:"mb-2 truncate text-sm font-semibold text-white",children:s.name}),a.length>0&&(0,U.jsxs)("div",{className:"mb-3 flex flex-wrap items-center gap-2","data-testid":"ai-editor-bulk-brand-colors",children:[(0,U.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-white/40",children:"Colors"}),a.map((e,t)=>(0,U.jsx)(L.q,{index:t,hex:e,onChange:e=>((e,t)=>{const i=[...a];i[e]=t,null===d||void 0===d||d(i)})(t,e),onRemove:a.length>1?()=>(e=>{a.length<=1||null===d||void 0===d||d(a.filter((t,a)=>a!==e))})(t):null},t)),a.length<6&&(0,U.jsx)("button",{type:"button",onClick:()=>{a.length>=6||null===d||void 0===d||d([...a,"#888888"])},className:"flex h-9 w-9 items-center justify-center rounded-full border border-dashed border-white/20 text-white/55 transition hover:border-orange-400/60 hover:text-orange-200",title:"Add a colour","data-testid":"ai-editor-bulk-brand-colors-add",children:(0,U.jsx)(D.A,{className:"h-4 w-4"})}),i&&(0,U.jsx)("button",{type:"button",onClick:()=>null===d||void 0===d?void 0:d(null),className:"ml-1 text-[10px] font-semibold uppercase tracking-[0.16em] text-white/45 underline-offset-2 transition hover:text-orange-200 hover:underline","data-testid":"ai-editor-bulk-brand-colors-reset",children:"Reset"})]}),(0,U.jsx)(B,{settings:u,onChange:m,embedded:!0})]})]})})():(0,U.jsx)("div",{className:"mt-5",children:(0,U.jsx)(B,{settings:u,onChange:m})}),(0,U.jsx)("div",{className:"mt-6 grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4","data-testid":"ai-editor-bulk-cards",children:c.map((e,t)=>(0,U.jsx)(G,{index:t,card:e,onChange:t=>((e,t)=>x(c.map(a=>a.id===e?(0,i.A)((0,i.A)({},a),t):a)))(e.id,t),onRemove:()=>{return t=e.id,void(c.length<=2?n.oR.message("Minimum 2 cards",{description:"Bulk Designer needs at least two cards to make sense."}):x(c.filter(e=>e.id!==t)));var t},onPickStructure:()=>b(e.id),canRemove:c.length>2,cardCount:c.length},e.id))}),(0,U.jsxs)("div",{className:"mt-4 flex flex-col items-center justify-between gap-3 sm:flex-row",children:[(0,U.jsxs)("button",{type:"button",onClick:()=>{c.length>=50?n.oR.message("Maximum 50 cards",{description:"We cap each batch at 50 to keep the queue healthy."}):x([...c,f()])},disabled:c.length>=50,className:"inline-flex items-center gap-2 rounded-full border border-white/15 bg-white/[0.04] px-4 py-2 text-sm font-medium text-white/80 transition hover:border-white/30 hover:bg-white/[0.08] hover:text-white disabled:opacity-40","data-testid":"ai-editor-bulk-add-card",children:[(0,U.jsx)(D.A,{className:"h-4 w-4"}),"Add another card"," ",(0,U.jsxs)("span",{className:"text-[11px] text-white/45",children:["(",c.length,"/50)"]})]}),(0,U.jsxs)("div",{className:"flex flex-col items-end gap-1",children:[(0,U.jsxs)("div",{className:"text-[11px] text-white/55",children:[y," of ",j," cards ready \xb7 ",k," credits"]}),(0,U.jsx)("button",{type:"button",onClick:w,disabled:!N,className:"btn-flame inline-flex items-center gap-2 rounded-full px-6 py-3 text-sm font-semibold text-white disabled:opacity-50","data-testid":"ai-editor-bulk-generate",children:"running"===v.phase?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(p.A,{className:"h-4 w-4 animate-spin"}),"Generating ",v.progress.done,"/",v.progress.total,"\u2026"]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(l.A,{className:"h-4 w-4"}),"Generate ",y," designs",(0,U.jsx)(g.A,{className:"h-4 w-4"})]})})]})]}),"running"===v.phase&&(0,U.jsxs)("div",{className:"mt-4 rounded-xl border border-orange-400/30 bg-
2orange-500/[0.06] p-3",children:[(0,U.jsxs)("div",{className:"mb-1.5 flex items-center justify-between text-[11px] font-semibold uppercase tracking-[0.16em] text-orange-100",children:[(0,U.jsx)("span",{children:"Bulk run in progress"}),(0,U.jsxs)("span",{children:[v.progress.done,"/",v.progress.total,v.progress.failed>0?" \xb7 ".concat(v.progress.failed," failed"):""]})]}),(0,U.jsx)("div",{className:"h-1.5 w-full overflow-hidden rounded-full bg-white/10",children:(0,U.jsx)("div",{className:"h-full rounded-full bg-gradient-to-r from-orange-500 via-rose-500 to-fuchsia-500 transition-[width] duration-300",style:{width:"".concat(Math.round(v.progress.done/Math.max(1,v.progress.total)*100),"%")}})})]})]})}function F(e){let{className:t="h-3.5 w-3.5"}=e;return(0,U.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",className:t,fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,U.jsx)("path",{d:"M5.5 6h13"}),(0,U.jsx)("path",{d:"M12 6v13"}),(0,U.jsx)("path",{d:"M4 20 L20 4"})]})}function B(e){let{settings:t,onChange:a,embedded:r=!1}=e;const s=e=>{let{label:t,value:a,onClick:i,icon:r,renderIcon:s,dataTestid:n}=e;return(0,U.jsxs)("button",{type:"button",onClick:i,"aria-pressed":a,className:"inline-flex items-center gap-1.5 rounded-full border px-3 py-1.5 text-[11.5px] font-medium transition ".concat(a?"border-orange-400/60 bg-orange-500/[0.15] text-orange-100":"border-white/10 bg-white/[0.04] text-white/65 hover:border-white/25 hover:text-white"),"data-testid":n,children:[s?s():(0,U.jsx)(r,{className:"h-3.5 w-3.5"}),t]})};return(0,U.jsxs)("div",{className:r?"flex flex-wrap items-center gap-1.5":"flex flex-wrap items-center gap-2 rounded-2xl border border-white/12 bg-white/[0.03] p-3","data-testid":"ai-editor-bulk-global-settings",children:[!r&&(0,U.jsx)("div",{className:"mr-1 text-[10px] font-semibold uppercase tracking-[0.18em] text-white/45",children:"Batch settings"}),(0,U.jsx)("select",{value:t.language,onChange:e=>a((0,i.A)((0,i.A)({},t),{},{language:e.target.value})),className:"h-8 rounded-full border border-white/15 bg-zinc-950 px-3 text-[12px] font-medium text-white outline-none transition hover:border-white/30","data-testid":"ai-editor-bulk-language",children:["English","Deutsch","Fran\xe7ais","Espa\xf1ol","Italiano","Portugu\xeas","Nederlands","\u65e5\u672c\u8a9e","\u4e2d\u6587","\ud55c\uad6d\uc5b4","Polski","T\xfcrk\xe7e","\u0420\u0443\u0441\u0441\u043a\u0438\u0439"].map(e=>(0,U.jsx)("option",{value:e,children:e},e))}),(0,U.jsx)(s,{label:"Web search",icon:x.A,value:t.webMode,onClick:()=>a((0,i.A)((0,i.A)({},t),{},{webMode:!t.webMode})),dataTestid:"ai-editor-bulk-toggle-web"}),(0,U.jsx)(s,{label:"Ultra mode",icon:l.A,value:t.ultraMode,onClick:()=>a((0,i.A)((0,i.A)({},t),{},{ultraMode:!t.ultraMode})),dataTestid:"ai-editor-bulk-toggle-ultra"}),(0,U.jsx)(s,{label:"No text on design",renderIcon:()=>(0,U.jsx)(F,{}),value:t.noTextOnDesign,onClick:()=>a((0,i.A)((0,i.A)({},t),{},{noTextOnDesign:!t.noTextOnDesign})),dataTestid:"ai-editor-bulk-toggle-notext"})]})}function G(e){var t,a,i,s;let{index:d,card:c,onChange:u,onRemove:h,onPickStructure:m,canRemove:g,cardCount:p}=e;const x=(0,r.useRef)(null),b=(0,r.useRef)(null),v=(0,r.useRef)(null),[w,j]=(0,r.useState)(!1),N=c.variation,A=(null===N||void 0===N?void 0:N.image)||(null===N||void 0===N?void 0:N.refImage)||null,_=(e,t)=>{const a=Array.from(e.target.files||[]);return e.target.value="",a.filter(e=>!(t&&!t.test(e.type))&&(!(e.size>10485760)||(n.oR.error("File too large",{description:"".concat(e.name,": max upload size is 10 MB.")}),!1)))},C=async e=>{if(e)if(/^image\/(jpeg|png|webp)$/.test(e.type)){if(e.size>10485760){const t=(e.size/1048576).toFixed(1);return void n.oR.error("File too large",{description:"That image is ".concat(t," MB. Max upload size is 10 MB.")})}try{const t=await(e=>new Promise((t,a)=>{const i=new FileReader;i.onload=()=>{const e=String(i.result||""),a=e.indexOf(",");t(a>=0?e.slice(a+1):e)},i.onerror=a,i.readAsDataURL(e)}))(e);u({variation:{id:"dropped-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2)),name:e.name.replace(/\.[^.]+$/,"")||"Uploaded structure",image:t,refImage:t,isCustom:!0,colors:[],aspect_ratio:null,tags:[]}}),n.oR.success("Structure ready",{description:"Dropped image is now the card's reference."})}catch(t){n.oR.error("Could not read that file")}}else n.oR.error("Image only",{description:"Drop a JPG, PNG or WebP \u2014 that becomes the card's structure."})};return(0,U.jsxs)("div",{onDragOver:e=>{e.preventDefault(),e.stopPropagation(),w||j(!0)},onDragEnter:e=>{e.preventDefault(),j(!0)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||j(!1)},onDrop:e=>{var t;e.preventDefault(),e.stopPropagation(),j(!1);const a=((null===(t=e.dataTransfer)||void 0===t?void 0:t.files)||[])[0];a&&C(a)},className:"relative overflow-hidden rounded-2xl border bg-white/[0.025] p-3 transition ".concat(w?"border-orange-300/80 bg-orange-500/[0.08] ring-2 ring-orange-400/30":N?"border-orange-400/35 ring-1 ring-orange-400/15":"border-white/12 hover:border-white/25"),"data-testid":"ai-editor-bulk-card-".concat(d),children:[(0,U.jsxs)("div",{className:"mb-2 flex items-center justify-between text-[10px] font-semibold uppercase tracking-[0.18em] text-white/45",children:[(0,U.jsxs)("span",{children:["Card ",d+1]}),g&&(0,U.jsx)("button",{type:"button",onClick:h,className:"rounded-full p-1 text-white/40 transition hover:bg-rose-500/15 hover:text-rose-200",title:"Remove card","aria-label":"Remove card","data-testid":"ai-editor-bulk-card-remove-".concat(d),children:(0,U.jsx)(f.A,{className:"h-3.5 w-3.5"})})]}),(0,U.jsx)("button",{type:"button",onClick:m,className:"group block w-full overflow-hidden rounded-xl border border-white/10 bg-black/40 transition hover:border-orange-400/40","data-testid":"ai-editor-bulk-card-stru
2cture-".concat(d),children:A?(0,U.jsx)("div",{className:"flex aspect-[4/3] items-center justify-center bg-zinc-900",children:(0,U.jsx)("img",{src:A.startsWith("data:")?A:"data:image/png;base64,".concat(A),alt:(null===N||void 0===N?void 0:N.name)||"Structure",className:"max-h-full max-w-full object-contain",loading:"lazy"})}):(0,U.jsxs)("div",{className:"flex aspect-[4/3] flex-col items-center justify-center gap-1.5 text-white/45 transition group-hover:text-white",children:[(0,U.jsx)(o.A,{className:"h-6 w-6"}),(0,U.jsx)("span",{className:"text-[12px] font-semibold",children:"Choose structure"}),(0,U.jsx)("span",{className:"text-[10px] text-white/35",children:"Favorites \xb7 All \xb7 Search \xb7 or drop image"})]})}),N&&(0,U.jsxs)("div",{className:"mt-2 flex items-center justify-between gap-2 text-[11px]",children:[(0,U.jsx)("div",{className:"min-w-0 flex-1 truncate font-semibold text-white",children:N.name||"Structure"}),(0,U.jsx)("button",{type:"button",onClick:m,className:"text-orange-300 underline-offset-2 transition hover:text-orange-200 hover:underline","data-testid":"ai-editor-bulk-card-change-".concat(d),children:"Change"})]}),(0,U.jsx)("textarea",{value:c.content,onChange:e=>u({content:e.target.value}),placeholder:"What goes on this design? Add your headline, body and any specific text\u2026",rows:3,className:"mt-2.5 w-full resize-none rounded-lg border border-white/10 bg-black/40 px-2.5 py-2 text-[12.5px] text-white outline-none placeholder:text-white/35 focus:border-orange-400/60","data-testid":"ai-editor-bulk-card-content-".concat(d)}),(0,U.jsxs)("div",{className:"mt-2 flex items-center justify-between gap-1",children:[(0,U.jsxs)("div",{className:"flex items-center gap-1",children:[(0,U.jsx)(q,{title:"Upload documents".concat(null!==(t=c.documents)&&void 0!==t&&t.length?" (".concat(c.documents.length,")"):""," \u2014 PDF, DOCX, TXT\u2026"),active:(null===(a=c.documents)||void 0===a?void 0:a.length)>0,onClick:()=>{var e;return null===(e=x.current)||void 0===e?void 0:e.click()},dataTestid:"ai-editor-bulk-card-docs-".concat(d),icon:k.A}),(0,U.jsx)("input",{ref:x,type:"file",multiple:!0,accept:".pdf,.doc,.docx,.txt,.md",className:"hidden",onChange:e=>{const t=_(e);t.length>0&&u({documents:[...c.documents||[],...t]})}}),(0,U.jsx)(q,{title:"Upload image(s)".concat(null!==(i=c.images)&&void 0!==i&&i.length?" (".concat(c.images.length,")"):""," \u2014 JPG, PNG, WebP"),active:(null===(s=c.images)||void 0===s?void 0:s.length)>0,onClick:()=>{var e;return null===(e=b.current)||void 0===e?void 0:e.click()},dataTestid:"ai-editor-bulk-card-images-".concat(d),icon:y.A}),(0,U.jsx)("input",{ref:b,type:"file",multiple:!0,accept:"image/jpeg,image/png,image/webp",className:"hidden",onChange:e=>{const t=_(e,/^image\/(jpeg|png|webp)$/);t.length>0&&u({images:[...c.images||[],...t]})}}),(0,U.jsx)(q,{title:c.logo?"Replace brand logo":"Upload brand logo \u2014 JPG, PNG, WebP",active:!!c.logo,onClick:()=>{var e;return null===(e=v.current)||void 0===e?void 0:e.click()},dataTestid:"ai-editor-bulk-card-logo-".concat(d),icon:l.A}),(0,U.jsx)("input",{ref:v,type:"file",accept:"image/jpeg,image/png,image/webp",className:"hidden",onChange:e=>{const[t]=_(e,/^image\/(jpeg|png|webp)$/);t&&u({logo:t})}})]}),(0,U.jsx)("div",{className:"text-[10px] uppercase tracking-[0.16em] text-white/35",children:c.variation?"Ready":"Pick structure"})]})]})}function q(e){let{title:t,active:a,onClick:i,icon:r,dataTestid:s}=e;return(0,U.jsx)("button",{type:"button",onClick:i,title:t,"aria-label":t,className:"inline-flex h-8 w-8 items-center justify-center rounded-full border transition ".concat(a?"border-orange-400/60 bg-orange-500/[0.15] text-orange-100":"border-white/10 bg-white/[0.04] text-white/60 hover:border-white/30 hover:text-white"),"data-testid":s,children:(0,U.jsx)(r,{className:"h-3.5 w-3.5"})})}function W(e){let{onFile:t,busy:a,dragOver:i,setDragOver:r,fileInputRef:s}=e;return(0,U.jsxs)("div",{onDragOver:e=>{e.preventDefault(),r(!0)},onDragLeave:()=>r(!1),onDrop:e=>{var a,i;e.preventDefault(),r(!1);const s=null===(a=e.dataTransfer)||void 0===a||null===(i=a.files)||void 0===i?void 0:i[0];s&&t(s)},onClick:()=>{var e;return!a&&(null===(e=s.current)||void 0===e?void 0:e.click())},className:"flex min-h-[260px] cursor-pointer flex-col items-center justify-center gap-3 rounded-2xl border-2 border-dashed p-6 text-center transition ".concat(i?"border-orange-400/70 bg-orange-500/[0.08] text-orange-100":"border-white/15 bg-white/[0.02] text-white/70 hover:border-white/30 hover:bg-white/[0.04]"),"data-testid":"ai-editor-bulk-structure-picker-upload-dropzone",role:"button","aria-label":"Drop a structure image or click to choose a file",children:[(0,U.jsx)("div",{className:"flex h-14 w-14 items-center justify-center rounded-full transition ".concat(i?"bg-orange-500/20 text-orange-200":"bg-white/[0.06] text-white/75"),children:a?(0,U.jsx)(p.A,{className:"h-6 w-6 animate-spin"}):(0,U.jsx)(w.A,{className:"h-6 w-6"})}),(0,U.jsx)("div",{className:"text-sm font-semibold text-white",children:a?"Reading file\u2026":"Drop a structure here"}),(0,U.jsx)("div",{className:"max-w-sm text-[11.5px] leading-relaxed text-white/55",children:a?"Encoding your reference for the bulk pipeline.":(0,U.jsxs)(U.Fragment,{children:["Or ",(0,U.jsx)("span",{className:"font-semibold text-orange-300",children:"click to browse"})," your computer.",(0,U.jsx)("br",{}),"PNG, JPG or WebP \xb7 up to 8 MB."]})}
2),(0,U.jsx)("input",{ref:s,type:"file",accept:"image/png,image/jpeg,image/webp",className:"hidden",onChange:e=>{var a;const i=null===(a=e.target.files)||void 0===a?void 0:a[0];i&&t(i),e.target.value=""},"data-testid":"ai-editor-bulk-structure-picker-upload-input"})]})}function Y(e){let{api:t,onClose:a,onPick:i}=e;const[l,d]=(0,r.useState)("favorites"),[u,h]=(0,r.useState)(""),[m,g]=(0,r.useState)([]),[b,v]=(0,r.useState)(!1),[w,y]=(0,r.useState)([]),[j,N]=(0,r.useState)(0),[k,A]=(0,r.useState)(0),[_,C]=(0,r.useState)(!1),[S,R]=(0,r.useState)(!1),[T,E]=(0,r.useState)(!1),[D,M]=(0,r.useState)(!1),O=(0,r.useRef)(null),I=(0,r.useMemo)(()=>new Set(m.map(e=>e.id)),[m]),L=(0,r.useRef)(null);(0,r.useEffect)(()=>{let e=!1;return(async()=>{try{const{data:a}=await s.A.get("".concat(t,"/ai-editor-favorites?hydrate=1"));if(e)return;g(Array.isArray(null===a||void 0===a?void 0:a.variations)?a.variations:[])}catch(a){e||g([])}finally{e||v(!0)}})(),()=>{e=!0}},[t]);const z=(0,r.useCallback)(async function(e){let a=arguments.length>1&&void 0!==arguments[1]&&arguments[1];try{var i;R(!0);const r=new URLSearchParams({limit:String(8),offset:String(e)}),n=(u||"").trim();n&&r.set("q",n);const{data:o}=await s.A.get("".concat(t,"/ai-editor-variations?").concat(r.toString())),l=Array.isArray(null===o||void 0===o?void 0:o.variations)?o.variations:[];A(Number(null!==(i=null===o||void 0===o?void 0:o.total)&&void 0!==i?i:l.length)),y(e=>a?l:[...e,...l]),N(e+l.length)}finally{R(!1),C(!0)}},[t,u]);(0,r.useEffect)(()=>{"all"===l&&(y([]),N(0),A(0),C(!1),z(0,!0))},[l,u,z]),(0,r.useEffect)(()=>{const e=e=>{"Escape"===e.key&&a()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[a]);const[F,B]=(0,r.useState)(8);(0,r.useEffect)(()=>{B(8)},[l,u]),(0,r.useEffect)(()=>{const e=L.current;if(!e)return;const t=new IntersectionObserver(e=>{var t;null!==(t=e[0])&&void 0!==t&&t.isIntersecting&&("favorites"===l?B(e=>Math.min(e+8,G.length)):"all"===l&&!S&&w.length<k&&z(j,!1))},{root:null,rootMargin:"160px",threshold:0});return t.observe(e),()=>t.disconnect()},[l,S,w.length,k,j,z,u]);const G=(()=>{const e=(u||"").trim().toLowerCase();return e?m.filter(t=>{if(String(t.name||"").toLowerCase().includes(e))return!0;return(Array.isArray(t.tags)?t.tags:[]).some(t=>String(t||"").toLowerCase().includes(e))}):m})(),q="favorites"===l,Y=q?G.slice(0,F):w,H=q?!b:!_,V=q?F<G.length:w.length<k;return(0,U.jsx)("div",{className:"fixed inset-0 z-[80] flex items-center justify-center bg-black/70 px-4 py-8 backdrop-blur-sm",onClick:a,"data-testid":"ai-editor-bulk-structure-picker",children:(0,U.jsxs)("div",{onClick:e=>e.stopPropagation(),className:"flex max-h-[88vh] w-full max-w-3xl flex-col overflow-hidden rounded-3xl border border-white/15 bg-zinc-950 shadow-2xl",children:[(0,U.jsxs)("div",{className:"border-b border-white/10 p-4",children:[(0,U.jsxs)("div",{className:"mb-3 flex items-center justify-between",children:[(0,U.jsxs)("div",{children:[(0,U.jsx)("div",{className:"text-[10px] font-semibold uppercase tracking-[0.18em] text-white/45",children:"Choose a structure"}),(0,U.jsx)("div",{className:"text-sm font-semibold text-white",children:"Pick a design layout for this card"})]}),(0,U.jsx)("button",{type:"button",onClick:a,className:"rounded-full border border-white/15 bg-white/[0.04] p-1.5 text-white/65 transition hover:border-white/30 hover:text-white","aria-label":"Close","data-testid":"ai-editor-bulk-structure-picker-close",children:(0,U.jsx)(f.A,{className:"h-3.5 w-3.5"})})]}),(0,U.jsx)("div",{className:"mb-3 flex items-center gap-1.5",children:[{id:"favorites",label:"Favorites",Icon:c},{id:"all",label:"All",Icon:o.A},{id:"upload",label:"Upload",Icon:P.A}].map(e=>{const t=l===e.id;return(0,U.jsxs)("button",{type:"button",onClick:()=>d(e.id),className:"inline-flex items-center gap-1.5 rounded-full px-3 py-1.5 text-[12px] font-semibold transition ".concat(t?"bg-gradient-to-r from-orange-500 via-rose-500 to-fuchsia-600 text-white":"border border-white/10 bg-white/[0.04] text-white/65 hover:border-white/25 hover:text-white"),"data-testid":"ai-editor-bulk-structure-picker-tab-".concat(e.id),children:[(0,U.jsx)(e.Icon,{className:"h-3.5 w-3.5"}),e.label]},e.id)})}),"upload"!==l&&(0,U.jsxs)("div",{className:"flex min-h-[44px] items-center gap-2 rounded-full border border-white/10 bg-white/[0.04] px-3",children:[(0,U.jsx)(x.A,{className:"h-4 w-4 text-white/60"}),(0,U.jsx)("input",{type:"text",value:u,onChange:e=>h(e.target.value),placeholder:"Search ".concat("favorites"===l?"favorites":"all designs","\u2026"),className:"h-9 w-full bg-transparent text-[14px] text-white outline-none placeholder:text-white/55","data-testid":"ai-editor-bulk-structure-picker-search"})]})]}),(0,U.jsx)("div",{className:"flex-1 overflow-x-hidden overflow-y-auto p-4",children:"upload"===l?(0,U.jsx)(W,{busy:D,dragOver:T,setDragOver:E,fileInputRef:O,onFile:async e=>{if(e)if(/^image\//.test(e.type))if(e.size>8388608)n.oR.error("File too large",{description:"Structure references must be under 8 MB."});else{M(!0);try{const t=await new Promise((t,a)=>{const i=new FileReader;i.onload=()=>{const e=String(i.result||""),a=e.indexOf(",");t(a>=0?e.slice(a+1):e)},i.onerror=()=>a(i.error||new Error("read failed")),i.readAsDataURL(e)});i({id:"upload-".concat(Date.now()),name:(e.name||"Uploaded structure").replace(/\.[^.]+$/,"").slice(0,60),image:t,refImage:t,colors:[],aspect_ratio:null,tags:[]})}catch(t){n.oR.error("Could not read file",{description:String((null===t||void 0===t?void 0:t.message)||t).slice(0,200)})}finally{M(!1)}}else n.oR.error("Unsupported file",{description:"Drop an image (PNG, JPG, WebP) of the structure you want to copy."})}}):H?(0,U.jsx)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-4",children:Array.from({length:8},(e,t)=>(0,U.jsx)("div",{className:"aspect-[4/3] animate-pulse rounded-xl border border-white/10 bg-white/[0.04]"},t))}):0===Y.length?(0,U.jsx)("div",{className:"py-10 text-center text-sm text-white/55",children:q?"No favorites yet. Heart a design to add it here.":"No designs match your search."}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-4",children:Y.map(e=>(0,U.jsxs)("button",{type:"button",onClick:()=>{i({id:e.id,name:e.name,image:e.thumbnail_base64||e.reference_image_base64||null,refImage:e.reference_image_base64||e.thumbnail_base64||null,colors:e.colors||[],aspect_ratio:e.aspect_ratio||null,tags:e.tags||[]})},className:"group overflow-hidden rounded-xl border border-white/10 bg-white/[0.025] text-left transition hover:border-orange-400/50 hover:bg-white/[0.05]","data-testid":"ai-editor-bulk-structure-picker-item-".concat(e.id),children:[(0,U.jsx)("div",{className:"flex aspect-[4/3] items-center justify-center overflow-hidden bg-black/40",children:e.thumbnail_base64?(0,U.jsx)("img",{src:"data:image/png;base64,".concat(e.thumbnail_base64),alt:e.name,className:"max-h-full max-w-full object-contain transition group-hover:scale-[1.02]",loading:"lazy"}):(0,U.jsx)(o.A,{className:"h-6 w-6 text-white/35"})}),(0,U.jsxs)("div",{className:"flex items-center justify-between gap-2 p-2 text-[11.5px]",children:[(0,U.jsx)("div",{className:"min-w-0 flex-1 truncate font-semibold text-white/85",children:e.name}),I.has(e.id)&&(0,U.jsx)(c,{className:"h-3 w-3 fill-rose-400 text-rose-400"})]})]},e.id))}),V&&(0,U.jsx)("div",{ref:L,className:"flex items-center justify-center py-4 text-[11px] text-white/50","data-testid":"ai-editor-bulk-structure-picker-sentinel",children:!q&&S?(0,U.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,U.jsx)(p.A,{className:"h-3 w-3 animate-spin text-orange-300"}),"Loading more\u2026"]}):(0,U.jsx)("span",{children:"Scroll for more"})})]})})]})})}function H(e){let{variation:t,customName:a,customRef:i,format:r,style:s,colors:n,onChangeColors:o,onGenerate:l,generating:d,genProgress:c,quickMode:u=!1}=e;const h=!(null===t||void 0===t||!t.isCustom),m=h?a||"Custom Structure":null===t||void 0===t?void 0:t.name,g=h?i?i.startsWith("data:")?i:"data:image/png;base64,".concat(i):null:null===t||void 0===t?void 0:t.image,p=[...E.Iw,...E.aA].find(e=>e.id===r),x=(null===p||void 0===p?void 0:p.ratio)||r||"",f=["9:16","4:5","3:4","2:3"].includes(x),b=x?{aspectRatio:x.replace(":","/")}:void 0,v=(n||[]).slice(0,5),w=(e,t)=>{const a=[...v];a[e]=t,o(a)},y=e=>
2{v.length<=1||o(v.filter((t,a)=>a!==e))},j=()=>{v.length>=5||o([...v,"#888888"])},N=(0,U.jsx)("div",{className:"relative z-30 flex h-full flex-col rounded-xl border border-white/10 bg-black/30",children:(0,U.jsxs)("ul",{className:"divide-y divide-white/5 text-xs",children:[(0,U.jsxs)("li",{className:"flex items-center justify-between gap-3 px-3 py-2",children:[(0,U.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-[0.22em] text-white/45",children:"Structure"}),(0,U.jsx)("span",{className:"truncate font-semibold text-white",title:m||"\u2014",children:m||"\u2014"})]}),(0,U.jsxs)("li",{className:"flex items-center justify-between gap-3 px-3 py-2",children:[(0,U.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-[0.22em] text-white/45",children:"Format"}),(0,U.jsx)("span",{className:"truncate font-semibold text-white",children:x||"\u2014"})]}),!u&&(0,U.jsxs)("li",{className:"flex items-center justify-between gap-3 px-3 py-2",children:[(0,U.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-[0.22em] text-white/45",children:"Style"}),(0,U.jsx)("span",{className:"truncate font-semibold text-white",title:(null===s||void 0===s?void 0:s.name)||"\u2014",children:(null===s||void 0===s?void 0:s.name)||"\u2014"})]}),(0,U.jsxs)("li",{className:"relative z-40 flex flex-col gap-2 px-3 py-2",children:[(0,U.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,U.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-[0.22em] text-white/45",children:"Colors"}),(0,U.jsxs)("span",{className:"text-[10px] font-mono text-white/40",children:[v.length,"/5"]})]}),(0,U.jsxs)("div",{className:"flex flex-wrap items-center gap-2","data-testid":"ai-editor-review-palette",children:[v.map((e,t)=>(0,U.jsx)(L.q,{index:t,hex:e,onChange:e=>w(t,e),onRemove:v.length>1?()=>y(t):null},t)),v.length<5&&(0,U.jsx)("button",{type:"button",onClick:j,className:"flex h-9 w-9 items-center justify-center rounded-full border border-dashed border-white/20 text-white/50 transition hover:border-orange-400/60 hover:text-orange-200",title:"Add a colour","data-testid":"ai-editor-review-palette-add",children:(0,U.jsx)(D.A,{className:"h-4 w-4"})})]})]})]})});return(0,U.jsxs)("div",{className:"mx-auto max-w-5xl","data-testid":"ai-editor-review-step",children:[(0,U.jsxs)("div",{className:"space-y-3 md:hidden",children:[(0,U.jsx)("div",{className:"mx-auto w-full ".concat("16:9"===x?"max-w-[60%]":"max-w-[30%]"),children:(0,U.jsxs)("div",{className:"grid gap-3 ".concat(u?"grid-cols-1":"grid-cols-2"),children:[(0,U.jsx)("div",{className:"relative w-full overflow-hidden rounded-xl border border-white/10 bg-black/40",style:b,children:g?(0,U.jsx)("img",{src:g,alt:"".concat(m," preview"),className:"block h-full w-full object-contain",draggable:"false"}):(0,U.jsx)("div",{className:"flex h-full w-full items-center justify-center text-[10px] uppercase tracking-[0.22em] text-white/30",children:"No preview"})}),!u&&(0,U.jsx)("div",{className:"relative aspect-video w-full overflow-hidden rounded-xl border border-white/10 bg-black/40",children:null!==s&&void 0!==s&&s.preview_image_base64||null!==s&&void 0!==s&&s.thumbnail_base64||null!==s&&void 0!==s&&s.image_base64_list&&s.image_base64_list[0]?(0,U.jsx)("img",{src:s.preview_image_base64?"data:image/jpeg;base64,".concat(s.preview_image_base64):s.thumbnail_base64?"data:image/jpeg;base64,".concat(s.thumbnail_base64):"data:image/jpeg;base64,".concat(s.image_base64_list[0]),alt:"".concat((null===s||void 0===s?void 0:s.name)||"Style"," preview"),className:"block h-full w-full object-cover",draggable:"false"}):(0,U.jsx)("div",{className:"flex h-full w-full items-center justify-center text-[10px] uppercase tracking-[0.22em] text-white/30",children:(null===s||void 0===s?void 0:s.name)||"Style"})})]})}),(0,U.jsxs)("div",{className:"flex items-center justify-center gap-2 rounded-lg border border-white/10 bg-black/30 px-3 py-2 text-center text-[12px] font-semibold text-white",children:[(0,U.jsx)("span",{className:"truncate",children:m||"\u2014"}),(0,U.jsx)("span",{className:"text-white/30",children:"\xb7"}),(0,U.jsx)("span",{className:"truncate",children:p?p.ratio:r||"\u2014"}),!u&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("span",{className:"text-white/30",children:"\xb7"}),(0,U.jsx)("span",{className:"truncate",children:(null===s||void 0===s?void 0:s.name)||"\u2014"})]})]}),(0,U.jsxs)("div",{className:"rounded-lg border border-white/10 bg-black/30 p-3",children:[(0,U.jsxs)("div",{className:"mb-2 flex items-center justify-between gap-2",children:[(0,U.jsx)("div",{className:"text-[10px] font-semibold uppercase tracking-[0.22em] text-white/55",children:"Colors"}),(0,U.jsxs)("div",{className:"text-[10px] font-mono text-white/40",children:[v.length,"/5"]})]}),(0,U.jsxs)("div",{className:"flex flex-wrap items-center gap-2","data-testid":"ai-editor-review-palette-mobile",children:[v.map((e,t)=>(0,U.jsx)(L.q,{index:t,hex:e,onChange:e=>w(t,e),onRemove:v.length>1?()=>y(t):null},t)),v.length<5&&(0,U.jsx)("button",{type:"button",onClick:j,className:"flex h-9 w-9 items-center justify-center rounded-full border border-dashed border-white/20 text-white/50 transition hover:border-orange-400/60 hover:text-orange-200",title:"Add a colour",children:(0,U.jsx)(D.A,{className:"h-4 w-4"})})]})]}),(0,U.jsx)(X,{onGenerate:l,generating:d,genProgress:c})]}),u?(0,U.jsxs)("div",{className:"hidden md:grid md:grid-cols-[minmax(150px,0.55fr)_minmax(0,2.45fr)] md:gap-4","data-testid":"ai-editor-review-portrait",children:[(0,U.jsxs)("div",{className:"relative w-full overflow-hidden rounded-xl border border-white/10 bg-black/40",style:f?b:{aspectRatio:"1/1"},children:[g?(0,U.jsx)("img",{src:g,alt:"".concat(m," preview"),className:"block h-full w-full object-contain",draggable:"false"}):(0,U.jsx)("div",{className:"flex h-full w-full items-center justify-center text-[11px] uppercase tracking-[0.22em] text-white/30",children:"No preview"}),(0,U.jsx)("span",{className:"absolute left-3 top-3 rounded-full border border-white/15 bg-black/60 px-2.5 py-1 text-[10px] font-semibold uppercase tracking-[0.18em] text-white/80 backdrop-blur-sm",children:"Structure"})]}),(0,U.jsxs)("div",{className:"flex flex-col gap-2",children:[N,(0,U.jsx)("div",{children:(0,U.jsx)(X,{onGenerate:l,generating:d,genProgress:c})})]})]}):(()=>{const e=f||"16:9"===x,t=x?{aspectRatio:x.replace(":","/")}:{aspectRatio:"16/9"},a=(0,U.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"ai-editor-review-previews",children:[(0,U.jsxs)("div",{className:"relative w-full overflow-hidden rounded-xl border border-white/10 bg-black/40",style:t,children:[g?(0,U.jsx)("img",{src:g,alt:"".concat(m," preview"),className:"block h-full w-full object-contain",draggable:"false"}):(0,U.jsx)("div",{className:"flex h-full w-full items-center justify-center text-[11px] uppercase tracking-[0.22em] text-white/30",children:"No preview"}),(0,U.jsx)("span",{className:"absolute left-3 top-3 rounded-full border border-white/15 bg-black/60 px-2.5 py-1 text-[10px] font-semibold uppercase tracking-[0.18em] text-white/80 backdrop-blur-sm",children:"Structure"})]}),(0,U.jsxs)("div",{className:"relative w-full overflow-hidden rounded-xl border border-white/10 bg-black/40",style:t,children:[null!==s&&void 0!==s&&s.preview_image_base64||null!==s&&void 0!==s&&s.thumbnail_base64||null!==s&&void 0!==s&&s.image_base64_list&&s.image_base64_list[0]?(0,U.jsx)("img",{src:s.preview_image_base64?"data:image/jpeg;base64,".concat(s.preview_image_base64):s.thumbnail_base64?"data:image/jpeg;base64,".concat(s.thumbnail_base64):"data:image/jpeg;base64,".concat(s.image_base64_list[0]),alt:"".concat((null===s||void 0===s?void 0:s.name)||"Style"," preview"),className:"block h-full w-full object-contain",draggable:"false"}):(0,U.jsx)("div",{className:"flex h-full w-full items-center justify-center text-[11px] uppercase tracking-[0.22em] text-white/30",children:(null===s||void 0===s?void 0:s.name)||"Style"}),(0,U.jsx)("span",{className:"absolute left-3 top-3 rounded-full border border-white/15 bg-black/60 px-2.5 py-1 text-[10px] font-semibold uppercase tracking-[0.18em] text-white/80 backdrop-blur-sm",children:"Style"})]})]}),i=(0,U.jsxs)("div",{className:"flex flex-col gap-2",children:[N,(0,U.jsx)("div",{children:(0,U.jsx)(X,{onGenerate:l,generating:d,genProgress:c})})]}),r=f?"minmax(180px,0.55fr)":"minmax(260px,0.9fr)",n="minmax(0,2.45fr)",o=e?"".concat(r,"_").concat(n):"".concat(n,"_").concat(r);return(0,U.jsx)("div",{className:"hidden md:grid md:gap-4",style:{gridTemplateColumns:o.replace("_"," ")}
2,"data-testid":"ai-editor-review-customize-".concat(e?"left":"right"),children:e?(0,U.jsxs)(U.Fragment,{children:[a,i]}):(0,U.jsxs)(U.Fragment,{children:[i,a]})})})()]})}function V(e){let{testid:t,icon:a,label:i,hint:r,accept:s,multiple:n=!1,highlighted:o,inputRef:l,onPick:d,onDrop:c,onDragOver:u,onDragLeave:h,onClear:m,thumbnails:g=[]}=e;return(0,U.jsxs)("label",{onDrop:c,onDragOver:u,onDragLeave:h,className:"group flex min-h-[64px] cursor-pointer flex-col gap-1 rounded-2xl border-2 border-dashed px-3 py-2.5 transition ".concat(o?"border-orange-400/70 bg-orange-500/[0.06]":"border-white/15 bg-white/[0.02] hover:border-orange-400/40 hover:bg-orange-500/[0.04]"),"data-testid":t,children:[(0,U.jsxs)("div",{className:"flex items-center gap-2",children:[a,(0,U.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,U.jsx)("div",{className:"truncate text-[12px] font-semibold text-white",children:i}),(0,U.jsx)("div",{className:"truncate text-[10px] text-white/50",children:r})]}),m&&(0,U.jsx)("button",{type:"button",onClick:e=>{e.preventDefault(),m()},className:"rounded-full p-1 text-white/45 hover:text-rose-300",title:"Remove","data-testid":"".concat(t,"-clear"),children:(0,U.jsx)(f.A,{className:"h-3.5 w-3.5"})})]}),g.length>0&&(0,U.jsx)("div",{className:"flex flex-wrap gap-1",children:g.slice(0,4).map((e,a)=>(0,U.jsx)("span",{className:"block h-7 w-9 overflow-hidden rounded border border-white/15 bg-black/40",children:(0,U.jsx)("img",{src:"data:image/jpeg;base64,".concat(e),alt:"",className:"block h-full w-full object-cover",draggable:"false"})},"".concat(t,"-thumb-").concat(a)))}),(0,U.jsx)("input",{ref:l,type:"file",className:"hidden",accept:s,multiple:n,onChange:d})]})}function X(e){let{onGenerate:t,generating:i,genProgress:s}=e;const{user:o}=(0,C.Ay)(),d="premium"===(null===o||void 0===o?void 0:o.plan),[c,u]=(0,r.useState)(""),[h,m]=(0,r.useState)(null),[x,f]=(0,r.useState)([]),[b,v]=(0,r.useState)(null),[w,N]=(0,r.useState)(null),A=(0,r.useRef)(null),S=(0,r.useRef)(null),R=(0,r.useRef)(null),[T,E]=(0,r.useState)(!1),[D,P]=(0,r.useState)(!1),[L,z]=(0,r.useState)(1),[B,G]=(0,r.useState)("2k"),[q,W]=(0,r.useState)("default"),[Y,H]=(0,r.useState)(""),[X,Z]=(0,r.useState)(!1),Q=20,ee=/\.(heic|heif)$/i,te=e=>new Promise((t,a)=>{const i=new FileReader;i.onload=()=>{const e=String(i.result||"");t(e.includes(",")?e.split(",",2)[1]:e)},i.onerror=a,i.readAsDataURL(e)}),ae=async e=>{if(ee.test((null===e||void 0===e?void 0:e.name)||""))try{const t=await a.e(833).then(a.t.bind(a,1833,23)),i=t.default||t,r=await i({blob:e,toType:"image/jpeg",quality:.9}),s=Array.isArray(r)?r[0]:r;return te(s)}catch(t){return n.oR.warning("Could not convert ".concat(e.name," to JPEG"),{description:"Attaching original \u2014 vision matching may fail."}),te(e)}return te(e)},ie=e=>async t=>{var a;t.preventDefault(),N(null);const i=Array.from((null===(a=t.dataTransfer)||void 0===a?void 0:a.files)||[]);if("doc"===e){const e=i[0];e&&m({file:e,name:e.name})}else if("logo"===e){const e=i[0];if(!e)return;try{const t=await te(e);v({file:e,name:e.name,b64:t})}catch(r){n.oR.error("Could not read logo",{description:String(r.message).slice(0,160)})}}else if("images"===e){if(x.length+i.length>Q)return void n.oR.error("Not more than ".concat(Q," images can be uploaded"),{description:"Pick a smaller batch and try again."});for(const e of i){if(x.length>=Q)break;try{const t=await ae(e);f(a=>a.length>=Q?a:[...a,{file:e,name:e.name,b64:t}])}catch(r){n.oR.error("Could not read image",{description:String(r.message).slice(0,160)})}}}},re=e=>t=>{t.preventDefault(),N(e)},se=()=>N(null);return(0,U.jsxs)("div",{className:"glass relative flex flex-col gap-2 overflow-hidden rounded-3xl p-3 sm:p-4","data-testid":"ai-editor-content-input",children:[(0,U.jsxs)("div",{className:"pointer-events-none absolute inset-0 -z-10 opacity-60",children:[(0,U.jsx)("div",{className:"absolute -left-24 -top-24 h-72 w-72 rounded-full bg-orange-500/15 blur-[80px]"}),(0,U.jsx)("div",{className:"absolute -right-20 bottom-0 h-72 w-72 rounded-full bg-fuchsia-500/15 blur-[80px]"})]}),(0,U.jsx)("textarea",{value:c,onChange:e=>u(e.target.value),placeholder:"Type in content here\u2026",rows:4,className:"topic-textarea -mb-2 min-h-[72px] w-full resize-none overflow-y-auto bg-transparent px-4 py-3 text-base text-white placeholder:text-[1.25em] placeholder:text-white/65 focus:outline-none","data-testid":"ai-editor-content-textarea"}),(0,U.jsxs)("div",{className:"grid gap-2 sm:grid-cols-3","data-testid":"ai-editor-content-uploads",children:[(0,U.jsx)(V,{testid:"ai-editor-upload-doc",icon:(0,U.jsx)(k.A,{className:"h-5 w-5 text-orange-300"}),label:h?h.name:"Upload Documents",hint:h?"Click or drop to replace":"PDF \xb7 DOCX \xb7 PPTX \xb7 TXT \xb7 MD",accept:".pdf,.ppt,.pptx,.doc,.docx,.txt,.md",highlighted:"doc"===w,inputRef:A,onPick:e=>{var t;const a=null===(t=e.target.files)||void 0===t?void 0:t[0];a&&m({file:a,name:a.name}),A.current&&(A.current.value="")},onDrop:ie("doc"),onDragOver:re("doc"),onDragLeave:se,onClear:h?()=>m(null):null}),(0,U.jsx)(V,{testid:"ai-editor-upload-images",icon:(0,U.jsx)(y.A,{className:"h-5 w-5 text-orange-300"}),label:x.length>0?"".concat(x.length," image").concat(x.length>
21?"s":""," ready"):"Upload Images",hint:x.length>0?"Up to ".concat(Q," \u2014 click to add more"):"Up to ".concat(Q," \xb7 max 3 per design \xb7 JPG \xb7 PNG \xb7 WebP \xb7 HEIC"),accept:"image/jpeg,image/png,image/webp,image/gif,image/heic,image/heif,.heic,.heif",multiple:!0,highlighted:"images"===w,inputRef:S,onPick:async e=>{const t=Array.from(e.target.files||[]);if(S.current&&(S.current.value=""),x.length+t.length>Q)n.oR.error("Not more than ".concat(Q," images can be uploaded"),{description:"Pick a smaller batch and try again."});else for(const i of t){if(x.length>=Q)break;try{const e=await ae(i);f(t=>t.length>=Q?t:[...t,{file:i,name:i.name,b64:e}])}catch(a){n.oR.error("Could not read image",{description:String(a.message||a).slice(0,160)})}}},onDrop:ie("images"),onDragOver:re("images"),onDragLeave:se,onClear:x.length>0?()=>f([]):null,thumbnails:x.map(e=>e.b64)}),(0,U.jsx)(V,{testid:"ai-editor-upload-logo",icon:(0,U.jsx)(l.A,{className:"h-5 w-5 text-orange-300"}),label:b?b.name:"Upload Logo",hint:b?"Click or drop to replace":"Used as branding \xb7 PNG \xb7 SVG \xb7 WebP",accept:"image/jpeg,image/png,image/webp,image/svg+xml",highlighted:"logo"===w,inputRef:R,onPick:async e=>{var t;const a=null===(t=e.target.files)||void 0===t?void 0:t[0];if(R.current&&(R.current.value=""),a)try{const e=await te(a);v({file:a,name:a.name,b64:e})}catch(i){n.oR.error("Could not read logo",{description:String(i.message||i).slice(0,160)})}},onDrop:ie("logo"),onDragOver:re("logo"),onDragLeave:se,onClear:b?()=>v(null):null,thumbnails:b?[b.b64]:[]})]}),(0,U.jsxs)("div",{className:"flex items-center justify-between gap-2 pt-1",children:[(0,U.jsx)(_.Bc,{delayDuration:150,disableHoverableContent:!0,children:(0,U.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,U.jsxs)(_.m_,{children:[(0,U.jsx)(_.k$,{asChild:!0,children:(0,U.jsx)("span",{children:(0,U.jsx)(J,{})})}),(0,U.jsx)(_.ZI,{side:"bottom",className:"bg-zinc-900 text-white",children:"Select your language"})]}),(0,U.jsxs)(_.m_,{children:[(0,U.jsx)(_.k$,{asChild:!0,children:(0,U.jsx)("span",{children:(0,U.jsx)($,{icon:(0,U.jsx)(M.A,{className:"h-4 w-4"}),title:"Web",testid:"ai-editor-web-toggle",active:X,onToggle:Z})})}),(0,U.jsx)(_.ZI,{side:"bottom",className:"bg-zinc-900 text-white",children:"Enable web search"})]}),(0,U.jsxs)(_.m_,{children:[(0,U.jsx)(_.k$,{asChild:!0,children:(0,U.jsx)("span",{children:(0,U.jsx)($,{icon:(0,U.jsx)(j.A,{className:"h-4 w-4"}),title:"Ultra",testid:"ai-editor-ultra-toggle"})})}),(0,U.jsxs)(_.ZI,{side:"bottom",className:"bg-zinc-900 text-white",children:["Enable Ultra mode"," ",(0,U.jsx)("span",{className:"ml-1 rounded-full bg-amber-400/20 px-1.5 py-[1px] text-[9px] font-bold uppercase tracking-wider text-amber-200",children:"Premium only"})]})]}),(0,U.jsxs)(_.m_,{children:[(0,U.jsx)(_.k$,{asChild:!0,children:(0,U.jsx)("span",{children:(0,U.jsx)($,{icon:(0,U.jsx)(O.A,{className:"h-4 w-4"}),title:"Voice input",testid:"ai-editor-voice-toggle"})})}),(0,U.jsx)(_.ZI,{side:"bottom",className:"bg-zinc-900 text-white",children:"Enable voice input"})]}),(0,U.jsxs)(_.m_,{children:[(0,U.jsx)(_.k$,{asChild:!0,children:(0,U.jsx)("button",{type:"button",onClick:()=>P(e=>!e),"aria-pressed":D,"aria-label":"No text on design",className:"relative inline-flex h-9 w-9 items-center justify-center rounded-full border transition ".concat(D?"border-orange-400/60 bg-orange-500/[0.16] text-orange-200 hover:border-orange-300/80 hover:bg-orange-500/[0.22]":"border-white/10 bg-white/5 text-white/70 hover:border-white/25 hover:bg-white/10 hover:text-white"),"data-testid":"ai-editor-no-text-toggle",children:(0,U.jsx)(F,{className:"h-4 w-4"})})}),(0,U.jsx)(_.ZI,{side:"bottom",className:"bg-zinc-900 text-white",children:D?"Text-free render \u2014 ON":"No text on design"})]}),d&&(0,U.jsxs)(_.m_,{children:[(0,U.jsx)(_.k$,{asChild:!0,children:(0,U.jsx)("button",{type:"button",onClick:()=>E(!0),"aria-label":"Advanced settings",className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-white/10 bg-white/5 text-white/70 transition hover:border-white/25 hover:bg-white/10 hover:text-white","data-testid":"ai-editor-settings-toggle",children:(0,U.jsx)(I.A,{className:"h-4 w-4"})})}),(0,U.jsx)(_.ZI,{side:"bottom",className:"bg-zinc-900 text-white",children:"Advanced settings"})]})]})}),(0,U.jsx)("button",{type:"button",disabled:i,onClick:()=>{i||null===t||void 0===t||t({text:c,file:(null===h||void 0===h?void 0:h.file)||null,images:x.map(e=>e.b64),logo:(null===b||void 0===b?void 0:b.b64)||null,slideCount:L,quality:B,thinking:q,font:Y,webMode:X,noTextOnDesign:D})},className:"btn-flame inline-flex items-center gap-2 rounded-full px-6 py-3 text-sm font-semibold text-white disabled:opacity-60","data-testid":"ai-editor-content-go",children:i?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(p.A,{className:"h-4 w-4 animate-spin"}),s?"Rendering ".concat(s.slides_done,"/").concat(s.slides_total," image").concat(s.slides_total>1?"s":"","\u2026"):"Generating\u2026"]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(l.A,{className:"h-4 w-4"}),"Let's go",(0,U.jsx)(g.A,{className:"h-4 w-4"})]})})]}),(0,U.jsx)(K,{open:T,onOpenChange:E,slideCount:L,onSlideCount:z,quality:B,onQuality:G,thinking:q,onThinking:W,font:Y,onFont:H,userPlan:(null===o||void 0===o?void 0:o.plan)||"anon"})]})}function J(){const[e,t]=(0,r.useState)("English"),a=R.Yj.find(t=>t.name===e)||R.Yj[0];return(0,U.jsxs)("label",{className:"relative inline-flex h-9 cursor-pointer items-center justify-center rounded-full border border-white/10 bg-white/5 px-2.5 transition hover:border-white/25 hover:bg-white/10",title:a.name,"data-testid":"ai-editor-lang-toggle",children:[(0,U.jsx)("span",{className:"text-base leading-none",children:a.flag}),(0,U.jsx)("select",{value:a.name,onChange:e=>t(e.target.value),className:"absolute inset-0 h-full w-full cursor-pointer opacity-0","data-testid":"ai-editor-lang-select",children:R.Yj.map(e=>(0,U.jsxs)("option",{value:e.name,children:[e.flag," ",e.name]},e.code))})]})}function $(e){let{icon:t,title:a,testid:i,active:s,onToggle:n}=e;const[o,l]=(0,r.useState)(!1),d="boolean"===typeof s,c=d?s:o;return(0,U.jsx)("button",{type:"button",onClick:()=>{d?null===n||void 0===n||n(!c):l(e=>!e)},title:a,"aria-label":a,"aria-pressed":c,className:"inline-flex h-9 w-9 items-center justify-center rounded-full border transition ".concat(c?"border-orange-400/70 bg-orange-500/15 text-orange-100":"border-white/10 bg-white/5 text-white/70 hover:border-white/25 hover:bg-white/10 hover:text-white"),"data-testid":i,children:t})}function K(e){let{open:t,onOpenChange:a,slideCount:i,onSlideCount:r,quality:s,onQuality:n,thinking:o,onThinking:l,font:d,onFont:c,userPlan:u="anon"}=e;return(0,U.jsx)(A.lG,{open:t,onOpenChange:a,children:(0,U.jsxs)(A.Cf,{className:"w-[95vw] max-w-5xl border-white/10 bg-zinc-950 text-white sm:w-full","data-testid":"ai-editor-settings-dialog",children:[(0,U.jsx)(A.c7,{children:(0,U.jsxs)(A.L3,{className:"flex items-center gap-2 text-2xl font-semibold text-white",children:[(0,U.jsx)(I.A,{className:"h-5 w-5 text-orange-300"}),"Settings"]})}),(0,U.jsxs)("div",{className:"mt-2 space-y-6",children:[(0,U.jsxs)("div",{children:[(0,U.jsx)("label",{className:"mb-2 block text-base font-semibold text-white",children:"Number of slides"}),(0,U.jsx)("div",{className:"flex flex-wrap gap-2",children:Array.from({length:10},(e,t)=>t+1).map(e=>{const t=i===e;return(0,U.jsx)("button",{type:"button",onClick:()=>r(e),className:"h-9 min-w-9 rounded-full border px-3 text-sm font-semibold transition ".concat(t?"border-orange-400/70 bg-orange-500/15 text-orange-100":"border-white/10 bg-white/5 text-white/70 hover:border-white/25 hover:bg-white/10 hover:text-white"),"aria-pressed":t,"data-testid":"ai-editor-settings-slides-".concat(e),children:e},e)})})]}),(0,U.jsxs)("div",{children:[(0,U.jsx)("label",{className:"mb-2 block text-base font-semibold text-white",children:"Quality"}),(0,U.jsxs)("div",{className:"flex gap-2",children:[(0,U.jsx)(Z,{active:"2k"===s,onClick:()=>n("2k"),testid:"ai-editor-settings-quality-2k",children:"2K"}),"premium"===u&&(0,U.jsxs)(Z,{active:"4k"===s,onClick:()=>n("4k"),testid:"ai-editor-settings-quality-4k",children:["4K",(0,U.jsx)("span",{className:"ml-1.5 rounded-full bg-amber-400/20 px-1.5 py-[1px] text-[9px] font-bold uppercase tracking-wider text-amber-200",children:"Premium"}),(0,U.jsx)("span",{className:"ml-1.5 text-[10px] font-medium text-white/45",children:"15 credits"})]})]})]}),(0,U.jsxs)("div",{children:[(0,U.jsx)("label",{className:"mb-2 block text-base font-semibold text-white",children:"Thinking complexity"}),(0,U.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,U.jsxs)(Z,{active:"default"===o,onClick:()=>l("default"),testid:"ai-editor-settings-thinking-default",children:["Default",(0,U.jsx)("span",{className:"ml-1.5 text-[10px] font-medium text-white/45",children:"(recommended)"})]}),(0,U.jsxs)(Z,{active:"high"===o,onClick:()=>l("high"),testid:"ai-editor-settings-thinking-high",children:["High",(0,U.jsx)("span",{className:"ml-1.5 text-[10px] font-medium text-white/45",children:"10 credits"})]}),(0,U.jsxs)(Z,{active:"very-high"===o,onClick:()=>l("very-high"),testid:"ai-editor-settings-thinking-very-high",children:["Very High",(0,U.jsx)("span",{className:"ml-1.5 text-[10px] font-medium text-white/45",children:"20 credits"})]})]})]}),(0,U.jsxs)("div",{children:[(0,U.jsx)("label",{className:"mb-2 block text-base font-semibold text-white",children:"Font"}),(0,U.jsx)("input",{type:"text",value:d,onChange:e=>c(e.target.value),placeholder:'e.g. "Inter", "Roboto", "Playfair Display"',className:"h-10 w-full rounded-lg border border-white/10 bg-black/40 px-3 text-sm text-white outline-none placeholder:text-white/35 focus:border-orange-400/60","data-testid":"ai-editor-settings-font"})]})]})]})})}function Z(e){let{active:t,onClick:a,children:i,testid:r}=e;return(0,U.jsx)("button",{type:"button",onClick:a,"aria-pressed":t,className:"inline-flex h-9 items-center rounded-full border px-3.5 text-sm font-semibold transition ".concat(t?"border-orange-400/70 bg-orange-500/15 text-orange-100":"border-white/10 bg-white/5 text-white/75 hover:border-white/25 hover:bg-white/10 hover:text-white"),"data-testid":r,children:i})}function Q(e){let{industries:t,value:a,categorySlug:i,onChange:s}=e;const[n,o]=(0,r.useState)(!1),[l,d]=(0,r.useState)(""),c=(0,r.useRef)(null),u=(0,r.useRef)(null),h=Array.isArray(t)?t:[],m=h.find(e=>e.slug===a),g=!m&&a?a.split("-").map(e=>e?e[0].toUpperCase()+e.slice(1):"").join(" "):"",p=(null===m||void 0===m?void 0:m.name)||g||"All industries";(0,r.useEffect)(()=>
2{if(!n)return;d(""),setTimeout(()=>{var e;return null===(e=u.current)||void 0===e?void 0:e.focus()},0);const e=e=>{c.current&&!c.current.contains(e.target)&&o(!1)},t=e=>{"Escape"===e.key&&o(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[n]);const w=(()=>{const e=(l||"").trim().toLowerCase();return e?h.filter(t=>{const a=String((null===t||void 0===t?void 0:t.name)||"").toLowerCase(),i=String((null===t||void 0===t?void 0:t.slug)||"").toLowerCase();if(a.includes(e)||i.includes(e))return!0;return(Array.isArray(null===t||void 0===t?void 0:t.tags)?t.tags:[]).some(t=>String(t||"").toLowerCase().includes(e))}):h})();return(0,U.jsxs)("div",{ref:c,className:"relative w-full sm:w-auto",children:[(0,U.jsxs)("button",{type:"button",onClick:()=>o(e=>!e),className:"flex min-h-[58px] w-full items-center justify-between gap-2 rounded-full border px-4 text-sm font-medium transition sm:w-auto sm:min-w-[200px] ".concat(m?"border-orange-400/40 bg-orange-500/[0.08] text-orange-100 hover:border-orange-300/60 hover:bg-orange-500/[0.12]":"border-white/10 bg-white/[0.04] text-white/75 hover:border-white/25 hover:bg-white/[0.08] hover:text-white"),"aria-haspopup":"listbox","aria-expanded":n,"data-testid":"ai-editor-industry-dropdown-toggle",children:[(0,U.jsxs)("div",{className:"flex min-w-0 flex-col items-start text-left",children:[(0,U.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-[0.18em] text-white/45",children:"Selected industry"}),(0,U.jsx)("span",{className:"truncate text-[13px] font-semibold",children:p})]}),(0,U.jsx)(b.A,{className:"h-3.5 w-3.5 shrink-0 transition ".concat(n?"rotate-180":"")})]}),n&&(0,U.jsxs)("div",{className:"absolute right-0 z-30 mt-2 w-full overflow-hidden rounded-2xl border border-white/12 bg-zinc-950 shadow-2xl sm:w-[280px]",role:"listbox","data-testid":"ai-editor-industry-dropdown-menu",children:[(0,U.jsx)("div",{className:"border-b border-white/10 p-2",children:(0,U.jsxs)("div",{className:"flex items-center gap-2 rounded-full border border-white/10 bg-white/[0.04] px-3 py-1.5",children:[(0,U.jsx)(x.A,{className:"h-4 w-4 text-white/65"}),(0,U.jsx)("input",{ref:u,type:"text",value:l,onChange:e=>d(e.target.value),placeholder:"Search categories\u2026",className:"h-7 w-full bg-transparent text-[15.5px] text-white outline-none placeholder:text-white/70","data-testid":"ai-editor-industry-dropdown-search"}),l&&(0,U.jsx)("button",{type:"button",onClick:()=>d(""),className:"text-white/65 transition hover:text-white","aria-label":"Clear search","data-testid":"ai-editor-industry-dropdown-search-clear",children:(0,U.jsx)(f.A,{className:"h-3.5 w-3.5"})})]})}),(0,U.jsxs)("button",{type:"button",onClick:()=>{null===s||void 0===s||s(""),o(!1)},className:"flex w-full items-center justify-between px-4 py-2.5 text-left text-sm transition ".concat(m?"text-white/80 hover:bg-white/[0.06] hover:text-white":"bg-orange-500/[0.12] text-orange-100"),"data-testid":"ai-editor-industry-dropdown-item-all",children:["All industries",!m&&(0,U.jsx)(v.A,{className:"h-3.5 w-3.5 text-orange-300"})]}),(0,U.jsx)("div",{className:"max-h-72 overflow-y-auto border-t border-white/10",children:0===w.length?(0,U.jsxs)("div",{className:"px-4 py-3 text-center text-[12px] text-white/45","data-testid":"ai-editor-industry-dropdown-empty",children:["No categories match \u201c",l,"\u201d."]}):w.map(e=>{const t=e.slug===a;return(0,U.jsxs)("button",{type:"button",onClick:()=>{null===s||void 0===s||s(e.slug),o(!1)},className:"flex w-full items-center justify-between px-4 py-2 text-left text-[13px] transition ".concat(t?"bg-orange-500/[0.12] text-orange-100":"text-white/80 hover:bg-white/[0.06] hover:text-white"),"data-testid":"ai-editor-industry-dropdown-item-".concat(e.slug),children:[e.name,t&&(0,U.jsx)(v.A,{className:"h-3.5 w-3.5 text-orange-300"})]},e.id)})})]})]})}function ee(e){let{industries:t,industriesLoaded:a,categorySlug:i,onSelect:s,onSkipAll:n}=e;(i||"").split("-").map(e=>e?e[0].toUpperCase()+e.slice(1):"").join(" ");const[o,l]=(0,r.useState)(""),d=(0,r.useMemo)(()=>{const e=(o||"").trim().toLowerCase();return e&&Array.isArray(t)?t.filter(t=>{if(((null===t||void 0===t?void 0:t.name)||"").toLowerCase().includes(e))return!0;return(Array.isArray(null===t||void 0===t?void 0:t.tags)?t.tags:[]).some(t=>(t||"").toLowerCase().includes(e))}):t||[]}
2,[t,o]);return a?(0,U.jsxs)("div",{className:"space-y-4","data-testid":"ai-editor-industry-step",children:[(0,U.jsxs)("div",{className:"mx-auto flex max-w-sm items-center gap-2 rounded-full border border-white/10 bg-white/[0.04] px-3 py-1.5",children:[(0,U.jsx)(x.A,{className:"h-3.5 w-3.5 text-white/40"}),(0,U.jsx)("input",{type:"text",value:o,onChange:e=>l(e.target.value),placeholder:"Search industry",className:"h-6 w-full bg-transparent text-[12.5px] text-white outline-none placeholder:text-white/40","data-testid":"ai-editor-industry-search"}),o&&(0,U.jsx)("button",{type:"button",onClick:()=>l(""),className:"text-white/40 transition hover:text-white","aria-label":"Clear search","data-testid":"ai-editor-industry-search-clear",children:(0,U.jsx)(f.A,{className:"h-3 w-3"})})]}),0===d.length?(0,U.jsxs)("div",{className:"rounded-2xl border border-white/10 bg-white/[0.02] p-10 text-center text-sm text-white/55","data-testid":"ai-editor-industry-empty",children:['No industries match "',(0,U.jsx)("span",{className:"text-white",children:o}),'". Clear the search to see them all.']}):(0,U.jsxs)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4 sm:gap-4 lg:grid-cols-5","data-testid":"ai-editor-industry-grid",children:[!o&&(0,U.jsxs)("button",{type:"button",onClick:()=>null===n||void 0===n?void 0:n(),className:"group relative aspect-video w-full overflow-hidden rounded-2xl border border-orange-400/40 bg-gradient-to-br from-orange-500/15 via-rose-500/10 to-transparent transition hover:border-orange-300/70 hover:shadow-[0_0_24px_rgba(251,146,60,0.35)]","data-testid":"ai-editor-industry-card-all",children:[(0,U.jsx)("div",{className:"absolute inset-0 flex items-center justify-center px-3 text-center",children:(0,U.jsx)("div",{className:"text-base font-bold uppercase tracking-[0.18em] text-white drop-shadow",children:"See all"})}),(0,U.jsx)("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 translate-y-full bg-gradient-to-t from-black/80 via-black/40 to-transparent px-4 pb-3 pt-6 transition-transform duration-300 ease-out group-hover:translate-y-0",children:(0,U.jsx)("div",{className:"text-sm font-semibold text-white",children:"Skip the niche filter"})})]}),(d||[]).map(e=>{const t=e.thumbnail_base64?e.thumbnail_base64.startsWith("data:")?e.thumbnail_base64:"data:image/jpeg;base64,".concat(e.thumbnail_base64):null;return(0,U.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ai-editor-industry-card-".concat(e.slug),children:[(0,U.jsx)("button",{type:"button",onClick:()=>null===s||void 0===s?void 0:s(e.slug),className:"group relative aspect-video w-full overflow-hidden rounded-2xl border border-white/10 bg-zinc-900 transition hover:border-white/30 hover:shadow-[0_0_24px_rgba(255,255,255,0.12)]","data-testid":"ai-editor-industry-card-".concat(e.slug,"-button"),children:t?(0,U.jsx)("img",{src:t,alt:e.name,loading:"lazy",decoding:"async",className:"h-full w-full object-cover transition duration-500 group-hover:scale-[1.04]"}):(0,U.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-gradient-to-br from-white/5 to-white/0 px-3 text-center",children:(0,U.jsx)("div",{className:"text-sm font-semibold uppercase tracking-[0.18em] text-white/55",children:e.name})})}),(0,U.jsx)("div",{className:"px-1 text-center text-[13px] font-semibold leading-tight text-white sm:text-sm",children:e.name})]},e.id)})]})]}):(0,U.jsx)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4 sm:gap-4 lg:grid-cols-5","data-testid":"ai-editor-industry-grid-loading","aria-busy":"true",children:Array.from({length:21},(e,t)=>(0,U.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,U.jsx)("div",{className:"relative aspect-video w-full overflow-hidden rounded-2xl border border-white/10 bg-white/[0.03]",children:(0,U.jsx)("div",{className:"absolute inset-0 animate-pulse bg-gradient-to-br from-white/[0.04] via-white/[0.02] to-transparent"})}),(0,U.jsx)("div",{className:"mx-auto h-3 w-2/3 animate-pulse rounded bg-white/10"})]},t))})}function te(e){let{variation:t,onClick:a,onCustomFileDropped:i,isFavorite:s,onToggleFavorite:n}=e;const o=!!t.image,l=t.id.startsWith("placeholder"),d=!!t.isCustom,u=(0,r.useRef)(null),[h,m]=(0,r.useState)(!1),g=()=>(0,U.jsx)("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 translate-y-full bg-gradient-to-t from-black/85 via-black/55 to-transparent px-4 pb-3.5 pt-7 transition-transform duration-300 ease-out group-hover:translate-y-0","data-testid":"ai-editor-card-".concat(t.id,"-hover-label"),children:(0,U.jsx)("div",{className:"text-base font-semibold text-white drop-shadow-[0_1px_2px_rgba(0,0,0,0.45)]",children:t.name})});if(d){const e=()=>{var e;l||null===(e=u.current)||void 0===e||e.click()};return(0,U.jsxs)("div",{role:"button",tabIndex:0,onClick:e,onKeyDown:t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),e())},onDragOver:e=>{e.preventDefault(),l||m(!0)},onDragLeave:()=>m(!1),onDrop:e=>{var t,r;e.preventDefault(),m(!1);const s=null===(t=e.dataTransfer)||void 0===t||null===(r=t.files)||void 0===r?void 0:r[0];s&&i?i(s):s&&(null===a||void 0===a||a())},"aria-label":t.name,className:"group relative flex w-full cursor-pointer flex-col overflow-hidden rounded-2xl border text-left transition ".concat(h?"border-orange-400/80 bg-orange-500/[0.12] shadow-[0_20px_50px_-25
2px_rgba(251,146,60,0.7)]":"border-dashed border-orange-400/40 bg-orange-500/[0.04] hover:border-orange-400/70 hover:bg-orange-500/[0.08] hover:shadow-[0_20px_50px_-25px_rgba(251,146,60,0.55)]"),"data-testid":"ai-editor-card-".concat(t.id),children:[(0,U.jsxs)("div",{className:"relative aspect-video w-full overflow-hidden bg-black/40",children:[(0,U.jsxs)("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 px-3 text-center text-orange-200/85",children:[(0,U.jsx)(w.A,{className:"h-9 w-9 transition ".concat(h?"scale-110":"group-hover:scale-110")}),(0,U.jsx)("div",{className:"text-[10px] font-semibold uppercase tracking-[0.22em]",children:h?"Drop to analyze":"Upload your own design"}),(0,U.jsx)("div",{className:"hidden text-[9px] uppercase tracking-[0.18em] text-orange-200/45 sm:block",children:"drag & drop \xb7 or click to upload"})]}),(0,U.jsx)(g,{})]}),(0,U.jsx)("input",{ref:u,type:"file",accept:"image/jpeg,image/png,image/webp",className:"hidden",onChange:e=>{var t;const r=null===(t=e.target.files)||void 0===t?void 0:t[0];u.current&&(u.current.value=""),r&&i?i(r):null===a||void 0===a||a()},"data-testid":"ai-editor-card-".concat(t.id,"-file-input")})]})}return(0,U.jsx)("button",{type:"button",onClick:a,disabled:l,"aria-label":t.name,className:"group relative flex w-full flex-col overflow-hidden rounded-2xl border text-left transition ".concat(l?"cursor-not-allowed border-white/10 bg-white/[0.03] opacity-80":d?"border-dashed border-orange-400/40 bg-orange-500/[0.04] hover:border-orange-400/70 hover:bg-orange-500/[0.08] hover:shadow-[0_20px_50px_-25px_rgba(251,146,60,0.55)]":"border-white/10 bg-white/[0.03] hover:border-orange-400/40 hover:bg-white/[0.06] hover:shadow-[0_20px_50px_-25px_rgba(251,146,60,0.45)]"),"data-testid":"ai-editor-card-".concat(t.id),children:o?(0,U.jsxs)("div",{className:"relative w-full overflow-hidden bg-black/40",children:[(0,U.jsx)("img",{src:t.image,alt:"".concat(t.name," preview"),className:"block h-auto w-full transition-transform duration-500 group-hover:scale-[1.03]",draggable:"false",loading:"lazy"}),!l&&!d&&n&&(0,U.jsx)("span",{role:"button",tabIndex:0,onClick:e=>{e.preventDefault(),e.stopPropagation(),n()},onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),e.stopPropagation(),n())},className:"absolute right-2 top-2 z-10 inline-flex h-9 w-9 cursor-pointer items-center justify-center rounded-full border backdrop-blur-md transition ".concat(s?"border-rose-400/60 bg-rose-500/[0.18] text-rose-300 hover:bg-rose-500/[0.28]":"border-white/20 bg-black/35 text-white/70 opacity-0 group-hover:opacity-100 hover:border-rose-400/40 hover:bg-rose-500/[0.18] hover:text-rose-200"),"aria-label":s?"Remove from favorites":"Add to favorites","aria-pressed":s,"data-testid":"ai-editor-card-".concat(t.id,"-favorite").concat(s?"-active":""),children:(0,U.jsx)(c,{className:"h-4 w-4 transition ".concat(s?"fill-current":"")})}),(0,U.jsx)(g,{})]}):(0,U.jsxs)("div",{className:"relative aspect-video w-full overflow-hidden bg-black/40",children:[d?(0,U.jsxs)("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 text-orange-200/85",children:[(0,U.jsx)(w.A,{className:"h-9 w-9 transition group-hover:scale-110"}),(0,U.jsx)("div",{className:"text-[10px] uppercase tracking-[0.22em]",children:"Bring your own"})]}):(0,U.jsx)("div",{className:"flex h-full w-full items-center justify-center text-[11px] uppercase tracking-[0.22em] text-white/30",children:"Coming soon"}),(0,U.jsx)(g,{})]})})}function ae(e){let{name:t,reference:a,api:i,onChangeName:o,onChangeReference:d,onDetectedMeta:c,onContinue:u}=e;const[h,m]=(0,r.useState)(!1),[x,b]=(0,r.useState)(!1),[v,y]=(0,r.useState)([]),j=(0,r.useRef)(!1),N=(0,r.useCallback)(async e=>{if(e){m(!0);try{const{data:t}=await s.A.post("".concat(i,"/ai-editor-variations/generate-tags"),{image_base64:e,name:""},{timeout:45e3}),a=String((null===t||void 0===t?void 0:t.name)||"").trim(),r=Array.isArray(null===t||void 0===t?void 0:t.colors)?t.colors:[],n=(null===t||void 0===t?void 0:t.aspect_ratio)||null;a&&!j.current&&o(a),y(r),null===c||void 0===c||c({colors:r,aspect_ratio:n,tags:Array.isArray(null===t||void 0===t?void 0:t.tags)?t.tags:[]})}catch(t){console.warn("Custom structure auto-analyze failed:",null===t||void 0===t?void 0:t.message)}finally{m(!1)}}},[i]),k=(0,r.useRef)("");(0,r.useEffect)(()=>{a&&k.current!==a&&(h||(v.length>0?k.current=a:(k.current=a,N(a))))},[a]);const A=async e=>{if(!e)return;if(!["image/jpeg","image/png","image/webp"].includes(e.type))return void n.oR.error("JPEG, PNG or WebP only",{description:"Please upload a JPG, PNG or WebP image as your reference."});if(e.size>10485760){const t=(e.size/1048576).toFixed(1);return void n.oR.error("File too large",{description:"That image is ".concat(t," MB. Max upload size is 10 MB on every plan \u2014 please compress it and try again.")})}try{const t=await(e=>new Promise((t,a)=>{const i=new FileReader;i.onload=()=>{const e=String(i.result||"");t(e.includes(",")?e.split(",")[1]:e)},i.onerror=a,i.readAsDataURL(e)}))(e);d(t),k.current=t,await N(t)}catch(t){n.oR.error("Could not read that file")}},_=t.trim().length>0&&!h&&!x;return(0,U.jsxs)("div",{className:"mx-auto max-w-2xl space-y-6","data-testid":"ai-editor-custom-structure-step",children:[(0,U.jsxs)("div",{children:[(0,U.jsx)("label",{className:"mb-2 block text-base font-semibold text-white",children:"Upload your Reference"}),(0,U.jsxs)("label",{onDrop:e=>{var t,a;e.preventDefault(),A(null===(t=e.dataTransfer)||void 0===t||null===(a=t.files)||void 0===a?void 0:a[0])},onDragOver:e=>e.preventDefault(),className:"group relative flex min-h-[260px] cursor-pointer flex-col items-center justify-center gap-3 rounded-2xl border-2 border-dashed border-white/15 bg-white/[0.02] px-6 py-10 text-center transition hover:border-orange-400/50 hover:bg-orange-500/[0.04]","data-testid":"ai-editor-custom-upload-zone",children:[a?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("div",{className:"relative",children:(0,U.jsx)("img",{src:a.startsWith("data:")?a:"data:image/png;base64,".concat(a),alt:"Reference preview",className:"max-h-72 max-w-full rounded-lg border border-white/10 object-contain"})}),(0,U.jsx)("div",{className:"text-xs text-white/55",children:"Click or drop a new file to replace it."})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(w.A,{className:"h-12 w-12 text-white/55 transition group-hover:text-orange-300"}),(0,U.jsx)("div",{className:"text-base font-semibold text-white",children:"Drop a file or click to upload"}),(0,U.jsx)("div",{className:"max-w-md text-xs leading-relaxed text-white/50",children:"JPEG, PNG or WebP only."})]}),(0,U.jsx)("input",{type:"file",className:"hidden",accept:"image/jpeg,image/png,image/webp",onChange:e=>{var t;return A(null===(t=e.target.files)||void 0===t?void 0:t[0])},"data-testid":"ai-editor-custom-file-input"}),h&&(0,U.jsx)("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center rounded-2xl bg-black/55 backdrop-blur-[2px]","data-testid":"ai-editor-custom-analyzing",children:(0,U.jsxs)("div",{className:"inline-flex items-center gap-2 rounded-full border border-orange-400/40 bg-black/60 px-3 py-1.5 text-xs font-semibold text-orange-200",children:[(0,U.jsx)(p.A,{className:"h-3.5 w-3.5 animate-spin"}),"Analyzing \u2014 naming & reading colors\u2026"]})})]}),a&&!h&&(0,U.jsx)("div",{className:"mt-2 flex justify-end",children:(0,U.jsx)("button",{type:"button",onClick:()=>{d(""),y([])},className:"text-[11px] text-rose-300 hover:underline","data-testid":"ai-editor-custom-clear",children:"Remove reference"})})]}),(0,U.jsxs)("div",{children:[(0,U.jsx)("label",{className:"mb-2 block text-sm font-semibold text-white",children:"Name"}),(0,U.jsx)("input",{type:"text",value:t,onChange:e=>{j.current=!0,o(e.target.value)},placeholder:h?"Reading reference\u2026":"e.g. Org Chart, Customer Journey, Flywheel",maxLength:80,className:"h-11 w-full rounded-xl border border-white/10 bg-black/40 px-4 text-sm text-white outline-none transition placeholder:text-white/35 focus:border-orange-400/60","data-testid":"ai-editor-custom-name"})]}),(0,U.jsxs)("div",{children:[(0,U.jsxs)("div",{className:"mb-2 flex items-end justify-between",children:[(0,U.jsx)("label",{className:"block text-sm font-semibold text-white",children:"Colors"}),v.length<5&&(0,U.jsxs)("button",{type:"button",onClick:()=>{const e=[...v,"#888888"];y(e),null===c||void 0===c||c({colors:e})},className:"inline-flex items-center gap-1 rounded-full border border-white/15 bg-white/[0.04] px-2.5 py-1 text-[10px] font-semibold uppercase tracking-[0.18em] text-white/75 transition hover:border-orange-400/50 hover:bg-orange-500/10 hover:text-orange-200","data-testid":"ai-editor-custom-add-color",children:[(0,U.jsx)(l.A,{className:"h-3 w-3"}),"Add color"]})]}),v.length>0?(0,U.jsx)("div",{className:"flex flex-wrap gap-2","data-testid":"ai-editor-custom-colors",children:v.slice(0,5).map((e,t)=>(0,U.jsxs)("div",{className:"group relative inline-flex items-center gap-2 rounded-full border border-white/10 bg-white/[0.04] py-1 pl-1 pr-3",title:e,children:[(0,U.jsx)("label",{className:"relative inline-block h-5 w-5 cursor-pointer overflow-hidden rounded-full border border-white/20",style:{background:e}
2,children:(0,U.jsx)("input",{type:"color",value:e,onChange:e=>{const a=[...v];a[t]=e.target.value.toLowerCase(),y(a),null===c||void 0===c||c({colors:a})},className:"absolute inset-0 cursor-pointer opacity-0","aria-label":"Edit colour ".concat(e),"data-testid":"ai-editor-custom-color-edit-".concat(t)})}),(0,U.jsx)("span",{className:"font-mono text-[11px] uppercase text-white/85",children:e}),(0,U.jsx)("button",{type:"button",onClick:()=>{const e=v.filter((e,a)=>a!==t);y(e),null===c||void 0===c||c({colors:e})},"aria-label":"Remove ".concat(e),"data-testid":"ai-editor-custom-color-remove-".concat(t),className:"ml-0.5 flex h-4 w-4 items-center justify-center rounded-full border border-white/15 bg-black/30 text-white/55 opacity-0 transition hover:border-rose-400/60 hover:bg-rose-500/20 hover:text-rose-200 group-hover:opacity-100",children:(0,U.jsx)(f.A,{className:"h-2.5 w-2.5"})})]},t))}):(0,U.jsx)("div",{className:"text-xs text-white/40",children:h?"Reading colors from your reference\u2026":a?'No colors detected \u2014 click "Add color" to set them manually.':"Upload a reference and we'll pull the palette automatically."})]}),(0,U.jsxs)("div",{className:"space-y-3 pt-2",children:[x&&(0,U.jsxs)("div",{className:"space-y-2",role:"status","aria-live":"polite","data-testid":"ai-editor-custom-saving",children:[(0,U.jsxs)("div",{className:"flex items-center justify-between text-[11px] font-semibold uppercase tracking-[0.18em] text-white/70",children:[(0,U.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,U.jsx)(p.A,{className:"h-3.5 w-3.5 animate-spin text-orange-300"}),"Saving your reference\u2026"]}),(0,U.jsx)("span",{className:"text-white/40",children:"Just a moment"})]}),(0,U.jsx)("div",{className:"relative h-1.5 w-full overflow-hidden rounded-full bg-white/10",children:(0,U.jsx)("div",{className:"absolute inset-y-0 left-0 w-1/3 rounded-full bg-gradient-to-r from-orange-500 via-rose-500 to-fuchsia-500 shadow-[0_0_14px_rgba(244,63,94,0.55)] ai-editor-progress-indeterminate"})})]}),(0,U.jsx)("div",{className:"flex justify-end",children:(0,U.jsx)("button",{type:"button",onClick:async()=>{if(_){b(!0);try{await Promise.resolve(null===u||void 0===u?void 0:u())}finally{b(!1)}}},disabled:!_,className:"btn-flame inline-flex items-center gap-2 rounded-full px-6 py-3 text-sm font-semibold text-white disabled:opacity-50","data-testid":"ai-editor-custom-continue",children:x?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(p.A,{className:"h-4 w-4 animate-spin"}),"Saving\u2026"]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(l.A,{className:"h-4 w-4"}),"Save and Continue",(0,U.jsx)(g.A,{className:"h-4 w-4"})]})})})]})]})}function ie(e){let{variation:t,onPick:a}=e;const i=(null===t||void 0===t?void 0:t.image)||null,r=(null===t||void 0===t?void 0:t.aspect_ratio)||"1:1",s=Array.isArray(null===t||void 0===t?void 0:t.colors)?t.colors.filter(Boolean).slice(0,5):[];return(0,U.jsxs)("div",{className:"mx-auto grid w-full max-w-[1000px] grid-cols-1 gap-5 sm:grid-cols-2","data-testid":"ai-editor-quick-step",children:[(0,U.jsxs)("button",{type:"button",onClick:()=>null===a||void 0===a?void 0:a("quick"),className:"group relative flex flex-col overflow-hidden rounded-2xl border border-white/12 bg-white/[0.03] text-left transition hover:-translate-y-0.5 hover:border-orange-400/45 hover:bg-orange-500/[0.04]","data-testid":"ai-editor-quick-pick",children:[(0,U.jsxs)("div",{className:"relative w-full aspect-square overflow-hidden bg-black/40",children:[i?(0,U.jsx)("img",{src:i,alt:"".concat((null===t||void 0===t?void 0:t.name)||"Variation"," preview"),className:"block h-full w-full object-contain transition-transform duration-500 group-hover:scale-[1.03]",draggable:"false"}):(0,U.jsx)("div",{className:"flex h-full w-full items-center justify-center text-white/45",children:(0,U.jsx)(y.A,{className:"h-10 w-10"})}),(0,U.jsxs)("span",{className:"absolute right-3 top-3 z-30 inline-flex items-center gap-1 rounded-full border border-white/15 bg-black/60 px-2.5 py-1 text-[10px] font-semibold uppercase tracking-[0.18em] text-white/80 backdrop-blur-sm",children:[(0,U.jsx)(j.A,{className:"h-3 w-3"}),r]}),(0,U.jsx)("div",{className:"pointer-events-none absolute inset-0 z-10 bg-black/85 opacity-0 transition-opacity duration-500 group-hover:opacity-100","aria-hidden":"true"}),(0,U.jsx)("div",{className:"pointer-events-none absolute inset-0 z-20 flex items-center justify-center opacity-0 transition-opacity duration-500 group-hover:opacity-100","aria-hidden":"true",children:(0,U.jsxs)("span",{className:"inline-flex items-center gap-2 rounded-full bg-gradient-to-r from-orange-500 via-rose-500 to-fuchsia-600 px-5 py-3 text-xs font-bold uppercase tracking-[0.18em] text-white shadow-[0_10px_30px_-10px_rgba(244,63,94,0.7)] ring-1 ring-white/15 sm:text-sm","data-testid":"ai-editor-quick-pick-cta",children:[(0,U.jsx)(l.A,{className:"h-4 w-4"}),"Create design"]})})]}),(0,U.jsxs)("div",{className:"flex flex-col items-center gap-2 px-5 py-4 text-center",children:[(0,U.jsx)("div",{className:"text-lg font-bold uppercase tracking-wide text-white",children:"Qu
2ick Design - Use Existing Style"}),s.length>0&&(0,U.jsx)("div",{className:"mt-1 flex items-center justify-center gap-1.5",children:s.map(e=>(0,U.jsx)("span",{className:"h-4 w-4 rounded-full border border-white/15",style:{background:e},title:e},e))})]})]}),(0,U.jsxs)("button",{type:"button",onClick:()=>null===a||void 0===a?void 0:a("custom"),className:"group relative flex flex-col overflow-hidden rounded-2xl border border-white/12 bg-white/[0.03] text-left transition hover:-translate-y-0.5 hover:border-orange-400/45 hover:bg-orange-500/[0.04]","data-testid":"ai-editor-quick-customize",children:[(0,U.jsxs)("div",{className:"relative w-full aspect-square overflow-hidden bg-gradient-to-br from-zinc-950 via-zinc-900 to-zinc-950",children:[(0,U.jsx)("div",{className:"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_50%_50%,rgba(251,146,60,0.22),transparent_60%)]"}),(0,U.jsx)("div",{className:"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_50%_50%,rgba(244,63,94,0.12),transparent_70%)]"}),(0,U.jsx)("div",{className:"absolute inset-0 flex items-center justify-center",children:(0,U.jsxs)("div",{className:"relative flex h-48 w-48 items-center justify-center",children:[(0,U.jsx)("span",{className:"absolute inset-0 rounded-full border-2 border-orange-400/45 customize-ping",style:{animationDelay:"0s"},"aria-hidden":"true"}),(0,U.jsx)("span",{className:"absolute inset-3 rounded-full border-2 border-rose-400/45 customize-ping",style:{animationDelay:"1.2s"},"aria-hidden":"true"}),(0,U.jsx)("span",{className:"absolute inset-6 rounded-full border-2 border-amber-300/45 customize-ping",style:{animationDelay:"2.4s"},"aria-hidden":"true"}),(0,U.jsx)("span",{className:"absolute inset-8 rounded-full bg-gradient-to-br from-orange-500/30 via-rose-500/20 to-fuchsia-500/20 blur-xl","aria-hidden":"true"}),(0,U.jsx)("span",{className:"relative z-[2] flex h-28 w-28 items-center justify-center rounded-full border border-orange-300/50 bg-gradient-to-br from-amber-400 via-orange-500 to-rose-600 shadow-[0_30px_70px_-15px_rgba(251,146,60,0.85)] transition-transform duration-500 group-hover:scale-[1.06]","aria-hidden":"true",children:(0,U.jsx)(N.A,{className:"h-14 w-14 text-white drop-shadow"})})]})}),(0,U.jsx)("div",{className:"pointer-events-none absolute inset-0 z-10 bg-black/85 opacity-0 transition-opacity duration-500 group-hover:opacity-100","aria-hidden":"true"}),(0,U.jsx)("div",{className:"pointer-events-none absolute inset-0 z-20 flex items-center justify-center opacity-0 transition-opacity duration-500 group-hover:opacity-100","aria-hidden":"true",children:(0,U.jsxs)("span",{className:"inline-flex items-center gap-2 rounded-full bg-gradient-to-r from-orange-500 via-rose-500 to-fuchsia-600 px-5 py-3 text-xs font-bold uppercase tracking-[0.18em] text-white shadow-[0_10px_30px_-10px_rgba(244,63,94,0.7)] ring-1 ring-white/15 sm:text-sm","data-testid":"ai-editor-quick-customize-cta",children:[(0,U.jsx)(l.A,{className:"h-4 w-4"}),"Customize"]})})]}),(0,U.jsx)("div",{className:"flex flex-col items-center gap-2 px-5 py-4 text-center",children:(0,U.jsx)("div",{className:"text-lg font-bold uppercase tracking-wide text-white",children:"Customize your way"})})]})]})}function re(e){let{selected:t,onSelect:a}=e;return(0,U.jsxs)("div",{className:"space-y-6",children:[(0,U.jsx)("div",{className:"mx-auto grid max-w-3xl grid-cols-2 gap-4",children:E.aA.map(e=>(0,U.jsx)(se,{format:e,active:t===e.id,onClick:()=>a(e.id)},e.id))}),(0,U.jsx)("div",{className:"grid grid-cols-2 gap-4 sm:grid-cols-3 lg:grid-cols-5",children:E.Iw.map(e=>(0,U.jsx)(se,{format:e,active:t===e.id,onClick:()=>a(e.id)},e.id))})]})}function se(e){let{format:t,active:a,onClick:i}=e;const r=64,s=t.w/t.h,n=s>=1?r:Math.round(r*s),o=s>=1?Math.round(r/s):r;return(0,U.jsxs)("button",{type:"button",onClick:i,className:"group relative flex flex-col items-center gap-2 rounded-xl border bg-white/[0.03] px-3 py-3 text-center transition ".concat(a?"border-orange-400/70 bg-orange-500/[0.08] shadow-[0_0_18px_-6px_rgba(251,146,60,0.65)]":"border-white/10 hover:-translate-y-0.5 hover:border-white/25 hover:bg-white/[0.06]"),"data-testid":"ai-editor-format-".concat(t.id),"aria-pressed":a,children:[(0,U.jsx)("div",{className:"flex shrink-0 items-center justify-center",style:{height:"".concat(r,"px"),width:"".concat(r,"px")},children:(0,U.jsx)("div",{className:"rounded-md border-2 border-dashed transition ".concat(a?"border-orange-300/80 bg-orange-500/[0.08]":"border-white/35 group-hover:border-white/55"),style:{width:"".concat(n,"px"),height:"".concat(o,"px")}})}),(0,U.jsxs)("div",{className:"flex flex-col items-center gap-0.5",children:[(0,U.jsx)("div",{className:"text-[40px] font-bold leading-none tracking-tight ".concat(a?"text-orange-100":"text-white"),children:t.ratio}),(0,U.jsxs)("div",{className:"text-xs font-medium text-white/55",children:[t.w,"\xd7",t.h]}),t.use&&(0,U.jsx)("div",{className:"mt-0.5 text-[10px] leading-snug text-white/40",children:t.use})]}),a&&(0,U.jsx)("span",{className:"absolute right-2 top-2 inline-flex h-5 w-5 items-center justify-center rounded-full bg-emerald-500 text-white shadow-lg",children:(0,U.jsx)(v.A,{className:"h-3 w-3"})})]})}function ne(e){let{api:t,navigate:a,selected:i,onSelect:o}=e;const{user:d}=(0,C.Ay)(),{kits:c}=(0,S.Ay)(d),[u,h]=(0,r.useState)([]),[m,x]=(0,r.useState)(!0);(0,r.useEffect)(()=>{let e=!1;return(async()=>{try{const{data:a}=await s.A.get("".concat(t,"/ai-editor-styles"));e||h(a.styles||[])}catch(a){}finally{e||x(!1)}})(),()=>{e=!0}},[t]);const b=u,[v,y]=(0,r.useState)(null),[j,N]=(0,r.useState)(null),[A,_]=(0,r.useState)(null),[R,T]=(0,r.useState)(!1),E=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{j&&URL.revokeObjectURL(j)},[j]);const D=".pdf,.ppt,.pptx,image/jpeg,image/png,image/webp,image/gif",P=e=>{if(!e)return;const t=(e.name||"").toLowerCase(),a=/\.(pdf|ppt|pptx|jpg|jpeg|png|webp|gif)$/i.test(t),i=["application/pdf","application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation","image/jpeg","image/png","image/webp","image/gif"].includes(e.type);if(a||i)if(j&&URL.revokeObjectURL(j),y(e),N(e.type.startsWith("image/")?URL.createObjectURL(e):null),e.type.startsWith("image/")){const t=new FileReader;t.onload=()=>{const e=t.result;_(e&&e.split(",")[1]||null)}
2,t.readAsDataURL(e)}else _(null);else n.oR.error("Unsupported file",{description:"Use a PDF, PowerPoint, JPEG, PNG or web picture."})},M=e=>{var t;const a=null===(t=e.target.files)||void 0===t?void 0:t[0];P(a),E.current&&(E.current.value="")};return(0,U.jsxs)("div",{className:"space-y-6",children:[v&&(0,U.jsxs)("section",{"data-testid":"ai-editor-style-upload",children:[(0,U.jsxs)("div",{className:"flex flex-col gap-3 rounded-2xl border border-white/15 bg-white/[0.03] p-4 sm:flex-row sm:items-center","data-testid":"ai-editor-style-upload-preview",children:[(0,U.jsx)("div",{className:"flex h-32 w-full shrink-0 items-center justify-center overflow-hidden rounded-xl border border-white/10 bg-black/40 sm:h-24 sm:w-32",children:j?(0,U.jsx)("img",{src:j,alt:"".concat(v.name," preview"),className:"block h-full w-full object-contain",draggable:"false"}):(0,U.jsxs)("div",{className:"flex flex-col items-center gap-1 text-white/55",children:[(0,U.jsx)(k.A,{className:"h-6 w-6"}),(0,U.jsx)("span",{className:"text-[10px] uppercase tracking-[0.22em]",children:(v.name.split(".").pop()||"file").toUpperCase()})]})}),(0,U.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,U.jsx)("div",{className:"truncate text-sm font-semibold text-white",title:v.name,children:v.name}),(0,U.jsxs)("div",{className:"mt-0.5 text-[11px] text-white/45",children:[v.type||"Reference file"," \xb7 ",(O=v.size,O||0===O?O<1024?"".concat(O," B"):O<1048576?"".concat((O/1024).toFixed(1)," KB"):"".concat((O/1048576).toFixed(1)," MB"):"")]}),(0,U.jsxs)("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[(0,U.jsx)("button",{type:"button",onClick:()=>{var e;return null===(e=E.current)||void 0===e?void 0:e.click()},className:"inline-flex h-8 items-center rounded-full border border-white/15 px-3 text-[11px] font-semibold uppercase tracking-[0.18em] text-white/75 transition hover:border-white/30 hover:text-white","data-testid":"ai-editor-style-upload-replace",children:"Replace"}),(0,U.jsxs)("button",{type:"button",onClick:()=>{j&&URL.revokeObjectURL(j),y(null),N(null),E.current&&(E.current.value="")},className:"inline-flex h-8 items-center gap-1.5 rounded-full border border-rose-400/40 bg-transparent px-3 text-[11px] font-semibold uppercase tracking-[0.18em] text-rose-200 transition hover:border-rose-400/70 hover:bg-rose-500/15","data-testid":"ai-editor-style-upload-remove",children:[(0,U.jsx)(f.A,{className:"h-3 w-3"}),"Remove"]})]})]}),(0,U.jsx)("input",{ref:E,type:"file",className:"hidden",accept:D,onChange:M})]}),(0,U.jsx)("div",{className:"mt-4 flex justify-center",children:(0,U.jsxs)("button",{type:"button",onClick:()=>o("custom-upload",{id:"custom-upload",name:"Uploaded Reference",colors:[],source:"upload",image_base64_list:A?[A]:[]}),className:"btn-flame inline-flex items-center gap-2 rounded-full px-6 py-3 text-sm font-semibold text-white","data-testid":"ai-editor-style-continue",children:[(0,U.jsx)(l.A,{className:"h-4 w-4"}),"Continue with uploaded reference",(0,U.jsx)(g.A,{className:"h-4 w-4"})]})})]}),(0,U.jsx)("section",{"data-testid":"ai-editor-style-unified-grid",children:m?(0,U.jsxs)("div",{className:"flex items-center gap-3 text-sm text-white/55",children:[(0,U.jsx)(p.A,{className:"h-4 w-4 animate-spin text-orange-300"}),"Loading styles\u2026"]}):(0,U.jsxs)("div",{className:"grid grid-cols-1 gap-5 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:[!v&&(0,U.jsxs)("label",{onDrop:e=>{var t,a;e.preventDefault(),e.stopPropagation(),T(!1),P(null===(t=e.dataTransfer)||void 0===t||null===(a=t.files)||void 0===a?void 0:a[0])},onDragOver:e=>{e.preventDefault(),e.stopPropagation(),T(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),T(!1)},className:"group relative flex cursor-pointer flex-col overflow-hidden rounded-2xl border-2 border-dashed text-left transition ".concat(R?"border-orange-400/70 bg-orange-500/[0.06]":"border-white/15 bg-white/[0.02] hover:border-orange-400/40 hover:bg-orange-500/[0.04]"),"data-testid":"ai-editor-style-upload-zone",children:[(0,U.jsxs)("div",{className:"relative flex aspect-video w-full flex-col items-center justify-center gap-2 bg-black/20 text-center",children:[(0,U.jsx)(w.A,{className:"h-9 w-9 text-white/55 transition group-hover:text-orange-300"}),(0,U.jsx)("div",{className:"px-4 text-sm font-semibold text-white",children:R?"Release to upload":"Drop a file as Style reference"}),(0,U.jsx)("div",{className:"px-6 text-[11px] leading-relaxed text-white/45",children:"PDF, PowerPoint, JPG, PNG or WebP"})]}),(0,U.jsx)("div",{className:"px-4 py-3.5",children:(0,U.jsx)("div",{className:"text-base font-semibold text-white",children:"Copy a style"})}),(0,U.jsx)("input",{ref:E,type:"file",className:"hidden",accept:D,onChange:M,"data-testid":"ai-editor-style-upload-input"})]}),d&&c.map(e=>{var t;const a=e.thumbnail||(null===(t=e.screenshots)||void 0===t?void 0:t[0])||"",r="kit:".concat(e.id),s=(e.palette||[]).filter(e=>"string"===typeof e&&e.trim());return(0,U.jsx)(oe,{id:r,name:e.name,thumbnail:a||null,active:i===r,onClick:()=>{const t=a.startsWith("data:")?a.split(",")[1]||"":a;o(r,{id:r,name:e.name,thumbnail:a||null,preview_image_base64:t||null,colors:s,source:"user-kit",image_base64_list:[],font:e.font||"",style_description:e.styleDescription||""})},badge:"Kit"},r)}),b.map(e=>{const t=e.image_base64||"",a=t?t.startsWith("data:")?t:"data:image/png;base64,".concat(t):null,r=(e.colors||[]).filter(e=>"string"===typeof e&&e.trim());return(0,U.jsx)(oe,{id:e.id,name:e.name,thumbnail:a,active:i===e.id,onClick:()=>o(e.id,{id:e.id,name:e.name,thumbnail:a,preview_image_base64:t&&!t.startsWith("data:")?t:null,colors:r,source:"ai-editor-styles",image_base64_list:(()=>{const e=t.startsWith("data:")?t.split(",")[1]||"":t;return e?[e]:[]})()})},e.id)})]})})]});var O}function oe(e){let{id:t,name:a,thumbnail:i,active:r,onClick:s,badge:n,fallbackGradient:o}=e;return(0,U.jsxs)("button",{type:"button",onClick:s,className:"group relative flex flex-col overflow-hidden rounded-2xl border bg-white/[0.03] text-left transition ".concat(r?"border-orange-400/70 bg-orange-500/[0.06] shadow-[0_0_22px_-6px_rgba(251,146,60,0.65)]":"border-white/10 hover:border-white/25 hover:bg-white/[0.06]"),"data-testid":"ai-editor-style-".concat(t),"aria-pressed":r,children:[(0,U.jsxs)("div",{className:"relative aspect-video w-full overflow-hidden bg-black/40",children:[i?(0,U.jsx)("img",{src:i,alt:"".concat(a," preview"),className:"block h-full w-full object-cover transition-transform duration-500 group-hover:scale-[1.03]",draggable:"false",loading:"lazy"}):(0,U.jsx)("div",{className:"h-full w-full",style:o?{background:o}:void 0}),n&&(0,U.jsx)("span",{className:"absolute left-2 top-2 rounded-full border border-white/15 bg-black/60 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-[0.18em] text-white/75 backdrop-blur-sm",children:n}),r&&(0,U.jsx)("span",{className:"absolute right-2 top-2 inline-flex h-6 w-6 items-center justify-center rounded-full bg-emerald-500 text-white shadow-lg",children:(0,U.jsx)(v.A,{className:"h-3.5 w-3.5"})})]}),(0,U.jsx)("div",{className:"px-4 py-3.5",children:(0,U.jsx)("div",{className:"text-base font-semibold ".concat(r?"text-orange-100":"text-white"),children:a})})]})}const le=function(e){let{api:t,onBack:a,navigate:d,categorySlug:b,industrySlug:v,onGenerated:w,authUser:y}=e;const{user:j,hasCredits:N,consumeCredits:k,updateUser:A}=(0,C.Ay)(),[_,S]=(0,r.useState)("idle"),[R,D]=(0,r.useState)(null),[P,M]=(0,r.useState)(null),[O,I]=(0,r.useState)(null),[L,F]=(0,r.useState)(0),B=(0,r.useRef)(!1),[G,q]=(0,r.useState)(!1),W=async e=>{var a,i,r,o,l,c,u;
2let{text:h,file:m,images:g=[],logo:p=null,slideCount:x,quality:f,thinking:b,font:v,webMode:y,noTextOnDesign:C=!1,overrideContext:R=null,aggregateOnly:T=!1}=e;if(!T&&"idle"!==_)return;if(!j){if(T)throw new Error("Sign in required to run Bulk Designer");return n.oR.message("Create a free account",{description:"Sign up to generate AI Editor designs (5 credits each)."}),void(null===d||void 0===d||d("register"))}const P=Number.isFinite(x)&&x>0?x:1,O=5*P;if(!N(O)){if(T)throw new Error("Not enough credits \u2014 this card needs ".concat(O," credits."));return void n.oR.error("Not enough credits",{description:"This run needs ".concat(O," credits (").concat(5," per design \xd7 ").concat(P,").")})}const L=null!==(a=null===R||void 0===R?void 0:R.variation)&&void 0!==a?a:V,U=null!==(i=null===R||void 0===R?void 0:R.format)&&void 0!==i?i:K,z=null!==(r=null===R||void 0===R?void 0:R.style)&&void 0!==r?r:se,G=null!==(o=null===R||void 0===R?void 0:R.styleDetails)&&void 0!==o?o:le,q=null!==(l=null===R||void 0===R?void 0:R.reviewColors)&&void 0!==l?l:ce,W=null!==(c=null===R||void 0===R?void 0:R.customName)&&void 0!==c?c:Fe,Y=null!==(u=null===R||void 0===R?void 0:R.customRef)&&void 0!==u?u:Ge,H=Number.isFinite(x)&&x>0?x:1;B.current=!1,T||(S("extracting"),D(null),M(null),I(null),F(H));let X=!1;try{var J,$;let e="";if(m){const a=new FormData;a.append("file",m);const{data:i}=await s.A.post("".concat(t,"/extract-file"),a,{headers:{"Content-Type":"multipart/form-data"},timeout:6e4});e=i.text||""}if(B.current)return;let a=e?"".concat(h||"","\n\n----\n\nHERE COMES THE CONTENT FROM THE DOCUMENT (paraphrased / transcribed):\n\n").concat(e):h||"";if(!a.trim()&&(null===R||void 0===R||null===(J=R.bulkPerSlide)||void 0===J||!J.length)){if(T)throw new Error("Card has no content to render.");return n.oR.error("Please enter some content or upload a file."),void S("idle")}if(y){try{S("researching");const{data:e}=await s.A.post("".concat(t,"/web-research"),{content:a.slice(0,4e3),language:"English"},{timeout:35e3});null!==e&&void 0!==e&&e.brief&&(a="WEB RESEARCH BRIEF (use these facts as the primary source \u2014 they are fresher than your training data):\n"+e.brief+"\n\nUSER-PROVIDED CONTENT:\n"+a)}catch(re){console.warn("Web research failed, continuing without:",re)}if(B.current)return}let i=null;if((null===R||void 0===R||!R.bulkPerSlide)&&H>1&&(a||g.length)){try{S("splitting");const{data:e}=await s.A.post("".concat(t,"/ai-editor/outline"),{content:a,slide_count:H,language:"English",user_image_attachments:Array.isArray(g)?g:[]},{timeout:6e4});i=Array.isArray(null===e||void 0===e?void 0:e.designs)?e.designs:null}catch(ne){console.warn("AI Editor outline split failed, using full content per design:",ne),i=null,n.oR.warning("Content split skipped",{description:"Could not split your content into separate designs \u2014 every design will use the full content. Try again in a moment."})}if(B.current)return}const r=null!==L&&void 0!==L&&L.isCustom?W||"Custom Structure":(null===L||void 0===L?void 0:L.name)||"",o=[...E.Iw,...E.aA].find(e=>e.id===U),l=[r?"Structure: ".concat(r,"."):"",U?"Format: ".concat(U,"."):"",v?"Font: ".concat(v,"."):"",q.length>0?"Colors: ".concat(q.join(", "),"."):""].filter(Boolean).join(" ");"undefined"!==typeof window&&window.scrollTo({top:0,left:0,behavior:"auto"}),S("rendering");let d=null;if(null!==L&&void 0!==L&&L.isCustom)d=Y||null;else if(null!==L&&void 0!==L&&L.refImage)d=L.refImage;else if(null!==L&&void 0!==L&&L.image)if(L.image.startsWith("data:"))d=L.image.split(",")[1]||null;else try{const e=await fetch(L.image),t=await e.blob();d=await new Promise(e=>{const a=new FileReader;a.onload=()=>e((a.result||"").split(",")[1]||null),a.onerror=()=>e(null),a.readAsDataURL(t)})}catch(oe){console.warn("Failed to fetch variation image as base64:",oe)}const c=new Array(H);if(null!==R&&void 0!==R&&R.bulkPerSlide);else if(d){const e=[...E.Iw,...E.aA].find(e=>e.id===U),r=(null===e||void 0===e?void 0:e.ratio)||U||"16:9",n=[];for(let o=0;o<H;o++){var Z;const e=(null===(Z=i)||void 0===Z?void 0:Z[o])||null;let l=((null===e||void 0===e?void 0:e.body)||a||"").slice(0,2e3);
2const u=l.split(/\s+/).filter(Boolean);u.length>65&&(l=u.slice(0,65).join(" ").replace(/[,;:\-\s]+$/,"")),l.trim()?n.push(s.A.post("".concat(t,"/ai-editor/adapt-content"),{content:l,structure_image_base64:d,language:"English",aspect_ratio:r},{timeout:45e3}).then(e=>{var t;const a=((null===e||void 0===e||null===(t=e.data)||void 0===t?void 0:t.adapted_content)||"").trim();c[o]=a||l}).catch(e=>{console.warn("adapt-content failed for design ".concat(o,":"),null===e||void 0===e?void 0:e.message),c[o]=l})):(c[o]=l,n.push(Promise.resolve(null)))}try{await Promise.all(n)}catch(de){console.warn("adapt-content batch failed:",null===de||void 0===de?void 0:de.message)}if(B.current)return}else for(let t=0;t<H;t++){var Q;const e=(null===(Q=i)||void 0===Q?void 0:Q[t])||null;let r=((null===e||void 0===e?void 0:e.body)||a||"").slice(0,2e3);const s=r.split(/\s+/).filter(Boolean);s.length>65&&(r=s.slice(0,65).join(" ").replace(/[,;:\-\s]+$/,"")),c[t]=r}const u=[],x=v||(null===G||void 0===G?void 0:G.font)||"default",b=(q||[]).filter(Boolean).slice(0,5).join(" ")||"(use the style reference's palette)",j=(null===o||void 0===o?void 0:o.ratio)||U||"16:9",N="user-kit"===(null===G||void 0===G?void 0:G.source),A=(q||[]).filter(e=>"string"===typeof e&&e.trim()).slice(0,8),_=(v||(null===G||void 0===G?void 0:G.font)||"").toString().trim(),P=((null===G||void 0===G?void 0:G.style_description)||"").toString().trim(),F=(null===R||void 0===R?void 0:R.bulkPerSlide)||null;for(let t=0;t<H;t++){var ee;const e=(null===(ee=i)||void 0===ee?void 0:ee[t])||null,a=(null===F||void 0===F?void 0:F[t])||null,s=(null===a||void 0===a?void 0:a.title)||(null===e||void 0===e?void 0:e.title)||r||"Infographic",n=null!==a&&void 0!==a&&a.body?a.body:c[t]||"",o=null!==a&&void 0!==a&&a.image_attachments?a.image_attachments:Array.isArray(null===e||void 0===e?void 0:e.image_attachments)?e.image_attachments:[],l=C?["The size ratio: ".concat(j),"Colours: ".concat(b),"Keep the style of the reference image exactly the same.","Do not put any text written on the slide. Only make use of the colors that are listed above if mentioned in the user prompt below. If nothing is mentioned regarding colors, ignore the colors above and just take the reference image as it is. User Prompt (Changes to the image): ".concat(n),"",'REFERENCE CHROME REMOVAL \u2014 MANDATORY: Any text on the reference image that refers to the layout directly (for example: "STRUCTURE REFERENCE LAYOUT", "Reference Layout", "Structure Reference", "Layout Reference") MUST be removed from the final slide. Do NOT carry these labels, watermarks, captions, or headers over to the generated output.',"",'PROMPT / PLACEHOLDER TEXT REMOVAL \u2014 MANDATORY: Any text on the reference image that reads like a prompt or design brief (for example: "Create this", "Design this", "Build this", "Make this design", "Generate this") OR any text that reads like a placeholder describing what should be on the design rather than actual content (for example: "Marketing demo screen", "Headline for marketing post", "Hero headline goes here", "Subtitle placeholder", "Sample tagline", "Insert headline here", "CTA button text") MUST NOT appear anywhere in the final design. These are reference-image artifacts, not real content. Replace them with the actual user content above, or remove them entirely if the user content does not cover that region.']:N?["The first image that I have uploaded is only for the structure (Structure Reference Layout).","","The size ratio: ".concat(j),"","The content that you need to put in there. THIS IS THE ACTUAL CONTENT OF THE FINAL DESIGN \u2014 every heading, sentence, bullet, label and number visible in the output MUST come from the text below (or be a faithful, concise restatement of it in the same language). Do NOT carry any words from the reference image into the output; the reference image's text is placeholder copy from a different design.",n,"","TEXT DENSITY \u2014 MANDATORY: The content above is already capped at 65 words. The final design MUST stay at or below this 65-word ceiling \u2014 never exceed it, never pad it out with invented text, and never copy filler words from the reference image to make the layout look busier. A clean, breathable, easy-to-scan composition beats a stuffed one \u2014 prioritise readability over filling every region of the canvas.","","CONTENT REPLACEMENT \u2014 MANDATORY: every visible text element on the output design (headline, subheadings, body, bullets, labels, captions) MUST be drawn from the content above. The structure reference image is ONLY a layout template; ALL of its words are placeholder copy from a different design and MUST be replaced. If the content above is short, reflow / condense it to fill the layout naturally \u2014 never copy the reference's text to fill space.","",'REFERENCE CHROME REMOVAL \u2014 MANDATORY: Any text on the reference image that refers to the layout directly (for example: "STRUCTURE REFERENCE LAYOUT", "Reference Layout", "Structure Reference", "Layout Reference") MUST be removed from the final slide. Do NOT carry these labels, watermarks, captions, or headers over to the generated output.',"",'PROMPT / PLACEHOLDER TEXT REMOVAL \u2014 MANDATORY: Any text on the reference image that reads like a prompt or design brief (for example: "Create this", "Design this", "Build this", "Make this design", "Generate this") OR any text that reads like a placeholder describing what should be on the design rather than actual content (for example: "Marketing demo screen", "Headline for marketing post", "Hero headline goes here", "Subtitle placeholder", "Sample tagline", "Insert headline here", "CTA button text") MUST NOT appear anywhere in the final design. These are reference-image artifacts, not real content. Replace them with the actual user content above, or remove them entirely if the user content does not cover that region.',"","REFERENCE BRANDING REMOVAL \u2014 MANDATORY: The structure reference image is ONLY a layout template. Any branding from that reference \u2014 including company logos, brand marks, brand names, product names, website URLs, social-media handles, slogans, taglines, signatures, watermarks, or any other identifiers belonging to a different brand \u2014 MUST be removed from the final design. Do NOT carry them over. The ONLY brand-specific elements allowed in the output are: (a) brand names, product names, or URLs that the user explicitly wrote in the content above, AND/OR (b) a logo image attached separately via the EXTRA \u2014 BRAND LOGO instruction (if present). If neither applies, the design must be unbranded \u2014 no logos, no company names, no URLs."]:["The first image that I have uploaded is only for the structure (Structure Reference Layout).","","The second image uploaded is only for the style. Don't see this as an absolute design. It's just about the shapes, the colors, and the overall style. Keep in mind that we want the structure from the reference layout to be correct. Always make sure the text is readable.","","The font: ".concat(x),"The colors used: ".concat(b),"The size ratio: ".concat(j),"","The third is the content that you need to put in there. THIS IS THE ACTUAL CONTENT OF THE FINAL DESIGN \u2014 every heading, sentence, bullet, label and number visible in the output MUST come from the text below (or be a faithful, concise restatement of it in the same language). Do NOT carry any words from the reference image into the output; the reference image's text is placeholder copy from a different design.",n,"","TEXT DENSITY \u2014 MANDATORY: The content above is already capped at 65 words. The final design MUST stay at or below this 65-word ceiling \u2014 never exceed it, never pad it out with invented text, and never copy filler words from the reference image to make the layout look busier. A clean, breathable, easy-to-scan composition beats a stuffed one \u2014 prioritise readability over filling every region of the canvas.","","CONTENT REPLACEMENT \u2014 MANDATORY: every visible text element on the output design (headline, subheadings, body, bullets, labels, captions) MUST be drawn from the content above. The structure reference image is ONLY a layout template; ALL of its words are placeholder copy from a different design and MUST be replaced. If the content above is short, reflow / condense it to fill the layout naturally \u2014 never copy the reference's text to fill space.","",'REFERENCE CHROME REMOVAL \u2014 MANDATORY: Any text on the reference image that refers to the layout directly (for example: "STRUCTURE REFERENCE LAYOUT", "Reference Layout", "Structure Reference", "Layout Reference") MUST be removed from the final slide. Do NOT carry these labels, watermarks, captions, or headers over to the generated output.',"",'PROMPT / PLACEHOLDER TEXT REMOVAL \u2014 MANDATORY: Any text on the reference image that reads like a prompt or design brief (for example: "Create this", "Design this", "Build this", "Make this design", "Generate this") OR any text that reads like a placeholder describing what should be on the design rather than actual content (for example: "Marketing demo screen", "Headline for marketing post", "Hero headline goes here", "Subtitle placeholder", "Sample tagline", "Insert headline here", "CTA button text") MUST NOT appear anywhere in the final design. These are reference-image artifacts, not real content. Replace them with the actual user content above, or remove them entirely if the user content does not cover that region.',"","REFERENCE BRANDING REMOVAL \u2014 MANDATORY: The structure reference image is ONLY a layout template. Any branding from that reference \u2014 including company logos, brand marks, brand names, product names, website URLs, social-media handles, slogans, taglines, signatures, watermarks, or any other identifiers belonging to a different brand \u2014 MUST be removed from the final design. Do NOT carry them over. The ONLY brand-specific elements allowed in the output are: (a) brand names, product names, or URLs that the user explicitly wrote in the content above, AND/OR (b) a logo image attached separately via the EXTRA \u2014 BRAND LOGO instruction (if present). If neither applies, the design must be unbranded \u2014 no logos, no company names, no URLs."];if(N&&!C){const e=[];A.length>0&&e.push("BRAND COLORS \u2014 MANDATORY: Use ONLY the following brand colors for every visual element (backgrounds, accents, typography, shapes, icons): ".concat(A.join(", "),". Do not introduce other hues. The first color is the dominant brand color.")),_&&e.push('BRAND FONT \u2014 MANDATORY: Render all typography (headlines, body, labels, captions) in the font "'.concat(_,'" or the closest visual match available. Keep the typography consistent with this brand font across the whole design.')),P&&e.push("BRAND STYLE CHARACTERISTICS: ".concat(P)),e.length>0&&l.push("",...e)}if(o.length>0&&!C){const e=o.length;l.push("","EXTRA \u2014 USER IMAGE".concat(e>1?"S":""," FOR THIS DESIGN: I have attached ").concat(e," ")+"picture".concat(e>1?"s":""," that should be used in THIS design. Place ")+"".concat(e>1?"them":"it"," where they naturally fit (hero, product, team, ")+"illustrative content). Preserve the subject faithfully. IMAGE QUALITY \u2014 MANDATORY: The rendered output of each attached picture MUST match the quality, sharpness and resolution of the originally uploaded file. Do NOT downscale, blur, soften, posterise, re-illustrate, paint-over or otherwise degrade the user's pictures. Keep them photographically crisp and as high-fidelity as they came in.")}const d=l.join("\n");u.push({index:t,title:s,subtitle:H>1?"Part ".concat(t+1," of ").concat(H):"",body:n,bullets:[],image_prompt:d,slide_type:"content",attachments:o,structure_reference_image_base64:(null===a||void 0===a?void 0:a.structure_reference_image_base64)||null})}const V="4k"===f,K={"16:9":"3840x2160","9:16":"1440x2560","4:3":"1024x768","3:4":"768x1024","1:1":"1024x1024","2:3":"1024x1536","3:2":"1536x1024"}[U]||(V?"3840x2160":"2048x1152"),ae=(null===G||void 0===G?void 0:G.image_base64_list)||[],ie=[],se=[];if(ae.length>
20&&ie.push("STYLE vs STRUCTURE \u2014 MANDATORY: The structure, like shapes and elements, should be taken from the structural reference image, but the design itself should be what was uploaded in addition to that."),e&&ie.push("EXTRA \u2014 DOCUMENT INPUT: A document has been uploaded. Extract the most relevant information from it and use it as the source content for this design."),!i&&Array.isArray(g)&&g.length>0){const e=g.length;ie.push("EXTRA \u2014 USER IMAGE".concat(e>1?"S":"",": I have attached ").concat(e," ")+"picture".concat(e>1?"s":"",". Use ").concat(e>1?"them":"it"," in ")+"the design where they naturally fit (hero shot, product, team, illustrative content). Preserve the subject as closely to the original as possible. IMAGE QUALITY \u2014 MANDATORY: The rendered output of each attached picture MUST match the quality, sharpness and resolution of the originally uploaded file. Do NOT downscale, blur, soften, posterise, re-illustrate, paint-over or otherwise degrade the user's pictures. Keep them photographically crisp and as high-fidelity as they came in.");for(const t of g)t&&"string"===typeof t&&se.push(t)}if(p&&"string"===typeof p&&(ie.push("EXTRA \u2014 BRAND LOGO: I have attached a logo. Use this logo for the design as branding (place it in a corner or wherever is most appropriate for the layout). Do NOT redesign or recolour the logo \u2014 keep it faithful to the original."),se.push(p)),ie.length>0){const e="\n\n"+ie.join("\n");for(const t of u)t.image_prompt=(t.image_prompt||"")+e}const le={slides:u,style_prompt:l,style_id:z&&!String(z).startsWith("kit:")&&"custom-upload"!==z?z:null,style_reference_description:(null===G||void 0===G?void 0:G.style_description)||null,style_reference_image_base64_list:(()=>{const e=[...ae];!d||null!==R&&void 0!==R&&R.bulkPerSlide||e.unshift(d);for(const t of se)e.push(t);return e.length?e:null})(),style_reference_categorized:((null===G||void 0===G?void 0:G.categorized_slides)||[]).map(e=>({title:e.title,image_base64:e.image_base64})),style_font:v||(null===G||void 0===G?void 0:G.font)||null,style_logo_light_base64:(null===G||void 0===G?void 0:G.logo_light_base64)||null,style_logo_dark_base64:(null===G||void 0===G?void 0:G.logo_dark_base64)||null,style_logo_position:(null===G||void 0===G?void 0:G.logo_position)||null,color_overrides:(q||[]).filter(Boolean).slice(0,5),language:"English",settings:{quality:V?"high":"low",size:K,output_format:"jpeg",flow:"ai_editor"},prompts:{image_prompt_template:"{image_prompt}"}},ce=null===($=(await s.A.post("".concat(t,"/render"),le)).data)||void 0===$?void 0:$.job_id;if(!ce)throw new Error("Render returned no job_id");I(ce),k(O),X=!0;const ue=Date.now()+48e4;let he=0;for(;Date.now()<ue;){if(B.current)return;await new Promise(e=>setTimeout(e,1200));try{var te;const{data:e}=await s.A.get("".concat(t,"/generate/").concat(ce),{timeout:15e3});if(he=0,M(e),D({slides_done:e.slides_done||(null===(te=e.slides)||void 0===te?void 0:te.length)||0,slides_total:e.slides_total||H}),"done"===e.status){const t=e.dropped_count||0;return T?{result:{id:e.id,slides:e.slides,pdf_base64:e.pdf_base64||""},styleSnap:{style_prompt:l,style_reference_description:(null===G||void 0===G?void 0:G.style_description)||null,style_reference_image_base64_list:ae,style_reference_categorized:((null===G||void 0===G?void 0:G.categorized_slides)||[]).map(e=>({title:e.title,image_base64:e.image_base64})),style_font:v||(null===G||void 0===G?void 0:G.font)||null,style_logo_light_base64:(null===G||void 0===G?void 0:G.logo_light_base64)||null,style_logo_dark_base64:(null===G||void 0===G?void 0:G.logo_dark_base64)||null,style_logo_position:(null===G||void 0===G?void 0:G.logo_position)||null,colors:(q||[]).filter(Boolean).slice(0,5),language:"English"},sourceSummary:a.slice(0,500),aiEditorSettings:{quality:V?"high":"low",size:K,output_format:"jpeg",flow:"ai_editor"},dropped:t}:(S("done"),t>0?n.oR.warning("Ready \xb7 ".concat(e.slides.length," image").concat(e.slides.length>1?"s":""),{description:"".concat(t," image").concat(t>1?"s":""," failed to render and ").concat(t>1?"were":"was"," skipped."),duration:8e3}):n.oR.success("Infographic ready",{description:"".concat(e.slides.length," image").concat(e.slides.length>
21?"s":""," generated")}),void(null===w||void 0===w||w({id:e.id,slides:e.slides,pdf_base64:e.pdf_base64||""},{style_prompt:l,style_reference_description:(null===G||void 0===G?void 0:G.style_description)||null,style_reference_image_base64_list:ae,style_reference_categorized:((null===G||void 0===G?void 0:G.categorized_slides)||[]).map(e=>({title:e.title,image_base64:e.image_base64})),style_font:v||(null===G||void 0===G?void 0:G.font)||null,style_logo_light_base64:(null===G||void 0===G?void 0:G.logo_light_base64)||null,style_logo_dark_base64:(null===G||void 0===G?void 0:G.logo_dark_base64)||null,style_logo_position:(null===G||void 0===G?void 0:G.logo_position)||null,colors:(q||[]).filter(Boolean).slice(0,5),language:"English"},a.slice(0,500),{quality:V?"high":"low",size:K,output_format:"jpeg",flow:"ai_editor"})))}if("error"===e.status)throw new Error(e.error||"Render failed")}catch(oe){if(he++,he>=8)throw oe}}throw new Error("Render timed out (8 min)")}catch(de){var ae,ie;if(B.current)return;const e=(null===(ae=de.response)||void 0===ae||null===(ie=ae.data)||void 0===ie?void 0:ie.detail)||de.message;if(X)try{const{data:e}=await s.A.post("".concat(t,"/credits/refund"),{amount:O},{withCredentials:!0});"number"===typeof(null===e||void 0===e?void 0:e.credits)&&(null===A||void 0===A||A({credits:e.credits}))}catch(ue){}if(T)throw de;n.oR.error("Generation failed",{description:"".concat(String(e).slice(0,180)).concat(X?" \xb7 5 credits refunded.":"")}),S("idle")}},[V,X]=(0,r.useState)(null),[J,$]=(0,r.useState)(null),[K,Z]=(0,r.useState)(null),[se,oe]=(0,r.useState)(null),[le,de]=(0,r.useState)(null),[ce,ue]=(0,r.useState)([]),[he,me]=(0,r.useState)(!1),[ge,pe]=(0,r.useState)(null),[xe,fe]=(0,r.useState)(null),[be,ve]=(0,r.useState)(null),[we,ye]=(0,r.useState)(null),[je,Ne]=(0,r.useState)({language:"English",webMode:!1,ultraMode:!1,noTextOnDesign:!1}),ke=()=>({id:"undefined"!==typeof crypto&&crypto.randomUUID?crypto.randomUUID():"".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2)),variation:null,content:"",images:[],logo:null,documents:[],font:"default"}),[Ae,_e]=(0,r.useState)(()=>[ke(),ke(),ke(),ke()]),[Ce,Se]=(0,r.useState)(null),[Re,Te]=(0,r.useState)({phase:"idle",progress:{done:0,total:0,failed:0},results:[]}),[Ee,De]=(0,r.useState)(""),Pe={"social-media-posts":"Social Media Posts",infographics:"Infographics",mockups:"Mockups",images:"Images"},Me=["Mockups","Images"],[Oe,Ie]=(0,r.useState)(()=>{const e=(b||"").toLowerCase();return Pe[e]||"All"}),Le=[{label:"All",Icon:o.A},{label:"My Designs",Icon:l.A,requiresAuth:!0,ownTint:!0},{label:"Favorites",Icon:c,requiresAuth:!0,ownTint:!0},{label:"Bulk Designer",Icon:u,requiresAuth:!0,ownTint:!0},{label:"Social Media Posts",Icon:h.A},{label:"Infographics",Icon:m.A},{label:"Mockups",Icon:o.A},{label:"Images",Icon:o.A}],Ue=e=>e&&"All"!==e?"My Designs"===e?"Personal":"Bulk Designer"===e?null:"Social Media Posts"===e?"Social Media Content":e:null,ze={"Social Media Posts":["social","media","marketing","content","branding","post","advertising","instagram","facebook","twitter","linkedin","promotion","campaign"],"Social Media Content":["social","media","marketing","content","branding","post","advertising","instagram","facebook","twitter","linkedin","promotion","campaign"],Infographic:["infographic","chart","graph","data","visualization","analysis","comparison","statistics","analytics","timeline","diagram","matrix","canvas","flowchart","mind map","process","workflow","swot","roadmap","hierarchy"],Infographics:["infographic","chart","graph","data","visualization","analysis","comparison","statistics","analytics","timeline","diagram","matrix","canvas","flowchart","mind map","process","workflow","swot","roadmap","hierarchy"],Mockups:["mockup","wireframe","prototype","ui","ux","screen","app","website","interface","device","phone","laptop","desktop","mobile"],Images:["image","photo","illustration","graphic","picture","visual","art","creative","design","drawing","sketch","artwork"]},[Fe,Be]=(0,r.useState)(""),[Ge,qe]=(0,r.useState)(""),[We,Ye]=(0,r.useState)(!1),[He,Ve]=(0,r.useState)({colors:[],aspect_ratio:null,tags:[]}),[Xe,Je]=(0,r.useState)(()=>
2{if("undefined"!==typeof window&&Array.isArray(window.__esPrefetchedAIEditorVariations)){const e=window.__esPrefetchedAIEditorVariations;return window.__esPrefetchedAIEditorVariations=null,e}return[]}),[$e,Ke]=(0,r.useState)(()=>{if("undefined"!==typeof window&&Number.isFinite(window.__esPrefetchedAIEditorVariationsTotal)){const e=window.__esPrefetchedAIEditorVariationsTotal;return window.__esPrefetchedAIEditorVariationsTotal=null,e}return 0}),[Ze,Qe]=(0,r.useState)(Xe.length>0),[et,tt]=(0,r.useState)(!1),[at,it]=(0,r.useState)(!1),[rt,st]=(0,r.useState)(()=>new Set),[nt,ot]=(0,r.useState)([]),[lt,dt]=(0,r.useState)(!1);(0,r.useEffect)(()=>{if(!y)return st(new Set),ot([]),void dt(!0);let e=!1;return(async()=>{try{const{data:a}=await s.A.get("".concat(t,"/ai-editor-favorites?hydrate=1"));if(e)return;const i=Array.isArray(null===a||void 0===a?void 0:a.variation_ids)?a.variation_ids:[];st(new Set(i)),ot(Array.isArray(null===a||void 0===a?void 0:a.variations)?a.variations:[])}catch(a){e||(st(new Set),ot([]))}finally{e||dt(!0)}})(),()=>{e=!0}},[t,y]);const ct=(0,r.useCallback)(async e=>{if(null===e||void 0===e||!e.id)return;if(!y)return void n.oR.error("Sign in to save favorites",{description:"Create a free account to start your favorites collection."});const a=e.id,i=rt.has(a);st(e=>{const t=new Set(e);return i?t.delete(a):t.add(a),t}),ot(t=>{if(i)return t.filter(e=>e.id!==a);return new Set(t.map(e=>e.id)).has(a)?t:[e,...t]});try{i?await s.A.delete("".concat(t,"/ai-editor-favorites/").concat(a)):await s.A.post("".concat(t,"/ai-editor-favorites/").concat(a))}catch(l){var r,o;st(e=>{const t=new Set(e);return i?t.add(a):t.delete(a),t}),ot(t=>{if(i){return new Set(t.map(e=>e.id)).has(a)?t:[e,...t]}return t.filter(e=>e.id!==a)}),n.oR.error("Couldn't update favorite",{description:(null===l||void 0===l||null===(r=l.response)||void 0===r||null===(o=r.data)||void 0===o?void 0:o.detail)||(null===l||void 0===l?void 0:l.message)})}},[t,y,rt]),[ut,ht]=(0,r.useState)([]),[mt,gt]=(0,r.useState)(!1);(0,r.useEffect)(()=>{let e=!1;return(async()=>{try{const{data:a}=await s.A.get("".concat(t,"/ai-editor-industries"));if(e)return;ht(Array.isArray(null===a||void 0===a?void 0:a.industries)?a.industries:[])}catch(a){e||ht([])}finally{e||gt(!0)}})(),()=>{e=!0}},[t]),(0,r.useEffect)(()=>{b&&!v&&mt&&0===ut.length&&"undefined"!==typeof window&&(window.history.replaceState({},"","/ai-editor/".concat(b,"/all")),window.dispatchEvent(new PopStateEvent("popstate")))},[b,v,mt,ut.length]);const pt=(0,r.useRef)(null),xt=(0,r.useRef)(0),ft=(0,r.useRef)({filter:Oe,q:Ee});(0,r.useEffect)(()=>{if(Ze)return;const e=++xt.current;let a=!1;return(async()=>{try{const i=new URLSearchParams({limit:String(30),offset:"0"});v&&"all"!==v&&i.set("industry",v);const{data:r}=await s.A.get("".concat(t,"/ai-editor-variations?").concat(i.toString()));if(a||e!==xt.current)return;Je(r.variations||[]),Ke(r.total||0),ft.current={filter:"All",q:""}}catch(i){}finally{a||e!==xt.current||Qe(!0)}})(),()=>{a=!0}},[t,Ze,v]);const bt=(0,r.useRef)({filter:"All",q:""});(0,r.useEffect)(()=>{const e=setTimeout(()=>{const e=bt.current;if(e.filter===Oe&&e.q===Ee)return;if(bt.current={filter:Oe,q:Ee},"Bulk Designer"===Oe)return pt.current&&pt.current.abort(),tt(!1),it(!1),Je([]),void Ke(0);const a=++xt.current;pt.current&&pt.current.abort();const i=new AbortController;pt.current=i,tt(!0),it(!0),Je([]),Ke(0),(async()=>{try{const e=new URLSearchParams({limit:String(30),offset:"0"});if(Oe&&"All"!==Oe){const t=Ue(Oe);t&&e.set("category",t)}v&&"all"!==v&&e.set("industry",v);const r=Ee.trim();r&&e.set("q",r);const{data:n}=await s.A.get("".concat(t,"/ai-editor-variations?").concat(e.toString()),{signal:i.signal});if(a!==xt.current)return;if(i.signal.aborted)return;Je(n.variations||[]),Ke(n.total||0),ft.current={filter:Oe,q:Ee}}catch(r){var e;if(null!==(e=s.A.isCancel)&&void 0!==e&&e.call(s.A,r)||"CanceledError"===(null===r||void 0===r?void 0:r.name))return}finally{a!==xt.current||i.signal.aborted||(Qe(!0),tt(!1),it(!1))}})()},Ee!==bt.current.q?250:0);return()=>clearTimeout(e)},[t,Oe,Ee,v]);const vt=(0,r.useCallback)(async()=>
2{if(et)return;if(Xe.length>=$e)return;const e=xt.current,a=Oe,i=Ee;tt(!0);try{const r=new URLSearchParams({limit:String(30),offset:String(Xe.length)});if(Oe&&"All"!==Oe){const e=Ue(Oe);e&&r.set("category",e)}v&&"all"!==v&&r.set("industry",v);const n=Ee.trim();n&&r.set("q",n);const{data:o}=await s.A.get("".concat(t,"/ai-editor-variations?").concat(r.toString()));if(e!==xt.current)return;const l=ft.current;if(l.filter!==a||l.q!==i)return;const d=o.variations||[];0===d.length?Ke(Xe.length):(Je(e=>{const t=new Set(e.map(e=>e.id));return[...e,...d.filter(e=>!t.has(e.id))]}),Number.isFinite(o.total)&&Ke(o.total))}catch(r){}finally{e===xt.current&&tt(!1)}},[t,Xe.length,$e,Oe,Ee,v,et]),wt={id:"custom-structure",name:"Custom Structure",desc:"Upload your own structure as a reference.",image:null,isCustom:!0},yt=(()=>{const e=[wt],t=Xe.map(e=>{let t=null;e.thumbnail_base64?t=e.thumbnail_base64.startsWith("data:")?e.thumbnail_base64:"data:image/png;base64,".concat(e.thumbnail_base64):"Mind Map"===e.name&&(t=E.I1[0].image);const a=e.reference_image_base64||null;return{id:e.id,name:e.name,desc:"Tap to start building.",image:t,refImage:a,tags:Array.isArray(e.tags)?e.tags:[],categories:Array.isArray(e.categories)?e.categories:[],aspect_ratio:e.aspect_ratio||null,colors:Array.isArray(e.colors)?e.colors.filter(Boolean):[]}});return e.push(...t),0===t.length&&Ze&&"All"===Oe&&e.push((0,i.A)((0,i.A)({},E.I1[0]),{},{tags:[]})),e})(),jt=(()=>{let e=yt;if(e=e.filter(e=>{if(e.isCustom||(e.id||"").startsWith("placeholder"))return!0;const t=Array.isArray(e.categories)?e.categories:[];return 0===t.length||t.some(e=>!Me.includes(e))}),"All"!==Oe){const t=ze[Oe]||[],a=new Set([Oe]);"Infographics"===Oe&&a.add("Infographic"),"Infographic"===Oe&&a.add("Infographics"),"Social Media Posts"===Oe&&a.add("Social Media Content"),"Social Media Content"===Oe&&a.add("Social Media Posts"),"My Designs"===Oe&&a.add("Personal"),e=e.filter(e=>{if(e.isCustom||(e.id||"").startsWith("placeholder"))return!0;if(Array.isArray(e.categories)&&e.categories.length>0)return e.categories.some(e=>a.has(e));const i=(e.tags||[]).map(e=>(e||"").toLowerCase()),r=(e.name||"").toLowerCase();return t.some(e=>r.includes(e)||i.some(t=>t.includes(e)))})}const t=Ee.trim().toLowerCase();return t?e.filter(e=>!(!e.isCustom&&!(e.id||"").startsWith("placeholder"))||(!!(e.name||"").toLowerCase().includes(t)||(e.tags||[]).some(e=>(e||"").toLowerCase().includes(t)))):e})(),Nt=e=>{if(e&&(e.image||e.refImage))return e;let t=null;return e.thumbnail_base64?t=e.thumbnail_base64.startsWith("data:")?e.thumbnail_base64:"data:image/png;base64,".concat(e.thumbnail_base64):"Mind Map"===e.name&&(t=E.I1[0].image),{id:e.id,name:e.name,desc:"Tap to start building.",image:t,refImage:e.reference_image_base64||null,tags:Array.isArray(e.tags)?e.tags:[],categories:Array.isArray(e.categories)?e.categories:[],aspect_ratio:e.aspect_ratio||null,colors:Array.isArray(e.colors)?e.colors.filter(Boolean):[]}},kt=(()=>{if("Favorites"!==Oe)return jt;const e=(Ee||"").trim().toLowerCase(),t=(nt||[]).map(Nt);return e?t.filter(t=>!!(t.name||"").toLowerCase().includes(e)||(t.tags||[]).some(t=>(t||"").toLowerCase().includes(e))):t})(),At="Favorites"!==Oe&&Xe.length<$e,_t=(0,r.useRef)(null);(0,r.useEffect)(()=>{if(!At)return;if(et)return;const e=_t.current;if(!e||"undefined"===typeof IntersectionObserver)return;const t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&vt()},{rootMargin:"400px 0px"});return t.observe(e),()=>t.disconnect()},[At,et,vt]);const Ct=he?ge?xe?"bulk-content":"bulk-style":"bulk-format":!b||v||V?V?V.isCustom&&!We?"custom-structure":J?K?se?"review":"style":"format":"quick":"variation":"industry-picker";(0,r.useEffect)(()=>{"undefined"!==typeof window&&window.scrollTo({top:0,left:0,behavior:"auto"})},[Ct]);const St=()=>{if(he)return"bulk-content"===Ct?(fe(null),void ve(null)):"bulk-style"===Ct?void pe(null):(me(!1),pe(null),fe(null),void ve(null));if("review"===Ct){if("quick"===J)return X(null),$(null),Z(null),oe(null),de(null),void ue([]);oe(null),de(null),ue([])}else"style"===Ct?(Z(null),oe(null)):"format"===Ct?null!==V&&void 0!==V&&V.isCustom?(Ye(!1),$(null),Z(null),oe(null)):"custom"===J?($(null),Z(null),oe(null)):(X(null),Z(null),oe(null)):"quick"===Ct?null!==V&&void 0!==V&&V.isCustom?(Ye(!1),$(null)):(X(null),$(null)):"custom-structure"===Ct?(X(null),Be(""),qe(""),Ye(!1),Ve({colors:[],aspect_ratio:null,tags:[]})):"industry-picker"===Ct?null===d||void 0===d||d("ai-editor"):null===a||void 0===a||a()},Rt="bulk-content"===Ct?"Back to styles":"bulk-style"===Ct?"Back to formats":"bulk-format"===Ct?"Back to Bulk Designer":"review"===Ct?"quick"===J?"Variations":"Back to styles":"style"===Ct?"Back to formats":"format"===Ct?null!==V&&void 0!==V&&V.isCustom?"Back to reference":"custom"===J?"Back to Quick design":"Back to variations":"quick"===Ct?null!==V&&void 0!==V&&V.isCustom?"Back to reference":"Back to variations":"custom-structure"===Ct?"Back to variations":"industry-picker"===Ct?"Back to all categories":"Back to Home";return(0,U.jsxs)("div",{className:"min-h-screen spotlight","data-testid":"ai-editor-page",children:[(0,U.jsx)(T.A,{}),(0,U.jsx)(E.DW,{navigate:d,currentRoute:"ai-editor"}),G&&(0,U.jsx)("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-black/70 backdrop-blur-sm","data-testid":"ai-editor-back-loading","aria-live":"polite","aria-busy":"true",children:(0,U.jsx)(E.re,{title:"Loading ".concat(Rt.replace(/^Back to\s*/i,"").toLowerCase()||"previous step"),subtitle:"rewinding \xb7 keeping your choices"})}),(0,U.jsxs)("main",{className:"relative z-10 mx-auto max-w-[1280px] px-6 py-6 sm:py-8",children:["variation"!==Ct&&("idle"===_||"done"===_)&&(0,U.jsx)("div",{className:"mb-3 text-center",children:(0,U.jsxs)("button",{type:"button",onClick:()=>
2{"idle"!==_&&"done"!==_||(q(!0),setTimeout(()=>{St(),setTimeout(()=>q(!1),180)},60))},className:"inline-flex items-center gap-1 text-xs font-medium text-white/55 transition hover:text-white","data-testid":"ai-editor-back",children:[(0,U.jsx)(g.A,{className:"h-3 w-3 rotate-180"}),Rt]})}),"variation"===Ct&&"rendering"!==_&&"extracting"!==_&&"researching"!==_&&"splitting"!==_&&"outline"!==_&&(0,U.jsx)(E.vl,{user:y,navigate:d}),(0,U.jsxs)("div",{className:"mb-4 text-center",children:["idle"===_||"done"===_?(0,U.jsx)("img",{src:"/announcements/powered-by-fable.webp",alt:"Powered by Fable",loading:"eager",decoding:"async",className:"mx-auto mb-3 h-7 w-auto select-none sm:h-8","data-testid":"powered-by-fable-badge"}):null,"idle"!==_&&"done"!==_?(0,U.jsxs)("h2",{className:"text-4xl font-bold tracking-tight sm:text-5xl",children:["Creating your",(0,U.jsx)("span",{className:"text-gradient-flow inline-block",children:"\xa0Design"}),(0,U.jsx)(l.A,{className:"ml-3 inline h-7 w-7 -translate-y-2 text-rose-400"})]}):(0,U.jsx)(U.Fragment,{children:"bulk-format"===Ct?(0,U.jsxs)("h2",{className:"text-4xl font-bold tracking-tight sm:text-5xl",children:["Choose your",(0,U.jsx)("span",{className:"text-gradient-flow inline-block",children:"\xa0format"}),(0,U.jsx)("span",{className:"text-white",children:"\xa0for multiple files"}),(0,U.jsx)(l.A,{className:"ml-3 inline h-7 w-7 -translate-y-2 text-rose-400"})]}):"bulk-style"===Ct?(0,U.jsxs)("h2",{className:"text-4xl font-bold tracking-tight sm:text-5xl",children:["Select your",(0,U.jsx)("span",{className:"text-gradient-flow inline-block",children:"\xa0style"}),(0,U.jsx)("span",{className:"text-white",children:"\xa0for multiple files"}),(0,U.jsx)(l.A,{className:"ml-3 inline h-7 w-7 -translate-y-2 text-rose-400"})]}):"bulk-content"===Ct?(0,U.jsxs)("h2",{className:"text-4xl font-bold tracking-tight sm:text-5xl",children:["Input your",(0,U.jsx)("span",{className:"text-gradient-flow inline-block",children:"\xa0content"}),(0,U.jsx)("span",{className:"text-white",children:"\xa0for multiple files"}),(0,U.jsx)(l.A,{className:"ml-3 inline h-7 w-7 -translate-y-2 text-rose-400"})]}):"review"===Ct?(0,U.jsxs)("h2",{className:"text-4xl font-bold tracking-tight sm:text-5xl",children:["Input your",(0,U.jsx)("span",{className:"text-gradient-flow inline-block",children:"\xa0Content"}),(0,U.jsx)(l.A,{className:"ml-3 inline h-7 w-7 -translate-y-2 text-rose-400"})]}):"style"===Ct?(0,U.jsxs)("h2",{className:"text-4xl font-bold tracking-tight sm:text-5xl",children:["Select your",(0,U.jsx)("span",{className:"text-gradient-flow inline-block",children:"\xa0Style"}),(0,U.jsx)(l.A,{className:"ml-3 inline h-7 w-7 -translate-y-2 text-rose-400"})]}):"format"===Ct?(0,U.jsxs)("h2",{className:"text-4xl font-bold tracking-tight sm:text-5xl",children:["Choose your",(0,U.jsx)("span",{className:"text-gradient-flow inline-block",children:"\xa0format"}),(0,U.jsx)(l.A,{className:"ml-3 inline h-7 w-7 -translate-y-2 text-rose-400"})]}):"quick"===Ct?(0,U.jsxs)("h2",{className:"text-4xl font-bold tracking-tight sm:text-5xl",children:["Quick",(0,U.jsx)("span",{className:"text-gradient-flow inline-block",children:"\xa0Design"}),(0,U.jsx)("span",{className:"text-white",children:"\xa0or\xa0"}),(0,U.jsx)("span",{className:"text-gradient-flow inline-block",children:"Customize"}),(0,U.jsx)(l.A,{className:"ml-3 inline h-7 w-7 -translate-y-2 text-rose-400"})]}):"custom-structure"===Ct?(0,U.jsx)(U.Fragment,{children:(0,U.jsxs)("h2",{className:"text-4xl font-bold tracking-tight sm:text-5xl",children:["Upload your",(0,U.jsx)("span",{className:"text-gradient-flow inline-block",children:"\xa0reference"}),(0,U.jsx)(l.A,{className:"ml-3 inline h-7 w-7 -translate-y-2 text-rose-400"})]})}):"industry-picker"===Ct?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)("h2",{className:"text-4xl font-bold tracking-tight sm:text-5xl",children:["Choose your",(0,U.jsx)("span",{className:"text-gradient-flow inline-block",children:"\xa0industry"}),(0,U.jsx)(l.A,{className:"ml-3 inline h-7 w-7 -translate-y-2 text-rose-400"})]}),(0,U.jsx)("p",{className:"mx-auto mt-4 max-w-md text-sm text-white/50",children:"Pick a niche to see designs tailored to it."})]}):(0,U.jsxs)("h2",{className:"text-4xl font-bold tracking-tight sm:text-5xl",children:["What do you want",(0,U.jsx)("br",{className:"lg:hidden"}),(0,U.jsx)("span",{className:"hidden lg:inline",children:" "}),"to",(0,U.jsx)("span",{className:"text-gradient-flow inline-block",children:"\xa0build?"}),(0,U.jsx)(l.A,{className:"ml-3 inline h-7 w-7 -translate-y-2 text-rose-400"})]})})]}),"idle"!==_&&"done"!==_?(0,U.jsxs)("div",{className:"space-y-4",children:[(0,U.jsx)("div",{className:"relative w-full overflow-hidden rounded-2xl border border-white/10 bg-zinc-900 p-6 sm:p-8","data-testid":"ai-editor-progress-card",children:(0,U.jsx)(E.AO,{job:P||{step:_}})}),(0,U.jsxs)("div",{className:"relative flex w-full items-center justify-center gap-3 overflow-hidden rounded-2xl border border-white/10 bg-zinc-900 px-6 py-4","data-testid":"ai-editor-rendering-animation",children:[(0,U.jsx)("div",{className:"absolute inset-0 analyzing-pulse opacity-40"}),(0,U.jsx)("div",{className:"absolute inset-x-0 h-[2px] bg-gradient-to-r from-transparent via-orange-300 to-transparent shadow-[0_0_18px_rgba(249,115,22,0.6)] analyzing-scan"}),(0,U.jsxs)("div",{className:"relative z-[1] flex items-center gap-3",children:[(0,U.jsx)("div",{className:"flex h-9 w-9 items-center justify-center rounded-full border border-orange-400/40 bg-orange-500/[0.08]",children:(0,U.jsx)(p.A,{className:"h-4 w-4 animate-spin text-orange-300"})}),(0,U.jsx)("div",{className:"text-sm font-bold uppercase tracking-[0.18em] text-white",children:"Rendering your design"})]})]})]}):"bulk-format"===Ct?(0,U.jsx)(re,{selected:ge,onSelect:e=>pe(e)}):"bulk-style"===Ct?(0,U.jsx)(ne,{api:t,navigate:d,selected:xe,onSelect:(e,t)=>
2{fe(e),ve(t),ye(null)}}):"bulk-content"===Ct?(0,U.jsx)(z,{api:t,authUser:y,format:ge,style:be,colorsOverride:we,onChangeColorsOverride:ye,cards:Ae,settings:je,onChangeSettings:Ne,onChangeCards:_e,makeBlankCard:ke,onOpenStructurePicker:e=>Se(e),run:Re,onGenerateAll:()=>(async()=>{const e=Ae.filter(e=>e.variation&&(e.content||"").trim().length>0);if(e.length<2)return void n.oR.error("Need at least 2 ready cards",{description:"Each card needs a structure and some content before you can generate the batch."});if(!y)return void n.oR.error("Please sign in",{description:"Bulk Designer is a signed-in feature so we can save results to your account."});if("idle"!==_)return void n.oR.message("A generation is already running",{description:"Wait for the current job to finish before starting a new bulk run."});const t=e.length,a=5*t;if(!N(a))return void n.oR.error("Not enough credits",{description:"This bulk run needs ".concat(a," credits (").concat(5," per design \xd7 ").concat(t,").")});B.current=!1,S("rendering"),D({slides_done:0,slides_total:t}),M({step:"render",slides_done:0,slides_total:t}),I(null),F(t),Te({phase:"running",progress:{done:0,total:t,failed:0},results:[]}),"undefined"!==typeof window&&window.scrollTo({top:0,left:0,behavior:"auto"});const r=[];let s=null,o=null,l="";const d={done:0,failed:0},c=await Promise.all(e.map((e,a)=>{var r,s,n;return W({text:(e.content||"").trim(),file:(e.documents||[])[0]||null,images:Array.isArray(e.images)?e.images:[],logo:e.logo||null,slideCount:1,font:(null===be||void 0===be?void 0:be.font)||null,webMode:je.webMode,noTextOnDesign:je.noTextOnDesign,aggregateOnly:!0,overrideContext:{variation:e.variation,format:ge,style:xe,styleDetails:be,reviewColors:(Array.isArray(we)&&we.length>0?we:null===be||void 0===be?void 0:be.colors)||(null===(r=e.variation)||void 0===r?void 0:r.colors)||[],customName:null!==(s=e.variation)&&void 0!==s&&s.isCustom?e.variation.name||"Custom Structure":null,customRef:null!==(n=e.variation)&&void 0!==n&&n.isCustom&&(e.variation.refImage||e.variation.image)||null}}).then(r=>{d.done+=1;const s=d.done,n=d.failed;return Te(t=>(0,i.A)((0,i.A)({},t),{},{progress:(0,i.A)((0,i.A)({},t.progress),{},{done:s,failed:n}),results:[...t.results,{cardId:e.id,ok:!0,originalIndex:a}]})),D({slides_done:s-n,slides_total:t}),M({step:"render",slides_done:s-n,slides_total:t}),{ok:!0,originalIndex:a,cardId:e.id,out:r}},r=>{d.done+=1,d.failed+=1;const s=d.done,n=d.failed;return console.warn("Bulk Designer \xb7 card ".concat(a+1," failed:"),(null===r||void 0===r?void 0:r.message)||r),Te(t=>(0,i.A)((0,i.A)({},t),{},{progress:(0,i.A)((0,i.A)({},t.progress),{},{done:s,failed:n}),results:[...t.results,{cardId:e.id,ok:!1,originalIndex:a,error:String((null===r||void 0===r?void 0:r.message)||r)}]})),D({slides_done:s-n,slides_total:t}),{ok:!1,originalIndex:a,cardId:e.id,error:r}})}));c.sort((e,t)=>e.originalIndex-t.originalIndex);const u=[];for(const n of c){var h,m;if(!n.ok){var g;r.push({cardId:n.cardId,error:String((null===(g=n.error)||void 0===g?void 0:g.message)||n.error)});continue}const e=n.out;if(null!==e&&void 0!==e&&null!==(h=e.result)&&void 0!==h&&null!==(m=h.slides)&&void 0!==m&&m.length)for(const t of e.result.slides)u.push((0,i.A)((0,i.A)({},t),{},{index:u.length}));null!==e&&void 0!==e&&e.styleSnap&&(s=e.styleSnap),null!==e&&void 0!==e&&e.aiEditorSettings&&(o=e.aiEditorSettings),!l&&null!==e&&void 0!==e&&e.sourceSummary&&(l=e.sourceSummary)}var p,x;if(0===u.length)return Te(e=>(0,i.A)((0,i.A)({},e),{},{phase:"done"})),S("idle"),void n.oR.error("Bulk run failed",{description:(null===(p=r[0])||void 0===p||null===(x=p.error)||void 0===x?void 0:x.slice(0,200))||"Every card failed to render. Check your credits and try again."});Te(e=>(0,i.A)((0,i.A)({},e),{},{phase:"done"})),S("done"),r.length>0?n.oR.warning("Generated ".concat(u.length," of ").concat(t," designs"),{description:"".concat(r.length," card").concat(r.length>1?"s":""," failed and ").concat(r.length>1?"were":"was"," skipped."),duration:8e3}):n.oR.success("Generated ".concat(u.length," designs in 1 project!")),null===w||void 0===w||w({id:"bulk-".concat(Date.now()),slides:u,pdf_base64:""},s,l,o)})()}):"review"===Ct?(0,U.jsx)(H,{variation:V,customName:Fe,customRef:Ge,format:K,style:le,colors:ce,onChangeColors:ue,onGenerate:W,generating:"idle"!==_&&"done"!==_,genProgress:R,quickMode:"quick"===J}):"style"===Ct?(0,U.jsx)(ne,{api:t,navigate:d,selected:se,onSelect:(e,t)=>
2{oe(e),de(t),ue((null===t||void 0===t?void 0:t.colors)||[])}}):"format"===Ct?(0,U.jsx)(re,{selected:K,onSelect:e=>{Z(e)}}):"quick"===Ct?(0,U.jsx)(ie,{variation:V,onPick:e=>{if("quick"===e){const e=(null===V||void 0===V?void 0:V.aspect_ratio)||"1:1";$("quick"),Z(e);const t=(null===V||void 0===V?void 0:V.refImage)||(null===V||void 0===V?void 0:V.image)||"",a=t?t.startsWith("data:")?t.split(",")[1]||"":t:"";oe("variation:".concat((null===V||void 0===V?void 0:V.id)||"")),de({id:"variation:".concat((null===V||void 0===V?void 0:V.id)||""),name:(null===V||void 0===V?void 0:V.name)||"Variation",thumbnail:t||null,preview_image_base64:a||null,colors:(null===V||void 0===V?void 0:V.colors)||[],source:"variation-quick",image_base64_list:a?[a]:[]}),ue((null===V||void 0===V?void 0:V.colors)||[])}else $("custom")}}):"custom-structure"===Ct?(0,U.jsx)(ae,{api:t,name:Fe,reference:Ge,onChangeName:Be,onChangeReference:e=>{qe(e),e||Ve({colors:[],aspect_ratio:null,tags:[]})},onDetectedMeta:e=>Ve({colors:Array.isArray(null===e||void 0===e?void 0:e.colors)?e.colors:[],aspect_ratio:(null===e||void 0===e?void 0:e.aspect_ratio)||null,tags:Array.isArray(null===e||void 0===e?void 0:e.tags)?e.tags:[]}),onContinue:async()=>{if(y)try{await s.A.post("".concat(t,"/ai-editor-variations"),{name:Fe.trim()||"Custom Structure",thumbnail_base64:Ge||null,reference_image_base64:Ge||null,tags:He.tags||[],categories:["Personal"],colors:He.colors||[],aspect_ratio:He.aspect_ratio||null})}catch(o){var e,a,r;const t=(null===o||void 0===o||null===(e=o.response)||void 0===e||null===(a=e.data)||void 0===a?void 0:a.detail)||(null===o||void 0===o?void 0:o.message),i=null===o||void 0===o||null===(r=o.response)||void 0===r?void 0:r.status;if(403===i||413===i)return void n.oR.warning(413===i?"File too large":"Custom design not saved",{description:t,duration:8e3});console.warn("Persist custom structure failed:",t)}X(e=>(0,i.A)((0,i.A)({},e||{}),{},{isCustom:!0,name:Fe.trim()||"Custom Structure",image:Ge?Ge.startsWith("data:")?Ge:"data:image/png;base64,".concat(Ge):null,aspect_ratio:He.aspect_ratio||null,colors:He.colors||[]})),Ye(!0),Z(null),oe(null)}}):"industry-picker"===Ct?(0,U.jsx)(ee,{industries:ut,industriesLoaded:mt,categorySlug:b,onSelect:e=>{"undefined"!==typeof window&&(window.history.pushState({},"","/ai-editor/".concat(b,"/").concat(e)),window.dispatchEvent(new PopStateEvent("popstate")))},onSkipAll:()=>{"undefined"!==typeof window&&(window.history.pushState({},"","/ai-editor/".concat(b,"/all")),window.dispatchEvent(new PopStateEvent("popstate")))}}):(0,U.jsxs)("div",{className:"space-y-6",children:[(0,U.jsxs)("div",{className:"mx-auto flex max-w-2xl flex-col gap-2 sm:flex-row sm:items-stretch sm:gap-2",children:[(0,U.jsxs)("div",{className:"flex min-h-[58px] flex-1 items-center gap-2 rounded-full border border-white/10 bg-white/[0.04] px-4",children:[(0,U.jsx)(x.A,{className:"h-4 w-4 text-white/65"}),(0,U.jsx)("input",{type:"text",value:Ee,onChange:e=>De(e.target.value),placeholder:"Search designs here...",className:"h-9 w-full bg-transparent text-[17.5px] text-white outline-none placeholder:text-white/70","data-testid":"ai-editor-variation-search"}),Ee&&(0,U.jsx)("button",{type:"button",onClick:()=>De(""),className:"text-white/65 transition hover:text-white","aria-label":"Clear search","data-testid":"ai-editor-variation-search-clear",children:(0,U.jsx)(f.A,{className:"h-3.5 w-3.5"})})]}),(0,U.jsx)(Q,{industries:ut,value:v,categorySlug:b,onChange:e=>{if("undefined"===typeof window)return;let t;if(e){t="/ai-editor/".concat(b||"all","/").concat(e)}else t=b?"/ai-editor/".concat(b,"/all"):"/ai-editor";window.history.pushState({},"",t),window.dispatchEvent(new PopStateEvent("popstate"))}})]}),(0,U.jsx)("div",{className:"flex flex-wrap items-center justify-center gap-2.5",children:Le.filter(e=>{let{label:t,requiresAuth:a}=e;return!Me.includes(t)&&!(a&&!y)}).map(e=>{let{label:t,Icon:a,ownTint:i}=e;const r=Oe===t,s=i?"border border-orange-400/30 bg-orange-500/[0.06] text-orange-100/85 hover:border-orange-300/55 hover:bg-orange-500/[0.10] hover:text-orange-100":"border border-white/10 bg-white/[0.04] text-white/65 hover:border-white/25 hover:bg-white/[0.08] hover:text-white";return(0,U.jsxs)("button",{type:"button",onClick:()=>
2{if(Ie(t),"undefined"!==typeof window&&d){var e;const a=null===(e=Object.entries(Pe).find(e=>{let[,a]=e;return a===t}))||void 0===e?void 0:e[0];d(a?"ai-editor:".concat(a):"ai-editor")}},className:"relative inline-flex items-center gap-1.5 rounded-full px-3 py-1.5 text-[12px] font-semibold transition sm:gap-2 sm:px-4 sm:text-[13px] ".concat(r?"bg-gradient-to-r from-orange-500 via-rose-500 to-fuchsia-600 text-white shadow-[0_8px_28px_-6px_rgba(244,63,94,0.55),0_0_0_1px_rgba(255,255,255,0.08)_inset]":s),"data-testid":"ai-editor-filter-".concat(t.toLowerCase().replace(/\s+/g,"-")),children:[r&&(0,U.jsx)("span",{"aria-hidden":"true",className:"pointer-events-none absolute -inset-x-3 -top-2 -bottom-2 -z-10 rounded-full bg-rose-500/20 blur-xl"}),(0,U.jsx)(a,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4 ".concat(r?"text-white":i?"text-orange-300/85":"text-white/55")}),t]},t)})}),"Bulk Designer"===Oe?(0,U.jsxs)("div",{className:"rounded-2xl border border-orange-400/30 bg-gradient-to-br from-orange-500/[0.08] via-rose-500/[0.05] to-fuchsia-500/[0.05] p-8 text-center sm:p-12","data-testid":"ai-editor-bulk-designer-stub",children:[(0,U.jsx)("div",{className:"mx-auto mb-4 flex h-14 w-14 items-center justify-center rounded-2xl border border-orange-300/40 bg-orange-500/[0.12]",children:(0,U.jsx)(u,{className:"h-7 w-7 text-orange-200"})}),(0,U.jsx)("h3",{className:"text-xl font-semibold text-white sm:text-2xl",children:"Bulk Designer"}),(0,U.jsxs)("p",{className:"mx-auto mt-2 max-w-md text-sm text-white/65",children:["Generate up to ",(0,U.jsx)("span",{className:"font-semibold text-white",children:"50 designs"})," at once \u2014 same brand kit, different layouts and content, all running in parallel."]}),(0,U.jsxs)("div",{className:"mt-5 flex flex-col items-center justify-center gap-2 text-[12px] text-white/55 sm:flex-row sm:gap-5",children:[(0,U.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,U.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-orange-300"}),"5 credits per card"]}),(0,U.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,U.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-orange-300"}),"Up to 20 generations in parallel"]}),(0,U.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,U.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-orange-300"}),"Per-card structure & uploads"]})]}),(0,U.jsxs)("button",{type:"button",onClick:()=>{me(!0),pe(null),fe(null),ve(null),Te({phase:"idle",progress:{done:0,total:0,failed:0},results:[]})},className:"mt-6 inline-flex items-center gap-2 rounded-full bg-gradient-to-r from-orange-500 via-rose-500 to-fuchsia-600 px-6 py-2.5 text-sm font-semibold text-white shadow-[0_8px_28px_-6px_rgba(244,63,94,0.55)] transition hover:brightness-110","data-testid":"ai-editor-bulk-designer-start",children:[(0,U.jsx)(l.A,{className:"h-4 w-4"}),"Start Bulk Designer"]})]}):(0,U.jsxs)(U.Fragment,{children:[at||"Favorites"===Oe&&!lt?(0,U.jsx)("div",{className:"columns-2 gap-2.5 sm:columns-4 xl:columns-5 [&>*]:mb-2.5 [&>*]:break-inside-avoid","data-testid":"ai-editor-variations-skeleton","aria-busy":"true","aria-live":"polite",children:Array.from({length:10},(e,t)=>{const a=["aspect-square","aspect-[4/5]","aspect-video","aspect-[9/16]","aspect-[3/4]"],i=a[t%a.length];return(0,U.jsx)("div",{className:"overflow-hidden rounded-2xl border border-white/10 bg-white/[0.025]",children:(0,U.jsxs)("div",{className:"relative w-full ".concat(i," bg-gradient-to-br from-white/[0.05] via-white/[0.02] to-transparent"),children:[(0,U.jsx)("div",{className:"absolute inset-0 animate-pulse"}),(0,U.jsx)("div",{className:"pointer-events-none absolute inset-x-0 -top-1/2 h-full bg-gradient-to-b from-transparent via-white/[0.04] to-transparent shimmer"})]})},t)})}):null,(0,U.jsx)("div",{className:"columns-2 gap-2.5 sm:columns-4 xl:columns-5 [&>*]:mb-2.5 [&>*]:break-inside-avoid ".concat(at||"Favorites"===Oe&&!lt?"hidden":""),children:kt.map(e=>(0,U.jsx)(te,{variation:e,isFavorite:rt.has(e.id),onToggleFavorite:()=>ct(e),onClick:()=>{e.id.startsWith("placeholder")||(X(e),Z(null),oe(null),$(null),Ye(!1),Be(""),qe(""),Ve({colors:[],aspect_ratio:null,tags:[]}))},onCustomFileDropped:async t=>{if(t)if(["image/jpeg","image/png","image/webp"].includes(t.type)){if(t.size>10485760){const e=(t.size/1048576).toFixed(1);return void n.oR.error("File too large",{description:"That image is ".concat(e," MB. Max upload size is 10 MB on every plan \u2014 please compress it and try again.")})}try{const a=await new Promise((e,a)=>{const i=new FileReader;i.onload=()=>{const t=String(i.result||"");e(t.includes(",")?t.split(",")[1]:t)},i.onerror=a,i.readAsDataURL(t)});X(e),Z(null),oe(null),$(null),Ye(!1),Be(""),qe(a),Ve({colors:[],aspect_ratio:null,tags:[]})}catch(a){n.oR.error("Could not read that file")}}else n.oR.error("JPEG, PNG or WebP only",{description:"Please drop a JPG, PNG or WebP image as your reference."})}},e.id))}),"My Designs"===Oe&&0===Xe.length&&!at&&(0,U.jsxs)("div",{className:"mt-3 rounded-xl border border-dashed border-white/15 bg-white/[0.02] p-5 text-center text-sm text-white/55",children:["No saved designs yet. Drop a reference on the",(0,U.jsx)("span",{className:"mx-1 font-semibold text-orange-200",children:"Upload your own design"}),"card above and we'll save it here automatically."]}),"Favorites"===Oe&&!lt&&(0,U.jsxs)("div",{className:"mt-3 flex items-center justify-center gap-3 rounded-xl border border-rose-400/20 bg-rose-500/[0.03] p-6 text-sm text-white/65","data-testid":"ai-editor-favorites-loading",children:[(0,U.jsx)(p.A,{className:"h-4 w-4 animate-spin text-rose-300"}),"Loading your favorites\u2026"]}),"Favorites"===Oe&<&&0===nt.length&&(0,U.jsxs)("div",{className:"mt-3 rounded-xl border border-dashed border-rose-400/25 bg-rose-500/[0.04] p-5 text-center text-sm text-white/65","data-testid":"ai-editor-favorites-empty",children:["No favorites yet. Tap the",(0,U.jsx)(c,{className:"mx-1 -mt-0.5 inline h-3.5 w-3.5 text-rose-300"}),"heart in the top-right corner of any design to save it here."]}),At&&(0,U.jsxs)("div",{ref:_t,className:"relative mt-6 overflow-hidden rounded-2xl border border-orange-400/30 bg-gradient-to-r from-orange-500/10 via-rose-500/10 to-fuchsia-500/10 px-6 py-5 shadow-[0_0_30px_rgba(249,115,22,0.18)]","data-testid":"ai-editor-variations-sentinel",children:[(0,U.jsxs)("div",{className:"pointer-events-none absolute inset-0 opacity-60",children:[(0,U.jsx)("div",{className:"absolute -left-10 top-1/2 h-24 w-24 -translate-y-1/2 roun
2ded-full bg-orange-500/30 blur-3xl"}),(0,U.jsx)("div",{className:"absolute -right-10 top-1/2 h-24 w-24 -translate-y-1/2 rounded-full bg-fuchsia-500/30 blur-3xl"})]}),(0,U.jsx)("div",{className:"pointer-events-none absolute inset-y-0 left-0 w-1/3 bg-gradient-to-r from-transparent via-white/10 to-transparent shimmer"}),(0,U.jsxs)("div",{className:"relative z-[1] flex items-center justify-center gap-3 text-2xl font-semibold text-white/90",children:[(0,U.jsx)(p.A,{className:"h-7 w-7 animate-spin text-orange-300"}),(0,U.jsx)("span",{className:"bg-gradient-to-r from-orange-200 via-rose-200 to-fuchsia-200 bg-clip-text text-transparent",children:et?"Loading more designs\u2026":"Scroll to load more"})]})]})]})]})]}),Ce&&(0,U.jsx)(Y,{api:t,onClose:()=>Se(null),onPick:e=>{_e(t=>t.map(t=>t.id===Ce?(0,i.A)((0,i.A)({},t),{},{variation:e}):t)),Se(null)}}),(0,U.jsx)(E.Xd,{navigate:d})]})}}}]); 3//# sourceMappingURL=463.498ea648.chunk.js.map
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.