1"use strict";(self.webpackChunkfront_end_ui=self.webpackChunkfront_end_ui||[]).push([[8209],{58209(e,t,n){n.r(t),n.d(t,{default:()=>ye});var a=n(97e3),i=n(32799),o=n(44719),l=n(64336),s=n(55428),r=n(50119),c=n(80554),d=n(5608),u=n(69565),m=n(26308),p=n(75851),h=n(85006),g=n(79894),v=n(36595),f=n(9950),b=n(41413),x=n(62601),y=n(74364),_=n(19216),N=n(17240),A=n(95443),S=n(77440);async function j(e){try{return await(0,S.y)(S.A.get(e))}catch(t){throw new Error("CryptoCompare request error: ".concat(t.status))}}function w(e){const t=e.split("_");return{fromSymbol:t[0],toSymbol:t[1]}}const k=n(97592).A.baseWebSocket||"";let T;const B=new Map,E=new Set;function C(e,t,n){e&&e.readyState===WebSocket.OPEN&&t&&n&&e.send(JSON.stringify({messageType:"SUBSCRIBE_STREAM_OHLC",params:{symbol:t,quote:n}}))}function P(){if(T&&[WebSocket.OPEN,WebSocket.CONNECTING].includes(T.readyState))return T;const e=new WebSocket(k);return T=e,e.onopen=function(){E.forEach((t=>{const n=t.split("~"),i=(0,a.A)(n,4),o=i[2],l=i[3];C(e,o,l)}))},e.onmessage=function(e){if(!e.data)return;const t=JSON.parse(e.data);if("STREAM_OHLC_UPDATE_V2"!==t.messageType)return;const n=t.data||{},a=n.buyPrice,i=n.timestamp,o=parseFloat(a),l=1e3*parseInt(i,10);E.forEach((e=>{const t=B.get(e);if(!t)return;const n=t.lastDailyBar,a=t.resolution,i=function(e,t){let n;switch(t){case"1D":n=1440;break;case"W":case"D":n=10080;break;default:n=t}const a=new Date(1e3*(e+60*n*1e3));return a.setDate(a.getDate()),a.getTime()/1e3}(null===n||void 0===n?void 0:n.time,a);let s;s=l>=i?{time:i,open:null===n||void 0===n?void 0:n.close,high:o,low:o,close:o}:(0,A.A)((0,A.A)({},n),{},{close:o,high:Math.max(o,null===n||void 0===n?void 0:n.high),low:Math.min(o,null===n||void 0===n?void 0:n.low)}),t.lastDailyBar=(0,A.A)({},s),t.handlers.forEach((e=>e.callback(s)))}))},e.onclose=function(){T===e&&(T=void 0),setTimeout((()=>{P()}),1e3)},e}const D=new Map;function G(){var e;const t=window.location.pathname.split("/").pop(),n=null===t||void 0===t||null===(e=t.split("-"))||void 0===e?void 0:e[1];return(null===n||void 0===n?void 0:n.toUpperCase())||"THB"}async function O(){const e=(await j("/ohlc/api/common/exchange-feed/config")).body;return{configurationData:(0,A.A)((0,A.A)({},e),{},{time_frames:[{text:"60",resolution:"60"}]})}}async function U(e){var t;const n=(await j("/ohlc/api/common/exchange-feed/symbols?quote=".concat(e||"THB"))).body;return(null===n||void 0===n||null===(t=n.symbolWithPriceScales)||void 0===t?void 0:t.length)>0?n.symbolWithPriceScales.map((e=>{const t=e.symbol.replace("/","_");return{symbol:t,pricescale:e.priceScale,full_name:t,description:t,exchange:"Exchange",type:"Crypto"}})):null===n||void 0===n?void 0:n.symbol.map((e=>{const t=e.symbol.replace("/","_");return{symbol:t,pricescale:100,full_name:t,description:t,exchange:"Exchange",type:"Crypto"}}))}const L={onReady:async e=>{const t=(await O()).configurationData;setTimeout((()=>e(t)))},searchSymbols:async(e,t,n,a)=>{if((await O()).configurationData.supports_search){a((await U(G())).filter((n=>{const a=""===t||n.exchange===t,i=-1!==n.full_name.toLowerCase().indexOf(e.toLowerCase());return a&&i})))}else a([])},resolveSymbol:async(e,t,n,a)=>{var i;const o=await U(G()),l=(await O()).configurationData,s=null===o||void 0===o?void 0:o.find((t=>t.full_name===e));if(!s)return void n("cannot resolve symbol");t({ticker:s.full_name,name:s.symbol,description:s.description,type:s.type,session:"24x7",timezone:"Asia/Bangkok",exchange:s.exchange,minmov:1,pricescale:null!==(i=s.pricescale)&&void 0!==i?i:100,precision:4,has_no_volume:!0,has_intraday:!0,has_daily:!0,has_weekly_and_monthly:!0,supported_resolutions:l.supported_resolutions,volume_precision:2,data_status:"streaming",time_frames:l.time_frames})},getBars:async(e,t,n,a,i)=>{const o=n.to,l=n.firstDataRequest,s=w(e.full_name),r=s.fromSymbol,c=s.toSymbol,d=(e=>{switch(e){case"1D":return"D";case"1W":return"W";default:return e}})(t);try{const t=(await j("/ohlc/api/common/exchange-feed/kline-v2\n\t\t\t\t?base=".concat(r,"\n\t\t\t\t&interval=").concat(d,"\n\t\t\t\t"e=").concat(c,"\n\t\t\t\t&limit=",500,"\n\t\t\t\t&endTime=").concat(o))).body;0===t.length&&a([],{noData:!0});const n=[],i="D"===d||"W"===d?86400:0;t.forEach((e=>{e[0]<o&&n.push({time:1e3*(Number(e[0])+i),low:Number(e[3]),high:Number(e[2]),open:Number(e[1]),close:Number(e[4]),volume:Number(e[5])})})),l&&D.set(e.full_name,(0,A.A)({},n[n.length-1])),a(n,{noData:!1})}catch(u){i(u)}},subscribeBars:(e,t,n,a,i)=>{!function(e,t,n,a,i,o){const l=P(),s=w(e.full_name),r="0~Maxbit~".concat(s.fromSymbol,"~").concat(s.toSymbol),c={id:a,callback:n},d=B.get(r);d?d.handlers.push(c):(B.set(r,{subscribeUID:a,resolution:t,lastDailyBar:o,handlers:[c]}),E.add(r),C(l,s.fromSymbol,s.toSymbol))}(e,t,n,a,0,D.get(e.full_name))},unsubscribeBars:e=>{!function(e){for(const t of B.keys()){const n=w(e),a=B.get(t),i=a.handlers.findIndex((t=>t.id===e));if(-1!==i&&(a.handlers.splice(i,1),0===a.handlers.length)){E.delete(t),T&&T.readyState===WebSocket.OPEN&&T.send(JSON.stringify({messageType:"UNSUBSCRIBE_STREAM_OHLC",params:{symbol
1:"".concat(n.fromSymbol),quote:"".concat(n.toSymbol)}})),B.delete(t);break}}}(e)}};var M=n(44414);const F="".concat("","/charting_library/"),q=e=>{let t=e.base,n=e.quote;const i=(0,b.ok)(),o=(0,a.A)(i,1)[0].get("theme"),l=(0,r.a$)(),s=(0,f.useState)(navigator.onLine),c=(0,a.A)(s,2),d=c[0],m=c[1],p={locale:"en",symbol:"".concat(t||"XAUT","_").concat(n||"THB"),interval:"15",fullscreen:!0,container:"tv_gold_chart_container",datafeed:L,timezone:"Asia/Bangkok",theme:o||"dark",libraryPath:F,studiesOverrides:{"ma.precision":1e4},enabled_features:["header_layouttoggle"],clientId:"*",userId:"0",numeric_formatting:{decimal_sign:"."},disabled_features:["use_localstorage_for_settings","volume_force_overlay"]};return(0,f.useEffect)((()=>{const e="dark"===p.theme,t={symbol:p.symbol,datafeed:p.datafeed,interval:p.interval,container:p.container,library_path:p.libraryPath,theme:p.theme,locale:p.locale,timezone:p.timezone,disabled_features:["header_symbol_search"],enabled_features:["study_templates","header_layouttoggle","support_multicharts"],client_id:p.clientId,user_id:p.userId,fullscreen:p.fullscreen,studies_overrides:p.studiesOverrides,numeric_formatting:p.numeric_formatting,toolbar_bg:e?"#151515":"#ffffff"},n=new N.H(t);try{n.onChartReady((()=>{n.applyOverrides({"paneProperties.background":e?"#151515":"#ffffff","paneProperties.backgroundGradientStartColor":e?"#151515":"#ffffff","paneProperties.backgroundGradientEndColor":e?"#151515":"#ffffff","paneProperties.vertGridProperties.color":e?"#2a2e39":"#e6e6e6","paneProperties.horzGridProperties.color":e?"#2a2e39":"#e6e6e6","scalesProperties.textColor":e?"#e6e6e6":"#2a2e39"}),n.setCSSCustomProperty("--tv-color-pane-background",e?"#151515":"#ffffff")}))}catch(a){(0,u.Hm)({message:l("trade.chart-view.message"),title:l("trade.chart-view.title")})}return()=>{n.remove()}}),[t,n,d,o]),(0,f.useEffect)((()=>{const e=()=>m(!0),t=()=>m(!1);return window.addEventListener("online",e),window.addEventListener("offline",t),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",t)}}),[]),(0,M.jsx)("div",{id:"tv_gold_chart_container"})},I=e=>{let t=e.coinBase,n=e.coinQuote;return(0,M.jsx)("div",{className:"trading-chart__big-chart chart__advanced-chart",children:(0,M.jsx)(q,{base:t,quote:n})})};var $=n(15541),W=n(26215),z=n(16674),R=n(22041),X=n(80669),H=n(93611),V=n(46413),Y=n(80086),K=n(32128),Q=n(37813),J=n(75012);const Z=new c.A(.001),ee=["XAUT","PAXG"],te=["THB","USDT"],ne=["BUY","SELL"],ae={XAUT:"https://gold.tether.to/",PAXG:"https://paxos.com/paxgold/"},ie={"Baht Gold":[.25,.5,1,2,5],Ounce:[.1,.5,1,5,10],Gram:[5,10,50,100,500]},oe=["Baht Gold","Ounce","Gram"],le={XAUT:x.imageCollection.xautBannerDesktop,PAXG:x.imageCollection.paxgBannerDesktop},se={XAUT:x.icons.xautCoins,PAXG:x.icons.paxgCoins},re={Ounce:{unitsPerToken:1,tokenPerUnit:1},"Baht Gold":{unitsPerToken:2.0403,tokenPerUnit:.4901},Gram:{unitsPerToken:31.1035,tokenPerUnit:.0321}},ce=function(e){return"".concat(arguments.length>1&&void 0!==arguments[1]&&arguments[1]?"":"\u2248").concat(e.toFixed(4))},de=e=>ee.includes(e),ue=e=>te.includes(e),me=(e,t)=>"/trade/gold/".concat(e.toLowerCase(),"-").concat(t.toLowerCase()),pe=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;return e.toLocaleString("en-US",{minimumFractionDigits:t,maximumFractionDigits:t})},he=function(e){return e&&e>0?pe(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:2):"-"},ge=e=>{const t=e.replace(/[^\d.]/g,"").split("."),n=(0,i.A)(t),a=n[0],o=void 0===a?"":a,l=n.slice(1);return l.length?"".concat(o,".").concat(l.join("")):o},ve=e=>"."===e||e.endsWith("."),fe=e=>/\.\d*0$/.test(e),be=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const a=new c.A(e).decimalPlaces(t,c.A.ROUND_DOWN).toFormat(t);return n?a:(e=>{if(!e.includes("."))return e;let t=e.length;for(;t>0&&"0"===e[t-1];)t-=1;return t>0&&"."===e[t-1]&&(t-=1),e.slice(0,t)})(a)},xe={pairId:0,name:"string",buyStatus:"string",sellStatus:"string",percentBuyFee:0,percentSellFee:0,tradeSettingId:0,minAmount:0,maxAmount:0,percentBuySlippage:0,minAmountMovement:0,minPriceMovementThb:0,minPriceMovementUsd:0,buyMinOrderSize:0,sellMinOrderSize:0,buy
1BetaGroups:[],sellBetaGroups:[],slippageDto:{defaultBuySlippage:"",defaultSellSlippage:"",pairId:0,pairName:"",percentBuySlippageFour:0,percentBuySlippageOne:0,percentBuySlippageThree:0,percentBuySlippageTwo:0,percentSellSlippageFour:0,percentSellSlippageOne:0,percentSellSlippageThree:0,percentSellSlippageTwo:0,slippageSettingId:0},minAmountDca:0,maxAmountDca:0,minPriceOrderGrid:0,maxPriceOrderGrid:0,minTrailingStopLoss:0,maxTrailingStopLoss:0},ye=()=>{var e,t,n,i,N,A,S,j,w,k,T,B,E;const C=(0,b.g)().pair,P=(0,b.Zp)(),D=(0,r.jL)(),G=(0,r.a$)(),O=(0,r.GV)(_.B$),U=(0,r.GV)(_.TA),L=(0,r.GV)(_.mR)||Q.pD,F=(0,r.GV)(_.zg),q=(0,r.GV)(g.Ep),ye=(0,r.GV)((e=>e.wallet.currencies)),_e=(0,r.GV)(v.My).slippageValue,Ne=(0,X.A)().userWallets,Ae=(0,H.q)().checkDeviation,Se=(0,f.useState)("Ounce"),je=(0,a.A)(Se,2),we=je[0],ke=je[1],Te=(0,f.useState)("BUY"),Be=(0,a.A)(Te,2),Ee=Be[0],Ce=Be[1],Pe=(0,f.useState)(!0),De=(0,a.A)(Pe,2),Ge=De[0],Oe=De[1],Ue=(0,f.useState)(!1),Le=(0,a.A)(Ue,2),Me=Le[0],Fe=Le[1],qe=(0,f.useState)(""),Ie=(0,a.A)(qe,2),$e=Ie[0],We=Ie[1],ze=(0,f.useState)(""),Re=(0,a.A)(ze,2),Xe=Re[0],He=Re[1],Ve=(0,f.useState)(null),Ye=(0,a.A)(Ve,2),Ke=Ye[0],Qe=Ye[1],Je=(0,f.useState)(null),Ze=(0,a.A)(Je,2),et=Ze[0],tt=Ze[1],nt=(0,f.useState)(xe),at=(0,a.A)(nt,2),it=at[0],ot=at[1],lt=(0,f.useState)([]),st=(0,a.A)(lt,2),rt=st[0],ct=st[1],dt=(0,f.useState)(!1),ut=(0,a.A)(dt,2),mt=ut[0],pt=ut[1],ht=(0,f.useState)(!1),gt=(0,a.A)(ht,2),vt=gt[0],ft=gt[1],bt=(0,f.useState)(),xt=(0,a.A)(bt,2),yt=xt[0],_t=xt[1],Nt=(0,f.useState)(null),At=(0,a.A)(Nt,2),St=At[0],jt=At[1],wt=(0,f.useState)(!1),kt=(0,a.A)(wt,2),Tt=kt[0],Bt=kt[1],Et=null===C||void 0===C?void 0:C.split("-"),Ct=null===Et||void 0===Et||null===(e=Et[0])||void 0===e?void 0:e.toUpperCase(),Pt=null===Et||void 0===Et||null===(t=Et[1])||void 0===t?void 0:t.toUpperCase(),Dt=de(Ct)?Ct:"XAUT",Gt=ue(Pt)?Pt:"THB",Ot=U["".concat(Dt,"_").concat(Gt)],Ut=null===(n=O["".concat(Dt).concat(Gt)])||void 0===n?void 0:n[4],Lt=F.base===Dt&&F.quote===Gt,Mt=Lt?(0,Y.A)({isBuy:!0,orderBook:L}).price:0,Ft=Lt?(0,Y.A)({isBuy:!1,orderBook:L}).price:0,qt=Number(F.percentChange24h||0),It=Lt?qt:void 0!==Ut?Number(Ut):void 0,$t={buy:Mt||(null===Ot||void 0===Ot?void 0:Ot.buyPrice),sell:Ft||(null===Ot||void 0===Ot?void 0:Ot.sellPrice),highChange:It},Wt=(null===(i=Ne.find((e=>e.currency===Gt)))||void 0===i?void 0:i.availableBalance)||0,zt=(null===(N=Ne.find((e=>e.currency===Dt)))||void 0===N?void 0:N.availableBalance)||0,Rt=re[we],Xt="Baht Gold"===we||"Gram"===we?4:3,Ht="BUY"===Ee?$t.buy||0:$t.sell||0,Vt=!!$t.buy&&!!$t.sell,Yt=(0,f.useMemo)((()=>{const e=rt.find((e=>e.isMin));return e?Number(e.value):0}),[rt]),Kt=(0,f.useMemo)((()=>(e=>[{goldUnit:e("gold-trade.modal.rows.troy-ounce"),token:ce(1,!0),bahtGold:ce(re["Baht Gold"].unitsPerToken),gram:ce(re.Gram.unitsPerToken)},{goldUnit:e("gold-trade.modal.rows.baht-gold"),token:ce(re["Baht Gold"].tokenPerUnit),bahtGold:ce(1,!0),gram:ce(re["Baht Gold"].tokenPerUnit*re.Gram.unitsPerToken)},{goldUnit:e("gold-trade.modal.rows.quarter-baht-gold"),token:ce(.25*re["Baht Gold"].tokenPerUnit),bahtGold:ce(.25,!0),gram:ce(.25*re["Baht Gold"].tokenPerUnit*re.Gram.unitsPerToken)},{goldUnit:e("gold-trade.modal.rows.gram"),token:ce(re.Gram.tokenPerUnit),bahtGold:ce(re.Gram.tokenPerUnit*re["Baht Gold"].unitsPerToken),gram:ce(1,!0)}])(G)),[G]),Qt=(0,f.useMemo)((()=>new c.A(Yt||0).dividedBy(100)),[Yt]),Jt=$t.buy?$t.buy/Rt.unitsPerToken:void 0,Zt=$t.sell?$t.sell/Rt.unitsPerToken:void 0,en="".concat(Dt,"_").concat(Gt),tn="BUY"===Ee,nn=(null===it||void 0===it||it[tn?"buyStatus":"sellStatus"],it.buyStatus!==h.n$.BETA||Tt?it.buyStatus:h.n$.OFF),an=it.sellStatus!==h.n$.BETA||Tt?it.sellStatus:h.n$.OFF,on=tn?nn:an,ln=on===h.n$.ON||on===h.n$.BETA,sn=(null===(A=ye.find((e=>e.shortName===Dt)))||void 0===A?void 0:A.status)===h.n$.MAINTENANCE,rn=(0,f.useCallback)(((e,t)=>{if(e.isNaN()||t.isNaN()||e.isNegative()||t.isNegative())return D(v.xN.setDefault()),void D(v.xN.setPrice(0));const n=tn?t.multipliedBy(Qt):e.multipliedBy(Ht).multipliedBy(Qt);D(v.xN.setAmountSpend(tn?t.toNumber():e.toNumber())),D(v.xN.setAmountReceive(tn?e.toNumber():t.toNumber())),D(v.xN.setFee(n.toNumber())),D(v.xN.setPrice(Ht))}),[Ht,D,Qt,tn]),cn=(0,f.useCallback)((e=>{const t=new c.A(e||0);if(!t.isFinite()||t.isNegative())return We(""),void D(v.xN.setDefault());const n=tn?Qt.isGreaterThanOrEqualTo(1)?new c.A(0):t.multipliedBy(Ht).dividedBy(new c.A(1).minus(Qt)):t.multipliedBy(Ht).multipliedBy(new c.A(1).minus(Qt));We(be(n,2)),rn(t,n)}),[Ht,Qt,tn,rn]),dn=(0,f.useCallback)((e=>{const t=new c.A(e||0);if(!t.isFinite()||t.isNegative())return He(""),void D(v.xN.setDefault());const n=Ht?tn?t.multipliedBy(new c.A(1).minus(Qt)).dividedBy(Ht):Qt.isGreaterThanOrEqualTo(1)?new c.A(0):t.dividedBy(new c.A(1).minus(Qt)).dividedBy(Ht):new c.A(0);He(be(n,Xt,4===Xt)),rn(n,t)}
1),[Xt,Ht,D,Qt,tn,rn]),un=(0,f.useCallback)((e=>{const t=new c.A(e||0);if(!t.isFinite()||t.isNegative())return He(""),We(""),void D(v.xN.setDefault());const n=tn?Qt.isGreaterThanOrEqualTo(1)?new c.A(0):t.multipliedBy(Ht).dividedBy(new c.A(1).minus(Qt)):t.multipliedBy(Ht).multipliedBy(new c.A(1).minus(Qt));He(be(t,Xt,4===Xt)),We(be(n,2)),rn(t,n)}),[Xt,Ht,D,Qt,tn,rn]),mn=(0,f.useCallback)((e=>{const t=new c.A(e||0);if(!t.isFinite()||t.isNegative())return We(""),He(""),void D(v.xN.setDefault());const n=Ht?tn?t.multipliedBy(new c.A(1).minus(Qt)).dividedBy(Ht):Qt.isGreaterThanOrEqualTo(1)?new c.A(0):t.dividedBy(new c.A(1).minus(Qt)).dividedBy(Ht):new c.A(0);We(be(t,2)),He(be(n,Xt,4===Xt)),rn(n,t)}),[Xt,Ht,D,Qt,tn,rn]),pn=(0,f.useMemo)((()=>"SELL"===Ee?[25,50,75,100]:ie[we]),[Ee,we]),hn="SELL"===Ee?"%":we;(0,f.useEffect)((()=>{Object.values(le).forEach((e=>{(new Image).src=e}))}),[]),(0,f.useEffect)((()=>{de(Ct)&&ue(Pt)||P(me("XAUT","THB"),{replace:!0})}),[Ct,P,Pt]),(0,f.useEffect)((()=>{D(R.Wm.setCurrentOrderType(h.$d.QUICK))}),[D]),(0,f.useEffect)((()=>{D(R.Wm.setCurrentOrderSide(tn?h.gN.BUY:h.gN.SELL))}),[D,tn]),(0,f.useEffect)((()=>{D((0,_.n)())}),[D,Dt,Gt]),(0,f.useEffect)((()=>{q?l.A.getTradeSetting({symbol:en}).then((e=>{let t=e.body;t&&ot(t)})).catch((()=>{})):ot(xe)}),[en,q]),(0,f.useEffect)((()=>{q?s.A.checkUserBeta([h.bD.GOLD_TRADE]).then((e=>{var t,n;let a=e.body;const i=null!==(t=null===a||void 0===a||null===(n=a.betaList.find((e=>e.settingKey===h.bD.GOLD_TRADE)))||void 0===n?void 0:n.granted)&&void 0!==t&&t;Bt(i)})).catch((()=>{Bt(!1)})):Bt(!1)}),[q]),(0,f.useEffect)((()=>{q?l.A.getTradingFeesInstrument(en,h.$d.QUICK).then((e=>{let t=e.ok,n=e.body;if(!t||!n)return void ct([]);const a=n.standardFee,i=n.profileFee,o=n.percentFeeDiscount,l=[];if(a&&l.push({name:"standardFee",value:a,isMin:!1}),i&&l.push({name:"profileFee",value:i,isMin:!1}),o&&l.push({name:"percentFeeDiscount",value:o,isMin:!0}),!l.length)return void ct([]);let s=0,r=new c.A(l[0].value);l.forEach(((e,t)=>{const n=new c.A(e.value);n.isLessThan(r)&&(r=n,s=t)})),l.forEach(((e,t)=>{e.isMin=t===s})),ct(l)})).catch((()=>{ct([])})):ct([])}),[en,q]),(0,f.useEffect)((()=>{var e,t;const n=it.slippageDto,a=new c.A("BUY"===Ee?null!==(e=null===n||void 0===n?void 0:n.percentBuySlippageTwo)&&void 0!==e?e:.1:null!==(t=null===n||void 0===n?void 0:n.percentSellSlippageTwo)&&void 0!==t?t:.1).toNumber();D(v.xN.setSlippage(a))}),[D,Ee,it]),(0,f.useEffect)((()=>{Qe(null)}),[we]),(0,f.useEffect)((()=>{We(""),He(""),Qe(null),tt(null),D(v.xN.setDefault())}),[D,Ee]),(0,f.useEffect)((()=>{if(Qe(null),!mt&&et){if("amount"===et||"quick"===et){const e=Xe.replace(/,/g,"");if(e&&!ve(e)&&!fe(e))return void un(e)}if("total"===et){const e=$e.replace(/,/g,"");!e||ve(e)||fe(e)||mn(e)}}}),[Xe,mt,et,Dt,Gt,Ee,un,mn,$e]);const gn=(0,f.useMemo)((()=>{if(!Xe)return"\u22480.0000 ".concat(we);const e=new c.A(Xe.replace(/,/g,"")||0).multipliedBy(Rt.unitsPerToken);return"\u2248".concat(pe(e.toNumber(),4)," ").concat(we)}),[Xe,we,Rt.unitsPerToken]),vn=(0,f.useMemo)((()=>"1 ".concat(Dt," (\u2248").concat(pe(Rt.unitsPerToken,4)," ").concat(we,")")),[Dt,we,Rt.unitsPerToken]),fn=(0,f.useMemo)((()=>"Ounce"===we?"":"".concat(pe(Rt.tokenPerUnit,4)," ").concat(Dt," (\u22481 ").concat(we,")")),[Dt,we,Rt.tokenPerUnit]),bn=(0,f.useMemo)((()=>{const e=zt*Rt.unitsPerToken,t=zt*Ht;return"\u2248".concat(pe(e,4)," ").concat(we," \u2248").concat(pe(t,2)," ").concat(Gt)}),[zt,Ht,Gt,we,Rt.unitsPerToken]),xn=e=>{const t=((e,t)=>{const n=e.split("."),i=(0,a.A)(n,2),o=i[0],l=i[1];return void 0===l||e.endsWith(".")?e:"".concat(o,".").concat(l.slice(0,t))})(ge(e),Xt);return Qe(null),tt("amount"),t?ve(t)?(He(t),void("."===t&&(We(""),D(v.xN.setDefault())))):Ht?fe(t)?(He(t),void cn(t)):void un(t):(He(t),We(""),void D(v.xN.setDefault())):(He(""),We(""),void D(v.xN.setDefault()))},yn="BUY"===Ee?"".concat(G("gold-trade.available-prefix"),": ").concat(pe(Wt,2)," ").concat(Gt):"".concat(G("gold-trade.available-prefix"),": ").concat(pe(zt,4)," ").concat(Dt),_n=(0,f.useMemo)((()=>new c.A(Xe.replace(/,/g,"")||0)),[Xe]),Nn=(0,f.useMemo)((()=>new c.A($e.replace(/,/g,"")||0)),[$e]),An=(0,f.useMemo)((()=>
1{if(!Xe||_n.isNaN())return"";const e=new c.A((null===it||void 0===it?void 0:it.minAmount)||0),t=e.isGreaterThan(Z)?e:Z;return _n.isLessThanOrEqualTo(0)||_n.isLessThan(t)?G("trade.minAmount",{min:t.toNumber()}):_n.isGreaterThan((null===it||void 0===it?void 0:it.maxAmount)||0)?G("trade.maxAmount",{max:null===it||void 0===it?void 0:it.maxAmount}):"SELL"===Ee&&_n.isGreaterThan(zt||0)?G("trade.over-balance"):""}),[Xe,zt,_n,Ee,it,G]),Sn=(0,f.useMemo)((()=>!$e||Nn.isNaN()?"":Nn.isLessThanOrEqualTo(0)?G("trade.minTotal",{min:0,unit:Gt}):"BUY"===Ee&&Nn.isLessThan((null===it||void 0===it?void 0:it.buyMinOrderSize)||0)?G("trade.minTotal",{min:null===it||void 0===it?void 0:it.buyMinOrderSize,unit:Gt}):"SELL"===Ee&&Nn.isLessThan((null===it||void 0===it?void 0:it.sellMinOrderSize)||0)?G("trade.minTotal",{min:null===it||void 0===it?void 0:it.sellMinOrderSize,unit:Gt}):"BUY"===Ee&&Nn.isGreaterThan(Wt||0)?G("trade.over-balance"):""),[Wt,Nn,Gt,Ee,it,G,$e]),jn=!Vt||!Xe||!$e||_n.isLessThanOrEqualTo(0)||!!An||!!Sn,wn=()=>{pt(!1),jt(null)},kn=()=>{D(v.xN.setDefault()),He(""),We(""),Qe(null),tt(null)},Tn=(0,f.useCallback)((async()=>{if(!ln)return;const e=new c.A($e.replace(/,/g,"")||0),t=new c.A(Xe.replace(/,/g,"")||0),n="amount"===et||"quick"===et,a=n?null:e.toNumber(),i=n?t.toNumber():null,o=n?null:e.toNumber(),s=n?t.toNumber():null,r=await l.A.postPlaceOrder({orderSide:Ee,coinPair:en,price:String((0,K.K$)(Ht,"THB"===Gt?it.minPriceMovementThb||m.Fw:it.minPriceMovementUsd||m.Fw)),originPrice:0,total:tn?a:o,amount:tn?i:s,slippage:_e,orderType:"LIMIT"});if(r.error)return wn(),void(e=>{var t;"wallet.error.insufficient-balance"!==(null===e||void 0===e?void 0:e.message)?(0,u.Hm)({title:G("gold-trade.trade-error-title"),message:"lp.error.trading.stop-price-invalid"===(null===e||void 0===e?void 0:e.message)?e.message:null!==(t=null===e||void 0===e?void 0:e.message)&&void 0!==t?t:"Unable to ".concat(Ee.toLowerCase()," ").concat(Dt),onOk:kn}):(0,u.jr)({title:null!==e&&void 0!==e&&e.message?e.message:"",message:null===e||void 0===e?void 0:e.message,onOk:()=>P("/my/wallet")})})(r.error);r.body&&(_t(r.body),ft(!0),D((0,J.t)()),D(R.Wm.setRefreshOrderHistory())),wn()}),[Xe,Ht,D,wn,en,tn,ln,et,Gt,Ee,it,_e,$e]),Bn=(0,V.A)(Tn),En=(0,V.A)((async()=>{await Ae({price:Number((0,K.K$)(Ht||0,m.Fw)),orderSide:tn?h.gN.BUY:h.gN.SELL,instrument:en,onSuccess:Bn,onFail:wn})}));return(0,M.jsxs)("div",{className:"gold-trade-page",children:[(0,M.jsxs)("div",{className:"gold-trade-page__heading",children:[(0,M.jsx)("h1",{children:G("gold-trade.page-title")}),(0,M.jsxs)("div",{className:"gold-trade-page__heading-controls",children:[(0,M.jsx)("div",{className:"gold-trade-page__quote-switch",children:te.map((e=>(0,M.jsx)("button",{type:"button",className:e===Gt?"active":"",onClick:()=>P(me(Dt,e)),children:e},e)))}),(0,M.jsx)("button",{type:"button",className:"gold-trade-page__chart-toggle ".concat(Ge?"active":""),onClick:()=>Oe((e=>!e)),"aria-label":G(Ge?"gold-trade.aria.hide-chart":"gold-trade.aria.show-chart"),children:(0,M.jsx)("img",{src:x.icons.barChartDark,alt:"",width:18,height:18})})]})]}),(0,M.jsxs)("div",{className:"gold-trade-page__content ".concat(Ge?"":"gold-trade-page__content--form-only"),children:[(0,M.jsxs)("section",{className:"gold-trade-panel",children:[(0,M.jsx)("div",{className:"gold-trade-panel__asset-tabs",children:ee.map((e=>(0,M.jsxs)("button",{type:"button",className:e===Dt?"active":"",onClick:()=>P(me(e,Gt)),children:[(0,M.jsx)("img",{src:se[e],alt:"".concat(e," icon"),width:22,height:22}),(0,M.jsxs)("span",{children:[e,"/",Gt]})]},e)))}),(0,M.jsx)("div",{className:"gold-trade-panel__unit-tabs",children:oe.map((e=>(0,M.jsx)("button",{type:"button",className:e===we?"active":"",onClick:()=>ke(e),children:e},e)))}),(0,M.jsxs)("div",{className:"gold-balance-card ".concat(Dt.toLowerCase()),children:[(0,M.jsx)("img",{className:"gold-balance-card__banner",src:le[Dt],alt:"".concat(Dt," banner")}),(0,M.jsxs)("div",{className:"gold-balance-card__content",children:[(0,M.jsxs)("span",{className:"gold-balance-card__label",children:[G("gold-trade.my-asset-prefix")," ",Dt]}),(0,M.jsxs)("div",{className:"gold-balance-card__amount",children:[(0,M.jsx)("span",{children:pe(zt,4)}),(0,M.jsx)("strong",{children:Dt})]}),(0,M.jsx)("p",{children:bn})]})]}),(0,M.jsxs)("div",{className:"gold-price-compare",children:[(0,M.jsxs)("div",{className:"gold-price-compare__summary",children:[(0,M.jsxs)("div",{className:"gold-price-compare__title",children:[(0,M.jsx)("span",{children:G("gold-trade.unit-comparison-title")}),(0,M.jsx)("button",{type:"button",className:"gold-price-compare__info-button",onClick:()=>Fe(!0),"aria-label":G("gold-trade.aria.open-unit-comparison"),children:(0,M.jsx)(y.A,{alt:"info",src:x.icons.info,size:{width:16,height:16}})})]}),(0,M.jsx)("p",{children:vn}),fn&&(0,M.jsx)("p",{children:fn})]}),(0,M.jsx)("div",{className:"gold-price-compare__divider"}),(0,M.jsxs)("div",{className:"gold-price-compare__prices",children:[(0,M.jsxs)("div",{children:[(0,M.jsx)("span",{children:G("gold-trade.buy")}),(0,M.jsx)("p",{className:"gold-price-compare__value",children:he($t.buy)}),(0,M.jsx)("small",{children:"Ounce"===we?"-":he(Jt)})]}),(0,M.jsxs)("div",{children:[(0,M.jsx)("span",{children:G("gold-trade.sell")}),(0,M.jsx)("p",{className:"gold-price-compare__value",children:he($t.sell)}),(0,M.jsx)("small",{children:"Ounce"===we?"-":he(Zt)})]})]})]}),(0,M.jsx)("div",{className:"gold-side-toggle",children:ne.map((e=>(0,M.jsx)("button",{type:"button",className:e===Ee?"active":"",onClick:()=>{var t;(t=e)!==Ee&&(Ce(t),He(""),We(""),Qe(null),tt(null),pt(!1),jt(null),D(v.xN.setDefault()))},children:e},e)))}),(0,M.jsx)("div",{className:"gold-available-balance",children:yn}),(0,M.jsxs)("label",{className:"gold-form-field",children:[(0,M.jsx)("input",{value:$e,onChange:e=>(e=>{const t=ge(e);return Qe(null),tt("total"),t?ve(t)?(We(t),void("."===t&&(He(""),D(v.xN.setDefault())))):Ht?fe(t)?(We(t),void dn(t)):void mn(t):(We(t),He(""),void D(v.xN.setDefault())):(We(""),He(""),void D(v.xN.setDefault()))})(e.target.value),placeholder:G("gold-trade.placeholder.total")}),(0,M.jsx)("span",{children:Gt})]}),!!Sn&&(0,M.jsx)("span",{className:"gold-form-error text-red ".concat(p.A.p6),children:Sn}),(0,M.jsx)("div",{className:"gold-quick-amounts ".concat("SELL"===Ee?"is-sell":""),children:pn.map((e=>(0,M.jsx)("button",{type:"button",className:Ke===e?"active":"",onClick:()=>(e=>{if(!Ht)return;if(Qe(e),tt("quick"),"SELL"===Ee){const t=new c.A(zt).multipliedBy(e).dividedBy(100);return void un(t)}const t=new c.A(e).multipliedBy(Rt.tokenPerUnit);un(t)})(e),children:"SELL"===Ee?(0,M.jsxs)("strong",{children:[e,"%"]}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)("strong",{children:e}),(0,M.jsx)("span",{children:hn})]})},e)))}),(0,M.jsxs)("div",{className:"gold-amount-row",children:[(0,M.jsxs)("label",{className:"gold-form-field",children:[(0,M.jsx)("input",{value:Xe,onChange:e=>xn(e.target.value),placeholder:G("gold-trade.placeholder.amount")}),(0,M.jsx)("span",{children:Dt})]}),!!An&&(0,M.jsx)("span",{className:"gold-form-error text-red ".concat(p.A.p6),children:An}),(0,M.jsxs)("div",{className:"gold-equivalent",children:[(0,M.jsx)("span",{children:G("gold-trade.equivalent")}),(0,M.jsx)("strong",{children:gn})]})]}),(0,M.jsx)(d.Ay,{typeElement:"div",disabled:q&&jn,text:(0,M.jsxs)("button",{type:"button",className:"gold-submit-button ".concat("SELL"===Ee?"sell":"buy"," ").concat(q&&jn?"disabled":""),disabled:q&&jn,children:[Ee," ",Dt]}),isLogin:!0,needKycApproved:!0,needCheckReKyc:!0,isCheckBankStatus:!0,isCryptoKnowledge:!0,needEnableTradeByAdmin:!0,needEnableTrade:!0,maintenanceAsset:sn,maintenanceBuy:tn&&nn===h.n$.MAINTENANCE,offBuy:tn&&nn===h.n$.OFF,maintenanceSell:!tn&&an===h.n$.MAINTENANCE,offSell:!tn&&an===h.n$.OFF,onClick:()=>{const e=new c.A($e.replace(/,/g,"")||0),t=new c.A(Xe.replace(/,/g,"")||0),n=tn?Wt:zt;An||Sn||Vt&&((tn?e:t).isGreaterThan(n||0)?(0,u.jr)({message:G("gold-trade.insufficient-balance.message"),title:G("gold-trade.insufficient-balance.title"),onOk:()=>P("/my/wallet")}):(jt({bestPrice:Ht,orderSide:tn?"buy":"sell",coinBase:Dt,coinQuote:Gt,tiersFeeTrading:Yt,tradingFees:rt,initialValues:{amount:tn?Xe:$e}}),pt(!0)))}}),(0,M.jsxs)("div",{className:"gold-note-box",children:[(0,M.jsx)(y.A,{alt:"info",src:x.icons.info,size:{width:18,height:18}}),(0,M.jsxs)("p",{children:[G("gold-trade.quick-order-note-prefix",{asset:Dt})," ",(0,M.jsxs)("span",{className:"gold-note-box__menu",children:[(0,M.jsx)("img",{src:se.XAUT,alt:"XAUT",width:14,height:14}),(0,M.jsx)("img",{src:se.PAXG,alt:"PAXG",width:14,height:14})]})," ",G("gold-trade.quick-order-note-suffix")]})]})]}),Ge&&(0,M.jsxs)("section",{className:"gold-chart-panel",children:[(0,M.jsxs)("div",{className:"gold-chart-panel__header",children:[(0,M.jsxs)("div",{className:"gold-chart-panel__pair",children:[(0,M.jsx)(y.A,{alt:"gold asset icon",src:se[Dt],size:{width:26,height:26}}),(0,M.jsxs)("span",{children:[Dt,"/",Gt]})]}),(0,M.jsxs)("div",{className:"gold-chart-panel__stats",children:[(0,M.jsx)("span",{children:G("gold-trade.chart.24h-change")}),(0,M.jsx)("strong",{children:void 0!==$t.highChange?"".concat(pe($t.highChange),"%"):"-"})]}),(0,M.jsxs)("button",{type:"button",className:"gold-chart-panel__asset-link",onClick:()=>P("/asset-information",{state:{assetSN:Dt}}),children:[(0,M.jsx)("img",{src:x.icons.info,alt:"info",width:18,height:18}),(0,M.jsx)("span",{children:G("gold-trade.asset-information")})]})]}),(0,M.jsx)("div",{className:"gold-chart-panel__chart",children:(0,M.jsx)(I,{coinBase:Dt,coinQuote:Gt})})]})]}),(0,M.jsx)("section",{className:"gold-trade-page__history",children:(0,M.jsx)("div",{className:"trading__history",children:(0,M.jsx)(z.A,{isDCAOn:!0,isGRIDOn:!0})})}),mt&&(0,M.jsx)($.A,{visible:mt,onClosePreview:wn,onSubmit:En,initialValues:null!==(S=null===St||void 0===St?void 0:St.initialValues)&&void 0!==S?S:{amount:""},orderSide:null!==(j=null===St||void 0===St?void 0:St.orderSide)&&void 0!==j?j:"buy",coinBase:null!==(w=null===St||void 0===St?void 0:St.coinBase)&&void 0!==w?w:Dt,coinQuote:null!==(k=null===St||void 0===St?void 0:St.coinQuote)&&void 0!==k?k:Gt,tiersFeeTrading:null!==(T=null===St||void 0===St?void 0:St.tiersFeeTrading)&&void 0!==T?T:Yt,tradingFees:null!==(B=null===St||void 0===St?void 0:St.tradingFees)&&void 0!==B?B:rt,orderCategory:h.$d.QUICK,bestPrice:null!==(E=null===St||void 0===St?void 0:St.bestPrice)&&void 0!==E?E:Ht}),vt&&(0,M.jsx)(W.A,{visible:vt,coinBase:Dt,coinQuote:Gt,isBuy:tn,data:yt,onClose:e=>{ft(!1),jt(null),e&&kn()},isLimitOrder:!1}),(0,M.jsx)(o.A,{open:Me,onCancel:()=>Fe(!1),footer:null,centered:!0,width:480,className:"gold-unit-comparison-modal",closable:!1,children:(0,M.jsxs)("div",{className:"gold-unit-comparison-modal__content",children:[(0,M.jsxs)("div",{className:"gold-unit-comparison-modal__header",children:[(0,M.jsxs)("h2",{children:[G("gold-trade.unit-comparison-title")," (",Dt,")"]}),(0,M.jsx)("button",{type:"button",className:"gold-unit-comparison-modal__close",onClick:()=>Fe(!1),"aria-label":G("gold-trade.aria.close-unit-comparison"),children:(0,M.jsx)(y.A,{alt:"close",src:x.icons.close,size:{width:14,height:14}})})]}),(0,M.jsx)("p",{children:G("gold-trade.modal.description-1",{asset:Dt})}),(0,M.jsx)("p",{children:G("gold-trade.modal.description-2")}),(0,M.jsxs)("p",{children:[G("gold-trade.modal.more-details"),(0,M.jsx)("br",{}),Dt," ",(0,M.jsx)("a",{href:ae[Dt],target:"_blank",rel:"noreferrer",children:ae[Dt]})]}),(0,M.jsxs)("div",{className:"gold-unit-comparison-modal__table",children:[(0,M.jsxs)("div",{className:"gold-unit-comparison-modal__row gold-unit-comparison-modal__row--head",children:[(0,M.jsx)("span",{children:G("gold-trade.modal.table.gold-unit")}),(0,M.jsx)("span",{children:Dt}),(0,M.jsx)("span",{children:G("gold-trade.modal.table.baht-gold")}),(0,M.jsx)("span",{children:G("gold-trade.modal.table.gram")})]}),Kt.map((e=>(0,M.jsxs)("div",{className:"gold-unit-comparison-modal__row",children:[(0,M.jsx)("span",{children:e.goldUnit}),(0,M.jsx)("span",{children:e.token}),(0,M.jsx)("span",{children:e.bahtGold}),(0,M.jsx)("span",{children:e.gram})]},e.goldUnit)))]}),(0,M.jsx)("p",{className:"gold-unit-comparison-modal__footnote",children:G("gold-trade.modal.footnote",{asset:Dt})})]})})]})}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.