@arcblock/payment-service 1.29.12 → 1.29.13

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 (163) hide show
  1. package/dist/cf.js +13 -13
  2. package/dist/index.js +10 -2
  3. package/package.json +3 -3
  4. package/web/assets/{account-DrsnH5wP.js → account-BN9x94rB.js} +1 -1
  5. package/web/assets/{action-C2c0yWuW.js → action-B9qBcxnd.js} +1 -1
  6. package/web/assets/{actions-BEUwbsq1.js → actions-BYX1WnBr.js} +1 -1
  7. package/web/assets/{actions-C9AfME83.js → actions-Bal42Hlw.js} +1 -1
  8. package/web/assets/{actions-D2-s31n3.js → actions-BmYfP6Ex.js} +1 -1
  9. package/web/assets/{actions-DeCPtfTK.js → actions-BvdAKBBR.js} +1 -1
  10. package/web/assets/{actions-DXMceTgd.js → actions-C0iB0sUH.js} +1 -1
  11. package/web/assets/{actions-JHsqbHpB.js → actions-C8z5APgU.js} +1 -1
  12. package/web/assets/{actions-DtNZGZWf.js → actions-CHC4oZpy.js} +1 -1
  13. package/web/assets/{actions-izdZ2Mn4.js → actions-CYXoOOED.js} +1 -1
  14. package/web/assets/{actions--FNKSNIs.js → actions-DTY0f0j8.js} +1 -1
  15. package/web/assets/{add-price-TdXAR3NW.js → add-price-BxoCZ-Tz.js} +1 -1
  16. package/web/assets/{admin-BpFv3eF5.js → admin--WTDrdAF.js} +1 -1
  17. package/web/assets/{assign-DKRfmN7W.js → assign-BOWJRdk_.js} +1 -1
  18. package/web/assets/{attempts-BfbYfiJa.js → attempts-D5nVVL_6.js} +1 -1
  19. package/web/assets/browser-QPNAlSRH.js +1 -0
  20. package/web/assets/{change-payment-j5UC8_h0.js → change-payment-DXontAeB.js} +1 -1
  21. package/web/assets/{change-plan-CtXvsIDw.js → change-plan-BsSmbAiG.js} +1 -1
  22. package/web/assets/{click-boundary-Bi28Y0Fq.js → click-boundary-Cozpjijr.js} +1 -1
  23. package/web/assets/{connect-CXek4LAE.js → connect-Wm36BWSB.js} +1 -1
  24. package/web/assets/{copyable-CprMHdhV.js → copyable-Dn7WoFib.js} +1 -1
  25. package/web/assets/{create-B-Ubepl_.js → create-4PWfxWLb.js} +1 -1
  26. package/web/assets/{create-IaalYGmm.js → create-7bXG85gU.js} +1 -1
  27. package/web/assets/{create-BWviSWbC.js → create-B5JxFhZm.js} +1 -1
  28. package/web/assets/{create-BVt_sQ_7.js → create-B9rgbz0l.js} +1 -1
  29. package/web/assets/{create-C6jihslA.js → create-DRn34vtT.js} +1 -1
  30. package/web/assets/{create-jzl1m8ZK.js → create-DSvEFvVu.js} +1 -1
  31. package/web/assets/{credit-grant-item-list-DQcvdSRs.js → credit-grant-item-list-B_vTdJGs.js} +1 -1
  32. package/web/assets/{credit-overview-CPId2vzk.js → credit-overview-hFT3I5RJ.js} +1 -1
  33. package/web/assets/{currency-restrictions-Dsupz2ce.js → currency-restrictions-DummyP0l.js} +1 -1
  34. package/web/assets/{currency-select-C8j7QQMP.js → currency-select-3BZ7dBe5.js} +1 -1
  35. package/web/assets/{dayjs-DUNWtvju.js → dayjs-t9Apc5Bb.js} +1 -1
  36. package/web/assets/{description-BHxdy5I3.js → description-Ci4-GOSF.js} +1 -1
  37. package/web/assets/{detail-BkRkrKyw.js → detail-8cEd6DEn.js} +1 -1
  38. package/web/assets/{detail-BdC9VIc6.js → detail-BH-Vvu0W.js} +1 -1
  39. package/web/assets/{detail-DUAJzKsu.js → detail-BO6Agb-b.js} +1 -1
  40. package/web/assets/{detail-H0dkKVyS.js → detail-BWPA3PH8.js} +1 -1
  41. package/web/assets/{detail-DTXDMIR9.js → detail-BgYHeC3e.js} +1 -1
  42. package/web/assets/{detail-CHJqYZ0W.js → detail-Bt5iQMX3.js} +1 -1
  43. package/web/assets/{detail-De8PyTyx.js → detail-BzlOf80w.js} +1 -1
  44. package/web/assets/{detail-MgdgGj5J.js → detail-C3T6qeB-.js} +1 -1
  45. package/web/assets/{detail-D729Bgs6.js → detail-C3_ACSpn.js} +1 -1
  46. package/web/assets/{detail-C--ATvwm.js → detail-CIUyjUAi.js} +1 -1
  47. package/web/assets/{detail-BvcI9cB_.js → detail-CPyUedtO.js} +1 -1
  48. package/web/assets/{detail-CmIweOLE.js → detail-CQWsMU9x.js} +1 -1
  49. package/web/assets/{detail-B17BN6kU.js → detail-CwTgF8q3.js} +1 -1
  50. package/web/assets/{detail-Dzt5tfyZ.js → detail-D1VjwguC.js} +1 -1
  51. package/web/assets/{detail-DQj1mbhA.js → detail-D4H6jbI1.js} +1 -1
  52. package/web/assets/{detail-WAmPM6yq.js → detail-D6NtqUGL.js} +1 -1
  53. package/web/assets/{detail-CfvKZ7IV.js → detail-D8kasVEc.js} +1 -1
  54. package/web/assets/{detail-DOcm4Kqg.js → detail-DMTZKNwK.js} +1 -1
  55. package/web/assets/{detail-DqfxOHky.js → detail-DO-7MCEH.js} +1 -1
  56. package/web/assets/{detail-g6el9Fxj.js → detail-DQfl09aa.js} +1 -1
  57. package/web/assets/{detail-DD1YBtex.js → detail-DtDNi9LO.js} +1 -1
  58. package/web/assets/{detail-BJEqTXDS.js → detail-VwGSacR5.js} +1 -1
  59. package/web/assets/{detail-BJ-hl5PK.js → detail-XRs3LPkf.js} +1 -1
  60. package/web/assets/{drawer-form-CQjNFFWk.js → drawer-form-CSWrmdZI.js} +1 -1
  61. package/web/assets/{edit-DAU8AWzT.js → edit-Cr-QHEQs.js} +1 -1
  62. package/web/assets/{editor-vZvxDUTl.js → editor-BzrYE3Ds.js} +1 -1
  63. package/web/assets/{embed-ClYNqZbf.js → embed-Dj1y7Zwp.js} +1 -1
  64. package/web/assets/{filter-toolbar-VvmMATj0.js → filter-toolbar-DpJmPWVP.js} +1 -1
  65. package/web/assets/{form-Bro99BjK.js → form-BBQXYqsx.js} +1 -1
  66. package/web/assets/{form-4_MzglPj.js → form-BJdpcmEf.js} +1 -1
  67. package/web/assets/{form-Cuvruf4H.js → form-BiiiQfiO.js} +1 -1
  68. package/web/assets/{form-AFzUvoFE.js → form-DPTZI-Fw.js} +1 -1
  69. package/web/assets/{form-CnrBCyTJ.js → form-nz7nSyN7.js} +1 -1
  70. package/web/assets/{gas-kw2KMH1u.js → gas-BGJEvZ8T.js} +1 -1
  71. package/web/assets/{generateCategoricalChart-BCpuUeC_.js → generateCategoricalChart-DJ3AfbsA.js} +1 -1
  72. package/web/assets/{home-ZNJREzbw.js → home-DfyGtwPb.js} +1 -1
  73. package/web/assets/index-B3Jk6ppU.js +1 -0
  74. package/web/assets/{index-BHwID_s4.js → index-B8bk0Ojf.js} +1 -1
  75. package/web/assets/{index-BtWfmATr.js → index-BFVHrFpT.js} +1 -1
  76. package/web/assets/{index-CPFlZhA2.js → index-BHIDYW0u.js} +1 -1
  77. package/web/assets/{index-DZkpxY-C.js → index-BNcCDKM5.js} +1 -1
  78. package/web/assets/{index-eDERHpkr.js → index-BPTu0yg7.js} +1 -1
  79. package/web/assets/index-BS70xmCD.js +1 -0
  80. package/web/assets/{index-BRmN8ViQ.js → index-BXCq4SkL.js} +1 -1
  81. package/web/assets/{index-C3AP4jq0.js → index-BXtNZIry.js} +1 -1
  82. package/web/assets/{index-B4yaPb7B.js → index-Bfp56O3W.js} +4 -4
  83. package/web/assets/{index-CKPfOW6M.js → index-BgQwjOVK.js} +1 -1
  84. package/web/assets/{index-DY-g0BPU.js → index-BhMKRIqj.js} +1 -1
  85. package/web/assets/{index-Dju8k6mq.js → index-Bo_vcdD9.js} +1 -1
  86. package/web/assets/{index-Dh9agU9O.js → index-BoqL8izO.js} +1 -1
  87. package/web/assets/{index-DAen2-cr.js → index-BuuQy4UK.js} +1 -1
  88. package/web/assets/{index-Dze0CpfQ.js → index-CQ7Ml281.js} +1 -1
  89. package/web/assets/{index-C3Rh1SaB.js → index-CcREcO7K.js} +1 -1
  90. package/web/assets/index-Cd-8zjpb.js +1 -0
  91. package/web/assets/{index-mgPU1lyd.js → index-CjPQC4mk.js} +1 -1
  92. package/web/assets/{index-C-5n472s.js → index-Cve8Vvzh.js} +1 -1
  93. package/web/assets/{index-olGOY5KB.js → index-Cvgxrbh_.js} +1 -1
  94. package/web/assets/{index-D7pWd60Z.js → index-D6Qc93ry.js} +1 -1
  95. package/web/assets/{index-ASk8vU2H.js → index-DA2h2xQ0.js} +1 -1
  96. package/web/assets/{index-CiWvs3j9.js → index-DAJUVYVW.js} +1 -1
  97. package/web/assets/{index-DwDNPqjF.js → index-DGlYR3g5.js} +1 -1
  98. package/web/assets/{index-BjKRyxNQ.js → index-DNwHUtwI.js} +1 -1
  99. package/web/assets/index-DVKKpTqA.js +1 -0
  100. package/web/assets/{index-DNobX-Tr.js → index-DdZRyqZe.js} +1 -1
  101. package/web/assets/{index-CH_k9MVv.js → index-DkHezF0C.js} +1 -1
  102. package/web/assets/index-DsYh3Cg8.js +1 -0
  103. package/web/assets/{index-x7sBb6oM.js → index-DxJqoRNV.js} +1 -1
  104. package/web/assets/{index-oy7LrXGT.js → index-HSIuOZNi.js} +1 -1
  105. package/web/assets/{index-CPyGjEd3.js → index-Z5VIg59-.js} +2 -2
  106. package/web/assets/index-_Owi04Rb.js +1 -0
  107. package/web/assets/index-bj4dA1Ad.js +1 -0
  108. package/web/assets/{index-B4n6PvPu.js → index-vdswLk79.js} +1 -1
  109. package/web/assets/{index-D6gv9jHh.js → index-vs4D4-i_.js} +1 -1
  110. package/web/assets/{index.es-C2Q6Owow.js → index.es-oPgScGhn.js} +1 -1
  111. package/web/assets/{info-card-C9dRgztS.js → info-card-Xtng8th6.js} +1 -1
  112. package/web/assets/{info-metric-ukWq8INi.js → info-metric-DwDA6oTc.js} +1 -1
  113. package/web/assets/{info-row-CaPaNF4L.js → info-row-Cr8bdDz0.js} +1 -1
  114. package/web/assets/{info-row-group-Cxo-4Gk5.js → info-row-group-qhfbrxfY.js} +1 -1
  115. package/web/assets/{libphonenumber-CTvobi0D.js → libphonenumber-DjN-XRyW.js} +1 -1
  116. package/web/assets/{link-DsltSF2Q.js → link-Dhj5mzaG.js} +1 -1
  117. package/web/assets/{list-BzgF4i3i.js → list-0fajnTAx.js} +1 -1
  118. package/web/assets/{list-B2b-s8wM.js → list-B6NGNObl.js} +1 -1
  119. package/web/assets/{list-DtEjqlED.js → list-BaGkIr9x.js} +1 -1
  120. package/web/assets/{list-ZaBapEXW.js → list-CMRLDBem.js} +1 -1
  121. package/web/assets/{list-CvM46TsP.js → list-CQ5uQIra.js} +1 -1
  122. package/web/assets/{list-O_uCSLFq.js → list-CZbuS490.js} +1 -1
  123. package/web/assets/{list-YNWVqjwW.js → list-DiFKB2Fh.js} +1 -1
  124. package/web/assets/{list-Cd1O-aDi.js → list-qrTTpMns.js} +1 -1
  125. package/web/assets/{metadata-_hV0ZaVh.js → metadata-C5loY77S.js} +1 -1
  126. package/web/assets/{meter-event-CPVBpekF.js → meter-event-BUamJsml.js} +1 -1
  127. package/web/assets/{metrics-DVPdwpyf.js → metrics-qFgjQM5V.js} +1 -1
  128. package/web/assets/{overview-CGdVIJrJ.js → overview-Bbyl7SwX.js} +1 -1
  129. package/web/assets/{overview-CN59I5Sc.js → overview-DPA4NQjh.js} +1 -1
  130. package/web/assets/{past-due-C3PtU8uo.js → past-due-D4jJMcjq.js} +1 -1
  131. package/web/assets/{pay-XVdSNq__.js → pay-s4cR1nfz.js} +1 -1
  132. package/web/assets/{payment-method-info-D_qR04xC.js → payment-method-info-Cto4lYu0.js} +1 -1
  133. package/web/assets/preview-DV7989ox.js +1 -0
  134. package/web/assets/{preview-F3lma170.js → preview-DrU96XLI.js} +1 -1
  135. package/web/assets/{pricing-table-Bt2WljzE.js → pricing-table-BstRGwem.js} +1 -1
  136. package/web/assets/{pricing-table-D9FGYBVa.js → pricing-table-CwzRykLm.js} +1 -1
  137. package/web/assets/{product-select-_72p-5lF.js → product-select-VFuyl5ev.js} +1 -1
  138. package/web/assets/{recharge-CSlKshbU.js → recharge-Dlg-3474.js} +1 -1
  139. package/web/assets/{related-credit-grants-DnKdAit6.js → related-credit-grants-BxHOJRRa.js} +3 -3
  140. package/web/assets/{safe-did-address-CRTPYo34.js → safe-did-address-Bj0hfqCH.js} +1 -1
  141. package/web/assets/{source-data-viewer-D1GShrs5.js → source-data-viewer-DQnM31KB.js} +1 -1
  142. package/web/assets/{status-3Swm2gK5.js → status-DlEqz2pS.js} +1 -1
  143. package/web/assets/{subscription-BX00k6FU.js → subscription-BJxso5rX.js} +1 -1
  144. package/web/assets/{subscription-Bzeblscr.js → subscription-DzHzZLOA.js} +1 -1
  145. package/web/assets/table-CyJj8e85.js +1 -0
  146. package/web/assets/{tax-code-select-j2arPbaE.js → tax-code-select-CoXANTPX.js} +1 -1
  147. package/web/assets/{tax-utils-B8J0Kfnz.js → tax-utils-BF4tobIJ.js} +1 -1
  148. package/web/assets/{uploader-BLdAbLR6.js → uploader-CV9IVKh1.js} +1 -1
  149. package/web/assets/{usage-records-BAwNs1y8.js → usage-records-nONbPDaL.js} +1 -1
  150. package/web/assets/{util-B8B3fsMa.js → util-Dp629jKU.js} +1 -1
  151. package/web/assets/{vendor-arcblock-D1drrE7q.js → vendor-arcblock-D34ufhta.js} +1 -1
  152. package/web/assets/{vendor-blocklet-B67R14so.js → vendor-blocklet-B8V2HFST.js} +2 -2
  153. package/web/index.html +1 -1
  154. package/web/assets/browser-DF2vfpBa.js +0 -1
  155. package/web/assets/index-BMcnd_jZ.js +0 -1
  156. package/web/assets/index-BdbLl6St.js +0 -1
  157. package/web/assets/index-BjLJQRKY.js +0 -1
  158. package/web/assets/index-BkNCPnTn.js +0 -1
  159. package/web/assets/index-BlAwTTmu.js +0 -1
  160. package/web/assets/index-CDyxbCzc.js +0 -1
  161. package/web/assets/index-ChC-jsE2.js +0 -1
  162. package/web/assets/preview-Bdtbh-xk.js +0 -1
  163. package/web/assets/table-BN3WBnr3.js +0 -1
@@ -1 +1 @@
1
- import{j as e,B as x,a3 as w,ck as re,a2 as F,N as se,q as A,x as T,r as M,cD as ue,bp as X,bs as fe,bt as te,bg as pe,a1 as xe,aF as ge,A as W,aN as he,aM as ae,w as ye,z as ve,bv as je,Y as $,cA as be,bf as Ce}from"./vendor-mui-BXZut9Pz.js";import{V as G,Y as J,$ as _e,B as y,Z as Y,O as De,P as ie,H as ne}from"./vendor-blocklet-B67R14so.js";import{d as Q,aW as H,N as oe,e as _,k as Z,a as de,j as U,T as le,Y as we,n as ke,h as Se,F as Me}from"./index-B4yaPb7B.js";import{C as Ee}from"./copyable-CprMHdhV.js";import{I as K}from"./info-metric-ukWq8INi.js";import{I as z}from"./info-row-CaPaNF4L.js";import{I as Te}from"./info-row-group-Cxo-4Gk5.js";import{M as Ie}from"./editor-vZvxDUTl.js";import{M as Ae}from"./list-B2b-s8wM.js";import{M as Pe}from"./actions-DXMceTgd.js";import{S as B}from"./header-ivXuPt06.js";import{n as Ye,g as Le}from"./util-B8B3fsMa.js";import{L as R,a as Oe}from"./vendor-react-BPknnnEA.js";import{R as ze,A as Re,C as Ne,a as $e,D as Be,g as Fe}from"./overview-CGdVIJrJ.js";import{C as He}from"./link-DsltSF2Q.js";import{X as We,Y as Ue,T as Ge}from"./generateCategoricalChart-BCpuUeC_.js";import Ve from"./create-B-Ubepl_.js";import{I as qe}from"./info-card-C9dRgztS.js";import{P as Ke}from"./actions-C9AfME83.js";import{M as Xe}from"./form-Bro99BjK.js";import{D as Ze}from"./drawer-form-CQjNFFWk.js";import"./lodash-B4Ozcv0x.js";import"./form-CnrBCyTJ.js";import"./actions-BEUwbsq1.js";import"./click-boundary-Bi28Y0Fq.js";import"./currency-select-C8j7QQMP.js";import"./currency-GstdXsJf.js";import"./collapse-CSrlJ0eG.js";import"./form-AFzUvoFE.js";import"./product-select-_72p-5lF.js";import"./uploader-BLdAbLR6.js";import"./tax-code-select-j2arPbaE.js";import"./collapse-BvbJGg1V.js";import"./assign-DKRfmN7W.js";import"./edit-DAU8AWzT.js";const Je=c=>_.post("/api/meter-events",{event_name:c.event_name,payload:{customer_id:c.customer_id,value:c.value,subscription_id:c.subscription_id||void 0},timestamp:c.timestamp,identifier:`manual_${Date.now()}`,metadata:{source:"manual",created_by:"admin"},source_data:[{key:"origin",label:"created_by",value:"Admin",type:"text"}]}).then(a=>a.data);function Qe({open:c,onClose:a,meterId:d,customers:r,onSuccess:C}){const{t:n}=G(),{isMobile:m}=Q("md"),[i,g]=J({loading:!1,form:{customer_id:"",value:"",subscription_id:"",timestamp:new Date}}),k=l=>l.name||l.email||l.did||l.id,s=()=>{g({form:{customer_id:"",value:"",subscription_id:"",timestamp:new Date}}),a()},o=async()=>{if(!i.form.customer_id||!i.form.value){Y.error(n("admin.meterEvent.add.validation"));return}g({loading:!0});try{const p=(await _.get(`/api/meters/${d}`)).data;await Je({event_name:p.event_name,customer_id:i.form.customer_id,value:i.form.value,subscription_id:i.form.subscription_id,timestamp:y(i.form.timestamp).unix()}),Y.success(n("admin.meterEvent.add.success")),s(),C()}catch(l){console.error("Failed to add usage:",l),Y.error(Z(l))}finally{g({loading:!1})}};return e.jsx(_e,{open:c,onClose:s,maxWidth:"sm",fullWidth:!0,fullScreen:m,title:n("admin.meterEvent.add.title"),actions:e.jsxs(e.Fragment,{children:[e.jsx(T,{onClick:s,variant:"outlined",disabled:i.loading,children:n("common.cancel")}),e.jsx(T,{onClick:o,variant:"contained",disabled:i.loading,children:n("admin.meterEvent.add.submit")})]}),children:e.jsx(x,{children:e.jsxs(w,{spacing:3,children:[e.jsxs(x,{children:[e.jsx(H,{sx:{color:"text.primary"},children:n("admin.meterEvent.add.customerId")}),e.jsx(re,{options:r,getOptionLabel:k,value:r.find(l=>l.id===i.form.customer_id)||null,onChange:(l,p)=>g({form:{...i.form,customer_id:p?.id||""}}),renderOption:(l,p)=>e.jsxs(x,{component:"li",...l,sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(se,{src:oe(p.did,p?.updated_at?new Date(p.updated_at).toISOString():void 0,24),sx:{width:24,height:24},alt:k(p)}),k(p)]}),renderInput:l=>e.jsx(F,{...l,placeholder:n("admin.meterEvent.add.customerIdPlaceholder"),fullWidth:!0})})]}),e.jsxs(x,{children:[e.jsx(H,{sx:{color:"text.primary"},children:n("admin.meterEvent.add.value")}),e.jsx(F,{type:"number",fullWidth:!0,value:i.form.value,onChange:l=>g({form:{...i.form,value:l.target.value}}),placeholder:n("admin.meterEvent.add.valuePlaceholder")})]}),e.jsxs(x,{children:[e.jsx(H,{sx:{color:"text.primary"},children:n("admin.meterEvent.add.subscriptionId")}),e.jsx(F,{fullWidth:!0,value:i.form.subscription_id,onChange:l=>g({form:{...i.form,subscription_id:l.target.value}}),placeholder:n("admin.meterEvent.add.subscriptionIdPlaceholder")}),e.jsx(A,{variant:"caption",sx:{color:"text.secondary",mt:.5,display:"block"},children:n("admin.meterEvent.add.subscriptionIdHint")})]}),e.jsxs(x,{children:[e.jsx(H,{sx:{color:"text.primary"},children:n("admin.meterEvent.add.timestamp")}),e.jsx(F,{type:"datetime-local",fullWidth:!0,value:y(i.form.timestamp).format("YYYY-MM-DDTHH:mm"),onChange:l=>g({form:{...i.form,timestamp:new Date(l.target.value)}}),InputLabelProps:{shrink:!0}}),e.jsx(A,{variant:"caption",sx:{color:"text.secondary",mt:.5,display:"block"},children:n("admin.meterEvent.add.timestampHint")})]})]})})})}const et=(c,a={})=>{const d=new URLSearchParams;return d.append("meter_id",c),a.page!==void 0&&d.append("page",String(a.page)),a.pageSize!==void 0&&d.append("pageSize",String(a.pageSize)),a.start!==void 0&&d.append("start",String(a.start)),a.end!==void 0&&d.append("end",String(a.end)),a.customer_id&&d.append("customer_id",a.customer_id),_.get(`/api/meter-events?${d.toString()}`).then(r=>r.data)},tt=(c,a,d,r,C)=>{const n=new URLSearchParams;return n.append("meter_id",c),n.append("start",a.toString()),n.append("end",d.toString()),r&&n.append("customer_id",r),C&&n.append("granularity",C),_.get(`/api/meter-events/stats?${n.toString()}`).then(m=>m.data)},at=()=>_.get("/api/customers?limit=100").then(c=>c.data),nt=(c,a,d)=>{const r=[],C=y(c),n=y(a),m=y();if(d==="hour"){let i=C.startOf("hour");const g=n.isAfter(m)?m:n;for(;i.isBefore(g)||i.isSame(g,"hour");)r.push({date:i.format("HH:mm"),fullDate:i.format("YYYY-MM-DD HH:mm"),timestamp:i.unix().toString(),event_count:0,total_value:0}),i=i.add(1,"hour")}else{let i=C.startOf("day");const g=n.isAfter(m,"day")?m.startOf("day"):n;for(;i.isBefore(g)||i.isSame(g,"day");)r.push({date:i.format("MM/DD"),fullDate:i.format("YYYY-MM-DD"),timestamp:i.unix().toString(),event_count:0,total_value:0}),i=i.add(1,"day")}return r};function rt({meterId:c,paymentCurrency:a}){const{t:d}=G(),{isMobile:r}=Q("md"),{livemode:C}=de(),n=y().endOf("day").toDate(),[m,i]=De(`meter-events-${c}`,{defaultValue:{pageSize:10,page:1,start:y().subtract(30,"day").startOf("day").unix(),end:y().endOf("day").unix()}}),{data:g={list:[],count:0},refresh:k,loading:s}=ie(()=>et(c,m),{refreshDeps:[m]}),[o,l]=J({stats:[],customers:[],statsLoading:!1,anchorEl:null,startDate:y().subtract(30,"day").startOf("day").toDate(),endDate:n,selectedCustomer:null,chartType:"event_count",addUsageDialog:!1}),p=M.useMemo(()=>{const t=y(o.startDate);return y(o.endDate).diff(t,"day")===0?"hour":"day"},[o.startDate,o.endDate]),P=M.useMemo(()=>{if(o.statsLoading)return[];const t=nt(o.startDate,o.endDate,p);if(!o.stats.length)return t;const u=new Map;return o.stats.forEach(f=>{let D,q;p==="hour"?(D=y(f.timestamp).format("HH:mm"),q=y(f.timestamp).format("YYYY-MM-DD HH:mm")):(D=y(f.timestamp).format("MM/DD"),q=y(f.timestamp).format("YYYY-MM-DD")),u.set(D,{...f,date:D,fullDate:q})}),t.map(f=>u.get(f.date)||f)},[o.stats,o.statsLoading,o.startDate,o.endDate,p]),I=async()=>{l({statsLoading:!0});try{const t=await tt(c,y(o.startDate).unix(),y(o.endDate).unix(),o.selectedCustomer?.id,p);l({stats:t.list,statsLoading:!1})}catch(t){console.error("Failed to fetch stats:",t),l({statsLoading:!1})}},N=async()=>{try{const t=await at();if(l({customers:t.list}),m.customer_id&&t.list.length>0){const u=t.list.find(f=>f.id===m.customer_id);u&&l({selectedCustomer:u})}}catch(t){console.error("Failed to fetch customers:",t)}};M.useEffect(()=>{N()},[c]),M.useEffect(()=>{m?.start&&m?.end&&l({startDate:y.unix(m.start).toDate(),endDate:y.unix(m.end).toDate()})},[m?.start,m?.end]),M.useEffect(()=>{I()},[o.startDate,o.endDate,o.selectedCustomer,p]);const h=({page:t,rowsPerPage:u})=>{m.pageSize!==u?i(f=>({...f,pageSize:u,page:1})):m.page!==t+1&&i(f=>({...f,page:t+1}))},v=t=>{o.anchorEl?l({anchorEl:null}):l({anchorEl:t.currentTarget})},L=t=>{const u=y(t.startDate).startOf("day").unix(),f=y(t.endDate).endOf("day").unix();i(D=>({...D,start:u,end:f,page:1})),l({startDate:t.startDate,endDate:y(t.endDate).endOf("day").toDate(),anchorEl:null})},S=(t,u)=>{u!==null&&l({chartType:u})},O=t=>{i(u=>({...u,customer_id:t?.id,page:1})),l({selectedCustomer:t})},E=t=>t.name||t.email||t.did||t.id,b=()=>{l({addUsageDialog:!0})},j=()=>{l({addUsageDialog:!1})},V=()=>{k(),I()},ee=!!o.anchorEl,ce=ee?"date-range-picker-popover":void 0,me=[{label:d("admin.meter.events.value"),name:"value",options:{filter:!1,sort:!1,customBodyRenderLite:(t,u)=>{const f=g.list[u];if(!f)return null;const D=ne(f.payload.value||"0",a.decimal);return e.jsx(R,{to:`/admin/billing/${f.id}`,children:`${D} ${a.symbol}`})}}},{label:d("admin.meter.events.customer"),name:"customer",options:{filter:!1,sort:!1,customBodyRenderLite:(t,u)=>{const f=g.list[u];return!f||!f?.customer?"-":e.jsx(He,{customer:f.customer,size:"small"})}}},{label:d("admin.meter.events.subscription"),name:"subscription",options:{filter:!1,sort:!1,customBodyRenderLite:(t,u)=>{const f=g.list[u];if(!f)return"-";const D=f.payload?.subscription_id;return D?e.jsx(R,{to:`/admin/billing/${D}`,children:e.jsx(A,{variant:"body2",sx:{color:"text.link"},children:f?.subscription?.description||D})}):"-"}}},{label:d("admin.meter.events.reportTime"),name:"created_at",options:{filter:!1,sort:!1,customBodyRenderLite:(t,u)=>{const f=g.list[u];return e.jsx(R,{to:`/admin/billing/${f?.id}`,children:f?U(f.created_at):"-"})}}}];return e.jsxs(x,{children:[e.jsxs(x,{sx:{mb:3},children:[e.jsxs(w,{direction:r?"column":"row",spacing:2,sx:{alignItems:r?"stretch":"center",flexWrap:"wrap"},children:[e.jsxs(T,{variant:"outlined",startIcon:e.jsx(ue,{}),onClick:v,size:"large",sx:{minWidth:r?"100%":200,justifyContent:r?"flex-start":"center",color:"text.secondary",borderColor:"grey.300","&:hover":{borderColor:"primary.main"},backgroundColor:"grey.50"},children:[y(o.startDate).format("YYYY-MM-DD")," - ",y(o.endDate).format("YYYY-MM-DD")]}),e.jsx(re,{options:o.customers,getOptionLabel:E,value:o.selectedCustomer,onChange:(t,u)=>O(u),sx:{minWidth:r?"100%":200,flex:r?1:"none"},renderInput:t=>e.jsx(F,{...t,label:d("admin.meter.events.filterByCustomer"),size:"small"}),renderOption:(t,u)=>e.jsxs(x,{component:"li",...t,sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(se,{src:oe(u.did,u?.updated_at?new Date(u.updated_at).toISOString():void 0,24),sx:{width:24,height:24},alt:E(u)}),E(u)]})}),!C&&e.jsx(T,{variant:"outlined",startIcon:e.jsx(X,{}),onClick:b,sx:{minWidth:r?"100%":"auto",color:"text.link"},children:d("admin.meterEvent.add.button")})]}),e.jsx(x,{sx:{mt:2,display:"flex",justifyContent:r?"center":"flex-end"},children:e.jsxs(fe,{value:o.chartType,exclusive:!0,onChange:S,size:"small",sx:{width:r?"100%":"auto","& .MuiToggleButton-root":{flex:r?1:"none"}},children:[e.jsx(te,{value:"event_count",children:d("admin.meter.events.eventCount")}),e.jsx(te,{value:"total_value",children:d("admin.meter.events.totalValue")})]})})]}),e.jsx(pe,{sx:{mb:3},children:e.jsx(x,{sx:{height:r?250:300,position:"relative",pr:r?1:2,pl:r?.5:1},children:o.statsLoading?e.jsx(x,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0},children:e.jsx(xe,{variant:"rectangular",width:"100%",height:"100%"})}):e.jsx(ze,{width:"100%",height:"100%",children:e.jsxs(Re,{data:P,margin:{top:10,right:r?10:30,left:r?5:10,bottom:p==="hour"?r?50:60:r?30:40},children:[e.jsx(Ne,{strokeDasharray:"3 3"}),e.jsx(We,{dataKey:"date",tick:{fontSize:r?10:11},angle:p==="hour"?-45:0,textAnchor:p==="hour"?"end":"middle",height:p==="hour"?r?50:60:r?30:40,interval:(()=>{const t=P.length;return r?t>20?Math.floor(t/6):t>10?Math.floor(t/4):t>5?1:0:p==="hour"?t>24?Math.floor(t/12):t>12?1:0:t>30?Math.floor(t/15):t>15?1:0})()}),e.jsx(Ue,{tick:{fontSize:r?9:11},width:r?35:40,tickFormatter:t=>r&&t>=1e3?`${(t/1e3).toFixed(1)}k`:t.toString()}),e.jsx(Ge,{labelFormatter:t=>P.find(f=>f.date===t)?.fullDate||t,formatter:(t,u)=>[u==="event_count"?t:ne(t,a.decimal),d(u==="event_count"?"admin.meter.events.eventCount":"admin.meter.events.totalValue")],contentStyle:{fontSize:r?"12px":"14px",padding:r?"8px":"10px"}}),e.jsx($e,{type:"monotone",dataKey:o.chartType,stroke:o.chartType==="event_count"?"#8884d8":"#82ca9d",fill:o.chartType==="event_count"?"#8884d8":"#82ca9d",fillOpacity:.6,strokeWidth:r?1.5:2})]})})})}),e.jsx(x,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:e.jsx(A,{variant:"body2",sx:{color:"text.secondary"},children:d("admin.meter.events.count",{count:g.count})})}),e.jsx(le,{data:g.list,columns:me,onChange:h,options:{count:g.count,page:m.page-1,rowsPerPage:m.pageSize,responsive:r?"vertical":"standard"},loading:s,emptyNodeText:d("admin.meter.events.empty")}),e.jsx(ge,{id:ce,open:ee,anchorEl:o.anchorEl,onClose:()=>l({anchorEl:null}),anchorOrigin:{vertical:"bottom",horizontal:"right"},children:e.jsx(Be,{open:!0,toggle:v,maxDate:n,definedRanges:Fe(n.toISOString()),onChange:L})}),e.jsx(Qe,{open:o.addUsageDialog,onClose:j,meterId:c,customers:o.customers,paymentCurrency:a,onSuccess:V})]})}const st=c=>_.get(`/api/products?meter_id=${c}`).then(a=>a.data),it=c=>_.get(`/api/products?type=credit&meter_id=${c}`).then(a=>a.data);function ot({meterId:c,meter:a=void 0}){const{t:d,locale:r}=G(),{settings:C}=de(),[n,m]=M.useState([]),[i,g]=M.useState(!1),[k,s]=M.useState(!1),[o,l]=M.useState(null),[p,P]=M.useState("credit"),I=async(E=p)=>{g(!0),l(null);try{const b=E==="meter"?await st(c):await it(c);m(b.list)}catch(b){console.error("Failed to fetch products:",b),l("Failed to load products")}finally{g(!1)}};M.useEffect(()=>{I()},[c,p]);const N=(E,b)=>{P(b)},h=()=>{s(!0)},v=()=>{s(!1),I()};if(o)return e.jsx(W,{severity:"error",sx:{mt:1},children:o});const L=[{label:d("admin.product.name.label"),name:"name",options:{filter:!1,customBodyRenderLite:(E,b)=>{const j=n[b];if(!j)return null;const V=we(C.paymentMethods,j.prices[0]?.currency_id??"")||C.baseCurrency;return e.jsx(R,{to:`/admin/products/${j.id}`,children:e.jsx(qe,{name:j.name,description:Ye(j,V,r),logo:j.images[0]})})}}},{label:d("common.status"),name:"active",options:{filter:!1,customBodyRenderLite:(E,b)=>{const j=n[b];return j?e.jsx(R,{to:`/admin/products/${j.id}`,children:e.jsx(ke,{label:j?.active?"Active":"Archived",color:j?.active?"success":"default"})}):null}}},{label:d("common.createdAt"),name:"created_at",options:{sort:!1,customBodyRenderLite:(E,b)=>{const j=n[b];return j?e.jsx(R,{to:`/admin/products/${j.id}`,children:U(j.created_at)}):null}}},{label:d("common.actions"),name:"id",width:100,align:"center",options:{sort:!1,customBodyRenderLite:(E,b)=>{const j=n[b];return j?e.jsx(Ke,{data:j,onChange:()=>I()}):null}}}],O=p==="meter"?{text:d("admin.meter.products.emptyTip"),buttonText:d("admin.meter.products.create")}:{text:d("admin.meter.creditProducts.emptyTip"),buttonText:d("admin.creditProduct.create")};return e.jsxs(x,{children:[e.jsx(w,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsxs(he,{value:p,onChange:N,sx:{flex:"1 0 auto",maxWidth:"100%",fontSize:14,borderBottom:1,borderColor:"divider",".Mui-selected":{fontSize:"14px !important",color:"primary.main"}},children:[e.jsx(ae,{label:d("admin.meter.products.creditCharge"),value:"credit"}),e.jsx(ae,{label:d("admin.meter.products.meterService"),value:"meter"})]})}),e.jsx(w,{direction:"row",sx:{justifyContent:"flex-end",mb:2},children:e.jsx(T,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link",float:"right"},startIcon:e.jsx(X,{}),onClick:h,children:d(p==="meter"?"admin.meter.products.create":"admin.creditProduct.create")})}),e.jsx(le,{hasRowLink:!0,data:n,columns:L,options:{count:n.length,page:0,rowsPerPage:n.length,pagination:!1,search:!1,filter:!1,sort:!1,viewColumns:!1,download:!1,print:!1,selectableRows:"none"},loading:i,emptyNodeText:e.jsxs(x,{children:[e.jsx(A,{children:O.text}),e.jsx(T,{size:"small",variant:"text",startIcon:e.jsx(X,{}),onClick:h,sx:{mt:1,color:"text.link"},children:O.buttonText})]})}),k&&e.jsx(Ve,{open:k,onClose:v,onSubmit:()=>I(p),mode:p==="credit"?"credit":"standard",meterId:c,initialPrice:p==="meter"?{currency_id:a?.currency_id||"",priceModel:"credit_metered"}:{metadata:{credit_config:{currency_id:a?.currency_id||""}},name:a?.unit||""}})]})}const dt=c=>_.get(`/api/meters/${c}`).then(a=>a.data);function Ut(c){const{t:a}=G(),{isMobile:d}=Q(),r=Oe(),C=h=>{switch(h){case"sum":return a("admin.meter.aggregationMethod.sumHint");case"count":return a("admin.meter.aggregationMethod.countHint");case"last":return a("admin.meter.aggregationMethod.lastHint");default:return""}},[n,m]=J({editing:{metadata:!1,meter:!1},loading:{metadata:!1,meter:!1},creating:{product:!1,creditProduct:!1},tokenConfig:{name:"",symbol:"",tokenFactoryAddress:""}}),i=Se({defaultValues:{name:"",event_name:"",aggregation_method:"sum",unit:"",description:"",metadata:{},mode:"OffChain"}}),{loading:g,error:k,data:s,runAsync:o}=ie(()=>dt(c.id));if(k)return e.jsx(W,{severity:"error",children:k.message});if(g||!s)return e.jsx(ye,{});const l=async h=>{try{m(v=>({loading:{...v.loading,metadata:!0}})),await _.put(`/api/meters/${c.id}`,h),Y.success(a("common.saved")),o()}catch(v){console.error(v),Y.error(Z(v))}finally{m(v=>({loading:{...v.loading,metadata:!1}}))}},p=h=>{h==="delete"?r("/admin/billing/meters"):o()},P=()=>{m(h=>({editing:{...h.editing,metadata:!0}}))},I=()=>{const h=!!s.paymentCurrency?.token_config;i.reset({name:s.name,event_name:s.event_name,aggregation_method:s.aggregation_method,unit:s.unit,description:s.description||"",metadata:s.metadata||{},mode:h?"OnChain":"OffChain"}),m(v=>({editing:{...v.editing,meter:!0},tokenConfig:{name:"",symbol:"",tokenFactoryAddress:""}}))},N=async h=>{try{m(S=>({loading:{...S.loading,meter:!0}}));const v=s.paymentCurrency?.id,L=!!s.paymentCurrency?.token_config;if(v&&!L&&h.mode==="OnChain"){let{tokenFactoryAddress:S}=n.tokenConfig;if(!S&&n.tokenConfig.symbol){const{data:O}=await _.post("/api/credit-tokens",{name:n.tokenConfig.name,symbol:n.tokenConfig.symbol});S=O.address}S&&await _.put(`/api/payment-currencies/${v}/token-config`,{token_factory_address:S})}v&&L&&h.mode==="OffChain"&&await _.delete(`/api/payment-currencies/${v}/token-config`),delete h.mode,await _.put(`/api/meters/${c.id}`,h),Y.success(a("admin.meter.saved")),m(S=>({editing:{...S.editing,meter:!1}})),o()}catch(v){console.error(v),Y.error(Z(v))}finally{m(v=>({loading:{...v.loading,meter:!1}}))}};return e.jsxs(lt,{direction:"column",spacing:2.5,sx:{mb:4},children:[e.jsxs(x,{children:[s.status==="inactive"&&e.jsxs(W,{severity:"warning",sx:{mb:2},children:[e.jsx(ve,{children:a("admin.meter.inactive")}),a("admin.meter.inactiveTip")]}),e.jsxs(w,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(w,{direction:"row",onClick:()=>Le("/admin/meters"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(je,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(A,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:a("admin.meters")})]}),e.jsx(Pe,{data:s,variant:"normal",onChange:p})]}),e.jsxs(x,{sx:{mt:4,mb:3,display:"flex",gap:{xs:2,sm:2,md:5},flexWrap:"wrap",flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"}},children:[e.jsx(w,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsx(w,{direction:"row",spacing:1,sx:{alignItems:"center"},children:e.jsxs(w,{direction:"column",sx:{alignItems:"flex-start",justifyContent:"space-around"},children:[e.jsx(A,{variant:"h2",sx:{color:"text.primary"},children:s.name}),e.jsxs(A,{variant:"subtitle1",sx:{color:"text.lighter"},children:[s.event_name," • ",s.unit]})]})})}),e.jsxs(w,{className:"section-body",sx:{justifyContent:"flex-start",flexWrap:"wrap","hr.MuiDivider-root:last-child":{display:"none"},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:"flex-start",gap:{xs:1,sm:1,md:3}},children:[e.jsx(K,{label:a("common.id"),value:e.jsx(Ee,{text:c.id,style:{marginLeft:4}}),divider:!0}),e.jsx(K,{label:a("common.createdAt"),value:U(s.created_at),divider:!0}),s.paymentCurrency?.recharge_config?.base_price_id&&e.jsx(K,{label:a("admin.meter.rechargePackage.priceId"),tip:a("admin.meter.rechargePackage.tooltip",{name:s.paymentCurrency.name}),value:e.jsx(T,{variant:"text",size:"small",onClick:()=>r(`/admin/products/${s.paymentCurrency.recharge_config.base_price_id}`),sx:{p:0,minWidth:"auto",textAlign:"left",ml:.5,color:"text.link"},children:s.paymentCurrency.recharge_config.base_price_id}),divider:!0})]})]}),e.jsx($,{})]}),e.jsxs(w,{sx:{flexDirection:{xs:"column",lg:"row"},gap:{xs:2.5,md:4},".meter-column-1":{minWidth:{xs:"100%",lg:"600px"}},".meter-column-2":{width:{xs:"100%",md:"100%",lg:"320px"},maxWidth:{xs:"100%",md:"33%"}}},children:[e.jsxs(x,{className:"meter-column-1",sx:{flex:1,gap:2.5,display:"flex",flexDirection:"column"},children:[e.jsxs(x,{className:"section",sx:{containerType:"inline-size"},children:[e.jsx(B,{title:a("admin.details"),children:e.jsx(T,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},disabled:n.editing.meter,onClick:I,children:a("common.edit")})}),e.jsxs(Te,{sx:{display:"grid",gridTemplateColumns:{xs:"repeat(1, 1fr)",xl:"repeat(2, 1fr)"},"@container (min-width: 1000px)":{gridTemplateColumns:"repeat(2, 1fr)"},".info-row-wrapper":{gap:1,flexDirection:{xs:"column",xl:"row"},alignItems:{xs:"flex-start",xl:"center"},"@container (min-width: 1000px)":{flexDirection:"row",alignItems:"center"}}},children:[e.jsx(z,{label:a("admin.meter.name.label"),value:s.name}),e.jsx(z,{label:a("admin.meter.eventName.label"),value:s.event_name}),e.jsx(z,{label:a("admin.meter.aggregationMethod.label"),value:s.aggregation_method}),e.jsx(z,{label:a("admin.meter.unit.label"),value:s.unit}),e.jsx(z,{label:a("admin.meter.description.label"),value:s.description||"-"}),e.jsx(z,{label:a("common.updatedAt"),value:U(s.updated_at)})]})]}),e.jsx($,{}),e.jsxs(x,{className:"section",children:[e.jsx(B,{title:a("admin.meter.events.title")}),e.jsx(x,{className:"section-body",children:e.jsx(rt,{meterId:s.id,paymentCurrency:s.paymentCurrency})})]}),e.jsx($,{}),e.jsxs(x,{className:"section",children:[e.jsx(x,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:e.jsx(B,{title:a("admin.meter.products.title")})}),e.jsx(x,{className:"section-body",children:e.jsx(ot,{meterId:s.id,meter:s})})]})]}),d&&e.jsx($,{}),e.jsxs(x,{className:"meter-column-2",sx:{gap:2.5,display:"flex",flexDirection:"column"},children:[e.jsxs(x,{className:"section",children:[e.jsx(B,{title:a("admin.meter.usageGuide.title")}),e.jsx(x,{className:"section-body",children:e.jsx(W,{severity:"info",sx:{mb:2},children:e.jsx(A,{variant:"body2",children:a("admin.meter.usageGuide.tip",{eventName:s.event_name,aggregationMethodHint:C(s.aggregation_method),unit:s.unit})})})})]}),e.jsx($,{}),e.jsxs(x,{className:"section",children:[e.jsx(B,{title:a("common.metadata.label"),children:e.jsx(T,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},disabled:n.editing.metadata,onClick:P,children:a("common.edit")})}),e.jsxs(x,{className:"section-body",children:[e.jsx(Ae,{data:s.metadata,handleEditMetadata:P}),n.editing.metadata&&e.jsx(Ie,{data:s,loading:n.loading.metadata,onSave:l,onCancel:()=>m(h=>({editing:{...h.editing,metadata:!1}}))})]})]})]})]}),n.editing.meter&&e.jsx(Ze,{icon:e.jsx(be,{}),text:a("admin.meter.edit"),open:n.editing.meter,onClose:()=>m(h=>({editing:{...h.editing,meter:!1}})),width:640,addons:e.jsx(T,{variant:"contained",size:"small",disabled:n.loading.meter,onClick:i.handleSubmit(N),children:a("admin.meter.save")}),children:e.jsx(Me,{...i,children:e.jsx(Xe,{mode:"edit",paymentCurrency:s.paymentCurrency,tokenConfig:n.tokenConfig,onTokenConfigChange:h=>m({tokenConfig:h})})})})]})}const lt=Ce(w)``;export{Ut as default};
1
+ import{j as e,B as x,a3 as w,ck as re,a2 as F,N as se,q as A,x as T,r as M,cD as ue,bp as X,bs as fe,bt as te,bg as pe,a1 as xe,aF as ge,A as W,aN as he,aM as ae,w as ye,z as ve,bv as je,Y as $,cA as be,bf as Ce}from"./vendor-mui-BXZut9Pz.js";import{V as G,Y as J,$ as _e,B as y,Z as Y,O as De,P as ie,H as ne}from"./vendor-blocklet-B8V2HFST.js";import{d as Q,aW as H,N as oe,e as _,k as Z,a as de,j as U,T as le,Y as we,n as ke,h as Se,F as Me}from"./index-Bfp56O3W.js";import{C as Ee}from"./copyable-Dn7WoFib.js";import{I as K}from"./info-metric-DwDA6oTc.js";import{I as z}from"./info-row-Cr8bdDz0.js";import{I as Te}from"./info-row-group-qhfbrxfY.js";import{M as Ie}from"./editor-BzrYE3Ds.js";import{M as Ae}from"./list-B6NGNObl.js";import{M as Pe}from"./actions-C0iB0sUH.js";import{S as B}from"./header-ivXuPt06.js";import{n as Ye,g as Le}from"./util-Dp629jKU.js";import{L as R,a as Oe}from"./vendor-react-BPknnnEA.js";import{R as ze,A as Re,C as Ne,a as $e,D as Be,g as Fe}from"./overview-Bbyl7SwX.js";import{C as He}from"./link-Dhj5mzaG.js";import{X as We,Y as Ue,T as Ge}from"./generateCategoricalChart-DJ3AfbsA.js";import Ve from"./create-4PWfxWLb.js";import{I as qe}from"./info-card-Xtng8th6.js";import{P as Ke}from"./actions-Bal42Hlw.js";import{M as Xe}from"./form-BBQXYqsx.js";import{D as Ze}from"./drawer-form-CSWrmdZI.js";import"./lodash-B4Ozcv0x.js";import"./form-nz7nSyN7.js";import"./actions-BYX1WnBr.js";import"./click-boundary-Cozpjijr.js";import"./currency-select-3BZ7dBe5.js";import"./currency-GstdXsJf.js";import"./collapse-CSrlJ0eG.js";import"./form-DPTZI-Fw.js";import"./product-select-VFuyl5ev.js";import"./uploader-CV9IVKh1.js";import"./tax-code-select-CoXANTPX.js";import"./collapse-BvbJGg1V.js";import"./assign-BOWJRdk_.js";import"./edit-Cr-QHEQs.js";const Je=c=>_.post("/api/meter-events",{event_name:c.event_name,payload:{customer_id:c.customer_id,value:c.value,subscription_id:c.subscription_id||void 0},timestamp:c.timestamp,identifier:`manual_${Date.now()}`,metadata:{source:"manual",created_by:"admin"},source_data:[{key:"origin",label:"created_by",value:"Admin",type:"text"}]}).then(a=>a.data);function Qe({open:c,onClose:a,meterId:d,customers:r,onSuccess:C}){const{t:n}=G(),{isMobile:m}=Q("md"),[i,g]=J({loading:!1,form:{customer_id:"",value:"",subscription_id:"",timestamp:new Date}}),k=l=>l.name||l.email||l.did||l.id,s=()=>{g({form:{customer_id:"",value:"",subscription_id:"",timestamp:new Date}}),a()},o=async()=>{if(!i.form.customer_id||!i.form.value){Y.error(n("admin.meterEvent.add.validation"));return}g({loading:!0});try{const p=(await _.get(`/api/meters/${d}`)).data;await Je({event_name:p.event_name,customer_id:i.form.customer_id,value:i.form.value,subscription_id:i.form.subscription_id,timestamp:y(i.form.timestamp).unix()}),Y.success(n("admin.meterEvent.add.success")),s(),C()}catch(l){console.error("Failed to add usage:",l),Y.error(Z(l))}finally{g({loading:!1})}};return e.jsx(_e,{open:c,onClose:s,maxWidth:"sm",fullWidth:!0,fullScreen:m,title:n("admin.meterEvent.add.title"),actions:e.jsxs(e.Fragment,{children:[e.jsx(T,{onClick:s,variant:"outlined",disabled:i.loading,children:n("common.cancel")}),e.jsx(T,{onClick:o,variant:"contained",disabled:i.loading,children:n("admin.meterEvent.add.submit")})]}),children:e.jsx(x,{children:e.jsxs(w,{spacing:3,children:[e.jsxs(x,{children:[e.jsx(H,{sx:{color:"text.primary"},children:n("admin.meterEvent.add.customerId")}),e.jsx(re,{options:r,getOptionLabel:k,value:r.find(l=>l.id===i.form.customer_id)||null,onChange:(l,p)=>g({form:{...i.form,customer_id:p?.id||""}}),renderOption:(l,p)=>e.jsxs(x,{component:"li",...l,sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(se,{src:oe(p.did,p?.updated_at?new Date(p.updated_at).toISOString():void 0,24),sx:{width:24,height:24},alt:k(p)}),k(p)]}),renderInput:l=>e.jsx(F,{...l,placeholder:n("admin.meterEvent.add.customerIdPlaceholder"),fullWidth:!0})})]}),e.jsxs(x,{children:[e.jsx(H,{sx:{color:"text.primary"},children:n("admin.meterEvent.add.value")}),e.jsx(F,{type:"number",fullWidth:!0,value:i.form.value,onChange:l=>g({form:{...i.form,value:l.target.value}}),placeholder:n("admin.meterEvent.add.valuePlaceholder")})]}),e.jsxs(x,{children:[e.jsx(H,{sx:{color:"text.primary"},children:n("admin.meterEvent.add.subscriptionId")}),e.jsx(F,{fullWidth:!0,value:i.form.subscription_id,onChange:l=>g({form:{...i.form,subscription_id:l.target.value}}),placeholder:n("admin.meterEvent.add.subscriptionIdPlaceholder")}),e.jsx(A,{variant:"caption",sx:{color:"text.secondary",mt:.5,display:"block"},children:n("admin.meterEvent.add.subscriptionIdHint")})]}),e.jsxs(x,{children:[e.jsx(H,{sx:{color:"text.primary"},children:n("admin.meterEvent.add.timestamp")}),e.jsx(F,{type:"datetime-local",fullWidth:!0,value:y(i.form.timestamp).format("YYYY-MM-DDTHH:mm"),onChange:l=>g({form:{...i.form,timestamp:new Date(l.target.value)}}),InputLabelProps:{shrink:!0}}),e.jsx(A,{variant:"caption",sx:{color:"text.secondary",mt:.5,display:"block"},children:n("admin.meterEvent.add.timestampHint")})]})]})})})}const et=(c,a={})=>{const d=new URLSearchParams;return d.append("meter_id",c),a.page!==void 0&&d.append("page",String(a.page)),a.pageSize!==void 0&&d.append("pageSize",String(a.pageSize)),a.start!==void 0&&d.append("start",String(a.start)),a.end!==void 0&&d.append("end",String(a.end)),a.customer_id&&d.append("customer_id",a.customer_id),_.get(`/api/meter-events?${d.toString()}`).then(r=>r.data)},tt=(c,a,d,r,C)=>{const n=new URLSearchParams;return n.append("meter_id",c),n.append("start",a.toString()),n.append("end",d.toString()),r&&n.append("customer_id",r),C&&n.append("granularity",C),_.get(`/api/meter-events/stats?${n.toString()}`).then(m=>m.data)},at=()=>_.get("/api/customers?limit=100").then(c=>c.data),nt=(c,a,d)=>{const r=[],C=y(c),n=y(a),m=y();if(d==="hour"){let i=C.startOf("hour");const g=n.isAfter(m)?m:n;for(;i.isBefore(g)||i.isSame(g,"hour");)r.push({date:i.format("HH:mm"),fullDate:i.format("YYYY-MM-DD HH:mm"),timestamp:i.unix().toString(),event_count:0,total_value:0}),i=i.add(1,"hour")}else{let i=C.startOf("day");const g=n.isAfter(m,"day")?m.startOf("day"):n;for(;i.isBefore(g)||i.isSame(g,"day");)r.push({date:i.format("MM/DD"),fullDate:i.format("YYYY-MM-DD"),timestamp:i.unix().toString(),event_count:0,total_value:0}),i=i.add(1,"day")}return r};function rt({meterId:c,paymentCurrency:a}){const{t:d}=G(),{isMobile:r}=Q("md"),{livemode:C}=de(),n=y().endOf("day").toDate(),[m,i]=De(`meter-events-${c}`,{defaultValue:{pageSize:10,page:1,start:y().subtract(30,"day").startOf("day").unix(),end:y().endOf("day").unix()}}),{data:g={list:[],count:0},refresh:k,loading:s}=ie(()=>et(c,m),{refreshDeps:[m]}),[o,l]=J({stats:[],customers:[],statsLoading:!1,anchorEl:null,startDate:y().subtract(30,"day").startOf("day").toDate(),endDate:n,selectedCustomer:null,chartType:"event_count",addUsageDialog:!1}),p=M.useMemo(()=>{const t=y(o.startDate);return y(o.endDate).diff(t,"day")===0?"hour":"day"},[o.startDate,o.endDate]),P=M.useMemo(()=>{if(o.statsLoading)return[];const t=nt(o.startDate,o.endDate,p);if(!o.stats.length)return t;const u=new Map;return o.stats.forEach(f=>{let D,q;p==="hour"?(D=y(f.timestamp).format("HH:mm"),q=y(f.timestamp).format("YYYY-MM-DD HH:mm")):(D=y(f.timestamp).format("MM/DD"),q=y(f.timestamp).format("YYYY-MM-DD")),u.set(D,{...f,date:D,fullDate:q})}),t.map(f=>u.get(f.date)||f)},[o.stats,o.statsLoading,o.startDate,o.endDate,p]),I=async()=>{l({statsLoading:!0});try{const t=await tt(c,y(o.startDate).unix(),y(o.endDate).unix(),o.selectedCustomer?.id,p);l({stats:t.list,statsLoading:!1})}catch(t){console.error("Failed to fetch stats:",t),l({statsLoading:!1})}},N=async()=>{try{const t=await at();if(l({customers:t.list}),m.customer_id&&t.list.length>0){const u=t.list.find(f=>f.id===m.customer_id);u&&l({selectedCustomer:u})}}catch(t){console.error("Failed to fetch customers:",t)}};M.useEffect(()=>{N()},[c]),M.useEffect(()=>{m?.start&&m?.end&&l({startDate:y.unix(m.start).toDate(),endDate:y.unix(m.end).toDate()})},[m?.start,m?.end]),M.useEffect(()=>{I()},[o.startDate,o.endDate,o.selectedCustomer,p]);const h=({page:t,rowsPerPage:u})=>{m.pageSize!==u?i(f=>({...f,pageSize:u,page:1})):m.page!==t+1&&i(f=>({...f,page:t+1}))},v=t=>{o.anchorEl?l({anchorEl:null}):l({anchorEl:t.currentTarget})},L=t=>{const u=y(t.startDate).startOf("day").unix(),f=y(t.endDate).endOf("day").unix();i(D=>({...D,start:u,end:f,page:1})),l({startDate:t.startDate,endDate:y(t.endDate).endOf("day").toDate(),anchorEl:null})},S=(t,u)=>{u!==null&&l({chartType:u})},O=t=>{i(u=>({...u,customer_id:t?.id,page:1})),l({selectedCustomer:t})},E=t=>t.name||t.email||t.did||t.id,b=()=>{l({addUsageDialog:!0})},j=()=>{l({addUsageDialog:!1})},V=()=>{k(),I()},ee=!!o.anchorEl,ce=ee?"date-range-picker-popover":void 0,me=[{label:d("admin.meter.events.value"),name:"value",options:{filter:!1,sort:!1,customBodyRenderLite:(t,u)=>{const f=g.list[u];if(!f)return null;const D=ne(f.payload.value||"0",a.decimal);return e.jsx(R,{to:`/admin/billing/${f.id}`,children:`${D} ${a.symbol}`})}}},{label:d("admin.meter.events.customer"),name:"customer",options:{filter:!1,sort:!1,customBodyRenderLite:(t,u)=>{const f=g.list[u];return!f||!f?.customer?"-":e.jsx(He,{customer:f.customer,size:"small"})}}},{label:d("admin.meter.events.subscription"),name:"subscription",options:{filter:!1,sort:!1,customBodyRenderLite:(t,u)=>{const f=g.list[u];if(!f)return"-";const D=f.payload?.subscription_id;return D?e.jsx(R,{to:`/admin/billing/${D}`,children:e.jsx(A,{variant:"body2",sx:{color:"text.link"},children:f?.subscription?.description||D})}):"-"}}},{label:d("admin.meter.events.reportTime"),name:"created_at",options:{filter:!1,sort:!1,customBodyRenderLite:(t,u)=>{const f=g.list[u];return e.jsx(R,{to:`/admin/billing/${f?.id}`,children:f?U(f.created_at):"-"})}}}];return e.jsxs(x,{children:[e.jsxs(x,{sx:{mb:3},children:[e.jsxs(w,{direction:r?"column":"row",spacing:2,sx:{alignItems:r?"stretch":"center",flexWrap:"wrap"},children:[e.jsxs(T,{variant:"outlined",startIcon:e.jsx(ue,{}),onClick:v,size:"large",sx:{minWidth:r?"100%":200,justifyContent:r?"flex-start":"center",color:"text.secondary",borderColor:"grey.300","&:hover":{borderColor:"primary.main"},backgroundColor:"grey.50"},children:[y(o.startDate).format("YYYY-MM-DD")," - ",y(o.endDate).format("YYYY-MM-DD")]}),e.jsx(re,{options:o.customers,getOptionLabel:E,value:o.selectedCustomer,onChange:(t,u)=>O(u),sx:{minWidth:r?"100%":200,flex:r?1:"none"},renderInput:t=>e.jsx(F,{...t,label:d("admin.meter.events.filterByCustomer"),size:"small"}),renderOption:(t,u)=>e.jsxs(x,{component:"li",...t,sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(se,{src:oe(u.did,u?.updated_at?new Date(u.updated_at).toISOString():void 0,24),sx:{width:24,height:24},alt:E(u)}),E(u)]})}),!C&&e.jsx(T,{variant:"outlined",startIcon:e.jsx(X,{}),onClick:b,sx:{minWidth:r?"100%":"auto",color:"text.link"},children:d("admin.meterEvent.add.button")})]}),e.jsx(x,{sx:{mt:2,display:"flex",justifyContent:r?"center":"flex-end"},children:e.jsxs(fe,{value:o.chartType,exclusive:!0,onChange:S,size:"small",sx:{width:r?"100%":"auto","& .MuiToggleButton-root":{flex:r?1:"none"}},children:[e.jsx(te,{value:"event_count",children:d("admin.meter.events.eventCount")}),e.jsx(te,{value:"total_value",children:d("admin.meter.events.totalValue")})]})})]}),e.jsx(pe,{sx:{mb:3},children:e.jsx(x,{sx:{height:r?250:300,position:"relative",pr:r?1:2,pl:r?.5:1},children:o.statsLoading?e.jsx(x,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0},children:e.jsx(xe,{variant:"rectangular",width:"100%",height:"100%"})}):e.jsx(ze,{width:"100%",height:"100%",children:e.jsxs(Re,{data:P,margin:{top:10,right:r?10:30,left:r?5:10,bottom:p==="hour"?r?50:60:r?30:40},children:[e.jsx(Ne,{strokeDasharray:"3 3"}),e.jsx(We,{dataKey:"date",tick:{fontSize:r?10:11},angle:p==="hour"?-45:0,textAnchor:p==="hour"?"end":"middle",height:p==="hour"?r?50:60:r?30:40,interval:(()=>{const t=P.length;return r?t>20?Math.floor(t/6):t>10?Math.floor(t/4):t>5?1:0:p==="hour"?t>24?Math.floor(t/12):t>12?1:0:t>30?Math.floor(t/15):t>15?1:0})()}),e.jsx(Ue,{tick:{fontSize:r?9:11},width:r?35:40,tickFormatter:t=>r&&t>=1e3?`${(t/1e3).toFixed(1)}k`:t.toString()}),e.jsx(Ge,{labelFormatter:t=>P.find(f=>f.date===t)?.fullDate||t,formatter:(t,u)=>[u==="event_count"?t:ne(t,a.decimal),d(u==="event_count"?"admin.meter.events.eventCount":"admin.meter.events.totalValue")],contentStyle:{fontSize:r?"12px":"14px",padding:r?"8px":"10px"}}),e.jsx($e,{type:"monotone",dataKey:o.chartType,stroke:o.chartType==="event_count"?"#8884d8":"#82ca9d",fill:o.chartType==="event_count"?"#8884d8":"#82ca9d",fillOpacity:.6,strokeWidth:r?1.5:2})]})})})}),e.jsx(x,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:e.jsx(A,{variant:"body2",sx:{color:"text.secondary"},children:d("admin.meter.events.count",{count:g.count})})}),e.jsx(le,{data:g.list,columns:me,onChange:h,options:{count:g.count,page:m.page-1,rowsPerPage:m.pageSize,responsive:r?"vertical":"standard"},loading:s,emptyNodeText:d("admin.meter.events.empty")}),e.jsx(ge,{id:ce,open:ee,anchorEl:o.anchorEl,onClose:()=>l({anchorEl:null}),anchorOrigin:{vertical:"bottom",horizontal:"right"},children:e.jsx(Be,{open:!0,toggle:v,maxDate:n,definedRanges:Fe(n.toISOString()),onChange:L})}),e.jsx(Qe,{open:o.addUsageDialog,onClose:j,meterId:c,customers:o.customers,paymentCurrency:a,onSuccess:V})]})}const st=c=>_.get(`/api/products?meter_id=${c}`).then(a=>a.data),it=c=>_.get(`/api/products?type=credit&meter_id=${c}`).then(a=>a.data);function ot({meterId:c,meter:a=void 0}){const{t:d,locale:r}=G(),{settings:C}=de(),[n,m]=M.useState([]),[i,g]=M.useState(!1),[k,s]=M.useState(!1),[o,l]=M.useState(null),[p,P]=M.useState("credit"),I=async(E=p)=>{g(!0),l(null);try{const b=E==="meter"?await st(c):await it(c);m(b.list)}catch(b){console.error("Failed to fetch products:",b),l("Failed to load products")}finally{g(!1)}};M.useEffect(()=>{I()},[c,p]);const N=(E,b)=>{P(b)},h=()=>{s(!0)},v=()=>{s(!1),I()};if(o)return e.jsx(W,{severity:"error",sx:{mt:1},children:o});const L=[{label:d("admin.product.name.label"),name:"name",options:{filter:!1,customBodyRenderLite:(E,b)=>{const j=n[b];if(!j)return null;const V=we(C.paymentMethods,j.prices[0]?.currency_id??"")||C.baseCurrency;return e.jsx(R,{to:`/admin/products/${j.id}`,children:e.jsx(qe,{name:j.name,description:Ye(j,V,r),logo:j.images[0]})})}}},{label:d("common.status"),name:"active",options:{filter:!1,customBodyRenderLite:(E,b)=>{const j=n[b];return j?e.jsx(R,{to:`/admin/products/${j.id}`,children:e.jsx(ke,{label:j?.active?"Active":"Archived",color:j?.active?"success":"default"})}):null}}},{label:d("common.createdAt"),name:"created_at",options:{sort:!1,customBodyRenderLite:(E,b)=>{const j=n[b];return j?e.jsx(R,{to:`/admin/products/${j.id}`,children:U(j.created_at)}):null}}},{label:d("common.actions"),name:"id",width:100,align:"center",options:{sort:!1,customBodyRenderLite:(E,b)=>{const j=n[b];return j?e.jsx(Ke,{data:j,onChange:()=>I()}):null}}}],O=p==="meter"?{text:d("admin.meter.products.emptyTip"),buttonText:d("admin.meter.products.create")}:{text:d("admin.meter.creditProducts.emptyTip"),buttonText:d("admin.creditProduct.create")};return e.jsxs(x,{children:[e.jsx(w,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsxs(he,{value:p,onChange:N,sx:{flex:"1 0 auto",maxWidth:"100%",fontSize:14,borderBottom:1,borderColor:"divider",".Mui-selected":{fontSize:"14px !important",color:"primary.main"}},children:[e.jsx(ae,{label:d("admin.meter.products.creditCharge"),value:"credit"}),e.jsx(ae,{label:d("admin.meter.products.meterService"),value:"meter"})]})}),e.jsx(w,{direction:"row",sx:{justifyContent:"flex-end",mb:2},children:e.jsx(T,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link",float:"right"},startIcon:e.jsx(X,{}),onClick:h,children:d(p==="meter"?"admin.meter.products.create":"admin.creditProduct.create")})}),e.jsx(le,{hasRowLink:!0,data:n,columns:L,options:{count:n.length,page:0,rowsPerPage:n.length,pagination:!1,search:!1,filter:!1,sort:!1,viewColumns:!1,download:!1,print:!1,selectableRows:"none"},loading:i,emptyNodeText:e.jsxs(x,{children:[e.jsx(A,{children:O.text}),e.jsx(T,{size:"small",variant:"text",startIcon:e.jsx(X,{}),onClick:h,sx:{mt:1,color:"text.link"},children:O.buttonText})]})}),k&&e.jsx(Ve,{open:k,onClose:v,onSubmit:()=>I(p),mode:p==="credit"?"credit":"standard",meterId:c,initialPrice:p==="meter"?{currency_id:a?.currency_id||"",priceModel:"credit_metered"}:{metadata:{credit_config:{currency_id:a?.currency_id||""}},name:a?.unit||""}})]})}const dt=c=>_.get(`/api/meters/${c}`).then(a=>a.data);function Ut(c){const{t:a}=G(),{isMobile:d}=Q(),r=Oe(),C=h=>{switch(h){case"sum":return a("admin.meter.aggregationMethod.sumHint");case"count":return a("admin.meter.aggregationMethod.countHint");case"last":return a("admin.meter.aggregationMethod.lastHint");default:return""}},[n,m]=J({editing:{metadata:!1,meter:!1},loading:{metadata:!1,meter:!1},creating:{product:!1,creditProduct:!1},tokenConfig:{name:"",symbol:"",tokenFactoryAddress:""}}),i=Se({defaultValues:{name:"",event_name:"",aggregation_method:"sum",unit:"",description:"",metadata:{},mode:"OffChain"}}),{loading:g,error:k,data:s,runAsync:o}=ie(()=>dt(c.id));if(k)return e.jsx(W,{severity:"error",children:k.message});if(g||!s)return e.jsx(ye,{});const l=async h=>{try{m(v=>({loading:{...v.loading,metadata:!0}})),await _.put(`/api/meters/${c.id}`,h),Y.success(a("common.saved")),o()}catch(v){console.error(v),Y.error(Z(v))}finally{m(v=>({loading:{...v.loading,metadata:!1}}))}},p=h=>{h==="delete"?r("/admin/billing/meters"):o()},P=()=>{m(h=>({editing:{...h.editing,metadata:!0}}))},I=()=>{const h=!!s.paymentCurrency?.token_config;i.reset({name:s.name,event_name:s.event_name,aggregation_method:s.aggregation_method,unit:s.unit,description:s.description||"",metadata:s.metadata||{},mode:h?"OnChain":"OffChain"}),m(v=>({editing:{...v.editing,meter:!0},tokenConfig:{name:"",symbol:"",tokenFactoryAddress:""}}))},N=async h=>{try{m(S=>({loading:{...S.loading,meter:!0}}));const v=s.paymentCurrency?.id,L=!!s.paymentCurrency?.token_config;if(v&&!L&&h.mode==="OnChain"){let{tokenFactoryAddress:S}=n.tokenConfig;if(!S&&n.tokenConfig.symbol){const{data:O}=await _.post("/api/credit-tokens",{name:n.tokenConfig.name,symbol:n.tokenConfig.symbol});S=O.address}S&&await _.put(`/api/payment-currencies/${v}/token-config`,{token_factory_address:S})}v&&L&&h.mode==="OffChain"&&await _.delete(`/api/payment-currencies/${v}/token-config`),delete h.mode,await _.put(`/api/meters/${c.id}`,h),Y.success(a("admin.meter.saved")),m(S=>({editing:{...S.editing,meter:!1}})),o()}catch(v){console.error(v),Y.error(Z(v))}finally{m(v=>({loading:{...v.loading,meter:!1}}))}};return e.jsxs(lt,{direction:"column",spacing:2.5,sx:{mb:4},children:[e.jsxs(x,{children:[s.status==="inactive"&&e.jsxs(W,{severity:"warning",sx:{mb:2},children:[e.jsx(ve,{children:a("admin.meter.inactive")}),a("admin.meter.inactiveTip")]}),e.jsxs(w,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(w,{direction:"row",onClick:()=>Le("/admin/meters"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(je,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(A,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:a("admin.meters")})]}),e.jsx(Pe,{data:s,variant:"normal",onChange:p})]}),e.jsxs(x,{sx:{mt:4,mb:3,display:"flex",gap:{xs:2,sm:2,md:5},flexWrap:"wrap",flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"}},children:[e.jsx(w,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsx(w,{direction:"row",spacing:1,sx:{alignItems:"center"},children:e.jsxs(w,{direction:"column",sx:{alignItems:"flex-start",justifyContent:"space-around"},children:[e.jsx(A,{variant:"h2",sx:{color:"text.primary"},children:s.name}),e.jsxs(A,{variant:"subtitle1",sx:{color:"text.lighter"},children:[s.event_name," • ",s.unit]})]})})}),e.jsxs(w,{className:"section-body",sx:{justifyContent:"flex-start",flexWrap:"wrap","hr.MuiDivider-root:last-child":{display:"none"},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:"flex-start",gap:{xs:1,sm:1,md:3}},children:[e.jsx(K,{label:a("common.id"),value:e.jsx(Ee,{text:c.id,style:{marginLeft:4}}),divider:!0}),e.jsx(K,{label:a("common.createdAt"),value:U(s.created_at),divider:!0}),s.paymentCurrency?.recharge_config?.base_price_id&&e.jsx(K,{label:a("admin.meter.rechargePackage.priceId"),tip:a("admin.meter.rechargePackage.tooltip",{name:s.paymentCurrency.name}),value:e.jsx(T,{variant:"text",size:"small",onClick:()=>r(`/admin/products/${s.paymentCurrency.recharge_config.base_price_id}`),sx:{p:0,minWidth:"auto",textAlign:"left",ml:.5,color:"text.link"},children:s.paymentCurrency.recharge_config.base_price_id}),divider:!0})]})]}),e.jsx($,{})]}),e.jsxs(w,{sx:{flexDirection:{xs:"column",lg:"row"},gap:{xs:2.5,md:4},".meter-column-1":{minWidth:{xs:"100%",lg:"600px"}},".meter-column-2":{width:{xs:"100%",md:"100%",lg:"320px"},maxWidth:{xs:"100%",md:"33%"}}},children:[e.jsxs(x,{className:"meter-column-1",sx:{flex:1,gap:2.5,display:"flex",flexDirection:"column"},children:[e.jsxs(x,{className:"section",sx:{containerType:"inline-size"},children:[e.jsx(B,{title:a("admin.details"),children:e.jsx(T,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},disabled:n.editing.meter,onClick:I,children:a("common.edit")})}),e.jsxs(Te,{sx:{display:"grid",gridTemplateColumns:{xs:"repeat(1, 1fr)",xl:"repeat(2, 1fr)"},"@container (min-width: 1000px)":{gridTemplateColumns:"repeat(2, 1fr)"},".info-row-wrapper":{gap:1,flexDirection:{xs:"column",xl:"row"},alignItems:{xs:"flex-start",xl:"center"},"@container (min-width: 1000px)":{flexDirection:"row",alignItems:"center"}}},children:[e.jsx(z,{label:a("admin.meter.name.label"),value:s.name}),e.jsx(z,{label:a("admin.meter.eventName.label"),value:s.event_name}),e.jsx(z,{label:a("admin.meter.aggregationMethod.label"),value:s.aggregation_method}),e.jsx(z,{label:a("admin.meter.unit.label"),value:s.unit}),e.jsx(z,{label:a("admin.meter.description.label"),value:s.description||"-"}),e.jsx(z,{label:a("common.updatedAt"),value:U(s.updated_at)})]})]}),e.jsx($,{}),e.jsxs(x,{className:"section",children:[e.jsx(B,{title:a("admin.meter.events.title")}),e.jsx(x,{className:"section-body",children:e.jsx(rt,{meterId:s.id,paymentCurrency:s.paymentCurrency})})]}),e.jsx($,{}),e.jsxs(x,{className:"section",children:[e.jsx(x,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:e.jsx(B,{title:a("admin.meter.products.title")})}),e.jsx(x,{className:"section-body",children:e.jsx(ot,{meterId:s.id,meter:s})})]})]}),d&&e.jsx($,{}),e.jsxs(x,{className:"meter-column-2",sx:{gap:2.5,display:"flex",flexDirection:"column"},children:[e.jsxs(x,{className:"section",children:[e.jsx(B,{title:a("admin.meter.usageGuide.title")}),e.jsx(x,{className:"section-body",children:e.jsx(W,{severity:"info",sx:{mb:2},children:e.jsx(A,{variant:"body2",children:a("admin.meter.usageGuide.tip",{eventName:s.event_name,aggregationMethodHint:C(s.aggregation_method),unit:s.unit})})})})]}),e.jsx($,{}),e.jsxs(x,{className:"section",children:[e.jsx(B,{title:a("common.metadata.label"),children:e.jsx(T,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},disabled:n.editing.metadata,onClick:P,children:a("common.edit")})}),e.jsxs(x,{className:"section-body",children:[e.jsx(Ae,{data:s.metadata,handleEditMetadata:P}),n.editing.metadata&&e.jsx(Ie,{data:s,loading:n.loading.metadata,onSave:l,onCancel:()=>m(h=>({editing:{...h.editing,metadata:!1}}))})]})]})]})]}),n.editing.meter&&e.jsx(Ze,{icon:e.jsx(be,{}),text:a("admin.meter.edit"),open:n.editing.meter,onClose:()=>m(h=>({editing:{...h.editing,meter:!1}})),width:640,addons:e.jsx(T,{variant:"contained",size:"small",disabled:n.loading.meter,onClick:i.handleSubmit(N),children:a("admin.meter.save")}),children:e.jsx(Me,{...i,children:e.jsx(Xe,{mode:"edit",paymentCurrency:s.paymentCurrency,tokenConfig:n.tokenConfig,onTokenConfigChange:h=>m({tokenConfig:h})})})})]})}const lt=Ce(w)``;export{Ut as default};
@@ -1 +1 @@
1
- import{j as e,A as S,w as M,B as t,a3 as d,bv as T,q as p,Y as o,x as D,bf as L}from"./vendor-mui-BXZut9Pz.js";import{V as A,Y as F,P as W,Z as f}from"./vendor-blocklet-B67R14so.js";import{u as z,d as P,j as l,z as R,p as _,a_ as B,A as E,e as k,k as H}from"./index-B4yaPb7B.js";import{L as $}from"./vendor-react-BPknnnEA.js";import{C as G}from"./copyable-CprMHdhV.js";import{C as O}from"./currency-GstdXsJf.js";import{C as U}from"./link-DsltSF2Q.js";import{E as V}from"./list-CvM46TsP.js";import{I as i}from"./info-row-CaPaNF4L.js";import{I as q}from"./list-ZaBapEXW.js";import{M as Y}from"./editor-vZvxDUTl.js";import{M as Z}from"./list-B2b-s8wM.js";import{R as J}from"./list-BzgF4i3i.js";import{S as c}from"./header-ivXuPt06.js";import{S as K}from"./index-ASk8vU2H.js";import{P as Q,D as X,S as ee,V as se}from"./payment-method-info-D_qR04xC.js";import{S as ae}from"./metrics-DVPdwpyf.js";import{g as te}from"./util-B8B3fsMa.js";import{I as v}from"./info-row-group-Cxo-4Gk5.js";import"./table-BN3WBnr3.js";import"./cache-state-lld4zuDg.js";import"./filter-toolbar-VvmMATj0.js";import"./lodash-B4Ozcv0x.js";import"./product-select-_72p-5lF.js";import"./info-card-C9dRgztS.js";import"./action-C2c0yWuW.js";import"./actions-BEUwbsq1.js";import"./click-boundary-Bi28Y0Fq.js";import"./form-CnrBCyTJ.js";import"./actions-DeCPtfTK.js";import"./usage-records-BAwNs1y8.js";import"./generateCategoricalChart-BCpuUeC_.js";import"./info-metric-ukWq8INi.js";import"./status-3Swm2gK5.js";const ie=m=>k.get(`/api/subscriptions/${m}`).then(a=>a.data);function He(m){const{t:a}=A(),{session:N}=z(),{isMobile:h}=P(),[u,x]=F({adding:{price:!1},editing:{metadata:!1,product:!1},loading:{metadata:!1,price:!1,product:!1}}),{loading:C,error:y,data:s,runAsync:b}=W(()=>ie(m.id));if(y)return e.jsx(S,{severity:"error",children:y.message});if(C||!s)return e.jsx(M,{});const w=(n=>async j=>{try{x(r=>({loading:{...r.loading,[n]:!0}})),await k.put(`/api/subscriptions/${m.id}`,j).then(r=>r.data),f.success(a("common.saved")),b()}catch(r){console.error(r),f.error(H(r))}finally{x(r=>({loading:{...r.loading,[n]:!1}}))}})("metadata"),g=()=>{x(n=>({editing:{...n.editing,metadata:!0}}))},I=s?.serviceType==="credit"||s?.paymentCurrency?.type==="credit"||s?.items?.some(n=>n?.price?.product?.type==="credit"||n?.price?.metadata?.credit_config);return e.jsxs(ne,{direction:"column",spacing:2.5,sx:{mb:4},children:[e.jsxs(t,{children:[e.jsxs(d,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(d,{direction:"row",onClick:()=>te("/admin/billing/subscriptions"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(T,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(p,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:a("admin.subscriptions")})]}),e.jsx(K,{data:s,onChange:b,variant:"normal"})]}),e.jsxs(t,{sx:{mt:4,mb:3,display:"flex",gap:{xs:2,sm:2,md:5},flexWrap:"wrap",flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"}},children:[e.jsxs(d,{direction:"column",sx:{gap:1},children:[e.jsx(d,{direction:"row",sx:{alignItems:"center"},children:e.jsx(p,{variant:"h2",sx:{fontWeight:600},children:s.description})}),e.jsx(G,{text:m.id})]}),e.jsx(d,{className:"section-body",sx:{justifyContent:"flex-start",flexWrap:"wrap","hr.MuiDivider-root:last-child":{display:"none"},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:"flex-start",gap:{xs:1,sm:1,md:3}},children:e.jsx(ae,{subscription:s,mode:"admin"})})]}),e.jsx(o,{})]}),e.jsxs(d,{sx:{flexDirection:{xs:"column",lg:"row"},gap:{xs:2.5,md:4},".payment-link-column-1":{minWidth:{xs:"100%",lg:"600px"}},".payment-link-column-2":{width:{xs:"100%",md:"100%",lg:"320px"},maxWidth:{xs:"100%",md:"33%"}}},children:[e.jsxs(t,{className:"payment-link-column-1",sx:{flex:1,gap:2.5,display:"flex",flexDirection:"column"},children:[e.jsxs(t,{className:"section",sx:{containerType:"inline-size"},children:[e.jsx(c,{title:a("admin.details")}),e.jsxs(v,{sx:{display:"grid",gridTemplateColumns:{xs:"repeat(1, 1fr)",xl:"repeat(2, 1fr)"},"@container (min-width: 1000px)":{gridTemplateColumns:"repeat(2, 1fr)"},".info-row-wrapper":{gap:1,flexDirection:{xs:"column",xl:"row"},alignItems:{xs:"flex-start",xl:"center"},"@container (min-width: 1000px)":{flexDirection:"row",alignItems:"center"}},".currency-name":{color:"text.secondary"}},children:[e.jsx(i,{label:a("common.customer"),value:e.jsx(U,{customer:s.customer,size:h?"default":"small"})}),e.jsx(i,{label:a("common.createdAt"),value:l(s.created_at)}),e.jsx(i,{label:a("admin.subscription.currentPeriod"),value:[l(s.current_period_start*1e3),l(s.current_period_end*1e3)].join(" ~ ")}),e.jsx(i,{label:a("admin.subscription.trialingPeriod"),value:s.trial_end&&s.trial_start?[l(s.trial_start*1e3),l(s.trial_end*1e3)].join(" ~ "):""}),s.status==="paused"&&!!s.pause_collection?.resumes_at&&e.jsx(i,{label:a("common.resumesAt"),value:l(s.pause_collection.resumes_at*1e3)}),e.jsx(i,{label:a("admin.subscription.collectionMethod"),value:s.collection_method}),e.jsx(i,{label:a("admin.paymentCurrency.name"),value:e.jsx(O,{logo:s.paymentCurrency.logo,name:`${s.paymentCurrency.symbol} (${s.paymentMethod?.name})`})}),s.paymentMethodDetails&&e.jsx(i,{label:a("admin.subscription.payerAddress"),value:e.jsx(Q,{subscriptionId:s.id,customer:s.customer,paymentMethodDetails:s.paymentMethodDetails,editable:!1,paymentMethodType:s.paymentMethod?.type})}),s.payment_details&&R(s.payment_details,s.paymentMethod)&&e.jsx(i,{label:a("common.delegateTxHash"),value:e.jsx(_,{details:s.payment_details,method:s.paymentMethod})}),s.paymentMethod?.type==="arcblock"&&s.payment_details?.arcblock?.staking?.tx_hash&&e.jsx(i,{label:a("common.stakeTxHash"),value:e.jsx(_,{details:{arcblock:{tx_hash:s.payment_details?.arcblock?.staking?.tx_hash,payer:""}},method:s.paymentMethod})}),!!s.description&&e.jsx(i,{label:a("common.description"),value:s.description}),!!s.recovered_from&&e.jsx(i,{label:a("common.recoverFrom"),value:e.jsx($,{to:`/admin/billing/${s.recovered_from}`,target:"_blank",children:s.recovered_from})})]})]}),(s.payment_details?.google_play||s.payment_details?.app_store)&&e.jsxs(e.Fragment,{children:[e.jsx(o,{}),e.jsxs(t,{className:"section",sx:{containerType:"inline-size"},children:[e.jsx(c,{title:s.payment_details?.google_play?a("admin.subscription.iap.googlePlayTitle"):a("admin.subscription.iap.appStoreTitle")}),e.jsxs(v,{sx:{".info-row-value":{wordBreak:"break-all"}},children:[s.channel&&e.jsx(i,{label:a("admin.subscription.channel"),value:s.channel}),s.payment_details?.google_play&&e.jsxs(e.Fragment,{children:[e.jsx(i,{label:a("admin.subscription.iap.purchaseToken"),value:s.payment_details.google_play.purchase_token}),e.jsx(i,{label:a("admin.subscription.iap.orderId"),value:s.payment_details.google_play.order_id||"—"}),e.jsx(i,{label:a("admin.subscription.iap.productId"),value:s.payment_details.google_play.product_id}),e.jsx(i,{label:a("admin.subscription.iap.expiryTime"),value:s.payment_details.google_play.expiry_time_millis?l(Number(s.payment_details.google_play.expiry_time_millis)):"—"}),e.jsx(i,{label:a("admin.subscription.iap.environment"),value:s.payment_details.google_play.environment||s.environment||"—"})]}),s.payment_details?.app_store&&e.jsxs(e.Fragment,{children:[e.jsx(i,{label:a("admin.subscription.iap.originalTransactionId"),value:s.payment_details.app_store.original_transaction_id}),e.jsx(i,{label:a("admin.subscription.iap.transactionId"),value:s.payment_details.app_store.transaction_id||"—"}),e.jsx(i,{label:a("admin.subscription.iap.productId"),value:s.payment_details.app_store.product_id}),e.jsx(i,{label:a("admin.subscription.iap.expiryTime"),value:s.payment_details.app_store.expires_at?l(s.payment_details.app_store.expires_at*1e3):"—"}),e.jsx(i,{label:a("admin.subscription.iap.environment"),value:s.payment_details.app_store.environment||s.environment||"—"})]})]})]})]}),e.jsx(o,{}),s.discountStats&&e.jsxs(t,{className:"section",children:[e.jsx(p,{variant:"h3",className:"section-header",sx:{mb:1.5},children:a("admin.subscription.discount")}),e.jsx(t,{className:"section-body",children:e.jsx(X,{discountStats:s.discountStats})})]}),e.jsxs(t,{className:"section",children:[e.jsx(c,{title:a("admin.product.pricing")}),e.jsx(t,{className:"section-body",children:e.jsx(ee,{data:s.items,currency:s.paymentCurrency,mode:"admin"})})]}),(()=>{const n=s.items?.map(j=>j.price?.product?.vendor_config||[]).flat();return!n||n.length===0?null:e.jsxs(e.Fragment,{children:[e.jsx(o,{}),e.jsx(t,{className:"section",sx:{".section-header":{fontSize:{xs:"18px",md:"1.09375rem"}},".vendor-service-item":{maxWidth:"400px"}},children:e.jsx(se,{vendorServices:n,subscriptionId:s.id,isOwner:N?.user?.did===s.customer?.did,isCanceled:s.status==="canceled"})})]})})(),e.jsx(o,{sx:{my:1.5}}),I?e.jsxs(e.Fragment,{children:[e.jsxs(t,{className:"section",children:[e.jsx(p,{variant:"h3",className:"section-header",children:a("admin.creditGrants.tab")}),e.jsx(t,{className:"section-body",children:e.jsx(B,{customer_id:s.customer_id,subscription_id:s.id,mode:"dashboard"})})]}),e.jsxs(t,{className:"section",children:[e.jsx(p,{variant:"h3",className:"section-header",children:a("admin.creditTransactions.title")}),e.jsx(t,{className:"section-body",children:e.jsx(E,{customer_id:s.customer_id,subscription_id:s.id,includeGrants:!0,mode:"dashboard"})})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(t,{className:"section",children:[e.jsx(c,{title:a("admin.invoices")}),e.jsx(t,{className:"section-body",children:e.jsx(q,{features:{customer:!0,toolbar:!1},subscription_id:s.id,include_staking:!0})})]}),e.jsx(o,{}),e.jsxs(t,{className:"section",children:[e.jsx(c,{title:a("admin.refunds")}),e.jsx(t,{className:"section-body",children:e.jsx(J,{features:{customer:!0,toolbar:!1},subscription_id:s.id})})]})]}),e.jsx(o,{}),e.jsxs(t,{className:"section",children:[e.jsx(c,{title:a("admin.events.title")}),e.jsx(t,{className:"section-body",children:e.jsx(V,{features:{toolbar:!1},object_id:s.id})})]})]}),h&&e.jsx(o,{}),e.jsx(t,{className:"payment-link-column-2",sx:{gap:2.5,display:"flex",flexDirection:"column"},children:e.jsxs(t,{className:"section",children:[e.jsx(c,{title:a("common.metadata.label"),children:e.jsx(D,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},disabled:u.editing.metadata,onClick:g,children:a("common.edit")})}),e.jsxs(t,{className:"section-body",children:[e.jsx(Z,{data:s.metadata,handleEditMetadata:g}),u.editing.metadata&&e.jsx(Y,{data:s,loading:u.loading.metadata,onSave:w,onCancel:()=>x(n=>({editing:{...n.editing,metadata:!1}}))})]})]})})]})]})}const ne=L(d)``;export{He as default};
1
+ import{j as e,A as S,w as M,B as t,a3 as d,bv as T,q as p,Y as o,x as D,bf as L}from"./vendor-mui-BXZut9Pz.js";import{V as A,Y as F,P as W,Z as f}from"./vendor-blocklet-B8V2HFST.js";import{u as z,d as P,j as l,z as R,p as _,a_ as B,A as E,e as k,k as H}from"./index-Bfp56O3W.js";import{L as $}from"./vendor-react-BPknnnEA.js";import{C as G}from"./copyable-Dn7WoFib.js";import{C as O}from"./currency-GstdXsJf.js";import{C as U}from"./link-Dhj5mzaG.js";import{E as V}from"./list-CQ5uQIra.js";import{I as i}from"./info-row-Cr8bdDz0.js";import{I as q}from"./list-CMRLDBem.js";import{M as Y}from"./editor-BzrYE3Ds.js";import{M as Z}from"./list-B6NGNObl.js";import{R as J}from"./list-0fajnTAx.js";import{S as c}from"./header-ivXuPt06.js";import{S as K}from"./index-DA2h2xQ0.js";import{P as Q,D as X,S as ee,V as se}from"./payment-method-info-Cto4lYu0.js";import{S as ae}from"./metrics-qFgjQM5V.js";import{g as te}from"./util-Dp629jKU.js";import{I as v}from"./info-row-group-qhfbrxfY.js";import"./table-CyJj8e85.js";import"./cache-state-lld4zuDg.js";import"./filter-toolbar-DpJmPWVP.js";import"./lodash-B4Ozcv0x.js";import"./product-select-VFuyl5ev.js";import"./info-card-Xtng8th6.js";import"./action-B9qBcxnd.js";import"./actions-BYX1WnBr.js";import"./click-boundary-Cozpjijr.js";import"./form-nz7nSyN7.js";import"./actions-BvdAKBBR.js";import"./usage-records-nONbPDaL.js";import"./generateCategoricalChart-DJ3AfbsA.js";import"./info-metric-DwDA6oTc.js";import"./status-DlEqz2pS.js";const ie=m=>k.get(`/api/subscriptions/${m}`).then(a=>a.data);function He(m){const{t:a}=A(),{session:N}=z(),{isMobile:h}=P(),[u,x]=F({adding:{price:!1},editing:{metadata:!1,product:!1},loading:{metadata:!1,price:!1,product:!1}}),{loading:C,error:y,data:s,runAsync:b}=W(()=>ie(m.id));if(y)return e.jsx(S,{severity:"error",children:y.message});if(C||!s)return e.jsx(M,{});const w=(n=>async j=>{try{x(r=>({loading:{...r.loading,[n]:!0}})),await k.put(`/api/subscriptions/${m.id}`,j).then(r=>r.data),f.success(a("common.saved")),b()}catch(r){console.error(r),f.error(H(r))}finally{x(r=>({loading:{...r.loading,[n]:!1}}))}})("metadata"),g=()=>{x(n=>({editing:{...n.editing,metadata:!0}}))},I=s?.serviceType==="credit"||s?.paymentCurrency?.type==="credit"||s?.items?.some(n=>n?.price?.product?.type==="credit"||n?.price?.metadata?.credit_config);return e.jsxs(ne,{direction:"column",spacing:2.5,sx:{mb:4},children:[e.jsxs(t,{children:[e.jsxs(d,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(d,{direction:"row",onClick:()=>te("/admin/billing/subscriptions"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(T,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(p,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:a("admin.subscriptions")})]}),e.jsx(K,{data:s,onChange:b,variant:"normal"})]}),e.jsxs(t,{sx:{mt:4,mb:3,display:"flex",gap:{xs:2,sm:2,md:5},flexWrap:"wrap",flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"}},children:[e.jsxs(d,{direction:"column",sx:{gap:1},children:[e.jsx(d,{direction:"row",sx:{alignItems:"center"},children:e.jsx(p,{variant:"h2",sx:{fontWeight:600},children:s.description})}),e.jsx(G,{text:m.id})]}),e.jsx(d,{className:"section-body",sx:{justifyContent:"flex-start",flexWrap:"wrap","hr.MuiDivider-root:last-child":{display:"none"},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:"flex-start",gap:{xs:1,sm:1,md:3}},children:e.jsx(ae,{subscription:s,mode:"admin"})})]}),e.jsx(o,{})]}),e.jsxs(d,{sx:{flexDirection:{xs:"column",lg:"row"},gap:{xs:2.5,md:4},".payment-link-column-1":{minWidth:{xs:"100%",lg:"600px"}},".payment-link-column-2":{width:{xs:"100%",md:"100%",lg:"320px"},maxWidth:{xs:"100%",md:"33%"}}},children:[e.jsxs(t,{className:"payment-link-column-1",sx:{flex:1,gap:2.5,display:"flex",flexDirection:"column"},children:[e.jsxs(t,{className:"section",sx:{containerType:"inline-size"},children:[e.jsx(c,{title:a("admin.details")}),e.jsxs(v,{sx:{display:"grid",gridTemplateColumns:{xs:"repeat(1, 1fr)",xl:"repeat(2, 1fr)"},"@container (min-width: 1000px)":{gridTemplateColumns:"repeat(2, 1fr)"},".info-row-wrapper":{gap:1,flexDirection:{xs:"column",xl:"row"},alignItems:{xs:"flex-start",xl:"center"},"@container (min-width: 1000px)":{flexDirection:"row",alignItems:"center"}},".currency-name":{color:"text.secondary"}},children:[e.jsx(i,{label:a("common.customer"),value:e.jsx(U,{customer:s.customer,size:h?"default":"small"})}),e.jsx(i,{label:a("common.createdAt"),value:l(s.created_at)}),e.jsx(i,{label:a("admin.subscription.currentPeriod"),value:[l(s.current_period_start*1e3),l(s.current_period_end*1e3)].join(" ~ ")}),e.jsx(i,{label:a("admin.subscription.trialingPeriod"),value:s.trial_end&&s.trial_start?[l(s.trial_start*1e3),l(s.trial_end*1e3)].join(" ~ "):""}),s.status==="paused"&&!!s.pause_collection?.resumes_at&&e.jsx(i,{label:a("common.resumesAt"),value:l(s.pause_collection.resumes_at*1e3)}),e.jsx(i,{label:a("admin.subscription.collectionMethod"),value:s.collection_method}),e.jsx(i,{label:a("admin.paymentCurrency.name"),value:e.jsx(O,{logo:s.paymentCurrency.logo,name:`${s.paymentCurrency.symbol} (${s.paymentMethod?.name})`})}),s.paymentMethodDetails&&e.jsx(i,{label:a("admin.subscription.payerAddress"),value:e.jsx(Q,{subscriptionId:s.id,customer:s.customer,paymentMethodDetails:s.paymentMethodDetails,editable:!1,paymentMethodType:s.paymentMethod?.type})}),s.payment_details&&R(s.payment_details,s.paymentMethod)&&e.jsx(i,{label:a("common.delegateTxHash"),value:e.jsx(_,{details:s.payment_details,method:s.paymentMethod})}),s.paymentMethod?.type==="arcblock"&&s.payment_details?.arcblock?.staking?.tx_hash&&e.jsx(i,{label:a("common.stakeTxHash"),value:e.jsx(_,{details:{arcblock:{tx_hash:s.payment_details?.arcblock?.staking?.tx_hash,payer:""}},method:s.paymentMethod})}),!!s.description&&e.jsx(i,{label:a("common.description"),value:s.description}),!!s.recovered_from&&e.jsx(i,{label:a("common.recoverFrom"),value:e.jsx($,{to:`/admin/billing/${s.recovered_from}`,target:"_blank",children:s.recovered_from})})]})]}),(s.payment_details?.google_play||s.payment_details?.app_store)&&e.jsxs(e.Fragment,{children:[e.jsx(o,{}),e.jsxs(t,{className:"section",sx:{containerType:"inline-size"},children:[e.jsx(c,{title:s.payment_details?.google_play?a("admin.subscription.iap.googlePlayTitle"):a("admin.subscription.iap.appStoreTitle")}),e.jsxs(v,{sx:{".info-row-value":{wordBreak:"break-all"}},children:[s.channel&&e.jsx(i,{label:a("admin.subscription.channel"),value:s.channel}),s.payment_details?.google_play&&e.jsxs(e.Fragment,{children:[e.jsx(i,{label:a("admin.subscription.iap.purchaseToken"),value:s.payment_details.google_play.purchase_token}),e.jsx(i,{label:a("admin.subscription.iap.orderId"),value:s.payment_details.google_play.order_id||"—"}),e.jsx(i,{label:a("admin.subscription.iap.productId"),value:s.payment_details.google_play.product_id}),e.jsx(i,{label:a("admin.subscription.iap.expiryTime"),value:s.payment_details.google_play.expiry_time_millis?l(Number(s.payment_details.google_play.expiry_time_millis)):"—"}),e.jsx(i,{label:a("admin.subscription.iap.environment"),value:s.payment_details.google_play.environment||s.environment||"—"})]}),s.payment_details?.app_store&&e.jsxs(e.Fragment,{children:[e.jsx(i,{label:a("admin.subscription.iap.originalTransactionId"),value:s.payment_details.app_store.original_transaction_id}),e.jsx(i,{label:a("admin.subscription.iap.transactionId"),value:s.payment_details.app_store.transaction_id||"—"}),e.jsx(i,{label:a("admin.subscription.iap.productId"),value:s.payment_details.app_store.product_id}),e.jsx(i,{label:a("admin.subscription.iap.expiryTime"),value:s.payment_details.app_store.expires_at?l(s.payment_details.app_store.expires_at*1e3):"—"}),e.jsx(i,{label:a("admin.subscription.iap.environment"),value:s.payment_details.app_store.environment||s.environment||"—"})]})]})]})]}),e.jsx(o,{}),s.discountStats&&e.jsxs(t,{className:"section",children:[e.jsx(p,{variant:"h3",className:"section-header",sx:{mb:1.5},children:a("admin.subscription.discount")}),e.jsx(t,{className:"section-body",children:e.jsx(X,{discountStats:s.discountStats})})]}),e.jsxs(t,{className:"section",children:[e.jsx(c,{title:a("admin.product.pricing")}),e.jsx(t,{className:"section-body",children:e.jsx(ee,{data:s.items,currency:s.paymentCurrency,mode:"admin"})})]}),(()=>{const n=s.items?.map(j=>j.price?.product?.vendor_config||[]).flat();return!n||n.length===0?null:e.jsxs(e.Fragment,{children:[e.jsx(o,{}),e.jsx(t,{className:"section",sx:{".section-header":{fontSize:{xs:"18px",md:"1.09375rem"}},".vendor-service-item":{maxWidth:"400px"}},children:e.jsx(se,{vendorServices:n,subscriptionId:s.id,isOwner:N?.user?.did===s.customer?.did,isCanceled:s.status==="canceled"})})]})})(),e.jsx(o,{sx:{my:1.5}}),I?e.jsxs(e.Fragment,{children:[e.jsxs(t,{className:"section",children:[e.jsx(p,{variant:"h3",className:"section-header",children:a("admin.creditGrants.tab")}),e.jsx(t,{className:"section-body",children:e.jsx(B,{customer_id:s.customer_id,subscription_id:s.id,mode:"dashboard"})})]}),e.jsxs(t,{className:"section",children:[e.jsx(p,{variant:"h3",className:"section-header",children:a("admin.creditTransactions.title")}),e.jsx(t,{className:"section-body",children:e.jsx(E,{customer_id:s.customer_id,subscription_id:s.id,includeGrants:!0,mode:"dashboard"})})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(t,{className:"section",children:[e.jsx(c,{title:a("admin.invoices")}),e.jsx(t,{className:"section-body",children:e.jsx(q,{features:{customer:!0,toolbar:!1},subscription_id:s.id,include_staking:!0})})]}),e.jsx(o,{}),e.jsxs(t,{className:"section",children:[e.jsx(c,{title:a("admin.refunds")}),e.jsx(t,{className:"section-body",children:e.jsx(J,{features:{customer:!0,toolbar:!1},subscription_id:s.id})})]})]}),e.jsx(o,{}),e.jsxs(t,{className:"section",children:[e.jsx(c,{title:a("admin.events.title")}),e.jsx(t,{className:"section-body",children:e.jsx(V,{features:{toolbar:!1},object_id:s.id})})]})]}),h&&e.jsx(o,{}),e.jsx(t,{className:"payment-link-column-2",sx:{gap:2.5,display:"flex",flexDirection:"column"},children:e.jsxs(t,{className:"section",children:[e.jsx(c,{title:a("common.metadata.label"),children:e.jsx(D,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},disabled:u.editing.metadata,onClick:g,children:a("common.edit")})}),e.jsxs(t,{className:"section-body",children:[e.jsx(Z,{data:s.metadata,handleEditMetadata:g}),u.editing.metadata&&e.jsx(Y,{data:s,loading:u.loading.metadata,onSave:w,onCancel:()=>x(n=>({editing:{...n.editing,metadata:!1}}))})]})]})})]})]})}const ne=L(d)``;export{He as default};
@@ -1,4 +1,4 @@
1
- import{r as q,j as e,A as M,w as R,aT as V,ad as $,a3 as u,q as I,bH as K,$ as L,I as Z,ci as J,B as s,z as Q,bv as X,Y as j,x as U,bf as O}from"./vendor-mui-BXZut9Pz.js";import{V as G,Y as E,P as H,Z as w}from"./vendor-blocklet-B67R14so.js";import{f as N,e as C,k as S,a as ee,Y as te,d as re,j as W,aP as ie,bb as ne,T as ae,b8 as se}from"./index-B4yaPb7B.js";import{a as le,L as oe}from"./vendor-react-BPknnnEA.js";import{C as ce}from"./copyable-CprMHdhV.js";import{C as A}from"./currency-GstdXsJf.js";import{E as de}from"./list-CvM46TsP.js";import{I as z}from"./info-metric-ukWq8INi.js";import{I as d}from"./info-row-CaPaNF4L.js";import{I as F}from"./info-row-group-Cxo-4Gk5.js";import{M as me}from"./editor-vZvxDUTl.js";import{M as ue}from"./list-B2b-s8wM.js";import{A as pe}from"./add-price-TdXAR3NW.js";import{P as xe,E as ge}from"./actions-D2-s31n3.js";import{S as y}from"./header-ivXuPt06.js";import{g as he}from"./util-B8B3fsMa.js";import"./table-BN3WBnr3.js";import"./lodash-B4Ozcv0x.js";import"./form-CnrBCyTJ.js";import"./form-AFzUvoFE.js";import"./collapse-CSrlJ0eG.js";import"./product-select-_72p-5lF.js";import"./currency-select-C8j7QQMP.js";import"./info-card-C9dRgztS.js";import"./uploader-BLdAbLR6.js";import"./tax-code-select-j2arPbaE.js";import"./collapse-BvbJGg1V.js";import"./actions-BEUwbsq1.js";const fe=n=>C.get(`/api/prices/${n}/upsell`).then(t=>t.data);function je({price:n,onSelect:t,onAdd:g}){const{t:h}=G(),[m,c]=E({loading:!1,adding:!1,action:""}),{loading:p,error:b,data:o}=H(()=>fe(n.id)),r=q.useMemo(()=>{if(!o||o.length===0)return[];const l=n.currency_options?.map(v=>v.currency_id)||[],f=l.length;return o.filter(v=>v.currency_options.length===f&&v.currency_options.every(D=>l.includes(D.currency_id)))},[o,n.id]);if(b)return e.jsx(M,{severity:"error",children:b.message});if(p||!o)return e.jsx(R,{});const P=l=>{l.target.value&&l.target.value!=="empty"&&(l.target.value==="add"?c({action:"add"}):t(l.target.value))},T=async l=>{try{c({adding:!0}),await C.post("/api/prices",{...l,product_id:n.product_id}),w.success(h("common.saved")),g()}catch(f){throw console.error(f),w.error(S(f)),f}finally{c({adding:!1})}};return e.jsxs(e.Fragment,{children:[e.jsxs(V,{value:"empty",sx:{width:300},size:"small",onChange:P,MenuProps:{style:{maxHeight:480}},children:[e.jsx($,{value:"empty",children:e.jsx(u,{direction:"row",sx:{alignItems:"center"},children:e.jsx(I,{children:h("admin.price.find")})})}),e.jsx($,{value:"add",children:e.jsxs(u,{direction:"row",sx:{alignItems:"center"},children:[e.jsx(K,{}),e.jsx(I,{children:h("admin.price.add")})]})}),r.map(l=>e.jsx($,{value:l.id,children:N(l,n.currency||l.currency)},l.id))]}),m.action==="add"&&e.jsx(pe,{loading:m.adding,onSave:T,onCancel:()=>c({action:""})})]})}function ye({data:n,onChange:t}){const{settings:g}=ee(),[h,m]=E({loading:!1}),c=async()=>{try{m({loading:!0}),await C.put(`/api/prices/${n.id}`,{upsell:{upsells_to_id:""}}).then(o=>o.data),m({loading:!1}),t()}catch(o){console.error(o),w.error(S(o)),m({loading:!1})}},p=async o=>{try{m({loading:!0}),await C.put(`/api/prices/${n.id}`,{upsell:{upsells_to_id:o}}).then(r=>r.data),m({loading:!1}),t()}catch(r){console.error(r),w.error(S(r)),m({loading:!1})}};if(h.loading)return e.jsx(R,{});const b=te(g.paymentMethods,n?.currency_id||"")||g.baseCurrency;return n.upsell?.upsells_to_id?e.jsxs(u,{spacing:1,direction:"row",sx:{alignItems:"center"},children:[e.jsx(I,{children:N(n.upsell.upsells_to,b)}),e.jsx(Z,{size:"small",sx:{ml:1},onClick:c,children:e.jsx(J,{color:"error",sx:{opacity:.75}})})]}):e.jsx(je,{price:n,onSelect:p,onAdd:t})}function be({data:n,onChange:t}){return e.jsx(L,{container:!0,children:e.jsx(L,{size:{xs:12,md:12},children:e.jsx(d,{label:"",value:e.jsx(ye,{data:n,onChange:t}),showLabel:!1})})})}const ve=n=>C.get(`/api/prices/${n}`).then(t=>t.data);function Qe(n){const{t,locale:g}=G(),{isMobile:h}=re(),m=le(),[c,p]=E({adding:{price:!1},editing:{metadata:!1,price:!1},loading:{metadata:!1,price:!1}}),{loading:b,error:o,data:r,runAsync:P}=H(()=>ve(n.id));if(o)return e.jsx(M,{severity:"error",children:o.message});if(b||!r)return e.jsx(R,{});const T=i=>async x=>{try{p(a=>({loading:{...a.loading,[i]:!0}})),await C.put(`/api/prices/${n.id}`,x).then(a=>a.data),w.success(t("common.saved")),se("price.updated"),P()}catch(a){throw console.error(a),w.error(S(a)),a}finally{p(a=>({loading:{...a.loading,[i]:!1}}))}},l=T("metadata"),f=T("price"),v=i=>{i==="remove"?m("/admin/products"):P()},D=()=>{p(i=>({editing:{...i.editing,metadata:!0}}))},Y=i=>i==="recurring"?t("admin.price.types.recurring"):i==="one_time"?t("admin.price.types.onetime"):i;return e.jsxs(_e,{direction:"column",spacing:2.5,sx:{mb:4},children:[e.jsxs(s,{children:[r.active===!1&&e.jsxs(M,{severity:"warning",children:[e.jsx(Q,{children:t("admin.price.archived")}),t("admin.price.archivedTip")]}),r.locked&&e.jsx(M,{severity:"warning",sx:{mb:1},children:t("admin.price.locked")}),e.jsxs(u,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(u,{direction:"row",onClick:()=>he(`/admin/products/${r.product_id}`),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(X,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(I,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:t("admin.products")})]}),e.jsx(xe,{data:r,onChange:v,variant:"normal"})]}),e.jsxs(s,{sx:{mt:4,mb:3,display:"flex",gap:{xs:2,sm:2,md:5},flexWrap:"wrap",flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"}},children:[e.jsxs(u,{direction:"column",sx:{gap:1},children:[e.jsxs(I,{variant:"h2",sx:{fontWeight:600},children:["Price for ",r.product.name]}),e.jsx(ce,{text:n.id,style:{marginLeft:4}})]}),e.jsxs(u,{className:"section-body",sx:{justifyContent:"flex-start",flexWrap:"wrap","hr.MuiDivider-root:last-child":{display:"none"},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:"flex-start",gap:{xs:1,sm:1,md:3}},children:[e.jsx(z,{label:t("admin.price.amount"),value:N(r,r.currency,r.product.unit_label,1,!0,g),divider:!0}),e.jsx(z,{label:t("common.createdAt"),value:W(r.created_at),divider:!0}),e.jsx(z,{label:t("common.updatedAt"),value:W(r.updated_at)})]})]}),e.jsx(j,{})]}),e.jsxs(u,{sx:{flexDirection:{xs:"column",lg:"row"},gap:{xs:2.5,md:4},".payment-link-column-1":{minWidth:{xs:"100%",lg:"600px"}},".payment-link-column-2":{width:{xs:"100%",md:"100%",lg:"320px"},maxWidth:{xs:"100%",md:"33%"}}},children:[e.jsxs(s,{className:"payment-link-column-1",sx:{flex:1,gap:2.5,display:"flex",flexDirection:"column"},children:[e.jsxs(s,{className:"section",sx:{containerType:"inline-size"},children:[e.jsx(y,{title:t("admin.details"),children:e.jsx(U,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},onClick:()=>p(i=>({editing:{...i.editing,price:!0}})),children:t("common.edit")})}),e.jsxs(F,{sx:{display:"grid",gridTemplateColumns:{xs:"repeat(1, 1fr)",xl:"repeat(2, 1fr)"},"@container (min-width: 1000px)":{gridTemplateColumns:"repeat(2, 1fr)"},".info-row-wrapper":{gap:1,flexDirection:{xs:"column",xl:"row"},alignItems:{xs:"flex-start",xl:"center"},"@container (min-width: 1000px)":{flexDirection:"row",alignItems:"center"}}},children:[e.jsx(d,{label:t("admin.price.type"),value:Y(r.type)}),r.type==="recurring"&&e.jsx(d,{label:t("admin.price.recurring.interval"),value:ie(r.recurring,!0,"per",g)}),e.jsx(d,{label:t("admin.price.lookupKey"),value:r.lookup_key}),e.jsx(d,{label:t("admin.price.nickname.label"),value:r.nickname}),c.editing.price&&e.jsx(ge,{price:r,loading:c.loading.price,onSave:f,onCancel:()=>p(i=>({editing:{...i.editing,price:!1}}))})]})]}),e.jsx(j,{}),r.metadata?.credit_config&&e.jsxs(e.Fragment,{children:[e.jsxs(s,{className:"section",children:[e.jsx(y,{title:t("admin.creditProduct.configTitle")}),e.jsx(F,{sx:{display:"grid",gridTemplateColumns:{xs:"repeat(1, 1fr)",xl:"repeat(2, 1fr)"},"@container (min-width: 1000px)":{gridTemplateColumns:"repeat(2, 1fr)"},".info-row-wrapper":{gap:1,flexDirection:{xs:"column",xl:"row"},alignItems:{xs:"flex-start",xl:"center"},"@container (min-width: 1000px)":{flexDirection:"row",alignItems:"center"}}},children:(()=>{const i=r.metadata.credit_config,x=i.schedule?.enabled,a=r.currency_options?.find(k=>k.currency_id===i.currency_id),_=a?a.currency:null;return e.jsxs(e.Fragment,{children:[x&&i.schedule?.interval_value&&i.schedule?.interval_unit&&e.jsx(d,{label:t("admin.creditProduct.schedule.interval.label"),value:`${t("common.every")} ${i.schedule.interval_value} ${t(`admin.creditProduct.schedule.interval.${i.schedule.interval_unit}`)}`}),x&&i.schedule?.amount_per_grant&&e.jsx(d,{label:t("admin.creditProduct.schedule.amountPerGrant.label"),value:_?e.jsxs(u,{direction:"row",spacing:.5,alignItems:"center",children:[e.jsx("span",{children:i.schedule.amount_per_grant}),e.jsx(A,{logo:_.logo,name:_.symbol,size:16})]}):i.schedule.amount_per_grant}),!x&&i.credit_amount&&e.jsx(d,{label:t("admin.creditProduct.creditAmount.label"),value:_?e.jsxs(u,{direction:"row",spacing:.5,alignItems:"center",children:[e.jsx("span",{children:i.credit_amount}),e.jsx(A,{logo:_.logo,name:_.symbol,size:16})]}):i.credit_amount}),e.jsx(d,{label:t("admin.creditProduct.expirationTime.label"),value:(()=>{if(x&&i.schedule?.expire_with_next_grant)return t("admin.creditProduct.expirationTime.expireWithNextGrant");const k=i.valid_duration_value,B=i.valid_duration_unit;return k&&k>0&&B?`${k} ${t(`admin.creditProduct.validDuration.${B}`)}`:"-"})()}),i.priority!==void 0&&e.jsx(d,{label:t("admin.creditProduct.priority.label"),value:i.priority}),i.applicable_prices&&i.applicable_prices.length>0&&e.jsx(d,{label:t("admin.creditProduct.associatedPrices.label"),value:i.applicable_prices.length})]})})()})]}),e.jsx(j,{})]}),ne(r)&&e.jsxs(e.Fragment,{children:[e.jsxs(s,{className:"section",children:[e.jsx(y,{title:t("admin.meters")}),e.jsx(s,{className:"section-body",children:e.jsx(d,{label:t("admin.meter.eventName.label"),value:e.jsx(oe,{to:`/admin/billing/${r.meter?.id}`,target:"_blank",children:r.meter?.event_name})})})]}),e.jsx(j,{})]}),e.jsxs(s,{className:"section",children:[e.jsx(y,{title:t("admin.price.currency.list")}),e.jsx(s,{className:"section-body",children:e.jsx(we,{children:e.jsx(ae,{toolbar:!1,footer:!1,data:r.currency_options,columns:[{label:t("admin.price.name"),name:"currency_id",width:200,options:{customBodyRenderLite:(i,x)=>{const a=r.currency_options[x];return e.jsx(A,{logo:a.currency?.logo,name:a.currency?.symbol})}}},{label:t("common.amount"),name:"unit_amount",options:{customBodyRenderLite:(i,x)=>{const a=r.currency_options[x];return N({id:r.id,currency_id:a.currency_id,type:r.type,unit_amount:a.unit_amount,custom_unit_amount:a.custom_unit_amount,recurring:r.recurring},a.currency,r.product.unit_label,1,!0,g)}}}],options:{count:r.currency_options.length,page:0,rowsPerPage:20},mobileTDFlexDirection:"row"})})})]}),e.jsx(j,{}),e.jsxs(s,{className:"section",children:[e.jsx(y,{title:t("admin.events.title")}),e.jsx(s,{className:"section-body",children:e.jsx(de,{features:{toolbar:!1},object_id:r.id})})]})]}),h&&e.jsx(j,{}),e.jsxs(s,{className:"payment-link-column-2",sx:{gap:2.5,display:"flex",flexDirection:"column"},children:[e.jsxs(s,{className:"section",children:[e.jsx(y,{title:t("admin.price.upsell.title")}),e.jsx(s,{className:"section-body",children:e.jsx(be,{data:r,onChange:P})})]}),e.jsx(j,{}),e.jsxs(s,{className:"section",children:[e.jsx(y,{title:t("common.metadata.label"),children:e.jsx(U,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},disabled:c.editing.metadata,onClick:D,children:t("common.edit")})}),e.jsxs(s,{className:"section-body",children:[e.jsx(ue,{data:r.metadata,handleEditMetadata:D}),c.editing.metadata&&e.jsx(me,{data:r,loading:c.loading.metadata,onSave:l,onCancel:()=>p(i=>({editing:{...i.editing,metadata:!1}}))})]})]})]})]})]})}const _e=O(u)``,we=O(s)`
1
+ import{r as q,j as e,A as M,w as R,aT as V,ad as $,a3 as u,q as I,bH as K,$ as L,I as Z,ci as J,B as s,z as Q,bv as X,Y as j,x as U,bf as O}from"./vendor-mui-BXZut9Pz.js";import{V as G,Y as E,P as H,Z as w}from"./vendor-blocklet-B8V2HFST.js";import{f as N,e as C,k as S,a as ee,Y as te,d as re,j as W,aP as ie,bb as ne,T as ae,b8 as se}from"./index-Bfp56O3W.js";import{a as le,L as oe}from"./vendor-react-BPknnnEA.js";import{C as ce}from"./copyable-Dn7WoFib.js";import{C as A}from"./currency-GstdXsJf.js";import{E as de}from"./list-CQ5uQIra.js";import{I as z}from"./info-metric-DwDA6oTc.js";import{I as d}from"./info-row-Cr8bdDz0.js";import{I as F}from"./info-row-group-qhfbrxfY.js";import{M as me}from"./editor-BzrYE3Ds.js";import{M as ue}from"./list-B6NGNObl.js";import{A as pe}from"./add-price-BxoCZ-Tz.js";import{P as xe,E as ge}from"./actions-BmYfP6Ex.js";import{S as y}from"./header-ivXuPt06.js";import{g as he}from"./util-Dp629jKU.js";import"./table-CyJj8e85.js";import"./lodash-B4Ozcv0x.js";import"./form-nz7nSyN7.js";import"./form-DPTZI-Fw.js";import"./collapse-CSrlJ0eG.js";import"./product-select-VFuyl5ev.js";import"./currency-select-3BZ7dBe5.js";import"./info-card-Xtng8th6.js";import"./uploader-CV9IVKh1.js";import"./tax-code-select-CoXANTPX.js";import"./collapse-BvbJGg1V.js";import"./actions-BYX1WnBr.js";const fe=n=>C.get(`/api/prices/${n}/upsell`).then(t=>t.data);function je({price:n,onSelect:t,onAdd:g}){const{t:h}=G(),[m,c]=E({loading:!1,adding:!1,action:""}),{loading:p,error:b,data:o}=H(()=>fe(n.id)),r=q.useMemo(()=>{if(!o||o.length===0)return[];const l=n.currency_options?.map(v=>v.currency_id)||[],f=l.length;return o.filter(v=>v.currency_options.length===f&&v.currency_options.every(D=>l.includes(D.currency_id)))},[o,n.id]);if(b)return e.jsx(M,{severity:"error",children:b.message});if(p||!o)return e.jsx(R,{});const P=l=>{l.target.value&&l.target.value!=="empty"&&(l.target.value==="add"?c({action:"add"}):t(l.target.value))},T=async l=>{try{c({adding:!0}),await C.post("/api/prices",{...l,product_id:n.product_id}),w.success(h("common.saved")),g()}catch(f){throw console.error(f),w.error(S(f)),f}finally{c({adding:!1})}};return e.jsxs(e.Fragment,{children:[e.jsxs(V,{value:"empty",sx:{width:300},size:"small",onChange:P,MenuProps:{style:{maxHeight:480}},children:[e.jsx($,{value:"empty",children:e.jsx(u,{direction:"row",sx:{alignItems:"center"},children:e.jsx(I,{children:h("admin.price.find")})})}),e.jsx($,{value:"add",children:e.jsxs(u,{direction:"row",sx:{alignItems:"center"},children:[e.jsx(K,{}),e.jsx(I,{children:h("admin.price.add")})]})}),r.map(l=>e.jsx($,{value:l.id,children:N(l,n.currency||l.currency)},l.id))]}),m.action==="add"&&e.jsx(pe,{loading:m.adding,onSave:T,onCancel:()=>c({action:""})})]})}function ye({data:n,onChange:t}){const{settings:g}=ee(),[h,m]=E({loading:!1}),c=async()=>{try{m({loading:!0}),await C.put(`/api/prices/${n.id}`,{upsell:{upsells_to_id:""}}).then(o=>o.data),m({loading:!1}),t()}catch(o){console.error(o),w.error(S(o)),m({loading:!1})}},p=async o=>{try{m({loading:!0}),await C.put(`/api/prices/${n.id}`,{upsell:{upsells_to_id:o}}).then(r=>r.data),m({loading:!1}),t()}catch(r){console.error(r),w.error(S(r)),m({loading:!1})}};if(h.loading)return e.jsx(R,{});const b=te(g.paymentMethods,n?.currency_id||"")||g.baseCurrency;return n.upsell?.upsells_to_id?e.jsxs(u,{spacing:1,direction:"row",sx:{alignItems:"center"},children:[e.jsx(I,{children:N(n.upsell.upsells_to,b)}),e.jsx(Z,{size:"small",sx:{ml:1},onClick:c,children:e.jsx(J,{color:"error",sx:{opacity:.75}})})]}):e.jsx(je,{price:n,onSelect:p,onAdd:t})}function be({data:n,onChange:t}){return e.jsx(L,{container:!0,children:e.jsx(L,{size:{xs:12,md:12},children:e.jsx(d,{label:"",value:e.jsx(ye,{data:n,onChange:t}),showLabel:!1})})})}const ve=n=>C.get(`/api/prices/${n}`).then(t=>t.data);function Qe(n){const{t,locale:g}=G(),{isMobile:h}=re(),m=le(),[c,p]=E({adding:{price:!1},editing:{metadata:!1,price:!1},loading:{metadata:!1,price:!1}}),{loading:b,error:o,data:r,runAsync:P}=H(()=>ve(n.id));if(o)return e.jsx(M,{severity:"error",children:o.message});if(b||!r)return e.jsx(R,{});const T=i=>async x=>{try{p(a=>({loading:{...a.loading,[i]:!0}})),await C.put(`/api/prices/${n.id}`,x).then(a=>a.data),w.success(t("common.saved")),se("price.updated"),P()}catch(a){throw console.error(a),w.error(S(a)),a}finally{p(a=>({loading:{...a.loading,[i]:!1}}))}},l=T("metadata"),f=T("price"),v=i=>{i==="remove"?m("/admin/products"):P()},D=()=>{p(i=>({editing:{...i.editing,metadata:!0}}))},Y=i=>i==="recurring"?t("admin.price.types.recurring"):i==="one_time"?t("admin.price.types.onetime"):i;return e.jsxs(_e,{direction:"column",spacing:2.5,sx:{mb:4},children:[e.jsxs(s,{children:[r.active===!1&&e.jsxs(M,{severity:"warning",children:[e.jsx(Q,{children:t("admin.price.archived")}),t("admin.price.archivedTip")]}),r.locked&&e.jsx(M,{severity:"warning",sx:{mb:1},children:t("admin.price.locked")}),e.jsxs(u,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(u,{direction:"row",onClick:()=>he(`/admin/products/${r.product_id}`),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(X,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(I,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:t("admin.products")})]}),e.jsx(xe,{data:r,onChange:v,variant:"normal"})]}),e.jsxs(s,{sx:{mt:4,mb:3,display:"flex",gap:{xs:2,sm:2,md:5},flexWrap:"wrap",flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"}},children:[e.jsxs(u,{direction:"column",sx:{gap:1},children:[e.jsxs(I,{variant:"h2",sx:{fontWeight:600},children:["Price for ",r.product.name]}),e.jsx(ce,{text:n.id,style:{marginLeft:4}})]}),e.jsxs(u,{className:"section-body",sx:{justifyContent:"flex-start",flexWrap:"wrap","hr.MuiDivider-root:last-child":{display:"none"},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:"flex-start",gap:{xs:1,sm:1,md:3}},children:[e.jsx(z,{label:t("admin.price.amount"),value:N(r,r.currency,r.product.unit_label,1,!0,g),divider:!0}),e.jsx(z,{label:t("common.createdAt"),value:W(r.created_at),divider:!0}),e.jsx(z,{label:t("common.updatedAt"),value:W(r.updated_at)})]})]}),e.jsx(j,{})]}),e.jsxs(u,{sx:{flexDirection:{xs:"column",lg:"row"},gap:{xs:2.5,md:4},".payment-link-column-1":{minWidth:{xs:"100%",lg:"600px"}},".payment-link-column-2":{width:{xs:"100%",md:"100%",lg:"320px"},maxWidth:{xs:"100%",md:"33%"}}},children:[e.jsxs(s,{className:"payment-link-column-1",sx:{flex:1,gap:2.5,display:"flex",flexDirection:"column"},children:[e.jsxs(s,{className:"section",sx:{containerType:"inline-size"},children:[e.jsx(y,{title:t("admin.details"),children:e.jsx(U,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},onClick:()=>p(i=>({editing:{...i.editing,price:!0}})),children:t("common.edit")})}),e.jsxs(F,{sx:{display:"grid",gridTemplateColumns:{xs:"repeat(1, 1fr)",xl:"repeat(2, 1fr)"},"@container (min-width: 1000px)":{gridTemplateColumns:"repeat(2, 1fr)"},".info-row-wrapper":{gap:1,flexDirection:{xs:"column",xl:"row"},alignItems:{xs:"flex-start",xl:"center"},"@container (min-width: 1000px)":{flexDirection:"row",alignItems:"center"}}},children:[e.jsx(d,{label:t("admin.price.type"),value:Y(r.type)}),r.type==="recurring"&&e.jsx(d,{label:t("admin.price.recurring.interval"),value:ie(r.recurring,!0,"per",g)}),e.jsx(d,{label:t("admin.price.lookupKey"),value:r.lookup_key}),e.jsx(d,{label:t("admin.price.nickname.label"),value:r.nickname}),c.editing.price&&e.jsx(ge,{price:r,loading:c.loading.price,onSave:f,onCancel:()=>p(i=>({editing:{...i.editing,price:!1}}))})]})]}),e.jsx(j,{}),r.metadata?.credit_config&&e.jsxs(e.Fragment,{children:[e.jsxs(s,{className:"section",children:[e.jsx(y,{title:t("admin.creditProduct.configTitle")}),e.jsx(F,{sx:{display:"grid",gridTemplateColumns:{xs:"repeat(1, 1fr)",xl:"repeat(2, 1fr)"},"@container (min-width: 1000px)":{gridTemplateColumns:"repeat(2, 1fr)"},".info-row-wrapper":{gap:1,flexDirection:{xs:"column",xl:"row"},alignItems:{xs:"flex-start",xl:"center"},"@container (min-width: 1000px)":{flexDirection:"row",alignItems:"center"}}},children:(()=>{const i=r.metadata.credit_config,x=i.schedule?.enabled,a=r.currency_options?.find(k=>k.currency_id===i.currency_id),_=a?a.currency:null;return e.jsxs(e.Fragment,{children:[x&&i.schedule?.interval_value&&i.schedule?.interval_unit&&e.jsx(d,{label:t("admin.creditProduct.schedule.interval.label"),value:`${t("common.every")} ${i.schedule.interval_value} ${t(`admin.creditProduct.schedule.interval.${i.schedule.interval_unit}`)}`}),x&&i.schedule?.amount_per_grant&&e.jsx(d,{label:t("admin.creditProduct.schedule.amountPerGrant.label"),value:_?e.jsxs(u,{direction:"row",spacing:.5,alignItems:"center",children:[e.jsx("span",{children:i.schedule.amount_per_grant}),e.jsx(A,{logo:_.logo,name:_.symbol,size:16})]}):i.schedule.amount_per_grant}),!x&&i.credit_amount&&e.jsx(d,{label:t("admin.creditProduct.creditAmount.label"),value:_?e.jsxs(u,{direction:"row",spacing:.5,alignItems:"center",children:[e.jsx("span",{children:i.credit_amount}),e.jsx(A,{logo:_.logo,name:_.symbol,size:16})]}):i.credit_amount}),e.jsx(d,{label:t("admin.creditProduct.expirationTime.label"),value:(()=>{if(x&&i.schedule?.expire_with_next_grant)return t("admin.creditProduct.expirationTime.expireWithNextGrant");const k=i.valid_duration_value,B=i.valid_duration_unit;return k&&k>0&&B?`${k} ${t(`admin.creditProduct.validDuration.${B}`)}`:"-"})()}),i.priority!==void 0&&e.jsx(d,{label:t("admin.creditProduct.priority.label"),value:i.priority}),i.applicable_prices&&i.applicable_prices.length>0&&e.jsx(d,{label:t("admin.creditProduct.associatedPrices.label"),value:i.applicable_prices.length})]})})()})]}),e.jsx(j,{})]}),ne(r)&&e.jsxs(e.Fragment,{children:[e.jsxs(s,{className:"section",children:[e.jsx(y,{title:t("admin.meters")}),e.jsx(s,{className:"section-body",children:e.jsx(d,{label:t("admin.meter.eventName.label"),value:e.jsx(oe,{to:`/admin/billing/${r.meter?.id}`,target:"_blank",children:r.meter?.event_name})})})]}),e.jsx(j,{})]}),e.jsxs(s,{className:"section",children:[e.jsx(y,{title:t("admin.price.currency.list")}),e.jsx(s,{className:"section-body",children:e.jsx(we,{children:e.jsx(ae,{toolbar:!1,footer:!1,data:r.currency_options,columns:[{label:t("admin.price.name"),name:"currency_id",width:200,options:{customBodyRenderLite:(i,x)=>{const a=r.currency_options[x];return e.jsx(A,{logo:a.currency?.logo,name:a.currency?.symbol})}}},{label:t("common.amount"),name:"unit_amount",options:{customBodyRenderLite:(i,x)=>{const a=r.currency_options[x];return N({id:r.id,currency_id:a.currency_id,type:r.type,unit_amount:a.unit_amount,custom_unit_amount:a.custom_unit_amount,recurring:r.recurring},a.currency,r.product.unit_label,1,!0,g)}}}],options:{count:r.currency_options.length,page:0,rowsPerPage:20},mobileTDFlexDirection:"row"})})})]}),e.jsx(j,{}),e.jsxs(s,{className:"section",children:[e.jsx(y,{title:t("admin.events.title")}),e.jsx(s,{className:"section-body",children:e.jsx(de,{features:{toolbar:!1},object_id:r.id})})]})]}),h&&e.jsx(j,{}),e.jsxs(s,{className:"payment-link-column-2",sx:{gap:2.5,display:"flex",flexDirection:"column"},children:[e.jsxs(s,{className:"section",children:[e.jsx(y,{title:t("admin.price.upsell.title")}),e.jsx(s,{className:"section-body",children:e.jsx(be,{data:r,onChange:P})})]}),e.jsx(j,{}),e.jsxs(s,{className:"section",children:[e.jsx(y,{title:t("common.metadata.label"),children:e.jsx(U,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},disabled:c.editing.metadata,onClick:D,children:t("common.edit")})}),e.jsxs(s,{className:"section-body",children:[e.jsx(ue,{data:r.metadata,handleEditMetadata:D}),c.editing.metadata&&e.jsx(me,{data:r,loading:c.loading.metadata,onSave:l,onCancel:()=>p(i=>({editing:{...i.editing,metadata:!1}}))})]})]})]})]})]})}const _e=O(u)``,we=O(s)`
2
2
  @media (max-width: ${({theme:n})=>n.breakpoints.values.md}px) {
3
3
  .MuiTable-root > .MuiTableBody-root > .MuiTableRow-root > .MuiTableCell-root {
4
4
  > div {
@@ -1,4 +1,4 @@
1
- import{j as e,r as D,q as l,B as c,w as G,a3 as x,x as S,bf as H,u as Q,A as P,bv as X,O as E,Y as k}from"./vendor-mui-BXZut9Pz.js";import{V as $,P as F,ah as ee,Y as te,Z as N,F as se}from"./vendor-blocklet-B67R14so.js";import{i as O,n as w,o as q,j as b,p as A,T as ae,q as ne,e as K,d as oe,a as ie,u as re,k as W,r as ce,s as le,t as me,v as de,l as pe,w as ue}from"./index-B4yaPb7B.js";import{T as xe}from"./gas-kw2KMH1u.js";import{b as he,e as ye,L as fe}from"./vendor-react-BPknnnEA.js";import{l as j}from"./lodash-B4Ozcv0x.js";import{C as ge}from"./currency-GstdXsJf.js";import{C as be}from"./link-DsltSF2Q.js";import{I as h}from"./info-row-CaPaNF4L.js";import{D as je,R as ve,I as _e}from"./related-credit-grants-DnKdAit6.js";import{g as we}from"./util-B8B3fsMa.js";import{i as Ce}from"./did-Bqcz-NjH.js";import{I}from"./info-metric-ukWq8INi.js";import{I as ke}from"./info-row-group-Cxo-4Gk5.js";import{u as Ie}from"./browser-DF2vfpBa.js";import"./browser-Bb9g-cvG.js";import"./usage-records-BAwNs1y8.js";import"./actions-BEUwbsq1.js";import"./click-boundary-Bi28Y0Fq.js";import"./generateCategoricalChart-BCpuUeC_.js";const Se=s=>{const o={};return s.forEach(a=>{const r=new Date(a.created_at).toLocaleDateString();o[r]||(o[r]=[]),o[r]?.push(a)}),o},U=(s={})=>{const o=new URLSearchParams;return Object.keys(s).forEach(a=>{o.set(a,String(s[a]))}),K.get(`/api/refunds?${o.toString()}`).then(a=>a.data)},R=10,Re=D.memo(({invoice_id:s})=>{const o="invoice-table",{t:a,locale:r}=$(),[d,y]=D.useState({pageSize:R,page:1}),{loading:f,data:p={list:[],count:0}}=F(()=>U({...d,invoice_id:s}),{refreshDeps:[d]}),u=[{label:a("common.amount"),name:"id",width:80,align:"right",options:{customBodyRenderLite:(n,i)=>{const t=p.list[i];return e.jsxs(l,{component:"strong",sx:{fontWeight:600},children:[O(t?.amount,t?.paymentCurrency.decimal),t?.paymentCurrency.symbol]})}}},{label:a("common.status"),name:"status",width:100,options:{filter:!0,customBodyRenderLite:(n,i)=>{const t=p.list[i];return e.jsx(w,{label:t.status,color:q(t.status)})}}},{label:a("common.type"),name:"type",width:80,options:{filter:!0,customBodyRenderLite:(n,i)=>{const t=p.list[i];return e.jsx(w,{label:a(`refund.type.${t.type}`)})}}},{label:a("common.description"),name:"description",options:{customBodyRenderLite:(n,i)=>{const t=p.list[i];return t.description?j.capitalize(j.toLower(t.description.replace(/_/g," "))):t.id}}},{label:a("common.createdAt"),name:"created_at",options:{sort:!0,customBodyRenderLite:(n,i)=>{const t=p.list[i];return b(t.created_at)}}},{label:a("common.updatedAt"),name:"updated_at",options:{sort:!0,customBodyRenderLite:(n,i)=>{const t=p.list[i];return b(t.updated_at)}}},{label:a("common.txHash"),name:"",options:{customBodyRenderLite:(n,i)=>{const t=p.list[i],v=t.payment_details;return["arcblock","ethereum","base"].map(C=>!!v?.[C]?.tx_hash).find(Boolean)?e.jsx(c,{sx:{".MuiTypography-root":{color:"text.link"}},children:e.jsx(A,{details:v,method:t.paymentMethod,mode:"customer"})}):a("common.none")}}}],m=({page:n,rowsPerPage:i})=>{d.pageSize!==i?y(t=>({...t,pageSize:i,page:1})):d.page!==n+1&&y(t=>({...t,page:n+1}))};return e.jsx(De,{children:e.jsx(ae,{hasRowLink:!0,durable:`__${o}__`,durableKeys:["page","rowsPerPage","searchText"],data:p.list,columns:u,options:{count:p.count,page:d.page-1,rowsPerPage:d.pageSize},loading:f,onChange:m,toolbar:!1,sx:{mt:2},showMobile:!1,locale:r,mobileTDFlexDirection:"row",emptyNodeText:a("payment.customer.refund.emptyList")})})}),De=H(c)`
1
+ import{j as e,r as D,q as l,B as c,w as G,a3 as x,x as S,bf as H,u as Q,A as P,bv as X,O as E,Y as k}from"./vendor-mui-BXZut9Pz.js";import{V as $,P as F,ah as ee,Y as te,Z as N,F as se}from"./vendor-blocklet-B8V2HFST.js";import{i as O,n as w,o as q,j as b,p as A,T as ae,q as ne,e as K,d as oe,a as ie,u as re,k as W,r as ce,s as le,t as me,v as de,l as pe,w as ue}from"./index-Bfp56O3W.js";import{T as xe}from"./gas-BGJEvZ8T.js";import{b as he,e as ye,L as fe}from"./vendor-react-BPknnnEA.js";import{l as j}from"./lodash-B4Ozcv0x.js";import{C as ge}from"./currency-GstdXsJf.js";import{C as be}from"./link-Dhj5mzaG.js";import{I as h}from"./info-row-Cr8bdDz0.js";import{D as je,R as ve,I as _e}from"./related-credit-grants-BxHOJRRa.js";import{g as we}from"./util-Dp629jKU.js";import{i as Ce}from"./did-Bqcz-NjH.js";import{I}from"./info-metric-DwDA6oTc.js";import{I as ke}from"./info-row-group-qhfbrxfY.js";import{u as Ie}from"./browser-QPNAlSRH.js";import"./browser-Bb9g-cvG.js";import"./usage-records-nONbPDaL.js";import"./actions-BYX1WnBr.js";import"./click-boundary-Cozpjijr.js";import"./generateCategoricalChart-DJ3AfbsA.js";const Se=s=>{const o={};return s.forEach(a=>{const r=new Date(a.created_at).toLocaleDateString();o[r]||(o[r]=[]),o[r]?.push(a)}),o},U=(s={})=>{const o=new URLSearchParams;return Object.keys(s).forEach(a=>{o.set(a,String(s[a]))}),K.get(`/api/refunds?${o.toString()}`).then(a=>a.data)},R=10,Re=D.memo(({invoice_id:s})=>{const o="invoice-table",{t:a,locale:r}=$(),[d,y]=D.useState({pageSize:R,page:1}),{loading:f,data:p={list:[],count:0}}=F(()=>U({...d,invoice_id:s}),{refreshDeps:[d]}),u=[{label:a("common.amount"),name:"id",width:80,align:"right",options:{customBodyRenderLite:(n,i)=>{const t=p.list[i];return e.jsxs(l,{component:"strong",sx:{fontWeight:600},children:[O(t?.amount,t?.paymentCurrency.decimal),t?.paymentCurrency.symbol]})}}},{label:a("common.status"),name:"status",width:100,options:{filter:!0,customBodyRenderLite:(n,i)=>{const t=p.list[i];return e.jsx(w,{label:t.status,color:q(t.status)})}}},{label:a("common.type"),name:"type",width:80,options:{filter:!0,customBodyRenderLite:(n,i)=>{const t=p.list[i];return e.jsx(w,{label:a(`refund.type.${t.type}`)})}}},{label:a("common.description"),name:"description",options:{customBodyRenderLite:(n,i)=>{const t=p.list[i];return t.description?j.capitalize(j.toLower(t.description.replace(/_/g," "))):t.id}}},{label:a("common.createdAt"),name:"created_at",options:{sort:!0,customBodyRenderLite:(n,i)=>{const t=p.list[i];return b(t.created_at)}}},{label:a("common.updatedAt"),name:"updated_at",options:{sort:!0,customBodyRenderLite:(n,i)=>{const t=p.list[i];return b(t.updated_at)}}},{label:a("common.txHash"),name:"",options:{customBodyRenderLite:(n,i)=>{const t=p.list[i],v=t.payment_details;return["arcblock","ethereum","base"].map(C=>!!v?.[C]?.tx_hash).find(Boolean)?e.jsx(c,{sx:{".MuiTypography-root":{color:"text.link"}},children:e.jsx(A,{details:v,method:t.paymentMethod,mode:"customer"})}):a("common.none")}}}],m=({page:n,rowsPerPage:i})=>{d.pageSize!==i?y(t=>({...t,pageSize:i,page:1})):d.page!==n+1&&y(t=>({...t,page:n+1}))};return e.jsx(De,{children:e.jsx(ae,{hasRowLink:!0,durable:`__${o}__`,durableKeys:["page","rowsPerPage","searchText"],data:p.list,columns:u,options:{count:p.count,page:d.page-1,rowsPerPage:d.pageSize},loading:f,onChange:m,toolbar:!1,sx:{mt:2},showMobile:!1,locale:r,mobileTDFlexDirection:"row",emptyNodeText:a("payment.customer.refund.emptyList")})})}),De=H(c)`
2
2
  @media (max-width: ${({theme:s})=>s.breakpoints.values.md}px) {
3
3
  .MuiTable-root > .MuiTableBody-root > .MuiTableRow-root > .MuiTableCell-root {
4
4
  > div {
@@ -1 +1 @@
1
- import{j as e,A as M,w as W,$ as p,a3 as n,bv as _,q as f,B as i,Y as d,x as $,bf as A}from"./vendor-mui-BXZut9Pz.js";import{V as L,Y as B,P as E,F as w,Z as y}from"./vendor-blocklet-B67R14so.js";import{a as R,T as U,j as v,e as I,k as z}from"./index-B4yaPb7B.js";import{a as O,L as q}from"./vendor-react-BPknnnEA.js";import{C as k}from"./copyable-CprMHdhV.js";import{E as F}from"./list-CvM46TsP.js";import{I as G}from"./info-card-C9dRgztS.js";import{I as C}from"./info-row-CaPaNF4L.js";import{M as H}from"./editor-vZvxDUTl.js";import{M as Y}from"./list-B2b-s8wM.js";import{P as V}from"./actions--FNKSNIs.js";import{P as Z}from"./preview-F3lma170.js";import{S as l}from"./header-ivXuPt06.js";import{g as J,n as K}from"./util-B8B3fsMa.js";import{I as Q}from"./info-metric-ukWq8INi.js";import{I as X}from"./info-row-group-Cxo-4Gk5.js";import"./table-BN3WBnr3.js";import"./lodash-B4Ozcv0x.js";import"./form-CnrBCyTJ.js";import"./actions-BEUwbsq1.js";import"./click-boundary-Bi28Y0Fq.js";import"./assign-DKRfmN7W.js";import"./chrome-BPS46pXA.js";const ee=o=>I.get(`/api/pricing-tables/${o}`).then(t=>t.data);function Ne(o){const{t,locale:u}=L(),N=O(),{settings:P}=R(),[m,c]=B({adding:{price:!1},editing:{metadata:!1,product:!1},loading:{metadata:!1,price:!1,product:!1}}),{loading:T,error:g,data:a,runAsync:j}=E(()=>ee(o.id));if(g)return e.jsx(M,{severity:"error",children:g.message});if(T||!a)return e.jsx(W,{});const D=(r=>async x=>{try{c(s=>({loading:{...s.loading,[r]:!0}})),await I.put(`/api/pricing-tables/${o.id}`,x).then(s=>s.data),y.success(t("common.saved")),j()}catch(s){console.error(s),y.error(z(s))}finally{c(s=>({loading:{...s.loading,[r]:!1}}))}})("metadata"),S=r=>{r==="remove"?N("/admin/products/pricing-tables"):j()},h=()=>{c(r=>({editing:{...r.editing,metadata:!0}}))};return e.jsxs(p,{container:!0,spacing:4,sx:{mb:4},children:[e.jsxs(p,{size:12,children:[e.jsxs(n,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(n,{direction:"row",onClick:()=>J("/admin/products/pricing-tables"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(_,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(f,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:t("admin.pricingTables")})]}),e.jsx(V,{data:a,onChange:S,variant:"normal"})]}),e.jsxs(i,{sx:{mt:4,mb:3,display:"flex",gap:{xs:2,sm:2,md:5},flexWrap:"wrap",flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"}},children:[e.jsx(n,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center",gap:5},children:e.jsxs(n,{direction:"column",sx:{alignItems:"flex-start"},children:[e.jsx(f,{variant:"h1",children:a.name}),e.jsx(k,{text:w(window.blocklet.appUrl,window.blocklet.prefix,`/checkout/pricing-table/${a.id}`),children:e.jsx(f,{variant:"h6",sx:{color:"text.secondary",mr:1,maxWidth:{xs:300,md:"100%"},textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap"},children:w(window.blocklet.prefix,`/checkout/pricing-table/${a.id}`)})})]})}),e.jsx(n,{className:"section-body",sx:{justifyContent:"flex-start",flexWrap:"wrap","hr.MuiDivider-root:last-child":{display:"none"},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:"flex-start",gap:{xs:1,sm:1,md:3}},children:e.jsx(Q,{label:t("common.id"),value:e.jsx(k,{text:o.id,style:{marginLeft:4}}),divider:!0})})]}),e.jsx(d,{})]}),e.jsx(p,{size:12,children:e.jsxs(n,{sx:{flexDirection:{xs:"column",lg:"row"},gap:4,".payment-link-column-1":{minWidth:{xs:"100%",lg:"600px"}},".payment-link-column-2":{width:{xs:"100%",md:"100%",lg:"320px"},maxWidth:{xs:"100%",md:"33%"}}},children:[e.jsx(i,{className:"payment-link-column-1",sx:{flex:1},children:e.jsxs(te,{direction:"column",spacing:3,children:[e.jsxs(i,{className:"section",children:[e.jsx(l,{title:t("admin.products")}),e.jsx(i,{className:"section-body",children:e.jsx(U,{className:"link-products-table",toolbar:!1,footer:!1,locale:u,data:a.items,columns:[{label:t("common.title"),name:"product_id",options:{sort:!1,customBodyRenderLite:(r,x)=>{const s=a.items[x],b=a?.currency||P.baseCurrency;return e.jsx(q,{to:`/admin/products/${s.product_id}?currency_id=${b?.id}&price_id=${s.price.id}`,children:e.jsx(G,{name:s.product.name,description:K({...s.product,prices:[s.price]},b,u),logo:s.product.images[0]})})}}}],options:{count:a.items.length,page:0,rowsPerPage:20},emptyNodeText:t("empty.products")})})]}),e.jsx(d,{}),e.jsxs(i,{className:"section",children:[e.jsx(l,{title:t("admin.details")}),e.jsxs(X,{sx:{display:"grid",gridTemplateColumns:{xs:"repeat(1, 1fr)",xl:"repeat(2, 1fr)"},"@container (min-width: 1000px)":{gridTemplateColumns:"repeat(2, 1fr)"},".info-row-wrapper":{gap:1,flexDirection:{xs:"column",xl:"row"},alignItems:{xs:"flex-start",xl:"center"},"@container (min-width: 1000px)":{flexDirection:"row",alignItems:"center"}}},children:[e.jsx(C,{label:t("common.createdAt"),value:v(a.created_at)}),e.jsx(C,{label:t("common.updatedAt"),value:v(a.updated_at)})]})]}),e.jsx(d,{}),e.jsxs(i,{className:"section",children:[e.jsx(l,{title:t("common.preview")}),e.jsx(i,{className:"section-body",sx:{maxWidth:1050},children:e.jsx(Z,{id:a.id})})]}),e.jsx(d,{}),e.jsxs(i,{className:"section",children:[e.jsx(l,{title:t("admin.events.title")}),e.jsx(i,{className:"section-body",children:e.jsx(F,{features:{toolbar:!1},object_id:a.id})})]})]})}),e.jsx(i,{className:"payment-link-column-2",children:e.jsxs(i,{className:"section",children:[e.jsx(l,{title:t("common.metadata.label"),children:e.jsx($,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},disabled:m.editing.metadata,onClick:h,children:t("common.edit")})}),e.jsxs(i,{className:"section-body",children:[e.jsx(Y,{data:a.metadata,handleEditMetadata:h}),m.editing.metadata&&e.jsx(H,{data:a,loading:m.loading.metadata,onSave:D,onCancel:()=>c(r=>({editing:{...r.editing,metadata:!1}}))})]})]})})]})})]})}const te=A(n)``;export{Ne as default};
1
+ import{j as e,A as M,w as W,$ as p,a3 as n,bv as _,q as f,B as i,Y as d,x as $,bf as A}from"./vendor-mui-BXZut9Pz.js";import{V as L,Y as B,P as E,F as w,Z as y}from"./vendor-blocklet-B8V2HFST.js";import{a as R,T as U,j as v,e as I,k as z}from"./index-Bfp56O3W.js";import{a as O,L as q}from"./vendor-react-BPknnnEA.js";import{C as k}from"./copyable-Dn7WoFib.js";import{E as F}from"./list-CQ5uQIra.js";import{I as G}from"./info-card-Xtng8th6.js";import{I as C}from"./info-row-Cr8bdDz0.js";import{M as H}from"./editor-BzrYE3Ds.js";import{M as Y}from"./list-B6NGNObl.js";import{P as V}from"./actions-DTY0f0j8.js";import{P as Z}from"./preview-DrU96XLI.js";import{S as l}from"./header-ivXuPt06.js";import{g as J,n as K}from"./util-Dp629jKU.js";import{I as Q}from"./info-metric-DwDA6oTc.js";import{I as X}from"./info-row-group-qhfbrxfY.js";import"./table-CyJj8e85.js";import"./lodash-B4Ozcv0x.js";import"./form-nz7nSyN7.js";import"./actions-BYX1WnBr.js";import"./click-boundary-Cozpjijr.js";import"./assign-BOWJRdk_.js";import"./chrome-BPS46pXA.js";const ee=o=>I.get(`/api/pricing-tables/${o}`).then(t=>t.data);function Ne(o){const{t,locale:u}=L(),N=O(),{settings:P}=R(),[m,c]=B({adding:{price:!1},editing:{metadata:!1,product:!1},loading:{metadata:!1,price:!1,product:!1}}),{loading:T,error:g,data:a,runAsync:j}=E(()=>ee(o.id));if(g)return e.jsx(M,{severity:"error",children:g.message});if(T||!a)return e.jsx(W,{});const D=(r=>async x=>{try{c(s=>({loading:{...s.loading,[r]:!0}})),await I.put(`/api/pricing-tables/${o.id}`,x).then(s=>s.data),y.success(t("common.saved")),j()}catch(s){console.error(s),y.error(z(s))}finally{c(s=>({loading:{...s.loading,[r]:!1}}))}})("metadata"),S=r=>{r==="remove"?N("/admin/products/pricing-tables"):j()},h=()=>{c(r=>({editing:{...r.editing,metadata:!0}}))};return e.jsxs(p,{container:!0,spacing:4,sx:{mb:4},children:[e.jsxs(p,{size:12,children:[e.jsxs(n,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(n,{direction:"row",onClick:()=>J("/admin/products/pricing-tables"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(_,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(f,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:t("admin.pricingTables")})]}),e.jsx(V,{data:a,onChange:S,variant:"normal"})]}),e.jsxs(i,{sx:{mt:4,mb:3,display:"flex",gap:{xs:2,sm:2,md:5},flexWrap:"wrap",flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"}},children:[e.jsx(n,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center",gap:5},children:e.jsxs(n,{direction:"column",sx:{alignItems:"flex-start"},children:[e.jsx(f,{variant:"h1",children:a.name}),e.jsx(k,{text:w(window.blocklet.appUrl,window.blocklet.prefix,`/checkout/pricing-table/${a.id}`),children:e.jsx(f,{variant:"h6",sx:{color:"text.secondary",mr:1,maxWidth:{xs:300,md:"100%"},textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap"},children:w(window.blocklet.prefix,`/checkout/pricing-table/${a.id}`)})})]})}),e.jsx(n,{className:"section-body",sx:{justifyContent:"flex-start",flexWrap:"wrap","hr.MuiDivider-root:last-child":{display:"none"},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:"flex-start",gap:{xs:1,sm:1,md:3}},children:e.jsx(Q,{label:t("common.id"),value:e.jsx(k,{text:o.id,style:{marginLeft:4}}),divider:!0})})]}),e.jsx(d,{})]}),e.jsx(p,{size:12,children:e.jsxs(n,{sx:{flexDirection:{xs:"column",lg:"row"},gap:4,".payment-link-column-1":{minWidth:{xs:"100%",lg:"600px"}},".payment-link-column-2":{width:{xs:"100%",md:"100%",lg:"320px"},maxWidth:{xs:"100%",md:"33%"}}},children:[e.jsx(i,{className:"payment-link-column-1",sx:{flex:1},children:e.jsxs(te,{direction:"column",spacing:3,children:[e.jsxs(i,{className:"section",children:[e.jsx(l,{title:t("admin.products")}),e.jsx(i,{className:"section-body",children:e.jsx(U,{className:"link-products-table",toolbar:!1,footer:!1,locale:u,data:a.items,columns:[{label:t("common.title"),name:"product_id",options:{sort:!1,customBodyRenderLite:(r,x)=>{const s=a.items[x],b=a?.currency||P.baseCurrency;return e.jsx(q,{to:`/admin/products/${s.product_id}?currency_id=${b?.id}&price_id=${s.price.id}`,children:e.jsx(G,{name:s.product.name,description:K({...s.product,prices:[s.price]},b,u),logo:s.product.images[0]})})}}}],options:{count:a.items.length,page:0,rowsPerPage:20},emptyNodeText:t("empty.products")})})]}),e.jsx(d,{}),e.jsxs(i,{className:"section",children:[e.jsx(l,{title:t("admin.details")}),e.jsxs(X,{sx:{display:"grid",gridTemplateColumns:{xs:"repeat(1, 1fr)",xl:"repeat(2, 1fr)"},"@container (min-width: 1000px)":{gridTemplateColumns:"repeat(2, 1fr)"},".info-row-wrapper":{gap:1,flexDirection:{xs:"column",xl:"row"},alignItems:{xs:"flex-start",xl:"center"},"@container (min-width: 1000px)":{flexDirection:"row",alignItems:"center"}}},children:[e.jsx(C,{label:t("common.createdAt"),value:v(a.created_at)}),e.jsx(C,{label:t("common.updatedAt"),value:v(a.updated_at)})]})]}),e.jsx(d,{}),e.jsxs(i,{className:"section",children:[e.jsx(l,{title:t("common.preview")}),e.jsx(i,{className:"section-body",sx:{maxWidth:1050},children:e.jsx(Z,{id:a.id})})]}),e.jsx(d,{}),e.jsxs(i,{className:"section",children:[e.jsx(l,{title:t("admin.events.title")}),e.jsx(i,{className:"section-body",children:e.jsx(F,{features:{toolbar:!1},object_id:a.id})})]})]})}),e.jsx(i,{className:"payment-link-column-2",children:e.jsxs(i,{className:"section",children:[e.jsx(l,{title:t("common.metadata.label"),children:e.jsx($,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},disabled:m.editing.metadata,onClick:h,children:t("common.edit")})}),e.jsxs(i,{className:"section-body",children:[e.jsx(Y,{data:a.metadata,handleEditMetadata:h}),m.editing.metadata&&e.jsx(H,{data:a,loading:m.loading.metadata,onSave:D,onCancel:()=>c(r=>({editing:{...r.editing,metadata:!1}}))})]})]})})]})})]})}const te=A(n)``;export{Ne as default};
@@ -1 +1 @@
1
- import{j as e,A as d,w as x,B as o,a3 as r,bv as p,q as l,Y as f,bf as u}from"./vendor-mui-BXZut9Pz.js";import{V as j,P as h}from"./vendor-blocklet-B67R14so.js";import{j as m,e as g}from"./index-B4yaPb7B.js";import{C as v}from"./copyable-CprMHdhV.js";import{I as i}from"./info-metric-ukWq8INi.js";import{S as b}from"./header-ivXuPt06.js";import{W as y}from"./attempts-BfbYfiJa.js";import{g as w}from"./util-B8B3fsMa.js";import"./vendor-react-BPknnnEA.js";import"./vendor-arcblock-D1drrE7q.js";import"./lodash-B4Ozcv0x.js";import"./info-card-C9dRgztS.js";const k=a=>g.get(`/api/events/${a}`).then(t=>t.data);function O(a){const{t}=j(),{loading:c,error:n,data:s}=h(()=>k(a.id));return n?e.jsx(d,{severity:"error",children:n.message}):c||!s?e.jsx(x,{}):e.jsxs(W,{direction:"column",spacing:2.5,sx:{mb:4},children:[e.jsxs(o,{children:[e.jsx(r,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsxs(r,{direction:"row",onClick:()=>w("/admin/developers/events"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(p,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(l,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:t("admin.events.title")})]})}),e.jsxs(o,{sx:{mt:4,mb:3,display:"flex",gap:{xs:2,sm:2,md:5},flexWrap:"wrap",flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"}},children:[e.jsx(r,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsx(l,{variant:"h2",sx:{fontWeight:600},children:s.type})}),e.jsxs(r,{className:"section-body",sx:{justifyContent:"flex-start",flexWrap:"wrap","hr.MuiDivider-root:last-child":{display:"none"},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:"flex-start",gap:{xs:1,sm:1,md:3}},children:[e.jsx(i,{label:t("common.id"),value:e.jsx(v,{text:a.id,style:{marginLeft:4}})}),e.jsx(i,{label:t("admin.event.pendingWebhooks"),value:s.pending_webhooks,divider:!0}),e.jsx(i,{label:t("common.createdAt"),value:m(s.created_at),divider:!0}),e.jsx(i,{label:t("common.updatedAt"),value:m(s.updated_at)})]})]}),e.jsx(f,{})]}),e.jsxs(o,{className:"section",children:[e.jsx(b,{title:t("admin.event.webhooks")}),e.jsx(o,{className:"section-body",children:e.jsx(y,{event_id:s.id,event:s})})]})]})}const W=u(r)``;export{O as default};
1
+ import{j as e,A as d,w as x,B as o,a3 as r,bv as p,q as l,Y as f,bf as u}from"./vendor-mui-BXZut9Pz.js";import{V as j,P as h}from"./vendor-blocklet-B8V2HFST.js";import{j as m,e as g}from"./index-Bfp56O3W.js";import{C as v}from"./copyable-Dn7WoFib.js";import{I as i}from"./info-metric-DwDA6oTc.js";import{S as b}from"./header-ivXuPt06.js";import{W as y}from"./attempts-D5nVVL_6.js";import{g as w}from"./util-Dp629jKU.js";import"./vendor-react-BPknnnEA.js";import"./vendor-arcblock-D34ufhta.js";import"./lodash-B4Ozcv0x.js";import"./info-card-Xtng8th6.js";const k=a=>g.get(`/api/events/${a}`).then(t=>t.data);function O(a){const{t}=j(),{loading:c,error:n,data:s}=h(()=>k(a.id));return n?e.jsx(d,{severity:"error",children:n.message}):c||!s?e.jsx(x,{}):e.jsxs(W,{direction:"column",spacing:2.5,sx:{mb:4},children:[e.jsxs(o,{children:[e.jsx(r,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsxs(r,{direction:"row",onClick:()=>w("/admin/developers/events"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(p,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(l,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:t("admin.events.title")})]})}),e.jsxs(o,{sx:{mt:4,mb:3,display:"flex",gap:{xs:2,sm:2,md:5},flexWrap:"wrap",flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"}},children:[e.jsx(r,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsx(l,{variant:"h2",sx:{fontWeight:600},children:s.type})}),e.jsxs(r,{className:"section-body",sx:{justifyContent:"flex-start",flexWrap:"wrap","hr.MuiDivider-root:last-child":{display:"none"},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:"flex-start",gap:{xs:1,sm:1,md:3}},children:[e.jsx(i,{label:t("common.id"),value:e.jsx(v,{text:a.id,style:{marginLeft:4}})}),e.jsx(i,{label:t("admin.event.pendingWebhooks"),value:s.pending_webhooks,divider:!0}),e.jsx(i,{label:t("common.createdAt"),value:m(s.created_at),divider:!0}),e.jsx(i,{label:t("common.updatedAt"),value:m(s.updated_at)})]})]}),e.jsx(f,{})]}),e.jsxs(o,{className:"section",children:[e.jsx(b,{title:t("admin.event.webhooks")}),e.jsx(o,{className:"section-body",children:e.jsx(y,{event_id:s.id,event:s})})]})]})}const W=u(r)``;export{O as default};
@@ -1 +1 @@
1
- import{j as e,w as z,A as N,B as o,a3 as m,bv as P,q as x,Y as v,x as b,O as q,cA as H,bf as J}from"./vendor-mui-BXZut9Pz.js";import{V as U,Y as V,P as Y,Z as f}from"./vendor-blocklet-B67R14so.js";import{d as G,h as Z,ac as D,j as M,F as K,e as w,b8 as S,k as A}from"./index-B4yaPb7B.js";import{C as Q}from"./copyable-CprMHdhV.js";import{I as g}from"./info-metric-ukWq8INi.js";import{I as d}from"./info-row-CaPaNF4L.js";import{I as X}from"./info-row-group-Cxo-4Gk5.js";import{I as ee}from"./list-ZaBapEXW.js";import{M as te}from"./editor-vZvxDUTl.js";import{M as ae}from"./list-B2b-s8wM.js";import{S as R}from"./header-ivXuPt06.js";import{g as se,a as ie,T as ne}from"./tax-utils-B8J0Kfnz.js";import{T as oe}from"./index-C3AP4jq0.js";import{D as re}from"./drawer-form-CQjNFFWk.js";import{g as le}from"./util-B8B3fsMa.js";import{a as de}from"./vendor-react-BPknnnEA.js";import"./table-BN3WBnr3.js";import"./cache-state-lld4zuDg.js";import"./link-DsltSF2Q.js";import"./filter-toolbar-VvmMATj0.js";import"./lodash-B4Ozcv0x.js";import"./product-select-_72p-5lF.js";import"./info-card-C9dRgztS.js";import"./action-C2c0yWuW.js";import"./actions-BEUwbsq1.js";import"./click-boundary-Bi28Y0Fq.js";import"./form-CnrBCyTJ.js";import"./tax-code-select-j2arPbaE.js";import"./collapse-BvbJGg1V.js";import"./collapse-CSrlJ0eG.js";const ce=r=>w.get(`/api/tax-rates/${r}`).then(t=>t.data),xe=(r={})=>Object.entries(r).map(([t,n])=>({key:t,value:typeof n=="object"?JSON.stringify(n,null,2):String(n)})),me=r=>r.reduce((t,n)=>{if(!n.key||!n.value)return t;try{t[n.key]=JSON.parse(n.value)}catch{t[n.key]=n.value}return t},{});function He({id:r}){const{t,locale:n}=U(),{isMobile:O}=G(),W=de(),[c,l]=V({editing:{metadata:!1,taxRate:!1},loading:{metadata:!1,taxRate:!1}}),j=Z({defaultValues:{display_name:"",description:"",country:"",state:"",postal_code:"",tax_code:"",percentage:0,metadata:[{key:"",value:""}]}}),{data:a,loading:$,error:C,runAsync:h}=Y(()=>ce(r));if($&&!a)return e.jsx(z,{});if(C)return e.jsx(N,{severity:"error",children:C.message});if(!a)return null;const F=s=>{s==="delete"?W("/admin/tax/rates"):h()},I=()=>{l(s=>({editing:{...s.editing,metadata:!0}}))},B=()=>{j.reset({display_name:a.display_name,description:a.description||"",country:(a.country||"").toLowerCase(),state:a.state||"",postal_code:a.postal_code||"",tax_code:a.tax_code||"",percentage:a.percentage,metadata:xe(a.metadata||{})}),l(s=>({editing:{...s.editing,taxRate:!0}}))},E=async s=>{try{l(i=>({loading:{...i.loading,metadata:!0}})),await w.put(`/api/tax-rates/${r}`,s),f.success(t("common.saved")),S("tax-rate.updated"),h()}catch(i){console.error(i),f.error(A(i))}finally{l(i=>({loading:{...i.loading,metadata:!1}}))}},L=async s=>{try{l(y=>({loading:{...y.loading,taxRate:!0}}));const{metadata:i,...T}=s;await w.put(`/api/tax-rates/${r}`,{...T,percentage:Number(T.percentage),metadata:me(i||[])}),f.success(t("admin.taxRate.updated")),S("tax-rate.updated"),l(y=>({editing:{...y.editing,taxRate:!1}})),h()}catch(i){console.error(i),f.error(A(i))}finally{l(i=>({loading:{...i.loading,taxRate:!1}}))}},p=a.country?se(a.country):null,_=[a.state,a.postal_code].filter(Boolean),k=p?`${p.name}${_.length>0?` · ${_.join(" · ")}`:""}`:"—",u=a.tax_code?ie(a.tax_code,n):null;return e.jsxs(pe,{direction:"column",spacing:2.5,sx:{mb:4},children:[e.jsxs(o,{children:[!a.active&&e.jsx(N,{severity:"warning",sx:{mb:2},children:t("admin.taxRate.inactiveWarning")}),e.jsxs(m,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(m,{direction:"row",onClick:()=>le("/admin/tax/rates"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(P,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(x,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:t("admin.taxRates")})]}),e.jsx(ne,{data:a,onChange:F})]}),e.jsxs(o,{sx:{mt:4,mb:3,display:"flex",gap:{xs:2,sm:2,md:5},flexWrap:"wrap",flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"}},children:[e.jsx(m,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsxs(m,{direction:"column",sx:{alignItems:"flex-start",justifyContent:"space-around"},children:[e.jsx(x,{variant:"h2",sx:{color:"text.primary"},children:a.display_name}),a.description&&e.jsx(x,{variant:"subtitle1",sx:{color:"text.lighter"},children:a.description})]})}),e.jsxs(m,{className:"section-body",sx:{justifyContent:"flex-start",flexWrap:"wrap","hr.MuiDivider-root:last-child":{display:"none"},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:"flex-start",gap:{xs:1,sm:1,md:3}},children:[e.jsx(g,{label:t("common.id"),value:e.jsx(Q,{text:r,style:{marginLeft:4}}),divider:!0}),e.jsx(g,{label:t("admin.taxRate.percentage"),value:`${a.percentage}%`,divider:!0}),e.jsx(g,{label:t("admin.taxRate.location"),value:p?e.jsxs(o,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(D,{iso2:a.country.toLowerCase(),style:{width:24}}),e.jsx(x,{variant:"body2",children:k})]}):k,divider:!0}),e.jsx(g,{label:t("common.createdAt"),value:M(a.created_at),divider:!0})]})]}),e.jsx(v,{})]}),e.jsxs(m,{sx:{flexDirection:{xs:"column",lg:"row"},gap:{xs:2.5,md:4},".tax-column-1":{minWidth:{xs:"100%",lg:"600px"}},".tax-column-2":{width:{xs:"100%",md:"100%",lg:"320px"},maxWidth:{xs:"100%",md:"33%"}}},children:[e.jsxs(o,{className:"tax-column-1",sx:{flex:1,gap:2.5,display:"flex",flexDirection:"column"},children:[e.jsxs(o,{className:"section",sx:{containerType:"inline-size"},children:[e.jsx(R,{title:t("admin.details"),children:e.jsx(b,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},disabled:c.editing.taxRate,onClick:B,children:t("common.edit")})}),e.jsxs(X,{sx:{display:"grid",gridTemplateColumns:{xs:"repeat(1, 1fr)",xl:"repeat(2, 1fr)"},"@container (min-width: 1000px)":{gridTemplateColumns:"repeat(2, 1fr)"},".info-row-wrapper":{gap:1,flexDirection:{xs:"column",xl:"row"},alignItems:{xs:"flex-start",xl:"center"},"@container (min-width: 1000px)":{flexDirection:"row",alignItems:"center"}}},children:[e.jsx(d,{label:t("admin.taxRate.displayName"),value:a.display_name}),e.jsx(d,{label:t("admin.taxRate.country"),value:p?e.jsxs(o,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(D,{iso2:a.country.toLowerCase(),style:{width:24}}),e.jsx(x,{variant:"body2",children:p.name})]}):"—"}),e.jsx(d,{label:t("admin.taxRate.state"),value:a.state||"—"}),e.jsx(d,{label:t("admin.taxRate.postalCode"),value:a.postal_code||"—"}),e.jsx(d,{label:t("admin.taxRate.percentage"),value:`${a.percentage}%`}),e.jsx(d,{label:t("admin.taxRate.taxCode"),value:u?e.jsx(q,{title:u.description,arrow:!0,placement:"top",children:e.jsxs(o,{children:[e.jsx(x,{variant:"body2",sx:{fontWeight:500},children:u.name}),e.jsx(x,{variant:"caption",sx:{color:"text.secondary"},children:u.id})]})}):a.tax_code||"—"}),e.jsx(d,{label:t("common.status"),value:a.active?t("common.active"):t("common.inactive")}),e.jsx(d,{label:t("common.updatedAt"),value:M(a.updated_at)})]})]}),e.jsx(v,{}),e.jsxs(o,{className:"section",children:[e.jsx(R,{title:t("admin.taxRate.associatedInvoices")}),e.jsx(o,{className:"section-body",children:e.jsx(ee,{features:{customer:!0,filter:!1,toolbar:!1},tax_rate_id:r,mode:"admin",status:""})})]})]}),O&&e.jsx(v,{}),e.jsx(o,{className:"tax-column-2",sx:{gap:2.5,display:"flex",flexDirection:"column"},children:e.jsxs(o,{className:"section",children:[e.jsx(R,{title:t("common.metadata.label"),children:e.jsx(b,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},disabled:c.editing.metadata,onClick:I,children:t("common.edit")})}),e.jsxs(o,{className:"section-body",children:[e.jsx(ae,{data:a.metadata||{},handleEditMetadata:I}),c.editing.metadata&&e.jsx(te,{data:a,loading:c.loading.metadata,onSave:E,onCancel:()=>l(s=>({editing:{...s.editing,metadata:!1}}))})]})]})})]}),c.editing.taxRate&&e.jsx(re,{icon:e.jsx(H,{}),text:t("admin.taxRate.edit"),open:c.editing.taxRate,onClose:()=>l(s=>({editing:{...s.editing,taxRate:!1}})),width:640,addons:e.jsx(b,{variant:"contained",size:"small",disabled:c.loading.taxRate,onClick:j.handleSubmit(L),children:t("common.save")}),children:e.jsx(K,{...j,children:e.jsx(oe,{})})})]})}const pe=J(m)``;export{He as default};
1
+ import{j as e,w as z,A as N,B as o,a3 as m,bv as P,q as x,Y as v,x as b,O as q,cA as H,bf as J}from"./vendor-mui-BXZut9Pz.js";import{V as U,Y as V,P as Y,Z as f}from"./vendor-blocklet-B8V2HFST.js";import{d as G,h as Z,ac as D,j as M,F as K,e as w,b8 as S,k as A}from"./index-Bfp56O3W.js";import{C as Q}from"./copyable-Dn7WoFib.js";import{I as g}from"./info-metric-DwDA6oTc.js";import{I as d}from"./info-row-Cr8bdDz0.js";import{I as X}from"./info-row-group-qhfbrxfY.js";import{I as ee}from"./list-CMRLDBem.js";import{M as te}from"./editor-BzrYE3Ds.js";import{M as ae}from"./list-B6NGNObl.js";import{S as R}from"./header-ivXuPt06.js";import{g as se,a as ie,T as ne}from"./tax-utils-BF4tobIJ.js";import{T as oe}from"./index-BXtNZIry.js";import{D as re}from"./drawer-form-CSWrmdZI.js";import{g as le}from"./util-Dp629jKU.js";import{a as de}from"./vendor-react-BPknnnEA.js";import"./table-CyJj8e85.js";import"./cache-state-lld4zuDg.js";import"./link-Dhj5mzaG.js";import"./filter-toolbar-DpJmPWVP.js";import"./lodash-B4Ozcv0x.js";import"./product-select-VFuyl5ev.js";import"./info-card-Xtng8th6.js";import"./action-B9qBcxnd.js";import"./actions-BYX1WnBr.js";import"./click-boundary-Cozpjijr.js";import"./form-nz7nSyN7.js";import"./tax-code-select-CoXANTPX.js";import"./collapse-BvbJGg1V.js";import"./collapse-CSrlJ0eG.js";const ce=r=>w.get(`/api/tax-rates/${r}`).then(t=>t.data),xe=(r={})=>Object.entries(r).map(([t,n])=>({key:t,value:typeof n=="object"?JSON.stringify(n,null,2):String(n)})),me=r=>r.reduce((t,n)=>{if(!n.key||!n.value)return t;try{t[n.key]=JSON.parse(n.value)}catch{t[n.key]=n.value}return t},{});function He({id:r}){const{t,locale:n}=U(),{isMobile:O}=G(),W=de(),[c,l]=V({editing:{metadata:!1,taxRate:!1},loading:{metadata:!1,taxRate:!1}}),j=Z({defaultValues:{display_name:"",description:"",country:"",state:"",postal_code:"",tax_code:"",percentage:0,metadata:[{key:"",value:""}]}}),{data:a,loading:$,error:C,runAsync:h}=Y(()=>ce(r));if($&&!a)return e.jsx(z,{});if(C)return e.jsx(N,{severity:"error",children:C.message});if(!a)return null;const F=s=>{s==="delete"?W("/admin/tax/rates"):h()},I=()=>{l(s=>({editing:{...s.editing,metadata:!0}}))},B=()=>{j.reset({display_name:a.display_name,description:a.description||"",country:(a.country||"").toLowerCase(),state:a.state||"",postal_code:a.postal_code||"",tax_code:a.tax_code||"",percentage:a.percentage,metadata:xe(a.metadata||{})}),l(s=>({editing:{...s.editing,taxRate:!0}}))},E=async s=>{try{l(i=>({loading:{...i.loading,metadata:!0}})),await w.put(`/api/tax-rates/${r}`,s),f.success(t("common.saved")),S("tax-rate.updated"),h()}catch(i){console.error(i),f.error(A(i))}finally{l(i=>({loading:{...i.loading,metadata:!1}}))}},L=async s=>{try{l(y=>({loading:{...y.loading,taxRate:!0}}));const{metadata:i,...T}=s;await w.put(`/api/tax-rates/${r}`,{...T,percentage:Number(T.percentage),metadata:me(i||[])}),f.success(t("admin.taxRate.updated")),S("tax-rate.updated"),l(y=>({editing:{...y.editing,taxRate:!1}})),h()}catch(i){console.error(i),f.error(A(i))}finally{l(i=>({loading:{...i.loading,taxRate:!1}}))}},p=a.country?se(a.country):null,_=[a.state,a.postal_code].filter(Boolean),k=p?`${p.name}${_.length>0?` · ${_.join(" · ")}`:""}`:"—",u=a.tax_code?ie(a.tax_code,n):null;return e.jsxs(pe,{direction:"column",spacing:2.5,sx:{mb:4},children:[e.jsxs(o,{children:[!a.active&&e.jsx(N,{severity:"warning",sx:{mb:2},children:t("admin.taxRate.inactiveWarning")}),e.jsxs(m,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(m,{direction:"row",onClick:()=>le("/admin/tax/rates"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(P,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(x,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:t("admin.taxRates")})]}),e.jsx(ne,{data:a,onChange:F})]}),e.jsxs(o,{sx:{mt:4,mb:3,display:"flex",gap:{xs:2,sm:2,md:5},flexWrap:"wrap",flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"}},children:[e.jsx(m,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsxs(m,{direction:"column",sx:{alignItems:"flex-start",justifyContent:"space-around"},children:[e.jsx(x,{variant:"h2",sx:{color:"text.primary"},children:a.display_name}),a.description&&e.jsx(x,{variant:"subtitle1",sx:{color:"text.lighter"},children:a.description})]})}),e.jsxs(m,{className:"section-body",sx:{justifyContent:"flex-start",flexWrap:"wrap","hr.MuiDivider-root:last-child":{display:"none"},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:"flex-start",gap:{xs:1,sm:1,md:3}},children:[e.jsx(g,{label:t("common.id"),value:e.jsx(Q,{text:r,style:{marginLeft:4}}),divider:!0}),e.jsx(g,{label:t("admin.taxRate.percentage"),value:`${a.percentage}%`,divider:!0}),e.jsx(g,{label:t("admin.taxRate.location"),value:p?e.jsxs(o,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(D,{iso2:a.country.toLowerCase(),style:{width:24}}),e.jsx(x,{variant:"body2",children:k})]}):k,divider:!0}),e.jsx(g,{label:t("common.createdAt"),value:M(a.created_at),divider:!0})]})]}),e.jsx(v,{})]}),e.jsxs(m,{sx:{flexDirection:{xs:"column",lg:"row"},gap:{xs:2.5,md:4},".tax-column-1":{minWidth:{xs:"100%",lg:"600px"}},".tax-column-2":{width:{xs:"100%",md:"100%",lg:"320px"},maxWidth:{xs:"100%",md:"33%"}}},children:[e.jsxs(o,{className:"tax-column-1",sx:{flex:1,gap:2.5,display:"flex",flexDirection:"column"},children:[e.jsxs(o,{className:"section",sx:{containerType:"inline-size"},children:[e.jsx(R,{title:t("admin.details"),children:e.jsx(b,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},disabled:c.editing.taxRate,onClick:B,children:t("common.edit")})}),e.jsxs(X,{sx:{display:"grid",gridTemplateColumns:{xs:"repeat(1, 1fr)",xl:"repeat(2, 1fr)"},"@container (min-width: 1000px)":{gridTemplateColumns:"repeat(2, 1fr)"},".info-row-wrapper":{gap:1,flexDirection:{xs:"column",xl:"row"},alignItems:{xs:"flex-start",xl:"center"},"@container (min-width: 1000px)":{flexDirection:"row",alignItems:"center"}}},children:[e.jsx(d,{label:t("admin.taxRate.displayName"),value:a.display_name}),e.jsx(d,{label:t("admin.taxRate.country"),value:p?e.jsxs(o,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(D,{iso2:a.country.toLowerCase(),style:{width:24}}),e.jsx(x,{variant:"body2",children:p.name})]}):"—"}),e.jsx(d,{label:t("admin.taxRate.state"),value:a.state||"—"}),e.jsx(d,{label:t("admin.taxRate.postalCode"),value:a.postal_code||"—"}),e.jsx(d,{label:t("admin.taxRate.percentage"),value:`${a.percentage}%`}),e.jsx(d,{label:t("admin.taxRate.taxCode"),value:u?e.jsx(q,{title:u.description,arrow:!0,placement:"top",children:e.jsxs(o,{children:[e.jsx(x,{variant:"body2",sx:{fontWeight:500},children:u.name}),e.jsx(x,{variant:"caption",sx:{color:"text.secondary"},children:u.id})]})}):a.tax_code||"—"}),e.jsx(d,{label:t("common.status"),value:a.active?t("common.active"):t("common.inactive")}),e.jsx(d,{label:t("common.updatedAt"),value:M(a.updated_at)})]})]}),e.jsx(v,{}),e.jsxs(o,{className:"section",children:[e.jsx(R,{title:t("admin.taxRate.associatedInvoices")}),e.jsx(o,{className:"section-body",children:e.jsx(ee,{features:{customer:!0,filter:!1,toolbar:!1},tax_rate_id:r,mode:"admin",status:""})})]})]}),O&&e.jsx(v,{}),e.jsx(o,{className:"tax-column-2",sx:{gap:2.5,display:"flex",flexDirection:"column"},children:e.jsxs(o,{className:"section",children:[e.jsx(R,{title:t("common.metadata.label"),children:e.jsx(b,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},disabled:c.editing.metadata,onClick:I,children:t("common.edit")})}),e.jsxs(o,{className:"section-body",children:[e.jsx(ae,{data:a.metadata||{},handleEditMetadata:I}),c.editing.metadata&&e.jsx(te,{data:a,loading:c.loading.metadata,onSave:E,onCancel:()=>l(s=>({editing:{...s.editing,metadata:!1}}))})]})]})})]}),c.editing.taxRate&&e.jsx(re,{icon:e.jsx(H,{}),text:t("admin.taxRate.edit"),open:c.editing.taxRate,onClose:()=>l(s=>({editing:{...s.editing,taxRate:!1}})),width:640,addons:e.jsx(b,{variant:"contained",size:"small",disabled:c.loading.taxRate,onClick:j.handleSubmit(L),children:t("common.save")}),children:e.jsx(K,{...j,children:e.jsx(oe,{})})})]})}const pe=J(m)``;export{He as default};
@@ -1 +1 @@
1
- import{j as e,A as v,w as C,B as o,a3 as r,bv as I,q as p,x as A,N as D,Y as P,bf as N}from"./vendor-mui-BXZut9Pz.js";import{V as S,P as _}from"./vendor-blocklet-B67R14so.js";import{d as R,i as B,a5 as W,n as M,a6 as T,a7 as f,j as L,p as q,e as z}from"./index-B4yaPb7B.js";import{I as y}from"./info-metric-ukWq8INi.js";import{I as l}from"./info-row-CaPaNF4L.js";import{S as H}from"./header-ivXuPt06.js";import{g as O}from"./util-B8B3fsMa.js";import{C as j}from"./link-DsltSF2Q.js";import{I as E}from"./info-row-group-Cxo-4Gk5.js";import{u as F}from"./browser-DF2vfpBa.js";import{e as G}from"./vendor-react-BPknnnEA.js";import"./lodash-B4Ozcv0x.js";const U=t=>z.get(`/api/payouts/${t}`).then(n=>n.data);function oe(){const{t,locale:n}=S(),{isMobile:g}=R(),h=F(),m=G(),{loading:w,error:c,data:s}=_(()=>U(m.id),{ready:!!m.id});if(c)return e.jsx(v,{severity:"error",children:c.message});if(w||!s)return e.jsx(C,{});const x=s.paymentCurrency,b=[B(s?.amount,x.decimal),x.symbol].join(" "),{paymentIntent:a,paymentLink:d}=s||{},i=a?.customer?.metadata?.anonymous;return e.jsxs(V,{direction:"column",spacing:2.5,mb:4,children:[e.jsxs(o,{children:[e.jsxs(r,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[h?e.jsx(o,{}):e.jsxs(r,{direction:"row",onClick:()=>O("/customer/payouts"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(I,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(p,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:t("common.previous")})]}),d?.donation_settings?.reference&&e.jsx(A,{variant:"outlined",onClick:()=>{window.open(d?.donation_settings?.reference,"_blank")},children:t("customer.payout.viewReference")})]}),e.jsxs(o,{sx:{mt:4,mb:3,display:"flex",gap:{xs:2,sm:2,md:5},flexWrap:"wrap",flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"}},children:[e.jsx(r,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsx(r,{direction:"row",sx:{alignItems:"center"},children:e.jsxs(r,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(D,{src:s.paymentCurrency.logo,alt:s.paymentCurrency.symbol,variant:"square",sx:{width:"52px",height:"52px",borderRadius:.5}}),e.jsx(r,{direction:"column",sx:{alignItems:"flex-start",justifyContent:"space-around"},children:e.jsx(W,{amount:b,sx:{my:0,fontSize:"1.75rem",lineHeight:"32px"}})})]})})}),e.jsxs(r,{className:"section-body",sx:{justifyContent:"flex-start",flexWrap:"wrap","hr.MuiDivider-root:last-child":{display:"none"},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:"flex-start",gap:{xs:1,sm:1,md:3}},children:[e.jsx(y,{label:t("common.status"),value:e.jsx(M,{label:s.status,color:T(s.status)}),divider:!0}),e.jsx(y,{label:t("customer.payout.payer"),value:e.jsx(j,{customer:a.customer,cardProps:{onAvatarClick:()=>{i||window.open(f(a?.customer?.did,n),"_blank")},renderName:u=>e.jsx(p,{variant:"subtitle1",sx:{...i?{}:{cursor:"pointer","&:hover":{color:"text.link"}}},onClick:()=>{if(i)return;const k=f(u?.did,n);window.open(k,"_blank")},children:u.fullName})},linked:!1}),divider:!0})]})]}),e.jsx(P,{})]}),e.jsx(r,{sx:{flexDirection:{xs:"column",lg:"row"},gap:{xs:2.5,md:4},".payment-link-column-1":{minWidth:{xs:"100%",lg:"600px"}},".payment-link-column-2":{width:{xs:"100%",md:"100%",lg:"320px"},maxWidth:{xs:"100%",md:"33%"}}},children:e.jsx(o,{className:"payment-link-column-1",sx:{flex:1,gap:2.5,display:"flex",flexDirection:"column"},children:e.jsxs(o,{className:"section",children:[e.jsx(H,{title:t("common.detail")}),e.jsxs(E,{sx:{display:"grid",gridTemplateColumns:{xs:"repeat(1, 1fr)",lg:"repeat(2, 1fr)"},".info-row-wrapper":{gap:1,flexDirection:{xs:"column",lg:"row"},alignItems:{xs:"flex-start",lg:"center"}}},children:[e.jsx(l,{label:t("common.createdAt"),value:L(s.created_at)}),a&&a.payment_details&&e.jsx(l,{label:t("customer.payout.payTxHash"),value:e.jsx(q,{details:a.payment_details,method:s.paymentMethod,mode:"customer"})}),e.jsx(l,{label:t("customer.payout.receiver"),value:e.jsx(j,{customer:s.customer,linked:!1,size:g?"default":"small"})})]})]})})})]})}const V=N(r)``;export{oe as default};
1
+ import{j as e,A as v,w as C,B as o,a3 as r,bv as I,q as p,x as A,N as D,Y as P,bf as N}from"./vendor-mui-BXZut9Pz.js";import{V as S,P as _}from"./vendor-blocklet-B8V2HFST.js";import{d as R,i as B,a5 as W,n as M,a6 as T,a7 as f,j as L,p as q,e as z}from"./index-Bfp56O3W.js";import{I as y}from"./info-metric-DwDA6oTc.js";import{I as l}from"./info-row-Cr8bdDz0.js";import{S as H}from"./header-ivXuPt06.js";import{g as O}from"./util-Dp629jKU.js";import{C as j}from"./link-Dhj5mzaG.js";import{I as E}from"./info-row-group-qhfbrxfY.js";import{u as F}from"./browser-QPNAlSRH.js";import{e as G}from"./vendor-react-BPknnnEA.js";import"./lodash-B4Ozcv0x.js";const U=t=>z.get(`/api/payouts/${t}`).then(n=>n.data);function oe(){const{t,locale:n}=S(),{isMobile:g}=R(),h=F(),m=G(),{loading:w,error:c,data:s}=_(()=>U(m.id),{ready:!!m.id});if(c)return e.jsx(v,{severity:"error",children:c.message});if(w||!s)return e.jsx(C,{});const x=s.paymentCurrency,b=[B(s?.amount,x.decimal),x.symbol].join(" "),{paymentIntent:a,paymentLink:d}=s||{},i=a?.customer?.metadata?.anonymous;return e.jsxs(V,{direction:"column",spacing:2.5,mb:4,children:[e.jsxs(o,{children:[e.jsxs(r,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[h?e.jsx(o,{}):e.jsxs(r,{direction:"row",onClick:()=>O("/customer/payouts"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(I,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(p,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:t("common.previous")})]}),d?.donation_settings?.reference&&e.jsx(A,{variant:"outlined",onClick:()=>{window.open(d?.donation_settings?.reference,"_blank")},children:t("customer.payout.viewReference")})]}),e.jsxs(o,{sx:{mt:4,mb:3,display:"flex",gap:{xs:2,sm:2,md:5},flexWrap:"wrap",flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"}},children:[e.jsx(r,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsx(r,{direction:"row",sx:{alignItems:"center"},children:e.jsxs(r,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(D,{src:s.paymentCurrency.logo,alt:s.paymentCurrency.symbol,variant:"square",sx:{width:"52px",height:"52px",borderRadius:.5}}),e.jsx(r,{direction:"column",sx:{alignItems:"flex-start",justifyContent:"space-around"},children:e.jsx(W,{amount:b,sx:{my:0,fontSize:"1.75rem",lineHeight:"32px"}})})]})})}),e.jsxs(r,{className:"section-body",sx:{justifyContent:"flex-start",flexWrap:"wrap","hr.MuiDivider-root:last-child":{display:"none"},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:"flex-start",gap:{xs:1,sm:1,md:3}},children:[e.jsx(y,{label:t("common.status"),value:e.jsx(M,{label:s.status,color:T(s.status)}),divider:!0}),e.jsx(y,{label:t("customer.payout.payer"),value:e.jsx(j,{customer:a.customer,cardProps:{onAvatarClick:()=>{i||window.open(f(a?.customer?.did,n),"_blank")},renderName:u=>e.jsx(p,{variant:"subtitle1",sx:{...i?{}:{cursor:"pointer","&:hover":{color:"text.link"}}},onClick:()=>{if(i)return;const k=f(u?.did,n);window.open(k,"_blank")},children:u.fullName})},linked:!1}),divider:!0})]})]}),e.jsx(P,{})]}),e.jsx(r,{sx:{flexDirection:{xs:"column",lg:"row"},gap:{xs:2.5,md:4},".payment-link-column-1":{minWidth:{xs:"100%",lg:"600px"}},".payment-link-column-2":{width:{xs:"100%",md:"100%",lg:"320px"},maxWidth:{xs:"100%",md:"33%"}}},children:e.jsx(o,{className:"payment-link-column-1",sx:{flex:1,gap:2.5,display:"flex",flexDirection:"column"},children:e.jsxs(o,{className:"section",children:[e.jsx(H,{title:t("common.detail")}),e.jsxs(E,{sx:{display:"grid",gridTemplateColumns:{xs:"repeat(1, 1fr)",lg:"repeat(2, 1fr)"},".info-row-wrapper":{gap:1,flexDirection:{xs:"column",lg:"row"},alignItems:{xs:"flex-start",lg:"center"}}},children:[e.jsx(l,{label:t("common.createdAt"),value:L(s.created_at)}),a&&a.payment_details&&e.jsx(l,{label:t("customer.payout.payTxHash"),value:e.jsx(q,{details:a.payment_details,method:s.paymentMethod,mode:"customer"})}),e.jsx(l,{label:t("customer.payout.receiver"),value:e.jsx(j,{customer:s.customer,linked:!1,size:g?"default":"small"})})]})]})})})]})}const V=N(r)``;export{oe as default};
@@ -1 +1 @@
1
- import{j as e,A,w as R,B as n,a3 as i,bv as T,q as $,N as E,Y as d,O as B,be as L,x as W,bf as z}from"./vendor-mui-BXZut9Pz.js";import{V as O,Y as H,P as q,Z as _}from"./vendor-blocklet-B67R14so.js";import{d as G,i as P,a5 as U,n as I,bd as w,j,p as F,e as M,k as Y}from"./index-B4yaPb7B.js";import{T as J}from"./gas-kw2KMH1u.js";import{L as u}from"./vendor-react-BPknnnEA.js";import{l as V}from"./lodash-B4Ozcv0x.js";import{C as Z}from"./copyable-CprMHdhV.js";import{C as K}from"./link-DsltSF2Q.js";import{E as Q}from"./list-CvM46TsP.js";import{I as C}from"./info-metric-ukWq8INi.js";import{I as s}from"./info-row-CaPaNF4L.js";import{M as X}from"./editor-vZvxDUTl.js";import{M as ee}from"./list-B2b-s8wM.js";import{R as te}from"./actions-DeCPtfTK.js";import{S as x}from"./header-ivXuPt06.js";import{g as ae}from"./util-B8B3fsMa.js";import{I as se}from"./info-row-group-Cxo-4Gk5.js";import"./table-BN3WBnr3.js";import"./form-CnrBCyTJ.js";import"./actions-BEUwbsq1.js";import"./click-boundary-Bi28Y0Fq.js";const ne=c=>M.get(`/api/refunds/${c}`).then(a=>a.data),o="column",r="flex-start";function Se(c){const{t:a}=O(),{isMobile:k}=G(),[f,p]=H({adding:{price:!1},editing:{metadata:!1,product:!1},loading:{metadata:!1,price:!1,product:!1}}),{loading:S,error:h,data:t,runAsync:y}=q(()=>ne(c.id));if(h)return e.jsx(A,{severity:"error",children:h.message});if(S||!t)return e.jsx(R,{});const N=(m=>async D=>{try{p(l=>({loading:{...l.loading,[m]:!0}})),await M.put(`/api/refunds/${c.id}`,D).then(l=>l.data),_.success(a("common.saved")),y()}catch(l){console.error(l),_.error(Y(l))}finally{p(l=>({loading:{...l.loading,[m]:!1}}))}})("metadata"),g=t.paymentCurrency,b=[P(t?.amount,g.decimal),g.symbol].join(" "),v=()=>{p(m=>({editing:{...m.editing,metadata:!0}}))};return e.jsxs(ie,{direction:"column",spacing:2.5,mb:4,children:[e.jsxs(n,{children:[e.jsxs(i,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(i,{direction:"row",onClick:()=>ae("/admin/payments/refunds"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(T,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx($,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:a("admin.refunds")})]}),e.jsx(te,{data:t,variant:"normal",onChange:()=>y()})]}),e.jsxs(n,{sx:{mt:4,mb:3,display:"flex",gap:{xs:2,sm:2,md:5},flexWrap:"wrap",flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"}},children:[e.jsx(i,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsxs(i,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(E,{src:t.paymentCurrency.logo,alt:t.paymentCurrency.symbol,variant:"square",sx:{width:"52px",height:"52px",borderRadius:.5}}),e.jsxs(i,{direction:"column",sx:{alignItems:"flex-start",justifyContent:"space-around"},children:[e.jsx(U,{amount:b,sx:{my:0,fontSize:"1.75rem",lineHeight:"32px"}}),e.jsx(Z,{text:c.id})]})]})}),e.jsxs(i,{className:"section-body",sx:{justifyContent:"flex-start",flexWrap:"wrap","hr.MuiDivider-root:last-child":{display:"none"},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:"flex-start",gap:{xs:1,sm:1,md:3}},children:[e.jsx(C,{label:a("common.status"),value:e.jsx(I,{label:t.status,color:w(t.status)}),divider:!0}),e.jsx(C,{label:a("common.customer"),value:e.jsx(K,{customer:t.customer})})]})]}),e.jsx(d,{})]}),e.jsxs(i,{sx:{flexDirection:{xs:"column",lg:"row"},gap:{xs:2.5,md:4},".payment-link-column-1":{minWidth:{xs:"100%",lg:"600px"}},".payment-link-column-2":{width:{xs:"100%",md:"100%",lg:"320px"},maxWidth:{xs:"100%",md:"33%"}}},children:[e.jsxs(n,{className:"payment-link-column-1",sx:{flex:1,gap:2.5,display:"flex",flexDirection:"column"},children:[e.jsxs(n,{className:"section",sx:{containerType:"inline-size"},children:[e.jsx(x,{title:a("admin.details")}),e.jsxs(se,{sx:{display:"grid",gridTemplateColumns:{xs:"repeat(1, 1fr)",xl:"repeat(2, 1fr)"},"@container (min-width: 1000px)":{gridTemplateColumns:"repeat(2, 1fr)"},".info-row-wrapper":{gap:1,flexDirection:{xs:"column",xl:"row"},alignItems:{xs:"flex-start",xl:"center"},"@container (min-width: 1000px)":{flexDirection:"row",alignItems:"center"}}},children:[e.jsx(s,{label:a("common.status"),value:e.jsxs(i,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(I,{label:t.status,color:w(t.status)}),t.last_attempt_error&&t.status!=="canceled"&&e.jsx(B,{title:e.jsx("pre",{style:{whiteSpace:"break-spaces"},children:JSON.stringify({...t.last_attempt_error,next_attempt:t.next_attempt?j(t.next_attempt*1e3):"-",attempt_count:t.attempt_count,type:V.startCase(t.last_attempt_error?.type)},null,2)}),children:e.jsx(L,{fontSize:"small",color:"error"})})]})}),e.jsx(s,{label:a("common.amount"),value:b}),e.jsx(s,{label:a("common.type"),value:a(`refund.type.${t.type}`)}),e.jsx(s,{label:a("common.createdAt"),value:j(t.created_at)}),e.jsx(s,{label:a("common.description"),value:t.description}),e.jsx(s,{label:a("common.updatedAt"),value:j(t.updated_at)})]})]}),e.jsx(d,{}),e.jsxs(n,{className:"section",children:[e.jsx(x,{title:a("admin.events.title")}),e.jsx(n,{className:"section-body",children:e.jsx(Q,{features:{toolbar:!1},object_id:t.id})})]})]}),k&&e.jsx(d,{}),e.jsxs(n,{className:"payment-link-column-2",sx:{gap:2.5,display:"flex",flexDirection:"column"},children:[t.paymentMethod&&e.jsxs(e.Fragment,{children:[e.jsxs(n,{className:"section",children:[e.jsx(x,{title:a("admin.paymentMethod._name")}),e.jsxs(i,{children:[e.jsx(s,{label:a("common.id"),value:t.paymentMethod.id,direction:o,alignItems:r}),e.jsx(s,{label:a("admin.paymentMethod.type"),value:t.paymentMethod.type,direction:o,alignItems:r}),e.jsx(s,{label:a("admin.paymentCurrency.name"),value:`${t.paymentCurrency.symbol} (${t.paymentMethod.name})`,direction:o,alignItems:r}),(!!t.payment_details?.ethereum||!!t.payment_details?.base)&&e.jsx(s,{label:a("common.txGas"),value:e.jsx(J,{details:t.payment_details,method:t.paymentMethod}),direction:o,alignItems:r}),e.jsx(s,{label:a("common.txHash"),value:e.jsx(F,{details:t.payment_details,method:t.paymentMethod}),direction:o,alignItems:r})]})]}),e.jsx(d,{})]}),e.jsxs(n,{className:"section",children:[e.jsx(x,{title:a("admin.connections")}),e.jsxs(i,{children:[e.jsx(s,{label:a("admin.subscription.name"),value:t.subscription?e.jsx(u,{to:`/admin/billing/${t.subscription.id}`,children:t.subscription.id}):"",direction:o,alignItems:r}),e.jsx(s,{label:a("admin.invoice.name"),value:t.invoice_id?e.jsx(u,{to:`/admin/billing/${t.invoice_id}`,children:t.invoice_id}):"",direction:o,alignItems:r}),e.jsx(s,{label:a("admin.customers"),value:t.customer_id?e.jsx(u,{to:`/admin/customers/${t.customer_id}`,children:t.customer_id}):"",direction:o,alignItems:r}),e.jsx(s,{label:a("admin.payments"),value:t.payment_intent_id?e.jsx(u,{to:`/admin/payments/${t.payment_intent_id}`,children:t.payment_intent_id}):"",direction:o,alignItems:r})]})]}),e.jsx(d,{}),e.jsxs(n,{className:"section",children:[e.jsx(x,{title:a("common.metadata.label"),children:e.jsx(W,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},disabled:f.editing.metadata,onClick:v,children:a("common.edit")})}),e.jsxs(n,{className:"section-body",children:[e.jsx(ee,{data:t.metadata,handleEditMetadata:v}),f.editing.metadata&&e.jsx(X,{data:t,loading:f.loading.metadata,onSave:N,onCancel:()=>p(m=>({editing:{...m.editing,metadata:!1}}))})]})]})]})]})]})}const ie=z(i)``;export{Se as default};
1
+ import{j as e,A,w as R,B as n,a3 as i,bv as T,q as $,N as E,Y as d,O as B,be as L,x as W,bf as z}from"./vendor-mui-BXZut9Pz.js";import{V as O,Y as H,P as q,Z as _}from"./vendor-blocklet-B8V2HFST.js";import{d as G,i as P,a5 as U,n as I,bd as w,j,p as F,e as M,k as Y}from"./index-Bfp56O3W.js";import{T as J}from"./gas-BGJEvZ8T.js";import{L as u}from"./vendor-react-BPknnnEA.js";import{l as V}from"./lodash-B4Ozcv0x.js";import{C as Z}from"./copyable-Dn7WoFib.js";import{C as K}from"./link-Dhj5mzaG.js";import{E as Q}from"./list-CQ5uQIra.js";import{I as C}from"./info-metric-DwDA6oTc.js";import{I as s}from"./info-row-Cr8bdDz0.js";import{M as X}from"./editor-BzrYE3Ds.js";import{M as ee}from"./list-B6NGNObl.js";import{R as te}from"./actions-BvdAKBBR.js";import{S as x}from"./header-ivXuPt06.js";import{g as ae}from"./util-Dp629jKU.js";import{I as se}from"./info-row-group-qhfbrxfY.js";import"./table-CyJj8e85.js";import"./form-nz7nSyN7.js";import"./actions-BYX1WnBr.js";import"./click-boundary-Cozpjijr.js";const ne=c=>M.get(`/api/refunds/${c}`).then(a=>a.data),o="column",r="flex-start";function Se(c){const{t:a}=O(),{isMobile:k}=G(),[f,p]=H({adding:{price:!1},editing:{metadata:!1,product:!1},loading:{metadata:!1,price:!1,product:!1}}),{loading:S,error:h,data:t,runAsync:y}=q(()=>ne(c.id));if(h)return e.jsx(A,{severity:"error",children:h.message});if(S||!t)return e.jsx(R,{});const N=(m=>async D=>{try{p(l=>({loading:{...l.loading,[m]:!0}})),await M.put(`/api/refunds/${c.id}`,D).then(l=>l.data),_.success(a("common.saved")),y()}catch(l){console.error(l),_.error(Y(l))}finally{p(l=>({loading:{...l.loading,[m]:!1}}))}})("metadata"),g=t.paymentCurrency,b=[P(t?.amount,g.decimal),g.symbol].join(" "),v=()=>{p(m=>({editing:{...m.editing,metadata:!0}}))};return e.jsxs(ie,{direction:"column",spacing:2.5,mb:4,children:[e.jsxs(n,{children:[e.jsxs(i,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(i,{direction:"row",onClick:()=>ae("/admin/payments/refunds"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(T,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx($,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:a("admin.refunds")})]}),e.jsx(te,{data:t,variant:"normal",onChange:()=>y()})]}),e.jsxs(n,{sx:{mt:4,mb:3,display:"flex",gap:{xs:2,sm:2,md:5},flexWrap:"wrap",flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"}},children:[e.jsx(i,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsxs(i,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(E,{src:t.paymentCurrency.logo,alt:t.paymentCurrency.symbol,variant:"square",sx:{width:"52px",height:"52px",borderRadius:.5}}),e.jsxs(i,{direction:"column",sx:{alignItems:"flex-start",justifyContent:"space-around"},children:[e.jsx(U,{amount:b,sx:{my:0,fontSize:"1.75rem",lineHeight:"32px"}}),e.jsx(Z,{text:c.id})]})]})}),e.jsxs(i,{className:"section-body",sx:{justifyContent:"flex-start",flexWrap:"wrap","hr.MuiDivider-root:last-child":{display:"none"},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:"flex-start",gap:{xs:1,sm:1,md:3}},children:[e.jsx(C,{label:a("common.status"),value:e.jsx(I,{label:t.status,color:w(t.status)}),divider:!0}),e.jsx(C,{label:a("common.customer"),value:e.jsx(K,{customer:t.customer})})]})]}),e.jsx(d,{})]}),e.jsxs(i,{sx:{flexDirection:{xs:"column",lg:"row"},gap:{xs:2.5,md:4},".payment-link-column-1":{minWidth:{xs:"100%",lg:"600px"}},".payment-link-column-2":{width:{xs:"100%",md:"100%",lg:"320px"},maxWidth:{xs:"100%",md:"33%"}}},children:[e.jsxs(n,{className:"payment-link-column-1",sx:{flex:1,gap:2.5,display:"flex",flexDirection:"column"},children:[e.jsxs(n,{className:"section",sx:{containerType:"inline-size"},children:[e.jsx(x,{title:a("admin.details")}),e.jsxs(se,{sx:{display:"grid",gridTemplateColumns:{xs:"repeat(1, 1fr)",xl:"repeat(2, 1fr)"},"@container (min-width: 1000px)":{gridTemplateColumns:"repeat(2, 1fr)"},".info-row-wrapper":{gap:1,flexDirection:{xs:"column",xl:"row"},alignItems:{xs:"flex-start",xl:"center"},"@container (min-width: 1000px)":{flexDirection:"row",alignItems:"center"}}},children:[e.jsx(s,{label:a("common.status"),value:e.jsxs(i,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(I,{label:t.status,color:w(t.status)}),t.last_attempt_error&&t.status!=="canceled"&&e.jsx(B,{title:e.jsx("pre",{style:{whiteSpace:"break-spaces"},children:JSON.stringify({...t.last_attempt_error,next_attempt:t.next_attempt?j(t.next_attempt*1e3):"-",attempt_count:t.attempt_count,type:V.startCase(t.last_attempt_error?.type)},null,2)}),children:e.jsx(L,{fontSize:"small",color:"error"})})]})}),e.jsx(s,{label:a("common.amount"),value:b}),e.jsx(s,{label:a("common.type"),value:a(`refund.type.${t.type}`)}),e.jsx(s,{label:a("common.createdAt"),value:j(t.created_at)}),e.jsx(s,{label:a("common.description"),value:t.description}),e.jsx(s,{label:a("common.updatedAt"),value:j(t.updated_at)})]})]}),e.jsx(d,{}),e.jsxs(n,{className:"section",children:[e.jsx(x,{title:a("admin.events.title")}),e.jsx(n,{className:"section-body",children:e.jsx(Q,{features:{toolbar:!1},object_id:t.id})})]})]}),k&&e.jsx(d,{}),e.jsxs(n,{className:"payment-link-column-2",sx:{gap:2.5,display:"flex",flexDirection:"column"},children:[t.paymentMethod&&e.jsxs(e.Fragment,{children:[e.jsxs(n,{className:"section",children:[e.jsx(x,{title:a("admin.paymentMethod._name")}),e.jsxs(i,{children:[e.jsx(s,{label:a("common.id"),value:t.paymentMethod.id,direction:o,alignItems:r}),e.jsx(s,{label:a("admin.paymentMethod.type"),value:t.paymentMethod.type,direction:o,alignItems:r}),e.jsx(s,{label:a("admin.paymentCurrency.name"),value:`${t.paymentCurrency.symbol} (${t.paymentMethod.name})`,direction:o,alignItems:r}),(!!t.payment_details?.ethereum||!!t.payment_details?.base)&&e.jsx(s,{label:a("common.txGas"),value:e.jsx(J,{details:t.payment_details,method:t.paymentMethod}),direction:o,alignItems:r}),e.jsx(s,{label:a("common.txHash"),value:e.jsx(F,{details:t.payment_details,method:t.paymentMethod}),direction:o,alignItems:r})]})]}),e.jsx(d,{})]}),e.jsxs(n,{className:"section",children:[e.jsx(x,{title:a("admin.connections")}),e.jsxs(i,{children:[e.jsx(s,{label:a("admin.subscription.name"),value:t.subscription?e.jsx(u,{to:`/admin/billing/${t.subscription.id}`,children:t.subscription.id}):"",direction:o,alignItems:r}),e.jsx(s,{label:a("admin.invoice.name"),value:t.invoice_id?e.jsx(u,{to:`/admin/billing/${t.invoice_id}`,children:t.invoice_id}):"",direction:o,alignItems:r}),e.jsx(s,{label:a("admin.customers"),value:t.customer_id?e.jsx(u,{to:`/admin/customers/${t.customer_id}`,children:t.customer_id}):"",direction:o,alignItems:r}),e.jsx(s,{label:a("admin.payments"),value:t.payment_intent_id?e.jsx(u,{to:`/admin/payments/${t.payment_intent_id}`,children:t.payment_intent_id}):"",direction:o,alignItems:r})]})]}),e.jsx(d,{}),e.jsxs(n,{className:"section",children:[e.jsx(x,{title:a("common.metadata.label"),children:e.jsx(W,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},disabled:f.editing.metadata,onClick:v,children:a("common.edit")})}),e.jsxs(n,{className:"section-body",children:[e.jsx(ee,{data:t.metadata,handleEditMetadata:v}),f.editing.metadata&&e.jsx(X,{data:t,loading:f.loading.metadata,onSave:N,onCancel:()=>p(m=>({editing:{...m.editing,metadata:!1}}))})]})]})]})]})]})}const ie=z(i)``;export{Se as default};
@@ -1 +1 @@
1
- import{j as e,A as E,w as z,$ as j,a3 as m,bv as U,q as x,B as o,Y as u,x as F,bf as O}from"./vendor-mui-BXZut9Pz.js";import{V as Y,Y as G,P as H,F as P,Z as f}from"./vendor-blocklet-B67R14so.js";import{a as V,Y as L,T as Z,j as C,e as h,k as N}from"./index-B4yaPb7B.js";import{a as J,L as I}from"./vendor-react-BPknnnEA.js";import{C as A}from"./copyable-CprMHdhV.js";import{E as K}from"./list-CvM46TsP.js";import{I as Q}from"./info-card-C9dRgztS.js";import{I as r}from"./info-row-CaPaNF4L.js";import{M as X}from"./editor-vZvxDUTl.js";import{M as ee}from"./list-B2b-s8wM.js";import{P as te}from"./actions-izdZ2Mn4.js";import{P as ae}from"./preview-Bdtbh-xk.js";import{A as ie}from"./add-price-TdXAR3NW.js";import{S as p}from"./header-ivXuPt06.js";import{q as ne,g as se,n as oe}from"./util-B8B3fsMa.js";import{I as D}from"./info-metric-ukWq8INi.js";import{I as re}from"./info-row-group-Cxo-4Gk5.js";import"./table-BN3WBnr3.js";import"./lodash-B4Ozcv0x.js";import"./form-CnrBCyTJ.js";import"./actions-BEUwbsq1.js";import"./click-boundary-Bi28Y0Fq.js";import"./assign-DKRfmN7W.js";import"./chrome-BPS46pXA.js";import"./form-AFzUvoFE.js";import"./collapse-CSrlJ0eG.js";import"./product-select-_72p-5lF.js";import"./currency-select-C8j7QQMP.js";import"./currency-GstdXsJf.js";import"./uploader-BLdAbLR6.js";import"./tax-code-select-j2arPbaE.js";import"./collapse-BvbJGg1V.js";const le=c=>h.get(`/api/payment-links/${c}`).then(t=>t.data);function Ue(c){const{t,locale:y}=Y(),M=J(),{settings:b}=V(),[d,l]=G({adding:{price:!1},editing:{metadata:!1,product:!1},loading:{metadata:!1,price:!1,product:!1}}),{loading:$,error:w,data:a,runAsync:g}=H(()=>le(c.id));if(w)return e.jsx(E,{severity:"error",children:w.message});if($||!a)return e.jsx(z,{});const q=i=>async s=>{try{l(n=>({loading:{...n.loading,[i]:!0}})),await h.put(`/api/payment-links/${c.id}`,s).then(n=>n.data),f.success(t("common.saved")),g()}catch(n){console.error(n),f.error(N(n))}finally{l(n=>({loading:{...n.loading,[i]:!1}}))}},S=async i=>{try{l(s=>({loading:{...s.loading,price:!0}})),await h.post("/api/prices",{...i,product_id:c.id}),f.success(t("common.saved")),g()}catch(s){throw console.error(s),f.error(N(s)),s}finally{l(s=>({loading:{...s.loading,price:!1}}))}},B=q("metadata"),W=i=>{i==="remove"?M("/admin/products/links"):g()},k=L(b.paymentMethods,a?.currency_id??""),R=ne(a,k,y),_=()=>{l(i=>({editing:{...i.editing,metadata:!0}}))},T=i=>i.type==="hosted_confirmation"?e.jsx(x,{children:i.hosted_confirmation.custom_message||t("common.none")}):i.type==="redirect"&&i.redirect.url?e.jsx(I,{to:i.redirect.url,children:i.redirect.url}):t("common.none");return e.jsxs(j,{container:!0,spacing:4,sx:{mb:4},children:[e.jsxs(j,{size:12,children:[e.jsxs(m,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(m,{direction:"row",onClick:()=>se("/admin/products/links"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(U,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(x,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:t("admin.paymentLinks")})]}),e.jsx(te,{data:a,onChange:W,variant:"normal"})]}),e.jsxs(o,{sx:{mt:4,mb:3,display:"flex",gap:{xs:2,sm:2,md:5},flexWrap:"wrap",flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"}},children:[e.jsx(m,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsxs(m,{sx:{gap:1},children:[e.jsx(x,{variant:"h1",children:a.name}),e.jsx(A,{text:P(window.blocklet.appUrl,window.blocklet.prefix,`/checkout/pay/${a.id}`),children:e.jsx(x,{variant:"h6",sx:{color:"text.secondary",mr:1,maxWidth:"80%",textOverflow:"ellipsis",overflow:"hidden"},children:P(window.blocklet.prefix,`/checkout/pay/${a.id}`)})})]})}),e.jsxs(m,{className:"section-body",sx:{justifyContent:"flex-start",flexWrap:"wrap","hr.MuiDivider-root:last-child":{display:"none"},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:"flex-start",gap:{xs:1,sm:1,md:3}},children:[e.jsx(D,{label:t("common.price"),value:R.priceDisplay,divider:!0}),e.jsx(D,{label:t("common.id"),value:e.jsx(A,{text:c.id,style:{marginLeft:4}}),divider:!0})]})]}),e.jsx(u,{})]}),e.jsx(j,{size:12,children:e.jsxs(m,{sx:{flexDirection:{xs:"column",lg:"row"},gap:4,".payment-link-column-1":{minWidth:{xs:"100%",lg:"600px"}},".payment-link-column-2":{width:{xs:"100%",md:"100%",lg:"320px"},maxWidth:{xs:"100%",md:"33%"}}},children:[e.jsx(o,{className:"payment-link-column-1",sx:{flex:1},children:e.jsxs(me,{direction:"column",spacing:3,children:[e.jsxs(o,{className:"section",children:[e.jsx(p,{title:t("admin.products")}),e.jsxs(o,{className:"section-body",children:[e.jsx(Z,{className:"link-products-table",toolbar:!1,footer:!1,locale:y,data:a.line_items,columns:[{label:t("common.title"),name:"name",options:{sort:!1,customBodyRenderLite:(i,s)=>{const n=a.line_items[s],v=k||L(b.paymentMethods,n?.price?.currency_id??"");return e.jsx(I,{to:`/admin/products/${n.price.product_id}?currency_id=${v?.id}&price_id=${n.price.id}`,children:e.jsx(Q,{name:n.price.product.name,description:oe({...n.price.product,prices:[n.price]},v,y),logo:n.price.product.images[0]})})}}},{label:t("common.quantity"),name:"quantity",align:"right"},{label:t("admin.paymentLink.adjustable"),name:"price_id",align:"right",options:{customBodyRenderLite:(i,s)=>{const n=a.line_items[s];return n?.adjustable_quantity?.enabled?`${t("common.yes")} (${n.adjustable_quantity.minimum} - ${n.adjustable_quantity.maximum})`:t("common.no")}}}],options:{count:a.line_items.length,page:0,rowsPerPage:20}}),d.adding.price&&e.jsx(ie,{loading:d.loading.price,onSave:S,onCancel:()=>l(i=>({adding:{...i.adding,price:!1}}))})]})]}),e.jsx(u,{}),e.jsxs(o,{className:"section",children:[e.jsx(p,{title:t("admin.details")}),e.jsxs(re,{sx:{display:"grid",gridTemplateColumns:{xs:"repeat(1, 1fr)",xl:"repeat(2, 1fr)"},"@container (min-width: 1000px)":{gridTemplateColumns:"repeat(2, 1fr)"},".info-row-wrapper":{gap:1,flexDirection:{xs:"column",xl:"row"},alignItems:{xs:"flex-start",xl:"center"},"@container (min-width: 1000px)":{flexDirection:"row",alignItems:"center"}}},children:[e.jsx(r,{label:t("admin.paymentLink.allowPromotionCodes"),value:a.allow_promotion_codes?t("common.yes"):t("common.no")}),e.jsx(r,{label:t("admin.paymentLink.includeFreeTrial"),value:a.subscription_data?.trial_period_days?t("common.yes"):t("common.no")}),e.jsx(r,{label:t("admin.paymentLink.requireBillingAddress"),value:a.billing_address_collection?t("common.yes"):t("common.no")}),e.jsx(r,{label:t("admin.paymentLink.requirePhoneNumber"),value:a.phone_number_collection?.enabled?t("common.yes"):t("common.no")}),e.jsx(r,{label:t("admin.paymentLink.allowSkipPaymentMethod"),value:a.metadata?.allow_skip_payment_method==="true"?t("common.yes"):t("common.no")}),e.jsx(r,{label:t("admin.paymentLink.showConfirmPage"),value:T(a.after_completion)}),e.jsx(r,{label:t("admin.paymentLink.mintNft"),value:a.nft_mint_settings?.factory||""}),e.jsx(r,{label:t("common.createdAt"),value:C(a.created_at)}),e.jsx(r,{label:t("common.updatedAt"),value:C(a.updated_at)})]})]}),e.jsx(u,{}),e.jsxs(o,{className:"section",children:[e.jsx(p,{title:t("common.preview")}),e.jsx(o,{className:"section-body",sx:{maxWidth:1050},children:e.jsx(ae,{id:a.id})})]}),e.jsx(u,{}),e.jsxs(o,{className:"section",children:[e.jsx(p,{title:t("admin.events.title")}),e.jsx(o,{className:"section-body",children:e.jsx(K,{features:{toolbar:!1},object_id:a.id})})]})]})}),e.jsx(o,{className:"payment-link-column-2",children:e.jsxs(o,{className:"section",children:[e.jsx(p,{title:t("common.metadata.label"),children:e.jsx(F,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},disabled:d.editing.metadata,onClick:_,children:t("common.edit")})}),e.jsxs(o,{className:"section-body",children:[e.jsx(ee,{data:a.metadata,handleEditMetadata:_}),d.editing.metadata&&e.jsx(X,{data:a,loading:d.loading.metadata,onSave:B,onCancel:()=>l(i=>({editing:{...i.editing,metadata:!1}}))})]})]})})]})})]})}const me=O(m)``;export{Ue as default};
1
+ import{j as e,A as E,w as z,$ as j,a3 as m,bv as U,q as x,B as o,Y as u,x as F,bf as O}from"./vendor-mui-BXZut9Pz.js";import{V as Y,Y as G,P as H,F as P,Z as f}from"./vendor-blocklet-B8V2HFST.js";import{a as V,Y as L,T as Z,j as C,e as h,k as N}from"./index-Bfp56O3W.js";import{a as J,L as I}from"./vendor-react-BPknnnEA.js";import{C as A}from"./copyable-Dn7WoFib.js";import{E as K}from"./list-CQ5uQIra.js";import{I as Q}from"./info-card-Xtng8th6.js";import{I as r}from"./info-row-Cr8bdDz0.js";import{M as X}from"./editor-BzrYE3Ds.js";import{M as ee}from"./list-B6NGNObl.js";import{P as te}from"./actions-CYXoOOED.js";import{P as ae}from"./preview-DV7989ox.js";import{A as ie}from"./add-price-BxoCZ-Tz.js";import{S as p}from"./header-ivXuPt06.js";import{q as ne,g as se,n as oe}from"./util-Dp629jKU.js";import{I as D}from"./info-metric-DwDA6oTc.js";import{I as re}from"./info-row-group-qhfbrxfY.js";import"./table-CyJj8e85.js";import"./lodash-B4Ozcv0x.js";import"./form-nz7nSyN7.js";import"./actions-BYX1WnBr.js";import"./click-boundary-Cozpjijr.js";import"./assign-BOWJRdk_.js";import"./chrome-BPS46pXA.js";import"./form-DPTZI-Fw.js";import"./collapse-CSrlJ0eG.js";import"./product-select-VFuyl5ev.js";import"./currency-select-3BZ7dBe5.js";import"./currency-GstdXsJf.js";import"./uploader-CV9IVKh1.js";import"./tax-code-select-CoXANTPX.js";import"./collapse-BvbJGg1V.js";const le=c=>h.get(`/api/payment-links/${c}`).then(t=>t.data);function Ue(c){const{t,locale:y}=Y(),M=J(),{settings:b}=V(),[d,l]=G({adding:{price:!1},editing:{metadata:!1,product:!1},loading:{metadata:!1,price:!1,product:!1}}),{loading:$,error:w,data:a,runAsync:g}=H(()=>le(c.id));if(w)return e.jsx(E,{severity:"error",children:w.message});if($||!a)return e.jsx(z,{});const q=i=>async s=>{try{l(n=>({loading:{...n.loading,[i]:!0}})),await h.put(`/api/payment-links/${c.id}`,s).then(n=>n.data),f.success(t("common.saved")),g()}catch(n){console.error(n),f.error(N(n))}finally{l(n=>({loading:{...n.loading,[i]:!1}}))}},S=async i=>{try{l(s=>({loading:{...s.loading,price:!0}})),await h.post("/api/prices",{...i,product_id:c.id}),f.success(t("common.saved")),g()}catch(s){throw console.error(s),f.error(N(s)),s}finally{l(s=>({loading:{...s.loading,price:!1}}))}},B=q("metadata"),W=i=>{i==="remove"?M("/admin/products/links"):g()},k=L(b.paymentMethods,a?.currency_id??""),R=ne(a,k,y),_=()=>{l(i=>({editing:{...i.editing,metadata:!0}}))},T=i=>i.type==="hosted_confirmation"?e.jsx(x,{children:i.hosted_confirmation.custom_message||t("common.none")}):i.type==="redirect"&&i.redirect.url?e.jsx(I,{to:i.redirect.url,children:i.redirect.url}):t("common.none");return e.jsxs(j,{container:!0,spacing:4,sx:{mb:4},children:[e.jsxs(j,{size:12,children:[e.jsxs(m,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(m,{direction:"row",onClick:()=>se("/admin/products/links"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(U,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(x,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:t("admin.paymentLinks")})]}),e.jsx(te,{data:a,onChange:W,variant:"normal"})]}),e.jsxs(o,{sx:{mt:4,mb:3,display:"flex",gap:{xs:2,sm:2,md:5},flexWrap:"wrap",flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"}},children:[e.jsx(m,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsxs(m,{sx:{gap:1},children:[e.jsx(x,{variant:"h1",children:a.name}),e.jsx(A,{text:P(window.blocklet.appUrl,window.blocklet.prefix,`/checkout/pay/${a.id}`),children:e.jsx(x,{variant:"h6",sx:{color:"text.secondary",mr:1,maxWidth:"80%",textOverflow:"ellipsis",overflow:"hidden"},children:P(window.blocklet.prefix,`/checkout/pay/${a.id}`)})})]})}),e.jsxs(m,{className:"section-body",sx:{justifyContent:"flex-start",flexWrap:"wrap","hr.MuiDivider-root:last-child":{display:"none"},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:"flex-start",gap:{xs:1,sm:1,md:3}},children:[e.jsx(D,{label:t("common.price"),value:R.priceDisplay,divider:!0}),e.jsx(D,{label:t("common.id"),value:e.jsx(A,{text:c.id,style:{marginLeft:4}}),divider:!0})]})]}),e.jsx(u,{})]}),e.jsx(j,{size:12,children:e.jsxs(m,{sx:{flexDirection:{xs:"column",lg:"row"},gap:4,".payment-link-column-1":{minWidth:{xs:"100%",lg:"600px"}},".payment-link-column-2":{width:{xs:"100%",md:"100%",lg:"320px"},maxWidth:{xs:"100%",md:"33%"}}},children:[e.jsx(o,{className:"payment-link-column-1",sx:{flex:1},children:e.jsxs(me,{direction:"column",spacing:3,children:[e.jsxs(o,{className:"section",children:[e.jsx(p,{title:t("admin.products")}),e.jsxs(o,{className:"section-body",children:[e.jsx(Z,{className:"link-products-table",toolbar:!1,footer:!1,locale:y,data:a.line_items,columns:[{label:t("common.title"),name:"name",options:{sort:!1,customBodyRenderLite:(i,s)=>{const n=a.line_items[s],v=k||L(b.paymentMethods,n?.price?.currency_id??"");return e.jsx(I,{to:`/admin/products/${n.price.product_id}?currency_id=${v?.id}&price_id=${n.price.id}`,children:e.jsx(Q,{name:n.price.product.name,description:oe({...n.price.product,prices:[n.price]},v,y),logo:n.price.product.images[0]})})}}},{label:t("common.quantity"),name:"quantity",align:"right"},{label:t("admin.paymentLink.adjustable"),name:"price_id",align:"right",options:{customBodyRenderLite:(i,s)=>{const n=a.line_items[s];return n?.adjustable_quantity?.enabled?`${t("common.yes")} (${n.adjustable_quantity.minimum} - ${n.adjustable_quantity.maximum})`:t("common.no")}}}],options:{count:a.line_items.length,page:0,rowsPerPage:20}}),d.adding.price&&e.jsx(ie,{loading:d.loading.price,onSave:S,onCancel:()=>l(i=>({adding:{...i.adding,price:!1}}))})]})]}),e.jsx(u,{}),e.jsxs(o,{className:"section",children:[e.jsx(p,{title:t("admin.details")}),e.jsxs(re,{sx:{display:"grid",gridTemplateColumns:{xs:"repeat(1, 1fr)",xl:"repeat(2, 1fr)"},"@container (min-width: 1000px)":{gridTemplateColumns:"repeat(2, 1fr)"},".info-row-wrapper":{gap:1,flexDirection:{xs:"column",xl:"row"},alignItems:{xs:"flex-start",xl:"center"},"@container (min-width: 1000px)":{flexDirection:"row",alignItems:"center"}}},children:[e.jsx(r,{label:t("admin.paymentLink.allowPromotionCodes"),value:a.allow_promotion_codes?t("common.yes"):t("common.no")}),e.jsx(r,{label:t("admin.paymentLink.includeFreeTrial"),value:a.subscription_data?.trial_period_days?t("common.yes"):t("common.no")}),e.jsx(r,{label:t("admin.paymentLink.requireBillingAddress"),value:a.billing_address_collection?t("common.yes"):t("common.no")}),e.jsx(r,{label:t("admin.paymentLink.requirePhoneNumber"),value:a.phone_number_collection?.enabled?t("common.yes"):t("common.no")}),e.jsx(r,{label:t("admin.paymentLink.allowSkipPaymentMethod"),value:a.metadata?.allow_skip_payment_method==="true"?t("common.yes"):t("common.no")}),e.jsx(r,{label:t("admin.paymentLink.showConfirmPage"),value:T(a.after_completion)}),e.jsx(r,{label:t("admin.paymentLink.mintNft"),value:a.nft_mint_settings?.factory||""}),e.jsx(r,{label:t("common.createdAt"),value:C(a.created_at)}),e.jsx(r,{label:t("common.updatedAt"),value:C(a.updated_at)})]})]}),e.jsx(u,{}),e.jsxs(o,{className:"section",children:[e.jsx(p,{title:t("common.preview")}),e.jsx(o,{className:"section-body",sx:{maxWidth:1050},children:e.jsx(ae,{id:a.id})})]}),e.jsx(u,{}),e.jsxs(o,{className:"section",children:[e.jsx(p,{title:t("admin.events.title")}),e.jsx(o,{className:"section-body",children:e.jsx(K,{features:{toolbar:!1},object_id:a.id})})]})]})}),e.jsx(o,{className:"payment-link-column-2",children:e.jsxs(o,{className:"section",children:[e.jsx(p,{title:t("common.metadata.label"),children:e.jsx(F,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},disabled:d.editing.metadata,onClick:_,children:t("common.edit")})}),e.jsxs(o,{className:"section-body",children:[e.jsx(ee,{data:a.metadata,handleEditMetadata:_}),d.editing.metadata&&e.jsx(X,{data:a,loading:d.loading.metadata,onSave:B,onCancel:()=>l(i=>({editing:{...i.editing,metadata:!1}}))})]})]})})]})})]})}const me=O(m)``;export{Ue as default};
@@ -1 +1 @@
1
- import{j as e,A as E,w as O,B as r,a3 as o,bv as R,q as w,N as W,Y as x,O as H,be as U,x as q,bf as G}from"./vendor-mui-BXZut9Pz.js";import{V,Y,P as F,cw as J,a7 as C,Z as k}from"./vendor-blocklet-B67R14so.js";import{d as Z,i as K,a5 as Q,n as _,a6 as M,a7 as X,N as ee,j as S,p as te,e as A,k as ae}from"./index-B4yaPb7B.js";import{T as se}from"./gas-kw2KMH1u.js";import{L as ne}from"./vendor-react-BPknnnEA.js";import{C as ie}from"./copyable-CprMHdhV.js";import{C as oe}from"./link-DsltSF2Q.js";import{E as re}from"./list-CvM46TsP.js";import{I as N}from"./info-metric-ukWq8INi.js";import{I as i}from"./info-row-CaPaNF4L.js";import{M as le}from"./editor-vZvxDUTl.js";import{M as me}from"./list-B2b-s8wM.js";import{S as p}from"./header-ivXuPt06.js";import{g as ce,l as de}from"./util-B8B3fsMa.js";import{I as D}from"./info-card-C9dRgztS.js";import{I as xe}from"./info-row-group-Cxo-4Gk5.js";import"./table-BN3WBnr3.js";import"./lodash-B4Ozcv0x.js";import"./form-CnrBCyTJ.js";const pe=d=>A.get(`/api/payouts/${d}`).then(a=>a.data),m="column",c="flex-start";function Le(d){const{t:a,locale:T}=V(),{isMobile:j}=Z(),[f,u]=Y({adding:{price:!1},editing:{metadata:!1,product:!1},loading:{metadata:!1,price:!1,product:!1}}),{loading:$,error:y,data:t,runAsync:z}=F(()=>pe(d.id));if(y)return e.jsx(E,{severity:"error",children:y.message});if($||!t)return e.jsx(O,{});const L=(n=>async B=>{try{u(l=>({loading:{...l.loading,[n]:!0}})),await A.put(`/api/payouts/${d.id}`,B).then(l=>l.data),k.success(a("common.saved")),z()}catch(l){console.error(l),k.error(ae(l))}finally{u(l=>({loading:{...l.loading,[n]:!1}}))}})("metadata"),g=t.paymentCurrency,h=[K(t?.amount,g.decimal),g.symbol].join(" "),b=()=>{u(n=>({editing:{...n.editing,metadata:!0}}))},{paymentIntent:s}=t||{},P=()=>{if(t.customer)return e.jsx(oe,{customer:t.customer});const n=de(t.destination);return n?e.jsx(D,{name:n.name,description:e.jsx(C,{did:t.destination}),logo:n.avatar,size:40}):t.destination},I=s?.customer?.metadata?.anonymous,v=s?.customer?.did||s?.metadata?.payerDid||"";return e.jsxs(ue,{direction:"column",spacing:2.5,mb:4,children:[e.jsxs(r,{children:[e.jsx(o,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsxs(o,{direction:"row",onClick:()=>ce("/admin/payments/payouts"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(R,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(w,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:a("admin.payouts")})]})}),e.jsxs(r,{sx:{mt:4,mb:3,display:"flex",gap:{xs:2,sm:2,md:5},flexWrap:"wrap",flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"}},children:[e.jsx(o,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsx(o,{direction:"row",sx:{alignItems:"center"},children:e.jsxs(o,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(W,{src:t.paymentCurrency.logo,alt:t.paymentCurrency.symbol,variant:"square",sx:{width:"52px",height:"52px",borderRadius:.5}}),e.jsxs(o,{direction:"column",sx:{alignItems:"flex-start",justifyContent:"space-around"},children:[e.jsx(Q,{amount:h,sx:{my:0,fontSize:"1.75rem",lineHeight:"32px"}}),e.jsx(ie,{text:d.id})]})]})})}),e.jsxs(o,{className:"section-body",sx:{justifyContent:"flex-start",flexWrap:"wrap","hr.MuiDivider-root:last-child":{display:"none"},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:"flex-start",gap:{xs:1,sm:1,md:3}},children:[e.jsx(N,{label:a("common.status"),value:e.jsx(_,{label:t.status,color:M(t.status)}),divider:!0}),s?.id&&e.jsx(N,{label:a("customer.payout.payer"),value:e.jsx(D,{variant:"circular",logo:ee(s?.customer?.did,s?.customer?.updated_at?new Date(s?.customer?.updated_at).toISOString():"",48),logoName:s?.customer?.metadata?.anonymous?"":s?.customer?.name,name:e.jsxs(w,{variant:"subtitle2",sx:{...I?{}:{cursor:"pointer","&:hover":{color:"text.link"}}},onClick:()=>{if(I)return;const n=X(s?.customer?.did,T);window.open(n,"_blank")},children:[s?.customer?.name,s?.customer?.email?` (${s?.customer?.email})`:""]}),description:J(v)&&e.jsx(C,{did:v,...j?{responsive:!1,compact:!0}:{}}),size:40}),divider:!0})]})]}),e.jsx(x,{})]}),e.jsxs(o,{sx:{flexDirection:{xs:"column",lg:"row"},gap:{xs:2.5,md:4},".payment-link-column-1":{minWidth:{xs:"100%",lg:"600px"}},".payment-link-column-2":{width:{xs:"100%",md:"100%",lg:"320px"},maxWidth:{xs:"100%",md:"33%"}}},children:[e.jsxs(r,{className:"payment-link-column-1",sx:{flex:1,gap:2.5,display:"flex",flexDirection:"column"},children:[e.jsxs(r,{className:"section",sx:{containerType:"inline-size"},children:[e.jsx(p,{title:a("admin.details")}),e.jsxs(xe,{sx:{display:"grid",gridTemplateColumns:{xs:"repeat(1, 1fr)",xl:"repeat(2, 1fr)"},"@container (min-width: 1000px)":{gridTemplateColumns:"repeat(2, 1fr)"},".info-row-wrapper":{gap:1,flexDirection:{xs:"column",xl:"row"},alignItems:{xs:"flex-start",xl:"center"},"@container (min-width: 1000px)":{flexDirection:"row",alignItems:"center"}}},children:[e.jsx(i,{label:a("common.status"),value:e.jsxs(o,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(_,{label:t.status,color:M(t.status)}),t.last_attempt_error&&e.jsx(H,{title:e.jsx("pre",{style:{whiteSpace:"break-spaces"},children:JSON.stringify(t.last_attempt_error,null,2)}),children:e.jsx(U,{fontSize:"small",color:"error"})})]})}),e.jsx(i,{label:a("common.amount"),value:h}),e.jsx(i,{label:a("common.customer"),value:P()}),e.jsx(i,{label:a("common.createdAt"),value:S(t.created_at)}),e.jsx(i,{label:a("common.description"),value:t.description}),e.jsx(i,{label:a("common.updatedAt"),value:S(t.updated_at)})]})]}),e.jsx(x,{}),e.jsxs(r,{className:"section",children:[e.jsx(p,{title:a("admin.events.title")}),e.jsx(r,{className:"section-body",children:e.jsx(re,{features:{toolbar:!1},object_id:t.id})})]})]}),j&&e.jsx(x,{}),e.jsxs(r,{className:"payment-link-column-2",sx:{gap:2.5,display:"flex",flexDirection:"column"},children:[e.jsxs(r,{className:"section",children:[e.jsx(p,{title:a("admin.paymentMethod._name")}),e.jsxs(o,{children:[e.jsx(i,{label:a("common.id"),value:t.paymentMethod?.id,direction:m,alignItems:c}),e.jsx(i,{label:a("admin.paymentMethod.type"),value:t.paymentMethod?.type,direction:m,alignItems:c}),e.jsx(i,{label:a("admin.paymentCurrency.name"),value:`${t.paymentCurrency.symbol} (${t.paymentMethod?.name})`,direction:m,alignItems:c}),(!!t.payment_details?.ethereum||!!t.payment_details?.base)&&e.jsx(i,{label:a("common.txGas"),value:e.jsx(se,{details:t.payment_details,method:t.paymentMethod}),direction:m,alignItems:c}),e.jsx(i,{label:a(`common.${t.payment_details?.arcblock?.type||"transfer"}TxHash`),value:e.jsx(te,{details:t.payment_details,method:t.paymentMethod}),direction:m,alignItems:c})]})]}),e.jsx(x,{}),e.jsxs(r,{className:"section",children:[e.jsx(p,{title:a("admin.connections")}),e.jsx(o,{children:t.payment_intent_id?e.jsx(i,{label:a("admin.paymentIntent.name"),value:e.jsx(ne,{to:`/admin/payments/${t.paymentIntent.id}`,children:t.paymentIntent.id}),direction:m,alignItems:c}):a("common.none")})]}),e.jsx(x,{}),e.jsxs(r,{className:"section",children:[e.jsx(p,{title:a("common.metadata.label"),children:e.jsx(q,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},disabled:f.editing.metadata,onClick:b,children:a("common.edit")})}),e.jsxs(r,{className:"section-body",children:[e.jsx(me,{data:t.metadata,handleEditMetadata:b}),f.editing.metadata&&e.jsx(le,{data:t,loading:f.loading.metadata,onSave:L,onCancel:()=>u(n=>({editing:{...n.editing,metadata:!1}}))})]})]})]})]})]})}const ue=G(o)``;export{Le as default};
1
+ import{j as e,A as E,w as O,B as r,a3 as o,bv as R,q as w,N as W,Y as x,O as H,be as U,x as q,bf as G}from"./vendor-mui-BXZut9Pz.js";import{V,Y,P as F,cw as J,a7 as C,Z as k}from"./vendor-blocklet-B8V2HFST.js";import{d as Z,i as K,a5 as Q,n as _,a6 as M,a7 as X,N as ee,j as S,p as te,e as A,k as ae}from"./index-Bfp56O3W.js";import{T as se}from"./gas-BGJEvZ8T.js";import{L as ne}from"./vendor-react-BPknnnEA.js";import{C as ie}from"./copyable-Dn7WoFib.js";import{C as oe}from"./link-Dhj5mzaG.js";import{E as re}from"./list-CQ5uQIra.js";import{I as N}from"./info-metric-DwDA6oTc.js";import{I as i}from"./info-row-Cr8bdDz0.js";import{M as le}from"./editor-BzrYE3Ds.js";import{M as me}from"./list-B6NGNObl.js";import{S as p}from"./header-ivXuPt06.js";import{g as ce,l as de}from"./util-Dp629jKU.js";import{I as D}from"./info-card-Xtng8th6.js";import{I as xe}from"./info-row-group-qhfbrxfY.js";import"./table-CyJj8e85.js";import"./lodash-B4Ozcv0x.js";import"./form-nz7nSyN7.js";const pe=d=>A.get(`/api/payouts/${d}`).then(a=>a.data),m="column",c="flex-start";function Le(d){const{t:a,locale:T}=V(),{isMobile:j}=Z(),[f,u]=Y({adding:{price:!1},editing:{metadata:!1,product:!1},loading:{metadata:!1,price:!1,product:!1}}),{loading:$,error:y,data:t,runAsync:z}=F(()=>pe(d.id));if(y)return e.jsx(E,{severity:"error",children:y.message});if($||!t)return e.jsx(O,{});const L=(n=>async B=>{try{u(l=>({loading:{...l.loading,[n]:!0}})),await A.put(`/api/payouts/${d.id}`,B).then(l=>l.data),k.success(a("common.saved")),z()}catch(l){console.error(l),k.error(ae(l))}finally{u(l=>({loading:{...l.loading,[n]:!1}}))}})("metadata"),g=t.paymentCurrency,h=[K(t?.amount,g.decimal),g.symbol].join(" "),b=()=>{u(n=>({editing:{...n.editing,metadata:!0}}))},{paymentIntent:s}=t||{},P=()=>{if(t.customer)return e.jsx(oe,{customer:t.customer});const n=de(t.destination);return n?e.jsx(D,{name:n.name,description:e.jsx(C,{did:t.destination}),logo:n.avatar,size:40}):t.destination},I=s?.customer?.metadata?.anonymous,v=s?.customer?.did||s?.metadata?.payerDid||"";return e.jsxs(ue,{direction:"column",spacing:2.5,mb:4,children:[e.jsxs(r,{children:[e.jsx(o,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsxs(o,{direction:"row",onClick:()=>ce("/admin/payments/payouts"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(R,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(w,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:a("admin.payouts")})]})}),e.jsxs(r,{sx:{mt:4,mb:3,display:"flex",gap:{xs:2,sm:2,md:5},flexWrap:"wrap",flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"}},children:[e.jsx(o,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsx(o,{direction:"row",sx:{alignItems:"center"},children:e.jsxs(o,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(W,{src:t.paymentCurrency.logo,alt:t.paymentCurrency.symbol,variant:"square",sx:{width:"52px",height:"52px",borderRadius:.5}}),e.jsxs(o,{direction:"column",sx:{alignItems:"flex-start",justifyContent:"space-around"},children:[e.jsx(Q,{amount:h,sx:{my:0,fontSize:"1.75rem",lineHeight:"32px"}}),e.jsx(ie,{text:d.id})]})]})})}),e.jsxs(o,{className:"section-body",sx:{justifyContent:"flex-start",flexWrap:"wrap","hr.MuiDivider-root:last-child":{display:"none"},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:"flex-start",gap:{xs:1,sm:1,md:3}},children:[e.jsx(N,{label:a("common.status"),value:e.jsx(_,{label:t.status,color:M(t.status)}),divider:!0}),s?.id&&e.jsx(N,{label:a("customer.payout.payer"),value:e.jsx(D,{variant:"circular",logo:ee(s?.customer?.did,s?.customer?.updated_at?new Date(s?.customer?.updated_at).toISOString():"",48),logoName:s?.customer?.metadata?.anonymous?"":s?.customer?.name,name:e.jsxs(w,{variant:"subtitle2",sx:{...I?{}:{cursor:"pointer","&:hover":{color:"text.link"}}},onClick:()=>{if(I)return;const n=X(s?.customer?.did,T);window.open(n,"_blank")},children:[s?.customer?.name,s?.customer?.email?` (${s?.customer?.email})`:""]}),description:J(v)&&e.jsx(C,{did:v,...j?{responsive:!1,compact:!0}:{}}),size:40}),divider:!0})]})]}),e.jsx(x,{})]}),e.jsxs(o,{sx:{flexDirection:{xs:"column",lg:"row"},gap:{xs:2.5,md:4},".payment-link-column-1":{minWidth:{xs:"100%",lg:"600px"}},".payment-link-column-2":{width:{xs:"100%",md:"100%",lg:"320px"},maxWidth:{xs:"100%",md:"33%"}}},children:[e.jsxs(r,{className:"payment-link-column-1",sx:{flex:1,gap:2.5,display:"flex",flexDirection:"column"},children:[e.jsxs(r,{className:"section",sx:{containerType:"inline-size"},children:[e.jsx(p,{title:a("admin.details")}),e.jsxs(xe,{sx:{display:"grid",gridTemplateColumns:{xs:"repeat(1, 1fr)",xl:"repeat(2, 1fr)"},"@container (min-width: 1000px)":{gridTemplateColumns:"repeat(2, 1fr)"},".info-row-wrapper":{gap:1,flexDirection:{xs:"column",xl:"row"},alignItems:{xs:"flex-start",xl:"center"},"@container (min-width: 1000px)":{flexDirection:"row",alignItems:"center"}}},children:[e.jsx(i,{label:a("common.status"),value:e.jsxs(o,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(_,{label:t.status,color:M(t.status)}),t.last_attempt_error&&e.jsx(H,{title:e.jsx("pre",{style:{whiteSpace:"break-spaces"},children:JSON.stringify(t.last_attempt_error,null,2)}),children:e.jsx(U,{fontSize:"small",color:"error"})})]})}),e.jsx(i,{label:a("common.amount"),value:h}),e.jsx(i,{label:a("common.customer"),value:P()}),e.jsx(i,{label:a("common.createdAt"),value:S(t.created_at)}),e.jsx(i,{label:a("common.description"),value:t.description}),e.jsx(i,{label:a("common.updatedAt"),value:S(t.updated_at)})]})]}),e.jsx(x,{}),e.jsxs(r,{className:"section",children:[e.jsx(p,{title:a("admin.events.title")}),e.jsx(r,{className:"section-body",children:e.jsx(re,{features:{toolbar:!1},object_id:t.id})})]})]}),j&&e.jsx(x,{}),e.jsxs(r,{className:"payment-link-column-2",sx:{gap:2.5,display:"flex",flexDirection:"column"},children:[e.jsxs(r,{className:"section",children:[e.jsx(p,{title:a("admin.paymentMethod._name")}),e.jsxs(o,{children:[e.jsx(i,{label:a("common.id"),value:t.paymentMethod?.id,direction:m,alignItems:c}),e.jsx(i,{label:a("admin.paymentMethod.type"),value:t.paymentMethod?.type,direction:m,alignItems:c}),e.jsx(i,{label:a("admin.paymentCurrency.name"),value:`${t.paymentCurrency.symbol} (${t.paymentMethod?.name})`,direction:m,alignItems:c}),(!!t.payment_details?.ethereum||!!t.payment_details?.base)&&e.jsx(i,{label:a("common.txGas"),value:e.jsx(se,{details:t.payment_details,method:t.paymentMethod}),direction:m,alignItems:c}),e.jsx(i,{label:a(`common.${t.payment_details?.arcblock?.type||"transfer"}TxHash`),value:e.jsx(te,{details:t.payment_details,method:t.paymentMethod}),direction:m,alignItems:c})]})]}),e.jsx(x,{}),e.jsxs(r,{className:"section",children:[e.jsx(p,{title:a("admin.connections")}),e.jsx(o,{children:t.payment_intent_id?e.jsx(i,{label:a("admin.paymentIntent.name"),value:e.jsx(ne,{to:`/admin/payments/${t.paymentIntent.id}`,children:t.paymentIntent.id}),direction:m,alignItems:c}):a("common.none")})]}),e.jsx(x,{}),e.jsxs(r,{className:"section",children:[e.jsx(p,{title:a("common.metadata.label"),children:e.jsx(q,{variant:"text",color:"inherit",size:"small",sx:{color:"text.link"},disabled:f.editing.metadata,onClick:b,children:a("common.edit")})}),e.jsxs(r,{className:"section-body",children:[e.jsx(me,{data:t.metadata,handleEditMetadata:b}),f.editing.metadata&&e.jsx(le,{data:t,loading:f.loading.metadata,onSave:L,onCancel:()=>u(n=>({editing:{...n.editing,metadata:!1}}))})]})]})]})]})]})}const ue=G(o)``;export{Le as default};