@backtest-kit/ui 14.1.0 → 15.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +273 -273
  2. package/build/index.cjs +28 -8
  3. package/build/index.mjs +28 -8
  4. package/build/modules/frontend/build/3rdparty/ace_1.4.12/ace.js +21337 -21337
  5. package/build/modules/frontend/build/3rdparty/ace_1.4.12/mode-javascript.js +797 -797
  6. package/build/modules/frontend/build/3rdparty/ace_1.4.12/theme-chrome.js +137 -137
  7. package/build/modules/frontend/build/3rdparty/ace_1.4.12/theme-twilight.js +115 -115
  8. package/build/modules/frontend/build/3rdparty/ace_1.4.12/worker-javascript.js +15012 -15012
  9. package/build/modules/frontend/build/3rdparty/qfchart_0.8.7/echarts.min.js +45 -45
  10. package/build/modules/frontend/build/assets/{Article-CpU7DBcT.js → Article-BFa1r6-4.js} +1 -1
  11. package/build/modules/frontend/build/assets/{Background-DISIt7NA.js → Background-C0snDG25.js} +1 -1
  12. package/build/modules/frontend/build/assets/{IconPhoto-Czod_jkW.js → IconPhoto-CTTANJQT.js} +1 -1
  13. package/build/modules/frontend/build/assets/{KeyboardArrowLeft-BUZ_pXI5.js → KeyboardArrowLeft-vg5fS39b.js} +1 -1
  14. package/build/modules/frontend/build/assets/{PictureAsPdfOutlined-BgifaQ0L.js → PictureAsPdfOutlined-B1bBHTk-.js} +1 -1
  15. package/build/modules/frontend/build/assets/{Refresh-3cixHjvW.js → Refresh-BrRXF_OY.js} +1 -1
  16. package/build/modules/frontend/build/assets/emitters-CzPcqIDz.js +1 -0
  17. package/build/modules/frontend/build/assets/{hasRouteMatch-CqJJG3sx.js → hasRouteMatch-D81_5Zia.js} +1 -1
  18. package/build/modules/frontend/build/assets/{html2canvas-Ds2vwzb-.js → html2canvas-CeYsQ7Ia.js} +1 -1
  19. package/build/modules/frontend/build/assets/{index-pxXO4P81.js → index-B8jbArE_.js} +1 -1
  20. package/build/modules/frontend/build/assets/{index-B1plXuf6.js → index-BGch4vTY.js} +1 -1
  21. package/build/modules/frontend/build/assets/index-BNHew1fQ.js +1 -0
  22. package/build/modules/frontend/build/assets/index-BUbFRdFe.js +1 -0
  23. package/build/modules/frontend/build/assets/{index-C8oIDQdm.js → index-CYxbx7rx.js} +1 -1
  24. package/build/modules/frontend/build/assets/{index-BI3k7b1T.js → index-Cgx-XS5d.js} +10 -10
  25. package/build/modules/frontend/build/assets/index-DKA1GI73.js +1 -0
  26. package/build/modules/frontend/build/assets/{index-DwO4-4_F.js → index-DR-YErQ2.js} +1 -1
  27. package/build/modules/frontend/build/assets/{index-BMq2INDq.js → index-D_qcRzkR.js} +1 -1
  28. package/build/modules/frontend/build/assets/{index-VxkdhxAi.js → index-DwTK5Bv3.js} +1 -1
  29. package/build/modules/frontend/build/assets/{index-DJ7B8Och.js → index-JWp04bbN.js} +1 -1
  30. package/build/modules/frontend/build/assets/{index-BYnSX2YX.js → index-lJLcrenO.js} +1 -1
  31. package/build/modules/frontend/build/assets/{index-CA19hrNH.js → index-xjrsOJPu.js} +1 -1
  32. package/build/modules/frontend/build/assets/{index.es-DPOJOdbj.js → index.es-CjcEW2lH.js} +1 -1
  33. package/build/modules/frontend/build/assets/{markdownit-C4X6Sysk.js → markdownit-D4PDy3DR.js} +1 -1
  34. package/build/modules/frontend/build/index.html +87 -87
  35. package/build/modules/frontend/build/manifest.json +23 -23
  36. package/package.json +118 -118
  37. package/build/modules/frontend/build/assets/emitters-DmNf0ttF.js +0 -1
  38. package/build/modules/frontend/build/assets/index-BYiuApxW.js +0 -1
  39. package/build/modules/frontend/build/assets/index-Cqt7co-7.js +0 -1
  40. package/build/modules/frontend/build/assets/index-ruSh1u75.js +0 -1
@@ -0,0 +1 @@
1
+ import{r as e,f as a,P as i,B as r,A as n,a9 as t,T as o,H as c,a3 as s,aa as l,N as d,J as p,F as m,G as u,M as b,aO as v,aP as y,aQ as g,aR as h,ad as x,aS as k,aT as f,aU as $,aV as P,aW as w,aX as C,aY as S,i as _,aG as A,a8 as O,aH as N,O as E,R as D,aZ as L,a_ as F,Z as z}from"./index-Cgx-XS5d.js";import{C as T,R as j}from"./Refresh-BrRXF_OY.js";import{K as R}from"./KeyboardArrowLeft-vg5fS39b.js";const B=e=>{const i={color:"white",fontSize:28};switch(e.type){case"signal.opened":case"partial_profit.available":case"partial_profit.commit":return a(C,{sx:i});case"signal.closed":case"signal_sync.close":case"close_pending.commit":return a(x,{sx:i});case"signal.scheduled":return a(S,{sx:i});case"signal.cancelled":case"cancel_scheduled.commit":return a(k,{sx:i});case"partial_loss.available":case"partial_loss.commit":case"average_buy.commit":return a(P,{sx:i});case"breakeven.available":case"breakeven.commit":return a(w,{sx:i});case"activate_scheduled.commit":case"signal_sync.open":return a(f,{sx:i});case"trailing_stop.commit":case"trailing_take.commit":return a($,{sx:i});case"risk.rejection":return a(h,{sx:i});case"error.info":case"error.validation":case"signal.info":return a(y,{sx:i});case"error.critical":return a(g,{sx:i});default:return a(v,{sx:i})}},I=e=>{switch(e.type){case"signal.opened":return`${l("Opened")} ${e.position.toUpperCase()} ${e.symbol}`;case"signal.closed":return`${l("Closed")} ${e.symbol} (${null!=e.pnlPercentage?`${e.pnlPercentage>0?"+":""}${e.pnlPercentage.toFixed(2)}%`:"N/A"})`;case"signal.scheduled":return`${l("Scheduled")} ${e.position.toUpperCase()} ${e.symbol}`;case"signal.cancelled":return`${l("Cancelled")} ${e.symbol}`;case"partial_profit.available":return`${l("Partial profit")} ${e.level}% ${e.symbol}`;case"partial_profit.commit":return`${l("Profit fixed")} ${e.percentToClose}% ${e.symbol}`;case"partial_loss.available":return`${l("Partial loss")} ${e.level}% ${e.symbol}`;case"partial_loss.commit":return`${l("Loss fixed")} ${e.percentToClose}% ${e.symbol}`;case"breakeven.available":return`${l("Breakeven available")} ${e.symbol}`;case"breakeven.commit":return`${l("Breakeven set")} ${e.symbol}`;case"activate_scheduled.commit":return`${l("Activated")} ${e.position.toUpperCase()} ${e.symbol}`;case"average_buy.commit":return`${l("Average Buy")} ${e.symbol}`;case"trailing_stop.commit":return`${l("Trailing stop")} ${e.symbol}`;case"trailing_take.commit":return`${l("Trailing take")} ${e.symbol}`;case"signal_sync.open":return`${l("Sync Open")} ${e.position.toUpperCase()} ${e.symbol}`;case"signal_sync.close":return`${l("Sync Close")} ${e.symbol} (${null!=e.pnlPercentage?`${e.pnlPercentage>0?"+":""}${e.pnlPercentage.toFixed(2)}%`:"N/A"})`;case"cancel_scheduled.commit":return`${l("Cancel Scheduled")} ${e.symbol}`;case"close_pending.commit":return`${l("Close Pending")} ${e.symbol}`;case"risk.rejection":return`${l("Rejected")} ${e.position.toUpperCase()} ${e.symbol}`;case"error.info":return`${l("Error")}: ${e.message}`;case"error.validation":return`${l("Validation")}: ${e.message}`;case"error.critical":return`${l("Critical")}: ${e.message}`;case"signal.info":return`${l("Signal Info")} ${e.symbol} (${null!=e.pnlPercentage?`${e.pnlPercentage>0?"+":""}${e.pnlPercentage.toFixed(2)}%`:"N/A"})`;default:return l("Unknown")}},U=e=>{switch(e.type){case"signal.opened":return l("Signal Opened");case"signal.closed":return l("Signal Closed");case"signal.scheduled":return l("Signal Scheduled");case"signal.cancelled":return l("Signal Cancelled");case"partial_profit.available":return l("Partial Profit Available");case"partial_profit.commit":return l("Partial Profit Commit");case"partial_loss.available":return l("Partial Loss Available");case"partial_loss.commit":return l("Partial Loss Commit");case"breakeven.available":return l("Breakeven Available");case"breakeven.commit":return l("Breakeven Commit");case"activate_scheduled.commit":return l("Activated Scheduled");case"average_buy.commit":return l("Average Buy");case"trailing_stop.commit":return l("Trailing Stop");case"trailing_take.commit":return l("Trailing Take");case"signal_sync.open":return l("Signal Sync Open");case"signal_sync.close":return l("Signal Sync Close");case"cancel_scheduled.commit":return l("Cancel Scheduled");case"close_pending.commit":return l("Close Pending");case"risk.rejection":return l("Risk Rejection");case"error.info":return l("Info Error");case"error.validation":return l("Validation Error");case"error.critical":return l("Critical Error");case"signal.info":return l("Signal Info");default:return l("Unknown")}},W=e=>"symbol"in e,M=e=>"position"in e,H=e=>"priceOpen"in e&&"priceTakeProfit"in e&&"priceStopLoss"in e,Y=e=>"pnlPercentage"in e,V=e=>"level"in e,G=e=>"percentToClose"in e,K=e=>"currentPrice"in e,Z=e=>"duration"in e,q=e=>"closeReason"in e,J=e=>"cancelReason"in e,Q=e=>"percentShift"in e,X=e=>"signal.opened"===e.type?"note"in e&&!!e.note:"signal.info"===e.type?"note"in e&&!!e.note&&!!e.notificationId:"activate_scheduled.commit"===e.type?"note"in e&&!!e.note&&!!e.activateId:"close_pending.commit"===e.type?"note"in e&&!!e.note&&!!e.closeId:"cancel_scheduled.commit"===e.type&&("note"in e&&!!e.note&&!!e.cancelId),ee=e=>"message"in e,ae=e=>"rejectionNote"in e,ie=e=>"activePositionCount"in e,re=e=>"effectivePriceOpen"in e,ne=e=>"totalEntries"in e&&e.totalEntries>1,te=e=>"originalPriceOpen"in e&&"priceOpen"in e&&null!=e.originalPriceOpen&&Number(e.originalPriceOpen).toFixed(6)!==Number(e.priceOpen).toFixed(6),oe=e=>"totalPartials"in e&&e.totalPartials>0,ce=e=>"cost"in e,se=e=>"pnlPriceOpen"in e&&"pnlPriceClose"in e&&"pnlCost"in e&&"pnlEntries"in e,le=e=>"peakProfitPriceClose"in e,de=e=>"maxDrawdownPriceClose"in e,pe=e.forwardRef(({item:e,className:v,style:y,sx:g},h)=>{const x=(e=>{switch(e.type){case"signal.opened":case"activate_scheduled.commit":case"signal_sync.open":return"#4CAF50";case"signal.closed":case"signal_sync.close":return"#2196F3";case"signal.scheduled":case"average_buy.commit":case"error.info":case"error.validation":return"#FF9800";case"signal.cancelled":case"cancel_scheduled.commit":default:return"#9E9E9E";case"partial_profit.available":case"partial_profit.commit":return"#8BC34A";case"partial_loss.available":case"partial_loss.commit":return"#FF5722";case"breakeven.available":case"breakeven.commit":return"#00BCD4";case"trailing_stop.commit":case"trailing_take.commit":return"#673AB7";case"close_pending.commit":return"#607D8B";case"risk.rejection":return"#F44336";case"error.critical":return"#D32F2F";case"signal.info":return"#9C27B0"}})(e),k=(e=>"timestamp"in e)(e)?e.timestamp:Date.now();return a("div",{className:v,style:y,ref:h,children:a(i,{variant:"outlined",onClick:()=>(e=>{switch(e.type){case"risk.rejection":_.layoutService.pickRisk(e.id);break;case"signal.opened":_.layoutService.pickSignalOpened(e.id);break;case"signal.closed":_.layoutService.pickSignalClosed(e.id);break;case"signal.scheduled":_.layoutService.pickSignalScheduled(e.id);break;case"signal.cancelled":_.layoutService.pickSignalCancelled(e.id);break;case"partial_profit.available":_.layoutService.pickPartialProfitAvailable(e.id);break;case"partial_profit.commit":_.layoutService.pickPartialProfitCommit(e.id);break;case"partial_loss.available":_.layoutService.pickPartialLossAvailable(e.id);break;case"partial_loss.commit":_.layoutService.pickPartialLossCommit(e.id);break;case"breakeven.available":_.layoutService.pickBreakevenAvailable(e.id);break;case"breakeven.commit":_.layoutService.pickBreakevenCommit(e.id);break;case"trailing_stop.commit":_.layoutService.pickTrailingStop(e.id);break;case"trailing_take.commit":_.layoutService.pickTrailingTake(e.id);break;case"activate_scheduled.commit":_.layoutService.pickActivateScheduled(e.id);break;case"average_buy.commit":_.layoutService.pickAverageBuyCommit(e.id);break;case"signal_sync.open":_.layoutService.pickSignalSyncOpen(e.id);break;case"signal_sync.close":_.layoutService.pickSignalSyncClose(e.id);break;case"cancel_scheduled.commit":_.layoutService.pickCancelScheduled(e.id);break;case"close_pending.commit":_.layoutService.pickClosePending(e.id);break;case"signal.info":_.layoutService.pickSignalNotify(e.id)}})(e),sx:{transition:"box-shadow 0.2s ease",cursor:"pointer",display:"flex",alignItems:"stretch",justifyContent:"stretch","&:hover":{boxShadow:4},...g},children:a(r,{sx:{flex:1,position:"relative",overflow:"clip",height:"100%",width:"100%",borderRadius:"12px"},children:[a(n,{direction:"row",spacing:2,sx:{p:2},children:[a(t,{sx:{width:56,height:56,background:x},children:B(e)}),a(n,{flex:1,spacing:1,children:[a(n,{direction:"row",justifyContent:"space-between",alignItems:"flex-start",children:[a(o,{variant:"h6",sx:{fontWeight:600},children:I(e)}),a(o,{variant:"body2",color:"text.secondary",sx:{whiteSpace:"nowrap",ml:2},children:c(k).format("HH:mm DD/MM/YYYY")})]}),a(n,{mt:-1,direction:"row",flexWrap:"wrap",children:[a(s,{size:"small",label:U(e),sx:{background:x,mt:1,mr:1,color:"white",fontWeight:500}}),W(e)&&a(s,{size:"small",sx:{mt:1,mr:1},label:e.symbol,variant:"outlined"}),M(e)&&a(s,{size:"small",sx:{mt:1,mr:1},label:e.position.toUpperCase(),variant:"outlined",color:"long"===e.position?"success":"error"}),Y(e)&&a(s,{size:"small",sx:{mt:1,mr:1},label:"PnL: "+(null!=e.pnlPercentage?`${e.pnlPercentage>0?"+":""}${e.pnlPercentage.toFixed(2)}%`:"N/A"),color:e.pnlPercentage>=0?"success":"error",variant:"outlined"}),V(e)&&a(s,{size:"small",sx:{mt:1,mr:1},label:`${l("Level")}: ${e.level}%`,variant:"outlined"}),G(e)&&a(s,{size:"small",sx:{mt:1,mr:1},label:`${l("Close")}: ${e.percentToClose}%`,variant:"outlined"}),Z(e)&&a(s,{size:"small",sx:{mt:1,mr:1},label:`${l("Duration")}: ${e.duration} ${l("min")}`,variant:"outlined"}),q(e)&&a(s,{size:"small",sx:{mt:1,mr:1},label:e.closeReason,variant:"outlined",color:"info"}),J(e)&&a(s,{size:"small",sx:{mt:1,mr:1},label:e.cancelReason,variant:"outlined",color:"info"}),Q(e)&&a(s,{size:"small",sx:{mt:1,mr:1},label:`${l("Shift")}: ${e.percentShift>0?"+":""}${e.percentShift}%`,variant:"outlined"}),ie(e)&&a(s,{size:"small",sx:{mt:1,mr:1},label:`${l("Active")}: ${e.activePositionCount}`,variant:"outlined"}),ne(e)&&a(s,{size:"small",sx:{mt:1,mr:1},label:`${l("Entries")}: ${e.totalEntries}`,variant:"outlined"}),oe(e)&&a(s,{size:"small",sx:{mt:1,mr:1},label:`${l("Partials")}: ${e.totalPartials}`,variant:"outlined"}),ce(e)&&a(s,{size:"small",sx:{mt:1,mr:1},label:`${l("Cost")}: ${e.cost?`${e.cost.toFixed(d(e.cost))}$`:"N/A"}`,variant:"outlined"}),re(e)&&a(s,{size:"small",sx:{mt:1,mr:1},label:`${l("Avg entry")}: ${e.effectivePriceOpen?p(e.effectivePriceOpen,d(e.effectivePriceOpen)):"N/A"}`,variant:"outlined",color:"warning"}),te(e)&&a(s,{size:"small",sx:{mt:1,mr:1},label:`${l("Orig entry")}: ${e.originalPriceOpen?p(e.originalPriceOpen,d(e.originalPriceOpen)):"N/A"}`,variant:"outlined"})]}),H(e)&&a(m,{children:[a(u,{sx:{my:1}}),a(n,{direction:"row",spacing:3,flexWrap:"wrap",children:[K(e)&&a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("Current"),":"," "]}),e.currentPrice?p(e.currentPrice,d(e.currentPrice)):"N/A"]}),a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("Take Profit"),":"," "]}),e.priceTakeProfit?p(e.priceTakeProfit,d(e.priceTakeProfit)):"N/A"]}),a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("Stop Loss"),":"," "]}),e.priceStopLoss?p(e.priceStopLoss,d(e.priceStopLoss)):"N/A"]})]})]}),se(e)&&a(m,{children:[a(u,{sx:{my:1}}),a(n,{direction:"row",spacing:3,flexWrap:"wrap",children:[a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("PnL Entry"),":"," "]}),e.pnlPriceOpen?p(e.pnlPriceOpen,d(e.pnlPriceOpen)):"N/A"]}),a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("PnL Exit"),":"," "]}),e.pnlPriceClose?p(e.pnlPriceClose,d(e.pnlPriceClose)):"N/A"]}),a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("PnL"),":"," "]}),a(o,{component:"span",color:e.pnlCost>=0?"success.main":"error.main",children:e.pnlCost?`${e.pnlCost>=0?"+":""}${e.pnlCost.toFixed(d(e.pnlCost))}$`:"N/A"})]}),a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("Invested"),":"," "]}),e.pnlEntries?`${e.pnlEntries.toFixed(d(e.pnlEntries))}$`:"N/A"]})]})]}),le(e)&&a(m,{children:[a(u,{sx:{my:1}}),a(n,{direction:"row",spacing:3,flexWrap:"wrap",children:[a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("Peak Entry"),":"," "]}),e.peakProfitPriceOpen?p(e.peakProfitPriceOpen,d(e.peakProfitPriceOpen)):"N/A"]}),a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("Peak Exit"),":"," "]}),e.peakProfitPriceClose?p(e.peakProfitPriceClose,d(e.peakProfitPriceClose)):"N/A"]}),a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("Peak"),":"," "]}),a(o,{component:"span",color:e.peakProfitCost>=0?"success.main":"error.main",children:e.peakProfitCost?`${e.peakProfitCost>=0?"+":""}${e.peakProfitCost.toFixed(d(e.peakProfitCost))}$`:"N/A"})]}),a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("Invested"),":"," "]}),e.peakProfitEntries?`${e.peakProfitEntries.toFixed(d(e.peakProfitEntries))}$`:"N/A"]})]})]}),de(e)&&a(m,{children:[a(u,{sx:{my:1}}),a(n,{direction:"row",spacing:3,flexWrap:"wrap",children:[a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("Drawdown Entry"),":"," "]}),e.maxDrawdownPriceOpen?p(e.maxDrawdownPriceOpen,d(e.maxDrawdownPriceOpen)):"N/A"]}),a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("Drawdown Exit"),":"," "]}),e.maxDrawdownPriceClose?p(e.maxDrawdownPriceClose,d(e.maxDrawdownPriceClose)):"N/A"]}),a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("Drawdown"),":"," "]}),a(o,{component:"span",color:e.maxDrawdownCost>=0?"success.main":"error.main",children:e.maxDrawdownCost?`${e.maxDrawdownCost>=0?"+":""}${e.maxDrawdownCost.toFixed(d(e.maxDrawdownCost))}$`:"N/A"})]}),a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("Invested"),":"," "]}),e.maxDrawdownEntries?`${e.maxDrawdownEntries.toFixed(d(e.maxDrawdownEntries))}$`:"N/A"]})]})]})]})]}),X(e)&&a(r,{onClick:e=>{e.preventDefault(),e.stopPropagation()},sx:{px:2,pb:2},children:[a(u,{sx:{mb:1.5}}),a(r,{component:"pre",sx:{m:0,whiteSpace:"pre-wrap",wordWrap:"break-word"},children:a(b,{content:e.note})})]}),ae(e)&&a(r,{sx:{px:2,pb:2},children:[a(u,{sx:{mb:1.5}}),a(o,{variant:"body2",color:"error",children:e.rejectionNote})]}),ee(e)&&!X(e)&&a(r,{sx:{px:2,pb:2},children:[a(u,{sx:{mb:1.5}}),a(o,{variant:"body2",color:"text.secondary",children:e.message})]}),a(r,{sx:{position:"absolute",top:0,left:0,bottom:0,width:6,zIndex:1,background:x}})]})})})}),me=[{action:"update-now",label:"Refresh manually",icon:()=>a(z,{icon:j,color:"#4caf50"})}],ue=[{type:D.Link,action:"back-action",label:a(R,{sx:{display:"block"}})},{type:D.Link,action:"back-action",label:"Main"},{type:D.Link,action:"back-action",label:"Notifications"}],be=new O,ve=()=>{const{data:e,hasMore:i,loading:r,onSkip:n}=A({handler:async(e,a)=>{const i=await _.notificationViewService.getList(),r=N(e,a);for(const n of i)if(r([n]).done)break;return r().rows},onLoadStart:()=>_.layoutService.setAppbarLoader(!0),onLoadEnd:()=>_.layoutService.setAppbarLoader(!1),reloadSubject:be});return a(T,{children:[a(E,{items:ue,actions:me,onAction:async e=>{"back-action"===e&&_.routerService.push("/"),"update-now"===e&&await be.next()}}),a(L,{sx:{height:"calc(100vh - 155px)"},withScrollbar:!0,minHeight:72,loading:r,onDataRequest:n,bufferSize:F,hasMore:i,children:e.map(e=>a(pe,{item:e,sx:{mb:1}},e.id))})]})};export{ve as NotificationPage,ve as default};
@@ -1 +1 @@
1
- import{b as e,f as o,Q as t,x as i,i as a,O as n,R as l,p as s,a2 as r,Z as c,T as p,b2 as d,W as m,B as u,F as h,a3 as b,E as y,A as f,a5 as g,l as k,n as v,a4 as C,a6 as S,r as x,aD as L,bz as w,bA as P,bB as T,bC as V,bD as $,bE as H,H as z,J as M,N,al as O,X as A,bk as _,a$ as E,G as I,P as F,a1 as R,az as j,bF as G,a8 as D,aI as W,aJ as B,b3 as U,ag as Y,I as J,ad as K,D as Q,aj as X}from"./index-BI3k7b1T.js";import{h as Z}from"./hasRouteMatch-CqJJG3sx.js";import{I as q}from"./IconPhoto-Czod_jkW.js";import{C as ee,R as oe}from"./Refresh-3cixHjvW.js";import{K as te}from"./KeyboardArrowLeft-BUZ_pXI5.js";const ie=e([o("path",{d:"M5 19h14V5H5v14zm4-4h4v-2h-2v-2h2V9H9V7h4c1.1 0 2 .89 2 2v1.5c0 .83-.67 1.5-1.5 1.5.83 0 1.5.67 1.5 1.5V15c0 1.11-.9 2-2 2H9v-2z",opacity:".3"}),o("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V5h14v14zm-4-4v-1.5c0-.83-.67-1.5-1.5-1.5.83 0 1.5-.67 1.5-1.5V9c0-1.11-.9-2-2-2H9v2h4v2h-2v2h2v2H9v2h4c1.1 0 2-.89 2-2z"})],"Looks3TwoTone"),ae=e([o("path",{d:"M19 5H5v14h14V5zm-5 12h-2V9h-2V7h4v10z",opacity:".3"}),o("path",{d:"M5 21h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2zM5 5h14v14H5V5zm5 4h2v8h2V7h-4z"})],"LooksOneTwoTone"),ne=e([o("path",{d:"M19 5H5v14h14V5zm-4 6c0 1.11-.9 2-2 2h-2v2h4v2H9v-4c0-1.11.9-2 2-2h2V9H9V7h4c1.1 0 2 .89 2 2v2z",opacity:".3"}),o("path",{d:"M5 21h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2zM5 5h14v14H5V5zm8 2H9v2h4v2h-2c-1.1 0-2 .89-2 2v4h6v-2h-4v-2h2c1.1 0 2-.89 2-2V9c0-1.11-.9-2-2-2z"})],"LooksTwoTwoTone"),le="backtest-kit__groupHeader",se="backtest-kit__groupRoot",re="backtest-kit__symbolImage",ce=s()({root:{[`& .${se}:hover .${le}`]:{opacity:"1 !important"}}});function pe(e){return S(e,"#000000")>S(e,"#FFFFFF")}const de=[{type:l.Link,action:"back-action",label:o(te,{sx:{display:"block"}})},{type:l.Link,action:"back-action",label:"Main"},{type:l.Link,action:"back-action",label:"Price Chart"}],me=[{action:"update-now",label:"Refresh",icon:()=>o(c,{icon:oe,color:"#4caf50"})}],ue=(e,t)=>({type:r.Group,className:se,sx:{p:2},tabletColumns:"12",desktopColumns:"3",fields:[{type:r.Component,className:le,style:{transition:"opacity 500ms",opacity:.5},element:()=>o(f,{direction:"row",children:[o(b,{variant:"outlined",size:"small",color:"info",label:`${y.bullet} ${e}`,sx:{mb:1,pr:.5,fontSize:"14px",background:"white",cursor:"not-allowed"}}),o(u,{flex:1})]})},{type:r.Group,fields:t.map(({symbol:e,label:t,color:i})=>((e,t,i)=>({type:r.Component,desktopColumns:"6",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:()=>o(C,{component:g,onClick:()=>{a.routerService.push(`/price_chart/${e.toLowerCase()}`)},sx:{width:"100%",background:i,color:"white",fontWeight:"bold",fontSize:"14px",height:"75px",minHeight:"75px",textWrap:"wrap",padding:"16px",[`& .${re}`]:{transition:"filter 500ms"},"&:hover":{background:()=>pe(i)?k(i,.33):v(i,.33),[`& .${re}`]:{transition:"filter 500ms",filter:pe(i)?"brightness(0.7) contrast(1.2)":"brightness(1.3) contrast(0.5)"}},transition:"background 500ms"},startIcon:o(q,{className:re,symbol:e}),children:o(u,{sx:{overflow:"hidden",textOverflow:"ellipsis",width:"75px"},children:t})})}))(e,t,i))}]}),he="backtest-kit__groupHeader",be="backtest-kit__groupRoot",ye="backtest-kit__symbolImage",fe=s()({root:{[`& .${be}:hover .${he}`]:{opacity:"1 !important"}}});function ge(e){return S(e,"#000000")>S(e,"#FFFFFF")}const ke=[{type:l.Link,action:"back-action",label:o(te,{sx:{display:"block"}})},{type:l.Link,action:"back-action",label:"Main"},{type:l.Link,action:"back-action",label:"Price Chart"},{type:l.Link,action:"back-action",compute:e=>String(e).toUpperCase()}],ve=(e,t)=>({type:r.Group,className:be,sx:{p:2},desktopColumns:"6",tabletColumns:"6",phoneColumns:"12",fields:[{type:r.Component,className:he,style:{transition:"opacity 500ms",opacity:.5},element:()=>o(f,{direction:"row",children:[o(b,{variant:"outlined",size:"medium",color:"info",label:`${y.bullet} ${e}`,sx:{mb:1,pr:.5,fontSize:"16px",background:"white",cursor:"not-allowed"}}),o(u,{flex:1})]})},{type:r.Group,fields:t.map(({label:e,to:t,color:i,icon:n})=>((e,t,i,n)=>({type:r.Component,desktopColumns:"6",tabletColumns:"12",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:()=>o(C,{component:g,onClick:()=>{a.routerService.push(e)},sx:{width:"100%",background:i,color:"white",fontWeight:"bold",fontSize:"18px",height:"75px",minHeight:"125px",textWrap:"wrap",padding:"16px",[`& .${ye}`]:{transition:"filter 500ms"},"&:hover":{background:()=>ge(i)?k(i,.33):v(i,.33),[`& .${ye}`]:{transition:"filter 500ms",filter:ge(i)?"brightness(0.7) contrast(1.2)":"brightness(1.3) contrast(0.5)"}},transition:"background 500ms"},startIcon:o(n,{className:ye}),children:t})}))(t,e,i,n))}]}),Ce=s()({root:{position:"relative"},tooltip:{position:"absolute",margin:0,left:5,top:5,backgroundColor:"#343434",zIndex:999,color:"white",fontWeight:"bold",padding:"5px 10px",borderRadius:3,fontSize:"12px",pointerEvents:"none",touchAction:"none"}}),Se={layout:{textColor:"#d4d4d8",backgroundColor:"#ffffff"},rightPriceScale:{scaleMargins:{top:.3,bottom:.25}},crosshair:{vertLine:{width:4,color:"#ebe0e301",style:0},horzLine:{visible:!1,labelVisible:!1}},grid:{vertLines:{color:"#f8b3"},horzLines:{color:"#f8b3"}},handleScroll:{vertTouchDrag:!1}},xe=({height:e,width:t,items:i,position:a,priceOpen:n,priceStopLoss:l,priceTakeProfit:s})=>{const{classes:r}=Ce(),c=x.useRef(void 0),[p,d]=x.useState(null);return x.useLayoutEffect(()=>{const{current:o}=c,r=L(o,{...Se,localization:{priceFormatter:e=>M(e,N(e))},width:t,height:e,crosshair:{mode:w.Normal,vertLine:{labelVisible:!1},horzLine:{visible:!1,labelVisible:!0}},timeScale:{timeVisible:!0,secondsVisible:!0,tickMarkFormatter:e=>{const o=i.find(o=>o.timestamp===Number(e))||i[0];if(!o||!o.timestamp)return"Invalid date";const t=z(o.timestamp);return t.isValid()?t.format("HH:mm:ss"):"Invalid date"}}}),p=r.addLineSeries({lastValueVisible:!1,color:P[400]}),m=i.map(e=>({time:Math.floor(e.timestamp),value:parseFloat(e.close)}));if(p.setData(m),a&&n){const e="long"===a?P[700]:V[700];p.createPriceLine({price:n,color:e,lineWidth:2,lineStyle:T.Solid,axisLabelVisible:!0,title:"long"===a?"LONG Entry":"SHORT Entry"})}return l&&p.createPriceLine({price:l,color:$[500],lineWidth:2,lineStyle:T.Solid,axisLabelVisible:!0,title:"SL"}),s&&p.createPriceLine({price:s,color:H[500],lineWidth:2,lineStyle:T.Solid,axisLabelVisible:!0,title:"TP"}),r.subscribeCrosshairMove(e=>{if(e.time){const o=i.find(o=>o.timestamp===Number(e.time));if(o){const e=z(o.timestamp).format("DD/MM/YYYY HH:mm:ss"),t=M(o.close,N(o.close));d(`${e}: ${t}`)}else d(null)}else d(null)}),r.timeScale().fitContent(),()=>{r.remove()}},[e,t,i]),o("div",{ref:c,className:r.root,children:p&&o("div",{className:r.tooltip,children:p})})},Le={"1m":"#2979ff","15m":"#f3a43a","1h":"#d500f9"},we={"1m":"1 minute","15m":"15 minutes","1h":"1 hour"};const Pe=({symbol:e,interval:t,reloadSubject:n,downloadSubject:l,onInfoClick:s,disableInfo:r,position:c,priceOpen:d,priceStopLoss:m,priceTakeProfit:h,sx:y})=>{const[f,{loading:g,execute:k}]=i(async()=>await a.exchangeViewService.getLastCandles(e,t),{onLoadStart:()=>a.layoutService.setAppbarLoader(!0),onLoadEnd:()=>a.layoutService.setAppbarLoader(!1),deps:[e,t]}),v=O(f);A(()=>n.subscribe(k)),A(()=>l.subscribe(()=>{const{current:o}=v;!function(e,o="data.json"){const t=new Blob([e],{type:"application/json"}),i=window.URL.createObjectURL(t);a.layoutService.downloadFile(i,o)}(JSON.stringify(o,null,2),`${e}-${t}.json`)}));return o(F,{sx:{...y,display:"flex",flexDirection:"column",alignItems:"stretch",overflow:"clip"},children:[o(u,{sx:{background:Le[t]||"#607d8b",minHeight:"48px",display:"flex",alignItems:"center",pl:2,pr:1},children:[o(p,{variant:"h6",sx:{color:"white",fontWeight:"bold",mr:1},children:we[t]||t}),!!c&&o(b,{variant:"filled",sx:{color:"white"},color:"short"===c?"warning":"success",label:String(c).toUpperCase()}),o(u,{sx:{flex:1}}),o(_,{disabled:r,onClick:s,children:o(E,{style:{color:"white",opacity:r?.5:1}})})]}),o(I,{}),!f||g?o(R,{sx:{height:"100%",width:"100%"}}):o(u,{sx:{position:"relative",flex:1},children:o(j,{style:{position:"absolute"},children:({height:e,width:t})=>o(xe,{items:f,height:e,width:t,position:c,priceOpen:d,priceStopLoss:m,priceTakeProfit:h})})})]})},Te=[{type:l.Link,action:"back-action",label:o(te,{sx:{display:"block"}})},{type:l.Link,action:"back-action",label:"Main"},{type:l.Link,action:"back-action",label:"Price Chart"},{type:l.Link,action:"back-action",compute:({symbol:e})=>String(e).toUpperCase()},{type:l.Link,action:"back-action",compute:({interval:e})=>String(e).toUpperCase()}],Ve=[{action:"download-now",label:"Download",icon:()=>o(c,{icon:Q,color:"#4caf50"})},{divider:!0},{action:"update-now",label:"Refresh",icon:()=>o(c,{icon:oe,color:"#4caf50"})}],$e=new D,He=new D,ze=[{type:r.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"symbol",title:"Symbol",readonly:!0,compute:e=>e.symbol||"N/A"},{type:r.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"position",title:"Position",readonly:!0,compute:e=>"long"===e.position?"🔵 LONG (profit on rise)":"🟠 SHORT (profit on fall)"},{type:r.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"priceOpen",title:"Entry",readonly:!0,compute:e=>e.priceOpen?`${M(e.priceOpen)}$`:"N/A"},{type:r.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"originalPriceOpen",title:"Original Entry",readonly:!0,isVisible:e=>null!=e.originalPriceOpen&&e.originalPriceOpen!==e.priceOpen,compute:e=>e.originalPriceOpen?`${M(e.originalPriceOpen)}$`:"N/A"},{type:r.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"priceTakeProfit",title:"Take Profit",readonly:!0,compute:e=>e.priceTakeProfit?`${M(e.priceTakeProfit)}$`:"N/A"},{type:r.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"originalPriceTakeProfit",title:"Original Take Profit",readonly:!0,isVisible:e=>null!=e.originalPriceTakeProfit&&e.originalPriceTakeProfit!==e.priceTakeProfit,compute:e=>e.originalPriceTakeProfit?`${M(e.originalPriceTakeProfit)}$`:"N/A"},{type:r.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"priceStopLoss",title:"Stop Loss",readonly:!0,compute:e=>e.priceStopLoss?`${M(e.priceStopLoss)}$`:"N/A"},{type:r.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"originalPriceStopLoss",title:"Original Stop Loss",readonly:!0,isVisible:e=>null!=e.originalPriceStopLoss&&e.originalPriceStopLoss!==e.priceStopLoss,compute:e=>e.originalPriceStopLoss?`${M(e.originalPriceStopLoss)}$`:"N/A"},{type:r.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"totalEntries",title:"Total Entries",readonly:!0,isVisible:e=>null!=e.totalEntries&&e.totalEntries>1,compute:e=>String(e.totalEntries)},{type:r.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"totalPartials",title:"Total Closes",readonly:!0,isVisible:e=>null!=e.totalPartials&&e.totalPartials>0,compute:e=>String(e.totalPartials)},{type:r.Component,sx:{mt:2},element:({payload:e})=>o(C,{variant:"outlined",onClick:e.handleClose,children:"Back"})}],Me=[{id:"chart",element:({params:e})=>{const t=G(()=>({symbol:String(e.symbol).toUpperCase(),interval:e.interval})),[l,{loading:s,execute:r}]=i(async()=>{const o=String(e.symbol).toUpperCase();return await a.signalViewService.getPendingSignal(o)},{onLoadStart:()=>a.layoutService.setAppbarLoader(!0),onLoadEnd:()=>a.layoutService.setAppbarLoader(!1),deps:[e.symbol]});A(()=>$e.subscribe(r));const c=x.useMemo(()=>l?l.priceTakeProfit:0,[l]),p=x.useMemo(()=>l?l.priceStopLoss:0,[l]),d=x.useMemo(()=>l?l.priceOpen:0,[l]),m=x.useMemo(()=>l?l.position:null,[l]),[u,h]=W(null),{pickData:b,setOpen:y,render:g}=B({title:"Info",AfterTitle:({onClose:e})=>o(f,{direction:"row",gap:2,children:[o(Y,{onClick:()=>a.layoutService.pickSignal(u.current.id),variant:"outlined",children:"Show Details"}),o(J,{size:"small",onClick:e,children:o(K,{})})]}),payload:()=>({handleClose(){y(!1)}}),fields:ze,handler:()=>u.current,withActionButton:!1}),k=U(async()=>{l&&(h(l),b(l.id))});return o(ee,{children:[o(n,{items:Te,actions:Ve,payload:t,onAction:async o=>{"back-action"===o&&a.routerService.push(`/price_chart/${e.symbol}`),"update-now"===o&&await $e.next(),"download-now"===o&&await He.next()}}),s?null:o(Pe,{symbol:t.symbol,interval:t.interval,disableInfo:!l,reloadSubject:$e,downloadSubject:He,onInfoClick:k,position:m,priceOpen:d,priceStopLoss:p,priceTakeProfit:c,sx:{height:"calc(100dvh - 165px)"}}),g()]})},isActive:e=>Z(["/price_chart/:symbol/:interval"],e)},{id:"coin",element:({params:e})=>{const{classes:t}=fe(),i=e.symbol,l=x.useMemo(()=>[{label:"1 minute",to:`/price_chart/${i}/1m`,color:"#2979ff",icon:ae},{label:"15 minutes",to:`/price_chart/${i}/15m`,color:"#f3a43a",icon:ne},{label:"1 hour",to:`/price_chart/${i}/1h`,color:"#d500f9",icon:ie}],[i]),s=x.useMemo(()=>[ve("Chart",l)],[l]);return o(ee,{children:[o(n,{items:ke,payload:i,onAction:e=>{"back-action"===e&&a.routerService.push("/price_chart")}}),o(m,{className:t.root,fields:s}),o(u,{paddingBottom:"24px"})]})},isActive:e=>Z(["/price_chart/:symbol"],e)},{id:"main",element:()=>{const{classes:e}=ce(),{reloadTrigger:l,doReload:s}=t(),[c,{loading:b}]=i(async()=>await(async()=>{const[e,o]=await Promise.all([a.symbolGlobalService.getSymbolList(),a.symbolGlobalService.getSymbolMap()]),t={};e.forEach((e,i)=>{const a=o[e],n=i+1,l=(null==a?void 0:a.priority)||n;t[l]||(t[l]=[]),t[l].push({symbol:e,label:(null==a?void 0:a.displayName)||e,color:(null==a?void 0:a.color)||"#ccc"})});const i=Object.entries(t).map(([e,o])=>({priority:parseInt(e),routes:o})).sort(({priority:e,routes:{length:o}},{priority:t,routes:{length:i}})=>i-o||t-e),n=[],l=[],s=[];return i.forEach(({routes:e,priority:o},t)=>{const i=ue(`Priority ${o}`,e);t%2==0&&n.push(i),t%2==1&&l.push(i),s.push(i)}),s.length?[{type:r.Group,columns:"6",className:"tabletLeftColumn",phoneHidden:!0,desktopHidden:!0,fields:n},{type:r.Group,columns:"6",className:"tabletRightColumn",phoneHidden:!0,desktopHidden:!0,fields:l},{type:r.Group,columns:"12",className:"wideColumn",tabletHidden:!0,fields:s}]:[]})(),{onLoadStart:()=>a.layoutService.setAppbarLoader(!0),onLoadEnd:()=>a.layoutService.setAppbarLoader(!1),deps:[l]});return o(ee,{children:[o(n,{items:de,actions:me,onAction:e=>{"back-action"===e&&a.routerService.push("/"),"update-now"===e&&s()}}),b||!c?o(d,{children:o(p,{variant:"h6",sx:{opacity:.5},children:"Loading..."})}):c.length?o(h,{children:[o(m,{className:e.root,fields:c},l),o(u,{paddingBottom:"24px"})]}):o(d,{children:o(p,{variant:"h6",sx:{opacity:.5},children:"No symbols found"})})]})},isActive:e=>Z(["/price_chart"],e)}],Ne=({symbol:e,interval:t})=>o(X,{history:a.routerService,onLoadStart:()=>a.layoutService.setAppbarLoader(!0),onLoadEnd:()=>a.layoutService.setAppbarLoader(!1),routes:Me,params:{symbol:e,interval:t}});export{Ne as PriceChartPage,Ne as default};
1
+ import{b as e,f as o,Q as t,x as i,i as a,O as n,R as l,p as s,a2 as r,Z as c,T as p,b2 as d,W as m,B as u,F as h,a3 as b,E as y,A as f,a5 as g,l as k,n as v,a4 as C,a6 as S,r as x,aD as L,bz as w,bA as P,bB as T,bC as V,bD as $,bE as H,H as z,J as M,N,al as O,X as A,bk as _,a$ as E,G as I,P as F,a1 as R,az as j,bF as G,a8 as D,aI as W,aJ as B,b3 as U,ag as Y,I as J,ad as K,D as Q,aj as X}from"./index-Cgx-XS5d.js";import{h as Z}from"./hasRouteMatch-D81_5Zia.js";import{I as q}from"./IconPhoto-CTTANJQT.js";import{C as ee,R as oe}from"./Refresh-BrRXF_OY.js";import{K as te}from"./KeyboardArrowLeft-vg5fS39b.js";const ie=e([o("path",{d:"M5 19h14V5H5v14zm4-4h4v-2h-2v-2h2V9H9V7h4c1.1 0 2 .89 2 2v1.5c0 .83-.67 1.5-1.5 1.5.83 0 1.5.67 1.5 1.5V15c0 1.11-.9 2-2 2H9v-2z",opacity:".3"}),o("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V5h14v14zm-4-4v-1.5c0-.83-.67-1.5-1.5-1.5.83 0 1.5-.67 1.5-1.5V9c0-1.11-.9-2-2-2H9v2h4v2h-2v2h2v2H9v2h4c1.1 0 2-.89 2-2z"})],"Looks3TwoTone"),ae=e([o("path",{d:"M19 5H5v14h14V5zm-5 12h-2V9h-2V7h4v10z",opacity:".3"}),o("path",{d:"M5 21h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2zM5 5h14v14H5V5zm5 4h2v8h2V7h-4z"})],"LooksOneTwoTone"),ne=e([o("path",{d:"M19 5H5v14h14V5zm-4 6c0 1.11-.9 2-2 2h-2v2h4v2H9v-4c0-1.11.9-2 2-2h2V9H9V7h4c1.1 0 2 .89 2 2v2z",opacity:".3"}),o("path",{d:"M5 21h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2zM5 5h14v14H5V5zm8 2H9v2h4v2h-2c-1.1 0-2 .89-2 2v4h6v-2h-4v-2h2c1.1 0 2-.89 2-2V9c0-1.11-.9-2-2-2z"})],"LooksTwoTwoTone"),le="backtest-kit__groupHeader",se="backtest-kit__groupRoot",re="backtest-kit__symbolImage",ce=s()({root:{[`& .${se}:hover .${le}`]:{opacity:"1 !important"}}});function pe(e){return S(e,"#000000")>S(e,"#FFFFFF")}const de=[{type:l.Link,action:"back-action",label:o(te,{sx:{display:"block"}})},{type:l.Link,action:"back-action",label:"Main"},{type:l.Link,action:"back-action",label:"Price Chart"}],me=[{action:"update-now",label:"Refresh",icon:()=>o(c,{icon:oe,color:"#4caf50"})}],ue=(e,t)=>({type:r.Group,className:se,sx:{p:2},tabletColumns:"12",desktopColumns:"3",fields:[{type:r.Component,className:le,style:{transition:"opacity 500ms",opacity:.5},element:()=>o(f,{direction:"row",children:[o(b,{variant:"outlined",size:"small",color:"info",label:`${y.bullet} ${e}`,sx:{mb:1,pr:.5,fontSize:"14px",background:"white",cursor:"not-allowed"}}),o(u,{flex:1})]})},{type:r.Group,fields:t.map(({symbol:e,label:t,color:i})=>((e,t,i)=>({type:r.Component,desktopColumns:"6",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:()=>o(C,{component:g,onClick:()=>{a.routerService.push(`/price_chart/${e.toLowerCase()}`)},sx:{width:"100%",background:i,color:"white",fontWeight:"bold",fontSize:"14px",height:"75px",minHeight:"75px",textWrap:"wrap",padding:"16px",[`& .${re}`]:{transition:"filter 500ms"},"&:hover":{background:()=>pe(i)?k(i,.33):v(i,.33),[`& .${re}`]:{transition:"filter 500ms",filter:pe(i)?"brightness(0.7) contrast(1.2)":"brightness(1.3) contrast(0.5)"}},transition:"background 500ms"},startIcon:o(q,{className:re,symbol:e}),children:o(u,{sx:{overflow:"hidden",textOverflow:"ellipsis",width:"75px"},children:t})})}))(e,t,i))}]}),he="backtest-kit__groupHeader",be="backtest-kit__groupRoot",ye="backtest-kit__symbolImage",fe=s()({root:{[`& .${be}:hover .${he}`]:{opacity:"1 !important"}}});function ge(e){return S(e,"#000000")>S(e,"#FFFFFF")}const ke=[{type:l.Link,action:"back-action",label:o(te,{sx:{display:"block"}})},{type:l.Link,action:"back-action",label:"Main"},{type:l.Link,action:"back-action",label:"Price Chart"},{type:l.Link,action:"back-action",compute:e=>String(e).toUpperCase()}],ve=(e,t)=>({type:r.Group,className:be,sx:{p:2},desktopColumns:"6",tabletColumns:"6",phoneColumns:"12",fields:[{type:r.Component,className:he,style:{transition:"opacity 500ms",opacity:.5},element:()=>o(f,{direction:"row",children:[o(b,{variant:"outlined",size:"medium",color:"info",label:`${y.bullet} ${e}`,sx:{mb:1,pr:.5,fontSize:"16px",background:"white",cursor:"not-allowed"}}),o(u,{flex:1})]})},{type:r.Group,fields:t.map(({label:e,to:t,color:i,icon:n})=>((e,t,i,n)=>({type:r.Component,desktopColumns:"6",tabletColumns:"12",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:()=>o(C,{component:g,onClick:()=>{a.routerService.push(e)},sx:{width:"100%",background:i,color:"white",fontWeight:"bold",fontSize:"18px",height:"75px",minHeight:"125px",textWrap:"wrap",padding:"16px",[`& .${ye}`]:{transition:"filter 500ms"},"&:hover":{background:()=>ge(i)?k(i,.33):v(i,.33),[`& .${ye}`]:{transition:"filter 500ms",filter:ge(i)?"brightness(0.7) contrast(1.2)":"brightness(1.3) contrast(0.5)"}},transition:"background 500ms"},startIcon:o(n,{className:ye}),children:t})}))(t,e,i,n))}]}),Ce=s()({root:{position:"relative"},tooltip:{position:"absolute",margin:0,left:5,top:5,backgroundColor:"#343434",zIndex:999,color:"white",fontWeight:"bold",padding:"5px 10px",borderRadius:3,fontSize:"12px",pointerEvents:"none",touchAction:"none"}}),Se={layout:{textColor:"#d4d4d8",backgroundColor:"#ffffff"},rightPriceScale:{scaleMargins:{top:.3,bottom:.25}},crosshair:{vertLine:{width:4,color:"#ebe0e301",style:0},horzLine:{visible:!1,labelVisible:!1}},grid:{vertLines:{color:"#f8b3"},horzLines:{color:"#f8b3"}},handleScroll:{vertTouchDrag:!1}},xe=({height:e,width:t,items:i,position:a,priceOpen:n,priceStopLoss:l,priceTakeProfit:s})=>{const{classes:r}=Ce(),c=x.useRef(void 0),[p,d]=x.useState(null);return x.useLayoutEffect(()=>{const{current:o}=c,r=L(o,{...Se,localization:{priceFormatter:e=>M(e,N(e))},width:t,height:e,crosshair:{mode:w.Normal,vertLine:{labelVisible:!1},horzLine:{visible:!1,labelVisible:!0}},timeScale:{timeVisible:!0,secondsVisible:!0,tickMarkFormatter:e=>{const o=i.find(o=>o.timestamp===Number(e))||i[0];if(!o||!o.timestamp)return"Invalid date";const t=z(o.timestamp);return t.isValid()?t.format("HH:mm:ss"):"Invalid date"}}}),p=r.addLineSeries({lastValueVisible:!1,color:P[400]}),m=i.map(e=>({time:Math.floor(e.timestamp),value:parseFloat(e.close)}));if(p.setData(m),a&&n){const e="long"===a?P[700]:V[700];p.createPriceLine({price:n,color:e,lineWidth:2,lineStyle:T.Solid,axisLabelVisible:!0,title:"long"===a?"LONG Entry":"SHORT Entry"})}return l&&p.createPriceLine({price:l,color:$[500],lineWidth:2,lineStyle:T.Solid,axisLabelVisible:!0,title:"SL"}),s&&p.createPriceLine({price:s,color:H[500],lineWidth:2,lineStyle:T.Solid,axisLabelVisible:!0,title:"TP"}),r.subscribeCrosshairMove(e=>{if(e.time){const o=i.find(o=>o.timestamp===Number(e.time));if(o){const e=z(o.timestamp).format("DD/MM/YYYY HH:mm:ss"),t=M(o.close,N(o.close));d(`${e}: ${t}`)}else d(null)}else d(null)}),r.timeScale().fitContent(),()=>{r.remove()}},[e,t,i]),o("div",{ref:c,className:r.root,children:p&&o("div",{className:r.tooltip,children:p})})},Le={"1m":"#2979ff","15m":"#f3a43a","1h":"#d500f9"},we={"1m":"1 minute","15m":"15 minutes","1h":"1 hour"};const Pe=({symbol:e,interval:t,reloadSubject:n,downloadSubject:l,onInfoClick:s,disableInfo:r,position:c,priceOpen:d,priceStopLoss:m,priceTakeProfit:h,sx:y})=>{const[f,{loading:g,execute:k}]=i(async()=>await a.exchangeViewService.getLastCandles(e,t),{onLoadStart:()=>a.layoutService.setAppbarLoader(!0),onLoadEnd:()=>a.layoutService.setAppbarLoader(!1),deps:[e,t]}),v=O(f);A(()=>n.subscribe(k)),A(()=>l.subscribe(()=>{const{current:o}=v;!function(e,o="data.json"){const t=new Blob([e],{type:"application/json"}),i=window.URL.createObjectURL(t);a.layoutService.downloadFile(i,o)}(JSON.stringify(o,null,2),`${e}-${t}.json`)}));return o(F,{sx:{...y,display:"flex",flexDirection:"column",alignItems:"stretch",overflow:"clip"},children:[o(u,{sx:{background:Le[t]||"#607d8b",minHeight:"48px",display:"flex",alignItems:"center",pl:2,pr:1},children:[o(p,{variant:"h6",sx:{color:"white",fontWeight:"bold",mr:1},children:we[t]||t}),!!c&&o(b,{variant:"filled",sx:{color:"white"},color:"short"===c?"warning":"success",label:String(c).toUpperCase()}),o(u,{sx:{flex:1}}),o(_,{disabled:r,onClick:s,children:o(E,{style:{color:"white",opacity:r?.5:1}})})]}),o(I,{}),!f||g?o(R,{sx:{height:"100%",width:"100%"}}):o(u,{sx:{position:"relative",flex:1},children:o(j,{style:{position:"absolute"},children:({height:e,width:t})=>o(xe,{items:f,height:e,width:t,position:c,priceOpen:d,priceStopLoss:m,priceTakeProfit:h})})})]})},Te=[{type:l.Link,action:"back-action",label:o(te,{sx:{display:"block"}})},{type:l.Link,action:"back-action",label:"Main"},{type:l.Link,action:"back-action",label:"Price Chart"},{type:l.Link,action:"back-action",compute:({symbol:e})=>String(e).toUpperCase()},{type:l.Link,action:"back-action",compute:({interval:e})=>String(e).toUpperCase()}],Ve=[{action:"download-now",label:"Download",icon:()=>o(c,{icon:Q,color:"#4caf50"})},{divider:!0},{action:"update-now",label:"Refresh",icon:()=>o(c,{icon:oe,color:"#4caf50"})}],$e=new D,He=new D,ze=[{type:r.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"symbol",title:"Symbol",readonly:!0,compute:e=>e.symbol||"N/A"},{type:r.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"position",title:"Position",readonly:!0,compute:e=>"long"===e.position?"🔵 LONG (profit on rise)":"🟠 SHORT (profit on fall)"},{type:r.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"priceOpen",title:"Entry",readonly:!0,compute:e=>e.priceOpen?`${M(e.priceOpen)}$`:"N/A"},{type:r.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"originalPriceOpen",title:"Original Entry",readonly:!0,isVisible:e=>null!=e.originalPriceOpen&&e.originalPriceOpen!==e.priceOpen,compute:e=>e.originalPriceOpen?`${M(e.originalPriceOpen)}$`:"N/A"},{type:r.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"priceTakeProfit",title:"Take Profit",readonly:!0,compute:e=>e.priceTakeProfit?`${M(e.priceTakeProfit)}$`:"N/A"},{type:r.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"originalPriceTakeProfit",title:"Original Take Profit",readonly:!0,isVisible:e=>null!=e.originalPriceTakeProfit&&e.originalPriceTakeProfit!==e.priceTakeProfit,compute:e=>e.originalPriceTakeProfit?`${M(e.originalPriceTakeProfit)}$`:"N/A"},{type:r.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"priceStopLoss",title:"Stop Loss",readonly:!0,compute:e=>e.priceStopLoss?`${M(e.priceStopLoss)}$`:"N/A"},{type:r.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"originalPriceStopLoss",title:"Original Stop Loss",readonly:!0,isVisible:e=>null!=e.originalPriceStopLoss&&e.originalPriceStopLoss!==e.priceStopLoss,compute:e=>e.originalPriceStopLoss?`${M(e.originalPriceStopLoss)}$`:"N/A"},{type:r.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"totalEntries",title:"Total Entries",readonly:!0,isVisible:e=>null!=e.totalEntries&&e.totalEntries>1,compute:e=>String(e.totalEntries)},{type:r.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"totalPartials",title:"Total Closes",readonly:!0,isVisible:e=>null!=e.totalPartials&&e.totalPartials>0,compute:e=>String(e.totalPartials)},{type:r.Component,sx:{mt:2},element:({payload:e})=>o(C,{variant:"outlined",onClick:e.handleClose,children:"Back"})}],Me=[{id:"chart",element:({params:e})=>{const t=G(()=>({symbol:String(e.symbol).toUpperCase(),interval:e.interval})),[l,{loading:s,execute:r}]=i(async()=>{const o=String(e.symbol).toUpperCase();return await a.signalViewService.getPendingSignal(o)},{onLoadStart:()=>a.layoutService.setAppbarLoader(!0),onLoadEnd:()=>a.layoutService.setAppbarLoader(!1),deps:[e.symbol]});A(()=>$e.subscribe(r));const c=x.useMemo(()=>l?l.priceTakeProfit:0,[l]),p=x.useMemo(()=>l?l.priceStopLoss:0,[l]),d=x.useMemo(()=>l?l.priceOpen:0,[l]),m=x.useMemo(()=>l?l.position:null,[l]),[u,h]=W(null),{pickData:b,setOpen:y,render:g}=B({title:"Info",AfterTitle:({onClose:e})=>o(f,{direction:"row",gap:2,children:[o(Y,{onClick:()=>a.layoutService.pickSignal(u.current.id),variant:"outlined",children:"Show Details"}),o(J,{size:"small",onClick:e,children:o(K,{})})]}),payload:()=>({handleClose(){y(!1)}}),fields:ze,handler:()=>u.current,withActionButton:!1}),k=U(async()=>{l&&(h(l),b(l.id))});return o(ee,{children:[o(n,{items:Te,actions:Ve,payload:t,onAction:async o=>{"back-action"===o&&a.routerService.push(`/price_chart/${e.symbol}`),"update-now"===o&&await $e.next(),"download-now"===o&&await He.next()}}),s?null:o(Pe,{symbol:t.symbol,interval:t.interval,disableInfo:!l,reloadSubject:$e,downloadSubject:He,onInfoClick:k,position:m,priceOpen:d,priceStopLoss:p,priceTakeProfit:c,sx:{height:"calc(100dvh - 165px)"}}),g()]})},isActive:e=>Z(["/price_chart/:symbol/:interval"],e)},{id:"coin",element:({params:e})=>{const{classes:t}=fe(),i=e.symbol,l=x.useMemo(()=>[{label:"1 minute",to:`/price_chart/${i}/1m`,color:"#2979ff",icon:ae},{label:"15 minutes",to:`/price_chart/${i}/15m`,color:"#f3a43a",icon:ne},{label:"1 hour",to:`/price_chart/${i}/1h`,color:"#d500f9",icon:ie}],[i]),s=x.useMemo(()=>[ve("Chart",l)],[l]);return o(ee,{children:[o(n,{items:ke,payload:i,onAction:e=>{"back-action"===e&&a.routerService.push("/price_chart")}}),o(m,{className:t.root,fields:s}),o(u,{paddingBottom:"24px"})]})},isActive:e=>Z(["/price_chart/:symbol"],e)},{id:"main",element:()=>{const{classes:e}=ce(),{reloadTrigger:l,doReload:s}=t(),[c,{loading:b}]=i(async()=>await(async()=>{const[e,o]=await Promise.all([a.symbolGlobalService.getSymbolList(),a.symbolGlobalService.getSymbolMap()]),t={};e.forEach((e,i)=>{const a=o[e],n=i+1,l=(null==a?void 0:a.priority)||n;t[l]||(t[l]=[]),t[l].push({symbol:e,label:(null==a?void 0:a.displayName)||e,color:(null==a?void 0:a.color)||"#ccc"})});const i=Object.entries(t).map(([e,o])=>({priority:parseInt(e),routes:o})).sort(({priority:e,routes:{length:o}},{priority:t,routes:{length:i}})=>i-o||t-e),n=[],l=[],s=[];return i.forEach(({routes:e,priority:o},t)=>{const i=ue(`Priority ${o}`,e);t%2==0&&n.push(i),t%2==1&&l.push(i),s.push(i)}),s.length?[{type:r.Group,columns:"6",className:"tabletLeftColumn",phoneHidden:!0,desktopHidden:!0,fields:n},{type:r.Group,columns:"6",className:"tabletRightColumn",phoneHidden:!0,desktopHidden:!0,fields:l},{type:r.Group,columns:"12",className:"wideColumn",tabletHidden:!0,fields:s}]:[]})(),{onLoadStart:()=>a.layoutService.setAppbarLoader(!0),onLoadEnd:()=>a.layoutService.setAppbarLoader(!1),deps:[l]});return o(ee,{children:[o(n,{items:de,actions:me,onAction:e=>{"back-action"===e&&a.routerService.push("/"),"update-now"===e&&s()}}),b||!c?o(d,{children:o(p,{variant:"h6",sx:{opacity:.5},children:"Loading..."})}):c.length?o(h,{children:[o(m,{className:e.root,fields:c},l),o(u,{paddingBottom:"24px"})]}):o(d,{children:o(p,{variant:"h6",sx:{opacity:.5},children:"No symbols found"})})]})},isActive:e=>Z(["/price_chart"],e)}],Ne=({symbol:e,interval:t})=>o(X,{history:a.routerService,onLoadStart:()=>a.layoutService.setAppbarLoader(!0),onLoadEnd:()=>a.layoutService.setAppbarLoader(!1),routes:Me,params:{symbol:e,interval:t}});export{Ne as PriceChartPage,Ne as default};
@@ -1 +1 @@
1
- import{h as e,f as t,c as n,r,i,S as o,m as a,U as l}from"./index-BI3k7b1T.js";const[c,s]=e("pine-code-context"),u=e=>t(c,{initialState:'//@version=5\nindicator("Simple MA", overlay=true)\n\nlength = input.int(20, "Length")\nsma = ta.sma(close, length)\n\nplot(sma, "SMA", color.blue, linewidth=2)',children:e.children}),[d,h]=e("pine-from-date-context"),v=e=>t(d,{initialState:"",children:e.children}),[m,p]=e("pine-limit-context"),g=e=>t(m,{initialState:250,children:e.children}),[f,y]=e("pine-symbol-context"),b=e=>t(f,{initialState:"BTCUSDT",children:e.children}),[C,D]=e("pine-timeframe-context"),x=e=>t(C,{initialState:"1",children:e.children}),[S,w]=e("pine-to-date-context"),T=e=>t(S,{initialState:"",children:e.children}),k=n(e=>t("div",{style:e.v0,children:[t("input",{type:"text",value:e.v1,onChange:e.v2,style:e.v3,placeholder:"BTCUSDT"}),t("select",{value:e.v4,onChange:e.v5,style:e.v6,children:e.v7}),t("input",{type:"number",value:e.v8,min:100,step:100,onChange:e.v9,style:e.v10,title:"Bars limit"}),t("input",{type:"date",value:e.v11,onChange:e.v12,style:e.v13,title:"From date"}),t("input",{type:"date",value:e.v14,onChange:e.v15,style:e.v16,title:"To date"}),t("button",{onClick:e.v17,disabled:e.v18,style:e.v19,children:e.v20}),e.v21]}),{name:"Toolbar_1",portals:["v7","v20","v21"]}),R=function({symbol:e,timeframe:n,fromDate:r,toDate:i,limit:o,running:a,status:l,onSymbolChange:c,onTimeframeChange:s,onFromDateChange:u,onToDateChange:d,onLimitChange:h,onRun:v}){return t(k,{v0:{display:"flex",gap:8,padding:"8px 12px",background:"#1e293b",alignItems:"center",flexShrink:0},v1:e,v2:e=>c(e.target.value.toUpperCase()),v3:{...B,width:100},v4:n,v5:e=>s(e.target.value),v6:B,v7:z.map(e=>t("option",{children:e},e)),v8:o,v9:e=>h(Number(e.target.value)),v10:{...B,width:80},v11:r,v12:e=>u(e.target.value),v13:F,v14:i,v15:e=>d(e.target.value),v16:F,v17:v,v18:a,v19:{background:"#3b82f6",color:"#fff",border:"none",borderRadius:4,padding:"5px 16px",fontSize:13,cursor:"pointer"},v20:a?"...":"▶ Run",v21:l&&t("span",{style:{fontSize:12,color:"#94a3b8",marginLeft:8},children:l})})},z=["1","5","15","60","D"],B={background:"#1e293b",color:"#e2e8f0",border:"1px solid #334155",borderRadius:4,padding:"4px 8px",fontSize:13},F={...B,colorScheme:"dark"},U=n(e=>t("textarea",{value:e.v0,onChange:e.v1,onKeyDown:e.v2,spellCheck:!1,style:e.v3}),{name:"CodeEditor_1"}),E=function({value:e,onChange:n,onRun:r}){return t(U,{v0:e,v1:e=>n(e.target.value),v2:e=>{e.ctrlKey&&"Enter"===e.key&&(e.preventDefault(),r())},v3:{width:320,flexShrink:0,resize:"none",background:"#1e293b",color:"#e2e8f0",border:"none",borderRight:"1px solid #334155",padding:12,fontFamily:"monospace",fontSize:13,lineHeight:1.5,outline:"none"}})},$={1:"1m",3:"3m",5:"5m",15:"15m",30:"30m",60:"1h",120:"2h",240:"4h",360:"6h",480:"8h","1D":"1d",D:"1d"};function L(e){return{time:e.openTime,open:e.open,high:e.high,low:e.low,close:e.close,volume:e.volume}}class I{async getMarketData(e,t,n,r,o){const a=e.toUpperCase().replace(/^BINANCE:|^BYBIT:|^OKX:/,""),l=$[t]??t;return(await i.exchangeViewService.getRangeCandles({symbol:a,interval:l,limit:n,sDate:r,eDate:o})).map(e=>({openTime:e.timestamp,open:e.open,high:e.high,low:e.low,close:e.close,volume:e.volume}))}async getSymbolInfo(e){const t=e.toUpperCase().replace(/^BINANCE:|^BYBIT:|^OKX:/,""),n=t.replace(/USDT$|BUSD$|USD$/,""),r=t.replace(n,"");return{ticker:t,tickerid:t,description:`${n}/${r}`,type:"crypto",basecurrency:n,currency:r||"USDT",timezone:"UTC"}}}const M=()=>t(o,{children:"\n #root > .MuiBox-root {\n padding-left: 0;\n padding-right: 0;\n }\n "}),P=()=>{const e=r.useRef(null),[n,i]=s(),[o,l]=y(),[c,u]=D(),[d,v]=h(),[m,g]=w(),[f,b]=p(),{run:C,status:x,running:S}=function(){const e=r.useRef(null),t=r.useRef(null),n=r.useRef(null),[i,o]=r.useState(""),[a,l]=r.useState(!1);function c(){if(n.current){try{n.current.stop()}catch{}n.current=null}}function s(){e.current&&(e.current.destroy(),e.current=null,t.current=null)}function u(e){o(`Error: ${e.message}`),l(!1)}return r.useEffect(()=>{const t=()=>{var t;return null==(t=e.current)?void 0:t.resize()};return window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t),c(),s()}},[]),{run:function({symbol:r,timeframe:i,fromDate:a,toDate:d,limit:h,code:v,containerRef:m}){if(!m.current)return;l(!0),o("Connecting..."),c(),s();const p=/indicator\([^)]*overlay\s*=\s*true/i.test(v);let g=!1;try{const c=a?new Date(a).getTime():void 0,s=d?new Date(d).getTime():void 0,f=new I,y=new PineTS(f,r,i,h,c,s).stream(v,{pageSize:500,live:!0,interval:3e3});n.current=y,y.on("data",a=>{var c,s;if(n.current===y)if(g)t.current&&a.plots&&t.current.updateData(a.plots),null==(s=e.current)||s.updateData([L(a.marketData[a.marketData.length-1])]);else{g=!0;const n=a.marketData.map(L);m.current.innerHTML="",e.current=new QFChart.QFChart(m.current,{title:`${r} · ${i}`,backgroundColor:"#0f172a",height:"100%",padding:.1,databox:{position:"right",triggerOn:"mousemove"},dataZoom:{visible:!0,position:"top",height:6,start:80,end:101},layout:{mainPaneHeight:"70%",gap:5},controls:{collapse:!1,maximize:!1,fullscreen:!1}}),e.current.setMarketData(n);const s=(null==(c=a.fullContext)?void 0:c.plots)??a.plots;t.current=e.current.addIndicator("indicator",s,{overlay:p,height:p?void 0:30,controls:{collapse:!1,maximize:!1}}),e.current.registerPlugin(new QFChart.MeasureTool),e.current.registerPlugin(new QFChart.LineTool),e.current.registerPlugin(new QFChart.FibonacciTool),o(`${n.length} bars loaded`),l(!1)}}),y.on("error",u)}catch(f){u(f)}},status:i,running:a}}();function T(){C({symbol:o,timeframe:c,fromDate:d,toDate:m,limit:f,code:n,containerRef:e})}return t(a,{children:t("div",{style:{display:"flex",flexDirection:"column",height:"100vh",background:"#0f172a",color:"#e2e8f0",fontFamily:"monospace"},children:[t(R,{symbol:o,timeframe:c,fromDate:d,toDate:m,limit:f,running:S,status:x,onSymbolChange:l,onTimeframeChange:u,onFromDateChange:v,onToDateChange:g,onLimitChange:b,onRun:T}),t("div",{style:{display:"flex",flex:1,overflow:"clip"},children:[t(E,{value:n,onChange:i,onRun:T}),t("div",{style:{flex:1},children:t("div",{ref:e,style:{width:"100%",height:"100%"},children:t("p",{style:{color:"#475569",textAlign:"center",marginTop:"20%"},children:["Press ",t("b",{children:"▶ Run"})," or ",t("b",{children:"Ctrl+Enter"})," to load the chart"]})})})]}),t(M,{})]})})},A=l(e=>t(u,{children:e}),e=>t(v,{children:e}),e=>t(T,{children:e}),e=>t(g,{children:e}),e=>t(b,{children:e}),e=>t(x,{children:e})),N=()=>A(t(P,{}));export{N as PinePage,N as default};
1
+ import{h as e,f as t,c as n,r,i,S as o,m as a,U as l}from"./index-Cgx-XS5d.js";const[c,s]=e("pine-code-context"),u=e=>t(c,{initialState:'//@version=5\nindicator("Simple MA", overlay=true)\n\nlength = input.int(20, "Length")\nsma = ta.sma(close, length)\n\nplot(sma, "SMA", color.blue, linewidth=2)',children:e.children}),[d,h]=e("pine-from-date-context"),v=e=>t(d,{initialState:"",children:e.children}),[m,p]=e("pine-limit-context"),g=e=>t(m,{initialState:250,children:e.children}),[f,y]=e("pine-symbol-context"),b=e=>t(f,{initialState:"BTCUSDT",children:e.children}),[C,D]=e("pine-timeframe-context"),x=e=>t(C,{initialState:"1",children:e.children}),[S,w]=e("pine-to-date-context"),T=e=>t(S,{initialState:"",children:e.children}),k=n(e=>t("div",{style:e.v0,children:[t("input",{type:"text",value:e.v1,onChange:e.v2,style:e.v3,placeholder:"BTCUSDT"}),t("select",{value:e.v4,onChange:e.v5,style:e.v6,children:e.v7}),t("input",{type:"number",value:e.v8,min:100,step:100,onChange:e.v9,style:e.v10,title:"Bars limit"}),t("input",{type:"date",value:e.v11,onChange:e.v12,style:e.v13,title:"From date"}),t("input",{type:"date",value:e.v14,onChange:e.v15,style:e.v16,title:"To date"}),t("button",{onClick:e.v17,disabled:e.v18,style:e.v19,children:e.v20}),e.v21]}),{name:"Toolbar_1",portals:["v7","v20","v21"]}),R=function({symbol:e,timeframe:n,fromDate:r,toDate:i,limit:o,running:a,status:l,onSymbolChange:c,onTimeframeChange:s,onFromDateChange:u,onToDateChange:d,onLimitChange:h,onRun:v}){return t(k,{v0:{display:"flex",gap:8,padding:"8px 12px",background:"#1e293b",alignItems:"center",flexShrink:0},v1:e,v2:e=>c(e.target.value.toUpperCase()),v3:{...B,width:100},v4:n,v5:e=>s(e.target.value),v6:B,v7:z.map(e=>t("option",{children:e},e)),v8:o,v9:e=>h(Number(e.target.value)),v10:{...B,width:80},v11:r,v12:e=>u(e.target.value),v13:F,v14:i,v15:e=>d(e.target.value),v16:F,v17:v,v18:a,v19:{background:"#3b82f6",color:"#fff",border:"none",borderRadius:4,padding:"5px 16px",fontSize:13,cursor:"pointer"},v20:a?"...":"▶ Run",v21:l&&t("span",{style:{fontSize:12,color:"#94a3b8",marginLeft:8},children:l})})},z=["1","5","15","60","D"],B={background:"#1e293b",color:"#e2e8f0",border:"1px solid #334155",borderRadius:4,padding:"4px 8px",fontSize:13},F={...B,colorScheme:"dark"},U=n(e=>t("textarea",{value:e.v0,onChange:e.v1,onKeyDown:e.v2,spellCheck:!1,style:e.v3}),{name:"CodeEditor_1"}),E=function({value:e,onChange:n,onRun:r}){return t(U,{v0:e,v1:e=>n(e.target.value),v2:e=>{e.ctrlKey&&"Enter"===e.key&&(e.preventDefault(),r())},v3:{width:320,flexShrink:0,resize:"none",background:"#1e293b",color:"#e2e8f0",border:"none",borderRight:"1px solid #334155",padding:12,fontFamily:"monospace",fontSize:13,lineHeight:1.5,outline:"none"}})},$={1:"1m",3:"3m",5:"5m",15:"15m",30:"30m",60:"1h",120:"2h",240:"4h",360:"6h",480:"8h","1D":"1d",D:"1d"};function L(e){return{time:e.openTime,open:e.open,high:e.high,low:e.low,close:e.close,volume:e.volume}}class I{async getMarketData(e,t,n,r,o){const a=e.toUpperCase().replace(/^BINANCE:|^BYBIT:|^OKX:/,""),l=$[t]??t;return(await i.exchangeViewService.getRangeCandles({symbol:a,interval:l,limit:n,sDate:r,eDate:o})).map(e=>({openTime:e.timestamp,open:e.open,high:e.high,low:e.low,close:e.close,volume:e.volume}))}async getSymbolInfo(e){const t=e.toUpperCase().replace(/^BINANCE:|^BYBIT:|^OKX:/,""),n=t.replace(/USDT$|BUSD$|USD$/,""),r=t.replace(n,"");return{ticker:t,tickerid:t,description:`${n}/${r}`,type:"crypto",basecurrency:n,currency:r||"USDT",timezone:"UTC"}}}const M=()=>t(o,{children:"\n #root > .MuiBox-root {\n padding-left: 0;\n padding-right: 0;\n }\n "}),P=()=>{const e=r.useRef(null),[n,i]=s(),[o,l]=y(),[c,u]=D(),[d,v]=h(),[m,g]=w(),[f,b]=p(),{run:C,status:x,running:S}=function(){const e=r.useRef(null),t=r.useRef(null),n=r.useRef(null),[i,o]=r.useState(""),[a,l]=r.useState(!1);function c(){if(n.current){try{n.current.stop()}catch{}n.current=null}}function s(){e.current&&(e.current.destroy(),e.current=null,t.current=null)}function u(e){o(`Error: ${e.message}`),l(!1)}return r.useEffect(()=>{const t=()=>{var t;return null==(t=e.current)?void 0:t.resize()};return window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t),c(),s()}},[]),{run:function({symbol:r,timeframe:i,fromDate:a,toDate:d,limit:h,code:v,containerRef:m}){if(!m.current)return;l(!0),o("Connecting..."),c(),s();const p=/indicator\([^)]*overlay\s*=\s*true/i.test(v);let g=!1;try{const c=a?new Date(a).getTime():void 0,s=d?new Date(d).getTime():void 0,f=new I,y=new PineTS(f,r,i,h,c,s).stream(v,{pageSize:500,live:!0,interval:3e3});n.current=y,y.on("data",a=>{var c,s;if(n.current===y)if(g)t.current&&a.plots&&t.current.updateData(a.plots),null==(s=e.current)||s.updateData([L(a.marketData[a.marketData.length-1])]);else{g=!0;const n=a.marketData.map(L);m.current.innerHTML="",e.current=new QFChart.QFChart(m.current,{title:`${r} · ${i}`,backgroundColor:"#0f172a",height:"100%",padding:.1,databox:{position:"right",triggerOn:"mousemove"},dataZoom:{visible:!0,position:"top",height:6,start:80,end:101},layout:{mainPaneHeight:"70%",gap:5},controls:{collapse:!1,maximize:!1,fullscreen:!1}}),e.current.setMarketData(n);const s=(null==(c=a.fullContext)?void 0:c.plots)??a.plots;t.current=e.current.addIndicator("indicator",s,{overlay:p,height:p?void 0:30,controls:{collapse:!1,maximize:!1}}),e.current.registerPlugin(new QFChart.MeasureTool),e.current.registerPlugin(new QFChart.LineTool),e.current.registerPlugin(new QFChart.FibonacciTool),o(`${n.length} bars loaded`),l(!1)}}),y.on("error",u)}catch(f){u(f)}},status:i,running:a}}();function T(){C({symbol:o,timeframe:c,fromDate:d,toDate:m,limit:f,code:n,containerRef:e})}return t(a,{children:t("div",{style:{display:"flex",flexDirection:"column",height:"100vh",background:"#0f172a",color:"#e2e8f0",fontFamily:"monospace"},children:[t(R,{symbol:o,timeframe:c,fromDate:d,toDate:m,limit:f,running:S,status:x,onSymbolChange:l,onTimeframeChange:u,onFromDateChange:v,onToDateChange:g,onLimitChange:b,onRun:T}),t("div",{style:{display:"flex",flex:1,overflow:"clip"},children:[t(E,{value:n,onChange:i,onRun:T}),t("div",{style:{flex:1},children:t("div",{ref:e,style:{width:"100%",height:"100%"},children:t("p",{style:{color:"#475569",textAlign:"center",marginTop:"20%"},children:["Press ",t("b",{children:"▶ Run"})," or ",t("b",{children:"Ctrl+Enter"})," to load the chart"]})})})]}),t(M,{})]})})},A=l(e=>t(u,{children:e}),e=>t(v,{children:e}),e=>t(T,{children:e}),e=>t(g,{children:e}),e=>t(b,{children:e}),e=>t(x,{children:e})),N=()=>A(t(P,{}));export{N as PinePage,N as default};
@@ -1 +1 @@
1
- import{b as a,f as e,aZ as t,B as o,A as r,a9 as n,T as i,H as s,a3 as c,F as l,G as d,P as h,aO as p,a$ as u,b0 as b,aG as w,a8 as f,i as x,aH as g,al as y,aL as v,O as m,R as S,b1 as L,a_ as k,D as j,Z as A}from"./index-BI3k7b1T.js";import{A as H}from"./Article-CpU7DBcT.js";import{C as R,R as z}from"./Refresh-3cixHjvW.js";import{K as C}from"./KeyboardArrowLeft-BUZ_pXI5.js";const B=a(e("path",{d:"M20 8h-2.81c-.45-.78-1.07-1.45-1.82-1.96L17 4.41 15.59 3l-2.17 2.17C12.96 5.06 12.49 5 12 5c-.49 0-.96.06-1.41.17L8.41 3 7 4.41l1.62 1.63C7.88 6.55 7.26 7.22 6.81 8H4v2h2.09c-.05.33-.09.66-.09 1v1H4v2h2v1c0 .34.04.67.09 1H4v2h2.81c1.04 1.79 2.97 3 5.19 3s4.15-1.21 5.19-3H20v-2h-2.09c.05-.33.09-.66.09-1v-1h2v-2h-2v-1c0-.34-.04-.67-.09-1H20V8zm-6 8h-4v-2h4v2zm0-4h-4v-2h4v2z"}),"BugReport"),D=a=>{const t={color:"white",fontSize:28};switch(a.type){case"debug":return e(B,{sx:t});case"info":return e(u,{sx:t});case"warn":return e(p,{sx:t});default:return e(H,{sx:t})}},E=t.virtualize(({data:a,sx:t})=>{const p=(a=>{switch(a.type){case"debug":default:return"#9E9E9E";case"info":return"#2196F3";case"warn":return"#FF9800";case"log":return"#4CAF50"}})(a);return e(h,{variant:"outlined",sx:{display:"flex",alignItems:"stretch",justifyContent:"stretch",...t},children:e(o,{sx:{flex:1,position:"relative",overflow:"clip",height:"100%",width:"100%",borderRadius:"12px"},children:[e(r,{direction:"row",spacing:2,sx:{p:2},children:[e(n,{sx:{width:56,height:56,background:p},children:D(a)}),e(r,{flex:1,spacing:1,children:[e(r,{direction:"row",justifyContent:"space-between",alignItems:"flex-start",children:[e(i,{variant:"h6",sx:{fontWeight:600,wordBreak:"break-all"},children:a.topic}),e(i,{variant:"body2",color:"text.secondary",sx:{whiteSpace:"nowrap",ml:2},children:s(a.createdAt).format("HH:mm DD/MM/YYYY")})]}),e(r,{direction:"row",spacing:1,flexWrap:"wrap",children:e(c,{size:"small",label:a.type.toUpperCase(),sx:{background:p,color:"white",fontWeight:500}})}),a.args.length>0&&e(l,{children:[e(d,{sx:{my:1}}),e(o,{component:"pre",sx:{m:0,fontSize:"0.75rem",whiteSpace:"pre-wrap",wordBreak:"break-all",color:"text.secondary"},children:JSON.stringify(1===a.args.length?a.args[0]:a.args,null,2)})]})]})]}),e(o,{sx:{position:"absolute",top:0,left:0,bottom:0,width:6,zIndex:1,background:p}})]})})}),F=[{action:"download-action",label:"Download",icon:()=>e(A,{icon:j,color:"#4caf50"})},{divider:!0},{action:"update-now",label:"Refresh manually",icon:()=>e(A,{icon:z,color:"#4caf50"})}],M=[{type:S.Link,action:"back-action",label:e(C,{sx:{display:"block"}})},{type:S.Link,action:"back-action",label:"Main"},{type:S.Link,action:"back-action",label:"Logs"},{type:S.Button,icon:L,action:"search-action",label:"Search"}],O=new f,Y=()=>{const[a,o]=b(""),{data:r,hasMore:n,loading:i,onSkip:s}=w({handler:async(e,t)=>{const o=await x.logViewService.getList(),r=g(e,t);for(const n of o)if(new RegExp(a.current,"i").test(n.topic)&&r([n]).done)break;return r().rows},onLoadStart:()=>x.layoutService.setAppbarLoader(!0),onLoadEnd:()=>x.layoutService.setAppbarLoader(!1),reloadSubject:O}),c=y(r),{execute:l}=v(async()=>{const a=new Blob([JSON.stringify(c.current,null,2)],{type:"application/json"}),e=URL.createObjectURL(a);x.layoutService.downloadFile(e,`logs_${Date.now()}.json`)},{onLoadStart:()=>x.layoutService.setAppbarLoader(!0),onLoadEnd:()=>x.layoutService.setAppbarLoader(!1)});return e(R,{children:[e(m,{items:M,actions:F,onAction:async a=>{"back-action"===a&&x.routerService.push("/"),"download-action"===a&&l(),"update-now"===a&&(o(""),await O.next()),"search-action"===a&&(async()=>{const a=await x.layoutService.prompt("Search keyword");if(a)return o(a),void O.next();o(""),O.next()})()}}),e(t,{sx:{height:"calc(100vh - 155px)"},withScrollbar:!0,minHeight:72,loading:i,onDataRequest:s,bufferSize:k,hasMore:n,children:r.map(a=>e(E,{data:a,sx:{mb:1}},a.id))})]})};export{Y as LogPage,Y as default};
1
+ import{b as a,f as e,aZ as t,B as o,A as r,a9 as n,T as i,H as s,a3 as c,F as l,G as d,P as h,aO as p,a$ as u,b0 as b,aG as w,a8 as f,i as x,aH as g,al as y,aL as v,O as m,R as S,b1 as L,a_ as k,D as j,Z as A}from"./index-Cgx-XS5d.js";import{A as H}from"./Article-BFa1r6-4.js";import{C as R,R as z}from"./Refresh-BrRXF_OY.js";import{K as C}from"./KeyboardArrowLeft-vg5fS39b.js";const B=a(e("path",{d:"M20 8h-2.81c-.45-.78-1.07-1.45-1.82-1.96L17 4.41 15.59 3l-2.17 2.17C12.96 5.06 12.49 5 12 5c-.49 0-.96.06-1.41.17L8.41 3 7 4.41l1.62 1.63C7.88 6.55 7.26 7.22 6.81 8H4v2h2.09c-.05.33-.09.66-.09 1v1H4v2h2v1c0 .34.04.67.09 1H4v2h2.81c1.04 1.79 2.97 3 5.19 3s4.15-1.21 5.19-3H20v-2h-2.09c.05-.33.09-.66.09-1v-1h2v-2h-2v-1c0-.34-.04-.67-.09-1H20V8zm-6 8h-4v-2h4v2zm0-4h-4v-2h4v2z"}),"BugReport"),D=a=>{const t={color:"white",fontSize:28};switch(a.type){case"debug":return e(B,{sx:t});case"info":return e(u,{sx:t});case"warn":return e(p,{sx:t});default:return e(H,{sx:t})}},E=t.virtualize(({data:a,sx:t})=>{const p=(a=>{switch(a.type){case"debug":default:return"#9E9E9E";case"info":return"#2196F3";case"warn":return"#FF9800";case"log":return"#4CAF50"}})(a);return e(h,{variant:"outlined",sx:{display:"flex",alignItems:"stretch",justifyContent:"stretch",...t},children:e(o,{sx:{flex:1,position:"relative",overflow:"clip",height:"100%",width:"100%",borderRadius:"12px"},children:[e(r,{direction:"row",spacing:2,sx:{p:2},children:[e(n,{sx:{width:56,height:56,background:p},children:D(a)}),e(r,{flex:1,spacing:1,children:[e(r,{direction:"row",justifyContent:"space-between",alignItems:"flex-start",children:[e(i,{variant:"h6",sx:{fontWeight:600,wordBreak:"break-all"},children:a.topic}),e(i,{variant:"body2",color:"text.secondary",sx:{whiteSpace:"nowrap",ml:2},children:s(a.createdAt).format("HH:mm DD/MM/YYYY")})]}),e(r,{direction:"row",spacing:1,flexWrap:"wrap",children:e(c,{size:"small",label:a.type.toUpperCase(),sx:{background:p,color:"white",fontWeight:500}})}),a.args.length>0&&e(l,{children:[e(d,{sx:{my:1}}),e(o,{component:"pre",sx:{m:0,fontSize:"0.75rem",whiteSpace:"pre-wrap",wordBreak:"break-all",color:"text.secondary"},children:JSON.stringify(1===a.args.length?a.args[0]:a.args,null,2)})]})]})]}),e(o,{sx:{position:"absolute",top:0,left:0,bottom:0,width:6,zIndex:1,background:p}})]})})}),F=[{action:"download-action",label:"Download",icon:()=>e(A,{icon:j,color:"#4caf50"})},{divider:!0},{action:"update-now",label:"Refresh manually",icon:()=>e(A,{icon:z,color:"#4caf50"})}],M=[{type:S.Link,action:"back-action",label:e(C,{sx:{display:"block"}})},{type:S.Link,action:"back-action",label:"Main"},{type:S.Link,action:"back-action",label:"Logs"},{type:S.Button,icon:L,action:"search-action",label:"Search"}],O=new f,Y=()=>{const[a,o]=b(""),{data:r,hasMore:n,loading:i,onSkip:s}=w({handler:async(e,t)=>{const o=await x.logViewService.getList(),r=g(e,t);for(const n of o)if(new RegExp(a.current,"i").test(n.topic)&&r([n]).done)break;return r().rows},onLoadStart:()=>x.layoutService.setAppbarLoader(!0),onLoadEnd:()=>x.layoutService.setAppbarLoader(!1),reloadSubject:O}),c=y(r),{execute:l}=v(async()=>{const a=new Blob([JSON.stringify(c.current,null,2)],{type:"application/json"}),e=URL.createObjectURL(a);x.layoutService.downloadFile(e,`logs_${Date.now()}.json`)},{onLoadStart:()=>x.layoutService.setAppbarLoader(!0),onLoadEnd:()=>x.layoutService.setAppbarLoader(!1)});return e(R,{children:[e(m,{items:M,actions:F,onAction:async a=>{"back-action"===a&&x.routerService.push("/"),"download-action"===a&&l(),"update-now"===a&&(o(""),await O.next()),"search-action"===a&&(async()=>{const a=await x.layoutService.prompt("Search keyword");if(a)return o(a),void O.next();o(""),O.next()})()}}),e(t,{sx:{height:"calc(100vh - 155px)"},withScrollbar:!0,minHeight:72,loading:i,onDataRequest:s,bufferSize:k,hasMore:n,children:r.map(a=>e(E,{data:a,sx:{mb:1}},a.id))})]})};export{Y as LogPage,Y as default};
@@ -1 +1 @@
1
- import{g as e,a as t,r as o,u as a,_ as i,d as r,f as n,e as l,k as s,s as c,P as p,b as d,Q as m,x as y,i as u,O as g,R as h,p as b,a2 as f,Z as v,T as x,b2 as C,W as w,B as S,F as N,a3 as P,E as k,A,a5 as L,l as M,n as T,a4 as $,a6 as B,ai as R,b3 as F,b4 as V,w as z,X as I,a8 as E,b5 as O,D,b6 as j,b7 as H,ag as W,V as G,N as q,a1 as _,b8 as U,ad as Y,b9 as Q,ba as J,bb as K,J as X,bc as Z,aX as ee,ah as te,bd as oe,aQ as ae,aO as ie,a$ as re,be as ne,bf as le,bg as se,bh as ce,I as pe,av as de,al as me,bi as ye,aj as ue}from"./index-BI3k7b1T.js";import{h as ge}from"./hasRouteMatch-CqJJG3sx.js";import{I as he}from"./IconPhoto-Czod_jkW.js";import{C as be,R as fe}from"./Refresh-3cixHjvW.js";import{K as ve}from"./KeyboardArrowLeft-BUZ_pXI5.js";import{B as xe}from"./Background-DISIt7NA.js";import{r as Ce}from"./emitters-DmNf0ttF.js";function we(t){return e("MuiCard",t)}t("MuiCard",["root"]);const Se=["className","raised"],Ne=c(p,{name:"MuiCard",slot:"Root",overridesResolver:(e,t)=>t.root})(()=>({overflow:"hidden"})),Pe=o.forwardRef(function(e,t){const o=a({props:e,name:"MuiCard"}),{className:c,raised:p=!1}=o,d=i(o,Se),m=r({},o,{raised:p}),y=(e=>{const{classes:t}=e;return s({root:["root"]},we,t)})(m);return n(Ne,r({className:l(y.root,c),elevation:p?8:void 0,ref:t,ownerState:m},d))});function ke(t){return e("MuiCardContent",t)}t("MuiCardContent",["root"]);const Ae=["className","component"],Le=c("div",{name:"MuiCardContent",slot:"Root",overridesResolver:(e,t)=>t.root})(()=>({padding:16,"&:last-child":{paddingBottom:24}})),Me=o.forwardRef(function(e,t){const o=a({props:e,name:"MuiCardContent"}),{className:c,component:p="div"}=o,d=i(o,Ae),m=r({},o,{component:p}),y=(e=>{const{classes:t}=e;return s({root:["root"]},ke,t)})(m);return n(Le,r({as:p,className:l(y.root,c),ownerState:m,ref:t},d))}),Te=d(n("path",{d:"M18.21 9.21C15.93 10.78 13.45 13.3 13 17h2v2H9v-2h2c-.5-4.5-4.37-8-9-8V7c4.39 0 8.22 2.55 10 6.3 1.13-2.43 2.99-4.25 4.78-5.52L14 5h7v7l-2.79-2.79z"}),"AirlineStops"),$e=d(n("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"}),"CheckCircle"),Be=d(n("path",{d:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"}),"CloseOutlined"),Re=d(n("path",{d:"M12 2 4 5v6.09c0 5.05 3.41 9.76 8 10.91 4.59-1.15 8-5.86 8-10.91V5l-8-3zm6 9.09c0 4-2.55 7.7-6 8.83-3.45-1.13-6-4.82-6-8.83v-4.7l6-2.25 6 2.25v4.7z"}),"ShieldOutlined"),Fe=d(n("path",{d:"m16 6 2.29 2.29-4.88 4.88-4-4L2 16.59 3.41 18l6-6 4 4 6.3-6.29L22 12V6h-6z"}),"TrendingUpOutlined"),Ve=d(n("path",{d:"M21 6H3c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm-10 7H8v3H6v-3H3v-2h3V8h2v3h3v2zm4.5 2c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5zm4-3c-.83 0-1.5-.67-1.5-1.5S18.67 9 19.5 9s1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"}),"VideogameAsset"),ze="backtest-kit__groupHeader",Ie="backtest-kit__groupRoot",Ee="backtest-kit__symbolImage",Oe=b()({root:{[`& .${Ie}:hover .${ze}`]:{opacity:"1 !important"}}});function De(e){return B(e,"#000000")>B(e,"#FFFFFF")}const je=[{type:h.Link,action:"back-action",label:n(ve,{sx:{display:"block"}})},{type:h.Link,action:"back-action",label:"Main"},{type:h.Link,action:"back-action",label:"Status"}],He=[{action:"update-now",label:"Refresh",icon:()=>n(v,{icon:fe,color:"#4caf50"})}],We=(e,t)=>({type:f.Group,className:Ie,sx:{p:2},tabletColumns:"12",desktopColumns:"3",fields:[{type:f.Component,className:ze,style:{transition:"opacity 500ms",opacity:.5},element:()=>n(A,{direction:"row",children:[n(P,{variant:"outlined",size:"small",color:"info",label:`${k.bullet} ${e}`,sx:{mb:1,pr:.5,fontSize:"14px",background:"white",cursor:"not-allowed"}}),n(S,{flex:1})]})},{type:f.Group,fields:t.map(({symbol:e,label:t,to:o,color:a})=>((e,t,o,a)=>({type:f.Component,desktopColumns:"6",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:()=>n($,{component:L,onClick:()=>{u.routerService.push(`/status/${t}`)},sx:{width:"100%",background:a,color:"white",fontWeight:"bold",fontSize:"14px",height:"75px",minHeight:"75px",textWrap:"wrap",padding:"16px",[`& .${Ee}`]:{transition:"filter 500ms"},"&:hover":{background:()=>De(a)?M(a,.33):T(a,.33),[`& .${Ee}`]:{transition:"filter 500ms",filter:De(a)?"brightness(0.7) contrast(1.2)":"brightness(1.3) contrast(0.5)"}},transition:"background 500ms"},startIcon:n(he,{className:Ee,symbol:e}),children:n(S,{sx:{overflow:"hidden",textOverflow:"ellipsis",width:"75px"},children:o})})}))(e,o,t,a))}]}),Ge=[{type:h.Link,action:"back-action",label:n(ve,{sx:{display:"block"}})},{type:h.Link,action:"back-action",label:"Main"},{type:h.Link,action:"back-action",label:"Status"},{type:h.Link,action:"back-action",compute:e=>e?`${String(e.symbol).toUpperCase()} (${e.strategyName})`:"Live"},{type:h.Button,action:"control-action",label:"Manual Control",icon:Ve},{type:h.Fab,action:"print-action",label:"Print",icon:O},{type:h.Fab,action:"update-now",label:"Refresh",icon:fe}],qe=[{action:"print-action",label:"Print",icon:()=>n(v,{icon:O,color:"#4caf50"})},{action:"download-action",label:"Download",icon:()=>n(v,{icon:D,color:"#4caf50"})},{divider:!0},{action:"update-now",label:"Refresh",icon:()=>n(v,{icon:fe,color:"#4caf50"})}],_e=new E,Ue=new E,Ye=new E,Qe=new E,Je=new E,Ke=_.createLoader(12),Xe=({payload:e})=>n(S,{sx:{mb:1,minHeight:48},children:n(H,{sx:{height:"100%",minHeight:48},hideOverflowY:!0,children:n(A,{direction:"row",gap:1,sx:{pointerEvents:"all"},children:[n(W,{startIcon:n(Te,{}),onClick:async()=>await Ue.next(),color:"success",sx:{whiteSpace:"nowrap"},children:"Open Position"}),n(W,{startIcon:n(Fe,{}),onClick:async()=>await Ye.next(),color:"warning",sx:{whiteSpace:"nowrap"},children:"Commit Averaging"}),n(W,{startIcon:n(Re,{}),onClick:async()=>await Je.next(),sx:{whiteSpace:"nowrap"},children:"Commit Breakeven"}),n(S,{flex:1}),n(G,{Loader:Ke,deps:[e.symbol,e.exchangeName,e.strategyName],reloadSubject:Ce,children:async()=>{const t=await u.controlViewService.getAveragePrice(e.symbol,{exchangeName:e.exchangeName,strategyName:e.strategyName}),o=Number(t);return n(x,{height:"100%",display:"flex",alignItems:"center",whiteSpace:"nowrap",mr:1,children:["Avg price ",e.symbol,":",k.nbsp,n("b",{children:`${o.toFixed(q(o))}$`})]})}}),n(W,{startIcon:n(Be,{}),onClick:async()=>await Qe.next(),sx:{whiteSpace:"nowrap"},color:"error",children:"Close Position"})]})})}),Ze=[{type:f.Center,child:{type:f.Group,desktopColumns:"6",tabletColumns:"12",phoneColumns:"12",fields:[{type:f.Typography,style:{opacity:.5},fieldBottomMargin:"3",typoVariant:"h6",placeholder:"Open Position"},{type:f.Outline,fields:[{type:f.Combo,name:"position",title:"Direction",placeholder:"Select direction",itemList:["long","short"],validation:{required:!0},defaultValue:"long"},{type:f.Text,name:"cost",inputPattern:"[0-9]*",inputMode:"numeric",inputType:"tel",trailingIcon:Y,trailingIconClick:(e,{},{},t)=>{t("")},validation:{required:!0},title:"Amount USDT",placeholder:"00000",inputFormatterSymbol:"0",inputFormatterAllowed:/[0-9]/,defaultValue:"100"},{type:f.Text,outlined:!0,name:"quantity",sx:{cursor:"not-allowed","& *":{cursor:"not-allowed"}},title:"Coin Quantity",placeholder:"0.00",compute:(e,t)=>{const o=parseFloat(e.cost||"0"),a=parseFloat(t.averagePrice||"0");return o&&a?(o/a).toFixed(6):"0"},inputFormatterSymbol:"0",inputFormatterAllowed:/[0-9.]/,readonly:!0},{type:f.Text,name:"note",title:"Note",placeholder:"Reason for opening the position"}]},{type:f.Typography,fieldBottomMargin:"3",typoVariant:"caption",sx:{pt:2,opacity:.5,fontSize:12},placeholder:`${k.bullet} After pressing the Next button, the position will be opened IMMEDIATELY`}]}}],et=[{type:f.Center,child:{type:f.Group,desktopColumns:"6",tabletColumns:"12",phoneColumns:"12",fields:[{type:f.Typography,style:{opacity:.5},fieldBottomMargin:"3",typoVariant:"h6",placeholder:"Open Position"},{type:f.Outline,fields:[{type:f.Text,name:"symbol",compute:({},e)=>e.symbol,title:"Symbol"},{type:f.Text,name:"price",inputPattern:"[0-9.]*",inputMode:"decimal",inputType:"tel",compute:({},e)=>`${X(e.averagePrice)}$`,title:"Coin Price",placeholder:"000000.00",inputFormatterSymbol:"0",inputFormatterAllowed:/[0-9.]/}]},{type:f.Typography,fieldBottomMargin:"3",typoVariant:"caption",sx:{pt:2,opacity:.5,fontSize:12},placeholder:`${k.bullet} Carefully verify that this is the coin you want to open a position on. Rely on the symbol AND THE PRICE`}]}}],tt=({type:e,title:t,description:o,amount:a,price:i,symbol:r})=>{const l=Z(),s="loading"===e?{color:l.palette.warning.main,bgColor:te(l.palette.warning.main,.1),icon:n(oe,{size:24,color:"warning"}),chipColor:"warning"}:"success"===e?{color:l.palette.success.main,bgColor:te(l.palette.success.main,.1),icon:n($e,{}),chipColor:"success"}:"error"===e?{color:l.palette.error.main,bgColor:te(l.palette.error.main,.1),icon:n(ae,{}),chipColor:"error"}:"warning"===e?{color:l.palette.warning.main,bgColor:te(l.palette.warning.main,.1),icon:n(ie,{}),chipColor:"warning"}:"info"===e?{color:l.palette.info.main,bgColor:te(l.palette.info.main,.1),icon:n(re,{}),chipColor:"info"}:{color:l.palette.grey[500],bgColor:te(l.palette.grey[500],.1),icon:n(re,{}),chipColor:"default"};return n(Pe,{elevation:0,sx:{backgroundColor:s.bgColor,border:`1px solid ${te(s.color,.3)}`,borderRadius:2,transition:"all 0.3s ease"},children:n(Me,{sx:{p:3},children:[n(S,{sx:{display:"flex",alignItems:"center",gap:2,mb:2},children:[n(S,{sx:{color:s.color,display:"flex",alignItems:"center"},children:s.icon}),n(x,{variant:"h6",sx:{color:s.color,fontWeight:600,flex:1},children:t}),r&&n(P,{label:r,size:"small",color:s.chipColor,variant:"outlined",icon:n(ee,{})})]}),o&&n(x,{variant:"body2",color:"text.secondary",sx:{mb:2,lineHeight:1.5},children:o}),(a||i)&&n(S,{sx:{display:"flex",gap:3,mt:2,p:2,backgroundColor:te(l.palette.background.paper,.6),borderRadius:1,border:`1px solid ${te(s.color,.1)}`},children:[a&&n(S,{children:[n(x,{variant:"caption",color:"text.secondary",children:"Amount"}),n(x,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:a})]}),i&&n(S,{children:[n(x,{variant:"caption",color:"text.secondary",children:"Price"}),n(x,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:i})]})]})]})})},ot={success:!1,loading:!0,error:""},at=[{id:"brief",element:({data:e,payload:t,history:o,onChange:a,onClose:i,setLoading:r})=>{const l=U([e],50),[s,{loading:c}]=y(async()=>{const e=t.getContext();return{averagePrice:await u.controlViewService.getAveragePrice(e.symbol,{strategyName:e.strategyName,exchangeName:e.exchangeName}),symbol:e.symbol}},{onLoadStart:()=>r(!0),onLoadEnd:()=>r(!1)});return n(K,{Navigation:n(J,{hasPrev:!0,hasNext:!!s,labelPrev:"Close",onPrev:async()=>{await i()},onNext:async()=>{a({averagePrice:s.averagePrice,symbol:s.symbol}),await l(),o.replace("/form")}}),children:s?c?null:n(w,{payload:()=>({averagePrice:s.averagePrice,symbol:s.symbol}),slots:Q,fields:et}):null})},isActive:e=>!!le("/brief",e)},{id:"form",element:({data:e,history:t,formState:a,onChange:i})=>{const[r,l]=o.useState(e),s=U([e],50);return n(K,{Navigation:n(J,{hasPrev:!0,hasNext:!0,labelPrev:"Back",onPrev:async()=>{t.replace("/brief")},onNext:async()=>{r&&(i({position:r.position,cost:r.cost,note:r.note,symbol:a.data.brief.symbol}),await s(),t.replace("/submit"))}}),children:n(w,{payload:()=>({averagePrice:a.data.brief.averagePrice}),onChange:e=>l(e),slots:Q,fields:Ze,sx:{pt:1}})})},isActive:e=>!!le("/form",e)},{id:"submit",element:({formState:e,payload:t,beginSave:a,setLoading:i})=>{const[r,l]=o.useState(ot),{position:s,cost:c,note:p,symbol:d}=o.useMemo(()=>{const{position:t,cost:o,note:a,symbol:i}=e.data.form;return{position:t,cost:o,note:a,symbol:i}},[e]);I(async()=>{i(!0);try{const e=t.getContext();await u.controlViewService.commitOpenPending(e.symbol,{strategyName:e.strategyName,exchangeName:e.exchangeName},{position:s,cost:parseFloat(c||"0"),note:p||""}),l({success:!0,loading:!1,error:""})}catch(e){l({success:!1,loading:!1,error:ne(e)})}finally{i(!1)}});return n(K,{Navigation:n(J,{hasNext:r.success||!!r.error,labelNext:"Close",onNext:async()=>{await a()}}),children:n(S,{p:1,children:r.error?n(tt,{type:"error",title:"Position Opening Error",description:r.error,amount:`${X(parseFloat(c||"0"))}$`,symbol:d}):r.loading?n(tt,{type:"loading",title:"Opening Position",description:"Please wait. Your operation is being processed...",amount:`${X(parseFloat(c||"0"))}$`,symbol:d}):n(tt,{type:"success",title:"Position Opened",description:"Position has been scheduled successfully. Waiting for the order to be executed on the exchange",amount:`${X(parseFloat(c||"0"))}$`,symbol:d})})})},isActive:e=>!!le("/submit",e)}],it=[{id:"brief",label:"Briefing"},{id:"form",label:"Input"},{id:"submit",label:"Opening"}],rt="/brief",nt=de(),lt=[{type:f.Center,child:{type:f.Group,desktopColumns:"6",tabletColumns:"12",phoneColumns:"12",fields:[{type:f.Typography,style:{opacity:.5},fieldBottomMargin:"3",typoVariant:"h6",placeholder:"Average Position"},{type:f.Outline,fields:[{type:f.Text,name:"cost",inputPattern:"[0-9]*",inputMode:"numeric",inputType:"tel",trailingIcon:Y,trailingIconClick:(e,{},{},t)=>{t("")},validation:{required:!0},title:"Amount USDT",placeholder:"00000",inputFormatterSymbol:"0",inputFormatterAllowed:/[0-9]/,defaultValue:"100"},{type:f.Text,outlined:!0,name:"quantity",sx:{cursor:"not-allowed","& *":{cursor:"not-allowed"}},title:"Coin Quantity",placeholder:"0.00",compute:(e,t)=>{const o=parseFloat(e.cost||"0"),a=parseFloat(t.averagePrice||"0");return o&&a?(o/a).toFixed(6):"0"},inputFormatterSymbol:"0",inputFormatterAllowed:/[0-9.]/,readonly:!0},{type:f.Text,name:"note",title:"Note",placeholder:"Reason for averaging the position"}]},{type:f.Typography,fieldBottomMargin:"3",typoVariant:"caption",sx:{pt:2,opacity:.5,fontSize:12},placeholder:`${k.bullet} After pressing the Next button, the averaging will be performed IMMEDIATELY`}]}}],st=[{type:f.Center,child:{type:f.Group,desktopColumns:"6",tabletColumns:"12",phoneColumns:"12",fields:[{type:f.Typography,style:{opacity:.5},fieldBottomMargin:"3",typoVariant:"h6",placeholder:"Average Position"},{type:f.Outline,fields:[{type:f.Text,name:"symbol",compute:({},e)=>e.symbol,title:"Symbol"},{type:f.Text,name:"price",inputPattern:"[0-9.]*",inputMode:"decimal",inputType:"tel",compute:({},e)=>`${X(e.averagePrice)}$`,title:"Coin Price",placeholder:"000000.00",inputFormatterSymbol:"0",inputFormatterAllowed:/[0-9.]/}]},{type:f.Typography,fieldBottomMargin:"3",typoVariant:"caption",sx:{pt:2,opacity:.5,fontSize:12},placeholder:`${k.bullet} Carefully verify that this is the coin you want to average the position on. Rely on the symbol AND THE PRICE`}]}}],ct=({type:e,title:t,description:o,amount:a,price:i,symbol:r})=>{const l=Z(),s="loading"===e?{color:l.palette.warning.main,bgColor:te(l.palette.warning.main,.1),icon:n(oe,{size:24,color:"warning"}),chipColor:"warning"}:"success"===e?{color:l.palette.success.main,bgColor:te(l.palette.success.main,.1),icon:n($e,{}),chipColor:"success"}:"error"===e?{color:l.palette.error.main,bgColor:te(l.palette.error.main,.1),icon:n(ae,{}),chipColor:"error"}:"warning"===e?{color:l.palette.warning.main,bgColor:te(l.palette.warning.main,.1),icon:n(ie,{}),chipColor:"warning"}:"info"===e?{color:l.palette.info.main,bgColor:te(l.palette.info.main,.1),icon:n(re,{}),chipColor:"info"}:{color:l.palette.grey[500],bgColor:te(l.palette.grey[500],.1),icon:n(re,{}),chipColor:"default"};return n(Pe,{elevation:0,sx:{backgroundColor:s.bgColor,border:`1px solid ${te(s.color,.3)}`,borderRadius:2,transition:"all 0.3s ease"},children:n(Me,{sx:{p:3},children:[n(S,{sx:{display:"flex",alignItems:"center",gap:2,mb:2},children:[n(S,{sx:{color:s.color,display:"flex",alignItems:"center"},children:s.icon}),n(x,{variant:"h6",sx:{color:s.color,fontWeight:600,flex:1},children:t}),r&&n(P,{label:r,size:"small",color:s.chipColor,variant:"outlined",icon:n(ee,{})})]}),o&&n(x,{variant:"body2",color:"text.secondary",sx:{mb:2,lineHeight:1.5},children:o}),(a||i)&&n(S,{sx:{display:"flex",gap:3,mt:2,p:2,backgroundColor:te(l.palette.background.paper,.6),borderRadius:1,border:`1px solid ${te(s.color,.1)}`},children:[a&&n(S,{children:[n(x,{variant:"caption",color:"text.secondary",children:"Amount"}),n(x,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:a})]}),i&&n(S,{children:[n(x,{variant:"caption",color:"text.secondary",children:"Price"}),n(x,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:i})]})]})]})})},pt={success:!1,loading:!0,error:""},dt=[{id:"brief",element:({data:e,payload:t,history:o,onChange:a,onClose:i,setLoading:r})=>{const l=U([e],50),[s,{loading:c}]=y(async()=>{const e=t.getContext();return{averagePrice:await u.controlViewService.getAveragePrice(e.symbol,{strategyName:e.strategyName,exchangeName:e.exchangeName}),symbol:e.symbol}},{onLoadStart:()=>r(!0),onLoadEnd:()=>r(!1)});return n(K,{Navigation:n(J,{hasPrev:!0,hasNext:!!s,labelPrev:"Close",onPrev:async()=>{await i()},onNext:async()=>{a({averagePrice:s.averagePrice,symbol:s.symbol}),await l(),o.replace("/form")}}),children:s?c?null:n(w,{payload:()=>({averagePrice:s.averagePrice,symbol:s.symbol}),slots:Q,fields:st}):null})},isActive:e=>!!le("/brief",e)},{id:"form",element:({data:e,history:t,formState:a,onChange:i})=>{const[r,l]=o.useState(e),s=U([e],50);return n(K,{Navigation:n(J,{hasPrev:!0,hasNext:!0,labelPrev:"Back",onPrev:async()=>{t.replace("/brief")},onNext:async()=>{r&&(i({cost:r.cost,note:r.note,symbol:a.data.brief.symbol}),await s(),t.replace("/submit"))}}),children:n(w,{payload:()=>({averagePrice:a.data.brief.averagePrice}),onChange:e=>l(e),slots:Q,fields:lt,sx:{pt:1}})})},isActive:e=>!!le("/form",e)},{id:"submit",element:({formState:e,payload:t,beginSave:a,setLoading:i})=>{const[r,l]=o.useState(pt),{cost:s,note:c,symbol:p}=o.useMemo(()=>{const{cost:t,note:o,symbol:a}=e.data.form;return{cost:t,note:o,symbol:a}},[e]);I(async()=>{i(!0);try{const e=t.getContext();await u.controlViewService.commitAverageBuy(e.symbol,{strategyName:e.strategyName,exchangeName:e.exchangeName},{cost:parseFloat(s||"0"),note:c||""}),l({success:!0,loading:!1,error:""})}catch(e){l({success:!1,loading:!1,error:ne(e)})}finally{i(!1)}});return n(K,{Navigation:n(J,{hasNext:r.success||!!r.error,labelNext:"Close",onNext:async()=>{await a()}}),children:n(S,{p:1,children:r.error?n(ct,{type:"error",title:"Averaging Error",description:r.error,amount:`${X(parseFloat(s||"0"))}$`,symbol:p}):r.loading?n(ct,{type:"loading",title:"Averaging Position",description:"Please wait. Your operation is being processed...",amount:`${X(parseFloat(s||"0"))}$`,symbol:p}):n(ct,{type:"success",title:"Position Averaged",description:"Averaging has been scheduled successfully. Waiting for the order to be executed on the exchange",amount:`${X(parseFloat(s||"0"))}$`,symbol:p})})})},isActive:e=>!!le("/submit",e)}],mt=[{id:"brief",label:"Briefing"},{id:"form",label:"Input"},{id:"submit",label:"Averaging"}],yt="/brief",ut=de(),gt=[{type:f.Center,child:{type:f.Group,desktopColumns:"6",tabletColumns:"12",phoneColumns:"12",fields:[{type:f.Typography,style:{opacity:.5},fieldBottomMargin:"3",typoVariant:"h6",placeholder:"Close Position"},{type:f.Outline,fields:[{type:f.Text,name:"note",title:"Note",placeholder:"Reason for closing the position"}]},{type:f.Typography,fieldBottomMargin:"3",typoVariant:"caption",sx:{pt:2,opacity:.5,fontSize:12},placeholder:`${k.bullet} After pressing the Next button, the closing will be performed IMMEDIATELY`}]}}],ht=[{type:f.Center,child:{type:f.Group,desktopColumns:"6",tabletColumns:"12",phoneColumns:"12",fields:[{type:f.Typography,style:{opacity:.5},fieldBottomMargin:"3",typoVariant:"h6",placeholder:"Close Position"},{type:f.Outline,fields:[{type:f.Text,name:"symbol",compute:({},e)=>e.symbol,title:"Symbol"},{type:f.Text,name:"price",inputPattern:"[0-9.]*",inputMode:"decimal",inputType:"tel",compute:({},e)=>`${X(e.averagePrice)}$`,title:"Coin Price",placeholder:"000000.00",inputFormatterSymbol:"0",inputFormatterAllowed:/[0-9.]/}]},{type:f.Typography,fieldBottomMargin:"3",typoVariant:"caption",sx:{pt:2,opacity:.5,fontSize:12},placeholder:`${k.bullet} Carefully verify that this is the coin you want to close the position on. Rely on the symbol AND THE PRICE`}]}}],bt=({type:e,title:t,description:o,amount:a,price:i,symbol:r})=>{const l=Z(),s="loading"===e?{color:l.palette.warning.main,bgColor:te(l.palette.warning.main,.1),icon:n(oe,{size:24,color:"warning"}),chipColor:"warning"}:"success"===e?{color:l.palette.success.main,bgColor:te(l.palette.success.main,.1),icon:n($e,{}),chipColor:"success"}:"error"===e?{color:l.palette.error.main,bgColor:te(l.palette.error.main,.1),icon:n(ae,{}),chipColor:"error"}:"warning"===e?{color:l.palette.warning.main,bgColor:te(l.palette.warning.main,.1),icon:n(ie,{}),chipColor:"warning"}:"info"===e?{color:l.palette.info.main,bgColor:te(l.palette.info.main,.1),icon:n(re,{}),chipColor:"info"}:{color:l.palette.grey[500],bgColor:te(l.palette.grey[500],.1),icon:n(re,{}),chipColor:"default"};return n(Pe,{elevation:0,sx:{backgroundColor:s.bgColor,border:`1px solid ${te(s.color,.3)}`,borderRadius:2,transition:"all 0.3s ease"},children:n(Me,{sx:{p:3},children:[n(S,{sx:{display:"flex",alignItems:"center",gap:2,mb:2},children:[n(S,{sx:{color:s.color,display:"flex",alignItems:"center"},children:s.icon}),n(x,{variant:"h6",sx:{color:s.color,fontWeight:600,flex:1},children:t}),r&&n(P,{label:r,size:"small",color:s.chipColor,variant:"outlined",icon:n(ee,{})})]}),o&&n(x,{variant:"body2",color:"text.secondary",sx:{mb:2,lineHeight:1.5},children:o}),(a||i)&&n(S,{sx:{display:"flex",gap:3,mt:2,p:2,backgroundColor:te(l.palette.background.paper,.6),borderRadius:1,border:`1px solid ${te(s.color,.1)}`},children:[a&&n(S,{children:[n(x,{variant:"caption",color:"text.secondary",children:"Amount"}),n(x,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:a})]}),i&&n(S,{children:[n(x,{variant:"caption",color:"text.secondary",children:"Price"}),n(x,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:i})]})]})]})})},ft={success:!1,loading:!0,error:""},vt=[{id:"brief",element:({data:e,payload:t,history:o,onChange:a,onClose:i,setLoading:r})=>{const l=U([e],50),[s,{loading:c}]=y(async()=>{const e=t.getContext();return{averagePrice:await u.controlViewService.getAveragePrice(e.symbol,{strategyName:e.strategyName,exchangeName:e.exchangeName}),symbol:e.symbol}},{onLoadStart:()=>r(!0),onLoadEnd:()=>r(!1)});return n(K,{Navigation:n(J,{hasPrev:!0,hasNext:!!s,labelPrev:"Close",onPrev:async()=>{await i()},onNext:async()=>{a({averagePrice:s.averagePrice,symbol:s.symbol}),await l(),o.replace("/form")}}),children:s?c?null:n(w,{payload:()=>({averagePrice:s.averagePrice,symbol:s.symbol}),slots:Q,fields:ht}):null})},isActive:e=>!!le("/brief",e)},{id:"form",element:({data:e,history:t,formState:a,onChange:i})=>{const[r,l]=o.useState(e),s=U([e],50);return n(K,{Navigation:n(J,{hasPrev:!0,hasNext:!0,labelPrev:"Back",onPrev:async()=>{t.replace("/brief")},onNext:async()=>{r&&(i({note:r.note,symbol:a.data.brief.symbol}),await s(),t.replace("/submit"))}}),children:n(w,{payload:()=>({averagePrice:a.data.brief.averagePrice}),onChange:e=>l(e),slots:Q,fields:gt,sx:{pt:1}})})},isActive:e=>!!le("/form",e)},{id:"submit",element:({formState:e,payload:t,beginSave:a,setLoading:i})=>{const[r,l]=o.useState(ft),{note:s,symbol:c}=o.useMemo(()=>{const{note:t,symbol:o}=e.data.form;return{note:t,symbol:o}},[e]);I(async()=>{i(!0);try{const e=t.getContext();await u.controlViewService.commitClosePending(e.symbol,{strategyName:e.strategyName,exchangeName:e.exchangeName},{note:s||""}),l({success:!0,loading:!1,error:""})}catch(e){l({success:!1,loading:!1,error:ne(e)})}finally{i(!1)}});return n(K,{Navigation:n(J,{hasNext:r.success||!!r.error,labelNext:"Close",onNext:async()=>{await a()}}),children:n(S,{p:1,children:r.error?n(bt,{type:"error",title:"Position Closing Error",description:r.error,symbol:c}):r.loading?n(bt,{type:"loading",title:"Closing Position",description:"Please wait. Your operation is being processed...",symbol:c}):n(bt,{type:"success",title:"Position Closed",description:"Closing has been scheduled successfully. Waiting for the order to be executed on the exchange",symbol:c})})})},isActive:e=>!!le("/submit",e)}],xt=[{id:"brief",label:"Briefing"},{id:"form",label:"Input"},{id:"submit",label:"Closing"}],Ct="/brief",wt=de(),St=[{type:f.Center,child:{type:f.Group,desktopColumns:"6",tabletColumns:"12",phoneColumns:"12",fields:[{type:f.Typography,style:{opacity:.5},fieldBottomMargin:"3",typoVariant:"h6",placeholder:"Move to Breakeven"},{type:f.Outline,fields:[{type:f.Typography,typoVariant:"body1",placeholder:"The stop-loss will be moved to the breakeven point of the current position. No additional input is required."}]},{type:f.Typography,fieldBottomMargin:"3",typoVariant:"caption",sx:{pt:2,opacity:.5,fontSize:12},placeholder:`${k.bullet} After pressing the Next button, the move to breakeven will be performed IMMEDIATELY`}]}}],Nt=[{type:f.Center,child:{type:f.Group,desktopColumns:"6",tabletColumns:"12",phoneColumns:"12",fields:[{type:f.Typography,style:{opacity:.5},fieldBottomMargin:"3",typoVariant:"h6",placeholder:"Move to Breakeven"},{type:f.Outline,fields:[{type:f.Text,name:"symbol",compute:({},e)=>e.symbol,title:"Symbol"},{type:f.Text,name:"price",inputPattern:"[0-9.]*",inputMode:"decimal",inputType:"tel",compute:({},e)=>`${X(e.averagePrice)}$`,title:"Coin Price",placeholder:"000000.00",inputFormatterSymbol:"0",inputFormatterAllowed:/[0-9.]/}]},{type:f.Typography,fieldBottomMargin:"3",typoVariant:"caption",sx:{pt:2,opacity:.5,fontSize:12},placeholder:`${k.bullet} Carefully verify that this is the coin whose stop you want to move to breakeven. Rely on the symbol AND THE PRICE`}]}}],Pt=({type:e,title:t,description:o,amount:a,price:i,symbol:r})=>{const l=Z(),s="loading"===e?{color:l.palette.warning.main,bgColor:te(l.palette.warning.main,.1),icon:n(oe,{size:24,color:"warning"}),chipColor:"warning"}:"success"===e?{color:l.palette.success.main,bgColor:te(l.palette.success.main,.1),icon:n($e,{}),chipColor:"success"}:"error"===e?{color:l.palette.error.main,bgColor:te(l.palette.error.main,.1),icon:n(ae,{}),chipColor:"error"}:"warning"===e?{color:l.palette.warning.main,bgColor:te(l.palette.warning.main,.1),icon:n(ie,{}),chipColor:"warning"}:"info"===e?{color:l.palette.info.main,bgColor:te(l.palette.info.main,.1),icon:n(re,{}),chipColor:"info"}:{color:l.palette.grey[500],bgColor:te(l.palette.grey[500],.1),icon:n(re,{}),chipColor:"default"};return n(Pe,{elevation:0,sx:{backgroundColor:s.bgColor,border:`1px solid ${te(s.color,.3)}`,borderRadius:2,transition:"all 0.3s ease"},children:n(Me,{sx:{p:3},children:[n(S,{sx:{display:"flex",alignItems:"center",gap:2,mb:2},children:[n(S,{sx:{color:s.color,display:"flex",alignItems:"center"},children:s.icon}),n(x,{variant:"h6",sx:{color:s.color,fontWeight:600,flex:1},children:t}),r&&n(P,{label:r,size:"small",color:s.chipColor,variant:"outlined",icon:n(ee,{})})]}),o&&n(x,{variant:"body2",color:"text.secondary",sx:{mb:2,lineHeight:1.5},children:o}),(a||i)&&n(S,{sx:{display:"flex",gap:3,mt:2,p:2,backgroundColor:te(l.palette.background.paper,.6),borderRadius:1,border:`1px solid ${te(s.color,.1)}`},children:[a&&n(S,{children:[n(x,{variant:"caption",color:"text.secondary",children:"Amount"}),n(x,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:a})]}),i&&n(S,{children:[n(x,{variant:"caption",color:"text.secondary",children:"Price"}),n(x,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:i})]})]})]})})},kt={success:!1,loading:!0,error:""},At=[{id:"brief",element:({data:e,payload:t,history:o,onChange:a,onClose:i,setLoading:r})=>{const l=U([e],50),[s,{loading:c}]=y(async()=>{const e=t.getContext();return{averagePrice:await u.controlViewService.getAveragePrice(e.symbol,{strategyName:e.strategyName,exchangeName:e.exchangeName}),symbol:e.symbol}},{onLoadStart:()=>r(!0),onLoadEnd:()=>r(!1)});return n(K,{Navigation:n(J,{hasPrev:!0,hasNext:!!s,labelPrev:"Close",onPrev:async()=>{await i()},onNext:async()=>{a({averagePrice:s.averagePrice,symbol:s.symbol}),await l(),o.replace("/form")}}),children:s?c?null:n(w,{payload:()=>({averagePrice:s.averagePrice,symbol:s.symbol}),slots:Q,fields:Nt}):null})},isActive:e=>!!le("/brief",e)},{id:"form",element:({data:e,history:t,formState:o,onChange:a})=>{const i=U([e],50);return n(K,{Navigation:n(J,{hasPrev:!0,hasNext:!0,labelPrev:"Back",onPrev:async()=>{t.replace("/brief")},onNext:async()=>{a({symbol:o.data.brief.symbol}),await i(),t.replace("/submit")}}),children:n(w,{payload:()=>({averagePrice:o.data.brief.averagePrice}),slots:Q,fields:St,sx:{pt:1}})})},isActive:e=>!!le("/form",e)},{id:"submit",element:({formState:e,payload:t,beginSave:a,setLoading:i})=>{const[r,l]=o.useState(kt),{symbol:s}=o.useMemo(()=>{const{symbol:t}=e.data.form;return{symbol:t}},[e]);I(async()=>{i(!0);try{const e=t.getContext();await u.controlViewService.commitBreakeven(e.symbol,{strategyName:e.strategyName,exchangeName:e.exchangeName}),l({success:!0,loading:!1,error:""})}catch(e){l({success:!1,loading:!1,error:ne(e)})}finally{i(!1)}});return n(K,{Navigation:n(J,{hasNext:r.success||!!r.error,labelNext:"Close",onNext:async()=>{await a()}}),children:n(S,{p:1,children:r.error?n(Pt,{type:"error",title:"Breakeven Error",description:r.error,symbol:s}):r.loading?n(Pt,{type:"loading",title:"Moving to Breakeven",description:"Please wait. Your operation is being processed...",symbol:s}):n(Pt,{type:"success",title:"Breakeven Set",description:"Breakeven has been scheduled successfully. Waiting for the order to be executed on the exchange",symbol:s})})})},isActive:e=>!!le("/submit",e)}],Lt=[{id:"brief",label:"Briefing"},{id:"form",label:"Input"},{id:"submit",label:"Breakeven"}],Mt="/brief",Tt=de(),$t=e=>"pnl"===e?"P&L":e,Bt=[{type:h.Link,action:"back-action",label:n(ve,{sx:{display:"block"}})},{type:h.Link,action:"back-action",label:"Main"},{type:h.Link,action:"back-action",label:"Status"},{type:h.Link,action:"back-action",compute:e=>e?`${String(e.symbol).toUpperCase()} (${e.strategyName})`:"Live"},{type:h.Link,action:"back-action",label:"Manual Control"},{type:h.Button,action:"update-now",label:"Refresh",icon:fe}],Rt=[{action:"download-action",label:"Download",icon:()=>n(v,{icon:D,color:"#4caf50"})},{divider:!0},{action:"update-now",label:"Refresh",icon:()=>n(v,{icon:fe,color:"#4caf50"})}],Ft=[{id:"control",element:({params:e})=>{const[t]=y(async()=>{const t=await u.statusViewService.getStatusMap();return R.get(t,e.id,null)},{onLoadStart:()=>u.layoutService.setAppbarLoader(!0),onLoadEnd:()=>u.layoutService.setAppbarLoader(!1),deps:[e.id]}),[o,{loading:a,execute:i}]=y(async()=>t?await u.controlViewService.getStrategyStatus(t.symbol,{strategyName:t.strategyName,exchangeName:t.exchangeName}):null,{onLoadStart:()=>u.layoutService.setAppbarLoader(!0),onLoadEnd:()=>u.layoutService.setAppbarLoader(!1),deps:[t]}),r=me(t),{pickData:l,render:s}=(({payload:e})=>{const{pickData:t,render:o}=se({history:nt,animation:"none",title:"Open Position",AfterTitle:({onClose:e})=>n(A,{direction:"row",gap:1,children:n(pe,{size:"small",onClick:e,children:n(Y,{})})}),mapPayload:()=>e,pathname:rt,sizeRequest:ce,routes:at,steps:it,onSubmit:async t=>(t&&await e.reloadSubject.next(),!0)});return{pickData:()=>{nt.push(rt),t()},render:o}})({payload:{getContext:()=>r.current,reloadSubject:Ce}}),{pickData:c,render:d}=(({payload:e})=>{const{pickData:t,render:o}=se({history:ut,animation:"none",title:"Average Position",AfterTitle:({onClose:e})=>n(A,{direction:"row",gap:1,children:n(pe,{size:"small",onClick:e,children:n(Y,{})})}),mapPayload:()=>e,pathname:yt,sizeRequest:ce,routes:dt,steps:mt,onSubmit:async t=>(t&&await e.reloadSubject.next(),!0)});return{pickData:()=>{ut.push(yt),t()},render:o}})({payload:{getContext:()=>r.current,reloadSubject:Ce}}),{pickData:m,render:h}=(({payload:e})=>{const{pickData:t,render:o}=se({history:wt,animation:"none",title:"Close Position",AfterTitle:({onClose:e})=>n(A,{direction:"row",gap:1,children:n(pe,{size:"small",onClick:e,children:n(Y,{})})}),mapPayload:()=>e,pathname:Ct,sizeRequest:ce,routes:vt,steps:xt,onSubmit:async t=>(t&&await e.reloadSubject.next(),!0)});return{pickData:()=>{wt.push(Ct),t()},render:o}})({payload:{getContext:()=>r.current,reloadSubject:Ce}}),{pickData:b,render:f}=(({payload:e})=>{const{pickData:t,render:o}=se({history:Tt,animation:"none",title:"Move to Breakeven",AfterTitle:({onClose:e})=>n(A,{direction:"row",gap:1,children:n(pe,{size:"small",onClick:e,children:n(Y,{})})}),mapPayload:()=>e,pathname:Mt,sizeRequest:ce,routes:At,steps:Lt,onSubmit:async t=>(t&&await e.reloadSubject.next(),!0)});return{pickData:()=>{Tt.push(Mt),t()},render:o}})({payload:{getContext:()=>r.current,reloadSubject:Ce}});I(Ce.subscribe(i)),I(Ue.subscribe(l)),I(Ye.subscribe(c)),I(Qe.subscribe(m)),I(Je.subscribe(b));const v=F(async()=>{if(!o)return;const e=new Blob([JSON.stringify(o,null,2)],{type:"application/json"}),t=URL.createObjectURL(e);u.layoutService.downloadFile(t,`manual_control_${Date.now()}.json`)});return n(be,{children:[n(g,{items:Bt,actions:Rt,payload:t,onAction:async t=>{"back-action"===t&&u.routerService.push(`/status/${e.id}`),"download-action"===t&&v(),"update-now"===t&&await Ce.next()}}),o?a?null:n(ye,{component:p,withExpandAll:!0,sx:{p:1,minHeight:"calc(100dvh - 175px)"},payload:t,formatSearch:$t,AfterSearch:Xe,data:o}):null,n(S,{sx:{paddingBottom:"24px"}}),n(xe,{}),s(),d(),h(),f()]})},isActive:e=>ge(["/status/:id/control"],e)},{id:"status",element:({params:e})=>{const[t]=y(async()=>{const t=await u.statusViewService.getStatusMap();return R.get(t,e.id,null)},{onLoadStart:()=>u.layoutService.setAppbarLoader(!0),onLoadEnd:()=>u.layoutService.setAppbarLoader(!1),deps:[e.id]}),[o,{loading:a,execute:i}]=y(async()=>await u.statusViewService.getStatusOne(e.id),{onLoadStart:()=>u.layoutService.setAppbarLoader(!0),onLoadEnd:()=>u.layoutService.setAppbarLoader(!1),deps:[e.id]}),r=F(async()=>{if(!o)return;const e=new Blob([JSON.stringify(o,null,2)],{type:"application/json"}),t=URL.createObjectURL(e);u.layoutService.downloadFile(t,`status_${Date.now()}.json`)}),l=F(async()=>{if(!o)return;const e=u.markdownHelperService.buildMarkdownFromFields(V,o);await z(e)});I(()=>_e.subscribe(i));return n(be,{children:[n(g,{items:Ge,actions:qe,payload:t,onAction:async t=>{"back-action"===t&&(async()=>{1!==(await u.statusViewService.getStatusList()).length?u.routerService.push("/status"):u.routerService.push("/")})(),"control-action"===t&&u.routerService.push(`/status/${e.id}/control`),"update-now"===t&&await _e.next(),"download-action"===t&&await r(),"print-action"===t&&await l()}}),a?n(C,{children:n(x,{variant:"h6",sx:{opacity:.5},children:"Loading..."})}):o?n(N,{children:[n(w,{handler:o,fields:j}),n(S,{paddingBottom:"24px"})]}):n(C,{children:n(x,{variant:"h6",sx:{opacity:.5},children:"No pending signal"})}),n(xe,{})]})},isActive:e=>ge(["/status/:id"],e)},{id:"main",element:()=>{const{classes:e}=Oe(),{reloadTrigger:t,doReload:o}=m();y(async()=>{const e=await u.statusViewService.getStatusList();if(1===e.length){const[{id:t}]=e;u.routerService.push(`/status/${t}`)}},{onLoadStart:()=>u.layoutService.setAppbarLoader(!0),onLoadEnd:()=>u.layoutService.setAppbarLoader(!1),deps:[t]});const[a,{loading:i}]=y(async()=>await(async()=>{const[e,t]=await Promise.all([u.symbolGlobalService.getSymbolMap(),u.statusViewService.getStatusList()]);if(!t||0===t.length)return[{type:f.Typography,typoVariant:"h6",placeholder:"Listening for a pending signal...",sx:{textAlign:"center",opacity:.5,mt:4}}];const o={};t.forEach(t=>{const a=e[t.symbol],i=t.strategyName;o[i]||(o[i]=[]),o[i].push({symbol:t.symbol,label:(null==a?void 0:a.displayName)||t.symbol,color:(null==a?void 0:a.color)||"#ccc",to:t.id})});const a=Object.entries(o).sort(([,e],[,t])=>t.length-e.length),i=[],r=[],n=[];return a.forEach(([e,t],o)=>{const a=We(e,t);o%2==0?i.push(a):r.push(a),n.push(a)}),[{type:f.Group,columns:"6",className:"tabletLeftColumn",phoneHidden:!0,desktopHidden:!0,fields:i},{type:f.Group,columns:"6",className:"tabletRightColumn",phoneHidden:!0,desktopHidden:!0,fields:r},{type:f.Group,columns:"12",className:"wideColumn",tabletHidden:!0,fields:n}]})(),{onLoadStart:()=>u.layoutService.setAppbarLoader(!0),onLoadEnd:()=>u.layoutService.setAppbarLoader(!1),deps:[t]});return n(be,{children:[n(g,{items:je,actions:He,onAction:e=>{"back-action"===e&&u.routerService.push("/"),"update-now"===e&&o()}}),i||!a?n(C,{children:n(x,{variant:"h6",sx:{opacity:.5},children:"Loading..."})}):a.length?n(N,{children:[n(w,{className:e.root,fields:a},t),n(S,{paddingBottom:"24px"})]}):n(C,{children:n(x,{variant:"h6",sx:{opacity:.5},children:"No pending signals"})})]})},isActive:e=>ge(["/status"],e)}],Vt=({id:e})=>n(ue,{history:u.routerService,onLoadStart:()=>u.layoutService.setAppbarLoader(!0),onLoadEnd:()=>u.layoutService.setAppbarLoader(!1),routes:Ft,params:{id:e}});export{Vt as StatusPage,Vt as default};
1
+ import{g as e,a as t,r as o,u as a,_ as i,d as r,f as n,e as l,k as s,s as c,P as p,b as d,Q as m,x as y,i as u,O as g,R as h,p as b,a2 as f,Z as v,T as x,b2 as C,W as w,B as S,F as N,a3 as P,E as k,A,a5 as L,l as M,n as T,a4 as $,a6 as B,ai as R,b3 as F,b4 as V,w as z,X as I,a8 as E,b5 as O,D,b6 as j,b7 as H,ag as W,V as G,N as q,a1 as _,b8 as U,ad as Y,b9 as Q,ba as J,bb as K,J as X,bc as Z,aX as ee,ah as te,bd as oe,aQ as ae,aO as ie,a$ as re,be as ne,bf as le,bg as se,bh as ce,I as pe,av as de,al as me,bi as ye,aj as ue}from"./index-Cgx-XS5d.js";import{h as ge}from"./hasRouteMatch-D81_5Zia.js";import{I as he}from"./IconPhoto-CTTANJQT.js";import{C as be,R as fe}from"./Refresh-BrRXF_OY.js";import{K as ve}from"./KeyboardArrowLeft-vg5fS39b.js";import{B as xe}from"./Background-C0snDG25.js";import{r as Ce}from"./emitters-CzPcqIDz.js";function we(t){return e("MuiCard",t)}t("MuiCard",["root"]);const Se=["className","raised"],Ne=c(p,{name:"MuiCard",slot:"Root",overridesResolver:(e,t)=>t.root})(()=>({overflow:"hidden"})),Pe=o.forwardRef(function(e,t){const o=a({props:e,name:"MuiCard"}),{className:c,raised:p=!1}=o,d=i(o,Se),m=r({},o,{raised:p}),y=(e=>{const{classes:t}=e;return s({root:["root"]},we,t)})(m);return n(Ne,r({className:l(y.root,c),elevation:p?8:void 0,ref:t,ownerState:m},d))});function ke(t){return e("MuiCardContent",t)}t("MuiCardContent",["root"]);const Ae=["className","component"],Le=c("div",{name:"MuiCardContent",slot:"Root",overridesResolver:(e,t)=>t.root})(()=>({padding:16,"&:last-child":{paddingBottom:24}})),Me=o.forwardRef(function(e,t){const o=a({props:e,name:"MuiCardContent"}),{className:c,component:p="div"}=o,d=i(o,Ae),m=r({},o,{component:p}),y=(e=>{const{classes:t}=e;return s({root:["root"]},ke,t)})(m);return n(Le,r({as:p,className:l(y.root,c),ownerState:m,ref:t},d))}),Te=d(n("path",{d:"M18.21 9.21C15.93 10.78 13.45 13.3 13 17h2v2H9v-2h2c-.5-4.5-4.37-8-9-8V7c4.39 0 8.22 2.55 10 6.3 1.13-2.43 2.99-4.25 4.78-5.52L14 5h7v7l-2.79-2.79z"}),"AirlineStops"),$e=d(n("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"}),"CheckCircle"),Be=d(n("path",{d:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"}),"CloseOutlined"),Re=d(n("path",{d:"M12 2 4 5v6.09c0 5.05 3.41 9.76 8 10.91 4.59-1.15 8-5.86 8-10.91V5l-8-3zm6 9.09c0 4-2.55 7.7-6 8.83-3.45-1.13-6-4.82-6-8.83v-4.7l6-2.25 6 2.25v4.7z"}),"ShieldOutlined"),Fe=d(n("path",{d:"m16 6 2.29 2.29-4.88 4.88-4-4L2 16.59 3.41 18l6-6 4 4 6.3-6.29L22 12V6h-6z"}),"TrendingUpOutlined"),Ve=d(n("path",{d:"M21 6H3c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm-10 7H8v3H6v-3H3v-2h3V8h2v3h3v2zm4.5 2c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5zm4-3c-.83 0-1.5-.67-1.5-1.5S18.67 9 19.5 9s1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"}),"VideogameAsset"),ze="backtest-kit__groupHeader",Ie="backtest-kit__groupRoot",Ee="backtest-kit__symbolImage",Oe=b()({root:{[`& .${Ie}:hover .${ze}`]:{opacity:"1 !important"}}});function De(e){return B(e,"#000000")>B(e,"#FFFFFF")}const je=[{type:h.Link,action:"back-action",label:n(ve,{sx:{display:"block"}})},{type:h.Link,action:"back-action",label:"Main"},{type:h.Link,action:"back-action",label:"Status"}],He=[{action:"update-now",label:"Refresh",icon:()=>n(v,{icon:fe,color:"#4caf50"})}],We=(e,t)=>({type:f.Group,className:Ie,sx:{p:2},tabletColumns:"12",desktopColumns:"3",fields:[{type:f.Component,className:ze,style:{transition:"opacity 500ms",opacity:.5},element:()=>n(A,{direction:"row",children:[n(P,{variant:"outlined",size:"small",color:"info",label:`${k.bullet} ${e}`,sx:{mb:1,pr:.5,fontSize:"14px",background:"white",cursor:"not-allowed"}}),n(S,{flex:1})]})},{type:f.Group,fields:t.map(({symbol:e,label:t,to:o,color:a})=>((e,t,o,a)=>({type:f.Component,desktopColumns:"6",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:()=>n($,{component:L,onClick:()=>{u.routerService.push(`/status/${t}`)},sx:{width:"100%",background:a,color:"white",fontWeight:"bold",fontSize:"14px",height:"75px",minHeight:"75px",textWrap:"wrap",padding:"16px",[`& .${Ee}`]:{transition:"filter 500ms"},"&:hover":{background:()=>De(a)?M(a,.33):T(a,.33),[`& .${Ee}`]:{transition:"filter 500ms",filter:De(a)?"brightness(0.7) contrast(1.2)":"brightness(1.3) contrast(0.5)"}},transition:"background 500ms"},startIcon:n(he,{className:Ee,symbol:e}),children:n(S,{sx:{overflow:"hidden",textOverflow:"ellipsis",width:"75px"},children:o})})}))(e,o,t,a))}]}),Ge=[{type:h.Link,action:"back-action",label:n(ve,{sx:{display:"block"}})},{type:h.Link,action:"back-action",label:"Main"},{type:h.Link,action:"back-action",label:"Status"},{type:h.Link,action:"back-action",compute:e=>e?`${String(e.symbol).toUpperCase()} (${e.strategyName})`:"Live"},{type:h.Button,action:"control-action",label:"Manual Control",icon:Ve},{type:h.Fab,action:"print-action",label:"Print",icon:O},{type:h.Fab,action:"update-now",label:"Refresh",icon:fe}],qe=[{action:"print-action",label:"Print",icon:()=>n(v,{icon:O,color:"#4caf50"})},{action:"download-action",label:"Download",icon:()=>n(v,{icon:D,color:"#4caf50"})},{divider:!0},{action:"update-now",label:"Refresh",icon:()=>n(v,{icon:fe,color:"#4caf50"})}],_e=new E,Ue=new E,Ye=new E,Qe=new E,Je=new E,Ke=_.createLoader(12),Xe=({payload:e})=>n(S,{sx:{mb:1,minHeight:48},children:n(H,{sx:{height:"100%",minHeight:48},hideOverflowY:!0,children:n(A,{direction:"row",gap:1,sx:{pointerEvents:"all"},children:[n(W,{startIcon:n(Te,{}),onClick:async()=>await Ue.next(),color:"success",sx:{whiteSpace:"nowrap"},children:"Open Position"}),n(W,{startIcon:n(Fe,{}),onClick:async()=>await Ye.next(),color:"warning",sx:{whiteSpace:"nowrap"},children:"Commit Averaging"}),n(W,{startIcon:n(Re,{}),onClick:async()=>await Je.next(),sx:{whiteSpace:"nowrap"},children:"Commit Breakeven"}),n(S,{flex:1}),n(G,{Loader:Ke,deps:[e.symbol,e.exchangeName,e.strategyName],reloadSubject:Ce,children:async()=>{const t=await u.controlViewService.getAveragePrice(e.symbol,{exchangeName:e.exchangeName,strategyName:e.strategyName}),o=Number(t);return n(x,{height:"100%",display:"flex",alignItems:"center",whiteSpace:"nowrap",mr:1,children:["Avg price ",e.symbol,":",k.nbsp,n("b",{children:`${o.toFixed(q(o))}$`})]})}}),n(W,{startIcon:n(Be,{}),onClick:async()=>await Qe.next(),sx:{whiteSpace:"nowrap"},color:"error",children:"Close Position"})]})})}),Ze=[{type:f.Center,child:{type:f.Group,desktopColumns:"6",tabletColumns:"12",phoneColumns:"12",fields:[{type:f.Typography,style:{opacity:.5},fieldBottomMargin:"3",typoVariant:"h6",placeholder:"Open Position"},{type:f.Outline,fields:[{type:f.Combo,name:"position",title:"Direction",placeholder:"Select direction",itemList:["long","short"],validation:{required:!0},defaultValue:"long"},{type:f.Text,name:"cost",inputPattern:"[0-9]*",inputMode:"numeric",inputType:"tel",trailingIcon:Y,trailingIconClick:(e,{},{},t)=>{t("")},validation:{required:!0},title:"Amount USDT",placeholder:"00000",inputFormatterSymbol:"0",inputFormatterAllowed:/[0-9]/,defaultValue:"100"},{type:f.Text,outlined:!0,name:"quantity",sx:{cursor:"not-allowed","& *":{cursor:"not-allowed"}},title:"Coin Quantity",placeholder:"0.00",compute:(e,t)=>{const o=parseFloat(e.cost||"0"),a=parseFloat(t.averagePrice||"0");return o&&a?(o/a).toFixed(6):"0"},inputFormatterSymbol:"0",inputFormatterAllowed:/[0-9.]/,readonly:!0},{type:f.Text,name:"note",title:"Note",placeholder:"Reason for opening the position"}]},{type:f.Typography,fieldBottomMargin:"3",typoVariant:"caption",sx:{pt:2,opacity:.5,fontSize:12},placeholder:`${k.bullet} After pressing the Next button, the position will be opened IMMEDIATELY`}]}}],et=[{type:f.Center,child:{type:f.Group,desktopColumns:"6",tabletColumns:"12",phoneColumns:"12",fields:[{type:f.Typography,style:{opacity:.5},fieldBottomMargin:"3",typoVariant:"h6",placeholder:"Open Position"},{type:f.Outline,fields:[{type:f.Text,name:"symbol",compute:({},e)=>e.symbol,title:"Symbol"},{type:f.Text,name:"price",inputPattern:"[0-9.]*",inputMode:"decimal",inputType:"tel",compute:({},e)=>`${X(e.averagePrice)}$`,title:"Coin Price",placeholder:"000000.00",inputFormatterSymbol:"0",inputFormatterAllowed:/[0-9.]/}]},{type:f.Typography,fieldBottomMargin:"3",typoVariant:"caption",sx:{pt:2,opacity:.5,fontSize:12},placeholder:`${k.bullet} Carefully verify that this is the coin you want to open a position on. Rely on the symbol AND THE PRICE`}]}}],tt=({type:e,title:t,description:o,amount:a,price:i,symbol:r})=>{const l=Z(),s="loading"===e?{color:l.palette.warning.main,bgColor:te(l.palette.warning.main,.1),icon:n(oe,{size:24,color:"warning"}),chipColor:"warning"}:"success"===e?{color:l.palette.success.main,bgColor:te(l.palette.success.main,.1),icon:n($e,{}),chipColor:"success"}:"error"===e?{color:l.palette.error.main,bgColor:te(l.palette.error.main,.1),icon:n(ae,{}),chipColor:"error"}:"warning"===e?{color:l.palette.warning.main,bgColor:te(l.palette.warning.main,.1),icon:n(ie,{}),chipColor:"warning"}:"info"===e?{color:l.palette.info.main,bgColor:te(l.palette.info.main,.1),icon:n(re,{}),chipColor:"info"}:{color:l.palette.grey[500],bgColor:te(l.palette.grey[500],.1),icon:n(re,{}),chipColor:"default"};return n(Pe,{elevation:0,sx:{backgroundColor:s.bgColor,border:`1px solid ${te(s.color,.3)}`,borderRadius:2,transition:"all 0.3s ease"},children:n(Me,{sx:{p:3},children:[n(S,{sx:{display:"flex",alignItems:"center",gap:2,mb:2},children:[n(S,{sx:{color:s.color,display:"flex",alignItems:"center"},children:s.icon}),n(x,{variant:"h6",sx:{color:s.color,fontWeight:600,flex:1},children:t}),r&&n(P,{label:r,size:"small",color:s.chipColor,variant:"outlined",icon:n(ee,{})})]}),o&&n(x,{variant:"body2",color:"text.secondary",sx:{mb:2,lineHeight:1.5},children:o}),(a||i)&&n(S,{sx:{display:"flex",gap:3,mt:2,p:2,backgroundColor:te(l.palette.background.paper,.6),borderRadius:1,border:`1px solid ${te(s.color,.1)}`},children:[a&&n(S,{children:[n(x,{variant:"caption",color:"text.secondary",children:"Amount"}),n(x,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:a})]}),i&&n(S,{children:[n(x,{variant:"caption",color:"text.secondary",children:"Price"}),n(x,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:i})]})]})]})})},ot={success:!1,loading:!0,error:""},at=[{id:"brief",element:({data:e,payload:t,history:o,onChange:a,onClose:i,setLoading:r})=>{const l=U([e],50),[s,{loading:c}]=y(async()=>{const e=t.getContext();return{averagePrice:await u.controlViewService.getAveragePrice(e.symbol,{strategyName:e.strategyName,exchangeName:e.exchangeName}),symbol:e.symbol}},{onLoadStart:()=>r(!0),onLoadEnd:()=>r(!1)});return n(K,{Navigation:n(J,{hasPrev:!0,hasNext:!!s,labelPrev:"Close",onPrev:async()=>{await i()},onNext:async()=>{a({averagePrice:s.averagePrice,symbol:s.symbol}),await l(),o.replace("/form")}}),children:s?c?null:n(w,{payload:()=>({averagePrice:s.averagePrice,symbol:s.symbol}),slots:Q,fields:et}):null})},isActive:e=>!!le("/brief",e)},{id:"form",element:({data:e,history:t,formState:a,onChange:i})=>{const[r,l]=o.useState(e),s=U([e],50);return n(K,{Navigation:n(J,{hasPrev:!0,hasNext:!0,labelPrev:"Back",onPrev:async()=>{t.replace("/brief")},onNext:async()=>{r&&(i({position:r.position,cost:r.cost,note:r.note,symbol:a.data.brief.symbol}),await s(),t.replace("/submit"))}}),children:n(w,{payload:()=>({averagePrice:a.data.brief.averagePrice}),onChange:e=>l(e),slots:Q,fields:Ze,sx:{pt:1}})})},isActive:e=>!!le("/form",e)},{id:"submit",element:({formState:e,payload:t,beginSave:a,setLoading:i})=>{const[r,l]=o.useState(ot),{position:s,cost:c,note:p,symbol:d}=o.useMemo(()=>{const{position:t,cost:o,note:a,symbol:i}=e.data.form;return{position:t,cost:o,note:a,symbol:i}},[e]);I(async()=>{i(!0);try{const e=t.getContext();await u.controlViewService.commitOpenPending(e.symbol,{strategyName:e.strategyName,exchangeName:e.exchangeName},{position:s,cost:parseFloat(c||"0"),note:p||""}),l({success:!0,loading:!1,error:""})}catch(e){l({success:!1,loading:!1,error:ne(e)})}finally{i(!1)}});return n(K,{Navigation:n(J,{hasNext:r.success||!!r.error,labelNext:"Close",onNext:async()=>{await a()}}),children:n(S,{p:1,children:r.error?n(tt,{type:"error",title:"Position Opening Error",description:r.error,amount:`${X(parseFloat(c||"0"))}$`,symbol:d}):r.loading?n(tt,{type:"loading",title:"Opening Position",description:"Please wait. Your operation is being processed...",amount:`${X(parseFloat(c||"0"))}$`,symbol:d}):n(tt,{type:"success",title:"Position Opened",description:"Position has been scheduled successfully. Waiting for the order to be executed on the exchange",amount:`${X(parseFloat(c||"0"))}$`,symbol:d})})})},isActive:e=>!!le("/submit",e)}],it=[{id:"brief",label:"Briefing"},{id:"form",label:"Input"},{id:"submit",label:"Opening"}],rt="/brief",nt=de(),lt=[{type:f.Center,child:{type:f.Group,desktopColumns:"6",tabletColumns:"12",phoneColumns:"12",fields:[{type:f.Typography,style:{opacity:.5},fieldBottomMargin:"3",typoVariant:"h6",placeholder:"Average Position"},{type:f.Outline,fields:[{type:f.Text,name:"cost",inputPattern:"[0-9]*",inputMode:"numeric",inputType:"tel",trailingIcon:Y,trailingIconClick:(e,{},{},t)=>{t("")},validation:{required:!0},title:"Amount USDT",placeholder:"00000",inputFormatterSymbol:"0",inputFormatterAllowed:/[0-9]/,defaultValue:"100"},{type:f.Text,outlined:!0,name:"quantity",sx:{cursor:"not-allowed","& *":{cursor:"not-allowed"}},title:"Coin Quantity",placeholder:"0.00",compute:(e,t)=>{const o=parseFloat(e.cost||"0"),a=parseFloat(t.averagePrice||"0");return o&&a?(o/a).toFixed(6):"0"},inputFormatterSymbol:"0",inputFormatterAllowed:/[0-9.]/,readonly:!0},{type:f.Text,name:"note",title:"Note",placeholder:"Reason for averaging the position"}]},{type:f.Typography,fieldBottomMargin:"3",typoVariant:"caption",sx:{pt:2,opacity:.5,fontSize:12},placeholder:`${k.bullet} After pressing the Next button, the averaging will be performed IMMEDIATELY`}]}}],st=[{type:f.Center,child:{type:f.Group,desktopColumns:"6",tabletColumns:"12",phoneColumns:"12",fields:[{type:f.Typography,style:{opacity:.5},fieldBottomMargin:"3",typoVariant:"h6",placeholder:"Average Position"},{type:f.Outline,fields:[{type:f.Text,name:"symbol",compute:({},e)=>e.symbol,title:"Symbol"},{type:f.Text,name:"price",inputPattern:"[0-9.]*",inputMode:"decimal",inputType:"tel",compute:({},e)=>`${X(e.averagePrice)}$`,title:"Coin Price",placeholder:"000000.00",inputFormatterSymbol:"0",inputFormatterAllowed:/[0-9.]/}]},{type:f.Typography,fieldBottomMargin:"3",typoVariant:"caption",sx:{pt:2,opacity:.5,fontSize:12},placeholder:`${k.bullet} Carefully verify that this is the coin you want to average the position on. Rely on the symbol AND THE PRICE`}]}}],ct=({type:e,title:t,description:o,amount:a,price:i,symbol:r})=>{const l=Z(),s="loading"===e?{color:l.palette.warning.main,bgColor:te(l.palette.warning.main,.1),icon:n(oe,{size:24,color:"warning"}),chipColor:"warning"}:"success"===e?{color:l.palette.success.main,bgColor:te(l.palette.success.main,.1),icon:n($e,{}),chipColor:"success"}:"error"===e?{color:l.palette.error.main,bgColor:te(l.palette.error.main,.1),icon:n(ae,{}),chipColor:"error"}:"warning"===e?{color:l.palette.warning.main,bgColor:te(l.palette.warning.main,.1),icon:n(ie,{}),chipColor:"warning"}:"info"===e?{color:l.palette.info.main,bgColor:te(l.palette.info.main,.1),icon:n(re,{}),chipColor:"info"}:{color:l.palette.grey[500],bgColor:te(l.palette.grey[500],.1),icon:n(re,{}),chipColor:"default"};return n(Pe,{elevation:0,sx:{backgroundColor:s.bgColor,border:`1px solid ${te(s.color,.3)}`,borderRadius:2,transition:"all 0.3s ease"},children:n(Me,{sx:{p:3},children:[n(S,{sx:{display:"flex",alignItems:"center",gap:2,mb:2},children:[n(S,{sx:{color:s.color,display:"flex",alignItems:"center"},children:s.icon}),n(x,{variant:"h6",sx:{color:s.color,fontWeight:600,flex:1},children:t}),r&&n(P,{label:r,size:"small",color:s.chipColor,variant:"outlined",icon:n(ee,{})})]}),o&&n(x,{variant:"body2",color:"text.secondary",sx:{mb:2,lineHeight:1.5},children:o}),(a||i)&&n(S,{sx:{display:"flex",gap:3,mt:2,p:2,backgroundColor:te(l.palette.background.paper,.6),borderRadius:1,border:`1px solid ${te(s.color,.1)}`},children:[a&&n(S,{children:[n(x,{variant:"caption",color:"text.secondary",children:"Amount"}),n(x,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:a})]}),i&&n(S,{children:[n(x,{variant:"caption",color:"text.secondary",children:"Price"}),n(x,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:i})]})]})]})})},pt={success:!1,loading:!0,error:""},dt=[{id:"brief",element:({data:e,payload:t,history:o,onChange:a,onClose:i,setLoading:r})=>{const l=U([e],50),[s,{loading:c}]=y(async()=>{const e=t.getContext();return{averagePrice:await u.controlViewService.getAveragePrice(e.symbol,{strategyName:e.strategyName,exchangeName:e.exchangeName}),symbol:e.symbol}},{onLoadStart:()=>r(!0),onLoadEnd:()=>r(!1)});return n(K,{Navigation:n(J,{hasPrev:!0,hasNext:!!s,labelPrev:"Close",onPrev:async()=>{await i()},onNext:async()=>{a({averagePrice:s.averagePrice,symbol:s.symbol}),await l(),o.replace("/form")}}),children:s?c?null:n(w,{payload:()=>({averagePrice:s.averagePrice,symbol:s.symbol}),slots:Q,fields:st}):null})},isActive:e=>!!le("/brief",e)},{id:"form",element:({data:e,history:t,formState:a,onChange:i})=>{const[r,l]=o.useState(e),s=U([e],50);return n(K,{Navigation:n(J,{hasPrev:!0,hasNext:!0,labelPrev:"Back",onPrev:async()=>{t.replace("/brief")},onNext:async()=>{r&&(i({cost:r.cost,note:r.note,symbol:a.data.brief.symbol}),await s(),t.replace("/submit"))}}),children:n(w,{payload:()=>({averagePrice:a.data.brief.averagePrice}),onChange:e=>l(e),slots:Q,fields:lt,sx:{pt:1}})})},isActive:e=>!!le("/form",e)},{id:"submit",element:({formState:e,payload:t,beginSave:a,setLoading:i})=>{const[r,l]=o.useState(pt),{cost:s,note:c,symbol:p}=o.useMemo(()=>{const{cost:t,note:o,symbol:a}=e.data.form;return{cost:t,note:o,symbol:a}},[e]);I(async()=>{i(!0);try{const e=t.getContext();await u.controlViewService.commitAverageBuy(e.symbol,{strategyName:e.strategyName,exchangeName:e.exchangeName},{cost:parseFloat(s||"0"),note:c||""}),l({success:!0,loading:!1,error:""})}catch(e){l({success:!1,loading:!1,error:ne(e)})}finally{i(!1)}});return n(K,{Navigation:n(J,{hasNext:r.success||!!r.error,labelNext:"Close",onNext:async()=>{await a()}}),children:n(S,{p:1,children:r.error?n(ct,{type:"error",title:"Averaging Error",description:r.error,amount:`${X(parseFloat(s||"0"))}$`,symbol:p}):r.loading?n(ct,{type:"loading",title:"Averaging Position",description:"Please wait. Your operation is being processed...",amount:`${X(parseFloat(s||"0"))}$`,symbol:p}):n(ct,{type:"success",title:"Position Averaged",description:"Averaging has been scheduled successfully. Waiting for the order to be executed on the exchange",amount:`${X(parseFloat(s||"0"))}$`,symbol:p})})})},isActive:e=>!!le("/submit",e)}],mt=[{id:"brief",label:"Briefing"},{id:"form",label:"Input"},{id:"submit",label:"Averaging"}],yt="/brief",ut=de(),gt=[{type:f.Center,child:{type:f.Group,desktopColumns:"6",tabletColumns:"12",phoneColumns:"12",fields:[{type:f.Typography,style:{opacity:.5},fieldBottomMargin:"3",typoVariant:"h6",placeholder:"Close Position"},{type:f.Outline,fields:[{type:f.Text,name:"note",title:"Note",placeholder:"Reason for closing the position"}]},{type:f.Typography,fieldBottomMargin:"3",typoVariant:"caption",sx:{pt:2,opacity:.5,fontSize:12},placeholder:`${k.bullet} After pressing the Next button, the closing will be performed IMMEDIATELY`}]}}],ht=[{type:f.Center,child:{type:f.Group,desktopColumns:"6",tabletColumns:"12",phoneColumns:"12",fields:[{type:f.Typography,style:{opacity:.5},fieldBottomMargin:"3",typoVariant:"h6",placeholder:"Close Position"},{type:f.Outline,fields:[{type:f.Text,name:"symbol",compute:({},e)=>e.symbol,title:"Symbol"},{type:f.Text,name:"price",inputPattern:"[0-9.]*",inputMode:"decimal",inputType:"tel",compute:({},e)=>`${X(e.averagePrice)}$`,title:"Coin Price",placeholder:"000000.00",inputFormatterSymbol:"0",inputFormatterAllowed:/[0-9.]/}]},{type:f.Typography,fieldBottomMargin:"3",typoVariant:"caption",sx:{pt:2,opacity:.5,fontSize:12},placeholder:`${k.bullet} Carefully verify that this is the coin you want to close the position on. Rely on the symbol AND THE PRICE`}]}}],bt=({type:e,title:t,description:o,amount:a,price:i,symbol:r})=>{const l=Z(),s="loading"===e?{color:l.palette.warning.main,bgColor:te(l.palette.warning.main,.1),icon:n(oe,{size:24,color:"warning"}),chipColor:"warning"}:"success"===e?{color:l.palette.success.main,bgColor:te(l.palette.success.main,.1),icon:n($e,{}),chipColor:"success"}:"error"===e?{color:l.palette.error.main,bgColor:te(l.palette.error.main,.1),icon:n(ae,{}),chipColor:"error"}:"warning"===e?{color:l.palette.warning.main,bgColor:te(l.palette.warning.main,.1),icon:n(ie,{}),chipColor:"warning"}:"info"===e?{color:l.palette.info.main,bgColor:te(l.palette.info.main,.1),icon:n(re,{}),chipColor:"info"}:{color:l.palette.grey[500],bgColor:te(l.palette.grey[500],.1),icon:n(re,{}),chipColor:"default"};return n(Pe,{elevation:0,sx:{backgroundColor:s.bgColor,border:`1px solid ${te(s.color,.3)}`,borderRadius:2,transition:"all 0.3s ease"},children:n(Me,{sx:{p:3},children:[n(S,{sx:{display:"flex",alignItems:"center",gap:2,mb:2},children:[n(S,{sx:{color:s.color,display:"flex",alignItems:"center"},children:s.icon}),n(x,{variant:"h6",sx:{color:s.color,fontWeight:600,flex:1},children:t}),r&&n(P,{label:r,size:"small",color:s.chipColor,variant:"outlined",icon:n(ee,{})})]}),o&&n(x,{variant:"body2",color:"text.secondary",sx:{mb:2,lineHeight:1.5},children:o}),(a||i)&&n(S,{sx:{display:"flex",gap:3,mt:2,p:2,backgroundColor:te(l.palette.background.paper,.6),borderRadius:1,border:`1px solid ${te(s.color,.1)}`},children:[a&&n(S,{children:[n(x,{variant:"caption",color:"text.secondary",children:"Amount"}),n(x,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:a})]}),i&&n(S,{children:[n(x,{variant:"caption",color:"text.secondary",children:"Price"}),n(x,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:i})]})]})]})})},ft={success:!1,loading:!0,error:""},vt=[{id:"brief",element:({data:e,payload:t,history:o,onChange:a,onClose:i,setLoading:r})=>{const l=U([e],50),[s,{loading:c}]=y(async()=>{const e=t.getContext();return{averagePrice:await u.controlViewService.getAveragePrice(e.symbol,{strategyName:e.strategyName,exchangeName:e.exchangeName}),symbol:e.symbol}},{onLoadStart:()=>r(!0),onLoadEnd:()=>r(!1)});return n(K,{Navigation:n(J,{hasPrev:!0,hasNext:!!s,labelPrev:"Close",onPrev:async()=>{await i()},onNext:async()=>{a({averagePrice:s.averagePrice,symbol:s.symbol}),await l(),o.replace("/form")}}),children:s?c?null:n(w,{payload:()=>({averagePrice:s.averagePrice,symbol:s.symbol}),slots:Q,fields:ht}):null})},isActive:e=>!!le("/brief",e)},{id:"form",element:({data:e,history:t,formState:a,onChange:i})=>{const[r,l]=o.useState(e),s=U([e],50);return n(K,{Navigation:n(J,{hasPrev:!0,hasNext:!0,labelPrev:"Back",onPrev:async()=>{t.replace("/brief")},onNext:async()=>{r&&(i({note:r.note,symbol:a.data.brief.symbol}),await s(),t.replace("/submit"))}}),children:n(w,{payload:()=>({averagePrice:a.data.brief.averagePrice}),onChange:e=>l(e),slots:Q,fields:gt,sx:{pt:1}})})},isActive:e=>!!le("/form",e)},{id:"submit",element:({formState:e,payload:t,beginSave:a,setLoading:i})=>{const[r,l]=o.useState(ft),{note:s,symbol:c}=o.useMemo(()=>{const{note:t,symbol:o}=e.data.form;return{note:t,symbol:o}},[e]);I(async()=>{i(!0);try{const e=t.getContext();await u.controlViewService.commitClosePending(e.symbol,{strategyName:e.strategyName,exchangeName:e.exchangeName},{note:s||""}),l({success:!0,loading:!1,error:""})}catch(e){l({success:!1,loading:!1,error:ne(e)})}finally{i(!1)}});return n(K,{Navigation:n(J,{hasNext:r.success||!!r.error,labelNext:"Close",onNext:async()=>{await a()}}),children:n(S,{p:1,children:r.error?n(bt,{type:"error",title:"Position Closing Error",description:r.error,symbol:c}):r.loading?n(bt,{type:"loading",title:"Closing Position",description:"Please wait. Your operation is being processed...",symbol:c}):n(bt,{type:"success",title:"Position Closed",description:"Closing has been scheduled successfully. Waiting for the order to be executed on the exchange",symbol:c})})})},isActive:e=>!!le("/submit",e)}],xt=[{id:"brief",label:"Briefing"},{id:"form",label:"Input"},{id:"submit",label:"Closing"}],Ct="/brief",wt=de(),St=[{type:f.Center,child:{type:f.Group,desktopColumns:"6",tabletColumns:"12",phoneColumns:"12",fields:[{type:f.Typography,style:{opacity:.5},fieldBottomMargin:"3",typoVariant:"h6",placeholder:"Move to Breakeven"},{type:f.Outline,fields:[{type:f.Typography,typoVariant:"body1",placeholder:"The stop-loss will be moved to the breakeven point of the current position. No additional input is required."}]},{type:f.Typography,fieldBottomMargin:"3",typoVariant:"caption",sx:{pt:2,opacity:.5,fontSize:12},placeholder:`${k.bullet} After pressing the Next button, the move to breakeven will be performed IMMEDIATELY`}]}}],Nt=[{type:f.Center,child:{type:f.Group,desktopColumns:"6",tabletColumns:"12",phoneColumns:"12",fields:[{type:f.Typography,style:{opacity:.5},fieldBottomMargin:"3",typoVariant:"h6",placeholder:"Move to Breakeven"},{type:f.Outline,fields:[{type:f.Text,name:"symbol",compute:({},e)=>e.symbol,title:"Symbol"},{type:f.Text,name:"price",inputPattern:"[0-9.]*",inputMode:"decimal",inputType:"tel",compute:({},e)=>`${X(e.averagePrice)}$`,title:"Coin Price",placeholder:"000000.00",inputFormatterSymbol:"0",inputFormatterAllowed:/[0-9.]/}]},{type:f.Typography,fieldBottomMargin:"3",typoVariant:"caption",sx:{pt:2,opacity:.5,fontSize:12},placeholder:`${k.bullet} Carefully verify that this is the coin whose stop you want to move to breakeven. Rely on the symbol AND THE PRICE`}]}}],Pt=({type:e,title:t,description:o,amount:a,price:i,symbol:r})=>{const l=Z(),s="loading"===e?{color:l.palette.warning.main,bgColor:te(l.palette.warning.main,.1),icon:n(oe,{size:24,color:"warning"}),chipColor:"warning"}:"success"===e?{color:l.palette.success.main,bgColor:te(l.palette.success.main,.1),icon:n($e,{}),chipColor:"success"}:"error"===e?{color:l.palette.error.main,bgColor:te(l.palette.error.main,.1),icon:n(ae,{}),chipColor:"error"}:"warning"===e?{color:l.palette.warning.main,bgColor:te(l.palette.warning.main,.1),icon:n(ie,{}),chipColor:"warning"}:"info"===e?{color:l.palette.info.main,bgColor:te(l.palette.info.main,.1),icon:n(re,{}),chipColor:"info"}:{color:l.palette.grey[500],bgColor:te(l.palette.grey[500],.1),icon:n(re,{}),chipColor:"default"};return n(Pe,{elevation:0,sx:{backgroundColor:s.bgColor,border:`1px solid ${te(s.color,.3)}`,borderRadius:2,transition:"all 0.3s ease"},children:n(Me,{sx:{p:3},children:[n(S,{sx:{display:"flex",alignItems:"center",gap:2,mb:2},children:[n(S,{sx:{color:s.color,display:"flex",alignItems:"center"},children:s.icon}),n(x,{variant:"h6",sx:{color:s.color,fontWeight:600,flex:1},children:t}),r&&n(P,{label:r,size:"small",color:s.chipColor,variant:"outlined",icon:n(ee,{})})]}),o&&n(x,{variant:"body2",color:"text.secondary",sx:{mb:2,lineHeight:1.5},children:o}),(a||i)&&n(S,{sx:{display:"flex",gap:3,mt:2,p:2,backgroundColor:te(l.palette.background.paper,.6),borderRadius:1,border:`1px solid ${te(s.color,.1)}`},children:[a&&n(S,{children:[n(x,{variant:"caption",color:"text.secondary",children:"Amount"}),n(x,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:a})]}),i&&n(S,{children:[n(x,{variant:"caption",color:"text.secondary",children:"Price"}),n(x,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:i})]})]})]})})},kt={success:!1,loading:!0,error:""},At=[{id:"brief",element:({data:e,payload:t,history:o,onChange:a,onClose:i,setLoading:r})=>{const l=U([e],50),[s,{loading:c}]=y(async()=>{const e=t.getContext();return{averagePrice:await u.controlViewService.getAveragePrice(e.symbol,{strategyName:e.strategyName,exchangeName:e.exchangeName}),symbol:e.symbol}},{onLoadStart:()=>r(!0),onLoadEnd:()=>r(!1)});return n(K,{Navigation:n(J,{hasPrev:!0,hasNext:!!s,labelPrev:"Close",onPrev:async()=>{await i()},onNext:async()=>{a({averagePrice:s.averagePrice,symbol:s.symbol}),await l(),o.replace("/form")}}),children:s?c?null:n(w,{payload:()=>({averagePrice:s.averagePrice,symbol:s.symbol}),slots:Q,fields:Nt}):null})},isActive:e=>!!le("/brief",e)},{id:"form",element:({data:e,history:t,formState:o,onChange:a})=>{const i=U([e],50);return n(K,{Navigation:n(J,{hasPrev:!0,hasNext:!0,labelPrev:"Back",onPrev:async()=>{t.replace("/brief")},onNext:async()=>{a({symbol:o.data.brief.symbol}),await i(),t.replace("/submit")}}),children:n(w,{payload:()=>({averagePrice:o.data.brief.averagePrice}),slots:Q,fields:St,sx:{pt:1}})})},isActive:e=>!!le("/form",e)},{id:"submit",element:({formState:e,payload:t,beginSave:a,setLoading:i})=>{const[r,l]=o.useState(kt),{symbol:s}=o.useMemo(()=>{const{symbol:t}=e.data.form;return{symbol:t}},[e]);I(async()=>{i(!0);try{const e=t.getContext();await u.controlViewService.commitBreakeven(e.symbol,{strategyName:e.strategyName,exchangeName:e.exchangeName}),l({success:!0,loading:!1,error:""})}catch(e){l({success:!1,loading:!1,error:ne(e)})}finally{i(!1)}});return n(K,{Navigation:n(J,{hasNext:r.success||!!r.error,labelNext:"Close",onNext:async()=>{await a()}}),children:n(S,{p:1,children:r.error?n(Pt,{type:"error",title:"Breakeven Error",description:r.error,symbol:s}):r.loading?n(Pt,{type:"loading",title:"Moving to Breakeven",description:"Please wait. Your operation is being processed...",symbol:s}):n(Pt,{type:"success",title:"Breakeven Set",description:"Breakeven has been scheduled successfully. Waiting for the order to be executed on the exchange",symbol:s})})})},isActive:e=>!!le("/submit",e)}],Lt=[{id:"brief",label:"Briefing"},{id:"form",label:"Input"},{id:"submit",label:"Breakeven"}],Mt="/brief",Tt=de(),$t=e=>"pnl"===e?"P&L":e,Bt=[{type:h.Link,action:"back-action",label:n(ve,{sx:{display:"block"}})},{type:h.Link,action:"back-action",label:"Main"},{type:h.Link,action:"back-action",label:"Status"},{type:h.Link,action:"back-action",compute:e=>e?`${String(e.symbol).toUpperCase()} (${e.strategyName})`:"Live"},{type:h.Link,action:"back-action",label:"Manual Control"},{type:h.Button,action:"update-now",label:"Refresh",icon:fe}],Rt=[{action:"download-action",label:"Download",icon:()=>n(v,{icon:D,color:"#4caf50"})},{divider:!0},{action:"update-now",label:"Refresh",icon:()=>n(v,{icon:fe,color:"#4caf50"})}],Ft=[{id:"control",element:({params:e})=>{const[t]=y(async()=>{const t=await u.statusViewService.getStatusMap();return R.get(t,e.id,null)},{onLoadStart:()=>u.layoutService.setAppbarLoader(!0),onLoadEnd:()=>u.layoutService.setAppbarLoader(!1),deps:[e.id]}),[o,{loading:a,execute:i}]=y(async()=>t?await u.controlViewService.getStrategyStatus(t.symbol,{strategyName:t.strategyName,exchangeName:t.exchangeName}):null,{onLoadStart:()=>u.layoutService.setAppbarLoader(!0),onLoadEnd:()=>u.layoutService.setAppbarLoader(!1),deps:[t]}),r=me(t),{pickData:l,render:s}=(({payload:e})=>{const{pickData:t,render:o}=se({history:nt,animation:"none",title:"Open Position",AfterTitle:({onClose:e})=>n(A,{direction:"row",gap:1,children:n(pe,{size:"small",onClick:e,children:n(Y,{})})}),mapPayload:()=>e,pathname:rt,sizeRequest:ce,routes:at,steps:it,onSubmit:async t=>(t&&await e.reloadSubject.next(),!0)});return{pickData:()=>{nt.push(rt),t()},render:o}})({payload:{getContext:()=>r.current,reloadSubject:Ce}}),{pickData:c,render:d}=(({payload:e})=>{const{pickData:t,render:o}=se({history:ut,animation:"none",title:"Average Position",AfterTitle:({onClose:e})=>n(A,{direction:"row",gap:1,children:n(pe,{size:"small",onClick:e,children:n(Y,{})})}),mapPayload:()=>e,pathname:yt,sizeRequest:ce,routes:dt,steps:mt,onSubmit:async t=>(t&&await e.reloadSubject.next(),!0)});return{pickData:()=>{ut.push(yt),t()},render:o}})({payload:{getContext:()=>r.current,reloadSubject:Ce}}),{pickData:m,render:h}=(({payload:e})=>{const{pickData:t,render:o}=se({history:wt,animation:"none",title:"Close Position",AfterTitle:({onClose:e})=>n(A,{direction:"row",gap:1,children:n(pe,{size:"small",onClick:e,children:n(Y,{})})}),mapPayload:()=>e,pathname:Ct,sizeRequest:ce,routes:vt,steps:xt,onSubmit:async t=>(t&&await e.reloadSubject.next(),!0)});return{pickData:()=>{wt.push(Ct),t()},render:o}})({payload:{getContext:()=>r.current,reloadSubject:Ce}}),{pickData:b,render:f}=(({payload:e})=>{const{pickData:t,render:o}=se({history:Tt,animation:"none",title:"Move to Breakeven",AfterTitle:({onClose:e})=>n(A,{direction:"row",gap:1,children:n(pe,{size:"small",onClick:e,children:n(Y,{})})}),mapPayload:()=>e,pathname:Mt,sizeRequest:ce,routes:At,steps:Lt,onSubmit:async t=>(t&&await e.reloadSubject.next(),!0)});return{pickData:()=>{Tt.push(Mt),t()},render:o}})({payload:{getContext:()=>r.current,reloadSubject:Ce}});I(()=>Ce.subscribe(i)),I(()=>Ue.subscribe(l)),I(()=>Ye.subscribe(c)),I(()=>Qe.subscribe(m)),I(()=>Je.subscribe(b));const v=F(async()=>{if(!o)return;const e=new Blob([JSON.stringify(o,null,2)],{type:"application/json"}),t=URL.createObjectURL(e);u.layoutService.downloadFile(t,`manual_control_${Date.now()}.json`)});return n(be,{children:[n(g,{items:Bt,actions:Rt,payload:t,onAction:async t=>{"back-action"===t&&u.routerService.push(`/status/${e.id}`),"download-action"===t&&v(),"update-now"===t&&await Ce.next()}}),o?a?null:n(ye,{component:p,withExpandAll:!0,sx:{p:1,minHeight:"calc(100dvh - 175px)"},payload:t,formatSearch:$t,AfterSearch:Xe,data:o}):null,n(S,{sx:{paddingBottom:"24px"}}),n(xe,{}),s(),d(),h(),f()]})},isActive:e=>ge(["/status/:id/control"],e)},{id:"status",element:({params:e})=>{const[t]=y(async()=>{const t=await u.statusViewService.getStatusMap();return R.get(t,e.id,null)},{onLoadStart:()=>u.layoutService.setAppbarLoader(!0),onLoadEnd:()=>u.layoutService.setAppbarLoader(!1),deps:[e.id]}),[o,{loading:a,execute:i}]=y(async()=>await u.statusViewService.getStatusOne(e.id),{onLoadStart:()=>u.layoutService.setAppbarLoader(!0),onLoadEnd:()=>u.layoutService.setAppbarLoader(!1),deps:[e.id]}),r=F(async()=>{if(!o)return;const e=new Blob([JSON.stringify(o,null,2)],{type:"application/json"}),t=URL.createObjectURL(e);u.layoutService.downloadFile(t,`status_${Date.now()}.json`)}),l=F(async()=>{if(!o)return;const e=u.markdownHelperService.buildMarkdownFromFields(V,o);await z(e)});I(()=>_e.subscribe(i));return n(be,{children:[n(g,{items:Ge,actions:qe,payload:t,onAction:async t=>{"back-action"===t&&(async()=>{1!==(await u.statusViewService.getStatusList()).length?u.routerService.push("/status"):u.routerService.push("/")})(),"control-action"===t&&u.routerService.push(`/status/${e.id}/control`),"update-now"===t&&await _e.next(),"download-action"===t&&await r(),"print-action"===t&&await l()}}),a?n(C,{children:n(x,{variant:"h6",sx:{opacity:.5},children:"Loading..."})}):o?n(N,{children:[n(w,{handler:o,fields:j}),n(S,{paddingBottom:"24px"})]}):n(C,{children:n(x,{variant:"h6",sx:{opacity:.5},children:"No pending signal"})}),n(xe,{})]})},isActive:e=>ge(["/status/:id"],e)},{id:"main",element:()=>{const{classes:e}=Oe(),{reloadTrigger:t,doReload:o}=m();y(async()=>{const e=await u.statusViewService.getStatusList();if(1===e.length){const[{id:t}]=e;u.routerService.push(`/status/${t}`)}},{onLoadStart:()=>u.layoutService.setAppbarLoader(!0),onLoadEnd:()=>u.layoutService.setAppbarLoader(!1),deps:[t]});const[a,{loading:i}]=y(async()=>await(async()=>{const[e,t]=await Promise.all([u.symbolGlobalService.getSymbolMap(),u.statusViewService.getStatusList()]);if(!t||0===t.length)return[{type:f.Typography,typoVariant:"h6",placeholder:"Listening for a pending signal...",sx:{textAlign:"center",opacity:.5,mt:4}}];const o={};t.forEach(t=>{const a=e[t.symbol],i=t.strategyName;o[i]||(o[i]=[]),o[i].push({symbol:t.symbol,label:(null==a?void 0:a.displayName)||t.symbol,color:(null==a?void 0:a.color)||"#ccc",to:t.id})});const a=Object.entries(o).sort(([,e],[,t])=>t.length-e.length),i=[],r=[],n=[];return a.forEach(([e,t],o)=>{const a=We(e,t);o%2==0?i.push(a):r.push(a),n.push(a)}),[{type:f.Group,columns:"6",className:"tabletLeftColumn",phoneHidden:!0,desktopHidden:!0,fields:i},{type:f.Group,columns:"6",className:"tabletRightColumn",phoneHidden:!0,desktopHidden:!0,fields:r},{type:f.Group,columns:"12",className:"wideColumn",tabletHidden:!0,fields:n}]})(),{onLoadStart:()=>u.layoutService.setAppbarLoader(!0),onLoadEnd:()=>u.layoutService.setAppbarLoader(!1),deps:[t]});return n(be,{children:[n(g,{items:je,actions:He,onAction:e=>{"back-action"===e&&u.routerService.push("/"),"update-now"===e&&o()}}),i||!a?n(C,{children:n(x,{variant:"h6",sx:{opacity:.5},children:"Loading..."})}):a.length?n(N,{children:[n(w,{className:e.root,fields:a},t),n(S,{paddingBottom:"24px"})]}):n(C,{children:n(x,{variant:"h6",sx:{opacity:.5},children:"No pending signals"})})]})},isActive:e=>ge(["/status"],e)}],Vt=({id:e})=>n(ue,{history:u.routerService,onLoadStart:()=>u.layoutService.setAppbarLoader(!0),onLoadEnd:()=>u.layoutService.setAppbarLoader(!1),routes:Ft,params:{id:e}});export{Vt as StatusPage,Vt as default};
@@ -1 +1 @@
1
- import{f as e,b7 as t,M as a,B as i,q as r,bj as o,i as n,bk as l,v as s,b3 as c,bl as d,Y as w,Z as p,$ as h,a0 as m,b0 as k,bm as g,aI as b,bn as v,av as y,bh as u,b5 as f,ad as S,A as x,bo as _,ax as D,w as V,Q as N,x as O,O as R,R as L,p as B,a2 as A,T as P,b2 as C,W as $,F as j,a3 as J,E as M,a5 as G,l as F,n as X,a4 as H,a6 as I,aj as E}from"./index-BI3k7b1T.js";import{h as z}from"./hasRouteMatch-CqJJG3sx.js";import{I as T}from"./IconPhoto-Czod_jkW.js";import{C as U,R as W}from"./Refresh-3cixHjvW.js";import{K as q}from"./KeyboardArrowLeft-BUZ_pXI5.js";const K=[{id:"backtest",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/backtest")},{id:"live",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/live")},{id:"breakeven",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/breakeven")},{id:"risk",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/risk")},{id:"partial",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/partial")},{id:"highest_profit",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/highest_profit")},{id:"max_drawdown",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/max_drawdown")},{id:"schedule",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/schedule")},{id:"performance",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/performance")},{id:"sync",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/sync")},{id:"heat",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/heat")},{id:"strategy",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/strategy")}],Q=[{id:"backtest",label:"Backtest",isVisible:({type:e})=>"backtest"===e},{id:"live",label:"Live",isVisible:({type:e})=>"live"===e},{id:"strategy",label:"Strategy"},{id:"breakeven",label:"Breakeven"},{id:"risk",label:"Risk"},{id:"partial",label:"Partial"},{id:"highest_profit",label:"Highest Profit"},{id:"max_drawdown",label:"Max Drawdown"},{id:"schedule",label:"Schedule"},{id:"performance",label:"Performance"},{id:"sync",label:"Sync"},{id:"heat",label:"Heat"}],Y=({disabled:t,className:a,style:i,sx:c,onClick:d,color:w})=>e(l,{className:a,style:i,sx:c,disabled:t,color:w,size:36,onClick:async e=>{const[t,{resolve:a}]=o();e.preventDefault(),e.stopPropagation(),await d(e,e=>a(e));const i=await t;await(async e=>{let t=!1;t=t||"string"==typeof e,t=t||"number"==typeof e,t=t||"boolean"==typeof e,t=t||void 0===e,t=t||null===e,t&&await s(String(e))})(i),n.alertService.notify("Copied!")},children:e(r,{})}),Z=[{action:"json",label:"Download JSON",icon:()=>e(p,{icon:w,color:"#4caf50"})},{action:"markdown",label:"Download Markdown",icon:()=>e(p,{icon:h,color:"#4caf50"})},{action:"pdf",label:"Download PDF",icon:()=>e(p,{icon:m,color:"#4caf50"})}],ee=({disabled:t,className:a,style:i,sx:r,onDownloadJson:o,onDownloadMarkdown:n,onDownloadPdf:l})=>{const s=c(async e=>{"json"===e?await o():"markdown"===e?await n():"pdf"===e&&await l()});return e(d,{transparent:!0,className:a,style:i,sx:r,disabled:t,options:Z,onAction:s})},te=y(),ae=D(async(e,t)=>{const a=("backtest"===t?await n.backtestGlobalService.list():await n.liveGlobalService.list()).find(t=>t.id===e);if(!a)throw new Error(`Item not found: ${e}`);const{symbol:i,strategyName:r,exchangeName:o,frameName:l}=a,[s,c,d,w,p,h,m,k,g,b,v,y]=await Promise.all(["backtest"===t?n.markdownViewService.getBacktestReport(i,r,o,l):Promise.resolve(""),"live"===t?n.markdownViewService.getLiveReport(i,r,o):Promise.resolve(""),n.markdownViewService.getBreakevenReport(i,r,o,l,"backtest"===t),n.markdownViewService.getRiskReport(i,r,o,l,"backtest"===t),n.markdownViewService.getPartialReport(i,r,o,l,"backtest"===t),n.markdownViewService.getHighestProfitReport(i,r,o,l,"backtest"===t),n.markdownViewService.getMaxDrawdownReport(i,r,o,l,"backtest"===t),n.markdownViewService.getScheduleReport(i,r,o,l,"backtest"===t),n.markdownViewService.getPerformanceReport(i,r,o,l,"backtest"===t),n.markdownViewService.getSyncReport(i,r,o,l,"backtest"===t),n.markdownViewService.getHeatReport(r,o,l,"backtest"===t),n.markdownViewService.getStrategyReport(i,r,o,l,"backtest"===t)]);return{type:t,backtest:s,live:c,breakeven:d,risk:w,partial:p,highest_profit:h,max_drawdown:m,schedule:k,performance:g,sync:b,heat:v,strategy:y}},{timeout:45e3,key:([e,t])=>`${e}_${t}`}),ie=()=>{const[t,a]=k(""),[r,o]=k("backtest"),s=g(),{push:c,pop:d}=s,[w,p]=b(te.location.pathname),h=async()=>{const e=(await ae(t.current,r.current))[w.current.replace("/markdown_report/","")];"string"==typeof e&&await V(e)},m=async()=>{const e=await ae(t.current,r.current),a=w.current.replace("/markdown_report/",""),i=e[a];if("string"==typeof i){const e=new Blob([i],{type:"text/plain"}),t=URL.createObjectURL(e);n.layoutService.downloadFile(t,`${a}_${r.current}_${Date.now()}.md`)}},y=async()=>{const e=("backtest"===r.current?await n.backtestGlobalService.list():await n.liveGlobalService.list()).find(e=>e.id===t.current);if(!e)throw new Error(`Item not found: ${t.current}`);const{symbol:a,strategyName:i,exchangeName:o,frameName:l}=e,s=w.current.replace("/markdown_report/",""),c="backtest"===r.current;let d;if("backtest"===s?d=await n.markdownViewService.getBacktestData(a,i,o,l):"live"===s?d=await n.markdownViewService.getLiveData(a,i,o):"breakeven"===s?d=await n.markdownViewService.getBreakevenData(a,i,o,l,c):"risk"===s?d=await n.markdownViewService.getRiskData(a,i,o,l,c):"partial"===s?d=await n.markdownViewService.getPartialData(a,i,o,l,c):"highest_profit"===s?d=await n.markdownViewService.getHighestProfitData(a,i,o,l,c):"max_drawdown"===s?d=await n.markdownViewService.getMaxDrawdownData(a,i,o,l,c):"schedule"===s?d=await n.markdownViewService.getScheduleData(a,i,o,l,c):"performance"===s?d=await n.markdownViewService.getPerformanceData(a,i,o,l,c):"sync"===s?d=await n.markdownViewService.getSyncData(a,i,o,l,c):"heat"===s?d=await n.markdownViewService.getHeatData(i,o,l,c):"strategy"===s&&(d=await n.markdownViewService.getStrategyData(a,i,o,l,c)),void 0!==d){const e=new Blob([JSON.stringify(d,null,2)],{type:"application/json"}),t=URL.createObjectURL(e);n.layoutService.downloadFile(t,`${s}_${r.current}_${Date.now()}.json`)}},{pickData:D,render:N}=v({tabs:Q,withStaticAction:!0,onTabChange:(e,t)=>{const a=`/markdown_report/${e}`;t.replace(a),p(a)},animation:"none",title:"Markdown Report",sizeRequest:u,history:te,routes:K,BeforeTitle:({onClose:t})=>{const{total:a}=g();return e(i,{sx:{mr:1,display:1===a?"none":"flex"},children:e(l,{onClick:t,children:e(_,{})})})},AfterTitle:({onClose:a})=>e(x,{direction:"row",gap:1,children:[e(l,{sx:{mr:"10px"},onClick:()=>h(),children:e(f,{})}),e(Y,{onClick:async(e,a)=>{await(async(e,t,a,i)=>{const r=("backtest"===a?await n.backtestGlobalService.list():await n.liveGlobalService.list()).find(e=>e.id===t);if(!r)throw new Error(`Item not found: ${t}`);const{symbol:o,strategyName:l,exchangeName:s,frameName:c}=r,d="backtest"===a;e.includes("/markdown_report/backtest")?i(JSON.stringify(await n.markdownViewService.getBacktestData(o,l,s,c),null,2)):e.includes("/markdown_report/live")?i(JSON.stringify(await n.markdownViewService.getLiveData(o,l,s),null,2)):e.includes("/markdown_report/breakeven")?i(JSON.stringify(await n.markdownViewService.getBreakevenData(o,l,s,c,d),null,2)):e.includes("/markdown_report/risk")?i(JSON.stringify(await n.markdownViewService.getRiskData(o,l,s,c,d),null,2)):e.includes("/markdown_report/partial")?i(JSON.stringify(await n.markdownViewService.getPartialData(o,l,s,c,d),null,2)):e.includes("/markdown_report/highest_profit")?i(JSON.stringify(await n.markdownViewService.getHighestProfitData(o,l,s,c,d),null,2)):e.includes("/markdown_report/max_drawdown")?i(JSON.stringify(await n.markdownViewService.getMaxDrawdownData(o,l,s,c,d),null,2)):e.includes("/markdown_report/schedule")?i(JSON.stringify(await n.markdownViewService.getScheduleData(o,l,s,c,d),null,2)):e.includes("/markdown_report/performance")?i(JSON.stringify(await n.markdownViewService.getPerformanceData(o,l,s,c,d),null,2)):e.includes("/markdown_report/sync")?i(JSON.stringify(await n.markdownViewService.getSyncData(o,l,s,c,d),null,2)):e.includes("/markdown_report/heat")?i(JSON.stringify(await n.markdownViewService.getHeatData(l,s,c,d),null,2)):e.includes("/markdown_report/strategy")&&i(JSON.stringify(await n.markdownViewService.getStrategyData(o,l,s,c,d),null,2))})(w.current,t.current,r.current,a)},sx:{mr:"10px",mt:"2.5px"}}),e(ee,{sx:{mr:"10px",mt:"0.5px"},onDownloadJson:y,onDownloadMarkdown:m,onDownloadPdf:h}),e(l,{onClick:a,children:e(S,{})})]}),fetchState:async()=>await ae(t.current,r.current),mapInitialData:([{type:e,backtest:t,live:a,breakeven:i,risk:r,partial:o,highest_profit:n,max_drawdown:l,schedule:s,performance:c,sync:d,heat:w,strategy:p}])=>({backtest:t,live:a,breakeven:i,risk:r,partial:o,highest_profit:n,max_drawdown:l,schedule:s,performance:c,sync:d,heat:w,strategy:p,type:e}),mapPayload:([{type:e}])=>({type:e}),onLoadStart:()=>n.layoutService.setAppbarLoader(!0),onLoadEnd:()=>n.layoutService.setAppbarLoader(!1),onClose:()=>{d()}});return(e,t)=>{c({id:"markdown_report_modal",render:N,onInit:()=>{const e="live"===t?"/markdown_report/live":"/markdown_report/backtest";te.push(e),p(e)},onMount:()=>{a(e),o(t),D()}})}},re="backtest-kit__groupHeader",oe="backtest-kit__groupRoot",ne="backtest-kit__symbolImage",le=B()({root:{[`& .${oe}:hover .${re}`]:{opacity:"1 !important"}}});function se(e){return I(e,"#000000")>I(e,"#FFFFFF")}const ce=[{type:L.Link,action:"back-action",label:e(q,{sx:{display:"block"}})},{type:L.Link,action:"back-action",label:"Main"},{type:L.Link,action:"back-action",label:"Markdown Report"}],de=[{action:"update-now",label:"Refresh",icon:()=>e(p,{icon:W,color:"#4caf50"})}],we=(t,a)=>({type:A.Group,className:oe,sx:{p:2},tabletColumns:"12",desktopColumns:"3",fields:[{type:A.Component,className:re,style:{transition:"opacity 500ms",opacity:.5},element:()=>e(x,{direction:"row",children:[e(J,{variant:"outlined",size:"small",color:"info",label:`${M.bullet} ${t}`,sx:{mb:1,pr:.5,fontSize:"14px",background:"white",cursor:"not-allowed"}}),e(i,{flex:1})]})},{type:A.Group,fields:a.map(({symbol:t,label:a,id:r,type:o,color:n})=>((t,a,r,o,n)=>({type:A.Component,desktopColumns:"6",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:({payload:l})=>e(H,{component:G,onClick:()=>{l.handleOpen(t,a)},sx:{width:"100%",background:n,color:"white",fontWeight:"bold",fontSize:"14px",height:"75px",minHeight:"75px",textWrap:"wrap",padding:"16px",[`& .${ne}`]:{transition:"filter 500ms"},"&:hover":{background:()=>se(n)?F(n,.33):X(n,.33),[`& .${ne}`]:{transition:"filter 500ms",filter:se(n)?"brightness(0.7) contrast(1.2)":"brightness(1.3) contrast(0.5)"}},transition:"background 500ms"},startIcon:e(T,{className:ne,symbol:r}),children:e(i,{sx:{overflow:"hidden",textOverflow:"ellipsis",width:"75px"},children:o})})}))(r,o,t,a,n))}]}),pe=[{id:"main",element:()=>{const{classes:t}=le(),{reloadTrigger:a,doReload:r}=N(),[o,{loading:l}]=O(async()=>await(async()=>{const[e,t,a]=await Promise.all([n.symbolGlobalService.getSymbolMap(),n.backtestGlobalService.list(),n.liveGlobalService.list()]),i={},r={};t.forEach(t=>{const a=e[t.symbol],r=t.strategyName;i[r]||(i[r]=[]),i[r].push({symbol:t.symbol,label:(null==a?void 0:a.displayName)||t.symbol,color:(null==a?void 0:a.color)||"#ccc",type:"backtest",id:t.id})}),a.forEach(t=>{const a=e[t.symbol],i=t.strategyName;r[i]||(r[i]=[]),r[i].push({symbol:t.symbol,label:(null==a?void 0:a.displayName)||t.symbol,color:(null==a?void 0:a.color)||"#ccc",id:t.id,type:"live"})});const o=Object.entries(i).sort(([,e],[,t])=>t.length-e.length).map(([e,t])=>we(e,t)),l=Object.entries(r).sort(([,e],[,t])=>t.length-e.length).map(([e,t])=>we(e,t));return l.length||o.length?[{type:A.Fragment,isVisible:()=>!!o.length,fields:[{type:A.Line,title:"Backtest"},{type:A.Group,columns:"12",fields:o}]},{type:A.Fragment,isVisible:()=>!!l.length,fields:[{type:A.Line,title:"Live"},{type:A.Group,columns:"12",fields:l}]}]:[]})(),{onLoadStart:()=>n.layoutService.setAppbarLoader(!0),onLoadEnd:()=>n.layoutService.setAppbarLoader(!1),deps:[a]}),s=ie(),c=(e,t)=>{s(e,t)};return e(U,{children:[e(R,{items:ce,actions:de,onAction:e=>{"back-action"===e&&n.routerService.push("/"),"update-now"===e&&r()}}),l||!o?e(C,{children:e(P,{variant:"h6",sx:{opacity:.5},children:"Loading..."})}):o.length?e(j,{children:[e($,{className:t.root,fields:o,payload:()=>({handleOpen:c})},a),e(i,{paddingBottom:"24px"})]}):e(C,{children:e(P,{variant:"h6",sx:{opacity:.5},children:"No pending signals"})})]})},isActive:e=>z(["/report"],e)}],he=({id:t})=>e(E,{history:n.routerService,onLoadStart:()=>n.layoutService.setAppbarLoader(!0),onLoadEnd:()=>n.layoutService.setAppbarLoader(!1),routes:pe,params:{id:t}});export{he as StatusPage,he as default};
1
+ import{f as e,b7 as t,M as a,B as i,q as r,bj as o,i as n,bk as l,v as s,b3 as c,bl as d,Y as w,Z as p,$ as h,a0 as m,b0 as k,bm as g,aI as b,bn as v,av as y,bh as u,b5 as f,ad as S,A as x,bo as _,ax as D,w as V,Q as N,x as O,O as R,R as L,p as B,a2 as A,T as P,b2 as C,W as $,F as j,a3 as J,E as M,a5 as G,l as F,n as X,a4 as H,a6 as I,aj as E}from"./index-Cgx-XS5d.js";import{h as z}from"./hasRouteMatch-D81_5Zia.js";import{I as T}from"./IconPhoto-CTTANJQT.js";import{C as U,R as W}from"./Refresh-BrRXF_OY.js";import{K as q}from"./KeyboardArrowLeft-vg5fS39b.js";const K=[{id:"backtest",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/backtest")},{id:"live",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/live")},{id:"breakeven",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/breakeven")},{id:"risk",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/risk")},{id:"partial",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/partial")},{id:"highest_profit",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/highest_profit")},{id:"max_drawdown",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/max_drawdown")},{id:"schedule",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/schedule")},{id:"performance",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/performance")},{id:"sync",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/sync")},{id:"heat",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/heat")},{id:"strategy",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/strategy")}],Q=[{id:"backtest",label:"Backtest",isVisible:({type:e})=>"backtest"===e},{id:"live",label:"Live",isVisible:({type:e})=>"live"===e},{id:"strategy",label:"Strategy"},{id:"breakeven",label:"Breakeven"},{id:"risk",label:"Risk"},{id:"partial",label:"Partial"},{id:"highest_profit",label:"Highest Profit"},{id:"max_drawdown",label:"Max Drawdown"},{id:"schedule",label:"Schedule"},{id:"performance",label:"Performance"},{id:"sync",label:"Sync"},{id:"heat",label:"Heat"}],Y=({disabled:t,className:a,style:i,sx:c,onClick:d,color:w})=>e(l,{className:a,style:i,sx:c,disabled:t,color:w,size:36,onClick:async e=>{const[t,{resolve:a}]=o();e.preventDefault(),e.stopPropagation(),await d(e,e=>a(e));const i=await t;await(async e=>{let t=!1;t=t||"string"==typeof e,t=t||"number"==typeof e,t=t||"boolean"==typeof e,t=t||void 0===e,t=t||null===e,t&&await s(String(e))})(i),n.alertService.notify("Copied!")},children:e(r,{})}),Z=[{action:"json",label:"Download JSON",icon:()=>e(p,{icon:w,color:"#4caf50"})},{action:"markdown",label:"Download Markdown",icon:()=>e(p,{icon:h,color:"#4caf50"})},{action:"pdf",label:"Download PDF",icon:()=>e(p,{icon:m,color:"#4caf50"})}],ee=({disabled:t,className:a,style:i,sx:r,onDownloadJson:o,onDownloadMarkdown:n,onDownloadPdf:l})=>{const s=c(async e=>{"json"===e?await o():"markdown"===e?await n():"pdf"===e&&await l()});return e(d,{transparent:!0,className:a,style:i,sx:r,disabled:t,options:Z,onAction:s})},te=y(),ae=D(async(e,t)=>{const a=("backtest"===t?await n.backtestGlobalService.list():await n.liveGlobalService.list()).find(t=>t.id===e);if(!a)throw new Error(`Item not found: ${e}`);const{symbol:i,strategyName:r,exchangeName:o,frameName:l}=a,[s,c,d,w,p,h,m,k,g,b,v,y]=await Promise.all(["backtest"===t?n.markdownViewService.getBacktestReport(i,r,o,l):Promise.resolve(""),"live"===t?n.markdownViewService.getLiveReport(i,r,o):Promise.resolve(""),n.markdownViewService.getBreakevenReport(i,r,o,l,"backtest"===t),n.markdownViewService.getRiskReport(i,r,o,l,"backtest"===t),n.markdownViewService.getPartialReport(i,r,o,l,"backtest"===t),n.markdownViewService.getHighestProfitReport(i,r,o,l,"backtest"===t),n.markdownViewService.getMaxDrawdownReport(i,r,o,l,"backtest"===t),n.markdownViewService.getScheduleReport(i,r,o,l,"backtest"===t),n.markdownViewService.getPerformanceReport(i,r,o,l,"backtest"===t),n.markdownViewService.getSyncReport(i,r,o,l,"backtest"===t),n.markdownViewService.getHeatReport(r,o,l,"backtest"===t),n.markdownViewService.getStrategyReport(i,r,o,l,"backtest"===t)]);return{type:t,backtest:s,live:c,breakeven:d,risk:w,partial:p,highest_profit:h,max_drawdown:m,schedule:k,performance:g,sync:b,heat:v,strategy:y}},{timeout:45e3,key:([e,t])=>`${e}_${t}`}),ie=()=>{const[t,a]=k(""),[r,o]=k("backtest"),s=g(),{push:c,pop:d}=s,[w,p]=b(te.location.pathname),h=async()=>{const e=(await ae(t.current,r.current))[w.current.replace("/markdown_report/","")];"string"==typeof e&&await V(e)},m=async()=>{const e=await ae(t.current,r.current),a=w.current.replace("/markdown_report/",""),i=e[a];if("string"==typeof i){const e=new Blob([i],{type:"text/plain"}),t=URL.createObjectURL(e);n.layoutService.downloadFile(t,`${a}_${r.current}_${Date.now()}.md`)}},y=async()=>{const e=("backtest"===r.current?await n.backtestGlobalService.list():await n.liveGlobalService.list()).find(e=>e.id===t.current);if(!e)throw new Error(`Item not found: ${t.current}`);const{symbol:a,strategyName:i,exchangeName:o,frameName:l}=e,s=w.current.replace("/markdown_report/",""),c="backtest"===r.current;let d;if("backtest"===s?d=await n.markdownViewService.getBacktestData(a,i,o,l):"live"===s?d=await n.markdownViewService.getLiveData(a,i,o):"breakeven"===s?d=await n.markdownViewService.getBreakevenData(a,i,o,l,c):"risk"===s?d=await n.markdownViewService.getRiskData(a,i,o,l,c):"partial"===s?d=await n.markdownViewService.getPartialData(a,i,o,l,c):"highest_profit"===s?d=await n.markdownViewService.getHighestProfitData(a,i,o,l,c):"max_drawdown"===s?d=await n.markdownViewService.getMaxDrawdownData(a,i,o,l,c):"schedule"===s?d=await n.markdownViewService.getScheduleData(a,i,o,l,c):"performance"===s?d=await n.markdownViewService.getPerformanceData(a,i,o,l,c):"sync"===s?d=await n.markdownViewService.getSyncData(a,i,o,l,c):"heat"===s?d=await n.markdownViewService.getHeatData(i,o,l,c):"strategy"===s&&(d=await n.markdownViewService.getStrategyData(a,i,o,l,c)),void 0!==d){const e=new Blob([JSON.stringify(d,null,2)],{type:"application/json"}),t=URL.createObjectURL(e);n.layoutService.downloadFile(t,`${s}_${r.current}_${Date.now()}.json`)}},{pickData:D,render:N}=v({tabs:Q,withStaticAction:!0,onTabChange:(e,t)=>{const a=`/markdown_report/${e}`;t.replace(a),p(a)},animation:"none",title:"Markdown Report",sizeRequest:u,history:te,routes:K,BeforeTitle:({onClose:t})=>{const{total:a}=g();return e(i,{sx:{mr:1,display:1===a?"none":"flex"},children:e(l,{onClick:t,children:e(_,{})})})},AfterTitle:({onClose:a})=>e(x,{direction:"row",gap:1,children:[e(l,{sx:{mr:"10px"},onClick:()=>h(),children:e(f,{})}),e(Y,{onClick:async(e,a)=>{await(async(e,t,a,i)=>{const r=("backtest"===a?await n.backtestGlobalService.list():await n.liveGlobalService.list()).find(e=>e.id===t);if(!r)throw new Error(`Item not found: ${t}`);const{symbol:o,strategyName:l,exchangeName:s,frameName:c}=r,d="backtest"===a;e.includes("/markdown_report/backtest")?i(JSON.stringify(await n.markdownViewService.getBacktestData(o,l,s,c),null,2)):e.includes("/markdown_report/live")?i(JSON.stringify(await n.markdownViewService.getLiveData(o,l,s),null,2)):e.includes("/markdown_report/breakeven")?i(JSON.stringify(await n.markdownViewService.getBreakevenData(o,l,s,c,d),null,2)):e.includes("/markdown_report/risk")?i(JSON.stringify(await n.markdownViewService.getRiskData(o,l,s,c,d),null,2)):e.includes("/markdown_report/partial")?i(JSON.stringify(await n.markdownViewService.getPartialData(o,l,s,c,d),null,2)):e.includes("/markdown_report/highest_profit")?i(JSON.stringify(await n.markdownViewService.getHighestProfitData(o,l,s,c,d),null,2)):e.includes("/markdown_report/max_drawdown")?i(JSON.stringify(await n.markdownViewService.getMaxDrawdownData(o,l,s,c,d),null,2)):e.includes("/markdown_report/schedule")?i(JSON.stringify(await n.markdownViewService.getScheduleData(o,l,s,c,d),null,2)):e.includes("/markdown_report/performance")?i(JSON.stringify(await n.markdownViewService.getPerformanceData(o,l,s,c,d),null,2)):e.includes("/markdown_report/sync")?i(JSON.stringify(await n.markdownViewService.getSyncData(o,l,s,c,d),null,2)):e.includes("/markdown_report/heat")?i(JSON.stringify(await n.markdownViewService.getHeatData(l,s,c,d),null,2)):e.includes("/markdown_report/strategy")&&i(JSON.stringify(await n.markdownViewService.getStrategyData(o,l,s,c,d),null,2))})(w.current,t.current,r.current,a)},sx:{mr:"10px",mt:"2.5px"}}),e(ee,{sx:{mr:"10px",mt:"0.5px"},onDownloadJson:y,onDownloadMarkdown:m,onDownloadPdf:h}),e(l,{onClick:a,children:e(S,{})})]}),fetchState:async()=>await ae(t.current,r.current),mapInitialData:([{type:e,backtest:t,live:a,breakeven:i,risk:r,partial:o,highest_profit:n,max_drawdown:l,schedule:s,performance:c,sync:d,heat:w,strategy:p}])=>({backtest:t,live:a,breakeven:i,risk:r,partial:o,highest_profit:n,max_drawdown:l,schedule:s,performance:c,sync:d,heat:w,strategy:p,type:e}),mapPayload:([{type:e}])=>({type:e}),onLoadStart:()=>n.layoutService.setAppbarLoader(!0),onLoadEnd:()=>n.layoutService.setAppbarLoader(!1),onClose:()=>{d()}});return(e,t)=>{c({id:"markdown_report_modal",render:N,onInit:()=>{const e="live"===t?"/markdown_report/live":"/markdown_report/backtest";te.push(e),p(e)},onMount:()=>{a(e),o(t),D()}})}},re="backtest-kit__groupHeader",oe="backtest-kit__groupRoot",ne="backtest-kit__symbolImage",le=B()({root:{[`& .${oe}:hover .${re}`]:{opacity:"1 !important"}}});function se(e){return I(e,"#000000")>I(e,"#FFFFFF")}const ce=[{type:L.Link,action:"back-action",label:e(q,{sx:{display:"block"}})},{type:L.Link,action:"back-action",label:"Main"},{type:L.Link,action:"back-action",label:"Markdown Report"}],de=[{action:"update-now",label:"Refresh",icon:()=>e(p,{icon:W,color:"#4caf50"})}],we=(t,a)=>({type:A.Group,className:oe,sx:{p:2},tabletColumns:"12",desktopColumns:"3",fields:[{type:A.Component,className:re,style:{transition:"opacity 500ms",opacity:.5},element:()=>e(x,{direction:"row",children:[e(J,{variant:"outlined",size:"small",color:"info",label:`${M.bullet} ${t}`,sx:{mb:1,pr:.5,fontSize:"14px",background:"white",cursor:"not-allowed"}}),e(i,{flex:1})]})},{type:A.Group,fields:a.map(({symbol:t,label:a,id:r,type:o,color:n})=>((t,a,r,o,n)=>({type:A.Component,desktopColumns:"6",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:({payload:l})=>e(H,{component:G,onClick:()=>{l.handleOpen(t,a)},sx:{width:"100%",background:n,color:"white",fontWeight:"bold",fontSize:"14px",height:"75px",minHeight:"75px",textWrap:"wrap",padding:"16px",[`& .${ne}`]:{transition:"filter 500ms"},"&:hover":{background:()=>se(n)?F(n,.33):X(n,.33),[`& .${ne}`]:{transition:"filter 500ms",filter:se(n)?"brightness(0.7) contrast(1.2)":"brightness(1.3) contrast(0.5)"}},transition:"background 500ms"},startIcon:e(T,{className:ne,symbol:r}),children:e(i,{sx:{overflow:"hidden",textOverflow:"ellipsis",width:"75px"},children:o})})}))(r,o,t,a,n))}]}),pe=[{id:"main",element:()=>{const{classes:t}=le(),{reloadTrigger:a,doReload:r}=N(),[o,{loading:l}]=O(async()=>await(async()=>{const[e,t,a]=await Promise.all([n.symbolGlobalService.getSymbolMap(),n.backtestGlobalService.list(),n.liveGlobalService.list()]),i={},r={};t.forEach(t=>{const a=e[t.symbol],r=t.strategyName;i[r]||(i[r]=[]),i[r].push({symbol:t.symbol,label:(null==a?void 0:a.displayName)||t.symbol,color:(null==a?void 0:a.color)||"#ccc",type:"backtest",id:t.id})}),a.forEach(t=>{const a=e[t.symbol],i=t.strategyName;r[i]||(r[i]=[]),r[i].push({symbol:t.symbol,label:(null==a?void 0:a.displayName)||t.symbol,color:(null==a?void 0:a.color)||"#ccc",id:t.id,type:"live"})});const o=Object.entries(i).sort(([,e],[,t])=>t.length-e.length).map(([e,t])=>we(e,t)),l=Object.entries(r).sort(([,e],[,t])=>t.length-e.length).map(([e,t])=>we(e,t));return l.length||o.length?[{type:A.Fragment,isVisible:()=>!!o.length,fields:[{type:A.Line,title:"Backtest"},{type:A.Group,columns:"12",fields:o}]},{type:A.Fragment,isVisible:()=>!!l.length,fields:[{type:A.Line,title:"Live"},{type:A.Group,columns:"12",fields:l}]}]:[]})(),{onLoadStart:()=>n.layoutService.setAppbarLoader(!0),onLoadEnd:()=>n.layoutService.setAppbarLoader(!1),deps:[a]}),s=ie(),c=(e,t)=>{s(e,t)};return e(U,{children:[e(R,{items:ce,actions:de,onAction:e=>{"back-action"===e&&n.routerService.push("/"),"update-now"===e&&r()}}),l||!o?e(C,{children:e(P,{variant:"h6",sx:{opacity:.5},children:"Loading..."})}):o.length?e(j,{children:[e($,{className:t.root,fields:o,payload:()=>({handleOpen:c})},a),e(i,{paddingBottom:"24px"})]}):e(C,{children:e(P,{variant:"h6",sx:{opacity:.5},children:"No pending signals"})})]})},isActive:e=>z(["/report"],e)}],he=({id:t})=>e(E,{history:n.routerService,onLoadStart:()=>n.layoutService.setAppbarLoader(!0),onLoadEnd:()=>n.layoutService.setAppbarLoader(!1),routes:pe,params:{id:t}});export{he as StatusPage,he as default};