@acedatacloud/nexior 3.19.0 → 3.19.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{Auth-Bw1DOhJF.js → Auth-C-IuIG-B.js} +1 -1
- package/dist/assets/{BotPlaceholder-C_vy0qCQ.js → BotPlaceholder-BWFhmlAo.js} +1 -1
- package/dist/assets/{Callback-Cqk0rKBN.js → Callback-EUksYGmT.js} +1 -1
- package/dist/assets/{Console-qoC957to.js → Console-CCoikoR8.js} +1 -1
- package/dist/assets/{Conversation-MQNI8qlX.css → Conversation-CjRJo_oi.css} +1 -1
- package/dist/assets/{Conversation-uMvDRIJR.js → Conversation-D5F7bNRk.js} +3 -3
- package/dist/assets/{CopyToClipboard-CU-Bssp8.js → CopyToClipboard-BCGRlwJJ.js} +1 -1
- package/dist/assets/{Detail-cO4DPSNq.js → Detail-Dpi6TrM0.js} +1 -1
- package/dist/assets/{EditArray-C43_QVaw.js → EditArray-CNffMlZs.js} +1 -1
- package/dist/assets/{Extra-PdVV78Il.js → Extra-DO4acRM1.js} +1 -1
- package/dist/assets/{FilePreview-9n711Ra6.js → FilePreview-fVU_bWwG.js} +1 -1
- package/dist/assets/{History-B0qXtfS_.js → History-C9FxNW-l.js} +1 -1
- package/dist/assets/{ImagePreview-D6FjLfQO.js → ImagePreview-TA4gKfP6.js} +1 -1
- package/dist/assets/{ImageWrapper-DzYTbbFD.js → ImageWrapper-DiWDwTYN.js} +1 -1
- package/dist/assets/{Index-s-n_Jcpk.js → Index-B1xNRnzS.js} +1 -1
- package/dist/assets/{Index-B_5LccCK.js → Index-Bd8eGbDS.js} +1 -1
- package/dist/assets/{Index-DR--TL10.js → Index-BkOh3bne.js} +1 -1
- package/dist/assets/{Index-C5_lGkBZ.js → Index-BnFlUjW_.js} +1 -1
- package/dist/assets/{Index-CCxY1jnd.js → Index-Bx68JxDv.js} +1 -1
- package/dist/assets/{Index-C19C6xgu.js → Index-CDiKWMtk.js} +1 -1
- package/dist/assets/{Index-CLGNbukd.js → Index-CLLP-0_j.js} +1 -1
- package/dist/assets/{Index-C7Ncg6Qj.js → Index-CYZH4K_O.js} +1 -1
- package/dist/assets/{Index-C2_2zuSy.js → Index-CiCrJcLB.js} +1 -1
- package/dist/assets/{Index-Cg05F_5Q.js → Index-CmPTK3LL.js} +1 -1
- package/dist/assets/{Index-Bvgj_uOE.js → Index-D1NzhXpH.js} +1 -1
- package/dist/assets/{Index-Cs62YC8R.js → Index-D2We28NW.js} +1 -1
- package/dist/assets/{Index-tiwIgnaL.js → Index-DXMsU8Cz.js} +1 -1
- package/dist/assets/{Index-3q0rHE7m.js → Index-DclWXX-T.js} +1 -1
- package/dist/assets/{Index-PESGbhdr.js → Index-qn1KRXz8.js} +1 -1
- package/dist/assets/{InfoIcon-YhCcbV8z.js → InfoIcon-BJAJcb5a.js} +1 -1
- package/dist/assets/{Invitees-C2K1S9qq.js → Invitees-BPgw8JIs.js} +1 -1
- package/dist/assets/{List-jjkNRvFz.js → List-BAZxY2QY.js} +1 -1
- package/dist/assets/{List-DKz9i_BC.js → List-BRdMCfwC.js} +1 -1
- package/dist/assets/{List-DL89ylII.js → List-BdH_9_rT.js} +1 -1
- package/dist/assets/{Login-B2vP1VD7.js → Login-nlVKPBYj.js} +1 -1
- package/dist/assets/{Main-5-DxlbAw.js → Main-BFjhKPUF.js} +1 -1
- package/dist/assets/{Navigator-Dj-FFsqC.js → Navigator-BEzvNdn6.js} +1 -1
- package/dist/assets/{NoTasks-ex5PKih3.js → NoTasks-oiStcbHf.js} +1 -1
- package/dist/assets/{Pagination-DeEC_sGQ.js → Pagination-1fwMfKLT.js} +1 -1
- package/dist/assets/{Status-BmL-zn_q.js → Status-kXBbvBuV.js} +1 -1
- package/dist/assets/{Subscribe-BH-RryJn.js → Subscribe-pO6AF-vC.js} +1 -1
- package/dist/assets/{VideoPlayer-C0am2_1Y.js → VideoPlayer-CYaGmv09.js} +1 -1
- package/dist/assets/{_baseClone-BDmNDGGK.js → _baseClone-kJ5Pgx6e.js} +1 -1
- package/dist/assets/{_baseIteratee-LczmVVcS.js → _baseIteratee-35aC5hBk.js} +1 -1
- package/dist/assets/{_initCloneObject-CJq550xS.js → _initCloneObject-djD3gYlF.js} +1 -1
- package/dist/assets/{castArray-pZCaAVDW.js → castArray-TlECDAqv.js} +1 -1
- package/dist/assets/{debounce-Bzi7Cd91.js → debounce-DTzFlSYq.js} +1 -1
- package/dist/assets/{distribution-BcejgPw4.js → distribution-BNAm6hj-.js} +1 -1
- package/dist/assets/{dropdown-BG6nYAE4.js → dropdown-zSfjtIjT.js} +1 -1
- package/dist/assets/{index-DyxxJgEB.js → index-B7ak1Sj_.js} +1 -1
- package/dist/assets/{index-DiDFukvb.js → index-B85SWIvk.js} +1 -1
- package/dist/assets/{index-bImFSswd.js → index-BR0vba1Y.js} +1 -1
- package/dist/assets/{index-kbbIEoS7.js → index-BV4o_bfz.js} +1 -1
- package/dist/assets/{index-XAOdMJRW.js → index-Bgk8tZFf.js} +1 -1
- package/dist/assets/{index-H7zk7enZ.js → index-BqAthpig.js} +1 -1
- package/dist/assets/{index-BgQ-O6aa.js → index-BqzuTEwO.js} +1 -1
- package/dist/assets/{index-I4cHhAfY.js → index-Bth-8JIu.js} +1 -1
- package/dist/assets/{index-CNg43fsi.js → index-BzyEWvnL.js} +1 -1
- package/dist/assets/{index-DkUww0O6.js → index-C3GYDBc-.js} +1 -1
- package/dist/assets/{index-DTe9fRn-.js → index-C4ssJdBR.js} +2 -2
- package/dist/assets/{index-DCYB3TDh.js → index-C4trafQk.js} +1 -1
- package/dist/assets/{index-DjlWqdX5.js → index-CCjGuukj.js} +1 -1
- package/dist/assets/{index-0ZIggTSP.js → index-CPE0C_s4.js} +1 -1
- package/dist/assets/{index-DPoEMPUV.js → index-CP_56dlf.js} +1 -1
- package/dist/assets/{index-C5k9PNqL.js → index-CqTGsJay.js} +1 -1
- package/dist/assets/{index-CDCMsrCt.js → index-CzVzQVmI.js} +1 -1
- package/dist/assets/{index-DLyu6NQP.js → index-DEAamx_H.js} +1 -1
- package/dist/assets/{index-CuoHzlXN.js → index-DIwFcazb.js} +1 -1
- package/dist/assets/{index-CJ3Mnfei.css → index-DUrKxJFe.css} +1 -1
- package/dist/assets/{index-isAF6YJy.js → index-DislasB7.js} +1 -1
- package/dist/assets/{index-DkpfqXBZ.js → index-DpSdtysU.js} +1 -1
- package/dist/assets/{index-P6nOuLhh.js → index-DqySUAY6.js} +1 -1
- package/dist/assets/{index-DvXCzKR2.js → index-Drn8vYFB.js} +1 -1
- package/dist/assets/{index-DaEk4vUe.js → index-J4WBpiv9.js} +1 -1
- package/dist/assets/{index-DxTeNsnH.js → index-gFYmOD1F.js} +1 -1
- package/dist/assets/{index-N-T3RtWX.js → index-qJunmjSC.js} +1 -1
- package/dist/assets/{index-CdMzZF3s.js → index-tOFv-Cd9.js} +1 -1
- package/dist/assets/{index-Bp0DDosh.js → index-tdgIYwZh.js} +1 -1
- package/dist/assets/{index-MMWJF36O.js → index-zBoOr1pW.js} +1 -1
- package/dist/assets/{index.es-CJbKM0CV.js → index.es-EtbmiVQe.js} +1 -1
- package/dist/assets/{isEqual-CH8EZj5t.js → isEqual-BqBcCRrU.js} +1 -1
- package/dist/assets/{isPlainObject-zVqjHzMk.js → isPlainObject-BLPi94hV.js} +1 -1
- package/dist/assets/{order-DNAFc_Ok.js → order-BLvyPp28.js} +1 -1
- package/dist/assets/{price-C04dX6gR.js → price-DPmHeT6D.js} +1 -1
- package/dist/assets/{strings-CNF1iAZ6.js → strings-cAoZbHaH.js} +1 -1
- package/dist/assets/{typescript-BioIzq79.js → typescript-D14l1a1y.js} +1 -1
- package/dist/assets/{use-form-item-CtZlpzU6.js → use-form-item-CGJaz8fH.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as x}from"./index.es-CJbKM0CV.js";import{E as K}from"./index-C5k9PNqL.js";import{E as de}from"./index-CNg43fsi.js";import{ak as pe,aq as me,bJ as fe,al as ae,ca as he,_ as _e,d as b,a as $e,am as ve,c as F,bi as ge,bo as ke,ax as le,b as h,o as l,i as w,r as U,f as oe,e as V,j as $,b9 as re,E as R,n as ye,g as we,h as E,t as r,k as s,l as c,eS as se,x as v,F as z,v as N,eT as H,c7 as be,D as I,eU as Y,eV as Q,y,J as X,cO as ee,eW as B,bS as Ce,dn as W,ai as P,eX as G,ao as Se,K as Ae,eY as Le,df as Ee,dm as Ve}from"./index-DTe9fRn-.js";import{E as ce}from"./index-DkUww0O6.js";import{E as je,a as Fe}from"./index-DCYB3TDh.js";import{I as M}from"./InfoIcon-YhCcbV8z.js";import{E as Te}from"./index-DxTeNsnH.js";import{E as L}from"./index-H7zk7enZ.js";import{E as Z}from"./index-I4cHhAfY.js";import{E as Pe,a as ue}from"./index-CuoHzlXN.js";import{E as J}from"./index-Bp0DDosh.js";import{C as Ie,N as Ue}from"./NoTasks-ex5PKih3.js";import{a as ze}from"./price-C04dX6gR.js";import{E as De,a as Re,b as Ge}from"./index-DiDFukvb.js";import{E as Me}from"./index-DjlWqdX5.js";import{E as Oe}from"./index-CdMzZF3s.js";import{E as Be,a as We}from"./index-DyxxJgEB.js";import"./use-form-item-CtZlpzU6.js";import"./index-r5W6hzzQ.js";import"./index-DaEk4vUe.js";import"./index-DLyu6NQP.js";import"./typescript-BioIzq79.js";import"./strings-CNF1iAZ6.js";import"./castArray-pZCaAVDW.js";import"./isEqual-CH8EZj5t.js";import"./_initCloneObject-CJq550xS.js";import"./debounce-Bzi7Cd91.js";import"./_baseIteratee-LczmVVcS.js";import"./index-BgQ-O6aa.js";import"./index-DPoEMPUV.js";import"./_baseClone-BDmNDGGK.js";import"./index-MMWJF36O.js";import"./dropdown-BG6nYAE4.js";const qe=pe({size:{type:[Number,String],values:he,default:"",validator:e=>ae(e)},shape:{type:String,values:["circle","square"],default:"circle"},icon:{type:fe},src:{type:String,default:""},alt:String,srcSet:String,fit:{type:me(String),default:"cover"}}),Ne={error:e=>e instanceof Event},He=b({name:"ElAvatar"}),xe=b({...He,props:qe,emits:Ne,setup(e,{emit:t}){const i=e,o=$e("avatar"),a=ve(!1),u=F(()=>{const{size:n,icon:m,shape:k}=i,f=[o.b()];return ge(n)&&f.push(o.m(n)),m&&f.push(o.m("icon")),k&&f.push(o.m(k)),f}),d=F(()=>{const{size:n}=i;return ae(n)?o.cssVarBlock({size:ke(n)||""}):void 0}),p=F(()=>({objectFit:i.fit}));le(()=>i.src,()=>a.value=!1);function _(n){a.value=!0,t("error",n)}return(n,m)=>(l(),h("span",{class:ye(V(u)),style:oe(V(d))},[(n.src||n.srcSet)&&!a.value?(l(),h("img",{key:0,src:n.src,alt:n.alt,srcset:n.srcSet,style:oe(V(p)),onError:_},null,44,["src","alt","srcset"])):n.icon?(l(),w(V(R),{key:1},{default:$(()=>[(l(),w(re(n.icon)))]),_:1})):U(n.$slots,"default",{key:2})],6))}});var Ke=_e(xe,[["__file","avatar.vue"]]);const Xe=we(Ke),Ze=b({name:"LayoutSuno",components:{ElDrawer:de,ElButton:K,FontAwesomeIcon:x},data(){return{drawer:!1,preview:!1}},computed:{}}),Je={class:"main flex flex-row flex-1"},Ye={class:"config w-[300px] h-full overflow-y-scroll border-r border-[var(--el-border-color)]"},Qe={class:"result h-full flex flex-col flex-1 border-r border-[var(--el-border-color)]"},et={class:"preview h-full w-[300px] flex flex-col"};function tt(e,t,i,o,a,u){const d=c("font-awesome-icon"),p=c("el-button"),_=c("el-drawer");return l(),h("div",Je,[r("div",Ye,[U(e.$slots,"config",{},void 0,!0)]),r("div",Qe,[U(e.$slots,"result",{},void 0,!0)]),r("div",et,[U(e.$slots,"preview",{},void 0,!0)]),s(p,{circle:"",class:"menu",onClick:t[0]||(t[0]=n=>e.drawer=!0)},{default:$(()=>[s(d,{icon:"fa-solid fa-magic"})]),_:1}),s(_,{modelValue:e.drawer,"onUpdate:modelValue":t[1]||(t[1]=n=>e.drawer=n),direction:"ltr","with-header":!1,size:"340px",class:"drawer"},{default:$(()=>[U(e.$slots,"config",{},void 0,!0)]),_:3},8,["modelValue"])])}const ot=E(Ze,[["render",tt],["__scopeId","data-v-6cc632e5"]]),st=b({name:"VersionSelector",components:{ElSelect:Fe,ElOption:je,ElSwitch:ce},props:{modelValue:{type:String,default:void 0}},emits:["update:modelValue"],data(){return{options:[{label:this.$t("suno.model.model1"),value:"chirp-v2-xxl-alpha"},{label:this.$t("suno.model.model2"),value:"chirp-v3-0"},{label:this.$t("suno.model.model3"),value:"chirp-v3-5"},{label:this.$t("suno.model.model4"),value:"chirp-v4"},{label:this.$t("suno.model.model45"),value:"chirp-v4-5"}]}},computed:{custom:{get(){return this.$store.state.suno?.config?.custom},set(e){console.debug("set custom",e),this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,custom:e})}},model:{get(){return this.$store.state.suno?.config?.model},set(e){console.debug("set model",e),this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,model:e})}}},mounted(){this.model||(console.debug("set default type",se),this.model=se)}}),nt={class:"field"},it={class:"title font-bold"};function at(e,t,i,o,a,u){const d=c("el-switch"),p=c("el-option"),_=c("el-select");return l(),h("div",nt,[r("h2",it,v(e.$t("suno.name.type")),1),s(d,{modelValue:e.custom,"onUpdate:modelValue":t[0]||(t[0]=n=>e.custom=n),class:"value"},null,8,["modelValue"]),s(_,{modelValue:e.model,"onUpdate:modelValue":t[1]||(t[1]=n=>e.model=n),class:"value",placeholder:e.$t("suno.placeholder.select")},{default:$(()=>[(l(!0),h(z,null,N(e.options,n=>(l(),w(p,{key:n.value,label:n.label,value:n.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])])}const lt=E(st,[["render",at],["__scopeId","data-v-5a66a01f"]]),rt=b({name:"UploadAudio",components:{ElUpload:Te,ElButton:K,InfoIcon:M,FontAwesomeIcon:x},emits:["change"],data(){return{fileList:[],uploadUrl:be()+"/api/v1/files/"}},computed:{headers(){return{Authorization:`Bearer ${this.$store.state.token.access}`}},credential(){return this.$store.state.suno.credential},config(){return this.$store.state.suno.config},urls(){return this.fileList.map(e=>e?.response?.file_url)},value:{get(){return this.$store.state.suno?.config?.audio_id},set(){}}},watch:{urls:{handler(e){this.$emit("change",e)}}},mounted(){this.value||(this.value=void 0),this.onSetAudio()},methods:{onExceed(){L.warning(this.$t("suno.message.uploadReferencesExceed"))},onError(){L.error(this.$t("suno.message.uploadReferencesError"))},async onSuccess(){const e=this.urls?.[0];await this.onGenerateAudioId(e)},async onGenerateAudioId(e){const t={audio_url:e},i=this.credential?.token;if(!i){console.error("no token specified");return}L.info(this.$t("suno.message.startingUploadAudio")),H.upload(t,{token:i}).then(o=>{console.debug("get upload music success",o.data);const a=o.data?.data.audio_id;this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,audio_id:a,action:"upload_extend"}),L.success(this.$t("suno.message.startUploadAudioSuccess"))}).catch(o=>{L.error(o?.response?.data?.error?.message||this.$t("suno.message.startUploadAudioFailed"))})},onSetAudio(){}}}),ct={class:"relative"},ut={class:"flex justify-between"},dt={class:"flex justify-start items-center"},pt={class:"text-sm font-bold"};function mt(e,t,i,o,a,u){const d=c("info-icon"),p=c("font-awesome-icon"),_=c("el-button"),n=c("el-upload");return l(),h("div",ct,[r("div",ut,[r("div",dt,[r("span",pt,v(e.$t("suno.name.referenceAudios")),1),s(d,{content:e.$t("suno.description.uploadAudios")},null,8,["content"])])]),s(n,{"file-list":e.fileList,"onUpdate:fileList":t[0]||(t[0]=m=>e.fileList=m),name:"file",limit:1,class:"upload-wrapper",action:e.uploadUrl,accept:".mp3","show-file-list":!0,"on-exceed":e.onExceed,"on-error":e.onError,"on-success":e.onSuccess,headers:e.headers},{default:$(()=>[s(_,{round:"",type:"primary",size:"small",class:"btn btn-upload"},{default:$(()=>[s(p,{icon:"fa-solid fa-upload",class:"icon mr-1"}),I(" "+v(e.$t("suno.button.uploadAudios")),1)]),_:1})]),_:1},8,["file-list","action","on-exceed","on-error","on-success","headers"])])}const ft=E(rt,[["render",mt],["__scopeId","data-v-6236152c"]]),ht="",_t=b({name:"PromptInput",components:{ElInput:Z,ElSwitch:ce,InfoIcon:M},data(){return{}},computed:{prompt:{get(){return this.$store.state.suno?.config?.prompt},set(e){console.debug("set prompt",e),this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,prompt:e})}},instrumental:{get(){return this.$store.state.suno?.config?.instrumental},set(e){console.debug("set instrumental",e),this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,instrumental:e})}}},mounted(){this.prompt||(this.prompt=ht)}}),$t={class:"field"},vt={class:"box"},gt={class:"title-info"},kt={class:"title font-bold"},yt={class:"instrumental"},wt={class:"title inline-block"};function bt(e,t,i,o,a,u){const d=c("info-icon"),p=c("el-switch"),_=c("el-input");return l(),h("div",$t,[r("div",vt,[r("div",gt,[r("h2",kt,v(e.$t("suno.name.prompt")),1),s(d,{content:e.$t("suno.description.prompt"),class:"info"},null,8,["content"])]),r("div",yt,[s(p,{modelValue:e.instrumental,"onUpdate:modelValue":t[0]||(t[0]=n=>e.instrumental=n),class:"value mr-2"},null,8,["modelValue"]),r("h2",wt,v(e.$t("suno.name.instrumental")),1)])]),s(_,{modelValue:e.prompt,"onUpdate:modelValue":t[1]||(t[1]=n=>e.prompt=n),rows:3,type:"textarea",class:"prompt",placeholder:e.$t("suno.placeholder.prompt"),maxlength:200,"show-word-limit":""},null,8,["modelValue","placeholder"])])}const Ct=E(_t,[["render",bt],["__scopeId","data-v-d7004a7c"]]),St="",At=b({name:"LyricInput",components:{ElInput:Z,InfoIcon:M},data(){return{}},computed:{lyric:{get(){return this.$store.state.suno?.config?.lyric},set(e){console.debug("set lyric",e),this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,lyric:e})}},config(){return this.$store.state.suno?.config}},mounted(){this.lyric||(this.lyric=St)}}),Lt={class:"field"},Et={class:"box"},Vt={class:"title font-bold"};function jt(e,t,i,o,a,u){const d=c("info-icon"),p=c("el-input");return l(),h("div",Lt,[r("div",Et,[r("h2",Vt,v(e.$t("suno.name.lyrics")),1),s(d,{content:e.$t("suno.description.lyrics"),class:"info"},null,8,["content"])]),e.config?.action!=="extend"?(l(),w(p,{key:0,modelValue:e.lyric,"onUpdate:modelValue":t[0]||(t[0]=_=>e.lyric=_),rows:3,type:"textarea",class:"lyrics",placeholder:e.$t("suno.placeholder.lyrics"),maxlength:3e3,"show-word-limit":""},null,8,["modelValue","placeholder"])):(l(),w(p,{key:1,modelValue:e.lyric,"onUpdate:modelValue":t[1]||(t[1]=_=>e.lyric=_),rows:3,type:"textarea",class:"lyrics",placeholder:e.$t("suno.placeholder.extend.lyrics"),maxlength:3e3,"show-word-limit":""},null,8,["modelValue","placeholder"]))])}const Ft=E(At,[["render",jt],["__scopeId","data-v-99dfded8"]]),Tt=b({name:"StyleInput",components:{ElInput:Z,InfoIcon:M},data(){return{}},computed:{style:{get(){return this.$store.state.suno?.config?.style},set(e){console.debug("set style",e),this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,style:e})}},config(){return this.$store.state.suno?.config}}}),Pt={class:"field"},It={class:"title-container"},Ut={class:"titlefont-bold"};function zt(e,t,i,o,a,u){const d=c("info-icon"),p=c("el-input");return l(),h("div",Pt,[r("div",It,[r("h2",Ut,v(e.$t("suno.name.style")),1),s(d,{content:e.$t("suno.description.style"),class:"info"},null,8,["content"])]),s(p,{modelValue:e.style,"onUpdate:modelValue":t[0]||(t[0]=_=>e.style=_),rows:3,type:"textarea",class:"style",placeholder:e.$t("suno.placeholder.style"),maxlength:200,"show-word-limit":""},null,8,["modelValue","placeholder"])])}const Dt=E(Tt,[["render",zt],["__scopeId","data-v-85bbfcaa"]]),Rt=b({name:"TitleInput",components:{ElInput:Z,InfoIcon:M},data(){return{}},computed:{title:{get(){return this.$store.state.suno?.config?.title},set(e){console.debug("set title",e),this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,title:e})}},instrumental:{get(){return this.$store.state.suno?.config?.instrumental},set(e){console.debug("set instrumental",e),this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,instrumental:e})}}}}),Gt={class:"field"},Mt={class:"title-container"},Ot={class:"title font-bold"};function Bt(e,t,i,o,a,u){const d=c("info-icon"),p=c("el-input");return l(),h("div",Gt,[r("div",Mt,[r("h2",Ot,v(e.$t("suno.name.title")),1),s(d,{content:e.$t("suno.description.title"),class:"info"},null,8,["content"])]),s(p,{modelValue:e.title,"onUpdate:modelValue":t[0]||(t[0]=_=>e.title=_),rows:3,type:"textarea",class:"title",placeholder:e.$t("suno.placeholder.title"),maxlength:80,"show-word-limit":""},null,8,["modelValue","placeholder"])])}const Wt=E(Rt,[["render",Bt],["__scopeId","data-v-ce70fe34"]]);function D(e){const t=Math.floor(e)%60;e=Math.floor(e/60);const i=e%60,o=i<10?`0${i}`:i,a=t<10?`0${t}`:t;return o+":"+a}const qt=b({name:"ExtendFromInput",components:{ElImage:J,ElIcon:R,ElInputNumber:Pe,VideoPlay:Q,VideoPause:Y},data(){return{}},computed:{audio(){return this.$store.state.suno?.config?.audio},value:{get(){return this.$store.state.suno?.config?.continue_at},set(e){console.debug("set continue_at",e),this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,continue_at:e?parseInt(e):void 0})}}},mounted(){this.value||(this.value=void 0)},methods:{handleChange(e){if(e===void 0){this.value=void 0;return}e<0?this.value=0:e>this.audio?.duration?this.value=this.audio?.duration:this.value=e},useFormatDuring:D,onPlay(e){this.$store.dispatch("suno/setAudio",{...this.$store.state.suno.audio,...e,state:"playing"}),console.log("on play")},onPause(e){this.$store.dispatch("suno/setAudio",{...this.$store.state.suno.audio,...e,state:"paused"}),console.log("on pause")},onClick(e){this.$store.state?.suno?.audio?.id!==e.id&&this.onPlay({...e,progress:0})}}}),Nt={class:"field"},Ht={class:"box"},xt={class:"title font-bold"},Kt={class:"input-wrapper"},Xt={class:"task"},Zt={class:"left"},Jt={key:2,class:"duration"},Yt={class:"info"},Qt={class:"title"},eo={class:"style"};function to(e,t,i,o,a,u){const d=c("el-input-number"),p=c("el-image"),_=c("video-pause"),n=c("el-icon"),m=c("video-play"),k=ee("loading");return l(),h("div",Nt,[r("div",Ht,[r("h2",xt,v(e.$t("suno.name.extend")),1),r("div",Kt,[s(d,{modelValue:e.value,"onUpdate:modelValue":t[0]||(t[0]=f=>e.value=f),class:"value",min:0,max:e.audio?.duration,controls:!1,placeholder:e.$t("suno.placeholder.extend.continue_at"),onChange:e.handleChange},null,8,["modelValue","max","placeholder","onChange"])])]),r("div",Xt,[e.audio?(l(),h("div",{key:0,class:"audio",onClick:t[3]||(t[3]=f=>e.onClick(e.audio))},[X((l(),h("div",Zt,[s(p,{src:e.audio?.image_url,class:"cover",fit:"cover"},null,8,["src"]),e.audio?.audio_url&&e.$store.state?.suno?.audio?.id===e.audio.id&&e.$store.state?.suno?.audio?.state==="playing"?(l(),h("div",{key:0,class:"overlay",onClick:t[1]||(t[1]=f=>e.onPause(e.audio))},[s(n,null,{default:$(()=>[s(_)]),_:1})])):y("",!0),e.audio?.audio_url&&(e.$store.state?.suno?.audio?.id!==e.audio.id||e.$store.state?.suno?.audio?.id===e.audio.id&&e.$store.state?.suno?.audio?.state==="paused")?(l(),h("div",{key:1,class:"overlay",onClick:t[2]||(t[2]=f=>e.onPlay(e.audio))},[s(n,null,{default:$(()=>[s(m)]),_:1})])):y("",!0),e.audio?.duration?(l(),h("div",Jt,v(e.useFormatDuring(e.audio?.duration)),1)):y("",!0)])),[[k,!e.audio?.audio_url]]),r("div",Yt,[r("h2",Qt,v(e.audio?.title),1),r("p",eo,v(e.audio?.style),1)])])):y("",!0)])])}const oo=E(qt,[["render",to],["__scopeId","data-v-bcce4821"]]),so=b({name:"CoverFromInput",components:{ElImage:J,ElIcon:R,VideoPlay:Q,VideoPause:Y},data(){return{}},computed:{audio(){return this.$store.state.suno?.config?.audio},value:{get(){return this.$store.state.suno?.config?.continue_at},set(e){console.debug("set continue_at",e),this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,continue_at:e?parseInt(e):void 0})}}},mounted(){this.value||(this.value=void 0)},methods:{handleChange(e){e<0?this.value=0:e>this.audio?.duration?this.value=this.audio?.duration:this.value=e},useFormatDuring:D,onPlay(e){this.$store.dispatch("suno/setAudio",{...this.$store.state.suno.audio,...e,state:"playing"}),console.log("on play")},onPause(e){this.$store.dispatch("suno/setAudio",{...this.$store.state.suno.audio,...e,state:"paused"}),console.log("on pause")},onClick(e){this.$store.state?.suno?.audio?.id!==e.id&&this.onPlay({...e,progress:0})}}}),no={class:"field"},io={class:"box"},ao={class:"title font-bold"},lo={class:"task"},ro={class:"left"},co={key:2,class:"duration"},uo={class:"info"},po={class:"title"},mo={class:"style"};function fo(e,t,i,o,a,u){const d=c("el-image"),p=c("video-pause"),_=c("el-icon"),n=c("video-play"),m=ee("loading");return l(),h("div",no,[r("div",io,[r("h2",ao,v(e.$t("suno.name.cover")),1)]),r("div",lo,[e.audio?(l(),h("div",{key:0,class:"audio",onClick:t[2]||(t[2]=k=>e.onClick(e.audio))},[X((l(),h("div",ro,[s(d,{src:e.audio?.image_url,class:"cover",fit:"cover"},null,8,["src"]),e.audio?.audio_url&&e.$store.state?.suno?.audio?.id===e.audio.id&&e.$store.state?.suno?.audio?.state==="playing"?(l(),h("div",{key:0,class:"overlay",onClick:t[0]||(t[0]=k=>e.onPause(e.audio))},[s(_,null,{default:$(()=>[s(p)]),_:1})])):y("",!0),e.audio?.audio_url&&(e.$store.state?.suno?.audio?.id!==e.audio.id||e.$store.state?.suno?.audio?.id===e.audio.id&&e.$store.state?.suno?.audio?.state==="paused")?(l(),h("div",{key:1,class:"overlay",onClick:t[1]||(t[1]=k=>e.onPlay(e.audio))},[s(_,null,{default:$(()=>[s(n)]),_:1})])):y("",!0),e.audio?.duration?(l(),h("div",co,v(e.useFormatDuring(e.audio?.duration)),1)):y("",!0)])),[[m,!e.audio?.audio_url]]),r("div",uo,[r("h2",po,v(e.audio?.title),1),r("p",mo,v(e.audio?.style),1)])])):y("",!0)])])}const ho=E(so,[["render",fo],["__scopeId","data-v-06640216"]]),_o=b({name:"PresetPanel",components:{TypeSelector:lt,PromptInput:Ct,LyricInput:Ft,StyleInput:Dt,TitleInput:Wt,ExtendFromInput:oo,CoverFromInput:ho,UploadAudio:ft,FontAwesomeIcon:x,ElButton:K,Consumption:Ie},emits:["generate"],computed:{config(){return this.$store.state.suno?.config},consumption(){return ze(this.config,this.service?.metadata?.price)},service(){return this.$store.state.suno?.service}},methods:{onGenerate(){this.$emit("generate")}}}),$o={class:"flex flex-col h-full"},vo={class:"flex-1 overflow-y-auto p-[15px]"},go={class:"flex flex-col items-center justify-center px-[15px] pb-[15px]"};function ko(e,t,i,o,a,u){const d=c("type-selector"),p=c("upload-audio"),_=c("prompt-input"),n=c("lyric-input"),m=c("style-input"),k=c("title-input"),f=c("extend-from-input"),C=c("cover-from-input"),j=c("consumption"),T=c("font-awesome-icon"),A=c("el-button");return l(),h("div",$o,[r("div",vo,[s(d,{class:"mb-4"}),s(p,{class:"mb-4"}),e.config?.custom?y("",!0):(l(),w(_,{key:0,class:"mb-4"})),e.config?.custom&&!e.config.instrumental?(l(),w(n,{key:1,class:"mb-4"})):y("",!0),e.config?.custom?(l(),w(m,{key:2,class:"mb-4"})):y("",!0),e.config?.custom?(l(),w(k,{key:3,class:"mb-4"})):y("",!0),e.config?.action==="extend"?(l(),w(f,{key:4,class:"mb-4"})):y("",!0),e.config?.action==="cover"?(l(),w(C,{key:5,class:"mb-4"})):y("",!0)]),r("div",go,[s(j,{value:e.consumption,service:e.service},null,8,["value","service"]),e.config?.action!=="extend"?(l(),w(A,{key:0,type:"primary",class:"btn w-full",round:"",onClick:e.onGenerate},{default:$(()=>[s(T,{icon:"fa-solid fa-magic",class:"mr-2"}),I(" "+v(e.$t("suno.button.generate")),1)]),_:1},8,["onClick"])):(l(),w(A,{key:1,type:"primary",class:"btn w-full",round:"",onClick:e.onGenerate},{default:$(()=>[s(T,{icon:"fa-solid fa-magic",class:"mr-2"}),I(" "+v(e.$t("suno.button.extend")),1)]),_:1},8,["onClick"]))])])}const yo=E(_o,[["render",ko],["__scopeId","data-v-b9fab929"]]);var q={exports:{}},wo=q.exports,ne;function bo(){return ne||(ne=1,function(e,t){(function(i,o){o()})(wo,function(){function i(n,m){return typeof m>"u"?m={autoBom:!1}:typeof m!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),m={autoBom:!m}),m.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(n.type)?new Blob(["\uFEFF",n],{type:n.type}):n}function o(n,m,k){var f=new XMLHttpRequest;f.open("GET",n),f.responseType="blob",f.onload=function(){_(f.response,m,k)},f.onerror=function(){console.error("could not download file")},f.send()}function a(n){var m=new XMLHttpRequest;m.open("HEAD",n,!1);try{m.send()}catch{}return 200<=m.status&&299>=m.status}function u(n){try{n.dispatchEvent(new MouseEvent("click"))}catch{var m=document.createEvent("MouseEvents");m.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),n.dispatchEvent(m)}}var d=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof B=="object"&&B.global===B?B:void 0,p=d.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),_=d.saveAs||(typeof window!="object"||window!==d?function(){}:"download"in HTMLAnchorElement.prototype&&!p?function(n,m,k){var f=d.URL||d.webkitURL,C=document.createElement("a");m=m||n.name||"download",C.download=m,C.rel="noopener",typeof n=="string"?(C.href=n,C.origin===location.origin?u(C):a(C.href)?o(n,m,k):u(C,C.target="_blank")):(C.href=f.createObjectURL(n),setTimeout(function(){f.revokeObjectURL(C.href)},4e4),setTimeout(function(){u(C)},0))}:"msSaveOrOpenBlob"in navigator?function(n,m,k){if(m=m||n.name||"download",typeof n!="string")navigator.msSaveOrOpenBlob(i(n,k),m);else if(a(n))o(n,m,k);else{var f=document.createElement("a");f.href=n,f.target="_blank",setTimeout(function(){u(f)})}}:function(n,m,k,f){if(f=f||open("","_blank"),f&&(f.document.title=f.document.body.innerText="downloading..."),typeof n=="string")return o(n,m,k);var C=n.type==="application/octet-stream",j=/constructor/i.test(d.HTMLElement)||d.safari,T=/CriOS\/[\d]+/.test(navigator.userAgent);if((T||C&&j||p)&&typeof FileReader<"u"){var A=new FileReader;A.onloadend=function(){var S=A.result;S=T?S:S.replace(/^data:[^;]*;/,"data:attachment/file;"),f?f.location.href=S:location=S,f=null},A.readAsDataURL(n)}else{var O=d.URL||d.webkitURL,g=O.createObjectURL(n);f?f.location=g:location.href=g,f=null,setTimeout(function(){O.revokeObjectURL(g)},4e4)}});d.saveAs=_.saveAs=_,e.exports=_})}(q)),q.exports}var Co=bo();const So="https://webhook.acedata.cloud/suno",Ao=b({name:"TaskPreview",components:{ElImage:J,ElIcon:R,ElTooltip:Me,ElButton:K,FontAwesomeIcon:x,VideoPlay:Q,VideoPause:Y,ElDropdown:Ge,ElDropdownMenu:Re,ElDropdownItem:De,Loading:Ce},props:{modelValue:{type:Object,required:!0}},data(){return{isFetchingVideoUrl:!1}},computed:{loading(){return this.$store.state.suno?.status?.getApplications===W.Request},credential(){return this.$store.state.suno.credential},config(){return this.$store.state.suno.config},task(){return this.$store.state.suno?.tasks},audios(){const e=this.modelValue?.response?.data??[],t=this.modelValue?.request?.action;return t?e.map(i=>({...i,action:t})):e},application(){return this.$store.state.suno?.application},active(){return this.$store.state.suno?.tasks?.active}},methods:{useFormatDuring:D,onPlay(e){this.$store.dispatch("suno/setAudio",{...this.$store.state.suno.audio,...e,state:"playing"}),console.log("on play")},onPause(e){this.$store.dispatch("suno/setAudio",{...this.$store.state.suno.audio,...e,state:"paused"}),console.log("on pause")},onClick(e){this.$store.state?.suno?.audio?.id!==e.id&&this.onPlay({...e,progress:0})},onExtend(e,t){e.stopPropagation(),console.log("on extend"),console.debug("set config",t),this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,model:t.model,custom:!0,instrumental:!1,style:t.style,action:"extend",audio:t,audio_id:t.id,continue_at:t.duration})},onDownload(e,t){e&&e.stopPropagation(),console.log("on download",t);const o=new URL(t).pathname,a=o.substring(o.lastIndexOf("/")+1);console.log("on preview",a),fetch(t).then(u=>u.blob()).then(u=>{Co.saveAs(u,a)})},async handleVideoDownload(e){if(e.video_url){this.onDownload(null,e.video_url);return}if(!this.isFetchingVideoUrl)try{this.isFetchingVideoUrl=!0;const t=await this.fetchVideoUrlFromApi(e?.id);console.log(`get videoUrl: ${t}`),e.video_url=t,this.onDownload(null,t)}catch(t){console.error("get videoUrl failed:",t),L.error(this.$t("suno.message.getVideoUrlFailed"))}finally{this.isFetchingVideoUrl=!1}},async fetchVideoUrlFromApi(e){return new Promise((t,i)=>{const o={audio_id:e},a=this.credential?.token;if(!a){console.error("no token specified"),i(new Error("No token specified"));return}H.mp4(o,{token:a}).then(u=>{const d=u.data?.data?.video_url;d?t(d):i(new Error("Video URL not found in response"))}).catch(u=>{i(u)})})},onPreview(e,t){e.stopPropagation(),console.log("on preview",t),window.open(t,"_blank")},async onGetStems(e){await this.onGenerateAudioUrl("stems",e)},onCover(e){console.log("on cover"),console.debug("set config",e),this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,model:e.model,custom:!0,instrumental:!1,style:e.style,action:"cover",audio:e,audio_id:e.id})},async onConcatMusic(e){await this.onGenerateAudioUrl("concat",e)},async onGenerateAudioUrl(e,t){const i={action:e,audio_id:t,callback_url:So},o=this.credential?.token;if(!o){console.error("no token specified");return}L.info(this.$t("suno.message.startingTask")),H.audio(i,{token:o}).then(()=>{L.success(this.$t("suno.message.startTaskSuccess"))}).catch(a=>{L.error(a?.response?.data?.error?.message||this.$t("suno.message.startTaskFailed"))}).finally(async()=>{await this.onGetTasks(),await this.onScrollDown()})},async onScrollDown(){setTimeout(()=>{const e=document.querySelector(".tasks");e&&(e.scrollTop=e.scrollHeight)},1e3)},async onGetTasks(){if(this.loading){console.debug("loading");return}await this.$store.dispatch("suno/getTasks",{limit:30,offset:0})}}}),Lo={class:"task"},Eo=["onClick"],Vo={class:"left"},jo=["onClick"],Fo=["onClick"],To={key:2,class:"duration"},Po={class:"info"},Io={class:"title"},Uo={class:"style"},zo={class:"right"},Do={class:"el-dropdown-link"},Ro={class:"flex items-center min-w-[120px]"},Go={class:"el-dropdown-link"};function Mo(e,t,i,o,a,u){const d=c("el-image"),p=c("video-pause"),_=c("el-icon"),n=c("video-play"),m=c("el-button"),k=c("font-awesome-icon"),f=c("el-tooltip"),C=c("Loading"),j=c("el-dropdown-item"),T=c("el-dropdown-menu"),A=c("el-dropdown"),O=ee("loading");return l(),h("div",Lo,[(l(!0),h(z,null,N(e.audios,g=>(l(),h("div",{key:g.id,class:"audio",onClick:P(S=>e.onClick(g),["stop"])},[X((l(),h("div",Vo,[s(d,{src:g?.image_url,class:"cover",fit:"cover",lazy:""},null,8,["src"]),g?.audio_url&&e.$store.state?.suno?.audio?.id===g.id&&e.$store.state?.suno?.audio?.state==="playing"?(l(),h("div",{key:0,class:"overlay",onClick:P(S=>e.onPause(g),["stop"])},[s(_,null,{default:$(()=>[s(p)]),_:1})],8,jo)):y("",!0),g?.audio_url&&(e.$store.state?.suno?.audio?.id!==g.id||e.$store.state?.suno?.audio?.id===g.id&&e.$store.state?.suno?.audio?.state==="paused")?(l(),h("div",{key:1,class:"overlay",onClick:P(S=>e.onPlay(g),["stop"])},[s(_,null,{default:$(()=>[s(n)]),_:1})],8,Fo)):y("",!0),g?.duration?(l(),h("div",To,v(e.useFormatDuring(g?.duration)),1)):y("",!0)])),[[O,!g?.audio_url]]),r("div",Po,[r("h2",Io,v(g?.title),1),r("p",Uo,v(g?.style),1)]),r("div",zo,[g?.audio_url?(l(),w(m,{key:0,size:"small",round:"",onClick:P(S=>e.onExtend(S,g),["stop"])},{default:$(()=>[I(v(e.$t("suno.button.extend")),1)]),_:2},1032,["onClick"])):y("",!0),s(A,null,{dropdown:$(()=>[s(T,null,{default:$(()=>[s(j,{disabled:e.isFetchingVideoUrl,onClick:S=>e.handleVideoDownload(g)},{default:$(()=>[r("div",Ro,[e.isFetchingVideoUrl?(l(),w(_,{key:0,class:"is-loading mr-2"},{default:$(()=>[s(C)]),_:1})):y("",!0),r("span",null,v(e.$t("suno.button.download_video")),1)])]),_:2},1032,["disabled","onClick"]),g?.audio_url?(l(),w(j,{key:0,onClick:P(S=>e.onDownload(S,g?.audio_url),["stop"])},{default:$(()=>[I(v(e.$t("suno.button.download_audio")),1)]),_:2},1032,["onClick"])):y("",!0)]),_:2},1024)]),default:$(()=>[r("span",Do,[s(f,{effect:"dark",content:e.$t("suno.button.download"),placement:"top"},{default:$(()=>[g?.audio_url||g?.video_url?(l(),w(k,{key:0,icon:"fa-solid fa-download",class:"icon icon-download"})):y("",!0)]),_:2},1032,["content"])])]),_:2},1024),s(A,null,{dropdown:$(()=>[s(T,null,{default:$(()=>[g.id?(l(),w(j,{key:0,onClick:P(S=>e.onGetStems(g.id),["stop"])},{default:$(()=>[I(v(e.$t("suno.button.get_stems")),1)]),_:2},1032,["onClick"])):y("",!0),s(j,{onClick:P(S=>e.onCover(g),["stop"])},{default:$(()=>[I(v(e.$t("suno.button.cover_music")),1)]),_:2},1032,["onClick"]),g?.id&&g?.action==="extend"?(l(),w(j,{key:1,onClick:P(S=>e.onConcatMusic(g?.id),["stop"])},{default:$(()=>[I(v(e.$t("suno.button.concat_music")),1)]),_:2},1032,["onClick"])):y("",!0)]),_:2},1024)]),default:$(()=>[r("span",Go,[s(f,{effect:"dark",content:e.$t("suno.button.more"),placement:"top"},{default:$(()=>[g?.audio_url||g?.video_url?(l(),w(k,{key:0,icon:"fa-solid fa-ellipsis",class:"icon icon-ellipsis"})):y("",!0)]),_:2},1032,["content"])])]),_:2},1024)])],8,Eo))),128))])}const Oo=E(Ao,[["render",Mo]]),Bo={class:"player-slider"},Wo=b({__name:"PlayerSlider",setup(e){const t=G(),i=F({get:()=>t.state.suno?.audio?.progress,set:d=>t.commit("suno/setAudio",{...t.state.suno.audio,progress:d})}),o=F({get:()=>t.state.suno?.audio?.duration,set:d=>t.commit("suno/setAudio",{...t.state.suno.audio,duration:d})}),a=()=>{},u=d=>t.dispatch("suno/setAudio",{...t.state.suno.audio,progress:d});return(d,p)=>(l(),h("div",Bo,[s(V(ue),{modelValue:i.value,"onUpdate:modelValue":p[0]||(p[0]=_=>i.value=_),"show-tooltip":!1,min:0,max:o.value,onChange:u,onInput:a},null,8,["modelValue","max"])]))}}),qo="/assets/disk-XFRmVAfp.png",No={class:"flex player-song"},Ho=["src"],xo={class:"ml-2 text-xs flex flex-col justify-between"},Ko={class:"w-52 2xl:w-96 cursor-pointer truncate"},Xo={class:"flex"},Zo={class:"ml-2 text-dc"},Jo=b({__name:"PlayerSong",setup(e){const t=G(),i=F({get:()=>t.state.suno.audio,set:o=>t.commit("suno/setAudio",o)});return le(i,(o,a)=>{if(o?.audio_url!==a?.audio_url){console.log("audio changed",o),o.object&&(console.log("111",o.object),o.object.pause(),delete o.object);const u=new Audio(o.audio_url);o.state==="playing"?u.play():u.pause(),u.addEventListener("loadedmetadata",()=>{u.currentTime=0,u.addEventListener("timeupdate",()=>{t.commit("suno/setAudio",{...t.state.suno.audio,progress:u.currentTime})})}),t.commit("suno/setAudio",{...t.state.suno.audio,object:u})}else if(o?.progress!==a?.progress&&Math.abs(o.progress-o.object.currentTime)>2){console.log("progress changed",o.progress);const u=t.state.suno.audio;u.object&&(u.object.currentTime=u.progress)}else o?.state!==a?.state&&(console.log("state changed",o.state),o.object&&(o.state==="playing"?o.object.play():o.object.pause()));o?.volume!==a?.volume&&(console.log("volume changed",o.volume),o.object&&(o.object.volume=o.volume/100))}),(o,a)=>(l(),h("div",No,[r("img",{alt:"",class:"w-11 h-11 rounded",src:i.value?.image_url||V(qo)},null,8,Ho),r("div",xo,[r("div",Ko,[r("div",Xo,[r("span",null,v(i.value?.title||"Music"),1),r("span",Zo,"- "+v(i.value?.style||"SmallRuralDog"),1)])])])]))}}),Yo={class:"flex justify-end items-center gap-x-2.5"},Qo={class:"text-xs"},es=b({__name:"PlayerAction",setup(e){const t=G(),i=F({get:()=>t.state.suno?.audio?.progress,set:a=>t.commit("suno/setAudio",{...t.state.suno.audio,progress:a})}),o=F({get:()=>t.state.suno?.audio?.duration,set:a=>t.commit("suno/setAudio",{...t.state.suno.audio,duration:a})});return(a,u)=>(l(),h("div",Yo,[r("span",Qo,v(V(D)(i.value))+" / "+v(V(D)(o.value)),1)]))}});var ts={size:"1em",strokeWidth:4,strokeLinecap:"round",strokeLinejoin:"round",rtl:!1,theme:"outline",colors:{outline:{fill:"#333",background:"transparent"},filled:{fill:"#333",background:"#FFF"},twoTone:{fill:"#333",twoTone:"#2F88FF"},multiColor:{outStrokeColor:"#333",outFillColor:"#2F88FF",innerStrokeColor:"#FFF",innerFillColor:"#43CCF8"}},prefix:"i"};function os(){return"icon-"+((1+Math.random())*4294967296|0).toString(16).substring(1)}function ss(e,t,i){var o=typeof t.fill=="string"?[t.fill]:t.fill||[],a=[],u=t.theme||i.theme;switch(u){case"outline":a.push(typeof o[0]=="string"?o[0]:"currentColor"),a.push("none"),a.push(typeof o[0]=="string"?o[0]:"currentColor"),a.push("none");break;case"filled":a.push(typeof o[0]=="string"?o[0]:"currentColor"),a.push(typeof o[0]=="string"?o[0]:"currentColor"),a.push("#FFF"),a.push("#FFF");break;case"two-tone":a.push(typeof o[0]=="string"?o[0]:"currentColor"),a.push(typeof o[1]=="string"?o[1]:i.colors.twoTone.twoTone),a.push(typeof o[0]=="string"?o[0]:"currentColor"),a.push(typeof o[1]=="string"?o[1]:i.colors.twoTone.twoTone);break;case"multi-color":a.push(typeof o[0]=="string"?o[0]:"currentColor"),a.push(typeof o[1]=="string"?o[1]:i.colors.multiColor.outFillColor),a.push(typeof o[2]=="string"?o[2]:i.colors.multiColor.innerStrokeColor),a.push(typeof o[3]=="string"?o[3]:i.colors.multiColor.innerFillColor);break}return{size:t.size||i.size,strokeWidth:t.strokeWidth||i.strokeWidth,strokeLinecap:t.strokeLinecap||i.strokeLinecap,strokeLinejoin:t.strokeLinejoin||i.strokeLinejoin,colors:a,id:e}}var ns=Symbol("icon-context");function te(e,t,i){var o={name:"icon-"+e,props:["size","strokeWidth","strokeLinecap","strokeLinejoin","theme","fill","spin"],setup:function(u){var d=os(),p=Se(ns,ts);return function(){var _=u.size,n=u.strokeWidth,m=u.strokeLinecap,k=u.strokeLinejoin,f=u.theme,C=u.fill,j=u.spin,T=ss(d,{size:_,strokeWidth:n,strokeLinecap:m,strokeLinejoin:k,theme:f,fill:C},p),A=[p.prefix+"-icon"];return A.push(p.prefix+"-icon-"+e),t&&p.rtl&&A.push(p.prefix+"-icon-rtl"),j&&A.push(p.prefix+"-icon-spin"),s("span",{class:A.join(" ")},[i(T)])}}};return o}const is=te("pause-one",!1,function(e){return s("svg",{width:e.size,height:e.size,viewBox:"0 0 48 48",fill:"none"},[s("path",{d:"M24 44C35.0457 44 44 35.0457 44 24C44 12.9543 35.0457 4 24 4C12.9543 4 4 12.9543 4 24C4 35.0457 12.9543 44 24 44Z",fill:e.colors[1],stroke:e.colors[0],"stroke-width":e.strokeWidth,"stroke-linejoin":e.strokeLinejoin},null),s("path",{d:"M19 18V30",stroke:e.colors[2],"stroke-width":e.strokeWidth,"stroke-linecap":e.strokeLinecap,"stroke-linejoin":e.strokeLinejoin},null),s("path",{d:"M29 18V30",stroke:e.colors[2],"stroke-width":e.strokeWidth,"stroke-linecap":e.strokeLinecap,"stroke-linejoin":e.strokeLinejoin},null)])}),as=te("play",!0,function(e){return s("svg",{width:e.size,height:e.size,viewBox:"0 0 48 48",fill:"none"},[s("path",{d:"M24 44C35.0457 44 44 35.0457 44 24C44 12.9543 35.0457 4 24 4C12.9543 4 4 12.9543 4 24C4 35.0457 12.9543 44 24 44Z",fill:e.colors[1],stroke:e.colors[0],"stroke-width":e.strokeWidth,"stroke-linejoin":e.strokeLinejoin},null),s("path",{d:"M20 24V17.0718L26 20.5359L32 24L26 27.4641L20 30.9282V24Z",fill:e.colors[3],stroke:e.colors[2],"stroke-width":e.strokeWidth,"stroke-linejoin":e.strokeLinejoin},null)])}),ls=te("volume-small",!0,function(e){return s("svg",{width:e.size,height:e.size,viewBox:"0 0 48 48",fill:"none"},[s("path",{d:"M24 6V42C17 42 11.7985 32.8391 11.7985 32.8391H6C4.89543 32.8391 4 31.9437 4 30.8391V17.0108C4 15.9062 4.89543 15.0108 6 15.0108H11.7985C11.7985 15.0108 17 6 24 6Z",fill:e.colors[1],stroke:e.colors[0],"stroke-width":e.strokeWidth,"stroke-linejoin":e.strokeLinejoin},null),s("path",{d:"M32 15L32 15C32.6232 15.5565 33.1881 16.1797 33.6841 16.8588C35.1387 18.8504 36 21.3223 36 24C36 26.6545 35.1535 29.1067 33.7218 31.0893C33.2168 31.7885 32.6391 32.4293 32 33",stroke:e.colors[0],"stroke-width":e.strokeWidth,"stroke-linecap":e.strokeLinecap,"stroke-linejoin":e.strokeLinejoin},null)])}),ie=b({__name:"IconPark",props:{icon:{},theme:{},size:{},spin:{type:Boolean},fill:{},strokeLinecap:{},strokeLinejoin:{},strokeWidth:{}},setup(e){return(t,i)=>(l(),w(re(t.icon),{theme:t.theme,size:t.size,spin:t.spin,fill:t.fill,"stroke-linecap":t.strokeLinecap,"stroke-linejoin":t.strokeLinejoin,"stroke-width":t.strokeWidth},null,8,["theme","size","spin","fill","stroke-linecap","stroke-linejoin","stroke-width"]))}}),rs={class:"player-volume flex flex-col items-center pt-2"},cs={class:"text-sm mt-3"},us=b({__name:"PlayerVolumeSlider",setup(e){const t=G(),i=F({get:()=>t.state.suno.audio?.volume,set:u=>t.commit("suno/setAudio",{...t.state.suno.audio,volume:u})}),o=F({get:()=>t.state.suno.audio?.muted,set:u=>t.commit("suno/setAudio",{...t.state.suno.audio,muted:u})}),a=u=>t.dispatch("suno/setVolume",u);return(u,d)=>(l(),h("div",rs,[s(V(ue),{modelValue:i.value,"onUpdate:modelValue":d[0]||(d[0]=p=>i.value=p),vertical:"",height:"100px","show-tooltip":!1,max:100,min:0,size:"small",disabled:o.value,onInput:a},null,8,["modelValue","disabled"]),r("div",cs,v(i.value),1)]))}}),ds={class:"flex items-center justify-center gap-x-3"},ps=b({__name:"PlayerController",setup(e){const t=G(),i=()=>t.dispatch("suno/setAudio",{...t.state.suno.audio,state:t.state.suno.audio.state==="playing"?"paused":"playing"}),o=F(()=>t.state.suno.audio);return(a,u)=>(l(),h("div",ds,[s(ie,{icon:o.value?.state==="playing"?V(is):V(as),size:"45",theme:"filled",class:"text-[var(--el-color-primary)] cursor-pointer",onClick:i},null,8,["icon"]),s(V(Oe),{placement:"top",width:"50px",trigger:"click"},{reference:$(()=>[s(ie,{icon:V(ls),size:"20","stroke-width":2,class:"cursor-pointer"},null,8,["icon"])]),default:$(()=>[s(us)]),_:1})]))}}),ms={class:"flex flex-col items-stretch h-20"},fs={class:"flex grow px-5 items-center"},hs={class:"flex-1"},_s={class:"flex-1"},$s={class:"flex-1"},vs=b({__name:"Player",setup(e){return(t,i)=>(l(),h("div",ms,[s(Wo),r("div",fs,[r("div",hs,[s(Jo)]),r("div",_s,[s(ps)]),r("div",$s,[s(es)])])]))}}),gs=b({name:"RecentPanel",components:{ElSkeletonItem:We,ElSkeleton:Be,TaskPreview:Oo,Player:vs,NoTasks:Ue},emits:["reach-top"],data(){return{job:0}},computed:{tasks(){return{...this.$store.state.suno?.tasks,items:this.$store.state.suno?.tasks?.items?.slice()}}},methods:{onHandleScroll(){const e=this.$refs.panel;console.log("reach-top"),e.scrollTop===0&&this.$emit("reach-top")}}}),ks={key:0,class:"tasks"},ys={class:"left w-[70px] p-[10px] flex items-center"},ws={class:"main w-[calc(100%-70px)] flex-1 p-[10px]"},bs={key:2,class:"w-full flex-1 flex items-center justify-center"},Cs={class:"h-20"};function Ss(e,t,i,o,a,u){const d=c("el-skeleton-item"),p=c("el-skeleton"),_=c("task-preview"),n=c("no-tasks"),m=c("player");return l(),h(z,null,[e.tasks?.items===void 0?(l(),h("div",ks,[(l(),h(z,null,N(3,k=>r("div",{key:k,class:"flex"},[r("div",ys,[s(p,{animated:""},{template:$(()=>[s(d,{variant:"image",class:"avatar w-[50px] h-[50px]"})]),_:1})]),r("div",ws,[s(p,{animated:""},{template:$(()=>[s(d,{variant:"p",class:"w-[200px] h-[15px] mb-[5px] mt-[10px]"}),s(d,{variant:"text"})]),_:1})])])),64))])):e.tasks?.items?.length&&e.tasks?.items?.length>0?(l(),h("div",{key:1,class:"flex-1 w-full overflow-y-auto tasks p-2",onScroll:t[0]||(t[0]=(...k)=>e.onHandleScroll&&e.onHandleScroll(...k))},[(l(!0),h(z,null,N(e.tasks?.items,(k,f)=>(l(),w(_,{key:f,"model-value":k,class:"preview"},null,8,["model-value"]))),128))],32)):y("",!0),e.tasks?.items?.length===0?(l(),h("div",bs,[s(n)])):y("",!0),X(r("div",Cs,[s(m)],512),[[Ae,!!e.$store?.state?.suno?.audio?.object]])],64)}const As=E(gs,[["render",Ss]]),Ls=b({name:"TaskPreview",components:{IconPicture:Le,ElImage:J,ElAvatar:Xe,ElIcon:R},computed:{audio(){return this.$store.state.suno?.audio}}}),Es={key:0,class:"size-full overflow-hidden"},Vs={class:"relative h-[300px]"},js={class:"flex items-center justify-center size-full bg-[var(--el-bg-color)]"},Fs={class:"absolute bottom-0 left-0 right-0 m-0 p-4 text-white z-10 bg-gradient-to-t from-black/70 to-transparent"},Ts={class:"p-4"},Ps={class:"flex items-center font-bold mb-2"},Is={class:"text-[var(--el-text-color-regular)] mb-2"},Us={class:"text-xs text-[var(--el-text-color-regular)]"},zs={class:"mt-4 text-sm leading-[25px] whitespace-pre-wrap"},Ds={key:1,class:"w-full h-full"};function Rs(e,t,i,o,a,u){const d=c("icon-picture"),p=c("el-icon"),_=c("el-image"),n=c("el-avatar");return e.audio?.object?(l(),h("div",Es,[r("div",Vs,[s(_,{src:e.audio.image_url,fit:"cover",class:"size-full"},{error:$(()=>[r("div",js,[s(p,{class:"text-3xl"},{default:$(()=>[s(d)]),_:1})])]),_:1},8,["src"]),r("h2",Fs,v(e.audio?.title),1)]),r("div",Ts,[r("div",Ps,[s(n,{size:30,src:e.audio?.image_url,class:"mr-2"},null,8,["src"]),r("span",null,v(e.audio?.title),1)]),r("p",Is,v(e.audio?.style),1),r("p",Us,v(e.$dayjs.format(e.audio?.created_at)),1),r("div",zs,[r("p",null,v(e.audio?.lyric),1)])])])):(l(),h("div",Ds))}const Gs=E(Ls,[["render",Rs]]),Ms="https://webhook.acedata.cloud/suno",Os=b({name:"SunoIndex",components:{Layout:ot,ConfigPanel:yo,RecentPanel:As,PreviewPanel:Gs},inject:["initialized"],data(){return{task:void 0,job:0}},computed:{loading(){return this.$store.state.suno?.status?.getApplications===W.Request},service(){return this.$store.state.suno.service},credential(){return this.$store.state.suno.credential},config(){return this.$store.state.suno.config},initializing(){return this.$store.state.suno.status.getApplications===W.Request},needApply(){return this.$store.state.suno.status.getApplications===W.Success&&!this.application},application(){return this.$store.state.suno.application},tasks(){return this.$store.state.suno.tasks},applications(){return this.$store.state.suno.applications}},watch:{tasks:{handler(e,t){e?.items?.length>t?.items?.length&&console.debug("new tasks detected")},deep:!0},initialized:{async handler(e){e&&(console.debug("layout initialized"),await this.onGetTasks(),await this.onScrollDown(),this.job=setInterval(()=>{this.onGetTasks()},5e3))},immediate:!0}},async mounted(){await this.onGetService()},async unmounted(){clearInterval(this.job)},methods:{async onReachTop(){console.debug("reached top"),await this.onGetTasks({createdAtMax:this.tasks?.items?.[0]?.created_at})},async onGetService(){console.debug("start onGetService"),await this.$store.dispatch("suno/getService"),console.debug("end onGetService")},async onGetApplication(){console.debug("start onGetApplications"),await this.$store.dispatch("suno/getApplications"),console.debug("end onGetApplications"),await this.onGetTasks()},onApply(){Ee.create({application:this.application}).then(({data:e})=>{this.application=e,L.success(this.$t("application.message.applySuccessfully"))}).catch(e=>{e?.response?.data?.code===Ve&&L.error(this.$t("application.message.alreadyApplied"))})},async onScrollDown(){setTimeout(()=>{const e=document.querySelector(".recent");e&&(e.scrollTop=e.scrollHeight)},1e3)},async onGetTasks(e){if(this.loading){console.debug("loading");return}console.debug("start onGetTasks",e);const{limit:t=5,createdAtMin:i,createdAtMax:o}=e||{};console.debug("limit",t,"createdAtMin",i,"createdAtMax",o),await this.$store.dispatch("suno/getTasks",{limit:t,createdAtMin:i,createdAtMax:o})},async onGenerateAudio(){const e={...this.config,callback_url:Ms},t=this.credential?.token;if(!t){console.error("no token specified");return}L.info(this.$t("suno.message.startingTask")),H.audio(e,{token:t}).then(()=>{L.success(this.$t("suno.message.startTaskSuccess"))}).catch(i=>{L.error(i?.response?.data?.error?.message||this.$t("suno.message.startTaskFailed"))}).finally(async()=>{setTimeout(async()=>{await this.onGetTasks(),await this.onScrollDown()},1e3)})}}});function Bs(e,t,i,o,a,u){const d=c("config-panel"),p=c("recent-panel"),_=c("preview-panel"),n=c("layout");return l(),w(n,null,{config:$(()=>[s(d,{onGenerate:e.onGenerateAudio},null,8,["onGenerate"])]),result:$(()=>[s(p,{class:"panel recent",onReachTop:e.onReachTop},null,8,["onReachTop"])]),preview:$(()=>[s(_)]),_:1})}const Cn=E(Os,[["render",Bs],["__scopeId","data-v-f5721d95"]]);export{Cn as default};
|
|
1
|
+
import{F as x}from"./index.es-EtbmiVQe.js";import{E as K}from"./index-CqTGsJay.js";import{E as de}from"./index-BzyEWvnL.js";import{ak as pe,aq as me,bJ as fe,al as ae,ca as he,_ as _e,d as b,a as $e,am as ve,c as F,bi as ge,bo as ke,ax as le,b as h,o as l,i as w,r as U,f as oe,e as V,j as $,b9 as re,E as R,n as ye,g as we,h as E,t as r,k as s,l as c,eS as se,x as v,F as z,v as N,eT as H,c7 as be,D as I,eU as Y,eV as Q,y,J as X,cO as ee,eW as B,bS as Ce,dn as W,ai as P,eX as G,ao as Se,K as Ae,eY as Le,df as Ee,dm as Ve}from"./index-C4ssJdBR.js";import{E as ce}from"./index-C3GYDBc-.js";import{E as je,a as Fe}from"./index-C4trafQk.js";import{I as M}from"./InfoIcon-BJAJcb5a.js";import{E as Te}from"./index-gFYmOD1F.js";import{E as L}from"./index-BqAthpig.js";import{E as Z}from"./index-Bth-8JIu.js";import{E as Pe,a as ue}from"./index-DIwFcazb.js";import{E as J}from"./index-tdgIYwZh.js";import{C as Ie,N as Ue}from"./NoTasks-oiStcbHf.js";import{a as ze}from"./price-DPmHeT6D.js";import{E as De,a as Re,b as Ge}from"./index-B85SWIvk.js";import{E as Me}from"./index-CCjGuukj.js";import{E as Oe}from"./index-tOFv-Cd9.js";import{E as Be,a as We}from"./index-B7ak1Sj_.js";import"./use-form-item-CGJaz8fH.js";import"./index-r5W6hzzQ.js";import"./index-J4WBpiv9.js";import"./index-DEAamx_H.js";import"./typescript-D14l1a1y.js";import"./strings-cAoZbHaH.js";import"./castArray-TlECDAqv.js";import"./isEqual-BqBcCRrU.js";import"./_initCloneObject-djD3gYlF.js";import"./debounce-DTzFlSYq.js";import"./_baseIteratee-35aC5hBk.js";import"./index-BqzuTEwO.js";import"./index-CP_56dlf.js";import"./_baseClone-kJ5Pgx6e.js";import"./index-zBoOr1pW.js";import"./dropdown-zSfjtIjT.js";const qe=pe({size:{type:[Number,String],values:he,default:"",validator:e=>ae(e)},shape:{type:String,values:["circle","square"],default:"circle"},icon:{type:fe},src:{type:String,default:""},alt:String,srcSet:String,fit:{type:me(String),default:"cover"}}),Ne={error:e=>e instanceof Event},He=b({name:"ElAvatar"}),xe=b({...He,props:qe,emits:Ne,setup(e,{emit:t}){const i=e,o=$e("avatar"),a=ve(!1),u=F(()=>{const{size:n,icon:m,shape:k}=i,f=[o.b()];return ge(n)&&f.push(o.m(n)),m&&f.push(o.m("icon")),k&&f.push(o.m(k)),f}),d=F(()=>{const{size:n}=i;return ae(n)?o.cssVarBlock({size:ke(n)||""}):void 0}),p=F(()=>({objectFit:i.fit}));le(()=>i.src,()=>a.value=!1);function _(n){a.value=!0,t("error",n)}return(n,m)=>(l(),h("span",{class:ye(V(u)),style:oe(V(d))},[(n.src||n.srcSet)&&!a.value?(l(),h("img",{key:0,src:n.src,alt:n.alt,srcset:n.srcSet,style:oe(V(p)),onError:_},null,44,["src","alt","srcset"])):n.icon?(l(),w(V(R),{key:1},{default:$(()=>[(l(),w(re(n.icon)))]),_:1})):U(n.$slots,"default",{key:2})],6))}});var Ke=_e(xe,[["__file","avatar.vue"]]);const Xe=we(Ke),Ze=b({name:"LayoutSuno",components:{ElDrawer:de,ElButton:K,FontAwesomeIcon:x},data(){return{drawer:!1,preview:!1}},computed:{}}),Je={class:"main flex flex-row flex-1"},Ye={class:"config w-[300px] h-full overflow-y-scroll border-r border-[var(--el-border-color)]"},Qe={class:"result h-full flex flex-col flex-1 border-r border-[var(--el-border-color)]"},et={class:"preview h-full w-[300px] flex flex-col"};function tt(e,t,i,o,a,u){const d=c("font-awesome-icon"),p=c("el-button"),_=c("el-drawer");return l(),h("div",Je,[r("div",Ye,[U(e.$slots,"config",{},void 0,!0)]),r("div",Qe,[U(e.$slots,"result",{},void 0,!0)]),r("div",et,[U(e.$slots,"preview",{},void 0,!0)]),s(p,{circle:"",class:"menu",onClick:t[0]||(t[0]=n=>e.drawer=!0)},{default:$(()=>[s(d,{icon:"fa-solid fa-magic"})]),_:1}),s(_,{modelValue:e.drawer,"onUpdate:modelValue":t[1]||(t[1]=n=>e.drawer=n),direction:"ltr","with-header":!1,size:"340px",class:"drawer"},{default:$(()=>[U(e.$slots,"config",{},void 0,!0)]),_:3},8,["modelValue"])])}const ot=E(Ze,[["render",tt],["__scopeId","data-v-6cc632e5"]]),st=b({name:"VersionSelector",components:{ElSelect:Fe,ElOption:je,ElSwitch:ce},props:{modelValue:{type:String,default:void 0}},emits:["update:modelValue"],data(){return{options:[{label:this.$t("suno.model.model1"),value:"chirp-v2-xxl-alpha"},{label:this.$t("suno.model.model2"),value:"chirp-v3-0"},{label:this.$t("suno.model.model3"),value:"chirp-v3-5"},{label:this.$t("suno.model.model4"),value:"chirp-v4"},{label:this.$t("suno.model.model45"),value:"chirp-v4-5"}]}},computed:{custom:{get(){return this.$store.state.suno?.config?.custom},set(e){console.debug("set custom",e),this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,custom:e})}},model:{get(){return this.$store.state.suno?.config?.model},set(e){console.debug("set model",e),this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,model:e})}}},mounted(){this.model||(console.debug("set default type",se),this.model=se)}}),nt={class:"field"},it={class:"title font-bold"};function at(e,t,i,o,a,u){const d=c("el-switch"),p=c("el-option"),_=c("el-select");return l(),h("div",nt,[r("h2",it,v(e.$t("suno.name.type")),1),s(d,{modelValue:e.custom,"onUpdate:modelValue":t[0]||(t[0]=n=>e.custom=n),class:"value"},null,8,["modelValue"]),s(_,{modelValue:e.model,"onUpdate:modelValue":t[1]||(t[1]=n=>e.model=n),class:"value",placeholder:e.$t("suno.placeholder.select")},{default:$(()=>[(l(!0),h(z,null,N(e.options,n=>(l(),w(p,{key:n.value,label:n.label,value:n.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])])}const lt=E(st,[["render",at],["__scopeId","data-v-5a66a01f"]]),rt=b({name:"UploadAudio",components:{ElUpload:Te,ElButton:K,InfoIcon:M,FontAwesomeIcon:x},emits:["change"],data(){return{fileList:[],uploadUrl:be()+"/api/v1/files/"}},computed:{headers(){return{Authorization:`Bearer ${this.$store.state.token.access}`}},credential(){return this.$store.state.suno.credential},config(){return this.$store.state.suno.config},urls(){return this.fileList.map(e=>e?.response?.file_url)},value:{get(){return this.$store.state.suno?.config?.audio_id},set(){}}},watch:{urls:{handler(e){this.$emit("change",e)}}},mounted(){this.value||(this.value=void 0),this.onSetAudio()},methods:{onExceed(){L.warning(this.$t("suno.message.uploadReferencesExceed"))},onError(){L.error(this.$t("suno.message.uploadReferencesError"))},async onSuccess(){const e=this.urls?.[0];await this.onGenerateAudioId(e)},async onGenerateAudioId(e){const t={audio_url:e},i=this.credential?.token;if(!i){console.error("no token specified");return}L.info(this.$t("suno.message.startingUploadAudio")),H.upload(t,{token:i}).then(o=>{console.debug("get upload music success",o.data);const a=o.data?.data.audio_id;this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,audio_id:a,action:"upload_extend"}),L.success(this.$t("suno.message.startUploadAudioSuccess"))}).catch(o=>{L.error(o?.response?.data?.error?.message||this.$t("suno.message.startUploadAudioFailed"))})},onSetAudio(){}}}),ct={class:"relative"},ut={class:"flex justify-between"},dt={class:"flex justify-start items-center"},pt={class:"text-sm font-bold"};function mt(e,t,i,o,a,u){const d=c("info-icon"),p=c("font-awesome-icon"),_=c("el-button"),n=c("el-upload");return l(),h("div",ct,[r("div",ut,[r("div",dt,[r("span",pt,v(e.$t("suno.name.referenceAudios")),1),s(d,{content:e.$t("suno.description.uploadAudios")},null,8,["content"])])]),s(n,{"file-list":e.fileList,"onUpdate:fileList":t[0]||(t[0]=m=>e.fileList=m),name:"file",limit:1,class:"upload-wrapper",action:e.uploadUrl,accept:".mp3","show-file-list":!0,"on-exceed":e.onExceed,"on-error":e.onError,"on-success":e.onSuccess,headers:e.headers},{default:$(()=>[s(_,{round:"",type:"primary",size:"small",class:"btn btn-upload"},{default:$(()=>[s(p,{icon:"fa-solid fa-upload",class:"icon mr-1"}),I(" "+v(e.$t("suno.button.uploadAudios")),1)]),_:1})]),_:1},8,["file-list","action","on-exceed","on-error","on-success","headers"])])}const ft=E(rt,[["render",mt],["__scopeId","data-v-6236152c"]]),ht="",_t=b({name:"PromptInput",components:{ElInput:Z,ElSwitch:ce,InfoIcon:M},data(){return{}},computed:{prompt:{get(){return this.$store.state.suno?.config?.prompt},set(e){console.debug("set prompt",e),this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,prompt:e})}},instrumental:{get(){return this.$store.state.suno?.config?.instrumental},set(e){console.debug("set instrumental",e),this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,instrumental:e})}}},mounted(){this.prompt||(this.prompt=ht)}}),$t={class:"field"},vt={class:"box"},gt={class:"title-info"},kt={class:"title font-bold"},yt={class:"instrumental"},wt={class:"title inline-block"};function bt(e,t,i,o,a,u){const d=c("info-icon"),p=c("el-switch"),_=c("el-input");return l(),h("div",$t,[r("div",vt,[r("div",gt,[r("h2",kt,v(e.$t("suno.name.prompt")),1),s(d,{content:e.$t("suno.description.prompt"),class:"info"},null,8,["content"])]),r("div",yt,[s(p,{modelValue:e.instrumental,"onUpdate:modelValue":t[0]||(t[0]=n=>e.instrumental=n),class:"value mr-2"},null,8,["modelValue"]),r("h2",wt,v(e.$t("suno.name.instrumental")),1)])]),s(_,{modelValue:e.prompt,"onUpdate:modelValue":t[1]||(t[1]=n=>e.prompt=n),rows:3,type:"textarea",class:"prompt",placeholder:e.$t("suno.placeholder.prompt"),maxlength:200,"show-word-limit":""},null,8,["modelValue","placeholder"])])}const Ct=E(_t,[["render",bt],["__scopeId","data-v-d7004a7c"]]),St="",At=b({name:"LyricInput",components:{ElInput:Z,InfoIcon:M},data(){return{}},computed:{lyric:{get(){return this.$store.state.suno?.config?.lyric},set(e){console.debug("set lyric",e),this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,lyric:e})}},config(){return this.$store.state.suno?.config}},mounted(){this.lyric||(this.lyric=St)}}),Lt={class:"field"},Et={class:"box"},Vt={class:"title font-bold"};function jt(e,t,i,o,a,u){const d=c("info-icon"),p=c("el-input");return l(),h("div",Lt,[r("div",Et,[r("h2",Vt,v(e.$t("suno.name.lyrics")),1),s(d,{content:e.$t("suno.description.lyrics"),class:"info"},null,8,["content"])]),e.config?.action!=="extend"?(l(),w(p,{key:0,modelValue:e.lyric,"onUpdate:modelValue":t[0]||(t[0]=_=>e.lyric=_),rows:3,type:"textarea",class:"lyrics",placeholder:e.$t("suno.placeholder.lyrics"),maxlength:3e3,"show-word-limit":""},null,8,["modelValue","placeholder"])):(l(),w(p,{key:1,modelValue:e.lyric,"onUpdate:modelValue":t[1]||(t[1]=_=>e.lyric=_),rows:3,type:"textarea",class:"lyrics",placeholder:e.$t("suno.placeholder.extend.lyrics"),maxlength:3e3,"show-word-limit":""},null,8,["modelValue","placeholder"]))])}const Ft=E(At,[["render",jt],["__scopeId","data-v-99dfded8"]]),Tt=b({name:"StyleInput",components:{ElInput:Z,InfoIcon:M},data(){return{}},computed:{style:{get(){return this.$store.state.suno?.config?.style},set(e){console.debug("set style",e),this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,style:e})}},config(){return this.$store.state.suno?.config}}}),Pt={class:"field"},It={class:"title-container"},Ut={class:"titlefont-bold"};function zt(e,t,i,o,a,u){const d=c("info-icon"),p=c("el-input");return l(),h("div",Pt,[r("div",It,[r("h2",Ut,v(e.$t("suno.name.style")),1),s(d,{content:e.$t("suno.description.style"),class:"info"},null,8,["content"])]),s(p,{modelValue:e.style,"onUpdate:modelValue":t[0]||(t[0]=_=>e.style=_),rows:3,type:"textarea",class:"style",placeholder:e.$t("suno.placeholder.style"),maxlength:200,"show-word-limit":""},null,8,["modelValue","placeholder"])])}const Dt=E(Tt,[["render",zt],["__scopeId","data-v-85bbfcaa"]]),Rt=b({name:"TitleInput",components:{ElInput:Z,InfoIcon:M},data(){return{}},computed:{title:{get(){return this.$store.state.suno?.config?.title},set(e){console.debug("set title",e),this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,title:e})}},instrumental:{get(){return this.$store.state.suno?.config?.instrumental},set(e){console.debug("set instrumental",e),this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,instrumental:e})}}}}),Gt={class:"field"},Mt={class:"title-container"},Ot={class:"title font-bold"};function Bt(e,t,i,o,a,u){const d=c("info-icon"),p=c("el-input");return l(),h("div",Gt,[r("div",Mt,[r("h2",Ot,v(e.$t("suno.name.title")),1),s(d,{content:e.$t("suno.description.title"),class:"info"},null,8,["content"])]),s(p,{modelValue:e.title,"onUpdate:modelValue":t[0]||(t[0]=_=>e.title=_),rows:3,type:"textarea",class:"title",placeholder:e.$t("suno.placeholder.title"),maxlength:80,"show-word-limit":""},null,8,["modelValue","placeholder"])])}const Wt=E(Rt,[["render",Bt],["__scopeId","data-v-ce70fe34"]]);function D(e){const t=Math.floor(e)%60;e=Math.floor(e/60);const i=e%60,o=i<10?`0${i}`:i,a=t<10?`0${t}`:t;return o+":"+a}const qt=b({name:"ExtendFromInput",components:{ElImage:J,ElIcon:R,ElInputNumber:Pe,VideoPlay:Q,VideoPause:Y},data(){return{}},computed:{audio(){return this.$store.state.suno?.config?.audio},value:{get(){return this.$store.state.suno?.config?.continue_at},set(e){console.debug("set continue_at",e),this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,continue_at:e?parseInt(e):void 0})}}},mounted(){this.value||(this.value=void 0)},methods:{handleChange(e){if(e===void 0){this.value=void 0;return}e<0?this.value=0:e>this.audio?.duration?this.value=this.audio?.duration:this.value=e},useFormatDuring:D,onPlay(e){this.$store.dispatch("suno/setAudio",{...this.$store.state.suno.audio,...e,state:"playing"}),console.log("on play")},onPause(e){this.$store.dispatch("suno/setAudio",{...this.$store.state.suno.audio,...e,state:"paused"}),console.log("on pause")},onClick(e){this.$store.state?.suno?.audio?.id!==e.id&&this.onPlay({...e,progress:0})}}}),Nt={class:"field"},Ht={class:"box"},xt={class:"title font-bold"},Kt={class:"input-wrapper"},Xt={class:"task"},Zt={class:"left"},Jt={key:2,class:"duration"},Yt={class:"info"},Qt={class:"title"},eo={class:"style"};function to(e,t,i,o,a,u){const d=c("el-input-number"),p=c("el-image"),_=c("video-pause"),n=c("el-icon"),m=c("video-play"),k=ee("loading");return l(),h("div",Nt,[r("div",Ht,[r("h2",xt,v(e.$t("suno.name.extend")),1),r("div",Kt,[s(d,{modelValue:e.value,"onUpdate:modelValue":t[0]||(t[0]=f=>e.value=f),class:"value",min:0,max:e.audio?.duration,controls:!1,placeholder:e.$t("suno.placeholder.extend.continue_at"),onChange:e.handleChange},null,8,["modelValue","max","placeholder","onChange"])])]),r("div",Xt,[e.audio?(l(),h("div",{key:0,class:"audio",onClick:t[3]||(t[3]=f=>e.onClick(e.audio))},[X((l(),h("div",Zt,[s(p,{src:e.audio?.image_url,class:"cover",fit:"cover"},null,8,["src"]),e.audio?.audio_url&&e.$store.state?.suno?.audio?.id===e.audio.id&&e.$store.state?.suno?.audio?.state==="playing"?(l(),h("div",{key:0,class:"overlay",onClick:t[1]||(t[1]=f=>e.onPause(e.audio))},[s(n,null,{default:$(()=>[s(_)]),_:1})])):y("",!0),e.audio?.audio_url&&(e.$store.state?.suno?.audio?.id!==e.audio.id||e.$store.state?.suno?.audio?.id===e.audio.id&&e.$store.state?.suno?.audio?.state==="paused")?(l(),h("div",{key:1,class:"overlay",onClick:t[2]||(t[2]=f=>e.onPlay(e.audio))},[s(n,null,{default:$(()=>[s(m)]),_:1})])):y("",!0),e.audio?.duration?(l(),h("div",Jt,v(e.useFormatDuring(e.audio?.duration)),1)):y("",!0)])),[[k,!e.audio?.audio_url]]),r("div",Yt,[r("h2",Qt,v(e.audio?.title),1),r("p",eo,v(e.audio?.style),1)])])):y("",!0)])])}const oo=E(qt,[["render",to],["__scopeId","data-v-bcce4821"]]),so=b({name:"CoverFromInput",components:{ElImage:J,ElIcon:R,VideoPlay:Q,VideoPause:Y},data(){return{}},computed:{audio(){return this.$store.state.suno?.config?.audio},value:{get(){return this.$store.state.suno?.config?.continue_at},set(e){console.debug("set continue_at",e),this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,continue_at:e?parseInt(e):void 0})}}},mounted(){this.value||(this.value=void 0)},methods:{handleChange(e){e<0?this.value=0:e>this.audio?.duration?this.value=this.audio?.duration:this.value=e},useFormatDuring:D,onPlay(e){this.$store.dispatch("suno/setAudio",{...this.$store.state.suno.audio,...e,state:"playing"}),console.log("on play")},onPause(e){this.$store.dispatch("suno/setAudio",{...this.$store.state.suno.audio,...e,state:"paused"}),console.log("on pause")},onClick(e){this.$store.state?.suno?.audio?.id!==e.id&&this.onPlay({...e,progress:0})}}}),no={class:"field"},io={class:"box"},ao={class:"title font-bold"},lo={class:"task"},ro={class:"left"},co={key:2,class:"duration"},uo={class:"info"},po={class:"title"},mo={class:"style"};function fo(e,t,i,o,a,u){const d=c("el-image"),p=c("video-pause"),_=c("el-icon"),n=c("video-play"),m=ee("loading");return l(),h("div",no,[r("div",io,[r("h2",ao,v(e.$t("suno.name.cover")),1)]),r("div",lo,[e.audio?(l(),h("div",{key:0,class:"audio",onClick:t[2]||(t[2]=k=>e.onClick(e.audio))},[X((l(),h("div",ro,[s(d,{src:e.audio?.image_url,class:"cover",fit:"cover"},null,8,["src"]),e.audio?.audio_url&&e.$store.state?.suno?.audio?.id===e.audio.id&&e.$store.state?.suno?.audio?.state==="playing"?(l(),h("div",{key:0,class:"overlay",onClick:t[0]||(t[0]=k=>e.onPause(e.audio))},[s(_,null,{default:$(()=>[s(p)]),_:1})])):y("",!0),e.audio?.audio_url&&(e.$store.state?.suno?.audio?.id!==e.audio.id||e.$store.state?.suno?.audio?.id===e.audio.id&&e.$store.state?.suno?.audio?.state==="paused")?(l(),h("div",{key:1,class:"overlay",onClick:t[1]||(t[1]=k=>e.onPlay(e.audio))},[s(_,null,{default:$(()=>[s(n)]),_:1})])):y("",!0),e.audio?.duration?(l(),h("div",co,v(e.useFormatDuring(e.audio?.duration)),1)):y("",!0)])),[[m,!e.audio?.audio_url]]),r("div",uo,[r("h2",po,v(e.audio?.title),1),r("p",mo,v(e.audio?.style),1)])])):y("",!0)])])}const ho=E(so,[["render",fo],["__scopeId","data-v-06640216"]]),_o=b({name:"PresetPanel",components:{TypeSelector:lt,PromptInput:Ct,LyricInput:Ft,StyleInput:Dt,TitleInput:Wt,ExtendFromInput:oo,CoverFromInput:ho,UploadAudio:ft,FontAwesomeIcon:x,ElButton:K,Consumption:Ie},emits:["generate"],computed:{config(){return this.$store.state.suno?.config},consumption(){return ze(this.config,this.service?.metadata?.price)},service(){return this.$store.state.suno?.service}},methods:{onGenerate(){this.$emit("generate")}}}),$o={class:"flex flex-col h-full"},vo={class:"flex-1 overflow-y-auto p-[15px]"},go={class:"flex flex-col items-center justify-center px-[15px] pb-[15px]"};function ko(e,t,i,o,a,u){const d=c("type-selector"),p=c("upload-audio"),_=c("prompt-input"),n=c("lyric-input"),m=c("style-input"),k=c("title-input"),f=c("extend-from-input"),C=c("cover-from-input"),j=c("consumption"),T=c("font-awesome-icon"),A=c("el-button");return l(),h("div",$o,[r("div",vo,[s(d,{class:"mb-4"}),s(p,{class:"mb-4"}),e.config?.custom?y("",!0):(l(),w(_,{key:0,class:"mb-4"})),e.config?.custom&&!e.config.instrumental?(l(),w(n,{key:1,class:"mb-4"})):y("",!0),e.config?.custom?(l(),w(m,{key:2,class:"mb-4"})):y("",!0),e.config?.custom?(l(),w(k,{key:3,class:"mb-4"})):y("",!0),e.config?.action==="extend"?(l(),w(f,{key:4,class:"mb-4"})):y("",!0),e.config?.action==="cover"?(l(),w(C,{key:5,class:"mb-4"})):y("",!0)]),r("div",go,[s(j,{value:e.consumption,service:e.service},null,8,["value","service"]),e.config?.action!=="extend"?(l(),w(A,{key:0,type:"primary",class:"btn w-full",round:"",onClick:e.onGenerate},{default:$(()=>[s(T,{icon:"fa-solid fa-magic",class:"mr-2"}),I(" "+v(e.$t("suno.button.generate")),1)]),_:1},8,["onClick"])):(l(),w(A,{key:1,type:"primary",class:"btn w-full",round:"",onClick:e.onGenerate},{default:$(()=>[s(T,{icon:"fa-solid fa-magic",class:"mr-2"}),I(" "+v(e.$t("suno.button.extend")),1)]),_:1},8,["onClick"]))])])}const yo=E(_o,[["render",ko],["__scopeId","data-v-b9fab929"]]);var q={exports:{}},wo=q.exports,ne;function bo(){return ne||(ne=1,function(e,t){(function(i,o){o()})(wo,function(){function i(n,m){return typeof m>"u"?m={autoBom:!1}:typeof m!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),m={autoBom:!m}),m.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(n.type)?new Blob(["\uFEFF",n],{type:n.type}):n}function o(n,m,k){var f=new XMLHttpRequest;f.open("GET",n),f.responseType="blob",f.onload=function(){_(f.response,m,k)},f.onerror=function(){console.error("could not download file")},f.send()}function a(n){var m=new XMLHttpRequest;m.open("HEAD",n,!1);try{m.send()}catch{}return 200<=m.status&&299>=m.status}function u(n){try{n.dispatchEvent(new MouseEvent("click"))}catch{var m=document.createEvent("MouseEvents");m.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),n.dispatchEvent(m)}}var d=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof B=="object"&&B.global===B?B:void 0,p=d.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),_=d.saveAs||(typeof window!="object"||window!==d?function(){}:"download"in HTMLAnchorElement.prototype&&!p?function(n,m,k){var f=d.URL||d.webkitURL,C=document.createElement("a");m=m||n.name||"download",C.download=m,C.rel="noopener",typeof n=="string"?(C.href=n,C.origin===location.origin?u(C):a(C.href)?o(n,m,k):u(C,C.target="_blank")):(C.href=f.createObjectURL(n),setTimeout(function(){f.revokeObjectURL(C.href)},4e4),setTimeout(function(){u(C)},0))}:"msSaveOrOpenBlob"in navigator?function(n,m,k){if(m=m||n.name||"download",typeof n!="string")navigator.msSaveOrOpenBlob(i(n,k),m);else if(a(n))o(n,m,k);else{var f=document.createElement("a");f.href=n,f.target="_blank",setTimeout(function(){u(f)})}}:function(n,m,k,f){if(f=f||open("","_blank"),f&&(f.document.title=f.document.body.innerText="downloading..."),typeof n=="string")return o(n,m,k);var C=n.type==="application/octet-stream",j=/constructor/i.test(d.HTMLElement)||d.safari,T=/CriOS\/[\d]+/.test(navigator.userAgent);if((T||C&&j||p)&&typeof FileReader<"u"){var A=new FileReader;A.onloadend=function(){var S=A.result;S=T?S:S.replace(/^data:[^;]*;/,"data:attachment/file;"),f?f.location.href=S:location=S,f=null},A.readAsDataURL(n)}else{var O=d.URL||d.webkitURL,g=O.createObjectURL(n);f?f.location=g:location.href=g,f=null,setTimeout(function(){O.revokeObjectURL(g)},4e4)}});d.saveAs=_.saveAs=_,e.exports=_})}(q)),q.exports}var Co=bo();const So="https://webhook.acedata.cloud/suno",Ao=b({name:"TaskPreview",components:{ElImage:J,ElIcon:R,ElTooltip:Me,ElButton:K,FontAwesomeIcon:x,VideoPlay:Q,VideoPause:Y,ElDropdown:Ge,ElDropdownMenu:Re,ElDropdownItem:De,Loading:Ce},props:{modelValue:{type:Object,required:!0}},data(){return{isFetchingVideoUrl:!1}},computed:{loading(){return this.$store.state.suno?.status?.getApplications===W.Request},credential(){return this.$store.state.suno.credential},config(){return this.$store.state.suno.config},task(){return this.$store.state.suno?.tasks},audios(){const e=this.modelValue?.response?.data??[],t=this.modelValue?.request?.action;return t?e.map(i=>({...i,action:t})):e},application(){return this.$store.state.suno?.application},active(){return this.$store.state.suno?.tasks?.active}},methods:{useFormatDuring:D,onPlay(e){this.$store.dispatch("suno/setAudio",{...this.$store.state.suno.audio,...e,state:"playing"}),console.log("on play")},onPause(e){this.$store.dispatch("suno/setAudio",{...this.$store.state.suno.audio,...e,state:"paused"}),console.log("on pause")},onClick(e){this.$store.state?.suno?.audio?.id!==e.id&&this.onPlay({...e,progress:0})},onExtend(e,t){e.stopPropagation(),console.log("on extend"),console.debug("set config",t),this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,model:t.model,custom:!0,instrumental:!1,style:t.style,action:"extend",audio:t,audio_id:t.id,continue_at:t.duration})},onDownload(e,t){e&&e.stopPropagation(),console.log("on download",t);const o=new URL(t).pathname,a=o.substring(o.lastIndexOf("/")+1);console.log("on preview",a),fetch(t).then(u=>u.blob()).then(u=>{Co.saveAs(u,a)})},async handleVideoDownload(e){if(e.video_url){this.onDownload(null,e.video_url);return}if(!this.isFetchingVideoUrl)try{this.isFetchingVideoUrl=!0;const t=await this.fetchVideoUrlFromApi(e?.id);console.log(`get videoUrl: ${t}`),e.video_url=t,this.onDownload(null,t)}catch(t){console.error("get videoUrl failed:",t),L.error(this.$t("suno.message.getVideoUrlFailed"))}finally{this.isFetchingVideoUrl=!1}},async fetchVideoUrlFromApi(e){return new Promise((t,i)=>{const o={audio_id:e},a=this.credential?.token;if(!a){console.error("no token specified"),i(new Error("No token specified"));return}H.mp4(o,{token:a}).then(u=>{const d=u.data?.data?.video_url;d?t(d):i(new Error("Video URL not found in response"))}).catch(u=>{i(u)})})},onPreview(e,t){e.stopPropagation(),console.log("on preview",t),window.open(t,"_blank")},async onGetStems(e){await this.onGenerateAudioUrl("stems",e)},onCover(e){console.log("on cover"),console.debug("set config",e),this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,model:e.model,custom:!0,instrumental:!1,style:e.style,action:"cover",audio:e,audio_id:e.id})},async onConcatMusic(e){await this.onGenerateAudioUrl("concat",e)},async onGenerateAudioUrl(e,t){const i={action:e,audio_id:t,callback_url:So},o=this.credential?.token;if(!o){console.error("no token specified");return}L.info(this.$t("suno.message.startingTask")),H.audio(i,{token:o}).then(()=>{L.success(this.$t("suno.message.startTaskSuccess"))}).catch(a=>{L.error(a?.response?.data?.error?.message||this.$t("suno.message.startTaskFailed"))}).finally(async()=>{await this.onGetTasks(),await this.onScrollDown()})},async onScrollDown(){setTimeout(()=>{const e=document.querySelector(".tasks");e&&(e.scrollTop=e.scrollHeight)},1e3)},async onGetTasks(){if(this.loading){console.debug("loading");return}await this.$store.dispatch("suno/getTasks",{limit:30,offset:0})}}}),Lo={class:"task"},Eo=["onClick"],Vo={class:"left"},jo=["onClick"],Fo=["onClick"],To={key:2,class:"duration"},Po={class:"info"},Io={class:"title"},Uo={class:"style"},zo={class:"right"},Do={class:"el-dropdown-link"},Ro={class:"flex items-center min-w-[120px]"},Go={class:"el-dropdown-link"};function Mo(e,t,i,o,a,u){const d=c("el-image"),p=c("video-pause"),_=c("el-icon"),n=c("video-play"),m=c("el-button"),k=c("font-awesome-icon"),f=c("el-tooltip"),C=c("Loading"),j=c("el-dropdown-item"),T=c("el-dropdown-menu"),A=c("el-dropdown"),O=ee("loading");return l(),h("div",Lo,[(l(!0),h(z,null,N(e.audios,g=>(l(),h("div",{key:g.id,class:"audio",onClick:P(S=>e.onClick(g),["stop"])},[X((l(),h("div",Vo,[s(d,{src:g?.image_url,class:"cover",fit:"cover",lazy:""},null,8,["src"]),g?.audio_url&&e.$store.state?.suno?.audio?.id===g.id&&e.$store.state?.suno?.audio?.state==="playing"?(l(),h("div",{key:0,class:"overlay",onClick:P(S=>e.onPause(g),["stop"])},[s(_,null,{default:$(()=>[s(p)]),_:1})],8,jo)):y("",!0),g?.audio_url&&(e.$store.state?.suno?.audio?.id!==g.id||e.$store.state?.suno?.audio?.id===g.id&&e.$store.state?.suno?.audio?.state==="paused")?(l(),h("div",{key:1,class:"overlay",onClick:P(S=>e.onPlay(g),["stop"])},[s(_,null,{default:$(()=>[s(n)]),_:1})],8,Fo)):y("",!0),g?.duration?(l(),h("div",To,v(e.useFormatDuring(g?.duration)),1)):y("",!0)])),[[O,!g?.audio_url]]),r("div",Po,[r("h2",Io,v(g?.title),1),r("p",Uo,v(g?.style),1)]),r("div",zo,[g?.audio_url?(l(),w(m,{key:0,size:"small",round:"",onClick:P(S=>e.onExtend(S,g),["stop"])},{default:$(()=>[I(v(e.$t("suno.button.extend")),1)]),_:2},1032,["onClick"])):y("",!0),s(A,null,{dropdown:$(()=>[s(T,null,{default:$(()=>[s(j,{disabled:e.isFetchingVideoUrl,onClick:S=>e.handleVideoDownload(g)},{default:$(()=>[r("div",Ro,[e.isFetchingVideoUrl?(l(),w(_,{key:0,class:"is-loading mr-2"},{default:$(()=>[s(C)]),_:1})):y("",!0),r("span",null,v(e.$t("suno.button.download_video")),1)])]),_:2},1032,["disabled","onClick"]),g?.audio_url?(l(),w(j,{key:0,onClick:P(S=>e.onDownload(S,g?.audio_url),["stop"])},{default:$(()=>[I(v(e.$t("suno.button.download_audio")),1)]),_:2},1032,["onClick"])):y("",!0)]),_:2},1024)]),default:$(()=>[r("span",Do,[s(f,{effect:"dark",content:e.$t("suno.button.download"),placement:"top"},{default:$(()=>[g?.audio_url||g?.video_url?(l(),w(k,{key:0,icon:"fa-solid fa-download",class:"icon icon-download"})):y("",!0)]),_:2},1032,["content"])])]),_:2},1024),s(A,null,{dropdown:$(()=>[s(T,null,{default:$(()=>[g.id?(l(),w(j,{key:0,onClick:P(S=>e.onGetStems(g.id),["stop"])},{default:$(()=>[I(v(e.$t("suno.button.get_stems")),1)]),_:2},1032,["onClick"])):y("",!0),s(j,{onClick:P(S=>e.onCover(g),["stop"])},{default:$(()=>[I(v(e.$t("suno.button.cover_music")),1)]),_:2},1032,["onClick"]),g?.id&&g?.action==="extend"?(l(),w(j,{key:1,onClick:P(S=>e.onConcatMusic(g?.id),["stop"])},{default:$(()=>[I(v(e.$t("suno.button.concat_music")),1)]),_:2},1032,["onClick"])):y("",!0)]),_:2},1024)]),default:$(()=>[r("span",Go,[s(f,{effect:"dark",content:e.$t("suno.button.more"),placement:"top"},{default:$(()=>[g?.audio_url||g?.video_url?(l(),w(k,{key:0,icon:"fa-solid fa-ellipsis",class:"icon icon-ellipsis"})):y("",!0)]),_:2},1032,["content"])])]),_:2},1024)])],8,Eo))),128))])}const Oo=E(Ao,[["render",Mo]]),Bo={class:"player-slider"},Wo=b({__name:"PlayerSlider",setup(e){const t=G(),i=F({get:()=>t.state.suno?.audio?.progress,set:d=>t.commit("suno/setAudio",{...t.state.suno.audio,progress:d})}),o=F({get:()=>t.state.suno?.audio?.duration,set:d=>t.commit("suno/setAudio",{...t.state.suno.audio,duration:d})}),a=()=>{},u=d=>t.dispatch("suno/setAudio",{...t.state.suno.audio,progress:d});return(d,p)=>(l(),h("div",Bo,[s(V(ue),{modelValue:i.value,"onUpdate:modelValue":p[0]||(p[0]=_=>i.value=_),"show-tooltip":!1,min:0,max:o.value,onChange:u,onInput:a},null,8,["modelValue","max"])]))}}),qo="/assets/disk-XFRmVAfp.png",No={class:"flex player-song"},Ho=["src"],xo={class:"ml-2 text-xs flex flex-col justify-between"},Ko={class:"w-52 2xl:w-96 cursor-pointer truncate"},Xo={class:"flex"},Zo={class:"ml-2 text-dc"},Jo=b({__name:"PlayerSong",setup(e){const t=G(),i=F({get:()=>t.state.suno.audio,set:o=>t.commit("suno/setAudio",o)});return le(i,(o,a)=>{if(o?.audio_url!==a?.audio_url){console.log("audio changed",o),o.object&&(console.log("111",o.object),o.object.pause(),delete o.object);const u=new Audio(o.audio_url);o.state==="playing"?u.play():u.pause(),u.addEventListener("loadedmetadata",()=>{u.currentTime=0,u.addEventListener("timeupdate",()=>{t.commit("suno/setAudio",{...t.state.suno.audio,progress:u.currentTime})})}),t.commit("suno/setAudio",{...t.state.suno.audio,object:u})}else if(o?.progress!==a?.progress&&Math.abs(o.progress-o.object.currentTime)>2){console.log("progress changed",o.progress);const u=t.state.suno.audio;u.object&&(u.object.currentTime=u.progress)}else o?.state!==a?.state&&(console.log("state changed",o.state),o.object&&(o.state==="playing"?o.object.play():o.object.pause()));o?.volume!==a?.volume&&(console.log("volume changed",o.volume),o.object&&(o.object.volume=o.volume/100))}),(o,a)=>(l(),h("div",No,[r("img",{alt:"",class:"w-11 h-11 rounded",src:i.value?.image_url||V(qo)},null,8,Ho),r("div",xo,[r("div",Ko,[r("div",Xo,[r("span",null,v(i.value?.title||"Music"),1),r("span",Zo,"- "+v(i.value?.style||"SmallRuralDog"),1)])])])]))}}),Yo={class:"flex justify-end items-center gap-x-2.5"},Qo={class:"text-xs"},es=b({__name:"PlayerAction",setup(e){const t=G(),i=F({get:()=>t.state.suno?.audio?.progress,set:a=>t.commit("suno/setAudio",{...t.state.suno.audio,progress:a})}),o=F({get:()=>t.state.suno?.audio?.duration,set:a=>t.commit("suno/setAudio",{...t.state.suno.audio,duration:a})});return(a,u)=>(l(),h("div",Yo,[r("span",Qo,v(V(D)(i.value))+" / "+v(V(D)(o.value)),1)]))}});var ts={size:"1em",strokeWidth:4,strokeLinecap:"round",strokeLinejoin:"round",rtl:!1,theme:"outline",colors:{outline:{fill:"#333",background:"transparent"},filled:{fill:"#333",background:"#FFF"},twoTone:{fill:"#333",twoTone:"#2F88FF"},multiColor:{outStrokeColor:"#333",outFillColor:"#2F88FF",innerStrokeColor:"#FFF",innerFillColor:"#43CCF8"}},prefix:"i"};function os(){return"icon-"+((1+Math.random())*4294967296|0).toString(16).substring(1)}function ss(e,t,i){var o=typeof t.fill=="string"?[t.fill]:t.fill||[],a=[],u=t.theme||i.theme;switch(u){case"outline":a.push(typeof o[0]=="string"?o[0]:"currentColor"),a.push("none"),a.push(typeof o[0]=="string"?o[0]:"currentColor"),a.push("none");break;case"filled":a.push(typeof o[0]=="string"?o[0]:"currentColor"),a.push(typeof o[0]=="string"?o[0]:"currentColor"),a.push("#FFF"),a.push("#FFF");break;case"two-tone":a.push(typeof o[0]=="string"?o[0]:"currentColor"),a.push(typeof o[1]=="string"?o[1]:i.colors.twoTone.twoTone),a.push(typeof o[0]=="string"?o[0]:"currentColor"),a.push(typeof o[1]=="string"?o[1]:i.colors.twoTone.twoTone);break;case"multi-color":a.push(typeof o[0]=="string"?o[0]:"currentColor"),a.push(typeof o[1]=="string"?o[1]:i.colors.multiColor.outFillColor),a.push(typeof o[2]=="string"?o[2]:i.colors.multiColor.innerStrokeColor),a.push(typeof o[3]=="string"?o[3]:i.colors.multiColor.innerFillColor);break}return{size:t.size||i.size,strokeWidth:t.strokeWidth||i.strokeWidth,strokeLinecap:t.strokeLinecap||i.strokeLinecap,strokeLinejoin:t.strokeLinejoin||i.strokeLinejoin,colors:a,id:e}}var ns=Symbol("icon-context");function te(e,t,i){var o={name:"icon-"+e,props:["size","strokeWidth","strokeLinecap","strokeLinejoin","theme","fill","spin"],setup:function(u){var d=os(),p=Se(ns,ts);return function(){var _=u.size,n=u.strokeWidth,m=u.strokeLinecap,k=u.strokeLinejoin,f=u.theme,C=u.fill,j=u.spin,T=ss(d,{size:_,strokeWidth:n,strokeLinecap:m,strokeLinejoin:k,theme:f,fill:C},p),A=[p.prefix+"-icon"];return A.push(p.prefix+"-icon-"+e),t&&p.rtl&&A.push(p.prefix+"-icon-rtl"),j&&A.push(p.prefix+"-icon-spin"),s("span",{class:A.join(" ")},[i(T)])}}};return o}const is=te("pause-one",!1,function(e){return s("svg",{width:e.size,height:e.size,viewBox:"0 0 48 48",fill:"none"},[s("path",{d:"M24 44C35.0457 44 44 35.0457 44 24C44 12.9543 35.0457 4 24 4C12.9543 4 4 12.9543 4 24C4 35.0457 12.9543 44 24 44Z",fill:e.colors[1],stroke:e.colors[0],"stroke-width":e.strokeWidth,"stroke-linejoin":e.strokeLinejoin},null),s("path",{d:"M19 18V30",stroke:e.colors[2],"stroke-width":e.strokeWidth,"stroke-linecap":e.strokeLinecap,"stroke-linejoin":e.strokeLinejoin},null),s("path",{d:"M29 18V30",stroke:e.colors[2],"stroke-width":e.strokeWidth,"stroke-linecap":e.strokeLinecap,"stroke-linejoin":e.strokeLinejoin},null)])}),as=te("play",!0,function(e){return s("svg",{width:e.size,height:e.size,viewBox:"0 0 48 48",fill:"none"},[s("path",{d:"M24 44C35.0457 44 44 35.0457 44 24C44 12.9543 35.0457 4 24 4C12.9543 4 4 12.9543 4 24C4 35.0457 12.9543 44 24 44Z",fill:e.colors[1],stroke:e.colors[0],"stroke-width":e.strokeWidth,"stroke-linejoin":e.strokeLinejoin},null),s("path",{d:"M20 24V17.0718L26 20.5359L32 24L26 27.4641L20 30.9282V24Z",fill:e.colors[3],stroke:e.colors[2],"stroke-width":e.strokeWidth,"stroke-linejoin":e.strokeLinejoin},null)])}),ls=te("volume-small",!0,function(e){return s("svg",{width:e.size,height:e.size,viewBox:"0 0 48 48",fill:"none"},[s("path",{d:"M24 6V42C17 42 11.7985 32.8391 11.7985 32.8391H6C4.89543 32.8391 4 31.9437 4 30.8391V17.0108C4 15.9062 4.89543 15.0108 6 15.0108H11.7985C11.7985 15.0108 17 6 24 6Z",fill:e.colors[1],stroke:e.colors[0],"stroke-width":e.strokeWidth,"stroke-linejoin":e.strokeLinejoin},null),s("path",{d:"M32 15L32 15C32.6232 15.5565 33.1881 16.1797 33.6841 16.8588C35.1387 18.8504 36 21.3223 36 24C36 26.6545 35.1535 29.1067 33.7218 31.0893C33.2168 31.7885 32.6391 32.4293 32 33",stroke:e.colors[0],"stroke-width":e.strokeWidth,"stroke-linecap":e.strokeLinecap,"stroke-linejoin":e.strokeLinejoin},null)])}),ie=b({__name:"IconPark",props:{icon:{},theme:{},size:{},spin:{type:Boolean},fill:{},strokeLinecap:{},strokeLinejoin:{},strokeWidth:{}},setup(e){return(t,i)=>(l(),w(re(t.icon),{theme:t.theme,size:t.size,spin:t.spin,fill:t.fill,"stroke-linecap":t.strokeLinecap,"stroke-linejoin":t.strokeLinejoin,"stroke-width":t.strokeWidth},null,8,["theme","size","spin","fill","stroke-linecap","stroke-linejoin","stroke-width"]))}}),rs={class:"player-volume flex flex-col items-center pt-2"},cs={class:"text-sm mt-3"},us=b({__name:"PlayerVolumeSlider",setup(e){const t=G(),i=F({get:()=>t.state.suno.audio?.volume,set:u=>t.commit("suno/setAudio",{...t.state.suno.audio,volume:u})}),o=F({get:()=>t.state.suno.audio?.muted,set:u=>t.commit("suno/setAudio",{...t.state.suno.audio,muted:u})}),a=u=>t.dispatch("suno/setVolume",u);return(u,d)=>(l(),h("div",rs,[s(V(ue),{modelValue:i.value,"onUpdate:modelValue":d[0]||(d[0]=p=>i.value=p),vertical:"",height:"100px","show-tooltip":!1,max:100,min:0,size:"small",disabled:o.value,onInput:a},null,8,["modelValue","disabled"]),r("div",cs,v(i.value),1)]))}}),ds={class:"flex items-center justify-center gap-x-3"},ps=b({__name:"PlayerController",setup(e){const t=G(),i=()=>t.dispatch("suno/setAudio",{...t.state.suno.audio,state:t.state.suno.audio.state==="playing"?"paused":"playing"}),o=F(()=>t.state.suno.audio);return(a,u)=>(l(),h("div",ds,[s(ie,{icon:o.value?.state==="playing"?V(is):V(as),size:"45",theme:"filled",class:"text-[var(--el-color-primary)] cursor-pointer",onClick:i},null,8,["icon"]),s(V(Oe),{placement:"top",width:"50px",trigger:"click"},{reference:$(()=>[s(ie,{icon:V(ls),size:"20","stroke-width":2,class:"cursor-pointer"},null,8,["icon"])]),default:$(()=>[s(us)]),_:1})]))}}),ms={class:"flex flex-col items-stretch h-20"},fs={class:"flex grow px-5 items-center"},hs={class:"flex-1"},_s={class:"flex-1"},$s={class:"flex-1"},vs=b({__name:"Player",setup(e){return(t,i)=>(l(),h("div",ms,[s(Wo),r("div",fs,[r("div",hs,[s(Jo)]),r("div",_s,[s(ps)]),r("div",$s,[s(es)])])]))}}),gs=b({name:"RecentPanel",components:{ElSkeletonItem:We,ElSkeleton:Be,TaskPreview:Oo,Player:vs,NoTasks:Ue},emits:["reach-top"],data(){return{job:0}},computed:{tasks(){return{...this.$store.state.suno?.tasks,items:this.$store.state.suno?.tasks?.items?.slice()}}},methods:{onHandleScroll(){const e=this.$refs.panel;console.log("reach-top"),e.scrollTop===0&&this.$emit("reach-top")}}}),ks={key:0,class:"tasks"},ys={class:"left w-[70px] p-[10px] flex items-center"},ws={class:"main w-[calc(100%-70px)] flex-1 p-[10px]"},bs={key:2,class:"w-full flex-1 flex items-center justify-center"},Cs={class:"h-20"};function Ss(e,t,i,o,a,u){const d=c("el-skeleton-item"),p=c("el-skeleton"),_=c("task-preview"),n=c("no-tasks"),m=c("player");return l(),h(z,null,[e.tasks?.items===void 0?(l(),h("div",ks,[(l(),h(z,null,N(3,k=>r("div",{key:k,class:"flex"},[r("div",ys,[s(p,{animated:""},{template:$(()=>[s(d,{variant:"image",class:"avatar w-[50px] h-[50px]"})]),_:1})]),r("div",ws,[s(p,{animated:""},{template:$(()=>[s(d,{variant:"p",class:"w-[200px] h-[15px] mb-[5px] mt-[10px]"}),s(d,{variant:"text"})]),_:1})])])),64))])):e.tasks?.items?.length&&e.tasks?.items?.length>0?(l(),h("div",{key:1,class:"flex-1 w-full overflow-y-auto tasks p-2",onScroll:t[0]||(t[0]=(...k)=>e.onHandleScroll&&e.onHandleScroll(...k))},[(l(!0),h(z,null,N(e.tasks?.items,(k,f)=>(l(),w(_,{key:f,"model-value":k,class:"preview"},null,8,["model-value"]))),128))],32)):y("",!0),e.tasks?.items?.length===0?(l(),h("div",bs,[s(n)])):y("",!0),X(r("div",Cs,[s(m)],512),[[Ae,!!e.$store?.state?.suno?.audio?.object]])],64)}const As=E(gs,[["render",Ss]]),Ls=b({name:"TaskPreview",components:{IconPicture:Le,ElImage:J,ElAvatar:Xe,ElIcon:R},computed:{audio(){return this.$store.state.suno?.audio}}}),Es={key:0,class:"size-full overflow-hidden"},Vs={class:"relative h-[300px]"},js={class:"flex items-center justify-center size-full bg-[var(--el-bg-color)]"},Fs={class:"absolute bottom-0 left-0 right-0 m-0 p-4 text-white z-10 bg-gradient-to-t from-black/70 to-transparent"},Ts={class:"p-4"},Ps={class:"flex items-center font-bold mb-2"},Is={class:"text-[var(--el-text-color-regular)] mb-2"},Us={class:"text-xs text-[var(--el-text-color-regular)]"},zs={class:"mt-4 text-sm leading-[25px] whitespace-pre-wrap"},Ds={key:1,class:"w-full h-full"};function Rs(e,t,i,o,a,u){const d=c("icon-picture"),p=c("el-icon"),_=c("el-image"),n=c("el-avatar");return e.audio?.object?(l(),h("div",Es,[r("div",Vs,[s(_,{src:e.audio.image_url,fit:"cover",class:"size-full"},{error:$(()=>[r("div",js,[s(p,{class:"text-3xl"},{default:$(()=>[s(d)]),_:1})])]),_:1},8,["src"]),r("h2",Fs,v(e.audio?.title),1)]),r("div",Ts,[r("div",Ps,[s(n,{size:30,src:e.audio?.image_url,class:"mr-2"},null,8,["src"]),r("span",null,v(e.audio?.title),1)]),r("p",Is,v(e.audio?.style),1),r("p",Us,v(e.$dayjs.format(e.audio?.created_at)),1),r("div",zs,[r("p",null,v(e.audio?.lyric),1)])])])):(l(),h("div",Ds))}const Gs=E(Ls,[["render",Rs]]),Ms="https://webhook.acedata.cloud/suno",Os=b({name:"SunoIndex",components:{Layout:ot,ConfigPanel:yo,RecentPanel:As,PreviewPanel:Gs},inject:["initialized"],data(){return{task:void 0,job:0}},computed:{loading(){return this.$store.state.suno?.status?.getApplications===W.Request},service(){return this.$store.state.suno.service},credential(){return this.$store.state.suno.credential},config(){return this.$store.state.suno.config},initializing(){return this.$store.state.suno.status.getApplications===W.Request},needApply(){return this.$store.state.suno.status.getApplications===W.Success&&!this.application},application(){return this.$store.state.suno.application},tasks(){return this.$store.state.suno.tasks},applications(){return this.$store.state.suno.applications}},watch:{tasks:{handler(e,t){e?.items?.length>t?.items?.length&&console.debug("new tasks detected")},deep:!0},initialized:{async handler(e){e&&(console.debug("layout initialized"),await this.onGetTasks(),await this.onScrollDown(),this.job=setInterval(()=>{this.onGetTasks()},5e3))},immediate:!0}},async mounted(){await this.onGetService()},async unmounted(){clearInterval(this.job)},methods:{async onReachTop(){console.debug("reached top"),await this.onGetTasks({createdAtMax:this.tasks?.items?.[0]?.created_at})},async onGetService(){console.debug("start onGetService"),await this.$store.dispatch("suno/getService"),console.debug("end onGetService")},async onGetApplication(){console.debug("start onGetApplications"),await this.$store.dispatch("suno/getApplications"),console.debug("end onGetApplications"),await this.onGetTasks()},onApply(){Ee.create({application:this.application}).then(({data:e})=>{this.application=e,L.success(this.$t("application.message.applySuccessfully"))}).catch(e=>{e?.response?.data?.code===Ve&&L.error(this.$t("application.message.alreadyApplied"))})},async onScrollDown(){setTimeout(()=>{const e=document.querySelector(".recent");e&&(e.scrollTop=e.scrollHeight)},1e3)},async onGetTasks(e){if(this.loading){console.debug("loading");return}console.debug("start onGetTasks",e);const{limit:t=5,createdAtMin:i,createdAtMax:o}=e||{};console.debug("limit",t,"createdAtMin",i,"createdAtMax",o),await this.$store.dispatch("suno/getTasks",{limit:t,createdAtMin:i,createdAtMax:o})},async onGenerateAudio(){const e={...this.config,callback_url:Ms},t=this.credential?.token;if(!t){console.error("no token specified");return}L.info(this.$t("suno.message.startingTask")),H.audio(e,{token:t}).then(()=>{L.success(this.$t("suno.message.startTaskSuccess"))}).catch(i=>{L.error(i?.response?.data?.error?.message||this.$t("suno.message.startTaskFailed"))}).finally(async()=>{setTimeout(async()=>{await this.onGetTasks(),await this.onScrollDown()},1e3)})}}});function Bs(e,t,i,o,a,u){const d=c("config-panel"),p=c("recent-panel"),_=c("preview-panel"),n=c("layout");return l(),w(n,null,{config:$(()=>[s(d,{onGenerate:e.onGenerateAudio},null,8,["onGenerate"])]),result:$(()=>[s(p,{class:"panel recent",onReachTop:e.onReachTop},null,8,["onReachTop"])]),preview:$(()=>[s(_)]),_:1})}const Cn=E(Os,[["render",Bs],["__scopeId","data-v-f5721d95"]]);export{Cn as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C}from"./CopyToClipboard-
|
|
1
|
+
import{C}from"./CopyToClipboard-BCGRlwJJ.js";import{d as I,dc as F,e3 as T,e4 as N,e5 as P,h as B,i as r,j as o,k as i,l,t as e,x as s,b as p,D as m,y as k,o as n}from"./index-C4ssJdBR.js";import{d as O,a as w,s as M}from"./distribution-BNAm6hj-.js";import{g as q}from"./price-DPmHeT6D.js";import{F as R}from"./index.es-EtbmiVQe.js";import{E as z}from"./index-B7ak1Sj_.js";import{E as U,a as V}from"./index-Drn8vYFB.js";import{E as A}from"./index-CCjGuukj.js";import{E as H,a as G,b as Q}from"./index-DqySUAY6.js";import{E as j}from"./index-DpSdtysU.js";import{E as W}from"./index-CqTGsJay.js";import{E as Y}from"./index-CP_56dlf.js";import"./index-DEAamx_H.js";import"./typescript-D14l1a1y.js";import"./index-J4WBpiv9.js";import"./_initCloneObject-djD3gYlF.js";import"./isPlainObject-BLPi94hV.js";import"./_baseIteratee-35aC5hBk.js";import"./isEqual-BqBcCRrU.js";import"./castArray-TlECDAqv.js";import"./debounce-DTzFlSYq.js";import"./index-DislasB7.js";import"./use-form-item-CGJaz8fH.js";import"./index-BqzuTEwO.js";import"./index-r5W6hzzQ.js";const J=I({name:"ConsoleDistributionList",components:{CopyToClipboard:C,FontAwesomeIcon:R,QrCode:F,ElProgress:Y,ElRow:Q,ElCol:G,ElButton:W,ElDivider:j,ElCard:H,ElTooltip:A,ElTable:V,ElTableColumn:U,ElSkeleton:z},data(){return{invitees:[],inviteesCount:void 0,distributionLevels:[],distributionLink:void 0,distributionStatus:void 0,loading:!1}},computed:{redirect(){return this.$route.query.redirect},page(){return parseInt(this.$route.query.page?.toString()||"1")},distributionLevelMap(){let t={};return this.distributionLevels.forEach(a=>{t[a.level]=a}),t}},watch:{page:{handler(){this.onFetchData()}}},async mounted(){this.onFetchData(),this.onGenerateDistributionLink()},methods:{getPriceString:q,goHistory(){this.$router.push({name:P})},goInvitees(){this.$router.push({name:N})},onPageChange(t){this.$router.push({name:this.$route.name?.toString(),query:{page:t}})},getPercentageForNextLevel(){const t=this.distributionLevelMap[this.distributionStatus?.level?.level]?.threshold,a=this.distributionLevelMap[this.distributionStatus?.level?.level+1]?.threshold;return Math.floor((this.distributionStatus?.price-t)/(a-t)*100)},getDeltaForNextLevel(){const t=this.distributionLevelMap[this.distributionStatus?.level?.level+1]?.threshold;return Math.floor(t-this.distributionStatus?.price)},async onFetchData(){this.loading=!0,await w.initialize(),Promise.all([this.onFetchDistributionStatus(),this.onFetchDistributionLevels(),this.onFetchInvitees()]).finally(()=>{this.loading=!1})},async onGenerateDistributionLink(){const a=`${window.location.origin}?inviter_id=${this.$store.getters.user.id}`;try{const v=(await M.create(a))?.data?.data?.url;this.distributionLink=(v||a).replace("surl.id","share.acedata.cloud")}catch{this.distributionLink=a}},async onFetchDistributionStatus(){const{data:t}=await w.getAll({user_id:this.$store.getters.user.id});t.items&&t.items.length>0&&(this.distributionStatus=t.items[0])},async onFetchDistributionLevels(){const{data:t}=await O.getAll({limit:20,user_id:this.$store.getters.user.id});this.distributionLevels=t.items},async onFetchInvitees(){const{data:t}=await T.getInvitees({});this.invitees=t.items,this.inviteesCount=t.count}}}),K={class:"title"},X={key:1},Z={class:"icon-wrapper"},x={class:"text-left"},tt={class:"description"},et={class:"value"},it={key:1},st={class:"icon-wrapper"},ot={class:"text-left"},nt={class:"description"},lt={class:"value"},at={key:1},rt={class:"icon-wrapper"},dt={class:"text-left"},ct={class:"description"},ut={class:"value"},pt={key:1},ht={class:"icon-wrapper"},mt={class:"text-left"},_t={class:"description"},bt={class:"value"},vt={key:1},ft={class:"title"},gt={class:"clear-both overflow-hidden"},kt={class:"float-left description"},yt={class:"float-right description"},$t={class:"description"},wt={class:"level"},Lt={class:"level"},St={class:"level"},Et={key:1},Dt={class:"title"},Ct={class:"link-wrapper text-center"},It=["href"],Ft={class:"qr-wrapper ml-auto mr-auto"},Tt={class:"mt-0"},Nt={class:"description"},Pt={class:"more"};function Bt(t,a,v,Ot,Mt,qt){const d=l("el-col"),_=l("el-row"),c=l("el-skeleton"),b=l("font-awesome-icon"),f=l("el-button"),u=l("el-card"),y=l("el-tooltip"),L=l("el-progress"),$=l("el-divider"),g=l("el-table-column"),S=l("el-table"),E=l("copy-to-clipboard"),D=l("qr-code");return n(),r(_,{class:"panel"},{default:o(()=>[i(d,{span:24},{default:o(()=>[i(_,null,{default:o(()=>[i(d,{span:24},{default:o(()=>[e("h2",K,s(t.$t("common.title.distribution")),1)]),_:1})]),_:1}),i(_,{gutter:15},{default:o(()=>[i(d,{md:6,xs:24},{default:o(()=>[i(u,{shadow:"hover",class:"item-mini mb-4"},{default:o(()=>[t.loading?(n(),r(c,{key:0})):(n(),p("div",X,[e("div",Z,[i(b,{icon:"fa-solid fa-wallet",class:"icon"})]),e("div",x,[e("p",tt,s(t.$t("distribution.title.price")),1),e("p",et,s(t.getPriceString({value:t.distributionStatus?.price})),1)]),i(f,{type:"primary",round:"",size:"small",class:"btn",onClick:t.goHistory},{default:o(()=>[m(s(t.$t("distribution.button.detail")),1)]),_:1},8,["onClick"])]))]),_:1})]),_:1}),i(d,{md:6,xs:24},{default:o(()=>[i(u,{shadow:"hover",class:"item-mini mb-4"},{default:o(()=>[t.loading?(n(),r(c,{key:0})):(n(),p("div",it,[e("div",st,[i(b,{icon:"fa-solid fa-coins",class:"icon"})]),e("div",ot,[e("p",nt,s(t.$t("distribution.title.reward")),1),e("p",lt,s(t.getPriceString({value:t.distributionStatus?.reward})),1)]),i(y,{effect:"dark",content:t.$t("distribution.message.developingWithDrawal"),placement:"top"},{default:o(()=>[i(f,{type:"primary",round:"",size:"small",class:"btn"},{default:o(()=>[m(s(t.$t("distribution.button.withdrawal")),1)]),_:1})]),_:1},8,["content"])]))]),_:1})]),_:1}),i(d,{md:6,xs:24},{default:o(()=>[i(u,{shadow:"hover",class:"item-mini mb-4"},{default:o(()=>[t.loading?(n(),r(c,{key:0})):(n(),p("div",at,[e("div",rt,[i(b,{icon:"fa-solid fa-percent",class:"icon"})]),e("div",dt,[e("p",ct,s(t.$t("distribution.title.percentage")),1),e("p",ut,s(t.distributionStatus?.level?.percentage)+"%",1)])]))]),_:1})]),_:1}),i(d,{md:6,xs:24},{default:o(()=>[i(u,{shadow:"hover",class:"item-mini mb-4"},{default:o(()=>[t.loading?(n(),r(c,{key:0})):(n(),p("div",pt,[e("div",ht,[i(b,{icon:"fa-regular fa-user",class:"icon"})]),e("div",mt,[e("p",_t,s(t.$t("distribution.title.inviteesCount")),1),e("p",bt,s(t.inviteesCount),1)]),i(f,{type:"primary",round:"",size:"small",class:"btn",onClick:t.goInvitees},{default:o(()=>[m(s(t.$t("distribution.button.detail")),1)]),_:1},8,["onClick"])]))]),_:1})]),_:1})]),_:1}),i(_,{gutter:15},{default:o(()=>[i(d,{md:12,xs:24},{default:o(()=>[i(u,{shadow:"hover",class:"level-info mb-4"},{default:o(()=>[t.loading?(n(),r(c,{key:0})):(n(),p("div",vt,[e("h4",ft,s(t.$t("distribution.title.levelInfo")),1),e("div",gt,[e("div",kt,[e("p",null,s(t.$t("distribution.title.currentLevel"))+": L"+s(t.distributionStatus?.level?.level),1),e("p",null,s(t.$t("distribution.title.currentPercentage"))+": "+s(t.distributionLevelMap[t.distributionStatus?.level?.level]?.percentage)+"% ",1)]),e("div",yt,[e("p",null,s(t.$t("distribution.title.nextLevel"))+": L"+s(t.distributionStatus?.level?.level+1),1),e("p",null,s(t.$t("distribution.title.nextPercentage"))+": "+s(t.distributionLevelMap[t.distributionStatus?.level?.level+1]?.percentage)+"% ",1)])]),i(L,{"text-inside":!0,"stroke-width":20,percentage:t.getPercentageForNextLevel(),class:"mb-2"},null,8,["percentage"]),e("p",$t,s(t.$t("distribution.message.deltaPriceForNextLevel"))+": $"+s(t.getDeltaForNextLevel()),1),i($),t.distributionLevels?(n(),r(S,{key:0,data:t.distributionLevels,stripe:""},{default:o(()=>[i(g,{label:t.$t("distribution.field.level")},{default:o(h=>[e("span",wt,"L"+s(h.row?.level),1)]),_:1},8,["label"]),i(g,{label:t.$t("distribution.field.threshold")},{default:o(h=>[e("span",Lt,"$"+s(h.row?.threshold),1)]),_:1},8,["label"]),i(g,{label:t.$t("distribution.field.percentage")},{default:o(h=>[e("span",St,s(h.row?.percentage)+"%",1)]),_:1},8,["label"])]),_:1},8,["data"])):k("",!0)]))]),_:1})]),_:1}),i(d,{md:12,xs:24},{default:o(()=>[i(u,{shadow:"hover",class:"distribution-info mb-4"},{default:o(()=>[t.loading?(n(),r(c,{key:0})):(n(),p("div",Et,[e("h4",Dt,s(t.$t("distribution.title.distributionLink")),1),i($),e("div",Ct,[k("",!0),e("a",{href:t.distributionLink,class:"link"},s(t.distributionLink),9,It),i(E,{content:t.distributionLink},null,8,["content"])]),e("div",Ft,[t.distributionLink?(n(),r(D,{key:0,value:t.distributionLink,size:180,margin:2,class:"block mb-2 ml-auto mr-auto",type:"image/png",color:{dark:"#000000",light:"#ffffff"}},null,8,["value"])):k("",!0),e("p",Tt,s(t.$t("distribution.message.distributionQrDescription")),1)]),e("p",Nt,[m(s(t.$t("distribution.message.distributionLinkDescription"))+" ",1),e("span",Pt,[i(y,{effect:"dark",content:t.$t("distribution.message.distributionLinkDescription2"),placement:"top"},{default:o(()=>[m(s(t.$t("distribution.message.technicalDetail")),1)]),_:1},8,["content"])])])]))]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})}const de=B(J,[["render",Bt],["__scopeId","data-v-a8befdf2"]]);export{de as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as U}from"./index.es-CJbKM0CV.js";import{E as I}from"./index-C5k9PNqL.js";import{E as L}from"./index-CNg43fsi.js";import{d as b,h as k,b as l,t as i,k as t,r as T,j as u,l as o,o as s,eP as P,x as n,F as C,v as G,i as v,c7 as R,D as p,y as h,n as E,ai as j,eQ as D,ds as B,dn as M}from"./index-DTe9fRn-.js";import{E as q,a as O}from"./index-DCYB3TDh.js";import{I as A}from"./InfoIcon-YhCcbV8z.js";import{I as z}from"./ImagePreview-D6FjLfQO.js";import{E as F}from"./index-DxTeNsnH.js";import{E as V}from"./index-H7zk7enZ.js";import{E as N}from"./index-I4cHhAfY.js";import{C as H,N as K}from"./NoTasks-ex5PKih3.js";import{a as Q}from"./price-C04dX6gR.js";import{C as J}from"./CopyToClipboard-CU-Bssp8.js";import{V as W}from"./VideoPlayer-C0am2_1Y.js";import{E as X}from"./index-DjlWqdX5.js";import{E as Y}from"./index-N-T3RtWX.js";import{E as Z}from"./index-Bp0DDosh.js";import{B as x}from"./BotPlaceholder-C_vy0qCQ.js";import"./use-form-item-CtZlpzU6.js";import"./index-r5W6hzzQ.js";import"./index-DLyu6NQP.js";import"./typescript-BioIzq79.js";import"./index-DaEk4vUe.js";import"./strings-CNF1iAZ6.js";import"./castArray-pZCaAVDW.js";import"./isEqual-CH8EZj5t.js";import"./_initCloneObject-CJq550xS.js";import"./debounce-Bzi7Cd91.js";import"./_baseIteratee-LczmVVcS.js";import"./index-BgQ-O6aa.js";import"./index-DPoEMPUV.js";import"./_baseClone-BDmNDGGK.js";import"./index-MMWJF36O.js";import"./vue-plyr-QZFBikSk.js";import"./index-DyxxJgEB.js";const ee=b({name:"LayoutHailuo",components:{ElDrawer:L,ElButton:I,FontAwesomeIcon:U},data(){return{drawer:!1}}}),te={class:"main flex flex-row flex-1"},oe={class:"config w-[300px] h-full overflow-y-scroll border-r border-[var(--el-border-color)]"},se={class:"result h-full p-[15px] flex-1 flex flex-col"};function ae(e,a,f,_,w,y){const d=o("font-awesome-icon"),m=o("el-button"),r=o("el-drawer");return s(),l("div",te,[i("div",oe,[T(e.$slots,"config",{},void 0,!0)]),i("div",se,[T(e.$slots,"result",{},void 0,!0)]),t(m,{circle:"",class:"menu",onClick:a[0]||(a[0]=g=>e.drawer=!0)},{default:u(()=>[t(d,{icon:"fa-solid fa-magic"})]),_:1}),t(r,{modelValue:e.drawer,"onUpdate:modelValue":a[1]||(a[1]=g=>e.drawer=g),direction:"ltr","with-header":!1,size:"340px"},{default:u(()=>[T(e.$slots,"config",{},void 0,!0)]),_:3},8,["modelValue"])])}const ne=k(ee,[["render",ae],["__scopeId","data-v-096d9205"]]),le=b({name:"ModelSelector",components:{ElSelect:O,ElOption:q},data(){return{}},computed:{options(){return[{value:"minimax-t2v",label:this.$t("hailuo.button.model1")},{value:"minimax-i2v",label:this.$t("hailuo.button.model2")}]},value:{get(){return this.$store.state.hailuo?.config?.model},set(e){this.$store.commit("hailuo/setConfig",{...this.$store.state.hailuo?.config,model:e})}}},mounted(){this.value||(this.value=P)}}),ie={class:"field"},re={class:"title font-bold"},ce={class:"float-left"};function ue(e,a,f,_,w,y){const d=o("el-option"),m=o("el-select");return s(),l("div",ie,[i("h2",re,n(e.$t("hailuo.name.model")),1),t(m,{modelValue:e.value,"onUpdate:modelValue":a[0]||(a[0]=r=>e.value=r),class:"value",placeholder:e.$t("hailuo.placeholder.select"),clearable:""},{default:u(()=>[(s(!0),l(C,null,G(e.options,r=>(s(),v(d,{key:r.value,label:r.label,value:r.value},{default:u(()=>[i("span",ce,n(r.label),1)]),_:2},1032,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])])}const de=k(le,[["render",ue],["__scopeId","data-v-30ff1e69"]]),me=b({name:"StartImageUrlInput",components:{ElUpload:F,ElButton:I,InfoIcon:A,ImagePreview:z},data(){return{fileList:[],uploadUrl:R()+"/api/v1/files/"}},computed:{headers(){return{Authorization:`Bearer ${this.$store.state.token.access}`}},urls(){return this.fileList.map(e=>e.url).filter(e=>e!==void 0)},value:{get(){return this.$store.state.hailuo?.config?.first_image_url},set(){const e=this.urls?.[0];this.$store.commit("hailuo/setConfig",{...this.$store.state.hailuo?.config,first_image_url:e})}}},mounted(){this.value||(this.value=void 0),this.onSetStartImageUrl()},methods:{onExceed(){V.warning(this.$t("hailuo.message.uploadStartImageExceed"))},onError(){V.error(this.$t("hailuo.message.uploadStartImageError"))},async onRemove(){V.error(this.$t("hailuo.message.uploadStartImageError"))},onSetStartImageUrl(){const e=this.urls?.[0];this.$store.commit("hailuo/setConfig",{...this.$store.state.hailuo?.config,first_image_url:e})},async onSuccess(){this.onSetStartImageUrl()}}}),pe={class:"relative"},he={class:"flex justify-between"},fe={class:"flex justify-start items-center"},_e={class:"text-sm font-bold"};function ge(e,a,f,_,w,y){const d=o("info-icon"),m=o("image-preview"),r=o("el-button"),g=o("el-upload");return s(),l("div",pe,[i("div",he,[i("div",fe,[i("span",_e,n(e.$t("hailuo.name.startImageUrl")),1),t(d,{content:e.$t("hailuo.description.startImageUrl"),class:"info"},null,8,["content"])])]),t(g,{"file-list":e.fileList,"onUpdate:fileList":a[0]||(a[0]=c=>e.fileList=c),accept:".png,.jpg,.jpeg,.gif,.bmp,.webp",name:"file","show-file-list":!0,limit:1,multiple:!1,"list-type":"picture",action:e.uploadUrl,"on-exceed":e.onExceed,"on-error":e.onError,"on-remove":e.onRemove,"on-success":e.onSuccess,headers:e.headers},{file:u(({file:c})=>[c.url&&c.percentage!==void 0?(s(),v(m,{key:0,url:c.url,name:c.name,percentage:c.percentage,onRemove:$=>e.fileList.splice(e.fileList.indexOf(c),1)},null,8,["url","name","percentage","onRemove"])):h("",!0)]),default:u(()=>[t(r,{size:"small",type:"primary",class:"btn btn-upload",round:""},{default:u(()=>[p(n(e.$t("hailuo.button.uploadStartImageUrl")),1)]),_:1})]),_:1},8,["file-list","action","on-exceed","on-error","on-remove","on-success","headers"])])}const $e=k(me,[["render",ge],["__scopeId","data-v-a906df80"]]),ve="",be=b({name:"PromptInput",components:{ElInput:N,InfoIcon:A},computed:{prompt:{get(){return this.$store.state.hailuo?.config?.prompt},set(e){console.debug("set prompt",e),this.$store.commit("hailuo/setConfig",{...this.$store.state.hailuo?.config,prompt:e})}}},mounted(){this.prompt||(this.prompt=ve)}}),ke={class:"field"},we={class:"box"},ye={class:"title font-bold"};function Ve(e,a,f,_,w,y){const d=o("info-icon"),m=o("el-input");return s(),l("div",ke,[i("div",we,[i("h2",ye,n(e.$t("hailuo.name.prompt")),1),t(d,{content:e.$t("hailuo.description.prompt"),class:"info"},null,8,["content"])]),t(m,{modelValue:e.prompt,"onUpdate:modelValue":a[0]||(a[0]=r=>e.prompt=r),rows:3,type:"textarea",class:"prompt",placeholder:e.$t("hailuo.placeholder.prompt"),maxlength:300,"show-word-limit":""},null,8,["modelValue","placeholder"])])}const Ie=k(be,[["render",Ve],["__scopeId","data-v-d54ffa64"]]),Ee=b({name:"PresetPanel",components:{ElButton:I,FontAwesomeIcon:U,PromptInput:Ie,StartImageUrlInput:$e,ModelSelector:de,Consumption:H},emits:["generate"],computed:{config(){return this.$store.state.hailuo?.config},consumption(){return Q(this.config,this.service?.metadata?.price)},service(){return this.$store.state.hailuo?.service}},methods:{onGenerate(){this.$emit("generate")}}}),Se={class:"flex flex-col h-full"},Te={class:"flex-1 overflow-y-auto p-[15px]"},Ce={class:"flex flex-col items-center justify-center px-[15px] pb-[15px]"};function Ue(e,a,f,_,w,y){const d=o("prompt-input"),m=o("model-selector"),r=o("start-image-url-input"),g=o("consumption"),c=o("font-awesome-icon"),$=o("el-button");return s(),l("div",Se,[i("div",Te,[t(d,{class:"mb-4"}),t(m,{class:"mb-4"}),e.config?.model==="minimax-i2v"?(s(),v(r,{key:0,class:"mb-2"})):h("",!0)]),i("div",Ce,[t(g,{value:e.consumption,service:e.service},null,8,["value","service"]),e.config?.video_url!==void 0||e.config?.custom?(s(),v($,{key:0,type:"primary",class:"btn w-full",round:"",onClick:e.onGenerate},{default:u(()=>[t(c,{icon:"fa-solid fa-magic",class:"mr-2"}),p(" "+n(e.$t("hailuo.button.extend")),1)]),_:1},8,["onClick"])):(s(),v($,{key:1,type:"primary",class:"btn w-full",round:"",onClick:e.onGenerate},{default:u(()=>[t(c,{icon:"fa-solid fa-magic",class:"mr-2"}),p(" "+n(e.$t("hailuo.button.generate")),1)]),_:1},8,["onClick"]))])])}const Ge=k(Ee,[["render",Ue]]),Ae=b({name:"TaskPreview",components:{ElImage:Z,CopyToClipboard:J,FontAwesomeIcon:U,ElAlert:Y,VideoPlayer:W,ElTooltip:X,ElButton:I},props:{modelValue:{type:Object,required:!0}},computed:{application(){return this.$store.state.hailuo?.application},config(){return this.$store.state.hailuo?.config},video(){return this.modelValue?.response?.data?.[0]}},methods:{onDownload(e){console.debug("on download hailuo video",e),window.open(e,"_blank")}}}),Le={class:"preview"},Pe={class:"left"},Re={class:"main"},je={class:"bot"},De={class:"datetime"},Be={class:"info"},Me={key:0,class:"prompt mt-2"},qe={key:0},Oe={key:1},ze={key:0,class:E({content:!0,failed:!0})},Fe={key:0,class:"mb-4"},Ne={key:1,class:E({operations:!0,"mt-2":!0})},He={key:0,class:"text-[var(--el-text-color-regular)] text-xs mb-2"},Ke={class:"text-[var(--el-text-color-regular)] text-xs mb-0"},Qe={key:1,class:E({content:!0})},Je={class:"text-[var(--el-text-color-regular)] text-xs mb-2"},We={class:"text-[var(--el-text-color-regular)] text-xs mb-2"},Xe={class:"text-[var(--el-text-color-regular)] text-xs mb-0"},Ye={key:2,class:E({content:!0})},Ze={class:"text-[var(--el-text-color-regular)] text-xs mb-0"};function xe(e,a,f,_,w,y){const d=o("el-image"),m=o("video-player"),r=o("el-button"),g=o("el-tooltip"),c=o("font-awesome-icon"),$=o("copy-to-clipboard"),S=o("el-alert");return s(),l("div",Le,[i("div",Pe,[t(d,{src:"https://cdn.acedata.cloud/0qg4gp.png",class:"avatar"})]),i("div",Re,[i("div",je,[p(n(e.$t("hailuo.name.hailuoBot"))+" ",1),i("span",De,n(e.$dayjs.format(""+new Date(parseFloat((e.modelValue?.created_at||"").toString())*1e3))),1)]),i("div",Be,[e.modelValue?.request?.prompt?(s(),l("p",Me,[p(n(e.modelValue?.request?.prompt)+" ",1),e.modelValue?.response?h("",!0):(s(),l("span",qe," - ("+n(e.$t("hailuo.status.pending"))+") ",1)),e.video?.state==="processing"||e.video?.state==="pending"||e.video?.state==="running"?(s(),l("span",Oe," - ("+n(e.$t("hailuo.status.processing"))+") ",1)):h("",!0)])):h("",!0)]),e.modelValue?.response?.success===!0?(s(),l("div",ze,[e.video?.video_url?(s(),l("div",Fe,[t(m,{src:e.video?.video_url},null,8,["src"])])):h("",!0),e.video?(s(),l("div",Ne,[t(g,{class:"box-item",effect:"dark",content:e.$t("hailuo.message.downloadVideo"),placement:"top-start"},{default:u(()=>[e.video?.video_url?(s(),v(r,{key:0,type:"info",size:"small",class:"mb-2",onClick:a[0]||(a[0]=j(ut=>e.onDownload(e.video?.video_url),["stop"]))},{default:u(()=>[p(n(e.$t("hailuo.button.download")),1)]),_:1})):h("",!0)]),_:1},8,["content"])])):h("",!0),t(S,{closable:!1,class:"mt-2 success"},{default:u(()=>[e.modelValue?.request?.model?(s(),l("p",He,[t(c,{icon:"fa-solid fa-hashtag",class:"mr-1"}),p(" "+n(e.$t("hailuo.name.model"))+": "+n(e.modelValue?.request?.model)+" ",1),t($,{content:e.modelValue?.id},null,8,["content"])])):h("",!0),i("p",Ke,[t(c,{icon:"fa-solid fa-magic",class:"mr-1"}),p(" "+n(e.$t("hailuo.name.taskId"))+": "+n(e.modelValue?.id)+" ",1),t($,{content:e.modelValue?.id},null,8,["content"])])]),_:1})])):h("",!0),e.modelValue?.response?.success===!1?(s(),l("div",Qe,[t(S,{closable:!1,class:"failure"},{template:u(()=>[t(c,{icon:"fa-solid fa-exclamation-triangle",class:"mr-1"}),p(" "+n(e.$t("hailuo.name.failure")),1)]),default:u(()=>[i("p",Je,[t(c,{icon:"fa-solid fa-magic",class:"mr-1"}),p(" "+n(e.$t("hailuo.name.taskId"))+": "+n(e.modelValue?.id)+" ",1),t($,{content:e.modelValue?.id},null,8,["content"])]),i("p",We,[t(c,{icon:"fa-solid fa-circle-info",class:"mr-1"}),p(" "+n(e.$t("hailuo.name.failureReason"))+": "+n(e.modelValue?.response?.error?.message)+" ",1),t($,{content:e.modelValue?.response?.error?.message},null,8,["content"])]),i("p",Xe,[t(c,{icon:"fa-solid fa-hashtag",class:"mr-1"}),p(" "+n(e.$t("hailuo.name.traceId"))+": "+n(e.modelValue?.response?.trace_id)+" ",1),t($,{content:e.modelValue?.response?.trace_id},null,8,["content"])])]),_:1})])):h("",!0),e.modelValue?.response?.success===void 0?(s(),l("div",Ye,[t(S,{closable:!1,class:"info"},{template:u(()=>[t(c,{icon:"fa-solid fa-exclamation-triangle",class:"mr-1"}),p(" "+n(e.$t("hailuo.name.failure")),1)]),default:u(()=>[i("p",Ze,[t(c,{icon:"fa-solid fa-magic",class:"mr-1"}),p(" "+n(e.$t("hailuo.name.taskId"))+": "+n(e.modelValue?.id)+" ",1),t($,{content:e.modelValue?.id},null,8,["content"])])]),_:1})])):h("",!0)])])}const et=k(Ae,[["render",xe],["__scopeId","data-v-72acd507"]]),tt=b({name:"RecentPanel",components:{TaskPreview:et,BotPlaceholder:x,NoTasks:K},emits:["reach-top"],data(){return{job:0}},computed:{tasks(){return{...this.$store.state.hailuo?.tasks,items:this.$store.state.hailuo?.tasks?.items?.slice()}}},methods:{onHandleScroll(){const e=this.$refs.panel;console.log("reach-top reach-top reach-top"),e.scrollTop===0&&this.$emit("reach-top")}}}),ot={key:0},st={key:1,class:"tasks w-full h-full overflow-y-auto"},at={key:2,class:"w-full h-full flex items-center justify-center"};function nt(e,a,f,_,w,y){const d=o("bot-placeholder"),m=o("task-preview"),r=o("no-tasks");return s(),l(C,null,[e.tasks?.items===void 0?(s(),l("div",ot,[t(d)])):e.tasks?.items?.length&&e.tasks?.items?.length>0?(s(),l("div",st,[(s(!0),l(C,null,G(e.tasks?.items,g=>(s(),v(m,{key:g.id,"model-value":g},null,8,["model-value"]))),128))])):h("",!0),e.tasks?.items?.length===0?(s(),l("div",at,[t(r)])):h("",!0)],64)}const lt=k(tt,[["render",nt]]),it="https://webhook.acedata.cloud/hailuo",rt=b({name:"HailuoIndex",components:{ConfigPanel:Ge,Layout:ne,RecentPanel:lt},inject:["initialized"],data(){return{task:void 0,job:0,timer:void 0}},computed:{loading(){return this.$store.state.hailuo?.status?.getApplications===M.Request},credential(){return this.$store.state.hailuo.credential},config(){return this.$store.state.hailuo.config},application(){return this.$store.state.hailuo.application},tasks(){return this.$store.state.hailuo.tasks}},watch:{tasks:{handler(e,a){e?.items?.length>a?.items?.length&&console.debug("new tasks detected")},deep:!0},initialized:{async handler(e){e&&(console.debug("layout initialized"),await this.onGetTasks(),await this.onScrollDown(),this.job=setInterval(()=>{this.onGetTasks()},5e3))},immediate:!0}},async mounted(){await this.onGetService()},async unmounted(){clearInterval(this.job)},methods:{async onReachTop(){console.debug("reached top"),await this.onGetTasks({createdAtMax:this.tasks?.items?.[0]?.created_at})},async onGetService(){console.debug("start onGetService"),await this.$store.dispatch("hailuo/getService"),console.debug("end onGetService")},async onGetApplication(){console.debug("start onGetApplication"),await this.$store.dispatch("hailuo/getApplications"),console.debug("end onGetApplication"),await this.onGetTasks()},async onScrollDown(){setTimeout(()=>{const e=document.querySelector(".tasks");e&&(e.scrollTop=e.scrollHeight)},500)},async onGetTasks(e){if(this.loading){console.debug("loading");return}console.debug("start onGetTasks",e);const{limit:a=5,createdAtMin:f,createdAtMax:_}=e||{};console.debug("limit",a,"createdAtMin",f,"createdAtMax",_),await this.$store.dispatch("hailuo/getTasks",{limit:a,createdAtMin:f,createdAtMax:_})},async onGenerate(){const e={...this.config,callback_url:it},a=this.credential?.token;if(!a){console.error("no token specified");return}V.info(this.$t("hailuo.message.startingTask")),D.generate(e,{token:a}).then(()=>{V.success(this.$t("hailuo.message.startTaskSuccess"))}).catch(f=>{f?.response?.data?.error?.code===B?V.error(this.$t("hailuo.message.usedUp")):V.error(this.$t("hailuo.message.startTaskFailed"))}).finally(async()=>{setTimeout(async()=>{await this.onGetTasks(),await this.onScrollDown()},1e3)})}}});function ct(e,a,f,_,w,y){const d=o("config-panel"),m=o("recent-panel"),r=o("layout");return s(),v(r,null,{config:u(()=>[t(d,{onGenerate:e.onGenerate},null,8,["onGenerate"])]),result:u(()=>[t(m,{onReachTop:e.onReachTop},null,8,["onReachTop"])]),_:1})}const Kt=k(rt,[["render",ct]]);export{Kt as default};
|
|
1
|
+
import{F as U}from"./index.es-EtbmiVQe.js";import{E as I}from"./index-CqTGsJay.js";import{E as L}from"./index-BzyEWvnL.js";import{d as b,h as k,b as l,t as i,k as t,r as T,j as u,l as o,o as s,eP as P,x as n,F as C,v as G,i as v,c7 as R,D as p,y as h,n as E,ai as j,eQ as D,ds as B,dn as M}from"./index-C4ssJdBR.js";import{E as q,a as O}from"./index-C4trafQk.js";import{I as A}from"./InfoIcon-BJAJcb5a.js";import{I as z}from"./ImagePreview-TA4gKfP6.js";import{E as F}from"./index-gFYmOD1F.js";import{E as V}from"./index-BqAthpig.js";import{E as N}from"./index-Bth-8JIu.js";import{C as H,N as K}from"./NoTasks-oiStcbHf.js";import{a as Q}from"./price-DPmHeT6D.js";import{C as J}from"./CopyToClipboard-BCGRlwJJ.js";import{V as W}from"./VideoPlayer-CYaGmv09.js";import{E as X}from"./index-CCjGuukj.js";import{E as Y}from"./index-qJunmjSC.js";import{E as Z}from"./index-tdgIYwZh.js";import{B as x}from"./BotPlaceholder-BWFhmlAo.js";import"./use-form-item-CGJaz8fH.js";import"./index-r5W6hzzQ.js";import"./index-DEAamx_H.js";import"./typescript-D14l1a1y.js";import"./index-J4WBpiv9.js";import"./strings-cAoZbHaH.js";import"./castArray-TlECDAqv.js";import"./isEqual-BqBcCRrU.js";import"./_initCloneObject-djD3gYlF.js";import"./debounce-DTzFlSYq.js";import"./_baseIteratee-35aC5hBk.js";import"./index-BqzuTEwO.js";import"./index-CP_56dlf.js";import"./_baseClone-kJ5Pgx6e.js";import"./index-zBoOr1pW.js";import"./vue-plyr-QZFBikSk.js";import"./index-B7ak1Sj_.js";const ee=b({name:"LayoutHailuo",components:{ElDrawer:L,ElButton:I,FontAwesomeIcon:U},data(){return{drawer:!1}}}),te={class:"main flex flex-row flex-1"},oe={class:"config w-[300px] h-full overflow-y-scroll border-r border-[var(--el-border-color)]"},se={class:"result h-full p-[15px] flex-1 flex flex-col"};function ae(e,a,f,_,w,y){const d=o("font-awesome-icon"),m=o("el-button"),r=o("el-drawer");return s(),l("div",te,[i("div",oe,[T(e.$slots,"config",{},void 0,!0)]),i("div",se,[T(e.$slots,"result",{},void 0,!0)]),t(m,{circle:"",class:"menu",onClick:a[0]||(a[0]=g=>e.drawer=!0)},{default:u(()=>[t(d,{icon:"fa-solid fa-magic"})]),_:1}),t(r,{modelValue:e.drawer,"onUpdate:modelValue":a[1]||(a[1]=g=>e.drawer=g),direction:"ltr","with-header":!1,size:"340px"},{default:u(()=>[T(e.$slots,"config",{},void 0,!0)]),_:3},8,["modelValue"])])}const ne=k(ee,[["render",ae],["__scopeId","data-v-096d9205"]]),le=b({name:"ModelSelector",components:{ElSelect:O,ElOption:q},data(){return{}},computed:{options(){return[{value:"minimax-t2v",label:this.$t("hailuo.button.model1")},{value:"minimax-i2v",label:this.$t("hailuo.button.model2")}]},value:{get(){return this.$store.state.hailuo?.config?.model},set(e){this.$store.commit("hailuo/setConfig",{...this.$store.state.hailuo?.config,model:e})}}},mounted(){this.value||(this.value=P)}}),ie={class:"field"},re={class:"title font-bold"},ce={class:"float-left"};function ue(e,a,f,_,w,y){const d=o("el-option"),m=o("el-select");return s(),l("div",ie,[i("h2",re,n(e.$t("hailuo.name.model")),1),t(m,{modelValue:e.value,"onUpdate:modelValue":a[0]||(a[0]=r=>e.value=r),class:"value",placeholder:e.$t("hailuo.placeholder.select"),clearable:""},{default:u(()=>[(s(!0),l(C,null,G(e.options,r=>(s(),v(d,{key:r.value,label:r.label,value:r.value},{default:u(()=>[i("span",ce,n(r.label),1)]),_:2},1032,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])])}const de=k(le,[["render",ue],["__scopeId","data-v-30ff1e69"]]),me=b({name:"StartImageUrlInput",components:{ElUpload:F,ElButton:I,InfoIcon:A,ImagePreview:z},data(){return{fileList:[],uploadUrl:R()+"/api/v1/files/"}},computed:{headers(){return{Authorization:`Bearer ${this.$store.state.token.access}`}},urls(){return this.fileList.map(e=>e.url).filter(e=>e!==void 0)},value:{get(){return this.$store.state.hailuo?.config?.first_image_url},set(){const e=this.urls?.[0];this.$store.commit("hailuo/setConfig",{...this.$store.state.hailuo?.config,first_image_url:e})}}},mounted(){this.value||(this.value=void 0),this.onSetStartImageUrl()},methods:{onExceed(){V.warning(this.$t("hailuo.message.uploadStartImageExceed"))},onError(){V.error(this.$t("hailuo.message.uploadStartImageError"))},async onRemove(){V.error(this.$t("hailuo.message.uploadStartImageError"))},onSetStartImageUrl(){const e=this.urls?.[0];this.$store.commit("hailuo/setConfig",{...this.$store.state.hailuo?.config,first_image_url:e})},async onSuccess(){this.onSetStartImageUrl()}}}),pe={class:"relative"},he={class:"flex justify-between"},fe={class:"flex justify-start items-center"},_e={class:"text-sm font-bold"};function ge(e,a,f,_,w,y){const d=o("info-icon"),m=o("image-preview"),r=o("el-button"),g=o("el-upload");return s(),l("div",pe,[i("div",he,[i("div",fe,[i("span",_e,n(e.$t("hailuo.name.startImageUrl")),1),t(d,{content:e.$t("hailuo.description.startImageUrl"),class:"info"},null,8,["content"])])]),t(g,{"file-list":e.fileList,"onUpdate:fileList":a[0]||(a[0]=c=>e.fileList=c),accept:".png,.jpg,.jpeg,.gif,.bmp,.webp",name:"file","show-file-list":!0,limit:1,multiple:!1,"list-type":"picture",action:e.uploadUrl,"on-exceed":e.onExceed,"on-error":e.onError,"on-remove":e.onRemove,"on-success":e.onSuccess,headers:e.headers},{file:u(({file:c})=>[c.url&&c.percentage!==void 0?(s(),v(m,{key:0,url:c.url,name:c.name,percentage:c.percentage,onRemove:$=>e.fileList.splice(e.fileList.indexOf(c),1)},null,8,["url","name","percentage","onRemove"])):h("",!0)]),default:u(()=>[t(r,{size:"small",type:"primary",class:"btn btn-upload",round:""},{default:u(()=>[p(n(e.$t("hailuo.button.uploadStartImageUrl")),1)]),_:1})]),_:1},8,["file-list","action","on-exceed","on-error","on-remove","on-success","headers"])])}const $e=k(me,[["render",ge],["__scopeId","data-v-a906df80"]]),ve="",be=b({name:"PromptInput",components:{ElInput:N,InfoIcon:A},computed:{prompt:{get(){return this.$store.state.hailuo?.config?.prompt},set(e){console.debug("set prompt",e),this.$store.commit("hailuo/setConfig",{...this.$store.state.hailuo?.config,prompt:e})}}},mounted(){this.prompt||(this.prompt=ve)}}),ke={class:"field"},we={class:"box"},ye={class:"title font-bold"};function Ve(e,a,f,_,w,y){const d=o("info-icon"),m=o("el-input");return s(),l("div",ke,[i("div",we,[i("h2",ye,n(e.$t("hailuo.name.prompt")),1),t(d,{content:e.$t("hailuo.description.prompt"),class:"info"},null,8,["content"])]),t(m,{modelValue:e.prompt,"onUpdate:modelValue":a[0]||(a[0]=r=>e.prompt=r),rows:3,type:"textarea",class:"prompt",placeholder:e.$t("hailuo.placeholder.prompt"),maxlength:300,"show-word-limit":""},null,8,["modelValue","placeholder"])])}const Ie=k(be,[["render",Ve],["__scopeId","data-v-d54ffa64"]]),Ee=b({name:"PresetPanel",components:{ElButton:I,FontAwesomeIcon:U,PromptInput:Ie,StartImageUrlInput:$e,ModelSelector:de,Consumption:H},emits:["generate"],computed:{config(){return this.$store.state.hailuo?.config},consumption(){return Q(this.config,this.service?.metadata?.price)},service(){return this.$store.state.hailuo?.service}},methods:{onGenerate(){this.$emit("generate")}}}),Se={class:"flex flex-col h-full"},Te={class:"flex-1 overflow-y-auto p-[15px]"},Ce={class:"flex flex-col items-center justify-center px-[15px] pb-[15px]"};function Ue(e,a,f,_,w,y){const d=o("prompt-input"),m=o("model-selector"),r=o("start-image-url-input"),g=o("consumption"),c=o("font-awesome-icon"),$=o("el-button");return s(),l("div",Se,[i("div",Te,[t(d,{class:"mb-4"}),t(m,{class:"mb-4"}),e.config?.model==="minimax-i2v"?(s(),v(r,{key:0,class:"mb-2"})):h("",!0)]),i("div",Ce,[t(g,{value:e.consumption,service:e.service},null,8,["value","service"]),e.config?.video_url!==void 0||e.config?.custom?(s(),v($,{key:0,type:"primary",class:"btn w-full",round:"",onClick:e.onGenerate},{default:u(()=>[t(c,{icon:"fa-solid fa-magic",class:"mr-2"}),p(" "+n(e.$t("hailuo.button.extend")),1)]),_:1},8,["onClick"])):(s(),v($,{key:1,type:"primary",class:"btn w-full",round:"",onClick:e.onGenerate},{default:u(()=>[t(c,{icon:"fa-solid fa-magic",class:"mr-2"}),p(" "+n(e.$t("hailuo.button.generate")),1)]),_:1},8,["onClick"]))])])}const Ge=k(Ee,[["render",Ue]]),Ae=b({name:"TaskPreview",components:{ElImage:Z,CopyToClipboard:J,FontAwesomeIcon:U,ElAlert:Y,VideoPlayer:W,ElTooltip:X,ElButton:I},props:{modelValue:{type:Object,required:!0}},computed:{application(){return this.$store.state.hailuo?.application},config(){return this.$store.state.hailuo?.config},video(){return this.modelValue?.response?.data?.[0]}},methods:{onDownload(e){console.debug("on download hailuo video",e),window.open(e,"_blank")}}}),Le={class:"preview"},Pe={class:"left"},Re={class:"main"},je={class:"bot"},De={class:"datetime"},Be={class:"info"},Me={key:0,class:"prompt mt-2"},qe={key:0},Oe={key:1},ze={key:0,class:E({content:!0,failed:!0})},Fe={key:0,class:"mb-4"},Ne={key:1,class:E({operations:!0,"mt-2":!0})},He={key:0,class:"text-[var(--el-text-color-regular)] text-xs mb-2"},Ke={class:"text-[var(--el-text-color-regular)] text-xs mb-0"},Qe={key:1,class:E({content:!0})},Je={class:"text-[var(--el-text-color-regular)] text-xs mb-2"},We={class:"text-[var(--el-text-color-regular)] text-xs mb-2"},Xe={class:"text-[var(--el-text-color-regular)] text-xs mb-0"},Ye={key:2,class:E({content:!0})},Ze={class:"text-[var(--el-text-color-regular)] text-xs mb-0"};function xe(e,a,f,_,w,y){const d=o("el-image"),m=o("video-player"),r=o("el-button"),g=o("el-tooltip"),c=o("font-awesome-icon"),$=o("copy-to-clipboard"),S=o("el-alert");return s(),l("div",Le,[i("div",Pe,[t(d,{src:"https://cdn.acedata.cloud/0qg4gp.png",class:"avatar"})]),i("div",Re,[i("div",je,[p(n(e.$t("hailuo.name.hailuoBot"))+" ",1),i("span",De,n(e.$dayjs.format(""+new Date(parseFloat((e.modelValue?.created_at||"").toString())*1e3))),1)]),i("div",Be,[e.modelValue?.request?.prompt?(s(),l("p",Me,[p(n(e.modelValue?.request?.prompt)+" ",1),e.modelValue?.response?h("",!0):(s(),l("span",qe," - ("+n(e.$t("hailuo.status.pending"))+") ",1)),e.video?.state==="processing"||e.video?.state==="pending"||e.video?.state==="running"?(s(),l("span",Oe," - ("+n(e.$t("hailuo.status.processing"))+") ",1)):h("",!0)])):h("",!0)]),e.modelValue?.response?.success===!0?(s(),l("div",ze,[e.video?.video_url?(s(),l("div",Fe,[t(m,{src:e.video?.video_url},null,8,["src"])])):h("",!0),e.video?(s(),l("div",Ne,[t(g,{class:"box-item",effect:"dark",content:e.$t("hailuo.message.downloadVideo"),placement:"top-start"},{default:u(()=>[e.video?.video_url?(s(),v(r,{key:0,type:"info",size:"small",class:"mb-2",onClick:a[0]||(a[0]=j(ut=>e.onDownload(e.video?.video_url),["stop"]))},{default:u(()=>[p(n(e.$t("hailuo.button.download")),1)]),_:1})):h("",!0)]),_:1},8,["content"])])):h("",!0),t(S,{closable:!1,class:"mt-2 success"},{default:u(()=>[e.modelValue?.request?.model?(s(),l("p",He,[t(c,{icon:"fa-solid fa-hashtag",class:"mr-1"}),p(" "+n(e.$t("hailuo.name.model"))+": "+n(e.modelValue?.request?.model)+" ",1),t($,{content:e.modelValue?.id},null,8,["content"])])):h("",!0),i("p",Ke,[t(c,{icon:"fa-solid fa-magic",class:"mr-1"}),p(" "+n(e.$t("hailuo.name.taskId"))+": "+n(e.modelValue?.id)+" ",1),t($,{content:e.modelValue?.id},null,8,["content"])])]),_:1})])):h("",!0),e.modelValue?.response?.success===!1?(s(),l("div",Qe,[t(S,{closable:!1,class:"failure"},{template:u(()=>[t(c,{icon:"fa-solid fa-exclamation-triangle",class:"mr-1"}),p(" "+n(e.$t("hailuo.name.failure")),1)]),default:u(()=>[i("p",Je,[t(c,{icon:"fa-solid fa-magic",class:"mr-1"}),p(" "+n(e.$t("hailuo.name.taskId"))+": "+n(e.modelValue?.id)+" ",1),t($,{content:e.modelValue?.id},null,8,["content"])]),i("p",We,[t(c,{icon:"fa-solid fa-circle-info",class:"mr-1"}),p(" "+n(e.$t("hailuo.name.failureReason"))+": "+n(e.modelValue?.response?.error?.message)+" ",1),t($,{content:e.modelValue?.response?.error?.message},null,8,["content"])]),i("p",Xe,[t(c,{icon:"fa-solid fa-hashtag",class:"mr-1"}),p(" "+n(e.$t("hailuo.name.traceId"))+": "+n(e.modelValue?.response?.trace_id)+" ",1),t($,{content:e.modelValue?.response?.trace_id},null,8,["content"])])]),_:1})])):h("",!0),e.modelValue?.response?.success===void 0?(s(),l("div",Ye,[t(S,{closable:!1,class:"info"},{template:u(()=>[t(c,{icon:"fa-solid fa-exclamation-triangle",class:"mr-1"}),p(" "+n(e.$t("hailuo.name.failure")),1)]),default:u(()=>[i("p",Ze,[t(c,{icon:"fa-solid fa-magic",class:"mr-1"}),p(" "+n(e.$t("hailuo.name.taskId"))+": "+n(e.modelValue?.id)+" ",1),t($,{content:e.modelValue?.id},null,8,["content"])])]),_:1})])):h("",!0)])])}const et=k(Ae,[["render",xe],["__scopeId","data-v-72acd507"]]),tt=b({name:"RecentPanel",components:{TaskPreview:et,BotPlaceholder:x,NoTasks:K},emits:["reach-top"],data(){return{job:0}},computed:{tasks(){return{...this.$store.state.hailuo?.tasks,items:this.$store.state.hailuo?.tasks?.items?.slice()}}},methods:{onHandleScroll(){const e=this.$refs.panel;console.log("reach-top reach-top reach-top"),e.scrollTop===0&&this.$emit("reach-top")}}}),ot={key:0},st={key:1,class:"tasks w-full h-full overflow-y-auto"},at={key:2,class:"w-full h-full flex items-center justify-center"};function nt(e,a,f,_,w,y){const d=o("bot-placeholder"),m=o("task-preview"),r=o("no-tasks");return s(),l(C,null,[e.tasks?.items===void 0?(s(),l("div",ot,[t(d)])):e.tasks?.items?.length&&e.tasks?.items?.length>0?(s(),l("div",st,[(s(!0),l(C,null,G(e.tasks?.items,g=>(s(),v(m,{key:g.id,"model-value":g},null,8,["model-value"]))),128))])):h("",!0),e.tasks?.items?.length===0?(s(),l("div",at,[t(r)])):h("",!0)],64)}const lt=k(tt,[["render",nt]]),it="https://webhook.acedata.cloud/hailuo",rt=b({name:"HailuoIndex",components:{ConfigPanel:Ge,Layout:ne,RecentPanel:lt},inject:["initialized"],data(){return{task:void 0,job:0,timer:void 0}},computed:{loading(){return this.$store.state.hailuo?.status?.getApplications===M.Request},credential(){return this.$store.state.hailuo.credential},config(){return this.$store.state.hailuo.config},application(){return this.$store.state.hailuo.application},tasks(){return this.$store.state.hailuo.tasks}},watch:{tasks:{handler(e,a){e?.items?.length>a?.items?.length&&console.debug("new tasks detected")},deep:!0},initialized:{async handler(e){e&&(console.debug("layout initialized"),await this.onGetTasks(),await this.onScrollDown(),this.job=setInterval(()=>{this.onGetTasks()},5e3))},immediate:!0}},async mounted(){await this.onGetService()},async unmounted(){clearInterval(this.job)},methods:{async onReachTop(){console.debug("reached top"),await this.onGetTasks({createdAtMax:this.tasks?.items?.[0]?.created_at})},async onGetService(){console.debug("start onGetService"),await this.$store.dispatch("hailuo/getService"),console.debug("end onGetService")},async onGetApplication(){console.debug("start onGetApplication"),await this.$store.dispatch("hailuo/getApplications"),console.debug("end onGetApplication"),await this.onGetTasks()},async onScrollDown(){setTimeout(()=>{const e=document.querySelector(".tasks");e&&(e.scrollTop=e.scrollHeight)},500)},async onGetTasks(e){if(this.loading){console.debug("loading");return}console.debug("start onGetTasks",e);const{limit:a=5,createdAtMin:f,createdAtMax:_}=e||{};console.debug("limit",a,"createdAtMin",f,"createdAtMax",_),await this.$store.dispatch("hailuo/getTasks",{limit:a,createdAtMin:f,createdAtMax:_})},async onGenerate(){const e={...this.config,callback_url:it},a=this.credential?.token;if(!a){console.error("no token specified");return}V.info(this.$t("hailuo.message.startingTask")),D.generate(e,{token:a}).then(()=>{V.success(this.$t("hailuo.message.startTaskSuccess"))}).catch(f=>{f?.response?.data?.error?.code===B?V.error(this.$t("hailuo.message.usedUp")):V.error(this.$t("hailuo.message.startTaskFailed"))}).finally(async()=>{setTimeout(async()=>{await this.onGetTasks(),await this.onScrollDown()},1e3)})}}});function ct(e,a,f,_,w,y){const d=o("config-panel"),m=o("recent-panel"),r=o("layout");return s(),v(r,null,{config:u(()=>[t(d,{onGenerate:e.onGenerate},null,8,["onGenerate"])]),result:u(()=>[t(m,{onReachTop:e.onReachTop},null,8,["onReachTop"])]),_:1})}const Kt=k(rt,[["render",ct]]);export{Kt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as T}from"./index.es-CJbKM0CV.js";import{E as A}from"./index-C5k9PNqL.js";import{E as M}from"./index-CNg43fsi.js";import{d as g,h as k,b as l,t as r,k as t,r as R,j as m,l as s,o as a,ep as O,x as i,F as S,v as C,i as I,eq as j,D as h,er as B,c7 as z,y as $,n as P,es as N,ds as F,df as K,dm as H,dn as D}from"./index-DTe9fRn-.js";import{I as G}from"./InfoIcon-YhCcbV8z.js";import{E as J}from"./index-DkUww0O6.js";import{E as L,a as q}from"./index-DCYB3TDh.js";import{a as Q,E as W}from"./index-CDCMsrCt.js";import{I as X}from"./ImagePreview-D6FjLfQO.js";import{E as Y}from"./index-DxTeNsnH.js";import{E as V}from"./index-H7zk7enZ.js";import{E as Z}from"./index-I4cHhAfY.js";import{C as x,N as ee}from"./NoTasks-ex5PKih3.js";import{a as te}from"./price-C04dX6gR.js";import{C as oe}from"./CopyToClipboard-CU-Bssp8.js";import{s as se}from"./vue-plyr-QZFBikSk.js";import{E as ae}from"./index-DjlWqdX5.js";import{E as ne}from"./index-N-T3RtWX.js";import{E as ie}from"./index-Bp0DDosh.js";import{B as le}from"./BotPlaceholder-C_vy0qCQ.js";import"./use-form-item-CtZlpzU6.js";import"./index-r5W6hzzQ.js";import"./index-DaEk4vUe.js";import"./index-DLyu6NQP.js";import"./typescript-BioIzq79.js";import"./strings-CNF1iAZ6.js";import"./castArray-pZCaAVDW.js";import"./isEqual-CH8EZj5t.js";import"./_initCloneObject-CJq550xS.js";import"./debounce-Bzi7Cd91.js";import"./_baseIteratee-LczmVVcS.js";import"./index-BgQ-O6aa.js";import"./index-DPoEMPUV.js";import"./_baseClone-BDmNDGGK.js";import"./index-MMWJF36O.js";import"./index-DyxxJgEB.js";const re=g({name:"LayoutPika",components:{ElDrawer:M,ElButton:A,FontAwesomeIcon:T},data(){return{drawer:!1}}}),ce={class:"main flex flex-row flex-1"},pe={class:"config w-[300px] h-full overflow-y-scroll border-r border-[var(--el-border-color)]"},de={class:"result h-full p-[15px] flex-1 flex flex-col"};function ue(e,o,c,d,v,b){const p=s("font-awesome-icon"),u=s("el-button"),n=s("el-drawer");return a(),l("div",ce,[r("div",pe,[R(e.$slots,"config",{},void 0,!0)]),r("div",de,[R(e.$slots,"result",{},void 0,!0)]),t(u,{circle:"",class:"menu",onClick:o[0]||(o[0]=y=>e.drawer=!0)},{default:m(()=>[t(p,{icon:"fa-solid fa-magic"})]),_:1}),t(n,{modelValue:e.drawer,"onUpdate:modelValue":o[1]||(o[1]=y=>e.drawer=y),direction:"ltr","with-header":!1,size:"350px"},{default:m(()=>[R(e.$slots,"config",{},void 0,!0)]),_:3},8,["modelValue"])])}const me=k(re,[["render",ue],["__scopeId","data-v-80748529"]]),fe=g({name:"IngredientsSelector",components:{ElSwitch:J,InfoIcon:G},computed:{value:{get(){return this.$store.state.pika?.config?.ingredients},set(e){console.debug("set ingredients",e),e||this.$store.commit("pika/setConfig",{...this.$store.state.pika?.config,ingredients:e,ingredients_mode:void 0,image_url:void 0}),this.$store.commit("pika/setConfig",{...this.$store.state.pika?.config,ingredients:e,model:"2.0"})}}},mounted(){this.value===void 0&&(this.value=O)}}),_e={class:"field"},he={class:"title font-bold"};function $e(e,o,c,d,v,b){const p=s("el-switch"),u=s("info-icon");return a(),l("div",_e,[r("h2",he,i(e.$t("pika.name.ingredients")),1),t(p,{modelValue:e.value,"onUpdate:modelValue":o[0]||(o[0]=n=>e.value=n),class:"value"},null,8,["modelValue"]),t(u,{content:e.$t("pika.description.ingredients"),class:"info"},null,8,["content"])])}const ge=k(fe,[["render",$e],["__scopeId","data-v-17c0af5c"]]),ke=g({name:"EffectSelector",components:{ElSelect:q,ElOption:L},data(){return{}},computed:{options(){return[{value:"Levitate",label:this.$t("pika.style.effect1")},{value:"Decapitate",label:this.$t("pika.style.effect2")},{value:"Eye-pop",label:this.$t("pika.style.effect3")},{value:"Ta-da",label:this.$t("pika.style.effect4")},{value:"Deflate",label:this.$t("pika.style.effect5")},{value:"Crumble",label:this.$t("pika.style.effect6")},{value:"Dissolve",label:this.$t("pika.style.effect7")},{value:"Squish",label:this.$t("pika.style.effect8")},{value:"Inflate",label:this.$t("pika.style.effect9")},{value:"Melt",label:this.$t("pika.style.effect10")},{value:"Cake-ify",label:this.$t("pika.style.effect11")},{value:"Crush",label:this.$t("pika.style.effect12")},{value:"Explode",label:this.$t("pika.style.effect13")}]},value:{get(){return this.$store.state.pika?.config?.effect},set(e){this.$store.commit("pika/setConfig",{...this.$store.state.pika?.config,effect:e})}}}}),ve={class:"field"},be={class:"title font-bold"},ye={class:"float-left"};function we(e,o,c,d,v,b){const p=s("el-option"),u=s("el-select");return a(),l("div",ve,[r("h2",be,i(e.$t("pika.name.effect")),1),t(u,{modelValue:e.value,"onUpdate:modelValue":o[0]||(o[0]=n=>e.value=n),class:"value",placeholder:e.$t("pika.placeholder.select"),clearable:""},{default:m(()=>[(a(!0),l(S,null,C(e.options,n=>(a(),I(p,{key:n.value,label:n.label,value:n.value},{default:m(()=>[r("span",ye,i(n.label),1)]),_:2},1032,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])])}const Ve=k(ke,[["render",we],["__scopeId","data-v-d1c54475"]]),Ie=g({name:"IngredientsModelSelector",components:{ElRadioButton:W,ElRadioGroup:Q},data(){return{options:[{label:this.$t("pika.button.precise"),value:"precise"},{label:this.$t("pika.button.creative"),value:"creative"}]}},computed:{value:{get(){return this.$store.state.pika?.config?.ingredients_mode},set(e){this.$store.commit("pika/setConfig",{...this.$store.state.pika?.config,ingredients_mode:e})}}},mounted(){this.value||(this.value=j)}}),Ee={class:"field"},Se={class:"title font-bold"};function Ce(e,o,c,d,v,b){const p=s("el-radio-button"),u=s("el-radio-group");return a(),l("div",Ee,[r("h2",Se,i(e.$t("pika.name.ingredientsModel")),1),t(u,{modelValue:e.value,"onUpdate:modelValue":o[0]||(o[0]=n=>e.value=n),size:"small",class:"quality"},{default:m(()=>[(a(!0),l(S,null,C(e.options,n=>(a(),I(p,{key:n.value,label:n.value},{default:m(()=>[h(i(n.label),1)]),_:2},1032,["label"]))),128))]),_:1},8,["modelValue"])])}const Te=k(Ie,[["render",Ce],["__scopeId","data-v-b948551f"]]),Ae=g({name:"ModelSelector",components:{ElSelect:q,ElOption:L},props:{modelValue:{type:String,default:void 0}},emits:["update:modelValue"],data(){return{options:[{value:"2.0",label:"2.0"},{value:"1.5",label:"1.5"}]}},computed:{value:{get(){return this.$store.state.pika?.config?.model},set(e){this.$store.commit("pika/setConfig",{...this.$store.state.pika.config,model:e})}}},mounted(){this.value||(this.value=B)}}),Pe={class:"field"},Ue={class:"title font-bold"};function Re(e,o,c,d,v,b){const p=s("el-option"),u=s("el-select");return a(),l("div",Pe,[r("h2",Ue,i(e.$t("pika.name.model")),1),t(u,{modelValue:e.value,"onUpdate:modelValue":o[0]||(o[0]=n=>e.value=n),class:"value",placeholder:e.$t("pika.placeholder.select")},{default:m(()=>[(a(!0),l(S,null,C(e.options,n=>(a(),I(p,{key:n.value,label:n.label,value:n.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])])}const De=k(Ae,[["render",Re],["__scopeId","data-v-7b2e870a"]]),Ge=g({name:"ImageUrlInput",components:{ElUpload:Y,ElButton:A,InfoIcon:G,ImagePreview:X,FontAwesomeIcon:T},data(){return{fileList:[],uploadUrl:z()+"/api/v1/files/"}},computed:{headers(){return{Authorization:`Bearer ${this.$store.state.token.access}`}},urls(){return this.fileList.map(e=>e?.response?.file_url)},value:{get(){return this.$store.state.pika?.config?.image_url},set(){const e=this.urls?.[0];this.$store.commit("pika/setConfig",{...this.$store.state.pika?.config,image_url:e})}}},mounted(){this.value||(this.value=void 0),this.onSetStartImageUrl()},methods:{onExceed(){V.warning(this.$t("pika.message.uploadStartImageExceed"))},onError(){V.error(this.$t("pika.message.uploadStartImageError"))},async onRemove(){V.error(this.$t("pika.message.uploadStartImageError"))},onSetStartImageUrl(){this.$store.commit("pika/setConfig",{...this.$store.state.pika?.config,image_url:this.urls})},async onSuccess(){this.onSetStartImageUrl()}}}),Le={class:"field"},qe={class:"title font-bold"},Me={class:"upload-wrapper"};function Oe(e,o,c,d,v,b){const p=s("image-preview"),u=s("font-awesome-icon"),n=s("el-button"),y=s("el-upload"),_=s("info-icon");return a(),l("div",Le,[r("h2",qe,i(e.$t("pika.name.imageUrl")),1),r("div",Me,[t(y,{"file-list":e.fileList,"onUpdate:fileList":o[0]||(o[0]=f=>e.fileList=f),accept:".png,.jpg,.jpeg,.gif,.bmp,.webp",name:"file",class:"value upload-wrapper",limit:3,multiple:!0,"list-type":"picture",action:e.uploadUrl,"on-exceed":e.onExceed,"on-error":e.onError,"on-remove":e.onRemove,"on-success":e.onSuccess,headers:e.headers},{file:m(({file:f})=>[t(p,{url:f.url||f.response?.file_url,name:f.name,percentage:f.percentage,onRemove:E=>e.fileList.splice(e.fileList.indexOf(f),1)},null,8,["url","name","percentage","onRemove"])]),default:m(()=>[t(n,{size:"small",type:"primary",round:""},{default:m(()=>[t(u,{icon:"fa-solid fa-upload",class:"mr-1"}),h(" "+i(e.$t("pika.button.uploadImageUrl")),1)]),_:1})]),_:1},8,["file-list","action","on-exceed","on-error","on-remove","on-success","headers"])]),t(_,{content:e.$t("pika.description.imageUrl"),class:"info"},null,8,["content"])])}const je=k(Ge,[["render",Oe],["__scopeId","data-v-18cda67a"]]),Be="",ze=g({name:"PromptInput",components:{ElInput:Z,InfoIcon:G},computed:{prompt:{get(){return this.$store.state.pika?.config?.prompt},set(e){console.debug("set prompt",e),this.$store.commit("pika/setConfig",{...this.$store.state.pika?.config,prompt:e})}}},mounted(){this.prompt||(this.prompt=Be)}}),Ne={class:"field"},Fe={class:"box"},Ke={class:"title font-bold"};function He(e,o,c,d,v,b){const p=s("info-icon"),u=s("el-input");return a(),l("div",Ne,[r("div",Fe,[r("h2",Ke,i(e.$t("pika.name.prompt")),1),t(p,{content:e.$t("pika.description.prompt"),class:"info"},null,8,["content"])]),t(u,{modelValue:e.prompt,"onUpdate:modelValue":o[0]||(o[0]=n=>e.prompt=n),rows:3,type:"textarea",class:"prompt",placeholder:e.$t("pika.placeholder.prompt"),maxlength:300,"show-word-limit":""},null,8,["modelValue","placeholder"])])}const Je=k(ze,[["render",He],["__scopeId","data-v-b94e7a3e"]]),Qe=g({name:"PresetPanel",components:{ImageUrlInput:je,ElButton:A,FontAwesomeIcon:T,Consumption:x,PromptInput:Je,IngredientsSelector:ge,IngredientsModelSelector:Te,ModelSelector:De,EffectSelector:Ve},emits:["generate"],computed:{config(){return this.$store.state.pika?.config},consumption(){return te(this.config,this.service?.metadata?.price)},service(){return this.$store.state.pika?.service}},methods:{onGenerate(){this.$emit("generate")}}}),We={class:"flex flex-col h-full"},Xe={class:"flex-1 overflow-y-auto p-[15px]"},Ye={class:"flex flex-col items-center justify-center px-[15px] pb-[15px]"};function Ze(e,o,c,d,v,b){const p=s("prompt-input"),u=s("model-selector"),n=s("ingredients-selector"),y=s("effect-selector"),_=s("image-url-input"),f=s("ingredients-model-selector"),E=s("consumption"),w=s("font-awesome-icon"),U=s("el-button");return a(),l("div",We,[r("div",Xe,[t(p,{class:"mb-4"}),t(u,{class:"mb-4"}),t(n,{class:"mb-4"}),t(y,{class:"mb-4"}),e.config?.ingredients?(a(),I(_,{key:0,class:"mb-4"})):$("",!0),e.config?.ingredients?(a(),I(f,{key:1,class:"mb-4"})):$("",!0)]),r("div",Ye,[t(E,{value:e.consumption,service:e.service},null,8,["value","service"]),t(U,{type:"primary",class:"btn w-full",round:"",onClick:e.onGenerate},{default:m(()=>[t(w,{icon:"fa-solid fa-magic",class:"mr-2"}),h(" "+i(e.$t("pika.button.generate")),1)]),_:1},8,["onClick"])])])}const xe=k(Qe,[["render",Ze]]),et=g({name:"VideoPlayer",components:{VuePlyr:se},props:{modelValue:{type:Object,required:!0}},data(){return{options:{quality:{default:"1080p"}}}}}),tt=["data-poster"],ot=["src"];function st(e,o,c,d,v,b){const p=s("vue-plyr");return a(),l("div",null,[t(p,{options:e.options,class:"video"},{default:m(()=>[r("video",{controls:"",crossorigin:"",playsinline:"","data-poster":e.modelValue?.image_url},[r("source",{size:"1080",src:e.modelValue?.video_url,type:"video/mp4"},null,8,ot)],8,tt)]),_:1},8,["options"])])}const at=k(et,[["render",st],["__scopeId","data-v-fc420430"]]),nt=g({name:"TaskPreview",components:{ElImage:ie,CopyToClipboard:oe,FontAwesomeIcon:T,ElAlert:ne,VideoPlayer:at,ElTooltip:ae,ElButton:A},props:{modelValue:{type:Object,required:!0}},data(){return{}},computed:{application(){return this.$store.state.pika?.application},config(){return this.$store.state.pika?.config},videos(){let e=[];const o=this.modelValue?.request?.action;return Array.isArray(this.modelValue?.response?.data)&&this.modelValue?.response?.data?.forEach(c=>{let d=c;o&&(d.action=o),e.push(d)}),e}},methods:{onDownload(e){console.log("on download"),window.open(e,"_blank")},onReload(e){const o=e.target,c=new URL(o.src),d=c.searchParams.get("retry");if(!d)c.searchParams.set("retry","1");else if(parseInt(d)<2)c.searchParams.set("retry",(parseInt(d)+1).toString());else return;o.src=c.toString()},onOpenVideo(e){window.open(e,"_blank")}}}),it={class:"left"},lt={class:"main"},rt={class:"bot"},ct={class:"datetime"},pt={class:"info"},dt={key:0,class:"prompt mt-2"},ut={key:0},mt={key:1},ft={key:0,class:P({content:!0,failed:!0})},_t={class:"image-wrapper"},ht={key:0,class:P({operations:!0,"mt-2":!0})},$t={key:0,class:"description"},gt={class:"description"},kt={key:1,class:P({content:!0})},vt={class:"description"},bt={class:"description"},yt={class:"description"},wt={key:2,class:P({content:!0})},Vt={class:"description"};function It(e,o,c,d,v,b){const p=s("el-image"),u=s("VideoPlayer"),n=s("el-button"),y=s("el-tooltip"),_=s("font-awesome-icon"),f=s("copy-to-clipboard"),E=s("el-alert");return a(!0),l(S,null,C(e.videos,(w,U)=>(a(),l("div",{key:U,class:"preview"},[r("div",it,[t(p,{src:"https://cdn.acedata.cloud/i80tgn.png",class:"avatar"})]),r("div",lt,[r("div",rt,[h(i(e.$t("pika.name.pikaBot"))+" ",1),r("span",ct,i(e.$dayjs.format(""+new Date(parseFloat((e.modelValue?.created_at||"").toString())*1e3))),1)]),r("div",pt,[e.modelValue?.request?.prompt?(a(),l("p",dt,[h(i(e.modelValue?.request?.prompt)+" ",1),e.modelValue?.response?$("",!0):(a(),l("span",ut," - ("+i(e.$t("pika.status.pending"))+") ",1)),w?.state==="processing"||w?.state==="pending"?(a(),l("span",mt," - ("+i(e.$t("pika.status.processing"))+") ",1)):$("",!0)])):$("",!0)]),e.modelValue?.response?.success===!0?(a(),l("div",ft,[r("div",_t,[t(u,{"model-value":w},null,8,["model-value"])]),w?(a(),l("div",ht,[t(y,{class:"box-item",effect:"dark",content:e.$t("pika.message.downloadVideo"),placement:"top-start"},{default:m(()=>[w?.video_url?(a(),I(n,{key:0,type:"info",size:"small",class:"btn-action",onClick:Lt=>e.onDownload(w?.video_url)},{default:m(()=>[h(i(e.$t("pika.button.download")),1)]),_:2},1032,["onClick"])):$("",!0)]),_:2},1032,["content"])])):$("",!0),t(E,{closable:!1,class:"mt-2 success"},{default:m(()=>[e.modelValue?.request?.model?(a(),l("p",$t,[t(_,{icon:"fa-solid fa-hashtag",class:"mr-1"}),h(" "+i(e.$t("pika.name.model"))+": "+i(e.modelValue?.request?.model),1)])):$("",!0),r("p",gt,[t(_,{icon:"fa-solid fa-magic",class:"mr-1"}),h(" "+i(e.$t("pika.name.taskId"))+": "+i(e.modelValue?.id)+" ",1),t(f,{content:e.modelValue?.id,class:"btn-copy"},null,8,["content"])])]),_:1})])):$("",!0),e.modelValue?.response?.success===!1?(a(),l("div",kt,[t(E,{closable:!1,class:"failure"},{template:m(()=>[t(_,{icon:"fa-solid fa-exclamation-triangle",class:"mr-1"}),h(" "+i(e.$t("pika.name.failure")),1)]),default:m(()=>[r("p",vt,[t(_,{icon:"fa-solid fa-magic",class:"mr-1"}),h(" "+i(e.$t("pika.name.taskId"))+": "+i(e.modelValue?.id)+" ",1),t(f,{content:e.modelValue?.id,class:"btn-copy"},null,8,["content"])]),r("p",bt,[t(_,{icon:"fa-solid fa-circle-info",class:"mr-1"}),h(" "+i(e.$t("pika.name.failureReason"))+": "+i(e.modelValue?.response?.error?.message)+" ",1),t(f,{content:e.modelValue?.response?.error?.message,class:"btn-copy"},null,8,["content"])]),r("p",yt,[t(_,{icon:"fa-solid fa-hashtag",class:"mr-1"}),h(" "+i(e.$t("pika.name.traceId"))+": "+i(e.modelValue?.response?.trace_id)+" ",1),t(f,{content:e.modelValue?.response?.trace_id,class:"btn-copy"},null,8,["content"])])]),_:1})])):$("",!0),!e.modelValue?.response||w?.state==="processing"||w?.state==="pending"?(a(),l("div",wt,[t(E,{closable:!1,class:"info"},{template:m(()=>[t(_,{icon:"fa-solid fa-exclamation-triangle",class:"mr-1"}),h(" "+i(e.$t("pika.name.failure")),1)]),default:m(()=>[r("p",Vt,[t(_,{icon:"fa-solid fa-magic",class:"mr-1"}),h(" "+i(e.$t("pika.name.taskId"))+": "+i(e.modelValue?.id)+" ",1),t(f,{content:e.modelValue?.id,class:"btn-copy"},null,8,["content"])])]),_:1})])):$("",!0)])]))),128)}const Et=k(nt,[["render",It],["__scopeId","data-v-4c2810f1"]]),St=g({name:"RecentPanel",components:{TaskPreview:Et,BotPlaceholder:le,NoTasks:ee},emits:["reach-top"],data(){return{job:0}},computed:{tasks(){return{...this.$store.state.pika?.tasks,items:this.$store.state.pika?.tasks?.items?.slice()}}},methods:{onHandleScroll(){const e=this.$refs.panel;console.log("reach-top reach-top reach-top"),e.scrollTop===0&&this.$emit("reach-top")}}}),Ct={key:0},Tt={key:1,class:"tasks h-full w-full overflow-y-auto"},At={key:2,class:"w-full h-full flex items-center justify-center"};function Pt(e,o,c,d,v,b){const p=s("bot-placeholder"),u=s("task-preview"),n=s("no-tasks");return a(),l(S,null,[e.tasks?.items===void 0?(a(),l("div",Ct,[t(p)])):e.tasks?.items?.length&&e.tasks?.items?.length>0?(a(),l("div",Tt,[(a(!0),l(S,null,C(e.tasks?.items,(y,_)=>(a(),I(u,{key:_,"model-value":y},null,8,["model-value"]))),128))])):$("",!0),e.tasks?.items?.length===0?(a(),l("div",At,[t(n)])):$("",!0)],64)}const Ut=k(St,[["render",Pt]]),Rt="https://webhook.acedata.cloud/pika",Dt=g({name:"PikaIndex",components:{ConfigPanel:xe,Layout:me,RecentPanel:Ut},inject:["initialized"],data(){return{task:void 0,job:0}},computed:{loading(){return this.$store.state.pika?.status?.getApplications===D.Request},service(){return this.$store.state.pika.service},credential(){return this.$store.state.pika.credential},config(){return this.$store.state.pika.config},initializing(){return this.$store.state.pika.status.getApplications===D.Request},needApply(){return this.$store.state.pika.status.getApplications===D.Success&&!this.application},application(){return this.$store.state.pika.application},applications(){return this.$store.state.pika.applications},tasks(){return this.$store.state.pika.tasks}},watch:{tasks:{handler(e,o){e?.items?.length>o?.items?.length&&console.debug("new tasks detected")},deep:!0},initialized:{async handler(e){e&&(console.debug("layout initialized"),await this.onGetTasks(),await this.onScrollDown(),this.job=setInterval(()=>{this.onGetTasks()},5e3))},immediate:!0}},async mounted(){await this.onGetService()},async unmounted(){clearInterval(this.job)},methods:{async onReachTop(){console.debug("reached top"),await this.onGetTasks({createdAtMax:this.tasks?.items?.[0]?.created_at})},async onGetService(){console.debug("start onGetService"),await this.$store.dispatch("pika/getService"),console.debug("end onGetService")},async onGetApplication(){console.debug("start onGetApplication"),await this.$store.dispatch("pika/getApplications"),console.debug("end onGetApplication"),await this.onGetTasks()},onApply(){K.create({application:this.application}).then(({data:e})=>{this.application=e,V.success(this.$t("application.message.applySuccessfully"))}).catch(e=>{e?.response?.data?.code===H&&V.error(this.$t("application.message.alreadyApplied"))})},async onScrollDown(){setTimeout(()=>{const e=document.querySelector(".recent");e&&(e.scrollTop=e.scrollHeight)},500)},async onGetTasks(e){if(this.loading){console.debug("loading");return}console.debug("start onGetTasks",e);const{limit:o=5,createdAtMin:c,createdAtMax:d}=e||{};console.debug("limit",o,"createdAtMin",c,"createdAtMax",d),await this.$store.dispatch("pika/getTasks",{limit:o,createdAtMin:c,createdAtMax:d})},async onGenerate(){const e={...this.config,callback_url:Rt},o=this.credential?.token;if(!o){console.error("no token specified");return}V.info(this.$t("pika.message.startingTask")),N.generate(e,{token:o}).then(()=>{V.success(this.$t("pika.message.startTaskSuccess")),this.$store.commit("pika/setConfig",{config:void 0})}).catch(c=>{c?.response?.data?.error?.code===F?V.error(this.$t("pika.message.usedUp")):V.error(this.$t("pika.message.startTaskFailed"))}).finally(async()=>{setTimeout(async()=>{await this.onGetTasks(),await this.onScrollDown()},1e3)})}}});function Gt(e,o,c,d,v,b){const p=s("config-panel"),u=s("recent-panel"),n=s("layout");return a(),I(n,null,{config:m(()=>[t(p,{onGenerate:e.onGenerate},null,8,["onGenerate"])]),result:m(()=>[t(u,{class:"panel recent",onReachTop:e.onReachTop},null,8,["onReachTop"])]),_:1})}const vo=k(Dt,[["render",Gt],["__scopeId","data-v-bc973743"]]);export{vo as default};
|
|
1
|
+
import{F as T}from"./index.es-EtbmiVQe.js";import{E as A}from"./index-CqTGsJay.js";import{E as M}from"./index-BzyEWvnL.js";import{d as g,h as k,b as l,t as r,k as t,r as R,j as m,l as s,o as a,ep as O,x as i,F as S,v as C,i as I,eq as j,D as h,er as B,c7 as z,y as $,n as P,es as N,ds as F,df as K,dm as H,dn as D}from"./index-C4ssJdBR.js";import{I as G}from"./InfoIcon-BJAJcb5a.js";import{E as J}from"./index-C3GYDBc-.js";import{E as L,a as q}from"./index-C4trafQk.js";import{a as Q,E as W}from"./index-CzVzQVmI.js";import{I as X}from"./ImagePreview-TA4gKfP6.js";import{E as Y}from"./index-gFYmOD1F.js";import{E as V}from"./index-BqAthpig.js";import{E as Z}from"./index-Bth-8JIu.js";import{C as x,N as ee}from"./NoTasks-oiStcbHf.js";import{a as te}from"./price-DPmHeT6D.js";import{C as oe}from"./CopyToClipboard-BCGRlwJJ.js";import{s as se}from"./vue-plyr-QZFBikSk.js";import{E as ae}from"./index-CCjGuukj.js";import{E as ne}from"./index-qJunmjSC.js";import{E as ie}from"./index-tdgIYwZh.js";import{B as le}from"./BotPlaceholder-BWFhmlAo.js";import"./use-form-item-CGJaz8fH.js";import"./index-r5W6hzzQ.js";import"./index-J4WBpiv9.js";import"./index-DEAamx_H.js";import"./typescript-D14l1a1y.js";import"./strings-cAoZbHaH.js";import"./castArray-TlECDAqv.js";import"./isEqual-BqBcCRrU.js";import"./_initCloneObject-djD3gYlF.js";import"./debounce-DTzFlSYq.js";import"./_baseIteratee-35aC5hBk.js";import"./index-BqzuTEwO.js";import"./index-CP_56dlf.js";import"./_baseClone-kJ5Pgx6e.js";import"./index-zBoOr1pW.js";import"./index-B7ak1Sj_.js";const re=g({name:"LayoutPika",components:{ElDrawer:M,ElButton:A,FontAwesomeIcon:T},data(){return{drawer:!1}}}),ce={class:"main flex flex-row flex-1"},pe={class:"config w-[300px] h-full overflow-y-scroll border-r border-[var(--el-border-color)]"},de={class:"result h-full p-[15px] flex-1 flex flex-col"};function ue(e,o,c,d,v,b){const p=s("font-awesome-icon"),u=s("el-button"),n=s("el-drawer");return a(),l("div",ce,[r("div",pe,[R(e.$slots,"config",{},void 0,!0)]),r("div",de,[R(e.$slots,"result",{},void 0,!0)]),t(u,{circle:"",class:"menu",onClick:o[0]||(o[0]=y=>e.drawer=!0)},{default:m(()=>[t(p,{icon:"fa-solid fa-magic"})]),_:1}),t(n,{modelValue:e.drawer,"onUpdate:modelValue":o[1]||(o[1]=y=>e.drawer=y),direction:"ltr","with-header":!1,size:"350px"},{default:m(()=>[R(e.$slots,"config",{},void 0,!0)]),_:3},8,["modelValue"])])}const me=k(re,[["render",ue],["__scopeId","data-v-80748529"]]),fe=g({name:"IngredientsSelector",components:{ElSwitch:J,InfoIcon:G},computed:{value:{get(){return this.$store.state.pika?.config?.ingredients},set(e){console.debug("set ingredients",e),e||this.$store.commit("pika/setConfig",{...this.$store.state.pika?.config,ingredients:e,ingredients_mode:void 0,image_url:void 0}),this.$store.commit("pika/setConfig",{...this.$store.state.pika?.config,ingredients:e,model:"2.0"})}}},mounted(){this.value===void 0&&(this.value=O)}}),_e={class:"field"},he={class:"title font-bold"};function $e(e,o,c,d,v,b){const p=s("el-switch"),u=s("info-icon");return a(),l("div",_e,[r("h2",he,i(e.$t("pika.name.ingredients")),1),t(p,{modelValue:e.value,"onUpdate:modelValue":o[0]||(o[0]=n=>e.value=n),class:"value"},null,8,["modelValue"]),t(u,{content:e.$t("pika.description.ingredients"),class:"info"},null,8,["content"])])}const ge=k(fe,[["render",$e],["__scopeId","data-v-17c0af5c"]]),ke=g({name:"EffectSelector",components:{ElSelect:q,ElOption:L},data(){return{}},computed:{options(){return[{value:"Levitate",label:this.$t("pika.style.effect1")},{value:"Decapitate",label:this.$t("pika.style.effect2")},{value:"Eye-pop",label:this.$t("pika.style.effect3")},{value:"Ta-da",label:this.$t("pika.style.effect4")},{value:"Deflate",label:this.$t("pika.style.effect5")},{value:"Crumble",label:this.$t("pika.style.effect6")},{value:"Dissolve",label:this.$t("pika.style.effect7")},{value:"Squish",label:this.$t("pika.style.effect8")},{value:"Inflate",label:this.$t("pika.style.effect9")},{value:"Melt",label:this.$t("pika.style.effect10")},{value:"Cake-ify",label:this.$t("pika.style.effect11")},{value:"Crush",label:this.$t("pika.style.effect12")},{value:"Explode",label:this.$t("pika.style.effect13")}]},value:{get(){return this.$store.state.pika?.config?.effect},set(e){this.$store.commit("pika/setConfig",{...this.$store.state.pika?.config,effect:e})}}}}),ve={class:"field"},be={class:"title font-bold"},ye={class:"float-left"};function we(e,o,c,d,v,b){const p=s("el-option"),u=s("el-select");return a(),l("div",ve,[r("h2",be,i(e.$t("pika.name.effect")),1),t(u,{modelValue:e.value,"onUpdate:modelValue":o[0]||(o[0]=n=>e.value=n),class:"value",placeholder:e.$t("pika.placeholder.select"),clearable:""},{default:m(()=>[(a(!0),l(S,null,C(e.options,n=>(a(),I(p,{key:n.value,label:n.label,value:n.value},{default:m(()=>[r("span",ye,i(n.label),1)]),_:2},1032,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])])}const Ve=k(ke,[["render",we],["__scopeId","data-v-d1c54475"]]),Ie=g({name:"IngredientsModelSelector",components:{ElRadioButton:W,ElRadioGroup:Q},data(){return{options:[{label:this.$t("pika.button.precise"),value:"precise"},{label:this.$t("pika.button.creative"),value:"creative"}]}},computed:{value:{get(){return this.$store.state.pika?.config?.ingredients_mode},set(e){this.$store.commit("pika/setConfig",{...this.$store.state.pika?.config,ingredients_mode:e})}}},mounted(){this.value||(this.value=j)}}),Ee={class:"field"},Se={class:"title font-bold"};function Ce(e,o,c,d,v,b){const p=s("el-radio-button"),u=s("el-radio-group");return a(),l("div",Ee,[r("h2",Se,i(e.$t("pika.name.ingredientsModel")),1),t(u,{modelValue:e.value,"onUpdate:modelValue":o[0]||(o[0]=n=>e.value=n),size:"small",class:"quality"},{default:m(()=>[(a(!0),l(S,null,C(e.options,n=>(a(),I(p,{key:n.value,label:n.value},{default:m(()=>[h(i(n.label),1)]),_:2},1032,["label"]))),128))]),_:1},8,["modelValue"])])}const Te=k(Ie,[["render",Ce],["__scopeId","data-v-b948551f"]]),Ae=g({name:"ModelSelector",components:{ElSelect:q,ElOption:L},props:{modelValue:{type:String,default:void 0}},emits:["update:modelValue"],data(){return{options:[{value:"2.0",label:"2.0"},{value:"1.5",label:"1.5"}]}},computed:{value:{get(){return this.$store.state.pika?.config?.model},set(e){this.$store.commit("pika/setConfig",{...this.$store.state.pika.config,model:e})}}},mounted(){this.value||(this.value=B)}}),Pe={class:"field"},Ue={class:"title font-bold"};function Re(e,o,c,d,v,b){const p=s("el-option"),u=s("el-select");return a(),l("div",Pe,[r("h2",Ue,i(e.$t("pika.name.model")),1),t(u,{modelValue:e.value,"onUpdate:modelValue":o[0]||(o[0]=n=>e.value=n),class:"value",placeholder:e.$t("pika.placeholder.select")},{default:m(()=>[(a(!0),l(S,null,C(e.options,n=>(a(),I(p,{key:n.value,label:n.label,value:n.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])])}const De=k(Ae,[["render",Re],["__scopeId","data-v-7b2e870a"]]),Ge=g({name:"ImageUrlInput",components:{ElUpload:Y,ElButton:A,InfoIcon:G,ImagePreview:X,FontAwesomeIcon:T},data(){return{fileList:[],uploadUrl:z()+"/api/v1/files/"}},computed:{headers(){return{Authorization:`Bearer ${this.$store.state.token.access}`}},urls(){return this.fileList.map(e=>e?.response?.file_url)},value:{get(){return this.$store.state.pika?.config?.image_url},set(){const e=this.urls?.[0];this.$store.commit("pika/setConfig",{...this.$store.state.pika?.config,image_url:e})}}},mounted(){this.value||(this.value=void 0),this.onSetStartImageUrl()},methods:{onExceed(){V.warning(this.$t("pika.message.uploadStartImageExceed"))},onError(){V.error(this.$t("pika.message.uploadStartImageError"))},async onRemove(){V.error(this.$t("pika.message.uploadStartImageError"))},onSetStartImageUrl(){this.$store.commit("pika/setConfig",{...this.$store.state.pika?.config,image_url:this.urls})},async onSuccess(){this.onSetStartImageUrl()}}}),Le={class:"field"},qe={class:"title font-bold"},Me={class:"upload-wrapper"};function Oe(e,o,c,d,v,b){const p=s("image-preview"),u=s("font-awesome-icon"),n=s("el-button"),y=s("el-upload"),_=s("info-icon");return a(),l("div",Le,[r("h2",qe,i(e.$t("pika.name.imageUrl")),1),r("div",Me,[t(y,{"file-list":e.fileList,"onUpdate:fileList":o[0]||(o[0]=f=>e.fileList=f),accept:".png,.jpg,.jpeg,.gif,.bmp,.webp",name:"file",class:"value upload-wrapper",limit:3,multiple:!0,"list-type":"picture",action:e.uploadUrl,"on-exceed":e.onExceed,"on-error":e.onError,"on-remove":e.onRemove,"on-success":e.onSuccess,headers:e.headers},{file:m(({file:f})=>[t(p,{url:f.url||f.response?.file_url,name:f.name,percentage:f.percentage,onRemove:E=>e.fileList.splice(e.fileList.indexOf(f),1)},null,8,["url","name","percentage","onRemove"])]),default:m(()=>[t(n,{size:"small",type:"primary",round:""},{default:m(()=>[t(u,{icon:"fa-solid fa-upload",class:"mr-1"}),h(" "+i(e.$t("pika.button.uploadImageUrl")),1)]),_:1})]),_:1},8,["file-list","action","on-exceed","on-error","on-remove","on-success","headers"])]),t(_,{content:e.$t("pika.description.imageUrl"),class:"info"},null,8,["content"])])}const je=k(Ge,[["render",Oe],["__scopeId","data-v-18cda67a"]]),Be="",ze=g({name:"PromptInput",components:{ElInput:Z,InfoIcon:G},computed:{prompt:{get(){return this.$store.state.pika?.config?.prompt},set(e){console.debug("set prompt",e),this.$store.commit("pika/setConfig",{...this.$store.state.pika?.config,prompt:e})}}},mounted(){this.prompt||(this.prompt=Be)}}),Ne={class:"field"},Fe={class:"box"},Ke={class:"title font-bold"};function He(e,o,c,d,v,b){const p=s("info-icon"),u=s("el-input");return a(),l("div",Ne,[r("div",Fe,[r("h2",Ke,i(e.$t("pika.name.prompt")),1),t(p,{content:e.$t("pika.description.prompt"),class:"info"},null,8,["content"])]),t(u,{modelValue:e.prompt,"onUpdate:modelValue":o[0]||(o[0]=n=>e.prompt=n),rows:3,type:"textarea",class:"prompt",placeholder:e.$t("pika.placeholder.prompt"),maxlength:300,"show-word-limit":""},null,8,["modelValue","placeholder"])])}const Je=k(ze,[["render",He],["__scopeId","data-v-b94e7a3e"]]),Qe=g({name:"PresetPanel",components:{ImageUrlInput:je,ElButton:A,FontAwesomeIcon:T,Consumption:x,PromptInput:Je,IngredientsSelector:ge,IngredientsModelSelector:Te,ModelSelector:De,EffectSelector:Ve},emits:["generate"],computed:{config(){return this.$store.state.pika?.config},consumption(){return te(this.config,this.service?.metadata?.price)},service(){return this.$store.state.pika?.service}},methods:{onGenerate(){this.$emit("generate")}}}),We={class:"flex flex-col h-full"},Xe={class:"flex-1 overflow-y-auto p-[15px]"},Ye={class:"flex flex-col items-center justify-center px-[15px] pb-[15px]"};function Ze(e,o,c,d,v,b){const p=s("prompt-input"),u=s("model-selector"),n=s("ingredients-selector"),y=s("effect-selector"),_=s("image-url-input"),f=s("ingredients-model-selector"),E=s("consumption"),w=s("font-awesome-icon"),U=s("el-button");return a(),l("div",We,[r("div",Xe,[t(p,{class:"mb-4"}),t(u,{class:"mb-4"}),t(n,{class:"mb-4"}),t(y,{class:"mb-4"}),e.config?.ingredients?(a(),I(_,{key:0,class:"mb-4"})):$("",!0),e.config?.ingredients?(a(),I(f,{key:1,class:"mb-4"})):$("",!0)]),r("div",Ye,[t(E,{value:e.consumption,service:e.service},null,8,["value","service"]),t(U,{type:"primary",class:"btn w-full",round:"",onClick:e.onGenerate},{default:m(()=>[t(w,{icon:"fa-solid fa-magic",class:"mr-2"}),h(" "+i(e.$t("pika.button.generate")),1)]),_:1},8,["onClick"])])])}const xe=k(Qe,[["render",Ze]]),et=g({name:"VideoPlayer",components:{VuePlyr:se},props:{modelValue:{type:Object,required:!0}},data(){return{options:{quality:{default:"1080p"}}}}}),tt=["data-poster"],ot=["src"];function st(e,o,c,d,v,b){const p=s("vue-plyr");return a(),l("div",null,[t(p,{options:e.options,class:"video"},{default:m(()=>[r("video",{controls:"",crossorigin:"",playsinline:"","data-poster":e.modelValue?.image_url},[r("source",{size:"1080",src:e.modelValue?.video_url,type:"video/mp4"},null,8,ot)],8,tt)]),_:1},8,["options"])])}const at=k(et,[["render",st],["__scopeId","data-v-fc420430"]]),nt=g({name:"TaskPreview",components:{ElImage:ie,CopyToClipboard:oe,FontAwesomeIcon:T,ElAlert:ne,VideoPlayer:at,ElTooltip:ae,ElButton:A},props:{modelValue:{type:Object,required:!0}},data(){return{}},computed:{application(){return this.$store.state.pika?.application},config(){return this.$store.state.pika?.config},videos(){let e=[];const o=this.modelValue?.request?.action;return Array.isArray(this.modelValue?.response?.data)&&this.modelValue?.response?.data?.forEach(c=>{let d=c;o&&(d.action=o),e.push(d)}),e}},methods:{onDownload(e){console.log("on download"),window.open(e,"_blank")},onReload(e){const o=e.target,c=new URL(o.src),d=c.searchParams.get("retry");if(!d)c.searchParams.set("retry","1");else if(parseInt(d)<2)c.searchParams.set("retry",(parseInt(d)+1).toString());else return;o.src=c.toString()},onOpenVideo(e){window.open(e,"_blank")}}}),it={class:"left"},lt={class:"main"},rt={class:"bot"},ct={class:"datetime"},pt={class:"info"},dt={key:0,class:"prompt mt-2"},ut={key:0},mt={key:1},ft={key:0,class:P({content:!0,failed:!0})},_t={class:"image-wrapper"},ht={key:0,class:P({operations:!0,"mt-2":!0})},$t={key:0,class:"description"},gt={class:"description"},kt={key:1,class:P({content:!0})},vt={class:"description"},bt={class:"description"},yt={class:"description"},wt={key:2,class:P({content:!0})},Vt={class:"description"};function It(e,o,c,d,v,b){const p=s("el-image"),u=s("VideoPlayer"),n=s("el-button"),y=s("el-tooltip"),_=s("font-awesome-icon"),f=s("copy-to-clipboard"),E=s("el-alert");return a(!0),l(S,null,C(e.videos,(w,U)=>(a(),l("div",{key:U,class:"preview"},[r("div",it,[t(p,{src:"https://cdn.acedata.cloud/i80tgn.png",class:"avatar"})]),r("div",lt,[r("div",rt,[h(i(e.$t("pika.name.pikaBot"))+" ",1),r("span",ct,i(e.$dayjs.format(""+new Date(parseFloat((e.modelValue?.created_at||"").toString())*1e3))),1)]),r("div",pt,[e.modelValue?.request?.prompt?(a(),l("p",dt,[h(i(e.modelValue?.request?.prompt)+" ",1),e.modelValue?.response?$("",!0):(a(),l("span",ut," - ("+i(e.$t("pika.status.pending"))+") ",1)),w?.state==="processing"||w?.state==="pending"?(a(),l("span",mt," - ("+i(e.$t("pika.status.processing"))+") ",1)):$("",!0)])):$("",!0)]),e.modelValue?.response?.success===!0?(a(),l("div",ft,[r("div",_t,[t(u,{"model-value":w},null,8,["model-value"])]),w?(a(),l("div",ht,[t(y,{class:"box-item",effect:"dark",content:e.$t("pika.message.downloadVideo"),placement:"top-start"},{default:m(()=>[w?.video_url?(a(),I(n,{key:0,type:"info",size:"small",class:"btn-action",onClick:Lt=>e.onDownload(w?.video_url)},{default:m(()=>[h(i(e.$t("pika.button.download")),1)]),_:2},1032,["onClick"])):$("",!0)]),_:2},1032,["content"])])):$("",!0),t(E,{closable:!1,class:"mt-2 success"},{default:m(()=>[e.modelValue?.request?.model?(a(),l("p",$t,[t(_,{icon:"fa-solid fa-hashtag",class:"mr-1"}),h(" "+i(e.$t("pika.name.model"))+": "+i(e.modelValue?.request?.model),1)])):$("",!0),r("p",gt,[t(_,{icon:"fa-solid fa-magic",class:"mr-1"}),h(" "+i(e.$t("pika.name.taskId"))+": "+i(e.modelValue?.id)+" ",1),t(f,{content:e.modelValue?.id,class:"btn-copy"},null,8,["content"])])]),_:1})])):$("",!0),e.modelValue?.response?.success===!1?(a(),l("div",kt,[t(E,{closable:!1,class:"failure"},{template:m(()=>[t(_,{icon:"fa-solid fa-exclamation-triangle",class:"mr-1"}),h(" "+i(e.$t("pika.name.failure")),1)]),default:m(()=>[r("p",vt,[t(_,{icon:"fa-solid fa-magic",class:"mr-1"}),h(" "+i(e.$t("pika.name.taskId"))+": "+i(e.modelValue?.id)+" ",1),t(f,{content:e.modelValue?.id,class:"btn-copy"},null,8,["content"])]),r("p",bt,[t(_,{icon:"fa-solid fa-circle-info",class:"mr-1"}),h(" "+i(e.$t("pika.name.failureReason"))+": "+i(e.modelValue?.response?.error?.message)+" ",1),t(f,{content:e.modelValue?.response?.error?.message,class:"btn-copy"},null,8,["content"])]),r("p",yt,[t(_,{icon:"fa-solid fa-hashtag",class:"mr-1"}),h(" "+i(e.$t("pika.name.traceId"))+": "+i(e.modelValue?.response?.trace_id)+" ",1),t(f,{content:e.modelValue?.response?.trace_id,class:"btn-copy"},null,8,["content"])])]),_:1})])):$("",!0),!e.modelValue?.response||w?.state==="processing"||w?.state==="pending"?(a(),l("div",wt,[t(E,{closable:!1,class:"info"},{template:m(()=>[t(_,{icon:"fa-solid fa-exclamation-triangle",class:"mr-1"}),h(" "+i(e.$t("pika.name.failure")),1)]),default:m(()=>[r("p",Vt,[t(_,{icon:"fa-solid fa-magic",class:"mr-1"}),h(" "+i(e.$t("pika.name.taskId"))+": "+i(e.modelValue?.id)+" ",1),t(f,{content:e.modelValue?.id,class:"btn-copy"},null,8,["content"])])]),_:1})])):$("",!0)])]))),128)}const Et=k(nt,[["render",It],["__scopeId","data-v-4c2810f1"]]),St=g({name:"RecentPanel",components:{TaskPreview:Et,BotPlaceholder:le,NoTasks:ee},emits:["reach-top"],data(){return{job:0}},computed:{tasks(){return{...this.$store.state.pika?.tasks,items:this.$store.state.pika?.tasks?.items?.slice()}}},methods:{onHandleScroll(){const e=this.$refs.panel;console.log("reach-top reach-top reach-top"),e.scrollTop===0&&this.$emit("reach-top")}}}),Ct={key:0},Tt={key:1,class:"tasks h-full w-full overflow-y-auto"},At={key:2,class:"w-full h-full flex items-center justify-center"};function Pt(e,o,c,d,v,b){const p=s("bot-placeholder"),u=s("task-preview"),n=s("no-tasks");return a(),l(S,null,[e.tasks?.items===void 0?(a(),l("div",Ct,[t(p)])):e.tasks?.items?.length&&e.tasks?.items?.length>0?(a(),l("div",Tt,[(a(!0),l(S,null,C(e.tasks?.items,(y,_)=>(a(),I(u,{key:_,"model-value":y},null,8,["model-value"]))),128))])):$("",!0),e.tasks?.items?.length===0?(a(),l("div",At,[t(n)])):$("",!0)],64)}const Ut=k(St,[["render",Pt]]),Rt="https://webhook.acedata.cloud/pika",Dt=g({name:"PikaIndex",components:{ConfigPanel:xe,Layout:me,RecentPanel:Ut},inject:["initialized"],data(){return{task:void 0,job:0}},computed:{loading(){return this.$store.state.pika?.status?.getApplications===D.Request},service(){return this.$store.state.pika.service},credential(){return this.$store.state.pika.credential},config(){return this.$store.state.pika.config},initializing(){return this.$store.state.pika.status.getApplications===D.Request},needApply(){return this.$store.state.pika.status.getApplications===D.Success&&!this.application},application(){return this.$store.state.pika.application},applications(){return this.$store.state.pika.applications},tasks(){return this.$store.state.pika.tasks}},watch:{tasks:{handler(e,o){e?.items?.length>o?.items?.length&&console.debug("new tasks detected")},deep:!0},initialized:{async handler(e){e&&(console.debug("layout initialized"),await this.onGetTasks(),await this.onScrollDown(),this.job=setInterval(()=>{this.onGetTasks()},5e3))},immediate:!0}},async mounted(){await this.onGetService()},async unmounted(){clearInterval(this.job)},methods:{async onReachTop(){console.debug("reached top"),await this.onGetTasks({createdAtMax:this.tasks?.items?.[0]?.created_at})},async onGetService(){console.debug("start onGetService"),await this.$store.dispatch("pika/getService"),console.debug("end onGetService")},async onGetApplication(){console.debug("start onGetApplication"),await this.$store.dispatch("pika/getApplications"),console.debug("end onGetApplication"),await this.onGetTasks()},onApply(){K.create({application:this.application}).then(({data:e})=>{this.application=e,V.success(this.$t("application.message.applySuccessfully"))}).catch(e=>{e?.response?.data?.code===H&&V.error(this.$t("application.message.alreadyApplied"))})},async onScrollDown(){setTimeout(()=>{const e=document.querySelector(".recent");e&&(e.scrollTop=e.scrollHeight)},500)},async onGetTasks(e){if(this.loading){console.debug("loading");return}console.debug("start onGetTasks",e);const{limit:o=5,createdAtMin:c,createdAtMax:d}=e||{};console.debug("limit",o,"createdAtMin",c,"createdAtMax",d),await this.$store.dispatch("pika/getTasks",{limit:o,createdAtMin:c,createdAtMax:d})},async onGenerate(){const e={...this.config,callback_url:Rt},o=this.credential?.token;if(!o){console.error("no token specified");return}V.info(this.$t("pika.message.startingTask")),N.generate(e,{token:o}).then(()=>{V.success(this.$t("pika.message.startTaskSuccess")),this.$store.commit("pika/setConfig",{config:void 0})}).catch(c=>{c?.response?.data?.error?.code===F?V.error(this.$t("pika.message.usedUp")):V.error(this.$t("pika.message.startTaskFailed"))}).finally(async()=>{setTimeout(async()=>{await this.onGetTasks(),await this.onScrollDown()},1e3)})}}});function Gt(e,o,c,d,v,b){const p=s("config-panel"),u=s("recent-panel"),n=s("layout");return a(),I(n,null,{config:m(()=>[t(p,{onGenerate:e.onGenerate},null,8,["onGenerate"])]),result:m(()=>[t(u,{class:"panel recent",onReachTop:e.onReachTop},null,8,["onReachTop"])]),_:1})}const vo=k(Dt,[["render",Gt],["__scopeId","data-v-bc973743"]]);export{vo as default};
|