1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,516719,e=>{"use strict";e.i(90985);var t,r,a=e.i(466471),i=e.i(884702),n=e.i(46219),n=n,o=e.i(205574),o=o,s=e.i(559768),s=s,l=e.i(178549),l=l,d=e.i(183885),d=d,c=e.i(636680),u=e.i(394673),m=e.i(910776),g=e.i(169543),p=e.i(855989),b=e.i(462297),h=e.i(262336),h=h,x=e.i(956333),f=e.i(576076),v=e.i(578033),v=v,w=e.i(754853),y=e.i(869965),y=y,j=e.i(141836),k=e.i(506039),N=e.i(624770),N=N,C=e.i(39973),S=e.i(862015),E=e.i(653668),z=e.i(103979),L=e.i(779342),P=((t={}).MUSIC="music",t.IMAGE="image",t.VIDEO="video",t.TEXT="text",t.SPEECH="speech",t),M=((r={}).PENDING="pending",r.PROCESSING="processing",r.SUCCESS="success",r.FAILED="failed",r.CANCELED="canceled",r);e.i(741820);var I=e.i(561444),R=e.i(24963),B=e.i(511398),$=e.i(122913),F=e.i(901017),A=e.i(638678),D=e.i(534522),T=e.i(960568),U=e.i(526683);let G="nano-banana-pro",O={x:7,y:78,width:17},q=[{label:"Bricolage",value:'"Bricolage Grotesque", Arial, sans-serif'},{label:"Quicksand",value:"Quicksand, Arial, sans-serif"},{label:"Arial",value:"Arial, sans-serif"},{label:"Impact",value:"Impact, Arial Black, sans-serif"},{label:"Georgia",value:"Georgia, serif"}],_=[{label:"Classic",value:"classic",image:"/imgs/album-cover-generator/explicit-labels/parental-advisory-classic.webp"},{label:"Lyrics",value:"clean",image:"/imgs/album-cover-generator/explicit-labels/parental-advisory-explicit-lyrics.webp"},{label:"Strong",value:"black",image:"/imgs/album-cover-generator/explicit-labels/parental-advisory-strong-content.webp"}],V=["Single","EP","Album","Playlist","Podcast"],W=[1,2,3,4],H={Genre:["Hip-Hop","Pop","Rock","Electronic","Lo-Fi","R&B","Jazz","Metal"],Mood:["Dark","Energetic","Calm","Cinematic","Minimal","Gritty","Dreamy","Romantic"],"Visual Style":["Photo","Illustration","Vintage","Minimal","Synthwave","Grunge","Watercolor","3D"]},J={Photo:"/imgs/album-cover-generator/style-photo-v1.webp",Illustration:"/imgs/album-cover-generator/style-illustration-v1.webp",Vintage:"/imgs/album-cover-generator/style-vintage-v1.webp",Minimal:"/imgs/album-cover-generator/style-minimal-v1.webp",Synthwave:"/imgs/album-cover-generator/style-synthwave-v1.webp",Grunge:"/imgs/album-cover-generator/style-grunge-v1.webp",Watercolor:"/imgs/album-cover-generator/style-watercolor-v1.webp","3D":"/imgs/album-cover-generator/style-3d-v1.webp"},X={"Hip-Hop":"/imgs/album-cover-generator/genre-hip-hop-v1.webp",Pop:"/imgs/album-cover-generator/genre-pop-v1.webp",Rock:"/imgs/album-cover-generator/genre-rock-v1.webp",Electronic:"/imgs/album-cover-generator/genre-electronic-v1.webp","Lo-Fi":"/imgs/album-cover-generator/genre-lo-fi-v1.webp","R&B":"/imgs/album-cover-generator/genre-r-and-b-v1.webp",Jazz:"/imgs/album-cover-generator/genre-jazz-v1.webp",Metal:"/imgs/album-cover-generator/genre-metal-v1.webp"},Y={Minimal:"/imgs/musicmake/sample-soft-frame-cover-v1.webp",Gritty:"/imgs/musicmake/sample-05-v2.webp"},Q={Genre:{"Hip-Hop":"/imgs/album-cover-generator/genre-hip-hop-wide-v1.webp"},"Visual Style":{Photo:"/imgs/album-cover-generator/style-photo-wide-v1.webp"}};function K(e){if(!e)return null;try{return JSON.parse(e)}catch(e){return console.warn("Failed to parse task result:",e),null}}function Z(e){if(!e)return[];if("string"==typeof e.resultJson&&e.resultJson.trim().length>0)try{let t=JSON.parse(e.resultJson);if(Array.isArray(t.resultUrls))return t.resultUrls.filter(e=>"string"==typeof e)}catch(e){console.warn("Failed to parse provider resultJson:",e)}if(Array.isArray(e.resultUrls))return e.resultUrls.filter(e=>"string"==typeof e);let t=e.output??e.images??e.data;if(!t)return[];if("string"==typeof t)return[t];if(Array.isArray(t))return t.flatMap(e=>{if(!e)return[];if("string"==typeof e)return[e];if("object"==typeof e){let t=e.url??e.uri??e.image??e.src??e.imageUrl;return"string"==typeof t?[t]:[]}return[]}).filter(Boolean);if("object"==typeof t){let e=t.url??t.uri??t.image??t.src??t.imageUrl;return"string"==typeof e?[e]:[]}return[]}function ee(e){return Array.from(new Set(e.filter(Boolean)))}function et(e){let t=String(e||"");return t.includes("insufficient credits")?"Insufficient credits. Please top up to keep creating.":t.includes("no auth")?"Please sign in to generate a cover.":t.includes("database migration")||t.includes("Failed query")||t.includes("insert into")||t.includes("ai_task")?"Could not create the generation task. Please refresh after the database migration is applied.":t||"Cover generation failed. Please try again."}function er(e,t={}){return{id:`text-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,text:e,x:50,y:50,fontSize:46,fontFamily:q[0].value,color:"#f8f1df",bold:!0,align:"center",rotation:0,...t}}async function ea(e){let t=e.startsWith("http")?`/api/proxy/file?url=${encodeURIComponent(e)}`:e,r=await fetch(t);if(!r.ok)throw Error("Failed to load cover image");let a=await r.blob(),i=URL.createObjectURL(a);try{return await new Promise((e,t)=>
1{let r=new window.Image;r.onload=()=>e(r),r.onerror=()=>t(Error("Failed to decode cover image")),r.src=i})}finally{setTimeout(()=>URL.revokeObjectURL(i),500)}}async function ei({backgroundUrl:e,textLayers:t,showExplicitLabel:r,explicitLabelStyle:a,explicitLabelPlacement:i,showCoverBorder:n,coverBorderColor:o,coverBorderWidth:s}){let l,d,c,u,m,g=document.createElement("canvas");g.width=3e3,g.height=3e3;let p=g.getContext("2d");if(!p)throw Error("Canvas is not available");p.fillStyle="#080604",p.fillRect(0,0,3e3,3e3);let b=await ea(e);l=b.naturalWidth/b.naturalHeight,d=b.naturalWidth,c=b.naturalHeight,u=0,m=0,l>1?(d=+b.naturalHeight,u=(b.naturalWidth-d)/2):(c=b.naturalWidth/1,m=(b.naturalHeight-c)/2),p.drawImage(b,u,m,d,c,0,0,3e3,3e3);let h=_.find(e=>e.value===a);if(t.forEach(e=>{if(!e.text.trim())return;let t=5*e.fontSize,r=e.x/100*3e3,a=e.y/100*3e3;p.save(),p.translate(r,a),p.rotate(e.rotation*Math.PI/180),p.font=`${e.bold?800:500} ${t}px ${e.fontFamily}`,p.fillStyle=e.color,p.textAlign=e.align,p.textBaseline="middle",p.shadowColor="rgba(0, 0, 0, 0.55)",p.shadowBlur=28,p.shadowOffsetY=10,p.fillText(e.text,0,0,2580),p.restore()}),r&&h){let e,t,r,a,n=await ea(h.image);e=i.width/100*3e3,t=n.naturalHeight/n.naturalWidth*e,r=i.x/100*3e3,a=i.y/100*3e3,p.save(),p.drawImage(n,r,a,e,t),p.restore(
1)}if(n&&s>0){let e=Math.max(1,Math.round(5*s)),t=e/2;p.save(),p.strokeStyle=o,p.lineWidth=e,p.lineJoin="miter",p.strokeRect(t,t,3e3-e,3e3-e),p.restore()}return new Promise((e,t)=>{g.toBlob(r=>{r?e(r):t(Error("Failed to export cover"))},"image/png")})}async function en(e){let t=new FormData;t.append("files",new File([e],"makebpm-cover-canvas.png",{type:"image/png"}));let r=await fetch("/api/storage/upload-image",{method:"POST",body:t});if(!r.ok)throw Error("Failed to upload cover canvas");let a=await r.json(),i=a?.data?.urls?.[0];if(0!==a.code||!i)throw Error(a.message||"Failed to upload cover canvas");return i}async function eo(e){let t=e.startsWith("http")?`/api/proxy/file?url=${encodeURIComponent(e)}`:e,r=await fetch(t);if(!r.ok)throw Error("Failed to prepare current background");let a=await r.blob(),i=a.type.includes("webp")?"webp":a.type.includes("jpeg")?"jpg":a.type.includes("png")?"png":"webp",n=new FormData;n.append("files",new File([a],`makebpm-background-reference.${i}`,{type:a.type||"image/webp"}));let o=await fetch("/api/storage/upload-image",{method:"POST",body:n});if(!o.ok)throw Error("Failed to upload current background");let s=await o.json(),l=s?.data?.urls?.[0];if(0!==s.code||!l)throw Error(s.message||"Failed to upload current background");return l}function es(e){return e.toLowerCase().replace(/&/g,"and").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function el(e,t){return"Genre"===e?X[t]||`/imgs/music-genres/${es(t)}-ai2.webp`:"Mood"===e?Y[t]||`/imgs/music-moods/${es(t)}-ai2.webp`:J[t]||"/imgs/musicmake/sample-01-v2.webp"}function ed(e){return{...e,textLayers:e.textLayers.map(e=>({...e})),explicitLabelPlacement:{...e.explicitLabelPlacement}}}function ec(e){return JSON.stringify(e)}function eu(){let[e,t]=(0,i.useState)(""),[r,J]=(0,i.useState)(""),[X,Y]=(0,i.useState)(""),[ea,es]=(0,i.useState)("Single"),[eu,em]=(0,i.useState)(1),[eg,ep]=(0,i.useState)("Hip-Hop"),[eb,eh]=(0,i.useState)("Dark"),[ex,ef]=(0,i.useState)("Photo"),[ev,ew]=(0,i.useState)(null),[ey,ej]=(0,i.useState)(""),[ek,eN]=(0,i.useState)([]),[eC,eS]=(0,i.useState)([]),[eE,ez]=(0,i.useState)([]),[eL,eP]=(0,i.useState)(""),[eM,eI]=(0,i.useState)([]),[eR,eB]=(0,i.useState)(null),[e$,eF]=(0,i.useState)(!1),[eA,eD]=(0,i.useState)("classic"),[eT,eU]=(0,i.useState)(O),[eG,eO]=(0,i.useState)(!1),[eq,e_]=(0,i.useState)(!1),[eV,eW]=(0,i.useState)("#f8f1df"),[eH,eJ]=(0,i.useState)(8),[eX,eY]=(0,i.useState)([]),[eQ,eK]=(0,i.useState)([]),[eZ,e0]=(0,i.useState)(!1),[e1,e2]=(0,i.useState)(""),[e5,e3]=(0,i.useState)(!1),[e8,e4]=(0,i.useState)("background"),[e6,e7]=(0,i.useState)(0),[e9,te]=(0,i.useState)(null),[tt,tr]=(0,i.useState)(null),[ta,ti]=(0,i.useState)(null),[tn,to]=(0,i.useState)(!1),[ts,tl]=(0,i.useState)(!1),[td,tc]=(0,i.useState)(!1),[tu,tm]=(0,i.useState)(48),[tg,tp]=(0,i.useState)(!1),[tb,th]=(0,i.useState)(54),[tx,tf]=(0,i.useState)(!1),[tv,tw]=(0,i.useState)(600),ty=(0,i.useRef)(null),tj=(0,i.useRef)(null),tk=(0,i.useRef)(null),tN=(0,i.useRef)(!1),{user:tC,isCheckSign:tS,setIsShowSignModal:tE,fetchUserCredits:tz}=(0,T.useAppContext)(),tL=(0,i.useMemo)(()=>({canvasBackgroundUrl:eL,textLayers:eM,showExplicitLabel:e$,explicitLabelStyle:eA,explicitLabelPlacement:eT,showCoverBorder:eq,coverBorderColor:eV,coverBorderWidth:eH}),[eL,eV,eH,eT,eA,eq,e$,eM]);(0,i.useEffect)(()=>{tc(!0)},[]),(0,i.useEffect)(()=>{let e=ed(tL);if(tN.current){tN.current=!1,tk.current=e;return}let t=tk.current;if(!t||!t.canvasBackgroundUrl&&0===t.textLayers.length){tk.current=e;return}ec(t)!==ec(e)&&(eY(e=>[...e.slice(-59),ed(t)]),eK([]),tk.current=e)},[tL]),(0,i.useEffect)(()=>{let e=ty.current;if(!e||"undefined"==typeof ResizeObserver)return;let t=()=>{let t=e.getBoundingClientRect(),r=Math.max(1,Math.min(t.width,t.height));tw(e=>Math.abs(e-r)>.5?r:e)},r=new ResizeObserver(t);return t(),r.observe(e),()=>r.disconnect()},[]),(0,i.useEffect)(()=>{},[X,eL,r,eM.length]);let tP=(ek.length>0||eC.length>0?4:2)*eu,tM=tC?.credits?.remainingCredits??0,tI=e.trim().length,tR=tI>2e3,tB={Genre:eg,Mood:eb,"Visual Style":ex},t$=(0,i.useMemo)(()=>ta?ta===M.PENDING?"blend"===e8?"Preparing AI text blend":"regenerate"===e8?"Preparing background variation":"Preparing your cover background":ta===M.PROCESSING?"blend"===e8?"Blending text into artwork":"regenerate"===e8?"Regenerating background from reference":"Generating cover background concepts":ta===M.SUCCESS?"Cover generation complete":ta===M.FAILED?"Generation failed":"":"",[e8,ta]),tF=(0,i.useCallback)(e=>{eN(e),eS(e.filter(e=>"uploaded"===e.status&&e.url).map(e=>e.url))},[]),tA=(0,i.useMemo)(()=>ek.some(e=>"uploading"===e.status),[ek]),tD=(0,i.useMemo)(()=>ek.some(e=>"error"===e.status),[ek]),tT=(0,i.useCallback)(()=>{e3(!1),tl(!1),e7(0),te(null),tr(null),ti(null)},[]),tU=(0,i.useCallback)((e,t,a,i=e8)=>{let n=e.map((e,r)=>({id:`${t}-${r}`,url:e,prompt:a??void 0}));if(ez(e=>{let t=new Set,r=n.filter(e=>!t.has(e.url)&&(t.add(e.url),!0));return"blend"===i||"regenerate"===i?[...r,...e].filter((e,t,r)=>r.findIndex(t=>t.url===e.url)===t):r}),"background"===i&&n[0]?.url){eP(n[0].url);let e=[er(r.trim()||"Release Title",{y:73,fontSize:54,bold:!0}),er(X.trim()||"Artist Name",{y:84,fontSize:24,bold:!1}
1)];eI(e),eB(e[0]?.id??null)}"regenerate"===i&&n[0]?.url&&eP(n[0].url)},[X,e8,r]),tG=(0,i.useCallback)(async e=>{try{if(tt&&Date.now()-tt>18e4)return tT(),L.toast.error("Cover generation timed out. Please try again."),!0;let t=await fetch("/api/ai/query",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({taskId:e})});if(!t.ok)throw Error(`request failed with status: ${t.status}`);let{code:r,message:a,data:i}=await t.json();if(0!==r)throw Error(a||"Query task failed");let n=i.status,o=K(i.taskInfo),s=K(i.taskResult),l=ee([...Z(o),...Z(s)]);if(ti(n),n===M.PENDING)return e7(e=>Math.max(e,20)),!1;if(n===M.PROCESSING)return l.length>0?(tU(l,i.id,i.prompt,e8),e7(e=>Math.max(e,85))):e7(e=>Math.min(e+10,80)),!1;if(n===M.SUCCESS)return 0===l.length?L.toast.error("The provider returned no images. Please retry."):(tU(l,i.id,i.prompt,e8),L.toast.success("blend"===e8?"AI blended cover generated":"regenerate"===e8?"Background variation generated":"Album cover background generated")),e7(100),tT(),await tz(),!0;if(n===M.FAILED){let e=o?.errorMessage||"Generate album cover failed";return L.toast.error(e),tT(),await tz(),!0}return e7(e=>Math.min(e+5,95)),!1}catch(e){return console.error("Error polling album cover task:",e),L.toast.error(`Query task failed: ${e.message}`),tT(),await tz(),!0}},[tU,tz,e8,tt,tT]);(0,i.useEffect)(()=>{if(!e9||!e5)return;let e=!1;(async()=>{!e9||await tG(e9)&&(e=!0)})();let t=setInterval(async()=>{e||!e9?clearInterval(t):await tG(e9)&&clearInterval(t)},5e3);return()=>{e=!0,clearInterval(t)}},[e5,tG,e9]);let tO=async()=>{let t;if(!tC)return void tE(!0);if(tM<tP)return void L.toast.error("Insufficient credits. Please top up to keep creating.");if(!e.trim())return void L.toast.error("Please describe your album cover idea first.");if(tR)return void L.toast.error("Please shorten the cover description before generating.");let a=(t=e.trim(),[`Create a square album cover background artwork concept for a ${ea.toLowerCase()} music release.`,"\nRelease context:",`Release title: ${r.trim()||"Untitled"}`,`Artist name: ${X.trim()||"Unknown artist"}`,"\nVisual idea:",t,"\nMusic context:",`Genre: ${eg}`,`Mood: ${eb}`,`Visual style: ${ex}`,"\nDesign requirements:\nUse one clear focal subject. Make the cover readable as a small thumbnail. Create a polished music release cover composition. Leave clean negative space for title and artist text that will be added later. Do not include readable text, logos, platform icons, celebrity likenesses, copyrighted characters, or existing album cover designs. Avoid generic AI-art look."].join("\n"));e4("background"),e3(!0),tl(!1),e7(15),ti(M.PENDING),ez([]),tr(Date.now());try{let e={aspect_ratio:"1:1",output_format:"png",output_quantity:eu};eC.length>0&&(e.image_input=eC);let t=await fetch("/api/ai/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mediaType:P.IMAGE,scene:eC.length>0?"image-to-image":"text-to-image",provider:"kie",model:G,prompt:a,options:e})});if(!t.ok)throw Error(`request failed with status: ${t.status}`);let{code:r,message:i,data:n}=await t.json();if(0!==r)throw Error(i||"Failed to create an album cover task");let o=n?.id;if(!o)throw Error("Task id missing in response");if(n.status===M.SUCCESS){let e=K(n.taskInfo),t=K(n.taskResult),r=ee([...Z(e),...Z(t)]);if(r.length>0){tU(r,o,a,"background"),L.toast.success("Album cover background generated"),e7(100),tT(),await tz();return}}te(o),e7(25),await tz()}catch(e){console.error("Failed to generate album cover:",e),L.toast.error(et(e.message)),tT()}},tq=async()=>{if(!eL)return void L.toast.error("Generate a cover background first.");if(!e1.trim())return void L.toast.error("Describe what you want to change first.");if(!tC)return void tE(!0);if(tM<4)return void L.toast.error("Insufficient credits. Please top up to keep creating.");let t=["Create a new square album cover background variation from the reference image.\n\nKeep the strongest parts of the current composition, mood, palette, and music release direction unless the change request says otherwise.\nDo not include readable text, logos, platform icons, QR codes, prices, watermarks, celebrity likenesses, copyrighted characters, or existing album cover designs.\nLeave clean negative space for title and artist text that will be added later.\n\nOriginal cover context:",`Release title: ${r.trim()||"Untitled"}`,`Artist name: ${X.trim()||"Unknown artist"}`,`Release type: ${ea}`,`Genre: ${eg}`,`Mood: ${eb}`,`Visual style: ${ex}`,`Original visual idea: ${e.trim()||"Use the reference image direction."}`,"\nChange request:",e1.trim()].join("\n");
1e4("regenerate"),e3(!0),tl(!1),e7(15),ti(M.PENDING),tr(Date.now());try{let e=await eo(eL),r=await fetch("/api/ai/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mediaType:P.IMAGE,scene:"image-to-image",provider:"kie",model:G,prompt:t,options:{aspect_ratio:"1:1",output_format:"png",output_quantity:1,image_input:[e]}})});if(!r.ok)throw Error(`request failed with status: ${r.status}`);let{code:a,message:i,data:n}=await r.json();if(0!==a)throw Error(i||"Failed to create a background variation");let o=n?.id;if(!o)throw Error("Task id missing in response");if(n.status===M.SUCCESS){let e=K(n.taskInfo),r=K(n.taskResult),a=ee([...Z(e),...Z(r)]);if(a.length>0){tU(a,o,t,"regenerate"),L.toast.success("Background variation generated"),e7(100),e0(!1),e2(""),tT(),await tz();return}}te(o),e7(25),e0(!1),e2(""),L.toast.info("Background variation started"),await tz()}catch(e){console.error("Failed to regenerate album cover background:",e),L.toast.error(et(e.message)),tT()}},t_=(0,i.useMemo)(()=>_.find(e=>e.value===eA),[eA]),tV=(0,i.useMemo)(()=>eE.length>1?eE:[],[eE]),tW=e=>{let t=ed(e);tN.current=!0,eP(t.canvasBackgroundUrl),eI(t.textLayers),eF(t.showExplicitLabel),eD(t.explicitLabelStyle),eU(t.explicitLabelPlacement),e_(t.showCoverBorder),eW(t.coverBorderColor),eJ(t.coverBorderWidth),eB(e=>e&&t.textLayers.some(t=>t.id===e)?e:t.textLayers[0]?.id??null)},tH=(e,t)=>{eI(r=>r.map(r=>r.id===e?{...r,...t}:r))},tJ=e=>{let t=ty.current,r=t?.querySelector(`[data-cover-layer-id="${e}"]`);if(!t||!r)return{width:0,height:0};let a=t.getBoundingClientRect(),i=r.getBoundingClientRect();return{width:i.width/a.width*100,height:i.height/a.height*100}},tX=(e,t,r,a=tJ(e.id))=>{let i=a.height/2,n=2,o=98;"center"===e.align?(n=2+a.width/2,o=98-a.width/2):"right"===e.align?(n=2+a.width,o=98):(n=2,o=98-a.width);let s=2+i,l=Math.max(s,98-i);return{x:Number(Math.min(Math.max(n,o),Math.max(n,t)).toFixed(2)),y:Number(Math.min(l,Math.max(s,r)).toFixed(2))}},tY=(e,t)=>{let r=eM.find(t=>t.id===e);if(!r)return;let a={...r,...t};tH(e,tX(a,a.x,a.y))},tQ=async()=>{if(!eL)return void L.toast.error("Generate a cover background first.");to(!0);try{let e=await ei({backgroundUrl:eL,textLayers:eM,showExplicitLabel:e$,explicitLabelStyle:eA,explicitLabelPlacement:eT,showCoverBorder:eq,coverBorderColor:eV,coverBorderWidth:eH}),t=URL.createObjectURL(e),a=document.createElement("a");a.href=t,a.download=`${(r||"makebpm-album-cover").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"makebpm-album-cover"}.png`,document.body.appendChild(a),a.click(),document.body.removeChild(a),setTimeout(()=>URL.revokeObjectURL(t),200),L.toast.success("Cover downloaded")}catch(e){console.error("Failed to download album cover:",e),L.toast.error("Failed to download cover")}finally{to(!1)}},tK=async()=>{if(!tC)return void tE(!0);if(!eL)return void L.toast.error("Generate a cover background first.");if(tM<4)return void L.toast.error("Insufficient credits. Please top up to keep creating.");e4("blend"),e3(!0),tl(!0),e7(15),ti(M.PENDING),tr(Date.now());try{let e=await ei({backgroundUrl:eL,textLayers:eM,showExplicitLabel:e$,explicitLabelStyle:eA,explicitLabelPlacement:eT,showCoverBorder:eq,coverBorderColor:eV,coverBorderWidth:eH}),t=await en(e),a=`Create an integrated final album cover from this edited reference image. 2 3Preserve the square composition, main subject, mood, palette, and release artwork direction. 4Make the visible typography feel native to the artwork, like print, sticker, poster, painted, or photographed album cover design. 5Release title: ${r.trim()||"use the visible title text"} 6Artist name: ${X.trim()||"use the visible artist text"} 7 8Do not add extra words, logos, platform icons, URLs, QR codes, prices, or watermarks. Keep the cover polished and release-ready. If any lettering is visible, keep the spelling as close as possible to the reference image.`,i=await fetch("/api/ai/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mediaType:P.IMAGE,scene:"image-to-image",provider:"kie",model:G,prompt:a,options:{aspect_ratio:"1:1",output_format:"png",image_input:[t]}})});if(!i.ok)throw Error(`request failed with status: ${i.status}`);let{code:n,message:o,data:s}=await i.json();if(0!==n)throw Error(o||"Failed to create an AI blend task");let l=s?.id;if(!l)throw Error("Task id missing in response");if(s.status===M.SUCCESS){let e=K(s.taskInfo),t=K(s.taskResult),r=ee([...Z(e),...Z(t)]);if(r.length>0){tU(r,l,a,"blend"),L.toast.success("AI blended cover generated"),e7(100),tT(),tl(!1),await tz();return}}te(l),e7(25),await tz()}catch(e){console.error("Failed to blend album cover:",e),L.toast.error(et(e.message)),tT(),tl(!1)}},tZ=e=>{let t=ty.current;if(!t)return;e.preventDefault(),e.stopPropagation(),e.currentTarget.setPointerCapture(e.pointerId),eB(null),eO(!0);let r=t.getBoundingClientRect(),a=eT.width,i=e.currentTarget.closest('button[title="Move explicit label"]'),n=i?i.getBoundingClientRect().height/r.height*100:8,o=r.left+(eT.x+eT.width/2)/100*r.width,s=r.top+(eT.y+5)/100*r.height,l=Math.hypot(e.clientX-o,e.clientY-s),d=e=>{let t=Math.min(36,Math.max(10,a+(Math.hypot(e.clientX-o,e.clientY-s)-l)/r.width*120));eU(e=>({...e,width:Number(t.toFixed(2)),x:Number(Math.min(98-t,Math.max(2,e.x)).toFixed(2)),y:Number(Math.min(98-n,Math.max(2,e.y)).toFixed(2))}))},c=()=>{window.removeEventListener("pointermove",d),window.removeEventListener("pointerup",c),window.removeEventListener("pointercancel",c)};window.addEventListener("pointermove",d),window.addEventListener("pointerup",c),window.addEventListener("pointercancel",c)};return(0,a.jsxs)("section",{id:"tool",className:"border-border/50 relative mt-[var(--site-header-height)] flex min-h-[calc(100vh-var(--top-banner-height,0px)-var(--site-header-height,0px))] scroll-mt-36 items-stretch overflow-hidden border-b lg:h-[calc(100vh-var(--top-banner-height,0px)-var(--site-header-height,0px))] lg:min-h-0",children:[(0,a.jsx)("div",{className:"pointer-events-none absolute inset-0 bg-cover bg-center opacity-60 contrast-110 saturate-125",style:{backgroundImage:"url('/imgs/musicmake/hero-background-v2.webp')"}}),(0,a.jsx)("div",{className:"from-background/80 via-background/72 to-background pointer-events-none absolute inset-0 bg-gradient-to-b"}),(0,a.jsx)("div",{className:"bg-primary/15 pointer-events-none absolute top-1/3 left-1/2 h-80 w-80 -translate-x-1/2 roun
8ded-full blur-3xl"}),(0,a.jsxs)("div",{className:"relative z-10 grid min-h-0 w-full grid-cols-1 gap-4 lg:grid-cols-[var(--makebpm-cover-tool-grid-template)] lg:gap-0",style:{"--makebpm-cover-tool-grid-template":`${tu}% 1px minmax(420px,1fr)`},children:[(0,a.jsxs)("div",{className:"border-border/80 bg-card/95 shadow-primary/10 flex min-h-0 flex-col overflow-hidden border shadow-2xl lg:rounded-none",children:[(0,a.jsx)("div",{className:"flex items-center justify-between px-5 py-4",children:(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("span",{className:"bg-primary/15 text-primary flex size-9 items-center justify-center rounded-xl",children:(0,a.jsx)(S.WandSparkles,{className:"size-5"})}),(0,a.jsx)("div",{className:"text-lg font-semibold",children:"AI Album Cover Generator"})]})}),(0,a.jsxs)("div",{className:"min-h-0 flex-1 space-y-4 overflow-visible p-5 pt-0 lg:overflow-y-auto",children:[(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"mb-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("div",{className:"text-sm font-semibold",children:"Reference Image"}),(0,a.jsx)("span",{className:"border-border/70 bg-background/60 text-muted-foreground shrink-0 rounded-full border px-2 py-0.5 text-xs",children:"Optional"})]}),(0,a.jsx)("p",{className:"text-muted-foreground mt-1 text-xs leading-5",children:"Add an image you own to guide the mood, palette, composition, or subject."})]}),(0,a.jsx)(I.ImageUploader,{allowMultiple:!1,maxImages:1,maxSizeMB:5,onChange:tF}),tD&&(0,a.jsx)("p",{className:"text-destructive mt-2 text-xs",children:"Some images failed to upload."})]}),(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("label",{htmlFor:"release-title",className:"text-sm font-semibold",children:"Release Title"}),(0,a.jsx)("input",{id:"release-title",value:r,onChange:e=>J(e.target.value),placeholder:"Late Night Drive",className:"border-border/70 bg-background/50 placeholder:text-muted-foreground h-11 w-full rounded-xl border px-3 text-sm outline-none"})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("label",{htmlFor:"artist-name",className:"text-sm font-semibold",children:"Artist Name"}),(0,a.jsx)("input",{id:"artist-name",value:X,onChange:e=>Y(e.target.value),placeholder:"MakeBPM Artist",className:"border-border/70 bg-background/50 placeholder:text-muted-foreground h-11 w-full rounded-xl border px-3 text-sm outline-none"})]})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("label",{htmlFor:"image-prompt",className:"text-sm font-semibold",children:["Visual Idea ",(0,a.jsx)("span",{className:"text-primary",children:"*"})]}),(0,a.jsxs)("span",{className:"text-muted-foreground text-xs",children:[tI," / ",2e3]})]}),(0,a.jsx)("textarea",{id:"image-prompt",value:e,onChange:e=>t(e.target.value),maxLength:2e3,placeholder:"A lone car under rain-soaked streetlights, deep blue and silver, cinematic film grain, quiet late-night mood",className:"border-border/80 bg-background/60 placeholder:text-muted-foreground min-h-36 w-full resize-none rounded-xl border p-4 text-sm leading-6 outline-none"}),tR&&(0,a.jsxs)("p",{className:"text-destructive mt-2 text-xs",children:["Please keep the description under ",2e3," characters."]})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("label",{className:"text-sm font-semibold",children:"Release Type"}),(0,a.jsxs)(A.Select,{value:ea,onValueChange:es,children:[(0,a.jsx)(A.SelectTrigger,{className:"border-border/70 bg-background/50 h-11 w-full rounded-xl",children:(0,a.jsx)(A.SelectValue,{placeholder:"Select release type"})}),(0,a.jsx)(A.SelectContent,{children:V.map(e=>(0,a.jsx)(A.SelectItem,{value:e,children:e},e))})]})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("label",{className:"text-sm font-semibold",children:"Backgroun
8d Image Count"}),(0,a.jsxs)("span",{className:"text-muted-foreground text-xs",children:["Generate ",eu," images"]})]}),(0,a.jsx)("div",{className:"grid grid-cols-4 gap-2",children:W.map(e=>(0,a.jsx)("button",{type:"button",onClick:()=>em(e),className:(0,U.cn)("border-border/70 bg-background/40 hover:border-primary/70 h-9 rounded-lg border text-sm font-medium transition",eu===e&&"border-primary bg-primary text-primary-foreground"),children:e},e))})]}),(0,a.jsx)("div",{className:"space-y-2",children:(0,a.jsx)("div",{className:"grid grid-cols-3 gap-2",children:["Genre","Mood","Visual Style"].map(e=>{let t=tB[e];return(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)("p",{className:"text-foreground text-xs font-semibold",children:e}),(0,a.jsxs)("div",{className:"border-border/70 relative h-24 overflow-hidden rounded-lg border bg-black",children:[(0,a.jsx)(z.default,{src:Q[e]?.[t]||el(e,t),alt:`${t} ${e.toLowerCase()} album cover direction`,fill:!0,sizes:"160px",className:"object-cover brightness-125 contrast-110 saturate-125"}),(0,a.jsx)("span",{className:"absolute inset-0 bg-gradient-to-t from-black/70 via-black/10 to-transparent"}),(0,a.jsx)("span",{className:"absolute right-10 bottom-2 left-3 min-w-0 truncate text-xs font-semibold text-white drop-shadow",children:t}),(0,a.jsx)("button",{type:"button",onClick:()=>{ew(e),ej("")},"aria-label":`Change ${e}`,title:`Change ${e}`,className:"bg-secondary text-muted-foreground hover:bg-primary hover:text-primary-foreground absolute right-2 bottom-2 flex size-8 shrink-0 items-center justify-center rounded-lg bg-black/45 text-white backdrop-blur transition",children:(0,a.jsx)(f.RefreshCw,{className:"size-3.5"})})]})]},e)})})})]}),(0,a.jsxs)("div",{className:"border-border/70 relative flex items-center justify-between gap-3 border-t p-4",children:[(0,a.jsxs)("span",{className:"text-muted-foreground flex shrink-0 items-center gap-1.5 text-xs",children:[(0,a.jsx)(u.Coins,{className:"text-primary size-4"}),tP," credits",tC&&(0,a.jsxs)("span",{className:"hidden sm:inline",children:["· ",tM," remaining"]})]}),!td||tS?(0,a.jsxs)(B.Button,{className:"ml-auto h-11 w-auto px-8",disabled:!0,children:[(0,a.jsx)(b.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),td?"Checking account":"Loading"]}):tC?(0,a.jsx)(B.Button,{className:"ml-auto h-11 w-auto px-8",onClick:tO,disabled:e5||!e.trim()||tR||tA||tD,children:e5?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(b.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"blend"===e8?"Blending...":"Generating..."]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.WandSparkles,{className:"mr-2 h-4 w-4"}),"Generate Cover Background"]})}):(0,a.jsxs)(B.Button,{className:"ml-auto h-11 w-auto px-8",onClick:()=>tE(!0),children:[(0,a.jsx)(C.User,{className:"mr-2 h-4 w-4"}),"Sign in to generate"]}),e5&&(0,a.jsxs)("div",{className:"border-border/70 bg-background/35 absolute right-4 bottom-20 left-4 space-y-2 rounded-xl border p-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,a.jsx)("span",{children:t$||"Generating cover"}),(0,a.jsxs)("span",{children:[e6,"%"]})]}),(0,a.jsx)(F.Progress,{value:e6})]})]})]}),(0,a.jsx)("button",{type:"button",onPointerDown:e=>{let t=e.currentTarget.parentElement;if(!t)return;e.currentTarget.setPointerCapture(e.pointerId),tp(!0);let r=e=>{let r=t.getBoundingClientRect(),a=(e-r.left)/r.width*100,i=420/r.width*100;tm(Number(Math.min(100-i,Math.max(i,a)).toFixed(2)))};r(e.clientX);let a=e=>{r(e.clientX)},i=()=>{tp(!1),window.removeEventListener("pointermove",a),window.removeEventListener("pointerup",i),window.removeEventListener("pointercancel",i)};window.addEventListener("pointermove",a),window.addEventListener("pointerup",i),window.addEventListener("pointercancel",i)},"aria-label":"Resize album cover tool panels",title:"Drag to resize panels",className:(0,U.cn)("group bg-border/60 hover:bg-primary/50 relative z-20 hidden h-full cursor-col-resize items-stretch justify-center transition lg:flex",'before:absolute before:inset-y-0 before:-right-3 before:-left-3 before:content-[""]',tg&&"bg-primary/70"),children:(0,a.jsx)("span",{className:"border-border bg-card/95 group-hover:border-primary/70 absolute top-1/2 left-1/2 flex h-11 w-3 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full border shadow-lg transition",children:(0,a.jsx)("span",{className:"bg-muted-foreground
8/45 group-hover:bg-primary h-5 w-px rounded-full transition"})})}),(0,a.jsxs)("div",{className:"border-border/80 bg-card/95 shadow-primary/10 flex min-h-0 flex-col overflow-hidden border shadow-2xl lg:rounded-none",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 px-5 py-4",children:[(0,a.jsx)("span",{className:"bg-primary/15 text-primary flex size-9 items-center justify-center rounded-xl",children:(0,a.jsx)(g.ImageIcon,{className:"size-5"})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-lg font-semibold",children:"Cover Canvas"}),(0,a.jsx)("p",{className:"text-muted-foreground text-xs",children:"Edit release text, explicit label, and final export."})]})]}),(0,a.jsxs)("div",{ref:tj,className:"flex min-h-0 flex-1 flex-col",children:[(0,a.jsxs)("div",{className:"relative flex min-h-[15rem] shrink-0 items-center justify-center px-5 pb-4",style:{flex:`0 0 ${tb}%`},children:[eL&&(0,a.jsx)(B.Button,{type:"button",variant:"outline",size:"sm",onClick:()=>e0(!0),disabled:!td||tS||e5||!eL,title:"Regenerate background","aria-label":"Regenerate background",className:"border-primary/35 bg-card/75 hover:bg-primary hover:text-primary-foreground absolute top-3 right-5 z-30 size-9 rounded-full border p-0 shadow-lg backdrop-blur",children:e5&&"background"===e8?(0,a.jsx)(b.Loader2,{className:"size-4 animate-spin"}):(0,a.jsx)(f.RefreshCw,{className:"size-4"})}),(0,a.jsx)("div",{className:"mx-auto flex h-full w-full items-center justify-center",children:(0,a.jsx)("div",{ref:ty,className:(0,U.cn)("relative aspect-square h-[min(100%,30rem)] max-h-full max-w-full overflow-hidden",eL&&"border-border/70 bg-background/35 border shadow-2xl shadow-black/25"),children:eL?(0,a.jsxs)("div",{className:"absolute top-0 left-0 origin-top-left overflow-hidden",style:{width:600,height:600,transform:`scale(${tv/600})`},children:[(0,a.jsx)("img",{src:eL,alt:"Editable album cover background",className:"absolute inset-0 h-full w-full object-cover"}),eM.map(e=>(0,a.jsxs)("button",{type:"button","data-cover-layer-id":e.id,onPointerDown:t=>((e,t)=>{let r=ty.current,a=eM.find(e=>e.id===t);if(!r||!a)return;e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),eB(t),eO(!1);let i=(e,i)=>{let n=r.getBoundingClientRect(),o=tX(a,(e-n.left)/n.width*100,(i-n.top)/n.height*100,tJ(t));tH(t,o)};i(e.clientX,e.clientY);let n=e=>{i(e.clientX,e.clientY)},o=()=>{window.removeEventListener("pointermove",n),window.removeEventListener("pointerup",o),window.removeEventListener("pointercancel",o)};window.addEventListener("pointermove",n),window.addEventListener("pointerup",o),window.addEventListener("pointercancel",o)})(t,e.id),onClick:()=>eB(e.id),className:(0,U.cn)("group absolute max-w-[86%] touch-none border border-transparent px-3 py-1.5 text-shadow-lg outline-none transition",eR===e.id&&"border-primary bg-black/15 ring-primary/25 ring-2"),style:{left:`${e.x}%`,top:`${e.y}%`,transform:`${"center"===e.align?"translate(-50%, -50%)":"right"===e.align?"translate(-100%, -50%)":"translate(0, -50%)"} rotate(${e.rotation}deg)`,color:e.color,fontSize:`${e.fontSize}px`,fontFamily:e.fontFamily,fontWeight:e.bold?800:500,textAlign:e.align},children:[(0,a.jsx)("span",{className:"block truncate drop-shadow-[0_3px_12px_rgba(0,0,0,0.8)]",children:e.text||"Text"}),eR===e.id&&(0,a.jsxs)(a.Fragment,{children:[["top-1 left-1","top-1 right-1","bottom-1 left-1","right-1 bottom-1"].map(t=>(0,a.jsx)("span",{onPointerDown:t=>((e,t)=>{let r=ty.current,a=eM.find(e=>e.id===t);if(!r||!a)return;e.preventDefault(),e.stopPropagation(),e.currentTarget.setPointerCapture(e.pointerId),eB(t),eO(!1);let i=r.getBoundingClientRect(),n=i.left+a.x/100*i.width,o=i.top+a.y/100*i.height,s=Math.hypot(e.clientX-n,e.clientY-o),l=a.fontSize,d=e=>{tH(t,{fontSize:Math.round(Math.min(120,Math.max(12,l+(Math.hypot(e.clientX-n,e.clientY-o)-s)*.18)))}),requestAnimationFrame(()=>tY(t))},c=()=>{window.removeEventListener("pointermove",d),window.removeEventListener("pointerup",c),window.removeEventListener("pointercancel",c)};window.addEventListener("pointermove",d),window.addEventListener("pointerup",c),window.addEventListener("pointercancel",c)})(t,e.id),className:(0,U.cn)("border-primary bg-background absolute size-3 rounded-full border shadow-sm",t)},t)),(0,a.jsx)("span",{className:"bg-primary/80 absolute left-1/2 -top-3 h-3 w-px -translate-x-1/2 roun
8ded-full"}),(0,a.jsx)("span",{onPointerDown:t=>((e,t)=>{let r=eM.find(e=>e.id===t),a=ty.current?.querySelector(`[data-cover-layer-id="${t}"]`);if(!r||!a)return;e.preventDefault(),e.stopPropagation(),e.currentTarget.setPointerCapture(e.pointerId),eB(t),eO(!1);let i=e.clientX,n=r.rotation,o=e=>{tH(t,{rotation:Math.round((n+(e.clientX-i)*.35+360)%360)})},s=()=>{window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",s),window.removeEventListener("pointercancel",s)};window.addEventListener("pointermove",o),window.addEventListener("pointerup",s),window.addEventListener("pointercancel",s)})(t,e.id),className:"border-primary bg-background text-primary absolute left-1/2 -top-10 z-20 flex size-7 -translate-x-1/2 items-center justify-center rounded-full border shadow-sm",title:"Rotate",children:(0,a.jsx)(y.default,{className:"size-3.5"})})]})]},e.id)),e$&&t_&&(0,a.jsxs)("button",{type:"button",onPointerDown:e=>{let t=ty.current;if(!t)return;e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),eB(null),eO(!0);let r=t.getBoundingClientRect(),a=eT.x,i=eT.y,n=eT.width,o=e.currentTarget.getBoundingClientRect().height/r.height*100,s=e.clientX,l=e.clientY,d=e=>{var t,d;let c,u,m,g;t=e.clientX,d=e.clientY,c=(t-s)/r.width*100,u=(d-l)/r.height*100,m=Math.min(98-n,Math.max(2,a+c)),g=Math.min(98-o,Math.max(2,i+u)),eU(e=>({...e,x:Number(m.toFixed(2)),y:Number(g.toFixed(2))}))},c=()=>{window.removeEventListener("pointermove",d),window.removeEventListener("pointerup",c),window.removeEventListener("pointercancel",c)};window.addEventListener("pointermove",d),window.addEventListener("pointerup",c),window.addEventListener("pointercancel",c)},onClick:()=>{eB(null),eO(!0)},className:(0,U.cn)("absolute touch-none overflow-visible border border-transparent shadow-lg outline-none transition",eG&&"border-primary bg-black/10 ring-primary/25 ring-2"),style:{left:`${eT.x}%`,top:`${eT.y}%`,width:`${eT.width}%`},title:"Move explicit label",children:[(0,a.jsx)("img",{src:t_.image,alt:`${t_.label} explicit label`,className:"h-auto w-full"}),eG&&["top-1 left-1","top-1 right-1","bottom-1 left-1","right-1 bottom-1"].map(e=>(0,a.jsx)("span",{onPointerDown:tZ,className:(0,U.cn)("border-primary bg-background absolute size-3 rounded-full border shadow-sm",e)},e))]}),eq&&eH>0&&(0,a.jsx)("div",{className:"pointer-events-none absolute inset-0 z-30",style:{border:`${eH}px solid ${eV}`,borderRadius:0}})]}):(0,a.jsxs)("div",{className:"flex h-full flex-col items-center justify-center px-8 text-center",children:[(0,a.jsx)("div",{className:"bg-primary/10 text-primary mb-5 flex size-16 items-center justify-center rounded-full",children:e5?(0,a.jsx)(b.Loader2,{className:"size-8 animate-spin"}):(0,a.jsx)(g.ImageIcon,{className:"size-8"})}),(0,a.jsx)("p",{className:"text-muted-foreground max-w-sm leading-6",children:e5?"Preparing your cover preview.":"Preview your cover here after generating a background."})]})})})]}),(0,a.jsx)("button",{type:"button",onPointerDown:e=>{let t=tj.current;if(!t)return;e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),tf(!0);let r=e=>{let r=t.getBoundingClientRect();th(Number(Math.min(72,Math.max(34,(e-r.top)/r.height*100)).toFixed(2)))};r(e.clientY);let a=e=>{r(e.clientY)},i=()=>{tf(!1),window.removeEventListener("pointermove",a),window.removeEventListener("pointerup",i),window.removeEventListener("pointercancel",i)};window.addEventListener("pointermove",a),window.addEventListener("pointerup",i),window.addEventListener("pointercancel",i)},"aria-label":"Resize cover canvas preview and edit options",title:"Drag to resize preview and edit options",className:(0,U.cn)("group bg-border/60 hover:bg-primary/50 relative z-20 flex h-px shrink-0 cursor-row-resize items-center justify-center transition",'before:absolute before:-inset-y-3 before:inset-x-0 before:content-[""]',tx&&"bg-primary/70"),style:{cursor:"row-resize"},children:(0,a.jsx)("span",{className:"border-border bg-card/95 group-hover:border-primary/70 absolute left-1/2 flex h-3 w-11 -translate-x-1/2 items-center justify-center rounded-full border shadow-lg transition",children:(0,a.jsx)("span",{className:"bg-muted-foreground
8/45 group-hover:bg-primary h-px w-5 rounded-full transition"})})}),eL&&(0,a.jsxs)("div",{className:"border-border/60 bg-card/95 flex shrink-0 items-center justify-between border-y px-5 py-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"text-sm font-semibold",children:"Edit Options"}),(0,a.jsx)("p",{className:"text-muted-foreground text-xs",children:"Choose backgrounds, labels, and text settings."})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(B.Button,{type:"button",size:"icon",variant:"ghost",title:"Undo","aria-label":"Undo edit",disabled:0===eX.length,onClick:()=>{let e=eX.at(-1);e&&(eY(e=>e.slice(0,-1)),eK(e=>[ed(tL),...e.slice(0,59)]),tW(e))},className:"border-border/60 bg-background/25 hover:bg-background/60 size-8 rounded-lg border",children:(0,a.jsx)(N.default,{className:"size-3.5"})}),(0,a.jsx)(B.Button,{type:"button",size:"icon",variant:"ghost",title:"Redo","aria-label":"Redo edit",disabled:0===eQ.length,onClick:()=>{let e=eQ[0];e&&(eK(e=>e.slice(1)),eY(e=>[...e.slice(-59),ed(tL)]),tW(e))},className:"border-border/60 bg-background/25 hover:bg-background/60 size-8 rounded-lg border",children:(0,a.jsx)(v.default,{className:"size-3.5"})})]})]}),(0,a.jsxs)("div",{className:"makebpm-scrollbar min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4",children:[tV.length>0&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("p",{className:"text-xs font-semibold",children:"Backgroun
8d Candidates"}),(0,a.jsx)("div",{className:"grid grid-cols-4 gap-2",children:tV.map(e=>(0,a.jsxs)("button",{type:"button",onClick:()=>eP(e.url),className:(0,U.cn)("border-border/70 relative aspect-square overflow-hidden rounded-lg border bg-black transition",eL===e.url&&"border-primary ring-primary/30 ring-2"),children:[(0,a.jsx)(R.LazyImage,{src:e.url,alt:e.prompt||"Album cover background candidate",className:"h-full w-full object-cover"}),(0,a.jsx)("span",{className:"absolute inset-x-0 bottom-0 bg-black/65 px-2 py-1 text-[10px] font-medium text-white",children:eL===e.url?"Current Background":"Use Background"})]},e.id))})]}),eL&&(0,a.jsxs)("div",{className:"border-border/70 bg-background/35 space-y-4 rounded-2xl border p-4",children:[(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,a.jsx)("p",{className:"text-muted-foreground text-[11px] font-semibold tracking-wide uppercase",children:"Text"}),(0,a.jsxs)(B.Button,{type:"button",variant:"ghost",size:"sm",onClick:()=>{let e=er("New Text",{y:50+Math.min(8*eM.length,28),fontSize:30,bold:!1});eI(t=>[...t,e]),eB(e.id)},className:"border-border/70 bg-background/25 hover:bg-background/60 h-7 rounded-lg border px-2 text-xs",children:[(0,a.jsx)(x.Plus,{className:"mr-1 size-3.5"}),"Add Text"]})]}),(0,a.jsx)("div",{className:"space-y-2",children:eM.map(e=>(0,a.jsxs)("div",{onClick:()=>eB(e.id),className:(0,U.cn)("border-border/70 bg-background/35 space-y-2 rounded-xl border p-2 transition",eR===e.id&&"border-primary/80 bg-primary/5"),children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)(B.Button,{type:"button",size:"icon",variant:"ghost",title:"Smaller",onClick:t=>{t.stopPropagation(),tH(e.id,{fontSize:Math.max(12,e.fontSize-4)}),requestAnimationFrame(()=>tY(e.id))},className:"border-border/60 bg-background/25 hover:bg-background/60 size-8 shrink-0 rounded-lg border",children:(0,a.jsx)(h.default,{className:"size-3.5"})}),(0,a.jsx)(B.Button,{type:"button",size:"icon",variant:"ghost",title:"Larger",onClick:t=>{t.stopPropagation(),tH(e.id,{fontSize:Math.min(120,e.fontSize+4)}),requestAnimationFrame(()=>tY(e.id))},className:"border-border/60 bg-background/25 hover:bg-background/60 size-8 shrink-0 rounded-lg border",children:(0,a.jsx)(x.Plus,{className:"size-3.5"})}),(0,a.jsx)("input",{value:e.text,onChange:t=>{tH(e.id,{text:t.target.value}),requestAnimationFrame(()=>tY(e.id))},onClick:e=>e.stopPropagation(),className:"border-border/70 bg-background/60 h-8 min-w-0 flex-1 rounded-lg border px-2.5 text-sm outline-none"}),(0,a.jsx)(B.Button,{type:"button",size:"icon",variant:"ghost",title:"Rotate left",onClick:t=>{t.stopPropagation(),tH(e.id,{rotation:(e.rotation+355)%360})},className:"border-border/60 bg-background/25 hover:bg-background/60 size-8 shrink-0 rounded-lg border",children:(0,a.jsx)(w.RotateCcw,{className:"size-3.5"})}),(0,a.jsx)(B.Button,{type:"button",size:"icon",variant:"ghost",title:"Rotate right",onClick:t=>{t.stopPropagation(),tH(e.id,{rotation:(e.rotation+5)%360})},className:"border-border/60 bg-background/25 hover:bg-background/60 size-8 shrink-0 rounded-lg border",children:(0,a.jsx)(y.default,{className:"size-3.5"})})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,a.jsxs)(A.Select,{value:e.fontFamily,onValueChange:t=>{tH(e.id,{fontFamily:t}),requestAnimationFrame(()=>tY(e.id))},children:[(0,a.jsx)(A.SelectTrigger,{onClick:e=>e.stopPropagation(),className:"h-8 w-[132px] rounded-lg text-xs",children:(0,a.jsx)(A.SelectValue,{})}),(0,a.jsx)(A.SelectContent,{children:q.map(e=>(0,a.jsx)(A.SelectItem,{value:e.value,children:e.label},e.value))})]}),(0,a.jsx)("input",{type:"color",value:e.color,onChange:t=>tH(e.id,{color:t.target.value}),onClick:e=>e.stopPropagation(),className:"border-border/70 bg-background h-8 w-9 rounded-lg border p-1",title:"Text color"}),(0,a.jsxs)(B.Button,{type:"button",size:"sm",variant:"ghost",onClick:t=>{t.stopPropagation(),tH(e.id,{bold:!e.bold})},className:(0,U.cn)("border-border/60 bg-background/25 hover:bg-background/60 h-8 rounded-lg border px-2.5 text-xs",e.bold&&"text-primary"),children:[(0,a.jsx)(d.default,{className:"mr-1 size-3.5"}),"Bold"]}),[{label:"left",value:"left",Icon:o.default},{label:"center",value:"center",Icon:n.default},{label:"right",value:"right",Icon:s.default}].map(({label:t,value:r,Icon:i})=>(0,a.jsx)(B.Button,{type:"button",size:"icon",variant:"ghost",title:`Align ${t}`,onClick:t=>{t.stopPropagation();let a="left"===r?8:"right"===r?92:50;tH(e.id,{align:r,x:a}),requestAnimationFrame(()=>tY(e.id,{align:r,x:a}))},className:(0,U.cn)("border-border/60 bg-background/25 hover:bg-background/60 size-8 rounded-lg border",e.align===r&&"border-primary bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground"),children:(0,a.jsx)(i,{className:"size-3.5"})},t)),(0,a.jsxs)(B.Button,{type:"button",size:"sm",variant:"ghost",onClick:t=>{var r;t.stopPropagation(),r=e.id,eI(e=>e.filter(e=>e.id!==r)),eB(e=>e===r?null:e)},className:"border-border/60 bg-background/25 hover:bg-background/60 h-8 rounded-lg border px-2.5 text-xs",children:[(0,a.jsx)(k.Trash2,{className:"mr-1 size-3.5"}),"Delete"]})]})]},e.id))})]}),(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,a.jsx)("p",{className:"text-muted-foreground text-[11px] font-semibold tracking-wide uppercase",children:"Explicit Label"}),(0,a.jsxs)("div",{className:"border-border/70 flex h-8 items-center gap-2 rounded-lg border px-2.5",children:[(0,a.jsx)(l.default,{className:"text-primary size-3.5"}),(0,a.jsx)("span",{className:"text-xs font-medium",children:e$?"On":"Off"}),(0,a.jsx)(D.Switch,{checked:e$,onCheckedChange:eF})]})]}),e$&&(0,a.jsx)("div",{className:"grid grid-cols-3 gap-2",children:_.map(e=>(0,a.jsxs)("button",{type:"button",onClick:()=>eD(e.value),className:(0,U.cn)("border-border/70 bg-background/40 overflow-hidden rounded-lg border p-1.5 text-left transition",eA===e.value&&"border-primary ring-primary/30 ring-2"),children:[(0,a.jsx)("span",{className:"flex h-12 items-center justify-center rounded bg-white p-1",children:(0,a.jsx)(R.LazyImage,{src:e.image,alt:`${e.label} explicit label`,className:"max-h-full w-full object-contain"})}),(0,a.jsx)("span",{className:"mt-1 block truncate text-center text-[11px] font-medium",children:e.label})]},e.value))})]}),(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-muted-foreground text-[11px] font-semibold tracking-wide uppercase",children:"Cover Border"}),(0,a.jsx)("p",{className:"text-muted-foreground mt-1 text-xs",children:"Add a straight-edge color border around the cover."})]}),(0,a.jsxs)("div",{className:"border-border/70 flex h-8 items-center gap-2 rounded-lg border px-2.5",children:[(0,a.jsx)("span",{className:"text-xs font-medium",children:eq?"On":"Off"}),(0,a.jsx)(D.Switch,{checked:eq,onCheckedChange:e_})]})]}),eq&&(0,a.jsxs)("div",{className:"grid gap-3 rounded-xl border border-white/10 bg-black/10 p-3 sm:grid-cols-[auto_1fr]",children:[(0,a.jsxs)("label",{className:"flex items-center gap-2 text-xs font-semibold",children:[(0,a.jsx)("input",{type:"color",value:eV,onChange:e=>eW(e.target.value),className:"border-border/70 bg-background h-8 w-10 rounded-lg border p-1",title:"Border color"}),"Color"]}),(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,a.jsx)("label",{className:"text-xs font-semibold",children:"Width"}),(0,a.jsxs)("span",{className:"text-muted-foreground text-xs",children:[eH,"px"]})]}),(0,a.jsx)("input",{type:"range",min:1,max:48,value:eH,onChange:e=>eJ(Number(e.target.value)),className:"accent-primary w-full"})]})]})]})]})]}),eL&&(0,a.jsx)("div",{className:"border-border/70 bg-card/98 shadow-primary/10 shrink-0 border-t p-4 shadow-2xl",children:(0,a.jsxs)("div",{className:"grid gap-2 sm:grid-cols-2",children:[(0,a.jsxs)(B.Button,{type:"button",onClick:tQ,disabled:tn,className:"h-11 rounded-lg",children:[tn?(0,a.jsx)(b.Loader2,{className:"mr-2 size-4 animate-spin"}):(0,a.jsx)(m.Download,{className:"mr-2 size-4"}),"Download Cover"]}),(0,a.jsxs)(B.Button,{type:"button",variant:"outline",onClick:tK,disabled:e5||tn,className:"h-11 rounded-lg",children:[ts?(0,a.jsx)(b.Loader2,{className:"mr-2 size-4 animate-spin"}):(0,a.jsx)(S.WandSparkles,{className:"mr-2 size-4"}),"Blend with AI"]})]})})]})]})]}),(0,a.jsx)($.Dialog,{open:eZ,onOpenChange:e=>{e5||e0(e)},children:(0,a.jsxs)($.DialogContent,{className:"border-border/70 bg-card text-card-foreground sm:max-w-xl",children:[(0,a.jsx)($.DialogHeader,{children:(0,a.jsx)($.DialogTitle,{children:"Regenerate Backgroun
8d"})}),(0,a.jsxs)("div",{className:"grid gap-4 sm:grid-cols-[9rem_1fr]",children:[(0,a.jsx)("div",{className:"border-border/70 bg-background/40 relative aspect-square overflow-hidden rounded-lg border",children:eL&&(0,a.jsx)(R.LazyImage,{src:eL,alt:"Current album cover background reference",className:"h-full w-full object-cover"})}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("label",{htmlFor:"regenerate-background-instruction",className:"text-sm font-semibold",children:"Change request"}),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("textarea",{id:"regenerate-background-instruction",value:e1,onChange:e=>e2(e.target.value),maxLength:500,placeholder:"Make it darker, add more rain, keep the neon road composition...",className:"border-border/70 bg-background/70 placeholder:text-muted-foreground focus:border-primary/70 min-h-32 w-full resize-none rounded-xl border px-3 pt-2.5 pr-3 pb-8 text-sm leading-6 outline-none"}),(0,a.jsxs)("span",{className:"text-muted-foreground bg-background/80 pointer-events-none absolute right-3 bottom-2 rounded px-1.5 text-[11px]",children:[e1.length," /"," ",500]})]}),(0,a.jsxs)("p",{className:"text-muted-foreground flex items-center gap-1.5 truncate text-xs",children:[(0,a.jsx)(p.Info,{className:"text-primary size-3.5 shrink-0"}
8),(0,a.jsx)("span",{className:"truncate",children:"Background only. Text, explicit label, and border stay editable."})]})]})]}),(0,a.jsxs)($.DialogFooter,{className:"flex-row justify-end",children:[(0,a.jsx)(B.Button,{type:"button",variant:"ghost",onClick:()=>e0(!1),disabled:e5,className:"border-border/70 bg-background/25 hover:bg-background/60 h-9 rounded-lg border px-4 text-xs",children:"Cancel"}),(0,a.jsxs)(B.Button,{type:"button",variant:"ghost",onClick:tq,disabled:e5||!e1.trim(),className:"border-primary/40 text-primary hover:bg-primary hover:text-primary-foreground h-9 rounded-lg border px-4 text-xs",children:[e5&&"regenerate"===e8?(0,a.jsx)(b.Loader2,{className:"mr-2 size-4 animate-spin"}):(0,a.jsx)(S.WandSparkles,{className:"mr-2 size-4"}),"Generate Variation"]})]})]})}),ev&&(0,a.jsx)("div",{className:"fixed inset-0 z-[80] flex items-center justify-center bg-black/70 px-4 py-6 backdrop-blur-sm",children:(0,a.jsxs)("div",{className:"border-border/70 bg-card text-foreground w-full max-w-5xl overflow-hidden rounded-2xl border shadow-2xl",children:[(0,a.jsxs)("div",{className:"border-border/70 flex items-center justify-between border-b px-5 py-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("h3",{className:"text-lg font-semibold",children:["Choose ",ev]}),(0,a.jsx)("p",{className:"text-muted-foreground mt-1 text-xs",children:"Pick one direction for your album cover prompt."})]}),(0,a.jsx)("button",{type:"button",onClick:()=>ew(null),className:"text-muted-foreground hover:bg-secondary hover:text-foreground rounded-lg p-2","aria-label":"Close cover direction selector",children:(0,a.jsx)(E.X,{className:"size-4"})})]}),(0,a.jsxs)("div",{className:"space-y-4 p-5",children:[(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)(j.Search,{className:"text-muted-foreground pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2"}),(0,a.jsx)("input",{value:ey,onChange:e=>ej(e.target.value),placeholder:`Search ${ev.toLowerCase()}...`,className:"border-border/70 bg-background/70 placeholder:text-muted-foreground focus:border-primary/70 w-full rounded-xl border py-2.5 pr-3 pl-10 text-sm outline-none",autoFocus:!0})]}),(0,a.jsx)("div",{className:"makebpm-scrollbar max-h-[52vh] overflow-y-auto pr-1",children:(0,a.jsx)("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-5",children:H[ev].filter(e=>e.toLowerCase().includes(ey.trim().toLowerCase())).map(e=>{let t=tB[ev]===e;return(0,a.jsxs)("button",{type:"button",onClick:()=>{"Genre"===ev&&ep(e),"Mood"===ev&&eh(e),"Visual Style"===ev&&ef(e),ew(null),ej("")},className:(0,U.cn)("border-border/70 text-muted-foreground hover:border-primary/70 group relative aspect-square overflow-hidden rounded-lg border bg-black p-0 text-left text-xs transition hover:text-foreground",t&&"border-primary text-foreground ring-primary/35 ring-2"),children:[(0,a.jsx)(z.default,{src:el(ev,e),alt:`${e} ${ev.toLowerCase()} album cover direction`,fill:!0,sizes:"(max-width: 640px) 45vw, 180px",className:"object-cover transition duration-300 group-hover:scale-105"}),(0,a.jsx)("span",{className:"absolute inset-0 bg-gradient-to-t from-black/80 via-black/20 to-transparent"}),(0,a.jsx)("span",{className:(0,U.cn)("absolute right-2 bottom-2 left-2 text-sm text-white drop-shadow",t?"font-bold":"font-semibold"),children:e}),t&&(0,a.jsx)("span",{className:"bg-primary text-primary-foreground absolute top-2 right-2 flex size-7 items-center justify-center rounded-full shadow-lg",children:(0,a.jsx)(c.Check,{className:"size-4"})})]},e)})})})]})]})})]})}e.s(["AlbumCoverTool",()=>eu],516719)}]);
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.