@acedatacloud/nexior 3.305.0 → 3.306.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 (135) hide show
  1. package/dist/assets/{ApiCodeButton-Dt8pNU6x.js → ApiCodeButton-DmpBd78g.js} +1 -1
  2. package/dist/assets/{AskUserQuestionCard-Bqw0UgzI.js → AskUserQuestionCard-CDsMNMiw.js} +1 -1
  3. package/dist/assets/{Auth-9uVHSnoZ.js → Auth-CwqL4Iw4.js} +1 -1
  4. package/dist/assets/{Bare-3BOqLg1l.js → Bare-Dq0jc4d1.js} +1 -1
  5. package/dist/assets/{BotPlaceholder-COOqE9-9.js → BotPlaceholder-CFCvvJUK.js} +1 -1
  6. package/dist/assets/{BottomFooter-QxhaMdwi.js → BottomFooter-Cof6D_4j.js} +1 -1
  7. package/dist/assets/{Callback-BbvMUtas.js → Callback-BcW39nAn.js} +1 -1
  8. package/dist/assets/{CodeSnippet-BlvgY6h4.js → CodeSnippet-BvwxgmCL.js} +1 -1
  9. package/dist/assets/{Console-aR2vaZ1v.js → Console-Dh5aJMAQ.js} +1 -1
  10. package/dist/assets/{Consumption-DFVEdkHT.js → Consumption-B0cpex_d.js} +1 -1
  11. package/dist/assets/{Conversation-BgZjhoIW.js → Conversation-DaIwty3q.js} +2 -2
  12. package/dist/assets/{Conversation-RnSchLfb.css → Conversation-DkEhRu2d.css} +1 -1
  13. package/dist/assets/{CopyToClipboard-BH7fpVgM.js → CopyToClipboard-DaBIpGcq.js} +1 -1
  14. package/dist/assets/{Detail-Chdau1eT.js → Detail-AAqatldJ.js} +2 -2
  15. package/dist/assets/{Extra-CHn0--1A.js → Extra-DSGHHKB4.js} +1 -1
  16. package/dist/assets/{FilePreview-BT6abrb0.js → FilePreview-Bw8OwuxF.js} +1 -1
  17. package/dist/assets/{Hailuo-D0TpAhjT.js → Hailuo-DIchMDcd.js} +1 -1
  18. package/dist/assets/{History-Culh0KAt.js → History-BmfbaiNr.js} +1 -1
  19. package/dist/assets/{ImagePreview-CUabAe1W.js → ImagePreview-Bp03gxTS.js} +1 -1
  20. package/dist/assets/{ImageWrapper-DWoMneh0.js → ImageWrapper-BaJdH_hI.js} +1 -1
  21. package/dist/assets/{Index-DZQ1z5Mb.js → Index-1UHhWlXp.js} +1 -1
  22. package/dist/assets/{Index-BXuTmpKe.js → Index-BDaOWhod.js} +1 -1
  23. package/dist/assets/{Index-RZ1SnsX2.js → Index-BLoUT_4T.js} +1 -1
  24. package/dist/assets/{Index-DJ8stGbR.js → Index-BO0EwN6k.js} +1 -1
  25. package/dist/assets/{Index-kDlbUZul.js → Index-BRfA9XlW.js} +1 -1
  26. package/dist/assets/{Index-CRP81Rf1.js → Index-BncLluPY.js} +1 -1
  27. package/dist/assets/{Index-CnDm5BHf.js → Index-BwSTjvKa.js} +1 -1
  28. package/dist/assets/{Index-U_WEUqVO.js → Index-C5aYSETY.js} +1 -1
  29. package/dist/assets/{Index-DrQ8toup.js → Index-C6CibWBE.js} +1 -1
  30. package/dist/assets/{Index-BluTbDhQ.js → Index-C9f0x_Ni.js} +1 -1
  31. package/dist/assets/{Index-bM6_qwuR.js → Index-Cl6M8_qx.js} +1 -1
  32. package/dist/assets/{Index-D35lE1hg.js → Index-Cp41YL6h.js} +1 -1
  33. package/dist/assets/{Index-LXDup59N.js → Index-CtMsLQAa.js} +1 -1
  34. package/dist/assets/{Index-DH3--PhA.js → Index-Cux9mdN_.js} +1 -1
  35. package/dist/assets/{Index-DOylWer9.js → Index-CxRAUV_D.js} +1 -1
  36. package/dist/assets/{Index-DIGWjE24.js → Index-DOCu1JWj.js} +1 -1
  37. package/dist/assets/{Index-B9gVedPS.js → Index-DRta1BJn.js} +1 -1
  38. package/dist/assets/{Index-6KkPb7km.js → Index-DdI-yzz5.js} +1 -1
  39. package/dist/assets/{Index-BkQihiHN.js → Index-DpHppg3-.js} +1 -1
  40. package/dist/assets/{Index-8tWBmlUv.js → Index-Dx-VGFvj.js} +1 -1
  41. package/dist/assets/{Index-B6OAXA9r.js → Index-F1mroBu9.js} +1 -1
  42. package/dist/assets/{Index-56iLv7IE.js → Index-YHPhowDJ.js} +1 -1
  43. package/dist/assets/{Index-DMxmqO9G.js → Index-ZRdXRNyX.js} +1 -1
  44. package/dist/assets/{Index-C3hd_ME-.js → Index-io6wxMXT.js} +1 -1
  45. package/dist/assets/{Index-FE7WONoF.js → Index-iwq4J-vy.js} +1 -1
  46. package/dist/assets/{Index-gyCarV4s.js → Index-m5ZDe5DM.js} +1 -1
  47. package/dist/assets/{Index-BGstngRu.js → Index-pebLpvTX.js} +1 -1
  48. package/dist/assets/{Index-BJwehCcT.js → Index-r7oMIDkw.js} +1 -1
  49. package/dist/assets/{Invitees-Dc_0Medi.js → Invitees-BQnqaICs.js} +1 -1
  50. package/dist/assets/{List-YiedLn4j.js → List-CPLbCoEy.js} +1 -1
  51. package/dist/assets/{List-BjBTxQvg.js → List-D8pfd-Ti.js} +1 -1
  52. package/dist/assets/{List-CBFgsh9q.js → List-HNevAId0.js} +1 -1
  53. package/dist/assets/{LocalTools-Dj7eO4RQ.js → LocalTools-BtAL4Z-m.js} +1 -1
  54. package/dist/assets/{LocalTools-DjhDkgm5.js → LocalTools-Co2UcXcC.js} +1 -1
  55. package/dist/assets/{Main-C7tLTXiR.js → Main-DFFReLuh.js} +1 -1
  56. package/dist/assets/{Model-BVUgJ6Ia.js → Model-BDp1EDjF.js} +1 -1
  57. package/dist/assets/{Navigator-DS288V9m.js → Navigator-BP0eFtEz.js} +1 -1
  58. package/dist/assets/{NoTasks-DZB4fe7R.js → NoTasks-ZMexP2rC.js} +1 -1
  59. package/dist/assets/{NotFound-D04B-E2L.js → NotFound-CD6MrGLx.js} +1 -1
  60. package/dist/assets/{Pagination-GVBd1ZiN.js → Pagination-zB_rZyae.js} +1 -1
  61. package/dist/assets/{Pay-DkgndqNz.js → Pay-DCWk8Hm9.js} +1 -1
  62. package/dist/assets/{Player-BCp34eW6.js → Player-CCj4vpzO.js} +1 -1
  63. package/dist/assets/{PromptTextarea-BgrCdcrq.js → PromptTextarea-DmCp6vDF.js} +1 -1
  64. package/dist/assets/{RealtimeCall-BFm1yqsm.js → RealtimeCall-DpRaLuob.js} +1 -1
  65. package/dist/assets/{ScheduledTasks-Ds0gqOPP.js → ScheduledTasks-Cp3MqY3c.js} +1 -1
  66. package/dist/assets/{Status-DwS3bnGN.js → Status-ZSvRAAJM.js} +1 -1
  67. package/dist/assets/{Subscribe-DeQqWhl4.js → Subscribe-BFHl_3T7.js} +1 -1
  68. package/dist/assets/{TabSwitcher-b1dTVdoe.js → TabSwitcher-DMdBkoDS.js} +1 -1
  69. package/dist/assets/{Tts-D4ylnltN.js → Tts-CXdpw8cp.js} +1 -1
  70. package/dist/assets/{VideoPlayer-BBzXW6S4.js → VideoPlayer-Cgvt92-Q.js} +1 -1
  71. package/dist/assets/{avatar-B7yeS-cP.js → avatar-74OO2o_E.js} +1 -1
  72. package/dist/assets/{basic-CCyX1xjZ.js → basic-BGZai6sI.js} +1 -1
  73. package/dist/assets/{chat-BxDi_jZY.js → chat-BEkU97z4.js} +1 -1
  74. package/dist/assets/{codingBridge-nVzp_t5M.js → codingBridge-B65oCtdl.js} +1 -1
  75. package/dist/assets/{codingBridgeNotify-jLzGZnSE.js → codingBridgeNotify-CKUuuHSV.js} +2 -2
  76. package/dist/assets/{collapse-BUr44XV1.js → collapse-BTBexGk-.js} +1 -1
  77. package/dist/assets/{createTaskActions-DJoOej0T.js → createTaskActions-CQvja3O4.js} +1 -1
  78. package/dist/assets/{date-picker-DFWF2WgW.js → date-picker-vxBUCvDp.js} +1 -1
  79. package/dist/assets/{digitalhuman-DbhM9sSX.js → digitalhuman-BJqqabde.js} +1 -1
  80. package/dist/assets/{dropdown-cJdVkovA.js → dropdown-DE03rbxq.js} +1 -1
  81. package/dist/assets/{esm-B6ssDvbS.js → esm-BjKeYu6x.js} +1 -1
  82. package/dist/assets/{esm-BptQfyqe.js → esm-BqvO3Eb_.js} +2 -2
  83. package/dist/assets/{esm-BlKrXZjB.js → esm-Chksb94H.js} +3 -3
  84. package/dist/assets/{esm-k_mi7Wtt.js → esm-DKeamfK-.js} +1 -1
  85. package/dist/assets/esm-DldjhYMA.js +1 -0
  86. package/dist/assets/{esm-DYlC4gJE.js → esm-Do5Xa37R.js} +2 -2
  87. package/dist/assets/{esm-6cpVdM6K.js → esm-DxnvJV6A.js} +1 -1
  88. package/dist/assets/{fish-OaW_0JCu.js → fish-Ds5RK1u3.js} +1 -1
  89. package/dist/assets/{flux-vXpWWkUl.js → flux-B9kplACa.js} +1 -1
  90. package/dist/assets/{grokvideo-BD-H3DdP.js → grokvideo-DnWe7h5S.js} +1 -1
  91. package/dist/assets/{hailuo-YgCVFaux.js → hailuo-Dn4ZEENV.js} +1 -1
  92. package/dist/assets/{headshots-BBuPlN2K.js → headshots-N3AZfFMs.js} +1 -1
  93. package/dist/assets/{image-C1rOF43l.js → image-D3kX4G-o.js} +1 -1
  94. package/dist/assets/{index-DclJnQCv.js → index-BvXr-3ek.js} +3 -3
  95. package/dist/assets/{index.browser.esm-C52Qe4zG.js → index.browser.esm-6Oc8oJ8g.js} +1 -1
  96. package/dist/assets/{index.es-Dam0OO1D.js → index.es-C7iPP9Jz.js} +1 -1
  97. package/dist/assets/{input-number-Bswm4QYv.js → input-number-ra3Tnd9C.js} +1 -1
  98. package/dist/assets/{kling-a8jowPGd.js → kling-D9PaMhkc.js} +1 -1
  99. package/dist/assets/{luma-DGTM8cSH.js → luma-DxRVZ-Cj.js} +1 -1
  100. package/dist/assets/{maestro-qTTxBIJ5.js → maestro-B-YjLUrs.js} +1 -1
  101. package/dist/assets/{midjourney-Bcug_Q8z.js → midjourney-BvqMQw0m.js} +1 -1
  102. package/dist/assets/{nanobanana-CyxxW29B.js → nanobanana-zaezsphd.js} +1 -1
  103. package/dist/assets/{openaiimage-DaFXl6m4.js → openaiimage-CT8_hHZ5.js} +1 -1
  104. package/dist/assets/{pagination-D0XVag9D.js → pagination-D9o0Ru3X.js} +1 -1
  105. package/dist/assets/{pika-yyGoxgOw.js → pika-BcMlXrIM.js} +1 -1
  106. package/dist/assets/{pixverse-BmYaQsKl.js → pixverse-DX9Yoolz.js} +1 -1
  107. package/dist/assets/{popover-xMZALxvw.js → popover-B5fUemnu.js} +1 -1
  108. package/dist/assets/{producer-pbeuE0wX.js → producer-BHq15G5O.js} +1 -1
  109. package/dist/assets/{qrart-Dfz2lwo-.js → qrart-CTI43DzH.js} +1 -1
  110. package/dist/assets/{realtime-Bh3UsnxT.js → realtime-F7uGfkB5.js} +1 -1
  111. package/dist/assets/{row-B1Fh_BWz.js → row-CSxasYIf.js} +1 -1
  112. package/dist/assets/{seedance-4rcegRX6.js → seedance-DRMk7CsV.js} +1 -1
  113. package/dist/assets/{seedream-DKEmP8ea.js → seedream-D49zSg8x.js} +1 -1
  114. package/dist/assets/{select-BNNyIngy.js → select-DOCxBFVa.js} +1 -1
  115. package/dist/assets/{serp-6CdD2j_r.js → serp-DIYE4wos.js} +1 -1
  116. package/dist/assets/{slider-BtfdLTJb.js → slider-BT6wKkEb.js} +1 -1
  117. package/dist/assets/{solana-wallets-D5Wa4gLw.js → solana-wallets-HHcJPiuS.js} +2 -2
  118. package/dist/assets/{solana-wallets-vue-LDmfiACL.js → solana-wallets-vue-BueflACz.js} +1 -1
  119. package/dist/assets/{sora-KFzVGJzc.js → sora-DmWxnGQp.js} +1 -1
  120. package/dist/assets/{suno-KqHQ7BQC.js → suno-5vW7NVs7.js} +1 -1
  121. package/dist/assets/{switch-DWXQZz-o.js → switch-CKGiLdIO.js} +1 -1
  122. package/dist/assets/{tabs-4x0FGxKt.js → tabs-cPzdgcs6.js} +1 -1
  123. package/dist/assets/{time-picker-CNAm5JBc.js → time-picker-OnMWyY11.js} +1 -1
  124. package/dist/assets/{upload-D0e0nt-T.js → upload-Cq_7IVD4.js} +1 -1
  125. package/dist/assets/{veo-DvDy0_7R.js → veo-DcJq9lna.js} +1 -1
  126. package/dist/assets/{wan-ByN6HEI2.js → wan-C8h3PQxw.js} +1 -1
  127. package/dist/assets/{web-C9ruDcRK.js → web-B41KyeGX.js} +1 -1
  128. package/dist/assets/{web-D6SNxMVv.js → web-CtmlIzyj.js} +1 -1
  129. package/dist/assets/{web-ArQHixjj.js → web-D5Lc6MKs.js} +1 -1
  130. package/dist/assets/{web-BOc84B9P.js → web-DMZLegUo.js} +1 -1
  131. package/dist/assets/{web-DOZ1-GWL.js → web-e5FgVT2H.js} +1 -1
  132. package/dist/assets/{webextrator-4qobCNYw.js → webextrator-DT8qNtSw.js} +1 -1
  133. package/dist/index.html +1 -1
  134. package/package.json +1 -1
  135. package/dist/assets/esm-DA6AByd4.js +0 -1
@@ -1 +1 @@
1
- import"./rolldown-runtime--c01j_DQ.js";import{D as e,F as t,O as n,P as r,Wt as i,Z as a,dt as o,nt as s,tt as c,ut as l}from"./vendor-chart-BJCvKk8-.js";import{n as u,t as d}from"./table-BJr3w4hQ.js";import{t as f}from"./card-DjyfNde2.js";import{n as p,t as m}from"./row-B1Fh_BWz.js";import{t as h}from"./Pagination-GVBd1ZiN.js";import{O as g,Un as _}from"./index-DclJnQCv.js";import{t as v}from"./CopyToClipboard-BH7fpVgM.js";var y=t({name:`ConsoleDistributionInvitees`,components:{Pagination:h,CopyToClipboard:v,ElRow:m,ElCol:p,ElTable:d,ElTableColumn:u,ElCard:f},data(){return{invitees:[],loading:!1,total:void 0,limit:10}},computed:{redirect(){return this.$route.query.redirect},page(){return parseInt(this.$route.query.page?.toString()||`1`)}},watch:{page:{handler(){this.onFetchData()}}},mounted(){this.onFetchData()},methods:{onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{page:e}})},onFetchData(){this.loading=!0,Promise.all([this.onFetchInvitees()]).finally(()=>{this.loading=!1})},async onFetchInvitees(){let{data:e}=await _.getInvitees({limit:this.limit,offset:(this.page-1)*this.limit,ordering:`-created_at`});this.invitees=e.items,this.total=e.count}}}),b={class:`title`},x={class:`key`},S={class:`copy`},C={class:`description`},w={class:`description`},T={class:`description`},E={class:`created-at`},D={class:`pagination m-v-lg`};function O(t,u,d,f,p,m){let h=c(`el-col`),g=c(`el-row`),_=c(`copy-to-clipboard`),v=c(`el-table-column`),y=c(`el-table`),O=c(`el-card`),k=c(`pagination`),A=s(`loading`);return a(),n(g,{class:`panel`},{default:l(()=>[r(h,{span:24},{default:l(()=>[r(g,null,{default:l(()=>[r(h,{span:24},{default:l(()=>[e(`h2`,b,i(t.$t(`common.title.invitee`)),1)]),_:1})]),_:1}),r(g,null,{default:l(()=>[r(h,{span:24},{default:l(()=>[r(O,{shadow:`hover`},{default:l(()=>[o((a(),n(y,{data:t.invitees,stripe:``},{default:l(()=>[r(v,{prop:`id`,label:t.$t(`user.field.id`),"class-name":`text-center`,width:`350px`},{default:l(t=>[e(`span`,x,i(t.row.id),1),e(`span`,S,[r(_,{content:t.row.id},null,8,[`content`])])]),_:1},8,[`label`]),r(v,{label:t.$t(`user.field.username`),width:`300px`},{default:l(t=>[e(`span`,C,i(t.row?.username),1)]),_:1},8,[`label`]),r(v,{label:t.$t(`user.field.email`),width:`300px`},{default:l(t=>[e(`span`,w,i(t.row?.email),1)]),_:1},8,[`label`]),r(v,{label:t.$t(`user.field.nickname`),width:`200px`},{default:l(t=>[e(`span`,T,i(t.row.nickname),1)]),_:1},8,[`label`]),r(v,{label:t.$t(`user.field.dateJoined`)},{default:l(n=>[e(`span`,E,i(t.$dayjs.format(n.row.date_joined)),1)]),_:1},8,[`label`])]),_:1},8,[`data`])),[[A,t.loading]])]),_:1})]),_:1})]),_:1}),r(g,null,{default:l(()=>[r(h,{span:10,offset:14},{default:l(()=>[e(`div`,D,[r(k,{"current-page":t.page,"page-size":t.limit,total:t.total,onChange:t.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var k=g(y,[[`render`,O],[`__scopeId`,`data-v-4556864d`]]);export{k as default};
1
+ import"./rolldown-runtime--c01j_DQ.js";import{D as e,F as t,O as n,P as r,Wt as i,Z as a,dt as o,nt as s,tt as c,ut as l}from"./vendor-chart-BJCvKk8-.js";import{n as u,t as d}from"./table-BJr3w4hQ.js";import{t as f}from"./card-DjyfNde2.js";import{n as p,t as m}from"./row-CSxasYIf.js";import{t as h}from"./Pagination-zB_rZyae.js";import{O as g,Un as _}from"./index-BvXr-3ek.js";import{t as v}from"./CopyToClipboard-DaBIpGcq.js";var y=t({name:`ConsoleDistributionInvitees`,components:{Pagination:h,CopyToClipboard:v,ElRow:m,ElCol:p,ElTable:d,ElTableColumn:u,ElCard:f},data(){return{invitees:[],loading:!1,total:void 0,limit:10}},computed:{redirect(){return this.$route.query.redirect},page(){return parseInt(this.$route.query.page?.toString()||`1`)}},watch:{page:{handler(){this.onFetchData()}}},mounted(){this.onFetchData()},methods:{onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{page:e}})},onFetchData(){this.loading=!0,Promise.all([this.onFetchInvitees()]).finally(()=>{this.loading=!1})},async onFetchInvitees(){let{data:e}=await _.getInvitees({limit:this.limit,offset:(this.page-1)*this.limit,ordering:`-created_at`});this.invitees=e.items,this.total=e.count}}}),b={class:`title`},x={class:`key`},S={class:`copy`},C={class:`description`},w={class:`description`},T={class:`description`},E={class:`created-at`},D={class:`pagination m-v-lg`};function O(t,u,d,f,p,m){let h=c(`el-col`),g=c(`el-row`),_=c(`copy-to-clipboard`),v=c(`el-table-column`),y=c(`el-table`),O=c(`el-card`),k=c(`pagination`),A=s(`loading`);return a(),n(g,{class:`panel`},{default:l(()=>[r(h,{span:24},{default:l(()=>[r(g,null,{default:l(()=>[r(h,{span:24},{default:l(()=>[e(`h2`,b,i(t.$t(`common.title.invitee`)),1)]),_:1})]),_:1}),r(g,null,{default:l(()=>[r(h,{span:24},{default:l(()=>[r(O,{shadow:`hover`},{default:l(()=>[o((a(),n(y,{data:t.invitees,stripe:``},{default:l(()=>[r(v,{prop:`id`,label:t.$t(`user.field.id`),"class-name":`text-center`,width:`350px`},{default:l(t=>[e(`span`,x,i(t.row.id),1),e(`span`,S,[r(_,{content:t.row.id},null,8,[`content`])])]),_:1},8,[`label`]),r(v,{label:t.$t(`user.field.username`),width:`300px`},{default:l(t=>[e(`span`,C,i(t.row?.username),1)]),_:1},8,[`label`]),r(v,{label:t.$t(`user.field.email`),width:`300px`},{default:l(t=>[e(`span`,w,i(t.row?.email),1)]),_:1},8,[`label`]),r(v,{label:t.$t(`user.field.nickname`),width:`200px`},{default:l(t=>[e(`span`,T,i(t.row.nickname),1)]),_:1},8,[`label`]),r(v,{label:t.$t(`user.field.dateJoined`)},{default:l(n=>[e(`span`,E,i(t.$dayjs.format(n.row.date_joined)),1)]),_:1},8,[`label`])]),_:1},8,[`data`])),[[A,t.loading]])]),_:1})]),_:1})]),_:1}),r(g,null,{default:l(()=>[r(h,{span:10,offset:14},{default:l(()=>[e(`div`,D,[r(k,{"current-page":t.page,"page-size":t.limit,total:t.total,onChange:t.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var k=g(y,[[`render`,O],[`__scopeId`,`data-v-4556864d`]]);export{k as default};
@@ -1 +1 @@
1
- import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,a as u,c as d,dt as f,i as ee,k as p,n as m,nt as h,o as g,r as _,s as v,t as y,tt as b,ut as x,v as S}from"./vendor-chart-BJCvKk8-.js";import{t as C}from"./button-BydTr5nV.js";import{r as w,t as T}from"./select-BNNyIngy.js";import{n as E,t as D}from"./table-BJr3w4hQ.js";import{n as O,t as k}from"./tabs-4x0FGxKt.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-DFWF2WgW.js";import{n as P,t as F}from"./row-B1Fh_BWz.js";import{t as I}from"./Pagination-GVBd1ZiN.js";import{n as L,t as R}from"./skeleton-BwNBivMN.js";import{$r as z,Bn as B,Mr as V,O as H,Rn as U,Tr as W,Wn as G,Zr as K,wr as q,zn as J}from"./index-DclJnQCv.js";import{t as Y}from"./index.es-Dam0OO1D.js";import{t as X}from"./CopyToClipboard-BH7fpVgM.js";ee.register(_,u,m,v,d,g);var Z=r({name:`ConsoleUsageList`,components:{Pagination:I,ElTag:z,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:K,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,B.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-DOCxBFVa.js";import{n as E,t as D}from"./table-BJr3w4hQ.js";import{n as O,t as k}from"./tabs-cPzdgcs6.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-vxBUCvDp.js";import{n as P,t as F}from"./row-CSxasYIf.js";import{t as I}from"./Pagination-zB_rZyae.js";import{n as L,t as R}from"./skeleton-BwNBivMN.js";import{$r as z,Bn as B,Mr as V,O as H,Rn as U,Tr as W,Wn as G,Zr as K,wr as q,zn as J}from"./index-BvXr-3ek.js";import{t as Y}from"./index.es-C7iPP9Jz.js";import{t as X}from"./CopyToClipboard-DaBIpGcq.js";ee.register(_,u,m,v,d,g);var Z=r({name:`ConsoleUsageList`,components:{Pagination:I,ElTag:z,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:K,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,B.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,k as d,nt as f,tt as p,ut as m}from"./vendor-chart-BJCvKk8-.js";import{t as h}from"./button-BydTr5nV.js";import{n as g,t as ee}from"./table-BJr3w4hQ.js";import{t as _}from"./card-DjyfNde2.js";import{n as v,t as y}from"./row-B1Fh_BWz.js";import{t as b}from"./empty-CdsD8g84.js";import{t as x}from"./Pagination-GVBd1ZiN.js";import{t as S}from"./skeleton-BwNBivMN.js";import{t as C}from"./switch-DWXQZz-o.js";import{$r as w,B as T,Jr as E,K as D,Mr as O,O as k,Tr as A,Vr as j,Wn as M,jr as N,wr as P}from"./index-DclJnQCv.js";import{t as F}from"./index.es-Dam0OO1D.js";import{t as I}from"./CopyToClipboard-BH7fpVgM.js";var L=r({name:`ConsoleApplicationList`,components:{Pagination:x,CopyToClipboard:I,ElTable:ee,ElRow:y,ElButton:h,ElCol:v,ElTag:w,ElSkeleton:S,ElSwitch:C,ElEmpty:b,ElTableColumn:g,ElCard:_,FontAwesomeIcon:F},data(){return{credentialType:P,serviceType:A,individualApplications:[],globalApplications:[],individualApplicationsTotal:void 0,globalApplicationsTotal:void 0,loading:!1,buying:!1,limit:10,form:{amount:1},active:{service:void 0,application:void 0}}},computed:{redirect(){return this.$route.query?.redirect},page(){return parseInt(this.$route.query.page?.toString()||`1`)},showGlobalPayment(){return!0}},watch:{page:{handler(){this.onFetchData()}}},mounted(){this.onInitializeGlobalApplication(),this.onFetchData()},methods:{rowCanPay(e){return j()?(e?.packages||[]).some(e=>e?.metadata?.apple_product_id):!0},updateAllowConsumeGlobal(e,t){!e||!e.id||M.updateAllConsumeGlobal(e.id,{...e,allow_consume_global:!!t}).then(()=>{E.success(this.$t(`application.message.updateSuccessfully`).toString())}).catch(()=>{E.error(this.$t(`application.message.updateFailed`).toString())})},onGoUsage(e){this.$router.push({name:D,query:{application_id:e.id,type:e?.service?.type}})},onBuyMore(e){e?.id&&this.$router.push({name:T,params:{id:e.id}})},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,page:e}})},onFetchApplications(e=N.INDIVIDUAL){return new Promise((t,n)=>{M.getAll({limit:this.limit,...e===N.INDIVIDUAL?{offset:(this.page-1)*this.limit}:{},user_id:this.$store.getters.user.id,ordering:`-created_at`,type:O.USAGE,scope:e}).then(({data:n})=>{e===N.INDIVIDUAL?(this.individualApplications=n.items,this.individualApplicationsTotal=n.count):(this.globalApplications=n.items,this.globalApplicationsTotal=n.count),t(n)}).catch(e=>{E.error(this.$t(`application.message.fetchFailed`).toString()),n(e)})})},onFetchData(){this.loading=!0,Promise.all([this.onFetchApplications(N.INDIVIDUAL),this.onFetchApplications(N.GLOBAL)]).then(()=>{this.loading=!1}).catch(()=>{this.loading=!1})},onInitializeGlobalApplication(){M.create({type:O.USAGE,scope:N.GLOBAL,user_id:this.$store.getters.user.id}).finally(()=>{this.onFetchApplications(N.GLOBAL)})},getRemainingAmount(e){if(e.remaining_amount===void 0||e.remaining_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.remaining_amount?.toFixed(6)} ${t}`},getUsedAmount(e){if(e.used_amount===void 0||e.used_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.used_amount?.toFixed(6)} ${t}`}}}),R={class:`title`},z={key:1,class:`summary-card`},B={class:`icon-wrapper`},V={class:`label`},H={class:`value`},U={class:`description`},W={key:1,class:`flex flex-row justify-between items-center gap-3`},G={class:`summary-card min-w-0 flex-1`},K={class:`flex justify-start items-center gap-2 mb-2 w-full`},q={class:`icon-wrapper !mb-0`},J={class:`text-[var(--el-text-color-regular)] text-[14px] truncate`},te={class:`label`},Y={class:`value`},X={class:`description`},Z={class:`flex flex-col items-end gap-2 shrink-0`},Q={class:`copy`},ne={key:0,class:`expired-at`},re={class:`flex flex-wrap items-center justify-end gap-1`},ie={class:`application-cards block sm:hidden`},ae={class:`flex items-center gap-2 flex-wrap`},oe={class:`application-card__name`},se={class:`application-card__id`},ce={class:`truncate`},le={class:`application-card__row`},ue={class:`label`},de={class:`value`},fe={key:0,class:`application-card__row`},pe={class:`label`},$={class:`value`},me={key:1,class:`application-card__row`},he={class:`label`},ge={class:`flex items-center justify-end gap-2 mt-3`},_e={class:`pagination`};function ve(r,h,g,ee,_,v){let y=p(`el-col`),b=p(`el-row`),x=p(`el-skeleton`),S=p(`font-awesome-icon`),C=p(`el-card`),w=p(`copy-to-clipboard`),T=p(`el-button`),E=p(`el-table-column`),D=p(`el-tag`),O=p(`el-switch`),k=p(`el-table`),A=p(`el-empty`),j=p(`pagination`),M=f(`loading`);return l(),a(b,{class:`application-list`},{default:m(()=>[o(y,{span:24},{default:m(()=>[o(b,null,{default:m(()=>[o(y,{span:24},{default:m(()=>[n(`h2`,R,c(r.$t(`common.title.allApplications`)),1)]),_:1})]),_:1}),o(b,{gutter:15,class:`mb-3`},{default:m(()=>[o(y,{md:12,xs:24},{default:m(()=>[o(C,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:m(()=>[r.loading?(l(),a(x,{key:0})):(l(),t(`div`,z,[n(`div`,B,[o(S,{icon:`fa-solid fa-cubes-stacked`})]),n(`p`,V,c(r.$t(`application.title.count`)),1),n(`p`,H,c(r.individualApplicationsTotal),1),n(`p`,U,c(r.$t(`application.message.countDescription`)),1)]))]),_:1})]),_:1}),r.showGlobalPayment&&r.globalApplications?.length>0?(l(),a(y,{key:0,md:12,xs:24},{default:m(()=>[o(C,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:m(()=>[r.loading?(l(),a(x,{key:0})):(l(),t(`div`,W,[n(`div`,G,[n(`div`,K,[n(`div`,q,[o(S,{icon:`fa-solid fa-wallet`})]),n(`span`,J,[i(c(r.$t(`application.field.id`))+`: `+c(r.globalApplications?.[0]?.id)+` `,1),r.globalApplications?.[0]?.id?(l(),a(w,{key:0,content:r.globalApplications?.[0]?.id,class:`inline-block`},null,8,[`content`])):d(``,!0)])]),n(`p`,te,c(r.$t(`application.title.globalBalance`)),1),n(`p`,Y,c(r.globalApplications?.[0]?.remaining_amount?.toFixed(6)||`0.000000`)+` `+c(r.$t(`service.unit.credits`)),1),n(`p`,X,c(r.$t(`application.message.globalBalanceDescription`)),1)]),n(`div`,Z,[o(T,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:h[0]||=e=>r.onGoUsage(r.globalApplications?.[0])},{default:m(()=>[o(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.usage`)),1)]),_:1}),r.showGlobalPayment?(l(),a(T,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:h[1]||=e=>r.onBuyMore(r.globalApplications?.[0])},{default:m(()=>[o(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.buyMore`)),1)]),_:1})):d(``,!0)])]))]),_:1})]),_:1})):d(``,!0)]),_:1}),o(b,null,{default:m(()=>[o(y,{span:24},{default:m(()=>[o(C,{shadow:`hover`,class:`applications-table-card hidden sm:block`},{default:m(()=>[u((l(),a(k,{data:r.individualApplications,stripe:``,class:`applications-table !min-h-[calc(100vh-420px)]`,"table-layout":`fixed`,"empty-text":r.$t(`common.message.noData`)},{default:m(()=>[o(E,{prop:`id`,label:r.$t(`application.field.id`),width:`200px`,"class-name":`text-center`},{default:m(e=>[n(`span`,null,c(e.row.id),1),n(`span`,Q,[o(w,{content:e?.row?.id,class:`inline-block`},null,8,[`content`])])]),_:1},8,[`label`]),o(E,{label:r.$t(`application.field.type`),width:`90px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[e.row?.type===`Period`?(l(),a(D,{key:0,type:`success`,effect:`dark`,round:``},{default:m(()=>[i(c(r.$t(`application.type.period`)),1)]),_:1})):e.row?.type===`Usage`?(l(),a(D,{key:1,effect:`dark`,round:``},{default:m(()=>[i(c(r.$t(`application.type.usage`)),1)]),_:1})):d(``,!0)]),_:1},8,[`label`]),o(E,{label:r.$t(`application.field.name`),width:`180px`},{default:m(e=>[n(`span`,null,c(e.row?.service?.title),1),e.row?.role===`grantee`?(l(),a(D,{key:0,type:`info`,size:`small`,round:``,class:`ml-2`},{default:m(()=>[i(c(r.$t(`application.badge.shared`)),1)]),_:1})):d(``,!0)]),_:1},8,[`label`]),o(E,{prop:`remaining_amount`,label:r.$t(`application.field.remainingAmount`),width:`150px`,"class-name":`text-center`},{default:m(e=>[n(`span`,null,c(r.getRemainingAmount(e.row)),1)]),_:1},8,[`label`]),o(E,{prop:`used_amount`,label:r.$t(`application.field.usedAmount`),width:`150px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[n(`span`,null,c(r.getUsedAmount(e.row)),1)]),_:1},8,[`label`]),o(E,{prop:`allow_consume_global`,label:r.$t(`application.field.allowConsumeGlobal`),width:`120px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[e.row.service?.type===r.serviceType.API?(l(),a(O,{key:0,modelValue:e.row.allow_consume_global,"onUpdate:modelValue":t=>e.row.allow_consume_global=t,"active-value":!0,"inactive-value":!1,onChange:t=>r.updateAllowConsumeGlobal(e.row,t)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])):d(``,!0)]),_:1},8,[`label`]),o(E,{label:r.$t(`application.field.expiredAt`),width:`180px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[e.row.expired_at?(l(),t(`span`,ne,c(r.$dayjs.format(e.row.expired_at)),1)):d(``,!0)]),_:1},8,[`label`]),o(E,{fixed:`right`,width:`200px`},{default:m(e=>[n(`div`,re,[o(T,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:t=>r.onGoUsage(e?.row)},{default:m(()=>[o(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),r.rowCanPay(e?.row)?(l(),a(T,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:t=>r.onBuyMore(e?.row)},{default:m(()=>[o(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):d(``,!0)])]),_:1})]),_:1},8,[`data`,`empty-text`])),[[M,r.loading]])]),_:1}),n(`div`,ie,[r.loading?(l(),a(x,{key:0,rows:4,animated:``})):(l(),t(s,{key:1},[r.individualApplications?.length?(l(!0),t(s,{key:1},e(r.individualApplications,e=>(l(),a(C,{key:e.id,shadow:`hover`,class:`application-card mb-2`,"body-style":{padding:`14px 16px`}},{default:m(()=>[n(`div`,ae,[n(`span`,oe,c(e?.service?.title),1),e?.type===`Period`?(l(),a(D,{key:0,type:`success`,effect:`dark`,size:`small`,round:``},{default:m(()=>[i(c(r.$t(`application.type.period`)),1)]),_:1})):e?.type===`Usage`?(l(),a(D,{key:1,effect:`dark`,size:`small`,round:``},{default:m(()=>[i(c(r.$t(`application.type.usage`)),1)]),_:1})):d(``,!0),e?.role===`grantee`?(l(),a(D,{key:2,type:`info`,size:`small`,round:``},{default:m(()=>[i(c(r.$t(`application.badge.shared`)),1)]),_:1})):d(``,!0)]),n(`div`,se,[n(`span`,ce,c(r.$t(`application.field.id`))+`: `+c(e.id),1),o(w,{content:e.id,class:`inline-block shrink-0`},null,8,[`content`])]),n(`div`,le,[n(`span`,ue,c(r.$t(`application.field.remainingAmount`)),1),n(`span`,de,c(r.getRemainingAmount(e)),1)]),e?.expired_at?(l(),t(`div`,fe,[n(`span`,pe,c(r.$t(`application.field.expiredAt`)),1),n(`span`,$,c(r.$dayjs.format(e.expired_at)),1)])):d(``,!0),e.service?.type===r.serviceType.API?(l(),t(`div`,me,[n(`span`,he,c(r.$t(`application.field.allowConsumeGlobal`)),1),o(O,{modelValue:e.allow_consume_global,"onUpdate:modelValue":t=>e.allow_consume_global=t,"active-value":!0,"inactive-value":!1,onChange:t=>r.updateAllowConsumeGlobal(e,t)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])])):d(``,!0),n(`div`,ge,[o(T,{class:`!m-0 !px-3`,size:`small`,round:``,onClick:t=>r.onGoUsage(e)},{default:m(()=>[o(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),r.rowCanPay(e)?(l(),a(T,{key:0,class:`!m-0 !px-3`,type:`primary`,round:``,size:`small`,onClick:t=>r.onBuyMore(e)},{default:m(()=>[o(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):d(``,!0)])]),_:2},1024))),128)):(l(),a(A,{key:0,description:r.$t(`common.message.noData`)},null,8,[`description`]))],64))])]),_:1})]),_:1}),o(b,null,{default:m(()=>[o(y,{span:24},{default:m(()=>[n(`div`,_e,[o(j,{"current-page":r.page,"page-size":r.limit,total:r.individualApplicationsTotal,onChange:r.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var ye=k(L,[[`render`,ve],[`__scopeId`,`data-v-b4164ed9`]]);export{ye as default};
1
+ import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,dt as u,k as d,nt as f,tt as p,ut as m}from"./vendor-chart-BJCvKk8-.js";import{t as h}from"./button-BydTr5nV.js";import{n as g,t as ee}from"./table-BJr3w4hQ.js";import{t as _}from"./card-DjyfNde2.js";import{n as v,t as y}from"./row-CSxasYIf.js";import{t as b}from"./empty-CdsD8g84.js";import{t as x}from"./Pagination-zB_rZyae.js";import{t as S}from"./skeleton-BwNBivMN.js";import{t as C}from"./switch-CKGiLdIO.js";import{$r as w,B as T,Jr as E,K as D,Mr as O,O as k,Tr as A,Vr as j,Wn as M,jr as N,wr as P}from"./index-BvXr-3ek.js";import{t as F}from"./index.es-C7iPP9Jz.js";import{t as I}from"./CopyToClipboard-DaBIpGcq.js";var L=r({name:`ConsoleApplicationList`,components:{Pagination:x,CopyToClipboard:I,ElTable:ee,ElRow:y,ElButton:h,ElCol:v,ElTag:w,ElSkeleton:S,ElSwitch:C,ElEmpty:b,ElTableColumn:g,ElCard:_,FontAwesomeIcon:F},data(){return{credentialType:P,serviceType:A,individualApplications:[],globalApplications:[],individualApplicationsTotal:void 0,globalApplicationsTotal:void 0,loading:!1,buying:!1,limit:10,form:{amount:1},active:{service:void 0,application:void 0}}},computed:{redirect(){return this.$route.query?.redirect},page(){return parseInt(this.$route.query.page?.toString()||`1`)},showGlobalPayment(){return!0}},watch:{page:{handler(){this.onFetchData()}}},mounted(){this.onInitializeGlobalApplication(),this.onFetchData()},methods:{rowCanPay(e){return j()?(e?.packages||[]).some(e=>e?.metadata?.apple_product_id):!0},updateAllowConsumeGlobal(e,t){!e||!e.id||M.updateAllConsumeGlobal(e.id,{...e,allow_consume_global:!!t}).then(()=>{E.success(this.$t(`application.message.updateSuccessfully`).toString())}).catch(()=>{E.error(this.$t(`application.message.updateFailed`).toString())})},onGoUsage(e){this.$router.push({name:D,query:{application_id:e.id,type:e?.service?.type}})},onBuyMore(e){e?.id&&this.$router.push({name:T,params:{id:e.id}})},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,page:e}})},onFetchApplications(e=N.INDIVIDUAL){return new Promise((t,n)=>{M.getAll({limit:this.limit,...e===N.INDIVIDUAL?{offset:(this.page-1)*this.limit}:{},user_id:this.$store.getters.user.id,ordering:`-created_at`,type:O.USAGE,scope:e}).then(({data:n})=>{e===N.INDIVIDUAL?(this.individualApplications=n.items,this.individualApplicationsTotal=n.count):(this.globalApplications=n.items,this.globalApplicationsTotal=n.count),t(n)}).catch(e=>{E.error(this.$t(`application.message.fetchFailed`).toString()),n(e)})})},onFetchData(){this.loading=!0,Promise.all([this.onFetchApplications(N.INDIVIDUAL),this.onFetchApplications(N.GLOBAL)]).then(()=>{this.loading=!1}).catch(()=>{this.loading=!1})},onInitializeGlobalApplication(){M.create({type:O.USAGE,scope:N.GLOBAL,user_id:this.$store.getters.user.id}).finally(()=>{this.onFetchApplications(N.GLOBAL)})},getRemainingAmount(e){if(e.remaining_amount===void 0||e.remaining_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.remaining_amount?.toFixed(6)} ${t}`},getUsedAmount(e){if(e.used_amount===void 0||e.used_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.used_amount?.toFixed(6)} ${t}`}}}),R={class:`title`},z={key:1,class:`summary-card`},B={class:`icon-wrapper`},V={class:`label`},H={class:`value`},U={class:`description`},W={key:1,class:`flex flex-row justify-between items-center gap-3`},G={class:`summary-card min-w-0 flex-1`},K={class:`flex justify-start items-center gap-2 mb-2 w-full`},q={class:`icon-wrapper !mb-0`},J={class:`text-[var(--el-text-color-regular)] text-[14px] truncate`},te={class:`label`},Y={class:`value`},X={class:`description`},Z={class:`flex flex-col items-end gap-2 shrink-0`},Q={class:`copy`},ne={key:0,class:`expired-at`},re={class:`flex flex-wrap items-center justify-end gap-1`},ie={class:`application-cards block sm:hidden`},ae={class:`flex items-center gap-2 flex-wrap`},oe={class:`application-card__name`},se={class:`application-card__id`},ce={class:`truncate`},le={class:`application-card__row`},ue={class:`label`},de={class:`value`},fe={key:0,class:`application-card__row`},pe={class:`label`},$={class:`value`},me={key:1,class:`application-card__row`},he={class:`label`},ge={class:`flex items-center justify-end gap-2 mt-3`},_e={class:`pagination`};function ve(r,h,g,ee,_,v){let y=p(`el-col`),b=p(`el-row`),x=p(`el-skeleton`),S=p(`font-awesome-icon`),C=p(`el-card`),w=p(`copy-to-clipboard`),T=p(`el-button`),E=p(`el-table-column`),D=p(`el-tag`),O=p(`el-switch`),k=p(`el-table`),A=p(`el-empty`),j=p(`pagination`),M=f(`loading`);return l(),a(b,{class:`application-list`},{default:m(()=>[o(y,{span:24},{default:m(()=>[o(b,null,{default:m(()=>[o(y,{span:24},{default:m(()=>[n(`h2`,R,c(r.$t(`common.title.allApplications`)),1)]),_:1})]),_:1}),o(b,{gutter:15,class:`mb-3`},{default:m(()=>[o(y,{md:12,xs:24},{default:m(()=>[o(C,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:m(()=>[r.loading?(l(),a(x,{key:0})):(l(),t(`div`,z,[n(`div`,B,[o(S,{icon:`fa-solid fa-cubes-stacked`})]),n(`p`,V,c(r.$t(`application.title.count`)),1),n(`p`,H,c(r.individualApplicationsTotal),1),n(`p`,U,c(r.$t(`application.message.countDescription`)),1)]))]),_:1})]),_:1}),r.showGlobalPayment&&r.globalApplications?.length>0?(l(),a(y,{key:0,md:12,xs:24},{default:m(()=>[o(C,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:m(()=>[r.loading?(l(),a(x,{key:0})):(l(),t(`div`,W,[n(`div`,G,[n(`div`,K,[n(`div`,q,[o(S,{icon:`fa-solid fa-wallet`})]),n(`span`,J,[i(c(r.$t(`application.field.id`))+`: `+c(r.globalApplications?.[0]?.id)+` `,1),r.globalApplications?.[0]?.id?(l(),a(w,{key:0,content:r.globalApplications?.[0]?.id,class:`inline-block`},null,8,[`content`])):d(``,!0)])]),n(`p`,te,c(r.$t(`application.title.globalBalance`)),1),n(`p`,Y,c(r.globalApplications?.[0]?.remaining_amount?.toFixed(6)||`0.000000`)+` `+c(r.$t(`service.unit.credits`)),1),n(`p`,X,c(r.$t(`application.message.globalBalanceDescription`)),1)]),n(`div`,Z,[o(T,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:h[0]||=e=>r.onGoUsage(r.globalApplications?.[0])},{default:m(()=>[o(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.usage`)),1)]),_:1}),r.showGlobalPayment?(l(),a(T,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:h[1]||=e=>r.onBuyMore(r.globalApplications?.[0])},{default:m(()=>[o(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.buyMore`)),1)]),_:1})):d(``,!0)])]))]),_:1})]),_:1})):d(``,!0)]),_:1}),o(b,null,{default:m(()=>[o(y,{span:24},{default:m(()=>[o(C,{shadow:`hover`,class:`applications-table-card hidden sm:block`},{default:m(()=>[u((l(),a(k,{data:r.individualApplications,stripe:``,class:`applications-table !min-h-[calc(100vh-420px)]`,"table-layout":`fixed`,"empty-text":r.$t(`common.message.noData`)},{default:m(()=>[o(E,{prop:`id`,label:r.$t(`application.field.id`),width:`200px`,"class-name":`text-center`},{default:m(e=>[n(`span`,null,c(e.row.id),1),n(`span`,Q,[o(w,{content:e?.row?.id,class:`inline-block`},null,8,[`content`])])]),_:1},8,[`label`]),o(E,{label:r.$t(`application.field.type`),width:`90px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[e.row?.type===`Period`?(l(),a(D,{key:0,type:`success`,effect:`dark`,round:``},{default:m(()=>[i(c(r.$t(`application.type.period`)),1)]),_:1})):e.row?.type===`Usage`?(l(),a(D,{key:1,effect:`dark`,round:``},{default:m(()=>[i(c(r.$t(`application.type.usage`)),1)]),_:1})):d(``,!0)]),_:1},8,[`label`]),o(E,{label:r.$t(`application.field.name`),width:`180px`},{default:m(e=>[n(`span`,null,c(e.row?.service?.title),1),e.row?.role===`grantee`?(l(),a(D,{key:0,type:`info`,size:`small`,round:``,class:`ml-2`},{default:m(()=>[i(c(r.$t(`application.badge.shared`)),1)]),_:1})):d(``,!0)]),_:1},8,[`label`]),o(E,{prop:`remaining_amount`,label:r.$t(`application.field.remainingAmount`),width:`150px`,"class-name":`text-center`},{default:m(e=>[n(`span`,null,c(r.getRemainingAmount(e.row)),1)]),_:1},8,[`label`]),o(E,{prop:`used_amount`,label:r.$t(`application.field.usedAmount`),width:`150px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[n(`span`,null,c(r.getUsedAmount(e.row)),1)]),_:1},8,[`label`]),o(E,{prop:`allow_consume_global`,label:r.$t(`application.field.allowConsumeGlobal`),width:`120px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[e.row.service?.type===r.serviceType.API?(l(),a(O,{key:0,modelValue:e.row.allow_consume_global,"onUpdate:modelValue":t=>e.row.allow_consume_global=t,"active-value":!0,"inactive-value":!1,onChange:t=>r.updateAllowConsumeGlobal(e.row,t)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])):d(``,!0)]),_:1},8,[`label`]),o(E,{label:r.$t(`application.field.expiredAt`),width:`180px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[e.row.expired_at?(l(),t(`span`,ne,c(r.$dayjs.format(e.row.expired_at)),1)):d(``,!0)]),_:1},8,[`label`]),o(E,{fixed:`right`,width:`200px`},{default:m(e=>[n(`div`,re,[o(T,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:t=>r.onGoUsage(e?.row)},{default:m(()=>[o(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),r.rowCanPay(e?.row)?(l(),a(T,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:t=>r.onBuyMore(e?.row)},{default:m(()=>[o(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):d(``,!0)])]),_:1})]),_:1},8,[`data`,`empty-text`])),[[M,r.loading]])]),_:1}),n(`div`,ie,[r.loading?(l(),a(x,{key:0,rows:4,animated:``})):(l(),t(s,{key:1},[r.individualApplications?.length?(l(!0),t(s,{key:1},e(r.individualApplications,e=>(l(),a(C,{key:e.id,shadow:`hover`,class:`application-card mb-2`,"body-style":{padding:`14px 16px`}},{default:m(()=>[n(`div`,ae,[n(`span`,oe,c(e?.service?.title),1),e?.type===`Period`?(l(),a(D,{key:0,type:`success`,effect:`dark`,size:`small`,round:``},{default:m(()=>[i(c(r.$t(`application.type.period`)),1)]),_:1})):e?.type===`Usage`?(l(),a(D,{key:1,effect:`dark`,size:`small`,round:``},{default:m(()=>[i(c(r.$t(`application.type.usage`)),1)]),_:1})):d(``,!0),e?.role===`grantee`?(l(),a(D,{key:2,type:`info`,size:`small`,round:``},{default:m(()=>[i(c(r.$t(`application.badge.shared`)),1)]),_:1})):d(``,!0)]),n(`div`,se,[n(`span`,ce,c(r.$t(`application.field.id`))+`: `+c(e.id),1),o(w,{content:e.id,class:`inline-block shrink-0`},null,8,[`content`])]),n(`div`,le,[n(`span`,ue,c(r.$t(`application.field.remainingAmount`)),1),n(`span`,de,c(r.getRemainingAmount(e)),1)]),e?.expired_at?(l(),t(`div`,fe,[n(`span`,pe,c(r.$t(`application.field.expiredAt`)),1),n(`span`,$,c(r.$dayjs.format(e.expired_at)),1)])):d(``,!0),e.service?.type===r.serviceType.API?(l(),t(`div`,me,[n(`span`,he,c(r.$t(`application.field.allowConsumeGlobal`)),1),o(O,{modelValue:e.allow_consume_global,"onUpdate:modelValue":t=>e.allow_consume_global=t,"active-value":!0,"inactive-value":!1,onChange:t=>r.updateAllowConsumeGlobal(e,t)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])])):d(``,!0),n(`div`,ge,[o(T,{class:`!m-0 !px-3`,size:`small`,round:``,onClick:t=>r.onGoUsage(e)},{default:m(()=>[o(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),r.rowCanPay(e)?(l(),a(T,{key:0,class:`!m-0 !px-3`,type:`primary`,round:``,size:`small`,onClick:t=>r.onBuyMore(e)},{default:m(()=>[o(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):d(``,!0)])]),_:2},1024))),128)):(l(),a(A,{key:0,description:r.$t(`common.message.noData`)},null,8,[`description`]))],64))])]),_:1})]),_:1}),o(b,null,{default:m(()=>[o(y,{span:24},{default:m(()=>[n(`div`,_e,[o(j,{"current-page":r.page,"page-size":r.limit,total:r.individualApplicationsTotal,onChange:r.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var ye=k(L,[[`render`,ve],[`__scopeId`,`data-v-b4164ed9`]]);export{ye as default};
@@ -1 +1 @@
1
- import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,dt as u,nt as d,tt as f,ut as p}from"./vendor-chart-BJCvKk8-.js";import{t as m}from"./button-BydTr5nV.js";import{r as h,t as g}from"./select-BNNyIngy.js";import{n as _,t as v}from"./table-BJr3w4hQ.js";import{t as y}from"./card-DjyfNde2.js";import{t as b}from"./date-picker-DFWF2WgW.js";import{n as x,t as S}from"./row-B1Fh_BWz.js";import{t as C}from"./Pagination-GVBd1ZiN.js";import{t as w}from"./skeleton-BwNBivMN.js";import{$r as T,Er as E,Ln as D,O,Wt as k}from"./index-DclJnQCv.js";import{t as A}from"./index.es-Dam0OO1D.js";import{t as j}from"./CopyToClipboard-BH7fpVgM.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:T,ElCard:y,ElSelect:h,ElOption:g,ElDatePicker:b,ElSkeleton:w,FontAwesomeIcon:A},data(){return{OrderState:E,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:E.PENDING,label:this.$t(`order.state.pending`)},{value:E.FINISHED,label:this.$t(`order.state.finished`)},{value:E.PAID,label:this.$t(`order.state.paid`)},{value:E.EXPIRED,label:this.$t(`order.state.expired`)},{value:E.FAILED,label:this.$t(`order.state.failed`)},{value:E.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===E.FINISHED||e===E.PAID?`success`:e===E.EXPIRED||e===E.FAILED?`danger`:e===E.REFUNDED?`warning`:`info`},stateLabel(e){return{[E.PENDING]:this.$t(`order.state.pending`),[E.PAID]:this.$t(`order.state.paid`),[E.FINISHED]:this.$t(`order.state.finished`),[E.EXPIRED]:this.$t(`order.state.expired`),[E.FAILED]:this.$t(`order.state.failed`),[E.REFUNDED]:this.$t(`order.state.refunded`)}[e]||e},isPendingAction(e){return e!==E.PAID&&e!==E.FINISHED&&e!==E.EXPIRED&&e!==E.FAILED&&e!==E.REFUNDED},goToDetail(e){this.$router.push({name:`console-order-detail`,params:{id:e}})},async onFilterChange(){await this.$router.push({name:this.$route.name?.toString(),query:{page:1,...this.filterState?{state:this.filterState}:{},...this.filterPayWay?{pay_way:this.filterPayWay}:{},...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0].toISOString()}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1].toISOString()}:{}}}),this.onFetchData(),this.onFetchSummary()},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,page:e}})},onFetchData(){this.loading=!0,D.getAll({ordering:`-created_at`,limit:this.limit,offset:(this.page-1)*this.limit,...this.filterQuery}).then(({data:e})=>{this.orders=e.items,this.total=e.count}).catch(()=>{}).finally(()=>{this.loading=!1})},onFetchSummary(){this.summaryLoading=!0,D.getSummary(this.filterQuery).then(({data:e})=>{this.summary=e}).catch(()=>{this.summary={...M}}).finally(()=>{this.summaryLoading=!1})},onExport(){this.exporting=!0,D.exportCsv(this.filterQuery).then(({data:e})=>{let t=window.URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`orders.csv`,n.click(),window.URL.revokeObjectURL(t)}).catch(()=>{}).finally(()=>{this.exporting=!1})}}}),P={class:`title`},F={key:1,class:`card-content`},I={class:`icon-wrapper`},L={class:`description`},R={class:`value`},z={key:1,class:`card-content`},B={class:`icon-wrapper`},V={class:`description`},H={class:`value`},U={key:1,class:`card-content`},W={class:`icon-wrapper`},ee={class:`description`},G={class:`value`},K={key:1,class:`card-content`},q={class:`icon-wrapper`},J={class:`description`},Y={class:`value`},X={class:`filter-row mb-3`},Z={class:`key`},Q={class:`cursor-pointer`},$={class:`price`},te={class:`description`},ne={class:`text-gray-500`},re={class:`created-at`},ie={class:`flex items-center justify-center flex-wrap`},ae={class:`float-right`};function oe(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=O(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-DOCxBFVa.js";import{n as _,t as v}from"./table-BJr3w4hQ.js";import{t as y}from"./card-DjyfNde2.js";import{t as b}from"./date-picker-vxBUCvDp.js";import{n as x,t as S}from"./row-CSxasYIf.js";import{t as C}from"./Pagination-zB_rZyae.js";import{t as w}from"./skeleton-BwNBivMN.js";import{$r as T,Er as E,Ln as D,O,Wt as k}from"./index-BvXr-3ek.js";import{t as A}from"./index.es-C7iPP9Jz.js";import{t as j}from"./CopyToClipboard-DaBIpGcq.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:T,ElCard:y,ElSelect:h,ElOption:g,ElDatePicker:b,ElSkeleton:w,FontAwesomeIcon:A},data(){return{OrderState:E,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:E.PENDING,label:this.$t(`order.state.pending`)},{value:E.FINISHED,label:this.$t(`order.state.finished`)},{value:E.PAID,label:this.$t(`order.state.paid`)},{value:E.EXPIRED,label:this.$t(`order.state.expired`)},{value:E.FAILED,label:this.$t(`order.state.failed`)},{value:E.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===E.FINISHED||e===E.PAID?`success`:e===E.EXPIRED||e===E.FAILED?`danger`:e===E.REFUNDED?`warning`:`info`},stateLabel(e){return{[E.PENDING]:this.$t(`order.state.pending`),[E.PAID]:this.$t(`order.state.paid`),[E.FINISHED]:this.$t(`order.state.finished`),[E.EXPIRED]:this.$t(`order.state.expired`),[E.FAILED]:this.$t(`order.state.failed`),[E.REFUNDED]:this.$t(`order.state.refunded`)}[e]||e},isPendingAction(e){return e!==E.PAID&&e!==E.FINISHED&&e!==E.EXPIRED&&e!==E.FAILED&&e!==E.REFUNDED},goToDetail(e){this.$router.push({name:`console-order-detail`,params:{id:e}})},async onFilterChange(){await this.$router.push({name:this.$route.name?.toString(),query:{page:1,...this.filterState?{state:this.filterState}:{},...this.filterPayWay?{pay_way:this.filterPayWay}:{},...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0].toISOString()}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1].toISOString()}:{}}}),this.onFetchData(),this.onFetchSummary()},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,page:e}})},onFetchData(){this.loading=!0,D.getAll({ordering:`-created_at`,limit:this.limit,offset:(this.page-1)*this.limit,...this.filterQuery}).then(({data:e})=>{this.orders=e.items,this.total=e.count}).catch(()=>{}).finally(()=>{this.loading=!1})},onFetchSummary(){this.summaryLoading=!0,D.getSummary(this.filterQuery).then(({data:e})=>{this.summary=e}).catch(()=>{this.summary={...M}}).finally(()=>{this.summaryLoading=!1})},onExport(){this.exporting=!0,D.exportCsv(this.filterQuery).then(({data:e})=>{let t=window.URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`orders.csv`,n.click(),window.URL.revokeObjectURL(t)}).catch(()=>{}).finally(()=>{this.exporting=!1})}}}),P={class:`title`},F={key:1,class:`card-content`},I={class:`icon-wrapper`},L={class:`description`},R={class:`value`},z={key:1,class:`card-content`},B={class:`icon-wrapper`},V={class:`description`},H={class:`value`},U={key:1,class:`card-content`},W={class:`icon-wrapper`},ee={class:`description`},G={class:`value`},K={key:1,class:`card-content`},q={class:`icon-wrapper`},J={class:`description`},Y={class:`value`},X={class:`filter-row mb-3`},Z={class:`key`},Q={class:`cursor-pointer`},$={class:`price`},te={class:`description`},ne={class:`text-gray-500`},re={class:`created-at`},ie={class:`flex items-center justify-center flex-wrap`},ae={class:`float-right`};function oe(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=O(N,[[`render`,oe],[`__scopeId`,`data-v-350ab467`]]);export{se as default};
@@ -1 +1 @@
1
- import{A as e,D as t,F as n,P as r,Wt as i,Z as a,tt as o}from"./vendor-chart-BJCvKk8-.js";import{O as s}from"./index-DclJnQCv.js";import{t as c}from"./LocalTools-DjhDkgm5.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-BvXr-3ek.js";import{t as c}from"./LocalTools-Co2UcXcC.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{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,k as u,tt as d,ut as f}from"./vendor-chart-BJCvKk8-.js";import{t as p}from"./button-BydTr5nV.js";import{H as m}from"./use-deprecated-B-NFNg3W.js";import{t as ee}from"./switch-DWXQZz-o.js";import{$r as te,A as h,O as g}from"./index-DclJnQCv.js";import{t as _}from"./index.es-Dam0OO1D.js";var v=r({name:`LocalToolsSetting`,components:{ElButton:p,ElTag:te,ElSwitch:ee,FontAwesomeIcon:_},data(){return{Plus:m,roots:[],tools:[],grants:null,perm:null,computerUse:!1,computerTools:[],computerGrants:{},cuBusy:null,builtinTools:[],toolGrants:{},builtinBusy:null,savingCU:!1,preauthorizing:!1,saving:!1,savedTip:!1,cuOff:null}},computed:{desktop(){return!!h()}},async mounted(){let e=h();if(!e)return;let t=await e.getConfig();this.roots=t.roots,this.computerUse=t.computerUse===!0,this.tools=(await e.listTools()).map(e=>e.name),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.cuOff=e.onComputerUseDisabled?.(()=>{this.computerUse=!1})??null},beforeUnmount(){this.cuOff?.()},methods:{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)},async open(e){await h()?.perm?.openPane(e)},async save(){this.saving=!0;let e=await h()?.getConfig();await h()?.saveConfig({roots:this.roots,mcp:e?.mcp??[],computerUse:this.computerUse}),this.saving=!1,this.savedTip=!0,setTimeout(()=>this.savedTip=!1,2e3)},async onToggleComputerUse(e){this.savingCU=!0;let t=await h()?.getConfig();await h()?.saveConfig({roots:t?.roots??this.roots,mcp:t?.mcp??[],computerUse:e===!0}),this.savingCU=!1},async preauthorizeAll(){let e=h();if(e?.preauthorizeComputerUse){this.preauthorizing=!0;try{let t=await e.preauthorizeComputerUse();this.computerUse=t.computerUse===!0,t.perm?.mac&&(this.perm=t.perm),await this.loadGrants()}finally{this.preauthorizing=!1}}},async onToggleComputerTool(e,t){let n=h();if(n){this.cuBusy=e;try{if(t===!0){let t=await n.preauthorizeComputerUse?.([e]);t&&(this.computerUse=t.computerUse===!0,t.perm?.mac&&(this.perm=t.perm))}else await n.grants?.revoke(e);await this.loadGrants()}finally{this.cuBusy=null}}},cuLabel(e){let t=`common.settings.localToolsCu${this.cuSuffix(e)}`,n=this.$t(t);return n===t?e.replace(/^computer\./,``):n},cuIcon(e){return{screenshot:`fa-solid fa-camera`,click:`fa-solid fa-arrow-pointer`,move:`fa-solid fa-up-down-left-right`,type:`fa-solid fa-keyboard`,key:`fa-solid fa-keyboard`,scroll:`fa-solid fa-arrows-up-down`}[e.replace(/^computer\./,``)]??`fa-solid fa-shield-halved`},cuSuffix(e){let t=e.replace(/^computer\./,``);return t.charAt(0).toUpperCase()+t.slice(1)},async onToggleBuiltinTool(e,t){let n=h();if(n?.grants){this.builtinBusy=e;try{t===!0?(await n.grants.grantToolWide?.(e))?.ok||(this.toolGrants={...this.toolGrants,[e]:!1}):await n.grants.revoke(e),await this.loadGrants()}finally{this.builtinBusy=null}}},builtinIcon(e){return e===`shell.run_command`?`fa-solid fa-terminal`:e===`fs.write_file`?`fa-solid fa-pen`:e===`fs.read_file`?`fa-solid fa-file`:e===`fs.list_dir`?`fa-solid fa-folder`:`fa-solid fa-shield-halved`},async revoke(e){await h()?.grants?.revoke(e),await this.loadGrants()},async revokeAll(){await h()?.grants?.clear(),await this.loadGrants()}}}),y={class:`settings-list local-tools-setting`},b={key:0,class:`hint muted`},x={class:`section-head`},S={class:`muted`},C={class:`rows`},w={class:`path`},T={key:0,class:`row muted empty`},E={class:`actions`},D={key:0,class:`muted saved-tip`},O={key:0,class:`muted tools`},k={key:0},A={class:`section-head`},j={class:`muted`},M={class:`rows`},N={class:`grant`},P={class:`grant-name`},F={class:`grant-input`},I={key:0,class:`row muted empty`},L={key:1},ne={class:`section-head`},R={class:`muted`},z={class:`rows`},B={class:`cu-action`},V={class:`cu-action-name`},H={class:`grant-name`},U={class:`cu-action-desc`},W={class:`section-head`},G={class:`muted`},K={class:`section-head sub`},q={class:`muted`},J={class:`rows`},Y={class:`cu-action`},X={class:`cu-action-name`},Z={class:`cu-action-desc`},re={key:2},ie={class:`section-head`},ae={class:`muted`},oe={class:`perm-row`},se={class:`perm-name`},Q={class:`perm-row`},ce={class:`perm-name`},le={class:`perm-row`},ue={class:`perm-name`};function $(r,p,m,ee,te,h){let g=d(`el-button`),_=d(`font-awesome-icon`),v=d(`el-tag`),$=d(`el-switch`);return l(),t(`div`,y,[r.desktop?(l(),t(s,{key:1},[n(`section`,null,[n(`div`,x,[n(`h3`,null,c(r.$t(`common.settings.localToolsFoldersTitle`)),1),o(g,{size:`small`,type:`primary`,icon:r.Plus,onClick:r.addFolder},{default:f(()=>[i(c(r.$t(`common.settings.localToolsAddFolder`)),1)]),_:1},8,[`icon`,`onClick`])]),n(`p`,S,c(r.$t(`common.settings.localToolsFoldersHint`)),1),n(`ul`,C,[(l(!0),t(s,null,e(r.roots,(e,a)=>(l(),t(`li`,{key:e,class:`row`},[o(_,{icon:`fa-solid fa-folder`,class:`row-icon`}),n(`span`,w,c(e),1),o(g,{size:`small`,text:``,type:`danger`,onClick:e=>r.removeRoot(a)},{default:f(()=>[i(c(r.$t(`common.settings.localToolsRemove`)),1)]),_:1},8,[`onClick`])]))),128)),r.roots.length?u(``,!0):(l(),t(`li`,T,c(r.$t(`common.settings.localToolsNoFolders`)),1))]),n(`div`,E,[o(g,{size:`small`,type:`primary`,loading:r.saving,onClick:r.save},{default:f(()=>[i(c(r.$t(`common.settings.localToolsSave`)),1)]),_:1},8,[`loading`,`onClick`]),r.savedTip?(l(),t(`span`,D,c(r.$t(`common.settings.localToolsSaved`)),1)):u(``,!0)]),r.tools.length?(l(),t(`p`,O,c(r.$t(`common.settings.localToolsActiveTools`))+`: `+c(r.tools.join(`, `)),1)):u(``,!0)]),r.grants===null?u(``,!0):(l(),t(`section`,k,[n(`div`,A,[n(`h3`,null,c(r.$t(`common.settings.localToolsGrantsTitle`)),1),r.grants.length?(l(),a(g,{key:0,size:`small`,text:``,type:`danger`,onClick:r.revokeAll},{default:f(()=>[i(c(r.$t(`common.settings.localToolsRevokeAll`)),1)]),_:1},8,[`onClick`])):u(``,!0)]),n(`p`,j,c(r.$t(`common.settings.localToolsGrantsHint`)),1),n(`ul`,M,[(l(!0),t(s,null,e(r.grants,e=>(l(),t(`li`,{key:e.key,class:`row`},[o(_,{icon:`fa-solid fa-shield-halved`,class:`row-icon`}),n(`span`,N,[n(`code`,P,c(e.name),1),n(`span`,F,c(e.input),1)]),o(g,{size:`small`,type:`danger`,onClick:t=>r.revoke(e.key)},{default:f(()=>[i(c(r.$t(`common.settings.localToolsRevoke`)),1)]),_:1},8,[`onClick`])]))),128)),r.grants.length?u(``,!0):(l(),t(`li`,I,c(r.$t(`common.settings.localToolsNoGrants`)),1))])])),r.builtinTools.length?(l(),t(`section`,L,[n(`div`,ne,[n(`h3`,null,c(r.$t(`common.settings.localToolsBuiltinTitle`)),1)]),n(`p`,R,c(r.$t(`common.settings.localToolsBuiltinHint`)),1),n(`ul`,z,[(l(!0),t(s,null,e(r.builtinTools,e=>(l(),t(`li`,{key:e.name,class:`row`},[o(_,{icon:r.builtinIcon(e.name),class:`row-icon`},null,8,[`icon`]),n(`span`,B,[n(`span`,V,[n(`code`,H,c(e.name),1),e.name===`shell.run_command`?(l(),a(v,{key:0,size:`small`,type:`danger`,effect:`plain`},{default:f(()=>[i(c(r.$t(`common.settings.localToolsBuiltinRisky`)),1)]),_:1})):u(``,!0)]),n(`span`,U,c(e.description),1)]),o($,{"model-value":r.toolGrants[e.name]===!0,loading:r.builtinBusy===e.name,disabled:!!r.builtinBusy,onChange:t=>r.onToggleBuiltinTool(e.name,t)},null,8,[`model-value`,`loading`,`disabled`,`onChange`])]))),128))])])):u(``,!0),n(`section`,null,[n(`div`,W,[n(`h3`,null,c(r.$t(`common.settings.localToolsComputerUseTitle`)),1),o($,{modelValue:r.computerUse,"onUpdate:modelValue":p[0]||=e=>r.computerUse=e,loading:r.savingCU,onChange:r.onToggleComputerUse},null,8,[`modelValue`,`loading`,`onChange`])]),n(`p`,G,c(r.$t(`common.settings.localToolsComputerUseHint`)),1),r.computerTools.length?(l(),t(s,{key:0},[n(`div`,K,[n(`h4`,null,c(r.$t(`common.settings.localToolsCuActionsTitle`)),1),o(g,{size:`small`,text:``,type:`primary`,loading:r.preauthorizing,onClick:r.preauthorizeAll},{default:f(()=>[i(c(r.$t(`common.settings.localToolsPreauthorizeAll`)),1)]),_:1},8,[`loading`,`onClick`])]),n(`p`,q,c(r.$t(`common.settings.localToolsCuActionsHint`)),1),n(`ul`,J,[(l(!0),t(s,null,e(r.computerTools,e=>(l(),t(`li`,{key:e.name,class:`row`},[o(_,{icon:r.cuIcon(e.name),class:`row-icon`},null,8,[`icon`]),n(`span`,Y,[n(`span`,X,c(r.cuLabel(e.name)),1),n(`span`,Z,c(e.description),1)]),o($,{"model-value":r.computerGrants[e.name]===!0,loading:r.cuBusy===e.name,disabled:!!r.cuBusy||r.preauthorizing,onChange:t=>r.onToggleComputerTool(e.name,t)},null,8,[`model-value`,`loading`,`disabled`,`onChange`])]))),128))])],64)):u(``,!0)]),r.perm?(l(),t(`section`,re,[n(`div`,ie,[n(`h3`,null,c(r.$t(`common.settings.localToolsPermsTitle`)),1)]),n(`p`,ae,c(r.$t(`common.settings.localToolsPermsHint`)),1),n(`div`,oe,[n(`span`,se,c(r.$t(`common.settings.localToolsPermFullDisk`)),1),o(v,{size:`small`,type:r.perm.fullDisk?`success`:`info`,effect:`plain`},{default:f(()=>[i(c(r.perm.fullDisk?r.$t(`common.settings.localToolsGranted`):r.$t(`common.settings.localToolsNotGranted`)),1)]),_:1},8,[`type`]),o(g,{size:`small`,type:`primary`,onClick:p[1]||=e=>r.open(`fullDisk`)},{default:f(()=>[i(c(r.$t(`common.settings.localToolsOpen`)),1)]),_:1})]),n(`div`,Q,[n(`span`,ce,c(r.$t(`common.settings.localToolsPermScreen`)),1),o(v,{size:`small`,type:r.perm.screen===`granted`?`success`:`info`,effect:`plain`},{default:f(()=>[i(c(r.perm.screen===`granted`?r.$t(`common.settings.localToolsGranted`):r.$t(`common.settings.localToolsNotGranted`)),1)]),_:1},8,[`type`]),o(g,{size:`small`,type:`primary`,onClick:p[2]||=e=>r.open(`screen`)},{default:f(()=>[i(c(r.$t(`common.settings.localToolsOpen`)),1)]),_:1})]),n(`div`,le,[n(`span`,ue,c(r.$t(`common.settings.localToolsPermAccessibility`)),1),o(v,{size:`small`,type:r.perm.accessibility?`success`:`info`,effect:`plain`},{default:f(()=>[i(c(r.perm.accessibility?r.$t(`common.settings.localToolsGranted`):r.$t(`common.settings.localToolsNotGranted`)),1)]),_:1},8,[`type`]),o(g,{size:`small`,type:`primary`,onClick:p[3]||=e=>r.open(`accessibility`)},{default:f(()=>[i(c(r.$t(`common.settings.localToolsOpen`)),1)]),_:1})])])):u(``,!0)],64)):(l(),t(`p`,b,c(r.$t(`common.settings.localToolsDesktopOnly`)),1))])}var de=g(v,[[`render`,$],[`__scopeId`,`data-v-2eeda110`]]);export{de as t};
1
+ import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,k as u,tt as d,ut as f}from"./vendor-chart-BJCvKk8-.js";import{t as p}from"./button-BydTr5nV.js";import{H as m}from"./use-deprecated-B-NFNg3W.js";import{t as ee}from"./switch-CKGiLdIO.js";import{$r as te,A as h,O as g}from"./index-BvXr-3ek.js";import{t as _}from"./index.es-C7iPP9Jz.js";var v=r({name:`LocalToolsSetting`,components:{ElButton:p,ElTag:te,ElSwitch:ee,FontAwesomeIcon:_},data(){return{Plus:m,roots:[],tools:[],grants:null,perm:null,computerUse:!1,computerTools:[],computerGrants:{},cuBusy:null,builtinTools:[],toolGrants:{},builtinBusy:null,savingCU:!1,preauthorizing:!1,saving:!1,savedTip:!1,cuOff:null}},computed:{desktop(){return!!h()}},async mounted(){let e=h();if(!e)return;let t=await e.getConfig();this.roots=t.roots,this.computerUse=t.computerUse===!0,this.tools=(await e.listTools()).map(e=>e.name),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.cuOff=e.onComputerUseDisabled?.(()=>{this.computerUse=!1})??null},beforeUnmount(){this.cuOff?.()},methods:{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)},async open(e){await h()?.perm?.openPane(e)},async save(){this.saving=!0;let e=await h()?.getConfig();await h()?.saveConfig({roots:this.roots,mcp:e?.mcp??[],computerUse:this.computerUse}),this.saving=!1,this.savedTip=!0,setTimeout(()=>this.savedTip=!1,2e3)},async onToggleComputerUse(e){this.savingCU=!0;let t=await h()?.getConfig();await h()?.saveConfig({roots:t?.roots??this.roots,mcp:t?.mcp??[],computerUse:e===!0}),this.savingCU=!1},async preauthorizeAll(){let e=h();if(e?.preauthorizeComputerUse){this.preauthorizing=!0;try{let t=await e.preauthorizeComputerUse();this.computerUse=t.computerUse===!0,t.perm?.mac&&(this.perm=t.perm),await this.loadGrants()}finally{this.preauthorizing=!1}}},async onToggleComputerTool(e,t){let n=h();if(n){this.cuBusy=e;try{if(t===!0){let t=await n.preauthorizeComputerUse?.([e]);t&&(this.computerUse=t.computerUse===!0,t.perm?.mac&&(this.perm=t.perm))}else await n.grants?.revoke(e);await this.loadGrants()}finally{this.cuBusy=null}}},cuLabel(e){let t=`common.settings.localToolsCu${this.cuSuffix(e)}`,n=this.$t(t);return n===t?e.replace(/^computer\./,``):n},cuIcon(e){return{screenshot:`fa-solid fa-camera`,click:`fa-solid fa-arrow-pointer`,move:`fa-solid fa-up-down-left-right`,type:`fa-solid fa-keyboard`,key:`fa-solid fa-keyboard`,scroll:`fa-solid fa-arrows-up-down`}[e.replace(/^computer\./,``)]??`fa-solid fa-shield-halved`},cuSuffix(e){let t=e.replace(/^computer\./,``);return t.charAt(0).toUpperCase()+t.slice(1)},async onToggleBuiltinTool(e,t){let n=h();if(n?.grants){this.builtinBusy=e;try{t===!0?(await n.grants.grantToolWide?.(e))?.ok||(this.toolGrants={...this.toolGrants,[e]:!1}):await n.grants.revoke(e),await this.loadGrants()}finally{this.builtinBusy=null}}},builtinIcon(e){return e===`shell.run_command`?`fa-solid fa-terminal`:e===`fs.write_file`?`fa-solid fa-pen`:e===`fs.read_file`?`fa-solid fa-file`:e===`fs.list_dir`?`fa-solid fa-folder`:`fa-solid fa-shield-halved`},async revoke(e){await h()?.grants?.revoke(e),await this.loadGrants()},async revokeAll(){await h()?.grants?.clear(),await this.loadGrants()}}}),y={class:`settings-list local-tools-setting`},b={key:0,class:`hint muted`},x={class:`section-head`},S={class:`muted`},C={class:`rows`},w={class:`path`},T={key:0,class:`row muted empty`},E={class:`actions`},D={key:0,class:`muted saved-tip`},O={key:0,class:`muted tools`},k={key:0},A={class:`section-head`},j={class:`muted`},M={class:`rows`},N={class:`grant`},P={class:`grant-name`},F={class:`grant-input`},I={key:0,class:`row muted empty`},L={key:1},ne={class:`section-head`},R={class:`muted`},z={class:`rows`},B={class:`cu-action`},V={class:`cu-action-name`},H={class:`grant-name`},U={class:`cu-action-desc`},W={class:`section-head`},G={class:`muted`},K={class:`section-head sub`},q={class:`muted`},J={class:`rows`},Y={class:`cu-action`},X={class:`cu-action-name`},Z={class:`cu-action-desc`},re={key:2},ie={class:`section-head`},ae={class:`muted`},oe={class:`perm-row`},se={class:`perm-name`},Q={class:`perm-row`},ce={class:`perm-name`},le={class:`perm-row`},ue={class:`perm-name`};function $(r,p,m,ee,te,h){let g=d(`el-button`),_=d(`font-awesome-icon`),v=d(`el-tag`),$=d(`el-switch`);return l(),t(`div`,y,[r.desktop?(l(),t(s,{key:1},[n(`section`,null,[n(`div`,x,[n(`h3`,null,c(r.$t(`common.settings.localToolsFoldersTitle`)),1),o(g,{size:`small`,type:`primary`,icon:r.Plus,onClick:r.addFolder},{default:f(()=>[i(c(r.$t(`common.settings.localToolsAddFolder`)),1)]),_:1},8,[`icon`,`onClick`])]),n(`p`,S,c(r.$t(`common.settings.localToolsFoldersHint`)),1),n(`ul`,C,[(l(!0),t(s,null,e(r.roots,(e,a)=>(l(),t(`li`,{key:e,class:`row`},[o(_,{icon:`fa-solid fa-folder`,class:`row-icon`}),n(`span`,w,c(e),1),o(g,{size:`small`,text:``,type:`danger`,onClick:e=>r.removeRoot(a)},{default:f(()=>[i(c(r.$t(`common.settings.localToolsRemove`)),1)]),_:1},8,[`onClick`])]))),128)),r.roots.length?u(``,!0):(l(),t(`li`,T,c(r.$t(`common.settings.localToolsNoFolders`)),1))]),n(`div`,E,[o(g,{size:`small`,type:`primary`,loading:r.saving,onClick:r.save},{default:f(()=>[i(c(r.$t(`common.settings.localToolsSave`)),1)]),_:1},8,[`loading`,`onClick`]),r.savedTip?(l(),t(`span`,D,c(r.$t(`common.settings.localToolsSaved`)),1)):u(``,!0)]),r.tools.length?(l(),t(`p`,O,c(r.$t(`common.settings.localToolsActiveTools`))+`: `+c(r.tools.join(`, `)),1)):u(``,!0)]),r.grants===null?u(``,!0):(l(),t(`section`,k,[n(`div`,A,[n(`h3`,null,c(r.$t(`common.settings.localToolsGrantsTitle`)),1),r.grants.length?(l(),a(g,{key:0,size:`small`,text:``,type:`danger`,onClick:r.revokeAll},{default:f(()=>[i(c(r.$t(`common.settings.localToolsRevokeAll`)),1)]),_:1},8,[`onClick`])):u(``,!0)]),n(`p`,j,c(r.$t(`common.settings.localToolsGrantsHint`)),1),n(`ul`,M,[(l(!0),t(s,null,e(r.grants,e=>(l(),t(`li`,{key:e.key,class:`row`},[o(_,{icon:`fa-solid fa-shield-halved`,class:`row-icon`}),n(`span`,N,[n(`code`,P,c(e.name),1),n(`span`,F,c(e.input),1)]),o(g,{size:`small`,type:`danger`,onClick:t=>r.revoke(e.key)},{default:f(()=>[i(c(r.$t(`common.settings.localToolsRevoke`)),1)]),_:1},8,[`onClick`])]))),128)),r.grants.length?u(``,!0):(l(),t(`li`,I,c(r.$t(`common.settings.localToolsNoGrants`)),1))])])),r.builtinTools.length?(l(),t(`section`,L,[n(`div`,ne,[n(`h3`,null,c(r.$t(`common.settings.localToolsBuiltinTitle`)),1)]),n(`p`,R,c(r.$t(`common.settings.localToolsBuiltinHint`)),1),n(`ul`,z,[(l(!0),t(s,null,e(r.builtinTools,e=>(l(),t(`li`,{key:e.name,class:`row`},[o(_,{icon:r.builtinIcon(e.name),class:`row-icon`},null,8,[`icon`]),n(`span`,B,[n(`span`,V,[n(`code`,H,c(e.name),1),e.name===`shell.run_command`?(l(),a(v,{key:0,size:`small`,type:`danger`,effect:`plain`},{default:f(()=>[i(c(r.$t(`common.settings.localToolsBuiltinRisky`)),1)]),_:1})):u(``,!0)]),n(`span`,U,c(e.description),1)]),o($,{"model-value":r.toolGrants[e.name]===!0,loading:r.builtinBusy===e.name,disabled:!!r.builtinBusy,onChange:t=>r.onToggleBuiltinTool(e.name,t)},null,8,[`model-value`,`loading`,`disabled`,`onChange`])]))),128))])])):u(``,!0),n(`section`,null,[n(`div`,W,[n(`h3`,null,c(r.$t(`common.settings.localToolsComputerUseTitle`)),1),o($,{modelValue:r.computerUse,"onUpdate:modelValue":p[0]||=e=>r.computerUse=e,loading:r.savingCU,onChange:r.onToggleComputerUse},null,8,[`modelValue`,`loading`,`onChange`])]),n(`p`,G,c(r.$t(`common.settings.localToolsComputerUseHint`)),1),r.computerTools.length?(l(),t(s,{key:0},[n(`div`,K,[n(`h4`,null,c(r.$t(`common.settings.localToolsCuActionsTitle`)),1),o(g,{size:`small`,text:``,type:`primary`,loading:r.preauthorizing,onClick:r.preauthorizeAll},{default:f(()=>[i(c(r.$t(`common.settings.localToolsPreauthorizeAll`)),1)]),_:1},8,[`loading`,`onClick`])]),n(`p`,q,c(r.$t(`common.settings.localToolsCuActionsHint`)),1),n(`ul`,J,[(l(!0),t(s,null,e(r.computerTools,e=>(l(),t(`li`,{key:e.name,class:`row`},[o(_,{icon:r.cuIcon(e.name),class:`row-icon`},null,8,[`icon`]),n(`span`,Y,[n(`span`,X,c(r.cuLabel(e.name)),1),n(`span`,Z,c(e.description),1)]),o($,{"model-value":r.computerGrants[e.name]===!0,loading:r.cuBusy===e.name,disabled:!!r.cuBusy||r.preauthorizing,onChange:t=>r.onToggleComputerTool(e.name,t)},null,8,[`model-value`,`loading`,`disabled`,`onChange`])]))),128))])],64)):u(``,!0)]),r.perm?(l(),t(`section`,re,[n(`div`,ie,[n(`h3`,null,c(r.$t(`common.settings.localToolsPermsTitle`)),1)]),n(`p`,ae,c(r.$t(`common.settings.localToolsPermsHint`)),1),n(`div`,oe,[n(`span`,se,c(r.$t(`common.settings.localToolsPermFullDisk`)),1),o(v,{size:`small`,type:r.perm.fullDisk?`success`:`info`,effect:`plain`},{default:f(()=>[i(c(r.perm.fullDisk?r.$t(`common.settings.localToolsGranted`):r.$t(`common.settings.localToolsNotGranted`)),1)]),_:1},8,[`type`]),o(g,{size:`small`,type:`primary`,onClick:p[1]||=e=>r.open(`fullDisk`)},{default:f(()=>[i(c(r.$t(`common.settings.localToolsOpen`)),1)]),_:1})]),n(`div`,Q,[n(`span`,ce,c(r.$t(`common.settings.localToolsPermScreen`)),1),o(v,{size:`small`,type:r.perm.screen===`granted`?`success`:`info`,effect:`plain`},{default:f(()=>[i(c(r.perm.screen===`granted`?r.$t(`common.settings.localToolsGranted`):r.$t(`common.settings.localToolsNotGranted`)),1)]),_:1},8,[`type`]),o(g,{size:`small`,type:`primary`,onClick:p[2]||=e=>r.open(`screen`)},{default:f(()=>[i(c(r.$t(`common.settings.localToolsOpen`)),1)]),_:1})]),n(`div`,le,[n(`span`,ue,c(r.$t(`common.settings.localToolsPermAccessibility`)),1),o(v,{size:`small`,type:r.perm.accessibility?`success`:`info`,effect:`plain`},{default:f(()=>[i(c(r.perm.accessibility?r.$t(`common.settings.localToolsGranted`):r.$t(`common.settings.localToolsNotGranted`)),1)]),_:1},8,[`type`]),o(g,{size:`small`,type:`primary`,onClick:p[3]||=e=>r.open(`accessibility`)},{default:f(()=>[i(c(r.$t(`common.settings.localToolsOpen`)),1)]),_:1})])])):u(``,!0)],64)):(l(),t(`p`,b,c(r.$t(`common.settings.localToolsDesktopOnly`)),1))])}var de=g(v,[[`render`,$],[`__scopeId`,`data-v-2eeda110`]]);export{de as t};
@@ -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-DS288V9m.js";import{t as m}from"./checkbox-BC1X4B2U.js";import{t as h}from"./divider-LA__Fty9.js";import"./constants-DNpQuSUd.js";import{Ht as g,Jr as _,Lr as v,Mr as y,O as b,Pr as x,Wn as S,Zr as C,jr as w}from"./index-DclJnQCv.js";import{t as T}from"./Status-DwS3bnGN.js";var E=r({name:`ApplicationConfirm`,components:{ElDialog:C,ElDivider:h,ElCheckbox:m,ElButton:f},props:{visible:{type:Boolean,required:!1,default:!1}},emits:[`update:visible`,`apply`],data(){return{checked:!0}},watch:{},methods:{getBaseUrlPlatform:v,onApply(){if(!this.checked){_.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=g(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:w.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`):_.error(this.$t(`application.message.applyFailed`))}},showWelcomeToast(){let e=this.$store.state.applications?.[0],t=Math.floor(e?.remaining_amount??0);_({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-2a0de4ac`]]);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-BP0eFtEz.js";import{t as m}from"./checkbox-BC1X4B2U.js";import{t as h}from"./divider-LA__Fty9.js";import"./constants-DNpQuSUd.js";import{Ht as g,Jr as _,Lr as v,Mr as y,O as b,Pr as x,Wn as S,Zr as C,jr as w}from"./index-BvXr-3ek.js";import{t as T}from"./Status-ZSvRAAJM.js";var E=r({name:`ApplicationConfirm`,components:{ElDialog:C,ElDivider:h,ElCheckbox:m,ElButton:f},props:{visible:{type:Boolean,required:!1,default:!1}},emits:[`update:visible`,`apply`],data(){return{checked:!0}},watch:{},methods:{getBaseUrlPlatform:v,onApply(){if(!this.checked){_.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=g(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:w.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`):_.error(this.$t(`application.message.applyFailed`))}},showWelcomeToast(){let e=this.$store.state.applications?.[0],t=Math.floor(e?.remaining_amount??0);_({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-2a0de4ac`]]);export{R as default};
@@ -1 +1 @@
1
- import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Vt as c,Wt as l,Z as u,b as d,k as f,tt as p,ut as m}from"./vendor-chart-BJCvKk8-.js";import{t as h}from"./button-BydTr5nV.js";import{t as g}from"./upload-D0e0nt-T.js";import{t as _}from"./image-C1rOF43l.js";import{t as v}from"./alert-CuX4SjQB.js";import{n as y,r as b}from"./radio-3Hz7h3DR.js";import{t as x}from"./switch-DWXQZz-o.js";import{t as S}from"./vendor-axios-Ck2ffRoh.js";import"./constants-DNpQuSUd.js";import{Jr as C,Lr as w,O as T,Zt as E,an as ee,ti as te,tt as D,zt as O}from"./index-DclJnQCv.js";import{t as k}from"./index.es-Dam0OO1D.js";import{t as A}from"./CopyToClipboard-BH7fpVgM.js";import{t as j}from"./BotPlaceholder-COOqE9-9.js";import{t as M}from"./Hailuo-D0TpAhjT.js";import{t as N}from"./TabSwitcher-b1dTVdoe.js";var P=4,F=90,I=r({name:`FishRecorder`,components:{ElButton:h,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`){C.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`;C.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){C.warning(this.$t(`fish.message.recordingTooShort`));return}this.uploading=!0;try{let e=this.$store.state.token?.access,t=this.extensionForMime(this.recordedBlob.type||``),n=new File([this.recordedBlob],`recording-${Date.now()}.${t}`,{type:this.recordedBlob.type||`audio/webm`}),r=new FormData;r.append(`file`,n);let{data:i}=await S.post(`${w()}/api/v1/files/`,r,{headers:{Authorization:`Bearer ${e}`}}),a=i?.file_url;if(!a){C.error(this.$t(`fish.message.uploadError`));return}this.$emit(`done`,{url:a,text:this.currentScript})}catch(e){C.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,d,h,g){let _=p(`font-awesome-icon`),v=p(`el-button`);return u(),t(`div`,L,[e.state===`recorded`?f(``,!0):(u(),t(`div`,R,[n(`div`,z,[o(_,{icon:`fa-solid fa-book-open`,class:`icon mr-1`}),n(`span`,B,l(e.$t(`fish.description.readScript`)),1),o(v,{link:``,size:`small`,class:`ml-auto`,disabled:e.state===`recording`,onClick:e.nextScript},{default:m(()=>[o(_,{icon:`fa-solid fa-shuffle`,class:`mr-1`}),i(` `+l(e.$t(`fish.button.nextScript`)),1)]),_:1},8,[`disabled`,`onClick`])]),n(`p`,V,l(e.currentScript),1)])),n(`div`,H,[e.state===`idle`?(u(),a(v,{key:0,type:`danger`,circle:``,size:`large`,title:e.$t(`fish.button.startRecord`),onClick:e.startRecord},{default:m(()=>[o(_,{icon:`fa-solid fa-microphone`})]),_:1},8,[`title`,`onClick`])):e.state===`recording`?(u(),a(v,{key:1,type:`warning`,circle:``,size:`large`,title:e.$t(`fish.button.stopRecord`),onClick:e.stopRecord},{default:m(()=>[o(_,{icon:`fa-solid fa-stop`})]),_:1},8,[`title`,`onClick`])):f(``,!0),n(`div`,U,[n(`span`,{class:c([`timer`,e.state===`recording`?`live`:``])},l(e.formattedTime),3),n(`span`,W,l(e.state===`idle`?e.$t(`fish.description.recorderIdle`):e.state===`recording`?e.$t(`fish.description.recorderRecording`):e.$t(`fish.description.recorderRecorded`)),1)])]),e.state===`recorded`&&e.recordedUrl?(u(),t(`div`,G,[n(`audio`,{src:e.recordedUrl,controls:``,preload:`metadata`,class:`w-full`},null,8,K),n(`div`,q,[o(v,{size:`small`,disabled:e.uploading,onClick:e.reset},{default:m(()=>[o(_,{icon:`fa-solid fa-rotate-left`,class:`mr-1`}),i(` `+l(e.$t(`fish.button.reRecord`)),1)]),_:1},8,[`disabled`,`onClick`]),o(v,{size:`small`,type:`primary`,loading:e.uploading,onClick:e.useRecording},{default:m(()=>[o(_,{icon:`fa-solid fa-check`,class:`mr-1`}),i(` `+l(e.$t(`fish.button.useRecording`)),1)]),_:1},8,[`loading`,`onClick`])])])):f(``,!0),n(`div`,J,[o(v,{link:``,size:`small`,disabled:e.uploading||e.state===`recording`,onClick:e.onCancel},{default:m(()=>[i(l(e.$t(`fish.button.cancel`)),1)]),_:1},8,[`disabled`,`onClick`])])])}var X=T(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:h,ElInput:te,ElRadioButton:y,ElRadioGroup:b,ElSwitch:x,ElUpload:g,FontAwesomeIcon:k,Recorder:X},mixins:[O],emits:[`create`],data(){return{form:Q(),fileList:[],uploading:!1,creating:!1,recording:!1,textsAuto:!0}},computed:{uploadUrl(){return w()+`/api/v1/files/`},uploadHeaders(){return{Authorization:`Bearer ${this.$store.state.token?.access}`}},canCreate(){return!!this.form.title.trim()&&!!this.form.voicesUrl&&!this.uploading&&!this.creating},supportsRecorder(){return!!(typeof navigator<`u`?navigator.mediaDevices:void 0)?.getUserMedia&&typeof MediaRecorder<`u`}},methods:{onBeforeUpload(e){return e.size>Z?(C.warning(this.$t(`fish.message.audioSizeExceed`)),!1):(this.uploading=!0,!0)},onExceed(){C.warning(this.$t(`fish.message.audioOnlyOne`))},onUploadError(){this.uploading=!1,C.error(this.$t(`fish.message.uploadError`))},onUploadSuccess(e,t,n){this.uploading=!1;let r=e?.file_url;if(!r){C.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){C.warning(this.$t(`fish.message.titleRequired`));return}if(!this.form.voicesUrl){C.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,c,d,h){let g=p(`el-input`),_=p(`font-awesome-icon`),v=p(`el-button`),y=p(`el-upload`),b=p(`recorder`),x=p(`el-radio-button`),S=p(`el-radio-group`),C=p(`el-switch`);return u(),t(`div`,re,[n(`div`,ie,[n(`div`,ae,[n(`h2`,oe,[i(l(e.$t(`fish.name.voiceTitle`))+` `,1),r[9]||=n(`span`,{class:`required`},`*`,-1)]),o(g,{modelValue:e.form.title,"onUpdate:modelValue":r[0]||=t=>e.form.title=t,placeholder:e.$t(`fish.placeholder.voiceTitle`),maxlength:`60`},null,8,[`modelValue`,`placeholder`])]),n(`div`,se,[n(`div`,ce,[n(`h2`,le,[i(l(e.$t(`fish.name.referenceAudio`))+` `,1),r[10]||=n(`span`,{class:`required`},`*`,-1)]),!e.form.voicesUrl&&!e.recording?(u(),t(`span`,ue,l(e.$t(`fish.description.audioRequired`)),1)):f(``,!0)]),n(`p`,de,l(e.$t(`fish.description.uploadAudio`)),1),!e.form.voicesUrl&&!e.recording?(u(),t(`div`,fe,[o(y,{"file-list":e.fileList,"onUpdate:fileList":r[1]||=t=>e.fileList=t,name:`file`,limit:1,class:`upload-wrapper`,action:e.uploadUrl,accept:`.mp3,.wav,.m4a,.ogg,.webm,audio/*`,"show-file-list":!1,"on-exceed":e.onExceed,"on-error":e.onUploadError,"on-success":e.onUploadSuccess,"before-upload":e.onBeforeUpload,headers:e.uploadHeaders},{default:m(()=>[o(v,{type:`primary`,plain:``,round:``,loading:e.uploading},{default:m(()=>[o(_,{icon:`fa-solid fa-upload`,class:`icon mr-1`}),i(` `+l(e.$t(`fish.button.uploadAudio`)),1)]),_:1},8,[`loading`])]),_:1},8,[`file-list`,`action`,`on-exceed`,`on-error`,`on-success`,`before-upload`,`headers`]),o(v,{type:`primary`,round:``,disabled:!e.supportsRecorder,onClick:e.onStartRecord},{default:m(()=>[o(_,{icon:`fa-solid fa-microphone`,class:`icon mr-1`}),i(` `+l(e.$t(`fish.button.recordAudio`)),1)]),_:1},8,[`disabled`,`onClick`])])):f(``,!0),!e.supportsRecorder&&!e.form.voicesUrl&&!e.recording?(u(),t(`p`,pe,l(e.$t(`fish.message.recorderUnsupported`)),1)):f(``,!0),e.recording?(u(),a(b,{key:2,class:`mt-2`,onDone:e.onRecorded,onCancel:r[2]||=t=>e.recording=!1,"onUpdate:script":e.onScriptChange},null,8,[`onDone`,`onUpdate:script`])):f(``,!0),e.form.voicesUrl&&!e.recording?(u(),t(`div`,me,[n(`audio`,{src:e.form.voicesUrl,controls:``,preload:`metadata`,class:`w-full`},null,8,he),n(`div`,ge,[o(v,{link:``,size:`small`,onClick:e.clearAudio},{default:m(()=>[o(_,{icon:`fa-solid fa-rotate-left`,class:`mr-1`}),i(` `+l(e.$t(`fish.button.replaceAudio`)),1)]),_:1},8,[`onClick`])])])):f(``,!0)]),n(`div`,_e,[n(`h2`,ve,l(e.$t(`fish.name.audioTexts`)),1),n(`p`,ye,l(e.$t(`fish.description.audioTexts`)),1),o(g,{modelValue:e.form.texts,"onUpdate:modelValue":r[3]||=t=>e.form.texts=t,type:`textarea`,rows:2,placeholder:e.$t(`fish.placeholder.audioTexts`),maxlength:`500`,onInput:e.onTextsInput},null,8,[`modelValue`,`placeholder`,`onInput`])]),n(`div`,be,[n(`h2`,xe,l(e.$t(`fish.name.voiceDescription`)),1),o(g,{modelValue:e.form.description,"onUpdate:modelValue":r[4]||=t=>e.form.description=t,type:`textarea`,rows:2,placeholder:e.$t(`fish.placeholder.voiceDescription`),maxlength:`500`},null,8,[`modelValue`,`placeholder`])]),n(`div`,Se,[n(`h2`,Ce,l(e.$t(`fish.name.visibility`)),1),o(S,{modelValue:e.form.visibility,"onUpdate:modelValue":r[5]||=t=>e.form.visibility=t,size:`small`},{default:m(()=>[o(x,{label:`private`,value:`private`},{default:m(()=>[i(l(e.$t(`fish.value.private`)),1)]),_:1}),o(x,{label:`unlist`,value:`unlist`},{default:m(()=>[i(l(e.$t(`fish.value.unlist`)),1)]),_:1}),o(x,{label:`public`,value:`public`},{default:m(()=>[i(l(e.$t(`fish.value.public`)),1)]),_:1})]),_:1},8,[`modelValue`])]),n(`div`,we,[n(`h2`,Te,l(e.$t(`fish.name.trainMode`)),1),o(S,{modelValue:e.form.trainMode,"onUpdate:modelValue":r[6]||=t=>e.form.trainMode=t,size:`small`},{default:m(()=>[o(x,{label:`fast`,value:`fast`},{default:m(()=>[i(l(e.$t(`fish.value.trainModeFast`)),1)]),_:1}),o(x,{label:`precise`,value:`precise`},{default:m(()=>[i(l(e.$t(`fish.value.trainModePrecise`)),1)]),_:1})]),_:1},8,[`modelValue`])]),n(`div`,Ee,[n(`div`,De,[n(`h2`,Oe,l(e.$t(`fish.name.enhanceAudio`)),1),o(C,{modelValue:e.form.enhanceAudio,"onUpdate:modelValue":r[7]||=t=>e.form.enhanceAudio=t},null,8,[`modelValue`])]),n(`p`,ke,l(e.$t(`fish.description.enhanceAudio`)),1)]),n(`div`,Ae,[n(`div`,je,[n(`h2`,Me,l(e.$t(`fish.name.generateSample`)),1),o(C,{modelValue:e.form.generateSample,"onUpdate:modelValue":r[8]||=t=>e.form.generateSample=t},null,8,[`modelValue`])]),n(`p`,Ne,l(e.$t(`fish.description.generateSample`)),1)])]),n(`div`,Pe,[o(v,{type:`primary`,class:`btn w-full`,round:``,disabled:!e.canCreate||e.creating,loading:e.creating,onClick:e.onCreate},{default:m(()=>[o(_,{icon:`fa-solid fa-magic`,class:`mr-2`}),i(` `+l(e.$t(`fish.button.createModel`)),1)]),_:1},8,[`disabled`,`loading`,`onClick`])])])}var Ie=T(ne,[[`render`,Fe],[`__scopeId`,`data-v-d8fc0e55`]]),Le=r({name:`FishVoiceCard`,components:{ElAlert:v,ElButton:h,ElImage:_,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:D}))}}}),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,c,h,g){let _=p(`el-image`),v=p(`font-awesome-icon`),y=p(`copy-to-clipboard`),b=p(`el-alert`),x=p(`el-button`);return u(),t(`div`,Re,[n(`div`,ze,[e.coverSrc?(u(),a(_,{key:0,src:e.coverSrc,class:`cover`,fit:`cover`},{error:m(()=>[o(_,{src:`https://cdn.acedata.cloud/e40fccc727.png`,class:`cover fallback`,fit:`cover`})]),placeholder:m(()=>[...r[0]||=[n(`div`,{class:`cover placeholder`},null,-1)]]),_:1},8,[`src`])):(u(),a(_,{key:1,src:`https://cdn.acedata.cloud/e40fccc727.png`,class:`cover fallback`,fit:`cover`}))]),n(`div`,Be,[n(`div`,Ve,[n(`span`,He,l(e.modelValue?.title||e.$t(`fish.name.untitledVoice`)),1),e.createdAtLabel?(u(),t(`span`,Ue,l(e.createdAtLabel),1)):f(``,!0)]),e.modelValue?.description?(u(),t(`p`,We,l(e.modelValue?.description),1)):f(``,!0),e.sampleAudioUrl?(u(),t(`div`,Ge,[n(`audio`,{src:e.sampleAudioUrl,controls:``,preload:`metadata`,class:`w-full`},null,8,Ke)])):f(``,!0),o(b,{closable:!1,class:`mt-2 success`},{default:m(()=>[e.voiceId?(u(),t(`p`,qe,[o(v,{icon:`fa-solid fa-microphone`,class:`mr-1`}),i(` `+l(e.$t(`fish.name.referenceId`))+`: `+l(e.voiceId)+` `,1),o(y,{content:e.voiceId},null,8,[`content`])])):f(``,!0),e.modelValue?.visibility?(u(),t(`p`,Je,[o(v,{icon:`fa-solid fa-eye`,class:`mr-1`}),i(` `+l(e.$t(`fish.name.visibility`))+`: `+l(e.modelValue?.visibility),1)])):f(``,!0)]),_:1}),n(`div`,Ye,[o(x,{type:`primary`,size:`small`,plain:``,disabled:!e.voiceId,onClick:d(e.onUseVoice,[`stop`])},{default:m(()=>[o(v,{icon:`fa-solid fa-volume-high`,class:`mr-1`}),i(` `+l(e.$t(`fish.button.useVoice`)),1)]),_:1},8,[`disabled`,`onClick`])])])])}var Ze=r({name:`FishModelListPanel`,components:{VoiceCard:T(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,c,d,m,h){let g=p(`bot-placeholder`),_=p(`font-awesome-icon`),v=p(`voice-card`);return u(),t(`div`,Qe,[n(`header`,$e,[n(`h2`,et,l(r.$t(`fish.title.myVoices`)),1),r.voices?.length?(u(),t(`span`,tt,l(r.voices?.length),1)):f(``,!0)]),n(`div`,$,[r.voices===void 0?(u(),t(`div`,nt,[o(g)])):r.voices.length===0?(u(),t(`div`,rt,[o(_,{icon:`fa-solid fa-microphone-lines`,class:`empty-icon`}),n(`p`,it,l(r.$t(`fish.title.noVoicesYet`)),1),n(`p`,at,l(r.$t(`fish.description.noVoicesYet`)),1)])):(u(),t(`div`,ot,[(u(!0),t(s,null,e(r.voices,e=>(u(),a(v,{key:e.id,"model-value":e},null,8,[`model-value`]))),128))]))])])}var ct=r({name:`FishModelIndex`,components:{ModelConfigPanel:Ie,Layout:M,ModelListPanel:T(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(!E())return;let t=this.credential?.token;if(!t){console.error(`no token specified`);return}this.loading=!0,C.info(this.$t(`fish.message.creatingModel`));try{await ee.createModel(e,{token:t}),C.success(this.$t(`fish.message.createModelSuccess`)),await this.onGetVoices()}catch(e){let t=e?.response?.data;t?.error?.code===`used_up`?C.error(this.$t(`fish.message.usedUp`)):C.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,c){let l=p(`tab-switcher`),d=p(`model-config-panel`),f=p(`model-list-panel`),h=p(`layout`);return u(),a(h,null,{config:m(()=>[n(`div`,lt,[o(l),n(`div`,ut,[o(d,{onCreate:e.onCreate},null,8,[`onCreate`])])])]),result:m(()=>[o(f,{loading:e.loading},null,8,[`loading`])]),_:1})}var ft=T(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 c,Wt as l,Z as u,b as d,k as f,tt as p,ut as m}from"./vendor-chart-BJCvKk8-.js";import{t as h}from"./button-BydTr5nV.js";import{t as g}from"./upload-Cq_7IVD4.js";import{t as _}from"./image-D3kX4G-o.js";import{t as v}from"./alert-CuX4SjQB.js";import{n as y,r as b}from"./radio-3Hz7h3DR.js";import{t as x}from"./switch-CKGiLdIO.js";import{t as S}from"./vendor-axios-Ck2ffRoh.js";import"./constants-DNpQuSUd.js";import{Jr as C,Lr as w,O as T,Zt as E,an as ee,ti as te,tt as D,zt as O}from"./index-BvXr-3ek.js";import{t as k}from"./index.es-C7iPP9Jz.js";import{t as A}from"./CopyToClipboard-DaBIpGcq.js";import{t as j}from"./BotPlaceholder-CFCvvJUK.js";import{t as M}from"./Hailuo-DIchMDcd.js";import{t as N}from"./TabSwitcher-DMdBkoDS.js";var P=4,F=90,I=r({name:`FishRecorder`,components:{ElButton:h,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`){C.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`;C.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){C.warning(this.$t(`fish.message.recordingTooShort`));return}this.uploading=!0;try{let e=this.$store.state.token?.access,t=this.extensionForMime(this.recordedBlob.type||``),n=new File([this.recordedBlob],`recording-${Date.now()}.${t}`,{type:this.recordedBlob.type||`audio/webm`}),r=new FormData;r.append(`file`,n);let{data:i}=await S.post(`${w()}/api/v1/files/`,r,{headers:{Authorization:`Bearer ${e}`}}),a=i?.file_url;if(!a){C.error(this.$t(`fish.message.uploadError`));return}this.$emit(`done`,{url:a,text:this.currentScript})}catch(e){C.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,d,h,g){let _=p(`font-awesome-icon`),v=p(`el-button`);return u(),t(`div`,L,[e.state===`recorded`?f(``,!0):(u(),t(`div`,R,[n(`div`,z,[o(_,{icon:`fa-solid fa-book-open`,class:`icon mr-1`}),n(`span`,B,l(e.$t(`fish.description.readScript`)),1),o(v,{link:``,size:`small`,class:`ml-auto`,disabled:e.state===`recording`,onClick:e.nextScript},{default:m(()=>[o(_,{icon:`fa-solid fa-shuffle`,class:`mr-1`}),i(` `+l(e.$t(`fish.button.nextScript`)),1)]),_:1},8,[`disabled`,`onClick`])]),n(`p`,V,l(e.currentScript),1)])),n(`div`,H,[e.state===`idle`?(u(),a(v,{key:0,type:`danger`,circle:``,size:`large`,title:e.$t(`fish.button.startRecord`),onClick:e.startRecord},{default:m(()=>[o(_,{icon:`fa-solid fa-microphone`})]),_:1},8,[`title`,`onClick`])):e.state===`recording`?(u(),a(v,{key:1,type:`warning`,circle:``,size:`large`,title:e.$t(`fish.button.stopRecord`),onClick:e.stopRecord},{default:m(()=>[o(_,{icon:`fa-solid fa-stop`})]),_:1},8,[`title`,`onClick`])):f(``,!0),n(`div`,U,[n(`span`,{class:c([`timer`,e.state===`recording`?`live`:``])},l(e.formattedTime),3),n(`span`,W,l(e.state===`idle`?e.$t(`fish.description.recorderIdle`):e.state===`recording`?e.$t(`fish.description.recorderRecording`):e.$t(`fish.description.recorderRecorded`)),1)])]),e.state===`recorded`&&e.recordedUrl?(u(),t(`div`,G,[n(`audio`,{src:e.recordedUrl,controls:``,preload:`metadata`,class:`w-full`},null,8,K),n(`div`,q,[o(v,{size:`small`,disabled:e.uploading,onClick:e.reset},{default:m(()=>[o(_,{icon:`fa-solid fa-rotate-left`,class:`mr-1`}),i(` `+l(e.$t(`fish.button.reRecord`)),1)]),_:1},8,[`disabled`,`onClick`]),o(v,{size:`small`,type:`primary`,loading:e.uploading,onClick:e.useRecording},{default:m(()=>[o(_,{icon:`fa-solid fa-check`,class:`mr-1`}),i(` `+l(e.$t(`fish.button.useRecording`)),1)]),_:1},8,[`loading`,`onClick`])])])):f(``,!0),n(`div`,J,[o(v,{link:``,size:`small`,disabled:e.uploading||e.state===`recording`,onClick:e.onCancel},{default:m(()=>[i(l(e.$t(`fish.button.cancel`)),1)]),_:1},8,[`disabled`,`onClick`])])])}var X=T(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:h,ElInput:te,ElRadioButton:y,ElRadioGroup:b,ElSwitch:x,ElUpload:g,FontAwesomeIcon:k,Recorder:X},mixins:[O],emits:[`create`],data(){return{form:Q(),fileList:[],uploading:!1,creating:!1,recording:!1,textsAuto:!0}},computed:{uploadUrl(){return w()+`/api/v1/files/`},uploadHeaders(){return{Authorization:`Bearer ${this.$store.state.token?.access}`}},canCreate(){return!!this.form.title.trim()&&!!this.form.voicesUrl&&!this.uploading&&!this.creating},supportsRecorder(){return!!(typeof navigator<`u`?navigator.mediaDevices:void 0)?.getUserMedia&&typeof MediaRecorder<`u`}},methods:{onBeforeUpload(e){return e.size>Z?(C.warning(this.$t(`fish.message.audioSizeExceed`)),!1):(this.uploading=!0,!0)},onExceed(){C.warning(this.$t(`fish.message.audioOnlyOne`))},onUploadError(){this.uploading=!1,C.error(this.$t(`fish.message.uploadError`))},onUploadSuccess(e,t,n){this.uploading=!1;let r=e?.file_url;if(!r){C.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){C.warning(this.$t(`fish.message.titleRequired`));return}if(!this.form.voicesUrl){C.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,c,d,h){let g=p(`el-input`),_=p(`font-awesome-icon`),v=p(`el-button`),y=p(`el-upload`),b=p(`recorder`),x=p(`el-radio-button`),S=p(`el-radio-group`),C=p(`el-switch`);return u(),t(`div`,re,[n(`div`,ie,[n(`div`,ae,[n(`h2`,oe,[i(l(e.$t(`fish.name.voiceTitle`))+` `,1),r[9]||=n(`span`,{class:`required`},`*`,-1)]),o(g,{modelValue:e.form.title,"onUpdate:modelValue":r[0]||=t=>e.form.title=t,placeholder:e.$t(`fish.placeholder.voiceTitle`),maxlength:`60`},null,8,[`modelValue`,`placeholder`])]),n(`div`,se,[n(`div`,ce,[n(`h2`,le,[i(l(e.$t(`fish.name.referenceAudio`))+` `,1),r[10]||=n(`span`,{class:`required`},`*`,-1)]),!e.form.voicesUrl&&!e.recording?(u(),t(`span`,ue,l(e.$t(`fish.description.audioRequired`)),1)):f(``,!0)]),n(`p`,de,l(e.$t(`fish.description.uploadAudio`)),1),!e.form.voicesUrl&&!e.recording?(u(),t(`div`,fe,[o(y,{"file-list":e.fileList,"onUpdate:fileList":r[1]||=t=>e.fileList=t,name:`file`,limit:1,class:`upload-wrapper`,action:e.uploadUrl,accept:`.mp3,.wav,.m4a,.ogg,.webm,audio/*`,"show-file-list":!1,"on-exceed":e.onExceed,"on-error":e.onUploadError,"on-success":e.onUploadSuccess,"before-upload":e.onBeforeUpload,headers:e.uploadHeaders},{default:m(()=>[o(v,{type:`primary`,plain:``,round:``,loading:e.uploading},{default:m(()=>[o(_,{icon:`fa-solid fa-upload`,class:`icon mr-1`}),i(` `+l(e.$t(`fish.button.uploadAudio`)),1)]),_:1},8,[`loading`])]),_:1},8,[`file-list`,`action`,`on-exceed`,`on-error`,`on-success`,`before-upload`,`headers`]),o(v,{type:`primary`,round:``,disabled:!e.supportsRecorder,onClick:e.onStartRecord},{default:m(()=>[o(_,{icon:`fa-solid fa-microphone`,class:`icon mr-1`}),i(` `+l(e.$t(`fish.button.recordAudio`)),1)]),_:1},8,[`disabled`,`onClick`])])):f(``,!0),!e.supportsRecorder&&!e.form.voicesUrl&&!e.recording?(u(),t(`p`,pe,l(e.$t(`fish.message.recorderUnsupported`)),1)):f(``,!0),e.recording?(u(),a(b,{key:2,class:`mt-2`,onDone:e.onRecorded,onCancel:r[2]||=t=>e.recording=!1,"onUpdate:script":e.onScriptChange},null,8,[`onDone`,`onUpdate:script`])):f(``,!0),e.form.voicesUrl&&!e.recording?(u(),t(`div`,me,[n(`audio`,{src:e.form.voicesUrl,controls:``,preload:`metadata`,class:`w-full`},null,8,he),n(`div`,ge,[o(v,{link:``,size:`small`,onClick:e.clearAudio},{default:m(()=>[o(_,{icon:`fa-solid fa-rotate-left`,class:`mr-1`}),i(` `+l(e.$t(`fish.button.replaceAudio`)),1)]),_:1},8,[`onClick`])])])):f(``,!0)]),n(`div`,_e,[n(`h2`,ve,l(e.$t(`fish.name.audioTexts`)),1),n(`p`,ye,l(e.$t(`fish.description.audioTexts`)),1),o(g,{modelValue:e.form.texts,"onUpdate:modelValue":r[3]||=t=>e.form.texts=t,type:`textarea`,rows:2,placeholder:e.$t(`fish.placeholder.audioTexts`),maxlength:`500`,onInput:e.onTextsInput},null,8,[`modelValue`,`placeholder`,`onInput`])]),n(`div`,be,[n(`h2`,xe,l(e.$t(`fish.name.voiceDescription`)),1),o(g,{modelValue:e.form.description,"onUpdate:modelValue":r[4]||=t=>e.form.description=t,type:`textarea`,rows:2,placeholder:e.$t(`fish.placeholder.voiceDescription`),maxlength:`500`},null,8,[`modelValue`,`placeholder`])]),n(`div`,Se,[n(`h2`,Ce,l(e.$t(`fish.name.visibility`)),1),o(S,{modelValue:e.form.visibility,"onUpdate:modelValue":r[5]||=t=>e.form.visibility=t,size:`small`},{default:m(()=>[o(x,{label:`private`,value:`private`},{default:m(()=>[i(l(e.$t(`fish.value.private`)),1)]),_:1}),o(x,{label:`unlist`,value:`unlist`},{default:m(()=>[i(l(e.$t(`fish.value.unlist`)),1)]),_:1}),o(x,{label:`public`,value:`public`},{default:m(()=>[i(l(e.$t(`fish.value.public`)),1)]),_:1})]),_:1},8,[`modelValue`])]),n(`div`,we,[n(`h2`,Te,l(e.$t(`fish.name.trainMode`)),1),o(S,{modelValue:e.form.trainMode,"onUpdate:modelValue":r[6]||=t=>e.form.trainMode=t,size:`small`},{default:m(()=>[o(x,{label:`fast`,value:`fast`},{default:m(()=>[i(l(e.$t(`fish.value.trainModeFast`)),1)]),_:1}),o(x,{label:`precise`,value:`precise`},{default:m(()=>[i(l(e.$t(`fish.value.trainModePrecise`)),1)]),_:1})]),_:1},8,[`modelValue`])]),n(`div`,Ee,[n(`div`,De,[n(`h2`,Oe,l(e.$t(`fish.name.enhanceAudio`)),1),o(C,{modelValue:e.form.enhanceAudio,"onUpdate:modelValue":r[7]||=t=>e.form.enhanceAudio=t},null,8,[`modelValue`])]),n(`p`,ke,l(e.$t(`fish.description.enhanceAudio`)),1)]),n(`div`,Ae,[n(`div`,je,[n(`h2`,Me,l(e.$t(`fish.name.generateSample`)),1),o(C,{modelValue:e.form.generateSample,"onUpdate:modelValue":r[8]||=t=>e.form.generateSample=t},null,8,[`modelValue`])]),n(`p`,Ne,l(e.$t(`fish.description.generateSample`)),1)])]),n(`div`,Pe,[o(v,{type:`primary`,class:`btn w-full`,round:``,disabled:!e.canCreate||e.creating,loading:e.creating,onClick:e.onCreate},{default:m(()=>[o(_,{icon:`fa-solid fa-magic`,class:`mr-2`}),i(` `+l(e.$t(`fish.button.createModel`)),1)]),_:1},8,[`disabled`,`loading`,`onClick`])])])}var Ie=T(ne,[[`render`,Fe],[`__scopeId`,`data-v-d8fc0e55`]]),Le=r({name:`FishVoiceCard`,components:{ElAlert:v,ElButton:h,ElImage:_,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:D}))}}}),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,c,h,g){let _=p(`el-image`),v=p(`font-awesome-icon`),y=p(`copy-to-clipboard`),b=p(`el-alert`),x=p(`el-button`);return u(),t(`div`,Re,[n(`div`,ze,[e.coverSrc?(u(),a(_,{key:0,src:e.coverSrc,class:`cover`,fit:`cover`},{error:m(()=>[o(_,{src:`https://cdn.acedata.cloud/e40fccc727.png`,class:`cover fallback`,fit:`cover`})]),placeholder:m(()=>[...r[0]||=[n(`div`,{class:`cover placeholder`},null,-1)]]),_:1},8,[`src`])):(u(),a(_,{key:1,src:`https://cdn.acedata.cloud/e40fccc727.png`,class:`cover fallback`,fit:`cover`}))]),n(`div`,Be,[n(`div`,Ve,[n(`span`,He,l(e.modelValue?.title||e.$t(`fish.name.untitledVoice`)),1),e.createdAtLabel?(u(),t(`span`,Ue,l(e.createdAtLabel),1)):f(``,!0)]),e.modelValue?.description?(u(),t(`p`,We,l(e.modelValue?.description),1)):f(``,!0),e.sampleAudioUrl?(u(),t(`div`,Ge,[n(`audio`,{src:e.sampleAudioUrl,controls:``,preload:`metadata`,class:`w-full`},null,8,Ke)])):f(``,!0),o(b,{closable:!1,class:`mt-2 success`},{default:m(()=>[e.voiceId?(u(),t(`p`,qe,[o(v,{icon:`fa-solid fa-microphone`,class:`mr-1`}),i(` `+l(e.$t(`fish.name.referenceId`))+`: `+l(e.voiceId)+` `,1),o(y,{content:e.voiceId},null,8,[`content`])])):f(``,!0),e.modelValue?.visibility?(u(),t(`p`,Je,[o(v,{icon:`fa-solid fa-eye`,class:`mr-1`}),i(` `+l(e.$t(`fish.name.visibility`))+`: `+l(e.modelValue?.visibility),1)])):f(``,!0)]),_:1}),n(`div`,Ye,[o(x,{type:`primary`,size:`small`,plain:``,disabled:!e.voiceId,onClick:d(e.onUseVoice,[`stop`])},{default:m(()=>[o(v,{icon:`fa-solid fa-volume-high`,class:`mr-1`}),i(` `+l(e.$t(`fish.button.useVoice`)),1)]),_:1},8,[`disabled`,`onClick`])])])])}var Ze=r({name:`FishModelListPanel`,components:{VoiceCard:T(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,c,d,m,h){let g=p(`bot-placeholder`),_=p(`font-awesome-icon`),v=p(`voice-card`);return u(),t(`div`,Qe,[n(`header`,$e,[n(`h2`,et,l(r.$t(`fish.title.myVoices`)),1),r.voices?.length?(u(),t(`span`,tt,l(r.voices?.length),1)):f(``,!0)]),n(`div`,$,[r.voices===void 0?(u(),t(`div`,nt,[o(g)])):r.voices.length===0?(u(),t(`div`,rt,[o(_,{icon:`fa-solid fa-microphone-lines`,class:`empty-icon`}),n(`p`,it,l(r.$t(`fish.title.noVoicesYet`)),1),n(`p`,at,l(r.$t(`fish.description.noVoicesYet`)),1)])):(u(),t(`div`,ot,[(u(!0),t(s,null,e(r.voices,e=>(u(),a(v,{key:e.id,"model-value":e},null,8,[`model-value`]))),128))]))])])}var ct=r({name:`FishModelIndex`,components:{ModelConfigPanel:Ie,Layout:M,ModelListPanel:T(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(!E())return;let t=this.credential?.token;if(!t){console.error(`no token specified`);return}this.loading=!0,C.info(this.$t(`fish.message.creatingModel`));try{await ee.createModel(e,{token:t}),C.success(this.$t(`fish.message.createModelSuccess`)),await this.onGetVoices()}catch(e){let t=e?.response?.data;t?.error?.code===`used_up`?C.error(this.$t(`fish.message.usedUp`)):C.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,c){let l=p(`tab-switcher`),d=p(`model-config-panel`),f=p(`model-list-panel`),h=p(`layout`);return u(),a(h,null,{config:m(()=>[n(`div`,lt,[o(l),n(`div`,ut,[o(d,{onCreate:e.onCreate},null,8,[`onCreate`])])])]),result:m(()=>[o(f,{loading:e.loading},null,8,[`loading`])]),_:1})}var ft=T(ct,[[`render`,dt]]);export{ft as default};