@acedatacloud/nexior 3.326.2 → 3.327.0
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-xwJDhZOe.js → ApiCodeButton-BjtkLb7c.js} +1 -1
- package/dist/assets/{Artifacts-DrOfdbLQ.js → Artifacts-ChttZvG5.js} +1 -1
- package/dist/assets/{AskUserQuestionCard-D9lCCIyx.js → AskUserQuestionCard-C8eIhYgm.js} +1 -1
- package/dist/assets/{Auth-fXGzAW9t.js → Auth-CoRg4CB2.js} +1 -1
- package/dist/assets/{Bare-Cy8LJ112.js → Bare-4SQ3D8qO.js} +1 -1
- package/dist/assets/{BotPlaceholder-BRgbQOrp.js → BotPlaceholder-nYgSf_zI.js} +1 -1
- package/dist/assets/{BottomFooter-CaztjWjC.js → BottomFooter-ByBNWzrc.js} +1 -1
- package/dist/assets/{Callback-CfE0osgl.js → Callback-DdQ6_8_x.js} +1 -1
- package/dist/assets/{CodeSnippet-DviKfpAQ.js → CodeSnippet-CUfvjt9O.js} +1 -1
- package/dist/assets/{Console-BtSpOpY9.js → Console-CgsiOVgQ.js} +1 -1
- package/dist/assets/{Consumption-Dkf2iVZI.js → Consumption-BZfcI4CV.js} +1 -1
- package/dist/assets/{Conversation-BCHcnUYk.js → Conversation-BwwPMOvN.js} +1 -1
- package/dist/assets/{Conversation-VcaBOWDy.js → Conversation-ucBJ0gzH.js} +1 -1
- package/dist/assets/{CopyToClipboard-D9EquLu_.js → CopyToClipboard-B1VphMUw.js} +1 -1
- package/dist/assets/{Detail-DGuaLj6e.js → Detail-DOWbZ2TL.js} +2 -2
- package/dist/assets/{Extra-DxRhyaRD.js → Extra-BiQX9dXy.js} +1 -1
- package/dist/assets/{FilePreview-oEaNU3WW.js → FilePreview-D_pCB9_L.js} +1 -1
- package/dist/assets/{Hailuo-nWyaeZm9.js → Hailuo-ou0j9eZW.js} +1 -1
- package/dist/assets/{History-CSbhEV0v.js → History-RVqFV5eB.js} +1 -1
- package/dist/assets/{ImagePreview-YRfRWo9W.js → ImagePreview-BEXz3Sfq.js} +1 -1
- package/dist/assets/{ImageWrapper-BVMF1vjV.js → ImageWrapper-BSp8_LnL.js} +1 -1
- package/dist/assets/{Index-BwIiLANG.js → Index-08H5zvLO.js} +1 -1
- package/dist/assets/{Index-DD-ZnikW.js → Index-8k_kkcaZ.js} +1 -1
- package/dist/assets/{Index-acNgcC4V.js → Index-B0-vL0Vv.js} +1 -1
- package/dist/assets/{Index-Dh5gX5e_.js → Index-B0Zm71dl.js} +1 -1
- package/dist/assets/Index-B5IuOA6z.js +1 -0
- package/dist/assets/{Index-DQhZOIji.js → Index-BLlTsQE0.js} +1 -1
- package/dist/assets/{Index-BtLBVRQ_.js → Index-BPurZkbD.js} +1 -1
- package/dist/assets/{Index-i-MMrdeG.js → Index-C-6FESPS.js} +1 -1
- package/dist/assets/{Index-D_jqnsC_.js → Index-C6Ry0YVI.js} +1 -1
- package/dist/assets/{Index-mjqC_tyg.js → Index-CIS2-LeJ.js} +1 -1
- package/dist/assets/{Index-DFWACRcz.js → Index-CIbbdPbr.js} +1 -1
- package/dist/assets/{Index-D_bZ1ETE.js → Index-CPqAEzb5.js} +1 -1
- package/dist/assets/{Index-BaNPV_Mj.js → Index-Ck5Eb_Ne.js} +1 -1
- package/dist/assets/{Index-B6TQ8D65.js → Index-Cozsxwgs.js} +1 -1
- package/dist/assets/{Index-DK9D9wiI.js → Index-CsyXOJeG.js} +1 -1
- package/dist/assets/{Index-BMqPpOp2.js → Index-CxBf017N.js} +1 -1
- package/dist/assets/{Index-BcOGYVBr.js → Index-DFhl82Xw.js} +1 -1
- package/dist/assets/{Index-DuAyEGOx.js → Index-DnzNgXwR.js} +1 -1
- package/dist/assets/{Index-CamLwN-w.js → Index-Dz3EQqOm.js} +1 -1
- package/dist/assets/{Index-BUyaX7yj.js → Index-IkAFIy3B.js} +1 -1
- package/dist/assets/{Index-Df46989q.js → Index-PfJT1M_Q.js} +1 -1
- package/dist/assets/{Index-Dq0spg7g.js → Index-PlyGFAaX.js} +1 -1
- package/dist/assets/{Index-CbBadZlH.js → Index-S18JJBhC.js} +1 -1
- package/dist/assets/{Index-BolvHk3C.js → Index-UZzrwY3t.js} +1 -1
- package/dist/assets/{Index-BQiYekum.js → Index-WTT_SieY.js} +1 -1
- package/dist/assets/{Index-g4lXpqJr.js → Index-bP5ohGdK.js} +1 -1
- package/dist/assets/Index-ie4OX51-.css +1 -0
- package/dist/assets/{Index-DftzFcSY.js → Index-rtdSFNAo.js} +1 -1
- package/dist/assets/{Index-crOK2Adu.js → Index-vDFMaCSq.js} +1 -1
- package/dist/assets/{Index-DibvyoRC.js → Index-wIvsnD1E.js} +1 -1
- package/dist/assets/{Invitees-CBZfzYCA.js → Invitees-Bb6fct76.js} +1 -1
- package/dist/assets/{List-CrvjwSpV.js → List-C6yYb_aB.js} +1 -1
- package/dist/assets/{List-YYmn2L3s.js → List-CRUgYPFh.js} +1 -1
- package/dist/assets/{List-CzZC-aqm.js → List-DloCBs90.js} +1 -1
- package/dist/assets/{LocalTools-CRN-Gp0U.js → LocalTools-C_Sa1LaL.js} +1 -1
- package/dist/assets/{LocalTools-BP_5cXAL.js → LocalTools-DMXyjh59.js} +1 -1
- package/dist/assets/{Main-BhftGmOD.js → Main-DkcN76D7.js} +1 -1
- package/dist/assets/{Message-BLsnRppj.js → Message-Bz0KQDES.js} +1 -1
- package/dist/assets/{Model-DGeY6IgQ.js → Model-B8dADhid.js} +1 -1
- package/dist/assets/Navigator-B8kHU0Nv.css +1 -0
- package/dist/assets/{Navigator-BPsierXw.js → Navigator-DIqP0pBF.js} +3 -3
- package/dist/assets/{NoTasks-aQlCIMQ-.js → NoTasks-EnkPu5PA.js} +1 -1
- package/dist/assets/{NotFound-BSYPR1j8.js → NotFound-Coo8fh-u.js} +1 -1
- package/dist/assets/{Pay-CGyfB7sd.js → Pay-SsmXb_fs.js} +1 -1
- package/dist/assets/{Player-Bj93Yik6.js → Player-DfKucsKu.js} +1 -1
- package/dist/assets/{PromptTextarea-hv4s5RNk.js → PromptTextarea-D4708v1G.js} +1 -1
- package/dist/assets/{RealtimeCall-DGUVBJjt.js → RealtimeCall-D8vpKsYA.js} +1 -1
- package/dist/assets/{ScheduledTasks-C5H_ZLFU.js → ScheduledTasks-BHXxFWf5.js} +1 -1
- package/dist/assets/{Status-C1Nti3Rj.js → Status-DmbaNjnQ.js} +1 -1
- package/dist/assets/{Subscribe-DfDvXqRi.js → Subscribe-DItp9JU2.js} +1 -1
- package/dist/assets/{TabSwitcher-B7yRSnkT.js → TabSwitcher-Bref4zxH.js} +1 -1
- package/dist/assets/{Tts-DtxKIZPi.js → Tts-Bi9KURUF.js} +1 -1
- package/dist/assets/{VideoPlayer-Bvma4ufX.js → VideoPlayer-CNf1umoG.js} +1 -1
- package/dist/assets/{VideoPreview-CD65fbRB.js → VideoPreview-DWVrf5x-.js} +1 -1
- package/dist/assets/{alert-BKtxgHd4.js → alert-BLnK0JlJ.js} +1 -1
- package/dist/assets/{ar-DekXB-MS.js → ar-Bw8k9YuL.js} +1 -1
- package/dist/assets/{avatar-DXNAAqKt.js → avatar-BorlhInS.js} +1 -1
- package/dist/assets/{basic-CVgmB_Ft.js → basic-CIkjGvLL.js} +1 -1
- package/dist/assets/{chat-DhhySuLR.js → chat-DyIVRTMU.js} +1 -1
- package/dist/assets/{codingBridge-DKNPnQPg.js → codingBridge-_Y15fb6Z.js} +1 -1
- package/dist/assets/{codingBridgeNotify-DP1OiOE_.js → codingBridgeNotify-CzKbSOXG.js} +2 -2
- package/dist/assets/{collapse-DccWfHEt.js → collapse-CwgPyFu-.js} +1 -1
- package/dist/assets/{constants-BX8aNNHM.js → constants-B_ksgMZ4.js} +1 -1
- package/dist/assets/{createTaskActions-D9A3z5dV.js → createTaskActions-Wqak_3Xb.js} +1 -1
- package/dist/assets/{date-picker-DtFbZyxJ.js → date-picker-BcJ2Wsoq.js} +1 -1
- package/dist/assets/{de-DRhBSAib.js → de-B7ElpqOd.js} +1 -1
- package/dist/assets/{digitalhuman-BeRLfov0.js → digitalhuman-BSQd4LBB.js} +1 -1
- package/dist/assets/{drawer-EvTtDXu1.js → drawer-Xsr_t0kg.js} +1 -1
- package/dist/assets/{dropdown-CLJceAVt.js → dropdown-B4uOapf_.js} +1 -1
- package/dist/assets/{dropdown-1c9o5gDF.js → dropdown-BPtM10ax.js} +1 -1
- package/dist/assets/{el-7dNC7M6G.js → el-CFaNrhu7.js} +1 -1
- package/dist/assets/{en-C_wY_PCq.js → en-CfE7LpWc.js} +1 -1
- package/dist/assets/{es-NfUM3r-U.js → es-DTykt3Qo.js} +1 -1
- package/dist/assets/{esm-DA23TB3J.js → esm-B9HmjRrT.js} +1 -1
- package/dist/assets/{esm-BnXXdgiM.js → esm-Bm2J7QDu.js} +1 -1
- package/dist/assets/{esm-D5VaRi73.js → esm-C2IxiBM0.js} +3 -3
- package/dist/assets/{esm-DSJ0YimI.js → esm-CJJN8MoL.js} +1 -1
- package/dist/assets/{esm-DQxRClxV.js → esm-DEr6cbK4.js} +2 -2
- package/dist/assets/esm-Dh0hS8oN.js +1 -0
- package/dist/assets/{esm-DjNvtQCb.js → esm-Q0ai2L5i.js} +2 -2
- package/dist/assets/{fi-pwcdTk67.js → fi-eD5aTtc1.js} +1 -1
- package/dist/assets/{fish-Bllu7fxh.js → fish-DMsMW119.js} +1 -1
- package/dist/assets/{flux-8d0gRL_k.js → flux-BsRxZztB.js} +1 -1
- package/dist/assets/{fr-bo1e2UuT.js → fr-Dv_mdYjN.js} +1 -1
- package/dist/assets/{grokvideo-CUblrZ9x.js → grokvideo-hlalGA5V.js} +1 -1
- package/dist/assets/{hailuo-DfsOT2YD.js → hailuo-DXLYpFdC.js} +1 -1
- package/dist/assets/{headshots-qMPMteuL.js → headshots-BJshbXpO.js} +1 -1
- package/dist/assets/{i18n-Btj5gKZ-.js → i18n-DIXqZj1s.js} +1 -1
- package/dist/assets/{image-CPrgMcYd.js → image-BEfHhCrE.js} +1 -1
- package/dist/assets/{index-uakaOzYD.js → index-BO8KoMTB.js} +11 -11
- package/dist/assets/{index.browser.esm-BXFDumWS.js → index.browser.esm-VExidluU.js} +1 -1
- package/dist/assets/{index.es-BJkAMcls.js → index.es-DWWSJOOT.js} +1 -1
- package/dist/assets/{input-number-3ArATLd5.js → input-number-DYu1xIU0.js} +1 -1
- package/dist/assets/{it-C0kCBmkH.js → it-OHBaRD2P.js} +1 -1
- package/dist/assets/{ja-DE7c0ePZ.js → ja-g5KofTAk.js} +1 -1
- package/dist/assets/{kling-CgZ6KcBU.js → kling-C-6uv2rj.js} +1 -1
- package/dist/assets/{ko-C2L0KP_G.js → ko-YTu33EaB.js} +1 -1
- package/dist/assets/{luma-D78UD1s8.js → luma-DQyeCwiO.js} +1 -1
- package/dist/assets/{maestro-DTGN5rk2.js → maestro-BRd-eAR8.js} +1 -1
- package/dist/assets/{maestro-BYo_Xb_U.js → maestro-CZbMr6vx.js} +1 -1
- package/dist/assets/{midjourney-BUq2eqDo.js → midjourney-BckN6lKV.js} +1 -1
- package/dist/assets/{mobileLocalExec-CUYD8apb.js → mobileLocalExec-Bc6W9egM.js} +2 -2
- package/dist/assets/{nanobanana-B-bpVIyb.js → nanobanana-7Q_1nPDY.js} +1 -1
- package/dist/assets/{openaiimage-DMvjKXHc.js → openaiimage-CZM9naAc.js} +1 -1
- package/dist/assets/{pagination-Dc6Cb7bJ.js → pagination-BWGjdsdd.js} +1 -1
- package/dist/assets/{pagination-DwmMdK1y.js → pagination-BspbxLLu.js} +1 -1
- package/dist/assets/{pika-kpJ6fj74.js → pika-DmKBSTM8.js} +1 -1
- package/dist/assets/{pixverse-CUV5NLwp.js → pixverse-De_v8k1e.js} +1 -1
- package/dist/assets/{pl-0qNsyhZP.js → pl-BZ8s7Bf2.js} +1 -1
- package/dist/assets/{popover-CTAxYlAz.js → popover-Dd9mgXhc.js} +1 -1
- package/dist/assets/{producer-C2WqSe_w.js → producer-CseeJvkr.js} +1 -1
- package/dist/assets/{pt-BgpRMJq3.js → pt-BHdBXUR6.js} +1 -1
- package/dist/assets/{qrart-BxmsSoIG.js → qrart-4tqi4BRk.js} +1 -1
- package/dist/assets/{realtime-I_loWEEV.js → realtime-C90OXoL9.js} +1 -1
- package/dist/assets/{row-Dfvy8Z58.js → row-H2IpqPLs.js} +1 -1
- package/dist/assets/{ru-PlLU5_Qo.js → ru-B2uFRW1k.js} +1 -1
- package/dist/assets/{seedance-CtOQrny2.js → seedance-BI2lD0tE.js} +1 -1
- package/dist/assets/{seedream-CDcF9Ym5.js → seedream-1Ug0u2kG.js} +1 -1
- package/dist/assets/{select-DsDoofB0.js → select-CBKmbQKx.js} +1 -1
- package/dist/assets/{serp-BSdg2oYK.js → serp-XefJ_M-0.js} +1 -1
- package/dist/assets/{slider-Bikt3SZy.js → slider-DHXwdpeA.js} +1 -1
- package/dist/assets/{solana-wallets-vUAgKkuU.js → solana-wallets-CZMpuJbF.js} +2 -2
- package/dist/assets/{solana-wallets-vue-Msi7Ec1-.js → solana-wallets-vue-o_Veogvf.js} +1 -1
- package/dist/assets/{sora-DfRSifP3.js → sora-BTdA6ZXs.js} +1 -1
- package/dist/assets/{sr-J2s-KcBb.js → sr-D74Uj4G1.js} +1 -1
- package/dist/assets/{suno-AYLMd7wv.js → suno-C-hpIwG-.js} +1 -1
- package/dist/assets/{sv-NF_PGwke.js → sv-Dy9Er0Vf.js} +1 -1
- package/dist/assets/{switch-C9nCxAuF.js → switch-CUBX5SGb.js} +1 -1
- package/dist/assets/{table-DnX0TaJt.js → table-BtJ_S4l0.js} +1 -1
- package/dist/assets/{tabs-CKv8u6ve.js → tabs-Bixsf1GB.js} +1 -1
- package/dist/assets/{time-picker-C01g_dCj.js → time-picker-BXmhts0Z.js} +1 -1
- package/dist/assets/{tooltip-bpsNk7vx.js → tooltip-BH-uqgsq.js} +1 -1
- package/dist/assets/{uk-DAugTrRZ.js → uk-Cbgef0tF.js} +1 -1
- package/dist/assets/{upload-YtZzPqur.js → upload-DlSWtKKf.js} +1 -1
- package/dist/assets/{veo-BFu3ebDe.js → veo-BiVdba6w.js} +1 -1
- package/dist/assets/{wan-C89WqF4e.js → wan-CRTEuLZO.js} +1 -1
- package/dist/assets/{web-DwEyGAgY.js → web-BDRpvDfc.js} +1 -1
- package/dist/assets/{web-BwafAuPC.js → web-Bx8bdCKc.js} +1 -1
- package/dist/assets/{web-BB9gpIgn.js → web-CZNP1Pd1.js} +1 -1
- package/dist/assets/{web-CM0CAoMz.js → web-DQCxqnrW.js} +1 -1
- package/dist/assets/{web-CjRjPoPO.js → web-FnJSIEaP.js} +1 -1
- package/dist/assets/{webextrator-BnSonie2.js → webextrator-CXolX4tp.js} +1 -1
- package/dist/assets/{zh-CN-CyKkMF0H.js → zh-CN-C4ZUzDMP.js} +1 -1
- package/dist/assets/{zh-TW-OFWOKPXD.js → zh-TW-6mr3sIiX.js} +1 -1
- package/dist/index.html +3 -3
- package/package.json +1 -1
- package/dist/assets/Navigator-pn77zeGd.css +0 -1
- package/dist/assets/esm-CjHF77VU.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime--c01j_DQ.js";import{A as e,C as t,I as n,Jt as r,L as i,M as a,N as o,T as s,at as c,ht as l,it as u,j as d,mt as f,ot as p,rt as m,tt as h,x as g,z as _}from"./vendor-chart-Dw-P17PN.js";import{B as v,I as y,X as b,Z as x,nt as S}from"./use-deprecated-B-uvyrTL.js";import{r as C,t as w}from"./select-DsDoofB0.js";import{n as T,t as E}from"./tabs-CKv8u6ve.js";import{t as D}from"./upload-YtZzPqur.js";import{t as O}from"./tooltip-bpsNk7vx.js";import{t as k}from"./image-CPrgMcYd.js";import{t as A}from"./avatar-CDRiCu03.js";import{n as j,r as M}from"./radio-Bj0tEwH8.js";import{n as N,t as P}from"./collapse-DccWfHEt.js";import{t as F}from"./drawer-EvTtDXu1.js";import{n as I,r as L,t as R}from"./dropdown-1c9o5gDF.js";import{t as z}from"./input-number-3ArATLd5.js";import{n as ee,t as te}from"./skeleton-CoheJz5x.js";import{t as ne}from"./slider-Bikt3SZy.js";import{t as re}from"./switch-C9nCxAuF.js";import{zn as ie}from"./constants-BX8aNNHM.js";import{G as B,Gi as V,Hn as H,Ii as U,Ti as W,Tr as G,di as K,hn as q,mi as J,nn as Y,on as ae,rn as oe,tn as se,yr as ce}from"./index-uakaOzYD.js";import{t as X}from"./index.es-BJkAMcls.js";import{n as le}from"./taskDrawerMixin-DyAUhFEq.js";import{t as ue}from"./Consumption-Dkf2iVZI.js";import{i as Z,n as de,r as fe,t as pe}from"./pagination-Dc6Cb7bJ.js";import{t as me}from"./NoTasks-aQlCIMQ-.js";import{t as he}from"./PromptTextarea-hv4s5RNk.js";import{n as ge,r as Q,t as _e}from"./Player-Bj93Yik6.js";var ve=_({name:`LayoutProducer`,components:{ElDrawer:F,ElButton:U,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(t,n,r,a,s,d){let p=c(`font-awesome-icon`),m=c(`el-button`),_=c(`el-drawer`);return h(),o(`div`,ye,[e(`div`,be,[u(t.$slots,`config`,{},void 0,!0)]),e(`div`,xe,[u(t.$slots,`result`,{},void 0,!0)]),e(`div`,Se,[u(t.$slots,`preview`,{},void 0,!0)]),l(i(m,{circle:``,class:`menu`,onClick:n[0]||=e=>t.drawer=!0},{default:f(()=>[i(p,{icon:`fa-solid fa-magic`})]),_:1},512),[[g,!t.tasksEmpty]]),i(_,{modelValue:t.drawer,"onUpdate:modelValue":n[1]||=e=>t.drawer=e,direction:`ltr`,"with-header":!1,size:`340px`,class:`drawer`},{default:f(()=>[u(t.$slots,`config`,{},void 0,!0)]),_:3},8,[`modelValue`])])}var we=B(ve,[[`render`,Ce],[`__scopeId`,`data-v-cc984c6f`]]),Te=_({name:`TypeSelector`,components:{ElSelect:C,ElOption:w,ElSwitch:re,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||=ie}}),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(t,n,l,u,p,g){let _=c(`el-option`),v=c(`el-select`),y=c(`info-icon`),b=c(`el-switch`);return h(),o(`div`,null,[e(`div`,Ee,[e(`div`,De,[e(`span`,Oe,r(t.$t(`producer.name.model`)),1)]),i(v,{modelValue:t.model,"onUpdate:modelValue":n[0]||=e=>t.model=e,class:`w-full model-select`,size:`default`,placeholder:t.$t(`producer.placeholder.select`)},{default:f(()=>[(h(!0),o(s,null,m(t.options,t=>(h(),d(_,{key:t.value,label:t.label,value:t.value},{default:f(()=>[e(`div`,ke,[e(`span`,Ae,r(t.label),1),e(`span`,je,r(t.desc),1)])]),_:2},1032,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])]),t.custom?(h(),o(`div`,Me,[e(`div`,Ne,[e(`span`,Pe,r(t.$t(`producer.name.instrumental`)),1),i(y,{content:t.$t(`producer.description.instrumental`)},null,8,[`content`])]),i(b,{modelValue:t.instrumental,"onUpdate:modelValue":n[1]||=e=>t.instrumental=e},null,8,[`modelValue`])])):a(``,!0)])}var Ie=B(Te,[[`render`,Fe],[`__scopeId`,`data-v-42496b9a`]]),Le=_({name:`UploadAudio`,components:{ElUpload:D,ElButton:U,ElRadioGroup:M,ElRadioButton:j,InfoIcon:Z,FontAwesomeIcon:X},mixins:[Y],emits:[`change`],data(){return{fileList:[],uploadUrl:J()+`/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(){W.warning(this.$t(`producer.message.uploadReferencesExceed`))},onError(){this.uploading=!1,W.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,W.info(this.$t(`producer.message.startingUploadAudio`));try{let e=(await H.upload(t,{token:n})).data?.data.audio_id;this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,audio_id:e,action:`upload_extend`}),W.success(this.$t(`producer.message.startUploadAudioSuccess`))}catch(e){W.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(t,s,l,u,d,p){let m=c(`info-icon`),g=c(`font-awesome-icon`),_=c(`el-button`),v=c(`el-upload`),y=c(`el-radio-button`),b=c(`el-radio-group`);return h(),o(`div`,Re,[e(`div`,ze,[e(`div`,Be,[e(`span`,Ve,r(t.$t(`producer.name.referenceAudios`)),1),i(m,{content:t.$t(`producer.description.uploadAudios`)},null,8,[`content`])]),i(v,{"file-list":t.fileList,"onUpdate:fileList":s[0]||=e=>t.fileList=e,name:`file`,limit:1,class:`upload-wrapper inline-upload`,action:t.uploadUrl,accept:`.mp3,.wav,.m4a,audio/*`,"show-file-list":!1,"on-exceed":t.onExceed,"on-error":t.onError,"on-success":t.onSuccess,headers:t.headers},{default:f(()=>[i(_,{round:``,type:`primary`,size:`small`,loading:t.uploading},{default:f(()=>[i(g,{icon:`fa-solid fa-upload`,class:`icon mr-1`}),n(` `+r(t.$t(`producer.button.uploadAudios`)),1)]),_:1},8,[`loading`])]),_:1},8,[`file-list`,`action`,`on-exceed`,`on-error`,`on-success`,`headers`])]),t.audioPreviewUrl?(h(),o(`div`,He,[e(`audio`,{src:t.audioPreviewUrl,controls:``,class:`w-full`},null,8,Ue)])):a(``,!0),t.hasUploadedAudio?(h(),o(`div`,We,[i(b,{modelValue:t.uploadAction,"onUpdate:modelValue":s[1]||=e=>t.uploadAction=e,size:`small`},{default:f(()=>[i(y,{value:`upload_extend`},{default:f(()=>[n(r(t.$t(`producer.button.extend`)),1)]),_:1}),i(y,{value:`upload_cover`},{default:f(()=>[n(r(t.$t(`producer.button.cover_music`)),1)]),_:1})]),_:1},8,[`modelValue`])])):a(``,!0)])}var Ke=B(Le,[[`render`,Ge],[`__scopeId`,`data-v-7fd0580a`]]),qe=_({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,a){let o=c(`prompt-textarea`);return h(),d(o,{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=B(qe,[[`render`,Je]]),Xe=_({name:`LyricInput`,components:{ElInput:V,ElButton:U,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,W.info(this.$t(`producer.message.generatingLyrics`));try{let n=(await H.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}),W.success(this.$t(`producer.message.generateLyricsSuccess`)))}catch{W.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(t,s,l,u,p,m){let g=c(`info-icon`),_=c(`font-awesome-icon`),v=c(`el-button`),y=c(`el-input`);return h(),o(`div`,Ze,[e(`div`,Qe,[e(`div`,$e,[e(`span`,et,r(t.$t(`producer.name.lyrics`)),1),i(g,{content:t.$t(`producer.description.lyrics`)},null,8,[`content`])]),t.config?.action===`extend`?a(``,!0):(h(),d(v,{key:0,size:`small`,loading:t.generatingLyrics,round:``,onClick:t.onGenerateLyrics},{default:f(()=>[t.generatingLyrics?a(``,!0):(h(),d(_,{key:0,icon:`fa-solid fa-wand-magic-sparkles`,class:`mr-1`})),n(` `+r(t.$t(`producer.button.generate_lyrics`)),1)]),_:1},8,[`loading`,`onClick`]))]),t.config?.action===`extend`?(h(),d(y,{key:1,modelValue:t.lyric,"onUpdate:modelValue":s[1]||=e=>t.lyric=e,rows:5,type:`textarea`,class:`lyrics`,placeholder:t.$t(`producer.placeholder.extend.lyrics`)},null,8,[`modelValue`,`placeholder`])):(h(),d(y,{key:0,modelValue:t.lyric,"onUpdate:modelValue":s[0]||=e=>t.lyric=e,rows:5,type:`textarea`,class:`lyrics`,placeholder:t.$t(`producer.placeholder.lyrics`)},null,8,[`modelValue`,`placeholder`]))])}var nt=B(Xe,[[`render`,tt],[`__scopeId`,`data-v-88c6da2b`]]),rt=_({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(t,n,a,s,l,u){let d=c(`info-icon`),f=c(`el-input`);return h(),o(`div`,it,[e(`div`,at,[e(`div`,ot,[e(`span`,st,r(t.$t(`producer.name.style`)),1),i(d,{content:t.$t(`producer.description.style`)},null,8,[`content`])])]),i(f,{modelValue:t.style,"onUpdate:modelValue":n[0]||=e=>t.style=e,rows:2,type:`textarea`,placeholder:t.$t(`producer.placeholder.style`)},null,8,[`modelValue`,`placeholder`])])}var lt=B(rt,[[`render`,ct]]),ut=_({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(t,n,a,s,l,u){let d=c(`info-icon`),f=c(`el-input`);return h(),o(`div`,dt,[e(`div`,ft,[e(`span`,pt,r(t.$t(`producer.name.title`)),1),i(d,{content:t.$t(`producer.description.title`)},null,8,[`content`])]),i(f,{modelValue:t.title,"onUpdate:modelValue":n[0]||=e=>t.title=e,placeholder:t.$t(`producer.placeholder.title`)},null,8,[`modelValue`,`placeholder`])])}var ht=B(ut,[[`render`,mt]]),gt=_({name:`ExtendFromInput`,components:{ElImage:k,ElIcon:S,ElInputNumber:z,VideoPlay:x,VideoPause:b},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(t,n,s,u,d,m){let g=c(`el-input-number`),_=c(`el-image`),v=c(`video-pause`),y=c(`el-icon`),b=c(`video-play`),x=p(`loading`);return h(),o(`div`,_t,[e(`div`,vt,[e(`h2`,yt,r(t.$t(`producer.name.extend`)),1),e(`div`,bt,[i(g,{modelValue:t.value,"onUpdate:modelValue":n[0]||=e=>t.value=e,class:`value`,min:0,max:t.audio?.duration,controls:!1,placeholder:t.$t(`producer.placeholder.extend.continue_at`),onChange:t.handleChange},null,8,[`modelValue`,`max`,`placeholder`,`onChange`])])]),e(`div`,xt,[t.audio?(h(),o(`div`,{key:0,class:`audio`,onClick:n[3]||=e=>t.onClick(t.audio)},[l((h(),o(`div`,St,[i(_,{src:t.audio?.image_url,class:`cover`,fit:`cover`},null,8,[`src`]),t.audio?.audio_url&&t.$store.state?.producer?.audio?.id===t.audio.id&&t.$store.state?.producer?.audio?.state===`playing`?(h(),o(`div`,{key:0,class:`overlay`,onClick:n[1]||=e=>t.onPause(t.audio)},[i(y,null,{default:f(()=>[i(v)]),_:1})])):a(``,!0),t.audio?.audio_url&&(t.$store.state?.producer?.audio?.id!==t.audio.id||t.$store.state?.producer?.audio?.id===t.audio.id&&t.$store.state?.producer?.audio?.state===`paused`)?(h(),o(`div`,{key:1,class:`overlay`,onClick:n[2]||=e=>t.onPlay(t.audio)},[i(y,null,{default:f(()=>[i(b)]),_:1})])):a(``,!0),t.audio?.duration?(h(),o(`div`,Ct,r(t.useFormatDuring(t.audio?.duration)),1)):a(``,!0)])),[[x,!t.audio?.audio_url]]),e(`div`,wt,[e(`h2`,Tt,r(t.audio?.title),1),e(`p`,Et,r(t.audio?.style),1)])])):a(``,!0)])])}var Ot=B(gt,[[`render`,Dt],[`__scopeId`,`data-v-26d43480`]]),kt=_({name:`CoverFromInput`,components:{ElImage:k,ElIcon:S,VideoPlay:x,VideoPause:b},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(t,n,s,u,d,m){let g=c(`el-image`),_=c(`video-pause`),v=c(`el-icon`),y=c(`video-play`),b=p(`loading`);return h(),o(`div`,At,[e(`div`,jt,[e(`h2`,Mt,r(t.$t(`producer.name.cover`)),1)]),e(`div`,Nt,[t.audio?(h(),o(`div`,{key:0,class:`audio`,onClick:n[2]||=e=>t.onClick(t.audio)},[l((h(),o(`div`,Pt,[i(g,{src:t.audio?.image_url,class:`cover`,fit:`cover`},null,8,[`src`]),t.audio?.audio_url&&t.$store.state?.producer?.audio?.id===t.audio.id&&t.$store.state?.producer?.audio?.state===`playing`?(h(),o(`div`,{key:0,class:`overlay`,onClick:n[0]||=e=>t.onPause(t.audio)},[i(v,null,{default:f(()=>[i(_)]),_:1})])):a(``,!0),t.audio?.audio_url&&(t.$store.state?.producer?.audio?.id!==t.audio.id||t.$store.state?.producer?.audio?.id===t.audio.id&&t.$store.state?.producer?.audio?.state===`paused`)?(h(),o(`div`,{key:1,class:`overlay`,onClick:n[1]||=e=>t.onPlay(t.audio)},[i(v,null,{default:f(()=>[i(y)]),_:1})])):a(``,!0),t.audio?.duration?(h(),o(`div`,Ft,r(t.useFormatDuring(t.audio?.duration)),1)):a(``,!0)])),[[b,!t.audio?.audio_url]]),e(`div`,It,[e(`h2`,Lt,r(t.audio?.title),1),e(`p`,Rt,r(t.audio?.style),1)])])):a(``,!0)])])}var Bt=B(kt,[[`render`,zt],[`__scopeId`,`data-v-d8a8e583`]]),Vt=_({name:`VocalGenderSelector`,components:{ElRadioGroup:M,ElRadioButton:j,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(t,a,s,l,u,d){let p=c(`info-icon`),m=c(`el-radio-button`),g=c(`el-radio-group`);return h(),o(`div`,Ht,[e(`div`,Ut,[e(`span`,Wt,r(t.$t(`producer.name.vocalGender`)),1),i(p,{content:t.$t(`producer.description.vocalGender`)},null,8,[`content`])]),i(g,{modelValue:t.vocalGender,"onUpdate:modelValue":a[0]||=e=>t.vocalGender=e},{default:f(()=>[i(m,{value:``},{default:f(()=>[n(r(t.$t(`producer.gender.auto`)),1)]),_:1}),i(m,{value:`f`},{default:f(()=>[n(r(t.$t(`producer.gender.female`)),1)]),_:1}),i(m,{value:`m`},{default:f(()=>[n(r(t.$t(`producer.gender.male`)),1)]),_:1})]),_:1},8,[`modelValue`])])}var Kt=B(Vt,[[`render`,Gt]]),qt=_({name:`AdvancedParams`,components:{ElCollapse:P,ElCollapseItem:N,ElInput:V,ElSlider:ne,ElInputNumber:z,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(t,n,s,l,u,p){let m=c(`info-icon`),g=c(`el-input`),_=c(`el-slider`),v=c(`el-input-number`),y=c(`el-collapse-item`),b=c(`el-collapse`);return h(),d(b,{modelValue:t.activeNames,"onUpdate:modelValue":n[6]||=e=>t.activeNames=e,class:`advanced-collapse`},{default:f(()=>[i(y,{title:t.$t(`producer.name.advancedParams`),name:`advanced`},{default:f(()=>[t.config?.custom?(h(),o(`div`,Jt,[e(`div`,Yt,[e(`span`,Xt,r(t.$t(`producer.name.styleNegative`)),1),i(m,{content:t.$t(`producer.description.styleNegative`)},null,8,[`content`])]),i(g,{modelValue:t.styleNegative,"onUpdate:modelValue":n[0]||=e=>t.styleNegative=e,size:`small`,placeholder:t.$t(`producer.placeholder.styleNegative`)},null,8,[`modelValue`,`placeholder`])])):a(``,!0),t.config?.custom&&!t.config?.instrumental?(h(),o(`div`,Zt,[e(`div`,Qt,[e(`span`,$t,r(t.$t(`producer.name.lyricPrompt`)),1),i(m,{content:t.$t(`producer.description.lyricPrompt`)},null,8,[`content`])]),i(g,{modelValue:t.lyricPrompt,"onUpdate:modelValue":n[1]||=e=>t.lyricPrompt=e,size:`small`,placeholder:t.$t(`producer.placeholder.lyricPrompt`)},null,8,[`modelValue`,`placeholder`])])):a(``,!0),e(`div`,en,[e(`div`,tn,[e(`div`,nn,[e(`span`,rn,r(t.$t(`producer.name.weirdness`)),1),i(m,{content:t.$t(`producer.description.weirdness`)},null,8,[`content`])]),e(`span`,an,r(t.weirdness??.5),1)]),i(_,{modelValue:t.weirdness,"onUpdate:modelValue":n[2]||=e=>t.weirdness=e,min:0,max:1,step:.01},null,8,[`modelValue`])]),e(`div`,on,[e(`div`,sn,[e(`div`,cn,[e(`span`,ln,r(t.$t(`producer.name.soundStrength`)),1),i(m,{content:t.$t(`producer.description.soundStrength`)},null,8,[`content`])]),e(`span`,un,r(t.soundStrength??.7),1)]),i(_,{modelValue:t.soundStrength,"onUpdate:modelValue":n[3]||=e=>t.soundStrength=e,min:.2,max:1,step:.01},null,8,[`modelValue`])]),t.config?.custom&&!t.config?.instrumental?(h(),o(`div`,dn,[e(`div`,fn,[e(`div`,pn,[e(`span`,mn,r(t.$t(`producer.name.lyricsStrength`)),1),i(m,{content:t.$t(`producer.description.lyricsStrength`)},null,8,[`content`])]),e(`span`,hn,r(t.lyricsStrength??.7),1)]),i(_,{modelValue:t.lyricsStrength,"onUpdate:modelValue":n[4]||=e=>t.lyricsStrength=e,min:0,max:1,step:.01},null,8,[`modelValue`])])):a(``,!0),e(`div`,gn,[e(`div`,_n,[e(`span`,vn,r(t.$t(`producer.name.seed`)),1),i(m,{content:t.$t(`producer.description.seed`)},null,8,[`content`])]),i(v,{modelValue:t.seed,"onUpdate:modelValue":n[5]||=e=>t.seed=e,min:0,controls:!1,size:`small`,placeholder:t.$t(`producer.placeholder.seed`),class:`w-full`},null,8,[`modelValue`,`placeholder`])])]),_:1},8,[`title`])]),_:1},8,[`modelValue`])}var bn=B(qt,[[`render`,yn],[`__scopeId`,`data-v-f9296888`]]),xn=_({name:`ReplaceSectionInput`,components:{ElInputNumber:z,ElImage:k,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(t,n,s,u,d,f){let m=c(`info-icon`),g=c(`el-image`),_=c(`el-input-number`),v=p(`loading`);return h(),o(`div`,Sn,[e(`div`,Cn,[e(`h2`,wn,r(t.$t(`producer.name.replaceSection`)),1),i(m,{content:t.$t(`producer.description.replaceSection`)},null,8,[`content`])]),t.audio?(h(),o(`div`,Tn,[e(`div`,{class:`audio flex items-center`,onClick:n[0]||=e=>t.onClick(t.audio)},[l((h(),o(`div`,En,[i(g,{src:t.audio?.image_url,class:`w-full h-full rounded`,fit:`cover`},null,8,[`src`])])),[[v,!t.audio?.audio_url]]),e(`div`,Dn,[e(`h2`,On,r(t.audio?.title),1),e(`p`,kn,r(t.audio?.style),1)])])])):a(``,!0),e(`div`,An,[i(_,{modelValue:t.replaceSectionStart,"onUpdate:modelValue":n[1]||=e=>t.replaceSectionStart=e,class:`flex-1`,min:0,max:t.audio?.duration,controls:!1,placeholder:t.$t(`producer.placeholder.replaceSectionStart`)},null,8,[`modelValue`,`max`,`placeholder`]),i(_,{modelValue:t.replaceSectionEnd,"onUpdate:modelValue":n[2]||=e=>t.replaceSectionEnd=e,class:`flex-1`,min:t.replaceSectionStart||0,max:t.audio?.duration,controls:!1,placeholder:t.$t(`producer.placeholder.replaceSectionEnd`)},null,8,[`modelValue`,`min`,`max`,`placeholder`])])])}var Mn=_({name:`PresetPanel`,components:{TypeSelector:Ie,PromptInput:Ye,LyricInput:nt,StyleInput:lt,TitleInput:ht,ExtendFromInput:Ot,CoverFromInput:Bt,UploadAudio:Ke,VocalGenderSelector:Kt,AdvancedParams:bn,ReplaceSectionInput:B(xn,[[`render`,jn]]),FontAwesomeIcon:X,ElButton:U,ElTabs:T,ElTabPane:E,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 ae(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(t,s,l,u,p,m){let g=c(`type-selector`),_=c(`upload-audio`),v=c(`prompt-input`),y=c(`extend-from-input`),b=c(`cover-from-input`),x=c(`replace-section-input`),S=c(`advanced-params`),C=c(`el-tab-pane`),w=c(`lyric-input`),T=c(`style-input`),E=c(`title-input`),D=c(`vocal-gender-selector`),O=c(`el-tabs`),k=c(`consumption`),A=c(`font-awesome-icon`),j=c(`el-button`);return h(),o(`div`,Nn,[e(`div`,Pn,[i(O,{modelValue:t.mode,"onUpdate:modelValue":s[0]||=e=>t.mode=e,class:`producer-mode-tabs`,stretch:``},{default:f(()=>[i(C,{label:t.$t(`producer.mode.simple`),name:`simple`},{default:f(()=>[e(`div`,Fn,[i(g,{class:`mb-4`}),i(_,{class:`mb-4`}),i(v,{class:`mb-4`}),t.config?.action===`extend`?(h(),d(y,{key:0,class:`mb-4`})):a(``,!0),t.config?.action===`cover`?(h(),d(b,{key:1,class:`mb-4`})):a(``,!0),t.config?.action===`replace_section`?(h(),d(x,{key:2,class:`mb-4`})):a(``,!0),i(S,{class:`mb-4`})])]),_:1},8,[`label`]),i(C,{label:t.$t(`producer.mode.custom`),name:`custom`},{default:f(()=>[e(`div`,In,[i(g,{class:`mb-4`}),i(_,{class:`mb-4`}),t.config?.instrumental?a(``,!0):(h(),d(w,{key:0,class:`mb-4`})),i(T,{class:`mb-4`}),i(E,{class:`mb-4`}),t.config?.instrumental?a(``,!0):(h(),d(D,{key:1,class:`mb-4`})),t.config?.action===`extend`?(h(),d(y,{key:2,class:`mb-4`})):a(``,!0),t.config?.action===`cover`?(h(),d(b,{key:3,class:`mb-4`})):a(``,!0),t.config?.action===`replace_section`?(h(),d(x,{key:4,class:`mb-4`})):a(``,!0),i(S,{class:`mb-4`})])]),_:1},8,[`label`])]),_:1},8,[`modelValue`])]),e(`div`,Ln,[i(k,{value:t.consumption,service:t.service},null,8,[`value`,`service`]),e(`div`,Rn,[i(j,{class:`flex-1`,onClick:t.onClearAll},{default:f(()=>[i(A,{icon:`fa-solid fa-broom`,class:`mr-1`}),n(` `+r(t.$t(`producer.button.clear_all`)),1)]),_:1},8,[`onClick`]),i(j,{type:`primary`,class:`flex-1`,round:``,onClick:t.onGenerate},{default:f(()=>[i(A,{icon:`fa-solid fa-magic`,class:`mr-2`}),n(` `+r(t.generateButtonText),1)]),_:1},8,[`onClick`])])])])}var Bn=B(Mn,[[`render`,zn],[`__scopeId`,`data-v-4a4b209e`]]),Vn=ge(),Hn=_({name:`TaskPreview`,components:{ElImage:k,ElIcon:S,ElTooltip:O,FontAwesomeIcon:X,VideoPlay:x,VideoPause:b,ElDropdown:R,ElDropdownMenu:L,ElDropdownItem:I,Loading:y,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===K.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),W.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}H.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,W.info(this.$t(`producer.message.fetchingWav`));let n=(await H.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):W.error(this.$t(`producer.message.fetchWavFailed`))}catch{W.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}W.info(this.$t(`producer.message.startingTask`)),H.audio(n,{token:r}).then(()=>{W.success(this.$t(`producer.message.startTaskSuccess`))}).catch(e=>{W.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(u,g,_,v,y,b){let x=c(`el-image`),S=c(`video-pause`),C=c(`el-icon`),w=c(`video-play`),T=c(`font-awesome-icon`),E=c(`el-tooltip`),D=c(`Loading`),O=c(`el-dropdown-item`),k=c(`el-dropdown-menu`),A=c(`el-dropdown`),j=c(`api-code-dialog`),M=p(`loading`);return h(),o(`div`,Un,[(h(!0),o(s,null,m(u.audios,s=>(h(),o(`div`,{key:s.id,class:`audio`,onClick:t(e=>u.onClick(s),[`stop`])},[l((h(),o(`div`,Gn,[i(x,{src:s?.image_url,class:`cover`,fit:`cover`,lazy:``},null,8,[`src`]),s?.audio_url&&u.$store.state?.producer?.audio?.id===s.id&&u.$store.state?.producer?.audio?.state===`playing`?(h(),o(`div`,{key:0,class:`overlay`,onClick:t(e=>u.onPause(s),[`stop`])},[i(C,null,{default:f(()=>[i(S)]),_:1})],8,Kn)):a(``,!0),s?.audio_url&&(u.$store.state?.producer?.audio?.id!==s.id||u.$store.state?.producer?.audio?.id===s.id&&u.$store.state?.producer?.audio?.state===`paused`)?(h(),o(`div`,{key:1,class:`overlay`,onClick:t(e=>u.onPlay(s),[`stop`])},[i(C,null,{default:f(()=>[i(w)]),_:1})],8,qn)):a(``,!0),s?.duration?(h(),o(`div`,Jn,r(u.useFormatDuring(s?.duration)),1)):a(``,!0)])),[[M,!s?.audio_url]]),e(`div`,Yn,[e(`h2`,Xn,r(s?.title),1),e(`p`,Zn,r(s?.style),1)]),e(`div`,Qn,[i(A,null,{dropdown:f(()=>[i(k,null,{default:f(()=>[i(O,{disabled:u.isFetchingVideoUrl,onClick:e=>u.handleVideoDownload(s)},{default:f(()=>[e(`div`,er,[u.isFetchingVideoUrl?(h(),d(C,{key:0,class:`is-loading mr-2`},{default:f(()=>[i(D)]),_:1})):a(``,!0),e(`span`,null,r(u.$t(`producer.button.download_video`)),1)])]),_:1},8,[`disabled`,`onClick`]),s?.audio_url?(h(),d(O,{key:0,onClick:t(e=>u.onDownload(e,s?.audio_url),[`stop`])},{default:f(()=>[n(r(u.$t(`producer.button.download_audio`)),1)]),_:1},8,[`onClick`])):a(``,!0),i(O,{disabled:u.isFetchingWav,onClick:e=>u.handleWavDownload(s)},{default:f(()=>[e(`div`,tr,[u.isFetchingWav?(h(),d(C,{key:0,class:`is-loading mr-2`},{default:f(()=>[i(D)]),_:1})):a(``,!0),e(`span`,null,r(u.$t(`producer.button.download_wav`)),1)])]),_:1},8,[`disabled`,`onClick`])]),_:2},1024)]),default:f(()=>[e(`span`,$n,[i(E,{effect:`dark`,content:u.$t(`producer.button.download`),placement:`top`},{default:f(()=>[s?.audio_url||s?.video_url?(h(),d(T,{key:0,icon:`fa-solid fa-download`,class:`icon icon-download`})):a(``,!0)]),_:2},1032,[`content`])])]),_:2},1024),i(A,null,{dropdown:f(()=>[i(k,null,{default:f(()=>[s?.audio_url?(h(),d(O,{key:0,onClick:t(e=>u.onExtend(e,s),[`stop`])},{default:f(()=>[n(r(u.$t(`producer.button.extend`)),1)]),_:1},8,[`onClick`])):a(``,!0),s.id?(h(),d(O,{key:1,onClick:t(e=>u.onGetStems(s.id),[`stop`])},{default:f(()=>[n(r(u.$t(`producer.button.get_stems`)),1)]),_:1},8,[`onClick`])):a(``,!0),s.id?(h(),d(O,{key:2,onClick:t(e=>u.onGetAllStems(s.id),[`stop`])},{default:f(()=>[n(r(u.$t(`producer.button.all_stems`)),1)]),_:1},8,[`onClick`])):a(``,!0),i(O,{onClick:t(e=>u.onCover(s),[`stop`])},{default:f(()=>[n(r(u.$t(`producer.button.cover_music`)),1)]),_:1},8,[`onClick`]),s?.id?(h(),d(O,{key:3,onClick:t(e=>u.onVariation(s),[`stop`])},{default:f(()=>[n(r(u.$t(`producer.button.variation`)),1)]),_:1},8,[`onClick`])):a(``,!0),s?.id?(h(),d(O,{key:4,onClick:t(e=>u.onSwapVocals(s.id),[`stop`])},{default:f(()=>[n(r(u.$t(`producer.button.swap_vocals`)),1)]),_:1},8,[`onClick`])):a(``,!0),s?.id?(h(),d(O,{key:5,onClick:t(e=>u.onSwapInstrumentals(s.id),[`stop`])},{default:f(()=>[n(r(u.$t(`producer.button.swap_instrumentals`)),1)]),_:1},8,[`onClick`])):a(``,!0),s?.id?(h(),d(O,{key:6,onClick:t(e=>u.onReplaceSection(s),[`stop`])},{default:f(()=>[n(r(u.$t(`producer.button.replace_section`)),1)]),_:1},8,[`onClick`])):a(``,!0),i(O,{onClick:t(u.onViewCode,[`stop`])},{default:f(()=>[i(T,{icon:`fa-solid fa-code`,class:`mr-1`}),n(` `+r(u.$t(`common.button.viewCode`)),1)]),_:1},8,[`onClick`])]),_:2},1024)]),default:f(()=>[e(`span`,nr,[i(E,{effect:`dark`,content:u.$t(`producer.button.more`),placement:`top`},{default:f(()=>[s?.audio_url||s?.video_url?(h(),d(T,{key:0,icon:`fa-solid fa-ellipsis`,class:`icon icon-ellipsis`})):a(``,!0)]),_:2},1032,[`content`])])]),_:2},1024)])],8,Wn))),128)),i(j,{visible:u.apiCodeVisible,"onUpdate:visible":g[0]||=e=>u.apiCodeVisible=e,method:`POST`,path:u.apiCodePath,body:u.apiCodeBody,token:u.$store.state.producer?.credential?.token||``},null,8,[`visible`,`path`,`body`,`token`])])}var ir=_({name:`RecentPanel`,components:{ElSkeletonItem:ee,ElSkeleton:te,TaskPreview:B(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(t,n,r,u,p,_){let v=c(`el-skeleton-item`),y=c(`el-skeleton`),b=c(`task-preview`),x=c(`scroll-list`),S=c(`no-tasks`),C=c(`player`);return h(),o(s,null,[t.tasks?.items===void 0?(h(),o(`div`,ar,[(h(),o(s,null,m(3,t=>e(`div`,{key:t,class:`flex`},[e(`div`,or,[i(y,{animated:``},{template:f(()=>[i(v,{variant:`image`,class:`avatar w-[50px] h-[50px]`})]),_:1})]),e(`div`,sr,[i(y,{animated:``},{template:f(()=>[i(v,{variant:`p`,class:`w-[200px] h-[15px] mb-[5px] mt-[10px]`}),i(v,{variant:`text`})]),_:1})])])),64))])):t.tasks?.items?.length&&t.tasks?.items?.length>0?(h(),d(x,{key:1,ref:`scrollList`,class:`flex-1 w-full overflow-y-auto tasks p-2`,loading:t.loading,onReachTop:n[0]||=e=>t.$emit(`reach-top`)},{default:f(()=>[(h(!0),o(s,null,m(t.tasks?.items,(e,t)=>(h(),d(b,{key:t,"model-value":e,class:`preview`},null,8,[`model-value`]))),128))]),_:1},8,[`loading`])):a(``,!0),t.tasks?.items?.length===0?(h(),o(`div`,$,[i(S)])):a(``,!0),l(e(`div`,cr,[i(C,{namespace:`producer`})],512),[[g,!!t.$store?.state?.producer?.audio?.object]])],64)}var ur=B(ir,[[`render`,lr]]),dr=_({name:`TaskPreview`,components:{IconPicture:v,ElImage:k,ElAvatar:A,ElIcon:S},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(t,n,a,s,l,u){let d=c(`icon-picture`),p=c(`el-icon`),m=c(`el-image`),g=c(`el-avatar`);return t.audio?.object?(h(),o(`div`,fr,[e(`div`,pr,[i(m,{src:t.audio.image_url,fit:`cover`,class:`size-full`},{error:f(()=>[e(`div`,mr,[i(p,{class:`text-3xl`},{default:f(()=>[i(d)]),_:1})])]),_:1},8,[`src`]),e(`h2`,hr,r(t.audio?.title),1)]),e(`div`,gr,[e(`div`,_r,[i(g,{size:30,src:t.audio?.image_url,class:`mr-2`},null,8,[`src`]),e(`span`,null,r(t.audio?.title),1)]),e(`p`,vr,r(t.audio?.style),1),e(`p`,yr,r(t.$dayjs.format(t.audio?.created_at)),1),e(`div`,br,[e(`p`,null,r(t.audio?.lyric),1)])])])):(h(),o(`div`,xr))}var Cr=_({name:`ProducerIndex`,components:{Layout:we,ConfigPanel:Bn,RecentPanel:ur,PreviewPanel:B(dr,[[`render`,Sr]])},mixins:[oe],inject:[`initialized`],data(){return{task:void 0,job:0,loadingMore:!1,fetchingTasks:!1}},computed:{applicationsLoading(){return this.$store.state.producer?.status?.getApplications===K.Request},tasksLoading(){return this.$store.state.producer?.status?.getTasks===K.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===K.Request},needApply(){return this.$store.state.producer.status.getApplications===K.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(){ce.create({application:this.application}).then(({data:e})=>{this.application=e,W.success(this.$t(`application.message.applySuccessfully`))}).catch(e=>{e?.response?.data?.code===`duplication`&&W.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(!se(this.uploadTracker,e=>this.$t(e),e=>W.warning(e)))return;let e={...this.config,async:!0};if(!q())return;let t=this.credential?.token;if(!t){console.error(`no token specified`);return}W.info(this.$t(`producer.message.startingTask`)),G(`producer`,H.audio(e,{token:t})).then(()=>{W.success(this.$t(`producer.message.startTaskSuccess`))}).catch(e=>{W.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,a,o){let s=c(`config-panel`),l=c(`recent-panel`),u=c(`preview-panel`),p=c(`layout`);return h(),d(p,null,{config:f(()=>[i(s,{onGenerate:e.onGenerateAudio},null,8,[`onGenerate`])]),result:f(()=>[i(l,{ref:`recentPanel`,class:`panel recent`,loading:e.loadingMore,onReachTop:e.onReachTop},null,8,[`loading`,`onReachTop`])]),preview:f(()=>[i(u)]),_:1})}var Tr=B(Cr,[[`render`,wr],[`__scopeId`,`data-v-23eb99dc`]]);export{Tr as default};
|
|
1
|
+
import"./rolldown-runtime--c01j_DQ.js";import{A as e,C as t,I as n,Jt as r,L as i,M as a,N as o,T as s,at as c,ht as l,it as u,j as d,mt as f,ot as p,rt as m,tt as h,x as g,z as _}from"./vendor-chart-Dw-P17PN.js";import{B as v,I as y,X as b,Z as x,nt as S}from"./use-deprecated-B-uvyrTL.js";import{r as C,t as w}from"./select-CBKmbQKx.js";import{n as T,t as E}from"./tabs-Bixsf1GB.js";import{t as D}from"./upload-DlSWtKKf.js";import{t as O}from"./tooltip-BH-uqgsq.js";import{t as k}from"./image-BEfHhCrE.js";import{t as A}from"./avatar-CDRiCu03.js";import{n as j,r as M}from"./radio-Bj0tEwH8.js";import{n as N,t as P}from"./collapse-CwgPyFu-.js";import{t as F}from"./drawer-Xsr_t0kg.js";import{n as I,r as L,t as R}from"./dropdown-BPtM10ax.js";import{t as z}from"./input-number-DYu1xIU0.js";import{n as ee,t as te}from"./skeleton-CoheJz5x.js";import{t as ne}from"./slider-DHXwdpeA.js";import{t as re}from"./switch-CUBX5SGb.js";import{zn as ie}from"./constants-B_ksgMZ4.js";import{G as B,Gi as V,Hn as H,Ii as U,Ti as W,Tr as G,di as K,hn as q,mi as J,nn as Y,on as ae,rn as oe,tn as se,yr as ce}from"./index-BO8KoMTB.js";import{t as X}from"./index.es-DWWSJOOT.js";import{n as le}from"./taskDrawerMixin-DyAUhFEq.js";import{t as ue}from"./Consumption-BZfcI4CV.js";import{i as Z,n as de,r as fe,t as pe}from"./pagination-BWGjdsdd.js";import{t as me}from"./NoTasks-EnkPu5PA.js";import{t as he}from"./PromptTextarea-D4708v1G.js";import{n as ge,r as Q,t as _e}from"./Player-DfKucsKu.js";var ve=_({name:`LayoutProducer`,components:{ElDrawer:F,ElButton:U,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(t,n,r,a,s,d){let p=c(`font-awesome-icon`),m=c(`el-button`),_=c(`el-drawer`);return h(),o(`div`,ye,[e(`div`,be,[u(t.$slots,`config`,{},void 0,!0)]),e(`div`,xe,[u(t.$slots,`result`,{},void 0,!0)]),e(`div`,Se,[u(t.$slots,`preview`,{},void 0,!0)]),l(i(m,{circle:``,class:`menu`,onClick:n[0]||=e=>t.drawer=!0},{default:f(()=>[i(p,{icon:`fa-solid fa-magic`})]),_:1},512),[[g,!t.tasksEmpty]]),i(_,{modelValue:t.drawer,"onUpdate:modelValue":n[1]||=e=>t.drawer=e,direction:`ltr`,"with-header":!1,size:`340px`,class:`drawer`},{default:f(()=>[u(t.$slots,`config`,{},void 0,!0)]),_:3},8,[`modelValue`])])}var we=B(ve,[[`render`,Ce],[`__scopeId`,`data-v-cc984c6f`]]),Te=_({name:`TypeSelector`,components:{ElSelect:C,ElOption:w,ElSwitch:re,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||=ie}}),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(t,n,l,u,p,g){let _=c(`el-option`),v=c(`el-select`),y=c(`info-icon`),b=c(`el-switch`);return h(),o(`div`,null,[e(`div`,Ee,[e(`div`,De,[e(`span`,Oe,r(t.$t(`producer.name.model`)),1)]),i(v,{modelValue:t.model,"onUpdate:modelValue":n[0]||=e=>t.model=e,class:`w-full model-select`,size:`default`,placeholder:t.$t(`producer.placeholder.select`)},{default:f(()=>[(h(!0),o(s,null,m(t.options,t=>(h(),d(_,{key:t.value,label:t.label,value:t.value},{default:f(()=>[e(`div`,ke,[e(`span`,Ae,r(t.label),1),e(`span`,je,r(t.desc),1)])]),_:2},1032,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])]),t.custom?(h(),o(`div`,Me,[e(`div`,Ne,[e(`span`,Pe,r(t.$t(`producer.name.instrumental`)),1),i(y,{content:t.$t(`producer.description.instrumental`)},null,8,[`content`])]),i(b,{modelValue:t.instrumental,"onUpdate:modelValue":n[1]||=e=>t.instrumental=e},null,8,[`modelValue`])])):a(``,!0)])}var Ie=B(Te,[[`render`,Fe],[`__scopeId`,`data-v-42496b9a`]]),Le=_({name:`UploadAudio`,components:{ElUpload:D,ElButton:U,ElRadioGroup:M,ElRadioButton:j,InfoIcon:Z,FontAwesomeIcon:X},mixins:[Y],emits:[`change`],data(){return{fileList:[],uploadUrl:J()+`/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(){W.warning(this.$t(`producer.message.uploadReferencesExceed`))},onError(){this.uploading=!1,W.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,W.info(this.$t(`producer.message.startingUploadAudio`));try{let e=(await H.upload(t,{token:n})).data?.data.audio_id;this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,audio_id:e,action:`upload_extend`}),W.success(this.$t(`producer.message.startUploadAudioSuccess`))}catch(e){W.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(t,s,l,u,d,p){let m=c(`info-icon`),g=c(`font-awesome-icon`),_=c(`el-button`),v=c(`el-upload`),y=c(`el-radio-button`),b=c(`el-radio-group`);return h(),o(`div`,Re,[e(`div`,ze,[e(`div`,Be,[e(`span`,Ve,r(t.$t(`producer.name.referenceAudios`)),1),i(m,{content:t.$t(`producer.description.uploadAudios`)},null,8,[`content`])]),i(v,{"file-list":t.fileList,"onUpdate:fileList":s[0]||=e=>t.fileList=e,name:`file`,limit:1,class:`upload-wrapper inline-upload`,action:t.uploadUrl,accept:`.mp3,.wav,.m4a,audio/*`,"show-file-list":!1,"on-exceed":t.onExceed,"on-error":t.onError,"on-success":t.onSuccess,headers:t.headers},{default:f(()=>[i(_,{round:``,type:`primary`,size:`small`,loading:t.uploading},{default:f(()=>[i(g,{icon:`fa-solid fa-upload`,class:`icon mr-1`}),n(` `+r(t.$t(`producer.button.uploadAudios`)),1)]),_:1},8,[`loading`])]),_:1},8,[`file-list`,`action`,`on-exceed`,`on-error`,`on-success`,`headers`])]),t.audioPreviewUrl?(h(),o(`div`,He,[e(`audio`,{src:t.audioPreviewUrl,controls:``,class:`w-full`},null,8,Ue)])):a(``,!0),t.hasUploadedAudio?(h(),o(`div`,We,[i(b,{modelValue:t.uploadAction,"onUpdate:modelValue":s[1]||=e=>t.uploadAction=e,size:`small`},{default:f(()=>[i(y,{value:`upload_extend`},{default:f(()=>[n(r(t.$t(`producer.button.extend`)),1)]),_:1}),i(y,{value:`upload_cover`},{default:f(()=>[n(r(t.$t(`producer.button.cover_music`)),1)]),_:1})]),_:1},8,[`modelValue`])])):a(``,!0)])}var Ke=B(Le,[[`render`,Ge],[`__scopeId`,`data-v-7fd0580a`]]),qe=_({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,a){let o=c(`prompt-textarea`);return h(),d(o,{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=B(qe,[[`render`,Je]]),Xe=_({name:`LyricInput`,components:{ElInput:V,ElButton:U,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,W.info(this.$t(`producer.message.generatingLyrics`));try{let n=(await H.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}),W.success(this.$t(`producer.message.generateLyricsSuccess`)))}catch{W.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(t,s,l,u,p,m){let g=c(`info-icon`),_=c(`font-awesome-icon`),v=c(`el-button`),y=c(`el-input`);return h(),o(`div`,Ze,[e(`div`,Qe,[e(`div`,$e,[e(`span`,et,r(t.$t(`producer.name.lyrics`)),1),i(g,{content:t.$t(`producer.description.lyrics`)},null,8,[`content`])]),t.config?.action===`extend`?a(``,!0):(h(),d(v,{key:0,size:`small`,loading:t.generatingLyrics,round:``,onClick:t.onGenerateLyrics},{default:f(()=>[t.generatingLyrics?a(``,!0):(h(),d(_,{key:0,icon:`fa-solid fa-wand-magic-sparkles`,class:`mr-1`})),n(` `+r(t.$t(`producer.button.generate_lyrics`)),1)]),_:1},8,[`loading`,`onClick`]))]),t.config?.action===`extend`?(h(),d(y,{key:1,modelValue:t.lyric,"onUpdate:modelValue":s[1]||=e=>t.lyric=e,rows:5,type:`textarea`,class:`lyrics`,placeholder:t.$t(`producer.placeholder.extend.lyrics`)},null,8,[`modelValue`,`placeholder`])):(h(),d(y,{key:0,modelValue:t.lyric,"onUpdate:modelValue":s[0]||=e=>t.lyric=e,rows:5,type:`textarea`,class:`lyrics`,placeholder:t.$t(`producer.placeholder.lyrics`)},null,8,[`modelValue`,`placeholder`]))])}var nt=B(Xe,[[`render`,tt],[`__scopeId`,`data-v-88c6da2b`]]),rt=_({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(t,n,a,s,l,u){let d=c(`info-icon`),f=c(`el-input`);return h(),o(`div`,it,[e(`div`,at,[e(`div`,ot,[e(`span`,st,r(t.$t(`producer.name.style`)),1),i(d,{content:t.$t(`producer.description.style`)},null,8,[`content`])])]),i(f,{modelValue:t.style,"onUpdate:modelValue":n[0]||=e=>t.style=e,rows:2,type:`textarea`,placeholder:t.$t(`producer.placeholder.style`)},null,8,[`modelValue`,`placeholder`])])}var lt=B(rt,[[`render`,ct]]),ut=_({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(t,n,a,s,l,u){let d=c(`info-icon`),f=c(`el-input`);return h(),o(`div`,dt,[e(`div`,ft,[e(`span`,pt,r(t.$t(`producer.name.title`)),1),i(d,{content:t.$t(`producer.description.title`)},null,8,[`content`])]),i(f,{modelValue:t.title,"onUpdate:modelValue":n[0]||=e=>t.title=e,placeholder:t.$t(`producer.placeholder.title`)},null,8,[`modelValue`,`placeholder`])])}var ht=B(ut,[[`render`,mt]]),gt=_({name:`ExtendFromInput`,components:{ElImage:k,ElIcon:S,ElInputNumber:z,VideoPlay:x,VideoPause:b},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(t,n,s,u,d,m){let g=c(`el-input-number`),_=c(`el-image`),v=c(`video-pause`),y=c(`el-icon`),b=c(`video-play`),x=p(`loading`);return h(),o(`div`,_t,[e(`div`,vt,[e(`h2`,yt,r(t.$t(`producer.name.extend`)),1),e(`div`,bt,[i(g,{modelValue:t.value,"onUpdate:modelValue":n[0]||=e=>t.value=e,class:`value`,min:0,max:t.audio?.duration,controls:!1,placeholder:t.$t(`producer.placeholder.extend.continue_at`),onChange:t.handleChange},null,8,[`modelValue`,`max`,`placeholder`,`onChange`])])]),e(`div`,xt,[t.audio?(h(),o(`div`,{key:0,class:`audio`,onClick:n[3]||=e=>t.onClick(t.audio)},[l((h(),o(`div`,St,[i(_,{src:t.audio?.image_url,class:`cover`,fit:`cover`},null,8,[`src`]),t.audio?.audio_url&&t.$store.state?.producer?.audio?.id===t.audio.id&&t.$store.state?.producer?.audio?.state===`playing`?(h(),o(`div`,{key:0,class:`overlay`,onClick:n[1]||=e=>t.onPause(t.audio)},[i(y,null,{default:f(()=>[i(v)]),_:1})])):a(``,!0),t.audio?.audio_url&&(t.$store.state?.producer?.audio?.id!==t.audio.id||t.$store.state?.producer?.audio?.id===t.audio.id&&t.$store.state?.producer?.audio?.state===`paused`)?(h(),o(`div`,{key:1,class:`overlay`,onClick:n[2]||=e=>t.onPlay(t.audio)},[i(y,null,{default:f(()=>[i(b)]),_:1})])):a(``,!0),t.audio?.duration?(h(),o(`div`,Ct,r(t.useFormatDuring(t.audio?.duration)),1)):a(``,!0)])),[[x,!t.audio?.audio_url]]),e(`div`,wt,[e(`h2`,Tt,r(t.audio?.title),1),e(`p`,Et,r(t.audio?.style),1)])])):a(``,!0)])])}var Ot=B(gt,[[`render`,Dt],[`__scopeId`,`data-v-26d43480`]]),kt=_({name:`CoverFromInput`,components:{ElImage:k,ElIcon:S,VideoPlay:x,VideoPause:b},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(t,n,s,u,d,m){let g=c(`el-image`),_=c(`video-pause`),v=c(`el-icon`),y=c(`video-play`),b=p(`loading`);return h(),o(`div`,At,[e(`div`,jt,[e(`h2`,Mt,r(t.$t(`producer.name.cover`)),1)]),e(`div`,Nt,[t.audio?(h(),o(`div`,{key:0,class:`audio`,onClick:n[2]||=e=>t.onClick(t.audio)},[l((h(),o(`div`,Pt,[i(g,{src:t.audio?.image_url,class:`cover`,fit:`cover`},null,8,[`src`]),t.audio?.audio_url&&t.$store.state?.producer?.audio?.id===t.audio.id&&t.$store.state?.producer?.audio?.state===`playing`?(h(),o(`div`,{key:0,class:`overlay`,onClick:n[0]||=e=>t.onPause(t.audio)},[i(v,null,{default:f(()=>[i(_)]),_:1})])):a(``,!0),t.audio?.audio_url&&(t.$store.state?.producer?.audio?.id!==t.audio.id||t.$store.state?.producer?.audio?.id===t.audio.id&&t.$store.state?.producer?.audio?.state===`paused`)?(h(),o(`div`,{key:1,class:`overlay`,onClick:n[1]||=e=>t.onPlay(t.audio)},[i(v,null,{default:f(()=>[i(y)]),_:1})])):a(``,!0),t.audio?.duration?(h(),o(`div`,Ft,r(t.useFormatDuring(t.audio?.duration)),1)):a(``,!0)])),[[b,!t.audio?.audio_url]]),e(`div`,It,[e(`h2`,Lt,r(t.audio?.title),1),e(`p`,Rt,r(t.audio?.style),1)])])):a(``,!0)])])}var Bt=B(kt,[[`render`,zt],[`__scopeId`,`data-v-d8a8e583`]]),Vt=_({name:`VocalGenderSelector`,components:{ElRadioGroup:M,ElRadioButton:j,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(t,a,s,l,u,d){let p=c(`info-icon`),m=c(`el-radio-button`),g=c(`el-radio-group`);return h(),o(`div`,Ht,[e(`div`,Ut,[e(`span`,Wt,r(t.$t(`producer.name.vocalGender`)),1),i(p,{content:t.$t(`producer.description.vocalGender`)},null,8,[`content`])]),i(g,{modelValue:t.vocalGender,"onUpdate:modelValue":a[0]||=e=>t.vocalGender=e},{default:f(()=>[i(m,{value:``},{default:f(()=>[n(r(t.$t(`producer.gender.auto`)),1)]),_:1}),i(m,{value:`f`},{default:f(()=>[n(r(t.$t(`producer.gender.female`)),1)]),_:1}),i(m,{value:`m`},{default:f(()=>[n(r(t.$t(`producer.gender.male`)),1)]),_:1})]),_:1},8,[`modelValue`])])}var Kt=B(Vt,[[`render`,Gt]]),qt=_({name:`AdvancedParams`,components:{ElCollapse:P,ElCollapseItem:N,ElInput:V,ElSlider:ne,ElInputNumber:z,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(t,n,s,l,u,p){let m=c(`info-icon`),g=c(`el-input`),_=c(`el-slider`),v=c(`el-input-number`),y=c(`el-collapse-item`),b=c(`el-collapse`);return h(),d(b,{modelValue:t.activeNames,"onUpdate:modelValue":n[6]||=e=>t.activeNames=e,class:`advanced-collapse`},{default:f(()=>[i(y,{title:t.$t(`producer.name.advancedParams`),name:`advanced`},{default:f(()=>[t.config?.custom?(h(),o(`div`,Jt,[e(`div`,Yt,[e(`span`,Xt,r(t.$t(`producer.name.styleNegative`)),1),i(m,{content:t.$t(`producer.description.styleNegative`)},null,8,[`content`])]),i(g,{modelValue:t.styleNegative,"onUpdate:modelValue":n[0]||=e=>t.styleNegative=e,size:`small`,placeholder:t.$t(`producer.placeholder.styleNegative`)},null,8,[`modelValue`,`placeholder`])])):a(``,!0),t.config?.custom&&!t.config?.instrumental?(h(),o(`div`,Zt,[e(`div`,Qt,[e(`span`,$t,r(t.$t(`producer.name.lyricPrompt`)),1),i(m,{content:t.$t(`producer.description.lyricPrompt`)},null,8,[`content`])]),i(g,{modelValue:t.lyricPrompt,"onUpdate:modelValue":n[1]||=e=>t.lyricPrompt=e,size:`small`,placeholder:t.$t(`producer.placeholder.lyricPrompt`)},null,8,[`modelValue`,`placeholder`])])):a(``,!0),e(`div`,en,[e(`div`,tn,[e(`div`,nn,[e(`span`,rn,r(t.$t(`producer.name.weirdness`)),1),i(m,{content:t.$t(`producer.description.weirdness`)},null,8,[`content`])]),e(`span`,an,r(t.weirdness??.5),1)]),i(_,{modelValue:t.weirdness,"onUpdate:modelValue":n[2]||=e=>t.weirdness=e,min:0,max:1,step:.01},null,8,[`modelValue`])]),e(`div`,on,[e(`div`,sn,[e(`div`,cn,[e(`span`,ln,r(t.$t(`producer.name.soundStrength`)),1),i(m,{content:t.$t(`producer.description.soundStrength`)},null,8,[`content`])]),e(`span`,un,r(t.soundStrength??.7),1)]),i(_,{modelValue:t.soundStrength,"onUpdate:modelValue":n[3]||=e=>t.soundStrength=e,min:.2,max:1,step:.01},null,8,[`modelValue`])]),t.config?.custom&&!t.config?.instrumental?(h(),o(`div`,dn,[e(`div`,fn,[e(`div`,pn,[e(`span`,mn,r(t.$t(`producer.name.lyricsStrength`)),1),i(m,{content:t.$t(`producer.description.lyricsStrength`)},null,8,[`content`])]),e(`span`,hn,r(t.lyricsStrength??.7),1)]),i(_,{modelValue:t.lyricsStrength,"onUpdate:modelValue":n[4]||=e=>t.lyricsStrength=e,min:0,max:1,step:.01},null,8,[`modelValue`])])):a(``,!0),e(`div`,gn,[e(`div`,_n,[e(`span`,vn,r(t.$t(`producer.name.seed`)),1),i(m,{content:t.$t(`producer.description.seed`)},null,8,[`content`])]),i(v,{modelValue:t.seed,"onUpdate:modelValue":n[5]||=e=>t.seed=e,min:0,controls:!1,size:`small`,placeholder:t.$t(`producer.placeholder.seed`),class:`w-full`},null,8,[`modelValue`,`placeholder`])])]),_:1},8,[`title`])]),_:1},8,[`modelValue`])}var bn=B(qt,[[`render`,yn],[`__scopeId`,`data-v-f9296888`]]),xn=_({name:`ReplaceSectionInput`,components:{ElInputNumber:z,ElImage:k,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(t,n,s,u,d,f){let m=c(`info-icon`),g=c(`el-image`),_=c(`el-input-number`),v=p(`loading`);return h(),o(`div`,Sn,[e(`div`,Cn,[e(`h2`,wn,r(t.$t(`producer.name.replaceSection`)),1),i(m,{content:t.$t(`producer.description.replaceSection`)},null,8,[`content`])]),t.audio?(h(),o(`div`,Tn,[e(`div`,{class:`audio flex items-center`,onClick:n[0]||=e=>t.onClick(t.audio)},[l((h(),o(`div`,En,[i(g,{src:t.audio?.image_url,class:`w-full h-full rounded`,fit:`cover`},null,8,[`src`])])),[[v,!t.audio?.audio_url]]),e(`div`,Dn,[e(`h2`,On,r(t.audio?.title),1),e(`p`,kn,r(t.audio?.style),1)])])])):a(``,!0),e(`div`,An,[i(_,{modelValue:t.replaceSectionStart,"onUpdate:modelValue":n[1]||=e=>t.replaceSectionStart=e,class:`flex-1`,min:0,max:t.audio?.duration,controls:!1,placeholder:t.$t(`producer.placeholder.replaceSectionStart`)},null,8,[`modelValue`,`max`,`placeholder`]),i(_,{modelValue:t.replaceSectionEnd,"onUpdate:modelValue":n[2]||=e=>t.replaceSectionEnd=e,class:`flex-1`,min:t.replaceSectionStart||0,max:t.audio?.duration,controls:!1,placeholder:t.$t(`producer.placeholder.replaceSectionEnd`)},null,8,[`modelValue`,`min`,`max`,`placeholder`])])])}var Mn=_({name:`PresetPanel`,components:{TypeSelector:Ie,PromptInput:Ye,LyricInput:nt,StyleInput:lt,TitleInput:ht,ExtendFromInput:Ot,CoverFromInput:Bt,UploadAudio:Ke,VocalGenderSelector:Kt,AdvancedParams:bn,ReplaceSectionInput:B(xn,[[`render`,jn]]),FontAwesomeIcon:X,ElButton:U,ElTabs:T,ElTabPane:E,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 ae(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(t,s,l,u,p,m){let g=c(`type-selector`),_=c(`upload-audio`),v=c(`prompt-input`),y=c(`extend-from-input`),b=c(`cover-from-input`),x=c(`replace-section-input`),S=c(`advanced-params`),C=c(`el-tab-pane`),w=c(`lyric-input`),T=c(`style-input`),E=c(`title-input`),D=c(`vocal-gender-selector`),O=c(`el-tabs`),k=c(`consumption`),A=c(`font-awesome-icon`),j=c(`el-button`);return h(),o(`div`,Nn,[e(`div`,Pn,[i(O,{modelValue:t.mode,"onUpdate:modelValue":s[0]||=e=>t.mode=e,class:`producer-mode-tabs`,stretch:``},{default:f(()=>[i(C,{label:t.$t(`producer.mode.simple`),name:`simple`},{default:f(()=>[e(`div`,Fn,[i(g,{class:`mb-4`}),i(_,{class:`mb-4`}),i(v,{class:`mb-4`}),t.config?.action===`extend`?(h(),d(y,{key:0,class:`mb-4`})):a(``,!0),t.config?.action===`cover`?(h(),d(b,{key:1,class:`mb-4`})):a(``,!0),t.config?.action===`replace_section`?(h(),d(x,{key:2,class:`mb-4`})):a(``,!0),i(S,{class:`mb-4`})])]),_:1},8,[`label`]),i(C,{label:t.$t(`producer.mode.custom`),name:`custom`},{default:f(()=>[e(`div`,In,[i(g,{class:`mb-4`}),i(_,{class:`mb-4`}),t.config?.instrumental?a(``,!0):(h(),d(w,{key:0,class:`mb-4`})),i(T,{class:`mb-4`}),i(E,{class:`mb-4`}),t.config?.instrumental?a(``,!0):(h(),d(D,{key:1,class:`mb-4`})),t.config?.action===`extend`?(h(),d(y,{key:2,class:`mb-4`})):a(``,!0),t.config?.action===`cover`?(h(),d(b,{key:3,class:`mb-4`})):a(``,!0),t.config?.action===`replace_section`?(h(),d(x,{key:4,class:`mb-4`})):a(``,!0),i(S,{class:`mb-4`})])]),_:1},8,[`label`])]),_:1},8,[`modelValue`])]),e(`div`,Ln,[i(k,{value:t.consumption,service:t.service},null,8,[`value`,`service`]),e(`div`,Rn,[i(j,{class:`flex-1`,onClick:t.onClearAll},{default:f(()=>[i(A,{icon:`fa-solid fa-broom`,class:`mr-1`}),n(` `+r(t.$t(`producer.button.clear_all`)),1)]),_:1},8,[`onClick`]),i(j,{type:`primary`,class:`flex-1`,round:``,onClick:t.onGenerate},{default:f(()=>[i(A,{icon:`fa-solid fa-magic`,class:`mr-2`}),n(` `+r(t.generateButtonText),1)]),_:1},8,[`onClick`])])])])}var Bn=B(Mn,[[`render`,zn],[`__scopeId`,`data-v-4a4b209e`]]),Vn=ge(),Hn=_({name:`TaskPreview`,components:{ElImage:k,ElIcon:S,ElTooltip:O,FontAwesomeIcon:X,VideoPlay:x,VideoPause:b,ElDropdown:R,ElDropdownMenu:L,ElDropdownItem:I,Loading:y,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===K.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),W.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}H.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,W.info(this.$t(`producer.message.fetchingWav`));let n=(await H.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):W.error(this.$t(`producer.message.fetchWavFailed`))}catch{W.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}W.info(this.$t(`producer.message.startingTask`)),H.audio(n,{token:r}).then(()=>{W.success(this.$t(`producer.message.startTaskSuccess`))}).catch(e=>{W.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(u,g,_,v,y,b){let x=c(`el-image`),S=c(`video-pause`),C=c(`el-icon`),w=c(`video-play`),T=c(`font-awesome-icon`),E=c(`el-tooltip`),D=c(`Loading`),O=c(`el-dropdown-item`),k=c(`el-dropdown-menu`),A=c(`el-dropdown`),j=c(`api-code-dialog`),M=p(`loading`);return h(),o(`div`,Un,[(h(!0),o(s,null,m(u.audios,s=>(h(),o(`div`,{key:s.id,class:`audio`,onClick:t(e=>u.onClick(s),[`stop`])},[l((h(),o(`div`,Gn,[i(x,{src:s?.image_url,class:`cover`,fit:`cover`,lazy:``},null,8,[`src`]),s?.audio_url&&u.$store.state?.producer?.audio?.id===s.id&&u.$store.state?.producer?.audio?.state===`playing`?(h(),o(`div`,{key:0,class:`overlay`,onClick:t(e=>u.onPause(s),[`stop`])},[i(C,null,{default:f(()=>[i(S)]),_:1})],8,Kn)):a(``,!0),s?.audio_url&&(u.$store.state?.producer?.audio?.id!==s.id||u.$store.state?.producer?.audio?.id===s.id&&u.$store.state?.producer?.audio?.state===`paused`)?(h(),o(`div`,{key:1,class:`overlay`,onClick:t(e=>u.onPlay(s),[`stop`])},[i(C,null,{default:f(()=>[i(w)]),_:1})],8,qn)):a(``,!0),s?.duration?(h(),o(`div`,Jn,r(u.useFormatDuring(s?.duration)),1)):a(``,!0)])),[[M,!s?.audio_url]]),e(`div`,Yn,[e(`h2`,Xn,r(s?.title),1),e(`p`,Zn,r(s?.style),1)]),e(`div`,Qn,[i(A,null,{dropdown:f(()=>[i(k,null,{default:f(()=>[i(O,{disabled:u.isFetchingVideoUrl,onClick:e=>u.handleVideoDownload(s)},{default:f(()=>[e(`div`,er,[u.isFetchingVideoUrl?(h(),d(C,{key:0,class:`is-loading mr-2`},{default:f(()=>[i(D)]),_:1})):a(``,!0),e(`span`,null,r(u.$t(`producer.button.download_video`)),1)])]),_:1},8,[`disabled`,`onClick`]),s?.audio_url?(h(),d(O,{key:0,onClick:t(e=>u.onDownload(e,s?.audio_url),[`stop`])},{default:f(()=>[n(r(u.$t(`producer.button.download_audio`)),1)]),_:1},8,[`onClick`])):a(``,!0),i(O,{disabled:u.isFetchingWav,onClick:e=>u.handleWavDownload(s)},{default:f(()=>[e(`div`,tr,[u.isFetchingWav?(h(),d(C,{key:0,class:`is-loading mr-2`},{default:f(()=>[i(D)]),_:1})):a(``,!0),e(`span`,null,r(u.$t(`producer.button.download_wav`)),1)])]),_:1},8,[`disabled`,`onClick`])]),_:2},1024)]),default:f(()=>[e(`span`,$n,[i(E,{effect:`dark`,content:u.$t(`producer.button.download`),placement:`top`},{default:f(()=>[s?.audio_url||s?.video_url?(h(),d(T,{key:0,icon:`fa-solid fa-download`,class:`icon icon-download`})):a(``,!0)]),_:2},1032,[`content`])])]),_:2},1024),i(A,null,{dropdown:f(()=>[i(k,null,{default:f(()=>[s?.audio_url?(h(),d(O,{key:0,onClick:t(e=>u.onExtend(e,s),[`stop`])},{default:f(()=>[n(r(u.$t(`producer.button.extend`)),1)]),_:1},8,[`onClick`])):a(``,!0),s.id?(h(),d(O,{key:1,onClick:t(e=>u.onGetStems(s.id),[`stop`])},{default:f(()=>[n(r(u.$t(`producer.button.get_stems`)),1)]),_:1},8,[`onClick`])):a(``,!0),s.id?(h(),d(O,{key:2,onClick:t(e=>u.onGetAllStems(s.id),[`stop`])},{default:f(()=>[n(r(u.$t(`producer.button.all_stems`)),1)]),_:1},8,[`onClick`])):a(``,!0),i(O,{onClick:t(e=>u.onCover(s),[`stop`])},{default:f(()=>[n(r(u.$t(`producer.button.cover_music`)),1)]),_:1},8,[`onClick`]),s?.id?(h(),d(O,{key:3,onClick:t(e=>u.onVariation(s),[`stop`])},{default:f(()=>[n(r(u.$t(`producer.button.variation`)),1)]),_:1},8,[`onClick`])):a(``,!0),s?.id?(h(),d(O,{key:4,onClick:t(e=>u.onSwapVocals(s.id),[`stop`])},{default:f(()=>[n(r(u.$t(`producer.button.swap_vocals`)),1)]),_:1},8,[`onClick`])):a(``,!0),s?.id?(h(),d(O,{key:5,onClick:t(e=>u.onSwapInstrumentals(s.id),[`stop`])},{default:f(()=>[n(r(u.$t(`producer.button.swap_instrumentals`)),1)]),_:1},8,[`onClick`])):a(``,!0),s?.id?(h(),d(O,{key:6,onClick:t(e=>u.onReplaceSection(s),[`stop`])},{default:f(()=>[n(r(u.$t(`producer.button.replace_section`)),1)]),_:1},8,[`onClick`])):a(``,!0),i(O,{onClick:t(u.onViewCode,[`stop`])},{default:f(()=>[i(T,{icon:`fa-solid fa-code`,class:`mr-1`}),n(` `+r(u.$t(`common.button.viewCode`)),1)]),_:1},8,[`onClick`])]),_:2},1024)]),default:f(()=>[e(`span`,nr,[i(E,{effect:`dark`,content:u.$t(`producer.button.more`),placement:`top`},{default:f(()=>[s?.audio_url||s?.video_url?(h(),d(T,{key:0,icon:`fa-solid fa-ellipsis`,class:`icon icon-ellipsis`})):a(``,!0)]),_:2},1032,[`content`])])]),_:2},1024)])],8,Wn))),128)),i(j,{visible:u.apiCodeVisible,"onUpdate:visible":g[0]||=e=>u.apiCodeVisible=e,method:`POST`,path:u.apiCodePath,body:u.apiCodeBody,token:u.$store.state.producer?.credential?.token||``},null,8,[`visible`,`path`,`body`,`token`])])}var ir=_({name:`RecentPanel`,components:{ElSkeletonItem:ee,ElSkeleton:te,TaskPreview:B(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(t,n,r,u,p,_){let v=c(`el-skeleton-item`),y=c(`el-skeleton`),b=c(`task-preview`),x=c(`scroll-list`),S=c(`no-tasks`),C=c(`player`);return h(),o(s,null,[t.tasks?.items===void 0?(h(),o(`div`,ar,[(h(),o(s,null,m(3,t=>e(`div`,{key:t,class:`flex`},[e(`div`,or,[i(y,{animated:``},{template:f(()=>[i(v,{variant:`image`,class:`avatar w-[50px] h-[50px]`})]),_:1})]),e(`div`,sr,[i(y,{animated:``},{template:f(()=>[i(v,{variant:`p`,class:`w-[200px] h-[15px] mb-[5px] mt-[10px]`}),i(v,{variant:`text`})]),_:1})])])),64))])):t.tasks?.items?.length&&t.tasks?.items?.length>0?(h(),d(x,{key:1,ref:`scrollList`,class:`flex-1 w-full overflow-y-auto tasks p-2`,loading:t.loading,onReachTop:n[0]||=e=>t.$emit(`reach-top`)},{default:f(()=>[(h(!0),o(s,null,m(t.tasks?.items,(e,t)=>(h(),d(b,{key:t,"model-value":e,class:`preview`},null,8,[`model-value`]))),128))]),_:1},8,[`loading`])):a(``,!0),t.tasks?.items?.length===0?(h(),o(`div`,$,[i(S)])):a(``,!0),l(e(`div`,cr,[i(C,{namespace:`producer`})],512),[[g,!!t.$store?.state?.producer?.audio?.object]])],64)}var ur=B(ir,[[`render`,lr]]),dr=_({name:`TaskPreview`,components:{IconPicture:v,ElImage:k,ElAvatar:A,ElIcon:S},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(t,n,a,s,l,u){let d=c(`icon-picture`),p=c(`el-icon`),m=c(`el-image`),g=c(`el-avatar`);return t.audio?.object?(h(),o(`div`,fr,[e(`div`,pr,[i(m,{src:t.audio.image_url,fit:`cover`,class:`size-full`},{error:f(()=>[e(`div`,mr,[i(p,{class:`text-3xl`},{default:f(()=>[i(d)]),_:1})])]),_:1},8,[`src`]),e(`h2`,hr,r(t.audio?.title),1)]),e(`div`,gr,[e(`div`,_r,[i(g,{size:30,src:t.audio?.image_url,class:`mr-2`},null,8,[`src`]),e(`span`,null,r(t.audio?.title),1)]),e(`p`,vr,r(t.audio?.style),1),e(`p`,yr,r(t.$dayjs.format(t.audio?.created_at)),1),e(`div`,br,[e(`p`,null,r(t.audio?.lyric),1)])])])):(h(),o(`div`,xr))}var Cr=_({name:`ProducerIndex`,components:{Layout:we,ConfigPanel:Bn,RecentPanel:ur,PreviewPanel:B(dr,[[`render`,Sr]])},mixins:[oe],inject:[`initialized`],data(){return{task:void 0,job:0,loadingMore:!1,fetchingTasks:!1}},computed:{applicationsLoading(){return this.$store.state.producer?.status?.getApplications===K.Request},tasksLoading(){return this.$store.state.producer?.status?.getTasks===K.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===K.Request},needApply(){return this.$store.state.producer.status.getApplications===K.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(){ce.create({application:this.application}).then(({data:e})=>{this.application=e,W.success(this.$t(`application.message.applySuccessfully`))}).catch(e=>{e?.response?.data?.code===`duplication`&&W.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(!se(this.uploadTracker,e=>this.$t(e),e=>W.warning(e)))return;let e={...this.config,async:!0};if(!q())return;let t=this.credential?.token;if(!t){console.error(`no token specified`);return}W.info(this.$t(`producer.message.startingTask`)),G(`producer`,H.audio(e,{token:t})).then(()=>{W.success(this.$t(`producer.message.startTaskSuccess`))}).catch(e=>{W.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,a,o){let s=c(`config-panel`),l=c(`recent-panel`),u=c(`preview-panel`),p=c(`layout`);return h(),d(p,null,{config:f(()=>[i(s,{onGenerate:e.onGenerateAudio},null,8,[`onGenerate`])]),result:f(()=>[i(l,{ref:`recentPanel`,class:`panel recent`,loading:e.loadingMore,onReachTop:e.onReachTop},null,8,[`loading`,`onReachTop`])]),preview:f(()=>[i(u)]),_:1})}var Tr=B(Cr,[[`render`,wr],[`__scopeId`,`data-v-23eb99dc`]]);export{Tr as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime--c01j_DQ.js";import{A as e,Jt as t,L as n,at as r,ht as i,j as a,mt as o,ot as s,tt as c,z as l}from"./vendor-chart-Dw-P17PN.js";import{n as u,t as d}from"./table-
|
|
1
|
+
import"./rolldown-runtime--c01j_DQ.js";import{A as e,Jt as t,L as n,at as r,ht as i,j as a,mt as o,ot as s,tt as c,z as l}from"./vendor-chart-Dw-P17PN.js";import{n as u,t as d}from"./table-BtJ_S4l0.js";import{t as f}from"./card-D-4S-l7a.js";import{n as p,t as m}from"./row-H2IpqPLs.js";import{t as h}from"./pagination-BspbxLLu.js";import{G as g,vr as _}from"./index-BO8KoMTB.js";import{t as v}from"./CopyToClipboard-B1VphMUw.js";var y=l({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(l,u,d,f,p,m){let h=r(`el-col`),g=r(`el-row`),_=r(`copy-to-clipboard`),v=r(`el-table-column`),y=r(`el-table`),O=r(`el-card`),k=r(`pagination`),A=s(`loading`);return c(),a(g,{class:`panel`},{default:o(()=>[n(h,{span:24},{default:o(()=>[n(g,null,{default:o(()=>[n(h,{span:24},{default:o(()=>[e(`h2`,b,t(l.$t(`common.title.invitee`)),1)]),_:1})]),_:1}),n(g,null,{default:o(()=>[n(h,{span:24},{default:o(()=>[n(O,{shadow:`hover`},{default:o(()=>[i((c(),a(y,{data:l.invitees,stripe:``},{default:o(()=>[n(v,{prop:`id`,label:l.$t(`user.field.id`),"class-name":`text-center`,width:`350px`},{default:o(r=>[e(`span`,x,t(r.row.id),1),e(`span`,S,[n(_,{content:r.row.id},null,8,[`content`])])]),_:1},8,[`label`]),n(v,{label:l.$t(`user.field.username`),width:`300px`},{default:o(n=>[e(`span`,C,t(n.row?.username),1)]),_:1},8,[`label`]),n(v,{label:l.$t(`user.field.email`),width:`300px`},{default:o(n=>[e(`span`,w,t(n.row?.email),1)]),_:1},8,[`label`]),n(v,{label:l.$t(`user.field.nickname`),width:`200px`},{default:o(n=>[e(`span`,T,t(n.row.nickname),1)]),_:1},8,[`label`]),n(v,{label:l.$t(`user.field.dateJoined`)},{default:o(n=>[e(`span`,E,t(l.$dayjs.format(n.row.date_joined)),1)]),_:1},8,[`label`])]),_:1},8,[`data`])),[[A,l.loading]])]),_:1})]),_:1})]),_:1}),n(g,null,{default:o(()=>[n(h,{span:10,offset:14},{default:o(()=>[e(`div`,D,[n(k,{"current-page":l.page,"page-size":l.limit,total:l.total,onChange:l.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var k=g(y,[[`render`,O],[`__scopeId`,`data-v-b2200c49`]]);export{k as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime--c01j_DQ.js";import{A as e,I as t,Jt as n,L as r,N as i,T as a,at as o,ht as s,j as c,mt as l,ot as u,rt as d,tt as f,z as p}from"./vendor-chart-Dw-P17PN.js";import{r as m,t as h}from"./select-DsDoofB0.js";import{n as g,t as _}from"./table-DnX0TaJt.js";import{t as v}from"./card-D-4S-l7a.js";import{t as y}from"./date-picker-DtFbZyxJ.js";import{n as b,t as x}from"./row-Dfvy8Z58.js";import{t as S}from"./pagination-DwmMdK1y.js";import{t as C}from"./skeleton-CoheJz5x.js";import{G as w,Ii as T,Pi as E,fr as D,ri as O,sn as k}from"./index-uakaOzYD.js";import{t as A}from"./index.es-BJkAMcls.js";import{t as j}from"./CopyToClipboard-D9EquLu_.js";var M={total_count:0,total_spent:0,state_counts:{}},N=p({name:`ConsoleOrderList`,components:{Pagination:S,CopyToClipboard:j,ElRow:x,ElCol:b,ElTable:_,ElTableColumn:g,ElButton:T,ElTag:E,ElCard:v,ElSelect:m,ElOption:h,ElDatePicker:y,ElSkeleton:C,FontAwesomeIcon:A},data(){return{OrderState:O,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:O.PENDING,label:this.$t(`order.state.pending`)},{value:O.FINISHED,label:this.$t(`order.state.finished`)},{value:O.PAID,label:this.$t(`order.state.paid`)},{value:O.EXPIRED,label:this.$t(`order.state.expired`)},{value:O.FAILED,label:this.$t(`order.state.failed`)},{value:O.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===O.FINISHED||e===O.PAID?`success`:e===O.EXPIRED||e===O.FAILED?`danger`:e===O.REFUNDED?`warning`:`info`},stateLabel(e){return{[O.PENDING]:this.$t(`order.state.pending`),[O.PAID]:this.$t(`order.state.paid`),[O.FINISHED]:this.$t(`order.state.finished`),[O.EXPIRED]:this.$t(`order.state.expired`),[O.FAILED]:this.$t(`order.state.failed`),[O.REFUNDED]:this.$t(`order.state.refunded`)}[e]||e},isPendingAction(e){return e!==O.PAID&&e!==O.FINISHED&&e!==O.EXPIRED&&e!==O.FAILED&&e!==O.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,D.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,D.getSummary(this.filterQuery).then(({data:e})=>{this.summary=e}).catch(()=>{this.summary={...M}}).finally(()=>{this.summaryLoading=!1})},onExport(){this.exporting=!0,D.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(p,m,h,g,_,v){let y=o(`el-col`),b=o(`el-row`),x=o(`el-skeleton`),S=o(`font-awesome-icon`),C=o(`el-card`),w=o(`el-option`),T=o(`el-select`),E=o(`el-date-picker`),D=o(`el-button`),O=o(`copy-to-clipboard`),k=o(`el-table-column`),A=o(`el-tag`),j=o(`el-table`),M=o(`pagination`),N=u(`loading`);return f(),c(b,{class:`panel`},{default:l(()=>[r(y,{span:24},{default:l(()=>[r(b,null,{default:l(()=>[r(y,{span:24},{default:l(()=>[e(`h2`,P,n(p.$t(`common.title.allOrders`)),1)]),_:1})]),_:1}),r(b,{gutter:16},{default:l(()=>[r(y,{md:6,sm:12,xs:24},{default:l(()=>[r(C,{shadow:`hover`,class:`item-mini mb-3`},{default:l(()=>[p.summaryLoading?(f(),c(x,{key:0})):(f(),i(`div`,F,[e(`div`,I,[r(S,{icon:`fa-solid fa-receipt`,class:`icon`})]),e(`p`,L,n(p.$t(`order.title.totalOrders`)),1),e(`p`,R,n(p.summary.total_count),1)]))]),_:1})]),_:1}),r(y,{md:6,sm:12,xs:24},{default:l(()=>[r(C,{shadow:`hover`,class:`item-mini mb-3`},{default:l(()=>[p.summaryLoading?(f(),c(x,{key:0})):(f(),i(`div`,z,[e(`div`,B,[r(S,{icon:`fa-solid fa-dollar-sign`,class:`icon`})]),e(`p`,V,n(p.$t(`order.title.totalSpent`)),1),e(`p`,H,n(p.getPriceString({value:p.summary.total_spent})),1)]))]),_:1})]),_:1}),r(y,{md:6,sm:12,xs:24},{default:l(()=>[r(C,{shadow:`hover`,class:`item-mini mb-3`},{default:l(()=>[p.summaryLoading?(f(),c(x,{key:0})):(f(),i(`div`,U,[e(`div`,W,[r(S,{icon:`fa-solid fa-check-circle`,class:`icon`})]),e(`p`,ee,n(p.$t(`order.title.finishedOrders`)),1),e(`p`,G,n(p.summary.state_counts?.Finished||0),1)]))]),_:1})]),_:1}),r(y,{md:6,sm:12,xs:24},{default:l(()=>[r(C,{shadow:`hover`,class:`item-mini mb-3`},{default:l(()=>[p.summaryLoading?(f(),c(x,{key:0})):(f(),i(`div`,K,[e(`div`,q,[r(S,{icon:`fa-solid fa-clock`,class:`icon`})]),e(`p`,J,n(p.$t(`order.title.pendingOrders`)),1),e(`p`,Y,n(p.summary.state_counts?.Pending||0),1)]))]),_:1})]),_:1})]),_:1}),e(`div`,X,[r(T,{modelValue:p.filterState,"onUpdate:modelValue":m[0]||=e=>p.filterState=e,clearable:``,placeholder:p.$t(`order.field.allStates`),class:`filter-select`,onChange:p.onFilterChange},{default:l(()=>[(f(!0),i(a,null,d(p.stateOptions,e=>(f(),c(w,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]),r(T,{modelValue:p.filterPayWay,"onUpdate:modelValue":m[1]||=e=>p.filterPayWay=e,clearable:``,placeholder:p.$t(`order.field.allPayWays`),class:`filter-select`,onChange:p.onFilterChange},{default:l(()=>[(f(!0),i(a,null,d(p.payWayOptions,e=>(f(),c(w,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]),r(E,{modelValue:p.createdAtRange,"onUpdate:modelValue":m[2]||=e=>p.createdAtRange=e,type:`datetimerange`,shortcuts:p.shortcuts,"range-separator":p.$t(`usage.placeholder.to`),"start-placeholder":p.$t(`usage.placeholder.startDate`),"end-placeholder":p.$t(`usage.placeholder.endDate`),onChange:p.onFilterChange},null,8,[`modelValue`,`shortcuts`,`range-separator`,`start-placeholder`,`end-placeholder`,`onChange`]),r(D,{type:`primary`,plain:``,loading:p.exporting,onClick:p.onExport},{default:l(()=>[r(S,{icon:`fa-solid fa-file-export`,class:`mr-1`}),t(` `+n(p.$t(`order.button.export`)),1)]),_:1},8,[`loading`,`onClick`])]),r(b,null,{default:l(()=>[r(y,{span:24},{default:l(()=>[r(C,{shadow:`hover`},{default:l(()=>[s((f(),c(j,{data:p.orders,stripe:``,"empty-text":p.$t(`common.message.noData`),class:`min-h-[calc(100vh-450px)] mb-[20px]`},{default:l(()=>[r(k,{prop:`id`,label:p.$t(`order.field.id`),"class-name":`text-center`,width:`200px`},{default:l(t=>[e(`span`,Z,n(t.row.id),1),e(`span`,Q,[r(O,{content:t.row.id,class:`inline-block`},null,8,[`content`])])]),_:1},8,[`label`]),r(k,{label:p.$t(`order.field.price`),width:`110px`,align:`center`},{default:l(t=>[e(`span`,$,n(p.getPriceString({value:t.row?.price})),1)]),_:1},8,[`label`]),r(k,{label:p.$t(`order.field.description`),"min-width":`220px`,"class-name":`hidden md:table-cell`,"label-class-name":`hidden md:table-cell`},{default:l(t=>[e(`span`,te,n(t.row.description),1)]),_:1},8,[`label`]),r(k,{prop:`state`,label:p.$t(`order.field.state`),width:`130px`,align:`center`},{default:l(e=>[r(A,{type:p.stateTagType(e.row.state),class:`mx-1`,effect:`dark`,round:``,size:`small`},{default:l(()=>[t(n(p.stateLabel(e.row.state)),1)]),_:2},1032,[`type`])]),_:1},8,[`label`]),r(k,{label:p.$t(`order.field.payWay`),width:`120px`,align:`center`,"class-name":`hidden md:table-cell`,"label-class-name":`hidden md:table-cell`},{default:l(t=>[e(`span`,ne,n(t.row.pay_way||`-`),1)]),_:1},8,[`label`]),r(k,{label:p.$t(`order.field.createdAt`),width:`200px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:l(t=>[e(`span`,re,n(p.$dayjs.format(t.row.created_at)),1)]),_:1},8,[`label`]),r(k,{"min-width":`130px`,fixed:`right`},{default:l(r=>[e(`div`,ie,[p.isPendingAction(r.row.state)?(f(),c(D,{key:0,type:`primary`,size:`small`,onClick:e=>p.goToDetail(r.row.id)},{default:l(()=>[t(n(p.$t(`order.button.continuePay`)),1)]),_:1},8,[`onClick`])):(f(),c(D,{key:1,size:`small`,onClick:e=>p.goToDetail(r.row.id)},{default:l(()=>[t(n(p.$t(`order.button.checkDetail`)),1)]),_:1},8,[`onClick`]))])]),_:1})]),_:1},8,[`data`,`empty-text`])),[[N,p.loading]])]),_:1})]),_:1})]),_:1}),r(b,null,{default:l(()=>[r(y,{span:10,offset:14},{default:l(()=>[e(`div`,ae,[r(M,{"current-page":p.page,"page-size":p.limit,total:p.total,onChange:p.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var se=w(N,[[`render`,oe],[`__scopeId`,`data-v-452d97b9`]]);export{se as default};
|
|
1
|
+
import"./rolldown-runtime--c01j_DQ.js";import{A as e,I as t,Jt as n,L as r,N as i,T as a,at as o,ht as s,j as c,mt as l,ot as u,rt as d,tt as f,z as p}from"./vendor-chart-Dw-P17PN.js";import{r as m,t as h}from"./select-CBKmbQKx.js";import{n as g,t as _}from"./table-BtJ_S4l0.js";import{t as v}from"./card-D-4S-l7a.js";import{t as y}from"./date-picker-BcJ2Wsoq.js";import{n as b,t as x}from"./row-H2IpqPLs.js";import{t as S}from"./pagination-BspbxLLu.js";import{t as C}from"./skeleton-CoheJz5x.js";import{G as w,Ii as T,Pi as E,fr as D,ri as O,sn as k}from"./index-BO8KoMTB.js";import{t as A}from"./index.es-DWWSJOOT.js";import{t as j}from"./CopyToClipboard-B1VphMUw.js";var M={total_count:0,total_spent:0,state_counts:{}},N=p({name:`ConsoleOrderList`,components:{Pagination:S,CopyToClipboard:j,ElRow:x,ElCol:b,ElTable:_,ElTableColumn:g,ElButton:T,ElTag:E,ElCard:v,ElSelect:m,ElOption:h,ElDatePicker:y,ElSkeleton:C,FontAwesomeIcon:A},data(){return{OrderState:O,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:O.PENDING,label:this.$t(`order.state.pending`)},{value:O.FINISHED,label:this.$t(`order.state.finished`)},{value:O.PAID,label:this.$t(`order.state.paid`)},{value:O.EXPIRED,label:this.$t(`order.state.expired`)},{value:O.FAILED,label:this.$t(`order.state.failed`)},{value:O.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===O.FINISHED||e===O.PAID?`success`:e===O.EXPIRED||e===O.FAILED?`danger`:e===O.REFUNDED?`warning`:`info`},stateLabel(e){return{[O.PENDING]:this.$t(`order.state.pending`),[O.PAID]:this.$t(`order.state.paid`),[O.FINISHED]:this.$t(`order.state.finished`),[O.EXPIRED]:this.$t(`order.state.expired`),[O.FAILED]:this.$t(`order.state.failed`),[O.REFUNDED]:this.$t(`order.state.refunded`)}[e]||e},isPendingAction(e){return e!==O.PAID&&e!==O.FINISHED&&e!==O.EXPIRED&&e!==O.FAILED&&e!==O.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,D.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,D.getSummary(this.filterQuery).then(({data:e})=>{this.summary=e}).catch(()=>{this.summary={...M}}).finally(()=>{this.summaryLoading=!1})},onExport(){this.exporting=!0,D.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(p,m,h,g,_,v){let y=o(`el-col`),b=o(`el-row`),x=o(`el-skeleton`),S=o(`font-awesome-icon`),C=o(`el-card`),w=o(`el-option`),T=o(`el-select`),E=o(`el-date-picker`),D=o(`el-button`),O=o(`copy-to-clipboard`),k=o(`el-table-column`),A=o(`el-tag`),j=o(`el-table`),M=o(`pagination`),N=u(`loading`);return f(),c(b,{class:`panel`},{default:l(()=>[r(y,{span:24},{default:l(()=>[r(b,null,{default:l(()=>[r(y,{span:24},{default:l(()=>[e(`h2`,P,n(p.$t(`common.title.allOrders`)),1)]),_:1})]),_:1}),r(b,{gutter:16},{default:l(()=>[r(y,{md:6,sm:12,xs:24},{default:l(()=>[r(C,{shadow:`hover`,class:`item-mini mb-3`},{default:l(()=>[p.summaryLoading?(f(),c(x,{key:0})):(f(),i(`div`,F,[e(`div`,I,[r(S,{icon:`fa-solid fa-receipt`,class:`icon`})]),e(`p`,L,n(p.$t(`order.title.totalOrders`)),1),e(`p`,R,n(p.summary.total_count),1)]))]),_:1})]),_:1}),r(y,{md:6,sm:12,xs:24},{default:l(()=>[r(C,{shadow:`hover`,class:`item-mini mb-3`},{default:l(()=>[p.summaryLoading?(f(),c(x,{key:0})):(f(),i(`div`,z,[e(`div`,B,[r(S,{icon:`fa-solid fa-dollar-sign`,class:`icon`})]),e(`p`,V,n(p.$t(`order.title.totalSpent`)),1),e(`p`,H,n(p.getPriceString({value:p.summary.total_spent})),1)]))]),_:1})]),_:1}),r(y,{md:6,sm:12,xs:24},{default:l(()=>[r(C,{shadow:`hover`,class:`item-mini mb-3`},{default:l(()=>[p.summaryLoading?(f(),c(x,{key:0})):(f(),i(`div`,U,[e(`div`,W,[r(S,{icon:`fa-solid fa-check-circle`,class:`icon`})]),e(`p`,ee,n(p.$t(`order.title.finishedOrders`)),1),e(`p`,G,n(p.summary.state_counts?.Finished||0),1)]))]),_:1})]),_:1}),r(y,{md:6,sm:12,xs:24},{default:l(()=>[r(C,{shadow:`hover`,class:`item-mini mb-3`},{default:l(()=>[p.summaryLoading?(f(),c(x,{key:0})):(f(),i(`div`,K,[e(`div`,q,[r(S,{icon:`fa-solid fa-clock`,class:`icon`})]),e(`p`,J,n(p.$t(`order.title.pendingOrders`)),1),e(`p`,Y,n(p.summary.state_counts?.Pending||0),1)]))]),_:1})]),_:1})]),_:1}),e(`div`,X,[r(T,{modelValue:p.filterState,"onUpdate:modelValue":m[0]||=e=>p.filterState=e,clearable:``,placeholder:p.$t(`order.field.allStates`),class:`filter-select`,onChange:p.onFilterChange},{default:l(()=>[(f(!0),i(a,null,d(p.stateOptions,e=>(f(),c(w,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]),r(T,{modelValue:p.filterPayWay,"onUpdate:modelValue":m[1]||=e=>p.filterPayWay=e,clearable:``,placeholder:p.$t(`order.field.allPayWays`),class:`filter-select`,onChange:p.onFilterChange},{default:l(()=>[(f(!0),i(a,null,d(p.payWayOptions,e=>(f(),c(w,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]),r(E,{modelValue:p.createdAtRange,"onUpdate:modelValue":m[2]||=e=>p.createdAtRange=e,type:`datetimerange`,shortcuts:p.shortcuts,"range-separator":p.$t(`usage.placeholder.to`),"start-placeholder":p.$t(`usage.placeholder.startDate`),"end-placeholder":p.$t(`usage.placeholder.endDate`),onChange:p.onFilterChange},null,8,[`modelValue`,`shortcuts`,`range-separator`,`start-placeholder`,`end-placeholder`,`onChange`]),r(D,{type:`primary`,plain:``,loading:p.exporting,onClick:p.onExport},{default:l(()=>[r(S,{icon:`fa-solid fa-file-export`,class:`mr-1`}),t(` `+n(p.$t(`order.button.export`)),1)]),_:1},8,[`loading`,`onClick`])]),r(b,null,{default:l(()=>[r(y,{span:24},{default:l(()=>[r(C,{shadow:`hover`},{default:l(()=>[s((f(),c(j,{data:p.orders,stripe:``,"empty-text":p.$t(`common.message.noData`),class:`min-h-[calc(100vh-450px)] mb-[20px]`},{default:l(()=>[r(k,{prop:`id`,label:p.$t(`order.field.id`),"class-name":`text-center`,width:`200px`},{default:l(t=>[e(`span`,Z,n(t.row.id),1),e(`span`,Q,[r(O,{content:t.row.id,class:`inline-block`},null,8,[`content`])])]),_:1},8,[`label`]),r(k,{label:p.$t(`order.field.price`),width:`110px`,align:`center`},{default:l(t=>[e(`span`,$,n(p.getPriceString({value:t.row?.price})),1)]),_:1},8,[`label`]),r(k,{label:p.$t(`order.field.description`),"min-width":`220px`,"class-name":`hidden md:table-cell`,"label-class-name":`hidden md:table-cell`},{default:l(t=>[e(`span`,te,n(t.row.description),1)]),_:1},8,[`label`]),r(k,{prop:`state`,label:p.$t(`order.field.state`),width:`130px`,align:`center`},{default:l(e=>[r(A,{type:p.stateTagType(e.row.state),class:`mx-1`,effect:`dark`,round:``,size:`small`},{default:l(()=>[t(n(p.stateLabel(e.row.state)),1)]),_:2},1032,[`type`])]),_:1},8,[`label`]),r(k,{label:p.$t(`order.field.payWay`),width:`120px`,align:`center`,"class-name":`hidden md:table-cell`,"label-class-name":`hidden md:table-cell`},{default:l(t=>[e(`span`,ne,n(t.row.pay_way||`-`),1)]),_:1},8,[`label`]),r(k,{label:p.$t(`order.field.createdAt`),width:`200px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:l(t=>[e(`span`,re,n(p.$dayjs.format(t.row.created_at)),1)]),_:1},8,[`label`]),r(k,{"min-width":`130px`,fixed:`right`},{default:l(r=>[e(`div`,ie,[p.isPendingAction(r.row.state)?(f(),c(D,{key:0,type:`primary`,size:`small`,onClick:e=>p.goToDetail(r.row.id)},{default:l(()=>[t(n(p.$t(`order.button.continuePay`)),1)]),_:1},8,[`onClick`])):(f(),c(D,{key:1,size:`small`,onClick:e=>p.goToDetail(r.row.id)},{default:l(()=>[t(n(p.$t(`order.button.checkDetail`)),1)]),_:1},8,[`onClick`]))])]),_:1})]),_:1},8,[`data`,`empty-text`])),[[N,p.loading]])]),_:1})]),_:1})]),_:1}),r(b,null,{default:l(()=>[r(y,{span:10,offset:14},{default:l(()=>[e(`div`,ae,[r(M,{"current-page":p.page,"page-size":p.limit,total:p.total,onChange:p.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var se=w(N,[[`render`,oe],[`__scopeId`,`data-v-452d97b9`]]);export{se as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime--c01j_DQ.js";import{A as e,I as t,Jt as n,L as r,M as i,N as a,T as o,at as s,ht as c,j as l,mt as u,ot as ee,rt as d,tt as f,z as p}from"./vendor-chart-Dw-P17PN.js";import{n as m,t as h}from"./table-DnX0TaJt.js";import{t as g}from"./card-D-4S-l7a.js";import{n as _,t as v}from"./row-Dfvy8Z58.js";import{t as y}from"./empty-xCRn_5sX.js";import{t as b}from"./pagination-DwmMdK1y.js";import{t as x}from"./skeleton-CoheJz5x.js";import{t as S}from"./switch-C9nCxAuF.js";import{G as C,Ii as w,Pi as T,Ti as E,ci as D,kn as O,li as k,lt as A,ni as j,rt as M,ti as N,vi as P,yr as F}from"./index-uakaOzYD.js";import{t as I}from"./index.es-BJkAMcls.js";import{t as L}from"./CopyToClipboard-D9EquLu_.js";var R=p({name:`ConsoleApplicationList`,components:{Pagination:b,CopyToClipboard:L,ElTable:h,ElRow:v,ElButton:w,ElCol:_,ElTag:T,ElSkeleton:x,ElSwitch:S,ElEmpty:y,ElTableColumn:m,ElCard:g,FontAwesomeIcon:I},data(){return{credentialType:N,serviceType:j,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!O(this.$store.getters.site)}},watch:{page:{handler(){this.onFetchData()}}},mounted(){this.onInitializeGlobalApplication(),this.onFetchData()},methods:{rowCanPay(e){return O(this.$store.getters.site)?!1:P()?(e?.packages||[]).some(e=>e?.metadata?.apple_product_id):!0},updateAllowConsumeGlobal(e,t){!e||!e.id||F.updateAllConsumeGlobal(e.id,{...e,allow_consume_global:!!t}).then(()=>{E.success(this.$t(`application.message.updateSuccessfully`).toString())}).catch(()=>{E.error(this.$t(`application.message.updateFailed`).toString())})},onGoUsage(e){this.$router.push({name:A,query:{application_id:e.id,type:e?.service?.type}})},onBuyMore(e){e?.id&&this.$router.push({name:M,params:{id:e.id}})},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,page:e}})},onFetchApplications(e=D.INDIVIDUAL){return new Promise((t,n)=>{F.getAll({limit:this.limit,...e===D.INDIVIDUAL?{offset:(this.page-1)*this.limit}:{},user_id:this.$store.getters.user.id,ordering:`-created_at`,type:k.USAGE,scope:e}).then(({data:n})=>{e===D.INDIVIDUAL?(this.individualApplications=n.items,this.individualApplicationsTotal=n.count):(this.globalApplications=n.items,this.globalApplicationsTotal=n.count),t(n)}).catch(e=>{E.error(this.$t(`application.message.fetchFailed`).toString()),n(e)})})},onFetchData(){this.loading=!0,Promise.all([this.onFetchApplications(D.INDIVIDUAL),this.onFetchApplications(D.GLOBAL)]).then(()=>{this.loading=!1}).catch(()=>{this.loading=!1})},onInitializeGlobalApplication(){F.create({type:k.USAGE,scope:D.GLOBAL,user_id:this.$store.getters.user.id}).finally(()=>{this.onFetchApplications(D.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}`}}}),z={class:`title`},B={key:1,class:`summary-card`},V={class:`icon-wrapper`},H={class:`label`},U={class:`value`},W={class:`description`},G={key:1,class:`flex flex-row justify-between items-center gap-3`},K={class:`summary-card min-w-0 flex-1`},q={class:`flex justify-start items-center gap-2 mb-2 w-full`},te={class:`icon-wrapper !mb-0`},J={class:`text-[var(--el-text-color-regular)] text-[14px] truncate`},Y={class:`label`},X={class:`value`},Z={class:`description`},Q={class:`flex flex-col items-end gap-2 shrink-0`},ne={class:`copy`},re={key:0,class:`expired-at`},ie={class:`flex flex-wrap items-center justify-end gap-1`},ae={class:`application-cards block sm:hidden`},oe={class:`flex items-center gap-2 flex-wrap`},se={class:`application-card__name`},ce={class:`application-card__id`},le={class:`truncate`},ue={class:`application-card__row`},de={class:`label`},fe={class:`value`},pe={key:0,class:`application-card__row`},$={class:`label`},me={class:`value`},he={key:1,class:`application-card__row`},ge={class:`label`},_e={class:`flex items-center justify-end gap-2 mt-3`},ve={class:`pagination`};function ye(p,m,h,g,_,v){let y=s(`el-col`),b=s(`el-row`),x=s(`el-skeleton`),S=s(`font-awesome-icon`),C=s(`el-card`),w=s(`copy-to-clipboard`),T=s(`el-button`),E=s(`el-table-column`),D=s(`el-tag`),O=s(`el-switch`),k=s(`el-table`),A=s(`el-empty`),j=s(`pagination`),M=ee(`loading`);return f(),l(b,{class:`application-list`},{default:u(()=>[r(y,{span:24},{default:u(()=>[r(b,null,{default:u(()=>[r(y,{span:24},{default:u(()=>[e(`h2`,z,n(p.$t(`common.title.allApplications`)),1)]),_:1})]),_:1}),r(b,{gutter:15,class:`mb-3`},{default:u(()=>[r(y,{md:12,xs:24},{default:u(()=>[r(C,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:u(()=>[p.loading?(f(),l(x,{key:0})):(f(),a(`div`,B,[e(`div`,V,[r(S,{icon:`fa-solid fa-cubes-stacked`})]),e(`p`,H,n(p.$t(`application.title.count`)),1),e(`p`,U,n(p.individualApplicationsTotal),1),e(`p`,W,n(p.$t(`application.message.countDescription`)),1)]))]),_:1})]),_:1}),p.showGlobalPayment&&p.globalApplications?.length>0?(f(),l(y,{key:0,md:12,xs:24},{default:u(()=>[r(C,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:u(()=>[p.loading?(f(),l(x,{key:0})):(f(),a(`div`,G,[e(`div`,K,[e(`div`,q,[e(`div`,te,[r(S,{icon:`fa-solid fa-wallet`})]),e(`span`,J,[t(n(p.$t(`application.field.id`))+`: `+n(p.globalApplications?.[0]?.id)+` `,1),p.globalApplications?.[0]?.id?(f(),l(w,{key:0,content:p.globalApplications?.[0]?.id,class:`inline-block`},null,8,[`content`])):i(``,!0)])]),e(`p`,Y,n(p.$t(`application.title.globalBalance`)),1),e(`p`,X,n(p.globalApplications?.[0]?.remaining_amount?.toFixed(6)||`0.000000`)+` `+n(p.$t(`service.unit.credits`)),1),e(`p`,Z,n(p.$t(`application.message.globalBalanceDescription`)),1)]),e(`div`,Q,[r(T,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:m[0]||=e=>p.onGoUsage(p.globalApplications?.[0])},{default:u(()=>[r(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),t(` `+n(p.$t(`application.button.usage`)),1)]),_:1}),p.showGlobalPayment?(f(),l(T,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:m[1]||=e=>p.onBuyMore(p.globalApplications?.[0])},{default:u(()=>[r(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),t(` `+n(p.$t(`application.button.buyMore`)),1)]),_:1})):i(``,!0)])]))]),_:1})]),_:1})):i(``,!0)]),_:1}),r(b,null,{default:u(()=>[r(y,{span:24},{default:u(()=>[r(C,{shadow:`hover`,class:`applications-table-card hidden sm:block`},{default:u(()=>[c((f(),l(k,{data:p.individualApplications,stripe:``,class:`applications-table !min-h-[calc(100vh-420px)]`,"table-layout":`fixed`,"empty-text":p.$t(`common.message.noData`)},{default:u(()=>[r(E,{prop:`id`,label:p.$t(`application.field.id`),width:`200px`,"class-name":`text-center`},{default:u(t=>[e(`span`,null,n(t.row.id),1),e(`span`,ne,[r(w,{content:t?.row?.id,class:`inline-block`},null,8,[`content`])])]),_:1},8,[`label`]),r(E,{label:p.$t(`application.field.type`),width:`90px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:u(e=>[e.row?.type===`Period`?(f(),l(D,{key:0,type:`success`,effect:`dark`,round:``},{default:u(()=>[t(n(p.$t(`application.type.period`)),1)]),_:1})):e.row?.type===`Usage`?(f(),l(D,{key:1,effect:`dark`,round:``},{default:u(()=>[t(n(p.$t(`application.type.usage`)),1)]),_:1})):i(``,!0)]),_:1},8,[`label`]),r(E,{label:p.$t(`application.field.name`),width:`180px`},{default:u(r=>[e(`span`,null,n(r.row?.service?.title),1),r.row?.role===`grantee`?(f(),l(D,{key:0,type:`info`,size:`small`,round:``,class:`ml-2`},{default:u(()=>[t(n(p.$t(`application.badge.shared`)),1)]),_:1})):i(``,!0)]),_:1},8,[`label`]),r(E,{prop:`remaining_amount`,label:p.$t(`application.field.remainingAmount`),width:`150px`,"class-name":`text-center`},{default:u(t=>[e(`span`,null,n(p.getRemainingAmount(t.row)),1)]),_:1},8,[`label`]),r(E,{prop:`used_amount`,label:p.$t(`application.field.usedAmount`),width:`150px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:u(t=>[e(`span`,null,n(p.getUsedAmount(t.row)),1)]),_:1},8,[`label`]),r(E,{prop:`allow_consume_global`,label:p.$t(`application.field.allowConsumeGlobal`),width:`120px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:u(e=>[e.row.service?.type===p.serviceType.API?(f(),l(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=>p.updateAllowConsumeGlobal(e.row,t)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])):i(``,!0)]),_:1},8,[`label`]),r(E,{label:p.$t(`application.field.expiredAt`),width:`180px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:u(e=>[e.row.expired_at?(f(),a(`span`,re,n(p.$dayjs.format(e.row.expired_at)),1)):i(``,!0)]),_:1},8,[`label`]),r(E,{fixed:`right`,width:`200px`},{default:u(a=>[e(`div`,ie,[r(T,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:e=>p.onGoUsage(a?.row)},{default:u(()=>[r(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),t(` `+n(p.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),p.rowCanPay(a?.row)?(f(),l(T,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:e=>p.onBuyMore(a?.row)},{default:u(()=>[r(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),t(` `+n(p.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):i(``,!0)])]),_:1})]),_:1},8,[`data`,`empty-text`])),[[M,p.loading]])]),_:1}),e(`div`,ae,[p.loading?(f(),l(x,{key:0,rows:4,animated:``})):(f(),a(o,{key:1},[p.individualApplications?.length?(f(!0),a(o,{key:1},d(p.individualApplications,o=>(f(),l(C,{key:o.id,shadow:`hover`,class:`application-card mb-2`,"body-style":{padding:`14px 16px`}},{default:u(()=>[e(`div`,oe,[e(`span`,se,n(o?.service?.title),1),o?.type===`Period`?(f(),l(D,{key:0,type:`success`,effect:`dark`,size:`small`,round:``},{default:u(()=>[t(n(p.$t(`application.type.period`)),1)]),_:1})):o?.type===`Usage`?(f(),l(D,{key:1,effect:`dark`,size:`small`,round:``},{default:u(()=>[t(n(p.$t(`application.type.usage`)),1)]),_:1})):i(``,!0),o?.role===`grantee`?(f(),l(D,{key:2,type:`info`,size:`small`,round:``},{default:u(()=>[t(n(p.$t(`application.badge.shared`)),1)]),_:1})):i(``,!0)]),e(`div`,ce,[e(`span`,le,n(p.$t(`application.field.id`))+`: `+n(o.id),1),r(w,{content:o.id,class:`inline-block shrink-0`},null,8,[`content`])]),e(`div`,ue,[e(`span`,de,n(p.$t(`application.field.remainingAmount`)),1),e(`span`,fe,n(p.getRemainingAmount(o)),1)]),o?.expired_at?(f(),a(`div`,pe,[e(`span`,$,n(p.$t(`application.field.expiredAt`)),1),e(`span`,me,n(p.$dayjs.format(o.expired_at)),1)])):i(``,!0),o.service?.type===p.serviceType.API?(f(),a(`div`,he,[e(`span`,ge,n(p.$t(`application.field.allowConsumeGlobal`)),1),r(O,{modelValue:o.allow_consume_global,"onUpdate:modelValue":e=>o.allow_consume_global=e,"active-value":!0,"inactive-value":!1,onChange:e=>p.updateAllowConsumeGlobal(o,e)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])])):i(``,!0),e(`div`,_e,[r(T,{class:`!m-0 !px-3`,size:`small`,round:``,onClick:e=>p.onGoUsage(o)},{default:u(()=>[r(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),t(` `+n(p.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),p.rowCanPay(o)?(f(),l(T,{key:0,class:`!m-0 !px-3`,type:`primary`,round:``,size:`small`,onClick:e=>p.onBuyMore(o)},{default:u(()=>[r(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),t(` `+n(p.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):i(``,!0)])]),_:2},1024))),128)):(f(),l(A,{key:0,description:p.$t(`common.message.noData`)},null,8,[`description`]))],64))])]),_:1})]),_:1}),r(b,null,{default:u(()=>[r(y,{span:24},{default:u(()=>[e(`div`,ve,[r(j,{"current-page":p.page,"page-size":p.limit,total:p.individualApplicationsTotal,onChange:p.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var be=C(R,[[`render`,ye],[`__scopeId`,`data-v-29e1e6d7`]]);export{be as default};
|
|
1
|
+
import"./rolldown-runtime--c01j_DQ.js";import{A as e,I as t,Jt as n,L as r,M as i,N as a,T as o,at as s,ht as c,j as l,mt as u,ot as ee,rt as d,tt as f,z as p}from"./vendor-chart-Dw-P17PN.js";import{n as m,t as h}from"./table-BtJ_S4l0.js";import{t as g}from"./card-D-4S-l7a.js";import{n as _,t as v}from"./row-H2IpqPLs.js";import{t as y}from"./empty-xCRn_5sX.js";import{t as b}from"./pagination-BspbxLLu.js";import{t as x}from"./skeleton-CoheJz5x.js";import{t as S}from"./switch-CUBX5SGb.js";import{G as C,Ii as w,Pi as T,Ti as E,ci as D,kn as O,li as k,lt as A,ni as j,rt as M,ti as N,vi as P,yr as F}from"./index-BO8KoMTB.js";import{t as I}from"./index.es-DWWSJOOT.js";import{t as L}from"./CopyToClipboard-B1VphMUw.js";var R=p({name:`ConsoleApplicationList`,components:{Pagination:b,CopyToClipboard:L,ElTable:h,ElRow:v,ElButton:w,ElCol:_,ElTag:T,ElSkeleton:x,ElSwitch:S,ElEmpty:y,ElTableColumn:m,ElCard:g,FontAwesomeIcon:I},data(){return{credentialType:N,serviceType:j,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!O(this.$store.getters.site)}},watch:{page:{handler(){this.onFetchData()}}},mounted(){this.onInitializeGlobalApplication(),this.onFetchData()},methods:{rowCanPay(e){return O(this.$store.getters.site)?!1:P()?(e?.packages||[]).some(e=>e?.metadata?.apple_product_id):!0},updateAllowConsumeGlobal(e,t){!e||!e.id||F.updateAllConsumeGlobal(e.id,{...e,allow_consume_global:!!t}).then(()=>{E.success(this.$t(`application.message.updateSuccessfully`).toString())}).catch(()=>{E.error(this.$t(`application.message.updateFailed`).toString())})},onGoUsage(e){this.$router.push({name:A,query:{application_id:e.id,type:e?.service?.type}})},onBuyMore(e){e?.id&&this.$router.push({name:M,params:{id:e.id}})},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,page:e}})},onFetchApplications(e=D.INDIVIDUAL){return new Promise((t,n)=>{F.getAll({limit:this.limit,...e===D.INDIVIDUAL?{offset:(this.page-1)*this.limit}:{},user_id:this.$store.getters.user.id,ordering:`-created_at`,type:k.USAGE,scope:e}).then(({data:n})=>{e===D.INDIVIDUAL?(this.individualApplications=n.items,this.individualApplicationsTotal=n.count):(this.globalApplications=n.items,this.globalApplicationsTotal=n.count),t(n)}).catch(e=>{E.error(this.$t(`application.message.fetchFailed`).toString()),n(e)})})},onFetchData(){this.loading=!0,Promise.all([this.onFetchApplications(D.INDIVIDUAL),this.onFetchApplications(D.GLOBAL)]).then(()=>{this.loading=!1}).catch(()=>{this.loading=!1})},onInitializeGlobalApplication(){F.create({type:k.USAGE,scope:D.GLOBAL,user_id:this.$store.getters.user.id}).finally(()=>{this.onFetchApplications(D.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}`}}}),z={class:`title`},B={key:1,class:`summary-card`},V={class:`icon-wrapper`},H={class:`label`},U={class:`value`},W={class:`description`},G={key:1,class:`flex flex-row justify-between items-center gap-3`},K={class:`summary-card min-w-0 flex-1`},q={class:`flex justify-start items-center gap-2 mb-2 w-full`},te={class:`icon-wrapper !mb-0`},J={class:`text-[var(--el-text-color-regular)] text-[14px] truncate`},Y={class:`label`},X={class:`value`},Z={class:`description`},Q={class:`flex flex-col items-end gap-2 shrink-0`},ne={class:`copy`},re={key:0,class:`expired-at`},ie={class:`flex flex-wrap items-center justify-end gap-1`},ae={class:`application-cards block sm:hidden`},oe={class:`flex items-center gap-2 flex-wrap`},se={class:`application-card__name`},ce={class:`application-card__id`},le={class:`truncate`},ue={class:`application-card__row`},de={class:`label`},fe={class:`value`},pe={key:0,class:`application-card__row`},$={class:`label`},me={class:`value`},he={key:1,class:`application-card__row`},ge={class:`label`},_e={class:`flex items-center justify-end gap-2 mt-3`},ve={class:`pagination`};function ye(p,m,h,g,_,v){let y=s(`el-col`),b=s(`el-row`),x=s(`el-skeleton`),S=s(`font-awesome-icon`),C=s(`el-card`),w=s(`copy-to-clipboard`),T=s(`el-button`),E=s(`el-table-column`),D=s(`el-tag`),O=s(`el-switch`),k=s(`el-table`),A=s(`el-empty`),j=s(`pagination`),M=ee(`loading`);return f(),l(b,{class:`application-list`},{default:u(()=>[r(y,{span:24},{default:u(()=>[r(b,null,{default:u(()=>[r(y,{span:24},{default:u(()=>[e(`h2`,z,n(p.$t(`common.title.allApplications`)),1)]),_:1})]),_:1}),r(b,{gutter:15,class:`mb-3`},{default:u(()=>[r(y,{md:12,xs:24},{default:u(()=>[r(C,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:u(()=>[p.loading?(f(),l(x,{key:0})):(f(),a(`div`,B,[e(`div`,V,[r(S,{icon:`fa-solid fa-cubes-stacked`})]),e(`p`,H,n(p.$t(`application.title.count`)),1),e(`p`,U,n(p.individualApplicationsTotal),1),e(`p`,W,n(p.$t(`application.message.countDescription`)),1)]))]),_:1})]),_:1}),p.showGlobalPayment&&p.globalApplications?.length>0?(f(),l(y,{key:0,md:12,xs:24},{default:u(()=>[r(C,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:u(()=>[p.loading?(f(),l(x,{key:0})):(f(),a(`div`,G,[e(`div`,K,[e(`div`,q,[e(`div`,te,[r(S,{icon:`fa-solid fa-wallet`})]),e(`span`,J,[t(n(p.$t(`application.field.id`))+`: `+n(p.globalApplications?.[0]?.id)+` `,1),p.globalApplications?.[0]?.id?(f(),l(w,{key:0,content:p.globalApplications?.[0]?.id,class:`inline-block`},null,8,[`content`])):i(``,!0)])]),e(`p`,Y,n(p.$t(`application.title.globalBalance`)),1),e(`p`,X,n(p.globalApplications?.[0]?.remaining_amount?.toFixed(6)||`0.000000`)+` `+n(p.$t(`service.unit.credits`)),1),e(`p`,Z,n(p.$t(`application.message.globalBalanceDescription`)),1)]),e(`div`,Q,[r(T,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:m[0]||=e=>p.onGoUsage(p.globalApplications?.[0])},{default:u(()=>[r(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),t(` `+n(p.$t(`application.button.usage`)),1)]),_:1}),p.showGlobalPayment?(f(),l(T,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:m[1]||=e=>p.onBuyMore(p.globalApplications?.[0])},{default:u(()=>[r(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),t(` `+n(p.$t(`application.button.buyMore`)),1)]),_:1})):i(``,!0)])]))]),_:1})]),_:1})):i(``,!0)]),_:1}),r(b,null,{default:u(()=>[r(y,{span:24},{default:u(()=>[r(C,{shadow:`hover`,class:`applications-table-card hidden sm:block`},{default:u(()=>[c((f(),l(k,{data:p.individualApplications,stripe:``,class:`applications-table !min-h-[calc(100vh-420px)]`,"table-layout":`fixed`,"empty-text":p.$t(`common.message.noData`)},{default:u(()=>[r(E,{prop:`id`,label:p.$t(`application.field.id`),width:`200px`,"class-name":`text-center`},{default:u(t=>[e(`span`,null,n(t.row.id),1),e(`span`,ne,[r(w,{content:t?.row?.id,class:`inline-block`},null,8,[`content`])])]),_:1},8,[`label`]),r(E,{label:p.$t(`application.field.type`),width:`90px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:u(e=>[e.row?.type===`Period`?(f(),l(D,{key:0,type:`success`,effect:`dark`,round:``},{default:u(()=>[t(n(p.$t(`application.type.period`)),1)]),_:1})):e.row?.type===`Usage`?(f(),l(D,{key:1,effect:`dark`,round:``},{default:u(()=>[t(n(p.$t(`application.type.usage`)),1)]),_:1})):i(``,!0)]),_:1},8,[`label`]),r(E,{label:p.$t(`application.field.name`),width:`180px`},{default:u(r=>[e(`span`,null,n(r.row?.service?.title),1),r.row?.role===`grantee`?(f(),l(D,{key:0,type:`info`,size:`small`,round:``,class:`ml-2`},{default:u(()=>[t(n(p.$t(`application.badge.shared`)),1)]),_:1})):i(``,!0)]),_:1},8,[`label`]),r(E,{prop:`remaining_amount`,label:p.$t(`application.field.remainingAmount`),width:`150px`,"class-name":`text-center`},{default:u(t=>[e(`span`,null,n(p.getRemainingAmount(t.row)),1)]),_:1},8,[`label`]),r(E,{prop:`used_amount`,label:p.$t(`application.field.usedAmount`),width:`150px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:u(t=>[e(`span`,null,n(p.getUsedAmount(t.row)),1)]),_:1},8,[`label`]),r(E,{prop:`allow_consume_global`,label:p.$t(`application.field.allowConsumeGlobal`),width:`120px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:u(e=>[e.row.service?.type===p.serviceType.API?(f(),l(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=>p.updateAllowConsumeGlobal(e.row,t)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])):i(``,!0)]),_:1},8,[`label`]),r(E,{label:p.$t(`application.field.expiredAt`),width:`180px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:u(e=>[e.row.expired_at?(f(),a(`span`,re,n(p.$dayjs.format(e.row.expired_at)),1)):i(``,!0)]),_:1},8,[`label`]),r(E,{fixed:`right`,width:`200px`},{default:u(a=>[e(`div`,ie,[r(T,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:e=>p.onGoUsage(a?.row)},{default:u(()=>[r(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),t(` `+n(p.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),p.rowCanPay(a?.row)?(f(),l(T,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:e=>p.onBuyMore(a?.row)},{default:u(()=>[r(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),t(` `+n(p.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):i(``,!0)])]),_:1})]),_:1},8,[`data`,`empty-text`])),[[M,p.loading]])]),_:1}),e(`div`,ae,[p.loading?(f(),l(x,{key:0,rows:4,animated:``})):(f(),a(o,{key:1},[p.individualApplications?.length?(f(!0),a(o,{key:1},d(p.individualApplications,o=>(f(),l(C,{key:o.id,shadow:`hover`,class:`application-card mb-2`,"body-style":{padding:`14px 16px`}},{default:u(()=>[e(`div`,oe,[e(`span`,se,n(o?.service?.title),1),o?.type===`Period`?(f(),l(D,{key:0,type:`success`,effect:`dark`,size:`small`,round:``},{default:u(()=>[t(n(p.$t(`application.type.period`)),1)]),_:1})):o?.type===`Usage`?(f(),l(D,{key:1,effect:`dark`,size:`small`,round:``},{default:u(()=>[t(n(p.$t(`application.type.usage`)),1)]),_:1})):i(``,!0),o?.role===`grantee`?(f(),l(D,{key:2,type:`info`,size:`small`,round:``},{default:u(()=>[t(n(p.$t(`application.badge.shared`)),1)]),_:1})):i(``,!0)]),e(`div`,ce,[e(`span`,le,n(p.$t(`application.field.id`))+`: `+n(o.id),1),r(w,{content:o.id,class:`inline-block shrink-0`},null,8,[`content`])]),e(`div`,ue,[e(`span`,de,n(p.$t(`application.field.remainingAmount`)),1),e(`span`,fe,n(p.getRemainingAmount(o)),1)]),o?.expired_at?(f(),a(`div`,pe,[e(`span`,$,n(p.$t(`application.field.expiredAt`)),1),e(`span`,me,n(p.$dayjs.format(o.expired_at)),1)])):i(``,!0),o.service?.type===p.serviceType.API?(f(),a(`div`,he,[e(`span`,ge,n(p.$t(`application.field.allowConsumeGlobal`)),1),r(O,{modelValue:o.allow_consume_global,"onUpdate:modelValue":e=>o.allow_consume_global=e,"active-value":!0,"inactive-value":!1,onChange:e=>p.updateAllowConsumeGlobal(o,e)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])])):i(``,!0),e(`div`,_e,[r(T,{class:`!m-0 !px-3`,size:`small`,round:``,onClick:e=>p.onGoUsage(o)},{default:u(()=>[r(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),t(` `+n(p.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),p.rowCanPay(o)?(f(),l(T,{key:0,class:`!m-0 !px-3`,type:`primary`,round:``,size:`small`,onClick:e=>p.onBuyMore(o)},{default:u(()=>[r(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),t(` `+n(p.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):i(``,!0)])]),_:2},1024))),128)):(f(),l(A,{key:0,description:p.$t(`common.message.noData`)},null,8,[`description`]))],64))])]),_:1})]),_:1}),r(b,null,{default:u(()=>[r(y,{span:24},{default:u(()=>[e(`div`,ve,[r(j,{"current-page":p.page,"page-size":p.limit,total:p.individualApplicationsTotal,onChange:p.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var be=C(R,[[`render`,ye],[`__scopeId`,`data-v-29e1e6d7`]]);export{be as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime--c01j_DQ.js";import{A as t,I as n,Jt as r,L as i,M as a,N as o,T as s,a as c,at as l,c as u,d,ht as f,i as p,j as m,l as h,mt as g,n as _,o as v,ot as ee,qt as y,r as b,rt as x,s as S,t as C,tt as w,u as T,x as te,z as E}from"./vendor-chart-Dw-P17PN.js";import{r as D,t as O}from"./select-DsDoofB0.js";import{n as k,t as A}from"./table-DnX0TaJt.js";import{n as j,t as M}from"./tabs-CKv8u6ve.js";import{t as N}from"./card-D-4S-l7a.js";import{n as P,r as F}from"./radio-Bj0tEwH8.js";import{t as I}from"./date-picker-DtFbZyxJ.js";import{n as L,t as R}from"./row-Dfvy8Z58.js";import{t as z}from"./empty-xCRn_5sX.js";import{t as B}from"./pagination-DwmMdK1y.js";import{n as V,t as H}from"./skeleton-CoheJz5x.js";import{t as U}from"./switch-C9nCxAuF.js";import{Cr as W,G as ne,Ii as re,Oi as ie,Pi as ae,Ti as G,hr as K,li as q,mi as J,mr as Y,ni as X,pr as oe,ti as se,yr as ce}from"./index-uakaOzYD.js";import{t as le}from"./index.es-BJkAMcls.js";import{t as ue}from"./CopyToClipboard-D9EquLu_.js";var de=e(W());v.register(c,u,p,b,S,T,d,h);var Z=[`#5B8FF9`,`#5AD8A6`,`#5D7092`,`#F6BD16`,`#6F5EF9`,`#6DC8EC`,`#945FB9`,`#FF9845`,`#1E9493`,`#FF99C3`],Q=`#C0C4CC`,fe=.01,pe=20;function me(e){return e<=Z.length?Z.slice(0,e):Array.from({length:e},(t,n)=>`hsl(${Math.round(n*360/e)}, 62%, ${n%2==0?55:45}%)`)}var he=15e3,ge=E({name:`ConsoleUsageList`,components:{Pagination:B,ElTag:ae,ElDatePicker:I,ElTable:A,ElSelect:D,ElOption:O,CopyToClipboard:ue,ElRow:R,ElCol:L,ElTableColumn:k,ElCard:N,ElRadioButton:P,ElRadioGroup:F,ElSkeleton:H,ElSkeletonItem:V,ElDialog:ie,ElTabs:j,ElTabPane:M,ElButton:re,ElEmpty:z,ElSwitch:U,FontAwesomeIcon:le,BarChart:C,DoughnutChart:_},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:se,serviceType:X,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()||X.API,loading:!1,total:void 0,limit:15,totalUsed:0,barChartLabels:[],barChartSeries:[],chartView:`trend`,apiBreakdown:[],pieLabels:[],pieData:[],pieColors:[],aggLoading:!1,detailDialogVisible:!1,detailRow:null,detailActiveTab:`request`,detailLoading:!1,exporting:!1,statusCodeFilter:this.$route.query.status_code?.toString()||``,traceId:this.$route.query.trace_id?.toString()||``,statusCodeOptions:[],statusCodeOptionsLoading:!1,autoRefresh:!0,autoRefreshTimer:null,fetchSeq:0}},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,maxBarThickness:36,borderRadius:2,borderSkipped:!1}))}},barChartOptions(){let e=e=>new Intl.NumberFormat().format(Math.round(((e||0)+2**-52)*100)/100);return{responsive:!0,maintainAspectRatio:!1,interaction:{mode:`index`,intersect:!1},plugins:{legend:{position:`bottom`,labels:{usePointStyle:!0,pointStyle:`circle`,boxWidth:8,boxHeight:8,padding:14},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:!1},tooltip:{itemSort:(e,t)=>(t.parsed?.y||0)-(e.parsed?.y||0),callbacks:{label:t=>` ${t.dataset.label}: ${e(t.parsed.y)}`,footer:t=>`${this.$t(`usage.title.totalUsed`)}: ${e(t.reduce((e,t)=>e+(t.parsed?.y||0),0))}`}}},scales:{x:{stacked:!0,grid:{display:!1},ticks:{maxRotation:0,autoSkip:!0,autoSkipPadding:16}},y:{stacked:!0,beginAtZero:!0,border:{display:!1},grid:{color:`rgba(128, 128, 128, 0.15)`},ticks:{callback:t=>e(Number(t))}}}}},doughnutChartData(){return{labels:this.pieLabels,datasets:[{data:this.pieData,backgroundColor:this.pieColors,borderWidth:0,hoverOffset:6}]}},doughnutChartOptions(){let e=e=>this.fmtAmount(e),t=this.pieData.reduce((e,t)=>e+(t||0),0);return{responsive:!0,maintainAspectRatio:!1,cutout:`58%`,plugins:{legend:{position:`right`,labels:{usePointStyle:!0,pointStyle:`circle`,boxWidth:8,boxHeight:8,padding:12}},title:{display:!1},tooltip:{callbacks:{label:n=>{let r=n.parsed||0,i=t>0?(r/t*100).toFixed(1):`0`;return` ${n.label}: ${e(r)} (${i}%)`}}}}}}},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()}},autoRefresh:{handler(e){e?this.startAutoRefresh():this.stopAutoRefresh()}}},mounted(){this.onFetchApplications(),this.onFetchApis(),this.onFetchUsages(),this.onFetchAggregate(),this.onFetchStatusCodeOptions(),this.autoRefresh&&this.startAutoRefresh()},beforeUnmount(){this.stopAutoRefresh()},methods:{async onFetchUsages(e=!1){this.type===X.API?this.onFetchApiUsages(e):this.type===X.Proxy&&this.onFetchProxyUsages(e)},startAutoRefresh(){this.stopAutoRefresh(),this.autoRefreshTimer=window.setInterval(()=>{document.hidden||this.onFetchUsages(!0)},he)},stopAutoRefresh(){this.autoRefreshTimer!==null&&(clearInterval(this.autoRefreshTimer),this.autoRefreshTimer=null)},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(){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 Y.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},getCredentialLabel(e){return e.credential?.name?.trim()||e.credential?.id||e.credential_id||`-`},onShowDetail(e){this.detailRow={...e,metadata:void 0},this.detailActiveTab=`request`,this.detailDialogVisible=!0,this.detailLoading=!0,e.id&&Y.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(){ce.getAll({limit:100,offset:0,user_id:this.$store.getters.user.id,ordering:`-created_at`,type:q.USAGE}).then(({data:e})=>{this.applications=e.items.filter(e=>e?.service?.type===this.type)}).catch(()=>{})},onFetchApis(){this.apisLoading=!0,oe.getAll({limit:1e3,offset:0,ordering:`-created_at`}).then(({data:e})=>{this.apis=e.items}).catch(()=>{}).finally(()=>{this.apisLoading=!1})},onFetchApiUsages(e=!1){e||(this.loading=!0);let t=++this.fetchSeq;Y.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}:{},...this.traceId?{trace_id:this.traceId}:{}}).then(({data:e})=>{t===this.fetchSeq&&(this.apiUsages=e.items,this.total=e.count)}).catch(()=>{}).finally(()=>{e||(this.loading=!1)})},onFetchProxyUsages(e=!1){e||(this.loading=!0);let t=++this.fetchSeq;K.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})=>{t===this.fetchSeq&&(this.proxyUsages=e.items,this.total=e.count)}).catch(()=>{}).finally(()=>{e||(this.loading=!1)})},async onExport(){let e=this.$store.state.token?.access;if(!e){G.error(this.$t(`usage.message.exportFailed`));return}let t={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}:{}},n=`${J()}/api/v1/usage/apis/export/?${de.default.stringify(t,{arrayFormat:`repeat`})}`,r=null,i=window.showSaveFilePicker;if(typeof i==`function`)try{r=await i({suggestedName:`usages.csv`,types:[{description:`CSV`,accept:{"text/csv":[`.csv`]}}]})}catch(e){if(e?.name===`AbortError`)return;r=null}this.exporting=!0;try{let t=await fetch(n,{headers:{authorization:`Bearer ${e}`}});if(!t.ok||!t.body)throw Error(`export failed: ${t.status}`);if(r)await t.body.pipeTo(await r.createWritable());else{let e=await t.blob(),n=window.URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=`usages.csv`,r.click(),window.URL.revokeObjectURL(n)}}catch{G.error(this.$t(`usage.message.exportFailed`))}finally{this.exporting=!1}},fmtAmount(e){return new Intl.NumberFormat().format(Math.round(((e||0)+2**-52)*100)/100)},async onFetchAggregate(){if(this.type!==this.serviceType.API)return;this.aggLoading=!0;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]}:{},timezone:Intl.DateTimeFormat().resolvedOptions().timeZone};try{let{data:t}=await Y.getAggregate(e);this.totalUsed=t.total||0;let n=Array.from(new Set((t.items||[]).map(e=>e.date))).sort(),r={},i={};(t.items||[]).forEach(e=>{let t=e.amount||0;(r[e.date]||(r[e.date]={}))[e.api_id]=(r[e.date]?.[e.api_id]||0)+t,i[e.api_id]=(i[e.api_id]||0)+t});let a=Object.keys(i).sort((e,t)=>i[t]-i[e]),o=a.reduce((e,t)=>e+i[t],0),s=a.length;if(o>0){let e=o*(1-fe),t=0;for(let n=0;n<a.length;n++)if(t+=i[a[n]],t>=e){s=n+1;break}s=Math.min(s,pe)}a.length-s===1&&(s=a.length);let c=a.slice(0,s),l=new Set(c),u=me(c.length),d=a.slice(s),f=`${this.$t(`usage.value.others`)} (${d.length})`,p=c.map((e,i)=>({key:e,label:t.apis?.[e]?.title||e,data:n.map(t=>r[t]?.[e]||0),color:u[i]}));if(d.length){let e=n.map(e=>Object.entries(r[e]||{}).reduce((e,[t,n])=>l.has(t)?e:e+n,0));e.some(e=>e>0)&&p.push({key:`__others__`,label:f,data:e,color:Q})}this.apiBreakdown=a.map((e,n)=>({key:e,label:t.apis?.[e]?.title||e,amount:i[e],color:n<c.length?u[n]:Q,share:o>0?i[e]/o:0}));let m=[],h=[],g=[];c.forEach((e,n)=>{m.push(t.apis?.[e]?.title||e),h.push(i[e]),g.push(u[n])});let _=d.reduce((e,t)=>e+i[t],0);_>0&&(m.push(f),h.push(_),g.push(Q)),this.pieLabels=m,this.pieData=h,this.pieColors=g,this.barChartLabels=n,this.barChartSeries=p}finally{this.aggLoading=!1}}}}),_e={class:`text-[26px] font-bold mb-5 text-[var(--el-text-color-primary)]`},ve={class:`inline-block w-9`},ye={class:`inline-block`},be={key:1,class:`summary-card`},xe={class:`icon-wrapper`},Se={class:`text-left`},Ce={class:`description`},we={class:`value`},Te={class:`flex flex-wrap items-center justify-between gap-2`},Ee={class:`text-[15px] font-medium text-[var(--el-text-color-primary)]`},De={class:`chart-wrapper`},Oe={class:`share-cell`},ke={class:`share-bar`},Ae={class:`share-pct`},je={class:`flex items-center justify-end gap-2 mb-4`},Me={class:`text-sm text-[var(--el-text-color-regular)]`},Ne={key:0},Pe={key:0},Fe={key:1},Ie={class:`flex flex-wrap gap-2`},Le={class:`key`},Re={key:0,class:`cursor-pointer`},ze={class:`key`},Be={key:0,class:`cursor-pointer`},Ve={class:`created-at`},$={class:`key`},He={key:0,class:`cursor-pointer`},Ue={class:`created-at`},We={key:1,class:`detail-json`},Ge={key:2,class:`text-gray-400`},Ke={key:1,class:`detail-json`},qe={key:2,class:`text-gray-400`},Je={class:`float-right`};function Ye(e,c,u,d,p,h){let _=l(`el-col`),v=l(`el-row`),b=l(`el-radio-button`),S=l(`el-radio-group`),C=l(`el-option`),T=l(`el-select`),E=l(`el-skeleton-item`),D=l(`el-skeleton`),O=l(`el-date-picker`),k=l(`font-awesome-icon`),A=l(`el-button`),j=l(`el-card`),M=l(`bar-chart`),N=l(`el-empty`),P=l(`doughnut-chart`),F=l(`el-table-column`),I=l(`el-table`),L=l(`el-switch`),R=l(`el-tag`),z=l(`copy-to-clipboard`),B=l(`el-tab-pane`),V=l(`el-tabs`),H=l(`el-dialog`),U=l(`pagination`),W=ee(`loading`);return w(),m(v,null,{default:g(()=>[i(_,{span:24},{default:g(()=>[i(v,null,{default:g(()=>[i(_,{span:24},{default:g(()=>[t(`h2`,_e,r(e.$t(`common.title.allUsages`)),1)]),_:1})]),_:1}),i(v,null,{default:g(()=>[i(_,{md:4,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:g(()=>[t(`span`,null,r(e.$t(`application.field.type`)),1),i(S,{modelValue:e.type,"onUpdate:modelValue":c[0]||=t=>e.type=t},{default:g(()=>[i(b,{value:e.serviceType.API,label:e.$t(`application.field.api`)},null,8,[`value`,`label`]),i(b,{value:e.serviceType.Proxy,label:e.$t(`application.field.proxy`)},null,8,[`value`,`label`])]),_:1},8,[`modelValue`])]),_:1}),f(i(_,{md:6,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:g(()=>[t(`span`,ve,r(e.$t(`usage.field.application`)),1),i(T,{modelValue:e.applicationIds,"onUpdate:modelValue":c[1]||=t=>e.applicationIds=t,placeholder:e.$t(`usage.field.application`),clearable:``,multiple:``,"collapse-tags":``,"collapse-tags-tooltip":``,class:`w-full`,onChange:e.onApplicationsChange},{default:g(()=>[(w(!0),o(s,null,x(e.applications,e=>(w(),m(C,{key:e.id,label:e.service?.title,value:e?.id},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`])]),_:1},512),[[te,!1]]),e.type===e.serviceType.API?(w(),m(_,{key:0,md:6,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:g(()=>[t(`span`,ye,r(e.$t(`usage.field.api`)),1),e.apisLoading?(w(),m(D,{key:0,animated:``,class:`w-full`},{template:g(()=>[i(E,{variant:`rect`,style:{height:`32px`,"border-radius":`4px`}})]),_:1})):(w(),m(T,{key:1,modelValue:e.apiIds,"onUpdate:modelValue":c[2]||=t=>e.apiIds=t,placeholder:e.$t(`usage.field.api`),clearable:``,filterable:``,multiple:``,"collapse-tags":``,"collapse-tags-tooltip":``,class:`w-full`,onChange:e.onApisChange},{default:g(()=>[(w(!0),o(s,null,x(e.apis,e=>(w(),m(C,{key:e?.id,label:e?.title,value:e?.id},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]))]),_:1})):a(``,!0),e.type===e.serviceType.API?(w(),m(_,{key:1,md:8,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:g(()=>[i(O,{modelValue:e.createdAtRange,"onUpdate:modelValue":c[3]||=t=>e.createdAtRange=t,type:`datetimerange`,class:`w-full`,shortcuts:e.shortcuts,"range-separator":e.$t(`usage.placeholder.to`),"start-placeholder":e.$t(`usage.placeholder.startDate`),"end-placeholder":e.$t(`usage.placeholder.endDate`),onChange:e.onTimeRangeChanged},null,8,[`modelValue`,`shortcuts`,`range-separator`,`start-placeholder`,`end-placeholder`,`onChange`])]),_:1})):a(``,!0),e.type===e.serviceType.API?(w(),m(_,{key:2,md:3,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:g(()=>[i(T,{modelValue:e.statusCodeFilter,"onUpdate:modelValue":c[4]||=t=>e.statusCodeFilter=t,placeholder:e.$t(`usage.option.statusCodeAll`),class:`w-full`,clearable:``,filterable:``,"allow-create":``,"default-first-option":``,loading:e.statusCodeOptionsLoading,onChange:e.onStatusCodeChange},{default:g(()=>[(w(!0),o(s,null,x(e.statusCodeOptions,e=>(w(),m(C,{key:e,label:String(e),value:String(e)},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`loading`,`onChange`])]),_:1})):a(``,!0),e.type===e.serviceType.API?(w(),m(_,{key:3,md:3,xs:24,class:`mb-5 flex px-2 gap-2 items-center justify-end`},{default:g(()=>[i(A,{type:`primary`,plain:``,loading:e.exporting,class:`w-full whitespace-nowrap`,onClick:e.onExport},{default:g(()=>[i(k,{icon:`fa-solid fa-file-export`,class:`mr-1`}),n(` `+r(e.$t(`usage.button.export`)),1)]),_:1},8,[`loading`,`onClick`])]),_:1})):a(``,!0)]),_:1}),i(v,null,{default:g(()=>[i(_,{span:24},{default:g(()=>[e.type===e.serviceType.API?(w(),m(v,{key:0,gutter:24,class:`mb-5`},{default:g(()=>[i(_,{md:6,xs:24},{default:g(()=>[i(j,{shadow:`hover`,class:`h-full`},{default:g(()=>[e.aggLoading?(w(),m(D,{key:0})):(w(),o(`div`,be,[t(`div`,xe,[i(k,{icon:`fa-solid fa-cubes`,class:`icon`})]),t(`div`,Se,[t(`p`,Ce,r(e.$t(`usage.title.totalUsed`)),1),t(`p`,we,r(e.totalUsedString),1)])]))]),_:1})]),_:1}),i(_,{md:18,xs:24},{default:g(()=>[i(j,{shadow:`hover`,class:`h-full`},{header:g(()=>[t(`div`,Te,[t(`span`,Ee,r(e.$t(`usage.title.usageAnalytics`)),1),i(S,{modelValue:e.chartView,"onUpdate:modelValue":c[5]||=t=>e.chartView=t,size:`small`},{default:g(()=>[i(b,{value:`trend`,label:e.$t(`usage.view.trend`)},null,8,[`label`]),i(b,{value:`distribution`,label:e.$t(`usage.view.distribution`)},null,8,[`label`]),i(b,{value:`breakdown`,label:e.$t(`usage.view.breakdown`)},null,8,[`label`])]),_:1},8,[`modelValue`])])]),default:g(()=>[t(`div`,De,[e.aggLoading?(w(),m(D,{key:0,class:`w-full`})):e.chartView===`trend`?(w(),o(s,{key:1},[e.barChartSeries.length?(w(),m(M,{key:0,data:e.barChartData,options:e.barChartOptions,class:`chart`},null,8,[`data`,`options`])):(w(),m(N,{key:1,description:e.$t(`common.message.noData`),"image-size":70,class:`w-full`},null,8,[`description`]))],64)):e.chartView===`distribution`?(w(),o(s,{key:2},[e.pieData.length?(w(),m(P,{key:0,data:e.doughnutChartData,options:e.doughnutChartOptions,class:`chart`},null,8,[`data`,`options`])):(w(),m(N,{key:1,description:e.$t(`common.message.noData`),"image-size":70,class:`w-full`},null,8,[`description`]))],64)):(w(),o(s,{key:3},[e.apiBreakdown.length?(w(),m(I,{key:0,data:e.apiBreakdown,size:`small`,height:`300`,class:`w-full`},{default:g(()=>[i(F,{label:e.$t(`usage.field.api`),"min-width":`160`},{default:g(e=>[t(`span`,{class:`color-dot`,style:y({backgroundColor:e.row.color})},null,4),t(`span`,null,r(e.row.label),1)]),_:1},8,[`label`]),i(F,{label:e.$t(`usage.field.consumed`),width:`120`,align:`right`},{default:g(n=>[t(`span`,null,r(e.fmtAmount(n.row.amount)),1)]),_:1},8,[`label`]),i(F,{label:e.$t(`usage.field.share`),width:`150`},{default:g(e=>[t(`div`,Oe,[t(`div`,ke,[t(`div`,{class:`share-bar-fill`,style:y({width:e.row.share*100+`%`,backgroundColor:e.row.color})},null,4)]),t(`span`,Ae,r((e.row.share*100).toFixed(1))+`%`,1)])]),_:1},8,[`label`])]),_:1},8,[`data`])):(w(),m(N,{key:1,description:e.$t(`common.message.noData`),"image-size":70,class:`w-full`},null,8,[`description`]))],64))])]),_:1})]),_:1})]),_:1})):a(``,!0),i(j,{shadow:`hover`},{default:g(()=>[t(`div`,je,[t(`span`,Me,r(e.$t(`usage.field.autoRefresh`)),1),i(L,{modelValue:e.autoRefresh,"onUpdate:modelValue":c[6]||=t=>e.autoRefresh=t},null,8,[`modelValue`])]),e.type===e.serviceType.API?f((w(),m(I,{key:0,data:e.apiUsages,stripe:``,"table-layout":`fixed`,"empty-text":e.$t(`common.message.noData`),class:`min-h-[calc(100vh-350px)] mb-5`},{default:g(()=>[i(F,{label:e.$t(`application.field.name`),width:`160px`},{default:g(e=>[t(`span`,null,r(e.row?.api?.title),1)]),_:1},8,[`label`]),i(F,{label:e.$t(`usage.field.statusCode`),width:`120px`},{default:g(t=>[t.row.status_code?(w(),o(`span`,Ne,r(t.row.status_code),1)):(w(),m(R,{key:1,type:`warning`,size:`small`},{default:g(()=>[n(r(e.$t(`usage.value.processing`)),1)]),_:1}))]),_:1},8,[`label`]),i(F,{label:e.$t(`usage.field.elapsed`),width:`120px`},{default:g(n=>[t(`span`,null,r(e.formatElapsed(n.row.elapsed)),1)]),_:1},8,[`label`]),i(F,{prop:`deducted_amount`,label:e.$t(`usage.field.deductedAmount`),width:`150px`,"class-name":`text-center`},{default:g(n=>[e.getDeductedAmount(n.row)===e.getOriginalAmount(n.row)?(w(),o(`div`,Pe,[t(`span`,null,r(e.getDeductedAmount(n.row)),1)])):(w(),o(`div`,Fe,[c[9]||=t(`p`,null,null,-1),t(`p`,null,[t(`span`,null,r(e.getDeductedAmount(n.row)),1)]),t(`p`,null,[t(`del`,null,r(e.getOriginalAmount(n.row)),1)])]))]),_:1},8,[`label`]),i(F,{prop:`remaining_amount`,label:e.$t(`usage.field.balanceAfter`),width:`160px`,"class-name":`text-center`},{default:g(n=>[t(`span`,null,r(e.getRemainingAmount(n.row)),1)]),_:1},8,[`label`]),i(F,{prop:`metadata`,label:e.$t(`usage.field.metadata`),width:`260px`,"class-name":`text-center`},{default:g(i=>[t(`div`,Ie,[i.row.original_amount>i.row.deducted_amount&&i.row.original_amount>0?(w(),m(R,{key:0,type:`success`,style:{textWrap:`wrap`,height:`fit-content`,lineHeight:`20px`,borderRadius:`10px`}},{default:g(()=>[n(r(((i.row.original_amount-i.row.deducted_amount)*100/i.row.original_amount).toFixed(0)+`% OFF`),1)]),_:2},1024)):a(``,!0),(w(!0),o(s,null,x(e.getSimpleMetadata(i.row.metadata),(e,t)=>(w(),m(R,{key:t,style:{textWrap:`wrap`,height:`fit-content`,lineHeight:`20px`,borderRadius:`10px`}},{default:g(()=>[n(r(t)+`: `+r(e),1)]),_:2},1024))),128))])]),_:1},8,[`label`]),i(F,{label:e.$t(`usage.button.viewDetail`),width:`120px`,"class-name":`text-center`},{default:g(t=>[t.row.id?(w(),m(A,{key:0,type:`primary`,plain:``,size:`small`,class:`!px-2 !py-1 !text-xs !h-auto !min-h-0`,onClick:n=>e.onShowDetail(t.row)},{default:g(()=>[n(r(e.$t(`usage.button.viewDetail`)),1)]),_:1},8,[`onClick`])):a(``,!0)]),_:1},8,[`label`]),i(F,{prop:`trace_id`,label:e.$t(`application.field.traceId`),width:`200px`,"class-name":`text-center`},{default:g(e=>[t(`span`,Le,r(e.row.trace_id),1),e.row.trace_id?(w(),o(`span`,Re,[i(z,{content:e.row.trace_id,class:`inline-block`},null,8,[`content`])])):a(``,!0)]),_:1},8,[`label`]),i(F,{prop:`credential_id`,label:e.$t(`usage.field.credential`),width:`200px`,"class-name":`text-center`},{default:g(n=>[t(`span`,ze,r(e.getCredentialLabel(n.row)),1),n.row.credential?.id||n.row.credential_id?(w(),o(`span`,Be,[i(z,{content:n.row.credential?.id||n.row.credential_id,class:`inline-block`},null,8,[`content`])])):a(``,!0)]),_:1},8,[`label`]),i(F,{label:e.$t(`usage.field.createdAt`),width:`200px`},{default:g(n=>[t(`span`,Ve,r(e.$dayjs.format(n.row.created_at)),1)]),_:1},8,[`label`])]),_:1},8,[`data`,`empty-text`])),[[W,e.loading]]):a(``,!0),e.type===e.serviceType.Proxy?f((w(),m(I,{key:1,data:e.proxyUsages,stripe:``,"table-layout":`fixed`,"empty-text":e.$t(`common.message.noData`),class:`min-h-[calc(100vh-350px)] mb-5`},{default:g(()=>[i(F,{label:e.$t(`application.field.name`),width:`160px`},{default:g(e=>[t(`span`,null,r(e.row?.service?.title),1)]),_:1},8,[`label`]),i(F,{prop:`remaining_amount`,label:e.$t(`usage.field.remainingAmount`),width:`160px`,"class-name":`text-center`},{default:g(n=>[t(`span`,null,r(e.getRemainingAmount(n.row)),1),t(`span`,null,r(e.getOriginalAmount(n.row)),1)]),_:1},8,[`label`]),i(F,{prop:`deducted_amount`,label:e.$t(`usage.field.deductedAmount`),width:`150px`,"class-name":`text-center`},{default:g(n=>[t(`span`,null,r(e.getDeductedAmount(n.row)),1)]),_:1},8,[`label`]),i(F,{label:e.$t(`usage.field.balanceAfter`),width:`160px`,"class-name":`text-center`},{default:g(n=>[t(`span`,null,r(e.getRemainingAmount(n.row)),1)]),_:1},8,[`label`]),i(F,{prop:`metadata`,label:e.$t(`usage.field.metadata`),width:`200px`,"class-name":`text-center`},{default:g(e=>[(w(!0),o(s,null,x(e.row.metadata,(e,t)=>(w(),m(R,{key:t,class:`mb-2`},{default:g(()=>[n(r(t)+`: `+r(e),1)]),_:2},1024))),128))]),_:1},8,[`label`]),i(F,{prop:`credential_id`,label:e.$t(`usage.field.credential`),width:`200px`,"class-name":`text-center`},{default:g(n=>[t(`span`,$,r(e.getCredentialLabel(n.row)),1),n.row.credential?.id||n.row.credential_id?(w(),o(`span`,He,[i(z,{content:n.row.credential?.id||n.row.credential_id,class:`inline-block`},null,8,[`content`])])):a(``,!0)]),_:1},8,[`label`]),i(F,{label:e.$t(`usage.field.createdAt`),width:`200px`},{default:g(n=>[t(`span`,Ue,r(e.$dayjs.format(n.row.created_at)),1)]),_:1},8,[`label`])]),_:1},8,[`data`,`empty-text`])),[[W,e.loading]]):a(``,!0)]),_:1})]),_:1})]),_:1}),i(H,{modelValue:e.detailDialogVisible,"onUpdate:modelValue":c[8]||=t=>e.detailDialogVisible=t,title:e.$t(`usage.dialog.detailTitle`),width:`70%`,top:`5vh`,"destroy-on-close":``},{default:g(()=>[i(V,{modelValue:e.detailActiveTab,"onUpdate:modelValue":c[7]||=t=>e.detailActiveTab=t},{default:g(()=>[i(B,{label:e.$t(`usage.dialog.request`),name:`request`},{default:g(()=>[e.detailLoading?(w(),m(D,{key:0,rows:6,animated:``})):e.detailRow?.metadata?.request?(w(),o(`pre`,We,r(e.formatJson(e.detailRow.metadata.request)),1)):(w(),o(`p`,Ge,r(e.$t(`usage.dialog.noData`)),1))]),_:1},8,[`label`]),i(B,{label:e.$t(`usage.dialog.response`),name:`response`},{default:g(()=>[e.detailLoading?(w(),m(D,{key:0,rows:6,animated:``})):e.detailRow?.metadata?.response?(w(),o(`pre`,Ke,r(e.formatJson(e.detailRow.metadata.response)),1)):(w(),o(`p`,qe,r(e.$t(`usage.dialog.noData`)),1))]),_:1},8,[`label`])]),_:1},8,[`modelValue`])]),_:1},8,[`modelValue`,`title`]),i(v,null,{default:g(()=>[i(_,{span:10,offset:14},{default:g(()=>[t(`div`,Je,[i(U,{"current-page":e.page,"page-size":e.limit,total:e.total,onChange:e.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var Xe=ne(ge,[[`render`,Ye],[`__scopeId`,`data-v-7028d194`]]);export{Xe as default};
|
|
1
|
+
import{o as e}from"./rolldown-runtime--c01j_DQ.js";import{A as t,I as n,Jt as r,L as i,M as a,N as o,T as s,a as c,at as l,c as u,d,ht as f,i as p,j as m,l as h,mt as g,n as _,o as v,ot as ee,qt as y,r as b,rt as x,s as S,t as C,tt as w,u as T,x as te,z as E}from"./vendor-chart-Dw-P17PN.js";import{r as D,t as O}from"./select-CBKmbQKx.js";import{n as k,t as A}from"./table-BtJ_S4l0.js";import{n as j,t as M}from"./tabs-Bixsf1GB.js";import{t as N}from"./card-D-4S-l7a.js";import{n as P,r as F}from"./radio-Bj0tEwH8.js";import{t as I}from"./date-picker-BcJ2Wsoq.js";import{n as L,t as R}from"./row-H2IpqPLs.js";import{t as z}from"./empty-xCRn_5sX.js";import{t as B}from"./pagination-BspbxLLu.js";import{n as V,t as H}from"./skeleton-CoheJz5x.js";import{t as U}from"./switch-CUBX5SGb.js";import{Cr as W,G as ne,Ii as re,Oi as ie,Pi as ae,Ti as G,hr as K,li as q,mi as J,mr as Y,ni as X,pr as oe,ti as se,yr as ce}from"./index-BO8KoMTB.js";import{t as le}from"./index.es-DWWSJOOT.js";import{t as ue}from"./CopyToClipboard-B1VphMUw.js";var de=e(W());v.register(c,u,p,b,S,T,d,h);var Z=[`#5B8FF9`,`#5AD8A6`,`#5D7092`,`#F6BD16`,`#6F5EF9`,`#6DC8EC`,`#945FB9`,`#FF9845`,`#1E9493`,`#FF99C3`],Q=`#C0C4CC`,fe=.01,pe=20;function me(e){return e<=Z.length?Z.slice(0,e):Array.from({length:e},(t,n)=>`hsl(${Math.round(n*360/e)}, 62%, ${n%2==0?55:45}%)`)}var he=15e3,ge=E({name:`ConsoleUsageList`,components:{Pagination:B,ElTag:ae,ElDatePicker:I,ElTable:A,ElSelect:D,ElOption:O,CopyToClipboard:ue,ElRow:R,ElCol:L,ElTableColumn:k,ElCard:N,ElRadioButton:P,ElRadioGroup:F,ElSkeleton:H,ElSkeletonItem:V,ElDialog:ie,ElTabs:j,ElTabPane:M,ElButton:re,ElEmpty:z,ElSwitch:U,FontAwesomeIcon:le,BarChart:C,DoughnutChart:_},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:se,serviceType:X,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()||X.API,loading:!1,total:void 0,limit:15,totalUsed:0,barChartLabels:[],barChartSeries:[],chartView:`trend`,apiBreakdown:[],pieLabels:[],pieData:[],pieColors:[],aggLoading:!1,detailDialogVisible:!1,detailRow:null,detailActiveTab:`request`,detailLoading:!1,exporting:!1,statusCodeFilter:this.$route.query.status_code?.toString()||``,traceId:this.$route.query.trace_id?.toString()||``,statusCodeOptions:[],statusCodeOptionsLoading:!1,autoRefresh:!0,autoRefreshTimer:null,fetchSeq:0}},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,maxBarThickness:36,borderRadius:2,borderSkipped:!1}))}},barChartOptions(){let e=e=>new Intl.NumberFormat().format(Math.round(((e||0)+2**-52)*100)/100);return{responsive:!0,maintainAspectRatio:!1,interaction:{mode:`index`,intersect:!1},plugins:{legend:{position:`bottom`,labels:{usePointStyle:!0,pointStyle:`circle`,boxWidth:8,boxHeight:8,padding:14},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:!1},tooltip:{itemSort:(e,t)=>(t.parsed?.y||0)-(e.parsed?.y||0),callbacks:{label:t=>` ${t.dataset.label}: ${e(t.parsed.y)}`,footer:t=>`${this.$t(`usage.title.totalUsed`)}: ${e(t.reduce((e,t)=>e+(t.parsed?.y||0),0))}`}}},scales:{x:{stacked:!0,grid:{display:!1},ticks:{maxRotation:0,autoSkip:!0,autoSkipPadding:16}},y:{stacked:!0,beginAtZero:!0,border:{display:!1},grid:{color:`rgba(128, 128, 128, 0.15)`},ticks:{callback:t=>e(Number(t))}}}}},doughnutChartData(){return{labels:this.pieLabels,datasets:[{data:this.pieData,backgroundColor:this.pieColors,borderWidth:0,hoverOffset:6}]}},doughnutChartOptions(){let e=e=>this.fmtAmount(e),t=this.pieData.reduce((e,t)=>e+(t||0),0);return{responsive:!0,maintainAspectRatio:!1,cutout:`58%`,plugins:{legend:{position:`right`,labels:{usePointStyle:!0,pointStyle:`circle`,boxWidth:8,boxHeight:8,padding:12}},title:{display:!1},tooltip:{callbacks:{label:n=>{let r=n.parsed||0,i=t>0?(r/t*100).toFixed(1):`0`;return` ${n.label}: ${e(r)} (${i}%)`}}}}}}},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()}},autoRefresh:{handler(e){e?this.startAutoRefresh():this.stopAutoRefresh()}}},mounted(){this.onFetchApplications(),this.onFetchApis(),this.onFetchUsages(),this.onFetchAggregate(),this.onFetchStatusCodeOptions(),this.autoRefresh&&this.startAutoRefresh()},beforeUnmount(){this.stopAutoRefresh()},methods:{async onFetchUsages(e=!1){this.type===X.API?this.onFetchApiUsages(e):this.type===X.Proxy&&this.onFetchProxyUsages(e)},startAutoRefresh(){this.stopAutoRefresh(),this.autoRefreshTimer=window.setInterval(()=>{document.hidden||this.onFetchUsages(!0)},he)},stopAutoRefresh(){this.autoRefreshTimer!==null&&(clearInterval(this.autoRefreshTimer),this.autoRefreshTimer=null)},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(){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 Y.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},getCredentialLabel(e){return e.credential?.name?.trim()||e.credential?.id||e.credential_id||`-`},onShowDetail(e){this.detailRow={...e,metadata:void 0},this.detailActiveTab=`request`,this.detailDialogVisible=!0,this.detailLoading=!0,e.id&&Y.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(){ce.getAll({limit:100,offset:0,user_id:this.$store.getters.user.id,ordering:`-created_at`,type:q.USAGE}).then(({data:e})=>{this.applications=e.items.filter(e=>e?.service?.type===this.type)}).catch(()=>{})},onFetchApis(){this.apisLoading=!0,oe.getAll({limit:1e3,offset:0,ordering:`-created_at`}).then(({data:e})=>{this.apis=e.items}).catch(()=>{}).finally(()=>{this.apisLoading=!1})},onFetchApiUsages(e=!1){e||(this.loading=!0);let t=++this.fetchSeq;Y.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}:{},...this.traceId?{trace_id:this.traceId}:{}}).then(({data:e})=>{t===this.fetchSeq&&(this.apiUsages=e.items,this.total=e.count)}).catch(()=>{}).finally(()=>{e||(this.loading=!1)})},onFetchProxyUsages(e=!1){e||(this.loading=!0);let t=++this.fetchSeq;K.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})=>{t===this.fetchSeq&&(this.proxyUsages=e.items,this.total=e.count)}).catch(()=>{}).finally(()=>{e||(this.loading=!1)})},async onExport(){let e=this.$store.state.token?.access;if(!e){G.error(this.$t(`usage.message.exportFailed`));return}let t={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}:{}},n=`${J()}/api/v1/usage/apis/export/?${de.default.stringify(t,{arrayFormat:`repeat`})}`,r=null,i=window.showSaveFilePicker;if(typeof i==`function`)try{r=await i({suggestedName:`usages.csv`,types:[{description:`CSV`,accept:{"text/csv":[`.csv`]}}]})}catch(e){if(e?.name===`AbortError`)return;r=null}this.exporting=!0;try{let t=await fetch(n,{headers:{authorization:`Bearer ${e}`}});if(!t.ok||!t.body)throw Error(`export failed: ${t.status}`);if(r)await t.body.pipeTo(await r.createWritable());else{let e=await t.blob(),n=window.URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=`usages.csv`,r.click(),window.URL.revokeObjectURL(n)}}catch{G.error(this.$t(`usage.message.exportFailed`))}finally{this.exporting=!1}},fmtAmount(e){return new Intl.NumberFormat().format(Math.round(((e||0)+2**-52)*100)/100)},async onFetchAggregate(){if(this.type!==this.serviceType.API)return;this.aggLoading=!0;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]}:{},timezone:Intl.DateTimeFormat().resolvedOptions().timeZone};try{let{data:t}=await Y.getAggregate(e);this.totalUsed=t.total||0;let n=Array.from(new Set((t.items||[]).map(e=>e.date))).sort(),r={},i={};(t.items||[]).forEach(e=>{let t=e.amount||0;(r[e.date]||(r[e.date]={}))[e.api_id]=(r[e.date]?.[e.api_id]||0)+t,i[e.api_id]=(i[e.api_id]||0)+t});let a=Object.keys(i).sort((e,t)=>i[t]-i[e]),o=a.reduce((e,t)=>e+i[t],0),s=a.length;if(o>0){let e=o*(1-fe),t=0;for(let n=0;n<a.length;n++)if(t+=i[a[n]],t>=e){s=n+1;break}s=Math.min(s,pe)}a.length-s===1&&(s=a.length);let c=a.slice(0,s),l=new Set(c),u=me(c.length),d=a.slice(s),f=`${this.$t(`usage.value.others`)} (${d.length})`,p=c.map((e,i)=>({key:e,label:t.apis?.[e]?.title||e,data:n.map(t=>r[t]?.[e]||0),color:u[i]}));if(d.length){let e=n.map(e=>Object.entries(r[e]||{}).reduce((e,[t,n])=>l.has(t)?e:e+n,0));e.some(e=>e>0)&&p.push({key:`__others__`,label:f,data:e,color:Q})}this.apiBreakdown=a.map((e,n)=>({key:e,label:t.apis?.[e]?.title||e,amount:i[e],color:n<c.length?u[n]:Q,share:o>0?i[e]/o:0}));let m=[],h=[],g=[];c.forEach((e,n)=>{m.push(t.apis?.[e]?.title||e),h.push(i[e]),g.push(u[n])});let _=d.reduce((e,t)=>e+i[t],0);_>0&&(m.push(f),h.push(_),g.push(Q)),this.pieLabels=m,this.pieData=h,this.pieColors=g,this.barChartLabels=n,this.barChartSeries=p}finally{this.aggLoading=!1}}}}),_e={class:`text-[26px] font-bold mb-5 text-[var(--el-text-color-primary)]`},ve={class:`inline-block w-9`},ye={class:`inline-block`},be={key:1,class:`summary-card`},xe={class:`icon-wrapper`},Se={class:`text-left`},Ce={class:`description`},we={class:`value`},Te={class:`flex flex-wrap items-center justify-between gap-2`},Ee={class:`text-[15px] font-medium text-[var(--el-text-color-primary)]`},De={class:`chart-wrapper`},Oe={class:`share-cell`},ke={class:`share-bar`},Ae={class:`share-pct`},je={class:`flex items-center justify-end gap-2 mb-4`},Me={class:`text-sm text-[var(--el-text-color-regular)]`},Ne={key:0},Pe={key:0},Fe={key:1},Ie={class:`flex flex-wrap gap-2`},Le={class:`key`},Re={key:0,class:`cursor-pointer`},ze={class:`key`},Be={key:0,class:`cursor-pointer`},Ve={class:`created-at`},$={class:`key`},He={key:0,class:`cursor-pointer`},Ue={class:`created-at`},We={key:1,class:`detail-json`},Ge={key:2,class:`text-gray-400`},Ke={key:1,class:`detail-json`},qe={key:2,class:`text-gray-400`},Je={class:`float-right`};function Ye(e,c,u,d,p,h){let _=l(`el-col`),v=l(`el-row`),b=l(`el-radio-button`),S=l(`el-radio-group`),C=l(`el-option`),T=l(`el-select`),E=l(`el-skeleton-item`),D=l(`el-skeleton`),O=l(`el-date-picker`),k=l(`font-awesome-icon`),A=l(`el-button`),j=l(`el-card`),M=l(`bar-chart`),N=l(`el-empty`),P=l(`doughnut-chart`),F=l(`el-table-column`),I=l(`el-table`),L=l(`el-switch`),R=l(`el-tag`),z=l(`copy-to-clipboard`),B=l(`el-tab-pane`),V=l(`el-tabs`),H=l(`el-dialog`),U=l(`pagination`),W=ee(`loading`);return w(),m(v,null,{default:g(()=>[i(_,{span:24},{default:g(()=>[i(v,null,{default:g(()=>[i(_,{span:24},{default:g(()=>[t(`h2`,_e,r(e.$t(`common.title.allUsages`)),1)]),_:1})]),_:1}),i(v,null,{default:g(()=>[i(_,{md:4,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:g(()=>[t(`span`,null,r(e.$t(`application.field.type`)),1),i(S,{modelValue:e.type,"onUpdate:modelValue":c[0]||=t=>e.type=t},{default:g(()=>[i(b,{value:e.serviceType.API,label:e.$t(`application.field.api`)},null,8,[`value`,`label`]),i(b,{value:e.serviceType.Proxy,label:e.$t(`application.field.proxy`)},null,8,[`value`,`label`])]),_:1},8,[`modelValue`])]),_:1}),f(i(_,{md:6,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:g(()=>[t(`span`,ve,r(e.$t(`usage.field.application`)),1),i(T,{modelValue:e.applicationIds,"onUpdate:modelValue":c[1]||=t=>e.applicationIds=t,placeholder:e.$t(`usage.field.application`),clearable:``,multiple:``,"collapse-tags":``,"collapse-tags-tooltip":``,class:`w-full`,onChange:e.onApplicationsChange},{default:g(()=>[(w(!0),o(s,null,x(e.applications,e=>(w(),m(C,{key:e.id,label:e.service?.title,value:e?.id},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`])]),_:1},512),[[te,!1]]),e.type===e.serviceType.API?(w(),m(_,{key:0,md:6,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:g(()=>[t(`span`,ye,r(e.$t(`usage.field.api`)),1),e.apisLoading?(w(),m(D,{key:0,animated:``,class:`w-full`},{template:g(()=>[i(E,{variant:`rect`,style:{height:`32px`,"border-radius":`4px`}})]),_:1})):(w(),m(T,{key:1,modelValue:e.apiIds,"onUpdate:modelValue":c[2]||=t=>e.apiIds=t,placeholder:e.$t(`usage.field.api`),clearable:``,filterable:``,multiple:``,"collapse-tags":``,"collapse-tags-tooltip":``,class:`w-full`,onChange:e.onApisChange},{default:g(()=>[(w(!0),o(s,null,x(e.apis,e=>(w(),m(C,{key:e?.id,label:e?.title,value:e?.id},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]))]),_:1})):a(``,!0),e.type===e.serviceType.API?(w(),m(_,{key:1,md:8,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:g(()=>[i(O,{modelValue:e.createdAtRange,"onUpdate:modelValue":c[3]||=t=>e.createdAtRange=t,type:`datetimerange`,class:`w-full`,shortcuts:e.shortcuts,"range-separator":e.$t(`usage.placeholder.to`),"start-placeholder":e.$t(`usage.placeholder.startDate`),"end-placeholder":e.$t(`usage.placeholder.endDate`),onChange:e.onTimeRangeChanged},null,8,[`modelValue`,`shortcuts`,`range-separator`,`start-placeholder`,`end-placeholder`,`onChange`])]),_:1})):a(``,!0),e.type===e.serviceType.API?(w(),m(_,{key:2,md:3,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:g(()=>[i(T,{modelValue:e.statusCodeFilter,"onUpdate:modelValue":c[4]||=t=>e.statusCodeFilter=t,placeholder:e.$t(`usage.option.statusCodeAll`),class:`w-full`,clearable:``,filterable:``,"allow-create":``,"default-first-option":``,loading:e.statusCodeOptionsLoading,onChange:e.onStatusCodeChange},{default:g(()=>[(w(!0),o(s,null,x(e.statusCodeOptions,e=>(w(),m(C,{key:e,label:String(e),value:String(e)},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`loading`,`onChange`])]),_:1})):a(``,!0),e.type===e.serviceType.API?(w(),m(_,{key:3,md:3,xs:24,class:`mb-5 flex px-2 gap-2 items-center justify-end`},{default:g(()=>[i(A,{type:`primary`,plain:``,loading:e.exporting,class:`w-full whitespace-nowrap`,onClick:e.onExport},{default:g(()=>[i(k,{icon:`fa-solid fa-file-export`,class:`mr-1`}),n(` `+r(e.$t(`usage.button.export`)),1)]),_:1},8,[`loading`,`onClick`])]),_:1})):a(``,!0)]),_:1}),i(v,null,{default:g(()=>[i(_,{span:24},{default:g(()=>[e.type===e.serviceType.API?(w(),m(v,{key:0,gutter:24,class:`mb-5`},{default:g(()=>[i(_,{md:6,xs:24},{default:g(()=>[i(j,{shadow:`hover`,class:`h-full`},{default:g(()=>[e.aggLoading?(w(),m(D,{key:0})):(w(),o(`div`,be,[t(`div`,xe,[i(k,{icon:`fa-solid fa-cubes`,class:`icon`})]),t(`div`,Se,[t(`p`,Ce,r(e.$t(`usage.title.totalUsed`)),1),t(`p`,we,r(e.totalUsedString),1)])]))]),_:1})]),_:1}),i(_,{md:18,xs:24},{default:g(()=>[i(j,{shadow:`hover`,class:`h-full`},{header:g(()=>[t(`div`,Te,[t(`span`,Ee,r(e.$t(`usage.title.usageAnalytics`)),1),i(S,{modelValue:e.chartView,"onUpdate:modelValue":c[5]||=t=>e.chartView=t,size:`small`},{default:g(()=>[i(b,{value:`trend`,label:e.$t(`usage.view.trend`)},null,8,[`label`]),i(b,{value:`distribution`,label:e.$t(`usage.view.distribution`)},null,8,[`label`]),i(b,{value:`breakdown`,label:e.$t(`usage.view.breakdown`)},null,8,[`label`])]),_:1},8,[`modelValue`])])]),default:g(()=>[t(`div`,De,[e.aggLoading?(w(),m(D,{key:0,class:`w-full`})):e.chartView===`trend`?(w(),o(s,{key:1},[e.barChartSeries.length?(w(),m(M,{key:0,data:e.barChartData,options:e.barChartOptions,class:`chart`},null,8,[`data`,`options`])):(w(),m(N,{key:1,description:e.$t(`common.message.noData`),"image-size":70,class:`w-full`},null,8,[`description`]))],64)):e.chartView===`distribution`?(w(),o(s,{key:2},[e.pieData.length?(w(),m(P,{key:0,data:e.doughnutChartData,options:e.doughnutChartOptions,class:`chart`},null,8,[`data`,`options`])):(w(),m(N,{key:1,description:e.$t(`common.message.noData`),"image-size":70,class:`w-full`},null,8,[`description`]))],64)):(w(),o(s,{key:3},[e.apiBreakdown.length?(w(),m(I,{key:0,data:e.apiBreakdown,size:`small`,height:`300`,class:`w-full`},{default:g(()=>[i(F,{label:e.$t(`usage.field.api`),"min-width":`160`},{default:g(e=>[t(`span`,{class:`color-dot`,style:y({backgroundColor:e.row.color})},null,4),t(`span`,null,r(e.row.label),1)]),_:1},8,[`label`]),i(F,{label:e.$t(`usage.field.consumed`),width:`120`,align:`right`},{default:g(n=>[t(`span`,null,r(e.fmtAmount(n.row.amount)),1)]),_:1},8,[`label`]),i(F,{label:e.$t(`usage.field.share`),width:`150`},{default:g(e=>[t(`div`,Oe,[t(`div`,ke,[t(`div`,{class:`share-bar-fill`,style:y({width:e.row.share*100+`%`,backgroundColor:e.row.color})},null,4)]),t(`span`,Ae,r((e.row.share*100).toFixed(1))+`%`,1)])]),_:1},8,[`label`])]),_:1},8,[`data`])):(w(),m(N,{key:1,description:e.$t(`common.message.noData`),"image-size":70,class:`w-full`},null,8,[`description`]))],64))])]),_:1})]),_:1})]),_:1})):a(``,!0),i(j,{shadow:`hover`},{default:g(()=>[t(`div`,je,[t(`span`,Me,r(e.$t(`usage.field.autoRefresh`)),1),i(L,{modelValue:e.autoRefresh,"onUpdate:modelValue":c[6]||=t=>e.autoRefresh=t},null,8,[`modelValue`])]),e.type===e.serviceType.API?f((w(),m(I,{key:0,data:e.apiUsages,stripe:``,"table-layout":`fixed`,"empty-text":e.$t(`common.message.noData`),class:`min-h-[calc(100vh-350px)] mb-5`},{default:g(()=>[i(F,{label:e.$t(`application.field.name`),width:`160px`},{default:g(e=>[t(`span`,null,r(e.row?.api?.title),1)]),_:1},8,[`label`]),i(F,{label:e.$t(`usage.field.statusCode`),width:`120px`},{default:g(t=>[t.row.status_code?(w(),o(`span`,Ne,r(t.row.status_code),1)):(w(),m(R,{key:1,type:`warning`,size:`small`},{default:g(()=>[n(r(e.$t(`usage.value.processing`)),1)]),_:1}))]),_:1},8,[`label`]),i(F,{label:e.$t(`usage.field.elapsed`),width:`120px`},{default:g(n=>[t(`span`,null,r(e.formatElapsed(n.row.elapsed)),1)]),_:1},8,[`label`]),i(F,{prop:`deducted_amount`,label:e.$t(`usage.field.deductedAmount`),width:`150px`,"class-name":`text-center`},{default:g(n=>[e.getDeductedAmount(n.row)===e.getOriginalAmount(n.row)?(w(),o(`div`,Pe,[t(`span`,null,r(e.getDeductedAmount(n.row)),1)])):(w(),o(`div`,Fe,[c[9]||=t(`p`,null,null,-1),t(`p`,null,[t(`span`,null,r(e.getDeductedAmount(n.row)),1)]),t(`p`,null,[t(`del`,null,r(e.getOriginalAmount(n.row)),1)])]))]),_:1},8,[`label`]),i(F,{prop:`remaining_amount`,label:e.$t(`usage.field.balanceAfter`),width:`160px`,"class-name":`text-center`},{default:g(n=>[t(`span`,null,r(e.getRemainingAmount(n.row)),1)]),_:1},8,[`label`]),i(F,{prop:`metadata`,label:e.$t(`usage.field.metadata`),width:`260px`,"class-name":`text-center`},{default:g(i=>[t(`div`,Ie,[i.row.original_amount>i.row.deducted_amount&&i.row.original_amount>0?(w(),m(R,{key:0,type:`success`,style:{textWrap:`wrap`,height:`fit-content`,lineHeight:`20px`,borderRadius:`10px`}},{default:g(()=>[n(r(((i.row.original_amount-i.row.deducted_amount)*100/i.row.original_amount).toFixed(0)+`% OFF`),1)]),_:2},1024)):a(``,!0),(w(!0),o(s,null,x(e.getSimpleMetadata(i.row.metadata),(e,t)=>(w(),m(R,{key:t,style:{textWrap:`wrap`,height:`fit-content`,lineHeight:`20px`,borderRadius:`10px`}},{default:g(()=>[n(r(t)+`: `+r(e),1)]),_:2},1024))),128))])]),_:1},8,[`label`]),i(F,{label:e.$t(`usage.button.viewDetail`),width:`120px`,"class-name":`text-center`},{default:g(t=>[t.row.id?(w(),m(A,{key:0,type:`primary`,plain:``,size:`small`,class:`!px-2 !py-1 !text-xs !h-auto !min-h-0`,onClick:n=>e.onShowDetail(t.row)},{default:g(()=>[n(r(e.$t(`usage.button.viewDetail`)),1)]),_:1},8,[`onClick`])):a(``,!0)]),_:1},8,[`label`]),i(F,{prop:`trace_id`,label:e.$t(`application.field.traceId`),width:`200px`,"class-name":`text-center`},{default:g(e=>[t(`span`,Le,r(e.row.trace_id),1),e.row.trace_id?(w(),o(`span`,Re,[i(z,{content:e.row.trace_id,class:`inline-block`},null,8,[`content`])])):a(``,!0)]),_:1},8,[`label`]),i(F,{prop:`credential_id`,label:e.$t(`usage.field.credential`),width:`200px`,"class-name":`text-center`},{default:g(n=>[t(`span`,ze,r(e.getCredentialLabel(n.row)),1),n.row.credential?.id||n.row.credential_id?(w(),o(`span`,Be,[i(z,{content:n.row.credential?.id||n.row.credential_id,class:`inline-block`},null,8,[`content`])])):a(``,!0)]),_:1},8,[`label`]),i(F,{label:e.$t(`usage.field.createdAt`),width:`200px`},{default:g(n=>[t(`span`,Ve,r(e.$dayjs.format(n.row.created_at)),1)]),_:1},8,[`label`])]),_:1},8,[`data`,`empty-text`])),[[W,e.loading]]):a(``,!0),e.type===e.serviceType.Proxy?f((w(),m(I,{key:1,data:e.proxyUsages,stripe:``,"table-layout":`fixed`,"empty-text":e.$t(`common.message.noData`),class:`min-h-[calc(100vh-350px)] mb-5`},{default:g(()=>[i(F,{label:e.$t(`application.field.name`),width:`160px`},{default:g(e=>[t(`span`,null,r(e.row?.service?.title),1)]),_:1},8,[`label`]),i(F,{prop:`remaining_amount`,label:e.$t(`usage.field.remainingAmount`),width:`160px`,"class-name":`text-center`},{default:g(n=>[t(`span`,null,r(e.getRemainingAmount(n.row)),1),t(`span`,null,r(e.getOriginalAmount(n.row)),1)]),_:1},8,[`label`]),i(F,{prop:`deducted_amount`,label:e.$t(`usage.field.deductedAmount`),width:`150px`,"class-name":`text-center`},{default:g(n=>[t(`span`,null,r(e.getDeductedAmount(n.row)),1)]),_:1},8,[`label`]),i(F,{label:e.$t(`usage.field.balanceAfter`),width:`160px`,"class-name":`text-center`},{default:g(n=>[t(`span`,null,r(e.getRemainingAmount(n.row)),1)]),_:1},8,[`label`]),i(F,{prop:`metadata`,label:e.$t(`usage.field.metadata`),width:`200px`,"class-name":`text-center`},{default:g(e=>[(w(!0),o(s,null,x(e.row.metadata,(e,t)=>(w(),m(R,{key:t,class:`mb-2`},{default:g(()=>[n(r(t)+`: `+r(e),1)]),_:2},1024))),128))]),_:1},8,[`label`]),i(F,{prop:`credential_id`,label:e.$t(`usage.field.credential`),width:`200px`,"class-name":`text-center`},{default:g(n=>[t(`span`,$,r(e.getCredentialLabel(n.row)),1),n.row.credential?.id||n.row.credential_id?(w(),o(`span`,He,[i(z,{content:n.row.credential?.id||n.row.credential_id,class:`inline-block`},null,8,[`content`])])):a(``,!0)]),_:1},8,[`label`]),i(F,{label:e.$t(`usage.field.createdAt`),width:`200px`},{default:g(n=>[t(`span`,Ue,r(e.$dayjs.format(n.row.created_at)),1)]),_:1},8,[`label`])]),_:1},8,[`data`,`empty-text`])),[[W,e.loading]]):a(``,!0)]),_:1})]),_:1})]),_:1}),i(H,{modelValue:e.detailDialogVisible,"onUpdate:modelValue":c[8]||=t=>e.detailDialogVisible=t,title:e.$t(`usage.dialog.detailTitle`),width:`70%`,top:`5vh`,"destroy-on-close":``},{default:g(()=>[i(V,{modelValue:e.detailActiveTab,"onUpdate:modelValue":c[7]||=t=>e.detailActiveTab=t},{default:g(()=>[i(B,{label:e.$t(`usage.dialog.request`),name:`request`},{default:g(()=>[e.detailLoading?(w(),m(D,{key:0,rows:6,animated:``})):e.detailRow?.metadata?.request?(w(),o(`pre`,We,r(e.formatJson(e.detailRow.metadata.request)),1)):(w(),o(`p`,Ge,r(e.$t(`usage.dialog.noData`)),1))]),_:1},8,[`label`]),i(B,{label:e.$t(`usage.dialog.response`),name:`response`},{default:g(()=>[e.detailLoading?(w(),m(D,{key:0,rows:6,animated:``})):e.detailRow?.metadata?.response?(w(),o(`pre`,Ke,r(e.formatJson(e.detailRow.metadata.response)),1)):(w(),o(`p`,qe,r(e.$t(`usage.dialog.noData`)),1))]),_:1},8,[`label`])]),_:1},8,[`modelValue`])]),_:1},8,[`modelValue`,`title`]),i(v,null,{default:g(()=>[i(_,{span:10,offset:14},{default:g(()=>[t(`div`,Je,[i(U,{"current-page":e.page,"page-size":e.limit,total:e.total,onChange:e.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var Xe=ne(ge,[[`render`,Ye],[`__scopeId`,`data-v-7028d194`]]);export{Xe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as e,Jt as t,L as n,N as r,at as i,tt as a,z as o}from"./vendor-chart-Dw-P17PN.js";import{G as s}from"./index-
|
|
1
|
+
import{A as e,Jt as t,L as n,N as r,at as i,tt as a,z as o}from"./vendor-chart-Dw-P17PN.js";import{G as s}from"./index-BO8KoMTB.js";import{t as c}from"./LocalTools-DMXyjh59.js";var l=o({name:`SettingsLocalTools`,components:{LocalToolsSetting:c}}),u={class:`local-tools-page`};function d(o,s,c,l,d,f){let p=i(`local-tools-setting`);return a(),r(`div`,u,[e(`h2`,null,t(o.$t(`common.settings.localTools`)),1),n(p)])}var f=s(l,[[`render`,d],[`__scopeId`,`data-v-ac732814`]]);export{f as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime--c01j_DQ.js";import{A as t,I as n,Jt as r,L as i,M as a,N as o,T as s,at as c,j as l,mt as u,rt as d,tt as f,z as p}from"./vendor-chart-Dw-P17PN.js";import{H as ee}from"./use-deprecated-B-uvyrTL.js";import{t as m}from"./switch-
|
|
1
|
+
import{r as e}from"./rolldown-runtime--c01j_DQ.js";import{A as t,I as n,Jt as r,L as i,M as a,N as o,T as s,at as c,j as l,mt as u,rt as d,tt as f,z as p}from"./vendor-chart-Dw-P17PN.js";import{H as ee}from"./use-deprecated-B-uvyrTL.js";import{t as m}from"./switch-CUBX5SGb.js";import{G as te,Gi as ne,Ii as h,Pi as g,br as _,gi as v,pi as y,q as b}from"./index-BO8KoMTB.js";import{t as x}from"./index.es-DWWSJOOT.js";var S=p({name:`LocalToolsSetting`,components:{ElButton:h,ElTag:g,ElSwitch:m,ElInput:ne,FontAwesomeIcon:x},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,xhsSkill:null,xhsLoading:!1,xhsInstalling:!1,xhsError:``,onFocus:null,cuOff:null,a11yPoll:null,refreshingA11y:!1}},computed:{desktop(){return!!b()},android(){return v()},canInstallXhs(){return this.a11yEnabled&&this.computerUse}},async mounted(){let e=b();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.fetchXhsSkill(),this.onFocus=()=>{document.visibilityState===`visible`&&this.refreshA11y()},document.addEventListener(`visibilitychange`,this.onFocus),this.a11yPoll=window.setInterval(()=>{document.visibilityState===`visible`&&this.refreshA11y()},3e3)),this.cuOff=e.onComputerUseDisabled?.(()=>{this.computerUse=!1})??null},beforeUnmount(){this.cuOff?.(),this.onFocus&&document.removeEventListener(`visibilitychange`,this.onFocus),this.a11yPoll&&clearInterval(this.a11yPoll)},methods:{async refreshA11y(){if(!this.refreshingA11y){this.refreshingA11y=!0;try{let e=await b()?.perm?.status();this.a11yEnabled=e?.accessibility===!0}finally{this.refreshingA11y=!1}}},async openAndroidAccessibility(){await b()?.perm?.openPane(`accessibility`)},async fetchXhsSkill(){this.xhsLoading=!0,this.xhsError=``;try{let e=await _.get(`/skills/`,{baseURL:`${y()}/api/v1`,params:{q:`xhs-dm`,limit:10}}),t=Array.isArray(e.data?.items)?e.data.items:[];this.xhsSkill=t.find(e=>e.identifier?.endsWith(`/xhs-dm`))??null}catch(e){console.warn(`[LocalTools] fetch xhs skill failed`,e),this.xhsSkill=null,this.xhsError=this.$t(`common.settings.localToolsAndroidSkillsLoadFailed`)}finally{this.xhsLoading=!1}},async installXhs(){let e=this.xhsSkill;if(!(!e||e.installed)){this.xhsInstalling=!0,this.xhsError=``;try{await _.post(`/skills/${e.id}/install/`,{},{baseURL:`${y()}/api/v1`}),e.installed=!0}catch(t){t?.response?.status===409?e.installed=!0:this.xhsError=this.$t(`common.settings.localToolsAndroidSkillsInstallFailed`)}finally{this.xhsInstalling=!1}}},async loadGrants(){let e=b();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 b()?.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(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime--c01j_DQ.js";import{A as e,I as t,Jt as n,L as r,M as i,N as a,at as o,j as s,k as c,mt as l,tt as u,z as d}from"./vendor-chart-Dw-P17PN.js";import{t as f}from"./Navigator-
|
|
1
|
+
import"./rolldown-runtime--c01j_DQ.js";import{A as e,I as t,Jt as n,L as r,M as i,N as a,at as o,j as s,k as c,mt as l,tt as u,z as d}from"./vendor-chart-Dw-P17PN.js";import{t as f}from"./Navigator-DIqP0pBF.js";import{t as p}from"./checkbox-ChInsWN4.js";import{t as m}from"./divider-BNWJAaA2.js";import"./constants-B_ksgMZ4.js";import{G as h,Ii as g,Oi as _,Ti as v,an as y,ci as b,di as x,li as S,mi as C,yr as w}from"./index-BO8KoMTB.js";import{t as T}from"./Status-DmbaNjnQ.js";var E=d({name:`ApplicationConfirm`,components:{ElDialog:_,ElDivider:m,ElCheckbox:p,ElButton:g},props:{visible:{type:Boolean,required:!1,default:!1}},emits:[`update:visible`,`apply`],data(){return{checked:!0}},watch:{},methods:{getBaseUrlPlatform:C,onApply(){if(!this.checked){v.error(this.$t(`application.message.notAgreePolicy`));return}this.$emit(`apply`)}}}),D={class:`content py-[10px] px-[40px]`},O={class:`my-4`},k={class:`policy mb-[10px]`},A={class:`policy-title text-[12px] relative -bottom-[3px]`},j=[`href`];function M(i,a,c,d,f,p){let m=o(`el-divider`),h=o(`el-checkbox`),g=o(`el-button`),_=o(`el-dialog`);return u(),s(_,{"model-value":i.visible,width:`500px`,title:i.$t(`application.message.welcome`),center:``,onClose:a[1]||=e=>i.$emit(`update:visible`,!1)},{default:l(()=>[e(`div`,D,[e(`p`,O,n(i.$t(`application.message.notApplied`)),1),r(m,{class:`my-2`}),e(`div`,k,[r(h,{modelValue:i.checked,"onUpdate:modelValue":a[0]||=e=>i.checked=e,size:`large`,class:`policy-checkbox mr-[10px]`},null,8,[`modelValue`]),e(`span`,A,n(i.$t(`application.message.readPolicy`)),1),e(`a`,{class:`policy-title text-[12px] relative -bottom-[3px] text-[var(--el-color-primary)] cursor-pointer no-underline`,target:`_blank`,href:i.getBaseUrlPlatform()+`/terms`},` \xA0`+n(i.$t(`application.message.policy`)),9,j)]),r(g,{round:``,type:`primary`,onClick:i.onApply},{default:l(()=>[t(n(i.$t(`common.button.start`)),1)]),_:1},8,[`onClick`])])]),_:1},8,[`model-value`,`title`])}var N=h(E,[[`render`,M]]),P=15e3,F=d({name:`LayoutMain`,components:{Navigator:f,ApplicationStatus:T,ApplicationConfirm:N},provide(){return{initialized:c(()=>this.initialized)}},data(){return{initialized:!1,applying:!1,mobile:typeof window<`u`&&window.innerWidth<768,initializeRunId:0,balanceTimer:0}},computed:{appName(){return this.$route.meta.appName},application(){return this.$store.state[this.appName]?.application},applications(){let e=this.$store.state[this.appName]?.applications??[];console.debug(`individualApplications`,e);let t=this.$store.state.applications??[];return console.debug(`globalApplications`,t),t.concat(e)},loading(){return this.$store.state[this.appName]?.status?.getApplications===x.Request},service(){return this.$store.state[this.appName]?.service},userId(){return this.$store.state.user?.id}},watch:{appName(){this.initialize()},userId(e,t){e&&e!==t&&this.initialize()}},mounted(){this.initialize(),window.addEventListener(`resize`,this.onResize),this.balanceTimer=window.setInterval(this.refreshBalances,P),document.addEventListener(`visibilitychange`,this.onVisibility)},beforeUnmount(){window.removeEventListener(`resize`,this.onResize),window.clearInterval(this.balanceTimer),document.removeEventListener(`visibilitychange`,this.onVisibility)},methods:{onResize(){this.mobile=window.innerWidth<768},onVisibility(){typeof document<`u`&&!document.hidden&&this.refreshBalances()},async refreshBalances(){if(!this.appName||!this.$store.state.token?.access||typeof document<`u`&&document.hidden||this.loading)return;await Promise.allSettled([this.$store.dispatch(`getApplications`),this.$store.dispatch(`${this.appName}/getApplications`)]);let e=this.$store.state[this.appName]?.application;if(!e)return;let t=this.applications?.find(t=>t.id===e.id);t&&t!==e&&this.$store.commit(`${this.appName}/setApplication`,t)},async initialize(){let e=++this.initializeRunId;if(this.initialized=!1,!this.$store.state.token?.access||(console.debug(`Fetching all individual and global applications for`,this.appName),await Promise.allSettled([this.$store.dispatch(`getApplications`),this.$store.dispatch(`${this.appName}/getApplications`)]),e!==this.initializeRunId))return;console.debug(`Fetched all applications`,this.applications),this.$store.state.applications?.length===0&&await this.onAutoApply();let t=this.$store.state[this.appName]?.application;console.debug(`current application`,t);let n=y(this.applications,t);console.debug(`final application`,n),n&&(console.debug(`set final application`,n,n?.type),await this.$store.dispatch(`${this.appName}/setApplication`,n)),console.debug(`finished initialization`),this.initialized=!0},onApply(){this.onAutoApply()},async onAutoApply(){try{await w.create({type:S.USAGE,scope:b.GLOBAL,user_id:this.$store.getters.user.id}),this.applying=!1,await this.$store.dispatch(`getApplications`),this.showWelcomeToast()}catch(e){e?.response?.data?.code===`duplication`?await this.$store.dispatch(`getApplications`):v.error(this.$t(`application.message.applyFailed`))}},showWelcomeToast(){let e=this.$store.state.applications?.[0],t=Math.floor(e?.remaining_amount??0),n=this.$store.state.site?.title||`AceData`;v({message:t>0?this.$t(`application.message.welcomeWithCredits`,{credits:t,brand:n}):this.$t(`application.message.welcomeNoCredits`,{brand:n}),type:`success`,duration:6e3,showClose:!0})}}}),I={class:`wrapper`};function L(e,t,n,c,l,d){let f=o(`router-view`),p=o(`navigator`),m=o(`application-status`),h=o(`application-confirm`);return u(),a(`div`,I,[r(f,{class:`main`}),r(p,{class:`navigator`,direction:e.mobile?`row`:`column`},null,8,[`direction`]),e.application?(u(),s(m,{key:0,class:`status-floating fixed right-2 z-[200]`,application:e.application,applications:e.applications,"show-price":!1,authenticated:!!e.$store.state.token.access,service:e.service,onSelect:t[0]||=t=>e.$store.dispatch(`${e.appName}/setApplication`,t)},null,8,[`application`,`applications`,`authenticated`,`service`])):i(``,!0),r(h,{modelValue:e.applying,"onUpdate:modelValue":t[1]||=t=>e.applying=t,modelModifiers:{visible:!0},onApply:e.onApply},null,8,[`modelValue`,`onApply`])])}var R=h(F,[[`render`,L],[`__scopeId`,`data-v-334ded1d`]]);export{R as default};
|