@acedatacloud/nexior 3.312.3 → 3.313.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 (157) hide show
  1. package/dist/assets/{ApiCodeButton-DuAlOpZG.js → ApiCodeButton-w2H75bSh.js} +1 -1
  2. package/dist/assets/{AskUserQuestionCard-Dhgyvu9K.js → AskUserQuestionCard-Dnc7kPo1.js} +1 -1
  3. package/dist/assets/{Auth-DLbfzvlZ.js → Auth-CUbHs_MB.js} +1 -1
  4. package/dist/assets/{Bare-CQEVz-Ur.js → Bare-BNBKb21h.js} +1 -1
  5. package/dist/assets/{BotPlaceholder-Dm168R0i.js → BotPlaceholder-CxKG8Hym.js} +1 -1
  6. package/dist/assets/{BottomFooter-CA5VNw3y.js → BottomFooter-ZNndGH3q.js} +1 -1
  7. package/dist/assets/{Callback-Bw2rUlhx.js → Callback-Ds6a8Llb.js} +1 -1
  8. package/dist/assets/{CodeSnippet-BCQMbHvH.js → CodeSnippet-9mq0FF0l.js} +1 -1
  9. package/dist/assets/{Console-DfYdzMqm.js → Console-P2UoG0ix.js} +1 -1
  10. package/dist/assets/{Consumption-hJG-OHSs.js → Consumption-mzszOU5D.js} +1 -1
  11. package/dist/assets/Conversation-C3UEE77Q.js +3 -0
  12. package/dist/assets/{CopyToClipboard-BYFO-_G-.js → CopyToClipboard--2jgu_fL.js} +1 -1
  13. package/dist/assets/{Detail-CJ3uwkb6.js → Detail-CLch9bp7.js} +2 -2
  14. package/dist/assets/{Extra-BuWZ3LBU.js → Extra-ClTjqaA6.js} +1 -1
  15. package/dist/assets/{FilePreview-Cehdo3ck.js → FilePreview-dJvwmz61.js} +1 -1
  16. package/dist/assets/{Hailuo-BTAqMI5M.js → Hailuo-C_c0dmdS.js} +1 -1
  17. package/dist/assets/{History-BMS2AkcN.js → History-D7VPiq5E.js} +1 -1
  18. package/dist/assets/{ImagePreview-BFGOcPHm.js → ImagePreview-zuMlHykT.js} +1 -1
  19. package/dist/assets/{ImageWrapper-jcaLH6EZ.js → ImageWrapper-mOGvz7wJ.js} +1 -1
  20. package/dist/assets/{Index-D7PHAZyQ.js → Index-0Wn6W0uM.js} +1 -1
  21. package/dist/assets/{Index-BwNLe4_l.js → Index-B-2RzsaX.js} +1 -1
  22. package/dist/assets/{Index-Dle_hmY8.js → Index-B09VLOhI.js} +1 -1
  23. package/dist/assets/{Index-ClZIkCWO.js → Index-BPIv4QL8.js} +1 -1
  24. package/dist/assets/{Index-ClRq0F6a.js → Index-BU8pBpAF.js} +1 -1
  25. package/dist/assets/{Index-DWlnjNQ3.js → Index-BZjqGrfk.js} +1 -1
  26. package/dist/assets/{Index-4tzRzeOr.js → Index-BazN_E5b.js} +1 -1
  27. package/dist/assets/{Index-DBUSq3EX.js → Index-C3iKtVpJ.js} +1 -1
  28. package/dist/assets/{Index-DdoqwRqI.js → Index-C6tDXz4f.js} +1 -1
  29. package/dist/assets/{Index-BNYCudAK.js → Index-C9I32hby.js} +1 -1
  30. package/dist/assets/{Index-C91WavxB.js → Index-CNW9VfjZ.js} +1 -1
  31. package/dist/assets/{Index-BOuZU4f-.js → Index-Cnwe05jC.js} +1 -1
  32. package/dist/assets/{Index-D81vrjjs.js → Index-CuyfbJ8j.js} +1 -1
  33. package/dist/assets/{Index-B77i6v--.js → Index-CxbAak1V.js} +1 -1
  34. package/dist/assets/{Index-BcMPBj2W.js → Index-DNARTjh6.js} +1 -1
  35. package/dist/assets/{Index-Dd5DwZbO.css → Index-DSGNU9jc.css} +1 -1
  36. package/dist/assets/{Index-D9Aay9cq.js → Index-DTD76wP9.js} +1 -1
  37. package/dist/assets/{Index--mAFavZ1.js → Index-DVRE51e6.js} +1 -1
  38. package/dist/assets/{Index-B6s3eU9Z.js → Index-D_9MMZRr.js} +1 -1
  39. package/dist/assets/{Index-BEDDOrgf.js → Index-D_WS0PPX.js} +1 -1
  40. package/dist/assets/Index-DhJM5ySV.js +1 -0
  41. package/dist/assets/{Index-QR6SmgM7.js → Index-DnYjAVUl.js} +1 -1
  42. package/dist/assets/{Index-DtMoGCuO.js → Index-DtqPELGk.js} +1 -1
  43. package/dist/assets/{Index-D6cM-SPf.js → Index-DvVdVGpY.js} +1 -1
  44. package/dist/assets/{Index-BS5fkIDx.js → Index-Fzsy7QQI.js} +1 -1
  45. package/dist/assets/{Index-CLRX9bSo.js → Index-ROJ66tLY.js} +1 -1
  46. package/dist/assets/Index-S2995lif.js +1 -0
  47. package/dist/assets/{Index-Cs4u7N3a.js → Index-TnZPuoqO.js} +1 -1
  48. package/dist/assets/{Index-rRpcFbuu.js → Index-l-4U1SVT.js} +1 -1
  49. package/dist/assets/{Invitees-DWUJOYFj.js → Invitees-BlDmXJDW.js} +1 -1
  50. package/dist/assets/{List-BULk6Y6u.js → List-B41GYa24.js} +1 -1
  51. package/dist/assets/{List-CzPepKkn.js → List-BboeE4h1.js} +1 -1
  52. package/dist/assets/{List-gLtfsmbJ.js → List-Bnb1W2FW.js} +1 -1
  53. package/dist/assets/{LocalTools-C-ArepDE.js → LocalTools-DjhJmJtS.js} +1 -1
  54. package/dist/assets/{LocalTools-BjixrPLE.js → LocalTools-DvfFfCUY.js} +1 -1
  55. package/dist/assets/{Main-DzgpEL_N.js → Main-T_C05vcR.js} +1 -1
  56. package/dist/assets/{Model-DLMBf2Mo.js → Model-C0LFUFRS.js} +1 -1
  57. package/dist/assets/{Navigator-BtBK9Tbx.js → Navigator-BHWYqhxz.js} +2 -2
  58. package/dist/assets/{NoTasks-DEoFRoDU.js → NoTasks-DWF77Bjw.js} +1 -1
  59. package/dist/assets/{NotFound-47N9tKg2.js → NotFound--tM_3F9Q.js} +1 -1
  60. package/dist/assets/{Pagination-Bh6hrzJJ.js → Pagination-B_hKCtLs.js} +1 -1
  61. package/dist/assets/{Pay-eoVnno0L.js → Pay-DMFP23cz.js} +1 -1
  62. package/dist/assets/{Player-B0Ne71ip.js → Player-UA87GBZN.js} +1 -1
  63. package/dist/assets/{PromptTextarea-CQ29jkWu.js → PromptTextarea-C_g1pSMP.js} +1 -1
  64. package/dist/assets/{RealtimeCall-DNhCxdS8.js → RealtimeCall-D4YYQpaY.js} +1 -1
  65. package/dist/assets/{ScheduledTasks-Dx-v-qDr.js → ScheduledTasks-CJqZEPGT.js} +1 -1
  66. package/dist/assets/{Status-CpjuwqcV.js → Status-B4cXfVjU.js} +1 -1
  67. package/dist/assets/{Subscribe-UH0SBQzT.js → Subscribe-BwhiIDW9.js} +1 -1
  68. package/dist/assets/{TabSwitcher-BlOqZ7LR.js → TabSwitcher-BfceQJnt.js} +1 -1
  69. package/dist/assets/{Tts-zfid94jy.js → Tts-_7e4Ip6z.js} +1 -1
  70. package/dist/assets/{VideoPlayer-BLzxLIKg.js → VideoPlayer-BowJFnOh.js} +1 -1
  71. package/dist/assets/{avatar-BOmZqYFQ.js → avatar-CKf1v6Ou.js} +1 -1
  72. package/dist/assets/{basic-DJ7Mg5D2.js → basic-D9W_bk0a.js} +1 -1
  73. package/dist/assets/{chat-BzIUlreB.js → chat-DyfoSEk1.js} +1 -1
  74. package/dist/assets/{codingBridge-xwjr99gw.js → codingBridge-BpWB11rv.js} +2 -2
  75. package/dist/assets/{codingBridgeNotify-D60KZZ7p.js → codingBridgeNotify-E9x7R9-r.js} +2 -2
  76. package/dist/assets/{collapse-199jrtQd.js → collapse-BDN9vBce.js} +1 -1
  77. package/dist/assets/{constants-CkWWBPId.js → constants-D5XSekB2.js} +1 -1
  78. package/dist/assets/{createTaskActions-DmV-Dtbs.js → createTaskActions--uI9aray.js} +1 -1
  79. package/dist/assets/{date-picker-Y5A3NHvV.js → date-picker-BB05x7os.js} +1 -1
  80. package/dist/assets/{digitalhuman-DgwZrM6A.js → digitalhuman-7a6OAxhs.js} +1 -1
  81. package/dist/assets/{dropdown-BzmtMVk5.js → dropdown-eQccMeSr.js} +1 -1
  82. package/dist/assets/{esm-B_UiGn4K.js → esm-B0cqCRhq.js} +3 -3
  83. package/dist/assets/{esm-LVrvfpWE.js → esm-B2Ps-Rdy.js} +1 -1
  84. package/dist/assets/{esm-CjUg2Uf7.js → esm-Bbe0IPpD.js} +2 -2
  85. package/dist/assets/{esm-DAJWfJe5.js → esm-Bqape_pJ.js} +1 -1
  86. package/dist/assets/esm-CBAjRqyO.js +1 -0
  87. package/dist/assets/{esm-DOT8--PX.js → esm-s-r4o8dI.js} +2 -2
  88. package/dist/assets/{esm-cTwaCJgt.js → esm-w-J7UtOH.js} +1 -1
  89. package/dist/assets/{fish-D2bA4wmc.js → fish-SCUoTPLr.js} +1 -1
  90. package/dist/assets/{flux-Bw2kVx10.js → flux-CCqcJrr8.js} +1 -1
  91. package/dist/assets/{grokvideo-BgYRMZ7r.js → grokvideo-B8z7YDjM.js} +1 -1
  92. package/dist/assets/{hailuo-DLDD6svp.js → hailuo-OlPFUuzF.js} +1 -1
  93. package/dist/assets/{headshots-BEX30PDu.js → headshots-BfIo2G9s.js} +1 -1
  94. package/dist/assets/{image-CLIo3ldG.js → image-DwKDUrzV.js} +1 -1
  95. package/dist/assets/{index-4nyvtI8-.js → index-DlJr9VYp.js} +5 -5
  96. package/dist/assets/{index.browser.esm-BMoAIQDo.js → index.browser.esm-BbZ4faFO.js} +1 -1
  97. package/dist/assets/{index.es-B6_5ZbW0.js → index.es-BHvvolz-.js} +1 -1
  98. package/dist/assets/{input-number-D1SXfL3G.js → input-number-DDAxxsV9.js} +1 -1
  99. package/dist/assets/{kling-BGaXJoq6.js → kling-BQEX-z47.js} +1 -1
  100. package/dist/assets/{luma-Dz4s-gcP.js → luma-DvAaWuVv.js} +1 -1
  101. package/dist/assets/{maestro-BUFrerSG.js → maestro-B1nMUn14.js} +1 -1
  102. package/dist/assets/{maestro-gOx6Ozct.js → maestro-B5DmREAA.js} +1 -1
  103. package/dist/assets/{maestro-CceqzrLx.js → maestro-Bnu52rfa.js} +1 -1
  104. package/dist/assets/{maestro-CKesa63q.js → maestro-BvpoYFSW.js} +1 -1
  105. package/dist/assets/{maestro-CdQrERmm.js → maestro-Bwxd-3Cj.js} +1 -1
  106. package/dist/assets/{maestro-BZl0Pdq0.js → maestro-C8LyjvhZ.js} +1 -1
  107. package/dist/assets/{maestro-og0drtv7.js → maestro-CA2M-Z9n.js} +1 -1
  108. package/dist/assets/{maestro-CZ6fjMJM.js → maestro-CKEJWYlR.js} +1 -1
  109. package/dist/assets/{maestro-Batexfxd.js → maestro-CVegZXcF.js} +1 -1
  110. package/dist/assets/{maestro-BPs2KdMV.js → maestro-D8h6wRa5.js} +1 -1
  111. package/dist/assets/{maestro-CodzcbCa.js → maestro-DJlc9Kp2.js} +1 -1
  112. package/dist/assets/{maestro-D5XO0VeM.js → maestro-DM0x64F0.js} +1 -1
  113. package/dist/assets/{maestro-Bdn8n9Rq.js → maestro-DY87xM49.js} +1 -1
  114. package/dist/assets/{maestro-DmaHLTNb.js → maestro-D_X3xfg1.js} +1 -1
  115. package/dist/assets/{maestro-DceF6PbU.js → maestro-Di8BEYDU.js} +1 -1
  116. package/dist/assets/{maestro-DBkBQlHk.js → maestro-DnnLP4rH.js} +1 -1
  117. package/dist/assets/{maestro-Bgoh25W_.js → maestro-DsFSbPsh.js} +1 -1
  118. package/dist/assets/{maestro-hKWt0xi9.js → maestro-bF3_3mTG.js} +1 -1
  119. package/dist/assets/{maestro-le8oJOMJ.js → maestro-hW87PFwC.js} +1 -1
  120. package/dist/assets/{midjourney-BkLYYjm6.js → midjourney-DG6Ix5Rq.js} +1 -1
  121. package/dist/assets/{nanobanana-CgRKwczL.js → nanobanana-DamPXFkC.js} +1 -1
  122. package/dist/assets/{openaiimage-CqfwRwDV.js → openaiimage-QqvfLPCW.js} +1 -1
  123. package/dist/assets/{pagination-DRUxt5oW.js → pagination-h9rCWZht.js} +1 -1
  124. package/dist/assets/{pika-De5FujDA.js → pika-DDqwHjZN.js} +1 -1
  125. package/dist/assets/{pixverse-hcYshelB.js → pixverse-BNhC3502.js} +1 -1
  126. package/dist/assets/{popover-C_mbGt3-.js → popover-B_CvW-p3.js} +1 -1
  127. package/dist/assets/{producer-CJwI3RKE.js → producer-BkUxZKXD.js} +1 -1
  128. package/dist/assets/{qrart-V7xKmGN2.js → qrart-CF5XIp9U.js} +1 -1
  129. package/dist/assets/{realtime-B0hZRHHC.js → realtime-4CjdOWk5.js} +1 -1
  130. package/dist/assets/{row-D9p6UztY.js → row-CuqrRPyi.js} +1 -1
  131. package/dist/assets/{seedance-CvUXfBIg.js → seedance-KBEMXhlz.js} +1 -1
  132. package/dist/assets/{seedream-D1QUxN-c.js → seedream-CIbV_CuW.js} +1 -1
  133. package/dist/assets/{select-ClTB8Ac0.js → select-CTGAdTl9.js} +1 -1
  134. package/dist/assets/{serp-CvKs99dm.js → serp-gfhnDEyg.js} +1 -1
  135. package/dist/assets/{slider-DQheA5Lp.js → slider-m4bBej6R.js} +1 -1
  136. package/dist/assets/{solana-wallets-FChWT0nD.js → solana-wallets-HE4-v6AP.js} +2 -2
  137. package/dist/assets/{solana-wallets-vue-Bd0SwDDv.js → solana-wallets-vue-0m1O_RGO.js} +1 -1
  138. package/dist/assets/{sora-DeaFB1FY.js → sora-D6y_5Wn4.js} +1 -1
  139. package/dist/assets/{suno-CFsHiUTJ.js → suno-DoSGAMQ8.js} +1 -1
  140. package/dist/assets/{switch-qPS9uKOY.js → switch-C7bMRiui.js} +1 -1
  141. package/dist/assets/{tabs-D3lvKTzq.js → tabs-BoOz64uZ.js} +1 -1
  142. package/dist/assets/{time-picker-DH2OPF3x.js → time-picker--8djDRT4.js} +1 -1
  143. package/dist/assets/{upload-DyzIWJnO.js → upload-CRcRB-U7.js} +1 -1
  144. package/dist/assets/{veo-Ccy0jERh.js → veo-B_Kd3MJV.js} +1 -1
  145. package/dist/assets/{wan-D09DNe5X.js → wan-Dpc-VA18.js} +1 -1
  146. package/dist/assets/{web-DE0SPJbT.js → web-BEcpzfG5.js} +1 -1
  147. package/dist/assets/{web-C-lwch1q.js → web-CW4fH3P_.js} +1 -1
  148. package/dist/assets/{web-BK9Cf_ez.js → web-DdXVXKOX.js} +1 -1
  149. package/dist/assets/{web-ptUvS1QD.js → web-dBKWh966.js} +1 -1
  150. package/dist/assets/{web-DYqp22v9.js → web-xGjtoIAR.js} +1 -1
  151. package/dist/assets/{webextrator-CqLSb0nu.js → webextrator-C19hR4r3.js} +1 -1
  152. package/dist/index.html +2 -2
  153. package/package.json +1 -1
  154. package/dist/assets/Conversation-DlG5-FVT.js +0 -3
  155. package/dist/assets/Index-J8THFcIc.js +0 -1
  156. package/dist/assets/Index-JHWtafnX.js +0 -1
  157. package/dist/assets/esm-dVdbxD96.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,a as u,c as d,dt as f,i as ee,k as p,n as m,nt as h,o as g,r as _,s as v,t as y,tt as b,ut as x,v as S}from"./vendor-chart-BJCvKk8-.js";import{t as C}from"./button-BydTr5nV.js";import{r as w,t as T}from"./select-ClTB8Ac0.js";import{n as E,t as D}from"./table-B5c9kfrJ.js";import{n as O,t as k}from"./tabs-D3lvKTzq.js";import{t as A}from"./card-DjyfNde2.js";import{n as j,r as M}from"./radio-3Hz7h3DR.js";import{t as N}from"./date-picker-Y5A3NHvV.js";import{n as P,t as F}from"./row-D9p6UztY.js";import{t as I}from"./Pagination-Bh6hrzJJ.js";import{n as L,t as R}from"./skeleton-BwNBivMN.js";import{Bn as z,Hr as B,Mr as V,O as H,Rn as U,Tr as W,Wn as G,Wr as K,wr as q,zn as J}from"./index-4nyvtI8-.js";import{t as Y}from"./index.es-B6_5ZbW0.js";import{t as X}from"./CopyToClipboard-BYFO-_G-.js";ee.register(_,u,m,v,d,g);var Z=r({name:`ConsoleUsageList`,components:{Pagination:I,ElTag:K,ElDatePicker:N,ElTable:D,ElSelect:w,ElOption:T,CopyToClipboard:X,ElRow:F,ElCol:P,ElTableColumn:E,ElCard:A,ElRadioButton:j,ElRadioGroup:M,ElSkeleton:R,ElSkeletonItem:L,ElDialog:B,ElTabs:O,ElTabPane:k,ElButton:C,FontAwesomeIcon:Y,BarChart:y},data(){return{applicationIds:this.$route.query.application_id?.toString()?this.$route.query.application_id?.toString().split(`,`):[],apiIds:this.$route.query.api_id?.toString()?this.$route.query.api_id?.toString().split(`,`):[],applications:[],apis:[],apisLoading:!1,credentialType:q,serviceType:W,apiUsages:[],proxyUsages:[],createdAtRange:(()=>{let e=this.$route.query.created_at_to?.toString(),t=this.$route.query.created_at_from?.toString();if(t&&e)return[new Date(t),new Date(e)];let n=new Date,r=new Date;return r.setDate(1),r.setHours(0,0,0,0),[r,n]})(),shortcuts:[{text:this.$t(`usage.shortcuts.thisMonth`),value:()=>{let e=new Date,t=new Date;return t.setDate(1),t.setHours(0,0,0,0),[t,e]}},{text:this.$t(`usage.shortcuts.today`),value:()=>{let e=new Date,t=new Date;return t.setHours(0,0,0,0),[t,e]}},{text:this.$t(`usage.shortcuts.last1Day`),value:()=>{let e=new Date,t=new Date;return t.setDate(t.getDate()-1),[t,e]}},{text:this.$t(`usage.shortcuts.last3Days`),value:()=>{let e=new Date,t=new Date;return t.setDate(t.getDate()-3),[t,e]}},{text:this.$t(`usage.shortcuts.last7Days`),value:()=>{let e=new Date,t=new Date;return t.setDate(t.getDate()-7),[t,e]}},{text:this.$t(`usage.shortcuts.last1Month`),value:()=>{let e=new Date,t=new Date;return t.setMonth(t.getMonth()-1),[t,e]}}],type:this.$route.query.type?.toString()||W.API,loading:!1,total:void 0,limit:15,totalUsed:0,barChartLabels:[],barChartSeries:[],aggLoading:!1,detailDialogVisible:!1,detailRow:null,detailActiveTab:`request`,detailLoading:!1,exporting:!1,statusCodeFilter:this.$route.query.status_code?.toString()||``,statusCodeOptions:[],statusCodeOptionsLoading:!1}},computed:{redirect(){return this.$route.query?.redirect},page(){return parseInt(this.$route.query.page?.toString()||`1`)},totalUsedString(){return`${(this.totalUsed||0).toFixed(2)}`},barChartData(){return{labels:this.barChartLabels,datasets:this.barChartSeries.map(e=>({label:e.label,data:e.data,backgroundColor:e.color}))}},barChartOptions(){return{responsive:!0,plugins:{legend:{position:`top`,onClick:(e,t,n)=>{let r=n?.chart;if(!r||t?.datasetIndex===void 0)return;let i=t.datasetIndex,a=r.data?.datasets||[];a.some((e,t)=>t!==i&&r.isDatasetVisible(t))?a.forEach((e,t)=>r.setDatasetVisibility(t,t===i)):a.forEach((e,t)=>r.setDatasetVisibility(t,!0)),r.update()}},title:{display:!0,text:this.$t(`usage.title.usageTrend`)}},scales:{x:{stacked:!0},y:{stacked:!0,beginAtZero:!0}}}}},watch:{page:{handler(){this.onFetchUsages()}},type:{handler(){this.applicationIds=[],this.apiIds=[],this.onApplicationsChange(this.applicationIds),this.onFetchApplications(),this.onFetchApis(),this.onFetchUsages(),this.onFetchAggregate(),this.onFetchStatusCodeOptions()}}},mounted(){this.onFetchApplications(),this.onFetchApis(),this.onFetchUsages(),this.onFetchAggregate(),this.onFetchStatusCodeOptions()},methods:{async onFetchUsages(){this.type===W.API?this.onFetchApiUsages():this.type===W.Proxy&&this.onFetchProxyUsages()},async onApiChange(e){await this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,api_id:e}}),this.onFetchApiUsages(),this.onFetchAggregate()},async onApisChange(e){await this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,api_id:e&&e.length?e.join(`,`):``}}),this.onFetchApiUsages(),this.onFetchAggregate()},async onTimeRangeChanged(){console.log(`onTimeRangeChanged`,this.createdAtRange),await this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,created_at_from:this.createdAtRange?this.$dayjs.format(this.createdAtRange[0].toString(),`YYYY-MM-DDTHH:mm:ss.SSSSSSZ`):``,created_at_to:this.createdAtRange?this.$dayjs.format(this.createdAtRange[1].toString(),`YYYY-MM-DDTHH:mm:ss.SSSSSSZ`):``}}),this.onFetchUsages(),this.onFetchAggregate(),this.onFetchStatusCodeOptions()},async onApplicationChange(e){await this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,application_id:e}}),this.onFetchUsages(),this.onFetchAggregate()},async onApplicationsChange(e){await this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,application_id:e&&e.length?e.join(`,`):``}}),this.onFetchUsages(),this.onFetchAggregate()},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,page:e}})},getRemainingAmount(e){if(e.remaining_amount===void 0||e.remaining_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.remaining_amount?.toFixed(6)} ${t}`},getUsedAmount(e){if(e.used_amount===void 0||e.used_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.used_amount?.toFixed(6)} ${t}`},getDeductedAmount(e){if(e?.deducted_amount===void 0||e?.deducted_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.deducted_amount?.toFixed(6)} ${t}`},getOriginalAmount(e){if(e?.original_amount===void 0||e?.original_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.original_amount?.toFixed(6)} ${t}`},onStatusCodeChange(e){let t={...this.$route.query},n=(e||``).trim();n?t.status_code=n:delete t.status_code,delete t.status_code_filter,this.$router.push({name:this.$route.name?.toString(),query:t}),this.onFetchUsages(),this.onFetchAggregate()},async onFetchStatusCodeOptions(){this.statusCodeOptionsLoading=!0;try{let{data:e}=await J.getStatusCodes({user_id:this.$store.getters.user.id,...this.applicationIds&&this.applicationIds.length?{application_id:this.applicationIds}:{},...this.apiIds&&this.apiIds.length?{api_id:this.apiIds}:{},...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0]}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1]}:{}});this.statusCodeOptions=(e?.items||[]).slice().sort((e,t)=>e-t)}catch{this.statusCodeOptions=[]}finally{this.statusCodeOptionsLoading=!1}},formatElapsed(e){return e==null||Number.isNaN(e)?`-`:e<1?`${Math.round(e*1e3)} ms`:`${e.toFixed(2)} s`},getSimpleMetadata(e){if(!e)return{};let t={};for(let[n,r]of Object.entries(e))n===`request`||n===`response`||typeof r==`object`&&r||(t[n]=r);return t},onShowDetail(e){this.detailRow={...e,metadata:void 0},this.detailActiveTab=`request`,this.detailDialogVisible=!0,this.detailLoading=!0,e.id&&J.get(e.id).then(e=>{this.detailRow=e.data}).finally(()=>{this.detailLoading=!1})},formatJson(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}},onFetchApplications(){G.getAll({limit:100,offset:0,user_id:this.$store.getters.user.id,ordering:`-created_at`,type:V.USAGE}).then(({data:e})=>{this.applications=e.items.filter(e=>e?.service?.type===this.type)}).catch(()=>{})},onFetchApis(){this.apisLoading=!0,U.getAll({limit:100,offset:0,ordering:`-created_at`}).then(({data:e})=>{this.apis=e.items}).catch(()=>{}).finally(()=>{this.apisLoading=!1})},onFetchApiUsages(){console.log(`onFetchApiUsages`,this.createdAtRange),this.loading=!0,J.getAll({limit:this.limit,offset:(this.page-1)*this.limit,user_id:this.$store.getters.user.id,ordering:`-created_at`,...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0]}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1]}:{},...this.applicationIds&&this.applicationIds.length?{application_id:this.applicationIds}:{},...this.apiIds&&this.apiIds.length?{api_id:this.apiIds}:{},...this.statusCodeFilter?{status_code:this.statusCodeFilter}:{}}).then(({data:e})=>{this.apiUsages=e.items,this.loading=!1,this.total=e.count}).catch(()=>{this.loading=!1})},onFetchProxyUsages(){this.loading=!0,z.getAll({limit:this.limit,offset:(this.page-1)*this.limit,user_id:this.$store.getters.user.id,ordering:`-created_at`,...this.applicationIds&&this.applicationIds.length?{application_id:this.applicationIds}:{}}).then(({data:e})=>{this.proxyUsages=e.items,this.loading=!1,this.total=e.count}).catch(()=>{this.loading=!1})},onExport(){this.exporting=!0,J.exportCsv({user_id:this.$store.getters.user.id,...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0]}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1]}:{},...this.applicationIds&&this.applicationIds.length?{application_id:this.applicationIds}:{},...this.apiIds&&this.apiIds.length?{api_id:this.apiIds}:{},...this.statusCodeFilter?{status_code:this.statusCodeFilter}:{}}).then(({data:e})=>{let t=window.URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`usages.csv`,n.click(),window.URL.revokeObjectURL(t)}).catch(()=>{}).finally(()=>{this.exporting=!1})},async onFetchAggregate(){if(this.aggLoading=!0,this.type!==this.serviceType.API)return;let e={user_id:this.$store.getters.user.id,...this.applicationIds&&this.applicationIds.length?{application_id:this.applicationIds}:{},...this.apiIds&&this.apiIds.length?{api_id:this.apiIds}:{},...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0]}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1]}:{}};try{let{data:t}=await J.getAggregate(e);this.totalUsed=t.total||0;let n=Array.from(new Set((t.items||[]).map(e=>e.date))).sort(),r=Array.from(new Set((t.items||[]).map(e=>e.api_id))),i=e=>`hsl(${e*57%360}, 70%, 60%)`,a=r.map((e,r)=>{let a=t.apis?.[e]?.title||e,o={};return(t.items||[]).filter(t=>t.api_id===e).forEach(e=>{o[e.date]=e.amount||0}),{key:e,label:a,data:n.map(e=>o[e]||0),color:i(r)}});this.barChartLabels=n,this.barChartSeries=a}finally{this.aggLoading=!1}}}}),Q={class:`text-[26px] font-bold mb-5 text-[var(--el-text-color-primary)]`},$={class:`inline-block w-9`},te={class:`inline-block`},ne={key:1,class:`summary-card`},re={class:`icon-wrapper`},ie={class:`text-left`},ae={class:`description`},oe={class:`value`},se={class:`chart-wrapper`},ce={key:0},le={key:1},ue={class:`flex flex-wrap gap-2`},de={class:`key`},fe={key:0,class:`cursor-pointer`},pe={class:`created-at`},me={class:`created-at`},he={key:1,class:`detail-json`},ge={key:2,class:`text-gray-400`},_e={key:1,class:`detail-json`},ve={key:2,class:`text-gray-400`},ye={class:`float-right`};function be(r,u,d,ee,m,g){let _=b(`el-col`),v=b(`el-row`),y=b(`el-radio-button`),C=b(`el-radio-group`),w=b(`el-option`),T=b(`el-select`),E=b(`el-skeleton-item`),D=b(`el-skeleton`),O=b(`el-date-picker`),k=b(`font-awesome-icon`),A=b(`el-button`),j=b(`el-card`),M=b(`bar-chart`),N=b(`el-table-column`),P=b(`el-tag`),F=b(`copy-to-clipboard`),I=b(`el-table`),L=b(`el-tab-pane`),R=b(`el-tabs`),z=b(`el-dialog`),B=b(`pagination`),V=h(`loading`);return l(),a(v,null,{default:x(()=>[o(_,{span:24},{default:x(()=>[o(v,null,{default:x(()=>[o(_,{span:24},{default:x(()=>[n(`h2`,Q,c(r.$t(`common.title.allUsages`)),1)]),_:1})]),_:1}),o(v,null,{default:x(()=>[o(_,{md:4,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:x(()=>[n(`span`,null,c(r.$t(`application.field.type`)),1),o(C,{modelValue:r.type,"onUpdate:modelValue":u[0]||=e=>r.type=e},{default:x(()=>[o(y,{value:r.serviceType.API,label:r.$t(`application.field.api`)},null,8,[`value`,`label`]),o(y,{value:r.serviceType.Proxy,label:r.$t(`application.field.proxy`)},null,8,[`value`,`label`])]),_:1},8,[`modelValue`])]),_:1}),f(o(_,{md:6,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:x(()=>[n(`span`,$,c(r.$t(`usage.field.application`)),1),o(T,{modelValue:r.applicationIds,"onUpdate:modelValue":u[1]||=e=>r.applicationIds=e,placeholder:r.$t(`usage.field.application`),clearable:``,multiple:``,"collapse-tags":``,"collapse-tags-tooltip":``,class:`w-full`,onChange:r.onApplicationsChange},{default:x(()=>[(l(!0),t(s,null,e(r.applications,e=>(l(),a(w,{key:e.id,label:e.service?.title,value:e?.id},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`])]),_:1},512),[[S,!1]]),r.type===r.serviceType.API?(l(),a(_,{key:0,md:6,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:x(()=>[n(`span`,te,c(r.$t(`usage.field.api`)),1),r.apisLoading?(l(),a(D,{key:0,animated:``,class:`w-full`},{template:x(()=>[o(E,{variant:`rect`,style:{height:`32px`,"border-radius":`4px`}})]),_:1})):(l(),a(T,{key:1,modelValue:r.apiIds,"onUpdate:modelValue":u[2]||=e=>r.apiIds=e,placeholder:r.$t(`usage.field.api`),clearable:``,filterable:``,multiple:``,"collapse-tags":``,"collapse-tags-tooltip":``,class:`w-full`,onChange:r.onApisChange},{default:x(()=>[(l(!0),t(s,null,e(r.apis,e=>(l(),a(w,{key:e?.id,label:e?.title,value:e?.id},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]))]),_:1})):p(``,!0),r.type===r.serviceType.API?(l(),a(_,{key:1,md:8,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:x(()=>[o(O,{modelValue:r.createdAtRange,"onUpdate:modelValue":u[3]||=e=>r.createdAtRange=e,type:`datetimerange`,class:`w-full`,shortcuts:r.shortcuts,"range-separator":r.$t(`usage.placeholder.to`),"start-placeholder":r.$t(`usage.placeholder.startDate`),"end-placeholder":r.$t(`usage.placeholder.endDate`),onChange:r.onTimeRangeChanged},null,8,[`modelValue`,`shortcuts`,`range-separator`,`start-placeholder`,`end-placeholder`,`onChange`])]),_:1})):p(``,!0),r.type===r.serviceType.API?(l(),a(_,{key:2,md:3,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:x(()=>[o(T,{modelValue:r.statusCodeFilter,"onUpdate:modelValue":u[4]||=e=>r.statusCodeFilter=e,placeholder:r.$t(`usage.option.statusCodeAll`),class:`w-full`,clearable:``,filterable:``,"allow-create":``,"default-first-option":``,loading:r.statusCodeOptionsLoading,onChange:r.onStatusCodeChange},{default:x(()=>[(l(!0),t(s,null,e(r.statusCodeOptions,e=>(l(),a(w,{key:e,label:String(e),value:String(e)},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`loading`,`onChange`])]),_:1})):p(``,!0),r.type===r.serviceType.API?(l(),a(_,{key:3,md:3,xs:24,class:`mb-5 flex px-2 gap-2 items-center justify-end`},{default:x(()=>[o(A,{type:`primary`,plain:``,loading:r.exporting,class:`w-full whitespace-nowrap`,onClick:r.onExport},{default:x(()=>[o(k,{icon:`fa-solid fa-file-export`,class:`mr-1`}),i(` `+c(r.$t(`usage.button.export`)),1)]),_:1},8,[`loading`,`onClick`])]),_:1})):p(``,!0)]),_:1}),o(v,null,{default:x(()=>[o(_,{span:24},{default:x(()=>[r.type===r.serviceType.API?(l(),a(v,{key:0,gutter:24,class:`mb-5`},{default:x(()=>[o(_,{md:6,xs:24},{default:x(()=>[o(j,{shadow:`hover`,class:`h-full`},{default:x(()=>[r.aggLoading?(l(),a(D,{key:0})):(l(),t(`div`,ne,[n(`div`,re,[o(k,{icon:`fa-solid fa-cubes`,class:`icon`})]),n(`div`,ie,[n(`p`,ae,c(r.$t(`usage.title.totalUsed`)),1),n(`p`,oe,c(r.totalUsedString),1)])]))]),_:1})]),_:1}),o(_,{md:18,xs:24},{default:x(()=>[o(j,{shadow:`hover`,class:`h-full`},{default:x(()=>[n(`div`,se,[r.aggLoading?(l(),a(D,{key:0,class:`w-full`})):(l(),a(M,{key:1,data:r.barChartData,options:r.barChartOptions,class:`chart`},null,8,[`data`,`options`]))])]),_:1})]),_:1})]),_:1})):p(``,!0),o(j,{shadow:`hover`},{default:x(()=>[r.type===r.serviceType.API?f((l(),a(I,{key:0,data:r.apiUsages,stripe:``,"table-layout":`fixed`,"empty-text":r.$t(`common.message.noData`),class:`min-h-[calc(100vh-350px)] mb-5`},{default:x(()=>[o(N,{label:r.$t(`application.field.name`),width:`160px`},{default:x(e=>[n(`span`,null,c(e.row?.api?.title),1)]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.statusCode`),width:`120px`},{default:x(e=>[n(`span`,null,c(e.row.status_code),1)]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.elapsed`),width:`120px`},{default:x(e=>[n(`span`,null,c(r.formatElapsed(e.row.elapsed)),1)]),_:1},8,[`label`]),o(N,{prop:`deducted_amount`,label:r.$t(`usage.field.deductedAmount`),width:`150px`,"class-name":`text-center`},{default:x(e=>[r.getDeductedAmount(e.row)===r.getOriginalAmount(e.row)?(l(),t(`div`,ce,[n(`span`,null,c(r.getDeductedAmount(e.row)),1)])):(l(),t(`div`,le,[u[7]||=n(`p`,null,null,-1),n(`p`,null,[n(`span`,null,c(r.getDeductedAmount(e.row)),1)]),n(`p`,null,[n(`del`,null,c(r.getOriginalAmount(e.row)),1)])]))]),_:1},8,[`label`]),o(N,{prop:`remaining_amount`,label:r.$t(`usage.field.balanceAfter`),width:`160px`,"class-name":`text-center`},{default:x(e=>[n(`span`,null,c(r.getRemainingAmount(e.row)),1)]),_:1},8,[`label`]),o(N,{prop:`metadata`,label:r.$t(`usage.field.metadata`),width:`260px`,"class-name":`text-center`},{default:x(o=>[n(`div`,ue,[o.row.original_amount>o.row.deducted_amount&&o.row.original_amount>0?(l(),a(P,{key:0,type:`success`,style:{textWrap:`wrap`,height:`fit-content`,lineHeight:`20px`,borderRadius:`10px`}},{default:x(()=>[i(c(((o.row.original_amount-o.row.deducted_amount)*100/o.row.original_amount).toFixed(0)+`% OFF`),1)]),_:2},1024)):p(``,!0),(l(!0),t(s,null,e(r.getSimpleMetadata(o.row.metadata),(e,t)=>(l(),a(P,{key:t,style:{textWrap:`wrap`,height:`fit-content`,lineHeight:`20px`,borderRadius:`10px`}},{default:x(()=>[i(c(t)+`: `+c(e),1)]),_:2},1024))),128))])]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.button.viewDetail`),width:`120px`,"class-name":`text-center`},{default:x(e=>[e.row.id?(l(),a(A,{key:0,type:`primary`,plain:``,size:`small`,class:`!px-2 !py-1 !text-xs !h-auto !min-h-0`,onClick:t=>r.onShowDetail(e.row)},{default:x(()=>[i(c(r.$t(`usage.button.viewDetail`)),1)]),_:1},8,[`onClick`])):p(``,!0)]),_:1},8,[`label`]),o(N,{prop:`trace_id`,label:r.$t(`application.field.traceId`),width:`200px`,"class-name":`text-center`},{default:x(e=>[n(`span`,de,c(e.row.trace_id),1),e.row.trace_id?(l(),t(`span`,fe,[o(F,{content:e.row.trace_id,class:`inline-block`},null,8,[`content`])])):p(``,!0)]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.createdAt`),width:`200px`},{default:x(e=>[n(`span`,pe,c(r.$dayjs.format(e.row.created_at)),1)]),_:1},8,[`label`])]),_:1},8,[`data`,`empty-text`])),[[V,r.loading]]):p(``,!0),r.type===r.serviceType.Proxy?f((l(),a(I,{key:1,data:r.proxyUsages,stripe:``,"table-layout":`fixed`,"empty-text":r.$t(`common.message.noData`),class:`min-h-[calc(100vh-350px)] mb-5`},{default:x(()=>[o(N,{label:r.$t(`application.field.name`),width:`160px`},{default:x(e=>[n(`span`,null,c(e.row?.service?.title),1)]),_:1},8,[`label`]),o(N,{prop:`remaining_amount`,label:r.$t(`usage.field.remainingAmount`),width:`160px`,"class-name":`text-center`},{default:x(e=>[n(`span`,null,c(r.getRemainingAmount(e.row)),1),n(`span`,null,c(r.getOriginalAmount(e.row)),1)]),_:1},8,[`label`]),o(N,{prop:`deducted_amount`,label:r.$t(`usage.field.deductedAmount`),width:`150px`,"class-name":`text-center`},{default:x(e=>[n(`span`,null,c(r.getDeductedAmount(e.row)),1)]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.balanceAfter`),width:`160px`,"class-name":`text-center`},{default:x(e=>[n(`span`,null,c(r.getRemainingAmount(e.row)),1)]),_:1},8,[`label`]),o(N,{prop:`metadata`,label:r.$t(`usage.field.metadata`),width:`200px`,"class-name":`text-center`},{default:x(n=>[(l(!0),t(s,null,e(n.row.metadata,(e,t)=>(l(),a(P,{key:t,class:`mb-2`},{default:x(()=>[i(c(t)+`: `+c(e),1)]),_:2},1024))),128))]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.createdAt`),width:`200px`},{default:x(e=>[n(`span`,me,c(r.$dayjs.format(e.row.created_at)),1)]),_:1},8,[`label`])]),_:1},8,[`data`,`empty-text`])),[[V,r.loading]]):p(``,!0)]),_:1})]),_:1})]),_:1}),o(z,{modelValue:r.detailDialogVisible,"onUpdate:modelValue":u[6]||=e=>r.detailDialogVisible=e,title:r.$t(`usage.dialog.detailTitle`),width:`70%`,top:`5vh`,"destroy-on-close":``},{default:x(()=>[o(R,{modelValue:r.detailActiveTab,"onUpdate:modelValue":u[5]||=e=>r.detailActiveTab=e},{default:x(()=>[o(L,{label:r.$t(`usage.dialog.request`),name:`request`},{default:x(()=>[r.detailLoading?(l(),a(D,{key:0,rows:6,animated:``})):r.detailRow?.metadata?.request?(l(),t(`pre`,he,c(r.formatJson(r.detailRow.metadata.request)),1)):(l(),t(`p`,ge,c(r.$t(`usage.dialog.noData`)),1))]),_:1},8,[`label`]),o(L,{label:r.$t(`usage.dialog.response`),name:`response`},{default:x(()=>[r.detailLoading?(l(),a(D,{key:0,rows:6,animated:``})):r.detailRow?.metadata?.response?(l(),t(`pre`,_e,c(r.formatJson(r.detailRow.metadata.response)),1)):(l(),t(`p`,ve,c(r.$t(`usage.dialog.noData`)),1))]),_:1},8,[`label`])]),_:1},8,[`modelValue`])]),_:1},8,[`modelValue`,`title`]),o(v,null,{default:x(()=>[o(_,{span:10,offset:14},{default:x(()=>[n(`div`,ye,[o(B,{"current-page":r.page,"page-size":r.limit,total:r.total,onChange:r.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var xe=H(Z,[[`render`,be],[`__scopeId`,`data-v-38f1845c`]]);export{xe as default};
1
+ import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,a as u,c as d,dt as f,i as ee,k as p,n as m,nt as h,o as g,r as _,s as v,t as y,tt as b,ut as x,v as S}from"./vendor-chart-BJCvKk8-.js";import{t as C}from"./button-BydTr5nV.js";import{r as w,t as T}from"./select-CTGAdTl9.js";import{n as E,t as D}from"./table-B5c9kfrJ.js";import{n as O,t as k}from"./tabs-BoOz64uZ.js";import{t as A}from"./card-DjyfNde2.js";import{n as j,r as M}from"./radio-3Hz7h3DR.js";import{t as N}from"./date-picker-BB05x7os.js";import{n as P,t as F}from"./row-CuqrRPyi.js";import{t as I}from"./Pagination-B_hKCtLs.js";import{n as L,t as R}from"./skeleton-BwNBivMN.js";import{Bn as z,Hr as B,Mr as V,O as H,Rn as U,Tr as W,Wn as G,Wr as K,wr as q,zn as J}from"./index-DlJr9VYp.js";import{t as Y}from"./index.es-BHvvolz-.js";import{t as X}from"./CopyToClipboard--2jgu_fL.js";ee.register(_,u,m,v,d,g);var Z=r({name:`ConsoleUsageList`,components:{Pagination:I,ElTag:K,ElDatePicker:N,ElTable:D,ElSelect:w,ElOption:T,CopyToClipboard:X,ElRow:F,ElCol:P,ElTableColumn:E,ElCard:A,ElRadioButton:j,ElRadioGroup:M,ElSkeleton:R,ElSkeletonItem:L,ElDialog:B,ElTabs:O,ElTabPane:k,ElButton:C,FontAwesomeIcon:Y,BarChart:y},data(){return{applicationIds:this.$route.query.application_id?.toString()?this.$route.query.application_id?.toString().split(`,`):[],apiIds:this.$route.query.api_id?.toString()?this.$route.query.api_id?.toString().split(`,`):[],applications:[],apis:[],apisLoading:!1,credentialType:q,serviceType:W,apiUsages:[],proxyUsages:[],createdAtRange:(()=>{let e=this.$route.query.created_at_to?.toString(),t=this.$route.query.created_at_from?.toString();if(t&&e)return[new Date(t),new Date(e)];let n=new Date,r=new Date;return r.setDate(1),r.setHours(0,0,0,0),[r,n]})(),shortcuts:[{text:this.$t(`usage.shortcuts.thisMonth`),value:()=>{let e=new Date,t=new Date;return t.setDate(1),t.setHours(0,0,0,0),[t,e]}},{text:this.$t(`usage.shortcuts.today`),value:()=>{let e=new Date,t=new Date;return t.setHours(0,0,0,0),[t,e]}},{text:this.$t(`usage.shortcuts.last1Day`),value:()=>{let e=new Date,t=new Date;return t.setDate(t.getDate()-1),[t,e]}},{text:this.$t(`usage.shortcuts.last3Days`),value:()=>{let e=new Date,t=new Date;return t.setDate(t.getDate()-3),[t,e]}},{text:this.$t(`usage.shortcuts.last7Days`),value:()=>{let e=new Date,t=new Date;return t.setDate(t.getDate()-7),[t,e]}},{text:this.$t(`usage.shortcuts.last1Month`),value:()=>{let e=new Date,t=new Date;return t.setMonth(t.getMonth()-1),[t,e]}}],type:this.$route.query.type?.toString()||W.API,loading:!1,total:void 0,limit:15,totalUsed:0,barChartLabels:[],barChartSeries:[],aggLoading:!1,detailDialogVisible:!1,detailRow:null,detailActiveTab:`request`,detailLoading:!1,exporting:!1,statusCodeFilter:this.$route.query.status_code?.toString()||``,statusCodeOptions:[],statusCodeOptionsLoading:!1}},computed:{redirect(){return this.$route.query?.redirect},page(){return parseInt(this.$route.query.page?.toString()||`1`)},totalUsedString(){return`${(this.totalUsed||0).toFixed(2)}`},barChartData(){return{labels:this.barChartLabels,datasets:this.barChartSeries.map(e=>({label:e.label,data:e.data,backgroundColor:e.color}))}},barChartOptions(){return{responsive:!0,plugins:{legend:{position:`top`,onClick:(e,t,n)=>{let r=n?.chart;if(!r||t?.datasetIndex===void 0)return;let i=t.datasetIndex,a=r.data?.datasets||[];a.some((e,t)=>t!==i&&r.isDatasetVisible(t))?a.forEach((e,t)=>r.setDatasetVisibility(t,t===i)):a.forEach((e,t)=>r.setDatasetVisibility(t,!0)),r.update()}},title:{display:!0,text:this.$t(`usage.title.usageTrend`)}},scales:{x:{stacked:!0},y:{stacked:!0,beginAtZero:!0}}}}},watch:{page:{handler(){this.onFetchUsages()}},type:{handler(){this.applicationIds=[],this.apiIds=[],this.onApplicationsChange(this.applicationIds),this.onFetchApplications(),this.onFetchApis(),this.onFetchUsages(),this.onFetchAggregate(),this.onFetchStatusCodeOptions()}}},mounted(){this.onFetchApplications(),this.onFetchApis(),this.onFetchUsages(),this.onFetchAggregate(),this.onFetchStatusCodeOptions()},methods:{async onFetchUsages(){this.type===W.API?this.onFetchApiUsages():this.type===W.Proxy&&this.onFetchProxyUsages()},async onApiChange(e){await this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,api_id:e}}),this.onFetchApiUsages(),this.onFetchAggregate()},async onApisChange(e){await this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,api_id:e&&e.length?e.join(`,`):``}}),this.onFetchApiUsages(),this.onFetchAggregate()},async onTimeRangeChanged(){console.log(`onTimeRangeChanged`,this.createdAtRange),await this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,created_at_from:this.createdAtRange?this.$dayjs.format(this.createdAtRange[0].toString(),`YYYY-MM-DDTHH:mm:ss.SSSSSSZ`):``,created_at_to:this.createdAtRange?this.$dayjs.format(this.createdAtRange[1].toString(),`YYYY-MM-DDTHH:mm:ss.SSSSSSZ`):``}}),this.onFetchUsages(),this.onFetchAggregate(),this.onFetchStatusCodeOptions()},async onApplicationChange(e){await this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,application_id:e}}),this.onFetchUsages(),this.onFetchAggregate()},async onApplicationsChange(e){await this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,application_id:e&&e.length?e.join(`,`):``}}),this.onFetchUsages(),this.onFetchAggregate()},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,page:e}})},getRemainingAmount(e){if(e.remaining_amount===void 0||e.remaining_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.remaining_amount?.toFixed(6)} ${t}`},getUsedAmount(e){if(e.used_amount===void 0||e.used_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.used_amount?.toFixed(6)} ${t}`},getDeductedAmount(e){if(e?.deducted_amount===void 0||e?.deducted_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.deducted_amount?.toFixed(6)} ${t}`},getOriginalAmount(e){if(e?.original_amount===void 0||e?.original_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.original_amount?.toFixed(6)} ${t}`},onStatusCodeChange(e){let t={...this.$route.query},n=(e||``).trim();n?t.status_code=n:delete t.status_code,delete t.status_code_filter,this.$router.push({name:this.$route.name?.toString(),query:t}),this.onFetchUsages(),this.onFetchAggregate()},async onFetchStatusCodeOptions(){this.statusCodeOptionsLoading=!0;try{let{data:e}=await J.getStatusCodes({user_id:this.$store.getters.user.id,...this.applicationIds&&this.applicationIds.length?{application_id:this.applicationIds}:{},...this.apiIds&&this.apiIds.length?{api_id:this.apiIds}:{},...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0]}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1]}:{}});this.statusCodeOptions=(e?.items||[]).slice().sort((e,t)=>e-t)}catch{this.statusCodeOptions=[]}finally{this.statusCodeOptionsLoading=!1}},formatElapsed(e){return e==null||Number.isNaN(e)?`-`:e<1?`${Math.round(e*1e3)} ms`:`${e.toFixed(2)} s`},getSimpleMetadata(e){if(!e)return{};let t={};for(let[n,r]of Object.entries(e))n===`request`||n===`response`||typeof r==`object`&&r||(t[n]=r);return t},onShowDetail(e){this.detailRow={...e,metadata:void 0},this.detailActiveTab=`request`,this.detailDialogVisible=!0,this.detailLoading=!0,e.id&&J.get(e.id).then(e=>{this.detailRow=e.data}).finally(()=>{this.detailLoading=!1})},formatJson(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}},onFetchApplications(){G.getAll({limit:100,offset:0,user_id:this.$store.getters.user.id,ordering:`-created_at`,type:V.USAGE}).then(({data:e})=>{this.applications=e.items.filter(e=>e?.service?.type===this.type)}).catch(()=>{})},onFetchApis(){this.apisLoading=!0,U.getAll({limit:100,offset:0,ordering:`-created_at`}).then(({data:e})=>{this.apis=e.items}).catch(()=>{}).finally(()=>{this.apisLoading=!1})},onFetchApiUsages(){console.log(`onFetchApiUsages`,this.createdAtRange),this.loading=!0,J.getAll({limit:this.limit,offset:(this.page-1)*this.limit,user_id:this.$store.getters.user.id,ordering:`-created_at`,...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0]}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1]}:{},...this.applicationIds&&this.applicationIds.length?{application_id:this.applicationIds}:{},...this.apiIds&&this.apiIds.length?{api_id:this.apiIds}:{},...this.statusCodeFilter?{status_code:this.statusCodeFilter}:{}}).then(({data:e})=>{this.apiUsages=e.items,this.loading=!1,this.total=e.count}).catch(()=>{this.loading=!1})},onFetchProxyUsages(){this.loading=!0,z.getAll({limit:this.limit,offset:(this.page-1)*this.limit,user_id:this.$store.getters.user.id,ordering:`-created_at`,...this.applicationIds&&this.applicationIds.length?{application_id:this.applicationIds}:{}}).then(({data:e})=>{this.proxyUsages=e.items,this.loading=!1,this.total=e.count}).catch(()=>{this.loading=!1})},onExport(){this.exporting=!0,J.exportCsv({user_id:this.$store.getters.user.id,...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0]}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1]}:{},...this.applicationIds&&this.applicationIds.length?{application_id:this.applicationIds}:{},...this.apiIds&&this.apiIds.length?{api_id:this.apiIds}:{},...this.statusCodeFilter?{status_code:this.statusCodeFilter}:{}}).then(({data:e})=>{let t=window.URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`usages.csv`,n.click(),window.URL.revokeObjectURL(t)}).catch(()=>{}).finally(()=>{this.exporting=!1})},async onFetchAggregate(){if(this.aggLoading=!0,this.type!==this.serviceType.API)return;let e={user_id:this.$store.getters.user.id,...this.applicationIds&&this.applicationIds.length?{application_id:this.applicationIds}:{},...this.apiIds&&this.apiIds.length?{api_id:this.apiIds}:{},...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0]}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1]}:{}};try{let{data:t}=await J.getAggregate(e);this.totalUsed=t.total||0;let n=Array.from(new Set((t.items||[]).map(e=>e.date))).sort(),r=Array.from(new Set((t.items||[]).map(e=>e.api_id))),i=e=>`hsl(${e*57%360}, 70%, 60%)`,a=r.map((e,r)=>{let a=t.apis?.[e]?.title||e,o={};return(t.items||[]).filter(t=>t.api_id===e).forEach(e=>{o[e.date]=e.amount||0}),{key:e,label:a,data:n.map(e=>o[e]||0),color:i(r)}});this.barChartLabels=n,this.barChartSeries=a}finally{this.aggLoading=!1}}}}),Q={class:`text-[26px] font-bold mb-5 text-[var(--el-text-color-primary)]`},$={class:`inline-block w-9`},te={class:`inline-block`},ne={key:1,class:`summary-card`},re={class:`icon-wrapper`},ie={class:`text-left`},ae={class:`description`},oe={class:`value`},se={class:`chart-wrapper`},ce={key:0},le={key:1},ue={class:`flex flex-wrap gap-2`},de={class:`key`},fe={key:0,class:`cursor-pointer`},pe={class:`created-at`},me={class:`created-at`},he={key:1,class:`detail-json`},ge={key:2,class:`text-gray-400`},_e={key:1,class:`detail-json`},ve={key:2,class:`text-gray-400`},ye={class:`float-right`};function be(r,u,d,ee,m,g){let _=b(`el-col`),v=b(`el-row`),y=b(`el-radio-button`),C=b(`el-radio-group`),w=b(`el-option`),T=b(`el-select`),E=b(`el-skeleton-item`),D=b(`el-skeleton`),O=b(`el-date-picker`),k=b(`font-awesome-icon`),A=b(`el-button`),j=b(`el-card`),M=b(`bar-chart`),N=b(`el-table-column`),P=b(`el-tag`),F=b(`copy-to-clipboard`),I=b(`el-table`),L=b(`el-tab-pane`),R=b(`el-tabs`),z=b(`el-dialog`),B=b(`pagination`),V=h(`loading`);return l(),a(v,null,{default:x(()=>[o(_,{span:24},{default:x(()=>[o(v,null,{default:x(()=>[o(_,{span:24},{default:x(()=>[n(`h2`,Q,c(r.$t(`common.title.allUsages`)),1)]),_:1})]),_:1}),o(v,null,{default:x(()=>[o(_,{md:4,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:x(()=>[n(`span`,null,c(r.$t(`application.field.type`)),1),o(C,{modelValue:r.type,"onUpdate:modelValue":u[0]||=e=>r.type=e},{default:x(()=>[o(y,{value:r.serviceType.API,label:r.$t(`application.field.api`)},null,8,[`value`,`label`]),o(y,{value:r.serviceType.Proxy,label:r.$t(`application.field.proxy`)},null,8,[`value`,`label`])]),_:1},8,[`modelValue`])]),_:1}),f(o(_,{md:6,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:x(()=>[n(`span`,$,c(r.$t(`usage.field.application`)),1),o(T,{modelValue:r.applicationIds,"onUpdate:modelValue":u[1]||=e=>r.applicationIds=e,placeholder:r.$t(`usage.field.application`),clearable:``,multiple:``,"collapse-tags":``,"collapse-tags-tooltip":``,class:`w-full`,onChange:r.onApplicationsChange},{default:x(()=>[(l(!0),t(s,null,e(r.applications,e=>(l(),a(w,{key:e.id,label:e.service?.title,value:e?.id},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`])]),_:1},512),[[S,!1]]),r.type===r.serviceType.API?(l(),a(_,{key:0,md:6,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:x(()=>[n(`span`,te,c(r.$t(`usage.field.api`)),1),r.apisLoading?(l(),a(D,{key:0,animated:``,class:`w-full`},{template:x(()=>[o(E,{variant:`rect`,style:{height:`32px`,"border-radius":`4px`}})]),_:1})):(l(),a(T,{key:1,modelValue:r.apiIds,"onUpdate:modelValue":u[2]||=e=>r.apiIds=e,placeholder:r.$t(`usage.field.api`),clearable:``,filterable:``,multiple:``,"collapse-tags":``,"collapse-tags-tooltip":``,class:`w-full`,onChange:r.onApisChange},{default:x(()=>[(l(!0),t(s,null,e(r.apis,e=>(l(),a(w,{key:e?.id,label:e?.title,value:e?.id},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]))]),_:1})):p(``,!0),r.type===r.serviceType.API?(l(),a(_,{key:1,md:8,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:x(()=>[o(O,{modelValue:r.createdAtRange,"onUpdate:modelValue":u[3]||=e=>r.createdAtRange=e,type:`datetimerange`,class:`w-full`,shortcuts:r.shortcuts,"range-separator":r.$t(`usage.placeholder.to`),"start-placeholder":r.$t(`usage.placeholder.startDate`),"end-placeholder":r.$t(`usage.placeholder.endDate`),onChange:r.onTimeRangeChanged},null,8,[`modelValue`,`shortcuts`,`range-separator`,`start-placeholder`,`end-placeholder`,`onChange`])]),_:1})):p(``,!0),r.type===r.serviceType.API?(l(),a(_,{key:2,md:3,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:x(()=>[o(T,{modelValue:r.statusCodeFilter,"onUpdate:modelValue":u[4]||=e=>r.statusCodeFilter=e,placeholder:r.$t(`usage.option.statusCodeAll`),class:`w-full`,clearable:``,filterable:``,"allow-create":``,"default-first-option":``,loading:r.statusCodeOptionsLoading,onChange:r.onStatusCodeChange},{default:x(()=>[(l(!0),t(s,null,e(r.statusCodeOptions,e=>(l(),a(w,{key:e,label:String(e),value:String(e)},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`loading`,`onChange`])]),_:1})):p(``,!0),r.type===r.serviceType.API?(l(),a(_,{key:3,md:3,xs:24,class:`mb-5 flex px-2 gap-2 items-center justify-end`},{default:x(()=>[o(A,{type:`primary`,plain:``,loading:r.exporting,class:`w-full whitespace-nowrap`,onClick:r.onExport},{default:x(()=>[o(k,{icon:`fa-solid fa-file-export`,class:`mr-1`}),i(` `+c(r.$t(`usage.button.export`)),1)]),_:1},8,[`loading`,`onClick`])]),_:1})):p(``,!0)]),_:1}),o(v,null,{default:x(()=>[o(_,{span:24},{default:x(()=>[r.type===r.serviceType.API?(l(),a(v,{key:0,gutter:24,class:`mb-5`},{default:x(()=>[o(_,{md:6,xs:24},{default:x(()=>[o(j,{shadow:`hover`,class:`h-full`},{default:x(()=>[r.aggLoading?(l(),a(D,{key:0})):(l(),t(`div`,ne,[n(`div`,re,[o(k,{icon:`fa-solid fa-cubes`,class:`icon`})]),n(`div`,ie,[n(`p`,ae,c(r.$t(`usage.title.totalUsed`)),1),n(`p`,oe,c(r.totalUsedString),1)])]))]),_:1})]),_:1}),o(_,{md:18,xs:24},{default:x(()=>[o(j,{shadow:`hover`,class:`h-full`},{default:x(()=>[n(`div`,se,[r.aggLoading?(l(),a(D,{key:0,class:`w-full`})):(l(),a(M,{key:1,data:r.barChartData,options:r.barChartOptions,class:`chart`},null,8,[`data`,`options`]))])]),_:1})]),_:1})]),_:1})):p(``,!0),o(j,{shadow:`hover`},{default:x(()=>[r.type===r.serviceType.API?f((l(),a(I,{key:0,data:r.apiUsages,stripe:``,"table-layout":`fixed`,"empty-text":r.$t(`common.message.noData`),class:`min-h-[calc(100vh-350px)] mb-5`},{default:x(()=>[o(N,{label:r.$t(`application.field.name`),width:`160px`},{default:x(e=>[n(`span`,null,c(e.row?.api?.title),1)]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.statusCode`),width:`120px`},{default:x(e=>[n(`span`,null,c(e.row.status_code),1)]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.elapsed`),width:`120px`},{default:x(e=>[n(`span`,null,c(r.formatElapsed(e.row.elapsed)),1)]),_:1},8,[`label`]),o(N,{prop:`deducted_amount`,label:r.$t(`usage.field.deductedAmount`),width:`150px`,"class-name":`text-center`},{default:x(e=>[r.getDeductedAmount(e.row)===r.getOriginalAmount(e.row)?(l(),t(`div`,ce,[n(`span`,null,c(r.getDeductedAmount(e.row)),1)])):(l(),t(`div`,le,[u[7]||=n(`p`,null,null,-1),n(`p`,null,[n(`span`,null,c(r.getDeductedAmount(e.row)),1)]),n(`p`,null,[n(`del`,null,c(r.getOriginalAmount(e.row)),1)])]))]),_:1},8,[`label`]),o(N,{prop:`remaining_amount`,label:r.$t(`usage.field.balanceAfter`),width:`160px`,"class-name":`text-center`},{default:x(e=>[n(`span`,null,c(r.getRemainingAmount(e.row)),1)]),_:1},8,[`label`]),o(N,{prop:`metadata`,label:r.$t(`usage.field.metadata`),width:`260px`,"class-name":`text-center`},{default:x(o=>[n(`div`,ue,[o.row.original_amount>o.row.deducted_amount&&o.row.original_amount>0?(l(),a(P,{key:0,type:`success`,style:{textWrap:`wrap`,height:`fit-content`,lineHeight:`20px`,borderRadius:`10px`}},{default:x(()=>[i(c(((o.row.original_amount-o.row.deducted_amount)*100/o.row.original_amount).toFixed(0)+`% OFF`),1)]),_:2},1024)):p(``,!0),(l(!0),t(s,null,e(r.getSimpleMetadata(o.row.metadata),(e,t)=>(l(),a(P,{key:t,style:{textWrap:`wrap`,height:`fit-content`,lineHeight:`20px`,borderRadius:`10px`}},{default:x(()=>[i(c(t)+`: `+c(e),1)]),_:2},1024))),128))])]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.button.viewDetail`),width:`120px`,"class-name":`text-center`},{default:x(e=>[e.row.id?(l(),a(A,{key:0,type:`primary`,plain:``,size:`small`,class:`!px-2 !py-1 !text-xs !h-auto !min-h-0`,onClick:t=>r.onShowDetail(e.row)},{default:x(()=>[i(c(r.$t(`usage.button.viewDetail`)),1)]),_:1},8,[`onClick`])):p(``,!0)]),_:1},8,[`label`]),o(N,{prop:`trace_id`,label:r.$t(`application.field.traceId`),width:`200px`,"class-name":`text-center`},{default:x(e=>[n(`span`,de,c(e.row.trace_id),1),e.row.trace_id?(l(),t(`span`,fe,[o(F,{content:e.row.trace_id,class:`inline-block`},null,8,[`content`])])):p(``,!0)]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.createdAt`),width:`200px`},{default:x(e=>[n(`span`,pe,c(r.$dayjs.format(e.row.created_at)),1)]),_:1},8,[`label`])]),_:1},8,[`data`,`empty-text`])),[[V,r.loading]]):p(``,!0),r.type===r.serviceType.Proxy?f((l(),a(I,{key:1,data:r.proxyUsages,stripe:``,"table-layout":`fixed`,"empty-text":r.$t(`common.message.noData`),class:`min-h-[calc(100vh-350px)] mb-5`},{default:x(()=>[o(N,{label:r.$t(`application.field.name`),width:`160px`},{default:x(e=>[n(`span`,null,c(e.row?.service?.title),1)]),_:1},8,[`label`]),o(N,{prop:`remaining_amount`,label:r.$t(`usage.field.remainingAmount`),width:`160px`,"class-name":`text-center`},{default:x(e=>[n(`span`,null,c(r.getRemainingAmount(e.row)),1),n(`span`,null,c(r.getOriginalAmount(e.row)),1)]),_:1},8,[`label`]),o(N,{prop:`deducted_amount`,label:r.$t(`usage.field.deductedAmount`),width:`150px`,"class-name":`text-center`},{default:x(e=>[n(`span`,null,c(r.getDeductedAmount(e.row)),1)]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.balanceAfter`),width:`160px`,"class-name":`text-center`},{default:x(e=>[n(`span`,null,c(r.getRemainingAmount(e.row)),1)]),_:1},8,[`label`]),o(N,{prop:`metadata`,label:r.$t(`usage.field.metadata`),width:`200px`,"class-name":`text-center`},{default:x(n=>[(l(!0),t(s,null,e(n.row.metadata,(e,t)=>(l(),a(P,{key:t,class:`mb-2`},{default:x(()=>[i(c(t)+`: `+c(e),1)]),_:2},1024))),128))]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.createdAt`),width:`200px`},{default:x(e=>[n(`span`,me,c(r.$dayjs.format(e.row.created_at)),1)]),_:1},8,[`label`])]),_:1},8,[`data`,`empty-text`])),[[V,r.loading]]):p(``,!0)]),_:1})]),_:1})]),_:1}),o(z,{modelValue:r.detailDialogVisible,"onUpdate:modelValue":u[6]||=e=>r.detailDialogVisible=e,title:r.$t(`usage.dialog.detailTitle`),width:`70%`,top:`5vh`,"destroy-on-close":``},{default:x(()=>[o(R,{modelValue:r.detailActiveTab,"onUpdate:modelValue":u[5]||=e=>r.detailActiveTab=e},{default:x(()=>[o(L,{label:r.$t(`usage.dialog.request`),name:`request`},{default:x(()=>[r.detailLoading?(l(),a(D,{key:0,rows:6,animated:``})):r.detailRow?.metadata?.request?(l(),t(`pre`,he,c(r.formatJson(r.detailRow.metadata.request)),1)):(l(),t(`p`,ge,c(r.$t(`usage.dialog.noData`)),1))]),_:1},8,[`label`]),o(L,{label:r.$t(`usage.dialog.response`),name:`response`},{default:x(()=>[r.detailLoading?(l(),a(D,{key:0,rows:6,animated:``})):r.detailRow?.metadata?.response?(l(),t(`pre`,_e,c(r.formatJson(r.detailRow.metadata.response)),1)):(l(),t(`p`,ve,c(r.$t(`usage.dialog.noData`)),1))]),_:1},8,[`label`])]),_:1},8,[`modelValue`])]),_:1},8,[`modelValue`,`title`]),o(v,null,{default:x(()=>[o(_,{span:10,offset:14},{default:x(()=>[n(`div`,ye,[o(B,{"current-page":r.page,"page-size":r.limit,total:r.total,onChange:r.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var xe=H(Z,[[`render`,be],[`__scopeId`,`data-v-38f1845c`]]);export{xe as default};
@@ -1 +1 @@
1
- import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,dt as u,nt as d,tt as f,ut as p}from"./vendor-chart-BJCvKk8-.js";import{t as m}from"./button-BydTr5nV.js";import{r as h,t as g}from"./select-ClTB8Ac0.js";import{n as _,t as v}from"./table-B5c9kfrJ.js";import{t as y}from"./card-DjyfNde2.js";import{t as b}from"./date-picker-Y5A3NHvV.js";import{n as x,t as S}from"./row-D9p6UztY.js";import{t as C}from"./Pagination-Bh6hrzJJ.js";import{t as w}from"./skeleton-BwNBivMN.js";import{Er as T,Ln as E,O as D,Wr as O,Wt as k}from"./index-4nyvtI8-.js";import{t as A}from"./index.es-B6_5ZbW0.js";import{t as j}from"./CopyToClipboard-BYFO-_G-.js";var M={total_count:0,total_spent:0,state_counts:{}},N=r({name:`ConsoleOrderList`,components:{Pagination:C,CopyToClipboard:j,ElRow:S,ElCol:x,ElTable:v,ElTableColumn:_,ElButton:m,ElTag:O,ElCard:y,ElSelect:h,ElOption:g,ElDatePicker:b,ElSkeleton:w,FontAwesomeIcon:A},data(){return{OrderState:T,orders:[],loading:!1,total:void 0,limit:10,filterState:this.$route.query.state?.toString()||``,filterPayWay:this.$route.query.pay_way?.toString()||``,createdAtRange:(()=>{let e=this.$route.query.created_at_from?.toString(),t=this.$route.query.created_at_to?.toString();if(e&&t)return[new Date(e),new Date(t)]})(),summary:{...M},summaryLoading:!1,exporting:!1,shortcuts:[{text:this.$t(`usage.shortcuts.today`),value:()=>{let e=new Date,t=new Date;return t.setHours(0,0,0,0),[t,e]}},{text:this.$t(`usage.shortcuts.last7Days`),value:()=>{let e=new Date,t=new Date;return t.setDate(t.getDate()-7),[t,e]}},{text:this.$t(`usage.shortcuts.last1Month`),value:()=>{let e=new Date,t=new Date;return t.setMonth(t.getMonth()-1),[t,e]}}]}},computed:{page(){return parseInt(this.$route.query.page?.toString()||`1`)},stateOptions(){return[{value:T.PENDING,label:this.$t(`order.state.pending`)},{value:T.FINISHED,label:this.$t(`order.state.finished`)},{value:T.PAID,label:this.$t(`order.state.paid`)},{value:T.EXPIRED,label:this.$t(`order.state.expired`)},{value:T.FAILED,label:this.$t(`order.state.failed`)},{value:T.REFUNDED,label:this.$t(`order.state.refunded`)}]},payWayOptions(){return[{value:`WechatPay`,label:this.$t(`order.title.wechatPay`)},{value:`Stripe`,label:this.$t(`order.title.stripe`)},{value:`AliPay`,label:this.$t(`order.title.aliPay`)},{value:`X402`,label:this.$t(`order.title.x402`)},{value:`PayPal`,label:this.$t(`order.title.paypal`)}]},filterQuery(){let e={user_id:this.$store.getters.user?.id};return this.filterState&&(e.state=this.filterState),this.filterPayWay&&(e.pay_way=this.filterPayWay),this.createdAtRange?.[0]&&(e.created_at_from=this.createdAtRange[0]),this.createdAtRange?.[1]&&(e.created_at_to=this.createdAtRange[1]),e}},watch:{page:{handler(){this.onFetchData()}}},mounted(){this.onFetchData(),this.onFetchSummary()},methods:{getPriceString:k,stateTagType(e){return e===T.FINISHED||e===T.PAID?`success`:e===T.EXPIRED||e===T.FAILED?`danger`:e===T.REFUNDED?`warning`:`info`},stateLabel(e){return{[T.PENDING]:this.$t(`order.state.pending`),[T.PAID]:this.$t(`order.state.paid`),[T.FINISHED]:this.$t(`order.state.finished`),[T.EXPIRED]:this.$t(`order.state.expired`),[T.FAILED]:this.$t(`order.state.failed`),[T.REFUNDED]:this.$t(`order.state.refunded`)}[e]||e},isPendingAction(e){return e!==T.PAID&&e!==T.FINISHED&&e!==T.EXPIRED&&e!==T.FAILED&&e!==T.REFUNDED},goToDetail(e){this.$router.push({name:`console-order-detail`,params:{id:e}})},async onFilterChange(){await this.$router.push({name:this.$route.name?.toString(),query:{page:1,...this.filterState?{state:this.filterState}:{},...this.filterPayWay?{pay_way:this.filterPayWay}:{},...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0].toISOString()}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1].toISOString()}:{}}}),this.onFetchData(),this.onFetchSummary()},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,page:e}})},onFetchData(){this.loading=!0,E.getAll({ordering:`-created_at`,limit:this.limit,offset:(this.page-1)*this.limit,...this.filterQuery}).then(({data:e})=>{this.orders=e.items,this.total=e.count}).catch(()=>{}).finally(()=>{this.loading=!1})},onFetchSummary(){this.summaryLoading=!0,E.getSummary(this.filterQuery).then(({data:e})=>{this.summary=e}).catch(()=>{this.summary={...M}}).finally(()=>{this.summaryLoading=!1})},onExport(){this.exporting=!0,E.exportCsv(this.filterQuery).then(({data:e})=>{let t=window.URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`orders.csv`,n.click(),window.URL.revokeObjectURL(t)}).catch(()=>{}).finally(()=>{this.exporting=!1})}}}),P={class:`title`},F={key:1,class:`card-content`},I={class:`icon-wrapper`},L={class:`description`},R={class:`value`},z={key:1,class:`card-content`},B={class:`icon-wrapper`},V={class:`description`},H={class:`value`},U={key:1,class:`card-content`},W={class:`icon-wrapper`},ee={class:`description`},G={class:`value`},K={key:1,class:`card-content`},q={class:`icon-wrapper`},J={class:`description`},Y={class:`value`},X={class:`filter-row mb-3`},Z={class:`key`},Q={class:`cursor-pointer`},$={class:`price`},te={class:`description`},ne={class:`text-gray-500`},re={class:`created-at`},ie={class:`flex items-center justify-center flex-wrap`},ae={class:`float-right`};function oe(r,m,h,g,_,v){let y=f(`el-col`),b=f(`el-row`),x=f(`el-skeleton`),S=f(`font-awesome-icon`),C=f(`el-card`),w=f(`el-option`),T=f(`el-select`),E=f(`el-date-picker`),D=f(`el-button`),O=f(`copy-to-clipboard`),k=f(`el-table-column`),A=f(`el-tag`),j=f(`el-table`),M=f(`pagination`),N=d(`loading`);return l(),a(b,{class:`panel`},{default:p(()=>[o(y,{span:24},{default:p(()=>[o(b,null,{default:p(()=>[o(y,{span:24},{default:p(()=>[n(`h2`,P,c(r.$t(`common.title.allOrders`)),1)]),_:1})]),_:1}),o(b,{gutter:16},{default:p(()=>[o(y,{md:6,sm:12,xs:24},{default:p(()=>[o(C,{shadow:`hover`,class:`item-mini mb-3`},{default:p(()=>[r.summaryLoading?(l(),a(x,{key:0})):(l(),t(`div`,F,[n(`div`,I,[o(S,{icon:`fa-solid fa-receipt`,class:`icon`})]),n(`p`,L,c(r.$t(`order.title.totalOrders`)),1),n(`p`,R,c(r.summary.total_count),1)]))]),_:1})]),_:1}),o(y,{md:6,sm:12,xs:24},{default:p(()=>[o(C,{shadow:`hover`,class:`item-mini mb-3`},{default:p(()=>[r.summaryLoading?(l(),a(x,{key:0})):(l(),t(`div`,z,[n(`div`,B,[o(S,{icon:`fa-solid fa-dollar-sign`,class:`icon`})]),n(`p`,V,c(r.$t(`order.title.totalSpent`)),1),n(`p`,H,c(r.getPriceString({value:r.summary.total_spent})),1)]))]),_:1})]),_:1}),o(y,{md:6,sm:12,xs:24},{default:p(()=>[o(C,{shadow:`hover`,class:`item-mini mb-3`},{default:p(()=>[r.summaryLoading?(l(),a(x,{key:0})):(l(),t(`div`,U,[n(`div`,W,[o(S,{icon:`fa-solid fa-check-circle`,class:`icon`})]),n(`p`,ee,c(r.$t(`order.title.finishedOrders`)),1),n(`p`,G,c(r.summary.state_counts?.Finished||0),1)]))]),_:1})]),_:1}),o(y,{md:6,sm:12,xs:24},{default:p(()=>[o(C,{shadow:`hover`,class:`item-mini mb-3`},{default:p(()=>[r.summaryLoading?(l(),a(x,{key:0})):(l(),t(`div`,K,[n(`div`,q,[o(S,{icon:`fa-solid fa-clock`,class:`icon`})]),n(`p`,J,c(r.$t(`order.title.pendingOrders`)),1),n(`p`,Y,c(r.summary.state_counts?.Pending||0),1)]))]),_:1})]),_:1})]),_:1}),n(`div`,X,[o(T,{modelValue:r.filterState,"onUpdate:modelValue":m[0]||=e=>r.filterState=e,clearable:``,placeholder:r.$t(`order.field.allStates`),class:`filter-select`,onChange:r.onFilterChange},{default:p(()=>[(l(!0),t(s,null,e(r.stateOptions,e=>(l(),a(w,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]),o(T,{modelValue:r.filterPayWay,"onUpdate:modelValue":m[1]||=e=>r.filterPayWay=e,clearable:``,placeholder:r.$t(`order.field.allPayWays`),class:`filter-select`,onChange:r.onFilterChange},{default:p(()=>[(l(!0),t(s,null,e(r.payWayOptions,e=>(l(),a(w,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]),o(E,{modelValue:r.createdAtRange,"onUpdate:modelValue":m[2]||=e=>r.createdAtRange=e,type:`datetimerange`,shortcuts:r.shortcuts,"range-separator":r.$t(`usage.placeholder.to`),"start-placeholder":r.$t(`usage.placeholder.startDate`),"end-placeholder":r.$t(`usage.placeholder.endDate`),onChange:r.onFilterChange},null,8,[`modelValue`,`shortcuts`,`range-separator`,`start-placeholder`,`end-placeholder`,`onChange`]),o(D,{type:`primary`,plain:``,loading:r.exporting,onClick:r.onExport},{default:p(()=>[o(S,{icon:`fa-solid fa-file-export`,class:`mr-1`}),i(` `+c(r.$t(`order.button.export`)),1)]),_:1},8,[`loading`,`onClick`])]),o(b,null,{default:p(()=>[o(y,{span:24},{default:p(()=>[o(C,{shadow:`hover`},{default:p(()=>[u((l(),a(j,{data:r.orders,stripe:``,"empty-text":r.$t(`common.message.noData`),class:`min-h-[calc(100vh-450px)] mb-[20px]`},{default:p(()=>[o(k,{prop:`id`,label:r.$t(`order.field.id`),"class-name":`text-center`,width:`200px`},{default:p(e=>[n(`span`,Z,c(e.row.id),1),n(`span`,Q,[o(O,{content:e.row.id,class:`inline-block`},null,8,[`content`])])]),_:1},8,[`label`]),o(k,{label:r.$t(`order.field.price`),width:`110px`,align:`center`},{default:p(e=>[n(`span`,$,c(r.getPriceString({value:e.row?.price})),1)]),_:1},8,[`label`]),o(k,{label:r.$t(`order.field.description`),"min-width":`220px`,"class-name":`hidden md:table-cell`,"label-class-name":`hidden md:table-cell`},{default:p(e=>[n(`span`,te,c(e.row.description),1)]),_:1},8,[`label`]),o(k,{prop:`state`,label:r.$t(`order.field.state`),width:`130px`,align:`center`},{default:p(e=>[o(A,{type:r.stateTagType(e.row.state),class:`mx-1`,effect:`dark`,round:``,size:`small`},{default:p(()=>[i(c(r.stateLabel(e.row.state)),1)]),_:2},1032,[`type`])]),_:1},8,[`label`]),o(k,{label:r.$t(`order.field.payWay`),width:`120px`,align:`center`,"class-name":`hidden md:table-cell`,"label-class-name":`hidden md:table-cell`},{default:p(e=>[n(`span`,ne,c(e.row.pay_way||`-`),1)]),_:1},8,[`label`]),o(k,{label:r.$t(`order.field.createdAt`),width:`200px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:p(e=>[n(`span`,re,c(r.$dayjs.format(e.row.created_at)),1)]),_:1},8,[`label`]),o(k,{"min-width":`130px`,fixed:`right`},{default:p(e=>[n(`div`,ie,[r.isPendingAction(e.row.state)?(l(),a(D,{key:0,type:`primary`,size:`small`,onClick:t=>r.goToDetail(e.row.id)},{default:p(()=>[i(c(r.$t(`order.button.continuePay`)),1)]),_:1},8,[`onClick`])):(l(),a(D,{key:1,size:`small`,onClick:t=>r.goToDetail(e.row.id)},{default:p(()=>[i(c(r.$t(`order.button.checkDetail`)),1)]),_:1},8,[`onClick`]))])]),_:1})]),_:1},8,[`data`,`empty-text`])),[[N,r.loading]])]),_:1})]),_:1})]),_:1}),o(b,null,{default:p(()=>[o(y,{span:10,offset:14},{default:p(()=>[n(`div`,ae,[o(M,{"current-page":r.page,"page-size":r.limit,total:r.total,onChange:r.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var se=D(N,[[`render`,oe],[`__scopeId`,`data-v-350ab467`]]);export{se as default};
1
+ import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,dt as u,nt as d,tt as f,ut as p}from"./vendor-chart-BJCvKk8-.js";import{t as m}from"./button-BydTr5nV.js";import{r as h,t as g}from"./select-CTGAdTl9.js";import{n as _,t as v}from"./table-B5c9kfrJ.js";import{t as y}from"./card-DjyfNde2.js";import{t as b}from"./date-picker-BB05x7os.js";import{n as x,t as S}from"./row-CuqrRPyi.js";import{t as C}from"./Pagination-B_hKCtLs.js";import{t as w}from"./skeleton-BwNBivMN.js";import{Er as T,Ln as E,O as D,Wr as O,Wt as k}from"./index-DlJr9VYp.js";import{t as A}from"./index.es-BHvvolz-.js";import{t as j}from"./CopyToClipboard--2jgu_fL.js";var M={total_count:0,total_spent:0,state_counts:{}},N=r({name:`ConsoleOrderList`,components:{Pagination:C,CopyToClipboard:j,ElRow:S,ElCol:x,ElTable:v,ElTableColumn:_,ElButton:m,ElTag:O,ElCard:y,ElSelect:h,ElOption:g,ElDatePicker:b,ElSkeleton:w,FontAwesomeIcon:A},data(){return{OrderState:T,orders:[],loading:!1,total:void 0,limit:10,filterState:this.$route.query.state?.toString()||``,filterPayWay:this.$route.query.pay_way?.toString()||``,createdAtRange:(()=>{let e=this.$route.query.created_at_from?.toString(),t=this.$route.query.created_at_to?.toString();if(e&&t)return[new Date(e),new Date(t)]})(),summary:{...M},summaryLoading:!1,exporting:!1,shortcuts:[{text:this.$t(`usage.shortcuts.today`),value:()=>{let e=new Date,t=new Date;return t.setHours(0,0,0,0),[t,e]}},{text:this.$t(`usage.shortcuts.last7Days`),value:()=>{let e=new Date,t=new Date;return t.setDate(t.getDate()-7),[t,e]}},{text:this.$t(`usage.shortcuts.last1Month`),value:()=>{let e=new Date,t=new Date;return t.setMonth(t.getMonth()-1),[t,e]}}]}},computed:{page(){return parseInt(this.$route.query.page?.toString()||`1`)},stateOptions(){return[{value:T.PENDING,label:this.$t(`order.state.pending`)},{value:T.FINISHED,label:this.$t(`order.state.finished`)},{value:T.PAID,label:this.$t(`order.state.paid`)},{value:T.EXPIRED,label:this.$t(`order.state.expired`)},{value:T.FAILED,label:this.$t(`order.state.failed`)},{value:T.REFUNDED,label:this.$t(`order.state.refunded`)}]},payWayOptions(){return[{value:`WechatPay`,label:this.$t(`order.title.wechatPay`)},{value:`Stripe`,label:this.$t(`order.title.stripe`)},{value:`AliPay`,label:this.$t(`order.title.aliPay`)},{value:`X402`,label:this.$t(`order.title.x402`)},{value:`PayPal`,label:this.$t(`order.title.paypal`)}]},filterQuery(){let e={user_id:this.$store.getters.user?.id};return this.filterState&&(e.state=this.filterState),this.filterPayWay&&(e.pay_way=this.filterPayWay),this.createdAtRange?.[0]&&(e.created_at_from=this.createdAtRange[0]),this.createdAtRange?.[1]&&(e.created_at_to=this.createdAtRange[1]),e}},watch:{page:{handler(){this.onFetchData()}}},mounted(){this.onFetchData(),this.onFetchSummary()},methods:{getPriceString:k,stateTagType(e){return e===T.FINISHED||e===T.PAID?`success`:e===T.EXPIRED||e===T.FAILED?`danger`:e===T.REFUNDED?`warning`:`info`},stateLabel(e){return{[T.PENDING]:this.$t(`order.state.pending`),[T.PAID]:this.$t(`order.state.paid`),[T.FINISHED]:this.$t(`order.state.finished`),[T.EXPIRED]:this.$t(`order.state.expired`),[T.FAILED]:this.$t(`order.state.failed`),[T.REFUNDED]:this.$t(`order.state.refunded`)}[e]||e},isPendingAction(e){return e!==T.PAID&&e!==T.FINISHED&&e!==T.EXPIRED&&e!==T.FAILED&&e!==T.REFUNDED},goToDetail(e){this.$router.push({name:`console-order-detail`,params:{id:e}})},async onFilterChange(){await this.$router.push({name:this.$route.name?.toString(),query:{page:1,...this.filterState?{state:this.filterState}:{},...this.filterPayWay?{pay_way:this.filterPayWay}:{},...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0].toISOString()}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1].toISOString()}:{}}}),this.onFetchData(),this.onFetchSummary()},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,page:e}})},onFetchData(){this.loading=!0,E.getAll({ordering:`-created_at`,limit:this.limit,offset:(this.page-1)*this.limit,...this.filterQuery}).then(({data:e})=>{this.orders=e.items,this.total=e.count}).catch(()=>{}).finally(()=>{this.loading=!1})},onFetchSummary(){this.summaryLoading=!0,E.getSummary(this.filterQuery).then(({data:e})=>{this.summary=e}).catch(()=>{this.summary={...M}}).finally(()=>{this.summaryLoading=!1})},onExport(){this.exporting=!0,E.exportCsv(this.filterQuery).then(({data:e})=>{let t=window.URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`orders.csv`,n.click(),window.URL.revokeObjectURL(t)}).catch(()=>{}).finally(()=>{this.exporting=!1})}}}),P={class:`title`},F={key:1,class:`card-content`},I={class:`icon-wrapper`},L={class:`description`},R={class:`value`},z={key:1,class:`card-content`},B={class:`icon-wrapper`},V={class:`description`},H={class:`value`},U={key:1,class:`card-content`},W={class:`icon-wrapper`},ee={class:`description`},G={class:`value`},K={key:1,class:`card-content`},q={class:`icon-wrapper`},J={class:`description`},Y={class:`value`},X={class:`filter-row mb-3`},Z={class:`key`},Q={class:`cursor-pointer`},$={class:`price`},te={class:`description`},ne={class:`text-gray-500`},re={class:`created-at`},ie={class:`flex items-center justify-center flex-wrap`},ae={class:`float-right`};function oe(r,m,h,g,_,v){let y=f(`el-col`),b=f(`el-row`),x=f(`el-skeleton`),S=f(`font-awesome-icon`),C=f(`el-card`),w=f(`el-option`),T=f(`el-select`),E=f(`el-date-picker`),D=f(`el-button`),O=f(`copy-to-clipboard`),k=f(`el-table-column`),A=f(`el-tag`),j=f(`el-table`),M=f(`pagination`),N=d(`loading`);return l(),a(b,{class:`panel`},{default:p(()=>[o(y,{span:24},{default:p(()=>[o(b,null,{default:p(()=>[o(y,{span:24},{default:p(()=>[n(`h2`,P,c(r.$t(`common.title.allOrders`)),1)]),_:1})]),_:1}),o(b,{gutter:16},{default:p(()=>[o(y,{md:6,sm:12,xs:24},{default:p(()=>[o(C,{shadow:`hover`,class:`item-mini mb-3`},{default:p(()=>[r.summaryLoading?(l(),a(x,{key:0})):(l(),t(`div`,F,[n(`div`,I,[o(S,{icon:`fa-solid fa-receipt`,class:`icon`})]),n(`p`,L,c(r.$t(`order.title.totalOrders`)),1),n(`p`,R,c(r.summary.total_count),1)]))]),_:1})]),_:1}),o(y,{md:6,sm:12,xs:24},{default:p(()=>[o(C,{shadow:`hover`,class:`item-mini mb-3`},{default:p(()=>[r.summaryLoading?(l(),a(x,{key:0})):(l(),t(`div`,z,[n(`div`,B,[o(S,{icon:`fa-solid fa-dollar-sign`,class:`icon`})]),n(`p`,V,c(r.$t(`order.title.totalSpent`)),1),n(`p`,H,c(r.getPriceString({value:r.summary.total_spent})),1)]))]),_:1})]),_:1}),o(y,{md:6,sm:12,xs:24},{default:p(()=>[o(C,{shadow:`hover`,class:`item-mini mb-3`},{default:p(()=>[r.summaryLoading?(l(),a(x,{key:0})):(l(),t(`div`,U,[n(`div`,W,[o(S,{icon:`fa-solid fa-check-circle`,class:`icon`})]),n(`p`,ee,c(r.$t(`order.title.finishedOrders`)),1),n(`p`,G,c(r.summary.state_counts?.Finished||0),1)]))]),_:1})]),_:1}),o(y,{md:6,sm:12,xs:24},{default:p(()=>[o(C,{shadow:`hover`,class:`item-mini mb-3`},{default:p(()=>[r.summaryLoading?(l(),a(x,{key:0})):(l(),t(`div`,K,[n(`div`,q,[o(S,{icon:`fa-solid fa-clock`,class:`icon`})]),n(`p`,J,c(r.$t(`order.title.pendingOrders`)),1),n(`p`,Y,c(r.summary.state_counts?.Pending||0),1)]))]),_:1})]),_:1})]),_:1}),n(`div`,X,[o(T,{modelValue:r.filterState,"onUpdate:modelValue":m[0]||=e=>r.filterState=e,clearable:``,placeholder:r.$t(`order.field.allStates`),class:`filter-select`,onChange:r.onFilterChange},{default:p(()=>[(l(!0),t(s,null,e(r.stateOptions,e=>(l(),a(w,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]),o(T,{modelValue:r.filterPayWay,"onUpdate:modelValue":m[1]||=e=>r.filterPayWay=e,clearable:``,placeholder:r.$t(`order.field.allPayWays`),class:`filter-select`,onChange:r.onFilterChange},{default:p(()=>[(l(!0),t(s,null,e(r.payWayOptions,e=>(l(),a(w,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]),o(E,{modelValue:r.createdAtRange,"onUpdate:modelValue":m[2]||=e=>r.createdAtRange=e,type:`datetimerange`,shortcuts:r.shortcuts,"range-separator":r.$t(`usage.placeholder.to`),"start-placeholder":r.$t(`usage.placeholder.startDate`),"end-placeholder":r.$t(`usage.placeholder.endDate`),onChange:r.onFilterChange},null,8,[`modelValue`,`shortcuts`,`range-separator`,`start-placeholder`,`end-placeholder`,`onChange`]),o(D,{type:`primary`,plain:``,loading:r.exporting,onClick:r.onExport},{default:p(()=>[o(S,{icon:`fa-solid fa-file-export`,class:`mr-1`}),i(` `+c(r.$t(`order.button.export`)),1)]),_:1},8,[`loading`,`onClick`])]),o(b,null,{default:p(()=>[o(y,{span:24},{default:p(()=>[o(C,{shadow:`hover`},{default:p(()=>[u((l(),a(j,{data:r.orders,stripe:``,"empty-text":r.$t(`common.message.noData`),class:`min-h-[calc(100vh-450px)] mb-[20px]`},{default:p(()=>[o(k,{prop:`id`,label:r.$t(`order.field.id`),"class-name":`text-center`,width:`200px`},{default:p(e=>[n(`span`,Z,c(e.row.id),1),n(`span`,Q,[o(O,{content:e.row.id,class:`inline-block`},null,8,[`content`])])]),_:1},8,[`label`]),o(k,{label:r.$t(`order.field.price`),width:`110px`,align:`center`},{default:p(e=>[n(`span`,$,c(r.getPriceString({value:e.row?.price})),1)]),_:1},8,[`label`]),o(k,{label:r.$t(`order.field.description`),"min-width":`220px`,"class-name":`hidden md:table-cell`,"label-class-name":`hidden md:table-cell`},{default:p(e=>[n(`span`,te,c(e.row.description),1)]),_:1},8,[`label`]),o(k,{prop:`state`,label:r.$t(`order.field.state`),width:`130px`,align:`center`},{default:p(e=>[o(A,{type:r.stateTagType(e.row.state),class:`mx-1`,effect:`dark`,round:``,size:`small`},{default:p(()=>[i(c(r.stateLabel(e.row.state)),1)]),_:2},1032,[`type`])]),_:1},8,[`label`]),o(k,{label:r.$t(`order.field.payWay`),width:`120px`,align:`center`,"class-name":`hidden md:table-cell`,"label-class-name":`hidden md:table-cell`},{default:p(e=>[n(`span`,ne,c(e.row.pay_way||`-`),1)]),_:1},8,[`label`]),o(k,{label:r.$t(`order.field.createdAt`),width:`200px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:p(e=>[n(`span`,re,c(r.$dayjs.format(e.row.created_at)),1)]),_:1},8,[`label`]),o(k,{"min-width":`130px`,fixed:`right`},{default:p(e=>[n(`div`,ie,[r.isPendingAction(e.row.state)?(l(),a(D,{key:0,type:`primary`,size:`small`,onClick:t=>r.goToDetail(e.row.id)},{default:p(()=>[i(c(r.$t(`order.button.continuePay`)),1)]),_:1},8,[`onClick`])):(l(),a(D,{key:1,size:`small`,onClick:t=>r.goToDetail(e.row.id)},{default:p(()=>[i(c(r.$t(`order.button.checkDetail`)),1)]),_:1},8,[`onClick`]))])]),_:1})]),_:1},8,[`data`,`empty-text`])),[[N,r.loading]])]),_:1})]),_:1})]),_:1}),o(b,null,{default:p(()=>[o(y,{span:10,offset:14},{default:p(()=>[n(`div`,ae,[o(M,{"current-page":r.page,"page-size":r.limit,total:r.total,onChange:r.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var se=D(N,[[`render`,oe],[`__scopeId`,`data-v-350ab467`]]);export{se as default};
@@ -1,4 +1,4 @@
1
- import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,k as u,tt as d,ut as f}from"./vendor-chart-BJCvKk8-.js";import{t as p}from"./button-BydTr5nV.js";import{H as ee}from"./use-deprecated-B-NFNg3W.js";import{t as te}from"./switch-qPS9uKOY.js";import{i as m}from"./surface-D249_eDG.js";import{A as h,Kr as g,O as _,Wr as v}from"./index-4nyvtI8-.js";import{t as y}from"./index.es-B6_5ZbW0.js";var b=r({name:`LocalToolsSetting`,components:{ElButton:p,ElTag:v,ElSwitch:te,ElInput:g,FontAwesomeIcon:y},data(){return{Plus:ee,roots:[],tools:[],mcpServers:[],mcpUid:0,mcpStatuses:[],mcpBusy:null,savingMcp:!1,mcpSavedTip:!1,mcpError:``,grants:null,perm:null,computerUse:!1,computerTools:[],computerGrants:{},cuBusy:null,builtinTools:[],toolGrants:{},builtinBusy:null,savingCU:!1,preauthorizing:!1,saving:!1,savedTip:!1,a11yEnabled:!1,onFocus:null,cuOff:null}},computed:{desktop(){return!!h()},android(){return m()}},async mounted(){let e=h();if(!e)return;let t=await e.getConfig();this.roots=t.roots,this.computerUse=t.computerUse===!0,this.mcpServers=(t.mcp??[]).map(e=>({_uid:this.mcpUid++,id:e.id,command:e.command,argsText:(e.args??[]).join(`
1
+ import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,k as u,tt as d,ut as f}from"./vendor-chart-BJCvKk8-.js";import{t as p}from"./button-BydTr5nV.js";import{H as ee}from"./use-deprecated-B-NFNg3W.js";import{t as te}from"./switch-C7bMRiui.js";import{i as m}from"./surface-D249_eDG.js";import{A as h,Kr as g,O as _,Wr as v}from"./index-DlJr9VYp.js";import{t as y}from"./index.es-BHvvolz-.js";var b=r({name:`LocalToolsSetting`,components:{ElButton:p,ElTag:v,ElSwitch:te,ElInput:g,FontAwesomeIcon:y},data(){return{Plus:ee,roots:[],tools:[],mcpServers:[],mcpUid:0,mcpStatuses:[],mcpBusy:null,savingMcp:!1,mcpSavedTip:!1,mcpError:``,grants:null,perm:null,computerUse:!1,computerTools:[],computerGrants:{},cuBusy:null,builtinTools:[],toolGrants:{},builtinBusy:null,savingCU:!1,preauthorizing:!1,saving:!1,savedTip:!1,a11yEnabled:!1,onFocus:null,cuOff:null}},computed:{desktop(){return!!h()},android(){return m()}},async mounted(){let e=h();if(!e)return;let t=await e.getConfig();this.roots=t.roots,this.computerUse=t.computerUse===!0,this.mcpServers=(t.mcp??[]).map(e=>({_uid:this.mcpUid++,id:e.id,command:e.command,argsText:(e.args??[]).join(`
2
2
  `),envText:Object.entries(e.env??{}).map(([e,t])=>`${e}=${t}`).join(`
3
3
  `),enabled:e.enabled!==!1})),this.mcpStatuses=await e.mcp?.status()??[],this.tools=(await e.listTools()).map(e=>e.name),this.computerTools=await e.computerTools?.()??[],this.builtinTools=await e.builtinTools?.()??[];let n=await e.perm?.status();n?.mac&&(this.perm=n),await this.loadGrants(),this.android&&(await this.refreshA11y(),this.onFocus=()=>{document.visibilityState===`visible`&&this.refreshA11y()},document.addEventListener(`visibilitychange`,this.onFocus)),this.cuOff=e.onComputerUseDisabled?.(()=>{this.computerUse=!1})??null},beforeUnmount(){this.cuOff?.(),this.onFocus&&document.removeEventListener(`visibilitychange`,this.onFocus)},methods:{async refreshA11y(){let e=await h()?.perm?.status();this.a11yEnabled=e?.accessibility===!0},async openAndroidAccessibility(){await h()?.perm?.openPane(`accessibility`)},async loadGrants(){let e=h();if(!e?.grants){this.grants=null;return}let t=await e.grants.list(),n={},r={},i=new Set(this.builtinTools.map(e=>e.name)),a=[];for(let e of t){if(e.startsWith(`computer.`)&&!e.includes(`:`)){n[e]=!0;continue}if(!e.includes(`:`)&&i.has(e)){r[e]=!0;continue}let t=e.indexOf(`:{`),o=t>=0?t:e.indexOf(`:`);a.push({key:e,name:o>=0?e.slice(0,o):e,input:o>=0?e.slice(o+1):``})}this.computerGrants=n,this.toolGrants=r,this.grants=a},async addFolder(){let e=await h()?.pickFolder();e&&!this.roots.includes(e)&&this.roots.push(e)},removeRoot(e){this.roots.splice(e,1)},addMcp(){this.mcpServers.push({_uid:this.mcpUid++,id:``,command:``,argsText:``,envText:``,enabled:!0})},removeMcp(e){this.mcpServers.splice(e,1)},mcpStatusFor(e){let t=e.trim();return this.mcpStatuses.find(e=>e.id===t)},mcpBadgeType(e){let t=this.mcpStatusFor(e)?.status;return t===`connected`?`success`:t===`failed`?`danger`:`info`},mcpBadgeText(e){let t=this.mcpStatusFor(e);return this.mcpBusy===e.trim()?this.$t(`common.settings.localToolsMcpConnecting`):t?t.status===`connected`?this.$t(`common.settings.localToolsMcpConnected`,{n:t.toolCount}):t.status===`disabled`?this.$t(`common.settings.localToolsMcpDisabled`):this.$t(`common.settings.localToolsMcpFailed`):this.$t(`common.settings.localToolsMcpNotSaved`)},mcpErrorFor(e){let t=this.mcpStatusFor(e);return t?.status===`failed`&&t.error?t.error:``},buildMcpPayload(){this.mcpError=``;let e=[],t=new Set;for(let n of this.mcpServers){let r=n.id.trim(),i=n.command.trim();if(!r||!i)return this.mcpError=this.$t(`common.settings.localToolsMcpNameRequired`),null;if(!/^[A-Za-z0-9_-]+$/.test(r))return this.mcpError=this.$t(`common.settings.localToolsMcpNameInvalid`),null;if(t.has(r))return this.mcpError=this.$t(`common.settings.localToolsMcpDuplicateName`),null;t.add(r);let a=n.argsText.split(`
4
4
  `).map(e=>e.trim()).filter(Boolean),o={};for(let e of n.envText.split(`
@@ -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-4nyvtI8-.js";import{t as c}from"./LocalTools-C-ArepDE.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-DlJr9VYp.js";import{t as c}from"./LocalTools-DjhJmJtS.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-BtBK9Tbx.js";import{t as m}from"./checkbox-BC1X4B2U.js";import{t as h}from"./divider-LA__Fty9.js";import"./constants-CkWWBPId.js";import{Hr as g,Ht as _,Lr as v,Mr as y,O as b,Pr as x,Wn as S,jr as C,zr as w}from"./index-4nyvtI8-.js";import{t as T}from"./Status-CpjuwqcV.js";var E=r({name:`ApplicationConfirm`,components:{ElDialog:g,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){w.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=b(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===x.Request},service(){return this.$store.state[this.appName]?.service},userId(){return this.$store.state.user?.id}},watch:{appName(){this.initialize()},userId(e,t){e&&e!==t&&this.initialize()}},mounted(){this.initialize(),window.addEventListener(`resize`,this.onResize),this.balanceTimer=window.setInterval(this.refreshBalances,P),document.addEventListener(`visibilitychange`,this.onVisibility)},beforeUnmount(){window.removeEventListener(`resize`,this.onResize),window.clearInterval(this.balanceTimer),document.removeEventListener(`visibilitychange`,this.onVisibility)},methods:{onResize(){this.mobile=window.innerWidth<768},onVisibility(){typeof document<`u`&&!document.hidden&&this.refreshBalances()},async refreshBalances(){if(!this.appName||!this.$store.state.token?.access||typeof document<`u`&&document.hidden||this.loading)return;await Promise.allSettled([this.$store.dispatch(`getApplications`),this.$store.dispatch(`${this.appName}/getApplications`)]);let e=this.$store.state[this.appName]?.application;if(!e)return;let t=this.applications?.find(t=>t.id===e.id);t&&t!==e&&this.$store.commit(`${this.appName}/setApplication`,t)},async initialize(){let e=++this.initializeRunId;if(this.initialized=!1,!this.$store.state.token?.access||(console.debug(`Fetching all individual and global applications for`,this.appName),await Promise.allSettled([this.$store.dispatch(`getApplications`),this.$store.dispatch(`${this.appName}/getApplications`)]),e!==this.initializeRunId))return;console.debug(`Fetched all applications`,this.applications),this.$store.state.applications?.length===0&&await this.onAutoApply();let t=this.$store.state[this.appName]?.application;console.debug(`current application`,t);let n=_(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:y.USAGE,scope:C.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`):w.error(this.$t(`application.message.applyFailed`))}},showWelcomeToast(){let e=this.$store.state.applications?.[0],t=Math.floor(e?.remaining_amount??0);w({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=b(F,[[`render`,L],[`__scopeId`,`data-v-f071b44e`]]);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-BHWYqhxz.js";import{t as m}from"./checkbox-BC1X4B2U.js";import{t as h}from"./divider-LA__Fty9.js";import"./constants-D5XSekB2.js";import{Hr as g,Ht as _,Lr as v,Mr as y,O as b,Pr as x,Wn as S,jr as C,zr as w}from"./index-DlJr9VYp.js";import{t as T}from"./Status-B4cXfVjU.js";var E=r({name:`ApplicationConfirm`,components:{ElDialog:g,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){w.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=b(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===x.Request},service(){return this.$store.state[this.appName]?.service},userId(){return this.$store.state.user?.id}},watch:{appName(){this.initialize()},userId(e,t){e&&e!==t&&this.initialize()}},mounted(){this.initialize(),window.addEventListener(`resize`,this.onResize),this.balanceTimer=window.setInterval(this.refreshBalances,P),document.addEventListener(`visibilitychange`,this.onVisibility)},beforeUnmount(){window.removeEventListener(`resize`,this.onResize),window.clearInterval(this.balanceTimer),document.removeEventListener(`visibilitychange`,this.onVisibility)},methods:{onResize(){this.mobile=window.innerWidth<768},onVisibility(){typeof document<`u`&&!document.hidden&&this.refreshBalances()},async refreshBalances(){if(!this.appName||!this.$store.state.token?.access||typeof document<`u`&&document.hidden||this.loading)return;await Promise.allSettled([this.$store.dispatch(`getApplications`),this.$store.dispatch(`${this.appName}/getApplications`)]);let e=this.$store.state[this.appName]?.application;if(!e)return;let t=this.applications?.find(t=>t.id===e.id);t&&t!==e&&this.$store.commit(`${this.appName}/setApplication`,t)},async initialize(){let e=++this.initializeRunId;if(this.initialized=!1,!this.$store.state.token?.access||(console.debug(`Fetching all individual and global applications for`,this.appName),await Promise.allSettled([this.$store.dispatch(`getApplications`),this.$store.dispatch(`${this.appName}/getApplications`)]),e!==this.initializeRunId))return;console.debug(`Fetched all applications`,this.applications),this.$store.state.applications?.length===0&&await this.onAutoApply();let t=this.$store.state[this.appName]?.application;console.debug(`current application`,t);let n=_(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:y.USAGE,scope:C.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`):w.error(this.$t(`application.message.applyFailed`))}},showWelcomeToast(){let e=this.$store.state.applications?.[0],t=Math.floor(e?.remaining_amount??0);w({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=b(F,[[`render`,L],[`__scopeId`,`data-v-f071b44e`]]);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 ee,Wt as c,Z as l,b as u,k as d,tt as f,ut as p}from"./vendor-chart-BJCvKk8-.js";import{t as m}from"./button-BydTr5nV.js";import{t as h}from"./upload-DyzIWJnO.js";import{t as g}from"./image-CLIo3ldG.js";import{t as _}from"./alert-C51owb6L.js";import{n as v,r as y}from"./radio-3Hz7h3DR.js";import{t as b}from"./switch-qPS9uKOY.js";import{t as x}from"./vendor-axios-Ck2ffRoh.js";import"./constants-CkWWBPId.js";import{Kr as S,Lr as C,O as w,Zt as T,an as E,tt as te,zr as D,zt as O}from"./index-4nyvtI8-.js";import{t as k}from"./index.es-B6_5ZbW0.js";import{t as A}from"./CopyToClipboard-BYFO-_G-.js";import{t as j}from"./BotPlaceholder-Dm168R0i.js";import{t as M}from"./Hailuo-BTAqMI5M.js";import{t as N}from"./TabSwitcher-BlOqZ7LR.js";var P=4,F=90,I=r({name:`FishRecorder`,components:{ElButton:m,FontAwesomeIcon:k},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%P+1}`;return this.$t(e)}},beforeUnmount(){this.cleanup()},mounted(){this.$emit(`update:script`,this.currentScript)},methods:{nextScript(){this.scriptIndex=(this.scriptIndex+1)%P,this.$emit(`update:script`,this.currentScript)},async startRecord(){if(!navigator.mediaDevices?.getUserMedia||typeof MediaRecorder>`u`){D.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`;D.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()},F*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){D.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 x.post(`${C()}/api/v1/files/`,r,{headers:{Authorization:`Bearer ${e}`}}),a=i?.file_url;if(!a){D.error(this.$t(`fish.message.uploadError`));return}this.$emit(`done`,{url:a,text:this.currentScript})}catch(e){D.error(this.$t(`fish.message.uploadError`)),console.error(`recorder upload failed`,e)}finally{this.uploading=!1}}}}}),L={class:`recorder`},R={key:0,class:`script`},z={class:`script-header`},B={class:`label`},V={class:`script-text`},H={class:`controls`},U={class:`status`},W={class:`hint`},G={key:1,class:`preview`},K=[`src`],q={class:`preview-actions`},J={class:`footer`};function Y(e,r,s,u,m,h){let g=f(`font-awesome-icon`),_=f(`el-button`);return l(),t(`div`,L,[e.state===`recorded`?d(``,!0):(l(),t(`div`,R,[n(`div`,z,[o(g,{icon:`fa-solid fa-book-open`,class:`icon mr-1`}),n(`span`,B,c(e.$t(`fish.description.readScript`)),1),o(_,{link:``,size:`small`,class:`ml-auto`,disabled:e.state===`recording`,onClick:e.nextScript},{default:p(()=>[o(g,{icon:`fa-solid fa-shuffle`,class:`mr-1`}),i(` `+c(e.$t(`fish.button.nextScript`)),1)]),_:1},8,[`disabled`,`onClick`])]),n(`p`,V,c(e.currentScript),1)])),n(`div`,H,[e.state===`idle`?(l(),a(_,{key:0,type:`danger`,circle:``,size:`large`,title:e.$t(`fish.button.startRecord`),onClick:e.startRecord},{default:p(()=>[o(g,{icon:`fa-solid fa-microphone`})]),_:1},8,[`title`,`onClick`])):e.state===`recording`?(l(),a(_,{key:1,type:`warning`,circle:``,size:`large`,title:e.$t(`fish.button.stopRecord`),onClick:e.stopRecord},{default:p(()=>[o(g,{icon:`fa-solid fa-stop`})]),_:1},8,[`title`,`onClick`])):d(``,!0),n(`div`,U,[n(`span`,{class:ee([`timer`,e.state===`recording`?`live`:``])},c(e.formattedTime),3),n(`span`,W,c(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?(l(),t(`div`,G,[n(`audio`,{src:e.recordedUrl,controls:``,preload:`metadata`,class:`w-full`},null,8,K),n(`div`,q,[o(_,{size:`small`,disabled:e.uploading,onClick:e.reset},{default:p(()=>[o(g,{icon:`fa-solid fa-rotate-left`,class:`mr-1`}),i(` `+c(e.$t(`fish.button.reRecord`)),1)]),_:1},8,[`disabled`,`onClick`]),o(_,{size:`small`,type:`primary`,loading:e.uploading,onClick:e.useRecording},{default:p(()=>[o(g,{icon:`fa-solid fa-check`,class:`mr-1`}),i(` `+c(e.$t(`fish.button.useRecording`)),1)]),_:1},8,[`loading`,`onClick`])])])):d(``,!0),n(`div`,J,[o(_,{link:``,size:`small`,disabled:e.uploading||e.state===`recording`,onClick:e.onCancel},{default:p(()=>[i(c(e.$t(`fish.button.cancel`)),1)]),_:1},8,[`disabled`,`onClick`])])])}var X=w(I,[[`render`,Y],[`__scopeId`,`data-v-1958e4a1`]]),Z=50*1024*1024,Q=()=>({title:``,description:``,texts:``,voicesUrl:``,visibility:`unlist`,trainMode:`fast`,enhanceAudio:!0,generateSample:!1}),ne=r({name:`FishModelConfigPanel`,components:{ElButton:m,ElInput:S,ElRadioButton:v,ElRadioGroup:y,ElSwitch:b,ElUpload:h,FontAwesomeIcon:k,Recorder:X},mixins:[O],emits:[`create`],data(){return{form:Q(),fileList:[],uploading:!1,creating:!1,recording:!1,textsAuto:!0}},computed:{uploadUrl(){return C()+`/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>Z?(D.warning(this.$t(`fish.message.audioSizeExceed`)),!1):(this.uploading=!0,!0)},onExceed(){D.warning(this.$t(`fish.message.audioOnlyOne`))},onUploadError(){this.uploading=!1,D.error(this.$t(`fish.message.uploadError`))},onUploadSuccess(e,t,n){this.uploading=!1;let r=e?.file_url;if(!r){D.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){D.warning(this.$t(`fish.message.titleRequired`));return}if(!this.form.voicesUrl){D.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=Q(),this.fileList=[]},600)}}}),re={class:`flex flex-col h-full`},ie={class:`flex-1 overflow-y-auto p-5`},ae={class:`field-block mb-4`},oe={class:`title font-bold`},se={class:`field-block mb-4`},ce={class:`flex items-baseline justify-between mb-1`},le={class:`title font-bold`},ue={key:0,class:`muted`},de={class:`hint`},fe={key:0,class:`audio-actions`},pe={key:1,class:`hint warn`},me={key:3,class:`mt-2`},he=[`src`],ge={class:`ready-actions`},_e={class:`field-block mb-4`},ve={class:`title font-bold`},ye={class:`hint`},be={class:`field-block mb-4`},xe={class:`title font-bold`},Se={class:`field-block mb-4`},Ce={class:`title font-bold`},we={class:`field-block mb-4`},Te={class:`title font-bold`},Ee={class:`field-block mb-3`},De={class:`field-row`},Oe={class:`title font-bold`},ke={class:`hint mt-0 mb-0`},Ae={class:`field-block mb-2`},je={class:`field-row`},Me={class:`title font-bold`},Ne={class:`hint mt-0 mb-0`},Pe={class:`flex flex-col items-center justify-center px-5 pb-5`};function Fe(e,r,s,ee,u,m){let h=f(`el-input`),g=f(`font-awesome-icon`),_=f(`el-button`),v=f(`el-upload`),y=f(`recorder`),b=f(`el-radio-button`),x=f(`el-radio-group`),S=f(`el-switch`);return l(),t(`div`,re,[n(`div`,ie,[n(`div`,ae,[n(`h2`,oe,[i(c(e.$t(`fish.name.voiceTitle`))+` `,1),r[9]||=n(`span`,{class:`required`},`*`,-1)]),o(h,{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`,se,[n(`div`,ce,[n(`h2`,le,[i(c(e.$t(`fish.name.referenceAudio`))+` `,1),r[10]||=n(`span`,{class:`required`},`*`,-1)]),!e.form.voicesUrl&&!e.recording?(l(),t(`span`,ue,c(e.$t(`fish.description.audioRequired`)),1)):d(``,!0)]),n(`p`,de,c(e.$t(`fish.description.uploadAudio`)),1),!e.form.voicesUrl&&!e.recording?(l(),t(`div`,fe,[o(v,{"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:p(()=>[o(_,{type:`primary`,plain:``,round:``,loading:e.uploading},{default:p(()=>[o(g,{icon:`fa-solid fa-upload`,class:`icon mr-1`}),i(` `+c(e.$t(`fish.button.uploadAudio`)),1)]),_:1},8,[`loading`])]),_:1},8,[`file-list`,`action`,`on-exceed`,`on-error`,`on-success`,`before-upload`,`headers`]),o(_,{type:`primary`,round:``,disabled:!e.supportsRecorder,onClick:e.onStartRecord},{default:p(()=>[o(g,{icon:`fa-solid fa-microphone`,class:`icon mr-1`}),i(` `+c(e.$t(`fish.button.recordAudio`)),1)]),_:1},8,[`disabled`,`onClick`])])):d(``,!0),!e.supportsRecorder&&!e.form.voicesUrl&&!e.recording?(l(),t(`p`,pe,c(e.$t(`fish.message.recorderUnsupported`)),1)):d(``,!0),e.recording?(l(),a(y,{key:2,class:`mt-2`,onDone:e.onRecorded,onCancel:r[2]||=t=>e.recording=!1,"onUpdate:script":e.onScriptChange},null,8,[`onDone`,`onUpdate:script`])):d(``,!0),e.form.voicesUrl&&!e.recording?(l(),t(`div`,me,[n(`audio`,{src:e.form.voicesUrl,controls:``,preload:`metadata`,class:`w-full`},null,8,he),n(`div`,ge,[o(_,{link:``,size:`small`,onClick:e.clearAudio},{default:p(()=>[o(g,{icon:`fa-solid fa-rotate-left`,class:`mr-1`}),i(` `+c(e.$t(`fish.button.replaceAudio`)),1)]),_:1},8,[`onClick`])])])):d(``,!0)]),n(`div`,_e,[n(`h2`,ve,c(e.$t(`fish.name.audioTexts`)),1),n(`p`,ye,c(e.$t(`fish.description.audioTexts`)),1),o(h,{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`,be,[n(`h2`,xe,c(e.$t(`fish.name.voiceDescription`)),1),o(h,{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`,Se,[n(`h2`,Ce,c(e.$t(`fish.name.visibility`)),1),o(x,{modelValue:e.form.visibility,"onUpdate:modelValue":r[5]||=t=>e.form.visibility=t,size:`small`},{default:p(()=>[o(b,{label:`private`,value:`private`},{default:p(()=>[i(c(e.$t(`fish.value.private`)),1)]),_:1}),o(b,{label:`unlist`,value:`unlist`},{default:p(()=>[i(c(e.$t(`fish.value.unlist`)),1)]),_:1}),o(b,{label:`public`,value:`public`},{default:p(()=>[i(c(e.$t(`fish.value.public`)),1)]),_:1})]),_:1},8,[`modelValue`])]),n(`div`,we,[n(`h2`,Te,c(e.$t(`fish.name.trainMode`)),1),o(x,{modelValue:e.form.trainMode,"onUpdate:modelValue":r[6]||=t=>e.form.trainMode=t,size:`small`},{default:p(()=>[o(b,{label:`fast`,value:`fast`},{default:p(()=>[i(c(e.$t(`fish.value.trainModeFast`)),1)]),_:1}),o(b,{label:`precise`,value:`precise`},{default:p(()=>[i(c(e.$t(`fish.value.trainModePrecise`)),1)]),_:1})]),_:1},8,[`modelValue`])]),n(`div`,Ee,[n(`div`,De,[n(`h2`,Oe,c(e.$t(`fish.name.enhanceAudio`)),1),o(S,{modelValue:e.form.enhanceAudio,"onUpdate:modelValue":r[7]||=t=>e.form.enhanceAudio=t},null,8,[`modelValue`])]),n(`p`,ke,c(e.$t(`fish.description.enhanceAudio`)),1)]),n(`div`,Ae,[n(`div`,je,[n(`h2`,Me,c(e.$t(`fish.name.generateSample`)),1),o(S,{modelValue:e.form.generateSample,"onUpdate:modelValue":r[8]||=t=>e.form.generateSample=t},null,8,[`modelValue`])]),n(`p`,Ne,c(e.$t(`fish.description.generateSample`)),1)])]),n(`div`,Pe,[o(_,{type:`primary`,class:`btn w-full`,round:``,disabled:!e.canCreate||e.creating,loading:e.creating,onClick:e.onCreate},{default:p(()=>[o(g,{icon:`fa-solid fa-magic`,class:`mr-2`}),i(` `+c(e.$t(`fish.button.createModel`)),1)]),_:1},8,[`disabled`,`loading`,`onClick`])])])}var Ie=w(ne,[[`render`,Fe],[`__scopeId`,`data-v-d8fc0e55`]]),Le=r({name:`FishVoiceCard`,components:{ElAlert:_,ElButton:m,ElImage:g,CopyToClipboard:A,FontAwesomeIcon:k},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:te}))}}}),Re={class:`card`},ze={class:`left`},Be={class:`main`},Ve={class:`header`},He={class:`title`},Ue={key:0,class:`datetime`},We={key:0,class:`description`},Ge={key:1,class:`sample mt-2`},Ke=[`src`],qe={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Je={key:1,class:`text-[var(--el-text-color-regular)] text-xs mb-0`},Ye={class:`operations mt-2`};function Xe(e,r,s,ee,m,h){let g=f(`el-image`),_=f(`font-awesome-icon`),v=f(`copy-to-clipboard`),y=f(`el-alert`),b=f(`el-button`);return l(),t(`div`,Re,[n(`div`,ze,[e.coverSrc?(l(),a(g,{key:0,src:e.coverSrc,class:`cover`,fit:`cover`},{error:p(()=>[o(g,{src:`https://cdn.acedata.cloud/e40fccc727.png`,class:`cover fallback`,fit:`cover`})]),placeholder:p(()=>[...r[0]||=[n(`div`,{class:`cover placeholder`},null,-1)]]),_:1},8,[`src`])):(l(),a(g,{key:1,src:`https://cdn.acedata.cloud/e40fccc727.png`,class:`cover fallback`,fit:`cover`}))]),n(`div`,Be,[n(`div`,Ve,[n(`span`,He,c(e.modelValue?.title||e.$t(`fish.name.untitledVoice`)),1),e.createdAtLabel?(l(),t(`span`,Ue,c(e.createdAtLabel),1)):d(``,!0)]),e.modelValue?.description?(l(),t(`p`,We,c(e.modelValue?.description),1)):d(``,!0),e.sampleAudioUrl?(l(),t(`div`,Ge,[n(`audio`,{src:e.sampleAudioUrl,controls:``,preload:`metadata`,class:`w-full`},null,8,Ke)])):d(``,!0),o(y,{closable:!1,class:`mt-2 success`},{default:p(()=>[e.voiceId?(l(),t(`p`,qe,[o(_,{icon:`fa-solid fa-microphone`,class:`mr-1`}),i(` `+c(e.$t(`fish.name.referenceId`))+`: `+c(e.voiceId)+` `,1),o(v,{content:e.voiceId},null,8,[`content`])])):d(``,!0),e.modelValue?.visibility?(l(),t(`p`,Je,[o(_,{icon:`fa-solid fa-eye`,class:`mr-1`}),i(` `+c(e.$t(`fish.name.visibility`))+`: `+c(e.modelValue?.visibility),1)])):d(``,!0)]),_:1}),n(`div`,Ye,[o(b,{type:`primary`,size:`small`,plain:``,disabled:!e.voiceId,onClick:u(e.onUseVoice,[`stop`])},{default:p(()=>[o(_,{icon:`fa-solid fa-volume-high`,class:`mr-1`}),i(` `+c(e.$t(`fish.button.useVoice`)),1)]),_:1},8,[`disabled`,`onClick`])])])])}var Ze=r({name:`FishModelListPanel`,components:{VoiceCard:w(Le,[[`render`,Xe],[`__scopeId`,`data-v-629e2d04`]]),BotPlaceholder:j,FontAwesomeIcon:k},props:{loading:{type:Boolean,default:!1}},computed:{voices(){return this.$store.state.fish?.voices}}}),Qe={class:`model-list-panel flex flex-col h-full`},$e={class:`header`},et={class:`title`},tt={key:0,class:`count`},$={class:`body flex-1 min-h-0`},nt={key:0,class:`h-full`},rt={key:1,class:`w-full h-full flex flex-col items-center justify-center text-center px-6`},it={class:`empty-title`},at={class:`empty-hint`},ot={key:2,class:`w-full h-full overflow-y-auto pr-1`};function st(r,i,ee,u,p,m){let h=f(`bot-placeholder`),g=f(`font-awesome-icon`),_=f(`voice-card`);return l(),t(`div`,Qe,[n(`header`,$e,[n(`h2`,et,c(r.$t(`fish.title.myVoices`)),1),r.voices?.length?(l(),t(`span`,tt,c(r.voices?.length),1)):d(``,!0)]),n(`div`,$,[r.voices===void 0?(l(),t(`div`,nt,[o(h)])):r.voices.length===0?(l(),t(`div`,rt,[o(g,{icon:`fa-solid fa-microphone-lines`,class:`empty-icon`}),n(`p`,it,c(r.$t(`fish.title.noVoicesYet`)),1),n(`p`,at,c(r.$t(`fish.description.noVoicesYet`)),1)])):(l(),t(`div`,ot,[(l(!0),t(s,null,e(r.voices,e=>(l(),a(_,{key:e.id,"model-value":e},null,8,[`model-value`]))),128))]))])])}var ct=r({name:`FishModelIndex`,components:{ModelConfigPanel:Ie,Layout:M,ModelListPanel:w(Ze,[[`render`,st],[`__scopeId`,`data-v-4aab2294`]]),TabSwitcher:N},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){if(!T())return;let t=this.credential?.token;if(!t){console.error(`no token specified`);return}this.loading=!0,D.info(this.$t(`fish.message.creatingModel`));try{await E.createModel(e,{token:t}),D.success(this.$t(`fish.message.createModelSuccess`)),await this.onGetVoices()}catch(e){let t=e?.response?.data;t?.error?.code===`used_up`?D.error(this.$t(`fish.message.usedUp`)):D.error(t?.error?.message||this.$t(`fish.message.createModelFailed`))}finally{this.loading=!1}}}}),lt={class:`flex flex-col h-full`},ut={class:`flex-1 min-h-0`};function dt(e,t,r,i,s,ee){let c=f(`tab-switcher`),u=f(`model-config-panel`),d=f(`model-list-panel`),m=f(`layout`);return l(),a(m,null,{config:p(()=>[n(`div`,lt,[o(c),n(`div`,ut,[o(u,{onCreate:e.onCreate},null,8,[`onCreate`])])])]),result:p(()=>[o(d,{loading:e.loading},null,8,[`loading`])]),_:1})}var ft=w(ct,[[`render`,dt]]);export{ft 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 ee,Wt as c,Z as l,b as u,k as d,tt as f,ut as p}from"./vendor-chart-BJCvKk8-.js";import{t as m}from"./button-BydTr5nV.js";import{t as h}from"./upload-CRcRB-U7.js";import{t as g}from"./image-DwKDUrzV.js";import{t as _}from"./alert-C51owb6L.js";import{n as v,r as y}from"./radio-3Hz7h3DR.js";import{t as b}from"./switch-C7bMRiui.js";import{t as x}from"./vendor-axios-Ck2ffRoh.js";import"./constants-D5XSekB2.js";import{Kr as S,Lr as C,O as w,Zt as T,an as E,tt as te,zr as D,zt as O}from"./index-DlJr9VYp.js";import{t as k}from"./index.es-BHvvolz-.js";import{t as A}from"./CopyToClipboard--2jgu_fL.js";import{t as j}from"./BotPlaceholder-CxKG8Hym.js";import{t as M}from"./Hailuo-C_c0dmdS.js";import{t as N}from"./TabSwitcher-BfceQJnt.js";var P=4,F=90,I=r({name:`FishRecorder`,components:{ElButton:m,FontAwesomeIcon:k},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%P+1}`;return this.$t(e)}},beforeUnmount(){this.cleanup()},mounted(){this.$emit(`update:script`,this.currentScript)},methods:{nextScript(){this.scriptIndex=(this.scriptIndex+1)%P,this.$emit(`update:script`,this.currentScript)},async startRecord(){if(!navigator.mediaDevices?.getUserMedia||typeof MediaRecorder>`u`){D.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`;D.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()},F*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){D.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 x.post(`${C()}/api/v1/files/`,r,{headers:{Authorization:`Bearer ${e}`}}),a=i?.file_url;if(!a){D.error(this.$t(`fish.message.uploadError`));return}this.$emit(`done`,{url:a,text:this.currentScript})}catch(e){D.error(this.$t(`fish.message.uploadError`)),console.error(`recorder upload failed`,e)}finally{this.uploading=!1}}}}}),L={class:`recorder`},R={key:0,class:`script`},z={class:`script-header`},B={class:`label`},V={class:`script-text`},H={class:`controls`},U={class:`status`},W={class:`hint`},G={key:1,class:`preview`},K=[`src`],q={class:`preview-actions`},J={class:`footer`};function Y(e,r,s,u,m,h){let g=f(`font-awesome-icon`),_=f(`el-button`);return l(),t(`div`,L,[e.state===`recorded`?d(``,!0):(l(),t(`div`,R,[n(`div`,z,[o(g,{icon:`fa-solid fa-book-open`,class:`icon mr-1`}),n(`span`,B,c(e.$t(`fish.description.readScript`)),1),o(_,{link:``,size:`small`,class:`ml-auto`,disabled:e.state===`recording`,onClick:e.nextScript},{default:p(()=>[o(g,{icon:`fa-solid fa-shuffle`,class:`mr-1`}),i(` `+c(e.$t(`fish.button.nextScript`)),1)]),_:1},8,[`disabled`,`onClick`])]),n(`p`,V,c(e.currentScript),1)])),n(`div`,H,[e.state===`idle`?(l(),a(_,{key:0,type:`danger`,circle:``,size:`large`,title:e.$t(`fish.button.startRecord`),onClick:e.startRecord},{default:p(()=>[o(g,{icon:`fa-solid fa-microphone`})]),_:1},8,[`title`,`onClick`])):e.state===`recording`?(l(),a(_,{key:1,type:`warning`,circle:``,size:`large`,title:e.$t(`fish.button.stopRecord`),onClick:e.stopRecord},{default:p(()=>[o(g,{icon:`fa-solid fa-stop`})]),_:1},8,[`title`,`onClick`])):d(``,!0),n(`div`,U,[n(`span`,{class:ee([`timer`,e.state===`recording`?`live`:``])},c(e.formattedTime),3),n(`span`,W,c(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?(l(),t(`div`,G,[n(`audio`,{src:e.recordedUrl,controls:``,preload:`metadata`,class:`w-full`},null,8,K),n(`div`,q,[o(_,{size:`small`,disabled:e.uploading,onClick:e.reset},{default:p(()=>[o(g,{icon:`fa-solid fa-rotate-left`,class:`mr-1`}),i(` `+c(e.$t(`fish.button.reRecord`)),1)]),_:1},8,[`disabled`,`onClick`]),o(_,{size:`small`,type:`primary`,loading:e.uploading,onClick:e.useRecording},{default:p(()=>[o(g,{icon:`fa-solid fa-check`,class:`mr-1`}),i(` `+c(e.$t(`fish.button.useRecording`)),1)]),_:1},8,[`loading`,`onClick`])])])):d(``,!0),n(`div`,J,[o(_,{link:``,size:`small`,disabled:e.uploading||e.state===`recording`,onClick:e.onCancel},{default:p(()=>[i(c(e.$t(`fish.button.cancel`)),1)]),_:1},8,[`disabled`,`onClick`])])])}var X=w(I,[[`render`,Y],[`__scopeId`,`data-v-1958e4a1`]]),Z=50*1024*1024,Q=()=>({title:``,description:``,texts:``,voicesUrl:``,visibility:`unlist`,trainMode:`fast`,enhanceAudio:!0,generateSample:!1}),ne=r({name:`FishModelConfigPanel`,components:{ElButton:m,ElInput:S,ElRadioButton:v,ElRadioGroup:y,ElSwitch:b,ElUpload:h,FontAwesomeIcon:k,Recorder:X},mixins:[O],emits:[`create`],data(){return{form:Q(),fileList:[],uploading:!1,creating:!1,recording:!1,textsAuto:!0}},computed:{uploadUrl(){return C()+`/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>Z?(D.warning(this.$t(`fish.message.audioSizeExceed`)),!1):(this.uploading=!0,!0)},onExceed(){D.warning(this.$t(`fish.message.audioOnlyOne`))},onUploadError(){this.uploading=!1,D.error(this.$t(`fish.message.uploadError`))},onUploadSuccess(e,t,n){this.uploading=!1;let r=e?.file_url;if(!r){D.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){D.warning(this.$t(`fish.message.titleRequired`));return}if(!this.form.voicesUrl){D.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=Q(),this.fileList=[]},600)}}}),re={class:`flex flex-col h-full`},ie={class:`flex-1 overflow-y-auto p-5`},ae={class:`field-block mb-4`},oe={class:`title font-bold`},se={class:`field-block mb-4`},ce={class:`flex items-baseline justify-between mb-1`},le={class:`title font-bold`},ue={key:0,class:`muted`},de={class:`hint`},fe={key:0,class:`audio-actions`},pe={key:1,class:`hint warn`},me={key:3,class:`mt-2`},he=[`src`],ge={class:`ready-actions`},_e={class:`field-block mb-4`},ve={class:`title font-bold`},ye={class:`hint`},be={class:`field-block mb-4`},xe={class:`title font-bold`},Se={class:`field-block mb-4`},Ce={class:`title font-bold`},we={class:`field-block mb-4`},Te={class:`title font-bold`},Ee={class:`field-block mb-3`},De={class:`field-row`},Oe={class:`title font-bold`},ke={class:`hint mt-0 mb-0`},Ae={class:`field-block mb-2`},je={class:`field-row`},Me={class:`title font-bold`},Ne={class:`hint mt-0 mb-0`},Pe={class:`flex flex-col items-center justify-center px-5 pb-5`};function Fe(e,r,s,ee,u,m){let h=f(`el-input`),g=f(`font-awesome-icon`),_=f(`el-button`),v=f(`el-upload`),y=f(`recorder`),b=f(`el-radio-button`),x=f(`el-radio-group`),S=f(`el-switch`);return l(),t(`div`,re,[n(`div`,ie,[n(`div`,ae,[n(`h2`,oe,[i(c(e.$t(`fish.name.voiceTitle`))+` `,1),r[9]||=n(`span`,{class:`required`},`*`,-1)]),o(h,{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`,se,[n(`div`,ce,[n(`h2`,le,[i(c(e.$t(`fish.name.referenceAudio`))+` `,1),r[10]||=n(`span`,{class:`required`},`*`,-1)]),!e.form.voicesUrl&&!e.recording?(l(),t(`span`,ue,c(e.$t(`fish.description.audioRequired`)),1)):d(``,!0)]),n(`p`,de,c(e.$t(`fish.description.uploadAudio`)),1),!e.form.voicesUrl&&!e.recording?(l(),t(`div`,fe,[o(v,{"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:p(()=>[o(_,{type:`primary`,plain:``,round:``,loading:e.uploading},{default:p(()=>[o(g,{icon:`fa-solid fa-upload`,class:`icon mr-1`}),i(` `+c(e.$t(`fish.button.uploadAudio`)),1)]),_:1},8,[`loading`])]),_:1},8,[`file-list`,`action`,`on-exceed`,`on-error`,`on-success`,`before-upload`,`headers`]),o(_,{type:`primary`,round:``,disabled:!e.supportsRecorder,onClick:e.onStartRecord},{default:p(()=>[o(g,{icon:`fa-solid fa-microphone`,class:`icon mr-1`}),i(` `+c(e.$t(`fish.button.recordAudio`)),1)]),_:1},8,[`disabled`,`onClick`])])):d(``,!0),!e.supportsRecorder&&!e.form.voicesUrl&&!e.recording?(l(),t(`p`,pe,c(e.$t(`fish.message.recorderUnsupported`)),1)):d(``,!0),e.recording?(l(),a(y,{key:2,class:`mt-2`,onDone:e.onRecorded,onCancel:r[2]||=t=>e.recording=!1,"onUpdate:script":e.onScriptChange},null,8,[`onDone`,`onUpdate:script`])):d(``,!0),e.form.voicesUrl&&!e.recording?(l(),t(`div`,me,[n(`audio`,{src:e.form.voicesUrl,controls:``,preload:`metadata`,class:`w-full`},null,8,he),n(`div`,ge,[o(_,{link:``,size:`small`,onClick:e.clearAudio},{default:p(()=>[o(g,{icon:`fa-solid fa-rotate-left`,class:`mr-1`}),i(` `+c(e.$t(`fish.button.replaceAudio`)),1)]),_:1},8,[`onClick`])])])):d(``,!0)]),n(`div`,_e,[n(`h2`,ve,c(e.$t(`fish.name.audioTexts`)),1),n(`p`,ye,c(e.$t(`fish.description.audioTexts`)),1),o(h,{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`,be,[n(`h2`,xe,c(e.$t(`fish.name.voiceDescription`)),1),o(h,{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`,Se,[n(`h2`,Ce,c(e.$t(`fish.name.visibility`)),1),o(x,{modelValue:e.form.visibility,"onUpdate:modelValue":r[5]||=t=>e.form.visibility=t,size:`small`},{default:p(()=>[o(b,{label:`private`,value:`private`},{default:p(()=>[i(c(e.$t(`fish.value.private`)),1)]),_:1}),o(b,{label:`unlist`,value:`unlist`},{default:p(()=>[i(c(e.$t(`fish.value.unlist`)),1)]),_:1}),o(b,{label:`public`,value:`public`},{default:p(()=>[i(c(e.$t(`fish.value.public`)),1)]),_:1})]),_:1},8,[`modelValue`])]),n(`div`,we,[n(`h2`,Te,c(e.$t(`fish.name.trainMode`)),1),o(x,{modelValue:e.form.trainMode,"onUpdate:modelValue":r[6]||=t=>e.form.trainMode=t,size:`small`},{default:p(()=>[o(b,{label:`fast`,value:`fast`},{default:p(()=>[i(c(e.$t(`fish.value.trainModeFast`)),1)]),_:1}),o(b,{label:`precise`,value:`precise`},{default:p(()=>[i(c(e.$t(`fish.value.trainModePrecise`)),1)]),_:1})]),_:1},8,[`modelValue`])]),n(`div`,Ee,[n(`div`,De,[n(`h2`,Oe,c(e.$t(`fish.name.enhanceAudio`)),1),o(S,{modelValue:e.form.enhanceAudio,"onUpdate:modelValue":r[7]||=t=>e.form.enhanceAudio=t},null,8,[`modelValue`])]),n(`p`,ke,c(e.$t(`fish.description.enhanceAudio`)),1)]),n(`div`,Ae,[n(`div`,je,[n(`h2`,Me,c(e.$t(`fish.name.generateSample`)),1),o(S,{modelValue:e.form.generateSample,"onUpdate:modelValue":r[8]||=t=>e.form.generateSample=t},null,8,[`modelValue`])]),n(`p`,Ne,c(e.$t(`fish.description.generateSample`)),1)])]),n(`div`,Pe,[o(_,{type:`primary`,class:`btn w-full`,round:``,disabled:!e.canCreate||e.creating,loading:e.creating,onClick:e.onCreate},{default:p(()=>[o(g,{icon:`fa-solid fa-magic`,class:`mr-2`}),i(` `+c(e.$t(`fish.button.createModel`)),1)]),_:1},8,[`disabled`,`loading`,`onClick`])])])}var Ie=w(ne,[[`render`,Fe],[`__scopeId`,`data-v-d8fc0e55`]]),Le=r({name:`FishVoiceCard`,components:{ElAlert:_,ElButton:m,ElImage:g,CopyToClipboard:A,FontAwesomeIcon:k},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:te}))}}}),Re={class:`card`},ze={class:`left`},Be={class:`main`},Ve={class:`header`},He={class:`title`},Ue={key:0,class:`datetime`},We={key:0,class:`description`},Ge={key:1,class:`sample mt-2`},Ke=[`src`],qe={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Je={key:1,class:`text-[var(--el-text-color-regular)] text-xs mb-0`},Ye={class:`operations mt-2`};function Xe(e,r,s,ee,m,h){let g=f(`el-image`),_=f(`font-awesome-icon`),v=f(`copy-to-clipboard`),y=f(`el-alert`),b=f(`el-button`);return l(),t(`div`,Re,[n(`div`,ze,[e.coverSrc?(l(),a(g,{key:0,src:e.coverSrc,class:`cover`,fit:`cover`},{error:p(()=>[o(g,{src:`https://cdn.acedata.cloud/e40fccc727.png`,class:`cover fallback`,fit:`cover`})]),placeholder:p(()=>[...r[0]||=[n(`div`,{class:`cover placeholder`},null,-1)]]),_:1},8,[`src`])):(l(),a(g,{key:1,src:`https://cdn.acedata.cloud/e40fccc727.png`,class:`cover fallback`,fit:`cover`}))]),n(`div`,Be,[n(`div`,Ve,[n(`span`,He,c(e.modelValue?.title||e.$t(`fish.name.untitledVoice`)),1),e.createdAtLabel?(l(),t(`span`,Ue,c(e.createdAtLabel),1)):d(``,!0)]),e.modelValue?.description?(l(),t(`p`,We,c(e.modelValue?.description),1)):d(``,!0),e.sampleAudioUrl?(l(),t(`div`,Ge,[n(`audio`,{src:e.sampleAudioUrl,controls:``,preload:`metadata`,class:`w-full`},null,8,Ke)])):d(``,!0),o(y,{closable:!1,class:`mt-2 success`},{default:p(()=>[e.voiceId?(l(),t(`p`,qe,[o(_,{icon:`fa-solid fa-microphone`,class:`mr-1`}),i(` `+c(e.$t(`fish.name.referenceId`))+`: `+c(e.voiceId)+` `,1),o(v,{content:e.voiceId},null,8,[`content`])])):d(``,!0),e.modelValue?.visibility?(l(),t(`p`,Je,[o(_,{icon:`fa-solid fa-eye`,class:`mr-1`}),i(` `+c(e.$t(`fish.name.visibility`))+`: `+c(e.modelValue?.visibility),1)])):d(``,!0)]),_:1}),n(`div`,Ye,[o(b,{type:`primary`,size:`small`,plain:``,disabled:!e.voiceId,onClick:u(e.onUseVoice,[`stop`])},{default:p(()=>[o(_,{icon:`fa-solid fa-volume-high`,class:`mr-1`}),i(` `+c(e.$t(`fish.button.useVoice`)),1)]),_:1},8,[`disabled`,`onClick`])])])])}var Ze=r({name:`FishModelListPanel`,components:{VoiceCard:w(Le,[[`render`,Xe],[`__scopeId`,`data-v-629e2d04`]]),BotPlaceholder:j,FontAwesomeIcon:k},props:{loading:{type:Boolean,default:!1}},computed:{voices(){return this.$store.state.fish?.voices}}}),Qe={class:`model-list-panel flex flex-col h-full`},$e={class:`header`},et={class:`title`},tt={key:0,class:`count`},$={class:`body flex-1 min-h-0`},nt={key:0,class:`h-full`},rt={key:1,class:`w-full h-full flex flex-col items-center justify-center text-center px-6`},it={class:`empty-title`},at={class:`empty-hint`},ot={key:2,class:`w-full h-full overflow-y-auto pr-1`};function st(r,i,ee,u,p,m){let h=f(`bot-placeholder`),g=f(`font-awesome-icon`),_=f(`voice-card`);return l(),t(`div`,Qe,[n(`header`,$e,[n(`h2`,et,c(r.$t(`fish.title.myVoices`)),1),r.voices?.length?(l(),t(`span`,tt,c(r.voices?.length),1)):d(``,!0)]),n(`div`,$,[r.voices===void 0?(l(),t(`div`,nt,[o(h)])):r.voices.length===0?(l(),t(`div`,rt,[o(g,{icon:`fa-solid fa-microphone-lines`,class:`empty-icon`}),n(`p`,it,c(r.$t(`fish.title.noVoicesYet`)),1),n(`p`,at,c(r.$t(`fish.description.noVoicesYet`)),1)])):(l(),t(`div`,ot,[(l(!0),t(s,null,e(r.voices,e=>(l(),a(_,{key:e.id,"model-value":e},null,8,[`model-value`]))),128))]))])])}var ct=r({name:`FishModelIndex`,components:{ModelConfigPanel:Ie,Layout:M,ModelListPanel:w(Ze,[[`render`,st],[`__scopeId`,`data-v-4aab2294`]]),TabSwitcher:N},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){if(!T())return;let t=this.credential?.token;if(!t){console.error(`no token specified`);return}this.loading=!0,D.info(this.$t(`fish.message.creatingModel`));try{await E.createModel(e,{token:t}),D.success(this.$t(`fish.message.createModelSuccess`)),await this.onGetVoices()}catch(e){let t=e?.response?.data;t?.error?.code===`used_up`?D.error(this.$t(`fish.message.usedUp`)):D.error(t?.error?.message||this.$t(`fish.message.createModelFailed`))}finally{this.loading=!1}}}}),lt={class:`flex flex-col h-full`},ut={class:`flex-1 min-h-0`};function dt(e,t,r,i,s,ee){let c=f(`tab-switcher`),u=f(`model-config-panel`),d=f(`model-list-panel`),m=f(`layout`);return l(),a(m,null,{config:p(()=>[n(`div`,lt,[o(c),n(`div`,ut,[o(u,{onCreate:e.onCreate},null,8,[`onCreate`])])])]),result:p(()=>[o(d,{loading:e.loading},null,8,[`loading`])]),_:1})}var ft=w(ct,[[`render`,dt]]);export{ft as default};