@acedatacloud/nexior 3.295.0 → 3.296.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.
Files changed (137) hide show
  1. package/dist/assets/{ApiCodeButton-Bj-n-MTw.js → ApiCodeButton-qIBprX29.js} +1 -1
  2. package/dist/assets/{AskUserQuestionCard-DDAIypKy.js → AskUserQuestionCard-3cyTzRZM.js} +1 -1
  3. package/dist/assets/{Auth-DUrmkBO0.js → Auth-IkrzcpF7.js} +1 -1
  4. package/dist/assets/{Bare-BlCBL-j1.js → Bare-BkwOOpvH.js} +1 -1
  5. package/dist/assets/{BotPlaceholder-B8PNfxso.js → BotPlaceholder-BklNrzaU.js} +1 -1
  6. package/dist/assets/{BottomFooter-CTXTehPB.js → BottomFooter-DM23gDpI.js} +1 -1
  7. package/dist/assets/{Callback-BuHkZii8.js → Callback-B62HusTd.js} +1 -1
  8. package/dist/assets/{CodeSnippet-zd4xvQ5d.js → CodeSnippet-BtkNcCu7.js} +1 -1
  9. package/dist/assets/{Console-KklTmjSn.js → Console-BT7Z1dCC.js} +1 -1
  10. package/dist/assets/{Consumption-tVV7hQ5u.js → Consumption-BwnLYvDF.js} +1 -1
  11. package/dist/assets/{Conversation-c6gkl-mV.js → Conversation-BXA4Ni6Y.js} +1 -1
  12. package/dist/assets/{CopyToClipboard-BM4VvfdY.js → CopyToClipboard-lWAkY_ey.js} +1 -1
  13. package/dist/assets/{Detail-COKoIaZ0.js → Detail-CnWkBvG0.js} +2 -2
  14. package/dist/assets/{Extra-Cs-tXS75.js → Extra-B0EW80OQ.js} +1 -1
  15. package/dist/assets/{FilePreview-DCsORpg5.js → FilePreview-Bl8NlHvA.js} +1 -1
  16. package/dist/assets/{Hailuo-esWUB2SE.js → Hailuo-HxDqMP2r.js} +1 -1
  17. package/dist/assets/{History-6laXCUhB.js → History-DAOIg2Qs.js} +1 -1
  18. package/dist/assets/{ImagePreview-Bni-DBAj.js → ImagePreview-CXfja4Qt.js} +1 -1
  19. package/dist/assets/{ImageWrapper-DgJElYpw.js → ImageWrapper-Bv1ZJFzC.js} +1 -1
  20. package/dist/assets/{Index-D0qcAsE7.js → Index-2t-5WvMO.js} +1 -1
  21. package/dist/assets/{Index-9o1RYvRQ.js → Index-9vfnpPPq.js} +1 -1
  22. package/dist/assets/{Index-nyrp1Apm.js → Index-B2PD2pU7.js} +1 -1
  23. package/dist/assets/{Index-DH5PqDlk.js → Index-B5LPCMmo.js} +1 -1
  24. package/dist/assets/{Index-C_10VMSb.js → Index-BCf4Qu1w.js} +1 -1
  25. package/dist/assets/{Index-BiUbHmQu.js → Index-BKPXlo56.js} +1 -1
  26. package/dist/assets/{Index-B_LKontL.js → Index-BRjQx632.js} +1 -1
  27. package/dist/assets/{Index-BW9be2mF.js → Index-BU2c2a-9.js} +1 -1
  28. package/dist/assets/{Index-CKkrMcI7.js → Index-Bf13S6UA.js} +1 -1
  29. package/dist/assets/{Index-DSHFr1hb.js → Index-Bk19clKc.js} +1 -1
  30. package/dist/assets/{Index-D-bKahrH.js → Index-BnMYjmCS.js} +1 -1
  31. package/dist/assets/{Index-DCyFZZFY.js → Index-Bs8_6Xpa.js} +1 -1
  32. package/dist/assets/{Index-D-zpGNxS.js → Index-Bt9dIpiJ.js} +1 -1
  33. package/dist/assets/{Index-Be3TxLHO.js → Index-CB3cU0St.js} +1 -1
  34. package/dist/assets/{Index-Br9FIpIk.js → Index-Com13wSA.js} +1 -1
  35. package/dist/assets/{Index-C2fswlzZ.js → Index-DGEy1cH-.js} +1 -1
  36. package/dist/assets/{Index-DGJp5jTK.js → Index-DMOFnsOs.js} +1 -1
  37. package/dist/assets/{Index-DUHWR3KA.js → Index-DXr5n1Q3.js} +1 -1
  38. package/dist/assets/{Index-Cz8lErDx.js → Index-DcAn7ciB.js} +1 -1
  39. package/dist/assets/{Index-KjiJiypj.js → Index-DtcNG2nc.js} +1 -1
  40. package/dist/assets/{Index-CQDO2OkC.js → Index-IMJClExx.js} +1 -1
  41. package/dist/assets/{Index-C-0TAGHF.js → Index-P6XThfKj.js} +1 -1
  42. package/dist/assets/{Index-Cw_ueXEV.js → Index-cbNSKT8K.js} +1 -1
  43. package/dist/assets/{Index-TTQvT-QT.js → Index-ewVX29uA.js} +1 -1
  44. package/dist/assets/{Index-B6Qy4CDb.js → Index-fhuPamTo.js} +1 -1
  45. package/dist/assets/{Index-4P2eY1Pb.js → Index-i8xltFmi.js} +1 -1
  46. package/dist/assets/{Index-pXo5iWv8.js → Index-lJxfHNF0.js} +1 -1
  47. package/dist/assets/{Index-C8ksqP5L.js → Index-x4WFXCek.js} +1 -1
  48. package/dist/assets/{Invitees-BBmncCt7.js → Invitees-DygUhx6l.js} +1 -1
  49. package/dist/assets/{List-5cYVTGQc.js → List-0rePExDV.js} +1 -1
  50. package/dist/assets/{List-CNX4H8Xg.js → List-BQJdaQag.js} +1 -1
  51. package/dist/assets/{List-DtNy4Q5W.js → List-NFR50JXX.js} +1 -1
  52. package/dist/assets/LocalTools-BK5uJNyi.js +1 -0
  53. package/dist/assets/LocalTools-Babksy8I.css +1 -0
  54. package/dist/assets/{LocalTools-B6bmPVgG.js → LocalTools-DjhSvXs_.js} +1 -1
  55. package/dist/assets/{Main-CcmDuH47.js → Main-C2mv0lWg.js} +1 -1
  56. package/dist/assets/{Model-ChXONprt.js → Model-DJzohYYj.js} +1 -1
  57. package/dist/assets/{Navigator-UC-XfU0f.js → Navigator-Cu_gtqFU.js} +1 -1
  58. package/dist/assets/{NoTasks-BDnSN1xc.js → NoTasks-CxdC3Rde.js} +1 -1
  59. package/dist/assets/{NotFound-CZSneMpE.js → NotFound-AHDvLT8C.js} +1 -1
  60. package/dist/assets/{Pagination-B_1jL6i5.js → Pagination-C2KeWH4y.js} +1 -1
  61. package/dist/assets/{Pay-B3TMV3Y2.js → Pay-B-orcFiW.js} +1 -1
  62. package/dist/assets/{Player-ONzugQK4.js → Player-CYNj4GHR.js} +1 -1
  63. package/dist/assets/{PromptTextarea-uiCZEDcU.js → PromptTextarea-BfwTxV-_.js} +1 -1
  64. package/dist/assets/{RealtimeCall-nvG0x0jh.js → RealtimeCall-5W-BJfBD.js} +1 -1
  65. package/dist/assets/{ScheduledTasks-T-59eWIO.js → ScheduledTasks-EL5ZSAYD.js} +1 -1
  66. package/dist/assets/{Status-DoQ01e65.js → Status-IWlNaZuC.js} +1 -1
  67. package/dist/assets/{Subscribe-B-oS2QiT.js → Subscribe-CETbdxxV.js} +1 -1
  68. package/dist/assets/{TabSwitcher-D8ioaRcC.js → TabSwitcher-CeGqltCT.js} +1 -1
  69. package/dist/assets/{Tts-DbXBm04T.js → Tts-BqkaBmDN.js} +1 -1
  70. package/dist/assets/{VideoPlayer-CKr2aTQg.js → VideoPlayer-lCCwqseV.js} +1 -1
  71. package/dist/assets/{avatar-Bvic_SgR.js → avatar-BMNgYz1d.js} +1 -1
  72. package/dist/assets/{basic-BwrKEexg.js → basic-Bk83RDnd.js} +1 -1
  73. package/dist/assets/{chat-Bm3V43_g.js → chat-DuVJAuKr.js} +1 -1
  74. package/dist/assets/{codingBridge-Y9QQiIdv.js → codingBridge-Cr2JQHtn.js} +1 -1
  75. package/dist/assets/{codingBridgeNotify-CbUCY2Ha.js → codingBridgeNotify-BqD9UypY.js} +2 -2
  76. package/dist/assets/{collapse-2OPuxRz7.js → collapse-C7d6wtM1.js} +1 -1
  77. package/dist/assets/{createTaskActions-DSyBtEgG.js → createTaskActions-C6s_eGn7.js} +1 -1
  78. package/dist/assets/{date-picker-DGHZ5U2D.js → date-picker-Dws4T00t.js} +1 -1
  79. package/dist/assets/{digitalhuman-Djdj0h_8.js → digitalhuman-uwm_3Bj8.js} +1 -1
  80. package/dist/assets/{dropdown-xXljOV09.js → dropdown-C2CTijMb.js} +1 -1
  81. package/dist/assets/esm-Bg9zfaHK.js +1 -0
  82. package/dist/assets/{esm-Dm8djnh2.js → esm-CXbsDTW7.js} +1 -1
  83. package/dist/assets/{esm-CzyWpYuO.js → esm-CxSCFe4-.js} +1 -1
  84. package/dist/assets/{esm-BXlI-SOb.js → esm-D8isJq2z.js} +3 -3
  85. package/dist/assets/{esm-C2ZHcl7J.js → esm-DR57J6g5.js} +2 -2
  86. package/dist/assets/{esm-CJg36aUP.js → esm-DyzyjX7D.js} +1 -1
  87. package/dist/assets/{esm-DNbTvQ5w.js → esm-hBQbXlTr.js} +2 -2
  88. package/dist/assets/{fish-DGTW6Smy.js → fish-BQjKeGKU.js} +1 -1
  89. package/dist/assets/{flux-BjYn_C-l.js → flux-DG7-GLQ-.js} +1 -1
  90. package/dist/assets/{grokvideo-VYqywNG6.js → grokvideo-CLjAbL_f.js} +1 -1
  91. package/dist/assets/{hailuo-Dt2LoDcn.js → hailuo-6qYG6Vmx.js} +1 -1
  92. package/dist/assets/{headshots-r0YjgpGI.js → headshots-Ctg8zmJ-.js} +1 -1
  93. package/dist/assets/{image-BPVgaSAh.js → image-BaawrLQN.js} +1 -1
  94. package/dist/assets/{index-DwgDCJZs.js → index-bhnA3ynS.js} +3 -3
  95. package/dist/assets/{index.browser.esm-DkE5S5y1.js → index.browser.esm-CVvep8p_.js} +1 -1
  96. package/dist/assets/{index.es-DMwpJkVk.js → index.es-BK9VjfWt.js} +1 -1
  97. package/dist/assets/{input-number-DfiG_0O_.js → input-number-D0E1xoH2.js} +1 -1
  98. package/dist/assets/{kling-DVyLkq-h.js → kling-D1s_AnPu.js} +1 -1
  99. package/dist/assets/{luma-BMhTeMR6.js → luma-DfNoyV8W.js} +1 -1
  100. package/dist/assets/{maestro-D_LVGDuW.js → maestro-C0kSj8Vu.js} +1 -1
  101. package/dist/assets/{midjourney-D9JhmNL2.js → midjourney-BMxzjPFU.js} +1 -1
  102. package/dist/assets/{nanobanana-D8ok9PV1.js → nanobanana-BTZ-rhz8.js} +1 -1
  103. package/dist/assets/{openaiimage-Do3R0nYo.js → openaiimage-URTkwm09.js} +1 -1
  104. package/dist/assets/{pagination-Bojn2-XY.js → pagination-D6tl2-MY.js} +1 -1
  105. package/dist/assets/{pika-Dl8HZ_1j.js → pika-Bsq1odwr.js} +1 -1
  106. package/dist/assets/{pixverse-Cibj1I82.js → pixverse-Ski4aLzy.js} +1 -1
  107. package/dist/assets/{popover-8d1UqEmG.js → popover-Di4vMAk5.js} +1 -1
  108. package/dist/assets/{producer-DmWk8RNZ.js → producer-C-m3e7OE.js} +1 -1
  109. package/dist/assets/{qrart-BDF2F6jD.js → qrart-DaTN62MX.js} +1 -1
  110. package/dist/assets/{realtime-jckFXv51.js → realtime-BAJBjkEK.js} +1 -1
  111. package/dist/assets/{row-BQIhF0VT.js → row-wAJtn2ZC.js} +1 -1
  112. package/dist/assets/{seedance-SUVQRJPE.js → seedance-CnjH7AdZ.js} +1 -1
  113. package/dist/assets/{seedream-DM0xYlQc.js → seedream-8Lz5Aghw.js} +1 -1
  114. package/dist/assets/{select-DyCz6rxk.js → select-DcGVDrKO.js} +1 -1
  115. package/dist/assets/{serp-BbWS7_fC.js → serp-CdjU_Adl.js} +1 -1
  116. package/dist/assets/{slider-tAw39xTJ.js → slider-QqNA8lXa.js} +1 -1
  117. package/dist/assets/{solana-wallets-wRAERYyP.js → solana-wallets-RTT-irG-.js} +2 -2
  118. package/dist/assets/{solana-wallets-vue-C9JvHO2A.js → solana-wallets-vue-09VXxGny.js} +1 -1
  119. package/dist/assets/{sora-nw9IZV_o.js → sora-DLbWns9z.js} +1 -1
  120. package/dist/assets/{suno-DBi3PpE1.js → suno-DVXccE6D.js} +1 -1
  121. package/dist/assets/{switch-BWI_Zh-b.js → switch-D1eTmtNv.js} +1 -1
  122. package/dist/assets/{tabs-yx3e4tqC.js → tabs-CFqNrPtR.js} +1 -1
  123. package/dist/assets/{time-picker--YNzkuXo.js → time-picker-B0Gpgb9S.js} +1 -1
  124. package/dist/assets/{upload-pKKwbKaB.js → upload-F7Gkd45h.js} +1 -1
  125. package/dist/assets/{veo-DT8bRT_g.js → veo-BUPSmy5W.js} +1 -1
  126. package/dist/assets/{wan-Bqt6POfL.js → wan-DFiEVxMM.js} +1 -1
  127. package/dist/assets/{web-BbcpN_SN.js → web--HLw7KUH.js} +1 -1
  128. package/dist/assets/{web-DXJLrRRo.js → web-CaNry171.js} +1 -1
  129. package/dist/assets/{web-uJ1irNGX.js → web-Cy4wOBKt.js} +1 -1
  130. package/dist/assets/{web-6quhxfuX.js → web-D4LzaN8G.js} +1 -1
  131. package/dist/assets/{web-Dx2EfDG-.js → web-DJfvwXv9.js} +1 -1
  132. package/dist/assets/{webextrator-DFWVw1-i.js → webextrator-gHIAaW2U.js} +1 -1
  133. package/dist/index.html +1 -1
  134. package/package.json +1 -1
  135. package/dist/assets/LocalTools-CN_Ci76o.js +0 -1
  136. package/dist/assets/LocalTools-DmdQlh4s.css +0 -1
  137. package/dist/assets/esm-6vknvolT.js +0 -1
@@ -1 +1 @@
1
- import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,dt as u,k as d,nt as f,tt as p,ut as m}from"./vendor-chart-BJCvKk8-.js";import{t as h}from"./button-BydTr5nV.js";import{n as g,t as ee}from"./table-BJr3w4hQ.js";import{t as _}from"./card-DjyfNde2.js";import{n as v,t as y}from"./row-BQIhF0VT.js";import{t as b}from"./empty-CdsD8g84.js";import{t as x}from"./Pagination-B_1jL6i5.js";import{t as S}from"./skeleton-BwNBivMN.js";import{t as C}from"./switch-BWI_Zh-b.js";import{Ar as w,B as T,Br as E,Cr as D,K as O,Kr as k,O as A,Un as j,Zr as M,jr as N,wr as P}from"./index-DwgDCJZs.js";import{t as F}from"./index.es-DMwpJkVk.js";import{t as I}from"./CopyToClipboard-BM4VvfdY.js";var L=r({name:`ConsoleApplicationList`,components:{Pagination:x,CopyToClipboard:I,ElTable:ee,ElRow:y,ElButton:h,ElCol:v,ElTag:M,ElSkeleton:S,ElSwitch:C,ElEmpty:b,ElTableColumn:g,ElCard:_,FontAwesomeIcon:F},data(){return{credentialType:D,serviceType:P,individualApplications:[],globalApplications:[],individualApplicationsTotal:void 0,globalApplicationsTotal:void 0,loading:!1,buying:!1,limit:10,form:{amount:1},active:{service:void 0,application:void 0}}},computed:{redirect(){return this.$route.query?.redirect},page(){return parseInt(this.$route.query.page?.toString()||`1`)},showGlobalPayment(){return!0}},watch:{page:{handler(){this.onFetchData()}}},mounted(){this.onInitializeGlobalApplication(),this.onFetchData()},methods:{rowCanPay(e){return E()?(e?.packages||[]).some(e=>e?.metadata?.apple_product_id):!0},updateAllowConsumeGlobal(e,t){!e||!e.id||j.updateAllConsumeGlobal(e.id,{...e,allow_consume_global:!!t}).then(()=>{k.success(this.$t(`application.message.updateSuccessfully`).toString())}).catch(()=>{k.error(this.$t(`application.message.updateFailed`).toString())})},onGoUsage(e){this.$router.push({name:O,query:{application_id:e.id,type:e?.service?.type}})},onBuyMore(e){e?.id&&this.$router.push({name:T,params:{id:e.id}})},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,page:e}})},onFetchApplications(e=w.INDIVIDUAL){return new Promise((t,n)=>{j.getAll({limit:this.limit,...e===w.INDIVIDUAL?{offset:(this.page-1)*this.limit}:{},user_id:this.$store.getters.user.id,ordering:`-created_at`,type:N.USAGE,scope:e}).then(({data:n})=>{e===w.INDIVIDUAL?(this.individualApplications=n.items,this.individualApplicationsTotal=n.count):(this.globalApplications=n.items,this.globalApplicationsTotal=n.count),t(n)}).catch(e=>{k.error(this.$t(`application.message.fetchFailed`).toString()),n(e)})})},onFetchData(){this.loading=!0,Promise.all([this.onFetchApplications(w.INDIVIDUAL),this.onFetchApplications(w.GLOBAL)]).then(()=>{this.loading=!1}).catch(()=>{this.loading=!1})},onInitializeGlobalApplication(){j.create({type:N.USAGE,scope:w.GLOBAL,user_id:this.$store.getters.user.id}).finally(()=>{this.onFetchApplications(w.GLOBAL)})},getRemainingAmount(e){if(e.remaining_amount===void 0||e.remaining_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.remaining_amount?.toFixed(6)} ${t}`},getUsedAmount(e){if(e.used_amount===void 0||e.used_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.used_amount?.toFixed(6)} ${t}`}}}),R={class:`title`},z={key:1,class:`summary-card`},B={class:`icon-wrapper`},V={class:`label`},H={class:`value`},U={class:`description`},W={key:1,class:`flex flex-row justify-between items-center gap-3`},G={class:`summary-card min-w-0 flex-1`},K={class:`flex justify-start items-center gap-2 mb-2 w-full`},q={class:`icon-wrapper !mb-0`},J={class:`text-[var(--el-text-color-regular)] text-[14px] truncate`},te={class:`label`},Y={class:`value`},X={class:`description`},Z={class:`flex flex-col items-end gap-2 shrink-0`},Q={class:`copy`},ne={key:0,class:`expired-at`},re={class:`flex flex-wrap items-center justify-end gap-1`},ie={class:`application-cards block sm:hidden`},ae={class:`flex items-center gap-2 flex-wrap`},oe={class:`application-card__name`},se={class:`application-card__id`},ce={class:`truncate`},le={class:`application-card__row`},ue={class:`label`},de={class:`value`},fe={key:0,class:`application-card__row`},pe={class:`label`},$={class:`value`},me={key:1,class:`application-card__row`},he={class:`label`},ge={class:`flex items-center justify-end gap-2 mt-3`},_e={class:`pagination`};function ve(r,h,g,ee,_,v){let y=p(`el-col`),b=p(`el-row`),x=p(`el-skeleton`),S=p(`font-awesome-icon`),C=p(`el-card`),w=p(`copy-to-clipboard`),T=p(`el-button`),E=p(`el-table-column`),D=p(`el-tag`),O=p(`el-switch`),k=p(`el-table`),A=p(`el-empty`),j=p(`pagination`),M=f(`loading`);return l(),a(b,{class:`application-list`},{default:m(()=>[o(y,{span:24},{default:m(()=>[o(b,null,{default:m(()=>[o(y,{span:24},{default:m(()=>[n(`h2`,R,c(r.$t(`common.title.allApplications`)),1)]),_:1})]),_:1}),o(b,{gutter:15,class:`mb-3`},{default:m(()=>[o(y,{md:12,xs:24},{default:m(()=>[o(C,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:m(()=>[r.loading?(l(),a(x,{key:0})):(l(),t(`div`,z,[n(`div`,B,[o(S,{icon:`fa-solid fa-cubes-stacked`})]),n(`p`,V,c(r.$t(`application.title.count`)),1),n(`p`,H,c(r.individualApplicationsTotal),1),n(`p`,U,c(r.$t(`application.message.countDescription`)),1)]))]),_:1})]),_:1}),r.showGlobalPayment&&r.globalApplications?.length>0?(l(),a(y,{key:0,md:12,xs:24},{default:m(()=>[o(C,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:m(()=>[r.loading?(l(),a(x,{key:0})):(l(),t(`div`,W,[n(`div`,G,[n(`div`,K,[n(`div`,q,[o(S,{icon:`fa-solid fa-wallet`})]),n(`span`,J,[i(c(r.$t(`application.field.id`))+`: `+c(r.globalApplications?.[0]?.id)+` `,1),r.globalApplications?.[0]?.id?(l(),a(w,{key:0,content:r.globalApplications?.[0]?.id,class:`inline-block`},null,8,[`content`])):d(``,!0)])]),n(`p`,te,c(r.$t(`application.title.globalBalance`)),1),n(`p`,Y,c(r.globalApplications?.[0]?.remaining_amount?.toFixed(6)||`0.000000`)+` `+c(r.$t(`service.unit.credits`)),1),n(`p`,X,c(r.$t(`application.message.globalBalanceDescription`)),1)]),n(`div`,Z,[o(T,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:h[0]||=e=>r.onGoUsage(r.globalApplications?.[0])},{default:m(()=>[o(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.usage`)),1)]),_:1}),r.showGlobalPayment?(l(),a(T,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:h[1]||=e=>r.onBuyMore(r.globalApplications?.[0])},{default:m(()=>[o(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.buyMore`)),1)]),_:1})):d(``,!0)])]))]),_:1})]),_:1})):d(``,!0)]),_:1}),o(b,null,{default:m(()=>[o(y,{span:24},{default:m(()=>[o(C,{shadow:`hover`,class:`applications-table-card hidden sm:block`},{default:m(()=>[u((l(),a(k,{data:r.individualApplications,stripe:``,class:`applications-table !min-h-[calc(100vh-420px)]`,"table-layout":`fixed`,"empty-text":r.$t(`common.message.noData`)},{default:m(()=>[o(E,{prop:`id`,label:r.$t(`application.field.id`),width:`200px`,"class-name":`text-center`},{default:m(e=>[n(`span`,null,c(e.row.id),1),n(`span`,Q,[o(w,{content:e?.row?.id,class:`inline-block`},null,8,[`content`])])]),_:1},8,[`label`]),o(E,{label:r.$t(`application.field.type`),width:`90px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[e.row?.type===`Period`?(l(),a(D,{key:0,type:`success`,effect:`dark`,round:``},{default:m(()=>[i(c(r.$t(`application.type.period`)),1)]),_:1})):e.row?.type===`Usage`?(l(),a(D,{key:1,effect:`dark`,round:``},{default:m(()=>[i(c(r.$t(`application.type.usage`)),1)]),_:1})):d(``,!0)]),_:1},8,[`label`]),o(E,{label:r.$t(`application.field.name`),width:`180px`},{default:m(e=>[n(`span`,null,c(e.row?.service?.title),1),e.row?.role===`grantee`?(l(),a(D,{key:0,type:`info`,size:`small`,round:``,class:`ml-2`},{default:m(()=>[i(c(r.$t(`application.badge.shared`)),1)]),_:1})):d(``,!0)]),_:1},8,[`label`]),o(E,{prop:`remaining_amount`,label:r.$t(`application.field.remainingAmount`),width:`150px`,"class-name":`text-center`},{default:m(e=>[n(`span`,null,c(r.getRemainingAmount(e.row)),1)]),_:1},8,[`label`]),o(E,{prop:`used_amount`,label:r.$t(`application.field.usedAmount`),width:`150px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[n(`span`,null,c(r.getUsedAmount(e.row)),1)]),_:1},8,[`label`]),o(E,{prop:`allow_consume_global`,label:r.$t(`application.field.allowConsumeGlobal`),width:`120px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[e.row.service?.type===r.serviceType.API?(l(),a(O,{key:0,modelValue:e.row.allow_consume_global,"onUpdate:modelValue":t=>e.row.allow_consume_global=t,"active-value":!0,"inactive-value":!1,onChange:t=>r.updateAllowConsumeGlobal(e.row,t)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])):d(``,!0)]),_:1},8,[`label`]),o(E,{label:r.$t(`application.field.expiredAt`),width:`180px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[e.row.expired_at?(l(),t(`span`,ne,c(r.$dayjs.format(e.row.expired_at)),1)):d(``,!0)]),_:1},8,[`label`]),o(E,{fixed:`right`,width:`200px`},{default:m(e=>[n(`div`,re,[o(T,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:t=>r.onGoUsage(e?.row)},{default:m(()=>[o(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),r.rowCanPay(e?.row)?(l(),a(T,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:t=>r.onBuyMore(e?.row)},{default:m(()=>[o(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):d(``,!0)])]),_:1})]),_:1},8,[`data`,`empty-text`])),[[M,r.loading]])]),_:1}),n(`div`,ie,[r.loading?(l(),a(x,{key:0,rows:4,animated:``})):(l(),t(s,{key:1},[r.individualApplications?.length?(l(!0),t(s,{key:1},e(r.individualApplications,e=>(l(),a(C,{key:e.id,shadow:`hover`,class:`application-card mb-2`,"body-style":{padding:`14px 16px`}},{default:m(()=>[n(`div`,ae,[n(`span`,oe,c(e?.service?.title),1),e?.type===`Period`?(l(),a(D,{key:0,type:`success`,effect:`dark`,size:`small`,round:``},{default:m(()=>[i(c(r.$t(`application.type.period`)),1)]),_:1})):e?.type===`Usage`?(l(),a(D,{key:1,effect:`dark`,size:`small`,round:``},{default:m(()=>[i(c(r.$t(`application.type.usage`)),1)]),_:1})):d(``,!0),e?.role===`grantee`?(l(),a(D,{key:2,type:`info`,size:`small`,round:``},{default:m(()=>[i(c(r.$t(`application.badge.shared`)),1)]),_:1})):d(``,!0)]),n(`div`,se,[n(`span`,ce,c(r.$t(`application.field.id`))+`: `+c(e.id),1),o(w,{content:e.id,class:`inline-block shrink-0`},null,8,[`content`])]),n(`div`,le,[n(`span`,ue,c(r.$t(`application.field.remainingAmount`)),1),n(`span`,de,c(r.getRemainingAmount(e)),1)]),e?.expired_at?(l(),t(`div`,fe,[n(`span`,pe,c(r.$t(`application.field.expiredAt`)),1),n(`span`,$,c(r.$dayjs.format(e.expired_at)),1)])):d(``,!0),e.service?.type===r.serviceType.API?(l(),t(`div`,me,[n(`span`,he,c(r.$t(`application.field.allowConsumeGlobal`)),1),o(O,{modelValue:e.allow_consume_global,"onUpdate:modelValue":t=>e.allow_consume_global=t,"active-value":!0,"inactive-value":!1,onChange:t=>r.updateAllowConsumeGlobal(e,t)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])])):d(``,!0),n(`div`,ge,[o(T,{class:`!m-0 !px-3`,size:`small`,round:``,onClick:t=>r.onGoUsage(e)},{default:m(()=>[o(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),r.rowCanPay(e)?(l(),a(T,{key:0,class:`!m-0 !px-3`,type:`primary`,round:``,size:`small`,onClick:t=>r.onBuyMore(e)},{default:m(()=>[o(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):d(``,!0)])]),_:2},1024))),128)):(l(),a(A,{key:0,description:r.$t(`common.message.noData`)},null,8,[`description`]))],64))])]),_:1})]),_:1}),o(b,null,{default:m(()=>[o(y,{span:24},{default:m(()=>[n(`div`,_e,[o(j,{"current-page":r.page,"page-size":r.limit,total:r.individualApplicationsTotal,onChange:r.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var ye=A(L,[[`render`,ve],[`__scopeId`,`data-v-b4164ed9`]]);export{ye as default};
1
+ import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,dt as u,k as d,nt as f,tt as p,ut as m}from"./vendor-chart-BJCvKk8-.js";import{t as h}from"./button-BydTr5nV.js";import{n as g,t as ee}from"./table-BJr3w4hQ.js";import{t as _}from"./card-DjyfNde2.js";import{n as v,t as y}from"./row-wAJtn2ZC.js";import{t as b}from"./empty-CdsD8g84.js";import{t as x}from"./Pagination-C2KeWH4y.js";import{t as S}from"./skeleton-BwNBivMN.js";import{t as C}from"./switch-D1eTmtNv.js";import{Ar as w,B as T,Br as E,Cr as D,K as O,Kr as k,O as A,Un as j,Zr as M,jr as N,wr as P}from"./index-bhnA3ynS.js";import{t as F}from"./index.es-BK9VjfWt.js";import{t as I}from"./CopyToClipboard-lWAkY_ey.js";var L=r({name:`ConsoleApplicationList`,components:{Pagination:x,CopyToClipboard:I,ElTable:ee,ElRow:y,ElButton:h,ElCol:v,ElTag:M,ElSkeleton:S,ElSwitch:C,ElEmpty:b,ElTableColumn:g,ElCard:_,FontAwesomeIcon:F},data(){return{credentialType:D,serviceType:P,individualApplications:[],globalApplications:[],individualApplicationsTotal:void 0,globalApplicationsTotal:void 0,loading:!1,buying:!1,limit:10,form:{amount:1},active:{service:void 0,application:void 0}}},computed:{redirect(){return this.$route.query?.redirect},page(){return parseInt(this.$route.query.page?.toString()||`1`)},showGlobalPayment(){return!0}},watch:{page:{handler(){this.onFetchData()}}},mounted(){this.onInitializeGlobalApplication(),this.onFetchData()},methods:{rowCanPay(e){return E()?(e?.packages||[]).some(e=>e?.metadata?.apple_product_id):!0},updateAllowConsumeGlobal(e,t){!e||!e.id||j.updateAllConsumeGlobal(e.id,{...e,allow_consume_global:!!t}).then(()=>{k.success(this.$t(`application.message.updateSuccessfully`).toString())}).catch(()=>{k.error(this.$t(`application.message.updateFailed`).toString())})},onGoUsage(e){this.$router.push({name:O,query:{application_id:e.id,type:e?.service?.type}})},onBuyMore(e){e?.id&&this.$router.push({name:T,params:{id:e.id}})},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,page:e}})},onFetchApplications(e=w.INDIVIDUAL){return new Promise((t,n)=>{j.getAll({limit:this.limit,...e===w.INDIVIDUAL?{offset:(this.page-1)*this.limit}:{},user_id:this.$store.getters.user.id,ordering:`-created_at`,type:N.USAGE,scope:e}).then(({data:n})=>{e===w.INDIVIDUAL?(this.individualApplications=n.items,this.individualApplicationsTotal=n.count):(this.globalApplications=n.items,this.globalApplicationsTotal=n.count),t(n)}).catch(e=>{k.error(this.$t(`application.message.fetchFailed`).toString()),n(e)})})},onFetchData(){this.loading=!0,Promise.all([this.onFetchApplications(w.INDIVIDUAL),this.onFetchApplications(w.GLOBAL)]).then(()=>{this.loading=!1}).catch(()=>{this.loading=!1})},onInitializeGlobalApplication(){j.create({type:N.USAGE,scope:w.GLOBAL,user_id:this.$store.getters.user.id}).finally(()=>{this.onFetchApplications(w.GLOBAL)})},getRemainingAmount(e){if(e.remaining_amount===void 0||e.remaining_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.remaining_amount?.toFixed(6)} ${t}`},getUsedAmount(e){if(e.used_amount===void 0||e.used_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.used_amount?.toFixed(6)} ${t}`}}}),R={class:`title`},z={key:1,class:`summary-card`},B={class:`icon-wrapper`},V={class:`label`},H={class:`value`},U={class:`description`},W={key:1,class:`flex flex-row justify-between items-center gap-3`},G={class:`summary-card min-w-0 flex-1`},K={class:`flex justify-start items-center gap-2 mb-2 w-full`},q={class:`icon-wrapper !mb-0`},J={class:`text-[var(--el-text-color-regular)] text-[14px] truncate`},te={class:`label`},Y={class:`value`},X={class:`description`},Z={class:`flex flex-col items-end gap-2 shrink-0`},Q={class:`copy`},ne={key:0,class:`expired-at`},re={class:`flex flex-wrap items-center justify-end gap-1`},ie={class:`application-cards block sm:hidden`},ae={class:`flex items-center gap-2 flex-wrap`},oe={class:`application-card__name`},se={class:`application-card__id`},ce={class:`truncate`},le={class:`application-card__row`},ue={class:`label`},de={class:`value`},fe={key:0,class:`application-card__row`},pe={class:`label`},$={class:`value`},me={key:1,class:`application-card__row`},he={class:`label`},ge={class:`flex items-center justify-end gap-2 mt-3`},_e={class:`pagination`};function ve(r,h,g,ee,_,v){let y=p(`el-col`),b=p(`el-row`),x=p(`el-skeleton`),S=p(`font-awesome-icon`),C=p(`el-card`),w=p(`copy-to-clipboard`),T=p(`el-button`),E=p(`el-table-column`),D=p(`el-tag`),O=p(`el-switch`),k=p(`el-table`),A=p(`el-empty`),j=p(`pagination`),M=f(`loading`);return l(),a(b,{class:`application-list`},{default:m(()=>[o(y,{span:24},{default:m(()=>[o(b,null,{default:m(()=>[o(y,{span:24},{default:m(()=>[n(`h2`,R,c(r.$t(`common.title.allApplications`)),1)]),_:1})]),_:1}),o(b,{gutter:15,class:`mb-3`},{default:m(()=>[o(y,{md:12,xs:24},{default:m(()=>[o(C,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:m(()=>[r.loading?(l(),a(x,{key:0})):(l(),t(`div`,z,[n(`div`,B,[o(S,{icon:`fa-solid fa-cubes-stacked`})]),n(`p`,V,c(r.$t(`application.title.count`)),1),n(`p`,H,c(r.individualApplicationsTotal),1),n(`p`,U,c(r.$t(`application.message.countDescription`)),1)]))]),_:1})]),_:1}),r.showGlobalPayment&&r.globalApplications?.length>0?(l(),a(y,{key:0,md:12,xs:24},{default:m(()=>[o(C,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:m(()=>[r.loading?(l(),a(x,{key:0})):(l(),t(`div`,W,[n(`div`,G,[n(`div`,K,[n(`div`,q,[o(S,{icon:`fa-solid fa-wallet`})]),n(`span`,J,[i(c(r.$t(`application.field.id`))+`: `+c(r.globalApplications?.[0]?.id)+` `,1),r.globalApplications?.[0]?.id?(l(),a(w,{key:0,content:r.globalApplications?.[0]?.id,class:`inline-block`},null,8,[`content`])):d(``,!0)])]),n(`p`,te,c(r.$t(`application.title.globalBalance`)),1),n(`p`,Y,c(r.globalApplications?.[0]?.remaining_amount?.toFixed(6)||`0.000000`)+` `+c(r.$t(`service.unit.credits`)),1),n(`p`,X,c(r.$t(`application.message.globalBalanceDescription`)),1)]),n(`div`,Z,[o(T,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:h[0]||=e=>r.onGoUsage(r.globalApplications?.[0])},{default:m(()=>[o(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.usage`)),1)]),_:1}),r.showGlobalPayment?(l(),a(T,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:h[1]||=e=>r.onBuyMore(r.globalApplications?.[0])},{default:m(()=>[o(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.buyMore`)),1)]),_:1})):d(``,!0)])]))]),_:1})]),_:1})):d(``,!0)]),_:1}),o(b,null,{default:m(()=>[o(y,{span:24},{default:m(()=>[o(C,{shadow:`hover`,class:`applications-table-card hidden sm:block`},{default:m(()=>[u((l(),a(k,{data:r.individualApplications,stripe:``,class:`applications-table !min-h-[calc(100vh-420px)]`,"table-layout":`fixed`,"empty-text":r.$t(`common.message.noData`)},{default:m(()=>[o(E,{prop:`id`,label:r.$t(`application.field.id`),width:`200px`,"class-name":`text-center`},{default:m(e=>[n(`span`,null,c(e.row.id),1),n(`span`,Q,[o(w,{content:e?.row?.id,class:`inline-block`},null,8,[`content`])])]),_:1},8,[`label`]),o(E,{label:r.$t(`application.field.type`),width:`90px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[e.row?.type===`Period`?(l(),a(D,{key:0,type:`success`,effect:`dark`,round:``},{default:m(()=>[i(c(r.$t(`application.type.period`)),1)]),_:1})):e.row?.type===`Usage`?(l(),a(D,{key:1,effect:`dark`,round:``},{default:m(()=>[i(c(r.$t(`application.type.usage`)),1)]),_:1})):d(``,!0)]),_:1},8,[`label`]),o(E,{label:r.$t(`application.field.name`),width:`180px`},{default:m(e=>[n(`span`,null,c(e.row?.service?.title),1),e.row?.role===`grantee`?(l(),a(D,{key:0,type:`info`,size:`small`,round:``,class:`ml-2`},{default:m(()=>[i(c(r.$t(`application.badge.shared`)),1)]),_:1})):d(``,!0)]),_:1},8,[`label`]),o(E,{prop:`remaining_amount`,label:r.$t(`application.field.remainingAmount`),width:`150px`,"class-name":`text-center`},{default:m(e=>[n(`span`,null,c(r.getRemainingAmount(e.row)),1)]),_:1},8,[`label`]),o(E,{prop:`used_amount`,label:r.$t(`application.field.usedAmount`),width:`150px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[n(`span`,null,c(r.getUsedAmount(e.row)),1)]),_:1},8,[`label`]),o(E,{prop:`allow_consume_global`,label:r.$t(`application.field.allowConsumeGlobal`),width:`120px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[e.row.service?.type===r.serviceType.API?(l(),a(O,{key:0,modelValue:e.row.allow_consume_global,"onUpdate:modelValue":t=>e.row.allow_consume_global=t,"active-value":!0,"inactive-value":!1,onChange:t=>r.updateAllowConsumeGlobal(e.row,t)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])):d(``,!0)]),_:1},8,[`label`]),o(E,{label:r.$t(`application.field.expiredAt`),width:`180px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[e.row.expired_at?(l(),t(`span`,ne,c(r.$dayjs.format(e.row.expired_at)),1)):d(``,!0)]),_:1},8,[`label`]),o(E,{fixed:`right`,width:`200px`},{default:m(e=>[n(`div`,re,[o(T,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:t=>r.onGoUsage(e?.row)},{default:m(()=>[o(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),r.rowCanPay(e?.row)?(l(),a(T,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:t=>r.onBuyMore(e?.row)},{default:m(()=>[o(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):d(``,!0)])]),_:1})]),_:1},8,[`data`,`empty-text`])),[[M,r.loading]])]),_:1}),n(`div`,ie,[r.loading?(l(),a(x,{key:0,rows:4,animated:``})):(l(),t(s,{key:1},[r.individualApplications?.length?(l(!0),t(s,{key:1},e(r.individualApplications,e=>(l(),a(C,{key:e.id,shadow:`hover`,class:`application-card mb-2`,"body-style":{padding:`14px 16px`}},{default:m(()=>[n(`div`,ae,[n(`span`,oe,c(e?.service?.title),1),e?.type===`Period`?(l(),a(D,{key:0,type:`success`,effect:`dark`,size:`small`,round:``},{default:m(()=>[i(c(r.$t(`application.type.period`)),1)]),_:1})):e?.type===`Usage`?(l(),a(D,{key:1,effect:`dark`,size:`small`,round:``},{default:m(()=>[i(c(r.$t(`application.type.usage`)),1)]),_:1})):d(``,!0),e?.role===`grantee`?(l(),a(D,{key:2,type:`info`,size:`small`,round:``},{default:m(()=>[i(c(r.$t(`application.badge.shared`)),1)]),_:1})):d(``,!0)]),n(`div`,se,[n(`span`,ce,c(r.$t(`application.field.id`))+`: `+c(e.id),1),o(w,{content:e.id,class:`inline-block shrink-0`},null,8,[`content`])]),n(`div`,le,[n(`span`,ue,c(r.$t(`application.field.remainingAmount`)),1),n(`span`,de,c(r.getRemainingAmount(e)),1)]),e?.expired_at?(l(),t(`div`,fe,[n(`span`,pe,c(r.$t(`application.field.expiredAt`)),1),n(`span`,$,c(r.$dayjs.format(e.expired_at)),1)])):d(``,!0),e.service?.type===r.serviceType.API?(l(),t(`div`,me,[n(`span`,he,c(r.$t(`application.field.allowConsumeGlobal`)),1),o(O,{modelValue:e.allow_consume_global,"onUpdate:modelValue":t=>e.allow_consume_global=t,"active-value":!0,"inactive-value":!1,onChange:t=>r.updateAllowConsumeGlobal(e,t)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])])):d(``,!0),n(`div`,ge,[o(T,{class:`!m-0 !px-3`,size:`small`,round:``,onClick:t=>r.onGoUsage(e)},{default:m(()=>[o(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),r.rowCanPay(e)?(l(),a(T,{key:0,class:`!m-0 !px-3`,type:`primary`,round:``,size:`small`,onClick:t=>r.onBuyMore(e)},{default:m(()=>[o(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):d(``,!0)])]),_:2},1024))),128)):(l(),a(A,{key:0,description:r.$t(`common.message.noData`)},null,8,[`description`]))],64))])]),_:1})]),_:1}),o(b,null,{default:m(()=>[o(y,{span:24},{default:m(()=>[n(`div`,_e,[o(j,{"current-page":r.page,"page-size":r.limit,total:r.individualApplicationsTotal,onChange:r.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var ye=A(L,[[`render`,ve],[`__scopeId`,`data-v-b4164ed9`]]);export{ye as default};
@@ -1 +1 @@
1
- import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,dt as u,nt as d,tt as f,ut as p}from"./vendor-chart-BJCvKk8-.js";import{t as m}from"./button-BydTr5nV.js";import{r as h,t as g}from"./select-DyCz6rxk.js";import{n as _,t as v}from"./table-BJr3w4hQ.js";import{t as y}from"./card-DjyfNde2.js";import{t as b}from"./date-picker-DGHZ5U2D.js";import{n as x,t as S}from"./row-BQIhF0VT.js";import{t as C}from"./Pagination-B_1jL6i5.js";import{t as w}from"./skeleton-BwNBivMN.js";import{In as T,O as E,Tr as D,Wt as O,Zr as k}from"./index-DwgDCJZs.js";import{t as A}from"./index.es-DMwpJkVk.js";import{t as j}from"./CopyToClipboard-BM4VvfdY.js";var M={total_count:0,total_spent:0,state_counts:{}},N=r({name:`ConsoleOrderList`,components:{Pagination:C,CopyToClipboard:j,ElRow:S,ElCol:x,ElTable:v,ElTableColumn:_,ElButton:m,ElTag:k,ElCard:y,ElSelect:h,ElOption:g,ElDatePicker:b,ElSkeleton:w,FontAwesomeIcon:A},data(){return{OrderState:D,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:D.PENDING,label:this.$t(`order.state.pending`)},{value:D.FINISHED,label:this.$t(`order.state.finished`)},{value:D.PAID,label:this.$t(`order.state.paid`)},{value:D.EXPIRED,label:this.$t(`order.state.expired`)},{value:D.FAILED,label:this.$t(`order.state.failed`)},{value:D.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:O,stateTagType(e){return e===D.FINISHED||e===D.PAID?`success`:e===D.EXPIRED||e===D.FAILED?`danger`:e===D.REFUNDED?`warning`:`info`},stateLabel(e){return{[D.PENDING]:this.$t(`order.state.pending`),[D.PAID]:this.$t(`order.state.paid`),[D.FINISHED]:this.$t(`order.state.finished`),[D.EXPIRED]:this.$t(`order.state.expired`),[D.FAILED]:this.$t(`order.state.failed`),[D.REFUNDED]:this.$t(`order.state.refunded`)}[e]||e},isPendingAction(e){return e!==D.PAID&&e!==D.FINISHED&&e!==D.EXPIRED&&e!==D.FAILED&&e!==D.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,T.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,T.getSummary(this.filterQuery).then(({data:e})=>{this.summary=e}).catch(()=>{this.summary={...M}}).finally(()=>{this.summaryLoading=!1})},onExport(){this.exporting=!0,T.exportCsv(this.filterQuery).then(({data:e})=>{let t=window.URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`orders.csv`,n.click(),window.URL.revokeObjectURL(t)}).catch(()=>{}).finally(()=>{this.exporting=!1})}}}),P={class:`title`},F={key:1,class:`card-content`},I={class:`icon-wrapper`},L={class:`description`},R={class:`value`},z={key:1,class:`card-content`},B={class:`icon-wrapper`},V={class:`description`},H={class:`value`},U={key:1,class:`card-content`},W={class:`icon-wrapper`},ee={class:`description`},G={class:`value`},K={key:1,class:`card-content`},q={class:`icon-wrapper`},J={class:`description`},Y={class:`value`},X={class:`filter-row mb-3`},Z={class:`key`},Q={class:`cursor-pointer`},$={class:`price`},te={class:`description`},ne={class:`text-gray-500`},re={class:`created-at`},ie={class:`flex items-center justify-center flex-wrap`},ae={class:`float-right`};function oe(r,m,h,g,_,v){let y=f(`el-col`),b=f(`el-row`),x=f(`el-skeleton`),S=f(`font-awesome-icon`),C=f(`el-card`),w=f(`el-option`),T=f(`el-select`),E=f(`el-date-picker`),D=f(`el-button`),O=f(`copy-to-clipboard`),k=f(`el-table-column`),A=f(`el-tag`),j=f(`el-table`),M=f(`pagination`),N=d(`loading`);return l(),a(b,{class:`panel`},{default:p(()=>[o(y,{span:24},{default:p(()=>[o(b,null,{default:p(()=>[o(y,{span:24},{default:p(()=>[n(`h2`,P,c(r.$t(`common.title.allOrders`)),1)]),_:1})]),_:1}),o(b,{gutter:16},{default:p(()=>[o(y,{md:6,sm:12,xs:24},{default:p(()=>[o(C,{shadow:`hover`,class:`item-mini mb-3`},{default:p(()=>[r.summaryLoading?(l(),a(x,{key:0})):(l(),t(`div`,F,[n(`div`,I,[o(S,{icon:`fa-solid fa-receipt`,class:`icon`})]),n(`p`,L,c(r.$t(`order.title.totalOrders`)),1),n(`p`,R,c(r.summary.total_count),1)]))]),_:1})]),_:1}),o(y,{md:6,sm:12,xs:24},{default:p(()=>[o(C,{shadow:`hover`,class:`item-mini mb-3`},{default:p(()=>[r.summaryLoading?(l(),a(x,{key:0})):(l(),t(`div`,z,[n(`div`,B,[o(S,{icon:`fa-solid fa-dollar-sign`,class:`icon`})]),n(`p`,V,c(r.$t(`order.title.totalSpent`)),1),n(`p`,H,c(r.getPriceString({value:r.summary.total_spent})),1)]))]),_:1})]),_:1}),o(y,{md:6,sm:12,xs:24},{default:p(()=>[o(C,{shadow:`hover`,class:`item-mini mb-3`},{default:p(()=>[r.summaryLoading?(l(),a(x,{key:0})):(l(),t(`div`,U,[n(`div`,W,[o(S,{icon:`fa-solid fa-check-circle`,class:`icon`})]),n(`p`,ee,c(r.$t(`order.title.finishedOrders`)),1),n(`p`,G,c(r.summary.state_counts?.Finished||0),1)]))]),_:1})]),_:1}),o(y,{md:6,sm:12,xs:24},{default:p(()=>[o(C,{shadow:`hover`,class:`item-mini mb-3`},{default:p(()=>[r.summaryLoading?(l(),a(x,{key:0})):(l(),t(`div`,K,[n(`div`,q,[o(S,{icon:`fa-solid fa-clock`,class:`icon`})]),n(`p`,J,c(r.$t(`order.title.pendingOrders`)),1),n(`p`,Y,c(r.summary.state_counts?.Pending||0),1)]))]),_:1})]),_:1})]),_:1}),n(`div`,X,[o(T,{modelValue:r.filterState,"onUpdate:modelValue":m[0]||=e=>r.filterState=e,clearable:``,placeholder:r.$t(`order.field.allStates`),class:`filter-select`,onChange:r.onFilterChange},{default:p(()=>[(l(!0),t(s,null,e(r.stateOptions,e=>(l(),a(w,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]),o(T,{modelValue:r.filterPayWay,"onUpdate:modelValue":m[1]||=e=>r.filterPayWay=e,clearable:``,placeholder:r.$t(`order.field.allPayWays`),class:`filter-select`,onChange:r.onFilterChange},{default:p(()=>[(l(!0),t(s,null,e(r.payWayOptions,e=>(l(),a(w,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]),o(E,{modelValue:r.createdAtRange,"onUpdate:modelValue":m[2]||=e=>r.createdAtRange=e,type:`datetimerange`,shortcuts:r.shortcuts,"range-separator":r.$t(`usage.placeholder.to`),"start-placeholder":r.$t(`usage.placeholder.startDate`),"end-placeholder":r.$t(`usage.placeholder.endDate`),onChange:r.onFilterChange},null,8,[`modelValue`,`shortcuts`,`range-separator`,`start-placeholder`,`end-placeholder`,`onChange`]),o(D,{type:`primary`,plain:``,loading:r.exporting,onClick:r.onExport},{default:p(()=>[o(S,{icon:`fa-solid fa-file-export`,class:`mr-1`}),i(` `+c(r.$t(`order.button.export`)),1)]),_:1},8,[`loading`,`onClick`])]),o(b,null,{default:p(()=>[o(y,{span:24},{default:p(()=>[o(C,{shadow:`hover`},{default:p(()=>[u((l(),a(j,{data:r.orders,stripe:``,"empty-text":r.$t(`common.message.noData`),class:`min-h-[calc(100vh-450px)] mb-[20px]`},{default:p(()=>[o(k,{prop:`id`,label:r.$t(`order.field.id`),"class-name":`text-center`,width:`200px`},{default:p(e=>[n(`span`,Z,c(e.row.id),1),n(`span`,Q,[o(O,{content:e.row.id,class:`inline-block`},null,8,[`content`])])]),_:1},8,[`label`]),o(k,{label:r.$t(`order.field.price`),width:`110px`,align:`center`},{default:p(e=>[n(`span`,$,c(r.getPriceString({value:e.row?.price})),1)]),_:1},8,[`label`]),o(k,{label:r.$t(`order.field.description`),"min-width":`220px`,"class-name":`hidden md:table-cell`,"label-class-name":`hidden md:table-cell`},{default:p(e=>[n(`span`,te,c(e.row.description),1)]),_:1},8,[`label`]),o(k,{prop:`state`,label:r.$t(`order.field.state`),width:`130px`,align:`center`},{default:p(e=>[o(A,{type:r.stateTagType(e.row.state),class:`mx-1`,effect:`dark`,round:``,size:`small`},{default:p(()=>[i(c(r.stateLabel(e.row.state)),1)]),_:2},1032,[`type`])]),_:1},8,[`label`]),o(k,{label:r.$t(`order.field.payWay`),width:`120px`,align:`center`,"class-name":`hidden md:table-cell`,"label-class-name":`hidden md:table-cell`},{default:p(e=>[n(`span`,ne,c(e.row.pay_way||`-`),1)]),_:1},8,[`label`]),o(k,{label:r.$t(`order.field.createdAt`),width:`200px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:p(e=>[n(`span`,re,c(r.$dayjs.format(e.row.created_at)),1)]),_:1},8,[`label`]),o(k,{"min-width":`130px`,fixed:`right`},{default:p(e=>[n(`div`,ie,[r.isPendingAction(e.row.state)?(l(),a(D,{key:0,type:`primary`,size:`small`,onClick:t=>r.goToDetail(e.row.id)},{default:p(()=>[i(c(r.$t(`order.button.continuePay`)),1)]),_:1},8,[`onClick`])):(l(),a(D,{key:1,size:`small`,onClick:t=>r.goToDetail(e.row.id)},{default:p(()=>[i(c(r.$t(`order.button.checkDetail`)),1)]),_:1},8,[`onClick`]))])]),_:1})]),_:1},8,[`data`,`empty-text`])),[[N,r.loading]])]),_:1})]),_:1})]),_:1}),o(b,null,{default:p(()=>[o(y,{span:10,offset:14},{default:p(()=>[n(`div`,ae,[o(M,{"current-page":r.page,"page-size":r.limit,total:r.total,onChange:r.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var se=E(N,[[`render`,oe],[`__scopeId`,`data-v-350ab467`]]);export{se as default};
1
+ import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,dt as u,nt as d,tt as f,ut as p}from"./vendor-chart-BJCvKk8-.js";import{t as m}from"./button-BydTr5nV.js";import{r as h,t as g}from"./select-DcGVDrKO.js";import{n as _,t as v}from"./table-BJr3w4hQ.js";import{t as y}from"./card-DjyfNde2.js";import{t as b}from"./date-picker-Dws4T00t.js";import{n as x,t as S}from"./row-wAJtn2ZC.js";import{t as C}from"./Pagination-C2KeWH4y.js";import{t as w}from"./skeleton-BwNBivMN.js";import{In as T,O as E,Tr as D,Wt as O,Zr as k}from"./index-bhnA3ynS.js";import{t as A}from"./index.es-BK9VjfWt.js";import{t as j}from"./CopyToClipboard-lWAkY_ey.js";var M={total_count:0,total_spent:0,state_counts:{}},N=r({name:`ConsoleOrderList`,components:{Pagination:C,CopyToClipboard:j,ElRow:S,ElCol:x,ElTable:v,ElTableColumn:_,ElButton:m,ElTag:k,ElCard:y,ElSelect:h,ElOption:g,ElDatePicker:b,ElSkeleton:w,FontAwesomeIcon:A},data(){return{OrderState:D,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:D.PENDING,label:this.$t(`order.state.pending`)},{value:D.FINISHED,label:this.$t(`order.state.finished`)},{value:D.PAID,label:this.$t(`order.state.paid`)},{value:D.EXPIRED,label:this.$t(`order.state.expired`)},{value:D.FAILED,label:this.$t(`order.state.failed`)},{value:D.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:O,stateTagType(e){return e===D.FINISHED||e===D.PAID?`success`:e===D.EXPIRED||e===D.FAILED?`danger`:e===D.REFUNDED?`warning`:`info`},stateLabel(e){return{[D.PENDING]:this.$t(`order.state.pending`),[D.PAID]:this.$t(`order.state.paid`),[D.FINISHED]:this.$t(`order.state.finished`),[D.EXPIRED]:this.$t(`order.state.expired`),[D.FAILED]:this.$t(`order.state.failed`),[D.REFUNDED]:this.$t(`order.state.refunded`)}[e]||e},isPendingAction(e){return e!==D.PAID&&e!==D.FINISHED&&e!==D.EXPIRED&&e!==D.FAILED&&e!==D.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,T.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,T.getSummary(this.filterQuery).then(({data:e})=>{this.summary=e}).catch(()=>{this.summary={...M}}).finally(()=>{this.summaryLoading=!1})},onExport(){this.exporting=!0,T.exportCsv(this.filterQuery).then(({data:e})=>{let t=window.URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`orders.csv`,n.click(),window.URL.revokeObjectURL(t)}).catch(()=>{}).finally(()=>{this.exporting=!1})}}}),P={class:`title`},F={key:1,class:`card-content`},I={class:`icon-wrapper`},L={class:`description`},R={class:`value`},z={key:1,class:`card-content`},B={class:`icon-wrapper`},V={class:`description`},H={class:`value`},U={key:1,class:`card-content`},W={class:`icon-wrapper`},ee={class:`description`},G={class:`value`},K={key:1,class:`card-content`},q={class:`icon-wrapper`},J={class:`description`},Y={class:`value`},X={class:`filter-row mb-3`},Z={class:`key`},Q={class:`cursor-pointer`},$={class:`price`},te={class:`description`},ne={class:`text-gray-500`},re={class:`created-at`},ie={class:`flex items-center justify-center flex-wrap`},ae={class:`float-right`};function oe(r,m,h,g,_,v){let y=f(`el-col`),b=f(`el-row`),x=f(`el-skeleton`),S=f(`font-awesome-icon`),C=f(`el-card`),w=f(`el-option`),T=f(`el-select`),E=f(`el-date-picker`),D=f(`el-button`),O=f(`copy-to-clipboard`),k=f(`el-table-column`),A=f(`el-tag`),j=f(`el-table`),M=f(`pagination`),N=d(`loading`);return l(),a(b,{class:`panel`},{default:p(()=>[o(y,{span:24},{default:p(()=>[o(b,null,{default:p(()=>[o(y,{span:24},{default:p(()=>[n(`h2`,P,c(r.$t(`common.title.allOrders`)),1)]),_:1})]),_:1}),o(b,{gutter:16},{default:p(()=>[o(y,{md:6,sm:12,xs:24},{default:p(()=>[o(C,{shadow:`hover`,class:`item-mini mb-3`},{default:p(()=>[r.summaryLoading?(l(),a(x,{key:0})):(l(),t(`div`,F,[n(`div`,I,[o(S,{icon:`fa-solid fa-receipt`,class:`icon`})]),n(`p`,L,c(r.$t(`order.title.totalOrders`)),1),n(`p`,R,c(r.summary.total_count),1)]))]),_:1})]),_:1}),o(y,{md:6,sm:12,xs:24},{default:p(()=>[o(C,{shadow:`hover`,class:`item-mini mb-3`},{default:p(()=>[r.summaryLoading?(l(),a(x,{key:0})):(l(),t(`div`,z,[n(`div`,B,[o(S,{icon:`fa-solid fa-dollar-sign`,class:`icon`})]),n(`p`,V,c(r.$t(`order.title.totalSpent`)),1),n(`p`,H,c(r.getPriceString({value:r.summary.total_spent})),1)]))]),_:1})]),_:1}),o(y,{md:6,sm:12,xs:24},{default:p(()=>[o(C,{shadow:`hover`,class:`item-mini mb-3`},{default:p(()=>[r.summaryLoading?(l(),a(x,{key:0})):(l(),t(`div`,U,[n(`div`,W,[o(S,{icon:`fa-solid fa-check-circle`,class:`icon`})]),n(`p`,ee,c(r.$t(`order.title.finishedOrders`)),1),n(`p`,G,c(r.summary.state_counts?.Finished||0),1)]))]),_:1})]),_:1}),o(y,{md:6,sm:12,xs:24},{default:p(()=>[o(C,{shadow:`hover`,class:`item-mini mb-3`},{default:p(()=>[r.summaryLoading?(l(),a(x,{key:0})):(l(),t(`div`,K,[n(`div`,q,[o(S,{icon:`fa-solid fa-clock`,class:`icon`})]),n(`p`,J,c(r.$t(`order.title.pendingOrders`)),1),n(`p`,Y,c(r.summary.state_counts?.Pending||0),1)]))]),_:1})]),_:1})]),_:1}),n(`div`,X,[o(T,{modelValue:r.filterState,"onUpdate:modelValue":m[0]||=e=>r.filterState=e,clearable:``,placeholder:r.$t(`order.field.allStates`),class:`filter-select`,onChange:r.onFilterChange},{default:p(()=>[(l(!0),t(s,null,e(r.stateOptions,e=>(l(),a(w,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]),o(T,{modelValue:r.filterPayWay,"onUpdate:modelValue":m[1]||=e=>r.filterPayWay=e,clearable:``,placeholder:r.$t(`order.field.allPayWays`),class:`filter-select`,onChange:r.onFilterChange},{default:p(()=>[(l(!0),t(s,null,e(r.payWayOptions,e=>(l(),a(w,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]),o(E,{modelValue:r.createdAtRange,"onUpdate:modelValue":m[2]||=e=>r.createdAtRange=e,type:`datetimerange`,shortcuts:r.shortcuts,"range-separator":r.$t(`usage.placeholder.to`),"start-placeholder":r.$t(`usage.placeholder.startDate`),"end-placeholder":r.$t(`usage.placeholder.endDate`),onChange:r.onFilterChange},null,8,[`modelValue`,`shortcuts`,`range-separator`,`start-placeholder`,`end-placeholder`,`onChange`]),o(D,{type:`primary`,plain:``,loading:r.exporting,onClick:r.onExport},{default:p(()=>[o(S,{icon:`fa-solid fa-file-export`,class:`mr-1`}),i(` `+c(r.$t(`order.button.export`)),1)]),_:1},8,[`loading`,`onClick`])]),o(b,null,{default:p(()=>[o(y,{span:24},{default:p(()=>[o(C,{shadow:`hover`},{default:p(()=>[u((l(),a(j,{data:r.orders,stripe:``,"empty-text":r.$t(`common.message.noData`),class:`min-h-[calc(100vh-450px)] mb-[20px]`},{default:p(()=>[o(k,{prop:`id`,label:r.$t(`order.field.id`),"class-name":`text-center`,width:`200px`},{default:p(e=>[n(`span`,Z,c(e.row.id),1),n(`span`,Q,[o(O,{content:e.row.id,class:`inline-block`},null,8,[`content`])])]),_:1},8,[`label`]),o(k,{label:r.$t(`order.field.price`),width:`110px`,align:`center`},{default:p(e=>[n(`span`,$,c(r.getPriceString({value:e.row?.price})),1)]),_:1},8,[`label`]),o(k,{label:r.$t(`order.field.description`),"min-width":`220px`,"class-name":`hidden md:table-cell`,"label-class-name":`hidden md:table-cell`},{default:p(e=>[n(`span`,te,c(e.row.description),1)]),_:1},8,[`label`]),o(k,{prop:`state`,label:r.$t(`order.field.state`),width:`130px`,align:`center`},{default:p(e=>[o(A,{type:r.stateTagType(e.row.state),class:`mx-1`,effect:`dark`,round:``,size:`small`},{default:p(()=>[i(c(r.stateLabel(e.row.state)),1)]),_:2},1032,[`type`])]),_:1},8,[`label`]),o(k,{label:r.$t(`order.field.payWay`),width:`120px`,align:`center`,"class-name":`hidden md:table-cell`,"label-class-name":`hidden md:table-cell`},{default:p(e=>[n(`span`,ne,c(e.row.pay_way||`-`),1)]),_:1},8,[`label`]),o(k,{label:r.$t(`order.field.createdAt`),width:`200px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:p(e=>[n(`span`,re,c(r.$dayjs.format(e.row.created_at)),1)]),_:1},8,[`label`]),o(k,{"min-width":`130px`,fixed:`right`},{default:p(e=>[n(`div`,ie,[r.isPendingAction(e.row.state)?(l(),a(D,{key:0,type:`primary`,size:`small`,onClick:t=>r.goToDetail(e.row.id)},{default:p(()=>[i(c(r.$t(`order.button.continuePay`)),1)]),_:1},8,[`onClick`])):(l(),a(D,{key:1,size:`small`,onClick:t=>r.goToDetail(e.row.id)},{default:p(()=>[i(c(r.$t(`order.button.checkDetail`)),1)]),_:1},8,[`onClick`]))])]),_:1})]),_:1},8,[`data`,`empty-text`])),[[N,r.loading]])]),_:1})]),_:1})]),_:1}),o(b,null,{default:p(()=>[o(y,{span:10,offset:14},{default:p(()=>[n(`div`,ae,[o(M,{"current-page":r.page,"page-size":r.limit,total:r.total,onChange:r.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var se=E(N,[[`render`,oe],[`__scopeId`,`data-v-350ab467`]]);export{se as default};
@@ -0,0 +1 @@
1
+ import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,k as u,tt as d,ut as f}from"./vendor-chart-BJCvKk8-.js";import{t as p}from"./button-BydTr5nV.js";import{H as m}from"./use-deprecated-B-NFNg3W.js";import{t as h}from"./switch-D1eTmtNv.js";import{A as g,O as _,Zr as v}from"./index-bhnA3ynS.js";import{t as y}from"./index.es-BK9VjfWt.js";var b=r({name:`LocalToolsSetting`,components:{ElButton:p,ElTag:v,ElSwitch:h,FontAwesomeIcon:y},data(){return{Plus:m,roots:[],tools:[],grants:null,perm:null,computerUse:!1,savingCU:!1,saving:!1,savedTip:!1,cuOff:null}},computed:{desktop(){return!!g()}},async mounted(){let e=g();if(!e)return;let t=await e.getConfig();this.roots=t.roots,this.computerUse=t.computerUse===!0,this.tools=(await e.listTools()).map(e=>e.name);let n=await e.perm?.status();n?.mac&&(this.perm=n),await this.loadGrants(),this.cuOff=e.onComputerUseDisabled?.(()=>{this.computerUse=!1})??null},beforeUnmount(){this.cuOff?.()},methods:{async loadGrants(){let e=g();if(!e?.grants){this.grants=null;return}let t=await e.grants.list();this.grants=t.map(e=>{let t=e.indexOf(`:{`),n=t>=0?t:e.indexOf(`:`);return{key:e,name:n>=0?e.slice(0,n):e,input:n>=0?e.slice(n+1):``}})},async addFolder(){let e=await g()?.pickFolder();e&&!this.roots.includes(e)&&this.roots.push(e)},removeRoot(e){this.roots.splice(e,1)},async open(e){await g()?.perm?.openPane(e)},async save(){this.saving=!0;let e=await g()?.getConfig();await g()?.saveConfig({roots:this.roots,mcp:e?.mcp??[],computerUse:this.computerUse}),this.saving=!1,this.savedTip=!0,setTimeout(()=>this.savedTip=!1,2e3)},async onToggleComputerUse(e){this.savingCU=!0;let t=await g()?.getConfig();await g()?.saveConfig({roots:t?.roots??this.roots,mcp:t?.mcp??[],computerUse:e===!0}),this.savingCU=!1},async revoke(e){await g()?.grants?.revoke(e),await this.loadGrants()},async revokeAll(){await g()?.grants?.clear(),await this.loadGrants()}}}),x={class:`settings-list local-tools-setting`},S={key:0,class:`hint muted`},C={class:`section-head`},w={class:`muted`},T={class:`rows`},E={class:`path`},D={key:0,class:`row muted empty`},O={class:`actions`},k={key:0,class:`muted saved-tip`},A={key:0,class:`muted tools`},j={key:0},M={class:`section-head`},N={class:`muted`},P={class:`rows`},F={class:`grant`},I={class:`grant-name`},L={class:`grant-input`},R={key:0,class:`row muted empty`},z={class:`section-head`},B={class:`muted`},V={key:1},H={class:`section-head`},U={class:`muted`},W={class:`perm-row`},G={class:`perm-name`},K={class:`perm-row`},q={class:`perm-name`},J={class:`perm-row`},Y={class:`perm-name`};function X(r,p,m,h,g,_){let v=d(`el-button`),y=d(`font-awesome-icon`),b=d(`el-switch`),X=d(`el-tag`);return l(),t(`div`,x,[r.desktop?(l(),t(s,{key:1},[n(`section`,null,[n(`div`,C,[n(`h3`,null,c(r.$t(`common.settings.localToolsFoldersTitle`)),1),o(v,{size:`small`,type:`primary`,icon:r.Plus,onClick:r.addFolder},{default:f(()=>[i(c(r.$t(`common.settings.localToolsAddFolder`)),1)]),_:1},8,[`icon`,`onClick`])]),n(`p`,w,c(r.$t(`common.settings.localToolsFoldersHint`)),1),n(`ul`,T,[(l(!0),t(s,null,e(r.roots,(e,a)=>(l(),t(`li`,{key:e,class:`row`},[o(y,{icon:`fa-solid fa-folder`,class:`row-icon`}),n(`span`,E,c(e),1),o(v,{size:`small`,text:``,type:`danger`,onClick:e=>r.removeRoot(a)},{default:f(()=>[i(c(r.$t(`common.settings.localToolsRemove`)),1)]),_:1},8,[`onClick`])]))),128)),r.roots.length?u(``,!0):(l(),t(`li`,D,c(r.$t(`common.settings.localToolsNoFolders`)),1))]),n(`div`,O,[o(v,{size:`small`,type:`primary`,loading:r.saving,onClick:r.save},{default:f(()=>[i(c(r.$t(`common.settings.localToolsSave`)),1)]),_:1},8,[`loading`,`onClick`]),r.savedTip?(l(),t(`span`,k,c(r.$t(`common.settings.localToolsSaved`)),1)):u(``,!0)]),r.tools.length?(l(),t(`p`,A,c(r.$t(`common.settings.localToolsActiveTools`))+`: `+c(r.tools.join(`, `)),1)):u(``,!0)]),r.grants===null?u(``,!0):(l(),t(`section`,j,[n(`div`,M,[n(`h3`,null,c(r.$t(`common.settings.localToolsGrantsTitle`)),1),r.grants.length?(l(),a(v,{key:0,size:`small`,text:``,type:`danger`,onClick:r.revokeAll},{default:f(()=>[i(c(r.$t(`common.settings.localToolsRevokeAll`)),1)]),_:1},8,[`onClick`])):u(``,!0)]),n(`p`,N,c(r.$t(`common.settings.localToolsGrantsHint`)),1),n(`ul`,P,[(l(!0),t(s,null,e(r.grants,e=>(l(),t(`li`,{key:e.key,class:`row`},[o(y,{icon:`fa-solid fa-shield-halved`,class:`row-icon`}),n(`span`,F,[n(`code`,I,c(e.name),1),n(`span`,L,c(e.input),1)]),o(v,{size:`small`,type:`danger`,onClick:t=>r.revoke(e.key)},{default:f(()=>[i(c(r.$t(`common.settings.localToolsRevoke`)),1)]),_:1},8,[`onClick`])]))),128)),r.grants.length?u(``,!0):(l(),t(`li`,R,c(r.$t(`common.settings.localToolsNoGrants`)),1))])])),n(`section`,null,[n(`div`,z,[n(`h3`,null,c(r.$t(`common.settings.localToolsComputerUseTitle`)),1),o(b,{modelValue:r.computerUse,"onUpdate:modelValue":p[0]||=e=>r.computerUse=e,loading:r.savingCU,onChange:r.onToggleComputerUse},null,8,[`modelValue`,`loading`,`onChange`])]),n(`p`,B,c(r.$t(`common.settings.localToolsComputerUseHint`)),1)]),r.perm?(l(),t(`section`,V,[n(`div`,H,[n(`h3`,null,c(r.$t(`common.settings.localToolsPermsTitle`)),1)]),n(`p`,U,c(r.$t(`common.settings.localToolsPermsHint`)),1),n(`div`,W,[n(`span`,G,c(r.$t(`common.settings.localToolsPermFullDisk`)),1),o(X,{size:`small`,type:r.perm.fullDisk?`success`:`info`,effect:`plain`},{default:f(()=>[i(c(r.perm.fullDisk?r.$t(`common.settings.localToolsGranted`):r.$t(`common.settings.localToolsNotGranted`)),1)]),_:1},8,[`type`]),o(v,{size:`small`,type:`primary`,onClick:p[1]||=e=>r.open(`fullDisk`)},{default:f(()=>[i(c(r.$t(`common.settings.localToolsOpen`)),1)]),_:1})]),n(`div`,K,[n(`span`,q,c(r.$t(`common.settings.localToolsPermScreen`)),1),o(X,{size:`small`,type:r.perm.screen===`granted`?`success`:`info`,effect:`plain`},{default:f(()=>[i(c(r.perm.screen===`granted`?r.$t(`common.settings.localToolsGranted`):r.$t(`common.settings.localToolsNotGranted`)),1)]),_:1},8,[`type`]),o(v,{size:`small`,type:`primary`,onClick:p[2]||=e=>r.open(`screen`)},{default:f(()=>[i(c(r.$t(`common.settings.localToolsOpen`)),1)]),_:1})]),n(`div`,J,[n(`span`,Y,c(r.$t(`common.settings.localToolsPermAccessibility`)),1),o(X,{size:`small`,type:r.perm.accessibility?`success`:`info`,effect:`plain`},{default:f(()=>[i(c(r.perm.accessibility?r.$t(`common.settings.localToolsGranted`):r.$t(`common.settings.localToolsNotGranted`)),1)]),_:1},8,[`type`]),o(v,{size:`small`,type:`primary`,onClick:p[3]||=e=>r.open(`accessibility`)},{default:f(()=>[i(c(r.$t(`common.settings.localToolsOpen`)),1)]),_:1})])])):u(``,!0)],64)):(l(),t(`p`,S,c(r.$t(`common.settings.localToolsDesktopOnly`)),1))])}var Z=_(b,[[`render`,X],[`__scopeId`,`data-v-62db9096`]]);export{Z as t};
@@ -0,0 +1 @@
1
+ .local-tools-setting[data-v-62db9096]{flex-direction:column;gap:28px;display:flex}.section-head[data-v-62db9096]{justify-content:space-between;align-items:center;gap:12px;display:flex}.section-head h3[data-v-62db9096]{margin:0;font-size:15px;font-weight:600}.muted[data-v-62db9096]{color:var(--el-text-color-secondary,#909399);margin:6px 0 10px;font-size:13px}.rows[data-v-62db9096]{border:1px solid var(--el-border-color-lighter,#ebeef5);border-radius:8px;margin:0;padding:0;list-style:none;overflow:hidden}.row[data-v-62db9096]{border-bottom:1px solid var(--el-border-color-lighter,#ebeef5);align-items:center;gap:10px;padding:10px 12px;display:flex}.rows .row[data-v-62db9096]:last-child{border-bottom:none}.row.empty[data-v-62db9096]{justify-content:center;padding:16px}.row-icon[data-v-62db9096]{color:var(--el-text-color-secondary,#909399);flex-shrink:0}.path[data-v-62db9096],.grant[data-v-62db9096]{word-break:break-all;flex:1;font-size:13px}.grant[data-v-62db9096]{flex-direction:column;gap:2px;display:flex}.grant-name[data-v-62db9096]{font-weight:600}.grant-input[data-v-62db9096]{color:var(--el-text-color-secondary,#909399);word-break:break-all;font-size:12px}.actions[data-v-62db9096]{align-items:center;gap:12px;margin-top:12px;display:flex}.saved-tip[data-v-62db9096]{margin:0}.tools[data-v-62db9096]{margin-top:12px}.perm-row[data-v-62db9096]{align-items:center;gap:12px;padding:8px 0;display:flex}.perm-name[data-v-62db9096]{flex:1;font-size:14px}
@@ -1 +1 @@
1
- import{A as e,D as t,F as n,P as r,Wt as i,Z as a,tt as o}from"./vendor-chart-BJCvKk8-.js";import{O as s}from"./index-DwgDCJZs.js";import{t as c}from"./LocalTools-CN_Ci76o.js";var l=n({name:`SettingsLocalTools`,components:{LocalToolsSetting:c}}),u={class:`local-tools-page`};function d(n,s,c,l,d,f){let p=o(`local-tools-setting`);return a(),e(`div`,u,[t(`h2`,null,i(n.$t(`common.settings.localTools`)),1),r(p)])}var f=s(l,[[`render`,d],[`__scopeId`,`data-v-ac732814`]]);export{f as default};
1
+ import{A as e,D as t,F as n,P as r,Wt as i,Z as a,tt as o}from"./vendor-chart-BJCvKk8-.js";import{O as s}from"./index-bhnA3ynS.js";import{t as c}from"./LocalTools-BK5uJNyi.js";var l=n({name:`SettingsLocalTools`,components:{LocalToolsSetting:c}}),u={class:`local-tools-page`};function d(n,s,c,l,d,f){let p=o(`local-tools-setting`);return a(),e(`div`,u,[t(`h2`,null,i(n.$t(`common.settings.localTools`)),1),r(p)])}var f=s(l,[[`render`,d],[`__scopeId`,`data-v-ac732814`]]);export{f as default};
@@ -1 +1 @@
1
- import"./rolldown-runtime--c01j_DQ.js";import{A as e,D as t,E as n,F as r,N as i,O as a,P as o,Wt as s,Z as c,k as l,tt as u,ut as d}from"./vendor-chart-BJCvKk8-.js";import{t as f}from"./button-BydTr5nV.js";import{t as p}from"./Navigator-UC-XfU0f.js";import{t as m}from"./checkbox-BC1X4B2U.js";import{t as h}from"./divider-LA__Fty9.js";import"./constants-NMxtQUbk.js";import{Ar as g,Ht as _,Ir as v,Kr as y,Nr as b,O as x,Un as S,Yr as C,jr as w}from"./index-DwgDCJZs.js";import{t as T}from"./Status-DoQ01e65.js";var E=r({name:`ApplicationConfirm`,components:{ElDialog:C,ElDivider:h,ElCheckbox:m,ElButton:f},props:{visible:{type:Boolean,required:!1,default:!1}},emits:[`update:visible`,`apply`],data(){return{checked:!0}},watch:{},methods:{getBaseUrlPlatform:v,onApply(){if(!this.checked){y.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(e,n,r,l,f,p){let m=u(`el-divider`),h=u(`el-checkbox`),g=u(`el-button`),_=u(`el-dialog`);return c(),a(_,{"model-value":e.visible,width:`500px`,title:e.$t(`application.message.welcome`),center:``,onClose:n[1]||=t=>e.$emit(`update:visible`,!1)},{default:d(()=>[t(`div`,D,[t(`p`,O,s(e.$t(`application.message.notApplied`)),1),o(m,{class:`my-2`}),t(`div`,k,[o(h,{modelValue:e.checked,"onUpdate:modelValue":n[0]||=t=>e.checked=t,size:`large`,class:`policy-checkbox mr-[10px]`},null,8,[`modelValue`]),t(`span`,A,s(e.$t(`application.message.readPolicy`)),1),t(`a`,{class:`policy-title text-[12px] relative -bottom-[3px] text-[var(--el-color-primary)] cursor-pointer no-underline`,target:`_blank`,href:e.getBaseUrlPlatform()+`/terms`},` \xA0`+s(e.$t(`application.message.policy`)),9,j)]),o(g,{round:``,type:`primary`,onClick:e.onApply},{default:d(()=>[i(s(e.$t(`common.button.start`)),1)]),_:1},8,[`onClick`])])]),_:1},8,[`model-value`,`title`])}var N=x(E,[[`render`,M]]),P=15e3,F=r({name:`LayoutMain`,components:{Navigator:p,ApplicationStatus:T,ApplicationConfirm:N},provide(){return{initialized:n(()=>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===b.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,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=_(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 S.create({type:w.USAGE,scope:g.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`):y.error(this.$t(`application.message.applyFailed`))}},showWelcomeToast(){let e=this.$store.state.applications?.[0],t=Math.floor(e?.remaining_amount??0);y({message:t>0?this.$t(`application.message.welcomeWithCredits`,{credits:t}):this.$t(`application.message.welcomeNoCredits`),type:`success`,duration:6e3,showClose:!0})}}}),I={class:`wrapper`};function L(t,n,r,i,s,d){let f=u(`router-view`),p=u(`navigator`),m=u(`application-status`),h=u(`application-confirm`);return c(),e(`div`,I,[o(f,{class:`main`}),o(p,{class:`navigator`,direction:t.mobile?`row`:`column`},null,8,[`direction`]),t.application?(c(),a(m,{key:0,class:`status-floating fixed right-2 z-[200]`,application:t.application,applications:t.applications,"show-price":!1,authenticated:!!t.$store.state.token.access,service:t.service,onSelect:n[0]||=e=>t.$store.dispatch(`${t.appName}/setApplication`,e)},null,8,[`application`,`applications`,`authenticated`,`service`])):l(``,!0),o(h,{modelValue:t.applying,"onUpdate:modelValue":n[1]||=e=>t.applying=e,modelModifiers:{visible:!0},onApply:t.onApply},null,8,[`modelValue`,`onApply`])])}var R=x(F,[[`render`,L],[`__scopeId`,`data-v-f14707c1`]]);export{R as default};
1
+ import"./rolldown-runtime--c01j_DQ.js";import{A as e,D as t,E as n,F as r,N as i,O as a,P as o,Wt as s,Z as c,k as l,tt as u,ut as d}from"./vendor-chart-BJCvKk8-.js";import{t as f}from"./button-BydTr5nV.js";import{t as p}from"./Navigator-Cu_gtqFU.js";import{t as m}from"./checkbox-BC1X4B2U.js";import{t as h}from"./divider-LA__Fty9.js";import"./constants-NMxtQUbk.js";import{Ar as g,Ht as _,Ir as v,Kr as y,Nr as b,O as x,Un as S,Yr as C,jr as w}from"./index-bhnA3ynS.js";import{t as T}from"./Status-IWlNaZuC.js";var E=r({name:`ApplicationConfirm`,components:{ElDialog:C,ElDivider:h,ElCheckbox:m,ElButton:f},props:{visible:{type:Boolean,required:!1,default:!1}},emits:[`update:visible`,`apply`],data(){return{checked:!0}},watch:{},methods:{getBaseUrlPlatform:v,onApply(){if(!this.checked){y.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(e,n,r,l,f,p){let m=u(`el-divider`),h=u(`el-checkbox`),g=u(`el-button`),_=u(`el-dialog`);return c(),a(_,{"model-value":e.visible,width:`500px`,title:e.$t(`application.message.welcome`),center:``,onClose:n[1]||=t=>e.$emit(`update:visible`,!1)},{default:d(()=>[t(`div`,D,[t(`p`,O,s(e.$t(`application.message.notApplied`)),1),o(m,{class:`my-2`}),t(`div`,k,[o(h,{modelValue:e.checked,"onUpdate:modelValue":n[0]||=t=>e.checked=t,size:`large`,class:`policy-checkbox mr-[10px]`},null,8,[`modelValue`]),t(`span`,A,s(e.$t(`application.message.readPolicy`)),1),t(`a`,{class:`policy-title text-[12px] relative -bottom-[3px] text-[var(--el-color-primary)] cursor-pointer no-underline`,target:`_blank`,href:e.getBaseUrlPlatform()+`/terms`},` \xA0`+s(e.$t(`application.message.policy`)),9,j)]),o(g,{round:``,type:`primary`,onClick:e.onApply},{default:d(()=>[i(s(e.$t(`common.button.start`)),1)]),_:1},8,[`onClick`])])]),_:1},8,[`model-value`,`title`])}var N=x(E,[[`render`,M]]),P=15e3,F=r({name:`LayoutMain`,components:{Navigator:p,ApplicationStatus:T,ApplicationConfirm:N},provide(){return{initialized:n(()=>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===b.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,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=_(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 S.create({type:w.USAGE,scope:g.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`):y.error(this.$t(`application.message.applyFailed`))}},showWelcomeToast(){let e=this.$store.state.applications?.[0],t=Math.floor(e?.remaining_amount??0);y({message:t>0?this.$t(`application.message.welcomeWithCredits`,{credits:t}):this.$t(`application.message.welcomeNoCredits`),type:`success`,duration:6e3,showClose:!0})}}}),I={class:`wrapper`};function L(t,n,r,i,s,d){let f=u(`router-view`),p=u(`navigator`),m=u(`application-status`),h=u(`application-confirm`);return c(),e(`div`,I,[o(f,{class:`main`}),o(p,{class:`navigator`,direction:t.mobile?`row`:`column`},null,8,[`direction`]),t.application?(c(),a(m,{key:0,class:`status-floating fixed right-2 z-[200]`,application:t.application,applications:t.applications,"show-price":!1,authenticated:!!t.$store.state.token.access,service:t.service,onSelect:n[0]||=e=>t.$store.dispatch(`${t.appName}/setApplication`,e)},null,8,[`application`,`applications`,`authenticated`,`service`])):l(``,!0),o(h,{modelValue:t.applying,"onUpdate:modelValue":n[1]||=e=>t.applying=e,modelModifiers:{visible:!0},onApply:t.onApply},null,8,[`modelValue`,`onApply`])])}var R=x(F,[[`render`,L],[`__scopeId`,`data-v-f14707c1`]]);export{R as default};
@@ -1 +1 @@
1
- import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Vt as c,Wt as l,Z as u,b as d,k as f,tt as p,ut as m}from"./vendor-chart-BJCvKk8-.js";import{t as h}from"./button-BydTr5nV.js";import{t as g}from"./upload-pKKwbKaB.js";import{t as _}from"./image-BPVgaSAh.js";import{t as v}from"./alert-CuX4SjQB.js";import{n as y,r as b}from"./radio-3Hz7h3DR.js";import{t as x}from"./switch-BWI_Zh-b.js";import{t as S}from"./vendor-axios-Ck2ffRoh.js";import"./constants-NMxtQUbk.js";import{$r as C,Ir as w,Kr as T,O as E,in as D,tt as ee,zt as te}from"./index-DwgDCJZs.js";import{t as O}from"./index.es-DMwpJkVk.js";import{t as k}from"./CopyToClipboard-BM4VvfdY.js";import{t as A}from"./BotPlaceholder-B8PNfxso.js";import{t as j}from"./Hailuo-esWUB2SE.js";import{t as M}from"./TabSwitcher-D8ioaRcC.js";var N=4,P=90,F=r({name:`FishRecorder`,components:{ElButton:h,FontAwesomeIcon:O},emits:[`done`,`cancel`,`update:script`],data(){return{state:`idle`,scriptIndex:0,seconds:0,timerId:0,maxTimerId:0,mediaRecorder:null,stream:null,chunks:[],recordedBlob:null,recordedUrl:``,uploading:!1}},computed:{formattedTime(){let e=Math.floor(this.seconds/60),t=this.seconds%60;return`${e.toString().padStart(2,`0`)}:${t.toString().padStart(2,`0`)}`},currentScript(){let e=`fish.script.passage${this.scriptIndex%N+1}`;return this.$t(e)}},beforeUnmount(){this.cleanup()},mounted(){this.$emit(`update:script`,this.currentScript)},methods:{nextScript(){this.scriptIndex=(this.scriptIndex+1)%N,this.$emit(`update:script`,this.currentScript)},async startRecord(){if(!navigator.mediaDevices?.getUserMedia||typeof MediaRecorder>`u`){T.error(this.$t(`fish.message.recorderUnsupported`));return}try{this.stream=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(e){let t=e?.name===`NotAllowedError`||e?.name===`PermissionDeniedError`;T.error(this.$t(t?`fish.message.micDenied`:`fish.message.micError`));return}this.chunks=[];let e=this.pickMimeType();try{this.mediaRecorder=e?new MediaRecorder(this.stream,{mimeType:e}):new MediaRecorder(this.stream)}catch{this.mediaRecorder=new MediaRecorder(this.stream)}this.mediaRecorder.ondataavailable=e=>{e.data&&e.data.size>0&&this.chunks.push(e.data)},this.mediaRecorder.onstop=()=>{let e=new Blob(this.chunks,{type:this.mediaRecorder?.mimeType||`audio/webm`});this.recordedBlob=e,this.recordedUrl=URL.createObjectURL(e),this.state=`recorded`,this.releaseStream()},this.mediaRecorder.start(),this.state=`recording`,this.seconds=0,this.timerId=window.setInterval(()=>{this.seconds++},1e3),this.maxTimerId=window.setTimeout(()=>{this.state===`recording`&&this.stopRecord()},P*1e3)},stopRecord(){this.mediaRecorder&&this.mediaRecorder.state!==`inactive`&&this.mediaRecorder.stop(),window.clearInterval(this.timerId),window.clearTimeout(this.maxTimerId)},reset(){this.recordedUrl&&URL.revokeObjectURL(this.recordedUrl),this.recordedUrl=``,this.recordedBlob=null,this.state=`idle`,this.seconds=0},onCancel(){this.cleanup(),this.$emit(`cancel`)},cleanup(){this.stopRecord(),this.releaseStream(),this.recordedUrl&&URL.revokeObjectURL(this.recordedUrl)},releaseStream(){this.stream?.getTracks().forEach(e=>e.stop()),this.stream=null},pickMimeType(){for(let e of[`audio/webm;codecs=opus`,`audio/webm`,`audio/mp4`,`audio/ogg`])if(typeof MediaRecorder<`u`&&MediaRecorder.isTypeSupported?.(e))return e},extensionForMime(e){return e.includes(`webm`)?`webm`:e.includes(`mp4`)?`m4a`:e.includes(`ogg`)?`ogg`:e.includes(`wav`)?`wav`:`mp3`},async useRecording(){if(this.recordedBlob){if(this.seconds<3){T.warning(this.$t(`fish.message.recordingTooShort`));return}this.uploading=!0;try{let e=this.$store.state.token?.access,t=this.extensionForMime(this.recordedBlob.type||``),n=new File([this.recordedBlob],`recording-${Date.now()}.${t}`,{type:this.recordedBlob.type||`audio/webm`}),r=new FormData;r.append(`file`,n);let{data:i}=await S.post(`${w()}/api/v1/files/`,r,{headers:{Authorization:`Bearer ${e}`}}),a=i?.file_url;if(!a){T.error(this.$t(`fish.message.uploadError`));return}this.$emit(`done`,{url:a,text:this.currentScript})}catch(e){T.error(this.$t(`fish.message.uploadError`)),console.error(`recorder upload failed`,e)}finally{this.uploading=!1}}}}}),I={class:`recorder`},L={key:0,class:`script`},R={class:`script-header`},z={class:`label`},B={class:`script-text`},V={class:`controls`},H={class:`status`},U={class:`hint`},W={key:1,class:`preview`},G=[`src`],K={class:`preview-actions`},q={class:`footer`};function J(e,r,s,d,h,g){let _=p(`font-awesome-icon`),v=p(`el-button`);return u(),t(`div`,I,[e.state===`recorded`?f(``,!0):(u(),t(`div`,L,[n(`div`,R,[o(_,{icon:`fa-solid fa-book-open`,class:`icon mr-1`}),n(`span`,z,l(e.$t(`fish.description.readScript`)),1),o(v,{link:``,size:`small`,class:`ml-auto`,disabled:e.state===`recording`,onClick:e.nextScript},{default:m(()=>[o(_,{icon:`fa-solid fa-shuffle`,class:`mr-1`}),i(` `+l(e.$t(`fish.button.nextScript`)),1)]),_:1},8,[`disabled`,`onClick`])]),n(`p`,B,l(e.currentScript),1)])),n(`div`,V,[e.state===`idle`?(u(),a(v,{key:0,type:`danger`,circle:``,size:`large`,title:e.$t(`fish.button.startRecord`),onClick:e.startRecord},{default:m(()=>[o(_,{icon:`fa-solid fa-microphone`})]),_:1},8,[`title`,`onClick`])):e.state===`recording`?(u(),a(v,{key:1,type:`warning`,circle:``,size:`large`,title:e.$t(`fish.button.stopRecord`),onClick:e.stopRecord},{default:m(()=>[o(_,{icon:`fa-solid fa-stop`})]),_:1},8,[`title`,`onClick`])):f(``,!0),n(`div`,H,[n(`span`,{class:c([`timer`,e.state===`recording`?`live`:``])},l(e.formattedTime),3),n(`span`,U,l(e.state===`idle`?e.$t(`fish.description.recorderIdle`):e.state===`recording`?e.$t(`fish.description.recorderRecording`):e.$t(`fish.description.recorderRecorded`)),1)])]),e.state===`recorded`&&e.recordedUrl?(u(),t(`div`,W,[n(`audio`,{src:e.recordedUrl,controls:``,preload:`metadata`,class:`w-full`},null,8,G),n(`div`,K,[o(v,{size:`small`,disabled:e.uploading,onClick:e.reset},{default:m(()=>[o(_,{icon:`fa-solid fa-rotate-left`,class:`mr-1`}),i(` `+l(e.$t(`fish.button.reRecord`)),1)]),_:1},8,[`disabled`,`onClick`]),o(v,{size:`small`,type:`primary`,loading:e.uploading,onClick:e.useRecording},{default:m(()=>[o(_,{icon:`fa-solid fa-check`,class:`mr-1`}),i(` `+l(e.$t(`fish.button.useRecording`)),1)]),_:1},8,[`loading`,`onClick`])])])):f(``,!0),n(`div`,q,[o(v,{link:``,size:`small`,disabled:e.uploading||e.state===`recording`,onClick:e.onCancel},{default:m(()=>[i(l(e.$t(`fish.button.cancel`)),1)]),_:1},8,[`disabled`,`onClick`])])])}var Y=E(F,[[`render`,J],[`__scopeId`,`data-v-1958e4a1`]]),X=50*1024*1024,Z=()=>({title:``,description:``,texts:``,voicesUrl:``,visibility:`unlist`,trainMode:`fast`,enhanceAudio:!0,generateSample:!1}),Q=r({name:`FishModelConfigPanel`,components:{ElButton:h,ElInput:C,ElRadioButton:y,ElRadioGroup:b,ElSwitch:x,ElUpload:g,FontAwesomeIcon:O,Recorder:Y},mixins:[te],emits:[`create`],data(){return{form:Z(),fileList:[],uploading:!1,creating:!1,recording:!1,textsAuto:!0}},computed:{uploadUrl(){return w()+`/api/v1/files/`},uploadHeaders(){return{Authorization:`Bearer ${this.$store.state.token?.access}`}},canCreate(){return!!this.form.title.trim()&&!!this.form.voicesUrl&&!this.uploading&&!this.creating},supportsRecorder(){return!!(typeof navigator<`u`?navigator.mediaDevices:void 0)?.getUserMedia&&typeof MediaRecorder<`u`}},methods:{onBeforeUpload(e){return e.size>X?(T.warning(this.$t(`fish.message.audioSizeExceed`)),!1):(this.uploading=!0,!0)},onExceed(){T.warning(this.$t(`fish.message.audioOnlyOne`))},onUploadError(){this.uploading=!1,T.error(this.$t(`fish.message.uploadError`))},onUploadSuccess(e,t,n){this.uploading=!1;let r=e?.file_url;if(!r){T.error(this.$t(`fish.message.uploadError`)),this.fileList=[];return}this.form.voicesUrl=r,this.fileList=n},onRecorded(e){this.form.voicesUrl=e.url,this.recording=!1,e.text&&this.textsAuto&&(this.form.texts=e.text)},onStartRecord(){this.recording=!0,this.textsAuto=!this.form.texts.trim()},onScriptChange(e){this.textsAuto&&this.recording&&(this.form.texts=e)},onTextsInput(){this.textsAuto=!1},clearAudio(){this.form.voicesUrl=``,this.fileList=[]},onCreate(){let e=this.form.title.trim();if(!e){T.warning(this.$t(`fish.message.titleRequired`));return}if(!this.form.voicesUrl){T.warning(this.$t(`fish.message.audioRequired`));return}let t={title:e,voices:this.form.voicesUrl,visibility:this.form.visibility,train_mode:this.form.trainMode,enhance_audio_quality:this.form.enhanceAudio,generate_sample:this.form.generateSample};this.form.description.trim()&&(t.description=this.form.description.trim()),this.form.texts.trim()&&(t.texts=[this.form.texts.trim()]),this.creating=!0,this.$emit(`create`,t),setTimeout(()=>{this.creating=!1,this.form=Z(),this.fileList=[]},600)}}}),ne={class:`flex flex-col h-full`},re={class:`flex-1 overflow-y-auto p-5`},ie={class:`field-block mb-4`},ae={class:`title font-bold`},oe={class:`field-block mb-4`},se={class:`flex items-baseline justify-between mb-1`},ce={class:`title font-bold`},le={key:0,class:`muted`},ue={class:`hint`},de={key:0,class:`audio-actions`},fe={key:1,class:`hint warn`},pe={key:3,class:`mt-2`},me=[`src`],he={class:`ready-actions`},ge={class:`field-block mb-4`},_e={class:`title font-bold`},ve={class:`hint`},ye={class:`field-block mb-4`},be={class:`title font-bold`},xe={class:`field-block mb-4`},Se={class:`title font-bold`},Ce={class:`field-block mb-4`},we={class:`title font-bold`},Te={class:`field-block mb-3`},Ee={class:`field-row`},De={class:`title font-bold`},Oe={class:`hint mt-0 mb-0`},ke={class:`field-block mb-2`},Ae={class:`field-row`},je={class:`title font-bold`},Me={class:`hint mt-0 mb-0`},Ne={class:`flex flex-col items-center justify-center px-5 pb-5`};function Pe(e,r,s,c,d,h){let g=p(`el-input`),_=p(`font-awesome-icon`),v=p(`el-button`),y=p(`el-upload`),b=p(`recorder`),x=p(`el-radio-button`),S=p(`el-radio-group`),C=p(`el-switch`);return u(),t(`div`,ne,[n(`div`,re,[n(`div`,ie,[n(`h2`,ae,[i(l(e.$t(`fish.name.voiceTitle`))+` `,1),r[9]||=n(`span`,{class:`required`},`*`,-1)]),o(g,{modelValue:e.form.title,"onUpdate:modelValue":r[0]||=t=>e.form.title=t,placeholder:e.$t(`fish.placeholder.voiceTitle`),maxlength:`60`},null,8,[`modelValue`,`placeholder`])]),n(`div`,oe,[n(`div`,se,[n(`h2`,ce,[i(l(e.$t(`fish.name.referenceAudio`))+` `,1),r[10]||=n(`span`,{class:`required`},`*`,-1)]),!e.form.voicesUrl&&!e.recording?(u(),t(`span`,le,l(e.$t(`fish.description.audioRequired`)),1)):f(``,!0)]),n(`p`,ue,l(e.$t(`fish.description.uploadAudio`)),1),!e.form.voicesUrl&&!e.recording?(u(),t(`div`,de,[o(y,{"file-list":e.fileList,"onUpdate:fileList":r[1]||=t=>e.fileList=t,name:`file`,limit:1,class:`upload-wrapper`,action:e.uploadUrl,accept:`.mp3,.wav,.m4a,.ogg,.webm,audio/*`,"show-file-list":!1,"on-exceed":e.onExceed,"on-error":e.onUploadError,"on-success":e.onUploadSuccess,"before-upload":e.onBeforeUpload,headers:e.uploadHeaders},{default:m(()=>[o(v,{type:`primary`,plain:``,round:``,loading:e.uploading},{default:m(()=>[o(_,{icon:`fa-solid fa-upload`,class:`icon mr-1`}),i(` `+l(e.$t(`fish.button.uploadAudio`)),1)]),_:1},8,[`loading`])]),_:1},8,[`file-list`,`action`,`on-exceed`,`on-error`,`on-success`,`before-upload`,`headers`]),o(v,{type:`primary`,round:``,disabled:!e.supportsRecorder,onClick:e.onStartRecord},{default:m(()=>[o(_,{icon:`fa-solid fa-microphone`,class:`icon mr-1`}),i(` `+l(e.$t(`fish.button.recordAudio`)),1)]),_:1},8,[`disabled`,`onClick`])])):f(``,!0),!e.supportsRecorder&&!e.form.voicesUrl&&!e.recording?(u(),t(`p`,fe,l(e.$t(`fish.message.recorderUnsupported`)),1)):f(``,!0),e.recording?(u(),a(b,{key:2,class:`mt-2`,onDone:e.onRecorded,onCancel:r[2]||=t=>e.recording=!1,"onUpdate:script":e.onScriptChange},null,8,[`onDone`,`onUpdate:script`])):f(``,!0),e.form.voicesUrl&&!e.recording?(u(),t(`div`,pe,[n(`audio`,{src:e.form.voicesUrl,controls:``,preload:`metadata`,class:`w-full`},null,8,me),n(`div`,he,[o(v,{link:``,size:`small`,onClick:e.clearAudio},{default:m(()=>[o(_,{icon:`fa-solid fa-rotate-left`,class:`mr-1`}),i(` `+l(e.$t(`fish.button.replaceAudio`)),1)]),_:1},8,[`onClick`])])])):f(``,!0)]),n(`div`,ge,[n(`h2`,_e,l(e.$t(`fish.name.audioTexts`)),1),n(`p`,ve,l(e.$t(`fish.description.audioTexts`)),1),o(g,{modelValue:e.form.texts,"onUpdate:modelValue":r[3]||=t=>e.form.texts=t,type:`textarea`,rows:2,placeholder:e.$t(`fish.placeholder.audioTexts`),maxlength:`500`,onInput:e.onTextsInput},null,8,[`modelValue`,`placeholder`,`onInput`])]),n(`div`,ye,[n(`h2`,be,l(e.$t(`fish.name.voiceDescription`)),1),o(g,{modelValue:e.form.description,"onUpdate:modelValue":r[4]||=t=>e.form.description=t,type:`textarea`,rows:2,placeholder:e.$t(`fish.placeholder.voiceDescription`),maxlength:`500`},null,8,[`modelValue`,`placeholder`])]),n(`div`,xe,[n(`h2`,Se,l(e.$t(`fish.name.visibility`)),1),o(S,{modelValue:e.form.visibility,"onUpdate:modelValue":r[5]||=t=>e.form.visibility=t,size:`small`},{default:m(()=>[o(x,{label:`private`,value:`private`},{default:m(()=>[i(l(e.$t(`fish.value.private`)),1)]),_:1}),o(x,{label:`unlist`,value:`unlist`},{default:m(()=>[i(l(e.$t(`fish.value.unlist`)),1)]),_:1}),o(x,{label:`public`,value:`public`},{default:m(()=>[i(l(e.$t(`fish.value.public`)),1)]),_:1})]),_:1},8,[`modelValue`])]),n(`div`,Ce,[n(`h2`,we,l(e.$t(`fish.name.trainMode`)),1),o(S,{modelValue:e.form.trainMode,"onUpdate:modelValue":r[6]||=t=>e.form.trainMode=t,size:`small`},{default:m(()=>[o(x,{label:`fast`,value:`fast`},{default:m(()=>[i(l(e.$t(`fish.value.trainModeFast`)),1)]),_:1}),o(x,{label:`precise`,value:`precise`},{default:m(()=>[i(l(e.$t(`fish.value.trainModePrecise`)),1)]),_:1})]),_:1},8,[`modelValue`])]),n(`div`,Te,[n(`div`,Ee,[n(`h2`,De,l(e.$t(`fish.name.enhanceAudio`)),1),o(C,{modelValue:e.form.enhanceAudio,"onUpdate:modelValue":r[7]||=t=>e.form.enhanceAudio=t},null,8,[`modelValue`])]),n(`p`,Oe,l(e.$t(`fish.description.enhanceAudio`)),1)]),n(`div`,ke,[n(`div`,Ae,[n(`h2`,je,l(e.$t(`fish.name.generateSample`)),1),o(C,{modelValue:e.form.generateSample,"onUpdate:modelValue":r[8]||=t=>e.form.generateSample=t},null,8,[`modelValue`])]),n(`p`,Me,l(e.$t(`fish.description.generateSample`)),1)])]),n(`div`,Ne,[o(v,{type:`primary`,class:`btn w-full`,round:``,disabled:!e.canCreate||e.creating,loading:e.creating,onClick:e.onCreate},{default:m(()=>[o(_,{icon:`fa-solid fa-magic`,class:`mr-2`}),i(` `+l(e.$t(`fish.button.createModel`)),1)]),_:1},8,[`disabled`,`loading`,`onClick`])])])}var Fe=E(Q,[[`render`,Pe],[`__scopeId`,`data-v-d8fc0e55`]]),Ie=r({name:`FishVoiceCard`,components:{ElAlert:v,ElButton:h,ElImage:_,CopyToClipboard:k,FontAwesomeIcon:O},props:{modelValue:{type:Object,required:!0}},computed:{sampleAudioUrl(){let e=this.modelValue?.samples;if(e?.length)return e[0]?.audio},voiceId(){let e=this.modelValue;return(e?.id||e?._id||e?.reference_id||``).toString()},coverSrc(){let e=this.modelValue?.cover_image;return e&&typeof e==`string`?e:void 0},createdAtLabel(){let e=this.modelValue?.created_at;if(e==null||e===``)return null;let t=typeof e==`number`?e:parseFloat(String(e));return!Number.isFinite(t)||t<=0?null:this.$dayjs.format(``+new Date(t*1e3))}},methods:{onUseVoice(){let e=this.voiceId;e&&(this.$store.commit(`fish/setConfig`,{...this.$store.state.fish?.config,reference_id:e}),this.$router.push({name:ee}))}}}),Le={class:`card`},Re={class:`left`},ze={class:`main`},Be={class:`header`},Ve={class:`title`},He={key:0,class:`datetime`},Ue={key:0,class:`description`},We={key:1,class:`sample mt-2`},Ge=[`src`],Ke={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},qe={key:1,class:`text-[var(--el-text-color-regular)] text-xs mb-0`},Je={class:`operations mt-2`};function Ye(e,r,s,c,h,g){let _=p(`el-image`),v=p(`font-awesome-icon`),y=p(`copy-to-clipboard`),b=p(`el-alert`),x=p(`el-button`);return u(),t(`div`,Le,[n(`div`,Re,[e.coverSrc?(u(),a(_,{key:0,src:e.coverSrc,class:`cover`,fit:`cover`},{error:m(()=>[o(_,{src:`https://cdn.acedata.cloud/e40fccc727.png`,class:`cover fallback`,fit:`cover`})]),placeholder:m(()=>[...r[0]||=[n(`div`,{class:`cover placeholder`},null,-1)]]),_:1},8,[`src`])):(u(),a(_,{key:1,src:`https://cdn.acedata.cloud/e40fccc727.png`,class:`cover fallback`,fit:`cover`}))]),n(`div`,ze,[n(`div`,Be,[n(`span`,Ve,l(e.modelValue?.title||e.$t(`fish.name.untitledVoice`)),1),e.createdAtLabel?(u(),t(`span`,He,l(e.createdAtLabel),1)):f(``,!0)]),e.modelValue?.description?(u(),t(`p`,Ue,l(e.modelValue?.description),1)):f(``,!0),e.sampleAudioUrl?(u(),t(`div`,We,[n(`audio`,{src:e.sampleAudioUrl,controls:``,preload:`metadata`,class:`w-full`},null,8,Ge)])):f(``,!0),o(b,{closable:!1,class:`mt-2 success`},{default:m(()=>[e.voiceId?(u(),t(`p`,Ke,[o(v,{icon:`fa-solid fa-microphone`,class:`mr-1`}),i(` `+l(e.$t(`fish.name.referenceId`))+`: `+l(e.voiceId)+` `,1),o(y,{content:e.voiceId},null,8,[`content`])])):f(``,!0),e.modelValue?.visibility?(u(),t(`p`,qe,[o(v,{icon:`fa-solid fa-eye`,class:`mr-1`}),i(` `+l(e.$t(`fish.name.visibility`))+`: `+l(e.modelValue?.visibility),1)])):f(``,!0)]),_:1}),n(`div`,Je,[o(x,{type:`primary`,size:`small`,plain:``,disabled:!e.voiceId,onClick:d(e.onUseVoice,[`stop`])},{default:m(()=>[o(v,{icon:`fa-solid fa-volume-high`,class:`mr-1`}),i(` `+l(e.$t(`fish.button.useVoice`)),1)]),_:1},8,[`disabled`,`onClick`])])])])}var Xe=r({name:`FishModelListPanel`,components:{VoiceCard:E(Ie,[[`render`,Ye],[`__scopeId`,`data-v-629e2d04`]]),BotPlaceholder:A,FontAwesomeIcon:O},props:{loading:{type:Boolean,default:!1}},computed:{voices(){return this.$store.state.fish?.voices}}}),Ze={class:`model-list-panel flex flex-col h-full`},Qe={class:`header`},$e={class:`title`},et={key:0,class:`count`},tt={class:`body flex-1 min-h-0`},$={key:0,class:`h-full`},nt={key:1,class:`w-full h-full flex flex-col items-center justify-center text-center px-6`},rt={class:`empty-title`},it={class:`empty-hint`},at={key:2,class:`w-full h-full overflow-y-auto pr-1`};function ot(r,i,c,d,m,h){let g=p(`bot-placeholder`),_=p(`font-awesome-icon`),v=p(`voice-card`);return u(),t(`div`,Ze,[n(`header`,Qe,[n(`h2`,$e,l(r.$t(`fish.title.myVoices`)),1),r.voices?.length?(u(),t(`span`,et,l(r.voices?.length),1)):f(``,!0)]),n(`div`,tt,[r.voices===void 0?(u(),t(`div`,$,[o(g)])):r.voices.length===0?(u(),t(`div`,nt,[o(_,{icon:`fa-solid fa-microphone-lines`,class:`empty-icon`}),n(`p`,rt,l(r.$t(`fish.title.noVoicesYet`)),1),n(`p`,it,l(r.$t(`fish.description.noVoicesYet`)),1)])):(u(),t(`div`,at,[(u(!0),t(s,null,e(r.voices,e=>(u(),a(v,{key:e.id,"model-value":e},null,8,[`model-value`]))),128))]))])])}var st=r({name:`FishModelIndex`,components:{ModelConfigPanel:Fe,Layout:j,ModelListPanel:E(Xe,[[`render`,ot],[`__scopeId`,`data-v-4aab2294`]]),TabSwitcher:M},inject:[`initialized`],data(){return{loading:!1}},computed:{credential(){return this.$store.state.fish?.credential}},watch:{initialized:{async handler(e){e&&await this.onGetVoices()},immediate:!0}},async mounted(){await this.onGetService()},methods:{async onGetService(){await this.$store.dispatch(`fish/getService`)},async onGetVoices(){await this.$store.dispatch(`fish/getVoices`)},async onCreate(e){let t=this.credential?.token;if(!t){console.error(`no token specified`);return}this.loading=!0,T.info(this.$t(`fish.message.creatingModel`));try{await D.createModel(e,{token:t}),T.success(this.$t(`fish.message.createModelSuccess`)),await this.onGetVoices()}catch(e){let t=e?.response?.data;t?.error?.code===`used_up`?T.error(this.$t(`fish.message.usedUp`)):T.error(t?.error?.message||this.$t(`fish.message.createModelFailed`))}finally{this.loading=!1}}}}),ct={class:`flex flex-col h-full`},lt={class:`flex-1 min-h-0`};function ut(e,t,r,i,s,c){let l=p(`tab-switcher`),d=p(`model-config-panel`),f=p(`model-list-panel`),h=p(`layout`);return u(),a(h,null,{config:m(()=>[n(`div`,ct,[o(l),n(`div`,lt,[o(d,{onCreate:e.onCreate},null,8,[`onCreate`])])])]),result:m(()=>[o(f,{loading:e.loading},null,8,[`loading`])]),_:1})}var dt=E(st,[[`render`,ut]]);export{dt as default};
1
+ import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Vt as c,Wt as l,Z as u,b as d,k as f,tt as p,ut as m}from"./vendor-chart-BJCvKk8-.js";import{t as h}from"./button-BydTr5nV.js";import{t as g}from"./upload-F7Gkd45h.js";import{t as _}from"./image-BaawrLQN.js";import{t as v}from"./alert-CuX4SjQB.js";import{n as y,r as b}from"./radio-3Hz7h3DR.js";import{t as x}from"./switch-D1eTmtNv.js";import{t as S}from"./vendor-axios-Ck2ffRoh.js";import"./constants-NMxtQUbk.js";import{$r as C,Ir as w,Kr as T,O as E,in as D,tt as ee,zt as te}from"./index-bhnA3ynS.js";import{t as O}from"./index.es-BK9VjfWt.js";import{t as k}from"./CopyToClipboard-lWAkY_ey.js";import{t as A}from"./BotPlaceholder-BklNrzaU.js";import{t as j}from"./Hailuo-HxDqMP2r.js";import{t as M}from"./TabSwitcher-CeGqltCT.js";var N=4,P=90,F=r({name:`FishRecorder`,components:{ElButton:h,FontAwesomeIcon:O},emits:[`done`,`cancel`,`update:script`],data(){return{state:`idle`,scriptIndex:0,seconds:0,timerId:0,maxTimerId:0,mediaRecorder:null,stream:null,chunks:[],recordedBlob:null,recordedUrl:``,uploading:!1}},computed:{formattedTime(){let e=Math.floor(this.seconds/60),t=this.seconds%60;return`${e.toString().padStart(2,`0`)}:${t.toString().padStart(2,`0`)}`},currentScript(){let e=`fish.script.passage${this.scriptIndex%N+1}`;return this.$t(e)}},beforeUnmount(){this.cleanup()},mounted(){this.$emit(`update:script`,this.currentScript)},methods:{nextScript(){this.scriptIndex=(this.scriptIndex+1)%N,this.$emit(`update:script`,this.currentScript)},async startRecord(){if(!navigator.mediaDevices?.getUserMedia||typeof MediaRecorder>`u`){T.error(this.$t(`fish.message.recorderUnsupported`));return}try{this.stream=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(e){let t=e?.name===`NotAllowedError`||e?.name===`PermissionDeniedError`;T.error(this.$t(t?`fish.message.micDenied`:`fish.message.micError`));return}this.chunks=[];let e=this.pickMimeType();try{this.mediaRecorder=e?new MediaRecorder(this.stream,{mimeType:e}):new MediaRecorder(this.stream)}catch{this.mediaRecorder=new MediaRecorder(this.stream)}this.mediaRecorder.ondataavailable=e=>{e.data&&e.data.size>0&&this.chunks.push(e.data)},this.mediaRecorder.onstop=()=>{let e=new Blob(this.chunks,{type:this.mediaRecorder?.mimeType||`audio/webm`});this.recordedBlob=e,this.recordedUrl=URL.createObjectURL(e),this.state=`recorded`,this.releaseStream()},this.mediaRecorder.start(),this.state=`recording`,this.seconds=0,this.timerId=window.setInterval(()=>{this.seconds++},1e3),this.maxTimerId=window.setTimeout(()=>{this.state===`recording`&&this.stopRecord()},P*1e3)},stopRecord(){this.mediaRecorder&&this.mediaRecorder.state!==`inactive`&&this.mediaRecorder.stop(),window.clearInterval(this.timerId),window.clearTimeout(this.maxTimerId)},reset(){this.recordedUrl&&URL.revokeObjectURL(this.recordedUrl),this.recordedUrl=``,this.recordedBlob=null,this.state=`idle`,this.seconds=0},onCancel(){this.cleanup(),this.$emit(`cancel`)},cleanup(){this.stopRecord(),this.releaseStream(),this.recordedUrl&&URL.revokeObjectURL(this.recordedUrl)},releaseStream(){this.stream?.getTracks().forEach(e=>e.stop()),this.stream=null},pickMimeType(){for(let e of[`audio/webm;codecs=opus`,`audio/webm`,`audio/mp4`,`audio/ogg`])if(typeof MediaRecorder<`u`&&MediaRecorder.isTypeSupported?.(e))return e},extensionForMime(e){return e.includes(`webm`)?`webm`:e.includes(`mp4`)?`m4a`:e.includes(`ogg`)?`ogg`:e.includes(`wav`)?`wav`:`mp3`},async useRecording(){if(this.recordedBlob){if(this.seconds<3){T.warning(this.$t(`fish.message.recordingTooShort`));return}this.uploading=!0;try{let e=this.$store.state.token?.access,t=this.extensionForMime(this.recordedBlob.type||``),n=new File([this.recordedBlob],`recording-${Date.now()}.${t}`,{type:this.recordedBlob.type||`audio/webm`}),r=new FormData;r.append(`file`,n);let{data:i}=await S.post(`${w()}/api/v1/files/`,r,{headers:{Authorization:`Bearer ${e}`}}),a=i?.file_url;if(!a){T.error(this.$t(`fish.message.uploadError`));return}this.$emit(`done`,{url:a,text:this.currentScript})}catch(e){T.error(this.$t(`fish.message.uploadError`)),console.error(`recorder upload failed`,e)}finally{this.uploading=!1}}}}}),I={class:`recorder`},L={key:0,class:`script`},R={class:`script-header`},z={class:`label`},B={class:`script-text`},V={class:`controls`},H={class:`status`},U={class:`hint`},W={key:1,class:`preview`},G=[`src`],K={class:`preview-actions`},q={class:`footer`};function J(e,r,s,d,h,g){let _=p(`font-awesome-icon`),v=p(`el-button`);return u(),t(`div`,I,[e.state===`recorded`?f(``,!0):(u(),t(`div`,L,[n(`div`,R,[o(_,{icon:`fa-solid fa-book-open`,class:`icon mr-1`}),n(`span`,z,l(e.$t(`fish.description.readScript`)),1),o(v,{link:``,size:`small`,class:`ml-auto`,disabled:e.state===`recording`,onClick:e.nextScript},{default:m(()=>[o(_,{icon:`fa-solid fa-shuffle`,class:`mr-1`}),i(` `+l(e.$t(`fish.button.nextScript`)),1)]),_:1},8,[`disabled`,`onClick`])]),n(`p`,B,l(e.currentScript),1)])),n(`div`,V,[e.state===`idle`?(u(),a(v,{key:0,type:`danger`,circle:``,size:`large`,title:e.$t(`fish.button.startRecord`),onClick:e.startRecord},{default:m(()=>[o(_,{icon:`fa-solid fa-microphone`})]),_:1},8,[`title`,`onClick`])):e.state===`recording`?(u(),a(v,{key:1,type:`warning`,circle:``,size:`large`,title:e.$t(`fish.button.stopRecord`),onClick:e.stopRecord},{default:m(()=>[o(_,{icon:`fa-solid fa-stop`})]),_:1},8,[`title`,`onClick`])):f(``,!0),n(`div`,H,[n(`span`,{class:c([`timer`,e.state===`recording`?`live`:``])},l(e.formattedTime),3),n(`span`,U,l(e.state===`idle`?e.$t(`fish.description.recorderIdle`):e.state===`recording`?e.$t(`fish.description.recorderRecording`):e.$t(`fish.description.recorderRecorded`)),1)])]),e.state===`recorded`&&e.recordedUrl?(u(),t(`div`,W,[n(`audio`,{src:e.recordedUrl,controls:``,preload:`metadata`,class:`w-full`},null,8,G),n(`div`,K,[o(v,{size:`small`,disabled:e.uploading,onClick:e.reset},{default:m(()=>[o(_,{icon:`fa-solid fa-rotate-left`,class:`mr-1`}),i(` `+l(e.$t(`fish.button.reRecord`)),1)]),_:1},8,[`disabled`,`onClick`]),o(v,{size:`small`,type:`primary`,loading:e.uploading,onClick:e.useRecording},{default:m(()=>[o(_,{icon:`fa-solid fa-check`,class:`mr-1`}),i(` `+l(e.$t(`fish.button.useRecording`)),1)]),_:1},8,[`loading`,`onClick`])])])):f(``,!0),n(`div`,q,[o(v,{link:``,size:`small`,disabled:e.uploading||e.state===`recording`,onClick:e.onCancel},{default:m(()=>[i(l(e.$t(`fish.button.cancel`)),1)]),_:1},8,[`disabled`,`onClick`])])])}var Y=E(F,[[`render`,J],[`__scopeId`,`data-v-1958e4a1`]]),X=50*1024*1024,Z=()=>({title:``,description:``,texts:``,voicesUrl:``,visibility:`unlist`,trainMode:`fast`,enhanceAudio:!0,generateSample:!1}),Q=r({name:`FishModelConfigPanel`,components:{ElButton:h,ElInput:C,ElRadioButton:y,ElRadioGroup:b,ElSwitch:x,ElUpload:g,FontAwesomeIcon:O,Recorder:Y},mixins:[te],emits:[`create`],data(){return{form:Z(),fileList:[],uploading:!1,creating:!1,recording:!1,textsAuto:!0}},computed:{uploadUrl(){return w()+`/api/v1/files/`},uploadHeaders(){return{Authorization:`Bearer ${this.$store.state.token?.access}`}},canCreate(){return!!this.form.title.trim()&&!!this.form.voicesUrl&&!this.uploading&&!this.creating},supportsRecorder(){return!!(typeof navigator<`u`?navigator.mediaDevices:void 0)?.getUserMedia&&typeof MediaRecorder<`u`}},methods:{onBeforeUpload(e){return e.size>X?(T.warning(this.$t(`fish.message.audioSizeExceed`)),!1):(this.uploading=!0,!0)},onExceed(){T.warning(this.$t(`fish.message.audioOnlyOne`))},onUploadError(){this.uploading=!1,T.error(this.$t(`fish.message.uploadError`))},onUploadSuccess(e,t,n){this.uploading=!1;let r=e?.file_url;if(!r){T.error(this.$t(`fish.message.uploadError`)),this.fileList=[];return}this.form.voicesUrl=r,this.fileList=n},onRecorded(e){this.form.voicesUrl=e.url,this.recording=!1,e.text&&this.textsAuto&&(this.form.texts=e.text)},onStartRecord(){this.recording=!0,this.textsAuto=!this.form.texts.trim()},onScriptChange(e){this.textsAuto&&this.recording&&(this.form.texts=e)},onTextsInput(){this.textsAuto=!1},clearAudio(){this.form.voicesUrl=``,this.fileList=[]},onCreate(){let e=this.form.title.trim();if(!e){T.warning(this.$t(`fish.message.titleRequired`));return}if(!this.form.voicesUrl){T.warning(this.$t(`fish.message.audioRequired`));return}let t={title:e,voices:this.form.voicesUrl,visibility:this.form.visibility,train_mode:this.form.trainMode,enhance_audio_quality:this.form.enhanceAudio,generate_sample:this.form.generateSample};this.form.description.trim()&&(t.description=this.form.description.trim()),this.form.texts.trim()&&(t.texts=[this.form.texts.trim()]),this.creating=!0,this.$emit(`create`,t),setTimeout(()=>{this.creating=!1,this.form=Z(),this.fileList=[]},600)}}}),ne={class:`flex flex-col h-full`},re={class:`flex-1 overflow-y-auto p-5`},ie={class:`field-block mb-4`},ae={class:`title font-bold`},oe={class:`field-block mb-4`},se={class:`flex items-baseline justify-between mb-1`},ce={class:`title font-bold`},le={key:0,class:`muted`},ue={class:`hint`},de={key:0,class:`audio-actions`},fe={key:1,class:`hint warn`},pe={key:3,class:`mt-2`},me=[`src`],he={class:`ready-actions`},ge={class:`field-block mb-4`},_e={class:`title font-bold`},ve={class:`hint`},ye={class:`field-block mb-4`},be={class:`title font-bold`},xe={class:`field-block mb-4`},Se={class:`title font-bold`},Ce={class:`field-block mb-4`},we={class:`title font-bold`},Te={class:`field-block mb-3`},Ee={class:`field-row`},De={class:`title font-bold`},Oe={class:`hint mt-0 mb-0`},ke={class:`field-block mb-2`},Ae={class:`field-row`},je={class:`title font-bold`},Me={class:`hint mt-0 mb-0`},Ne={class:`flex flex-col items-center justify-center px-5 pb-5`};function Pe(e,r,s,c,d,h){let g=p(`el-input`),_=p(`font-awesome-icon`),v=p(`el-button`),y=p(`el-upload`),b=p(`recorder`),x=p(`el-radio-button`),S=p(`el-radio-group`),C=p(`el-switch`);return u(),t(`div`,ne,[n(`div`,re,[n(`div`,ie,[n(`h2`,ae,[i(l(e.$t(`fish.name.voiceTitle`))+` `,1),r[9]||=n(`span`,{class:`required`},`*`,-1)]),o(g,{modelValue:e.form.title,"onUpdate:modelValue":r[0]||=t=>e.form.title=t,placeholder:e.$t(`fish.placeholder.voiceTitle`),maxlength:`60`},null,8,[`modelValue`,`placeholder`])]),n(`div`,oe,[n(`div`,se,[n(`h2`,ce,[i(l(e.$t(`fish.name.referenceAudio`))+` `,1),r[10]||=n(`span`,{class:`required`},`*`,-1)]),!e.form.voicesUrl&&!e.recording?(u(),t(`span`,le,l(e.$t(`fish.description.audioRequired`)),1)):f(``,!0)]),n(`p`,ue,l(e.$t(`fish.description.uploadAudio`)),1),!e.form.voicesUrl&&!e.recording?(u(),t(`div`,de,[o(y,{"file-list":e.fileList,"onUpdate:fileList":r[1]||=t=>e.fileList=t,name:`file`,limit:1,class:`upload-wrapper`,action:e.uploadUrl,accept:`.mp3,.wav,.m4a,.ogg,.webm,audio/*`,"show-file-list":!1,"on-exceed":e.onExceed,"on-error":e.onUploadError,"on-success":e.onUploadSuccess,"before-upload":e.onBeforeUpload,headers:e.uploadHeaders},{default:m(()=>[o(v,{type:`primary`,plain:``,round:``,loading:e.uploading},{default:m(()=>[o(_,{icon:`fa-solid fa-upload`,class:`icon mr-1`}),i(` `+l(e.$t(`fish.button.uploadAudio`)),1)]),_:1},8,[`loading`])]),_:1},8,[`file-list`,`action`,`on-exceed`,`on-error`,`on-success`,`before-upload`,`headers`]),o(v,{type:`primary`,round:``,disabled:!e.supportsRecorder,onClick:e.onStartRecord},{default:m(()=>[o(_,{icon:`fa-solid fa-microphone`,class:`icon mr-1`}),i(` `+l(e.$t(`fish.button.recordAudio`)),1)]),_:1},8,[`disabled`,`onClick`])])):f(``,!0),!e.supportsRecorder&&!e.form.voicesUrl&&!e.recording?(u(),t(`p`,fe,l(e.$t(`fish.message.recorderUnsupported`)),1)):f(``,!0),e.recording?(u(),a(b,{key:2,class:`mt-2`,onDone:e.onRecorded,onCancel:r[2]||=t=>e.recording=!1,"onUpdate:script":e.onScriptChange},null,8,[`onDone`,`onUpdate:script`])):f(``,!0),e.form.voicesUrl&&!e.recording?(u(),t(`div`,pe,[n(`audio`,{src:e.form.voicesUrl,controls:``,preload:`metadata`,class:`w-full`},null,8,me),n(`div`,he,[o(v,{link:``,size:`small`,onClick:e.clearAudio},{default:m(()=>[o(_,{icon:`fa-solid fa-rotate-left`,class:`mr-1`}),i(` `+l(e.$t(`fish.button.replaceAudio`)),1)]),_:1},8,[`onClick`])])])):f(``,!0)]),n(`div`,ge,[n(`h2`,_e,l(e.$t(`fish.name.audioTexts`)),1),n(`p`,ve,l(e.$t(`fish.description.audioTexts`)),1),o(g,{modelValue:e.form.texts,"onUpdate:modelValue":r[3]||=t=>e.form.texts=t,type:`textarea`,rows:2,placeholder:e.$t(`fish.placeholder.audioTexts`),maxlength:`500`,onInput:e.onTextsInput},null,8,[`modelValue`,`placeholder`,`onInput`])]),n(`div`,ye,[n(`h2`,be,l(e.$t(`fish.name.voiceDescription`)),1),o(g,{modelValue:e.form.description,"onUpdate:modelValue":r[4]||=t=>e.form.description=t,type:`textarea`,rows:2,placeholder:e.$t(`fish.placeholder.voiceDescription`),maxlength:`500`},null,8,[`modelValue`,`placeholder`])]),n(`div`,xe,[n(`h2`,Se,l(e.$t(`fish.name.visibility`)),1),o(S,{modelValue:e.form.visibility,"onUpdate:modelValue":r[5]||=t=>e.form.visibility=t,size:`small`},{default:m(()=>[o(x,{label:`private`,value:`private`},{default:m(()=>[i(l(e.$t(`fish.value.private`)),1)]),_:1}),o(x,{label:`unlist`,value:`unlist`},{default:m(()=>[i(l(e.$t(`fish.value.unlist`)),1)]),_:1}),o(x,{label:`public`,value:`public`},{default:m(()=>[i(l(e.$t(`fish.value.public`)),1)]),_:1})]),_:1},8,[`modelValue`])]),n(`div`,Ce,[n(`h2`,we,l(e.$t(`fish.name.trainMode`)),1),o(S,{modelValue:e.form.trainMode,"onUpdate:modelValue":r[6]||=t=>e.form.trainMode=t,size:`small`},{default:m(()=>[o(x,{label:`fast`,value:`fast`},{default:m(()=>[i(l(e.$t(`fish.value.trainModeFast`)),1)]),_:1}),o(x,{label:`precise`,value:`precise`},{default:m(()=>[i(l(e.$t(`fish.value.trainModePrecise`)),1)]),_:1})]),_:1},8,[`modelValue`])]),n(`div`,Te,[n(`div`,Ee,[n(`h2`,De,l(e.$t(`fish.name.enhanceAudio`)),1),o(C,{modelValue:e.form.enhanceAudio,"onUpdate:modelValue":r[7]||=t=>e.form.enhanceAudio=t},null,8,[`modelValue`])]),n(`p`,Oe,l(e.$t(`fish.description.enhanceAudio`)),1)]),n(`div`,ke,[n(`div`,Ae,[n(`h2`,je,l(e.$t(`fish.name.generateSample`)),1),o(C,{modelValue:e.form.generateSample,"onUpdate:modelValue":r[8]||=t=>e.form.generateSample=t},null,8,[`modelValue`])]),n(`p`,Me,l(e.$t(`fish.description.generateSample`)),1)])]),n(`div`,Ne,[o(v,{type:`primary`,class:`btn w-full`,round:``,disabled:!e.canCreate||e.creating,loading:e.creating,onClick:e.onCreate},{default:m(()=>[o(_,{icon:`fa-solid fa-magic`,class:`mr-2`}),i(` `+l(e.$t(`fish.button.createModel`)),1)]),_:1},8,[`disabled`,`loading`,`onClick`])])])}var Fe=E(Q,[[`render`,Pe],[`__scopeId`,`data-v-d8fc0e55`]]),Ie=r({name:`FishVoiceCard`,components:{ElAlert:v,ElButton:h,ElImage:_,CopyToClipboard:k,FontAwesomeIcon:O},props:{modelValue:{type:Object,required:!0}},computed:{sampleAudioUrl(){let e=this.modelValue?.samples;if(e?.length)return e[0]?.audio},voiceId(){let e=this.modelValue;return(e?.id||e?._id||e?.reference_id||``).toString()},coverSrc(){let e=this.modelValue?.cover_image;return e&&typeof e==`string`?e:void 0},createdAtLabel(){let e=this.modelValue?.created_at;if(e==null||e===``)return null;let t=typeof e==`number`?e:parseFloat(String(e));return!Number.isFinite(t)||t<=0?null:this.$dayjs.format(``+new Date(t*1e3))}},methods:{onUseVoice(){let e=this.voiceId;e&&(this.$store.commit(`fish/setConfig`,{...this.$store.state.fish?.config,reference_id:e}),this.$router.push({name:ee}))}}}),Le={class:`card`},Re={class:`left`},ze={class:`main`},Be={class:`header`},Ve={class:`title`},He={key:0,class:`datetime`},Ue={key:0,class:`description`},We={key:1,class:`sample mt-2`},Ge=[`src`],Ke={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},qe={key:1,class:`text-[var(--el-text-color-regular)] text-xs mb-0`},Je={class:`operations mt-2`};function Ye(e,r,s,c,h,g){let _=p(`el-image`),v=p(`font-awesome-icon`),y=p(`copy-to-clipboard`),b=p(`el-alert`),x=p(`el-button`);return u(),t(`div`,Le,[n(`div`,Re,[e.coverSrc?(u(),a(_,{key:0,src:e.coverSrc,class:`cover`,fit:`cover`},{error:m(()=>[o(_,{src:`https://cdn.acedata.cloud/e40fccc727.png`,class:`cover fallback`,fit:`cover`})]),placeholder:m(()=>[...r[0]||=[n(`div`,{class:`cover placeholder`},null,-1)]]),_:1},8,[`src`])):(u(),a(_,{key:1,src:`https://cdn.acedata.cloud/e40fccc727.png`,class:`cover fallback`,fit:`cover`}))]),n(`div`,ze,[n(`div`,Be,[n(`span`,Ve,l(e.modelValue?.title||e.$t(`fish.name.untitledVoice`)),1),e.createdAtLabel?(u(),t(`span`,He,l(e.createdAtLabel),1)):f(``,!0)]),e.modelValue?.description?(u(),t(`p`,Ue,l(e.modelValue?.description),1)):f(``,!0),e.sampleAudioUrl?(u(),t(`div`,We,[n(`audio`,{src:e.sampleAudioUrl,controls:``,preload:`metadata`,class:`w-full`},null,8,Ge)])):f(``,!0),o(b,{closable:!1,class:`mt-2 success`},{default:m(()=>[e.voiceId?(u(),t(`p`,Ke,[o(v,{icon:`fa-solid fa-microphone`,class:`mr-1`}),i(` `+l(e.$t(`fish.name.referenceId`))+`: `+l(e.voiceId)+` `,1),o(y,{content:e.voiceId},null,8,[`content`])])):f(``,!0),e.modelValue?.visibility?(u(),t(`p`,qe,[o(v,{icon:`fa-solid fa-eye`,class:`mr-1`}),i(` `+l(e.$t(`fish.name.visibility`))+`: `+l(e.modelValue?.visibility),1)])):f(``,!0)]),_:1}),n(`div`,Je,[o(x,{type:`primary`,size:`small`,plain:``,disabled:!e.voiceId,onClick:d(e.onUseVoice,[`stop`])},{default:m(()=>[o(v,{icon:`fa-solid fa-volume-high`,class:`mr-1`}),i(` `+l(e.$t(`fish.button.useVoice`)),1)]),_:1},8,[`disabled`,`onClick`])])])])}var Xe=r({name:`FishModelListPanel`,components:{VoiceCard:E(Ie,[[`render`,Ye],[`__scopeId`,`data-v-629e2d04`]]),BotPlaceholder:A,FontAwesomeIcon:O},props:{loading:{type:Boolean,default:!1}},computed:{voices(){return this.$store.state.fish?.voices}}}),Ze={class:`model-list-panel flex flex-col h-full`},Qe={class:`header`},$e={class:`title`},et={key:0,class:`count`},tt={class:`body flex-1 min-h-0`},$={key:0,class:`h-full`},nt={key:1,class:`w-full h-full flex flex-col items-center justify-center text-center px-6`},rt={class:`empty-title`},it={class:`empty-hint`},at={key:2,class:`w-full h-full overflow-y-auto pr-1`};function ot(r,i,c,d,m,h){let g=p(`bot-placeholder`),_=p(`font-awesome-icon`),v=p(`voice-card`);return u(),t(`div`,Ze,[n(`header`,Qe,[n(`h2`,$e,l(r.$t(`fish.title.myVoices`)),1),r.voices?.length?(u(),t(`span`,et,l(r.voices?.length),1)):f(``,!0)]),n(`div`,tt,[r.voices===void 0?(u(),t(`div`,$,[o(g)])):r.voices.length===0?(u(),t(`div`,nt,[o(_,{icon:`fa-solid fa-microphone-lines`,class:`empty-icon`}),n(`p`,rt,l(r.$t(`fish.title.noVoicesYet`)),1),n(`p`,it,l(r.$t(`fish.description.noVoicesYet`)),1)])):(u(),t(`div`,at,[(u(!0),t(s,null,e(r.voices,e=>(u(),a(v,{key:e.id,"model-value":e},null,8,[`model-value`]))),128))]))])])}var st=r({name:`FishModelIndex`,components:{ModelConfigPanel:Fe,Layout:j,ModelListPanel:E(Xe,[[`render`,ot],[`__scopeId`,`data-v-4aab2294`]]),TabSwitcher:M},inject:[`initialized`],data(){return{loading:!1}},computed:{credential(){return this.$store.state.fish?.credential}},watch:{initialized:{async handler(e){e&&await this.onGetVoices()},immediate:!0}},async mounted(){await this.onGetService()},methods:{async onGetService(){await this.$store.dispatch(`fish/getService`)},async onGetVoices(){await this.$store.dispatch(`fish/getVoices`)},async onCreate(e){let t=this.credential?.token;if(!t){console.error(`no token specified`);return}this.loading=!0,T.info(this.$t(`fish.message.creatingModel`));try{await D.createModel(e,{token:t}),T.success(this.$t(`fish.message.createModelSuccess`)),await this.onGetVoices()}catch(e){let t=e?.response?.data;t?.error?.code===`used_up`?T.error(this.$t(`fish.message.usedUp`)):T.error(t?.error?.message||this.$t(`fish.message.createModelFailed`))}finally{this.loading=!1}}}}),ct={class:`flex flex-col h-full`},lt={class:`flex-1 min-h-0`};function ut(e,t,r,i,s,c){let l=p(`tab-switcher`),d=p(`model-config-panel`),f=p(`model-list-panel`),h=p(`layout`);return u(),a(h,null,{config:m(()=>[n(`div`,ct,[o(l),n(`div`,lt,[o(d,{onCreate:e.onCreate},null,8,[`onCreate`])])])]),result:m(()=>[o(f,{loading:e.loading},null,8,[`loading`])]),_:1})}var dt=E(st,[[`render`,ut]]);export{dt as default};