@acedatacloud/nexior 3.313.1 → 3.313.3

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 (156) hide show
  1. package/dist/assets/{ApiCodeButton-CEvOQHRz.js → ApiCodeButton-BGCm2wlR.js} +1 -1
  2. package/dist/assets/{AskUserQuestionCard-BxvFdVSB.js → AskUserQuestionCard-BX896Wnf.js} +1 -1
  3. package/dist/assets/{Auth-BRa3_Ndw.js → Auth-BwuAQtW-.js} +1 -1
  4. package/dist/assets/{Bare-CDJwDpyj.js → Bare-BRoQubq-.js} +1 -1
  5. package/dist/assets/{BotPlaceholder-CueTGOF1.js → BotPlaceholder-BvTX-Ru2.js} +1 -1
  6. package/dist/assets/{BottomFooter-D0N_yZOc.js → BottomFooter-BHkgwVAg.js} +1 -1
  7. package/dist/assets/{Callback-CxWep0Pj.js → Callback-DBy4Efp_.js} +1 -1
  8. package/dist/assets/{CodeSnippet-C_wxCqnR.js → CodeSnippet-DAEGiqx4.js} +1 -1
  9. package/dist/assets/{Console-DOGC4exX.js → Console-uXOYNynX.js} +1 -1
  10. package/dist/assets/{Consumption-C9jb4ANC.js → Consumption-CI0ROIIx.js} +1 -1
  11. package/dist/assets/{Conversation-BmtMW9eb.js → Conversation-BaEVBpv-.js} +1 -1
  12. package/dist/assets/{CopyToClipboard-DFQ4IOLO.js → CopyToClipboard-CEWQPJuY.js} +1 -1
  13. package/dist/assets/{Detail-Bhstbq2O.js → Detail-tci_B9IT.js} +2 -2
  14. package/dist/assets/{Extra-Cwn1wFSK.js → Extra-Cl5aMwhm.js} +1 -1
  15. package/dist/assets/{FilePreview-DqQ_7x8i.js → FilePreview-DOf6wxL_.js} +1 -1
  16. package/dist/assets/{Hailuo-DJn5sNFj.js → Hailuo-0VSVVSCD.js} +1 -1
  17. package/dist/assets/{History-B8CstfSz.js → History-DfxhqQIh.js} +1 -1
  18. package/dist/assets/{ImagePreview-w1XgTsO0.js → ImagePreview-Dr6no3BJ.js} +1 -1
  19. package/dist/assets/{ImageWrapper-CkAQcRG3.js → ImageWrapper-Cfio68wJ.js} +1 -1
  20. package/dist/assets/{Index-BEvvaStY.js → Index-8nr3T6eN.js} +1 -1
  21. package/dist/assets/{Index-BFSZofI0.js → Index-B7h2Txy6.js} +1 -1
  22. package/dist/assets/{Index-DDh4P0hu.js → Index-B8qVwANo.js} +1 -1
  23. package/dist/assets/{Index-DV1qzkDU.js → Index-BUCGReWa.js} +1 -1
  24. package/dist/assets/{Index-iH5rZ7cg.js → Index-BZXYL9EB.js} +1 -1
  25. package/dist/assets/{Index-DKKr2G2K.js → Index-Ba6xecgX.js} +1 -1
  26. package/dist/assets/{Index-XnfkGNiv.js → Index-ByIpzIqw.js} +1 -1
  27. package/dist/assets/{Index-DDNnjve1.js → Index-BzSH4pCw.js} +1 -1
  28. package/dist/assets/{Index-BqvWnuD7.js → Index-C-a28sma.js} +1 -1
  29. package/dist/assets/{Index-C6uVkVgl.js → Index-C3l0aOey.js} +1 -1
  30. package/dist/assets/{Index-DH7aubPC.js → Index-C8WkNBFW.js} +1 -1
  31. package/dist/assets/{Index-D-CXE2JI.js → Index-CA8bHQK_.js} +1 -1
  32. package/dist/assets/{Index-Csdi9MWD.js → Index-CW2qYhPw.js} +1 -1
  33. package/dist/assets/{Index-CMWh86tb.js → Index-ClgWfLFU.js} +1 -1
  34. package/dist/assets/{Index-CJVpYRtI.js → Index-Cs-Z6QGI.js} +1 -1
  35. package/dist/assets/{Index-BHuDmvJP.js → Index-CxdOK89E.js} +1 -1
  36. package/dist/assets/{Index-BGKoIT_N.js → Index-DGhEbsCw.js} +1 -1
  37. package/dist/assets/{Index-DY5kmWcT.js → Index-DcbtSa-g.js} +1 -1
  38. package/dist/assets/{Index-ac-iq0lM.js → Index-DggCSAAZ.js} +1 -1
  39. package/dist/assets/{Index-JDoAV7wM.js → Index-Dv0EN5H6.js} +1 -1
  40. package/dist/assets/{Index-z-5fzqdW.js → Index-Mjsf13Xh.js} +1 -1
  41. package/dist/assets/{Index-BChOhIaH.js → Index-VA8oxXvS.js} +1 -1
  42. package/dist/assets/{Index-Zo1cOM3j.js → Index-dQ6jo-pB.js} +1 -1
  43. package/dist/assets/{Index-BFv5bkgw.js → Index-fLHhqWRH.js} +1 -1
  44. package/dist/assets/{Index-WPUwDvyn.js → Index-fpwAjFAN.js} +1 -1
  45. package/dist/assets/{Index-DxGRjDmp.js → Index-u9eTLTQF.js} +1 -1
  46. package/dist/assets/{Index-DX-lokWk.js → Index-wOSjG4ww.js} +1 -1
  47. package/dist/assets/{Index-BxSFMSkV.js → Index-ww7K9Ytd.js} +1 -1
  48. package/dist/assets/{Invitees-Q2Okncil.js → Invitees-Cpn0Q6zg.js} +1 -1
  49. package/dist/assets/{List-B8Ywypg_.js → List-BDRTbz-J.js} +1 -1
  50. package/dist/assets/{List-DtE5e4mS.js → List-CwIq7Xfh.js} +1 -1
  51. package/dist/assets/{List-DOP3Ye_j.js → List-Dir6_gw2.js} +1 -1
  52. package/dist/assets/LocalTools-BFxubxLK.css +1 -0
  53. package/dist/assets/{LocalTools-mGrnqaTl.js → LocalTools-C_JjmGxA.js} +1 -1
  54. package/dist/assets/LocalTools-DJGvXvcR.js +5 -0
  55. package/dist/assets/{Main-KhcvZDzn.js → Main-ZAMTyb4j.js} +1 -1
  56. package/dist/assets/{Model-Dofi_qI7.js → Model-BU9HX-Fh.js} +1 -1
  57. package/dist/assets/{Navigator-BQUbRnUn.js → Navigator-BJ5QRqKH.js} +1 -1
  58. package/dist/assets/{NoTasks-BLkIrpVk.js → NoTasks-Vj6eSGEt.js} +1 -1
  59. package/dist/assets/{NotFound-CZPNb-Rn.js → NotFound-BMYMGYyS.js} +1 -1
  60. package/dist/assets/{Pagination-D4ah8KTk.js → Pagination-Ckg-WbT7.js} +1 -1
  61. package/dist/assets/{Pay-DmmE_AUz.js → Pay-B0mlP6q2.js} +1 -1
  62. package/dist/assets/{Player-DtD0zzj9.js → Player-CsQ8ZQ_Q.js} +1 -1
  63. package/dist/assets/{PromptTextarea-DfG4xE4f.js → PromptTextarea-B86MQemy.js} +1 -1
  64. package/dist/assets/{RealtimeCall-5Xeh91pf.js → RealtimeCall-OeRSAF1I.js} +1 -1
  65. package/dist/assets/{ScheduledTasks-qPoYpFA9.js → ScheduledTasks-Dp7NK5zS.js} +1 -1
  66. package/dist/assets/{Status-CYJT4HgG.js → Status-BnQWhq_x.js} +1 -1
  67. package/dist/assets/{Subscribe-CuLpSStU.js → Subscribe-DT2BeQhz.js} +1 -1
  68. package/dist/assets/{TabSwitcher-BuwIJ1Nn.js → TabSwitcher-CO9PBuXo.js} +1 -1
  69. package/dist/assets/{Tts-B8XidMnu.js → Tts-UgDnaqte.js} +1 -1
  70. package/dist/assets/{VideoPlayer-CtxypgMD.js → VideoPlayer-CPUlsR7F.js} +1 -1
  71. package/dist/assets/{avatar-gzGrySh5.js → avatar-D1g_RnrP.js} +1 -1
  72. package/dist/assets/{basic-D665Q-Gy.js → basic-DvMcazuE.js} +1 -1
  73. package/dist/assets/{chat-DTpJs5ed.js → chat-D11DI3_7.js} +1 -1
  74. package/dist/assets/{codingBridge-lqnxD50z.js → codingBridge-C-a66RAz.js} +1 -1
  75. package/dist/assets/{codingBridgeNotify-DZo-jMnY.js → codingBridgeNotify-DwOx-1U-.js} +2 -2
  76. package/dist/assets/{collapse-B2Fz2b5O.js → collapse-tXxSOCxC.js} +1 -1
  77. package/dist/assets/{common-D2GQvNx-.js → common-B-w67biO.js} +1 -1
  78. package/dist/assets/{common-Dr8aKoJ-.js → common-B08mVyxn.js} +1 -1
  79. package/dist/assets/{common-CuBLNcry.js → common-BAFH2-m4.js} +1 -1
  80. package/dist/assets/{common-BpGhCuYa.js → common-BNyR3rCj.js} +1 -1
  81. package/dist/assets/{common-hcq4gGOK.js → common-C8NY5J1Z.js} +1 -1
  82. package/dist/assets/{common-DSUUR3Lv.js → common-CDOUtiHf.js} +1 -1
  83. package/dist/assets/{common-Ba0ujzmQ.js → common-CP7LPuqz.js} +1 -1
  84. package/dist/assets/{common-QkFyXDOr.js → common-CWXQH23z.js} +1 -1
  85. package/dist/assets/{common-CTtjBj4V.js → common-CYgzVjs7.js} +1 -1
  86. package/dist/assets/{common-Z7XArQ0m.js → common-CzHp6GQX.js} +1 -1
  87. package/dist/assets/{common-CQCAX3SY.js → common-D0hNu9Ub.js} +1 -1
  88. package/dist/assets/{common-JPO0c_sf.js → common-DE5DnvsB.js} +1 -1
  89. package/dist/assets/{common-BHXwTdST.js → common-DnV7l9fS.js} +1 -1
  90. package/dist/assets/{common-D34s7EFR.js → common-EJMgSC_m.js} +1 -1
  91. package/dist/assets/{common-C9sRa8rn.js → common-WyH_3xQA.js} +1 -1
  92. package/dist/assets/{common-C1NmBISH.js → common-Y8crsEb9.js} +1 -1
  93. package/dist/assets/{common-D2dTC8VD.js → common-ZAfOirdv.js} +1 -1
  94. package/dist/assets/{common-BJBYLgTk.js → common-dkjmh7HO.js} +1 -1
  95. package/dist/assets/{constants-D5XSekB2.js → constants-DReNd4Tz.js} +1 -1
  96. package/dist/assets/{createTaskActions-PY8zizvc.js → createTaskActions-DSvU3Cds.js} +1 -1
  97. package/dist/assets/{date-picker-DBPTKu3y.js → date-picker-Bquja1iq.js} +1 -1
  98. package/dist/assets/{digitalhuman-BucOjmu9.js → digitalhuman-CFfLFh2S.js} +1 -1
  99. package/dist/assets/{dropdown-B2u9D46C.js → dropdown-BnFPi240.js} +1 -1
  100. package/dist/assets/{esm-Ci4Q2SqN.js → esm-B_CmVdq9.js} +2 -2
  101. package/dist/assets/{esm-DFO9EBA0.js → esm-CC-JMdI5.js} +1 -1
  102. package/dist/assets/esm-CGH0CYve.js +1 -0
  103. package/dist/assets/{esm-CZczpmQe.js → esm-CNPZAOOP.js} +2 -2
  104. package/dist/assets/{esm-CpnzQK_s.js → esm-COQIXnQq.js} +1 -1
  105. package/dist/assets/{esm-D01tIOQY.js → esm-DE4JgYMY.js} +1 -1
  106. package/dist/assets/{esm-Dv-DfVZ6.js → esm-R21U-8Oa.js} +3 -3
  107. package/dist/assets/{fish-CZRn2ZeS.js → fish-DgCW2-4G.js} +1 -1
  108. package/dist/assets/{flux-9wgjjYmQ.js → flux-B1w_zXrB.js} +1 -1
  109. package/dist/assets/{grokvideo-5yJ01cRe.js → grokvideo-CDdi4hGw.js} +1 -1
  110. package/dist/assets/{hailuo-BBMgurzN.js → hailuo-DI7_AmYm.js} +1 -1
  111. package/dist/assets/{headshots-DiyT4ABu.js → headshots-BSf2jOjT.js} +1 -1
  112. package/dist/assets/{image-98SuLK5-.js → image-DP8UKkgf.js} +1 -1
  113. package/dist/assets/{index-BRkE9zIu.js → index-DYe3FRur.js} +4 -4
  114. package/dist/assets/{index.browser.esm-nNPVxpKu.js → index.browser.esm-CKSRNK_j.js} +1 -1
  115. package/dist/assets/{index.es-Dw0M6NcN.js → index.es-oA5jw_nk.js} +1 -1
  116. package/dist/assets/{input-number-B6BEZroj.js → input-number-Ds_7_DBB.js} +1 -1
  117. package/dist/assets/{kling-B2UPKJRT.js → kling-amRA_ak0.js} +1 -1
  118. package/dist/assets/{luma-C1nfY31E.js → luma-_d2C4T5-.js} +1 -1
  119. package/dist/assets/{maestro-CE99fPd6.js → maestro-DHoqveeB.js} +1 -1
  120. package/dist/assets/{midjourney-BEV_ALiB.js → midjourney-CWkvIh0W.js} +1 -1
  121. package/dist/assets/{nanobanana-CT8saHNk.js → nanobanana-CMmodNSj.js} +1 -1
  122. package/dist/assets/{openaiimage-BMKHDGCd.js → openaiimage-BnLGZWQT.js} +1 -1
  123. package/dist/assets/{pagination-B_40M0as.js → pagination-6kGyrmE2.js} +1 -1
  124. package/dist/assets/{pika-B0tWhW4z.js → pika-x8J3nPjj.js} +1 -1
  125. package/dist/assets/{pixverse-BhV5GD1D.js → pixverse-B5P8mueB.js} +1 -1
  126. package/dist/assets/{popover-BlzhA1VF.js → popover-CnQxug8F.js} +1 -1
  127. package/dist/assets/{producer-DL3XVEV-.js → producer-DI2CyMWF.js} +1 -1
  128. package/dist/assets/{qrart-Div2AiaA.js → qrart-CwgUsvEu.js} +1 -1
  129. package/dist/assets/{realtime-DiS-xQeP.js → realtime-BrNKBHuO.js} +1 -1
  130. package/dist/assets/{row-CCJteoSt.js → row-DB_nIy3Z.js} +1 -1
  131. package/dist/assets/{seedance-BxcA2f-M.js → seedance-BhoC6ulW.js} +1 -1
  132. package/dist/assets/{seedream-Dt0Wx8ht.js → seedream-DuuO5N4c.js} +1 -1
  133. package/dist/assets/{select-D3xXGtAg.js → select-CQ-1vGEP.js} +1 -1
  134. package/dist/assets/{serp-ByOfLcMN.js → serp-y8_GvqfN.js} +1 -1
  135. package/dist/assets/{slider-5CrpaEzT.js → slider-JdGhpeaV.js} +1 -1
  136. package/dist/assets/{solana-wallets-Cx2quCoU.js → solana-wallets-D2tIx-6Q.js} +2 -2
  137. package/dist/assets/{solana-wallets-vue--bf0uOPz.js → solana-wallets-vue-CQHQmIP-.js} +1 -1
  138. package/dist/assets/{sora-Dko4b_sU.js → sora-C1cJNVUL.js} +1 -1
  139. package/dist/assets/{suno-BMufH5NY.js → suno-DceslfhW.js} +1 -1
  140. package/dist/assets/{switch-BKuYGnPZ.js → switch-BYCNj-tS.js} +1 -1
  141. package/dist/assets/{tabs-CEBj_wbA.js → tabs-BjUHRih9.js} +1 -1
  142. package/dist/assets/{time-picker-AcysMiLn.js → time-picker-CFVy3dBc.js} +1 -1
  143. package/dist/assets/{upload-izq5b45N.js → upload-DVDT-Mym.js} +1 -1
  144. package/dist/assets/{veo-CHzp-X_S.js → veo-DdykJZkd.js} +1 -1
  145. package/dist/assets/{wan-ClDR7EGp.js → wan-BqG2UV0O.js} +1 -1
  146. package/dist/assets/{web-KWfGXG39.js → web-72cvTSYk.js} +1 -1
  147. package/dist/assets/{web-BFunJxNw.js → web-BPFKwOLL.js} +1 -1
  148. package/dist/assets/{web-BNpqdAeV.js → web-C7Su7gyX.js} +1 -1
  149. package/dist/assets/{web-BbF5rPKO.js → web-DcFIYral.js} +1 -1
  150. package/dist/assets/{web-CZPpr5bV.js → web-GL2XQy5H.js} +1 -1
  151. package/dist/assets/{webextrator-ukRP9ntW.js → webextrator-DamS9lK4.js} +1 -1
  152. package/dist/index.html +2 -2
  153. package/package.json +1 -1
  154. package/dist/assets/LocalTools-Dem6wxfr.css +0 -1
  155. package/dist/assets/LocalTools-DuoRqbBP.js +0 -5
  156. package/dist/assets/esm-siwicaMB.js +0 -1
@@ -1 +1 @@
1
- import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,dt as u,k as d,nt as f,tt as p,ut as m}from"./vendor-chart-BJCvKk8-.js";import{t as h}from"./button-BydTr5nV.js";import{n as g,t as ee}from"./table-B5c9kfrJ.js";import{t as _}from"./card-DjyfNde2.js";import{n as v,t as y}from"./row-CCJteoSt.js";import{t as b}from"./empty-CdsD8g84.js";import{t as x}from"./Pagination-D4ah8KTk.js";import{t as S}from"./skeleton-BwNBivMN.js";import{t as C}from"./switch-BKuYGnPZ.js";import{o as w}from"./surface-D249_eDG.js";import{B as T,K as E,Mr as D,O,Tr as k,Wn as A,Wr as j,jr as M,wr as N,zr as P}from"./index-BRkE9zIu.js";import{t as F}from"./index.es-Dw0M6NcN.js";import{t as I}from"./CopyToClipboard-DFQ4IOLO.js";var L=r({name:`ConsoleApplicationList`,components:{Pagination:x,CopyToClipboard:I,ElTable:ee,ElRow:y,ElButton:h,ElCol:v,ElTag:j,ElSkeleton:S,ElSwitch:C,ElEmpty:b,ElTableColumn:g,ElCard:_,FontAwesomeIcon:F},data(){return{credentialType:N,serviceType:k,individualApplications:[],globalApplications:[],individualApplicationsTotal:void 0,globalApplicationsTotal:void 0,loading:!1,buying:!1,limit:10,form:{amount:1},active:{service:void 0,application:void 0}}},computed:{redirect(){return this.$route.query?.redirect},page(){return parseInt(this.$route.query.page?.toString()||`1`)},showGlobalPayment(){return!0}},watch:{page:{handler(){this.onFetchData()}}},mounted(){this.onInitializeGlobalApplication(),this.onFetchData()},methods:{rowCanPay(e){return w()?(e?.packages||[]).some(e=>e?.metadata?.apple_product_id):!0},updateAllowConsumeGlobal(e,t){!e||!e.id||A.updateAllConsumeGlobal(e.id,{...e,allow_consume_global:!!t}).then(()=>{P.success(this.$t(`application.message.updateSuccessfully`).toString())}).catch(()=>{P.error(this.$t(`application.message.updateFailed`).toString())})},onGoUsage(e){this.$router.push({name:E,query:{application_id:e.id,type:e?.service?.type}})},onBuyMore(e){e?.id&&this.$router.push({name:T,params:{id:e.id}})},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,page:e}})},onFetchApplications(e=M.INDIVIDUAL){return new Promise((t,n)=>{A.getAll({limit:this.limit,...e===M.INDIVIDUAL?{offset:(this.page-1)*this.limit}:{},user_id:this.$store.getters.user.id,ordering:`-created_at`,type:D.USAGE,scope:e}).then(({data:n})=>{e===M.INDIVIDUAL?(this.individualApplications=n.items,this.individualApplicationsTotal=n.count):(this.globalApplications=n.items,this.globalApplicationsTotal=n.count),t(n)}).catch(e=>{P.error(this.$t(`application.message.fetchFailed`).toString()),n(e)})})},onFetchData(){this.loading=!0,Promise.all([this.onFetchApplications(M.INDIVIDUAL),this.onFetchApplications(M.GLOBAL)]).then(()=>{this.loading=!1}).catch(()=>{this.loading=!1})},onInitializeGlobalApplication(){A.create({type:D.USAGE,scope:M.GLOBAL,user_id:this.$store.getters.user.id}).finally(()=>{this.onFetchApplications(M.GLOBAL)})},getRemainingAmount(e){if(e.remaining_amount===void 0||e.remaining_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.remaining_amount?.toFixed(6)} ${t}`},getUsedAmount(e){if(e.used_amount===void 0||e.used_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.used_amount?.toFixed(6)} ${t}`}}}),R={class:`title`},z={key:1,class:`summary-card`},B={class:`icon-wrapper`},V={class:`label`},H={class:`value`},U={class:`description`},W={key:1,class:`flex flex-row justify-between items-center gap-3`},G={class:`summary-card min-w-0 flex-1`},K={class:`flex justify-start items-center gap-2 mb-2 w-full`},q={class:`icon-wrapper !mb-0`},J={class:`text-[var(--el-text-color-regular)] text-[14px] truncate`},te={class:`label`},Y={class:`value`},X={class:`description`},Z={class:`flex flex-col items-end gap-2 shrink-0`},Q={class:`copy`},ne={key:0,class:`expired-at`},re={class:`flex flex-wrap items-center justify-end gap-1`},ie={class:`application-cards block sm:hidden`},ae={class:`flex items-center gap-2 flex-wrap`},oe={class:`application-card__name`},se={class:`application-card__id`},ce={class:`truncate`},le={class:`application-card__row`},ue={class:`label`},de={class:`value`},fe={key:0,class:`application-card__row`},pe={class:`label`},$={class:`value`},me={key:1,class:`application-card__row`},he={class:`label`},ge={class:`flex items-center justify-end gap-2 mt-3`},_e={class:`pagination`};function ve(r,h,g,ee,_,v){let y=p(`el-col`),b=p(`el-row`),x=p(`el-skeleton`),S=p(`font-awesome-icon`),C=p(`el-card`),w=p(`copy-to-clipboard`),T=p(`el-button`),E=p(`el-table-column`),D=p(`el-tag`),O=p(`el-switch`),k=p(`el-table`),A=p(`el-empty`),j=p(`pagination`),M=f(`loading`);return l(),a(b,{class:`application-list`},{default:m(()=>[o(y,{span:24},{default:m(()=>[o(b,null,{default:m(()=>[o(y,{span:24},{default:m(()=>[n(`h2`,R,c(r.$t(`common.title.allApplications`)),1)]),_:1})]),_:1}),o(b,{gutter:15,class:`mb-3`},{default:m(()=>[o(y,{md:12,xs:24},{default:m(()=>[o(C,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:m(()=>[r.loading?(l(),a(x,{key:0})):(l(),t(`div`,z,[n(`div`,B,[o(S,{icon:`fa-solid fa-cubes-stacked`})]),n(`p`,V,c(r.$t(`application.title.count`)),1),n(`p`,H,c(r.individualApplicationsTotal),1),n(`p`,U,c(r.$t(`application.message.countDescription`)),1)]))]),_:1})]),_:1}),r.showGlobalPayment&&r.globalApplications?.length>0?(l(),a(y,{key:0,md:12,xs:24},{default:m(()=>[o(C,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:m(()=>[r.loading?(l(),a(x,{key:0})):(l(),t(`div`,W,[n(`div`,G,[n(`div`,K,[n(`div`,q,[o(S,{icon:`fa-solid fa-wallet`})]),n(`span`,J,[i(c(r.$t(`application.field.id`))+`: `+c(r.globalApplications?.[0]?.id)+` `,1),r.globalApplications?.[0]?.id?(l(),a(w,{key:0,content:r.globalApplications?.[0]?.id,class:`inline-block`},null,8,[`content`])):d(``,!0)])]),n(`p`,te,c(r.$t(`application.title.globalBalance`)),1),n(`p`,Y,c(r.globalApplications?.[0]?.remaining_amount?.toFixed(6)||`0.000000`)+` `+c(r.$t(`service.unit.credits`)),1),n(`p`,X,c(r.$t(`application.message.globalBalanceDescription`)),1)]),n(`div`,Z,[o(T,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:h[0]||=e=>r.onGoUsage(r.globalApplications?.[0])},{default:m(()=>[o(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.usage`)),1)]),_:1}),r.showGlobalPayment?(l(),a(T,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:h[1]||=e=>r.onBuyMore(r.globalApplications?.[0])},{default:m(()=>[o(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.buyMore`)),1)]),_:1})):d(``,!0)])]))]),_:1})]),_:1})):d(``,!0)]),_:1}),o(b,null,{default:m(()=>[o(y,{span:24},{default:m(()=>[o(C,{shadow:`hover`,class:`applications-table-card hidden sm:block`},{default:m(()=>[u((l(),a(k,{data:r.individualApplications,stripe:``,class:`applications-table !min-h-[calc(100vh-420px)]`,"table-layout":`fixed`,"empty-text":r.$t(`common.message.noData`)},{default:m(()=>[o(E,{prop:`id`,label:r.$t(`application.field.id`),width:`200px`,"class-name":`text-center`},{default:m(e=>[n(`span`,null,c(e.row.id),1),n(`span`,Q,[o(w,{content:e?.row?.id,class:`inline-block`},null,8,[`content`])])]),_:1},8,[`label`]),o(E,{label:r.$t(`application.field.type`),width:`90px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[e.row?.type===`Period`?(l(),a(D,{key:0,type:`success`,effect:`dark`,round:``},{default:m(()=>[i(c(r.$t(`application.type.period`)),1)]),_:1})):e.row?.type===`Usage`?(l(),a(D,{key:1,effect:`dark`,round:``},{default:m(()=>[i(c(r.$t(`application.type.usage`)),1)]),_:1})):d(``,!0)]),_:1},8,[`label`]),o(E,{label:r.$t(`application.field.name`),width:`180px`},{default:m(e=>[n(`span`,null,c(e.row?.service?.title),1),e.row?.role===`grantee`?(l(),a(D,{key:0,type:`info`,size:`small`,round:``,class:`ml-2`},{default:m(()=>[i(c(r.$t(`application.badge.shared`)),1)]),_:1})):d(``,!0)]),_:1},8,[`label`]),o(E,{prop:`remaining_amount`,label:r.$t(`application.field.remainingAmount`),width:`150px`,"class-name":`text-center`},{default:m(e=>[n(`span`,null,c(r.getRemainingAmount(e.row)),1)]),_:1},8,[`label`]),o(E,{prop:`used_amount`,label:r.$t(`application.field.usedAmount`),width:`150px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[n(`span`,null,c(r.getUsedAmount(e.row)),1)]),_:1},8,[`label`]),o(E,{prop:`allow_consume_global`,label:r.$t(`application.field.allowConsumeGlobal`),width:`120px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[e.row.service?.type===r.serviceType.API?(l(),a(O,{key:0,modelValue:e.row.allow_consume_global,"onUpdate:modelValue":t=>e.row.allow_consume_global=t,"active-value":!0,"inactive-value":!1,onChange:t=>r.updateAllowConsumeGlobal(e.row,t)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])):d(``,!0)]),_:1},8,[`label`]),o(E,{label:r.$t(`application.field.expiredAt`),width:`180px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[e.row.expired_at?(l(),t(`span`,ne,c(r.$dayjs.format(e.row.expired_at)),1)):d(``,!0)]),_:1},8,[`label`]),o(E,{fixed:`right`,width:`200px`},{default:m(e=>[n(`div`,re,[o(T,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:t=>r.onGoUsage(e?.row)},{default:m(()=>[o(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),r.rowCanPay(e?.row)?(l(),a(T,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:t=>r.onBuyMore(e?.row)},{default:m(()=>[o(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):d(``,!0)])]),_:1})]),_:1},8,[`data`,`empty-text`])),[[M,r.loading]])]),_:1}),n(`div`,ie,[r.loading?(l(),a(x,{key:0,rows:4,animated:``})):(l(),t(s,{key:1},[r.individualApplications?.length?(l(!0),t(s,{key:1},e(r.individualApplications,e=>(l(),a(C,{key:e.id,shadow:`hover`,class:`application-card mb-2`,"body-style":{padding:`14px 16px`}},{default:m(()=>[n(`div`,ae,[n(`span`,oe,c(e?.service?.title),1),e?.type===`Period`?(l(),a(D,{key:0,type:`success`,effect:`dark`,size:`small`,round:``},{default:m(()=>[i(c(r.$t(`application.type.period`)),1)]),_:1})):e?.type===`Usage`?(l(),a(D,{key:1,effect:`dark`,size:`small`,round:``},{default:m(()=>[i(c(r.$t(`application.type.usage`)),1)]),_:1})):d(``,!0),e?.role===`grantee`?(l(),a(D,{key:2,type:`info`,size:`small`,round:``},{default:m(()=>[i(c(r.$t(`application.badge.shared`)),1)]),_:1})):d(``,!0)]),n(`div`,se,[n(`span`,ce,c(r.$t(`application.field.id`))+`: `+c(e.id),1),o(w,{content:e.id,class:`inline-block shrink-0`},null,8,[`content`])]),n(`div`,le,[n(`span`,ue,c(r.$t(`application.field.remainingAmount`)),1),n(`span`,de,c(r.getRemainingAmount(e)),1)]),e?.expired_at?(l(),t(`div`,fe,[n(`span`,pe,c(r.$t(`application.field.expiredAt`)),1),n(`span`,$,c(r.$dayjs.format(e.expired_at)),1)])):d(``,!0),e.service?.type===r.serviceType.API?(l(),t(`div`,me,[n(`span`,he,c(r.$t(`application.field.allowConsumeGlobal`)),1),o(O,{modelValue:e.allow_consume_global,"onUpdate:modelValue":t=>e.allow_consume_global=t,"active-value":!0,"inactive-value":!1,onChange:t=>r.updateAllowConsumeGlobal(e,t)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])])):d(``,!0),n(`div`,ge,[o(T,{class:`!m-0 !px-3`,size:`small`,round:``,onClick:t=>r.onGoUsage(e)},{default:m(()=>[o(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),r.rowCanPay(e)?(l(),a(T,{key:0,class:`!m-0 !px-3`,type:`primary`,round:``,size:`small`,onClick:t=>r.onBuyMore(e)},{default:m(()=>[o(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):d(``,!0)])]),_:2},1024))),128)):(l(),a(A,{key:0,description:r.$t(`common.message.noData`)},null,8,[`description`]))],64))])]),_:1})]),_:1}),o(b,null,{default:m(()=>[o(y,{span:24},{default:m(()=>[n(`div`,_e,[o(j,{"current-page":r.page,"page-size":r.limit,total:r.individualApplicationsTotal,onChange:r.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var ye=O(L,[[`render`,ve],[`__scopeId`,`data-v-b4164ed9`]]);export{ye as default};
1
+ import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,dt as u,k as d,nt as f,tt as p,ut as m}from"./vendor-chart-BJCvKk8-.js";import{t as h}from"./button-BydTr5nV.js";import{n as g,t as ee}from"./table-B5c9kfrJ.js";import{t as _}from"./card-DjyfNde2.js";import{n as v,t as y}from"./row-DB_nIy3Z.js";import{t as b}from"./empty-CdsD8g84.js";import{t as x}from"./Pagination-Ckg-WbT7.js";import{t as S}from"./skeleton-BwNBivMN.js";import{t as C}from"./switch-BYCNj-tS.js";import{o as w}from"./surface-D249_eDG.js";import{B as T,K as E,Mr as D,O,Tr as k,Wn as A,Wr as j,jr as M,wr as N,zr as P}from"./index-DYe3FRur.js";import{t as F}from"./index.es-oA5jw_nk.js";import{t as I}from"./CopyToClipboard-CEWQPJuY.js";var L=r({name:`ConsoleApplicationList`,components:{Pagination:x,CopyToClipboard:I,ElTable:ee,ElRow:y,ElButton:h,ElCol:v,ElTag:j,ElSkeleton:S,ElSwitch:C,ElEmpty:b,ElTableColumn:g,ElCard:_,FontAwesomeIcon:F},data(){return{credentialType:N,serviceType:k,individualApplications:[],globalApplications:[],individualApplicationsTotal:void 0,globalApplicationsTotal:void 0,loading:!1,buying:!1,limit:10,form:{amount:1},active:{service:void 0,application:void 0}}},computed:{redirect(){return this.$route.query?.redirect},page(){return parseInt(this.$route.query.page?.toString()||`1`)},showGlobalPayment(){return!0}},watch:{page:{handler(){this.onFetchData()}}},mounted(){this.onInitializeGlobalApplication(),this.onFetchData()},methods:{rowCanPay(e){return w()?(e?.packages||[]).some(e=>e?.metadata?.apple_product_id):!0},updateAllowConsumeGlobal(e,t){!e||!e.id||A.updateAllConsumeGlobal(e.id,{...e,allow_consume_global:!!t}).then(()=>{P.success(this.$t(`application.message.updateSuccessfully`).toString())}).catch(()=>{P.error(this.$t(`application.message.updateFailed`).toString())})},onGoUsage(e){this.$router.push({name:E,query:{application_id:e.id,type:e?.service?.type}})},onBuyMore(e){e?.id&&this.$router.push({name:T,params:{id:e.id}})},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,page:e}})},onFetchApplications(e=M.INDIVIDUAL){return new Promise((t,n)=>{A.getAll({limit:this.limit,...e===M.INDIVIDUAL?{offset:(this.page-1)*this.limit}:{},user_id:this.$store.getters.user.id,ordering:`-created_at`,type:D.USAGE,scope:e}).then(({data:n})=>{e===M.INDIVIDUAL?(this.individualApplications=n.items,this.individualApplicationsTotal=n.count):(this.globalApplications=n.items,this.globalApplicationsTotal=n.count),t(n)}).catch(e=>{P.error(this.$t(`application.message.fetchFailed`).toString()),n(e)})})},onFetchData(){this.loading=!0,Promise.all([this.onFetchApplications(M.INDIVIDUAL),this.onFetchApplications(M.GLOBAL)]).then(()=>{this.loading=!1}).catch(()=>{this.loading=!1})},onInitializeGlobalApplication(){A.create({type:D.USAGE,scope:M.GLOBAL,user_id:this.$store.getters.user.id}).finally(()=>{this.onFetchApplications(M.GLOBAL)})},getRemainingAmount(e){if(e.remaining_amount===void 0||e.remaining_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.remaining_amount?.toFixed(6)} ${t}`},getUsedAmount(e){if(e.used_amount===void 0||e.used_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.used_amount?.toFixed(6)} ${t}`}}}),R={class:`title`},z={key:1,class:`summary-card`},B={class:`icon-wrapper`},V={class:`label`},H={class:`value`},U={class:`description`},W={key:1,class:`flex flex-row justify-between items-center gap-3`},G={class:`summary-card min-w-0 flex-1`},K={class:`flex justify-start items-center gap-2 mb-2 w-full`},q={class:`icon-wrapper !mb-0`},J={class:`text-[var(--el-text-color-regular)] text-[14px] truncate`},te={class:`label`},Y={class:`value`},X={class:`description`},Z={class:`flex flex-col items-end gap-2 shrink-0`},Q={class:`copy`},ne={key:0,class:`expired-at`},re={class:`flex flex-wrap items-center justify-end gap-1`},ie={class:`application-cards block sm:hidden`},ae={class:`flex items-center gap-2 flex-wrap`},oe={class:`application-card__name`},se={class:`application-card__id`},ce={class:`truncate`},le={class:`application-card__row`},ue={class:`label`},de={class:`value`},fe={key:0,class:`application-card__row`},pe={class:`label`},$={class:`value`},me={key:1,class:`application-card__row`},he={class:`label`},ge={class:`flex items-center justify-end gap-2 mt-3`},_e={class:`pagination`};function ve(r,h,g,ee,_,v){let y=p(`el-col`),b=p(`el-row`),x=p(`el-skeleton`),S=p(`font-awesome-icon`),C=p(`el-card`),w=p(`copy-to-clipboard`),T=p(`el-button`),E=p(`el-table-column`),D=p(`el-tag`),O=p(`el-switch`),k=p(`el-table`),A=p(`el-empty`),j=p(`pagination`),M=f(`loading`);return l(),a(b,{class:`application-list`},{default:m(()=>[o(y,{span:24},{default:m(()=>[o(b,null,{default:m(()=>[o(y,{span:24},{default:m(()=>[n(`h2`,R,c(r.$t(`common.title.allApplications`)),1)]),_:1})]),_:1}),o(b,{gutter:15,class:`mb-3`},{default:m(()=>[o(y,{md:12,xs:24},{default:m(()=>[o(C,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:m(()=>[r.loading?(l(),a(x,{key:0})):(l(),t(`div`,z,[n(`div`,B,[o(S,{icon:`fa-solid fa-cubes-stacked`})]),n(`p`,V,c(r.$t(`application.title.count`)),1),n(`p`,H,c(r.individualApplicationsTotal),1),n(`p`,U,c(r.$t(`application.message.countDescription`)),1)]))]),_:1})]),_:1}),r.showGlobalPayment&&r.globalApplications?.length>0?(l(),a(y,{key:0,md:12,xs:24},{default:m(()=>[o(C,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:m(()=>[r.loading?(l(),a(x,{key:0})):(l(),t(`div`,W,[n(`div`,G,[n(`div`,K,[n(`div`,q,[o(S,{icon:`fa-solid fa-wallet`})]),n(`span`,J,[i(c(r.$t(`application.field.id`))+`: `+c(r.globalApplications?.[0]?.id)+` `,1),r.globalApplications?.[0]?.id?(l(),a(w,{key:0,content:r.globalApplications?.[0]?.id,class:`inline-block`},null,8,[`content`])):d(``,!0)])]),n(`p`,te,c(r.$t(`application.title.globalBalance`)),1),n(`p`,Y,c(r.globalApplications?.[0]?.remaining_amount?.toFixed(6)||`0.000000`)+` `+c(r.$t(`service.unit.credits`)),1),n(`p`,X,c(r.$t(`application.message.globalBalanceDescription`)),1)]),n(`div`,Z,[o(T,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:h[0]||=e=>r.onGoUsage(r.globalApplications?.[0])},{default:m(()=>[o(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.usage`)),1)]),_:1}),r.showGlobalPayment?(l(),a(T,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:h[1]||=e=>r.onBuyMore(r.globalApplications?.[0])},{default:m(()=>[o(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.buyMore`)),1)]),_:1})):d(``,!0)])]))]),_:1})]),_:1})):d(``,!0)]),_:1}),o(b,null,{default:m(()=>[o(y,{span:24},{default:m(()=>[o(C,{shadow:`hover`,class:`applications-table-card hidden sm:block`},{default:m(()=>[u((l(),a(k,{data:r.individualApplications,stripe:``,class:`applications-table !min-h-[calc(100vh-420px)]`,"table-layout":`fixed`,"empty-text":r.$t(`common.message.noData`)},{default:m(()=>[o(E,{prop:`id`,label:r.$t(`application.field.id`),width:`200px`,"class-name":`text-center`},{default:m(e=>[n(`span`,null,c(e.row.id),1),n(`span`,Q,[o(w,{content:e?.row?.id,class:`inline-block`},null,8,[`content`])])]),_:1},8,[`label`]),o(E,{label:r.$t(`application.field.type`),width:`90px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[e.row?.type===`Period`?(l(),a(D,{key:0,type:`success`,effect:`dark`,round:``},{default:m(()=>[i(c(r.$t(`application.type.period`)),1)]),_:1})):e.row?.type===`Usage`?(l(),a(D,{key:1,effect:`dark`,round:``},{default:m(()=>[i(c(r.$t(`application.type.usage`)),1)]),_:1})):d(``,!0)]),_:1},8,[`label`]),o(E,{label:r.$t(`application.field.name`),width:`180px`},{default:m(e=>[n(`span`,null,c(e.row?.service?.title),1),e.row?.role===`grantee`?(l(),a(D,{key:0,type:`info`,size:`small`,round:``,class:`ml-2`},{default:m(()=>[i(c(r.$t(`application.badge.shared`)),1)]),_:1})):d(``,!0)]),_:1},8,[`label`]),o(E,{prop:`remaining_amount`,label:r.$t(`application.field.remainingAmount`),width:`150px`,"class-name":`text-center`},{default:m(e=>[n(`span`,null,c(r.getRemainingAmount(e.row)),1)]),_:1},8,[`label`]),o(E,{prop:`used_amount`,label:r.$t(`application.field.usedAmount`),width:`150px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[n(`span`,null,c(r.getUsedAmount(e.row)),1)]),_:1},8,[`label`]),o(E,{prop:`allow_consume_global`,label:r.$t(`application.field.allowConsumeGlobal`),width:`120px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[e.row.service?.type===r.serviceType.API?(l(),a(O,{key:0,modelValue:e.row.allow_consume_global,"onUpdate:modelValue":t=>e.row.allow_consume_global=t,"active-value":!0,"inactive-value":!1,onChange:t=>r.updateAllowConsumeGlobal(e.row,t)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])):d(``,!0)]),_:1},8,[`label`]),o(E,{label:r.$t(`application.field.expiredAt`),width:`180px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[e.row.expired_at?(l(),t(`span`,ne,c(r.$dayjs.format(e.row.expired_at)),1)):d(``,!0)]),_:1},8,[`label`]),o(E,{fixed:`right`,width:`200px`},{default:m(e=>[n(`div`,re,[o(T,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:t=>r.onGoUsage(e?.row)},{default:m(()=>[o(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),r.rowCanPay(e?.row)?(l(),a(T,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:t=>r.onBuyMore(e?.row)},{default:m(()=>[o(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):d(``,!0)])]),_:1})]),_:1},8,[`data`,`empty-text`])),[[M,r.loading]])]),_:1}),n(`div`,ie,[r.loading?(l(),a(x,{key:0,rows:4,animated:``})):(l(),t(s,{key:1},[r.individualApplications?.length?(l(!0),t(s,{key:1},e(r.individualApplications,e=>(l(),a(C,{key:e.id,shadow:`hover`,class:`application-card mb-2`,"body-style":{padding:`14px 16px`}},{default:m(()=>[n(`div`,ae,[n(`span`,oe,c(e?.service?.title),1),e?.type===`Period`?(l(),a(D,{key:0,type:`success`,effect:`dark`,size:`small`,round:``},{default:m(()=>[i(c(r.$t(`application.type.period`)),1)]),_:1})):e?.type===`Usage`?(l(),a(D,{key:1,effect:`dark`,size:`small`,round:``},{default:m(()=>[i(c(r.$t(`application.type.usage`)),1)]),_:1})):d(``,!0),e?.role===`grantee`?(l(),a(D,{key:2,type:`info`,size:`small`,round:``},{default:m(()=>[i(c(r.$t(`application.badge.shared`)),1)]),_:1})):d(``,!0)]),n(`div`,se,[n(`span`,ce,c(r.$t(`application.field.id`))+`: `+c(e.id),1),o(w,{content:e.id,class:`inline-block shrink-0`},null,8,[`content`])]),n(`div`,le,[n(`span`,ue,c(r.$t(`application.field.remainingAmount`)),1),n(`span`,de,c(r.getRemainingAmount(e)),1)]),e?.expired_at?(l(),t(`div`,fe,[n(`span`,pe,c(r.$t(`application.field.expiredAt`)),1),n(`span`,$,c(r.$dayjs.format(e.expired_at)),1)])):d(``,!0),e.service?.type===r.serviceType.API?(l(),t(`div`,me,[n(`span`,he,c(r.$t(`application.field.allowConsumeGlobal`)),1),o(O,{modelValue:e.allow_consume_global,"onUpdate:modelValue":t=>e.allow_consume_global=t,"active-value":!0,"inactive-value":!1,onChange:t=>r.updateAllowConsumeGlobal(e,t)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])])):d(``,!0),n(`div`,ge,[o(T,{class:`!m-0 !px-3`,size:`small`,round:``,onClick:t=>r.onGoUsage(e)},{default:m(()=>[o(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),r.rowCanPay(e)?(l(),a(T,{key:0,class:`!m-0 !px-3`,type:`primary`,round:``,size:`small`,onClick:t=>r.onBuyMore(e)},{default:m(()=>[o(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):d(``,!0)])]),_:2},1024))),128)):(l(),a(A,{key:0,description:r.$t(`common.message.noData`)},null,8,[`description`]))],64))])]),_:1})]),_:1}),o(b,null,{default:m(()=>[o(y,{span:24},{default:m(()=>[n(`div`,_e,[o(j,{"current-page":r.page,"page-size":r.limit,total:r.individualApplicationsTotal,onChange:r.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var ye=O(L,[[`render`,ve],[`__scopeId`,`data-v-b4164ed9`]]);export{ye as default};
@@ -0,0 +1 @@
1
+ .local-tools-setting[data-v-a0b02a43]{flex-direction:column;gap:28px;display:flex}.section-head[data-v-a0b02a43]{justify-content:space-between;align-items:center;gap:12px;display:flex}.section-head h3[data-v-a0b02a43]{margin:0;font-size:15px;font-weight:600}.section-head.sub[data-v-a0b02a43]{margin-top:6px}.section-head.sub h4[data-v-a0b02a43]{margin:0;font-size:13px;font-weight:600}.cu-action[data-v-a0b02a43]{flex-direction:column;flex:1;gap:2px;display:flex}.cu-action-name[data-v-a0b02a43]{font-size:13px;font-weight:600}.cu-action-desc[data-v-a0b02a43]{color:var(--el-text-color-secondary,#909399);font-size:12px}.mcp-row[data-v-a0b02a43]{background:var(--el-fill-color-lighter,#fafafa);align-items:flex-start;padding:16px}.mcp-fields[data-v-a0b02a43]{flex-direction:column;flex:1;gap:14px;min-width:0;display:flex}.mcp-grid[data-v-a0b02a43]{grid-template-columns:100px minmax(0,1fr);align-items:center;gap:10px 12px;display:grid}.mcp-flabel[data-v-a0b02a43]{color:var(--el-text-color-secondary,#909399);text-align:right;overflow-wrap:anywhere;font-size:12px;font-weight:600}.mcp-flabel.top[data-v-a0b02a43]{align-self:start;padding-top:8px}.mcp-head[data-v-a0b02a43]{align-items:center;gap:8px;display:flex}.mcp-spacer[data-v-a0b02a43]{flex:1}.mcp-row-error[data-v-a0b02a43]{color:var(--el-color-danger,#f56c6c);word-break:break-word;margin:0;font-size:12px}.mcp-platform-hint[data-v-a0b02a43]{margin-top:4px;line-height:1.5}.mcp-error[data-v-a0b02a43]{color:var(--el-color-danger,#f56c6c);font-size:13px}.muted[data-v-a0b02a43]{color:var(--el-text-color-secondary,#909399);margin:6px 0 10px;font-size:13px}.rows[data-v-a0b02a43]{border:1px solid var(--el-border-color-lighter,#ebeef5);border-radius:8px;margin:0;padding:0;list-style:none;overflow:hidden}.row[data-v-a0b02a43]{border-bottom:1px solid var(--el-border-color-lighter,#ebeef5);align-items:center;gap:10px;padding:10px 12px;display:flex}.rows .row[data-v-a0b02a43]:last-child{border-bottom:none}.row.empty[data-v-a0b02a43]{justify-content:center;padding:16px}.row-icon[data-v-a0b02a43]{color:var(--el-text-color-secondary,#909399);flex-shrink:0}.path[data-v-a0b02a43],.grant[data-v-a0b02a43]{word-break:break-all;flex:1;font-size:13px}.grant[data-v-a0b02a43]{flex-direction:column;gap:2px;display:flex}.grant-name[data-v-a0b02a43]{font-weight:600}.grant-input[data-v-a0b02a43]{color:var(--el-text-color-secondary,#909399);word-break:break-all;font-size:12px}.actions[data-v-a0b02a43]{align-items:center;gap:12px;margin-top:12px;display:flex}.saved-tip[data-v-a0b02a43]{margin:0}.tools[data-v-a0b02a43]{margin-top:12px}.perm-row[data-v-a0b02a43]{align-items:center;gap:12px;padding:8px 0;display:flex}.perm-name[data-v-a0b02a43]{flex:1;font-size:14px}
@@ -1 +1 @@
1
- import{A as e,D as t,F as n,P as r,Wt as i,Z as a,tt as o}from"./vendor-chart-BJCvKk8-.js";import{O as s}from"./index-BRkE9zIu.js";import{t as c}from"./LocalTools-DuoRqbBP.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-DYe3FRur.js";import{t as c}from"./LocalTools-DJGvXvcR.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};
@@ -0,0 +1,5 @@
1
+ import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,k as u,tt as d,ut as f}from"./vendor-chart-BJCvKk8-.js";import{t as p}from"./button-BydTr5nV.js";import{H as ee}from"./use-deprecated-B-NFNg3W.js";import{t as te}from"./switch-BYCNj-tS.js";import{i as m}from"./surface-D249_eDG.js";import{A as h,Kr as g,O as _,Wr as v}from"./index-DYe3FRur.js";import{t as y}from"./index.es-oA5jw_nk.js";var b=r({name:`LocalToolsSetting`,components:{ElButton:p,ElTag:v,ElSwitch:te,ElInput:g,FontAwesomeIcon:y},data(){return{Plus:ee,roots:[],tools:[],mcpServers:[],mcpUid:0,mcpStatuses:[],mcpBusy:null,savingMcp:!1,mcpSavedTip:!1,mcpError:``,grants:null,perm:null,computerUse:!1,computerTools:[],computerGrants:{},cuBusy:null,builtinTools:[],toolGrants:{},builtinBusy:null,savingCU:!1,preauthorizing:!1,saving:!1,savedTip:!1,a11yEnabled:!1,onFocus:null,cuOff:null}},computed:{desktop(){return!!h()},android(){return m()}},async mounted(){let e=h();if(!e)return;let t=await e.getConfig();this.roots=t.roots,this.computerUse=t.computerUse===!0,this.mcpServers=(t.mcp??[]).map(e=>({_uid:this.mcpUid++,id:e.id,command:e.command,argsText:(e.args??[]).join(`
2
+ `),envText:Object.entries(e.env??{}).map(([e,t])=>`${e}=${t}`).join(`
3
+ `),enabled:e.enabled!==!1})),this.mcpStatuses=await e.mcp?.status()??[],this.tools=(await e.listTools()).map(e=>e.name),this.computerTools=await e.computerTools?.()??[],this.builtinTools=await e.builtinTools?.()??[];let n=await e.perm?.status();n?.mac&&(this.perm=n),await this.loadGrants(),this.android&&(await this.refreshA11y(),this.onFocus=()=>{document.visibilityState===`visible`&&this.refreshA11y()},document.addEventListener(`visibilitychange`,this.onFocus)),this.cuOff=e.onComputerUseDisabled?.(()=>{this.computerUse=!1})??null},beforeUnmount(){this.cuOff?.(),this.onFocus&&document.removeEventListener(`visibilitychange`,this.onFocus)},methods:{async refreshA11y(){let e=await h()?.perm?.status();this.a11yEnabled=e?.accessibility===!0},async openAndroidAccessibility(){await h()?.perm?.openPane(`accessibility`)},async loadGrants(){let e=h();if(!e?.grants){this.grants=null;return}let t=await e.grants.list(),n={},r={},i=new Set(this.builtinTools.map(e=>e.name)),a=[];for(let e of t){if(e.startsWith(`computer.`)&&!e.includes(`:`)){n[e]=!0;continue}if(!e.includes(`:`)&&i.has(e)){r[e]=!0;continue}let t=e.indexOf(`:{`),o=t>=0?t:e.indexOf(`:`);a.push({key:e,name:o>=0?e.slice(0,o):e,input:o>=0?e.slice(o+1):``})}this.computerGrants=n,this.toolGrants=r,this.grants=a},async addFolder(){let e=await h()?.pickFolder();e&&!this.roots.includes(e)&&this.roots.push(e)},removeRoot(e){this.roots.splice(e,1)},addMcp(){this.mcpServers.push({_uid:this.mcpUid++,id:``,command:``,argsText:``,envText:``,enabled:!0})},removeMcp(e){this.mcpServers.splice(e,1)},mcpStatusFor(e){let t=e.trim();return this.mcpStatuses.find(e=>e.id===t)},mcpBadgeType(e){let t=this.mcpStatusFor(e)?.status;return t===`connected`?`success`:t===`failed`?`danger`:`info`},mcpBadgeText(e){let t=this.mcpStatusFor(e);return this.mcpBusy===e.trim()?this.$t(`common.settings.localToolsMcpConnecting`):t?t.status===`connected`?this.$t(`common.settings.localToolsMcpConnected`,{n:t.toolCount}):t.status===`disabled`?this.$t(`common.settings.localToolsMcpDisabled`):this.$t(`common.settings.localToolsMcpFailed`):this.$t(`common.settings.localToolsMcpNotSaved`)},mcpErrorFor(e){let t=this.mcpStatusFor(e);return t?.status===`failed`&&t.error?t.error:``},buildMcpPayload(){this.mcpError=``;let e=[],t=new Set;for(let n of this.mcpServers){let r=n.id.trim(),i=n.command.trim();if(!r||!i)return this.mcpError=this.$t(`common.settings.localToolsMcpNameRequired`),null;if(!/^[A-Za-z0-9_-]+$/.test(r))return this.mcpError=this.$t(`common.settings.localToolsMcpNameInvalid`),null;if(t.has(r))return this.mcpError=this.$t(`common.settings.localToolsMcpDuplicateName`),null;t.add(r);let a=n.argsText.split(`
4
+ `).map(e=>e.trim()).filter(Boolean),o={};for(let e of n.envText.split(`
5
+ `)){let t=e.trim();if(!t)continue;let n=t.indexOf(`=`);n<=0||(o[t.slice(0,n).trim()]=t.slice(n+1).trim())}let s={id:r,command:i,args:a,enabled:n.enabled!==!1};Object.keys(o).length&&(s.env=o),e.push(s)}return e},async saveMcp(){let e=this.buildMcpPayload();if(!e)return!1;this.savingMcp=!0;try{let t=await h()?.getConfig();return await h()?.saveConfig({roots:t?.roots??this.roots,mcp:e,computerUse:this.computerUse}),await this.refreshMcpStatus(),this.mcpSavedTip=!0,setTimeout(()=>this.mcpSavedTip=!1,2e3),!0}finally{this.savingMcp=!1}},async refreshMcpStatus(){let e=h();e&&(this.mcpStatuses=await e.mcp?.status()??[],this.tools=(await e.listTools())?.map(e=>e.name)??this.tools)},async onToggleMcpEnabled(e){await this.saveMcp()||(e.enabled=!e.enabled)},async reconnectMcp(e){let t=e.id.trim();if(!t||!e.command.trim())return;let n=this.buildMcpPayload();if(n){this.mcpBusy=t;try{let e=await h()?.getConfig();await h()?.saveConfig({roots:e?.roots??this.roots,mcp:n,computerUse:this.computerUse}),await h()?.mcp?.reconnect(t),await this.refreshMcpStatus()}finally{this.mcpBusy=null}}},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()}}}),x={class:`settings-list local-tools-setting`},S={key:0,class:`hint muted`},C={key:0},w={class:`section-head`},T={class:`muted`},E={class:`perm-row`},D={class:`perm-name`},O={key:1},k={class:`section-head`},A={class:`muted`},j={class:`rows`},M={class:`path`},N={key:0,class:`row muted empty`},P={class:`actions`},F={key:0,class:`muted saved-tip`},I={key:0,class:`muted tools`},L={class:`section-head`},R={class:`muted`},z={key:0,class:`rows`},B={class:`mcp-fields`},V={class:`mcp-head`},H={class:`mcp-grid`},U={class:`mcp-flabel`},W={class:`mcp-flabel`},G={class:`mcp-flabel top`},K={class:`mcp-flabel top`},q={key:0,class:`mcp-row-error`},J={key:1,class:`muted`},Y={class:`muted mcp-platform-hint`},X={class:`actions`},Z={key:0,class:`muted saved-tip`},Q={key:1,class:`mcp-error`},ne={key:2},re={class:`section-head`},ie={class:`muted`},ae={class:`rows`},oe={class:`grant`},se={class:`grant-name`},ce={class:`grant-input`},le={key:0,class:`row muted empty`},ue={key:3},de={class:`section-head`},fe={class:`muted`},pe={class:`rows`},me={class:`cu-action`},he={class:`cu-action-name`},ge={class:`grant-name`},_e={class:`cu-action-desc`},ve={class:`section-head`},ye={class:`muted`},be={class:`section-head sub`},xe={class:`muted`},Se={class:`rows`},Ce={class:`cu-action`},we={class:`cu-action-name`},Te={class:`cu-action-desc`},Ee={key:4},De={class:`section-head`},$={class:`muted`},Oe={class:`perm-row`},ke={class:`perm-name`},Ae={class:`perm-row`},je={class:`perm-name`},Me={class:`perm-row`},Ne={class:`perm-name`};function Pe(r,p,ee,te,m,h){let g=d(`el-tag`),_=d(`el-button`),v=d(`font-awesome-icon`),y=d(`el-switch`),b=d(`el-input`);return l(),t(`div`,x,[r.desktop?(l(),t(s,{key:1},[r.android?(l(),t(`section`,C,[n(`div`,w,[n(`h3`,null,c(r.$t(`common.settings.localToolsPermsTitle`)),1)]),n(`p`,T,c(r.$t(`common.settings.localToolsAndroidPermHint`)),1),n(`div`,E,[n(`span`,D,c(r.$t(`common.settings.localToolsPermAccessibility`)),1),o(g,{size:`small`,type:r.a11yEnabled?`success`:`info`,effect:`plain`},{default:f(()=>[i(c(r.a11yEnabled?r.$t(`common.settings.localToolsGranted`):r.$t(`common.settings.localToolsNotGranted`)),1)]),_:1},8,[`type`]),o(_,{size:`small`,type:`primary`,onClick:r.openAndroidAccessibility},{default:f(()=>[i(c(r.$t(`common.settings.localToolsOpen`)),1)]),_:1},8,[`onClick`])])])):u(``,!0),r.android?u(``,!0):(l(),t(`section`,O,[n(`div`,k,[n(`h3`,null,c(r.$t(`common.settings.localToolsFoldersTitle`)),1),o(_,{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`,A,c(r.$t(`common.settings.localToolsFoldersHint`)),1),n(`ul`,j,[(l(!0),t(s,null,e(r.roots,(e,a)=>(l(),t(`li`,{key:e,class:`row`},[o(v,{icon:`fa-solid fa-folder`,class:`row-icon`}),n(`span`,M,c(e),1),o(_,{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`,N,c(r.$t(`common.settings.localToolsNoFolders`)),1))]),n(`div`,P,[o(_,{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`,F,c(r.$t(`common.settings.localToolsSaved`)),1)):u(``,!0)]),r.tools.length?(l(),t(`p`,I,c(r.$t(`common.settings.localToolsActiveTools`))+`: `+c(r.tools.join(`, `)),1)):u(``,!0)])),n(`section`,null,[n(`div`,L,[n(`h3`,null,c(r.$t(`common.settings.localToolsMcpTitle`)),1),o(_,{size:`small`,type:`primary`,icon:r.Plus,onClick:r.addMcp},{default:f(()=>[i(c(r.$t(`common.settings.localToolsMcpAdd`)),1)]),_:1},8,[`icon`,`onClick`])]),n(`p`,R,c(r.$t(`common.settings.localToolsMcpHint`)),1),r.mcpServers.length?(l(),t(`ul`,z,[(l(!0),t(s,null,e(r.mcpServers,(e,a)=>(l(),t(`li`,{key:e._uid,class:`row mcp-row`},[n(`div`,B,[n(`div`,V,[o(g,{size:`small`,effect:`plain`,type:r.mcpBadgeType(e.id)},{default:f(()=>[i(c(r.mcpBadgeText(e.id)),1)]),_:2},1032,[`type`]),p[4]||=n(`span`,{class:`mcp-spacer`},null,-1),o(y,{modelValue:e.enabled,"onUpdate:modelValue":t=>e.enabled=t,size:`small`,"active-text":r.$t(`common.settings.localToolsMcpEnabled`),"inline-prompt":``,onChange:t=>r.onToggleMcpEnabled(e)},null,8,[`modelValue`,`onUpdate:modelValue`,`active-text`,`onChange`]),o(_,{size:`small`,text:``,loading:r.mcpBusy===e.id,disabled:!e.id||!e.command,onClick:t=>r.reconnectMcp(e)},{default:f(()=>[i(c(r.$t(`common.settings.localToolsMcpReconnect`)),1)]),_:1},8,[`loading`,`disabled`,`onClick`]),o(_,{size:`small`,text:``,type:`danger`,onClick:e=>r.removeMcp(a)},{default:f(()=>[i(c(r.$t(`common.settings.localToolsRemove`)),1)]),_:1},8,[`onClick`])]),n(`div`,H,[n(`label`,U,c(r.$t(`common.settings.localToolsMcpName`)),1),o(b,{modelValue:e.id,"onUpdate:modelValue":t=>e.id=t,placeholder:r.$t(`common.settings.localToolsMcpNamePlaceholder`)},null,8,[`modelValue`,`onUpdate:modelValue`,`placeholder`]),n(`label`,W,c(r.$t(`common.settings.localToolsMcpCommand`)),1),o(b,{modelValue:e.command,"onUpdate:modelValue":t=>e.command=t,placeholder:r.$t(`common.settings.localToolsMcpCommandPlaceholder`)},null,8,[`modelValue`,`onUpdate:modelValue`,`placeholder`]),n(`label`,G,c(r.$t(`common.settings.localToolsMcpArgs`)),1),o(b,{modelValue:e.argsText,"onUpdate:modelValue":t=>e.argsText=t,type:`textarea`,rows:2,placeholder:r.$t(`common.settings.localToolsMcpArgsHint`)},null,8,[`modelValue`,`onUpdate:modelValue`,`placeholder`]),n(`label`,K,c(r.$t(`common.settings.localToolsMcpEnv`)),1),o(b,{modelValue:e.envText,"onUpdate:modelValue":t=>e.envText=t,type:`textarea`,rows:2,placeholder:r.$t(`common.settings.localToolsMcpEnvHint`)},null,8,[`modelValue`,`onUpdate:modelValue`,`placeholder`])]),r.mcpErrorFor(e.id)?(l(),t(`p`,q,c(r.mcpErrorFor(e.id)),1)):u(``,!0)])]))),128))])):(l(),t(`p`,J,c(r.$t(`common.settings.localToolsMcpNoServers`)),1)),n(`p`,Y,c(r.$t(`common.settings.localToolsMcpPlatformHint`)),1),n(`div`,X,[o(_,{size:`small`,type:`primary`,loading:r.savingMcp,onClick:r.saveMcp},{default:f(()=>[i(c(r.$t(`common.settings.localToolsSave`)),1)]),_:1},8,[`loading`,`onClick`]),r.mcpSavedTip?(l(),t(`span`,Z,c(r.$t(`common.settings.localToolsSaved`)),1)):u(``,!0),r.mcpError?(l(),t(`span`,Q,c(r.mcpError),1)):u(``,!0)])]),r.grants!==null&&!r.android?(l(),t(`section`,ne,[n(`div`,re,[n(`h3`,null,c(r.$t(`common.settings.localToolsGrantsTitle`)),1),r.grants.length?(l(),a(_,{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`,ie,c(r.$t(`common.settings.localToolsGrantsHint`)),1),n(`ul`,ae,[(l(!0),t(s,null,e(r.grants,e=>(l(),t(`li`,{key:e.key,class:`row`},[o(v,{icon:`fa-solid fa-shield-halved`,class:`row-icon`}),n(`span`,oe,[n(`code`,se,c(e.name),1),n(`span`,ce,c(e.input),1)]),o(_,{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`,le,c(r.$t(`common.settings.localToolsNoGrants`)),1))])])):u(``,!0),r.builtinTools.length&&!r.android?(l(),t(`section`,ue,[n(`div`,de,[n(`h3`,null,c(r.$t(`common.settings.localToolsBuiltinTitle`)),1)]),n(`p`,fe,c(r.$t(`common.settings.localToolsBuiltinHint`)),1),n(`ul`,pe,[(l(!0),t(s,null,e(r.builtinTools,e=>(l(),t(`li`,{key:e.name,class:`row`},[o(v,{icon:r.builtinIcon(e.name),class:`row-icon`},null,8,[`icon`]),n(`span`,me,[n(`span`,he,[n(`code`,ge,c(e.name),1),e.name===`shell.run_command`?(l(),a(g,{key:0,size:`small`,type:`danger`,effect:`plain`},{default:f(()=>[i(c(r.$t(`common.settings.localToolsBuiltinRisky`)),1)]),_:1})):u(``,!0)]),n(`span`,_e,c(e.description),1)]),o(y,{"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`,ve,[n(`h3`,null,c(r.$t(`common.settings.localToolsComputerUseTitle`)),1),o(y,{modelValue:r.computerUse,"onUpdate:modelValue":p[0]||=e=>r.computerUse=e,loading:r.savingCU,onChange:r.onToggleComputerUse},null,8,[`modelValue`,`loading`,`onChange`])]),n(`p`,ye,c(r.$t(`common.settings.localToolsComputerUseHint`)),1),r.computerTools.length?(l(),t(s,{key:0},[n(`div`,be,[n(`h4`,null,c(r.$t(`common.settings.localToolsCuActionsTitle`)),1),o(_,{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`,xe,c(r.$t(`common.settings.localToolsCuActionsHint`)),1),n(`ul`,Se,[(l(!0),t(s,null,e(r.computerTools,e=>(l(),t(`li`,{key:e.name,class:`row`},[o(v,{icon:r.cuIcon(e.name),class:`row-icon`},null,8,[`icon`]),n(`span`,Ce,[n(`span`,we,c(r.cuLabel(e.name)),1),n(`span`,Te,c(e.description),1)]),o(y,{"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`,Ee,[n(`div`,De,[n(`h3`,null,c(r.$t(`common.settings.localToolsPermsTitle`)),1)]),n(`p`,$,c(r.$t(`common.settings.localToolsPermsHint`)),1),n(`div`,Oe,[n(`span`,ke,c(r.$t(`common.settings.localToolsPermFullDisk`)),1),o(g,{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(_,{size:`small`,type:`primary`,onClick:p[1]||=e=>r.open(`fullDisk`)},{default:f(()=>[i(c(r.$t(`common.settings.localToolsOpen`)),1)]),_:1})]),n(`div`,Ae,[n(`span`,je,c(r.$t(`common.settings.localToolsPermScreen`)),1),o(g,{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(_,{size:`small`,type:`primary`,onClick:p[2]||=e=>r.open(`screen`)},{default:f(()=>[i(c(r.$t(`common.settings.localToolsOpen`)),1)]),_:1})]),n(`div`,Me,[n(`span`,Ne,c(r.$t(`common.settings.localToolsPermAccessibility`)),1),o(g,{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(_,{size:`small`,type:`primary`,onClick:p[3]||=e=>r.open(`accessibility`)},{default:f(()=>[i(c(r.$t(`common.settings.localToolsOpen`)),1)]),_:1})])])):u(``,!0)],64)):(l(),t(`p`,S,c(r.$t(`common.settings.localToolsDesktopOnly`)),1))])}var Fe=_(b,[[`render`,Pe],[`__scopeId`,`data-v-a0b02a43`]]);export{Fe 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-BQUbRnUn.js";import{t as m}from"./checkbox-BC1X4B2U.js";import{t as h}from"./divider-LA__Fty9.js";import"./constants-D5XSekB2.js";import{Hr as g,Ht as _,Lr as v,Mr as y,O as b,Pr as x,Wn as S,jr as C,zr as w}from"./index-BRkE9zIu.js";import{t as T}from"./Status-CYJT4HgG.js";var E=r({name:`ApplicationConfirm`,components:{ElDialog:g,ElDivider:h,ElCheckbox:m,ElButton:f},props:{visible:{type:Boolean,required:!1,default:!1}},emits:[`update:visible`,`apply`],data(){return{checked:!0}},watch:{},methods:{getBaseUrlPlatform:v,onApply(){if(!this.checked){w.error(this.$t(`application.message.notAgreePolicy`));return}this.$emit(`apply`)}}}),D={class:`content py-[10px] px-[40px]`},O={class:`my-4`},k={class:`policy mb-[10px]`},A={class:`policy-title text-[12px] relative -bottom-[3px]`},j=[`href`];function M(e,n,r,l,f,p){let m=u(`el-divider`),h=u(`el-checkbox`),g=u(`el-button`),_=u(`el-dialog`);return c(),a(_,{"model-value":e.visible,width:`500px`,title:e.$t(`application.message.welcome`),center:``,onClose:n[1]||=t=>e.$emit(`update:visible`,!1)},{default:d(()=>[t(`div`,D,[t(`p`,O,s(e.$t(`application.message.notApplied`)),1),o(m,{class:`my-2`}),t(`div`,k,[o(h,{modelValue:e.checked,"onUpdate:modelValue":n[0]||=t=>e.checked=t,size:`large`,class:`policy-checkbox mr-[10px]`},null,8,[`modelValue`]),t(`span`,A,s(e.$t(`application.message.readPolicy`)),1),t(`a`,{class:`policy-title text-[12px] relative -bottom-[3px] text-[var(--el-color-primary)] cursor-pointer no-underline`,target:`_blank`,href:e.getBaseUrlPlatform()+`/terms`},` \xA0`+s(e.$t(`application.message.policy`)),9,j)]),o(g,{round:``,type:`primary`,onClick:e.onApply},{default:d(()=>[i(s(e.$t(`common.button.start`)),1)]),_:1},8,[`onClick`])])]),_:1},8,[`model-value`,`title`])}var N=b(E,[[`render`,M]]),P=15e3,F=r({name:`LayoutMain`,components:{Navigator:p,ApplicationStatus:T,ApplicationConfirm:N},provide(){return{initialized:n(()=>this.initialized)}},data(){return{initialized:!1,applying:!1,mobile:typeof window<`u`&&window.innerWidth<768,initializeRunId:0,balanceTimer:0}},computed:{appName(){return this.$route.meta.appName},application(){return this.$store.state[this.appName]?.application},applications(){let e=this.$store.state[this.appName]?.applications??[];console.debug(`individualApplications`,e);let t=this.$store.state.applications??[];return console.debug(`globalApplications`,t),t.concat(e)},loading(){return this.$store.state[this.appName]?.status?.getApplications===x.Request},service(){return this.$store.state[this.appName]?.service},userId(){return this.$store.state.user?.id}},watch:{appName(){this.initialize()},userId(e,t){e&&e!==t&&this.initialize()}},mounted(){this.initialize(),window.addEventListener(`resize`,this.onResize),this.balanceTimer=window.setInterval(this.refreshBalances,P),document.addEventListener(`visibilitychange`,this.onVisibility)},beforeUnmount(){window.removeEventListener(`resize`,this.onResize),window.clearInterval(this.balanceTimer),document.removeEventListener(`visibilitychange`,this.onVisibility)},methods:{onResize(){this.mobile=window.innerWidth<768},onVisibility(){typeof document<`u`&&!document.hidden&&this.refreshBalances()},async refreshBalances(){if(!this.appName||!this.$store.state.token?.access||typeof document<`u`&&document.hidden||this.loading)return;await Promise.allSettled([this.$store.dispatch(`getApplications`),this.$store.dispatch(`${this.appName}/getApplications`)]);let e=this.$store.state[this.appName]?.application;if(!e)return;let t=this.applications?.find(t=>t.id===e.id);t&&t!==e&&this.$store.commit(`${this.appName}/setApplication`,t)},async initialize(){let e=++this.initializeRunId;if(this.initialized=!1,!this.$store.state.token?.access||(console.debug(`Fetching all individual and global applications for`,this.appName),await Promise.allSettled([this.$store.dispatch(`getApplications`),this.$store.dispatch(`${this.appName}/getApplications`)]),e!==this.initializeRunId))return;console.debug(`Fetched all applications`,this.applications),this.$store.state.applications?.length===0&&await this.onAutoApply();let t=this.$store.state[this.appName]?.application;console.debug(`current application`,t);let n=_(this.applications,t);console.debug(`final application`,n),n&&(console.debug(`set final application`,n,n?.type),await this.$store.dispatch(`${this.appName}/setApplication`,n)),console.debug(`finished initialization`),this.initialized=!0},onApply(){this.onAutoApply()},async onAutoApply(){try{await S.create({type:y.USAGE,scope:C.GLOBAL,user_id:this.$store.getters.user.id}),this.applying=!1,await this.$store.dispatch(`getApplications`),this.showWelcomeToast()}catch(e){e?.response?.data?.code===`duplication`?await this.$store.dispatch(`getApplications`):w.error(this.$t(`application.message.applyFailed`))}},showWelcomeToast(){let e=this.$store.state.applications?.[0],t=Math.floor(e?.remaining_amount??0);w({message:t>0?this.$t(`application.message.welcomeWithCredits`,{credits:t}):this.$t(`application.message.welcomeNoCredits`),type:`success`,duration:6e3,showClose:!0})}}}),I={class:`wrapper`};function L(t,n,r,i,s,d){let f=u(`router-view`),p=u(`navigator`),m=u(`application-status`),h=u(`application-confirm`);return c(),e(`div`,I,[o(f,{class:`main`}),o(p,{class:`navigator`,direction:t.mobile?`row`:`column`},null,8,[`direction`]),t.application?(c(),a(m,{key:0,class:`status-floating fixed right-2 z-[200]`,application:t.application,applications:t.applications,"show-price":!1,authenticated:!!t.$store.state.token.access,service:t.service,onSelect:n[0]||=e=>t.$store.dispatch(`${t.appName}/setApplication`,e)},null,8,[`application`,`applications`,`authenticated`,`service`])):l(``,!0),o(h,{modelValue:t.applying,"onUpdate:modelValue":n[1]||=e=>t.applying=e,modelModifiers:{visible:!0},onApply:t.onApply},null,8,[`modelValue`,`onApply`])])}var R=b(F,[[`render`,L],[`__scopeId`,`data-v-f071b44e`]]);export{R as default};
1
+ import"./rolldown-runtime--c01j_DQ.js";import{A as e,D as t,E as n,F as r,N as i,O as a,P as o,Wt as s,Z as c,k as l,tt as u,ut as d}from"./vendor-chart-BJCvKk8-.js";import{t as f}from"./button-BydTr5nV.js";import{t as p}from"./Navigator-BJ5QRqKH.js";import{t as m}from"./checkbox-BC1X4B2U.js";import{t as h}from"./divider-LA__Fty9.js";import"./constants-DReNd4Tz.js";import{Hr as g,Ht as _,Lr as v,Mr as y,O as b,Pr as x,Wn as S,jr as C,zr as w}from"./index-DYe3FRur.js";import{t as T}from"./Status-BnQWhq_x.js";var E=r({name:`ApplicationConfirm`,components:{ElDialog:g,ElDivider:h,ElCheckbox:m,ElButton:f},props:{visible:{type:Boolean,required:!1,default:!1}},emits:[`update:visible`,`apply`],data(){return{checked:!0}},watch:{},methods:{getBaseUrlPlatform:v,onApply(){if(!this.checked){w.error(this.$t(`application.message.notAgreePolicy`));return}this.$emit(`apply`)}}}),D={class:`content py-[10px] px-[40px]`},O={class:`my-4`},k={class:`policy mb-[10px]`},A={class:`policy-title text-[12px] relative -bottom-[3px]`},j=[`href`];function M(e,n,r,l,f,p){let m=u(`el-divider`),h=u(`el-checkbox`),g=u(`el-button`),_=u(`el-dialog`);return c(),a(_,{"model-value":e.visible,width:`500px`,title:e.$t(`application.message.welcome`),center:``,onClose:n[1]||=t=>e.$emit(`update:visible`,!1)},{default:d(()=>[t(`div`,D,[t(`p`,O,s(e.$t(`application.message.notApplied`)),1),o(m,{class:`my-2`}),t(`div`,k,[o(h,{modelValue:e.checked,"onUpdate:modelValue":n[0]||=t=>e.checked=t,size:`large`,class:`policy-checkbox mr-[10px]`},null,8,[`modelValue`]),t(`span`,A,s(e.$t(`application.message.readPolicy`)),1),t(`a`,{class:`policy-title text-[12px] relative -bottom-[3px] text-[var(--el-color-primary)] cursor-pointer no-underline`,target:`_blank`,href:e.getBaseUrlPlatform()+`/terms`},` \xA0`+s(e.$t(`application.message.policy`)),9,j)]),o(g,{round:``,type:`primary`,onClick:e.onApply},{default:d(()=>[i(s(e.$t(`common.button.start`)),1)]),_:1},8,[`onClick`])])]),_:1},8,[`model-value`,`title`])}var N=b(E,[[`render`,M]]),P=15e3,F=r({name:`LayoutMain`,components:{Navigator:p,ApplicationStatus:T,ApplicationConfirm:N},provide(){return{initialized:n(()=>this.initialized)}},data(){return{initialized:!1,applying:!1,mobile:typeof window<`u`&&window.innerWidth<768,initializeRunId:0,balanceTimer:0}},computed:{appName(){return this.$route.meta.appName},application(){return this.$store.state[this.appName]?.application},applications(){let e=this.$store.state[this.appName]?.applications??[];console.debug(`individualApplications`,e);let t=this.$store.state.applications??[];return console.debug(`globalApplications`,t),t.concat(e)},loading(){return this.$store.state[this.appName]?.status?.getApplications===x.Request},service(){return this.$store.state[this.appName]?.service},userId(){return this.$store.state.user?.id}},watch:{appName(){this.initialize()},userId(e,t){e&&e!==t&&this.initialize()}},mounted(){this.initialize(),window.addEventListener(`resize`,this.onResize),this.balanceTimer=window.setInterval(this.refreshBalances,P),document.addEventListener(`visibilitychange`,this.onVisibility)},beforeUnmount(){window.removeEventListener(`resize`,this.onResize),window.clearInterval(this.balanceTimer),document.removeEventListener(`visibilitychange`,this.onVisibility)},methods:{onResize(){this.mobile=window.innerWidth<768},onVisibility(){typeof document<`u`&&!document.hidden&&this.refreshBalances()},async refreshBalances(){if(!this.appName||!this.$store.state.token?.access||typeof document<`u`&&document.hidden||this.loading)return;await Promise.allSettled([this.$store.dispatch(`getApplications`),this.$store.dispatch(`${this.appName}/getApplications`)]);let e=this.$store.state[this.appName]?.application;if(!e)return;let t=this.applications?.find(t=>t.id===e.id);t&&t!==e&&this.$store.commit(`${this.appName}/setApplication`,t)},async initialize(){let e=++this.initializeRunId;if(this.initialized=!1,!this.$store.state.token?.access||(console.debug(`Fetching all individual and global applications for`,this.appName),await Promise.allSettled([this.$store.dispatch(`getApplications`),this.$store.dispatch(`${this.appName}/getApplications`)]),e!==this.initializeRunId))return;console.debug(`Fetched all applications`,this.applications),this.$store.state.applications?.length===0&&await this.onAutoApply();let t=this.$store.state[this.appName]?.application;console.debug(`current application`,t);let n=_(this.applications,t);console.debug(`final application`,n),n&&(console.debug(`set final application`,n,n?.type),await this.$store.dispatch(`${this.appName}/setApplication`,n)),console.debug(`finished initialization`),this.initialized=!0},onApply(){this.onAutoApply()},async onAutoApply(){try{await S.create({type:y.USAGE,scope:C.GLOBAL,user_id:this.$store.getters.user.id}),this.applying=!1,await this.$store.dispatch(`getApplications`),this.showWelcomeToast()}catch(e){e?.response?.data?.code===`duplication`?await this.$store.dispatch(`getApplications`):w.error(this.$t(`application.message.applyFailed`))}},showWelcomeToast(){let e=this.$store.state.applications?.[0],t=Math.floor(e?.remaining_amount??0);w({message:t>0?this.$t(`application.message.welcomeWithCredits`,{credits:t}):this.$t(`application.message.welcomeNoCredits`),type:`success`,duration:6e3,showClose:!0})}}}),I={class:`wrapper`};function L(t,n,r,i,s,d){let f=u(`router-view`),p=u(`navigator`),m=u(`application-status`),h=u(`application-confirm`);return c(),e(`div`,I,[o(f,{class:`main`}),o(p,{class:`navigator`,direction:t.mobile?`row`:`column`},null,8,[`direction`]),t.application?(c(),a(m,{key:0,class:`status-floating fixed right-2 z-[200]`,application:t.application,applications:t.applications,"show-price":!1,authenticated:!!t.$store.state.token.access,service:t.service,onSelect:n[0]||=e=>t.$store.dispatch(`${t.appName}/setApplication`,e)},null,8,[`application`,`applications`,`authenticated`,`service`])):l(``,!0),o(h,{modelValue:t.applying,"onUpdate:modelValue":n[1]||=e=>t.applying=e,modelModifiers:{visible:!0},onApply:t.onApply},null,8,[`modelValue`,`onApply`])])}var R=b(F,[[`render`,L],[`__scopeId`,`data-v-f071b44e`]]);export{R as default};
@@ -1 +1 @@
1
- import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Vt as ee,Wt as c,Z as l,b as u,k as d,tt as f,ut as p}from"./vendor-chart-BJCvKk8-.js";import{t as m}from"./button-BydTr5nV.js";import{t as h}from"./upload-izq5b45N.js";import{t as g}from"./image-98SuLK5-.js";import{t as _}from"./alert-C51owb6L.js";import{n as v,r as y}from"./radio-3Hz7h3DR.js";import{t as b}from"./switch-BKuYGnPZ.js";import{t as x}from"./vendor-axios-Ck2ffRoh.js";import"./constants-D5XSekB2.js";import{Kr as S,Lr as C,O as w,Zt as T,an as E,tt as te,zr as D,zt as O}from"./index-BRkE9zIu.js";import{t as k}from"./index.es-Dw0M6NcN.js";import{t as A}from"./CopyToClipboard-DFQ4IOLO.js";import{t as j}from"./BotPlaceholder-CueTGOF1.js";import{t as M}from"./Hailuo-DJn5sNFj.js";import{t as N}from"./TabSwitcher-BuwIJ1Nn.js";var P=4,F=90,I=r({name:`FishRecorder`,components:{ElButton:m,FontAwesomeIcon:k},emits:[`done`,`cancel`,`update:script`],data(){return{state:`idle`,scriptIndex:0,seconds:0,timerId:0,maxTimerId:0,mediaRecorder:null,stream:null,chunks:[],recordedBlob:null,recordedUrl:``,uploading:!1}},computed:{formattedTime(){let e=Math.floor(this.seconds/60),t=this.seconds%60;return`${e.toString().padStart(2,`0`)}:${t.toString().padStart(2,`0`)}`},currentScript(){let e=`fish.script.passage${this.scriptIndex%P+1}`;return this.$t(e)}},beforeUnmount(){this.cleanup()},mounted(){this.$emit(`update:script`,this.currentScript)},methods:{nextScript(){this.scriptIndex=(this.scriptIndex+1)%P,this.$emit(`update:script`,this.currentScript)},async startRecord(){if(!navigator.mediaDevices?.getUserMedia||typeof MediaRecorder>`u`){D.error(this.$t(`fish.message.recorderUnsupported`));return}try{this.stream=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(e){let t=e?.name===`NotAllowedError`||e?.name===`PermissionDeniedError`;D.error(this.$t(t?`fish.message.micDenied`:`fish.message.micError`));return}this.chunks=[];let e=this.pickMimeType();try{this.mediaRecorder=e?new MediaRecorder(this.stream,{mimeType:e}):new MediaRecorder(this.stream)}catch{this.mediaRecorder=new MediaRecorder(this.stream)}this.mediaRecorder.ondataavailable=e=>{e.data&&e.data.size>0&&this.chunks.push(e.data)},this.mediaRecorder.onstop=()=>{let e=new Blob(this.chunks,{type:this.mediaRecorder?.mimeType||`audio/webm`});this.recordedBlob=e,this.recordedUrl=URL.createObjectURL(e),this.state=`recorded`,this.releaseStream()},this.mediaRecorder.start(),this.state=`recording`,this.seconds=0,this.timerId=window.setInterval(()=>{this.seconds++},1e3),this.maxTimerId=window.setTimeout(()=>{this.state===`recording`&&this.stopRecord()},F*1e3)},stopRecord(){this.mediaRecorder&&this.mediaRecorder.state!==`inactive`&&this.mediaRecorder.stop(),window.clearInterval(this.timerId),window.clearTimeout(this.maxTimerId)},reset(){this.recordedUrl&&URL.revokeObjectURL(this.recordedUrl),this.recordedUrl=``,this.recordedBlob=null,this.state=`idle`,this.seconds=0},onCancel(){this.cleanup(),this.$emit(`cancel`)},cleanup(){this.stopRecord(),this.releaseStream(),this.recordedUrl&&URL.revokeObjectURL(this.recordedUrl)},releaseStream(){this.stream?.getTracks().forEach(e=>e.stop()),this.stream=null},pickMimeType(){for(let e of[`audio/webm;codecs=opus`,`audio/webm`,`audio/mp4`,`audio/ogg`])if(typeof MediaRecorder<`u`&&MediaRecorder.isTypeSupported?.(e))return e},extensionForMime(e){return e.includes(`webm`)?`webm`:e.includes(`mp4`)?`m4a`:e.includes(`ogg`)?`ogg`:e.includes(`wav`)?`wav`:`mp3`},async useRecording(){if(this.recordedBlob){if(this.seconds<3){D.warning(this.$t(`fish.message.recordingTooShort`));return}this.uploading=!0;try{let e=this.$store.state.token?.access,t=this.extensionForMime(this.recordedBlob.type||``),n=new File([this.recordedBlob],`recording-${Date.now()}.${t}`,{type:this.recordedBlob.type||`audio/webm`}),r=new FormData;r.append(`file`,n);let{data:i}=await x.post(`${C()}/api/v1/files/`,r,{headers:{Authorization:`Bearer ${e}`}}),a=i?.file_url;if(!a){D.error(this.$t(`fish.message.uploadError`));return}this.$emit(`done`,{url:a,text:this.currentScript})}catch(e){D.error(this.$t(`fish.message.uploadError`)),console.error(`recorder upload failed`,e)}finally{this.uploading=!1}}}}}),L={class:`recorder`},R={key:0,class:`script`},z={class:`script-header`},B={class:`label`},V={class:`script-text`},H={class:`controls`},U={class:`status`},W={class:`hint`},G={key:1,class:`preview`},K=[`src`],q={class:`preview-actions`},J={class:`footer`};function Y(e,r,s,u,m,h){let g=f(`font-awesome-icon`),_=f(`el-button`);return l(),t(`div`,L,[e.state===`recorded`?d(``,!0):(l(),t(`div`,R,[n(`div`,z,[o(g,{icon:`fa-solid fa-book-open`,class:`icon mr-1`}),n(`span`,B,c(e.$t(`fish.description.readScript`)),1),o(_,{link:``,size:`small`,class:`ml-auto`,disabled:e.state===`recording`,onClick:e.nextScript},{default:p(()=>[o(g,{icon:`fa-solid fa-shuffle`,class:`mr-1`}),i(` `+c(e.$t(`fish.button.nextScript`)),1)]),_:1},8,[`disabled`,`onClick`])]),n(`p`,V,c(e.currentScript),1)])),n(`div`,H,[e.state===`idle`?(l(),a(_,{key:0,type:`danger`,circle:``,size:`large`,title:e.$t(`fish.button.startRecord`),onClick:e.startRecord},{default:p(()=>[o(g,{icon:`fa-solid fa-microphone`})]),_:1},8,[`title`,`onClick`])):e.state===`recording`?(l(),a(_,{key:1,type:`warning`,circle:``,size:`large`,title:e.$t(`fish.button.stopRecord`),onClick:e.stopRecord},{default:p(()=>[o(g,{icon:`fa-solid fa-stop`})]),_:1},8,[`title`,`onClick`])):d(``,!0),n(`div`,U,[n(`span`,{class:ee([`timer`,e.state===`recording`?`live`:``])},c(e.formattedTime),3),n(`span`,W,c(e.state===`idle`?e.$t(`fish.description.recorderIdle`):e.state===`recording`?e.$t(`fish.description.recorderRecording`):e.$t(`fish.description.recorderRecorded`)),1)])]),e.state===`recorded`&&e.recordedUrl?(l(),t(`div`,G,[n(`audio`,{src:e.recordedUrl,controls:``,preload:`metadata`,class:`w-full`},null,8,K),n(`div`,q,[o(_,{size:`small`,disabled:e.uploading,onClick:e.reset},{default:p(()=>[o(g,{icon:`fa-solid fa-rotate-left`,class:`mr-1`}),i(` `+c(e.$t(`fish.button.reRecord`)),1)]),_:1},8,[`disabled`,`onClick`]),o(_,{size:`small`,type:`primary`,loading:e.uploading,onClick:e.useRecording},{default:p(()=>[o(g,{icon:`fa-solid fa-check`,class:`mr-1`}),i(` `+c(e.$t(`fish.button.useRecording`)),1)]),_:1},8,[`loading`,`onClick`])])])):d(``,!0),n(`div`,J,[o(_,{link:``,size:`small`,disabled:e.uploading||e.state===`recording`,onClick:e.onCancel},{default:p(()=>[i(c(e.$t(`fish.button.cancel`)),1)]),_:1},8,[`disabled`,`onClick`])])])}var X=w(I,[[`render`,Y],[`__scopeId`,`data-v-1958e4a1`]]),Z=50*1024*1024,Q=()=>({title:``,description:``,texts:``,voicesUrl:``,visibility:`unlist`,trainMode:`fast`,enhanceAudio:!0,generateSample:!1}),ne=r({name:`FishModelConfigPanel`,components:{ElButton:m,ElInput:S,ElRadioButton:v,ElRadioGroup:y,ElSwitch:b,ElUpload:h,FontAwesomeIcon:k,Recorder:X},mixins:[O],emits:[`create`],data(){return{form:Q(),fileList:[],uploading:!1,creating:!1,recording:!1,textsAuto:!0}},computed:{uploadUrl(){return C()+`/api/v1/files/`},uploadHeaders(){return{Authorization:`Bearer ${this.$store.state.token?.access}`}},canCreate(){return!!this.form.title.trim()&&!!this.form.voicesUrl&&!this.uploading&&!this.creating},supportsRecorder(){return!!(typeof navigator<`u`?navigator.mediaDevices:void 0)?.getUserMedia&&typeof MediaRecorder<`u`}},methods:{onBeforeUpload(e){return e.size>Z?(D.warning(this.$t(`fish.message.audioSizeExceed`)),!1):(this.uploading=!0,!0)},onExceed(){D.warning(this.$t(`fish.message.audioOnlyOne`))},onUploadError(){this.uploading=!1,D.error(this.$t(`fish.message.uploadError`))},onUploadSuccess(e,t,n){this.uploading=!1;let r=e?.file_url;if(!r){D.error(this.$t(`fish.message.uploadError`)),this.fileList=[];return}this.form.voicesUrl=r,this.fileList=n},onRecorded(e){this.form.voicesUrl=e.url,this.recording=!1,e.text&&this.textsAuto&&(this.form.texts=e.text)},onStartRecord(){this.recording=!0,this.textsAuto=!this.form.texts.trim()},onScriptChange(e){this.textsAuto&&this.recording&&(this.form.texts=e)},onTextsInput(){this.textsAuto=!1},clearAudio(){this.form.voicesUrl=``,this.fileList=[]},onCreate(){let e=this.form.title.trim();if(!e){D.warning(this.$t(`fish.message.titleRequired`));return}if(!this.form.voicesUrl){D.warning(this.$t(`fish.message.audioRequired`));return}let t={title:e,voices:this.form.voicesUrl,visibility:this.form.visibility,train_mode:this.form.trainMode,enhance_audio_quality:this.form.enhanceAudio,generate_sample:this.form.generateSample};this.form.description.trim()&&(t.description=this.form.description.trim()),this.form.texts.trim()&&(t.texts=[this.form.texts.trim()]),this.creating=!0,this.$emit(`create`,t),setTimeout(()=>{this.creating=!1,this.form=Q(),this.fileList=[]},600)}}}),re={class:`flex flex-col h-full`},ie={class:`flex-1 overflow-y-auto p-5`},ae={class:`field-block mb-4`},oe={class:`title font-bold`},se={class:`field-block mb-4`},ce={class:`flex items-baseline justify-between mb-1`},le={class:`title font-bold`},ue={key:0,class:`muted`},de={class:`hint`},fe={key:0,class:`audio-actions`},pe={key:1,class:`hint warn`},me={key:3,class:`mt-2`},he=[`src`],ge={class:`ready-actions`},_e={class:`field-block mb-4`},ve={class:`title font-bold`},ye={class:`hint`},be={class:`field-block mb-4`},xe={class:`title font-bold`},Se={class:`field-block mb-4`},Ce={class:`title font-bold`},we={class:`field-block mb-4`},Te={class:`title font-bold`},Ee={class:`field-block mb-3`},De={class:`field-row`},Oe={class:`title font-bold`},ke={class:`hint mt-0 mb-0`},Ae={class:`field-block mb-2`},je={class:`field-row`},Me={class:`title font-bold`},Ne={class:`hint mt-0 mb-0`},Pe={class:`flex flex-col items-center justify-center px-5 pb-5`};function Fe(e,r,s,ee,u,m){let h=f(`el-input`),g=f(`font-awesome-icon`),_=f(`el-button`),v=f(`el-upload`),y=f(`recorder`),b=f(`el-radio-button`),x=f(`el-radio-group`),S=f(`el-switch`);return l(),t(`div`,re,[n(`div`,ie,[n(`div`,ae,[n(`h2`,oe,[i(c(e.$t(`fish.name.voiceTitle`))+` `,1),r[9]||=n(`span`,{class:`required`},`*`,-1)]),o(h,{modelValue:e.form.title,"onUpdate:modelValue":r[0]||=t=>e.form.title=t,placeholder:e.$t(`fish.placeholder.voiceTitle`),maxlength:`60`},null,8,[`modelValue`,`placeholder`])]),n(`div`,se,[n(`div`,ce,[n(`h2`,le,[i(c(e.$t(`fish.name.referenceAudio`))+` `,1),r[10]||=n(`span`,{class:`required`},`*`,-1)]),!e.form.voicesUrl&&!e.recording?(l(),t(`span`,ue,c(e.$t(`fish.description.audioRequired`)),1)):d(``,!0)]),n(`p`,de,c(e.$t(`fish.description.uploadAudio`)),1),!e.form.voicesUrl&&!e.recording?(l(),t(`div`,fe,[o(v,{"file-list":e.fileList,"onUpdate:fileList":r[1]||=t=>e.fileList=t,name:`file`,limit:1,class:`upload-wrapper`,action:e.uploadUrl,accept:`.mp3,.wav,.m4a,.ogg,.webm,audio/*`,"show-file-list":!1,"on-exceed":e.onExceed,"on-error":e.onUploadError,"on-success":e.onUploadSuccess,"before-upload":e.onBeforeUpload,headers:e.uploadHeaders},{default:p(()=>[o(_,{type:`primary`,plain:``,round:``,loading:e.uploading},{default:p(()=>[o(g,{icon:`fa-solid fa-upload`,class:`icon mr-1`}),i(` `+c(e.$t(`fish.button.uploadAudio`)),1)]),_:1},8,[`loading`])]),_:1},8,[`file-list`,`action`,`on-exceed`,`on-error`,`on-success`,`before-upload`,`headers`]),o(_,{type:`primary`,round:``,disabled:!e.supportsRecorder,onClick:e.onStartRecord},{default:p(()=>[o(g,{icon:`fa-solid fa-microphone`,class:`icon mr-1`}),i(` `+c(e.$t(`fish.button.recordAudio`)),1)]),_:1},8,[`disabled`,`onClick`])])):d(``,!0),!e.supportsRecorder&&!e.form.voicesUrl&&!e.recording?(l(),t(`p`,pe,c(e.$t(`fish.message.recorderUnsupported`)),1)):d(``,!0),e.recording?(l(),a(y,{key:2,class:`mt-2`,onDone:e.onRecorded,onCancel:r[2]||=t=>e.recording=!1,"onUpdate:script":e.onScriptChange},null,8,[`onDone`,`onUpdate:script`])):d(``,!0),e.form.voicesUrl&&!e.recording?(l(),t(`div`,me,[n(`audio`,{src:e.form.voicesUrl,controls:``,preload:`metadata`,class:`w-full`},null,8,he),n(`div`,ge,[o(_,{link:``,size:`small`,onClick:e.clearAudio},{default:p(()=>[o(g,{icon:`fa-solid fa-rotate-left`,class:`mr-1`}),i(` `+c(e.$t(`fish.button.replaceAudio`)),1)]),_:1},8,[`onClick`])])])):d(``,!0)]),n(`div`,_e,[n(`h2`,ve,c(e.$t(`fish.name.audioTexts`)),1),n(`p`,ye,c(e.$t(`fish.description.audioTexts`)),1),o(h,{modelValue:e.form.texts,"onUpdate:modelValue":r[3]||=t=>e.form.texts=t,type:`textarea`,rows:2,placeholder:e.$t(`fish.placeholder.audioTexts`),maxlength:`500`,onInput:e.onTextsInput},null,8,[`modelValue`,`placeholder`,`onInput`])]),n(`div`,be,[n(`h2`,xe,c(e.$t(`fish.name.voiceDescription`)),1),o(h,{modelValue:e.form.description,"onUpdate:modelValue":r[4]||=t=>e.form.description=t,type:`textarea`,rows:2,placeholder:e.$t(`fish.placeholder.voiceDescription`),maxlength:`500`},null,8,[`modelValue`,`placeholder`])]),n(`div`,Se,[n(`h2`,Ce,c(e.$t(`fish.name.visibility`)),1),o(x,{modelValue:e.form.visibility,"onUpdate:modelValue":r[5]||=t=>e.form.visibility=t,size:`small`},{default:p(()=>[o(b,{label:`private`,value:`private`},{default:p(()=>[i(c(e.$t(`fish.value.private`)),1)]),_:1}),o(b,{label:`unlist`,value:`unlist`},{default:p(()=>[i(c(e.$t(`fish.value.unlist`)),1)]),_:1}),o(b,{label:`public`,value:`public`},{default:p(()=>[i(c(e.$t(`fish.value.public`)),1)]),_:1})]),_:1},8,[`modelValue`])]),n(`div`,we,[n(`h2`,Te,c(e.$t(`fish.name.trainMode`)),1),o(x,{modelValue:e.form.trainMode,"onUpdate:modelValue":r[6]||=t=>e.form.trainMode=t,size:`small`},{default:p(()=>[o(b,{label:`fast`,value:`fast`},{default:p(()=>[i(c(e.$t(`fish.value.trainModeFast`)),1)]),_:1}),o(b,{label:`precise`,value:`precise`},{default:p(()=>[i(c(e.$t(`fish.value.trainModePrecise`)),1)]),_:1})]),_:1},8,[`modelValue`])]),n(`div`,Ee,[n(`div`,De,[n(`h2`,Oe,c(e.$t(`fish.name.enhanceAudio`)),1),o(S,{modelValue:e.form.enhanceAudio,"onUpdate:modelValue":r[7]||=t=>e.form.enhanceAudio=t},null,8,[`modelValue`])]),n(`p`,ke,c(e.$t(`fish.description.enhanceAudio`)),1)]),n(`div`,Ae,[n(`div`,je,[n(`h2`,Me,c(e.$t(`fish.name.generateSample`)),1),o(S,{modelValue:e.form.generateSample,"onUpdate:modelValue":r[8]||=t=>e.form.generateSample=t},null,8,[`modelValue`])]),n(`p`,Ne,c(e.$t(`fish.description.generateSample`)),1)])]),n(`div`,Pe,[o(_,{type:`primary`,class:`btn w-full`,round:``,disabled:!e.canCreate||e.creating,loading:e.creating,onClick:e.onCreate},{default:p(()=>[o(g,{icon:`fa-solid fa-magic`,class:`mr-2`}),i(` `+c(e.$t(`fish.button.createModel`)),1)]),_:1},8,[`disabled`,`loading`,`onClick`])])])}var Ie=w(ne,[[`render`,Fe],[`__scopeId`,`data-v-d8fc0e55`]]),Le=r({name:`FishVoiceCard`,components:{ElAlert:_,ElButton:m,ElImage:g,CopyToClipboard:A,FontAwesomeIcon:k},props:{modelValue:{type:Object,required:!0}},computed:{sampleAudioUrl(){let e=this.modelValue?.samples;if(e?.length)return e[0]?.audio},voiceId(){let e=this.modelValue;return(e?.id||e?._id||e?.reference_id||``).toString()},coverSrc(){let e=this.modelValue?.cover_image;return e&&typeof e==`string`?e:void 0},createdAtLabel(){let e=this.modelValue?.created_at;if(e==null||e===``)return null;let t=typeof e==`number`?e:parseFloat(String(e));return!Number.isFinite(t)||t<=0?null:this.$dayjs.format(``+new Date(t*1e3))}},methods:{onUseVoice(){let e=this.voiceId;e&&(this.$store.commit(`fish/setConfig`,{...this.$store.state.fish?.config,reference_id:e}),this.$router.push({name:te}))}}}),Re={class:`card`},ze={class:`left`},Be={class:`main`},Ve={class:`header`},He={class:`title`},Ue={key:0,class:`datetime`},We={key:0,class:`description`},Ge={key:1,class:`sample mt-2`},Ke=[`src`],qe={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Je={key:1,class:`text-[var(--el-text-color-regular)] text-xs mb-0`},Ye={class:`operations mt-2`};function Xe(e,r,s,ee,m,h){let g=f(`el-image`),_=f(`font-awesome-icon`),v=f(`copy-to-clipboard`),y=f(`el-alert`),b=f(`el-button`);return l(),t(`div`,Re,[n(`div`,ze,[e.coverSrc?(l(),a(g,{key:0,src:e.coverSrc,class:`cover`,fit:`cover`},{error:p(()=>[o(g,{src:`https://cdn.acedata.cloud/e40fccc727.png`,class:`cover fallback`,fit:`cover`})]),placeholder:p(()=>[...r[0]||=[n(`div`,{class:`cover placeholder`},null,-1)]]),_:1},8,[`src`])):(l(),a(g,{key:1,src:`https://cdn.acedata.cloud/e40fccc727.png`,class:`cover fallback`,fit:`cover`}))]),n(`div`,Be,[n(`div`,Ve,[n(`span`,He,c(e.modelValue?.title||e.$t(`fish.name.untitledVoice`)),1),e.createdAtLabel?(l(),t(`span`,Ue,c(e.createdAtLabel),1)):d(``,!0)]),e.modelValue?.description?(l(),t(`p`,We,c(e.modelValue?.description),1)):d(``,!0),e.sampleAudioUrl?(l(),t(`div`,Ge,[n(`audio`,{src:e.sampleAudioUrl,controls:``,preload:`metadata`,class:`w-full`},null,8,Ke)])):d(``,!0),o(y,{closable:!1,class:`mt-2 success`},{default:p(()=>[e.voiceId?(l(),t(`p`,qe,[o(_,{icon:`fa-solid fa-microphone`,class:`mr-1`}),i(` `+c(e.$t(`fish.name.referenceId`))+`: `+c(e.voiceId)+` `,1),o(v,{content:e.voiceId},null,8,[`content`])])):d(``,!0),e.modelValue?.visibility?(l(),t(`p`,Je,[o(_,{icon:`fa-solid fa-eye`,class:`mr-1`}),i(` `+c(e.$t(`fish.name.visibility`))+`: `+c(e.modelValue?.visibility),1)])):d(``,!0)]),_:1}),n(`div`,Ye,[o(b,{type:`primary`,size:`small`,plain:``,disabled:!e.voiceId,onClick:u(e.onUseVoice,[`stop`])},{default:p(()=>[o(_,{icon:`fa-solid fa-volume-high`,class:`mr-1`}),i(` `+c(e.$t(`fish.button.useVoice`)),1)]),_:1},8,[`disabled`,`onClick`])])])])}var Ze=r({name:`FishModelListPanel`,components:{VoiceCard:w(Le,[[`render`,Xe],[`__scopeId`,`data-v-629e2d04`]]),BotPlaceholder:j,FontAwesomeIcon:k},props:{loading:{type:Boolean,default:!1}},computed:{voices(){return this.$store.state.fish?.voices}}}),Qe={class:`model-list-panel flex flex-col h-full`},$e={class:`header`},et={class:`title`},tt={key:0,class:`count`},$={class:`body flex-1 min-h-0`},nt={key:0,class:`h-full`},rt={key:1,class:`w-full h-full flex flex-col items-center justify-center text-center px-6`},it={class:`empty-title`},at={class:`empty-hint`},ot={key:2,class:`w-full h-full overflow-y-auto pr-1`};function st(r,i,ee,u,p,m){let h=f(`bot-placeholder`),g=f(`font-awesome-icon`),_=f(`voice-card`);return l(),t(`div`,Qe,[n(`header`,$e,[n(`h2`,et,c(r.$t(`fish.title.myVoices`)),1),r.voices?.length?(l(),t(`span`,tt,c(r.voices?.length),1)):d(``,!0)]),n(`div`,$,[r.voices===void 0?(l(),t(`div`,nt,[o(h)])):r.voices.length===0?(l(),t(`div`,rt,[o(g,{icon:`fa-solid fa-microphone-lines`,class:`empty-icon`}),n(`p`,it,c(r.$t(`fish.title.noVoicesYet`)),1),n(`p`,at,c(r.$t(`fish.description.noVoicesYet`)),1)])):(l(),t(`div`,ot,[(l(!0),t(s,null,e(r.voices,e=>(l(),a(_,{key:e.id,"model-value":e},null,8,[`model-value`]))),128))]))])])}var ct=r({name:`FishModelIndex`,components:{ModelConfigPanel:Ie,Layout:M,ModelListPanel:w(Ze,[[`render`,st],[`__scopeId`,`data-v-4aab2294`]]),TabSwitcher:N},inject:[`initialized`],data(){return{loading:!1}},computed:{credential(){return this.$store.state.fish?.credential}},watch:{initialized:{async handler(e){e&&await this.onGetVoices()},immediate:!0}},async mounted(){await this.onGetService()},methods:{async onGetService(){await this.$store.dispatch(`fish/getService`)},async onGetVoices(){await this.$store.dispatch(`fish/getVoices`)},async onCreate(e){if(!T())return;let t=this.credential?.token;if(!t){console.error(`no token specified`);return}this.loading=!0,D.info(this.$t(`fish.message.creatingModel`));try{await E.createModel(e,{token:t}),D.success(this.$t(`fish.message.createModelSuccess`)),await this.onGetVoices()}catch(e){let t=e?.response?.data;t?.error?.code===`used_up`?D.error(this.$t(`fish.message.usedUp`)):D.error(t?.error?.message||this.$t(`fish.message.createModelFailed`))}finally{this.loading=!1}}}}),lt={class:`flex flex-col h-full`},ut={class:`flex-1 min-h-0`};function dt(e,t,r,i,s,ee){let c=f(`tab-switcher`),u=f(`model-config-panel`),d=f(`model-list-panel`),m=f(`layout`);return l(),a(m,null,{config:p(()=>[n(`div`,lt,[o(c),n(`div`,ut,[o(u,{onCreate:e.onCreate},null,8,[`onCreate`])])])]),result:p(()=>[o(d,{loading:e.loading},null,8,[`loading`])]),_:1})}var ft=w(ct,[[`render`,dt]]);export{ft as default};
1
+ import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Vt as ee,Wt as c,Z as l,b as u,k as d,tt as f,ut as p}from"./vendor-chart-BJCvKk8-.js";import{t as m}from"./button-BydTr5nV.js";import{t as h}from"./upload-DVDT-Mym.js";import{t as g}from"./image-DP8UKkgf.js";import{t as _}from"./alert-C51owb6L.js";import{n as v,r as y}from"./radio-3Hz7h3DR.js";import{t as b}from"./switch-BYCNj-tS.js";import{t as x}from"./vendor-axios-Ck2ffRoh.js";import"./constants-DReNd4Tz.js";import{Kr as S,Lr as C,O as w,Zt as T,an as E,tt as te,zr as D,zt as O}from"./index-DYe3FRur.js";import{t as k}from"./index.es-oA5jw_nk.js";import{t as A}from"./CopyToClipboard-CEWQPJuY.js";import{t as j}from"./BotPlaceholder-BvTX-Ru2.js";import{t as M}from"./Hailuo-0VSVVSCD.js";import{t as N}from"./TabSwitcher-CO9PBuXo.js";var P=4,F=90,I=r({name:`FishRecorder`,components:{ElButton:m,FontAwesomeIcon:k},emits:[`done`,`cancel`,`update:script`],data(){return{state:`idle`,scriptIndex:0,seconds:0,timerId:0,maxTimerId:0,mediaRecorder:null,stream:null,chunks:[],recordedBlob:null,recordedUrl:``,uploading:!1}},computed:{formattedTime(){let e=Math.floor(this.seconds/60),t=this.seconds%60;return`${e.toString().padStart(2,`0`)}:${t.toString().padStart(2,`0`)}`},currentScript(){let e=`fish.script.passage${this.scriptIndex%P+1}`;return this.$t(e)}},beforeUnmount(){this.cleanup()},mounted(){this.$emit(`update:script`,this.currentScript)},methods:{nextScript(){this.scriptIndex=(this.scriptIndex+1)%P,this.$emit(`update:script`,this.currentScript)},async startRecord(){if(!navigator.mediaDevices?.getUserMedia||typeof MediaRecorder>`u`){D.error(this.$t(`fish.message.recorderUnsupported`));return}try{this.stream=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(e){let t=e?.name===`NotAllowedError`||e?.name===`PermissionDeniedError`;D.error(this.$t(t?`fish.message.micDenied`:`fish.message.micError`));return}this.chunks=[];let e=this.pickMimeType();try{this.mediaRecorder=e?new MediaRecorder(this.stream,{mimeType:e}):new MediaRecorder(this.stream)}catch{this.mediaRecorder=new MediaRecorder(this.stream)}this.mediaRecorder.ondataavailable=e=>{e.data&&e.data.size>0&&this.chunks.push(e.data)},this.mediaRecorder.onstop=()=>{let e=new Blob(this.chunks,{type:this.mediaRecorder?.mimeType||`audio/webm`});this.recordedBlob=e,this.recordedUrl=URL.createObjectURL(e),this.state=`recorded`,this.releaseStream()},this.mediaRecorder.start(),this.state=`recording`,this.seconds=0,this.timerId=window.setInterval(()=>{this.seconds++},1e3),this.maxTimerId=window.setTimeout(()=>{this.state===`recording`&&this.stopRecord()},F*1e3)},stopRecord(){this.mediaRecorder&&this.mediaRecorder.state!==`inactive`&&this.mediaRecorder.stop(),window.clearInterval(this.timerId),window.clearTimeout(this.maxTimerId)},reset(){this.recordedUrl&&URL.revokeObjectURL(this.recordedUrl),this.recordedUrl=``,this.recordedBlob=null,this.state=`idle`,this.seconds=0},onCancel(){this.cleanup(),this.$emit(`cancel`)},cleanup(){this.stopRecord(),this.releaseStream(),this.recordedUrl&&URL.revokeObjectURL(this.recordedUrl)},releaseStream(){this.stream?.getTracks().forEach(e=>e.stop()),this.stream=null},pickMimeType(){for(let e of[`audio/webm;codecs=opus`,`audio/webm`,`audio/mp4`,`audio/ogg`])if(typeof MediaRecorder<`u`&&MediaRecorder.isTypeSupported?.(e))return e},extensionForMime(e){return e.includes(`webm`)?`webm`:e.includes(`mp4`)?`m4a`:e.includes(`ogg`)?`ogg`:e.includes(`wav`)?`wav`:`mp3`},async useRecording(){if(this.recordedBlob){if(this.seconds<3){D.warning(this.$t(`fish.message.recordingTooShort`));return}this.uploading=!0;try{let e=this.$store.state.token?.access,t=this.extensionForMime(this.recordedBlob.type||``),n=new File([this.recordedBlob],`recording-${Date.now()}.${t}`,{type:this.recordedBlob.type||`audio/webm`}),r=new FormData;r.append(`file`,n);let{data:i}=await x.post(`${C()}/api/v1/files/`,r,{headers:{Authorization:`Bearer ${e}`}}),a=i?.file_url;if(!a){D.error(this.$t(`fish.message.uploadError`));return}this.$emit(`done`,{url:a,text:this.currentScript})}catch(e){D.error(this.$t(`fish.message.uploadError`)),console.error(`recorder upload failed`,e)}finally{this.uploading=!1}}}}}),L={class:`recorder`},R={key:0,class:`script`},z={class:`script-header`},B={class:`label`},V={class:`script-text`},H={class:`controls`},U={class:`status`},W={class:`hint`},G={key:1,class:`preview`},K=[`src`],q={class:`preview-actions`},J={class:`footer`};function Y(e,r,s,u,m,h){let g=f(`font-awesome-icon`),_=f(`el-button`);return l(),t(`div`,L,[e.state===`recorded`?d(``,!0):(l(),t(`div`,R,[n(`div`,z,[o(g,{icon:`fa-solid fa-book-open`,class:`icon mr-1`}),n(`span`,B,c(e.$t(`fish.description.readScript`)),1),o(_,{link:``,size:`small`,class:`ml-auto`,disabled:e.state===`recording`,onClick:e.nextScript},{default:p(()=>[o(g,{icon:`fa-solid fa-shuffle`,class:`mr-1`}),i(` `+c(e.$t(`fish.button.nextScript`)),1)]),_:1},8,[`disabled`,`onClick`])]),n(`p`,V,c(e.currentScript),1)])),n(`div`,H,[e.state===`idle`?(l(),a(_,{key:0,type:`danger`,circle:``,size:`large`,title:e.$t(`fish.button.startRecord`),onClick:e.startRecord},{default:p(()=>[o(g,{icon:`fa-solid fa-microphone`})]),_:1},8,[`title`,`onClick`])):e.state===`recording`?(l(),a(_,{key:1,type:`warning`,circle:``,size:`large`,title:e.$t(`fish.button.stopRecord`),onClick:e.stopRecord},{default:p(()=>[o(g,{icon:`fa-solid fa-stop`})]),_:1},8,[`title`,`onClick`])):d(``,!0),n(`div`,U,[n(`span`,{class:ee([`timer`,e.state===`recording`?`live`:``])},c(e.formattedTime),3),n(`span`,W,c(e.state===`idle`?e.$t(`fish.description.recorderIdle`):e.state===`recording`?e.$t(`fish.description.recorderRecording`):e.$t(`fish.description.recorderRecorded`)),1)])]),e.state===`recorded`&&e.recordedUrl?(l(),t(`div`,G,[n(`audio`,{src:e.recordedUrl,controls:``,preload:`metadata`,class:`w-full`},null,8,K),n(`div`,q,[o(_,{size:`small`,disabled:e.uploading,onClick:e.reset},{default:p(()=>[o(g,{icon:`fa-solid fa-rotate-left`,class:`mr-1`}),i(` `+c(e.$t(`fish.button.reRecord`)),1)]),_:1},8,[`disabled`,`onClick`]),o(_,{size:`small`,type:`primary`,loading:e.uploading,onClick:e.useRecording},{default:p(()=>[o(g,{icon:`fa-solid fa-check`,class:`mr-1`}),i(` `+c(e.$t(`fish.button.useRecording`)),1)]),_:1},8,[`loading`,`onClick`])])])):d(``,!0),n(`div`,J,[o(_,{link:``,size:`small`,disabled:e.uploading||e.state===`recording`,onClick:e.onCancel},{default:p(()=>[i(c(e.$t(`fish.button.cancel`)),1)]),_:1},8,[`disabled`,`onClick`])])])}var X=w(I,[[`render`,Y],[`__scopeId`,`data-v-1958e4a1`]]),Z=50*1024*1024,Q=()=>({title:``,description:``,texts:``,voicesUrl:``,visibility:`unlist`,trainMode:`fast`,enhanceAudio:!0,generateSample:!1}),ne=r({name:`FishModelConfigPanel`,components:{ElButton:m,ElInput:S,ElRadioButton:v,ElRadioGroup:y,ElSwitch:b,ElUpload:h,FontAwesomeIcon:k,Recorder:X},mixins:[O],emits:[`create`],data(){return{form:Q(),fileList:[],uploading:!1,creating:!1,recording:!1,textsAuto:!0}},computed:{uploadUrl(){return C()+`/api/v1/files/`},uploadHeaders(){return{Authorization:`Bearer ${this.$store.state.token?.access}`}},canCreate(){return!!this.form.title.trim()&&!!this.form.voicesUrl&&!this.uploading&&!this.creating},supportsRecorder(){return!!(typeof navigator<`u`?navigator.mediaDevices:void 0)?.getUserMedia&&typeof MediaRecorder<`u`}},methods:{onBeforeUpload(e){return e.size>Z?(D.warning(this.$t(`fish.message.audioSizeExceed`)),!1):(this.uploading=!0,!0)},onExceed(){D.warning(this.$t(`fish.message.audioOnlyOne`))},onUploadError(){this.uploading=!1,D.error(this.$t(`fish.message.uploadError`))},onUploadSuccess(e,t,n){this.uploading=!1;let r=e?.file_url;if(!r){D.error(this.$t(`fish.message.uploadError`)),this.fileList=[];return}this.form.voicesUrl=r,this.fileList=n},onRecorded(e){this.form.voicesUrl=e.url,this.recording=!1,e.text&&this.textsAuto&&(this.form.texts=e.text)},onStartRecord(){this.recording=!0,this.textsAuto=!this.form.texts.trim()},onScriptChange(e){this.textsAuto&&this.recording&&(this.form.texts=e)},onTextsInput(){this.textsAuto=!1},clearAudio(){this.form.voicesUrl=``,this.fileList=[]},onCreate(){let e=this.form.title.trim();if(!e){D.warning(this.$t(`fish.message.titleRequired`));return}if(!this.form.voicesUrl){D.warning(this.$t(`fish.message.audioRequired`));return}let t={title:e,voices:this.form.voicesUrl,visibility:this.form.visibility,train_mode:this.form.trainMode,enhance_audio_quality:this.form.enhanceAudio,generate_sample:this.form.generateSample};this.form.description.trim()&&(t.description=this.form.description.trim()),this.form.texts.trim()&&(t.texts=[this.form.texts.trim()]),this.creating=!0,this.$emit(`create`,t),setTimeout(()=>{this.creating=!1,this.form=Q(),this.fileList=[]},600)}}}),re={class:`flex flex-col h-full`},ie={class:`flex-1 overflow-y-auto p-5`},ae={class:`field-block mb-4`},oe={class:`title font-bold`},se={class:`field-block mb-4`},ce={class:`flex items-baseline justify-between mb-1`},le={class:`title font-bold`},ue={key:0,class:`muted`},de={class:`hint`},fe={key:0,class:`audio-actions`},pe={key:1,class:`hint warn`},me={key:3,class:`mt-2`},he=[`src`],ge={class:`ready-actions`},_e={class:`field-block mb-4`},ve={class:`title font-bold`},ye={class:`hint`},be={class:`field-block mb-4`},xe={class:`title font-bold`},Se={class:`field-block mb-4`},Ce={class:`title font-bold`},we={class:`field-block mb-4`},Te={class:`title font-bold`},Ee={class:`field-block mb-3`},De={class:`field-row`},Oe={class:`title font-bold`},ke={class:`hint mt-0 mb-0`},Ae={class:`field-block mb-2`},je={class:`field-row`},Me={class:`title font-bold`},Ne={class:`hint mt-0 mb-0`},Pe={class:`flex flex-col items-center justify-center px-5 pb-5`};function Fe(e,r,s,ee,u,m){let h=f(`el-input`),g=f(`font-awesome-icon`),_=f(`el-button`),v=f(`el-upload`),y=f(`recorder`),b=f(`el-radio-button`),x=f(`el-radio-group`),S=f(`el-switch`);return l(),t(`div`,re,[n(`div`,ie,[n(`div`,ae,[n(`h2`,oe,[i(c(e.$t(`fish.name.voiceTitle`))+` `,1),r[9]||=n(`span`,{class:`required`},`*`,-1)]),o(h,{modelValue:e.form.title,"onUpdate:modelValue":r[0]||=t=>e.form.title=t,placeholder:e.$t(`fish.placeholder.voiceTitle`),maxlength:`60`},null,8,[`modelValue`,`placeholder`])]),n(`div`,se,[n(`div`,ce,[n(`h2`,le,[i(c(e.$t(`fish.name.referenceAudio`))+` `,1),r[10]||=n(`span`,{class:`required`},`*`,-1)]),!e.form.voicesUrl&&!e.recording?(l(),t(`span`,ue,c(e.$t(`fish.description.audioRequired`)),1)):d(``,!0)]),n(`p`,de,c(e.$t(`fish.description.uploadAudio`)),1),!e.form.voicesUrl&&!e.recording?(l(),t(`div`,fe,[o(v,{"file-list":e.fileList,"onUpdate:fileList":r[1]||=t=>e.fileList=t,name:`file`,limit:1,class:`upload-wrapper`,action:e.uploadUrl,accept:`.mp3,.wav,.m4a,.ogg,.webm,audio/*`,"show-file-list":!1,"on-exceed":e.onExceed,"on-error":e.onUploadError,"on-success":e.onUploadSuccess,"before-upload":e.onBeforeUpload,headers:e.uploadHeaders},{default:p(()=>[o(_,{type:`primary`,plain:``,round:``,loading:e.uploading},{default:p(()=>[o(g,{icon:`fa-solid fa-upload`,class:`icon mr-1`}),i(` `+c(e.$t(`fish.button.uploadAudio`)),1)]),_:1},8,[`loading`])]),_:1},8,[`file-list`,`action`,`on-exceed`,`on-error`,`on-success`,`before-upload`,`headers`]),o(_,{type:`primary`,round:``,disabled:!e.supportsRecorder,onClick:e.onStartRecord},{default:p(()=>[o(g,{icon:`fa-solid fa-microphone`,class:`icon mr-1`}),i(` `+c(e.$t(`fish.button.recordAudio`)),1)]),_:1},8,[`disabled`,`onClick`])])):d(``,!0),!e.supportsRecorder&&!e.form.voicesUrl&&!e.recording?(l(),t(`p`,pe,c(e.$t(`fish.message.recorderUnsupported`)),1)):d(``,!0),e.recording?(l(),a(y,{key:2,class:`mt-2`,onDone:e.onRecorded,onCancel:r[2]||=t=>e.recording=!1,"onUpdate:script":e.onScriptChange},null,8,[`onDone`,`onUpdate:script`])):d(``,!0),e.form.voicesUrl&&!e.recording?(l(),t(`div`,me,[n(`audio`,{src:e.form.voicesUrl,controls:``,preload:`metadata`,class:`w-full`},null,8,he),n(`div`,ge,[o(_,{link:``,size:`small`,onClick:e.clearAudio},{default:p(()=>[o(g,{icon:`fa-solid fa-rotate-left`,class:`mr-1`}),i(` `+c(e.$t(`fish.button.replaceAudio`)),1)]),_:1},8,[`onClick`])])])):d(``,!0)]),n(`div`,_e,[n(`h2`,ve,c(e.$t(`fish.name.audioTexts`)),1),n(`p`,ye,c(e.$t(`fish.description.audioTexts`)),1),o(h,{modelValue:e.form.texts,"onUpdate:modelValue":r[3]||=t=>e.form.texts=t,type:`textarea`,rows:2,placeholder:e.$t(`fish.placeholder.audioTexts`),maxlength:`500`,onInput:e.onTextsInput},null,8,[`modelValue`,`placeholder`,`onInput`])]),n(`div`,be,[n(`h2`,xe,c(e.$t(`fish.name.voiceDescription`)),1),o(h,{modelValue:e.form.description,"onUpdate:modelValue":r[4]||=t=>e.form.description=t,type:`textarea`,rows:2,placeholder:e.$t(`fish.placeholder.voiceDescription`),maxlength:`500`},null,8,[`modelValue`,`placeholder`])]),n(`div`,Se,[n(`h2`,Ce,c(e.$t(`fish.name.visibility`)),1),o(x,{modelValue:e.form.visibility,"onUpdate:modelValue":r[5]||=t=>e.form.visibility=t,size:`small`},{default:p(()=>[o(b,{label:`private`,value:`private`},{default:p(()=>[i(c(e.$t(`fish.value.private`)),1)]),_:1}),o(b,{label:`unlist`,value:`unlist`},{default:p(()=>[i(c(e.$t(`fish.value.unlist`)),1)]),_:1}),o(b,{label:`public`,value:`public`},{default:p(()=>[i(c(e.$t(`fish.value.public`)),1)]),_:1})]),_:1},8,[`modelValue`])]),n(`div`,we,[n(`h2`,Te,c(e.$t(`fish.name.trainMode`)),1),o(x,{modelValue:e.form.trainMode,"onUpdate:modelValue":r[6]||=t=>e.form.trainMode=t,size:`small`},{default:p(()=>[o(b,{label:`fast`,value:`fast`},{default:p(()=>[i(c(e.$t(`fish.value.trainModeFast`)),1)]),_:1}),o(b,{label:`precise`,value:`precise`},{default:p(()=>[i(c(e.$t(`fish.value.trainModePrecise`)),1)]),_:1})]),_:1},8,[`modelValue`])]),n(`div`,Ee,[n(`div`,De,[n(`h2`,Oe,c(e.$t(`fish.name.enhanceAudio`)),1),o(S,{modelValue:e.form.enhanceAudio,"onUpdate:modelValue":r[7]||=t=>e.form.enhanceAudio=t},null,8,[`modelValue`])]),n(`p`,ke,c(e.$t(`fish.description.enhanceAudio`)),1)]),n(`div`,Ae,[n(`div`,je,[n(`h2`,Me,c(e.$t(`fish.name.generateSample`)),1),o(S,{modelValue:e.form.generateSample,"onUpdate:modelValue":r[8]||=t=>e.form.generateSample=t},null,8,[`modelValue`])]),n(`p`,Ne,c(e.$t(`fish.description.generateSample`)),1)])]),n(`div`,Pe,[o(_,{type:`primary`,class:`btn w-full`,round:``,disabled:!e.canCreate||e.creating,loading:e.creating,onClick:e.onCreate},{default:p(()=>[o(g,{icon:`fa-solid fa-magic`,class:`mr-2`}),i(` `+c(e.$t(`fish.button.createModel`)),1)]),_:1},8,[`disabled`,`loading`,`onClick`])])])}var Ie=w(ne,[[`render`,Fe],[`__scopeId`,`data-v-d8fc0e55`]]),Le=r({name:`FishVoiceCard`,components:{ElAlert:_,ElButton:m,ElImage:g,CopyToClipboard:A,FontAwesomeIcon:k},props:{modelValue:{type:Object,required:!0}},computed:{sampleAudioUrl(){let e=this.modelValue?.samples;if(e?.length)return e[0]?.audio},voiceId(){let e=this.modelValue;return(e?.id||e?._id||e?.reference_id||``).toString()},coverSrc(){let e=this.modelValue?.cover_image;return e&&typeof e==`string`?e:void 0},createdAtLabel(){let e=this.modelValue?.created_at;if(e==null||e===``)return null;let t=typeof e==`number`?e:parseFloat(String(e));return!Number.isFinite(t)||t<=0?null:this.$dayjs.format(``+new Date(t*1e3))}},methods:{onUseVoice(){let e=this.voiceId;e&&(this.$store.commit(`fish/setConfig`,{...this.$store.state.fish?.config,reference_id:e}),this.$router.push({name:te}))}}}),Re={class:`card`},ze={class:`left`},Be={class:`main`},Ve={class:`header`},He={class:`title`},Ue={key:0,class:`datetime`},We={key:0,class:`description`},Ge={key:1,class:`sample mt-2`},Ke=[`src`],qe={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Je={key:1,class:`text-[var(--el-text-color-regular)] text-xs mb-0`},Ye={class:`operations mt-2`};function Xe(e,r,s,ee,m,h){let g=f(`el-image`),_=f(`font-awesome-icon`),v=f(`copy-to-clipboard`),y=f(`el-alert`),b=f(`el-button`);return l(),t(`div`,Re,[n(`div`,ze,[e.coverSrc?(l(),a(g,{key:0,src:e.coverSrc,class:`cover`,fit:`cover`},{error:p(()=>[o(g,{src:`https://cdn.acedata.cloud/e40fccc727.png`,class:`cover fallback`,fit:`cover`})]),placeholder:p(()=>[...r[0]||=[n(`div`,{class:`cover placeholder`},null,-1)]]),_:1},8,[`src`])):(l(),a(g,{key:1,src:`https://cdn.acedata.cloud/e40fccc727.png`,class:`cover fallback`,fit:`cover`}))]),n(`div`,Be,[n(`div`,Ve,[n(`span`,He,c(e.modelValue?.title||e.$t(`fish.name.untitledVoice`)),1),e.createdAtLabel?(l(),t(`span`,Ue,c(e.createdAtLabel),1)):d(``,!0)]),e.modelValue?.description?(l(),t(`p`,We,c(e.modelValue?.description),1)):d(``,!0),e.sampleAudioUrl?(l(),t(`div`,Ge,[n(`audio`,{src:e.sampleAudioUrl,controls:``,preload:`metadata`,class:`w-full`},null,8,Ke)])):d(``,!0),o(y,{closable:!1,class:`mt-2 success`},{default:p(()=>[e.voiceId?(l(),t(`p`,qe,[o(_,{icon:`fa-solid fa-microphone`,class:`mr-1`}),i(` `+c(e.$t(`fish.name.referenceId`))+`: `+c(e.voiceId)+` `,1),o(v,{content:e.voiceId},null,8,[`content`])])):d(``,!0),e.modelValue?.visibility?(l(),t(`p`,Je,[o(_,{icon:`fa-solid fa-eye`,class:`mr-1`}),i(` `+c(e.$t(`fish.name.visibility`))+`: `+c(e.modelValue?.visibility),1)])):d(``,!0)]),_:1}),n(`div`,Ye,[o(b,{type:`primary`,size:`small`,plain:``,disabled:!e.voiceId,onClick:u(e.onUseVoice,[`stop`])},{default:p(()=>[o(_,{icon:`fa-solid fa-volume-high`,class:`mr-1`}),i(` `+c(e.$t(`fish.button.useVoice`)),1)]),_:1},8,[`disabled`,`onClick`])])])])}var Ze=r({name:`FishModelListPanel`,components:{VoiceCard:w(Le,[[`render`,Xe],[`__scopeId`,`data-v-629e2d04`]]),BotPlaceholder:j,FontAwesomeIcon:k},props:{loading:{type:Boolean,default:!1}},computed:{voices(){return this.$store.state.fish?.voices}}}),Qe={class:`model-list-panel flex flex-col h-full`},$e={class:`header`},et={class:`title`},tt={key:0,class:`count`},$={class:`body flex-1 min-h-0`},nt={key:0,class:`h-full`},rt={key:1,class:`w-full h-full flex flex-col items-center justify-center text-center px-6`},it={class:`empty-title`},at={class:`empty-hint`},ot={key:2,class:`w-full h-full overflow-y-auto pr-1`};function st(r,i,ee,u,p,m){let h=f(`bot-placeholder`),g=f(`font-awesome-icon`),_=f(`voice-card`);return l(),t(`div`,Qe,[n(`header`,$e,[n(`h2`,et,c(r.$t(`fish.title.myVoices`)),1),r.voices?.length?(l(),t(`span`,tt,c(r.voices?.length),1)):d(``,!0)]),n(`div`,$,[r.voices===void 0?(l(),t(`div`,nt,[o(h)])):r.voices.length===0?(l(),t(`div`,rt,[o(g,{icon:`fa-solid fa-microphone-lines`,class:`empty-icon`}),n(`p`,it,c(r.$t(`fish.title.noVoicesYet`)),1),n(`p`,at,c(r.$t(`fish.description.noVoicesYet`)),1)])):(l(),t(`div`,ot,[(l(!0),t(s,null,e(r.voices,e=>(l(),a(_,{key:e.id,"model-value":e},null,8,[`model-value`]))),128))]))])])}var ct=r({name:`FishModelIndex`,components:{ModelConfigPanel:Ie,Layout:M,ModelListPanel:w(Ze,[[`render`,st],[`__scopeId`,`data-v-4aab2294`]]),TabSwitcher:N},inject:[`initialized`],data(){return{loading:!1}},computed:{credential(){return this.$store.state.fish?.credential}},watch:{initialized:{async handler(e){e&&await this.onGetVoices()},immediate:!0}},async mounted(){await this.onGetService()},methods:{async onGetService(){await this.$store.dispatch(`fish/getService`)},async onGetVoices(){await this.$store.dispatch(`fish/getVoices`)},async onCreate(e){if(!T())return;let t=this.credential?.token;if(!t){console.error(`no token specified`);return}this.loading=!0,D.info(this.$t(`fish.message.creatingModel`));try{await E.createModel(e,{token:t}),D.success(this.$t(`fish.message.createModelSuccess`)),await this.onGetVoices()}catch(e){let t=e?.response?.data;t?.error?.code===`used_up`?D.error(this.$t(`fish.message.usedUp`)):D.error(t?.error?.message||this.$t(`fish.message.createModelFailed`))}finally{this.loading=!1}}}}),lt={class:`flex flex-col h-full`},ut={class:`flex-1 min-h-0`};function dt(e,t,r,i,s,ee){let c=f(`tab-switcher`),u=f(`model-config-panel`),d=f(`model-list-panel`),m=f(`layout`);return l(),a(m,null,{config:p(()=>[n(`div`,lt,[o(c),n(`div`,ut,[o(u,{onCreate:e.onCreate},null,8,[`onCreate`])])])]),result:p(()=>[o(d,{loading:e.loading},null,8,[`loading`])]),_:1})}var ft=w(ct,[[`render`,dt]]);export{ft as default};