@acedatacloud/nexior 3.313.6 → 3.313.7
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/{ApiCodeButton-wdJVNGlF.js → ApiCodeButton-JTMQJL6h.js} +1 -1
- package/dist/assets/{AskUserQuestionCard-CPMIoCEq.js → AskUserQuestionCard-LEGkdGvb.js} +1 -1
- package/dist/assets/{Auth-CrYVk-fw.js → Auth-EMgKZQvf.js} +1 -1
- package/dist/assets/{Bare-SwDEDdYo.js → Bare-CCVUrVim.js} +1 -1
- package/dist/assets/{BotPlaceholder-DXOCEyrD.js → BotPlaceholder-Bh_kiVYK.js} +1 -1
- package/dist/assets/{BottomFooter-DMhSZZ5F.js → BottomFooter-CWPc0HDI.js} +1 -1
- package/dist/assets/{Callback-DqW1WC59.js → Callback-Cq9viPHr.js} +1 -1
- package/dist/assets/{CodeSnippet-Bgz-DfUk.js → CodeSnippet-DPmXkgq0.js} +1 -1
- package/dist/assets/{Console-CyPSzij1.js → Console-CukH2cvG.js} +1 -1
- package/dist/assets/{Consumption-l2q-1FXc.js → Consumption-Bo_pmB_S.js} +1 -1
- package/dist/assets/{Conversation-CWXgLXq-.js → Conversation-sXKeEy1P.js} +1 -1
- package/dist/assets/{CopyToClipboard-BqsCWkad.js → CopyToClipboard-B8J4icuV.js} +1 -1
- package/dist/assets/{Detail-RKa-bzSh.js → Detail-hmt5xVyE.js} +2 -2
- package/dist/assets/{Extra-cADQCoYn.js → Extra-1PmbhTvp.js} +1 -1
- package/dist/assets/{FilePreview-aEt7lQcH.js → FilePreview-gdmbW2De.js} +1 -1
- package/dist/assets/{Hailuo-1qJ3zPZ7.js → Hailuo-DRRLt5SP.js} +1 -1
- package/dist/assets/{History-xH2_Rls1.js → History-DyBrACGd.js} +1 -1
- package/dist/assets/{ImagePreview-CJknP8Hv.js → ImagePreview-CnqYWZzv.js} +1 -1
- package/dist/assets/{ImageWrapper-ITVnISLW.js → ImageWrapper-BG9vmKX-.js} +1 -1
- package/dist/assets/{Index-DtrNi3Oo.js → Index-0P0TV6Fn.js} +1 -1
- package/dist/assets/{Index-CEA0cne7.js → Index-0TRNOLyj.js} +1 -1
- package/dist/assets/{Index-eEv-lxFx.js → Index-BEElDDLh.js} +1 -1
- package/dist/assets/{Index-DUfcAlJU.js → Index-BEUEJOc5.js} +1 -1
- package/dist/assets/{Index-DLZOjb8i.js → Index-BQ7qIw3q.js} +1 -1
- package/dist/assets/{Index-DPj-rzNq.js → Index-BR4t6uDk.js} +1 -1
- package/dist/assets/{Index-DDbgFJqD.js → Index-BeGE35UR.js} +1 -1
- package/dist/assets/{Index-DE5_bU8c.js → Index-BuJCMons.js} +1 -1
- package/dist/assets/{Index-7RijraA1.js → Index-C9kGu2Bz.js} +1 -1
- package/dist/assets/{Index-DRk0LqEB.js → Index-CHG6ST6I.js} +1 -1
- package/dist/assets/{Index-NJZ1z9yR.js → Index-CNtI6c-9.js} +1 -1
- package/dist/assets/{Index-B6LyiDwt.js → Index-CQ__Y7p8.js} +1 -1
- package/dist/assets/{Index-evP-WJQT.js → Index-CR5QdIKj.js} +1 -1
- package/dist/assets/{Index-Ctd1-wW2.js → Index-CU0hjR5t.js} +1 -1
- package/dist/assets/{Index-EfTdeDsM.js → Index-C_bgXkNs.js} +1 -1
- package/dist/assets/{Index-BJUrKGv1.js → Index-Csch7zSP.js} +1 -1
- package/dist/assets/{Index-DRoCiQM7.js → Index-D-kAItWk.js} +1 -1
- package/dist/assets/{Index-BjgZ2rtX.js → Index-D3mNEi6o.js} +1 -1
- package/dist/assets/{Index-DAVDKz49.js → Index-D8QS1gfU.js} +1 -1
- package/dist/assets/{Index-CbpHzK7d.js → Index-D9Fs0Vax.js} +1 -1
- package/dist/assets/{Index-tb6pr52j.js → Index-DMgRTjtB.js} +1 -1
- package/dist/assets/{Index-BlPbuVgS.js → Index-DWHWD2Qb.js} +1 -1
- package/dist/assets/{Index-VGDgo9D1.js → Index-DderzIWq.js} +1 -1
- package/dist/assets/{Index-sodx48lW.js → Index-ISLYtooY.js} +1 -1
- package/dist/assets/{Index-CC3dSr8o.js → Index-QvPmtLSv.js} +1 -1
- package/dist/assets/{Index-BkEWnUSZ.js → Index-YK5y2LrH.js} +1 -1
- package/dist/assets/{Index-DjvR1W07.js → Index-oZP98HiQ.js} +1 -1
- package/dist/assets/{Index-9j3IItLu.js → Index-v35x0b2I.js} +1 -1
- package/dist/assets/{Invitees-2FOEzQy5.js → Invitees-DnIa9Nq-.js} +1 -1
- package/dist/assets/{List-BI8UbYVQ.js → List-BaWJIinB.js} +1 -1
- package/dist/assets/{List-CxB6tLpw.js → List-C0LZz6Dj.js} +1 -1
- package/dist/assets/{List-BUZnRDOy.js → List-CCd4sRHA.js} +1 -1
- package/dist/assets/{LocalTools-BfsUcnjJ.js → LocalTools-DRJ-frHg.js} +1 -1
- package/dist/assets/{LocalTools-DFf8bGCP.js → LocalTools-eQ_lSuK6.js} +1 -1
- package/dist/assets/{Main-hYLNWrOQ.js → Main-Bv6c2RIj.js} +1 -1
- package/dist/assets/{Model-U1clDTrx.js → Model-DJJCkX_g.js} +1 -1
- package/dist/assets/{Navigator-DhAMHsU6.js → Navigator-CP0yX3Xq.js} +1 -1
- package/dist/assets/{NoTasks-DNcvSM1_.js → NoTasks-CXc3S2PE.js} +1 -1
- package/dist/assets/{NotFound-ZQG_85P0.js → NotFound-P-7WjmbH.js} +1 -1
- package/dist/assets/{Pagination-Bx16Gkpp.js → Pagination-CEMukh4X.js} +1 -1
- package/dist/assets/{Pay-DpoHe9IT.js → Pay-CGSQIIkl.js} +1 -1
- package/dist/assets/{Player-BqWc1f7I.js → Player-BxmM7SHY.js} +1 -1
- package/dist/assets/{PromptTextarea-BDyN-Pcp.js → PromptTextarea-Dtz_bZis.js} +1 -1
- package/dist/assets/{RealtimeCall-CfigmH46.js → RealtimeCall-BuPZh-yD.js} +1 -1
- package/dist/assets/{ScheduledTasks-DtCisGsE.js → ScheduledTasks-CyP9xCnE.js} +1 -1
- package/dist/assets/{Status-Blv98aUK.js → Status-BVSqmWu1.js} +1 -1
- package/dist/assets/{Subscribe-a4D2HGV4.js → Subscribe-Brejxlsn.js} +1 -1
- package/dist/assets/{TabSwitcher-_BvKYt4Y.js → TabSwitcher-DOolc2qt.js} +1 -1
- package/dist/assets/{Tts-Bi7Sygmx.js → Tts-DbhA8LsC.js} +1 -1
- package/dist/assets/{VideoPlayer-DWFeM6Ae.js → VideoPlayer-B4Cx13s0.js} +1 -1
- package/dist/assets/{avatar-DcilHHC0.js → avatar-CWUSLaGu.js} +1 -1
- package/dist/assets/{basic-DT4rhcFG.js → basic-CwXQpb4k.js} +1 -1
- package/dist/assets/{chat-FwpagXNb.js → chat-BszKx9Rl.js} +1 -1
- package/dist/assets/{codingBridge-3mxNA2Ne.js → codingBridge-CW2Y6_6K.js} +1 -1
- package/dist/assets/{codingBridgeNotify-CO6RExx8.js → codingBridgeNotify-CJWmvZO8.js} +2 -2
- package/dist/assets/{collapse-CC1eMbEX.js → collapse-o0Tbh9kY.js} +1 -1
- package/dist/assets/{createTaskActions-DEG8d0iQ.js → createTaskActions-CnU83Auu.js} +1 -1
- package/dist/assets/{date-picker-DFSkI2T1.js → date-picker-CN9KO91T.js} +1 -1
- package/dist/assets/{digitalhuman-BMGdiI6o.js → digitalhuman-7E1xheJV.js} +1 -1
- package/dist/assets/{dropdown-CAZpXPRc.js → dropdown-Y7CGGDP7.js} +1 -1
- package/dist/assets/{esm-DkUEWpS_.js → esm-BWzXt6Ou.js} +1 -1
- package/dist/assets/{esm-BfMHGy7u.js → esm-Bt9q1z0S.js} +2 -2
- package/dist/assets/{esm-DW-wJmO_.js → esm-CtEXAm0V.js} +1 -1
- package/dist/assets/{esm-BIfUgn3I.js → esm-DD8-cTwS.js} +3 -3
- package/dist/assets/{esm-C1LxuXIO.js → esm-DG00bky1.js} +2 -2
- package/dist/assets/esm-DjtGkhYW.js +1 -0
- package/dist/assets/{esm-DnktJVfg.js → esm-DxAsSyO3.js} +1 -1
- package/dist/assets/{fish-Y_kzGFvS.js → fish-DrlkaIeb.js} +1 -1
- package/dist/assets/{flux-CA5IWBhv.js → flux-Dlj2DIiQ.js} +1 -1
- package/dist/assets/{grokvideo-DCBP4tzJ.js → grokvideo-DGcHdbcx.js} +1 -1
- package/dist/assets/{hailuo-CyzFz2VC.js → hailuo-DhNXZ2TZ.js} +1 -1
- package/dist/assets/{headshots-VlPxGaMn.js → headshots-oC3optZL.js} +1 -1
- package/dist/assets/{image-C-7ZJsIi.js → image-CsANLYkn.js} +1 -1
- package/dist/assets/{index-DoCEzMzZ.js → index-BwuZeZD0.js} +3 -3
- package/dist/assets/{index.browser.esm-C6oywPay.js → index.browser.esm-Ez1gppk4.js} +1 -1
- package/dist/assets/{index.es-CDSdB7LL.js → index.es-BAFsTiuS.js} +1 -1
- package/dist/assets/{input-number-Cu05I6kF.js → input-number-CUon16df.js} +1 -1
- package/dist/assets/{kling-DnuZB5hu.js → kling-CQ86zEfa.js} +1 -1
- package/dist/assets/{luma-CQmXmzd_.js → luma-kes842Wg.js} +1 -1
- package/dist/assets/{maestro-CDxrgRFe.js → maestro-b36IQU0R.js} +1 -1
- package/dist/assets/{midjourney-DZKpw_Ce.js → midjourney-nSCpERFA.js} +1 -1
- package/dist/assets/{nanobanana-DOtooCEd.js → nanobanana-DyRRukJO.js} +1 -1
- package/dist/assets/{openaiimage-BB2Zj1xC.js → openaiimage-qe0ObNvW.js} +1 -1
- package/dist/assets/{pagination-BOZzRk5L.js → pagination-rLdABsD2.js} +1 -1
- package/dist/assets/{pika-CnrvZW4v.js → pika-BbJRBWVb.js} +1 -1
- package/dist/assets/{pixverse-g8O_hd4V.js → pixverse-D4vfJUfP.js} +1 -1
- package/dist/assets/{popover-CGL4z7xK.js → popover-BBDHfo1j.js} +1 -1
- package/dist/assets/{producer-BOJwWrFZ.js → producer-DVhQQZmJ.js} +1 -1
- package/dist/assets/{qrart-Du8y9_uU.js → qrart-DO51IZl5.js} +1 -1
- package/dist/assets/{realtime-B90Bu7vN.js → realtime-BwHgUv78.js} +1 -1
- package/dist/assets/{row-Sw1tNXnG.js → row-B5bv9JPh.js} +1 -1
- package/dist/assets/{seedance-PK4TvINI.js → seedance-ByA6Dl5B.js} +1 -1
- package/dist/assets/{seedream-B7TytA2i.js → seedream-WANE2pMG.js} +1 -1
- package/dist/assets/{select-DBWrapm4.js → select-BrRoGuGI.js} +1 -1
- package/dist/assets/{serp-DMC3WlY-.js → serp-CByKa5vO.js} +1 -1
- package/dist/assets/{slider-D2r_O-wh.js → slider-oal-Uh6R.js} +1 -1
- package/dist/assets/{solana-wallets-CWM6oznc.js → solana-wallets-DO0vONgE.js} +2 -2
- package/dist/assets/{solana-wallets-vue-85cmk4rK.js → solana-wallets-vue-3n2BTpZB.js} +1 -1
- package/dist/assets/{sora-B5xlMOfD.js → sora-C1_rv1fQ.js} +1 -1
- package/dist/assets/{suno-BN23GNDF.js → suno-CdPQEHwa.js} +1 -1
- package/dist/assets/{switch-CEDyFSsQ.js → switch-9ZO_9tNo.js} +1 -1
- package/dist/assets/{tabs-B0ZFbaaU.js → tabs-BX6WZxwV.js} +1 -1
- package/dist/assets/{time-picker-Bs0EdzZJ.js → time-picker-DbA1OKAd.js} +1 -1
- package/dist/assets/{upload-r_wNvfRY.js → upload-BD93nwqF.js} +1 -1
- package/dist/assets/{veo-LD0gxYuh.js → veo-Cj3roNm5.js} +1 -1
- package/dist/assets/{wan-EdFiPLOj.js → wan-nEWKREY1.js} +1 -1
- package/dist/assets/{web-D4-kiTPi.js → web-BFQYy686.js} +1 -1
- package/dist/assets/{web-DjAO1tBG.js → web-BlZ7UOmr.js} +1 -1
- package/dist/assets/{web-CuPWazLU.js → web-DEvtRuam.js} +1 -1
- package/dist/assets/{web-BeWHodDj.js → web-DdFQdthJ.js} +1 -1
- package/dist/assets/{web-C60UZDK_.js → web-DtBpX_4I.js} +1 -1
- package/dist/assets/{webextrator-BVT3GBLM.js → webextrator-NpZ0uq0A.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/dist/assets/esm-D1nPa8KW.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Vt as c,Wt as l,Z as u,b as d,dt as f,et as p,k as m,tt as h,ut as g,v as _}from"./vendor-chart-BJCvKk8-.js";import{t as v}from"./button-BydTr5nV.js";import{r as y,t as b}from"./select-DBWrapm4.js";import{t as x}from"./upload-r_wNvfRY.js";import{t as S}from"./tooltip-ivBOvVK_.js";import{t as C}from"./image-C-7ZJsIi.js";import{t as w}from"./alert-C51owb6L.js";import{t as T}from"./drawer-Aw9IMZFK.js";import{_t as E,gt as D}from"./constants-DReNd4Tz.js";import{Bt as ee,Jn as te,Lr as O,O as k,Pr as A,Rt as j,Ut as M,Vt as N,Zt as P,sn as F,zr as I,zt as L}from"./index-DoCEzMzZ.js";import{t as R}from"./index.es-CDSdB7LL.js";import{t as z}from"./CopyToClipboard-BqsCWkad.js";import{t as B}from"./ImagePreview-CJknP8Hv.js";import{n as V}from"./taskDrawerMixin-DEgO_R5H.js";import{t as H}from"./Consumption-l2q-1FXc.js";import{i as U,n as W,t as G}from"./pagination-BOZzRk5L.js";import{t as K}from"./VideoPlayer-DWFeM6Ae.js";import{t as q}from"./ApiCodeButton-wdJVNGlF.js";import{t as J}from"./BotPlaceholder-DXOCEyrD.js";import{t as Y}from"./NoTasks-DNcvSM1_.js";import{t as X}from"./PromptTextarea-BDyN-Pcp.js";var Z=r({name:`LayoutWan`,components:{ElDrawer:T,ElButton:v,FontAwesomeIcon:R},mixins:[V]}),Q={class:`main flex flex-row flex-1`},ne={class:`config w-[320px] flex-none h-full overflow-y-auto bg-[var(--app-sidebar-bg)] border-r border-[var(--app-border-subtle)]`},re={class:`result h-full p-6 flex-1 flex flex-col min-w-0 overflow-x-hidden bg-[var(--app-content-bg)]`};function ie(e,r,i,a,s,c){let l=h(`font-awesome-icon`),d=h(`el-button`),m=h(`el-drawer`);return u(),t(`div`,Q,[n(`div`,ne,[p(e.$slots,`config`,{},void 0,!0)]),n(`div`,re,[p(e.$slots,`result`,{},void 0,!0)]),f(o(d,{circle:``,class:`menu`,onClick:r[0]||=t=>e.drawer=!0},{default:g(()=>[o(l,{icon:`fa-solid fa-magic`})]),_:1},512),[[_,!e.tasksEmpty]]),o(m,{modelValue:e.drawer,"onUpdate:modelValue":r[1]||=t=>e.drawer=t,direction:`ltr`,"with-header":!1,size:`340px`},{default:g(()=>[p(e.$slots,`config`,{},void 0,!0)]),_:3},8,[`modelValue`])])}var ae=k(Z,[[`render`,ie],[`__scopeId`,`data-v-1ffeb6b4`]]),oe=r({name:`ModelSelector`,components:{ElSelect:y,ElOption:b},data(){return{}},computed:{options(){return[{value:`wan2.6-t2v`,label:this.$t(`wan.button.modelT2v`)},{value:`wan2.6-i2v`,label:this.$t(`wan.button.modelI2v`)},{value:`wan2.6-i2v-flash`,label:this.$t(`wan.button.modelI2vFlash`)},{value:`wan2.6-r2v`,label:this.$t(`wan.button.modelR2v`)}]},value:{get(){return this.$store.state.wan?.config?.model},set(e){this.$store.commit(`wan/setConfig`,{...this.$store.state.wan?.config,model:e})}}},mounted(){this.value||=D}}),se={class:`field`},ce={class:`title font-bold`},le={class:`float-left`};function ue(r,i,c,d,f,p){let m=h(`el-option`),_=h(`el-select`);return u(),t(`div`,se,[n(`h2`,ce,l(r.$t(`wan.name.model`)),1),o(_,{modelValue:r.value,"onUpdate:modelValue":i[0]||=e=>r.value=e,class:`value`,placeholder:r.$t(`wan.placeholder.select`),clearable:``},{default:g(()=>[(u(!0),t(s,null,e(r.options,e=>(u(),a(m,{key:e.value,label:e.label,value:e.value},{default:g(()=>[n(`span`,le,l(e.label),1)]),_:2},1032,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])])}var de=k(oe,[[`render`,ue],[`__scopeId`,`data-v-eb090beb`]]),fe=`720p`,pe=r({name:`ResolutionSelector`,components:{ElSelect:y,ElOption:b},computed:{options(){return[{value:`480p`,label:this.$t(`wan.name.resolution480p`)},{value:`720p`,label:this.$t(`wan.name.resolution720p`)},{value:`1080p`,label:this.$t(`wan.name.resolution1080p`)}]},value:{get(){return this.$store.state.wan?.config?.resolution},set(e){this.$store.commit(`wan/setConfig`,{...this.$store.state.wan?.config,resolution:e})}}},mounted(){this.value||=fe}}),me={class:`field`},he={class:`title font-bold`},ge={class:`float-left`};function _e(r,i,c,d,f,p){let m=h(`el-option`),_=h(`el-select`);return u(),t(`div`,me,[n(`h2`,he,l(r.$t(`wan.name.resolution`)),1),o(_,{modelValue:r.value,"onUpdate:modelValue":i[0]||=e=>r.value=e,class:`value`,placeholder:r.$t(`wan.placeholder.select`),clearable:``},{default:g(()=>[(u(!0),t(s,null,e(r.options,e=>(u(),a(m,{key:e.value,label:e.label,value:e.value},{default:g(()=>[n(`span`,ge,l(e.label),1)]),_:2},1032,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])])}var ve=k(pe,[[`render`,_e],[`__scopeId`,`data-v-3e39f44e`]]),ye=5,be=r({name:`DurationSelector`,components:{ElSelect:y,ElOption:b},computed:{options(){return[{value:5,label:this.$t(`wan.name.duration5s`)},{value:10,label:this.$t(`wan.name.duration10s`)},{value:15,label:this.$t(`wan.name.duration15s`)}]},value:{get(){return this.$store.state.wan?.config?.duration},set(e){this.$store.commit(`wan/setConfig`,{...this.$store.state.wan?.config,duration:e})}}},mounted(){this.value||=ye}}),xe={class:`field`},Se={class:`title font-bold`},Ce={class:`float-left`};function we(r,i,c,d,f,p){let m=h(`el-option`),_=h(`el-select`);return u(),t(`div`,xe,[n(`h2`,Se,l(r.$t(`wan.name.duration`)),1),o(_,{modelValue:r.value,"onUpdate:modelValue":i[0]||=e=>r.value=e,class:`value`,placeholder:r.$t(`wan.placeholder.select`),clearable:``},{default:g(()=>[(u(!0),t(s,null,e(r.options,e=>(u(),a(m,{key:e.value,label:e.label,value:e.value},{default:g(()=>[n(`span`,Ce,l(e.label),1)]),_:2},1032,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])])}var Te=k(be,[[`render`,we],[`__scopeId`,`data-v-5f35a2cf`]]),Ee=r({name:`ImageUrlInput`,components:{ElUpload:x,ElButton:v,InfoIcon:U,ImagePreview:B},mixins:[N,L],data(){return{fileList:[],uploadUrl:O()+`/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.wan?.config?.image_url},set(){let e=this.urls?.[0];this.$store.commit(`wan/setConfig`,{...this.$store.state.wan?.config,image_url:e})}}},mounted(){this.value||=void 0,this.onSetImageUrl()},methods:{onExceed(){I.warning(this.$t(`wan.message.uploadImageExceed`))},onError(){I.error(this.$t(`wan.message.uploadImageError`))},async onRemove(){I.error(this.$t(`wan.message.uploadImageError`))},onSetImageUrl(){let e=this.urls?.[0];this.$store.commit(`wan/setConfig`,{...this.$store.state.wan?.config,image_url:e})},async onSuccess(){this.onSetImageUrl()}}}),De={class:`relative`},Oe={class:`flex justify-between`},ke={class:`flex justify-start items-center`},Ae={class:`text-sm font-bold`};function je(e,r,s,c,d,f){let p=h(`info-icon`),_=h(`image-preview`),v=h(`el-button`),y=h(`el-upload`);return u(),t(`div`,De,[n(`div`,Oe,[n(`div`,ke,[n(`span`,Ae,l(e.$t(`wan.name.imageUrl`)),1),o(p,{content:e.$t(`wan.description.imageUrl`),class:`info`},null,8,[`content`])])]),o(y,{"file-list":e.fileList,"onUpdate:fileList":r[0]||=t=>e.fileList=t,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:g(({file:t})=>[t.url&&t.percentage!==void 0?(u(),a(_,{key:0,url:t.url,name:t.name,percentage:t.percentage,onRemove:n=>e.fileList.splice(e.fileList.indexOf(t),1)},null,8,[`url`,`name`,`percentage`,`onRemove`])):m(``,!0)]),default:g(()=>[o(v,{size:`small`,type:`primary`,class:`btn btn-upload`,round:``},{default:g(()=>[i(l(e.$t(`wan.button.uploadImageUrl`)),1)]),_:1})]),_:1},8,[`file-list`,`action`,`on-exceed`,`on-error`,`on-remove`,`on-success`,`headers`])])}var Me=k(Ee,[[`render`,je],[`__scopeId`,`data-v-41a69004`]]),Ne=r({name:`PromptInput`,components:{PromptTextarea:X},computed:{prompt:{get(){return this.$store.state.wan?.config?.prompt},set(e){this.$store.commit(`wan/setConfig`,{...this.$store.state.wan?.config,prompt:e})}}},mounted(){this.prompt||=``}});function Pe(e,t,n,r,i,o){let s=h(`prompt-textarea`);return u(),a(s,{modelValue:e.prompt,"onUpdate:modelValue":t[0]||=t=>e.prompt=t,title:e.$t(`wan.name.prompt`),info:e.$t(`wan.description.prompt`),placeholder:e.$t(`wan.placeholder.prompt`)},null,8,[`modelValue`,`title`,`info`,`placeholder`])}var Fe=r({name:`PresetPanel`,components:{ElButton:v,FontAwesomeIcon:R,PromptInput:k(Ne,[[`render`,Pe]]),ImageUrlInput:Me,ModelSelector:de,ResolutionSelector:ve,DurationSelector:Te,Consumption:H},emits:[`generate`],computed:{config(){return this.$store.state.wan?.config},consumption(){return M(this.config,this.service?.cost)},service(){return this.$store.state.wan?.service},supportsResolution(){let e=this.config?.model;return e===`wan2.6-t2v`||e===`wan2.6-i2v`||e===`wan2.6-i2v-flash`},supportsDuration(){return this.config?.model===`wan2.6-t2v`},supportsImageUrl(){let e=this.config?.model;return e===`wan2.6-i2v`||e===`wan2.6-i2v-flash`}},methods:{onGenerate(){this.$emit(`generate`)}}}),Ie={class:`flex flex-col h-full`},Le={class:`flex-1 overflow-y-auto p-5`},Re={class:`flex flex-col items-center justify-center px-5 pb-5`};function ze(e,r,s,c,d,f){let p=h(`prompt-input`),_=h(`model-selector`),v=h(`resolution-selector`),y=h(`duration-selector`),b=h(`image-url-input`),x=h(`consumption`),S=h(`font-awesome-icon`),C=h(`el-button`);return u(),t(`div`,Ie,[n(`div`,Le,[o(p,{class:`mb-4`}),o(_,{class:`mb-4`}),e.supportsResolution?(u(),a(v,{key:0,class:`mb-4`})):m(``,!0),e.supportsDuration?(u(),a(y,{key:1,class:`mb-4`})):m(``,!0),e.supportsImageUrl?(u(),a(b,{key:2,class:`mb-2`})):m(``,!0)]),n(`div`,Re,[o(x,{value:e.consumption,service:e.service},null,8,[`value`,`service`]),o(C,{type:`primary`,class:`btn w-full`,round:``,onClick:e.onGenerate},{default:g(()=>[o(S,{icon:`fa-solid fa-magic`,class:`mr-2`}),i(` `+l(e.$t(`wan.button.generate`)),1)]),_:1},8,[`onClick`])])])}var Be=k(Fe,[[`render`,ze]]),Ve=r({name:`TaskPreview`,components:{ElImage:C,CopyToClipboard:z,FontAwesomeIcon:R,ElAlert:w,VideoPlayer:K,ElTooltip:S,ElButton:v,ApiCodeButton:q},props:{modelValue:{type:Object,required:!0}},setup(){return{WAN_LOGO:E}},computed:{application(){return this.$store.state.wan?.application},config(){return this.$store.state.wan?.config}},methods:{onDownload(e){console.debug(`on download wan video`,e),window.open(e,`_blank`)}}}),He={class:`preview`},Ue={class:`left`},We={class:`main`},Ge={class:`bot`},Ke={class:`datetime`},qe={class:`info`},Je={key:0,class:`prompt mt-2`},Ye={key:0},Xe={key:1},Ze={key:0,class:c({content:!0,failed:!0})},Qe={key:0,class:`mb-4`},$e={key:1,class:c({operations:!0,"mt-2":!0})},et={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},tt={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},$={key:1,class:`text-[var(--el-text-color-regular)] text-xs mb-0`},nt={key:1,class:c({content:!0})},rt={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},it={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},at={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},ot={class:`text-[var(--el-text-color-regular)] text-xs mb-0`},st={key:2,class:c({content:!0})},ct={class:`text-[var(--el-text-color-regular)] text-xs mb-0`};function lt(e,r,a,s,c,f){let p=h(`el-image`),_=h(`video-player`),v=h(`el-button`),y=h(`el-tooltip`),b=h(`api-code-button`),x=h(`font-awesome-icon`),S=h(`copy-to-clipboard`),C=h(`el-alert`);return u(),t(`div`,He,[n(`div`,Ue,[o(p,{src:e.WAN_LOGO,class:`avatar`},null,8,[`src`])]),n(`div`,We,[n(`div`,Ge,[i(l(e.$t(`wan.name.wanBot`))+` `,1),n(`span`,Ke,l(e.$dayjs.format(``+new Date(parseFloat((e.modelValue?.created_at||``).toString())*1e3))),1)]),n(`div`,qe,[e.modelValue?.request?.prompt?(u(),t(`p`,Je,[i(l(e.modelValue?.request?.prompt)+` `,1),e.modelValue?.response?m(``,!0):(u(),t(`span`,Ye,` - (`+l(e.$t(`wan.status.pending`))+`) `,1)),e.modelValue?.response?.state===`processing`||e.modelValue?.response?.state===`pending`||e.modelValue?.response?.state===`running`?(u(),t(`span`,Xe,` - (`+l(e.$t(`wan.status.processing`))+`) `,1)):m(``,!0)])):m(``,!0)]),e.modelValue?.response?.success===!0?(u(),t(`div`,Ze,[e.modelValue?.response?.video_url?(u(),t(`div`,Qe,[o(_,{src:e.modelValue?.response?.video_url},null,8,[`src`])])):m(``,!0),e.modelValue?.response?.video_url?(u(),t(`div`,$e,[o(y,{class:`box-item`,effect:`dark`,content:e.$t(`wan.message.downloadVideo`),placement:`top-start`},{default:g(()=>[o(v,{type:`info`,size:`small`,class:`mb-2`,onClick:r[0]||=d(t=>e.onDownload(e.modelValue?.response?.video_url),[`stop`])},{default:g(()=>[i(l(e.$t(`wan.button.download`)),1)]),_:1})]),_:1},8,[`content`]),o(b,{path:`/wan/videos`,body:e.modelValue?.request},null,8,[`body`])])):m(``,!0),o(C,{closable:!1,class:`mt-2 success`},{default:g(()=>[e.modelValue?.request?.model?(u(),t(`p`,et,[o(x,{icon:`fa-solid fa-hashtag`,class:`mr-1`}),i(` `+l(e.$t(`wan.name.model`))+`: `+l(e.modelValue?.request?.model)+` `,1),o(S,{content:e.modelValue?.id},null,8,[`content`])])):m(``,!0),n(`p`,tt,[o(x,{icon:`fa-solid fa-magic`,class:`mr-1`}),i(` `+l(e.$t(`wan.name.taskId`))+`: `+l(e.modelValue?.id)+` `,1),o(S,{content:e.modelValue?.id},null,8,[`content`])]),e.modelValue?.elapsed?(u(),t(`p`,$,[o(x,{icon:`fa-solid fa-clock`,class:`mr-1`}),i(` `+l(e.$t(`wan.name.elapsed`))+`: `+l(e.modelValue?.elapsed?.toFixed(2))+`s `,1)])):m(``,!0)]),_:1})])):m(``,!0),e.modelValue?.response?.success===!1?(u(),t(`div`,nt,[o(C,{closable:!1,class:`failure`},{template:g(()=>[o(x,{icon:`fa-solid fa-exclamation-triangle`,class:`mr-1`}),i(` `+l(e.$t(`wan.name.failure`)),1)]),default:g(()=>[n(`p`,rt,[o(x,{icon:`fa-solid fa-magic`,class:`mr-1`}),i(` `+l(e.$t(`wan.name.taskId`))+`: `+l(e.modelValue?.id)+` `,1),o(S,{content:e.modelValue?.id},null,8,[`content`])]),n(`p`,it,[o(x,{icon:`fa-solid fa-circle-info`,class:`mr-1`}),i(` `+l(e.$t(`wan.name.failureReason`))+`: `+l(e.modelValue?.response?.error?.message)+` `,1),o(S,{content:e.modelValue?.response?.error?.message},null,8,[`content`])]),e.modelValue?.elapsed?(u(),t(`p`,at,[o(x,{icon:`fa-solid fa-clock`,class:`mr-1`}),i(` `+l(e.$t(`wan.name.elapsed`))+`: `+l(e.modelValue?.elapsed?.toFixed(2))+`s `,1)])):m(``,!0),n(`p`,ot,[o(x,{icon:`fa-solid fa-hashtag`,class:`mr-1`}),i(` `+l(e.$t(`wan.name.traceId`))+`: `+l(e.modelValue?.response?.trace_id)+` `,1),o(S,{content:e.modelValue?.response?.trace_id},null,8,[`content`])])]),_:1})])):m(``,!0),e.modelValue?.response?.success===void 0?(u(),t(`div`,st,[o(C,{closable:!1,class:`info`},{template:g(()=>[o(x,{icon:`fa-solid fa-exclamation-triangle`,class:`mr-1`}),i(` `+l(e.$t(`wan.name.failure`)),1)]),default:g(()=>[n(`p`,ct,[o(x,{icon:`fa-solid fa-magic`,class:`mr-1`}),i(` `+l(e.$t(`wan.name.taskId`))+`: `+l(e.modelValue?.id)+` `,1),o(S,{content:e.modelValue?.id},null,8,[`content`])])]),_:1})])):m(``,!0)])])}var ut=r({name:`RecentPanel`,components:{TaskPreview:k(Ve,[[`render`,lt],[`__scopeId`,`data-v-916b8970`]]),BotPlaceholder:J,NoTasks:Y,ScrollList:W},props:{loading:{type:Boolean,default:!1}},emits:[`reach-top`],data(){return{job:0}},computed:{tasks(){return{...this.$store.state.wan?.tasks,items:this.$store.state.wan?.tasks?.items?.slice()}}},methods:{getScrollElement(){return this.$refs.scrollList?.getScrollElement?.()}}}),dt={key:0},ft={key:2,class:`w-full h-full flex items-center justify-center`};function pt(n,r,i,c,l,d){let f=h(`bot-placeholder`),p=h(`task-preview`),_=h(`scroll-list`),v=h(`no-tasks`);return u(),t(s,null,[n.tasks?.items===void 0?(u(),t(`div`,dt,[o(f)])):n.tasks?.items?.length&&n.tasks?.items?.length>0?(u(),a(_,{key:1,ref:`scrollList`,class:`tasks w-full h-full overflow-y-auto`,loading:n.loading,onReachTop:r[0]||=e=>n.$emit(`reach-top`)},{default:g(()=>[(u(!0),t(s,null,e(n.tasks?.items,e=>(u(),a(p,{key:e.id,"model-value":e},null,8,[`model-value`]))),128))]),_:1},8,[`loading`])):m(``,!0),n.tasks?.items?.length===0?(u(),t(`div`,ft,[o(v)])):m(``,!0)],64)}var mt=r({name:`WanIndex`,components:{ConfigPanel:Be,Layout:ae,RecentPanel:k(ut,[[`render`,pt]])},mixins:[ee],inject:[`initialized`],data(){return{task:void 0,job:0,timer:void 0,loadingMore:!1,fetchingTasks:!1}},computed:{applicationsLoading(){return this.$store.state.wan?.status?.getApplications===A.Request},tasksLoading(){return this.$store.state.wan?.status?.getTasks===A.Request||this.fetchingTasks},credential(){return this.$store.state.wan.credential},config(){return this.$store.state.wan.config},application(){return this.$store.state.wan.application},tasks(){return this.$store.state.wan.tasks}},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=window.setInterval(()=>{this.onGetTasks()},5e3))},immediate:!0}},async mounted(){await this.onGetService()},async unmounted(){window.clearInterval(this.job)},methods:{async onReachTop(){await G({tasks:this.tasks,getTasks:()=>this.tasks,loading:this.loadingMore,setLoading:e=>this.loadingMore=e,isBlocked:()=>this.tasksLoading||this.applicationsLoading,fetch:e=>this.onGetTasks({createdAtMax:e}),getScrollElement:()=>this.getTasksScrollElement()})},async onGetService(){console.debug(`start onGetService`),await this.$store.dispatch(`wan/getService`),console.debug(`end onGetService`)},async onGetApplication(){console.debug(`start onGetApplication`),await this.$store.dispatch(`wan/getApplications`),console.debug(`end onGetApplication`),await this.onGetTasks()},async onScrollDown(){await this.$nextTick();let e=this.getTasksScrollElement();e&&(e.scrollTop=e.scrollHeight)},async onGetTasks(e){if(this.applicationsLoading||this.fetchingTasks){console.debug(`loading`);return}console.debug(`start onGetTasks`,e);let{limit:t=5,createdAtMin:n,createdAtMax:r}=e||{};console.debug(`limit`,t,`createdAtMin`,n,`createdAtMax`,r),this.fetchingTasks=!0;try{await this.$store.dispatch(`wan/getTasks`,{limit:t,createdAtMin:n,createdAtMax:r})}finally{this.fetchingTasks=!1}},async onGenerate(){if(!j(this.uploadTracker,e=>this.$t(e),e=>I.warning(e)))return;let e={...this.config,async:!0};if(!P())return;let t=this.credential?.token;if(!t){console.error(`no token specified`);return}I.info(this.$t(`wan.message.startingTask`)),te(`wan`,F.generate(e,{token:t})).then(()=>{I.success(this.$t(`wan.message.startTaskSuccess`))}).catch(e=>{(e?.response?.data)?.error?.code===`used_up`?I.error(this.$t(`wan.message.usedUp`)):I.error(this.$t(`wan.message.startTaskFailed`))}).finally(async()=>{setTimeout(async()=>{await this.onGetTasks(),await this.onScrollDown()},1e3)})},getTasksScrollElement(){return this.$refs.recentPanel?.getScrollElement?.()}}});function ht(e,t,n,r,i,s){let c=h(`config-panel`),l=h(`recent-panel`),d=h(`layout`);return u(),a(d,null,{config:g(()=>[o(c,{onGenerate:e.onGenerate},null,8,[`onGenerate`])]),result:g(()=>[o(l,{ref:`recentPanel`,loading:e.loadingMore,onReachTop:e.onReachTop},null,8,[`loading`,`onReachTop`])]),_:1})}var gt=k(mt,[[`render`,ht]]);export{gt as default};
|
|
1
|
+
import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Vt as c,Wt as l,Z as u,b as d,dt as f,et as p,k as m,tt as h,ut as g,v as _}from"./vendor-chart-BJCvKk8-.js";import{t as v}from"./button-BydTr5nV.js";import{r as y,t as b}from"./select-BrRoGuGI.js";import{t as x}from"./upload-BD93nwqF.js";import{t as S}from"./tooltip-ivBOvVK_.js";import{t as C}from"./image-CsANLYkn.js";import{t as w}from"./alert-C51owb6L.js";import{t as T}from"./drawer-Aw9IMZFK.js";import{_t as E,gt as D}from"./constants-DReNd4Tz.js";import{Bt as ee,Jn as te,Lr as O,O as k,Pr as A,Rt as j,Ut as M,Vt as N,Zt as P,sn as F,zr as I,zt as L}from"./index-BwuZeZD0.js";import{t as R}from"./index.es-BAFsTiuS.js";import{t as z}from"./CopyToClipboard-B8J4icuV.js";import{t as B}from"./ImagePreview-CnqYWZzv.js";import{n as V}from"./taskDrawerMixin-DEgO_R5H.js";import{t as H}from"./Consumption-Bo_pmB_S.js";import{i as U,n as W,t as G}from"./pagination-rLdABsD2.js";import{t as K}from"./VideoPlayer-B4Cx13s0.js";import{t as q}from"./ApiCodeButton-JTMQJL6h.js";import{t as J}from"./BotPlaceholder-Bh_kiVYK.js";import{t as Y}from"./NoTasks-CXc3S2PE.js";import{t as X}from"./PromptTextarea-Dtz_bZis.js";var Z=r({name:`LayoutWan`,components:{ElDrawer:T,ElButton:v,FontAwesomeIcon:R},mixins:[V]}),Q={class:`main flex flex-row flex-1`},ne={class:`config w-[320px] flex-none h-full overflow-y-auto bg-[var(--app-sidebar-bg)] border-r border-[var(--app-border-subtle)]`},re={class:`result h-full p-6 flex-1 flex flex-col min-w-0 overflow-x-hidden bg-[var(--app-content-bg)]`};function ie(e,r,i,a,s,c){let l=h(`font-awesome-icon`),d=h(`el-button`),m=h(`el-drawer`);return u(),t(`div`,Q,[n(`div`,ne,[p(e.$slots,`config`,{},void 0,!0)]),n(`div`,re,[p(e.$slots,`result`,{},void 0,!0)]),f(o(d,{circle:``,class:`menu`,onClick:r[0]||=t=>e.drawer=!0},{default:g(()=>[o(l,{icon:`fa-solid fa-magic`})]),_:1},512),[[_,!e.tasksEmpty]]),o(m,{modelValue:e.drawer,"onUpdate:modelValue":r[1]||=t=>e.drawer=t,direction:`ltr`,"with-header":!1,size:`340px`},{default:g(()=>[p(e.$slots,`config`,{},void 0,!0)]),_:3},8,[`modelValue`])])}var ae=k(Z,[[`render`,ie],[`__scopeId`,`data-v-1ffeb6b4`]]),oe=r({name:`ModelSelector`,components:{ElSelect:y,ElOption:b},data(){return{}},computed:{options(){return[{value:`wan2.6-t2v`,label:this.$t(`wan.button.modelT2v`)},{value:`wan2.6-i2v`,label:this.$t(`wan.button.modelI2v`)},{value:`wan2.6-i2v-flash`,label:this.$t(`wan.button.modelI2vFlash`)},{value:`wan2.6-r2v`,label:this.$t(`wan.button.modelR2v`)}]},value:{get(){return this.$store.state.wan?.config?.model},set(e){this.$store.commit(`wan/setConfig`,{...this.$store.state.wan?.config,model:e})}}},mounted(){this.value||=D}}),se={class:`field`},ce={class:`title font-bold`},le={class:`float-left`};function ue(r,i,c,d,f,p){let m=h(`el-option`),_=h(`el-select`);return u(),t(`div`,se,[n(`h2`,ce,l(r.$t(`wan.name.model`)),1),o(_,{modelValue:r.value,"onUpdate:modelValue":i[0]||=e=>r.value=e,class:`value`,placeholder:r.$t(`wan.placeholder.select`),clearable:``},{default:g(()=>[(u(!0),t(s,null,e(r.options,e=>(u(),a(m,{key:e.value,label:e.label,value:e.value},{default:g(()=>[n(`span`,le,l(e.label),1)]),_:2},1032,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])])}var de=k(oe,[[`render`,ue],[`__scopeId`,`data-v-eb090beb`]]),fe=`720p`,pe=r({name:`ResolutionSelector`,components:{ElSelect:y,ElOption:b},computed:{options(){return[{value:`480p`,label:this.$t(`wan.name.resolution480p`)},{value:`720p`,label:this.$t(`wan.name.resolution720p`)},{value:`1080p`,label:this.$t(`wan.name.resolution1080p`)}]},value:{get(){return this.$store.state.wan?.config?.resolution},set(e){this.$store.commit(`wan/setConfig`,{...this.$store.state.wan?.config,resolution:e})}}},mounted(){this.value||=fe}}),me={class:`field`},he={class:`title font-bold`},ge={class:`float-left`};function _e(r,i,c,d,f,p){let m=h(`el-option`),_=h(`el-select`);return u(),t(`div`,me,[n(`h2`,he,l(r.$t(`wan.name.resolution`)),1),o(_,{modelValue:r.value,"onUpdate:modelValue":i[0]||=e=>r.value=e,class:`value`,placeholder:r.$t(`wan.placeholder.select`),clearable:``},{default:g(()=>[(u(!0),t(s,null,e(r.options,e=>(u(),a(m,{key:e.value,label:e.label,value:e.value},{default:g(()=>[n(`span`,ge,l(e.label),1)]),_:2},1032,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])])}var ve=k(pe,[[`render`,_e],[`__scopeId`,`data-v-3e39f44e`]]),ye=5,be=r({name:`DurationSelector`,components:{ElSelect:y,ElOption:b},computed:{options(){return[{value:5,label:this.$t(`wan.name.duration5s`)},{value:10,label:this.$t(`wan.name.duration10s`)},{value:15,label:this.$t(`wan.name.duration15s`)}]},value:{get(){return this.$store.state.wan?.config?.duration},set(e){this.$store.commit(`wan/setConfig`,{...this.$store.state.wan?.config,duration:e})}}},mounted(){this.value||=ye}}),xe={class:`field`},Se={class:`title font-bold`},Ce={class:`float-left`};function we(r,i,c,d,f,p){let m=h(`el-option`),_=h(`el-select`);return u(),t(`div`,xe,[n(`h2`,Se,l(r.$t(`wan.name.duration`)),1),o(_,{modelValue:r.value,"onUpdate:modelValue":i[0]||=e=>r.value=e,class:`value`,placeholder:r.$t(`wan.placeholder.select`),clearable:``},{default:g(()=>[(u(!0),t(s,null,e(r.options,e=>(u(),a(m,{key:e.value,label:e.label,value:e.value},{default:g(()=>[n(`span`,Ce,l(e.label),1)]),_:2},1032,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])])}var Te=k(be,[[`render`,we],[`__scopeId`,`data-v-5f35a2cf`]]),Ee=r({name:`ImageUrlInput`,components:{ElUpload:x,ElButton:v,InfoIcon:U,ImagePreview:B},mixins:[N,L],data(){return{fileList:[],uploadUrl:O()+`/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.wan?.config?.image_url},set(){let e=this.urls?.[0];this.$store.commit(`wan/setConfig`,{...this.$store.state.wan?.config,image_url:e})}}},mounted(){this.value||=void 0,this.onSetImageUrl()},methods:{onExceed(){I.warning(this.$t(`wan.message.uploadImageExceed`))},onError(){I.error(this.$t(`wan.message.uploadImageError`))},async onRemove(){I.error(this.$t(`wan.message.uploadImageError`))},onSetImageUrl(){let e=this.urls?.[0];this.$store.commit(`wan/setConfig`,{...this.$store.state.wan?.config,image_url:e})},async onSuccess(){this.onSetImageUrl()}}}),De={class:`relative`},Oe={class:`flex justify-between`},ke={class:`flex justify-start items-center`},Ae={class:`text-sm font-bold`};function je(e,r,s,c,d,f){let p=h(`info-icon`),_=h(`image-preview`),v=h(`el-button`),y=h(`el-upload`);return u(),t(`div`,De,[n(`div`,Oe,[n(`div`,ke,[n(`span`,Ae,l(e.$t(`wan.name.imageUrl`)),1),o(p,{content:e.$t(`wan.description.imageUrl`),class:`info`},null,8,[`content`])])]),o(y,{"file-list":e.fileList,"onUpdate:fileList":r[0]||=t=>e.fileList=t,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:g(({file:t})=>[t.url&&t.percentage!==void 0?(u(),a(_,{key:0,url:t.url,name:t.name,percentage:t.percentage,onRemove:n=>e.fileList.splice(e.fileList.indexOf(t),1)},null,8,[`url`,`name`,`percentage`,`onRemove`])):m(``,!0)]),default:g(()=>[o(v,{size:`small`,type:`primary`,class:`btn btn-upload`,round:``},{default:g(()=>[i(l(e.$t(`wan.button.uploadImageUrl`)),1)]),_:1})]),_:1},8,[`file-list`,`action`,`on-exceed`,`on-error`,`on-remove`,`on-success`,`headers`])])}var Me=k(Ee,[[`render`,je],[`__scopeId`,`data-v-41a69004`]]),Ne=r({name:`PromptInput`,components:{PromptTextarea:X},computed:{prompt:{get(){return this.$store.state.wan?.config?.prompt},set(e){this.$store.commit(`wan/setConfig`,{...this.$store.state.wan?.config,prompt:e})}}},mounted(){this.prompt||=``}});function Pe(e,t,n,r,i,o){let s=h(`prompt-textarea`);return u(),a(s,{modelValue:e.prompt,"onUpdate:modelValue":t[0]||=t=>e.prompt=t,title:e.$t(`wan.name.prompt`),info:e.$t(`wan.description.prompt`),placeholder:e.$t(`wan.placeholder.prompt`)},null,8,[`modelValue`,`title`,`info`,`placeholder`])}var Fe=r({name:`PresetPanel`,components:{ElButton:v,FontAwesomeIcon:R,PromptInput:k(Ne,[[`render`,Pe]]),ImageUrlInput:Me,ModelSelector:de,ResolutionSelector:ve,DurationSelector:Te,Consumption:H},emits:[`generate`],computed:{config(){return this.$store.state.wan?.config},consumption(){return M(this.config,this.service?.cost)},service(){return this.$store.state.wan?.service},supportsResolution(){let e=this.config?.model;return e===`wan2.6-t2v`||e===`wan2.6-i2v`||e===`wan2.6-i2v-flash`},supportsDuration(){return this.config?.model===`wan2.6-t2v`},supportsImageUrl(){let e=this.config?.model;return e===`wan2.6-i2v`||e===`wan2.6-i2v-flash`}},methods:{onGenerate(){this.$emit(`generate`)}}}),Ie={class:`flex flex-col h-full`},Le={class:`flex-1 overflow-y-auto p-5`},Re={class:`flex flex-col items-center justify-center px-5 pb-5`};function ze(e,r,s,c,d,f){let p=h(`prompt-input`),_=h(`model-selector`),v=h(`resolution-selector`),y=h(`duration-selector`),b=h(`image-url-input`),x=h(`consumption`),S=h(`font-awesome-icon`),C=h(`el-button`);return u(),t(`div`,Ie,[n(`div`,Le,[o(p,{class:`mb-4`}),o(_,{class:`mb-4`}),e.supportsResolution?(u(),a(v,{key:0,class:`mb-4`})):m(``,!0),e.supportsDuration?(u(),a(y,{key:1,class:`mb-4`})):m(``,!0),e.supportsImageUrl?(u(),a(b,{key:2,class:`mb-2`})):m(``,!0)]),n(`div`,Re,[o(x,{value:e.consumption,service:e.service},null,8,[`value`,`service`]),o(C,{type:`primary`,class:`btn w-full`,round:``,onClick:e.onGenerate},{default:g(()=>[o(S,{icon:`fa-solid fa-magic`,class:`mr-2`}),i(` `+l(e.$t(`wan.button.generate`)),1)]),_:1},8,[`onClick`])])])}var Be=k(Fe,[[`render`,ze]]),Ve=r({name:`TaskPreview`,components:{ElImage:C,CopyToClipboard:z,FontAwesomeIcon:R,ElAlert:w,VideoPlayer:K,ElTooltip:S,ElButton:v,ApiCodeButton:q},props:{modelValue:{type:Object,required:!0}},setup(){return{WAN_LOGO:E}},computed:{application(){return this.$store.state.wan?.application},config(){return this.$store.state.wan?.config}},methods:{onDownload(e){console.debug(`on download wan video`,e),window.open(e,`_blank`)}}}),He={class:`preview`},Ue={class:`left`},We={class:`main`},Ge={class:`bot`},Ke={class:`datetime`},qe={class:`info`},Je={key:0,class:`prompt mt-2`},Ye={key:0},Xe={key:1},Ze={key:0,class:c({content:!0,failed:!0})},Qe={key:0,class:`mb-4`},$e={key:1,class:c({operations:!0,"mt-2":!0})},et={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},tt={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},$={key:1,class:`text-[var(--el-text-color-regular)] text-xs mb-0`},nt={key:1,class:c({content:!0})},rt={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},it={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},at={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},ot={class:`text-[var(--el-text-color-regular)] text-xs mb-0`},st={key:2,class:c({content:!0})},ct={class:`text-[var(--el-text-color-regular)] text-xs mb-0`};function lt(e,r,a,s,c,f){let p=h(`el-image`),_=h(`video-player`),v=h(`el-button`),y=h(`el-tooltip`),b=h(`api-code-button`),x=h(`font-awesome-icon`),S=h(`copy-to-clipboard`),C=h(`el-alert`);return u(),t(`div`,He,[n(`div`,Ue,[o(p,{src:e.WAN_LOGO,class:`avatar`},null,8,[`src`])]),n(`div`,We,[n(`div`,Ge,[i(l(e.$t(`wan.name.wanBot`))+` `,1),n(`span`,Ke,l(e.$dayjs.format(``+new Date(parseFloat((e.modelValue?.created_at||``).toString())*1e3))),1)]),n(`div`,qe,[e.modelValue?.request?.prompt?(u(),t(`p`,Je,[i(l(e.modelValue?.request?.prompt)+` `,1),e.modelValue?.response?m(``,!0):(u(),t(`span`,Ye,` - (`+l(e.$t(`wan.status.pending`))+`) `,1)),e.modelValue?.response?.state===`processing`||e.modelValue?.response?.state===`pending`||e.modelValue?.response?.state===`running`?(u(),t(`span`,Xe,` - (`+l(e.$t(`wan.status.processing`))+`) `,1)):m(``,!0)])):m(``,!0)]),e.modelValue?.response?.success===!0?(u(),t(`div`,Ze,[e.modelValue?.response?.video_url?(u(),t(`div`,Qe,[o(_,{src:e.modelValue?.response?.video_url},null,8,[`src`])])):m(``,!0),e.modelValue?.response?.video_url?(u(),t(`div`,$e,[o(y,{class:`box-item`,effect:`dark`,content:e.$t(`wan.message.downloadVideo`),placement:`top-start`},{default:g(()=>[o(v,{type:`info`,size:`small`,class:`mb-2`,onClick:r[0]||=d(t=>e.onDownload(e.modelValue?.response?.video_url),[`stop`])},{default:g(()=>[i(l(e.$t(`wan.button.download`)),1)]),_:1})]),_:1},8,[`content`]),o(b,{path:`/wan/videos`,body:e.modelValue?.request},null,8,[`body`])])):m(``,!0),o(C,{closable:!1,class:`mt-2 success`},{default:g(()=>[e.modelValue?.request?.model?(u(),t(`p`,et,[o(x,{icon:`fa-solid fa-hashtag`,class:`mr-1`}),i(` `+l(e.$t(`wan.name.model`))+`: `+l(e.modelValue?.request?.model)+` `,1),o(S,{content:e.modelValue?.id},null,8,[`content`])])):m(``,!0),n(`p`,tt,[o(x,{icon:`fa-solid fa-magic`,class:`mr-1`}),i(` `+l(e.$t(`wan.name.taskId`))+`: `+l(e.modelValue?.id)+` `,1),o(S,{content:e.modelValue?.id},null,8,[`content`])]),e.modelValue?.elapsed?(u(),t(`p`,$,[o(x,{icon:`fa-solid fa-clock`,class:`mr-1`}),i(` `+l(e.$t(`wan.name.elapsed`))+`: `+l(e.modelValue?.elapsed?.toFixed(2))+`s `,1)])):m(``,!0)]),_:1})])):m(``,!0),e.modelValue?.response?.success===!1?(u(),t(`div`,nt,[o(C,{closable:!1,class:`failure`},{template:g(()=>[o(x,{icon:`fa-solid fa-exclamation-triangle`,class:`mr-1`}),i(` `+l(e.$t(`wan.name.failure`)),1)]),default:g(()=>[n(`p`,rt,[o(x,{icon:`fa-solid fa-magic`,class:`mr-1`}),i(` `+l(e.$t(`wan.name.taskId`))+`: `+l(e.modelValue?.id)+` `,1),o(S,{content:e.modelValue?.id},null,8,[`content`])]),n(`p`,it,[o(x,{icon:`fa-solid fa-circle-info`,class:`mr-1`}),i(` `+l(e.$t(`wan.name.failureReason`))+`: `+l(e.modelValue?.response?.error?.message)+` `,1),o(S,{content:e.modelValue?.response?.error?.message},null,8,[`content`])]),e.modelValue?.elapsed?(u(),t(`p`,at,[o(x,{icon:`fa-solid fa-clock`,class:`mr-1`}),i(` `+l(e.$t(`wan.name.elapsed`))+`: `+l(e.modelValue?.elapsed?.toFixed(2))+`s `,1)])):m(``,!0),n(`p`,ot,[o(x,{icon:`fa-solid fa-hashtag`,class:`mr-1`}),i(` `+l(e.$t(`wan.name.traceId`))+`: `+l(e.modelValue?.response?.trace_id)+` `,1),o(S,{content:e.modelValue?.response?.trace_id},null,8,[`content`])])]),_:1})])):m(``,!0),e.modelValue?.response?.success===void 0?(u(),t(`div`,st,[o(C,{closable:!1,class:`info`},{template:g(()=>[o(x,{icon:`fa-solid fa-exclamation-triangle`,class:`mr-1`}),i(` `+l(e.$t(`wan.name.failure`)),1)]),default:g(()=>[n(`p`,ct,[o(x,{icon:`fa-solid fa-magic`,class:`mr-1`}),i(` `+l(e.$t(`wan.name.taskId`))+`: `+l(e.modelValue?.id)+` `,1),o(S,{content:e.modelValue?.id},null,8,[`content`])])]),_:1})])):m(``,!0)])])}var ut=r({name:`RecentPanel`,components:{TaskPreview:k(Ve,[[`render`,lt],[`__scopeId`,`data-v-916b8970`]]),BotPlaceholder:J,NoTasks:Y,ScrollList:W},props:{loading:{type:Boolean,default:!1}},emits:[`reach-top`],data(){return{job:0}},computed:{tasks(){return{...this.$store.state.wan?.tasks,items:this.$store.state.wan?.tasks?.items?.slice()}}},methods:{getScrollElement(){return this.$refs.scrollList?.getScrollElement?.()}}}),dt={key:0},ft={key:2,class:`w-full h-full flex items-center justify-center`};function pt(n,r,i,c,l,d){let f=h(`bot-placeholder`),p=h(`task-preview`),_=h(`scroll-list`),v=h(`no-tasks`);return u(),t(s,null,[n.tasks?.items===void 0?(u(),t(`div`,dt,[o(f)])):n.tasks?.items?.length&&n.tasks?.items?.length>0?(u(),a(_,{key:1,ref:`scrollList`,class:`tasks w-full h-full overflow-y-auto`,loading:n.loading,onReachTop:r[0]||=e=>n.$emit(`reach-top`)},{default:g(()=>[(u(!0),t(s,null,e(n.tasks?.items,e=>(u(),a(p,{key:e.id,"model-value":e},null,8,[`model-value`]))),128))]),_:1},8,[`loading`])):m(``,!0),n.tasks?.items?.length===0?(u(),t(`div`,ft,[o(v)])):m(``,!0)],64)}var mt=r({name:`WanIndex`,components:{ConfigPanel:Be,Layout:ae,RecentPanel:k(ut,[[`render`,pt]])},mixins:[ee],inject:[`initialized`],data(){return{task:void 0,job:0,timer:void 0,loadingMore:!1,fetchingTasks:!1}},computed:{applicationsLoading(){return this.$store.state.wan?.status?.getApplications===A.Request},tasksLoading(){return this.$store.state.wan?.status?.getTasks===A.Request||this.fetchingTasks},credential(){return this.$store.state.wan.credential},config(){return this.$store.state.wan.config},application(){return this.$store.state.wan.application},tasks(){return this.$store.state.wan.tasks}},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=window.setInterval(()=>{this.onGetTasks()},5e3))},immediate:!0}},async mounted(){await this.onGetService()},async unmounted(){window.clearInterval(this.job)},methods:{async onReachTop(){await G({tasks:this.tasks,getTasks:()=>this.tasks,loading:this.loadingMore,setLoading:e=>this.loadingMore=e,isBlocked:()=>this.tasksLoading||this.applicationsLoading,fetch:e=>this.onGetTasks({createdAtMax:e}),getScrollElement:()=>this.getTasksScrollElement()})},async onGetService(){console.debug(`start onGetService`),await this.$store.dispatch(`wan/getService`),console.debug(`end onGetService`)},async onGetApplication(){console.debug(`start onGetApplication`),await this.$store.dispatch(`wan/getApplications`),console.debug(`end onGetApplication`),await this.onGetTasks()},async onScrollDown(){await this.$nextTick();let e=this.getTasksScrollElement();e&&(e.scrollTop=e.scrollHeight)},async onGetTasks(e){if(this.applicationsLoading||this.fetchingTasks){console.debug(`loading`);return}console.debug(`start onGetTasks`,e);let{limit:t=5,createdAtMin:n,createdAtMax:r}=e||{};console.debug(`limit`,t,`createdAtMin`,n,`createdAtMax`,r),this.fetchingTasks=!0;try{await this.$store.dispatch(`wan/getTasks`,{limit:t,createdAtMin:n,createdAtMax:r})}finally{this.fetchingTasks=!1}},async onGenerate(){if(!j(this.uploadTracker,e=>this.$t(e),e=>I.warning(e)))return;let e={...this.config,async:!0};if(!P())return;let t=this.credential?.token;if(!t){console.error(`no token specified`);return}I.info(this.$t(`wan.message.startingTask`)),te(`wan`,F.generate(e,{token:t})).then(()=>{I.success(this.$t(`wan.message.startTaskSuccess`))}).catch(e=>{(e?.response?.data)?.error?.code===`used_up`?I.error(this.$t(`wan.message.usedUp`)):I.error(this.$t(`wan.message.startTaskFailed`))}).finally(async()=>{setTimeout(async()=>{await this.onGetTasks(),await this.onScrollDown()},1e3)})},getTasksScrollElement(){return this.$refs.recentPanel?.getScrollElement?.()}}});function ht(e,t,n,r,i,s){let c=h(`config-panel`),l=h(`recent-panel`),d=h(`layout`);return u(),a(d,null,{config:g(()=>[o(c,{onGenerate:e.onGenerate},null,8,[`onGenerate`])]),result:g(()=>[o(l,{ref:`recentPanel`,loading:e.loadingMore,onReachTop:e.onReachTop},null,8,[`loading`,`onReachTop`])]),_:1})}var gt=k(mt,[[`render`,ht]]);export{gt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,b as u,dt as d,et as f,k as p,nt as m,tt as h,ut as g,v as _}from"./vendor-chart-BJCvKk8-.js";import{t as v}from"./button-BydTr5nV.js";import{B as y,I as b,X as x,Z as S,nt as C}from"./use-deprecated-B-NFNg3W.js";import{r as w,t as T}from"./select-DBWrapm4.js";import{n as E,t as D}from"./tabs-B0ZFbaaU.js";import{t as O}from"./upload-r_wNvfRY.js";import{t as k}from"./tooltip-ivBOvVK_.js";import{t as A}from"./image-C-7ZJsIi.js";import{t as j}from"./avatar-Chg0rxNt.js";import{n as M,r as N}from"./radio-3Hz7h3DR.js";import{n as ee,t as P}from"./collapse-CC1eMbEX.js";import{t as F}from"./drawer-Aw9IMZFK.js";import{n as I,r as te,t as ne}from"./dropdown-CAZpXPRc.js";import{t as L}from"./input-number-Cu05I6kF.js";import{n as re,t as ie}from"./skeleton-BwNBivMN.js";import{t as ae}from"./slider-D2r_O-wh.js";import{t as oe}from"./switch-CEDyFSsQ.js";import{Vn as R}from"./constants-DReNd4Tz.js";import{Bt as z,Jn as B,Kr as V,Lr as H,O as U,Pr as W,Rt as G,Ut as K,Wn as q,Zt as se,mn as J,zr as Y,zt as ce}from"./index-DoCEzMzZ.js";import{t as X}from"./index.es-CDSdB7LL.js";import{n as le}from"./taskDrawerMixin-DEgO_R5H.js";import{t as ue}from"./Consumption-l2q-1FXc.js";import{i as Z,n as de,r as fe,t as pe}from"./pagination-BOZzRk5L.js";import{t as me}from"./NoTasks-DNcvSM1_.js";import{t as he}from"./PromptTextarea-BDyN-Pcp.js";import{n as ge,r as Q,t as _e}from"./Player-BqWc1f7I.js";var ve=r({name:`LayoutProducer`,components:{ElDrawer:F,ElButton:v,FontAwesomeIcon:X},mixins:[le],data(){return{preview:!1}},computed:{}}),ye={class:`main flex flex-row flex-1`},be={class:`config w-[320px] flex-none h-full overflow-y-auto bg-[var(--app-sidebar-bg)] border-r border-[var(--app-border-subtle)]`},xe={class:`result h-full flex flex-col flex-1 min-w-0 overflow-x-hidden bg-[var(--app-content-bg)]`},Se={class:`preview h-full w-[300px] flex flex-col`};function Ce(e,r,i,a,s,c){let u=h(`font-awesome-icon`),p=h(`el-button`),m=h(`el-drawer`);return l(),t(`div`,ye,[n(`div`,be,[f(e.$slots,`config`,{},void 0,!0)]),n(`div`,xe,[f(e.$slots,`result`,{},void 0,!0)]),n(`div`,Se,[f(e.$slots,`preview`,{},void 0,!0)]),d(o(p,{circle:``,class:`menu`,onClick:r[0]||=t=>e.drawer=!0},{default:g(()=>[o(u,{icon:`fa-solid fa-magic`})]),_:1},512),[[_,!e.tasksEmpty]]),o(m,{modelValue:e.drawer,"onUpdate:modelValue":r[1]||=t=>e.drawer=t,direction:`ltr`,"with-header":!1,size:`340px`,class:`drawer`},{default:g(()=>[f(e.$slots,`config`,{},void 0,!0)]),_:3},8,[`modelValue`])])}var we=U(ve,[[`render`,Ce],[`__scopeId`,`data-v-cc984c6f`]]),Te=r({name:`TypeSelector`,components:{ElSelect:w,ElOption:T,ElSwitch:oe,InfoIcon:Z},data(){return{options:[{label:`FUZZ-2.0 Pro`,value:`FUZZ-2.0 Pro`,desc:this.$t(`producer.model.fuzz20proDesc`)},{label:`FUZZ-2.0`,value:`FUZZ-2.0`,desc:this.$t(`producer.model.fuzz20desc`)},{label:`FUZZ-2.0 Raw`,value:`FUZZ-2.0 Raw`,desc:this.$t(`producer.model.fuzz20rawDesc`)},{label:`FUZZ-1.1 Pro`,value:`FUZZ-1.1 Pro`,desc:this.$t(`producer.model.fuzz11proDesc`)},{label:`FUZZ-1.1`,value:`FUZZ-1.1`,desc:this.$t(`producer.model.fuzz11desc`)},{label:`FUZZ-1.0 Pro`,value:`FUZZ-1.0 Pro`,desc:this.$t(`producer.model.fuzz10proDesc`)},{label:`FUZZ-1.0`,value:`FUZZ-1.0`,desc:this.$t(`producer.model.fuzz10desc`)},{label:`FUZZ-0.8`,value:`FUZZ-0.8`,desc:this.$t(`producer.model.fuzz08desc`)}]}},computed:{custom:{get(){return this.$store.state.producer?.config?.custom||!1},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,custom:e})}},instrumental:{get(){return this.$store.state.producer?.config?.instrumental||!1},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,instrumental:e})}},model:{get(){return this.$store.state.producer?.config?.model},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,model:e})}}},mounted(){this.model||=R}}),Ee={class:`mb-3`},De={class:`flex items-center mb-1`},Oe={class:`text-sm font-bold`},ke={class:`model-option`},Ae={class:`model-option-name`},je={class:`model-option-desc`},Me={key:0,class:`flex items-center justify-between mb-3`},Ne={class:`flex items-center`},Pe={class:`text-sm font-bold`};function Fe(r,i,u,d,f,m){let _=h(`el-option`),v=h(`el-select`),y=h(`info-icon`),b=h(`el-switch`);return l(),t(`div`,null,[n(`div`,Ee,[n(`div`,De,[n(`span`,Oe,c(r.$t(`producer.name.model`)),1)]),o(v,{modelValue:r.model,"onUpdate:modelValue":i[0]||=e=>r.model=e,class:`w-full model-select`,size:`default`,placeholder:r.$t(`producer.placeholder.select`)},{default:g(()=>[(l(!0),t(s,null,e(r.options,e=>(l(),a(_,{key:e.value,label:e.label,value:e.value},{default:g(()=>[n(`div`,ke,[n(`span`,Ae,c(e.label),1),n(`span`,je,c(e.desc),1)])]),_:2},1032,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])]),r.custom?(l(),t(`div`,Me,[n(`div`,Ne,[n(`span`,Pe,c(r.$t(`producer.name.instrumental`)),1),o(y,{content:r.$t(`producer.description.instrumental`)},null,8,[`content`])]),o(b,{modelValue:r.instrumental,"onUpdate:modelValue":i[1]||=e=>r.instrumental=e},null,8,[`modelValue`])])):p(``,!0)])}var Ie=U(Te,[[`render`,Fe],[`__scopeId`,`data-v-42496b9a`]]),Le=r({name:`UploadAudio`,components:{ElUpload:O,ElButton:v,ElRadioGroup:N,ElRadioButton:M,InfoIcon:Z,FontAwesomeIcon:X},mixins:[ce],emits:[`change`],data(){return{fileList:[],uploadUrl:H()+`/api/v1/files/`,audioPreviewUrl:null,uploading:!1}},computed:{headers(){return{Authorization:`Bearer ${this.$store.state.token.access}`}},credential(){return this.$store.state.producer.credential},config(){return this.$store.state.producer.config},urls(){return this.fileList.map(e=>e?.response?.file_url)},hasUploadedAudio(){let e=this.$store.state.producer?.config?.action;return e===`upload_extend`||e===`upload_cover`},uploadAction:{get(){return this.$store.state.producer?.config?.action||`upload_extend`},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,action:e})}}},watch:{urls:{handler(e){this.$emit(`change`,e)}}},methods:{onExceed(){Y.warning(this.$t(`producer.message.uploadReferencesExceed`))},onError(){this.uploading=!1,Y.error(this.$t(`producer.message.uploadReferencesError`))},async onSuccess(){let e=this.urls?.[0];if(!e){this.uploading=!1;return}this.audioPreviewUrl=e,await this.onGenerateAudioId(e)},async onGenerateAudioId(e){let t={audio_url:e},n=this.credential?.token;if(!n){console.error(`no token specified`),this.uploading=!1;return}this.uploading=!0,Y.info(this.$t(`producer.message.startingUploadAudio`));try{let e=(await J.upload(t,{token:n})).data?.data.audio_id;this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,audio_id:e,action:`upload_extend`}),Y.success(this.$t(`producer.message.startUploadAudioSuccess`))}catch(e){Y.error(e?.response?.data?.error?.message||this.$t(`producer.message.startUploadAudioFailed`))}finally{this.uploading=!1}}}}),Re={class:`relative`},ze={class:`flex justify-between items-center mb-2`},Be={class:`flex justify-start items-center`},Ve={class:`text-sm font-bold`},He={key:0,class:`mb-2`},Ue=[`src`],We={key:1,class:`mt-1`};function Ge(e,r,a,s,u,d){let f=h(`info-icon`),m=h(`font-awesome-icon`),_=h(`el-button`),v=h(`el-upload`),y=h(`el-radio-button`),b=h(`el-radio-group`);return l(),t(`div`,Re,[n(`div`,ze,[n(`div`,Be,[n(`span`,Ve,c(e.$t(`producer.name.referenceAudios`)),1),o(f,{content:e.$t(`producer.description.uploadAudios`)},null,8,[`content`])]),o(v,{"file-list":e.fileList,"onUpdate:fileList":r[0]||=t=>e.fileList=t,name:`file`,limit:1,class:`upload-wrapper inline-upload`,action:e.uploadUrl,accept:`.mp3,.wav,.m4a,audio/*`,"show-file-list":!1,"on-exceed":e.onExceed,"on-error":e.onError,"on-success":e.onSuccess,headers:e.headers},{default:g(()=>[o(_,{round:``,type:`primary`,size:`small`,loading:e.uploading},{default:g(()=>[o(m,{icon:`fa-solid fa-upload`,class:`icon mr-1`}),i(` `+c(e.$t(`producer.button.uploadAudios`)),1)]),_:1},8,[`loading`])]),_:1},8,[`file-list`,`action`,`on-exceed`,`on-error`,`on-success`,`headers`])]),e.audioPreviewUrl?(l(),t(`div`,He,[n(`audio`,{src:e.audioPreviewUrl,controls:``,class:`w-full`},null,8,Ue)])):p(``,!0),e.hasUploadedAudio?(l(),t(`div`,We,[o(b,{modelValue:e.uploadAction,"onUpdate:modelValue":r[1]||=t=>e.uploadAction=t,size:`small`},{default:g(()=>[o(y,{value:`upload_extend`},{default:g(()=>[i(c(e.$t(`producer.button.extend`)),1)]),_:1}),o(y,{value:`upload_cover`},{default:g(()=>[i(c(e.$t(`producer.button.cover_music`)),1)]),_:1})]),_:1},8,[`modelValue`])])):p(``,!0)])}var Ke=U(Le,[[`render`,Ge],[`__scopeId`,`data-v-7fd0580a`]]),qe=r({name:`PromptInput`,components:{PromptTextarea:he},computed:{prompt:{get(){return this.$store.state.producer?.config?.prompt},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,prompt:e})}}},mounted(){this.prompt||=``}});function Je(e,t,n,r,i,o){let s=h(`prompt-textarea`);return l(),a(s,{modelValue:e.prompt,"onUpdate:modelValue":t[0]||=t=>e.prompt=t,title:e.$t(`producer.name.songDescription`),info:e.$t(`producer.description.prompt`),placeholder:e.$t(`producer.placeholder.prompt`),"min-rows":5,"max-rows":14},null,8,[`modelValue`,`title`,`info`,`placeholder`])}var Ye=U(qe,[[`render`,Je]]),Xe=r({name:`LyricInput`,components:{ElInput:V,ElButton:v,FontAwesomeIcon:X,InfoIcon:Z},data(){return{generatingLyrics:!1}},computed:{lyric:{get(){return this.$store.state.producer?.config?.lyric},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,lyric:e})}},config(){return this.$store.state.producer?.config},credential(){return this.$store.state.producer?.credential}},mounted(){this.lyric||=``},methods:{async onGenerateLyrics(){let e=this.credential?.token;if(!e)return;let t=this.config?.style||this.config?.title||`a beautiful song`;this.generatingLyrics=!0,Y.info(this.$t(`producer.message.generatingLyrics`));try{let n=(await J.lyric({prompt:t},{token:e})).data?.data;n?.text&&(this.lyric=n.text,n?.title&&!this.config?.title&&this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,lyric:n.text,title:n.title}),Y.success(this.$t(`producer.message.generateLyricsSuccess`)))}catch{Y.error(this.$t(`producer.message.generateLyricsFailed`))}finally{this.generatingLyrics=!1}}}}),Ze={class:`field`},Qe={class:`flex items-center justify-between mb-1`},$e={class:`flex items-center`},et={class:`text-sm font-bold`};function tt(e,r,s,u,d,f){let m=h(`info-icon`),_=h(`font-awesome-icon`),v=h(`el-button`),y=h(`el-input`);return l(),t(`div`,Ze,[n(`div`,Qe,[n(`div`,$e,[n(`span`,et,c(e.$t(`producer.name.lyrics`)),1),o(m,{content:e.$t(`producer.description.lyrics`)},null,8,[`content`])]),e.config?.action===`extend`?p(``,!0):(l(),a(v,{key:0,size:`small`,loading:e.generatingLyrics,round:``,onClick:e.onGenerateLyrics},{default:g(()=>[e.generatingLyrics?p(``,!0):(l(),a(_,{key:0,icon:`fa-solid fa-wand-magic-sparkles`,class:`mr-1`})),i(` `+c(e.$t(`producer.button.generate_lyrics`)),1)]),_:1},8,[`loading`,`onClick`]))]),e.config?.action===`extend`?(l(),a(y,{key:1,modelValue:e.lyric,"onUpdate:modelValue":r[1]||=t=>e.lyric=t,rows:5,type:`textarea`,class:`lyrics`,placeholder:e.$t(`producer.placeholder.extend.lyrics`)},null,8,[`modelValue`,`placeholder`])):(l(),a(y,{key:0,modelValue:e.lyric,"onUpdate:modelValue":r[0]||=t=>e.lyric=t,rows:5,type:`textarea`,class:`lyrics`,placeholder:e.$t(`producer.placeholder.lyrics`)},null,8,[`modelValue`,`placeholder`]))])}var nt=U(Xe,[[`render`,tt],[`__scopeId`,`data-v-88c6da2b`]]),rt=r({name:`StyleInput`,components:{ElInput:V,InfoIcon:Z},computed:{style:{get(){return this.$store.state.producer?.config?.style},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,style:e})}}}}),it={class:`field`},at={class:`flex items-center justify-between mb-1`},ot={class:`flex items-center`},st={class:`text-sm font-bold`};function ct(e,r,i,a,s,u){let d=h(`info-icon`),f=h(`el-input`);return l(),t(`div`,it,[n(`div`,at,[n(`div`,ot,[n(`span`,st,c(e.$t(`producer.name.style`)),1),o(d,{content:e.$t(`producer.description.style`)},null,8,[`content`])])]),o(f,{modelValue:e.style,"onUpdate:modelValue":r[0]||=t=>e.style=t,rows:2,type:`textarea`,placeholder:e.$t(`producer.placeholder.style`)},null,8,[`modelValue`,`placeholder`])])}var lt=U(rt,[[`render`,ct]]),ut=r({name:`TitleInput`,components:{ElInput:V,InfoIcon:Z},computed:{title:{get(){return this.$store.state.producer?.config?.title},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,title:e})}}}}),dt={class:`field`},ft={class:`flex items-center mb-1`},pt={class:`text-sm font-bold`};function mt(e,r,i,a,s,u){let d=h(`info-icon`),f=h(`el-input`);return l(),t(`div`,dt,[n(`div`,ft,[n(`span`,pt,c(e.$t(`producer.name.title`)),1),o(d,{content:e.$t(`producer.description.title`)},null,8,[`content`])]),o(f,{modelValue:e.title,"onUpdate:modelValue":r[0]||=t=>e.title=t,placeholder:e.$t(`producer.placeholder.title`)},null,8,[`modelValue`,`placeholder`])])}var ht=U(ut,[[`render`,mt]]),gt=r({name:`ExtendFromInput`,components:{ElImage:A,ElIcon:C,ElInputNumber:L,VideoPlay:S,VideoPause:x},data(){return{}},computed:{audio(){return this.$store.state.producer?.config?.audio},value:{get(){return this.$store.state.producer?.config?.continue_at},set(e){console.debug(`set continue_at`,e),this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,continue_at:e?parseInt(e):void 0})}}},mounted(){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:Q,onPlay(e){this.$store.dispatch(`producer/setAudio`,{...this.$store.state.producer.audio,...e,state:`playing`}),console.log(`on play`)},onPause(e){this.$store.dispatch(`producer/setAudio`,{...this.$store.state.producer.audio,...e,state:`paused`}),console.log(`on pause`)},onClick(e){this.$store.state?.producer?.audio?.id!==e.id&&this.onPlay({...e,progress:0})}}}),_t={class:`field`},vt={class:`box`},yt={class:`title font-bold`},bt={class:`input-wrapper`},xt={class:`task`},St={class:`left`},Ct={key:2,class:`duration`},wt={class:`info`},Tt={class:`title`},Et={class:`style`};function Dt(e,r,i,a,s,u){let f=h(`el-input-number`),_=h(`el-image`),v=h(`video-pause`),y=h(`el-icon`),b=h(`video-play`),x=m(`loading`);return l(),t(`div`,_t,[n(`div`,vt,[n(`h2`,yt,c(e.$t(`producer.name.extend`)),1),n(`div`,bt,[o(f,{modelValue:e.value,"onUpdate:modelValue":r[0]||=t=>e.value=t,class:`value`,min:0,max:e.audio?.duration,controls:!1,placeholder:e.$t(`producer.placeholder.extend.continue_at`),onChange:e.handleChange},null,8,[`modelValue`,`max`,`placeholder`,`onChange`])])]),n(`div`,xt,[e.audio?(l(),t(`div`,{key:0,class:`audio`,onClick:r[3]||=t=>e.onClick(e.audio)},[d((l(),t(`div`,St,[o(_,{src:e.audio?.image_url,class:`cover`,fit:`cover`},null,8,[`src`]),e.audio?.audio_url&&e.$store.state?.producer?.audio?.id===e.audio.id&&e.$store.state?.producer?.audio?.state===`playing`?(l(),t(`div`,{key:0,class:`overlay`,onClick:r[1]||=t=>e.onPause(e.audio)},[o(y,null,{default:g(()=>[o(v)]),_:1})])):p(``,!0),e.audio?.audio_url&&(e.$store.state?.producer?.audio?.id!==e.audio.id||e.$store.state?.producer?.audio?.id===e.audio.id&&e.$store.state?.producer?.audio?.state===`paused`)?(l(),t(`div`,{key:1,class:`overlay`,onClick:r[2]||=t=>e.onPlay(e.audio)},[o(y,null,{default:g(()=>[o(b)]),_:1})])):p(``,!0),e.audio?.duration?(l(),t(`div`,Ct,c(e.useFormatDuring(e.audio?.duration)),1)):p(``,!0)])),[[x,!e.audio?.audio_url]]),n(`div`,wt,[n(`h2`,Tt,c(e.audio?.title),1),n(`p`,Et,c(e.audio?.style),1)])])):p(``,!0)])])}var Ot=U(gt,[[`render`,Dt],[`__scopeId`,`data-v-26d43480`]]),kt=r({name:`CoverFromInput`,components:{ElImage:A,ElIcon:C,VideoPlay:S,VideoPause:x},data(){return{}},computed:{audio(){return this.$store.state.producer?.config?.audio},value:{get(){return this.$store.state.producer?.config?.continue_at},set(e){console.debug(`set continue_at`,e),this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,continue_at:e?parseInt(e):void 0})}}},mounted(){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:Q,onPlay(e){this.$store.dispatch(`producer/setAudio`,{...this.$store.state.producer.audio,...e,state:`playing`}),console.log(`on play`)},onPause(e){this.$store.dispatch(`producer/setAudio`,{...this.$store.state.producer.audio,...e,state:`paused`}),console.log(`on pause`)},onClick(e){this.$store.state?.producer?.audio?.id!==e.id&&this.onPlay({...e,progress:0})}}}),At={class:`field`},jt={class:`box`},Mt={class:`title font-bold`},Nt={class:`task`},Pt={class:`left`},Ft={key:2,class:`duration`},It={class:`info`},Lt={class:`title`},Rt={class:`style`};function zt(e,r,i,a,s,u){let f=h(`el-image`),_=h(`video-pause`),v=h(`el-icon`),y=h(`video-play`),b=m(`loading`);return l(),t(`div`,At,[n(`div`,jt,[n(`h2`,Mt,c(e.$t(`producer.name.cover`)),1)]),n(`div`,Nt,[e.audio?(l(),t(`div`,{key:0,class:`audio`,onClick:r[2]||=t=>e.onClick(e.audio)},[d((l(),t(`div`,Pt,[o(f,{src:e.audio?.image_url,class:`cover`,fit:`cover`},null,8,[`src`]),e.audio?.audio_url&&e.$store.state?.producer?.audio?.id===e.audio.id&&e.$store.state?.producer?.audio?.state===`playing`?(l(),t(`div`,{key:0,class:`overlay`,onClick:r[0]||=t=>e.onPause(e.audio)},[o(v,null,{default:g(()=>[o(_)]),_:1})])):p(``,!0),e.audio?.audio_url&&(e.$store.state?.producer?.audio?.id!==e.audio.id||e.$store.state?.producer?.audio?.id===e.audio.id&&e.$store.state?.producer?.audio?.state===`paused`)?(l(),t(`div`,{key:1,class:`overlay`,onClick:r[1]||=t=>e.onPlay(e.audio)},[o(v,null,{default:g(()=>[o(y)]),_:1})])):p(``,!0),e.audio?.duration?(l(),t(`div`,Ft,c(e.useFormatDuring(e.audio?.duration)),1)):p(``,!0)])),[[b,!e.audio?.audio_url]]),n(`div`,It,[n(`h2`,Lt,c(e.audio?.title),1),n(`p`,Rt,c(e.audio?.style),1)])])):p(``,!0)])])}var Bt=U(kt,[[`render`,zt],[`__scopeId`,`data-v-d8a8e583`]]),Vt=r({name:`VocalGenderSelector`,components:{ElRadioGroup:N,ElRadioButton:M,InfoIcon:Z},computed:{vocalGender:{get(){return this.$store.state.producer?.config?.vocal_gender||``},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,vocal_gender:e||void 0})}}}}),Ht={class:`mb-2`},Ut={class:`flex items-center mb-1`},Wt={class:`text-sm font-bold`};function Gt(e,r,a,s,u,d){let f=h(`info-icon`),p=h(`el-radio-button`),m=h(`el-radio-group`);return l(),t(`div`,Ht,[n(`div`,Ut,[n(`span`,Wt,c(e.$t(`producer.name.vocalGender`)),1),o(f,{content:e.$t(`producer.description.vocalGender`)},null,8,[`content`])]),o(m,{modelValue:e.vocalGender,"onUpdate:modelValue":r[0]||=t=>e.vocalGender=t},{default:g(()=>[o(p,{value:``},{default:g(()=>[i(c(e.$t(`producer.gender.auto`)),1)]),_:1}),o(p,{value:`f`},{default:g(()=>[i(c(e.$t(`producer.gender.female`)),1)]),_:1}),o(p,{value:`m`},{default:g(()=>[i(c(e.$t(`producer.gender.male`)),1)]),_:1})]),_:1},8,[`modelValue`])])}var Kt=U(Vt,[[`render`,Gt]]),qt=r({name:`AdvancedParams`,components:{ElCollapse:P,ElCollapseItem:ee,ElInput:V,ElSlider:ae,ElInputNumber:L,InfoIcon:Z},data(){return{activeNames:[]}},computed:{config(){return this.$store.state.producer?.config},styleNegative:{get(){return this.$store.state.producer?.config?.style_negative||``},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,style_negative:e||void 0})}},lyricPrompt:{get(){return this.$store.state.producer?.config?.lyric_prompt||``},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,lyric_prompt:e||void 0})}},weirdness:{get(){return this.$store.state.producer?.config?.weirdness??.5},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,weirdness:e})}},soundStrength:{get(){return this.$store.state.producer?.config?.sound_strength??.7},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,sound_strength:e})}},lyricsStrength:{get(){return this.$store.state.producer?.config?.lyrics_strength??.7},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,lyrics_strength:e})}},seed:{get(){return this.$store.state.producer?.config?.seed},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,seed:e})}}},mounted(){let e=this.$store.state.producer?.config;if(!e)return;let t={};typeof e.weirdness==`number`&&e.weirdness>1&&(t.weirdness=e.weirdness/100),typeof e.sound_strength==`number`&&e.sound_strength>1&&(t.sound_strength=e.sound_strength/100),typeof e.lyrics_strength==`number`&&e.lyrics_strength>1&&(t.lyrics_strength=e.lyrics_strength/100),Object.keys(t).length>0&&this.$store.commit(`producer/setConfig`,{...e,...t})}}),Jt={key:0,class:`mb-3`},Yt={class:`flex items-center mb-1`},Xt={class:`text-xs font-bold`},Zt={key:1,class:`mb-3`},Qt={class:`flex items-center mb-1`},$t={class:`text-xs font-bold`},en={class:`mb-3`},tn={class:`flex items-center justify-between mb-1`},nn={class:`flex items-center`},rn={class:`text-xs font-bold`},an={class:`text-xs text-[var(--el-text-color-secondary)]`},on={class:`mb-3`},sn={class:`flex items-center justify-between mb-1`},cn={class:`flex items-center`},ln={class:`text-xs font-bold`},un={class:`text-xs text-[var(--el-text-color-secondary)]`},dn={key:2,class:`mb-3`},fn={class:`flex items-center justify-between mb-1`},pn={class:`flex items-center`},mn={class:`text-xs font-bold`},hn={class:`text-xs text-[var(--el-text-color-secondary)]`},gn={class:`mb-3`},_n={class:`flex items-center mb-1`},vn={class:`text-xs font-bold`};function yn(e,r,i,s,u,d){let f=h(`info-icon`),m=h(`el-input`),_=h(`el-slider`),v=h(`el-input-number`),y=h(`el-collapse-item`),b=h(`el-collapse`);return l(),a(b,{modelValue:e.activeNames,"onUpdate:modelValue":r[6]||=t=>e.activeNames=t,class:`advanced-collapse`},{default:g(()=>[o(y,{title:e.$t(`producer.name.advancedParams`),name:`advanced`},{default:g(()=>[e.config?.custom?(l(),t(`div`,Jt,[n(`div`,Yt,[n(`span`,Xt,c(e.$t(`producer.name.styleNegative`)),1),o(f,{content:e.$t(`producer.description.styleNegative`)},null,8,[`content`])]),o(m,{modelValue:e.styleNegative,"onUpdate:modelValue":r[0]||=t=>e.styleNegative=t,size:`small`,placeholder:e.$t(`producer.placeholder.styleNegative`)},null,8,[`modelValue`,`placeholder`])])):p(``,!0),e.config?.custom&&!e.config?.instrumental?(l(),t(`div`,Zt,[n(`div`,Qt,[n(`span`,$t,c(e.$t(`producer.name.lyricPrompt`)),1),o(f,{content:e.$t(`producer.description.lyricPrompt`)},null,8,[`content`])]),o(m,{modelValue:e.lyricPrompt,"onUpdate:modelValue":r[1]||=t=>e.lyricPrompt=t,size:`small`,placeholder:e.$t(`producer.placeholder.lyricPrompt`)},null,8,[`modelValue`,`placeholder`])])):p(``,!0),n(`div`,en,[n(`div`,tn,[n(`div`,nn,[n(`span`,rn,c(e.$t(`producer.name.weirdness`)),1),o(f,{content:e.$t(`producer.description.weirdness`)},null,8,[`content`])]),n(`span`,an,c(e.weirdness??.5),1)]),o(_,{modelValue:e.weirdness,"onUpdate:modelValue":r[2]||=t=>e.weirdness=t,min:0,max:1,step:.01},null,8,[`modelValue`])]),n(`div`,on,[n(`div`,sn,[n(`div`,cn,[n(`span`,ln,c(e.$t(`producer.name.soundStrength`)),1),o(f,{content:e.$t(`producer.description.soundStrength`)},null,8,[`content`])]),n(`span`,un,c(e.soundStrength??.7),1)]),o(_,{modelValue:e.soundStrength,"onUpdate:modelValue":r[3]||=t=>e.soundStrength=t,min:.2,max:1,step:.01},null,8,[`modelValue`])]),e.config?.custom&&!e.config?.instrumental?(l(),t(`div`,dn,[n(`div`,fn,[n(`div`,pn,[n(`span`,mn,c(e.$t(`producer.name.lyricsStrength`)),1),o(f,{content:e.$t(`producer.description.lyricsStrength`)},null,8,[`content`])]),n(`span`,hn,c(e.lyricsStrength??.7),1)]),o(_,{modelValue:e.lyricsStrength,"onUpdate:modelValue":r[4]||=t=>e.lyricsStrength=t,min:0,max:1,step:.01},null,8,[`modelValue`])])):p(``,!0),n(`div`,gn,[n(`div`,_n,[n(`span`,vn,c(e.$t(`producer.name.seed`)),1),o(f,{content:e.$t(`producer.description.seed`)},null,8,[`content`])]),o(v,{modelValue:e.seed,"onUpdate:modelValue":r[5]||=t=>e.seed=t,min:0,controls:!1,size:`small`,placeholder:e.$t(`producer.placeholder.seed`),class:`w-full`},null,8,[`modelValue`,`placeholder`])])]),_:1},8,[`title`])]),_:1},8,[`modelValue`])}var bn=U(qt,[[`render`,yn],[`__scopeId`,`data-v-f9296888`]]),xn=r({name:`ReplaceSectionInput`,components:{ElInputNumber:L,ElImage:A,InfoIcon:Z},computed:{audio(){return this.$store.state.producer?.config?.audio},replaceSectionStart:{get(){return this.$store.state.producer?.config?.replace_section_start},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,replace_section_start:e})}},replaceSectionEnd:{get(){return this.$store.state.producer?.config?.replace_section_end},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,replace_section_end:e})}}},methods:{onClick(e){this.$store.dispatch(`producer/setAudio`,{...this.$store.state.producer.audio,...e,state:`playing`})}}}),Sn={class:`field`},Cn={class:`flex items-center mb-2`},wn={class:`text-sm font-bold m-0`},Tn={key:0,class:`task mb-2`},En={class:`left relative w-[50px] h-[50px] mr-3 flex-shrink-0`},Dn={class:`info flex-1 min-w-0`},On={class:`text-sm font-bold m-0 truncate`},kn={class:`text-xs text-[var(--el-text-color-secondary)] m-0 truncate`},An={class:`flex gap-2`};function jn(e,r,i,a,s,u){let f=h(`info-icon`),g=h(`el-image`),_=h(`el-input-number`),v=m(`loading`);return l(),t(`div`,Sn,[n(`div`,Cn,[n(`h2`,wn,c(e.$t(`producer.name.replaceSection`)),1),o(f,{content:e.$t(`producer.description.replaceSection`)},null,8,[`content`])]),e.audio?(l(),t(`div`,Tn,[n(`div`,{class:`audio flex items-center`,onClick:r[0]||=t=>e.onClick(e.audio)},[d((l(),t(`div`,En,[o(g,{src:e.audio?.image_url,class:`w-full h-full rounded`,fit:`cover`},null,8,[`src`])])),[[v,!e.audio?.audio_url]]),n(`div`,Dn,[n(`h2`,On,c(e.audio?.title),1),n(`p`,kn,c(e.audio?.style),1)])])])):p(``,!0),n(`div`,An,[o(_,{modelValue:e.replaceSectionStart,"onUpdate:modelValue":r[1]||=t=>e.replaceSectionStart=t,class:`flex-1`,min:0,max:e.audio?.duration,controls:!1,placeholder:e.$t(`producer.placeholder.replaceSectionStart`)},null,8,[`modelValue`,`max`,`placeholder`]),o(_,{modelValue:e.replaceSectionEnd,"onUpdate:modelValue":r[2]||=t=>e.replaceSectionEnd=t,class:`flex-1`,min:e.replaceSectionStart||0,max:e.audio?.duration,controls:!1,placeholder:e.$t(`producer.placeholder.replaceSectionEnd`)},null,8,[`modelValue`,`min`,`max`,`placeholder`])])])}var Mn=r({name:`PresetPanel`,components:{TypeSelector:Ie,PromptInput:Ye,LyricInput:nt,StyleInput:lt,TitleInput:ht,ExtendFromInput:Ot,CoverFromInput:Bt,UploadAudio:Ke,VocalGenderSelector:Kt,AdvancedParams:bn,ReplaceSectionInput:U(xn,[[`render`,jn]]),FontAwesomeIcon:X,ElButton:v,ElTabs:E,ElTabPane:D,Consumption:ue},emits:[`generate`],computed:{config(){return this.$store.state.producer?.config},mode:{get(){return this.$store.state.producer?.config?.custom?`custom`:`simple`},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,custom:e===`custom`})}},consumption(){return K(this.config,this.service?.cost)},service(){return this.$store.state.producer?.service},generateButtonText(){let e=this.config?.action;return e===`extend`||e===`upload_extend`?this.$t(`producer.button.extend`):e===`cover`||e===`upload_cover`?this.$t(`producer.button.cover_music`):e===`variation`?this.$t(`producer.button.variation`):e===`replace_section`?this.$t(`producer.button.replace_section`):e===`stems`?this.$t(`producer.button.get_stems`):e===`swap_vocals`?this.$t(`producer.button.swap_vocals`):e===`swap_instrumentals`?this.$t(`producer.button.swap_instrumentals`):this.$t(`producer.button.generate`)}},methods:{onGenerate(){this.$emit(`generate`)},onClearAll(){this.$store.commit(`producer/setConfig`,{custom:this.$store.state.producer?.config?.custom||!1,instrumental:!1,prompt:``,lyric:``,style:``,title:``,model:this.$store.state.producer?.config?.model})}}}),Nn={class:`flex flex-col h-full`},Pn={class:`flex-1 overflow-y-auto p-5`},Fn={class:`pt-2 px-1`},In={class:`pt-2 px-1`},Ln={class:`flex flex-col items-center justify-center px-5 pb-5 gap-2`},Rn={class:`flex gap-2 w-full`};function zn(e,r,s,u,d,f){let m=h(`type-selector`),_=h(`upload-audio`),v=h(`prompt-input`),y=h(`extend-from-input`),b=h(`cover-from-input`),x=h(`replace-section-input`),S=h(`advanced-params`),C=h(`el-tab-pane`),w=h(`lyric-input`),T=h(`style-input`),E=h(`title-input`),D=h(`vocal-gender-selector`),O=h(`el-tabs`),k=h(`consumption`),A=h(`font-awesome-icon`),j=h(`el-button`);return l(),t(`div`,Nn,[n(`div`,Pn,[o(O,{modelValue:e.mode,"onUpdate:modelValue":r[0]||=t=>e.mode=t,class:`producer-mode-tabs`,stretch:``},{default:g(()=>[o(C,{label:e.$t(`producer.mode.simple`),name:`simple`},{default:g(()=>[n(`div`,Fn,[o(m,{class:`mb-4`}),o(_,{class:`mb-4`}),o(v,{class:`mb-4`}),e.config?.action===`extend`?(l(),a(y,{key:0,class:`mb-4`})):p(``,!0),e.config?.action===`cover`?(l(),a(b,{key:1,class:`mb-4`})):p(``,!0),e.config?.action===`replace_section`?(l(),a(x,{key:2,class:`mb-4`})):p(``,!0),o(S,{class:`mb-4`})])]),_:1},8,[`label`]),o(C,{label:e.$t(`producer.mode.custom`),name:`custom`},{default:g(()=>[n(`div`,In,[o(m,{class:`mb-4`}),o(_,{class:`mb-4`}),e.config?.instrumental?p(``,!0):(l(),a(w,{key:0,class:`mb-4`})),o(T,{class:`mb-4`}),o(E,{class:`mb-4`}),e.config?.instrumental?p(``,!0):(l(),a(D,{key:1,class:`mb-4`})),e.config?.action===`extend`?(l(),a(y,{key:2,class:`mb-4`})):p(``,!0),e.config?.action===`cover`?(l(),a(b,{key:3,class:`mb-4`})):p(``,!0),e.config?.action===`replace_section`?(l(),a(x,{key:4,class:`mb-4`})):p(``,!0),o(S,{class:`mb-4`})])]),_:1},8,[`label`])]),_:1},8,[`modelValue`])]),n(`div`,Ln,[o(k,{value:e.consumption,service:e.service},null,8,[`value`,`service`]),n(`div`,Rn,[o(j,{class:`flex-1`,onClick:e.onClearAll},{default:g(()=>[o(A,{icon:`fa-solid fa-broom`,class:`mr-1`}),i(` `+c(e.$t(`producer.button.clear_all`)),1)]),_:1},8,[`onClick`]),o(j,{type:`primary`,class:`flex-1`,round:``,onClick:e.onGenerate},{default:g(()=>[o(A,{icon:`fa-solid fa-magic`,class:`mr-2`}),i(` `+c(e.generateButtonText),1)]),_:1},8,[`onClick`])])])])}var Bn=U(Mn,[[`render`,zn],[`__scopeId`,`data-v-4a4b209e`]]),Vn=ge(),Hn=r({name:`TaskPreview`,components:{ElImage:A,ElIcon:C,ElTooltip:k,FontAwesomeIcon:X,VideoPlay:S,VideoPause:x,ElDropdown:ne,ElDropdownMenu:te,ElDropdownItem:I,Loading:b,ApiCodeDialog:fe},props:{modelValue:{type:Object,required:!0}},data(){return{isFetchingVideoUrl:!1,isFetchingWav:!1,apiCodeVisible:!1,apiCodePath:`/producer/audios`,apiCodeBody:{}}},computed:{loading(){return this.$store.state.producer?.status?.getApplications===W.Request},credential(){return this.$store.state.producer.credential},config(){return this.$store.state.producer.config},task(){return this.$store.state.producer?.tasks},audios(){let e=this.modelValue?.response?.data??[],t=this.modelValue?.request?.action;return t?e.map(e=>({...e,action:t})):e},application(){return this.$store.state.producer?.application},active(){return this.$store.state.producer?.tasks?.active}},methods:{useFormatDuring:Q,onViewCode(){let e=this.modelValue?.request||{},t={};Object.entries(e).forEach(([e,n])=>{e===`application_id`||e===`callback_url`||n!=null&&(typeof n==`string`&&n===``||Array.isArray(n)&&n.length===0||(t[e]=n))}),this.apiCodeBody=t,this.apiCodePath=`/producer/audios`,this.apiCodeVisible=!0},onPlay(e){this.$store.dispatch(`producer/setAudio`,{...this.$store.state.producer.audio,...e,state:`playing`}),console.log(`on play`)},onPause(e){this.$store.dispatch(`producer/setAudio`,{...this.$store.state.producer.audio,...e,state:`paused`}),console.log(`on pause`)},onClick(e){this.$store.state?.producer?.audio?.id!==e.id&&this.onPlay({...e,progress:0})},onExtend(e,t){e?.stopPropagation(),console.debug(`set config`,t),this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.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();let n=new URL(t).pathname,r=n.substring(n.lastIndexOf(`/`)+1);fetch(t).then(e=>e.blob()).then(e=>{(0,Vn.saveAs)(e,r)})},async handleVideoDownload(e){if(e.video_url){this.onDownload(null,e.video_url);return}if(!this.isFetchingVideoUrl)try{this.isFetchingVideoUrl=!0;let t=await this.fetchVideoUrlFromApi(e?.id);console.log(`get videoUrl: ${t}`),e.video_url=t,this.onDownload(null,t)}catch(e){console.error(`get videoUrl failed:`,e),Y.error(this.$t(`producer.message.getVideoUrlFailed`))}finally{this.isFetchingVideoUrl=!1}},async fetchVideoUrlFromApi(e){return new Promise((t,n)=>{let r={audio_id:e},i=this.credential?.token;if(!i){console.error(`no token specified`),n(Error(`No token specified`));return}J.video(r,{token:i}).then(e=>{let r=e.data?.data?.video_url;r?t(r):n(Error(`Video URL not found in response`))}).catch(e=>{n(e)})})},onPreview(e,t){e?.stopPropagation(),window.open(t,`_blank`)},async onGetStems(e){await this.onGenerateAudioUrl(`stems`,e)},onCover(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,model:e.model,custom:!0,instrumental:!1,style:e.style,action:`cover`,audio:e,audio_id:e.id})},onVariation(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,model:e.model,custom:!0,style:e.style,action:`variation`,audio:e,audio_id:e.id})},async onSwapVocals(e){await this.onGenerateAudioUrl(`swap_vocals`,e)},async onSwapInstrumentals(e){await this.onGenerateAudioUrl(`swap_instrumentals`,e)},async onGetAllStems(e){await this.onGenerateAudioUrl(`all_stems`,e)},onReplaceSection(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,model:e.model,custom:!0,instrumental:!1,style:e.style,action:`replace_section`,audio:e,audio_id:e.id,replace_section_start:0,replace_section_end:Math.min(30,e.duration||30)})},async handleWavDownload(e){if(!e?.id||this.isFetchingWav)return;let t=this.credential?.token;if(t)try{this.isFetchingWav=!0,Y.info(this.$t(`producer.message.fetchingWav`));let n=(await J.wav({audio_id:e.id},{token:t})).data?.data,r=Array.isArray(n)?n[0]?.file_url:n?.file_url||n?.audio_url;r?this.onDownload(null,r):Y.error(this.$t(`producer.message.fetchWavFailed`))}catch{Y.error(this.$t(`producer.message.fetchWavFailed`))}finally{this.isFetchingWav=!1}},async onGenerateAudioUrl(e,t){let n={action:e,audio_id:t,async:!0},r=this.credential?.token;if(!r){console.error(`no token specified`);return}Y.info(this.$t(`producer.message.startingTask`)),J.audio(n,{token:r}).then(()=>{Y.success(this.$t(`producer.message.startTaskSuccess`))}).catch(e=>{Y.error(e?.response?.data?.error?.message||this.$t(`producer.message.startTaskFailed`))}).finally(async()=>{await this.onGetTasks(),await this.onScrollDown()})},async onScrollDown(){setTimeout(()=>{let e=document.querySelector(`.tasks`);e&&(e.scrollTop=e.scrollHeight)},1e3)},async onGetTasks(){if(this.loading){console.debug(`loading`);return}await this.$store.dispatch(`producer/getTasks`,{limit:30,offset:0})}}}),Un={class:`task`},Wn=[`onClick`],Gn={class:`left`},Kn=[`onClick`],qn=[`onClick`],Jn={key:2,class:`duration`},Yn={class:`info`},Xn={class:`title`},Zn={class:`style`},Qn={class:`right`},$n={class:`el-dropdown-link`},er={class:`flex items-center min-w-[120px]`},tr={class:`flex items-center min-w-[120px]`},nr={class:`el-dropdown-link`};function rr(r,f,_,v,y,b){let x=h(`el-image`),S=h(`video-pause`),C=h(`el-icon`),w=h(`video-play`),T=h(`font-awesome-icon`),E=h(`el-tooltip`),D=h(`Loading`),O=h(`el-dropdown-item`),k=h(`el-dropdown-menu`),A=h(`el-dropdown`),j=h(`api-code-dialog`),M=m(`loading`);return l(),t(`div`,Un,[(l(!0),t(s,null,e(r.audios,e=>(l(),t(`div`,{key:e.id,class:`audio`,onClick:u(t=>r.onClick(e),[`stop`])},[d((l(),t(`div`,Gn,[o(x,{src:e?.image_url,class:`cover`,fit:`cover`,lazy:``},null,8,[`src`]),e?.audio_url&&r.$store.state?.producer?.audio?.id===e.id&&r.$store.state?.producer?.audio?.state===`playing`?(l(),t(`div`,{key:0,class:`overlay`,onClick:u(t=>r.onPause(e),[`stop`])},[o(C,null,{default:g(()=>[o(S)]),_:1})],8,Kn)):p(``,!0),e?.audio_url&&(r.$store.state?.producer?.audio?.id!==e.id||r.$store.state?.producer?.audio?.id===e.id&&r.$store.state?.producer?.audio?.state===`paused`)?(l(),t(`div`,{key:1,class:`overlay`,onClick:u(t=>r.onPlay(e),[`stop`])},[o(C,null,{default:g(()=>[o(w)]),_:1})],8,qn)):p(``,!0),e?.duration?(l(),t(`div`,Jn,c(r.useFormatDuring(e?.duration)),1)):p(``,!0)])),[[M,!e?.audio_url]]),n(`div`,Yn,[n(`h2`,Xn,c(e?.title),1),n(`p`,Zn,c(e?.style),1)]),n(`div`,Qn,[o(A,null,{dropdown:g(()=>[o(k,null,{default:g(()=>[o(O,{disabled:r.isFetchingVideoUrl,onClick:t=>r.handleVideoDownload(e)},{default:g(()=>[n(`div`,er,[r.isFetchingVideoUrl?(l(),a(C,{key:0,class:`is-loading mr-2`},{default:g(()=>[o(D)]),_:1})):p(``,!0),n(`span`,null,c(r.$t(`producer.button.download_video`)),1)])]),_:1},8,[`disabled`,`onClick`]),e?.audio_url?(l(),a(O,{key:0,onClick:u(t=>r.onDownload(t,e?.audio_url),[`stop`])},{default:g(()=>[i(c(r.$t(`producer.button.download_audio`)),1)]),_:1},8,[`onClick`])):p(``,!0),o(O,{disabled:r.isFetchingWav,onClick:t=>r.handleWavDownload(e)},{default:g(()=>[n(`div`,tr,[r.isFetchingWav?(l(),a(C,{key:0,class:`is-loading mr-2`},{default:g(()=>[o(D)]),_:1})):p(``,!0),n(`span`,null,c(r.$t(`producer.button.download_wav`)),1)])]),_:1},8,[`disabled`,`onClick`])]),_:2},1024)]),default:g(()=>[n(`span`,$n,[o(E,{effect:`dark`,content:r.$t(`producer.button.download`),placement:`top`},{default:g(()=>[e?.audio_url||e?.video_url?(l(),a(T,{key:0,icon:`fa-solid fa-download`,class:`icon icon-download`})):p(``,!0)]),_:2},1032,[`content`])])]),_:2},1024),o(A,null,{dropdown:g(()=>[o(k,null,{default:g(()=>[e?.audio_url?(l(),a(O,{key:0,onClick:u(t=>r.onExtend(t,e),[`stop`])},{default:g(()=>[i(c(r.$t(`producer.button.extend`)),1)]),_:1},8,[`onClick`])):p(``,!0),e.id?(l(),a(O,{key:1,onClick:u(t=>r.onGetStems(e.id),[`stop`])},{default:g(()=>[i(c(r.$t(`producer.button.get_stems`)),1)]),_:1},8,[`onClick`])):p(``,!0),e.id?(l(),a(O,{key:2,onClick:u(t=>r.onGetAllStems(e.id),[`stop`])},{default:g(()=>[i(c(r.$t(`producer.button.all_stems`)),1)]),_:1},8,[`onClick`])):p(``,!0),o(O,{onClick:u(t=>r.onCover(e),[`stop`])},{default:g(()=>[i(c(r.$t(`producer.button.cover_music`)),1)]),_:1},8,[`onClick`]),e?.id?(l(),a(O,{key:3,onClick:u(t=>r.onVariation(e),[`stop`])},{default:g(()=>[i(c(r.$t(`producer.button.variation`)),1)]),_:1},8,[`onClick`])):p(``,!0),e?.id?(l(),a(O,{key:4,onClick:u(t=>r.onSwapVocals(e.id),[`stop`])},{default:g(()=>[i(c(r.$t(`producer.button.swap_vocals`)),1)]),_:1},8,[`onClick`])):p(``,!0),e?.id?(l(),a(O,{key:5,onClick:u(t=>r.onSwapInstrumentals(e.id),[`stop`])},{default:g(()=>[i(c(r.$t(`producer.button.swap_instrumentals`)),1)]),_:1},8,[`onClick`])):p(``,!0),e?.id?(l(),a(O,{key:6,onClick:u(t=>r.onReplaceSection(e),[`stop`])},{default:g(()=>[i(c(r.$t(`producer.button.replace_section`)),1)]),_:1},8,[`onClick`])):p(``,!0),o(O,{onClick:u(r.onViewCode,[`stop`])},{default:g(()=>[o(T,{icon:`fa-solid fa-code`,class:`mr-1`}),i(` `+c(r.$t(`common.button.viewCode`)),1)]),_:1},8,[`onClick`])]),_:2},1024)]),default:g(()=>[n(`span`,nr,[o(E,{effect:`dark`,content:r.$t(`producer.button.more`),placement:`top`},{default:g(()=>[e?.audio_url||e?.video_url?(l(),a(T,{key:0,icon:`fa-solid fa-ellipsis`,class:`icon icon-ellipsis`})):p(``,!0)]),_:2},1032,[`content`])])]),_:2},1024)])],8,Wn))),128)),o(j,{visible:r.apiCodeVisible,"onUpdate:visible":f[0]||=e=>r.apiCodeVisible=e,method:`POST`,path:r.apiCodePath,body:r.apiCodeBody,token:r.$store.state.producer?.credential?.token||``},null,8,[`visible`,`path`,`body`,`token`])])}var ir=r({name:`RecentPanel`,components:{ElSkeletonItem:re,ElSkeleton:ie,TaskPreview:U(Hn,[[`render`,rr]]),Player:_e,NoTasks:me,ScrollList:de},props:{loading:{type:Boolean,default:!1}},emits:[`reach-top`],data(){return{job:0}},computed:{tasks(){return{...this.$store.state.producer?.tasks,items:this.$store.state.producer?.tasks?.items?.slice()}}},methods:{getScrollElement(){return this.$refs.scrollList?.getScrollElement?.()}}}),ar={key:0,class:`tasks`},or={class:`left w-[70px] p-[10px] flex items-center`},sr={class:`main w-[calc(100%-70px)] flex-1 p-[10px]`},$={key:2,class:`w-full flex-1 flex items-center justify-center`},cr={class:`h-20`};function lr(r,i,c,u,f,m){let v=h(`el-skeleton-item`),y=h(`el-skeleton`),b=h(`task-preview`),x=h(`scroll-list`),S=h(`no-tasks`),C=h(`player`);return l(),t(s,null,[r.tasks?.items===void 0?(l(),t(`div`,ar,[(l(),t(s,null,e(3,e=>n(`div`,{key:e,class:`flex`},[n(`div`,or,[o(y,{animated:``},{template:g(()=>[o(v,{variant:`image`,class:`avatar w-[50px] h-[50px]`})]),_:1})]),n(`div`,sr,[o(y,{animated:``},{template:g(()=>[o(v,{variant:`p`,class:`w-[200px] h-[15px] mb-[5px] mt-[10px]`}),o(v,{variant:`text`})]),_:1})])])),64))])):r.tasks?.items?.length&&r.tasks?.items?.length>0?(l(),a(x,{key:1,ref:`scrollList`,class:`flex-1 w-full overflow-y-auto tasks p-2`,loading:r.loading,onReachTop:i[0]||=e=>r.$emit(`reach-top`)},{default:g(()=>[(l(!0),t(s,null,e(r.tasks?.items,(e,t)=>(l(),a(b,{key:t,"model-value":e,class:`preview`},null,8,[`model-value`]))),128))]),_:1},8,[`loading`])):p(``,!0),r.tasks?.items?.length===0?(l(),t(`div`,$,[o(S)])):p(``,!0),d(n(`div`,cr,[o(C,{namespace:`producer`})],512),[[_,!!r.$store?.state?.producer?.audio?.object]])],64)}var ur=U(ir,[[`render`,lr]]),dr=r({name:`TaskPreview`,components:{IconPicture:y,ElImage:A,ElAvatar:j,ElIcon:C},computed:{audio(){return this.$store.state.producer?.audio}}}),fr={key:0,class:`size-full overflow-hidden`},pr={class:`relative h-[300px]`},mr={class:`flex items-center justify-center size-full bg-[var(--el-bg-color)]`},hr={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`},gr={class:`p-4`},_r={class:`flex items-center font-bold mb-2`},vr={class:`text-[var(--el-text-color-regular)] mb-2`},yr={class:`text-xs text-[var(--el-text-color-regular)]`},br={class:`mt-4 text-sm leading-[25px] whitespace-pre-wrap`},xr={key:1,class:`w-full h-full`};function Sr(e,r,i,a,s,u){let d=h(`icon-picture`),f=h(`el-icon`),p=h(`el-image`),m=h(`el-avatar`);return e.audio?.object?(l(),t(`div`,fr,[n(`div`,pr,[o(p,{src:e.audio.image_url,fit:`cover`,class:`size-full`},{error:g(()=>[n(`div`,mr,[o(f,{class:`text-3xl`},{default:g(()=>[o(d)]),_:1})])]),_:1},8,[`src`]),n(`h2`,hr,c(e.audio?.title),1)]),n(`div`,gr,[n(`div`,_r,[o(m,{size:30,src:e.audio?.image_url,class:`mr-2`},null,8,[`src`]),n(`span`,null,c(e.audio?.title),1)]),n(`p`,vr,c(e.audio?.style),1),n(`p`,yr,c(e.$dayjs.format(e.audio?.created_at)),1),n(`div`,br,[n(`p`,null,c(e.audio?.lyric),1)])])])):(l(),t(`div`,xr))}var Cr=r({name:`ProducerIndex`,components:{Layout:we,ConfigPanel:Bn,RecentPanel:ur,PreviewPanel:U(dr,[[`render`,Sr]])},mixins:[z],inject:[`initialized`],data(){return{task:void 0,job:0,loadingMore:!1,fetchingTasks:!1}},computed:{applicationsLoading(){return this.$store.state.producer?.status?.getApplications===W.Request},tasksLoading(){return this.$store.state.producer?.status?.getTasks===W.Request||this.fetchingTasks},service(){return this.$store.state.producer.service},credential(){return this.$store.state.producer.credential},config(){return this.$store.state.producer.config},initializing(){return this.$store.state.producer.status.getApplications===W.Request},needApply(){return this.$store.state.producer.status.getApplications===W.Success&&!this.application},application(){return this.$store.state.producer.application},tasks(){return this.$store.state.producer.tasks},applications(){return this.$store.state.producer.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=window.setInterval(()=>{this.onGetTasks()},5e3))},immediate:!0}},async mounted(){await this.onGetService()},async unmounted(){window.clearInterval(this.job)},methods:{async onReachTop(){await pe({tasks:this.tasks,getTasks:()=>this.tasks,loading:this.loadingMore,setLoading:e=>this.loadingMore=e,isBlocked:()=>this.tasksLoading||this.applicationsLoading,fetch:e=>this.onGetTasks({createdAtMax:e}),getScrollElement:()=>this.getTasksScrollElement()})},async onGetService(){console.debug(`start onGetService`),await this.$store.dispatch(`producer/getService`),console.debug(`end onGetService`)},async onGetApplication(){console.debug(`start onGetApplications`),await this.$store.dispatch(`producer/getApplications`),console.debug(`end onGetApplications`),await this.onGetTasks()},onApply(){q.create({application:this.application}).then(({data:e})=>{this.application=e,Y.success(this.$t(`application.message.applySuccessfully`))}).catch(e=>{e?.response?.data?.code===`duplication`&&Y.error(this.$t(`application.message.alreadyApplied`))})},async onScrollDown(){await this.$nextTick();let e=this.getTasksScrollElement();e&&(e.scrollTop=e.scrollHeight)},async onGetTasks(e){if(this.applicationsLoading||this.fetchingTasks){console.debug(`loading`);return}console.debug(`start onGetTasks`,e);let{limit:t=5,createdAtMin:n,createdAtMax:r}=e||{};console.debug(`limit`,t,`createdAtMin`,n,`createdAtMax`,r),this.fetchingTasks=!0;try{await this.$store.dispatch(`producer/getTasks`,{limit:t,createdAtMin:n,createdAtMax:r})}finally{this.fetchingTasks=!1}},async onGenerateAudio(){if(!G(this.uploadTracker,e=>this.$t(e),e=>Y.warning(e)))return;let e={...this.config,async:!0};if(!se())return;let t=this.credential?.token;if(!t){console.error(`no token specified`);return}Y.info(this.$t(`producer.message.startingTask`)),B(`producer`,J.audio(e,{token:t})).then(()=>{Y.success(this.$t(`producer.message.startTaskSuccess`))}).catch(e=>{Y.error(e?.response?.data?.error?.message||this.$t(`producer.message.startTaskFailed`))}).finally(async()=>{setTimeout(async()=>{await this.onGetTasks(),await this.onScrollDown()},1e3)})},getTasksScrollElement(){return this.$refs.recentPanel?.getScrollElement?.()}}});function wr(e,t,n,r,i,s){let c=h(`config-panel`),u=h(`recent-panel`),d=h(`preview-panel`),f=h(`layout`);return l(),a(f,null,{config:g(()=>[o(c,{onGenerate:e.onGenerateAudio},null,8,[`onGenerate`])]),result:g(()=>[o(u,{ref:`recentPanel`,class:`panel recent`,loading:e.loadingMore,onReachTop:e.onReachTop},null,8,[`loading`,`onReachTop`])]),preview:g(()=>[o(d)]),_:1})}var Tr=U(Cr,[[`render`,wr],[`__scopeId`,`data-v-23eb99dc`]]);export{Tr as default};
|
|
1
|
+
import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,b as u,dt as d,et as f,k as p,nt as m,tt as h,ut as g,v as _}from"./vendor-chart-BJCvKk8-.js";import{t as v}from"./button-BydTr5nV.js";import{B as y,I as b,X as x,Z as S,nt as C}from"./use-deprecated-B-NFNg3W.js";import{r as w,t as T}from"./select-BrRoGuGI.js";import{n as E,t as D}from"./tabs-BX6WZxwV.js";import{t as O}from"./upload-BD93nwqF.js";import{t as k}from"./tooltip-ivBOvVK_.js";import{t as A}from"./image-CsANLYkn.js";import{t as j}from"./avatar-Chg0rxNt.js";import{n as M,r as N}from"./radio-3Hz7h3DR.js";import{n as ee,t as P}from"./collapse-o0Tbh9kY.js";import{t as F}from"./drawer-Aw9IMZFK.js";import{n as I,r as te,t as ne}from"./dropdown-Y7CGGDP7.js";import{t as L}from"./input-number-CUon16df.js";import{n as re,t as ie}from"./skeleton-BwNBivMN.js";import{t as ae}from"./slider-oal-Uh6R.js";import{t as oe}from"./switch-9ZO_9tNo.js";import{Vn as R}from"./constants-DReNd4Tz.js";import{Bt as z,Jn as B,Kr as V,Lr as H,O as U,Pr as W,Rt as G,Ut as K,Wn as q,Zt as se,mn as J,zr as Y,zt as ce}from"./index-BwuZeZD0.js";import{t as X}from"./index.es-BAFsTiuS.js";import{n as le}from"./taskDrawerMixin-DEgO_R5H.js";import{t as ue}from"./Consumption-Bo_pmB_S.js";import{i as Z,n as de,r as fe,t as pe}from"./pagination-rLdABsD2.js";import{t as me}from"./NoTasks-CXc3S2PE.js";import{t as he}from"./PromptTextarea-Dtz_bZis.js";import{n as ge,r as Q,t as _e}from"./Player-BxmM7SHY.js";var ve=r({name:`LayoutProducer`,components:{ElDrawer:F,ElButton:v,FontAwesomeIcon:X},mixins:[le],data(){return{preview:!1}},computed:{}}),ye={class:`main flex flex-row flex-1`},be={class:`config w-[320px] flex-none h-full overflow-y-auto bg-[var(--app-sidebar-bg)] border-r border-[var(--app-border-subtle)]`},xe={class:`result h-full flex flex-col flex-1 min-w-0 overflow-x-hidden bg-[var(--app-content-bg)]`},Se={class:`preview h-full w-[300px] flex flex-col`};function Ce(e,r,i,a,s,c){let u=h(`font-awesome-icon`),p=h(`el-button`),m=h(`el-drawer`);return l(),t(`div`,ye,[n(`div`,be,[f(e.$slots,`config`,{},void 0,!0)]),n(`div`,xe,[f(e.$slots,`result`,{},void 0,!0)]),n(`div`,Se,[f(e.$slots,`preview`,{},void 0,!0)]),d(o(p,{circle:``,class:`menu`,onClick:r[0]||=t=>e.drawer=!0},{default:g(()=>[o(u,{icon:`fa-solid fa-magic`})]),_:1},512),[[_,!e.tasksEmpty]]),o(m,{modelValue:e.drawer,"onUpdate:modelValue":r[1]||=t=>e.drawer=t,direction:`ltr`,"with-header":!1,size:`340px`,class:`drawer`},{default:g(()=>[f(e.$slots,`config`,{},void 0,!0)]),_:3},8,[`modelValue`])])}var we=U(ve,[[`render`,Ce],[`__scopeId`,`data-v-cc984c6f`]]),Te=r({name:`TypeSelector`,components:{ElSelect:w,ElOption:T,ElSwitch:oe,InfoIcon:Z},data(){return{options:[{label:`FUZZ-2.0 Pro`,value:`FUZZ-2.0 Pro`,desc:this.$t(`producer.model.fuzz20proDesc`)},{label:`FUZZ-2.0`,value:`FUZZ-2.0`,desc:this.$t(`producer.model.fuzz20desc`)},{label:`FUZZ-2.0 Raw`,value:`FUZZ-2.0 Raw`,desc:this.$t(`producer.model.fuzz20rawDesc`)},{label:`FUZZ-1.1 Pro`,value:`FUZZ-1.1 Pro`,desc:this.$t(`producer.model.fuzz11proDesc`)},{label:`FUZZ-1.1`,value:`FUZZ-1.1`,desc:this.$t(`producer.model.fuzz11desc`)},{label:`FUZZ-1.0 Pro`,value:`FUZZ-1.0 Pro`,desc:this.$t(`producer.model.fuzz10proDesc`)},{label:`FUZZ-1.0`,value:`FUZZ-1.0`,desc:this.$t(`producer.model.fuzz10desc`)},{label:`FUZZ-0.8`,value:`FUZZ-0.8`,desc:this.$t(`producer.model.fuzz08desc`)}]}},computed:{custom:{get(){return this.$store.state.producer?.config?.custom||!1},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,custom:e})}},instrumental:{get(){return this.$store.state.producer?.config?.instrumental||!1},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,instrumental:e})}},model:{get(){return this.$store.state.producer?.config?.model},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,model:e})}}},mounted(){this.model||=R}}),Ee={class:`mb-3`},De={class:`flex items-center mb-1`},Oe={class:`text-sm font-bold`},ke={class:`model-option`},Ae={class:`model-option-name`},je={class:`model-option-desc`},Me={key:0,class:`flex items-center justify-between mb-3`},Ne={class:`flex items-center`},Pe={class:`text-sm font-bold`};function Fe(r,i,u,d,f,m){let _=h(`el-option`),v=h(`el-select`),y=h(`info-icon`),b=h(`el-switch`);return l(),t(`div`,null,[n(`div`,Ee,[n(`div`,De,[n(`span`,Oe,c(r.$t(`producer.name.model`)),1)]),o(v,{modelValue:r.model,"onUpdate:modelValue":i[0]||=e=>r.model=e,class:`w-full model-select`,size:`default`,placeholder:r.$t(`producer.placeholder.select`)},{default:g(()=>[(l(!0),t(s,null,e(r.options,e=>(l(),a(_,{key:e.value,label:e.label,value:e.value},{default:g(()=>[n(`div`,ke,[n(`span`,Ae,c(e.label),1),n(`span`,je,c(e.desc),1)])]),_:2},1032,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])]),r.custom?(l(),t(`div`,Me,[n(`div`,Ne,[n(`span`,Pe,c(r.$t(`producer.name.instrumental`)),1),o(y,{content:r.$t(`producer.description.instrumental`)},null,8,[`content`])]),o(b,{modelValue:r.instrumental,"onUpdate:modelValue":i[1]||=e=>r.instrumental=e},null,8,[`modelValue`])])):p(``,!0)])}var Ie=U(Te,[[`render`,Fe],[`__scopeId`,`data-v-42496b9a`]]),Le=r({name:`UploadAudio`,components:{ElUpload:O,ElButton:v,ElRadioGroup:N,ElRadioButton:M,InfoIcon:Z,FontAwesomeIcon:X},mixins:[ce],emits:[`change`],data(){return{fileList:[],uploadUrl:H()+`/api/v1/files/`,audioPreviewUrl:null,uploading:!1}},computed:{headers(){return{Authorization:`Bearer ${this.$store.state.token.access}`}},credential(){return this.$store.state.producer.credential},config(){return this.$store.state.producer.config},urls(){return this.fileList.map(e=>e?.response?.file_url)},hasUploadedAudio(){let e=this.$store.state.producer?.config?.action;return e===`upload_extend`||e===`upload_cover`},uploadAction:{get(){return this.$store.state.producer?.config?.action||`upload_extend`},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,action:e})}}},watch:{urls:{handler(e){this.$emit(`change`,e)}}},methods:{onExceed(){Y.warning(this.$t(`producer.message.uploadReferencesExceed`))},onError(){this.uploading=!1,Y.error(this.$t(`producer.message.uploadReferencesError`))},async onSuccess(){let e=this.urls?.[0];if(!e){this.uploading=!1;return}this.audioPreviewUrl=e,await this.onGenerateAudioId(e)},async onGenerateAudioId(e){let t={audio_url:e},n=this.credential?.token;if(!n){console.error(`no token specified`),this.uploading=!1;return}this.uploading=!0,Y.info(this.$t(`producer.message.startingUploadAudio`));try{let e=(await J.upload(t,{token:n})).data?.data.audio_id;this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,audio_id:e,action:`upload_extend`}),Y.success(this.$t(`producer.message.startUploadAudioSuccess`))}catch(e){Y.error(e?.response?.data?.error?.message||this.$t(`producer.message.startUploadAudioFailed`))}finally{this.uploading=!1}}}}),Re={class:`relative`},ze={class:`flex justify-between items-center mb-2`},Be={class:`flex justify-start items-center`},Ve={class:`text-sm font-bold`},He={key:0,class:`mb-2`},Ue=[`src`],We={key:1,class:`mt-1`};function Ge(e,r,a,s,u,d){let f=h(`info-icon`),m=h(`font-awesome-icon`),_=h(`el-button`),v=h(`el-upload`),y=h(`el-radio-button`),b=h(`el-radio-group`);return l(),t(`div`,Re,[n(`div`,ze,[n(`div`,Be,[n(`span`,Ve,c(e.$t(`producer.name.referenceAudios`)),1),o(f,{content:e.$t(`producer.description.uploadAudios`)},null,8,[`content`])]),o(v,{"file-list":e.fileList,"onUpdate:fileList":r[0]||=t=>e.fileList=t,name:`file`,limit:1,class:`upload-wrapper inline-upload`,action:e.uploadUrl,accept:`.mp3,.wav,.m4a,audio/*`,"show-file-list":!1,"on-exceed":e.onExceed,"on-error":e.onError,"on-success":e.onSuccess,headers:e.headers},{default:g(()=>[o(_,{round:``,type:`primary`,size:`small`,loading:e.uploading},{default:g(()=>[o(m,{icon:`fa-solid fa-upload`,class:`icon mr-1`}),i(` `+c(e.$t(`producer.button.uploadAudios`)),1)]),_:1},8,[`loading`])]),_:1},8,[`file-list`,`action`,`on-exceed`,`on-error`,`on-success`,`headers`])]),e.audioPreviewUrl?(l(),t(`div`,He,[n(`audio`,{src:e.audioPreviewUrl,controls:``,class:`w-full`},null,8,Ue)])):p(``,!0),e.hasUploadedAudio?(l(),t(`div`,We,[o(b,{modelValue:e.uploadAction,"onUpdate:modelValue":r[1]||=t=>e.uploadAction=t,size:`small`},{default:g(()=>[o(y,{value:`upload_extend`},{default:g(()=>[i(c(e.$t(`producer.button.extend`)),1)]),_:1}),o(y,{value:`upload_cover`},{default:g(()=>[i(c(e.$t(`producer.button.cover_music`)),1)]),_:1})]),_:1},8,[`modelValue`])])):p(``,!0)])}var Ke=U(Le,[[`render`,Ge],[`__scopeId`,`data-v-7fd0580a`]]),qe=r({name:`PromptInput`,components:{PromptTextarea:he},computed:{prompt:{get(){return this.$store.state.producer?.config?.prompt},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,prompt:e})}}},mounted(){this.prompt||=``}});function Je(e,t,n,r,i,o){let s=h(`prompt-textarea`);return l(),a(s,{modelValue:e.prompt,"onUpdate:modelValue":t[0]||=t=>e.prompt=t,title:e.$t(`producer.name.songDescription`),info:e.$t(`producer.description.prompt`),placeholder:e.$t(`producer.placeholder.prompt`),"min-rows":5,"max-rows":14},null,8,[`modelValue`,`title`,`info`,`placeholder`])}var Ye=U(qe,[[`render`,Je]]),Xe=r({name:`LyricInput`,components:{ElInput:V,ElButton:v,FontAwesomeIcon:X,InfoIcon:Z},data(){return{generatingLyrics:!1}},computed:{lyric:{get(){return this.$store.state.producer?.config?.lyric},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,lyric:e})}},config(){return this.$store.state.producer?.config},credential(){return this.$store.state.producer?.credential}},mounted(){this.lyric||=``},methods:{async onGenerateLyrics(){let e=this.credential?.token;if(!e)return;let t=this.config?.style||this.config?.title||`a beautiful song`;this.generatingLyrics=!0,Y.info(this.$t(`producer.message.generatingLyrics`));try{let n=(await J.lyric({prompt:t},{token:e})).data?.data;n?.text&&(this.lyric=n.text,n?.title&&!this.config?.title&&this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,lyric:n.text,title:n.title}),Y.success(this.$t(`producer.message.generateLyricsSuccess`)))}catch{Y.error(this.$t(`producer.message.generateLyricsFailed`))}finally{this.generatingLyrics=!1}}}}),Ze={class:`field`},Qe={class:`flex items-center justify-between mb-1`},$e={class:`flex items-center`},et={class:`text-sm font-bold`};function tt(e,r,s,u,d,f){let m=h(`info-icon`),_=h(`font-awesome-icon`),v=h(`el-button`),y=h(`el-input`);return l(),t(`div`,Ze,[n(`div`,Qe,[n(`div`,$e,[n(`span`,et,c(e.$t(`producer.name.lyrics`)),1),o(m,{content:e.$t(`producer.description.lyrics`)},null,8,[`content`])]),e.config?.action===`extend`?p(``,!0):(l(),a(v,{key:0,size:`small`,loading:e.generatingLyrics,round:``,onClick:e.onGenerateLyrics},{default:g(()=>[e.generatingLyrics?p(``,!0):(l(),a(_,{key:0,icon:`fa-solid fa-wand-magic-sparkles`,class:`mr-1`})),i(` `+c(e.$t(`producer.button.generate_lyrics`)),1)]),_:1},8,[`loading`,`onClick`]))]),e.config?.action===`extend`?(l(),a(y,{key:1,modelValue:e.lyric,"onUpdate:modelValue":r[1]||=t=>e.lyric=t,rows:5,type:`textarea`,class:`lyrics`,placeholder:e.$t(`producer.placeholder.extend.lyrics`)},null,8,[`modelValue`,`placeholder`])):(l(),a(y,{key:0,modelValue:e.lyric,"onUpdate:modelValue":r[0]||=t=>e.lyric=t,rows:5,type:`textarea`,class:`lyrics`,placeholder:e.$t(`producer.placeholder.lyrics`)},null,8,[`modelValue`,`placeholder`]))])}var nt=U(Xe,[[`render`,tt],[`__scopeId`,`data-v-88c6da2b`]]),rt=r({name:`StyleInput`,components:{ElInput:V,InfoIcon:Z},computed:{style:{get(){return this.$store.state.producer?.config?.style},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,style:e})}}}}),it={class:`field`},at={class:`flex items-center justify-between mb-1`},ot={class:`flex items-center`},st={class:`text-sm font-bold`};function ct(e,r,i,a,s,u){let d=h(`info-icon`),f=h(`el-input`);return l(),t(`div`,it,[n(`div`,at,[n(`div`,ot,[n(`span`,st,c(e.$t(`producer.name.style`)),1),o(d,{content:e.$t(`producer.description.style`)},null,8,[`content`])])]),o(f,{modelValue:e.style,"onUpdate:modelValue":r[0]||=t=>e.style=t,rows:2,type:`textarea`,placeholder:e.$t(`producer.placeholder.style`)},null,8,[`modelValue`,`placeholder`])])}var lt=U(rt,[[`render`,ct]]),ut=r({name:`TitleInput`,components:{ElInput:V,InfoIcon:Z},computed:{title:{get(){return this.$store.state.producer?.config?.title},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,title:e})}}}}),dt={class:`field`},ft={class:`flex items-center mb-1`},pt={class:`text-sm font-bold`};function mt(e,r,i,a,s,u){let d=h(`info-icon`),f=h(`el-input`);return l(),t(`div`,dt,[n(`div`,ft,[n(`span`,pt,c(e.$t(`producer.name.title`)),1),o(d,{content:e.$t(`producer.description.title`)},null,8,[`content`])]),o(f,{modelValue:e.title,"onUpdate:modelValue":r[0]||=t=>e.title=t,placeholder:e.$t(`producer.placeholder.title`)},null,8,[`modelValue`,`placeholder`])])}var ht=U(ut,[[`render`,mt]]),gt=r({name:`ExtendFromInput`,components:{ElImage:A,ElIcon:C,ElInputNumber:L,VideoPlay:S,VideoPause:x},data(){return{}},computed:{audio(){return this.$store.state.producer?.config?.audio},value:{get(){return this.$store.state.producer?.config?.continue_at},set(e){console.debug(`set continue_at`,e),this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,continue_at:e?parseInt(e):void 0})}}},mounted(){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:Q,onPlay(e){this.$store.dispatch(`producer/setAudio`,{...this.$store.state.producer.audio,...e,state:`playing`}),console.log(`on play`)},onPause(e){this.$store.dispatch(`producer/setAudio`,{...this.$store.state.producer.audio,...e,state:`paused`}),console.log(`on pause`)},onClick(e){this.$store.state?.producer?.audio?.id!==e.id&&this.onPlay({...e,progress:0})}}}),_t={class:`field`},vt={class:`box`},yt={class:`title font-bold`},bt={class:`input-wrapper`},xt={class:`task`},St={class:`left`},Ct={key:2,class:`duration`},wt={class:`info`},Tt={class:`title`},Et={class:`style`};function Dt(e,r,i,a,s,u){let f=h(`el-input-number`),_=h(`el-image`),v=h(`video-pause`),y=h(`el-icon`),b=h(`video-play`),x=m(`loading`);return l(),t(`div`,_t,[n(`div`,vt,[n(`h2`,yt,c(e.$t(`producer.name.extend`)),1),n(`div`,bt,[o(f,{modelValue:e.value,"onUpdate:modelValue":r[0]||=t=>e.value=t,class:`value`,min:0,max:e.audio?.duration,controls:!1,placeholder:e.$t(`producer.placeholder.extend.continue_at`),onChange:e.handleChange},null,8,[`modelValue`,`max`,`placeholder`,`onChange`])])]),n(`div`,xt,[e.audio?(l(),t(`div`,{key:0,class:`audio`,onClick:r[3]||=t=>e.onClick(e.audio)},[d((l(),t(`div`,St,[o(_,{src:e.audio?.image_url,class:`cover`,fit:`cover`},null,8,[`src`]),e.audio?.audio_url&&e.$store.state?.producer?.audio?.id===e.audio.id&&e.$store.state?.producer?.audio?.state===`playing`?(l(),t(`div`,{key:0,class:`overlay`,onClick:r[1]||=t=>e.onPause(e.audio)},[o(y,null,{default:g(()=>[o(v)]),_:1})])):p(``,!0),e.audio?.audio_url&&(e.$store.state?.producer?.audio?.id!==e.audio.id||e.$store.state?.producer?.audio?.id===e.audio.id&&e.$store.state?.producer?.audio?.state===`paused`)?(l(),t(`div`,{key:1,class:`overlay`,onClick:r[2]||=t=>e.onPlay(e.audio)},[o(y,null,{default:g(()=>[o(b)]),_:1})])):p(``,!0),e.audio?.duration?(l(),t(`div`,Ct,c(e.useFormatDuring(e.audio?.duration)),1)):p(``,!0)])),[[x,!e.audio?.audio_url]]),n(`div`,wt,[n(`h2`,Tt,c(e.audio?.title),1),n(`p`,Et,c(e.audio?.style),1)])])):p(``,!0)])])}var Ot=U(gt,[[`render`,Dt],[`__scopeId`,`data-v-26d43480`]]),kt=r({name:`CoverFromInput`,components:{ElImage:A,ElIcon:C,VideoPlay:S,VideoPause:x},data(){return{}},computed:{audio(){return this.$store.state.producer?.config?.audio},value:{get(){return this.$store.state.producer?.config?.continue_at},set(e){console.debug(`set continue_at`,e),this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,continue_at:e?parseInt(e):void 0})}}},mounted(){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:Q,onPlay(e){this.$store.dispatch(`producer/setAudio`,{...this.$store.state.producer.audio,...e,state:`playing`}),console.log(`on play`)},onPause(e){this.$store.dispatch(`producer/setAudio`,{...this.$store.state.producer.audio,...e,state:`paused`}),console.log(`on pause`)},onClick(e){this.$store.state?.producer?.audio?.id!==e.id&&this.onPlay({...e,progress:0})}}}),At={class:`field`},jt={class:`box`},Mt={class:`title font-bold`},Nt={class:`task`},Pt={class:`left`},Ft={key:2,class:`duration`},It={class:`info`},Lt={class:`title`},Rt={class:`style`};function zt(e,r,i,a,s,u){let f=h(`el-image`),_=h(`video-pause`),v=h(`el-icon`),y=h(`video-play`),b=m(`loading`);return l(),t(`div`,At,[n(`div`,jt,[n(`h2`,Mt,c(e.$t(`producer.name.cover`)),1)]),n(`div`,Nt,[e.audio?(l(),t(`div`,{key:0,class:`audio`,onClick:r[2]||=t=>e.onClick(e.audio)},[d((l(),t(`div`,Pt,[o(f,{src:e.audio?.image_url,class:`cover`,fit:`cover`},null,8,[`src`]),e.audio?.audio_url&&e.$store.state?.producer?.audio?.id===e.audio.id&&e.$store.state?.producer?.audio?.state===`playing`?(l(),t(`div`,{key:0,class:`overlay`,onClick:r[0]||=t=>e.onPause(e.audio)},[o(v,null,{default:g(()=>[o(_)]),_:1})])):p(``,!0),e.audio?.audio_url&&(e.$store.state?.producer?.audio?.id!==e.audio.id||e.$store.state?.producer?.audio?.id===e.audio.id&&e.$store.state?.producer?.audio?.state===`paused`)?(l(),t(`div`,{key:1,class:`overlay`,onClick:r[1]||=t=>e.onPlay(e.audio)},[o(v,null,{default:g(()=>[o(y)]),_:1})])):p(``,!0),e.audio?.duration?(l(),t(`div`,Ft,c(e.useFormatDuring(e.audio?.duration)),1)):p(``,!0)])),[[b,!e.audio?.audio_url]]),n(`div`,It,[n(`h2`,Lt,c(e.audio?.title),1),n(`p`,Rt,c(e.audio?.style),1)])])):p(``,!0)])])}var Bt=U(kt,[[`render`,zt],[`__scopeId`,`data-v-d8a8e583`]]),Vt=r({name:`VocalGenderSelector`,components:{ElRadioGroup:N,ElRadioButton:M,InfoIcon:Z},computed:{vocalGender:{get(){return this.$store.state.producer?.config?.vocal_gender||``},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,vocal_gender:e||void 0})}}}}),Ht={class:`mb-2`},Ut={class:`flex items-center mb-1`},Wt={class:`text-sm font-bold`};function Gt(e,r,a,s,u,d){let f=h(`info-icon`),p=h(`el-radio-button`),m=h(`el-radio-group`);return l(),t(`div`,Ht,[n(`div`,Ut,[n(`span`,Wt,c(e.$t(`producer.name.vocalGender`)),1),o(f,{content:e.$t(`producer.description.vocalGender`)},null,8,[`content`])]),o(m,{modelValue:e.vocalGender,"onUpdate:modelValue":r[0]||=t=>e.vocalGender=t},{default:g(()=>[o(p,{value:``},{default:g(()=>[i(c(e.$t(`producer.gender.auto`)),1)]),_:1}),o(p,{value:`f`},{default:g(()=>[i(c(e.$t(`producer.gender.female`)),1)]),_:1}),o(p,{value:`m`},{default:g(()=>[i(c(e.$t(`producer.gender.male`)),1)]),_:1})]),_:1},8,[`modelValue`])])}var Kt=U(Vt,[[`render`,Gt]]),qt=r({name:`AdvancedParams`,components:{ElCollapse:P,ElCollapseItem:ee,ElInput:V,ElSlider:ae,ElInputNumber:L,InfoIcon:Z},data(){return{activeNames:[]}},computed:{config(){return this.$store.state.producer?.config},styleNegative:{get(){return this.$store.state.producer?.config?.style_negative||``},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,style_negative:e||void 0})}},lyricPrompt:{get(){return this.$store.state.producer?.config?.lyric_prompt||``},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,lyric_prompt:e||void 0})}},weirdness:{get(){return this.$store.state.producer?.config?.weirdness??.5},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,weirdness:e})}},soundStrength:{get(){return this.$store.state.producer?.config?.sound_strength??.7},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,sound_strength:e})}},lyricsStrength:{get(){return this.$store.state.producer?.config?.lyrics_strength??.7},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,lyrics_strength:e})}},seed:{get(){return this.$store.state.producer?.config?.seed},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,seed:e})}}},mounted(){let e=this.$store.state.producer?.config;if(!e)return;let t={};typeof e.weirdness==`number`&&e.weirdness>1&&(t.weirdness=e.weirdness/100),typeof e.sound_strength==`number`&&e.sound_strength>1&&(t.sound_strength=e.sound_strength/100),typeof e.lyrics_strength==`number`&&e.lyrics_strength>1&&(t.lyrics_strength=e.lyrics_strength/100),Object.keys(t).length>0&&this.$store.commit(`producer/setConfig`,{...e,...t})}}),Jt={key:0,class:`mb-3`},Yt={class:`flex items-center mb-1`},Xt={class:`text-xs font-bold`},Zt={key:1,class:`mb-3`},Qt={class:`flex items-center mb-1`},$t={class:`text-xs font-bold`},en={class:`mb-3`},tn={class:`flex items-center justify-between mb-1`},nn={class:`flex items-center`},rn={class:`text-xs font-bold`},an={class:`text-xs text-[var(--el-text-color-secondary)]`},on={class:`mb-3`},sn={class:`flex items-center justify-between mb-1`},cn={class:`flex items-center`},ln={class:`text-xs font-bold`},un={class:`text-xs text-[var(--el-text-color-secondary)]`},dn={key:2,class:`mb-3`},fn={class:`flex items-center justify-between mb-1`},pn={class:`flex items-center`},mn={class:`text-xs font-bold`},hn={class:`text-xs text-[var(--el-text-color-secondary)]`},gn={class:`mb-3`},_n={class:`flex items-center mb-1`},vn={class:`text-xs font-bold`};function yn(e,r,i,s,u,d){let f=h(`info-icon`),m=h(`el-input`),_=h(`el-slider`),v=h(`el-input-number`),y=h(`el-collapse-item`),b=h(`el-collapse`);return l(),a(b,{modelValue:e.activeNames,"onUpdate:modelValue":r[6]||=t=>e.activeNames=t,class:`advanced-collapse`},{default:g(()=>[o(y,{title:e.$t(`producer.name.advancedParams`),name:`advanced`},{default:g(()=>[e.config?.custom?(l(),t(`div`,Jt,[n(`div`,Yt,[n(`span`,Xt,c(e.$t(`producer.name.styleNegative`)),1),o(f,{content:e.$t(`producer.description.styleNegative`)},null,8,[`content`])]),o(m,{modelValue:e.styleNegative,"onUpdate:modelValue":r[0]||=t=>e.styleNegative=t,size:`small`,placeholder:e.$t(`producer.placeholder.styleNegative`)},null,8,[`modelValue`,`placeholder`])])):p(``,!0),e.config?.custom&&!e.config?.instrumental?(l(),t(`div`,Zt,[n(`div`,Qt,[n(`span`,$t,c(e.$t(`producer.name.lyricPrompt`)),1),o(f,{content:e.$t(`producer.description.lyricPrompt`)},null,8,[`content`])]),o(m,{modelValue:e.lyricPrompt,"onUpdate:modelValue":r[1]||=t=>e.lyricPrompt=t,size:`small`,placeholder:e.$t(`producer.placeholder.lyricPrompt`)},null,8,[`modelValue`,`placeholder`])])):p(``,!0),n(`div`,en,[n(`div`,tn,[n(`div`,nn,[n(`span`,rn,c(e.$t(`producer.name.weirdness`)),1),o(f,{content:e.$t(`producer.description.weirdness`)},null,8,[`content`])]),n(`span`,an,c(e.weirdness??.5),1)]),o(_,{modelValue:e.weirdness,"onUpdate:modelValue":r[2]||=t=>e.weirdness=t,min:0,max:1,step:.01},null,8,[`modelValue`])]),n(`div`,on,[n(`div`,sn,[n(`div`,cn,[n(`span`,ln,c(e.$t(`producer.name.soundStrength`)),1),o(f,{content:e.$t(`producer.description.soundStrength`)},null,8,[`content`])]),n(`span`,un,c(e.soundStrength??.7),1)]),o(_,{modelValue:e.soundStrength,"onUpdate:modelValue":r[3]||=t=>e.soundStrength=t,min:.2,max:1,step:.01},null,8,[`modelValue`])]),e.config?.custom&&!e.config?.instrumental?(l(),t(`div`,dn,[n(`div`,fn,[n(`div`,pn,[n(`span`,mn,c(e.$t(`producer.name.lyricsStrength`)),1),o(f,{content:e.$t(`producer.description.lyricsStrength`)},null,8,[`content`])]),n(`span`,hn,c(e.lyricsStrength??.7),1)]),o(_,{modelValue:e.lyricsStrength,"onUpdate:modelValue":r[4]||=t=>e.lyricsStrength=t,min:0,max:1,step:.01},null,8,[`modelValue`])])):p(``,!0),n(`div`,gn,[n(`div`,_n,[n(`span`,vn,c(e.$t(`producer.name.seed`)),1),o(f,{content:e.$t(`producer.description.seed`)},null,8,[`content`])]),o(v,{modelValue:e.seed,"onUpdate:modelValue":r[5]||=t=>e.seed=t,min:0,controls:!1,size:`small`,placeholder:e.$t(`producer.placeholder.seed`),class:`w-full`},null,8,[`modelValue`,`placeholder`])])]),_:1},8,[`title`])]),_:1},8,[`modelValue`])}var bn=U(qt,[[`render`,yn],[`__scopeId`,`data-v-f9296888`]]),xn=r({name:`ReplaceSectionInput`,components:{ElInputNumber:L,ElImage:A,InfoIcon:Z},computed:{audio(){return this.$store.state.producer?.config?.audio},replaceSectionStart:{get(){return this.$store.state.producer?.config?.replace_section_start},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,replace_section_start:e})}},replaceSectionEnd:{get(){return this.$store.state.producer?.config?.replace_section_end},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,replace_section_end:e})}}},methods:{onClick(e){this.$store.dispatch(`producer/setAudio`,{...this.$store.state.producer.audio,...e,state:`playing`})}}}),Sn={class:`field`},Cn={class:`flex items-center mb-2`},wn={class:`text-sm font-bold m-0`},Tn={key:0,class:`task mb-2`},En={class:`left relative w-[50px] h-[50px] mr-3 flex-shrink-0`},Dn={class:`info flex-1 min-w-0`},On={class:`text-sm font-bold m-0 truncate`},kn={class:`text-xs text-[var(--el-text-color-secondary)] m-0 truncate`},An={class:`flex gap-2`};function jn(e,r,i,a,s,u){let f=h(`info-icon`),g=h(`el-image`),_=h(`el-input-number`),v=m(`loading`);return l(),t(`div`,Sn,[n(`div`,Cn,[n(`h2`,wn,c(e.$t(`producer.name.replaceSection`)),1),o(f,{content:e.$t(`producer.description.replaceSection`)},null,8,[`content`])]),e.audio?(l(),t(`div`,Tn,[n(`div`,{class:`audio flex items-center`,onClick:r[0]||=t=>e.onClick(e.audio)},[d((l(),t(`div`,En,[o(g,{src:e.audio?.image_url,class:`w-full h-full rounded`,fit:`cover`},null,8,[`src`])])),[[v,!e.audio?.audio_url]]),n(`div`,Dn,[n(`h2`,On,c(e.audio?.title),1),n(`p`,kn,c(e.audio?.style),1)])])])):p(``,!0),n(`div`,An,[o(_,{modelValue:e.replaceSectionStart,"onUpdate:modelValue":r[1]||=t=>e.replaceSectionStart=t,class:`flex-1`,min:0,max:e.audio?.duration,controls:!1,placeholder:e.$t(`producer.placeholder.replaceSectionStart`)},null,8,[`modelValue`,`max`,`placeholder`]),o(_,{modelValue:e.replaceSectionEnd,"onUpdate:modelValue":r[2]||=t=>e.replaceSectionEnd=t,class:`flex-1`,min:e.replaceSectionStart||0,max:e.audio?.duration,controls:!1,placeholder:e.$t(`producer.placeholder.replaceSectionEnd`)},null,8,[`modelValue`,`min`,`max`,`placeholder`])])])}var Mn=r({name:`PresetPanel`,components:{TypeSelector:Ie,PromptInput:Ye,LyricInput:nt,StyleInput:lt,TitleInput:ht,ExtendFromInput:Ot,CoverFromInput:Bt,UploadAudio:Ke,VocalGenderSelector:Kt,AdvancedParams:bn,ReplaceSectionInput:U(xn,[[`render`,jn]]),FontAwesomeIcon:X,ElButton:v,ElTabs:E,ElTabPane:D,Consumption:ue},emits:[`generate`],computed:{config(){return this.$store.state.producer?.config},mode:{get(){return this.$store.state.producer?.config?.custom?`custom`:`simple`},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,custom:e===`custom`})}},consumption(){return K(this.config,this.service?.cost)},service(){return this.$store.state.producer?.service},generateButtonText(){let e=this.config?.action;return e===`extend`||e===`upload_extend`?this.$t(`producer.button.extend`):e===`cover`||e===`upload_cover`?this.$t(`producer.button.cover_music`):e===`variation`?this.$t(`producer.button.variation`):e===`replace_section`?this.$t(`producer.button.replace_section`):e===`stems`?this.$t(`producer.button.get_stems`):e===`swap_vocals`?this.$t(`producer.button.swap_vocals`):e===`swap_instrumentals`?this.$t(`producer.button.swap_instrumentals`):this.$t(`producer.button.generate`)}},methods:{onGenerate(){this.$emit(`generate`)},onClearAll(){this.$store.commit(`producer/setConfig`,{custom:this.$store.state.producer?.config?.custom||!1,instrumental:!1,prompt:``,lyric:``,style:``,title:``,model:this.$store.state.producer?.config?.model})}}}),Nn={class:`flex flex-col h-full`},Pn={class:`flex-1 overflow-y-auto p-5`},Fn={class:`pt-2 px-1`},In={class:`pt-2 px-1`},Ln={class:`flex flex-col items-center justify-center px-5 pb-5 gap-2`},Rn={class:`flex gap-2 w-full`};function zn(e,r,s,u,d,f){let m=h(`type-selector`),_=h(`upload-audio`),v=h(`prompt-input`),y=h(`extend-from-input`),b=h(`cover-from-input`),x=h(`replace-section-input`),S=h(`advanced-params`),C=h(`el-tab-pane`),w=h(`lyric-input`),T=h(`style-input`),E=h(`title-input`),D=h(`vocal-gender-selector`),O=h(`el-tabs`),k=h(`consumption`),A=h(`font-awesome-icon`),j=h(`el-button`);return l(),t(`div`,Nn,[n(`div`,Pn,[o(O,{modelValue:e.mode,"onUpdate:modelValue":r[0]||=t=>e.mode=t,class:`producer-mode-tabs`,stretch:``},{default:g(()=>[o(C,{label:e.$t(`producer.mode.simple`),name:`simple`},{default:g(()=>[n(`div`,Fn,[o(m,{class:`mb-4`}),o(_,{class:`mb-4`}),o(v,{class:`mb-4`}),e.config?.action===`extend`?(l(),a(y,{key:0,class:`mb-4`})):p(``,!0),e.config?.action===`cover`?(l(),a(b,{key:1,class:`mb-4`})):p(``,!0),e.config?.action===`replace_section`?(l(),a(x,{key:2,class:`mb-4`})):p(``,!0),o(S,{class:`mb-4`})])]),_:1},8,[`label`]),o(C,{label:e.$t(`producer.mode.custom`),name:`custom`},{default:g(()=>[n(`div`,In,[o(m,{class:`mb-4`}),o(_,{class:`mb-4`}),e.config?.instrumental?p(``,!0):(l(),a(w,{key:0,class:`mb-4`})),o(T,{class:`mb-4`}),o(E,{class:`mb-4`}),e.config?.instrumental?p(``,!0):(l(),a(D,{key:1,class:`mb-4`})),e.config?.action===`extend`?(l(),a(y,{key:2,class:`mb-4`})):p(``,!0),e.config?.action===`cover`?(l(),a(b,{key:3,class:`mb-4`})):p(``,!0),e.config?.action===`replace_section`?(l(),a(x,{key:4,class:`mb-4`})):p(``,!0),o(S,{class:`mb-4`})])]),_:1},8,[`label`])]),_:1},8,[`modelValue`])]),n(`div`,Ln,[o(k,{value:e.consumption,service:e.service},null,8,[`value`,`service`]),n(`div`,Rn,[o(j,{class:`flex-1`,onClick:e.onClearAll},{default:g(()=>[o(A,{icon:`fa-solid fa-broom`,class:`mr-1`}),i(` `+c(e.$t(`producer.button.clear_all`)),1)]),_:1},8,[`onClick`]),o(j,{type:`primary`,class:`flex-1`,round:``,onClick:e.onGenerate},{default:g(()=>[o(A,{icon:`fa-solid fa-magic`,class:`mr-2`}),i(` `+c(e.generateButtonText),1)]),_:1},8,[`onClick`])])])])}var Bn=U(Mn,[[`render`,zn],[`__scopeId`,`data-v-4a4b209e`]]),Vn=ge(),Hn=r({name:`TaskPreview`,components:{ElImage:A,ElIcon:C,ElTooltip:k,FontAwesomeIcon:X,VideoPlay:S,VideoPause:x,ElDropdown:ne,ElDropdownMenu:te,ElDropdownItem:I,Loading:b,ApiCodeDialog:fe},props:{modelValue:{type:Object,required:!0}},data(){return{isFetchingVideoUrl:!1,isFetchingWav:!1,apiCodeVisible:!1,apiCodePath:`/producer/audios`,apiCodeBody:{}}},computed:{loading(){return this.$store.state.producer?.status?.getApplications===W.Request},credential(){return this.$store.state.producer.credential},config(){return this.$store.state.producer.config},task(){return this.$store.state.producer?.tasks},audios(){let e=this.modelValue?.response?.data??[],t=this.modelValue?.request?.action;return t?e.map(e=>({...e,action:t})):e},application(){return this.$store.state.producer?.application},active(){return this.$store.state.producer?.tasks?.active}},methods:{useFormatDuring:Q,onViewCode(){let e=this.modelValue?.request||{},t={};Object.entries(e).forEach(([e,n])=>{e===`application_id`||e===`callback_url`||n!=null&&(typeof n==`string`&&n===``||Array.isArray(n)&&n.length===0||(t[e]=n))}),this.apiCodeBody=t,this.apiCodePath=`/producer/audios`,this.apiCodeVisible=!0},onPlay(e){this.$store.dispatch(`producer/setAudio`,{...this.$store.state.producer.audio,...e,state:`playing`}),console.log(`on play`)},onPause(e){this.$store.dispatch(`producer/setAudio`,{...this.$store.state.producer.audio,...e,state:`paused`}),console.log(`on pause`)},onClick(e){this.$store.state?.producer?.audio?.id!==e.id&&this.onPlay({...e,progress:0})},onExtend(e,t){e?.stopPropagation(),console.debug(`set config`,t),this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.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();let n=new URL(t).pathname,r=n.substring(n.lastIndexOf(`/`)+1);fetch(t).then(e=>e.blob()).then(e=>{(0,Vn.saveAs)(e,r)})},async handleVideoDownload(e){if(e.video_url){this.onDownload(null,e.video_url);return}if(!this.isFetchingVideoUrl)try{this.isFetchingVideoUrl=!0;let t=await this.fetchVideoUrlFromApi(e?.id);console.log(`get videoUrl: ${t}`),e.video_url=t,this.onDownload(null,t)}catch(e){console.error(`get videoUrl failed:`,e),Y.error(this.$t(`producer.message.getVideoUrlFailed`))}finally{this.isFetchingVideoUrl=!1}},async fetchVideoUrlFromApi(e){return new Promise((t,n)=>{let r={audio_id:e},i=this.credential?.token;if(!i){console.error(`no token specified`),n(Error(`No token specified`));return}J.video(r,{token:i}).then(e=>{let r=e.data?.data?.video_url;r?t(r):n(Error(`Video URL not found in response`))}).catch(e=>{n(e)})})},onPreview(e,t){e?.stopPropagation(),window.open(t,`_blank`)},async onGetStems(e){await this.onGenerateAudioUrl(`stems`,e)},onCover(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,model:e.model,custom:!0,instrumental:!1,style:e.style,action:`cover`,audio:e,audio_id:e.id})},onVariation(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,model:e.model,custom:!0,style:e.style,action:`variation`,audio:e,audio_id:e.id})},async onSwapVocals(e){await this.onGenerateAudioUrl(`swap_vocals`,e)},async onSwapInstrumentals(e){await this.onGenerateAudioUrl(`swap_instrumentals`,e)},async onGetAllStems(e){await this.onGenerateAudioUrl(`all_stems`,e)},onReplaceSection(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,model:e.model,custom:!0,instrumental:!1,style:e.style,action:`replace_section`,audio:e,audio_id:e.id,replace_section_start:0,replace_section_end:Math.min(30,e.duration||30)})},async handleWavDownload(e){if(!e?.id||this.isFetchingWav)return;let t=this.credential?.token;if(t)try{this.isFetchingWav=!0,Y.info(this.$t(`producer.message.fetchingWav`));let n=(await J.wav({audio_id:e.id},{token:t})).data?.data,r=Array.isArray(n)?n[0]?.file_url:n?.file_url||n?.audio_url;r?this.onDownload(null,r):Y.error(this.$t(`producer.message.fetchWavFailed`))}catch{Y.error(this.$t(`producer.message.fetchWavFailed`))}finally{this.isFetchingWav=!1}},async onGenerateAudioUrl(e,t){let n={action:e,audio_id:t,async:!0},r=this.credential?.token;if(!r){console.error(`no token specified`);return}Y.info(this.$t(`producer.message.startingTask`)),J.audio(n,{token:r}).then(()=>{Y.success(this.$t(`producer.message.startTaskSuccess`))}).catch(e=>{Y.error(e?.response?.data?.error?.message||this.$t(`producer.message.startTaskFailed`))}).finally(async()=>{await this.onGetTasks(),await this.onScrollDown()})},async onScrollDown(){setTimeout(()=>{let e=document.querySelector(`.tasks`);e&&(e.scrollTop=e.scrollHeight)},1e3)},async onGetTasks(){if(this.loading){console.debug(`loading`);return}await this.$store.dispatch(`producer/getTasks`,{limit:30,offset:0})}}}),Un={class:`task`},Wn=[`onClick`],Gn={class:`left`},Kn=[`onClick`],qn=[`onClick`],Jn={key:2,class:`duration`},Yn={class:`info`},Xn={class:`title`},Zn={class:`style`},Qn={class:`right`},$n={class:`el-dropdown-link`},er={class:`flex items-center min-w-[120px]`},tr={class:`flex items-center min-w-[120px]`},nr={class:`el-dropdown-link`};function rr(r,f,_,v,y,b){let x=h(`el-image`),S=h(`video-pause`),C=h(`el-icon`),w=h(`video-play`),T=h(`font-awesome-icon`),E=h(`el-tooltip`),D=h(`Loading`),O=h(`el-dropdown-item`),k=h(`el-dropdown-menu`),A=h(`el-dropdown`),j=h(`api-code-dialog`),M=m(`loading`);return l(),t(`div`,Un,[(l(!0),t(s,null,e(r.audios,e=>(l(),t(`div`,{key:e.id,class:`audio`,onClick:u(t=>r.onClick(e),[`stop`])},[d((l(),t(`div`,Gn,[o(x,{src:e?.image_url,class:`cover`,fit:`cover`,lazy:``},null,8,[`src`]),e?.audio_url&&r.$store.state?.producer?.audio?.id===e.id&&r.$store.state?.producer?.audio?.state===`playing`?(l(),t(`div`,{key:0,class:`overlay`,onClick:u(t=>r.onPause(e),[`stop`])},[o(C,null,{default:g(()=>[o(S)]),_:1})],8,Kn)):p(``,!0),e?.audio_url&&(r.$store.state?.producer?.audio?.id!==e.id||r.$store.state?.producer?.audio?.id===e.id&&r.$store.state?.producer?.audio?.state===`paused`)?(l(),t(`div`,{key:1,class:`overlay`,onClick:u(t=>r.onPlay(e),[`stop`])},[o(C,null,{default:g(()=>[o(w)]),_:1})],8,qn)):p(``,!0),e?.duration?(l(),t(`div`,Jn,c(r.useFormatDuring(e?.duration)),1)):p(``,!0)])),[[M,!e?.audio_url]]),n(`div`,Yn,[n(`h2`,Xn,c(e?.title),1),n(`p`,Zn,c(e?.style),1)]),n(`div`,Qn,[o(A,null,{dropdown:g(()=>[o(k,null,{default:g(()=>[o(O,{disabled:r.isFetchingVideoUrl,onClick:t=>r.handleVideoDownload(e)},{default:g(()=>[n(`div`,er,[r.isFetchingVideoUrl?(l(),a(C,{key:0,class:`is-loading mr-2`},{default:g(()=>[o(D)]),_:1})):p(``,!0),n(`span`,null,c(r.$t(`producer.button.download_video`)),1)])]),_:1},8,[`disabled`,`onClick`]),e?.audio_url?(l(),a(O,{key:0,onClick:u(t=>r.onDownload(t,e?.audio_url),[`stop`])},{default:g(()=>[i(c(r.$t(`producer.button.download_audio`)),1)]),_:1},8,[`onClick`])):p(``,!0),o(O,{disabled:r.isFetchingWav,onClick:t=>r.handleWavDownload(e)},{default:g(()=>[n(`div`,tr,[r.isFetchingWav?(l(),a(C,{key:0,class:`is-loading mr-2`},{default:g(()=>[o(D)]),_:1})):p(``,!0),n(`span`,null,c(r.$t(`producer.button.download_wav`)),1)])]),_:1},8,[`disabled`,`onClick`])]),_:2},1024)]),default:g(()=>[n(`span`,$n,[o(E,{effect:`dark`,content:r.$t(`producer.button.download`),placement:`top`},{default:g(()=>[e?.audio_url||e?.video_url?(l(),a(T,{key:0,icon:`fa-solid fa-download`,class:`icon icon-download`})):p(``,!0)]),_:2},1032,[`content`])])]),_:2},1024),o(A,null,{dropdown:g(()=>[o(k,null,{default:g(()=>[e?.audio_url?(l(),a(O,{key:0,onClick:u(t=>r.onExtend(t,e),[`stop`])},{default:g(()=>[i(c(r.$t(`producer.button.extend`)),1)]),_:1},8,[`onClick`])):p(``,!0),e.id?(l(),a(O,{key:1,onClick:u(t=>r.onGetStems(e.id),[`stop`])},{default:g(()=>[i(c(r.$t(`producer.button.get_stems`)),1)]),_:1},8,[`onClick`])):p(``,!0),e.id?(l(),a(O,{key:2,onClick:u(t=>r.onGetAllStems(e.id),[`stop`])},{default:g(()=>[i(c(r.$t(`producer.button.all_stems`)),1)]),_:1},8,[`onClick`])):p(``,!0),o(O,{onClick:u(t=>r.onCover(e),[`stop`])},{default:g(()=>[i(c(r.$t(`producer.button.cover_music`)),1)]),_:1},8,[`onClick`]),e?.id?(l(),a(O,{key:3,onClick:u(t=>r.onVariation(e),[`stop`])},{default:g(()=>[i(c(r.$t(`producer.button.variation`)),1)]),_:1},8,[`onClick`])):p(``,!0),e?.id?(l(),a(O,{key:4,onClick:u(t=>r.onSwapVocals(e.id),[`stop`])},{default:g(()=>[i(c(r.$t(`producer.button.swap_vocals`)),1)]),_:1},8,[`onClick`])):p(``,!0),e?.id?(l(),a(O,{key:5,onClick:u(t=>r.onSwapInstrumentals(e.id),[`stop`])},{default:g(()=>[i(c(r.$t(`producer.button.swap_instrumentals`)),1)]),_:1},8,[`onClick`])):p(``,!0),e?.id?(l(),a(O,{key:6,onClick:u(t=>r.onReplaceSection(e),[`stop`])},{default:g(()=>[i(c(r.$t(`producer.button.replace_section`)),1)]),_:1},8,[`onClick`])):p(``,!0),o(O,{onClick:u(r.onViewCode,[`stop`])},{default:g(()=>[o(T,{icon:`fa-solid fa-code`,class:`mr-1`}),i(` `+c(r.$t(`common.button.viewCode`)),1)]),_:1},8,[`onClick`])]),_:2},1024)]),default:g(()=>[n(`span`,nr,[o(E,{effect:`dark`,content:r.$t(`producer.button.more`),placement:`top`},{default:g(()=>[e?.audio_url||e?.video_url?(l(),a(T,{key:0,icon:`fa-solid fa-ellipsis`,class:`icon icon-ellipsis`})):p(``,!0)]),_:2},1032,[`content`])])]),_:2},1024)])],8,Wn))),128)),o(j,{visible:r.apiCodeVisible,"onUpdate:visible":f[0]||=e=>r.apiCodeVisible=e,method:`POST`,path:r.apiCodePath,body:r.apiCodeBody,token:r.$store.state.producer?.credential?.token||``},null,8,[`visible`,`path`,`body`,`token`])])}var ir=r({name:`RecentPanel`,components:{ElSkeletonItem:re,ElSkeleton:ie,TaskPreview:U(Hn,[[`render`,rr]]),Player:_e,NoTasks:me,ScrollList:de},props:{loading:{type:Boolean,default:!1}},emits:[`reach-top`],data(){return{job:0}},computed:{tasks(){return{...this.$store.state.producer?.tasks,items:this.$store.state.producer?.tasks?.items?.slice()}}},methods:{getScrollElement(){return this.$refs.scrollList?.getScrollElement?.()}}}),ar={key:0,class:`tasks`},or={class:`left w-[70px] p-[10px] flex items-center`},sr={class:`main w-[calc(100%-70px)] flex-1 p-[10px]`},$={key:2,class:`w-full flex-1 flex items-center justify-center`},cr={class:`h-20`};function lr(r,i,c,u,f,m){let v=h(`el-skeleton-item`),y=h(`el-skeleton`),b=h(`task-preview`),x=h(`scroll-list`),S=h(`no-tasks`),C=h(`player`);return l(),t(s,null,[r.tasks?.items===void 0?(l(),t(`div`,ar,[(l(),t(s,null,e(3,e=>n(`div`,{key:e,class:`flex`},[n(`div`,or,[o(y,{animated:``},{template:g(()=>[o(v,{variant:`image`,class:`avatar w-[50px] h-[50px]`})]),_:1})]),n(`div`,sr,[o(y,{animated:``},{template:g(()=>[o(v,{variant:`p`,class:`w-[200px] h-[15px] mb-[5px] mt-[10px]`}),o(v,{variant:`text`})]),_:1})])])),64))])):r.tasks?.items?.length&&r.tasks?.items?.length>0?(l(),a(x,{key:1,ref:`scrollList`,class:`flex-1 w-full overflow-y-auto tasks p-2`,loading:r.loading,onReachTop:i[0]||=e=>r.$emit(`reach-top`)},{default:g(()=>[(l(!0),t(s,null,e(r.tasks?.items,(e,t)=>(l(),a(b,{key:t,"model-value":e,class:`preview`},null,8,[`model-value`]))),128))]),_:1},8,[`loading`])):p(``,!0),r.tasks?.items?.length===0?(l(),t(`div`,$,[o(S)])):p(``,!0),d(n(`div`,cr,[o(C,{namespace:`producer`})],512),[[_,!!r.$store?.state?.producer?.audio?.object]])],64)}var ur=U(ir,[[`render`,lr]]),dr=r({name:`TaskPreview`,components:{IconPicture:y,ElImage:A,ElAvatar:j,ElIcon:C},computed:{audio(){return this.$store.state.producer?.audio}}}),fr={key:0,class:`size-full overflow-hidden`},pr={class:`relative h-[300px]`},mr={class:`flex items-center justify-center size-full bg-[var(--el-bg-color)]`},hr={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`},gr={class:`p-4`},_r={class:`flex items-center font-bold mb-2`},vr={class:`text-[var(--el-text-color-regular)] mb-2`},yr={class:`text-xs text-[var(--el-text-color-regular)]`},br={class:`mt-4 text-sm leading-[25px] whitespace-pre-wrap`},xr={key:1,class:`w-full h-full`};function Sr(e,r,i,a,s,u){let d=h(`icon-picture`),f=h(`el-icon`),p=h(`el-image`),m=h(`el-avatar`);return e.audio?.object?(l(),t(`div`,fr,[n(`div`,pr,[o(p,{src:e.audio.image_url,fit:`cover`,class:`size-full`},{error:g(()=>[n(`div`,mr,[o(f,{class:`text-3xl`},{default:g(()=>[o(d)]),_:1})])]),_:1},8,[`src`]),n(`h2`,hr,c(e.audio?.title),1)]),n(`div`,gr,[n(`div`,_r,[o(m,{size:30,src:e.audio?.image_url,class:`mr-2`},null,8,[`src`]),n(`span`,null,c(e.audio?.title),1)]),n(`p`,vr,c(e.audio?.style),1),n(`p`,yr,c(e.$dayjs.format(e.audio?.created_at)),1),n(`div`,br,[n(`p`,null,c(e.audio?.lyric),1)])])])):(l(),t(`div`,xr))}var Cr=r({name:`ProducerIndex`,components:{Layout:we,ConfigPanel:Bn,RecentPanel:ur,PreviewPanel:U(dr,[[`render`,Sr]])},mixins:[z],inject:[`initialized`],data(){return{task:void 0,job:0,loadingMore:!1,fetchingTasks:!1}},computed:{applicationsLoading(){return this.$store.state.producer?.status?.getApplications===W.Request},tasksLoading(){return this.$store.state.producer?.status?.getTasks===W.Request||this.fetchingTasks},service(){return this.$store.state.producer.service},credential(){return this.$store.state.producer.credential},config(){return this.$store.state.producer.config},initializing(){return this.$store.state.producer.status.getApplications===W.Request},needApply(){return this.$store.state.producer.status.getApplications===W.Success&&!this.application},application(){return this.$store.state.producer.application},tasks(){return this.$store.state.producer.tasks},applications(){return this.$store.state.producer.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=window.setInterval(()=>{this.onGetTasks()},5e3))},immediate:!0}},async mounted(){await this.onGetService()},async unmounted(){window.clearInterval(this.job)},methods:{async onReachTop(){await pe({tasks:this.tasks,getTasks:()=>this.tasks,loading:this.loadingMore,setLoading:e=>this.loadingMore=e,isBlocked:()=>this.tasksLoading||this.applicationsLoading,fetch:e=>this.onGetTasks({createdAtMax:e}),getScrollElement:()=>this.getTasksScrollElement()})},async onGetService(){console.debug(`start onGetService`),await this.$store.dispatch(`producer/getService`),console.debug(`end onGetService`)},async onGetApplication(){console.debug(`start onGetApplications`),await this.$store.dispatch(`producer/getApplications`),console.debug(`end onGetApplications`),await this.onGetTasks()},onApply(){q.create({application:this.application}).then(({data:e})=>{this.application=e,Y.success(this.$t(`application.message.applySuccessfully`))}).catch(e=>{e?.response?.data?.code===`duplication`&&Y.error(this.$t(`application.message.alreadyApplied`))})},async onScrollDown(){await this.$nextTick();let e=this.getTasksScrollElement();e&&(e.scrollTop=e.scrollHeight)},async onGetTasks(e){if(this.applicationsLoading||this.fetchingTasks){console.debug(`loading`);return}console.debug(`start onGetTasks`,e);let{limit:t=5,createdAtMin:n,createdAtMax:r}=e||{};console.debug(`limit`,t,`createdAtMin`,n,`createdAtMax`,r),this.fetchingTasks=!0;try{await this.$store.dispatch(`producer/getTasks`,{limit:t,createdAtMin:n,createdAtMax:r})}finally{this.fetchingTasks=!1}},async onGenerateAudio(){if(!G(this.uploadTracker,e=>this.$t(e),e=>Y.warning(e)))return;let e={...this.config,async:!0};if(!se())return;let t=this.credential?.token;if(!t){console.error(`no token specified`);return}Y.info(this.$t(`producer.message.startingTask`)),B(`producer`,J.audio(e,{token:t})).then(()=>{Y.success(this.$t(`producer.message.startTaskSuccess`))}).catch(e=>{Y.error(e?.response?.data?.error?.message||this.$t(`producer.message.startTaskFailed`))}).finally(async()=>{setTimeout(async()=>{await this.onGetTasks(),await this.onScrollDown()},1e3)})},getTasksScrollElement(){return this.$refs.recentPanel?.getScrollElement?.()}}});function wr(e,t,n,r,i,s){let c=h(`config-panel`),u=h(`recent-panel`),d=h(`preview-panel`),f=h(`layout`);return l(),a(f,null,{config:g(()=>[o(c,{onGenerate:e.onGenerateAudio},null,8,[`onGenerate`])]),result:g(()=>[o(u,{ref:`recentPanel`,class:`panel recent`,loading:e.loadingMore,onReachTop:e.onReachTop},null,8,[`loading`,`onReachTop`])]),preview:g(()=>[o(d)]),_:1})}var Tr=U(Cr,[[`render`,wr],[`__scopeId`,`data-v-23eb99dc`]]);export{Tr as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime--c01j_DQ.js";import{D as e,F as t,O as n,P as r,Wt as i,Z as a,dt as o,nt as s,tt as c,ut as l}from"./vendor-chart-BJCvKk8-.js";import{n as u,t as d}from"./table-B5c9kfrJ.js";import{t as f}from"./card-DjyfNde2.js";import{n as p,t as m}from"./row-
|
|
1
|
+
import"./rolldown-runtime--c01j_DQ.js";import{D as e,F as t,O as n,P as r,Wt as i,Z as a,dt as o,nt as s,tt as c,ut as l}from"./vendor-chart-BJCvKk8-.js";import{n as u,t as d}from"./table-B5c9kfrJ.js";import{t as f}from"./card-DjyfNde2.js";import{n as p,t as m}from"./row-B5bv9JPh.js";import{t as h}from"./Pagination-CEMukh4X.js";import{O as g,Un as _}from"./index-BwuZeZD0.js";import{t as v}from"./CopyToClipboard-B8J4icuV.js";var y=t({name:`ConsoleDistributionInvitees`,components:{Pagination:h,CopyToClipboard:v,ElRow:m,ElCol:p,ElTable:d,ElTableColumn:u,ElCard:f},data(){return{invitees:[],loading:!1,total:void 0,limit:10}},computed:{redirect(){return this.$route.query.redirect},page(){return parseInt(this.$route.query.page?.toString()||`1`)}},watch:{page:{handler(){this.onFetchData()}}},mounted(){this.onFetchData()},methods:{onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{page:e}})},onFetchData(){this.loading=!0,Promise.all([this.onFetchInvitees()]).finally(()=>{this.loading=!1})},async onFetchInvitees(){let{data:e}=await _.getInvitees({limit:this.limit,offset:(this.page-1)*this.limit,ordering:`-created_at`});this.invitees=e.items,this.total=e.count}}}),b={class:`title`},x={class:`key`},S={class:`copy`},C={class:`description`},w={class:`description`},T={class:`description`},E={class:`created-at`},D={class:`pagination m-v-lg`};function O(t,u,d,f,p,m){let h=c(`el-col`),g=c(`el-row`),_=c(`copy-to-clipboard`),v=c(`el-table-column`),y=c(`el-table`),O=c(`el-card`),k=c(`pagination`),A=s(`loading`);return a(),n(g,{class:`panel`},{default:l(()=>[r(h,{span:24},{default:l(()=>[r(g,null,{default:l(()=>[r(h,{span:24},{default:l(()=>[e(`h2`,b,i(t.$t(`common.title.invitee`)),1)]),_:1})]),_:1}),r(g,null,{default:l(()=>[r(h,{span:24},{default:l(()=>[r(O,{shadow:`hover`},{default:l(()=>[o((a(),n(y,{data:t.invitees,stripe:``},{default:l(()=>[r(v,{prop:`id`,label:t.$t(`user.field.id`),"class-name":`text-center`,width:`350px`},{default:l(t=>[e(`span`,x,i(t.row.id),1),e(`span`,S,[r(_,{content:t.row.id},null,8,[`content`])])]),_:1},8,[`label`]),r(v,{label:t.$t(`user.field.username`),width:`300px`},{default:l(t=>[e(`span`,C,i(t.row?.username),1)]),_:1},8,[`label`]),r(v,{label:t.$t(`user.field.email`),width:`300px`},{default:l(t=>[e(`span`,w,i(t.row?.email),1)]),_:1},8,[`label`]),r(v,{label:t.$t(`user.field.nickname`),width:`200px`},{default:l(t=>[e(`span`,T,i(t.row.nickname),1)]),_:1},8,[`label`]),r(v,{label:t.$t(`user.field.dateJoined`)},{default:l(n=>[e(`span`,E,i(t.$dayjs.format(n.row.date_joined)),1)]),_:1},8,[`label`])]),_:1},8,[`data`])),[[A,t.loading]])]),_:1})]),_:1})]),_:1}),r(g,null,{default:l(()=>[r(h,{span:10,offset:14},{default:l(()=>[e(`div`,D,[r(k,{"current-page":t.page,"page-size":t.limit,total:t.total,onChange:t.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var k=g(y,[[`render`,O],[`__scopeId`,`data-v-4556864d`]]);export{k as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,a as u,c as d,dt as f,i as ee,k as p,n as m,nt as h,o as g,r as _,s as v,t as y,tt as b,ut as x,v as S}from"./vendor-chart-BJCvKk8-.js";import{t as C}from"./button-BydTr5nV.js";import{r as w,t as T}from"./select-DBWrapm4.js";import{n as E,t as D}from"./table-B5c9kfrJ.js";import{n as O,t as k}from"./tabs-B0ZFbaaU.js";import{t as A}from"./card-DjyfNde2.js";import{n as j,r as M}from"./radio-3Hz7h3DR.js";import{t as N}from"./date-picker-DFSkI2T1.js";import{n as P,t as F}from"./row-Sw1tNXnG.js";import{t as I}from"./Pagination-Bx16Gkpp.js";import{n as L,t as R}from"./skeleton-BwNBivMN.js";import{Bn as z,Hr as B,Mr as V,O as H,Rn as U,Tr as W,Wn as G,Wr as K,wr as q,zn as J}from"./index-DoCEzMzZ.js";import{t as Y}from"./index.es-CDSdB7LL.js";import{t as X}from"./CopyToClipboard-BqsCWkad.js";ee.register(_,u,m,v,d,g);var Z=r({name:`ConsoleUsageList`,components:{Pagination:I,ElTag:K,ElDatePicker:N,ElTable:D,ElSelect:w,ElOption:T,CopyToClipboard:X,ElRow:F,ElCol:P,ElTableColumn:E,ElCard:A,ElRadioButton:j,ElRadioGroup:M,ElSkeleton:R,ElSkeletonItem:L,ElDialog:B,ElTabs:O,ElTabPane:k,ElButton:C,FontAwesomeIcon:Y,BarChart:y},data(){return{applicationIds:this.$route.query.application_id?.toString()?this.$route.query.application_id?.toString().split(`,`):[],apiIds:this.$route.query.api_id?.toString()?this.$route.query.api_id?.toString().split(`,`):[],applications:[],apis:[],apisLoading:!1,credentialType:q,serviceType:W,apiUsages:[],proxyUsages:[],createdAtRange:(()=>{let e=this.$route.query.created_at_to?.toString(),t=this.$route.query.created_at_from?.toString();if(t&&e)return[new Date(t),new Date(e)];let n=new Date,r=new Date;return r.setDate(1),r.setHours(0,0,0,0),[r,n]})(),shortcuts:[{text:this.$t(`usage.shortcuts.thisMonth`),value:()=>{let e=new Date,t=new Date;return t.setDate(1),t.setHours(0,0,0,0),[t,e]}},{text:this.$t(`usage.shortcuts.today`),value:()=>{let e=new Date,t=new Date;return t.setHours(0,0,0,0),[t,e]}},{text:this.$t(`usage.shortcuts.last1Day`),value:()=>{let e=new Date,t=new Date;return t.setDate(t.getDate()-1),[t,e]}},{text:this.$t(`usage.shortcuts.last3Days`),value:()=>{let e=new Date,t=new Date;return t.setDate(t.getDate()-3),[t,e]}},{text:this.$t(`usage.shortcuts.last7Days`),value:()=>{let e=new Date,t=new Date;return t.setDate(t.getDate()-7),[t,e]}},{text:this.$t(`usage.shortcuts.last1Month`),value:()=>{let e=new Date,t=new Date;return t.setMonth(t.getMonth()-1),[t,e]}}],type:this.$route.query.type?.toString()||W.API,loading:!1,total:void 0,limit:15,totalUsed:0,barChartLabels:[],barChartSeries:[],aggLoading:!1,detailDialogVisible:!1,detailRow:null,detailActiveTab:`request`,detailLoading:!1,exporting:!1,statusCodeFilter:this.$route.query.status_code?.toString()||``,statusCodeOptions:[],statusCodeOptionsLoading:!1}},computed:{redirect(){return this.$route.query?.redirect},page(){return parseInt(this.$route.query.page?.toString()||`1`)},totalUsedString(){return`${(this.totalUsed||0).toFixed(2)}`},barChartData(){return{labels:this.barChartLabels,datasets:this.barChartSeries.map(e=>({label:e.label,data:e.data,backgroundColor:e.color}))}},barChartOptions(){return{responsive:!0,plugins:{legend:{position:`top`,onClick:(e,t,n)=>{let r=n?.chart;if(!r||t?.datasetIndex===void 0)return;let i=t.datasetIndex,a=r.data?.datasets||[];a.some((e,t)=>t!==i&&r.isDatasetVisible(t))?a.forEach((e,t)=>r.setDatasetVisibility(t,t===i)):a.forEach((e,t)=>r.setDatasetVisibility(t,!0)),r.update()}},title:{display:!0,text:this.$t(`usage.title.usageTrend`)}},scales:{x:{stacked:!0},y:{stacked:!0,beginAtZero:!0}}}}},watch:{page:{handler(){this.onFetchUsages()}},type:{handler(){this.applicationIds=[],this.apiIds=[],this.onApplicationsChange(this.applicationIds),this.onFetchApplications(),this.onFetchApis(),this.onFetchUsages(),this.onFetchAggregate(),this.onFetchStatusCodeOptions()}}},mounted(){this.onFetchApplications(),this.onFetchApis(),this.onFetchUsages(),this.onFetchAggregate(),this.onFetchStatusCodeOptions()},methods:{async onFetchUsages(){this.type===W.API?this.onFetchApiUsages():this.type===W.Proxy&&this.onFetchProxyUsages()},async onApiChange(e){await this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,api_id:e}}),this.onFetchApiUsages(),this.onFetchAggregate()},async onApisChange(e){await this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,api_id:e&&e.length?e.join(`,`):``}}),this.onFetchApiUsages(),this.onFetchAggregate()},async onTimeRangeChanged(){console.log(`onTimeRangeChanged`,this.createdAtRange),await this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,created_at_from:this.createdAtRange?this.$dayjs.format(this.createdAtRange[0].toString(),`YYYY-MM-DDTHH:mm:ss.SSSSSSZ`):``,created_at_to:this.createdAtRange?this.$dayjs.format(this.createdAtRange[1].toString(),`YYYY-MM-DDTHH:mm:ss.SSSSSSZ`):``}}),this.onFetchUsages(),this.onFetchAggregate(),this.onFetchStatusCodeOptions()},async onApplicationChange(e){await this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,application_id:e}}),this.onFetchUsages(),this.onFetchAggregate()},async onApplicationsChange(e){await this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,application_id:e&&e.length?e.join(`,`):``}}),this.onFetchUsages(),this.onFetchAggregate()},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,page:e}})},getRemainingAmount(e){if(e.remaining_amount===void 0||e.remaining_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.remaining_amount?.toFixed(6)} ${t}`},getUsedAmount(e){if(e.used_amount===void 0||e.used_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.used_amount?.toFixed(6)} ${t}`},getDeductedAmount(e){if(e?.deducted_amount===void 0||e?.deducted_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.deducted_amount?.toFixed(6)} ${t}`},getOriginalAmount(e){if(e?.original_amount===void 0||e?.original_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.original_amount?.toFixed(6)} ${t}`},onStatusCodeChange(e){let t={...this.$route.query},n=(e||``).trim();n?t.status_code=n:delete t.status_code,delete t.status_code_filter,this.$router.push({name:this.$route.name?.toString(),query:t}),this.onFetchUsages(),this.onFetchAggregate()},async onFetchStatusCodeOptions(){this.statusCodeOptionsLoading=!0;try{let{data:e}=await J.getStatusCodes({user_id:this.$store.getters.user.id,...this.applicationIds&&this.applicationIds.length?{application_id:this.applicationIds}:{},...this.apiIds&&this.apiIds.length?{api_id:this.apiIds}:{},...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0]}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1]}:{}});this.statusCodeOptions=(e?.items||[]).slice().sort((e,t)=>e-t)}catch{this.statusCodeOptions=[]}finally{this.statusCodeOptionsLoading=!1}},formatElapsed(e){return e==null||Number.isNaN(e)?`-`:e<1?`${Math.round(e*1e3)} ms`:`${e.toFixed(2)} s`},getSimpleMetadata(e){if(!e)return{};let t={};for(let[n,r]of Object.entries(e))n===`request`||n===`response`||typeof r==`object`&&r||(t[n]=r);return t},onShowDetail(e){this.detailRow={...e,metadata:void 0},this.detailActiveTab=`request`,this.detailDialogVisible=!0,this.detailLoading=!0,e.id&&J.get(e.id).then(e=>{this.detailRow=e.data}).finally(()=>{this.detailLoading=!1})},formatJson(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}},onFetchApplications(){G.getAll({limit:100,offset:0,user_id:this.$store.getters.user.id,ordering:`-created_at`,type:V.USAGE}).then(({data:e})=>{this.applications=e.items.filter(e=>e?.service?.type===this.type)}).catch(()=>{})},onFetchApis(){this.apisLoading=!0,U.getAll({limit:100,offset:0,ordering:`-created_at`}).then(({data:e})=>{this.apis=e.items}).catch(()=>{}).finally(()=>{this.apisLoading=!1})},onFetchApiUsages(){console.log(`onFetchApiUsages`,this.createdAtRange),this.loading=!0,J.getAll({limit:this.limit,offset:(this.page-1)*this.limit,user_id:this.$store.getters.user.id,ordering:`-created_at`,...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0]}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1]}:{},...this.applicationIds&&this.applicationIds.length?{application_id:this.applicationIds}:{},...this.apiIds&&this.apiIds.length?{api_id:this.apiIds}:{},...this.statusCodeFilter?{status_code:this.statusCodeFilter}:{}}).then(({data:e})=>{this.apiUsages=e.items,this.loading=!1,this.total=e.count}).catch(()=>{this.loading=!1})},onFetchProxyUsages(){this.loading=!0,z.getAll({limit:this.limit,offset:(this.page-1)*this.limit,user_id:this.$store.getters.user.id,ordering:`-created_at`,...this.applicationIds&&this.applicationIds.length?{application_id:this.applicationIds}:{}}).then(({data:e})=>{this.proxyUsages=e.items,this.loading=!1,this.total=e.count}).catch(()=>{this.loading=!1})},onExport(){this.exporting=!0,J.exportCsv({user_id:this.$store.getters.user.id,...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0]}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1]}:{},...this.applicationIds&&this.applicationIds.length?{application_id:this.applicationIds}:{},...this.apiIds&&this.apiIds.length?{api_id:this.apiIds}:{},...this.statusCodeFilter?{status_code:this.statusCodeFilter}:{}}).then(({data:e})=>{let t=window.URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`usages.csv`,n.click(),window.URL.revokeObjectURL(t)}).catch(()=>{}).finally(()=>{this.exporting=!1})},async onFetchAggregate(){if(this.aggLoading=!0,this.type!==this.serviceType.API)return;let e={user_id:this.$store.getters.user.id,...this.applicationIds&&this.applicationIds.length?{application_id:this.applicationIds}:{},...this.apiIds&&this.apiIds.length?{api_id:this.apiIds}:{},...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0]}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1]}:{}};try{let{data:t}=await J.getAggregate(e);this.totalUsed=t.total||0;let n=Array.from(new Set((t.items||[]).map(e=>e.date))).sort(),r=Array.from(new Set((t.items||[]).map(e=>e.api_id))),i=e=>`hsl(${e*57%360}, 70%, 60%)`,a=r.map((e,r)=>{let a=t.apis?.[e]?.title||e,o={};return(t.items||[]).filter(t=>t.api_id===e).forEach(e=>{o[e.date]=e.amount||0}),{key:e,label:a,data:n.map(e=>o[e]||0),color:i(r)}});this.barChartLabels=n,this.barChartSeries=a}finally{this.aggLoading=!1}}}}),Q={class:`text-[26px] font-bold mb-5 text-[var(--el-text-color-primary)]`},$={class:`inline-block w-9`},te={class:`inline-block`},ne={key:1,class:`summary-card`},re={class:`icon-wrapper`},ie={class:`text-left`},ae={class:`description`},oe={class:`value`},se={class:`chart-wrapper`},ce={key:0},le={key:1},ue={class:`flex flex-wrap gap-2`},de={class:`key`},fe={key:0,class:`cursor-pointer`},pe={class:`created-at`},me={class:`created-at`},he={key:1,class:`detail-json`},ge={key:2,class:`text-gray-400`},_e={key:1,class:`detail-json`},ve={key:2,class:`text-gray-400`},ye={class:`float-right`};function be(r,u,d,ee,m,g){let _=b(`el-col`),v=b(`el-row`),y=b(`el-radio-button`),C=b(`el-radio-group`),w=b(`el-option`),T=b(`el-select`),E=b(`el-skeleton-item`),D=b(`el-skeleton`),O=b(`el-date-picker`),k=b(`font-awesome-icon`),A=b(`el-button`),j=b(`el-card`),M=b(`bar-chart`),N=b(`el-table-column`),P=b(`el-tag`),F=b(`copy-to-clipboard`),I=b(`el-table`),L=b(`el-tab-pane`),R=b(`el-tabs`),z=b(`el-dialog`),B=b(`pagination`),V=h(`loading`);return l(),a(v,null,{default:x(()=>[o(_,{span:24},{default:x(()=>[o(v,null,{default:x(()=>[o(_,{span:24},{default:x(()=>[n(`h2`,Q,c(r.$t(`common.title.allUsages`)),1)]),_:1})]),_:1}),o(v,null,{default:x(()=>[o(_,{md:4,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:x(()=>[n(`span`,null,c(r.$t(`application.field.type`)),1),o(C,{modelValue:r.type,"onUpdate:modelValue":u[0]||=e=>r.type=e},{default:x(()=>[o(y,{value:r.serviceType.API,label:r.$t(`application.field.api`)},null,8,[`value`,`label`]),o(y,{value:r.serviceType.Proxy,label:r.$t(`application.field.proxy`)},null,8,[`value`,`label`])]),_:1},8,[`modelValue`])]),_:1}),f(o(_,{md:6,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:x(()=>[n(`span`,$,c(r.$t(`usage.field.application`)),1),o(T,{modelValue:r.applicationIds,"onUpdate:modelValue":u[1]||=e=>r.applicationIds=e,placeholder:r.$t(`usage.field.application`),clearable:``,multiple:``,"collapse-tags":``,"collapse-tags-tooltip":``,class:`w-full`,onChange:r.onApplicationsChange},{default:x(()=>[(l(!0),t(s,null,e(r.applications,e=>(l(),a(w,{key:e.id,label:e.service?.title,value:e?.id},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`])]),_:1},512),[[S,!1]]),r.type===r.serviceType.API?(l(),a(_,{key:0,md:6,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:x(()=>[n(`span`,te,c(r.$t(`usage.field.api`)),1),r.apisLoading?(l(),a(D,{key:0,animated:``,class:`w-full`},{template:x(()=>[o(E,{variant:`rect`,style:{height:`32px`,"border-radius":`4px`}})]),_:1})):(l(),a(T,{key:1,modelValue:r.apiIds,"onUpdate:modelValue":u[2]||=e=>r.apiIds=e,placeholder:r.$t(`usage.field.api`),clearable:``,filterable:``,multiple:``,"collapse-tags":``,"collapse-tags-tooltip":``,class:`w-full`,onChange:r.onApisChange},{default:x(()=>[(l(!0),t(s,null,e(r.apis,e=>(l(),a(w,{key:e?.id,label:e?.title,value:e?.id},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]))]),_:1})):p(``,!0),r.type===r.serviceType.API?(l(),a(_,{key:1,md:8,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:x(()=>[o(O,{modelValue:r.createdAtRange,"onUpdate:modelValue":u[3]||=e=>r.createdAtRange=e,type:`datetimerange`,class:`w-full`,shortcuts:r.shortcuts,"range-separator":r.$t(`usage.placeholder.to`),"start-placeholder":r.$t(`usage.placeholder.startDate`),"end-placeholder":r.$t(`usage.placeholder.endDate`),onChange:r.onTimeRangeChanged},null,8,[`modelValue`,`shortcuts`,`range-separator`,`start-placeholder`,`end-placeholder`,`onChange`])]),_:1})):p(``,!0),r.type===r.serviceType.API?(l(),a(_,{key:2,md:3,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:x(()=>[o(T,{modelValue:r.statusCodeFilter,"onUpdate:modelValue":u[4]||=e=>r.statusCodeFilter=e,placeholder:r.$t(`usage.option.statusCodeAll`),class:`w-full`,clearable:``,filterable:``,"allow-create":``,"default-first-option":``,loading:r.statusCodeOptionsLoading,onChange:r.onStatusCodeChange},{default:x(()=>[(l(!0),t(s,null,e(r.statusCodeOptions,e=>(l(),a(w,{key:e,label:String(e),value:String(e)},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`loading`,`onChange`])]),_:1})):p(``,!0),r.type===r.serviceType.API?(l(),a(_,{key:3,md:3,xs:24,class:`mb-5 flex px-2 gap-2 items-center justify-end`},{default:x(()=>[o(A,{type:`primary`,plain:``,loading:r.exporting,class:`w-full whitespace-nowrap`,onClick:r.onExport},{default:x(()=>[o(k,{icon:`fa-solid fa-file-export`,class:`mr-1`}),i(` `+c(r.$t(`usage.button.export`)),1)]),_:1},8,[`loading`,`onClick`])]),_:1})):p(``,!0)]),_:1}),o(v,null,{default:x(()=>[o(_,{span:24},{default:x(()=>[r.type===r.serviceType.API?(l(),a(v,{key:0,gutter:24,class:`mb-5`},{default:x(()=>[o(_,{md:6,xs:24},{default:x(()=>[o(j,{shadow:`hover`,class:`h-full`},{default:x(()=>[r.aggLoading?(l(),a(D,{key:0})):(l(),t(`div`,ne,[n(`div`,re,[o(k,{icon:`fa-solid fa-cubes`,class:`icon`})]),n(`div`,ie,[n(`p`,ae,c(r.$t(`usage.title.totalUsed`)),1),n(`p`,oe,c(r.totalUsedString),1)])]))]),_:1})]),_:1}),o(_,{md:18,xs:24},{default:x(()=>[o(j,{shadow:`hover`,class:`h-full`},{default:x(()=>[n(`div`,se,[r.aggLoading?(l(),a(D,{key:0,class:`w-full`})):(l(),a(M,{key:1,data:r.barChartData,options:r.barChartOptions,class:`chart`},null,8,[`data`,`options`]))])]),_:1})]),_:1})]),_:1})):p(``,!0),o(j,{shadow:`hover`},{default:x(()=>[r.type===r.serviceType.API?f((l(),a(I,{key:0,data:r.apiUsages,stripe:``,"table-layout":`fixed`,"empty-text":r.$t(`common.message.noData`),class:`min-h-[calc(100vh-350px)] mb-5`},{default:x(()=>[o(N,{label:r.$t(`application.field.name`),width:`160px`},{default:x(e=>[n(`span`,null,c(e.row?.api?.title),1)]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.statusCode`),width:`120px`},{default:x(e=>[n(`span`,null,c(e.row.status_code),1)]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.elapsed`),width:`120px`},{default:x(e=>[n(`span`,null,c(r.formatElapsed(e.row.elapsed)),1)]),_:1},8,[`label`]),o(N,{prop:`deducted_amount`,label:r.$t(`usage.field.deductedAmount`),width:`150px`,"class-name":`text-center`},{default:x(e=>[r.getDeductedAmount(e.row)===r.getOriginalAmount(e.row)?(l(),t(`div`,ce,[n(`span`,null,c(r.getDeductedAmount(e.row)),1)])):(l(),t(`div`,le,[u[7]||=n(`p`,null,null,-1),n(`p`,null,[n(`span`,null,c(r.getDeductedAmount(e.row)),1)]),n(`p`,null,[n(`del`,null,c(r.getOriginalAmount(e.row)),1)])]))]),_:1},8,[`label`]),o(N,{prop:`remaining_amount`,label:r.$t(`usage.field.balanceAfter`),width:`160px`,"class-name":`text-center`},{default:x(e=>[n(`span`,null,c(r.getRemainingAmount(e.row)),1)]),_:1},8,[`label`]),o(N,{prop:`metadata`,label:r.$t(`usage.field.metadata`),width:`260px`,"class-name":`text-center`},{default:x(o=>[n(`div`,ue,[o.row.original_amount>o.row.deducted_amount&&o.row.original_amount>0?(l(),a(P,{key:0,type:`success`,style:{textWrap:`wrap`,height:`fit-content`,lineHeight:`20px`,borderRadius:`10px`}},{default:x(()=>[i(c(((o.row.original_amount-o.row.deducted_amount)*100/o.row.original_amount).toFixed(0)+`% OFF`),1)]),_:2},1024)):p(``,!0),(l(!0),t(s,null,e(r.getSimpleMetadata(o.row.metadata),(e,t)=>(l(),a(P,{key:t,style:{textWrap:`wrap`,height:`fit-content`,lineHeight:`20px`,borderRadius:`10px`}},{default:x(()=>[i(c(t)+`: `+c(e),1)]),_:2},1024))),128))])]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.button.viewDetail`),width:`120px`,"class-name":`text-center`},{default:x(e=>[e.row.id?(l(),a(A,{key:0,type:`primary`,plain:``,size:`small`,class:`!px-2 !py-1 !text-xs !h-auto !min-h-0`,onClick:t=>r.onShowDetail(e.row)},{default:x(()=>[i(c(r.$t(`usage.button.viewDetail`)),1)]),_:1},8,[`onClick`])):p(``,!0)]),_:1},8,[`label`]),o(N,{prop:`trace_id`,label:r.$t(`application.field.traceId`),width:`200px`,"class-name":`text-center`},{default:x(e=>[n(`span`,de,c(e.row.trace_id),1),e.row.trace_id?(l(),t(`span`,fe,[o(F,{content:e.row.trace_id,class:`inline-block`},null,8,[`content`])])):p(``,!0)]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.createdAt`),width:`200px`},{default:x(e=>[n(`span`,pe,c(r.$dayjs.format(e.row.created_at)),1)]),_:1},8,[`label`])]),_:1},8,[`data`,`empty-text`])),[[V,r.loading]]):p(``,!0),r.type===r.serviceType.Proxy?f((l(),a(I,{key:1,data:r.proxyUsages,stripe:``,"table-layout":`fixed`,"empty-text":r.$t(`common.message.noData`),class:`min-h-[calc(100vh-350px)] mb-5`},{default:x(()=>[o(N,{label:r.$t(`application.field.name`),width:`160px`},{default:x(e=>[n(`span`,null,c(e.row?.service?.title),1)]),_:1},8,[`label`]),o(N,{prop:`remaining_amount`,label:r.$t(`usage.field.remainingAmount`),width:`160px`,"class-name":`text-center`},{default:x(e=>[n(`span`,null,c(r.getRemainingAmount(e.row)),1),n(`span`,null,c(r.getOriginalAmount(e.row)),1)]),_:1},8,[`label`]),o(N,{prop:`deducted_amount`,label:r.$t(`usage.field.deductedAmount`),width:`150px`,"class-name":`text-center`},{default:x(e=>[n(`span`,null,c(r.getDeductedAmount(e.row)),1)]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.balanceAfter`),width:`160px`,"class-name":`text-center`},{default:x(e=>[n(`span`,null,c(r.getRemainingAmount(e.row)),1)]),_:1},8,[`label`]),o(N,{prop:`metadata`,label:r.$t(`usage.field.metadata`),width:`200px`,"class-name":`text-center`},{default:x(n=>[(l(!0),t(s,null,e(n.row.metadata,(e,t)=>(l(),a(P,{key:t,class:`mb-2`},{default:x(()=>[i(c(t)+`: `+c(e),1)]),_:2},1024))),128))]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.createdAt`),width:`200px`},{default:x(e=>[n(`span`,me,c(r.$dayjs.format(e.row.created_at)),1)]),_:1},8,[`label`])]),_:1},8,[`data`,`empty-text`])),[[V,r.loading]]):p(``,!0)]),_:1})]),_:1})]),_:1}),o(z,{modelValue:r.detailDialogVisible,"onUpdate:modelValue":u[6]||=e=>r.detailDialogVisible=e,title:r.$t(`usage.dialog.detailTitle`),width:`70%`,top:`5vh`,"destroy-on-close":``},{default:x(()=>[o(R,{modelValue:r.detailActiveTab,"onUpdate:modelValue":u[5]||=e=>r.detailActiveTab=e},{default:x(()=>[o(L,{label:r.$t(`usage.dialog.request`),name:`request`},{default:x(()=>[r.detailLoading?(l(),a(D,{key:0,rows:6,animated:``})):r.detailRow?.metadata?.request?(l(),t(`pre`,he,c(r.formatJson(r.detailRow.metadata.request)),1)):(l(),t(`p`,ge,c(r.$t(`usage.dialog.noData`)),1))]),_:1},8,[`label`]),o(L,{label:r.$t(`usage.dialog.response`),name:`response`},{default:x(()=>[r.detailLoading?(l(),a(D,{key:0,rows:6,animated:``})):r.detailRow?.metadata?.response?(l(),t(`pre`,_e,c(r.formatJson(r.detailRow.metadata.response)),1)):(l(),t(`p`,ve,c(r.$t(`usage.dialog.noData`)),1))]),_:1},8,[`label`])]),_:1},8,[`modelValue`])]),_:1},8,[`modelValue`,`title`]),o(v,null,{default:x(()=>[o(_,{span:10,offset:14},{default:x(()=>[n(`div`,ye,[o(B,{"current-page":r.page,"page-size":r.limit,total:r.total,onChange:r.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var xe=H(Z,[[`render`,be],[`__scopeId`,`data-v-38f1845c`]]);export{xe as default};
|
|
1
|
+
import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,a as u,c as d,dt as f,i as ee,k as p,n as m,nt as h,o as g,r as _,s as v,t as y,tt as b,ut as x,v as S}from"./vendor-chart-BJCvKk8-.js";import{t as C}from"./button-BydTr5nV.js";import{r as w,t as T}from"./select-BrRoGuGI.js";import{n as E,t as D}from"./table-B5c9kfrJ.js";import{n as O,t as k}from"./tabs-BX6WZxwV.js";import{t as A}from"./card-DjyfNde2.js";import{n as j,r as M}from"./radio-3Hz7h3DR.js";import{t as N}from"./date-picker-CN9KO91T.js";import{n as P,t as F}from"./row-B5bv9JPh.js";import{t as I}from"./Pagination-CEMukh4X.js";import{n as L,t as R}from"./skeleton-BwNBivMN.js";import{Bn as z,Hr as B,Mr as V,O as H,Rn as U,Tr as W,Wn as G,Wr as K,wr as q,zn as J}from"./index-BwuZeZD0.js";import{t as Y}from"./index.es-BAFsTiuS.js";import{t as X}from"./CopyToClipboard-B8J4icuV.js";ee.register(_,u,m,v,d,g);var Z=r({name:`ConsoleUsageList`,components:{Pagination:I,ElTag:K,ElDatePicker:N,ElTable:D,ElSelect:w,ElOption:T,CopyToClipboard:X,ElRow:F,ElCol:P,ElTableColumn:E,ElCard:A,ElRadioButton:j,ElRadioGroup:M,ElSkeleton:R,ElSkeletonItem:L,ElDialog:B,ElTabs:O,ElTabPane:k,ElButton:C,FontAwesomeIcon:Y,BarChart:y},data(){return{applicationIds:this.$route.query.application_id?.toString()?this.$route.query.application_id?.toString().split(`,`):[],apiIds:this.$route.query.api_id?.toString()?this.$route.query.api_id?.toString().split(`,`):[],applications:[],apis:[],apisLoading:!1,credentialType:q,serviceType:W,apiUsages:[],proxyUsages:[],createdAtRange:(()=>{let e=this.$route.query.created_at_to?.toString(),t=this.$route.query.created_at_from?.toString();if(t&&e)return[new Date(t),new Date(e)];let n=new Date,r=new Date;return r.setDate(1),r.setHours(0,0,0,0),[r,n]})(),shortcuts:[{text:this.$t(`usage.shortcuts.thisMonth`),value:()=>{let e=new Date,t=new Date;return t.setDate(1),t.setHours(0,0,0,0),[t,e]}},{text:this.$t(`usage.shortcuts.today`),value:()=>{let e=new Date,t=new Date;return t.setHours(0,0,0,0),[t,e]}},{text:this.$t(`usage.shortcuts.last1Day`),value:()=>{let e=new Date,t=new Date;return t.setDate(t.getDate()-1),[t,e]}},{text:this.$t(`usage.shortcuts.last3Days`),value:()=>{let e=new Date,t=new Date;return t.setDate(t.getDate()-3),[t,e]}},{text:this.$t(`usage.shortcuts.last7Days`),value:()=>{let e=new Date,t=new Date;return t.setDate(t.getDate()-7),[t,e]}},{text:this.$t(`usage.shortcuts.last1Month`),value:()=>{let e=new Date,t=new Date;return t.setMonth(t.getMonth()-1),[t,e]}}],type:this.$route.query.type?.toString()||W.API,loading:!1,total:void 0,limit:15,totalUsed:0,barChartLabels:[],barChartSeries:[],aggLoading:!1,detailDialogVisible:!1,detailRow:null,detailActiveTab:`request`,detailLoading:!1,exporting:!1,statusCodeFilter:this.$route.query.status_code?.toString()||``,statusCodeOptions:[],statusCodeOptionsLoading:!1}},computed:{redirect(){return this.$route.query?.redirect},page(){return parseInt(this.$route.query.page?.toString()||`1`)},totalUsedString(){return`${(this.totalUsed||0).toFixed(2)}`},barChartData(){return{labels:this.barChartLabels,datasets:this.barChartSeries.map(e=>({label:e.label,data:e.data,backgroundColor:e.color}))}},barChartOptions(){return{responsive:!0,plugins:{legend:{position:`top`,onClick:(e,t,n)=>{let r=n?.chart;if(!r||t?.datasetIndex===void 0)return;let i=t.datasetIndex,a=r.data?.datasets||[];a.some((e,t)=>t!==i&&r.isDatasetVisible(t))?a.forEach((e,t)=>r.setDatasetVisibility(t,t===i)):a.forEach((e,t)=>r.setDatasetVisibility(t,!0)),r.update()}},title:{display:!0,text:this.$t(`usage.title.usageTrend`)}},scales:{x:{stacked:!0},y:{stacked:!0,beginAtZero:!0}}}}},watch:{page:{handler(){this.onFetchUsages()}},type:{handler(){this.applicationIds=[],this.apiIds=[],this.onApplicationsChange(this.applicationIds),this.onFetchApplications(),this.onFetchApis(),this.onFetchUsages(),this.onFetchAggregate(),this.onFetchStatusCodeOptions()}}},mounted(){this.onFetchApplications(),this.onFetchApis(),this.onFetchUsages(),this.onFetchAggregate(),this.onFetchStatusCodeOptions()},methods:{async onFetchUsages(){this.type===W.API?this.onFetchApiUsages():this.type===W.Proxy&&this.onFetchProxyUsages()},async onApiChange(e){await this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,api_id:e}}),this.onFetchApiUsages(),this.onFetchAggregate()},async onApisChange(e){await this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,api_id:e&&e.length?e.join(`,`):``}}),this.onFetchApiUsages(),this.onFetchAggregate()},async onTimeRangeChanged(){console.log(`onTimeRangeChanged`,this.createdAtRange),await this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,created_at_from:this.createdAtRange?this.$dayjs.format(this.createdAtRange[0].toString(),`YYYY-MM-DDTHH:mm:ss.SSSSSSZ`):``,created_at_to:this.createdAtRange?this.$dayjs.format(this.createdAtRange[1].toString(),`YYYY-MM-DDTHH:mm:ss.SSSSSSZ`):``}}),this.onFetchUsages(),this.onFetchAggregate(),this.onFetchStatusCodeOptions()},async onApplicationChange(e){await this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,application_id:e}}),this.onFetchUsages(),this.onFetchAggregate()},async onApplicationsChange(e){await this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,application_id:e&&e.length?e.join(`,`):``}}),this.onFetchUsages(),this.onFetchAggregate()},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,page:e}})},getRemainingAmount(e){if(e.remaining_amount===void 0||e.remaining_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.remaining_amount?.toFixed(6)} ${t}`},getUsedAmount(e){if(e.used_amount===void 0||e.used_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.used_amount?.toFixed(6)} ${t}`},getDeductedAmount(e){if(e?.deducted_amount===void 0||e?.deducted_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.deducted_amount?.toFixed(6)} ${t}`},getOriginalAmount(e){if(e?.original_amount===void 0||e?.original_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.original_amount?.toFixed(6)} ${t}`},onStatusCodeChange(e){let t={...this.$route.query},n=(e||``).trim();n?t.status_code=n:delete t.status_code,delete t.status_code_filter,this.$router.push({name:this.$route.name?.toString(),query:t}),this.onFetchUsages(),this.onFetchAggregate()},async onFetchStatusCodeOptions(){this.statusCodeOptionsLoading=!0;try{let{data:e}=await J.getStatusCodes({user_id:this.$store.getters.user.id,...this.applicationIds&&this.applicationIds.length?{application_id:this.applicationIds}:{},...this.apiIds&&this.apiIds.length?{api_id:this.apiIds}:{},...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0]}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1]}:{}});this.statusCodeOptions=(e?.items||[]).slice().sort((e,t)=>e-t)}catch{this.statusCodeOptions=[]}finally{this.statusCodeOptionsLoading=!1}},formatElapsed(e){return e==null||Number.isNaN(e)?`-`:e<1?`${Math.round(e*1e3)} ms`:`${e.toFixed(2)} s`},getSimpleMetadata(e){if(!e)return{};let t={};for(let[n,r]of Object.entries(e))n===`request`||n===`response`||typeof r==`object`&&r||(t[n]=r);return t},onShowDetail(e){this.detailRow={...e,metadata:void 0},this.detailActiveTab=`request`,this.detailDialogVisible=!0,this.detailLoading=!0,e.id&&J.get(e.id).then(e=>{this.detailRow=e.data}).finally(()=>{this.detailLoading=!1})},formatJson(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}},onFetchApplications(){G.getAll({limit:100,offset:0,user_id:this.$store.getters.user.id,ordering:`-created_at`,type:V.USAGE}).then(({data:e})=>{this.applications=e.items.filter(e=>e?.service?.type===this.type)}).catch(()=>{})},onFetchApis(){this.apisLoading=!0,U.getAll({limit:100,offset:0,ordering:`-created_at`}).then(({data:e})=>{this.apis=e.items}).catch(()=>{}).finally(()=>{this.apisLoading=!1})},onFetchApiUsages(){console.log(`onFetchApiUsages`,this.createdAtRange),this.loading=!0,J.getAll({limit:this.limit,offset:(this.page-1)*this.limit,user_id:this.$store.getters.user.id,ordering:`-created_at`,...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0]}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1]}:{},...this.applicationIds&&this.applicationIds.length?{application_id:this.applicationIds}:{},...this.apiIds&&this.apiIds.length?{api_id:this.apiIds}:{},...this.statusCodeFilter?{status_code:this.statusCodeFilter}:{}}).then(({data:e})=>{this.apiUsages=e.items,this.loading=!1,this.total=e.count}).catch(()=>{this.loading=!1})},onFetchProxyUsages(){this.loading=!0,z.getAll({limit:this.limit,offset:(this.page-1)*this.limit,user_id:this.$store.getters.user.id,ordering:`-created_at`,...this.applicationIds&&this.applicationIds.length?{application_id:this.applicationIds}:{}}).then(({data:e})=>{this.proxyUsages=e.items,this.loading=!1,this.total=e.count}).catch(()=>{this.loading=!1})},onExport(){this.exporting=!0,J.exportCsv({user_id:this.$store.getters.user.id,...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0]}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1]}:{},...this.applicationIds&&this.applicationIds.length?{application_id:this.applicationIds}:{},...this.apiIds&&this.apiIds.length?{api_id:this.apiIds}:{},...this.statusCodeFilter?{status_code:this.statusCodeFilter}:{}}).then(({data:e})=>{let t=window.URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`usages.csv`,n.click(),window.URL.revokeObjectURL(t)}).catch(()=>{}).finally(()=>{this.exporting=!1})},async onFetchAggregate(){if(this.aggLoading=!0,this.type!==this.serviceType.API)return;let e={user_id:this.$store.getters.user.id,...this.applicationIds&&this.applicationIds.length?{application_id:this.applicationIds}:{},...this.apiIds&&this.apiIds.length?{api_id:this.apiIds}:{},...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0]}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1]}:{}};try{let{data:t}=await J.getAggregate(e);this.totalUsed=t.total||0;let n=Array.from(new Set((t.items||[]).map(e=>e.date))).sort(),r=Array.from(new Set((t.items||[]).map(e=>e.api_id))),i=e=>`hsl(${e*57%360}, 70%, 60%)`,a=r.map((e,r)=>{let a=t.apis?.[e]?.title||e,o={};return(t.items||[]).filter(t=>t.api_id===e).forEach(e=>{o[e.date]=e.amount||0}),{key:e,label:a,data:n.map(e=>o[e]||0),color:i(r)}});this.barChartLabels=n,this.barChartSeries=a}finally{this.aggLoading=!1}}}}),Q={class:`text-[26px] font-bold mb-5 text-[var(--el-text-color-primary)]`},$={class:`inline-block w-9`},te={class:`inline-block`},ne={key:1,class:`summary-card`},re={class:`icon-wrapper`},ie={class:`text-left`},ae={class:`description`},oe={class:`value`},se={class:`chart-wrapper`},ce={key:0},le={key:1},ue={class:`flex flex-wrap gap-2`},de={class:`key`},fe={key:0,class:`cursor-pointer`},pe={class:`created-at`},me={class:`created-at`},he={key:1,class:`detail-json`},ge={key:2,class:`text-gray-400`},_e={key:1,class:`detail-json`},ve={key:2,class:`text-gray-400`},ye={class:`float-right`};function be(r,u,d,ee,m,g){let _=b(`el-col`),v=b(`el-row`),y=b(`el-radio-button`),C=b(`el-radio-group`),w=b(`el-option`),T=b(`el-select`),E=b(`el-skeleton-item`),D=b(`el-skeleton`),O=b(`el-date-picker`),k=b(`font-awesome-icon`),A=b(`el-button`),j=b(`el-card`),M=b(`bar-chart`),N=b(`el-table-column`),P=b(`el-tag`),F=b(`copy-to-clipboard`),I=b(`el-table`),L=b(`el-tab-pane`),R=b(`el-tabs`),z=b(`el-dialog`),B=b(`pagination`),V=h(`loading`);return l(),a(v,null,{default:x(()=>[o(_,{span:24},{default:x(()=>[o(v,null,{default:x(()=>[o(_,{span:24},{default:x(()=>[n(`h2`,Q,c(r.$t(`common.title.allUsages`)),1)]),_:1})]),_:1}),o(v,null,{default:x(()=>[o(_,{md:4,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:x(()=>[n(`span`,null,c(r.$t(`application.field.type`)),1),o(C,{modelValue:r.type,"onUpdate:modelValue":u[0]||=e=>r.type=e},{default:x(()=>[o(y,{value:r.serviceType.API,label:r.$t(`application.field.api`)},null,8,[`value`,`label`]),o(y,{value:r.serviceType.Proxy,label:r.$t(`application.field.proxy`)},null,8,[`value`,`label`])]),_:1},8,[`modelValue`])]),_:1}),f(o(_,{md:6,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:x(()=>[n(`span`,$,c(r.$t(`usage.field.application`)),1),o(T,{modelValue:r.applicationIds,"onUpdate:modelValue":u[1]||=e=>r.applicationIds=e,placeholder:r.$t(`usage.field.application`),clearable:``,multiple:``,"collapse-tags":``,"collapse-tags-tooltip":``,class:`w-full`,onChange:r.onApplicationsChange},{default:x(()=>[(l(!0),t(s,null,e(r.applications,e=>(l(),a(w,{key:e.id,label:e.service?.title,value:e?.id},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`])]),_:1},512),[[S,!1]]),r.type===r.serviceType.API?(l(),a(_,{key:0,md:6,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:x(()=>[n(`span`,te,c(r.$t(`usage.field.api`)),1),r.apisLoading?(l(),a(D,{key:0,animated:``,class:`w-full`},{template:x(()=>[o(E,{variant:`rect`,style:{height:`32px`,"border-radius":`4px`}})]),_:1})):(l(),a(T,{key:1,modelValue:r.apiIds,"onUpdate:modelValue":u[2]||=e=>r.apiIds=e,placeholder:r.$t(`usage.field.api`),clearable:``,filterable:``,multiple:``,"collapse-tags":``,"collapse-tags-tooltip":``,class:`w-full`,onChange:r.onApisChange},{default:x(()=>[(l(!0),t(s,null,e(r.apis,e=>(l(),a(w,{key:e?.id,label:e?.title,value:e?.id},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]))]),_:1})):p(``,!0),r.type===r.serviceType.API?(l(),a(_,{key:1,md:8,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:x(()=>[o(O,{modelValue:r.createdAtRange,"onUpdate:modelValue":u[3]||=e=>r.createdAtRange=e,type:`datetimerange`,class:`w-full`,shortcuts:r.shortcuts,"range-separator":r.$t(`usage.placeholder.to`),"start-placeholder":r.$t(`usage.placeholder.startDate`),"end-placeholder":r.$t(`usage.placeholder.endDate`),onChange:r.onTimeRangeChanged},null,8,[`modelValue`,`shortcuts`,`range-separator`,`start-placeholder`,`end-placeholder`,`onChange`])]),_:1})):p(``,!0),r.type===r.serviceType.API?(l(),a(_,{key:2,md:3,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:x(()=>[o(T,{modelValue:r.statusCodeFilter,"onUpdate:modelValue":u[4]||=e=>r.statusCodeFilter=e,placeholder:r.$t(`usage.option.statusCodeAll`),class:`w-full`,clearable:``,filterable:``,"allow-create":``,"default-first-option":``,loading:r.statusCodeOptionsLoading,onChange:r.onStatusCodeChange},{default:x(()=>[(l(!0),t(s,null,e(r.statusCodeOptions,e=>(l(),a(w,{key:e,label:String(e),value:String(e)},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`loading`,`onChange`])]),_:1})):p(``,!0),r.type===r.serviceType.API?(l(),a(_,{key:3,md:3,xs:24,class:`mb-5 flex px-2 gap-2 items-center justify-end`},{default:x(()=>[o(A,{type:`primary`,plain:``,loading:r.exporting,class:`w-full whitespace-nowrap`,onClick:r.onExport},{default:x(()=>[o(k,{icon:`fa-solid fa-file-export`,class:`mr-1`}),i(` `+c(r.$t(`usage.button.export`)),1)]),_:1},8,[`loading`,`onClick`])]),_:1})):p(``,!0)]),_:1}),o(v,null,{default:x(()=>[o(_,{span:24},{default:x(()=>[r.type===r.serviceType.API?(l(),a(v,{key:0,gutter:24,class:`mb-5`},{default:x(()=>[o(_,{md:6,xs:24},{default:x(()=>[o(j,{shadow:`hover`,class:`h-full`},{default:x(()=>[r.aggLoading?(l(),a(D,{key:0})):(l(),t(`div`,ne,[n(`div`,re,[o(k,{icon:`fa-solid fa-cubes`,class:`icon`})]),n(`div`,ie,[n(`p`,ae,c(r.$t(`usage.title.totalUsed`)),1),n(`p`,oe,c(r.totalUsedString),1)])]))]),_:1})]),_:1}),o(_,{md:18,xs:24},{default:x(()=>[o(j,{shadow:`hover`,class:`h-full`},{default:x(()=>[n(`div`,se,[r.aggLoading?(l(),a(D,{key:0,class:`w-full`})):(l(),a(M,{key:1,data:r.barChartData,options:r.barChartOptions,class:`chart`},null,8,[`data`,`options`]))])]),_:1})]),_:1})]),_:1})):p(``,!0),o(j,{shadow:`hover`},{default:x(()=>[r.type===r.serviceType.API?f((l(),a(I,{key:0,data:r.apiUsages,stripe:``,"table-layout":`fixed`,"empty-text":r.$t(`common.message.noData`),class:`min-h-[calc(100vh-350px)] mb-5`},{default:x(()=>[o(N,{label:r.$t(`application.field.name`),width:`160px`},{default:x(e=>[n(`span`,null,c(e.row?.api?.title),1)]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.statusCode`),width:`120px`},{default:x(e=>[n(`span`,null,c(e.row.status_code),1)]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.elapsed`),width:`120px`},{default:x(e=>[n(`span`,null,c(r.formatElapsed(e.row.elapsed)),1)]),_:1},8,[`label`]),o(N,{prop:`deducted_amount`,label:r.$t(`usage.field.deductedAmount`),width:`150px`,"class-name":`text-center`},{default:x(e=>[r.getDeductedAmount(e.row)===r.getOriginalAmount(e.row)?(l(),t(`div`,ce,[n(`span`,null,c(r.getDeductedAmount(e.row)),1)])):(l(),t(`div`,le,[u[7]||=n(`p`,null,null,-1),n(`p`,null,[n(`span`,null,c(r.getDeductedAmount(e.row)),1)]),n(`p`,null,[n(`del`,null,c(r.getOriginalAmount(e.row)),1)])]))]),_:1},8,[`label`]),o(N,{prop:`remaining_amount`,label:r.$t(`usage.field.balanceAfter`),width:`160px`,"class-name":`text-center`},{default:x(e=>[n(`span`,null,c(r.getRemainingAmount(e.row)),1)]),_:1},8,[`label`]),o(N,{prop:`metadata`,label:r.$t(`usage.field.metadata`),width:`260px`,"class-name":`text-center`},{default:x(o=>[n(`div`,ue,[o.row.original_amount>o.row.deducted_amount&&o.row.original_amount>0?(l(),a(P,{key:0,type:`success`,style:{textWrap:`wrap`,height:`fit-content`,lineHeight:`20px`,borderRadius:`10px`}},{default:x(()=>[i(c(((o.row.original_amount-o.row.deducted_amount)*100/o.row.original_amount).toFixed(0)+`% OFF`),1)]),_:2},1024)):p(``,!0),(l(!0),t(s,null,e(r.getSimpleMetadata(o.row.metadata),(e,t)=>(l(),a(P,{key:t,style:{textWrap:`wrap`,height:`fit-content`,lineHeight:`20px`,borderRadius:`10px`}},{default:x(()=>[i(c(t)+`: `+c(e),1)]),_:2},1024))),128))])]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.button.viewDetail`),width:`120px`,"class-name":`text-center`},{default:x(e=>[e.row.id?(l(),a(A,{key:0,type:`primary`,plain:``,size:`small`,class:`!px-2 !py-1 !text-xs !h-auto !min-h-0`,onClick:t=>r.onShowDetail(e.row)},{default:x(()=>[i(c(r.$t(`usage.button.viewDetail`)),1)]),_:1},8,[`onClick`])):p(``,!0)]),_:1},8,[`label`]),o(N,{prop:`trace_id`,label:r.$t(`application.field.traceId`),width:`200px`,"class-name":`text-center`},{default:x(e=>[n(`span`,de,c(e.row.trace_id),1),e.row.trace_id?(l(),t(`span`,fe,[o(F,{content:e.row.trace_id,class:`inline-block`},null,8,[`content`])])):p(``,!0)]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.createdAt`),width:`200px`},{default:x(e=>[n(`span`,pe,c(r.$dayjs.format(e.row.created_at)),1)]),_:1},8,[`label`])]),_:1},8,[`data`,`empty-text`])),[[V,r.loading]]):p(``,!0),r.type===r.serviceType.Proxy?f((l(),a(I,{key:1,data:r.proxyUsages,stripe:``,"table-layout":`fixed`,"empty-text":r.$t(`common.message.noData`),class:`min-h-[calc(100vh-350px)] mb-5`},{default:x(()=>[o(N,{label:r.$t(`application.field.name`),width:`160px`},{default:x(e=>[n(`span`,null,c(e.row?.service?.title),1)]),_:1},8,[`label`]),o(N,{prop:`remaining_amount`,label:r.$t(`usage.field.remainingAmount`),width:`160px`,"class-name":`text-center`},{default:x(e=>[n(`span`,null,c(r.getRemainingAmount(e.row)),1),n(`span`,null,c(r.getOriginalAmount(e.row)),1)]),_:1},8,[`label`]),o(N,{prop:`deducted_amount`,label:r.$t(`usage.field.deductedAmount`),width:`150px`,"class-name":`text-center`},{default:x(e=>[n(`span`,null,c(r.getDeductedAmount(e.row)),1)]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.balanceAfter`),width:`160px`,"class-name":`text-center`},{default:x(e=>[n(`span`,null,c(r.getRemainingAmount(e.row)),1)]),_:1},8,[`label`]),o(N,{prop:`metadata`,label:r.$t(`usage.field.metadata`),width:`200px`,"class-name":`text-center`},{default:x(n=>[(l(!0),t(s,null,e(n.row.metadata,(e,t)=>(l(),a(P,{key:t,class:`mb-2`},{default:x(()=>[i(c(t)+`: `+c(e),1)]),_:2},1024))),128))]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.createdAt`),width:`200px`},{default:x(e=>[n(`span`,me,c(r.$dayjs.format(e.row.created_at)),1)]),_:1},8,[`label`])]),_:1},8,[`data`,`empty-text`])),[[V,r.loading]]):p(``,!0)]),_:1})]),_:1})]),_:1}),o(z,{modelValue:r.detailDialogVisible,"onUpdate:modelValue":u[6]||=e=>r.detailDialogVisible=e,title:r.$t(`usage.dialog.detailTitle`),width:`70%`,top:`5vh`,"destroy-on-close":``},{default:x(()=>[o(R,{modelValue:r.detailActiveTab,"onUpdate:modelValue":u[5]||=e=>r.detailActiveTab=e},{default:x(()=>[o(L,{label:r.$t(`usage.dialog.request`),name:`request`},{default:x(()=>[r.detailLoading?(l(),a(D,{key:0,rows:6,animated:``})):r.detailRow?.metadata?.request?(l(),t(`pre`,he,c(r.formatJson(r.detailRow.metadata.request)),1)):(l(),t(`p`,ge,c(r.$t(`usage.dialog.noData`)),1))]),_:1},8,[`label`]),o(L,{label:r.$t(`usage.dialog.response`),name:`response`},{default:x(()=>[r.detailLoading?(l(),a(D,{key:0,rows:6,animated:``})):r.detailRow?.metadata?.response?(l(),t(`pre`,_e,c(r.formatJson(r.detailRow.metadata.response)),1)):(l(),t(`p`,ve,c(r.$t(`usage.dialog.noData`)),1))]),_:1},8,[`label`])]),_:1},8,[`modelValue`])]),_:1},8,[`modelValue`,`title`]),o(v,null,{default:x(()=>[o(_,{span:10,offset:14},{default:x(()=>[n(`div`,ye,[o(B,{"current-page":r.page,"page-size":r.limit,total:r.total,onChange:r.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var xe=H(Z,[[`render`,be],[`__scopeId`,`data-v-38f1845c`]]);export{xe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,dt as u,nt as d,tt as f,ut as p}from"./vendor-chart-BJCvKk8-.js";import{t as m}from"./button-BydTr5nV.js";import{r as h,t as g}from"./select-DBWrapm4.js";import{n as _,t as v}from"./table-B5c9kfrJ.js";import{t as y}from"./card-DjyfNde2.js";import{t as b}from"./date-picker-DFSkI2T1.js";import{n as x,t as S}from"./row-Sw1tNXnG.js";import{t as C}from"./Pagination-Bx16Gkpp.js";import{t as w}from"./skeleton-BwNBivMN.js";import{Er as T,Ln as E,O as D,Wr as O,Wt as k}from"./index-DoCEzMzZ.js";import{t as A}from"./index.es-CDSdB7LL.js";import{t as j}from"./CopyToClipboard-BqsCWkad.js";var M={total_count:0,total_spent:0,state_counts:{}},N=r({name:`ConsoleOrderList`,components:{Pagination:C,CopyToClipboard:j,ElRow:S,ElCol:x,ElTable:v,ElTableColumn:_,ElButton:m,ElTag:O,ElCard:y,ElSelect:h,ElOption:g,ElDatePicker:b,ElSkeleton:w,FontAwesomeIcon:A},data(){return{OrderState:T,orders:[],loading:!1,total:void 0,limit:10,filterState:this.$route.query.state?.toString()||``,filterPayWay:this.$route.query.pay_way?.toString()||``,createdAtRange:(()=>{let e=this.$route.query.created_at_from?.toString(),t=this.$route.query.created_at_to?.toString();if(e&&t)return[new Date(e),new Date(t)]})(),summary:{...M},summaryLoading:!1,exporting:!1,shortcuts:[{text:this.$t(`usage.shortcuts.today`),value:()=>{let e=new Date,t=new Date;return t.setHours(0,0,0,0),[t,e]}},{text:this.$t(`usage.shortcuts.last7Days`),value:()=>{let e=new Date,t=new Date;return t.setDate(t.getDate()-7),[t,e]}},{text:this.$t(`usage.shortcuts.last1Month`),value:()=>{let e=new Date,t=new Date;return t.setMonth(t.getMonth()-1),[t,e]}}]}},computed:{page(){return parseInt(this.$route.query.page?.toString()||`1`)},stateOptions(){return[{value:T.PENDING,label:this.$t(`order.state.pending`)},{value:T.FINISHED,label:this.$t(`order.state.finished`)},{value:T.PAID,label:this.$t(`order.state.paid`)},{value:T.EXPIRED,label:this.$t(`order.state.expired`)},{value:T.FAILED,label:this.$t(`order.state.failed`)},{value:T.REFUNDED,label:this.$t(`order.state.refunded`)}]},payWayOptions(){return[{value:`WechatPay`,label:this.$t(`order.title.wechatPay`)},{value:`Stripe`,label:this.$t(`order.title.stripe`)},{value:`AliPay`,label:this.$t(`order.title.aliPay`)},{value:`X402`,label:this.$t(`order.title.x402`)},{value:`PayPal`,label:this.$t(`order.title.paypal`)}]},filterQuery(){let e={user_id:this.$store.getters.user?.id};return this.filterState&&(e.state=this.filterState),this.filterPayWay&&(e.pay_way=this.filterPayWay),this.createdAtRange?.[0]&&(e.created_at_from=this.createdAtRange[0]),this.createdAtRange?.[1]&&(e.created_at_to=this.createdAtRange[1]),e}},watch:{page:{handler(){this.onFetchData()}}},mounted(){this.onFetchData(),this.onFetchSummary()},methods:{getPriceString:k,stateTagType(e){return e===T.FINISHED||e===T.PAID?`success`:e===T.EXPIRED||e===T.FAILED?`danger`:e===T.REFUNDED?`warning`:`info`},stateLabel(e){return{[T.PENDING]:this.$t(`order.state.pending`),[T.PAID]:this.$t(`order.state.paid`),[T.FINISHED]:this.$t(`order.state.finished`),[T.EXPIRED]:this.$t(`order.state.expired`),[T.FAILED]:this.$t(`order.state.failed`),[T.REFUNDED]:this.$t(`order.state.refunded`)}[e]||e},isPendingAction(e){return e!==T.PAID&&e!==T.FINISHED&&e!==T.EXPIRED&&e!==T.FAILED&&e!==T.REFUNDED},goToDetail(e){this.$router.push({name:`console-order-detail`,params:{id:e}})},async onFilterChange(){await this.$router.push({name:this.$route.name?.toString(),query:{page:1,...this.filterState?{state:this.filterState}:{},...this.filterPayWay?{pay_way:this.filterPayWay}:{},...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0].toISOString()}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1].toISOString()}:{}}}),this.onFetchData(),this.onFetchSummary()},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,page:e}})},onFetchData(){this.loading=!0,E.getAll({ordering:`-created_at`,limit:this.limit,offset:(this.page-1)*this.limit,...this.filterQuery}).then(({data:e})=>{this.orders=e.items,this.total=e.count}).catch(()=>{}).finally(()=>{this.loading=!1})},onFetchSummary(){this.summaryLoading=!0,E.getSummary(this.filterQuery).then(({data:e})=>{this.summary=e}).catch(()=>{this.summary={...M}}).finally(()=>{this.summaryLoading=!1})},onExport(){this.exporting=!0,E.exportCsv(this.filterQuery).then(({data:e})=>{let t=window.URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`orders.csv`,n.click(),window.URL.revokeObjectURL(t)}).catch(()=>{}).finally(()=>{this.exporting=!1})}}}),P={class:`title`},F={key:1,class:`card-content`},I={class:`icon-wrapper`},L={class:`description`},R={class:`value`},z={key:1,class:`card-content`},B={class:`icon-wrapper`},V={class:`description`},H={class:`value`},U={key:1,class:`card-content`},W={class:`icon-wrapper`},ee={class:`description`},G={class:`value`},K={key:1,class:`card-content`},q={class:`icon-wrapper`},J={class:`description`},Y={class:`value`},X={class:`filter-row mb-3`},Z={class:`key`},Q={class:`cursor-pointer`},$={class:`price`},te={class:`description`},ne={class:`text-gray-500`},re={class:`created-at`},ie={class:`flex items-center justify-center flex-wrap`},ae={class:`float-right`};function oe(r,m,h,g,_,v){let y=f(`el-col`),b=f(`el-row`),x=f(`el-skeleton`),S=f(`font-awesome-icon`),C=f(`el-card`),w=f(`el-option`),T=f(`el-select`),E=f(`el-date-picker`),D=f(`el-button`),O=f(`copy-to-clipboard`),k=f(`el-table-column`),A=f(`el-tag`),j=f(`el-table`),M=f(`pagination`),N=d(`loading`);return l(),a(b,{class:`panel`},{default:p(()=>[o(y,{span:24},{default:p(()=>[o(b,null,{default:p(()=>[o(y,{span:24},{default:p(()=>[n(`h2`,P,c(r.$t(`common.title.allOrders`)),1)]),_:1})]),_:1}),o(b,{gutter:16},{default:p(()=>[o(y,{md:6,sm:12,xs:24},{default:p(()=>[o(C,{shadow:`hover`,class:`item-mini mb-3`},{default:p(()=>[r.summaryLoading?(l(),a(x,{key:0})):(l(),t(`div`,F,[n(`div`,I,[o(S,{icon:`fa-solid fa-receipt`,class:`icon`})]),n(`p`,L,c(r.$t(`order.title.totalOrders`)),1),n(`p`,R,c(r.summary.total_count),1)]))]),_:1})]),_:1}),o(y,{md:6,sm:12,xs:24},{default:p(()=>[o(C,{shadow:`hover`,class:`item-mini mb-3`},{default:p(()=>[r.summaryLoading?(l(),a(x,{key:0})):(l(),t(`div`,z,[n(`div`,B,[o(S,{icon:`fa-solid fa-dollar-sign`,class:`icon`})]),n(`p`,V,c(r.$t(`order.title.totalSpent`)),1),n(`p`,H,c(r.getPriceString({value:r.summary.total_spent})),1)]))]),_:1})]),_:1}),o(y,{md:6,sm:12,xs:24},{default:p(()=>[o(C,{shadow:`hover`,class:`item-mini mb-3`},{default:p(()=>[r.summaryLoading?(l(),a(x,{key:0})):(l(),t(`div`,U,[n(`div`,W,[o(S,{icon:`fa-solid fa-check-circle`,class:`icon`})]),n(`p`,ee,c(r.$t(`order.title.finishedOrders`)),1),n(`p`,G,c(r.summary.state_counts?.Finished||0),1)]))]),_:1})]),_:1}),o(y,{md:6,sm:12,xs:24},{default:p(()=>[o(C,{shadow:`hover`,class:`item-mini mb-3`},{default:p(()=>[r.summaryLoading?(l(),a(x,{key:0})):(l(),t(`div`,K,[n(`div`,q,[o(S,{icon:`fa-solid fa-clock`,class:`icon`})]),n(`p`,J,c(r.$t(`order.title.pendingOrders`)),1),n(`p`,Y,c(r.summary.state_counts?.Pending||0),1)]))]),_:1})]),_:1})]),_:1}),n(`div`,X,[o(T,{modelValue:r.filterState,"onUpdate:modelValue":m[0]||=e=>r.filterState=e,clearable:``,placeholder:r.$t(`order.field.allStates`),class:`filter-select`,onChange:r.onFilterChange},{default:p(()=>[(l(!0),t(s,null,e(r.stateOptions,e=>(l(),a(w,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]),o(T,{modelValue:r.filterPayWay,"onUpdate:modelValue":m[1]||=e=>r.filterPayWay=e,clearable:``,placeholder:r.$t(`order.field.allPayWays`),class:`filter-select`,onChange:r.onFilterChange},{default:p(()=>[(l(!0),t(s,null,e(r.payWayOptions,e=>(l(),a(w,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]),o(E,{modelValue:r.createdAtRange,"onUpdate:modelValue":m[2]||=e=>r.createdAtRange=e,type:`datetimerange`,shortcuts:r.shortcuts,"range-separator":r.$t(`usage.placeholder.to`),"start-placeholder":r.$t(`usage.placeholder.startDate`),"end-placeholder":r.$t(`usage.placeholder.endDate`),onChange:r.onFilterChange},null,8,[`modelValue`,`shortcuts`,`range-separator`,`start-placeholder`,`end-placeholder`,`onChange`]),o(D,{type:`primary`,plain:``,loading:r.exporting,onClick:r.onExport},{default:p(()=>[o(S,{icon:`fa-solid fa-file-export`,class:`mr-1`}),i(` `+c(r.$t(`order.button.export`)),1)]),_:1},8,[`loading`,`onClick`])]),o(b,null,{default:p(()=>[o(y,{span:24},{default:p(()=>[o(C,{shadow:`hover`},{default:p(()=>[u((l(),a(j,{data:r.orders,stripe:``,"empty-text":r.$t(`common.message.noData`),class:`min-h-[calc(100vh-450px)] mb-[20px]`},{default:p(()=>[o(k,{prop:`id`,label:r.$t(`order.field.id`),"class-name":`text-center`,width:`200px`},{default:p(e=>[n(`span`,Z,c(e.row.id),1),n(`span`,Q,[o(O,{content:e.row.id,class:`inline-block`},null,8,[`content`])])]),_:1},8,[`label`]),o(k,{label:r.$t(`order.field.price`),width:`110px`,align:`center`},{default:p(e=>[n(`span`,$,c(r.getPriceString({value:e.row?.price})),1)]),_:1},8,[`label`]),o(k,{label:r.$t(`order.field.description`),"min-width":`220px`,"class-name":`hidden md:table-cell`,"label-class-name":`hidden md:table-cell`},{default:p(e=>[n(`span`,te,c(e.row.description),1)]),_:1},8,[`label`]),o(k,{prop:`state`,label:r.$t(`order.field.state`),width:`130px`,align:`center`},{default:p(e=>[o(A,{type:r.stateTagType(e.row.state),class:`mx-1`,effect:`dark`,round:``,size:`small`},{default:p(()=>[i(c(r.stateLabel(e.row.state)),1)]),_:2},1032,[`type`])]),_:1},8,[`label`]),o(k,{label:r.$t(`order.field.payWay`),width:`120px`,align:`center`,"class-name":`hidden md:table-cell`,"label-class-name":`hidden md:table-cell`},{default:p(e=>[n(`span`,ne,c(e.row.pay_way||`-`),1)]),_:1},8,[`label`]),o(k,{label:r.$t(`order.field.createdAt`),width:`200px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:p(e=>[n(`span`,re,c(r.$dayjs.format(e.row.created_at)),1)]),_:1},8,[`label`]),o(k,{"min-width":`130px`,fixed:`right`},{default:p(e=>[n(`div`,ie,[r.isPendingAction(e.row.state)?(l(),a(D,{key:0,type:`primary`,size:`small`,onClick:t=>r.goToDetail(e.row.id)},{default:p(()=>[i(c(r.$t(`order.button.continuePay`)),1)]),_:1},8,[`onClick`])):(l(),a(D,{key:1,size:`small`,onClick:t=>r.goToDetail(e.row.id)},{default:p(()=>[i(c(r.$t(`order.button.checkDetail`)),1)]),_:1},8,[`onClick`]))])]),_:1})]),_:1},8,[`data`,`empty-text`])),[[N,r.loading]])]),_:1})]),_:1})]),_:1}),o(b,null,{default:p(()=>[o(y,{span:10,offset:14},{default:p(()=>[n(`div`,ae,[o(M,{"current-page":r.page,"page-size":r.limit,total:r.total,onChange:r.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var se=D(N,[[`render`,oe],[`__scopeId`,`data-v-350ab467`]]);export{se as default};
|
|
1
|
+
import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,dt as u,nt as d,tt as f,ut as p}from"./vendor-chart-BJCvKk8-.js";import{t as m}from"./button-BydTr5nV.js";import{r as h,t as g}from"./select-BrRoGuGI.js";import{n as _,t as v}from"./table-B5c9kfrJ.js";import{t as y}from"./card-DjyfNde2.js";import{t as b}from"./date-picker-CN9KO91T.js";import{n as x,t as S}from"./row-B5bv9JPh.js";import{t as C}from"./Pagination-CEMukh4X.js";import{t as w}from"./skeleton-BwNBivMN.js";import{Er as T,Ln as E,O as D,Wr as O,Wt as k}from"./index-BwuZeZD0.js";import{t as A}from"./index.es-BAFsTiuS.js";import{t as j}from"./CopyToClipboard-B8J4icuV.js";var M={total_count:0,total_spent:0,state_counts:{}},N=r({name:`ConsoleOrderList`,components:{Pagination:C,CopyToClipboard:j,ElRow:S,ElCol:x,ElTable:v,ElTableColumn:_,ElButton:m,ElTag:O,ElCard:y,ElSelect:h,ElOption:g,ElDatePicker:b,ElSkeleton:w,FontAwesomeIcon:A},data(){return{OrderState:T,orders:[],loading:!1,total:void 0,limit:10,filterState:this.$route.query.state?.toString()||``,filterPayWay:this.$route.query.pay_way?.toString()||``,createdAtRange:(()=>{let e=this.$route.query.created_at_from?.toString(),t=this.$route.query.created_at_to?.toString();if(e&&t)return[new Date(e),new Date(t)]})(),summary:{...M},summaryLoading:!1,exporting:!1,shortcuts:[{text:this.$t(`usage.shortcuts.today`),value:()=>{let e=new Date,t=new Date;return t.setHours(0,0,0,0),[t,e]}},{text:this.$t(`usage.shortcuts.last7Days`),value:()=>{let e=new Date,t=new Date;return t.setDate(t.getDate()-7),[t,e]}},{text:this.$t(`usage.shortcuts.last1Month`),value:()=>{let e=new Date,t=new Date;return t.setMonth(t.getMonth()-1),[t,e]}}]}},computed:{page(){return parseInt(this.$route.query.page?.toString()||`1`)},stateOptions(){return[{value:T.PENDING,label:this.$t(`order.state.pending`)},{value:T.FINISHED,label:this.$t(`order.state.finished`)},{value:T.PAID,label:this.$t(`order.state.paid`)},{value:T.EXPIRED,label:this.$t(`order.state.expired`)},{value:T.FAILED,label:this.$t(`order.state.failed`)},{value:T.REFUNDED,label:this.$t(`order.state.refunded`)}]},payWayOptions(){return[{value:`WechatPay`,label:this.$t(`order.title.wechatPay`)},{value:`Stripe`,label:this.$t(`order.title.stripe`)},{value:`AliPay`,label:this.$t(`order.title.aliPay`)},{value:`X402`,label:this.$t(`order.title.x402`)},{value:`PayPal`,label:this.$t(`order.title.paypal`)}]},filterQuery(){let e={user_id:this.$store.getters.user?.id};return this.filterState&&(e.state=this.filterState),this.filterPayWay&&(e.pay_way=this.filterPayWay),this.createdAtRange?.[0]&&(e.created_at_from=this.createdAtRange[0]),this.createdAtRange?.[1]&&(e.created_at_to=this.createdAtRange[1]),e}},watch:{page:{handler(){this.onFetchData()}}},mounted(){this.onFetchData(),this.onFetchSummary()},methods:{getPriceString:k,stateTagType(e){return e===T.FINISHED||e===T.PAID?`success`:e===T.EXPIRED||e===T.FAILED?`danger`:e===T.REFUNDED?`warning`:`info`},stateLabel(e){return{[T.PENDING]:this.$t(`order.state.pending`),[T.PAID]:this.$t(`order.state.paid`),[T.FINISHED]:this.$t(`order.state.finished`),[T.EXPIRED]:this.$t(`order.state.expired`),[T.FAILED]:this.$t(`order.state.failed`),[T.REFUNDED]:this.$t(`order.state.refunded`)}[e]||e},isPendingAction(e){return e!==T.PAID&&e!==T.FINISHED&&e!==T.EXPIRED&&e!==T.FAILED&&e!==T.REFUNDED},goToDetail(e){this.$router.push({name:`console-order-detail`,params:{id:e}})},async onFilterChange(){await this.$router.push({name:this.$route.name?.toString(),query:{page:1,...this.filterState?{state:this.filterState}:{},...this.filterPayWay?{pay_way:this.filterPayWay}:{},...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0].toISOString()}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1].toISOString()}:{}}}),this.onFetchData(),this.onFetchSummary()},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,page:e}})},onFetchData(){this.loading=!0,E.getAll({ordering:`-created_at`,limit:this.limit,offset:(this.page-1)*this.limit,...this.filterQuery}).then(({data:e})=>{this.orders=e.items,this.total=e.count}).catch(()=>{}).finally(()=>{this.loading=!1})},onFetchSummary(){this.summaryLoading=!0,E.getSummary(this.filterQuery).then(({data:e})=>{this.summary=e}).catch(()=>{this.summary={...M}}).finally(()=>{this.summaryLoading=!1})},onExport(){this.exporting=!0,E.exportCsv(this.filterQuery).then(({data:e})=>{let t=window.URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`orders.csv`,n.click(),window.URL.revokeObjectURL(t)}).catch(()=>{}).finally(()=>{this.exporting=!1})}}}),P={class:`title`},F={key:1,class:`card-content`},I={class:`icon-wrapper`},L={class:`description`},R={class:`value`},z={key:1,class:`card-content`},B={class:`icon-wrapper`},V={class:`description`},H={class:`value`},U={key:1,class:`card-content`},W={class:`icon-wrapper`},ee={class:`description`},G={class:`value`},K={key:1,class:`card-content`},q={class:`icon-wrapper`},J={class:`description`},Y={class:`value`},X={class:`filter-row mb-3`},Z={class:`key`},Q={class:`cursor-pointer`},$={class:`price`},te={class:`description`},ne={class:`text-gray-500`},re={class:`created-at`},ie={class:`flex items-center justify-center flex-wrap`},ae={class:`float-right`};function oe(r,m,h,g,_,v){let y=f(`el-col`),b=f(`el-row`),x=f(`el-skeleton`),S=f(`font-awesome-icon`),C=f(`el-card`),w=f(`el-option`),T=f(`el-select`),E=f(`el-date-picker`),D=f(`el-button`),O=f(`copy-to-clipboard`),k=f(`el-table-column`),A=f(`el-tag`),j=f(`el-table`),M=f(`pagination`),N=d(`loading`);return l(),a(b,{class:`panel`},{default:p(()=>[o(y,{span:24},{default:p(()=>[o(b,null,{default:p(()=>[o(y,{span:24},{default:p(()=>[n(`h2`,P,c(r.$t(`common.title.allOrders`)),1)]),_:1})]),_:1}),o(b,{gutter:16},{default:p(()=>[o(y,{md:6,sm:12,xs:24},{default:p(()=>[o(C,{shadow:`hover`,class:`item-mini mb-3`},{default:p(()=>[r.summaryLoading?(l(),a(x,{key:0})):(l(),t(`div`,F,[n(`div`,I,[o(S,{icon:`fa-solid fa-receipt`,class:`icon`})]),n(`p`,L,c(r.$t(`order.title.totalOrders`)),1),n(`p`,R,c(r.summary.total_count),1)]))]),_:1})]),_:1}),o(y,{md:6,sm:12,xs:24},{default:p(()=>[o(C,{shadow:`hover`,class:`item-mini mb-3`},{default:p(()=>[r.summaryLoading?(l(),a(x,{key:0})):(l(),t(`div`,z,[n(`div`,B,[o(S,{icon:`fa-solid fa-dollar-sign`,class:`icon`})]),n(`p`,V,c(r.$t(`order.title.totalSpent`)),1),n(`p`,H,c(r.getPriceString({value:r.summary.total_spent})),1)]))]),_:1})]),_:1}),o(y,{md:6,sm:12,xs:24},{default:p(()=>[o(C,{shadow:`hover`,class:`item-mini mb-3`},{default:p(()=>[r.summaryLoading?(l(),a(x,{key:0})):(l(),t(`div`,U,[n(`div`,W,[o(S,{icon:`fa-solid fa-check-circle`,class:`icon`})]),n(`p`,ee,c(r.$t(`order.title.finishedOrders`)),1),n(`p`,G,c(r.summary.state_counts?.Finished||0),1)]))]),_:1})]),_:1}),o(y,{md:6,sm:12,xs:24},{default:p(()=>[o(C,{shadow:`hover`,class:`item-mini mb-3`},{default:p(()=>[r.summaryLoading?(l(),a(x,{key:0})):(l(),t(`div`,K,[n(`div`,q,[o(S,{icon:`fa-solid fa-clock`,class:`icon`})]),n(`p`,J,c(r.$t(`order.title.pendingOrders`)),1),n(`p`,Y,c(r.summary.state_counts?.Pending||0),1)]))]),_:1})]),_:1})]),_:1}),n(`div`,X,[o(T,{modelValue:r.filterState,"onUpdate:modelValue":m[0]||=e=>r.filterState=e,clearable:``,placeholder:r.$t(`order.field.allStates`),class:`filter-select`,onChange:r.onFilterChange},{default:p(()=>[(l(!0),t(s,null,e(r.stateOptions,e=>(l(),a(w,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]),o(T,{modelValue:r.filterPayWay,"onUpdate:modelValue":m[1]||=e=>r.filterPayWay=e,clearable:``,placeholder:r.$t(`order.field.allPayWays`),class:`filter-select`,onChange:r.onFilterChange},{default:p(()=>[(l(!0),t(s,null,e(r.payWayOptions,e=>(l(),a(w,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]),o(E,{modelValue:r.createdAtRange,"onUpdate:modelValue":m[2]||=e=>r.createdAtRange=e,type:`datetimerange`,shortcuts:r.shortcuts,"range-separator":r.$t(`usage.placeholder.to`),"start-placeholder":r.$t(`usage.placeholder.startDate`),"end-placeholder":r.$t(`usage.placeholder.endDate`),onChange:r.onFilterChange},null,8,[`modelValue`,`shortcuts`,`range-separator`,`start-placeholder`,`end-placeholder`,`onChange`]),o(D,{type:`primary`,plain:``,loading:r.exporting,onClick:r.onExport},{default:p(()=>[o(S,{icon:`fa-solid fa-file-export`,class:`mr-1`}),i(` `+c(r.$t(`order.button.export`)),1)]),_:1},8,[`loading`,`onClick`])]),o(b,null,{default:p(()=>[o(y,{span:24},{default:p(()=>[o(C,{shadow:`hover`},{default:p(()=>[u((l(),a(j,{data:r.orders,stripe:``,"empty-text":r.$t(`common.message.noData`),class:`min-h-[calc(100vh-450px)] mb-[20px]`},{default:p(()=>[o(k,{prop:`id`,label:r.$t(`order.field.id`),"class-name":`text-center`,width:`200px`},{default:p(e=>[n(`span`,Z,c(e.row.id),1),n(`span`,Q,[o(O,{content:e.row.id,class:`inline-block`},null,8,[`content`])])]),_:1},8,[`label`]),o(k,{label:r.$t(`order.field.price`),width:`110px`,align:`center`},{default:p(e=>[n(`span`,$,c(r.getPriceString({value:e.row?.price})),1)]),_:1},8,[`label`]),o(k,{label:r.$t(`order.field.description`),"min-width":`220px`,"class-name":`hidden md:table-cell`,"label-class-name":`hidden md:table-cell`},{default:p(e=>[n(`span`,te,c(e.row.description),1)]),_:1},8,[`label`]),o(k,{prop:`state`,label:r.$t(`order.field.state`),width:`130px`,align:`center`},{default:p(e=>[o(A,{type:r.stateTagType(e.row.state),class:`mx-1`,effect:`dark`,round:``,size:`small`},{default:p(()=>[i(c(r.stateLabel(e.row.state)),1)]),_:2},1032,[`type`])]),_:1},8,[`label`]),o(k,{label:r.$t(`order.field.payWay`),width:`120px`,align:`center`,"class-name":`hidden md:table-cell`,"label-class-name":`hidden md:table-cell`},{default:p(e=>[n(`span`,ne,c(e.row.pay_way||`-`),1)]),_:1},8,[`label`]),o(k,{label:r.$t(`order.field.createdAt`),width:`200px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:p(e=>[n(`span`,re,c(r.$dayjs.format(e.row.created_at)),1)]),_:1},8,[`label`]),o(k,{"min-width":`130px`,fixed:`right`},{default:p(e=>[n(`div`,ie,[r.isPendingAction(e.row.state)?(l(),a(D,{key:0,type:`primary`,size:`small`,onClick:t=>r.goToDetail(e.row.id)},{default:p(()=>[i(c(r.$t(`order.button.continuePay`)),1)]),_:1},8,[`onClick`])):(l(),a(D,{key:1,size:`small`,onClick:t=>r.goToDetail(e.row.id)},{default:p(()=>[i(c(r.$t(`order.button.checkDetail`)),1)]),_:1},8,[`onClick`]))])]),_:1})]),_:1},8,[`data`,`empty-text`])),[[N,r.loading]])]),_:1})]),_:1})]),_:1}),o(b,null,{default:p(()=>[o(y,{span:10,offset:14},{default:p(()=>[n(`div`,ae,[o(M,{"current-page":r.page,"page-size":r.limit,total:r.total,onChange:r.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var se=D(N,[[`render`,oe],[`__scopeId`,`data-v-350ab467`]]);export{se as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,dt as u,k as d,nt as f,tt as p,ut as m}from"./vendor-chart-BJCvKk8-.js";import{t as h}from"./button-BydTr5nV.js";import{n as g,t as ee}from"./table-B5c9kfrJ.js";import{t as _}from"./card-DjyfNde2.js";import{n as v,t as y}from"./row-Sw1tNXnG.js";import{t as b}from"./empty-CdsD8g84.js";import{t as x}from"./Pagination-Bx16Gkpp.js";import{t as S}from"./skeleton-BwNBivMN.js";import{t as C}from"./switch-CEDyFSsQ.js";import{o as w}from"./surface-D249_eDG.js";import{B as T,K as E,Mr as D,O,Tr as k,Wn as A,Wr as j,jr as M,wr as N,zr as P}from"./index-DoCEzMzZ.js";import{t as F}from"./index.es-CDSdB7LL.js";import{t as I}from"./CopyToClipboard-BqsCWkad.js";var L=r({name:`ConsoleApplicationList`,components:{Pagination:x,CopyToClipboard:I,ElTable:ee,ElRow:y,ElButton:h,ElCol:v,ElTag:j,ElSkeleton:S,ElSwitch:C,ElEmpty:b,ElTableColumn:g,ElCard:_,FontAwesomeIcon:F},data(){return{credentialType:N,serviceType:k,individualApplications:[],globalApplications:[],individualApplicationsTotal:void 0,globalApplicationsTotal:void 0,loading:!1,buying:!1,limit:10,form:{amount:1},active:{service:void 0,application:void 0}}},computed:{redirect(){return this.$route.query?.redirect},page(){return parseInt(this.$route.query.page?.toString()||`1`)},showGlobalPayment(){return!0}},watch:{page:{handler(){this.onFetchData()}}},mounted(){this.onInitializeGlobalApplication(),this.onFetchData()},methods:{rowCanPay(e){return w()?(e?.packages||[]).some(e=>e?.metadata?.apple_product_id):!0},updateAllowConsumeGlobal(e,t){!e||!e.id||A.updateAllConsumeGlobal(e.id,{...e,allow_consume_global:!!t}).then(()=>{P.success(this.$t(`application.message.updateSuccessfully`).toString())}).catch(()=>{P.error(this.$t(`application.message.updateFailed`).toString())})},onGoUsage(e){this.$router.push({name:E,query:{application_id:e.id,type:e?.service?.type}})},onBuyMore(e){e?.id&&this.$router.push({name:T,params:{id:e.id}})},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,page:e}})},onFetchApplications(e=M.INDIVIDUAL){return new Promise((t,n)=>{A.getAll({limit:this.limit,...e===M.INDIVIDUAL?{offset:(this.page-1)*this.limit}:{},user_id:this.$store.getters.user.id,ordering:`-created_at`,type:D.USAGE,scope:e}).then(({data:n})=>{e===M.INDIVIDUAL?(this.individualApplications=n.items,this.individualApplicationsTotal=n.count):(this.globalApplications=n.items,this.globalApplicationsTotal=n.count),t(n)}).catch(e=>{P.error(this.$t(`application.message.fetchFailed`).toString()),n(e)})})},onFetchData(){this.loading=!0,Promise.all([this.onFetchApplications(M.INDIVIDUAL),this.onFetchApplications(M.GLOBAL)]).then(()=>{this.loading=!1}).catch(()=>{this.loading=!1})},onInitializeGlobalApplication(){A.create({type:D.USAGE,scope:M.GLOBAL,user_id:this.$store.getters.user.id}).finally(()=>{this.onFetchApplications(M.GLOBAL)})},getRemainingAmount(e){if(e.remaining_amount===void 0||e.remaining_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.remaining_amount?.toFixed(6)} ${t}`},getUsedAmount(e){if(e.used_amount===void 0||e.used_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.used_amount?.toFixed(6)} ${t}`}}}),R={class:`title`},z={key:1,class:`summary-card`},B={class:`icon-wrapper`},V={class:`label`},H={class:`value`},U={class:`description`},W={key:1,class:`flex flex-row justify-between items-center gap-3`},G={class:`summary-card min-w-0 flex-1`},K={class:`flex justify-start items-center gap-2 mb-2 w-full`},q={class:`icon-wrapper !mb-0`},J={class:`text-[var(--el-text-color-regular)] text-[14px] truncate`},te={class:`label`},Y={class:`value`},X={class:`description`},Z={class:`flex flex-col items-end gap-2 shrink-0`},Q={class:`copy`},ne={key:0,class:`expired-at`},re={class:`flex flex-wrap items-center justify-end gap-1`},ie={class:`application-cards block sm:hidden`},ae={class:`flex items-center gap-2 flex-wrap`},oe={class:`application-card__name`},se={class:`application-card__id`},ce={class:`truncate`},le={class:`application-card__row`},ue={class:`label`},de={class:`value`},fe={key:0,class:`application-card__row`},pe={class:`label`},$={class:`value`},me={key:1,class:`application-card__row`},he={class:`label`},ge={class:`flex items-center justify-end gap-2 mt-3`},_e={class:`pagination`};function ve(r,h,g,ee,_,v){let y=p(`el-col`),b=p(`el-row`),x=p(`el-skeleton`),S=p(`font-awesome-icon`),C=p(`el-card`),w=p(`copy-to-clipboard`),T=p(`el-button`),E=p(`el-table-column`),D=p(`el-tag`),O=p(`el-switch`),k=p(`el-table`),A=p(`el-empty`),j=p(`pagination`),M=f(`loading`);return l(),a(b,{class:`application-list`},{default:m(()=>[o(y,{span:24},{default:m(()=>[o(b,null,{default:m(()=>[o(y,{span:24},{default:m(()=>[n(`h2`,R,c(r.$t(`common.title.allApplications`)),1)]),_:1})]),_:1}),o(b,{gutter:15,class:`mb-3`},{default:m(()=>[o(y,{md:12,xs:24},{default:m(()=>[o(C,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:m(()=>[r.loading?(l(),a(x,{key:0})):(l(),t(`div`,z,[n(`div`,B,[o(S,{icon:`fa-solid fa-cubes-stacked`})]),n(`p`,V,c(r.$t(`application.title.count`)),1),n(`p`,H,c(r.individualApplicationsTotal),1),n(`p`,U,c(r.$t(`application.message.countDescription`)),1)]))]),_:1})]),_:1}),r.showGlobalPayment&&r.globalApplications?.length>0?(l(),a(y,{key:0,md:12,xs:24},{default:m(()=>[o(C,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:m(()=>[r.loading?(l(),a(x,{key:0})):(l(),t(`div`,W,[n(`div`,G,[n(`div`,K,[n(`div`,q,[o(S,{icon:`fa-solid fa-wallet`})]),n(`span`,J,[i(c(r.$t(`application.field.id`))+`: `+c(r.globalApplications?.[0]?.id)+` `,1),r.globalApplications?.[0]?.id?(l(),a(w,{key:0,content:r.globalApplications?.[0]?.id,class:`inline-block`},null,8,[`content`])):d(``,!0)])]),n(`p`,te,c(r.$t(`application.title.globalBalance`)),1),n(`p`,Y,c(r.globalApplications?.[0]?.remaining_amount?.toFixed(6)||`0.000000`)+` `+c(r.$t(`service.unit.credits`)),1),n(`p`,X,c(r.$t(`application.message.globalBalanceDescription`)),1)]),n(`div`,Z,[o(T,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:h[0]||=e=>r.onGoUsage(r.globalApplications?.[0])},{default:m(()=>[o(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.usage`)),1)]),_:1}),r.showGlobalPayment?(l(),a(T,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:h[1]||=e=>r.onBuyMore(r.globalApplications?.[0])},{default:m(()=>[o(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.buyMore`)),1)]),_:1})):d(``,!0)])]))]),_:1})]),_:1})):d(``,!0)]),_:1}),o(b,null,{default:m(()=>[o(y,{span:24},{default:m(()=>[o(C,{shadow:`hover`,class:`applications-table-card hidden sm:block`},{default:m(()=>[u((l(),a(k,{data:r.individualApplications,stripe:``,class:`applications-table !min-h-[calc(100vh-420px)]`,"table-layout":`fixed`,"empty-text":r.$t(`common.message.noData`)},{default:m(()=>[o(E,{prop:`id`,label:r.$t(`application.field.id`),width:`200px`,"class-name":`text-center`},{default:m(e=>[n(`span`,null,c(e.row.id),1),n(`span`,Q,[o(w,{content:e?.row?.id,class:`inline-block`},null,8,[`content`])])]),_:1},8,[`label`]),o(E,{label:r.$t(`application.field.type`),width:`90px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[e.row?.type===`Period`?(l(),a(D,{key:0,type:`success`,effect:`dark`,round:``},{default:m(()=>[i(c(r.$t(`application.type.period`)),1)]),_:1})):e.row?.type===`Usage`?(l(),a(D,{key:1,effect:`dark`,round:``},{default:m(()=>[i(c(r.$t(`application.type.usage`)),1)]),_:1})):d(``,!0)]),_:1},8,[`label`]),o(E,{label:r.$t(`application.field.name`),width:`180px`},{default:m(e=>[n(`span`,null,c(e.row?.service?.title),1),e.row?.role===`grantee`?(l(),a(D,{key:0,type:`info`,size:`small`,round:``,class:`ml-2`},{default:m(()=>[i(c(r.$t(`application.badge.shared`)),1)]),_:1})):d(``,!0)]),_:1},8,[`label`]),o(E,{prop:`remaining_amount`,label:r.$t(`application.field.remainingAmount`),width:`150px`,"class-name":`text-center`},{default:m(e=>[n(`span`,null,c(r.getRemainingAmount(e.row)),1)]),_:1},8,[`label`]),o(E,{prop:`used_amount`,label:r.$t(`application.field.usedAmount`),width:`150px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[n(`span`,null,c(r.getUsedAmount(e.row)),1)]),_:1},8,[`label`]),o(E,{prop:`allow_consume_global`,label:r.$t(`application.field.allowConsumeGlobal`),width:`120px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[e.row.service?.type===r.serviceType.API?(l(),a(O,{key:0,modelValue:e.row.allow_consume_global,"onUpdate:modelValue":t=>e.row.allow_consume_global=t,"active-value":!0,"inactive-value":!1,onChange:t=>r.updateAllowConsumeGlobal(e.row,t)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])):d(``,!0)]),_:1},8,[`label`]),o(E,{label:r.$t(`application.field.expiredAt`),width:`180px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[e.row.expired_at?(l(),t(`span`,ne,c(r.$dayjs.format(e.row.expired_at)),1)):d(``,!0)]),_:1},8,[`label`]),o(E,{fixed:`right`,width:`200px`},{default:m(e=>[n(`div`,re,[o(T,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:t=>r.onGoUsage(e?.row)},{default:m(()=>[o(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),r.rowCanPay(e?.row)?(l(),a(T,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:t=>r.onBuyMore(e?.row)},{default:m(()=>[o(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):d(``,!0)])]),_:1})]),_:1},8,[`data`,`empty-text`])),[[M,r.loading]])]),_:1}),n(`div`,ie,[r.loading?(l(),a(x,{key:0,rows:4,animated:``})):(l(),t(s,{key:1},[r.individualApplications?.length?(l(!0),t(s,{key:1},e(r.individualApplications,e=>(l(),a(C,{key:e.id,shadow:`hover`,class:`application-card mb-2`,"body-style":{padding:`14px 16px`}},{default:m(()=>[n(`div`,ae,[n(`span`,oe,c(e?.service?.title),1),e?.type===`Period`?(l(),a(D,{key:0,type:`success`,effect:`dark`,size:`small`,round:``},{default:m(()=>[i(c(r.$t(`application.type.period`)),1)]),_:1})):e?.type===`Usage`?(l(),a(D,{key:1,effect:`dark`,size:`small`,round:``},{default:m(()=>[i(c(r.$t(`application.type.usage`)),1)]),_:1})):d(``,!0),e?.role===`grantee`?(l(),a(D,{key:2,type:`info`,size:`small`,round:``},{default:m(()=>[i(c(r.$t(`application.badge.shared`)),1)]),_:1})):d(``,!0)]),n(`div`,se,[n(`span`,ce,c(r.$t(`application.field.id`))+`: `+c(e.id),1),o(w,{content:e.id,class:`inline-block shrink-0`},null,8,[`content`])]),n(`div`,le,[n(`span`,ue,c(r.$t(`application.field.remainingAmount`)),1),n(`span`,de,c(r.getRemainingAmount(e)),1)]),e?.expired_at?(l(),t(`div`,fe,[n(`span`,pe,c(r.$t(`application.field.expiredAt`)),1),n(`span`,$,c(r.$dayjs.format(e.expired_at)),1)])):d(``,!0),e.service?.type===r.serviceType.API?(l(),t(`div`,me,[n(`span`,he,c(r.$t(`application.field.allowConsumeGlobal`)),1),o(O,{modelValue:e.allow_consume_global,"onUpdate:modelValue":t=>e.allow_consume_global=t,"active-value":!0,"inactive-value":!1,onChange:t=>r.updateAllowConsumeGlobal(e,t)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])])):d(``,!0),n(`div`,ge,[o(T,{class:`!m-0 !px-3`,size:`small`,round:``,onClick:t=>r.onGoUsage(e)},{default:m(()=>[o(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),r.rowCanPay(e)?(l(),a(T,{key:0,class:`!m-0 !px-3`,type:`primary`,round:``,size:`small`,onClick:t=>r.onBuyMore(e)},{default:m(()=>[o(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):d(``,!0)])]),_:2},1024))),128)):(l(),a(A,{key:0,description:r.$t(`common.message.noData`)},null,8,[`description`]))],64))])]),_:1})]),_:1}),o(b,null,{default:m(()=>[o(y,{span:24},{default:m(()=>[n(`div`,_e,[o(j,{"current-page":r.page,"page-size":r.limit,total:r.individualApplicationsTotal,onChange:r.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var ye=O(L,[[`render`,ve],[`__scopeId`,`data-v-b4164ed9`]]);export{ye as default};
|
|
1
|
+
import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,dt as u,k as d,nt as f,tt as p,ut as m}from"./vendor-chart-BJCvKk8-.js";import{t as h}from"./button-BydTr5nV.js";import{n as g,t as ee}from"./table-B5c9kfrJ.js";import{t as _}from"./card-DjyfNde2.js";import{n as v,t as y}from"./row-B5bv9JPh.js";import{t as b}from"./empty-CdsD8g84.js";import{t as x}from"./Pagination-CEMukh4X.js";import{t as S}from"./skeleton-BwNBivMN.js";import{t as C}from"./switch-9ZO_9tNo.js";import{o as w}from"./surface-D249_eDG.js";import{B as T,K as E,Mr as D,O,Tr as k,Wn as A,Wr as j,jr as M,wr as N,zr as P}from"./index-BwuZeZD0.js";import{t as F}from"./index.es-BAFsTiuS.js";import{t as I}from"./CopyToClipboard-B8J4icuV.js";var L=r({name:`ConsoleApplicationList`,components:{Pagination:x,CopyToClipboard:I,ElTable:ee,ElRow:y,ElButton:h,ElCol:v,ElTag:j,ElSkeleton:S,ElSwitch:C,ElEmpty:b,ElTableColumn:g,ElCard:_,FontAwesomeIcon:F},data(){return{credentialType:N,serviceType:k,individualApplications:[],globalApplications:[],individualApplicationsTotal:void 0,globalApplicationsTotal:void 0,loading:!1,buying:!1,limit:10,form:{amount:1},active:{service:void 0,application:void 0}}},computed:{redirect(){return this.$route.query?.redirect},page(){return parseInt(this.$route.query.page?.toString()||`1`)},showGlobalPayment(){return!0}},watch:{page:{handler(){this.onFetchData()}}},mounted(){this.onInitializeGlobalApplication(),this.onFetchData()},methods:{rowCanPay(e){return w()?(e?.packages||[]).some(e=>e?.metadata?.apple_product_id):!0},updateAllowConsumeGlobal(e,t){!e||!e.id||A.updateAllConsumeGlobal(e.id,{...e,allow_consume_global:!!t}).then(()=>{P.success(this.$t(`application.message.updateSuccessfully`).toString())}).catch(()=>{P.error(this.$t(`application.message.updateFailed`).toString())})},onGoUsage(e){this.$router.push({name:E,query:{application_id:e.id,type:e?.service?.type}})},onBuyMore(e){e?.id&&this.$router.push({name:T,params:{id:e.id}})},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,page:e}})},onFetchApplications(e=M.INDIVIDUAL){return new Promise((t,n)=>{A.getAll({limit:this.limit,...e===M.INDIVIDUAL?{offset:(this.page-1)*this.limit}:{},user_id:this.$store.getters.user.id,ordering:`-created_at`,type:D.USAGE,scope:e}).then(({data:n})=>{e===M.INDIVIDUAL?(this.individualApplications=n.items,this.individualApplicationsTotal=n.count):(this.globalApplications=n.items,this.globalApplicationsTotal=n.count),t(n)}).catch(e=>{P.error(this.$t(`application.message.fetchFailed`).toString()),n(e)})})},onFetchData(){this.loading=!0,Promise.all([this.onFetchApplications(M.INDIVIDUAL),this.onFetchApplications(M.GLOBAL)]).then(()=>{this.loading=!1}).catch(()=>{this.loading=!1})},onInitializeGlobalApplication(){A.create({type:D.USAGE,scope:M.GLOBAL,user_id:this.$store.getters.user.id}).finally(()=>{this.onFetchApplications(M.GLOBAL)})},getRemainingAmount(e){if(e.remaining_amount===void 0||e.remaining_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.remaining_amount?.toFixed(6)} ${t}`},getUsedAmount(e){if(e.used_amount===void 0||e.used_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.used_amount?.toFixed(6)} ${t}`}}}),R={class:`title`},z={key:1,class:`summary-card`},B={class:`icon-wrapper`},V={class:`label`},H={class:`value`},U={class:`description`},W={key:1,class:`flex flex-row justify-between items-center gap-3`},G={class:`summary-card min-w-0 flex-1`},K={class:`flex justify-start items-center gap-2 mb-2 w-full`},q={class:`icon-wrapper !mb-0`},J={class:`text-[var(--el-text-color-regular)] text-[14px] truncate`},te={class:`label`},Y={class:`value`},X={class:`description`},Z={class:`flex flex-col items-end gap-2 shrink-0`},Q={class:`copy`},ne={key:0,class:`expired-at`},re={class:`flex flex-wrap items-center justify-end gap-1`},ie={class:`application-cards block sm:hidden`},ae={class:`flex items-center gap-2 flex-wrap`},oe={class:`application-card__name`},se={class:`application-card__id`},ce={class:`truncate`},le={class:`application-card__row`},ue={class:`label`},de={class:`value`},fe={key:0,class:`application-card__row`},pe={class:`label`},$={class:`value`},me={key:1,class:`application-card__row`},he={class:`label`},ge={class:`flex items-center justify-end gap-2 mt-3`},_e={class:`pagination`};function ve(r,h,g,ee,_,v){let y=p(`el-col`),b=p(`el-row`),x=p(`el-skeleton`),S=p(`font-awesome-icon`),C=p(`el-card`),w=p(`copy-to-clipboard`),T=p(`el-button`),E=p(`el-table-column`),D=p(`el-tag`),O=p(`el-switch`),k=p(`el-table`),A=p(`el-empty`),j=p(`pagination`),M=f(`loading`);return l(),a(b,{class:`application-list`},{default:m(()=>[o(y,{span:24},{default:m(()=>[o(b,null,{default:m(()=>[o(y,{span:24},{default:m(()=>[n(`h2`,R,c(r.$t(`common.title.allApplications`)),1)]),_:1})]),_:1}),o(b,{gutter:15,class:`mb-3`},{default:m(()=>[o(y,{md:12,xs:24},{default:m(()=>[o(C,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:m(()=>[r.loading?(l(),a(x,{key:0})):(l(),t(`div`,z,[n(`div`,B,[o(S,{icon:`fa-solid fa-cubes-stacked`})]),n(`p`,V,c(r.$t(`application.title.count`)),1),n(`p`,H,c(r.individualApplicationsTotal),1),n(`p`,U,c(r.$t(`application.message.countDescription`)),1)]))]),_:1})]),_:1}),r.showGlobalPayment&&r.globalApplications?.length>0?(l(),a(y,{key:0,md:12,xs:24},{default:m(()=>[o(C,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:m(()=>[r.loading?(l(),a(x,{key:0})):(l(),t(`div`,W,[n(`div`,G,[n(`div`,K,[n(`div`,q,[o(S,{icon:`fa-solid fa-wallet`})]),n(`span`,J,[i(c(r.$t(`application.field.id`))+`: `+c(r.globalApplications?.[0]?.id)+` `,1),r.globalApplications?.[0]?.id?(l(),a(w,{key:0,content:r.globalApplications?.[0]?.id,class:`inline-block`},null,8,[`content`])):d(``,!0)])]),n(`p`,te,c(r.$t(`application.title.globalBalance`)),1),n(`p`,Y,c(r.globalApplications?.[0]?.remaining_amount?.toFixed(6)||`0.000000`)+` `+c(r.$t(`service.unit.credits`)),1),n(`p`,X,c(r.$t(`application.message.globalBalanceDescription`)),1)]),n(`div`,Z,[o(T,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:h[0]||=e=>r.onGoUsage(r.globalApplications?.[0])},{default:m(()=>[o(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.usage`)),1)]),_:1}),r.showGlobalPayment?(l(),a(T,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:h[1]||=e=>r.onBuyMore(r.globalApplications?.[0])},{default:m(()=>[o(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.buyMore`)),1)]),_:1})):d(``,!0)])]))]),_:1})]),_:1})):d(``,!0)]),_:1}),o(b,null,{default:m(()=>[o(y,{span:24},{default:m(()=>[o(C,{shadow:`hover`,class:`applications-table-card hidden sm:block`},{default:m(()=>[u((l(),a(k,{data:r.individualApplications,stripe:``,class:`applications-table !min-h-[calc(100vh-420px)]`,"table-layout":`fixed`,"empty-text":r.$t(`common.message.noData`)},{default:m(()=>[o(E,{prop:`id`,label:r.$t(`application.field.id`),width:`200px`,"class-name":`text-center`},{default:m(e=>[n(`span`,null,c(e.row.id),1),n(`span`,Q,[o(w,{content:e?.row?.id,class:`inline-block`},null,8,[`content`])])]),_:1},8,[`label`]),o(E,{label:r.$t(`application.field.type`),width:`90px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[e.row?.type===`Period`?(l(),a(D,{key:0,type:`success`,effect:`dark`,round:``},{default:m(()=>[i(c(r.$t(`application.type.period`)),1)]),_:1})):e.row?.type===`Usage`?(l(),a(D,{key:1,effect:`dark`,round:``},{default:m(()=>[i(c(r.$t(`application.type.usage`)),1)]),_:1})):d(``,!0)]),_:1},8,[`label`]),o(E,{label:r.$t(`application.field.name`),width:`180px`},{default:m(e=>[n(`span`,null,c(e.row?.service?.title),1),e.row?.role===`grantee`?(l(),a(D,{key:0,type:`info`,size:`small`,round:``,class:`ml-2`},{default:m(()=>[i(c(r.$t(`application.badge.shared`)),1)]),_:1})):d(``,!0)]),_:1},8,[`label`]),o(E,{prop:`remaining_amount`,label:r.$t(`application.field.remainingAmount`),width:`150px`,"class-name":`text-center`},{default:m(e=>[n(`span`,null,c(r.getRemainingAmount(e.row)),1)]),_:1},8,[`label`]),o(E,{prop:`used_amount`,label:r.$t(`application.field.usedAmount`),width:`150px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[n(`span`,null,c(r.getUsedAmount(e.row)),1)]),_:1},8,[`label`]),o(E,{prop:`allow_consume_global`,label:r.$t(`application.field.allowConsumeGlobal`),width:`120px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[e.row.service?.type===r.serviceType.API?(l(),a(O,{key:0,modelValue:e.row.allow_consume_global,"onUpdate:modelValue":t=>e.row.allow_consume_global=t,"active-value":!0,"inactive-value":!1,onChange:t=>r.updateAllowConsumeGlobal(e.row,t)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])):d(``,!0)]),_:1},8,[`label`]),o(E,{label:r.$t(`application.field.expiredAt`),width:`180px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[e.row.expired_at?(l(),t(`span`,ne,c(r.$dayjs.format(e.row.expired_at)),1)):d(``,!0)]),_:1},8,[`label`]),o(E,{fixed:`right`,width:`200px`},{default:m(e=>[n(`div`,re,[o(T,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:t=>r.onGoUsage(e?.row)},{default:m(()=>[o(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),r.rowCanPay(e?.row)?(l(),a(T,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:t=>r.onBuyMore(e?.row)},{default:m(()=>[o(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):d(``,!0)])]),_:1})]),_:1},8,[`data`,`empty-text`])),[[M,r.loading]])]),_:1}),n(`div`,ie,[r.loading?(l(),a(x,{key:0,rows:4,animated:``})):(l(),t(s,{key:1},[r.individualApplications?.length?(l(!0),t(s,{key:1},e(r.individualApplications,e=>(l(),a(C,{key:e.id,shadow:`hover`,class:`application-card mb-2`,"body-style":{padding:`14px 16px`}},{default:m(()=>[n(`div`,ae,[n(`span`,oe,c(e?.service?.title),1),e?.type===`Period`?(l(),a(D,{key:0,type:`success`,effect:`dark`,size:`small`,round:``},{default:m(()=>[i(c(r.$t(`application.type.period`)),1)]),_:1})):e?.type===`Usage`?(l(),a(D,{key:1,effect:`dark`,size:`small`,round:``},{default:m(()=>[i(c(r.$t(`application.type.usage`)),1)]),_:1})):d(``,!0),e?.role===`grantee`?(l(),a(D,{key:2,type:`info`,size:`small`,round:``},{default:m(()=>[i(c(r.$t(`application.badge.shared`)),1)]),_:1})):d(``,!0)]),n(`div`,se,[n(`span`,ce,c(r.$t(`application.field.id`))+`: `+c(e.id),1),o(w,{content:e.id,class:`inline-block shrink-0`},null,8,[`content`])]),n(`div`,le,[n(`span`,ue,c(r.$t(`application.field.remainingAmount`)),1),n(`span`,de,c(r.getRemainingAmount(e)),1)]),e?.expired_at?(l(),t(`div`,fe,[n(`span`,pe,c(r.$t(`application.field.expiredAt`)),1),n(`span`,$,c(r.$dayjs.format(e.expired_at)),1)])):d(``,!0),e.service?.type===r.serviceType.API?(l(),t(`div`,me,[n(`span`,he,c(r.$t(`application.field.allowConsumeGlobal`)),1),o(O,{modelValue:e.allow_consume_global,"onUpdate:modelValue":t=>e.allow_consume_global=t,"active-value":!0,"inactive-value":!1,onChange:t=>r.updateAllowConsumeGlobal(e,t)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])])):d(``,!0),n(`div`,ge,[o(T,{class:`!m-0 !px-3`,size:`small`,round:``,onClick:t=>r.onGoUsage(e)},{default:m(()=>[o(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),r.rowCanPay(e)?(l(),a(T,{key:0,class:`!m-0 !px-3`,type:`primary`,round:``,size:`small`,onClick:t=>r.onBuyMore(e)},{default:m(()=>[o(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):d(``,!0)])]),_:2},1024))),128)):(l(),a(A,{key:0,description:r.$t(`common.message.noData`)},null,8,[`description`]))],64))])]),_:1})]),_:1}),o(b,null,{default:m(()=>[o(y,{span:24},{default:m(()=>[n(`div`,_e,[o(j,{"current-page":r.page,"page-size":r.limit,total:r.individualApplicationsTotal,onChange:r.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var ye=O(L,[[`render`,ve],[`__scopeId`,`data-v-b4164ed9`]]);export{ye as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as e,D as t,F as n,P as r,Wt as i,Z as a,tt as o}from"./vendor-chart-BJCvKk8-.js";import{O as s}from"./index-
|
|
1
|
+
import{A as e,D as t,F as n,P as r,Wt as i,Z as a,tt as o}from"./vendor-chart-BJCvKk8-.js";import{O as s}from"./index-BwuZeZD0.js";import{t as c}from"./LocalTools-eQ_lSuK6.js";var l=n({name:`SettingsLocalTools`,components:{LocalToolsSetting:c}}),u={class:`local-tools-page`};function d(n,s,c,l,d,f){let p=o(`local-tools-setting`);return a(),e(`div`,u,[t(`h2`,null,i(n.$t(`common.settings.localTools`)),1),r(p)])}var f=s(l,[[`render`,d],[`__scopeId`,`data-v-ac732814`]]);export{f as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,k as u,tt as d,ut as f}from"./vendor-chart-BJCvKk8-.js";import{t as p}from"./button-BydTr5nV.js";import{H as ee}from"./use-deprecated-B-NFNg3W.js";import{t as te}from"./switch-
|
|
1
|
+
import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,k as u,tt as d,ut as f}from"./vendor-chart-BJCvKk8-.js";import{t as p}from"./button-BydTr5nV.js";import{H as ee}from"./use-deprecated-B-NFNg3W.js";import{t as te}from"./switch-9ZO_9tNo.js";import{i as m}from"./surface-D249_eDG.js";import{A as h,Kr as g,O as _,Wr as v}from"./index-BwuZeZD0.js";import{t as y}from"./index.es-BAFsTiuS.js";var b=r({name:`LocalToolsSetting`,components:{ElButton:p,ElTag:v,ElSwitch:te,ElInput:g,FontAwesomeIcon:y},data(){return{Plus:ee,roots:[],tools:[],mcpServers:[],mcpUid:0,mcpStatuses:[],mcpBusy:null,savingMcp:!1,mcpSavedTip:!1,mcpError:``,grants:null,perm:null,computerUse:!1,computerTools:[],computerGrants:{},cuBusy:null,builtinTools:[],toolGrants:{},builtinBusy:null,savingCU:!1,preauthorizing:!1,saving:!1,savedTip:!1,a11yEnabled:!1,onFocus:null,cuOff:null}},computed:{desktop(){return!!h()},android(){return m()}},async mounted(){let e=h();if(!e)return;let t=await e.getConfig();this.roots=t.roots,this.computerUse=t.computerUse===!0,this.mcpServers=(t.mcp??[]).map(e=>({_uid:this.mcpUid++,id:e.id,command:e.command,argsText:(e.args??[]).join(`
|
|
2
2
|
`),envText:Object.entries(e.env??{}).map(([e,t])=>`${e}=${t}`).join(`
|
|
3
3
|
`),enabled:e.enabled!==!1})),this.mcpStatuses=await e.mcp?.status()??[],this.tools=(await e.listTools()).map(e=>e.name),this.computerTools=await e.computerTools?.()??[],this.builtinTools=await e.builtinTools?.()??[];let n=await e.perm?.status();n?.mac&&(this.perm=n),await this.loadGrants(),this.android&&(await this.refreshA11y(),this.onFocus=()=>{document.visibilityState===`visible`&&this.refreshA11y()},document.addEventListener(`visibilitychange`,this.onFocus)),this.cuOff=e.onComputerUseDisabled?.(()=>{this.computerUse=!1})??null},beforeUnmount(){this.cuOff?.(),this.onFocus&&document.removeEventListener(`visibilitychange`,this.onFocus)},methods:{async refreshA11y(){let e=await h()?.perm?.status();this.a11yEnabled=e?.accessibility===!0},async openAndroidAccessibility(){await h()?.perm?.openPane(`accessibility`)},async loadGrants(){let e=h();if(!e?.grants){this.grants=null;return}let t=await e.grants.list(),n={},r={},i=new Set(this.builtinTools.map(e=>e.name)),a=[];for(let e of t){if(e.startsWith(`computer.`)&&!e.includes(`:`)){n[e]=!0;continue}if(!e.includes(`:`)&&i.has(e)){r[e]=!0;continue}let t=e.indexOf(`:{`),o=t>=0?t:e.indexOf(`:`);a.push({key:e,name:o>=0?e.slice(0,o):e,input:o>=0?e.slice(o+1):``})}this.computerGrants=n,this.toolGrants=r,this.grants=a},async addFolder(){let e=await h()?.pickFolder();e&&!this.roots.includes(e)&&this.roots.push(e)},removeRoot(e){this.roots.splice(e,1)},addMcp(){this.mcpServers.push({_uid:this.mcpUid++,id:``,command:``,argsText:``,envText:``,enabled:!0})},removeMcp(e){this.mcpServers.splice(e,1)},mcpStatusFor(e){let t=e.trim();return this.mcpStatuses.find(e=>e.id===t)},mcpBadgeType(e){let t=this.mcpStatusFor(e)?.status;return t===`connected`?`success`:t===`failed`?`danger`:`info`},mcpBadgeText(e){let t=this.mcpStatusFor(e);return this.mcpBusy===e.trim()?this.$t(`common.settings.localToolsMcpConnecting`):t?t.status===`connected`?this.$t(`common.settings.localToolsMcpConnected`,{n:t.toolCount}):t.status===`disabled`?this.$t(`common.settings.localToolsMcpDisabled`):this.$t(`common.settings.localToolsMcpFailed`):this.$t(`common.settings.localToolsMcpNotSaved`)},mcpErrorFor(e){let t=this.mcpStatusFor(e);return t?.status===`failed`&&t.error?t.error:``},buildMcpPayload(){this.mcpError=``;let e=[],t=new Set;for(let n of this.mcpServers){let r=n.id.trim(),i=n.command.trim();if(!r||!i)return this.mcpError=this.$t(`common.settings.localToolsMcpNameRequired`),null;if(!/^[A-Za-z0-9_-]+$/.test(r))return this.mcpError=this.$t(`common.settings.localToolsMcpNameInvalid`),null;if(t.has(r))return this.mcpError=this.$t(`common.settings.localToolsMcpDuplicateName`),null;t.add(r);let a=n.argsText.split(`
|
|
4
4
|
`).map(e=>e.trim()).filter(Boolean),o={};for(let e of n.envText.split(`
|