1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6405],{28504:function(e,t,a){"use strict";var n=a(71600);t.Z=void 0;var i=n(a(68671)),r=a(52322);t.Z=(0,i.default)((0,r.jsx)("path",{d:"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20z"}),"ArrowBack")},49960:function(e,t,a){"use strict";var n=a(71600);t.Z=void 0;var i=n(a(68671)),r=a(52322);t.Z=(0,i.default)((0,r.jsx)("path",{d:"M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8zm2 11h-3v3.75c0 1.24-1.01 2.25-2.25 2.25S8.5 17.99 8.5 16.75s1.01-2.25 2.25-2.25c.46 0 .89.14 1.25.38V11h4zm-3-4V3.5L18.5 9z"}),"AudioFile")},938:function(e,t,a){"use strict";var n=a(71600);t.Z=void 0;var i=n(a(68671)),r=a(52322);t.Z=(0,i.default)((0,r.jsx)("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2M7.5 18c-.83 0-1.5-.67-1.5-1.5S6.67 15 7.5 15s1.5.67 1.5 1.5S8.33 18 7.5 18m0-9C6.67 9 6 8.33 6 7.5S6.67 6 7.5 6 9 6.67 9 7.5 8.33 9 7.5 9m4.5 4.5c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5m4.5 4.5c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5m0-9c-.83 0-1.5-.67-1.5-1.5S15.67 6 16.5 6s1.5.67 1.5 1.5S17.33 9 16.5 9"}),"Casino")},42713:function(e,t,a){"use strict";var n=a(71600);t.Z=void 0;var i=n(a(68671)),r=a(52322);t.Z=(0,i.default)((0,r.jsx)("path",{d:"M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"}),"Check")},18169:function(e,t,a){"use strict";var n=a(71600);t.Z=void 0;var i=n(a(68671)),r=a(52322);t.Z=(0,i.default)((0,r.jsx)("path",{d:"M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96M14 13v4h-4v-4H7l5-5 5 5z"}),"CloudUpload")},29164:function(e,t,a){"use strict";var n=a(71600);t.Z=void 0;var i=n(a(68671)),r=a(52322);t.Z=(0,i.default)((0,r.jsx)("path",{d:"M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2M8.5 13.5l2.5 3.01L14.5 12l4.5 6H5z"}),"Image")},31913:function(e,t,a){"use strict";var n=a(71600);t.Z=void 0;var i=n(a(68671)),r=a(52322);t.Z=(0,i.default)((0,r.jsx)("path",{d:"M8 5v14l11-7z"}),"PlayArrow")},22905:function(e,t,a){"use strict";var n=a(71600);t.Z=void 0;var i=n(a(68671)),r=a(52322);t.Z=(0,i.default)((0,r.jsx)("path",{d:"m20.41 8.41-4.83-4.83c-.37-.37-.88-.58-1.41-.58H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V9.83c0-.53-.21-1.04-.59-1.42M7 7h7v2H7zm10 10H7v-2h10zm0-4H7v-2h10z"}),"TextSnippet")},13787:function(e,t,a){"use strict";var n=a(71600);t.Z=void 0;var i=n(a(68671)),r=a(52322);t.Z=(0,i.default)([(0,r.jsx)("path",{d:"M12 5.99 19.53 19H4.47zM12 2 1 21h22z"},"0"),(0,r.jsx)("path",{d:"M13 16h-2v2h2zm0-6h-2v5h2z"},"1")],"WarningAmber")},28416:function(e,t,a){"use strict";a.d(t,{Z:function(){return X}});var n=a(52322),i=a(2784),r=a(5632),o=a(22905),l=a(49960),s=a(39785),c=a(938),u=a(72841),d=a(29164),m=a(92679),p=a(24032),h=a(34138),g=a.n(h);function _(e){let{prompt:t="",setPrompt:a,maxLength:r=250,loading:o=!1,generatingIdea:l=!1,onRandomIdea:h,onCreate:_,imagePreview:v,onImageUpload:x,onImageRemove:f,hasImage:j=!1,error:S,placeholder:b="Make an emo rock song about hating pineapple on your pizza...",createButtonText:C="Create",creditCost:y=null,disableCreateUntilInput:w=!1}=e,I=(0,i.useRef)(null),N=o||l,k=!!(null==t?void 0:t.trim());return(0,n.jsxs)("div",{className:g().root,children:[(0,n.jsxs)("div",{className:g().inputWrapper,children:[(0,n.jsx)("textarea",{value:t,maxLength:r,onChange:e=>a(e.target.value),placeholder:b,className:g().textInput,disabled:N,rows:3}),(0,n.jsxs)("div",{className:g().bottomControls,children:[(0,n.jsxs)("div",{className:g().leftControls,children:[x&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("input",{type:"file",ref:I,onChange:e=>{var t;let a=null===(t=e.target.files)||void 0===t?void 0:t[0];a&&x&&x(a,e)},accept:"image/*",style:{display:"none"},id:"song-prompt-image-upload",disabled:N}),(0,n.jsx)(p.Z,{title:"Upload reference image",children:(0,n.jsx)("label",{htmlFor:"song-prompt-image-upload",className:"".concat(g().iconButton," ").concat(N?g().disabled:""),children:(0,n.jsx)(d.Z,{})})})]}),h&&(0,n.jsx)(p.Z,{title:"Random song idea",children:(0,n.jsx)("button",{onClick:h,disabled:N,className:g().iconButton,type:"button",children:l?(0,n.jsx)(u.Z,{size:20,color:"inherit"}):(0,n.jsx)(c.Z,{})})})]}),(0,n.jsx)("button",{onClick:_,disabled:w&&!k&&!j||N,className:g().createButton,type:"button",children:o?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(u.Z,{size:20,color:"inherit"}),"Creating..."]}):(0,n.jsxs)(n.Fragment,{children:[C,y?" (".concat(y," credits)"):"",(0,n.jsx)(s.Z,{className:g().buttonIcon})]})})]})]}),v&&(0,n.jsxs)("div",{className:g().imagePreviewInline,children:[(0,n.jsx)("img",{src:v,alt:"Upload preview"}),(0,n.jsx)("button",{onClick:()=>{I.current&&(I.current.value=""),f&&f()},className:g().removeImageInline,disabled:N,type:"button",children:(0,n.jsx)(m.Z,{})})]}),S&&(0,n.jsx)("div",{className:g().errorMessage,children:S})]})}var v=a(28504),x=a(13787),f=a(27584),j=a(46131),S=a(57357),b=a(85270),C=a(85768),y=a.n(C);let w=j.Z.songCreationLyricsMaxChars,I=["Pop","Rock","Hip Hop","R&B","Country","Jazz","Electronic","Dance","Indie","Folk","Classical","Reggae","Blues","Soul","Funk","Disco","Punk","Metal","Alternative","Acoustic","Lo-fi","Synthwave","80s","Upbeat","Melancholic","Energetic","Chill","Dreamy","Dark","Romantic","Anthemic","Groovy","Ethereal","Cinematic","Retro","Modern","Ambient","Emo","Trippy","Indie Rock","Bubblegum Pop","Synthwave"],N=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return[...I.filter(e=>!t.includes(e))].sort(()=>Math.random()-.5).slice(0,e)};
1function k(e){let{onBack:t,creditCost:a=null,onSuccess:l,isAuthenticated:s=!1,onRequireAuth:c}=e,d=(0,r.useRouter)(),[m,p]=(0,i.useState)(!1),[h,g]=(0,i.useState)(null),[_,j]=(0,i.useState)(""),[C,I]=(0,i.useState)(""),[k,P]=(0,i.useState)(""),[A,Z]=(0,i.useState)(()=>N(3)),R=async()=>{if(!s){c&&c();return}if(!C.trim()){g("Please enter lyrics");return}if(C.trim().length<10){g("Lyrics must be at least ".concat(10," characters"));return}if(!k.trim()){g("Please enter a music style");return}if(k.trim().length<10){g("Style must be at least ".concat(10," characters"));return}p(!0),g(null);try{let e=await f.Z.post("/api/music/create-from-lyrics",{title:_.trim()||null,lyrics:C.trim(),style:k.trim()});if(e.musicID)l&&l(),d.push(S.Z.music(e.musicID));else throw Error("Failed to create music")}catch(e){console.error("Error creating music:",e),(null==e?void 0:e.error)!=="INSUFFICIENT_CREDITS"&&g((0,b.jN)(e,"Something went wrong. Please try again.")),p(!1)}},L=(e,t)=>{let a=k.trim()?"".concat(k.trim(),", ").concat(e):e;P(a.slice(0,200));let n=a.split(",").map(e=>e.trim()),i=[...A],r=N(1,[...n,...A]);i[t]=r[0]||N(1)[0],Z(i),h&&g(null)};return(0,n.jsxs)("div",{className:y().container,children:[(0,n.jsxs)("button",{className:y().backLink,onClick:t,disabled:m,children:[(0,n.jsx)(v.Z,{fontSize:"small"}),"Back"]}),(0,n.jsxs)("div",{className:y().formGroup,children:[(0,n.jsxs)("label",{className:y().label,children:["Song Title",(0,n.jsx)("span",{className:y().optional,children:"(Optional)"}),(0,n.jsxs)("span",{className:"".concat(y().charCount," ").concat(_.length>80?y().charCountError:""),children:[_.length,"/",80]})]}),(0,n.jsx)("input",{className:y().input,placeholder:"e.g. Neon Nights (Leave empty to auto-generate)",value:_,onChange:e=>{j(e.target.value.slice(0,80)),h&&g(null)},disabled:m})]}),(0,n.jsxs)("div",{className:y().formGroup,children:[(0,n.jsxs)("label",{className:y().label,children:["Lyrics",(0,n.jsxs)("span",{className:"".concat(y().charCount," ").concat(C.length>0&&C.length<10||C.length>w?y().charCountError:""),children:[C.length,"/",w]})]}),(0,n.jsx)("textarea",{className:y().textarea,placeholder:"[Verse]\nWalking down the boulevard...\n\n[Chorus]\nNeon lights are calling me...",value:C,onChange:e=>{I(e.target.value.slice(0,w)),h&&g(null)},disabled:m}),(0,n.jsxs)("span",{className:y().helperText,children:["Tip: Use [Intro], [Verse], [Chorus], [Bridge], [Outro] tags to help structure the song. ",(0,n.jsx)("br",{})]})]}),(0,n.jsxs)("div",{className:y().formGroup,children:[(0,n.jsxs)("label",{className:y().label,children:["Musical Style",(0,n.jsxs)("span",{className:"".concat(y().charCount," ").concat(k.length>0&&k.length<10||k.length>200?y().charCountError:""),children:[k.length,"/",200]})]}),(0,n.jsx)("input",{className:y().input,placeholder:"e.g. Synthwave, 80s Pop, Upbeat",value:k,onChange:e=>{P(e.target.value.slice(0,200)),h&&g(null)},disabled:m}),(0,n.jsx)("div",{className:y().pillsContainer,children:A.map((e,t)=>(0,n.jsxs)("button",{type:"button",className:y().pill,onClick:()=>L(e,t),disabled:m,children:["+ ",e]},"".concat(e,"-").concat(t)))}),(0,n.jsxs)("span",{className:y().helperText,children:["Describe the genre, mood, and instruments to define the sound. ",10," - ",200," chars."]})]}),h&&(0,n.jsxs)("div",{className:y().errorMessage,children:[(0,n.jsx)(x.Z,{fontSize:"small"}),h]}),(0,n.jsx)("button",{className:y().submitButton,onClick:R,disabled:m||!C.trim()||C.trim().length<10||!k.trim()||k.trim().length<10,children:m?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(u.Z,{size:20,color:"inherit"}),"Creating Music..."]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(o.Z,{}),"Create Music",a?" (".concat(a," credits)"):""]})})]})}var P=a(39097),A=a.n(P),Z=a(18169),R=a(14397);let L=new Set([714450,714522,715211,727392].map(String)),M=new Set(["application/octet-stream","binary/octet-stream","application/binary","application/x-binary"]),B=new Set(["video/mp4","application/mp4"]),F={"audio/aac":"audio/aac","audio/x-aac":"audio/aac","audio/flac":"audio/flac","audio/x-flac":"audio/flac","audio/m4a":"audio/mp4","audio/mp4":"audio/mp4","audio/x-m4a":"audio/mp4","audio/mp3":"audio/mpeg","audio/mpg":"audio/mpeg","audio/mpga":"audio/mpeg","audio/mpeg":"audio/mpeg","audio/mpeg3":"audio/mpeg","audio/x-mp3":"audio/mpeg","audio/x-mpeg":"audio/mpeg","audio/x-mpeg-3":"audio/mpeg","audio/ogg":"audio/ogg","audio/x-ogg":"audio/ogg","application/ogg":"audio/ogg","audio/vnd.wave":"audio/wav","audio/wav":"audio/wav","audio/wave":"audio/wav","audio/x-pn-wav":"audio/wav","audio/x-wav":"audio/wav","audio/webm":"audio/webm","audio/x-webm":"audio/webm"},E={".aac":"audio/aac",".flac":"audio/flac",".m4a":"audio/mp4",".mp3":"audio/mpeg",".mp4":"audio/mp4",".mpeg":"audio/mpeg",".mpga":"audio/mpeg",".oga":"audio/ogg",".ogg":"audio/ogg",".wav":"audio/wav",".w
1ave":"audio/wav",".webm":"audio/webm"};function D(e){return String(e||"").split(";")[0].trim().toLowerCase()}function O(e){let t=D(e);return t?F[t]||(t.startsWith("audio/")?t:null):null}function T(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=String(e||""),a=t;try{a=new URL(t).pathname}catch(e){a=t.split("?")[0].split("#")[0]}let n=a.toLowerCase(),i=Object.keys(E).find(e=>n.endsWith(e));return i?E[i]:null}var z=a(92835),U=a.n(z);let H=["mp3","mp4","ogg","wav"],G=new Set(["audio/mpeg","audio/mp4","audio/ogg","audio/wav"]),V=e=>Math.floor(e/60);function W(e){var t;let{onBack:a,isAuthenticated:o=!1,onRequireAuth:s}=e,c=(0,r.useRouter)(),{user:d}=(0,i.useContext)(R.Z),[m,p]=(0,i.useState)(!1),[h,g]=(0,i.useState)(null),[_,C]=(0,i.useState)(!1),[y,w]=(0,i.useState)(""),[I,N]=(0,i.useState)(null),[k,P]=(0,i.useState)(null),[F,E]=(0,i.useState)(!1),z=(0,i.useRef)(null);(0,i.useEffect)(()=>{if(!I){P(null);return}let e=URL.createObjectURL(I);return P(e),()=>URL.revokeObjectURL(e)},[I]);let W=(t=d?d.id:null)&&L.has(String(t))?420:j.Z.maxSongDurationSeconds,q=Math.floor(60),Y=e=>new Promise((t,a)=>{let n=new Audio;n.src=URL.createObjectURL(e),n.onloadedmetadata=()=>{URL.revokeObjectURL(n.src),t(n.duration)},n.onerror=()=>{URL.revokeObjectURL(n.src),a(Error("Could not load audio file."))}}),J=async e=>{if(e){if(!o){s&&s();return}if(C(!1),!function(e){if(!e)return!1;let t=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{fallbackMimeType:t=null}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(){let{contentType:e=null,sourceName:t="",fallbackMimeType:a="audio/mpeg"}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!function(e){let t=D(e);return!t||M.has(t)}(e)){let a=O(e);
1if(a)return a;let n=T(t);return B.has(D(e))&&"audio/mp4"===n?n:null}return T(t)||O(a)||a}({contentType:(null==e?void 0:e.type)||(null==e?void 0:e.mimetype)||(null==e?void 0:e.mimeType)||null,sourceName:(null==e?void 0:e.name)||(null==e?void 0:e.originalFilename)||(null==e?void 0:e.newFilename)||(null==e?void 0:e.filepath)||"",fallbackMimeType:t})}(e);return t&&G.has(t)}(e)){g("Invalid file type. Supported types: ".concat(H.join(", ").toUpperCase(),"."));return}if(e.size>62914560){g("File is too large. Please keep it under ".concat(q,"MB."));return}try{let t=await Y(e);if(t>W){g("Audio must be under ".concat(V(W)," minutes. This file is ").concat(Math.round(t)," seconds."));return}if(N(e),g(null),!y){let t=e.name.split(".").slice(0,-1).join(".");w(t.slice(0,80))}}catch(e){g("Failed to read audio file. Please try another one.")}}},K=async e=>{var t;let a=null===(t=e.target.files)||void 0===t?void 0:t[0];await J(a),e.target.value=""},Q=async e=>{if(e.preventDefault(),e.stopPropagation(),!o){C(!1),s&&s();return}if(m)return;C(!1);let t=Array.from(e.dataTransfer.files||[]),a=t[0];if(a){if(t.length>1){g("Please drop a single audio file.");return}await J(a)}},X=async()=>{if(!I){g("Please upload an audio file");return}if(!F){g("Please confirm you own or are licensed to use this audio.");return}p(!0),g(null);try{let{audioURL:e,uploadedMusicId:t,duration:a}=await f.Z.putFile("/api/music/upload",I,{name:y||I.name}),n=await f.Z.post("/api/music/create-from-audio",{title:y.trim()||null,audioUrl:e,duration:a,rightsConfirmed:!0,uploadedMusicId:t});if(n.musicID)c.push(S.Z.music(n.musicID));else throw Error("Failed to create project")}catch(e){console.error("Error creating project:",e),g((0,b.jN)(e,"Something went wrong. Please try again.")),p(!1)}};return(0,n.jsxs)("div",{className:U().container,children:[(0,n.jsxs)("div",{className:U().header,children:[(0,n.jsxs)("button",{className:U().backButton,onClick:a,disabled:m,children:[(0,n.jsx)(v.Z,{fontSize:"small"}),"Back"]}),(0,n.jsx)("h3",{className:U().title,children:"Start with Audio"}),(0,n.jsx)("div",{style:{width:60}})]}),(0,n.jsxs)("div",{className:U().formGroup,children:[(0,n.jsxs)("label",{className:U().label,children:["Song Title",(0,n.jsx)("span",{className:U().optional,children:"(Optional)"}),(0,n.jsxs)("span",{className:"".concat(U().charCount," ").concat(y.length>=80?U().charCountError:""),children:[y.length,"/",80]})]}),(0,n.jsx)("input",{className:U().input,placeholder:"e.g. My Awesome Track (Leave empty to auto-generate)",value:y,onChange:e=>{w(e.target.value.slice(0,80)),h&&g(null)},disabled:m})]}),(0,n.jsxs)("div",{className:U().formGroup,children:[(0,n.jsx)("label",{className:U().label,children:"Upload Audio"}),(0,n.jsx)("input",{type:"file",ref:z,onChange:K,accept:".mp3,.mp4,.ogg,.wav,audio/mpeg,audio/mp4,audio/ogg,audio/wav",style:{display:"none"}}),(0,n.jsx)("div",{className:"".concat(U().fileUploadBox," ").concat(I?U().hasFile:""," ").concat(m?U().disabled:""," ").concat(_?U().dragActive:""),onClick:()=>{var e;return!m&&(null===(e=z.current)||void 0===e?void 0:e.click())},onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),m||C(!0)},onDragOver:e=>{e.preventDefault(),e.stopPropagation(),m||(e.dataTransfer.dropEffect="copy",C(!0))},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),e.currentTarget.contains(e.relatedTarget)||C(!1)},onDrop:Q,role:"button",tabIndex:m?-1:0,onKeyDown:e=>{if(!m&&("Enter"===e.key||" "===e.key)){var t;e.preventDefault(),null===(t=z.current)||void 0===t||t.click()}},children:I?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:U().selectedFile,children:[(0,n.jsx)(l.Z,{}),(0,n.jsx)("span",{children:I.name})]}),(0,n.jsx)("div",{className:U().changeFile,children:"Click to change file"})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(Z.Z,{className:U().uploadIcon}),(0,n.jsx)("div",{className:U().uploadText,children:"Click or drop an audio file"}),(0,n.jsxs)("div",{className:U().uploadSubtext,children:["MP3, WAV, OGG (Max ",V(W)," min, ",q,"MB)"]})]})}),k&&(0,n.jsx)("div",{className:U().audioPreview,children:(0,n.jsx)("audio",{controls:!0,src:k})})]}),(0,n.jsxs)("div",{className:U().noticeBox,children:[(0,n.jsxs)("label",{className:U().checkboxRow,children:[(0,n.jsx)("input",{type:"checkbox",checked:F,onChange:e=>{E(e.target.checked),h&&g(null)},disabled:m}),(0,n.jsx)("span",{children:"I confirm I own or am licensed to use this audio and any related content I upload."})]}),(0,n.jsxs)("div",{className:U().noticeSubtext,children:["See our ",(0,n.jsx)(A(),{href:S.Z.terms,children:"Terms"})," and ",(0,n.jsx)(A(),{href:S.Z.dmca,children:"DMCA Policy"}),"."]})]}),h&&(0,n.jsxs)("div",{className:U().errorMessage,children:[(0,n.jsx)(x.Z,{fontSize:"small"}),h]}),(0,n.jsx)("button",{className:U().submitButton,onClick:X,disabled:m||!I||!F,children:m?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(u.Z,{size:20,color:"inherit"}),"Transcribing..."]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(l.Z,{}),"Create Project"]})})]})}var q=a(86002),Y=a(54097),J=a.n(Y);let K={PROMPT:"prompt",LYRICS:"lyrics",AUDIO:"audio"},Q="Please enter a prompt or upload an image";function X(e){let{isAuthenticated:t=!1,onRequireAuth:a,onSuccess:s,creditCost:c=null,showAltOptions:u=!0,disableCreateUntilInput:d=!1}=e,m=(0,r.useRouter)(),p=(0,i.useRef)(!0),[h,g]=(0,i.useState)(K.PROMPT),[v,x]=(0,i.useState)(!1),[j,C]=(0,i.useState)(null),[y,w]=(0,i.useState)(!1),[I,N]=(0,i.useState)(""),[P,A]=(0,i.useState)(null),[Z,R]=(0,i.useState)(null);(0,i.useEffect)(()=>(p.current=!0,()=>{p.current=!1}),[]),(0,i.useEffect)(()=>{let e=!!(null==I?void 0:I.trim())||!!Z;
1j===Q&&e&&C(null)},[I,Z,j]);let L=async e=>{if(!e)return;let t=(0,q.pJ)(e,8);if(t){C(t);return}C(null),A(e),R(await (0,q.WB)(e))},M=async()=>{w(!0),C(null);try{let e=await f.Z.post("/api/music/randomSongIdea");N((0,b.gn)(e.idea||""))}catch(e){console.error("Error generating random idea:",e),C((0,b.jN)(e,"Failed to generate idea. Please try again."))}finally{w(!1)}},B=async()=>{if(!t){a&&a();return}let e=(0,b.gn)(I||"").trim();if(!e&&!Z){C(Q);return}if(e&&e.length<10){C("Prompt must be at least ".concat(10," characters"));return}x(!0),C(null);try{let t=await f.Z.post("/api/music/create",{songDescription:e||void 0,imageBase64:Z||void 0});if(!p.current)return;if(t.musicID)s&&s(),m.push(S.Z.music(t.musicID));else throw Error("Failed to create music")}catch(e){if(console.error("Error creating music:",e),!p.current)return;(null==e?void 0:e.error)!=="INSUFFICIENT_CREDITS"&&C((0,b.jN)(e,"Something went wrong. Please try again.")),x(!1)}},F=e=>{g(e),C(null)},E=v||y;return(0,n.jsxs)("div",{className:J().root,children:[(0,n.jsx)("div",{className:"".concat(J().modeContent," ").concat(h===K.PROMPT?J().active:""),children:h===K.PROMPT&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(_,{prompt:I,setPrompt:e=>N((0,b.gn)(e||"")),maxLength:250,loading:v,generatingIdea:y,onRandomIdea:M,onCreate:B,imagePreview:Z,onImageUpload:L,onImageRemove:()=>{A(null),R(null)},hasImage:!!P,error:j,creditCost:c,disableCreateUntilInput:d}),u&&(0,n.jsxs)("div",{className:J().altOptions,children:[(0,n.jsx)("span",{className:J().altOptionsText,children:"or start with"}),(0,n.jsxs)("button",{className:J().altOptionButton,onClick:()=>F(K.LYRICS),disabled:E,children:[(0,n.jsx)(o.Z,{}),(0,n.jsx)("span",{children:"Custom Lyrics"})]}),(0,n.jsxs)("button",{className:J().altOptionButton,onClick:()=>F(K.AUDIO),disabled:E,children:[(0,n.jsx)(l.Z,{}),(0,n.jsx)("span",{children:"Your Audio"})]})]})]})}),(0,n.jsx)("div",{className:"".concat(J().modeContent," ").concat(h===K.LYRICS?J().active:""),children:h===K.LYRICS&&(0,n.jsx)(k,{onBack:()=>F(K.PROMPT),creditCost:c,onSuccess:s,isAuthenticated:t,onRequireAuth:a})}),(0,n.jsx)("div",{className:"".concat(J().modeContent," ").concat(h===K.AUDIO?J().active:""),children:h===K.AUDIO&&(0,n.jsx)(W,{onBack:()=>F(K.PROMPT),isAuthenticated:t,onRequireAuth:a})})]})}},86002:function(e,t,a){"use strict";async function n(e){let t=await createImageBitmap(e,{imageOrientation:"from-image"}),{width:a,height:n}=t;if(a>2048||n>2048){let e=Math.min(2048/a,2048/n);a=Math.round(a*e),n=Math.round(n*e)}let i=document.createElement("canvas");return i.width=a,i.height=n,i.getContext("2d").drawImage(t,0,0,a,n),t.close(),i.toDataURL("image/jpeg",.85)}async function i(e){try{return await n(e)}catch(t){return console.error("Error processing image, falling back to FileReader:",t),new Promise((t,a)=>{let n=new FileReader;n.onloadend=()=>t(n.result),n.onerror=a,n.readAsDataURL(e)})}}function r(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:50;return e.size>1048576*t?"Image is too large. Please select an image smaller than ".concat(t,"MB."):null}a.d(t,{WB:function(){return i},pJ:function(){return r}})},92835:function(e){e.exports={container:"AudioStart_container__fI_Vq",header:"AudioStart_header__W7hjX",backButton:"AudioStart_backButton__0KIKh",title:"AudioStart_title__0e0kz",formGroup:"AudioStart_formGroup___44h2",label:"AudioStart_label__QqZ6h",optional:"AudioStart_optional__Ku8_D",charCount:"AudioStart_charCount__8Z21g",charCountError:"AudioStart_charCountError__k5_tb",input:"AudioStart_input__ZfjFj",textarea:"AudioStart_textarea__R1Sw4",helperText:"AudioStart_helperText__jAb1_",errorMessage:"AudioStart_errorMessage__Rlmw6",shake:"AudioStart_shake__MzkuM",submitButton:"AudioStart_submitButton__gNCdj",fileUploadBox:"AudioStart_fileUploadBox__uujO_",disabled:"AudioStart_disabled__ZVOS_",uploadIcon:"AudioStart_uploadIcon__JvGjE",hasFile:"AudioStart_hasFile__BS_q6",dragActive:"AudioStart_dragActive__mYQzw",uploadText:"AudioStart_uploadText__jcmsz",uploadSubtext:"AudioStart_uploadSubtext__y7aBD",selectedFile:"AudioStart_selectedFile__QGwQ6",changeFile:"AudioStart_changeFile__9qpXR",audioPreview:"AudioStart_audioPreview__2fObr",noticeBox:"AudioStart_noticeBox__Y3hjo",checkboxRow:"AudioStart_checkboxRow__CxxD_",noticeSubtext:"AudioStart_noticeSubtext__nR7v3"}},85768:function(e){e.exports={container:"LyricsStart_container__z9NgH",backLink:"LyricsStart_backLink__WPvJ8",formGroup:"LyricsStart_formGroup__nU6K8",label:"LyricsStart_label__uA0xy",optional:"LyricsStart_optional__49AhS",charCount:"LyricsStart_charCount__EG_s0",charCountError:"LyricsStart_charCountError__8pqEn",input:"LyricsStart_input__PwM5P",textarea:"LyricsStart_textarea__tNCZu",helperText:"LyricsStart_helperText__9QiFH",pillsContainer:"LyricsStart_pillsContainer___qOlZ",pill:"LyricsStart_pill__omRk3",errorMessage:"LyricsStart_errorMessage__g5QH7",shake:"LyricsStart_shake__g1vld",submitButton:"LyricsStart_submitButton__qOEUg"}},54097:function(e){e.exports={root:"SongCreationInput_root__H494O",modeContent:"SongCreationInput_modeContent__6hbfy",fadeIn:"SongCreationInput_fadeIn__qlRN1",active:"SongCreationInput_active__vA_Dw",slideIn:"SongCreationInput_slideIn__2ihDA",altOptions:"SongCreationInput_altOptions__VCZp_",altOptionsText:"SongCreationInput_altOptionsText__PpSRu",altOptionButton:"SongCreationInput_altOptionButton__YgmRe"}},34138:function(e){e.exports={root:"SongPromptInput_root__awma9",inputWrapper:"SongPromptInput_inputWrapper__R1Dej",textInput:"SongPromptInput_textInput__8izhT",bottomControls:"SongPromptInput_bottomControls__eFf2u",leftControls:"SongPromptInput_leftControls__GRc9L",iconButton:"SongPromptInput_iconButton__bEwgv",disabled:"SongPromptInput_disabled__9Gp3B",createButton:"SongPromptInput_createButton__t1ZoA",buttonIcon:"SongPromptInput_buttonIcon__s3Isi",imagePreviewInline:"SongPromptInput_imagePreviewInline__m8Zfd",removeImageInline:"SongPromptInput_removeImageInline__iPKNd",errorMessage:"SongPromptInput_errorMessage__mbkGg",shake:"SongPromptInput_shake__bsv5J"}}}]);
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.