diff --git a/apps/cli/frontend/assets/SimpleGridForm-BMdftmE-.js b/apps/cli/frontend/assets/SimpleGridForm-E2pE-hYE.js similarity index 99% rename from apps/cli/frontend/assets/SimpleGridForm-BMdftmE-.js rename to apps/cli/frontend/assets/SimpleGridForm-E2pE-hYE.js index 8ff79682..614d8638 100644 --- a/apps/cli/frontend/assets/SimpleGridForm-BMdftmE-.js +++ b/apps/cli/frontend/assets/SimpleGridForm-E2pE-hYE.js @@ -1 +1 @@ -import{I as h,O as y,J as O,K as Y,r as u,L as ee,M as te,_ as v,N as ne,P as se,Q as re,T as ae,U as oe,V as ie,W as le,j as s,X as w,Y as ce,e as f,t as b,b as m,Z as ue,n as de,o as he,$ as me,a0 as xe,S as F,a1 as pe,a2 as ge,a3 as fe,a4 as be,a5 as ye,a6 as je,l as ve,a7 as Ce,a8 as Se,a9 as Ie,aa as Fe,ab as $,ac as Pe,ad as L,ae as N,af as T,ag as we,ah as Be,ai as M,aj as V,v as Ge,B as W,ak as Le,al as A,am as Ne,an as H,ao as Te,G as g,ap as Ae,d as _,aq as qe,ar as Ee,as as ze,at as ke}from"./index-C0B7FSMw.js";function Qe(e,n,t){return h(e).minus(n).div(t-1).toNumber()}function Re(e,n,t,r){const a=Qe(e,n,t);return Array.from({length:t}).map((i,o)=>({price:h(n).plus(h(a).mul(o)).toNumber(),quantity:r}))}function U(e,n){return e=String(e),n!=null&&n.ignoreTrailingZeros&&(e=new h(e).toString()),e.includes(".")?e.split(".")[1].length:0}function G(e,n){const t=n.decimals.price,r=U(e,{ignoreTrailingZeros:!0});return t===void 0?new h(e).toFixed(r):r>t?new h(e).toFixed(t,h.roundDown):new h(e).toFixed(r)}function $e(e,n){const t=n.decimals.amount,r=U(e,{ignoreTrailingZeros:!0});return t===void 0?new h(e).toFixed(r):r>t?new h(e).toFixed(t,h.roundDown):new h(e).toFixed(r)}function St(e,n,t,r,a){return Re(e,n,t,r).map(o=>{const l=G(o.price,a);return{...o,price:new h(l).toNumber()}})}function Ve(e){const n=e.reduce((r,a)=>a.buy.status===y.Filled&&a.sell.status===y.Idle?h(r).plus(a.sell.quantity).toNumber():r,0),t=e.reduce((r,a)=>{if(a.buy.status===y.Idle&&a.sell.status===y.Idle){const o=h(a.buy.quantity).times(a.buy.price);return h(r).plus(o).toNumber()}return r},0);return{baseCurrencyAmount:n,quoteCurrencyAmount:t}}function De(e,n,t){const r=n.findIndex(c=>c.price===e.price&&c.quantity===e.quantity);if(r===-1)throw new Error(`Cannot find grid line index of { price: ${e.price}, quantity: ${e.quantity} }`);const a=n[r],i=n[r-1],o=n[r+1],l=h(t).minus(a.price).abs();if(i){const c=h(t).minus(i.price).abs();if(h(c).lt(l))return!1}if(o){const c=h(t).minus(o.price).abs();if(h(c).lte(l))return!1}return!0}function Oe(e,n){const t=e[n+1];if(!t)throw new Error(`nextGridLinePrice: Grid line at index ${n} doesn't exists`);return t.price}function Me(e,n){return e.flatMap((t,r)=>{if(r===e.length-1)return[];const a=Oe(e,r);return De(t,e,n)||t.price>n?[{buy:{price:t.price,quantity:t.quantity,status:y.Filled},sell:{price:a,quantity:t.quantity,status:y.Idle}}]:[{buy:{price:t.price,quantity:t.quantity,status:y.Idle},sell:{price:a,quantity:t.quantity,status:y.Idle}}]})}function We(e,n,t){const r=Me(n,t),{baseCurrencyAmount:a,quoteCurrencyAmount:i}=Ve(r),o=i+a*t;return{baseCurrencyAmount:$e(a,e.filters),quoteCurrencyAmount:G(i,e.filters),totalInQuoteCurrency:G(o,e.filters)}}const It=e=>e.gridBotForm,He=e=>e.gridBotForm.type,_e=e=>e.gridBotForm.exchangeAccountId,Ue=e=>e.gridBotForm.exchangeCode,j=e=>e.gridBotForm.symbolId,Ze=e=>e.gridBotForm.highPrice,Je=e=>e.gridBotForm.lowPrice,Ke=e=>e.gridBotForm.gridLinesNumber,Xe=e=>e.gridBotForm.quantityPerGrid,Ye=e=>e.gridBotForm.botName,q=e=>e.gridBotForm.gridLines,Z=e=>n=>n.gridBotForm.gridLines[e],Ft=e=>e.gridBotForm.barSize;function et(e){return e.size}function tt(e){const{value:n,id:t,rootRef:r}=e,a=O();if(a===null)throw new Error("No TabContext provided");const{value:i,getTabId:o}=a,l=Y(t),c=u.useRef(null),d=ee(c,r),x=u.useMemo(()=>({id:l,ref:c}),[l]),{id:p}=te(n??et,x),C=p!==i,P=p!==void 0?o(p):void 0;return{hidden:C,getRootProps:(B={})=>v({"aria-labelledby":P??void 0,hidden:C,id:l??void 0},B,{ref:d}),rootRef:d}}function nt(e){return ne("MuiTabPanel",e)}se("MuiTabPanel",["root","hidden","sizeSm","sizeMd","sizeLg","horizontal","vertical","colorPrimary","colorNeutral","colorDanger","colorSuccess","colorWarning","colorContext","variantPlain","variantOutlined","variantSoft","variantSolid"]);const st=["children","value","component","color","variant","size","slots","slotProps","keepMounted"],rt=e=>{const{hidden:n,size:t,variant:r,color:a,orientation:i}=e,o={root:["root",n&&"hidden",t&&`size${w(t)}`,i,r&&`variant${w(r)}`,a&&`color${w(a)}`,t&&`size${w(t)}`]};return ce(o,nt,{})},at=re("div",{name:"JoyTabPanel",slot:"Root",overridesResolver:(e,n)=>n.root})(({theme:e,ownerState:n})=>{var t;return v({display:n.hidden?"none":"block",padding:"var(--Tabs-spacing)",flexGrow:1,fontFamily:e.vars.fontFamily.body},e.typography[`body-${n.size}`],(t=e.variants[n.variant])==null?void 0:t[n.color])}),D=u.forwardRef(function(n,t){const r=ae({props:n,name:"JoyTabPanel"}),{orientation:a}=O()||{orientation:"horizontal"},i=u.useContext(oe),{children:o,value:l=0,component:c,color:d="neutral",variant:x="plain",size:p,slots:C={},slotProps:P={},keepMounted:E=!1}=r,B=ie(r,st),{hidden:z,getRootProps:J}=tt(v({},r,{value:l})),k=v({},r,{orientation:a,hidden:z,size:p??i,color:d,variant:x}),K=rt(k),X=v({},B,{component:c,slots:C,slotProps:P}),[Q,R]=le("root",{ref:t,elementType:at,getSlotProps:J,externalForwardedProps:X,additionalProps:{role:"tabpanel",ref:t,as:c},ownerState:k,className:K.root});return E?s.jsx(Q,v({},R,{children:o})):s.jsx(Q,v({},R,{children:!z&&o}))}),ot=({disabled:e})=>{const n=f(),[t]=b.exchangeAccount.list.useSuspenseQuery(),r=m(_e),a=o=>{if(o===null)throw new Error("ExchangeAccountField: Cannot reset exchange account input");n(de(o.id)),n(he(o.exchangeCode))},i=t.find(o=>o.id===r);return s.jsx(ue,{onChange:a,value:i,disabled:e})},it=({disabled:e})=>{const n=f(),t=m(Ue),[r]=b.symbol.list.useSuspenseQuery(t),a=m(j),i=l=>{if(l===null)throw new Error("PairField: Cannot reset symbol input");n(xe(l.symbolId))},o=r.find(l=>l.symbolId===a);return s.jsx(me,{exchangeCode:t,onChange:i,value:o||null,disabled:e})},lt=36,I=({width:e="100%",withLabel:n})=>{const t=s.jsx(F,{animation:"wave",height:lt,variant:"rectangular",width:e});return n?s.jsxs(s.Fragment,{children:[s.jsx(F,{animation:"wave",height:20,sx:{mb:"6px"},variant:"text",width:72}),t]}):t};function ct(e,n){if(e.length===0)return-1;if(e.length===1)return e[0];const t=e.map(i=>Math.abs(i-n)),r=Math.min(...t),a=t.indexOf(r);return e[a]}function ut(e,n){const t=e.map(a=>a.price),r=ct(t,n);return t.map(a=>pe(a,t,r))}const Pt=({symbolId:e,barSize:n,onBarSizeChange:t,gridLines:r,currentAssetPrice:a})=>{const i=u.useDeferredValue(e),o=e!==i,l=u.useMemo(()=>ut(r,a),[r,a]),[c,d]=u.useState(!0);return s.jsx(u.Suspense,{fallback:s.jsx(F,{animation:"wave",height:ge,variant:"rectangular",width:"100%"}),children:s.jsxs(fe,{barSize:n,dimmed:o,priceLines:l,showPriceLines:c,symbolId:i,children:[s.jsx(u.Suspense,{fallback:s.jsx(I,{width:232}),children:s.jsx(ot,{})}),s.jsx(u.Suspense,{fallback:s.jsx(I,{width:232}),children:s.jsx(it,{})}),s.jsx(be,{onChange:x=>{t&&t(x)},value:n,whitelist:ye}),s.jsx(je,{}),s.jsx(ve,{display:"flex",children:s.jsx(Ce,{gridVisible:c,hideTradesButton:!0,onGridVisibleChange:d})})]})})},S={simple:"simple",advanced:"advanced"},wt=({simpleForm:e,advancedForm:n})=>{const t=m(He),r=f(),a=(i,o)=>{o!==null&&r(Pe(o))};return s.jsxs(Se,{defaultValue:S.simple,onChange:(i,o)=>{a(i,o)},sx:{borderRadius:"md",overflow:"auto",boxShadow:"sm"},value:t,children:[s.jsxs(Ie,{disableUnderline:!0,sx:{[`& .${Fe.root}`]:{bgcolor:"background.backdrop",'&[aria-selected="true"]':{bgcolor:"background.surface",fontWeight:"lg"}}},tabFlex:"auto",children:[s.jsx($,{disableIndicator:!0,value:S.simple,children:"Easy form"}),s.jsx($,{disableIndicator:!0,value:S.advanced,children:"Advanced form"})]}),s.jsx(D,{value:S.simple,children:e}),s.jsx(D,{value:S.advanced,children:n})]})},Bt=()=>{const e=f(),n=m(Ye),[t,r]=u.useState(n);u.useEffect(()=>{r(n)},[n]);const a=c=>{r(c.target.value)},i=()=>{t.length>0?e(V(t)):r(n)},o=()=>{e(V(Ge()))},l=t.length===0?"Must be defined":null;return s.jsxs(L,{error:!!l,children:[s.jsx(N,{children:"Bot name"}),s.jsx(T,{endDecorator:s.jsx(we,{onClick:o,children:s.jsx(Be,{})}),onBlur:i,onChange:a,value:t}),l?s.jsx(M,{children:l}):null]})},dt=e=>{const{className:n,gridLineIndex:t}=e,r=f(),a=()=>{r(Le(t))};return s.jsx(W,{className:n,color:"danger",onClick:a,size:"sm",children:"Remove"})},ht=e=>{const{className:n,gridLineIndex:t}=e,r=f(),{price:a}=m(Z(t)),[i,o]=u.useState(String(a));u.useEffect(()=>{o(`${a}`)},[a]);const l=m(j),[c]=b.symbol.getOne.useSuspenseQuery({symbolId:l}),d=p=>{o(p.target.value)},x=()=>{i.length>0?r(Ne({gridLineIndex:t,price:Number(i)})):o(String(a))};return s.jsx(A,{className:n,filter:c.filters,fullWidth:!0,label:"Price",onBlur:x,onChange:d,size:"sm",value:i})},mt=e=>{const{className:n,gridLineIndex:t,disabled:r}=e,a=f(),i=m(j),[o]=b.symbol.getOne.useSuspenseQuery({symbolId:i}),{quantity:l}=m(Z(t)),[c,d]=u.useState(`${l}`);u.useEffect(()=>{d(`${l}`)},[l]);const x=C=>{d(C.target.value)},p=()=>{isNaN(Number(c))?d(`${l}`):a(Te({gridLineIndex:t,quantity:Number(c)}))};return s.jsx(H,{className:n,disabled:r,filter:o.filters,fullWidth:!0,label:"Quantity",onBlur:p,onChange:x,size:"sm",value:c})},xt=e=>{const{gridLineIndex:n}=e,t=m(q),r=n===t.length-1;return s.jsxs(g,{alignItems:"flex-end",container:!0,spacing:2,children:[s.jsx(g,{xs:!0,children:s.jsx(u.Suspense,{fallback:s.jsx(F,{height:36,variant:"rectangular",width:200}),children:s.jsx(ht,{gridLineIndex:n})})}),s.jsx(g,{xs:!0,children:s.jsx(u.Suspense,{fallback:s.jsx(F,{height:36,variant:"rectangular",width:200}),children:s.jsx(mt,{disabled:r,gridLineIndex:n})})}),s.jsx(g,{xs:"auto",children:s.jsx(dt,{gridLineIndex:n})})]})},Gt=()=>{const e=f(),n=m(q),t=()=>{e(Ae({price:1,quantity:1}))},r=a=>n.length-1-a;return s.jsxs(g,{container:!0,spacing:2,children:[s.jsx(g,{xs:12,children:n.map((a,i)=>s.jsx(xt,{gridLineIndex:r(i)},i))}),s.jsx(g,{xs:12,children:s.jsx(W,{onClick:t,children:"Add"})})]})},pt=({baseCurrencyAmount:e,quoteCurrencyAmount:n,totalInQuoteCurrency:t})=>{const r=m(j),{baseCurrency:a,quoteCurrency:i}=_(r);return s.jsxs(M,{children:[s.jsxs("span",{children:[e," ",a]}),s.jsx("span",{children:" + "}),s.jsxs("span",{children:[n," ",i]}),s.jsx("span",{children:" ≈ "}),s.jsxs("span",{children:[t," ",i]})]})},Lt=e=>{const{className:n}=e,t=m(j),{quoteCurrency:r}=_(t),[a]=b.symbol.price.useSuspenseQuery({symbolId:t}),[i]=b.symbol.getOne.useSuspenseQuery({symbolId:t}),o=m(q),{baseCurrencyAmount:l,quoteCurrencyAmount:c,totalInQuoteCurrency:d}=We(i,o,a.price),x="investment-field";return s.jsxs(L,{className:n,children:[s.jsx(N,{htmlFor:x,children:"Investment"}),s.jsx(T,{disabled:!0,endDecorator:s.jsx(s.Fragment,{children:r}),id:x,type:"number",value:d}),s.jsx(pt,{baseCurrencyAmount:l,quoteCurrencyAmount:c,totalInQuoteCurrency:d})]})},gt=e=>{const{disabled:n,readOnly:t}=e,r=m(j),[a]=b.symbol.getOne.useSuspenseQuery({symbolId:r}),i=f(),o=m(Xe),[l,c]=u.useState(o);u.useEffect(()=>{c(o)},[o]);const d=p=>{c(p.target.value)},x=()=>{isNaN(Number(l))?c(o):i(qe(l))};return s.jsx(H,{disabled:n,filter:a.filters,fullWidth:!0,label:"Quantity per grid",onBlur:x,onChange:d,readOnly:t,required:!0,value:l})},ft="gridLevels",bt=e=>{const{disabled:n,readOnly:t}=e,r=f(),a=m(Ke),[i,o]=u.useState(a),l=d=>{o(d.target.valueAsNumber)},c=()=>{Number.isInteger(i)?r(Ee(i)):o(a)};return s.jsxs(L,{children:[s.jsx(N,{children:"Grid levels"}),s.jsx(T,{autoComplete:"off",disabled:n,name:ft,onBlur:c,onChange:l,readOnly:t,required:!0,type:"number",value:i})]})},yt=e=>{const{disabled:n,readOnly:t}=e,r=m(j),[a]=b.symbol.getOne.useSuspenseQuery({symbolId:r}),i=f(),o=m(Ze),[l,c]=u.useState(`${o}`);u.useEffect(()=>{c(`${o}`)},[o]);const d=p=>{c(p.target.value)},x=()=>{l.length>0?i(ze(Number(l))):c(`${o}`)};return s.jsx(A,{disabled:n,filter:a.filters,fullWidth:!0,label:"High price",onBlur:x,onChange:d,readOnly:t,value:l})},jt=e=>{const{disabled:n,readOnly:t}=e,r=m(j),[a]=b.symbol.getOne.useSuspenseQuery({symbolId:r}),i=f(),o=m(Je),[l,c]=u.useState(`${o}`);u.useEffect(()=>{c(`${o}`)},[o]);const d=p=>{c(p.target.value)},x=()=>{l.length>0?i(ke(Number(l))):c(`${o}`)};return s.jsx(A,{disabled:n,filter:a.filters,fullWidth:!0,label:"Low price",onBlur:x,onChange:d,readOnly:t,value:l})},Nt=()=>s.jsxs(g,{container:!0,spacing:2,children:[s.jsx(g,{md:6,xs:12,children:s.jsx(u.Suspense,{fallback:s.jsx(I,{withLabel:!0}),children:s.jsx(yt,{})})}),s.jsx(g,{md:6,xs:12,children:s.jsx(u.Suspense,{fallback:s.jsx(I,{withLabel:!0}),children:s.jsx(jt,{})})}),s.jsx(g,{md:6,xs:12,children:s.jsx(u.Suspense,{fallback:s.jsx(I,{withLabel:!0}),children:s.jsx(gt,{})})}),s.jsx(g,{md:6,xs:12,children:s.jsx(bt,{})})]});export{Gt as A,Bt as B,wt as F,Pt as G,I,Nt as S,j as a,Ze as b,Je as c,Ke as d,Xe as e,St as f,Lt as g,Ft as h,q as i,It as s}; +import{I as h,O as y,J as O,K as Y,r as u,L as ee,M as te,_ as v,N as ne,P as se,Q as re,T as ae,U as oe,V as ie,W as le,j as s,X as w,Y as ce,e as f,t as b,b as m,Z as ue,n as de,o as he,$ as me,a0 as xe,S as F,a1 as pe,a2 as ge,a3 as fe,a4 as be,a5 as ye,a6 as je,l as ve,a7 as Ce,a8 as Se,a9 as Ie,aa as Fe,ab as $,ac as Pe,ad as L,ae as N,af as T,ag as we,ah as Be,ai as M,aj as V,v as Ge,B as W,ak as Le,al as A,am as Ne,an as H,ao as Te,G as g,ap as Ae,d as _,aq as qe,ar as Ee,as as ze,at as ke}from"./index-BcZMUM3W.js";function Qe(e,n,t){return h(e).minus(n).div(t-1).toNumber()}function Re(e,n,t,r){const a=Qe(e,n,t);return Array.from({length:t}).map((i,o)=>({price:h(n).plus(h(a).mul(o)).toNumber(),quantity:r}))}function U(e,n){return e=String(e),n!=null&&n.ignoreTrailingZeros&&(e=new h(e).toString()),e.includes(".")?e.split(".")[1].length:0}function G(e,n){const t=n.decimals.price,r=U(e,{ignoreTrailingZeros:!0});return t===void 0?new h(e).toFixed(r):r>t?new h(e).toFixed(t,h.roundDown):new h(e).toFixed(r)}function $e(e,n){const t=n.decimals.amount,r=U(e,{ignoreTrailingZeros:!0});return t===void 0?new h(e).toFixed(r):r>t?new h(e).toFixed(t,h.roundDown):new h(e).toFixed(r)}function St(e,n,t,r,a){return Re(e,n,t,r).map(o=>{const l=G(o.price,a);return{...o,price:new h(l).toNumber()}})}function Ve(e){const n=e.reduce((r,a)=>a.buy.status===y.Filled&&a.sell.status===y.Idle?h(r).plus(a.sell.quantity).toNumber():r,0),t=e.reduce((r,a)=>{if(a.buy.status===y.Idle&&a.sell.status===y.Idle){const o=h(a.buy.quantity).times(a.buy.price);return h(r).plus(o).toNumber()}return r},0);return{baseCurrencyAmount:n,quoteCurrencyAmount:t}}function De(e,n,t){const r=n.findIndex(c=>c.price===e.price&&c.quantity===e.quantity);if(r===-1)throw new Error(`Cannot find grid line index of { price: ${e.price}, quantity: ${e.quantity} }`);const a=n[r],i=n[r-1],o=n[r+1],l=h(t).minus(a.price).abs();if(i){const c=h(t).minus(i.price).abs();if(h(c).lt(l))return!1}if(o){const c=h(t).minus(o.price).abs();if(h(c).lte(l))return!1}return!0}function Oe(e,n){const t=e[n+1];if(!t)throw new Error(`nextGridLinePrice: Grid line at index ${n} doesn't exists`);return t.price}function Me(e,n){return e.flatMap((t,r)=>{if(r===e.length-1)return[];const a=Oe(e,r);return De(t,e,n)||t.price>n?[{buy:{price:t.price,quantity:t.quantity,status:y.Filled},sell:{price:a,quantity:t.quantity,status:y.Idle}}]:[{buy:{price:t.price,quantity:t.quantity,status:y.Idle},sell:{price:a,quantity:t.quantity,status:y.Idle}}]})}function We(e,n,t){const r=Me(n,t),{baseCurrencyAmount:a,quoteCurrencyAmount:i}=Ve(r),o=i+a*t;return{baseCurrencyAmount:$e(a,e.filters),quoteCurrencyAmount:G(i,e.filters),totalInQuoteCurrency:G(o,e.filters)}}const It=e=>e.gridBotForm,He=e=>e.gridBotForm.type,_e=e=>e.gridBotForm.exchangeAccountId,Ue=e=>e.gridBotForm.exchangeCode,j=e=>e.gridBotForm.symbolId,Ze=e=>e.gridBotForm.highPrice,Je=e=>e.gridBotForm.lowPrice,Ke=e=>e.gridBotForm.gridLinesNumber,Xe=e=>e.gridBotForm.quantityPerGrid,Ye=e=>e.gridBotForm.botName,q=e=>e.gridBotForm.gridLines,Z=e=>n=>n.gridBotForm.gridLines[e],Ft=e=>e.gridBotForm.barSize;function et(e){return e.size}function tt(e){const{value:n,id:t,rootRef:r}=e,a=O();if(a===null)throw new Error("No TabContext provided");const{value:i,getTabId:o}=a,l=Y(t),c=u.useRef(null),d=ee(c,r),x=u.useMemo(()=>({id:l,ref:c}),[l]),{id:p}=te(n??et,x),C=p!==i,P=p!==void 0?o(p):void 0;return{hidden:C,getRootProps:(B={})=>v({"aria-labelledby":P??void 0,hidden:C,id:l??void 0},B,{ref:d}),rootRef:d}}function nt(e){return ne("MuiTabPanel",e)}se("MuiTabPanel",["root","hidden","sizeSm","sizeMd","sizeLg","horizontal","vertical","colorPrimary","colorNeutral","colorDanger","colorSuccess","colorWarning","colorContext","variantPlain","variantOutlined","variantSoft","variantSolid"]);const st=["children","value","component","color","variant","size","slots","slotProps","keepMounted"],rt=e=>{const{hidden:n,size:t,variant:r,color:a,orientation:i}=e,o={root:["root",n&&"hidden",t&&`size${w(t)}`,i,r&&`variant${w(r)}`,a&&`color${w(a)}`,t&&`size${w(t)}`]};return ce(o,nt,{})},at=re("div",{name:"JoyTabPanel",slot:"Root",overridesResolver:(e,n)=>n.root})(({theme:e,ownerState:n})=>{var t;return v({display:n.hidden?"none":"block",padding:"var(--Tabs-spacing)",flexGrow:1,fontFamily:e.vars.fontFamily.body},e.typography[`body-${n.size}`],(t=e.variants[n.variant])==null?void 0:t[n.color])}),D=u.forwardRef(function(n,t){const r=ae({props:n,name:"JoyTabPanel"}),{orientation:a}=O()||{orientation:"horizontal"},i=u.useContext(oe),{children:o,value:l=0,component:c,color:d="neutral",variant:x="plain",size:p,slots:C={},slotProps:P={},keepMounted:E=!1}=r,B=ie(r,st),{hidden:z,getRootProps:J}=tt(v({},r,{value:l})),k=v({},r,{orientation:a,hidden:z,size:p??i,color:d,variant:x}),K=rt(k),X=v({},B,{component:c,slots:C,slotProps:P}),[Q,R]=le("root",{ref:t,elementType:at,getSlotProps:J,externalForwardedProps:X,additionalProps:{role:"tabpanel",ref:t,as:c},ownerState:k,className:K.root});return E?s.jsx(Q,v({},R,{children:o})):s.jsx(Q,v({},R,{children:!z&&o}))}),ot=({disabled:e})=>{const n=f(),[t]=b.exchangeAccount.list.useSuspenseQuery(),r=m(_e),a=o=>{if(o===null)throw new Error("ExchangeAccountField: Cannot reset exchange account input");n(de(o.id)),n(he(o.exchangeCode))},i=t.find(o=>o.id===r);return s.jsx(ue,{onChange:a,value:i,disabled:e})},it=({disabled:e})=>{const n=f(),t=m(Ue),[r]=b.symbol.list.useSuspenseQuery(t),a=m(j),i=l=>{if(l===null)throw new Error("PairField: Cannot reset symbol input");n(xe(l.symbolId))},o=r.find(l=>l.symbolId===a);return s.jsx(me,{exchangeCode:t,onChange:i,value:o||null,disabled:e})},lt=36,I=({width:e="100%",withLabel:n})=>{const t=s.jsx(F,{animation:"wave",height:lt,variant:"rectangular",width:e});return n?s.jsxs(s.Fragment,{children:[s.jsx(F,{animation:"wave",height:20,sx:{mb:"6px"},variant:"text",width:72}),t]}):t};function ct(e,n){if(e.length===0)return-1;if(e.length===1)return e[0];const t=e.map(i=>Math.abs(i-n)),r=Math.min(...t),a=t.indexOf(r);return e[a]}function ut(e,n){const t=e.map(a=>a.price),r=ct(t,n);return t.map(a=>pe(a,t,r))}const Pt=({symbolId:e,barSize:n,onBarSizeChange:t,gridLines:r,currentAssetPrice:a})=>{const i=u.useDeferredValue(e),o=e!==i,l=u.useMemo(()=>ut(r,a),[r,a]),[c,d]=u.useState(!0);return s.jsx(u.Suspense,{fallback:s.jsx(F,{animation:"wave",height:ge,variant:"rectangular",width:"100%"}),children:s.jsxs(fe,{barSize:n,dimmed:o,priceLines:l,showPriceLines:c,symbolId:i,children:[s.jsx(u.Suspense,{fallback:s.jsx(I,{width:232}),children:s.jsx(ot,{})}),s.jsx(u.Suspense,{fallback:s.jsx(I,{width:232}),children:s.jsx(it,{})}),s.jsx(be,{onChange:x=>{t&&t(x)},value:n,whitelist:ye}),s.jsx(je,{}),s.jsx(ve,{display:"flex",children:s.jsx(Ce,{gridVisible:c,hideTradesButton:!0,onGridVisibleChange:d})})]})})},S={simple:"simple",advanced:"advanced"},wt=({simpleForm:e,advancedForm:n})=>{const t=m(He),r=f(),a=(i,o)=>{o!==null&&r(Pe(o))};return s.jsxs(Se,{defaultValue:S.simple,onChange:(i,o)=>{a(i,o)},sx:{borderRadius:"md",overflow:"auto",boxShadow:"sm"},value:t,children:[s.jsxs(Ie,{disableUnderline:!0,sx:{[`& .${Fe.root}`]:{bgcolor:"background.backdrop",'&[aria-selected="true"]':{bgcolor:"background.surface",fontWeight:"lg"}}},tabFlex:"auto",children:[s.jsx($,{disableIndicator:!0,value:S.simple,children:"Easy form"}),s.jsx($,{disableIndicator:!0,value:S.advanced,children:"Advanced form"})]}),s.jsx(D,{value:S.simple,children:e}),s.jsx(D,{value:S.advanced,children:n})]})},Bt=()=>{const e=f(),n=m(Ye),[t,r]=u.useState(n);u.useEffect(()=>{r(n)},[n]);const a=c=>{r(c.target.value)},i=()=>{t.length>0?e(V(t)):r(n)},o=()=>{e(V(Ge()))},l=t.length===0?"Must be defined":null;return s.jsxs(L,{error:!!l,children:[s.jsx(N,{children:"Bot name"}),s.jsx(T,{endDecorator:s.jsx(we,{onClick:o,children:s.jsx(Be,{})}),onBlur:i,onChange:a,value:t}),l?s.jsx(M,{children:l}):null]})},dt=e=>{const{className:n,gridLineIndex:t}=e,r=f(),a=()=>{r(Le(t))};return s.jsx(W,{className:n,color:"danger",onClick:a,size:"sm",children:"Remove"})},ht=e=>{const{className:n,gridLineIndex:t}=e,r=f(),{price:a}=m(Z(t)),[i,o]=u.useState(String(a));u.useEffect(()=>{o(`${a}`)},[a]);const l=m(j),[c]=b.symbol.getOne.useSuspenseQuery({symbolId:l}),d=p=>{o(p.target.value)},x=()=>{i.length>0?r(Ne({gridLineIndex:t,price:Number(i)})):o(String(a))};return s.jsx(A,{className:n,filter:c.filters,fullWidth:!0,label:"Price",onBlur:x,onChange:d,size:"sm",value:i})},mt=e=>{const{className:n,gridLineIndex:t,disabled:r}=e,a=f(),i=m(j),[o]=b.symbol.getOne.useSuspenseQuery({symbolId:i}),{quantity:l}=m(Z(t)),[c,d]=u.useState(`${l}`);u.useEffect(()=>{d(`${l}`)},[l]);const x=C=>{d(C.target.value)},p=()=>{isNaN(Number(c))?d(`${l}`):a(Te({gridLineIndex:t,quantity:Number(c)}))};return s.jsx(H,{className:n,disabled:r,filter:o.filters,fullWidth:!0,label:"Quantity",onBlur:p,onChange:x,size:"sm",value:c})},xt=e=>{const{gridLineIndex:n}=e,t=m(q),r=n===t.length-1;return s.jsxs(g,{alignItems:"flex-end",container:!0,spacing:2,children:[s.jsx(g,{xs:!0,children:s.jsx(u.Suspense,{fallback:s.jsx(F,{height:36,variant:"rectangular",width:200}),children:s.jsx(ht,{gridLineIndex:n})})}),s.jsx(g,{xs:!0,children:s.jsx(u.Suspense,{fallback:s.jsx(F,{height:36,variant:"rectangular",width:200}),children:s.jsx(mt,{disabled:r,gridLineIndex:n})})}),s.jsx(g,{xs:"auto",children:s.jsx(dt,{gridLineIndex:n})})]})},Gt=()=>{const e=f(),n=m(q),t=()=>{e(Ae({price:1,quantity:1}))},r=a=>n.length-1-a;return s.jsxs(g,{container:!0,spacing:2,children:[s.jsx(g,{xs:12,children:n.map((a,i)=>s.jsx(xt,{gridLineIndex:r(i)},i))}),s.jsx(g,{xs:12,children:s.jsx(W,{onClick:t,children:"Add"})})]})},pt=({baseCurrencyAmount:e,quoteCurrencyAmount:n,totalInQuoteCurrency:t})=>{const r=m(j),{baseCurrency:a,quoteCurrency:i}=_(r);return s.jsxs(M,{children:[s.jsxs("span",{children:[e," ",a]}),s.jsx("span",{children:" + "}),s.jsxs("span",{children:[n," ",i]}),s.jsx("span",{children:" ≈ "}),s.jsxs("span",{children:[t," ",i]})]})},Lt=e=>{const{className:n}=e,t=m(j),{quoteCurrency:r}=_(t),[a]=b.symbol.price.useSuspenseQuery({symbolId:t}),[i]=b.symbol.getOne.useSuspenseQuery({symbolId:t}),o=m(q),{baseCurrencyAmount:l,quoteCurrencyAmount:c,totalInQuoteCurrency:d}=We(i,o,a.price),x="investment-field";return s.jsxs(L,{className:n,children:[s.jsx(N,{htmlFor:x,children:"Investment"}),s.jsx(T,{disabled:!0,endDecorator:s.jsx(s.Fragment,{children:r}),id:x,type:"number",value:d}),s.jsx(pt,{baseCurrencyAmount:l,quoteCurrencyAmount:c,totalInQuoteCurrency:d})]})},gt=e=>{const{disabled:n,readOnly:t}=e,r=m(j),[a]=b.symbol.getOne.useSuspenseQuery({symbolId:r}),i=f(),o=m(Xe),[l,c]=u.useState(o);u.useEffect(()=>{c(o)},[o]);const d=p=>{c(p.target.value)},x=()=>{isNaN(Number(l))?c(o):i(qe(l))};return s.jsx(H,{disabled:n,filter:a.filters,fullWidth:!0,label:"Quantity per grid",onBlur:x,onChange:d,readOnly:t,required:!0,value:l})},ft="gridLevels",bt=e=>{const{disabled:n,readOnly:t}=e,r=f(),a=m(Ke),[i,o]=u.useState(a),l=d=>{o(d.target.valueAsNumber)},c=()=>{Number.isInteger(i)?r(Ee(i)):o(a)};return s.jsxs(L,{children:[s.jsx(N,{children:"Grid levels"}),s.jsx(T,{autoComplete:"off",disabled:n,name:ft,onBlur:c,onChange:l,readOnly:t,required:!0,type:"number",value:i})]})},yt=e=>{const{disabled:n,readOnly:t}=e,r=m(j),[a]=b.symbol.getOne.useSuspenseQuery({symbolId:r}),i=f(),o=m(Ze),[l,c]=u.useState(`${o}`);u.useEffect(()=>{c(`${o}`)},[o]);const d=p=>{c(p.target.value)},x=()=>{l.length>0?i(ze(Number(l))):c(`${o}`)};return s.jsx(A,{disabled:n,filter:a.filters,fullWidth:!0,label:"High price",onBlur:x,onChange:d,readOnly:t,value:l})},jt=e=>{const{disabled:n,readOnly:t}=e,r=m(j),[a]=b.symbol.getOne.useSuspenseQuery({symbolId:r}),i=f(),o=m(Je),[l,c]=u.useState(`${o}`);u.useEffect(()=>{c(`${o}`)},[o]);const d=p=>{c(p.target.value)},x=()=>{l.length>0?i(ke(Number(l))):c(`${o}`)};return s.jsx(A,{disabled:n,filter:a.filters,fullWidth:!0,label:"Low price",onBlur:x,onChange:d,readOnly:t,value:l})},Nt=()=>s.jsxs(g,{container:!0,spacing:2,children:[s.jsx(g,{md:6,xs:12,children:s.jsx(u.Suspense,{fallback:s.jsx(I,{withLabel:!0}),children:s.jsx(yt,{})})}),s.jsx(g,{md:6,xs:12,children:s.jsx(u.Suspense,{fallback:s.jsx(I,{withLabel:!0}),children:s.jsx(jt,{})})}),s.jsx(g,{md:6,xs:12,children:s.jsx(u.Suspense,{fallback:s.jsx(I,{withLabel:!0}),children:s.jsx(gt,{})})}),s.jsx(g,{md:6,xs:12,children:s.jsx(bt,{})})]});export{Gt as A,Bt as B,wt as F,Pt as G,I,Nt as S,j as a,Ze as b,Je as c,Ke as d,Xe as e,St as f,Lt as g,Ft as h,q as i,It as s}; diff --git a/apps/cli/frontend/assets/browser-DplhMTqm.js b/apps/cli/frontend/assets/browser-9oIzATog.js similarity index 99% rename from apps/cli/frontend/assets/browser-DplhMTqm.js rename to apps/cli/frontend/assets/browser-9oIzATog.js index 82ff8072..8913ade7 100644 --- a/apps/cli/frontend/assets/browser-DplhMTqm.js +++ b/apps/cli/frontend/assets/browser-9oIzATog.js @@ -1,4 +1,4 @@ -import{a$ as Pr,b0 as sn,a_ as fe,aX as U,aY as ln,aW as Ke}from"./index-C0B7FSMw.js";import{h as cn}from"./__vite-browser-external-v7f2oYTb.js";var dn={},Nt={exports:{}},ge=typeof Reflect=="object"?Reflect:null,Ht=ge&&typeof ge.apply=="function"?ge.apply:function(e,n,a){return Function.prototype.apply.call(e,n,a)},je;ge&&typeof ge.ownKeys=="function"?je=ge.ownKeys:Object.getOwnPropertySymbols?je=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:je=function(e){return Object.getOwnPropertyNames(e)};function pn(t){console&&console.warn&&console.warn(t)}var Tr=Number.isNaN||function(e){return e!==e};function H(){H.init.call(this)}Nt.exports=H;var So=Nt.exports.once=vn;H.EventEmitter=H;H.prototype._events=void 0;H.prototype._eventsCount=0;H.prototype._maxListeners=void 0;var Gt=10;function Ue(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(H,"defaultMaxListeners",{enumerable:!0,get:function(){return Gt},set:function(t){if(typeof t!="number"||t<0||Tr(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Gt=t}});H.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};H.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Tr(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function jr(t){return t._maxListeners===void 0?H.defaultMaxListeners:t._maxListeners}H.prototype.getMaxListeners=function(){return jr(this)};H.prototype.emit=function(e){for(var n=[],a=1;a0&&(y=n[0]),y instanceof Error)throw y;var f=new Error("Unhandled error."+(y?" ("+y.message+")":""));throw f.context=y,f}var d=s[e];if(d===void 0)return!1;if(typeof d=="function")Ht(d,this,n);else for(var g=d.length,O=Fr(d,g),a=0;a0&&y.length>p&&!y.warned){y.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+y.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=t,f.type=e,f.count=y.length,pn(f)}return t}H.prototype.addListener=function(e,n){return Mr(this,e,n,!1)};H.prototype.on=H.prototype.addListener;H.prototype.prependListener=function(e,n){return Mr(this,e,n,!0)};function yn(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Lr(t,e,n){var a={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},p=yn.bind(a);return p.listener=n,a.wrapFn=p,p}H.prototype.once=function(e,n){return Ue(n),this.on(e,Lr(this,e,n)),this};H.prototype.prependOnceListener=function(e,n){return Ue(n),this.prependListener(e,Lr(this,e,n)),this};H.prototype.removeListener=function(e,n){var a,p,s,y,f;if(Ue(n),p=this._events,p===void 0)return this;if(a=p[e],a===void 0)return this;if(a===n||a.listener===n)--this._eventsCount===0?this._events=Object.create(null):(delete p[e],p.removeListener&&this.emit("removeListener",e,a.listener||n));else if(typeof a!="function"){for(s=-1,y=a.length-1;y>=0;y--)if(a[y]===n||a[y].listener===n){f=a[y].listener,s=y;break}if(s<0)return this;s===0?a.shift():hn(a,s),a.length===1&&(p[e]=a[0]),p.removeListener!==void 0&&this.emit("removeListener",e,f||n)}return this};H.prototype.off=H.prototype.removeListener;H.prototype.removeAllListeners=function(e){var n,a,p;if(a=this._events,a===void 0)return this;if(a.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):a[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete a[e]),this;if(arguments.length===0){var s=Object.keys(a),y;for(p=0;p=0;p--)this.removeListener(e,n[p]);return this};function Nr(t,e,n){var a=t._events;if(a===void 0)return[];var p=a[e];return p===void 0?[]:typeof p=="function"?n?[p.listener||p]:[p]:n?gn(p):Fr(p,p.length)}H.prototype.listeners=function(e){return Nr(this,e,!0)};H.prototype.rawListeners=function(e){return Nr(this,e,!1)};H.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Br.call(t,e)};H.prototype.listenerCount=Br;function Br(t){var e=this._events;if(e!==void 0){var n=e[t];if(typeof n=="function")return 1;if(n!==void 0)return n.length}return 0}H.prototype.eventNames=function(){return this._eventsCount>0?je(this._events):[]};function Fr(t,e){for(var n=new Array(e),a=0;a"u"||!V?k:V(Uint8Array),ue={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?k:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?k:ArrayBuffer,"%ArrayIteratorPrototype%":de&&V?V([][Symbol.iterator]()):k,"%AsyncFromSyncIteratorPrototype%":k,"%AsyncFunction%":ye,"%AsyncGenerator%":ye,"%AsyncGeneratorFunction%":ye,"%AsyncIteratorPrototype%":ye,"%Atomics%":typeof Atomics>"u"?k:Atomics,"%BigInt%":typeof BigInt>"u"?k:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?k:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?k:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?k:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Gn,"%eval%":eval,"%EvalError%":Vn,"%Float32Array%":typeof Float32Array>"u"?k:Float32Array,"%Float64Array%":typeof Float64Array>"u"?k:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?k:FinalizationRegistry,"%Function%":qr,"%GeneratorFunction%":ye,"%Int8Array%":typeof Int8Array>"u"?k:Int8Array,"%Int16Array%":typeof Int16Array>"u"?k:Int16Array,"%Int32Array%":typeof Int32Array>"u"?k:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":de&&V?V(V([][Symbol.iterator]())):k,"%JSON%":typeof JSON=="object"?JSON:k,"%Map%":typeof Map>"u"?k:Map,"%MapIteratorPrototype%":typeof Map>"u"||!de||!V?k:V(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Wr,"%Object.getOwnPropertyDescriptor%":Se,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?k:Promise,"%Proxy%":typeof Proxy>"u"?k:Proxy,"%RangeError%":zn,"%ReferenceError%":Kn,"%Reflect%":typeof Reflect>"u"?k:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?k:Set,"%SetIteratorPrototype%":typeof Set>"u"||!de||!V?k:V(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?k:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":de&&V?V(""[Symbol.iterator]()):k,"%Symbol%":de?Symbol:k,"%SyntaxError%":be,"%ThrowTypeError%":ri,"%TypedArray%":ii,"%TypeError%":ve,"%Uint8Array%":typeof Uint8Array>"u"?k:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?k:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?k:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?k:Uint32Array,"%URIError%":Jn,"%WeakMap%":typeof WeakMap>"u"?k:WeakMap,"%WeakRef%":typeof WeakRef>"u"?k:WeakRef,"%WeakSet%":typeof WeakSet>"u"?k:WeakSet,"%Function.prototype.call%":Re,"%Function.prototype.apply%":xr,"%Object.defineProperty%":ti,"%Math.abs%":Yn,"%Math.floor%":Xn,"%Math.max%":Zn,"%Math.min%":Qn,"%Math.pow%":ei};if(V)try{null.error}catch(t){var oi=V(V(t));ue["%Error.prototype%"]=oi}var ai=function t(e){var n;if(e==="%AsyncFunction%")n=nt("async function () {}");else if(e==="%GeneratorFunction%")n=nt("function* () {}");else if(e==="%AsyncGeneratorFunction%")n=nt("async function* () {}");else if(e==="%AsyncGenerator%"){var a=t("%AsyncGeneratorFunction%");a&&(n=a.prototype)}else if(e==="%AsyncIteratorPrototype%"){var p=t("%AsyncGenerator%");p&&V&&(n=V(p.prototype))}return ue[e]=n,n},er={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},Oe=Ae(),Ce=Hn(),fi=Oe.call(Re,Array.prototype.concat),ui=Oe.call(xr,Array.prototype.splice),tr=Oe.call(Re,String.prototype.replace),De=Oe.call(Re,String.prototype.slice),si=Oe.call(Re,RegExp.prototype.exec),li=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,ci=/\\(\\)?/g,di=function(e){var n=De(e,0,1),a=De(e,-1);if(n==="%"&&a!=="%")throw new be("invalid intrinsic syntax, expected closing `%`");if(a==="%"&&n!=="%")throw new be("invalid intrinsic syntax, expected opening `%`");var p=[];return tr(e,li,function(s,y,f,d){p[p.length]=f?tr(d,ci,"$1"):y||s}),p},pi=function(e,n){var a=e,p;if(Ce(er,a)&&(p=er[a],a="%"+p[0]+"%"),Ce(ue,a)){var s=ue[a];if(s===ye&&(s=ai(a)),typeof s>"u"&&!n)throw new ve("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:p,name:a,value:s}}throw new be("intrinsic "+e+" does not exist!")},Hr=function(e,n){if(typeof e!="string"||e.length===0)throw new ve("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof n!="boolean")throw new ve('"allowMissing" argument must be a boolean');if(si(/^%?[^%]*%?$/,e)===null)throw new be("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var a=di(e),p=a.length>0?a[0]:"",s=pi("%"+p+"%",n),y=s.name,f=s.value,d=!1,g=s.alias;g&&(p=g[0],ui(a,fi([0,1],g)));for(var O=1,R=!0;O=a.length){var l=Se(f,E);R=!!l,R&&"get"in l&&!("originalValue"in l.get)?f=l.get:f=f[E]}else R=Ce(f,E),f=f[E];R&&!d&&(ue[y]=f)}}return f},Gr=Hr,Vr=It,yi=Vr([Gr("%String.prototype.indexOf%")]),zr=function(e,n){var a=Gr(e,!!n);return typeof a=="function"&&yi(e,".prototype.")>-1?Vr([a]):a},hi=Ft(),gi=zr,Ot=gi("Object.prototype.toString"),He=function(e){return hi&&e&&typeof e=="object"&&Symbol.toStringTag in e?!1:Ot(e)==="[object Arguments]"},Kr=function(e){return He(e)?!0:e!==null&&typeof e=="object"&&"length"in e&&typeof e.length=="number"&&e.length>=0&&Ot(e)!=="[object Array]"&&"callee"in e&&Ot(e.callee)==="[object Function]"},vi=function(){return He(arguments)}();He.isLegacyArguments=Kr;var bi=vi?He:Kr,wi=Object.prototype.toString,mi=Function.prototype.toString,_i=/^\s*(?:function)?\*/,Jr=Ft(),ot=Object.getPrototypeOf,Si=function(){if(!Jr)return!1;try{return Function("return function*() {}")()}catch{}},at,Ei=function(e){if(typeof e!="function")return!1;if(_i.test(mi.call(e)))return!0;if(!Jr){var n=wi.call(e);return n==="[object GeneratorFunction]"}if(!ot)return!1;if(typeof at>"u"){var a=Si();at=a?ot(a):!1}return ot(e)===at},Yr=Function.prototype.toString,he=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,Pt,Ne;if(typeof he=="function"&&typeof Object.defineProperty=="function")try{Pt=Object.defineProperty({},"length",{get:function(){throw Ne}}),Ne={},he(function(){throw 42},null,Pt)}catch(t){t!==Ne&&(he=null)}else he=null;var Ai=/^\s*class\b/,Tt=function(e){try{var n=Yr.call(e);return Ai.test(n)}catch{return!1}},ft=function(e){try{return Tt(e)?!1:(Yr.call(e),!0)}catch{return!1}},Be=Object.prototype.toString,Ri="[object Object]",Oi="[object Function]",Pi="[object GeneratorFunction]",Ti="[object HTMLAllCollection]",ji="[object HTML document.all class]",Mi="[object HTMLCollection]",Li=typeof Symbol=="function"&&!!Symbol.toStringTag,Ni=!(0 in[,]),jt=function(){return!1};if(typeof document=="object"){var Bi=document.all;Be.call(Bi)===Be.call(document.all)&&(jt=function(e){if((Ni||!e)&&(typeof e>"u"||typeof e=="object"))try{var n=Be.call(e);return(n===Ti||n===ji||n===Mi||n===Ri)&&e("")==null}catch{}return!1})}var Fi=he?function(e){if(jt(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{he(e,null,Pt)}catch(n){if(n!==Ne)return!1}return!Tt(e)&&ft(e)}:function(e){if(jt(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(Li)return ft(e);if(Tt(e))return!1;var n=Be.call(e);return n!==Oi&&n!==Pi&&!/^\[object HTML/.test(n)?!1:ft(e)},Ci=Fi,Di=Object.prototype.toString,Xr=Object.prototype.hasOwnProperty,Ii=function(e,n,a){for(var p=0,s=e.length;p=3&&(p=a),Di.call(e)==="[object Array]"?Ii(e,n,p):typeof e=="string"?$i(e,n,p):Ui(e,n,p)},Wi=ki,qi=["Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"],ut=qi,xi=typeof globalThis>"u"?fe:globalThis,Hi=function(){for(var e=[],n=0;n3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new pe("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new pe("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new pe("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new pe("`loose`, if provided, must be a boolean");var p=arguments.length>3?arguments[3]:null,s=arguments.length>4?arguments[4]:null,y=arguments.length>5?arguments[5]:null,f=arguments.length>6?arguments[6]:!1,d=!!nr&&nr(e,n);if(rr)rr(e,n,{configurable:y===null&&d?d.configurable:!y,enumerable:p===null&&d?d.enumerable:!p,value:a,writable:s===null&&d?d.writable:!s});else if(f||!p&&!s&&!y)e[n]=a;else throw new Gi("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},Mt=xe,Qr=function(){return!!Mt};Qr.hasArrayLengthDefineBug=function(){if(!Mt)return null;try{return Mt([],"length",{value:1}).length!==1}catch{return!0}};var zi=Qr,Ki=Hr,ir=Vi,Ji=zi(),or=Ee,ar=qe,Yi=Ki("%Math.floor%"),Xi=function(e,n){if(typeof e!="function")throw new ar("`fn` is not a function");if(typeof n!="number"||n<0||n>4294967295||Yi(n)!==n)throw new ar("`length` must be a positive 32-bit integer");var a=arguments.length>2&&!!arguments[2],p=!0,s=!0;if("length"in e&&or){var y=or(e,"length");y&&!y.configurable&&(p=!1),y&&!y.writable&&(s=!1)}return(p||s||!a)&&(Ji?ir(e,"length",n,!0,!0):ir(e,"length",n)),e},Zi=Ae(),Qi=Dt(),eo=kr,to=function(){return eo(Zi,Qi,arguments)};(function(t){var e=Xi,n=xe,a=It,p=to;t.exports=function(y){var f=a(arguments),d=y.length-(arguments.length-1);return e(f,1+(d>0?d:0),!0)},n?n(t.exports,"apply",{value:p}):t.exports.apply=p})(Zr);var ro=Zr.exports,Ie=Wi,no=Hi,fr=ro,$t=zr,Fe=Ee,io=$t("Object.prototype.toString"),en=Ft(),ur=typeof globalThis>"u"?fe:globalThis,Lt=no(),Ut=$t("String.prototype.slice"),st=Object.getPrototypeOf,oo=$t("Array.prototype.indexOf",!0)||function(e,n){for(var a=0;a-1?n:n!=="Object"?!1:fo(e)}return Fe?ao(e):null},uo=tn,so=function(e){return!!uo(e)};(function(t){var e=bi,n=Ei,a=tn,p=so;function s(_){return _.call.bind(_)}var y=typeof BigInt<"u",f=typeof Symbol<"u",d=s(Object.prototype.toString),g=s(Number.prototype.valueOf),O=s(String.prototype.valueOf),R=s(Boolean.prototype.valueOf);if(y)var E=s(BigInt.prototype.valueOf);if(f)var P=s(Symbol.prototype.valueOf);function j(_,Pe){if(typeof _!="object")return!1;try{return Pe(_),!0}catch{return!1}}t.isArgumentsObject=e,t.isGeneratorFunction=n,t.isTypedArray=p;function l(_){return typeof Promise<"u"&&_ instanceof Promise||_!==null&&typeof _=="object"&&typeof _.then=="function"&&typeof _.catch=="function"}t.isPromise=l;function v(_){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?ArrayBuffer.isView(_):p(_)||h(_)}t.isArrayBufferView=v;function o(_){return a(_)==="Uint8Array"}t.isUint8Array=o;function b(_){return a(_)==="Uint8ClampedArray"}t.isUint8ClampedArray=b;function A(_){return a(_)==="Uint16Array"}t.isUint16Array=A;function M(_){return a(_)==="Uint32Array"}t.isUint32Array=M;function N(_){return a(_)==="Int8Array"}t.isInt8Array=N;function C(_){return a(_)==="Int16Array"}t.isInt16Array=C;function W(_){return a(_)==="Int32Array"}t.isInt32Array=W;function I(_){return a(_)==="Float32Array"}t.isFloat32Array=I;function D(_){return a(_)==="Float64Array"}t.isFloat64Array=D;function G(_){return a(_)==="BigInt64Array"}t.isBigInt64Array=G;function Y(_){return a(_)==="BigUint64Array"}t.isBigUint64Array=Y;function K(_){return d(_)==="[object Map]"}K.working=typeof Map<"u"&&K(new Map);function J(_){return typeof Map>"u"?!1:K.working?K(_):_ instanceof Map}t.isMap=J;function re(_){return d(_)==="[object Set]"}re.working=typeof Set<"u"&&re(new Set);function ne(_){return typeof Set>"u"?!1:re.working?re(_):_ instanceof Set}t.isSet=ne;function X(_){return d(_)==="[object WeakMap]"}X.working=typeof WeakMap<"u"&&X(new WeakMap);function Q(_){return typeof WeakMap>"u"?!1:X.working?X(_):_ instanceof WeakMap}t.isWeakMap=Q;function ie(_){return d(_)==="[object WeakSet]"}ie.working=typeof WeakSet<"u"&&ie(new WeakSet);function ee(_){return ie(_)}t.isWeakSet=ee;function z(_){return d(_)==="[object ArrayBuffer]"}z.working=typeof ArrayBuffer<"u"&&z(new ArrayBuffer);function oe(_){return typeof ArrayBuffer>"u"?!1:z.working?z(_):_ instanceof ArrayBuffer}t.isArrayBuffer=oe;function te(_){return d(_)==="[object DataView]"}te.working=typeof ArrayBuffer<"u"&&typeof DataView<"u"&&te(new DataView(new ArrayBuffer(1),0,1));function h(_){return typeof DataView>"u"?!1:te.working?te(_):_ instanceof DataView}t.isDataView=h;var m=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:void 0;function T(_){return d(_)==="[object SharedArrayBuffer]"}function u(_){return typeof m>"u"?!1:(typeof T.working>"u"&&(T.working=T(new m)),T.working?T(_):_ instanceof m)}t.isSharedArrayBuffer=u;function c(_){return d(_)==="[object AsyncFunction]"}t.isAsyncFunction=c;function w(_){return d(_)==="[object Map Iterator]"}t.isMapIterator=w;function L(_){return d(_)==="[object Set Iterator]"}t.isSetIterator=L;function B(_){return d(_)==="[object Generator]"}t.isGeneratorObject=B;function r(_){return d(_)==="[object WebAssembly.Module]"}t.isWebAssemblyCompiledModule=r;function i(_){return j(_,g)}t.isNumberObject=i;function S(_){return j(_,O)}t.isStringObject=S;function F(_){return j(_,R)}t.isBooleanObject=F;function q(_){return y&&j(_,E)}t.isBigIntObject=q;function $(_){return f&&j(_,P)}t.isSymbolObject=$;function x(_){return i(_)||S(_)||F(_)||q(_)||$(_)}t.isBoxedPrimitive=x;function ae(_){return typeof Uint8Array<"u"&&(oe(_)||u(_))}t.isAnyArrayBuffer=ae,["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(_){Object.defineProperty(t,_,{enumerable:!1,value:function(){throw new Error(_+" is not supported in userland")}})})})(Ir);var lo=function(e){return e&&typeof e=="object"&&typeof e.copy=="function"&&typeof e.fill=="function"&&typeof e.readUInt8=="function"};(function(t){var e={},n=Object.getOwnPropertyDescriptors||function(m){for(var T=Object.keys(m),u={},c=0;c=c)return B;switch(B){case"%s":return String(u[T++]);case"%d":return Number(u[T++]);case"%j":try{return JSON.stringify(u[T++])}catch{return"[Circular]"}default:return B}}),L=u[T];T"u")return function(){return t.deprecate(h,m).apply(this,arguments)};var T=!1;function u(){if(!T){if(U.throwDeprecation)throw new Error(m);U.traceDeprecation?console.trace(m):console.error(m),T=!0}return h.apply(this,arguments)}return u};var p={},s=/^$/;if(e.NODE_DEBUG){var y=e.NODE_DEBUG;y=y.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),s=new RegExp("^"+y+"$","i")}t.debuglog=function(h){if(h=h.toUpperCase(),!p[h])if(s.test(h)){var m=U.pid;p[h]=function(){var T=t.format.apply(t,arguments);console.error("%s %d: %s",h,m,T)}}else p[h]=function(){};return p[h]};function f(h,m){var T={seen:[],stylize:g};return arguments.length>=3&&(T.depth=arguments[2]),arguments.length>=4&&(T.colors=arguments[3]),b(m)?T.showHidden=m:m&&t._extend(T,m),I(T.showHidden)&&(T.showHidden=!1),I(T.depth)&&(T.depth=2),I(T.colors)&&(T.colors=!1),I(T.customInspect)&&(T.customInspect=!0),T.colors&&(T.stylize=d),R(T,h,T.depth)}t.inspect=f,f.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},f.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function d(h,m){var T=f.styles[m];return T?"\x1B["+f.colors[T][0]+"m"+h+"\x1B["+f.colors[T][1]+"m":h}function g(h,m){return h}function O(h){var m={};return h.forEach(function(T,u){m[T]=!0}),m}function R(h,m,T){if(h.customInspect&&m&&J(m.inspect)&&m.inspect!==t.inspect&&!(m.constructor&&m.constructor.prototype===m)){var u=m.inspect(T,h);return C(u)||(u=R(h,u,T)),u}var c=E(h,m);if(c)return c;var w=Object.keys(m),L=O(w);if(h.showHidden&&(w=Object.getOwnPropertyNames(m)),K(m)&&(w.indexOf("message")>=0||w.indexOf("description")>=0))return P(m);if(w.length===0){if(J(m)){var B=m.name?": "+m.name:"";return h.stylize("[Function"+B+"]","special")}if(D(m))return h.stylize(RegExp.prototype.toString.call(m),"regexp");if(Y(m))return h.stylize(Date.prototype.toString.call(m),"date");if(K(m))return P(m)}var r="",i=!1,S=["{","}"];if(o(m)&&(i=!0,S=["[","]"]),J(m)){var F=m.name?": "+m.name:"";r=" [Function"+F+"]"}if(D(m)&&(r=" "+RegExp.prototype.toString.call(m)),Y(m)&&(r=" "+Date.prototype.toUTCString.call(m)),K(m)&&(r=" "+P(m)),w.length===0&&(!i||m.length==0))return S[0]+r+S[1];if(T<0)return D(m)?h.stylize(RegExp.prototype.toString.call(m),"regexp"):h.stylize("[Object]","special");h.seen.push(m);var q;return i?q=j(h,m,T,L,w):q=w.map(function($){return l(h,m,T,L,$,i)}),h.seen.pop(),v(q,r,S)}function E(h,m){if(I(m))return h.stylize("undefined","undefined");if(C(m)){var T="'"+JSON.stringify(m).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return h.stylize(T,"string")}if(N(m))return h.stylize(""+m,"number");if(b(m))return h.stylize(""+m,"boolean");if(A(m))return h.stylize("null","null")}function P(h){return"["+Error.prototype.toString.call(h)+"]"}function j(h,m,T,u,c){for(var w=[],L=0,B=m.length;L0&&(y=n[0]),y instanceof Error)throw y;var f=new Error("Unhandled error."+(y?" ("+y.message+")":""));throw f.context=y,f}var d=s[e];if(d===void 0)return!1;if(typeof d=="function")Ht(d,this,n);else for(var g=d.length,O=Fr(d,g),a=0;a0&&y.length>p&&!y.warned){y.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+y.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=t,f.type=e,f.count=y.length,pn(f)}return t}H.prototype.addListener=function(e,n){return Mr(this,e,n,!1)};H.prototype.on=H.prototype.addListener;H.prototype.prependListener=function(e,n){return Mr(this,e,n,!0)};function yn(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Lr(t,e,n){var a={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},p=yn.bind(a);return p.listener=n,a.wrapFn=p,p}H.prototype.once=function(e,n){return Ue(n),this.on(e,Lr(this,e,n)),this};H.prototype.prependOnceListener=function(e,n){return Ue(n),this.prependListener(e,Lr(this,e,n)),this};H.prototype.removeListener=function(e,n){var a,p,s,y,f;if(Ue(n),p=this._events,p===void 0)return this;if(a=p[e],a===void 0)return this;if(a===n||a.listener===n)--this._eventsCount===0?this._events=Object.create(null):(delete p[e],p.removeListener&&this.emit("removeListener",e,a.listener||n));else if(typeof a!="function"){for(s=-1,y=a.length-1;y>=0;y--)if(a[y]===n||a[y].listener===n){f=a[y].listener,s=y;break}if(s<0)return this;s===0?a.shift():hn(a,s),a.length===1&&(p[e]=a[0]),p.removeListener!==void 0&&this.emit("removeListener",e,f||n)}return this};H.prototype.off=H.prototype.removeListener;H.prototype.removeAllListeners=function(e){var n,a,p;if(a=this._events,a===void 0)return this;if(a.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):a[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete a[e]),this;if(arguments.length===0){var s=Object.keys(a),y;for(p=0;p=0;p--)this.removeListener(e,n[p]);return this};function Nr(t,e,n){var a=t._events;if(a===void 0)return[];var p=a[e];return p===void 0?[]:typeof p=="function"?n?[p.listener||p]:[p]:n?gn(p):Fr(p,p.length)}H.prototype.listeners=function(e){return Nr(this,e,!0)};H.prototype.rawListeners=function(e){return Nr(this,e,!1)};H.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Br.call(t,e)};H.prototype.listenerCount=Br;function Br(t){var e=this._events;if(e!==void 0){var n=e[t];if(typeof n=="function")return 1;if(n!==void 0)return n.length}return 0}H.prototype.eventNames=function(){return this._eventsCount>0?je(this._events):[]};function Fr(t,e){for(var n=new Array(e),a=0;a"u"||!V?k:V(Uint8Array),ue={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?k:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?k:ArrayBuffer,"%ArrayIteratorPrototype%":de&&V?V([][Symbol.iterator]()):k,"%AsyncFromSyncIteratorPrototype%":k,"%AsyncFunction%":ye,"%AsyncGenerator%":ye,"%AsyncGeneratorFunction%":ye,"%AsyncIteratorPrototype%":ye,"%Atomics%":typeof Atomics>"u"?k:Atomics,"%BigInt%":typeof BigInt>"u"?k:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?k:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?k:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?k:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Gn,"%eval%":eval,"%EvalError%":Vn,"%Float32Array%":typeof Float32Array>"u"?k:Float32Array,"%Float64Array%":typeof Float64Array>"u"?k:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?k:FinalizationRegistry,"%Function%":qr,"%GeneratorFunction%":ye,"%Int8Array%":typeof Int8Array>"u"?k:Int8Array,"%Int16Array%":typeof Int16Array>"u"?k:Int16Array,"%Int32Array%":typeof Int32Array>"u"?k:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":de&&V?V(V([][Symbol.iterator]())):k,"%JSON%":typeof JSON=="object"?JSON:k,"%Map%":typeof Map>"u"?k:Map,"%MapIteratorPrototype%":typeof Map>"u"||!de||!V?k:V(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Wr,"%Object.getOwnPropertyDescriptor%":Se,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?k:Promise,"%Proxy%":typeof Proxy>"u"?k:Proxy,"%RangeError%":zn,"%ReferenceError%":Kn,"%Reflect%":typeof Reflect>"u"?k:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?k:Set,"%SetIteratorPrototype%":typeof Set>"u"||!de||!V?k:V(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?k:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":de&&V?V(""[Symbol.iterator]()):k,"%Symbol%":de?Symbol:k,"%SyntaxError%":be,"%ThrowTypeError%":ri,"%TypedArray%":ii,"%TypeError%":ve,"%Uint8Array%":typeof Uint8Array>"u"?k:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?k:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?k:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?k:Uint32Array,"%URIError%":Jn,"%WeakMap%":typeof WeakMap>"u"?k:WeakMap,"%WeakRef%":typeof WeakRef>"u"?k:WeakRef,"%WeakSet%":typeof WeakSet>"u"?k:WeakSet,"%Function.prototype.call%":Re,"%Function.prototype.apply%":xr,"%Object.defineProperty%":ti,"%Math.abs%":Yn,"%Math.floor%":Xn,"%Math.max%":Zn,"%Math.min%":Qn,"%Math.pow%":ei};if(V)try{null.error}catch(t){var oi=V(V(t));ue["%Error.prototype%"]=oi}var ai=function t(e){var n;if(e==="%AsyncFunction%")n=nt("async function () {}");else if(e==="%GeneratorFunction%")n=nt("function* () {}");else if(e==="%AsyncGeneratorFunction%")n=nt("async function* () {}");else if(e==="%AsyncGenerator%"){var a=t("%AsyncGeneratorFunction%");a&&(n=a.prototype)}else if(e==="%AsyncIteratorPrototype%"){var p=t("%AsyncGenerator%");p&&V&&(n=V(p.prototype))}return ue[e]=n,n},er={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},Oe=Ae(),Ce=Hn(),fi=Oe.call(Re,Array.prototype.concat),ui=Oe.call(xr,Array.prototype.splice),tr=Oe.call(Re,String.prototype.replace),De=Oe.call(Re,String.prototype.slice),si=Oe.call(Re,RegExp.prototype.exec),li=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,ci=/\\(\\)?/g,di=function(e){var n=De(e,0,1),a=De(e,-1);if(n==="%"&&a!=="%")throw new be("invalid intrinsic syntax, expected closing `%`");if(a==="%"&&n!=="%")throw new be("invalid intrinsic syntax, expected opening `%`");var p=[];return tr(e,li,function(s,y,f,d){p[p.length]=f?tr(d,ci,"$1"):y||s}),p},pi=function(e,n){var a=e,p;if(Ce(er,a)&&(p=er[a],a="%"+p[0]+"%"),Ce(ue,a)){var s=ue[a];if(s===ye&&(s=ai(a)),typeof s>"u"&&!n)throw new ve("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:p,name:a,value:s}}throw new be("intrinsic "+e+" does not exist!")},Hr=function(e,n){if(typeof e!="string"||e.length===0)throw new ve("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof n!="boolean")throw new ve('"allowMissing" argument must be a boolean');if(si(/^%?[^%]*%?$/,e)===null)throw new be("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var a=di(e),p=a.length>0?a[0]:"",s=pi("%"+p+"%",n),y=s.name,f=s.value,d=!1,g=s.alias;g&&(p=g[0],ui(a,fi([0,1],g)));for(var O=1,R=!0;O=a.length){var l=Se(f,E);R=!!l,R&&"get"in l&&!("originalValue"in l.get)?f=l.get:f=f[E]}else R=Ce(f,E),f=f[E];R&&!d&&(ue[y]=f)}}return f},Gr=Hr,Vr=It,yi=Vr([Gr("%String.prototype.indexOf%")]),zr=function(e,n){var a=Gr(e,!!n);return typeof a=="function"&&yi(e,".prototype.")>-1?Vr([a]):a},hi=Ft(),gi=zr,Ot=gi("Object.prototype.toString"),He=function(e){return hi&&e&&typeof e=="object"&&Symbol.toStringTag in e?!1:Ot(e)==="[object Arguments]"},Kr=function(e){return He(e)?!0:e!==null&&typeof e=="object"&&"length"in e&&typeof e.length=="number"&&e.length>=0&&Ot(e)!=="[object Array]"&&"callee"in e&&Ot(e.callee)==="[object Function]"},vi=function(){return He(arguments)}();He.isLegacyArguments=Kr;var bi=vi?He:Kr,wi=Object.prototype.toString,mi=Function.prototype.toString,_i=/^\s*(?:function)?\*/,Jr=Ft(),ot=Object.getPrototypeOf,Si=function(){if(!Jr)return!1;try{return Function("return function*() {}")()}catch{}},at,Ei=function(e){if(typeof e!="function")return!1;if(_i.test(mi.call(e)))return!0;if(!Jr){var n=wi.call(e);return n==="[object GeneratorFunction]"}if(!ot)return!1;if(typeof at>"u"){var a=Si();at=a?ot(a):!1}return ot(e)===at},Yr=Function.prototype.toString,he=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,Pt,Ne;if(typeof he=="function"&&typeof Object.defineProperty=="function")try{Pt=Object.defineProperty({},"length",{get:function(){throw Ne}}),Ne={},he(function(){throw 42},null,Pt)}catch(t){t!==Ne&&(he=null)}else he=null;var Ai=/^\s*class\b/,Tt=function(e){try{var n=Yr.call(e);return Ai.test(n)}catch{return!1}},ft=function(e){try{return Tt(e)?!1:(Yr.call(e),!0)}catch{return!1}},Be=Object.prototype.toString,Ri="[object Object]",Oi="[object Function]",Pi="[object GeneratorFunction]",Ti="[object HTMLAllCollection]",ji="[object HTML document.all class]",Mi="[object HTMLCollection]",Li=typeof Symbol=="function"&&!!Symbol.toStringTag,Ni=!(0 in[,]),jt=function(){return!1};if(typeof document=="object"){var Bi=document.all;Be.call(Bi)===Be.call(document.all)&&(jt=function(e){if((Ni||!e)&&(typeof e>"u"||typeof e=="object"))try{var n=Be.call(e);return(n===Ti||n===ji||n===Mi||n===Ri)&&e("")==null}catch{}return!1})}var Fi=he?function(e){if(jt(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{he(e,null,Pt)}catch(n){if(n!==Ne)return!1}return!Tt(e)&&ft(e)}:function(e){if(jt(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(Li)return ft(e);if(Tt(e))return!1;var n=Be.call(e);return n!==Oi&&n!==Pi&&!/^\[object HTML/.test(n)?!1:ft(e)},Ci=Fi,Di=Object.prototype.toString,Xr=Object.prototype.hasOwnProperty,Ii=function(e,n,a){for(var p=0,s=e.length;p=3&&(p=a),Di.call(e)==="[object Array]"?Ii(e,n,p):typeof e=="string"?$i(e,n,p):Ui(e,n,p)},Wi=ki,qi=["Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"],ut=qi,xi=typeof globalThis>"u"?fe:globalThis,Hi=function(){for(var e=[],n=0;n3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new pe("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new pe("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new pe("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new pe("`loose`, if provided, must be a boolean");var p=arguments.length>3?arguments[3]:null,s=arguments.length>4?arguments[4]:null,y=arguments.length>5?arguments[5]:null,f=arguments.length>6?arguments[6]:!1,d=!!nr&&nr(e,n);if(rr)rr(e,n,{configurable:y===null&&d?d.configurable:!y,enumerable:p===null&&d?d.enumerable:!p,value:a,writable:s===null&&d?d.writable:!s});else if(f||!p&&!s&&!y)e[n]=a;else throw new Gi("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},Mt=xe,Qr=function(){return!!Mt};Qr.hasArrayLengthDefineBug=function(){if(!Mt)return null;try{return Mt([],"length",{value:1}).length!==1}catch{return!0}};var zi=Qr,Ki=Hr,ir=Vi,Ji=zi(),or=Ee,ar=qe,Yi=Ki("%Math.floor%"),Xi=function(e,n){if(typeof e!="function")throw new ar("`fn` is not a function");if(typeof n!="number"||n<0||n>4294967295||Yi(n)!==n)throw new ar("`length` must be a positive 32-bit integer");var a=arguments.length>2&&!!arguments[2],p=!0,s=!0;if("length"in e&&or){var y=or(e,"length");y&&!y.configurable&&(p=!1),y&&!y.writable&&(s=!1)}return(p||s||!a)&&(Ji?ir(e,"length",n,!0,!0):ir(e,"length",n)),e},Zi=Ae(),Qi=Dt(),eo=kr,to=function(){return eo(Zi,Qi,arguments)};(function(t){var e=Xi,n=xe,a=It,p=to;t.exports=function(y){var f=a(arguments),d=y.length-(arguments.length-1);return e(f,1+(d>0?d:0),!0)},n?n(t.exports,"apply",{value:p}):t.exports.apply=p})(Zr);var ro=Zr.exports,Ie=Wi,no=Hi,fr=ro,$t=zr,Fe=Ee,io=$t("Object.prototype.toString"),en=Ft(),ur=typeof globalThis>"u"?fe:globalThis,Lt=no(),Ut=$t("String.prototype.slice"),st=Object.getPrototypeOf,oo=$t("Array.prototype.indexOf",!0)||function(e,n){for(var a=0;a-1?n:n!=="Object"?!1:fo(e)}return Fe?ao(e):null},uo=tn,so=function(e){return!!uo(e)};(function(t){var e=bi,n=Ei,a=tn,p=so;function s(_){return _.call.bind(_)}var y=typeof BigInt<"u",f=typeof Symbol<"u",d=s(Object.prototype.toString),g=s(Number.prototype.valueOf),O=s(String.prototype.valueOf),R=s(Boolean.prototype.valueOf);if(y)var E=s(BigInt.prototype.valueOf);if(f)var P=s(Symbol.prototype.valueOf);function j(_,Pe){if(typeof _!="object")return!1;try{return Pe(_),!0}catch{return!1}}t.isArgumentsObject=e,t.isGeneratorFunction=n,t.isTypedArray=p;function l(_){return typeof Promise<"u"&&_ instanceof Promise||_!==null&&typeof _=="object"&&typeof _.then=="function"&&typeof _.catch=="function"}t.isPromise=l;function v(_){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?ArrayBuffer.isView(_):p(_)||h(_)}t.isArrayBufferView=v;function o(_){return a(_)==="Uint8Array"}t.isUint8Array=o;function b(_){return a(_)==="Uint8ClampedArray"}t.isUint8ClampedArray=b;function A(_){return a(_)==="Uint16Array"}t.isUint16Array=A;function M(_){return a(_)==="Uint32Array"}t.isUint32Array=M;function N(_){return a(_)==="Int8Array"}t.isInt8Array=N;function C(_){return a(_)==="Int16Array"}t.isInt16Array=C;function W(_){return a(_)==="Int32Array"}t.isInt32Array=W;function I(_){return a(_)==="Float32Array"}t.isFloat32Array=I;function D(_){return a(_)==="Float64Array"}t.isFloat64Array=D;function G(_){return a(_)==="BigInt64Array"}t.isBigInt64Array=G;function Y(_){return a(_)==="BigUint64Array"}t.isBigUint64Array=Y;function K(_){return d(_)==="[object Map]"}K.working=typeof Map<"u"&&K(new Map);function J(_){return typeof Map>"u"?!1:K.working?K(_):_ instanceof Map}t.isMap=J;function re(_){return d(_)==="[object Set]"}re.working=typeof Set<"u"&&re(new Set);function ne(_){return typeof Set>"u"?!1:re.working?re(_):_ instanceof Set}t.isSet=ne;function X(_){return d(_)==="[object WeakMap]"}X.working=typeof WeakMap<"u"&&X(new WeakMap);function Q(_){return typeof WeakMap>"u"?!1:X.working?X(_):_ instanceof WeakMap}t.isWeakMap=Q;function ie(_){return d(_)==="[object WeakSet]"}ie.working=typeof WeakSet<"u"&&ie(new WeakSet);function ee(_){return ie(_)}t.isWeakSet=ee;function z(_){return d(_)==="[object ArrayBuffer]"}z.working=typeof ArrayBuffer<"u"&&z(new ArrayBuffer);function oe(_){return typeof ArrayBuffer>"u"?!1:z.working?z(_):_ instanceof ArrayBuffer}t.isArrayBuffer=oe;function te(_){return d(_)==="[object DataView]"}te.working=typeof ArrayBuffer<"u"&&typeof DataView<"u"&&te(new DataView(new ArrayBuffer(1),0,1));function h(_){return typeof DataView>"u"?!1:te.working?te(_):_ instanceof DataView}t.isDataView=h;var m=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:void 0;function T(_){return d(_)==="[object SharedArrayBuffer]"}function u(_){return typeof m>"u"?!1:(typeof T.working>"u"&&(T.working=T(new m)),T.working?T(_):_ instanceof m)}t.isSharedArrayBuffer=u;function c(_){return d(_)==="[object AsyncFunction]"}t.isAsyncFunction=c;function w(_){return d(_)==="[object Map Iterator]"}t.isMapIterator=w;function L(_){return d(_)==="[object Set Iterator]"}t.isSetIterator=L;function B(_){return d(_)==="[object Generator]"}t.isGeneratorObject=B;function r(_){return d(_)==="[object WebAssembly.Module]"}t.isWebAssemblyCompiledModule=r;function i(_){return j(_,g)}t.isNumberObject=i;function S(_){return j(_,O)}t.isStringObject=S;function F(_){return j(_,R)}t.isBooleanObject=F;function q(_){return y&&j(_,E)}t.isBigIntObject=q;function $(_){return f&&j(_,P)}t.isSymbolObject=$;function x(_){return i(_)||S(_)||F(_)||q(_)||$(_)}t.isBoxedPrimitive=x;function ae(_){return typeof Uint8Array<"u"&&(oe(_)||u(_))}t.isAnyArrayBuffer=ae,["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(_){Object.defineProperty(t,_,{enumerable:!1,value:function(){throw new Error(_+" is not supported in userland")}})})})(Ir);var lo=function(e){return e&&typeof e=="object"&&typeof e.copy=="function"&&typeof e.fill=="function"&&typeof e.readUInt8=="function"};(function(t){var e={},n=Object.getOwnPropertyDescriptors||function(m){for(var T=Object.keys(m),u={},c=0;c=c)return B;switch(B){case"%s":return String(u[T++]);case"%d":return Number(u[T++]);case"%j":try{return JSON.stringify(u[T++])}catch{return"[Circular]"}default:return B}}),L=u[T];T"u")return function(){return t.deprecate(h,m).apply(this,arguments)};var T=!1;function u(){if(!T){if(U.throwDeprecation)throw new Error(m);U.traceDeprecation?console.trace(m):console.error(m),T=!0}return h.apply(this,arguments)}return u};var p={},s=/^$/;if(e.NODE_DEBUG){var y=e.NODE_DEBUG;y=y.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),s=new RegExp("^"+y+"$","i")}t.debuglog=function(h){if(h=h.toUpperCase(),!p[h])if(s.test(h)){var m=U.pid;p[h]=function(){var T=t.format.apply(t,arguments);console.error("%s %d: %s",h,m,T)}}else p[h]=function(){};return p[h]};function f(h,m){var T={seen:[],stylize:g};return arguments.length>=3&&(T.depth=arguments[2]),arguments.length>=4&&(T.colors=arguments[3]),b(m)?T.showHidden=m:m&&t._extend(T,m),I(T.showHidden)&&(T.showHidden=!1),I(T.depth)&&(T.depth=2),I(T.colors)&&(T.colors=!1),I(T.customInspect)&&(T.customInspect=!0),T.colors&&(T.stylize=d),R(T,h,T.depth)}t.inspect=f,f.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},f.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function d(h,m){var T=f.styles[m];return T?"\x1B["+f.colors[T][0]+"m"+h+"\x1B["+f.colors[T][1]+"m":h}function g(h,m){return h}function O(h){var m={};return h.forEach(function(T,u){m[T]=!0}),m}function R(h,m,T){if(h.customInspect&&m&&J(m.inspect)&&m.inspect!==t.inspect&&!(m.constructor&&m.constructor.prototype===m)){var u=m.inspect(T,h);return C(u)||(u=R(h,u,T)),u}var c=E(h,m);if(c)return c;var w=Object.keys(m),L=O(w);if(h.showHidden&&(w=Object.getOwnPropertyNames(m)),K(m)&&(w.indexOf("message")>=0||w.indexOf("description")>=0))return P(m);if(w.length===0){if(J(m)){var B=m.name?": "+m.name:"";return h.stylize("[Function"+B+"]","special")}if(D(m))return h.stylize(RegExp.prototype.toString.call(m),"regexp");if(Y(m))return h.stylize(Date.prototype.toString.call(m),"date");if(K(m))return P(m)}var r="",i=!1,S=["{","}"];if(o(m)&&(i=!0,S=["[","]"]),J(m)){var F=m.name?": "+m.name:"";r=" [Function"+F+"]"}if(D(m)&&(r=" "+RegExp.prototype.toString.call(m)),Y(m)&&(r=" "+Date.prototype.toUTCString.call(m)),K(m)&&(r=" "+P(m)),w.length===0&&(!i||m.length==0))return S[0]+r+S[1];if(T<0)return D(m)?h.stylize(RegExp.prototype.toString.call(m),"regexp"):h.stylize("[Object]","special");h.seen.push(m);var q;return i?q=j(h,m,T,L,w):q=w.map(function($){return l(h,m,T,L,$,i)}),h.seen.pop(),v(q,r,S)}function E(h,m){if(I(m))return h.stylize("undefined","undefined");if(C(m)){var T="'"+JSON.stringify(m).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return h.stylize(T,"string")}if(N(m))return h.stylize(""+m,"number");if(b(m))return h.stylize(""+m,"boolean");if(A(m))return h.stylize("null","null")}function P(h){return"["+Error.prototype.toString.call(h)+"]"}function j(h,m,T,u,c){for(var w=[],L=0,B=m.length;L-1&&(w?B=B.split(` `).map(function(i){return" "+i}).join(` `).slice(2):B=` diff --git a/apps/cli/frontend/assets/index-C0B7FSMw.js b/apps/cli/frontend/assets/index-BcZMUM3W.js similarity index 98% rename from apps/cli/frontend/assets/index-C0B7FSMw.js rename to apps/cli/frontend/assets/index-BcZMUM3W.js index f248d51b..f59d5026 100644 --- a/apps/cli/frontend/assets/index-C0B7FSMw.js +++ b/apps/cli/frontend/assets/index-BcZMUM3W.js @@ -1,5 +1,5 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/page-D3nC2yWj.js","assets/SimpleGridForm-BMdftmE-.js","assets/index-lYdp9a7W.js","assets/browser-DplhMTqm.js","assets/__vite-browser-external-v7f2oYTb.js","assets/index-C4_N9hxJ.js","assets/index-D5ks1fN6.js","assets/index-Cxn6EJsJ.js","assets/page-DXvJlC_-.js"])))=>i.map(i=>d[i]); -function Dee(d,e){for(var t=0;ts[i]})}}}return Object.freeze(Object.defineProperty(d,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const n of i)if(n.type==="childList")for(const r of n.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&s(r)}).observe(document,{childList:!0,subtree:!0});function t(i){const n={};return i.integrity&&(n.integrity=i.integrity),i.referrerPolicy&&(n.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?n.credentials="include":i.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function s(i){if(i.ep)return;i.ep=!0;const n=t(i);fetch(i.href,n)}})();var Sc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function sT(d){return d&&d.__esModule&&Object.prototype.hasOwnProperty.call(d,"default")?d.default:d}function uWe(d){if(d.__esModule)return d;var e=d.default;if(typeof e=="function"){var t=function s(){return this instanceof s?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(d).forEach(function(s){var i=Object.getOwnPropertyDescriptor(d,s);Object.defineProperty(t,s,i.get?i:{enumerable:!0,get:function(){return d[s]}})}),t}var i4={exports:{}},iT={},n4={exports:{}},ws={};/** +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/page-CoZS_l39.js","assets/SimpleGridForm-E2pE-hYE.js","assets/index-Dm5rXNPH.js","assets/browser-9oIzATog.js","assets/__vite-browser-external-v7f2oYTb.js","assets/index-Dc5kAPfD.js","assets/index-DTsNrB5y.js","assets/index-C9ivc5Jj.js","assets/page-DokNskun.js"])))=>i.map(i=>d[i]); +function Dee(d,e){for(var t=0;ts[i]})}}}return Object.freeze(Object.defineProperty(d,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const n of i)if(n.type==="childList")for(const r of n.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&s(r)}).observe(document,{childList:!0,subtree:!0});function t(i){const n={};return i.integrity&&(n.integrity=i.integrity),i.referrerPolicy&&(n.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?n.credentials="include":i.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function s(i){if(i.ep)return;i.ep=!0;const n=t(i);fetch(i.href,n)}})();var Sc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function sT(d){return d&&d.__esModule&&Object.prototype.hasOwnProperty.call(d,"default")?d.default:d}function lWe(d){if(d.__esModule)return d;var e=d.default;if(typeof e=="function"){var t=function s(){return this instanceof s?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(d).forEach(function(s){var i=Object.getOwnPropertyDescriptor(d,s);Object.defineProperty(t,s,i.get?i:{enumerable:!0,get:function(){return d[s]}})}),t}var i4={exports:{}},iT={},n4={exports:{}},ws={};/** * @license React * react.production.min.js * @@ -59,7 +59,7 @@ Error generating stack: `+n.message+` * * @author Feross Aboukhadijeh * @license MIT - */(function(d){const e=TT,t=Q_,s=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;d.Buffer=u,d.SlowBuffer=v,d.INSPECT_MAX_BYTES=50;const i=2147483647;d.kMaxLength=i;const{Uint8Array:n,ArrayBuffer:r,SharedArrayBuffer:a}=globalThis;u.TYPED_ARRAY_SUPPORT=o(),!u.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function o(){try{const se=new n(1),F={foo:function(){return 42}};return Object.setPrototypeOf(F,n.prototype),Object.setPrototypeOf(se,F),se.foo()===42}catch{return!1}}Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}});function c(se){if(se>i)throw new RangeError('The value "'+se+'" is invalid for option "size"');const F=new n(se);return Object.setPrototypeOf(F,u.prototype),F}function u(se,F,V){if(typeof se=="number"){if(typeof F=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return p(se)}return h(se,F,V)}u.poolSize=8192;function h(se,F,V){if(typeof se=="string")return m(se,F);if(r.isView(se))return y(se);if(se==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof se);if(yt(se,r)||se&&yt(se.buffer,r)||typeof a<"u"&&(yt(se,a)||se&&yt(se.buffer,a)))return w(se,F,V);if(typeof se=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const re=se.valueOf&&se.valueOf();if(re!=null&&re!==se)return u.from(re,F,V);const le=b(se);if(le)return le;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof se[Symbol.toPrimitive]=="function")return u.from(se[Symbol.toPrimitive]("string"),F,V);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof se)}u.from=function(se,F,V){return h(se,F,V)},Object.setPrototypeOf(u.prototype,n.prototype),Object.setPrototypeOf(u,n);function l(se){if(typeof se!="number")throw new TypeError('"size" argument must be of type number');if(se<0)throw new RangeError('The value "'+se+'" is invalid for option "size"')}function f(se,F,V){return l(se),se<=0?c(se):F!==void 0?typeof V=="string"?c(se).fill(F,V):c(se).fill(F):c(se)}u.alloc=function(se,F,V){return f(se,F,V)};function p(se){return l(se),c(se<0?0:S(se)|0)}u.allocUnsafe=function(se){return p(se)},u.allocUnsafeSlow=function(se){return p(se)};function m(se,F){if((typeof F!="string"||F==="")&&(F="utf8"),!u.isEncoding(F))throw new TypeError("Unknown encoding: "+F);const V=C(se,F)|0;let re=c(V);const le=re.write(se,F);return le!==V&&(re=re.slice(0,le)),re}function g(se){const F=se.length<0?0:S(se.length)|0,V=c(F);for(let re=0;re=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return se|0}function v(se){return+se!=se&&(se=0),u.alloc(+se)}u.isBuffer=function(F){return F!=null&&F._isBuffer===!0&&F!==u.prototype},u.compare=function(F,V){if(yt(F,n)&&(F=u.from(F,F.offset,F.byteLength)),yt(V,n)&&(V=u.from(V,V.offset,V.byteLength)),!u.isBuffer(F)||!u.isBuffer(V))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(F===V)return 0;let re=F.length,le=V.length;for(let ke=0,Ne=Math.min(re,le);kele.length?(u.isBuffer(Ne)||(Ne=u.from(Ne)),Ne.copy(le,ke)):n.prototype.set.call(le,Ne,ke);else if(u.isBuffer(Ne))Ne.copy(le,ke);else throw new TypeError('"list" argument must be an Array of Buffers');ke+=Ne.length}return le};function C(se,F){if(u.isBuffer(se))return se.length;if(r.isView(se)||yt(se,r))return se.byteLength;if(typeof se!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof se);const V=se.length,re=arguments.length>2&&arguments[2]===!0;if(!re&&V===0)return 0;let le=!1;for(;;)switch(F){case"ascii":case"latin1":case"binary":return V;case"utf8":case"utf-8":return ze(se).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return V*2;case"hex":return V>>>1;case"base64":return st(se).length;default:if(le)return re?-1:ze(se).length;F=(""+F).toLowerCase(),le=!0}}u.byteLength=C;function M(se,F,V){let re=!1;if((F===void 0||F<0)&&(F=0),F>this.length||((V===void 0||V>this.length)&&(V=this.length),V<=0)||(V>>>=0,F>>>=0,V<=F))return"";for(se||(se="utf8");;)switch(se){case"hex":return Q(this,F,V);case"utf8":case"utf-8":return J(this,F,V);case"ascii":return Z(this,F,V);case"latin1":case"binary":return te(this,F,V);case"base64":return z(this,F,V);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ie(this,F,V);default:if(re)throw new TypeError("Unknown encoding: "+se);se=(se+"").toLowerCase(),re=!0}}u.prototype._isBuffer=!0;function _(se,F,V){const re=se[F];se[F]=se[V],se[V]=re}u.prototype.swap16=function(){const F=this.length;if(F%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let V=0;VV&&(F+=" ... "),""},s&&(u.prototype[s]=u.prototype.inspect),u.prototype.compare=function(F,V,re,le,ke){if(yt(F,n)&&(F=u.from(F,F.offset,F.byteLength)),!u.isBuffer(F))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof F);if(V===void 0&&(V=0),re===void 0&&(re=F?F.length:0),le===void 0&&(le=0),ke===void 0&&(ke=this.length),V<0||re>F.length||le<0||ke>this.length)throw new RangeError("out of range index");if(le>=ke&&V>=re)return 0;if(le>=ke)return-1;if(V>=re)return 1;if(V>>>=0,re>>>=0,le>>>=0,ke>>>=0,this===F)return 0;let Ne=ke-le,wt=re-V;const Yt=Math.min(Ne,wt),zt=this.slice(le,ke),Et=F.slice(V,re);for(let bt=0;bt2147483647?V=2147483647:V<-2147483648&&(V=-2147483648),V=+V,Bt(V)&&(V=le?0:se.length-1),V<0&&(V=se.length+V),V>=se.length){if(le)return-1;V=se.length-1}else if(V<0)if(le)V=0;else return-1;if(typeof F=="string"&&(F=u.from(F,re)),u.isBuffer(F))return F.length===0?-1:A(se,F,V,re,le);if(typeof F=="number")return F=F&255,typeof n.prototype.indexOf=="function"?le?n.prototype.indexOf.call(se,F,V):n.prototype.lastIndexOf.call(se,F,V):A(se,[F],V,re,le);throw new TypeError("val must be string, number or Buffer")}function A(se,F,V,re,le){let ke=1,Ne=se.length,wt=F.length;if(re!==void 0&&(re=String(re).toLowerCase(),re==="ucs2"||re==="ucs-2"||re==="utf16le"||re==="utf-16le")){if(se.length<2||F.length<2)return-1;ke=2,Ne/=2,wt/=2,V/=2}function Yt(Et,bt){return ke===1?Et[bt]:Et.readUInt16BE(bt*ke)}let zt;if(le){let Et=-1;for(zt=V;ztNe&&(V=Ne-wt),zt=V;zt>=0;zt--){let Et=!0;for(let bt=0;btle&&(re=le)):re=le;const ke=F.length;re>ke/2&&(re=ke/2);let Ne;for(Ne=0;Ne>>0,isFinite(re)?(re=re>>>0,le===void 0&&(le="utf8")):(le=re,re=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const ke=this.length-V;if((re===void 0||re>ke)&&(re=ke),F.length>0&&(re<0||V<0)||V>this.length)throw new RangeError("Attempt to write outside buffer bounds");le||(le="utf8");let Ne=!1;for(;;)switch(le){case"hex":return R(this,F,V,re);case"utf8":case"utf-8":return D(this,F,V,re);case"ascii":case"latin1":case"binary":return U(this,F,V,re);case"base64":return K(this,F,V,re);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return j(this,F,V,re);default:if(Ne)throw new TypeError("Unknown encoding: "+le);le=(""+le).toLowerCase(),Ne=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function z(se,F,V){return F===0&&V===se.length?e.fromByteArray(se):e.fromByteArray(se.slice(F,V))}function J(se,F,V){V=Math.min(se.length,V);const re=[];let le=F;for(;le239?4:ke>223?3:ke>191?2:1;if(le+wt<=V){let Yt,zt,Et,bt;switch(wt){case 1:ke<128&&(Ne=ke);break;case 2:Yt=se[le+1],(Yt&192)===128&&(bt=(ke&31)<<6|Yt&63,bt>127&&(Ne=bt));break;case 3:Yt=se[le+1],zt=se[le+2],(Yt&192)===128&&(zt&192)===128&&(bt=(ke&15)<<12|(Yt&63)<<6|zt&63,bt>2047&&(bt<55296||bt>57343)&&(Ne=bt));break;case 4:Yt=se[le+1],zt=se[le+2],Et=se[le+3],(Yt&192)===128&&(zt&192)===128&&(Et&192)===128&&(bt=(ke&15)<<18|(Yt&63)<<12|(zt&63)<<6|Et&63,bt>65535&&bt<1114112&&(Ne=bt))}}Ne===null?(Ne=65533,wt=1):Ne>65535&&(Ne-=65536,re.push(Ne>>>10&1023|55296),Ne=56320|Ne&1023),re.push(Ne),le+=wt}return X(re)}const Y=4096;function X(se){const F=se.length;if(F<=Y)return String.fromCharCode.apply(String,se);let V="",re=0;for(;rere)&&(V=re);let le="";for(let ke=F;kere&&(F=re),V<0?(V+=re,V<0&&(V=0)):V>re&&(V=re),VV)throw new RangeError("Trying to access beyond buffer length")}u.prototype.readUintLE=u.prototype.readUIntLE=function(F,V,re){F=F>>>0,V=V>>>0,re||ne(F,V,this.length);let le=this[F],ke=1,Ne=0;for(;++Ne>>0,V=V>>>0,re||ne(F,V,this.length);let le=this[F+--V],ke=1;for(;V>0&&(ke*=256);)le+=this[F+--V]*ke;return le},u.prototype.readUint8=u.prototype.readUInt8=function(F,V){return F=F>>>0,V||ne(F,1,this.length),this[F]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(F,V){return F=F>>>0,V||ne(F,2,this.length),this[F]|this[F+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(F,V){return F=F>>>0,V||ne(F,2,this.length),this[F]<<8|this[F+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(F,V){return F=F>>>0,V||ne(F,4,this.length),(this[F]|this[F+1]<<8|this[F+2]<<16)+this[F+3]*16777216},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(F,V){return F=F>>>0,V||ne(F,4,this.length),this[F]*16777216+(this[F+1]<<16|this[F+2]<<8|this[F+3])},u.prototype.readBigUInt64LE=ht(function(F){F=F>>>0,Be(F,"offset");const V=this[F],re=this[F+7];(V===void 0||re===void 0)&&Me(F,this.length-8);const le=V+this[++F]*2**8+this[++F]*2**16+this[++F]*2**24,ke=this[++F]+this[++F]*2**8+this[++F]*2**16+re*2**24;return BigInt(le)+(BigInt(ke)<>>0,Be(F,"offset");const V=this[F],re=this[F+7];(V===void 0||re===void 0)&&Me(F,this.length-8);const le=V*2**24+this[++F]*2**16+this[++F]*2**8+this[++F],ke=this[++F]*2**24+this[++F]*2**16+this[++F]*2**8+re;return(BigInt(le)<>>0,V=V>>>0,re||ne(F,V,this.length);let le=this[F],ke=1,Ne=0;for(;++Ne=ke&&(le-=Math.pow(2,8*V)),le},u.prototype.readIntBE=function(F,V,re){F=F>>>0,V=V>>>0,re||ne(F,V,this.length);let le=V,ke=1,Ne=this[F+--le];for(;le>0&&(ke*=256);)Ne+=this[F+--le]*ke;return ke*=128,Ne>=ke&&(Ne-=Math.pow(2,8*V)),Ne},u.prototype.readInt8=function(F,V){return F=F>>>0,V||ne(F,1,this.length),this[F]&128?(255-this[F]+1)*-1:this[F]},u.prototype.readInt16LE=function(F,V){F=F>>>0,V||ne(F,2,this.length);const re=this[F]|this[F+1]<<8;return re&32768?re|4294901760:re},u.prototype.readInt16BE=function(F,V){F=F>>>0,V||ne(F,2,this.length);const re=this[F+1]|this[F]<<8;return re&32768?re|4294901760:re},u.prototype.readInt32LE=function(F,V){return F=F>>>0,V||ne(F,4,this.length),this[F]|this[F+1]<<8|this[F+2]<<16|this[F+3]<<24},u.prototype.readInt32BE=function(F,V){return F=F>>>0,V||ne(F,4,this.length),this[F]<<24|this[F+1]<<16|this[F+2]<<8|this[F+3]},u.prototype.readBigInt64LE=ht(function(F){F=F>>>0,Be(F,"offset");const V=this[F],re=this[F+7];(V===void 0||re===void 0)&&Me(F,this.length-8);const le=this[F+4]+this[F+5]*2**8+this[F+6]*2**16+(re<<24);return(BigInt(le)<>>0,Be(F,"offset");const V=this[F],re=this[F+7];(V===void 0||re===void 0)&&Me(F,this.length-8);const le=(V<<24)+this[++F]*2**16+this[++F]*2**8+this[++F];return(BigInt(le)<>>0,V||ne(F,4,this.length),t.read(this,F,!0,23,4)},u.prototype.readFloatBE=function(F,V){return F=F>>>0,V||ne(F,4,this.length),t.read(this,F,!1,23,4)},u.prototype.readDoubleLE=function(F,V){return F=F>>>0,V||ne(F,8,this.length),t.read(this,F,!0,52,8)},u.prototype.readDoubleBE=function(F,V){return F=F>>>0,V||ne(F,8,this.length),t.read(this,F,!1,52,8)};function oe(se,F,V,re,le,ke){if(!u.isBuffer(se))throw new TypeError('"buffer" argument must be a Buffer instance');if(F>le||Fse.length)throw new RangeError("Index out of range")}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(F,V,re,le){if(F=+F,V=V>>>0,re=re>>>0,!le){const wt=Math.pow(2,8*re)-1;oe(this,F,V,re,wt,0)}let ke=1,Ne=0;for(this[V]=F&255;++Ne>>0,re=re>>>0,!le){const wt=Math.pow(2,8*re)-1;oe(this,F,V,re,wt,0)}let ke=re-1,Ne=1;for(this[V+ke]=F&255;--ke>=0&&(Ne*=256);)this[V+ke]=F/Ne&255;return V+re},u.prototype.writeUint8=u.prototype.writeUInt8=function(F,V,re){return F=+F,V=V>>>0,re||oe(this,F,V,1,255,0),this[V]=F&255,V+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(F,V,re){return F=+F,V=V>>>0,re||oe(this,F,V,2,65535,0),this[V]=F&255,this[V+1]=F>>>8,V+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(F,V,re){return F=+F,V=V>>>0,re||oe(this,F,V,2,65535,0),this[V]=F>>>8,this[V+1]=F&255,V+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(F,V,re){return F=+F,V=V>>>0,re||oe(this,F,V,4,4294967295,0),this[V+3]=F>>>24,this[V+2]=F>>>16,this[V+1]=F>>>8,this[V]=F&255,V+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(F,V,re){return F=+F,V=V>>>0,re||oe(this,F,V,4,4294967295,0),this[V]=F>>>24,this[V+1]=F>>>16,this[V+2]=F>>>8,this[V+3]=F&255,V+4};function me(se,F,V,re,le){Re(F,re,le,se,V,7);let ke=Number(F&BigInt(4294967295));se[V++]=ke,ke=ke>>8,se[V++]=ke,ke=ke>>8,se[V++]=ke,ke=ke>>8,se[V++]=ke;let Ne=Number(F>>BigInt(32)&BigInt(4294967295));return se[V++]=Ne,Ne=Ne>>8,se[V++]=Ne,Ne=Ne>>8,se[V++]=Ne,Ne=Ne>>8,se[V++]=Ne,V}function fe(se,F,V,re,le){Re(F,re,le,se,V,7);let ke=Number(F&BigInt(4294967295));se[V+7]=ke,ke=ke>>8,se[V+6]=ke,ke=ke>>8,se[V+5]=ke,ke=ke>>8,se[V+4]=ke;let Ne=Number(F>>BigInt(32)&BigInt(4294967295));return se[V+3]=Ne,Ne=Ne>>8,se[V+2]=Ne,Ne=Ne>>8,se[V+1]=Ne,Ne=Ne>>8,se[V]=Ne,V+8}u.prototype.writeBigUInt64LE=ht(function(F,V=0){return me(this,F,V,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=ht(function(F,V=0){return fe(this,F,V,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(F,V,re,le){if(F=+F,V=V>>>0,!le){const Yt=Math.pow(2,8*re-1);oe(this,F,V,re,Yt-1,-Yt)}let ke=0,Ne=1,wt=0;for(this[V]=F&255;++ke>0)-wt&255;return V+re},u.prototype.writeIntBE=function(F,V,re,le){if(F=+F,V=V>>>0,!le){const Yt=Math.pow(2,8*re-1);oe(this,F,V,re,Yt-1,-Yt)}let ke=re-1,Ne=1,wt=0;for(this[V+ke]=F&255;--ke>=0&&(Ne*=256);)F<0&&wt===0&&this[V+ke+1]!==0&&(wt=1),this[V+ke]=(F/Ne>>0)-wt&255;return V+re},u.prototype.writeInt8=function(F,V,re){return F=+F,V=V>>>0,re||oe(this,F,V,1,127,-128),F<0&&(F=255+F+1),this[V]=F&255,V+1},u.prototype.writeInt16LE=function(F,V,re){return F=+F,V=V>>>0,re||oe(this,F,V,2,32767,-32768),this[V]=F&255,this[V+1]=F>>>8,V+2},u.prototype.writeInt16BE=function(F,V,re){return F=+F,V=V>>>0,re||oe(this,F,V,2,32767,-32768),this[V]=F>>>8,this[V+1]=F&255,V+2},u.prototype.writeInt32LE=function(F,V,re){return F=+F,V=V>>>0,re||oe(this,F,V,4,2147483647,-2147483648),this[V]=F&255,this[V+1]=F>>>8,this[V+2]=F>>>16,this[V+3]=F>>>24,V+4},u.prototype.writeInt32BE=function(F,V,re){return F=+F,V=V>>>0,re||oe(this,F,V,4,2147483647,-2147483648),F<0&&(F=4294967295+F+1),this[V]=F>>>24,this[V+1]=F>>>16,this[V+2]=F>>>8,this[V+3]=F&255,V+4},u.prototype.writeBigInt64LE=ht(function(F,V=0){return me(this,F,V,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=ht(function(F,V=0){return fe(this,F,V,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function he(se,F,V,re,le,ke){if(V+re>se.length)throw new RangeError("Index out of range");if(V<0)throw new RangeError("Index out of range")}function Se(se,F,V,re,le){return F=+F,V=V>>>0,le||he(se,F,V,4),t.write(se,F,V,re,23,4),V+4}u.prototype.writeFloatLE=function(F,V,re){return Se(this,F,V,!0,re)},u.prototype.writeFloatBE=function(F,V,re){return Se(this,F,V,!1,re)};function ye(se,F,V,re,le){return F=+F,V=V>>>0,le||he(se,F,V,8),t.write(se,F,V,re,52,8),V+8}u.prototype.writeDoubleLE=function(F,V,re){return ye(this,F,V,!0,re)},u.prototype.writeDoubleBE=function(F,V,re){return ye(this,F,V,!1,re)},u.prototype.copy=function(F,V,re,le){if(!u.isBuffer(F))throw new TypeError("argument should be a Buffer");if(re||(re=0),!le&&le!==0&&(le=this.length),V>=F.length&&(V=F.length),V||(V=0),le>0&&le=this.length)throw new RangeError("Index out of range");if(le<0)throw new RangeError("sourceEnd out of bounds");le>this.length&&(le=this.length),F.length-V>>0,re=re===void 0?this.length:re>>>0,F||(F=0);let ke;if(typeof F=="number")for(ke=V;ke2**32?le=Ge(String(V)):typeof V=="bigint"&&(le=String(V),(V>BigInt(2)**BigInt(32)||V<-(BigInt(2)**BigInt(32)))&&(le=Ge(le)),le+="n"),re+=` It must be ${F}. Received ${le}`,re},RangeError);function Ge(se){let F="",V=se.length;const re=se[0]==="-"?1:0;for(;V>=re+4;V-=3)F=`_${se.slice(V-3,V)}${F}`;return`${se.slice(0,V)}${F}`}function Ye(se,F,V){Be(F,"offset"),(se[F]===void 0||se[F+V]===void 0)&&Me(F,se.length-(V+1))}function Re(se,F,V,re,le,ke){if(se>V||se= 0${Ne} and < 2${Ne} ** ${(ke+1)*8}${Ne}`:wt=`>= -(2${Ne} ** ${(ke+1)*8-1}${Ne}) and < 2 ** ${(ke+1)*8-1}${Ne}`,new ge.ERR_OUT_OF_RANGE("value",wt,se)}Ye(re,le,ke)}function Be(se,F){if(typeof se!="number")throw new ge.ERR_INVALID_ARG_TYPE(F,"number",se)}function Me(se,F,V){throw Math.floor(se)!==se?(Be(se,V),new ge.ERR_OUT_OF_RANGE("offset","an integer",se)):F<0?new ge.ERR_BUFFER_OUT_OF_BOUNDS:new ge.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${F}`,se)}const Le=/[^+/0-9A-Za-z-_]/g;function rt(se){if(se=se.split("=")[0],se=se.trim().replace(Le,""),se.length<2)return"";for(;se.length%4!==0;)se=se+"=";return se}function ze(se,F){F=F||1/0;let V;const re=se.length;let le=null;const ke=[];for(let Ne=0;Ne55295&&V<57344){if(!le){if(V>56319){(F-=3)>-1&&ke.push(239,191,189);continue}else if(Ne+1===re){(F-=3)>-1&&ke.push(239,191,189);continue}le=V;continue}if(V<56320){(F-=3)>-1&&ke.push(239,191,189),le=V;continue}V=(le-55296<<10|V-56320)+65536}else le&&(F-=3)>-1&&ke.push(239,191,189);if(le=null,V<128){if((F-=1)<0)break;ke.push(V)}else if(V<2048){if((F-=2)<0)break;ke.push(V>>6|192,V&63|128)}else if(V<65536){if((F-=3)<0)break;ke.push(V>>12|224,V>>6&63|128,V&63|128)}else if(V<1114112){if((F-=4)<0)break;ke.push(V>>18|240,V>>12&63|128,V>>6&63|128,V&63|128)}else throw new Error("Invalid code point")}return ke}function Ue(se){const F=[];for(let V=0;V>8,le=V%256,ke.push(le),ke.push(re);return ke}function st(se){return e.toByteArray(rt(se))}function ut(se,F,V,re){let le;for(le=0;le=F.length||le>=se.length);++le)F[le+V]=se[le];return le}function yt(se,F){return se instanceof F||se!=null&&se.constructor!=null&&se.constructor.name!=null&&se.constructor.name===F.name}function Bt(se){return se!==se}const lt=function(){const se="0123456789abcdef",F=new Array(256);for(let V=0;V<16;++V){const re=V*16;for(let le=0;le<16;++le)F[re+le]=se[V]+se[le]}return F}();function ht(se){return typeof BigInt>"u"?ft:se}function ft(){throw new Error("BigInt not supported")}})(pn);const xH=pn.Buffer,hne=pn.Blob,lne=pn.BlobOptions,fne=pn.Buffer,pne=pn.File,mne=pn.FileOptions,gne=pn.INSPECT_MAX_BYTES,yne=pn.SlowBuffer,wne=pn.TranscodeEncoding,bne=pn.atob,kne=pn.btoa,Sne=pn.constants,vne=pn.isAscii,Tne=pn.isUtf8,One=pn.kMaxLength,xne=pn.kStringMaxLength,Pne=pn.resolveObjectURL,Ine=pn.transcode,lWe=Object.freeze(Object.defineProperty({__proto__:null,Blob:hne,BlobOptions:lne,Buffer:fne,File:pne,FileOptions:mne,INSPECT_MAX_BYTES:gne,SlowBuffer:yne,TranscodeEncoding:wne,atob:bne,btoa:kne,constants:Sne,default:xH,isAscii:vne,isUtf8:Tne,kMaxLength:One,kStringMaxLength:xne,resolveObjectURL:Pne,transcode:Ine},Symbol.toStringTag,{value:"Module"})),OT=B.createContext(void 0),Cne=B.createContext(void 0);function Wl(d){const e=B.useContext(d.from?Cne:OT);return Hr({select:s=>{const i=s.matches.find(n=>d.from?d.from===n.routeId:n.id===e);if(ca(!((d.shouldThrow??!0)&&!i),`Could not find ${d.from?`an active match from "${d.from}"`:"a nearest match!"}`),i!==void 0)return d.select?d.select(i):i},structuralSharing:d.structuralSharing})}function Mne(d){return Wl({from:d.from,strict:d.strict,structuralSharing:d.structuralSharing,select:e=>d.select?d.select(e.loaderData):e.loaderData})}function _ne(d){const{select:e,...t}=d;return Wl({...t,select:s=>e?e(s.loaderDeps):s.loaderDeps})}function Ane(d){return Wl({from:d.from,strict:d.strict,structuralSharing:d.structuralSharing,select:e=>d.select?d.select(e.params):e.params})}function Lne(d){return Wl({from:d.from,strict:d.strict,structuralSharing:d.structuralSharing,select:e=>d.select?d.select(e.search):e.search})}function Zc(d){const{navigate:e}=Nh();return B.useCallback(t=>e({...t}),[e])}let PH=class{constructor(e){this.init=t=>{var s,i;this.originalIndex=t.originalIndex;const n=this.options,r=!(n!=null&&n.path)&&!(n!=null&&n.id);this.parentRoute=(i=(s=this.options).getParentRoute)==null?void 0:i.call(s),r?this._path=na:ca(this.parentRoute);let a=r?na:n.path;a&&a!=="/"&&(a=K_(a));const o=(n==null?void 0:n.id)||a;let c=r?na:Nc([this.parentRoute.id===na?"":this.parentRoute.id,o]);a===na&&(a="/"),c!==na&&(c=Nc(["/",c]));const u=c===na?"/":Nc([this.parentRoute.fullPath,a]);this._path=a,this._id=c,this._fullPath=u,this._to=u,this._ssr=(n==null?void 0:n.ssr)??t.defaultSsr??!0},this.updateLoader=t=>(Object.assign(this.options,t),this),this.update=t=>(Object.assign(this.options,t),this),this.lazy=t=>(this.lazyFn=t,this),this.useMatch=t=>Wl({select:t==null?void 0:t.select,from:this.id,structuralSharing:t==null?void 0:t.structuralSharing}),this.useRouteContext=t=>Wl({...t,from:this.id,select:s=>t!=null&&t.select?t.select(s.context):s.context}),this.useSearch=t=>Lne({select:t==null?void 0:t.select,structuralSharing:t==null?void 0:t.structuralSharing,from:this.id}),this.useParams=t=>Ane({select:t==null?void 0:t.select,structuralSharing:t==null?void 0:t.structuralSharing,from:this.id}),this.useLoaderDeps=t=>_ne({...t,from:this.id}),this.useLoaderData=t=>Mne({...t,from:this.id}),this.useNavigate=()=>Zc({from:this.id}),this.options=e||{},this.isRoot=!(e!=null&&e.getParentRoute),ca(!(e!=null&&e.id&&(e!=null&&e.path))),this.$$typeof=Symbol.for("react.memo")}get to(){return this._to}get id(){return this._id}get path(){return this._path}get fullPath(){return this._fullPath}get ssr(){return this._ssr}addChildren(e){return this._addFileChildren(e)}_addFileChildren(e){return Array.isArray(e)&&(this.children=e),typeof e=="object"&&e!==null&&(this.children=Object.values(e)),this}};function Bne(d){return new PH(d)}class Nne extends PH{constructor(e){super(e)}addChildren(e){return super.addChildren(e),this}_addFileChildren(e){return super._addFileChildren(e),this}_addFileTypes(){return this}}function Ene(d){return new Nne(d)}function vr(d){return new Rne(d,{silent:!0}).createRoute}class Rne{constructor(e,t){this.path=e,this.createRoute=s=>{this.silent;const i=Bne(s);return i.isRoot=!1,i},this.silent=t==null?void 0:t.silent}}function ZS(d){return P.jsx(P.Fragment,{children:d.children})}function IH(d,e,t){return e.options.notFoundComponent?P.jsx(e.options.notFoundComponent,{data:t}):d.options.defaultNotFoundComponent?P.jsx(d.options.defaultNotFoundComponent,{data:t}):P.jsx(Xie,{})}const CH=B.memo(function({matchId:e}){var t,s;const i=Nh(),n=Hr({select:g=>{var y;return(y=g.matches.find(w=>w.id===e))==null?void 0:y.routeId}});ca(n);const r=i.routesById[n],a=r.options.pendingComponent??i.options.defaultPendingComponent,o=a?P.jsx(a,{}):null,c=r.options.errorComponent??i.options.defaultErrorComponent,u=r.options.onCatch??i.options.defaultOnCatch,h=r.isRoot?r.options.notFoundComponent??((t=i.options.notFoundRoute)==null?void 0:t.options.component):r.options.notFoundComponent,l=(!r.isRoot||r.options.wrapInSuspense)&&(r.options.wrapInSuspense??a??((s=r.options.errorComponent)==null?void 0:s.preload))?B.Suspense:ZS,f=c?X_:ZS,p=h?Kie:ZS,m=Hr({select:g=>g.loadedAt});return P.jsx(OT.Provider,{value:e,children:P.jsx(l,{fallback:o,children:P.jsx(f,{getResetKey:()=>m,errorComponent:c||vT,onCatch:(g,y)=>{if(Co(g))throw g;u==null||u(g,y)},children:P.jsx(p,{fallback:g=>{if(!h||g.routeId&&g.routeId!==n||!g.routeId&&!r.isRoot)throw g;return B.createElement(h,g)},children:P.jsx(Dne,{matchId:e})})})})})}),Dne=B.memo(function({matchId:e}){var t,s,i,n,r;const a=Nh(),{match:o,matchIndex:c,routeId:u}=Hr({select:p=>{const m=p.matches.findIndex(w=>w.id===e),g=p.matches[m];return{routeId:g.routeId,matchIndex:m,match:YS(g,["id","status","error"])}},structuralSharing:!0}),h=a.routesById[u],l=B.useMemo(()=>{const p=h.options.component??a.options.defaultComponent;return p?P.jsx(p,{}):P.jsx(Y_,{})},[h.options.component,a.options.defaultComponent]),f=(h.options.errorComponent??a.options.defaultErrorComponent)||vT;if(o.status==="notFound"){let p;return DD(o.error)?p=(((t=a.options.errorSerializer)==null?void 0:t.deserialize)??qD)(o.error.data):p=o.error,ca(Co(p)),IH(a,h,p)}if(o.status==="redirected")throw ca(hl(o.error)),(s=a.getMatch(o.id))==null?void 0:s.loadPromise;if(o.status==="error"){if(a.isServer)return P.jsx(f,{error:o.error,info:{componentStack:""}});throw DD(o.error)?(((i=a.options.errorSerializer)==null?void 0:i.deserialize)??qD)(o.error.data):o.error}if(o.status==="pending"){const p=h.options.pendingMinMs??a.options.defaultPendingMinMs;if(p&&!((n=a.getMatch(o.id))!=null&&n.minPendingPromise)&&!a.isServer){const m=mp();Promise.resolve().then(()=>{a.updateMatch(o.id,g=>({...g,minPendingPromise:m}))}),setTimeout(()=>{m.resolve(),a.updateMatch(o.id,g=>({...g,minPendingPromise:void 0}))},p)}throw(r=a.getMatch(o.id))==null?void 0:r.loadPromise}return P.jsxs(P.Fragment,{children:[l,a.AfterEachMatch?P.jsx(a.AfterEachMatch,{match:o,matchIndex:c}):null]})}),Y_=B.memo(function(){const e=Nh(),t=B.useContext(OT),s=Hr({select:c=>{var u;return(u=c.matches.find(h=>h.id===t))==null?void 0:u.routeId}}),i=e.routesById[s],n=Hr({select:c=>{const h=c.matches.find(l=>l.id===t);return ca(h),h.globalNotFound}}),r=Hr({select:c=>{var u;const h=c.matches,l=h.findIndex(f=>f.id===t);return(u=h[l+1])==null?void 0:u.id}});if(n)return IH(e,i,void 0);if(!r)return null;const a=P.jsx(CH,{matchId:r}),o=e.options.defaultPendingComponent?P.jsx(e.options.defaultPendingComponent,{}):null;return t===na?P.jsx(B.Suspense,{fallback:o,children:a}):a}),qne="Error preloading route! ☝️";function Vne(d,e){const t=Nh(),[s,i]=B.useState(!1),n=B.useRef(!1),r=Hie(e),{activeProps:a=()=>({className:"active"}),inactiveProps:o=()=>({}),activeOptions:c,to:u,preload:h,preloadDelay:l,hashScrollIntoView:f,replace:p,startTransition:m,resetScroll:g,viewTransition:y,children:w,target:b,disabled:S,style:v,className:C,onClick:M,onFocus:_,onMouseEnter:N,onMouseLeave:A,onTouchStart:R,ignoreBlocker:D,...U}=d,{params:K,search:j,hash:z,state:J,mask:Y,reloadDocument:X,...Z}=U,te=B.useMemo(()=>{try{return new URL(`${u}`),"external"}catch{}return"internal"},[u]),Q=Hr({select:ze=>ze.location.search,structuralSharing:!0});d={from:Wl({strict:!1,select:ze=>ze.pathname}),...d};const ne=B.useMemo(()=>t.buildLocation(d),[t,d,Q]),oe=B.useMemo(()=>d.reloadDocument?!1:h??t.options.defaultPreload,[t.options.defaultPreload,h,d.reloadDocument]),me=l??t.options.defaultPreloadDelay??0,fe=Hr({select:ze=>{if(c!=null&&c.exact){if(!Uie(ze.location.pathname,ne.pathname,t.basepath))return!1}else{const Ue=J1(ze.location.pathname,t.basepath).split("/");if(!J1(ne.pathname,t.basepath).split("/").every((ut,yt)=>ut===Ue[yt]))return!1}return((c==null?void 0:c.includeSearch)??!0)&&!Zp(ze.location.search,ne.search,{partial:!(c!=null&&c.exact),ignoreUndefined:!(c!=null&&c.explicitUndefined)})?!1:c!=null&&c.includeHash?ze.location.hash===ne.hash:!0}}),he=B.useCallback(()=>{t.preloadRoute(d).catch(ze=>{console.warn(ze),console.warn(qne)})},[d,t]),Se=B.useCallback(ze=>{ze!=null&&ze.isIntersecting&&he()},[he]);if(Fie(r,Se,{rootMargin:"100px"},{disabled:!!S||oe!=="viewport"}),Cy(()=>{n.current||!S&&oe==="render"&&(he(),n.current=!0)},[S,he,oe]),te==="external")return{...Z,ref:r,type:te,href:u,...w&&{children:w},...b&&{target:b},...S&&{disabled:S},...v&&{style:v},...C&&{className:C},...M&&{onClick:M},..._&&{onFocus:_},...N&&{onMouseEnter:N},...A&&{onMouseLeave:A},...R&&{onTouchStart:R}};const ye=ze=>{if(!S&&!Hne(ze)&&!ze.defaultPrevented&&(!b||b==="_self")&&ze.button===0){ze.preventDefault(),bT.flushSync(()=>{i(!0)});const Ue=t.subscribe("onResolved",()=>{Ue(),i(!1)});return t.navigate({...d,replace:p,resetScroll:g,hashScrollIntoView:f,startTransition:m,viewTransition:y,ignoreBlocker:D})}},ge=ze=>{S||oe&&he()},Te=ge,Ge=ze=>{if(S)return;const Ue=ze.target||{};if(oe){if(Ue.preloadTimeout)return;Ue.preloadTimeout=setTimeout(()=>{Ue.preloadTimeout=null,he()},me)}},Ye=ze=>{if(S)return;const Ue=ze.target||{};Ue.preloadTimeout&&(clearTimeout(Ue.preloadTimeout),Ue.preloadTimeout=null)},Re=ze=>Ue=>{var Je;(Je=Ue.persist)==null||Je.call(Ue),ze.filter(Boolean).forEach(st=>{Ue.defaultPrevented||st(Ue)})},Be=fe?Bp(a,{})??{}:{},Me=fe?{}:Bp(o,{}),Le=[C,Be.className,Me.className].filter(Boolean).join(" "),rt={...v,...Be.style,...Me.style};return{...Z,...Be,...Me,href:S?void 0:ne.maskedLocation?t.history.createHref(ne.maskedLocation.href):t.history.createHref(ne.href),ref:r,onClick:Re([M,ye]),onFocus:Re([_,ge]),onMouseEnter:Re([N,Ge]),onMouseLeave:Re([A,Ye]),onTouchStart:Re([R,Te]),disabled:!!S,target:b,...Object.keys(rt).length&&{style:rt},...Le&&{className:Le},...S&&{role:"link","aria-disabled":!0},...fe&&{"data-status":"active","aria-current":"page"},...s&&{"data-transitioning":"transitioning"}}}const Fne=B.forwardRef((d,e)=>{const{_asChild:t,...s}=d,{type:i,ref:n,...r}=Vne(s,e),a=typeof s.children=="function"?s.children({isActive:r["data-status"]==="active"}):s.children;return typeof t>"u"&&delete r.disabled,B.createElement(t||"a",{...r,ref:n},a)});function Hne(d){return!!(d.metaKey||d.altKey||d.ctrlKey||d.shiftKey)}function Gne(){const d=Nh(),e=B.useRef({router:d,mounted:!1}),t=Hr({select:({isLoading:h})=>h}),[s,i]=B.useState(!1),n=Hr({select:h=>h.matches.some(l=>l.status==="pending"),structuralSharing:!0}),r=YP(t),a=t||s||n,o=YP(a),c=t||n,u=YP(c);return d.isServer||(d.startReactTransition=h=>{i(!0),B.startTransition(()=>{h(),i(!1)})}),B.useEffect(()=>{const h=d.history.subscribe(d.load),l=d.buildLocation({to:d.latestLocation.pathname,search:!0,params:!0,hash:!0,state:!0,_includeValidateSearch:!0});return Tl(d.latestLocation.href)!==Tl(l.href)&&d.commitLocation({...l,replace:!0}),()=>{h()}},[d,d.history]),Cy(()=>{var h;if(typeof window<"u"&&((h=window.__TSR__)!=null&&h.dehydrated)||e.current.router===d&&e.current.mounted)return;e.current={router:d,mounted:!0},(async()=>{try{await d.load()}catch(f){console.error(f)}})()},[d]),Cy(()=>{if(r&&!t){const h=d.state.location,l=d.state.resolvedLocation,f=l.pathname!==h.pathname,p=l.href!==h.href;d.emit({type:"onLoad",fromLocation:l,toLocation:h,pathChanged:f,hrefChanged:p})}},[r,d,t]),Cy(()=>{if(u&&!c){const h=d.state.location,l=d.state.resolvedLocation,f=l.pathname!==h.pathname,p=l.href!==h.href;d.emit({type:"onBeforeRouteMount",fromLocation:l,toLocation:h,pathChanged:f,hrefChanged:p})}},[c,u,d]),Cy(()=>{if(o&&!a){const h=d.state.location,l=d.state.resolvedLocation,f=l.pathname!==h.pathname,p=l.href!==h.href;if(d.emit({type:"onResolved",fromLocation:l,toLocation:h,pathChanged:f,hrefChanged:p}),d.__store.setState(m=>({...m,status:"idle",resolvedLocation:m.location})),typeof document<"u"&&document.querySelector){const m=d.state.location.state.__hashScrollIntoViewOptions??!0;if(m&&d.state.location.hash!==""){const g=document.getElementById(d.state.location.hash);g&&g.scrollIntoView(m)}}}},[a,o,d]),null}function Une(){const d=Nh(),e=d.options.defaultPendingComponent?P.jsx(d.options.defaultPendingComponent,{}):null,t=d.isServer||typeof document<"u"&&window.__TSR__?ZS:B.Suspense,s=P.jsxs(t,{fallback:e,children:[P.jsx(Gne,{}),P.jsx(Wne,{})]});return d.options.InnerWrap?P.jsx(d.options.InnerWrap,{children:s}):s}function Wne(){const d=Hr({select:t=>{var s;return(s=t.matches[0])==null?void 0:s.id}}),e=Hr({select:t=>t.loadedAt});return P.jsx(OT.Provider,{value:d,children:P.jsx(X_,{getResetKey:()=>e,errorComponent:vT,onCatch:t=>{t.message||t.toString()},children:d?P.jsx(CH,{matchId:d}):null})})}function jne({router:d,children:e,...t}){d.update({...d.options,...t,context:{...d.options.context,...t.context}});const s=yH(),i=P.jsx(s.Provider,{value:d,children:e});return d.options.Wrap?P.jsx(d.options.Wrap,{children:i}):i}function zne({router:d,...e}){return P.jsx(jne,{router:d,...e,children:P.jsx(Une,{})})}const tg="$$joy";function R0(d){let e="https://mui.com/production-error/?code="+d;for(let t=1;t0?Vn(sg,--zr):0,Im--,en===10&&(Im=1,PT--),en}function wa(){return en=zr2||q0(en)>3?"":" "}function ore(d,e){for(;--e&&wa()&&!(en<48||en>102||en>57&&en<65||en>70&&en<97););return Hw(d,JS()+(e<6&&Ed()==32&&wa()==32))}function OM(d){for(;wa();)switch(en){case d:return zr;case 34:case 39:d!==34&&d!==39&&OM(en);break;case 40:d===41&&OM(d);break;case 92:wa();break}return zr}function dre(d,e){for(;wa()&&d+en!==57;)if(d+en===84&&Ed()===47)break;return"/*"+Hw(e,zr-1)+"*"+xT(d===47?d:wa())}function cre(d){for(;!q0(Ed());)wa();return Hw(d,zr)}function ure(d){return NH(t1("",null,null,null,[""],d=BH(d),0,[0],d))}function t1(d,e,t,s,i,n,r,a,o){for(var c=0,u=0,h=r,l=0,f=0,p=0,m=1,g=1,y=1,w=0,b="",S=i,v=n,C=s,M=b;g;)switch(p=w,w=wa()){case 40:if(p!=108&&Vn(M,h-1)==58){TM(M+=Ns(e1(w),"&","&\f"),"&\f")!=-1&&(y=-1);break}case 34:case 39:case 91:M+=e1(w);break;case 9:case 10:case 13:case 32:M+=are(p);break;case 92:M+=ore(JS()-1,7);continue;case 47:switch(Ed()){case 42:case 47:rS(hre(dre(wa(),JS()),e,t),o);break;default:M+="/"}break;case 123*m:a[c++]=vd(M)*y;case 125*m:case 59:case 0:switch(w){case 0:case 125:g=0;case 59+u:y==-1&&(M=Ns(M,/\f/g,"")),f>0&&vd(M)-h&&rS(f>32?FD(M+";",s,t,h-1):FD(Ns(M," ","")+";",s,t,h-2),o);break;case 59:M+=";";default:if(rS(C=VD(M,e,t,c,u,i,a,b,S=[],v=[],h),n),w===123)if(u===0)t1(M,e,C,C,S,n,h,a,v);else switch(l===99&&Vn(M,3)===110?100:l){case 100:case 108:case 109:case 115:t1(d,C,C,s&&rS(VD(d,C,C,0,0,i,a,b,i,S=[],h),v),i,v,h,a,s?S:v);break;default:t1(M,C,C,C,[""],v,0,a,v)}}c=u=f=0,m=y=1,b=M="",h=r;break;case 58:h=1+vd(M),f=p;default:if(m<1){if(w==123)--m;else if(w==125&&m++==0&&rre()==125)continue}switch(M+=xT(w),w*m){case 38:y=u>0?1:(M+="\f",-1);break;case 44:a[c++]=(vd(M)-1)*y,y=1;break;case 64:Ed()===45&&(M+=e1(wa())),l=Ed(),u=h=vd(b=M+=cre(JS())),w++;break;case 45:p===45&&vd(M)==2&&(m=0)}}return n}function VD(d,e,t,s,i,n,r,a,o,c,u){for(var h=i-1,l=i===0?n:[""],f=eA(l),p=0,m=0,g=0;p0?l[y]+" "+w:Ns(w,/&\f/g,l[y])))&&(o[g++]=b);return IT(d,e,t,i===0?Z_:a,o,c,u)}function hre(d,e,t){return IT(d,e,t,MH,xT(nre()),D0(d,2,-2),0)}function FD(d,e,t,s){return IT(d,e,t,J_,D0(d,0,s),D0(d,s+1,-1),s)}function Jp(d,e){for(var t="",s=eA(d),i=0;i6)switch(Vn(d,e+1)){case 109:if(Vn(d,e+4)!==45)break;case 102:return Ns(d,/(.+:)(.+)-([^]+)/,"$1"+Bs+"$2-$3$1"+tv+(Vn(d,e+3)==108?"$3":"$2-$3"))+d;case 115:return~TM(d,"stretch")?RH(Ns(d,"stretch","fill-available"),e)+d:d}break;case 4949:if(Vn(d,e+1)!==115)break;case 6444:switch(Vn(d,vd(d)-3-(~TM(d,"!important")&&10))){case 107:return Ns(d,":",":"+Bs)+d;case 101:return Ns(d,/(.+:)([^;!]+)(;|!.+)?/,"$1"+Bs+(Vn(d,14)===45?"inline-":"")+"box$3$1"+Bs+"$2$3$1"+Jn+"$2box$3")+d}break;case 5936:switch(Vn(d,e+11)){case 114:return Bs+d+Jn+Ns(d,/[svh]\w+-[tblr]{2}/,"tb")+d;case 108:return Bs+d+Jn+Ns(d,/[svh]\w+-[tblr]{2}/,"tb-rl")+d;case 45:return Bs+d+Jn+Ns(d,/[svh]\w+-[tblr]{2}/,"lr")+d}return Bs+d+Jn+d+d}return d}var kre=function(e,t,s,i){if(e.length>-1&&!e.return)switch(e.type){case J_:e.return=RH(e.value,e.length);break;case _H:return Jp([ry(e,{value:Ns(e.value,"@","@"+Bs)})],i);case Z_:if(e.length)return ire(e.props,function(n){switch(sre(n,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return Jp([ry(e,{props:[Ns(n,/:(read-\w+)/,":"+tv+"$1")]})],i);case"::placeholder":return Jp([ry(e,{props:[Ns(n,/:(plac\w+)/,":"+Bs+"input-$1")]}),ry(e,{props:[Ns(n,/:(plac\w+)/,":"+tv+"$1")]}),ry(e,{props:[Ns(n,/:(plac\w+)/,Jn+"input-$1")]})],i)}return""})}},Sre=[kre],DH=function(e){var t=e.key;if(t==="css"){var s=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(s,function(m){var g=m.getAttribute("data-emotion");g.indexOf(" ")!==-1&&(document.head.appendChild(m),m.setAttribute("data-s",""))})}var i=e.stylisPlugins||Sre,n={},r,a=[];r=e.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+t+' "]'),function(m){for(var g=m.getAttribute("data-emotion").split(" "),y=1;yi)throw new RangeError('The value "'+se+'" is invalid for option "size"');const F=new n(se);return Object.setPrototypeOf(F,u.prototype),F}function u(se,F,V){if(typeof se=="number"){if(typeof F=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return p(se)}return h(se,F,V)}u.poolSize=8192;function h(se,F,V){if(typeof se=="string")return m(se,F);if(r.isView(se))return y(se);if(se==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof se);if(yt(se,r)||se&&yt(se.buffer,r)||typeof a<"u"&&(yt(se,a)||se&&yt(se.buffer,a)))return w(se,F,V);if(typeof se=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const re=se.valueOf&&se.valueOf();if(re!=null&&re!==se)return u.from(re,F,V);const le=b(se);if(le)return le;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof se[Symbol.toPrimitive]=="function")return u.from(se[Symbol.toPrimitive]("string"),F,V);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof se)}u.from=function(se,F,V){return h(se,F,V)},Object.setPrototypeOf(u.prototype,n.prototype),Object.setPrototypeOf(u,n);function l(se){if(typeof se!="number")throw new TypeError('"size" argument must be of type number');if(se<0)throw new RangeError('The value "'+se+'" is invalid for option "size"')}function f(se,F,V){return l(se),se<=0?c(se):F!==void 0?typeof V=="string"?c(se).fill(F,V):c(se).fill(F):c(se)}u.alloc=function(se,F,V){return f(se,F,V)};function p(se){return l(se),c(se<0?0:S(se)|0)}u.allocUnsafe=function(se){return p(se)},u.allocUnsafeSlow=function(se){return p(se)};function m(se,F){if((typeof F!="string"||F==="")&&(F="utf8"),!u.isEncoding(F))throw new TypeError("Unknown encoding: "+F);const V=C(se,F)|0;let re=c(V);const le=re.write(se,F);return le!==V&&(re=re.slice(0,le)),re}function g(se){const F=se.length<0?0:S(se.length)|0,V=c(F);for(let re=0;re=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return se|0}function v(se){return+se!=se&&(se=0),u.alloc(+se)}u.isBuffer=function(F){return F!=null&&F._isBuffer===!0&&F!==u.prototype},u.compare=function(F,V){if(yt(F,n)&&(F=u.from(F,F.offset,F.byteLength)),yt(V,n)&&(V=u.from(V,V.offset,V.byteLength)),!u.isBuffer(F)||!u.isBuffer(V))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(F===V)return 0;let re=F.length,le=V.length;for(let ke=0,Ne=Math.min(re,le);kele.length?(u.isBuffer(Ne)||(Ne=u.from(Ne)),Ne.copy(le,ke)):n.prototype.set.call(le,Ne,ke);else if(u.isBuffer(Ne))Ne.copy(le,ke);else throw new TypeError('"list" argument must be an Array of Buffers');ke+=Ne.length}return le};function C(se,F){if(u.isBuffer(se))return se.length;if(r.isView(se)||yt(se,r))return se.byteLength;if(typeof se!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof se);const V=se.length,re=arguments.length>2&&arguments[2]===!0;if(!re&&V===0)return 0;let le=!1;for(;;)switch(F){case"ascii":case"latin1":case"binary":return V;case"utf8":case"utf-8":return ze(se).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return V*2;case"hex":return V>>>1;case"base64":return st(se).length;default:if(le)return re?-1:ze(se).length;F=(""+F).toLowerCase(),le=!0}}u.byteLength=C;function M(se,F,V){let re=!1;if((F===void 0||F<0)&&(F=0),F>this.length||((V===void 0||V>this.length)&&(V=this.length),V<=0)||(V>>>=0,F>>>=0,V<=F))return"";for(se||(se="utf8");;)switch(se){case"hex":return Q(this,F,V);case"utf8":case"utf-8":return J(this,F,V);case"ascii":return Z(this,F,V);case"latin1":case"binary":return te(this,F,V);case"base64":return z(this,F,V);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ie(this,F,V);default:if(re)throw new TypeError("Unknown encoding: "+se);se=(se+"").toLowerCase(),re=!0}}u.prototype._isBuffer=!0;function _(se,F,V){const re=se[F];se[F]=se[V],se[V]=re}u.prototype.swap16=function(){const F=this.length;if(F%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let V=0;VV&&(F+=" ... "),""},s&&(u.prototype[s]=u.prototype.inspect),u.prototype.compare=function(F,V,re,le,ke){if(yt(F,n)&&(F=u.from(F,F.offset,F.byteLength)),!u.isBuffer(F))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof F);if(V===void 0&&(V=0),re===void 0&&(re=F?F.length:0),le===void 0&&(le=0),ke===void 0&&(ke=this.length),V<0||re>F.length||le<0||ke>this.length)throw new RangeError("out of range index");if(le>=ke&&V>=re)return 0;if(le>=ke)return-1;if(V>=re)return 1;if(V>>>=0,re>>>=0,le>>>=0,ke>>>=0,this===F)return 0;let Ne=ke-le,wt=re-V;const Yt=Math.min(Ne,wt),zt=this.slice(le,ke),Et=F.slice(V,re);for(let bt=0;bt2147483647?V=2147483647:V<-2147483648&&(V=-2147483648),V=+V,Bt(V)&&(V=le?0:se.length-1),V<0&&(V=se.length+V),V>=se.length){if(le)return-1;V=se.length-1}else if(V<0)if(le)V=0;else return-1;if(typeof F=="string"&&(F=u.from(F,re)),u.isBuffer(F))return F.length===0?-1:A(se,F,V,re,le);if(typeof F=="number")return F=F&255,typeof n.prototype.indexOf=="function"?le?n.prototype.indexOf.call(se,F,V):n.prototype.lastIndexOf.call(se,F,V):A(se,[F],V,re,le);throw new TypeError("val must be string, number or Buffer")}function A(se,F,V,re,le){let ke=1,Ne=se.length,wt=F.length;if(re!==void 0&&(re=String(re).toLowerCase(),re==="ucs2"||re==="ucs-2"||re==="utf16le"||re==="utf-16le")){if(se.length<2||F.length<2)return-1;ke=2,Ne/=2,wt/=2,V/=2}function Yt(Et,bt){return ke===1?Et[bt]:Et.readUInt16BE(bt*ke)}let zt;if(le){let Et=-1;for(zt=V;ztNe&&(V=Ne-wt),zt=V;zt>=0;zt--){let Et=!0;for(let bt=0;btle&&(re=le)):re=le;const ke=F.length;re>ke/2&&(re=ke/2);let Ne;for(Ne=0;Ne>>0,isFinite(re)?(re=re>>>0,le===void 0&&(le="utf8")):(le=re,re=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const ke=this.length-V;if((re===void 0||re>ke)&&(re=ke),F.length>0&&(re<0||V<0)||V>this.length)throw new RangeError("Attempt to write outside buffer bounds");le||(le="utf8");let Ne=!1;for(;;)switch(le){case"hex":return R(this,F,V,re);case"utf8":case"utf-8":return D(this,F,V,re);case"ascii":case"latin1":case"binary":return U(this,F,V,re);case"base64":return K(this,F,V,re);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return j(this,F,V,re);default:if(Ne)throw new TypeError("Unknown encoding: "+le);le=(""+le).toLowerCase(),Ne=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function z(se,F,V){return F===0&&V===se.length?e.fromByteArray(se):e.fromByteArray(se.slice(F,V))}function J(se,F,V){V=Math.min(se.length,V);const re=[];let le=F;for(;le239?4:ke>223?3:ke>191?2:1;if(le+wt<=V){let Yt,zt,Et,bt;switch(wt){case 1:ke<128&&(Ne=ke);break;case 2:Yt=se[le+1],(Yt&192)===128&&(bt=(ke&31)<<6|Yt&63,bt>127&&(Ne=bt));break;case 3:Yt=se[le+1],zt=se[le+2],(Yt&192)===128&&(zt&192)===128&&(bt=(ke&15)<<12|(Yt&63)<<6|zt&63,bt>2047&&(bt<55296||bt>57343)&&(Ne=bt));break;case 4:Yt=se[le+1],zt=se[le+2],Et=se[le+3],(Yt&192)===128&&(zt&192)===128&&(Et&192)===128&&(bt=(ke&15)<<18|(Yt&63)<<12|(zt&63)<<6|Et&63,bt>65535&&bt<1114112&&(Ne=bt))}}Ne===null?(Ne=65533,wt=1):Ne>65535&&(Ne-=65536,re.push(Ne>>>10&1023|55296),Ne=56320|Ne&1023),re.push(Ne),le+=wt}return X(re)}const Y=4096;function X(se){const F=se.length;if(F<=Y)return String.fromCharCode.apply(String,se);let V="",re=0;for(;rere)&&(V=re);let le="";for(let ke=F;kere&&(F=re),V<0?(V+=re,V<0&&(V=0)):V>re&&(V=re),VV)throw new RangeError("Trying to access beyond buffer length")}u.prototype.readUintLE=u.prototype.readUIntLE=function(F,V,re){F=F>>>0,V=V>>>0,re||ne(F,V,this.length);let le=this[F],ke=1,Ne=0;for(;++Ne>>0,V=V>>>0,re||ne(F,V,this.length);let le=this[F+--V],ke=1;for(;V>0&&(ke*=256);)le+=this[F+--V]*ke;return le},u.prototype.readUint8=u.prototype.readUInt8=function(F,V){return F=F>>>0,V||ne(F,1,this.length),this[F]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(F,V){return F=F>>>0,V||ne(F,2,this.length),this[F]|this[F+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(F,V){return F=F>>>0,V||ne(F,2,this.length),this[F]<<8|this[F+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(F,V){return F=F>>>0,V||ne(F,4,this.length),(this[F]|this[F+1]<<8|this[F+2]<<16)+this[F+3]*16777216},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(F,V){return F=F>>>0,V||ne(F,4,this.length),this[F]*16777216+(this[F+1]<<16|this[F+2]<<8|this[F+3])},u.prototype.readBigUInt64LE=ht(function(F){F=F>>>0,Be(F,"offset");const V=this[F],re=this[F+7];(V===void 0||re===void 0)&&Me(F,this.length-8);const le=V+this[++F]*2**8+this[++F]*2**16+this[++F]*2**24,ke=this[++F]+this[++F]*2**8+this[++F]*2**16+re*2**24;return BigInt(le)+(BigInt(ke)<>>0,Be(F,"offset");const V=this[F],re=this[F+7];(V===void 0||re===void 0)&&Me(F,this.length-8);const le=V*2**24+this[++F]*2**16+this[++F]*2**8+this[++F],ke=this[++F]*2**24+this[++F]*2**16+this[++F]*2**8+re;return(BigInt(le)<>>0,V=V>>>0,re||ne(F,V,this.length);let le=this[F],ke=1,Ne=0;for(;++Ne=ke&&(le-=Math.pow(2,8*V)),le},u.prototype.readIntBE=function(F,V,re){F=F>>>0,V=V>>>0,re||ne(F,V,this.length);let le=V,ke=1,Ne=this[F+--le];for(;le>0&&(ke*=256);)Ne+=this[F+--le]*ke;return ke*=128,Ne>=ke&&(Ne-=Math.pow(2,8*V)),Ne},u.prototype.readInt8=function(F,V){return F=F>>>0,V||ne(F,1,this.length),this[F]&128?(255-this[F]+1)*-1:this[F]},u.prototype.readInt16LE=function(F,V){F=F>>>0,V||ne(F,2,this.length);const re=this[F]|this[F+1]<<8;return re&32768?re|4294901760:re},u.prototype.readInt16BE=function(F,V){F=F>>>0,V||ne(F,2,this.length);const re=this[F+1]|this[F]<<8;return re&32768?re|4294901760:re},u.prototype.readInt32LE=function(F,V){return F=F>>>0,V||ne(F,4,this.length),this[F]|this[F+1]<<8|this[F+2]<<16|this[F+3]<<24},u.prototype.readInt32BE=function(F,V){return F=F>>>0,V||ne(F,4,this.length),this[F]<<24|this[F+1]<<16|this[F+2]<<8|this[F+3]},u.prototype.readBigInt64LE=ht(function(F){F=F>>>0,Be(F,"offset");const V=this[F],re=this[F+7];(V===void 0||re===void 0)&&Me(F,this.length-8);const le=this[F+4]+this[F+5]*2**8+this[F+6]*2**16+(re<<24);return(BigInt(le)<>>0,Be(F,"offset");const V=this[F],re=this[F+7];(V===void 0||re===void 0)&&Me(F,this.length-8);const le=(V<<24)+this[++F]*2**16+this[++F]*2**8+this[++F];return(BigInt(le)<>>0,V||ne(F,4,this.length),t.read(this,F,!0,23,4)},u.prototype.readFloatBE=function(F,V){return F=F>>>0,V||ne(F,4,this.length),t.read(this,F,!1,23,4)},u.prototype.readDoubleLE=function(F,V){return F=F>>>0,V||ne(F,8,this.length),t.read(this,F,!0,52,8)},u.prototype.readDoubleBE=function(F,V){return F=F>>>0,V||ne(F,8,this.length),t.read(this,F,!1,52,8)};function oe(se,F,V,re,le,ke){if(!u.isBuffer(se))throw new TypeError('"buffer" argument must be a Buffer instance');if(F>le||Fse.length)throw new RangeError("Index out of range")}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(F,V,re,le){if(F=+F,V=V>>>0,re=re>>>0,!le){const wt=Math.pow(2,8*re)-1;oe(this,F,V,re,wt,0)}let ke=1,Ne=0;for(this[V]=F&255;++Ne>>0,re=re>>>0,!le){const wt=Math.pow(2,8*re)-1;oe(this,F,V,re,wt,0)}let ke=re-1,Ne=1;for(this[V+ke]=F&255;--ke>=0&&(Ne*=256);)this[V+ke]=F/Ne&255;return V+re},u.prototype.writeUint8=u.prototype.writeUInt8=function(F,V,re){return F=+F,V=V>>>0,re||oe(this,F,V,1,255,0),this[V]=F&255,V+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(F,V,re){return F=+F,V=V>>>0,re||oe(this,F,V,2,65535,0),this[V]=F&255,this[V+1]=F>>>8,V+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(F,V,re){return F=+F,V=V>>>0,re||oe(this,F,V,2,65535,0),this[V]=F>>>8,this[V+1]=F&255,V+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(F,V,re){return F=+F,V=V>>>0,re||oe(this,F,V,4,4294967295,0),this[V+3]=F>>>24,this[V+2]=F>>>16,this[V+1]=F>>>8,this[V]=F&255,V+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(F,V,re){return F=+F,V=V>>>0,re||oe(this,F,V,4,4294967295,0),this[V]=F>>>24,this[V+1]=F>>>16,this[V+2]=F>>>8,this[V+3]=F&255,V+4};function me(se,F,V,re,le){Re(F,re,le,se,V,7);let ke=Number(F&BigInt(4294967295));se[V++]=ke,ke=ke>>8,se[V++]=ke,ke=ke>>8,se[V++]=ke,ke=ke>>8,se[V++]=ke;let Ne=Number(F>>BigInt(32)&BigInt(4294967295));return se[V++]=Ne,Ne=Ne>>8,se[V++]=Ne,Ne=Ne>>8,se[V++]=Ne,Ne=Ne>>8,se[V++]=Ne,V}function fe(se,F,V,re,le){Re(F,re,le,se,V,7);let ke=Number(F&BigInt(4294967295));se[V+7]=ke,ke=ke>>8,se[V+6]=ke,ke=ke>>8,se[V+5]=ke,ke=ke>>8,se[V+4]=ke;let Ne=Number(F>>BigInt(32)&BigInt(4294967295));return se[V+3]=Ne,Ne=Ne>>8,se[V+2]=Ne,Ne=Ne>>8,se[V+1]=Ne,Ne=Ne>>8,se[V]=Ne,V+8}u.prototype.writeBigUInt64LE=ht(function(F,V=0){return me(this,F,V,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=ht(function(F,V=0){return fe(this,F,V,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(F,V,re,le){if(F=+F,V=V>>>0,!le){const Yt=Math.pow(2,8*re-1);oe(this,F,V,re,Yt-1,-Yt)}let ke=0,Ne=1,wt=0;for(this[V]=F&255;++ke>0)-wt&255;return V+re},u.prototype.writeIntBE=function(F,V,re,le){if(F=+F,V=V>>>0,!le){const Yt=Math.pow(2,8*re-1);oe(this,F,V,re,Yt-1,-Yt)}let ke=re-1,Ne=1,wt=0;for(this[V+ke]=F&255;--ke>=0&&(Ne*=256);)F<0&&wt===0&&this[V+ke+1]!==0&&(wt=1),this[V+ke]=(F/Ne>>0)-wt&255;return V+re},u.prototype.writeInt8=function(F,V,re){return F=+F,V=V>>>0,re||oe(this,F,V,1,127,-128),F<0&&(F=255+F+1),this[V]=F&255,V+1},u.prototype.writeInt16LE=function(F,V,re){return F=+F,V=V>>>0,re||oe(this,F,V,2,32767,-32768),this[V]=F&255,this[V+1]=F>>>8,V+2},u.prototype.writeInt16BE=function(F,V,re){return F=+F,V=V>>>0,re||oe(this,F,V,2,32767,-32768),this[V]=F>>>8,this[V+1]=F&255,V+2},u.prototype.writeInt32LE=function(F,V,re){return F=+F,V=V>>>0,re||oe(this,F,V,4,2147483647,-2147483648),this[V]=F&255,this[V+1]=F>>>8,this[V+2]=F>>>16,this[V+3]=F>>>24,V+4},u.prototype.writeInt32BE=function(F,V,re){return F=+F,V=V>>>0,re||oe(this,F,V,4,2147483647,-2147483648),F<0&&(F=4294967295+F+1),this[V]=F>>>24,this[V+1]=F>>>16,this[V+2]=F>>>8,this[V+3]=F&255,V+4},u.prototype.writeBigInt64LE=ht(function(F,V=0){return me(this,F,V,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=ht(function(F,V=0){return fe(this,F,V,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function he(se,F,V,re,le,ke){if(V+re>se.length)throw new RangeError("Index out of range");if(V<0)throw new RangeError("Index out of range")}function Se(se,F,V,re,le){return F=+F,V=V>>>0,le||he(se,F,V,4),t.write(se,F,V,re,23,4),V+4}u.prototype.writeFloatLE=function(F,V,re){return Se(this,F,V,!0,re)},u.prototype.writeFloatBE=function(F,V,re){return Se(this,F,V,!1,re)};function ye(se,F,V,re,le){return F=+F,V=V>>>0,le||he(se,F,V,8),t.write(se,F,V,re,52,8),V+8}u.prototype.writeDoubleLE=function(F,V,re){return ye(this,F,V,!0,re)},u.prototype.writeDoubleBE=function(F,V,re){return ye(this,F,V,!1,re)},u.prototype.copy=function(F,V,re,le){if(!u.isBuffer(F))throw new TypeError("argument should be a Buffer");if(re||(re=0),!le&&le!==0&&(le=this.length),V>=F.length&&(V=F.length),V||(V=0),le>0&&le=this.length)throw new RangeError("Index out of range");if(le<0)throw new RangeError("sourceEnd out of bounds");le>this.length&&(le=this.length),F.length-V>>0,re=re===void 0?this.length:re>>>0,F||(F=0);let ke;if(typeof F=="number")for(ke=V;ke2**32?le=Ge(String(V)):typeof V=="bigint"&&(le=String(V),(V>BigInt(2)**BigInt(32)||V<-(BigInt(2)**BigInt(32)))&&(le=Ge(le)),le+="n"),re+=` It must be ${F}. Received ${le}`,re},RangeError);function Ge(se){let F="",V=se.length;const re=se[0]==="-"?1:0;for(;V>=re+4;V-=3)F=`_${se.slice(V-3,V)}${F}`;return`${se.slice(0,V)}${F}`}function Ye(se,F,V){Be(F,"offset"),(se[F]===void 0||se[F+V]===void 0)&&Me(F,se.length-(V+1))}function Re(se,F,V,re,le,ke){if(se>V||se= 0${Ne} and < 2${Ne} ** ${(ke+1)*8}${Ne}`:wt=`>= -(2${Ne} ** ${(ke+1)*8-1}${Ne}) and < 2 ** ${(ke+1)*8-1}${Ne}`,new ge.ERR_OUT_OF_RANGE("value",wt,se)}Ye(re,le,ke)}function Be(se,F){if(typeof se!="number")throw new ge.ERR_INVALID_ARG_TYPE(F,"number",se)}function Me(se,F,V){throw Math.floor(se)!==se?(Be(se,V),new ge.ERR_OUT_OF_RANGE("offset","an integer",se)):F<0?new ge.ERR_BUFFER_OUT_OF_BOUNDS:new ge.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${F}`,se)}const Le=/[^+/0-9A-Za-z-_]/g;function rt(se){if(se=se.split("=")[0],se=se.trim().replace(Le,""),se.length<2)return"";for(;se.length%4!==0;)se=se+"=";return se}function ze(se,F){F=F||1/0;let V;const re=se.length;let le=null;const ke=[];for(let Ne=0;Ne55295&&V<57344){if(!le){if(V>56319){(F-=3)>-1&&ke.push(239,191,189);continue}else if(Ne+1===re){(F-=3)>-1&&ke.push(239,191,189);continue}le=V;continue}if(V<56320){(F-=3)>-1&&ke.push(239,191,189),le=V;continue}V=(le-55296<<10|V-56320)+65536}else le&&(F-=3)>-1&&ke.push(239,191,189);if(le=null,V<128){if((F-=1)<0)break;ke.push(V)}else if(V<2048){if((F-=2)<0)break;ke.push(V>>6|192,V&63|128)}else if(V<65536){if((F-=3)<0)break;ke.push(V>>12|224,V>>6&63|128,V&63|128)}else if(V<1114112){if((F-=4)<0)break;ke.push(V>>18|240,V>>12&63|128,V>>6&63|128,V&63|128)}else throw new Error("Invalid code point")}return ke}function Ue(se){const F=[];for(let V=0;V>8,le=V%256,ke.push(le),ke.push(re);return ke}function st(se){return e.toByteArray(rt(se))}function ut(se,F,V,re){let le;for(le=0;le=F.length||le>=se.length);++le)F[le+V]=se[le];return le}function yt(se,F){return se instanceof F||se!=null&&se.constructor!=null&&se.constructor.name!=null&&se.constructor.name===F.name}function Bt(se){return se!==se}const lt=function(){const se="0123456789abcdef",F=new Array(256);for(let V=0;V<16;++V){const re=V*16;for(let le=0;le<16;++le)F[re+le]=se[V]+se[le]}return F}();function ht(se){return typeof BigInt>"u"?ft:se}function ft(){throw new Error("BigInt not supported")}})(pn);const xH=pn.Buffer,hne=pn.Blob,lne=pn.BlobOptions,fne=pn.Buffer,pne=pn.File,mne=pn.FileOptions,gne=pn.INSPECT_MAX_BYTES,yne=pn.SlowBuffer,wne=pn.TranscodeEncoding,bne=pn.atob,kne=pn.btoa,Sne=pn.constants,vne=pn.isAscii,Tne=pn.isUtf8,One=pn.kMaxLength,xne=pn.kStringMaxLength,Pne=pn.resolveObjectURL,Ine=pn.transcode,pWe=Object.freeze(Object.defineProperty({__proto__:null,Blob:hne,BlobOptions:lne,Buffer:fne,File:pne,FileOptions:mne,INSPECT_MAX_BYTES:gne,SlowBuffer:yne,TranscodeEncoding:wne,atob:bne,btoa:kne,constants:Sne,default:xH,isAscii:vne,isUtf8:Tne,kMaxLength:One,kStringMaxLength:xne,resolveObjectURL:Pne,transcode:Ine},Symbol.toStringTag,{value:"Module"})),OT=B.createContext(void 0),Cne=B.createContext(void 0);function Wl(d){const e=B.useContext(d.from?Cne:OT);return Hr({select:s=>{const i=s.matches.find(n=>d.from?d.from===n.routeId:n.id===e);if(ca(!((d.shouldThrow??!0)&&!i),`Could not find ${d.from?`an active match from "${d.from}"`:"a nearest match!"}`),i!==void 0)return d.select?d.select(i):i},structuralSharing:d.structuralSharing})}function Mne(d){return Wl({from:d.from,strict:d.strict,structuralSharing:d.structuralSharing,select:e=>d.select?d.select(e.loaderData):e.loaderData})}function _ne(d){const{select:e,...t}=d;return Wl({...t,select:s=>e?e(s.loaderDeps):s.loaderDeps})}function Ane(d){return Wl({from:d.from,strict:d.strict,structuralSharing:d.structuralSharing,select:e=>d.select?d.select(e.params):e.params})}function Lne(d){return Wl({from:d.from,strict:d.strict,structuralSharing:d.structuralSharing,select:e=>d.select?d.select(e.search):e.search})}function Zc(d){const{navigate:e}=Nh();return B.useCallback(t=>e({...t}),[e])}let PH=class{constructor(e){this.init=t=>{var s,i;this.originalIndex=t.originalIndex;const n=this.options,r=!(n!=null&&n.path)&&!(n!=null&&n.id);this.parentRoute=(i=(s=this.options).getParentRoute)==null?void 0:i.call(s),r?this._path=na:ca(this.parentRoute);let a=r?na:n.path;a&&a!=="/"&&(a=K_(a));const o=(n==null?void 0:n.id)||a;let c=r?na:Nc([this.parentRoute.id===na?"":this.parentRoute.id,o]);a===na&&(a="/"),c!==na&&(c=Nc(["/",c]));const u=c===na?"/":Nc([this.parentRoute.fullPath,a]);this._path=a,this._id=c,this._fullPath=u,this._to=u,this._ssr=(n==null?void 0:n.ssr)??t.defaultSsr??!0},this.updateLoader=t=>(Object.assign(this.options,t),this),this.update=t=>(Object.assign(this.options,t),this),this.lazy=t=>(this.lazyFn=t,this),this.useMatch=t=>Wl({select:t==null?void 0:t.select,from:this.id,structuralSharing:t==null?void 0:t.structuralSharing}),this.useRouteContext=t=>Wl({...t,from:this.id,select:s=>t!=null&&t.select?t.select(s.context):s.context}),this.useSearch=t=>Lne({select:t==null?void 0:t.select,structuralSharing:t==null?void 0:t.structuralSharing,from:this.id}),this.useParams=t=>Ane({select:t==null?void 0:t.select,structuralSharing:t==null?void 0:t.structuralSharing,from:this.id}),this.useLoaderDeps=t=>_ne({...t,from:this.id}),this.useLoaderData=t=>Mne({...t,from:this.id}),this.useNavigate=()=>Zc({from:this.id}),this.options=e||{},this.isRoot=!(e!=null&&e.getParentRoute),ca(!(e!=null&&e.id&&(e!=null&&e.path))),this.$$typeof=Symbol.for("react.memo")}get to(){return this._to}get id(){return this._id}get path(){return this._path}get fullPath(){return this._fullPath}get ssr(){return this._ssr}addChildren(e){return this._addFileChildren(e)}_addFileChildren(e){return Array.isArray(e)&&(this.children=e),typeof e=="object"&&e!==null&&(this.children=Object.values(e)),this}};function Bne(d){return new PH(d)}class Nne extends PH{constructor(e){super(e)}addChildren(e){return super.addChildren(e),this}_addFileChildren(e){return super._addFileChildren(e),this}_addFileTypes(){return this}}function Ene(d){return new Nne(d)}function vr(d){return new Rne(d,{silent:!0}).createRoute}class Rne{constructor(e,t){this.path=e,this.createRoute=s=>{this.silent;const i=Bne(s);return i.isRoot=!1,i},this.silent=t==null?void 0:t.silent}}function ZS(d){return P.jsx(P.Fragment,{children:d.children})}function IH(d,e,t){return e.options.notFoundComponent?P.jsx(e.options.notFoundComponent,{data:t}):d.options.defaultNotFoundComponent?P.jsx(d.options.defaultNotFoundComponent,{data:t}):P.jsx(Xie,{})}const CH=B.memo(function({matchId:e}){var t,s;const i=Nh(),n=Hr({select:g=>{var y;return(y=g.matches.find(w=>w.id===e))==null?void 0:y.routeId}});ca(n);const r=i.routesById[n],a=r.options.pendingComponent??i.options.defaultPendingComponent,o=a?P.jsx(a,{}):null,c=r.options.errorComponent??i.options.defaultErrorComponent,u=r.options.onCatch??i.options.defaultOnCatch,h=r.isRoot?r.options.notFoundComponent??((t=i.options.notFoundRoute)==null?void 0:t.options.component):r.options.notFoundComponent,l=(!r.isRoot||r.options.wrapInSuspense)&&(r.options.wrapInSuspense??a??((s=r.options.errorComponent)==null?void 0:s.preload))?B.Suspense:ZS,f=c?X_:ZS,p=h?Kie:ZS,m=Hr({select:g=>g.loadedAt});return P.jsx(OT.Provider,{value:e,children:P.jsx(l,{fallback:o,children:P.jsx(f,{getResetKey:()=>m,errorComponent:c||vT,onCatch:(g,y)=>{if(Co(g))throw g;u==null||u(g,y)},children:P.jsx(p,{fallback:g=>{if(!h||g.routeId&&g.routeId!==n||!g.routeId&&!r.isRoot)throw g;return B.createElement(h,g)},children:P.jsx(Dne,{matchId:e})})})})})}),Dne=B.memo(function({matchId:e}){var t,s,i,n,r;const a=Nh(),{match:o,matchIndex:c,routeId:u}=Hr({select:p=>{const m=p.matches.findIndex(w=>w.id===e),g=p.matches[m];return{routeId:g.routeId,matchIndex:m,match:YS(g,["id","status","error"])}},structuralSharing:!0}),h=a.routesById[u],l=B.useMemo(()=>{const p=h.options.component??a.options.defaultComponent;return p?P.jsx(p,{}):P.jsx(Y_,{})},[h.options.component,a.options.defaultComponent]),f=(h.options.errorComponent??a.options.defaultErrorComponent)||vT;if(o.status==="notFound"){let p;return DD(o.error)?p=(((t=a.options.errorSerializer)==null?void 0:t.deserialize)??qD)(o.error.data):p=o.error,ca(Co(p)),IH(a,h,p)}if(o.status==="redirected")throw ca(hl(o.error)),(s=a.getMatch(o.id))==null?void 0:s.loadPromise;if(o.status==="error"){if(a.isServer)return P.jsx(f,{error:o.error,info:{componentStack:""}});throw DD(o.error)?(((i=a.options.errorSerializer)==null?void 0:i.deserialize)??qD)(o.error.data):o.error}if(o.status==="pending"){const p=h.options.pendingMinMs??a.options.defaultPendingMinMs;if(p&&!((n=a.getMatch(o.id))!=null&&n.minPendingPromise)&&!a.isServer){const m=mp();Promise.resolve().then(()=>{a.updateMatch(o.id,g=>({...g,minPendingPromise:m}))}),setTimeout(()=>{m.resolve(),a.updateMatch(o.id,g=>({...g,minPendingPromise:void 0}))},p)}throw(r=a.getMatch(o.id))==null?void 0:r.loadPromise}return P.jsxs(P.Fragment,{children:[l,a.AfterEachMatch?P.jsx(a.AfterEachMatch,{match:o,matchIndex:c}):null]})}),Y_=B.memo(function(){const e=Nh(),t=B.useContext(OT),s=Hr({select:c=>{var u;return(u=c.matches.find(h=>h.id===t))==null?void 0:u.routeId}}),i=e.routesById[s],n=Hr({select:c=>{const h=c.matches.find(l=>l.id===t);return ca(h),h.globalNotFound}}),r=Hr({select:c=>{var u;const h=c.matches,l=h.findIndex(f=>f.id===t);return(u=h[l+1])==null?void 0:u.id}});if(n)return IH(e,i,void 0);if(!r)return null;const a=P.jsx(CH,{matchId:r}),o=e.options.defaultPendingComponent?P.jsx(e.options.defaultPendingComponent,{}):null;return t===na?P.jsx(B.Suspense,{fallback:o,children:a}):a}),qne="Error preloading route! ☝️";function Vne(d,e){const t=Nh(),[s,i]=B.useState(!1),n=B.useRef(!1),r=Hie(e),{activeProps:a=()=>({className:"active"}),inactiveProps:o=()=>({}),activeOptions:c,to:u,preload:h,preloadDelay:l,hashScrollIntoView:f,replace:p,startTransition:m,resetScroll:g,viewTransition:y,children:w,target:b,disabled:S,style:v,className:C,onClick:M,onFocus:_,onMouseEnter:N,onMouseLeave:A,onTouchStart:R,ignoreBlocker:D,...U}=d,{params:K,search:j,hash:z,state:J,mask:Y,reloadDocument:X,...Z}=U,te=B.useMemo(()=>{try{return new URL(`${u}`),"external"}catch{}return"internal"},[u]),Q=Hr({select:ze=>ze.location.search,structuralSharing:!0});d={from:Wl({strict:!1,select:ze=>ze.pathname}),...d};const ne=B.useMemo(()=>t.buildLocation(d),[t,d,Q]),oe=B.useMemo(()=>d.reloadDocument?!1:h??t.options.defaultPreload,[t.options.defaultPreload,h,d.reloadDocument]),me=l??t.options.defaultPreloadDelay??0,fe=Hr({select:ze=>{if(c!=null&&c.exact){if(!Uie(ze.location.pathname,ne.pathname,t.basepath))return!1}else{const Ue=J1(ze.location.pathname,t.basepath).split("/");if(!J1(ne.pathname,t.basepath).split("/").every((ut,yt)=>ut===Ue[yt]))return!1}return((c==null?void 0:c.includeSearch)??!0)&&!Zp(ze.location.search,ne.search,{partial:!(c!=null&&c.exact),ignoreUndefined:!(c!=null&&c.explicitUndefined)})?!1:c!=null&&c.includeHash?ze.location.hash===ne.hash:!0}}),he=B.useCallback(()=>{t.preloadRoute(d).catch(ze=>{console.warn(ze),console.warn(qne)})},[d,t]),Se=B.useCallback(ze=>{ze!=null&&ze.isIntersecting&&he()},[he]);if(Fie(r,Se,{rootMargin:"100px"},{disabled:!!S||oe!=="viewport"}),Cy(()=>{n.current||!S&&oe==="render"&&(he(),n.current=!0)},[S,he,oe]),te==="external")return{...Z,ref:r,type:te,href:u,...w&&{children:w},...b&&{target:b},...S&&{disabled:S},...v&&{style:v},...C&&{className:C},...M&&{onClick:M},..._&&{onFocus:_},...N&&{onMouseEnter:N},...A&&{onMouseLeave:A},...R&&{onTouchStart:R}};const ye=ze=>{if(!S&&!Hne(ze)&&!ze.defaultPrevented&&(!b||b==="_self")&&ze.button===0){ze.preventDefault(),bT.flushSync(()=>{i(!0)});const Ue=t.subscribe("onResolved",()=>{Ue(),i(!1)});return t.navigate({...d,replace:p,resetScroll:g,hashScrollIntoView:f,startTransition:m,viewTransition:y,ignoreBlocker:D})}},ge=ze=>{S||oe&&he()},Te=ge,Ge=ze=>{if(S)return;const Ue=ze.target||{};if(oe){if(Ue.preloadTimeout)return;Ue.preloadTimeout=setTimeout(()=>{Ue.preloadTimeout=null,he()},me)}},Ye=ze=>{if(S)return;const Ue=ze.target||{};Ue.preloadTimeout&&(clearTimeout(Ue.preloadTimeout),Ue.preloadTimeout=null)},Re=ze=>Ue=>{var Je;(Je=Ue.persist)==null||Je.call(Ue),ze.filter(Boolean).forEach(st=>{Ue.defaultPrevented||st(Ue)})},Be=fe?Bp(a,{})??{}:{},Me=fe?{}:Bp(o,{}),Le=[C,Be.className,Me.className].filter(Boolean).join(" "),rt={...v,...Be.style,...Me.style};return{...Z,...Be,...Me,href:S?void 0:ne.maskedLocation?t.history.createHref(ne.maskedLocation.href):t.history.createHref(ne.href),ref:r,onClick:Re([M,ye]),onFocus:Re([_,ge]),onMouseEnter:Re([N,Ge]),onMouseLeave:Re([A,Ye]),onTouchStart:Re([R,Te]),disabled:!!S,target:b,...Object.keys(rt).length&&{style:rt},...Le&&{className:Le},...S&&{role:"link","aria-disabled":!0},...fe&&{"data-status":"active","aria-current":"page"},...s&&{"data-transitioning":"transitioning"}}}const Fne=B.forwardRef((d,e)=>{const{_asChild:t,...s}=d,{type:i,ref:n,...r}=Vne(s,e),a=typeof s.children=="function"?s.children({isActive:r["data-status"]==="active"}):s.children;return typeof t>"u"&&delete r.disabled,B.createElement(t||"a",{...r,ref:n},a)});function Hne(d){return!!(d.metaKey||d.altKey||d.ctrlKey||d.shiftKey)}function Gne(){const d=Nh(),e=B.useRef({router:d,mounted:!1}),t=Hr({select:({isLoading:h})=>h}),[s,i]=B.useState(!1),n=Hr({select:h=>h.matches.some(l=>l.status==="pending"),structuralSharing:!0}),r=YP(t),a=t||s||n,o=YP(a),c=t||n,u=YP(c);return d.isServer||(d.startReactTransition=h=>{i(!0),B.startTransition(()=>{h(),i(!1)})}),B.useEffect(()=>{const h=d.history.subscribe(d.load),l=d.buildLocation({to:d.latestLocation.pathname,search:!0,params:!0,hash:!0,state:!0,_includeValidateSearch:!0});return Tl(d.latestLocation.href)!==Tl(l.href)&&d.commitLocation({...l,replace:!0}),()=>{h()}},[d,d.history]),Cy(()=>{var h;if(typeof window<"u"&&((h=window.__TSR__)!=null&&h.dehydrated)||e.current.router===d&&e.current.mounted)return;e.current={router:d,mounted:!0},(async()=>{try{await d.load()}catch(f){console.error(f)}})()},[d]),Cy(()=>{if(r&&!t){const h=d.state.location,l=d.state.resolvedLocation,f=l.pathname!==h.pathname,p=l.href!==h.href;d.emit({type:"onLoad",fromLocation:l,toLocation:h,pathChanged:f,hrefChanged:p})}},[r,d,t]),Cy(()=>{if(u&&!c){const h=d.state.location,l=d.state.resolvedLocation,f=l.pathname!==h.pathname,p=l.href!==h.href;d.emit({type:"onBeforeRouteMount",fromLocation:l,toLocation:h,pathChanged:f,hrefChanged:p})}},[c,u,d]),Cy(()=>{if(o&&!a){const h=d.state.location,l=d.state.resolvedLocation,f=l.pathname!==h.pathname,p=l.href!==h.href;if(d.emit({type:"onResolved",fromLocation:l,toLocation:h,pathChanged:f,hrefChanged:p}),d.__store.setState(m=>({...m,status:"idle",resolvedLocation:m.location})),typeof document<"u"&&document.querySelector){const m=d.state.location.state.__hashScrollIntoViewOptions??!0;if(m&&d.state.location.hash!==""){const g=document.getElementById(d.state.location.hash);g&&g.scrollIntoView(m)}}}},[a,o,d]),null}function Une(){const d=Nh(),e=d.options.defaultPendingComponent?P.jsx(d.options.defaultPendingComponent,{}):null,t=d.isServer||typeof document<"u"&&window.__TSR__?ZS:B.Suspense,s=P.jsxs(t,{fallback:e,children:[P.jsx(Gne,{}),P.jsx(Wne,{})]});return d.options.InnerWrap?P.jsx(d.options.InnerWrap,{children:s}):s}function Wne(){const d=Hr({select:t=>{var s;return(s=t.matches[0])==null?void 0:s.id}}),e=Hr({select:t=>t.loadedAt});return P.jsx(OT.Provider,{value:d,children:P.jsx(X_,{getResetKey:()=>e,errorComponent:vT,onCatch:t=>{t.message||t.toString()},children:d?P.jsx(CH,{matchId:d}):null})})}function jne({router:d,children:e,...t}){d.update({...d.options,...t,context:{...d.options.context,...t.context}});const s=yH(),i=P.jsx(s.Provider,{value:d,children:e});return d.options.Wrap?P.jsx(d.options.Wrap,{children:i}):i}function zne({router:d,...e}){return P.jsx(jne,{router:d,...e,children:P.jsx(Une,{})})}const tg="$$joy";function R0(d){let e="https://mui.com/production-error/?code="+d;for(let t=1;t0?Vn(sg,--zr):0,Im--,en===10&&(Im=1,PT--),en}function wa(){return en=zr2||q0(en)>3?"":" "}function ore(d,e){for(;--e&&wa()&&!(en<48||en>102||en>57&&en<65||en>70&&en<97););return Hw(d,JS()+(e<6&&Ed()==32&&wa()==32))}function OM(d){for(;wa();)switch(en){case d:return zr;case 34:case 39:d!==34&&d!==39&&OM(en);break;case 40:d===41&&OM(d);break;case 92:wa();break}return zr}function dre(d,e){for(;wa()&&d+en!==57;)if(d+en===84&&Ed()===47)break;return"/*"+Hw(e,zr-1)+"*"+xT(d===47?d:wa())}function cre(d){for(;!q0(Ed());)wa();return Hw(d,zr)}function ure(d){return NH(t1("",null,null,null,[""],d=BH(d),0,[0],d))}function t1(d,e,t,s,i,n,r,a,o){for(var c=0,u=0,h=r,l=0,f=0,p=0,m=1,g=1,y=1,w=0,b="",S=i,v=n,C=s,M=b;g;)switch(p=w,w=wa()){case 40:if(p!=108&&Vn(M,h-1)==58){TM(M+=Ns(e1(w),"&","&\f"),"&\f")!=-1&&(y=-1);break}case 34:case 39:case 91:M+=e1(w);break;case 9:case 10:case 13:case 32:M+=are(p);break;case 92:M+=ore(JS()-1,7);continue;case 47:switch(Ed()){case 42:case 47:rS(hre(dre(wa(),JS()),e,t),o);break;default:M+="/"}break;case 123*m:a[c++]=vd(M)*y;case 125*m:case 59:case 0:switch(w){case 0:case 125:g=0;case 59+u:y==-1&&(M=Ns(M,/\f/g,"")),f>0&&vd(M)-h&&rS(f>32?FD(M+";",s,t,h-1):FD(Ns(M," ","")+";",s,t,h-2),o);break;case 59:M+=";";default:if(rS(C=VD(M,e,t,c,u,i,a,b,S=[],v=[],h),n),w===123)if(u===0)t1(M,e,C,C,S,n,h,a,v);else switch(l===99&&Vn(M,3)===110?100:l){case 100:case 108:case 109:case 115:t1(d,C,C,s&&rS(VD(d,C,C,0,0,i,a,b,i,S=[],h),v),i,v,h,a,s?S:v);break;default:t1(M,C,C,C,[""],v,0,a,v)}}c=u=f=0,m=y=1,b=M="",h=r;break;case 58:h=1+vd(M),f=p;default:if(m<1){if(w==123)--m;else if(w==125&&m++==0&&rre()==125)continue}switch(M+=xT(w),w*m){case 38:y=u>0?1:(M+="\f",-1);break;case 44:a[c++]=(vd(M)-1)*y,y=1;break;case 64:Ed()===45&&(M+=e1(wa())),l=Ed(),u=h=vd(b=M+=cre(JS())),w++;break;case 45:p===45&&vd(M)==2&&(m=0)}}return n}function VD(d,e,t,s,i,n,r,a,o,c,u){for(var h=i-1,l=i===0?n:[""],f=eA(l),p=0,m=0,g=0;p0?l[y]+" "+w:Ns(w,/&\f/g,l[y])))&&(o[g++]=b);return IT(d,e,t,i===0?Z_:a,o,c,u)}function hre(d,e,t){return IT(d,e,t,MH,xT(nre()),D0(d,2,-2),0)}function FD(d,e,t,s){return IT(d,e,t,J_,D0(d,0,s),D0(d,s+1,-1),s)}function Jp(d,e){for(var t="",s=eA(d),i=0;i6)switch(Vn(d,e+1)){case 109:if(Vn(d,e+4)!==45)break;case 102:return Ns(d,/(.+:)(.+)-([^]+)/,"$1"+Bs+"$2-$3$1"+tv+(Vn(d,e+3)==108?"$3":"$2-$3"))+d;case 115:return~TM(d,"stretch")?RH(Ns(d,"stretch","fill-available"),e)+d:d}break;case 4949:if(Vn(d,e+1)!==115)break;case 6444:switch(Vn(d,vd(d)-3-(~TM(d,"!important")&&10))){case 107:return Ns(d,":",":"+Bs)+d;case 101:return Ns(d,/(.+:)([^;!]+)(;|!.+)?/,"$1"+Bs+(Vn(d,14)===45?"inline-":"")+"box$3$1"+Bs+"$2$3$1"+Jn+"$2box$3")+d}break;case 5936:switch(Vn(d,e+11)){case 114:return Bs+d+Jn+Ns(d,/[svh]\w+-[tblr]{2}/,"tb")+d;case 108:return Bs+d+Jn+Ns(d,/[svh]\w+-[tblr]{2}/,"tb-rl")+d;case 45:return Bs+d+Jn+Ns(d,/[svh]\w+-[tblr]{2}/,"lr")+d}return Bs+d+Jn+d+d}return d}var kre=function(e,t,s,i){if(e.length>-1&&!e.return)switch(e.type){case J_:e.return=RH(e.value,e.length);break;case _H:return Jp([ry(e,{value:Ns(e.value,"@","@"+Bs)})],i);case Z_:if(e.length)return ire(e.props,function(n){switch(sre(n,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return Jp([ry(e,{props:[Ns(n,/:(read-\w+)/,":"+tv+"$1")]})],i);case"::placeholder":return Jp([ry(e,{props:[Ns(n,/:(plac\w+)/,":"+Bs+"input-$1")]}),ry(e,{props:[Ns(n,/:(plac\w+)/,":"+tv+"$1")]}),ry(e,{props:[Ns(n,/:(plac\w+)/,Jn+"input-$1")]})],i)}return""})}},Sre=[kre],DH=function(e){var t=e.key;if(t==="css"){var s=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(s,function(m){var g=m.getAttribute("data-emotion");g.indexOf(" ")!==-1&&(document.head.appendChild(m),m.setAttribute("data-s",""))})}var i=e.stylisPlugins||Sre,n={},r,a=[];r=e.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+t+' "]'),function(m){for(var g=m.getAttribute("data-emotion").split(" "),y=1;y{let t=d;for(;t;)t.callback(),t=t.next})},get(){const t=[];let s=d;for(;s;)t.push(s),s=s.next;return t},subscribe(t){let s=!0;const i=e={callback:t,next:null,prev:e};return i.prev?i.prev.next=i:d=i,function(){!s||d===null||(s=!1,i.next?i.next.prev=i.prev:e=i.prev,i.prev?i.prev.next=i.next:d=i.next)}}}}var dq={notify(){},get:()=>[]};function Nde(d,e){let t,s=dq,i=0,n=!1;function r(m){u();const g=s.subscribe(m);let y=!1;return()=>{y||(y=!0,g(),h())}}function a(){s.notify()}function o(){p.onStateChange&&p.onStateChange()}function c(){return n}function u(){i++,t||(t=d.subscribe(o),s=Bde())}function h(){i--,t&&i===0&&(t(),t=void 0,s.clear(),s=dq)}function l(){n||(n=!0,u())}function f(){n&&(n=!1,h())}const p={addNestedSub:r,notifyNestedSubs:a,handleChangeWrapper:o,isSubscribed:c,trySubscribe:l,tryUnsubscribe:f,getListeners:()=>s};return p}var Ede=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Rde=Ede(),Dde=()=>typeof navigator<"u"&&navigator.product==="ReactNative",qde=Dde(),Vde=()=>Rde||qde?B.useLayoutEffect:B.useEffect,Fde=Vde(),aI=Symbol.for("react-redux-context"),oI=typeof globalThis<"u"?globalThis:{};function Hde(){if(!B.createContext)return{};const d=oI[aI]??(oI[aI]=new Map);let e=d.get(B.createContext);return e||(e=B.createContext(null),d.set(B.createContext,e)),e}var wh=Hde();function Gde(d){const{children:e,context:t,serverState:s,store:i}=d,n=B.useMemo(()=>{const o=Nde(i);return{store:i,subscription:o,getServerState:s?()=>s:void 0}},[i,s]),r=B.useMemo(()=>i.getState(),[i]);Fde(()=>{const{subscription:o}=n;return o.onStateChange=o.notifyNestedSubs,o.trySubscribe(),r!==i.getState()&&o.notifyNestedSubs(),()=>{o.tryUnsubscribe(),o.onStateChange=void 0}},[n,r]);const a=t||wh;return B.createElement(a.Provider,{value:n},e)}var y8=Gde;function TA(d=wh){return function(){return B.useContext(d)}}var w8=TA();function OA(d=wh){const e=d===wh?w8:TA(d),t=()=>{const{store:s}=e();return s};return Object.assign(t,{withTypes:()=>t}),t}var Ude=OA();function b8(d=wh){const e=d===wh?Ude:OA(d),t=()=>e().dispatch;return Object.assign(t,{withTypes:()=>t}),t}var Wde=b8(),jde=(d,e)=>d===e;function k8(d=wh){const e=d===wh?w8:TA(d),t=(s,i={})=>{const{equalityFn:n=jde}=typeof i=="function"?{equalityFn:i}:i,r=e(),{store:a,subscription:o,getServerState:c}=r;B.useRef(!0);const u=B.useCallback({[s.name](l){return s(l)}}[s.name],[s]),h=Ade.useSyncExternalStoreWithSelector(o.addNestedSub,a.getState,c||a.getState,u,n);return B.useDebugValue(h),h};return Object.assign(t,{withTypes:()=>t}),t}var zde=k8();function $de(d){return d&&d.__esModule&&Object.prototype.hasOwnProperty.call(d,"default")?d.default:d}var S8={exports:{}},Qi=S8.exports={},bd,kd;function IM(){throw new Error("setTimeout has not been defined")}function CM(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?bd=setTimeout:bd=IM}catch{bd=IM}try{typeof clearTimeout=="function"?kd=clearTimeout:kd=CM}catch{kd=CM}})();function v8(d){if(bd===setTimeout)return setTimeout(d,0);if((bd===IM||!bd)&&setTimeout)return bd=setTimeout,setTimeout(d,0);try{return bd(d,0)}catch{try{return bd.call(null,d,0)}catch{return bd.call(this,d,0)}}}function Kde(d){if(kd===clearTimeout)return clearTimeout(d);if((kd===CM||!kd)&&clearTimeout)return kd=clearTimeout,clearTimeout(d);try{return kd(d)}catch{try{return kd.call(null,d)}catch{return kd.call(this,d)}}}var Mc=[],tm=!1,Ol,n1=-1;function Xde(){!tm||!Ol||(tm=!1,Ol.length?Mc=Ol.concat(Mc):n1=-1,Mc.length&&T8())}function T8(){if(!tm){var d=v8(Xde);tm=!0;for(var e=Mc.length;e;){for(Ol=Mc,Mc=[];++n11)for(var t=1;tMath.random().toString(36).substring(7).split("").join("."),Zde={INIT:`@@redux/INIT${dI()}`,REPLACE:`@@redux/REPLACE${dI()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${dI()}`},rv=Zde;function xA(d){if(typeof d!="object"||d===null)return!1;let e=d;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(d)===e||Object.getPrototypeOf(d)===null}function x8(d,e,t){if(typeof d!="function")throw new Error(Dn(2));if(typeof e=="function"&&typeof t=="function"||typeof t=="function"&&typeof arguments[3]=="function")throw new Error(Dn(0));if(typeof e=="function"&&typeof t>"u"&&(t=e,e=void 0),typeof t<"u"){if(typeof t!="function")throw new Error(Dn(1));return t(x8)(d,e)}let s=d,i=e,n=new Map,r=n,a=0,o=!1;function c(){r===n&&(r=new Map,n.forEach((g,y)=>{r.set(y,g)}))}function u(){if(o)throw new Error(Dn(3));return i}function h(g){if(typeof g!="function")throw new Error(Dn(4));if(o)throw new Error(Dn(5));let y=!0;c();const w=a++;return r.set(w,g),function(){if(y){if(o)throw new Error(Dn(6));y=!1,c(),r.delete(w),n=null}}}function l(g){if(!xA(g))throw new Error(Dn(7));if(typeof g.type>"u")throw new Error(Dn(8));if(typeof g.type!="string")throw new Error(Dn(17));if(o)throw new Error(Dn(9));try{o=!0,i=s(i,g)}finally{o=!1}return(n=r).forEach(w=>{w()}),g}function f(g){if(typeof g!="function")throw new Error(Dn(10));s=g,l({type:rv.REPLACE})}function p(){const g=h;return{subscribe(y){if(typeof y!="object"||y===null)throw new Error(Dn(11));function w(){const S=y;S.next&&S.next(u())}return w(),{unsubscribe:g(w)}},[cq](){return this}}}return l({type:rv.INIT}),{dispatch:l,subscribe:h,getState:u,replaceReducer:f,[cq]:p}}function Jde(d){Object.keys(d).forEach(e=>{const t=d[e];if(typeof t(void 0,{type:rv.INIT})>"u")throw new Error(Dn(12));if(typeof t(void 0,{type:rv.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(Dn(13))})}function ece(d){const e=Object.keys(d),t={};for(let n=0;n"u")throw a&&a.type,new Error(Dn(14));c[h]=p,o=o||p!==f}return o=o||s.length!==Object.keys(r).length,o?c:r}}function av(...d){return d.length===0?e=>e:d.length===1?d[0]:d.reduce((e,t)=>(...s)=>e(t(...s)))}function tce(...d){return e=>(t,s)=>{const i=e(t,s);let n=()=>{throw new Error(Dn(15))};const r={getState:i.getState,dispatch:(o,...c)=>n(o,...c)},a=d.map(o=>o(r));return n=av(...a)(i.dispatch),{...i,dispatch:n}}}function sce(d){return xA(d)&&"type"in d&&typeof d.type=="string"}var P8=Symbol.for("immer-nothing"),uq=Symbol.for("immer-draftable"),Oa=Symbol.for("immer-state");function Ao(d,...e){throw new Error(`[Immer] minified error nr: ${d}. Full error at: https://bit.ly/3cXEKWf`)}var Cm=Object.getPrototypeOf;function jl(d){return!!d&&!!d[Oa]}function zc(d){var e;return d?I8(d)||Array.isArray(d)||!!d[uq]||!!((e=d.constructor)!=null&&e[uq])||zT(d)||$T(d):!1}var ice=Object.prototype.constructor.toString();function I8(d){if(!d||typeof d!="object")return!1;const e=Cm(d);if(e===null)return!0;const t=Object.hasOwnProperty.call(e,"constructor")&&e.constructor;return t===Object?!0:typeof t=="function"&&Function.toString.call(t)===ice}function ov(d,e){jT(d)===0?Reflect.ownKeys(d).forEach(t=>{e(t,d[t],d)}):d.forEach((t,s)=>e(s,t,d))}function jT(d){const e=d[Oa];return e?e.type_:Array.isArray(d)?1:zT(d)?2:$T(d)?3:0}function MM(d,e){return jT(d)===2?d.has(e):Object.prototype.hasOwnProperty.call(d,e)}function C8(d,e,t){const s=jT(d);s===2?d.set(e,t):s===3?d.add(t):d[e]=t}function nce(d,e){return d===e?d!==0||1/d===1/e:d!==d&&e!==e}function zT(d){return d instanceof Map}function $T(d){return d instanceof Set}function ll(d){return d.copy_||d.base_}function _M(d,e){if(zT(d))return new Map(d);if($T(d))return new Set(d);if(Array.isArray(d))return Array.prototype.slice.call(d);const t=I8(d);if(e===!0||e==="class_only"&&!t){const s=Object.getOwnPropertyDescriptors(d);delete s[Oa];let i=Reflect.ownKeys(s);for(let n=0;n1&&(d.set=d.add=d.clear=d.delete=rce),Object.freeze(d),e&&Object.entries(d).forEach(([t,s])=>PA(s,!0))),d}function rce(){Ao(2)}function KT(d){return Object.isFrozen(d)}var ace={};function zl(d){const e=ace[d];return e||Ao(0,d),e}var G0;function M8(){return G0}function oce(d,e){return{drafts_:[],parent_:d,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function hq(d,e){e&&(zl("Patches"),d.patches_=[],d.inversePatches_=[],d.patchListener_=e)}function AM(d){LM(d),d.drafts_.forEach(dce),d.drafts_=null}function LM(d){d===G0&&(G0=d.parent_)}function lq(d){return G0=oce(G0,d)}function dce(d){const e=d[Oa];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function fq(d,e){e.unfinalizedDrafts_=e.drafts_.length;const t=e.drafts_[0];return d!==void 0&&d!==t?(t[Oa].modified_&&(AM(e),Ao(4)),zc(d)&&(d=dv(e,d),e.parent_||cv(e,d)),e.patches_&&zl("Patches").generateReplacementPatches_(t[Oa].base_,d,e.patches_,e.inversePatches_)):d=dv(e,t,[]),AM(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),d!==P8?d:void 0}function dv(d,e,t){if(KT(e))return e;const s=e[Oa];if(!s)return ov(e,(i,n)=>pq(d,s,e,i,n,t)),e;if(s.scope_!==d)return e;if(!s.modified_)return cv(d,s.base_,!0),s.base_;if(!s.finalized_){s.finalized_=!0,s.scope_.unfinalizedDrafts_--;const i=s.copy_;let n=i,r=!1;s.type_===3&&(n=new Set(i),i.clear(),r=!0),ov(n,(a,o)=>pq(d,s,i,a,o,t,r)),cv(d,i,!1),t&&d.patches_&&zl("Patches").generatePatches_(s,t,d.patches_,d.inversePatches_)}return s.copy_}function pq(d,e,t,s,i,n,r){if(jl(i)){const a=n&&e&&e.type_!==3&&!MM(e.assigned_,s)?n.concat(s):void 0,o=dv(d,i,a);if(C8(t,s,o),jl(o))d.canAutoFreeze_=!1;else return}else r&&t.add(i);if(zc(i)&&!KT(i)){if(!d.immer_.autoFreeze_&&d.unfinalizedDrafts_<1)return;dv(d,i),(!e||!e.scope_.parent_)&&typeof s!="symbol"&&Object.prototype.propertyIsEnumerable.call(t,s)&&cv(d,i)}}function cv(d,e,t=!1){!d.parent_&&d.immer_.autoFreeze_&&d.canAutoFreeze_&&PA(e,t)}function cce(d,e){const t=Array.isArray(d),s={type_:t?1:0,scope_:e?e.scope_:M8(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:d,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=s,n=IA;t&&(i=[s],n=U0);const{revoke:r,proxy:a}=Proxy.revocable(i,n);return s.draft_=a,s.revoke_=r,a}var IA={get(d,e){if(e===Oa)return d;const t=ll(d);if(!MM(t,e))return uce(d,t,e);const s=t[e];return d.finalized_||!zc(s)?s:s===cI(d.base_,e)?(uI(d),d.copy_[e]=NM(s,d)):s},has(d,e){return e in ll(d)},ownKeys(d){return Reflect.ownKeys(ll(d))},set(d,e,t){const s=_8(ll(d),e);if(s!=null&&s.set)return s.set.call(d.draft_,t),!0;if(!d.modified_){const i=cI(ll(d),e),n=i==null?void 0:i[Oa];if(n&&n.base_===t)return d.copy_[e]=t,d.assigned_[e]=!1,!0;if(nce(t,i)&&(t!==void 0||MM(d.base_,e)))return!0;uI(d),BM(d)}return d.copy_[e]===t&&(t!==void 0||e in d.copy_)||Number.isNaN(t)&&Number.isNaN(d.copy_[e])||(d.copy_[e]=t,d.assigned_[e]=!0),!0},deleteProperty(d,e){return cI(d.base_,e)!==void 0||e in d.base_?(d.assigned_[e]=!1,uI(d),BM(d)):delete d.assigned_[e],d.copy_&&delete d.copy_[e],!0},getOwnPropertyDescriptor(d,e){const t=ll(d),s=Reflect.getOwnPropertyDescriptor(t,e);return s&&{writable:!0,configurable:d.type_!==1||e!=="length",enumerable:s.enumerable,value:t[e]}},defineProperty(){Ao(11)},getPrototypeOf(d){return Cm(d.base_)},setPrototypeOf(){Ao(12)}},U0={};ov(IA,(d,e)=>{U0[d]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});U0.deleteProperty=function(d,e){return U0.set.call(this,d,e,void 0)};U0.set=function(d,e,t){return IA.set.call(this,d[0],e,t,d[0])};function cI(d,e){const t=d[Oa];return(t?ll(t):d)[e]}function uce(d,e,t){var i;const s=_8(e,t);return s?"value"in s?s.value:(i=s.get)==null?void 0:i.call(d.draft_):void 0}function _8(d,e){if(!(e in d))return;let t=Cm(d);for(;t;){const s=Object.getOwnPropertyDescriptor(t,e);if(s)return s;t=Cm(t)}}function BM(d){d.modified_||(d.modified_=!0,d.parent_&&BM(d.parent_))}function uI(d){d.copy_||(d.copy_=_M(d.base_,d.scope_.immer_.useStrictShallowCopy_))}var hce=class{constructor(d){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,s)=>{if(typeof e=="function"&&typeof t!="function"){const n=t;t=e;const r=this;return function(o=n,...c){return r.produce(o,u=>t.call(this,u,...c))}}typeof t!="function"&&Ao(6),s!==void 0&&typeof s!="function"&&Ao(7);let i;if(zc(e)){const n=lq(this),r=NM(e,void 0);let a=!0;try{i=t(r),a=!1}finally{a?AM(n):LM(n)}return hq(n,s),fq(i,n)}else if(!e||typeof e!="object"){if(i=t(e),i===void 0&&(i=e),i===P8&&(i=void 0),this.autoFreeze_&&PA(i,!0),s){const n=[],r=[];zl("Patches").generateReplacementPatches_(e,i,n,r),s(n,r)}return i}else Ao(1,e)},this.produceWithPatches=(e,t)=>{if(typeof e=="function")return(r,...a)=>this.produceWithPatches(r,o=>e(o,...a));let s,i;return[this.produce(e,t,(r,a)=>{s=r,i=a}),s,i]},typeof(d==null?void 0:d.autoFreeze)=="boolean"&&this.setAutoFreeze(d.autoFreeze),typeof(d==null?void 0:d.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(d.useStrictShallowCopy)}createDraft(d){zc(d)||Ao(8),jl(d)&&(d=lce(d));const e=lq(this),t=NM(d,void 0);return t[Oa].isManual_=!0,LM(e),t}finishDraft(d,e){const t=d&&d[Oa];(!t||!t.isManual_)&&Ao(9);const{scope_:s}=t;return hq(s,e),fq(void 0,s)}setAutoFreeze(d){this.autoFreeze_=d}setUseStrictShallowCopy(d){this.useStrictShallowCopy_=d}applyPatches(d,e){let t;for(t=e.length-1;t>=0;t--){const i=e[t];if(i.path.length===0&&i.op==="replace"){d=i.value;break}}t>-1&&(e=e.slice(t+1));const s=zl("Patches").applyPatches_;return jl(d)?s(d,e):this.produce(d,i=>s(i,e))}};function NM(d,e){const t=zT(d)?zl("MapSet").proxyMap_(d,e):$T(d)?zl("MapSet").proxySet_(d,e):cce(d,e);return(e?e.scope_:M8()).drafts_.push(t),t}function lce(d){return jl(d)||Ao(10,d),A8(d)}function A8(d){if(!zc(d)||KT(d))return d;const e=d[Oa];let t;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,t=_M(d,e.scope_.immer_.useStrictShallowCopy_)}else t=_M(d,!0);return ov(t,(s,i)=>{C8(t,s,A8(i))}),e&&(e.finalized_=!1),t}var xa=new hce,Gr=xa.produce;xa.produceWithPatches.bind(xa);xa.setAutoFreeze.bind(xa);xa.setUseStrictShallowCopy.bind(xa);xa.applyPatches.bind(xa);xa.createDraft.bind(xa);xa.finishDraft.bind(xa);function L8(d){return({dispatch:t,getState:s})=>i=>n=>typeof n=="function"?n(t,s,d):i(n)}var fce=L8(),pce=L8,mce=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?av:av.apply(null,arguments)};function Si(d,e){function t(...s){if(e){let i=e(...s);if(!i)throw new Error(Ec(0));return{type:d,payload:i.payload,..."meta"in i&&{meta:i.meta},..."error"in i&&{error:i.error}}}return{type:d,payload:s[0]}}return t.toString=()=>`${d}`,t.type=d,t.match=s=>sce(s)&&s.type===d,t}var B8=class _y extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,_y.prototype)}static get[Symbol.species](){return _y}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new _y(...e[0].concat(this)):new _y(...e.concat(this))}};function mq(d){return zc(d)?Gr(d,()=>{}):d}function gq(d,e,t){return d.has(e)?d.get(e):d.set(e,t(e)).get(e)}function gce(d){return typeof d=="boolean"}var yce=()=>function(e){const{thunk:t=!0,immutableCheck:s=!0,serializableCheck:i=!0,actionCreatorCheck:n=!0}=e??{};let r=new B8;return t&&(gce(t)?r.push(fce):r.push(pce(t.extraArgument))),r},wce="RTK_autoBatch",yq=d=>e=>{setTimeout(e,d)},bce=(d={type:"raf"})=>e=>(...t)=>{const s=e(...t);let i=!0,n=!1,r=!1;const a=new Set,o=d.type==="tick"?queueMicrotask:d.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:yq(10):d.type==="callback"?d.queueNotification:yq(d.timeout),c=()=>{r=!1,n&&(n=!1,a.forEach(u=>u()))};return Object.assign({},s,{subscribe(u){const h=()=>i&&u(),l=s.subscribe(h);return a.add(u),()=>{l(),a.delete(u)}},dispatch(u){var h;try{return i=!((h=u==null?void 0:u.meta)!=null&&h[wce]),n=!i,n&&(r||(r=!0,o(c))),s.dispatch(u)}finally{i=!0}}})},kce=d=>function(t){const{autoBatch:s=!0}=t??{};let i=new B8(d);return s&&i.push(bce(typeof s=="object"?s:void 0)),i};function N8(d){const e=yce(),{reducer:t=void 0,middleware:s,devTools:i=!0,preloadedState:n=void 0,enhancers:r=void 0}=d||{};let a;if(typeof t=="function")a=t;else if(xA(t))a=ece(t);else throw new Error(Ec(1));let o;typeof s=="function"?o=s(e):o=e();let c=av;i&&(c=mce({trace:!1,...typeof i=="object"&&i}));const u=tce(...o),h=kce(u);let l=typeof r=="function"?r(h):h();const f=c(...l);return x8(a,n,f)}function E8(d){const e={},t=[];let s;const i={addCase(n,r){const a=typeof n=="string"?n:n.type;if(!a)throw new Error(Ec(28));if(a in e)throw new Error(Ec(29));return e[a]=r,i},addMatcher(n,r){return t.push({matcher:n,reducer:r}),i},addDefaultCase(n){return s=n,i}};return d(i),[e,t,s]}function Sce(d){return typeof d=="function"}function vce(d,e){let[t,s,i]=E8(e),n;if(Sce(d))n=()=>mq(d());else{const a=mq(d);n=()=>a}function r(a=n(),o){let c=[t[o.type],...s.filter(({matcher:u})=>u(o)).map(({reducer:u})=>u)];return c.filter(u=>!!u).length===0&&(c=[i]),c.reduce((u,h)=>{if(h)if(jl(u)){const f=h(u,o);return f===void 0?u:f}else{if(zc(u))return Gr(u,l=>h(l,o));{const l=h(u,o);if(l===void 0){if(u===null)return u;throw Error("A case reducer on a non-draftable value must not return undefined")}return l}}return u},a)}return r.getInitialState=n,r}var Tce=Symbol.for("rtk-slice-createasyncthunk");function Oce(d,e){return`${d}/${e}`}function xce({creators:d}={}){var t;const e=(t=d==null?void 0:d.asyncThunk)==null?void 0:t[Tce];return function(i){const{name:n,reducerPath:r=n}=i;if(!n)throw new Error(Ec(11));const a=(typeof i.reducers=="function"?i.reducers(Ice()):i.reducers)||{},o=Object.keys(a),c={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},u={addCase(b,S){const v=typeof b=="string"?b:b.type;if(!v)throw new Error(Ec(12));if(v in c.sliceCaseReducersByType)throw new Error(Ec(13));return c.sliceCaseReducersByType[v]=S,u},addMatcher(b,S){return c.sliceMatchers.push({matcher:b,reducer:S}),u},exposeAction(b,S){return c.actionCreators[b]=S,u},exposeCaseReducer(b,S){return c.sliceCaseReducersByName[b]=S,u}};o.forEach(b=>{const S=a[b],v={reducerName:b,type:Oce(n,b),createNotation:typeof i.reducers=="function"};Mce(S)?Ace(v,S,u,e):Cce(v,S,u)});function h(){const[b={},S=[],v=void 0]=typeof i.extraReducers=="function"?E8(i.extraReducers):[i.extraReducers],C={...b,...c.sliceCaseReducersByType};return vce(i.initialState,M=>{for(let _ in C)M.addCase(_,C[_]);for(let _ of c.sliceMatchers)M.addMatcher(_.matcher,_.reducer);for(let _ of S)M.addMatcher(_.matcher,_.reducer);v&&M.addDefaultCase(v)})}const l=b=>b,f=new Map;let p;function m(b,S){return p||(p=h()),p(b,S)}function g(){return p||(p=h()),p.getInitialState()}function y(b,S=!1){function v(M){let _=M[b];return typeof _>"u"&&S&&(_=g()),_}function C(M=l){const _=gq(f,S,()=>new WeakMap);return gq(_,M,()=>{const N={};for(const[A,R]of Object.entries(i.selectors??{}))N[A]=Pce(R,M,g,S);return N})}return{reducerPath:b,getSelectors:C,get selectors(){return C(v)},selectSlice:v}}const w={name:n,reducer:m,actions:c.actionCreators,caseReducers:c.sliceCaseReducersByName,getInitialState:g,...y(r),injectInto(b,{reducerPath:S,...v}={}){const C=S??r;return b.inject({reducerPath:C,reducer:m},v),{...w,...y(C,!0)}}};return w}}function Pce(d,e,t,s){function i(n,...r){let a=e(n);return typeof a>"u"&&s&&(a=t()),d(a,...r)}return i.unwrapped=d,i}var XT=xce();function Ice(){function d(e,t){return{_reducerDefinitionType:"asyncThunk",payloadCreator:e,...t}}return d.withTypes=()=>d,{reducer(e){return Object.assign({[e.name](...t){return e(...t)}}[e.name],{_reducerDefinitionType:"reducer"})},preparedReducer(e,t){return{_reducerDefinitionType:"reducerWithPrepare",prepare:e,reducer:t}},asyncThunk:d}}function Cce({type:d,reducerName:e,createNotation:t},s,i){let n,r;if("reducer"in s){if(t&&!_ce(s))throw new Error(Ec(17));n=s.reducer,r=s.prepare}else n=s;i.addCase(d,n).exposeCaseReducer(e,n).exposeAction(e,r?Si(d,r):Si(d))}function Mce(d){return d._reducerDefinitionType==="asyncThunk"}function _ce(d){return d._reducerDefinitionType==="reducerWithPrepare"}function Ace({type:d,reducerName:e},t,s,i){if(!i)throw new Error(Ec(18));const{payloadCreator:n,fulfilled:r,pending:a,rejected:o,settled:c,options:u}=t,h=i(d,n,u);s.exposeAction(e,h),r&&s.addCase(h.fulfilled,r),a&&s.addCase(h.pending,a),o&&s.addCase(h.rejected,o),c&&s.addMatcher(h.settled,c),s.exposeCaseReducer(e,{fulfilled:r||oS,pending:a||oS,rejected:o||oS,settled:c||oS})}function oS(){}function Ec(d){return`Minified Redux Toolkit error #${d}; visit https://redux-toolkit.js.org/Errors?code=${d} for the full message or use the non-minified dev environment for full errors. `}const Lce="changeFormType",Bce=Si(Lce),Nce="setExchangeAccountId",Ece=Si(Nce),Rce="setExchangeCode",Dce=Si(Rce),qce="setSymbolId",Vce=Si(qce),Fce="changeSymbolId",Hce=Si(Fce),Gce="setHighPrice",Uce=Si(Gce),Wce="changeHighPrice",jce=Si(Wce),zce="setLowPrice",$ce=Si(zce),Kce="changeLowPrice",Xce=Si(Kce),Qce="changeGridLinesNumber",Yce=Si(Qce),Zce="setQuantityPerGrid",Jce=Si(Zce),eue="changeQuantityPerGrid",tue=Si(eue),sue="setBotId",iue=Si(sue),nue="setBotName",rue=Si(nue),aue="changeBotName",oue=Si(aue),due="changeBarSize",cue=Si(due),uue="setGridLines",hue=Si(uue),lue="updateGridLines",fue=Si(lue),pue="addGridLine",mue=Si(pue),gue="removeGridLine",yue=Si(gue),wue="updateGridLinePrice",bue=Si(wue),kue="updateGridLineQuantity",Sue=Si(kue),W0={Bot:"Bot",DcaBot:"DcaBot",GridBot:"GridBot"},vue={Buy:"Buy",Sell:"Sell"},Jf={Idle:"Idle",Placed:"Placed",Filled:"Filled",Canceled:"Canceled",Revoked:"Revoked",Deleted:"Deleted"},CA={Limit:"Limit",Market:"Market"},mf={ONE_MINUTE:"1m",FIVE_MINUTES:"5m",FIFTEEN_MINUTES:"15m",ONE_HOUR:"1h",FOUR_HOURS:"4h",ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1M",THREE_MONTHS:"3M"},Xa={OKX:"OKX",BYBIT:"BYBIT",BINANCE:"BINANCE",KRAKEN:"KRAKEN",COINBASE:"COINBASE",GATEIO:"GATEIO",BITGET:"BITGET"},vc={Real:"Real",Demo:"Demo",Paper:"Paper"};var im=(d=>(d.Buy="buy",d.Sell="sell",d))(im||{});const pWe={Idle:"idle",Placed:"placed",Filled:"filled"},Tue=d=>(d==null?void 0:d.indicatorValue)!==void 0&&(d==null?void 0:d.periods)!==void 0&&(d==null?void 0:d.timeframe)!==void 0,hI={onOrderFilled:"onOrderFilled",onCandleClosed:"onCandleClosed",onPublicTrade:"onPublicTrade",onOrderbookChange:"onOrderbookChange",onTickerChange:"onTickerChange"},Oue=10,xue=1,mWe=["1d","4h","1h","5m"],Pue={type:"simple",botId:NaN,botName:"",exchangeAccountId:0,exchangeCode:"OKX",symbolId:"OKX:BTC/USDT",highPrice:0,lowPrice:0,gridLinesNumber:Oue,quantityPerGrid:`${xue}`,gridLines:[],barSize:mf.ONE_DAY},R8=XT({name:"gridBotForm",initialState:Pue,reducers:{[Bce.type]:(d,e)=>{d.type=e.payload},[Ece.type]:(d,e)=>{d.exchangeAccountId=e.payload},[Dce.type]:(d,e)=>{d.exchangeCode=e.payload},[Vce.type]:(d,e)=>{d.symbolId=e.payload},[Hce.type]:(d,e)=>{d.symbolId=e.payload},[jce.type]:(d,e)=>{d.highPrice=e.payload},[Uce.type]:(d,e)=>{d.highPrice=e.payload},[Xce.type]:(d,e)=>{d.lowPrice=e.payload},[$ce.type]:(d,e)=>{d.lowPrice=e.payload},[Yce.type]:(d,e)=>{d.gridLinesNumber=e.payload},[tue.type]:(d,e)=>{d.quantityPerGrid=e.payload},[Jce.type]:(d,e)=>{d.quantityPerGrid=e.payload},[iue.type]:(d,e)=>{d.botId=e.payload},[rue.type]:(d,e)=>{d.botName=e.payload},[oue.type]:(d,e)=>{d.botName=e.payload},[cue.type]:(d,e)=>{d.barSize=e.payload},[hue.type]:(d,e)=>{d.gridLines=e.payload},[fue.type]:(d,e)=>{d.gridLines=e.payload},[mue.type]:(d,e)=>{d.gridLines.push(e.payload)},[yue.type]:(d,e)=>{const t=e.payload;d.gridLines.splice(t,1)},[bue.type]:(d,e)=>{const{gridLineIndex:t,price:s}=e.payload;d.gridLines[t].price=s},[Sue.type]:(d,e)=>{const{gridLineIndex:t,quantity:s}=e.payload;d.gridLines[t].quantity=s}}}),{changeFormType:gWe,setExchangeAccountId:yWe,setExchangeCode:wWe,setSymbolId:bWe,changeSymbolId:kWe,setHighPrice:SWe,changeHighPrice:vWe,setLowPrice:TWe,changeLowPrice:OWe,changeGridLinesNumber:xWe,setQuantityPerGrid:PWe,changeQuantityPerGrid:IWe,setBotId:CWe,setBotName:MWe,changeBotName:_We,changeBarSize:AWe,setGridLines:LWe,updateGridLines:BWe,addGridLine:NWe,removeGridLine:EWe,updateGridLinePrice:RWe,updateGridLineQuantity:DWe}=R8.actions;var Iue=20,Cue=1,$l=1e6,wq=1e6,Mue=-7,_ue=21,Aue=!1,Zw="[big.js] ",gf=Zw+"Invalid ",QT=gf+"decimal places",Lue=gf+"rounding mode",D8=Zw+"Division by zero",$s={},Rd=void 0,Bue=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function q8(){function d(e){var t=this;if(!(t instanceof d))return e===Rd?q8():new d(e);if(e instanceof d)t.s=e.s,t.e=e.e,t.c=e.c.slice();else{if(typeof e!="string"){if(d.strict===!0&&typeof e!="bigint")throw TypeError(gf+"value");e=e===0&&1/e<0?"-0":String(e)}Nue(t,e)}t.constructor=d}return d.prototype=$s,d.DP=Iue,d.RM=Cue,d.NE=Mue,d.PE=_ue,d.strict=Aue,d.roundDown=0,d.roundHalfUp=1,d.roundHalfEven=2,d.roundUp=3,d}function Nue(d,e){var t,s,i;if(!Bue.test(e))throw Error(gf+"number");for(d.s=e.charAt(0)=="-"?(e=e.slice(1),-1):1,(t=e.indexOf("."))>-1&&(e=e.replace(".","")),(s=e.search(/e/i))>0?(t<0&&(t=s),t+=+e.slice(s+1),e=e.substring(0,s)):t<0&&(t=e.length),i=e.length,s=0;s0&&e.charAt(--i)=="0";);for(d.e=t-s-1,d.c=[],t=0;s<=i;)d.c[t++]=+e.charAt(s++)}return d}function yf(d,e,t,s){var i=d.c;if(t===Rd&&(t=d.constructor.RM),t!==0&&t!==1&&t!==2&&t!==3)throw Error(Lue);if(e<1)s=t===3&&(s||!!i[0])||e===0&&(t===1&&i[0]>=5||t===2&&(i[0]>5||i[0]===5&&(s||i[1]!==Rd))),i.length=1,s?(d.e=d.e-e+1,i[0]=1):i[0]=d.e=0;else if(e=5||t===2&&(i[e]>5||i[e]===5&&(s||i[e+1]!==Rd||i[e-1]&1))||t===3&&(s||!!i[0]),i.length=e,s){for(;++i[--e]>9;)if(i[e]=0,e===0){++d.e,i.unshift(1);break}}for(e=i.length;!i[--e];)i.pop()}return d}function wf(d,e,t){var s=d.e,i=d.c.join(""),n=i.length;if(e)i=i.charAt(0)+(n>1?"."+i.slice(1):"")+(s<0?"e":"e+")+s;else if(s<0){for(;++s;)i="0"+i;i="0."+i}else if(s>0)if(++s>n)for(s-=n;s--;)i+="0";else s1&&(i=i.charAt(0)+"."+i.slice(1));return d.s<0&&t?"-"+i:i}$s.abs=function(){var d=new this.constructor(this);return d.s=1,d};$s.cmp=function(d){var e,t=this,s=t.c,i=(d=new t.constructor(d)).c,n=t.s,r=d.s,a=t.e,o=d.e;if(!s[0]||!i[0])return s[0]?n:i[0]?-r:0;if(n!=r)return n;if(e=n<0,a!=o)return a>o^e?1:-1;for(r=(a=s.length)<(o=i.length)?a:o,n=-1;++ni[n]^e?1:-1;return a==o?0:a>o^e?1:-1};$s.div=function(d){var e=this,t=e.constructor,s=e.c,i=(d=new t(d)).c,n=e.s==d.s?1:-1,r=t.DP;if(r!==~~r||r<0||r>$l)throw Error(QT);if(!i[0])throw Error(D8);if(!s[0])return d.s=n,d.c=[d.e=0],d;var a,o,c,u,h,l=i.slice(),f=a=i.length,p=s.length,m=s.slice(0,a),g=m.length,y=d,w=y.c=[],b=0,S=r+(y.e=e.e-d.e)+1;for(y.s=n,n=S<0?0:S,l.unshift(0);g++g?1:-1;else for(h=-1,u=0;++hm[h]?1:-1;break}if(u<0){for(o=g==a?i:l;g;){if(m[--g]S&&yf(y,S,t.RM,m[0]!==Rd),y};$s.eq=function(d){return this.cmp(d)===0};$s.gt=function(d){return this.cmp(d)>0};$s.gte=function(d){return this.cmp(d)>-1};$s.lt=function(d){return this.cmp(d)<0};$s.lte=function(d){return this.cmp(d)<1};$s.minus=$s.sub=function(d){var e,t,s,i,n=this,r=n.constructor,a=n.s,o=(d=new r(d)).s;if(a!=o)return d.s=-o,n.plus(d);var c=n.c.slice(),u=n.e,h=d.c,l=d.e;if(!c[0]||!h[0])return h[0]?d.s=-o:c[0]?d=new r(n):d.s=1,d;if(a=u-l){for((i=a<0)?(a=-a,s=c):(l=u,s=h),s.reverse(),o=a;o--;)s.push(0);s.reverse()}else for(t=((i=c.length0)for(;o--;)c[e++]=0;for(o=e;t>a;){if(c[--t]0?(o=r,s=c):(e=-e,s=a),s.reverse();e--;)s.push(0);s.reverse()}for(a.length-c.length<0&&(s=c,c=a,a=s),e=c.length,t=0;e;a[e]%=10)t=(a[--e]=a[e]+c[e]+t)/10|0;for(t&&(a.unshift(t),++o),e=a.length;a[--e]===0;)a.pop();return d.c=a,d.e=o,d};$s.pow=function(d){var e=this,t=new e.constructor("1"),s=t,i=d<0;if(d!==~~d||d<-wq||d>wq)throw Error(gf+"exponent");for(i&&(d=-d);d&1&&(s=s.times(e)),d>>=1,!!d;)e=e.times(e);return i?t.div(s):s};$s.prec=function(d,e){if(d!==~~d||d<1||d>$l)throw Error(gf+"precision");return yf(new this.constructor(this),d,e)};$s.round=function(d,e){if(d===Rd)d=0;else if(d!==~~d||d<-$l||d>$l)throw Error(QT);return yf(new this.constructor(this),d+this.e+1,e)};$s.sqrt=function(){var d,e,t,s=this,i=s.constructor,n=s.s,r=s.e,a=new i("0.5");if(!s.c[0])return new i(s);if(n<0)throw Error(Zw+"No square root");n=Math.sqrt(+wf(s,!0,!0)),n===0||n===1/0?(e=s.c.join(""),e.length+r&1||(e+="0"),n=Math.sqrt(e),r=((r+1)/2|0)-(r<0||r&1),d=new i((n==1/0?"5e":(n=n.toExponential()).slice(0,n.indexOf("e")+1))+r)):d=new i(n+""),r=d.e+(i.DP+=4);do t=d,d=a.times(t.plus(s.div(t)));while(t.c.slice(0,r).join("")!==d.c.slice(0,r).join(""));return yf(d,(i.DP-=4)+d.e+1,i.RM)};$s.times=$s.mul=function(d){var e,t=this,s=t.constructor,i=t.c,n=(d=new s(d)).c,r=i.length,a=n.length,o=t.e,c=d.e;if(d.s=t.s==d.s?1:-1,!i[0]||!n[0])return d.c=[d.e=0],d;for(d.e=o+c,ro;)a=e[c]+n[o]*i[c-o-1]+a,e[c--]=a%10,a=a/10|0;e[c]=a}for(a?++d.e:e.shift(),o=e.length;!e[--o];)e.pop();return d.c=e,d};$s.toExponential=function(d,e){var t=this,s=t.c[0];if(d!==Rd){if(d!==~~d||d<0||d>$l)throw Error(QT);for(t=yf(new t.constructor(t),++d,e);t.c.length$l)throw Error(QT);for(t=yf(new t.constructor(t),d+t.e+1,e),d=d+t.e+1;t.c.length=e.PE,!!d.c[0])};$s.toNumber=function(){var d=+wf(this,!0,!0);if(this.constructor.strict===!0&&!this.eq(d.toString()))throw Error(Zw+"Imprecise conversion");return d};$s.toPrecision=function(d,e){var t=this,s=t.constructor,i=t.c[0];if(d!==Rd){if(d!==~~d||d<1||d>$l)throw Error(gf+"precision");for(t=yf(new s(t),d,e);t.c.length=s.PE,!!i)};$s.valueOf=function(){var d=this,e=d.constructor;if(e.strict===!0)throw Error(Zw+"valueOf disallowed");return wf(d,d.e<=e.NE||d.e>=e.PE,!0)};var Ro=q8();const r1=60*1e3,EM=60*r1,dS=24*EM,V8={"1m":r1,"5m":5*r1,"15m":15*r1,"1h":EM,"4h":4*EM,"1d":dS,"1w":7*dS,"1M":30*dS,"3M":90*dS};function Eue(d){return V8[d]}const Mm=":",YT="/";function ZT(d,e,t){return`${d.toUpperCase()}${Mm}${e}${YT}${t}`}const F8=Object.keys(Xa),Rue=`^(${F8.join("|")})${Mm}[A-Z0-9]+${YT}[A-Z0-9]+$`,Due=`^(${F8.join("|")})${Mm}[A-Z0-9]+${YT}[A-Z0-9]+${Mm}[A-Z0-9]+$`;function que(d){return new RegExp(Rue).test(d)||new RegExp(Due).test(d)}function MA(d){if(!que(d))throw new Error(`${d} is not a valid symbolId`);const[e,t,s]=d.split(Mm),[i,n]=t.split(YT);return{exchangeCode:Xa[e],currencyPairSymbol:s?t+Mm+s:t,baseCurrency:i,quoteCurrency:n}}function Kd(d){const[e="NONE",t="NONE"]=d.split("/");return{baseCurrency:e,quoteCurrency:t}}function JT(d){const{baseCurrency:e}=Kd(d);return e}function eO(d){const{quoteCurrency:e}=Kd(d);return e}const Vue=0,H8=2,G8=.01,Fue=5,Hue=1.7,Gue=4,_A=1,U8={indicatorValue:"30",timeframe:mf.ONE_MINUTE,periods:"14"},Uue={indicatorValue:"50",timeframe:mf.ONE_MINUTE,periods:"7"},Wue={indicatorValue:"50",timeframe:mf.ONE_MINUTE,periods:"7"},W8={combinator:"and",rules:[{field:"RSI",operator:">",value:U8}]},jue=["1d","4h","1h","5m"],zue={botId:NaN,botName:"",exchangeAccountId:0,exchangeCode:"OKX",symbolId:"OKX:BTC/USDT",entryOrderType:CA.Market,entryOrderQuantity:`${Vue}`,entryConditions:W8,takeProfitPercent:H8,simple:{safetyOrdersCount:Fue,safetyOrdersVolumeScale:Hue,safetyOrdersPriceScale:Gue,safetyOrdersPriceDeviation:_A},safetyOrders:[],safetyOrderFormType:"advanced",barSize:mf.ONE_DAY},j8=XT({name:"dcaBotForm",initialState:zue,reducers:{changeSafetyOrdersFormType:(d,e)=>{d.safetyOrderFormType=e.payload},setExchangeAccountId:(d,e)=>{d.exchangeAccountId=e.payload},changeExchangeAccountId:(d,e)=>{d.exchangeAccountId=e.payload},setExchangeCode:(d,e)=>{d.exchangeCode=e.payload},setSymbolId:(d,e)=>{d.symbolId=e.payload},changeSymbolId:(d,e)=>{d.symbolId=e.payload},setBotId:(d,e)=>{d.botId=e.payload},setBotName:(d,e)=>{d.botName=e.payload},changeBotName:(d,e)=>{d.botName=e.payload},changeBarSize:(d,e)=>{d.barSize=e.payload},setEntryOrderType:(d,e)=>{d.entryOrderType=e.payload},changeEntryOrderType:(d,e)=>{d.entryOrderType=e.payload},setEntryOrderQuantity:(d,e)=>{d.entryOrderQuantity=e.payload},changeEntryOrderQuantity:(d,e)=>{d.entryOrderQuantity=e.payload},setEntryConditions:(d,e)=>{d.entryConditions=e.payload},changeEntryConditions:(d,e)=>{d.entryConditions=e.payload},setTakeProfitPercent:(d,e)=>{d.takeProfitPercent=e.payload},changeTakeProfitPercent:(d,e)=>{d.takeProfitPercent=e.payload},setSafetyOrdersCount:(d,e)=>{d.simple.safetyOrdersCount=e.payload},changeSafetyOrdersCount:(d,e)=>{d.simple.safetyOrdersCount=e.payload},setSafetyOrdersVolumeScale:(d,e)=>{d.simple.safetyOrdersVolumeScale=e.payload},changeSafetyOrdersVolumeScale:(d,e)=>{d.simple.safetyOrdersVolumeScale=e.payload},setSafetyOrdersPriceScale:(d,e)=>{d.simple.safetyOrdersPriceScale=e.payload},changeSafetyOrdersPriceScale:(d,e)=>{d.simple.safetyOrdersPriceScale=e.payload},setSafetyOrdersPriceDeviation:(d,e)=>{d.simple.safetyOrdersPriceDeviation=e.payload},changeSafetyOrdersPriceDeviation:(d,e)=>{d.simple.safetyOrdersPriceDeviation=e.payload},setSafetyOrders:(d,e)=>{d.safetyOrders=e.payload},updateSafetyOrders:(d,e)=>{d.safetyOrders=e.payload},addSafetyOrder:(d,e)=>{d.safetyOrders.push(e.payload)},removeSafetyOrder:(d,e)=>{const t=e.payload;d.safetyOrders.splice(t,1)},updateSafetyOrderPriceDeviation:(d,e)=>{const{index:t,priceDeviation:s}=e.payload;d.safetyOrders[t].priceDeviation=s},updateSafetyOrderQuantity:(d,e)=>{const{index:t,quantity:s}=e.payload;d.safetyOrders[t].quantity=s}}}),{changeSafetyOrdersFormType:qWe,setExchangeAccountId:$ue,changeExchangeAccountId:Kue,setExchangeCode:Xue,setSymbolId:Que,changeSymbolId:Yue,setBotId:VWe,setBotName:Zue,changeBotName:Jue,changeBarSize:ehe,setEntryOrderType:the,changeEntryOrderType:she,setEntryOrderQuantity:ihe,changeEntryOrderQuantity:nhe,setEntryConditions:rhe,changeEntryConditions:ahe,setTakeProfitPercent:ohe,changeTakeProfitPercent:dhe,setSafetyOrders:che,updateSafetyOrders:FWe,addSafetyOrder:bq,removeSafetyOrder:uhe,updateSafetyOrderPriceDeviation:hhe,updateSafetyOrderQuantity:lhe}=j8.actions,fhe=d=>d.dcaBotForm,phe=d=>d.dcaBotForm.botName,mhe=d=>d.dcaBotForm.barSize,ghe=d=>d.dcaBotForm.exchangeAccountId,tO=d=>d.dcaBotForm.symbolId,yhe=d=>d.dcaBotForm.entryOrderType,whe=d=>d.dcaBotForm.entryOrderQuantity,bhe=d=>d.dcaBotForm.entryConditions,z8=d=>d.dcaBotForm.takeProfitPercent,$8=d=>d.dcaBotForm.safetyOrders,K8=d=>e=>e.dcaBotForm.safetyOrders[d],khe=N8({reducer:{dcaBotForm:j8.reducer,gridBotForm:R8.reducer},devTools:!0}),She=({children:d})=>P.jsx(y8,{store:khe,children:d});class vhe{constructor(){this.keyToValue=new Map,this.valueToKey=new Map}set(e,t){this.keyToValue.set(e,t),this.valueToKey.set(t,e)}getByKey(e){return this.keyToValue.get(e)}getByValue(e){return this.valueToKey.get(e)}clear(){this.keyToValue.clear(),this.valueToKey.clear()}}class X8{constructor(e){this.generateIdentifier=e,this.kv=new vhe}register(e,t){this.kv.getByValue(e)||(t||(t=this.generateIdentifier(e)),this.kv.set(t,e))}clear(){this.kv.clear()}getIdentifier(e){return this.kv.getByValue(e)}getValue(e){return this.kv.getByKey(e)}}class The extends X8{constructor(){super(e=>e.name),this.classToAllowedProps=new Map}register(e,t){typeof t=="object"?(t.allowProps&&this.classToAllowedProps.set(e,t.allowProps),super.register(e,t.identifier)):super.register(e,t)}getAllowedProps(e){return this.classToAllowedProps.get(e)}}function Ohe(d){if("values"in Object)return Object.values(d);const e=[];for(const t in d)d.hasOwnProperty(t)&&e.push(d[t]);return e}function xhe(d,e){const t=Ohe(d);if("find"in t)return t.find(e);const s=t;for(let i=0;ie(s,t))}function a1(d,e){return d.indexOf(e)!==-1}function kq(d,e){for(let t=0;tt.isApplicable(e))}findByName(e){return this.transfomers[e]}}const Ihe=d=>Object.prototype.toString.call(d).slice(8,-1),Q8=d=>typeof d>"u",Che=d=>d===null,j0=d=>typeof d!="object"||d===null||d===Object.prototype?!1:Object.getPrototypeOf(d)===null?!0:Object.getPrototypeOf(d)===Object.prototype,RM=d=>j0(d)&&Object.keys(d).length===0,bh=d=>Array.isArray(d),Mhe=d=>typeof d=="string",_he=d=>typeof d=="number"&&!isNaN(d),Ahe=d=>typeof d=="boolean",Lhe=d=>d instanceof RegExp,z0=d=>d instanceof Map,$0=d=>d instanceof Set,Y8=d=>Ihe(d)==="Symbol",Bhe=d=>d instanceof Date&&!isNaN(d.valueOf()),Nhe=d=>d instanceof Error,Sq=d=>typeof d=="number"&&isNaN(d),Ehe=d=>Ahe(d)||Che(d)||Q8(d)||_he(d)||Mhe(d)||Y8(d),Rhe=d=>typeof d=="bigint",Dhe=d=>d===1/0||d===-1/0,qhe=d=>ArrayBuffer.isView(d)&&!(d instanceof DataView),Vhe=d=>d instanceof URL,Z8=d=>d.replace(/\./g,"\\."),lI=d=>d.map(String).map(Z8).join("."),Jy=d=>{const e=[];let t="";for(let i=0;inull,()=>{}),ud(Rhe,"bigint",d=>d.toString(),d=>typeof BigInt<"u"?BigInt(d):(console.error("Please add a BigInt polyfill."),d)),ud(Bhe,"Date",d=>d.toISOString(),d=>new Date(d)),ud(Nhe,"Error",(d,e)=>{const t={name:d.name,message:d.message};return e.allowedErrorProps.forEach(s=>{t[s]=d[s]}),t},(d,e)=>{const t=new Error(d.message);return t.name=d.name,t.stack=d.stack,e.allowedErrorProps.forEach(s=>{t[s]=d[s]}),t}),ud(Lhe,"regexp",d=>""+d,d=>{const e=d.slice(1,d.lastIndexOf("/")),t=d.slice(d.lastIndexOf("/")+1);return new RegExp(e,t)}),ud($0,"set",d=>[...d.values()],d=>new Set(d)),ud(z0,"map",d=>[...d.entries()],d=>new Map(d)),ud(d=>Sq(d)||Dhe(d),"number",d=>Sq(d)?"NaN":d>0?"Infinity":"-Infinity",Number),ud(d=>d===0&&1/d===-1/0,"number",()=>"-0",Number),ud(Vhe,"URL",d=>d.toString(),d=>new URL(d))];function sO(d,e,t,s){return{isApplicable:d,annotation:e,transform:t,untransform:s}}const eG=sO((d,e)=>Y8(d)?!!e.symbolRegistry.getIdentifier(d):!1,(d,e)=>["symbol",e.symbolRegistry.getIdentifier(d)],d=>d.description,(d,e,t)=>{const s=t.symbolRegistry.getValue(e[1]);if(!s)throw new Error("Trying to deserialize unknown symbol");return s}),Fhe=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,Uint8ClampedArray].reduce((d,e)=>(d[e.name]=e,d),{}),tG=sO(qhe,d=>["typed-array",d.constructor.name],d=>[...d],(d,e)=>{const t=Fhe[e[1]];if(!t)throw new Error("Trying to deserialize unknown typed array");return new t(d)});function sG(d,e){return d!=null&&d.constructor?!!e.classRegistry.getIdentifier(d.constructor):!1}const iG=sO(sG,(d,e)=>["class",e.classRegistry.getIdentifier(d.constructor)],(d,e)=>{const t=e.classRegistry.getAllowedProps(d.constructor);if(!t)return{...d};const s={};return t.forEach(i=>{s[i]=d[i]}),s},(d,e,t)=>{const s=t.classRegistry.getValue(e[1]);if(!s)throw new Error(`Trying to deserialize unknown class '${e[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);return Object.assign(Object.create(s.prototype),d)}),nG=sO((d,e)=>!!e.customTransformerRegistry.findApplicable(d),(d,e)=>["custom",e.customTransformerRegistry.findApplicable(d).name],(d,e)=>e.customTransformerRegistry.findApplicable(d).serialize(d),(d,e,t)=>{const s=t.customTransformerRegistry.findByName(e[1]);if(!s)throw new Error("Trying to deserialize unknown custom value");return s.deserialize(d)}),Hhe=[iG,eG,nG,tG],vq=(d,e)=>{const t=kq(Hhe,i=>i.isApplicable(d,e));if(t)return{value:t.transform(d,e),type:t.annotation(d,e)};const s=kq(J8,i=>i.isApplicable(d,e));if(s)return{value:s.transform(d,e),type:s.annotation}},rG={};J8.forEach(d=>{rG[d.annotation]=d});const Ghe=(d,e,t)=>{if(bh(e))switch(e[0]){case"symbol":return eG.untransform(d,e,t);case"class":return iG.untransform(d,e,t);case"custom":return nG.untransform(d,e,t);case"typed-array":return tG.untransform(d,e,t);default:throw new Error("Unknown transformation: "+e)}else{const s=rG[e];if(!s)throw new Error("Unknown transformation: "+e);return s.untransform(d,t)}},Np=(d,e)=>{if(e>d.size)throw new Error("index out of bounds");const t=d.keys();for(;e>0;)t.next(),e--;return t.next().value};function aG(d){if(a1(d,"__proto__"))throw new Error("__proto__ is not allowed as a property");if(a1(d,"prototype"))throw new Error("prototype is not allowed as a property");if(a1(d,"constructor"))throw new Error("constructor is not allowed as a property")}const Uhe=(d,e)=>{aG(e);for(let t=0;t{if(aG(e),e.length===0)return t(d);let s=d;for(let n=0;nqM(n,e,[...t,...Jy(r)]));return}const[s,i]=d;i&&_m(i,(n,r)=>{qM(n,e,[...t,...Jy(r)])}),e(s,t)}function Whe(d,e,t){return qM(e,(s,i)=>{d=DM(d,i,n=>Ghe(n,s,t))}),d}function jhe(d,e){function t(s,i){const n=Uhe(d,Jy(i));s.map(Jy).forEach(r=>{d=DM(d,r,()=>n)})}if(bh(e)){const[s,i]=e;s.forEach(n=>{d=DM(d,Jy(n),()=>d)}),i&&_m(i,t)}else _m(e,t);return d}const zhe=(d,e)=>j0(d)||bh(d)||z0(d)||$0(d)||sG(d,e);function $he(d,e,t){const s=t.get(d);s?s.push(e):t.set(d,[e])}function Khe(d,e){const t={};let s;return d.forEach(i=>{if(i.length<=1)return;e||(i=i.map(a=>a.map(String)).sort((a,o)=>a.length-o.length));const[n,...r]=i;n.length===0?s=r.map(lI):t[lI(n)]=r.map(lI)}),s?RM(t)?[s]:[s,t]:RM(t)?void 0:t}const oG=(d,e,t,s,i=[],n=[],r=new Map)=>{const a=Ehe(d);if(!a){$he(d,i,e);const f=r.get(d);if(f)return s?{transformedValue:null}:f}if(!zhe(d,t)){const f=vq(d,t),p=f?{transformedValue:f.value,annotations:[f.type]}:{transformedValue:d};return a||r.set(d,p),p}if(a1(n,d))return{transformedValue:null};const o=vq(d,t),c=(o==null?void 0:o.value)??d,u=bh(c)?[]:{},h={};_m(c,(f,p)=>{if(p==="__proto__"||p==="constructor"||p==="prototype")throw new Error(`Detected property ${p}. This is a prototype pollution risk, please remove it from your object.`);const m=oG(f,e,t,s,[...i,p],[...n,d],r);u[p]=m.transformedValue,bh(m.annotations)?h[p]=m.annotations:j0(m.annotations)&&_m(m.annotations,(g,y)=>{h[Z8(p)+"."+y]=g})});const l=RM(h)?{transformedValue:u,annotations:o?[o.type]:void 0}:{transformedValue:u,annotations:o?[o.type,h]:h};return a||r.set(d,l),l};function dG(d){return Object.prototype.toString.call(d).slice(8,-1)}function Tq(d){return dG(d)==="Array"}function Xhe(d){if(dG(d)!=="Object")return!1;const e=Object.getPrototypeOf(d);return!!e&&e.constructor===Object&&e===Object.prototype}function Qhe(d,e,t,s,i){const n={}.propertyIsEnumerable.call(s,e)?"enumerable":"nonenumerable";n==="enumerable"&&(d[e]=t),i&&n==="nonenumerable"&&Object.defineProperty(d,e,{value:t,enumerable:!1,writable:!0,configurable:!0})}function VM(d,e={}){if(Tq(d))return d.map(i=>VM(i,e));if(!Xhe(d))return d;const t=Object.getOwnPropertyNames(d),s=Object.getOwnPropertySymbols(d);return[...t,...s].reduce((i,n)=>{if(Tq(e.props)&&!e.props.includes(n))return i;const r=d[n],a=VM(r,e);return Qhe(i,n,a,d,e.nonenumerable),i},{})}class vs{constructor({dedupe:e=!1}={}){this.classRegistry=new The,this.symbolRegistry=new X8(t=>t.description??""),this.customTransformerRegistry=new Phe,this.allowedErrorProps=[],this.dedupe=e}serialize(e){const t=new Map,s=oG(e,t,this,this.dedupe),i={json:s.transformedValue};s.annotations&&(i.meta={...i.meta,values:s.annotations});const n=Khe(t,this.dedupe);return n&&(i.meta={...i.meta,referentialEqualities:n}),i}deserialize(e){const{json:t,meta:s}=e;let i=VM(t);return s!=null&&s.values&&(i=Whe(i,s.values,this)),s!=null&&s.referentialEqualities&&(i=jhe(i,s.referentialEqualities)),i}stringify(e){return JSON.stringify(this.serialize(e))}parse(e){return this.deserialize(JSON.parse(e))}registerClass(e,t){this.classRegistry.register(e,t)}registerSymbol(e,t){this.symbolRegistry.register(e,t)}registerCustom(e,t){this.customTransformerRegistry.register({name:t,...e})}allowErrorProps(...e){this.allowedErrorProps.push(...e)}}vs.defaultInstance=new vs;vs.serialize=vs.defaultInstance.serialize.bind(vs.defaultInstance);vs.deserialize=vs.defaultInstance.deserialize.bind(vs.defaultInstance);vs.stringify=vs.defaultInstance.stringify.bind(vs.defaultInstance);vs.parse=vs.defaultInstance.parse.bind(vs.defaultInstance);vs.registerClass=vs.defaultInstance.registerClass.bind(vs.defaultInstance);vs.registerSymbol=vs.defaultInstance.registerSymbol.bind(vs.defaultInstance);vs.registerCustom=vs.defaultInstance.registerCustom.bind(vs.defaultInstance);vs.allowErrorProps=vs.defaultInstance.allowErrorProps.bind(vs.defaultInstance);vs.serialize;vs.deserialize;vs.stringify;vs.parse;vs.registerClass;vs.registerCustom;vs.registerSymbol;vs.allowErrorProps;class bf{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){const t={listener:e};return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}}const K0=typeof window>"u"||"Deno"in window;function $a(){}function Yhe(d,e){return typeof d=="function"?d(e):d}function FM(d){return typeof d=="number"&&d>=0&&d!==1/0}function Oq(d,e){return d.filter(t=>!e.includes(t))}function Zhe(d,e,t){const s=d.slice(0);return s[e]=t,s}function cG(d,e){return Math.max(d+(e||0)-Date.now(),0)}function Ep(d,e,t){return Jw(d)?typeof e=="function"?{...t,queryKey:d,queryFn:e}:{...e,queryKey:d}:d}function Jhe(d,e,t){return Jw(d)?{...e,mutationKey:d}:typeof d=="function"?{...e,mutationFn:d}:{...d}}function Eu(d,e,t){return Jw(d)?[{...e,queryKey:d},t]:[d||{},e]}function xq(d,e){const{type:t="all",exact:s,fetchStatus:i,predicate:n,queryKey:r,stale:a}=d;if(Jw(r)){if(s){if(e.queryHash!==AA(r,e.options))return!1}else if(!uv(e.queryKey,r))return!1}if(t!=="all"){const o=e.isActive();if(t==="active"&&!o||t==="inactive"&&o)return!1}return!(typeof a=="boolean"&&e.isStale()!==a||typeof i<"u"&&i!==e.state.fetchStatus||n&&!n(e))}function Pq(d,e){const{exact:t,fetching:s,predicate:i,mutationKey:n}=d;if(Jw(n)){if(!e.options.mutationKey)return!1;if(t){if(Qu(e.options.mutationKey)!==Qu(n))return!1}else if(!uv(e.options.mutationKey,n))return!1}return!(typeof s=="boolean"&&e.state.status==="loading"!==s||i&&!i(e))}function AA(d,e){return((e==null?void 0:e.queryKeyHashFn)||Qu)(d)}function Qu(d){return JSON.stringify(d,(e,t)=>HM(t)?Object.keys(t).sort().reduce((s,i)=>(s[i]=t[i],s),{}):t)}function uv(d,e){return uG(d,e)}function uG(d,e){return d===e?!0:typeof d!=typeof e?!1:d&&e&&typeof d=="object"&&typeof e=="object"?!Object.keys(e).some(t=>!uG(d[t],e[t])):!1}function hG(d,e){if(d===e)return d;const t=Iq(d)&&Iq(e);if(t||HM(d)&&HM(e)){const s=t?d.length:Object.keys(d).length,i=t?e:Object.keys(e),n=i.length,r=t?[]:{};let a=0;for(let o=0;o"u")return!0;const t=e.prototype;return!(!Cq(t)||!t.hasOwnProperty("isPrototypeOf"))}function Cq(d){return Object.prototype.toString.call(d)==="[object Object]"}function Jw(d){return Array.isArray(d)}function lG(d){return new Promise(e=>{setTimeout(e,d)})}function Mq(d){lG(0).then(d)}function ele(){if(typeof AbortController=="function")return new AbortController}function GM(d,e,t){return t.isDataEqual!=null&&t.isDataEqual(d,e)?d:typeof t.structuralSharing=="function"?t.structuralSharing(d,e):t.structuralSharing!==!1?hG(d,e):e}class tle extends bf{constructor(){super(),this.setup=e=>{if(!K0&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),window.addEventListener("focus",t,!1),()=>{window.removeEventListener("visibilitychange",t),window.removeEventListener("focus",t)}}}}onSubscribe(){this.cleanup||this.setEventListener(this.setup)}onUnsubscribe(){if(!this.hasListeners()){var e;(e=this.cleanup)==null||e.call(this),this.cleanup=void 0}}setEventListener(e){var t;this.setup=e,(t=this.cleanup)==null||t.call(this),this.cleanup=e(s=>{typeof s=="boolean"?this.setFocused(s):this.onFocus()})}setFocused(e){this.focused!==e&&(this.focused=e,this.onFocus())}onFocus(){this.listeners.forEach(({listener:e})=>{e()})}isFocused(){return typeof this.focused=="boolean"?this.focused:typeof document>"u"?!0:[void 0,"visible","prerender"].includes(document.visibilityState)}}const lv=new tle,_q=["online","offline"];class sle extends bf{constructor(){super(),this.setup=e=>{if(!K0&&window.addEventListener){const t=()=>e();return _q.forEach(s=>{window.addEventListener(s,t,!1)}),()=>{_q.forEach(s=>{window.removeEventListener(s,t)})}}}}onSubscribe(){this.cleanup||this.setEventListener(this.setup)}onUnsubscribe(){if(!this.hasListeners()){var e;(e=this.cleanup)==null||e.call(this),this.cleanup=void 0}}setEventListener(e){var t;this.setup=e,(t=this.cleanup)==null||t.call(this),this.cleanup=e(s=>{typeof s=="boolean"?this.setOnline(s):this.onOnline()})}setOnline(e){this.online!==e&&(this.online=e,this.onOnline())}onOnline(){this.listeners.forEach(({listener:e})=>{e()})}isOnline(){return typeof this.online=="boolean"?this.online:typeof navigator>"u"||typeof navigator.onLine>"u"?!0:navigator.onLine}}const fv=new sle;function ile(d){return Math.min(1e3*2**d,3e4)}function iO(d){return(d??"online")==="online"?fv.isOnline():!0}class fG{constructor(e){this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}}function o1(d){return d instanceof fG}function pG(d){let e=!1,t=0,s=!1,i,n,r;const a=new Promise((g,y)=>{n=g,r=y}),o=g=>{s||(f(new fG(g)),d.abort==null||d.abort())},c=()=>{e=!0},u=()=>{e=!1},h=()=>!lv.isFocused()||d.networkMode!=="always"&&!fv.isOnline(),l=g=>{s||(s=!0,d.onSuccess==null||d.onSuccess(g),i==null||i(),n(g))},f=g=>{s||(s=!0,d.onError==null||d.onError(g),i==null||i(),r(g))},p=()=>new Promise(g=>{i=y=>{const w=s||!h();return w&&g(y),w},d.onPause==null||d.onPause()}).then(()=>{i=void 0,s||d.onContinue==null||d.onContinue()}),m=()=>{if(s)return;let g;try{g=d.fn()}catch(y){g=Promise.reject(y)}Promise.resolve(g).then(l).catch(y=>{var w,b;if(s)return;const S=(w=d.retry)!=null?w:3,v=(b=d.retryDelay)!=null?b:ile,C=typeof v=="function"?v(t,y):v,M=S===!0||typeof S=="number"&&t{if(h())return p()}).then(()=>{e?f(y):m()})})};return iO(d.networkMode)?m():p().then(m),{promise:a,cancel:o,continue:()=>(i==null?void 0:i())?a:Promise.resolve(),cancelRetry:c,continueRetry:u}}const LA=console;function nle(){let d=[],e=0,t=u=>{u()},s=u=>{u()};const i=u=>{let h;e++;try{h=u()}finally{e--,e||a()}return h},n=u=>{e?d.push(u):Mq(()=>{t(u)})},r=u=>(...h)=>{n(()=>{u(...h)})},a=()=>{const u=d;d=[],u.length&&Mq(()=>{s(()=>{u.forEach(h=>{t(h)})})})};return{batch:i,batchCalls:r,schedule:n,setNotifyFunction:u=>{t=u},setBatchNotifyFunction:u=>{s=u}}}const hi=nle();class mG{destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),FM(this.cacheTime)&&(this.gcTimeout=setTimeout(()=>{this.optionalRemove()},this.cacheTime))}updateCacheTime(e){this.cacheTime=Math.max(this.cacheTime||0,e??(K0?1/0:5*60*1e3))}clearGcTimeout(){this.gcTimeout&&(clearTimeout(this.gcTimeout),this.gcTimeout=void 0)}}class rle extends mG{constructor(e){super(),this.abortSignalConsumed=!1,this.defaultOptions=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.cache=e.cache,this.logger=e.logger||LA,this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.initialState=e.state||ale(this.options),this.state=this.initialState,this.scheduleGc()}get meta(){return this.options.meta}setOptions(e){this.options={...this.defaultOptions,...e},this.updateCacheTime(this.options.cacheTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.cache.remove(this)}setData(e,t){const s=GM(this.state.data,e,this.options);return this.dispatch({data:s,type:"success",dataUpdatedAt:t==null?void 0:t.updatedAt,manual:t==null?void 0:t.manual}),s}setState(e,t){this.dispatch({type:"setState",state:e,setStateOptions:t})}cancel(e){var t;const s=this.promise;return(t=this.retryer)==null||t.cancel(e),s?s.then($a).catch($a):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.initialState)}isActive(){return this.observers.some(e=>e.options.enabled!==!1)}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated||!this.state.dataUpdatedAt||this.observers.some(e=>e.getCurrentResult().isStale)}isStaleByTime(e=0){return this.state.isInvalidated||!this.state.dataUpdatedAt||!cG(this.state.dataUpdatedAt,e)}onFocus(){var e;const t=this.observers.find(s=>s.shouldFetchOnWindowFocus());t&&t.refetch({cancelRefetch:!1}),(e=this.retryer)==null||e.continue()}onOnline(){var e;const t=this.observers.find(s=>s.shouldFetchOnReconnect());t&&t.refetch({cancelRefetch:!1}),(e=this.retryer)==null||e.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.cache.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.retryer&&(this.abortSignalConsumed?this.retryer.cancel({revert:!0}):this.retryer.cancelRetry()),this.scheduleGc()),this.cache.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.dispatch({type:"invalidate"})}fetch(e,t){var s,i;if(this.state.fetchStatus!=="idle"){if(this.state.dataUpdatedAt&&t!=null&&t.cancelRefetch)this.cancel({silent:!0});else if(this.promise){var n;return(n=this.retryer)==null||n.continueRetry(),this.promise}}if(e&&this.setOptions(e),!this.options.queryFn){const f=this.observers.find(p=>p.options.queryFn);f&&this.setOptions(f.options)}const r=ele(),a={queryKey:this.queryKey,pageParam:void 0,meta:this.meta},o=f=>{Object.defineProperty(f,"signal",{enumerable:!0,get:()=>{if(r)return this.abortSignalConsumed=!0,r.signal}})};o(a);const c=()=>this.options.queryFn?(this.abortSignalConsumed=!1,this.options.queryFn(a)):Promise.reject("Missing queryFn for queryKey '"+this.options.queryHash+"'"),u={fetchOptions:t,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:c};if(o(u),(s=this.options.behavior)==null||s.onFetch(u),this.revertState=this.state,this.state.fetchStatus==="idle"||this.state.fetchMeta!==((i=u.fetchOptions)==null?void 0:i.meta)){var h;this.dispatch({type:"fetch",meta:(h=u.fetchOptions)==null?void 0:h.meta})}const l=f=>{if(o1(f)&&f.silent||this.dispatch({type:"error",error:f}),!o1(f)){var p,m,g,y;(p=(m=this.cache.config).onError)==null||p.call(m,f,this),(g=(y=this.cache.config).onSettled)==null||g.call(y,this.state.data,f,this)}this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return this.retryer=pG({fn:u.fetchFn,abort:r==null?void 0:r.abort.bind(r),onSuccess:f=>{var p,m,g,y;if(typeof f>"u"){l(new Error(this.queryHash+" data is undefined"));return}this.setData(f),(p=(m=this.cache.config).onSuccess)==null||p.call(m,f,this),(g=(y=this.cache.config).onSettled)==null||g.call(y,f,this.state.error,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1},onError:l,onFail:(f,p)=>{this.dispatch({type:"failed",failureCount:f,error:p})},onPause:()=>{this.dispatch({type:"pause"})},onContinue:()=>{this.dispatch({type:"continue"})},retry:u.options.retry,retryDelay:u.options.retryDelay,networkMode:u.options.networkMode}),this.promise=this.retryer.promise,this.promise}dispatch(e){const t=s=>{var i,n;switch(e.type){case"failed":return{...s,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...s,fetchStatus:"paused"};case"continue":return{...s,fetchStatus:"fetching"};case"fetch":return{...s,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:(i=e.meta)!=null?i:null,fetchStatus:iO(this.options.networkMode)?"fetching":"paused",...!s.dataUpdatedAt&&{error:null,status:"loading"}};case"success":return{...s,data:e.data,dataUpdateCount:s.dataUpdateCount+1,dataUpdatedAt:(n=e.dataUpdatedAt)!=null?n:Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const r=e.error;return o1(r)&&r.revert&&this.revertState?{...this.revertState,fetchStatus:"idle"}:{...s,error:r,errorUpdateCount:s.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:s.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:"idle",status:"error"};case"invalidate":return{...s,isInvalidated:!0};case"setState":return{...s,...e.state}}};this.state=t(this.state),hi.batch(()=>{this.observers.forEach(s=>{s.onQueryUpdate(e)}),this.cache.notify({query:this,type:"updated",action:e})})}}function ale(d){const e=typeof d.initialData=="function"?d.initialData():d.initialData,t=typeof e<"u",s=t?typeof d.initialDataUpdatedAt=="function"?d.initialDataUpdatedAt():d.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:t?s??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:t?"success":"loading",fetchStatus:"idle"}}class gG extends bf{constructor(e){super(),this.config=e||{},this.queries=[],this.queriesMap={}}build(e,t,s){var i;const n=t.queryKey,r=(i=t.queryHash)!=null?i:AA(n,t);let a=this.get(r);return a||(a=new rle({cache:this,logger:e.getLogger(),queryKey:n,queryHash:r,options:e.defaultQueryOptions(t),state:s,defaultOptions:e.getQueryDefaults(n)}),this.add(a)),a}add(e){this.queriesMap[e.queryHash]||(this.queriesMap[e.queryHash]=e,this.queries.push(e),this.notify({type:"added",query:e}))}remove(e){const t=this.queriesMap[e.queryHash];t&&(e.destroy(),this.queries=this.queries.filter(s=>s!==e),t===e&&delete this.queriesMap[e.queryHash],this.notify({type:"removed",query:e}))}clear(){hi.batch(()=>{this.queries.forEach(e=>{this.remove(e)})})}get(e){return this.queriesMap[e]}getAll(){return this.queries}find(e,t){const[s]=Eu(e,t);return typeof s.exact>"u"&&(s.exact=!0),this.queries.find(i=>xq(s,i))}findAll(e,t){const[s]=Eu(e,t);return Object.keys(s).length>0?this.queries.filter(i=>xq(s,i)):this.queries}notify(e){hi.batch(()=>{this.listeners.forEach(({listener:t})=>{t(e)})})}onFocus(){hi.batch(()=>{this.queries.forEach(e=>{e.onFocus()})})}onOnline(){hi.batch(()=>{this.queries.forEach(e=>{e.onOnline()})})}}class ole extends mG{constructor(e){super(),this.defaultOptions=e.defaultOptions,this.mutationId=e.mutationId,this.mutationCache=e.mutationCache,this.logger=e.logger||LA,this.observers=[],this.state=e.state||yG(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options={...this.defaultOptions,...e},this.updateCacheTime(this.options.cacheTime)}get meta(){return this.options.meta}setState(e){this.dispatch({type:"setState",state:e})}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.mutationCache.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.observers=this.observers.filter(t=>t!==e),this.scheduleGc(),this.mutationCache.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.observers.length||(this.state.status==="loading"?this.scheduleGc():this.mutationCache.remove(this))}continue(){var e,t;return(e=(t=this.retryer)==null?void 0:t.continue())!=null?e:this.execute()}async execute(){const e=()=>{var M;return this.retryer=pG({fn:()=>this.options.mutationFn?this.options.mutationFn(this.state.variables):Promise.reject("No mutationFn found"),onFail:(_,N)=>{this.dispatch({type:"failed",failureCount:_,error:N})},onPause:()=>{this.dispatch({type:"pause"})},onContinue:()=>{this.dispatch({type:"continue"})},retry:(M=this.options.retry)!=null?M:0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode}),this.retryer.promise},t=this.state.status==="loading";try{var s,i,n,r,a,o,c,u;if(!t){var h,l,f,p;this.dispatch({type:"loading",variables:this.options.variables}),await((h=(l=this.mutationCache.config).onMutate)==null?void 0:h.call(l,this.state.variables,this));const _=await((f=(p=this.options).onMutate)==null?void 0:f.call(p,this.state.variables));_!==this.state.context&&this.dispatch({type:"loading",context:_,variables:this.state.variables})}const M=await e();return await((s=(i=this.mutationCache.config).onSuccess)==null?void 0:s.call(i,M,this.state.variables,this.state.context,this)),await((n=(r=this.options).onSuccess)==null?void 0:n.call(r,M,this.state.variables,this.state.context)),await((a=(o=this.mutationCache.config).onSettled)==null?void 0:a.call(o,M,null,this.state.variables,this.state.context,this)),await((c=(u=this.options).onSettled)==null?void 0:c.call(u,M,null,this.state.variables,this.state.context)),this.dispatch({type:"success",data:M}),M}catch(M){try{var m,g,y,w,b,S,v,C;throw await((m=(g=this.mutationCache.config).onError)==null?void 0:m.call(g,M,this.state.variables,this.state.context,this)),await((y=(w=this.options).onError)==null?void 0:y.call(w,M,this.state.variables,this.state.context)),await((b=(S=this.mutationCache.config).onSettled)==null?void 0:b.call(S,void 0,M,this.state.variables,this.state.context,this)),await((v=(C=this.options).onSettled)==null?void 0:v.call(C,void 0,M,this.state.variables,this.state.context)),M}finally{this.dispatch({type:"error",error:M})}}}dispatch(e){const t=s=>{switch(e.type){case"failed":return{...s,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...s,isPaused:!0};case"continue":return{...s,isPaused:!1};case"loading":return{...s,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:!iO(this.options.networkMode),status:"loading",variables:e.variables};case"success":return{...s,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...s,data:void 0,error:e.error,failureCount:s.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"};case"setState":return{...s,...e.state}}};this.state=t(this.state),hi.batch(()=>{this.observers.forEach(s=>{s.onMutationUpdate(e)}),this.mutationCache.notify({mutation:this,type:"updated",action:e})})}}function yG(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0}}class wG extends bf{constructor(e){super(),this.config=e||{},this.mutations=[],this.mutationId=0}build(e,t,s){const i=new ole({mutationCache:this,logger:e.getLogger(),mutationId:++this.mutationId,options:e.defaultMutationOptions(t),state:s,defaultOptions:t.mutationKey?e.getMutationDefaults(t.mutationKey):void 0});return this.add(i),i}add(e){this.mutations.push(e),this.notify({type:"added",mutation:e})}remove(e){this.mutations=this.mutations.filter(t=>t!==e),this.notify({type:"removed",mutation:e})}clear(){hi.batch(()=>{this.mutations.forEach(e=>{this.remove(e)})})}getAll(){return this.mutations}find(e){return typeof e.exact>"u"&&(e.exact=!0),this.mutations.find(t=>Pq(e,t))}findAll(e){return this.mutations.filter(t=>Pq(e,t))}notify(e){hi.batch(()=>{this.listeners.forEach(({listener:t})=>{t(e)})})}resumePausedMutations(){var e;return this.resuming=((e=this.resuming)!=null?e:Promise.resolve()).then(()=>{const t=this.mutations.filter(s=>s.state.isPaused);return hi.batch(()=>t.reduce((s,i)=>s.then(()=>i.continue().catch($a)),Promise.resolve()))}).then(()=>{this.resuming=void 0}),this.resuming}}function UM(){return{onFetch:d=>{d.fetchFn=()=>{var e,t,s,i,n,r;const a=(e=d.fetchOptions)==null||(t=e.meta)==null?void 0:t.refetchPage,o=(s=d.fetchOptions)==null||(i=s.meta)==null?void 0:i.fetchMore,c=o==null?void 0:o.pageParam,u=(o==null?void 0:o.direction)==="forward",h=(o==null?void 0:o.direction)==="backward",l=((n=d.state.data)==null?void 0:n.pages)||[],f=((r=d.state.data)==null?void 0:r.pageParams)||[];let p=f,m=!1;const g=C=>{Object.defineProperty(C,"signal",{enumerable:!0,get:()=>{var M;if((M=d.signal)!=null&&M.aborted)m=!0;else{var _;(_=d.signal)==null||_.addEventListener("abort",()=>{m=!0})}return d.signal}})},y=d.options.queryFn||(()=>Promise.reject("Missing queryFn for queryKey '"+d.options.queryHash+"'")),w=(C,M,_,N)=>(p=N?[M,...p]:[...p,M],N?[_,...C]:[...C,_]),b=(C,M,_,N)=>{if(m)return Promise.reject("Cancelled");if(typeof _>"u"&&!M&&C.length)return Promise.resolve(C);const A={queryKey:d.queryKey,pageParam:_,meta:d.options.meta};g(A);const R=y(A);return Promise.resolve(R).then(U=>w(C,_,U,N))};let S;if(!l.length)S=b([]);else if(u){const C=typeof c<"u",M=C?c:WM(d.options,l);S=b(l,C,M)}else if(h){const C=typeof c<"u",M=C?c:bG(d.options,l);S=b(l,C,M,!0)}else{p=[];const C=typeof d.options.getNextPageParam>"u";S=(a&&l[0]?a(l[0],0,l):!0)?b([],C,f[0]):Promise.resolve(w([],f[0],l[0]));for(let _=1;_{if(a&&l[_]?a(l[_],_,l):!0){const R=C?f[_]:WM(d.options,N);return b(N,C,R)}return Promise.resolve(w(N,f[_],l[_]))})}return S.then(C=>({pages:C,pageParams:p}))}}}}function WM(d,e){return d.getNextPageParam==null?void 0:d.getNextPageParam(e[e.length-1],e)}function bG(d,e){return d.getPreviousPageParam==null?void 0:d.getPreviousPageParam(e[0],e)}function dle(d,e){if(d.getNextPageParam&&Array.isArray(e)){const t=WM(d,e);return typeof t<"u"&&t!==null&&t!==!1}}function cle(d,e){if(d.getPreviousPageParam&&Array.isArray(e)){const t=bG(d,e);return typeof t<"u"&&t!==null&&t!==!1}}class ule{constructor(e={}){this.queryCache=e.queryCache||new gG,this.mutationCache=e.mutationCache||new wG,this.logger=e.logger||LA,this.defaultOptions=e.defaultOptions||{},this.queryDefaults=[],this.mutationDefaults=[],this.mountCount=0}mount(){this.mountCount++,this.mountCount===1&&(this.unsubscribeFocus=lv.subscribe(()=>{lv.isFocused()&&(this.resumePausedMutations(),this.queryCache.onFocus())}),this.unsubscribeOnline=fv.subscribe(()=>{fv.isOnline()&&(this.resumePausedMutations(),this.queryCache.onOnline())}))}unmount(){var e,t;this.mountCount--,this.mountCount===0&&((e=this.unsubscribeFocus)==null||e.call(this),this.unsubscribeFocus=void 0,(t=this.unsubscribeOnline)==null||t.call(this),this.unsubscribeOnline=void 0)}isFetching(e,t){const[s]=Eu(e,t);return s.fetchStatus="fetching",this.queryCache.findAll(s).length}isMutating(e){return this.mutationCache.findAll({...e,fetching:!0}).length}getQueryData(e,t){var s;return(s=this.queryCache.find(e,t))==null?void 0:s.state.data}ensureQueryData(e,t,s){const i=Ep(e,t,s),n=this.getQueryData(i.queryKey);return n?Promise.resolve(n):this.fetchQuery(i)}getQueriesData(e){return this.getQueryCache().findAll(e).map(({queryKey:t,state:s})=>{const i=s.data;return[t,i]})}setQueryData(e,t,s){const i=this.queryCache.find(e),n=i==null?void 0:i.state.data,r=Yhe(t,n);if(typeof r>"u")return;const a=Ep(e),o=this.defaultQueryOptions(a);return this.queryCache.build(this,o).setData(r,{...s,manual:!0})}setQueriesData(e,t,s){return hi.batch(()=>this.getQueryCache().findAll(e).map(({queryKey:i})=>[i,this.setQueryData(i,t,s)]))}getQueryState(e,t){var s;return(s=this.queryCache.find(e,t))==null?void 0:s.state}removeQueries(e,t){const[s]=Eu(e,t),i=this.queryCache;hi.batch(()=>{i.findAll(s).forEach(n=>{i.remove(n)})})}resetQueries(e,t,s){const[i,n]=Eu(e,t,s),r=this.queryCache,a={type:"active",...i};return hi.batch(()=>(r.findAll(i).forEach(o=>{o.reset()}),this.refetchQueries(a,n)))}cancelQueries(e,t,s){const[i,n={}]=Eu(e,t,s);typeof n.revert>"u"&&(n.revert=!0);const r=hi.batch(()=>this.queryCache.findAll(i).map(a=>a.cancel(n)));return Promise.all(r).then($a).catch($a)}invalidateQueries(e,t,s){const[i,n]=Eu(e,t,s);return hi.batch(()=>{var r,a;if(this.queryCache.findAll(i).forEach(c=>{c.invalidate()}),i.refetchType==="none")return Promise.resolve();const o={...i,type:(r=(a=i.refetchType)!=null?a:i.type)!=null?r:"active"};return this.refetchQueries(o,n)})}refetchQueries(e,t,s){const[i,n]=Eu(e,t,s),r=hi.batch(()=>this.queryCache.findAll(i).filter(o=>!o.isDisabled()).map(o=>{var c;return o.fetch(void 0,{...n,cancelRefetch:(c=n==null?void 0:n.cancelRefetch)!=null?c:!0,meta:{refetchPage:i.refetchPage}})}));let a=Promise.all(r).then($a);return n!=null&&n.throwOnError||(a=a.catch($a)),a}fetchQuery(e,t,s){const i=Ep(e,t,s),n=this.defaultQueryOptions(i);typeof n.retry>"u"&&(n.retry=!1);const r=this.queryCache.build(this,n);return r.isStaleByTime(n.staleTime)?r.fetch(n):Promise.resolve(r.state.data)}prefetchQuery(e,t,s){return this.fetchQuery(e,t,s).then($a).catch($a)}fetchInfiniteQuery(e,t,s){const i=Ep(e,t,s);return i.behavior=UM(),this.fetchQuery(i)}prefetchInfiniteQuery(e,t,s){return this.fetchInfiniteQuery(e,t,s).then($a).catch($a)}resumePausedMutations(){return this.mutationCache.resumePausedMutations()}getQueryCache(){return this.queryCache}getMutationCache(){return this.mutationCache}getLogger(){return this.logger}getDefaultOptions(){return this.defaultOptions}setDefaultOptions(e){this.defaultOptions=e}setQueryDefaults(e,t){const s=this.queryDefaults.find(i=>Qu(e)===Qu(i.queryKey));s?s.defaultOptions=t:this.queryDefaults.push({queryKey:e,defaultOptions:t})}getQueryDefaults(e){if(!e)return;const t=this.queryDefaults.find(s=>uv(e,s.queryKey));return t==null?void 0:t.defaultOptions}setMutationDefaults(e,t){const s=this.mutationDefaults.find(i=>Qu(e)===Qu(i.mutationKey));s?s.defaultOptions=t:this.mutationDefaults.push({mutationKey:e,defaultOptions:t})}getMutationDefaults(e){if(!e)return;const t=this.mutationDefaults.find(s=>uv(e,s.mutationKey));return t==null?void 0:t.defaultOptions}defaultQueryOptions(e){if(e!=null&&e._defaulted)return e;const t={...this.defaultOptions.queries,...this.getQueryDefaults(e==null?void 0:e.queryKey),...e,_defaulted:!0};return!t.queryHash&&t.queryKey&&(t.queryHash=AA(t.queryKey,t)),typeof t.refetchOnReconnect>"u"&&(t.refetchOnReconnect=t.networkMode!=="always"),typeof t.useErrorBoundary>"u"&&(t.useErrorBoundary=!!t.suspense),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...this.defaultOptions.mutations,...this.getMutationDefaults(e==null?void 0:e.mutationKey),...e,_defaulted:!0}}clear(){this.queryCache.clear(),this.mutationCache.clear()}}class BA extends bf{constructor(e,t){super(),this.client=e,this.options=t,this.trackedProps=new Set,this.selectError=null,this.bindMethods(),this.setOptions(t)}bindMethods(){this.remove=this.remove.bind(this),this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.currentQuery.addObserver(this),Aq(this.currentQuery,this.options)&&this.executeFetch(),this.updateTimers())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return jM(this.currentQuery,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return jM(this.currentQuery,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.clearStaleTimeout(),this.clearRefetchInterval(),this.currentQuery.removeObserver(this)}setOptions(e,t){const s=this.options,i=this.currentQuery;if(this.options=this.client.defaultQueryOptions(e),hv(s,this.options)||this.client.getQueryCache().notify({type:"observerOptionsUpdated",query:this.currentQuery,observer:this}),typeof this.options.enabled<"u"&&typeof this.options.enabled!="boolean")throw new Error("Expected enabled to be a boolean");this.options.queryKey||(this.options.queryKey=s.queryKey),this.updateQuery();const n=this.hasListeners();n&&Lq(this.currentQuery,i,this.options,s)&&this.executeFetch(),this.updateResult(t),n&&(this.currentQuery!==i||this.options.enabled!==s.enabled||this.options.staleTime!==s.staleTime)&&this.updateStaleTimeout();const r=this.computeRefetchInterval();n&&(this.currentQuery!==i||this.options.enabled!==s.enabled||r!==this.currentRefetchInterval)&&this.updateRefetchInterval(r)}getOptimisticResult(e){const t=this.client.getQueryCache().build(this.client,e),s=this.createResult(t,e);return lle(this,s,e)&&(this.currentResult=s,this.currentResultOptions=this.options,this.currentResultState=this.currentQuery.state),s}getCurrentResult(){return this.currentResult}trackResult(e){const t={};return Object.keys(e).forEach(s=>{Object.defineProperty(t,s,{configurable:!1,enumerable:!0,get:()=>(this.trackedProps.add(s),e[s])})}),t}getCurrentQuery(){return this.currentQuery}remove(){this.client.getQueryCache().remove(this.currentQuery)}refetch({refetchPage:e,...t}={}){return this.fetch({...t,meta:{refetchPage:e}})}fetchOptimistic(e){const t=this.client.defaultQueryOptions(e),s=this.client.getQueryCache().build(this.client,t);return s.isFetchingOptimistic=!0,s.fetch().then(()=>this.createResult(s,t))}fetch(e){var t;return this.executeFetch({...e,cancelRefetch:(t=e.cancelRefetch)!=null?t:!0}).then(()=>(this.updateResult(),this.currentResult))}executeFetch(e){this.updateQuery();let t=this.currentQuery.fetch(this.options,e);return e!=null&&e.throwOnError||(t=t.catch($a)),t}updateStaleTimeout(){if(this.clearStaleTimeout(),K0||this.currentResult.isStale||!FM(this.options.staleTime))return;const t=cG(this.currentResult.dataUpdatedAt,this.options.staleTime)+1;this.staleTimeoutId=setTimeout(()=>{this.currentResult.isStale||this.updateResult()},t)}computeRefetchInterval(){var e;return typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.currentResult.data,this.currentQuery):(e=this.options.refetchInterval)!=null?e:!1}updateRefetchInterval(e){this.clearRefetchInterval(),this.currentRefetchInterval=e,!(K0||this.options.enabled===!1||!FM(this.currentRefetchInterval)||this.currentRefetchInterval===0)&&(this.refetchIntervalId=setInterval(()=>{(this.options.refetchIntervalInBackground||lv.isFocused())&&this.executeFetch()},this.currentRefetchInterval))}updateTimers(){this.updateStaleTimeout(),this.updateRefetchInterval(this.computeRefetchInterval())}clearStaleTimeout(){this.staleTimeoutId&&(clearTimeout(this.staleTimeoutId),this.staleTimeoutId=void 0)}clearRefetchInterval(){this.refetchIntervalId&&(clearInterval(this.refetchIntervalId),this.refetchIntervalId=void 0)}createResult(e,t){const s=this.currentQuery,i=this.options,n=this.currentResult,r=this.currentResultState,a=this.currentResultOptions,o=e!==s,c=o?e.state:this.currentQueryInitialState,u=o?this.currentResult:this.previousQueryResult,{state:h}=e;let{dataUpdatedAt:l,error:f,errorUpdatedAt:p,fetchStatus:m,status:g}=h,y=!1,w=!1,b;if(t._optimisticResults){const _=this.hasListeners(),N=!_&&Aq(e,t),A=_&&Lq(e,s,t,i);(N||A)&&(m=iO(e.options.networkMode)?"fetching":"paused",l||(g="loading")),t._optimisticResults==="isRestoring"&&(m="idle")}if(t.keepPreviousData&&!h.dataUpdatedAt&&u!=null&&u.isSuccess&&g!=="error")b=u.data,l=u.dataUpdatedAt,g=u.status,y=!0;else if(t.select&&typeof h.data<"u")if(n&&h.data===(r==null?void 0:r.data)&&t.select===this.selectFn)b=this.selectResult;else try{this.selectFn=t.select,b=t.select(h.data),b=GM(n==null?void 0:n.data,b,t),this.selectResult=b,this.selectError=null}catch(_){this.selectError=_}else b=h.data;if(typeof t.placeholderData<"u"&&typeof b>"u"&&g==="loading"){let _;if(n!=null&&n.isPlaceholderData&&t.placeholderData===(a==null?void 0:a.placeholderData))_=n.data;else if(_=typeof t.placeholderData=="function"?t.placeholderData():t.placeholderData,t.select&&typeof _<"u")try{_=t.select(_),this.selectError=null}catch(N){this.selectError=N}typeof _<"u"&&(g="success",b=GM(n==null?void 0:n.data,_,t),w=!0)}this.selectError&&(f=this.selectError,b=this.selectResult,p=Date.now(),g="error");const S=m==="fetching",v=g==="loading",C=g==="error";return{status:g,fetchStatus:m,isLoading:v,isSuccess:g==="success",isError:C,isInitialLoading:v&&S,data:b,dataUpdatedAt:l,error:f,errorUpdatedAt:p,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:h.dataUpdateCount>0||h.errorUpdateCount>0,isFetchedAfterMount:h.dataUpdateCount>c.dataUpdateCount||h.errorUpdateCount>c.errorUpdateCount,isFetching:S,isRefetching:S&&!v,isLoadingError:C&&h.dataUpdatedAt===0,isPaused:m==="paused",isPlaceholderData:w,isPreviousData:y,isRefetchError:C&&h.dataUpdatedAt!==0,isStale:NA(e,t),refetch:this.refetch,remove:this.remove}}updateResult(e){const t=this.currentResult,s=this.createResult(this.currentQuery,this.options);if(this.currentResultState=this.currentQuery.state,this.currentResultOptions=this.options,hv(s,t))return;this.currentResult=s;const i={cache:!0},n=()=>{if(!t)return!0;const{notifyOnChangeProps:r}=this.options,a=typeof r=="function"?r():r;if(a==="all"||!a&&!this.trackedProps.size)return!0;const o=new Set(a??this.trackedProps);return this.options.useErrorBoundary&&o.add("error"),Object.keys(this.currentResult).some(c=>{const u=c;return this.currentResult[u]!==t[u]&&o.has(u)})};(e==null?void 0:e.listeners)!==!1&&n()&&(i.listeners=!0),this.notify({...i,...e})}updateQuery(){const e=this.client.getQueryCache().build(this.client,this.options);if(e===this.currentQuery)return;const t=this.currentQuery;this.currentQuery=e,this.currentQueryInitialState=e.state,this.previousQueryResult=this.currentResult,this.hasListeners()&&(t==null||t.removeObserver(this),e.addObserver(this))}onQueryUpdate(e){const t={};e.type==="success"?t.onSuccess=!e.manual:e.type==="error"&&!o1(e.error)&&(t.onError=!0),this.updateResult(t),this.hasListeners()&&this.updateTimers()}notify(e){hi.batch(()=>{if(e.onSuccess){var t,s,i,n;(t=(s=this.options).onSuccess)==null||t.call(s,this.currentResult.data),(i=(n=this.options).onSettled)==null||i.call(n,this.currentResult.data,null)}else if(e.onError){var r,a,o,c;(r=(a=this.options).onError)==null||r.call(a,this.currentResult.error),(o=(c=this.options).onSettled)==null||o.call(c,void 0,this.currentResult.error)}e.listeners&&this.listeners.forEach(({listener:u})=>{u(this.currentResult)}),e.cache&&this.client.getQueryCache().notify({query:this.currentQuery,type:"observerResultsUpdated"})})}}function hle(d,e){return e.enabled!==!1&&!d.state.dataUpdatedAt&&!(d.state.status==="error"&&e.retryOnMount===!1)}function Aq(d,e){return hle(d,e)||d.state.dataUpdatedAt>0&&jM(d,e,e.refetchOnMount)}function jM(d,e,t){if(e.enabled!==!1){const s=typeof t=="function"?t(d):t;return s==="always"||s!==!1&&NA(d,e)}return!1}function Lq(d,e,t,s){return t.enabled!==!1&&(d!==e||s.enabled===!1)&&(!t.suspense||d.state.status!=="error")&&NA(d,t)}function NA(d,e){return d.isStaleByTime(e.staleTime)}function lle(d,e,t){return t.keepPreviousData?!1:t.placeholderData!==void 0?e.isPlaceholderData:!hv(d.getCurrentResult(),e)}class fle extends bf{constructor(e,t){super(),this.client=e,this.queries=[],this.result=[],this.observers=[],this.observersMap={},t&&this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.observers.forEach(e=>{e.subscribe(t=>{this.onUpdate(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.observers.forEach(e=>{e.destroy()})}setQueries(e,t){this.queries=e,hi.batch(()=>{const s=this.observers,i=this.findMatchingObservers(this.queries);i.forEach(c=>c.observer.setOptions(c.defaultedQueryOptions,t));const n=i.map(c=>c.observer),r=Object.fromEntries(n.map(c=>[c.options.queryHash,c])),a=n.map(c=>c.getCurrentResult()),o=n.some((c,u)=>c!==s[u]);s.length===n.length&&!o||(this.observers=n,this.observersMap=r,this.result=a,this.hasListeners()&&(Oq(s,n).forEach(c=>{c.destroy()}),Oq(n,s).forEach(c=>{c.subscribe(u=>{this.onUpdate(c,u)})}),this.notify()))})}getCurrentResult(){return this.result}getQueries(){return this.observers.map(e=>e.getCurrentQuery())}getObservers(){return this.observers}getOptimisticResult(e){return this.findMatchingObservers(e).map(t=>t.observer.getOptimisticResult(t.defaultedQueryOptions))}findMatchingObservers(e){const t=this.observers,s=new Map(t.map(f=>[f.options.queryHash,f])),i=e.map(f=>this.client.defaultQueryOptions(f)),n=i.flatMap(f=>{const p=s.get(f.queryHash);return p!=null?[{defaultedQueryOptions:f,observer:p}]:[]}),r=new Set(n.map(f=>f.defaultedQueryOptions.queryHash)),a=i.filter(f=>!r.has(f.queryHash)),o=new Set(n.map(f=>f.observer)),c=t.filter(f=>!o.has(f)),u=f=>{const p=this.client.defaultQueryOptions(f),m=this.observersMap[p.queryHash];return m??new BA(this.client,p)},h=a.map((f,p)=>{if(f.keepPreviousData){const m=c[p];if(m!==void 0)return{defaultedQueryOptions:f,observer:m}}return{defaultedQueryOptions:f,observer:u(f)}}),l=(f,p)=>i.indexOf(f.defaultedQueryOptions)-i.indexOf(p.defaultedQueryOptions);return n.concat(h).sort(l)}onUpdate(e,t){const s=this.observers.indexOf(e);s!==-1&&(this.result=Zhe(this.result,s,t),this.notify())}notify(){hi.batch(()=>{this.listeners.forEach(({listener:e})=>{e(this.result)})})}}class ple extends BA{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e,t){super.setOptions({...e,behavior:UM()},t)}getOptimisticResult(e){return e.behavior=UM(),super.getOptimisticResult(e)}fetchNextPage({pageParam:e,...t}={}){return this.fetch({...t,meta:{fetchMore:{direction:"forward",pageParam:e}}})}fetchPreviousPage({pageParam:e,...t}={}){return this.fetch({...t,meta:{fetchMore:{direction:"backward",pageParam:e}}})}createResult(e,t){var s,i,n,r,a,o;const{state:c}=e,u=super.createResult(e,t),{isFetching:h,isRefetching:l}=u,f=h&&((s=c.fetchMeta)==null||(i=s.fetchMore)==null?void 0:i.direction)==="forward",p=h&&((n=c.fetchMeta)==null||(r=n.fetchMore)==null?void 0:r.direction)==="backward";return{...u,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:dle(t,(a=c.data)==null?void 0:a.pages),hasPreviousPage:cle(t,(o=c.data)==null?void 0:o.pages),isFetchingNextPage:f,isFetchingPreviousPage:p,isRefetching:l&&!f&&!p}}}let mle=class extends bf{constructor(e,t){super(),this.client=e,this.setOptions(t),this.bindMethods(),this.updateResult()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){var t;const s=this.options;this.options=this.client.defaultMutationOptions(e),hv(s,this.options)||this.client.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.currentMutation,observer:this}),(t=this.currentMutation)==null||t.setOptions(this.options)}onUnsubscribe(){if(!this.hasListeners()){var e;(e=this.currentMutation)==null||e.removeObserver(this)}}onMutationUpdate(e){this.updateResult();const t={listeners:!0};e.type==="success"?t.onSuccess=!0:e.type==="error"&&(t.onError=!0),this.notify(t)}getCurrentResult(){return this.currentResult}reset(){this.currentMutation=void 0,this.updateResult(),this.notify({listeners:!0})}mutate(e,t){return this.mutateOptions=t,this.currentMutation&&this.currentMutation.removeObserver(this),this.currentMutation=this.client.getMutationCache().build(this.client,{...this.options,variables:typeof e<"u"?e:this.options.variables}),this.currentMutation.addObserver(this),this.currentMutation.execute()}updateResult(){const e=this.currentMutation?this.currentMutation.state:yG(),t={...e,isLoading:e.status==="loading",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset};this.currentResult=t}notify(e){hi.batch(()=>{if(this.mutateOptions&&this.hasListeners()){if(e.onSuccess){var t,s,i,n;(t=(s=this.mutateOptions).onSuccess)==null||t.call(s,this.currentResult.data,this.currentResult.variables,this.currentResult.context),(i=(n=this.mutateOptions).onSettled)==null||i.call(n,this.currentResult.data,null,this.currentResult.variables,this.currentResult.context)}else if(e.onError){var r,a,o,c;(r=(a=this.mutateOptions).onError)==null||r.call(a,this.currentResult.error,this.currentResult.variables,this.currentResult.context),(o=(c=this.mutateOptions).onSettled)==null||o.call(c,void 0,this.currentResult.error,this.currentResult.variables,this.currentResult.context)}}e.listeners&&this.listeners.forEach(({listener:u})=>{u(this.currentResult)})})}};const EA=vH.useSyncExternalStore,Bq=B.createContext(void 0),kG=B.createContext(!1);function SG(d,e){return d||(e&&typeof window<"u"?(window.ReactQueryClientContext||(window.ReactQueryClientContext=Bq),window.ReactQueryClientContext):Bq)}const nO=({context:d}={})=>{const e=B.useContext(SG(d,B.useContext(kG)));if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},gle=({client:d,children:e,context:t,contextSharing:s=!1})=>{B.useEffect(()=>(d.mount(),()=>{d.unmount()}),[d]);const i=SG(t,s);return B.createElement(kG.Provider,{value:!t&&s},B.createElement(i.Provider,{value:d},e))},vG=B.createContext(!1),TG=()=>B.useContext(vG);vG.Provider;function yle(){let d=!1;return{clearReset:()=>{d=!1},reset:()=>{d=!0},isReset:()=>d}}const wle=B.createContext(yle()),OG=()=>B.useContext(wle);function xG(d,e){return typeof d=="function"?d(...e):!!d}const PG=(d,e)=>{(d.suspense||d.useErrorBoundary)&&(e.isReset()||(d.retryOnMount=!1))},IG=d=>{B.useEffect(()=>{d.clearReset()},[d])},CG=({result:d,errorResetBoundary:e,useErrorBoundary:t,query:s})=>d.isError&&!e.isReset()&&!d.isFetching&&xG(t,[d.error,s]),MG=d=>{d.suspense&&typeof d.staleTime!="number"&&(d.staleTime=1e3)},_G=(d,e)=>d.isLoading&&d.isFetching&&!e,zM=(d,e,t)=>(d==null?void 0:d.suspense)&&_G(e,t),$M=(d,e,t)=>e.fetchOptimistic(d).then(({data:s})=>{d.onSuccess==null||d.onSuccess(s),d.onSettled==null||d.onSettled(s,null)}).catch(s=>{t.clearReset(),d.onError==null||d.onError(s),d.onSettled==null||d.onSettled(void 0,s)});function ble({queries:d,context:e}){const t=nO({context:e}),s=TG(),i=OG(),n=B.useMemo(()=>d.map(l=>{const f=t.defaultQueryOptions(l);return f._optimisticResults=s?"isRestoring":"optimistic",f}),[d,t,s]);n.forEach(l=>{MG(l),PG(l,i)}),IG(i);const[r]=B.useState(()=>new fle(t,n)),a=r.getOptimisticResult(n);EA(B.useCallback(l=>s?()=>{}:r.subscribe(hi.batchCalls(l)),[r,s]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),B.useEffect(()=>{r.setQueries(n,{listeners:!1})},[n,r]);const c=a.some((l,f)=>zM(n[f],l,s))?a.flatMap((l,f)=>{const p=n[f],m=r.getObservers()[f];if(p&&m){if(zM(p,l,s))return $M(p,m,i);_G(l,s)&&$M(p,m,i)}return[]}):[];if(c.length>0)throw Promise.all(c);const u=r.getQueries(),h=a.find((l,f)=>{var p,m;return CG({result:l,errorResetBoundary:i,useErrorBoundary:(p=(m=n[f])==null?void 0:m.useErrorBoundary)!=null?p:!1,query:u[f]})});if(h!=null&&h.error)throw h.error;return a}function AG(d,e){const t=nO({context:d.context}),s=TG(),i=OG(),n=t.defaultQueryOptions(d);n._optimisticResults=s?"isRestoring":"optimistic",n.onError&&(n.onError=hi.batchCalls(n.onError)),n.onSuccess&&(n.onSuccess=hi.batchCalls(n.onSuccess)),n.onSettled&&(n.onSettled=hi.batchCalls(n.onSettled)),MG(n),PG(n,i),IG(i);const[r]=B.useState(()=>new e(t,n)),a=r.getOptimisticResult(n);if(EA(B.useCallback(o=>{const c=s?()=>{}:r.subscribe(hi.batchCalls(o));return r.updateResult(),c},[r,s]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),B.useEffect(()=>{r.setOptions(n,{listeners:!1})},[n,r]),zM(n,a,s))throw $M(n,r,i);if(CG({result:a,errorResetBoundary:i,useErrorBoundary:n.useErrorBoundary,query:r.getCurrentQuery()}))throw a.error;return n.notifyOnChangeProps?a:r.trackResult(a)}function kle(d,e,t){const s=Ep(d,e,t);return AG(s,BA)}function Sle(d,e,t){const s=Jhe(d,e),i=nO({context:s.context}),[n]=B.useState(()=>new mle(i,s));B.useEffect(()=>{n.setOptions(s)},[n,s]);const r=EA(B.useCallback(o=>n.subscribe(hi.batchCalls(o)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),a=B.useCallback((o,c)=>{n.mutate(o,c).catch(vle)},[n]);if(r.error&&xG(n.options.useErrorBoundary,[r.error]))throw r.error;return{...r,mutate:a,mutateAsync:r.mutate}}function vle(){}function Tle(d,e,t){const s=Ep(d,e,t);return AG(s,ple)}function Ole(d){return d}function xle(d){return d.length===0?Ole:d.length===1?d[0]:function(t){return d.reduce((s,i)=>i(s),t)}}function LG(d){const e={subscribe(t){let s=null,i=!1,n=!1,r=!1;function a(){if(s===null){r=!0;return}n||(n=!0,typeof s=="function"?s():s&&s.unsubscribe())}return s=d({next(o){var c;i||(c=t.next)==null||c.call(t,o)},error(o){var c;i||(i=!0,(c=t.error)==null||c.call(t,o),a())},complete(){var o;i||(i=!0,(o=t.complete)==null||o.call(t),a())}}),r&&a(),{unsubscribe:a}},pipe(...t){return xle(t)(e)}};return e}function Ple(d){return e=>{let t=0,s=null;const i=[];function n(){s||(s=e.subscribe({next(a){var o;for(const c of i)(o=c.next)==null||o.call(c,a)},error(a){var o;for(const c of i)(o=c.error)==null||o.call(c,a)},complete(){var a;for(const o of i)(a=o.complete)==null||a.call(o)}}))}function r(){if(t===0&&s){const a=s;s=null,a.unsubscribe()}}return{subscribe(a){return t++,i.push(a),n(),{unsubscribe(){t--,r();const o=i.findIndex(c=>c===a);o>-1&&i.splice(o,1)}}}}}}class RA extends Error{constructor(e){super(e),this.name="ObservableAbortError",Object.setPrototypeOf(this,RA.prototype)}}function Ile(d){let e;return{promise:new Promise((s,i)=>{let n=!1;function r(){n||(n=!0,i(new RA("This operation was aborted.")),a.unsubscribe())}const a=d.subscribe({next(o){n=!0,s(o),r()},error(o){n=!0,i(o),r()},complete(){n=!0,r()}});e=r}),abort:e}}function Cle(d){return LG(e=>{function t(i=0,n=d.op){const r=d.links[i];if(!r)throw new Error("No more links to execute - did you forget to add an ending link?");return r({op:n,next(o){return t(i+1,o)}})}return t().subscribe(e)})}function BG(d){const e=Object.create(null);for(const t in d){const s=d[t];e[s]=t}return e}const rO={PARSE_ERROR:-32700,BAD_REQUEST:-32600,INTERNAL_SERVER_ERROR:-32603,NOT_IMPLEMENTED:-32603,UNAUTHORIZED:-32001,FORBIDDEN:-32003,NOT_FOUND:-32004,METHOD_NOT_SUPPORTED:-32005,TIMEOUT:-32008,CONFLICT:-32009,PRECONDITION_FAILED:-32012,PAYLOAD_TOO_LARGE:-32013,UNPROCESSABLE_CONTENT:-32022,TOO_MANY_REQUESTS:-32029,CLIENT_CLOSED_REQUEST:-32099};BG(rO);BG(rO);const NG=()=>{};function EG(d,e){return new Proxy(NG,{get(s,i){if(!(typeof i!="string"||i==="then"))return EG(d,[...e,i])},apply(s,i,n){const r=e[e.length-1]==="apply";return d({args:r?n.length>=2?n[1]:[]:n,path:r?e.slice(0,-1):e})}})}const aO=d=>EG(d,[]),DA=d=>new Proxy(NG,{get(e,t){if(!(typeof t!="string"||t==="then"))return d(t)}});function Mle(d){return!!d&&!Array.isArray(d)&&typeof d=="object"}class _le extends Error{}function Ale(d){if(d instanceof Error)return d;const e=typeof d;if(!(e==="undefined"||e==="function"||d===null)){if(e!=="object")return new Error(String(d));if(Mle(d)){const t=new _le;for(const s in d)t[s]=d[s];return t}}}function pv(d){return!!d&&!Array.isArray(d)&&typeof d=="object"}function Lle(d,e){if("error"in d){const s=e.transformer.deserialize(d.error);return{ok:!1,error:{...d,error:s}}}return{ok:!0,result:{...d.result,...(!d.result.type||d.result.type==="data")&&{type:"data",data:e.transformer.deserialize(d.result.data)}}}}class fI extends Error{constructor(){super("Unable to transform response from server")}}function Ble(d,e){let t;try{t=Lle(d,e)}catch{throw new fI}if(!t.ok&&(!pv(t.error.error)||typeof t.error.error.code!="number"))throw new fI;if(t.ok&&!pv(t.result))throw new fI;return t}function Nle(d){return d instanceof _d||d instanceof Error&&d.name==="TRPCClientError"}function Ele(d){return pv(d)&&pv(d.error)&&typeof d.error.code=="number"&&typeof d.error.message=="string"}class _d extends Error{static from(e,t={}){const s=e;return Nle(s)?(t.meta&&(s.meta={...s.meta,...t.meta}),s):Ele(s)?new _d(s.error.message,{...t,result:s}):s instanceof Error?new _d(s.message,{...t,cause:Ale(s)}):new _d("Unknown error",{...t,cause:s})}constructor(e,t){var i,n;const s=t==null?void 0:t.cause;super(e,{cause:s}),this.meta=t==null?void 0:t.meta,this.cause=s,this.shape=(i=t==null?void 0:t.result)==null?void 0:i.error,this.data=(n=t==null?void 0:t.result)==null?void 0:n.error.data,this.name="TRPCClientError",Object.setPrototypeOf(this,_d.prototype)}}const Nq=d=>typeof d=="function";function Rle(d){if(d)return d;if(typeof window<"u"&&Nq(window.fetch))return window.fetch;if(typeof globalThis<"u"&&Nq(globalThis.fetch))return globalThis.fetch;throw new Error("No fetch implementation found")}function Dle(d){return d||(typeof window<"u"&&window.AbortController?window.AbortController:typeof globalThis<"u"&&globalThis.AbortController?globalThis.AbortController:null)}function qle(d){return{url:d.url.toString().replace(/\/$/,""),fetch:d.fetch,AbortController:Dle(d.AbortController)}}function Vle(d){const e={};for(let t=0;td.runtime.transformer.serialize(e)))}const DG=d=>{let e=d.url+"/"+d.path;const t=[];if("inputs"in d&&t.push("batch=1"),d.type==="query"){const s=RG(d);s!==void 0&&t.push(`input=${encodeURIComponent(JSON.stringify(s))}`)}return t.length&&(e+="?"+t.join("&")),e},Hle=d=>{if(d.type==="query")return;const e=RG(d);return e!==void 0?JSON.stringify(e):void 0},Gle=d=>Wle({...d,contentTypeHeader:"application/json",getUrl:DG,getBody:Hle});async function Ule(d,e){const t=d.getUrl(d),s=d.getBody(d),{type:i}=d,n=await d.headers();/* istanbul ignore if -- @preserve */if(i==="subscription")throw new Error("Subscriptions should use wsLink");const r={...d.contentTypeHeader?{"content-type":d.contentTypeHeader}:{},...d.batchModeHeader?{"trpc-batch-mode":d.batchModeHeader}:{},...n};return Rle(d.fetch)(t,{method:Fle[i],signal:e==null?void 0:e.signal,body:s,headers:r})}function Wle(d){const e=d.AbortController?new d.AbortController:null,t={};let s=!1;return{promise:new Promise((r,a)=>{Ule(d,e).then(o=>(t.response=o,s=!0,o.json())).then(o=>{t.responseJSON=o,r({json:o,meta:t})}).catch(o=>{s=!0,a(_d.from(o,{meta:t}))})}),cancel:()=>{s||e==null||e.abort()}}}const pI=()=>{throw new Error("Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new")};function mI(d){let e=null,t=null;const s=()=>{clearTimeout(t),t=null,e=null};function i(a){var u,h;const o=[[]];let c=0;for(;;){const l=a[c];if(!l)break;const f=o[o.length-1];if(l.aborted){(u=l.reject)==null||u.call(l,new Error("Aborted")),c++;continue}if(d.validate(f.concat(l).map(m=>m.key))){f.push(l),c++;continue}if(f.length===0){(h=l.reject)==null||h.call(l,new Error("Input is too big for a single dispatch")),c++;continue}o.push([])}return o}function n(){const a=i(e);s();for(const o of a){if(!o.length)continue;const c={items:o,cancel:pI};for(const f of o)f.batch=c;const u=(f,p)=>{var g;const m=c.items[f];(g=m.resolve)==null||g.call(m,p),m.batch=null,m.reject=null,m.resolve=null},{promise:h,cancel:l}=d.fetch(c.items.map(f=>f.key),u);c.cancel=l,h.then(f=>{var p;for(let m=0;m{var p;for(const m of c.items)(p=m.reject)==null||p.call(m,f),m.batch=null})}}function r(a){const o={aborted:!1,key:a,batch:null,resolve:pI,reject:pI},c=new Promise((h,l)=>{o.reject=l,o.resolve=h,e||(e=[]),e.push(o)});return t||(t=setTimeout(n)),{promise:c,cancel:()=>{var h;o.aborted=!0,(h=o.batch)!=null&&h.items.every(l=>l.aborted)&&(o.batch.cancel(),o.batch=null)}}}return{load:r}}function jle(d){return function(t){const s=qle(t),i=t.maxURLLength??1/0;return n=>{const r=h=>{const l=p=>{if(i===1/0)return!0;const m=p.map(w=>w.path).join(","),g=p.map(w=>w.input);return DG({...s,runtime:n,type:h,path:m,inputs:g}).length<=i},f=d({...s,runtime:n,type:h,opts:t});return{validate:l,fetch:f}},a=mI(r("query")),o=mI(r("mutation")),c=mI(r("subscription")),u={query:a,subscription:c,mutation:o};return({op:h})=>LG(l=>{const f=u[h.type],{promise:p,cancel:m}=f.load(h);let g;return p.then(y=>{g=y;const w=Ble(y.json,n);if(!w.ok){l.error(_d.from(w.error,{meta:y.meta}));return}l.next({context:y.meta,result:w.result}),l.complete()}).catch(y=>{l.error(_d.from(y,{meta:g==null?void 0:g.meta}))}),()=>{m()}})}}}const zle=d=>e=>{const t=e.map(r=>r.path).join(","),s=e.map(r=>r.input),{promise:i,cancel:n}=Gle({...d,path:t,inputs:s,headers(){return d.opts.headers?typeof d.opts.headers=="function"?d.opts.headers({opList:e}):d.opts.headers:{}}});return{promise:i.then(r=>(Array.isArray(r.json)?r.json:e.map(()=>r.json)).map(c=>({meta:r.meta,json:c}))),cancel:n}},$le=jle(zle);class Kle{$request({type:e,input:t,path:s,context:i={}}){return Cle({links:this.links,op:{id:++this.requestId,type:e,path:s,input:t,context:i}}).pipe(Ple())}requestAsPromise(e){const t=this.$request(e),{promise:s,abort:i}=Ile(t);return new Promise((r,a)=>{var o;(o=e.signal)==null||o.addEventListener("abort",i),s.then(c=>{r(c.result.data)}).catch(c=>{a(_d.from(c))})})}query(e,t,s){return this.requestAsPromise({type:"query",path:e,input:t,context:s==null?void 0:s.context,signal:s==null?void 0:s.signal})}mutation(e,t,s){return this.requestAsPromise({type:"mutation",path:e,input:t,context:s==null?void 0:s.context,signal:s==null?void 0:s.signal})}subscription(e,t,s){return this.$request({type:"subscription",path:e,input:t,context:s==null?void 0:s.context}).subscribe({next(n){var r,a,o;n.result.type==="started"?(r=s.onStarted)==null||r.call(s):n.result.type==="stopped"?(a=s.onStopped)==null||a.call(s):(o=s.onData)==null||o.call(s,n.result.data)},error(n){var r;(r=s.onError)==null||r.call(s,n)},complete(){var n;(n=s.onComplete)==null||n.call(s)}})}constructor(e){this.requestId=0;const t=(()=>{const s=e.transformer;return s?"input"in s?e.transformer:{input:s,output:s}:{input:{serialize:i=>i,deserialize:i=>i},output:{serialize:i=>i,deserialize:i=>i}}})();this.runtime={transformer:{serialize:s=>t.input.serialize(s),deserialize:s=>t.output.deserialize(s)},combinedTransformer:t},this.links=e.links.map(s=>s(this.runtime))}}function Xle(d){return new Kle(d)}const Qle={query:"query",mutate:"mutation",subscribe:"subscription"},Yle=d=>Qle[d];function Zle(d){return DA(e=>d.hasOwnProperty(e)?d[e]:e==="__untypedClient"?d:aO(({path:t,args:s})=>{const i=[e,...t],n=Yle(i.pop()),r=i.join(".");return d[n](r,...s)}))}const KM="APP_URL",qA="ADMIN_PASSWORD",gI="DEVELOPER_MODE_ENABLED",Eq="http://localhost:8000";function Jle(){return localStorage.getItem(qA)}var Os;(function(d){d.assertEqual=i=>i;function e(i){}d.assertIs=e;function t(i){throw new Error}d.assertNever=t,d.arrayToEnum=i=>{const n={};for(const r of i)n[r]=r;return n},d.getValidEnumValues=i=>{const n=d.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),r={};for(const a of n)r[a]=i[a];return d.objectValues(r)},d.objectValues=i=>d.objectKeys(i).map(function(n){return i[n]}),d.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const n=[];for(const r in i)Object.prototype.hasOwnProperty.call(i,r)&&n.push(r);return n},d.find=(i,n)=>{for(const r of i)if(n(r))return r},d.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function s(i,n=" | "){return i.map(r=>typeof r=="string"?`'${r}'`:r).join(n)}d.joinValues=s,d.jsonStringifyReplacer=(i,n)=>typeof n=="bigint"?n.toString():n})(Os||(Os={}));var XM;(function(d){d.mergeShapes=(e,t)=>({...e,...t})})(XM||(XM={}));const vt=Os.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),wc=d=>{switch(typeof d){case"undefined":return vt.undefined;case"string":return vt.string;case"number":return isNaN(d)?vt.nan:vt.number;case"boolean":return vt.boolean;case"function":return vt.function;case"bigint":return vt.bigint;case"symbol":return vt.symbol;case"object":return Array.isArray(d)?vt.array:d===null?vt.null:d.then&&typeof d.then=="function"&&d.catch&&typeof d.catch=="function"?vt.promise:typeof Map<"u"&&d instanceof Map?vt.map:typeof Set<"u"&&d instanceof Set?vt.set:typeof Date<"u"&&d instanceof Date?vt.date:vt.object;default:return vt.unknown}},et=Os.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),efe=d=>JSON.stringify(d,null,2).replace(/"([^"]+)":/g,"$1:");class ka extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(n){return n.message},s={_errors:[]},i=n=>{for(const r of n.issues)if(r.code==="invalid_union")r.unionErrors.map(i);else if(r.code==="invalid_return_type")i(r.returnTypeError);else if(r.code==="invalid_arguments")i(r.argumentsError);else if(r.path.length===0)s._errors.push(t(r));else{let a=s,o=0;for(;ot.message){const t={},s=[];for(const i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):s.push(e(i));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}}ka.create=d=>new ka(d);const Am=(d,e)=>{let t;switch(d.code){case et.invalid_type:d.received===vt.undefined?t="Required":t=`Expected ${d.expected}, received ${d.received}`;break;case et.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(d.expected,Os.jsonStringifyReplacer)}`;break;case et.unrecognized_keys:t=`Unrecognized key(s) in object: ${Os.joinValues(d.keys,", ")}`;break;case et.invalid_union:t="Invalid input";break;case et.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Os.joinValues(d.options)}`;break;case et.invalid_enum_value:t=`Invalid enum value. Expected ${Os.joinValues(d.options)}, received '${d.received}'`;break;case et.invalid_arguments:t="Invalid function arguments";break;case et.invalid_return_type:t="Invalid function return type";break;case et.invalid_date:t="Invalid date";break;case et.invalid_string:typeof d.validation=="object"?"includes"in d.validation?(t=`Invalid input: must include "${d.validation.includes}"`,typeof d.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${d.validation.position}`)):"startsWith"in d.validation?t=`Invalid input: must start with "${d.validation.startsWith}"`:"endsWith"in d.validation?t=`Invalid input: must end with "${d.validation.endsWith}"`:Os.assertNever(d.validation):d.validation!=="regex"?t=`Invalid ${d.validation}`:t="Invalid";break;case et.too_small:d.type==="array"?t=`Array must contain ${d.exact?"exactly":d.inclusive?"at least":"more than"} ${d.minimum} element(s)`:d.type==="string"?t=`String must contain ${d.exact?"exactly":d.inclusive?"at least":"over"} ${d.minimum} character(s)`:d.type==="number"?t=`Number must be ${d.exact?"exactly equal to ":d.inclusive?"greater than or equal to ":"greater than "}${d.minimum}`:d.type==="date"?t=`Date must be ${d.exact?"exactly equal to ":d.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(d.minimum))}`:t="Invalid input";break;case et.too_big:d.type==="array"?t=`Array must contain ${d.exact?"exactly":d.inclusive?"at most":"less than"} ${d.maximum} element(s)`:d.type==="string"?t=`String must contain ${d.exact?"exactly":d.inclusive?"at most":"under"} ${d.maximum} character(s)`:d.type==="number"?t=`Number must be ${d.exact?"exactly":d.inclusive?"less than or equal to":"less than"} ${d.maximum}`:d.type==="bigint"?t=`BigInt must be ${d.exact?"exactly":d.inclusive?"less than or equal to":"less than"} ${d.maximum}`:d.type==="date"?t=`Date must be ${d.exact?"exactly":d.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(d.maximum))}`:t="Invalid input";break;case et.custom:t="Invalid input";break;case et.invalid_intersection_types:t="Intersection results could not be merged";break;case et.not_multiple_of:t=`Number must be a multiple of ${d.multipleOf}`;break;case et.not_finite:t="Number must be finite";break;default:t=e.defaultError,Os.assertNever(d)}return{message:t}};let qG=Am;function tfe(d){qG=d}function mv(){return qG}const gv=d=>{const{data:e,path:t,errorMaps:s,issueData:i}=d,n=[...t,...i.path||[]],r={...i,path:n};if(i.message!==void 0)return{...i,path:n,message:i.message};let a="";const o=s.filter(c=>!!c).slice().reverse();for(const c of o)a=c(r,{data:e,defaultError:a}).message;return{...i,path:n,message:a}},sfe=[];function mt(d,e){const t=mv(),s=gv({issueData:e,data:d.data,path:d.path,errorMaps:[d.common.contextualErrorMap,d.schemaErrorMap,t,t===Am?void 0:Am].filter(i=>!!i)});d.common.issues.push(s)}class nr{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const i of t){if(i.status==="aborted")return Xt;i.status==="dirty"&&e.dirty(),s.push(i.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const i of t){const n=await i.key,r=await i.value;s.push({key:n,value:r})}return nr.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const i of t){const{key:n,value:r}=i;if(n.status==="aborted"||r.status==="aborted")return Xt;n.status==="dirty"&&e.dirty(),r.status==="dirty"&&e.dirty(),n.value!=="__proto__"&&(typeof r.value<"u"||i.alwaysSet)&&(s[n.value]=r.value)}return{status:e.value,value:s}}}const Xt=Object.freeze({status:"aborted"}),Rp=d=>({status:"dirty",value:d}),wr=d=>({status:"valid",value:d}),QM=d=>d.status==="aborted",YM=d=>d.status==="dirty",Kl=d=>d.status==="valid",X0=d=>typeof Promise<"u"&&d instanceof Promise;function yv(d,e,t,s){if(typeof e=="function"?d!==e||!s:!e.has(d))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(d)}function VG(d,e,t,s,i){if(typeof e=="function"?d!==e||!i:!e.has(d))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(d,t),t}var Lt;(function(d){d.errToObj=e=>typeof e=="string"?{message:e}:e||{},d.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Lt||(Lt={}));var Ay,Ly;class Hd{constructor(e,t,s,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Rq=(d,e)=>{if(Kl(e))return{success:!0,data:e.value};if(!d.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new ka(d.common.issues);return this._error=t,this._error}}};function os(d){if(!d)return{};const{errorMap:e,invalid_type_error:t,required_error:s,description:i}=d;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(r,a)=>{var o,c;const{message:u}=d;return r.code==="invalid_enum_value"?{message:u??a.defaultError}:typeof a.data>"u"?{message:(o=u??s)!==null&&o!==void 0?o:a.defaultError}:r.code!=="invalid_type"?{message:a.defaultError}:{message:(c=u??t)!==null&&c!==void 0?c:a.defaultError}},description:i}}class hs{get description(){return this._def.description}_getType(e){return wc(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:wc(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new nr,ctx:{common:e.parent.common,data:e.data,parsedType:wc(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(X0(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){var s;const i={common:{issues:[],async:(s=t==null?void 0:t.async)!==null&&s!==void 0?s:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:wc(e)},n=this._parseSync({data:e,path:i.path,parent:i});return Rq(i,n)}"~validate"(e){var t,s;const i={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:wc(e)};if(!this["~standard"].async)try{const n=this._parseSync({data:e,path:[],parent:i});return Kl(n)?{value:n.value}:{issues:i.common.issues}}catch(n){!((s=(t=n==null?void 0:n.message)===null||t===void 0?void 0:t.toLowerCase())===null||s===void 0)&&s.includes("encountered")&&(this["~standard"].async=!0),i.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:i}).then(n=>Kl(n)?{value:n.value}:{issues:i.common.issues})}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:wc(e)},i=this._parse({data:e,path:s.path,parent:s}),n=await(X0(i)?i:Promise.resolve(i));return Rq(s,n)}refine(e,t){const s=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,n)=>{const r=e(i),a=()=>n.addIssue({code:et.custom,...s(i)});return typeof Promise<"u"&&r instanceof Promise?r.then(o=>o?!0:(a(),!1)):r?!0:(a(),!1)})}refinement(e,t){return this._refinement((s,i)=>e(s)?!0:(i.addIssue(typeof t=="function"?t(s,i):t),!1))}_refinement(e){return new zo({schema:this,typeName:Kt.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return Dd.create(this,this._def)}nullable(){return Th.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Go.create(this)}promise(){return Bm.create(this,this._def)}or(e){return J0.create([this,e],this._def)}and(e){return ew.create(this,e,this._def)}transform(e){return new zo({...os(this._def),schema:this,typeName:Kt.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new rw({...os(this._def),innerType:this,defaultValue:t,typeName:Kt.ZodDefault})}brand(){return new VA({typeName:Kt.ZodBranded,type:this,...os(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new aw({...os(this._def),innerType:this,catchValue:t,typeName:Kt.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return eb.create(this,e)}readonly(){return ow.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const ife=/^c[^\s-]{8,}$/i,nfe=/^[0-9a-z]+$/,rfe=/^[0-9A-HJKMNP-TV-Z]{26}$/i,afe=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,ofe=/^[a-z0-9_-]{21}$/i,dfe=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,cfe=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,ufe=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,hfe="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let yI;const lfe=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ffe=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,pfe=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,mfe=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,gfe=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,yfe=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,FG="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",wfe=new RegExp(`^${FG}$`);function HG(d){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return d.precision?e=`${e}\\.\\d{${d.precision}}`:d.precision==null&&(e=`${e}(\\.\\d+)?`),e}function bfe(d){return new RegExp(`^${HG(d)}$`)}function GG(d){let e=`${FG}T${HG(d)}`;const t=[];return t.push(d.local?"Z?":"Z"),d.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function kfe(d,e){return!!((e==="v4"||!e)&&lfe.test(d)||(e==="v6"||!e)&&pfe.test(d))}function Sfe(d,e){if(!dfe.test(d))return!1;try{const[t]=d.split("."),s=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),i=JSON.parse(atob(s));return!(typeof i!="object"||i===null||!i.typ||!i.alg||e&&i.alg!==e)}catch{return!1}}function vfe(d,e){return!!((e==="v4"||!e)&&ffe.test(d)||(e==="v6"||!e)&&mfe.test(d))}class Do extends hs{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==vt.string){const n=this._getOrReturnCtx(e);return mt(n,{code:et.invalid_type,expected:vt.string,received:n.parsedType}),Xt}const s=new nr;let i;for(const n of this._def.checks)if(n.kind==="min")e.data.lengthn.value&&(i=this._getOrReturnCtx(e,i),mt(i,{code:et.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),s.dirty());else if(n.kind==="length"){const r=e.data.length>n.value,a=e.data.lengthe.test(i),{validation:t,code:et.invalid_string,...Lt.errToObj(s)})}_addCheck(e){return new Do({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Lt.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Lt.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Lt.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Lt.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Lt.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Lt.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Lt.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Lt.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Lt.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Lt.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Lt.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Lt.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Lt.errToObj(e)})}datetime(e){var t,s;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(s=e==null?void 0:e.local)!==null&&s!==void 0?s:!1,...Lt.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...Lt.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Lt.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Lt.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...Lt.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Lt.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Lt.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Lt.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Lt.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Lt.errToObj(t)})}nonempty(e){return this.min(1,Lt.errToObj(e))}trim(){return new Do({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Do({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Do({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value{var e;return new Do({checks:[],typeName:Kt.ZodString,coerce:(e=d==null?void 0:d.coerce)!==null&&e!==void 0?e:!1,...os(d)})};function Tfe(d,e){const t=(d.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,i=t>s?t:s,n=parseInt(d.toFixed(i).replace(".","")),r=parseInt(e.toFixed(i).replace(".",""));return n%r/Math.pow(10,i)}class kh extends hs{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==vt.number){const n=this._getOrReturnCtx(e);return mt(n,{code:et.invalid_type,expected:vt.number,received:n.parsedType}),Xt}let s;const i=new nr;for(const n of this._def.checks)n.kind==="int"?Os.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),mt(s,{code:et.invalid_type,expected:"integer",received:"float",message:n.message}),i.dirty()):n.kind==="min"?(n.inclusive?e.datan.value:e.data>=n.value)&&(s=this._getOrReturnCtx(e,s),mt(s,{code:et.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),i.dirty()):n.kind==="multipleOf"?Tfe(e.data,n.value)!==0&&(s=this._getOrReturnCtx(e,s),mt(s,{code:et.not_multiple_of,multipleOf:n.value,message:n.message}),i.dirty()):n.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),mt(s,{code:et.not_finite,message:n.message}),i.dirty()):Os.assertNever(n);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Lt.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Lt.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Lt.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Lt.toString(t))}setLimit(e,t,s,i){return new kh({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:Lt.toString(i)}]})}_addCheck(e){return new kh({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Lt.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Lt.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Lt.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Lt.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Lt.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Lt.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Lt.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Lt.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Lt.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.valuee.kind==="int"||e.kind==="multipleOf"&&Os.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.valuenew kh({checks:[],typeName:Kt.ZodNumber,coerce:(d==null?void 0:d.coerce)||!1,...os(d)});class Sh extends hs{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==vt.bigint)return this._getInvalidInput(e);let s;const i=new nr;for(const n of this._def.checks)n.kind==="min"?(n.inclusive?e.datan.value:e.data>=n.value)&&(s=this._getOrReturnCtx(e,s),mt(s,{code:et.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),i.dirty()):n.kind==="multipleOf"?e.data%n.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),mt(s,{code:et.not_multiple_of,multipleOf:n.value,message:n.message}),i.dirty()):Os.assertNever(n);return{status:i.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return mt(t,{code:et.invalid_type,expected:vt.bigint,received:t.parsedType}),Xt}gte(e,t){return this.setLimit("min",e,!0,Lt.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Lt.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Lt.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Lt.toString(t))}setLimit(e,t,s,i){return new Sh({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:Lt.toString(i)}]})}_addCheck(e){return new Sh({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Lt.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Lt.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Lt.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Lt.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Lt.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value{var e;return new Sh({checks:[],typeName:Kt.ZodBigInt,coerce:(e=d==null?void 0:d.coerce)!==null&&e!==void 0?e:!1,...os(d)})};class Q0 extends hs{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==vt.boolean){const s=this._getOrReturnCtx(e);return mt(s,{code:et.invalid_type,expected:vt.boolean,received:s.parsedType}),Xt}return wr(e.data)}}Q0.create=d=>new Q0({typeName:Kt.ZodBoolean,coerce:(d==null?void 0:d.coerce)||!1,...os(d)});class Xl extends hs{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==vt.date){const n=this._getOrReturnCtx(e);return mt(n,{code:et.invalid_type,expected:vt.date,received:n.parsedType}),Xt}if(isNaN(e.data.getTime())){const n=this._getOrReturnCtx(e);return mt(n,{code:et.invalid_date}),Xt}const s=new nr;let i;for(const n of this._def.checks)n.kind==="min"?e.data.getTime()n.value&&(i=this._getOrReturnCtx(e,i),mt(i,{code:et.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),s.dirty()):Os.assertNever(n);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Xl({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Lt.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Lt.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.valuenew Xl({checks:[],coerce:(d==null?void 0:d.coerce)||!1,typeName:Kt.ZodDate,...os(d)});class wv extends hs{_parse(e){if(this._getType(e)!==vt.symbol){const s=this._getOrReturnCtx(e);return mt(s,{code:et.invalid_type,expected:vt.symbol,received:s.parsedType}),Xt}return wr(e.data)}}wv.create=d=>new wv({typeName:Kt.ZodSymbol,...os(d)});class Y0 extends hs{_parse(e){if(this._getType(e)!==vt.undefined){const s=this._getOrReturnCtx(e);return mt(s,{code:et.invalid_type,expected:vt.undefined,received:s.parsedType}),Xt}return wr(e.data)}}Y0.create=d=>new Y0({typeName:Kt.ZodUndefined,...os(d)});class Z0 extends hs{_parse(e){if(this._getType(e)!==vt.null){const s=this._getOrReturnCtx(e);return mt(s,{code:et.invalid_type,expected:vt.null,received:s.parsedType}),Xt}return wr(e.data)}}Z0.create=d=>new Z0({typeName:Kt.ZodNull,...os(d)});class Lm extends hs{constructor(){super(...arguments),this._any=!0}_parse(e){return wr(e.data)}}Lm.create=d=>new Lm({typeName:Kt.ZodAny,...os(d)});class El extends hs{constructor(){super(...arguments),this._unknown=!0}_parse(e){return wr(e.data)}}El.create=d=>new El({typeName:Kt.ZodUnknown,...os(d)});class $c extends hs{_parse(e){const t=this._getOrReturnCtx(e);return mt(t,{code:et.invalid_type,expected:vt.never,received:t.parsedType}),Xt}}$c.create=d=>new $c({typeName:Kt.ZodNever,...os(d)});class bv extends hs{_parse(e){if(this._getType(e)!==vt.undefined){const s=this._getOrReturnCtx(e);return mt(s,{code:et.invalid_type,expected:vt.void,received:s.parsedType}),Xt}return wr(e.data)}}bv.create=d=>new bv({typeName:Kt.ZodVoid,...os(d)});class Go extends hs{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),i=this._def;if(t.parsedType!==vt.array)return mt(t,{code:et.invalid_type,expected:vt.array,received:t.parsedType}),Xt;if(i.exactLength!==null){const r=t.data.length>i.exactLength.value,a=t.data.lengthi.maxLength.value&&(mt(t,{code:et.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((r,a)=>i.type._parseAsync(new Hd(t,r,t.path,a)))).then(r=>nr.mergeArray(s,r));const n=[...t.data].map((r,a)=>i.type._parseSync(new Hd(t,r,t.path,a)));return nr.mergeArray(s,n)}get element(){return this._def.type}min(e,t){return new Go({...this._def,minLength:{value:e,message:Lt.toString(t)}})}max(e,t){return new Go({...this._def,maxLength:{value:e,message:Lt.toString(t)}})}length(e,t){return new Go({...this._def,exactLength:{value:e,message:Lt.toString(t)}})}nonempty(e){return this.min(1,e)}}Go.create=(d,e)=>new Go({type:d,minLength:null,maxLength:null,exactLength:null,typeName:Kt.ZodArray,...os(e)});function gp(d){if(d instanceof Pi){const e={};for(const t in d.shape){const s=d.shape[t];e[t]=Dd.create(gp(s))}return new Pi({...d._def,shape:()=>e})}else return d instanceof Go?new Go({...d._def,type:gp(d.element)}):d instanceof Dd?Dd.create(gp(d.unwrap())):d instanceof Th?Th.create(gp(d.unwrap())):d instanceof Gd?Gd.create(d.items.map(e=>gp(e))):d}class Pi extends hs{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=Os.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==vt.object){const c=this._getOrReturnCtx(e);return mt(c,{code:et.invalid_type,expected:vt.object,received:c.parsedType}),Xt}const{status:s,ctx:i}=this._processInputParams(e),{shape:n,keys:r}=this._getCached(),a=[];if(!(this._def.catchall instanceof $c&&this._def.unknownKeys==="strip"))for(const c in i.data)r.includes(c)||a.push(c);const o=[];for(const c of r){const u=n[c],h=i.data[c];o.push({key:{status:"valid",value:c},value:u._parse(new Hd(i,h,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof $c){const c=this._def.unknownKeys;if(c==="passthrough")for(const u of a)o.push({key:{status:"valid",value:u},value:{status:"valid",value:i.data[u]}});else if(c==="strict")a.length>0&&(mt(i,{code:et.unrecognized_keys,keys:a}),s.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const u of a){const h=i.data[u];o.push({key:{status:"valid",value:u},value:c._parse(new Hd(i,h,i.path,u)),alwaysSet:u in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const c=[];for(const u of o){const h=await u.key,l=await u.value;c.push({key:h,value:l,alwaysSet:u.alwaysSet})}return c}).then(c=>nr.mergeObjectSync(s,c)):nr.mergeObjectSync(s,o)}get shape(){return this._def.shape()}strict(e){return Lt.errToObj,new Pi({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{var i,n,r,a;const o=(r=(n=(i=this._def).errorMap)===null||n===void 0?void 0:n.call(i,t,s).message)!==null&&r!==void 0?r:s.defaultError;return t.code==="unrecognized_keys"?{message:(a=Lt.errToObj(e).message)!==null&&a!==void 0?a:o}:{message:o}}}:{}})}strip(){return new Pi({...this._def,unknownKeys:"strip"})}passthrough(){return new Pi({...this._def,unknownKeys:"passthrough"})}extend(e){return new Pi({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Pi({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Kt.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Pi({...this._def,catchall:e})}pick(e){const t={};return Os.objectKeys(e).forEach(s=>{e[s]&&this.shape[s]&&(t[s]=this.shape[s])}),new Pi({...this._def,shape:()=>t})}omit(e){const t={};return Os.objectKeys(this.shape).forEach(s=>{e[s]||(t[s]=this.shape[s])}),new Pi({...this._def,shape:()=>t})}deepPartial(){return gp(this)}partial(e){const t={};return Os.objectKeys(this.shape).forEach(s=>{const i=this.shape[s];e&&!e[s]?t[s]=i:t[s]=i.optional()}),new Pi({...this._def,shape:()=>t})}required(e){const t={};return Os.objectKeys(this.shape).forEach(s=>{if(e&&!e[s])t[s]=this.shape[s];else{let n=this.shape[s];for(;n instanceof Dd;)n=n._def.innerType;t[s]=n}}),new Pi({...this._def,shape:()=>t})}keyof(){return UG(Os.objectKeys(this.shape))}}Pi.create=(d,e)=>new Pi({shape:()=>d,unknownKeys:"strip",catchall:$c.create(),typeName:Kt.ZodObject,...os(e)});Pi.strictCreate=(d,e)=>new Pi({shape:()=>d,unknownKeys:"strict",catchall:$c.create(),typeName:Kt.ZodObject,...os(e)});Pi.lazycreate=(d,e)=>new Pi({shape:d,unknownKeys:"strip",catchall:$c.create(),typeName:Kt.ZodObject,...os(e)});class J0 extends hs{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;function i(n){for(const a of n)if(a.result.status==="valid")return a.result;for(const a of n)if(a.result.status==="dirty")return t.common.issues.push(...a.ctx.common.issues),a.result;const r=n.map(a=>new ka(a.ctx.common.issues));return mt(t,{code:et.invalid_union,unionErrors:r}),Xt}if(t.common.async)return Promise.all(s.map(async n=>{const r={...t,common:{...t.common,issues:[]},parent:null};return{result:await n._parseAsync({data:t.data,path:t.path,parent:r}),ctx:r}})).then(i);{let n;const r=[];for(const o of s){const c={...t,common:{...t.common,issues:[]},parent:null},u=o._parseSync({data:t.data,path:t.path,parent:c});if(u.status==="valid")return u;u.status==="dirty"&&!n&&(n={result:u,ctx:c}),c.common.issues.length&&r.push(c.common.issues)}if(n)return t.common.issues.push(...n.ctx.common.issues),n.result;const a=r.map(o=>new ka(o));return mt(t,{code:et.invalid_union,unionErrors:a}),Xt}}get options(){return this._def.options}}J0.create=(d,e)=>new J0({options:d,typeName:Kt.ZodUnion,...os(e)});const pc=d=>d instanceof sw?pc(d.schema):d instanceof zo?pc(d.innerType()):d instanceof iw?[d.value]:d instanceof vh?d.options:d instanceof nw?Os.objectValues(d.enum):d instanceof rw?pc(d._def.innerType):d instanceof Y0?[void 0]:d instanceof Z0?[null]:d instanceof Dd?[void 0,...pc(d.unwrap())]:d instanceof Th?[null,...pc(d.unwrap())]:d instanceof VA||d instanceof ow?pc(d.unwrap()):d instanceof aw?pc(d._def.innerType):[];class oO extends hs{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==vt.object)return mt(t,{code:et.invalid_type,expected:vt.object,received:t.parsedType}),Xt;const s=this.discriminator,i=t.data[s],n=this.optionsMap.get(i);return n?t.common.async?n._parseAsync({data:t.data,path:t.path,parent:t}):n._parseSync({data:t.data,path:t.path,parent:t}):(mt(t,{code:et.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),Xt)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const i=new Map;for(const n of t){const r=pc(n.shape[e]);if(!r.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const a of r){if(i.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);i.set(a,n)}}return new oO({typeName:Kt.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...os(s)})}}function ZM(d,e){const t=wc(d),s=wc(e);if(d===e)return{valid:!0,data:d};if(t===vt.object&&s===vt.object){const i=Os.objectKeys(e),n=Os.objectKeys(d).filter(a=>i.indexOf(a)!==-1),r={...d,...e};for(const a of n){const o=ZM(d[a],e[a]);if(!o.valid)return{valid:!1};r[a]=o.data}return{valid:!0,data:r}}else if(t===vt.array&&s===vt.array){if(d.length!==e.length)return{valid:!1};const i=[];for(let n=0;n{if(QM(n)||QM(r))return Xt;const a=ZM(n.value,r.value);return a.valid?((YM(n)||YM(r))&&t.dirty(),{status:t.value,value:a.data}):(mt(s,{code:et.invalid_intersection_types}),Xt)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([n,r])=>i(n,r)):i(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}ew.create=(d,e,t)=>new ew({left:d,right:e,typeName:Kt.ZodIntersection,...os(t)});class Gd extends hs{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==vt.array)return mt(s,{code:et.invalid_type,expected:vt.array,received:s.parsedType}),Xt;if(s.data.lengththis._def.items.length&&(mt(s,{code:et.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const n=[...s.data].map((r,a)=>{const o=this._def.items[a]||this._def.rest;return o?o._parse(new Hd(s,r,s.path,a)):null}).filter(r=>!!r);return s.common.async?Promise.all(n).then(r=>nr.mergeArray(t,r)):nr.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new Gd({...this._def,rest:e})}}Gd.create=(d,e)=>{if(!Array.isArray(d))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Gd({items:d,typeName:Kt.ZodTuple,rest:null,...os(e)})};class tw extends hs{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==vt.object)return mt(s,{code:et.invalid_type,expected:vt.object,received:s.parsedType}),Xt;const i=[],n=this._def.keyType,r=this._def.valueType;for(const a in s.data)i.push({key:n._parse(new Hd(s,a,s.path,a)),value:r._parse(new Hd(s,s.data[a],s.path,a)),alwaysSet:a in s.data});return s.common.async?nr.mergeObjectAsync(t,i):nr.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof hs?new tw({keyType:e,valueType:t,typeName:Kt.ZodRecord,...os(s)}):new tw({keyType:Do.create(),valueType:e,typeName:Kt.ZodRecord,...os(t)})}}class kv extends hs{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==vt.map)return mt(s,{code:et.invalid_type,expected:vt.map,received:s.parsedType}),Xt;const i=this._def.keyType,n=this._def.valueType,r=[...s.data.entries()].map(([a,o],c)=>({key:i._parse(new Hd(s,a,s.path,[c,"key"])),value:n._parse(new Hd(s,o,s.path,[c,"value"]))}));if(s.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const o of r){const c=await o.key,u=await o.value;if(c.status==="aborted"||u.status==="aborted")return Xt;(c.status==="dirty"||u.status==="dirty")&&t.dirty(),a.set(c.value,u.value)}return{status:t.value,value:a}})}else{const a=new Map;for(const o of r){const c=o.key,u=o.value;if(c.status==="aborted"||u.status==="aborted")return Xt;(c.status==="dirty"||u.status==="dirty")&&t.dirty(),a.set(c.value,u.value)}return{status:t.value,value:a}}}}kv.create=(d,e,t)=>new kv({valueType:e,keyType:d,typeName:Kt.ZodMap,...os(t)});class Ql extends hs{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==vt.set)return mt(s,{code:et.invalid_type,expected:vt.set,received:s.parsedType}),Xt;const i=this._def;i.minSize!==null&&s.data.sizei.maxSize.value&&(mt(s,{code:et.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const n=this._def.valueType;function r(o){const c=new Set;for(const u of o){if(u.status==="aborted")return Xt;u.status==="dirty"&&t.dirty(),c.add(u.value)}return{status:t.value,value:c}}const a=[...s.data.values()].map((o,c)=>n._parse(new Hd(s,o,s.path,c)));return s.common.async?Promise.all(a).then(o=>r(o)):r(a)}min(e,t){return new Ql({...this._def,minSize:{value:e,message:Lt.toString(t)}})}max(e,t){return new Ql({...this._def,maxSize:{value:e,message:Lt.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Ql.create=(d,e)=>new Ql({valueType:d,minSize:null,maxSize:null,typeName:Kt.ZodSet,...os(e)});class nm extends hs{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==vt.function)return mt(t,{code:et.invalid_type,expected:vt.function,received:t.parsedType}),Xt;function s(a,o){return gv({data:a,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,mv(),Am].filter(c=>!!c),issueData:{code:et.invalid_arguments,argumentsError:o}})}function i(a,o){return gv({data:a,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,mv(),Am].filter(c=>!!c),issueData:{code:et.invalid_return_type,returnTypeError:o}})}const n={errorMap:t.common.contextualErrorMap},r=t.data;if(this._def.returns instanceof Bm){const a=this;return wr(async function(...o){const c=new ka([]),u=await a._def.args.parseAsync(o,n).catch(f=>{throw c.addIssue(s(o,f)),c}),h=await Reflect.apply(r,this,u);return await a._def.returns._def.type.parseAsync(h,n).catch(f=>{throw c.addIssue(i(h,f)),c})})}else{const a=this;return wr(function(...o){const c=a._def.args.safeParse(o,n);if(!c.success)throw new ka([s(o,c.error)]);const u=Reflect.apply(r,this,c.data),h=a._def.returns.safeParse(u,n);if(!h.success)throw new ka([i(u,h.error)]);return h.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new nm({...this._def,args:Gd.create(e).rest(El.create())})}returns(e){return new nm({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new nm({args:e||Gd.create([]).rest(El.create()),returns:t||El.create(),typeName:Kt.ZodFunction,...os(s)})}}class sw extends hs{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}sw.create=(d,e)=>new sw({getter:d,typeName:Kt.ZodLazy,...os(e)});class iw extends hs{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return mt(t,{received:t.data,code:et.invalid_literal,expected:this._def.value}),Xt}return{status:"valid",value:e.data}}get value(){return this._def.value}}iw.create=(d,e)=>new iw({value:d,typeName:Kt.ZodLiteral,...os(e)});function UG(d,e){return new vh({values:d,typeName:Kt.ZodEnum,...os(e)})}class vh extends hs{constructor(){super(...arguments),Ay.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),s=this._def.values;return mt(t,{expected:Os.joinValues(s),received:t.parsedType,code:et.invalid_type}),Xt}if(yv(this,Ay)||VG(this,Ay,new Set(this._def.values)),!yv(this,Ay).has(e.data)){const t=this._getOrReturnCtx(e),s=this._def.values;return mt(t,{received:t.data,code:et.invalid_enum_value,options:s}),Xt}return wr(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return vh.create(e,{...this._def,...t})}exclude(e,t=this._def){return vh.create(this.options.filter(s=>!e.includes(s)),{...this._def,...t})}}Ay=new WeakMap;vh.create=UG;class nw extends hs{constructor(){super(...arguments),Ly.set(this,void 0)}_parse(e){const t=Os.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==vt.string&&s.parsedType!==vt.number){const i=Os.objectValues(t);return mt(s,{expected:Os.joinValues(i),received:s.parsedType,code:et.invalid_type}),Xt}if(yv(this,Ly)||VG(this,Ly,new Set(Os.getValidEnumValues(this._def.values))),!yv(this,Ly).has(e.data)){const i=Os.objectValues(t);return mt(s,{received:s.data,code:et.invalid_enum_value,options:i}),Xt}return wr(e.data)}get enum(){return this._def.values}}Ly=new WeakMap;nw.create=(d,e)=>new nw({values:d,typeName:Kt.ZodNativeEnum,...os(e)});class Bm extends hs{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==vt.promise&&t.common.async===!1)return mt(t,{code:et.invalid_type,expected:vt.promise,received:t.parsedType}),Xt;const s=t.parsedType===vt.promise?t.data:Promise.resolve(t.data);return wr(s.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Bm.create=(d,e)=>new Bm({type:d,typeName:Kt.ZodPromise,...os(e)});class zo extends hs{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Kt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),i=this._def.effect||null,n={addIssue:r=>{mt(s,r),r.fatal?t.abort():t.dirty()},get path(){return s.path}};if(n.addIssue=n.addIssue.bind(n),i.type==="preprocess"){const r=i.transform(s.data,n);if(s.common.async)return Promise.resolve(r).then(async a=>{if(t.value==="aborted")return Xt;const o=await this._def.schema._parseAsync({data:a,path:s.path,parent:s});return o.status==="aborted"?Xt:o.status==="dirty"||t.value==="dirty"?Rp(o.value):o});{if(t.value==="aborted")return Xt;const a=this._def.schema._parseSync({data:r,path:s.path,parent:s});return a.status==="aborted"?Xt:a.status==="dirty"||t.value==="dirty"?Rp(a.value):a}}if(i.type==="refinement"){const r=a=>{const o=i.refinement(a,n);if(s.common.async)return Promise.resolve(o);if(o instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(s.common.async===!1){const a=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?Xt:(a.status==="dirty"&&t.dirty(),r(a.value),{status:t.value,value:a.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(a=>a.status==="aborted"?Xt:(a.status==="dirty"&&t.dirty(),r(a.value).then(()=>({status:t.value,value:a.value}))))}if(i.type==="transform")if(s.common.async===!1){const r=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!Kl(r))return r;const a=i.transform(r.value,n);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(r=>Kl(r)?Promise.resolve(i.transform(r.value,n)).then(a=>({status:t.value,value:a})):r);Os.assertNever(i)}}zo.create=(d,e,t)=>new zo({schema:d,typeName:Kt.ZodEffects,effect:e,...os(t)});zo.createWithPreprocess=(d,e,t)=>new zo({schema:e,effect:{type:"preprocess",transform:d},typeName:Kt.ZodEffects,...os(t)});class Dd extends hs{_parse(e){return this._getType(e)===vt.undefined?wr(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Dd.create=(d,e)=>new Dd({innerType:d,typeName:Kt.ZodOptional,...os(e)});class Th extends hs{_parse(e){return this._getType(e)===vt.null?wr(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Th.create=(d,e)=>new Th({innerType:d,typeName:Kt.ZodNullable,...os(e)});class rw extends hs{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===vt.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}rw.create=(d,e)=>new rw({innerType:d,typeName:Kt.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...os(e)});class aw extends hs{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return X0(i)?i.then(n=>({status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new ka(s.common.issues)},input:s.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new ka(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}aw.create=(d,e)=>new aw({innerType:d,typeName:Kt.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...os(e)});class Sv extends hs{_parse(e){if(this._getType(e)!==vt.nan){const s=this._getOrReturnCtx(e);return mt(s,{code:et.invalid_type,expected:vt.nan,received:s.parsedType}),Xt}return{status:"valid",value:e.data}}}Sv.create=d=>new Sv({typeName:Kt.ZodNaN,...os(d)});const Ofe=Symbol("zod_brand");class VA extends hs{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class eb extends hs{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const n=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?Xt:n.status==="dirty"?(t.dirty(),Rp(n.value)):this._def.out._parseAsync({data:n.value,path:s.path,parent:s})})();{const i=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return i.status==="aborted"?Xt:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:s.path,parent:s})}}static create(e,t){return new eb({in:e,out:t,typeName:Kt.ZodPipeline})}}class ow extends hs{_parse(e){const t=this._def.innerType._parse(e),s=i=>(Kl(i)&&(i.value=Object.freeze(i.value)),i);return X0(t)?t.then(i=>s(i)):s(t)}unwrap(){return this._def.innerType}}ow.create=(d,e)=>new ow({innerType:d,typeName:Kt.ZodReadonly,...os(e)});function WG(d,e={},t){return d?Lm.create().superRefine((s,i)=>{var n,r;if(!d(s)){const a=typeof e=="function"?e(s):typeof e=="string"?{message:e}:e,o=(r=(n=a.fatal)!==null&&n!==void 0?n:t)!==null&&r!==void 0?r:!0,c=typeof a=="string"?{message:a}:a;i.addIssue({code:"custom",...c,fatal:o})}}):Lm.create()}const xfe={object:Pi.lazycreate};var Kt;(function(d){d.ZodString="ZodString",d.ZodNumber="ZodNumber",d.ZodNaN="ZodNaN",d.ZodBigInt="ZodBigInt",d.ZodBoolean="ZodBoolean",d.ZodDate="ZodDate",d.ZodSymbol="ZodSymbol",d.ZodUndefined="ZodUndefined",d.ZodNull="ZodNull",d.ZodAny="ZodAny",d.ZodUnknown="ZodUnknown",d.ZodNever="ZodNever",d.ZodVoid="ZodVoid",d.ZodArray="ZodArray",d.ZodObject="ZodObject",d.ZodUnion="ZodUnion",d.ZodDiscriminatedUnion="ZodDiscriminatedUnion",d.ZodIntersection="ZodIntersection",d.ZodTuple="ZodTuple",d.ZodRecord="ZodRecord",d.ZodMap="ZodMap",d.ZodSet="ZodSet",d.ZodFunction="ZodFunction",d.ZodLazy="ZodLazy",d.ZodLiteral="ZodLiteral",d.ZodEnum="ZodEnum",d.ZodEffects="ZodEffects",d.ZodNativeEnum="ZodNativeEnum",d.ZodOptional="ZodOptional",d.ZodNullable="ZodNullable",d.ZodDefault="ZodDefault",d.ZodCatch="ZodCatch",d.ZodPromise="ZodPromise",d.ZodBranded="ZodBranded",d.ZodPipeline="ZodPipeline",d.ZodReadonly="ZodReadonly"})(Kt||(Kt={}));const Pfe=(d,e={message:`Input not instance of ${d.name}`})=>WG(t=>t instanceof d,e),jG=Do.create,zG=kh.create,Ife=Sv.create,Cfe=Sh.create,$G=Q0.create,Mfe=Xl.create,_fe=wv.create,Afe=Y0.create,Lfe=Z0.create,Bfe=Lm.create,Nfe=El.create,Efe=$c.create,Rfe=bv.create,Dfe=Go.create,qfe=Pi.create,Vfe=Pi.strictCreate,Ffe=J0.create,Hfe=oO.create,Gfe=ew.create,Ufe=Gd.create,Wfe=tw.create,jfe=kv.create,zfe=Ql.create,$fe=nm.create,Kfe=sw.create,Xfe=iw.create,Qfe=vh.create,Yfe=nw.create,Zfe=Bm.create,Dq=zo.create,Jfe=Dd.create,epe=Th.create,tpe=zo.createWithPreprocess,spe=eb.create,ipe=()=>jG().optional(),npe=()=>zG().optional(),rpe=()=>$G().optional(),ape={string:d=>Do.create({...d,coerce:!0}),number:d=>kh.create({...d,coerce:!0}),boolean:d=>Q0.create({...d,coerce:!0}),bigint:d=>Sh.create({...d,coerce:!0}),date:d=>Xl.create({...d,coerce:!0})},ope=Xt;var Oo=Object.freeze({__proto__:null,defaultErrorMap:Am,setErrorMap:tfe,getErrorMap:mv,makeIssue:gv,EMPTY_PATH:sfe,addIssueToContext:mt,ParseStatus:nr,INVALID:Xt,DIRTY:Rp,OK:wr,isAborted:QM,isDirty:YM,isValid:Kl,isAsync:X0,get util(){return Os},get objectUtil(){return XM},ZodParsedType:vt,getParsedType:wc,ZodType:hs,datetimeRegex:GG,ZodString:Do,ZodNumber:kh,ZodBigInt:Sh,ZodBoolean:Q0,ZodDate:Xl,ZodSymbol:wv,ZodUndefined:Y0,ZodNull:Z0,ZodAny:Lm,ZodUnknown:El,ZodNever:$c,ZodVoid:bv,ZodArray:Go,ZodObject:Pi,ZodUnion:J0,ZodDiscriminatedUnion:oO,ZodIntersection:ew,ZodTuple:Gd,ZodRecord:tw,ZodMap:kv,ZodSet:Ql,ZodFunction:nm,ZodLazy:sw,ZodLiteral:iw,ZodEnum:vh,ZodNativeEnum:nw,ZodPromise:Bm,ZodEffects:zo,ZodTransformer:zo,ZodOptional:Dd,ZodNullable:Th,ZodDefault:rw,ZodCatch:aw,ZodNaN:Sv,BRAND:Ofe,ZodBranded:VA,ZodPipeline:eb,ZodReadonly:ow,custom:WG,Schema:hs,ZodSchema:hs,late:xfe,get ZodFirstPartyTypeKind(){return Kt},coerce:ape,any:Bfe,array:Dfe,bigint:Cfe,boolean:$G,date:Mfe,discriminatedUnion:Hfe,effect:Dq,enum:Qfe,function:$fe,instanceof:Pfe,intersection:Gfe,lazy:Kfe,literal:Xfe,map:jfe,nan:Ife,nativeEnum:Yfe,never:Efe,null:Lfe,nullable:epe,number:zG,object:qfe,oboolean:rpe,onumber:npe,optional:Jfe,ostring:ipe,pipeline:spe,preprocess:tpe,promise:Zfe,record:Wfe,set:zfe,strictObject:Vfe,string:jG,symbol:_fe,transformer:Dq,tuple:Ufe,undefined:Afe,union:Ffe,unknown:Nfe,void:Rfe,NEVER:ope,ZodIssueCode:et,quotelessJson:efe,ZodError:ka});const dpe=Object.keys(rO),cpe=Oo.object({shape:Oo.object({code:Oo.number(),message:Oo.string(),data:Oo.object({code:Oo.enum(dpe),httpStatus:Oo.number(),path:Oo.string(),stack:Oo.string()})})});function JM(d){return cpe.safeParse(d).success}function upe(d){return typeof d=="function"?d():d}const FA=B.forwardRef(function(e,t){const{children:s,container:i,disablePortal:n=!1}=e,[r,a]=B.useState(null),o=Cs(B.isValidElement(s)?s.ref:null,t);if(jo(()=>{n||a(upe(i)||document.body)},[i,n]),jo(()=>{if(r&&!n)return nv(t,r),()=>{nv(t,null)}},[t,r,n]),n){if(B.isValidElement(s)){const c={ref:o};return B.cloneElement(s,c)}return P.jsx(B.Fragment,{children:s})}return P.jsx(B.Fragment,{children:r&&bT.createPortal(s,r)})}),hpe=["input","select","textarea","a[href]","button","[tabindex]","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable="false"])'].join(",");function lpe(d){const e=parseInt(d.getAttribute("tabindex")||"",10);return Number.isNaN(e)?d.contentEditable==="true"||(d.nodeName==="AUDIO"||d.nodeName==="VIDEO"||d.nodeName==="DETAILS")&&d.getAttribute("tabindex")===null?0:d.tabIndex:e}function fpe(d){if(d.tagName!=="INPUT"||d.type!=="radio"||!d.name)return!1;const e=s=>d.ownerDocument.querySelector(`input[type="radio"]${s}`);let t=e(`[name="${d.name}"]:checked`);return t||(t=e(`[name="${d.name}"]`)),t!==d}function ppe(d){return!(d.disabled||d.tagName==="INPUT"&&d.type==="hidden"||fpe(d))}function mpe(d){const e=[],t=[];return Array.from(d.querySelectorAll(hpe)).forEach((s,i)=>{const n=lpe(s);n===-1||!ppe(s)||(n===0?e.push(s):t.push({documentOrder:i,tabIndex:n,node:s}))}),t.sort((s,i)=>s.tabIndex===i.tabIndex?s.documentOrder-i.documentOrder:s.tabIndex-i.tabIndex).map(s=>s.node).concat(e)}function gpe(){return!0}function KG(d){const{children:e,disableAutoFocus:t=!1,disableEnforceFocus:s=!1,disableRestoreFocus:i=!1,getTabbable:n=mpe,isEnabled:r=gpe,open:a}=d,o=B.useRef(!1),c=B.useRef(null),u=B.useRef(null),h=B.useRef(null),l=B.useRef(null),f=B.useRef(!1),p=B.useRef(null),m=Cs(e.ref,p),g=B.useRef(null);B.useEffect(()=>{!a||!p.current||(f.current=!t)},[t,a]),B.useEffect(()=>{if(!a||!p.current)return;const b=ba(p.current);return p.current.contains(b.activeElement)||(p.current.hasAttribute("tabIndex")||p.current.setAttribute("tabIndex","-1"),f.current&&p.current.focus()),()=>{i||(h.current&&h.current.focus&&(o.current=!0,h.current.focus()),h.current=null)}},[a]),B.useEffect(()=>{if(!a||!p.current)return;const b=ba(p.current),S=M=>{g.current=M,!(s||!r()||M.key!=="Tab")&&b.activeElement===p.current&&M.shiftKey&&(o.current=!0,u.current&&u.current.focus())},v=()=>{const M=p.current;if(M===null)return;if(!b.hasFocus()||!r()||o.current){o.current=!1;return}if(M.contains(b.activeElement)||s&&b.activeElement!==c.current&&b.activeElement!==u.current)return;if(b.activeElement!==l.current)l.current=null;else if(l.current!==null)return;if(!f.current)return;let _=[];if((b.activeElement===c.current||b.activeElement===u.current)&&(_=n(p.current)),_.length>0){var N,A;const R=!!((N=g.current)!=null&&N.shiftKey&&((A=g.current)==null?void 0:A.key)==="Tab"),D=_[0],U=_[_.length-1];typeof D!="string"&&typeof U!="string"&&(R?U.focus():D.focus())}else M.focus()};b.addEventListener("focusin",v),b.addEventListener("keydown",S,!0);const C=setInterval(()=>{b.activeElement&&b.activeElement.tagName==="BODY"&&v()},50);return()=>{clearInterval(C),b.removeEventListener("focusin",v),b.removeEventListener("keydown",S,!0)}},[t,s,i,r,a,n]);const y=b=>{h.current===null&&(h.current=b.relatedTarget),f.current=!0,l.current=b.target;const S=e.props.onFocus;S&&S(b)},w=b=>{h.current===null&&(h.current=b.relatedTarget),f.current=!0};return P.jsxs(B.Fragment,{children:[P.jsx("div",{tabIndex:a?0:-1,onFocus:w,ref:c,"data-testid":"sentinelStart"}),B.cloneElement(e,{ref:m,onFocus:y}),P.jsx("div",{tabIndex:a?0:-1,onFocus:w,ref:u,"data-testid":"sentinelEnd"})]})}function ype(d){return typeof d=="string"}function XG(d,e,t){return d===void 0||ype(d)?e:W({},e,{ownerState:W({},e.ownerState,t)})}function qq(d,e,t=(s,i)=>s===i){return d.length===e.length&&d.every((s,i)=>t(s,e[i]))}const wpe={disableDefaultClasses:!1},bpe=B.createContext(wpe);function kpe(d){const{disableDefaultClasses:e}=B.useContext(bpe);return t=>e?"":d(t)}function hn(d,e=[]){if(d===void 0)return{};const t={};return Object.keys(d).filter(s=>s.match(/^on[A-Z]/)&&typeof d[s]=="function"&&!e.includes(s)).forEach(s=>{t[s]=d[s]}),t}function QG(d,e,t){return typeof d=="function"?d(e,t):d}function Spe(d){const{rootElementName:e="",componentName:t}=d,[s,i]=B.useState(e.toUpperCase()),n=B.useCallback(r=>{var a;i((a=r==null?void 0:r.tagName)!=null?a:"")},[]);return[s,n]}function Vq(d){if(d===void 0)return{};const e={};return Object.keys(d).filter(t=>!(t.match(/^on[A-Z]/)&&typeof d[t]=="function")).forEach(t=>{e[t]=d[t]}),e}function YG(d){const{getSlotProps:e,additionalProps:t,externalSlotProps:s,externalForwardedProps:i,className:n}=d;if(!e){const f=Gt(t==null?void 0:t.className,n,i==null?void 0:i.className,s==null?void 0:s.className),p=W({},t==null?void 0:t.style,i==null?void 0:i.style,s==null?void 0:s.style),m=W({},t,i,s);return f.length>0&&(m.className=f),Object.keys(p).length>0&&(m.style=p),{props:m,internalRef:void 0}}const r=hn(W({},i,s)),a=Vq(s),o=Vq(i),c=e(r),u=Gt(c==null?void 0:c.className,t==null?void 0:t.className,n,i==null?void 0:i.className,s==null?void 0:s.className),h=W({},c==null?void 0:c.style,t==null?void 0:t.style,i==null?void 0:i.style,s==null?void 0:s.style),l=W({},c,t,o,a);return u.length>0&&(l.className=u),Object.keys(h).length>0&&(l.style=h),{props:l,internalRef:c.ref}}const vpe=["elementType","externalSlotProps","ownerState","skipResolvingSlotProps"];function ZG(d){var e;const{elementType:t,externalSlotProps:s,ownerState:i,skipResolvingSlotProps:n=!1}=d,r=at(d,vpe),a=n?{}:QG(s,i),{props:o,internalRef:c}=YG(W({},r,{externalSlotProps:a})),u=Cs(c,a==null?void 0:a.ref,(e=d.additionalProps)==null?void 0:e.ref);return XG(t,W({},o,{ref:u}),i)}function Tpe(d){const e=ba(d);return e.body===d?F0(d).innerWidth>e.documentElement.clientWidth:d.scrollHeight>d.clientHeight}function e0(d,e){e?d.setAttribute("aria-hidden","true"):d.removeAttribute("aria-hidden")}function Fq(d){return parseInt(F0(d).getComputedStyle(d).paddingRight,10)||0}function Ope(d){const t=["TEMPLATE","SCRIPT","STYLE","LINK","MAP","META","NOSCRIPT","PICTURE","COL","COLGROUP","PARAM","SLOT","SOURCE","TRACK"].indexOf(d.tagName)!==-1,s=d.tagName==="INPUT"&&d.getAttribute("type")==="hidden";return t||s}function Hq(d,e,t,s,i){const n=[e,t,...s];[].forEach.call(d.children,r=>{const a=n.indexOf(r)===-1,o=!Ope(r);a&&o&&e0(r,i)})}function wI(d,e){let t=-1;return d.some((s,i)=>e(s)?(t=i,!0):!1),t}function xpe(d,e){const t=[],s=d.container;if(!e.disableScrollLock){if(Tpe(s)){const r=voe(ba(s));t.push({value:s.style.paddingRight,property:"padding-right",el:s}),s.style.paddingRight=`${Fq(s)+r}px`;const a=ba(s).querySelectorAll(".mui-fixed");[].forEach.call(a,o=>{t.push({value:o.style.paddingRight,property:"padding-right",el:o}),o.style.paddingRight=`${Fq(o)+r}px`})}let n;if(s.parentNode instanceof DocumentFragment)n=ba(s).body;else{const r=s.parentElement,a=F0(s);n=(r==null?void 0:r.nodeName)==="HTML"&&a.getComputedStyle(r).overflowY==="scroll"?r:s}t.push({value:n.style.overflow,property:"overflow",el:n},{value:n.style.overflowX,property:"overflow-x",el:n},{value:n.style.overflowY,property:"overflow-y",el:n}),n.style.overflow="hidden"}return()=>{t.forEach(({value:n,el:r,property:a})=>{n?r.style.setProperty(a,n):r.style.removeProperty(a)})}}function Ppe(d){const e=[];return[].forEach.call(d.children,t=>{t.getAttribute("aria-hidden")==="true"&&e.push(t)}),e}class Ipe{constructor(){this.containers=void 0,this.modals=void 0,this.modals=[],this.containers=[]}add(e,t){let s=this.modals.indexOf(e);if(s!==-1)return s;s=this.modals.length,this.modals.push(e),e.modalRef&&e0(e.modalRef,!1);const i=Ppe(t);Hq(t,e.mount,e.modalRef,i,!0);const n=wI(this.containers,r=>r.container===t);return n!==-1?(this.containers[n].modals.push(e),s):(this.containers.push({modals:[e],container:t,restore:null,hiddenSiblings:i}),s)}mount(e,t){const s=wI(this.containers,n=>n.modals.indexOf(e)!==-1),i=this.containers[s];i.restore||(i.restore=xpe(i,t))}remove(e,t=!0){const s=this.modals.indexOf(e);if(s===-1)return s;const i=wI(this.containers,r=>r.modals.indexOf(e)!==-1),n=this.containers[i];if(n.modals.splice(n.modals.indexOf(e),1),this.modals.splice(s,1),n.modals.length===0)n.restore&&n.restore(),e.modalRef&&e0(e.modalRef,t),Hq(n.container,e.mount,e.modalRef,n.hiddenSiblings,!1),this.containers.splice(i,1);else{const r=n.modals[n.modals.length-1];r.modalRef&&e0(r.modalRef,!1)}return s}isTopModal(e){return this.modals.length>0&&this.modals[this.modals.length-1]===e}}function Cpe(d){return typeof d=="function"?d():d}function Mpe(d){return d?d.props.hasOwnProperty("in"):!1}const _pe=new Ipe;function JG(d){const{container:e,disableEscapeKeyDown:t=!1,disableScrollLock:s=!1,manager:i=_pe,closeAfterTransition:n=!1,onTransitionEnter:r,onTransitionExited:a,children:o,onClose:c,open:u,rootRef:h}=d,l=B.useRef({}),f=B.useRef(null),p=B.useRef(null),m=Cs(p,h),[g,y]=B.useState(!u),w=Mpe(o);let b=!0;(d["aria-hidden"]==="false"||d["aria-hidden"]===!1)&&(b=!1);const S=()=>ba(f.current),v=()=>(l.current.modalRef=p.current,l.current.mount=f.current,l.current),C=()=>{i.mount(v(),{disableScrollLock:s}),p.current&&(p.current.scrollTop=0)},M=Eo(()=>{const z=Cpe(e)||S().body;i.add(v(),z),p.current&&C()}),_=B.useCallback(()=>i.isTopModal(v()),[i]),N=Eo(z=>{f.current=z,z&&(u&&_()?C():p.current&&e0(p.current,b))}),A=B.useCallback(()=>{i.remove(v(),b)},[b,i]);B.useEffect(()=>()=>{A()},[A]),B.useEffect(()=>{u?M():(!w||!n)&&A()},[u,A,w,n,M]);const R=z=>J=>{var Y;(Y=z.onKeyDown)==null||Y.call(z,J),!(J.key!=="Escape"||J.which===229||!_())&&(t||(J.stopPropagation(),c&&c(J,"escapeKeyDown")))},D=z=>J=>{var Y;(Y=z.onClick)==null||Y.call(z,J),J.target===J.currentTarget&&c&&c(J,"backdropClick")};return{getRootProps:(z={})=>{const J=hn(d);delete J.onTransitionEnter,delete J.onTransitionExited;const Y=W({},J,z);return W({role:"presentation"},Y,{onKeyDown:R(Y),ref:m})},getBackdropProps:(z={})=>{const J=z;return W({"aria-hidden":!0},J,{onClick:D(J),open:u})},getTransitionProps:()=>{const z=()=>{y(!1),r&&r()},J=()=>{y(!0),a&&a(),n&&A()};return{onEnter:YD(z,o==null?void 0:o.props.onEnter),onExited:YD(J,o==null?void 0:o.props.onExited)}},rootRef:m,portalRef:N,isTopModal:_,exited:g,hasTransition:w}}const Ape=["className","elementType","ownerState","externalForwardedProps","getSlotOwnerState","internalForwardedProps"],Lpe=["component","slots","slotProps"],Bpe=["component"];function Fe(d,e){const{className:t,elementType:s,ownerState:i,externalForwardedProps:n,getSlotOwnerState:r,internalForwardedProps:a}=e,o=at(e,Ape),{component:c,slots:u={[d]:void 0},slotProps:h={[d]:void 0}}=n,l=at(n,Lpe),f=u[d]||s,p=QG(h[d],i),m=YG(W({className:t},o,{externalForwardedProps:d==="root"?l:void 0,externalSlotProps:p})),{props:{component:g},internalRef:y}=m,w=at(m.props,Bpe),b=Cs(y,p==null?void 0:p.ref,e.ref),S=r?r(w):{},v=W({},i,S),C=d==="root"?g||c:g,M=XG(f,W({},d==="root"&&!c&&!u[d]&&a,d!=="root"&&!u[d]&&a,w,C&&{as:C},{ref:b}),v);return Object.keys(S).forEach(_=>{delete M[_]}),[f,M]}function Npe(d){return Rt("MuiModal",d)}Dt("MuiModal",["root","hidden","backdrop"]);const HA=B.createContext(void 0),Epe=["children","container","disableAutoFocus","disableEnforceFocus","disableEscapeKeyDown","disablePortal","disableRestoreFocus","disableScrollLock","hideBackdrop","keepMounted","onClose","onKeyDown","open","component","slots","slotProps"],Rpe=d=>{const{open:e}=d;return Nt({root:["root",!e&&"hidden"],backdrop:["backdrop"]},Npe,{})},eU=_e("div")(({ownerState:d,theme:e})=>W({"--unstable_popup-zIndex":`calc(${e.vars.zIndex.modal} + 1)`,'& ~ [role="listbox"]':{"--unstable_popup-zIndex":`calc(${e.vars.zIndex.modal} + 1)`},position:"fixed",zIndex:e.vars.zIndex.modal,right:0,bottom:0,top:0,left:0},!d.open&&{visibility:"hidden"})),Dpe=_e(eU,{name:"JoyModal",slot:"Root",overridesResolver:(d,e)=>e.root})({}),tU=_e("div")(({theme:d})=>({zIndex:-1,position:"fixed",right:0,bottom:0,top:0,left:0,backgroundColor:d.vars.palette.background.backdrop,WebkitTapHighlightColor:"transparent",backdropFilter:"blur(8px)"})),qpe=_e(tU,{name:"JoyModal",slot:"Backdrop",overridesResolver:(d,e)=>e.backdrop})({}),tb=B.forwardRef(function(e,t){const s=qt({props:e,name:"JoyModal"}),{children:i,container:n,disableAutoFocus:r=!1,disableEnforceFocus:a=!1,disableEscapeKeyDown:o=!1,disablePortal:c=!1,disableRestoreFocus:u=!1,disableScrollLock:h=!1,hideBackdrop:l=!1,keepMounted:f=!1,onClose:p,open:m,component:g,slots:y={},slotProps:w={}}=s,b=at(s,Epe),S=W({},s,{disableAutoFocus:r,disableEnforceFocus:a,disableEscapeKeyDown:o,disablePortal:c,disableRestoreFocus:u,disableScrollLock:h,hideBackdrop:l,keepMounted:f}),{getRootProps:v,getBackdropProps:C,rootRef:M,portalRef:_,isTopModal:N}=JG(W({},S,{rootRef:t})),A=Rpe(S),R=W({},b,{component:g,slots:y,slotProps:w}),[D,U]=Fe("root",{ref:M,className:A.root,elementType:Dpe,externalForwardedProps:R,getSlotProps:v,ownerState:S}),[K,j]=Fe("backdrop",{className:A.backdrop,elementType:qpe,externalForwardedProps:R,getSlotProps:C,ownerState:S});return!f&&!m?null:P.jsx(HA.Provider,{value:p,children:P.jsx(FA,{ref:_,container:n,disablePortal:c,children:P.jsxs(D,W({},U,{children:[l?null:P.jsx(K,W({},j)),P.jsx(KG,{disableEnforceFocus:a,disableAutoFocus:r,disableRestoreFocus:u,isEnabled:N,open:m,children:B.Children.only(i)&&B.cloneElement(i,W({},i.props.tabIndex===void 0&&{tabIndex:-1}))})]}))})})}),sU="base";function Vpe(d){return`${sU}--${d}`}function Fpe(d,e){return`${sU}-${d}-${e}`}function iU(d,e){const t=i8[e];return t?Vpe(t):Fpe(d,e)}function Hpe(d,e){const t={};return e.forEach(s=>{t[s]=iU(d,s)}),t}function Jo(d={}){const{disabled:e=!1,focusableWhenDisabled:t,href:s,rootRef:i,tabIndex:n,to:r,type:a,rootElementName:o}=d,c=B.useRef(),[u,h]=B.useState(!1),{isFocusVisibleRef:l,onFocus:f,onBlur:p,ref:m}=mA(),[g,y]=B.useState(!1);e&&!t&&g&&y(!1),B.useEffect(()=>{l.current=g},[g,l]);const[w,b]=Spe({rootElementName:o??(s||r?"a":void 0),componentName:"Button"}),S=j=>z=>{var J;g&&z.preventDefault(),(J=j.onMouseLeave)==null||J.call(j,z)},v=j=>z=>{var J;p(z),l.current===!1&&y(!1),(J=j.onBlur)==null||J.call(j,z)},C=j=>z=>{var J;if(c.current||(c.current=z.currentTarget),f(z),l.current===!0){var Y;y(!0),(Y=j.onFocusVisible)==null||Y.call(j,z)}(J=j.onFocus)==null||J.call(j,z)},M=()=>{const j=c.current;return w==="BUTTON"||w==="INPUT"&&["button","submit","reset"].includes(j==null?void 0:j.type)||w==="A"&&(j==null?void 0:j.href)},_=j=>z=>{if(!e){var J;(J=j.onClick)==null||J.call(j,z)}},N=j=>z=>{var J;e||(h(!0),document.addEventListener("mouseup",()=>{h(!1)},{once:!0})),(J=j.onMouseDown)==null||J.call(j,z)},A=j=>z=>{var J;if((J=j.onKeyDown)==null||J.call(j,z),!z.defaultMuiPrevented&&(z.target===z.currentTarget&&!M()&&z.key===" "&&z.preventDefault(),z.target===z.currentTarget&&z.key===" "&&!e&&h(!0),z.target===z.currentTarget&&!M()&&z.key==="Enter"&&!e)){var Y;(Y=j.onClick)==null||Y.call(j,z),z.preventDefault()}},R=j=>z=>{var J;if(z.target===z.currentTarget&&h(!1),(J=j.onKeyUp)==null||J.call(j,z),z.target===z.currentTarget&&!M()&&!e&&z.key===" "&&!z.defaultMuiPrevented){var Y;(Y=j.onClick)==null||Y.call(j,z)}},D=Cs(b,i,m,c),U={};return n!==void 0&&(U.tabIndex=n),w==="BUTTON"?(U.type=a??"button",t?U["aria-disabled"]=e:U.disabled=e):w==="INPUT"?a&&["button","submit","reset"].includes(a)&&(t?U["aria-disabled"]=e:U.disabled=e):w!==""&&(!s&&!r&&(U.role="button",U.tabIndex=n??0),e&&(U["aria-disabled"]=e,U.tabIndex=t?n??0:-1)),{getRootProps:(j={})=>{const z=W({},hn(d),hn(j)),J=W({type:a},z,U,j,{onBlur:v(z),onClick:_(z),onFocus:C(z),onKeyDown:A(z),onKeyUp:R(z),onMouseDown:N(z),onMouseLeave:S(z),ref:D});return delete J.onFocusVisible,J},focusVisible:g,setFocusVisible:y,active:u,rootRef:D}}function Gq(d){return d.substring(2).toLowerCase()}function Gpe(d,e){return e.documentElement.clientWidth(setTimeout(()=>{o.current=!0},0),()=>{o.current=!1}),[]);const u=Cs(e.ref,a),h=Eo(p=>{const m=c.current;c.current=!1;const g=ba(a.current);if(!o.current||!a.current||"clientX"in p&&Gpe(p,g))return;if(r.current){r.current=!1;return}let y;p.composedPath?y=p.composedPath().indexOf(a.current)>-1:y=!g.documentElement.contains(p.target)||a.current.contains(p.target),!y&&(t||!m)&&i(p)}),l=p=>m=>{c.current=!0;const g=e.props[p];g&&g(m)},f={ref:u};return n!==!1&&(f[n]=l(n)),B.useEffect(()=>{if(n!==!1){const p=Gq(n),m=ba(a.current),g=()=>{r.current=!0};return m.addEventListener(p,h),m.addEventListener("touchmove",g),()=>{m.removeEventListener(p,h),m.removeEventListener("touchmove",g)}}},[h,n]),s!==!1&&(f[s]=l(s)),B.useEffect(()=>{if(s!==!1){const p=Gq(s),m=ba(a.current);return m.addEventListener(p,h),()=>{m.removeEventListener(p,h)}}},[h,s]),P.jsx(B.Fragment,{children:B.cloneElement(e,f)})}const dO=B.createContext(null);function Wpe(d,e){return d===e}const bI={},Uq=()=>{};function e2(d,e){const t=W({},d);return Object.keys(e).forEach(s=>{e[s]!==void 0&&(t[s]=e[s])}),t}function jpe(d){const{nextState:e,initialState:t,stateComparers:s,onStateChange:i,controlledProps:n,lastActionRef:r}=d,a=B.useRef(t);B.useEffect(()=>{if(r.current===null)return;const o=e2(a.current,n);Object.keys(e).forEach(c=>{var u;const h=(u=s[c])!=null?u:Wpe,l=e[c],f=o[c];if(f==null&&l!=null||f!=null&&l==null||f!=null&&l!=null&&!h(l,f)){var p,m;i==null||i((p=r.current.event)!=null?p:null,c,l,(m=r.current.type)!=null?m:"",e)}}),a.current=e,r.current=null},[a,e,r,i,s,n])}function nU(d){const e=B.useRef(null),{reducer:t,initialState:s,controlledProps:i=bI,stateComparers:n=bI,onStateChange:r=Uq,actionContext:a,componentName:o=""}=d;B.useRef(i);const c=B.useCallback((f,p)=>{e.current=p;const m=e2(f,i);return t(m,p)},[i,t]),[u,h]=B.useReducer(c,s),l=B.useCallback(f=>{h(W({},f,{context:a}))},[a]);return jpe({nextState:u,initialState:s,stateComparers:n??bI,onStateChange:r??Uq,controlledProps:i,lastActionRef:e}),[e2(u,i),l]}const Lo={blur:"dropdown:blur",escapeKeyDown:"dropdown:escapeKeyDown",toggle:"dropdown:toggle",open:"dropdown:open",close:"dropdown:close"};function zpe(d,e){switch(e.type){case Lo.blur:return{open:!1,changeReason:e.event};case Lo.escapeKeyDown:return{open:!1,changeReason:e.event};case Lo.toggle:return{open:!d.open,changeReason:e.event};case Lo.open:return{open:!0,changeReason:e.event};case Lo.close:return{open:!1,changeReason:e.event};default:throw new Error("Unhandled action")}}function $pe(d={}){const{defaultOpen:e,onOpenChange:t,open:s,componentName:i="useDropdown"}=d,[n,r]=B.useState(""),[a,o]=B.useState(null),c=B.useRef(null),u=B.useCallback((m,g,y,w)=>{g==="open"&&(t==null||t(m,y)),c.current=w},[t]),h=B.useMemo(()=>s!==void 0?{open:s}:{},[s]),[l,f]=nU({controlledProps:h,initialState:e?{open:!0,changeReason:null}:{open:!1,changeReason:null},onStateChange:u,reducer:zpe,componentName:i});return B.useEffect(()=>{!l.open&&c.current!==null&&c.current!==Lo.blur&&(a==null||a.focus())},[l.open,a]),{contextValue:{state:l,dispatch:f,popupId:n,registerPopup:r,registerTrigger:o,triggerElement:a},open:l.open}}function Kpe(d){const{children:e,open:t,defaultOpen:s,onOpenChange:i}=d,{contextValue:n}=$pe({defaultOpen:s,onOpenChange:i,open:t});return P.jsx(dO.Provider,{value:n,children:e})}const Xpe=B.createContext(void 0);function Qpe(){return B.useContext(Xpe)}function Ype(d={}){const{defaultValue:e,disabled:t=!1,error:s=!1,onBlur:i,onChange:n,onFocus:r,required:a=!1,value:o,inputRef:c}=d,u=Qpe();let h,l,f,p,m;if(u){var g,y,w;h=void 0,l=(g=u.disabled)!=null?g:!1,f=(y=u.error)!=null?y:!1,p=(w=u.required)!=null?w:!1,m=u.value}else h=e,l=t,f=s,p=a,m=o;const{current:b}=B.useRef(m!=null),S=B.useCallback(j=>{},[]),v=B.useRef(null),C=Cs(v,c,S),[M,_]=B.useState(!1);B.useEffect(()=>{!u&&l&&M&&(_(!1),i==null||i())},[u,l,M,i]);const N=j=>z=>{var J;if(u!=null&&u.disabled){z.stopPropagation();return}if((J=j.onFocus)==null||J.call(j,z),u&&u.onFocus){var Y;u==null||(Y=u.onFocus)==null||Y.call(u)}else _(!0)},A=j=>z=>{var J;(J=j.onBlur)==null||J.call(j,z),u&&u.onBlur?u.onBlur():_(!1)},R=j=>(z,...J)=>{var Y,X;if(!b&&(z.target||v.current)==null)throw new Error(R0(17));u==null||(Y=u.onChange)==null||Y.call(u,z),(X=j.onChange)==null||X.call(j,z,...J)},D=j=>z=>{var J;v.current&&z.currentTarget===z.target&&v.current.focus(),(J=j.onClick)==null||J.call(j,z)};return{disabled:l,error:f,focused:M,formControlContext:u,getInputProps:(j={})=>{const J=W({},{onBlur:i,onChange:n,onFocus:r},hn(j)),Y=W({},J,{onBlur:A(J),onChange:R(J),onFocus:N(J)});return W({},Y,{"aria-invalid":f||void 0,defaultValue:h,value:m,required:p,disabled:l},j,{ref:C},Y)},getRootProps:(j={})=>{const z=hn(d,["onBlur","onChange","onFocus"]),J=W({},z,hn(j));return W({},j,J,{onClick:D(J)})},inputRef:C,required:p,value:m}}const ei={blur:"list:blur",focus:"list:focus",itemClick:"list:itemClick",itemHover:"list:itemHover",itemsChange:"list:itemsChange",keyDown:"list:keyDown",resetHighlight:"list:resetHighlight",highlightLast:"list:highlightLast",textNavigation:"list:textNavigation",clearSelection:"list:clearSelection"};function Zpe(d,e,t,s,i,n){if(t.length===0||!s&&t.every((a,o)=>i(a,o)))return-1;let r=d;for(;;){if(!n&&e==="next"&&r===t.length||!n&&e==="previous"&&r===-1)return-1;if(s?!1:i(t[r],r))r+=e==="next"?1:-1,n&&(r=(r+t.length)%t.length);else return r}}function Sn(d,e,t){var s;const{items:i,isItemDisabled:n,disableListWrap:r,disabledItemsFocusable:a,itemComparer:o,focusManagement:c}=t,u=c==="DOM"?0:-1,h=i.length-1,l=d==null?-1:i.findIndex(y=>o(y,d));let f,p,m=!r;switch(e){case"reset":if(u===-1)return null;f=0,p="next",m=!1;break;case"start":f=0,p="next",m=!1;break;case"end":f=h,p="previous",m=!1;break;default:{const y=l+e;y<0?!m&&l!==-1||Math.abs(e)>1?(f=0,p="next"):(f=h,p="previous"):y>h?!m||Math.abs(e)>1?(f=h,p="previous"):(f=0,p="next"):(f=y,p=e>=0?"next":"previous")}}const g=Zpe(f,p,i,a,n,m);return g===-1&&d!==null&&!n(d,l)?d:(s=i[g])!=null?s:null}function Jpe(d,e,t,s){return t==="none"?[]:t==="single"?s(e[0],d)?e:[d]:e.some(i=>s(i,d))?e.filter(i=>!s(i,d)):[...e,d]}function GA(d,e,t){const{itemComparer:s,isItemDisabled:i,selectionMode:n,items:r}=t,{selectedValues:a}=e,o=r.findIndex(u=>s(d,u));if(i(d,o))return e;const c=Jpe(d,a,n,s);return W({},e,{selectedValues:c,highlightedValue:d})}function eme(d,e,t){const s=e.highlightedValue,{orientation:i,pageSize:n}=t;switch(d){case"Home":return W({},e,{highlightedValue:Sn(s,"start",t)});case"End":return W({},e,{highlightedValue:Sn(s,"end",t)});case"PageUp":return W({},e,{highlightedValue:Sn(s,-n,t)});case"PageDown":return W({},e,{highlightedValue:Sn(s,n,t)});case"ArrowUp":if(i!=="vertical")break;return W({},e,{highlightedValue:Sn(s,-1,t)});case"ArrowDown":if(i!=="vertical")break;return W({},e,{highlightedValue:Sn(s,1,t)});case"ArrowLeft":{if(i==="vertical")break;return W({},e,{highlightedValue:Sn(s,i==="horizontal-ltr"?-1:1,t)})}case"ArrowRight":{if(i==="vertical")break;return W({},e,{highlightedValue:Sn(s,i==="horizontal-ltr"?1:-1,t)})}case"Enter":case" ":return e.highlightedValue===null?e:GA(e.highlightedValue,e,t)}return e}function tme(d,e){return e.focusManagement==="DOM"?d:W({},d,{highlightedValue:null})}function sme(d,e,t){var s;const i=(s=t(d))==null?void 0:s.trim().toLowerCase();return!i||i.length===0?!1:i.indexOf(e)===0}function ime(d,e,t){const{items:s,isItemDisabled:i,disabledItemsFocusable:n,getItemAsString:r}=t,a=e.length>1;let o=a?d.highlightedValue:Sn(d.highlightedValue,1,t);for(let c=0;cn(h,t.highlightedValue)))!=null?o:null}else r==="DOM"&&e.length===0&&(a=Sn(null,"reset",s));const u=((i=t.selectedValues)!=null?i:[]).filter(h=>d.some(l=>n(l,h)));return W({},t,{highlightedValue:a,selectedValues:u})}function rme(d,e){return W({},d,{highlightedValue:Sn(null,"reset",e)})}function ame(d,e){return W({},d,{highlightedValue:Sn(null,"end",e)})}function ome(d,e){return W({},d,{selectedValues:[],highlightedValue:Sn(null,"reset",e)})}function cO(d,e){const{type:t,context:s}=e;switch(t){case ei.keyDown:return eme(e.key,d,s);case ei.itemClick:return GA(e.item,d,s);case ei.blur:return tme(d,s);case ei.textNavigation:return ime(d,e.searchString,s);case ei.itemsChange:return nme(e.items,e.previousItems,d,s);case ei.resetHighlight:return rme(d,s);case ei.highlightLast:return ame(d,s);case ei.clearSelection:return ome(d,s);default:return d}}const dme=500;function cme(d){const e=B.useRef({searchString:"",lastTime:null});return B.useCallback(t=>{if(t.key.length===1&&t.key!==" "){const s=e.current,i=t.key.toLowerCase(),n=performance.now();s.searchString.length>0&&s.lastTime&&n-s.lastTime>dme?s.searchString=i:(s.searchString.length!==1||i!==s.searchString)&&(s.searchString+=i),s.lastTime=n,d(s.searchString,t)}},[d])}const Wq={},ume=()=>{},hme=(d,e)=>d===e,lme=()=>!1,fme=d=>typeof d=="string"?d:String(d),pme=()=>({highlightedValue:null,selectedValues:[]});function UA(d){const{controlledProps:e=Wq,disabledItemsFocusable:t=!1,disableListWrap:s=!1,focusManagement:i="activeDescendant",getInitialState:n=pme,getItemDomElement:r,getItemId:a,isItemDisabled:o=lme,rootRef:c,onStateChange:u=ume,items:h,itemComparer:l=hme,getItemAsString:f=fme,onChange:p,onHighlightChange:m,onItemsChange:g,orientation:y="vertical",pageSize:w=5,reducerActionContext:b=Wq,selectionMode:S="single",stateReducer:v,componentName:C="useList"}=d,M=B.useRef(null),_=Cs(c,M),N=B.useCallback((fe,he,Se)=>{if(m==null||m(fe,he,Se),i==="DOM"&&he!=null&&(Se===ei.itemClick||Se===ei.keyDown||Se===ei.textNavigation)){var ye;r==null||(ye=r(he))==null||ye.focus()}},[r,m,i]),A=B.useMemo(()=>({highlightedValue:l,selectedValues:(fe,he)=>qq(fe,he,l)}),[l]),R=B.useCallback((fe,he,Se,ye,ge)=>{switch(u==null||u(fe,he,Se,ye,ge),he){case"highlightedValue":N(fe,Se,ye);break;case"selectedValues":p==null||p(fe,Se,ye);break}},[N,p,u]),D=B.useMemo(()=>({disabledItemsFocusable:t,disableListWrap:s,focusManagement:i,isItemDisabled:o,itemComparer:l,items:h,getItemAsString:f,onHighlightChange:N,orientation:y,pageSize:w,selectionMode:S,stateComparers:A}),[t,s,i,o,l,h,f,N,y,w,S,A]),U=n(),K=v??cO,j=B.useMemo(()=>W({},b,D),[b,D]),[z,J]=nU({reducer:K,actionContext:j,initialState:U,controlledProps:e,stateComparers:A,onStateChange:R,componentName:C}),{highlightedValue:Y,selectedValues:X}=z,Z=cme((fe,he)=>J({type:ei.textNavigation,event:he,searchString:fe})),te=B.useRef([]);B.useEffect(()=>{qq(te.current,h,l)||(J({type:ei.itemsChange,event:null,items:h,previousItems:te.current}),te.current=h,g==null||g(h))},[h,l,J,g]);const Q=fe=>he=>{var Se;if((Se=fe.onKeyDown)==null||Se.call(fe,he),he.defaultMuiPrevented)return;const ye=["Home","End","PageUp","PageDown"];y==="vertical"?ye.push("ArrowUp","ArrowDown"):ye.push("ArrowLeft","ArrowRight"),i==="activeDescendant"&&ye.push(" ","Enter"),ye.includes(he.key)&&he.preventDefault(),J({type:ei.keyDown,key:he.key,event:he}),Z(he)},ie=fe=>he=>{var Se,ye;(Se=fe.onBlur)==null||Se.call(fe,he),!he.defaultMuiPrevented&&((ye=M.current)!=null&&ye.contains(he.relatedTarget)||J({type:ei.blur,event:he}))},ne=(fe={})=>{const he=hn(fe);return W({},fe,{"aria-activedescendant":i==="activeDescendant"&&Y!=null?a(Y):void 0,tabIndex:i==="DOM"?-1:0,ref:_},he,{onBlur:ie(he),onKeyDown:Q(he)})},oe=B.useCallback(fe=>{const he=(X??[]).some(ge=>ge!=null&&l(fe,ge)),Se=Y!=null&&l(fe,Y);return{focusable:i==="DOM",highlighted:Se,selected:he}},[l,X,Y,i]),me=B.useMemo(()=>({dispatch:J,getItemState:oe}),[J,oe]);return B.useDebugValue({state:z}),{contextValue:me,dispatch:J,getRootProps:ne,rootRef:_,state:z}}const Eh=B.createContext(null);function WA(d){const{handlePointerOverEvents:e=!1,item:t}=d,s=B.useContext(Eh);if(!s)throw new Error("useListItem must be used within a ListProvider");const{dispatch:i,getItemState:n}=s,{highlighted:r,selected:a,focusable:o}=n(t),c=B.useCallback(f=>p=>{var m;(m=f.onClick)==null||m.call(f,p),!p.defaultPrevented&&i({type:ei.itemClick,item:t,event:p})},[i,t]),u=B.useCallback(f=>p=>{var m;(m=f.onMouseOver)==null||m.call(f,p),!p.defaultPrevented&&i({type:ei.itemHover,item:t,event:p})},[i,t]);let h;return o&&(h=r?0:-1),{getRootProps:(f={})=>{const p=hn(f);return W({},f,{onClick:c(p),onPointerOver:e?u(p):void 0,tabIndex:h})},highlighted:r,selected:a}}function mme(d,e){if(e.type===ei.itemHover)return W({},d,{highlightedValue:e.item});const t=cO(d,e);if(t.highlightedValue===null&&e.context.items.length>0)return W({},t,{highlightedValue:e.context.items[0]});if(e.type===ei.keyDown&&e.event.key==="Escape")return W({},t,{open:!1});if(e.type===ei.blur){var s;if(!((s=e.context.listboxRef.current)!=null&&s.contains(e.event.relatedTarget))){var i,n;const r=(i=e.context.listboxRef.current)==null?void 0:i.getAttribute("id"),a=(n=e.event.relatedTarget)==null?void 0:n.getAttribute("aria-controls");return r&&a&&r===a?t:W({},t,{open:!1,highlightedValue:e.context.items[0]})}}return t}const sb=B.createContext(null);function gme(d){const e=Array.from(d.keys()).map(t=>{const s=d.get(t);return{key:t,subitem:s}});return e.sort((t,s)=>{const i=t.subitem.ref.current,n=s.subitem.ref.current;return i===null||n===null||i===n?0:i.compareDocumentPosition(n)&Node.DOCUMENT_POSITION_PRECEDING?1:-1}),new Map(e.map(t=>[t.key,t.subitem]))}function uO(){const[d,e]=B.useState(new Map),t=B.useRef(new Set),s=B.useCallback(function(c){t.current.delete(c),e(u=>{const h=new Map(u);return h.delete(c),h})},[]),i=B.useCallback(function(c,u){let h;return typeof c=="function"?h=c(t.current):h=c,t.current.add(h),e(l=>{const f=new Map(l);return f.set(h,u),f}),{id:h,deregister:()=>s(h)}},[s]),n=B.useMemo(()=>gme(d),[d]),r=B.useCallback(function(c){return Array.from(n.keys()).indexOf(c)},[n]);return{contextValue:B.useMemo(()=>({getItemIndex:r,registerItem:i,totalSubitemCount:d.size}),[r,i,d.size]),subitems:n}}function jA(d,e){const t=B.useContext(sb);if(t===null)throw new Error("useCompoundItem must be used within a useCompoundParent");const{registerItem:s}=t,[i,n]=B.useState(typeof d=="function"?void 0:d);return jo(()=>{const{id:r,deregister:a}=s(d,e);return n(r),a},[s,e,d]),{id:i,index:i!==void 0?t.getItemIndex(i):-1,totalItemCount:t.totalSubitemCount}}function Kc(d,e){return function(s={}){const i=W({},s,d(s));return W({},i,e(i))}}const yme={dispatch:()=>{},popupId:"",registerPopup:()=>{},registerTrigger:()=>{},state:{open:!0,changeReason:null},triggerElement:null};function wme(d={}){var e,t;const{listboxRef:s,onItemsChange:i,id:n,disabledItemsFocusable:r=!0,disableListWrap:a=!1,autoFocus:o=!0,componentName:c="useMenu"}=d,u=B.useRef(null),h=Cs(u,s),l=(e=ln(n))!=null?e:"",{state:{open:f,changeReason:p},dispatch:m,triggerElement:g,registerPopup:y}=(t=B.useContext(dO))!=null?t:yme,w=B.useRef(f),{subitems:b,contextValue:S}=uO(),v=B.useMemo(()=>Array.from(b.keys()),[b]),C=B.useCallback(X=>{var Z,te;return X==null?null:(Z=(te=b.get(X))==null?void 0:te.ref.current)!=null?Z:null},[b]),M=B.useCallback(X=>{var Z;return(b==null||(Z=b.get(X))==null?void 0:Z.disabled)||!1},[b]),_=B.useCallback(X=>{var Z,te;return((Z=b.get(X))==null?void 0:Z.label)||((te=b.get(X))==null||(te=te.ref.current)==null?void 0:te.innerText)},[b]),N=B.useMemo(()=>({listboxRef:u}),[u]),{dispatch:A,getRootProps:R,contextValue:D,state:{highlightedValue:U},rootRef:K}=UA({disabledItemsFocusable:r,disableListWrap:a,focusManagement:"DOM",getItemDomElement:C,getInitialState:()=>({selectedValues:[],highlightedValue:null}),isItemDisabled:M,items:v,getItemAsString:_,rootRef:h,onItemsChange:i,reducerActionContext:N,selectionMode:"none",stateReducer:mme,componentName:c});jo(()=>{y(l)},[l,y]),jo(()=>{f&&(p==null?void 0:p.type)==="keydown"&&p.key==="ArrowUp"&&A({type:ei.highlightLast,event:p})},[f,p,A]),B.useEffect(()=>{if(f&&o&&U&&!w.current){var X;(X=b.get(U))==null||(X=X.ref)==null||(X=X.current)==null||X.focus()}},[f,o,U,b,v]),B.useEffect(()=>{var X;if((X=u.current)!=null&&X.contains(document.activeElement)&&U!==null){var Z;b==null||(Z=b.get(U))==null||(Z=Z.ref.current)==null||Z.focus()}},[U,b]);const j=X=>Z=>{var te,Q;(te=X.onBlur)==null||te.call(X,Z),!Z.defaultMuiPrevented&&((Q=u.current)!=null&&Q.contains(Z.relatedTarget)||Z.relatedTarget===g||m({type:Lo.blur,event:Z}))},z=X=>Z=>{var te;(te=X.onKeyDown)==null||te.call(X,Z),!Z.defaultMuiPrevented&&Z.key==="Escape"&&m({type:Lo.escapeKeyDown,event:Z})},J=(X={})=>({onBlur:j(X),onKeyDown:z(X)}),Y=(X={})=>{const Z=Kc(J,R),te=hn(X);return W({},X,te,Z(te),{id:l,role:"menu"})};return B.useDebugValue({subitems:b,highlightedValue:U}),{contextValue:W({},S,D),dispatch:A,getListboxProps:Y,highlightedValue:U,listboxRef:K,menuItems:b,open:f,triggerElement:g}}function bme(d){const{value:e,children:t}=d,{dispatch:s,getItemIndex:i,getItemState:n,registerItem:r,totalSubitemCount:a}=e,o=B.useMemo(()=>({dispatch:s,getItemState:n,getItemIndex:i}),[s,i,n]),c=B.useMemo(()=>({getItemIndex:i,registerItem:r,totalSubitemCount:a}),[r,i,a]);return P.jsx(sb.Provider,{value:c,children:P.jsx(Eh.Provider,{value:o,children:t})})}function kme(d={}){const{disabled:e=!1,focusableWhenDisabled:t,rootRef:s}=d,i=B.useContext(dO);if(i===null)throw new Error("useMenuButton: no menu context available.");const{state:n,dispatch:r,registerTrigger:a,popupId:o}=i,{getRootProps:c,rootRef:u,active:h}=Jo({disabled:e,focusableWhenDisabled:t,rootRef:s}),l=Cs(u,a),f=y=>w=>{var b;(b=y.onClick)==null||b.call(y,w),!w.defaultMuiPrevented&&r({type:Lo.toggle,event:w})},p=y=>w=>{var b;(b=y.onKeyDown)==null||b.call(y,w),!w.defaultMuiPrevented&&(w.key==="ArrowDown"||w.key==="ArrowUp")&&(w.preventDefault(),r({type:Lo.open,event:w}))},m=(y={})=>({onClick:f(y),onKeyDown:p(y)});return{active:h,getRootProps:(y={})=>{const w=hn(y),b=Kc(m,c);return W({"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o},y,w,b(w),{tabIndex:0,ref:l})},open:n.open,rootRef:l}}function Sme(d){return`menu-item-${d.size}`}const vme={dispatch:()=>{},popupId:"",registerPopup:()=>{},registerTrigger:()=>{},state:{open:!0,changeReason:null},triggerElement:null};function Tme(d){var e;const{disabled:t=!1,id:s,rootRef:i,label:n,disableFocusOnHover:r=!1}=d,a=ln(s),o=B.useRef(null),c=B.useMemo(()=>({disabled:t,id:a??"",label:n,ref:o}),[t,a,n]),{dispatch:u}=(e=B.useContext(dO))!=null?e:vme,{getRootProps:h,highlighted:l}=WA({item:a,handlePointerOverEvents:!r}),{index:f,totalItemCount:p}=jA(a??Sme,c),{getRootProps:m,focusVisible:g,rootRef:y}=Jo({disabled:t,focusableWhenDisabled:!0}),w=Cs(y,i,o);B.useDebugValue({id:a,highlighted:l,disabled:t,label:n});const b=C=>M=>{var _;(_=C.onClick)==null||_.call(C,M),!M.defaultMuiPrevented&&u({type:Lo.close,event:M})},S=(C={})=>W({},C,{onClick:b(C)});function v(C={}){const M=hn(C),_=Kc(S,Kc(m,h));return W({},C,M,_(M),{id:a,ref:w,role:"menuitem"})}return a===void 0?{getRootProps:v,disabled:!1,focusVisible:g,highlighted:!1,index:-1,totalItemCount:0,rootRef:w}:{getRootProps:v,disabled:t,focusVisible:g,highlighted:l,index:f,totalItemCount:p,rootRef:w}}function Ome(d){const e=B.useContext(Eh);if(!e)throw new Error("MenuItem: ListContext was not found.");const t=ln(d),{getItemState:s,dispatch:i}=e;let n;t!=null?n=s(t):n={focusable:!0,highlighted:!1,selected:!1};const{highlighted:r,selected:a,focusable:o}=n,c=B.useCallback(h=>{if(h!==t)throw new Error(["Base UI MenuItem: Tried to access the state of another MenuItem.",`itemValue: ${h} | id: ${t}`,"This is unsupported when the MenuItem uses the MenuItemContextStabilizer as a performance optimization."].join("/n"));return{highlighted:r,selected:a,focusable:o}},[r,a,o,t]);return{contextValue:B.useMemo(()=>({dispatch:i,getItemState:c}),[i,c]),id:t}}function xme(d){const{value:e,label:t,disabled:s,rootRef:i,id:n}=d,{getRootProps:r,highlighted:a,selected:o}=WA({item:e}),{getRootProps:c,rootRef:u}=Jo({disabled:s,focusableWhenDisabled:!0}),h=ln(n),l=B.useRef(null),f=B.useMemo(()=>({disabled:s,label:t,value:e,ref:l,id:h}),[s,t,e,h]),{index:p}=jA(e,f),m=Cs(i,l,u),g=w=>b=>{var S;(S=w.onKeyDown)==null||S.call(w,b),!b.defaultMuiPrevented&&[" ","Enter"].includes(b.key)&&(b.defaultMuiPrevented=!0)},y=(w={})=>({onKeyDown:g(w)});return{getRootProps:(w={})=>{const b=hn(w),S=Kc(r,Kc(c,y));return W({},w,b,S(b),{id:h,ref:m,role:"option","aria-selected":o})},highlighted:a,index:p,selected:o,rootRef:m}}function Pme(d){const e=B.useContext(Eh);if(!e)throw new Error("Option: ListContext was not found.");const{getItemState:t,dispatch:s}=e,{highlighted:i,selected:n,focusable:r}=t(d),a=B.useCallback(c=>{if(c!==d)throw new Error(["Base UI Option: Tried to access the state of another Option.","This is unsupported when the Option uses the OptionContextStabilizer as a performance optimization."].join("/n"));return{highlighted:i,selected:n,focusable:r}},[i,n,r,d]);return{contextValue:B.useMemo(()=>({dispatch:s,getItemState:a}),[s,a])}}var Ur="top",ho="bottom",lo="right",Wr="left",zA="auto",ib=[Ur,ho,lo,Wr],Nm="start",dw="end",Ime="clippingParents",rU="viewport",dy="popper",Cme="reference",jq=ib.reduce(function(d,e){return d.concat([e+"-"+Nm,e+"-"+dw])},[]),aU=[].concat(ib,[zA]).reduce(function(d,e){return d.concat([e,e+"-"+Nm,e+"-"+dw])},[]),Mme="beforeRead",_me="read",Ame="afterRead",Lme="beforeMain",Bme="main",Nme="afterMain",Eme="beforeWrite",Rme="write",Dme="afterWrite",qme=[Mme,_me,Ame,Lme,Bme,Nme,Eme,Rme,Dme];function Ud(d){return d?(d.nodeName||"").toLowerCase():null}function Pa(d){if(d==null)return window;if(d.toString()!=="[object Window]"){var e=d.ownerDocument;return e&&e.defaultView||window}return d}function Yl(d){var e=Pa(d).Element;return d instanceof e||d instanceof Element}function ao(d){var e=Pa(d).HTMLElement;return d instanceof e||d instanceof HTMLElement}function $A(d){if(typeof ShadowRoot>"u")return!1;var e=Pa(d).ShadowRoot;return d instanceof e||d instanceof ShadowRoot}function Vme(d){var e=d.state;Object.keys(e.elements).forEach(function(t){var s=e.styles[t]||{},i=e.attributes[t]||{},n=e.elements[t];!ao(n)||!Ud(n)||(Object.assign(n.style,s),Object.keys(i).forEach(function(r){var a=i[r];a===!1?n.removeAttribute(r):n.setAttribute(r,a===!0?"":a)}))})}function Fme(d){var e=d.state,t={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(e.elements.popper.style,t.popper),e.styles=t,e.elements.arrow&&Object.assign(e.elements.arrow.style,t.arrow),function(){Object.keys(e.elements).forEach(function(s){var i=e.elements[s],n=e.attributes[s]||{},r=Object.keys(e.styles.hasOwnProperty(s)?e.styles[s]:t[s]),a=r.reduce(function(o,c){return o[c]="",o},{});!ao(i)||!Ud(i)||(Object.assign(i.style,a),Object.keys(n).forEach(function(o){i.removeAttribute(o)}))})}}const Hme={name:"applyStyles",enabled:!0,phase:"write",fn:Vme,effect:Fme,requires:["computeStyles"]};function qd(d){return d.split("-")[0]}var Rl=Math.max,vv=Math.min,Em=Math.round;function t2(){var d=navigator.userAgentData;return d!=null&&d.brands&&Array.isArray(d.brands)?d.brands.map(function(e){return e.brand+"/"+e.version}).join(" "):navigator.userAgent}function oU(){return!/^((?!chrome|android).)*safari/i.test(t2())}function Rm(d,e,t){e===void 0&&(e=!1),t===void 0&&(t=!1);var s=d.getBoundingClientRect(),i=1,n=1;e&&ao(d)&&(i=d.offsetWidth>0&&Em(s.width)/d.offsetWidth||1,n=d.offsetHeight>0&&Em(s.height)/d.offsetHeight||1);var r=Yl(d)?Pa(d):window,a=r.visualViewport,o=!oU()&&t,c=(s.left+(o&&a?a.offsetLeft:0))/i,u=(s.top+(o&&a?a.offsetTop:0))/n,h=s.width/i,l=s.height/n;return{width:h,height:l,top:u,right:c+h,bottom:u+l,left:c,x:c,y:u}}function KA(d){var e=Rm(d),t=d.offsetWidth,s=d.offsetHeight;return Math.abs(e.width-t)<=1&&(t=e.width),Math.abs(e.height-s)<=1&&(s=e.height),{x:d.offsetLeft,y:d.offsetTop,width:t,height:s}}function dU(d,e){var t=e.getRootNode&&e.getRootNode();if(d.contains(e))return!0;if(t&&$A(t)){var s=e;do{if(s&&d.isSameNode(s))return!0;s=s.parentNode||s.host}while(s)}return!1}function Xc(d){return Pa(d).getComputedStyle(d)}function Gme(d){return["table","td","th"].indexOf(Ud(d))>=0}function Rh(d){return((Yl(d)?d.ownerDocument:d.document)||window.document).documentElement}function hO(d){return Ud(d)==="html"?d:d.assignedSlot||d.parentNode||($A(d)?d.host:null)||Rh(d)}function zq(d){return!ao(d)||Xc(d).position==="fixed"?null:d.offsetParent}function Ume(d){var e=/firefox/i.test(t2()),t=/Trident/i.test(t2());if(t&&ao(d)){var s=Xc(d);if(s.position==="fixed")return null}var i=hO(d);for($A(i)&&(i=i.host);ao(i)&&["html","body"].indexOf(Ud(i))<0;){var n=Xc(i);if(n.transform!=="none"||n.perspective!=="none"||n.contain==="paint"||["transform","perspective"].indexOf(n.willChange)!==-1||e&&n.willChange==="filter"||e&&n.filter&&n.filter!=="none")return i;i=i.parentNode}return null}function nb(d){for(var e=Pa(d),t=zq(d);t&&Gme(t)&&Xc(t).position==="static";)t=zq(t);return t&&(Ud(t)==="html"||Ud(t)==="body"&&Xc(t).position==="static")?e:t||Ume(d)||e}function XA(d){return["top","bottom"].indexOf(d)>=0?"x":"y"}function t0(d,e,t){return Rl(d,vv(e,t))}function Wme(d,e,t){var s=t0(d,e,t);return s>t?t:s}function cU(){return{top:0,right:0,bottom:0,left:0}}function uU(d){return Object.assign({},cU(),d)}function hU(d,e){return e.reduce(function(t,s){return t[s]=d,t},{})}var jme=function(e,t){return e=typeof e=="function"?e(Object.assign({},t.rects,{placement:t.placement})):e,uU(typeof e!="number"?e:hU(e,ib))};function zme(d){var e,t=d.state,s=d.name,i=d.options,n=t.elements.arrow,r=t.modifiersData.popperOffsets,a=qd(t.placement),o=XA(a),c=[Wr,lo].indexOf(a)>=0,u=c?"height":"width";if(!(!n||!r)){var h=jme(i.padding,t),l=KA(n),f=o==="y"?Ur:Wr,p=o==="y"?ho:lo,m=t.rects.reference[u]+t.rects.reference[o]-r[o]-t.rects.popper[u],g=r[o]-t.rects.reference[o],y=nb(n),w=y?o==="y"?y.clientHeight||0:y.clientWidth||0:0,b=m/2-g/2,S=h[f],v=w-l[u]-h[p],C=w/2-l[u]/2+b,M=t0(S,C,v),_=o;t.modifiersData[s]=(e={},e[_]=M,e.centerOffset=M-C,e)}}function $me(d){var e=d.state,t=d.options,s=t.element,i=s===void 0?"[data-popper-arrow]":s;i!=null&&(typeof i=="string"&&(i=e.elements.popper.querySelector(i),!i)||dU(e.elements.popper,i)&&(e.elements.arrow=i))}const Kme={name:"arrow",enabled:!0,phase:"main",fn:zme,effect:$me,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function Dm(d){return d.split("-")[1]}var Xme={top:"auto",right:"auto",bottom:"auto",left:"auto"};function Qme(d,e){var t=d.x,s=d.y,i=e.devicePixelRatio||1;return{x:Em(t*i)/i||0,y:Em(s*i)/i||0}}function $q(d){var e,t=d.popper,s=d.popperRect,i=d.placement,n=d.variation,r=d.offsets,a=d.position,o=d.gpuAcceleration,c=d.adaptive,u=d.roundOffsets,h=d.isFixed,l=r.x,f=l===void 0?0:l,p=r.y,m=p===void 0?0:p,g=typeof u=="function"?u({x:f,y:m}):{x:f,y:m};f=g.x,m=g.y;var y=r.hasOwnProperty("x"),w=r.hasOwnProperty("y"),b=Wr,S=Ur,v=window;if(c){var C=nb(t),M="clientHeight",_="clientWidth";if(C===Pa(t)&&(C=Rh(t),Xc(C).position!=="static"&&a==="absolute"&&(M="scrollHeight",_="scrollWidth")),C=C,i===Ur||(i===Wr||i===lo)&&n===dw){S=ho;var N=h&&C===v&&v.visualViewport?v.visualViewport.height:C[M];m-=N-s.height,m*=o?1:-1}if(i===Wr||(i===Ur||i===ho)&&n===dw){b=lo;var A=h&&C===v&&v.visualViewport?v.visualViewport.width:C[_];f-=A-s.width,f*=o?1:-1}}var R=Object.assign({position:a},c&&Xme),D=u===!0?Qme({x:f,y:m},Pa(t)):{x:f,y:m};if(f=D.x,m=D.y,o){var U;return Object.assign({},R,(U={},U[S]=w?"0":"",U[b]=y?"0":"",U.transform=(v.devicePixelRatio||1)<=1?"translate("+f+"px, "+m+"px)":"translate3d("+f+"px, "+m+"px, 0)",U))}return Object.assign({},R,(e={},e[S]=w?m+"px":"",e[b]=y?f+"px":"",e.transform="",e))}function Yme(d){var e=d.state,t=d.options,s=t.gpuAcceleration,i=s===void 0?!0:s,n=t.adaptive,r=n===void 0?!0:n,a=t.roundOffsets,o=a===void 0?!0:a,c={placement:qd(e.placement),variation:Dm(e.placement),popper:e.elements.popper,popperRect:e.rects.popper,gpuAcceleration:i,isFixed:e.options.strategy==="fixed"};e.modifiersData.popperOffsets!=null&&(e.styles.popper=Object.assign({},e.styles.popper,$q(Object.assign({},c,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:r,roundOffsets:o})))),e.modifiersData.arrow!=null&&(e.styles.arrow=Object.assign({},e.styles.arrow,$q(Object.assign({},c,{offsets:e.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:o})))),e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-placement":e.placement})}const Zme={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:Yme,data:{}};var cS={passive:!0};function Jme(d){var e=d.state,t=d.instance,s=d.options,i=s.scroll,n=i===void 0?!0:i,r=s.resize,a=r===void 0?!0:r,o=Pa(e.elements.popper),c=[].concat(e.scrollParents.reference,e.scrollParents.popper);return n&&c.forEach(function(u){u.addEventListener("scroll",t.update,cS)}),a&&o.addEventListener("resize",t.update,cS),function(){n&&c.forEach(function(u){u.removeEventListener("scroll",t.update,cS)}),a&&o.removeEventListener("resize",t.update,cS)}}const ege={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:Jme,data:{}};var tge={left:"right",right:"left",bottom:"top",top:"bottom"};function d1(d){return d.replace(/left|right|bottom|top/g,function(e){return tge[e]})}var sge={start:"end",end:"start"};function Kq(d){return d.replace(/start|end/g,function(e){return sge[e]})}function QA(d){var e=Pa(d),t=e.pageXOffset,s=e.pageYOffset;return{scrollLeft:t,scrollTop:s}}function YA(d){return Rm(Rh(d)).left+QA(d).scrollLeft}function ige(d,e){var t=Pa(d),s=Rh(d),i=t.visualViewport,n=s.clientWidth,r=s.clientHeight,a=0,o=0;if(i){n=i.width,r=i.height;var c=oU();(c||!c&&e==="fixed")&&(a=i.offsetLeft,o=i.offsetTop)}return{width:n,height:r,x:a+YA(d),y:o}}function nge(d){var e,t=Rh(d),s=QA(d),i=(e=d.ownerDocument)==null?void 0:e.body,n=Rl(t.scrollWidth,t.clientWidth,i?i.scrollWidth:0,i?i.clientWidth:0),r=Rl(t.scrollHeight,t.clientHeight,i?i.scrollHeight:0,i?i.clientHeight:0),a=-s.scrollLeft+YA(d),o=-s.scrollTop;return Xc(i||t).direction==="rtl"&&(a+=Rl(t.clientWidth,i?i.clientWidth:0)-n),{width:n,height:r,x:a,y:o}}function ZA(d){var e=Xc(d),t=e.overflow,s=e.overflowX,i=e.overflowY;return/auto|scroll|overlay|hidden/.test(t+i+s)}function lU(d){return["html","body","#document"].indexOf(Ud(d))>=0?d.ownerDocument.body:ao(d)&&ZA(d)?d:lU(hO(d))}function s0(d,e){var t;e===void 0&&(e=[]);var s=lU(d),i=s===((t=d.ownerDocument)==null?void 0:t.body),n=Pa(s),r=i?[n].concat(n.visualViewport||[],ZA(s)?s:[]):s,a=e.concat(r);return i?a:a.concat(s0(hO(r)))}function s2(d){return Object.assign({},d,{left:d.x,top:d.y,right:d.x+d.width,bottom:d.y+d.height})}function rge(d,e){var t=Rm(d,!1,e==="fixed");return t.top=t.top+d.clientTop,t.left=t.left+d.clientLeft,t.bottom=t.top+d.clientHeight,t.right=t.left+d.clientWidth,t.width=d.clientWidth,t.height=d.clientHeight,t.x=t.left,t.y=t.top,t}function Xq(d,e,t){return e===rU?s2(ige(d,t)):Yl(e)?rge(e,t):s2(nge(Rh(d)))}function age(d){var e=s0(hO(d)),t=["absolute","fixed"].indexOf(Xc(d).position)>=0,s=t&&ao(d)?nb(d):d;return Yl(s)?e.filter(function(i){return Yl(i)&&dU(i,s)&&Ud(i)!=="body"}):[]}function oge(d,e,t,s){var i=e==="clippingParents"?age(d):[].concat(e),n=[].concat(i,[t]),r=n[0],a=n.reduce(function(o,c){var u=Xq(d,c,s);return o.top=Rl(u.top,o.top),o.right=vv(u.right,o.right),o.bottom=vv(u.bottom,o.bottom),o.left=Rl(u.left,o.left),o},Xq(d,r,s));return a.width=a.right-a.left,a.height=a.bottom-a.top,a.x=a.left,a.y=a.top,a}function fU(d){var e=d.reference,t=d.element,s=d.placement,i=s?qd(s):null,n=s?Dm(s):null,r=e.x+e.width/2-t.width/2,a=e.y+e.height/2-t.height/2,o;switch(i){case Ur:o={x:r,y:e.y-t.height};break;case ho:o={x:r,y:e.y+e.height};break;case lo:o={x:e.x+e.width,y:a};break;case Wr:o={x:e.x-t.width,y:a};break;default:o={x:e.x,y:e.y}}var c=i?XA(i):null;if(c!=null){var u=c==="y"?"height":"width";switch(n){case Nm:o[c]=o[c]-(e[u]/2-t[u]/2);break;case dw:o[c]=o[c]+(e[u]/2-t[u]/2);break}}return o}function cw(d,e){e===void 0&&(e={});var t=e,s=t.placement,i=s===void 0?d.placement:s,n=t.strategy,r=n===void 0?d.strategy:n,a=t.boundary,o=a===void 0?Ime:a,c=t.rootBoundary,u=c===void 0?rU:c,h=t.elementContext,l=h===void 0?dy:h,f=t.altBoundary,p=f===void 0?!1:f,m=t.padding,g=m===void 0?0:m,y=uU(typeof g!="number"?g:hU(g,ib)),w=l===dy?Cme:dy,b=d.rects.popper,S=d.elements[p?w:l],v=oge(Yl(S)?S:S.contextElement||Rh(d.elements.popper),o,u,r),C=Rm(d.elements.reference),M=fU({reference:C,element:b,strategy:"absolute",placement:i}),_=s2(Object.assign({},b,M)),N=l===dy?_:C,A={top:v.top-N.top+y.top,bottom:N.bottom-v.bottom+y.bottom,left:v.left-N.left+y.left,right:N.right-v.right+y.right},R=d.modifiersData.offset;if(l===dy&&R){var D=R[i];Object.keys(A).forEach(function(U){var K=[lo,ho].indexOf(U)>=0?1:-1,j=[Ur,ho].indexOf(U)>=0?"y":"x";A[U]+=D[j]*K})}return A}function dge(d,e){e===void 0&&(e={});var t=e,s=t.placement,i=t.boundary,n=t.rootBoundary,r=t.padding,a=t.flipVariations,o=t.allowedAutoPlacements,c=o===void 0?aU:o,u=Dm(s),h=u?a?jq:jq.filter(function(p){return Dm(p)===u}):ib,l=h.filter(function(p){return c.indexOf(p)>=0});l.length===0&&(l=h);var f=l.reduce(function(p,m){return p[m]=cw(d,{placement:m,boundary:i,rootBoundary:n,padding:r})[qd(m)],p},{});return Object.keys(f).sort(function(p,m){return f[p]-f[m]})}function cge(d){if(qd(d)===zA)return[];var e=d1(d);return[Kq(d),e,Kq(e)]}function uge(d){var e=d.state,t=d.options,s=d.name;if(!e.modifiersData[s]._skip){for(var i=t.mainAxis,n=i===void 0?!0:i,r=t.altAxis,a=r===void 0?!0:r,o=t.fallbackPlacements,c=t.padding,u=t.boundary,h=t.rootBoundary,l=t.altBoundary,f=t.flipVariations,p=f===void 0?!0:f,m=t.allowedAutoPlacements,g=e.options.placement,y=qd(g),w=y===g,b=o||(w||!p?[d1(g)]:cge(g)),S=[g].concat(b).reduce(function(ne,oe){return ne.concat(qd(oe)===zA?dge(e,{placement:oe,boundary:u,rootBoundary:h,padding:c,flipVariations:p,allowedAutoPlacements:m}):oe)},[]),v=e.rects.reference,C=e.rects.popper,M=new Map,_=!0,N=S[0],A=0;A=0,j=K?"width":"height",z=cw(e,{placement:R,boundary:u,rootBoundary:h,altBoundary:l,padding:c}),J=K?U?lo:Wr:U?ho:Ur;v[j]>C[j]&&(J=d1(J));var Y=d1(J),X=[];if(n&&X.push(z[D]<=0),a&&X.push(z[J]<=0,z[Y]<=0),X.every(function(ne){return ne})){N=R,_=!1;break}M.set(R,X)}if(_)for(var Z=p?3:1,te=function(oe){var me=S.find(function(fe){var he=M.get(fe);if(he)return he.slice(0,oe).every(function(Se){return Se})});if(me)return N=me,"break"},Q=Z;Q>0;Q--){var ie=te(Q);if(ie==="break")break}e.placement!==N&&(e.modifiersData[s]._skip=!0,e.placement=N,e.reset=!0)}}const hge={name:"flip",enabled:!0,phase:"main",fn:uge,requiresIfExists:["offset"],data:{_skip:!1}};function Qq(d,e,t){return t===void 0&&(t={x:0,y:0}),{top:d.top-e.height-t.y,right:d.right-e.width+t.x,bottom:d.bottom-e.height+t.y,left:d.left-e.width-t.x}}function Yq(d){return[Ur,lo,ho,Wr].some(function(e){return d[e]>=0})}function lge(d){var e=d.state,t=d.name,s=e.rects.reference,i=e.rects.popper,n=e.modifiersData.preventOverflow,r=cw(e,{elementContext:"reference"}),a=cw(e,{altBoundary:!0}),o=Qq(r,s),c=Qq(a,i,n),u=Yq(o),h=Yq(c);e.modifiersData[t]={referenceClippingOffsets:o,popperEscapeOffsets:c,isReferenceHidden:u,hasPopperEscaped:h},e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-reference-hidden":u,"data-popper-escaped":h})}const fge={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:lge};function pge(d,e,t){var s=qd(d),i=[Wr,Ur].indexOf(s)>=0?-1:1,n=typeof t=="function"?t(Object.assign({},e,{placement:d})):t,r=n[0],a=n[1];return r=r||0,a=(a||0)*i,[Wr,lo].indexOf(s)>=0?{x:a,y:r}:{x:r,y:a}}function mge(d){var e=d.state,t=d.options,s=d.name,i=t.offset,n=i===void 0?[0,0]:i,r=aU.reduce(function(u,h){return u[h]=pge(h,e.rects,n),u},{}),a=r[e.placement],o=a.x,c=a.y;e.modifiersData.popperOffsets!=null&&(e.modifiersData.popperOffsets.x+=o,e.modifiersData.popperOffsets.y+=c),e.modifiersData[s]=r}const gge={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:mge};function yge(d){var e=d.state,t=d.name;e.modifiersData[t]=fU({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})}const wge={name:"popperOffsets",enabled:!0,phase:"read",fn:yge,data:{}};function bge(d){return d==="x"?"y":"x"}function kge(d){var e=d.state,t=d.options,s=d.name,i=t.mainAxis,n=i===void 0?!0:i,r=t.altAxis,a=r===void 0?!1:r,o=t.boundary,c=t.rootBoundary,u=t.altBoundary,h=t.padding,l=t.tether,f=l===void 0?!0:l,p=t.tetherOffset,m=p===void 0?0:p,g=cw(e,{boundary:o,rootBoundary:c,padding:h,altBoundary:u}),y=qd(e.placement),w=Dm(e.placement),b=!w,S=XA(y),v=bge(S),C=e.modifiersData.popperOffsets,M=e.rects.reference,_=e.rects.popper,N=typeof m=="function"?m(Object.assign({},e.rects,{placement:e.placement})):m,A=typeof N=="number"?{mainAxis:N,altAxis:N}:Object.assign({mainAxis:0,altAxis:0},N),R=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,D={x:0,y:0};if(C){if(n){var U,K=S==="y"?Ur:Wr,j=S==="y"?ho:lo,z=S==="y"?"height":"width",J=C[S],Y=J+g[K],X=J-g[j],Z=f?-_[z]/2:0,te=w===Nm?M[z]:_[z],Q=w===Nm?-_[z]:-M[z],ie=e.elements.arrow,ne=f&&ie?KA(ie):{width:0,height:0},oe=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:cU(),me=oe[K],fe=oe[j],he=t0(0,M[z],ne[z]),Se=b?M[z]/2-Z-he-me-A.mainAxis:te-he-me-A.mainAxis,ye=b?-M[z]/2+Z+he+fe+A.mainAxis:Q+he+fe+A.mainAxis,ge=e.elements.arrow&&nb(e.elements.arrow),Te=ge?S==="y"?ge.clientTop||0:ge.clientLeft||0:0,Ge=(U=R==null?void 0:R[S])!=null?U:0,Ye=J+Se-Ge-Te,Re=J+ye-Ge,Be=t0(f?vv(Y,Ye):Y,J,f?Rl(X,Re):X);C[S]=Be,D[S]=Be-J}if(a){var Me,Le=S==="x"?Ur:Wr,rt=S==="x"?ho:lo,ze=C[v],Ue=v==="y"?"height":"width",Je=ze+g[Le],st=ze-g[rt],ut=[Ur,Wr].indexOf(y)!==-1,yt=(Me=R==null?void 0:R[v])!=null?Me:0,Bt=ut?Je:ze-M[Ue]-_[Ue]-yt+A.altAxis,lt=ut?ze+M[Ue]+_[Ue]-yt-A.altAxis:st,ht=f&&ut?Wme(Bt,ze,lt):t0(f?Bt:Je,ze,f?lt:st);C[v]=ht,D[v]=ht-ze}e.modifiersData[s]=D}}const Sge={name:"preventOverflow",enabled:!0,phase:"main",fn:kge,requiresIfExists:["offset"]};function vge(d){return{scrollLeft:d.scrollLeft,scrollTop:d.scrollTop}}function Tge(d){return d===Pa(d)||!ao(d)?QA(d):vge(d)}function Oge(d){var e=d.getBoundingClientRect(),t=Em(e.width)/d.offsetWidth||1,s=Em(e.height)/d.offsetHeight||1;return t!==1||s!==1}function xge(d,e,t){t===void 0&&(t=!1);var s=ao(e),i=ao(e)&&Oge(e),n=Rh(e),r=Rm(d,i,t),a={scrollLeft:0,scrollTop:0},o={x:0,y:0};return(s||!s&&!t)&&((Ud(e)!=="body"||ZA(n))&&(a=Tge(e)),ao(e)?(o=Rm(e,!0),o.x+=e.clientLeft,o.y+=e.clientTop):n&&(o.x=YA(n))),{x:r.left+a.scrollLeft-o.x,y:r.top+a.scrollTop-o.y,width:r.width,height:r.height}}function Pge(d){var e=new Map,t=new Set,s=[];d.forEach(function(n){e.set(n.name,n)});function i(n){t.add(n.name);var r=[].concat(n.requires||[],n.requiresIfExists||[]);r.forEach(function(a){if(!t.has(a)){var o=e.get(a);o&&i(o)}}),s.push(n)}return d.forEach(function(n){t.has(n.name)||i(n)}),s}function Ige(d){var e=Pge(d);return qme.reduce(function(t,s){return t.concat(e.filter(function(i){return i.phase===s}))},[])}function Cge(d){var e;return function(){return e||(e=new Promise(function(t){Promise.resolve().then(function(){e=void 0,t(d())})})),e}}function Mge(d){var e=d.reduce(function(t,s){var i=t[s.name];return t[s.name]=i?Object.assign({},i,s,{options:Object.assign({},i.options,s.options),data:Object.assign({},i.data,s.data)}):s,t},{});return Object.keys(e).map(function(t){return e[t]})}var Zq={placement:"bottom",modifiers:[],strategy:"absolute"};function Jq(){for(var d=arguments.length,e=new Array(d),t=0;tNt({root:["root"]},kpe(Lge)),qge={},Vge=B.forwardRef(function(e,t){var s;const{anchorEl:i,children:n,direction:r,disablePortal:a,modifiers:o,open:c,placement:u,popperOptions:h,popperRef:l,slotProps:f={},slots:p={},TransitionProps:m}=e,g=at(e,Bge),y=B.useRef(null),w=Cs(y,t),b=B.useRef(null),S=Cs(b,l),v=B.useRef(S);jo(()=>{v.current=S},[S]),B.useImperativeHandle(l,()=>b.current,[]);const C=Ege(u,r),[M,_]=B.useState(C),[N,A]=B.useState(i2(i));B.useEffect(()=>{b.current&&b.current.forceUpdate()}),B.useEffect(()=>{i&&A(i2(i))},[i]),jo(()=>{if(!N||!c)return;const j=Y=>{_(Y.placement)};let z=[{name:"preventOverflow",options:{altBoundary:a}},{name:"flip",options:{altBoundary:a}},{name:"onUpdate",enabled:!0,phase:"afterWrite",fn:({state:Y})=>{j(Y)}}];o!=null&&(z=z.concat(o)),h&&h.modifiers!=null&&(z=z.concat(h.modifiers));const J=pU(N,y.current,W({placement:C},h,{modifiers:z}));return v.current(J),()=>{J.destroy(),v.current(null)}},[N,a,o,c,h,C]);const R={placement:M};m!==null&&(R.TransitionProps=m);const D=Dge(),U=(s=p.root)!=null?s:"div",K=ZG({elementType:U,externalSlotProps:f.root,externalForwardedProps:g,additionalProps:{role:"tooltip",ref:w},ownerState:e,className:D.root});return P.jsx(U,W({},K,{children:typeof n=="function"?n(R):n}))}),lO=B.forwardRef(function(e,t){const{anchorEl:s,children:i,container:n,direction:r="ltr",disablePortal:a=!1,keepMounted:o=!1,modifiers:c,open:u,placement:h="bottom",popperOptions:l=qge,popperRef:f,style:p,transition:m=!1,slotProps:g={},slots:y={}}=e,w=at(e,Nge),[b,S]=B.useState(!0),v=()=>{S(!1)},C=()=>{S(!0)};if(!o&&!u&&(!m||b))return null;let M;if(n)M=n;else if(s){const A=i2(s);M=A&&Rge(A)?ba(A).body:ba(null).body}const _=!u&&o&&(!m||b)?"none":void 0,N=m?{in:u,onEnter:v,onExited:C}:void 0;return P.jsx(FA,{disablePortal:a,container:M,children:P.jsx(Vge,W({anchorEl:s,direction:r,disablePortal:a,modifiers:c,ref:t,open:m?!b:u,placement:h,popperOptions:l,popperRef:f,slotProps:g,slots:y},w,{style:W({position:"fixed",top:0,left:0,display:_},p),TransitionProps:N,children:i}))})}),Tv={buttonClick:"buttonClick",browserAutoFill:"browserAutoFill"},Fge=d=>{const{label:e,value:t}=d;return typeof e=="string"?e:typeof t=="string"?t:String(d)};function Hge(d,e){const{open:t}=d,{context:{selectionMode:s}}=e;if(e.type===Tv.buttonClick){var i;const o=(i=d.selectedValues[0])!=null?i:Sn(null,"start",e.context);return W({},d,{open:!t,highlightedValue:t?null:o})}if(e.type===Tv.browserAutoFill)return GA(e.item,d,e.context);const n=cO(d,e);switch(e.type){case ei.keyDown:if(d.open){if(e.event.key==="Escape")return W({},n,{open:!1})}else{if(e.event.key==="ArrowDown"){var r;return W({},d,{open:!0,highlightedValue:(r=d.selectedValues[0])!=null?r:Sn(null,"start",e.context)})}if(e.event.key==="ArrowUp"){var a;return W({},d,{open:!0,highlightedValue:(a=d.selectedValues[0])!=null?a:Sn(null,"end",e.context)})}}break;case ei.itemClick:if(s==="single")return W({},n,{open:!1});break;case ei.blur:return W({},n,{open:!1});default:return n}return n}function Gge(d){return Array.isArray(d)?d.length===0?"":JSON.stringify(d.map(e=>e.value)):(d==null?void 0:d.value)==null?"":typeof d.value=="string"||typeof d.value=="number"?d.value:JSON.stringify(d.value)}function Uge(d){const{areOptionsEqual:e,buttonRef:t,defaultOpen:s=!1,defaultValue:i,disabled:n=!1,listboxId:r,listboxRef:a,multiple:o=!1,name:c,required:u,onChange:h,onHighlightChange:l,onOpenChange:f,open:p,options:m,getOptionAsString:g=Fge,getSerializedValue:y=Gge,value:w,componentName:b="useSelect"}=d,S=B.useRef(null),v=Cs(t,S),C=B.useRef(null),M=ln(r);let _;w===void 0&&i===void 0?_=[]:i!==void 0&&(o?_=i:_=i==null?[]:[i]);const N=B.useMemo(()=>{if(w!==void 0)return o?w:w==null?[]:[w]},[w,o]),{subitems:A,contextValue:R}=uO(),D=B.useMemo(()=>m!=null?new Map(m.map((V,re)=>[V.value,{value:V.value,label:V.label,disabled:V.disabled,ref:B.createRef(),id:`${M}_${re}`}])):A,[m,A,M]),U=Cs(a,C),{getRootProps:K,active:j,focusVisible:z,rootRef:J}=Jo({disabled:n,rootRef:v}),Y=B.useMemo(()=>Array.from(D.keys()),[D]),X=B.useCallback(V=>{if(e!==void 0){const re=Y.find(le=>e(le,V));return D.get(re)}return D.get(V)},[D,e,Y]),Z=B.useCallback(V=>{var re;const le=X(V);return(re=le==null?void 0:le.disabled)!=null?re:!1},[X]),te=B.useCallback(V=>{const re=X(V);return re?g(re):""},[X,g]),Q=B.useMemo(()=>({selectedValues:N,open:p}),[N,p]),ie=B.useCallback(V=>{var re;return(re=D.get(V))==null?void 0:re.id},[D]),ne=B.useCallback((V,re)=>{if(o)h==null||h(V,re);else{var le;h==null||h(V,(le=re[0])!=null?le:null)}},[o,h]),oe=B.useCallback((V,re)=>{l==null||l(V,re??null)},[l]),me=B.useCallback((V,re,le)=>{if(re==="open"&&(f==null||f(le),le===!1&&(V==null?void 0:V.type)!=="blur")){var ke;(ke=S.current)==null||ke.focus()}},[f]),fe=B.useCallback(V=>{var re,le;return V==null?null:(re=(le=A.get(V))==null?void 0:le.ref.current)!=null?re:null},[A]),he={getInitialState:()=>{var V;return{highlightedValue:null,selectedValues:(V=_)!=null?V:[],open:s}},getItemId:ie,controlledProps:Q,focusManagement:"DOM",getItemDomElement:fe,itemComparer:e,isItemDisabled:Z,rootRef:U,onChange:ne,onHighlightChange:oe,onStateChange:me,reducerActionContext:B.useMemo(()=>({multiple:o}),[o]),items:Y,getItemAsString:te,selectionMode:o?"multiple":"single",stateReducer:Hge,componentName:b},{dispatch:Se,getRootProps:ye,contextValue:ge,state:{open:Te,highlightedValue:Ge,selectedValues:Ye},rootRef:Re}=UA(he),Be=B.useRef(Te);jo(()=>{if(Te&&Ge!==null){var V;const re=(V=X(Ge))==null?void 0:V.ref;if(!C.current||!(re!=null&&re.current))return;Be.current||re.current.focus({preventScroll:!0});const le=C.current.getBoundingClientRect(),ke=re.current.getBoundingClientRect();ke.tople.bottom&&(C.current.scrollTop+=ke.bottom-le.bottom)}},[Te,Ge,X]);const Me=B.useCallback(V=>X(V),[X]),Le=V=>re=>{var le;if(V==null||(le=V.onClick)==null||le.call(V,re),!re.defaultMuiPrevented){const ke={type:Tv.buttonClick,event:re};Se(ke)}},rt=V=>re=>{var le;(le=V.onKeyDown)==null||le.call(V,re),!re.defaultMuiPrevented&&(re.key==="ArrowDown"||re.key==="ArrowUp")&&(re.preventDefault(),Se({type:ei.keyDown,key:re.key,event:re}))},ze=(V={})=>({onClick:Le(V),onKeyDown:rt(V)}),Ue=(V={})=>W({},V,ze(V),{role:"combobox","aria-expanded":Te,"aria-controls":M}),Je=(V={})=>{const re=hn(V),le=Kc(Ue,K);return W({},V,le(re))},st=V=>re=>{var le,ke;(le=V.onBlur)==null||le.call(V,re),!re.defaultMuiPrevented&&((ke=C.current)!=null&&ke.contains(re.relatedTarget)||re.relatedTarget===S.current)&&(re.defaultMuiPrevented=!0)},ut=(V={})=>({onBlur:st(V)}),yt=(V={})=>{const re=hn(V),le=Kc(ut,ye);return W({id:M,role:"listbox","aria-multiselectable":o?"true":void 0},V,le(re))};B.useDebugValue({selectedOptions:Ye,highlightedOption:Ge,open:Te});const Bt=B.useMemo(()=>W({},ge,R),[ge,R]);let lt;d.multiple?lt=Ye:lt=Ye.length>0?Ye[0]:null;let ht;if(o)ht=lt.map(V=>Me(V)).filter(V=>V!==void 0);else{var ft;ht=(ft=Me(lt))!=null?ft:null}const se=V=>re=>{var le;if(V==null||(le=V.onChange)==null||le.call(V,re),re.defaultMuiPrevented)return;const ke=D.get(re.target.value);re.target.value===""?Se({type:ei.clearSelection}):ke!==void 0&&Se({type:Tv.browserAutoFill,item:ke.value,event:re})};return{buttonActive:j,buttonFocusVisible:z,buttonRef:J,contextValue:Bt,disabled:n,dispatch:Se,getButtonProps:Je,getHiddenInputProps:(V={})=>{const re=hn(V);return W({name:c,tabIndex:-1,"aria-hidden":!0,required:u?!0:void 0,value:y(ht),style:Ooe},V,{onChange:se(re)})},getListboxProps:yt,getOptionMetadata:Me,listboxRef:Re,open:Te,options:Y,value:lt,highlightedOption:Ge}}function Wge(d){const{value:e,children:t}=d,{dispatch:s,getItemIndex:i,getItemState:n,registerItem:r,totalSubitemCount:a}=e,o=B.useMemo(()=>({dispatch:s,getItemState:n,getItemIndex:i}),[s,i,n]),c=B.useMemo(()=>({getItemIndex:i,registerItem:r,totalSubitemCount:a}),[r,i,a]);return P.jsx(sb.Provider,{value:c,children:P.jsx(Eh.Provider,{value:o,children:t})})}function jge(d={}){const{autoHideDuration:e=null,disableWindowBlurListener:t=!1,onClose:s,open:i,resumeHideDuration:n}=d,r=My();B.useEffect(()=>{if(!i)return;function y(w){w.defaultPrevented||(w.key==="Escape"||w.key==="Esc")&&(s==null||s(w,"escapeKeyDown"))}return document.addEventListener("keydown",y),()=>{document.removeEventListener("keydown",y)}},[i,s]);const a=Eo((y,w)=>{s==null||s(y,w)}),o=Eo(y=>{!s||y==null||r.start(y,()=>{a(null,"timeout")})});B.useEffect(()=>(i&&o(e),r.clear),[i,e,o,r]);const c=y=>{s==null||s(y,"clickaway")},u=r.clear,h=B.useCallback(()=>{e!=null&&o(n??e*.5)},[e,n,o]),l=y=>w=>{const b=y.onBlur;b==null||b(w),h()},f=y=>w=>{const b=y.onFocus;b==null||b(w),u()},p=y=>w=>{const b=y.onMouseEnter;b==null||b(w),u()},m=y=>w=>{const b=y.onMouseLeave;b==null||b(w),h()};return B.useEffect(()=>{if(!t&&i)return window.addEventListener("focus",h),window.addEventListener("blur",u),()=>{window.removeEventListener("focus",h),window.removeEventListener("blur",u)}},[t,i,h,u]),{getRootProps:(y={})=>{const w=W({},hn(d),hn(y));return W({role:"presentation"},y,w,{onBlur:l(w),onFocus:f(w),onMouseEnter:p(w),onMouseLeave:m(w)})},onClickAway:c}}function JA(d){const{checked:e,defaultChecked:t,disabled:s,onBlur:i,onChange:n,onFocus:r,onFocusVisible:a,readOnly:o,required:c}=d,[u,h]=ch({controlled:e,default:!!t,name:"Switch",state:"checked"}),l=_=>N=>{var A;N.nativeEvent.defaultPrevented||(h(N.target.checked),n==null||n(N),(A=_.onChange)==null||A.call(_,N))},{isFocusVisibleRef:f,onBlur:p,onFocus:m,ref:g}=mA(),[y,w]=B.useState(!1);s&&y&&w(!1),B.useEffect(()=>{f.current=y},[y,f]);const b=B.useRef(null),S=_=>N=>{var A;b.current||(b.current=N.currentTarget),m(N),f.current===!0&&(w(!0),a==null||a(N)),r==null||r(N),(A=_.onFocus)==null||A.call(_,N)},v=_=>N=>{var A;p(N),f.current===!1&&w(!1),i==null||i(N),(A=_.onBlur)==null||A.call(_,N)},C=Cs(g,b);return{checked:u,disabled:!!s,focusVisible:y,getInputProps:(_={})=>W({checked:e,defaultChecked:t,disabled:s,readOnly:o,ref:C,required:c,type:"checkbox",role:"switch","aria-checked":e},_,{onChange:l(_),onFocus:S(_),onBlur:v(_)}),inputRef:C,readOnly:!!o}}function zge(d){const{value:e,defaultValue:t,onChange:s,orientation:i="horizontal",direction:n="ltr",selectionFollowsFocus:r=!1}=d,[a,o]=ch({controlled:e,default:t,name:"Tabs",state:"value"}),c=B.useCallback((g,y)=>{o(y),s==null||s(g,y)},[s,o]),{subitems:u,contextValue:h}=uO(),l=B.useRef(()=>{}),f=B.useCallback(g=>{var y;return(y=u.get(g))==null?void 0:y.id},[u]),p=B.useCallback(g=>l.current(g),[]),m=B.useCallback(g=>{l.current=g},[]);return{contextValue:W({direction:n,getTabId:p,getTabPanelId:f,onSelected:c,orientation:i,registerTabIdLookup:m,selectionFollowsFocus:r,value:a},h)}}const gU=B.createContext(null);function yU(){const d=B.useContext(gU);if(d==null)throw new Error("No TabsContext provided");return d}function $ge(d){const{value:e,children:t}=d,{direction:s,getItemIndex:i,onSelected:n,orientation:r,registerItem:a,registerTabIdLookup:o,selectionFollowsFocus:c,totalSubitemCount:u,value:h,getTabId:l,getTabPanelId:f}=e,p=B.useMemo(()=>({getItemIndex:i,registerItem:a,totalSubitemCount:u}),[a,i,u]),m=B.useMemo(()=>({direction:s,getTabId:l,getTabPanelId:f,onSelected:n,orientation:r,registerTabIdLookup:o,selectionFollowsFocus:c,value:h}),[s,l,f,n,r,o,c,h]);return P.jsx(sb.Provider,{value:p,children:P.jsx(gU.Provider,{value:m,children:t})})}const wU={valueChange:"valueChange"};function Kge(d,e){if(e.type===wU.valueChange)return W({},d,{highlightedValue:e.value});const t=cO(d,e),{context:{selectionFollowsFocus:s}}=e;if(e.type===ei.itemsChange){if(t.selectedValues.length>0)return W({},t,{highlightedValue:t.selectedValues[0]});Sn(null,"reset",e.context)}return s&&t.highlightedValue!=null?W({},t,{selectedValues:[t.highlightedValue]}):t}function Xge(d){var e;const{rootRef:t}=d,{direction:s="ltr",onSelected:i,orientation:n="horizontal",value:r,registerTabIdLookup:a,selectionFollowsFocus:o}=yU(),{subitems:c,contextValue:u}=uO(),h=B.useCallback(R=>{var D;return(D=c.get(R))==null?void 0:D.id},[c]);a(h);const l=B.useMemo(()=>Array.from(c.keys()),[c]),f=B.useCallback(R=>{var D,U;return R==null?null:(D=(U=c.get(R))==null?void 0:U.ref.current)!=null?D:null},[c]),p=s==="rtl";let m;n==="vertical"?m="vertical":m=p?"horizontal-rtl":"horizontal-ltr";const g=B.useCallback((R,D)=>{var U;i(R,(U=D[0])!=null?U:null)},[i]),y=B.useMemo(()=>r===void 0?{}:r!=null?{selectedValues:[r]}:{selectedValues:[]},[r]),w=B.useCallback(R=>{var D,U;return(D=(U=c.get(R))==null?void 0:U.disabled)!=null?D:!1},[c]),{contextValue:b,dispatch:S,getRootProps:v,state:{highlightedValue:C,selectedValues:M},rootRef:_}=UA({controlledProps:y,disabledItemsFocusable:!o,focusManagement:"DOM",getItemDomElement:f,isItemDisabled:w,items:l,rootRef:t,onChange:g,orientation:m,reducerActionContext:B.useMemo(()=>({selectionFollowsFocus:o||!1}),[o]),selectionMode:"single",stateReducer:Kge});B.useEffect(()=>{r!==void 0&&r!=null&&S({type:wU.valueChange,value:r})},[S,r]);const N=(R={})=>W({},R,v(R),{"aria-orientation":n==="vertical"?"vertical":void 0,role:"tablist"});return{contextValue:B.useMemo(()=>W({},u,b),[u,b]),dispatch:S,getRootProps:N,highlightedValue:C,isRtl:p,orientation:n,rootRef:_,selectedValue:(e=M[0])!=null?e:null}}function Qge(d){const{value:e,children:t}=d,{dispatch:s,getItemIndex:i,getItemState:n,registerItem:r,totalSubitemCount:a}=e,o=B.useMemo(()=>({dispatch:s,getItemState:n,getItemIndex:i}),[s,i,n]),c=B.useMemo(()=>({getItemIndex:i,registerItem:r,totalSubitemCount:a}),[r,i,a]);return P.jsx(sb.Provider,{value:c,children:P.jsx(Eh.Provider,{value:o,children:t})})}function Yge(d){return d.size}function Zge(d){const{value:e,rootRef:t,disabled:s=!1,id:i}=d,n=B.useRef(null),r=ln(i),{value:a,selectionFollowsFocus:o,getTabPanelId:c}=yU(),u=B.useMemo(()=>({disabled:s,ref:n,id:r}),[s,n,r]),{id:h,index:l,totalItemCount:f}=jA(e??Yge,u),{getRootProps:p,highlighted:m,selected:g}=WA({item:h}),{getRootProps:y,rootRef:w,active:b,focusVisible:S,setFocusVisible:v}=Jo({disabled:s,focusableWhenDisabled:!o,type:"button"}),C=Cs(n,t,w),M=h!==void 0?c(h):void 0;return{getRootProps:(N={})=>{const A=hn(N),R=Kc(p,y);return W({},N,R(A),{role:"tab","aria-controls":M,"aria-selected":g,id:r,ref:C})},active:b,focusVisible:S,highlighted:m,index:l,rootRef:C,selected:g||h===a,setFocusVisible:v,totalTabsCount:f}}const Jge=["onChange","maxRows","minRows","style","value"];function uS(d){return parseInt(d,10)||0}const eye={shadow:{visibility:"hidden",position:"absolute",overflow:"hidden",height:0,top:0,left:0,transform:"translateZ(0)"}};function tye(d){return d==null||Object.keys(d).length===0||d.outerHeightStyle===0&&!d.overflowing}const sye=B.forwardRef(function(e,t){const{onChange:s,maxRows:i,minRows:n=1,style:r,value:a}=e,o=at(e,Jge),{current:c}=B.useRef(a!=null),u=B.useRef(null),h=Cs(t,u),l=B.useRef(null),f=B.useCallback(()=>{const g=u.current,w=F0(g).getComputedStyle(g);if(w.width==="0px")return{outerHeightStyle:0,overflowing:!1};const b=l.current;b.style.width=w.width,b.value=g.value||e.placeholder||"x",b.value.slice(-1)===` + */var Yw=B;function Ode(d,e){return d===e&&(d!==0||1/d===1/e)||d!==d&&e!==e}var xde=typeof Object.is=="function"?Object.is:Ode,Pde=Yw.useSyncExternalStore,Ide=Yw.useRef,Cde=Yw.useEffect,Mde=Yw.useMemo,_de=Yw.useDebugValue;g8.useSyncExternalStoreWithSelector=function(d,e,t,s,i){var n=Ide(null);if(n.current===null){var r={hasValue:!1,value:null};n.current=r}else r=n.current;n=Mde(function(){function o(f){if(!c){if(c=!0,u=f,f=s(f),i!==void 0&&r.hasValue){var p=r.value;if(i(p,f))return h=p}return h=f}if(p=h,xde(u,f))return p;var m=s(f);return i!==void 0&&i(p,m)?(u=f,p):(u=f,h=m)}var c=!1,u,h,l=t===void 0?null:t;return[function(){return o(e())},l===null?void 0:function(){return o(l())}]},[e,t,s,i]);var a=Pde(d,n[0],n[1]);return Cde(function(){r.hasValue=!0,r.value=a},[a]),_de(a),a};m8.exports=g8;var Ade=m8.exports;function Lde(d){d()}function Bde(){let d=null,e=null;return{clear(){d=null,e=null},notify(){Lde(()=>{let t=d;for(;t;)t.callback(),t=t.next})},get(){const t=[];let s=d;for(;s;)t.push(s),s=s.next;return t},subscribe(t){let s=!0;const i=e={callback:t,next:null,prev:e};return i.prev?i.prev.next=i:d=i,function(){!s||d===null||(s=!1,i.next?i.next.prev=i.prev:e=i.prev,i.prev?i.prev.next=i.next:d=i.next)}}}}var dq={notify(){},get:()=>[]};function Nde(d,e){let t,s=dq,i=0,n=!1;function r(m){u();const g=s.subscribe(m);let y=!1;return()=>{y||(y=!0,g(),h())}}function a(){s.notify()}function o(){p.onStateChange&&p.onStateChange()}function c(){return n}function u(){i++,t||(t=d.subscribe(o),s=Bde())}function h(){i--,t&&i===0&&(t(),t=void 0,s.clear(),s=dq)}function l(){n||(n=!0,u())}function f(){n&&(n=!1,h())}const p={addNestedSub:r,notifyNestedSubs:a,handleChangeWrapper:o,isSubscribed:c,trySubscribe:l,tryUnsubscribe:f,getListeners:()=>s};return p}var Ede=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Rde=Ede(),Dde=()=>typeof navigator<"u"&&navigator.product==="ReactNative",qde=Dde(),Vde=()=>Rde||qde?B.useLayoutEffect:B.useEffect,Fde=Vde(),aI=Symbol.for("react-redux-context"),oI=typeof globalThis<"u"?globalThis:{};function Hde(){if(!B.createContext)return{};const d=oI[aI]??(oI[aI]=new Map);let e=d.get(B.createContext);return e||(e=B.createContext(null),d.set(B.createContext,e)),e}var wh=Hde();function Gde(d){const{children:e,context:t,serverState:s,store:i}=d,n=B.useMemo(()=>{const o=Nde(i);return{store:i,subscription:o,getServerState:s?()=>s:void 0}},[i,s]),r=B.useMemo(()=>i.getState(),[i]);Fde(()=>{const{subscription:o}=n;return o.onStateChange=o.notifyNestedSubs,o.trySubscribe(),r!==i.getState()&&o.notifyNestedSubs(),()=>{o.tryUnsubscribe(),o.onStateChange=void 0}},[n,r]);const a=t||wh;return B.createElement(a.Provider,{value:n},e)}var y8=Gde;function TA(d=wh){return function(){return B.useContext(d)}}var w8=TA();function OA(d=wh){const e=d===wh?w8:TA(d),t=()=>{const{store:s}=e();return s};return Object.assign(t,{withTypes:()=>t}),t}var Ude=OA();function b8(d=wh){const e=d===wh?Ude:OA(d),t=()=>e().dispatch;return Object.assign(t,{withTypes:()=>t}),t}var Wde=b8(),jde=(d,e)=>d===e;function k8(d=wh){const e=d===wh?w8:TA(d),t=(s,i={})=>{const{equalityFn:n=jde}=typeof i=="function"?{equalityFn:i}:i,r=e(),{store:a,subscription:o,getServerState:c}=r;B.useRef(!0);const u=B.useCallback({[s.name](l){return s(l)}}[s.name],[s]),h=Ade.useSyncExternalStoreWithSelector(o.addNestedSub,a.getState,c||a.getState,u,n);return B.useDebugValue(h),h};return Object.assign(t,{withTypes:()=>t}),t}var zde=k8();function $de(d){return d&&d.__esModule&&Object.prototype.hasOwnProperty.call(d,"default")?d.default:d}var S8={exports:{}},Qi=S8.exports={},bd,kd;function IM(){throw new Error("setTimeout has not been defined")}function CM(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?bd=setTimeout:bd=IM}catch{bd=IM}try{typeof clearTimeout=="function"?kd=clearTimeout:kd=CM}catch{kd=CM}})();function v8(d){if(bd===setTimeout)return setTimeout(d,0);if((bd===IM||!bd)&&setTimeout)return bd=setTimeout,setTimeout(d,0);try{return bd(d,0)}catch{try{return bd.call(null,d,0)}catch{return bd.call(this,d,0)}}}function Kde(d){if(kd===clearTimeout)return clearTimeout(d);if((kd===CM||!kd)&&clearTimeout)return kd=clearTimeout,clearTimeout(d);try{return kd(d)}catch{try{return kd.call(null,d)}catch{return kd.call(this,d)}}}var Mc=[],tm=!1,Ol,n1=-1;function Xde(){!tm||!Ol||(tm=!1,Ol.length?Mc=Ol.concat(Mc):n1=-1,Mc.length&&T8())}function T8(){if(!tm){var d=v8(Xde);tm=!0;for(var e=Mc.length;e;){for(Ol=Mc,Mc=[];++n11)for(var t=1;tMath.random().toString(36).substring(7).split("").join("."),Zde={INIT:`@@redux/INIT${dI()}`,REPLACE:`@@redux/REPLACE${dI()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${dI()}`},rv=Zde;function xA(d){if(typeof d!="object"||d===null)return!1;let e=d;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(d)===e||Object.getPrototypeOf(d)===null}function x8(d,e,t){if(typeof d!="function")throw new Error(Dn(2));if(typeof e=="function"&&typeof t=="function"||typeof t=="function"&&typeof arguments[3]=="function")throw new Error(Dn(0));if(typeof e=="function"&&typeof t>"u"&&(t=e,e=void 0),typeof t<"u"){if(typeof t!="function")throw new Error(Dn(1));return t(x8)(d,e)}let s=d,i=e,n=new Map,r=n,a=0,o=!1;function c(){r===n&&(r=new Map,n.forEach((g,y)=>{r.set(y,g)}))}function u(){if(o)throw new Error(Dn(3));return i}function h(g){if(typeof g!="function")throw new Error(Dn(4));if(o)throw new Error(Dn(5));let y=!0;c();const w=a++;return r.set(w,g),function(){if(y){if(o)throw new Error(Dn(6));y=!1,c(),r.delete(w),n=null}}}function l(g){if(!xA(g))throw new Error(Dn(7));if(typeof g.type>"u")throw new Error(Dn(8));if(typeof g.type!="string")throw new Error(Dn(17));if(o)throw new Error(Dn(9));try{o=!0,i=s(i,g)}finally{o=!1}return(n=r).forEach(w=>{w()}),g}function f(g){if(typeof g!="function")throw new Error(Dn(10));s=g,l({type:rv.REPLACE})}function p(){const g=h;return{subscribe(y){if(typeof y!="object"||y===null)throw new Error(Dn(11));function w(){const S=y;S.next&&S.next(u())}return w(),{unsubscribe:g(w)}},[cq](){return this}}}return l({type:rv.INIT}),{dispatch:l,subscribe:h,getState:u,replaceReducer:f,[cq]:p}}function Jde(d){Object.keys(d).forEach(e=>{const t=d[e];if(typeof t(void 0,{type:rv.INIT})>"u")throw new Error(Dn(12));if(typeof t(void 0,{type:rv.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(Dn(13))})}function ece(d){const e=Object.keys(d),t={};for(let n=0;n"u")throw a&&a.type,new Error(Dn(14));c[h]=p,o=o||p!==f}return o=o||s.length!==Object.keys(r).length,o?c:r}}function av(...d){return d.length===0?e=>e:d.length===1?d[0]:d.reduce((e,t)=>(...s)=>e(t(...s)))}function tce(...d){return e=>(t,s)=>{const i=e(t,s);let n=()=>{throw new Error(Dn(15))};const r={getState:i.getState,dispatch:(o,...c)=>n(o,...c)},a=d.map(o=>o(r));return n=av(...a)(i.dispatch),{...i,dispatch:n}}}function sce(d){return xA(d)&&"type"in d&&typeof d.type=="string"}var P8=Symbol.for("immer-nothing"),uq=Symbol.for("immer-draftable"),Oa=Symbol.for("immer-state");function Ao(d,...e){throw new Error(`[Immer] minified error nr: ${d}. Full error at: https://bit.ly/3cXEKWf`)}var Cm=Object.getPrototypeOf;function jl(d){return!!d&&!!d[Oa]}function zc(d){var e;return d?I8(d)||Array.isArray(d)||!!d[uq]||!!((e=d.constructor)!=null&&e[uq])||zT(d)||$T(d):!1}var ice=Object.prototype.constructor.toString();function I8(d){if(!d||typeof d!="object")return!1;const e=Cm(d);if(e===null)return!0;const t=Object.hasOwnProperty.call(e,"constructor")&&e.constructor;return t===Object?!0:typeof t=="function"&&Function.toString.call(t)===ice}function ov(d,e){jT(d)===0?Reflect.ownKeys(d).forEach(t=>{e(t,d[t],d)}):d.forEach((t,s)=>e(s,t,d))}function jT(d){const e=d[Oa];return e?e.type_:Array.isArray(d)?1:zT(d)?2:$T(d)?3:0}function MM(d,e){return jT(d)===2?d.has(e):Object.prototype.hasOwnProperty.call(d,e)}function C8(d,e,t){const s=jT(d);s===2?d.set(e,t):s===3?d.add(t):d[e]=t}function nce(d,e){return d===e?d!==0||1/d===1/e:d!==d&&e!==e}function zT(d){return d instanceof Map}function $T(d){return d instanceof Set}function ll(d){return d.copy_||d.base_}function _M(d,e){if(zT(d))return new Map(d);if($T(d))return new Set(d);if(Array.isArray(d))return Array.prototype.slice.call(d);const t=I8(d);if(e===!0||e==="class_only"&&!t){const s=Object.getOwnPropertyDescriptors(d);delete s[Oa];let i=Reflect.ownKeys(s);for(let n=0;n1&&(d.set=d.add=d.clear=d.delete=rce),Object.freeze(d),e&&Object.entries(d).forEach(([t,s])=>PA(s,!0))),d}function rce(){Ao(2)}function KT(d){return Object.isFrozen(d)}var ace={};function zl(d){const e=ace[d];return e||Ao(0,d),e}var G0;function M8(){return G0}function oce(d,e){return{drafts_:[],parent_:d,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function hq(d,e){e&&(zl("Patches"),d.patches_=[],d.inversePatches_=[],d.patchListener_=e)}function AM(d){LM(d),d.drafts_.forEach(dce),d.drafts_=null}function LM(d){d===G0&&(G0=d.parent_)}function lq(d){return G0=oce(G0,d)}function dce(d){const e=d[Oa];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function fq(d,e){e.unfinalizedDrafts_=e.drafts_.length;const t=e.drafts_[0];return d!==void 0&&d!==t?(t[Oa].modified_&&(AM(e),Ao(4)),zc(d)&&(d=dv(e,d),e.parent_||cv(e,d)),e.patches_&&zl("Patches").generateReplacementPatches_(t[Oa].base_,d,e.patches_,e.inversePatches_)):d=dv(e,t,[]),AM(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),d!==P8?d:void 0}function dv(d,e,t){if(KT(e))return e;const s=e[Oa];if(!s)return ov(e,(i,n)=>pq(d,s,e,i,n,t)),e;if(s.scope_!==d)return e;if(!s.modified_)return cv(d,s.base_,!0),s.base_;if(!s.finalized_){s.finalized_=!0,s.scope_.unfinalizedDrafts_--;const i=s.copy_;let n=i,r=!1;s.type_===3&&(n=new Set(i),i.clear(),r=!0),ov(n,(a,o)=>pq(d,s,i,a,o,t,r)),cv(d,i,!1),t&&d.patches_&&zl("Patches").generatePatches_(s,t,d.patches_,d.inversePatches_)}return s.copy_}function pq(d,e,t,s,i,n,r){if(jl(i)){const a=n&&e&&e.type_!==3&&!MM(e.assigned_,s)?n.concat(s):void 0,o=dv(d,i,a);if(C8(t,s,o),jl(o))d.canAutoFreeze_=!1;else return}else r&&t.add(i);if(zc(i)&&!KT(i)){if(!d.immer_.autoFreeze_&&d.unfinalizedDrafts_<1)return;dv(d,i),(!e||!e.scope_.parent_)&&typeof s!="symbol"&&Object.prototype.propertyIsEnumerable.call(t,s)&&cv(d,i)}}function cv(d,e,t=!1){!d.parent_&&d.immer_.autoFreeze_&&d.canAutoFreeze_&&PA(e,t)}function cce(d,e){const t=Array.isArray(d),s={type_:t?1:0,scope_:e?e.scope_:M8(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:d,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=s,n=IA;t&&(i=[s],n=U0);const{revoke:r,proxy:a}=Proxy.revocable(i,n);return s.draft_=a,s.revoke_=r,a}var IA={get(d,e){if(e===Oa)return d;const t=ll(d);if(!MM(t,e))return uce(d,t,e);const s=t[e];return d.finalized_||!zc(s)?s:s===cI(d.base_,e)?(uI(d),d.copy_[e]=NM(s,d)):s},has(d,e){return e in ll(d)},ownKeys(d){return Reflect.ownKeys(ll(d))},set(d,e,t){const s=_8(ll(d),e);if(s!=null&&s.set)return s.set.call(d.draft_,t),!0;if(!d.modified_){const i=cI(ll(d),e),n=i==null?void 0:i[Oa];if(n&&n.base_===t)return d.copy_[e]=t,d.assigned_[e]=!1,!0;if(nce(t,i)&&(t!==void 0||MM(d.base_,e)))return!0;uI(d),BM(d)}return d.copy_[e]===t&&(t!==void 0||e in d.copy_)||Number.isNaN(t)&&Number.isNaN(d.copy_[e])||(d.copy_[e]=t,d.assigned_[e]=!0),!0},deleteProperty(d,e){return cI(d.base_,e)!==void 0||e in d.base_?(d.assigned_[e]=!1,uI(d),BM(d)):delete d.assigned_[e],d.copy_&&delete d.copy_[e],!0},getOwnPropertyDescriptor(d,e){const t=ll(d),s=Reflect.getOwnPropertyDescriptor(t,e);return s&&{writable:!0,configurable:d.type_!==1||e!=="length",enumerable:s.enumerable,value:t[e]}},defineProperty(){Ao(11)},getPrototypeOf(d){return Cm(d.base_)},setPrototypeOf(){Ao(12)}},U0={};ov(IA,(d,e)=>{U0[d]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});U0.deleteProperty=function(d,e){return U0.set.call(this,d,e,void 0)};U0.set=function(d,e,t){return IA.set.call(this,d[0],e,t,d[0])};function cI(d,e){const t=d[Oa];return(t?ll(t):d)[e]}function uce(d,e,t){var i;const s=_8(e,t);return s?"value"in s?s.value:(i=s.get)==null?void 0:i.call(d.draft_):void 0}function _8(d,e){if(!(e in d))return;let t=Cm(d);for(;t;){const s=Object.getOwnPropertyDescriptor(t,e);if(s)return s;t=Cm(t)}}function BM(d){d.modified_||(d.modified_=!0,d.parent_&&BM(d.parent_))}function uI(d){d.copy_||(d.copy_=_M(d.base_,d.scope_.immer_.useStrictShallowCopy_))}var hce=class{constructor(d){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,s)=>{if(typeof e=="function"&&typeof t!="function"){const n=t;t=e;const r=this;return function(o=n,...c){return r.produce(o,u=>t.call(this,u,...c))}}typeof t!="function"&&Ao(6),s!==void 0&&typeof s!="function"&&Ao(7);let i;if(zc(e)){const n=lq(this),r=NM(e,void 0);let a=!0;try{i=t(r),a=!1}finally{a?AM(n):LM(n)}return hq(n,s),fq(i,n)}else if(!e||typeof e!="object"){if(i=t(e),i===void 0&&(i=e),i===P8&&(i=void 0),this.autoFreeze_&&PA(i,!0),s){const n=[],r=[];zl("Patches").generateReplacementPatches_(e,i,n,r),s(n,r)}return i}else Ao(1,e)},this.produceWithPatches=(e,t)=>{if(typeof e=="function")return(r,...a)=>this.produceWithPatches(r,o=>e(o,...a));let s,i;return[this.produce(e,t,(r,a)=>{s=r,i=a}),s,i]},typeof(d==null?void 0:d.autoFreeze)=="boolean"&&this.setAutoFreeze(d.autoFreeze),typeof(d==null?void 0:d.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(d.useStrictShallowCopy)}createDraft(d){zc(d)||Ao(8),jl(d)&&(d=lce(d));const e=lq(this),t=NM(d,void 0);return t[Oa].isManual_=!0,LM(e),t}finishDraft(d,e){const t=d&&d[Oa];(!t||!t.isManual_)&&Ao(9);const{scope_:s}=t;return hq(s,e),fq(void 0,s)}setAutoFreeze(d){this.autoFreeze_=d}setUseStrictShallowCopy(d){this.useStrictShallowCopy_=d}applyPatches(d,e){let t;for(t=e.length-1;t>=0;t--){const i=e[t];if(i.path.length===0&&i.op==="replace"){d=i.value;break}}t>-1&&(e=e.slice(t+1));const s=zl("Patches").applyPatches_;return jl(d)?s(d,e):this.produce(d,i=>s(i,e))}};function NM(d,e){const t=zT(d)?zl("MapSet").proxyMap_(d,e):$T(d)?zl("MapSet").proxySet_(d,e):cce(d,e);return(e?e.scope_:M8()).drafts_.push(t),t}function lce(d){return jl(d)||Ao(10,d),A8(d)}function A8(d){if(!zc(d)||KT(d))return d;const e=d[Oa];let t;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,t=_M(d,e.scope_.immer_.useStrictShallowCopy_)}else t=_M(d,!0);return ov(t,(s,i)=>{C8(t,s,A8(i))}),e&&(e.finalized_=!1),t}var xa=new hce,Gr=xa.produce;xa.produceWithPatches.bind(xa);xa.setAutoFreeze.bind(xa);xa.setUseStrictShallowCopy.bind(xa);xa.applyPatches.bind(xa);xa.createDraft.bind(xa);xa.finishDraft.bind(xa);function L8(d){return({dispatch:t,getState:s})=>i=>n=>typeof n=="function"?n(t,s,d):i(n)}var fce=L8(),pce=L8,mce=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?av:av.apply(null,arguments)};function Si(d,e){function t(...s){if(e){let i=e(...s);if(!i)throw new Error(Ec(0));return{type:d,payload:i.payload,..."meta"in i&&{meta:i.meta},..."error"in i&&{error:i.error}}}return{type:d,payload:s[0]}}return t.toString=()=>`${d}`,t.type=d,t.match=s=>sce(s)&&s.type===d,t}var B8=class _y extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,_y.prototype)}static get[Symbol.species](){return _y}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new _y(...e[0].concat(this)):new _y(...e.concat(this))}};function mq(d){return zc(d)?Gr(d,()=>{}):d}function gq(d,e,t){return d.has(e)?d.get(e):d.set(e,t(e)).get(e)}function gce(d){return typeof d=="boolean"}var yce=()=>function(e){const{thunk:t=!0,immutableCheck:s=!0,serializableCheck:i=!0,actionCreatorCheck:n=!0}=e??{};let r=new B8;return t&&(gce(t)?r.push(fce):r.push(pce(t.extraArgument))),r},wce="RTK_autoBatch",yq=d=>e=>{setTimeout(e,d)},bce=(d={type:"raf"})=>e=>(...t)=>{const s=e(...t);let i=!0,n=!1,r=!1;const a=new Set,o=d.type==="tick"?queueMicrotask:d.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:yq(10):d.type==="callback"?d.queueNotification:yq(d.timeout),c=()=>{r=!1,n&&(n=!1,a.forEach(u=>u()))};return Object.assign({},s,{subscribe(u){const h=()=>i&&u(),l=s.subscribe(h);return a.add(u),()=>{l(),a.delete(u)}},dispatch(u){var h;try{return i=!((h=u==null?void 0:u.meta)!=null&&h[wce]),n=!i,n&&(r||(r=!0,o(c))),s.dispatch(u)}finally{i=!0}}})},kce=d=>function(t){const{autoBatch:s=!0}=t??{};let i=new B8(d);return s&&i.push(bce(typeof s=="object"?s:void 0)),i};function N8(d){const e=yce(),{reducer:t=void 0,middleware:s,devTools:i=!0,preloadedState:n=void 0,enhancers:r=void 0}=d||{};let a;if(typeof t=="function")a=t;else if(xA(t))a=ece(t);else throw new Error(Ec(1));let o;typeof s=="function"?o=s(e):o=e();let c=av;i&&(c=mce({trace:!1,...typeof i=="object"&&i}));const u=tce(...o),h=kce(u);let l=typeof r=="function"?r(h):h();const f=c(...l);return x8(a,n,f)}function E8(d){const e={},t=[];let s;const i={addCase(n,r){const a=typeof n=="string"?n:n.type;if(!a)throw new Error(Ec(28));if(a in e)throw new Error(Ec(29));return e[a]=r,i},addMatcher(n,r){return t.push({matcher:n,reducer:r}),i},addDefaultCase(n){return s=n,i}};return d(i),[e,t,s]}function Sce(d){return typeof d=="function"}function vce(d,e){let[t,s,i]=E8(e),n;if(Sce(d))n=()=>mq(d());else{const a=mq(d);n=()=>a}function r(a=n(),o){let c=[t[o.type],...s.filter(({matcher:u})=>u(o)).map(({reducer:u})=>u)];return c.filter(u=>!!u).length===0&&(c=[i]),c.reduce((u,h)=>{if(h)if(jl(u)){const f=h(u,o);return f===void 0?u:f}else{if(zc(u))return Gr(u,l=>h(l,o));{const l=h(u,o);if(l===void 0){if(u===null)return u;throw Error("A case reducer on a non-draftable value must not return undefined")}return l}}return u},a)}return r.getInitialState=n,r}var Tce=Symbol.for("rtk-slice-createasyncthunk");function Oce(d,e){return`${d}/${e}`}function xce({creators:d}={}){var t;const e=(t=d==null?void 0:d.asyncThunk)==null?void 0:t[Tce];return function(i){const{name:n,reducerPath:r=n}=i;if(!n)throw new Error(Ec(11));const a=(typeof i.reducers=="function"?i.reducers(Ice()):i.reducers)||{},o=Object.keys(a),c={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},u={addCase(b,S){const v=typeof b=="string"?b:b.type;if(!v)throw new Error(Ec(12));if(v in c.sliceCaseReducersByType)throw new Error(Ec(13));return c.sliceCaseReducersByType[v]=S,u},addMatcher(b,S){return c.sliceMatchers.push({matcher:b,reducer:S}),u},exposeAction(b,S){return c.actionCreators[b]=S,u},exposeCaseReducer(b,S){return c.sliceCaseReducersByName[b]=S,u}};o.forEach(b=>{const S=a[b],v={reducerName:b,type:Oce(n,b),createNotation:typeof i.reducers=="function"};Mce(S)?Ace(v,S,u,e):Cce(v,S,u)});function h(){const[b={},S=[],v=void 0]=typeof i.extraReducers=="function"?E8(i.extraReducers):[i.extraReducers],C={...b,...c.sliceCaseReducersByType};return vce(i.initialState,M=>{for(let _ in C)M.addCase(_,C[_]);for(let _ of c.sliceMatchers)M.addMatcher(_.matcher,_.reducer);for(let _ of S)M.addMatcher(_.matcher,_.reducer);v&&M.addDefaultCase(v)})}const l=b=>b,f=new Map;let p;function m(b,S){return p||(p=h()),p(b,S)}function g(){return p||(p=h()),p.getInitialState()}function y(b,S=!1){function v(M){let _=M[b];return typeof _>"u"&&S&&(_=g()),_}function C(M=l){const _=gq(f,S,()=>new WeakMap);return gq(_,M,()=>{const N={};for(const[A,R]of Object.entries(i.selectors??{}))N[A]=Pce(R,M,g,S);return N})}return{reducerPath:b,getSelectors:C,get selectors(){return C(v)},selectSlice:v}}const w={name:n,reducer:m,actions:c.actionCreators,caseReducers:c.sliceCaseReducersByName,getInitialState:g,...y(r),injectInto(b,{reducerPath:S,...v}={}){const C=S??r;return b.inject({reducerPath:C,reducer:m},v),{...w,...y(C,!0)}}};return w}}function Pce(d,e,t,s){function i(n,...r){let a=e(n);return typeof a>"u"&&s&&(a=t()),d(a,...r)}return i.unwrapped=d,i}var XT=xce();function Ice(){function d(e,t){return{_reducerDefinitionType:"asyncThunk",payloadCreator:e,...t}}return d.withTypes=()=>d,{reducer(e){return Object.assign({[e.name](...t){return e(...t)}}[e.name],{_reducerDefinitionType:"reducer"})},preparedReducer(e,t){return{_reducerDefinitionType:"reducerWithPrepare",prepare:e,reducer:t}},asyncThunk:d}}function Cce({type:d,reducerName:e,createNotation:t},s,i){let n,r;if("reducer"in s){if(t&&!_ce(s))throw new Error(Ec(17));n=s.reducer,r=s.prepare}else n=s;i.addCase(d,n).exposeCaseReducer(e,n).exposeAction(e,r?Si(d,r):Si(d))}function Mce(d){return d._reducerDefinitionType==="asyncThunk"}function _ce(d){return d._reducerDefinitionType==="reducerWithPrepare"}function Ace({type:d,reducerName:e},t,s,i){if(!i)throw new Error(Ec(18));const{payloadCreator:n,fulfilled:r,pending:a,rejected:o,settled:c,options:u}=t,h=i(d,n,u);s.exposeAction(e,h),r&&s.addCase(h.fulfilled,r),a&&s.addCase(h.pending,a),o&&s.addCase(h.rejected,o),c&&s.addMatcher(h.settled,c),s.exposeCaseReducer(e,{fulfilled:r||oS,pending:a||oS,rejected:o||oS,settled:c||oS})}function oS(){}function Ec(d){return`Minified Redux Toolkit error #${d}; visit https://redux-toolkit.js.org/Errors?code=${d} for the full message or use the non-minified dev environment for full errors. `}const Lce="changeFormType",Bce=Si(Lce),Nce="setExchangeAccountId",Ece=Si(Nce),Rce="setExchangeCode",Dce=Si(Rce),qce="setSymbolId",Vce=Si(qce),Fce="changeSymbolId",Hce=Si(Fce),Gce="setHighPrice",Uce=Si(Gce),Wce="changeHighPrice",jce=Si(Wce),zce="setLowPrice",$ce=Si(zce),Kce="changeLowPrice",Xce=Si(Kce),Qce="changeGridLinesNumber",Yce=Si(Qce),Zce="setQuantityPerGrid",Jce=Si(Zce),eue="changeQuantityPerGrid",tue=Si(eue),sue="setBotId",iue=Si(sue),nue="setBotName",rue=Si(nue),aue="changeBotName",oue=Si(aue),due="changeBarSize",cue=Si(due),uue="setGridLines",hue=Si(uue),lue="updateGridLines",fue=Si(lue),pue="addGridLine",mue=Si(pue),gue="removeGridLine",yue=Si(gue),wue="updateGridLinePrice",bue=Si(wue),kue="updateGridLineQuantity",Sue=Si(kue),W0={Bot:"Bot",DcaBot:"DcaBot",GridBot:"GridBot"},vue={Buy:"Buy",Sell:"Sell"},Jf={Idle:"Idle",Placed:"Placed",Filled:"Filled",Canceled:"Canceled",Revoked:"Revoked",Deleted:"Deleted"},CA={Limit:"Limit",Market:"Market"},mf={ONE_MINUTE:"1m",FIVE_MINUTES:"5m",FIFTEEN_MINUTES:"15m",ONE_HOUR:"1h",FOUR_HOURS:"4h",ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1M",THREE_MONTHS:"3M"},Xa={OKX:"OKX",BYBIT:"BYBIT",BINANCE:"BINANCE",KRAKEN:"KRAKEN",COINBASE:"COINBASE",GATEIO:"GATEIO",BITGET:"BITGET"},vc={Real:"Real",Demo:"Demo",Paper:"Paper"};var im=(d=>(d.Buy="buy",d.Sell="sell",d))(im||{});const gWe={Idle:"idle",Placed:"placed",Filled:"filled"},Tue=d=>(d==null?void 0:d.indicatorValue)!==void 0&&(d==null?void 0:d.periods)!==void 0&&(d==null?void 0:d.timeframe)!==void 0,hI={onOrderFilled:"onOrderFilled",onCandleClosed:"onCandleClosed",onPublicTrade:"onPublicTrade",onOrderbookChange:"onOrderbookChange",onTickerChange:"onTickerChange"},Oue=10,xue=1,yWe=["1d","4h","1h","5m"],Pue={type:"simple",botId:NaN,botName:"",exchangeAccountId:0,exchangeCode:"OKX",symbolId:"OKX:BTC/USDT",highPrice:0,lowPrice:0,gridLinesNumber:Oue,quantityPerGrid:`${xue}`,gridLines:[],barSize:mf.ONE_DAY},R8=XT({name:"gridBotForm",initialState:Pue,reducers:{[Bce.type]:(d,e)=>{d.type=e.payload},[Ece.type]:(d,e)=>{d.exchangeAccountId=e.payload},[Dce.type]:(d,e)=>{d.exchangeCode=e.payload},[Vce.type]:(d,e)=>{d.symbolId=e.payload},[Hce.type]:(d,e)=>{d.symbolId=e.payload},[jce.type]:(d,e)=>{d.highPrice=e.payload},[Uce.type]:(d,e)=>{d.highPrice=e.payload},[Xce.type]:(d,e)=>{d.lowPrice=e.payload},[$ce.type]:(d,e)=>{d.lowPrice=e.payload},[Yce.type]:(d,e)=>{d.gridLinesNumber=e.payload},[tue.type]:(d,e)=>{d.quantityPerGrid=e.payload},[Jce.type]:(d,e)=>{d.quantityPerGrid=e.payload},[iue.type]:(d,e)=>{d.botId=e.payload},[rue.type]:(d,e)=>{d.botName=e.payload},[oue.type]:(d,e)=>{d.botName=e.payload},[cue.type]:(d,e)=>{d.barSize=e.payload},[hue.type]:(d,e)=>{d.gridLines=e.payload},[fue.type]:(d,e)=>{d.gridLines=e.payload},[mue.type]:(d,e)=>{d.gridLines.push(e.payload)},[yue.type]:(d,e)=>{const t=e.payload;d.gridLines.splice(t,1)},[bue.type]:(d,e)=>{const{gridLineIndex:t,price:s}=e.payload;d.gridLines[t].price=s},[Sue.type]:(d,e)=>{const{gridLineIndex:t,quantity:s}=e.payload;d.gridLines[t].quantity=s}}}),{changeFormType:wWe,setExchangeAccountId:bWe,setExchangeCode:kWe,setSymbolId:SWe,changeSymbolId:vWe,setHighPrice:TWe,changeHighPrice:OWe,setLowPrice:xWe,changeLowPrice:PWe,changeGridLinesNumber:IWe,setQuantityPerGrid:CWe,changeQuantityPerGrid:MWe,setBotId:_We,setBotName:AWe,changeBotName:LWe,changeBarSize:BWe,setGridLines:NWe,updateGridLines:EWe,addGridLine:RWe,removeGridLine:DWe,updateGridLinePrice:qWe,updateGridLineQuantity:VWe}=R8.actions;var Iue=20,Cue=1,$l=1e6,wq=1e6,Mue=-7,_ue=21,Aue=!1,Zw="[big.js] ",gf=Zw+"Invalid ",QT=gf+"decimal places",Lue=gf+"rounding mode",D8=Zw+"Division by zero",$s={},Rd=void 0,Bue=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function q8(){function d(e){var t=this;if(!(t instanceof d))return e===Rd?q8():new d(e);if(e instanceof d)t.s=e.s,t.e=e.e,t.c=e.c.slice();else{if(typeof e!="string"){if(d.strict===!0&&typeof e!="bigint")throw TypeError(gf+"value");e=e===0&&1/e<0?"-0":String(e)}Nue(t,e)}t.constructor=d}return d.prototype=$s,d.DP=Iue,d.RM=Cue,d.NE=Mue,d.PE=_ue,d.strict=Aue,d.roundDown=0,d.roundHalfUp=1,d.roundHalfEven=2,d.roundUp=3,d}function Nue(d,e){var t,s,i;if(!Bue.test(e))throw Error(gf+"number");for(d.s=e.charAt(0)=="-"?(e=e.slice(1),-1):1,(t=e.indexOf("."))>-1&&(e=e.replace(".","")),(s=e.search(/e/i))>0?(t<0&&(t=s),t+=+e.slice(s+1),e=e.substring(0,s)):t<0&&(t=e.length),i=e.length,s=0;s0&&e.charAt(--i)=="0";);for(d.e=t-s-1,d.c=[],t=0;s<=i;)d.c[t++]=+e.charAt(s++)}return d}function yf(d,e,t,s){var i=d.c;if(t===Rd&&(t=d.constructor.RM),t!==0&&t!==1&&t!==2&&t!==3)throw Error(Lue);if(e<1)s=t===3&&(s||!!i[0])||e===0&&(t===1&&i[0]>=5||t===2&&(i[0]>5||i[0]===5&&(s||i[1]!==Rd))),i.length=1,s?(d.e=d.e-e+1,i[0]=1):i[0]=d.e=0;else if(e=5||t===2&&(i[e]>5||i[e]===5&&(s||i[e+1]!==Rd||i[e-1]&1))||t===3&&(s||!!i[0]),i.length=e,s){for(;++i[--e]>9;)if(i[e]=0,e===0){++d.e,i.unshift(1);break}}for(e=i.length;!i[--e];)i.pop()}return d}function wf(d,e,t){var s=d.e,i=d.c.join(""),n=i.length;if(e)i=i.charAt(0)+(n>1?"."+i.slice(1):"")+(s<0?"e":"e+")+s;else if(s<0){for(;++s;)i="0"+i;i="0."+i}else if(s>0)if(++s>n)for(s-=n;s--;)i+="0";else s1&&(i=i.charAt(0)+"."+i.slice(1));return d.s<0&&t?"-"+i:i}$s.abs=function(){var d=new this.constructor(this);return d.s=1,d};$s.cmp=function(d){var e,t=this,s=t.c,i=(d=new t.constructor(d)).c,n=t.s,r=d.s,a=t.e,o=d.e;if(!s[0]||!i[0])return s[0]?n:i[0]?-r:0;if(n!=r)return n;if(e=n<0,a!=o)return a>o^e?1:-1;for(r=(a=s.length)<(o=i.length)?a:o,n=-1;++ni[n]^e?1:-1;return a==o?0:a>o^e?1:-1};$s.div=function(d){var e=this,t=e.constructor,s=e.c,i=(d=new t(d)).c,n=e.s==d.s?1:-1,r=t.DP;if(r!==~~r||r<0||r>$l)throw Error(QT);if(!i[0])throw Error(D8);if(!s[0])return d.s=n,d.c=[d.e=0],d;var a,o,c,u,h,l=i.slice(),f=a=i.length,p=s.length,m=s.slice(0,a),g=m.length,y=d,w=y.c=[],b=0,S=r+(y.e=e.e-d.e)+1;for(y.s=n,n=S<0?0:S,l.unshift(0);g++g?1:-1;else for(h=-1,u=0;++hm[h]?1:-1;break}if(u<0){for(o=g==a?i:l;g;){if(m[--g]S&&yf(y,S,t.RM,m[0]!==Rd),y};$s.eq=function(d){return this.cmp(d)===0};$s.gt=function(d){return this.cmp(d)>0};$s.gte=function(d){return this.cmp(d)>-1};$s.lt=function(d){return this.cmp(d)<0};$s.lte=function(d){return this.cmp(d)<1};$s.minus=$s.sub=function(d){var e,t,s,i,n=this,r=n.constructor,a=n.s,o=(d=new r(d)).s;if(a!=o)return d.s=-o,n.plus(d);var c=n.c.slice(),u=n.e,h=d.c,l=d.e;if(!c[0]||!h[0])return h[0]?d.s=-o:c[0]?d=new r(n):d.s=1,d;if(a=u-l){for((i=a<0)?(a=-a,s=c):(l=u,s=h),s.reverse(),o=a;o--;)s.push(0);s.reverse()}else for(t=((i=c.length0)for(;o--;)c[e++]=0;for(o=e;t>a;){if(c[--t]0?(o=r,s=c):(e=-e,s=a),s.reverse();e--;)s.push(0);s.reverse()}for(a.length-c.length<0&&(s=c,c=a,a=s),e=c.length,t=0;e;a[e]%=10)t=(a[--e]=a[e]+c[e]+t)/10|0;for(t&&(a.unshift(t),++o),e=a.length;a[--e]===0;)a.pop();return d.c=a,d.e=o,d};$s.pow=function(d){var e=this,t=new e.constructor("1"),s=t,i=d<0;if(d!==~~d||d<-wq||d>wq)throw Error(gf+"exponent");for(i&&(d=-d);d&1&&(s=s.times(e)),d>>=1,!!d;)e=e.times(e);return i?t.div(s):s};$s.prec=function(d,e){if(d!==~~d||d<1||d>$l)throw Error(gf+"precision");return yf(new this.constructor(this),d,e)};$s.round=function(d,e){if(d===Rd)d=0;else if(d!==~~d||d<-$l||d>$l)throw Error(QT);return yf(new this.constructor(this),d+this.e+1,e)};$s.sqrt=function(){var d,e,t,s=this,i=s.constructor,n=s.s,r=s.e,a=new i("0.5");if(!s.c[0])return new i(s);if(n<0)throw Error(Zw+"No square root");n=Math.sqrt(+wf(s,!0,!0)),n===0||n===1/0?(e=s.c.join(""),e.length+r&1||(e+="0"),n=Math.sqrt(e),r=((r+1)/2|0)-(r<0||r&1),d=new i((n==1/0?"5e":(n=n.toExponential()).slice(0,n.indexOf("e")+1))+r)):d=new i(n+""),r=d.e+(i.DP+=4);do t=d,d=a.times(t.plus(s.div(t)));while(t.c.slice(0,r).join("")!==d.c.slice(0,r).join(""));return yf(d,(i.DP-=4)+d.e+1,i.RM)};$s.times=$s.mul=function(d){var e,t=this,s=t.constructor,i=t.c,n=(d=new s(d)).c,r=i.length,a=n.length,o=t.e,c=d.e;if(d.s=t.s==d.s?1:-1,!i[0]||!n[0])return d.c=[d.e=0],d;for(d.e=o+c,ro;)a=e[c]+n[o]*i[c-o-1]+a,e[c--]=a%10,a=a/10|0;e[c]=a}for(a?++d.e:e.shift(),o=e.length;!e[--o];)e.pop();return d.c=e,d};$s.toExponential=function(d,e){var t=this,s=t.c[0];if(d!==Rd){if(d!==~~d||d<0||d>$l)throw Error(QT);for(t=yf(new t.constructor(t),++d,e);t.c.length$l)throw Error(QT);for(t=yf(new t.constructor(t),d+t.e+1,e),d=d+t.e+1;t.c.length=e.PE,!!d.c[0])};$s.toNumber=function(){var d=+wf(this,!0,!0);if(this.constructor.strict===!0&&!this.eq(d.toString()))throw Error(Zw+"Imprecise conversion");return d};$s.toPrecision=function(d,e){var t=this,s=t.constructor,i=t.c[0];if(d!==Rd){if(d!==~~d||d<1||d>$l)throw Error(gf+"precision");for(t=yf(new s(t),d,e);t.c.length=s.PE,!!i)};$s.valueOf=function(){var d=this,e=d.constructor;if(e.strict===!0)throw Error(Zw+"valueOf disallowed");return wf(d,d.e<=e.NE||d.e>=e.PE,!0)};var Ro=q8();const r1=60*1e3,EM=60*r1,dS=24*EM,V8={"1m":r1,"5m":5*r1,"15m":15*r1,"1h":EM,"4h":4*EM,"1d":dS,"1w":7*dS,"1M":30*dS,"3M":90*dS};function Eue(d){return V8[d]}const Mm=":",YT="/";function ZT(d,e,t){return`${d.toUpperCase()}${Mm}${e}${YT}${t}`}const F8=Object.keys(Xa),Rue=`^(${F8.join("|")})${Mm}[A-Z0-9]+${YT}[A-Z0-9]+$`,Due=`^(${F8.join("|")})${Mm}[A-Z0-9]+${YT}[A-Z0-9]+${Mm}[A-Z0-9]+$`;function que(d){return new RegExp(Rue).test(d)||new RegExp(Due).test(d)}function MA(d){if(!que(d))throw new Error(`${d} is not a valid symbolId`);const[e,t,s]=d.split(Mm),[i,n]=t.split(YT);return{exchangeCode:Xa[e],currencyPairSymbol:s?t+Mm+s:t,baseCurrency:i,quoteCurrency:n}}function Kd(d){const[e="NONE",t="NONE"]=d.split("/");return{baseCurrency:e,quoteCurrency:t}}function JT(d){const{baseCurrency:e}=Kd(d);return e}function eO(d){const{quoteCurrency:e}=Kd(d);return e}const Vue=0,H8=2,G8=.01,Fue=5,Hue=1.7,Gue=4,_A=1,U8={indicatorValue:"30",timeframe:mf.ONE_MINUTE,periods:"14"},Uue={indicatorValue:"50",timeframe:mf.ONE_MINUTE,periods:"7"},Wue={indicatorValue:"50",timeframe:mf.ONE_MINUTE,periods:"7"},W8={combinator:"and",rules:[{field:"RSI",operator:">",value:U8}]},jue=["1d","4h","1h","5m"],zue={botId:NaN,botName:"",exchangeAccountId:0,exchangeCode:"OKX",symbolId:"OKX:BTC/USDT",entryOrderType:CA.Market,entryOrderQuantity:`${Vue}`,entryConditions:W8,takeProfitPercent:H8,simple:{safetyOrdersCount:Fue,safetyOrdersVolumeScale:Hue,safetyOrdersPriceScale:Gue,safetyOrdersPriceDeviation:_A},safetyOrders:[],safetyOrderFormType:"advanced",barSize:mf.ONE_DAY},j8=XT({name:"dcaBotForm",initialState:zue,reducers:{changeSafetyOrdersFormType:(d,e)=>{d.safetyOrderFormType=e.payload},setExchangeAccountId:(d,e)=>{d.exchangeAccountId=e.payload},changeExchangeAccountId:(d,e)=>{d.exchangeAccountId=e.payload},setExchangeCode:(d,e)=>{d.exchangeCode=e.payload},setSymbolId:(d,e)=>{d.symbolId=e.payload},changeSymbolId:(d,e)=>{d.symbolId=e.payload},setBotId:(d,e)=>{d.botId=e.payload},setBotName:(d,e)=>{d.botName=e.payload},changeBotName:(d,e)=>{d.botName=e.payload},changeBarSize:(d,e)=>{d.barSize=e.payload},setEntryOrderType:(d,e)=>{d.entryOrderType=e.payload},changeEntryOrderType:(d,e)=>{d.entryOrderType=e.payload},setEntryOrderQuantity:(d,e)=>{d.entryOrderQuantity=e.payload},changeEntryOrderQuantity:(d,e)=>{d.entryOrderQuantity=e.payload},setEntryConditions:(d,e)=>{d.entryConditions=e.payload},changeEntryConditions:(d,e)=>{d.entryConditions=e.payload},setTakeProfitPercent:(d,e)=>{d.takeProfitPercent=e.payload},changeTakeProfitPercent:(d,e)=>{d.takeProfitPercent=e.payload},setSafetyOrdersCount:(d,e)=>{d.simple.safetyOrdersCount=e.payload},changeSafetyOrdersCount:(d,e)=>{d.simple.safetyOrdersCount=e.payload},setSafetyOrdersVolumeScale:(d,e)=>{d.simple.safetyOrdersVolumeScale=e.payload},changeSafetyOrdersVolumeScale:(d,e)=>{d.simple.safetyOrdersVolumeScale=e.payload},setSafetyOrdersPriceScale:(d,e)=>{d.simple.safetyOrdersPriceScale=e.payload},changeSafetyOrdersPriceScale:(d,e)=>{d.simple.safetyOrdersPriceScale=e.payload},setSafetyOrdersPriceDeviation:(d,e)=>{d.simple.safetyOrdersPriceDeviation=e.payload},changeSafetyOrdersPriceDeviation:(d,e)=>{d.simple.safetyOrdersPriceDeviation=e.payload},setSafetyOrders:(d,e)=>{d.safetyOrders=e.payload},updateSafetyOrders:(d,e)=>{d.safetyOrders=e.payload},addSafetyOrder:(d,e)=>{d.safetyOrders.push(e.payload)},removeSafetyOrder:(d,e)=>{const t=e.payload;d.safetyOrders.splice(t,1)},updateSafetyOrderPriceDeviation:(d,e)=>{const{index:t,priceDeviation:s}=e.payload;d.safetyOrders[t].priceDeviation=s},updateSafetyOrderQuantity:(d,e)=>{const{index:t,quantity:s}=e.payload;d.safetyOrders[t].quantity=s}}}),{changeSafetyOrdersFormType:FWe,setExchangeAccountId:$ue,changeExchangeAccountId:Kue,setExchangeCode:Xue,setSymbolId:Que,changeSymbolId:Yue,setBotId:HWe,setBotName:Zue,changeBotName:Jue,changeBarSize:ehe,setEntryOrderType:the,changeEntryOrderType:she,setEntryOrderQuantity:ihe,changeEntryOrderQuantity:nhe,setEntryConditions:rhe,changeEntryConditions:ahe,setTakeProfitPercent:ohe,changeTakeProfitPercent:dhe,setSafetyOrders:che,updateSafetyOrders:GWe,addSafetyOrder:bq,removeSafetyOrder:uhe,updateSafetyOrderPriceDeviation:hhe,updateSafetyOrderQuantity:lhe}=j8.actions,fhe=d=>d.dcaBotForm,phe=d=>d.dcaBotForm.botName,mhe=d=>d.dcaBotForm.barSize,ghe=d=>d.dcaBotForm.exchangeAccountId,tO=d=>d.dcaBotForm.symbolId,yhe=d=>d.dcaBotForm.entryOrderType,whe=d=>d.dcaBotForm.entryOrderQuantity,bhe=d=>d.dcaBotForm.entryConditions,z8=d=>d.dcaBotForm.takeProfitPercent,$8=d=>d.dcaBotForm.safetyOrders,K8=d=>e=>e.dcaBotForm.safetyOrders[d],khe=N8({reducer:{dcaBotForm:j8.reducer,gridBotForm:R8.reducer},devTools:!0}),She=({children:d})=>P.jsx(y8,{store:khe,children:d});class vhe{constructor(){this.keyToValue=new Map,this.valueToKey=new Map}set(e,t){this.keyToValue.set(e,t),this.valueToKey.set(t,e)}getByKey(e){return this.keyToValue.get(e)}getByValue(e){return this.valueToKey.get(e)}clear(){this.keyToValue.clear(),this.valueToKey.clear()}}class X8{constructor(e){this.generateIdentifier=e,this.kv=new vhe}register(e,t){this.kv.getByValue(e)||(t||(t=this.generateIdentifier(e)),this.kv.set(t,e))}clear(){this.kv.clear()}getIdentifier(e){return this.kv.getByValue(e)}getValue(e){return this.kv.getByKey(e)}}class The extends X8{constructor(){super(e=>e.name),this.classToAllowedProps=new Map}register(e,t){typeof t=="object"?(t.allowProps&&this.classToAllowedProps.set(e,t.allowProps),super.register(e,t.identifier)):super.register(e,t)}getAllowedProps(e){return this.classToAllowedProps.get(e)}}function Ohe(d){if("values"in Object)return Object.values(d);const e=[];for(const t in d)d.hasOwnProperty(t)&&e.push(d[t]);return e}function xhe(d,e){const t=Ohe(d);if("find"in t)return t.find(e);const s=t;for(let i=0;ie(s,t))}function a1(d,e){return d.indexOf(e)!==-1}function kq(d,e){for(let t=0;tt.isApplicable(e))}findByName(e){return this.transfomers[e]}}const Ihe=d=>Object.prototype.toString.call(d).slice(8,-1),Q8=d=>typeof d>"u",Che=d=>d===null,j0=d=>typeof d!="object"||d===null||d===Object.prototype?!1:Object.getPrototypeOf(d)===null?!0:Object.getPrototypeOf(d)===Object.prototype,RM=d=>j0(d)&&Object.keys(d).length===0,bh=d=>Array.isArray(d),Mhe=d=>typeof d=="string",_he=d=>typeof d=="number"&&!isNaN(d),Ahe=d=>typeof d=="boolean",Lhe=d=>d instanceof RegExp,z0=d=>d instanceof Map,$0=d=>d instanceof Set,Y8=d=>Ihe(d)==="Symbol",Bhe=d=>d instanceof Date&&!isNaN(d.valueOf()),Nhe=d=>d instanceof Error,Sq=d=>typeof d=="number"&&isNaN(d),Ehe=d=>Ahe(d)||Che(d)||Q8(d)||_he(d)||Mhe(d)||Y8(d),Rhe=d=>typeof d=="bigint",Dhe=d=>d===1/0||d===-1/0,qhe=d=>ArrayBuffer.isView(d)&&!(d instanceof DataView),Vhe=d=>d instanceof URL,Z8=d=>d.replace(/\./g,"\\."),lI=d=>d.map(String).map(Z8).join("."),Jy=d=>{const e=[];let t="";for(let i=0;inull,()=>{}),ud(Rhe,"bigint",d=>d.toString(),d=>typeof BigInt<"u"?BigInt(d):(console.error("Please add a BigInt polyfill."),d)),ud(Bhe,"Date",d=>d.toISOString(),d=>new Date(d)),ud(Nhe,"Error",(d,e)=>{const t={name:d.name,message:d.message};return e.allowedErrorProps.forEach(s=>{t[s]=d[s]}),t},(d,e)=>{const t=new Error(d.message);return t.name=d.name,t.stack=d.stack,e.allowedErrorProps.forEach(s=>{t[s]=d[s]}),t}),ud(Lhe,"regexp",d=>""+d,d=>{const e=d.slice(1,d.lastIndexOf("/")),t=d.slice(d.lastIndexOf("/")+1);return new RegExp(e,t)}),ud($0,"set",d=>[...d.values()],d=>new Set(d)),ud(z0,"map",d=>[...d.entries()],d=>new Map(d)),ud(d=>Sq(d)||Dhe(d),"number",d=>Sq(d)?"NaN":d>0?"Infinity":"-Infinity",Number),ud(d=>d===0&&1/d===-1/0,"number",()=>"-0",Number),ud(Vhe,"URL",d=>d.toString(),d=>new URL(d))];function sO(d,e,t,s){return{isApplicable:d,annotation:e,transform:t,untransform:s}}const eG=sO((d,e)=>Y8(d)?!!e.symbolRegistry.getIdentifier(d):!1,(d,e)=>["symbol",e.symbolRegistry.getIdentifier(d)],d=>d.description,(d,e,t)=>{const s=t.symbolRegistry.getValue(e[1]);if(!s)throw new Error("Trying to deserialize unknown symbol");return s}),Fhe=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,Uint8ClampedArray].reduce((d,e)=>(d[e.name]=e,d),{}),tG=sO(qhe,d=>["typed-array",d.constructor.name],d=>[...d],(d,e)=>{const t=Fhe[e[1]];if(!t)throw new Error("Trying to deserialize unknown typed array");return new t(d)});function sG(d,e){return d!=null&&d.constructor?!!e.classRegistry.getIdentifier(d.constructor):!1}const iG=sO(sG,(d,e)=>["class",e.classRegistry.getIdentifier(d.constructor)],(d,e)=>{const t=e.classRegistry.getAllowedProps(d.constructor);if(!t)return{...d};const s={};return t.forEach(i=>{s[i]=d[i]}),s},(d,e,t)=>{const s=t.classRegistry.getValue(e[1]);if(!s)throw new Error(`Trying to deserialize unknown class '${e[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);return Object.assign(Object.create(s.prototype),d)}),nG=sO((d,e)=>!!e.customTransformerRegistry.findApplicable(d),(d,e)=>["custom",e.customTransformerRegistry.findApplicable(d).name],(d,e)=>e.customTransformerRegistry.findApplicable(d).serialize(d),(d,e,t)=>{const s=t.customTransformerRegistry.findByName(e[1]);if(!s)throw new Error("Trying to deserialize unknown custom value");return s.deserialize(d)}),Hhe=[iG,eG,nG,tG],vq=(d,e)=>{const t=kq(Hhe,i=>i.isApplicable(d,e));if(t)return{value:t.transform(d,e),type:t.annotation(d,e)};const s=kq(J8,i=>i.isApplicable(d,e));if(s)return{value:s.transform(d,e),type:s.annotation}},rG={};J8.forEach(d=>{rG[d.annotation]=d});const Ghe=(d,e,t)=>{if(bh(e))switch(e[0]){case"symbol":return eG.untransform(d,e,t);case"class":return iG.untransform(d,e,t);case"custom":return nG.untransform(d,e,t);case"typed-array":return tG.untransform(d,e,t);default:throw new Error("Unknown transformation: "+e)}else{const s=rG[e];if(!s)throw new Error("Unknown transformation: "+e);return s.untransform(d,t)}},Np=(d,e)=>{if(e>d.size)throw new Error("index out of bounds");const t=d.keys();for(;e>0;)t.next(),e--;return t.next().value};function aG(d){if(a1(d,"__proto__"))throw new Error("__proto__ is not allowed as a property");if(a1(d,"prototype"))throw new Error("prototype is not allowed as a property");if(a1(d,"constructor"))throw new Error("constructor is not allowed as a property")}const Uhe=(d,e)=>{aG(e);for(let t=0;t{if(aG(e),e.length===0)return t(d);let s=d;for(let n=0;nqM(n,e,[...t,...Jy(r)]));return}const[s,i]=d;i&&_m(i,(n,r)=>{qM(n,e,[...t,...Jy(r)])}),e(s,t)}function Whe(d,e,t){return qM(e,(s,i)=>{d=DM(d,i,n=>Ghe(n,s,t))}),d}function jhe(d,e){function t(s,i){const n=Uhe(d,Jy(i));s.map(Jy).forEach(r=>{d=DM(d,r,()=>n)})}if(bh(e)){const[s,i]=e;s.forEach(n=>{d=DM(d,Jy(n),()=>d)}),i&&_m(i,t)}else _m(e,t);return d}const zhe=(d,e)=>j0(d)||bh(d)||z0(d)||$0(d)||sG(d,e);function $he(d,e,t){const s=t.get(d);s?s.push(e):t.set(d,[e])}function Khe(d,e){const t={};let s;return d.forEach(i=>{if(i.length<=1)return;e||(i=i.map(a=>a.map(String)).sort((a,o)=>a.length-o.length));const[n,...r]=i;n.length===0?s=r.map(lI):t[lI(n)]=r.map(lI)}),s?RM(t)?[s]:[s,t]:RM(t)?void 0:t}const oG=(d,e,t,s,i=[],n=[],r=new Map)=>{const a=Ehe(d);if(!a){$he(d,i,e);const f=r.get(d);if(f)return s?{transformedValue:null}:f}if(!zhe(d,t)){const f=vq(d,t),p=f?{transformedValue:f.value,annotations:[f.type]}:{transformedValue:d};return a||r.set(d,p),p}if(a1(n,d))return{transformedValue:null};const o=vq(d,t),c=(o==null?void 0:o.value)??d,u=bh(c)?[]:{},h={};_m(c,(f,p)=>{if(p==="__proto__"||p==="constructor"||p==="prototype")throw new Error(`Detected property ${p}. This is a prototype pollution risk, please remove it from your object.`);const m=oG(f,e,t,s,[...i,p],[...n,d],r);u[p]=m.transformedValue,bh(m.annotations)?h[p]=m.annotations:j0(m.annotations)&&_m(m.annotations,(g,y)=>{h[Z8(p)+"."+y]=g})});const l=RM(h)?{transformedValue:u,annotations:o?[o.type]:void 0}:{transformedValue:u,annotations:o?[o.type,h]:h};return a||r.set(d,l),l};function dG(d){return Object.prototype.toString.call(d).slice(8,-1)}function Tq(d){return dG(d)==="Array"}function Xhe(d){if(dG(d)!=="Object")return!1;const e=Object.getPrototypeOf(d);return!!e&&e.constructor===Object&&e===Object.prototype}function Qhe(d,e,t,s,i){const n={}.propertyIsEnumerable.call(s,e)?"enumerable":"nonenumerable";n==="enumerable"&&(d[e]=t),i&&n==="nonenumerable"&&Object.defineProperty(d,e,{value:t,enumerable:!1,writable:!0,configurable:!0})}function VM(d,e={}){if(Tq(d))return d.map(i=>VM(i,e));if(!Xhe(d))return d;const t=Object.getOwnPropertyNames(d),s=Object.getOwnPropertySymbols(d);return[...t,...s].reduce((i,n)=>{if(Tq(e.props)&&!e.props.includes(n))return i;const r=d[n],a=VM(r,e);return Qhe(i,n,a,d,e.nonenumerable),i},{})}class vs{constructor({dedupe:e=!1}={}){this.classRegistry=new The,this.symbolRegistry=new X8(t=>t.description??""),this.customTransformerRegistry=new Phe,this.allowedErrorProps=[],this.dedupe=e}serialize(e){const t=new Map,s=oG(e,t,this,this.dedupe),i={json:s.transformedValue};s.annotations&&(i.meta={...i.meta,values:s.annotations});const n=Khe(t,this.dedupe);return n&&(i.meta={...i.meta,referentialEqualities:n}),i}deserialize(e){const{json:t,meta:s}=e;let i=VM(t);return s!=null&&s.values&&(i=Whe(i,s.values,this)),s!=null&&s.referentialEqualities&&(i=jhe(i,s.referentialEqualities)),i}stringify(e){return JSON.stringify(this.serialize(e))}parse(e){return this.deserialize(JSON.parse(e))}registerClass(e,t){this.classRegistry.register(e,t)}registerSymbol(e,t){this.symbolRegistry.register(e,t)}registerCustom(e,t){this.customTransformerRegistry.register({name:t,...e})}allowErrorProps(...e){this.allowedErrorProps.push(...e)}}vs.defaultInstance=new vs;vs.serialize=vs.defaultInstance.serialize.bind(vs.defaultInstance);vs.deserialize=vs.defaultInstance.deserialize.bind(vs.defaultInstance);vs.stringify=vs.defaultInstance.stringify.bind(vs.defaultInstance);vs.parse=vs.defaultInstance.parse.bind(vs.defaultInstance);vs.registerClass=vs.defaultInstance.registerClass.bind(vs.defaultInstance);vs.registerSymbol=vs.defaultInstance.registerSymbol.bind(vs.defaultInstance);vs.registerCustom=vs.defaultInstance.registerCustom.bind(vs.defaultInstance);vs.allowErrorProps=vs.defaultInstance.allowErrorProps.bind(vs.defaultInstance);vs.serialize;vs.deserialize;vs.stringify;vs.parse;vs.registerClass;vs.registerCustom;vs.registerSymbol;vs.allowErrorProps;class bf{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){const t={listener:e};return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}}const K0=typeof window>"u"||"Deno"in window;function $a(){}function Yhe(d,e){return typeof d=="function"?d(e):d}function FM(d){return typeof d=="number"&&d>=0&&d!==1/0}function Oq(d,e){return d.filter(t=>!e.includes(t))}function Zhe(d,e,t){const s=d.slice(0);return s[e]=t,s}function cG(d,e){return Math.max(d+(e||0)-Date.now(),0)}function Ep(d,e,t){return Jw(d)?typeof e=="function"?{...t,queryKey:d,queryFn:e}:{...e,queryKey:d}:d}function Jhe(d,e,t){return Jw(d)?{...e,mutationKey:d}:typeof d=="function"?{...e,mutationFn:d}:{...d}}function Eu(d,e,t){return Jw(d)?[{...e,queryKey:d},t]:[d||{},e]}function xq(d,e){const{type:t="all",exact:s,fetchStatus:i,predicate:n,queryKey:r,stale:a}=d;if(Jw(r)){if(s){if(e.queryHash!==AA(r,e.options))return!1}else if(!uv(e.queryKey,r))return!1}if(t!=="all"){const o=e.isActive();if(t==="active"&&!o||t==="inactive"&&o)return!1}return!(typeof a=="boolean"&&e.isStale()!==a||typeof i<"u"&&i!==e.state.fetchStatus||n&&!n(e))}function Pq(d,e){const{exact:t,fetching:s,predicate:i,mutationKey:n}=d;if(Jw(n)){if(!e.options.mutationKey)return!1;if(t){if(Qu(e.options.mutationKey)!==Qu(n))return!1}else if(!uv(e.options.mutationKey,n))return!1}return!(typeof s=="boolean"&&e.state.status==="loading"!==s||i&&!i(e))}function AA(d,e){return((e==null?void 0:e.queryKeyHashFn)||Qu)(d)}function Qu(d){return JSON.stringify(d,(e,t)=>HM(t)?Object.keys(t).sort().reduce((s,i)=>(s[i]=t[i],s),{}):t)}function uv(d,e){return uG(d,e)}function uG(d,e){return d===e?!0:typeof d!=typeof e?!1:d&&e&&typeof d=="object"&&typeof e=="object"?!Object.keys(e).some(t=>!uG(d[t],e[t])):!1}function hG(d,e){if(d===e)return d;const t=Iq(d)&&Iq(e);if(t||HM(d)&&HM(e)){const s=t?d.length:Object.keys(d).length,i=t?e:Object.keys(e),n=i.length,r=t?[]:{};let a=0;for(let o=0;o"u")return!0;const t=e.prototype;return!(!Cq(t)||!t.hasOwnProperty("isPrototypeOf"))}function Cq(d){return Object.prototype.toString.call(d)==="[object Object]"}function Jw(d){return Array.isArray(d)}function lG(d){return new Promise(e=>{setTimeout(e,d)})}function Mq(d){lG(0).then(d)}function ele(){if(typeof AbortController=="function")return new AbortController}function GM(d,e,t){return t.isDataEqual!=null&&t.isDataEqual(d,e)?d:typeof t.structuralSharing=="function"?t.structuralSharing(d,e):t.structuralSharing!==!1?hG(d,e):e}class tle extends bf{constructor(){super(),this.setup=e=>{if(!K0&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),window.addEventListener("focus",t,!1),()=>{window.removeEventListener("visibilitychange",t),window.removeEventListener("focus",t)}}}}onSubscribe(){this.cleanup||this.setEventListener(this.setup)}onUnsubscribe(){if(!this.hasListeners()){var e;(e=this.cleanup)==null||e.call(this),this.cleanup=void 0}}setEventListener(e){var t;this.setup=e,(t=this.cleanup)==null||t.call(this),this.cleanup=e(s=>{typeof s=="boolean"?this.setFocused(s):this.onFocus()})}setFocused(e){this.focused!==e&&(this.focused=e,this.onFocus())}onFocus(){this.listeners.forEach(({listener:e})=>{e()})}isFocused(){return typeof this.focused=="boolean"?this.focused:typeof document>"u"?!0:[void 0,"visible","prerender"].includes(document.visibilityState)}}const lv=new tle,_q=["online","offline"];class sle extends bf{constructor(){super(),this.setup=e=>{if(!K0&&window.addEventListener){const t=()=>e();return _q.forEach(s=>{window.addEventListener(s,t,!1)}),()=>{_q.forEach(s=>{window.removeEventListener(s,t)})}}}}onSubscribe(){this.cleanup||this.setEventListener(this.setup)}onUnsubscribe(){if(!this.hasListeners()){var e;(e=this.cleanup)==null||e.call(this),this.cleanup=void 0}}setEventListener(e){var t;this.setup=e,(t=this.cleanup)==null||t.call(this),this.cleanup=e(s=>{typeof s=="boolean"?this.setOnline(s):this.onOnline()})}setOnline(e){this.online!==e&&(this.online=e,this.onOnline())}onOnline(){this.listeners.forEach(({listener:e})=>{e()})}isOnline(){return typeof this.online=="boolean"?this.online:typeof navigator>"u"||typeof navigator.onLine>"u"?!0:navigator.onLine}}const fv=new sle;function ile(d){return Math.min(1e3*2**d,3e4)}function iO(d){return(d??"online")==="online"?fv.isOnline():!0}class fG{constructor(e){this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}}function o1(d){return d instanceof fG}function pG(d){let e=!1,t=0,s=!1,i,n,r;const a=new Promise((g,y)=>{n=g,r=y}),o=g=>{s||(f(new fG(g)),d.abort==null||d.abort())},c=()=>{e=!0},u=()=>{e=!1},h=()=>!lv.isFocused()||d.networkMode!=="always"&&!fv.isOnline(),l=g=>{s||(s=!0,d.onSuccess==null||d.onSuccess(g),i==null||i(),n(g))},f=g=>{s||(s=!0,d.onError==null||d.onError(g),i==null||i(),r(g))},p=()=>new Promise(g=>{i=y=>{const w=s||!h();return w&&g(y),w},d.onPause==null||d.onPause()}).then(()=>{i=void 0,s||d.onContinue==null||d.onContinue()}),m=()=>{if(s)return;let g;try{g=d.fn()}catch(y){g=Promise.reject(y)}Promise.resolve(g).then(l).catch(y=>{var w,b;if(s)return;const S=(w=d.retry)!=null?w:3,v=(b=d.retryDelay)!=null?b:ile,C=typeof v=="function"?v(t,y):v,M=S===!0||typeof S=="number"&&t{if(h())return p()}).then(()=>{e?f(y):m()})})};return iO(d.networkMode)?m():p().then(m),{promise:a,cancel:o,continue:()=>(i==null?void 0:i())?a:Promise.resolve(),cancelRetry:c,continueRetry:u}}const LA=console;function nle(){let d=[],e=0,t=u=>{u()},s=u=>{u()};const i=u=>{let h;e++;try{h=u()}finally{e--,e||a()}return h},n=u=>{e?d.push(u):Mq(()=>{t(u)})},r=u=>(...h)=>{n(()=>{u(...h)})},a=()=>{const u=d;d=[],u.length&&Mq(()=>{s(()=>{u.forEach(h=>{t(h)})})})};return{batch:i,batchCalls:r,schedule:n,setNotifyFunction:u=>{t=u},setBatchNotifyFunction:u=>{s=u}}}const hi=nle();class mG{destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),FM(this.cacheTime)&&(this.gcTimeout=setTimeout(()=>{this.optionalRemove()},this.cacheTime))}updateCacheTime(e){this.cacheTime=Math.max(this.cacheTime||0,e??(K0?1/0:5*60*1e3))}clearGcTimeout(){this.gcTimeout&&(clearTimeout(this.gcTimeout),this.gcTimeout=void 0)}}class rle extends mG{constructor(e){super(),this.abortSignalConsumed=!1,this.defaultOptions=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.cache=e.cache,this.logger=e.logger||LA,this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.initialState=e.state||ale(this.options),this.state=this.initialState,this.scheduleGc()}get meta(){return this.options.meta}setOptions(e){this.options={...this.defaultOptions,...e},this.updateCacheTime(this.options.cacheTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.cache.remove(this)}setData(e,t){const s=GM(this.state.data,e,this.options);return this.dispatch({data:s,type:"success",dataUpdatedAt:t==null?void 0:t.updatedAt,manual:t==null?void 0:t.manual}),s}setState(e,t){this.dispatch({type:"setState",state:e,setStateOptions:t})}cancel(e){var t;const s=this.promise;return(t=this.retryer)==null||t.cancel(e),s?s.then($a).catch($a):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.initialState)}isActive(){return this.observers.some(e=>e.options.enabled!==!1)}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated||!this.state.dataUpdatedAt||this.observers.some(e=>e.getCurrentResult().isStale)}isStaleByTime(e=0){return this.state.isInvalidated||!this.state.dataUpdatedAt||!cG(this.state.dataUpdatedAt,e)}onFocus(){var e;const t=this.observers.find(s=>s.shouldFetchOnWindowFocus());t&&t.refetch({cancelRefetch:!1}),(e=this.retryer)==null||e.continue()}onOnline(){var e;const t=this.observers.find(s=>s.shouldFetchOnReconnect());t&&t.refetch({cancelRefetch:!1}),(e=this.retryer)==null||e.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.cache.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.retryer&&(this.abortSignalConsumed?this.retryer.cancel({revert:!0}):this.retryer.cancelRetry()),this.scheduleGc()),this.cache.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.dispatch({type:"invalidate"})}fetch(e,t){var s,i;if(this.state.fetchStatus!=="idle"){if(this.state.dataUpdatedAt&&t!=null&&t.cancelRefetch)this.cancel({silent:!0});else if(this.promise){var n;return(n=this.retryer)==null||n.continueRetry(),this.promise}}if(e&&this.setOptions(e),!this.options.queryFn){const f=this.observers.find(p=>p.options.queryFn);f&&this.setOptions(f.options)}const r=ele(),a={queryKey:this.queryKey,pageParam:void 0,meta:this.meta},o=f=>{Object.defineProperty(f,"signal",{enumerable:!0,get:()=>{if(r)return this.abortSignalConsumed=!0,r.signal}})};o(a);const c=()=>this.options.queryFn?(this.abortSignalConsumed=!1,this.options.queryFn(a)):Promise.reject("Missing queryFn for queryKey '"+this.options.queryHash+"'"),u={fetchOptions:t,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:c};if(o(u),(s=this.options.behavior)==null||s.onFetch(u),this.revertState=this.state,this.state.fetchStatus==="idle"||this.state.fetchMeta!==((i=u.fetchOptions)==null?void 0:i.meta)){var h;this.dispatch({type:"fetch",meta:(h=u.fetchOptions)==null?void 0:h.meta})}const l=f=>{if(o1(f)&&f.silent||this.dispatch({type:"error",error:f}),!o1(f)){var p,m,g,y;(p=(m=this.cache.config).onError)==null||p.call(m,f,this),(g=(y=this.cache.config).onSettled)==null||g.call(y,this.state.data,f,this)}this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return this.retryer=pG({fn:u.fetchFn,abort:r==null?void 0:r.abort.bind(r),onSuccess:f=>{var p,m,g,y;if(typeof f>"u"){l(new Error(this.queryHash+" data is undefined"));return}this.setData(f),(p=(m=this.cache.config).onSuccess)==null||p.call(m,f,this),(g=(y=this.cache.config).onSettled)==null||g.call(y,f,this.state.error,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1},onError:l,onFail:(f,p)=>{this.dispatch({type:"failed",failureCount:f,error:p})},onPause:()=>{this.dispatch({type:"pause"})},onContinue:()=>{this.dispatch({type:"continue"})},retry:u.options.retry,retryDelay:u.options.retryDelay,networkMode:u.options.networkMode}),this.promise=this.retryer.promise,this.promise}dispatch(e){const t=s=>{var i,n;switch(e.type){case"failed":return{...s,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...s,fetchStatus:"paused"};case"continue":return{...s,fetchStatus:"fetching"};case"fetch":return{...s,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:(i=e.meta)!=null?i:null,fetchStatus:iO(this.options.networkMode)?"fetching":"paused",...!s.dataUpdatedAt&&{error:null,status:"loading"}};case"success":return{...s,data:e.data,dataUpdateCount:s.dataUpdateCount+1,dataUpdatedAt:(n=e.dataUpdatedAt)!=null?n:Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const r=e.error;return o1(r)&&r.revert&&this.revertState?{...this.revertState,fetchStatus:"idle"}:{...s,error:r,errorUpdateCount:s.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:s.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:"idle",status:"error"};case"invalidate":return{...s,isInvalidated:!0};case"setState":return{...s,...e.state}}};this.state=t(this.state),hi.batch(()=>{this.observers.forEach(s=>{s.onQueryUpdate(e)}),this.cache.notify({query:this,type:"updated",action:e})})}}function ale(d){const e=typeof d.initialData=="function"?d.initialData():d.initialData,t=typeof e<"u",s=t?typeof d.initialDataUpdatedAt=="function"?d.initialDataUpdatedAt():d.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:t?s??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:t?"success":"loading",fetchStatus:"idle"}}class gG extends bf{constructor(e){super(),this.config=e||{},this.queries=[],this.queriesMap={}}build(e,t,s){var i;const n=t.queryKey,r=(i=t.queryHash)!=null?i:AA(n,t);let a=this.get(r);return a||(a=new rle({cache:this,logger:e.getLogger(),queryKey:n,queryHash:r,options:e.defaultQueryOptions(t),state:s,defaultOptions:e.getQueryDefaults(n)}),this.add(a)),a}add(e){this.queriesMap[e.queryHash]||(this.queriesMap[e.queryHash]=e,this.queries.push(e),this.notify({type:"added",query:e}))}remove(e){const t=this.queriesMap[e.queryHash];t&&(e.destroy(),this.queries=this.queries.filter(s=>s!==e),t===e&&delete this.queriesMap[e.queryHash],this.notify({type:"removed",query:e}))}clear(){hi.batch(()=>{this.queries.forEach(e=>{this.remove(e)})})}get(e){return this.queriesMap[e]}getAll(){return this.queries}find(e,t){const[s]=Eu(e,t);return typeof s.exact>"u"&&(s.exact=!0),this.queries.find(i=>xq(s,i))}findAll(e,t){const[s]=Eu(e,t);return Object.keys(s).length>0?this.queries.filter(i=>xq(s,i)):this.queries}notify(e){hi.batch(()=>{this.listeners.forEach(({listener:t})=>{t(e)})})}onFocus(){hi.batch(()=>{this.queries.forEach(e=>{e.onFocus()})})}onOnline(){hi.batch(()=>{this.queries.forEach(e=>{e.onOnline()})})}}class ole extends mG{constructor(e){super(),this.defaultOptions=e.defaultOptions,this.mutationId=e.mutationId,this.mutationCache=e.mutationCache,this.logger=e.logger||LA,this.observers=[],this.state=e.state||yG(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options={...this.defaultOptions,...e},this.updateCacheTime(this.options.cacheTime)}get meta(){return this.options.meta}setState(e){this.dispatch({type:"setState",state:e})}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.mutationCache.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.observers=this.observers.filter(t=>t!==e),this.scheduleGc(),this.mutationCache.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.observers.length||(this.state.status==="loading"?this.scheduleGc():this.mutationCache.remove(this))}continue(){var e,t;return(e=(t=this.retryer)==null?void 0:t.continue())!=null?e:this.execute()}async execute(){const e=()=>{var M;return this.retryer=pG({fn:()=>this.options.mutationFn?this.options.mutationFn(this.state.variables):Promise.reject("No mutationFn found"),onFail:(_,N)=>{this.dispatch({type:"failed",failureCount:_,error:N})},onPause:()=>{this.dispatch({type:"pause"})},onContinue:()=>{this.dispatch({type:"continue"})},retry:(M=this.options.retry)!=null?M:0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode}),this.retryer.promise},t=this.state.status==="loading";try{var s,i,n,r,a,o,c,u;if(!t){var h,l,f,p;this.dispatch({type:"loading",variables:this.options.variables}),await((h=(l=this.mutationCache.config).onMutate)==null?void 0:h.call(l,this.state.variables,this));const _=await((f=(p=this.options).onMutate)==null?void 0:f.call(p,this.state.variables));_!==this.state.context&&this.dispatch({type:"loading",context:_,variables:this.state.variables})}const M=await e();return await((s=(i=this.mutationCache.config).onSuccess)==null?void 0:s.call(i,M,this.state.variables,this.state.context,this)),await((n=(r=this.options).onSuccess)==null?void 0:n.call(r,M,this.state.variables,this.state.context)),await((a=(o=this.mutationCache.config).onSettled)==null?void 0:a.call(o,M,null,this.state.variables,this.state.context,this)),await((c=(u=this.options).onSettled)==null?void 0:c.call(u,M,null,this.state.variables,this.state.context)),this.dispatch({type:"success",data:M}),M}catch(M){try{var m,g,y,w,b,S,v,C;throw await((m=(g=this.mutationCache.config).onError)==null?void 0:m.call(g,M,this.state.variables,this.state.context,this)),await((y=(w=this.options).onError)==null?void 0:y.call(w,M,this.state.variables,this.state.context)),await((b=(S=this.mutationCache.config).onSettled)==null?void 0:b.call(S,void 0,M,this.state.variables,this.state.context,this)),await((v=(C=this.options).onSettled)==null?void 0:v.call(C,void 0,M,this.state.variables,this.state.context)),M}finally{this.dispatch({type:"error",error:M})}}}dispatch(e){const t=s=>{switch(e.type){case"failed":return{...s,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...s,isPaused:!0};case"continue":return{...s,isPaused:!1};case"loading":return{...s,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:!iO(this.options.networkMode),status:"loading",variables:e.variables};case"success":return{...s,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...s,data:void 0,error:e.error,failureCount:s.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"};case"setState":return{...s,...e.state}}};this.state=t(this.state),hi.batch(()=>{this.observers.forEach(s=>{s.onMutationUpdate(e)}),this.mutationCache.notify({mutation:this,type:"updated",action:e})})}}function yG(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0}}class wG extends bf{constructor(e){super(),this.config=e||{},this.mutations=[],this.mutationId=0}build(e,t,s){const i=new ole({mutationCache:this,logger:e.getLogger(),mutationId:++this.mutationId,options:e.defaultMutationOptions(t),state:s,defaultOptions:t.mutationKey?e.getMutationDefaults(t.mutationKey):void 0});return this.add(i),i}add(e){this.mutations.push(e),this.notify({type:"added",mutation:e})}remove(e){this.mutations=this.mutations.filter(t=>t!==e),this.notify({type:"removed",mutation:e})}clear(){hi.batch(()=>{this.mutations.forEach(e=>{this.remove(e)})})}getAll(){return this.mutations}find(e){return typeof e.exact>"u"&&(e.exact=!0),this.mutations.find(t=>Pq(e,t))}findAll(e){return this.mutations.filter(t=>Pq(e,t))}notify(e){hi.batch(()=>{this.listeners.forEach(({listener:t})=>{t(e)})})}resumePausedMutations(){var e;return this.resuming=((e=this.resuming)!=null?e:Promise.resolve()).then(()=>{const t=this.mutations.filter(s=>s.state.isPaused);return hi.batch(()=>t.reduce((s,i)=>s.then(()=>i.continue().catch($a)),Promise.resolve()))}).then(()=>{this.resuming=void 0}),this.resuming}}function UM(){return{onFetch:d=>{d.fetchFn=()=>{var e,t,s,i,n,r;const a=(e=d.fetchOptions)==null||(t=e.meta)==null?void 0:t.refetchPage,o=(s=d.fetchOptions)==null||(i=s.meta)==null?void 0:i.fetchMore,c=o==null?void 0:o.pageParam,u=(o==null?void 0:o.direction)==="forward",h=(o==null?void 0:o.direction)==="backward",l=((n=d.state.data)==null?void 0:n.pages)||[],f=((r=d.state.data)==null?void 0:r.pageParams)||[];let p=f,m=!1;const g=C=>{Object.defineProperty(C,"signal",{enumerable:!0,get:()=>{var M;if((M=d.signal)!=null&&M.aborted)m=!0;else{var _;(_=d.signal)==null||_.addEventListener("abort",()=>{m=!0})}return d.signal}})},y=d.options.queryFn||(()=>Promise.reject("Missing queryFn for queryKey '"+d.options.queryHash+"'")),w=(C,M,_,N)=>(p=N?[M,...p]:[...p,M],N?[_,...C]:[...C,_]),b=(C,M,_,N)=>{if(m)return Promise.reject("Cancelled");if(typeof _>"u"&&!M&&C.length)return Promise.resolve(C);const A={queryKey:d.queryKey,pageParam:_,meta:d.options.meta};g(A);const R=y(A);return Promise.resolve(R).then(U=>w(C,_,U,N))};let S;if(!l.length)S=b([]);else if(u){const C=typeof c<"u",M=C?c:WM(d.options,l);S=b(l,C,M)}else if(h){const C=typeof c<"u",M=C?c:bG(d.options,l);S=b(l,C,M,!0)}else{p=[];const C=typeof d.options.getNextPageParam>"u";S=(a&&l[0]?a(l[0],0,l):!0)?b([],C,f[0]):Promise.resolve(w([],f[0],l[0]));for(let _=1;_{if(a&&l[_]?a(l[_],_,l):!0){const R=C?f[_]:WM(d.options,N);return b(N,C,R)}return Promise.resolve(w(N,f[_],l[_]))})}return S.then(C=>({pages:C,pageParams:p}))}}}}function WM(d,e){return d.getNextPageParam==null?void 0:d.getNextPageParam(e[e.length-1],e)}function bG(d,e){return d.getPreviousPageParam==null?void 0:d.getPreviousPageParam(e[0],e)}function dle(d,e){if(d.getNextPageParam&&Array.isArray(e)){const t=WM(d,e);return typeof t<"u"&&t!==null&&t!==!1}}function cle(d,e){if(d.getPreviousPageParam&&Array.isArray(e)){const t=bG(d,e);return typeof t<"u"&&t!==null&&t!==!1}}class ule{constructor(e={}){this.queryCache=e.queryCache||new gG,this.mutationCache=e.mutationCache||new wG,this.logger=e.logger||LA,this.defaultOptions=e.defaultOptions||{},this.queryDefaults=[],this.mutationDefaults=[],this.mountCount=0}mount(){this.mountCount++,this.mountCount===1&&(this.unsubscribeFocus=lv.subscribe(()=>{lv.isFocused()&&(this.resumePausedMutations(),this.queryCache.onFocus())}),this.unsubscribeOnline=fv.subscribe(()=>{fv.isOnline()&&(this.resumePausedMutations(),this.queryCache.onOnline())}))}unmount(){var e,t;this.mountCount--,this.mountCount===0&&((e=this.unsubscribeFocus)==null||e.call(this),this.unsubscribeFocus=void 0,(t=this.unsubscribeOnline)==null||t.call(this),this.unsubscribeOnline=void 0)}isFetching(e,t){const[s]=Eu(e,t);return s.fetchStatus="fetching",this.queryCache.findAll(s).length}isMutating(e){return this.mutationCache.findAll({...e,fetching:!0}).length}getQueryData(e,t){var s;return(s=this.queryCache.find(e,t))==null?void 0:s.state.data}ensureQueryData(e,t,s){const i=Ep(e,t,s),n=this.getQueryData(i.queryKey);return n?Promise.resolve(n):this.fetchQuery(i)}getQueriesData(e){return this.getQueryCache().findAll(e).map(({queryKey:t,state:s})=>{const i=s.data;return[t,i]})}setQueryData(e,t,s){const i=this.queryCache.find(e),n=i==null?void 0:i.state.data,r=Yhe(t,n);if(typeof r>"u")return;const a=Ep(e),o=this.defaultQueryOptions(a);return this.queryCache.build(this,o).setData(r,{...s,manual:!0})}setQueriesData(e,t,s){return hi.batch(()=>this.getQueryCache().findAll(e).map(({queryKey:i})=>[i,this.setQueryData(i,t,s)]))}getQueryState(e,t){var s;return(s=this.queryCache.find(e,t))==null?void 0:s.state}removeQueries(e,t){const[s]=Eu(e,t),i=this.queryCache;hi.batch(()=>{i.findAll(s).forEach(n=>{i.remove(n)})})}resetQueries(e,t,s){const[i,n]=Eu(e,t,s),r=this.queryCache,a={type:"active",...i};return hi.batch(()=>(r.findAll(i).forEach(o=>{o.reset()}),this.refetchQueries(a,n)))}cancelQueries(e,t,s){const[i,n={}]=Eu(e,t,s);typeof n.revert>"u"&&(n.revert=!0);const r=hi.batch(()=>this.queryCache.findAll(i).map(a=>a.cancel(n)));return Promise.all(r).then($a).catch($a)}invalidateQueries(e,t,s){const[i,n]=Eu(e,t,s);return hi.batch(()=>{var r,a;if(this.queryCache.findAll(i).forEach(c=>{c.invalidate()}),i.refetchType==="none")return Promise.resolve();const o={...i,type:(r=(a=i.refetchType)!=null?a:i.type)!=null?r:"active"};return this.refetchQueries(o,n)})}refetchQueries(e,t,s){const[i,n]=Eu(e,t,s),r=hi.batch(()=>this.queryCache.findAll(i).filter(o=>!o.isDisabled()).map(o=>{var c;return o.fetch(void 0,{...n,cancelRefetch:(c=n==null?void 0:n.cancelRefetch)!=null?c:!0,meta:{refetchPage:i.refetchPage}})}));let a=Promise.all(r).then($a);return n!=null&&n.throwOnError||(a=a.catch($a)),a}fetchQuery(e,t,s){const i=Ep(e,t,s),n=this.defaultQueryOptions(i);typeof n.retry>"u"&&(n.retry=!1);const r=this.queryCache.build(this,n);return r.isStaleByTime(n.staleTime)?r.fetch(n):Promise.resolve(r.state.data)}prefetchQuery(e,t,s){return this.fetchQuery(e,t,s).then($a).catch($a)}fetchInfiniteQuery(e,t,s){const i=Ep(e,t,s);return i.behavior=UM(),this.fetchQuery(i)}prefetchInfiniteQuery(e,t,s){return this.fetchInfiniteQuery(e,t,s).then($a).catch($a)}resumePausedMutations(){return this.mutationCache.resumePausedMutations()}getQueryCache(){return this.queryCache}getMutationCache(){return this.mutationCache}getLogger(){return this.logger}getDefaultOptions(){return this.defaultOptions}setDefaultOptions(e){this.defaultOptions=e}setQueryDefaults(e,t){const s=this.queryDefaults.find(i=>Qu(e)===Qu(i.queryKey));s?s.defaultOptions=t:this.queryDefaults.push({queryKey:e,defaultOptions:t})}getQueryDefaults(e){if(!e)return;const t=this.queryDefaults.find(s=>uv(e,s.queryKey));return t==null?void 0:t.defaultOptions}setMutationDefaults(e,t){const s=this.mutationDefaults.find(i=>Qu(e)===Qu(i.mutationKey));s?s.defaultOptions=t:this.mutationDefaults.push({mutationKey:e,defaultOptions:t})}getMutationDefaults(e){if(!e)return;const t=this.mutationDefaults.find(s=>uv(e,s.mutationKey));return t==null?void 0:t.defaultOptions}defaultQueryOptions(e){if(e!=null&&e._defaulted)return e;const t={...this.defaultOptions.queries,...this.getQueryDefaults(e==null?void 0:e.queryKey),...e,_defaulted:!0};return!t.queryHash&&t.queryKey&&(t.queryHash=AA(t.queryKey,t)),typeof t.refetchOnReconnect>"u"&&(t.refetchOnReconnect=t.networkMode!=="always"),typeof t.useErrorBoundary>"u"&&(t.useErrorBoundary=!!t.suspense),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...this.defaultOptions.mutations,...this.getMutationDefaults(e==null?void 0:e.mutationKey),...e,_defaulted:!0}}clear(){this.queryCache.clear(),this.mutationCache.clear()}}class BA extends bf{constructor(e,t){super(),this.client=e,this.options=t,this.trackedProps=new Set,this.selectError=null,this.bindMethods(),this.setOptions(t)}bindMethods(){this.remove=this.remove.bind(this),this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.currentQuery.addObserver(this),Aq(this.currentQuery,this.options)&&this.executeFetch(),this.updateTimers())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return jM(this.currentQuery,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return jM(this.currentQuery,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.clearStaleTimeout(),this.clearRefetchInterval(),this.currentQuery.removeObserver(this)}setOptions(e,t){const s=this.options,i=this.currentQuery;if(this.options=this.client.defaultQueryOptions(e),hv(s,this.options)||this.client.getQueryCache().notify({type:"observerOptionsUpdated",query:this.currentQuery,observer:this}),typeof this.options.enabled<"u"&&typeof this.options.enabled!="boolean")throw new Error("Expected enabled to be a boolean");this.options.queryKey||(this.options.queryKey=s.queryKey),this.updateQuery();const n=this.hasListeners();n&&Lq(this.currentQuery,i,this.options,s)&&this.executeFetch(),this.updateResult(t),n&&(this.currentQuery!==i||this.options.enabled!==s.enabled||this.options.staleTime!==s.staleTime)&&this.updateStaleTimeout();const r=this.computeRefetchInterval();n&&(this.currentQuery!==i||this.options.enabled!==s.enabled||r!==this.currentRefetchInterval)&&this.updateRefetchInterval(r)}getOptimisticResult(e){const t=this.client.getQueryCache().build(this.client,e),s=this.createResult(t,e);return lle(this,s,e)&&(this.currentResult=s,this.currentResultOptions=this.options,this.currentResultState=this.currentQuery.state),s}getCurrentResult(){return this.currentResult}trackResult(e){const t={};return Object.keys(e).forEach(s=>{Object.defineProperty(t,s,{configurable:!1,enumerable:!0,get:()=>(this.trackedProps.add(s),e[s])})}),t}getCurrentQuery(){return this.currentQuery}remove(){this.client.getQueryCache().remove(this.currentQuery)}refetch({refetchPage:e,...t}={}){return this.fetch({...t,meta:{refetchPage:e}})}fetchOptimistic(e){const t=this.client.defaultQueryOptions(e),s=this.client.getQueryCache().build(this.client,t);return s.isFetchingOptimistic=!0,s.fetch().then(()=>this.createResult(s,t))}fetch(e){var t;return this.executeFetch({...e,cancelRefetch:(t=e.cancelRefetch)!=null?t:!0}).then(()=>(this.updateResult(),this.currentResult))}executeFetch(e){this.updateQuery();let t=this.currentQuery.fetch(this.options,e);return e!=null&&e.throwOnError||(t=t.catch($a)),t}updateStaleTimeout(){if(this.clearStaleTimeout(),K0||this.currentResult.isStale||!FM(this.options.staleTime))return;const t=cG(this.currentResult.dataUpdatedAt,this.options.staleTime)+1;this.staleTimeoutId=setTimeout(()=>{this.currentResult.isStale||this.updateResult()},t)}computeRefetchInterval(){var e;return typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.currentResult.data,this.currentQuery):(e=this.options.refetchInterval)!=null?e:!1}updateRefetchInterval(e){this.clearRefetchInterval(),this.currentRefetchInterval=e,!(K0||this.options.enabled===!1||!FM(this.currentRefetchInterval)||this.currentRefetchInterval===0)&&(this.refetchIntervalId=setInterval(()=>{(this.options.refetchIntervalInBackground||lv.isFocused())&&this.executeFetch()},this.currentRefetchInterval))}updateTimers(){this.updateStaleTimeout(),this.updateRefetchInterval(this.computeRefetchInterval())}clearStaleTimeout(){this.staleTimeoutId&&(clearTimeout(this.staleTimeoutId),this.staleTimeoutId=void 0)}clearRefetchInterval(){this.refetchIntervalId&&(clearInterval(this.refetchIntervalId),this.refetchIntervalId=void 0)}createResult(e,t){const s=this.currentQuery,i=this.options,n=this.currentResult,r=this.currentResultState,a=this.currentResultOptions,o=e!==s,c=o?e.state:this.currentQueryInitialState,u=o?this.currentResult:this.previousQueryResult,{state:h}=e;let{dataUpdatedAt:l,error:f,errorUpdatedAt:p,fetchStatus:m,status:g}=h,y=!1,w=!1,b;if(t._optimisticResults){const _=this.hasListeners(),N=!_&&Aq(e,t),A=_&&Lq(e,s,t,i);(N||A)&&(m=iO(e.options.networkMode)?"fetching":"paused",l||(g="loading")),t._optimisticResults==="isRestoring"&&(m="idle")}if(t.keepPreviousData&&!h.dataUpdatedAt&&u!=null&&u.isSuccess&&g!=="error")b=u.data,l=u.dataUpdatedAt,g=u.status,y=!0;else if(t.select&&typeof h.data<"u")if(n&&h.data===(r==null?void 0:r.data)&&t.select===this.selectFn)b=this.selectResult;else try{this.selectFn=t.select,b=t.select(h.data),b=GM(n==null?void 0:n.data,b,t),this.selectResult=b,this.selectError=null}catch(_){this.selectError=_}else b=h.data;if(typeof t.placeholderData<"u"&&typeof b>"u"&&g==="loading"){let _;if(n!=null&&n.isPlaceholderData&&t.placeholderData===(a==null?void 0:a.placeholderData))_=n.data;else if(_=typeof t.placeholderData=="function"?t.placeholderData():t.placeholderData,t.select&&typeof _<"u")try{_=t.select(_),this.selectError=null}catch(N){this.selectError=N}typeof _<"u"&&(g="success",b=GM(n==null?void 0:n.data,_,t),w=!0)}this.selectError&&(f=this.selectError,b=this.selectResult,p=Date.now(),g="error");const S=m==="fetching",v=g==="loading",C=g==="error";return{status:g,fetchStatus:m,isLoading:v,isSuccess:g==="success",isError:C,isInitialLoading:v&&S,data:b,dataUpdatedAt:l,error:f,errorUpdatedAt:p,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:h.dataUpdateCount>0||h.errorUpdateCount>0,isFetchedAfterMount:h.dataUpdateCount>c.dataUpdateCount||h.errorUpdateCount>c.errorUpdateCount,isFetching:S,isRefetching:S&&!v,isLoadingError:C&&h.dataUpdatedAt===0,isPaused:m==="paused",isPlaceholderData:w,isPreviousData:y,isRefetchError:C&&h.dataUpdatedAt!==0,isStale:NA(e,t),refetch:this.refetch,remove:this.remove}}updateResult(e){const t=this.currentResult,s=this.createResult(this.currentQuery,this.options);if(this.currentResultState=this.currentQuery.state,this.currentResultOptions=this.options,hv(s,t))return;this.currentResult=s;const i={cache:!0},n=()=>{if(!t)return!0;const{notifyOnChangeProps:r}=this.options,a=typeof r=="function"?r():r;if(a==="all"||!a&&!this.trackedProps.size)return!0;const o=new Set(a??this.trackedProps);return this.options.useErrorBoundary&&o.add("error"),Object.keys(this.currentResult).some(c=>{const u=c;return this.currentResult[u]!==t[u]&&o.has(u)})};(e==null?void 0:e.listeners)!==!1&&n()&&(i.listeners=!0),this.notify({...i,...e})}updateQuery(){const e=this.client.getQueryCache().build(this.client,this.options);if(e===this.currentQuery)return;const t=this.currentQuery;this.currentQuery=e,this.currentQueryInitialState=e.state,this.previousQueryResult=this.currentResult,this.hasListeners()&&(t==null||t.removeObserver(this),e.addObserver(this))}onQueryUpdate(e){const t={};e.type==="success"?t.onSuccess=!e.manual:e.type==="error"&&!o1(e.error)&&(t.onError=!0),this.updateResult(t),this.hasListeners()&&this.updateTimers()}notify(e){hi.batch(()=>{if(e.onSuccess){var t,s,i,n;(t=(s=this.options).onSuccess)==null||t.call(s,this.currentResult.data),(i=(n=this.options).onSettled)==null||i.call(n,this.currentResult.data,null)}else if(e.onError){var r,a,o,c;(r=(a=this.options).onError)==null||r.call(a,this.currentResult.error),(o=(c=this.options).onSettled)==null||o.call(c,void 0,this.currentResult.error)}e.listeners&&this.listeners.forEach(({listener:u})=>{u(this.currentResult)}),e.cache&&this.client.getQueryCache().notify({query:this.currentQuery,type:"observerResultsUpdated"})})}}function hle(d,e){return e.enabled!==!1&&!d.state.dataUpdatedAt&&!(d.state.status==="error"&&e.retryOnMount===!1)}function Aq(d,e){return hle(d,e)||d.state.dataUpdatedAt>0&&jM(d,e,e.refetchOnMount)}function jM(d,e,t){if(e.enabled!==!1){const s=typeof t=="function"?t(d):t;return s==="always"||s!==!1&&NA(d,e)}return!1}function Lq(d,e,t,s){return t.enabled!==!1&&(d!==e||s.enabled===!1)&&(!t.suspense||d.state.status!=="error")&&NA(d,t)}function NA(d,e){return d.isStaleByTime(e.staleTime)}function lle(d,e,t){return t.keepPreviousData?!1:t.placeholderData!==void 0?e.isPlaceholderData:!hv(d.getCurrentResult(),e)}class fle extends bf{constructor(e,t){super(),this.client=e,this.queries=[],this.result=[],this.observers=[],this.observersMap={},t&&this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.observers.forEach(e=>{e.subscribe(t=>{this.onUpdate(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.observers.forEach(e=>{e.destroy()})}setQueries(e,t){this.queries=e,hi.batch(()=>{const s=this.observers,i=this.findMatchingObservers(this.queries);i.forEach(c=>c.observer.setOptions(c.defaultedQueryOptions,t));const n=i.map(c=>c.observer),r=Object.fromEntries(n.map(c=>[c.options.queryHash,c])),a=n.map(c=>c.getCurrentResult()),o=n.some((c,u)=>c!==s[u]);s.length===n.length&&!o||(this.observers=n,this.observersMap=r,this.result=a,this.hasListeners()&&(Oq(s,n).forEach(c=>{c.destroy()}),Oq(n,s).forEach(c=>{c.subscribe(u=>{this.onUpdate(c,u)})}),this.notify()))})}getCurrentResult(){return this.result}getQueries(){return this.observers.map(e=>e.getCurrentQuery())}getObservers(){return this.observers}getOptimisticResult(e){return this.findMatchingObservers(e).map(t=>t.observer.getOptimisticResult(t.defaultedQueryOptions))}findMatchingObservers(e){const t=this.observers,s=new Map(t.map(f=>[f.options.queryHash,f])),i=e.map(f=>this.client.defaultQueryOptions(f)),n=i.flatMap(f=>{const p=s.get(f.queryHash);return p!=null?[{defaultedQueryOptions:f,observer:p}]:[]}),r=new Set(n.map(f=>f.defaultedQueryOptions.queryHash)),a=i.filter(f=>!r.has(f.queryHash)),o=new Set(n.map(f=>f.observer)),c=t.filter(f=>!o.has(f)),u=f=>{const p=this.client.defaultQueryOptions(f),m=this.observersMap[p.queryHash];return m??new BA(this.client,p)},h=a.map((f,p)=>{if(f.keepPreviousData){const m=c[p];if(m!==void 0)return{defaultedQueryOptions:f,observer:m}}return{defaultedQueryOptions:f,observer:u(f)}}),l=(f,p)=>i.indexOf(f.defaultedQueryOptions)-i.indexOf(p.defaultedQueryOptions);return n.concat(h).sort(l)}onUpdate(e,t){const s=this.observers.indexOf(e);s!==-1&&(this.result=Zhe(this.result,s,t),this.notify())}notify(){hi.batch(()=>{this.listeners.forEach(({listener:e})=>{e(this.result)})})}}class ple extends BA{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e,t){super.setOptions({...e,behavior:UM()},t)}getOptimisticResult(e){return e.behavior=UM(),super.getOptimisticResult(e)}fetchNextPage({pageParam:e,...t}={}){return this.fetch({...t,meta:{fetchMore:{direction:"forward",pageParam:e}}})}fetchPreviousPage({pageParam:e,...t}={}){return this.fetch({...t,meta:{fetchMore:{direction:"backward",pageParam:e}}})}createResult(e,t){var s,i,n,r,a,o;const{state:c}=e,u=super.createResult(e,t),{isFetching:h,isRefetching:l}=u,f=h&&((s=c.fetchMeta)==null||(i=s.fetchMore)==null?void 0:i.direction)==="forward",p=h&&((n=c.fetchMeta)==null||(r=n.fetchMore)==null?void 0:r.direction)==="backward";return{...u,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:dle(t,(a=c.data)==null?void 0:a.pages),hasPreviousPage:cle(t,(o=c.data)==null?void 0:o.pages),isFetchingNextPage:f,isFetchingPreviousPage:p,isRefetching:l&&!f&&!p}}}let mle=class extends bf{constructor(e,t){super(),this.client=e,this.setOptions(t),this.bindMethods(),this.updateResult()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){var t;const s=this.options;this.options=this.client.defaultMutationOptions(e),hv(s,this.options)||this.client.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.currentMutation,observer:this}),(t=this.currentMutation)==null||t.setOptions(this.options)}onUnsubscribe(){if(!this.hasListeners()){var e;(e=this.currentMutation)==null||e.removeObserver(this)}}onMutationUpdate(e){this.updateResult();const t={listeners:!0};e.type==="success"?t.onSuccess=!0:e.type==="error"&&(t.onError=!0),this.notify(t)}getCurrentResult(){return this.currentResult}reset(){this.currentMutation=void 0,this.updateResult(),this.notify({listeners:!0})}mutate(e,t){return this.mutateOptions=t,this.currentMutation&&this.currentMutation.removeObserver(this),this.currentMutation=this.client.getMutationCache().build(this.client,{...this.options,variables:typeof e<"u"?e:this.options.variables}),this.currentMutation.addObserver(this),this.currentMutation.execute()}updateResult(){const e=this.currentMutation?this.currentMutation.state:yG(),t={...e,isLoading:e.status==="loading",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset};this.currentResult=t}notify(e){hi.batch(()=>{if(this.mutateOptions&&this.hasListeners()){if(e.onSuccess){var t,s,i,n;(t=(s=this.mutateOptions).onSuccess)==null||t.call(s,this.currentResult.data,this.currentResult.variables,this.currentResult.context),(i=(n=this.mutateOptions).onSettled)==null||i.call(n,this.currentResult.data,null,this.currentResult.variables,this.currentResult.context)}else if(e.onError){var r,a,o,c;(r=(a=this.mutateOptions).onError)==null||r.call(a,this.currentResult.error,this.currentResult.variables,this.currentResult.context),(o=(c=this.mutateOptions).onSettled)==null||o.call(c,void 0,this.currentResult.error,this.currentResult.variables,this.currentResult.context)}}e.listeners&&this.listeners.forEach(({listener:u})=>{u(this.currentResult)})})}};const EA=vH.useSyncExternalStore,Bq=B.createContext(void 0),kG=B.createContext(!1);function SG(d,e){return d||(e&&typeof window<"u"?(window.ReactQueryClientContext||(window.ReactQueryClientContext=Bq),window.ReactQueryClientContext):Bq)}const nO=({context:d}={})=>{const e=B.useContext(SG(d,B.useContext(kG)));if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},gle=({client:d,children:e,context:t,contextSharing:s=!1})=>{B.useEffect(()=>(d.mount(),()=>{d.unmount()}),[d]);const i=SG(t,s);return B.createElement(kG.Provider,{value:!t&&s},B.createElement(i.Provider,{value:d},e))},vG=B.createContext(!1),TG=()=>B.useContext(vG);vG.Provider;function yle(){let d=!1;return{clearReset:()=>{d=!1},reset:()=>{d=!0},isReset:()=>d}}const wle=B.createContext(yle()),OG=()=>B.useContext(wle);function xG(d,e){return typeof d=="function"?d(...e):!!d}const PG=(d,e)=>{(d.suspense||d.useErrorBoundary)&&(e.isReset()||(d.retryOnMount=!1))},IG=d=>{B.useEffect(()=>{d.clearReset()},[d])},CG=({result:d,errorResetBoundary:e,useErrorBoundary:t,query:s})=>d.isError&&!e.isReset()&&!d.isFetching&&xG(t,[d.error,s]),MG=d=>{d.suspense&&typeof d.staleTime!="number"&&(d.staleTime=1e3)},_G=(d,e)=>d.isLoading&&d.isFetching&&!e,zM=(d,e,t)=>(d==null?void 0:d.suspense)&&_G(e,t),$M=(d,e,t)=>e.fetchOptimistic(d).then(({data:s})=>{d.onSuccess==null||d.onSuccess(s),d.onSettled==null||d.onSettled(s,null)}).catch(s=>{t.clearReset(),d.onError==null||d.onError(s),d.onSettled==null||d.onSettled(void 0,s)});function ble({queries:d,context:e}){const t=nO({context:e}),s=TG(),i=OG(),n=B.useMemo(()=>d.map(l=>{const f=t.defaultQueryOptions(l);return f._optimisticResults=s?"isRestoring":"optimistic",f}),[d,t,s]);n.forEach(l=>{MG(l),PG(l,i)}),IG(i);const[r]=B.useState(()=>new fle(t,n)),a=r.getOptimisticResult(n);EA(B.useCallback(l=>s?()=>{}:r.subscribe(hi.batchCalls(l)),[r,s]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),B.useEffect(()=>{r.setQueries(n,{listeners:!1})},[n,r]);const c=a.some((l,f)=>zM(n[f],l,s))?a.flatMap((l,f)=>{const p=n[f],m=r.getObservers()[f];if(p&&m){if(zM(p,l,s))return $M(p,m,i);_G(l,s)&&$M(p,m,i)}return[]}):[];if(c.length>0)throw Promise.all(c);const u=r.getQueries(),h=a.find((l,f)=>{var p,m;return CG({result:l,errorResetBoundary:i,useErrorBoundary:(p=(m=n[f])==null?void 0:m.useErrorBoundary)!=null?p:!1,query:u[f]})});if(h!=null&&h.error)throw h.error;return a}function AG(d,e){const t=nO({context:d.context}),s=TG(),i=OG(),n=t.defaultQueryOptions(d);n._optimisticResults=s?"isRestoring":"optimistic",n.onError&&(n.onError=hi.batchCalls(n.onError)),n.onSuccess&&(n.onSuccess=hi.batchCalls(n.onSuccess)),n.onSettled&&(n.onSettled=hi.batchCalls(n.onSettled)),MG(n),PG(n,i),IG(i);const[r]=B.useState(()=>new e(t,n)),a=r.getOptimisticResult(n);if(EA(B.useCallback(o=>{const c=s?()=>{}:r.subscribe(hi.batchCalls(o));return r.updateResult(),c},[r,s]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),B.useEffect(()=>{r.setOptions(n,{listeners:!1})},[n,r]),zM(n,a,s))throw $M(n,r,i);if(CG({result:a,errorResetBoundary:i,useErrorBoundary:n.useErrorBoundary,query:r.getCurrentQuery()}))throw a.error;return n.notifyOnChangeProps?a:r.trackResult(a)}function kle(d,e,t){const s=Ep(d,e,t);return AG(s,BA)}function Sle(d,e,t){const s=Jhe(d,e),i=nO({context:s.context}),[n]=B.useState(()=>new mle(i,s));B.useEffect(()=>{n.setOptions(s)},[n,s]);const r=EA(B.useCallback(o=>n.subscribe(hi.batchCalls(o)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),a=B.useCallback((o,c)=>{n.mutate(o,c).catch(vle)},[n]);if(r.error&&xG(n.options.useErrorBoundary,[r.error]))throw r.error;return{...r,mutate:a,mutateAsync:r.mutate}}function vle(){}function Tle(d,e,t){const s=Ep(d,e,t);return AG(s,ple)}function Ole(d){return d}function xle(d){return d.length===0?Ole:d.length===1?d[0]:function(t){return d.reduce((s,i)=>i(s),t)}}function LG(d){const e={subscribe(t){let s=null,i=!1,n=!1,r=!1;function a(){if(s===null){r=!0;return}n||(n=!0,typeof s=="function"?s():s&&s.unsubscribe())}return s=d({next(o){var c;i||(c=t.next)==null||c.call(t,o)},error(o){var c;i||(i=!0,(c=t.error)==null||c.call(t,o),a())},complete(){var o;i||(i=!0,(o=t.complete)==null||o.call(t),a())}}),r&&a(),{unsubscribe:a}},pipe(...t){return xle(t)(e)}};return e}function Ple(d){return e=>{let t=0,s=null;const i=[];function n(){s||(s=e.subscribe({next(a){var o;for(const c of i)(o=c.next)==null||o.call(c,a)},error(a){var o;for(const c of i)(o=c.error)==null||o.call(c,a)},complete(){var a;for(const o of i)(a=o.complete)==null||a.call(o)}}))}function r(){if(t===0&&s){const a=s;s=null,a.unsubscribe()}}return{subscribe(a){return t++,i.push(a),n(),{unsubscribe(){t--,r();const o=i.findIndex(c=>c===a);o>-1&&i.splice(o,1)}}}}}}class RA extends Error{constructor(e){super(e),this.name="ObservableAbortError",Object.setPrototypeOf(this,RA.prototype)}}function Ile(d){let e;return{promise:new Promise((s,i)=>{let n=!1;function r(){n||(n=!0,i(new RA("This operation was aborted.")),a.unsubscribe())}const a=d.subscribe({next(o){n=!0,s(o),r()},error(o){n=!0,i(o),r()},complete(){n=!0,r()}});e=r}),abort:e}}function Cle(d){return LG(e=>{function t(i=0,n=d.op){const r=d.links[i];if(!r)throw new Error("No more links to execute - did you forget to add an ending link?");return r({op:n,next(o){return t(i+1,o)}})}return t().subscribe(e)})}function BG(d){const e=Object.create(null);for(const t in d){const s=d[t];e[s]=t}return e}const rO={PARSE_ERROR:-32700,BAD_REQUEST:-32600,INTERNAL_SERVER_ERROR:-32603,NOT_IMPLEMENTED:-32603,UNAUTHORIZED:-32001,FORBIDDEN:-32003,NOT_FOUND:-32004,METHOD_NOT_SUPPORTED:-32005,TIMEOUT:-32008,CONFLICT:-32009,PRECONDITION_FAILED:-32012,PAYLOAD_TOO_LARGE:-32013,UNPROCESSABLE_CONTENT:-32022,TOO_MANY_REQUESTS:-32029,CLIENT_CLOSED_REQUEST:-32099};BG(rO);BG(rO);const NG=()=>{};function EG(d,e){return new Proxy(NG,{get(s,i){if(!(typeof i!="string"||i==="then"))return EG(d,[...e,i])},apply(s,i,n){const r=e[e.length-1]==="apply";return d({args:r?n.length>=2?n[1]:[]:n,path:r?e.slice(0,-1):e})}})}const aO=d=>EG(d,[]),DA=d=>new Proxy(NG,{get(e,t){if(!(typeof t!="string"||t==="then"))return d(t)}});function Mle(d){return!!d&&!Array.isArray(d)&&typeof d=="object"}class _le extends Error{}function Ale(d){if(d instanceof Error)return d;const e=typeof d;if(!(e==="undefined"||e==="function"||d===null)){if(e!=="object")return new Error(String(d));if(Mle(d)){const t=new _le;for(const s in d)t[s]=d[s];return t}}}function pv(d){return!!d&&!Array.isArray(d)&&typeof d=="object"}function Lle(d,e){if("error"in d){const s=e.transformer.deserialize(d.error);return{ok:!1,error:{...d,error:s}}}return{ok:!0,result:{...d.result,...(!d.result.type||d.result.type==="data")&&{type:"data",data:e.transformer.deserialize(d.result.data)}}}}class fI extends Error{constructor(){super("Unable to transform response from server")}}function Ble(d,e){let t;try{t=Lle(d,e)}catch{throw new fI}if(!t.ok&&(!pv(t.error.error)||typeof t.error.error.code!="number"))throw new fI;if(t.ok&&!pv(t.result))throw new fI;return t}function Nle(d){return d instanceof _d||d instanceof Error&&d.name==="TRPCClientError"}function Ele(d){return pv(d)&&pv(d.error)&&typeof d.error.code=="number"&&typeof d.error.message=="string"}class _d extends Error{static from(e,t={}){const s=e;return Nle(s)?(t.meta&&(s.meta={...s.meta,...t.meta}),s):Ele(s)?new _d(s.error.message,{...t,result:s}):s instanceof Error?new _d(s.message,{...t,cause:Ale(s)}):new _d("Unknown error",{...t,cause:s})}constructor(e,t){var i,n;const s=t==null?void 0:t.cause;super(e,{cause:s}),this.meta=t==null?void 0:t.meta,this.cause=s,this.shape=(i=t==null?void 0:t.result)==null?void 0:i.error,this.data=(n=t==null?void 0:t.result)==null?void 0:n.error.data,this.name="TRPCClientError",Object.setPrototypeOf(this,_d.prototype)}}const Nq=d=>typeof d=="function";function Rle(d){if(d)return d;if(typeof window<"u"&&Nq(window.fetch))return window.fetch;if(typeof globalThis<"u"&&Nq(globalThis.fetch))return globalThis.fetch;throw new Error("No fetch implementation found")}function Dle(d){return d||(typeof window<"u"&&window.AbortController?window.AbortController:typeof globalThis<"u"&&globalThis.AbortController?globalThis.AbortController:null)}function qle(d){return{url:d.url.toString().replace(/\/$/,""),fetch:d.fetch,AbortController:Dle(d.AbortController)}}function Vle(d){const e={};for(let t=0;td.runtime.transformer.serialize(e)))}const DG=d=>{let e=d.url+"/"+d.path;const t=[];if("inputs"in d&&t.push("batch=1"),d.type==="query"){const s=RG(d);s!==void 0&&t.push(`input=${encodeURIComponent(JSON.stringify(s))}`)}return t.length&&(e+="?"+t.join("&")),e},Hle=d=>{if(d.type==="query")return;const e=RG(d);return e!==void 0?JSON.stringify(e):void 0},Gle=d=>Wle({...d,contentTypeHeader:"application/json",getUrl:DG,getBody:Hle});async function Ule(d,e){const t=d.getUrl(d),s=d.getBody(d),{type:i}=d,n=await d.headers();/* istanbul ignore if -- @preserve */if(i==="subscription")throw new Error("Subscriptions should use wsLink");const r={...d.contentTypeHeader?{"content-type":d.contentTypeHeader}:{},...d.batchModeHeader?{"trpc-batch-mode":d.batchModeHeader}:{},...n};return Rle(d.fetch)(t,{method:Fle[i],signal:e==null?void 0:e.signal,body:s,headers:r})}function Wle(d){const e=d.AbortController?new d.AbortController:null,t={};let s=!1;return{promise:new Promise((r,a)=>{Ule(d,e).then(o=>(t.response=o,s=!0,o.json())).then(o=>{t.responseJSON=o,r({json:o,meta:t})}).catch(o=>{s=!0,a(_d.from(o,{meta:t}))})}),cancel:()=>{s||e==null||e.abort()}}}const pI=()=>{throw new Error("Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new")};function mI(d){let e=null,t=null;const s=()=>{clearTimeout(t),t=null,e=null};function i(a){var u,h;const o=[[]];let c=0;for(;;){const l=a[c];if(!l)break;const f=o[o.length-1];if(l.aborted){(u=l.reject)==null||u.call(l,new Error("Aborted")),c++;continue}if(d.validate(f.concat(l).map(m=>m.key))){f.push(l),c++;continue}if(f.length===0){(h=l.reject)==null||h.call(l,new Error("Input is too big for a single dispatch")),c++;continue}o.push([])}return o}function n(){const a=i(e);s();for(const o of a){if(!o.length)continue;const c={items:o,cancel:pI};for(const f of o)f.batch=c;const u=(f,p)=>{var g;const m=c.items[f];(g=m.resolve)==null||g.call(m,p),m.batch=null,m.reject=null,m.resolve=null},{promise:h,cancel:l}=d.fetch(c.items.map(f=>f.key),u);c.cancel=l,h.then(f=>{var p;for(let m=0;m{var p;for(const m of c.items)(p=m.reject)==null||p.call(m,f),m.batch=null})}}function r(a){const o={aborted:!1,key:a,batch:null,resolve:pI,reject:pI},c=new Promise((h,l)=>{o.reject=l,o.resolve=h,e||(e=[]),e.push(o)});return t||(t=setTimeout(n)),{promise:c,cancel:()=>{var h;o.aborted=!0,(h=o.batch)!=null&&h.items.every(l=>l.aborted)&&(o.batch.cancel(),o.batch=null)}}}return{load:r}}function jle(d){return function(t){const s=qle(t),i=t.maxURLLength??1/0;return n=>{const r=h=>{const l=p=>{if(i===1/0)return!0;const m=p.map(w=>w.path).join(","),g=p.map(w=>w.input);return DG({...s,runtime:n,type:h,path:m,inputs:g}).length<=i},f=d({...s,runtime:n,type:h,opts:t});return{validate:l,fetch:f}},a=mI(r("query")),o=mI(r("mutation")),c=mI(r("subscription")),u={query:a,subscription:c,mutation:o};return({op:h})=>LG(l=>{const f=u[h.type],{promise:p,cancel:m}=f.load(h);let g;return p.then(y=>{g=y;const w=Ble(y.json,n);if(!w.ok){l.error(_d.from(w.error,{meta:y.meta}));return}l.next({context:y.meta,result:w.result}),l.complete()}).catch(y=>{l.error(_d.from(y,{meta:g==null?void 0:g.meta}))}),()=>{m()}})}}}const zle=d=>e=>{const t=e.map(r=>r.path).join(","),s=e.map(r=>r.input),{promise:i,cancel:n}=Gle({...d,path:t,inputs:s,headers(){return d.opts.headers?typeof d.opts.headers=="function"?d.opts.headers({opList:e}):d.opts.headers:{}}});return{promise:i.then(r=>(Array.isArray(r.json)?r.json:e.map(()=>r.json)).map(c=>({meta:r.meta,json:c}))),cancel:n}},$le=jle(zle);class Kle{$request({type:e,input:t,path:s,context:i={}}){return Cle({links:this.links,op:{id:++this.requestId,type:e,path:s,input:t,context:i}}).pipe(Ple())}requestAsPromise(e){const t=this.$request(e),{promise:s,abort:i}=Ile(t);return new Promise((r,a)=>{var o;(o=e.signal)==null||o.addEventListener("abort",i),s.then(c=>{r(c.result.data)}).catch(c=>{a(_d.from(c))})})}query(e,t,s){return this.requestAsPromise({type:"query",path:e,input:t,context:s==null?void 0:s.context,signal:s==null?void 0:s.signal})}mutation(e,t,s){return this.requestAsPromise({type:"mutation",path:e,input:t,context:s==null?void 0:s.context,signal:s==null?void 0:s.signal})}subscription(e,t,s){return this.$request({type:"subscription",path:e,input:t,context:s==null?void 0:s.context}).subscribe({next(n){var r,a,o;n.result.type==="started"?(r=s.onStarted)==null||r.call(s):n.result.type==="stopped"?(a=s.onStopped)==null||a.call(s):(o=s.onData)==null||o.call(s,n.result.data)},error(n){var r;(r=s.onError)==null||r.call(s,n)},complete(){var n;(n=s.onComplete)==null||n.call(s)}})}constructor(e){this.requestId=0;const t=(()=>{const s=e.transformer;return s?"input"in s?e.transformer:{input:s,output:s}:{input:{serialize:i=>i,deserialize:i=>i},output:{serialize:i=>i,deserialize:i=>i}}})();this.runtime={transformer:{serialize:s=>t.input.serialize(s),deserialize:s=>t.output.deserialize(s)},combinedTransformer:t},this.links=e.links.map(s=>s(this.runtime))}}function Xle(d){return new Kle(d)}const Qle={query:"query",mutate:"mutation",subscribe:"subscription"},Yle=d=>Qle[d];function Zle(d){return DA(e=>d.hasOwnProperty(e)?d[e]:e==="__untypedClient"?d:aO(({path:t,args:s})=>{const i=[e,...t],n=Yle(i.pop()),r=i.join(".");return d[n](r,...s)}))}const KM="APP_URL",qA="ADMIN_PASSWORD",gI="DEVELOPER_MODE_ENABLED",Eq="http://localhost:8000";function Jle(){return localStorage.getItem(qA)}var Os;(function(d){d.assertEqual=i=>i;function e(i){}d.assertIs=e;function t(i){throw new Error}d.assertNever=t,d.arrayToEnum=i=>{const n={};for(const r of i)n[r]=r;return n},d.getValidEnumValues=i=>{const n=d.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),r={};for(const a of n)r[a]=i[a];return d.objectValues(r)},d.objectValues=i=>d.objectKeys(i).map(function(n){return i[n]}),d.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const n=[];for(const r in i)Object.prototype.hasOwnProperty.call(i,r)&&n.push(r);return n},d.find=(i,n)=>{for(const r of i)if(n(r))return r},d.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function s(i,n=" | "){return i.map(r=>typeof r=="string"?`'${r}'`:r).join(n)}d.joinValues=s,d.jsonStringifyReplacer=(i,n)=>typeof n=="bigint"?n.toString():n})(Os||(Os={}));var XM;(function(d){d.mergeShapes=(e,t)=>({...e,...t})})(XM||(XM={}));const vt=Os.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),wc=d=>{switch(typeof d){case"undefined":return vt.undefined;case"string":return vt.string;case"number":return isNaN(d)?vt.nan:vt.number;case"boolean":return vt.boolean;case"function":return vt.function;case"bigint":return vt.bigint;case"symbol":return vt.symbol;case"object":return Array.isArray(d)?vt.array:d===null?vt.null:d.then&&typeof d.then=="function"&&d.catch&&typeof d.catch=="function"?vt.promise:typeof Map<"u"&&d instanceof Map?vt.map:typeof Set<"u"&&d instanceof Set?vt.set:typeof Date<"u"&&d instanceof Date?vt.date:vt.object;default:return vt.unknown}},et=Os.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),efe=d=>JSON.stringify(d,null,2).replace(/"([^"]+)":/g,"$1:");class ka extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(n){return n.message},s={_errors:[]},i=n=>{for(const r of n.issues)if(r.code==="invalid_union")r.unionErrors.map(i);else if(r.code==="invalid_return_type")i(r.returnTypeError);else if(r.code==="invalid_arguments")i(r.argumentsError);else if(r.path.length===0)s._errors.push(t(r));else{let a=s,o=0;for(;ot.message){const t={},s=[];for(const i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):s.push(e(i));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}}ka.create=d=>new ka(d);const Am=(d,e)=>{let t;switch(d.code){case et.invalid_type:d.received===vt.undefined?t="Required":t=`Expected ${d.expected}, received ${d.received}`;break;case et.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(d.expected,Os.jsonStringifyReplacer)}`;break;case et.unrecognized_keys:t=`Unrecognized key(s) in object: ${Os.joinValues(d.keys,", ")}`;break;case et.invalid_union:t="Invalid input";break;case et.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Os.joinValues(d.options)}`;break;case et.invalid_enum_value:t=`Invalid enum value. Expected ${Os.joinValues(d.options)}, received '${d.received}'`;break;case et.invalid_arguments:t="Invalid function arguments";break;case et.invalid_return_type:t="Invalid function return type";break;case et.invalid_date:t="Invalid date";break;case et.invalid_string:typeof d.validation=="object"?"includes"in d.validation?(t=`Invalid input: must include "${d.validation.includes}"`,typeof d.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${d.validation.position}`)):"startsWith"in d.validation?t=`Invalid input: must start with "${d.validation.startsWith}"`:"endsWith"in d.validation?t=`Invalid input: must end with "${d.validation.endsWith}"`:Os.assertNever(d.validation):d.validation!=="regex"?t=`Invalid ${d.validation}`:t="Invalid";break;case et.too_small:d.type==="array"?t=`Array must contain ${d.exact?"exactly":d.inclusive?"at least":"more than"} ${d.minimum} element(s)`:d.type==="string"?t=`String must contain ${d.exact?"exactly":d.inclusive?"at least":"over"} ${d.minimum} character(s)`:d.type==="number"?t=`Number must be ${d.exact?"exactly equal to ":d.inclusive?"greater than or equal to ":"greater than "}${d.minimum}`:d.type==="date"?t=`Date must be ${d.exact?"exactly equal to ":d.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(d.minimum))}`:t="Invalid input";break;case et.too_big:d.type==="array"?t=`Array must contain ${d.exact?"exactly":d.inclusive?"at most":"less than"} ${d.maximum} element(s)`:d.type==="string"?t=`String must contain ${d.exact?"exactly":d.inclusive?"at most":"under"} ${d.maximum} character(s)`:d.type==="number"?t=`Number must be ${d.exact?"exactly":d.inclusive?"less than or equal to":"less than"} ${d.maximum}`:d.type==="bigint"?t=`BigInt must be ${d.exact?"exactly":d.inclusive?"less than or equal to":"less than"} ${d.maximum}`:d.type==="date"?t=`Date must be ${d.exact?"exactly":d.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(d.maximum))}`:t="Invalid input";break;case et.custom:t="Invalid input";break;case et.invalid_intersection_types:t="Intersection results could not be merged";break;case et.not_multiple_of:t=`Number must be a multiple of ${d.multipleOf}`;break;case et.not_finite:t="Number must be finite";break;default:t=e.defaultError,Os.assertNever(d)}return{message:t}};let qG=Am;function tfe(d){qG=d}function mv(){return qG}const gv=d=>{const{data:e,path:t,errorMaps:s,issueData:i}=d,n=[...t,...i.path||[]],r={...i,path:n};if(i.message!==void 0)return{...i,path:n,message:i.message};let a="";const o=s.filter(c=>!!c).slice().reverse();for(const c of o)a=c(r,{data:e,defaultError:a}).message;return{...i,path:n,message:a}},sfe=[];function mt(d,e){const t=mv(),s=gv({issueData:e,data:d.data,path:d.path,errorMaps:[d.common.contextualErrorMap,d.schemaErrorMap,t,t===Am?void 0:Am].filter(i=>!!i)});d.common.issues.push(s)}class nr{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const i of t){if(i.status==="aborted")return Xt;i.status==="dirty"&&e.dirty(),s.push(i.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const i of t){const n=await i.key,r=await i.value;s.push({key:n,value:r})}return nr.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const i of t){const{key:n,value:r}=i;if(n.status==="aborted"||r.status==="aborted")return Xt;n.status==="dirty"&&e.dirty(),r.status==="dirty"&&e.dirty(),n.value!=="__proto__"&&(typeof r.value<"u"||i.alwaysSet)&&(s[n.value]=r.value)}return{status:e.value,value:s}}}const Xt=Object.freeze({status:"aborted"}),Rp=d=>({status:"dirty",value:d}),wr=d=>({status:"valid",value:d}),QM=d=>d.status==="aborted",YM=d=>d.status==="dirty",Kl=d=>d.status==="valid",X0=d=>typeof Promise<"u"&&d instanceof Promise;function yv(d,e,t,s){if(typeof e=="function"?d!==e||!s:!e.has(d))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(d)}function VG(d,e,t,s,i){if(typeof e=="function"?d!==e||!i:!e.has(d))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(d,t),t}var Lt;(function(d){d.errToObj=e=>typeof e=="string"?{message:e}:e||{},d.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Lt||(Lt={}));var Ay,Ly;class Hd{constructor(e,t,s,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Rq=(d,e)=>{if(Kl(e))return{success:!0,data:e.value};if(!d.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new ka(d.common.issues);return this._error=t,this._error}}};function os(d){if(!d)return{};const{errorMap:e,invalid_type_error:t,required_error:s,description:i}=d;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(r,a)=>{var o,c;const{message:u}=d;return r.code==="invalid_enum_value"?{message:u??a.defaultError}:typeof a.data>"u"?{message:(o=u??s)!==null&&o!==void 0?o:a.defaultError}:r.code!=="invalid_type"?{message:a.defaultError}:{message:(c=u??t)!==null&&c!==void 0?c:a.defaultError}},description:i}}class hs{get description(){return this._def.description}_getType(e){return wc(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:wc(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new nr,ctx:{common:e.parent.common,data:e.data,parsedType:wc(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(X0(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){var s;const i={common:{issues:[],async:(s=t==null?void 0:t.async)!==null&&s!==void 0?s:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:wc(e)},n=this._parseSync({data:e,path:i.path,parent:i});return Rq(i,n)}"~validate"(e){var t,s;const i={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:wc(e)};if(!this["~standard"].async)try{const n=this._parseSync({data:e,path:[],parent:i});return Kl(n)?{value:n.value}:{issues:i.common.issues}}catch(n){!((s=(t=n==null?void 0:n.message)===null||t===void 0?void 0:t.toLowerCase())===null||s===void 0)&&s.includes("encountered")&&(this["~standard"].async=!0),i.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:i}).then(n=>Kl(n)?{value:n.value}:{issues:i.common.issues})}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:wc(e)},i=this._parse({data:e,path:s.path,parent:s}),n=await(X0(i)?i:Promise.resolve(i));return Rq(s,n)}refine(e,t){const s=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,n)=>{const r=e(i),a=()=>n.addIssue({code:et.custom,...s(i)});return typeof Promise<"u"&&r instanceof Promise?r.then(o=>o?!0:(a(),!1)):r?!0:(a(),!1)})}refinement(e,t){return this._refinement((s,i)=>e(s)?!0:(i.addIssue(typeof t=="function"?t(s,i):t),!1))}_refinement(e){return new zo({schema:this,typeName:Kt.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return Dd.create(this,this._def)}nullable(){return Th.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Go.create(this)}promise(){return Bm.create(this,this._def)}or(e){return J0.create([this,e],this._def)}and(e){return ew.create(this,e,this._def)}transform(e){return new zo({...os(this._def),schema:this,typeName:Kt.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new rw({...os(this._def),innerType:this,defaultValue:t,typeName:Kt.ZodDefault})}brand(){return new VA({typeName:Kt.ZodBranded,type:this,...os(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new aw({...os(this._def),innerType:this,catchValue:t,typeName:Kt.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return eb.create(this,e)}readonly(){return ow.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const ife=/^c[^\s-]{8,}$/i,nfe=/^[0-9a-z]+$/,rfe=/^[0-9A-HJKMNP-TV-Z]{26}$/i,afe=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,ofe=/^[a-z0-9_-]{21}$/i,dfe=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,cfe=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,ufe=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,hfe="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let yI;const lfe=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ffe=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,pfe=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,mfe=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,gfe=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,yfe=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,FG="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",wfe=new RegExp(`^${FG}$`);function HG(d){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return d.precision?e=`${e}\\.\\d{${d.precision}}`:d.precision==null&&(e=`${e}(\\.\\d+)?`),e}function bfe(d){return new RegExp(`^${HG(d)}$`)}function GG(d){let e=`${FG}T${HG(d)}`;const t=[];return t.push(d.local?"Z?":"Z"),d.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function kfe(d,e){return!!((e==="v4"||!e)&&lfe.test(d)||(e==="v6"||!e)&&pfe.test(d))}function Sfe(d,e){if(!dfe.test(d))return!1;try{const[t]=d.split("."),s=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),i=JSON.parse(atob(s));return!(typeof i!="object"||i===null||!i.typ||!i.alg||e&&i.alg!==e)}catch{return!1}}function vfe(d,e){return!!((e==="v4"||!e)&&ffe.test(d)||(e==="v6"||!e)&&mfe.test(d))}class Do extends hs{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==vt.string){const n=this._getOrReturnCtx(e);return mt(n,{code:et.invalid_type,expected:vt.string,received:n.parsedType}),Xt}const s=new nr;let i;for(const n of this._def.checks)if(n.kind==="min")e.data.lengthn.value&&(i=this._getOrReturnCtx(e,i),mt(i,{code:et.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),s.dirty());else if(n.kind==="length"){const r=e.data.length>n.value,a=e.data.lengthe.test(i),{validation:t,code:et.invalid_string,...Lt.errToObj(s)})}_addCheck(e){return new Do({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Lt.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Lt.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Lt.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Lt.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Lt.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Lt.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Lt.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Lt.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Lt.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Lt.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Lt.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Lt.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Lt.errToObj(e)})}datetime(e){var t,s;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(s=e==null?void 0:e.local)!==null&&s!==void 0?s:!1,...Lt.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...Lt.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Lt.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Lt.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...Lt.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Lt.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Lt.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Lt.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Lt.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Lt.errToObj(t)})}nonempty(e){return this.min(1,Lt.errToObj(e))}trim(){return new Do({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Do({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Do({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value{var e;return new Do({checks:[],typeName:Kt.ZodString,coerce:(e=d==null?void 0:d.coerce)!==null&&e!==void 0?e:!1,...os(d)})};function Tfe(d,e){const t=(d.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,i=t>s?t:s,n=parseInt(d.toFixed(i).replace(".","")),r=parseInt(e.toFixed(i).replace(".",""));return n%r/Math.pow(10,i)}class kh extends hs{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==vt.number){const n=this._getOrReturnCtx(e);return mt(n,{code:et.invalid_type,expected:vt.number,received:n.parsedType}),Xt}let s;const i=new nr;for(const n of this._def.checks)n.kind==="int"?Os.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),mt(s,{code:et.invalid_type,expected:"integer",received:"float",message:n.message}),i.dirty()):n.kind==="min"?(n.inclusive?e.datan.value:e.data>=n.value)&&(s=this._getOrReturnCtx(e,s),mt(s,{code:et.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),i.dirty()):n.kind==="multipleOf"?Tfe(e.data,n.value)!==0&&(s=this._getOrReturnCtx(e,s),mt(s,{code:et.not_multiple_of,multipleOf:n.value,message:n.message}),i.dirty()):n.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),mt(s,{code:et.not_finite,message:n.message}),i.dirty()):Os.assertNever(n);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Lt.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Lt.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Lt.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Lt.toString(t))}setLimit(e,t,s,i){return new kh({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:Lt.toString(i)}]})}_addCheck(e){return new kh({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Lt.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Lt.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Lt.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Lt.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Lt.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Lt.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Lt.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Lt.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Lt.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.valuee.kind==="int"||e.kind==="multipleOf"&&Os.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.valuenew kh({checks:[],typeName:Kt.ZodNumber,coerce:(d==null?void 0:d.coerce)||!1,...os(d)});class Sh extends hs{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==vt.bigint)return this._getInvalidInput(e);let s;const i=new nr;for(const n of this._def.checks)n.kind==="min"?(n.inclusive?e.datan.value:e.data>=n.value)&&(s=this._getOrReturnCtx(e,s),mt(s,{code:et.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),i.dirty()):n.kind==="multipleOf"?e.data%n.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),mt(s,{code:et.not_multiple_of,multipleOf:n.value,message:n.message}),i.dirty()):Os.assertNever(n);return{status:i.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return mt(t,{code:et.invalid_type,expected:vt.bigint,received:t.parsedType}),Xt}gte(e,t){return this.setLimit("min",e,!0,Lt.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Lt.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Lt.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Lt.toString(t))}setLimit(e,t,s,i){return new Sh({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:Lt.toString(i)}]})}_addCheck(e){return new Sh({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Lt.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Lt.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Lt.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Lt.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Lt.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value{var e;return new Sh({checks:[],typeName:Kt.ZodBigInt,coerce:(e=d==null?void 0:d.coerce)!==null&&e!==void 0?e:!1,...os(d)})};class Q0 extends hs{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==vt.boolean){const s=this._getOrReturnCtx(e);return mt(s,{code:et.invalid_type,expected:vt.boolean,received:s.parsedType}),Xt}return wr(e.data)}}Q0.create=d=>new Q0({typeName:Kt.ZodBoolean,coerce:(d==null?void 0:d.coerce)||!1,...os(d)});class Xl extends hs{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==vt.date){const n=this._getOrReturnCtx(e);return mt(n,{code:et.invalid_type,expected:vt.date,received:n.parsedType}),Xt}if(isNaN(e.data.getTime())){const n=this._getOrReturnCtx(e);return mt(n,{code:et.invalid_date}),Xt}const s=new nr;let i;for(const n of this._def.checks)n.kind==="min"?e.data.getTime()n.value&&(i=this._getOrReturnCtx(e,i),mt(i,{code:et.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),s.dirty()):Os.assertNever(n);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Xl({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Lt.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Lt.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.valuenew Xl({checks:[],coerce:(d==null?void 0:d.coerce)||!1,typeName:Kt.ZodDate,...os(d)});class wv extends hs{_parse(e){if(this._getType(e)!==vt.symbol){const s=this._getOrReturnCtx(e);return mt(s,{code:et.invalid_type,expected:vt.symbol,received:s.parsedType}),Xt}return wr(e.data)}}wv.create=d=>new wv({typeName:Kt.ZodSymbol,...os(d)});class Y0 extends hs{_parse(e){if(this._getType(e)!==vt.undefined){const s=this._getOrReturnCtx(e);return mt(s,{code:et.invalid_type,expected:vt.undefined,received:s.parsedType}),Xt}return wr(e.data)}}Y0.create=d=>new Y0({typeName:Kt.ZodUndefined,...os(d)});class Z0 extends hs{_parse(e){if(this._getType(e)!==vt.null){const s=this._getOrReturnCtx(e);return mt(s,{code:et.invalid_type,expected:vt.null,received:s.parsedType}),Xt}return wr(e.data)}}Z0.create=d=>new Z0({typeName:Kt.ZodNull,...os(d)});class Lm extends hs{constructor(){super(...arguments),this._any=!0}_parse(e){return wr(e.data)}}Lm.create=d=>new Lm({typeName:Kt.ZodAny,...os(d)});class El extends hs{constructor(){super(...arguments),this._unknown=!0}_parse(e){return wr(e.data)}}El.create=d=>new El({typeName:Kt.ZodUnknown,...os(d)});class $c extends hs{_parse(e){const t=this._getOrReturnCtx(e);return mt(t,{code:et.invalid_type,expected:vt.never,received:t.parsedType}),Xt}}$c.create=d=>new $c({typeName:Kt.ZodNever,...os(d)});class bv extends hs{_parse(e){if(this._getType(e)!==vt.undefined){const s=this._getOrReturnCtx(e);return mt(s,{code:et.invalid_type,expected:vt.void,received:s.parsedType}),Xt}return wr(e.data)}}bv.create=d=>new bv({typeName:Kt.ZodVoid,...os(d)});class Go extends hs{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),i=this._def;if(t.parsedType!==vt.array)return mt(t,{code:et.invalid_type,expected:vt.array,received:t.parsedType}),Xt;if(i.exactLength!==null){const r=t.data.length>i.exactLength.value,a=t.data.lengthi.maxLength.value&&(mt(t,{code:et.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((r,a)=>i.type._parseAsync(new Hd(t,r,t.path,a)))).then(r=>nr.mergeArray(s,r));const n=[...t.data].map((r,a)=>i.type._parseSync(new Hd(t,r,t.path,a)));return nr.mergeArray(s,n)}get element(){return this._def.type}min(e,t){return new Go({...this._def,minLength:{value:e,message:Lt.toString(t)}})}max(e,t){return new Go({...this._def,maxLength:{value:e,message:Lt.toString(t)}})}length(e,t){return new Go({...this._def,exactLength:{value:e,message:Lt.toString(t)}})}nonempty(e){return this.min(1,e)}}Go.create=(d,e)=>new Go({type:d,minLength:null,maxLength:null,exactLength:null,typeName:Kt.ZodArray,...os(e)});function gp(d){if(d instanceof Pi){const e={};for(const t in d.shape){const s=d.shape[t];e[t]=Dd.create(gp(s))}return new Pi({...d._def,shape:()=>e})}else return d instanceof Go?new Go({...d._def,type:gp(d.element)}):d instanceof Dd?Dd.create(gp(d.unwrap())):d instanceof Th?Th.create(gp(d.unwrap())):d instanceof Gd?Gd.create(d.items.map(e=>gp(e))):d}class Pi extends hs{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=Os.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==vt.object){const c=this._getOrReturnCtx(e);return mt(c,{code:et.invalid_type,expected:vt.object,received:c.parsedType}),Xt}const{status:s,ctx:i}=this._processInputParams(e),{shape:n,keys:r}=this._getCached(),a=[];if(!(this._def.catchall instanceof $c&&this._def.unknownKeys==="strip"))for(const c in i.data)r.includes(c)||a.push(c);const o=[];for(const c of r){const u=n[c],h=i.data[c];o.push({key:{status:"valid",value:c},value:u._parse(new Hd(i,h,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof $c){const c=this._def.unknownKeys;if(c==="passthrough")for(const u of a)o.push({key:{status:"valid",value:u},value:{status:"valid",value:i.data[u]}});else if(c==="strict")a.length>0&&(mt(i,{code:et.unrecognized_keys,keys:a}),s.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const u of a){const h=i.data[u];o.push({key:{status:"valid",value:u},value:c._parse(new Hd(i,h,i.path,u)),alwaysSet:u in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const c=[];for(const u of o){const h=await u.key,l=await u.value;c.push({key:h,value:l,alwaysSet:u.alwaysSet})}return c}).then(c=>nr.mergeObjectSync(s,c)):nr.mergeObjectSync(s,o)}get shape(){return this._def.shape()}strict(e){return Lt.errToObj,new Pi({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{var i,n,r,a;const o=(r=(n=(i=this._def).errorMap)===null||n===void 0?void 0:n.call(i,t,s).message)!==null&&r!==void 0?r:s.defaultError;return t.code==="unrecognized_keys"?{message:(a=Lt.errToObj(e).message)!==null&&a!==void 0?a:o}:{message:o}}}:{}})}strip(){return new Pi({...this._def,unknownKeys:"strip"})}passthrough(){return new Pi({...this._def,unknownKeys:"passthrough"})}extend(e){return new Pi({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Pi({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Kt.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Pi({...this._def,catchall:e})}pick(e){const t={};return Os.objectKeys(e).forEach(s=>{e[s]&&this.shape[s]&&(t[s]=this.shape[s])}),new Pi({...this._def,shape:()=>t})}omit(e){const t={};return Os.objectKeys(this.shape).forEach(s=>{e[s]||(t[s]=this.shape[s])}),new Pi({...this._def,shape:()=>t})}deepPartial(){return gp(this)}partial(e){const t={};return Os.objectKeys(this.shape).forEach(s=>{const i=this.shape[s];e&&!e[s]?t[s]=i:t[s]=i.optional()}),new Pi({...this._def,shape:()=>t})}required(e){const t={};return Os.objectKeys(this.shape).forEach(s=>{if(e&&!e[s])t[s]=this.shape[s];else{let n=this.shape[s];for(;n instanceof Dd;)n=n._def.innerType;t[s]=n}}),new Pi({...this._def,shape:()=>t})}keyof(){return UG(Os.objectKeys(this.shape))}}Pi.create=(d,e)=>new Pi({shape:()=>d,unknownKeys:"strip",catchall:$c.create(),typeName:Kt.ZodObject,...os(e)});Pi.strictCreate=(d,e)=>new Pi({shape:()=>d,unknownKeys:"strict",catchall:$c.create(),typeName:Kt.ZodObject,...os(e)});Pi.lazycreate=(d,e)=>new Pi({shape:d,unknownKeys:"strip",catchall:$c.create(),typeName:Kt.ZodObject,...os(e)});class J0 extends hs{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;function i(n){for(const a of n)if(a.result.status==="valid")return a.result;for(const a of n)if(a.result.status==="dirty")return t.common.issues.push(...a.ctx.common.issues),a.result;const r=n.map(a=>new ka(a.ctx.common.issues));return mt(t,{code:et.invalid_union,unionErrors:r}),Xt}if(t.common.async)return Promise.all(s.map(async n=>{const r={...t,common:{...t.common,issues:[]},parent:null};return{result:await n._parseAsync({data:t.data,path:t.path,parent:r}),ctx:r}})).then(i);{let n;const r=[];for(const o of s){const c={...t,common:{...t.common,issues:[]},parent:null},u=o._parseSync({data:t.data,path:t.path,parent:c});if(u.status==="valid")return u;u.status==="dirty"&&!n&&(n={result:u,ctx:c}),c.common.issues.length&&r.push(c.common.issues)}if(n)return t.common.issues.push(...n.ctx.common.issues),n.result;const a=r.map(o=>new ka(o));return mt(t,{code:et.invalid_union,unionErrors:a}),Xt}}get options(){return this._def.options}}J0.create=(d,e)=>new J0({options:d,typeName:Kt.ZodUnion,...os(e)});const pc=d=>d instanceof sw?pc(d.schema):d instanceof zo?pc(d.innerType()):d instanceof iw?[d.value]:d instanceof vh?d.options:d instanceof nw?Os.objectValues(d.enum):d instanceof rw?pc(d._def.innerType):d instanceof Y0?[void 0]:d instanceof Z0?[null]:d instanceof Dd?[void 0,...pc(d.unwrap())]:d instanceof Th?[null,...pc(d.unwrap())]:d instanceof VA||d instanceof ow?pc(d.unwrap()):d instanceof aw?pc(d._def.innerType):[];class oO extends hs{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==vt.object)return mt(t,{code:et.invalid_type,expected:vt.object,received:t.parsedType}),Xt;const s=this.discriminator,i=t.data[s],n=this.optionsMap.get(i);return n?t.common.async?n._parseAsync({data:t.data,path:t.path,parent:t}):n._parseSync({data:t.data,path:t.path,parent:t}):(mt(t,{code:et.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),Xt)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const i=new Map;for(const n of t){const r=pc(n.shape[e]);if(!r.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const a of r){if(i.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);i.set(a,n)}}return new oO({typeName:Kt.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...os(s)})}}function ZM(d,e){const t=wc(d),s=wc(e);if(d===e)return{valid:!0,data:d};if(t===vt.object&&s===vt.object){const i=Os.objectKeys(e),n=Os.objectKeys(d).filter(a=>i.indexOf(a)!==-1),r={...d,...e};for(const a of n){const o=ZM(d[a],e[a]);if(!o.valid)return{valid:!1};r[a]=o.data}return{valid:!0,data:r}}else if(t===vt.array&&s===vt.array){if(d.length!==e.length)return{valid:!1};const i=[];for(let n=0;n{if(QM(n)||QM(r))return Xt;const a=ZM(n.value,r.value);return a.valid?((YM(n)||YM(r))&&t.dirty(),{status:t.value,value:a.data}):(mt(s,{code:et.invalid_intersection_types}),Xt)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([n,r])=>i(n,r)):i(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}ew.create=(d,e,t)=>new ew({left:d,right:e,typeName:Kt.ZodIntersection,...os(t)});class Gd extends hs{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==vt.array)return mt(s,{code:et.invalid_type,expected:vt.array,received:s.parsedType}),Xt;if(s.data.lengththis._def.items.length&&(mt(s,{code:et.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const n=[...s.data].map((r,a)=>{const o=this._def.items[a]||this._def.rest;return o?o._parse(new Hd(s,r,s.path,a)):null}).filter(r=>!!r);return s.common.async?Promise.all(n).then(r=>nr.mergeArray(t,r)):nr.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new Gd({...this._def,rest:e})}}Gd.create=(d,e)=>{if(!Array.isArray(d))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Gd({items:d,typeName:Kt.ZodTuple,rest:null,...os(e)})};class tw extends hs{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==vt.object)return mt(s,{code:et.invalid_type,expected:vt.object,received:s.parsedType}),Xt;const i=[],n=this._def.keyType,r=this._def.valueType;for(const a in s.data)i.push({key:n._parse(new Hd(s,a,s.path,a)),value:r._parse(new Hd(s,s.data[a],s.path,a)),alwaysSet:a in s.data});return s.common.async?nr.mergeObjectAsync(t,i):nr.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof hs?new tw({keyType:e,valueType:t,typeName:Kt.ZodRecord,...os(s)}):new tw({keyType:Do.create(),valueType:e,typeName:Kt.ZodRecord,...os(t)})}}class kv extends hs{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==vt.map)return mt(s,{code:et.invalid_type,expected:vt.map,received:s.parsedType}),Xt;const i=this._def.keyType,n=this._def.valueType,r=[...s.data.entries()].map(([a,o],c)=>({key:i._parse(new Hd(s,a,s.path,[c,"key"])),value:n._parse(new Hd(s,o,s.path,[c,"value"]))}));if(s.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const o of r){const c=await o.key,u=await o.value;if(c.status==="aborted"||u.status==="aborted")return Xt;(c.status==="dirty"||u.status==="dirty")&&t.dirty(),a.set(c.value,u.value)}return{status:t.value,value:a}})}else{const a=new Map;for(const o of r){const c=o.key,u=o.value;if(c.status==="aborted"||u.status==="aborted")return Xt;(c.status==="dirty"||u.status==="dirty")&&t.dirty(),a.set(c.value,u.value)}return{status:t.value,value:a}}}}kv.create=(d,e,t)=>new kv({valueType:e,keyType:d,typeName:Kt.ZodMap,...os(t)});class Ql extends hs{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==vt.set)return mt(s,{code:et.invalid_type,expected:vt.set,received:s.parsedType}),Xt;const i=this._def;i.minSize!==null&&s.data.sizei.maxSize.value&&(mt(s,{code:et.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const n=this._def.valueType;function r(o){const c=new Set;for(const u of o){if(u.status==="aborted")return Xt;u.status==="dirty"&&t.dirty(),c.add(u.value)}return{status:t.value,value:c}}const a=[...s.data.values()].map((o,c)=>n._parse(new Hd(s,o,s.path,c)));return s.common.async?Promise.all(a).then(o=>r(o)):r(a)}min(e,t){return new Ql({...this._def,minSize:{value:e,message:Lt.toString(t)}})}max(e,t){return new Ql({...this._def,maxSize:{value:e,message:Lt.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Ql.create=(d,e)=>new Ql({valueType:d,minSize:null,maxSize:null,typeName:Kt.ZodSet,...os(e)});class nm extends hs{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==vt.function)return mt(t,{code:et.invalid_type,expected:vt.function,received:t.parsedType}),Xt;function s(a,o){return gv({data:a,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,mv(),Am].filter(c=>!!c),issueData:{code:et.invalid_arguments,argumentsError:o}})}function i(a,o){return gv({data:a,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,mv(),Am].filter(c=>!!c),issueData:{code:et.invalid_return_type,returnTypeError:o}})}const n={errorMap:t.common.contextualErrorMap},r=t.data;if(this._def.returns instanceof Bm){const a=this;return wr(async function(...o){const c=new ka([]),u=await a._def.args.parseAsync(o,n).catch(f=>{throw c.addIssue(s(o,f)),c}),h=await Reflect.apply(r,this,u);return await a._def.returns._def.type.parseAsync(h,n).catch(f=>{throw c.addIssue(i(h,f)),c})})}else{const a=this;return wr(function(...o){const c=a._def.args.safeParse(o,n);if(!c.success)throw new ka([s(o,c.error)]);const u=Reflect.apply(r,this,c.data),h=a._def.returns.safeParse(u,n);if(!h.success)throw new ka([i(u,h.error)]);return h.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new nm({...this._def,args:Gd.create(e).rest(El.create())})}returns(e){return new nm({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new nm({args:e||Gd.create([]).rest(El.create()),returns:t||El.create(),typeName:Kt.ZodFunction,...os(s)})}}class sw extends hs{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}sw.create=(d,e)=>new sw({getter:d,typeName:Kt.ZodLazy,...os(e)});class iw extends hs{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return mt(t,{received:t.data,code:et.invalid_literal,expected:this._def.value}),Xt}return{status:"valid",value:e.data}}get value(){return this._def.value}}iw.create=(d,e)=>new iw({value:d,typeName:Kt.ZodLiteral,...os(e)});function UG(d,e){return new vh({values:d,typeName:Kt.ZodEnum,...os(e)})}class vh extends hs{constructor(){super(...arguments),Ay.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),s=this._def.values;return mt(t,{expected:Os.joinValues(s),received:t.parsedType,code:et.invalid_type}),Xt}if(yv(this,Ay)||VG(this,Ay,new Set(this._def.values)),!yv(this,Ay).has(e.data)){const t=this._getOrReturnCtx(e),s=this._def.values;return mt(t,{received:t.data,code:et.invalid_enum_value,options:s}),Xt}return wr(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return vh.create(e,{...this._def,...t})}exclude(e,t=this._def){return vh.create(this.options.filter(s=>!e.includes(s)),{...this._def,...t})}}Ay=new WeakMap;vh.create=UG;class nw extends hs{constructor(){super(...arguments),Ly.set(this,void 0)}_parse(e){const t=Os.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==vt.string&&s.parsedType!==vt.number){const i=Os.objectValues(t);return mt(s,{expected:Os.joinValues(i),received:s.parsedType,code:et.invalid_type}),Xt}if(yv(this,Ly)||VG(this,Ly,new Set(Os.getValidEnumValues(this._def.values))),!yv(this,Ly).has(e.data)){const i=Os.objectValues(t);return mt(s,{received:s.data,code:et.invalid_enum_value,options:i}),Xt}return wr(e.data)}get enum(){return this._def.values}}Ly=new WeakMap;nw.create=(d,e)=>new nw({values:d,typeName:Kt.ZodNativeEnum,...os(e)});class Bm extends hs{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==vt.promise&&t.common.async===!1)return mt(t,{code:et.invalid_type,expected:vt.promise,received:t.parsedType}),Xt;const s=t.parsedType===vt.promise?t.data:Promise.resolve(t.data);return wr(s.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Bm.create=(d,e)=>new Bm({type:d,typeName:Kt.ZodPromise,...os(e)});class zo extends hs{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Kt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),i=this._def.effect||null,n={addIssue:r=>{mt(s,r),r.fatal?t.abort():t.dirty()},get path(){return s.path}};if(n.addIssue=n.addIssue.bind(n),i.type==="preprocess"){const r=i.transform(s.data,n);if(s.common.async)return Promise.resolve(r).then(async a=>{if(t.value==="aborted")return Xt;const o=await this._def.schema._parseAsync({data:a,path:s.path,parent:s});return o.status==="aborted"?Xt:o.status==="dirty"||t.value==="dirty"?Rp(o.value):o});{if(t.value==="aborted")return Xt;const a=this._def.schema._parseSync({data:r,path:s.path,parent:s});return a.status==="aborted"?Xt:a.status==="dirty"||t.value==="dirty"?Rp(a.value):a}}if(i.type==="refinement"){const r=a=>{const o=i.refinement(a,n);if(s.common.async)return Promise.resolve(o);if(o instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(s.common.async===!1){const a=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?Xt:(a.status==="dirty"&&t.dirty(),r(a.value),{status:t.value,value:a.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(a=>a.status==="aborted"?Xt:(a.status==="dirty"&&t.dirty(),r(a.value).then(()=>({status:t.value,value:a.value}))))}if(i.type==="transform")if(s.common.async===!1){const r=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!Kl(r))return r;const a=i.transform(r.value,n);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(r=>Kl(r)?Promise.resolve(i.transform(r.value,n)).then(a=>({status:t.value,value:a})):r);Os.assertNever(i)}}zo.create=(d,e,t)=>new zo({schema:d,typeName:Kt.ZodEffects,effect:e,...os(t)});zo.createWithPreprocess=(d,e,t)=>new zo({schema:e,effect:{type:"preprocess",transform:d},typeName:Kt.ZodEffects,...os(t)});class Dd extends hs{_parse(e){return this._getType(e)===vt.undefined?wr(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Dd.create=(d,e)=>new Dd({innerType:d,typeName:Kt.ZodOptional,...os(e)});class Th extends hs{_parse(e){return this._getType(e)===vt.null?wr(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Th.create=(d,e)=>new Th({innerType:d,typeName:Kt.ZodNullable,...os(e)});class rw extends hs{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===vt.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}rw.create=(d,e)=>new rw({innerType:d,typeName:Kt.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...os(e)});class aw extends hs{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return X0(i)?i.then(n=>({status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new ka(s.common.issues)},input:s.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new ka(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}aw.create=(d,e)=>new aw({innerType:d,typeName:Kt.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...os(e)});class Sv extends hs{_parse(e){if(this._getType(e)!==vt.nan){const s=this._getOrReturnCtx(e);return mt(s,{code:et.invalid_type,expected:vt.nan,received:s.parsedType}),Xt}return{status:"valid",value:e.data}}}Sv.create=d=>new Sv({typeName:Kt.ZodNaN,...os(d)});const Ofe=Symbol("zod_brand");class VA extends hs{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class eb extends hs{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const n=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?Xt:n.status==="dirty"?(t.dirty(),Rp(n.value)):this._def.out._parseAsync({data:n.value,path:s.path,parent:s})})();{const i=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return i.status==="aborted"?Xt:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:s.path,parent:s})}}static create(e,t){return new eb({in:e,out:t,typeName:Kt.ZodPipeline})}}class ow extends hs{_parse(e){const t=this._def.innerType._parse(e),s=i=>(Kl(i)&&(i.value=Object.freeze(i.value)),i);return X0(t)?t.then(i=>s(i)):s(t)}unwrap(){return this._def.innerType}}ow.create=(d,e)=>new ow({innerType:d,typeName:Kt.ZodReadonly,...os(e)});function WG(d,e={},t){return d?Lm.create().superRefine((s,i)=>{var n,r;if(!d(s)){const a=typeof e=="function"?e(s):typeof e=="string"?{message:e}:e,o=(r=(n=a.fatal)!==null&&n!==void 0?n:t)!==null&&r!==void 0?r:!0,c=typeof a=="string"?{message:a}:a;i.addIssue({code:"custom",...c,fatal:o})}}):Lm.create()}const xfe={object:Pi.lazycreate};var Kt;(function(d){d.ZodString="ZodString",d.ZodNumber="ZodNumber",d.ZodNaN="ZodNaN",d.ZodBigInt="ZodBigInt",d.ZodBoolean="ZodBoolean",d.ZodDate="ZodDate",d.ZodSymbol="ZodSymbol",d.ZodUndefined="ZodUndefined",d.ZodNull="ZodNull",d.ZodAny="ZodAny",d.ZodUnknown="ZodUnknown",d.ZodNever="ZodNever",d.ZodVoid="ZodVoid",d.ZodArray="ZodArray",d.ZodObject="ZodObject",d.ZodUnion="ZodUnion",d.ZodDiscriminatedUnion="ZodDiscriminatedUnion",d.ZodIntersection="ZodIntersection",d.ZodTuple="ZodTuple",d.ZodRecord="ZodRecord",d.ZodMap="ZodMap",d.ZodSet="ZodSet",d.ZodFunction="ZodFunction",d.ZodLazy="ZodLazy",d.ZodLiteral="ZodLiteral",d.ZodEnum="ZodEnum",d.ZodEffects="ZodEffects",d.ZodNativeEnum="ZodNativeEnum",d.ZodOptional="ZodOptional",d.ZodNullable="ZodNullable",d.ZodDefault="ZodDefault",d.ZodCatch="ZodCatch",d.ZodPromise="ZodPromise",d.ZodBranded="ZodBranded",d.ZodPipeline="ZodPipeline",d.ZodReadonly="ZodReadonly"})(Kt||(Kt={}));const Pfe=(d,e={message:`Input not instance of ${d.name}`})=>WG(t=>t instanceof d,e),jG=Do.create,zG=kh.create,Ife=Sv.create,Cfe=Sh.create,$G=Q0.create,Mfe=Xl.create,_fe=wv.create,Afe=Y0.create,Lfe=Z0.create,Bfe=Lm.create,Nfe=El.create,Efe=$c.create,Rfe=bv.create,Dfe=Go.create,qfe=Pi.create,Vfe=Pi.strictCreate,Ffe=J0.create,Hfe=oO.create,Gfe=ew.create,Ufe=Gd.create,Wfe=tw.create,jfe=kv.create,zfe=Ql.create,$fe=nm.create,Kfe=sw.create,Xfe=iw.create,Qfe=vh.create,Yfe=nw.create,Zfe=Bm.create,Dq=zo.create,Jfe=Dd.create,epe=Th.create,tpe=zo.createWithPreprocess,spe=eb.create,ipe=()=>jG().optional(),npe=()=>zG().optional(),rpe=()=>$G().optional(),ape={string:d=>Do.create({...d,coerce:!0}),number:d=>kh.create({...d,coerce:!0}),boolean:d=>Q0.create({...d,coerce:!0}),bigint:d=>Sh.create({...d,coerce:!0}),date:d=>Xl.create({...d,coerce:!0})},ope=Xt;var Oo=Object.freeze({__proto__:null,defaultErrorMap:Am,setErrorMap:tfe,getErrorMap:mv,makeIssue:gv,EMPTY_PATH:sfe,addIssueToContext:mt,ParseStatus:nr,INVALID:Xt,DIRTY:Rp,OK:wr,isAborted:QM,isDirty:YM,isValid:Kl,isAsync:X0,get util(){return Os},get objectUtil(){return XM},ZodParsedType:vt,getParsedType:wc,ZodType:hs,datetimeRegex:GG,ZodString:Do,ZodNumber:kh,ZodBigInt:Sh,ZodBoolean:Q0,ZodDate:Xl,ZodSymbol:wv,ZodUndefined:Y0,ZodNull:Z0,ZodAny:Lm,ZodUnknown:El,ZodNever:$c,ZodVoid:bv,ZodArray:Go,ZodObject:Pi,ZodUnion:J0,ZodDiscriminatedUnion:oO,ZodIntersection:ew,ZodTuple:Gd,ZodRecord:tw,ZodMap:kv,ZodSet:Ql,ZodFunction:nm,ZodLazy:sw,ZodLiteral:iw,ZodEnum:vh,ZodNativeEnum:nw,ZodPromise:Bm,ZodEffects:zo,ZodTransformer:zo,ZodOptional:Dd,ZodNullable:Th,ZodDefault:rw,ZodCatch:aw,ZodNaN:Sv,BRAND:Ofe,ZodBranded:VA,ZodPipeline:eb,ZodReadonly:ow,custom:WG,Schema:hs,ZodSchema:hs,late:xfe,get ZodFirstPartyTypeKind(){return Kt},coerce:ape,any:Bfe,array:Dfe,bigint:Cfe,boolean:$G,date:Mfe,discriminatedUnion:Hfe,effect:Dq,enum:Qfe,function:$fe,instanceof:Pfe,intersection:Gfe,lazy:Kfe,literal:Xfe,map:jfe,nan:Ife,nativeEnum:Yfe,never:Efe,null:Lfe,nullable:epe,number:zG,object:qfe,oboolean:rpe,onumber:npe,optional:Jfe,ostring:ipe,pipeline:spe,preprocess:tpe,promise:Zfe,record:Wfe,set:zfe,strictObject:Vfe,string:jG,symbol:_fe,transformer:Dq,tuple:Ufe,undefined:Afe,union:Ffe,unknown:Nfe,void:Rfe,NEVER:ope,ZodIssueCode:et,quotelessJson:efe,ZodError:ka});const dpe=Object.keys(rO),cpe=Oo.object({shape:Oo.object({code:Oo.number(),message:Oo.string(),data:Oo.object({code:Oo.enum(dpe),httpStatus:Oo.number(),path:Oo.string(),stack:Oo.string()})})});function JM(d){return cpe.safeParse(d).success}function upe(d){return typeof d=="function"?d():d}const FA=B.forwardRef(function(e,t){const{children:s,container:i,disablePortal:n=!1}=e,[r,a]=B.useState(null),o=Cs(B.isValidElement(s)?s.ref:null,t);if(jo(()=>{n||a(upe(i)||document.body)},[i,n]),jo(()=>{if(r&&!n)return nv(t,r),()=>{nv(t,null)}},[t,r,n]),n){if(B.isValidElement(s)){const c={ref:o};return B.cloneElement(s,c)}return P.jsx(B.Fragment,{children:s})}return P.jsx(B.Fragment,{children:r&&bT.createPortal(s,r)})}),hpe=["input","select","textarea","a[href]","button","[tabindex]","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable="false"])'].join(",");function lpe(d){const e=parseInt(d.getAttribute("tabindex")||"",10);return Number.isNaN(e)?d.contentEditable==="true"||(d.nodeName==="AUDIO"||d.nodeName==="VIDEO"||d.nodeName==="DETAILS")&&d.getAttribute("tabindex")===null?0:d.tabIndex:e}function fpe(d){if(d.tagName!=="INPUT"||d.type!=="radio"||!d.name)return!1;const e=s=>d.ownerDocument.querySelector(`input[type="radio"]${s}`);let t=e(`[name="${d.name}"]:checked`);return t||(t=e(`[name="${d.name}"]`)),t!==d}function ppe(d){return!(d.disabled||d.tagName==="INPUT"&&d.type==="hidden"||fpe(d))}function mpe(d){const e=[],t=[];return Array.from(d.querySelectorAll(hpe)).forEach((s,i)=>{const n=lpe(s);n===-1||!ppe(s)||(n===0?e.push(s):t.push({documentOrder:i,tabIndex:n,node:s}))}),t.sort((s,i)=>s.tabIndex===i.tabIndex?s.documentOrder-i.documentOrder:s.tabIndex-i.tabIndex).map(s=>s.node).concat(e)}function gpe(){return!0}function KG(d){const{children:e,disableAutoFocus:t=!1,disableEnforceFocus:s=!1,disableRestoreFocus:i=!1,getTabbable:n=mpe,isEnabled:r=gpe,open:a}=d,o=B.useRef(!1),c=B.useRef(null),u=B.useRef(null),h=B.useRef(null),l=B.useRef(null),f=B.useRef(!1),p=B.useRef(null),m=Cs(e.ref,p),g=B.useRef(null);B.useEffect(()=>{!a||!p.current||(f.current=!t)},[t,a]),B.useEffect(()=>{if(!a||!p.current)return;const b=ba(p.current);return p.current.contains(b.activeElement)||(p.current.hasAttribute("tabIndex")||p.current.setAttribute("tabIndex","-1"),f.current&&p.current.focus()),()=>{i||(h.current&&h.current.focus&&(o.current=!0,h.current.focus()),h.current=null)}},[a]),B.useEffect(()=>{if(!a||!p.current)return;const b=ba(p.current),S=M=>{g.current=M,!(s||!r()||M.key!=="Tab")&&b.activeElement===p.current&&M.shiftKey&&(o.current=!0,u.current&&u.current.focus())},v=()=>{const M=p.current;if(M===null)return;if(!b.hasFocus()||!r()||o.current){o.current=!1;return}if(M.contains(b.activeElement)||s&&b.activeElement!==c.current&&b.activeElement!==u.current)return;if(b.activeElement!==l.current)l.current=null;else if(l.current!==null)return;if(!f.current)return;let _=[];if((b.activeElement===c.current||b.activeElement===u.current)&&(_=n(p.current)),_.length>0){var N,A;const R=!!((N=g.current)!=null&&N.shiftKey&&((A=g.current)==null?void 0:A.key)==="Tab"),D=_[0],U=_[_.length-1];typeof D!="string"&&typeof U!="string"&&(R?U.focus():D.focus())}else M.focus()};b.addEventListener("focusin",v),b.addEventListener("keydown",S,!0);const C=setInterval(()=>{b.activeElement&&b.activeElement.tagName==="BODY"&&v()},50);return()=>{clearInterval(C),b.removeEventListener("focusin",v),b.removeEventListener("keydown",S,!0)}},[t,s,i,r,a,n]);const y=b=>{h.current===null&&(h.current=b.relatedTarget),f.current=!0,l.current=b.target;const S=e.props.onFocus;S&&S(b)},w=b=>{h.current===null&&(h.current=b.relatedTarget),f.current=!0};return P.jsxs(B.Fragment,{children:[P.jsx("div",{tabIndex:a?0:-1,onFocus:w,ref:c,"data-testid":"sentinelStart"}),B.cloneElement(e,{ref:m,onFocus:y}),P.jsx("div",{tabIndex:a?0:-1,onFocus:w,ref:u,"data-testid":"sentinelEnd"})]})}function ype(d){return typeof d=="string"}function XG(d,e,t){return d===void 0||ype(d)?e:W({},e,{ownerState:W({},e.ownerState,t)})}function qq(d,e,t=(s,i)=>s===i){return d.length===e.length&&d.every((s,i)=>t(s,e[i]))}const wpe={disableDefaultClasses:!1},bpe=B.createContext(wpe);function kpe(d){const{disableDefaultClasses:e}=B.useContext(bpe);return t=>e?"":d(t)}function hn(d,e=[]){if(d===void 0)return{};const t={};return Object.keys(d).filter(s=>s.match(/^on[A-Z]/)&&typeof d[s]=="function"&&!e.includes(s)).forEach(s=>{t[s]=d[s]}),t}function QG(d,e,t){return typeof d=="function"?d(e,t):d}function Spe(d){const{rootElementName:e="",componentName:t}=d,[s,i]=B.useState(e.toUpperCase()),n=B.useCallback(r=>{var a;i((a=r==null?void 0:r.tagName)!=null?a:"")},[]);return[s,n]}function Vq(d){if(d===void 0)return{};const e={};return Object.keys(d).filter(t=>!(t.match(/^on[A-Z]/)&&typeof d[t]=="function")).forEach(t=>{e[t]=d[t]}),e}function YG(d){const{getSlotProps:e,additionalProps:t,externalSlotProps:s,externalForwardedProps:i,className:n}=d;if(!e){const f=Gt(t==null?void 0:t.className,n,i==null?void 0:i.className,s==null?void 0:s.className),p=W({},t==null?void 0:t.style,i==null?void 0:i.style,s==null?void 0:s.style),m=W({},t,i,s);return f.length>0&&(m.className=f),Object.keys(p).length>0&&(m.style=p),{props:m,internalRef:void 0}}const r=hn(W({},i,s)),a=Vq(s),o=Vq(i),c=e(r),u=Gt(c==null?void 0:c.className,t==null?void 0:t.className,n,i==null?void 0:i.className,s==null?void 0:s.className),h=W({},c==null?void 0:c.style,t==null?void 0:t.style,i==null?void 0:i.style,s==null?void 0:s.style),l=W({},c,t,o,a);return u.length>0&&(l.className=u),Object.keys(h).length>0&&(l.style=h),{props:l,internalRef:c.ref}}const vpe=["elementType","externalSlotProps","ownerState","skipResolvingSlotProps"];function ZG(d){var e;const{elementType:t,externalSlotProps:s,ownerState:i,skipResolvingSlotProps:n=!1}=d,r=at(d,vpe),a=n?{}:QG(s,i),{props:o,internalRef:c}=YG(W({},r,{externalSlotProps:a})),u=Cs(c,a==null?void 0:a.ref,(e=d.additionalProps)==null?void 0:e.ref);return XG(t,W({},o,{ref:u}),i)}function Tpe(d){const e=ba(d);return e.body===d?F0(d).innerWidth>e.documentElement.clientWidth:d.scrollHeight>d.clientHeight}function e0(d,e){e?d.setAttribute("aria-hidden","true"):d.removeAttribute("aria-hidden")}function Fq(d){return parseInt(F0(d).getComputedStyle(d).paddingRight,10)||0}function Ope(d){const t=["TEMPLATE","SCRIPT","STYLE","LINK","MAP","META","NOSCRIPT","PICTURE","COL","COLGROUP","PARAM","SLOT","SOURCE","TRACK"].indexOf(d.tagName)!==-1,s=d.tagName==="INPUT"&&d.getAttribute("type")==="hidden";return t||s}function Hq(d,e,t,s,i){const n=[e,t,...s];[].forEach.call(d.children,r=>{const a=n.indexOf(r)===-1,o=!Ope(r);a&&o&&e0(r,i)})}function wI(d,e){let t=-1;return d.some((s,i)=>e(s)?(t=i,!0):!1),t}function xpe(d,e){const t=[],s=d.container;if(!e.disableScrollLock){if(Tpe(s)){const r=voe(ba(s));t.push({value:s.style.paddingRight,property:"padding-right",el:s}),s.style.paddingRight=`${Fq(s)+r}px`;const a=ba(s).querySelectorAll(".mui-fixed");[].forEach.call(a,o=>{t.push({value:o.style.paddingRight,property:"padding-right",el:o}),o.style.paddingRight=`${Fq(o)+r}px`})}let n;if(s.parentNode instanceof DocumentFragment)n=ba(s).body;else{const r=s.parentElement,a=F0(s);n=(r==null?void 0:r.nodeName)==="HTML"&&a.getComputedStyle(r).overflowY==="scroll"?r:s}t.push({value:n.style.overflow,property:"overflow",el:n},{value:n.style.overflowX,property:"overflow-x",el:n},{value:n.style.overflowY,property:"overflow-y",el:n}),n.style.overflow="hidden"}return()=>{t.forEach(({value:n,el:r,property:a})=>{n?r.style.setProperty(a,n):r.style.removeProperty(a)})}}function Ppe(d){const e=[];return[].forEach.call(d.children,t=>{t.getAttribute("aria-hidden")==="true"&&e.push(t)}),e}class Ipe{constructor(){this.containers=void 0,this.modals=void 0,this.modals=[],this.containers=[]}add(e,t){let s=this.modals.indexOf(e);if(s!==-1)return s;s=this.modals.length,this.modals.push(e),e.modalRef&&e0(e.modalRef,!1);const i=Ppe(t);Hq(t,e.mount,e.modalRef,i,!0);const n=wI(this.containers,r=>r.container===t);return n!==-1?(this.containers[n].modals.push(e),s):(this.containers.push({modals:[e],container:t,restore:null,hiddenSiblings:i}),s)}mount(e,t){const s=wI(this.containers,n=>n.modals.indexOf(e)!==-1),i=this.containers[s];i.restore||(i.restore=xpe(i,t))}remove(e,t=!0){const s=this.modals.indexOf(e);if(s===-1)return s;const i=wI(this.containers,r=>r.modals.indexOf(e)!==-1),n=this.containers[i];if(n.modals.splice(n.modals.indexOf(e),1),this.modals.splice(s,1),n.modals.length===0)n.restore&&n.restore(),e.modalRef&&e0(e.modalRef,t),Hq(n.container,e.mount,e.modalRef,n.hiddenSiblings,!1),this.containers.splice(i,1);else{const r=n.modals[n.modals.length-1];r.modalRef&&e0(r.modalRef,!1)}return s}isTopModal(e){return this.modals.length>0&&this.modals[this.modals.length-1]===e}}function Cpe(d){return typeof d=="function"?d():d}function Mpe(d){return d?d.props.hasOwnProperty("in"):!1}const _pe=new Ipe;function JG(d){const{container:e,disableEscapeKeyDown:t=!1,disableScrollLock:s=!1,manager:i=_pe,closeAfterTransition:n=!1,onTransitionEnter:r,onTransitionExited:a,children:o,onClose:c,open:u,rootRef:h}=d,l=B.useRef({}),f=B.useRef(null),p=B.useRef(null),m=Cs(p,h),[g,y]=B.useState(!u),w=Mpe(o);let b=!0;(d["aria-hidden"]==="false"||d["aria-hidden"]===!1)&&(b=!1);const S=()=>ba(f.current),v=()=>(l.current.modalRef=p.current,l.current.mount=f.current,l.current),C=()=>{i.mount(v(),{disableScrollLock:s}),p.current&&(p.current.scrollTop=0)},M=Eo(()=>{const z=Cpe(e)||S().body;i.add(v(),z),p.current&&C()}),_=B.useCallback(()=>i.isTopModal(v()),[i]),N=Eo(z=>{f.current=z,z&&(u&&_()?C():p.current&&e0(p.current,b))}),A=B.useCallback(()=>{i.remove(v(),b)},[b,i]);B.useEffect(()=>()=>{A()},[A]),B.useEffect(()=>{u?M():(!w||!n)&&A()},[u,A,w,n,M]);const R=z=>J=>{var Y;(Y=z.onKeyDown)==null||Y.call(z,J),!(J.key!=="Escape"||J.which===229||!_())&&(t||(J.stopPropagation(),c&&c(J,"escapeKeyDown")))},D=z=>J=>{var Y;(Y=z.onClick)==null||Y.call(z,J),J.target===J.currentTarget&&c&&c(J,"backdropClick")};return{getRootProps:(z={})=>{const J=hn(d);delete J.onTransitionEnter,delete J.onTransitionExited;const Y=W({},J,z);return W({role:"presentation"},Y,{onKeyDown:R(Y),ref:m})},getBackdropProps:(z={})=>{const J=z;return W({"aria-hidden":!0},J,{onClick:D(J),open:u})},getTransitionProps:()=>{const z=()=>{y(!1),r&&r()},J=()=>{y(!0),a&&a(),n&&A()};return{onEnter:YD(z,o==null?void 0:o.props.onEnter),onExited:YD(J,o==null?void 0:o.props.onExited)}},rootRef:m,portalRef:N,isTopModal:_,exited:g,hasTransition:w}}const Ape=["className","elementType","ownerState","externalForwardedProps","getSlotOwnerState","internalForwardedProps"],Lpe=["component","slots","slotProps"],Bpe=["component"];function Fe(d,e){const{className:t,elementType:s,ownerState:i,externalForwardedProps:n,getSlotOwnerState:r,internalForwardedProps:a}=e,o=at(e,Ape),{component:c,slots:u={[d]:void 0},slotProps:h={[d]:void 0}}=n,l=at(n,Lpe),f=u[d]||s,p=QG(h[d],i),m=YG(W({className:t},o,{externalForwardedProps:d==="root"?l:void 0,externalSlotProps:p})),{props:{component:g},internalRef:y}=m,w=at(m.props,Bpe),b=Cs(y,p==null?void 0:p.ref,e.ref),S=r?r(w):{},v=W({},i,S),C=d==="root"?g||c:g,M=XG(f,W({},d==="root"&&!c&&!u[d]&&a,d!=="root"&&!u[d]&&a,w,C&&{as:C},{ref:b}),v);return Object.keys(S).forEach(_=>{delete M[_]}),[f,M]}function Npe(d){return Rt("MuiModal",d)}Dt("MuiModal",["root","hidden","backdrop"]);const HA=B.createContext(void 0),Epe=["children","container","disableAutoFocus","disableEnforceFocus","disableEscapeKeyDown","disablePortal","disableRestoreFocus","disableScrollLock","hideBackdrop","keepMounted","onClose","onKeyDown","open","component","slots","slotProps"],Rpe=d=>{const{open:e}=d;return Nt({root:["root",!e&&"hidden"],backdrop:["backdrop"]},Npe,{})},eU=_e("div")(({ownerState:d,theme:e})=>W({"--unstable_popup-zIndex":`calc(${e.vars.zIndex.modal} + 1)`,'& ~ [role="listbox"]':{"--unstable_popup-zIndex":`calc(${e.vars.zIndex.modal} + 1)`},position:"fixed",zIndex:e.vars.zIndex.modal,right:0,bottom:0,top:0,left:0},!d.open&&{visibility:"hidden"})),Dpe=_e(eU,{name:"JoyModal",slot:"Root",overridesResolver:(d,e)=>e.root})({}),tU=_e("div")(({theme:d})=>({zIndex:-1,position:"fixed",right:0,bottom:0,top:0,left:0,backgroundColor:d.vars.palette.background.backdrop,WebkitTapHighlightColor:"transparent",backdropFilter:"blur(8px)"})),qpe=_e(tU,{name:"JoyModal",slot:"Backdrop",overridesResolver:(d,e)=>e.backdrop})({}),tb=B.forwardRef(function(e,t){const s=qt({props:e,name:"JoyModal"}),{children:i,container:n,disableAutoFocus:r=!1,disableEnforceFocus:a=!1,disableEscapeKeyDown:o=!1,disablePortal:c=!1,disableRestoreFocus:u=!1,disableScrollLock:h=!1,hideBackdrop:l=!1,keepMounted:f=!1,onClose:p,open:m,component:g,slots:y={},slotProps:w={}}=s,b=at(s,Epe),S=W({},s,{disableAutoFocus:r,disableEnforceFocus:a,disableEscapeKeyDown:o,disablePortal:c,disableRestoreFocus:u,disableScrollLock:h,hideBackdrop:l,keepMounted:f}),{getRootProps:v,getBackdropProps:C,rootRef:M,portalRef:_,isTopModal:N}=JG(W({},S,{rootRef:t})),A=Rpe(S),R=W({},b,{component:g,slots:y,slotProps:w}),[D,U]=Fe("root",{ref:M,className:A.root,elementType:Dpe,externalForwardedProps:R,getSlotProps:v,ownerState:S}),[K,j]=Fe("backdrop",{className:A.backdrop,elementType:qpe,externalForwardedProps:R,getSlotProps:C,ownerState:S});return!f&&!m?null:P.jsx(HA.Provider,{value:p,children:P.jsx(FA,{ref:_,container:n,disablePortal:c,children:P.jsxs(D,W({},U,{children:[l?null:P.jsx(K,W({},j)),P.jsx(KG,{disableEnforceFocus:a,disableAutoFocus:r,disableRestoreFocus:u,isEnabled:N,open:m,children:B.Children.only(i)&&B.cloneElement(i,W({},i.props.tabIndex===void 0&&{tabIndex:-1}))})]}))})})}),sU="base";function Vpe(d){return`${sU}--${d}`}function Fpe(d,e){return`${sU}-${d}-${e}`}function iU(d,e){const t=i8[e];return t?Vpe(t):Fpe(d,e)}function Hpe(d,e){const t={};return e.forEach(s=>{t[s]=iU(d,s)}),t}function Jo(d={}){const{disabled:e=!1,focusableWhenDisabled:t,href:s,rootRef:i,tabIndex:n,to:r,type:a,rootElementName:o}=d,c=B.useRef(),[u,h]=B.useState(!1),{isFocusVisibleRef:l,onFocus:f,onBlur:p,ref:m}=mA(),[g,y]=B.useState(!1);e&&!t&&g&&y(!1),B.useEffect(()=>{l.current=g},[g,l]);const[w,b]=Spe({rootElementName:o??(s||r?"a":void 0),componentName:"Button"}),S=j=>z=>{var J;g&&z.preventDefault(),(J=j.onMouseLeave)==null||J.call(j,z)},v=j=>z=>{var J;p(z),l.current===!1&&y(!1),(J=j.onBlur)==null||J.call(j,z)},C=j=>z=>{var J;if(c.current||(c.current=z.currentTarget),f(z),l.current===!0){var Y;y(!0),(Y=j.onFocusVisible)==null||Y.call(j,z)}(J=j.onFocus)==null||J.call(j,z)},M=()=>{const j=c.current;return w==="BUTTON"||w==="INPUT"&&["button","submit","reset"].includes(j==null?void 0:j.type)||w==="A"&&(j==null?void 0:j.href)},_=j=>z=>{if(!e){var J;(J=j.onClick)==null||J.call(j,z)}},N=j=>z=>{var J;e||(h(!0),document.addEventListener("mouseup",()=>{h(!1)},{once:!0})),(J=j.onMouseDown)==null||J.call(j,z)},A=j=>z=>{var J;if((J=j.onKeyDown)==null||J.call(j,z),!z.defaultMuiPrevented&&(z.target===z.currentTarget&&!M()&&z.key===" "&&z.preventDefault(),z.target===z.currentTarget&&z.key===" "&&!e&&h(!0),z.target===z.currentTarget&&!M()&&z.key==="Enter"&&!e)){var Y;(Y=j.onClick)==null||Y.call(j,z),z.preventDefault()}},R=j=>z=>{var J;if(z.target===z.currentTarget&&h(!1),(J=j.onKeyUp)==null||J.call(j,z),z.target===z.currentTarget&&!M()&&!e&&z.key===" "&&!z.defaultMuiPrevented){var Y;(Y=j.onClick)==null||Y.call(j,z)}},D=Cs(b,i,m,c),U={};return n!==void 0&&(U.tabIndex=n),w==="BUTTON"?(U.type=a??"button",t?U["aria-disabled"]=e:U.disabled=e):w==="INPUT"?a&&["button","submit","reset"].includes(a)&&(t?U["aria-disabled"]=e:U.disabled=e):w!==""&&(!s&&!r&&(U.role="button",U.tabIndex=n??0),e&&(U["aria-disabled"]=e,U.tabIndex=t?n??0:-1)),{getRootProps:(j={})=>{const z=W({},hn(d),hn(j)),J=W({type:a},z,U,j,{onBlur:v(z),onClick:_(z),onFocus:C(z),onKeyDown:A(z),onKeyUp:R(z),onMouseDown:N(z),onMouseLeave:S(z),ref:D});return delete J.onFocusVisible,J},focusVisible:g,setFocusVisible:y,active:u,rootRef:D}}function Gq(d){return d.substring(2).toLowerCase()}function Gpe(d,e){return e.documentElement.clientWidth(setTimeout(()=>{o.current=!0},0),()=>{o.current=!1}),[]);const u=Cs(e.ref,a),h=Eo(p=>{const m=c.current;c.current=!1;const g=ba(a.current);if(!o.current||!a.current||"clientX"in p&&Gpe(p,g))return;if(r.current){r.current=!1;return}let y;p.composedPath?y=p.composedPath().indexOf(a.current)>-1:y=!g.documentElement.contains(p.target)||a.current.contains(p.target),!y&&(t||!m)&&i(p)}),l=p=>m=>{c.current=!0;const g=e.props[p];g&&g(m)},f={ref:u};return n!==!1&&(f[n]=l(n)),B.useEffect(()=>{if(n!==!1){const p=Gq(n),m=ba(a.current),g=()=>{r.current=!0};return m.addEventListener(p,h),m.addEventListener("touchmove",g),()=>{m.removeEventListener(p,h),m.removeEventListener("touchmove",g)}}},[h,n]),s!==!1&&(f[s]=l(s)),B.useEffect(()=>{if(s!==!1){const p=Gq(s),m=ba(a.current);return m.addEventListener(p,h),()=>{m.removeEventListener(p,h)}}},[h,s]),P.jsx(B.Fragment,{children:B.cloneElement(e,f)})}const dO=B.createContext(null);function Wpe(d,e){return d===e}const bI={},Uq=()=>{};function e2(d,e){const t=W({},d);return Object.keys(e).forEach(s=>{e[s]!==void 0&&(t[s]=e[s])}),t}function jpe(d){const{nextState:e,initialState:t,stateComparers:s,onStateChange:i,controlledProps:n,lastActionRef:r}=d,a=B.useRef(t);B.useEffect(()=>{if(r.current===null)return;const o=e2(a.current,n);Object.keys(e).forEach(c=>{var u;const h=(u=s[c])!=null?u:Wpe,l=e[c],f=o[c];if(f==null&&l!=null||f!=null&&l==null||f!=null&&l!=null&&!h(l,f)){var p,m;i==null||i((p=r.current.event)!=null?p:null,c,l,(m=r.current.type)!=null?m:"",e)}}),a.current=e,r.current=null},[a,e,r,i,s,n])}function nU(d){const e=B.useRef(null),{reducer:t,initialState:s,controlledProps:i=bI,stateComparers:n=bI,onStateChange:r=Uq,actionContext:a,componentName:o=""}=d;B.useRef(i);const c=B.useCallback((f,p)=>{e.current=p;const m=e2(f,i);return t(m,p)},[i,t]),[u,h]=B.useReducer(c,s),l=B.useCallback(f=>{h(W({},f,{context:a}))},[a]);return jpe({nextState:u,initialState:s,stateComparers:n??bI,onStateChange:r??Uq,controlledProps:i,lastActionRef:e}),[e2(u,i),l]}const Lo={blur:"dropdown:blur",escapeKeyDown:"dropdown:escapeKeyDown",toggle:"dropdown:toggle",open:"dropdown:open",close:"dropdown:close"};function zpe(d,e){switch(e.type){case Lo.blur:return{open:!1,changeReason:e.event};case Lo.escapeKeyDown:return{open:!1,changeReason:e.event};case Lo.toggle:return{open:!d.open,changeReason:e.event};case Lo.open:return{open:!0,changeReason:e.event};case Lo.close:return{open:!1,changeReason:e.event};default:throw new Error("Unhandled action")}}function $pe(d={}){const{defaultOpen:e,onOpenChange:t,open:s,componentName:i="useDropdown"}=d,[n,r]=B.useState(""),[a,o]=B.useState(null),c=B.useRef(null),u=B.useCallback((m,g,y,w)=>{g==="open"&&(t==null||t(m,y)),c.current=w},[t]),h=B.useMemo(()=>s!==void 0?{open:s}:{},[s]),[l,f]=nU({controlledProps:h,initialState:e?{open:!0,changeReason:null}:{open:!1,changeReason:null},onStateChange:u,reducer:zpe,componentName:i});return B.useEffect(()=>{!l.open&&c.current!==null&&c.current!==Lo.blur&&(a==null||a.focus())},[l.open,a]),{contextValue:{state:l,dispatch:f,popupId:n,registerPopup:r,registerTrigger:o,triggerElement:a},open:l.open}}function Kpe(d){const{children:e,open:t,defaultOpen:s,onOpenChange:i}=d,{contextValue:n}=$pe({defaultOpen:s,onOpenChange:i,open:t});return P.jsx(dO.Provider,{value:n,children:e})}const Xpe=B.createContext(void 0);function Qpe(){return B.useContext(Xpe)}function Ype(d={}){const{defaultValue:e,disabled:t=!1,error:s=!1,onBlur:i,onChange:n,onFocus:r,required:a=!1,value:o,inputRef:c}=d,u=Qpe();let h,l,f,p,m;if(u){var g,y,w;h=void 0,l=(g=u.disabled)!=null?g:!1,f=(y=u.error)!=null?y:!1,p=(w=u.required)!=null?w:!1,m=u.value}else h=e,l=t,f=s,p=a,m=o;const{current:b}=B.useRef(m!=null),S=B.useCallback(j=>{},[]),v=B.useRef(null),C=Cs(v,c,S),[M,_]=B.useState(!1);B.useEffect(()=>{!u&&l&&M&&(_(!1),i==null||i())},[u,l,M,i]);const N=j=>z=>{var J;if(u!=null&&u.disabled){z.stopPropagation();return}if((J=j.onFocus)==null||J.call(j,z),u&&u.onFocus){var Y;u==null||(Y=u.onFocus)==null||Y.call(u)}else _(!0)},A=j=>z=>{var J;(J=j.onBlur)==null||J.call(j,z),u&&u.onBlur?u.onBlur():_(!1)},R=j=>(z,...J)=>{var Y,X;if(!b&&(z.target||v.current)==null)throw new Error(R0(17));u==null||(Y=u.onChange)==null||Y.call(u,z),(X=j.onChange)==null||X.call(j,z,...J)},D=j=>z=>{var J;v.current&&z.currentTarget===z.target&&v.current.focus(),(J=j.onClick)==null||J.call(j,z)};return{disabled:l,error:f,focused:M,formControlContext:u,getInputProps:(j={})=>{const J=W({},{onBlur:i,onChange:n,onFocus:r},hn(j)),Y=W({},J,{onBlur:A(J),onChange:R(J),onFocus:N(J)});return W({},Y,{"aria-invalid":f||void 0,defaultValue:h,value:m,required:p,disabled:l},j,{ref:C},Y)},getRootProps:(j={})=>{const z=hn(d,["onBlur","onChange","onFocus"]),J=W({},z,hn(j));return W({},j,J,{onClick:D(J)})},inputRef:C,required:p,value:m}}const ei={blur:"list:blur",focus:"list:focus",itemClick:"list:itemClick",itemHover:"list:itemHover",itemsChange:"list:itemsChange",keyDown:"list:keyDown",resetHighlight:"list:resetHighlight",highlightLast:"list:highlightLast",textNavigation:"list:textNavigation",clearSelection:"list:clearSelection"};function Zpe(d,e,t,s,i,n){if(t.length===0||!s&&t.every((a,o)=>i(a,o)))return-1;let r=d;for(;;){if(!n&&e==="next"&&r===t.length||!n&&e==="previous"&&r===-1)return-1;if(s?!1:i(t[r],r))r+=e==="next"?1:-1,n&&(r=(r+t.length)%t.length);else return r}}function Sn(d,e,t){var s;const{items:i,isItemDisabled:n,disableListWrap:r,disabledItemsFocusable:a,itemComparer:o,focusManagement:c}=t,u=c==="DOM"?0:-1,h=i.length-1,l=d==null?-1:i.findIndex(y=>o(y,d));let f,p,m=!r;switch(e){case"reset":if(u===-1)return null;f=0,p="next",m=!1;break;case"start":f=0,p="next",m=!1;break;case"end":f=h,p="previous",m=!1;break;default:{const y=l+e;y<0?!m&&l!==-1||Math.abs(e)>1?(f=0,p="next"):(f=h,p="previous"):y>h?!m||Math.abs(e)>1?(f=h,p="previous"):(f=0,p="next"):(f=y,p=e>=0?"next":"previous")}}const g=Zpe(f,p,i,a,n,m);return g===-1&&d!==null&&!n(d,l)?d:(s=i[g])!=null?s:null}function Jpe(d,e,t,s){return t==="none"?[]:t==="single"?s(e[0],d)?e:[d]:e.some(i=>s(i,d))?e.filter(i=>!s(i,d)):[...e,d]}function GA(d,e,t){const{itemComparer:s,isItemDisabled:i,selectionMode:n,items:r}=t,{selectedValues:a}=e,o=r.findIndex(u=>s(d,u));if(i(d,o))return e;const c=Jpe(d,a,n,s);return W({},e,{selectedValues:c,highlightedValue:d})}function eme(d,e,t){const s=e.highlightedValue,{orientation:i,pageSize:n}=t;switch(d){case"Home":return W({},e,{highlightedValue:Sn(s,"start",t)});case"End":return W({},e,{highlightedValue:Sn(s,"end",t)});case"PageUp":return W({},e,{highlightedValue:Sn(s,-n,t)});case"PageDown":return W({},e,{highlightedValue:Sn(s,n,t)});case"ArrowUp":if(i!=="vertical")break;return W({},e,{highlightedValue:Sn(s,-1,t)});case"ArrowDown":if(i!=="vertical")break;return W({},e,{highlightedValue:Sn(s,1,t)});case"ArrowLeft":{if(i==="vertical")break;return W({},e,{highlightedValue:Sn(s,i==="horizontal-ltr"?-1:1,t)})}case"ArrowRight":{if(i==="vertical")break;return W({},e,{highlightedValue:Sn(s,i==="horizontal-ltr"?1:-1,t)})}case"Enter":case" ":return e.highlightedValue===null?e:GA(e.highlightedValue,e,t)}return e}function tme(d,e){return e.focusManagement==="DOM"?d:W({},d,{highlightedValue:null})}function sme(d,e,t){var s;const i=(s=t(d))==null?void 0:s.trim().toLowerCase();return!i||i.length===0?!1:i.indexOf(e)===0}function ime(d,e,t){const{items:s,isItemDisabled:i,disabledItemsFocusable:n,getItemAsString:r}=t,a=e.length>1;let o=a?d.highlightedValue:Sn(d.highlightedValue,1,t);for(let c=0;cn(h,t.highlightedValue)))!=null?o:null}else r==="DOM"&&e.length===0&&(a=Sn(null,"reset",s));const u=((i=t.selectedValues)!=null?i:[]).filter(h=>d.some(l=>n(l,h)));return W({},t,{highlightedValue:a,selectedValues:u})}function rme(d,e){return W({},d,{highlightedValue:Sn(null,"reset",e)})}function ame(d,e){return W({},d,{highlightedValue:Sn(null,"end",e)})}function ome(d,e){return W({},d,{selectedValues:[],highlightedValue:Sn(null,"reset",e)})}function cO(d,e){const{type:t,context:s}=e;switch(t){case ei.keyDown:return eme(e.key,d,s);case ei.itemClick:return GA(e.item,d,s);case ei.blur:return tme(d,s);case ei.textNavigation:return ime(d,e.searchString,s);case ei.itemsChange:return nme(e.items,e.previousItems,d,s);case ei.resetHighlight:return rme(d,s);case ei.highlightLast:return ame(d,s);case ei.clearSelection:return ome(d,s);default:return d}}const dme=500;function cme(d){const e=B.useRef({searchString:"",lastTime:null});return B.useCallback(t=>{if(t.key.length===1&&t.key!==" "){const s=e.current,i=t.key.toLowerCase(),n=performance.now();s.searchString.length>0&&s.lastTime&&n-s.lastTime>dme?s.searchString=i:(s.searchString.length!==1||i!==s.searchString)&&(s.searchString+=i),s.lastTime=n,d(s.searchString,t)}},[d])}const Wq={},ume=()=>{},hme=(d,e)=>d===e,lme=()=>!1,fme=d=>typeof d=="string"?d:String(d),pme=()=>({highlightedValue:null,selectedValues:[]});function UA(d){const{controlledProps:e=Wq,disabledItemsFocusable:t=!1,disableListWrap:s=!1,focusManagement:i="activeDescendant",getInitialState:n=pme,getItemDomElement:r,getItemId:a,isItemDisabled:o=lme,rootRef:c,onStateChange:u=ume,items:h,itemComparer:l=hme,getItemAsString:f=fme,onChange:p,onHighlightChange:m,onItemsChange:g,orientation:y="vertical",pageSize:w=5,reducerActionContext:b=Wq,selectionMode:S="single",stateReducer:v,componentName:C="useList"}=d,M=B.useRef(null),_=Cs(c,M),N=B.useCallback((fe,he,Se)=>{if(m==null||m(fe,he,Se),i==="DOM"&&he!=null&&(Se===ei.itemClick||Se===ei.keyDown||Se===ei.textNavigation)){var ye;r==null||(ye=r(he))==null||ye.focus()}},[r,m,i]),A=B.useMemo(()=>({highlightedValue:l,selectedValues:(fe,he)=>qq(fe,he,l)}),[l]),R=B.useCallback((fe,he,Se,ye,ge)=>{switch(u==null||u(fe,he,Se,ye,ge),he){case"highlightedValue":N(fe,Se,ye);break;case"selectedValues":p==null||p(fe,Se,ye);break}},[N,p,u]),D=B.useMemo(()=>({disabledItemsFocusable:t,disableListWrap:s,focusManagement:i,isItemDisabled:o,itemComparer:l,items:h,getItemAsString:f,onHighlightChange:N,orientation:y,pageSize:w,selectionMode:S,stateComparers:A}),[t,s,i,o,l,h,f,N,y,w,S,A]),U=n(),K=v??cO,j=B.useMemo(()=>W({},b,D),[b,D]),[z,J]=nU({reducer:K,actionContext:j,initialState:U,controlledProps:e,stateComparers:A,onStateChange:R,componentName:C}),{highlightedValue:Y,selectedValues:X}=z,Z=cme((fe,he)=>J({type:ei.textNavigation,event:he,searchString:fe})),te=B.useRef([]);B.useEffect(()=>{qq(te.current,h,l)||(J({type:ei.itemsChange,event:null,items:h,previousItems:te.current}),te.current=h,g==null||g(h))},[h,l,J,g]);const Q=fe=>he=>{var Se;if((Se=fe.onKeyDown)==null||Se.call(fe,he),he.defaultMuiPrevented)return;const ye=["Home","End","PageUp","PageDown"];y==="vertical"?ye.push("ArrowUp","ArrowDown"):ye.push("ArrowLeft","ArrowRight"),i==="activeDescendant"&&ye.push(" ","Enter"),ye.includes(he.key)&&he.preventDefault(),J({type:ei.keyDown,key:he.key,event:he}),Z(he)},ie=fe=>he=>{var Se,ye;(Se=fe.onBlur)==null||Se.call(fe,he),!he.defaultMuiPrevented&&((ye=M.current)!=null&&ye.contains(he.relatedTarget)||J({type:ei.blur,event:he}))},ne=(fe={})=>{const he=hn(fe);return W({},fe,{"aria-activedescendant":i==="activeDescendant"&&Y!=null?a(Y):void 0,tabIndex:i==="DOM"?-1:0,ref:_},he,{onBlur:ie(he),onKeyDown:Q(he)})},oe=B.useCallback(fe=>{const he=(X??[]).some(ge=>ge!=null&&l(fe,ge)),Se=Y!=null&&l(fe,Y);return{focusable:i==="DOM",highlighted:Se,selected:he}},[l,X,Y,i]),me=B.useMemo(()=>({dispatch:J,getItemState:oe}),[J,oe]);return B.useDebugValue({state:z}),{contextValue:me,dispatch:J,getRootProps:ne,rootRef:_,state:z}}const Eh=B.createContext(null);function WA(d){const{handlePointerOverEvents:e=!1,item:t}=d,s=B.useContext(Eh);if(!s)throw new Error("useListItem must be used within a ListProvider");const{dispatch:i,getItemState:n}=s,{highlighted:r,selected:a,focusable:o}=n(t),c=B.useCallback(f=>p=>{var m;(m=f.onClick)==null||m.call(f,p),!p.defaultPrevented&&i({type:ei.itemClick,item:t,event:p})},[i,t]),u=B.useCallback(f=>p=>{var m;(m=f.onMouseOver)==null||m.call(f,p),!p.defaultPrevented&&i({type:ei.itemHover,item:t,event:p})},[i,t]);let h;return o&&(h=r?0:-1),{getRootProps:(f={})=>{const p=hn(f);return W({},f,{onClick:c(p),onPointerOver:e?u(p):void 0,tabIndex:h})},highlighted:r,selected:a}}function mme(d,e){if(e.type===ei.itemHover)return W({},d,{highlightedValue:e.item});const t=cO(d,e);if(t.highlightedValue===null&&e.context.items.length>0)return W({},t,{highlightedValue:e.context.items[0]});if(e.type===ei.keyDown&&e.event.key==="Escape")return W({},t,{open:!1});if(e.type===ei.blur){var s;if(!((s=e.context.listboxRef.current)!=null&&s.contains(e.event.relatedTarget))){var i,n;const r=(i=e.context.listboxRef.current)==null?void 0:i.getAttribute("id"),a=(n=e.event.relatedTarget)==null?void 0:n.getAttribute("aria-controls");return r&&a&&r===a?t:W({},t,{open:!1,highlightedValue:e.context.items[0]})}}return t}const sb=B.createContext(null);function gme(d){const e=Array.from(d.keys()).map(t=>{const s=d.get(t);return{key:t,subitem:s}});return e.sort((t,s)=>{const i=t.subitem.ref.current,n=s.subitem.ref.current;return i===null||n===null||i===n?0:i.compareDocumentPosition(n)&Node.DOCUMENT_POSITION_PRECEDING?1:-1}),new Map(e.map(t=>[t.key,t.subitem]))}function uO(){const[d,e]=B.useState(new Map),t=B.useRef(new Set),s=B.useCallback(function(c){t.current.delete(c),e(u=>{const h=new Map(u);return h.delete(c),h})},[]),i=B.useCallback(function(c,u){let h;return typeof c=="function"?h=c(t.current):h=c,t.current.add(h),e(l=>{const f=new Map(l);return f.set(h,u),f}),{id:h,deregister:()=>s(h)}},[s]),n=B.useMemo(()=>gme(d),[d]),r=B.useCallback(function(c){return Array.from(n.keys()).indexOf(c)},[n]);return{contextValue:B.useMemo(()=>({getItemIndex:r,registerItem:i,totalSubitemCount:d.size}),[r,i,d.size]),subitems:n}}function jA(d,e){const t=B.useContext(sb);if(t===null)throw new Error("useCompoundItem must be used within a useCompoundParent");const{registerItem:s}=t,[i,n]=B.useState(typeof d=="function"?void 0:d);return jo(()=>{const{id:r,deregister:a}=s(d,e);return n(r),a},[s,e,d]),{id:i,index:i!==void 0?t.getItemIndex(i):-1,totalItemCount:t.totalSubitemCount}}function Kc(d,e){return function(s={}){const i=W({},s,d(s));return W({},i,e(i))}}const yme={dispatch:()=>{},popupId:"",registerPopup:()=>{},registerTrigger:()=>{},state:{open:!0,changeReason:null},triggerElement:null};function wme(d={}){var e,t;const{listboxRef:s,onItemsChange:i,id:n,disabledItemsFocusable:r=!0,disableListWrap:a=!1,autoFocus:o=!0,componentName:c="useMenu"}=d,u=B.useRef(null),h=Cs(u,s),l=(e=ln(n))!=null?e:"",{state:{open:f,changeReason:p},dispatch:m,triggerElement:g,registerPopup:y}=(t=B.useContext(dO))!=null?t:yme,w=B.useRef(f),{subitems:b,contextValue:S}=uO(),v=B.useMemo(()=>Array.from(b.keys()),[b]),C=B.useCallback(X=>{var Z,te;return X==null?null:(Z=(te=b.get(X))==null?void 0:te.ref.current)!=null?Z:null},[b]),M=B.useCallback(X=>{var Z;return(b==null||(Z=b.get(X))==null?void 0:Z.disabled)||!1},[b]),_=B.useCallback(X=>{var Z,te;return((Z=b.get(X))==null?void 0:Z.label)||((te=b.get(X))==null||(te=te.ref.current)==null?void 0:te.innerText)},[b]),N=B.useMemo(()=>({listboxRef:u}),[u]),{dispatch:A,getRootProps:R,contextValue:D,state:{highlightedValue:U},rootRef:K}=UA({disabledItemsFocusable:r,disableListWrap:a,focusManagement:"DOM",getItemDomElement:C,getInitialState:()=>({selectedValues:[],highlightedValue:null}),isItemDisabled:M,items:v,getItemAsString:_,rootRef:h,onItemsChange:i,reducerActionContext:N,selectionMode:"none",stateReducer:mme,componentName:c});jo(()=>{y(l)},[l,y]),jo(()=>{f&&(p==null?void 0:p.type)==="keydown"&&p.key==="ArrowUp"&&A({type:ei.highlightLast,event:p})},[f,p,A]),B.useEffect(()=>{if(f&&o&&U&&!w.current){var X;(X=b.get(U))==null||(X=X.ref)==null||(X=X.current)==null||X.focus()}},[f,o,U,b,v]),B.useEffect(()=>{var X;if((X=u.current)!=null&&X.contains(document.activeElement)&&U!==null){var Z;b==null||(Z=b.get(U))==null||(Z=Z.ref.current)==null||Z.focus()}},[U,b]);const j=X=>Z=>{var te,Q;(te=X.onBlur)==null||te.call(X,Z),!Z.defaultMuiPrevented&&((Q=u.current)!=null&&Q.contains(Z.relatedTarget)||Z.relatedTarget===g||m({type:Lo.blur,event:Z}))},z=X=>Z=>{var te;(te=X.onKeyDown)==null||te.call(X,Z),!Z.defaultMuiPrevented&&Z.key==="Escape"&&m({type:Lo.escapeKeyDown,event:Z})},J=(X={})=>({onBlur:j(X),onKeyDown:z(X)}),Y=(X={})=>{const Z=Kc(J,R),te=hn(X);return W({},X,te,Z(te),{id:l,role:"menu"})};return B.useDebugValue({subitems:b,highlightedValue:U}),{contextValue:W({},S,D),dispatch:A,getListboxProps:Y,highlightedValue:U,listboxRef:K,menuItems:b,open:f,triggerElement:g}}function bme(d){const{value:e,children:t}=d,{dispatch:s,getItemIndex:i,getItemState:n,registerItem:r,totalSubitemCount:a}=e,o=B.useMemo(()=>({dispatch:s,getItemState:n,getItemIndex:i}),[s,i,n]),c=B.useMemo(()=>({getItemIndex:i,registerItem:r,totalSubitemCount:a}),[r,i,a]);return P.jsx(sb.Provider,{value:c,children:P.jsx(Eh.Provider,{value:o,children:t})})}function kme(d={}){const{disabled:e=!1,focusableWhenDisabled:t,rootRef:s}=d,i=B.useContext(dO);if(i===null)throw new Error("useMenuButton: no menu context available.");const{state:n,dispatch:r,registerTrigger:a,popupId:o}=i,{getRootProps:c,rootRef:u,active:h}=Jo({disabled:e,focusableWhenDisabled:t,rootRef:s}),l=Cs(u,a),f=y=>w=>{var b;(b=y.onClick)==null||b.call(y,w),!w.defaultMuiPrevented&&r({type:Lo.toggle,event:w})},p=y=>w=>{var b;(b=y.onKeyDown)==null||b.call(y,w),!w.defaultMuiPrevented&&(w.key==="ArrowDown"||w.key==="ArrowUp")&&(w.preventDefault(),r({type:Lo.open,event:w}))},m=(y={})=>({onClick:f(y),onKeyDown:p(y)});return{active:h,getRootProps:(y={})=>{const w=hn(y),b=Kc(m,c);return W({"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o},y,w,b(w),{tabIndex:0,ref:l})},open:n.open,rootRef:l}}function Sme(d){return`menu-item-${d.size}`}const vme={dispatch:()=>{},popupId:"",registerPopup:()=>{},registerTrigger:()=>{},state:{open:!0,changeReason:null},triggerElement:null};function Tme(d){var e;const{disabled:t=!1,id:s,rootRef:i,label:n,disableFocusOnHover:r=!1}=d,a=ln(s),o=B.useRef(null),c=B.useMemo(()=>({disabled:t,id:a??"",label:n,ref:o}),[t,a,n]),{dispatch:u}=(e=B.useContext(dO))!=null?e:vme,{getRootProps:h,highlighted:l}=WA({item:a,handlePointerOverEvents:!r}),{index:f,totalItemCount:p}=jA(a??Sme,c),{getRootProps:m,focusVisible:g,rootRef:y}=Jo({disabled:t,focusableWhenDisabled:!0}),w=Cs(y,i,o);B.useDebugValue({id:a,highlighted:l,disabled:t,label:n});const b=C=>M=>{var _;(_=C.onClick)==null||_.call(C,M),!M.defaultMuiPrevented&&u({type:Lo.close,event:M})},S=(C={})=>W({},C,{onClick:b(C)});function v(C={}){const M=hn(C),_=Kc(S,Kc(m,h));return W({},C,M,_(M),{id:a,ref:w,role:"menuitem"})}return a===void 0?{getRootProps:v,disabled:!1,focusVisible:g,highlighted:!1,index:-1,totalItemCount:0,rootRef:w}:{getRootProps:v,disabled:t,focusVisible:g,highlighted:l,index:f,totalItemCount:p,rootRef:w}}function Ome(d){const e=B.useContext(Eh);if(!e)throw new Error("MenuItem: ListContext was not found.");const t=ln(d),{getItemState:s,dispatch:i}=e;let n;t!=null?n=s(t):n={focusable:!0,highlighted:!1,selected:!1};const{highlighted:r,selected:a,focusable:o}=n,c=B.useCallback(h=>{if(h!==t)throw new Error(["Base UI MenuItem: Tried to access the state of another MenuItem.",`itemValue: ${h} | id: ${t}`,"This is unsupported when the MenuItem uses the MenuItemContextStabilizer as a performance optimization."].join("/n"));return{highlighted:r,selected:a,focusable:o}},[r,a,o,t]);return{contextValue:B.useMemo(()=>({dispatch:i,getItemState:c}),[i,c]),id:t}}function xme(d){const{value:e,label:t,disabled:s,rootRef:i,id:n}=d,{getRootProps:r,highlighted:a,selected:o}=WA({item:e}),{getRootProps:c,rootRef:u}=Jo({disabled:s,focusableWhenDisabled:!0}),h=ln(n),l=B.useRef(null),f=B.useMemo(()=>({disabled:s,label:t,value:e,ref:l,id:h}),[s,t,e,h]),{index:p}=jA(e,f),m=Cs(i,l,u),g=w=>b=>{var S;(S=w.onKeyDown)==null||S.call(w,b),!b.defaultMuiPrevented&&[" ","Enter"].includes(b.key)&&(b.defaultMuiPrevented=!0)},y=(w={})=>({onKeyDown:g(w)});return{getRootProps:(w={})=>{const b=hn(w),S=Kc(r,Kc(c,y));return W({},w,b,S(b),{id:h,ref:m,role:"option","aria-selected":o})},highlighted:a,index:p,selected:o,rootRef:m}}function Pme(d){const e=B.useContext(Eh);if(!e)throw new Error("Option: ListContext was not found.");const{getItemState:t,dispatch:s}=e,{highlighted:i,selected:n,focusable:r}=t(d),a=B.useCallback(c=>{if(c!==d)throw new Error(["Base UI Option: Tried to access the state of another Option.","This is unsupported when the Option uses the OptionContextStabilizer as a performance optimization."].join("/n"));return{highlighted:i,selected:n,focusable:r}},[i,n,r,d]);return{contextValue:B.useMemo(()=>({dispatch:s,getItemState:a}),[s,a])}}var Ur="top",ho="bottom",lo="right",Wr="left",zA="auto",ib=[Ur,ho,lo,Wr],Nm="start",dw="end",Ime="clippingParents",rU="viewport",dy="popper",Cme="reference",jq=ib.reduce(function(d,e){return d.concat([e+"-"+Nm,e+"-"+dw])},[]),aU=[].concat(ib,[zA]).reduce(function(d,e){return d.concat([e,e+"-"+Nm,e+"-"+dw])},[]),Mme="beforeRead",_me="read",Ame="afterRead",Lme="beforeMain",Bme="main",Nme="afterMain",Eme="beforeWrite",Rme="write",Dme="afterWrite",qme=[Mme,_me,Ame,Lme,Bme,Nme,Eme,Rme,Dme];function Ud(d){return d?(d.nodeName||"").toLowerCase():null}function Pa(d){if(d==null)return window;if(d.toString()!=="[object Window]"){var e=d.ownerDocument;return e&&e.defaultView||window}return d}function Yl(d){var e=Pa(d).Element;return d instanceof e||d instanceof Element}function ao(d){var e=Pa(d).HTMLElement;return d instanceof e||d instanceof HTMLElement}function $A(d){if(typeof ShadowRoot>"u")return!1;var e=Pa(d).ShadowRoot;return d instanceof e||d instanceof ShadowRoot}function Vme(d){var e=d.state;Object.keys(e.elements).forEach(function(t){var s=e.styles[t]||{},i=e.attributes[t]||{},n=e.elements[t];!ao(n)||!Ud(n)||(Object.assign(n.style,s),Object.keys(i).forEach(function(r){var a=i[r];a===!1?n.removeAttribute(r):n.setAttribute(r,a===!0?"":a)}))})}function Fme(d){var e=d.state,t={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(e.elements.popper.style,t.popper),e.styles=t,e.elements.arrow&&Object.assign(e.elements.arrow.style,t.arrow),function(){Object.keys(e.elements).forEach(function(s){var i=e.elements[s],n=e.attributes[s]||{},r=Object.keys(e.styles.hasOwnProperty(s)?e.styles[s]:t[s]),a=r.reduce(function(o,c){return o[c]="",o},{});!ao(i)||!Ud(i)||(Object.assign(i.style,a),Object.keys(n).forEach(function(o){i.removeAttribute(o)}))})}}const Hme={name:"applyStyles",enabled:!0,phase:"write",fn:Vme,effect:Fme,requires:["computeStyles"]};function qd(d){return d.split("-")[0]}var Rl=Math.max,vv=Math.min,Em=Math.round;function t2(){var d=navigator.userAgentData;return d!=null&&d.brands&&Array.isArray(d.brands)?d.brands.map(function(e){return e.brand+"/"+e.version}).join(" "):navigator.userAgent}function oU(){return!/^((?!chrome|android).)*safari/i.test(t2())}function Rm(d,e,t){e===void 0&&(e=!1),t===void 0&&(t=!1);var s=d.getBoundingClientRect(),i=1,n=1;e&&ao(d)&&(i=d.offsetWidth>0&&Em(s.width)/d.offsetWidth||1,n=d.offsetHeight>0&&Em(s.height)/d.offsetHeight||1);var r=Yl(d)?Pa(d):window,a=r.visualViewport,o=!oU()&&t,c=(s.left+(o&&a?a.offsetLeft:0))/i,u=(s.top+(o&&a?a.offsetTop:0))/n,h=s.width/i,l=s.height/n;return{width:h,height:l,top:u,right:c+h,bottom:u+l,left:c,x:c,y:u}}function KA(d){var e=Rm(d),t=d.offsetWidth,s=d.offsetHeight;return Math.abs(e.width-t)<=1&&(t=e.width),Math.abs(e.height-s)<=1&&(s=e.height),{x:d.offsetLeft,y:d.offsetTop,width:t,height:s}}function dU(d,e){var t=e.getRootNode&&e.getRootNode();if(d.contains(e))return!0;if(t&&$A(t)){var s=e;do{if(s&&d.isSameNode(s))return!0;s=s.parentNode||s.host}while(s)}return!1}function Xc(d){return Pa(d).getComputedStyle(d)}function Gme(d){return["table","td","th"].indexOf(Ud(d))>=0}function Rh(d){return((Yl(d)?d.ownerDocument:d.document)||window.document).documentElement}function hO(d){return Ud(d)==="html"?d:d.assignedSlot||d.parentNode||($A(d)?d.host:null)||Rh(d)}function zq(d){return!ao(d)||Xc(d).position==="fixed"?null:d.offsetParent}function Ume(d){var e=/firefox/i.test(t2()),t=/Trident/i.test(t2());if(t&&ao(d)){var s=Xc(d);if(s.position==="fixed")return null}var i=hO(d);for($A(i)&&(i=i.host);ao(i)&&["html","body"].indexOf(Ud(i))<0;){var n=Xc(i);if(n.transform!=="none"||n.perspective!=="none"||n.contain==="paint"||["transform","perspective"].indexOf(n.willChange)!==-1||e&&n.willChange==="filter"||e&&n.filter&&n.filter!=="none")return i;i=i.parentNode}return null}function nb(d){for(var e=Pa(d),t=zq(d);t&&Gme(t)&&Xc(t).position==="static";)t=zq(t);return t&&(Ud(t)==="html"||Ud(t)==="body"&&Xc(t).position==="static")?e:t||Ume(d)||e}function XA(d){return["top","bottom"].indexOf(d)>=0?"x":"y"}function t0(d,e,t){return Rl(d,vv(e,t))}function Wme(d,e,t){var s=t0(d,e,t);return s>t?t:s}function cU(){return{top:0,right:0,bottom:0,left:0}}function uU(d){return Object.assign({},cU(),d)}function hU(d,e){return e.reduce(function(t,s){return t[s]=d,t},{})}var jme=function(e,t){return e=typeof e=="function"?e(Object.assign({},t.rects,{placement:t.placement})):e,uU(typeof e!="number"?e:hU(e,ib))};function zme(d){var e,t=d.state,s=d.name,i=d.options,n=t.elements.arrow,r=t.modifiersData.popperOffsets,a=qd(t.placement),o=XA(a),c=[Wr,lo].indexOf(a)>=0,u=c?"height":"width";if(!(!n||!r)){var h=jme(i.padding,t),l=KA(n),f=o==="y"?Ur:Wr,p=o==="y"?ho:lo,m=t.rects.reference[u]+t.rects.reference[o]-r[o]-t.rects.popper[u],g=r[o]-t.rects.reference[o],y=nb(n),w=y?o==="y"?y.clientHeight||0:y.clientWidth||0:0,b=m/2-g/2,S=h[f],v=w-l[u]-h[p],C=w/2-l[u]/2+b,M=t0(S,C,v),_=o;t.modifiersData[s]=(e={},e[_]=M,e.centerOffset=M-C,e)}}function $me(d){var e=d.state,t=d.options,s=t.element,i=s===void 0?"[data-popper-arrow]":s;i!=null&&(typeof i=="string"&&(i=e.elements.popper.querySelector(i),!i)||dU(e.elements.popper,i)&&(e.elements.arrow=i))}const Kme={name:"arrow",enabled:!0,phase:"main",fn:zme,effect:$me,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function Dm(d){return d.split("-")[1]}var Xme={top:"auto",right:"auto",bottom:"auto",left:"auto"};function Qme(d,e){var t=d.x,s=d.y,i=e.devicePixelRatio||1;return{x:Em(t*i)/i||0,y:Em(s*i)/i||0}}function $q(d){var e,t=d.popper,s=d.popperRect,i=d.placement,n=d.variation,r=d.offsets,a=d.position,o=d.gpuAcceleration,c=d.adaptive,u=d.roundOffsets,h=d.isFixed,l=r.x,f=l===void 0?0:l,p=r.y,m=p===void 0?0:p,g=typeof u=="function"?u({x:f,y:m}):{x:f,y:m};f=g.x,m=g.y;var y=r.hasOwnProperty("x"),w=r.hasOwnProperty("y"),b=Wr,S=Ur,v=window;if(c){var C=nb(t),M="clientHeight",_="clientWidth";if(C===Pa(t)&&(C=Rh(t),Xc(C).position!=="static"&&a==="absolute"&&(M="scrollHeight",_="scrollWidth")),C=C,i===Ur||(i===Wr||i===lo)&&n===dw){S=ho;var N=h&&C===v&&v.visualViewport?v.visualViewport.height:C[M];m-=N-s.height,m*=o?1:-1}if(i===Wr||(i===Ur||i===ho)&&n===dw){b=lo;var A=h&&C===v&&v.visualViewport?v.visualViewport.width:C[_];f-=A-s.width,f*=o?1:-1}}var R=Object.assign({position:a},c&&Xme),D=u===!0?Qme({x:f,y:m},Pa(t)):{x:f,y:m};if(f=D.x,m=D.y,o){var U;return Object.assign({},R,(U={},U[S]=w?"0":"",U[b]=y?"0":"",U.transform=(v.devicePixelRatio||1)<=1?"translate("+f+"px, "+m+"px)":"translate3d("+f+"px, "+m+"px, 0)",U))}return Object.assign({},R,(e={},e[S]=w?m+"px":"",e[b]=y?f+"px":"",e.transform="",e))}function Yme(d){var e=d.state,t=d.options,s=t.gpuAcceleration,i=s===void 0?!0:s,n=t.adaptive,r=n===void 0?!0:n,a=t.roundOffsets,o=a===void 0?!0:a,c={placement:qd(e.placement),variation:Dm(e.placement),popper:e.elements.popper,popperRect:e.rects.popper,gpuAcceleration:i,isFixed:e.options.strategy==="fixed"};e.modifiersData.popperOffsets!=null&&(e.styles.popper=Object.assign({},e.styles.popper,$q(Object.assign({},c,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:r,roundOffsets:o})))),e.modifiersData.arrow!=null&&(e.styles.arrow=Object.assign({},e.styles.arrow,$q(Object.assign({},c,{offsets:e.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:o})))),e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-placement":e.placement})}const Zme={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:Yme,data:{}};var cS={passive:!0};function Jme(d){var e=d.state,t=d.instance,s=d.options,i=s.scroll,n=i===void 0?!0:i,r=s.resize,a=r===void 0?!0:r,o=Pa(e.elements.popper),c=[].concat(e.scrollParents.reference,e.scrollParents.popper);return n&&c.forEach(function(u){u.addEventListener("scroll",t.update,cS)}),a&&o.addEventListener("resize",t.update,cS),function(){n&&c.forEach(function(u){u.removeEventListener("scroll",t.update,cS)}),a&&o.removeEventListener("resize",t.update,cS)}}const ege={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:Jme,data:{}};var tge={left:"right",right:"left",bottom:"top",top:"bottom"};function d1(d){return d.replace(/left|right|bottom|top/g,function(e){return tge[e]})}var sge={start:"end",end:"start"};function Kq(d){return d.replace(/start|end/g,function(e){return sge[e]})}function QA(d){var e=Pa(d),t=e.pageXOffset,s=e.pageYOffset;return{scrollLeft:t,scrollTop:s}}function YA(d){return Rm(Rh(d)).left+QA(d).scrollLeft}function ige(d,e){var t=Pa(d),s=Rh(d),i=t.visualViewport,n=s.clientWidth,r=s.clientHeight,a=0,o=0;if(i){n=i.width,r=i.height;var c=oU();(c||!c&&e==="fixed")&&(a=i.offsetLeft,o=i.offsetTop)}return{width:n,height:r,x:a+YA(d),y:o}}function nge(d){var e,t=Rh(d),s=QA(d),i=(e=d.ownerDocument)==null?void 0:e.body,n=Rl(t.scrollWidth,t.clientWidth,i?i.scrollWidth:0,i?i.clientWidth:0),r=Rl(t.scrollHeight,t.clientHeight,i?i.scrollHeight:0,i?i.clientHeight:0),a=-s.scrollLeft+YA(d),o=-s.scrollTop;return Xc(i||t).direction==="rtl"&&(a+=Rl(t.clientWidth,i?i.clientWidth:0)-n),{width:n,height:r,x:a,y:o}}function ZA(d){var e=Xc(d),t=e.overflow,s=e.overflowX,i=e.overflowY;return/auto|scroll|overlay|hidden/.test(t+i+s)}function lU(d){return["html","body","#document"].indexOf(Ud(d))>=0?d.ownerDocument.body:ao(d)&&ZA(d)?d:lU(hO(d))}function s0(d,e){var t;e===void 0&&(e=[]);var s=lU(d),i=s===((t=d.ownerDocument)==null?void 0:t.body),n=Pa(s),r=i?[n].concat(n.visualViewport||[],ZA(s)?s:[]):s,a=e.concat(r);return i?a:a.concat(s0(hO(r)))}function s2(d){return Object.assign({},d,{left:d.x,top:d.y,right:d.x+d.width,bottom:d.y+d.height})}function rge(d,e){var t=Rm(d,!1,e==="fixed");return t.top=t.top+d.clientTop,t.left=t.left+d.clientLeft,t.bottom=t.top+d.clientHeight,t.right=t.left+d.clientWidth,t.width=d.clientWidth,t.height=d.clientHeight,t.x=t.left,t.y=t.top,t}function Xq(d,e,t){return e===rU?s2(ige(d,t)):Yl(e)?rge(e,t):s2(nge(Rh(d)))}function age(d){var e=s0(hO(d)),t=["absolute","fixed"].indexOf(Xc(d).position)>=0,s=t&&ao(d)?nb(d):d;return Yl(s)?e.filter(function(i){return Yl(i)&&dU(i,s)&&Ud(i)!=="body"}):[]}function oge(d,e,t,s){var i=e==="clippingParents"?age(d):[].concat(e),n=[].concat(i,[t]),r=n[0],a=n.reduce(function(o,c){var u=Xq(d,c,s);return o.top=Rl(u.top,o.top),o.right=vv(u.right,o.right),o.bottom=vv(u.bottom,o.bottom),o.left=Rl(u.left,o.left),o},Xq(d,r,s));return a.width=a.right-a.left,a.height=a.bottom-a.top,a.x=a.left,a.y=a.top,a}function fU(d){var e=d.reference,t=d.element,s=d.placement,i=s?qd(s):null,n=s?Dm(s):null,r=e.x+e.width/2-t.width/2,a=e.y+e.height/2-t.height/2,o;switch(i){case Ur:o={x:r,y:e.y-t.height};break;case ho:o={x:r,y:e.y+e.height};break;case lo:o={x:e.x+e.width,y:a};break;case Wr:o={x:e.x-t.width,y:a};break;default:o={x:e.x,y:e.y}}var c=i?XA(i):null;if(c!=null){var u=c==="y"?"height":"width";switch(n){case Nm:o[c]=o[c]-(e[u]/2-t[u]/2);break;case dw:o[c]=o[c]+(e[u]/2-t[u]/2);break}}return o}function cw(d,e){e===void 0&&(e={});var t=e,s=t.placement,i=s===void 0?d.placement:s,n=t.strategy,r=n===void 0?d.strategy:n,a=t.boundary,o=a===void 0?Ime:a,c=t.rootBoundary,u=c===void 0?rU:c,h=t.elementContext,l=h===void 0?dy:h,f=t.altBoundary,p=f===void 0?!1:f,m=t.padding,g=m===void 0?0:m,y=uU(typeof g!="number"?g:hU(g,ib)),w=l===dy?Cme:dy,b=d.rects.popper,S=d.elements[p?w:l],v=oge(Yl(S)?S:S.contextElement||Rh(d.elements.popper),o,u,r),C=Rm(d.elements.reference),M=fU({reference:C,element:b,strategy:"absolute",placement:i}),_=s2(Object.assign({},b,M)),N=l===dy?_:C,A={top:v.top-N.top+y.top,bottom:N.bottom-v.bottom+y.bottom,left:v.left-N.left+y.left,right:N.right-v.right+y.right},R=d.modifiersData.offset;if(l===dy&&R){var D=R[i];Object.keys(A).forEach(function(U){var K=[lo,ho].indexOf(U)>=0?1:-1,j=[Ur,ho].indexOf(U)>=0?"y":"x";A[U]+=D[j]*K})}return A}function dge(d,e){e===void 0&&(e={});var t=e,s=t.placement,i=t.boundary,n=t.rootBoundary,r=t.padding,a=t.flipVariations,o=t.allowedAutoPlacements,c=o===void 0?aU:o,u=Dm(s),h=u?a?jq:jq.filter(function(p){return Dm(p)===u}):ib,l=h.filter(function(p){return c.indexOf(p)>=0});l.length===0&&(l=h);var f=l.reduce(function(p,m){return p[m]=cw(d,{placement:m,boundary:i,rootBoundary:n,padding:r})[qd(m)],p},{});return Object.keys(f).sort(function(p,m){return f[p]-f[m]})}function cge(d){if(qd(d)===zA)return[];var e=d1(d);return[Kq(d),e,Kq(e)]}function uge(d){var e=d.state,t=d.options,s=d.name;if(!e.modifiersData[s]._skip){for(var i=t.mainAxis,n=i===void 0?!0:i,r=t.altAxis,a=r===void 0?!0:r,o=t.fallbackPlacements,c=t.padding,u=t.boundary,h=t.rootBoundary,l=t.altBoundary,f=t.flipVariations,p=f===void 0?!0:f,m=t.allowedAutoPlacements,g=e.options.placement,y=qd(g),w=y===g,b=o||(w||!p?[d1(g)]:cge(g)),S=[g].concat(b).reduce(function(ne,oe){return ne.concat(qd(oe)===zA?dge(e,{placement:oe,boundary:u,rootBoundary:h,padding:c,flipVariations:p,allowedAutoPlacements:m}):oe)},[]),v=e.rects.reference,C=e.rects.popper,M=new Map,_=!0,N=S[0],A=0;A=0,j=K?"width":"height",z=cw(e,{placement:R,boundary:u,rootBoundary:h,altBoundary:l,padding:c}),J=K?U?lo:Wr:U?ho:Ur;v[j]>C[j]&&(J=d1(J));var Y=d1(J),X=[];if(n&&X.push(z[D]<=0),a&&X.push(z[J]<=0,z[Y]<=0),X.every(function(ne){return ne})){N=R,_=!1;break}M.set(R,X)}if(_)for(var Z=p?3:1,te=function(oe){var me=S.find(function(fe){var he=M.get(fe);if(he)return he.slice(0,oe).every(function(Se){return Se})});if(me)return N=me,"break"},Q=Z;Q>0;Q--){var ie=te(Q);if(ie==="break")break}e.placement!==N&&(e.modifiersData[s]._skip=!0,e.placement=N,e.reset=!0)}}const hge={name:"flip",enabled:!0,phase:"main",fn:uge,requiresIfExists:["offset"],data:{_skip:!1}};function Qq(d,e,t){return t===void 0&&(t={x:0,y:0}),{top:d.top-e.height-t.y,right:d.right-e.width+t.x,bottom:d.bottom-e.height+t.y,left:d.left-e.width-t.x}}function Yq(d){return[Ur,lo,ho,Wr].some(function(e){return d[e]>=0})}function lge(d){var e=d.state,t=d.name,s=e.rects.reference,i=e.rects.popper,n=e.modifiersData.preventOverflow,r=cw(e,{elementContext:"reference"}),a=cw(e,{altBoundary:!0}),o=Qq(r,s),c=Qq(a,i,n),u=Yq(o),h=Yq(c);e.modifiersData[t]={referenceClippingOffsets:o,popperEscapeOffsets:c,isReferenceHidden:u,hasPopperEscaped:h},e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-reference-hidden":u,"data-popper-escaped":h})}const fge={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:lge};function pge(d,e,t){var s=qd(d),i=[Wr,Ur].indexOf(s)>=0?-1:1,n=typeof t=="function"?t(Object.assign({},e,{placement:d})):t,r=n[0],a=n[1];return r=r||0,a=(a||0)*i,[Wr,lo].indexOf(s)>=0?{x:a,y:r}:{x:r,y:a}}function mge(d){var e=d.state,t=d.options,s=d.name,i=t.offset,n=i===void 0?[0,0]:i,r=aU.reduce(function(u,h){return u[h]=pge(h,e.rects,n),u},{}),a=r[e.placement],o=a.x,c=a.y;e.modifiersData.popperOffsets!=null&&(e.modifiersData.popperOffsets.x+=o,e.modifiersData.popperOffsets.y+=c),e.modifiersData[s]=r}const gge={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:mge};function yge(d){var e=d.state,t=d.name;e.modifiersData[t]=fU({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})}const wge={name:"popperOffsets",enabled:!0,phase:"read",fn:yge,data:{}};function bge(d){return d==="x"?"y":"x"}function kge(d){var e=d.state,t=d.options,s=d.name,i=t.mainAxis,n=i===void 0?!0:i,r=t.altAxis,a=r===void 0?!1:r,o=t.boundary,c=t.rootBoundary,u=t.altBoundary,h=t.padding,l=t.tether,f=l===void 0?!0:l,p=t.tetherOffset,m=p===void 0?0:p,g=cw(e,{boundary:o,rootBoundary:c,padding:h,altBoundary:u}),y=qd(e.placement),w=Dm(e.placement),b=!w,S=XA(y),v=bge(S),C=e.modifiersData.popperOffsets,M=e.rects.reference,_=e.rects.popper,N=typeof m=="function"?m(Object.assign({},e.rects,{placement:e.placement})):m,A=typeof N=="number"?{mainAxis:N,altAxis:N}:Object.assign({mainAxis:0,altAxis:0},N),R=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,D={x:0,y:0};if(C){if(n){var U,K=S==="y"?Ur:Wr,j=S==="y"?ho:lo,z=S==="y"?"height":"width",J=C[S],Y=J+g[K],X=J-g[j],Z=f?-_[z]/2:0,te=w===Nm?M[z]:_[z],Q=w===Nm?-_[z]:-M[z],ie=e.elements.arrow,ne=f&&ie?KA(ie):{width:0,height:0},oe=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:cU(),me=oe[K],fe=oe[j],he=t0(0,M[z],ne[z]),Se=b?M[z]/2-Z-he-me-A.mainAxis:te-he-me-A.mainAxis,ye=b?-M[z]/2+Z+he+fe+A.mainAxis:Q+he+fe+A.mainAxis,ge=e.elements.arrow&&nb(e.elements.arrow),Te=ge?S==="y"?ge.clientTop||0:ge.clientLeft||0:0,Ge=(U=R==null?void 0:R[S])!=null?U:0,Ye=J+Se-Ge-Te,Re=J+ye-Ge,Be=t0(f?vv(Y,Ye):Y,J,f?Rl(X,Re):X);C[S]=Be,D[S]=Be-J}if(a){var Me,Le=S==="x"?Ur:Wr,rt=S==="x"?ho:lo,ze=C[v],Ue=v==="y"?"height":"width",Je=ze+g[Le],st=ze-g[rt],ut=[Ur,Wr].indexOf(y)!==-1,yt=(Me=R==null?void 0:R[v])!=null?Me:0,Bt=ut?Je:ze-M[Ue]-_[Ue]-yt+A.altAxis,lt=ut?ze+M[Ue]+_[Ue]-yt-A.altAxis:st,ht=f&&ut?Wme(Bt,ze,lt):t0(f?Bt:Je,ze,f?lt:st);C[v]=ht,D[v]=ht-ze}e.modifiersData[s]=D}}const Sge={name:"preventOverflow",enabled:!0,phase:"main",fn:kge,requiresIfExists:["offset"]};function vge(d){return{scrollLeft:d.scrollLeft,scrollTop:d.scrollTop}}function Tge(d){return d===Pa(d)||!ao(d)?QA(d):vge(d)}function Oge(d){var e=d.getBoundingClientRect(),t=Em(e.width)/d.offsetWidth||1,s=Em(e.height)/d.offsetHeight||1;return t!==1||s!==1}function xge(d,e,t){t===void 0&&(t=!1);var s=ao(e),i=ao(e)&&Oge(e),n=Rh(e),r=Rm(d,i,t),a={scrollLeft:0,scrollTop:0},o={x:0,y:0};return(s||!s&&!t)&&((Ud(e)!=="body"||ZA(n))&&(a=Tge(e)),ao(e)?(o=Rm(e,!0),o.x+=e.clientLeft,o.y+=e.clientTop):n&&(o.x=YA(n))),{x:r.left+a.scrollLeft-o.x,y:r.top+a.scrollTop-o.y,width:r.width,height:r.height}}function Pge(d){var e=new Map,t=new Set,s=[];d.forEach(function(n){e.set(n.name,n)});function i(n){t.add(n.name);var r=[].concat(n.requires||[],n.requiresIfExists||[]);r.forEach(function(a){if(!t.has(a)){var o=e.get(a);o&&i(o)}}),s.push(n)}return d.forEach(function(n){t.has(n.name)||i(n)}),s}function Ige(d){var e=Pge(d);return qme.reduce(function(t,s){return t.concat(e.filter(function(i){return i.phase===s}))},[])}function Cge(d){var e;return function(){return e||(e=new Promise(function(t){Promise.resolve().then(function(){e=void 0,t(d())})})),e}}function Mge(d){var e=d.reduce(function(t,s){var i=t[s.name];return t[s.name]=i?Object.assign({},i,s,{options:Object.assign({},i.options,s.options),data:Object.assign({},i.data,s.data)}):s,t},{});return Object.keys(e).map(function(t){return e[t]})}var Zq={placement:"bottom",modifiers:[],strategy:"absolute"};function Jq(){for(var d=arguments.length,e=new Array(d),t=0;tNt({root:["root"]},kpe(Lge)),qge={},Vge=B.forwardRef(function(e,t){var s;const{anchorEl:i,children:n,direction:r,disablePortal:a,modifiers:o,open:c,placement:u,popperOptions:h,popperRef:l,slotProps:f={},slots:p={},TransitionProps:m}=e,g=at(e,Bge),y=B.useRef(null),w=Cs(y,t),b=B.useRef(null),S=Cs(b,l),v=B.useRef(S);jo(()=>{v.current=S},[S]),B.useImperativeHandle(l,()=>b.current,[]);const C=Ege(u,r),[M,_]=B.useState(C),[N,A]=B.useState(i2(i));B.useEffect(()=>{b.current&&b.current.forceUpdate()}),B.useEffect(()=>{i&&A(i2(i))},[i]),jo(()=>{if(!N||!c)return;const j=Y=>{_(Y.placement)};let z=[{name:"preventOverflow",options:{altBoundary:a}},{name:"flip",options:{altBoundary:a}},{name:"onUpdate",enabled:!0,phase:"afterWrite",fn:({state:Y})=>{j(Y)}}];o!=null&&(z=z.concat(o)),h&&h.modifiers!=null&&(z=z.concat(h.modifiers));const J=pU(N,y.current,W({placement:C},h,{modifiers:z}));return v.current(J),()=>{J.destroy(),v.current(null)}},[N,a,o,c,h,C]);const R={placement:M};m!==null&&(R.TransitionProps=m);const D=Dge(),U=(s=p.root)!=null?s:"div",K=ZG({elementType:U,externalSlotProps:f.root,externalForwardedProps:g,additionalProps:{role:"tooltip",ref:w},ownerState:e,className:D.root});return P.jsx(U,W({},K,{children:typeof n=="function"?n(R):n}))}),lO=B.forwardRef(function(e,t){const{anchorEl:s,children:i,container:n,direction:r="ltr",disablePortal:a=!1,keepMounted:o=!1,modifiers:c,open:u,placement:h="bottom",popperOptions:l=qge,popperRef:f,style:p,transition:m=!1,slotProps:g={},slots:y={}}=e,w=at(e,Nge),[b,S]=B.useState(!0),v=()=>{S(!1)},C=()=>{S(!0)};if(!o&&!u&&(!m||b))return null;let M;if(n)M=n;else if(s){const A=i2(s);M=A&&Rge(A)?ba(A).body:ba(null).body}const _=!u&&o&&(!m||b)?"none":void 0,N=m?{in:u,onEnter:v,onExited:C}:void 0;return P.jsx(FA,{disablePortal:a,container:M,children:P.jsx(Vge,W({anchorEl:s,direction:r,disablePortal:a,modifiers:c,ref:t,open:m?!b:u,placement:h,popperOptions:l,popperRef:f,slotProps:g,slots:y},w,{style:W({position:"fixed",top:0,left:0,display:_},p),TransitionProps:N,children:i}))})}),Tv={buttonClick:"buttonClick",browserAutoFill:"browserAutoFill"},Fge=d=>{const{label:e,value:t}=d;return typeof e=="string"?e:typeof t=="string"?t:String(d)};function Hge(d,e){const{open:t}=d,{context:{selectionMode:s}}=e;if(e.type===Tv.buttonClick){var i;const o=(i=d.selectedValues[0])!=null?i:Sn(null,"start",e.context);return W({},d,{open:!t,highlightedValue:t?null:o})}if(e.type===Tv.browserAutoFill)return GA(e.item,d,e.context);const n=cO(d,e);switch(e.type){case ei.keyDown:if(d.open){if(e.event.key==="Escape")return W({},n,{open:!1})}else{if(e.event.key==="ArrowDown"){var r;return W({},d,{open:!0,highlightedValue:(r=d.selectedValues[0])!=null?r:Sn(null,"start",e.context)})}if(e.event.key==="ArrowUp"){var a;return W({},d,{open:!0,highlightedValue:(a=d.selectedValues[0])!=null?a:Sn(null,"end",e.context)})}}break;case ei.itemClick:if(s==="single")return W({},n,{open:!1});break;case ei.blur:return W({},n,{open:!1});default:return n}return n}function Gge(d){return Array.isArray(d)?d.length===0?"":JSON.stringify(d.map(e=>e.value)):(d==null?void 0:d.value)==null?"":typeof d.value=="string"||typeof d.value=="number"?d.value:JSON.stringify(d.value)}function Uge(d){const{areOptionsEqual:e,buttonRef:t,defaultOpen:s=!1,defaultValue:i,disabled:n=!1,listboxId:r,listboxRef:a,multiple:o=!1,name:c,required:u,onChange:h,onHighlightChange:l,onOpenChange:f,open:p,options:m,getOptionAsString:g=Fge,getSerializedValue:y=Gge,value:w,componentName:b="useSelect"}=d,S=B.useRef(null),v=Cs(t,S),C=B.useRef(null),M=ln(r);let _;w===void 0&&i===void 0?_=[]:i!==void 0&&(o?_=i:_=i==null?[]:[i]);const N=B.useMemo(()=>{if(w!==void 0)return o?w:w==null?[]:[w]},[w,o]),{subitems:A,contextValue:R}=uO(),D=B.useMemo(()=>m!=null?new Map(m.map((V,re)=>[V.value,{value:V.value,label:V.label,disabled:V.disabled,ref:B.createRef(),id:`${M}_${re}`}])):A,[m,A,M]),U=Cs(a,C),{getRootProps:K,active:j,focusVisible:z,rootRef:J}=Jo({disabled:n,rootRef:v}),Y=B.useMemo(()=>Array.from(D.keys()),[D]),X=B.useCallback(V=>{if(e!==void 0){const re=Y.find(le=>e(le,V));return D.get(re)}return D.get(V)},[D,e,Y]),Z=B.useCallback(V=>{var re;const le=X(V);return(re=le==null?void 0:le.disabled)!=null?re:!1},[X]),te=B.useCallback(V=>{const re=X(V);return re?g(re):""},[X,g]),Q=B.useMemo(()=>({selectedValues:N,open:p}),[N,p]),ie=B.useCallback(V=>{var re;return(re=D.get(V))==null?void 0:re.id},[D]),ne=B.useCallback((V,re)=>{if(o)h==null||h(V,re);else{var le;h==null||h(V,(le=re[0])!=null?le:null)}},[o,h]),oe=B.useCallback((V,re)=>{l==null||l(V,re??null)},[l]),me=B.useCallback((V,re,le)=>{if(re==="open"&&(f==null||f(le),le===!1&&(V==null?void 0:V.type)!=="blur")){var ke;(ke=S.current)==null||ke.focus()}},[f]),fe=B.useCallback(V=>{var re,le;return V==null?null:(re=(le=A.get(V))==null?void 0:le.ref.current)!=null?re:null},[A]),he={getInitialState:()=>{var V;return{highlightedValue:null,selectedValues:(V=_)!=null?V:[],open:s}},getItemId:ie,controlledProps:Q,focusManagement:"DOM",getItemDomElement:fe,itemComparer:e,isItemDisabled:Z,rootRef:U,onChange:ne,onHighlightChange:oe,onStateChange:me,reducerActionContext:B.useMemo(()=>({multiple:o}),[o]),items:Y,getItemAsString:te,selectionMode:o?"multiple":"single",stateReducer:Hge,componentName:b},{dispatch:Se,getRootProps:ye,contextValue:ge,state:{open:Te,highlightedValue:Ge,selectedValues:Ye},rootRef:Re}=UA(he),Be=B.useRef(Te);jo(()=>{if(Te&&Ge!==null){var V;const re=(V=X(Ge))==null?void 0:V.ref;if(!C.current||!(re!=null&&re.current))return;Be.current||re.current.focus({preventScroll:!0});const le=C.current.getBoundingClientRect(),ke=re.current.getBoundingClientRect();ke.tople.bottom&&(C.current.scrollTop+=ke.bottom-le.bottom)}},[Te,Ge,X]);const Me=B.useCallback(V=>X(V),[X]),Le=V=>re=>{var le;if(V==null||(le=V.onClick)==null||le.call(V,re),!re.defaultMuiPrevented){const ke={type:Tv.buttonClick,event:re};Se(ke)}},rt=V=>re=>{var le;(le=V.onKeyDown)==null||le.call(V,re),!re.defaultMuiPrevented&&(re.key==="ArrowDown"||re.key==="ArrowUp")&&(re.preventDefault(),Se({type:ei.keyDown,key:re.key,event:re}))},ze=(V={})=>({onClick:Le(V),onKeyDown:rt(V)}),Ue=(V={})=>W({},V,ze(V),{role:"combobox","aria-expanded":Te,"aria-controls":M}),Je=(V={})=>{const re=hn(V),le=Kc(Ue,K);return W({},V,le(re))},st=V=>re=>{var le,ke;(le=V.onBlur)==null||le.call(V,re),!re.defaultMuiPrevented&&((ke=C.current)!=null&&ke.contains(re.relatedTarget)||re.relatedTarget===S.current)&&(re.defaultMuiPrevented=!0)},ut=(V={})=>({onBlur:st(V)}),yt=(V={})=>{const re=hn(V),le=Kc(ut,ye);return W({id:M,role:"listbox","aria-multiselectable":o?"true":void 0},V,le(re))};B.useDebugValue({selectedOptions:Ye,highlightedOption:Ge,open:Te});const Bt=B.useMemo(()=>W({},ge,R),[ge,R]);let lt;d.multiple?lt=Ye:lt=Ye.length>0?Ye[0]:null;let ht;if(o)ht=lt.map(V=>Me(V)).filter(V=>V!==void 0);else{var ft;ht=(ft=Me(lt))!=null?ft:null}const se=V=>re=>{var le;if(V==null||(le=V.onChange)==null||le.call(V,re),re.defaultMuiPrevented)return;const ke=D.get(re.target.value);re.target.value===""?Se({type:ei.clearSelection}):ke!==void 0&&Se({type:Tv.browserAutoFill,item:ke.value,event:re})};return{buttonActive:j,buttonFocusVisible:z,buttonRef:J,contextValue:Bt,disabled:n,dispatch:Se,getButtonProps:Je,getHiddenInputProps:(V={})=>{const re=hn(V);return W({name:c,tabIndex:-1,"aria-hidden":!0,required:u?!0:void 0,value:y(ht),style:Ooe},V,{onChange:se(re)})},getListboxProps:yt,getOptionMetadata:Me,listboxRef:Re,open:Te,options:Y,value:lt,highlightedOption:Ge}}function Wge(d){const{value:e,children:t}=d,{dispatch:s,getItemIndex:i,getItemState:n,registerItem:r,totalSubitemCount:a}=e,o=B.useMemo(()=>({dispatch:s,getItemState:n,getItemIndex:i}),[s,i,n]),c=B.useMemo(()=>({getItemIndex:i,registerItem:r,totalSubitemCount:a}),[r,i,a]);return P.jsx(sb.Provider,{value:c,children:P.jsx(Eh.Provider,{value:o,children:t})})}function jge(d={}){const{autoHideDuration:e=null,disableWindowBlurListener:t=!1,onClose:s,open:i,resumeHideDuration:n}=d,r=My();B.useEffect(()=>{if(!i)return;function y(w){w.defaultPrevented||(w.key==="Escape"||w.key==="Esc")&&(s==null||s(w,"escapeKeyDown"))}return document.addEventListener("keydown",y),()=>{document.removeEventListener("keydown",y)}},[i,s]);const a=Eo((y,w)=>{s==null||s(y,w)}),o=Eo(y=>{!s||y==null||r.start(y,()=>{a(null,"timeout")})});B.useEffect(()=>(i&&o(e),r.clear),[i,e,o,r]);const c=y=>{s==null||s(y,"clickaway")},u=r.clear,h=B.useCallback(()=>{e!=null&&o(n??e*.5)},[e,n,o]),l=y=>w=>{const b=y.onBlur;b==null||b(w),h()},f=y=>w=>{const b=y.onFocus;b==null||b(w),u()},p=y=>w=>{const b=y.onMouseEnter;b==null||b(w),u()},m=y=>w=>{const b=y.onMouseLeave;b==null||b(w),h()};return B.useEffect(()=>{if(!t&&i)return window.addEventListener("focus",h),window.addEventListener("blur",u),()=>{window.removeEventListener("focus",h),window.removeEventListener("blur",u)}},[t,i,h,u]),{getRootProps:(y={})=>{const w=W({},hn(d),hn(y));return W({role:"presentation"},y,w,{onBlur:l(w),onFocus:f(w),onMouseEnter:p(w),onMouseLeave:m(w)})},onClickAway:c}}function JA(d){const{checked:e,defaultChecked:t,disabled:s,onBlur:i,onChange:n,onFocus:r,onFocusVisible:a,readOnly:o,required:c}=d,[u,h]=ch({controlled:e,default:!!t,name:"Switch",state:"checked"}),l=_=>N=>{var A;N.nativeEvent.defaultPrevented||(h(N.target.checked),n==null||n(N),(A=_.onChange)==null||A.call(_,N))},{isFocusVisibleRef:f,onBlur:p,onFocus:m,ref:g}=mA(),[y,w]=B.useState(!1);s&&y&&w(!1),B.useEffect(()=>{f.current=y},[y,f]);const b=B.useRef(null),S=_=>N=>{var A;b.current||(b.current=N.currentTarget),m(N),f.current===!0&&(w(!0),a==null||a(N)),r==null||r(N),(A=_.onFocus)==null||A.call(_,N)},v=_=>N=>{var A;p(N),f.current===!1&&w(!1),i==null||i(N),(A=_.onBlur)==null||A.call(_,N)},C=Cs(g,b);return{checked:u,disabled:!!s,focusVisible:y,getInputProps:(_={})=>W({checked:e,defaultChecked:t,disabled:s,readOnly:o,ref:C,required:c,type:"checkbox",role:"switch","aria-checked":e},_,{onChange:l(_),onFocus:S(_),onBlur:v(_)}),inputRef:C,readOnly:!!o}}function zge(d){const{value:e,defaultValue:t,onChange:s,orientation:i="horizontal",direction:n="ltr",selectionFollowsFocus:r=!1}=d,[a,o]=ch({controlled:e,default:t,name:"Tabs",state:"value"}),c=B.useCallback((g,y)=>{o(y),s==null||s(g,y)},[s,o]),{subitems:u,contextValue:h}=uO(),l=B.useRef(()=>{}),f=B.useCallback(g=>{var y;return(y=u.get(g))==null?void 0:y.id},[u]),p=B.useCallback(g=>l.current(g),[]),m=B.useCallback(g=>{l.current=g},[]);return{contextValue:W({direction:n,getTabId:p,getTabPanelId:f,onSelected:c,orientation:i,registerTabIdLookup:m,selectionFollowsFocus:r,value:a},h)}}const gU=B.createContext(null);function yU(){const d=B.useContext(gU);if(d==null)throw new Error("No TabsContext provided");return d}function $ge(d){const{value:e,children:t}=d,{direction:s,getItemIndex:i,onSelected:n,orientation:r,registerItem:a,registerTabIdLookup:o,selectionFollowsFocus:c,totalSubitemCount:u,value:h,getTabId:l,getTabPanelId:f}=e,p=B.useMemo(()=>({getItemIndex:i,registerItem:a,totalSubitemCount:u}),[a,i,u]),m=B.useMemo(()=>({direction:s,getTabId:l,getTabPanelId:f,onSelected:n,orientation:r,registerTabIdLookup:o,selectionFollowsFocus:c,value:h}),[s,l,f,n,r,o,c,h]);return P.jsx(sb.Provider,{value:p,children:P.jsx(gU.Provider,{value:m,children:t})})}const wU={valueChange:"valueChange"};function Kge(d,e){if(e.type===wU.valueChange)return W({},d,{highlightedValue:e.value});const t=cO(d,e),{context:{selectionFollowsFocus:s}}=e;if(e.type===ei.itemsChange){if(t.selectedValues.length>0)return W({},t,{highlightedValue:t.selectedValues[0]});Sn(null,"reset",e.context)}return s&&t.highlightedValue!=null?W({},t,{selectedValues:[t.highlightedValue]}):t}function Xge(d){var e;const{rootRef:t}=d,{direction:s="ltr",onSelected:i,orientation:n="horizontal",value:r,registerTabIdLookup:a,selectionFollowsFocus:o}=yU(),{subitems:c,contextValue:u}=uO(),h=B.useCallback(R=>{var D;return(D=c.get(R))==null?void 0:D.id},[c]);a(h);const l=B.useMemo(()=>Array.from(c.keys()),[c]),f=B.useCallback(R=>{var D,U;return R==null?null:(D=(U=c.get(R))==null?void 0:U.ref.current)!=null?D:null},[c]),p=s==="rtl";let m;n==="vertical"?m="vertical":m=p?"horizontal-rtl":"horizontal-ltr";const g=B.useCallback((R,D)=>{var U;i(R,(U=D[0])!=null?U:null)},[i]),y=B.useMemo(()=>r===void 0?{}:r!=null?{selectedValues:[r]}:{selectedValues:[]},[r]),w=B.useCallback(R=>{var D,U;return(D=(U=c.get(R))==null?void 0:U.disabled)!=null?D:!1},[c]),{contextValue:b,dispatch:S,getRootProps:v,state:{highlightedValue:C,selectedValues:M},rootRef:_}=UA({controlledProps:y,disabledItemsFocusable:!o,focusManagement:"DOM",getItemDomElement:f,isItemDisabled:w,items:l,rootRef:t,onChange:g,orientation:m,reducerActionContext:B.useMemo(()=>({selectionFollowsFocus:o||!1}),[o]),selectionMode:"single",stateReducer:Kge});B.useEffect(()=>{r!==void 0&&r!=null&&S({type:wU.valueChange,value:r})},[S,r]);const N=(R={})=>W({},R,v(R),{"aria-orientation":n==="vertical"?"vertical":void 0,role:"tablist"});return{contextValue:B.useMemo(()=>W({},u,b),[u,b]),dispatch:S,getRootProps:N,highlightedValue:C,isRtl:p,orientation:n,rootRef:_,selectedValue:(e=M[0])!=null?e:null}}function Qge(d){const{value:e,children:t}=d,{dispatch:s,getItemIndex:i,getItemState:n,registerItem:r,totalSubitemCount:a}=e,o=B.useMemo(()=>({dispatch:s,getItemState:n,getItemIndex:i}),[s,i,n]),c=B.useMemo(()=>({getItemIndex:i,registerItem:r,totalSubitemCount:a}),[r,i,a]);return P.jsx(sb.Provider,{value:c,children:P.jsx(Eh.Provider,{value:o,children:t})})}function Yge(d){return d.size}function Zge(d){const{value:e,rootRef:t,disabled:s=!1,id:i}=d,n=B.useRef(null),r=ln(i),{value:a,selectionFollowsFocus:o,getTabPanelId:c}=yU(),u=B.useMemo(()=>({disabled:s,ref:n,id:r}),[s,n,r]),{id:h,index:l,totalItemCount:f}=jA(e??Yge,u),{getRootProps:p,highlighted:m,selected:g}=WA({item:h}),{getRootProps:y,rootRef:w,active:b,focusVisible:S,setFocusVisible:v}=Jo({disabled:s,focusableWhenDisabled:!o,type:"button"}),C=Cs(n,t,w),M=h!==void 0?c(h):void 0;return{getRootProps:(N={})=>{const A=hn(N),R=Kc(p,y);return W({},N,R(A),{role:"tab","aria-controls":M,"aria-selected":g,id:r,ref:C})},active:b,focusVisible:S,highlighted:m,index:l,rootRef:C,selected:g||h===a,setFocusVisible:v,totalTabsCount:f}}const Jge=["onChange","maxRows","minRows","style","value"];function uS(d){return parseInt(d,10)||0}const eye={shadow:{visibility:"hidden",position:"absolute",overflow:"hidden",height:0,top:0,left:0,transform:"translateZ(0)"}};function tye(d){return d==null||Object.keys(d).length===0||d.outerHeightStyle===0&&!d.overflowing}const sye=B.forwardRef(function(e,t){const{onChange:s,maxRows:i,minRows:n=1,style:r,value:a}=e,o=at(e,Jge),{current:c}=B.useRef(a!=null),u=B.useRef(null),h=Cs(t,u),l=B.useRef(null),f=B.useCallback(()=>{const g=u.current,w=F0(g).getComputedStyle(g);if(w.width==="0px")return{outerHeightStyle:0,overflowing:!1};const b=l.current;b.style.width=w.width,b.value=g.value||e.placeholder||"x",b.value.slice(-1)===` `&&(b.value+=" ");const S=w.boxSizing,v=uS(w.paddingBottom)+uS(w.paddingTop),C=uS(w.borderBottomWidth)+uS(w.borderTopWidth),M=b.scrollHeight;b.value="x";const _=b.scrollHeight;let N=M;n&&(N=Math.max(Number(n)*_,N)),i&&(N=Math.min(Number(i)*_,N)),N=Math.max(N,_);const A=N+(S==="border-box"?v+C:0),R=Math.abs(N-M)<=1;return{outerHeightStyle:A,overflowing:R}},[i,n,e.placeholder]),p=B.useCallback(()=>{const g=f();if(tye(g))return;const y=u.current;y.style.height=`${g.outerHeightStyle}px`,y.style.overflow=g.overflowing?"hidden":""},[f]);jo(()=>{const g=()=>{p()};let y;const w=uoe(g),b=u.current,S=F0(b);S.addEventListener("resize",w);let v;return typeof ResizeObserver<"u"&&(v=new ResizeObserver(g),v.observe(b)),()=>{w.clear(),cancelAnimationFrame(y),S.removeEventListener("resize",w),v&&v.disconnect()}},[f,p]),jo(()=>{p()});const m=g=>{c||p(),s&&s(g)};return P.jsxs(B.Fragment,{children:[P.jsx("textarea",W({value:a,onChange:m,ref:h,rows:n,style:r},o)),P.jsx("textarea",{"aria-hidden":!0,className:e.className,readOnly:!0,ref:l,tabIndex:-1,style:W({},eye.shadow,r,{paddingTop:0,paddingBottom:0})})]})});function eV(d){return typeof d.normalize<"u"?d.normalize("NFD").replace(/[\u0300-\u036f]/g,""):d}function bU(d={}){const{ignoreAccents:e=!0,ignoreCase:t=!0,limit:s,matchFrom:i="any",stringify:n,trim:r=!1}=d;return(a,{inputValue:o,getOptionLabel:c})=>{let u=r?o.trim():o;t&&(u=u.toLowerCase()),e&&(u=eV(u));const h=u?a.filter(l=>{let f=(n||c)(l);return t&&(f=f.toLowerCase()),e&&(f=eV(f)),i==="start"?f.indexOf(u)===0:f.indexOf(u)>-1}):a;return typeof s=="number"?h.slice(0,s):h}}function hS(d,e){for(let t=0;t{var e;return d.current!==null&&((e=d.current.parentElement)==null?void 0:e.contains(document.activeElement))};function rye(d){const{unstable_isActiveElementInListbox:e=nye,unstable_classNamePrefix:t="Mui",autoComplete:s=!1,autoHighlight:i=!1,autoSelect:n=!1,blurOnSelect:r=!1,clearOnBlur:a=!d.freeSolo,clearOnEscape:o=!1,componentName:c="useAutocomplete",defaultValue:u=d.multiple?[]:null,disableClearable:h=!1,disableCloseOnSelect:l=!1,disabled:f,disabledItemsFocusable:p=!1,disableListWrap:m=!1,filterOptions:g=iye,filterSelectedOptions:y=!1,freeSolo:w=!1,getOptionDisabled:b,getOptionKey:S,getOptionLabel:v=Ce=>{var xe;return(xe=Ce.label)!=null?xe:Ce},groupBy:C,handleHomeEndKeys:M=!d.freeSolo,id:_,includeInputInList:N=!1,inputValue:A,isOptionEqualToValue:R=(Ce,xe)=>Ce===xe,multiple:D=!1,onChange:U,onClose:K,onHighlightChange:j,onInputChange:z,onOpen:J,open:Y,openOnFocus:X=!1,options:Z,readOnly:te=!1,selectOnFocus:Q=!d.freeSolo,value:ie}=d,ne=ln(_);let oe=v;oe=Ce=>{const xe=v(Ce);return typeof xe!="string"?String(xe):xe};const me=B.useRef(!1),fe=B.useRef(!0),he=B.useRef(null),Se=B.useRef(null),[ye,ge]=B.useState(null),[Te,Ge]=B.useState(-1),Ye=i?0:-1,Re=B.useRef(Ye),[Be,Me]=ch({controlled:ie,default:u,name:c}),[Le,rt]=ch({controlled:A,default:"",name:c,state:"inputValue"}),[ze,Ue]=B.useState(!1),Je=B.useCallback((Ce,xe)=>{if(!(D?Be.length!(y&&(D?Be:[Be]).some(xe=>xe!==null&&R(Ce,xe)))),{inputValue:lt&&yt?"":Le,getOptionLabel:oe}):[],se=Toe({filteredOptions:ft,value:Be,inputValue:Le});B.useEffect(()=>{const Ce=Be!==se.value;ze&&!Ce||w&&!Ce||Je(null,Be)},[Be,Je,ze,se.value,w]);const F=st&&ft.length>0&&!te,V=Eo(Ce=>{Ce===-1?he.current.focus():ye.querySelector(`[data-tag-index="${Ce}"]`).focus()});B.useEffect(()=>{D&&Te>Be.length-1&&(Ge(-1),V(-1))},[Be,D,Te,V]);function re(Ce,xe){if(!Se.current||Ce<0||Ce>=ft.length)return-1;let dt=Ce;for(;;){const Ct=Se.current.querySelector(`[data-option-index="${dt}"]`),ns=p?!1:!Ct||Ct.disabled||Ct.getAttribute("aria-disabled")==="true";if(Ct&&Ct.hasAttribute("tabindex")&&!ns)return dt;if(xe==="next"?dt=(dt+1)%ft.length:dt=(dt-1+ft.length)%ft.length,dt===Ce)return-1}}const le=Eo(({event:Ce,index:xe,reason:dt="auto"})=>{if(Re.current=xe,xe===-1?he.current.removeAttribute("aria-activedescendant"):he.current.setAttribute("aria-activedescendant",`${ne}-option-${xe}`),j&&j(Ce,xe===-1?null:ft[xe],dt),!Se.current)return;const Ct=Se.current.querySelector(`[role="option"].${t}-focused`);Ct&&(Ct.classList.remove(`${t}-focused`),Ct.classList.remove(`${t}-focusVisible`));let ns=Se.current;if(Se.current.getAttribute("role")!=="listbox"&&(ns=Se.current.parentElement.querySelector('[role="listbox"]')),!ns)return;if(xe===-1){ns.scrollTop=0;return}const Ts=Se.current.querySelector(`[data-option-index="${xe}"]`);if(Ts&&(Ts.classList.add(`${t}-focused`),dt==="keyboard"&&Ts.classList.add(`${t}-focusVisible`),ns.scrollHeight>ns.clientHeight&&dt!=="mouse"&&dt!=="touch")){const Fs=Ts,Ln=ns.clientHeight+ns.scrollTop,Ba=Fs.offsetTop+Fs.offsetHeight;Ba>Ln?ns.scrollTop=Ba-ns.clientHeight:Fs.offsetTop-Fs.offsetHeight*(C?1.3:0){if(!ht)return;const Ts=re((()=>{const Fs=ft.length-1;if(xe==="reset")return Ye;if(xe==="start")return 0;if(xe==="end")return Fs;const Ln=Re.current+xe;return Ln<0?Ln===-1&&N?-1:m&&Re.current!==-1||Math.abs(xe)>1?0:Fs:Ln>Fs?Ln===Fs+1&&N?-1:m||Math.abs(xe)>1?Fs:0:Ln})(),dt);if(le({index:Ts,reason:Ct,event:Ce}),s&&xe!=="reset")if(Ts===-1)he.current.value=Le;else{const Fs=oe(ft[Ts]);he.current.value=Fs,Fs.toLowerCase().indexOf(Le.toLowerCase())===0&&Le.length>0&&he.current.setSelectionRange(Le.length,Fs.length)}}),Ne=()=>{const Ce=(xe,dt)=>{const Ct=xe?oe(xe):"",ns=dt?oe(dt):"";return Ct===ns};if(Re.current!==-1&&se.filteredOptions&&se.filteredOptions.length!==ft.length&&se.inputValue===Le&&(D?Be.length===se.value.length&&se.value.every((xe,dt)=>oe(Be[dt])===oe(xe)):Ce(se.value,Be))){const xe=se.filteredOptions[Re.current];if(xe)return hS(ft,dt=>oe(dt)===oe(xe))}return-1},wt=B.useCallback(()=>{if(!ht)return;const Ce=Ne();if(Ce!==-1){Re.current=Ce;return}const xe=D?Be[0]:Be;if(ft.length===0||xe==null){ke({diff:"reset"});return}if(Se.current){if(xe!=null){const dt=ft[Re.current];if(D&&dt&&hS(Be,ns=>R(dt,ns))!==-1)return;const Ct=hS(ft,ns=>R(ns,xe));Ct===-1?ke({diff:"reset"}):le({index:Ct});return}if(Re.current>=ft.length-1){le({index:ft.length-1});return}le({index:Re.current})}},[ft.length,D?!1:Be,y,ke,le,ht,Le,D]),Yt=Eo(Ce=>{nv(Se,Ce),Ce&&wt()});B.useEffect(()=>{wt()},[wt]);const zt=Ce=>{st||(ut(!0),Bt(!0),J&&J(Ce))},Et=(Ce,xe)=>{st&&(ut(!1),K&&K(Ce,xe))},bt=(Ce,xe,dt,Ct)=>{if(D){if(Be.length===xe.length&&Be.every((ns,Ts)=>ns===xe[Ts]))return}else if(Be===xe)return;U&&U(Ce,xe,dt,Ct),Me(xe)},Ms=B.useRef(!1),ls=(Ce,xe,dt="selectOption",Ct="options")=>{let ns=dt,Ts=xe;if(D){Ts=Array.isArray(Be)?Be.slice():[];const Fs=hS(Ts,Ln=>R(xe,Ln));Fs===-1?Ts.push(xe):Ct!=="freeSolo"&&(Ts.splice(Fs,1),ns="removeOption")}Je(Ce,Ts),bt(Ce,Ts,ns,{option:xe}),!l&&(!Ce||!Ce.ctrlKey&&!Ce.metaKey)&&Et(Ce,ns),(r===!0||r==="touch"&&Ms.current||r==="mouse"&&!Ms.current)&&he.current.blur()};function Or(Ce,xe){if(Ce===-1)return-1;let dt=Ce;for(;;){if(xe==="next"&&dt===Be.length||xe==="previous"&&dt===-1)return-1;const Ct=ye.querySelector(`[data-tag-index="${dt}"]`);if(!Ct||!Ct.hasAttribute("tabindex")||Ct.disabled||Ct.getAttribute("aria-disabled")==="true")dt+=xe==="next"?1:-1;else return dt}}const An=(Ce,xe)=>{if(!D)return;Le===""&&Et(Ce,"toggleInput");let dt=Te;Te===-1?Le===""&&xe==="previous"&&(dt=Be.length-1):(dt+=xe==="next"?1:-1,dt<0&&(dt=0),dt===Be.length&&(dt=-1)),dt=Or(dt,xe),Ge(dt),V(dt)},Rs=Ce=>{me.current=!0,rt(""),z&&z(Ce,"","clear"),bt(Ce,D?[]:null,"clear")},Qt=Ce=>xe=>{if(Ce.onKeyDown&&Ce.onKeyDown(xe),!xe.defaultMuiPrevented&&(Te!==-1&&["ArrowLeft","ArrowRight"].indexOf(xe.key)===-1&&(Ge(-1),V(-1)),xe.which!==229))switch(xe.key){case"Home":ht&&M&&(xe.preventDefault(),ke({diff:"start",direction:"next",reason:"keyboard",event:xe}));break;case"End":ht&&M&&(xe.preventDefault(),ke({diff:"end",direction:"previous",reason:"keyboard",event:xe}));break;case"PageUp":xe.preventDefault(),ke({diff:-tV,direction:"previous",reason:"keyboard",event:xe}),zt(xe);break;case"PageDown":xe.preventDefault(),ke({diff:tV,direction:"next",reason:"keyboard",event:xe}),zt(xe);break;case"ArrowDown":xe.preventDefault(),ke({diff:1,direction:"next",reason:"keyboard",event:xe}),zt(xe);break;case"ArrowUp":xe.preventDefault(),ke({diff:-1,direction:"previous",reason:"keyboard",event:xe}),zt(xe);break;case"ArrowLeft":An(xe,"previous");break;case"ArrowRight":An(xe,"next");break;case"Enter":if(Re.current!==-1&&ht){const dt=ft[Re.current],Ct=b?b(dt):!1;if(xe.preventDefault(),Ct)return;ls(xe,dt,"selectOption"),s&&he.current.setSelectionRange(he.current.value.length,he.current.value.length)}else w&&Le!==""&<===!1&&(D&&xe.preventDefault(),ls(xe,Le,"createOption","freeSolo"));break;case"Escape":ht?(xe.preventDefault(),xe.stopPropagation(),Et(xe,"escape")):o&&(Le!==""||D&&Be.length>0)&&(xe.preventDefault(),xe.stopPropagation(),Rs(xe));break;case"Backspace":if(D&&!te&&Le===""&&Be.length>0){const dt=Te===-1?Be.length-1:Te,Ct=Be.slice();Ct.splice(dt,1),bt(xe,Ct,"removeOption",{option:Be[dt]})}break;case"Delete":if(D&&!te&&Le===""&&Be.length>0&&Te!==-1){const dt=Te,Ct=Be.slice();Ct.splice(dt,1),bt(xe,Ct,"removeOption",{option:Be[dt]})}break}},oi=Ce=>{Ue(!0),X&&!me.current&&zt(Ce)},Aa=Ce=>{if(e(Se)){he.current.focus();return}Ue(!1),fe.current=!0,me.current=!1,n&&Re.current!==-1&&ht?ls(Ce,ft[Re.current],"blur"):n&&w&&Le!==""?ls(Ce,Le,"blur","freeSolo"):a&&Je(Ce,Be),Et(Ce,"blur")},mn=Ce=>{const xe=Ce.target.value;Le!==xe&&(rt(xe),Bt(!1),z&&z(Ce,xe,"input")),xe===""?!h&&!D&&bt(Ce,null,"clear"):zt(Ce)},Xr=Ce=>{const xe=Number(Ce.currentTarget.getAttribute("data-option-index"));Re.current!==xe&&le({event:Ce,index:xe,reason:"mouse"})},sd=Ce=>{le({event:Ce,index:Number(Ce.currentTarget.getAttribute("data-option-index")),reason:"touch"}),Ms.current=!0},La=Ce=>{const xe=Number(Ce.currentTarget.getAttribute("data-option-index"));ls(Ce,ft[xe],"selectOption"),Ms.current=!1},id=Ce=>xe=>{const dt=Be.slice();dt.splice(Ce,1),bt(xe,dt,"removeOption",{option:Be[Ce]})},yo=Ce=>{st?Et(Ce,"toggleInput"):zt(Ce)},nd=Ce=>{Ce.currentTarget.contains(Ce.target)&&Ce.target.getAttribute("id")!==ne&&Ce.preventDefault()},Jd=Ce=>{Ce.currentTarget.contains(Ce.target)&&(he.current.focus(),Q&&fe.current&&he.current.selectionEnd-he.current.selectionStart===0&&he.current.select(),fe.current=!1)},$t=Ce=>{!f&&(Le===""||!st)&&yo(Ce)};let ms=w&&Le.length>0;ms=ms||(D?Be.length>0:Be!==null);let ds=ft;return C&&(ds=ft.reduce((Ce,xe,dt)=>{const Ct=C(xe);return Ce.length>0&&Ce[Ce.length-1].group===Ct?Ce[Ce.length-1].options.push(xe):Ce.push({key:dt,index:dt,group:Ct,options:[xe]}),Ce},[])),f&&ze&&Aa(),{getRootProps:(Ce={})=>W({"aria-owns":F?`${ne}-listbox`:null},Ce,{onKeyDown:Qt(Ce),onMouseDown:nd,onClick:Jd}),getInputLabelProps:()=>({id:`${ne}-label`,htmlFor:ne}),getInputProps:()=>({id:ne,value:Le,onBlur:Aa,onFocus:oi,onChange:mn,onMouseDown:$t,"aria-activedescendant":ht?"":null,"aria-autocomplete":s?"both":"list","aria-controls":F?`${ne}-listbox`:void 0,"aria-expanded":F,autoComplete:"off",ref:he,autoCapitalize:"none",spellCheck:"false",role:"combobox",disabled:f}),getClearProps:()=>({tabIndex:-1,type:"button",onClick:Rs}),getPopupIndicatorProps:()=>({tabIndex:-1,type:"button",onClick:yo}),getTagProps:({index:Ce})=>W({key:Ce,"data-tag-index":Ce,tabIndex:-1},!te&&{onDelete:id(Ce)}),getListboxProps:()=>({role:"listbox",id:`${ne}-listbox`,"aria-labelledby":`${ne}-label`,ref:Yt,onMouseDown:Ce=>{Ce.preventDefault()}}),getOptionProps:({index:Ce,option:xe})=>{var dt;const Ct=(D?Be:[Be]).some(Ts=>Ts!=null&&R(xe,Ts)),ns=b?b(xe):!1;return{key:(dt=S==null?void 0:S(xe))!=null?dt:oe(xe),tabIndex:-1,role:"option",id:`${ne}-option-${Ce}`,onMouseMove:Xr,onClick:La,onTouchStart:sd,"data-option-index":Ce,"aria-disabled":ns,"aria-selected":Ct}},id:ne,inputValue:Le,value:Be,dirty:ms,expanded:ht&&ye,popupOpen:ht,focused:ze||Te!==-1,anchorEl:ye,setAnchorEl:ge,focusedTag:Te,groupedOptions:ds}}function aye(d){return Rt("MuiIconButton",d)}const n2=Dt("MuiIconButton",["root","colorPrimary","colorNeutral","colorDanger","colorSuccess","colorWarning","colorContext","variantPlain","variantOutlined","variantSoft","variantSolid","focusVisible","disabled","sizeSm","sizeMd","sizeLg","loading","loadingIndicator"]),rb=B.createContext({}),eL=B.createContext(void 0);function oye(d){return Rt("MuiCircularProgress",d)}Dt("MuiCircularProgress",["root","determinate","svg","track","progress","colorPrimary","colorNeutral","colorDanger","colorSuccess","colorWarning","colorContext","sizeSm","sizeMd","sizeLg","variantPlain","variantOutlined","variantSoft","variantSolid"]);let dye=d=>d,sV;const cye=["color","backgroundColor"],uye=["children","className","color","size","variant","thickness","determinate","value","component","slots","slotProps"],hye=Ww({"0%":{transform:"rotate(-90deg)"},"100%":{transform:"rotate(270deg)"}}),lye=d=>{const{determinate:e,color:t,variant:s,size:i}=d,n={root:["root",e&&"determinate",t&&`color${De(t)}`,s&&`variant${De(s)}`,i&&`size${De(i)}`],svg:["svg"],track:["track"],progress:["progress"]};return Nt(n,oye,{})};function ep(d,e){return`var(--CircularProgress-${d}Thickness, var(--CircularProgress-thickness, ${e}))`}const fye=_e("span",{name:"JoyCircularProgress",slot:"Root",overridesResolver:(d,e)=>e.root})(({ownerState:d,theme:e})=>{var t,s,i,n;const r=((t=e.variants[d.variant])==null?void 0:t[d.color])||{},{color:a,backgroundColor:o}=r,c=at(r,cye);return W({"--Icon-fontSize":"calc(0.4 * var(--_root-size))","--CircularProgress-trackColor":o,"--CircularProgress-progressColor":a,"--CircularProgress-percent":d.value,"--CircularProgress-linecap":"round"},d.size==="sm"&&{"--_root-size":"var(--CircularProgress-size, 24px)","--_track-thickness":ep("track","3px"),"--_progress-thickness":ep("progress","3px")},d.instanceSize==="sm"&&{"--CircularProgress-size":"24px"},d.size==="md"&&{"--_track-thickness":ep("track","6px"),"--_progress-thickness":ep("progress","6px"),"--_root-size":"var(--CircularProgress-size, 40px)"},d.instanceSize==="md"&&{"--CircularProgress-size":"40px"},d.size==="lg"&&{"--_track-thickness":ep("track","8px"),"--_progress-thickness":ep("progress","8px"),"--_root-size":"var(--CircularProgress-size, 64px)"},d.instanceSize==="lg"&&{"--CircularProgress-size":"64px"},d.thickness&&{"--_track-thickness":`${d.thickness}px`,"--_progress-thickness":`${d.thickness}px`},{"--_thickness-diff":"calc(var(--_track-thickness) - var(--_progress-thickness))","--_inner-size":"calc(var(--_root-size) - 2 * var(--variant-borderWidth, 0px))","--_outlined-inset":"max(var(--_track-thickness), var(--_progress-thickness))",width:"var(--_root-size)",height:"var(--_root-size)",borderRadius:"var(--_root-size)",margin:"var(--CircularProgress-margin)",boxSizing:"border-box",display:"inline-flex",justifyContent:"center",alignItems:"center",flexShrink:0,position:"relative",color:a},d.children&&{fontFamily:e.vars.fontFamily.body,fontWeight:e.vars.fontWeight.md,fontSize:"calc(0.2 * var(--_root-size))"},c,d.variant==="outlined"&&{"&::before":W({content:'""',display:"block",position:"absolute",borderRadius:"inherit",top:"var(--_outlined-inset)",left:"var(--_outlined-inset)",right:"var(--_outlined-inset)",bottom:"var(--_outlined-inset)"},c)},d.variant==="soft"&&{"--CircularProgress-trackColor":e.variants.soft.neutral.backgroundColor,"--CircularProgress-progressColor":(s=e.variants.solid)==null?void 0:s[d.color].backgroundColor},d.variant==="solid"&&{"--CircularProgress-trackColor":(i=e.variants.softHover)==null?void 0:i[d.color].backgroundColor,"--CircularProgress-progressColor":(n=e.variants.solid)==null?void 0:n[d.color].backgroundColor})}),pye=_e("svg",{name:"JoyCircularProgress",slot:"Svg",overridesResolver:(d,e)=>e.svg})({width:"inherit",height:"inherit",display:"inherit",boxSizing:"inherit",position:"absolute",top:"calc(-1 * var(--variant-borderWidth, 0px))",left:"calc(-1 * var(--variant-borderWidth, 0px))"}),mye=_e("circle",{name:"JoyCircularProgress",slot:"track",overridesResolver:(d,e)=>e.track})({cx:"50%",cy:"50%",r:"calc(var(--_inner-size) / 2 - var(--_track-thickness) / 2 + min(0px, var(--_thickness-diff) / 2))",fill:"transparent",strokeWidth:"var(--_track-thickness)",stroke:"var(--CircularProgress-trackColor)"}),gye=_e("circle",{name:"JoyCircularProgress",slot:"progress",overridesResolver:(d,e)=>e.progress})({"--_progress-radius":"calc(var(--_inner-size) / 2 - var(--_progress-thickness) / 2 - max(0px, var(--_thickness-diff) / 2))","--_progress-length":"calc(2 * 3.1415926535 * var(--_progress-radius))",cx:"50%",cy:"50%",r:"var(--_progress-radius)",fill:"transparent",strokeWidth:"var(--_progress-thickness)",stroke:"var(--CircularProgress-progressColor)",strokeLinecap:"var(--CircularProgress-linecap, round)",strokeDasharray:"var(--_progress-length)",strokeDashoffset:"calc(var(--_progress-length) - var(--CircularProgress-percent) * var(--_progress-length) / 100)",transformOrigin:"center",transform:"rotate(-90deg)"},({ownerState:d})=>!d.determinate&&Yy(sV||(sV=dye` animation: var(--CircularProgress-circulation, 0.8s linear 0s infinite normal none running) ${0}; @@ -191,7 +191,7 @@ export default theme;`}function d2(d={},...e){const{breakpoints:t,mixins:s={},sp ); transform: translateX(-100%); /* Avoid flash during server-side hydration */ } - `),e.vars.palette.background.level3,oxe),({ownerState:d,theme:e})=>{var t,s,i,n;const r=((t=e.components)==null||(t=t.JoyTypography)==null||(t=t.defaultProps)==null?void 0:t.level)||"body1";return[{display:"block",position:"relative","--unstable_pseudo-zIndex":9,"--unstable_pulse-bg":e.vars.palette.background.level1,overflow:"hidden",cursor:"default",color:"transparent","& *":{visibility:"hidden"},"&::before":{display:"block",content:'" "',top:0,bottom:0,left:0,right:0,zIndex:"var(--unstable_pseudo-zIndex)",borderRadius:"inherit"},[e.getColorSchemeSelector("dark")]:{"--unstable_wave-bg":"rgba(255 255 255 / 0.1)"}},d.variant==="rectangular"&&W({borderRadius:"min(0.15em, 6px)",height:"auto",width:"100%","&::before":{position:"absolute"}},!d.animation&&{backgroundColor:e.vars.palette.background.level3},d.level!=="inherit"&&W({},e.typography[d.level])),d.variant==="circular"&&W({borderRadius:"50%",width:"100%",height:"100%","&::before":{position:"absolute"}},!d.animation&&{backgroundColor:e.vars.palette.background.level3},d.level!=="inherit"&&W({},e.typography[d.level])),d.variant==="text"&&W({borderRadius:"min(0.15em, 6px)",background:"transparent",width:"100%"},d.level!=="inherit"&&W({},e.typography[d.level||r],{paddingBlockStart:`calc((${((s=e.typography[d.level||r])==null?void 0:s.lineHeight)||1} - 1) * 0.56em)`,paddingBlockEnd:`calc((${((i=e.typography[d.level||r])==null?void 0:i.lineHeight)||1} - 1) * 0.44em)`,"&::before":W({height:"1em"},e.typography[d.level||r],d.animation==="wave"&&{backgroundColor:e.vars.palette.background.level3},!d.animation&&{backgroundColor:e.vars.palette.background.level3}),"&::after":W({height:"1em",top:`calc((${((n=e.typography[d.level||r])==null?void 0:n.lineHeight)||1} - 1) * 0.56em)`},e.typography[d.level||r])})),d.variant==="inline"&&W({display:"inline",position:"initial",borderRadius:"min(0.15em, 6px)"},!d.animation&&{backgroundColor:e.vars.palette.background.level3},d.level!=="inherit"&&W({},e.typography[d.level]),{WebkitMaskImage:"-webkit-radial-gradient(white, black)","&::before":{position:"absolute",zIndex:"var(--unstable_pseudo-zIndex)",backgroundColor:e.vars.palette.background.level3}},d.animation==="pulse"&&{"&::after":{content:'""',position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:"var(--unstable_pseudo-zIndex)",backgroundColor:e.vars.palette.background.level3}}),d.variant==="overlay"&&W({borderRadius:e.vars.radius.xs,position:"absolute",width:"100%",height:"100%",zIndex:"var(--unstable_pseudo-zIndex)"},d.animation==="pulse"&&{backgroundColor:e.vars.palette.background.surface},d.level!=="inherit"&&W({},e.typography[d.level]),{"&::before":{position:"absolute"}})]}),mi=B.forwardRef(function(e,t){const s=qt({props:e,name:"JoySkeleton"}),{className:i,component:n="span",children:r,animation:a="pulse",overlay:o=!1,loading:c=!0,variant:u="overlay",level:h=u==="text"?"body-md":"inherit",height:l,width:f,sx:p,slots:m={},slotProps:g={}}=s,y=at(s,rxe),w=W({},y,{component:n,slots:m,slotProps:g,sx:[{width:f,height:l},...Array.isArray(p)?p:[p]]}),b=W({},s,{animation:a,component:n,level:h,loading:c,overlay:o,variant:u,width:f,height:l}),S=axe(b),[v,C]=Fe("root",{ref:t,className:Gt(S.root,i),elementType:dxe,externalForwardedProps:w,ownerState:b});return c?P.jsx(v,W({},C,{children:r})):P.jsx(B.Fragment,{children:B.Children.map(r,(M,_)=>_===0&&B.isValidElement(M)?B.cloneElement(M,{"data-first-child":""}):M)})});mi.muiName="Skeleton";const cxe=8,uxe=()=>{const d=Array.from({length:cxe});return P.jsx(It,{container:!0,spacing:2,children:d.map((e,t)=>P.jsx(It,{md:4,sm:6,xl:3,xs:12,children:P.jsx(mi,{animation:"wave",height:236,sx:{borderRadius:8},variant:"rectangular",width:"100%"},t)},t))})};function hxe(d){return Rt("MuiMenu",d)}Dt("MuiMenu",["root","listbox","expanded","colorPrimary","colorNeutral","colorDanger","colorSuccess","colorWarning","colorContext","variantPlain","variantOutlined","variantSoft","variantSolid","sizeSm","sizeMd","sizeLg"]);const lxe=["actions","children","color","component","disablePortal","keepMounted","id","invertedColors","onItemsChange","modifiers","variant","size","slots","slotProps"],fxe=d=>{const{open:e,variant:t,color:s,size:i}=d,n={root:["root",e&&"expanded",t&&`variant${De(t)}`,s&&`color${De(s)}`,i&&`size${De(i)}`],listbox:["listbox"]};return Nt(n,hxe,{})},ZV=_e(ag,{name:"JoyMenu",slot:"Root",overridesResolver:(d,e)=>e.root})(({theme:d,ownerState:e})=>{var t,s;const i=(t=d.variants[e.variant])==null?void 0:t[e.color];return[W({"--focus-outline-offset":`calc(${d.vars.focus.thickness} * -1)`,"--ListItem-stickyBackground":(i==null?void 0:i.backgroundColor)||(i==null?void 0:i.background)||d.vars.palette.background.popup,"--ListItem-stickyTop":"calc(var(--List-padding, var(--ListDivider-gap)) * -1)"},CO,{borderRadius:`var(--List-radius, ${d.vars.radius.sm})`,boxShadow:d.shadow.md,overflow:"auto",zIndex:`var(--unstable_popup-zIndex, ${d.vars.zIndex.popup})`},!(i!=null&&i.backgroundColor)&&{backgroundColor:d.vars.palette.background.popup},e.variant==="solid"&&e.color&&e.invertedColors&&ig(e.color)(d),e.variant==="soft"&&e.color&&e.invertedColors&&ng(e.color)(d),(s=d.variants[e.variant])==null?void 0:s[e.color])]}),pxe=B.forwardRef(function(e,t){var s;const i=qt({props:e,name:"JoyMenu"}),{actions:n,children:r,color:a="neutral",component:o,disablePortal:c=!1,keepMounted:u=!1,id:h,invertedColors:l=!1,onItemsChange:f,modifiers:p,variant:m="outlined",size:g="md",slots:y={},slotProps:w={}}=i,b=at(i,lxe),{contextValue:S,getListboxProps:v,dispatch:C,open:M,triggerElement:_}=wme({onItemsChange:f,id:h,listboxRef:t});B.useImperativeHandle(n,()=>({dispatch:C,resetHighlight:()=>C({type:ei.resetHighlight,event:null})}),[C]);const N=W({},i,{disablePortal:c,invertedColors:l,color:a,variant:m,size:g,open:M,nesting:!1,row:!1}),A=fxe(N),R=W({},b,{component:o,slots:y,slotProps:w}),D=B.useMemo(()=>[{name:"offset",options:{offset:[0,4]}},...p||[]],[p]),U=ZG({elementType:ZV,getSlotProps:v,externalForwardedProps:R,externalSlotProps:{},ownerState:N,additionalProps:{anchorEl:_,open:M&&_!==null,disablePortal:c,keepMounted:u,modifiers:D},className:A.root});return P.jsx(ZV,W({},U,!((s=i.slots)!=null&&s.root)&&{as:lO,slots:{root:o||"ul"}},{children:P.jsx(bme,{value:S,children:P.jsx(hb,{variant:l?void 0:m,color:a,children:P.jsx(IO.Provider,{value:"menu",children:P.jsx(rg,{nested:!0,children:r})})})})}))});function mxe(d){return Rt("MuiMenuButton",d)}Dt("MuiMenuButton",["root","colorPrimary","colorNeutral","colorDanger","colorInfo","colorSuccess","colorWarning","colorContext","variantPlain","variantOutlined","variantSoft","variantSolid","disabled","sizeSm","sizeMd","sizeLg","fullWidth","startDecorator","endDecorator","loading","loadingIndicatorCenter"]);const gxe=["children","color","component","disabled","endDecorator","loading","loadingPosition","loadingIndicator","size","slotProps","slots","startDecorator","variant"],yxe=d=>{const{color:e,disabled:t,fullWidth:s,size:i,variant:n,loading:r}=d,a={root:["root",t&&"disabled",s&&"fullWidth",n&&`variant${De(n)}`,e&&`color${De(e)}`,i&&`size${De(i)}`,r&&"loading"],startDecorator:["startDecorator"],endDecorator:["endDecorator"],loadingIndicatorCenter:["loadingIndicatorCenter"]};return Nt(a,mxe,{})},wxe=_e("button",{name:"JoyMenuButton",slot:"Root",overridesResolver:(d,e)=>e.root})(DU),bxe=_e("span",{name:"JoyMenuButton",slot:"StartDecorator",overridesResolver:(d,e)=>e.startDecorator})({"--Icon-margin":"0 0 0 calc(var(--Button-gap) / -2)","--CircularProgress-margin":"0 0 0 calc(var(--Button-gap) / -2)",display:"inherit",marginRight:"var(--Button-gap)"}),kxe=_e("span",{name:"JoyMenuButton",slot:"EndDecorator",overridesResolver:(d,e)=>e.endDecorator})({"--Icon-margin":"0 calc(var(--Button-gap) / -2) 0 0","--CircularProgress-margin":"0 calc(var(--Button-gap) / -2) 0 0",display:"inherit",marginLeft:"var(--Button-gap)"}),Sxe=_e("span",{name:"JoyMenuButton",slot:"LoadingCenter",overridesResolver:(d,e)=>e.loadingIndicatorCenter})(({theme:d,ownerState:e})=>{var t,s;return W({display:"inherit",position:"absolute",left:"50%",transform:"translateX(-50%)",color:(t=d.variants[e.variant])==null||(t=t[e.color])==null?void 0:t.color},e.disabled&&{color:(s=d.variants[`${e.variant}Disabled`])==null||(s=s[e.color])==null?void 0:s.color})}),vxe=B.forwardRef(function(e,t){var s;const i=qt({props:e,name:"JoyMenuButton"}),{children:n,color:r="neutral",component:a,disabled:o=!1,endDecorator:c,loading:u=!1,loadingPosition:h="center",loadingIndicator:l,size:f="md",slotProps:p={},slots:m={},startDecorator:g,variant:y="outlined"}=i,w=at(i,gxe),b=B.useContext(rb),S=e.variant||b.variant||y,v=e.size||b.size||f,C=(s=e.disabled)!=null?s:b.disabled||o||u,{getRootProps:M,open:_,active:N}=kme({rootRef:t,disabled:C}),A=l??P.jsx(fO,{color:r,thickness:{sm:2,md:3,lg:4}[v]||3}),R=W({},i,{active:N,color:r,disabled:C,open:_,size:v,variant:S}),D=yxe(R),U=W({},w,{component:a,slots:m,slotProps:p}),[K,j]=Fe("root",{elementType:wxe,getSlotProps:M,externalForwardedProps:U,ref:t,ownerState:R,className:D.root}),[z,J]=Fe("startDecorator",{className:D.startDecorator,elementType:bxe,externalForwardedProps:U,ownerState:R}),[Y,X]=Fe("endDecorator",{className:D.endDecorator,elementType:kxe,externalForwardedProps:U,ownerState:R}),[Z,te]=Fe("loadingIndicatorCenter",{className:D.loadingIndicatorCenter,elementType:Sxe,externalForwardedProps:U,ownerState:R});return P.jsxs(K,W({},j,{children:[(g||u&&h==="start")&&P.jsx(z,W({},J,{children:u&&h==="start"?A:g})),n,u&&h==="center"&&P.jsx(Z,W({},te,{children:A})),(c||u&&h==="end")&&P.jsx(Y,W({},X,{children:u&&h==="end"?A:c}))]}))});function Txe(d){return Rt("MuiMenuItem",d)}Dt("MuiMenuItem",["root","focusVisible","disabled","selected","colorPrimary","colorNeutral","colorDanger","colorSuccess","colorWarning","colorContext","variantPlain","variantSoft","variantOutlined","variantSolid"]);const Oxe=["children","disabled","component","selected","color","orientation","variant","slots","slotProps","id"],xxe=d=>{const{focusVisible:e,disabled:t,selected:s,color:i,variant:n}=d,r={root:["root",e&&"focusVisible",t&&"disabled",s&&"selected",i&&`color${De(i)}`,n&&`variant${De(n)}`]};return Nt(r,Txe,{})},Pxe=_e(og,{name:"JoyMenuItem",slot:"Root",overridesResolver:(d,e)=>e.root})({}),Ixe=B.memo(B.forwardRef(function(e,t){const s=qt({props:e,name:"JoyMenuItem"}),i=B.useContext(Sf),{children:n,disabled:r=!1,component:a="li",selected:o=!1,color:c="neutral",orientation:u="horizontal",variant:h="plain",slots:l={},slotProps:f={},id:p}=s,m=at(s,Oxe),{variant:g=h,color:y=c}=PO(e.variant,e.color),{getRootProps:w,disabled:b,focusVisible:S}=Tme({id:p,disabled:r,rootRef:t}),v=W({},s,{component:a,color:y,disabled:b,focusVisible:S,orientation:u,selected:o,row:i,variant:g}),C=xxe(v),M=W({},m,{component:a,slots:l,slotProps:f}),[_,N]=Fe("root",{ref:t,elementType:Pxe,getSlotProps:w,externalForwardedProps:M,className:C.root,ownerState:v});return P.jsx(MO.Provider,{value:u,children:P.jsx(_,W({},N,{children:n}))})})),MI=B.forwardRef(function(e,t){const{contextValue:s,id:i}=Ome(e.id);return P.jsx(Eh.Provider,{value:s,children:P.jsx(Ixe,W({},e,{id:i,ref:t}))})}),Cxe=()=>P.jsxs(Kpe,{children:[P.jsx(vxe,{size:"lg",color:"primary",variant:"solid",children:"Create new bot"}),P.jsxs(pxe,{size:"lg",children:[P.jsx(MI,{component:Uo,href:ai("grid-bot/create"),children:"New Grid Bot"}),P.jsx(MI,{component:Uo,href:ai("dca-bot/create"),children:"New DCA Bot"}),P.jsx(MI,{component:Uo,href:ai("bot/create"),children:"New custom bot"})]})]}),Mxe=()=>P.jsx(_t,{display:"flex",justifyContent:"space-around",children:P.jsxs(_t,{sx:{textAlign:"center",mt:2},children:[P.jsx(ot,{level:"body-lg",children:"You must add an exchange account before creating a bot"}),P.jsx(Es,{component:Uo,href:ai("accounts"),variant:"soft",size:"md",sx:{mt:1},children:"Add exchange account"})]})});function _xe(){const[d]=kt.exchangeAccount.list.useSuspenseQuery();return d.length===0?P.jsx(Mxe,{}):P.jsxs(It,{container:!0,spacing:4,children:[P.jsx(It,{xs:12,children:P.jsx(_t,{display:"flex",gap:1,children:P.jsx(Cxe,{})})}),P.jsx(It,{xs:12,children:P.jsx(B.Suspense,{fallback:P.jsx(uxe,{}),children:P.jsx(ixe,{})})})]})}const Axe=vr("/_layout/dashboard/bot/")({component:_xe}),Lxe="modulepreload",Bxe=function(d){return"/"+d},JV={},Po=function(e,t,s){let i=Promise.resolve();if(t&&t.length>0){document.getElementsByTagName("link");const r=document.querySelector("meta[property=csp-nonce]"),a=(r==null?void 0:r.nonce)||(r==null?void 0:r.getAttribute("nonce"));i=Promise.allSettled(t.map(o=>{if(o=Bxe(o),o in JV)return;JV[o]=!0;const c=o.endsWith(".css"),u=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${o}"]${u}`))return;const h=document.createElement("link");if(h.rel=c?"stylesheet":Lxe,c||(h.as="script"),h.crossOrigin="",h.href=o,a&&h.setAttribute("nonce",a),document.head.appendChild(h),c)return new Promise((l,f)=>{h.addEventListener("load",l),h.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${o}`)))})}))}function n(r){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=r,window.dispatchEvent(a),!a.defaultPrevented)throw r}return i.then(r=>{for(const a of r||[])a.status==="rejected"&&n(a.reason);return e().catch(n)})},vL=()=>P.jsxs(It,{container:!0,spacing:2,children:[P.jsx(It,{md:9,children:P.jsx(mi,{animation:"wave",height:420,sx:{borderRadius:8},variant:"rectangular",width:"100%"})}),P.jsx(It,{md:3,children:P.jsx(mi,{animation:"wave",height:232,sx:{borderRadius:8},variant:"rectangular",width:"100%"})})]}),TL=(d,e=null)=>{const t=B.lazy(d);return s=>P.jsx(B.Suspense,{fallback:e,children:P.jsx(t,{...s})})},Nxe=TL(()=>Po(()=>import("./page-D3nC2yWj.js"),__vite__mapDeps([0,1])),P.jsx(vL,{})),Exe=vr("/_layout/dashboard/grid-bot/create")({component:Nxe});function Rxe(){return P.jsx("tbody",{children:P.jsx("tr",{children:P.jsx("td",{colSpan:4,children:P.jsx(ot,{fontWeight:"400",level:"h4",sx:{py:2},textAlign:"center",children:"No logs yet"})})})})}const WW=80,jW=160,Dxe=()=>P.jsx("thead",{children:P.jsxs("tr",{children:[P.jsx("th",{children:"Action"}),P.jsx("th",{children:"Description"}),P.jsx("th",{style:{textAlign:"right",width:WW},children:P.jsx(In,{title:"Strategy execution duration",children:P.jsx(ot,{children:"Duration"})})}),P.jsx("th",{style:{textAlign:"right",width:jW},children:"Date"})]})}),qxe=({log:d,children:e})=>{var s;const t=(s=d.context)==null?void 0:s.candle;return P.jsx(In,{title:P.jsxs(_t,{children:[P.jsxs("div",{children:["O ",t==null?void 0:t.open]}),P.jsxs("div",{children:["H ",t==null?void 0:t.high]}),P.jsxs("div",{children:["L ",t==null?void 0:t.low]}),P.jsxs("div",{children:["C ",t==null?void 0:t.close]})]}),children:e})};function Vxe(d){return d==="start"?"success":d==="stop"?"danger":"warning"}const Fxe=({action:d})=>P.jsx(nn,{color:Vxe(d),children:d}),Hxe=Ys(P.jsx("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 12z"}),"Close"),Gxe=Ys(P.jsx("path",{d:"M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2M12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"}),"ErrorOutline"),Uxe=({log:d})=>{var n,r,a;console.log("log.context",d);const[e,t]=B.useState(!1),s=()=>t(!0),i=()=>t(!1);return P.jsxs(P.Fragment,{children:[P.jsx(In,{title:(n=d.error)==null?void 0:n.message,children:P.jsx(Gxe,{sx:{fontSize:"xl"},color:"warning",onClick:s})}),P.jsx(tb,{onClose:i,open:e,children:P.jsxs(db,{maxWidth:1024,children:[P.jsxs(mO,{children:[P.jsx(JU,{}),"An error occurred in the strategy template",P.jsx(Rc,{}),P.jsx(Vd,{onClick:i,children:P.jsx(Hxe,{})})]}),P.jsx(Ia,{}),P.jsxs(iL,{children:[P.jsx(ot,{level:"title-lg",fontWeight:"bold",children:(r=d.error)==null?void 0:r.message}),P.jsx(ot,{children:P.jsx("pre",{children:(a=d.error)==null?void 0:a.stack})})]})]})})]})};function Wxe(d,e){const t=new Date(d);return`+${new Date(e).getTime()-t.getTime()}ms`}function jxe(d){return h2(new Date(d),"yyyy-MM-dd'T'HH:mm:ss")}const zxe=d=>{var e;if(d.action==="start"){const t=d==null?void 0:d.error;return t?`An error occurred when starting the bot: ${t.message}`:"Bot started"}if(d.action==="stop"){const t=d==null?void 0:d.error;return t?`An error occurred while stopping the bot: ${t.message}`:"Bot stopped"}if(d.triggerEventType===hI.onOrderFilled)return"An order was filled";if(d.triggerEventType===hI.onCandleClosed){const t=(e=d.context)==null?void 0:e.candle,s=t!=null&&t.timestamp?jxe(t.timestamp):"MISSING_TIMESTAMP";return P.jsxs(P.Fragment,{children:["Candle"," ",P.jsx(nn,{size:"sm",variant:"outlined",color:"neutral",children:s})," ","closed at price"," ",P.jsx(qxe,{log:d,children:P.jsx(nn,{size:"sm",variant:"outlined",color:"neutral",children:t==null?void 0:t.close})})]})}else if(d.triggerEventType===hI.onPublicTrade)return"A public trade happened";return"Unhandled log message"},$xe=({log:d})=>{const e=Jl(d.createdAt.getTime(),!0);return P.jsxs("tr",{tabIndex:-1,children:[P.jsx("td",{scope:"row",children:P.jsxs(_t,{display:"flex",alignItems:"center",children:[d.error?P.jsx(Uxe,{log:d}):null,P.jsx(Fxe,{action:d.action})]})}),P.jsx("td",{scope:"row",children:P.jsx(ot,{display:"inline",children:zxe(d)})}),P.jsx("td",{style:{textAlign:"right",width:WW},children:P.jsx(ot,{display:"inline",color:"success",fontSize:"sm",children:Wxe(d.startedAt,d.endedAt)})}),P.jsx("td",{style:{textAlign:"right",width:jW},children:P.jsx(ot,{level:"body-sm",children:e})})]})},OL=({botId:d})=>{const[e]=kt.bot.getBotLogs.useSuspenseQuery({botId:d});return P.jsx(dg,{sx:{width:"100%",boxShadow:"sm",borderRadius:"sm"},variant:"outlined",children:P.jsxs(_O,{hoverRow:!0,sx:{"--TableCell-headBackground":"transparent","--TableCell-selectedBackground":t=>t.vars.palette.success.softBg,"& thead th:nth-child(1)":{width:"80px"}},children:[P.jsx(Dxe,{}),e.length>0?P.jsx("tbody",{children:e.map(t=>P.jsx($xe,{log:t},t.id))}):P.jsx(Rxe,{})]})})};function Kxe(d){return Rt("MuiTab",d)}const Xxe=Dt("MuiTab",["root","disabled","focusVisible","selected","horizontal","vertical","colorPrimary","colorNeutral","colorDanger","colorSuccess","colorWarning","colorContext","variantPlain","variantOutlined","variantSoft","variantSolid"]),Qxe=["action","children","value","disabled","onChange","onClick","onFocus","component","orientation","variant","color","disableIndicator","indicatorPlacement","indicatorInset","slots","slotProps"],Yxe=d=>{const{selected:e,disabled:t,focusVisible:s,variant:i,color:n,orientation:r}=d,a={root:["root",r,t&&"disabled",s&&"focusVisible",e&&"selected",i&&`variant${De(i)}`,n&&`color${De(n)}`]};return Nt(a,Kxe,{})},Zxe=_e(og,{name:"JoyTab",slot:"Root",overridesResolver:(d,e)=>e.root})(({ownerState:d})=>[{flex:"initial",justifyContent:d.row?"center":"initial","--unstable_ListItemDecorator-alignItems":"center","--unstable_offset":"min(calc(-1 * var(--variant-borderWidth, 0px)), -1px)"},!d.disableIndicator&&{'&[aria-selected="true"]':{"--Tab-indicatorColor":"currentColor",zIndex:1},"&::after":{content:'""',display:"block",position:"absolute",margin:"auto",background:"var(--Tab-indicatorColor)",borderRadius:"var(--Tab-indicatorRadius)"}},!d.disableIndicator&&d.indicatorPlacement==="bottom"&&{paddingBottom:"calc(var(--ListItem-paddingY) - var(--variant-borderWidth, 0px) + var(--Tab-indicatorThickness) - 1px)","&::after":{height:"var(--Tab-indicatorThickness)",width:"var(--Tab-indicatorSize)",left:d.indicatorInset?"var(--ListItem-paddingLeft)":"var(--unstable_offset)",right:d.indicatorInset?"var(--ListItem-paddingRight)":"var(--unstable_offset)",bottom:"calc(-1px - var(--unstable_TabList-underlineBottom, 0px))"}},!d.disableIndicator&&d.indicatorPlacement==="top"&&{paddingTop:"calc(var(--ListItem-paddingY) - var(--variant-borderWidth, 0px) + var(--Tab-indicatorThickness) - 1px)","&::after":{height:"var(--Tab-indicatorThickness)",width:"var(--Tab-indicatorSize)",left:d.indicatorInset?"var(--ListItem-paddingLeft)":"var(--unstable_offset)",right:d.indicatorInset?"var(--ListItem-paddingRight)":"var(--unstable_offset)",top:"calc(-1px - var(--unstable_TabList-underlineTop, 0px))"}},!d.disableIndicator&&d.indicatorPlacement==="right"&&{paddingRight:"calc(var(--ListItem-paddingRight) + var(--Tab-indicatorThickness) - 1px)","&::after":{height:"var(--Tab-indicatorSize)",width:"var(--Tab-indicatorThickness)",top:d.indicatorInset?"var(--ListItem-paddingY)":"var(--unstable_offset)",bottom:d.indicatorInset?"var(--ListItem-paddingY)":"var(--unstable_offset)",right:"calc(-1px - var(--unstable_TabList-underlineRight, 0px))"}},!d.disableIndicator&&d.indicatorPlacement==="left"&&{paddingLeft:"calc(var(--ListItem-paddingLeft) + var(--Tab-indicatorThickness) - 1px)","&::after":{height:"var(--Tab-indicatorSize)",width:"var(--Tab-indicatorThickness)",top:d.indicatorInset?"var(--ListItem-paddingY)":"var(--unstable_offset)",bottom:d.indicatorInset?"var(--ListItem-paddingY)":"var(--unstable_offset)",left:"calc(-1px - var(--unstable_TabList-underlineLeft, 0px))"}}]),_I=B.forwardRef(function(e,t){const s=qt({props:e,name:"JoyTab"}),i=B.useContext(Sf),{action:n,children:r,disabled:a=!1,component:o="button",orientation:c="horizontal",variant:u="plain",color:h="neutral",disableIndicator:l=!1,indicatorPlacement:f=i?"bottom":"right",indicatorInset:p=!1,slots:m={},slotProps:g={}}=s,y=at(s,Qxe),w=B.useRef(null),b=Cs(w,t),{active:S,focusVisible:v,setFocusVisible:C,selected:M,getRootProps:_}=Zge(W({},s,{rootRef:b}));B.useImperativeHandle(n,()=>({focusVisible:()=>{C(!0),w.current.focus()}}),[C]);const N=W({},s,{disableIndicator:l,indicatorPlacement:f,indicatorInset:p,orientation:c,row:i,active:S,focusVisible:v,disabled:a,selected:M,variant:u,color:h}),A=Yxe(N),R=W({},y,{component:o,slots:m,slotProps:g}),[D,U]=Fe("root",{ref:t,elementType:Zxe,getSlotProps:_,externalForwardedProps:R,ownerState:N,className:A.root});return P.jsx(MO.Provider,{value:c,children:P.jsx(D,W({},U,{children:r}))})}),zW=B.createContext("md");function Jxe(d){return Rt("MuiTabList",d)}Dt("MuiTabList",["root","colorPrimary","colorNeutral","colorDanger","colorSuccess","colorWarning","colorContext","variantPlain","variantOutlined","variantSoft","variantSolid","sizeSm","sizeMd","sizeLg"]);const ePe=["component","children","variant","color","size","disableUnderline","underlinePlacement","tabFlex","sticky","slots","slotProps"],tPe=d=>{const{orientation:e,size:t,variant:s,color:i}=d,n={root:["root",e,s&&`variant${De(s)}`,i&&`color${De(i)}`,t&&`size${De(t)}`]};return Nt(n,Jxe,{})},sPe=_e(ag,{name:"JoyTabList",slot:"Root",overridesResolver:(d,e)=>e.root})(({theme:d,ownerState:e})=>{var t;const s=(t=d.variants[e.variant])==null?void 0:t[e.color];return W({"--List-gap":"0px","--ListDivider-gap":"0px","--ListItem-paddingX":"var(--Tabs-spacing)","--ListItem-gap":"0.375rem","--unstable_TabList-hasUnderline":e.disableUnderline?"var(--unknown,)":"initial"},CO,{flexGrow:"initial",flexDirection:e.orientation==="vertical"?"column":"row",borderRadius:"var(--List-radius, 0px)",padding:"var(--List-padding, 0px)",zIndex:1},e.sticky&&{position:"sticky",top:e.sticky==="top"?"calc(-1 * var(--Tabs-padding, 0px))":"initial",bottom:e.sticky==="bottom"?"calc(-1 * var(--Tabs-padding, 0px))":"initial",backgroundColor:(s==null?void 0:s.backgroundColor)||`var(--TabList-stickyBackground, ${d.vars.palette.background.body})`},!e.disableUnderline&&W({},e.underlinePlacement==="bottom"&&{"--unstable_TabList-underlineBottom":"1px",paddingBottom:1,boxShadow:`inset 0 -1px ${d.vars.palette.divider}`},e.underlinePlacement==="top"&&{"--unstable_TabList-underlineTop":"1px",paddingTop:1,boxShadow:`inset 0 1px ${d.vars.palette.divider}`},e.underlinePlacement==="right"&&{"--unstable_TabList-underlineRight":"1px",paddingRight:1,boxShadow:`inset -1px 0 ${d.vars.palette.divider}`},e.underlinePlacement==="left"&&{"--unstable_TabList-underlineLeft":"1px",paddingLeft:1,boxShadow:`inset 1px 0 ${d.vars.palette.divider}`}),e.tabFlex&&{[`& .${Xxe.root}`]:{flex:e.tabFlex}})}),iPe=B.forwardRef(function(e,t){const s=qt({props:e,name:"JoyTabList"}),i=B.useContext(zW),{isRtl:n,orientation:r,getRootProps:a,contextValue:o}=Xge({rootRef:t}),{component:c="div",children:u,variant:h="plain",color:l="neutral",size:f,disableUnderline:p=!1,underlinePlacement:m=r==="horizontal"?"bottom":"right",tabFlex:g,sticky:y,slots:w={},slotProps:b={}}=s,S=at(s,ePe),C=W({},s,{isRtl:n,orientation:r,variant:h,color:l,size:f??i,sticky:y,tabFlex:g,nesting:!1,disableUnderline:p,underlinePlacement:m}),M=tPe(C),_=W({},S,{component:c,slots:w,slotProps:b}),[N,A]=Fe("root",{ref:t,elementType:sPe,getSlotProps:a,externalForwardedProps:_,ownerState:C,className:M.root});return P.jsx(N,W({},A,{children:P.jsx(Qge,{value:o,children:P.jsx(rg,{row:r==="horizontal",nested:!0,children:u})})}))});function nPe(d){return Rt("MuiTabs",d)}Dt("MuiTabs",["root","horizontal","vertical","colorPrimary","colorNeutral","colorDanger","colorSuccess","colorWarning","colorContext","variantPlain","variantOutlined","variantSoft","variantSolid","sizeSm","sizeMd","sizeLg"]);const rPe=["children","value","defaultValue","orientation","direction","component","onChange","selectionFollowsFocus","variant","color","size","slots","slotProps"],aPe=d=>{const{orientation:e,variant:t,color:s,size:i}=d,n={root:["root",e,t&&`variant${De(t)}`,s&&`color${De(s)}`,i&&`size${De(i)}`]};return Nt(n,nPe,{})},oPe=_e("div",{name:"JoyTabs",slot:"Root",overridesResolver:(d,e)=>e.root})(({ownerState:d,theme:e})=>{var t,s;const i=(t=e.variants[d.variant])==null?void 0:t[d.color],{bgcolor:n,backgroundColor:r,background:a,p:o,padding:c}=eu({theme:e,ownerState:d},["bgcolor","backgroundColor","background","p","padding"]),u=yh(e,`palette.${n}`)||n||yh(e,`palette.${r}`)||r||a||(i==null?void 0:i.backgroundColor)||(i==null?void 0:i.background)||e.vars.palette.background.surface;return W({},d.size==="sm"&&{"--Tabs-spacing":"0.75rem"},d.size==="md"&&{"--Tabs-spacing":"1rem"},d.size==="lg"&&{"--Tabs-spacing":"1.25rem"},{"--Tab-indicatorThickness":"2px","--Icon-color":d.color!=="neutral"||d.variant==="solid"?"currentColor":e.vars.palette.text.icon,"--TabList-stickyBackground":u==="transparent"?"initial":u,display:"flex",flexDirection:"column"},d.orientation==="vertical"&&{flexDirection:"row"},{backgroundColor:e.vars.palette.background.surface,position:"relative"},e.typography[`body-${d.size}`],(s=e.variants[d.variant])==null?void 0:s[d.color],o!==void 0&&{"--Tabs-padding":o},c!==void 0&&{"--Tabs-padding":c})}),dPe=B.forwardRef(function(e,t){const s=qt({props:e,name:"JoyTabs"}),{children:i,value:n,defaultValue:r,orientation:a="horizontal",direction:o="ltr",component:c,variant:u="plain",color:h="neutral",size:l="md",slots:f={},slotProps:p={}}=s,m=at(s,rPe),g=r||(n===void 0?0:void 0),{contextValue:y}=zge(W({},s,{orientation:a,defaultValue:g})),w=W({},s,{orientation:a,direction:o,variant:u,color:h,size:l}),b=aPe(w),S=W({},m,{component:c,slots:f,slotProps:p}),[v,C]=Fe("root",{ref:t,elementType:oPe,externalForwardedProps:S,additionalProps:{ref:t,as:c},ownerState:w,className:b.root});return P.jsx(v,W({},C,{children:P.jsx($ge,{value:y,children:P.jsx(zW.Provider,{value:l,children:i})})}))}),AI={Orders:"Orders",SmartTrades:"SmartTrades",StrategyLogs:"StrategyLogs"},xL=({value:d,onChange:e,children:t,actions:s})=>P.jsxs(P.Fragment,{children:[P.jsx(dPe,{value:d,onChange:(i,n)=>e(n),sx:{bgcolor:"transparent"},children:P.jsxs(iPe,{sx:{alignItems:"center"},children:[P.jsx(_I,{value:AI.Orders,sx:{borderTopLeftRadius:6,borderTopRightRadius:6},disableIndicator:!0,children:"Orders"}),P.jsx(_I,{value:AI.SmartTrades,sx:{borderTopLeftRadius:6,borderTopRightRadius:6},disableIndicator:!0,children:"Trades"}),P.jsx(_I,{value:AI.StrategyLogs,sx:{borderTopLeftRadius:6,borderTopRightRadius:6},disableIndicator:!0,children:"Strategy logs"}),P.jsx(Rc,{}),s?P.jsx(_t,{children:s}):null]})}),P.jsx(_t,{children:t})]}),cPe="SyncClosedOrdersButton",uPe={root:`${cPe}-root`},PL=d=>{const{className:e,polling:t}=d,{showSnackbar:s}=Tr(),{isLoading:i,mutate:n,mutateAsync:r}=kt.cron.syncClosedOrders.useMutation({onSuccess(){s("Orders have been synced")}});return B.useEffect(()=>{if(!t)return;const a=setInterval(()=>{r().then(o=>{console.log("response",o)})},15e3);return()=>{clearInterval(a)}},[t]),P.jsx(Es,{className:Gt(uPe.root,e),color:"neutral",loading:i,loadingPosition:"start",onClick:()=>{n()},size:"lg",variant:"outlined",children:"Sync orders"})};function hPe(d){return Rt("MuiAccordion",d)}const lPe=Dt("MuiAccordion",["root","expanded","disabled"]),IL=B.createContext({}),$W=B.createContext(void 0),fPe=["component","className","children","nested","sticky","variant","color","startAction","endAction","role","slots","slotProps"],pPe=d=>{const{sticky:e,nested:t,nesting:s,variant:i,color:n}=d,r={root:["root",t&&"nested",s&&"nesting",e&&"sticky",n&&`color${De(n)}`,i&&`variant${De(i)}`],startAction:["startAction"],endAction:["endAction"]};return Nt(r,BSe,{})},CL=_e("li")(({theme:d,ownerState:e})=>{var t;return[!e.nested&&{"--ListItemButton-marginInline":"calc(-1 * var(--ListItem-paddingLeft)) calc(-1 * var(--ListItem-paddingRight))","--ListItemButton-marginBlock":"calc(-1 * var(--ListItem-paddingY))",alignItems:"center",gap:"var(--ListItem-gap)",marginInline:"var(--ListItem-marginInline)"},e.nested&&{"--NestedList-marginRight":"calc(-1 * var(--ListItem-paddingRight))","--NestedList-marginLeft":"calc(-1 * var(--ListItem-paddingLeft))","--NestedListItem-paddingLeft":"calc(var(--ListItem-paddingLeft) + var(--List-nestedInsetStart))","--ListItemButton-marginBlock":"0px","--ListItemButton-marginInline":"calc(-1 * var(--ListItem-paddingLeft)) calc(-1 * var(--ListItem-paddingRight))","--ListItem-marginInline":"calc(-1 * var(--ListItem-paddingLeft)) calc(-1 * var(--ListItem-paddingRight))",flexDirection:"column"},W({"--unstable_actionRadius":"calc(var(--ListItem-radius) - var(--variant-borderWidth, 0px))"},e.startAction&&{"--unstable_startActionWidth":"2rem"},e.endAction&&{"--unstable_endActionWidth":"2.5rem"},{boxSizing:"border-box",borderRadius:"var(--ListItem-radius)",display:"var(--_ListItem-display)","&:not([hidden])":{"--_ListItem-display":"var(--_List-markerDisplay, flex)"},flex:"none",listStyleType:"var(--_List-markerType, disc)",position:"relative",paddingBlockStart:e.nested?0:"var(--ListItem-paddingY)",paddingBlockEnd:e.nested?0:"var(--ListItem-paddingY)",paddingInlineStart:"var(--ListItem-paddingLeft)",paddingInlineEnd:"var(--ListItem-paddingRight)"},e["data-first-child"]===void 0&&W({},e.row?{marginInlineStart:"var(--List-gap)"}:{marginBlockStart:"var(--List-gap)"}),e.row&&e.wrap&&{marginInlineStart:"var(--List-gap)",marginBlockStart:"var(--List-gap)"},{minBlockSize:"var(--ListItem-minHeight)"},e.sticky&&{position:"sticky",top:"var(--ListItem-stickyTop, 0px)",zIndex:1,background:`var(--ListItem-stickyBackground, ${d.vars.palette.background.body})`},{[`.${Bv.nested} > &`]:{"--_ListItem-display":"flex"}}),(t=d.variants[e.variant])==null?void 0:t[e.color]]}),mPe=_e(CL,{name:"JoyListItem",slot:"Root",overridesResolver:(d,e)=>e.root})({}),gPe=_e("div",{name:"JoyListItem",slot:"StartAction",overridesResolver:(d,e)=>e.startAction})(({ownerState:d})=>({display:"inherit",position:"absolute",top:d.nested?"calc(var(--ListItem-minHeight) / 2)":"50%",left:0,transform:"translate(var(--ListItem-startActionTranslateX), -50%)",zIndex:1})),yPe=_e("div",{name:"JoyListItem",slot:"StartAction",overridesResolver:(d,e)=>e.startAction})(({ownerState:d})=>({display:"inherit",position:"absolute",top:d.nested?"calc(var(--ListItem-minHeight) / 2)":"50%",right:0,transform:"translate(var(--ListItem-endActionTranslateX), -50%)"})),Er=B.forwardRef(function(e,t){const s=qt({props:e,name:"JoyListItem"}),i=B.useContext(IO),n=B.useContext(mL),r=B.useContext(Sf),a=B.useContext(uW),o=B.useContext(Lv),{component:c,className:u,children:h,nested:l=!1,sticky:f=!1,variant:p="plain",color:m="neutral",startAction:g,endAction:y,role:w,slots:b={},slotProps:S={}}=s,v=at(s,fPe),[C,M]=B.useState(""),[_,N]=(n==null?void 0:n.split(":"))||["",""],A=c||(_&&!_.match(/^(ul|ol|menu)$/)?"div":void 0);let R=i==="menu"?"none":void 0;n&&(R={menu:"none",menubar:"none",group:"presentation"}[N]),w&&(R=w);const D=W({},s,{sticky:f,startAction:g,endAction:y,row:r,wrap:a,variant:p,color:m,nesting:o,nested:l,component:A,role:R}),U=pPe(D),K=W({},v,{component:A,slots:b,slotProps:S}),[j,z]=Fe("root",{additionalProps:{role:R},ref:t,className:Gt(U.root,u),elementType:mPe,externalForwardedProps:K,ownerState:D}),[J,Y]=Fe("startAction",{className:U.startAction,elementType:gPe,externalForwardedProps:K,ownerState:D}),[X,Z]=Fe("endAction",{className:U.endAction,elementType:yPe,externalForwardedProps:K,ownerState:D});return P.jsx($W.Provider,{value:M,children:P.jsx(Lv.Provider,{value:l?C||!0:!1,children:P.jsxs(j,W({},z,{children:[g&&P.jsx(J,W({},Y,{children:g})),B.Children.map(h,(te,Q)=>{var ie;return B.isValidElement(te)?B.cloneElement(te,W({},Q===0&&{"data-first-child":""},lf(te,["ListItem"])&&{component:((ie=te.props)==null?void 0:ie.component)||"div"})):te}),y&&P.jsx(X,W({},Z,{children:y}))]}))})})});Er.muiName="ListItem";function wPe(d){return Rt("MuiAccordionDetails",d)}const hh=Dt("MuiAccordionDetails",["root","content","expanded"]),bPe=["accordionId","component","color","children","defaultExpanded","disabled","expanded","onChange","variant","slots","slotProps"],kPe=d=>{const{variant:e,color:t,expanded:s,disabled:i}=d,n={root:["root",s&&"expanded",i&&"disabled",t&&`color${De(t)}`,e&&`variant${De(e)}`]};return Nt(n,hPe,{})},SPe=_e(CL,{name:"JoyAccordion",slot:"Root",overridesResolver:(d,e)=>e.root})({borderBottom:"var(--Accordion-borderBottom)","&[data-first-child]":{"--ListItem-radius":"var(--unstable_List-childRadius) var(--unstable_List-childRadius) 0 0"},"&[data-last-child]":{"--ListItem-radius":"0 0 var(--unstable_List-childRadius) var(--unstable_List-childRadius)",'& [aria-expanded="true"]':{"--ListItem-radius":"0"},[`& .${hh.root}`]:{"--AccordionDetails-radius":"0 0 var(--unstable_List-childRadius) var(--unstable_List-childRadius)"}},"&:not([data-first-child]):not([data-last-child])":{"--ListItem-radius":"0"}}),vPe=B.forwardRef(function(e,t){const s=qt({props:e,name:"JoyAccordion"}),{accordionId:i,component:n="div",color:r="neutral",children:a,defaultExpanded:o=!1,disabled:c=!1,expanded:u,onChange:h,variant:l="plain",slots:f={},slotProps:p={}}=s,m=at(s,bPe),g=ln(i),[y,w]=ch({controlled:u,default:o,name:"Accordion",state:"expanded"}),b=B.useCallback(A=>{w(!y),h&&h(A,!y)},[y,h,w]),S=B.useMemo(()=>({accordionId:g,expanded:y,disabled:c,toggle:b}),[g,y,c,b]),v=W({},m,{component:n,slots:f,slotProps:p}),C=W({},s,{component:n,color:r,variant:l,expanded:y,disabled:c,nested:!0}),M=kPe(C),[_,N]=Fe("root",{ref:t,className:M.root,elementType:SPe,externalForwardedProps:v,ownerState:C});return P.jsx(IL.Provider,{value:S,children:P.jsx(_,W({},N,{children:B.Children.map(a,(A,R)=>B.isValidElement(A)&&R===0?B.cloneElement(A,{"data-first-child":""}):A)}))})});function TPe(d){return Rt("MuiAccordionGroup",d)}Dt("MuiAccordionGroup",["root","colorPrimary","colorNeutral","colorDanger","colorSuccess","colorWarning","colorContext","variantPlain","variantOutlined","variantSoft","variantSolid","sizeSm","sizeMd","sizeLg"]);const OPe=["component","color","children","disableDivider","variant","transition","size","slots","slotProps"],xPe=d=>{const{variant:e,color:t,size:s}=d,i={root:["root",e&&`variant${De(e)}`,t&&`color${De(t)}`,s&&`size${De(s)}`]};return Nt(i,TPe,{})},PPe=_e(ag,{name:"JoyAccordionGroup",slot:"Root",overridesResolver:(d,e)=>e.root})(({theme:d,ownerState:e})=>{let t={};return e.transition&&(typeof e.transition=="string"&&(t={"--AccordionDetails-transition":`grid-template-rows ${e.transition}, padding-block ${e.transition}`}),typeof e.transition=="object"&&(t={"--AccordionDetails-transition":`grid-template-rows ${e.transition.initial}, padding-block ${e.transition.initial}`,[`& .${hh.root}.${hh.expanded}`]:{"--AccordionDetails-transition":`grid-template-rows ${e.transition.expanded}, padding-block ${e.transition.expanded}`}})),W({"--List-padding":"0px","--ListDivider-gap":"0px"},t,!e.disableDivider&&{[`& .${lPe.root}:not([data-last-child])`]:{"--Accordion-borderBottom":`1px solid ${d.vars.palette.divider}`}})}),IPe=B.forwardRef(function(e,t){const s=qt({props:e,name:"JoyAccordionGroup"}),{component:i="div",color:n="neutral",children:r,disableDivider:a=!1,variant:o="plain",transition:c="0.2s ease",size:u="md",slots:h={},slotProps:l={}}=s,f=at(s,OPe),p=W({},f,{component:i,slots:h,slotProps:l}),m=W({},s,{component:i,color:n,disableDivider:a,variant:o,transition:c,size:u}),g=xPe(m),[y,w]=Fe("root",{ref:t,className:g.root,elementType:PPe,externalForwardedProps:p,ownerState:m});return P.jsx(y,W({},w,{children:P.jsx(rg,{children:r})}))});function CPe(d){return Rt("MuiAccordionSummary",d)}const AO=Dt("MuiAccordionSummary",["root","button","indicator","disabled","expanded"]),MPe=kf(P.jsx("path",{d:"M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z"}),"KeyboardArrowDown");var e5;const _Pe=["component","color","children","indicator","variant","slots","slotProps"],APe=d=>{const{disabled:e,expanded:t}=d;return Nt({root:["root",e&&"disabled",t&&"expanded"],button:["button",e&&"disabled",t&&"expanded"],indicator:["indicator",e&&"disabled",t&&"expanded"]},CPe,{})},LPe=_e(CL,{name:"JoyAccordionSummary",slot:"Root",overridesResolver:(d,e)=>e.root})(({theme:d})=>({fontWeight:d.vars.fontWeight.md,gap:"calc(var(--ListItem-paddingX, 0.75rem) + 0.25rem)",[`&.${AO.expanded}`]:{"--Icon-color":"currentColor"}})),BPe=_e(og,{name:"JoyAccordionSummary",slot:"Button",overridesResolver:(d,e)=>e.button})({gap:"inherit",fontWeight:"inherit",justifyContent:"space-between",font:"inherit","&:focus-visible":{zIndex:1},[`.${AO.root} &`]:{"--unstable_ListItem-flex":"1 0 0%"}}),NPe=_e("span",{name:"JoyAccordionSummary",slot:"Indicator",overridesResolver:(d,e)=>e.indicator})({display:"inline-flex",[`&.${AO.expanded}`]:{transform:"rotate(180deg)"}}),EPe=B.forwardRef(function(e,t){const s=qt({props:e,name:"JoyAccordionSummary"}),{component:i="div",color:n="neutral",children:r,indicator:a=e5||(e5=P.jsx(MPe,{})),variant:o="plain",slots:c={},slotProps:u={}}=s,h=at(s,_Pe),{accordionId:l,disabled:f=!1,expanded:p=!1,toggle:m}=B.useContext(IL),g=W({},h,{component:i,slots:c,slotProps:u}),y=W({},s,{component:i,color:n,disabled:f,expanded:p,variant:o}),w=A=>{if(m&&m(A),typeof u.button=="function"){var R,D;(R=u.button(y))==null||(D=R.onClick)==null||D.call(R,A)}else{var U,K;(U=u.button)==null||(K=U.onClick)==null||K.call(U,A)}},b=APe(y),[S,v]=Fe("root",{ref:t,className:b.root,elementType:LPe,externalForwardedProps:g,ownerState:y}),[C,M]=Fe("button",{ref:t,className:b.button,elementType:BPe,externalForwardedProps:g,additionalProps:{component:"button",id:`${l}-summary`,"aria-expanded":p?"true":"false","aria-controls":`${l}-details`,disabled:f,type:"button",onClick:w},ownerState:y}),[_,N]=Fe("indicator",{ref:t,className:b.indicator,elementType:NPe,externalForwardedProps:g,ownerState:y});return P.jsx(S,W({},v,{children:P.jsxs(C,W({},M,{children:[r,a&&P.jsx(_,W({},N,{children:a}))]}))}))}),RPe=["component","children","color","variant","slots","slotProps"],DPe=d=>{const{expanded:e}=d;return Nt({root:["root",e&&"expanded"],content:["content",e&&"expanded"]},wPe,{})},qPe=_e("div",{name:"JoyAccordionDetails",slot:"Root",overridesResolver:(d,e)=>e.root})(({ownerState:d,theme:e})=>{var t;return W({overflow:"hidden",borderRadius:"var(--AccordionDetails-radius)",display:"grid",gridTemplateRows:"1fr",marginInline:"calc(-1 * var(--ListItem-paddingLeft)) calc(-1 * var(--ListItem-paddingRight))",transition:"var(--AccordionDetails-transition)"},(t=e.variants[d.variant])==null?void 0:t[d.color],{[`&:not(.${hh.expanded})`]:{gridTemplateRows:"0fr"}})}),VPe=_e("div",{name:"JoyAccordionDetails",slot:"Content",overridesResolver:(d,e)=>e.root})({display:"flex",flexDirection:"column",overflow:"hidden",paddingInlineStart:"var(--ListItem-paddingLeft)",paddingInlineEnd:"var(--ListItem-paddingRight)",paddingBlockStart:"calc(var(--ListItem-paddingY) / 2)",paddingBlockEnd:"calc(2.5 * var(--ListItem-paddingY))",transition:"var(--AccordionDetails-transition)",[`&:not(.${hh.expanded})`]:{paddingBlock:0}}),FPe=B.forwardRef(function(e,t){const s=qt({props:e,name:"JoyAccordionDetails"}),{component:i="div",children:n,color:r="neutral",variant:a="plain",slots:o={},slotProps:c={}}=s,u=at(s,RPe),{accordionId:h,expanded:l=!1}=B.useContext(IL),f=B.useRef(null),p=Cs(f,t);B.useEffect(()=>{f.current&&f.current.querySelectorAll('a, button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])').forEach(M=>{if(l){const _=M.getAttribute("data-prev-tabindex"),N=M.getAttribute("tabindex");N&&_&&(M.setAttribute("tabindex",_),M.removeAttribute("data-prev-tabindex")),!_&&!N&&M.removeAttribute("tabindex")}else M.setAttribute("data-prev-tabindex",M.getAttribute("tabindex")||""),M.setAttribute("tabindex","-1")})},[l]);const m=W({},u,{component:i,slots:o,slotProps:c}),g=W({},s,{component:i,color:r,variant:a,expanded:l,nesting:!0}),y=DPe(g),[w,b]=Fe("root",{ref:p,className:y.root,elementType:qPe,externalForwardedProps:m,additionalProps:{id:`${h}-details`,"aria-labelledby":`${h}-summary`,role:"region",hidden:l?void 0:!0},ownerState:g}),[S,v]=Fe("content",{className:y.content,elementType:VPe,externalForwardedProps:m,ownerState:g});return P.jsx(w,W({},b,{children:P.jsx(S,W({},v,{children:n}))}))}),ML=({children:d})=>P.jsx(IPe,{size:"lg",sx:e=>({mx:-2,mb:-2,borderRadius:"md",[`& .${AO.button}`]:{color:e.vars.palette.text.tertiary},[`& .${hh.root}`]:{backgroundColor:"transparent",color:e.vars.palette.text.primary,border:0},[`& .${hh.content}`]:{gap:"0.75rem",[`&.${hh.expanded}`]:{paddingBlock:"0.75rem"}}}),transition:"0.2s",variant:"plain",children:P.jsxs(vPe,{children:[P.jsx(EPe,{children:"More actions"}),P.jsx(FPe,{variant:"soft",children:d})]})}),HPe="RunBotTemplateButton",GPe={root:`${HPe}-root`},_L=d=>{const{className:e,bot:t}=d,{showSnackbar:s}=Tr(),{isLoading:i,mutate:n}=kt.bot.manualProcess.useMutation({onSuccess(){s("Bot template executed")}});return P.jsx(Es,{className:Gt(GPe.root,e),color:"neutral",loading:i,loadingPosition:"start",onClick:()=>{n({botId:t.id})},size:"lg",variant:"outlined",children:"Run template"})},UPe="StartStopBotButton",LI={root:`${UPe}-root`},AL=({className:d,bot:e})=>{const{showSnackbar:t}=Tr(),s=kt.useUtils(),i=()=>{s.gridBot.getOne.invalidate(e.id),s.dcaBot.getOne.invalidate(e.id),s.bot.getOne.invalidate(e.id),s.order.openOrders.invalidate({botId:e.id}),s.order.closedOrders.invalidate({botId:e.id}),s.order.infiniteOrders.invalidate({botId:e.id}),s.bot.activeSmartTrades.invalidate({botId:e.id}),s.bot.completedSmartTrades.invalidate({botId:e.id}),s.bot.getBotLogs.invalidate({botId:e.id}),s.smartTrade.infiniteList.invalidate({botId:e.id})},n=kt.bot.start.useMutation({onSuccess(){i(),t("Bot has been enabled")}}),r=kt.bot.stop.useMutation({onSuccess(){i(),t("Bot has been stopped")}});return n.isLoading||r.isLoading?P.jsx(Es,{className:Gt(LI.root,d),color:n.isLoading?"success":"danger",loading:!0,loadingPosition:"start",size:"lg",variant:"soft",children:n.isLoading?"Starting...":"Stopping..."}):e.enabled?P.jsx(Es,{className:Gt(LI.root,d),color:"danger",onClick:()=>{r.mutate({botId:e.id})},size:"lg",variant:"soft",children:"Stop bot"}):P.jsx(Es,{className:Gt(LI.root,d),color:"success",onClick:()=>{n.mutate({botId:e.id})},size:"lg",variant:"soft",children:"Start bot"})},LL=({bot:d,href:e})=>{const{showSnackbar:t}=Tr();return d.enabled?P.jsx(Es,{onClick:()=>t("Bot is currently running. Stop it first to edit.",{color:"warning",autoHideDuration:3e3}),size:"lg",color:"neutral",variant:"solid",children:"Edit"}):P.jsx(Es,{component:Uo,href:e,size:"lg",color:"neutral",variant:"solid",children:"Edit"})},WPe="DeleteBotButton",t5={root:`${WPe}-root`},BL=({className:d,bot:e,redirectPath:t})=>{const s=Zc(),{showSnackbar:i}=Tr(),{showConfirmDialog:n}=NU(),r=kt.useUtils(),a=()=>{r.bot.list.invalidate(),r.gridBot.list.invalidate()},o=kt.bot.delete.useMutation({onSuccess(){a(),i("Bot has been deleted"),setTimeout(()=>{s({to:t})},1500)}});return o.isLoading?P.jsx(Es,{className:Gt(t5.root,d),color:"danger",loading:!0,loadingPosition:"start",size:"lg",variant:"soft",children:"Deleting..."}):P.jsx(Es,{className:Gt(t5.root,d),color:"danger",loading:o.isLoading,loadingPosition:"start",onClick:()=>{n("Are you sure you want to delete the bot? All orders and profit history will be deleted as well.",()=>{o.mutate({botId:e.id})},{confirmText:"Delete",confirmButtonColor:"danger",confirmButtonVariant:"outlined"})},size:"lg",variant:"soft",children:"Delete bot"})},NL=({children:d})=>P.jsx(P.Fragment,{children:d}),EL=Ys(P.jsx("path",{d:"M4 7v2c0 .55-.45 1-1 1H2v4h1c.55 0 1 .45 1 1v2c0 1.65 1.35 3 3 3h3v-2H7c-.55 0-1-.45-1-1v-2c0-1.3-.84-2.42-2-2.83v-.34C5.16 11.42 6 10.3 6 9V7c0-.55.45-1 1-1h3V4H7C5.35 4 4 5.35 4 7m17 3c-.55 0-1-.45-1-1V7c0-1.65-1.35-3-3-3h-3v2h3c.55 0 1 .45 1 1v2c0 1.3.84 2.42 2 2.83v.34c-1.16.41-2 1.52-2 2.83v2c0 .55-.45 1-1 1h-3v2h3c1.65 0 3-1.35 3-3v-2c0-.55.45-1 1-1h1v-4z"}),"DataObject"),jPe=Ys(P.jsx("path",{d:"m20 12-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8z"}),"ArrowDownward"),KW=Ys(P.jsx("path",{d:"m4 12 1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8z"}),"ArrowUpward"),zPe=Ys(P.jsx("path",{d:"M18 17h2v.5h-1v1h1v.5h-2v1h3v-4h-3zm1-9h1V4h-2v1h1zm-1 3h1.8L18 13.1v.9h3v-1h-1.8l1.8-2.1V10h-3zM2 5h14v2H2zm0 12h14v2H2zm0-6h14v2H2z"}),"FormatListNumberedRtl"),$Pe=Ys(P.jsx("path",{d:"m20.5 10 .5-2h-4l1-4h-2l-1 4h-4l1-4h-2L9 8H5l-.5 2h4l-1 4h-4L3 16h4l-1 4h2l1-4h4l-1 4h2l1-4h4l.5-2h-4l1-4zm-7 4h-4l1-4h4z"}),"Numbers"),KPe=Ys(P.jsx("path",{d:"M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2"}),"Circle"),XPe="BotStatusChip",m1={root:`${XPe}-root`},BI=_e(nn)(()=>({[`&.${m1.root}`]:{}})),QPe=d=>{const{className:e,bot:t,sx:s,size:i}=d,{showSnackbar:n}=Tr(),r=kt.useUtils(),a=()=>{r.gridBot.getOne.invalidate(t.id),r.bot.getOne.invalidate(t.id),r.bot.activeSmartTrades.invalidate({botId:t.id}),r.bot.completedSmartTrades.invalidate({botId:t.id})},o=kt.bot.start.useMutation({onSuccess(){a(),n("Bot has been enabled")}}),c=kt.bot.stop.useMutation({onSuccess(){a(),n("Bot has been stopped")}});return o.isLoading||c.isLoading?P.jsx(BI,{className:Gt(m1.root,e),disabled:!0,size:i,startDecorator:P.jsx(Dl,{}),sx:s,variant:"outlined",children:o.isLoading?"Starting...":"Stopping..."}):t.enabled?P.jsx(BI,{className:Gt(m1.root,e),color:"success",onClick:()=>{c.mutate({botId:t.id})},size:i,startDecorator:P.jsx(Dl,{}),sx:s,variant:"outlined",children:"Running"}):P.jsx(BI,{className:Gt(m1.root,e),color:"danger",onClick:()=>{o.mutate({botId:t.id})},size:i,startDecorator:P.jsx(Dl,{}),sx:s,variant:"outlined",children:"Disabled"})},RL=({bot:d})=>P.jsxs(Er,{children:[P.jsx(qh,{children:P.jsx(KPe,{})}),P.jsx(to,{children:"Status"}),P.jsx(QPe,{bot:d,size:"lg"})]}),YPe=Ys(P.jsx("path",{d:"M17.06 11.57c.59-.69.94-1.59.94-2.57 0-1.86-1.27-3.43-3-3.87V3h-2v2h-2V3H9v2H6v2h2v10H6v2h3v2h2v-2h2v2h2v-2c2.21 0 4-1.79 4-4 0-1.45-.78-2.73-1.94-3.43M10 7h4c1.1 0 2 .9 2 2s-.9 2-2 2h-4zm5 10h-5v-4h5c1.1 0 2 .9 2 2s-.9 2-2 2"}),"CurrencyBitcoin"),ZPe="CryptoIcon",JPe="https://meta.viewblock.io",DL=({symbol:d,size:e=32})=>P.jsx("img",{alt:d,height:e,src:`${JPe}/${d}/logo`,width:e});DL.displayName=ZPe;const qL=({bot:d})=>{const{baseCurrency:e}=Kd(d.symbol);return P.jsxs(Er,{children:[P.jsx(qh,{children:P.jsx(YPe,{})}),P.jsx(to,{children:"Pair"}),P.jsxs(_t,{alignItems:"center",display:"flex",children:[P.jsx(DL,{size:20,symbol:e}),P.jsx(ot,{sx:{ml:1},textColor:"text.tertiary",children:d.symbol})]})]})},Id=({icon:d,name:e,children:t})=>P.jsxs(Er,{children:[P.jsx(qh,{children:d}),P.jsx(to,{children:e}),P.jsx(ot,{textColor:"text.tertiary",children:t})]}),eIe=({bot:d})=>{const e=UW(d.settings.gridLines),t=GW(d.settings.gridLines),s=HW(d.settings.gridLines),{baseCurrency:i,quoteCurrency:n}=Kd(d.symbol);return P.jsxs(Dh,{children:[P.jsx(RL,{bot:d}),P.jsx(fr,{inset:"startContent"}),P.jsx(qL,{bot:d}),P.jsx(fr,{inset:"startContent"}),P.jsxs(Id,{icon:P.jsx(KW,{}),name:"High price",children:[t," ",n]}),P.jsx(fr,{inset:"startContent"}),P.jsxs(Id,{icon:P.jsx(jPe,{}),name:"Low price",children:[e," ",n]}),P.jsx(fr,{inset:"startContent"}),P.jsxs(Id,{icon:P.jsx($Pe,{}),name:"Av. quantity per grid",children:[s.toFixed(6)," ",i]}),P.jsx(fr,{inset:"startContent"}),P.jsx(Id,{icon:P.jsx(zPe,{}),name:"Grid levels",children:d.settings.gridLines.length}),P.jsx(fr,{inset:"startContent"}),P.jsx(Id,{icon:P.jsx(EL,{}),name:"Template",children:P.jsx(nn,{color:"primary",variant:"soft",children:d.template})})]})},tIe=({botId:d})=>{const[e]=kt.gridBot.getOne.useSuspenseQuery(d),[t]=go();return P.jsxs(fn,{children:[P.jsxs(_t,{display:"flex",justifyContent:"space-between",children:[P.jsx(ot,{fontSize:"xl2",fontWeight:"xl",level:"h3",children:e.name}),P.jsxs(ot,{color:"neutral",fontSize:"xl2",fontWeight:"xl",level:"h3",children:["#",e.id]})]}),P.jsx(eIe,{bot:e}),P.jsx(NL,{children:P.jsx(AL,{bot:e})}),P.jsxs(ML,{children:[P.jsx(LL,{bot:e,href:ai("grid-bot/edit/:id",e.id)}),P.jsx(BL,{bot:e,redirectPath:ai("bot")}),t?P.jsxs(P.Fragment,{children:[P.jsx(Ia,{children:"Debugging"}),P.jsx(PL,{polling:!1}),P.jsx(_L,{bot:e})]}):null]})]})};var sIe=typeof Sc=="object"&&Sc&&Sc.Object===Object&&Sc,iIe=typeof self=="object"&&self&&self.Object===Object&&self;sIe||iIe||Function("return this")();function nIe(){const d=B.useRef(!1);return B.useEffect(()=>(d.current=!0,()=>{d.current=!1}),[]),B.useCallback(()=>d.current,[])}var s5={width:void 0,height:void 0};function rIe(d){const{ref:e,box:t="content-box"}=d,[{width:s,height:i},n]=B.useState(s5),r=nIe(),a=B.useRef({...s5}),o=B.useRef(void 0);return o.current=d.onResize,B.useEffect(()=>{if(!e.current||typeof window>"u"||!("ResizeObserver"in window))return;const c=new ResizeObserver(([u])=>{const h=t==="border-box"?"borderBoxSize":t==="device-pixel-content-box"?"devicePixelContentBoxSize":"contentBoxSize",l=i5(u,h,"inlineSize"),f=i5(u,h,"blockSize");if(a.current.width!==l||a.current.height!==f){const m={width:l,height:f};a.current.width=l,a.current.height=f,o.current?o.current(m):r()&&n(m)}});return c.observe(e.current,{box:t}),()=>{c.disconnect()}},[t,e,r]),{width:s,height:i}}function i5(d,e,t){return d[e]?Array.isArray(d[e])?d[e][0][t]:d[e][t]:e==="contentBoxSize"?d.contentRect[t==="inlineSize"?"width":"height"]:void 0}function li(d){var e=d.width,t=d.height;if(e<0)throw new Error("Negative width is not allowed for Size");if(t<0)throw new Error("Negative height is not allowed for Size");return{width:e,height:t}}function ql(d,e){return d.width===e.width&&d.height===e.height}var aIe=function(){function d(e){var t=this;this._resolutionListener=function(){return t._onResolutionChanged()},this._resolutionMediaQueryList=null,this._observers=[],this._window=e,this._installResolutionListener()}return d.prototype.dispose=function(){this._uninstallResolutionListener(),this._window=null},Object.defineProperty(d.prototype,"value",{get:function(){return this._window.devicePixelRatio},enumerable:!1,configurable:!0}),d.prototype.subscribe=function(e){var t=this,s={next:e};return this._observers.push(s),{unsubscribe:function(){t._observers=t._observers.filter(function(i){return i!==s})}}},d.prototype._installResolutionListener=function(){if(this._resolutionMediaQueryList!==null)throw new Error("Resolution listener is already installed");var e=this._window.devicePixelRatio;this._resolutionMediaQueryList=this._window.matchMedia("all and (resolution: ".concat(e,"dppx)")),this._resolutionMediaQueryList.addListener(this._resolutionListener)},d.prototype._uninstallResolutionListener=function(){this._resolutionMediaQueryList!==null&&(this._resolutionMediaQueryList.removeListener(this._resolutionListener),this._resolutionMediaQueryList=null)},d.prototype._reinstallResolutionListener=function(){this._uninstallResolutionListener(),this._installResolutionListener()},d.prototype._onResolutionChanged=function(){var e=this;this._observers.forEach(function(t){return t.next(e._window.devicePixelRatio)}),this._reinstallResolutionListener()},d}();function oIe(d){return new aIe(d)}var dIe=function(){function d(e,t,s){var i;this._canvasElement=null,this._bitmapSizeChangedListeners=[],this._suggestedBitmapSize=null,this._suggestedBitmapSizeChangedListeners=[],this._devicePixelRatioObservable=null,this._canvasElementResizeObserver=null,this._canvasElement=e,this._canvasElementClientSize=li({width:this._canvasElement.clientWidth,height:this._canvasElement.clientHeight}),this._transformBitmapSize=t??function(n){return n},this._allowResizeObserver=(i=s==null?void 0:s.allowResizeObserver)!==null&&i!==void 0?i:!0,this._chooseAndInitObserver()}return d.prototype.dispose=function(){var e,t;if(this._canvasElement===null)throw new Error("Object is disposed");(e=this._canvasElementResizeObserver)===null||e===void 0||e.disconnect(),this._canvasElementResizeObserver=null,(t=this._devicePixelRatioObservable)===null||t===void 0||t.dispose(),this._devicePixelRatioObservable=null,this._suggestedBitmapSizeChangedListeners.length=0,this._bitmapSizeChangedListeners.length=0,this._canvasElement=null},Object.defineProperty(d.prototype,"canvasElement",{get:function(){if(this._canvasElement===null)throw new Error("Object is disposed");return this._canvasElement},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"canvasElementClientSize",{get:function(){return this._canvasElementClientSize},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"bitmapSize",{get:function(){return li({width:this.canvasElement.width,height:this.canvasElement.height})},enumerable:!1,configurable:!0}),d.prototype.resizeCanvasElement=function(e){this._canvasElementClientSize=li(e),this.canvasElement.style.width="".concat(this._canvasElementClientSize.width,"px"),this.canvasElement.style.height="".concat(this._canvasElementClientSize.height,"px"),this._invalidateBitmapSize()},d.prototype.subscribeBitmapSizeChanged=function(e){this._bitmapSizeChangedListeners.push(e)},d.prototype.unsubscribeBitmapSizeChanged=function(e){this._bitmapSizeChangedListeners=this._bitmapSizeChangedListeners.filter(function(t){return t!==e})},Object.defineProperty(d.prototype,"suggestedBitmapSize",{get:function(){return this._suggestedBitmapSize},enumerable:!1,configurable:!0}),d.prototype.subscribeSuggestedBitmapSizeChanged=function(e){this._suggestedBitmapSizeChangedListeners.push(e)},d.prototype.unsubscribeSuggestedBitmapSizeChanged=function(e){this._suggestedBitmapSizeChangedListeners=this._suggestedBitmapSizeChangedListeners.filter(function(t){return t!==e})},d.prototype.applySuggestedBitmapSize=function(){if(this._suggestedBitmapSize!==null){var e=this._suggestedBitmapSize;this._suggestedBitmapSize=null,this._resizeBitmap(e),this._emitSuggestedBitmapSizeChanged(e,this._suggestedBitmapSize)}},d.prototype._resizeBitmap=function(e){var t=this.bitmapSize;ql(t,e)||(this.canvasElement.width=e.width,this.canvasElement.height=e.height,this._emitBitmapSizeChanged(t,e))},d.prototype._emitBitmapSizeChanged=function(e,t){var s=this;this._bitmapSizeChangedListeners.forEach(function(i){return i.call(s,e,t)})},d.prototype._suggestNewBitmapSize=function(e){var t=this._suggestedBitmapSize,s=li(this._transformBitmapSize(e,this._canvasElementClientSize)),i=ql(this.bitmapSize,s)?null:s;t===null&&i===null||t!==null&&i!==null&&ql(t,i)||(this._suggestedBitmapSize=i,this._emitSuggestedBitmapSizeChanged(t,i))},d.prototype._emitSuggestedBitmapSizeChanged=function(e,t){var s=this;this._suggestedBitmapSizeChangedListeners.forEach(function(i){return i.call(s,e,t)})},d.prototype._chooseAndInitObserver=function(){var e=this;if(!this._allowResizeObserver){this._initDevicePixelRatioObservable();return}uIe().then(function(t){return t?e._initResizeObserver():e._initDevicePixelRatioObservable()})},d.prototype._initDevicePixelRatioObservable=function(){var e=this;if(this._canvasElement!==null){var t=n5(this._canvasElement);if(t===null)throw new Error("No window is associated with the canvas");this._devicePixelRatioObservable=oIe(t),this._devicePixelRatioObservable.subscribe(function(){return e._invalidateBitmapSize()}),this._invalidateBitmapSize()}},d.prototype._invalidateBitmapSize=function(){var e,t;if(this._canvasElement!==null){var s=n5(this._canvasElement);if(s!==null){var i=(t=(e=this._devicePixelRatioObservable)===null||e===void 0?void 0:e.value)!==null&&t!==void 0?t:s.devicePixelRatio,n=this._canvasElement.getClientRects(),r=n[0]!==void 0?hIe(n[0],i):li({width:this._canvasElementClientSize.width*i,height:this._canvasElementClientSize.height*i});this._suggestNewBitmapSize(r)}}},d.prototype._initResizeObserver=function(){var e=this;this._canvasElement!==null&&(this._canvasElementResizeObserver=new ResizeObserver(function(t){var s=t.find(function(r){return r.target===e._canvasElement});if(!(!s||!s.devicePixelContentBoxSize||!s.devicePixelContentBoxSize[0])){var i=s.devicePixelContentBoxSize[0],n=li({width:i.inlineSize,height:i.blockSize});e._suggestNewBitmapSize(n)}}),this._canvasElementResizeObserver.observe(this._canvasElement,{box:"device-pixel-content-box"}))},d}();function cIe(d,e){if(e.type==="device-pixel-content-box")return new dIe(d,e.transform,e.options);throw new Error("Unsupported binding target")}function n5(d){return d.ownerDocument.defaultView}function uIe(){return new Promise(function(d){var e=new ResizeObserver(function(t){d(t.every(function(s){return"devicePixelContentBoxSize"in s})),e.disconnect()});e.observe(document.body,{box:"device-pixel-content-box"})}).catch(function(){return!1})}function hIe(d,e){return li({width:Math.round(d.left*e+d.width*e)-Math.round(d.left*e),height:Math.round(d.top*e+d.height*e)-Math.round(d.top*e)})}var lIe=function(){function d(e,t,s){if(t.width===0||t.height===0)throw new TypeError("Rendering target could only be created on a media with positive width and height");if(this._mediaSize=t,s.width===0||s.height===0)throw new TypeError("Rendering target could only be created using a bitmap with positive integer width and height");this._bitmapSize=s,this._context=e}return d.prototype.useMediaCoordinateSpace=function(e){try{return this._context.save(),this._context.setTransform(1,0,0,1,0,0),this._context.scale(this._horizontalPixelRatio,this._verticalPixelRatio),e({context:this._context,mediaSize:this._mediaSize})}finally{this._context.restore()}},d.prototype.useBitmapCoordinateSpace=function(e){try{return this._context.save(),this._context.setTransform(1,0,0,1,0,0),e({context:this._context,mediaSize:this._mediaSize,bitmapSize:this._bitmapSize,horizontalPixelRatio:this._horizontalPixelRatio,verticalPixelRatio:this._verticalPixelRatio})}finally{this._context.restore()}},Object.defineProperty(d.prototype,"_horizontalPixelRatio",{get:function(){return this._bitmapSize.width/this._mediaSize.width},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"_verticalPixelRatio",{get:function(){return this._bitmapSize.height/this._mediaSize.height},enumerable:!1,configurable:!0}),d}();function tf(d,e){var t=d.canvasElementClientSize;if(t.width===0||t.height===0)return null;var s=d.bitmapSize;if(s.width===0||s.height===0)return null;var i=d.canvasElement.getContext("2d",e);return i===null?null:new lIe(i,t,s)}/*! + `),e.vars.palette.background.level3,oxe),({ownerState:d,theme:e})=>{var t,s,i,n;const r=((t=e.components)==null||(t=t.JoyTypography)==null||(t=t.defaultProps)==null?void 0:t.level)||"body1";return[{display:"block",position:"relative","--unstable_pseudo-zIndex":9,"--unstable_pulse-bg":e.vars.palette.background.level1,overflow:"hidden",cursor:"default",color:"transparent","& *":{visibility:"hidden"},"&::before":{display:"block",content:'" "',top:0,bottom:0,left:0,right:0,zIndex:"var(--unstable_pseudo-zIndex)",borderRadius:"inherit"},[e.getColorSchemeSelector("dark")]:{"--unstable_wave-bg":"rgba(255 255 255 / 0.1)"}},d.variant==="rectangular"&&W({borderRadius:"min(0.15em, 6px)",height:"auto",width:"100%","&::before":{position:"absolute"}},!d.animation&&{backgroundColor:e.vars.palette.background.level3},d.level!=="inherit"&&W({},e.typography[d.level])),d.variant==="circular"&&W({borderRadius:"50%",width:"100%",height:"100%","&::before":{position:"absolute"}},!d.animation&&{backgroundColor:e.vars.palette.background.level3},d.level!=="inherit"&&W({},e.typography[d.level])),d.variant==="text"&&W({borderRadius:"min(0.15em, 6px)",background:"transparent",width:"100%"},d.level!=="inherit"&&W({},e.typography[d.level||r],{paddingBlockStart:`calc((${((s=e.typography[d.level||r])==null?void 0:s.lineHeight)||1} - 1) * 0.56em)`,paddingBlockEnd:`calc((${((i=e.typography[d.level||r])==null?void 0:i.lineHeight)||1} - 1) * 0.44em)`,"&::before":W({height:"1em"},e.typography[d.level||r],d.animation==="wave"&&{backgroundColor:e.vars.palette.background.level3},!d.animation&&{backgroundColor:e.vars.palette.background.level3}),"&::after":W({height:"1em",top:`calc((${((n=e.typography[d.level||r])==null?void 0:n.lineHeight)||1} - 1) * 0.56em)`},e.typography[d.level||r])})),d.variant==="inline"&&W({display:"inline",position:"initial",borderRadius:"min(0.15em, 6px)"},!d.animation&&{backgroundColor:e.vars.palette.background.level3},d.level!=="inherit"&&W({},e.typography[d.level]),{WebkitMaskImage:"-webkit-radial-gradient(white, black)","&::before":{position:"absolute",zIndex:"var(--unstable_pseudo-zIndex)",backgroundColor:e.vars.palette.background.level3}},d.animation==="pulse"&&{"&::after":{content:'""',position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:"var(--unstable_pseudo-zIndex)",backgroundColor:e.vars.palette.background.level3}}),d.variant==="overlay"&&W({borderRadius:e.vars.radius.xs,position:"absolute",width:"100%",height:"100%",zIndex:"var(--unstable_pseudo-zIndex)"},d.animation==="pulse"&&{backgroundColor:e.vars.palette.background.surface},d.level!=="inherit"&&W({},e.typography[d.level]),{"&::before":{position:"absolute"}})]}),mi=B.forwardRef(function(e,t){const s=qt({props:e,name:"JoySkeleton"}),{className:i,component:n="span",children:r,animation:a="pulse",overlay:o=!1,loading:c=!0,variant:u="overlay",level:h=u==="text"?"body-md":"inherit",height:l,width:f,sx:p,slots:m={},slotProps:g={}}=s,y=at(s,rxe),w=W({},y,{component:n,slots:m,slotProps:g,sx:[{width:f,height:l},...Array.isArray(p)?p:[p]]}),b=W({},s,{animation:a,component:n,level:h,loading:c,overlay:o,variant:u,width:f,height:l}),S=axe(b),[v,C]=Fe("root",{ref:t,className:Gt(S.root,i),elementType:dxe,externalForwardedProps:w,ownerState:b});return c?P.jsx(v,W({},C,{children:r})):P.jsx(B.Fragment,{children:B.Children.map(r,(M,_)=>_===0&&B.isValidElement(M)?B.cloneElement(M,{"data-first-child":""}):M)})});mi.muiName="Skeleton";const cxe=8,uxe=()=>{const d=Array.from({length:cxe});return P.jsx(It,{container:!0,spacing:2,children:d.map((e,t)=>P.jsx(It,{md:4,sm:6,xl:3,xs:12,children:P.jsx(mi,{animation:"wave",height:236,sx:{borderRadius:8},variant:"rectangular",width:"100%"},t)},t))})};function hxe(d){return Rt("MuiMenu",d)}Dt("MuiMenu",["root","listbox","expanded","colorPrimary","colorNeutral","colorDanger","colorSuccess","colorWarning","colorContext","variantPlain","variantOutlined","variantSoft","variantSolid","sizeSm","sizeMd","sizeLg"]);const lxe=["actions","children","color","component","disablePortal","keepMounted","id","invertedColors","onItemsChange","modifiers","variant","size","slots","slotProps"],fxe=d=>{const{open:e,variant:t,color:s,size:i}=d,n={root:["root",e&&"expanded",t&&`variant${De(t)}`,s&&`color${De(s)}`,i&&`size${De(i)}`],listbox:["listbox"]};return Nt(n,hxe,{})},ZV=_e(ag,{name:"JoyMenu",slot:"Root",overridesResolver:(d,e)=>e.root})(({theme:d,ownerState:e})=>{var t,s;const i=(t=d.variants[e.variant])==null?void 0:t[e.color];return[W({"--focus-outline-offset":`calc(${d.vars.focus.thickness} * -1)`,"--ListItem-stickyBackground":(i==null?void 0:i.backgroundColor)||(i==null?void 0:i.background)||d.vars.palette.background.popup,"--ListItem-stickyTop":"calc(var(--List-padding, var(--ListDivider-gap)) * -1)"},CO,{borderRadius:`var(--List-radius, ${d.vars.radius.sm})`,boxShadow:d.shadow.md,overflow:"auto",zIndex:`var(--unstable_popup-zIndex, ${d.vars.zIndex.popup})`},!(i!=null&&i.backgroundColor)&&{backgroundColor:d.vars.palette.background.popup},e.variant==="solid"&&e.color&&e.invertedColors&&ig(e.color)(d),e.variant==="soft"&&e.color&&e.invertedColors&&ng(e.color)(d),(s=d.variants[e.variant])==null?void 0:s[e.color])]}),pxe=B.forwardRef(function(e,t){var s;const i=qt({props:e,name:"JoyMenu"}),{actions:n,children:r,color:a="neutral",component:o,disablePortal:c=!1,keepMounted:u=!1,id:h,invertedColors:l=!1,onItemsChange:f,modifiers:p,variant:m="outlined",size:g="md",slots:y={},slotProps:w={}}=i,b=at(i,lxe),{contextValue:S,getListboxProps:v,dispatch:C,open:M,triggerElement:_}=wme({onItemsChange:f,id:h,listboxRef:t});B.useImperativeHandle(n,()=>({dispatch:C,resetHighlight:()=>C({type:ei.resetHighlight,event:null})}),[C]);const N=W({},i,{disablePortal:c,invertedColors:l,color:a,variant:m,size:g,open:M,nesting:!1,row:!1}),A=fxe(N),R=W({},b,{component:o,slots:y,slotProps:w}),D=B.useMemo(()=>[{name:"offset",options:{offset:[0,4]}},...p||[]],[p]),U=ZG({elementType:ZV,getSlotProps:v,externalForwardedProps:R,externalSlotProps:{},ownerState:N,additionalProps:{anchorEl:_,open:M&&_!==null,disablePortal:c,keepMounted:u,modifiers:D},className:A.root});return P.jsx(ZV,W({},U,!((s=i.slots)!=null&&s.root)&&{as:lO,slots:{root:o||"ul"}},{children:P.jsx(bme,{value:S,children:P.jsx(hb,{variant:l?void 0:m,color:a,children:P.jsx(IO.Provider,{value:"menu",children:P.jsx(rg,{nested:!0,children:r})})})})}))});function mxe(d){return Rt("MuiMenuButton",d)}Dt("MuiMenuButton",["root","colorPrimary","colorNeutral","colorDanger","colorInfo","colorSuccess","colorWarning","colorContext","variantPlain","variantOutlined","variantSoft","variantSolid","disabled","sizeSm","sizeMd","sizeLg","fullWidth","startDecorator","endDecorator","loading","loadingIndicatorCenter"]);const gxe=["children","color","component","disabled","endDecorator","loading","loadingPosition","loadingIndicator","size","slotProps","slots","startDecorator","variant"],yxe=d=>{const{color:e,disabled:t,fullWidth:s,size:i,variant:n,loading:r}=d,a={root:["root",t&&"disabled",s&&"fullWidth",n&&`variant${De(n)}`,e&&`color${De(e)}`,i&&`size${De(i)}`,r&&"loading"],startDecorator:["startDecorator"],endDecorator:["endDecorator"],loadingIndicatorCenter:["loadingIndicatorCenter"]};return Nt(a,mxe,{})},wxe=_e("button",{name:"JoyMenuButton",slot:"Root",overridesResolver:(d,e)=>e.root})(DU),bxe=_e("span",{name:"JoyMenuButton",slot:"StartDecorator",overridesResolver:(d,e)=>e.startDecorator})({"--Icon-margin":"0 0 0 calc(var(--Button-gap) / -2)","--CircularProgress-margin":"0 0 0 calc(var(--Button-gap) / -2)",display:"inherit",marginRight:"var(--Button-gap)"}),kxe=_e("span",{name:"JoyMenuButton",slot:"EndDecorator",overridesResolver:(d,e)=>e.endDecorator})({"--Icon-margin":"0 calc(var(--Button-gap) / -2) 0 0","--CircularProgress-margin":"0 calc(var(--Button-gap) / -2) 0 0",display:"inherit",marginLeft:"var(--Button-gap)"}),Sxe=_e("span",{name:"JoyMenuButton",slot:"LoadingCenter",overridesResolver:(d,e)=>e.loadingIndicatorCenter})(({theme:d,ownerState:e})=>{var t,s;return W({display:"inherit",position:"absolute",left:"50%",transform:"translateX(-50%)",color:(t=d.variants[e.variant])==null||(t=t[e.color])==null?void 0:t.color},e.disabled&&{color:(s=d.variants[`${e.variant}Disabled`])==null||(s=s[e.color])==null?void 0:s.color})}),vxe=B.forwardRef(function(e,t){var s;const i=qt({props:e,name:"JoyMenuButton"}),{children:n,color:r="neutral",component:a,disabled:o=!1,endDecorator:c,loading:u=!1,loadingPosition:h="center",loadingIndicator:l,size:f="md",slotProps:p={},slots:m={},startDecorator:g,variant:y="outlined"}=i,w=at(i,gxe),b=B.useContext(rb),S=e.variant||b.variant||y,v=e.size||b.size||f,C=(s=e.disabled)!=null?s:b.disabled||o||u,{getRootProps:M,open:_,active:N}=kme({rootRef:t,disabled:C}),A=l??P.jsx(fO,{color:r,thickness:{sm:2,md:3,lg:4}[v]||3}),R=W({},i,{active:N,color:r,disabled:C,open:_,size:v,variant:S}),D=yxe(R),U=W({},w,{component:a,slots:m,slotProps:p}),[K,j]=Fe("root",{elementType:wxe,getSlotProps:M,externalForwardedProps:U,ref:t,ownerState:R,className:D.root}),[z,J]=Fe("startDecorator",{className:D.startDecorator,elementType:bxe,externalForwardedProps:U,ownerState:R}),[Y,X]=Fe("endDecorator",{className:D.endDecorator,elementType:kxe,externalForwardedProps:U,ownerState:R}),[Z,te]=Fe("loadingIndicatorCenter",{className:D.loadingIndicatorCenter,elementType:Sxe,externalForwardedProps:U,ownerState:R});return P.jsxs(K,W({},j,{children:[(g||u&&h==="start")&&P.jsx(z,W({},J,{children:u&&h==="start"?A:g})),n,u&&h==="center"&&P.jsx(Z,W({},te,{children:A})),(c||u&&h==="end")&&P.jsx(Y,W({},X,{children:u&&h==="end"?A:c}))]}))});function Txe(d){return Rt("MuiMenuItem",d)}Dt("MuiMenuItem",["root","focusVisible","disabled","selected","colorPrimary","colorNeutral","colorDanger","colorSuccess","colorWarning","colorContext","variantPlain","variantSoft","variantOutlined","variantSolid"]);const Oxe=["children","disabled","component","selected","color","orientation","variant","slots","slotProps","id"],xxe=d=>{const{focusVisible:e,disabled:t,selected:s,color:i,variant:n}=d,r={root:["root",e&&"focusVisible",t&&"disabled",s&&"selected",i&&`color${De(i)}`,n&&`variant${De(n)}`]};return Nt(r,Txe,{})},Pxe=_e(og,{name:"JoyMenuItem",slot:"Root",overridesResolver:(d,e)=>e.root})({}),Ixe=B.memo(B.forwardRef(function(e,t){const s=qt({props:e,name:"JoyMenuItem"}),i=B.useContext(Sf),{children:n,disabled:r=!1,component:a="li",selected:o=!1,color:c="neutral",orientation:u="horizontal",variant:h="plain",slots:l={},slotProps:f={},id:p}=s,m=at(s,Oxe),{variant:g=h,color:y=c}=PO(e.variant,e.color),{getRootProps:w,disabled:b,focusVisible:S}=Tme({id:p,disabled:r,rootRef:t}),v=W({},s,{component:a,color:y,disabled:b,focusVisible:S,orientation:u,selected:o,row:i,variant:g}),C=xxe(v),M=W({},m,{component:a,slots:l,slotProps:f}),[_,N]=Fe("root",{ref:t,elementType:Pxe,getSlotProps:w,externalForwardedProps:M,className:C.root,ownerState:v});return P.jsx(MO.Provider,{value:u,children:P.jsx(_,W({},N,{children:n}))})})),MI=B.forwardRef(function(e,t){const{contextValue:s,id:i}=Ome(e.id);return P.jsx(Eh.Provider,{value:s,children:P.jsx(Ixe,W({},e,{id:i,ref:t}))})}),Cxe=()=>P.jsxs(Kpe,{children:[P.jsx(vxe,{size:"lg",color:"primary",variant:"solid",children:"Create new bot"}),P.jsxs(pxe,{size:"lg",children:[P.jsx(MI,{component:Uo,href:ai("grid-bot/create"),children:"New Grid Bot"}),P.jsx(MI,{component:Uo,href:ai("dca-bot/create"),children:"New DCA Bot"}),P.jsx(MI,{component:Uo,href:ai("bot/create"),children:"New custom bot"})]})]}),Mxe=()=>P.jsx(_t,{display:"flex",justifyContent:"space-around",children:P.jsxs(_t,{sx:{textAlign:"center",mt:2},children:[P.jsx(ot,{level:"body-lg",children:"You must add an exchange account before creating a bot"}),P.jsx(Es,{component:Uo,href:ai("accounts"),variant:"soft",size:"md",sx:{mt:1},children:"Add exchange account"})]})});function _xe(){const[d]=kt.exchangeAccount.list.useSuspenseQuery();return d.length===0?P.jsx(Mxe,{}):P.jsxs(It,{container:!0,spacing:4,children:[P.jsx(It,{xs:12,children:P.jsx(_t,{display:"flex",gap:1,children:P.jsx(Cxe,{})})}),P.jsx(It,{xs:12,children:P.jsx(B.Suspense,{fallback:P.jsx(uxe,{}),children:P.jsx(ixe,{})})})]})}const Axe=vr("/_layout/dashboard/bot/")({component:_xe}),Lxe="modulepreload",Bxe=function(d){return"/"+d},JV={},Po=function(e,t,s){let i=Promise.resolve();if(t&&t.length>0){document.getElementsByTagName("link");const r=document.querySelector("meta[property=csp-nonce]"),a=(r==null?void 0:r.nonce)||(r==null?void 0:r.getAttribute("nonce"));i=Promise.allSettled(t.map(o=>{if(o=Bxe(o),o in JV)return;JV[o]=!0;const c=o.endsWith(".css"),u=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${o}"]${u}`))return;const h=document.createElement("link");if(h.rel=c?"stylesheet":Lxe,c||(h.as="script"),h.crossOrigin="",h.href=o,a&&h.setAttribute("nonce",a),document.head.appendChild(h),c)return new Promise((l,f)=>{h.addEventListener("load",l),h.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${o}`)))})}))}function n(r){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=r,window.dispatchEvent(a),!a.defaultPrevented)throw r}return i.then(r=>{for(const a of r||[])a.status==="rejected"&&n(a.reason);return e().catch(n)})},vL=()=>P.jsxs(It,{container:!0,spacing:2,children:[P.jsx(It,{md:9,children:P.jsx(mi,{animation:"wave",height:420,sx:{borderRadius:8},variant:"rectangular",width:"100%"})}),P.jsx(It,{md:3,children:P.jsx(mi,{animation:"wave",height:232,sx:{borderRadius:8},variant:"rectangular",width:"100%"})})]}),TL=(d,e=null)=>{const t=B.lazy(d);return s=>P.jsx(B.Suspense,{fallback:e,children:P.jsx(t,{...s})})},Nxe=TL(()=>Po(()=>import("./page-CoZS_l39.js"),__vite__mapDeps([0,1])),P.jsx(vL,{})),Exe=vr("/_layout/dashboard/grid-bot/create")({component:Nxe});function Rxe(){return P.jsx("tbody",{children:P.jsx("tr",{children:P.jsx("td",{colSpan:4,children:P.jsx(ot,{fontWeight:"400",level:"h4",sx:{py:2},textAlign:"center",children:"No logs yet"})})})})}const WW=80,jW=160,Dxe=()=>P.jsx("thead",{children:P.jsxs("tr",{children:[P.jsx("th",{children:"Action"}),P.jsx("th",{children:"Description"}),P.jsx("th",{style:{textAlign:"right",width:WW},children:P.jsx(In,{title:"Strategy execution duration",children:P.jsx(ot,{children:"Duration"})})}),P.jsx("th",{style:{textAlign:"right",width:jW},children:"Date"})]})}),qxe=({log:d,children:e})=>{var s;const t=(s=d.context)==null?void 0:s.candle;return P.jsx(In,{title:P.jsxs(_t,{children:[P.jsxs("div",{children:["O ",t==null?void 0:t.open]}),P.jsxs("div",{children:["H ",t==null?void 0:t.high]}),P.jsxs("div",{children:["L ",t==null?void 0:t.low]}),P.jsxs("div",{children:["C ",t==null?void 0:t.close]})]}),children:e})};function Vxe(d){return d==="start"?"success":d==="stop"?"danger":"warning"}const Fxe=({action:d})=>P.jsx(nn,{color:Vxe(d),children:d}),Hxe=Ys(P.jsx("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 12z"}),"Close"),Gxe=Ys(P.jsx("path",{d:"M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2M12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"}),"ErrorOutline"),Uxe=({log:d})=>{var n,r,a;console.log("log.context",d);const[e,t]=B.useState(!1),s=()=>t(!0),i=()=>t(!1);return P.jsxs(P.Fragment,{children:[P.jsx(In,{title:(n=d.error)==null?void 0:n.message,children:P.jsx(Gxe,{sx:{fontSize:"xl"},color:"warning",onClick:s})}),P.jsx(tb,{onClose:i,open:e,children:P.jsxs(db,{maxWidth:1024,children:[P.jsxs(mO,{children:[P.jsx(JU,{}),"An error occurred in the strategy template",P.jsx(Rc,{}),P.jsx(Vd,{onClick:i,children:P.jsx(Hxe,{})})]}),P.jsx(Ia,{}),P.jsxs(iL,{children:[P.jsx(ot,{level:"title-lg",fontWeight:"bold",children:(r=d.error)==null?void 0:r.message}),P.jsx(ot,{children:P.jsx("pre",{children:(a=d.error)==null?void 0:a.stack})})]})]})})]})};function Wxe(d,e){const t=new Date(d);return`+${new Date(e).getTime()-t.getTime()}ms`}function jxe(d){return h2(new Date(d),"yyyy-MM-dd'T'HH:mm:ss")}const zxe=d=>{var e;if(d.action==="start"){const t=d==null?void 0:d.error;return t?`An error occurred when starting the bot: ${t.message}`:"Bot started"}if(d.action==="stop"){const t=d==null?void 0:d.error;return t?`An error occurred while stopping the bot: ${t.message}`:"Bot stopped"}if(d.triggerEventType===hI.onOrderFilled)return"An order was filled";if(d.triggerEventType===hI.onCandleClosed){const t=(e=d.context)==null?void 0:e.candle,s=t!=null&&t.timestamp?jxe(t.timestamp):"MISSING_TIMESTAMP";return P.jsxs(P.Fragment,{children:["Candle"," ",P.jsx(nn,{size:"sm",variant:"outlined",color:"neutral",children:s})," ","closed at price"," ",P.jsx(qxe,{log:d,children:P.jsx(nn,{size:"sm",variant:"outlined",color:"neutral",children:t==null?void 0:t.close})})]})}else if(d.triggerEventType===hI.onPublicTrade)return"A public trade happened";return"Unhandled log message"},$xe=({log:d})=>{const e=Jl(d.createdAt.getTime(),!0);return P.jsxs("tr",{tabIndex:-1,children:[P.jsx("td",{scope:"row",children:P.jsxs(_t,{display:"flex",alignItems:"center",children:[d.error?P.jsx(Uxe,{log:d}):null,P.jsx(Fxe,{action:d.action})]})}),P.jsx("td",{scope:"row",children:P.jsx(ot,{display:"inline",children:zxe(d)})}),P.jsx("td",{style:{textAlign:"right",width:WW},children:P.jsx(ot,{display:"inline",color:"success",fontSize:"sm",children:Wxe(d.startedAt,d.endedAt)})}),P.jsx("td",{style:{textAlign:"right",width:jW},children:P.jsx(ot,{level:"body-sm",children:e})})]})},OL=({botId:d})=>{const[e]=kt.bot.getBotLogs.useSuspenseQuery({botId:d});return P.jsx(dg,{sx:{width:"100%",boxShadow:"sm",borderRadius:"sm"},variant:"outlined",children:P.jsxs(_O,{hoverRow:!0,sx:{"--TableCell-headBackground":"transparent","--TableCell-selectedBackground":t=>t.vars.palette.success.softBg,"& thead th:nth-child(1)":{width:"80px"}},children:[P.jsx(Dxe,{}),e.length>0?P.jsx("tbody",{children:e.map(t=>P.jsx($xe,{log:t},t.id))}):P.jsx(Rxe,{})]})})};function Kxe(d){return Rt("MuiTab",d)}const Xxe=Dt("MuiTab",["root","disabled","focusVisible","selected","horizontal","vertical","colorPrimary","colorNeutral","colorDanger","colorSuccess","colorWarning","colorContext","variantPlain","variantOutlined","variantSoft","variantSolid"]),Qxe=["action","children","value","disabled","onChange","onClick","onFocus","component","orientation","variant","color","disableIndicator","indicatorPlacement","indicatorInset","slots","slotProps"],Yxe=d=>{const{selected:e,disabled:t,focusVisible:s,variant:i,color:n,orientation:r}=d,a={root:["root",r,t&&"disabled",s&&"focusVisible",e&&"selected",i&&`variant${De(i)}`,n&&`color${De(n)}`]};return Nt(a,Kxe,{})},Zxe=_e(og,{name:"JoyTab",slot:"Root",overridesResolver:(d,e)=>e.root})(({ownerState:d})=>[{flex:"initial",justifyContent:d.row?"center":"initial","--unstable_ListItemDecorator-alignItems":"center","--unstable_offset":"min(calc(-1 * var(--variant-borderWidth, 0px)), -1px)"},!d.disableIndicator&&{'&[aria-selected="true"]':{"--Tab-indicatorColor":"currentColor",zIndex:1},"&::after":{content:'""',display:"block",position:"absolute",margin:"auto",background:"var(--Tab-indicatorColor)",borderRadius:"var(--Tab-indicatorRadius)"}},!d.disableIndicator&&d.indicatorPlacement==="bottom"&&{paddingBottom:"calc(var(--ListItem-paddingY) - var(--variant-borderWidth, 0px) + var(--Tab-indicatorThickness) - 1px)","&::after":{height:"var(--Tab-indicatorThickness)",width:"var(--Tab-indicatorSize)",left:d.indicatorInset?"var(--ListItem-paddingLeft)":"var(--unstable_offset)",right:d.indicatorInset?"var(--ListItem-paddingRight)":"var(--unstable_offset)",bottom:"calc(-1px - var(--unstable_TabList-underlineBottom, 0px))"}},!d.disableIndicator&&d.indicatorPlacement==="top"&&{paddingTop:"calc(var(--ListItem-paddingY) - var(--variant-borderWidth, 0px) + var(--Tab-indicatorThickness) - 1px)","&::after":{height:"var(--Tab-indicatorThickness)",width:"var(--Tab-indicatorSize)",left:d.indicatorInset?"var(--ListItem-paddingLeft)":"var(--unstable_offset)",right:d.indicatorInset?"var(--ListItem-paddingRight)":"var(--unstable_offset)",top:"calc(-1px - var(--unstable_TabList-underlineTop, 0px))"}},!d.disableIndicator&&d.indicatorPlacement==="right"&&{paddingRight:"calc(var(--ListItem-paddingRight) + var(--Tab-indicatorThickness) - 1px)","&::after":{height:"var(--Tab-indicatorSize)",width:"var(--Tab-indicatorThickness)",top:d.indicatorInset?"var(--ListItem-paddingY)":"var(--unstable_offset)",bottom:d.indicatorInset?"var(--ListItem-paddingY)":"var(--unstable_offset)",right:"calc(-1px - var(--unstable_TabList-underlineRight, 0px))"}},!d.disableIndicator&&d.indicatorPlacement==="left"&&{paddingLeft:"calc(var(--ListItem-paddingLeft) + var(--Tab-indicatorThickness) - 1px)","&::after":{height:"var(--Tab-indicatorSize)",width:"var(--Tab-indicatorThickness)",top:d.indicatorInset?"var(--ListItem-paddingY)":"var(--unstable_offset)",bottom:d.indicatorInset?"var(--ListItem-paddingY)":"var(--unstable_offset)",left:"calc(-1px - var(--unstable_TabList-underlineLeft, 0px))"}}]),_I=B.forwardRef(function(e,t){const s=qt({props:e,name:"JoyTab"}),i=B.useContext(Sf),{action:n,children:r,disabled:a=!1,component:o="button",orientation:c="horizontal",variant:u="plain",color:h="neutral",disableIndicator:l=!1,indicatorPlacement:f=i?"bottom":"right",indicatorInset:p=!1,slots:m={},slotProps:g={}}=s,y=at(s,Qxe),w=B.useRef(null),b=Cs(w,t),{active:S,focusVisible:v,setFocusVisible:C,selected:M,getRootProps:_}=Zge(W({},s,{rootRef:b}));B.useImperativeHandle(n,()=>({focusVisible:()=>{C(!0),w.current.focus()}}),[C]);const N=W({},s,{disableIndicator:l,indicatorPlacement:f,indicatorInset:p,orientation:c,row:i,active:S,focusVisible:v,disabled:a,selected:M,variant:u,color:h}),A=Yxe(N),R=W({},y,{component:o,slots:m,slotProps:g}),[D,U]=Fe("root",{ref:t,elementType:Zxe,getSlotProps:_,externalForwardedProps:R,ownerState:N,className:A.root});return P.jsx(MO.Provider,{value:c,children:P.jsx(D,W({},U,{children:r}))})}),zW=B.createContext("md");function Jxe(d){return Rt("MuiTabList",d)}Dt("MuiTabList",["root","colorPrimary","colorNeutral","colorDanger","colorSuccess","colorWarning","colorContext","variantPlain","variantOutlined","variantSoft","variantSolid","sizeSm","sizeMd","sizeLg"]);const ePe=["component","children","variant","color","size","disableUnderline","underlinePlacement","tabFlex","sticky","slots","slotProps"],tPe=d=>{const{orientation:e,size:t,variant:s,color:i}=d,n={root:["root",e,s&&`variant${De(s)}`,i&&`color${De(i)}`,t&&`size${De(t)}`]};return Nt(n,Jxe,{})},sPe=_e(ag,{name:"JoyTabList",slot:"Root",overridesResolver:(d,e)=>e.root})(({theme:d,ownerState:e})=>{var t;const s=(t=d.variants[e.variant])==null?void 0:t[e.color];return W({"--List-gap":"0px","--ListDivider-gap":"0px","--ListItem-paddingX":"var(--Tabs-spacing)","--ListItem-gap":"0.375rem","--unstable_TabList-hasUnderline":e.disableUnderline?"var(--unknown,)":"initial"},CO,{flexGrow:"initial",flexDirection:e.orientation==="vertical"?"column":"row",borderRadius:"var(--List-radius, 0px)",padding:"var(--List-padding, 0px)",zIndex:1},e.sticky&&{position:"sticky",top:e.sticky==="top"?"calc(-1 * var(--Tabs-padding, 0px))":"initial",bottom:e.sticky==="bottom"?"calc(-1 * var(--Tabs-padding, 0px))":"initial",backgroundColor:(s==null?void 0:s.backgroundColor)||`var(--TabList-stickyBackground, ${d.vars.palette.background.body})`},!e.disableUnderline&&W({},e.underlinePlacement==="bottom"&&{"--unstable_TabList-underlineBottom":"1px",paddingBottom:1,boxShadow:`inset 0 -1px ${d.vars.palette.divider}`},e.underlinePlacement==="top"&&{"--unstable_TabList-underlineTop":"1px",paddingTop:1,boxShadow:`inset 0 1px ${d.vars.palette.divider}`},e.underlinePlacement==="right"&&{"--unstable_TabList-underlineRight":"1px",paddingRight:1,boxShadow:`inset -1px 0 ${d.vars.palette.divider}`},e.underlinePlacement==="left"&&{"--unstable_TabList-underlineLeft":"1px",paddingLeft:1,boxShadow:`inset 1px 0 ${d.vars.palette.divider}`}),e.tabFlex&&{[`& .${Xxe.root}`]:{flex:e.tabFlex}})}),iPe=B.forwardRef(function(e,t){const s=qt({props:e,name:"JoyTabList"}),i=B.useContext(zW),{isRtl:n,orientation:r,getRootProps:a,contextValue:o}=Xge({rootRef:t}),{component:c="div",children:u,variant:h="plain",color:l="neutral",size:f,disableUnderline:p=!1,underlinePlacement:m=r==="horizontal"?"bottom":"right",tabFlex:g,sticky:y,slots:w={},slotProps:b={}}=s,S=at(s,ePe),C=W({},s,{isRtl:n,orientation:r,variant:h,color:l,size:f??i,sticky:y,tabFlex:g,nesting:!1,disableUnderline:p,underlinePlacement:m}),M=tPe(C),_=W({},S,{component:c,slots:w,slotProps:b}),[N,A]=Fe("root",{ref:t,elementType:sPe,getSlotProps:a,externalForwardedProps:_,ownerState:C,className:M.root});return P.jsx(N,W({},A,{children:P.jsx(Qge,{value:o,children:P.jsx(rg,{row:r==="horizontal",nested:!0,children:u})})}))});function nPe(d){return Rt("MuiTabs",d)}Dt("MuiTabs",["root","horizontal","vertical","colorPrimary","colorNeutral","colorDanger","colorSuccess","colorWarning","colorContext","variantPlain","variantOutlined","variantSoft","variantSolid","sizeSm","sizeMd","sizeLg"]);const rPe=["children","value","defaultValue","orientation","direction","component","onChange","selectionFollowsFocus","variant","color","size","slots","slotProps"],aPe=d=>{const{orientation:e,variant:t,color:s,size:i}=d,n={root:["root",e,t&&`variant${De(t)}`,s&&`color${De(s)}`,i&&`size${De(i)}`]};return Nt(n,nPe,{})},oPe=_e("div",{name:"JoyTabs",slot:"Root",overridesResolver:(d,e)=>e.root})(({ownerState:d,theme:e})=>{var t,s;const i=(t=e.variants[d.variant])==null?void 0:t[d.color],{bgcolor:n,backgroundColor:r,background:a,p:o,padding:c}=eu({theme:e,ownerState:d},["bgcolor","backgroundColor","background","p","padding"]),u=yh(e,`palette.${n}`)||n||yh(e,`palette.${r}`)||r||a||(i==null?void 0:i.backgroundColor)||(i==null?void 0:i.background)||e.vars.palette.background.surface;return W({},d.size==="sm"&&{"--Tabs-spacing":"0.75rem"},d.size==="md"&&{"--Tabs-spacing":"1rem"},d.size==="lg"&&{"--Tabs-spacing":"1.25rem"},{"--Tab-indicatorThickness":"2px","--Icon-color":d.color!=="neutral"||d.variant==="solid"?"currentColor":e.vars.palette.text.icon,"--TabList-stickyBackground":u==="transparent"?"initial":u,display:"flex",flexDirection:"column"},d.orientation==="vertical"&&{flexDirection:"row"},{backgroundColor:e.vars.palette.background.surface,position:"relative"},e.typography[`body-${d.size}`],(s=e.variants[d.variant])==null?void 0:s[d.color],o!==void 0&&{"--Tabs-padding":o},c!==void 0&&{"--Tabs-padding":c})}),dPe=B.forwardRef(function(e,t){const s=qt({props:e,name:"JoyTabs"}),{children:i,value:n,defaultValue:r,orientation:a="horizontal",direction:o="ltr",component:c,variant:u="plain",color:h="neutral",size:l="md",slots:f={},slotProps:p={}}=s,m=at(s,rPe),g=r||(n===void 0?0:void 0),{contextValue:y}=zge(W({},s,{orientation:a,defaultValue:g})),w=W({},s,{orientation:a,direction:o,variant:u,color:h,size:l}),b=aPe(w),S=W({},m,{component:c,slots:f,slotProps:p}),[v,C]=Fe("root",{ref:t,elementType:oPe,externalForwardedProps:S,additionalProps:{ref:t,as:c},ownerState:w,className:b.root});return P.jsx(v,W({},C,{children:P.jsx($ge,{value:y,children:P.jsx(zW.Provider,{value:l,children:i})})}))}),AI={Orders:"Orders",SmartTrades:"SmartTrades",StrategyLogs:"StrategyLogs"},xL=({value:d,onChange:e,children:t,actions:s})=>P.jsxs(P.Fragment,{children:[P.jsx(dPe,{value:d,onChange:(i,n)=>e(n),sx:{bgcolor:"transparent"},children:P.jsxs(iPe,{sx:{alignItems:"center"},children:[P.jsx(_I,{value:AI.Orders,sx:{borderTopLeftRadius:6,borderTopRightRadius:6},disableIndicator:!0,children:"Orders"}),P.jsx(_I,{value:AI.SmartTrades,sx:{borderTopLeftRadius:6,borderTopRightRadius:6},disableIndicator:!0,children:"Trades"}),P.jsx(_I,{value:AI.StrategyLogs,sx:{borderTopLeftRadius:6,borderTopRightRadius:6},disableIndicator:!0,children:"Strategy logs"}),P.jsx(Rc,{}),s?P.jsx(_t,{children:s}):null]})}),P.jsx(_t,{children:t})]}),cPe="SyncClosedOrdersButton",uPe={root:`${cPe}-root`},PL=d=>{const{className:e,polling:t}=d,{showSnackbar:s}=Tr(),{isLoading:i,mutate:n,mutateAsync:r}=kt.cron.syncClosedOrders.useMutation({onSuccess(){s("Orders have been synced")}});return B.useEffect(()=>{if(!t)return;const a=setInterval(()=>{r().then(o=>{console.log("response",o)})},15e3);return()=>{clearInterval(a)}},[t]),P.jsx(Es,{className:Gt(uPe.root,e),color:"neutral",loading:i,loadingPosition:"start",onClick:()=>{n()},size:"lg",variant:"outlined",children:"Sync orders"})};function hPe(d){return Rt("MuiAccordion",d)}const lPe=Dt("MuiAccordion",["root","expanded","disabled"]),IL=B.createContext({}),$W=B.createContext(void 0),fPe=["component","className","children","nested","sticky","variant","color","startAction","endAction","role","slots","slotProps"],pPe=d=>{const{sticky:e,nested:t,nesting:s,variant:i,color:n}=d,r={root:["root",t&&"nested",s&&"nesting",e&&"sticky",n&&`color${De(n)}`,i&&`variant${De(i)}`],startAction:["startAction"],endAction:["endAction"]};return Nt(r,BSe,{})},CL=_e("li")(({theme:d,ownerState:e})=>{var t;return[!e.nested&&{"--ListItemButton-marginInline":"calc(-1 * var(--ListItem-paddingLeft)) calc(-1 * var(--ListItem-paddingRight))","--ListItemButton-marginBlock":"calc(-1 * var(--ListItem-paddingY))",alignItems:"center",gap:"var(--ListItem-gap)",marginInline:"var(--ListItem-marginInline)"},e.nested&&{"--NestedList-marginRight":"calc(-1 * var(--ListItem-paddingRight))","--NestedList-marginLeft":"calc(-1 * var(--ListItem-paddingLeft))","--NestedListItem-paddingLeft":"calc(var(--ListItem-paddingLeft) + var(--List-nestedInsetStart))","--ListItemButton-marginBlock":"0px","--ListItemButton-marginInline":"calc(-1 * var(--ListItem-paddingLeft)) calc(-1 * var(--ListItem-paddingRight))","--ListItem-marginInline":"calc(-1 * var(--ListItem-paddingLeft)) calc(-1 * var(--ListItem-paddingRight))",flexDirection:"column"},W({"--unstable_actionRadius":"calc(var(--ListItem-radius) - var(--variant-borderWidth, 0px))"},e.startAction&&{"--unstable_startActionWidth":"2rem"},e.endAction&&{"--unstable_endActionWidth":"2.5rem"},{boxSizing:"border-box",borderRadius:"var(--ListItem-radius)",display:"var(--_ListItem-display)","&:not([hidden])":{"--_ListItem-display":"var(--_List-markerDisplay, flex)"},flex:"none",listStyleType:"var(--_List-markerType, disc)",position:"relative",paddingBlockStart:e.nested?0:"var(--ListItem-paddingY)",paddingBlockEnd:e.nested?0:"var(--ListItem-paddingY)",paddingInlineStart:"var(--ListItem-paddingLeft)",paddingInlineEnd:"var(--ListItem-paddingRight)"},e["data-first-child"]===void 0&&W({},e.row?{marginInlineStart:"var(--List-gap)"}:{marginBlockStart:"var(--List-gap)"}),e.row&&e.wrap&&{marginInlineStart:"var(--List-gap)",marginBlockStart:"var(--List-gap)"},{minBlockSize:"var(--ListItem-minHeight)"},e.sticky&&{position:"sticky",top:"var(--ListItem-stickyTop, 0px)",zIndex:1,background:`var(--ListItem-stickyBackground, ${d.vars.palette.background.body})`},{[`.${Bv.nested} > &`]:{"--_ListItem-display":"flex"}}),(t=d.variants[e.variant])==null?void 0:t[e.color]]}),mPe=_e(CL,{name:"JoyListItem",slot:"Root",overridesResolver:(d,e)=>e.root})({}),gPe=_e("div",{name:"JoyListItem",slot:"StartAction",overridesResolver:(d,e)=>e.startAction})(({ownerState:d})=>({display:"inherit",position:"absolute",top:d.nested?"calc(var(--ListItem-minHeight) / 2)":"50%",left:0,transform:"translate(var(--ListItem-startActionTranslateX), -50%)",zIndex:1})),yPe=_e("div",{name:"JoyListItem",slot:"StartAction",overridesResolver:(d,e)=>e.startAction})(({ownerState:d})=>({display:"inherit",position:"absolute",top:d.nested?"calc(var(--ListItem-minHeight) / 2)":"50%",right:0,transform:"translate(var(--ListItem-endActionTranslateX), -50%)"})),Er=B.forwardRef(function(e,t){const s=qt({props:e,name:"JoyListItem"}),i=B.useContext(IO),n=B.useContext(mL),r=B.useContext(Sf),a=B.useContext(uW),o=B.useContext(Lv),{component:c,className:u,children:h,nested:l=!1,sticky:f=!1,variant:p="plain",color:m="neutral",startAction:g,endAction:y,role:w,slots:b={},slotProps:S={}}=s,v=at(s,fPe),[C,M]=B.useState(""),[_,N]=(n==null?void 0:n.split(":"))||["",""],A=c||(_&&!_.match(/^(ul|ol|menu)$/)?"div":void 0);let R=i==="menu"?"none":void 0;n&&(R={menu:"none",menubar:"none",group:"presentation"}[N]),w&&(R=w);const D=W({},s,{sticky:f,startAction:g,endAction:y,row:r,wrap:a,variant:p,color:m,nesting:o,nested:l,component:A,role:R}),U=pPe(D),K=W({},v,{component:A,slots:b,slotProps:S}),[j,z]=Fe("root",{additionalProps:{role:R},ref:t,className:Gt(U.root,u),elementType:mPe,externalForwardedProps:K,ownerState:D}),[J,Y]=Fe("startAction",{className:U.startAction,elementType:gPe,externalForwardedProps:K,ownerState:D}),[X,Z]=Fe("endAction",{className:U.endAction,elementType:yPe,externalForwardedProps:K,ownerState:D});return P.jsx($W.Provider,{value:M,children:P.jsx(Lv.Provider,{value:l?C||!0:!1,children:P.jsxs(j,W({},z,{children:[g&&P.jsx(J,W({},Y,{children:g})),B.Children.map(h,(te,Q)=>{var ie;return B.isValidElement(te)?B.cloneElement(te,W({},Q===0&&{"data-first-child":""},lf(te,["ListItem"])&&{component:((ie=te.props)==null?void 0:ie.component)||"div"})):te}),y&&P.jsx(X,W({},Z,{children:y}))]}))})})});Er.muiName="ListItem";function wPe(d){return Rt("MuiAccordionDetails",d)}const hh=Dt("MuiAccordionDetails",["root","content","expanded"]),bPe=["accordionId","component","color","children","defaultExpanded","disabled","expanded","onChange","variant","slots","slotProps"],kPe=d=>{const{variant:e,color:t,expanded:s,disabled:i}=d,n={root:["root",s&&"expanded",i&&"disabled",t&&`color${De(t)}`,e&&`variant${De(e)}`]};return Nt(n,hPe,{})},SPe=_e(CL,{name:"JoyAccordion",slot:"Root",overridesResolver:(d,e)=>e.root})({borderBottom:"var(--Accordion-borderBottom)","&[data-first-child]":{"--ListItem-radius":"var(--unstable_List-childRadius) var(--unstable_List-childRadius) 0 0"},"&[data-last-child]":{"--ListItem-radius":"0 0 var(--unstable_List-childRadius) var(--unstable_List-childRadius)",'& [aria-expanded="true"]':{"--ListItem-radius":"0"},[`& .${hh.root}`]:{"--AccordionDetails-radius":"0 0 var(--unstable_List-childRadius) var(--unstable_List-childRadius)"}},"&:not([data-first-child]):not([data-last-child])":{"--ListItem-radius":"0"}}),vPe=B.forwardRef(function(e,t){const s=qt({props:e,name:"JoyAccordion"}),{accordionId:i,component:n="div",color:r="neutral",children:a,defaultExpanded:o=!1,disabled:c=!1,expanded:u,onChange:h,variant:l="plain",slots:f={},slotProps:p={}}=s,m=at(s,bPe),g=ln(i),[y,w]=ch({controlled:u,default:o,name:"Accordion",state:"expanded"}),b=B.useCallback(A=>{w(!y),h&&h(A,!y)},[y,h,w]),S=B.useMemo(()=>({accordionId:g,expanded:y,disabled:c,toggle:b}),[g,y,c,b]),v=W({},m,{component:n,slots:f,slotProps:p}),C=W({},s,{component:n,color:r,variant:l,expanded:y,disabled:c,nested:!0}),M=kPe(C),[_,N]=Fe("root",{ref:t,className:M.root,elementType:SPe,externalForwardedProps:v,ownerState:C});return P.jsx(IL.Provider,{value:S,children:P.jsx(_,W({},N,{children:B.Children.map(a,(A,R)=>B.isValidElement(A)&&R===0?B.cloneElement(A,{"data-first-child":""}):A)}))})});function TPe(d){return Rt("MuiAccordionGroup",d)}Dt("MuiAccordionGroup",["root","colorPrimary","colorNeutral","colorDanger","colorSuccess","colorWarning","colorContext","variantPlain","variantOutlined","variantSoft","variantSolid","sizeSm","sizeMd","sizeLg"]);const OPe=["component","color","children","disableDivider","variant","transition","size","slots","slotProps"],xPe=d=>{const{variant:e,color:t,size:s}=d,i={root:["root",e&&`variant${De(e)}`,t&&`color${De(t)}`,s&&`size${De(s)}`]};return Nt(i,TPe,{})},PPe=_e(ag,{name:"JoyAccordionGroup",slot:"Root",overridesResolver:(d,e)=>e.root})(({theme:d,ownerState:e})=>{let t={};return e.transition&&(typeof e.transition=="string"&&(t={"--AccordionDetails-transition":`grid-template-rows ${e.transition}, padding-block ${e.transition}`}),typeof e.transition=="object"&&(t={"--AccordionDetails-transition":`grid-template-rows ${e.transition.initial}, padding-block ${e.transition.initial}`,[`& .${hh.root}.${hh.expanded}`]:{"--AccordionDetails-transition":`grid-template-rows ${e.transition.expanded}, padding-block ${e.transition.expanded}`}})),W({"--List-padding":"0px","--ListDivider-gap":"0px"},t,!e.disableDivider&&{[`& .${lPe.root}:not([data-last-child])`]:{"--Accordion-borderBottom":`1px solid ${d.vars.palette.divider}`}})}),IPe=B.forwardRef(function(e,t){const s=qt({props:e,name:"JoyAccordionGroup"}),{component:i="div",color:n="neutral",children:r,disableDivider:a=!1,variant:o="plain",transition:c="0.2s ease",size:u="md",slots:h={},slotProps:l={}}=s,f=at(s,OPe),p=W({},f,{component:i,slots:h,slotProps:l}),m=W({},s,{component:i,color:n,disableDivider:a,variant:o,transition:c,size:u}),g=xPe(m),[y,w]=Fe("root",{ref:t,className:g.root,elementType:PPe,externalForwardedProps:p,ownerState:m});return P.jsx(y,W({},w,{children:P.jsx(rg,{children:r})}))});function CPe(d){return Rt("MuiAccordionSummary",d)}const AO=Dt("MuiAccordionSummary",["root","button","indicator","disabled","expanded"]),MPe=kf(P.jsx("path",{d:"M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z"}),"KeyboardArrowDown");var e5;const _Pe=["component","color","children","indicator","variant","slots","slotProps"],APe=d=>{const{disabled:e,expanded:t}=d;return Nt({root:["root",e&&"disabled",t&&"expanded"],button:["button",e&&"disabled",t&&"expanded"],indicator:["indicator",e&&"disabled",t&&"expanded"]},CPe,{})},LPe=_e(CL,{name:"JoyAccordionSummary",slot:"Root",overridesResolver:(d,e)=>e.root})(({theme:d})=>({fontWeight:d.vars.fontWeight.md,gap:"calc(var(--ListItem-paddingX, 0.75rem) + 0.25rem)",[`&.${AO.expanded}`]:{"--Icon-color":"currentColor"}})),BPe=_e(og,{name:"JoyAccordionSummary",slot:"Button",overridesResolver:(d,e)=>e.button})({gap:"inherit",fontWeight:"inherit",justifyContent:"space-between",font:"inherit","&:focus-visible":{zIndex:1},[`.${AO.root} &`]:{"--unstable_ListItem-flex":"1 0 0%"}}),NPe=_e("span",{name:"JoyAccordionSummary",slot:"Indicator",overridesResolver:(d,e)=>e.indicator})({display:"inline-flex",[`&.${AO.expanded}`]:{transform:"rotate(180deg)"}}),EPe=B.forwardRef(function(e,t){const s=qt({props:e,name:"JoyAccordionSummary"}),{component:i="div",color:n="neutral",children:r,indicator:a=e5||(e5=P.jsx(MPe,{})),variant:o="plain",slots:c={},slotProps:u={}}=s,h=at(s,_Pe),{accordionId:l,disabled:f=!1,expanded:p=!1,toggle:m}=B.useContext(IL),g=W({},h,{component:i,slots:c,slotProps:u}),y=W({},s,{component:i,color:n,disabled:f,expanded:p,variant:o}),w=A=>{if(m&&m(A),typeof u.button=="function"){var R,D;(R=u.button(y))==null||(D=R.onClick)==null||D.call(R,A)}else{var U,K;(U=u.button)==null||(K=U.onClick)==null||K.call(U,A)}},b=APe(y),[S,v]=Fe("root",{ref:t,className:b.root,elementType:LPe,externalForwardedProps:g,ownerState:y}),[C,M]=Fe("button",{ref:t,className:b.button,elementType:BPe,externalForwardedProps:g,additionalProps:{component:"button",id:`${l}-summary`,"aria-expanded":p?"true":"false","aria-controls":`${l}-details`,disabled:f,type:"button",onClick:w},ownerState:y}),[_,N]=Fe("indicator",{ref:t,className:b.indicator,elementType:NPe,externalForwardedProps:g,ownerState:y});return P.jsx(S,W({},v,{children:P.jsxs(C,W({},M,{children:[r,a&&P.jsx(_,W({},N,{children:a}))]}))}))}),RPe=["component","children","color","variant","slots","slotProps"],DPe=d=>{const{expanded:e}=d;return Nt({root:["root",e&&"expanded"],content:["content",e&&"expanded"]},wPe,{})},qPe=_e("div",{name:"JoyAccordionDetails",slot:"Root",overridesResolver:(d,e)=>e.root})(({ownerState:d,theme:e})=>{var t;return W({overflow:"hidden",borderRadius:"var(--AccordionDetails-radius)",display:"grid",gridTemplateRows:"1fr",marginInline:"calc(-1 * var(--ListItem-paddingLeft)) calc(-1 * var(--ListItem-paddingRight))",transition:"var(--AccordionDetails-transition)"},(t=e.variants[d.variant])==null?void 0:t[d.color],{[`&:not(.${hh.expanded})`]:{gridTemplateRows:"0fr"}})}),VPe=_e("div",{name:"JoyAccordionDetails",slot:"Content",overridesResolver:(d,e)=>e.root})({display:"flex",flexDirection:"column",overflow:"hidden",paddingInlineStart:"var(--ListItem-paddingLeft)",paddingInlineEnd:"var(--ListItem-paddingRight)",paddingBlockStart:"calc(var(--ListItem-paddingY) / 2)",paddingBlockEnd:"calc(2.5 * var(--ListItem-paddingY))",transition:"var(--AccordionDetails-transition)",[`&:not(.${hh.expanded})`]:{paddingBlock:0}}),FPe=B.forwardRef(function(e,t){const s=qt({props:e,name:"JoyAccordionDetails"}),{component:i="div",children:n,color:r="neutral",variant:a="plain",slots:o={},slotProps:c={}}=s,u=at(s,RPe),{accordionId:h,expanded:l=!1}=B.useContext(IL),f=B.useRef(null),p=Cs(f,t);B.useEffect(()=>{f.current&&f.current.querySelectorAll('a, button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])').forEach(M=>{if(l){const _=M.getAttribute("data-prev-tabindex"),N=M.getAttribute("tabindex");N&&_&&(M.setAttribute("tabindex",_),M.removeAttribute("data-prev-tabindex")),!_&&!N&&M.removeAttribute("tabindex")}else M.setAttribute("data-prev-tabindex",M.getAttribute("tabindex")||""),M.setAttribute("tabindex","-1")})},[l]);const m=W({},u,{component:i,slots:o,slotProps:c}),g=W({},s,{component:i,color:r,variant:a,expanded:l,nesting:!0}),y=DPe(g),[w,b]=Fe("root",{ref:p,className:y.root,elementType:qPe,externalForwardedProps:m,additionalProps:{id:`${h}-details`,"aria-labelledby":`${h}-summary`,role:"region",hidden:l?void 0:!0},ownerState:g}),[S,v]=Fe("content",{className:y.content,elementType:VPe,externalForwardedProps:m,ownerState:g});return P.jsx(w,W({},b,{children:P.jsx(S,W({},v,{children:n}))}))}),ML=({children:d})=>P.jsx(IPe,{size:"lg",sx:e=>({mx:-2,mb:-2,borderRadius:"md",[`& .${AO.button}`]:{color:e.vars.palette.text.tertiary},[`& .${hh.root}`]:{backgroundColor:"transparent",color:e.vars.palette.text.primary,border:0},[`& .${hh.content}`]:{gap:"0.75rem",[`&.${hh.expanded}`]:{paddingBlock:"0.75rem"}}}),transition:"0.2s",variant:"plain",children:P.jsxs(vPe,{children:[P.jsx(EPe,{children:"More actions"}),P.jsx(FPe,{variant:"soft",children:d})]})}),HPe="RunBotTemplateButton",GPe={root:`${HPe}-root`},_L=d=>{const{className:e,bot:t}=d,{showSnackbar:s}=Tr(),{isLoading:i,mutate:n}=kt.bot.manualProcess.useMutation({onSuccess(){s("Bot template executed")}});return P.jsx(Es,{className:Gt(GPe.root,e),color:"neutral",loading:i,loadingPosition:"start",onClick:()=>{n({botId:t.id})},size:"lg",variant:"outlined",children:"Run template"})},UPe="StartStopBotButton",LI={root:`${UPe}-root`},AL=({className:d,bot:e})=>{const{showSnackbar:t}=Tr(),s=kt.useUtils(),i=()=>{s.gridBot.getOne.invalidate(e.id),s.dcaBot.getOne.invalidate(e.id),s.bot.getOne.invalidate(e.id),s.order.openOrders.invalidate({botId:e.id}),s.order.closedOrders.invalidate({botId:e.id}),s.order.infiniteOrders.invalidate({botId:e.id}),s.bot.activeSmartTrades.invalidate({botId:e.id}),s.bot.completedSmartTrades.invalidate({botId:e.id}),s.bot.getBotLogs.invalidate({botId:e.id}),s.smartTrade.infiniteList.invalidate({botId:e.id})},n=kt.bot.start.useMutation({onSuccess(){i(),t("Bot has been enabled")}}),r=kt.bot.stop.useMutation({onSuccess(){i(),t("Bot has been stopped")}});return n.isLoading||r.isLoading?P.jsx(Es,{className:Gt(LI.root,d),color:n.isLoading?"success":"danger",loading:!0,loadingPosition:"start",size:"lg",variant:"soft",children:n.isLoading?"Starting...":"Stopping..."}):e.enabled?P.jsx(Es,{className:Gt(LI.root,d),color:"danger",onClick:()=>{r.mutate({botId:e.id})},size:"lg",variant:"soft",children:"Stop bot"}):P.jsx(Es,{className:Gt(LI.root,d),color:"success",onClick:()=>{n.mutate({botId:e.id})},size:"lg",variant:"soft",children:"Start bot"})},LL=({bot:d,href:e})=>{const{showSnackbar:t}=Tr();return d.enabled?P.jsx(Es,{onClick:()=>t("Bot is currently running. Stop it first to edit.",{color:"warning",autoHideDuration:3e3}),size:"lg",color:"neutral",variant:"solid",children:"Edit"}):P.jsx(Es,{component:Uo,href:e,size:"lg",color:"neutral",variant:"solid",children:"Edit"})},WPe="DeleteBotButton",t5={root:`${WPe}-root`},BL=({className:d,bot:e,redirectPath:t})=>{const s=Zc(),{showSnackbar:i}=Tr(),{showConfirmDialog:n}=NU(),r=kt.useUtils(),a=()=>{r.bot.list.invalidate(),r.gridBot.list.invalidate()},o=kt.bot.delete.useMutation({onSuccess(){a(),i("Bot has been deleted"),setTimeout(()=>{s({to:t})},1500)}});return o.isLoading?P.jsx(Es,{className:Gt(t5.root,d),color:"danger",loading:!0,loadingPosition:"start",size:"lg",variant:"soft",children:"Deleting..."}):P.jsx(Es,{className:Gt(t5.root,d),color:"danger",loading:o.isLoading,loadingPosition:"start",onClick:()=>{n("Are you sure you want to delete the bot? All orders and profit history will be deleted as well.",()=>{o.mutate({botId:e.id})},{confirmText:"Delete",confirmButtonColor:"danger",confirmButtonVariant:"outlined"})},size:"lg",variant:"soft",children:"Delete bot"})},NL=({children:d})=>P.jsx(P.Fragment,{children:d}),EL=Ys(P.jsx("path",{d:"M4 7v2c0 .55-.45 1-1 1H2v4h1c.55 0 1 .45 1 1v2c0 1.65 1.35 3 3 3h3v-2H7c-.55 0-1-.45-1-1v-2c0-1.3-.84-2.42-2-2.83v-.34C5.16 11.42 6 10.3 6 9V7c0-.55.45-1 1-1h3V4H7C5.35 4 4 5.35 4 7m17 3c-.55 0-1-.45-1-1V7c0-1.65-1.35-3-3-3h-3v2h3c.55 0 1 .45 1 1v2c0 1.3.84 2.42 2 2.83v.34c-1.16.41-2 1.52-2 2.83v2c0 .55-.45 1-1 1h-3v2h3c1.65 0 3-1.35 3-3v-2c0-.55.45-1 1-1h1v-4z"}),"DataObject"),jPe=Ys(P.jsx("path",{d:"m20 12-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8z"}),"ArrowDownward"),KW=Ys(P.jsx("path",{d:"m4 12 1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8z"}),"ArrowUpward"),zPe=Ys(P.jsx("path",{d:"M18 17h2v.5h-1v1h1v.5h-2v1h3v-4h-3zm1-9h1V4h-2v1h1zm-1 3h1.8L18 13.1v.9h3v-1h-1.8l1.8-2.1V10h-3zM2 5h14v2H2zm0 12h14v2H2zm0-6h14v2H2z"}),"FormatListNumberedRtl"),$Pe=Ys(P.jsx("path",{d:"m20.5 10 .5-2h-4l1-4h-2l-1 4h-4l1-4h-2L9 8H5l-.5 2h4l-1 4h-4L3 16h4l-1 4h2l1-4h4l-1 4h2l1-4h4l.5-2h-4l1-4zm-7 4h-4l1-4h4z"}),"Numbers"),KPe=Ys(P.jsx("path",{d:"M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2"}),"Circle"),XPe="BotStatusChip",m1={root:`${XPe}-root`},BI=_e(nn)(()=>({[`&.${m1.root}`]:{}})),QPe=d=>{const{className:e,bot:t,sx:s,size:i}=d,{showSnackbar:n}=Tr(),r=kt.useUtils(),a=()=>{r.gridBot.getOne.invalidate(t.id),r.bot.getOne.invalidate(t.id),r.bot.activeSmartTrades.invalidate({botId:t.id}),r.bot.completedSmartTrades.invalidate({botId:t.id})},o=kt.bot.start.useMutation({onSuccess(){a(),n("Bot has been enabled")}}),c=kt.bot.stop.useMutation({onSuccess(){a(),n("Bot has been stopped")}});return o.isLoading||c.isLoading?P.jsx(BI,{className:Gt(m1.root,e),disabled:!0,size:i,startDecorator:P.jsx(Dl,{}),sx:s,variant:"outlined",children:o.isLoading?"Starting...":"Stopping..."}):t.enabled?P.jsx(BI,{className:Gt(m1.root,e),color:"success",onClick:()=>{c.mutate({botId:t.id})},size:i,startDecorator:P.jsx(Dl,{}),sx:s,variant:"outlined",children:"Running"}):P.jsx(BI,{className:Gt(m1.root,e),color:"danger",onClick:()=>{o.mutate({botId:t.id})},size:i,startDecorator:P.jsx(Dl,{}),sx:s,variant:"outlined",children:"Disabled"})},RL=({bot:d})=>P.jsxs(Er,{children:[P.jsx(qh,{children:P.jsx(KPe,{})}),P.jsx(to,{children:"Status"}),P.jsx(QPe,{bot:d,size:"lg"})]}),YPe=Ys(P.jsx("path",{d:"M17.06 11.57c.59-.69.94-1.59.94-2.57 0-1.86-1.27-3.43-3-3.87V3h-2v2h-2V3H9v2H6v2h2v10H6v2h3v2h2v-2h2v2h2v-2c2.21 0 4-1.79 4-4 0-1.45-.78-2.73-1.94-3.43M10 7h4c1.1 0 2 .9 2 2s-.9 2-2 2h-4zm5 10h-5v-4h5c1.1 0 2 .9 2 2s-.9 2-2 2"}),"CurrencyBitcoin"),ZPe="CryptoIcon",JPe="https://meta.viewblock.io",DL=({symbol:d,size:e=32})=>P.jsx("img",{alt:d,height:e,src:`${JPe}/${d}/logo`,width:e});DL.displayName=ZPe;const qL=({bot:d})=>{const{baseCurrency:e}=Kd(d.symbol);return P.jsxs(Er,{children:[P.jsx(qh,{children:P.jsx(YPe,{})}),P.jsx(to,{children:"Pair"}),P.jsxs(_t,{alignItems:"center",display:"flex",children:[P.jsx(DL,{size:20,symbol:e}),P.jsx(ot,{sx:{ml:1},textColor:"text.tertiary",children:d.symbol})]})]})},Id=({icon:d,name:e,children:t})=>P.jsxs(Er,{children:[P.jsx(qh,{children:d}),P.jsx(to,{children:e}),P.jsx(ot,{textColor:"text.tertiary",children:t})]}),eIe=({bot:d})=>{const e=UW(d.settings.gridLines),t=GW(d.settings.gridLines),s=HW(d.settings.gridLines),{baseCurrency:i,quoteCurrency:n}=Kd(d.symbol);return P.jsxs(Dh,{children:[P.jsx(RL,{bot:d}),P.jsx(fr,{inset:"startContent"}),P.jsx(qL,{bot:d}),P.jsx(fr,{inset:"startContent"}),P.jsxs(Id,{icon:P.jsx(KW,{}),name:"High price",children:[t," ",n]}),P.jsx(fr,{inset:"startContent"}),P.jsxs(Id,{icon:P.jsx(jPe,{}),name:"Low price",children:[e," ",n]}),P.jsx(fr,{inset:"startContent"}),P.jsxs(Id,{icon:P.jsx($Pe,{}),name:"Av. quantity per grid",children:[s.toFixed(6)," ",i]}),P.jsx(fr,{inset:"startContent"}),P.jsx(Id,{icon:P.jsx(zPe,{}),name:"Grid levels",children:d.settings.gridLines.length}),P.jsx(fr,{inset:"startContent"}),P.jsx(Id,{icon:P.jsx(EL,{}),name:"Template",children:P.jsx(nn,{color:"primary",variant:"soft",children:d.template})})]})},tIe=({botId:d})=>{const[e]=kt.gridBot.getOne.useSuspenseQuery(d),[t]=go();return P.jsxs(fn,{children:[P.jsxs(_t,{display:"flex",justifyContent:"space-between",children:[P.jsx(ot,{fontSize:"xl2",fontWeight:"xl",level:"h3",children:e.name}),P.jsxs(ot,{color:"neutral",fontSize:"xl2",fontWeight:"xl",level:"h3",children:["#",e.id]})]}),P.jsx(eIe,{bot:e}),P.jsx(NL,{children:P.jsx(AL,{bot:e})}),P.jsxs(ML,{children:[P.jsx(LL,{bot:e,href:ai("grid-bot/edit/:id",e.id)}),P.jsx(BL,{bot:e,redirectPath:ai("bot")}),t?P.jsxs(P.Fragment,{children:[P.jsx(Ia,{children:"Debugging"}),P.jsx(PL,{polling:!1}),P.jsx(_L,{bot:e})]}):null]})]})};var sIe=typeof Sc=="object"&&Sc&&Sc.Object===Object&&Sc,iIe=typeof self=="object"&&self&&self.Object===Object&&self;sIe||iIe||Function("return this")();function nIe(){const d=B.useRef(!1);return B.useEffect(()=>(d.current=!0,()=>{d.current=!1}),[]),B.useCallback(()=>d.current,[])}var s5={width:void 0,height:void 0};function rIe(d){const{ref:e,box:t="content-box"}=d,[{width:s,height:i},n]=B.useState(s5),r=nIe(),a=B.useRef({...s5}),o=B.useRef(void 0);return o.current=d.onResize,B.useEffect(()=>{if(!e.current||typeof window>"u"||!("ResizeObserver"in window))return;const c=new ResizeObserver(([u])=>{const h=t==="border-box"?"borderBoxSize":t==="device-pixel-content-box"?"devicePixelContentBoxSize":"contentBoxSize",l=i5(u,h,"inlineSize"),f=i5(u,h,"blockSize");if(a.current.width!==l||a.current.height!==f){const m={width:l,height:f};a.current.width=l,a.current.height=f,o.current?o.current(m):r()&&n(m)}});return c.observe(e.current,{box:t}),()=>{c.disconnect()}},[t,e,r]),{width:s,height:i}}function i5(d,e,t){return d[e]?Array.isArray(d[e])?d[e][0][t]:d[e][t]:e==="contentBoxSize"?d.contentRect[t==="inlineSize"?"width":"height"]:void 0}function li(d){var e=d.width,t=d.height;if(e<0)throw new Error("Negative width is not allowed for Size");if(t<0)throw new Error("Negative height is not allowed for Size");return{width:e,height:t}}function ql(d,e){return d.width===e.width&&d.height===e.height}var aIe=function(){function d(e){var t=this;this._resolutionListener=function(){return t._onResolutionChanged()},this._resolutionMediaQueryList=null,this._observers=[],this._window=e,this._installResolutionListener()}return d.prototype.dispose=function(){this._uninstallResolutionListener(),this._window=null},Object.defineProperty(d.prototype,"value",{get:function(){return this._window.devicePixelRatio},enumerable:!1,configurable:!0}),d.prototype.subscribe=function(e){var t=this,s={next:e};return this._observers.push(s),{unsubscribe:function(){t._observers=t._observers.filter(function(i){return i!==s})}}},d.prototype._installResolutionListener=function(){if(this._resolutionMediaQueryList!==null)throw new Error("Resolution listener is already installed");var e=this._window.devicePixelRatio;this._resolutionMediaQueryList=this._window.matchMedia("all and (resolution: ".concat(e,"dppx)")),this._resolutionMediaQueryList.addListener(this._resolutionListener)},d.prototype._uninstallResolutionListener=function(){this._resolutionMediaQueryList!==null&&(this._resolutionMediaQueryList.removeListener(this._resolutionListener),this._resolutionMediaQueryList=null)},d.prototype._reinstallResolutionListener=function(){this._uninstallResolutionListener(),this._installResolutionListener()},d.prototype._onResolutionChanged=function(){var e=this;this._observers.forEach(function(t){return t.next(e._window.devicePixelRatio)}),this._reinstallResolutionListener()},d}();function oIe(d){return new aIe(d)}var dIe=function(){function d(e,t,s){var i;this._canvasElement=null,this._bitmapSizeChangedListeners=[],this._suggestedBitmapSize=null,this._suggestedBitmapSizeChangedListeners=[],this._devicePixelRatioObservable=null,this._canvasElementResizeObserver=null,this._canvasElement=e,this._canvasElementClientSize=li({width:this._canvasElement.clientWidth,height:this._canvasElement.clientHeight}),this._transformBitmapSize=t??function(n){return n},this._allowResizeObserver=(i=s==null?void 0:s.allowResizeObserver)!==null&&i!==void 0?i:!0,this._chooseAndInitObserver()}return d.prototype.dispose=function(){var e,t;if(this._canvasElement===null)throw new Error("Object is disposed");(e=this._canvasElementResizeObserver)===null||e===void 0||e.disconnect(),this._canvasElementResizeObserver=null,(t=this._devicePixelRatioObservable)===null||t===void 0||t.dispose(),this._devicePixelRatioObservable=null,this._suggestedBitmapSizeChangedListeners.length=0,this._bitmapSizeChangedListeners.length=0,this._canvasElement=null},Object.defineProperty(d.prototype,"canvasElement",{get:function(){if(this._canvasElement===null)throw new Error("Object is disposed");return this._canvasElement},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"canvasElementClientSize",{get:function(){return this._canvasElementClientSize},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"bitmapSize",{get:function(){return li({width:this.canvasElement.width,height:this.canvasElement.height})},enumerable:!1,configurable:!0}),d.prototype.resizeCanvasElement=function(e){this._canvasElementClientSize=li(e),this.canvasElement.style.width="".concat(this._canvasElementClientSize.width,"px"),this.canvasElement.style.height="".concat(this._canvasElementClientSize.height,"px"),this._invalidateBitmapSize()},d.prototype.subscribeBitmapSizeChanged=function(e){this._bitmapSizeChangedListeners.push(e)},d.prototype.unsubscribeBitmapSizeChanged=function(e){this._bitmapSizeChangedListeners=this._bitmapSizeChangedListeners.filter(function(t){return t!==e})},Object.defineProperty(d.prototype,"suggestedBitmapSize",{get:function(){return this._suggestedBitmapSize},enumerable:!1,configurable:!0}),d.prototype.subscribeSuggestedBitmapSizeChanged=function(e){this._suggestedBitmapSizeChangedListeners.push(e)},d.prototype.unsubscribeSuggestedBitmapSizeChanged=function(e){this._suggestedBitmapSizeChangedListeners=this._suggestedBitmapSizeChangedListeners.filter(function(t){return t!==e})},d.prototype.applySuggestedBitmapSize=function(){if(this._suggestedBitmapSize!==null){var e=this._suggestedBitmapSize;this._suggestedBitmapSize=null,this._resizeBitmap(e),this._emitSuggestedBitmapSizeChanged(e,this._suggestedBitmapSize)}},d.prototype._resizeBitmap=function(e){var t=this.bitmapSize;ql(t,e)||(this.canvasElement.width=e.width,this.canvasElement.height=e.height,this._emitBitmapSizeChanged(t,e))},d.prototype._emitBitmapSizeChanged=function(e,t){var s=this;this._bitmapSizeChangedListeners.forEach(function(i){return i.call(s,e,t)})},d.prototype._suggestNewBitmapSize=function(e){var t=this._suggestedBitmapSize,s=li(this._transformBitmapSize(e,this._canvasElementClientSize)),i=ql(this.bitmapSize,s)?null:s;t===null&&i===null||t!==null&&i!==null&&ql(t,i)||(this._suggestedBitmapSize=i,this._emitSuggestedBitmapSizeChanged(t,i))},d.prototype._emitSuggestedBitmapSizeChanged=function(e,t){var s=this;this._suggestedBitmapSizeChangedListeners.forEach(function(i){return i.call(s,e,t)})},d.prototype._chooseAndInitObserver=function(){var e=this;if(!this._allowResizeObserver){this._initDevicePixelRatioObservable();return}uIe().then(function(t){return t?e._initResizeObserver():e._initDevicePixelRatioObservable()})},d.prototype._initDevicePixelRatioObservable=function(){var e=this;if(this._canvasElement!==null){var t=n5(this._canvasElement);if(t===null)throw new Error("No window is associated with the canvas");this._devicePixelRatioObservable=oIe(t),this._devicePixelRatioObservable.subscribe(function(){return e._invalidateBitmapSize()}),this._invalidateBitmapSize()}},d.prototype._invalidateBitmapSize=function(){var e,t;if(this._canvasElement!==null){var s=n5(this._canvasElement);if(s!==null){var i=(t=(e=this._devicePixelRatioObservable)===null||e===void 0?void 0:e.value)!==null&&t!==void 0?t:s.devicePixelRatio,n=this._canvasElement.getClientRects(),r=n[0]!==void 0?hIe(n[0],i):li({width:this._canvasElementClientSize.width*i,height:this._canvasElementClientSize.height*i});this._suggestNewBitmapSize(r)}}},d.prototype._initResizeObserver=function(){var e=this;this._canvasElement!==null&&(this._canvasElementResizeObserver=new ResizeObserver(function(t){var s=t.find(function(r){return r.target===e._canvasElement});if(!(!s||!s.devicePixelContentBoxSize||!s.devicePixelContentBoxSize[0])){var i=s.devicePixelContentBoxSize[0],n=li({width:i.inlineSize,height:i.blockSize});e._suggestNewBitmapSize(n)}}),this._canvasElementResizeObserver.observe(this._canvasElement,{box:"device-pixel-content-box"}))},d}();function cIe(d,e){if(e.type==="device-pixel-content-box")return new dIe(d,e.transform,e.options);throw new Error("Unsupported binding target")}function n5(d){return d.ownerDocument.defaultView}function uIe(){return new Promise(function(d){var e=new ResizeObserver(function(t){d(t.every(function(s){return"devicePixelContentBoxSize"in s})),e.disconnect()});e.observe(document.body,{box:"device-pixel-content-box"})}).catch(function(){return!1})}function hIe(d,e){return li({width:Math.round(d.left*e+d.width*e)-Math.round(d.left*e),height:Math.round(d.top*e+d.height*e)-Math.round(d.top*e)})}var lIe=function(){function d(e,t,s){if(t.width===0||t.height===0)throw new TypeError("Rendering target could only be created on a media with positive width and height");if(this._mediaSize=t,s.width===0||s.height===0)throw new TypeError("Rendering target could only be created using a bitmap with positive integer width and height");this._bitmapSize=s,this._context=e}return d.prototype.useMediaCoordinateSpace=function(e){try{return this._context.save(),this._context.setTransform(1,0,0,1,0,0),this._context.scale(this._horizontalPixelRatio,this._verticalPixelRatio),e({context:this._context,mediaSize:this._mediaSize})}finally{this._context.restore()}},d.prototype.useBitmapCoordinateSpace=function(e){try{return this._context.save(),this._context.setTransform(1,0,0,1,0,0),e({context:this._context,mediaSize:this._mediaSize,bitmapSize:this._bitmapSize,horizontalPixelRatio:this._horizontalPixelRatio,verticalPixelRatio:this._verticalPixelRatio})}finally{this._context.restore()}},Object.defineProperty(d.prototype,"_horizontalPixelRatio",{get:function(){return this._bitmapSize.width/this._mediaSize.width},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"_verticalPixelRatio",{get:function(){return this._bitmapSize.height/this._mediaSize.height},enumerable:!1,configurable:!0}),d}();function tf(d,e){var t=d.canvasElementClientSize;if(t.width===0||t.height===0)return null;var s=d.bitmapSize;if(s.width===0||s.height===0)return null;var i=d.canvasElement.getContext("2d",e);return i===null?null:new lIe(i,t,s)}/*! * @license * TradingView Lightweight Charts™ v4.2.2 * Copyright (c) 2024 TradingView, Inc. @@ -202,15 +202,15 @@ export default theme;`}function d2(d={},...e){const{breakpoints:t,mixins:s={},sp `}i&&(s=s-256);const o=new Ey(s);for(let c=e+1;c=u;--h)a+=c>>h&1?"1":"0";if(a.length>s)return r+hm(a,s)}return r+a}parseOctetString(e,t,s){if(this.isASCII(e,t))return hm(this.parseStringISO(e,t),s);const i=t-e;let n="("+i+` byte) `;s/=2,i>s&&(t=e+s);for(let r=e;rs&&(n+=Zj),n}parseOID(e,t,s){let i="",n=new Ey,r=0;for(let a=e;as)return hm(i,s);n=new Ey,r=0}}return r>0&&(i+=".incomplete"),i}}class xl{constructor(e,t,s,i,n){if(!(i instanceof r3))throw new Error("Invalid tag value.");this.stream=e,this.header=t,this.length=s,this.tag=i,this.sub=n}typeName(){switch(this.tag.tagClass){case 0:switch(this.tag.tagNumber){case 0:return"EOC";case 1:return"BOOLEAN";case 2:return"INTEGER";case 3:return"BIT_STRING";case 4:return"OCTET_STRING";case 5:return"NULL";case 6:return"OBJECT_IDENTIFIER";case 7:return"ObjectDescriptor";case 8:return"EXTERNAL";case 9:return"REAL";case 10:return"ENUMERATED";case 11:return"EMBEDDED_PDV";case 12:return"UTF8String";case 16:return"SEQUENCE";case 17:return"SET";case 18:return"NumericString";case 19:return"PrintableString";case 20:return"TeletexString";case 21:return"VideotexString";case 22:return"IA5String";case 23:return"UTCTime";case 24:return"GeneralizedTime";case 25:return"GraphicString";case 26:return"VisibleString";case 27:return"GeneralString";case 28:return"UniversalString";case 30:return"BMPString"}return"Universal_"+this.tag.tagNumber.toString();case 1:return"Application_"+this.tag.tagNumber.toString();case 2:return"["+this.tag.tagNumber.toString()+"]";case 3:return"Private_"+this.tag.tagNumber.toString()}}content(e){if(this.tag===void 0)return null;e===void 0&&(e=1/0);const t=this.posContent(),s=Math.abs(this.length);if(!this.tag.isUniversal())return this.sub!==null?"("+this.sub.length+" elem)":this.stream.parseOctetString(t,t+s,e);switch(this.tag.tagNumber){case 1:return this.stream.get(t)===0?"false":"true";case 2:return this.stream.parseInteger(t,t+s);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(t,t+s,e);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(t,t+s,e);case 6:return this.stream.parseOID(t,t+s,e);case 16:case 17:return this.sub!==null?"("+this.sub.length+" elem)":"(no elem)";case 12:return hm(this.stream.parseStringUTF(t,t+s),e);case 18:case 19:case 20:case 21:case 22:case 26:return hm(this.stream.parseStringISO(t,t+s),e);case 30:return hm(this.stream.parseStringBMP(t,t+s),e);case 23:case 24:return this.stream.parseTime(t,t+s,this.tag.tagNumber==23)}return null}toString(){return this.typeName()+"@"+this.stream.pos+"[header:"+this.header+",length:"+this.length+",sub:"+(this.sub===null?"null":this.sub.length)+"]"}toPrettyString(e){e===void 0&&(e="");let t=e+this.typeName()+" @"+this.stream.pos;if(this.length>=0&&(t+="+"),t+=this.length,this.tag.tagConstructed?t+=" (constructed)":this.tag.isUniversal()&&(this.tag.tagNumber==3||this.tag.tagNumber==4)&&this.sub!==null&&(t+=" (encapsulates)"),t+=` -`,this.sub!==null){e+=" ";for(let s=0,i=this.sub.length;s6)throw new Error("Length over 48 bits not supported at position "+(e.pos-1));if(s===0)return null;t=0;for(let i=0;i>6,this.tagConstructed=(t&32)!==0,this.tagNumber=t&31,this.tagNumber==31){const s=new Ey;do t=e.get(),s.mulAdd(128,t&127);while(t&128);this.tagNumber=s.simplify()}}isUniversal(){return this.tagClass===0}isEOC(){return this.tagClass===0&&this.tagNumber===0}}function sAe(d,e,t,s){if(typeof d.setBigUint64=="function")return d.setBigUint64(e,t,s);const i=BigInt(32),n=BigInt(4294967295),r=Number(t>>i&n),a=Number(t&n),o=s?4:0,c=s?0:4;d.setUint32(e+o,r,s),d.setUint32(e+c,a,s)}class cB extends WO{constructor(e,t,s,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=s,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=sC(this.buffer)}update(e){ua.exists(this);const{view:t,buffer:s,blockLen:i}=this;e=hg(e);const n=e.length;for(let r=0;ri-r&&(this.process(s,0),r=0);for(let h=r;hu.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;hd&e^~d&t,nAe=(d,e,t)=>d&e^d&t^e&t,rAe=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),xu=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Pu=new Uint32Array(64);class Jj extends cB{constructor(){super(64,32,8,!1),this.A=xu[0]|0,this.B=xu[1]|0,this.C=xu[2]|0,this.D=xu[3]|0,this.E=xu[4]|0,this.F=xu[5]|0,this.G=xu[6]|0,this.H=xu[7]|0}get(){const{A:e,B:t,C:s,D:i,E:n,F:r,G:a,H:o}=this;return[e,t,s,i,n,r,a,o]}set(e,t,s,i,n,r,a,o){this.A=e|0,this.B=t|0,this.C=s|0,this.D=i|0,this.E=n|0,this.F=r|0,this.G=a|0,this.H=o|0}process(e,t){for(let h=0;h<16;h++,t+=4)Pu[h]=e.getUint32(t,!1);for(let h=16;h<64;h++){const l=Pu[h-15],f=Pu[h-2],p=pd(l,7)^pd(l,18)^l>>>3,m=pd(f,17)^pd(f,19)^f>>>10;Pu[h]=m+Pu[h-7]+p+Pu[h-16]|0}let{A:s,B:i,C:n,D:r,E:a,F:o,G:c,H:u}=this;for(let h=0;h<64;h++){const l=pd(a,6)^pd(a,11)^pd(a,25),f=u+l+iAe(a,o,c)+rAe[h]+Pu[h]|0,m=(pd(s,2)^pd(s,13)^pd(s,22))+nAe(s,i,n)|0;u=c,c=o,o=a,a=r+f|0,r=n,n=i,i=s,s=f+m|0}s=s+this.A|0,i=i+this.B|0,n=n+this.C|0,r=r+this.D|0,a=a+this.E|0,o=o+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(s,i,n,r,a,o,c,u)}roundClean(){Pu.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class aAe extends Jj{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}const He=ru(()=>new Jj);ru(()=>new aAe);const On=BigInt(0),Vi=BigInt(1),gl=BigInt(2),oAe=BigInt(3),P2=BigInt(4),a3=BigInt(5),o3=BigInt(8);BigInt(9);BigInt(16);function Ps(d,e){const t=d%e;return t>=On?t:e+t}function e7(d,e,t){if(t<=On||e 0");if(t===Vi)return On;let s=Vi;for(;e>On;)e&Vi&&(s=s*d%t),d=d*d%t,e>>=Vi;return s}function xi(d,e,t){let s=d;for(;e-- >On;)s*=s,s%=t;return s}function Wv(d,e){if(d===On||e<=On)throw new Error(`invert: expected positive integers, got n=${d} mod=${e}`);let t=Ps(d,e),s=e,i=On,n=Vi;for(;t!==On;){const a=s/t,o=s%t,c=i-n*a;s=t,t=o,i=n,n=c}if(s!==Vi)throw new Error("invert: does not exist");return Ps(i,e)}function dAe(d){const e=(d-Vi)/gl;let t,s,i;for(t=d-Vi,s=0;t%gl===On;t/=gl,s++);for(i=gl;i(Ps(d,e)&Vi)===Vi,uAe=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function zO(d){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=uAe.reduce((s,i)=>(s[i]="function",s),e);return Wh(d,t)}function t7(d,e,t){if(t 0");if(t===On)return d.ONE;if(t===Vi)return e;let s=d.ONE,i=e;for(;t>On;)t&Vi&&(s=d.mul(s,i)),i=d.sqr(i),t>>=1n;return s}function hAe(d,e){const t=new Array(e.length),s=e.reduce((n,r,a)=>d.is0(r)?n:(t[a]=n,d.mul(n,r)),d.ONE),i=d.inv(s);return e.reduceRight((n,r,a)=>d.is0(r)?n:(t[a]=d.mul(n,t[a]),d.mul(n,r)),i),t}function uB(d,e){const t=e!==void 0?e:d.toString(2).length,s=Math.ceil(t/8);return{nBitLength:t,nByteLength:s}}function kb(d,e,t=!1,s={}){if(d<=On)throw new Error(`Expected Fp ORDER > 0, got ${d}`);const{nBitLength:i,nByteLength:n}=uB(d,e);if(n>2048)throw new Error("Field lengths over 2048 bytes are not supported");const r=cAe(d),a=Object.freeze({ORDER:d,BITS:i,BYTES:n,MASK:GO(i),ZERO:On,ONE:Vi,create:o=>Ps(o,d),isValid:o=>{if(typeof o!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof o}`);return On<=o&&oo===On,isOdd:o=>(o&Vi)===Vi,neg:o=>Ps(-o,d),eql:(o,c)=>o===c,sqr:o=>Ps(o*o,d),add:(o,c)=>Ps(o+c,d),sub:(o,c)=>Ps(o-c,d),mul:(o,c)=>Ps(o*c,d),pow:(o,c)=>t7(a,o,c),div:(o,c)=>Ps(o*Wv(c,d),d),sqrN:o=>o*o,addN:(o,c)=>o+c,subN:(o,c)=>o-c,mulN:(o,c)=>o*c,inv:o=>Wv(o,d),sqrt:s.sqrt||(o=>r(a,o)),invertBatch:o=>hAe(a,o),cmov:(o,c,u)=>u?c:o,toBytes:o=>t?Fd(o,n):Dc(o,n),fromBytes:o=>{if(o.length!==n)throw new Error(`Fp.fromBytes: expected ${n}, got ${o.length}`);return t?Ld(o):Ki(o)}});return Object.freeze(a)}function lAe(d,e){if(!d.isOdd)throw new Error("Field doesn't have isOdd");const t=d.sqrt(e);return d.isOdd(t)?d.neg(t):t}function fAe(d,e,t=!1){d=xs("privateHash",d);const s=d.length,i=uB(e).nByteLength+8;if(i<24||s1024)throw new Error(`hashToPrivateScalar: expected ${i}-1024 bytes of input, got ${s}`);const n=t?Ld(d):Ki(d);return Ps(n,e-Vi)+Vi}const pAe=BigInt(0),iC=BigInt(1);function s7(d,e){const t=(i,n)=>{const r=n.negate();return i?r:n},s=i=>{const n=Math.ceil(e/i)+1,r=2**(i-1);return{windows:n,windowSize:r}};return{constTimeNegate:t,unsafeLadder(i,n){let r=d.ZERO,a=i;for(;n>pAe;)n&iC&&(r=r.add(a)),a=a.double(),n>>=iC;return r},precomputeWindow(i,n){const{windows:r,windowSize:a}=s(n),o=[];let c=i,u=c;for(let h=0;h>=f,g>o&&(g-=l,r+=iC);const y=m,w=m+Math.abs(g)-1,b=p%2!==0,S=g<0;g===0?u=u.add(t(b,n[y])):c=c.add(t(S,n[w]))}return{p:c,f:u}},wNAFCached(i,n,r,a){const o=i._WINDOW_SIZE||1;let c=n.get(i);return c||(c=this.precomputeWindow(i,o),o!==1&&n.set(i,a(c))),this.wNAF(o,c,r)}}}function hB(d){return zO(d.Fp),Wh(d,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...uB(d.n,d.nBitLength),...d})}function mAe(d){const e=hB(d);Wh(e,{a:"field",b:"field",fromBytes:"function",toBytes:"function"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean"});const{endo:t,Fp:s,a:i}=e;if(t){if(!s.eql(i,s.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:gAe,hexToBytes:yAe}=Y2e,Pl={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(d){const{Err:e}=Pl;if(d.length<2||d[0]!==2)throw new e("Invalid signature integer tag");const t=d[1],s=d.subarray(2,t+2);if(!t||s.length!==t)throw new e("Invalid signature integer: wrong length");if(s[0]===0&&s[1]<=127)throw new e("Invalid signature integer: trailing length");return{d:gAe(s),l:d.subarray(t+2)}},toSig(d){const{Err:e}=Pl,t=typeof d=="string"?yAe(d):d;if(!(t instanceof Uint8Array))throw new Error("ui8a expected");let s=t.length;if(s<2||t[0]!=48)throw new e("Invalid signature tag");if(t[1]!==s-2)throw new e("Invalid signature: incorrect length");const{d:i,l:n}=Pl._parseInt(t.subarray(2)),{d:r,l:a}=Pl._parseInt(n);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s:r}},hexFromSig(d){const e=c=>Number.parseInt(c[0],16)>=8?"00"+c:c,t=c=>{const u=c.toString(16);return u.length&1?`0${u}`:u},s=e(t(d.s)),i=e(t(d.r)),n=s.length/2,r=i.length/2,a=t(n),o=t(r);return`30${t(r+n+4)}02${o}${i}02${a}${s}`}},Oc=BigInt(0),Ka=BigInt(1);function wAe(d){const e=mAe(d),{Fp:t}=e;function s(l){const{a:f,b:p}=e,m=t.sqr(l),g=t.mul(m,l);return t.add(t.add(g,t.mul(l,f)),p)}function i(l){return typeof l=="bigint"&&Oct.eql(y,t.ZERO);return g(p)&&g(m)?c.ZERO:new c(p,m,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(f){const p=t.invertBatch(f.map(m=>m.pz));return f.map((m,g)=>m.toAffine(p[g])).map(c.fromAffine)}static fromHex(f){const p=c.fromAffine(e.fromBytes(xs("pointHex",f)));return p.assertValidity(),p}static fromPrivateKey(f){return c.BASE.multiply(r(f))}_setWindowSize(f){this._WINDOW_SIZE=f,a.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint)return;throw new Error("bad point: ZERO")}const{x:f,y:p}=this.toAffine();if(!t.isValid(f)||!t.isValid(p))throw new Error("bad point: x or y not FE");const m=t.sqr(p),g=s(f);if(!t.eql(m,g))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:f}=this.toAffine();if(t.isOdd)return!t.isOdd(f);throw new Error("Field doesn't support isOdd")}equals(f){o(f);const{px:p,py:m,pz:g}=this,{px:y,py:w,pz:b}=f,S=t.eql(t.mul(p,b),t.mul(y,g)),v=t.eql(t.mul(m,b),t.mul(w,g));return S&&v}negate(){return new c(this.px,t.neg(this.py),this.pz)}double(){const{a:f,b:p}=e,m=t.mul(p,3n),{px:g,py:y,pz:w}=this;let b=t.ZERO,S=t.ZERO,v=t.ZERO,C=t.mul(g,g),M=t.mul(y,y),_=t.mul(w,w),N=t.mul(g,y);return N=t.add(N,N),v=t.mul(g,w),v=t.add(v,v),b=t.mul(f,v),S=t.mul(m,_),S=t.add(b,S),b=t.sub(M,S),S=t.add(M,S),S=t.mul(b,S),b=t.mul(N,b),v=t.mul(m,v),_=t.mul(f,_),N=t.sub(C,_),N=t.mul(f,N),N=t.add(N,v),v=t.add(C,C),C=t.add(v,C),C=t.add(C,_),C=t.mul(C,N),S=t.add(S,C),_=t.mul(y,w),_=t.add(_,_),C=t.mul(_,N),b=t.sub(b,C),v=t.mul(_,M),v=t.add(v,v),v=t.add(v,v),new c(b,S,v)}add(f){o(f);const{px:p,py:m,pz:g}=this,{px:y,py:w,pz:b}=f;let S=t.ZERO,v=t.ZERO,C=t.ZERO;const M=e.a,_=t.mul(e.b,3n);let N=t.mul(p,y),A=t.mul(m,w),R=t.mul(g,b),D=t.add(p,m),U=t.add(y,w);D=t.mul(D,U),U=t.add(N,A),D=t.sub(D,U),U=t.add(p,g);let K=t.add(y,b);return U=t.mul(U,K),K=t.add(N,R),U=t.sub(U,K),K=t.add(m,g),S=t.add(w,b),K=t.mul(K,S),S=t.add(A,R),K=t.sub(K,S),C=t.mul(M,U),S=t.mul(_,R),C=t.add(S,C),S=t.sub(A,C),C=t.add(A,C),v=t.mul(S,C),A=t.add(N,N),A=t.add(A,N),R=t.mul(M,R),U=t.mul(_,U),A=t.add(A,R),R=t.sub(N,R),R=t.mul(M,R),U=t.add(U,R),N=t.mul(A,U),v=t.add(v,N),N=t.mul(K,U),S=t.mul(D,S),S=t.sub(S,N),N=t.mul(D,A),C=t.mul(K,C),C=t.add(C,N),new c(S,v,C)}subtract(f){return this.add(f.negate())}is0(){return this.equals(c.ZERO)}wNAF(f){return h.wNAFCached(this,a,f,p=>{const m=t.invertBatch(p.map(g=>g.pz));return p.map((g,y)=>g.toAffine(m[y])).map(c.fromAffine)})}multiplyUnsafe(f){const p=c.ZERO;if(f===Oc)return p;if(n(f),f===Ka)return this;const{endo:m}=e;if(!m)return h.unsafeLadder(this,f);let{k1neg:g,k1:y,k2neg:w,k2:b}=m.splitScalar(f),S=p,v=p,C=this;for(;y>Oc||b>Oc;)y&Ka&&(S=S.add(C)),b&Ka&&(v=v.add(C)),C=C.double(),y>>=Ka,b>>=Ka;return g&&(S=S.negate()),w&&(v=v.negate()),v=new c(t.mul(v.px,m.beta),v.py,v.pz),S.add(v)}multiply(f){n(f);let p=f,m,g;const{endo:y}=e;if(y){const{k1neg:w,k1:b,k2neg:S,k2:v}=y.splitScalar(p);let{p:C,f:M}=this.wNAF(b),{p:_,f:N}=this.wNAF(v);C=h.constTimeNegate(w,C),_=h.constTimeNegate(S,_),_=new c(t.mul(_.px,y.beta),_.py,_.pz),m=C.add(_),g=M.add(N)}else{const{p:w,f:b}=this.wNAF(p);m=w,g=b}return c.normalizeZ([m,g])[0]}multiplyAndAddUnsafe(f,p,m){const g=c.BASE,y=(b,S)=>S===Oc||S===Ka||!b.equals(g)?b.multiplyUnsafe(S):b.multiply(S),w=y(this,p).add(y(f,m));return w.is0()?void 0:w}toAffine(f){const{px:p,py:m,pz:g}=this,y=this.is0();f==null&&(f=y?t.ONE:t.inv(g));const w=t.mul(p,f),b=t.mul(m,f),S=t.mul(g,f);if(y)return{x:t.ZERO,y:t.ZERO};if(!t.eql(S,t.ONE))throw new Error("invZ was invalid");return{x:w,y:b}}isTorsionFree(){const{h:f,isTorsionFree:p}=e;if(f===Ka)return!0;if(p)return p(c,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:f,clearCofactor:p}=e;return f===Ka?this:p?p(c,this):this.multiplyUnsafe(e.h)}toRawBytes(f=!0){return this.assertValidity(),e.toBytes(c,this,f)}toHex(f=!0){return jd(this.toRawBytes(f))}}c.BASE=new c(e.Gx,e.Gy,t.ONE),c.ZERO=new c(t.ZERO,t.ONE,t.ZERO);const u=e.nBitLength,h=s7(c,e.endo?Math.ceil(u/2):u);return{ProjectivePoint:c,normPrivateKeyToScalar:r,weierstrassEquation:s,isWithinCurveOrder:i}}function bAe(d){const e=hB(d);return Wh(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function i7(d){const e=bAe(d),t=e.n,s=e.Fp,i=s.BYTES+1,n=2*s.BYTES+1;function r(j){return Ocjd(Dc(j,e.nByteLength));function p(j){const z=t>>Ka;return j>z}function m(j){return p(j)?a(-j):j}const g=(j,z,J)=>Ki(j.slice(z,J));class y{constructor(z,J,Y){this.r=z,this.s=J,this.recovery=Y,this.assertValidity()}static fromCompact(z){const J=e.nByteLength;return z=xs("compactSignature",z,J*2),new y(g(z,0,J),g(z,J,2*J))}static fromDER(z){const{r:J,s:Y}=Pl.toSig(xs("DER",z));return new y(J,Y)}assertValidity(){if(!l(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!l(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(z){return new y(this.r,this.s,z)}recoverPublicKey(z){const{r:J,s:Y,recovery:X}=this,Z=M(xs("msgHash",z));if(X==null||![0,1,2,3].includes(X))throw new Error("recovery id invalid");const te=X===2||X===3?J+e.n:J;if(te>=s.ORDER)throw new Error("recovery id 2 or 3 invalid");const Q=X&1?"03":"02",ie=c.fromHex(Q+f(te)),ne=o(te),oe=a(-Z*ne),me=a(Y*ne),fe=c.BASE.multiplyAndAddUnsafe(ie,oe,me);if(!fe)throw new Error("point at infinify");return fe.assertValidity(),fe}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new y(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return af(this.toDERHex())}toDERHex(){return Pl.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return af(this.toCompactHex())}toCompactHex(){return f(this.r)+f(this.s)}}const w={isValidPrivateKey(j){try{return u(j),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{const j=e.randomBytes(s.BYTES+8),z=fAe(j,t);return Dc(z,e.nByteLength)},precompute(j=8,z=c.BASE){return z._setWindowSize(j),z.multiply(BigInt(3)),z}};function b(j,z=!0){return c.fromPrivateKey(j).toRawBytes(z)}function S(j){const z=j instanceof Uint8Array,J=typeof j=="string",Y=(z||J)&&j.length;return z?Y===i||Y===n:J?Y===2*i||Y===2*n:j instanceof c}function v(j,z,J=!0){if(S(j))throw new Error("first arg must be private key");if(!S(z))throw new Error("second arg must be public key");return c.fromHex(z).multiply(u(j)).toRawBytes(J)}const C=e.bits2int||function(j){const z=Ki(j),J=j.length*8-e.nBitLength;return J>0?z>>BigInt(J):z},M=e.bits2int_modN||function(j){return a(C(j))},_=GO(e.nBitLength);function N(j){if(typeof j!="bigint")throw new Error("bigint expected");if(!(Oc<=j&&j<_))throw new Error(`bigint expected < 2^${e.nBitLength}`);return Dc(j,e.nByteLength)}function A(j,z,J=R){if(["recovered","canonical"].some(Se=>Se in J))throw new Error("sign() legacy options not supported");const{hash:Y,randomBytes:X}=e;let{lowS:Z,prehash:te,extraEntropy:Q}=J;Z==null&&(Z=!0),j=xs("msgHash",j),te&&(j=xs("prehashed msgHash",Y(j)));const ie=M(j),ne=u(z),oe=[N(ne),N(ie)];if(Q!=null){const Se=Q===!0?X(s.BYTES):Q;oe.push(xs("extraEntropy",Se,s.BYTES))}const me=vn(...oe),fe=ie;function he(Se){const ye=C(Se);if(!l(ye))return;const ge=o(ye),Te=c.BASE.multiply(ye).toAffine(),Ge=a(Te.x);if(Ge===Oc)return;const Ye=a(ge*a(fe+Ge*ne));if(Ye===Oc)return;let Re=(Te.x===Ge?0:2)|Number(Te.y&Ka),Be=Ye;return Z&&p(Ye)&&(Be=m(Ye),Re^=1),new y(Ge,Be,Re)}return{seed:me,k2sig:he}}const R={lowS:e.lowS,prehash:!1},D={lowS:e.lowS,prehash:!1};function U(j,z,J=R){const{seed:Y,k2sig:X}=A(j,z,J);return Fj(e.hash.outputLen,e.nByteLength,e.hmac)(Y,X)}c.BASE._setWindowSize(8);function K(j,z,J,Y=D){var Te;const X=j;if(z=xs("msgHash",z),J=xs("publicKey",J),"strict"in Y)throw new Error("options.strict was renamed to lowS");const{lowS:Z,prehash:te}=Y;let Q,ie;try{if(typeof X=="string"||X instanceof Uint8Array)try{Q=y.fromDER(X)}catch(Ge){if(!(Ge instanceof Pl.Err))throw Ge;Q=y.fromCompact(X)}else if(typeof X=="object"&&typeof X.r=="bigint"&&typeof X.s=="bigint"){const{r:Ge,s:Ye}=X;Q=new y(Ge,Ye)}else throw new Error("PARSE");ie=c.fromHex(J)}catch(Ge){if(Ge.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(Z&&Q.hasHighS())return!1;te&&(z=e.hash(z));const{r:ne,s:oe}=Q,me=M(z),fe=o(oe),he=a(me*fe),Se=a(ne*fe),ye=(Te=c.BASE.multiplyAndAddUnsafe(ie,he,Se))==null?void 0:Te.toAffine();return ye?a(ye.x)===ne:!1}return{CURVE:e,getPublicKey:b,getSharedSecret:v,sign:U,verify:K,ProjectivePoint:c,Signature:y,utils:w}}function kAe(d,e){const t=d.ORDER;let s=0n;for(let l=t-1n;l%2n===0n;l/=2n)s+=1n;const i=s,n=(t-1n)/2n**i,r=(n-1n)/2n,a=2n**i-1n,o=2n**(i-1n),c=d.pow(e,n),u=d.pow(e,(n+1n)/2n);let h=(l,f)=>{let p=c,m=d.pow(f,a),g=d.sqr(m);g=d.mul(g,f);let y=d.mul(l,g);y=d.pow(y,r),y=d.mul(y,m),m=d.mul(y,f),g=d.mul(y,l);let w=d.mul(g,m);y=d.pow(w,o);let b=d.eql(y,d.ONE);m=d.mul(g,u),y=d.mul(w,p),g=d.cmov(m,g,b),w=d.cmov(y,w,b);for(let S=i;S>1;S--){let v=2n**(S-2n),C=d.pow(w,v);const M=d.eql(C,d.ONE);m=d.mul(g,p),p=d.mul(p,p),C=d.mul(w,p),g=d.cmov(m,g,M),w=d.cmov(C,w,M)}return{isValid:b,value:g}};if(d.ORDER%4n===3n){const l=(d.ORDER-3n)/4n,f=d.sqrt(d.neg(e));h=(p,m)=>{let g=d.sqr(m);const y=d.mul(p,m);g=d.mul(g,y);let w=d.pow(g,l);w=d.mul(w,y);const b=d.mul(w,f),S=d.mul(d.sqr(w),m),v=d.eql(S,p);let C=d.cmov(b,w,v);return{isValid:v,value:C}}}return h}function n7(d,e){if(zO(d),!d.isValid(e.A)||!d.isValid(e.B)||!d.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const t=kAe(d,e.Z);if(!d.isOdd)throw new Error("Fp.isOdd is not implemented!");return s=>{let i,n,r,a,o,c,u,h;i=d.sqr(s),i=d.mul(i,e.Z),n=d.sqr(i),n=d.add(n,i),r=d.add(n,d.ONE),r=d.mul(r,e.B),a=d.cmov(e.Z,d.neg(n),!d.eql(n,d.ZERO)),a=d.mul(a,e.A),n=d.sqr(r),c=d.sqr(a),o=d.mul(c,e.A),n=d.add(n,o),n=d.mul(n,r),c=d.mul(c,a),o=d.mul(c,e.B),n=d.add(n,o),u=d.mul(i,r);const{isValid:l,value:f}=t(n,c);h=d.mul(i,s),h=d.mul(h,f),u=d.cmov(u,r,l),h=d.cmov(h,f,l);const p=d.isOdd(s)===d.isOdd(h);return h=d.cmov(d.neg(h),h,p),u=d.div(u,a),{x:u,y:h}}}function SAe(d){if(d instanceof Uint8Array)return d;if(typeof d=="string")return HO(d);throw new Error("DST must be Uint8Array or string")}const vAe=Ki;function Du(d,e){if(d<0||d>=1<<8*e)throw new Error(`bad I2OSP call: value=${d} length=${e}`);const t=Array.from({length:e}).fill(0);for(let s=e-1;s>=0;s--)t[s]=d&255,d>>>=8;return new Uint8Array(t)}function TAe(d,e){const t=new Uint8Array(d.length);for(let s=0;s255&&(e=s(vn(HO("H2C-OVERSIZE-DST-"),e)));const{outputLen:i,blockLen:n}=s,r=Math.ceil(t/i);if(r>255)throw new Error("Invalid xmd length");const a=vn(e,Du(e.length,1)),o=Du(0,n),c=Du(t,2),u=new Array(r),h=s(vn(o,d,c,Du(0,1),a));u[0]=s(vn(h,Du(1,1),a));for(let f=1;f<=r;f++){const p=[TAe(h,u[f-1]),Du(f+1,1),a];u[f]=s(vn(...p))}return vn(...u).slice(0,t)}function xAe(d,e,t,s,i){if(kw(d),kw(e),lB(t),e.length>255){const n=Math.ceil(2*s/8);e=i.create({dkLen:n}).update(HO("H2C-OVERSIZE-DST-")).update(e).digest()}if(t>65535||e.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:t}).update(d).update(Du(t,2)).update(e).update(Du(e.length,1)).digest()}function d3(d,e,t){Wh(t,{DST:"string",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});const{p:s,k:i,m:n,hash:r,expand:a,DST:o}=t;kw(d),lB(e);const c=SAe(o),u=s.toString(2).length,h=Math.ceil((u+i)/8),l=e*n*h;let f;if(a==="xmd")f=OAe(d,c,l,r);else if(a==="xof")f=xAe(d,c,l,i,r);else if(a===void 0)f=d;else throw new Error('expand must be "xmd", "xof" or undefined');const p=new Array(e);for(let m=0;mArray.from(s).reverse());return(s,i)=>{const[n,r,a,o]=t.map(c=>c.reduce((u,h)=>d.add(d.mul(u,s),h)));return s=d.div(n,r),i=d.mul(i,d.div(a,o)),{x:s,y:i}}}function fB(d,e,t){if(typeof e!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(s,i){const n=d3(s,2,{...t,DST:t.DST,...i}),r=d.fromAffine(e(n[0])),a=d.fromAffine(e(n[1])),o=r.add(a).clearCofactor();return o.assertValidity(),o},encodeToCurve(s,i){const n=d3(s,1,{...t,DST:t.encodeDST,...i}),r=d.fromAffine(e(n[0])).clearCofactor();return r.assertValidity(),r}}}function r7(d){return{hash:d,hmac:(e,...t)=>dB(d,e,oB(...t)),randomBytes:jO}}function a7(d,e){const t=s=>i7({...d,...r7(s)});return Object.freeze({...t(e),create:t})}const $O=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),jv=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),o7=BigInt(1),I2=BigInt(2),c3=(d,e)=>(d+e/I2)/e;function d7(d){const e=$O,t=BigInt(3),s=BigInt(6),i=BigInt(11),n=BigInt(22),r=BigInt(23),a=BigInt(44),o=BigInt(88),c=d*d*d%e,u=c*c*d%e,h=xi(u,t,e)*u%e,l=xi(h,t,e)*u%e,f=xi(l,I2,e)*c%e,p=xi(f,i,e)*f%e,m=xi(p,n,e)*p%e,g=xi(m,a,e)*m%e,y=xi(g,o,e)*g%e,w=xi(y,a,e)*m%e,b=xi(w,t,e)*u%e,S=xi(b,r,e)*p%e,v=xi(S,s,e)*c%e,C=xi(v,I2,e);if(!Ch.eql(Ch.sqr(C),d))throw new Error("Cannot find square root");return C}const Ch=kb($O,void 0,void 0,{sqrt:d7}),Qd=a7({a:BigInt(0),b:BigInt(7),Fp:Ch,n:jv,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:d=>{const e=jv,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),s=-o7*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),n=t,r=BigInt("0x100000000000000000000000000000000"),a=c3(n*d,e),o=c3(-s*d,e);let c=Ps(d-a*t-o*i,e),u=Ps(-a*s-o*n,e);const h=c>r,l=u>r;if(h&&(c=e-c),l&&(u=e-u),c>r||u>r)throw new Error("splitScalar: Endomorphism failed, k="+d);return{k1neg:h,k1:c,k2neg:l,k2:u}}}},He),pB=BigInt(0),c7=d=>typeof d=="bigint"&&pBtypeof d=="bigint"&&pBi.charCodeAt(0)));t=vn(s,s),u3[d]=t}return He(vn(t,...e))}const mB=d=>d.toRawBytes(!0).slice(1),C2=d=>Dc(d,32),nC=d=>Ps(d,$O),Sw=d=>Ps(d,jv),gB=Qd.ProjectivePoint,CAe=(d,e,t)=>gB.BASE.multiplyAndAddUnsafe(d,e,t);function M2(d){let e=Qd.utils.normPrivateKeyToScalar(d),t=gB.fromPrivateKey(e);return{scalar:t.hasEvenY()?e:Sw(-e),bytes:mB(t)}}function u7(d){if(!c7(d))throw new Error("bad x: need 0 < x < p");const e=nC(d*d),t=nC(e*d+BigInt(7));let s=d7(t);s%2n!==0n&&(s=nC(-s));const i=new gB(d,s,o7);return i.assertValidity(),i}function h7(...d){return Sw(Ki(zv("BIP0340/challenge",...d)))}function MAe(d){return M2(d).bytes}function _Ae(d,e,t=jO(32)){const s=xs("message",d),{bytes:i,scalar:n}=M2(e),r=xs("auxRand",t,32),a=C2(n^Ki(zv("BIP0340/aux",r))),o=zv("BIP0340/nonce",a,i,s),c=Sw(Ki(o));if(c===pB)throw new Error("sign failed: k is zero");const{bytes:u,scalar:h}=M2(c),l=h7(u,i,s),f=new Uint8Array(64);if(f.set(u,0),f.set(C2(Sw(h+l*n)),32),!l7(f,s,i))throw new Error("sign: Invalid signature produced");return f}function l7(d,e,t){const s=xs("signature",d,64),i=xs("message",e),n=xs("publicKey",t,32);try{const r=u7(Ki(n)),a=Ki(s.subarray(0,32));if(!c7(a))return!1;const o=Ki(s.subarray(32,64));if(!IAe(o))return!1;const c=h7(C2(a),mB(r),i),u=CAe(r,o,Sw(-c));return!(!u||!u.hasEvenY()||u.toAffine().x!==a)}catch{return!1}}Qd.utils.randomPrivateKey;const AAe=PAe(Ch,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map(d=>d.map(e=>BigInt(e)))),LAe=n7(Ch,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:Ch.create(BigInt("-11"))});fB(Qd.ProjectivePoint,d=>{const{x:e,y:t}=LAe(Ch.create(d[0]));return AAe(e,t)},{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:Ch.ORDER,m:1,k:128,expand:"xmd",hash:He});const vw=kb(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),f7=vw.create(BigInt("-3")),p7=BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),BAe=n7(vw,{A:f7,B:p7,Z:vw.create(BigInt("-10"))}),yB=a7({a:f7,b:p7,Fp:vw,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},He),NAe=yB;fB(NAe.ProjectivePoint,d=>BAe(d[0]),{DST:"P256_XMD:SHA-256_SSWU_RO_",encodeDST:"P256_XMD:SHA-256_SSWU_NU_",p:vw.ORDER,m:1,k:128,expand:"xmd",hash:He});const m7={binary:d=>d,hex:Uh.encode,base64:nu.encode},h3={"1.3.132.0.10":Qd,"1.2.840.10045.3.1.7":yB},KO=(d,e,t="hex")=>{const s=e(d);return m7[t](s)},wB=(d,e,t,s="hex")=>{const i=dB(t,e,d);return m7[s](i)};function xf(d,e,t,s=null,i=!1){if(s&&(d=KO(d,s,"hex")),typeof e=="string"&&e.length>64)if(e.startsWith("-----BEGIN EC PRIVATE KEY-----")){const c=bw.unarmor(e);let u=xl.decode(c);if(u.sub.length===4){if(typeof u.sub[2].sub!==null&&u.sub[2].sub.length>0){const h=u.sub[2].sub[0].content(void 0);if(h3[h]===void 0)throw new Error("Unsupported curve");t=h3[h]}e=u.sub[1].getHexStringValue()}else throw new Error("Unsupported key format")}else throw new Error("Unsupported key format");let n=t.sign(d,e,{lowS:!0});const r=(BigInt(1)<a||n.r<=r||n.s<=r);)n=t.sign(d,e,{lowS:!0,extraEntropy:Fd(BigInt(o),32)}),o+=1;return{r:n.r.toString(16),s:n.s.toString(16),v:n.recovery}}function g7(d,e,t){const s=t.signModified(d,e);return zm.encode(s)}function lg(d,e,t){let s;e.length===32?s=e:typeof e=="string"&&(s=new Uint8Array(bw.unarmor(e).slice(16)));const i=t.sign(d,s);return nu.encode(i)}function y1(d,e=!1){const t="00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F 63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC 51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E 7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D 806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA 11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F 30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D";y1.table===void 0&&(y1.table=t.split(" ").map(n=>parseInt(n,16)));let s=-1;for(let n=0;n>>8^y1.table[(s^d.charCodeAt(n))&255];const i=(s^-1)>>>0;return e&&i>=2147483648?i-4294967296:i}const Mh=Date.now,y7=()=>Mh()*1e3,l0=Mh,EAe=()=>Math.floor(Mh()/1e3),RAe=()=>{const s=(y7()*10+122192928e9).toString(16),i=s.slice(7,15)+s.slice(3,7)+"1"+s.slice(0,3),n="9696",r="ff".repeat(6);return i+n+r},DAe=setTimeout,XO=(d,e,t=DAe,s=Mh()+e)=>{if(e>=2147483647)throw new Error("setTimeout() function was called with unrealistic value of "+e.toString());let i=()=>{},n=!0;const r=t(()=>{n=!0;const a=s-Mh();a>0?i=XO(d,a,t,s):d()},e);return function(){n&&(n=!1,clearTimeout(r)),i()}};class Tw extends Error{constructor(){const e="timed out";super(e),this.constructor=Tw,this.__proto__=Tw.prototype,this.message=e}}const w1=d=>{let e;if(typeof d=="number"?e=Math.floor(d):e=parseInt(d,10),!(Number.isNaN(e)||e<0))try{return new Date(e).toISOString()}catch{return}},w7=d=>{if(!(typeof d!="string"||!d)&&!d.match(/^[0-9]+$/)&&!(d.indexOf("-")<0||d.indexOf(":")<0))try{const e=Date.parse(d.indexOf("+")>=0||d.slice(-1)==="Z"?d:(d+"Z").replace(/\s(\d\d):/,"T$1:"));return Number.isNaN(e)?void 0:e}catch{return}},qAe=d=>{if(!(typeof d!="string"||!d)){if(d.indexOf("GMT")>=0)try{return Date.parse(d)}catch{return}return w7(d)}},VAe=(d=void 0)=>new Date(d).toUTCString(),FAe=(d,e="-")=>{e=e||"";const t=new Date(d),s=t.getUTCFullYear().toString();let i=t.getUTCMonth()+1,n=t.getUTCDate();return i=i<10?"0"+i:i.toString(),n=n<10?"0"+n:n.toString(),i+e+n+e+s},bB=(d,e,t=!0)=>{e=e||"";const s=new Date(d),i=s.getUTCFullYear(),r=(t?i:i-2e3).toString();let a=s.getUTCMonth()+1,o=s.getUTCDate();return a=a<10?"0"+a:a.toString(),o=o<10?"0"+o:o.toString(),r+e+a+e+o},HAe=(d,e="")=>bB(d,e,!1),GAe=(d,e="-")=>bB(d,e,!0),UAe=(d,e=" ")=>{const t=new Date(d),s=t.getUTCFullYear();let i=t.getUTCMonth()+1,n=t.getUTCDate(),r=t.getUTCHours(),a=t.getUTCMinutes(),o=t.getUTCSeconds();return i=i<10?"0"+i:i,n=n<10?"0"+n:n,r=r<10?"0"+r:r,a=a<10?"0"+a:a,o=o<10?"0"+o:o,s+"-"+i+"-"+n+e+r+":"+a+":"+o},kB=d=>new Promise(e=>XO(e,d)),WAe=async(d,e)=>{let t=()=>{};const s=new Promise(i=>t=XO(i,d));try{return await Promise.race([e,s.then(()=>{throw new Tw})])}finally{t()}};let jAe=class{constructor(e){this.config={refillRate:1,delay:.001,capacity:1,maxCapacity:2e3,tokens:0,cost:1},Object.assign(this.config,e),this.queue=[],this.running=!1}async loop(){let e=Mh();for(;this.running;){const{resolver:t,cost:s}=this.queue[0];if(this.config.tokens>=0)this.config.tokens-=s,t(),this.queue.shift(),await Promise.resolve(),this.queue.length===0&&(this.running=!1);else{await kB(this.config.delay*1e3);const i=Mh(),n=i-e;e=i;const r=this.config.tokens+this.config.refillRate*n;this.config.tokens=Math.min(r,this.config.capacity)}}}throttle(e=void 0){let t;const s=new Promise((i,n)=>{t=i});if(this.queue.length>this.config.maxCapacity)throw new Error("throttle queue is over maxCapacity ("+this.config.maxCapacity.toString()+"), see https://github.com/ccxt/ccxt/issues/11645#issuecomment-1195695526");return e=e===void 0?this.config.cost:e,this.queue.push({resolver:t,cost:e}),this.running||(this.running=!0,this.loop()),s}};class fg extends Error{constructor(e){super(e),this.name="BaseError"}}class I extends fg{constructor(e){super(e),this.name="ExchangeError"}}class $ extends I{constructor(e){super(e),this.name="AuthenticationError"}}class de extends ${constructor(e){super(e),this.name="PermissionDenied"}}class Ii extends de{constructor(e){super(e),this.name="AccountNotEnabled"}}class gt extends ${constructor(e){super(e),this.name="AccountSuspended"}}class G extends I{constructor(e){super(e),this.name="ArgumentsRequired"}}class T extends I{constructor(e){super(e),this.name="BadRequest"}}class we extends T{constructor(e){super(e),this.name="BadSymbol"}}class Pe extends I{constructor(e){super(e),this.name="OperationRejected"}}class Ow extends Pe{constructor(e){super(e),this.name="NoChange"}}class $m extends Ow{constructor(e){super(e),this.name="MarginModeAlreadySet"}}class Sb extends Pe{constructor(e){super(e),this.name="MarketClosed"}}class QO extends Pe{constructor(e){super(e),this.name="ManualInteractionNeeded"}}class ce extends I{constructor(e){super(e),this.name="InsufficientFunds"}}class is extends I{constructor(e){super(e),this.name="InvalidAddress"}}class SB extends is{constructor(e){super(e),this.name="AddressPending"}}class x extends I{constructor(e){super(e),this.name="InvalidOrder"}}class Ie extends x{constructor(e){super(e),this.name="OrderNotFound"}}class b7 extends x{constructor(e){super(e),this.name="OrderNotCached"}}class Mi extends x{constructor(e){super(e),this.name="OrderImmediatelyFillable"}}class Cd extends x{constructor(e){super(e),this.name="OrderNotFillable"}}class va extends x{constructor(e){super(e),this.name="DuplicateOrderId"}}class Od extends x{constructor(e){super(e),this.name="ContractUnavailable"}}class q extends I{constructor(e){super(e),this.name="NotSupported"}}class Fp extends I{constructor(e){super(e),this.name="InvalidProxySettings"}}class YO extends I{constructor(e){super(e),this.name="ExchangeClosedByUser"}}class xt extends fg{constructor(e){super(e),this.name="OperationFailed"}}class qs extends xt{constructor(e){super(e),this.name="NetworkError"}}class ts extends qs{constructor(e){super(e),this.name="DDoSProtection"}}class Ze extends qs{constructor(e){super(e),this.name="RateLimitExceeded"}}class Ee extends qs{constructor(e){super(e),this.name="ExchangeNotAvailable"}}class as extends Ee{constructor(e){super(e),this.name="OnMaintenance"}}class Ft extends qs{constructor(e){super(e),this.name="InvalidNonce"}}class $r extends Ft{constructor(e){super(e),this.name="ChecksumError"}}class Vs extends qs{constructor(e){super(e),this.name="RequestTimeout"}}class Wi extends xt{constructor(e){super(e),this.name="BadResponse"}}class xc extends Wi{constructor(e){super(e),this.name="NullResponse"}}class qo extends xt{constructor(e){super(e),this.name="CancelPending"}}class qc extends fg{constructor(e){super(e),this.name="UnsubscribeError"}}const zAe={BaseError:fg,ExchangeError:I,AuthenticationError:$,PermissionDenied:de,AccountNotEnabled:Ii,AccountSuspended:gt,ArgumentsRequired:G,BadRequest:T,BadSymbol:we,OperationRejected:Pe,NoChange:Ow,MarginModeAlreadySet:$m,MarketClosed:Sb,ManualInteractionNeeded:QO,InsufficientFunds:ce,InvalidAddress:is,AddressPending:SB,InvalidOrder:x,OrderNotFound:Ie,OrderNotCached:b7,OrderImmediatelyFillable:Mi,OrderNotFillable:Cd,DuplicateOrderId:va,ContractUnavailable:Od,NotSupported:q,InvalidProxySettings:Fp,ExchangeClosedByUser:YO,OperationFailed:xt,NetworkError:qs,DDoSProtection:ts,RateLimitExceeded:Ze,ExchangeNotAvailable:Ee,OnMaintenance:as,InvalidNonce:Ft,ChecksumError:$r,RequestTimeout:Vs,BadResponse:Wi,NullResponse:xc,CancelPending:qo,UnsubscribeError:qc},$Ae=Object.freeze(Object.defineProperty({__proto__:null,AccountNotEnabled:Ii,AccountSuspended:gt,AddressPending:SB,ArgumentsRequired:G,AuthenticationError:$,BadRequest:T,BadResponse:Wi,BadSymbol:we,BaseError:fg,CancelPending:qo,ChecksumError:$r,ContractUnavailable:Od,DDoSProtection:ts,DuplicateOrderId:va,ExchangeClosedByUser:YO,ExchangeError:I,ExchangeNotAvailable:Ee,InsufficientFunds:ce,InvalidAddress:is,InvalidNonce:Ft,InvalidOrder:x,InvalidProxySettings:Fp,ManualInteractionNeeded:QO,MarginModeAlreadySet:$m,MarketClosed:Sb,NetworkError:qs,NoChange:Ow,NotSupported:q,NullResponse:xc,OnMaintenance:as,OperationFailed:xt,OperationRejected:Pe,OrderImmediatelyFillable:Mi,OrderNotCached:b7,OrderNotFillable:Cd,OrderNotFound:Ie,PermissionDenied:de,RateLimitExceeded:Ze,RequestTimeout:Vs,UnsubscribeError:qc,default:zAe},Symbol.toStringTag,{value:"Module"})),k7=d=>{const e=td(d.slice(0,-1)),t=d.slice(-1);let s;if(t==="y")s=60*60*24*365;else if(t==="M")s=60*60*24*30;else if(t==="w")s=60*60*24*7;else if(t==="d")s=60*60*24;else if(t==="h")s=60*60;else if(t==="m")s=60;else if(t==="s")s=1;else throw new q("timeframe unit "+t+" is not supported");return e*s},KAe=(d,e,t=tB)=>{const s=k7(d)*1e3,i=e%s;return e-i+(t===eB?s:0)},XAe=d=>{const e=/{([\w-]+)}/g,t=[];let s=e.exec(d);for(;s;)t.push(s[1]),s=e.exec(d);return t},QAe=(d,e)=>{if(!Array.isArray(e)){const t=Object.keys(e);for(let s=0;s0?e/d:void 0}function YAe(d){const e={};for(let t=0;t0&&(e[s]=(e[s]||0)+i)}return Object.keys(e).map(t=>[parseFloat(t),parseFloat(e[t])])}function v7(){let d=!1;try{d=self!==void 0}catch{d=!1}return d}const ZO=Object.freeze(Object.defineProperty({__proto__:null,DECIMAL_PLACES:Hn,NO_PADDING:Wu,PAD_WITH_ZERO:Gv,ROUND:tr,ROUND_DOWN:tB,ROUND_UP:eB,SIGNIFICANT_DIGITS:Hh,TICK_SIZE:Qe,TRUNCATE:js,Throttler:jAe,TimedOut:Tw,aggregate:YAe,arrayConcat:y2e,asFloat:td,asInteger:qO,axolotl:g7,base16ToBinary:Xj,base58ToBinary:N_e,base64ToBinary:$j,base64ToString:L_e,binaryConcat:R_e,binaryConcatArray:D_e,binaryToBase16:B_e,binaryToBase58:E_e,binaryToBase64:Kj,binaryToString:__e,capitalize:B2e,clone:Ij,crc32:y1,decimalToPrecision:D2e,decode:U_e,deepExtend:Cj,ecdsa:xf,eddsa:lg,encode:G_e,extend:bb,extractParams:XAe,filterBy:O2e,flatten:I2e,groupBy:v2e,hasProps:yb,hash:KO,hmac:wB,implodeParams:QAe,inArray:w2e,index:Pj,indexBy:T2e,isArray:cg,isBrowser:Tj,isDeno:xj,isDictionary:b2,isElectron:HMe,isEmpty:k2e,isInteger:UMe,isJsonEncodedObject:jj,isNode:jm,isNumber:zn,isObject:wb,isString:ZL,isStringCoercible:rr,isWebWorker:Oj,isWindows:GMe,iso8601:w1,json:M_e,keys:JL,keysort:S2e,mdy:FAe,merge:A2e,microseconds:y7,milliseconds:l0,now:Mh,numberToBE:j_e,numberToLE:W_e,numberToString:sB,omit:M2e,omitZero:q2e,ordered:m2e,packb:z_e,parse8601:w7,parseDate:qAe,parseTimeframe:k7,pluck:C2e,precisionConstants:E2e,precisionFromString:k2,prop:Xd,rawencode:H_e,rfc2616:VAe,roundTimeframe:KAe,safeFloat:jMe,safeFloat2:JMe,safeFloatN:o2e,safeInteger:zMe,safeInteger2:e2e,safeIntegerN:d2e,safeIntegerProduct:$Me,safeIntegerProduct2:t2e,safeIntegerProductN:c2e,safeString:QMe,safeString2:n2e,safeStringLower:YMe,safeStringLower2:r2e,safeStringLowerN:f2e,safeStringN:l2e,safeStringUpper:ZMe,safeStringUpper2:a2e,safeStringUpperN:p2e,safeTimestamp:KMe,safeTimestamp2:s2e,safeTimestampN:u2e,safeValue:XMe,safeValue2:i2e,safeValueN:h2e,seconds:EAe,selfIsDefined:v7,setTimeout_safe:XO,sleep:kB,sortBy:x2e,sortBy2:P2e,stringToBase64:zj,stringToBinary:A_e,strip:N2e,sum:_2e,timeout:WAe,toArray:b2e,truncate:R2e,truncate_to_string:Lj,unCamelCase:L2e,unique:g2e,urlencode:q_e,urlencodeBase64:bp,urlencodeNested:V_e,urlencodeWithArrayRepeat:F_e,uuid:Mj,uuid16:_j,uuid22:Aj,uuidv1:RAe,values:Of,vwap:S7,ymd:bB,ymdhms:UAe,yymmdd:HAe,yyyymmdd:GAe},Symbol.toStringTag,{value:"Module"})),ZAe=BigInt(0),JAe=BigInt(-1),cp=BigInt(10);class L{constructor(e,t=void 0){if(this.base=void 0,t===void 0){let s=0;if(e=e.toLowerCase(),e.indexOf("e")>-1){let r="0";[e,r]=e.split("e"),s=parseInt(r)}const i=e.indexOf(".");this.decimals=i>-1?e.length-i-1:0;const n=e.replace(".","");this.integer=BigInt(n),this.decimals=this.decimals-s}else this.integer=e,this.decimals=t}mul(e){const t=this.integer*e.integer;return new L(t,this.decimals+e.decimals)}div(e,t=18){const s=t-this.decimals+e.decimals;let i;if(s===0)i=this.integer;else if(s<0){const r=cp**BigInt(-s);i=this.integer/r}else{const r=cp**BigInt(s);i=this.integer*r}const n=i/e.integer;return new L(n,t)}add(e){if(this.decimals===e.decimals){const t=this.integer+e.integer;return new L(t,this.decimals)}else{const[t,s]=this.decimals>e.decimals?[e,this]:[this,e],i=s.decimals-t.decimals,r=t.integer*cp**BigInt(i)+s.integer;return new L(r,s.decimals)}}mod(e){const t=Math.max(-this.decimals+e.decimals,0),s=this.integer*cp**BigInt(t),i=Math.max(-e.decimals+this.decimals,0),n=e.integer*cp**BigInt(i),r=s%n;return new L(r,i+e.decimals)}sub(e){const t=new L(-e.integer,e.decimals);return this.add(t)}abs(){return new L(this.integer<0?this.integer*JAe:this.integer,this.decimals)}neg(){return new L(-this.integer,this.decimals)}or(e){const t=this.integer|e.integer;return new L(t,this.decimals)}min(e){return this.lt(e)?this:e}max(e){return this.gt(e)?this:e}gt(e){return this.sub(e).integer>0}ge(e){return this.sub(e).integer>=0}lt(e){return e.gt(this)}le(e){return e.ge(this)}reduce(){const e=this.integer.toString(),t=e.length-1;if(t===0)return e==="0"&&(this.decimals=0),this;let s;for(s=t;s>=0&&e.charAt(s)==="0";s--);const i=t-s;if(i===0)return this;this.decimals-=i,this.integer=BigInt(e.slice(0,s+1))}equals(e){return this.reduce(),e.reduce(),this.decimals===e.decimals&&this.integer===e.integer}toString(){this.reduce();let e,t;this.integer<0?(e="-",t=-this.integer):(e="",t=this.integer);const s=Array.from(t.toString(Number(cp)).padStart(this.decimals,"0")),i=s.length-this.decimals;let n;return i===0?n="0.":this.decimals<0?n="0".repeat(-this.decimals):this.decimals===0?n="":n=".",s.splice(i,0,n),e+s.join("")}static stringMul(e,t){if(!(e===void 0||t===void 0))return new L(e).mul(new L(t)).toString()}static stringDiv(e,t,s=18){if(e===void 0||t===void 0)return;const i=new L(t);if(i.integer!==ZAe)return new L(e).div(i,s).toString()}static stringAdd(e,t){if(!(e===void 0&&t===void 0))return e===void 0?t:t===void 0?e:new L(e).add(new L(t)).toString()}static stringSub(e,t){if(!(e===void 0||t===void 0))return new L(e).sub(new L(t)).toString()}static stringAbs(e){if(e!==void 0)return new L(e).abs().toString()}static stringNeg(e){if(e!==void 0)return new L(e).neg().toString()}static stringMod(e,t){if(!(e===void 0||t===void 0))return new L(e).mod(new L(t)).toString()}static stringOr(e,t){if(!(e===void 0||t===void 0))return new L(e).or(new L(t)).toString()}static stringEquals(e,t){if(!(e===void 0||t===void 0))return new L(e).equals(new L(t))}static stringEq(e,t){if(!(e===void 0||t===void 0))return new L(e).equals(new L(t))}static stringMin(e,t){if(!(e===void 0||t===void 0))return new L(e).min(new L(t)).toString()}static stringMax(e,t){if(!(e===void 0||t===void 0))return new L(e).max(new L(t)).toString()}static stringGt(e,t){if(!(e===void 0||t===void 0))return new L(e).gt(new L(t))}static stringGe(e,t){if(!(e===void 0||t===void 0))return new L(e).ge(new L(t))}static stringLt(e,t){if(!(e===void 0||t===void 0))return new L(e).lt(new L(t))}static stringLe(e,t){if(!(e===void 0||t===void 0))return new L(e).le(new L(t))}}var eLe=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")};const tLe=sT(eLe);var pa=Uint8Array,Il=Uint16Array,T7=Uint32Array,O7=new pa([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),x7=new pa([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),sLe=new pa([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),P7=function(d,e){for(var t=new Il(31),s=0;s<31;++s)t[s]=e+=1<>>1|(fi&21845)<<1;Iu=(Iu&52428)>>>2|(Iu&13107)<<2,Iu=(Iu&61680)>>>4|(Iu&3855)<<4,_2[fi]=((Iu&65280)>>>8|(Iu&255)<<8)>>>1}var f0=function(d,e,t){for(var s=d.length,i=0,n=new Il(e);i>>o]=c}else for(a=new Il(s),i=0;i>>15-d[i]);return a},vb=new pa(288);for(var fi=0;fi<144;++fi)vb[fi]=8;for(var fi=144;fi<256;++fi)vb[fi]=9;for(var fi=256;fi<280;++fi)vb[fi]=7;for(var fi=280;fi<288;++fi)vb[fi]=8;var M7=new pa(32);for(var fi=0;fi<32;++fi)M7[fi]=5;var aLe=f0(vb,9,1),oLe=f0(M7,5,1),rC=function(d){for(var e=d[0],t=1;te&&(e=d[t]);return e},To=function(d,e,t){var s=e/8|0;return(d[s]|d[s+1]<<8)>>(e&7)&t},aC=function(d,e){var t=e/8|0;return(d[t]|d[t+1]<<8|d[t+2]<<16)>>(e&7)},dLe=function(d){return(d+7)/8|0},cLe=function(d,e,t){(t==null||t>d.length)&&(t=d.length);var s=new(d.BYTES_PER_ELEMENT==2?Il:d.BYTES_PER_ELEMENT==4?T7:pa)(t-e);return s.set(d.subarray(e,t)),s},uLe=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],gc=function(d,e,t){var s=new Error(e||uLe[d]);if(s.code=d,Error.captureStackTrace&&Error.captureStackTrace(s,gc),!t)throw s;return s},_7=function(d,e,t){var s=d.length;if(!s||t&&t.f&&!t.l)return e||new pa(0);var i=!e||t,n=!t||t.i;t||(t={}),e||(e=new pa(s*3));var r=function(me){var fe=e.length;if(me>fe){var he=new pa(Math.max(fe*2,me));he.set(e),e=he}},a=t.f||0,o=t.p||0,c=t.b||0,u=t.l,h=t.d,l=t.m,f=t.n,p=s*8;do{if(!u){a=To(d,o,1);var m=To(d,o+1,3);if(o+=3,m)if(m==1)u=aLe,h=oLe,l=9,f=5;else if(m==2){var b=To(d,o,31)+257,S=To(d,o+10,15)+4,v=b+To(d,o+5,31)+1;o+=14;for(var C=new pa(v),M=new pa(19),_=0;_>>4;if(g<16)C[_++]=g;else{var U=0,K=0;for(g==16?(K=3+To(d,o,3),o+=2,U=C[_-1]):g==17?(K=3+To(d,o,7),o+=3):g==18&&(K=11+To(d,o,127),o+=7);K--;)C[_++]=U}}var j=C.subarray(0,b),z=C.subarray(b);l=rC(j),f=rC(z),u=f0(j,l,1),h=f0(z,f,1)}else gc(1);else{var g=dLe(o)+4,y=d[g-4]|d[g-3]<<8,w=g+y;if(w>s){n&&gc(0);break}i&&r(c+y),e.set(d.subarray(g,w),c),t.b=c+=y,t.p=o=w*8,t.f=a;continue}if(o>p){n&&gc(0);break}}i&&r(c+131072);for(var J=(1<>>4;if(o+=U&15,o>p){n&&gc(0);break}if(U||gc(2),Z<256)e[c++]=Z;else if(Z==256){X=o,u=null;break}else{var te=Z-254;if(Z>264){var _=Z-257,Q=O7[_];te=To(d,o,(1<>>4;ie||gc(3),o+=ie&15;var z=rLe[ne];if(ne>3){var Q=x7[ne];z+=aC(d,o)&(1<p){n&&gc(0);break}i&&r(c+131072);for(var oe=c+te;c>3&1)+(e>>4&1);s>0;s-=!d[t++]);return t+(e&2)},fLe=function(d){var e=d.length;return(d[e-4]|d[e-3]<<8|d[e-2]<<16|d[e-1]<<24)>>>0};function pLe(d,e=void 0){return _7(d,e)}function mLe(d,e=void 0){return _7(d.subarray(lLe(d),-8),e||new pa(fLe(d)))}var gLe=typeof TextDecoder<"u"&&new TextDecoder,yLe=0;try{gLe.decode(hLe,{stream:!0}),yLe=1}catch{}var A7;const oC=new WeakMap,wLe=()=>{};class bc{constructor(e){this.subscribers=[],this.settlement=null,this[A7]="Unpromise",typeof e=="function"?this.promise=new Promise(e):this.promise=e;const t=this.promise.then(s=>{const{subscribers:i}=this;this.subscribers=null,this.settlement={status:"fulfilled",value:s},i==null||i.forEach(({resolve:n})=>{n(s)})});"catch"in t&&t.catch(s=>{const{subscribers:i}=this;this.subscribers=null,this.settlement={status:"rejected",reason:s},i==null||i.forEach(({reject:n})=>{n(s)})})}subscribe(){let e,t;const{settlement:s}=this;if(s===null){if(this.subscribers===null)throw new Error("Unpromise settled but still has subscribers");const i=kLe();this.subscribers=SLe(this.subscribers,i),e=i.promise,t=()=>{this.subscribers!==null&&(this.subscribers=TLe(this.subscribers,i))}}else{const{status:i}=s;i==="fulfilled"?e=Promise.resolve(s.value):e=Promise.reject(s.reason),t=wLe}return Object.assign(e,{unsubscribe:t})}then(e,t){const s=this.subscribe(),{unsubscribe:i}=s;return Object.assign(s.then(e,t),{unsubscribe:i})}catch(e){const t=this.subscribe(),{unsubscribe:s}=t;return Object.assign(t.catch(e),{unsubscribe:s})}finally(e){const t=this.subscribe(),{unsubscribe:s}=t;return Object.assign(t.finally(e),{unsubscribe:s})}static proxy(e){const t=bc.getSubscribablePromise(e);return typeof t<"u"?t:bc.createSubscribablePromise(e)}static createSubscribablePromise(e){const t=new bc(e);return oC.set(e,t),oC.set(t,t),t}static getSubscribablePromise(e){return oC.get(e)}static resolve(e){const t=typeof e=="object"&&e!==null&&"then"in e&&typeof e.then=="function"?e:Promise.resolve(e);return bc.proxy(t).subscribe()}static async any(e){const s=(Array.isArray(e)?e:[...e]).map(bc.resolve);try{return await Promise.any(s)}finally{s.forEach(({unsubscribe:i})=>{i()})}}static async race(e){const s=(Array.isArray(e)?e:[...e]).map(bc.resolve);try{return await Promise.race(s)}finally{s.forEach(({unsubscribe:i})=>{i()})}}static async raceReferences(e){const t=e.map(bLe);try{return await Promise.race(t)}finally{for(const s of t)s.unsubscribe()}}}A7=Symbol.toStringTag;function bLe(d){return bc.proxy(d).then(()=>[d])}function kLe(){let d,e;return{promise:new Promise((s,i)=>{d=s,e=i}),resolve:d,reject:e}}function SLe(d,e){return[...d,e]}function vLe(d,e){return[...d.slice(0,e),...d.slice(e+1)]}function TLe(d,e){const t=d.indexOf(e);return t!==-1?vLe(d,t):d}function lh(){let d,e;const t=new Promise((s,i)=>{d=s,e=i});return t.resolve=function(){setTimeout(()=>{d.apply(this,arguments)})},t.reject=function(){setTimeout(()=>{e.apply(this,arguments)})},t}function OLe(d){const e=lh();return d.then(e.resolve,e.reject),e}lh.race=d=>OLe(bc.race(d));class xLe{constructor(e,t,s,i,n,r={}){this.useMessageQueue=!1,this.verbose=!1,Object.assign(this,Cj({url:e,onMessageCallback:t,onErrorCallback:s,onCloseCallback:i,onConnectedCallback:n,verbose:!1,protocols:void 0,options:void 0,futures:{},subscriptions:{},rejections:{},messageQueue:{},useMessageQueue:!1,connected:void 0,error:void 0,connectionStarted:void 0,connectionEstablished:void 0,isConnected:!1,connectionTimer:void 0,connectionTimeout:1e4,pingInterval:void 0,ping:void 0,keepAlive:3e4,maxPingPongMisses:2,connection:void 0,startedConnecting:!1,gunzip:!1,inflate:!1},r)),this.connected=lh()}future(e){e in this.futures||(this.futures[e]=lh());const t=this.futures[e];if(e in this.rejections)return t.reject(this.rejections[e]),delete this.rejections[e],delete this.messageQueue[e],t;if(this.useMessageQueue){const s=this.messageQueue[e];s&&s.length&&(t.resolve(s.shift()),delete this.futures[e])}return t}resolve(e,t){if(this.verbose&&t===void 0&&this.log(new Date,"resolve received undefined messageHash"),this.useMessageQueue===!0){t in this.messageQueue||(this.messageQueue[t]=[]);const s=this.messageQueue[t];for(s.push(e);s.length>10;)s.shift();t!==void 0&&t in this.futures&&(this.futures[t].resolve(s.shift()),delete this.futures[t])}else t in this.futures&&(this.futures[t].resolve(e),delete this.futures[t]);return e}reject(e,t=void 0){if(t)t in this.futures?(this.futures[t].reject(e),delete this.futures[t]):this.rejections[t]=e;else{const s=Object.keys(this.futures);for(let i=0;i{this.onError(s)}):jm?this.connection.ping():this.lastPong=e}}}onOpen(){this.verbose&&this.log(new Date,"onOpen"),this.connectionEstablished=l0(),this.isConnected=!0,this.connected.resolve(this.url),this.clearConnectionTimeout(),this.setPingInterval(),this.onConnectedCallback(this)}onPing(){this.verbose&&this.log(new Date,"onPing")}onPong(){this.lastPong=l0(),this.verbose&&this.log(new Date,"onPong")}onError(e){this.verbose&&this.log(new Date,"onError",e.message),e instanceof fg||(e=new qs(e.message)),this.error=e,this.reset(this.error),this.onErrorCallback(this,this.error)}onClose(e){this.verbose&&this.log(new Date,"onClose",e),this.error||this.reset(new qs("connection closed by remote server, closing code "+String(e.code))),this.error instanceof YO&&this.reset(this.error),this.disconnected!==void 0&&this.disconnected.resolve(!0),this.onCloseCallback(this,e)}onUpgrade(e){this.verbose&&this.log(new Date,"onUpgrade")}async send(e){this.verbose&&this.log(new Date,"sending",e),e=typeof e=="string"?e:JSON.stringify(e);const t=lh();if(jm){let s=function(i){i?t.reject(i):t.resolve(null)};this.connection.send(e,{},s)}else this.connection.send(e),t.resolve(null);return t}close(){throw new q("close() not implemented yet")}onMessage(e){let t=e.data,s;typeof t!="string"&&(this.gunzip||this.inflate?(s=new Uint8Array(t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)),this.gunzip?s=mLe(s):this.inflate&&(s=pLe(s)),t=Wd.encode(s)):t=t.toString());try{jj(t)&&(t=JSON.parse(t.replace(/:(\d{15,}),/g,':"$1",'))),this.verbose&&this.log(new Date,"onMessage",t)}catch(i){this.log(new Date,"onMessage JSON.parse",i)}try{this.onMessageCallback(this,t)}catch(i){this.reject(i)}}}const IS=jm||!v7()?tLe:self.WebSocket;class PLe extends xLe{constructor(){super(...arguments),this.startedConnecting=!1}createConnection(){this.verbose&&this.log(new Date,"connecting to",this.url),this.connectionStarted=l0(),this.setConnectionTimeout(),jm?this.connection=new IS(this.url,this.protocols,this.options):this.connection=new IS(this.url,this.protocols),this.connection.onopen=this.onOpen.bind(this),this.connection.onmessage=this.onMessage.bind(this),this.connection.onerror=this.onError.bind(this),this.connection.onclose=this.onClose.bind(this),jm&&this.connection.on("ping",this.onPing.bind(this)).on("pong",this.onPong.bind(this)).on("upgrade",this.onUpgrade.bind(this))}connect(e=0){return this.startedConnecting||(this.startedConnecting=!0,e?kB(e).then(this.createConnection.bind(this)):this.createConnection()),this.connected}isOpen(){return this.connection.readyState===IS.OPEN}close(){return this.connection instanceof IS&&(this.disconnected===void 0&&(this.disconnected=lh()),this.connection.close()),this.disconnected}}function Hp(d,e){let t=0,s=d.length-1;for(;t<=s;){const i=t+s>>>1;d[i]-e<0?t=i+1:s=i-1}return t}const ILe=1024,L7=new Float64Array(new Array(ILe).fill(Number.MAX_VALUE));class vB extends Array{constructor(e=[],t=void 0){super(),Object.defineProperty(this,"index",{__proto__:null,value:new Float64Array(L7),writable:!0}),Object.defineProperty(this,"depth",{__proto__:null,value:t||Number.MAX_SAFE_INTEGER,writable:!0}),this.length=0;for(let s=0;sthis.index.length-1){const r=Array.from(this.index);r.length=this.length*2,r.fill(Number.MAX_VALUE,this.index.length),this.index=new Float64Array(r)}}else this.index[n]===i&&(this.index.copyWithin(n,n+1,this.index.length),this.index[this.length-1]=Number.MAX_VALUE,this.copyWithin(n,n+1,this.length),this.length--)}store(e,t){this.storeArray([e,t])}limit(){if(this.length>this.depth){for(let e=this.depth;ethis.index.length-1){const a=Array.from(this.index);a.length=this.length*2,a.fill(Number.MAX_VALUE,this.index.length),this.index=new Float64Array(a)}}else this.index[r]===n&&(this.index.copyWithin(r,r+1,this.index.length),this.index[this.length-1]=Number.MAX_VALUE,this.copyWithin(r,r+1,this.length),this.length--)}}class N7 extends Array{constructor(e=[],t=Number.MAX_SAFE_INTEGER){super(e.length),Object.defineProperty(this,"hashmap",{__proto__:null,value:new Map,writable:!0}),Object.defineProperty(this,"index",{__proto__:null,value:new Float64Array(L7),writable:!0}),Object.defineProperty(this,"depth",{__proto__:null,value:t||Number.MAX_SAFE_INTEGER,writable:!0});for(let s=0;sthis.index.length-1){const a=Array.from(this.index);a.length=this.length*2,a.fill(Number.MAX_VALUE,this.index.length),this.index=new Float64Array(a)}}else if(this.hashmap.has(i)){const r=this.hashmap.get(i);let a=Hp(this.index,r);for(;this[a][2]!==i;)a++;this.index.copyWithin(a,a+1,this.index.length),this.index[this.length-1]=Number.MAX_VALUE,this.copyWithin(a,a+1,this.length),this.length--,this.hashmap.delete(i)}}limit(){if(this.length>this.depth){for(let e=this.depth;ed<>>32-e>>>0,NLe=(d,e,t)=>d&e^~d&t,ELe=(d,e,t)=>d&e^d&t^e&t,my=new Uint32Array([1732584193,4023233417,2562383102,271733878,3285377520]),Cu=new Uint32Array(80);class RLe extends cB{constructor(){super(64,20,8,!1),this.A=my[0]|0,this.B=my[1]|0,this.C=my[2]|0,this.D=my[3]|0,this.E=my[4]|0}get(){const{A:e,B:t,C:s,D:i,E:n}=this;return[e,t,s,i,n]}set(e,t,s,i,n){this.A=e|0,this.B=t|0,this.C=s|0,this.D=i|0,this.E=n|0}process(e,t){for(let o=0;o<16;o++,t+=4)Cu[o]=e.getUint32(t,!1);for(let o=16;o<80;o++)Cu[o]=dC(Cu[o-3]^Cu[o-8]^Cu[o-14]^Cu[o-16],1);let{A:s,B:i,C:n,D:r,E:a}=this;for(let o=0;o<80;o++){let c,u;o<20?(c=NLe(i,n,r),u=1518500249):o<40?(c=i^n^r,u=1859775393):o<60?(c=ELe(i,n,r),u=2400959708):(c=i^n^r,u=3395469782);const h=dC(s,5)+c+a+u+Cu[o]|0;a=r,r=n,n=dC(i,30),i=s,s=h}s=s+this.A|0,i=i+this.B|0,n=n+this.C|0,r=r+this.D|0,a=a+this.E|0,this.set(s,i,n,r,a)}roundClean(){Cu.fill(0)}destroy(){this.set(0,0,0,0,0),this.buffer.fill(0)}}const DLe=ru(()=>new RLe);function xw(d){const e=c=>(c<15.5?"0":"")+Math.round(c).toString(16),t=c=>parseInt(c,16),s=(c,u)=>(u+c).slice(-u.length);d=d.replace(" ","");const i=Math.round(new Date().getTime()/1e3),n=s(e(Math.floor(i/30)),"0000000000000000"),r=wB(Uh.decode(n),Ej.decode(d),DLe,"hex"),a=t(r.substring(r.length-1));let o=(t(r.substr(a*2,8))&t("7fffffff"))+"";return o.substring(o.length-6,o.length)}function qLe(d,e,t){const s=e.split("|").map(n=>n.trim());for(let n=0;n>4],t+=e[d[s]&15];return t}if(typeof d=="object"&&typeof d.toJSON=="function")return Gp(d.toJSON());switch(typeof d){case"boolean":case"symbol":return d.toString();case"bigint":return BigInt(d).toString();case"number":return d.toString();case"string":return JSON.stringify(d);case"object":{const e=Object.keys(d);return e.sort(),"{ "+e.map(t=>`${Gp(t)}: ${Gp(d[t])}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function l3(d,e){return d&&d.code===e}function VLe(d,e,t){let s=d;{const n=[];if(t){if("message"in t||"code"in t||"name"in t)throw new Error(`value will overwrite populated values: ${Gp(t)}`);for(const r in t){if(r==="shortMessage")continue;const a=t[r];n.push(r+"="+Gp(a))}}n.push(`code=${e}`),n.length&&(d+=" ("+n.join(", ")+")")}let i;switch(e){case"INVALID_ARGUMENT":i=new TypeError(d);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":i=new RangeError(d);break;default:i=new Error(d)}return Qo(i,{code:e}),t&&Object.assign(i,t),i.shortMessage==null&&Qo(i,{shortMessage:s}),i}function jn(d,e,t,s){if(!d)throw VLe(e,t,s)}function Vt(d,e,t,s){jn(d,e,"INVALID_ARGUMENT",{argument:t,value:s})}function D7(d,e,t){t==null&&(t=""),t&&(t=": "+t),jn(d>=e,"missing arguemnt"+t,"MISSING_ARGUMENT",{count:d,expectedCount:e}),jn(d<=e,"too many arguemnts"+t,"UNEXPECTED_ARGUMENT",{count:d,expectedCount:e})}["NFD","NFC","NFKD","NFKC"].reduce((d,e)=>{try{if("test".normalize(e)!=="test")throw new Error("bad");if(e==="NFD"&&"é".normalize("NFD")!=="é")throw new Error("broken");d.push(e)}catch{}return d},[]);function FLe(d,e,t){if(d!==e){let s=t,i="new";s+=".",i+=" "+t,jn(!1,`private constructor; use ${s}from* methods`,"UNSUPPORTED_OPERATION",{operation:i})}}function q7(d,e,t){if(d instanceof Uint8Array)return t?new Uint8Array(d):d;if(typeof d=="string"&&d.match(/^0x([0-9a-f][0-9a-f])*$/i)){const s=new Uint8Array((d.length-2)/2);let i=2;for(let n=0;n>4]+f3[i&15]}return t}function of(d){return"0x"+d.map(e=>au(e).substring(2)).join("")}function GLe(d,e,t){const s=jh(d);jn(e>=s.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(s),length:e,offset:e+1});const i=new Uint8Array(e);return i.fill(0),i.set(s,e-s.length),au(i)}function ULe(d,e){return GLe(d,e)}const JO=BigInt(0),Bo=BigInt(1),Up=9007199254740991;function WLe(d,e){const t=ex(d,"value"),s=BigInt(zh(e,"width"));if(jn(t>>s===JO,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:d}),t>>s-Bo){const i=(Bo<=-Up&&d<=Up,"overflow",e||"value",d),BigInt(d);case"string":try{if(d==="")throw new Error("empty string");return d[0]==="-"&&d[1]!=="-"?-BigInt(d.substring(1)):BigInt(d)}catch(t){Vt(!1,`invalid BigNumberish string: ${t.message}`,e||"value",d)}}Vt(!1,"invalid BigNumberish value",e||"value",d)}function ex(d,e){const t=Pf(d,e);return jn(t>=JO,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:d}),t}const p3="0123456789abcdef";function F7(d){if(d instanceof Uint8Array){let e="0x0";for(const t of d)e+=p3[t>>4],e+=p3[t&15];return BigInt(e)}return Pf(d)}function zh(d,e){switch(typeof d){case"bigint":return Vt(d>=-Up&&d<=Up,"overflow",e||"value",d),Number(d);case"number":return Vt(Number.isInteger(d),"underflow",e||"value",d),Vt(d>=-Up&&d<=Up,"overflow",e||"value",d),d;case"string":try{if(d==="")throw new Error("empty string");return zh(BigInt(d),e)}catch(t){Vt(!1,`invalid numeric string: ${t.message}`,e||"value",d)}}Vt(!1,"invalid numeric value",e||"value",d)}function jLe(d){return zh(F7(d))}function tx(d,e){let s=ex(d,"value").toString(16);if(e==null)s.length%2&&(s="0"+s);else{const i=zh(e,"width");for(jn(i*2>=s.length,`value exceeds width (${i} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:d});s.length>6===2;r++)n++;return n}return d==="OVERRUN"?t.length-e-1:0}function KLe(d,e,t,s,i){return d==="OVERLONG"?(Vt(typeof i=="number","invalid bad code point for replacement","badCodepoint",i),s.push(i),0):(s.push(65533),G7(d,e,t))}const XLe=Object.freeze({error:$Le,ignore:G7,replace:KLe});function QLe(d,e){e==null&&(e=XLe.error);const t=jh(d,"bytes"),s=[];let i=0;for(;i>7)){s.push(n);continue}let r=null,a=null;if((n&224)===192)r=1,a=127;else if((n&240)===224)r=2,a=2047;else if((n&248)===240)r=3,a=65535;else{(n&192)===128?i+=e("UNEXPECTED_CONTINUE",i-1,t,s):i+=e("BAD_PREFIX",i-1,t,s);continue}if(i-1+r>=t.length){i+=e("OVERRUN",i-1,t,s);continue}let o=n&(1<<8-r-1)-1;for(let c=0;c1114111){i+=e("OUT_OF_RANGE",i-1-r,t,s,o);continue}if(o>=55296&&o<=57343){i+=e("UTF16_SURROGATE",i-1-r,t,s,o);continue}if(o<=a){i+=e("OVERLONG",i-1-r,t,s,o);continue}s.push(o)}}return s}function YLe(d,e){let t=[];for(let s=0;s>6|192),t.push(i&63|128);else if((i&64512)==55296){s++;const n=d.charCodeAt(s);Vt(s>18|240),t.push(r>>12&63|128),t.push(r>>6&63|128),t.push(r&63|128)}else t.push(i>>12|224),t.push(i>>6&63|128),t.push(i&63|128)}return new Uint8Array(t)}function ZLe(d){return d.map(e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10&1023)+55296,(e&1023)+56320))).join("")}function JLe(d,e){return ZLe(QLe(d,e))}const CS=BigInt(2**32-1),L2=BigInt(32);function U7(d,e=!1){return e?{h:Number(d&CS),l:Number(d>>L2&CS)}:{h:Number(d>>L2&CS)|0,l:Number(d&CS)|0}}function eBe(d,e=!1){let t=new Uint32Array(d.length),s=new Uint32Array(d.length);for(let i=0;iBigInt(d>>>0)<>>0),sBe=(d,e,t)=>d>>>t,iBe=(d,e,t)=>d<<32-t|e>>>t,nBe=(d,e,t)=>d>>>t|e<<32-t,rBe=(d,e,t)=>d<<32-t|e>>>t,aBe=(d,e,t)=>d<<64-t|e>>>t-32,oBe=(d,e,t)=>d>>>t-32|e<<64-t,dBe=(d,e)=>e,cBe=(d,e)=>d,uBe=(d,e,t)=>d<>>32-t,hBe=(d,e,t)=>e<>>32-t,lBe=(d,e,t)=>e<>>64-t,fBe=(d,e,t)=>d<>>64-t;function pBe(d,e,t,s){const i=(e>>>0)+(s>>>0);return{h:d+t+(i/2**32|0)|0,l:i|0}}const mBe=(d,e,t)=>(d>>>0)+(e>>>0)+(t>>>0),gBe=(d,e,t,s)=>e+t+s+(d/2**32|0)|0,yBe=(d,e,t,s)=>(d>>>0)+(e>>>0)+(t>>>0)+(s>>>0),wBe=(d,e,t,s,i)=>e+t+s+i+(d/2**32|0)|0,bBe=(d,e,t,s,i)=>(d>>>0)+(e>>>0)+(t>>>0)+(s>>>0)+(i>>>0),kBe=(d,e,t,s,i,n)=>e+t+s+i+n+(d/2**32|0)|0,es={fromBig:U7,split:eBe,toBig:tBe,shrSH:sBe,shrSL:iBe,rotrSH:nBe,rotrSL:rBe,rotrBH:aBe,rotrBL:oBe,rotr32H:dBe,rotr32L:cBe,rotlSH:uBe,rotlSL:hBe,rotlBH:lBe,rotlBL:fBe,add:pBe,add3L:mBe,add3H:gBe,add4L:yBe,add4H:wBe,add5H:kBe,add5L:bBe},[W7,j7,z7]=[[],[],[]],SBe=BigInt(0),gy=BigInt(1),vBe=BigInt(2),TBe=BigInt(7),OBe=BigInt(256),xBe=BigInt(113);for(let d=0,e=gy,t=1,s=0;d<24;d++){[t,s]=[s,(2*t+3*s)%5],W7.push(2*(5*s+t)),j7.push((d+1)*(d+2)/2%64);let i=SBe;for(let n=0;n<7;n++)e=(e<>TBe)*xBe)%OBe,e&vBe&&(i^=gy<<(gy<t>32?es.rotlBH(d,e,t):es.rotlSH(d,e,t),g3=(d,e,t)=>t>32?es.rotlBL(d,e,t):es.rotlSL(d,e,t);function CBe(d,e=24){const t=new Uint32Array(10);for(let s=24-e;s<24;s++){for(let r=0;r<10;r++)t[r]=d[r]^d[r+10]^d[r+20]^d[r+30]^d[r+40];for(let r=0;r<10;r+=2){const a=(r+8)%10,o=(r+2)%10,c=t[o],u=t[o+1],h=m3(c,u,1)^t[a],l=g3(c,u,1)^t[a+1];for(let f=0;f<50;f+=10)d[r+f]^=h,d[r+f+1]^=l}let i=d[2],n=d[3];for(let r=0;r<24;r++){const a=j7[r],o=m3(i,n,a),c=g3(i,n,a),u=W7[r];i=d[u],n=d[u+1],d[u]=o,d[u+1]=c}for(let r=0;r<50;r+=10){for(let a=0;a<10;a++)t[a]=d[r+a];for(let a=0;a<10;a++)d[r+a]^=~t[(a+2)%10]&t[(a+4)%10]}d[0]^=PBe[s],d[1]^=IBe[s]}t.fill(0)}class sx extends WO{constructor(e,t,s,i=!1,n=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=s,this.enableXOF=i,this.rounds=n,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,ua.number(s),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=Y_e(this.state)}keccak(){CBe(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){ua.exists(this);const{blockLen:t,state:s}=this;e=hg(e);const i=e.length;for(let n=0;n=s&&this.keccak();const r=Math.min(s-this.posOut,n-i);e.set(t.subarray(this.posOut,this.posOut+r),i),this.posOut+=r,i+=r}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return ua.number(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(ua.output(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:s,outputLen:i,rounds:n,enableXOF:r}=this;return e||(e=new sx(t,s,i,r,n)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=s,e.outputLen=i,e.enableXOF=r,e.destroyed=this.destroyed,e}}const $h=(d,e,t)=>ru(()=>new sx(e,d,t));$h(6,144,224/8);$h(6,136,256/8);$h(6,104,384/8);$h(6,72,512/8);$h(1,144,224/8);const pr=$h(1,136,256/8);$h(1,104,384/8);$h(1,72,512/8);const $7=(d,e,t)=>J_e((s={})=>new sx(e,d,s.dkLen===void 0?t:s.dkLen,!0));$7(31,168,128/8);$7(31,136,256/8);function K7(d){return"0x"+KO(d,pr,"hex")}function lm(d){return"0x"+KO(d,pr,"hex")}var ra=function(d,e,t,s,i){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?d!==e||!i:!e.has(d))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?i.call(d,t):i?i.value=t:e.set(d,t),t},Zt=function(d,e,t,s){if(t==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?d!==e||!s:!e.has(d))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?s:t==="a"?s.call(d):s?s.value:e.get(d)},ml,Dy,qu,ju,b1,p0,aa,oa,yl,fm,Cl,X7,Q7;const gr=32,B2=new Uint8Array(gr),MBe=["then"],MS={};function yy(d,e){const t=new Error(`deferred error during ABI decoding triggered accessing ${d}`);throw t.error=e,t}class m0 extends Array{constructor(...e){const t=e[0];let s=e[1],i=(e[2]||[]).slice(),n=!0;t!==MS&&(s=e,i=[],n=!1),super(s.length),ml.set(this,void 0),s.forEach((a,o)=>{this[o]=a});const r=i.reduce((a,o)=>(typeof o=="string"&&a.set(o,(a.get(o)||0)+1),a),new Map);if(ra(this,ml,Object.freeze(s.map((a,o)=>{const c=i[o];return c!=null&&r.get(c)===1?c:null})),"f"),!!n)return Object.freeze(this),new Proxy(this,{get:(a,o,c)=>{if(typeof o=="string"){if(o.match(/^[0-9]+$/)){const h=zh(o,"%index");if(h<0||h>=this.length)throw new RangeError("out of result range");const l=a[h];return l instanceof Error&&yy(`index ${h}`,l),l}if(MBe.indexOf(o)>=0)return Reflect.get(a,o,c);const u=a[o];if(u instanceof Function)return function(...h){return u.apply(this===c?a:this,h)};if(!(o in a))return a.getValue.apply(this===c?a:this,[o])}return Reflect.get(a,o,c)}})}toArray(){const e=[];return this.forEach((t,s)=>{t instanceof Error&&yy(`index ${s}`,t),e.push(t)}),e}toObject(){return Zt(this,ml,"f").reduce((e,t,s)=>(jn(t!=null,"value at index ${ index } unnamed","UNSUPPORTED_OPERATION",{operation:"toObject()"}),t in e||(e[t]=this.getValue(t)),e),{})}slice(e,t){e==null&&(e=0),e<0&&(e+=this.length,e<0&&(e=0)),t==null&&(t=this.length),t<0&&(t+=this.length,t<0&&(t=0)),t>this.length&&(t=this.length);const s=[],i=[];for(let n=e;n{Zt(this,qu,"f")[e]=y3(t)}}}qu=new WeakMap,ju=new WeakMap,Dy=new WeakSet,b1=function(e){return Zt(this,qu,"f").push(e),ra(this,ju,Zt(this,ju,"f")+e.length,"f"),e.length};class OB{constructor(e,t,s){p0.add(this),aa.set(this,void 0),oa.set(this,void 0),yl.set(this,void 0),fm.set(this,void 0),Cl.set(this,void 0),Qo(this,{allowLoose:!!t}),ra(this,aa,Vc(e),"f"),ra(this,yl,0,"f"),ra(this,fm,null,"f"),ra(this,Cl,s??1024,"f"),ra(this,oa,0,"f")}get data(){return au(Zt(this,aa,"f"))}get dataLength(){return Zt(this,aa,"f").length}get consumed(){return Zt(this,oa,"f")}get bytes(){return new Uint8Array(Zt(this,aa,"f"))}subReader(e){const t=new OB(Zt(this,aa,"f").slice(Zt(this,oa,"f")+e),this.allowLoose,Zt(this,Cl,"f"));return ra(t,fm,this,"f"),t}readBytes(e,t){let s=Zt(this,p0,"m",Q7).call(this,0,e,!!t);return Zt(this,p0,"m",X7).call(this,e),ra(this,oa,Zt(this,oa,"f")+s.length,"f"),s.slice(0,e)}readValue(){return F7(this.readBytes(gr))}readIndex(){return jLe(this.readBytes(gr))}}aa=new WeakMap,oa=new WeakMap,yl=new WeakMap,fm=new WeakMap,Cl=new WeakMap,p0=new WeakSet,X7=function d(e){var t;if(Zt(this,fm,"f"))return Zt(t=Zt(this,fm,"f"),p0,"m",d).call(t,e);ra(this,yl,Zt(this,yl,"f")+e,"f"),jn(Zt(this,Cl,"f")<1||Zt(this,yl,"f")<=Zt(this,Cl,"f")*this.dataLength,`compressed ABI data exceeds inflation ratio of ${Zt(this,Cl,"f")} ( see: https://github.com/ethers-io/ethers.js/issues/4537 )`,"BUFFER_OVERRUN",{buffer:Vc(Zt(this,aa,"f")),offset:Zt(this,oa,"f"),length:e,info:{bytesRead:Zt(this,yl,"f"),dataLength:this.dataLength}})},Q7=function(e,t,s){let i=Math.ceil(t/gr)*gr;return Zt(this,oa,"f")+i>Zt(this,aa,"f").length&&(this.allowLoose&&s&&Zt(this,oa,"f")+t<=Zt(this,aa,"f").length?i=t:jn(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:Vc(Zt(this,aa,"f")),length:Zt(this,aa,"f").length,offset:Zt(this,oa,"f")+i})),Zt(this,aa,"f").slice(Zt(this,oa,"f"),Zt(this,oa,"f")+i)};const _Be=BigInt(0),ABe=BigInt(36);function w3(d){d=d.toLowerCase();const e=d.substring(2).split(""),t=new Uint8Array(40);for(let i=0;i<40;i++)t[i]=e[i].charCodeAt(0);const s=pr(t);for(let i=0;i<40;i+=2)s[i>>1]>>4>=8&&(e[i]=e[i].toUpperCase()),(s[i>>1]&15)>=8&&(e[i+1]=e[i+1].toUpperCase());return"0x"+e.join("")}const xB={};for(let d=0;d<10;d++)xB[String(d)]=String(d);for(let d=0;d<26;d++)xB[String.fromCharCode(65+d)]=String(10+d);const b3=15;function LBe(d){d=d.toUpperCase(),d=d.substring(4)+d.substring(0,2)+"00";let e=d.split("").map(s=>xB[s]).join("");for(;e.length>=b3;){let s=e.substring(0,b3);e=parseInt(s,10)%97+e.substring(s.length)}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}const BBe=function(){const d={};for(let e=0;e<36;e++){const t="0123456789abcdefghijklmnopqrstuvwxyz"[e];d[t]=BigInt(e)}return d}();function NBe(d){d=d.toLowerCase();let e=_Be;for(let t=0;te.format()).join(",")})`:this.type}defaultValue(){return 0}minValue(){return 0}maxValue(){return 0}isBigInt(){return!!this.type.match(/^u?int[0-9]+$/)}isData(){return this.type.startsWith("bytes")}isString(){return this.type==="string"}get tupleName(){if(this.type!=="tuple")throw TypeError("not a tuple");return uC(this,kp,"f")}get arrayLength(){if(this.type!=="array")throw TypeError("not an array");return uC(this,kp,"f")===!0?-1:uC(this,kp,"f")===!1?this.value.length:null}static from(e,t){return new Fn(Vu,e,t)}static uint8(e){return Ot(e,8)}static uint16(e){return Ot(e,16)}static uint24(e){return Ot(e,24)}static uint32(e){return Ot(e,32)}static uint40(e){return Ot(e,40)}static uint48(e){return Ot(e,48)}static uint56(e){return Ot(e,56)}static uint64(e){return Ot(e,64)}static uint72(e){return Ot(e,72)}static uint80(e){return Ot(e,80)}static uint88(e){return Ot(e,88)}static uint96(e){return Ot(e,96)}static uint104(e){return Ot(e,104)}static uint112(e){return Ot(e,112)}static uint120(e){return Ot(e,120)}static uint128(e){return Ot(e,128)}static uint136(e){return Ot(e,136)}static uint144(e){return Ot(e,144)}static uint152(e){return Ot(e,152)}static uint160(e){return Ot(e,160)}static uint168(e){return Ot(e,168)}static uint176(e){return Ot(e,176)}static uint184(e){return Ot(e,184)}static uint192(e){return Ot(e,192)}static uint200(e){return Ot(e,200)}static uint208(e){return Ot(e,208)}static uint216(e){return Ot(e,216)}static uint224(e){return Ot(e,224)}static uint232(e){return Ot(e,232)}static uint240(e){return Ot(e,240)}static uint248(e){return Ot(e,248)}static uint256(e){return Ot(e,256)}static uint(e){return Ot(e,256)}static int8(e){return Ot(e,-8)}static int16(e){return Ot(e,-16)}static int24(e){return Ot(e,-24)}static int32(e){return Ot(e,-32)}static int40(e){return Ot(e,-40)}static int48(e){return Ot(e,-48)}static int56(e){return Ot(e,-56)}static int64(e){return Ot(e,-64)}static int72(e){return Ot(e,-72)}static int80(e){return Ot(e,-80)}static int88(e){return Ot(e,-88)}static int96(e){return Ot(e,-96)}static int104(e){return Ot(e,-104)}static int112(e){return Ot(e,-112)}static int120(e){return Ot(e,-120)}static int128(e){return Ot(e,-128)}static int136(e){return Ot(e,-136)}static int144(e){return Ot(e,-144)}static int152(e){return Ot(e,-152)}static int160(e){return Ot(e,-160)}static int168(e){return Ot(e,-168)}static int176(e){return Ot(e,-176)}static int184(e){return Ot(e,-184)}static int192(e){return Ot(e,-192)}static int200(e){return Ot(e,-200)}static int208(e){return Ot(e,-208)}static int216(e){return Ot(e,-216)}static int224(e){return Ot(e,-224)}static int232(e){return Ot(e,-232)}static int240(e){return Ot(e,-240)}static int248(e){return Ot(e,-248)}static int256(e){return Ot(e,-256)}static int(e){return Ot(e,-256)}static bytes1(e){return _s(e,1)}static bytes2(e){return _s(e,2)}static bytes3(e){return _s(e,3)}static bytes4(e){return _s(e,4)}static bytes5(e){return _s(e,5)}static bytes6(e){return _s(e,6)}static bytes7(e){return _s(e,7)}static bytes8(e){return _s(e,8)}static bytes9(e){return _s(e,9)}static bytes10(e){return _s(e,10)}static bytes11(e){return _s(e,11)}static bytes12(e){return _s(e,12)}static bytes13(e){return _s(e,13)}static bytes14(e){return _s(e,14)}static bytes15(e){return _s(e,15)}static bytes16(e){return _s(e,16)}static bytes17(e){return _s(e,17)}static bytes18(e){return _s(e,18)}static bytes19(e){return _s(e,19)}static bytes20(e){return _s(e,20)}static bytes21(e){return _s(e,21)}static bytes22(e){return _s(e,22)}static bytes23(e){return _s(e,23)}static bytes24(e){return _s(e,24)}static bytes25(e){return _s(e,25)}static bytes26(e){return _s(e,26)}static bytes27(e){return _s(e,27)}static bytes28(e){return _s(e,28)}static bytes29(e){return _s(e,29)}static bytes30(e){return _s(e,30)}static bytes31(e){return _s(e,31)}static bytes32(e){return _s(e,32)}static address(e){return new Fn(Vu,"address",e)}static bool(e){return new Fn(Vu,"bool",!!e)}static bytes(e){return new Fn(Vu,"bytes",e)}static string(e){return new Fn(Vu,"string",e)}static array(e,t){throw new Error("not implemented yet")}static tuple(e,t){throw new Error("not implemented yet")}static overrides(e){return new Fn(Vu,"overrides",Object.assign({},e))}static isTyped(e){return e&&typeof e=="object"&&"_typedSymbol"in e&&e._typedSymbol===k3}static dereference(e,t){if(Fn.isTyped(e)){if(e.type!==t)throw new Error(`invalid type: expecetd ${t}, got ${e.type}`);return e.value}return e}}kp=new WeakMap;class RBe extends ou{constructor(e){super("address","address",e,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(e,t){let s=Fn.dereference(t,"string");try{s=$v(s)}catch(i){return this._throwError(i.message,t)}return e.writeValue(s)}decode(e){return $v(tx(e.readValue(),20))}}class DBe extends ou{constructor(e){super(e.name,e.type,"_",e.dynamic),this.coder=e}defaultValue(){return this.coder.defaultValue()}encode(e,t){return this.coder.encode(e,t)}decode(e){return this.coder.decode(e)}}function Y7(d,e,t){let s=[];if(Array.isArray(t))s=t;else if(t&&typeof t=="object"){let o={};s=e.map(c=>{const u=c.localName;return jn(u,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:c},value:t}),jn(!o[u],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:c},value:t}),o[u]=!0,t[u]})}else Vt(!1,"invalid tuple value","tuple",t);Vt(e.length===s.length,"types/value length mismatch","tuple",t);let i=new N2,n=new N2,r=[];e.forEach((o,c)=>{let u=s[c];if(o.dynamic){let h=n.length;o.encode(n,u);let l=i.writeUpdatableValue();r.push(f=>{l(f+h)})}else o.encode(i,u)}),r.forEach(o=>{o(i.length)});let a=d.appendWriter(i);return a+=d.appendWriter(n),a}function Z7(d,e){let t=[],s=[],i=d.subReader(0);return e.forEach(n=>{let r=null;if(n.dynamic){let a=d.readIndex(),o=i.subReader(a);try{r=n.decode(o)}catch(c){if(l3(c,"BUFFER_OVERRUN"))throw c;r=c,r.baseType=n.name,r.name=n.localName,r.type=n.type}}else try{r=n.decode(d)}catch(a){if(l3(a,"BUFFER_OVERRUN"))throw a;r=a,r.baseType=n.name,r.name=n.localName,r.type=n.type}if(r==null)throw new Error("investigate");t.push(r),s.push(n.localName||null)}),m0.fromItems(t,s)}class qBe extends ou{constructor(e,t,s){const i=e.type+"["+(t>=0?t:"")+"]",n=t===-1||e.dynamic;super("array",i,s,n),Qo(this,{coder:e,length:t})}defaultValue(){const e=this.coder.defaultValue(),t=[];for(let s=0;sn||s<-(n+jBe))&&this._throwError("value out-of-bounds",t),s=V7(s,8*gr)}else(sRy(i,this.size*8))&&this._throwError("value out-of-bounds",t);return e.writeValue(s)}decode(e){let t=Ry(e.readValue(),this.size*8);return this.signed&&(t=WLe(t,this.size*8)),t}}class KBe extends J7{constructor(e){super("string",e)}defaultValue(){return""}encode(e,t){return super.encode(e,YLe(Fn.dereference(t,"string")))}decode(e){return JLe(super.decode(e))}}class k1 extends ou{constructor(e,t){let s=!1;const i=[];e.forEach(r=>{r.dynamic&&(s=!0),i.push(r.type)});const n="tuple("+i.join(",")+")";super("tuple",n,t,s),Qo(this,{coders:Object.freeze(e.slice())})}defaultValue(){const e=[];this.coders.forEach(s=>{e.push(s.defaultValue())});const t=this.coders.reduce((s,i)=>{const n=i.localName;return n&&(s[n]||(s[n]=0),s[n]++),s},{});return this.coders.forEach((s,i)=>{let n=s.localName;!n||t[n]!==1||(n==="length"&&(n="_length"),e[n]==null&&(e[n]=e[i]))}),Object.freeze(e)}encode(e,t){const s=Fn.dereference(t,"tuple");return Y7(e,this.coders,s)}decode(e){return Z7(e,this.coders)}}var ol=function(d,e,t,s,i){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?d!==e||!i:!e.has(d))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?i.call(d,t):i?i.value=t:e.set(d,t),t},Ui=function(d,e,t,s){if(t==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?d!==e||!s:!e.has(d))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?s:t==="a"?s.call(d):s?s.value:e.get(d)},S1,En,wd,E2,g0,ez;function pg(d){const e=new Set;return d.forEach(t=>e.add(t)),Object.freeze(e)}const XBe="external public payable";pg(XBe.split(" "));const tz="constant external internal payable private public pure view";pg(tz.split(" "));const sz="constructor error event fallback function receive struct";pg(sz.split(" "));const iz="calldata memory storage payable indexed",QBe=pg(iz.split(" ")),YBe="tuple returns",ZBe=[sz,iz,YBe,tz].join(" "),JBe=pg(ZBe.split(" ")),eNe={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},tNe=new RegExp("^(\\s*)"),sNe=new RegExp("^([0-9]+)"),iNe=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),nNe=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),nz=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$");class Tb{constructor(e){S1.add(this),En.set(this,void 0),wd.set(this,void 0),ol(this,En,0,"f"),ol(this,wd,e.slice(),"f")}get offset(){return Ui(this,En,"f")}get length(){return Ui(this,wd,"f").length-Ui(this,En,"f")}clone(){return new Tb(Ui(this,wd,"f"))}reset(){ol(this,En,0,"f")}popKeyword(e){const t=this.peek();if(t.type!=="KEYWORD"||!e.has(t.text))throw new Error(`expected keyword ${t.text}`);return this.pop().text}popType(e){if(this.peek().type!==e)throw new Error(`expected ${e}; got ${JSON.stringify(this.peek())}`);return this.pop().text}popParen(){const e=this.peek();if(e.type!=="OPEN_PAREN")throw new Error("bad start");const t=Ui(this,S1,"m",E2).call(this,Ui(this,En,"f")+1,e.match+1);return ol(this,En,e.match+1,"f"),t}popParams(){const e=this.peek();if(e.type!=="OPEN_PAREN")throw new Error("bad start");const t=[];for(;Ui(this,En,"f")=Ui(this,wd,"f").length)throw new Error("out-of-bounds");return Ui(this,wd,"f")[Ui(this,En,"f")]}peekKeyword(e){const t=this.peekType("KEYWORD");return t!=null&&e.has(t)?t:null}peekType(e){if(this.length===0)return null;const t=this.peek();return t.type===e?t.text:null}pop(){var e;const t=this.peek();return ol(this,En,(e=Ui(this,En,"f"),e++,e),"f"),t}toString(){const e=[];for(let t=Ui(this,En,"f");t`}}En=new WeakMap,wd=new WeakMap,S1=new WeakSet,E2=function(e=0,t=0){return new Tb(Ui(this,wd,"f").slice(e,t).map(s=>Object.freeze(Object.assign({},s,{match:s.match-e,linkBack:s.linkBack-e,linkNext:s.linkNext-e}))))};function rNe(d){const e=[],t=r=>{const a=n0&&e[e.length-1].type==="NUMBER"){const h=e.pop().text;u=h+u,e[e.length-1].value=zh(h)}if(e.length===0||e[e.length-1].type!=="BRACKET")throw new Error("missing opening bracket");e[e.length-1].text+=u}continue}if(a=r.match(iNe),a){if(o.text=a[1],n+=o.text.length,JBe.has(o.text)){o.type="KEYWORD";continue}if(o.text.match(nz)){o.type="TYPE";continue}o.type="ID";continue}if(a=r.match(sNe),a){o.text=a[1],o.type="NUMBER",n+=o.text.length;continue}throw new Error(`unexpected token ${JSON.stringify(r[0])} at position ${n}`)}return new Tb(e.map(r=>Object.freeze(r)))}function S3(d,e){const t=new Set;for(;;){const s=d.peekType("KEYWORD");if(s==null||e&&!e.has(s))break;if(d.pop(),t.has(s))throw new Error(`duplicate keywords: ${JSON.stringify(s)}`);t.add(s)}return Object.freeze(t)}const aNe=new RegExp(/^(.*)\[([0-9]*)\]$/);function v3(d){const e=d.match(nz);if(Vt(e,"invalid type","type",d),d==="uint")return"uint256";if(d==="int")return"int256";if(e[2]){const t=parseInt(e[2]);Vt(t!==0&&t<=32,"invalid bytes length","type",d)}else if(e[3]){const t=parseInt(e[3]);Vt(t!==0&&t<=256&&t%8===0,"invalid numeric width","type",d)}return d}const up={},T3=Symbol.for("_ethers_internal"),O3="_ParamTypeInternal";class Lr{constructor(e,t,s,i,n,r,a,o){if(g0.add(this),FLe(e,up,"ParamType"),Object.defineProperty(this,T3,{value:O3}),r&&(r=Object.freeze(r.slice())),i==="array"){if(a==null||o==null)throw new Error("")}else if(a!=null||o!=null)throw new Error("");if(i==="tuple"){if(r==null)throw new Error("")}else if(r!=null)throw new Error("");Qo(this,{name:t,type:s,baseType:i,indexed:n,components:r,arrayLength:a,arrayChildren:o})}format(e){if(e==null&&(e="sighash"),e==="json"){const s=this.name||"";if(this.isArray()){const n=JSON.parse(this.arrayChildren.format("json"));return n.name=s,n.type+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`,JSON.stringify(n)}const i={type:this.baseType==="tuple"?"tuple":this.type,name:s};return typeof this.indexed=="boolean"&&(i.indexed=this.indexed),this.isTuple()&&(i.components=this.components.map(n=>JSON.parse(n.format(e)))),JSON.stringify(i)}let t="";return this.isArray()?(t+=this.arrayChildren.format(e),t+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`):this.isTuple()?t+="("+this.components.map(s=>s.format(e)).join(e==="full"?", ":",")+")":t+=this.type,e!=="sighash"&&(this.indexed===!0&&(t+=" indexed"),e==="full"&&this.name&&(t+=" "+this.name)),t}isArray(){return this.baseType==="array"}isTuple(){return this.baseType==="tuple"}isIndexable(){return this.indexed!=null}walk(e,t){if(this.isArray()){if(!Array.isArray(e))throw new Error("invalid array value");if(this.arrayLength!==-1&&e.length!==this.arrayLength)throw new Error("array is wrong length");const s=this;return e.map(i=>s.arrayChildren.walk(i,t))}if(this.isTuple()){if(!Array.isArray(e))throw new Error("invalid tuple value");if(e.length!==this.components.length)throw new Error("array is wrong length");const s=this;return e.map((i,n)=>s.components[n].walk(i,t))}return t(this.type,e)}async walkAsync(e,t){const s=[],i=[e];return Ui(this,g0,"m",ez).call(this,s,e,t,n=>{i[0]=n}),s.length&&await Promise.all(s),i[0]}static from(e,t){if(Lr.isParamType(e))return e;if(typeof e=="string")try{return Lr.from(rNe(e),t)}catch{Vt(!1,"invalid param type","obj",e)}else if(e instanceof Tb){let a="",o="",c=null;S3(e,pg(["tuple"])).has("tuple")||e.peekType("OPEN_PAREN")?(o="tuple",c=e.popParams().map(m=>Lr.from(m)),a=`tuple(${c.map(m=>m.format()).join(",")})`):(a=v3(e.popType("TYPE")),o=a);let u=null,h=null;for(;e.length&&e.peekType("BRACKET");){const m=e.pop();u=new Lr(up,"",a,o,null,c,h,u),h=m.value,a+=m.text,o="array",c=null}let l=null;if(S3(e,QBe).has("indexed")){if(!t)throw new Error("");l=!0}const p=e.peekType("ID")?e.pop().text:"";if(e.length)throw new Error("leftover tokens");return new Lr(up,p,a,o,l,c,h,u)}const s=e.name;Vt(!s||typeof s=="string"&&s.match(nNe),"invalid name","obj.name",s);let i=e.indexed;i!=null&&(Vt(t,"parameter cannot be indexed","obj.indexed",e.indexed),i=!!i);let n=e.type,r=n.match(aNe);if(r){const a=parseInt(r[2]||"-1"),o=Lr.from({type:r[1],components:e.components});return new Lr(up,s||"",n,"array",i,null,a,o)}if(n==="tuple"||n.startsWith("tuple(")||n.startsWith("(")){const a=e.components!=null?e.components.map(c=>Lr.from(c)):null;return new Lr(up,s||"",n,"tuple",i,a,null,null)}return n=v3(e.type),new Lr(up,s||"",n,n,i,null,null,null)}static isParamType(e){return e&&e[T3]===O3}}g0=new WeakSet,ez=function d(e,t,s,i){if(this.isArray()){if(!Array.isArray(t))throw new Error("invalid array value");if(this.arrayLength!==-1&&t.length!==this.arrayLength)throw new Error("array is wrong length");const r=this.arrayChildren,a=t.slice();a.forEach((o,c)=>{Ui(r,g0,"m",d).call(r,e,o,s,u=>{a[c]=u})}),i(a);return}if(this.isTuple()){const r=this.components;let a;if(Array.isArray(t))a=t.slice();else{if(t==null||typeof t!="object")throw new Error("invalid tuple value");a=r.map(o=>{if(!o.name)throw new Error("cannot use object value with unnamed components");if(!(o.name in t))throw new Error(`missing value for component ${o.name}`);return t[o.name]})}if(a.length!==this.components.length)throw new Error("array is wrong length");a.forEach((o,c)=>{var u;Ui(u=r[c],g0,"m",d).call(u,e,o,s,h=>{a[c]=h})}),i(a);return}const n=s(this.type,t);n.then?e.push(async function(){i(await n)}()):i(n)};var y0=function(d,e,t,s){if(t==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?d!==e||!s:!e.has(d))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?s:t==="a"?s.call(d):s?s.value:e.get(d)},Ml,v1;const Yd=new Map;Yd.set(0,"GENERIC_PANIC");Yd.set(1,"ASSERT_FALSE");Yd.set(17,"OVERFLOW");Yd.set(18,"DIVIDE_BY_ZERO");Yd.set(33,"ENUM_RANGE_ERROR");Yd.set(34,"BAD_STORAGE_DATA");Yd.set(49,"STACK_UNDERFLOW");Yd.set(50,"ARRAY_RANGE_ERROR");Yd.set(65,"OUT_OF_MEMORY");Yd.set(81,"UNINITIALIZED_FUNCTION_CALL");const oNe=new RegExp(/^bytes([0-9]*)$/),dNe=new RegExp(/^(u?int)([0-9]*)$/);let hC=null,x3=1024;class PB{constructor(){Ml.add(this)}getDefaultValue(e){const t=e.map(i=>y0(this,Ml,"m",v1).call(this,Lr.from(i)));return new k1(t,"_").defaultValue()}encode(e,t){D7(t.length,e.length,"types/values length mismatch");const s=e.map(r=>y0(this,Ml,"m",v1).call(this,Lr.from(r))),i=new k1(s,"_"),n=new N2;return i.encode(n,t),n.data}decode(e,t,s){const i=e.map(r=>y0(this,Ml,"m",v1).call(this,Lr.from(r)));return new k1(i,"_").decode(new OB(t,s,x3))}static _setDefaultMaxInflation(e){Vt(typeof e=="number"&&Number.isInteger(e),"invalid defaultMaxInflation factor","value",e),x3=e}static defaultAbiCoder(){return hC==null&&(hC=new PB),hC}}Ml=new WeakSet,v1=function d(e){if(e.isArray())return new qBe(y0(this,Ml,"m",d).call(this,e.arrayChildren),e.arrayLength,e.name);if(e.isTuple())return new k1(e.components.map(s=>y0(this,Ml,"m",d).call(this,s)),e.name);switch(e.baseType){case"address":return new RBe(e.name);case"bool":return new VBe(e.name);case"string":return new KBe(e.name);case"bytes":return new FBe(e.name);case"":return new UBe(e.name)}let t=e.type.match(dNe);if(t){let s=parseInt(t[2]||"256");return Vt(s!==0&&s<=256&&s%8===0,"invalid "+t[1]+" bit length","param",e),new $Be(s/8,t[1]==="int",e.name)}if(t=e.type.match(oNe),t){let s=parseInt(t[1]);return Vt(s!==0&&s<=32,"invalid bytes length","param",e),new HBe(s,e.name)}Vt(!1,"invalid type","type",e.type)};const cNe=PB.defaultAbiCoder();var lC=function(d,e,t,s,i){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?d!==e||!i:!e.has(d))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?i.call(d,t):i?i.value=t:e.set(d,t),t},kc=function(d,e,t,s){if(t==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?d!==e||!s:!e.has(d))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?s:t==="a"?s.call(d):s?s.value:e.get(d)},R2,T1,Zu,qy,rz;const{base16ToBinary:uNe}=ZO,az=new Uint8Array(32);az.fill(0);const hNe=BigInt(-1),oz=BigInt(0),dz=BigInt(1),lNe=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function fNe(d){const e=jh(d),t=e.length%32;return t?of([e,az.slice(t)]):au(e)}const pNe=tx(dz,32),mNe=tx(oz,32),P3={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},fC=["name","version","chainId","verifyingContract","salt"];function I3(d){return function(e){return Vt(typeof e=="string",`invalid domain value for ${JSON.stringify(d)}`,`domain.${d}`,e),e}}const gNe={name:I3("name"),version:I3("version"),chainId:function(d){const e=Pf(d,"domain.chainId");return Vt(e>=0,"invalid chain ID","domain.chainId",d),Number.isSafeInteger(e)?Number(e):zLe(e)},verifyingContract:function(d){try{return $v(d).toLowerCase()}catch{}Vt(!1,'invalid domain value "verifyingContract"',"domain.verifyingContract",d)},salt:function(d){const e=jh(d,"domain.salt");return Vt(e.length===32,'invalid domain value "salt"',"domain.salt",d),au(e)}};function D2(d){{const e=d.match(/^(u?)int(\d*)$/);if(e){const t=e[1]==="",s=parseInt(e[2]||"256");Vt(s%8===0&&s!==0&&s<=256&&(e[2]==null||e[2]===String(s)),"invalid numeric width","type",d);const i=Ry(lNe,t?s-1:s),n=t?(i+dz)*hNe:oz;return function(r){const a=Pf(r,"value");return Vt(a>=n&&a<=i,`value out-of-bounds for ${d}`,"value",a),tx(t?V7(a,256):a,32)}}}{const e=d.match(/^bytes(\d+)$/);if(e){const t=parseInt(e[1]);return Vt(t!==0&&t<=32&&e[1]===String(t),"invalid bytes width","type",d),function(s){const i=jh(s);return Vt(i.length===t,`invalid length for ${d}`,"value",s),fNe(s)}}}switch(d){case"address":return function(e){return ULe($v(e),32)};case"bool":return function(e){return e?pNe:mNe};case"bytes":return function(e){return lm(e)};case"string":return function(e){return K7(e)}}return null}function C3(d,e){return`${d}(${e.map(({name:t,type:s})=>s+" "+t).join(",")})`}class Wa{constructor(e){R2.add(this),T1.set(this,void 0),Zu.set(this,void 0),qy.set(this,void 0),lC(this,T1,JSON.stringify(e),"f"),lC(this,Zu,new Map,"f"),lC(this,qy,new Map,"f");const t=new Map,s=new Map,i=new Map;Object.keys(e).forEach(a=>{t.set(a,new Set),s.set(a,[]),i.set(a,new Set)});for(const a in e){const o=new Set;for(const c of e[a]){Vt(!o.has(c.name),`duplicate variable name ${JSON.stringify(c.name)} in ${JSON.stringify(a)}`,"types",e),o.add(c.name);const u=c.type.match(/^([^\x5b]*)(\x5b|$)/)[1]||null;Vt(u!==a,`circular type reference to ${JSON.stringify(u)}`,"types",e),!D2(u)&&(Vt(s.has(u),`unknown type ${JSON.stringify(u)}`,"types",e),s.get(u).push(a),t.get(a).add(u))}}const n=Array.from(s.keys()).filter(a=>s.get(a).length===0);Vt(n.length!==0,"missing primary type","types",e),Vt(n.length===1,`ambiguous primary types or unused types: ${n.map(a=>JSON.stringify(a)).join(", ")}`,"types",e),Qo(this,{primaryType:n[0]});function r(a,o){Vt(!o.has(a),`circular type reference to ${JSON.stringify(a)}`,"types",e),o.add(a);for(const c of t.get(a))if(s.has(c)){r(c,o);for(const u of o)i.get(u).add(c)}o.delete(a)}r(this.primaryType,new Set);for(const[a,o]of i){const c=Array.from(o);c.sort(),kc(this,Zu,"f").set(a,C3(a,e[a])+c.map(u=>C3(u,e[u])).join(""))}}get types(){return JSON.parse(kc(this,T1,"f"))}getEncoder(e){let t=kc(this,qy,"f").get(e);return t||(t=kc(this,R2,"m",rz).call(this,e),kc(this,qy,"f").set(e,t)),t}encodeType(e){const t=kc(this,Zu,"f").get(e);return Vt(t,`unknown type: ${JSON.stringify(e)}`,"name",e),t}encodeData(e,t){return this.getEncoder(e)(t)}hashStruct(e,t){return lm(uNe(this.encodeData(e,t).slice(2)))}encode(e){return this.encodeData(this.primaryType,e)}hash(e){return this.hashStruct(this.primaryType,e)}_visit(e,t,s){if(D2(e))return s(e,t);const i=e.match(/^(.*)(\x5b(\d*)\x5d)$/);if(i)return Vt(!i[3]||parseInt(i[3])===t.length,`array length mismatch; expected length ${parseInt(i[3])}`,"value",t),t.map(r=>this._visit(i[1],r,s));const n=this.types[e];if(n)return n.reduce((r,{name:a,type:o})=>(r[a]=this._visit(o,t[a],s),r),{});Vt(!1,`unknown type: ${e}`,"type",e)}visit(e,t){return this._visit(this.primaryType,e,t)}static from(e){return new Wa(e)}static getPrimaryType(e){return Wa.from(e).primaryType}static hashStruct(e,t,s){return Wa.from(t).hashStruct(e,s)}static hashDomain(e){const t=[];for(const s in e){if(e[s]==null)continue;const i=P3[s];Vt(i,`invalid typed-data domain key: ${JSON.stringify(s)}`,"domain",e),t.push({name:s,type:i})}return t.sort((s,i)=>fC.indexOf(s.name)-fC.indexOf(i.name)),Wa.hashStruct("EIP712Domain",{EIP712Domain:t},e)}static encode(e,t,s){return of(["0x1901",Wa.hashDomain(e),Wa.from(t).hash(s)])}static hash(e,t,s){return lm(Wa.encode(e,t,s))}static async resolveNames(e,t,s,i){e=Object.assign({},e);for(const a in e)e[a]==null&&delete e[a];const n={};e.verifyingContract&&!A2(e.verifyingContract,20)&&(n[e.verifyingContract]="0x");const r=Wa.from(t);r.visit(s,(a,o)=>(a==="address"&&!A2(o,20)&&(n[o]="0x"),o));for(const a in n)n[a]=await i(a);return e.verifyingContract&&n[e.verifyingContract]&&(e.verifyingContract=n[e.verifyingContract]),s=r.visit(s,(a,o)=>a==="address"&&n[o]?n[o]:o),{domain:e,value:s}}static getPayload(e,t,s){Wa.hashDomain(e);const i={},n=[];fC.forEach(o=>{const c=e[o];c!=null&&(i[o]=gNe[o](c),n.push({name:o,type:P3[o]}))});const r=Wa.from(t),a=Object.assign({},t);return Vt(a.EIP712Domain==null,"types must not contain EIP712Domain type","types.EIP712Domain",t),a.EIP712Domain=n,r.encode(s),{types:a,domain:i,primaryType:r.primaryType,message:r.visit(s,(o,c)=>{if(o.match(/^bytes(\d*)/))return au(jh(c));if(o.match(/^u?int/))return Pf(c).toString();switch(o){case"address":return c.toLowerCase();case"bool":return!!c;case"string":return Vt(typeof c=="string","invalid string","value",c),c}Vt(!1,"unsupported type","type",o)})}}}T1=new WeakMap,Zu=new WeakMap,qy=new WeakMap,R2=new WeakSet,rz=function(e){{const i=D2(e);if(i)return i}const t=e.match(/^(.*)(\x5b(\d*)\x5d)$/);if(t){const i=t[1],n=this.getEncoder(i);return r=>{Vt(!t[3]||parseInt(t[3])===r.length,`array length mismatch; expected length ${parseInt(t[3])}`,"value",r);let a=r.map(n);return kc(this,Zu,"f").has(i)&&(a=a.map(lm)),lm(jh(of(a)))}}const s=this.types[e];if(s){const i=K7(kc(this,Zu,"f").get(e));return n=>{const r=s.map(({name:a,type:o})=>{const c=this.getEncoder(o)(n[a]);return kc(this,Zu,"f").has(o)?lm(c):c});return r.unshift(i),of(r)}}Vt(!1,`unknown type: ${e}`,"type",e)};class yNe{constructor(){this.i=0,this.j=0,this.S=[]}init(e){let t,s,i;for(t=0;t<256;++t)this.S[t]=t;for(s=0,t=0;t<256;++t)s=s+this.S[t]+e[t%e.length]&255,i=this.S[t],this.S[t]=this.S[s],this.S[s]=i;this.i=0,this.j=0}next(){let e;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,e=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=e,this.S[e+this.S[this.i]&255]}}function wNe(){return new yNe}let cz=256,_S,Ju=null,Mo;if(Ju==null){Ju=[],Mo=0;let d;if(typeof window<"u"&&window.crypto&&window.crypto.getRandomValues){const t=new Uint32Array(256);for(window.crypto.getRandomValues(t),d=0;d=256||Mo>=cz){window.removeEventListener?window.removeEventListener("mousemove",e,!1):window.detachEvent&&window.detachEvent("onmousemove",e);return}try{const s=t.x+t.y;Ju[Mo++]=s&255,AS+=1}catch{}};typeof window<"u"&&(window.addEventListener?window.addEventListener("mousemove",e,!1):window.attachEvent&&window.attachEvent("onmousemove",e))}function bNe(){if(_S==null){for(_S=wNe();Mot7(e,o,s);if(t===3?i=o=>e.mul(e.sqrN(o),o):t===5&&(i=o=>e.mul(e.sqrN(e.sqrN(o)),o)),d.roundsFull%2!==0)throw new Error(`Poseidon roundsFull is not even: ${d.roundsFull}`);const n=d.roundsFull+d.roundsPartial;if(!Array.isArray(d.roundConstants)||d.roundConstants.length!==n)throw new Error("Poseidon: wrong round constants");const r=d.roundConstants.map(o=>{if(!Array.isArray(o)||o.length!==d.t)throw new Error(`Poseidon wrong round constants: ${o}`);return o.map(c=>{if(typeof c!="bigint"||!e.isValid(c))throw new Error(`Poseidon wrong round constant=${c}`);return e.create(c)})});if(!Array.isArray(d.mds)||d.mds.length!==d.t)throw new Error("Poseidon: wrong MDS matrix");const a=d.mds.map(o=>{if(!Array.isArray(o)||o.length!==d.t)throw new Error(`Poseidon MDS matrix row: ${o}`);return o.map(c=>{if(typeof c!="bigint")throw new Error(`Poseidon MDS matrix value=${c}`);return e.create(c)})});return Object.freeze({...d,rounds:n,sboxFn:i,roundConstants:r,mds:a})}function SNe(d){const{t:e,Fp:t,rounds:s,sboxFn:i,reversePartialPowIdx:n}=kNe(d),r=Math.floor(d.roundsFull/2),a=n?e-1:0,o=(u,h,l)=>(u=u.map((f,p)=>t.add(f,d.roundConstants[l][p])),h?u=u.map(f=>i(f)):u[a]=i(u[a]),u=d.mds.map(f=>f.reduce((p,m,g)=>t.add(p,t.mulN(m,u[g])),t.ZERO)),u),c=function(h){if(!Array.isArray(h)||h.length!==e)throw new Error(`Poseidon: wrong values (expected array of bigints with length ${e})`);h=h.map(f=>{if(typeof f!="bigint")throw new Error(`Poseidon: wrong value=${f} (${typeof f})`);return t.create(f)});let l=0;for(let f=0;f0?t>>BigInt(e):t}function hz(d){return typeof d=="string"&&(d=pz(d),d.length&1&&(d="0"+d)),af(d)}const ix=i7({a:BigInt(1),b:BigInt("3141592653589793238462643383279502884197169399375105820974944592307816406665"),Fp:kb(BigInt("0x800000000000011000000000000000000000000000000000000000000000001")),n:Pw,nBitLength:uz,Gx:BigInt("874739451078007766457464989774322083649278607533249481151382481072868806602"),Gy:BigInt("152666792071518830868575557812948353041420400780739481342941381225525861407"),h:BigInt(1),lowS:!1,...r7(He),bits2int:M3,bits2int_modN:d=>{const e=Ki(d).toString(16);return e.length===63&&(d=hz(e+"0")),Ps(M3(d),Pw)}});function nx(d){return xs("",typeof d=="string"?hz(d):d)}function lz(d){return jd(nx(d)).padStart(64,"0")}function vNe(d,e=!1){return ix.getPublicKey(lz(d),e)}function TNe(d){const{r:e,s:t}=d;if(e<0n||e>=Wp)throw new Error(`Signature.r should be [1, ${Wp})`);const s=Wv(t,Pw);if(s<0n||s>=Wp)throw new Error(`inv(Signature.s) should be [1, ${Wp})`)}function ONe(d){const e=nx(d);if(Ki(e)>=Wp)throw new Error(`msgHash should be [0, ${Wp})`);return e}function xNe(d,e,t){const s=ix.sign(ONe(d),lz(e),t);return TNe(s),s}const{CURVE:WWe,ProjectivePoint:wy,Signature:jWe,utils:zWe}=ix;function fz(d){return`0x${jd(d.subarray(1)).replace(/^0+/gm,"")}`}function pz(d){return d.replace(/^0x/i,"")}function PNe(d){const e=nx(d),t=2n**256n,s=t-Ps(t,Pw);for(let i=0;;i++){const n=NNe(vn(e,qj(BigInt(i))));if(n>=1n}return d}function gz(d,e){let t=Iw[0];return t=_3(t,d,MNe),t=_3(t,e,_Ne),fz(t.toRawBytes(!0))}const LNe=GO(250),BNe=d=>Ki(pr(d))&LNe,NNe=d=>Ki(He(d)),ENe=kb(BigInt("3618502788666131213697322783095070105623107215331596699973092056135872020481"));function RNe(d,e,t){const s=d.fromBytes(He(aB(`${e}${t}`)));return d.create(s)}const DNe=[[3,1,1],[1,-1,1],[1,1,-2]].map(d=>d.map(BigInt));function qNe(d,e){if(zO(d.Fp),!Number.isSafeInteger(d.rate)||!Number.isSafeInteger(d.capacity))throw new Error(`Wrong poseidon opts: ${d}`);const t=d.rate+d.capacity,s=d.roundsFull+d.roundsPartial,i=[];for(let r=0;r"u")throw new Error("invalid index");n[a]+=o}n=e(n)}return n[0]}function HNe(d){return new TextEncoder().encode(d)}function _l(d){return d.replace(/^0x/i,"")}function io(d){return`0x${_l(d)}`}const wz=31,bz=0n,GNe=2n**250n-1n,kz=2n**251n+17n*2n**192n+1n,UNe=256n,WNe=2n**251n-UNe,IB=(d,e)=>({min:d,max:e}),A3=IB(bz,kz-1n),jNe=IB(-(2n**127n),2n**127n-1n),zNe=IB(bz,2n**128n-1n);var L3;(function(d){d.SN_MAIN="https://alpha-mainnet.starknet.io",d.SN_SEPOLIA="https://alpha-sepolia.starknet.io"})(L3||(L3={}));var B3;(function(d){d.SN_MAIN="SN_MAIN",d.SN_SEPOLIA="SN_SEPOLIA"})(B3||(B3={}));var N3;(function(d){d.SN_MAIN="0x534e5f4d41494e",d.SN_SEPOLIA="0x534e5f5345504f4c4941"})(N3||(N3={}));var E3;(function(d){d.DECLARE="0x6465636c617265",d.DEPLOY="0x6465706c6f79",d.DEPLOY_ACCOUNT="0x6465706c6f795f6163636f756e74",d.INVOKE="0x696e766f6b65",d.L1_HANDLER="0x6c315f68616e646c6572"})(E3||(E3={}));function Js(d,e){if(!d)throw new Error(e||"Assertion failure")}function Ob(d){return/^0x[0-9a-f]*$/i.test(d)}function Sz(d){return BigInt(d)}function xb(d){return typeof d=="bigint"}function fo(d){return io(Sz(d).toString(16))}const vz=d=>/^\d+$/.test(d);function q2(d){return typeof d=="number"}function Tz(d){return typeof d=="boolean"}function $Ne(d){return io(BNe(HNe(d)).toString(16))}function KNe(d){return BigInt($Ne(d))&GNe}function rx(d){return fo(KNe(d))}var jp;(function(d){d.DEPLOY="DEPLOY",d.CALL="CALL",d.INVOKE="INVOKE"})(jp||(jp={}));var Br;(function(d){d.u8="core::integer::u8",d.u16="core::integer::u16",d.u32="core::integer::u32",d.u64="core::integer::u64",d.u128="core::integer::u128",d.u256="core::integer::u256",d.u512="core::integer::u512"})(Br||(Br={}));var pm;(function(d){d.ClassHash="core::starknet::class_hash::ClassHash",d.ContractAddress="core::starknet::contract_address::ContractAddress",d.Secp256k1Point="core::starknet::secp256k1::Secp256k1Point"})(pm||(pm={}));var R3;(function(d){d[d.function=0]="function",d[d.l1_handler=1]="l1_handler",d[d.constructor=2]="constructor"})(R3||(R3={}));var D3;(function(d){d.EXTERNAL="EXTERNAL",d.L1_HANDLER="L1_HANDLER",d.CONSTRUCTOR="CONSTRUCTOR"})(D3||(D3={}));var q3;(function(d){d.DECLARE="DECLARE",d.DEPLOY="DEPLOY",d.DEPLOY_ACCOUNT="DEPLOY_ACCOUNT",d.INVOKE="INVOKE_FUNCTION"})(q3||(q3={}));var V3;(function(d){d.NOT_RECEIVED="NOT_RECEIVED",d.RECEIVED="RECEIVED",d.ACCEPTED_ON_L2="ACCEPTED_ON_L2",d.ACCEPTED_ON_L1="ACCEPTED_ON_L1",d.REJECTED="REJECTED",d.REVERTED="REVERTED"})(V3||(V3={}));var F3;(function(d){d.NOT_RECEIVED="NOT_RECEIVED",d.RECEIVED="RECEIVED",d.ACCEPTED_ON_L2="ACCEPTED_ON_L2",d.ACCEPTED_ON_L1="ACCEPTED_ON_L1"})(F3||(F3={}));var H3;(function(d){d.REJECTED="REJECTED",d.REVERTED="REVERTED",d.SUCCEEDED="SUCCEEDED"})(H3||(H3={}));var G3;(function(d){d.PENDING="PENDING",d.ACCEPTED_ON_L1="ACCEPTED_ON_L1",d.ACCEPTED_ON_L2="ACCEPTED_ON_L2",d.REJECTED="REJECTED"})(G3||(G3={}));var U3;(function(d){d.pending="pending",d.latest="latest"})(U3||(U3={}));const di={Active:"1",Legacy:"0"};function Oz(d){return/^[\x00-\x7F]*$/.test(d)}function CB(d){return d.length<=wz}function XNe(d){return/^[0-9]*$/i.test(d)}function zd(d){return typeof d=="string"}function MB(d){return zd(d)&&!Ob(d)&&!vz(d)}const xz=d=>MB(d)&&!CB(d);function Pz(d){const e=RegExp(`[^]{1,${wz}}`,"g");return d.match(e)||[]}function Pb(d){if(!Oz(d))throw new Error(`${d} is not an ASCII string`);if(!CB(d))throw new Error(`${d} is too long`);return io(d.replace(/./g,e=>e.charCodeAt(0).toString(16)))}function Cw(d){if(!Oz(d))throw new Error(`${d} is not an ASCII string`);if(Ob(d))return _l(d).replace(/.{2}/g,e=>String.fromCharCode(parseInt(e,16)));if(XNe(d))return Cw("0X".concat(BigInt(d).toString(16)));throw new Error(`${d} is not Hex or decimal`)}function QNe(d){const e=BigInt(d.pending_word)===0n?"":Cw(fo(d.pending_word));return d.data.reduce((t,s)=>{const i=BigInt(s)===0n?"":Cw(fo(s));return t+i},"")+e}function _B(d){const e=Pz(d),t=e[e.length-1],s=e.map(Pb),[i,n]=t===void 0||t.length===31?["0x00",0]:[s.pop(),t.length];return{data:s.length===0?[]:s,pending_word:i,pending_word_len:n}}function Al(d){if(xb(d)||Number.isInteger(d))return d.toString();if(zd(d)){if(Ob(d))return BigInt(d).toString();if(MB(d)){if(!CB(d))throw new Error(`${d} is a long string > 31 chars. Please split it into an array of short strings.`);return BigInt(Pb(d)).toString()}if(vz(d))return d}if(Tz(d))return`${+d}`;throw new Error(`${d} can't be computed by felt()`)}const Vy=(1n<<128n)-1n,YNe=(1n<<256n)-1n,ZNe=0n,JNe=340282366920938463463374607431768211455n,eEe=340282366920938463463374607431768211455n,tEe=0n,sEe=0n;class Fi{constructor(...e){if(typeof e[0]=="object"&&e.length===1&&"low"in e[0]&&"high"in e[0]){const t=Fi.validateProps(e[0].low,e[0].high);this.low=t.low,this.high=t.high}else if(e.length===1){const t=Fi.validate(e[0]);this.low=t&Vy,this.high=t>>128n}else if(e.length===2){const t=Fi.validateProps(e[0],e[1]);this.low=t.low,this.high=t.high}else throw Error("Incorrect constructor parameters")}static validate(e){const t=BigInt(e);if(tYNe)throw new Error("bigNumberish is bigger than UINT_256_MAX");return t}static validateProps(e,t){const s=BigInt(e),i=BigInt(t);if(sJNe)throw new Error("low is out of range UINT_256_LOW_MIN - UINT_256_LOW_MAX");if(ieEe)throw new Error("high is out of range UINT_256_HIGH_MIN - UINT_256_HIGH_MAX");return{low:s,high:i}}static is(e){try{Fi.validate(e)}catch{return!1}return!0}static isAbiType(e){return e===Fi.abiSelector}toBigInt(){return(this.high<<128n)+this.low}toUint256HexString(){return{low:io(this.low.toString(16)),high:io(this.high.toString(16))}}toUint256DecimalString(){return{low:this.low.toString(10),high:this.high.toString(10)}}toApiRequest(){return[Al(this.low),Al(this.high)]}}Fi.abiSelector="core::integer::u256";const iEe=(1n<<512n)-1n,nEe=0n,rEe=0n;class sn{constructor(...e){if(typeof e[0]=="object"&&e.length===1&&"limb0"in e[0]&&"limb1"in e[0]&&"limb2"in e[0]&&"limb3"in e[0]){const t=sn.validateProps(e[0].limb0,e[0].limb1,e[0].limb2,e[0].limb3);this.limb0=t.limb0,this.limb1=t.limb1,this.limb2=t.limb2,this.limb3=t.limb3}else if(e.length===1){const t=sn.validate(e[0]);this.limb0=t&Vy,this.limb1=(t&Vy<<128n)>>128n,this.limb2=(t&Vy<<256n)>>256n,this.limb3=t>>384n}else if(e.length===4){const t=sn.validateProps(e[0],e[1],e[2],e[3]);this.limb0=t.limb0,this.limb1=t.limb1,this.limb2=t.limb2,this.limb3=t.limb3}else throw Error("Incorrect Uint512 constructor parameters")}static validate(e){const t=BigInt(e);if(tiEe)throw Error("bigNumberish is bigger than UINT_512_MAX.");return t}static validateProps(e,t,s,i){const n=BigInt(e),r=BigInt(t),a=BigInt(s),o=BigInt(i);return[n,r,a,o].forEach((c,u)=>{if(cVy)throw Error(`limb${u} is not in the range of a u128 number`)}),{limb0:n,limb1:r,limb2:a,limb3:o}}static is(e){try{sn.validate(e)}catch{return!1}return!0}static isAbiType(e){return e===sn.abiSelector}toBigInt(){return(this.limb3<<384n)+(this.limb2<<256n)+(this.limb1<<128n)+this.limb0}toUint512HexString(){return{limb0:io(this.limb0.toString(16)),limb1:io(this.limb1.toString(16)),limb2:io(this.limb2.toString(16)),limb3:io(this.limb3.toString(16))}}toUint512DecimalString(){return{limb0:this.limb0.toString(10),limb1:this.limb1.toString(10),limb2:this.limb2.toString(10),limb3:this.limb3.toString(10)}}toApiRequest(){return[Al(this.limb0),Al(this.limb1),Al(this.limb2),Al(this.limb3)]}}sn.abiSelector="core::integer::u512";const Km=d=>/_len$/.test(d),V2=d=>d==="felt"||d==="core::felt252",df=d=>/\*/.test(d)||d.startsWith("core::array::Array::")||d.startsWith("core::array::Span::"),If=d=>/^\(.*\)$/i.test(d),aEe=d=>/\(.*\)/i.test(d)&&d.includes(":"),ax=(d,e)=>d in e,mg=(d,e)=>d in e,AB=d=>d.startsWith("core::option::Option::"),LB=d=>d.startsWith("core::result::Result::"),Iz=d=>Object.values(Br).includes(d),Cz=d=>Object.values(pm).includes(d),BB=d=>d==="core::bool",oEe=d=>d==="core::starknet::eth_address::EthAddress",Mz=d=>d==="core::bytes_31::bytes31",NB=d=>d==="core::byte_array::byteArray.js",EB=d=>d==="core::starknet::secp256k1::Secp256k1Point",cf=d=>d.includes("::"),Mw=d=>cf(d)?d.substring(d.indexOf("<")+1,d.lastIndexOf(">")):d.replace("*","");function dEe(d){const{cairo:e}=cEe(d);if(e===void 0)throw Error("Unable to determine Cairo version");return e==="1"}function cEe(d){if(d.find(s=>s.type==="interface"))return{cairo:"1",compiler:"2"};const e=d.find(s=>s.type==="function"&&(s.inputs.length||s.outputs.length));if(!e)return{cairo:void 0,compiler:void 0};const t=e.inputs.length?e.inputs:e.outputs;return cf(t[0].type)?{cairo:"1",compiler:"1"}:{cairo:"0",compiler:"0"}}const W3=d=>new Fi(d).toUint256DecimalString();function No(d){return Al(d)}class _z{constructor(e){const t=Object.values(e);if(t.length===0)throw new Error("This Enum must have at least 1 variant");if(t.filter(i=>typeof i<"u").length!==1)throw new Error("This Enum must have exactly one active variant");this.variant=e}unwrap(){const t=Object.entries(this.variant).find(s=>typeof s[1]<"u");if(!(typeof t>"u"))return t[1]}activeVariant(){const t=Object.entries(this.variant).find(s=>typeof s[1]<"u");return typeof t>"u"?"":t[0]}}var ga;(function(d){d[d.Some=0]="Some",d[d.None=1]="None"})(ga||(ga={}));class F2{constructor(e,t){if(!(e in ga))throw new Error("Wrong variant : should be CairoOptionVariant.Some or .None.");if(e===ga.Some){if(typeof t>"u")throw new Error('The creation of a Cairo Option with "Some" variant needs a content as input.');this.Some=t,this.None=void 0}else this.Some=void 0,this.None=!0}unwrap(){if(!this.None)return this.Some}isSome(){return!(typeof this.Some>"u")}isNone(){return this.None===!0}}var mr;(function(d){d[d.Ok=0]="Ok",d[d.Err=1]="Err"})(mr||(mr={}));class H2{constructor(e,t){if(!(e in mr))throw new Error("Wrong variant : should be CairoResultVariant.Ok or .Err.");e===mr.Ok?(this.Ok=t,this.Err=void 0):(this.Ok=void 0,this.Err=t)}unwrap(){if(typeof this.Ok<"u")return this.Ok;if(typeof this.Err<"u")return this.Err;throw new Error("Both Result.Ok and .Err are undefined. Not authorized.")}isOk(){return!(typeof this.Ok>"u")}isErr(){return!(typeof this.Err>"u")}}const pC={isBN:(d,e,t)=>{if(!xb(d[t]))throw new Error(`Data and formatter mismatch on ${t}:${e[t]}, expected response data ${t}:${d[t]} to be BN instead it is ${typeof d[t]}`)},unknown:(d,e,t)=>{throw new Error(`Unhandled formatter type on ${t}:${e[t]} for data ${t}:${d[t]}`)}};function O1(d,e,t){return Object.entries(d).reduce((s,[i,n])=>{const r=t??e[i];if(!(i in e)&&!t)return s[i]=n,s;if(r==="string"){if(Array.isArray(d[i])){const a=O1(d[i],d[i].map(o=>r));return s[i]=Object.values(a).join(""),s}return pC.isBN(d,e,i),s[i]=Cw(n),s}if(r==="number")return pC.isBN(d,e,i),s[i]=Number(n),s;if(typeof r=="function")return s[i]=r(n),s;if(Array.isArray(r)){const a=O1(d[i],r,r[0]);return s[i]=Object.values(a),s}return typeof r=="object"?(s[i]=O1(d[i],r),s):(pC.unknown(d,e,i),s)},{})}class uEe{constructor(e){this.abi=e}methodInputsLength(e){return e.inputs.reduce((t,s)=>Km(s.name)?t:t+1,0)}getMethod(e){return this.abi.find(t=>t.name===e)}getLegacyFormat(){return this.abi}}class hEe{constructor(e){this.abi=e}methodInputsLength(e){return e.inputs.length}getMethod(e){return this.abi.find(s=>s.type==="interface").items.find(s=>s.name===e)}getLegacyFormat(){return this.abi.flatMap(e=>e.type==="interface"?e.items:e)}}function lEe(d){const e=fEe(d);if(e===0||e===1)return new uEe(d);if(e===2)return new hEe(d);throw Error(`Unsupported ABI version ${e}`)}function fEe(d){return d.find(e=>e.type==="interface")?2:dEe(d)?1:0}function j3(d,e,t){return d==="constructor"&&!t&&!e.length}function pEe(d){const e=d.substring(0,d.indexOf(":")),t=d.substring(e.length+1);return{name:e,type:t}}function mEe(d){if(!d.includes("("))return{subTuple:[],result:d};const e=[];let t="",s=0;for(;st.length?n.replace(" ",t.shift()):n);return aEe(d)&&(i=i.reduce((n,r)=>n.concat(pEe(r)),[])),i}function z3(d,e,t){for(let s=0,i=0;s")+1;break}default:{const n=e.indexOf(",",s);i=n!==-1?n:Number.POSITIVE_INFINITY}}t.push(e.slice(s,i)),s=i+2}return t}function RB(d){return cf(d)?yEe(d):gEe(d)}function wEe(d){return Error(`Your object includes the property : ${d}, containing an Uint256 object without the 'low' and 'high' keys.`)}function bEe(d){return Error(`Your object includes the property : ${d}, containing an Uint512 object without the 'limb0' to 'limb3' keys.`)}function kEe(d,e,t,s){const i=(u,h)=>{if(df(h))return r(u,h);if(mg(h,s)){const l=s[h];return o(u,l)}if(If(h))return a(u,h);if(oEe(h)||NB(h)||EB(h))return u;if(Fi.isAbiType(h)){const l=u;if(typeof l!="object")return l;if(!("low"in l&&"high"in l))throw wEe(h);return{low:l.low,high:l.high}}if(sn.isAbiType(h)){const l=u;if(typeof l!="object")return l;if(!["limb0","limb1","limb2","limb3"].every(f=>f in l))throw bEe(h);return{limb0:l.limb0,limb1:l.limb1,limb2:l.limb2,limb3:l.limb3}}if(ax(h,t)){const l=t[h].members;return n(u,l)}return u},n=(u,h)=>h.reduce((f,p)=>{const m=g=>Object.defineProperty(f,p.name,{enumerable:!0,value:g??u[p.name]});if(u[p.name]==="undefined"&&(cf(p.type)||!Km(p.name)))throw Error(`Your object needs a property with key : ${p.name} .`);return m(i(u[p.name],p.type)),f},{});function r(u,h){const l=Mw(h);return zd(u)?u:u.map(f=>i(f,l))}function a(u,h){return RB(h).reduce((p,m,g)=>{const y=Object.keys(u),w=S=>Object.defineProperty(p,g.toString(),{enumerable:!0,value:S??u[y[g]]}),b=m!=null&&m.type?m.type:m;return w(i(u[y[g]],b)),p},{})}const o=(u,h)=>{if(LB(h.name)){const m=u,g=h.name.substring(h.name.indexOf("<")+1,h.name.lastIndexOf(",")),y=h.name.substring(h.name.indexOf(",")+1,h.name.lastIndexOf(">"));return m.isOk()?new H2(mr.Ok,i(u.unwrap(),g)):new H2(mr.Err,i(u.unwrap(),y))}if(AB(h.name)){const m=u,g=h.name.substring(h.name.indexOf("<")+1,h.name.lastIndexOf(">"));return m.isSome()?new F2(ga.Some,i(m.unwrap(),g)):new F2(ga.None,{})}const l=u,p=Object.entries(l.variant).map(m=>{if(typeof m[1]>"u")return m;const g=h.type.substring(h.type.lastIndexOf("<")+1,h.type.lastIndexOf(">"));return g==="()"?m:[m[0],i(l.unwrap(),g)]});return new _z(Object.fromEntries(p))};return e.reduce((u,h)=>{const l=f=>Object.defineProperty(u,h.name,{enumerable:!0,value:f});return Km(h.name)&&!cf(h.type)||l(i(d[h.name],h.type)),u},{})}function Xv(d,e){switch(!0){case Fi.isAbiType(d):return new Fi(e).toApiRequest();case sn.isAbiType(d):return new sn(e).toApiRequest();case Mz(d):return Pb(e.toString());case EB(d):{const t=_l(fo(e)).padStart(128,"0"),s=W3(io(t.slice(-64))),i=W3(io(t.slice(0,-64)));return[No(i.low),No(i.high),No(s.low),No(s.high)]}default:return No(e)}}function SEe(d,e){const t=RB(e),s=Object.values(d);if(s.length!==t.length)throw Error(`ParseTuple: provided and expected abi tuple size do not match. +`,this.sub!==null){e+=" ";for(let s=0,i=this.sub.length;s6)throw new Error("Length over 48 bits not supported at position "+(e.pos-1));if(s===0)return null;t=0;for(let i=0;i>6,this.tagConstructed=(t&32)!==0,this.tagNumber=t&31,this.tagNumber==31){const s=new Ey;do t=e.get(),s.mulAdd(128,t&127);while(t&128);this.tagNumber=s.simplify()}}isUniversal(){return this.tagClass===0}isEOC(){return this.tagClass===0&&this.tagNumber===0}}function sAe(d,e,t,s){if(typeof d.setBigUint64=="function")return d.setBigUint64(e,t,s);const i=BigInt(32),n=BigInt(4294967295),r=Number(t>>i&n),a=Number(t&n),o=s?4:0,c=s?0:4;d.setUint32(e+o,r,s),d.setUint32(e+c,a,s)}class cB extends WO{constructor(e,t,s,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=s,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=sC(this.buffer)}update(e){ua.exists(this);const{view:t,buffer:s,blockLen:i}=this;e=hg(e);const n=e.length;for(let r=0;ri-r&&(this.process(s,0),r=0);for(let h=r;hu.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;hd&e^~d&t,nAe=(d,e,t)=>d&e^d&t^e&t,rAe=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),xu=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Pu=new Uint32Array(64);class Jj extends cB{constructor(){super(64,32,8,!1),this.A=xu[0]|0,this.B=xu[1]|0,this.C=xu[2]|0,this.D=xu[3]|0,this.E=xu[4]|0,this.F=xu[5]|0,this.G=xu[6]|0,this.H=xu[7]|0}get(){const{A:e,B:t,C:s,D:i,E:n,F:r,G:a,H:o}=this;return[e,t,s,i,n,r,a,o]}set(e,t,s,i,n,r,a,o){this.A=e|0,this.B=t|0,this.C=s|0,this.D=i|0,this.E=n|0,this.F=r|0,this.G=a|0,this.H=o|0}process(e,t){for(let h=0;h<16;h++,t+=4)Pu[h]=e.getUint32(t,!1);for(let h=16;h<64;h++){const l=Pu[h-15],f=Pu[h-2],p=pd(l,7)^pd(l,18)^l>>>3,m=pd(f,17)^pd(f,19)^f>>>10;Pu[h]=m+Pu[h-7]+p+Pu[h-16]|0}let{A:s,B:i,C:n,D:r,E:a,F:o,G:c,H:u}=this;for(let h=0;h<64;h++){const l=pd(a,6)^pd(a,11)^pd(a,25),f=u+l+iAe(a,o,c)+rAe[h]+Pu[h]|0,m=(pd(s,2)^pd(s,13)^pd(s,22))+nAe(s,i,n)|0;u=c,c=o,o=a,a=r+f|0,r=n,n=i,i=s,s=f+m|0}s=s+this.A|0,i=i+this.B|0,n=n+this.C|0,r=r+this.D|0,a=a+this.E|0,o=o+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(s,i,n,r,a,o,c,u)}roundClean(){Pu.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class aAe extends Jj{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}const He=ru(()=>new Jj);ru(()=>new aAe);const On=BigInt(0),Vi=BigInt(1),gl=BigInt(2),oAe=BigInt(3),P2=BigInt(4),a3=BigInt(5),o3=BigInt(8);BigInt(9);BigInt(16);function Ps(d,e){const t=d%e;return t>=On?t:e+t}function e7(d,e,t){if(t<=On||e 0");if(t===Vi)return On;let s=Vi;for(;e>On;)e&Vi&&(s=s*d%t),d=d*d%t,e>>=Vi;return s}function xi(d,e,t){let s=d;for(;e-- >On;)s*=s,s%=t;return s}function Wv(d,e){if(d===On||e<=On)throw new Error(`invert: expected positive integers, got n=${d} mod=${e}`);let t=Ps(d,e),s=e,i=On,n=Vi;for(;t!==On;){const a=s/t,o=s%t,c=i-n*a;s=t,t=o,i=n,n=c}if(s!==Vi)throw new Error("invert: does not exist");return Ps(i,e)}function dAe(d){const e=(d-Vi)/gl;let t,s,i;for(t=d-Vi,s=0;t%gl===On;t/=gl,s++);for(i=gl;i(Ps(d,e)&Vi)===Vi,uAe=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function zO(d){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=uAe.reduce((s,i)=>(s[i]="function",s),e);return Wh(d,t)}function t7(d,e,t){if(t 0");if(t===On)return d.ONE;if(t===Vi)return e;let s=d.ONE,i=e;for(;t>On;)t&Vi&&(s=d.mul(s,i)),i=d.sqr(i),t>>=1n;return s}function hAe(d,e){const t=new Array(e.length),s=e.reduce((n,r,a)=>d.is0(r)?n:(t[a]=n,d.mul(n,r)),d.ONE),i=d.inv(s);return e.reduceRight((n,r,a)=>d.is0(r)?n:(t[a]=d.mul(n,t[a]),d.mul(n,r)),i),t}function uB(d,e){const t=e!==void 0?e:d.toString(2).length,s=Math.ceil(t/8);return{nBitLength:t,nByteLength:s}}function kb(d,e,t=!1,s={}){if(d<=On)throw new Error(`Expected Fp ORDER > 0, got ${d}`);const{nBitLength:i,nByteLength:n}=uB(d,e);if(n>2048)throw new Error("Field lengths over 2048 bytes are not supported");const r=cAe(d),a=Object.freeze({ORDER:d,BITS:i,BYTES:n,MASK:GO(i),ZERO:On,ONE:Vi,create:o=>Ps(o,d),isValid:o=>{if(typeof o!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof o}`);return On<=o&&oo===On,isOdd:o=>(o&Vi)===Vi,neg:o=>Ps(-o,d),eql:(o,c)=>o===c,sqr:o=>Ps(o*o,d),add:(o,c)=>Ps(o+c,d),sub:(o,c)=>Ps(o-c,d),mul:(o,c)=>Ps(o*c,d),pow:(o,c)=>t7(a,o,c),div:(o,c)=>Ps(o*Wv(c,d),d),sqrN:o=>o*o,addN:(o,c)=>o+c,subN:(o,c)=>o-c,mulN:(o,c)=>o*c,inv:o=>Wv(o,d),sqrt:s.sqrt||(o=>r(a,o)),invertBatch:o=>hAe(a,o),cmov:(o,c,u)=>u?c:o,toBytes:o=>t?Fd(o,n):Dc(o,n),fromBytes:o=>{if(o.length!==n)throw new Error(`Fp.fromBytes: expected ${n}, got ${o.length}`);return t?Ld(o):Ki(o)}});return Object.freeze(a)}function lAe(d,e){if(!d.isOdd)throw new Error("Field doesn't have isOdd");const t=d.sqrt(e);return d.isOdd(t)?d.neg(t):t}function fAe(d,e,t=!1){d=xs("privateHash",d);const s=d.length,i=uB(e).nByteLength+8;if(i<24||s1024)throw new Error(`hashToPrivateScalar: expected ${i}-1024 bytes of input, got ${s}`);const n=t?Ld(d):Ki(d);return Ps(n,e-Vi)+Vi}const pAe=BigInt(0),iC=BigInt(1);function s7(d,e){const t=(i,n)=>{const r=n.negate();return i?r:n},s=i=>{const n=Math.ceil(e/i)+1,r=2**(i-1);return{windows:n,windowSize:r}};return{constTimeNegate:t,unsafeLadder(i,n){let r=d.ZERO,a=i;for(;n>pAe;)n&iC&&(r=r.add(a)),a=a.double(),n>>=iC;return r},precomputeWindow(i,n){const{windows:r,windowSize:a}=s(n),o=[];let c=i,u=c;for(let h=0;h>=f,g>o&&(g-=l,r+=iC);const y=m,w=m+Math.abs(g)-1,b=p%2!==0,S=g<0;g===0?u=u.add(t(b,n[y])):c=c.add(t(S,n[w]))}return{p:c,f:u}},wNAFCached(i,n,r,a){const o=i._WINDOW_SIZE||1;let c=n.get(i);return c||(c=this.precomputeWindow(i,o),o!==1&&n.set(i,a(c))),this.wNAF(o,c,r)}}}function hB(d){return zO(d.Fp),Wh(d,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...uB(d.n,d.nBitLength),...d})}function mAe(d){const e=hB(d);Wh(e,{a:"field",b:"field",fromBytes:"function",toBytes:"function"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean"});const{endo:t,Fp:s,a:i}=e;if(t){if(!s.eql(i,s.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:gAe,hexToBytes:yAe}=Y2e,Pl={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(d){const{Err:e}=Pl;if(d.length<2||d[0]!==2)throw new e("Invalid signature integer tag");const t=d[1],s=d.subarray(2,t+2);if(!t||s.length!==t)throw new e("Invalid signature integer: wrong length");if(s[0]===0&&s[1]<=127)throw new e("Invalid signature integer: trailing length");return{d:gAe(s),l:d.subarray(t+2)}},toSig(d){const{Err:e}=Pl,t=typeof d=="string"?yAe(d):d;if(!(t instanceof Uint8Array))throw new Error("ui8a expected");let s=t.length;if(s<2||t[0]!=48)throw new e("Invalid signature tag");if(t[1]!==s-2)throw new e("Invalid signature: incorrect length");const{d:i,l:n}=Pl._parseInt(t.subarray(2)),{d:r,l:a}=Pl._parseInt(n);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s:r}},hexFromSig(d){const e=c=>Number.parseInt(c[0],16)>=8?"00"+c:c,t=c=>{const u=c.toString(16);return u.length&1?`0${u}`:u},s=e(t(d.s)),i=e(t(d.r)),n=s.length/2,r=i.length/2,a=t(n),o=t(r);return`30${t(r+n+4)}02${o}${i}02${a}${s}`}},Oc=BigInt(0),Ka=BigInt(1);function wAe(d){const e=mAe(d),{Fp:t}=e;function s(l){const{a:f,b:p}=e,m=t.sqr(l),g=t.mul(m,l);return t.add(t.add(g,t.mul(l,f)),p)}function i(l){return typeof l=="bigint"&&Oct.eql(y,t.ZERO);return g(p)&&g(m)?c.ZERO:new c(p,m,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(f){const p=t.invertBatch(f.map(m=>m.pz));return f.map((m,g)=>m.toAffine(p[g])).map(c.fromAffine)}static fromHex(f){const p=c.fromAffine(e.fromBytes(xs("pointHex",f)));return p.assertValidity(),p}static fromPrivateKey(f){return c.BASE.multiply(r(f))}_setWindowSize(f){this._WINDOW_SIZE=f,a.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint)return;throw new Error("bad point: ZERO")}const{x:f,y:p}=this.toAffine();if(!t.isValid(f)||!t.isValid(p))throw new Error("bad point: x or y not FE");const m=t.sqr(p),g=s(f);if(!t.eql(m,g))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:f}=this.toAffine();if(t.isOdd)return!t.isOdd(f);throw new Error("Field doesn't support isOdd")}equals(f){o(f);const{px:p,py:m,pz:g}=this,{px:y,py:w,pz:b}=f,S=t.eql(t.mul(p,b),t.mul(y,g)),v=t.eql(t.mul(m,b),t.mul(w,g));return S&&v}negate(){return new c(this.px,t.neg(this.py),this.pz)}double(){const{a:f,b:p}=e,m=t.mul(p,3n),{px:g,py:y,pz:w}=this;let b=t.ZERO,S=t.ZERO,v=t.ZERO,C=t.mul(g,g),M=t.mul(y,y),_=t.mul(w,w),N=t.mul(g,y);return N=t.add(N,N),v=t.mul(g,w),v=t.add(v,v),b=t.mul(f,v),S=t.mul(m,_),S=t.add(b,S),b=t.sub(M,S),S=t.add(M,S),S=t.mul(b,S),b=t.mul(N,b),v=t.mul(m,v),_=t.mul(f,_),N=t.sub(C,_),N=t.mul(f,N),N=t.add(N,v),v=t.add(C,C),C=t.add(v,C),C=t.add(C,_),C=t.mul(C,N),S=t.add(S,C),_=t.mul(y,w),_=t.add(_,_),C=t.mul(_,N),b=t.sub(b,C),v=t.mul(_,M),v=t.add(v,v),v=t.add(v,v),new c(b,S,v)}add(f){o(f);const{px:p,py:m,pz:g}=this,{px:y,py:w,pz:b}=f;let S=t.ZERO,v=t.ZERO,C=t.ZERO;const M=e.a,_=t.mul(e.b,3n);let N=t.mul(p,y),A=t.mul(m,w),R=t.mul(g,b),D=t.add(p,m),U=t.add(y,w);D=t.mul(D,U),U=t.add(N,A),D=t.sub(D,U),U=t.add(p,g);let K=t.add(y,b);return U=t.mul(U,K),K=t.add(N,R),U=t.sub(U,K),K=t.add(m,g),S=t.add(w,b),K=t.mul(K,S),S=t.add(A,R),K=t.sub(K,S),C=t.mul(M,U),S=t.mul(_,R),C=t.add(S,C),S=t.sub(A,C),C=t.add(A,C),v=t.mul(S,C),A=t.add(N,N),A=t.add(A,N),R=t.mul(M,R),U=t.mul(_,U),A=t.add(A,R),R=t.sub(N,R),R=t.mul(M,R),U=t.add(U,R),N=t.mul(A,U),v=t.add(v,N),N=t.mul(K,U),S=t.mul(D,S),S=t.sub(S,N),N=t.mul(D,A),C=t.mul(K,C),C=t.add(C,N),new c(S,v,C)}subtract(f){return this.add(f.negate())}is0(){return this.equals(c.ZERO)}wNAF(f){return h.wNAFCached(this,a,f,p=>{const m=t.invertBatch(p.map(g=>g.pz));return p.map((g,y)=>g.toAffine(m[y])).map(c.fromAffine)})}multiplyUnsafe(f){const p=c.ZERO;if(f===Oc)return p;if(n(f),f===Ka)return this;const{endo:m}=e;if(!m)return h.unsafeLadder(this,f);let{k1neg:g,k1:y,k2neg:w,k2:b}=m.splitScalar(f),S=p,v=p,C=this;for(;y>Oc||b>Oc;)y&Ka&&(S=S.add(C)),b&Ka&&(v=v.add(C)),C=C.double(),y>>=Ka,b>>=Ka;return g&&(S=S.negate()),w&&(v=v.negate()),v=new c(t.mul(v.px,m.beta),v.py,v.pz),S.add(v)}multiply(f){n(f);let p=f,m,g;const{endo:y}=e;if(y){const{k1neg:w,k1:b,k2neg:S,k2:v}=y.splitScalar(p);let{p:C,f:M}=this.wNAF(b),{p:_,f:N}=this.wNAF(v);C=h.constTimeNegate(w,C),_=h.constTimeNegate(S,_),_=new c(t.mul(_.px,y.beta),_.py,_.pz),m=C.add(_),g=M.add(N)}else{const{p:w,f:b}=this.wNAF(p);m=w,g=b}return c.normalizeZ([m,g])[0]}multiplyAndAddUnsafe(f,p,m){const g=c.BASE,y=(b,S)=>S===Oc||S===Ka||!b.equals(g)?b.multiplyUnsafe(S):b.multiply(S),w=y(this,p).add(y(f,m));return w.is0()?void 0:w}toAffine(f){const{px:p,py:m,pz:g}=this,y=this.is0();f==null&&(f=y?t.ONE:t.inv(g));const w=t.mul(p,f),b=t.mul(m,f),S=t.mul(g,f);if(y)return{x:t.ZERO,y:t.ZERO};if(!t.eql(S,t.ONE))throw new Error("invZ was invalid");return{x:w,y:b}}isTorsionFree(){const{h:f,isTorsionFree:p}=e;if(f===Ka)return!0;if(p)return p(c,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:f,clearCofactor:p}=e;return f===Ka?this:p?p(c,this):this.multiplyUnsafe(e.h)}toRawBytes(f=!0){return this.assertValidity(),e.toBytes(c,this,f)}toHex(f=!0){return jd(this.toRawBytes(f))}}c.BASE=new c(e.Gx,e.Gy,t.ONE),c.ZERO=new c(t.ZERO,t.ONE,t.ZERO);const u=e.nBitLength,h=s7(c,e.endo?Math.ceil(u/2):u);return{ProjectivePoint:c,normPrivateKeyToScalar:r,weierstrassEquation:s,isWithinCurveOrder:i}}function bAe(d){const e=hB(d);return Wh(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function i7(d){const e=bAe(d),t=e.n,s=e.Fp,i=s.BYTES+1,n=2*s.BYTES+1;function r(j){return Ocjd(Dc(j,e.nByteLength));function p(j){const z=t>>Ka;return j>z}function m(j){return p(j)?a(-j):j}const g=(j,z,J)=>Ki(j.slice(z,J));class y{constructor(z,J,Y){this.r=z,this.s=J,this.recovery=Y,this.assertValidity()}static fromCompact(z){const J=e.nByteLength;return z=xs("compactSignature",z,J*2),new y(g(z,0,J),g(z,J,2*J))}static fromDER(z){const{r:J,s:Y}=Pl.toSig(xs("DER",z));return new y(J,Y)}assertValidity(){if(!l(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!l(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(z){return new y(this.r,this.s,z)}recoverPublicKey(z){const{r:J,s:Y,recovery:X}=this,Z=M(xs("msgHash",z));if(X==null||![0,1,2,3].includes(X))throw new Error("recovery id invalid");const te=X===2||X===3?J+e.n:J;if(te>=s.ORDER)throw new Error("recovery id 2 or 3 invalid");const Q=X&1?"03":"02",ie=c.fromHex(Q+f(te)),ne=o(te),oe=a(-Z*ne),me=a(Y*ne),fe=c.BASE.multiplyAndAddUnsafe(ie,oe,me);if(!fe)throw new Error("point at infinify");return fe.assertValidity(),fe}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new y(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return af(this.toDERHex())}toDERHex(){return Pl.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return af(this.toCompactHex())}toCompactHex(){return f(this.r)+f(this.s)}}const w={isValidPrivateKey(j){try{return u(j),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{const j=e.randomBytes(s.BYTES+8),z=fAe(j,t);return Dc(z,e.nByteLength)},precompute(j=8,z=c.BASE){return z._setWindowSize(j),z.multiply(BigInt(3)),z}};function b(j,z=!0){return c.fromPrivateKey(j).toRawBytes(z)}function S(j){const z=j instanceof Uint8Array,J=typeof j=="string",Y=(z||J)&&j.length;return z?Y===i||Y===n:J?Y===2*i||Y===2*n:j instanceof c}function v(j,z,J=!0){if(S(j))throw new Error("first arg must be private key");if(!S(z))throw new Error("second arg must be public key");return c.fromHex(z).multiply(u(j)).toRawBytes(J)}const C=e.bits2int||function(j){const z=Ki(j),J=j.length*8-e.nBitLength;return J>0?z>>BigInt(J):z},M=e.bits2int_modN||function(j){return a(C(j))},_=GO(e.nBitLength);function N(j){if(typeof j!="bigint")throw new Error("bigint expected");if(!(Oc<=j&&j<_))throw new Error(`bigint expected < 2^${e.nBitLength}`);return Dc(j,e.nByteLength)}function A(j,z,J=R){if(["recovered","canonical"].some(Se=>Se in J))throw new Error("sign() legacy options not supported");const{hash:Y,randomBytes:X}=e;let{lowS:Z,prehash:te,extraEntropy:Q}=J;Z==null&&(Z=!0),j=xs("msgHash",j),te&&(j=xs("prehashed msgHash",Y(j)));const ie=M(j),ne=u(z),oe=[N(ne),N(ie)];if(Q!=null){const Se=Q===!0?X(s.BYTES):Q;oe.push(xs("extraEntropy",Se,s.BYTES))}const me=vn(...oe),fe=ie;function he(Se){const ye=C(Se);if(!l(ye))return;const ge=o(ye),Te=c.BASE.multiply(ye).toAffine(),Ge=a(Te.x);if(Ge===Oc)return;const Ye=a(ge*a(fe+Ge*ne));if(Ye===Oc)return;let Re=(Te.x===Ge?0:2)|Number(Te.y&Ka),Be=Ye;return Z&&p(Ye)&&(Be=m(Ye),Re^=1),new y(Ge,Be,Re)}return{seed:me,k2sig:he}}const R={lowS:e.lowS,prehash:!1},D={lowS:e.lowS,prehash:!1};function U(j,z,J=R){const{seed:Y,k2sig:X}=A(j,z,J);return Fj(e.hash.outputLen,e.nByteLength,e.hmac)(Y,X)}c.BASE._setWindowSize(8);function K(j,z,J,Y=D){var Te;const X=j;if(z=xs("msgHash",z),J=xs("publicKey",J),"strict"in Y)throw new Error("options.strict was renamed to lowS");const{lowS:Z,prehash:te}=Y;let Q,ie;try{if(typeof X=="string"||X instanceof Uint8Array)try{Q=y.fromDER(X)}catch(Ge){if(!(Ge instanceof Pl.Err))throw Ge;Q=y.fromCompact(X)}else if(typeof X=="object"&&typeof X.r=="bigint"&&typeof X.s=="bigint"){const{r:Ge,s:Ye}=X;Q=new y(Ge,Ye)}else throw new Error("PARSE");ie=c.fromHex(J)}catch(Ge){if(Ge.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(Z&&Q.hasHighS())return!1;te&&(z=e.hash(z));const{r:ne,s:oe}=Q,me=M(z),fe=o(oe),he=a(me*fe),Se=a(ne*fe),ye=(Te=c.BASE.multiplyAndAddUnsafe(ie,he,Se))==null?void 0:Te.toAffine();return ye?a(ye.x)===ne:!1}return{CURVE:e,getPublicKey:b,getSharedSecret:v,sign:U,verify:K,ProjectivePoint:c,Signature:y,utils:w}}function kAe(d,e){const t=d.ORDER;let s=0n;for(let l=t-1n;l%2n===0n;l/=2n)s+=1n;const i=s,n=(t-1n)/2n**i,r=(n-1n)/2n,a=2n**i-1n,o=2n**(i-1n),c=d.pow(e,n),u=d.pow(e,(n+1n)/2n);let h=(l,f)=>{let p=c,m=d.pow(f,a),g=d.sqr(m);g=d.mul(g,f);let y=d.mul(l,g);y=d.pow(y,r),y=d.mul(y,m),m=d.mul(y,f),g=d.mul(y,l);let w=d.mul(g,m);y=d.pow(w,o);let b=d.eql(y,d.ONE);m=d.mul(g,u),y=d.mul(w,p),g=d.cmov(m,g,b),w=d.cmov(y,w,b);for(let S=i;S>1;S--){let v=2n**(S-2n),C=d.pow(w,v);const M=d.eql(C,d.ONE);m=d.mul(g,p),p=d.mul(p,p),C=d.mul(w,p),g=d.cmov(m,g,M),w=d.cmov(C,w,M)}return{isValid:b,value:g}};if(d.ORDER%4n===3n){const l=(d.ORDER-3n)/4n,f=d.sqrt(d.neg(e));h=(p,m)=>{let g=d.sqr(m);const y=d.mul(p,m);g=d.mul(g,y);let w=d.pow(g,l);w=d.mul(w,y);const b=d.mul(w,f),S=d.mul(d.sqr(w),m),v=d.eql(S,p);let C=d.cmov(b,w,v);return{isValid:v,value:C}}}return h}function n7(d,e){if(zO(d),!d.isValid(e.A)||!d.isValid(e.B)||!d.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const t=kAe(d,e.Z);if(!d.isOdd)throw new Error("Fp.isOdd is not implemented!");return s=>{let i,n,r,a,o,c,u,h;i=d.sqr(s),i=d.mul(i,e.Z),n=d.sqr(i),n=d.add(n,i),r=d.add(n,d.ONE),r=d.mul(r,e.B),a=d.cmov(e.Z,d.neg(n),!d.eql(n,d.ZERO)),a=d.mul(a,e.A),n=d.sqr(r),c=d.sqr(a),o=d.mul(c,e.A),n=d.add(n,o),n=d.mul(n,r),c=d.mul(c,a),o=d.mul(c,e.B),n=d.add(n,o),u=d.mul(i,r);const{isValid:l,value:f}=t(n,c);h=d.mul(i,s),h=d.mul(h,f),u=d.cmov(u,r,l),h=d.cmov(h,f,l);const p=d.isOdd(s)===d.isOdd(h);return h=d.cmov(d.neg(h),h,p),u=d.div(u,a),{x:u,y:h}}}function SAe(d){if(d instanceof Uint8Array)return d;if(typeof d=="string")return HO(d);throw new Error("DST must be Uint8Array or string")}const vAe=Ki;function Du(d,e){if(d<0||d>=1<<8*e)throw new Error(`bad I2OSP call: value=${d} length=${e}`);const t=Array.from({length:e}).fill(0);for(let s=e-1;s>=0;s--)t[s]=d&255,d>>>=8;return new Uint8Array(t)}function TAe(d,e){const t=new Uint8Array(d.length);for(let s=0;s255&&(e=s(vn(HO("H2C-OVERSIZE-DST-"),e)));const{outputLen:i,blockLen:n}=s,r=Math.ceil(t/i);if(r>255)throw new Error("Invalid xmd length");const a=vn(e,Du(e.length,1)),o=Du(0,n),c=Du(t,2),u=new Array(r),h=s(vn(o,d,c,Du(0,1),a));u[0]=s(vn(h,Du(1,1),a));for(let f=1;f<=r;f++){const p=[TAe(h,u[f-1]),Du(f+1,1),a];u[f]=s(vn(...p))}return vn(...u).slice(0,t)}function xAe(d,e,t,s,i){if(kw(d),kw(e),lB(t),e.length>255){const n=Math.ceil(2*s/8);e=i.create({dkLen:n}).update(HO("H2C-OVERSIZE-DST-")).update(e).digest()}if(t>65535||e.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:t}).update(d).update(Du(t,2)).update(e).update(Du(e.length,1)).digest()}function d3(d,e,t){Wh(t,{DST:"string",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});const{p:s,k:i,m:n,hash:r,expand:a,DST:o}=t;kw(d),lB(e);const c=SAe(o),u=s.toString(2).length,h=Math.ceil((u+i)/8),l=e*n*h;let f;if(a==="xmd")f=OAe(d,c,l,r);else if(a==="xof")f=xAe(d,c,l,i,r);else if(a===void 0)f=d;else throw new Error('expand must be "xmd", "xof" or undefined');const p=new Array(e);for(let m=0;mArray.from(s).reverse());return(s,i)=>{const[n,r,a,o]=t.map(c=>c.reduce((u,h)=>d.add(d.mul(u,s),h)));return s=d.div(n,r),i=d.mul(i,d.div(a,o)),{x:s,y:i}}}function fB(d,e,t){if(typeof e!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(s,i){const n=d3(s,2,{...t,DST:t.DST,...i}),r=d.fromAffine(e(n[0])),a=d.fromAffine(e(n[1])),o=r.add(a).clearCofactor();return o.assertValidity(),o},encodeToCurve(s,i){const n=d3(s,1,{...t,DST:t.encodeDST,...i}),r=d.fromAffine(e(n[0])).clearCofactor();return r.assertValidity(),r}}}function r7(d){return{hash:d,hmac:(e,...t)=>dB(d,e,oB(...t)),randomBytes:jO}}function a7(d,e){const t=s=>i7({...d,...r7(s)});return Object.freeze({...t(e),create:t})}const $O=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),jv=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),o7=BigInt(1),I2=BigInt(2),c3=(d,e)=>(d+e/I2)/e;function d7(d){const e=$O,t=BigInt(3),s=BigInt(6),i=BigInt(11),n=BigInt(22),r=BigInt(23),a=BigInt(44),o=BigInt(88),c=d*d*d%e,u=c*c*d%e,h=xi(u,t,e)*u%e,l=xi(h,t,e)*u%e,f=xi(l,I2,e)*c%e,p=xi(f,i,e)*f%e,m=xi(p,n,e)*p%e,g=xi(m,a,e)*m%e,y=xi(g,o,e)*g%e,w=xi(y,a,e)*m%e,b=xi(w,t,e)*u%e,S=xi(b,r,e)*p%e,v=xi(S,s,e)*c%e,C=xi(v,I2,e);if(!Ch.eql(Ch.sqr(C),d))throw new Error("Cannot find square root");return C}const Ch=kb($O,void 0,void 0,{sqrt:d7}),Qd=a7({a:BigInt(0),b:BigInt(7),Fp:Ch,n:jv,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:d=>{const e=jv,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),s=-o7*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),n=t,r=BigInt("0x100000000000000000000000000000000"),a=c3(n*d,e),o=c3(-s*d,e);let c=Ps(d-a*t-o*i,e),u=Ps(-a*s-o*n,e);const h=c>r,l=u>r;if(h&&(c=e-c),l&&(u=e-u),c>r||u>r)throw new Error("splitScalar: Endomorphism failed, k="+d);return{k1neg:h,k1:c,k2neg:l,k2:u}}}},He),pB=BigInt(0),c7=d=>typeof d=="bigint"&&pBtypeof d=="bigint"&&pBi.charCodeAt(0)));t=vn(s,s),u3[d]=t}return He(vn(t,...e))}const mB=d=>d.toRawBytes(!0).slice(1),C2=d=>Dc(d,32),nC=d=>Ps(d,$O),Sw=d=>Ps(d,jv),gB=Qd.ProjectivePoint,CAe=(d,e,t)=>gB.BASE.multiplyAndAddUnsafe(d,e,t);function M2(d){let e=Qd.utils.normPrivateKeyToScalar(d),t=gB.fromPrivateKey(e);return{scalar:t.hasEvenY()?e:Sw(-e),bytes:mB(t)}}function u7(d){if(!c7(d))throw new Error("bad x: need 0 < x < p");const e=nC(d*d),t=nC(e*d+BigInt(7));let s=d7(t);s%2n!==0n&&(s=nC(-s));const i=new gB(d,s,o7);return i.assertValidity(),i}function h7(...d){return Sw(Ki(zv("BIP0340/challenge",...d)))}function MAe(d){return M2(d).bytes}function _Ae(d,e,t=jO(32)){const s=xs("message",d),{bytes:i,scalar:n}=M2(e),r=xs("auxRand",t,32),a=C2(n^Ki(zv("BIP0340/aux",r))),o=zv("BIP0340/nonce",a,i,s),c=Sw(Ki(o));if(c===pB)throw new Error("sign failed: k is zero");const{bytes:u,scalar:h}=M2(c),l=h7(u,i,s),f=new Uint8Array(64);if(f.set(u,0),f.set(C2(Sw(h+l*n)),32),!l7(f,s,i))throw new Error("sign: Invalid signature produced");return f}function l7(d,e,t){const s=xs("signature",d,64),i=xs("message",e),n=xs("publicKey",t,32);try{const r=u7(Ki(n)),a=Ki(s.subarray(0,32));if(!c7(a))return!1;const o=Ki(s.subarray(32,64));if(!IAe(o))return!1;const c=h7(C2(a),mB(r),i),u=CAe(r,o,Sw(-c));return!(!u||!u.hasEvenY()||u.toAffine().x!==a)}catch{return!1}}Qd.utils.randomPrivateKey;const AAe=PAe(Ch,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map(d=>d.map(e=>BigInt(e)))),LAe=n7(Ch,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:Ch.create(BigInt("-11"))});fB(Qd.ProjectivePoint,d=>{const{x:e,y:t}=LAe(Ch.create(d[0]));return AAe(e,t)},{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:Ch.ORDER,m:1,k:128,expand:"xmd",hash:He});const vw=kb(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),f7=vw.create(BigInt("-3")),p7=BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),BAe=n7(vw,{A:f7,B:p7,Z:vw.create(BigInt("-10"))}),yB=a7({a:f7,b:p7,Fp:vw,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},He),NAe=yB;fB(NAe.ProjectivePoint,d=>BAe(d[0]),{DST:"P256_XMD:SHA-256_SSWU_RO_",encodeDST:"P256_XMD:SHA-256_SSWU_NU_",p:vw.ORDER,m:1,k:128,expand:"xmd",hash:He});const m7={binary:d=>d,hex:Uh.encode,base64:nu.encode},h3={"1.3.132.0.10":Qd,"1.2.840.10045.3.1.7":yB},KO=(d,e,t="hex")=>{const s=e(d);return m7[t](s)},wB=(d,e,t,s="hex")=>{const i=dB(t,e,d);return m7[s](i)};function xf(d,e,t,s=null,i=!1){if(s&&(d=KO(d,s,"hex")),typeof e=="string"&&e.length>64)if(e.startsWith("-----BEGIN EC PRIVATE KEY-----")){const c=bw.unarmor(e);let u=xl.decode(c);if(u.sub.length===4){if(typeof u.sub[2].sub!==null&&u.sub[2].sub.length>0){const h=u.sub[2].sub[0].content(void 0);if(h3[h]===void 0)throw new Error("Unsupported curve");t=h3[h]}e=u.sub[1].getHexStringValue()}else throw new Error("Unsupported key format")}else throw new Error("Unsupported key format");let n=t.sign(d,e,{lowS:!0});const r=(BigInt(1)<a||n.r<=r||n.s<=r);)n=t.sign(d,e,{lowS:!0,extraEntropy:Fd(BigInt(o),32)}),o+=1;return{r:n.r.toString(16),s:n.s.toString(16),v:n.recovery}}function g7(d,e,t){const s=t.signModified(d,e);return zm.encode(s)}function lg(d,e,t){let s;e.length===32?s=e:typeof e=="string"&&(s=new Uint8Array(bw.unarmor(e).slice(16)));const i=t.sign(d,s);return nu.encode(i)}function y1(d,e=!1){const t="00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F 63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC 51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E 7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D 806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA 11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F 30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D";y1.table===void 0&&(y1.table=t.split(" ").map(n=>parseInt(n,16)));let s=-1;for(let n=0;n>>8^y1.table[(s^d.charCodeAt(n))&255];const i=(s^-1)>>>0;return e&&i>=2147483648?i-4294967296:i}const Mh=Date.now,y7=()=>Mh()*1e3,l0=Mh,EAe=()=>Math.floor(Mh()/1e3),RAe=()=>{const s=(y7()*10+122192928e9).toString(16),i=s.slice(7,15)+s.slice(3,7)+"1"+s.slice(0,3),n="9696",r="ff".repeat(6);return i+n+r},DAe=setTimeout,XO=(d,e,t=DAe,s=Mh()+e)=>{if(e>=2147483647)throw new Error("setTimeout() function was called with unrealistic value of "+e.toString());let i=()=>{},n=!0;const r=t(()=>{n=!0;const a=s-Mh();a>0?i=XO(d,a,t,s):d()},e);return function(){n&&(n=!1,clearTimeout(r)),i()}};class Tw extends Error{constructor(){const e="timed out";super(e),this.constructor=Tw,this.__proto__=Tw.prototype,this.message=e}}const w1=d=>{let e;if(typeof d=="number"?e=Math.floor(d):e=parseInt(d,10),!(Number.isNaN(e)||e<0))try{return new Date(e).toISOString()}catch{return}},w7=d=>{if(!(typeof d!="string"||!d)&&!d.match(/^[0-9]+$/)&&!(d.indexOf("-")<0||d.indexOf(":")<0))try{const e=Date.parse(d.indexOf("+")>=0||d.slice(-1)==="Z"?d:(d+"Z").replace(/\s(\d\d):/,"T$1:"));return Number.isNaN(e)?void 0:e}catch{return}},qAe=d=>{if(!(typeof d!="string"||!d)){if(d.indexOf("GMT")>=0)try{return Date.parse(d)}catch{return}return w7(d)}},VAe=(d=void 0)=>new Date(d).toUTCString(),FAe=(d,e="-")=>{e=e||"";const t=new Date(d),s=t.getUTCFullYear().toString();let i=t.getUTCMonth()+1,n=t.getUTCDate();return i=i<10?"0"+i:i.toString(),n=n<10?"0"+n:n.toString(),i+e+n+e+s},bB=(d,e,t=!0)=>{e=e||"";const s=new Date(d),i=s.getUTCFullYear(),r=(t?i:i-2e3).toString();let a=s.getUTCMonth()+1,o=s.getUTCDate();return a=a<10?"0"+a:a.toString(),o=o<10?"0"+o:o.toString(),r+e+a+e+o},HAe=(d,e="")=>bB(d,e,!1),GAe=(d,e="-")=>bB(d,e,!0),UAe=(d,e=" ")=>{const t=new Date(d),s=t.getUTCFullYear();let i=t.getUTCMonth()+1,n=t.getUTCDate(),r=t.getUTCHours(),a=t.getUTCMinutes(),o=t.getUTCSeconds();return i=i<10?"0"+i:i,n=n<10?"0"+n:n,r=r<10?"0"+r:r,a=a<10?"0"+a:a,o=o<10?"0"+o:o,s+"-"+i+"-"+n+e+r+":"+a+":"+o},kB=d=>new Promise(e=>XO(e,d)),WAe=async(d,e)=>{let t=()=>{};const s=new Promise(i=>t=XO(i,d));try{return await Promise.race([e,s.then(()=>{throw new Tw})])}finally{t()}};let jAe=class{constructor(e){this.config={refillRate:1,delay:.001,capacity:1,maxCapacity:2e3,tokens:0,cost:1},Object.assign(this.config,e),this.queue=[],this.running=!1}async loop(){let e=Mh();for(;this.running;){const{resolver:t,cost:s}=this.queue[0];if(this.config.tokens>=0)this.config.tokens-=s,t(),this.queue.shift(),await Promise.resolve(),this.queue.length===0&&(this.running=!1);else{await kB(this.config.delay*1e3);const i=Mh(),n=i-e;e=i;const r=this.config.tokens+this.config.refillRate*n;this.config.tokens=Math.min(r,this.config.capacity)}}}throttle(e=void 0){let t;const s=new Promise((i,n)=>{t=i});if(this.queue.length>this.config.maxCapacity)throw new Error("throttle queue is over maxCapacity ("+this.config.maxCapacity.toString()+"), see https://github.com/ccxt/ccxt/issues/11645#issuecomment-1195695526");return e=e===void 0?this.config.cost:e,this.queue.push({resolver:t,cost:e}),this.running||(this.running=!0,this.loop()),s}};class fg extends Error{constructor(e){super(e),this.name="BaseError"}}class I extends fg{constructor(e){super(e),this.name="ExchangeError"}}class $ extends I{constructor(e){super(e),this.name="AuthenticationError"}}class de extends ${constructor(e){super(e),this.name="PermissionDenied"}}class Ii extends de{constructor(e){super(e),this.name="AccountNotEnabled"}}class gt extends ${constructor(e){super(e),this.name="AccountSuspended"}}class G extends I{constructor(e){super(e),this.name="ArgumentsRequired"}}class T extends I{constructor(e){super(e),this.name="BadRequest"}}class we extends T{constructor(e){super(e),this.name="BadSymbol"}}class Pe extends I{constructor(e){super(e),this.name="OperationRejected"}}class Ow extends Pe{constructor(e){super(e),this.name="NoChange"}}class $m extends Ow{constructor(e){super(e),this.name="MarginModeAlreadySet"}}class Sb extends Pe{constructor(e){super(e),this.name="MarketClosed"}}class QO extends Pe{constructor(e){super(e),this.name="ManualInteractionNeeded"}}class ce extends I{constructor(e){super(e),this.name="InsufficientFunds"}}class is extends I{constructor(e){super(e),this.name="InvalidAddress"}}class SB extends is{constructor(e){super(e),this.name="AddressPending"}}class x extends I{constructor(e){super(e),this.name="InvalidOrder"}}class Ie extends x{constructor(e){super(e),this.name="OrderNotFound"}}class b7 extends x{constructor(e){super(e),this.name="OrderNotCached"}}class Mi extends x{constructor(e){super(e),this.name="OrderImmediatelyFillable"}}class Cd extends x{constructor(e){super(e),this.name="OrderNotFillable"}}class va extends x{constructor(e){super(e),this.name="DuplicateOrderId"}}class Od extends x{constructor(e){super(e),this.name="ContractUnavailable"}}class q extends I{constructor(e){super(e),this.name="NotSupported"}}class Fp extends I{constructor(e){super(e),this.name="InvalidProxySettings"}}class YO extends I{constructor(e){super(e),this.name="ExchangeClosedByUser"}}class xt extends fg{constructor(e){super(e),this.name="OperationFailed"}}class qs extends xt{constructor(e){super(e),this.name="NetworkError"}}class ts extends qs{constructor(e){super(e),this.name="DDoSProtection"}}class Ze extends qs{constructor(e){super(e),this.name="RateLimitExceeded"}}class Ee extends qs{constructor(e){super(e),this.name="ExchangeNotAvailable"}}class as extends Ee{constructor(e){super(e),this.name="OnMaintenance"}}class Ft extends qs{constructor(e){super(e),this.name="InvalidNonce"}}class $r extends Ft{constructor(e){super(e),this.name="ChecksumError"}}class Vs extends qs{constructor(e){super(e),this.name="RequestTimeout"}}class Wi extends xt{constructor(e){super(e),this.name="BadResponse"}}class xc extends Wi{constructor(e){super(e),this.name="NullResponse"}}class qo extends xt{constructor(e){super(e),this.name="CancelPending"}}class qc extends fg{constructor(e){super(e),this.name="UnsubscribeError"}}const zAe={BaseError:fg,ExchangeError:I,AuthenticationError:$,PermissionDenied:de,AccountNotEnabled:Ii,AccountSuspended:gt,ArgumentsRequired:G,BadRequest:T,BadSymbol:we,OperationRejected:Pe,NoChange:Ow,MarginModeAlreadySet:$m,MarketClosed:Sb,ManualInteractionNeeded:QO,InsufficientFunds:ce,InvalidAddress:is,AddressPending:SB,InvalidOrder:x,OrderNotFound:Ie,OrderNotCached:b7,OrderImmediatelyFillable:Mi,OrderNotFillable:Cd,DuplicateOrderId:va,ContractUnavailable:Od,NotSupported:q,InvalidProxySettings:Fp,ExchangeClosedByUser:YO,OperationFailed:xt,NetworkError:qs,DDoSProtection:ts,RateLimitExceeded:Ze,ExchangeNotAvailable:Ee,OnMaintenance:as,InvalidNonce:Ft,ChecksumError:$r,RequestTimeout:Vs,BadResponse:Wi,NullResponse:xc,CancelPending:qo,UnsubscribeError:qc},$Ae=Object.freeze(Object.defineProperty({__proto__:null,AccountNotEnabled:Ii,AccountSuspended:gt,AddressPending:SB,ArgumentsRequired:G,AuthenticationError:$,BadRequest:T,BadResponse:Wi,BadSymbol:we,BaseError:fg,CancelPending:qo,ChecksumError:$r,ContractUnavailable:Od,DDoSProtection:ts,DuplicateOrderId:va,ExchangeClosedByUser:YO,ExchangeError:I,ExchangeNotAvailable:Ee,InsufficientFunds:ce,InvalidAddress:is,InvalidNonce:Ft,InvalidOrder:x,InvalidProxySettings:Fp,ManualInteractionNeeded:QO,MarginModeAlreadySet:$m,MarketClosed:Sb,NetworkError:qs,NoChange:Ow,NotSupported:q,NullResponse:xc,OnMaintenance:as,OperationFailed:xt,OperationRejected:Pe,OrderImmediatelyFillable:Mi,OrderNotCached:b7,OrderNotFillable:Cd,OrderNotFound:Ie,PermissionDenied:de,RateLimitExceeded:Ze,RequestTimeout:Vs,UnsubscribeError:qc,default:zAe},Symbol.toStringTag,{value:"Module"})),k7=d=>{const e=td(d.slice(0,-1)),t=d.slice(-1);let s;if(t==="y")s=60*60*24*365;else if(t==="M")s=60*60*24*30;else if(t==="w")s=60*60*24*7;else if(t==="d")s=60*60*24;else if(t==="h")s=60*60;else if(t==="m")s=60;else if(t==="s")s=1;else throw new q("timeframe unit "+t+" is not supported");return e*s},KAe=(d,e,t=tB)=>{const s=k7(d)*1e3,i=e%s;return e-i+(t===eB?s:0)},XAe=d=>{const e=/{([\w-]+)}/g,t=[];let s=e.exec(d);for(;s;)t.push(s[1]),s=e.exec(d);return t},QAe=(d,e)=>{if(!Array.isArray(e)){const t=Object.keys(e);for(let s=0;s0?e/d:void 0}function YAe(d){const e={};for(let t=0;t0&&(e[s]=(e[s]||0)+i)}return Object.keys(e).map(t=>[parseFloat(t),parseFloat(e[t])])}function v7(){let d=!1;try{d=self!==void 0}catch{d=!1}return d}const ZO=Object.freeze(Object.defineProperty({__proto__:null,DECIMAL_PLACES:Hn,NO_PADDING:Wu,PAD_WITH_ZERO:Gv,ROUND:tr,ROUND_DOWN:tB,ROUND_UP:eB,SIGNIFICANT_DIGITS:Hh,TICK_SIZE:Qe,TRUNCATE:js,Throttler:jAe,TimedOut:Tw,aggregate:YAe,arrayConcat:y2e,asFloat:td,asInteger:qO,axolotl:g7,base16ToBinary:Xj,base58ToBinary:N_e,base64ToBinary:$j,base64ToString:L_e,binaryConcat:R_e,binaryConcatArray:D_e,binaryToBase16:B_e,binaryToBase58:E_e,binaryToBase64:Kj,binaryToString:__e,capitalize:B2e,clone:Ij,crc32:y1,decimalToPrecision:D2e,decode:U_e,deepExtend:Cj,ecdsa:xf,eddsa:lg,encode:G_e,extend:bb,extractParams:XAe,filterBy:O2e,flatten:I2e,groupBy:v2e,hasProps:yb,hash:KO,hmac:wB,implodeParams:QAe,inArray:w2e,index:Pj,indexBy:T2e,isArray:cg,isBrowser:Tj,isDeno:xj,isDictionary:b2,isElectron:HMe,isEmpty:k2e,isInteger:UMe,isJsonEncodedObject:jj,isNode:jm,isNumber:zn,isObject:wb,isString:ZL,isStringCoercible:rr,isWebWorker:Oj,isWindows:GMe,iso8601:w1,json:M_e,keys:JL,keysort:S2e,mdy:FAe,merge:A2e,microseconds:y7,milliseconds:l0,now:Mh,numberToBE:j_e,numberToLE:W_e,numberToString:sB,omit:M2e,omitZero:q2e,ordered:m2e,packb:z_e,parse8601:w7,parseDate:qAe,parseTimeframe:k7,pluck:C2e,precisionConstants:E2e,precisionFromString:k2,prop:Xd,rawencode:H_e,rfc2616:VAe,roundTimeframe:KAe,safeFloat:jMe,safeFloat2:JMe,safeFloatN:o2e,safeInteger:zMe,safeInteger2:e2e,safeIntegerN:d2e,safeIntegerProduct:$Me,safeIntegerProduct2:t2e,safeIntegerProductN:c2e,safeString:QMe,safeString2:n2e,safeStringLower:YMe,safeStringLower2:r2e,safeStringLowerN:f2e,safeStringN:l2e,safeStringUpper:ZMe,safeStringUpper2:a2e,safeStringUpperN:p2e,safeTimestamp:KMe,safeTimestamp2:s2e,safeTimestampN:u2e,safeValue:XMe,safeValue2:i2e,safeValueN:h2e,seconds:EAe,selfIsDefined:v7,setTimeout_safe:XO,sleep:kB,sortBy:x2e,sortBy2:P2e,stringToBase64:zj,stringToBinary:A_e,strip:N2e,sum:_2e,timeout:WAe,toArray:b2e,truncate:R2e,truncate_to_string:Lj,unCamelCase:L2e,unique:g2e,urlencode:q_e,urlencodeBase64:bp,urlencodeNested:V_e,urlencodeWithArrayRepeat:F_e,uuid:Mj,uuid16:_j,uuid22:Aj,uuidv1:RAe,values:Of,vwap:S7,ymd:bB,ymdhms:UAe,yymmdd:HAe,yyyymmdd:GAe},Symbol.toStringTag,{value:"Module"})),ZAe=BigInt(0),JAe=BigInt(-1),cp=BigInt(10);class L{constructor(e,t=void 0){if(this.base=void 0,t===void 0){let s=0;if(e=e.toLowerCase(),e.indexOf("e")>-1){let r="0";[e,r]=e.split("e"),s=parseInt(r)}const i=e.indexOf(".");this.decimals=i>-1?e.length-i-1:0;const n=e.replace(".","");this.integer=BigInt(n),this.decimals=this.decimals-s}else this.integer=e,this.decimals=t}mul(e){const t=this.integer*e.integer;return new L(t,this.decimals+e.decimals)}div(e,t=18){const s=t-this.decimals+e.decimals;let i;if(s===0)i=this.integer;else if(s<0){const r=cp**BigInt(-s);i=this.integer/r}else{const r=cp**BigInt(s);i=this.integer*r}const n=i/e.integer;return new L(n,t)}add(e){if(this.decimals===e.decimals){const t=this.integer+e.integer;return new L(t,this.decimals)}else{const[t,s]=this.decimals>e.decimals?[e,this]:[this,e],i=s.decimals-t.decimals,r=t.integer*cp**BigInt(i)+s.integer;return new L(r,s.decimals)}}mod(e){const t=Math.max(-this.decimals+e.decimals,0),s=this.integer*cp**BigInt(t),i=Math.max(-e.decimals+this.decimals,0),n=e.integer*cp**BigInt(i),r=s%n;return new L(r,i+e.decimals)}sub(e){const t=new L(-e.integer,e.decimals);return this.add(t)}abs(){return new L(this.integer<0?this.integer*JAe:this.integer,this.decimals)}neg(){return new L(-this.integer,this.decimals)}or(e){const t=this.integer|e.integer;return new L(t,this.decimals)}min(e){return this.lt(e)?this:e}max(e){return this.gt(e)?this:e}gt(e){return this.sub(e).integer>0}ge(e){return this.sub(e).integer>=0}lt(e){return e.gt(this)}le(e){return e.ge(this)}reduce(){const e=this.integer.toString(),t=e.length-1;if(t===0)return e==="0"&&(this.decimals=0),this;let s;for(s=t;s>=0&&e.charAt(s)==="0";s--);const i=t-s;if(i===0)return this;this.decimals-=i,this.integer=BigInt(e.slice(0,s+1))}equals(e){return this.reduce(),e.reduce(),this.decimals===e.decimals&&this.integer===e.integer}toString(){this.reduce();let e,t;this.integer<0?(e="-",t=-this.integer):(e="",t=this.integer);const s=Array.from(t.toString(Number(cp)).padStart(this.decimals,"0")),i=s.length-this.decimals;let n;return i===0?n="0.":this.decimals<0?n="0".repeat(-this.decimals):this.decimals===0?n="":n=".",s.splice(i,0,n),e+s.join("")}static stringMul(e,t){if(!(e===void 0||t===void 0))return new L(e).mul(new L(t)).toString()}static stringDiv(e,t,s=18){if(e===void 0||t===void 0)return;const i=new L(t);if(i.integer!==ZAe)return new L(e).div(i,s).toString()}static stringAdd(e,t){if(!(e===void 0&&t===void 0))return e===void 0?t:t===void 0?e:new L(e).add(new L(t)).toString()}static stringSub(e,t){if(!(e===void 0||t===void 0))return new L(e).sub(new L(t)).toString()}static stringAbs(e){if(e!==void 0)return new L(e).abs().toString()}static stringNeg(e){if(e!==void 0)return new L(e).neg().toString()}static stringMod(e,t){if(!(e===void 0||t===void 0))return new L(e).mod(new L(t)).toString()}static stringOr(e,t){if(!(e===void 0||t===void 0))return new L(e).or(new L(t)).toString()}static stringEquals(e,t){if(!(e===void 0||t===void 0))return new L(e).equals(new L(t))}static stringEq(e,t){if(!(e===void 0||t===void 0))return new L(e).equals(new L(t))}static stringMin(e,t){if(!(e===void 0||t===void 0))return new L(e).min(new L(t)).toString()}static stringMax(e,t){if(!(e===void 0||t===void 0))return new L(e).max(new L(t)).toString()}static stringGt(e,t){if(!(e===void 0||t===void 0))return new L(e).gt(new L(t))}static stringGe(e,t){if(!(e===void 0||t===void 0))return new L(e).ge(new L(t))}static stringLt(e,t){if(!(e===void 0||t===void 0))return new L(e).lt(new L(t))}static stringLe(e,t){if(!(e===void 0||t===void 0))return new L(e).le(new L(t))}}var eLe=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")};const tLe=sT(eLe);var pa=Uint8Array,Il=Uint16Array,T7=Uint32Array,O7=new pa([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),x7=new pa([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),sLe=new pa([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),P7=function(d,e){for(var t=new Il(31),s=0;s<31;++s)t[s]=e+=1<>>1|(fi&21845)<<1;Iu=(Iu&52428)>>>2|(Iu&13107)<<2,Iu=(Iu&61680)>>>4|(Iu&3855)<<4,_2[fi]=((Iu&65280)>>>8|(Iu&255)<<8)>>>1}var f0=function(d,e,t){for(var s=d.length,i=0,n=new Il(e);i>>o]=c}else for(a=new Il(s),i=0;i>>15-d[i]);return a},vb=new pa(288);for(var fi=0;fi<144;++fi)vb[fi]=8;for(var fi=144;fi<256;++fi)vb[fi]=9;for(var fi=256;fi<280;++fi)vb[fi]=7;for(var fi=280;fi<288;++fi)vb[fi]=8;var M7=new pa(32);for(var fi=0;fi<32;++fi)M7[fi]=5;var aLe=f0(vb,9,1),oLe=f0(M7,5,1),rC=function(d){for(var e=d[0],t=1;te&&(e=d[t]);return e},To=function(d,e,t){var s=e/8|0;return(d[s]|d[s+1]<<8)>>(e&7)&t},aC=function(d,e){var t=e/8|0;return(d[t]|d[t+1]<<8|d[t+2]<<16)>>(e&7)},dLe=function(d){return(d+7)/8|0},cLe=function(d,e,t){(t==null||t>d.length)&&(t=d.length);var s=new(d.BYTES_PER_ELEMENT==2?Il:d.BYTES_PER_ELEMENT==4?T7:pa)(t-e);return s.set(d.subarray(e,t)),s},uLe=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],gc=function(d,e,t){var s=new Error(e||uLe[d]);if(s.code=d,Error.captureStackTrace&&Error.captureStackTrace(s,gc),!t)throw s;return s},_7=function(d,e,t){var s=d.length;if(!s||t&&t.f&&!t.l)return e||new pa(0);var i=!e||t,n=!t||t.i;t||(t={}),e||(e=new pa(s*3));var r=function(me){var fe=e.length;if(me>fe){var he=new pa(Math.max(fe*2,me));he.set(e),e=he}},a=t.f||0,o=t.p||0,c=t.b||0,u=t.l,h=t.d,l=t.m,f=t.n,p=s*8;do{if(!u){a=To(d,o,1);var m=To(d,o+1,3);if(o+=3,m)if(m==1)u=aLe,h=oLe,l=9,f=5;else if(m==2){var b=To(d,o,31)+257,S=To(d,o+10,15)+4,v=b+To(d,o+5,31)+1;o+=14;for(var C=new pa(v),M=new pa(19),_=0;_>>4;if(g<16)C[_++]=g;else{var U=0,K=0;for(g==16?(K=3+To(d,o,3),o+=2,U=C[_-1]):g==17?(K=3+To(d,o,7),o+=3):g==18&&(K=11+To(d,o,127),o+=7);K--;)C[_++]=U}}var j=C.subarray(0,b),z=C.subarray(b);l=rC(j),f=rC(z),u=f0(j,l,1),h=f0(z,f,1)}else gc(1);else{var g=dLe(o)+4,y=d[g-4]|d[g-3]<<8,w=g+y;if(w>s){n&&gc(0);break}i&&r(c+y),e.set(d.subarray(g,w),c),t.b=c+=y,t.p=o=w*8,t.f=a;continue}if(o>p){n&&gc(0);break}}i&&r(c+131072);for(var J=(1<>>4;if(o+=U&15,o>p){n&&gc(0);break}if(U||gc(2),Z<256)e[c++]=Z;else if(Z==256){X=o,u=null;break}else{var te=Z-254;if(Z>264){var _=Z-257,Q=O7[_];te=To(d,o,(1<>>4;ie||gc(3),o+=ie&15;var z=rLe[ne];if(ne>3){var Q=x7[ne];z+=aC(d,o)&(1<p){n&&gc(0);break}i&&r(c+131072);for(var oe=c+te;c>3&1)+(e>>4&1);s>0;s-=!d[t++]);return t+(e&2)},fLe=function(d){var e=d.length;return(d[e-4]|d[e-3]<<8|d[e-2]<<16|d[e-1]<<24)>>>0};function pLe(d,e=void 0){return _7(d,e)}function mLe(d,e=void 0){return _7(d.subarray(lLe(d),-8),e||new pa(fLe(d)))}var gLe=typeof TextDecoder<"u"&&new TextDecoder,yLe=0;try{gLe.decode(hLe,{stream:!0}),yLe=1}catch{}var A7;const oC=new WeakMap,wLe=()=>{};class bc{constructor(e){this.subscribers=[],this.settlement=null,this[A7]="Unpromise",typeof e=="function"?this.promise=new Promise(e):this.promise=e;const t=this.promise.then(s=>{const{subscribers:i}=this;this.subscribers=null,this.settlement={status:"fulfilled",value:s},i==null||i.forEach(({resolve:n})=>{n(s)})});"catch"in t&&t.catch(s=>{const{subscribers:i}=this;this.subscribers=null,this.settlement={status:"rejected",reason:s},i==null||i.forEach(({reject:n})=>{n(s)})})}subscribe(){let e,t;const{settlement:s}=this;if(s===null){if(this.subscribers===null)throw new Error("Unpromise settled but still has subscribers");const i=kLe();this.subscribers=SLe(this.subscribers,i),e=i.promise,t=()=>{this.subscribers!==null&&(this.subscribers=TLe(this.subscribers,i))}}else{const{status:i}=s;i==="fulfilled"?e=Promise.resolve(s.value):e=Promise.reject(s.reason),t=wLe}return Object.assign(e,{unsubscribe:t})}then(e,t){const s=this.subscribe(),{unsubscribe:i}=s;return Object.assign(s.then(e,t),{unsubscribe:i})}catch(e){const t=this.subscribe(),{unsubscribe:s}=t;return Object.assign(t.catch(e),{unsubscribe:s})}finally(e){const t=this.subscribe(),{unsubscribe:s}=t;return Object.assign(t.finally(e),{unsubscribe:s})}static proxy(e){const t=bc.getSubscribablePromise(e);return typeof t<"u"?t:bc.createSubscribablePromise(e)}static createSubscribablePromise(e){const t=new bc(e);return oC.set(e,t),oC.set(t,t),t}static getSubscribablePromise(e){return oC.get(e)}static resolve(e){const t=typeof e=="object"&&e!==null&&"then"in e&&typeof e.then=="function"?e:Promise.resolve(e);return bc.proxy(t).subscribe()}static async any(e){const s=(Array.isArray(e)?e:[...e]).map(bc.resolve);try{return await Promise.any(s)}finally{s.forEach(({unsubscribe:i})=>{i()})}}static async race(e){const s=(Array.isArray(e)?e:[...e]).map(bc.resolve);try{return await Promise.race(s)}finally{s.forEach(({unsubscribe:i})=>{i()})}}static async raceReferences(e){const t=e.map(bLe);try{return await Promise.race(t)}finally{for(const s of t)s.unsubscribe()}}}A7=Symbol.toStringTag;function bLe(d){return bc.proxy(d).then(()=>[d])}function kLe(){let d,e;return{promise:new Promise((s,i)=>{d=s,e=i}),resolve:d,reject:e}}function SLe(d,e){return[...d,e]}function vLe(d,e){return[...d.slice(0,e),...d.slice(e+1)]}function TLe(d,e){const t=d.indexOf(e);return t!==-1?vLe(d,t):d}function lh(){let d,e;const t=new Promise((s,i)=>{d=s,e=i});return t.resolve=function(){setTimeout(()=>{d.apply(this,arguments)})},t.reject=function(){setTimeout(()=>{e.apply(this,arguments)})},t}function OLe(d){const e=lh();return d.then(e.resolve,e.reject),e}lh.race=d=>OLe(bc.race(d));class xLe{constructor(e,t,s,i,n,r={}){this.useMessageQueue=!1,this.verbose=!1,Object.assign(this,Cj({url:e,onMessageCallback:t,onErrorCallback:s,onCloseCallback:i,onConnectedCallback:n,verbose:!1,protocols:void 0,options:void 0,futures:{},subscriptions:{},rejections:{},messageQueue:{},useMessageQueue:!1,connected:void 0,error:void 0,connectionStarted:void 0,connectionEstablished:void 0,isConnected:!1,connectionTimer:void 0,connectionTimeout:1e4,pingInterval:void 0,ping:void 0,keepAlive:3e4,maxPingPongMisses:2,connection:void 0,startedConnecting:!1,gunzip:!1,inflate:!1},r)),this.connected=lh()}future(e){e in this.futures||(this.futures[e]=lh());const t=this.futures[e];if(e in this.rejections)return t.reject(this.rejections[e]),delete this.rejections[e],delete this.messageQueue[e],t;if(this.useMessageQueue){const s=this.messageQueue[e];s&&s.length&&(t.resolve(s.shift()),delete this.futures[e])}return t}resolve(e,t){if(this.verbose&&t===void 0&&this.log(new Date,"resolve received undefined messageHash"),this.useMessageQueue===!0){t in this.messageQueue||(this.messageQueue[t]=[]);const s=this.messageQueue[t];for(s.push(e);s.length>10;)s.shift();t!==void 0&&t in this.futures&&(this.futures[t].resolve(s.shift()),delete this.futures[t])}else t in this.futures&&(this.futures[t].resolve(e),delete this.futures[t]);return e}reject(e,t=void 0){if(t)t in this.futures?(this.futures[t].reject(e),delete this.futures[t]):this.rejections[t]=e;else{const s=Object.keys(this.futures);for(let i=0;i{this.onError(s)}):jm?this.connection.ping():this.lastPong=e}}}onOpen(){this.verbose&&this.log(new Date,"onOpen"),this.connectionEstablished=l0(),this.isConnected=!0,this.connected.resolve(this.url),this.clearConnectionTimeout(),this.setPingInterval(),this.onConnectedCallback(this)}onPing(){this.verbose&&this.log(new Date,"onPing")}onPong(){this.lastPong=l0(),this.verbose&&this.log(new Date,"onPong")}onError(e){this.verbose&&this.log(new Date,"onError",e.message),e instanceof fg||(e=new qs(e.message)),this.error=e,this.reset(this.error),this.onErrorCallback(this,this.error)}onClose(e){this.verbose&&this.log(new Date,"onClose",e),this.error||this.reset(new qs("connection closed by remote server, closing code "+String(e.code))),this.error instanceof YO&&this.reset(this.error),this.disconnected!==void 0&&this.disconnected.resolve(!0),this.onCloseCallback(this,e)}onUpgrade(e){this.verbose&&this.log(new Date,"onUpgrade")}async send(e){this.verbose&&this.log(new Date,"sending",e),e=typeof e=="string"?e:JSON.stringify(e);const t=lh();if(jm){let s=function(i){i?t.reject(i):t.resolve(null)};this.connection.send(e,{},s)}else this.connection.send(e),t.resolve(null);return t}close(){throw new q("close() not implemented yet")}onMessage(e){let t=e.data,s;typeof t!="string"&&(this.gunzip||this.inflate?(s=new Uint8Array(t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)),this.gunzip?s=mLe(s):this.inflate&&(s=pLe(s)),t=Wd.encode(s)):t=t.toString());try{jj(t)&&(t=JSON.parse(t.replace(/:(\d{15,}),/g,':"$1",'))),this.verbose&&this.log(new Date,"onMessage",t)}catch(i){this.log(new Date,"onMessage JSON.parse",i)}try{this.onMessageCallback(this,t)}catch(i){this.reject(i)}}}const IS=jm||!v7()?tLe:self.WebSocket;class PLe extends xLe{constructor(){super(...arguments),this.startedConnecting=!1}createConnection(){this.verbose&&this.log(new Date,"connecting to",this.url),this.connectionStarted=l0(),this.setConnectionTimeout(),jm?this.connection=new IS(this.url,this.protocols,this.options):this.connection=new IS(this.url,this.protocols),this.connection.onopen=this.onOpen.bind(this),this.connection.onmessage=this.onMessage.bind(this),this.connection.onerror=this.onError.bind(this),this.connection.onclose=this.onClose.bind(this),jm&&this.connection.on("ping",this.onPing.bind(this)).on("pong",this.onPong.bind(this)).on("upgrade",this.onUpgrade.bind(this))}connect(e=0){return this.startedConnecting||(this.startedConnecting=!0,e?kB(e).then(this.createConnection.bind(this)):this.createConnection()),this.connected}isOpen(){return this.connection.readyState===IS.OPEN}close(){return this.connection instanceof IS&&(this.disconnected===void 0&&(this.disconnected=lh()),this.connection.close()),this.disconnected}}function Hp(d,e){let t=0,s=d.length-1;for(;t<=s;){const i=t+s>>>1;d[i]-e<0?t=i+1:s=i-1}return t}const ILe=1024,L7=new Float64Array(new Array(ILe).fill(Number.MAX_VALUE));class vB extends Array{constructor(e=[],t=void 0){super(),Object.defineProperty(this,"index",{__proto__:null,value:new Float64Array(L7),writable:!0}),Object.defineProperty(this,"depth",{__proto__:null,value:t||Number.MAX_SAFE_INTEGER,writable:!0}),this.length=0;for(let s=0;sthis.index.length-1){const r=Array.from(this.index);r.length=this.length*2,r.fill(Number.MAX_VALUE,this.index.length),this.index=new Float64Array(r)}}else this.index[n]===i&&(this.index.copyWithin(n,n+1,this.index.length),this.index[this.length-1]=Number.MAX_VALUE,this.copyWithin(n,n+1,this.length),this.length--)}store(e,t){this.storeArray([e,t])}limit(){if(this.length>this.depth){for(let e=this.depth;ethis.index.length-1){const a=Array.from(this.index);a.length=this.length*2,a.fill(Number.MAX_VALUE,this.index.length),this.index=new Float64Array(a)}}else this.index[r]===n&&(this.index.copyWithin(r,r+1,this.index.length),this.index[this.length-1]=Number.MAX_VALUE,this.copyWithin(r,r+1,this.length),this.length--)}}class N7 extends Array{constructor(e=[],t=Number.MAX_SAFE_INTEGER){super(e.length),Object.defineProperty(this,"hashmap",{__proto__:null,value:new Map,writable:!0}),Object.defineProperty(this,"index",{__proto__:null,value:new Float64Array(L7),writable:!0}),Object.defineProperty(this,"depth",{__proto__:null,value:t||Number.MAX_SAFE_INTEGER,writable:!0});for(let s=0;sthis.index.length-1){const a=Array.from(this.index);a.length=this.length*2,a.fill(Number.MAX_VALUE,this.index.length),this.index=new Float64Array(a)}}else if(this.hashmap.has(i)){const r=this.hashmap.get(i);let a=Hp(this.index,r);for(;this[a][2]!==i;)a++;this.index.copyWithin(a,a+1,this.index.length),this.index[this.length-1]=Number.MAX_VALUE,this.copyWithin(a,a+1,this.length),this.length--,this.hashmap.delete(i)}}limit(){if(this.length>this.depth){for(let e=this.depth;ed<>>32-e>>>0,NLe=(d,e,t)=>d&e^~d&t,ELe=(d,e,t)=>d&e^d&t^e&t,my=new Uint32Array([1732584193,4023233417,2562383102,271733878,3285377520]),Cu=new Uint32Array(80);class RLe extends cB{constructor(){super(64,20,8,!1),this.A=my[0]|0,this.B=my[1]|0,this.C=my[2]|0,this.D=my[3]|0,this.E=my[4]|0}get(){const{A:e,B:t,C:s,D:i,E:n}=this;return[e,t,s,i,n]}set(e,t,s,i,n){this.A=e|0,this.B=t|0,this.C=s|0,this.D=i|0,this.E=n|0}process(e,t){for(let o=0;o<16;o++,t+=4)Cu[o]=e.getUint32(t,!1);for(let o=16;o<80;o++)Cu[o]=dC(Cu[o-3]^Cu[o-8]^Cu[o-14]^Cu[o-16],1);let{A:s,B:i,C:n,D:r,E:a}=this;for(let o=0;o<80;o++){let c,u;o<20?(c=NLe(i,n,r),u=1518500249):o<40?(c=i^n^r,u=1859775393):o<60?(c=ELe(i,n,r),u=2400959708):(c=i^n^r,u=3395469782);const h=dC(s,5)+c+a+u+Cu[o]|0;a=r,r=n,n=dC(i,30),i=s,s=h}s=s+this.A|0,i=i+this.B|0,n=n+this.C|0,r=r+this.D|0,a=a+this.E|0,this.set(s,i,n,r,a)}roundClean(){Cu.fill(0)}destroy(){this.set(0,0,0,0,0),this.buffer.fill(0)}}const DLe=ru(()=>new RLe);function xw(d){const e=c=>(c<15.5?"0":"")+Math.round(c).toString(16),t=c=>parseInt(c,16),s=(c,u)=>(u+c).slice(-u.length);d=d.replace(" ","");const i=Math.round(new Date().getTime()/1e3),n=s(e(Math.floor(i/30)),"0000000000000000"),r=wB(Uh.decode(n),Ej.decode(d),DLe,"hex"),a=t(r.substring(r.length-1));let o=(t(r.substr(a*2,8))&t("7fffffff"))+"";return o.substring(o.length-6,o.length)}function qLe(d,e,t){const s=e.split("|").map(n=>n.trim());for(let n=0;n>4],t+=e[d[s]&15];return t}if(typeof d=="object"&&typeof d.toJSON=="function")return Gp(d.toJSON());switch(typeof d){case"boolean":case"symbol":return d.toString();case"bigint":return BigInt(d).toString();case"number":return d.toString();case"string":return JSON.stringify(d);case"object":{const e=Object.keys(d);return e.sort(),"{ "+e.map(t=>`${Gp(t)}: ${Gp(d[t])}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function l3(d,e){return d&&d.code===e}function VLe(d,e,t){let s=d;{const n=[];if(t){if("message"in t||"code"in t||"name"in t)throw new Error(`value will overwrite populated values: ${Gp(t)}`);for(const r in t){if(r==="shortMessage")continue;const a=t[r];n.push(r+"="+Gp(a))}}n.push(`code=${e}`),n.length&&(d+=" ("+n.join(", ")+")")}let i;switch(e){case"INVALID_ARGUMENT":i=new TypeError(d);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":i=new RangeError(d);break;default:i=new Error(d)}return Qo(i,{code:e}),t&&Object.assign(i,t),i.shortMessage==null&&Qo(i,{shortMessage:s}),i}function jn(d,e,t,s){if(!d)throw VLe(e,t,s)}function Vt(d,e,t,s){jn(d,e,"INVALID_ARGUMENT",{argument:t,value:s})}function D7(d,e,t){t==null&&(t=""),t&&(t=": "+t),jn(d>=e,"missing arguemnt"+t,"MISSING_ARGUMENT",{count:d,expectedCount:e}),jn(d<=e,"too many arguemnts"+t,"UNEXPECTED_ARGUMENT",{count:d,expectedCount:e})}["NFD","NFC","NFKD","NFKC"].reduce((d,e)=>{try{if("test".normalize(e)!=="test")throw new Error("bad");if(e==="NFD"&&"é".normalize("NFD")!=="é")throw new Error("broken");d.push(e)}catch{}return d},[]);function FLe(d,e,t){if(d!==e){let s=t,i="new";s+=".",i+=" "+t,jn(!1,`private constructor; use ${s}from* methods`,"UNSUPPORTED_OPERATION",{operation:i})}}function q7(d,e,t){if(d instanceof Uint8Array)return t?new Uint8Array(d):d;if(typeof d=="string"&&d.match(/^0x([0-9a-f][0-9a-f])*$/i)){const s=new Uint8Array((d.length-2)/2);let i=2;for(let n=0;n>4]+f3[i&15]}return t}function of(d){return"0x"+d.map(e=>au(e).substring(2)).join("")}function GLe(d,e,t){const s=jh(d);jn(e>=s.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(s),length:e,offset:e+1});const i=new Uint8Array(e);return i.fill(0),i.set(s,e-s.length),au(i)}function ULe(d,e){return GLe(d,e)}const JO=BigInt(0),Bo=BigInt(1),Up=9007199254740991;function WLe(d,e){const t=ex(d,"value"),s=BigInt(zh(e,"width"));if(jn(t>>s===JO,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:d}),t>>s-Bo){const i=(Bo<=-Up&&d<=Up,"overflow",e||"value",d),BigInt(d);case"string":try{if(d==="")throw new Error("empty string");return d[0]==="-"&&d[1]!=="-"?-BigInt(d.substring(1)):BigInt(d)}catch(t){Vt(!1,`invalid BigNumberish string: ${t.message}`,e||"value",d)}}Vt(!1,"invalid BigNumberish value",e||"value",d)}function ex(d,e){const t=Pf(d,e);return jn(t>=JO,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:d}),t}const p3="0123456789abcdef";function F7(d){if(d instanceof Uint8Array){let e="0x0";for(const t of d)e+=p3[t>>4],e+=p3[t&15];return BigInt(e)}return Pf(d)}function zh(d,e){switch(typeof d){case"bigint":return Vt(d>=-Up&&d<=Up,"overflow",e||"value",d),Number(d);case"number":return Vt(Number.isInteger(d),"underflow",e||"value",d),Vt(d>=-Up&&d<=Up,"overflow",e||"value",d),d;case"string":try{if(d==="")throw new Error("empty string");return zh(BigInt(d),e)}catch(t){Vt(!1,`invalid numeric string: ${t.message}`,e||"value",d)}}Vt(!1,"invalid numeric value",e||"value",d)}function jLe(d){return zh(F7(d))}function tx(d,e){let s=ex(d,"value").toString(16);if(e==null)s.length%2&&(s="0"+s);else{const i=zh(e,"width");for(jn(i*2>=s.length,`value exceeds width (${i} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:d});s.length>6===2;r++)n++;return n}return d==="OVERRUN"?t.length-e-1:0}function KLe(d,e,t,s,i){return d==="OVERLONG"?(Vt(typeof i=="number","invalid bad code point for replacement","badCodepoint",i),s.push(i),0):(s.push(65533),G7(d,e,t))}const XLe=Object.freeze({error:$Le,ignore:G7,replace:KLe});function QLe(d,e){e==null&&(e=XLe.error);const t=jh(d,"bytes"),s=[];let i=0;for(;i>7)){s.push(n);continue}let r=null,a=null;if((n&224)===192)r=1,a=127;else if((n&240)===224)r=2,a=2047;else if((n&248)===240)r=3,a=65535;else{(n&192)===128?i+=e("UNEXPECTED_CONTINUE",i-1,t,s):i+=e("BAD_PREFIX",i-1,t,s);continue}if(i-1+r>=t.length){i+=e("OVERRUN",i-1,t,s);continue}let o=n&(1<<8-r-1)-1;for(let c=0;c1114111){i+=e("OUT_OF_RANGE",i-1-r,t,s,o);continue}if(o>=55296&&o<=57343){i+=e("UTF16_SURROGATE",i-1-r,t,s,o);continue}if(o<=a){i+=e("OVERLONG",i-1-r,t,s,o);continue}s.push(o)}}return s}function YLe(d,e){let t=[];for(let s=0;s>6|192),t.push(i&63|128);else if((i&64512)==55296){s++;const n=d.charCodeAt(s);Vt(s>18|240),t.push(r>>12&63|128),t.push(r>>6&63|128),t.push(r&63|128)}else t.push(i>>12|224),t.push(i>>6&63|128),t.push(i&63|128)}return new Uint8Array(t)}function ZLe(d){return d.map(e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10&1023)+55296,(e&1023)+56320))).join("")}function JLe(d,e){return ZLe(QLe(d,e))}const CS=BigInt(2**32-1),L2=BigInt(32);function U7(d,e=!1){return e?{h:Number(d&CS),l:Number(d>>L2&CS)}:{h:Number(d>>L2&CS)|0,l:Number(d&CS)|0}}function eBe(d,e=!1){let t=new Uint32Array(d.length),s=new Uint32Array(d.length);for(let i=0;iBigInt(d>>>0)<>>0),sBe=(d,e,t)=>d>>>t,iBe=(d,e,t)=>d<<32-t|e>>>t,nBe=(d,e,t)=>d>>>t|e<<32-t,rBe=(d,e,t)=>d<<32-t|e>>>t,aBe=(d,e,t)=>d<<64-t|e>>>t-32,oBe=(d,e,t)=>d>>>t-32|e<<64-t,dBe=(d,e)=>e,cBe=(d,e)=>d,uBe=(d,e,t)=>d<>>32-t,hBe=(d,e,t)=>e<>>32-t,lBe=(d,e,t)=>e<>>64-t,fBe=(d,e,t)=>d<>>64-t;function pBe(d,e,t,s){const i=(e>>>0)+(s>>>0);return{h:d+t+(i/2**32|0)|0,l:i|0}}const mBe=(d,e,t)=>(d>>>0)+(e>>>0)+(t>>>0),gBe=(d,e,t,s)=>e+t+s+(d/2**32|0)|0,yBe=(d,e,t,s)=>(d>>>0)+(e>>>0)+(t>>>0)+(s>>>0),wBe=(d,e,t,s,i)=>e+t+s+i+(d/2**32|0)|0,bBe=(d,e,t,s,i)=>(d>>>0)+(e>>>0)+(t>>>0)+(s>>>0)+(i>>>0),kBe=(d,e,t,s,i,n)=>e+t+s+i+n+(d/2**32|0)|0,es={fromBig:U7,split:eBe,toBig:tBe,shrSH:sBe,shrSL:iBe,rotrSH:nBe,rotrSL:rBe,rotrBH:aBe,rotrBL:oBe,rotr32H:dBe,rotr32L:cBe,rotlSH:uBe,rotlSL:hBe,rotlBH:lBe,rotlBL:fBe,add:pBe,add3L:mBe,add3H:gBe,add4L:yBe,add4H:wBe,add5H:kBe,add5L:bBe},[W7,j7,z7]=[[],[],[]],SBe=BigInt(0),gy=BigInt(1),vBe=BigInt(2),TBe=BigInt(7),OBe=BigInt(256),xBe=BigInt(113);for(let d=0,e=gy,t=1,s=0;d<24;d++){[t,s]=[s,(2*t+3*s)%5],W7.push(2*(5*s+t)),j7.push((d+1)*(d+2)/2%64);let i=SBe;for(let n=0;n<7;n++)e=(e<>TBe)*xBe)%OBe,e&vBe&&(i^=gy<<(gy<t>32?es.rotlBH(d,e,t):es.rotlSH(d,e,t),g3=(d,e,t)=>t>32?es.rotlBL(d,e,t):es.rotlSL(d,e,t);function CBe(d,e=24){const t=new Uint32Array(10);for(let s=24-e;s<24;s++){for(let r=0;r<10;r++)t[r]=d[r]^d[r+10]^d[r+20]^d[r+30]^d[r+40];for(let r=0;r<10;r+=2){const a=(r+8)%10,o=(r+2)%10,c=t[o],u=t[o+1],h=m3(c,u,1)^t[a],l=g3(c,u,1)^t[a+1];for(let f=0;f<50;f+=10)d[r+f]^=h,d[r+f+1]^=l}let i=d[2],n=d[3];for(let r=0;r<24;r++){const a=j7[r],o=m3(i,n,a),c=g3(i,n,a),u=W7[r];i=d[u],n=d[u+1],d[u]=o,d[u+1]=c}for(let r=0;r<50;r+=10){for(let a=0;a<10;a++)t[a]=d[r+a];for(let a=0;a<10;a++)d[r+a]^=~t[(a+2)%10]&t[(a+4)%10]}d[0]^=PBe[s],d[1]^=IBe[s]}t.fill(0)}class sx extends WO{constructor(e,t,s,i=!1,n=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=s,this.enableXOF=i,this.rounds=n,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,ua.number(s),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=Y_e(this.state)}keccak(){CBe(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){ua.exists(this);const{blockLen:t,state:s}=this;e=hg(e);const i=e.length;for(let n=0;n=s&&this.keccak();const r=Math.min(s-this.posOut,n-i);e.set(t.subarray(this.posOut,this.posOut+r),i),this.posOut+=r,i+=r}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return ua.number(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(ua.output(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:s,outputLen:i,rounds:n,enableXOF:r}=this;return e||(e=new sx(t,s,i,r,n)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=s,e.outputLen=i,e.enableXOF=r,e.destroyed=this.destroyed,e}}const $h=(d,e,t)=>ru(()=>new sx(e,d,t));$h(6,144,224/8);$h(6,136,256/8);$h(6,104,384/8);$h(6,72,512/8);$h(1,144,224/8);const pr=$h(1,136,256/8);$h(1,104,384/8);$h(1,72,512/8);const $7=(d,e,t)=>J_e((s={})=>new sx(e,d,s.dkLen===void 0?t:s.dkLen,!0));$7(31,168,128/8);$7(31,136,256/8);function K7(d){return"0x"+KO(d,pr,"hex")}function lm(d){return"0x"+KO(d,pr,"hex")}var ra=function(d,e,t,s,i){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?d!==e||!i:!e.has(d))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?i.call(d,t):i?i.value=t:e.set(d,t),t},Zt=function(d,e,t,s){if(t==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?d!==e||!s:!e.has(d))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?s:t==="a"?s.call(d):s?s.value:e.get(d)},ml,Dy,qu,ju,b1,p0,aa,oa,yl,fm,Cl,X7,Q7;const gr=32,B2=new Uint8Array(gr),MBe=["then"],MS={};function yy(d,e){const t=new Error(`deferred error during ABI decoding triggered accessing ${d}`);throw t.error=e,t}class m0 extends Array{constructor(...e){const t=e[0];let s=e[1],i=(e[2]||[]).slice(),n=!0;t!==MS&&(s=e,i=[],n=!1),super(s.length),ml.set(this,void 0),s.forEach((a,o)=>{this[o]=a});const r=i.reduce((a,o)=>(typeof o=="string"&&a.set(o,(a.get(o)||0)+1),a),new Map);if(ra(this,ml,Object.freeze(s.map((a,o)=>{const c=i[o];return c!=null&&r.get(c)===1?c:null})),"f"),!!n)return Object.freeze(this),new Proxy(this,{get:(a,o,c)=>{if(typeof o=="string"){if(o.match(/^[0-9]+$/)){const h=zh(o,"%index");if(h<0||h>=this.length)throw new RangeError("out of result range");const l=a[h];return l instanceof Error&&yy(`index ${h}`,l),l}if(MBe.indexOf(o)>=0)return Reflect.get(a,o,c);const u=a[o];if(u instanceof Function)return function(...h){return u.apply(this===c?a:this,h)};if(!(o in a))return a.getValue.apply(this===c?a:this,[o])}return Reflect.get(a,o,c)}})}toArray(){const e=[];return this.forEach((t,s)=>{t instanceof Error&&yy(`index ${s}`,t),e.push(t)}),e}toObject(){return Zt(this,ml,"f").reduce((e,t,s)=>(jn(t!=null,"value at index ${ index } unnamed","UNSUPPORTED_OPERATION",{operation:"toObject()"}),t in e||(e[t]=this.getValue(t)),e),{})}slice(e,t){e==null&&(e=0),e<0&&(e+=this.length,e<0&&(e=0)),t==null&&(t=this.length),t<0&&(t+=this.length,t<0&&(t=0)),t>this.length&&(t=this.length);const s=[],i=[];for(let n=e;n{Zt(this,qu,"f")[e]=y3(t)}}}qu=new WeakMap,ju=new WeakMap,Dy=new WeakSet,b1=function(e){return Zt(this,qu,"f").push(e),ra(this,ju,Zt(this,ju,"f")+e.length,"f"),e.length};class OB{constructor(e,t,s){p0.add(this),aa.set(this,void 0),oa.set(this,void 0),yl.set(this,void 0),fm.set(this,void 0),Cl.set(this,void 0),Qo(this,{allowLoose:!!t}),ra(this,aa,Vc(e),"f"),ra(this,yl,0,"f"),ra(this,fm,null,"f"),ra(this,Cl,s??1024,"f"),ra(this,oa,0,"f")}get data(){return au(Zt(this,aa,"f"))}get dataLength(){return Zt(this,aa,"f").length}get consumed(){return Zt(this,oa,"f")}get bytes(){return new Uint8Array(Zt(this,aa,"f"))}subReader(e){const t=new OB(Zt(this,aa,"f").slice(Zt(this,oa,"f")+e),this.allowLoose,Zt(this,Cl,"f"));return ra(t,fm,this,"f"),t}readBytes(e,t){let s=Zt(this,p0,"m",Q7).call(this,0,e,!!t);return Zt(this,p0,"m",X7).call(this,e),ra(this,oa,Zt(this,oa,"f")+s.length,"f"),s.slice(0,e)}readValue(){return F7(this.readBytes(gr))}readIndex(){return jLe(this.readBytes(gr))}}aa=new WeakMap,oa=new WeakMap,yl=new WeakMap,fm=new WeakMap,Cl=new WeakMap,p0=new WeakSet,X7=function d(e){var t;if(Zt(this,fm,"f"))return Zt(t=Zt(this,fm,"f"),p0,"m",d).call(t,e);ra(this,yl,Zt(this,yl,"f")+e,"f"),jn(Zt(this,Cl,"f")<1||Zt(this,yl,"f")<=Zt(this,Cl,"f")*this.dataLength,`compressed ABI data exceeds inflation ratio of ${Zt(this,Cl,"f")} ( see: https://github.com/ethers-io/ethers.js/issues/4537 )`,"BUFFER_OVERRUN",{buffer:Vc(Zt(this,aa,"f")),offset:Zt(this,oa,"f"),length:e,info:{bytesRead:Zt(this,yl,"f"),dataLength:this.dataLength}})},Q7=function(e,t,s){let i=Math.ceil(t/gr)*gr;return Zt(this,oa,"f")+i>Zt(this,aa,"f").length&&(this.allowLoose&&s&&Zt(this,oa,"f")+t<=Zt(this,aa,"f").length?i=t:jn(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:Vc(Zt(this,aa,"f")),length:Zt(this,aa,"f").length,offset:Zt(this,oa,"f")+i})),Zt(this,aa,"f").slice(Zt(this,oa,"f"),Zt(this,oa,"f")+i)};const _Be=BigInt(0),ABe=BigInt(36);function w3(d){d=d.toLowerCase();const e=d.substring(2).split(""),t=new Uint8Array(40);for(let i=0;i<40;i++)t[i]=e[i].charCodeAt(0);const s=pr(t);for(let i=0;i<40;i+=2)s[i>>1]>>4>=8&&(e[i]=e[i].toUpperCase()),(s[i>>1]&15)>=8&&(e[i+1]=e[i+1].toUpperCase());return"0x"+e.join("")}const xB={};for(let d=0;d<10;d++)xB[String(d)]=String(d);for(let d=0;d<26;d++)xB[String.fromCharCode(65+d)]=String(10+d);const b3=15;function LBe(d){d=d.toUpperCase(),d=d.substring(4)+d.substring(0,2)+"00";let e=d.split("").map(s=>xB[s]).join("");for(;e.length>=b3;){let s=e.substring(0,b3);e=parseInt(s,10)%97+e.substring(s.length)}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}const BBe=function(){const d={};for(let e=0;e<36;e++){const t="0123456789abcdefghijklmnopqrstuvwxyz"[e];d[t]=BigInt(e)}return d}();function NBe(d){d=d.toLowerCase();let e=_Be;for(let t=0;te.format()).join(",")})`:this.type}defaultValue(){return 0}minValue(){return 0}maxValue(){return 0}isBigInt(){return!!this.type.match(/^u?int[0-9]+$/)}isData(){return this.type.startsWith("bytes")}isString(){return this.type==="string"}get tupleName(){if(this.type!=="tuple")throw TypeError("not a tuple");return uC(this,kp,"f")}get arrayLength(){if(this.type!=="array")throw TypeError("not an array");return uC(this,kp,"f")===!0?-1:uC(this,kp,"f")===!1?this.value.length:null}static from(e,t){return new Fn(Vu,e,t)}static uint8(e){return Ot(e,8)}static uint16(e){return Ot(e,16)}static uint24(e){return Ot(e,24)}static uint32(e){return Ot(e,32)}static uint40(e){return Ot(e,40)}static uint48(e){return Ot(e,48)}static uint56(e){return Ot(e,56)}static uint64(e){return Ot(e,64)}static uint72(e){return Ot(e,72)}static uint80(e){return Ot(e,80)}static uint88(e){return Ot(e,88)}static uint96(e){return Ot(e,96)}static uint104(e){return Ot(e,104)}static uint112(e){return Ot(e,112)}static uint120(e){return Ot(e,120)}static uint128(e){return Ot(e,128)}static uint136(e){return Ot(e,136)}static uint144(e){return Ot(e,144)}static uint152(e){return Ot(e,152)}static uint160(e){return Ot(e,160)}static uint168(e){return Ot(e,168)}static uint176(e){return Ot(e,176)}static uint184(e){return Ot(e,184)}static uint192(e){return Ot(e,192)}static uint200(e){return Ot(e,200)}static uint208(e){return Ot(e,208)}static uint216(e){return Ot(e,216)}static uint224(e){return Ot(e,224)}static uint232(e){return Ot(e,232)}static uint240(e){return Ot(e,240)}static uint248(e){return Ot(e,248)}static uint256(e){return Ot(e,256)}static uint(e){return Ot(e,256)}static int8(e){return Ot(e,-8)}static int16(e){return Ot(e,-16)}static int24(e){return Ot(e,-24)}static int32(e){return Ot(e,-32)}static int40(e){return Ot(e,-40)}static int48(e){return Ot(e,-48)}static int56(e){return Ot(e,-56)}static int64(e){return Ot(e,-64)}static int72(e){return Ot(e,-72)}static int80(e){return Ot(e,-80)}static int88(e){return Ot(e,-88)}static int96(e){return Ot(e,-96)}static int104(e){return Ot(e,-104)}static int112(e){return Ot(e,-112)}static int120(e){return Ot(e,-120)}static int128(e){return Ot(e,-128)}static int136(e){return Ot(e,-136)}static int144(e){return Ot(e,-144)}static int152(e){return Ot(e,-152)}static int160(e){return Ot(e,-160)}static int168(e){return Ot(e,-168)}static int176(e){return Ot(e,-176)}static int184(e){return Ot(e,-184)}static int192(e){return Ot(e,-192)}static int200(e){return Ot(e,-200)}static int208(e){return Ot(e,-208)}static int216(e){return Ot(e,-216)}static int224(e){return Ot(e,-224)}static int232(e){return Ot(e,-232)}static int240(e){return Ot(e,-240)}static int248(e){return Ot(e,-248)}static int256(e){return Ot(e,-256)}static int(e){return Ot(e,-256)}static bytes1(e){return _s(e,1)}static bytes2(e){return _s(e,2)}static bytes3(e){return _s(e,3)}static bytes4(e){return _s(e,4)}static bytes5(e){return _s(e,5)}static bytes6(e){return _s(e,6)}static bytes7(e){return _s(e,7)}static bytes8(e){return _s(e,8)}static bytes9(e){return _s(e,9)}static bytes10(e){return _s(e,10)}static bytes11(e){return _s(e,11)}static bytes12(e){return _s(e,12)}static bytes13(e){return _s(e,13)}static bytes14(e){return _s(e,14)}static bytes15(e){return _s(e,15)}static bytes16(e){return _s(e,16)}static bytes17(e){return _s(e,17)}static bytes18(e){return _s(e,18)}static bytes19(e){return _s(e,19)}static bytes20(e){return _s(e,20)}static bytes21(e){return _s(e,21)}static bytes22(e){return _s(e,22)}static bytes23(e){return _s(e,23)}static bytes24(e){return _s(e,24)}static bytes25(e){return _s(e,25)}static bytes26(e){return _s(e,26)}static bytes27(e){return _s(e,27)}static bytes28(e){return _s(e,28)}static bytes29(e){return _s(e,29)}static bytes30(e){return _s(e,30)}static bytes31(e){return _s(e,31)}static bytes32(e){return _s(e,32)}static address(e){return new Fn(Vu,"address",e)}static bool(e){return new Fn(Vu,"bool",!!e)}static bytes(e){return new Fn(Vu,"bytes",e)}static string(e){return new Fn(Vu,"string",e)}static array(e,t){throw new Error("not implemented yet")}static tuple(e,t){throw new Error("not implemented yet")}static overrides(e){return new Fn(Vu,"overrides",Object.assign({},e))}static isTyped(e){return e&&typeof e=="object"&&"_typedSymbol"in e&&e._typedSymbol===k3}static dereference(e,t){if(Fn.isTyped(e)){if(e.type!==t)throw new Error(`invalid type: expecetd ${t}, got ${e.type}`);return e.value}return e}}kp=new WeakMap;class RBe extends ou{constructor(e){super("address","address",e,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(e,t){let s=Fn.dereference(t,"string");try{s=$v(s)}catch(i){return this._throwError(i.message,t)}return e.writeValue(s)}decode(e){return $v(tx(e.readValue(),20))}}class DBe extends ou{constructor(e){super(e.name,e.type,"_",e.dynamic),this.coder=e}defaultValue(){return this.coder.defaultValue()}encode(e,t){return this.coder.encode(e,t)}decode(e){return this.coder.decode(e)}}function Y7(d,e,t){let s=[];if(Array.isArray(t))s=t;else if(t&&typeof t=="object"){let o={};s=e.map(c=>{const u=c.localName;return jn(u,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:c},value:t}),jn(!o[u],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:c},value:t}),o[u]=!0,t[u]})}else Vt(!1,"invalid tuple value","tuple",t);Vt(e.length===s.length,"types/value length mismatch","tuple",t);let i=new N2,n=new N2,r=[];e.forEach((o,c)=>{let u=s[c];if(o.dynamic){let h=n.length;o.encode(n,u);let l=i.writeUpdatableValue();r.push(f=>{l(f+h)})}else o.encode(i,u)}),r.forEach(o=>{o(i.length)});let a=d.appendWriter(i);return a+=d.appendWriter(n),a}function Z7(d,e){let t=[],s=[],i=d.subReader(0);return e.forEach(n=>{let r=null;if(n.dynamic){let a=d.readIndex(),o=i.subReader(a);try{r=n.decode(o)}catch(c){if(l3(c,"BUFFER_OVERRUN"))throw c;r=c,r.baseType=n.name,r.name=n.localName,r.type=n.type}}else try{r=n.decode(d)}catch(a){if(l3(a,"BUFFER_OVERRUN"))throw a;r=a,r.baseType=n.name,r.name=n.localName,r.type=n.type}if(r==null)throw new Error("investigate");t.push(r),s.push(n.localName||null)}),m0.fromItems(t,s)}class qBe extends ou{constructor(e,t,s){const i=e.type+"["+(t>=0?t:"")+"]",n=t===-1||e.dynamic;super("array",i,s,n),Qo(this,{coder:e,length:t})}defaultValue(){const e=this.coder.defaultValue(),t=[];for(let s=0;sn||s<-(n+jBe))&&this._throwError("value out-of-bounds",t),s=V7(s,8*gr)}else(sRy(i,this.size*8))&&this._throwError("value out-of-bounds",t);return e.writeValue(s)}decode(e){let t=Ry(e.readValue(),this.size*8);return this.signed&&(t=WLe(t,this.size*8)),t}}class KBe extends J7{constructor(e){super("string",e)}defaultValue(){return""}encode(e,t){return super.encode(e,YLe(Fn.dereference(t,"string")))}decode(e){return JLe(super.decode(e))}}class k1 extends ou{constructor(e,t){let s=!1;const i=[];e.forEach(r=>{r.dynamic&&(s=!0),i.push(r.type)});const n="tuple("+i.join(",")+")";super("tuple",n,t,s),Qo(this,{coders:Object.freeze(e.slice())})}defaultValue(){const e=[];this.coders.forEach(s=>{e.push(s.defaultValue())});const t=this.coders.reduce((s,i)=>{const n=i.localName;return n&&(s[n]||(s[n]=0),s[n]++),s},{});return this.coders.forEach((s,i)=>{let n=s.localName;!n||t[n]!==1||(n==="length"&&(n="_length"),e[n]==null&&(e[n]=e[i]))}),Object.freeze(e)}encode(e,t){const s=Fn.dereference(t,"tuple");return Y7(e,this.coders,s)}decode(e){return Z7(e,this.coders)}}var ol=function(d,e,t,s,i){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?d!==e||!i:!e.has(d))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?i.call(d,t):i?i.value=t:e.set(d,t),t},Ui=function(d,e,t,s){if(t==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?d!==e||!s:!e.has(d))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?s:t==="a"?s.call(d):s?s.value:e.get(d)},S1,En,wd,E2,g0,ez;function pg(d){const e=new Set;return d.forEach(t=>e.add(t)),Object.freeze(e)}const XBe="external public payable";pg(XBe.split(" "));const tz="constant external internal payable private public pure view";pg(tz.split(" "));const sz="constructor error event fallback function receive struct";pg(sz.split(" "));const iz="calldata memory storage payable indexed",QBe=pg(iz.split(" ")),YBe="tuple returns",ZBe=[sz,iz,YBe,tz].join(" "),JBe=pg(ZBe.split(" ")),eNe={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},tNe=new RegExp("^(\\s*)"),sNe=new RegExp("^([0-9]+)"),iNe=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),nNe=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),nz=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$");class Tb{constructor(e){S1.add(this),En.set(this,void 0),wd.set(this,void 0),ol(this,En,0,"f"),ol(this,wd,e.slice(),"f")}get offset(){return Ui(this,En,"f")}get length(){return Ui(this,wd,"f").length-Ui(this,En,"f")}clone(){return new Tb(Ui(this,wd,"f"))}reset(){ol(this,En,0,"f")}popKeyword(e){const t=this.peek();if(t.type!=="KEYWORD"||!e.has(t.text))throw new Error(`expected keyword ${t.text}`);return this.pop().text}popType(e){if(this.peek().type!==e)throw new Error(`expected ${e}; got ${JSON.stringify(this.peek())}`);return this.pop().text}popParen(){const e=this.peek();if(e.type!=="OPEN_PAREN")throw new Error("bad start");const t=Ui(this,S1,"m",E2).call(this,Ui(this,En,"f")+1,e.match+1);return ol(this,En,e.match+1,"f"),t}popParams(){const e=this.peek();if(e.type!=="OPEN_PAREN")throw new Error("bad start");const t=[];for(;Ui(this,En,"f")=Ui(this,wd,"f").length)throw new Error("out-of-bounds");return Ui(this,wd,"f")[Ui(this,En,"f")]}peekKeyword(e){const t=this.peekType("KEYWORD");return t!=null&&e.has(t)?t:null}peekType(e){if(this.length===0)return null;const t=this.peek();return t.type===e?t.text:null}pop(){var e;const t=this.peek();return ol(this,En,(e=Ui(this,En,"f"),e++,e),"f"),t}toString(){const e=[];for(let t=Ui(this,En,"f");t`}}En=new WeakMap,wd=new WeakMap,S1=new WeakSet,E2=function(e=0,t=0){return new Tb(Ui(this,wd,"f").slice(e,t).map(s=>Object.freeze(Object.assign({},s,{match:s.match-e,linkBack:s.linkBack-e,linkNext:s.linkNext-e}))))};function rNe(d){const e=[],t=r=>{const a=n0&&e[e.length-1].type==="NUMBER"){const h=e.pop().text;u=h+u,e[e.length-1].value=zh(h)}if(e.length===0||e[e.length-1].type!=="BRACKET")throw new Error("missing opening bracket");e[e.length-1].text+=u}continue}if(a=r.match(iNe),a){if(o.text=a[1],n+=o.text.length,JBe.has(o.text)){o.type="KEYWORD";continue}if(o.text.match(nz)){o.type="TYPE";continue}o.type="ID";continue}if(a=r.match(sNe),a){o.text=a[1],o.type="NUMBER",n+=o.text.length;continue}throw new Error(`unexpected token ${JSON.stringify(r[0])} at position ${n}`)}return new Tb(e.map(r=>Object.freeze(r)))}function S3(d,e){const t=new Set;for(;;){const s=d.peekType("KEYWORD");if(s==null||e&&!e.has(s))break;if(d.pop(),t.has(s))throw new Error(`duplicate keywords: ${JSON.stringify(s)}`);t.add(s)}return Object.freeze(t)}const aNe=new RegExp(/^(.*)\[([0-9]*)\]$/);function v3(d){const e=d.match(nz);if(Vt(e,"invalid type","type",d),d==="uint")return"uint256";if(d==="int")return"int256";if(e[2]){const t=parseInt(e[2]);Vt(t!==0&&t<=32,"invalid bytes length","type",d)}else if(e[3]){const t=parseInt(e[3]);Vt(t!==0&&t<=256&&t%8===0,"invalid numeric width","type",d)}return d}const up={},T3=Symbol.for("_ethers_internal"),O3="_ParamTypeInternal";class Lr{constructor(e,t,s,i,n,r,a,o){if(g0.add(this),FLe(e,up,"ParamType"),Object.defineProperty(this,T3,{value:O3}),r&&(r=Object.freeze(r.slice())),i==="array"){if(a==null||o==null)throw new Error("")}else if(a!=null||o!=null)throw new Error("");if(i==="tuple"){if(r==null)throw new Error("")}else if(r!=null)throw new Error("");Qo(this,{name:t,type:s,baseType:i,indexed:n,components:r,arrayLength:a,arrayChildren:o})}format(e){if(e==null&&(e="sighash"),e==="json"){const s=this.name||"";if(this.isArray()){const n=JSON.parse(this.arrayChildren.format("json"));return n.name=s,n.type+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`,JSON.stringify(n)}const i={type:this.baseType==="tuple"?"tuple":this.type,name:s};return typeof this.indexed=="boolean"&&(i.indexed=this.indexed),this.isTuple()&&(i.components=this.components.map(n=>JSON.parse(n.format(e)))),JSON.stringify(i)}let t="";return this.isArray()?(t+=this.arrayChildren.format(e),t+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`):this.isTuple()?t+="("+this.components.map(s=>s.format(e)).join(e==="full"?", ":",")+")":t+=this.type,e!=="sighash"&&(this.indexed===!0&&(t+=" indexed"),e==="full"&&this.name&&(t+=" "+this.name)),t}isArray(){return this.baseType==="array"}isTuple(){return this.baseType==="tuple"}isIndexable(){return this.indexed!=null}walk(e,t){if(this.isArray()){if(!Array.isArray(e))throw new Error("invalid array value");if(this.arrayLength!==-1&&e.length!==this.arrayLength)throw new Error("array is wrong length");const s=this;return e.map(i=>s.arrayChildren.walk(i,t))}if(this.isTuple()){if(!Array.isArray(e))throw new Error("invalid tuple value");if(e.length!==this.components.length)throw new Error("array is wrong length");const s=this;return e.map((i,n)=>s.components[n].walk(i,t))}return t(this.type,e)}async walkAsync(e,t){const s=[],i=[e];return Ui(this,g0,"m",ez).call(this,s,e,t,n=>{i[0]=n}),s.length&&await Promise.all(s),i[0]}static from(e,t){if(Lr.isParamType(e))return e;if(typeof e=="string")try{return Lr.from(rNe(e),t)}catch{Vt(!1,"invalid param type","obj",e)}else if(e instanceof Tb){let a="",o="",c=null;S3(e,pg(["tuple"])).has("tuple")||e.peekType("OPEN_PAREN")?(o="tuple",c=e.popParams().map(m=>Lr.from(m)),a=`tuple(${c.map(m=>m.format()).join(",")})`):(a=v3(e.popType("TYPE")),o=a);let u=null,h=null;for(;e.length&&e.peekType("BRACKET");){const m=e.pop();u=new Lr(up,"",a,o,null,c,h,u),h=m.value,a+=m.text,o="array",c=null}let l=null;if(S3(e,QBe).has("indexed")){if(!t)throw new Error("");l=!0}const p=e.peekType("ID")?e.pop().text:"";if(e.length)throw new Error("leftover tokens");return new Lr(up,p,a,o,l,c,h,u)}const s=e.name;Vt(!s||typeof s=="string"&&s.match(nNe),"invalid name","obj.name",s);let i=e.indexed;i!=null&&(Vt(t,"parameter cannot be indexed","obj.indexed",e.indexed),i=!!i);let n=e.type,r=n.match(aNe);if(r){const a=parseInt(r[2]||"-1"),o=Lr.from({type:r[1],components:e.components});return new Lr(up,s||"",n,"array",i,null,a,o)}if(n==="tuple"||n.startsWith("tuple(")||n.startsWith("(")){const a=e.components!=null?e.components.map(c=>Lr.from(c)):null;return new Lr(up,s||"",n,"tuple",i,a,null,null)}return n=v3(e.type),new Lr(up,s||"",n,n,i,null,null,null)}static isParamType(e){return e&&e[T3]===O3}}g0=new WeakSet,ez=function d(e,t,s,i){if(this.isArray()){if(!Array.isArray(t))throw new Error("invalid array value");if(this.arrayLength!==-1&&t.length!==this.arrayLength)throw new Error("array is wrong length");const r=this.arrayChildren,a=t.slice();a.forEach((o,c)=>{Ui(r,g0,"m",d).call(r,e,o,s,u=>{a[c]=u})}),i(a);return}if(this.isTuple()){const r=this.components;let a;if(Array.isArray(t))a=t.slice();else{if(t==null||typeof t!="object")throw new Error("invalid tuple value");a=r.map(o=>{if(!o.name)throw new Error("cannot use object value with unnamed components");if(!(o.name in t))throw new Error(`missing value for component ${o.name}`);return t[o.name]})}if(a.length!==this.components.length)throw new Error("array is wrong length");a.forEach((o,c)=>{var u;Ui(u=r[c],g0,"m",d).call(u,e,o,s,h=>{a[c]=h})}),i(a);return}const n=s(this.type,t);n.then?e.push(async function(){i(await n)}()):i(n)};var y0=function(d,e,t,s){if(t==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?d!==e||!s:!e.has(d))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?s:t==="a"?s.call(d):s?s.value:e.get(d)},Ml,v1;const Yd=new Map;Yd.set(0,"GENERIC_PANIC");Yd.set(1,"ASSERT_FALSE");Yd.set(17,"OVERFLOW");Yd.set(18,"DIVIDE_BY_ZERO");Yd.set(33,"ENUM_RANGE_ERROR");Yd.set(34,"BAD_STORAGE_DATA");Yd.set(49,"STACK_UNDERFLOW");Yd.set(50,"ARRAY_RANGE_ERROR");Yd.set(65,"OUT_OF_MEMORY");Yd.set(81,"UNINITIALIZED_FUNCTION_CALL");const oNe=new RegExp(/^bytes([0-9]*)$/),dNe=new RegExp(/^(u?int)([0-9]*)$/);let hC=null,x3=1024;class PB{constructor(){Ml.add(this)}getDefaultValue(e){const t=e.map(i=>y0(this,Ml,"m",v1).call(this,Lr.from(i)));return new k1(t,"_").defaultValue()}encode(e,t){D7(t.length,e.length,"types/values length mismatch");const s=e.map(r=>y0(this,Ml,"m",v1).call(this,Lr.from(r))),i=new k1(s,"_"),n=new N2;return i.encode(n,t),n.data}decode(e,t,s){const i=e.map(r=>y0(this,Ml,"m",v1).call(this,Lr.from(r)));return new k1(i,"_").decode(new OB(t,s,x3))}static _setDefaultMaxInflation(e){Vt(typeof e=="number"&&Number.isInteger(e),"invalid defaultMaxInflation factor","value",e),x3=e}static defaultAbiCoder(){return hC==null&&(hC=new PB),hC}}Ml=new WeakSet,v1=function d(e){if(e.isArray())return new qBe(y0(this,Ml,"m",d).call(this,e.arrayChildren),e.arrayLength,e.name);if(e.isTuple())return new k1(e.components.map(s=>y0(this,Ml,"m",d).call(this,s)),e.name);switch(e.baseType){case"address":return new RBe(e.name);case"bool":return new VBe(e.name);case"string":return new KBe(e.name);case"bytes":return new FBe(e.name);case"":return new UBe(e.name)}let t=e.type.match(dNe);if(t){let s=parseInt(t[2]||"256");return Vt(s!==0&&s<=256&&s%8===0,"invalid "+t[1]+" bit length","param",e),new $Be(s/8,t[1]==="int",e.name)}if(t=e.type.match(oNe),t){let s=parseInt(t[1]);return Vt(s!==0&&s<=32,"invalid bytes length","param",e),new HBe(s,e.name)}Vt(!1,"invalid type","type",e.type)};const cNe=PB.defaultAbiCoder();var lC=function(d,e,t,s,i){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?d!==e||!i:!e.has(d))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?i.call(d,t):i?i.value=t:e.set(d,t),t},kc=function(d,e,t,s){if(t==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?d!==e||!s:!e.has(d))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?s:t==="a"?s.call(d):s?s.value:e.get(d)},R2,T1,Zu,qy,rz;const{base16ToBinary:uNe}=ZO,az=new Uint8Array(32);az.fill(0);const hNe=BigInt(-1),oz=BigInt(0),dz=BigInt(1),lNe=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function fNe(d){const e=jh(d),t=e.length%32;return t?of([e,az.slice(t)]):au(e)}const pNe=tx(dz,32),mNe=tx(oz,32),P3={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},fC=["name","version","chainId","verifyingContract","salt"];function I3(d){return function(e){return Vt(typeof e=="string",`invalid domain value for ${JSON.stringify(d)}`,`domain.${d}`,e),e}}const gNe={name:I3("name"),version:I3("version"),chainId:function(d){const e=Pf(d,"domain.chainId");return Vt(e>=0,"invalid chain ID","domain.chainId",d),Number.isSafeInteger(e)?Number(e):zLe(e)},verifyingContract:function(d){try{return $v(d).toLowerCase()}catch{}Vt(!1,'invalid domain value "verifyingContract"',"domain.verifyingContract",d)},salt:function(d){const e=jh(d,"domain.salt");return Vt(e.length===32,'invalid domain value "salt"',"domain.salt",d),au(e)}};function D2(d){{const e=d.match(/^(u?)int(\d*)$/);if(e){const t=e[1]==="",s=parseInt(e[2]||"256");Vt(s%8===0&&s!==0&&s<=256&&(e[2]==null||e[2]===String(s)),"invalid numeric width","type",d);const i=Ry(lNe,t?s-1:s),n=t?(i+dz)*hNe:oz;return function(r){const a=Pf(r,"value");return Vt(a>=n&&a<=i,`value out-of-bounds for ${d}`,"value",a),tx(t?V7(a,256):a,32)}}}{const e=d.match(/^bytes(\d+)$/);if(e){const t=parseInt(e[1]);return Vt(t!==0&&t<=32&&e[1]===String(t),"invalid bytes width","type",d),function(s){const i=jh(s);return Vt(i.length===t,`invalid length for ${d}`,"value",s),fNe(s)}}}switch(d){case"address":return function(e){return ULe($v(e),32)};case"bool":return function(e){return e?pNe:mNe};case"bytes":return function(e){return lm(e)};case"string":return function(e){return K7(e)}}return null}function C3(d,e){return`${d}(${e.map(({name:t,type:s})=>s+" "+t).join(",")})`}class Wa{constructor(e){R2.add(this),T1.set(this,void 0),Zu.set(this,void 0),qy.set(this,void 0),lC(this,T1,JSON.stringify(e),"f"),lC(this,Zu,new Map,"f"),lC(this,qy,new Map,"f");const t=new Map,s=new Map,i=new Map;Object.keys(e).forEach(a=>{t.set(a,new Set),s.set(a,[]),i.set(a,new Set)});for(const a in e){const o=new Set;for(const c of e[a]){Vt(!o.has(c.name),`duplicate variable name ${JSON.stringify(c.name)} in ${JSON.stringify(a)}`,"types",e),o.add(c.name);const u=c.type.match(/^([^\x5b]*)(\x5b|$)/)[1]||null;Vt(u!==a,`circular type reference to ${JSON.stringify(u)}`,"types",e),!D2(u)&&(Vt(s.has(u),`unknown type ${JSON.stringify(u)}`,"types",e),s.get(u).push(a),t.get(a).add(u))}}const n=Array.from(s.keys()).filter(a=>s.get(a).length===0);Vt(n.length!==0,"missing primary type","types",e),Vt(n.length===1,`ambiguous primary types or unused types: ${n.map(a=>JSON.stringify(a)).join(", ")}`,"types",e),Qo(this,{primaryType:n[0]});function r(a,o){Vt(!o.has(a),`circular type reference to ${JSON.stringify(a)}`,"types",e),o.add(a);for(const c of t.get(a))if(s.has(c)){r(c,o);for(const u of o)i.get(u).add(c)}o.delete(a)}r(this.primaryType,new Set);for(const[a,o]of i){const c=Array.from(o);c.sort(),kc(this,Zu,"f").set(a,C3(a,e[a])+c.map(u=>C3(u,e[u])).join(""))}}get types(){return JSON.parse(kc(this,T1,"f"))}getEncoder(e){let t=kc(this,qy,"f").get(e);return t||(t=kc(this,R2,"m",rz).call(this,e),kc(this,qy,"f").set(e,t)),t}encodeType(e){const t=kc(this,Zu,"f").get(e);return Vt(t,`unknown type: ${JSON.stringify(e)}`,"name",e),t}encodeData(e,t){return this.getEncoder(e)(t)}hashStruct(e,t){return lm(uNe(this.encodeData(e,t).slice(2)))}encode(e){return this.encodeData(this.primaryType,e)}hash(e){return this.hashStruct(this.primaryType,e)}_visit(e,t,s){if(D2(e))return s(e,t);const i=e.match(/^(.*)(\x5b(\d*)\x5d)$/);if(i)return Vt(!i[3]||parseInt(i[3])===t.length,`array length mismatch; expected length ${parseInt(i[3])}`,"value",t),t.map(r=>this._visit(i[1],r,s));const n=this.types[e];if(n)return n.reduce((r,{name:a,type:o})=>(r[a]=this._visit(o,t[a],s),r),{});Vt(!1,`unknown type: ${e}`,"type",e)}visit(e,t){return this._visit(this.primaryType,e,t)}static from(e){return new Wa(e)}static getPrimaryType(e){return Wa.from(e).primaryType}static hashStruct(e,t,s){return Wa.from(t).hashStruct(e,s)}static hashDomain(e){const t=[];for(const s in e){if(e[s]==null)continue;const i=P3[s];Vt(i,`invalid typed-data domain key: ${JSON.stringify(s)}`,"domain",e),t.push({name:s,type:i})}return t.sort((s,i)=>fC.indexOf(s.name)-fC.indexOf(i.name)),Wa.hashStruct("EIP712Domain",{EIP712Domain:t},e)}static encode(e,t,s){return of(["0x1901",Wa.hashDomain(e),Wa.from(t).hash(s)])}static hash(e,t,s){return lm(Wa.encode(e,t,s))}static async resolveNames(e,t,s,i){e=Object.assign({},e);for(const a in e)e[a]==null&&delete e[a];const n={};e.verifyingContract&&!A2(e.verifyingContract,20)&&(n[e.verifyingContract]="0x");const r=Wa.from(t);r.visit(s,(a,o)=>(a==="address"&&!A2(o,20)&&(n[o]="0x"),o));for(const a in n)n[a]=await i(a);return e.verifyingContract&&n[e.verifyingContract]&&(e.verifyingContract=n[e.verifyingContract]),s=r.visit(s,(a,o)=>a==="address"&&n[o]?n[o]:o),{domain:e,value:s}}static getPayload(e,t,s){Wa.hashDomain(e);const i={},n=[];fC.forEach(o=>{const c=e[o];c!=null&&(i[o]=gNe[o](c),n.push({name:o,type:P3[o]}))});const r=Wa.from(t),a=Object.assign({},t);return Vt(a.EIP712Domain==null,"types must not contain EIP712Domain type","types.EIP712Domain",t),a.EIP712Domain=n,r.encode(s),{types:a,domain:i,primaryType:r.primaryType,message:r.visit(s,(o,c)=>{if(o.match(/^bytes(\d*)/))return au(jh(c));if(o.match(/^u?int/))return Pf(c).toString();switch(o){case"address":return c.toLowerCase();case"bool":return!!c;case"string":return Vt(typeof c=="string","invalid string","value",c),c}Vt(!1,"unsupported type","type",o)})}}}T1=new WeakMap,Zu=new WeakMap,qy=new WeakMap,R2=new WeakSet,rz=function(e){{const i=D2(e);if(i)return i}const t=e.match(/^(.*)(\x5b(\d*)\x5d)$/);if(t){const i=t[1],n=this.getEncoder(i);return r=>{Vt(!t[3]||parseInt(t[3])===r.length,`array length mismatch; expected length ${parseInt(t[3])}`,"value",r);let a=r.map(n);return kc(this,Zu,"f").has(i)&&(a=a.map(lm)),lm(jh(of(a)))}}const s=this.types[e];if(s){const i=K7(kc(this,Zu,"f").get(e));return n=>{const r=s.map(({name:a,type:o})=>{const c=this.getEncoder(o)(n[a]);return kc(this,Zu,"f").has(o)?lm(c):c});return r.unshift(i),of(r)}}Vt(!1,`unknown type: ${e}`,"type",e)};class yNe{constructor(){this.i=0,this.j=0,this.S=[]}init(e){let t,s,i;for(t=0;t<256;++t)this.S[t]=t;for(s=0,t=0;t<256;++t)s=s+this.S[t]+e[t%e.length]&255,i=this.S[t],this.S[t]=this.S[s],this.S[s]=i;this.i=0,this.j=0}next(){let e;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,e=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=e,this.S[e+this.S[this.i]&255]}}function wNe(){return new yNe}let cz=256,_S,Ju=null,Mo;if(Ju==null){Ju=[],Mo=0;let d;if(typeof window<"u"&&window.crypto&&window.crypto.getRandomValues){const t=new Uint32Array(256);for(window.crypto.getRandomValues(t),d=0;d=256||Mo>=cz){window.removeEventListener?window.removeEventListener("mousemove",e,!1):window.detachEvent&&window.detachEvent("onmousemove",e);return}try{const s=t.x+t.y;Ju[Mo++]=s&255,AS+=1}catch{}};typeof window<"u"&&(window.addEventListener?window.addEventListener("mousemove",e,!1):window.attachEvent&&window.attachEvent("onmousemove",e))}function bNe(){if(_S==null){for(_S=wNe();Mot7(e,o,s);if(t===3?i=o=>e.mul(e.sqrN(o),o):t===5&&(i=o=>e.mul(e.sqrN(e.sqrN(o)),o)),d.roundsFull%2!==0)throw new Error(`Poseidon roundsFull is not even: ${d.roundsFull}`);const n=d.roundsFull+d.roundsPartial;if(!Array.isArray(d.roundConstants)||d.roundConstants.length!==n)throw new Error("Poseidon: wrong round constants");const r=d.roundConstants.map(o=>{if(!Array.isArray(o)||o.length!==d.t)throw new Error(`Poseidon wrong round constants: ${o}`);return o.map(c=>{if(typeof c!="bigint"||!e.isValid(c))throw new Error(`Poseidon wrong round constant=${c}`);return e.create(c)})});if(!Array.isArray(d.mds)||d.mds.length!==d.t)throw new Error("Poseidon: wrong MDS matrix");const a=d.mds.map(o=>{if(!Array.isArray(o)||o.length!==d.t)throw new Error(`Poseidon MDS matrix row: ${o}`);return o.map(c=>{if(typeof c!="bigint")throw new Error(`Poseidon MDS matrix value=${c}`);return e.create(c)})});return Object.freeze({...d,rounds:n,sboxFn:i,roundConstants:r,mds:a})}function SNe(d){const{t:e,Fp:t,rounds:s,sboxFn:i,reversePartialPowIdx:n}=kNe(d),r=Math.floor(d.roundsFull/2),a=n?e-1:0,o=(u,h,l)=>(u=u.map((f,p)=>t.add(f,d.roundConstants[l][p])),h?u=u.map(f=>i(f)):u[a]=i(u[a]),u=d.mds.map(f=>f.reduce((p,m,g)=>t.add(p,t.mulN(m,u[g])),t.ZERO)),u),c=function(h){if(!Array.isArray(h)||h.length!==e)throw new Error(`Poseidon: wrong values (expected array of bigints with length ${e})`);h=h.map(f=>{if(typeof f!="bigint")throw new Error(`Poseidon: wrong value=${f} (${typeof f})`);return t.create(f)});let l=0;for(let f=0;f0?t>>BigInt(e):t}function hz(d){return typeof d=="string"&&(d=pz(d),d.length&1&&(d="0"+d)),af(d)}const ix=i7({a:BigInt(1),b:BigInt("3141592653589793238462643383279502884197169399375105820974944592307816406665"),Fp:kb(BigInt("0x800000000000011000000000000000000000000000000000000000000000001")),n:Pw,nBitLength:uz,Gx:BigInt("874739451078007766457464989774322083649278607533249481151382481072868806602"),Gy:BigInt("152666792071518830868575557812948353041420400780739481342941381225525861407"),h:BigInt(1),lowS:!1,...r7(He),bits2int:M3,bits2int_modN:d=>{const e=Ki(d).toString(16);return e.length===63&&(d=hz(e+"0")),Ps(M3(d),Pw)}});function nx(d){return xs("",typeof d=="string"?hz(d):d)}function lz(d){return jd(nx(d)).padStart(64,"0")}function vNe(d,e=!1){return ix.getPublicKey(lz(d),e)}function TNe(d){const{r:e,s:t}=d;if(e<0n||e>=Wp)throw new Error(`Signature.r should be [1, ${Wp})`);const s=Wv(t,Pw);if(s<0n||s>=Wp)throw new Error(`inv(Signature.s) should be [1, ${Wp})`)}function ONe(d){const e=nx(d);if(Ki(e)>=Wp)throw new Error(`msgHash should be [0, ${Wp})`);return e}function xNe(d,e,t){const s=ix.sign(ONe(d),lz(e),t);return TNe(s),s}const{CURVE:zWe,ProjectivePoint:wy,Signature:$We,utils:KWe}=ix;function fz(d){return`0x${jd(d.subarray(1)).replace(/^0+/gm,"")}`}function pz(d){return d.replace(/^0x/i,"")}function PNe(d){const e=nx(d),t=2n**256n,s=t-Ps(t,Pw);for(let i=0;;i++){const n=NNe(vn(e,qj(BigInt(i))));if(n>=1n}return d}function gz(d,e){let t=Iw[0];return t=_3(t,d,MNe),t=_3(t,e,_Ne),fz(t.toRawBytes(!0))}const LNe=GO(250),BNe=d=>Ki(pr(d))&LNe,NNe=d=>Ki(He(d)),ENe=kb(BigInt("3618502788666131213697322783095070105623107215331596699973092056135872020481"));function RNe(d,e,t){const s=d.fromBytes(He(aB(`${e}${t}`)));return d.create(s)}const DNe=[[3,1,1],[1,-1,1],[1,1,-2]].map(d=>d.map(BigInt));function qNe(d,e){if(zO(d.Fp),!Number.isSafeInteger(d.rate)||!Number.isSafeInteger(d.capacity))throw new Error(`Wrong poseidon opts: ${d}`);const t=d.rate+d.capacity,s=d.roundsFull+d.roundsPartial,i=[];for(let r=0;r"u")throw new Error("invalid index");n[a]+=o}n=e(n)}return n[0]}function HNe(d){return new TextEncoder().encode(d)}function _l(d){return d.replace(/^0x/i,"")}function io(d){return`0x${_l(d)}`}const wz=31,bz=0n,GNe=2n**250n-1n,kz=2n**251n+17n*2n**192n+1n,UNe=256n,WNe=2n**251n-UNe,IB=(d,e)=>({min:d,max:e}),A3=IB(bz,kz-1n),jNe=IB(-(2n**127n),2n**127n-1n),zNe=IB(bz,2n**128n-1n);var L3;(function(d){d.SN_MAIN="https://alpha-mainnet.starknet.io",d.SN_SEPOLIA="https://alpha-sepolia.starknet.io"})(L3||(L3={}));var B3;(function(d){d.SN_MAIN="SN_MAIN",d.SN_SEPOLIA="SN_SEPOLIA"})(B3||(B3={}));var N3;(function(d){d.SN_MAIN="0x534e5f4d41494e",d.SN_SEPOLIA="0x534e5f5345504f4c4941"})(N3||(N3={}));var E3;(function(d){d.DECLARE="0x6465636c617265",d.DEPLOY="0x6465706c6f79",d.DEPLOY_ACCOUNT="0x6465706c6f795f6163636f756e74",d.INVOKE="0x696e766f6b65",d.L1_HANDLER="0x6c315f68616e646c6572"})(E3||(E3={}));function Js(d,e){if(!d)throw new Error(e||"Assertion failure")}function Ob(d){return/^0x[0-9a-f]*$/i.test(d)}function Sz(d){return BigInt(d)}function xb(d){return typeof d=="bigint"}function fo(d){return io(Sz(d).toString(16))}const vz=d=>/^\d+$/.test(d);function q2(d){return typeof d=="number"}function Tz(d){return typeof d=="boolean"}function $Ne(d){return io(BNe(HNe(d)).toString(16))}function KNe(d){return BigInt($Ne(d))&GNe}function rx(d){return fo(KNe(d))}var jp;(function(d){d.DEPLOY="DEPLOY",d.CALL="CALL",d.INVOKE="INVOKE"})(jp||(jp={}));var Br;(function(d){d.u8="core::integer::u8",d.u16="core::integer::u16",d.u32="core::integer::u32",d.u64="core::integer::u64",d.u128="core::integer::u128",d.u256="core::integer::u256",d.u512="core::integer::u512"})(Br||(Br={}));var pm;(function(d){d.ClassHash="core::starknet::class_hash::ClassHash",d.ContractAddress="core::starknet::contract_address::ContractAddress",d.Secp256k1Point="core::starknet::secp256k1::Secp256k1Point"})(pm||(pm={}));var R3;(function(d){d[d.function=0]="function",d[d.l1_handler=1]="l1_handler",d[d.constructor=2]="constructor"})(R3||(R3={}));var D3;(function(d){d.EXTERNAL="EXTERNAL",d.L1_HANDLER="L1_HANDLER",d.CONSTRUCTOR="CONSTRUCTOR"})(D3||(D3={}));var q3;(function(d){d.DECLARE="DECLARE",d.DEPLOY="DEPLOY",d.DEPLOY_ACCOUNT="DEPLOY_ACCOUNT",d.INVOKE="INVOKE_FUNCTION"})(q3||(q3={}));var V3;(function(d){d.NOT_RECEIVED="NOT_RECEIVED",d.RECEIVED="RECEIVED",d.ACCEPTED_ON_L2="ACCEPTED_ON_L2",d.ACCEPTED_ON_L1="ACCEPTED_ON_L1",d.REJECTED="REJECTED",d.REVERTED="REVERTED"})(V3||(V3={}));var F3;(function(d){d.NOT_RECEIVED="NOT_RECEIVED",d.RECEIVED="RECEIVED",d.ACCEPTED_ON_L2="ACCEPTED_ON_L2",d.ACCEPTED_ON_L1="ACCEPTED_ON_L1"})(F3||(F3={}));var H3;(function(d){d.REJECTED="REJECTED",d.REVERTED="REVERTED",d.SUCCEEDED="SUCCEEDED"})(H3||(H3={}));var G3;(function(d){d.PENDING="PENDING",d.ACCEPTED_ON_L1="ACCEPTED_ON_L1",d.ACCEPTED_ON_L2="ACCEPTED_ON_L2",d.REJECTED="REJECTED"})(G3||(G3={}));var U3;(function(d){d.pending="pending",d.latest="latest"})(U3||(U3={}));const di={Active:"1",Legacy:"0"};function Oz(d){return/^[\x00-\x7F]*$/.test(d)}function CB(d){return d.length<=wz}function XNe(d){return/^[0-9]*$/i.test(d)}function zd(d){return typeof d=="string"}function MB(d){return zd(d)&&!Ob(d)&&!vz(d)}const xz=d=>MB(d)&&!CB(d);function Pz(d){const e=RegExp(`[^]{1,${wz}}`,"g");return d.match(e)||[]}function Pb(d){if(!Oz(d))throw new Error(`${d} is not an ASCII string`);if(!CB(d))throw new Error(`${d} is too long`);return io(d.replace(/./g,e=>e.charCodeAt(0).toString(16)))}function Cw(d){if(!Oz(d))throw new Error(`${d} is not an ASCII string`);if(Ob(d))return _l(d).replace(/.{2}/g,e=>String.fromCharCode(parseInt(e,16)));if(XNe(d))return Cw("0X".concat(BigInt(d).toString(16)));throw new Error(`${d} is not Hex or decimal`)}function QNe(d){const e=BigInt(d.pending_word)===0n?"":Cw(fo(d.pending_word));return d.data.reduce((t,s)=>{const i=BigInt(s)===0n?"":Cw(fo(s));return t+i},"")+e}function _B(d){const e=Pz(d),t=e[e.length-1],s=e.map(Pb),[i,n]=t===void 0||t.length===31?["0x00",0]:[s.pop(),t.length];return{data:s.length===0?[]:s,pending_word:i,pending_word_len:n}}function Al(d){if(xb(d)||Number.isInteger(d))return d.toString();if(zd(d)){if(Ob(d))return BigInt(d).toString();if(MB(d)){if(!CB(d))throw new Error(`${d} is a long string > 31 chars. Please split it into an array of short strings.`);return BigInt(Pb(d)).toString()}if(vz(d))return d}if(Tz(d))return`${+d}`;throw new Error(`${d} can't be computed by felt()`)}const Vy=(1n<<128n)-1n,YNe=(1n<<256n)-1n,ZNe=0n,JNe=340282366920938463463374607431768211455n,eEe=340282366920938463463374607431768211455n,tEe=0n,sEe=0n;class Fi{constructor(...e){if(typeof e[0]=="object"&&e.length===1&&"low"in e[0]&&"high"in e[0]){const t=Fi.validateProps(e[0].low,e[0].high);this.low=t.low,this.high=t.high}else if(e.length===1){const t=Fi.validate(e[0]);this.low=t&Vy,this.high=t>>128n}else if(e.length===2){const t=Fi.validateProps(e[0],e[1]);this.low=t.low,this.high=t.high}else throw Error("Incorrect constructor parameters")}static validate(e){const t=BigInt(e);if(tYNe)throw new Error("bigNumberish is bigger than UINT_256_MAX");return t}static validateProps(e,t){const s=BigInt(e),i=BigInt(t);if(sJNe)throw new Error("low is out of range UINT_256_LOW_MIN - UINT_256_LOW_MAX");if(ieEe)throw new Error("high is out of range UINT_256_HIGH_MIN - UINT_256_HIGH_MAX");return{low:s,high:i}}static is(e){try{Fi.validate(e)}catch{return!1}return!0}static isAbiType(e){return e===Fi.abiSelector}toBigInt(){return(this.high<<128n)+this.low}toUint256HexString(){return{low:io(this.low.toString(16)),high:io(this.high.toString(16))}}toUint256DecimalString(){return{low:this.low.toString(10),high:this.high.toString(10)}}toApiRequest(){return[Al(this.low),Al(this.high)]}}Fi.abiSelector="core::integer::u256";const iEe=(1n<<512n)-1n,nEe=0n,rEe=0n;class sn{constructor(...e){if(typeof e[0]=="object"&&e.length===1&&"limb0"in e[0]&&"limb1"in e[0]&&"limb2"in e[0]&&"limb3"in e[0]){const t=sn.validateProps(e[0].limb0,e[0].limb1,e[0].limb2,e[0].limb3);this.limb0=t.limb0,this.limb1=t.limb1,this.limb2=t.limb2,this.limb3=t.limb3}else if(e.length===1){const t=sn.validate(e[0]);this.limb0=t&Vy,this.limb1=(t&Vy<<128n)>>128n,this.limb2=(t&Vy<<256n)>>256n,this.limb3=t>>384n}else if(e.length===4){const t=sn.validateProps(e[0],e[1],e[2],e[3]);this.limb0=t.limb0,this.limb1=t.limb1,this.limb2=t.limb2,this.limb3=t.limb3}else throw Error("Incorrect Uint512 constructor parameters")}static validate(e){const t=BigInt(e);if(tiEe)throw Error("bigNumberish is bigger than UINT_512_MAX.");return t}static validateProps(e,t,s,i){const n=BigInt(e),r=BigInt(t),a=BigInt(s),o=BigInt(i);return[n,r,a,o].forEach((c,u)=>{if(cVy)throw Error(`limb${u} is not in the range of a u128 number`)}),{limb0:n,limb1:r,limb2:a,limb3:o}}static is(e){try{sn.validate(e)}catch{return!1}return!0}static isAbiType(e){return e===sn.abiSelector}toBigInt(){return(this.limb3<<384n)+(this.limb2<<256n)+(this.limb1<<128n)+this.limb0}toUint512HexString(){return{limb0:io(this.limb0.toString(16)),limb1:io(this.limb1.toString(16)),limb2:io(this.limb2.toString(16)),limb3:io(this.limb3.toString(16))}}toUint512DecimalString(){return{limb0:this.limb0.toString(10),limb1:this.limb1.toString(10),limb2:this.limb2.toString(10),limb3:this.limb3.toString(10)}}toApiRequest(){return[Al(this.limb0),Al(this.limb1),Al(this.limb2),Al(this.limb3)]}}sn.abiSelector="core::integer::u512";const Km=d=>/_len$/.test(d),V2=d=>d==="felt"||d==="core::felt252",df=d=>/\*/.test(d)||d.startsWith("core::array::Array::")||d.startsWith("core::array::Span::"),If=d=>/^\(.*\)$/i.test(d),aEe=d=>/\(.*\)/i.test(d)&&d.includes(":"),ax=(d,e)=>d in e,mg=(d,e)=>d in e,AB=d=>d.startsWith("core::option::Option::"),LB=d=>d.startsWith("core::result::Result::"),Iz=d=>Object.values(Br).includes(d),Cz=d=>Object.values(pm).includes(d),BB=d=>d==="core::bool",oEe=d=>d==="core::starknet::eth_address::EthAddress",Mz=d=>d==="core::bytes_31::bytes31",NB=d=>d==="core::byte_array::byteArray.js",EB=d=>d==="core::starknet::secp256k1::Secp256k1Point",cf=d=>d.includes("::"),Mw=d=>cf(d)?d.substring(d.indexOf("<")+1,d.lastIndexOf(">")):d.replace("*","");function dEe(d){const{cairo:e}=cEe(d);if(e===void 0)throw Error("Unable to determine Cairo version");return e==="1"}function cEe(d){if(d.find(s=>s.type==="interface"))return{cairo:"1",compiler:"2"};const e=d.find(s=>s.type==="function"&&(s.inputs.length||s.outputs.length));if(!e)return{cairo:void 0,compiler:void 0};const t=e.inputs.length?e.inputs:e.outputs;return cf(t[0].type)?{cairo:"1",compiler:"1"}:{cairo:"0",compiler:"0"}}const W3=d=>new Fi(d).toUint256DecimalString();function No(d){return Al(d)}class _z{constructor(e){const t=Object.values(e);if(t.length===0)throw new Error("This Enum must have at least 1 variant");if(t.filter(i=>typeof i<"u").length!==1)throw new Error("This Enum must have exactly one active variant");this.variant=e}unwrap(){const t=Object.entries(this.variant).find(s=>typeof s[1]<"u");if(!(typeof t>"u"))return t[1]}activeVariant(){const t=Object.entries(this.variant).find(s=>typeof s[1]<"u");return typeof t>"u"?"":t[0]}}var ga;(function(d){d[d.Some=0]="Some",d[d.None=1]="None"})(ga||(ga={}));class F2{constructor(e,t){if(!(e in ga))throw new Error("Wrong variant : should be CairoOptionVariant.Some or .None.");if(e===ga.Some){if(typeof t>"u")throw new Error('The creation of a Cairo Option with "Some" variant needs a content as input.');this.Some=t,this.None=void 0}else this.Some=void 0,this.None=!0}unwrap(){if(!this.None)return this.Some}isSome(){return!(typeof this.Some>"u")}isNone(){return this.None===!0}}var mr;(function(d){d[d.Ok=0]="Ok",d[d.Err=1]="Err"})(mr||(mr={}));class H2{constructor(e,t){if(!(e in mr))throw new Error("Wrong variant : should be CairoResultVariant.Ok or .Err.");e===mr.Ok?(this.Ok=t,this.Err=void 0):(this.Ok=void 0,this.Err=t)}unwrap(){if(typeof this.Ok<"u")return this.Ok;if(typeof this.Err<"u")return this.Err;throw new Error("Both Result.Ok and .Err are undefined. Not authorized.")}isOk(){return!(typeof this.Ok>"u")}isErr(){return!(typeof this.Err>"u")}}const pC={isBN:(d,e,t)=>{if(!xb(d[t]))throw new Error(`Data and formatter mismatch on ${t}:${e[t]}, expected response data ${t}:${d[t]} to be BN instead it is ${typeof d[t]}`)},unknown:(d,e,t)=>{throw new Error(`Unhandled formatter type on ${t}:${e[t]} for data ${t}:${d[t]}`)}};function O1(d,e,t){return Object.entries(d).reduce((s,[i,n])=>{const r=t??e[i];if(!(i in e)&&!t)return s[i]=n,s;if(r==="string"){if(Array.isArray(d[i])){const a=O1(d[i],d[i].map(o=>r));return s[i]=Object.values(a).join(""),s}return pC.isBN(d,e,i),s[i]=Cw(n),s}if(r==="number")return pC.isBN(d,e,i),s[i]=Number(n),s;if(typeof r=="function")return s[i]=r(n),s;if(Array.isArray(r)){const a=O1(d[i],r,r[0]);return s[i]=Object.values(a),s}return typeof r=="object"?(s[i]=O1(d[i],r),s):(pC.unknown(d,e,i),s)},{})}class uEe{constructor(e){this.abi=e}methodInputsLength(e){return e.inputs.reduce((t,s)=>Km(s.name)?t:t+1,0)}getMethod(e){return this.abi.find(t=>t.name===e)}getLegacyFormat(){return this.abi}}class hEe{constructor(e){this.abi=e}methodInputsLength(e){return e.inputs.length}getMethod(e){return this.abi.find(s=>s.type==="interface").items.find(s=>s.name===e)}getLegacyFormat(){return this.abi.flatMap(e=>e.type==="interface"?e.items:e)}}function lEe(d){const e=fEe(d);if(e===0||e===1)return new uEe(d);if(e===2)return new hEe(d);throw Error(`Unsupported ABI version ${e}`)}function fEe(d){return d.find(e=>e.type==="interface")?2:dEe(d)?1:0}function j3(d,e,t){return d==="constructor"&&!t&&!e.length}function pEe(d){const e=d.substring(0,d.indexOf(":")),t=d.substring(e.length+1);return{name:e,type:t}}function mEe(d){if(!d.includes("("))return{subTuple:[],result:d};const e=[];let t="",s=0;for(;st.length?n.replace(" ",t.shift()):n);return aEe(d)&&(i=i.reduce((n,r)=>n.concat(pEe(r)),[])),i}function z3(d,e,t){for(let s=0,i=0;s")+1;break}default:{const n=e.indexOf(",",s);i=n!==-1?n:Number.POSITIVE_INFINITY}}t.push(e.slice(s,i)),s=i+2}return t}function RB(d){return cf(d)?yEe(d):gEe(d)}function wEe(d){return Error(`Your object includes the property : ${d}, containing an Uint256 object without the 'low' and 'high' keys.`)}function bEe(d){return Error(`Your object includes the property : ${d}, containing an Uint512 object without the 'limb0' to 'limb3' keys.`)}function kEe(d,e,t,s){const i=(u,h)=>{if(df(h))return r(u,h);if(mg(h,s)){const l=s[h];return o(u,l)}if(If(h))return a(u,h);if(oEe(h)||NB(h)||EB(h))return u;if(Fi.isAbiType(h)){const l=u;if(typeof l!="object")return l;if(!("low"in l&&"high"in l))throw wEe(h);return{low:l.low,high:l.high}}if(sn.isAbiType(h)){const l=u;if(typeof l!="object")return l;if(!["limb0","limb1","limb2","limb3"].every(f=>f in l))throw bEe(h);return{limb0:l.limb0,limb1:l.limb1,limb2:l.limb2,limb3:l.limb3}}if(ax(h,t)){const l=t[h].members;return n(u,l)}return u},n=(u,h)=>h.reduce((f,p)=>{const m=g=>Object.defineProperty(f,p.name,{enumerable:!0,value:g??u[p.name]});if(u[p.name]==="undefined"&&(cf(p.type)||!Km(p.name)))throw Error(`Your object needs a property with key : ${p.name} .`);return m(i(u[p.name],p.type)),f},{});function r(u,h){const l=Mw(h);return zd(u)?u:u.map(f=>i(f,l))}function a(u,h){return RB(h).reduce((p,m,g)=>{const y=Object.keys(u),w=S=>Object.defineProperty(p,g.toString(),{enumerable:!0,value:S??u[y[g]]}),b=m!=null&&m.type?m.type:m;return w(i(u[y[g]],b)),p},{})}const o=(u,h)=>{if(LB(h.name)){const m=u,g=h.name.substring(h.name.indexOf("<")+1,h.name.lastIndexOf(",")),y=h.name.substring(h.name.indexOf(",")+1,h.name.lastIndexOf(">"));return m.isOk()?new H2(mr.Ok,i(u.unwrap(),g)):new H2(mr.Err,i(u.unwrap(),y))}if(AB(h.name)){const m=u,g=h.name.substring(h.name.indexOf("<")+1,h.name.lastIndexOf(">"));return m.isSome()?new F2(ga.Some,i(m.unwrap(),g)):new F2(ga.None,{})}const l=u,p=Object.entries(l.variant).map(m=>{if(typeof m[1]>"u")return m;const g=h.type.substring(h.type.lastIndexOf("<")+1,h.type.lastIndexOf(">"));return g==="()"?m:[m[0],i(l.unwrap(),g)]});return new _z(Object.fromEntries(p))};return e.reduce((u,h)=>{const l=f=>Object.defineProperty(u,h.name,{enumerable:!0,value:f});return Km(h.name)&&!cf(h.type)||l(i(d[h.name],h.type)),u},{})}function Xv(d,e){switch(!0){case Fi.isAbiType(d):return new Fi(e).toApiRequest();case sn.isAbiType(d):return new sn(e).toApiRequest();case Mz(d):return Pb(e.toString());case EB(d):{const t=_l(fo(e)).padStart(128,"0"),s=W3(io(t.slice(-64))),i=W3(io(t.slice(0,-64)));return[No(i.low),No(i.high),No(s.low),No(s.high)]}default:return No(e)}}function SEe(d,e){const t=RB(e),s=Object.values(d);if(s.length!==t.length)throw Error(`ParseTuple: provided and expected abi tuple size do not match. provided: ${s} - expected: ${t}`);return t.map((i,n)=>({element:s[n],type:i.type??i}))}function vEe(d){const e=_B(d);return[e.data.length.toString(),...e.data.map(t=>t.toString()),e.pending_word.toString(),e.pending_word_len.toString()]}function Sd(d,e,t,s){if(d===void 0)throw Error(`Missing parameter for type ${e}`);if(Array.isArray(d)){const i=[];i.push(No(d.length));const n=Mw(e);return d.reduce((r,a)=>r.concat(Sd(a,n,t,s)),i)}if(t[e]&&t[e].members.length){if(Fi.isAbiType(e))return new Fi(d).toApiRequest();if(sn.isAbiType(e))return new sn(d).toApiRequest();if(e==="core::starknet::eth_address::EthAddress")return Xv(e,d);if(e==="core::byte_array::ByteArray")return vEe(d);const{members:i}=t[e],n=d;return i.reduce((r,a)=>r.concat(Sd(n[a.name],a.type,t,s)),[])}if(If(e))return SEe(d,e).reduce((n,r)=>{const a=Sd(r.element,r.type,t,s);return n.concat(a)},[]);if(Fi.isAbiType(e))return new Fi(d).toApiRequest();if(sn.isAbiType(e))return new sn(d).toApiRequest();if(mg(e,s)){const{variants:i}=s[e];if(AB(e)){const h=d;if(h.isSome()){const l=i.find(m=>m.name==="Some");if(typeof l>"u")throw Error("Error in abi : Option has no 'Some' variant.");const f=l.type;if(f==="()")return ga.Some.toString();const p=Sd(h.unwrap(),f,t,s);return Array.isArray(p)?[ga.Some.toString(),...p]:[ga.Some.toString(),p]}return ga.None.toString()}if(LB(e)){const h=d;if(h.isOk()){const m=i.find(w=>w.name==="Ok");if(typeof m>"u")throw Error("Error in abi : Result has no 'Ok' variant.");const g=m.type;if(g==="()")return mr.Ok.toString();const y=Sd(h.unwrap(),g,t,s);return Array.isArray(y)?[mr.Ok.toString(),...y]:[mr.Ok.toString(),y]}const l=i.find(m=>m.name==="Err");if(typeof l>"u")throw Error("Error in abi : Result has no 'Err' variant.");const f=l.type;if(f==="()")return mr.Err.toString();const p=Sd(h.unwrap(),f,t,s);return Array.isArray(p)?[mr.Err.toString(),...p]:[mr.Err.toString(),p]}const n=d,r=n.activeVariant(),a=i.find(h=>h.name===r);if(typeof a>"u")throw Error(`Not find in abi : Enum has no '${r}' variant.`);const o=a.type,c=i.findIndex(h=>h.name===r);if(o==="()")return c.toString();const u=Sd(n.unwrap(),o,t,s);return Array.isArray(u)?[c.toString(),...u]:[c.toString(),u]}if(typeof d=="object")throw Error(`Parameter ${d} do not align with abi parameter ${e}`);return Xv(e,d)}function TEe(d,e,t,s){const{name:i,type:n}=e;let{value:r}=d.next();switch(!0){case df(n):if(!Array.isArray(r)&&!MB(r))throw Error(`ABI expected parameter ${i} to be array or long string, got ${r}`);return zd(r)&&(r=Pz(r)),Sd(r,e.type,t,s);case n==="core::starknet::eth_address::EthAddress":return Xv(n,r);case(ax(n,t)||If(n)||Fi.isAbiType(n)||Fi.isAbiType(n)):return Sd(r,n,t,s);case mg(n,s):return Sd(r,n,t,s);default:return Xv(n,r)}}function G2(d,e){let t;switch(!0){case BB(d):return t=e.next().value,!!BigInt(t);case Fi.isAbiType(d):const s=e.next().value,i=e.next().value;return new Fi(s,i).toBigInt();case sn.isAbiType(d):const n=e.next().value,r=e.next().value,a=e.next().value,o=e.next().value;return new sn(n,r,a,o).toBigInt();case d==="core::starknet::eth_address::EthAddress":return t=e.next().value,BigInt(t);case d==="core::bytes_31::bytes31":return t=e.next().value,Cw(t);case EB(d):const c=_l(e.next().value).padStart(32,"0"),u=_l(e.next().value).padStart(32,"0"),h=_l(e.next().value).padStart(32,"0"),l=_l(e.next().value).padStart(32,"0");return BigInt(io(u+c+l+h));default:return t=e.next().value,BigInt(t)}}function Pc(d,e,t,s){if(e.type==="()")return{};if(Fi.isAbiType(e.type)){const i=d.next().value,n=d.next().value;return new Fi(i,n).toBigInt()}if(sn.isAbiType(e.type)){const i=d.next().value,n=d.next().value,r=d.next().value,a=d.next().value;return new sn(i,n,r,a).toBigInt()}if(NB(e.type)){const i=[],n=BigInt(d.next().value);for(;i.length(i[n.name]=Pc(d,n,t,s),i),{});if(s&&e.type in s&&s[e.type]){const i=Number(d.next().value),n=s[e.type].variants.reduce((a,o,c)=>c===i?(a[o.name]=Pc(d,{name:"",type:o.type},t,s),a):(a[o.name]=void 0,a),{});if(e.type.startsWith("core::option::Option")){const a=i===ga.Some?n.Some:void 0;return new F2(i,a)}if(e.type.startsWith("core::result::Result")){let a;return i===mr.Ok?a=n.Ok:a=n.Err,new H2(i,a)}return new _z(n)}if(If(e.type))return RB(e.type).reduce((n,r,a)=>{const o=r!=null&&r.name?r.name:a,c=r!=null&&r.type?r.type:r,u={name:o,type:c};return n[o]=Pc(d,u,t,s),n},{});if(df(e.type)){const i=[],n={name:"",type:Mw(e.type)},r=BigInt(d.next().value);for(;i.length{if(Js(zd(d)||q2(d)||xb(d),`Validate: arg ${e.name} should be a felt typed as (String, Number or BigInt)`),zd(d)&&!Ob(d))return;const t=BigInt(d.toString(10));Js(t>=0n&&t<=2n**252n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^252-1]`)},OEe=(d,e)=>{Js(zd(d),`Validate: arg ${e.name} should be a string.`),Js(d.length<32,`Validate: arg ${e.name} cairo typed ${e.type} should be a string of less than 32 characters.`)},xEe=(d,e)=>{Js(zd(d),`Validate: arg ${e.name} should be a string.`)},DB=(d,e)=>{q2(d)&&Js(d<=Number.MAX_SAFE_INTEGER,"Validation: Parameter is to large to be typed as Number use (BigInt or String)"),Js(zd(d)||q2(d)||xb(d)||typeof d=="object"&&"low"in d&&"high"in d||typeof d=="object"&&["limb0","limb1","limb2","limb3"].every(s=>s in d),`Validate: arg ${e.name} of cairo type ${e.type} should be type (String, Number or BigInt), but is ${typeof d} ${d}.`);let t;switch(e.type){case Br.u256:t=new Fi(d).toBigInt();break;case Br.u512:t=new sn(d).toBigInt();break;default:t=Sz(d)}switch(e.type){case Br.u8:Js(t>=0n&&t<=255n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0 - 255]`);break;case Br.u16:Js(t>=0n&&t<=65535n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 65535]`);break;case Br.u32:Js(t>=0n&&t<=4294967295n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 4294967295]`);break;case Br.u64:Js(t>=0n&&t<=2n**64n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^64-1]`);break;case Br.u128:Js(t>=0n&&t<=2n**128n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^128-1]`);break;case Br.u256:Js(t>=0n&&t<=2n**256n-1n,`Validate: arg ${e.name} is ${e.type} 0 - 2^256-1`);break;case Br.u512:Js(sn.is(t),`Validate: arg ${e.name} is ${e.type} 0 - 2^512-1`);break;case pm.ClassHash:Js(t>=0n&&t<=2n**252n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^252-1]`);break;case pm.ContractAddress:Js(t>=0n&&t<=2n**252n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^252-1]`);break;case pm.Secp256k1Point:{Js(t>=0n&&t<=2n**512n-1n,`Validate: arg ${e.name} must be ${e.type} : a 512 bits number.`);break}}},Lz=(d,e)=>{Js(Tz(d),`Validate: arg ${e.name} of cairo type ${e.type} should be type (Boolean)`)},Bz=(d,e,t)=>{if(e.type===Br.u256||e.type===Br.u512){DB(d,e);return}if(e.type==="core::starknet::eth_address::EthAddress"){Js(typeof d!="object",`EthAddress type is waiting a BigNumberish. Got ${d}`);const s=BigInt(d.toString(10));Js(s>=0n&&s<=2n**160n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^160-1]`);return}Js(typeof d=="object"&&!Array.isArray(d),`Validate: arg ${e.name} is cairo type struct (${e.type}), and should be defined as js object (not array)`),t[e.type].members.forEach(({name:s})=>{Js(Object.keys(d).includes(s),`Validate: arg ${e.name} should have a property ${s}`)})},Nz=(d,e)=>{Js(typeof d=="object"&&!Array.isArray(d),`Validate: arg ${e.name} is cairo type Enum (${e.type}), and should be defined as js object (not array)`);const t=Object.getOwnPropertyNames(Object.getPrototypeOf(d)),s=[...Object.getOwnPropertyNames(d),...t];if(!(AB(e.type)&&s.includes("isSome")&&s.includes("isNone"))&&!(LB(e.type)&&s.includes("isOk")&&s.includes("isErr"))&&!(s.includes("variant")&&s.includes("activeVariant")))throw new Error(`Validate Enum: argument ${e.name}, type ${e.type}, value received ${d}, is not an Enum.`)},Ez=(d,e)=>{Js(typeof d=="object"&&!Array.isArray(d),`Validate: arg ${e.name} should be a tuple (defined as object)`)},Rz=(d,e,t,s)=>{const i=Mw(e.type);if(!(V2(i)&&xz(d)))switch(Js(Array.isArray(d),`Validate: arg ${e.name} should be an Array`),!0){case V2(i):d.forEach(n=>Az(n,e));break;case If(i):d.forEach(n=>Ez(n,{name:e.name,type:i}));break;case df(i):d.forEach(n=>Rz(n,{name:"",type:i},t,s));break;case ax(i,t):d.forEach(n=>Bz(n,{name:e.name,type:i},t));break;case mg(i,s):d.forEach(n=>Nz(n,{name:e.name,type:i}));break;case(Iz(i)||Cz(i)):d.forEach(n=>DB(n,{name:"",type:i}));break;case BB(i):d.forEach(n=>Lz(n,e));break;default:throw new Error(`Validate Unhandled: argument ${e.name}, type ${e.type}, value ${d}`)}};function K3(d,e,t,s){d.inputs.reduce((i,n)=>{const r=e[i];switch(!0){case Km(n.name):return i;case V2(n.type):Az(r,n);break;case Mz(n.type):OEe(r,n);break;case(Iz(n.type)||Cz(n.type)):DB(r,n);break;case BB(n.type):Lz(r,n);break;case NB(n.type):xEe(r,n);break;case df(n.type):Rz(r,n,t,s);break;case ax(n.type,t):Bz(r,n,t);break;case mg(n.type,s):Nz(r,n);break;case If(n.type):Ez(r,n);break;default:throw new Error(`Validate Unhandled: argument ${n.name}, type ${n.type}, value ${r}`)}return i+1},0)}class eh{constructor(e){this.structs=eh.getAbiStruct(e),this.enums=eh.getAbiEnum(e),this.parser=lEe(e),this.abi=this.parser.getLegacyFormat()}validate(e,t,s=[]){if(e!==jp.DEPLOY){const r=this.abi.filter(a=>{if(a.type!=="function")return!1;const o=a.stateMutability==="view"||a.state_mutability==="view";return e===jp.INVOKE?!o:o}).map(a=>a.name);Js(r.includes(t),`${e===jp.INVOKE?"invocable":"viewable"} method not found in abi`)}const i=this.abi.find(r=>e===jp.DEPLOY?r.name===t&&r.type==="constructor":r.name===t&&r.type==="function");if(j3(t,s,i))return;const n=this.parser.methodInputsLength(i);if(s.length!==n)throw Error(`Invalid number of arguments, expected ${n} arguments, but got ${s.length}`);K3(i,s,this.structs,this.enums)}compile(e,t){const s=this.abi.find(a=>a.name===e);if(j3(e,t,s))return[];let i;if(Array.isArray(t))i=t;else{const a=kEe(t,s.inputs,this.structs,this.enums);i=Object.values(a),K3(s,i,this.structs,this.enums)}const n=i[Symbol.iterator](),r=s.inputs.reduce((a,o)=>Km(o.name)&&!cf(o.type)?a:a.concat(TEe(n,o,this.structs,this.enums)),[]);return Object.defineProperty(r,"__compiled__",{enumerable:!1,writable:!1,value:!0}),r}static compile(e){const t=i=>{const n=(a,o=".")=>{const c=Array.isArray(a)?[a.length.toString(),...a]:a;return Object.entries(c).flatMap(([u,h])=>{let l=h;u==="entrypoint"?l=rx(l):xz(l)&&(l=_B(l));const f=Array.isArray(c)&&u==="0"?"$$len":u;if(xb(l))return[[`${o}${f}`,No(l)]];if(Object(l)===l){const p=Object.getOwnPropertyNames(Object.getPrototypeOf(l)),m=[...Object.getOwnPropertyNames(l),...p];if(m.includes("isSome")&&m.includes("isNone")){const g=l,y=g.isSome()?ga.Some:ga.None;return g.isSome()?n({0:y,1:g.unwrap()},`${o}${f}.`):[[`${o}${f}`,No(y)]]}if(m.includes("isOk")&&m.includes("isErr")){const g=l,y=g.isOk()?mr.Ok:mr.Err;return n({0:y,1:g.unwrap()},`${o}${f}.`)}if(m.includes("variant")&&m.includes("activeVariant")){const g=l,y=g.activeVariant(),b=Object.keys(g.variant).findIndex(S=>S===y);return typeof g.unwrap()=="object"&&Object.keys(g.unwrap()).length===0?[[`${o}${f}`,No(b)]]:n({0:b,1:g.unwrap()},`${o}${f}.`)}return n(l,`${o}${f}.`)}return[[`${o}${f}`,No(l)]]})};return Object.fromEntries(n(i))};let s;if(Array.isArray(e)){const i={...e},n=t(i);s=Object.values(n)}else{const i=t(e);s=Object.values(i)}return Object.defineProperty(s,"__compiled__",{enumerable:!1,writable:!1,value:!0}),s}parse(e,t){const{outputs:s}=this.abi.find(r=>r.name===e),i=t.flat()[Symbol.iterator](),n=s.flat().reduce((r,a,o)=>{const c=a.name??o;return r[c]=$3(i,a,this.structs,this.enums,r),r[c]&&r[`${c}_len`]&&delete r[`${c}_len`],r},{});return Object.keys(n).length===1&&0 in n?n[0]:n}format(e,t,s){const i=this.parse(e,t);return O1(i,s)}static getAbiStruct(e){return e.filter(t=>t.type==="struct").reduce((t,s)=>({...t,[s.name]:s}),{})}static getAbiEnum(e){const t=e.filter(s=>s.type==="enum").reduce((s,i)=>({...s,[i.name]:i}),{});return delete t["core::bool"],t}static toCalldata(e=[]){return eh.compile(e)}static toHex(e=[]){return eh.compile(e).map(s=>fo(s))}decodeParameters(e,t){const s=Array.isArray(e)?e:[e],i=t.flat()[Symbol.iterator](),n=s.map(r=>$3(i,{name:"",type:r},this.structs,this.enums));return n.length===1?n[0]:n}}function U2(d,e){return gz(BigInt(d),BigInt(e))}function PEe(d,e){return fo(VNe(BigInt(d),BigInt(e)))}function W2(d){return[...d,d.length].reduce((e,t)=>gz(BigInt(e),BigInt(t)),0).toString()}const IEe=W2;function CEe(d){return fo(FNe(d.map(e=>BigInt(e))))}function MEe(d,e,t,s){const i=eh.compile(t),n=W2(i),r=No("0x535441524b4e45545f434f4e54524143545f41444452455353"),a=W2([r,s,d,e,n]);return fo(BigInt(a)%WNe)}class w0{constructor(e,t=U2){this.branches=[],this.hashMethod=t,this.leaves=e,this.root=this.build(e)}build(e){if(e.length===1)return e[0];e.length!==this.leaves.length&&this.branches.push(e);const t=[];for(let s=0;sr>=a?1:-1);return s(i,n)}getProof(e,t=this.leaves,s=[]){const i=t.indexOf(e);if(i===-1)throw new Error("leaf not found");if(t.length===1)return s;const n=i%2===0,r=(n?t[i+1]:t[i-1])??"0x0",a=[...s,r],o=this.leaves.length===t.length?-1:this.branches.findIndex(u=>u.length===t.length),c=this.branches[o+1]??[this.root];return this.getProof(w0.hash(n?e:r,n?r:e,this.hashMethod),c,a)}}const _Ee={u256:JSON.parse('[{ "name": "low", "type": "u128" }, { "name": "high", "type": "u128" }]'),TokenAmount:JSON.parse('[{ "name": "token_address", "type": "ContractAddress" }, { "name": "amount", "type": "u256" }]'),NftId:JSON.parse('[{ "name": "collection_address", "type": "ContractAddress" }, { "name": "token_id", "type": "u256" }]')},ha={[di.Active]:{domain:"StarknetDomain",hashMethod:CEe,hashMerkleMethod:PEe,escapeTypeString:d=>`"${d}"`,presetTypes:_Ee},[di.Legacy]:{domain:"StarkNetDomain",hashMethod:IEe,hashMerkleMethod:U2,escapeTypeString:d=>d,presetTypes:{}}};function LS(d,e,{min:t,max:s}){const i=BigInt(d);Js(i>=t&&i<=s,`${i} (${e}) is out of bounds [${t}, ${s}]`)}function Dz({types:d,domain:e}){if(ha[di.Active].domain in d&&e.revision===di.Active)return di.Active;if(ha[di.Legacy].domain in d&&(e.revision??di.Legacy)===di.Legacy)return di.Legacy}function md(d){try{return fo(d)}catch{if(zd(d))return fo(Pb(d));throw new Error(`Invalid BigNumberish: ${d}`)}}function AEe(d){const e=d;return!!(e.message&&e.primaryType&&e.types&&Dz(e))}function LEe(d){return Ob(d)?d:rx(d)}function BEe(d){return d.type==="merkletree"}function qz(d,e,t=[],s="",i=di.Legacy){return e[e.length-1]==="*"?e=e.slice(0,-1):i===di.Active&&(e==="enum"?e=s:e.match(/^\(.*\)$/)&&(e=e.slice(1,-1))),t.includes(e)||!d[e]?t:[e,...d[e].reduce((n,r)=>[...n,...qz(d,r.type,n,r.contains,i).filter(a=>!n.includes(a))],[])]}function NEe(d,e){if(e.parent&&e.key){const s=d[e.parent].find(n=>n.name===e.key);if(!BEe(s))throw new Error(`${e.key} is not a merkle tree`);if(s.contains.endsWith("*"))throw new Error(`Merkle tree contain property must not be an array but was given ${e.key}`);return s.contains}return"raw"}function EEe(d,e,t=di.Legacy){const s=t===di.Active?{...d,...ha[t].presetTypes}:d,[i,...n]=qz(s,e,void 0,void 0,t),r=i?[i,...n.sort()]:[],a=ha[t].escapeTypeString;return r.map(o=>{const c=s[o].map(u=>{const h=u.type==="enum"&&t===di.Active?u.contains:u.type,l=h.match(/^\(.*\)$/)?`(${h.slice(1,-1).split(",").map(f=>f&&a(f)).join(",")})`:a(h);return`${a(u.name)}:${l}`});return`${a(o)}(${c})`}).join("")}function REe(d,e,t=di.Legacy){return rx(EEe(d,e,t))}function x1(d,e,t,s={},i=di.Legacy){if(d[e])return[e,Qv(d,e,t,i)];if(ha[i].presetTypes[e])return[e,Qv(ha[i].presetTypes,e,t,i)];if(e.endsWith("*")){const n=t.map(r=>x1(d,e.slice(0,-1),r,void 0,i)[1]);return[e,ha[i].hashMethod(n)]}switch(e){case"enum":{if(i===di.Active){const[n,r]=Object.entries(t)[0],a=d[s.parent][0],o=d[a.contains],c=o.find(l=>l.name===n),u=o.indexOf(c),h=c.type.slice(1,-1).split(",").map((l,f)=>{if(!l)return l;const p=r[f];return x1(d,l,p,void 0,i)[1]});return[e,ha[i].hashMethod([u,...h])]}return[e,md(t)]}case"merkletree":{const n=NEe(d,s),r=t.map(o=>x1(d,n,o,void 0,i)[1]),{root:a}=new w0(r,ha[i].hashMerkleMethod);return["felt",a]}case"selector":return["felt",LEe(t)];case"string":{if(i===di.Active){const n=_B(t),r=[n.data.length,...n.data,n.pending_word,n.pending_word_len];return[e,ha[i].hashMethod(r)]}return[e,md(t)]}case"i128":{if(i===di.Active){const n=BigInt(t);return LS(n,e,jNe),[e,md(n<0n?kz+n:n)]}return[e,md(t)]}case"timestamp":case"u128":return i===di.Active&&LS(t,e,zNe),[e,md(t)];case"felt":case"shortstring":return i===di.Active&&LS(md(t),e,A3),[e,md(t)];case"ClassHash":case"ContractAddress":return i===di.Active&&LS(t,e,A3),[e,md(t)];case"bool":return i===di.Active&&Js(typeof t=="boolean",`Type mismatch for ${e} ${t}`),[e,md(t)];default:{if(i===di.Active)throw new Error(`Unsupported type: ${e}`);return[e,md(t)]}}}function DEe(d,e,t,s=di.Legacy){const i=d[e]??ha[s].presetTypes[e],[n,r]=i.reduce(([a,o],c)=>{if(t[c.name]===void 0||t[c.name]===null&&c.type!=="enum")throw new Error(`Cannot encode data: missing data for '${c.name}'`);const u=t[c.name],h={parent:e,key:c.name},[l,f]=x1(d,c.type,u,h,s);return[[...a,l],[...o,f]]},[["felt"],[REe(d,e,s)]]);return[n,r]}function Qv(d,e,t,s=di.Legacy){return ha[s].hashMethod(DEe(d,e,t,s)[1])}function qEe(d,e){if(!AEe(d))throw new Error("Typed data does not match JSON schema");const t=Dz(d),{domain:s,hashMethod:i}=ha[t],n=[Pb("StarkNet Message"),Qv(d.types,s,d.domain,t),e,Qv(d.types,d.primaryType,d.message,t)];return i(n)}const{isNode:Mu,selfIsDefined:VEe,deepExtend:FEe,extend:HEe,clone:GEe,flatten:UEe,unique:WEe,indexBy:jEe,sortBy:zEe,sortBy2:$Ee,safeFloat2:KEe,groupBy:XEe,aggregate:QEe,uuid:YEe,unCamelCase:X3,precisionFromString:ZEe,Throttler:Q3,capitalize:JEe,now:eRe,decimalToPrecision:tRe,safeValue:sRe,safeValue2:iRe,safeString:nRe,safeString2:rRe,seconds:aRe,milliseconds:oRe,binaryToBase16:dRe,numberToBE:cRe,base16ToBinary:uRe,iso8601:hRe,omit:lRe,isJsonEncodedObject:fRe,safeInteger:pRe,sum:mRe,omitZero:gRe,implodeParams:yRe,extractParams:wRe,json:bRe,merge:kRe,binaryConcat:SRe,hash:vRe,ecdsa:$We,arrayConcat:TRe,encode:ORe,urlencode:xRe,hmac:PRe,numberToString:Y3,roundTimeframe:IRe,parseTimeframe:CRe,safeInteger2:MRe,safeStringLower:_Re,parse8601:ARe,yyyymmdd:LRe,safeStringUpper:BRe,safeTimestamp:NRe,binaryConcatArray:ERe,uuidv1:RRe,numberToLE:DRe,ymdhms:qRe,stringToBase64:VRe,decode:FRe,uuid22:HRe,safeIntegerProduct2:GRe,safeIntegerProduct:URe,safeStringLower2:WRe,yymmdd:jRe,base58ToBinary:zRe,binaryToBase58:$Re,safeTimestamp2:KRe,rawencode:XRe,keysort:QRe,inArray:YRe,isEmpty:ZRe,ordered:JRe,filterBy:eDe,uuid16:tDe,safeFloat:sDe,base64ToBinary:iDe,safeStringUpper2:nDe,urlencodeWithArrayRepeat:rDe,microseconds:aDe,binaryToBase64:oDe,strip:dDe,toArray:cDe,safeFloatN:uDe,safeIntegerN:hDe,safeIntegerProductN:lDe,safeTimestampN:fDe,safeValueN:pDe,safeStringN:mDe,safeStringLowerN:gDe,safeStringUpperN:yDe,urlencodeNested:wDe,urlencodeBase64:bDe,parseDate:kDe,ymd:SDe,base64ToString:vDe,crc32:TDe,packb:ODe,TRUNCATE:Z3,ROUND:mC,DECIMAL_PLACES:J3,NO_PADDING:xDe,TICK_SIZE:gC,SIGNIFICANT_DIGITS:PDe,sleep:IDe}=ZO;let Xe=class j2{constructor(e={}){this.isSandboxModeEnabled=!1,this.throttleProp=void 0,this.sleep=IDe,this.api=void 0,this.certified=!1,this.pro=!1,this.countries=void 0,this.userAgent=void 0,this.user_agent=void 0,this.userAgents={chrome:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36",chrome39:"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36",chrome100:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36"},this.headers={},this.origin="*",this.agent=void 0,this.nodeHttpModuleLoaded=!1,this.httpAgent=void 0,this.httpsAgent=void 0,this.minFundingAddressLength=1,this.substituteCommonCurrencyCodes=!0,this.quoteJsonNumbers=!0,this.number=Number,this.handleContentTypeApplicationZip=!1,this.reduceFees=!0,this.validateServerSsl=!0,this.validateClientSsl=!1,this.timeout=1e4,this.verbose=!1,this.twofa=void 0,this.balance={},this.liquidations={},this.orderbooks={},this.tickers={},this.fundingRates={},this.bidsasks={},this.orders=void 0,this.triggerOrders=void 0,this.transactions={},this.myLiquidations={},this.requiresWeb3=!1,this.requiresEddsa=!1,this.precision=void 0,this.enableLastJsonResponse=!0,this.enableLastHttpResponse=!0,this.enableLastResponseHeaders=!0,this.last_http_response=void 0,this.last_json_response=void 0,this.last_response_headers=void 0,this.last_request_headers=void 0,this.last_request_body=void 0,this.last_request_url=void 0,this.last_request_path=void 0,this.id="Exchange",this.markets=void 0,this.features=void 0,this.status=void 0,this.rateLimit=void 0,this.tokenBucket=void 0,this.throttler=void 0,this.enableRateLimit=void 0,this.httpExceptions=void 0,this.limits=void 0,this.markets_by_id=void 0,this.symbols=void 0,this.ids=void 0,this.currencies={},this.baseCurrencies=void 0,this.quoteCurrencies=void 0,this.currencies_by_id=void 0,this.codes=void 0,this.reloadingMarkets=void 0,this.marketsLoading=void 0,this.accounts=void 0,this.accountsById=void 0,this.commonCurrencies=void 0,this.hostname=void 0,this.precisionMode=void 0,this.paddingMode=void 0,this.exceptions={},this.timeframes={},this.version=void 0,this.marketsByAltname=void 0,this.name=void 0,this.targetAccount=void 0,this.stablePairs={},this.clients={},this.newUpdates=!0,this.streaming={},this.alias=!1,this.deepExtend=FEe,this.isNode=Mu,this.keys=JL,this.values=Of,this.extend=HEe,this.clone=GEe,this.flatten=UEe,this.unique=WEe,this.indexBy=jEe,this.roundTimeframe=IRe,this.sortBy=zEe,this.sortBy2=$Ee,this.groupBy=XEe,this.aggregate=QEe,this.uuid=YEe,this.unCamelCase=X3,this.precisionFromString=ZEe,this.capitalize=JEe,this.now=eRe,this.decimalToPrecision=tRe,this.safeValue=sRe,this.safeValue2=iRe,this.safeString=nRe,this.safeString2=rRe,this.safeFloat=sDe,this.safeFloat2=KEe,this.seconds=aRe,this.milliseconds=oRe,this.binaryToBase16=dRe,this.numberToBE=cRe,this.base16ToBinary=uRe,this.iso8601=hRe,this.omit=lRe,this.isJsonEncodedObject=fRe,this.safeInteger=pRe,this.sum=mRe,this.omitZero=gRe,this.implodeParams=yRe,this.extractParams=wRe,this.json=bRe,this.vwap=S7,this.merge=kRe,this.binaryConcat=SRe,this.hash=vRe,this.arrayConcat=TRe,this.encode=ORe,this.urlencode=xRe,this.hmac=PRe,this.numberToString=Y3,this.parseTimeframe=CRe,this.safeInteger2=MRe,this.safeStringLower=_Re,this.parse8601=ARe,this.yyyymmdd=LRe,this.safeStringUpper=BRe,this.safeTimestamp=NRe,this.binaryConcatArray=ERe,this.uuidv1=RRe,this.numberToLE=DRe,this.ymdhms=qRe,this.yymmdd=jRe,this.stringToBase64=VRe,this.decode=FRe,this.uuid22=HRe,this.safeIntegerProduct2=GRe,this.safeIntegerProduct=URe,this.binaryToBase58=$Re,this.base58ToBinary=zRe,this.base64ToBinary=iDe,this.safeTimestamp2=KRe,this.rawencode=XRe,this.keysort=QRe,this.inArray=YRe,this.safeStringLower2=WRe,this.safeStringUpper2=nDe,this.isEmpty=ZRe,this.ordered=JRe,this.filterBy=eDe,this.uuid16=tDe,this.urlencodeWithArrayRepeat=rDe,this.microseconds=aDe,this.binaryToBase64=oDe,this.strip=dDe,this.toArray=cDe,this.safeFloatN=uDe,this.safeIntegerN=hDe,this.safeIntegerProductN=lDe,this.safeTimestampN=fDe,this.safeValueN=pDe,this.safeStringN=mDe,this.safeStringLowerN=gDe,this.safeStringUpperN=yDe,this.urlencodeNested=wDe,this.parseDate=kDe,this.ymd=SDe,this.base64ToString=vDe,this.crc32=TDe,this.packb=ODe,this.urlencodeBase64=bDe,this.httpProxyAgentModule=void 0,this.httpsProxyAgentModule=void 0,this.socksProxyAgentModule=void 0,this.socksProxyAgentModuleChecked=!1,this.proxyDictionaries={},this.proxiesModulesLoading=void 0,Object.assign(this,ZO),this.options=this.getDefaultOptions(),this.headers={},this.origin="*",this.minFundingAddressLength=1,this.substituteCommonCurrencyCodes=!0,this.quoteJsonNumbers=!0,this.number=Number,this.handleContentTypeApplicationZip=!1,this.reduceFees=!0,this.fetchImplementation=void 0,this.validateServerSsl=!0,this.validateClientSsl=!1,this.timeout=1e4,this.verbose=!1,this.twofa=void 0,this.apiKey=void 0,this.secret=void 0,this.uid=void 0,this.login=void 0,this.password=void 0,this.privateKey=void 0,this.walletAddress=void 0,this.token=void 0,this.balance={},this.orderbooks={},this.tickers={},this.liquidations={},this.orders=void 0,this.trades={},this.transactions={},this.ohlcvs={},this.myLiquidations={},this.myTrades=void 0,this.positions=void 0,this.requiresWeb3=!1,this.requiresEddsa=!1,this.lastRestRequestTimestamp=0,this.enableLastJsonResponse=!0,this.enableLastHttpResponse=!0,this.enableLastResponseHeaders=!0,this.last_http_response=void 0,this.last_json_response=void 0,this.last_response_headers=void 0,this.last_request_headers=void 0,this.last_request_body=void 0,this.last_request_url=void 0,this.last_request_path=void 0;const t=(r=this)=>{if(r!==null){const a=Object.getOwnPropertyNames(r);for(let o=0;of&&(s=!1),u===f&&(h>p||h===p&&l>m)&&(s=!1),!s){if(t)throw new q("Your current version of CCXT is "+j2.ccxtVersion+", a newer version "+e+" is required, please, upgrade your version of CCXT");return t}return s}initRestRateLimiter(){if(this.rateLimit===void 0)throw new Error(this.id+".rateLimit property is not configured");this.tokenBucket=this.extend({delay:.001,capacity:1,cost:1,maxCapacity:1e3,refillRate:this.rateLimit>0?1/this.rateLimit:Number.MAX_VALUE},this.tokenBucket),this.throttler=new Q3(this.tokenBucket)}throttle(e=void 0){return this.throttler.throttle(e)}defineRestApiEndpoint(e,t,s,i,n,r,a={}){const o=n.split(/[^a-zA-Z0-9]/),c=o.map(this.capitalize).join(""),u=o.map(y=>y.trim().toLowerCase()).filter(y=>y.length>0).join("_"),h=[r[0]].concat(r.slice(1).map(this.capitalize)).join(""),l=[r[0]].concat(r.slice(1).map(y=>y.trim()).filter(y=>y.length>0)).join("_"),f=h+i+this.capitalize(c),p=l+"_"+s+"_"+u,m=r.length>1?r:r[0],g=async(y={},w={})=>this[e](n,m,t,y,void 0,void 0,a,w);this[f]=g,this[p]=g}defineRestApi(e,t,s=[]){const i=Object.keys(e);for(let n=0;n{try{this.httpProxyAgentModule=await Po(()=>import("./index-lYdp9a7W.js"),__vite__mapDeps([2,3,4,5])),this.httpsProxyAgentModule=await Po(()=>import("./index-D5ks1fN6.js"),__vite__mapDeps([6,3,4,5]))}catch{try{this.httpProxyAgentModule=await Po(()=>import("./empty-module-BIHI7g3E.js"),[]),this.httpsProxyAgentModule=await Po(()=>import("./empty-module-BIHI7g3E.js"),[])}catch{}}if(this.socksProxyAgentModuleChecked===!1){try{this.socksProxyAgentModule=await Po(()=>import("./empty-module-BIHI7g3E.js"),[])}catch{}this.socksProxyAgentModuleChecked=!0}})()),await this.proxiesModulesLoading}setProxyAgents(e,t,s){let i;if(!Mu&&(e||t||s))throw new q(this.id+' - proxies in browser-side projects are not supported. You have several choices: [A] Use `exchange.proxyUrl` property to redirect requests through local/remote cors-proxy server (find sample file named "sample-local-proxy-server-with-cors" in https://github.com/ccxt/ccxt/tree/master/examples/ folder, which can be used for REST requests only) [B] override `exchange.fetch` && `exchange.watch` methods to send requests through your custom proxy');if(e){if(this.httpProxyAgentModule===void 0)throw new q(this.id+" you need to load JS proxy modules with `.loadProxyModules()` method at first to use proxies");e in this.proxyDictionaries||(this.proxyDictionaries[e]=new this.httpProxyAgentModule.HttpProxyAgent(e)),i=this.proxyDictionaries[e]}else if(t){if(this.httpsProxyAgentModule===void 0)throw new q(this.id+" you need to load JS proxy modules with `.loadProxyModules()` method at first to use proxies");t in this.proxyDictionaries||(this.proxyDictionaries[t]=new this.httpsProxyAgentModule.HttpsProxyAgent(t)),i=this.proxyDictionaries[t],i.keepAlive=!0}else if(s){if(this.socksProxyAgentModule===void 0)throw new q(this.id+' - to use SOCKS proxy with ccxt, at first you need install module "npm i socks-proxy-agent" and then initialize proxies with `.loadProxyModules()` method');s in this.proxyDictionaries||(this.proxyDictionaries[s]=new this.socksProxyAgentModule.SocksProxyAgent(s)),i=this.proxyDictionaries[s]}return i}async loadHttpProxyAgent(){if(!this.httpAgent){const e=await Po(()=>import("./__vite-browser-external-v7f2oYTb.js").then(t=>t.h),[]);this.httpAgent=new e.Agent}return this.httpAgent}getHttpAgentIfNeeded(e){if(Mu&&e.substring(0,5)==="ws://"){if(this.httpAgent===void 0)throw new q(this.id+" to use proxy with non-ssl ws:// urls, at first run `await exchange.loadHttpProxyAgent()` method");return this.httpAgent}}async fetch(e,t="GET",s=void 0,i=void 0){if(Mu&&!this.nodeHttpModuleLoaded){this.nodeHttpModuleLoaded=!0;const g=await Po(()=>import("./__vite-browser-external-v7f2oYTb.js").then(y=>y.h),[]);this.httpsAgent=new g.Agent({keepAlive:!0})}s=this.extend(this.headers,s);const n=this.checkProxyUrlSettings(e,t,s,i);let r=!1;n!==void 0&&(Mu&&(s=this.extend({Origin:this.origin},s),n.substring(0,5)==="http:"&&(await this.loadHttpProxyAgent(),r=this.httpAgent)),e=n+e);const[a,o,c]=this.checkProxySettings(e,t,s,i);this.checkConflictingProxies(a||o||c,n),Mu&&await this.loadProxyModules();const u=this.setProxyAgents(a,o,c),h=this.userAgent!==void 0?this.userAgent:this.user_agent;if(h&&Mu&&(typeof h=="string"?s=this.extend({"User-Agent":h},s):typeof h=="object"&&"User-Agent"in h&&(s=this.extend(h,s))),s=this.setHeaders(s),this.verbose&&this.log(`fetch Request: + expected: ${t}`);return t.map((i,n)=>({element:s[n],type:i.type??i}))}function vEe(d){const e=_B(d);return[e.data.length.toString(),...e.data.map(t=>t.toString()),e.pending_word.toString(),e.pending_word_len.toString()]}function Sd(d,e,t,s){if(d===void 0)throw Error(`Missing parameter for type ${e}`);if(Array.isArray(d)){const i=[];i.push(No(d.length));const n=Mw(e);return d.reduce((r,a)=>r.concat(Sd(a,n,t,s)),i)}if(t[e]&&t[e].members.length){if(Fi.isAbiType(e))return new Fi(d).toApiRequest();if(sn.isAbiType(e))return new sn(d).toApiRequest();if(e==="core::starknet::eth_address::EthAddress")return Xv(e,d);if(e==="core::byte_array::ByteArray")return vEe(d);const{members:i}=t[e],n=d;return i.reduce((r,a)=>r.concat(Sd(n[a.name],a.type,t,s)),[])}if(If(e))return SEe(d,e).reduce((n,r)=>{const a=Sd(r.element,r.type,t,s);return n.concat(a)},[]);if(Fi.isAbiType(e))return new Fi(d).toApiRequest();if(sn.isAbiType(e))return new sn(d).toApiRequest();if(mg(e,s)){const{variants:i}=s[e];if(AB(e)){const h=d;if(h.isSome()){const l=i.find(m=>m.name==="Some");if(typeof l>"u")throw Error("Error in abi : Option has no 'Some' variant.");const f=l.type;if(f==="()")return ga.Some.toString();const p=Sd(h.unwrap(),f,t,s);return Array.isArray(p)?[ga.Some.toString(),...p]:[ga.Some.toString(),p]}return ga.None.toString()}if(LB(e)){const h=d;if(h.isOk()){const m=i.find(w=>w.name==="Ok");if(typeof m>"u")throw Error("Error in abi : Result has no 'Ok' variant.");const g=m.type;if(g==="()")return mr.Ok.toString();const y=Sd(h.unwrap(),g,t,s);return Array.isArray(y)?[mr.Ok.toString(),...y]:[mr.Ok.toString(),y]}const l=i.find(m=>m.name==="Err");if(typeof l>"u")throw Error("Error in abi : Result has no 'Err' variant.");const f=l.type;if(f==="()")return mr.Err.toString();const p=Sd(h.unwrap(),f,t,s);return Array.isArray(p)?[mr.Err.toString(),...p]:[mr.Err.toString(),p]}const n=d,r=n.activeVariant(),a=i.find(h=>h.name===r);if(typeof a>"u")throw Error(`Not find in abi : Enum has no '${r}' variant.`);const o=a.type,c=i.findIndex(h=>h.name===r);if(o==="()")return c.toString();const u=Sd(n.unwrap(),o,t,s);return Array.isArray(u)?[c.toString(),...u]:[c.toString(),u]}if(typeof d=="object")throw Error(`Parameter ${d} do not align with abi parameter ${e}`);return Xv(e,d)}function TEe(d,e,t,s){const{name:i,type:n}=e;let{value:r}=d.next();switch(!0){case df(n):if(!Array.isArray(r)&&!MB(r))throw Error(`ABI expected parameter ${i} to be array or long string, got ${r}`);return zd(r)&&(r=Pz(r)),Sd(r,e.type,t,s);case n==="core::starknet::eth_address::EthAddress":return Xv(n,r);case(ax(n,t)||If(n)||Fi.isAbiType(n)||Fi.isAbiType(n)):return Sd(r,n,t,s);case mg(n,s):return Sd(r,n,t,s);default:return Xv(n,r)}}function G2(d,e){let t;switch(!0){case BB(d):return t=e.next().value,!!BigInt(t);case Fi.isAbiType(d):const s=e.next().value,i=e.next().value;return new Fi(s,i).toBigInt();case sn.isAbiType(d):const n=e.next().value,r=e.next().value,a=e.next().value,o=e.next().value;return new sn(n,r,a,o).toBigInt();case d==="core::starknet::eth_address::EthAddress":return t=e.next().value,BigInt(t);case d==="core::bytes_31::bytes31":return t=e.next().value,Cw(t);case EB(d):const c=_l(e.next().value).padStart(32,"0"),u=_l(e.next().value).padStart(32,"0"),h=_l(e.next().value).padStart(32,"0"),l=_l(e.next().value).padStart(32,"0");return BigInt(io(u+c+l+h));default:return t=e.next().value,BigInt(t)}}function Pc(d,e,t,s){if(e.type==="()")return{};if(Fi.isAbiType(e.type)){const i=d.next().value,n=d.next().value;return new Fi(i,n).toBigInt()}if(sn.isAbiType(e.type)){const i=d.next().value,n=d.next().value,r=d.next().value,a=d.next().value;return new sn(i,n,r,a).toBigInt()}if(NB(e.type)){const i=[],n=BigInt(d.next().value);for(;i.length(i[n.name]=Pc(d,n,t,s),i),{});if(s&&e.type in s&&s[e.type]){const i=Number(d.next().value),n=s[e.type].variants.reduce((a,o,c)=>c===i?(a[o.name]=Pc(d,{name:"",type:o.type},t,s),a):(a[o.name]=void 0,a),{});if(e.type.startsWith("core::option::Option")){const a=i===ga.Some?n.Some:void 0;return new F2(i,a)}if(e.type.startsWith("core::result::Result")){let a;return i===mr.Ok?a=n.Ok:a=n.Err,new H2(i,a)}return new _z(n)}if(If(e.type))return RB(e.type).reduce((n,r,a)=>{const o=r!=null&&r.name?r.name:a,c=r!=null&&r.type?r.type:r,u={name:o,type:c};return n[o]=Pc(d,u,t,s),n},{});if(df(e.type)){const i=[],n={name:"",type:Mw(e.type)},r=BigInt(d.next().value);for(;i.length{if(Js(zd(d)||q2(d)||xb(d),`Validate: arg ${e.name} should be a felt typed as (String, Number or BigInt)`),zd(d)&&!Ob(d))return;const t=BigInt(d.toString(10));Js(t>=0n&&t<=2n**252n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^252-1]`)},OEe=(d,e)=>{Js(zd(d),`Validate: arg ${e.name} should be a string.`),Js(d.length<32,`Validate: arg ${e.name} cairo typed ${e.type} should be a string of less than 32 characters.`)},xEe=(d,e)=>{Js(zd(d),`Validate: arg ${e.name} should be a string.`)},DB=(d,e)=>{q2(d)&&Js(d<=Number.MAX_SAFE_INTEGER,"Validation: Parameter is to large to be typed as Number use (BigInt or String)"),Js(zd(d)||q2(d)||xb(d)||typeof d=="object"&&"low"in d&&"high"in d||typeof d=="object"&&["limb0","limb1","limb2","limb3"].every(s=>s in d),`Validate: arg ${e.name} of cairo type ${e.type} should be type (String, Number or BigInt), but is ${typeof d} ${d}.`);let t;switch(e.type){case Br.u256:t=new Fi(d).toBigInt();break;case Br.u512:t=new sn(d).toBigInt();break;default:t=Sz(d)}switch(e.type){case Br.u8:Js(t>=0n&&t<=255n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0 - 255]`);break;case Br.u16:Js(t>=0n&&t<=65535n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 65535]`);break;case Br.u32:Js(t>=0n&&t<=4294967295n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 4294967295]`);break;case Br.u64:Js(t>=0n&&t<=2n**64n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^64-1]`);break;case Br.u128:Js(t>=0n&&t<=2n**128n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^128-1]`);break;case Br.u256:Js(t>=0n&&t<=2n**256n-1n,`Validate: arg ${e.name} is ${e.type} 0 - 2^256-1`);break;case Br.u512:Js(sn.is(t),`Validate: arg ${e.name} is ${e.type} 0 - 2^512-1`);break;case pm.ClassHash:Js(t>=0n&&t<=2n**252n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^252-1]`);break;case pm.ContractAddress:Js(t>=0n&&t<=2n**252n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^252-1]`);break;case pm.Secp256k1Point:{Js(t>=0n&&t<=2n**512n-1n,`Validate: arg ${e.name} must be ${e.type} : a 512 bits number.`);break}}},Lz=(d,e)=>{Js(Tz(d),`Validate: arg ${e.name} of cairo type ${e.type} should be type (Boolean)`)},Bz=(d,e,t)=>{if(e.type===Br.u256||e.type===Br.u512){DB(d,e);return}if(e.type==="core::starknet::eth_address::EthAddress"){Js(typeof d!="object",`EthAddress type is waiting a BigNumberish. Got ${d}`);const s=BigInt(d.toString(10));Js(s>=0n&&s<=2n**160n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^160-1]`);return}Js(typeof d=="object"&&!Array.isArray(d),`Validate: arg ${e.name} is cairo type struct (${e.type}), and should be defined as js object (not array)`),t[e.type].members.forEach(({name:s})=>{Js(Object.keys(d).includes(s),`Validate: arg ${e.name} should have a property ${s}`)})},Nz=(d,e)=>{Js(typeof d=="object"&&!Array.isArray(d),`Validate: arg ${e.name} is cairo type Enum (${e.type}), and should be defined as js object (not array)`);const t=Object.getOwnPropertyNames(Object.getPrototypeOf(d)),s=[...Object.getOwnPropertyNames(d),...t];if(!(AB(e.type)&&s.includes("isSome")&&s.includes("isNone"))&&!(LB(e.type)&&s.includes("isOk")&&s.includes("isErr"))&&!(s.includes("variant")&&s.includes("activeVariant")))throw new Error(`Validate Enum: argument ${e.name}, type ${e.type}, value received ${d}, is not an Enum.`)},Ez=(d,e)=>{Js(typeof d=="object"&&!Array.isArray(d),`Validate: arg ${e.name} should be a tuple (defined as object)`)},Rz=(d,e,t,s)=>{const i=Mw(e.type);if(!(V2(i)&&xz(d)))switch(Js(Array.isArray(d),`Validate: arg ${e.name} should be an Array`),!0){case V2(i):d.forEach(n=>Az(n,e));break;case If(i):d.forEach(n=>Ez(n,{name:e.name,type:i}));break;case df(i):d.forEach(n=>Rz(n,{name:"",type:i},t,s));break;case ax(i,t):d.forEach(n=>Bz(n,{name:e.name,type:i},t));break;case mg(i,s):d.forEach(n=>Nz(n,{name:e.name,type:i}));break;case(Iz(i)||Cz(i)):d.forEach(n=>DB(n,{name:"",type:i}));break;case BB(i):d.forEach(n=>Lz(n,e));break;default:throw new Error(`Validate Unhandled: argument ${e.name}, type ${e.type}, value ${d}`)}};function K3(d,e,t,s){d.inputs.reduce((i,n)=>{const r=e[i];switch(!0){case Km(n.name):return i;case V2(n.type):Az(r,n);break;case Mz(n.type):OEe(r,n);break;case(Iz(n.type)||Cz(n.type)):DB(r,n);break;case BB(n.type):Lz(r,n);break;case NB(n.type):xEe(r,n);break;case df(n.type):Rz(r,n,t,s);break;case ax(n.type,t):Bz(r,n,t);break;case mg(n.type,s):Nz(r,n);break;case If(n.type):Ez(r,n);break;default:throw new Error(`Validate Unhandled: argument ${n.name}, type ${n.type}, value ${r}`)}return i+1},0)}class eh{constructor(e){this.structs=eh.getAbiStruct(e),this.enums=eh.getAbiEnum(e),this.parser=lEe(e),this.abi=this.parser.getLegacyFormat()}validate(e,t,s=[]){if(e!==jp.DEPLOY){const r=this.abi.filter(a=>{if(a.type!=="function")return!1;const o=a.stateMutability==="view"||a.state_mutability==="view";return e===jp.INVOKE?!o:o}).map(a=>a.name);Js(r.includes(t),`${e===jp.INVOKE?"invocable":"viewable"} method not found in abi`)}const i=this.abi.find(r=>e===jp.DEPLOY?r.name===t&&r.type==="constructor":r.name===t&&r.type==="function");if(j3(t,s,i))return;const n=this.parser.methodInputsLength(i);if(s.length!==n)throw Error(`Invalid number of arguments, expected ${n} arguments, but got ${s.length}`);K3(i,s,this.structs,this.enums)}compile(e,t){const s=this.abi.find(a=>a.name===e);if(j3(e,t,s))return[];let i;if(Array.isArray(t))i=t;else{const a=kEe(t,s.inputs,this.structs,this.enums);i=Object.values(a),K3(s,i,this.structs,this.enums)}const n=i[Symbol.iterator](),r=s.inputs.reduce((a,o)=>Km(o.name)&&!cf(o.type)?a:a.concat(TEe(n,o,this.structs,this.enums)),[]);return Object.defineProperty(r,"__compiled__",{enumerable:!1,writable:!1,value:!0}),r}static compile(e){const t=i=>{const n=(a,o=".")=>{const c=Array.isArray(a)?[a.length.toString(),...a]:a;return Object.entries(c).flatMap(([u,h])=>{let l=h;u==="entrypoint"?l=rx(l):xz(l)&&(l=_B(l));const f=Array.isArray(c)&&u==="0"?"$$len":u;if(xb(l))return[[`${o}${f}`,No(l)]];if(Object(l)===l){const p=Object.getOwnPropertyNames(Object.getPrototypeOf(l)),m=[...Object.getOwnPropertyNames(l),...p];if(m.includes("isSome")&&m.includes("isNone")){const g=l,y=g.isSome()?ga.Some:ga.None;return g.isSome()?n({0:y,1:g.unwrap()},`${o}${f}.`):[[`${o}${f}`,No(y)]]}if(m.includes("isOk")&&m.includes("isErr")){const g=l,y=g.isOk()?mr.Ok:mr.Err;return n({0:y,1:g.unwrap()},`${o}${f}.`)}if(m.includes("variant")&&m.includes("activeVariant")){const g=l,y=g.activeVariant(),b=Object.keys(g.variant).findIndex(S=>S===y);return typeof g.unwrap()=="object"&&Object.keys(g.unwrap()).length===0?[[`${o}${f}`,No(b)]]:n({0:b,1:g.unwrap()},`${o}${f}.`)}return n(l,`${o}${f}.`)}return[[`${o}${f}`,No(l)]]})};return Object.fromEntries(n(i))};let s;if(Array.isArray(e)){const i={...e},n=t(i);s=Object.values(n)}else{const i=t(e);s=Object.values(i)}return Object.defineProperty(s,"__compiled__",{enumerable:!1,writable:!1,value:!0}),s}parse(e,t){const{outputs:s}=this.abi.find(r=>r.name===e),i=t.flat()[Symbol.iterator](),n=s.flat().reduce((r,a,o)=>{const c=a.name??o;return r[c]=$3(i,a,this.structs,this.enums,r),r[c]&&r[`${c}_len`]&&delete r[`${c}_len`],r},{});return Object.keys(n).length===1&&0 in n?n[0]:n}format(e,t,s){const i=this.parse(e,t);return O1(i,s)}static getAbiStruct(e){return e.filter(t=>t.type==="struct").reduce((t,s)=>({...t,[s.name]:s}),{})}static getAbiEnum(e){const t=e.filter(s=>s.type==="enum").reduce((s,i)=>({...s,[i.name]:i}),{});return delete t["core::bool"],t}static toCalldata(e=[]){return eh.compile(e)}static toHex(e=[]){return eh.compile(e).map(s=>fo(s))}decodeParameters(e,t){const s=Array.isArray(e)?e:[e],i=t.flat()[Symbol.iterator](),n=s.map(r=>$3(i,{name:"",type:r},this.structs,this.enums));return n.length===1?n[0]:n}}function U2(d,e){return gz(BigInt(d),BigInt(e))}function PEe(d,e){return fo(VNe(BigInt(d),BigInt(e)))}function W2(d){return[...d,d.length].reduce((e,t)=>gz(BigInt(e),BigInt(t)),0).toString()}const IEe=W2;function CEe(d){return fo(FNe(d.map(e=>BigInt(e))))}function MEe(d,e,t,s){const i=eh.compile(t),n=W2(i),r=No("0x535441524b4e45545f434f4e54524143545f41444452455353"),a=W2([r,s,d,e,n]);return fo(BigInt(a)%WNe)}class w0{constructor(e,t=U2){this.branches=[],this.hashMethod=t,this.leaves=e,this.root=this.build(e)}build(e){if(e.length===1)return e[0];e.length!==this.leaves.length&&this.branches.push(e);const t=[];for(let s=0;sr>=a?1:-1);return s(i,n)}getProof(e,t=this.leaves,s=[]){const i=t.indexOf(e);if(i===-1)throw new Error("leaf not found");if(t.length===1)return s;const n=i%2===0,r=(n?t[i+1]:t[i-1])??"0x0",a=[...s,r],o=this.leaves.length===t.length?-1:this.branches.findIndex(u=>u.length===t.length),c=this.branches[o+1]??[this.root];return this.getProof(w0.hash(n?e:r,n?r:e,this.hashMethod),c,a)}}const _Ee={u256:JSON.parse('[{ "name": "low", "type": "u128" }, { "name": "high", "type": "u128" }]'),TokenAmount:JSON.parse('[{ "name": "token_address", "type": "ContractAddress" }, { "name": "amount", "type": "u256" }]'),NftId:JSON.parse('[{ "name": "collection_address", "type": "ContractAddress" }, { "name": "token_id", "type": "u256" }]')},ha={[di.Active]:{domain:"StarknetDomain",hashMethod:CEe,hashMerkleMethod:PEe,escapeTypeString:d=>`"${d}"`,presetTypes:_Ee},[di.Legacy]:{domain:"StarkNetDomain",hashMethod:IEe,hashMerkleMethod:U2,escapeTypeString:d=>d,presetTypes:{}}};function LS(d,e,{min:t,max:s}){const i=BigInt(d);Js(i>=t&&i<=s,`${i} (${e}) is out of bounds [${t}, ${s}]`)}function Dz({types:d,domain:e}){if(ha[di.Active].domain in d&&e.revision===di.Active)return di.Active;if(ha[di.Legacy].domain in d&&(e.revision??di.Legacy)===di.Legacy)return di.Legacy}function md(d){try{return fo(d)}catch{if(zd(d))return fo(Pb(d));throw new Error(`Invalid BigNumberish: ${d}`)}}function AEe(d){const e=d;return!!(e.message&&e.primaryType&&e.types&&Dz(e))}function LEe(d){return Ob(d)?d:rx(d)}function BEe(d){return d.type==="merkletree"}function qz(d,e,t=[],s="",i=di.Legacy){return e[e.length-1]==="*"?e=e.slice(0,-1):i===di.Active&&(e==="enum"?e=s:e.match(/^\(.*\)$/)&&(e=e.slice(1,-1))),t.includes(e)||!d[e]?t:[e,...d[e].reduce((n,r)=>[...n,...qz(d,r.type,n,r.contains,i).filter(a=>!n.includes(a))],[])]}function NEe(d,e){if(e.parent&&e.key){const s=d[e.parent].find(n=>n.name===e.key);if(!BEe(s))throw new Error(`${e.key} is not a merkle tree`);if(s.contains.endsWith("*"))throw new Error(`Merkle tree contain property must not be an array but was given ${e.key}`);return s.contains}return"raw"}function EEe(d,e,t=di.Legacy){const s=t===di.Active?{...d,...ha[t].presetTypes}:d,[i,...n]=qz(s,e,void 0,void 0,t),r=i?[i,...n.sort()]:[],a=ha[t].escapeTypeString;return r.map(o=>{const c=s[o].map(u=>{const h=u.type==="enum"&&t===di.Active?u.contains:u.type,l=h.match(/^\(.*\)$/)?`(${h.slice(1,-1).split(",").map(f=>f&&a(f)).join(",")})`:a(h);return`${a(u.name)}:${l}`});return`${a(o)}(${c})`}).join("")}function REe(d,e,t=di.Legacy){return rx(EEe(d,e,t))}function x1(d,e,t,s={},i=di.Legacy){if(d[e])return[e,Qv(d,e,t,i)];if(ha[i].presetTypes[e])return[e,Qv(ha[i].presetTypes,e,t,i)];if(e.endsWith("*")){const n=t.map(r=>x1(d,e.slice(0,-1),r,void 0,i)[1]);return[e,ha[i].hashMethod(n)]}switch(e){case"enum":{if(i===di.Active){const[n,r]=Object.entries(t)[0],a=d[s.parent][0],o=d[a.contains],c=o.find(l=>l.name===n),u=o.indexOf(c),h=c.type.slice(1,-1).split(",").map((l,f)=>{if(!l)return l;const p=r[f];return x1(d,l,p,void 0,i)[1]});return[e,ha[i].hashMethod([u,...h])]}return[e,md(t)]}case"merkletree":{const n=NEe(d,s),r=t.map(o=>x1(d,n,o,void 0,i)[1]),{root:a}=new w0(r,ha[i].hashMerkleMethod);return["felt",a]}case"selector":return["felt",LEe(t)];case"string":{if(i===di.Active){const n=_B(t),r=[n.data.length,...n.data,n.pending_word,n.pending_word_len];return[e,ha[i].hashMethod(r)]}return[e,md(t)]}case"i128":{if(i===di.Active){const n=BigInt(t);return LS(n,e,jNe),[e,md(n<0n?kz+n:n)]}return[e,md(t)]}case"timestamp":case"u128":return i===di.Active&&LS(t,e,zNe),[e,md(t)];case"felt":case"shortstring":return i===di.Active&&LS(md(t),e,A3),[e,md(t)];case"ClassHash":case"ContractAddress":return i===di.Active&&LS(t,e,A3),[e,md(t)];case"bool":return i===di.Active&&Js(typeof t=="boolean",`Type mismatch for ${e} ${t}`),[e,md(t)];default:{if(i===di.Active)throw new Error(`Unsupported type: ${e}`);return[e,md(t)]}}}function DEe(d,e,t,s=di.Legacy){const i=d[e]??ha[s].presetTypes[e],[n,r]=i.reduce(([a,o],c)=>{if(t[c.name]===void 0||t[c.name]===null&&c.type!=="enum")throw new Error(`Cannot encode data: missing data for '${c.name}'`);const u=t[c.name],h={parent:e,key:c.name},[l,f]=x1(d,c.type,u,h,s);return[[...a,l],[...o,f]]},[["felt"],[REe(d,e,s)]]);return[n,r]}function Qv(d,e,t,s=di.Legacy){return ha[s].hashMethod(DEe(d,e,t,s)[1])}function qEe(d,e){if(!AEe(d))throw new Error("Typed data does not match JSON schema");const t=Dz(d),{domain:s,hashMethod:i}=ha[t],n=[Pb("StarkNet Message"),Qv(d.types,s,d.domain,t),e,Qv(d.types,d.primaryType,d.message,t)];return i(n)}const{isNode:Mu,selfIsDefined:VEe,deepExtend:FEe,extend:HEe,clone:GEe,flatten:UEe,unique:WEe,indexBy:jEe,sortBy:zEe,sortBy2:$Ee,safeFloat2:KEe,groupBy:XEe,aggregate:QEe,uuid:YEe,unCamelCase:X3,precisionFromString:ZEe,Throttler:Q3,capitalize:JEe,now:eRe,decimalToPrecision:tRe,safeValue:sRe,safeValue2:iRe,safeString:nRe,safeString2:rRe,seconds:aRe,milliseconds:oRe,binaryToBase16:dRe,numberToBE:cRe,base16ToBinary:uRe,iso8601:hRe,omit:lRe,isJsonEncodedObject:fRe,safeInteger:pRe,sum:mRe,omitZero:gRe,implodeParams:yRe,extractParams:wRe,json:bRe,merge:kRe,binaryConcat:SRe,hash:vRe,ecdsa:XWe,arrayConcat:TRe,encode:ORe,urlencode:xRe,hmac:PRe,numberToString:Y3,roundTimeframe:IRe,parseTimeframe:CRe,safeInteger2:MRe,safeStringLower:_Re,parse8601:ARe,yyyymmdd:LRe,safeStringUpper:BRe,safeTimestamp:NRe,binaryConcatArray:ERe,uuidv1:RRe,numberToLE:DRe,ymdhms:qRe,stringToBase64:VRe,decode:FRe,uuid22:HRe,safeIntegerProduct2:GRe,safeIntegerProduct:URe,safeStringLower2:WRe,yymmdd:jRe,base58ToBinary:zRe,binaryToBase58:$Re,safeTimestamp2:KRe,rawencode:XRe,keysort:QRe,inArray:YRe,isEmpty:ZRe,ordered:JRe,filterBy:eDe,uuid16:tDe,safeFloat:sDe,base64ToBinary:iDe,safeStringUpper2:nDe,urlencodeWithArrayRepeat:rDe,microseconds:aDe,binaryToBase64:oDe,strip:dDe,toArray:cDe,safeFloatN:uDe,safeIntegerN:hDe,safeIntegerProductN:lDe,safeTimestampN:fDe,safeValueN:pDe,safeStringN:mDe,safeStringLowerN:gDe,safeStringUpperN:yDe,urlencodeNested:wDe,urlencodeBase64:bDe,parseDate:kDe,ymd:SDe,base64ToString:vDe,crc32:TDe,packb:ODe,TRUNCATE:Z3,ROUND:mC,DECIMAL_PLACES:J3,NO_PADDING:xDe,TICK_SIZE:gC,SIGNIFICANT_DIGITS:PDe,sleep:IDe}=ZO;let Xe=class j2{constructor(e={}){this.isSandboxModeEnabled=!1,this.throttleProp=void 0,this.sleep=IDe,this.api=void 0,this.certified=!1,this.pro=!1,this.countries=void 0,this.userAgent=void 0,this.user_agent=void 0,this.userAgents={chrome:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36",chrome39:"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36",chrome100:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36"},this.headers={},this.origin="*",this.agent=void 0,this.nodeHttpModuleLoaded=!1,this.httpAgent=void 0,this.httpsAgent=void 0,this.minFundingAddressLength=1,this.substituteCommonCurrencyCodes=!0,this.quoteJsonNumbers=!0,this.number=Number,this.handleContentTypeApplicationZip=!1,this.reduceFees=!0,this.validateServerSsl=!0,this.validateClientSsl=!1,this.timeout=1e4,this.verbose=!1,this.twofa=void 0,this.balance={},this.liquidations={},this.orderbooks={},this.tickers={},this.fundingRates={},this.bidsasks={},this.orders=void 0,this.triggerOrders=void 0,this.transactions={},this.myLiquidations={},this.requiresWeb3=!1,this.requiresEddsa=!1,this.precision=void 0,this.enableLastJsonResponse=!0,this.enableLastHttpResponse=!0,this.enableLastResponseHeaders=!0,this.last_http_response=void 0,this.last_json_response=void 0,this.last_response_headers=void 0,this.last_request_headers=void 0,this.last_request_body=void 0,this.last_request_url=void 0,this.last_request_path=void 0,this.id="Exchange",this.markets=void 0,this.features=void 0,this.status=void 0,this.rateLimit=void 0,this.tokenBucket=void 0,this.throttler=void 0,this.enableRateLimit=void 0,this.httpExceptions=void 0,this.limits=void 0,this.markets_by_id=void 0,this.symbols=void 0,this.ids=void 0,this.currencies={},this.baseCurrencies=void 0,this.quoteCurrencies=void 0,this.currencies_by_id=void 0,this.codes=void 0,this.reloadingMarkets=void 0,this.marketsLoading=void 0,this.accounts=void 0,this.accountsById=void 0,this.commonCurrencies=void 0,this.hostname=void 0,this.precisionMode=void 0,this.paddingMode=void 0,this.exceptions={},this.timeframes={},this.version=void 0,this.marketsByAltname=void 0,this.name=void 0,this.targetAccount=void 0,this.stablePairs={},this.clients={},this.newUpdates=!0,this.streaming={},this.alias=!1,this.deepExtend=FEe,this.isNode=Mu,this.keys=JL,this.values=Of,this.extend=HEe,this.clone=GEe,this.flatten=UEe,this.unique=WEe,this.indexBy=jEe,this.roundTimeframe=IRe,this.sortBy=zEe,this.sortBy2=$Ee,this.groupBy=XEe,this.aggregate=QEe,this.uuid=YEe,this.unCamelCase=X3,this.precisionFromString=ZEe,this.capitalize=JEe,this.now=eRe,this.decimalToPrecision=tRe,this.safeValue=sRe,this.safeValue2=iRe,this.safeString=nRe,this.safeString2=rRe,this.safeFloat=sDe,this.safeFloat2=KEe,this.seconds=aRe,this.milliseconds=oRe,this.binaryToBase16=dRe,this.numberToBE=cRe,this.base16ToBinary=uRe,this.iso8601=hRe,this.omit=lRe,this.isJsonEncodedObject=fRe,this.safeInteger=pRe,this.sum=mRe,this.omitZero=gRe,this.implodeParams=yRe,this.extractParams=wRe,this.json=bRe,this.vwap=S7,this.merge=kRe,this.binaryConcat=SRe,this.hash=vRe,this.arrayConcat=TRe,this.encode=ORe,this.urlencode=xRe,this.hmac=PRe,this.numberToString=Y3,this.parseTimeframe=CRe,this.safeInteger2=MRe,this.safeStringLower=_Re,this.parse8601=ARe,this.yyyymmdd=LRe,this.safeStringUpper=BRe,this.safeTimestamp=NRe,this.binaryConcatArray=ERe,this.uuidv1=RRe,this.numberToLE=DRe,this.ymdhms=qRe,this.yymmdd=jRe,this.stringToBase64=VRe,this.decode=FRe,this.uuid22=HRe,this.safeIntegerProduct2=GRe,this.safeIntegerProduct=URe,this.binaryToBase58=$Re,this.base58ToBinary=zRe,this.base64ToBinary=iDe,this.safeTimestamp2=KRe,this.rawencode=XRe,this.keysort=QRe,this.inArray=YRe,this.safeStringLower2=WRe,this.safeStringUpper2=nDe,this.isEmpty=ZRe,this.ordered=JRe,this.filterBy=eDe,this.uuid16=tDe,this.urlencodeWithArrayRepeat=rDe,this.microseconds=aDe,this.binaryToBase64=oDe,this.strip=dDe,this.toArray=cDe,this.safeFloatN=uDe,this.safeIntegerN=hDe,this.safeIntegerProductN=lDe,this.safeTimestampN=fDe,this.safeValueN=pDe,this.safeStringN=mDe,this.safeStringLowerN=gDe,this.safeStringUpperN=yDe,this.urlencodeNested=wDe,this.parseDate=kDe,this.ymd=SDe,this.base64ToString=vDe,this.crc32=TDe,this.packb=ODe,this.urlencodeBase64=bDe,this.httpProxyAgentModule=void 0,this.httpsProxyAgentModule=void 0,this.socksProxyAgentModule=void 0,this.socksProxyAgentModuleChecked=!1,this.proxyDictionaries={},this.proxiesModulesLoading=void 0,Object.assign(this,ZO),this.options=this.getDefaultOptions(),this.headers={},this.origin="*",this.minFundingAddressLength=1,this.substituteCommonCurrencyCodes=!0,this.quoteJsonNumbers=!0,this.number=Number,this.handleContentTypeApplicationZip=!1,this.reduceFees=!0,this.fetchImplementation=void 0,this.validateServerSsl=!0,this.validateClientSsl=!1,this.timeout=1e4,this.verbose=!1,this.twofa=void 0,this.apiKey=void 0,this.secret=void 0,this.uid=void 0,this.login=void 0,this.password=void 0,this.privateKey=void 0,this.walletAddress=void 0,this.token=void 0,this.balance={},this.orderbooks={},this.tickers={},this.liquidations={},this.orders=void 0,this.trades={},this.transactions={},this.ohlcvs={},this.myLiquidations={},this.myTrades=void 0,this.positions=void 0,this.requiresWeb3=!1,this.requiresEddsa=!1,this.lastRestRequestTimestamp=0,this.enableLastJsonResponse=!0,this.enableLastHttpResponse=!0,this.enableLastResponseHeaders=!0,this.last_http_response=void 0,this.last_json_response=void 0,this.last_response_headers=void 0,this.last_request_headers=void 0,this.last_request_body=void 0,this.last_request_url=void 0,this.last_request_path=void 0;const t=(r=this)=>{if(r!==null){const a=Object.getOwnPropertyNames(r);for(let o=0;of&&(s=!1),u===f&&(h>p||h===p&&l>m)&&(s=!1),!s){if(t)throw new q("Your current version of CCXT is "+j2.ccxtVersion+", a newer version "+e+" is required, please, upgrade your version of CCXT");return t}return s}initRestRateLimiter(){if(this.rateLimit===void 0)throw new Error(this.id+".rateLimit property is not configured");this.tokenBucket=this.extend({delay:.001,capacity:1,cost:1,maxCapacity:1e3,refillRate:this.rateLimit>0?1/this.rateLimit:Number.MAX_VALUE},this.tokenBucket),this.throttler=new Q3(this.tokenBucket)}throttle(e=void 0){return this.throttler.throttle(e)}defineRestApiEndpoint(e,t,s,i,n,r,a={}){const o=n.split(/[^a-zA-Z0-9]/),c=o.map(this.capitalize).join(""),u=o.map(y=>y.trim().toLowerCase()).filter(y=>y.length>0).join("_"),h=[r[0]].concat(r.slice(1).map(this.capitalize)).join(""),l=[r[0]].concat(r.slice(1).map(y=>y.trim()).filter(y=>y.length>0)).join("_"),f=h+i+this.capitalize(c),p=l+"_"+s+"_"+u,m=r.length>1?r:r[0],g=async(y={},w={})=>this[e](n,m,t,y,void 0,void 0,a,w);this[f]=g,this[p]=g}defineRestApi(e,t,s=[]){const i=Object.keys(e);for(let n=0;n{try{this.httpProxyAgentModule=await Po(()=>import("./index-Dm5rXNPH.js"),__vite__mapDeps([2,3,4,5])),this.httpsProxyAgentModule=await Po(()=>import("./index-DTsNrB5y.js"),__vite__mapDeps([6,3,4,5]))}catch{try{this.httpProxyAgentModule=await Po(()=>import("./empty-module-BIHI7g3E.js"),[]),this.httpsProxyAgentModule=await Po(()=>import("./empty-module-BIHI7g3E.js"),[])}catch{}}if(this.socksProxyAgentModuleChecked===!1){try{this.socksProxyAgentModule=await Po(()=>import("./empty-module-BIHI7g3E.js"),[])}catch{}this.socksProxyAgentModuleChecked=!0}})()),await this.proxiesModulesLoading}setProxyAgents(e,t,s){let i;if(!Mu&&(e||t||s))throw new q(this.id+' - proxies in browser-side projects are not supported. You have several choices: [A] Use `exchange.proxyUrl` property to redirect requests through local/remote cors-proxy server (find sample file named "sample-local-proxy-server-with-cors" in https://github.com/ccxt/ccxt/tree/master/examples/ folder, which can be used for REST requests only) [B] override `exchange.fetch` && `exchange.watch` methods to send requests through your custom proxy');if(e){if(this.httpProxyAgentModule===void 0)throw new q(this.id+" you need to load JS proxy modules with `.loadProxyModules()` method at first to use proxies");e in this.proxyDictionaries||(this.proxyDictionaries[e]=new this.httpProxyAgentModule.HttpProxyAgent(e)),i=this.proxyDictionaries[e]}else if(t){if(this.httpsProxyAgentModule===void 0)throw new q(this.id+" you need to load JS proxy modules with `.loadProxyModules()` method at first to use proxies");t in this.proxyDictionaries||(this.proxyDictionaries[t]=new this.httpsProxyAgentModule.HttpsProxyAgent(t)),i=this.proxyDictionaries[t],i.keepAlive=!0}else if(s){if(this.socksProxyAgentModule===void 0)throw new q(this.id+' - to use SOCKS proxy with ccxt, at first you need install module "npm i socks-proxy-agent" and then initialize proxies with `.loadProxyModules()` method');s in this.proxyDictionaries||(this.proxyDictionaries[s]=new this.socksProxyAgentModule.SocksProxyAgent(s)),i=this.proxyDictionaries[s]}return i}async loadHttpProxyAgent(){if(!this.httpAgent){const e=await Po(()=>import("./__vite-browser-external-v7f2oYTb.js").then(t=>t.h),[]);this.httpAgent=new e.Agent}return this.httpAgent}getHttpAgentIfNeeded(e){if(Mu&&e.substring(0,5)==="ws://"){if(this.httpAgent===void 0)throw new q(this.id+" to use proxy with non-ssl ws:// urls, at first run `await exchange.loadHttpProxyAgent()` method");return this.httpAgent}}async fetch(e,t="GET",s=void 0,i=void 0){if(Mu&&!this.nodeHttpModuleLoaded){this.nodeHttpModuleLoaded=!0;const g=await Po(()=>import("./__vite-browser-external-v7f2oYTb.js").then(y=>y.h),[]);this.httpsAgent=new g.Agent({keepAlive:!0})}s=this.extend(this.headers,s);const n=this.checkProxyUrlSettings(e,t,s,i);let r=!1;n!==void 0&&(Mu&&(s=this.extend({Origin:this.origin},s),n.substring(0,5)==="http:"&&(await this.loadHttpProxyAgent(),r=this.httpAgent)),e=n+e);const[a,o,c]=this.checkProxySettings(e,t,s,i);this.checkConflictingProxies(a||o||c,n),Mu&&await this.loadProxyModules();const u=this.setProxyAgents(a,o,c),h=this.userAgent!==void 0?this.userAgent:this.user_agent;if(h&&Mu&&(typeof h=="string"?s=this.extend({"User-Agent":h},s):typeof h=="object"&&"User-Agent"in h&&(s=this.extend(h,s))),s=this.setHeaders(s),this.verbose&&this.log(`fetch Request: `,this.id,t,e,` RequestHeaders: `,s,` RequestBody: `,i,` -`),this.fetchImplementation===void 0)if(Mu){this.agent===void 0&&(this.agent=this.httpsAgent);try{const g=await Po(()=>import("./index-Cxn6EJsJ.js"),__vite__mapDeps([7,4,3]));this.AbortError=g.AbortError,this.fetchImplementation=g.default,this.FetchError=g.FetchError}catch{if(typeof fetch=="function")this.fetchImplementation=fetch,this.AbortError=DOMException,this.FetchError=TypeError;else throw new Error('Seems, "fetch" function is not available in your node-js version, please use latest node-js version')}}else this.fetchImplementation=VEe()?self.fetch:fetch,this.AbortError=DOMException,this.FetchError=TypeError;const l=this.fetchImplementation,f={method:t,headers:s,body:i,timeout:this.timeout};this.agent&&(f.agent=this.agent),r?f.agent=r:u&&(f.agent=u);const p=new AbortController;f.signal=p.signal;const m=setTimeout(()=>{p.abort()},this.timeout);try{const g=await l(e,f);return clearTimeout(m),this.handleRestResponse(g,e,t,s,i)}catch(g){throw g instanceof this.AbortError?new Vs(this.id+" "+t+" "+e+" request timed out ("+this.timeout+" ms)"):g instanceof this.FetchError?new qs(this.id+" "+t+" "+e+" fetch failed"):g}}parseJson(e){try{if(this.isJsonEncodedObject(e))return JSON.parse(this.onJsonResponse(e))}catch{return}}getResponseHeaders(e){const t={};return e.headers.forEach((s,i)=>{i=i.split("-").map(n=>this.capitalize(n)).join("-"),t[i]=s}),t}handleRestResponse(e,t,s="GET",i=void 0,n=void 0){const r=this.getResponseHeaders(e);if(this.handleContentTypeApplicationZip&&r["Content-Type"]==="application/zip"){const a=e.buffer();return this.enableLastResponseHeaders&&(this.last_response_headers=r),this.enableLastHttpResponse&&(this.last_http_response=a),this.verbose&&this.log(`handleRestResponse: +`),this.fetchImplementation===void 0)if(Mu){this.agent===void 0&&(this.agent=this.httpsAgent);try{const g=await Po(()=>import("./index-C9ivc5Jj.js"),__vite__mapDeps([7,4,3]));this.AbortError=g.AbortError,this.fetchImplementation=g.default,this.FetchError=g.FetchError}catch{if(typeof fetch=="function")this.fetchImplementation=fetch,this.AbortError=DOMException,this.FetchError=TypeError;else throw new Error('Seems, "fetch" function is not available in your node-js version, please use latest node-js version')}}else this.fetchImplementation=VEe()?self.fetch:fetch,this.AbortError=DOMException,this.FetchError=TypeError;const l=this.fetchImplementation,f={method:t,headers:s,body:i,timeout:this.timeout};this.agent&&(f.agent=this.agent),r?f.agent=r:u&&(f.agent=u);const p=new AbortController;f.signal=p.signal;const m=setTimeout(()=>{p.abort()},this.timeout);try{const g=await l(e,f);return clearTimeout(m),this.handleRestResponse(g,e,t,s,i)}catch(g){throw g instanceof this.AbortError?new Vs(this.id+" "+t+" "+e+" request timed out ("+this.timeout+" ms)"):g instanceof this.FetchError?new qs(this.id+" "+t+" "+e+" fetch failed"):g}}parseJson(e){try{if(this.isJsonEncodedObject(e))return JSON.parse(this.onJsonResponse(e))}catch{return}}getResponseHeaders(e){const t={};return e.headers.forEach((s,i)=>{i=i.split("-").map(n=>this.capitalize(n)).join("-"),t[i]=s}),t}handleRestResponse(e,t,s="GET",i=void 0,n=void 0){const r=this.getResponseHeaders(e);if(this.handleContentTypeApplicationZip&&r["Content-Type"]==="application/zip"){const a=e.buffer();return this.enableLastResponseHeaders&&(this.last_response_headers=r),this.enableLastHttpResponse&&(this.last_http_response=a),this.verbose&&this.log(`handleRestResponse: `,this.id,s,t,e.status,e.statusText,` ResponseHeaders: `,r,"ZIP redacted",` @@ -271,7 +271,7 @@ version: 2.9.0 `),c=this.hmac(this.encode(o),this.encode(this.secret),Xs,"hex"),u={req_id:i,timestamp:a.toString(),api_key:this.apiKey,signature:c,req_param:t},h={id:i,time:a,channel:s,event:n,payload:u};return await this.watch(e,r,h,r,i)}async subscribePrivate(e,t,s,i,n,r=!1){if(this.checkRequiredCredentials(),r){if(this.uid===void 0||this.uid.length===0)throw new G(this.id+" requires uid to subscribe");const g=[this.uid];s===void 0?s=g:s=this.arrayConcat(g,s)}const a=this.seconds(),o="subscribe",c="channel="+i+"&event="+o+"&time="+a.toString(),u=this.hmac(this.encode(c),this.encode(this.secret),Xs,"hex"),h={method:"api_key",KEY:this.apiKey,SIGN:u},l=this.requestId(),f={id:l,time:a,channel:i,event:o,auth:h};s!==void 0&&(f.payload=s);const p=this.client(e);if(!(t in p.subscriptions)){const g=l.toString();p.subscriptions[g]=t}const m=this.extend(f,n);return await this.watch(e,t,m,t,t)}}class B3e extends t${describe(){return this.deepExtend(super.describe(),{alias:!0,id:"gateio"})}}class N3e extends v9{describe(){return this.deepExtend(super.describe(),{has:{ws:!0,watchBalance:!1,watchTicker:!1,watchTickers:!1,watchBidsAsks:!0,watchTrades:!0,watchTradesForSymbols:!0,watchMyTrades:!1,watchOrders:!0,watchOrderBook:!0,watchOrderBookForSymbols:!0,watchOHLCV:!0},hostname:"api.gemini.com",urls:{api:{ws:"wss://api.gemini.com"},test:{ws:"wss://api.sandbox.gemini.com"}}})}async watchTrades(e,t=void 0,s=void 0,i={}){await this.loadMarkets();const n=this.market(e),r="trades:"+n.symbol,o={type:"subscribe",subscriptions:[{name:"l2",symbols:[n.id.toUpperCase()]}]},c="l2:"+n.symbol,u=this.urls.api.ws+"/v2/marketdata",h=await this.watch(u,r,o,c);return this.newUpdates&&(s=h.getLimit(n.symbol,s)),this.filterBySinceLimit(h,t,s,"timestamp",!0)}async watchTradesForSymbols(e,t=void 0,s=void 0,i={}){const n=await this.helperForWatchMultipleConstruct("trades",e,i);if(this.newUpdates){const r=this.safeList(n,0),a=this.safeString(r,"symbol");s=n.getLimit(a,s)}return this.filterBySinceLimit(n,t,s,"timestamp",!0)}parseWsTrade(e,t=void 0){const s=this.safeInteger(e,"timestamp"),i=this.safeString2(e,"event_id","tid"),n=this.safeString(e,"price"),r=this.safeString2(e,"quantity","amount");let a=this.safeStringLower(e,"side");if(a===void 0){const u=this.safeStringLower(e,"makerSide");u==="bid"?a="sell":u==="ask"&&(a="buy")}const o=this.safeStringLower(e,"symbol"),c=this.safeSymbol(o,t);return this.safeTrade({id:i,order:void 0,info:e,timestamp:s,datetime:this.iso8601(s),symbol:c,type:void 0,side:a,takerOrMaker:void 0,price:n,cost:void 0,amount:r,fee:void 0},t)}handleTrade(e,t){const s=this.parseWsTrade(t),i=s.symbol,n=this.safeInteger(this.options,"tradesLimit",1e3);let r=this.safeValue(this.trades,i);r===void 0&&(r=new ct(n),this.trades[i]=r),r.append(s);const a="trades:"+i;e.resolve(r,a)}handleTrades(e,t){const s=this.safeStringLower(t,"symbol"),i=this.safeMarket(s),n=this.safeValue(t,"trades");if(n!==void 0){const r=i.symbol,a=this.safeInteger(this.options,"tradesLimit",1e3);let o=this.safeValue(this.trades,r);o===void 0&&(o=new ct(a),this.trades[r]=o);for(let u=0;u=0){this.handleOHLCV(e,t);return}const a=this.safeValue(n,r);if(a!==void 0&&a.call(this,e,t),r==="update"){const o=this.safeInteger(t,"timestampms",this.milliseconds()),c=this.safeInteger(t,"eventId"),u=this.safeList(t,"events"),h=[],l=[],f=[],p=u.length;for(let w=0;w0&&this.handleBidsAsksForMultidata(e,l,o,c),h.length>0&&this.handleOrderBookForMultidata(e,h,o,c),f.length>0&&this.handleTradesForMultidata(e,f,o)}}async authenticate(e={}){const t=this.safeString(e,"url");if(this.clients!==void 0&&t in this.clients)return;this.checkRequiredCredentials();const s=this.urls.api.ws.length,i=t.indexOf("?"),n=t.length,r=i>=0?i:n,o={request:t.slice(s,r),nonce:this.nonce()},c=this.stringToBase64(this.json(o)),u=this.hmac(this.encode(c),this.encode(this.secret),$d,"hex"),h={ws:{options:{headers:{}}}};this.extendExchangeOptions(h);const l=this.options.ws.options.headers,f={"X-GEMINI-APIKEY":this.apiKey,"X-GEMINI-PAYLOAD":c,"X-GEMINI-SIGNATURE":u};this.options.ws.options.headers=f,this.client(t),this.options.ws.options.headers=l}}class E3e extends T9{describe(){return this.deepExtend(super.describe(),{has:{ws:!0,watchBalance:!0,watchMyTrades:!0,watchOHLCV:!0,watchOrderBook:!0,watchOrders:!0,watchTicker:!0,watchTrades:!0,watchTradesForSymbols:!1,watchPositions:!1},urls:{api:{ws:{public:"wss://stream-glb.hashkey.com/quote/ws/v1",private:"wss://stream-glb.hashkey.com/api/v1/ws"},test:{ws:{public:"wss://stream-glb.sim.hashkeydev.com/quote/ws/v1",private:"wss://stream-glb.sim.hashkeydev.com/api/v1/ws"}}}},options:{listenKeyRefreshRate:36e5,listenKey:void 0,watchBalance:{fetchBalanceSnapshot:!0,awaitBalanceSnapshot:!1}},streaming:{keepAlive:1e4}})}async wathPublic(e,t,s,i={}){const n={symbol:e.id,topic:t,event:"sub"},r=this.urls.api.ws.public;return await this.watch(r,s,this.deepExtend(n,i),s)}async watchPrivate(e){const t=await this.authenticate(),s=this.getPrivateUrl(t);return await this.watch(s,e,void 0,e)}getPrivateUrl(e){return this.urls.api.ws.private+"/"+e}async watchOHLCV(e,t="1m",s=void 0,i=void 0,n={}){await this.loadMarkets();const r=this.market(e);e=r.symbol;const o="kline_"+this.safeString(this.timeframes,t,t),c="ohlcv:"+e+":"+t,u=await this.wathPublic(r,o,c,n);return this.newUpdates&&(i=u.getLimit(e,i)),this.filterBySinceLimit(u,s,i,0,!0)}handleOHLCV(e,t){const s=this.safeString(t,"symbol"),i=this.safeMarket(s),n=this.safeSymbol(s,i);n in this.ohlcvs||(this.ohlcvs[n]={});const r=this.safeDict(t,"params"),a=this.safeString(r,"klineType"),o=this.findTimeframe(a);if(!(o in this.ohlcvs[n])){const l=this.safeInteger(this.options,"OHLCVLimit",1e3);this.ohlcvs[n][o]=new Jt(l)}const c=this.safeList(t,"data",[]),u=this.ohlcvs[n][o];for(let l=0;lo.nonce&&this.handleOption("watchOrderBook","checksum",!0))throw new $r(this.id+" "+this.orderbookChecksumMessage(a));const m=r.spot&&h===o.nonce,g=r.contract&&f-1===o.nonce;if(m||g){const y=this.safeValue(c,"asks",[]),w=this.safeValue(c,"bids",[]);this.handleDeltas(o.asks,y),this.handleDeltas(o.bids,w),o.nonce=m?u:f,o.timestamp=p,o.datetime=this.iso8601(p)}}handleOrderBook(e,t){const s=this.safeString(t,"ch"),i=this.safeDict(t,"tick"),n=this.safeString(i,"event"),a=this.safeString(t,"ch").split("."),o=this.safeString(a,1),c=this.safeSymbol(o);if(!(c in this.orderbooks)){const l=this.safeString(a,3).split("_"),f=this.safeInteger(l,1);this.orderbooks[c]=this.orderBook({},f)}const u=this.orderbooks[c];n===void 0&&u.nonce===void 0?u.cache.push(t):(this.handleOrderBookMessage(e,t),e.resolve(u,s))}handleOrderBookSubscription(e,t,s){const i=this.safeString(s,"symbol"),n=this.market(i),r=this.safeInteger(s,"limit");this.orderbooks[i]=this.orderBook({},r),n.spot&&this.spawn(this.watchOrderBookSnapshot,e,t,s)}async watchMyTrades(e=void 0,t=void 0,s=void 0,i={}){this.checkRequiredCredentials(),await this.loadMarkets();let n,r="*",a,o,c,u,h;if(e!==void 0?(a=this.market(e),e=a.symbol,n=a.type,h=a.linear?"linear":"inverse",r=a.lowercaseId):(n=this.safeString(this.options,"defaultType","spot"),n=this.safeString(i,"type",n),h=this.safeString2(this.options,"subType","defaultSubType","linear"),h=this.safeString(i,"subType",h),i=this.omit(i,["type","subType"])),n==="spot"){let l;l===void 0&&(l=this.safeString2(this.options,"watchMyTrades","mode","0"),l=this.safeString(i,"mode",l),i=this.omit(i,"mode")),o="trade.clearing#"+r+"#"+l,c=o}else{const l=this.getOrderChannelAndMessageHash(n,h,a,i);c=this.safeString(l,0),o=this.safeString(l,1)+":trade"}return u=await this.subscribePrivate(c,o,n,h,i),this.newUpdates&&(s=u.getLimit(e,s)),this.filterBySymbolSinceLimit(u,e,t,s,!0)}getOrderChannelAndMessageHash(e,t,s=void 0,i={}){let n,r,a=this.safeString(this.options,"orderType","orders");a=this.safeString(i,"orderType",a),i=this.omit(i,"orderType");const o=s!==void 0?s.lowercaseId.toLowerCase():void 0,c=s!==void 0?s.baseId:void 0,u=a;if(n=u,t==="linear"){const l=this.safeString(i,"margin","cross")==="cross"?u+"_cross":u;n=l,o!==void 0?(n+="."+o,r=n):r=l+".*"}else e==="future"?c!==void 0?(r=u+"."+c.toLowerCase(),n=r):r=u+".*":o!==void 0?(r=u+"."+o,n=r):r=u+".*";return[r,n]}async watchOrders(e=void 0,t=void 0,s=void 0,i={}){await this.loadMarkets();let n,r,a,o="*";e!==void 0?(a=this.market(e),e=a.symbol,n=a.type,o=a.lowercaseId,r=a.linear?"linear":"inverse"):(n=this.safeString(this.options,"defaultType","spot"),n=this.safeString(i,"type",n),r=this.safeString2(this.options,"subType","defaultSubType","linear"),r=this.safeString(i,"subType",r),i=this.omit(i,["type","subType"]));let c,u;if(n==="spot")c="orders#"+o,u=c;else{const l=this.getOrderChannelAndMessageHash(n,r,a,i);u=this.safeString(l,0),c=this.safeString(l,1)}const h=await this.subscribePrivate(u,c,n,r,i);return this.newUpdates&&(s=h.getLimit(e,s)),this.filterBySinceLimit(h,t,s,"timestamp",!0)}handleOrder(e,t){const s=this.safeString2(t,"ch","topic"),i=this.safeValue(t,"data");let n=this.safeString(t,"contract_code");n===void 0&&(n=this.safeString(i,"symbol"));const r=this.safeMarket(n);let a;if(i!==void 0)if(this.safeString(i,"eventType")==="trade"){const l=this.parseOrderTrade(i,r),f=this.safeString(l,"order"),p=[l],m=this.parseOrderStatus(this.safeString2(i,"orderStatus","status","closed")),g=this.safeString(i,"execAmt"),y=this.safeString(i,"remainAmt");a={id:f,trades:p,status:m,symbol:r.symbol,filled:this.parseNumber(g),remaining:this.parseNumber(y)}}else a=this.parseWsOrder(i,r);else{a=this.parseWsOrder(t,r);const h=this.safeValue(t,"trade",[]);if(h.length>0){const f={trades:h,ch:s,symbol:n},p={order:this.safeString(a,"id"),type:this.safeString(a,"type"),side:this.safeString(a,"side")};this.handleMyTrade(e,f,p)}}if(this.orders===void 0){const h=this.safeInteger(this.options,"ordersLimit",1e3);this.orders=new tt(h)}this.orders.append(a),e.resolve(this.orders,s);let c=s.replace("."+r.lowercaseId,"");const u=this.safeStringLower(r,"baseId");c=c.replace("."+u,""),e.resolve(this.orders,c)}parseWsOrder(e,t=void 0){const s=this.safeInteger2(e,"lastActTime","ts"),i=this.safeInteger(e,"orderCreateTime"),n=this.safeString2(e,"contract_code","symbol");t=this.safeMarket(n,t);const r=this.safeSymbol(n,t),a=this.safeString2(e,"orderSize","volume"),o=this.parseOrderStatus(this.safeString2(e,"orderStatus","status")),c=this.safeString2(e,"orderId","order_id"),u=this.safeString2(e,"clientOrderId","client_order_id"),h=this.safeString2(e,"orderPrice","price"),l=this.safeString(e,"execAmt"),f=this.safeString(e,"type"),p=this.safeString(e,"fee");let m;if(p!==void 0){const C=this.safeString(e,"fee_asset");m={cost:p,currency:this.safeCurrencyCode(C)}}const g=this.safeString(e,"trade_avg_price"),y=this.safeValue(e,"trade");let w=[];f!==void 0&&(w=f.split("-"));let b=this.safeStringLower(w,1);b===void 0&&(b=this.safeString(e,"order_price_type"));let S=this.safeStringLower(w,0);S===void 0&&(S=this.safeString(e,"direction"));const v=this.safeString(e,"orderValue");return this.safeOrder({info:e,id:c,clientOrderId:u,timestamp:i,datetime:this.iso8601(i),lastTradeTimestamp:s,status:o,symbol:r,type:b,timeInForce:void 0,postOnly:void 0,side:S,price:h,amount:a,filled:l,remaining:void 0,cost:v,fee:m,average:g,trades:y},t)}parseOrderTrade(e,t=void 0){t=this.safeMarket(void 0,t);const s=t.symbol,i=this.safeString(e,"tradeId"),n=this.safeString(e,"tradePrice"),r=this.safeString(e,"tradeVolume"),a=this.safeString(e,"orderId"),o=this.safeInteger(e,"tradeTime");let c=this.safeString(e,"type"),u;if(c!==void 0){const f=c.split("-");u=f[0],c=f[1]}const h=this.safeValue(e,"aggressor");let l;return h!==void 0&&(l=h?"taker":"maker"),this.safeTrade({info:e,timestamp:o,datetime:this.iso8601(o),symbol:s,id:i,order:a,type:c,takerOrMaker:l,side:u,price:n,amount:r,cost:void 0,fee:void 0},t)}async watchPositions(e=void 0,t=void 0,s=void 0,i={}){await this.loadMarkets();let n,r="";this.isEmpty(e)||(n=this.getMarketFromSymbols(e),r="::"+e.join(","));let a,o;n!==void 0?(a=n.type,o=n.linear?"linear":"inverse"):([a,i]=this.handleMarketTypeAndParams("watchPositions",n,i),a==="spot"&&(a="future"),[o,i]=this.handleOptionAndParams(i,"watchPositions","subType",o)),e=this.marketSymbols(e);let c;[c,i]=this.handleMarginModeAndParams("watchPositions",i,"cross");const u=o==="linear",h=this.getUrlByMarketType(a,u,!0);r=c+":positions"+r;const l=c==="cross"?"positions_cross.*":"positions.*",f=await this.subscribePrivate(l,r,a,o,i);return this.newUpdates?f:this.filterBySymbolsSinceLimit(this.positions[h][c],e,t,s,!1)}handlePositions(e,t){const s=e.url,n=this.safeString(t,"topic","")==="positions_cross"?"cross":"isolated";this.positions===void 0&&(this.positions={});const r=this.safeValue(this.positions,s);r===void 0&&(this.positions[s]={}),this.safeValue(r,n)===void 0&&(this.positions[s][n]=new Ks);const o=this.positions[s][n],c=this.safeValue(t,"data",[]),u=[],h=this.safeInteger(t,"ts");for(let f=0;f0)for(let w=0;w=0){this.handleBalance(e,t);return}if(a==="orders"){this.handleOrder(e,t);return}if(this.safeString(t,"op")==="notify"){const c=this.safeString(t,"topic","");c.indexOf("orders")>=0&&this.handleOrder(e,t),c.indexOf("account")>=0&&this.handleBalance(e,t),c.indexOf("positions")>=0&&this.handlePositions(e,t)}}async pong(e,t){try{const s=this.safeInteger(t,"ping");if(s!==void 0){await e.send({pong:s});return}if(this.safeString(t,"action")==="ping"){const r=this.safeValue(t,"data"),a=this.safeInteger(r,"ts");await e.send({action:"pong",data:{ts:a}});return}if(this.safeString(t,"op")==="ping"){const r=this.safeInteger(t,"ts");await e.send({op:"pong",ts:r})}}catch(s){const i=new qs(this.id+" pong failed "+this.json(s));e.reset(i)}}handlePing(e,t){this.spawn(this.pong,e,t)}handleAuthenticate(e,t){e.futures.auth.resolve(t)}handleErrorMessage(e,t){if(this.safeString(t,"status")==="error"){const n=this.safeString(t,"id"),r=this.indexBy(e.subscriptions,"id"),a=this.safeValue(r,n);if(a!==void 0){const o=this.safeString(t,"err-code");try{throw this.throwExactlyMatchedException(this.exceptions.ws.exact,o,this.json(t)),new I(this.json(t))}catch(c){const u=this.safeString(a,"messageHash");e.reject(c,u),e.reject(c,n),n in e.subscriptions&&delete e.subscriptions[n]}}return!1}const i=this.safeString2(t,"code","err-code");if(i!==void 0&&i!=="200"&&i!=="0"){const n=this.id+" "+this.json(t);try{throw this.throwExactlyMatchedException(this.exceptions.ws.exact,i,n),new I(n)}catch(r){if(r instanceof $){e.reject(r,"auth");const a="auth";return a in e.subscriptions&&delete e.subscriptions[a],!1}else e.reject(r)}}return t}handleMessage(e,t){if(this.handleErrorMessage(e,t)){if("id"in t){this.handleSubscriptionStatus(e,t);return}if("action"in t){const s=this.safeString(t,"action");if(s==="ping"){this.handlePing(e,t);return}if(s==="sub"){this.handleSubscriptionStatus(e,t);return}}if("ch"in t)if(t.ch==="auth"){this.handleAuthenticate(e,t);return}else{this.handleSubject(e,t);return}if("op"in t){const s=this.safeString(t,"op");if(s==="ping"){this.handlePing(e,t);return}if(s==="auth"){this.handleAuthenticate(e,t);return}if(s==="sub"){this.handleSubscriptionStatus(e,t);return}if(s==="notify"){this.handleSubject(e,t);return}}"ping"in t&&this.handlePing(e,t)}}handleMyTrade(e,t,s={}){if(this.myTrades===void 0){const r=this.safeInteger(this.options,"tradesLimit",1e3);this.myTrades=new tt(r)}const i=this.myTrades,n=this.safeString(t,"ch");if(n!==void 0){const r=this.safeValue(t,"data");if(r!==void 0){const a=this.parseWsTrade(r);this.safeString(a,"symbol")!==void 0&&(i.append(a),e.resolve(this.myTrades,n))}else{const a=this.safeValue(t,"trades",[]),o=this.safeValue(t,"symbol"),c=this.market(o);for(let p=0;ps.nonce){const a=this.safeValue(i,"asks",[]),o=this.safeValue(i,"bids",[]);this.handleDeltas(s.asks,a),this.handleDeltas(s.bids,o),s.nonce=n;const c=this.safeInteger(t,"ts");s.timestamp=c,s.datetime=this.iso8601(c)}return s}handleOrderBook(e,t){const s=this.safeString(t,"ch"),n=this.safeValue(t,"ch").split("."),r=this.safeString(n,1),a=this.safeSymbol(r),o=this.orderbooks[a];o.nonce===void 0?o.cache.push(t):(this.handleOrderBookMessage(e,t,o),e.resolve(o,s))}handleOrderBookSubscription(e,t,s){const i=this.safeString(s,"symbol"),n=this.safeInteger(s,"limit");i in this.orderbooks&&delete this.orderbooks[i],this.orderbooks[i]=this.orderBook({},n),this.spawn(this.watchOrderBookSnapshot,e,t,s)}handleSubscriptionStatus(e,t){const s=this.safeString(t,"id"),i=this.indexBy(e.subscriptions,"id"),n=this.safeValue(i,s);if(n!==void 0){const r=this.safeValue(n,"method");if(r!==void 0)return r.call(this,e,t,n);s in e.subscriptions&&delete e.subscriptions[s]}return t}handleSystemStatus(e,t){return t}handleSubject(e,t){const i=this.safeValue(t,"ch").split(".");if(this.safeString(i,0)==="market"){const r=this.safeString(i,2),a={mbp:this.handleOrderBook,detail:this.handleTicker,trade:this.handleTrades,kline:this.handleOHLCV},o=this.safeValue(a,r);o!==void 0&&o.call(this,e,t)}}async pong(e,t){await e.send({pong:this.safeInteger(t,"ping")})}handlePing(e,t){this.spawn(this.pong,e,t)}handleErrorMessage(e,t){if(this.safeString(t,"status")==="error"){const i=this.safeString(t,"id"),n=this.indexBy(e.subscriptions,"id"),r=this.safeValue(n,i);if(r!==void 0){const a=this.safeString(t,"err-code");try{this.throwExactlyMatchedException(this.exceptions.exact,a,this.json(t))}catch(o){const c=this.safeString(r,"messageHash");e.reject(o,c),e.reject(o,i),i in e.subscriptions&&delete e.subscriptions[i]}}return!1}return t}handleMessage(e,t){this.handleErrorMessage(e,t)&&(this.safeString(t,"id")!==void 0?this.handleSubscriptionStatus(e,t):this.safeString(t,"ch")!==void 0?this.handleSubject(e,t):this.safeString(t,"ping")!==void 0&&this.handlePing(e,t))}}class V3e extends P9{describe(){return this.deepExtend(super.describe(),{has:{ws:!0,createOrderWs:!0,createOrdersWs:!0,editOrderWs:!0,watchBalance:!1,watchMyTrades:!0,watchOHLCV:!0,watchOrderBook:!0,watchOrders:!0,watchTicker:!0,watchTickers:!0,watchTrades:!0,watchTradesForSymbols:!1,watchPosition:!1},urls:{api:{ws:{public:"wss://api.hyperliquid.xyz/ws"}},test:{ws:{public:"wss://api.hyperliquid-testnet.xyz/ws"}}},options:{},streaming:{ping:this.ping,keepAlive:2e4},exceptions:{ws:{exact:{}}}})}async createOrdersWs(e,t={}){await this.loadMarkets();const s=this.urls.api.ws.public,i=this.createOrdersRequest(e,t),n=this.wrapAsPostAction(i),r=this.safeDict(n,"request",{}),a=this.safeString(n,"requestId"),o=await this.watch(s,a,r,a),c=this.safeDict(o,"response",{}),u=this.safeDict(c,"data",{}),h=this.safeList(u,"statuses",[]);return this.parseOrders(h,void 0)}async createOrderWs(e,t,s,i,n=void 0,r={}){await this.loadMarkets();const[a,o]=this.parseCreateOrderArgs(e,t,s,i,n,r);return(await this.createOrdersWs([a],o))[0]}async editOrderWs(e,t,s,i,n=void 0,r=void 0,a={}){await this.loadMarkets();const o=this.market(t),c=this.urls.api.ws.public,u=this.editOrderRequest(e,t,s,i,n,r,a),h=this.wrapAsPostAction(u),l=this.safeDict(h,"request",{}),f=this.safeString(h,"requestId"),p=await this.watch(c,f,l,f),m=this.safeDict(p,"response",{}),g=this.safeDict(m,"data",{}),y=this.safeList(g,"statuses",[]),w=this.safeDict(y,0,{});return this.parseOrder(w,o)}async watchOrderBook(e,t=void 0,s={}){await this.loadMarkets();const i=this.market(e);e=i.symbol;const n="orderbook:"+e,r=this.urls.api.ws.public,a={method:"subscribe",subscription:{type:"l2Book",coin:i.swap?i.base:i.id}},o=this.extend(a,s);return(await this.watch(r,n,o,n)).limit()}async unWatchOrderBook(e,t={}){await this.loadMarkets();const s=this.market(e);e=s.symbol;const n="unsubscribe:"+("orderbook:"+e),r=this.urls.api.ws.public,o={id:this.nonce().toString(),method:"unsubscribe",subscription:{type:"l2Book",coin:s.swap?s.base:s.id}},c=this.extend(o,t);return await this.watch(r,n,c,n)}handleOrderBook(e,t){const s=this.safeDict(t,"data",{}),i=this.safeString(s,"coin"),n=this.coinToMarketId(i),a=this.market(n).symbol,o=this.safeList(s,"levels",[]),c={bids:this.safeList(o,0,[]),asks:this.safeList(o,1,[])},u=this.safeInteger(s,"time"),h=this.parseOrderBook(c,a,u,"bids","asks","px","sz");if(!(a in this.orderbooks)){const p=this.orderBook(h);this.orderbooks[a]=p}const l=this.orderbooks[a];l.reset(h);const f="orderbook:"+a;e.resolve(l,f)}async watchTicker(e,t={}){return e=this.market(e).symbol,(await this.watchTickers([e],t))[e]}async watchTickers(e=void 0,t={}){await this.loadMarkets(),e=this.marketSymbols(e,void 0,!0);const s="tickers",i=this.urls.api.ws.public,n={method:"subscribe",subscription:{type:"webData2",user:"0x0000000000000000000000000000000000000000"}},r=await this.watch(i,s,this.extend(n,t),s);return this.newUpdates?this.filterByArrayTickers(r,"symbol",e):this.tickers}async unWatchTickers(e=void 0,t={}){await this.loadMarkets(),e=this.marketSymbols(e,void 0,!0);const i="unsubscribe:"+"tickers",n=this.urls.api.ws.public,r={method:"unsubscribe",subscription:{type:"webData2",user:"0x0000000000000000000000000000000000000000"}};return await this.watch(n,i,this.extend(r,t),i)}async watchMyTrades(e=void 0,t=void 0,s=void 0,i={}){let n;[n,i]=this.handlePublicAddress("watchMyTrades",i),await this.loadMarkets();let r="myTrades";e!==void 0&&(e=this.symbol(e),r+=":"+e);const a=this.urls.api.ws.public,o={method:"subscribe",subscription:{type:"userFills",user:n}},c=this.extend(o,i),u=await this.watch(a,r,c,r);return this.newUpdates&&(s=u.getLimit(e,s)),this.filterBySymbolSinceLimit(u,e,t,s,!0)}handleWsTickers(e,t){const s=this.safeDict(t,"data",{}),i=this.safeList(s,"spotAssetCtxs",[]),n=[];for(let u=0;u=0){i[o].call(this,e,t);return}}}ping(e){return{method:"ping"}}handlePong(e,t){return e.lastPong=this.safeInteger(t,"pong"),t}requestId(){const e=this.sum(this.safeInteger(this.options,"requestId",0),1);return this.options.requestId=e,e}wrapAsPostAction(e){const t=this.requestId();return{requestId:t,request:{method:"post",id:t,request:{type:"action",payload:e}}}}}class F3e extends I9{describe(){return this.deepExtend(super.describe(),{has:{ws:!0,watchOrderBook:!0,watchTrades:!0,watchOHLCV:!0,watchTicker:!0,watchTickers:!1,watchOrders:!0,watchTransactions:!0},urls:{test:{ws:"wss://websocket-matic.idex.io/v1"},api:{}},options:{tradesLimit:1e3,ordersLimit:1e3,OHLCVLimit:1e3,watchOrderBookLimit:1e3,orderBookSubscriptions:{},token:void 0,watchOrderBook:{maxRetries:3},fetchOrderBookSnapshotMaxAttempts:10,fetchOrderBookSnapshotMaxDelay:1e4}})}async subscribe(e,t,s=!0){const i=this.urls.test.ws,n={method:"subscribe",subscriptions:[e]};return await this.watch(i,t,n,t,s)}async subscribePrivate(e,t){const s=await this.authenticate(),i=this.urls.test.ws,n={method:"subscribe",token:s,subscriptions:[e]};return await this.watch(i,t,n,t)}async watchTicker(e,t={}){await this.loadMarkets();const s=this.market(e),i="tickers",n={name:i,markets:[s.id]},r=i+":"+s.id;return await this.subscribe(this.extend(n,t),r)}handleTicker(e,t){const s=this.safeString(t,"type"),i=this.safeValue(t,"data"),n=this.safeString(i,"m"),r=this.safeSymbol(n),a=s+":"+n,o=this.safeInteger(i,"t"),c=this.safeString(i,"c"),u=this.safeString(i,"P");let h;u!==void 0&&c!==void 0&&(h=L.stringMul(c,u));const l=this.safeTicker({symbol:r,timestamp:o,datetime:this.iso8601(o),high:this.safeString(i,"h"),low:this.safeString(i,"l"),bid:this.safeString(i,"b"),bidVolume:void 0,ask:this.safeString(i,"a"),askVolume:void 0,vwap:void 0,open:this.safeString(i,"o"),close:c,last:c,previousClose:void 0,change:h,percentage:u,average:void 0,baseVolume:this.safeString(i,"v"),quoteVolume:this.safeString(i,"q"),info:t});e.resolve(l,a)}async watchTrades(e,t=void 0,s=void 0,i={}){await this.loadMarkets();const n=this.market(e);e=n.symbol;const r="trades",a={name:r,markets:[n.id]},o=r+":"+n.id,c=await this.subscribe(a,o);return this.newUpdates&&(s=c.getLimit(e,s)),this.filterBySinceLimit(c,t,s,"timestamp",!0)}handleTrade(e,t){const s=this.safeString(t,"type"),i=this.safeValue(t,"data"),n=this.safeString(i,"m"),r=s+":"+n,a=this.parseWsTrade(i);if(Object.keys(this.trades).length===0){const h=this.safeInteger(this.options,"tradesLimit");this.trades=new tt(h)}const u=this.trades;u.append(a),e.resolve(u,r)}parseWsTrade(e,t=void 0){const s=this.safeString(e,"m"),i=this.safeSymbol(s),n=this.safeString(e,"i"),r=this.safeString(e,"p"),a=this.safeString(e,"q"),o=this.safeString(e,"Q"),c=this.safeInteger(e,"t"),u=this.safeString(e,"s"),h={currency:this.safeString(e,"a"),cost:this.safeString(e,"f")},l=this.safeString(e,"l");return this.safeTrade({info:e,timestamp:c,datetime:this.iso8601(c),symbol:i,id:n,order:void 0,type:void 0,takerOrMaker:l,side:u,price:r,amount:a,cost:o,fee:h})}async watchOHLCV(e,t="1m",s=void 0,i=void 0,n={}){await this.loadMarkets();const r=this.market(e);e=r.symbol;const a="candles",o=this.safeString(this.timeframes,t,t),c={name:a,markets:[r.id],interval:o},u=a+":"+r.id,h=await this.subscribe(c,u);return this.newUpdates&&(i=h.getLimit(e,i)),this.filterBySinceLimit(h,s,i,0,!0)}handleOHLCV(e,t){const s=this.safeString(t,"type"),i=this.safeValue(t,"data"),n=this.safeString(i,"m"),r=s+":"+n,a=[this.safeInteger(i,"s"),this.safeFloat(i,"o"),this.safeFloat(i,"h"),this.safeFloat(i,"l"),this.safeFloat(i,"c"),this.safeFloat(i,"v")],o=this.safeSymbol(n),c=this.safeString(i,"i"),u=this.findTimeframe(c);this.ohlcvs[o]=this.safeValue(this.ohlcvs,o,{});let h=this.safeValue(this.ohlcvs[o],u);if(h===void 0){const l=this.safeInteger(this.options,"OHLCVLimit",1e3);h=new Jt(l),this.ohlcvs[o][u]=h}h.append(a),e.resolve(h,r)}handleSubscribeMessage(e,t){const s=this.safeValue(t,"subscriptions");for(let i=0;ih.nonce){i.reset(h);for(let S=0;Si.nonce&&this.handleOrderBookMessage(e,v,i)}a.fetchingOrderBookSnapshot=!1,e.resolve(i,r)}else{a.numAttempts=a.numAttempts+1;const S=this.milliseconds()-a.startTime,v=a.numAttempts900){const i={wallet:this.walletAddress,nonce:this.uuidv1()},n=await this.privateGetWsToken(this.extend(i,e));this.options.lastAuthenticatedTime=t,this.options.token=this.safeString(n,"token")}return this.options.token}async watchOrders(e=void 0,t=void 0,s=void 0,i={}){await this.loadMarkets();const n="orders",r={name:n};let a=n;if(e!==void 0){e=this.symbol(e);const c=this.marketId(e);r.markets=[c],a=n+":"+c}const o=await this.subscribePrivate(r,a);return this.newUpdates&&(s=o.getLimit(e,s)),this.filterBySinceLimit(o,t,s,"timestamp",!0)}handleOrder(e,t){const s=this.safeString(t,"type"),i=this.safeValue(t,"data"),n=this.safeString(i,"m"),r=this.safeSymbol(n),a=this.safeInteger(i,"t"),o=this.safeValue(i,"F",[]),c=[];for(let N=0;N]":I,"EGeneral:Invalid arguments":T,"EOrder:Cannot open opposing position":x,"EOrder:Cannot open position":x,"EOrder:Insufficient funds (insufficient user funds)":ce,"EOrder:Insufficient margin (exchange does not have sufficient funds to allow margin trading)":ce,"EOrder:Invalid price":x,"EOrder:Margin allowance exceeded":x,"EOrder:Margin level too low":x,"EOrder:Margin position size exceeded (client would exceed the maximum position size for this pair)":x,"EOrder:Order minimum not met (volume too low)":x,"EOrder:Orders limit exceeded":x,"EOrder:Positions limit exceeded":x,"EOrder:Rate limit exceeded":Ze,"EOrder:Scheduled orders limit exceeded":x,"EOrder:Unknown position":Ie,"EOrder:Unknown order":Ie,"EOrder:Invalid order":x,"EService:Deadline elapsed":Ee,"EService:Market in cancel_only mode":q,"EService:Market in limit_only mode":q,"EService:Market in post_only mode":q,"EService:Unavailable":Ee,"ETrade:Invalid request":T}}}})}async createOrderWs(e,t,s,i,n=void 0,r={}){await this.loadMarkets();const a=await this.authenticate(),o=this.market(e),c=this.urls.api.ws.private,u=this.requestId(),h=u;let l={event:"addOrder",token:a,reqid:u,ordertype:t,type:s,pair:o.wsId,volume:this.amountToPrecision(e,i)};return[l,r]=this.orderRequest("createOrderWs",e,t,l,i,n,r),await this.watch(c,h,this.extend(l,r),h)}handleCreateEditOrder(e,t){const s=this.parseOrder(t),i=this.safeValue(t,"reqid");e.resolve(s,i)}async editOrderWs(e,t,s,i,n=void 0,r=void 0,a={}){await this.loadMarkets();const o=await this.authenticate(),c=this.market(t),u=this.urls.api.ws.private,h=this.requestId(),l=h;let f={event:"editOrder",token:o,reqid:h,orderid:e,pair:c.wsId};return n!==void 0&&(f.volume=this.amountToPrecision(t,n)),[f,a]=this.orderRequest("editOrderWs",t,s,f,n,r,a),await this.watch(u,l,this.extend(f,a),l)}async cancelOrdersWs(e,t=void 0,s={}){await this.loadMarkets();const i=await this.authenticate(),n=this.urls.api.ws.private,r=this.requestId(),a=r,o={event:"cancelOrder",token:i,reqid:r,txid:e};return await this.watch(n,a,this.extend(o,s),a)}async cancelOrderWs(e,t=void 0,s={}){await this.loadMarkets();const i=await this.authenticate(),n=this.urls.api.ws.private,r=this.requestId(),a=r,o=this.safeValue2(s,"userref","clientOrderId",e);s=this.omit(s,["userref","clientOrderId"]);const c={event:"cancelOrder",token:i,reqid:r,txid:[o]};return await this.watch(n,a,this.extend(c,s),a)}handleCancelOrder(e,t){const s=this.safeValue(t,"reqid");e.resolve(t,s)}async cancelAllOrdersWs(e=void 0,t={}){if(e!==void 0)throw new q(this.id+" cancelAllOrdersWs () does not support cancelling orders in a specific market.");await this.loadMarkets();const s=await this.authenticate(),i=this.urls.api.ws.private,n=this.requestId(),r=n,a={event:"cancelAll",token:s,reqid:n};return await this.watch(i,r,this.extend(a,t),r)}handleCancelAllOrders(e,t){const s=this.safeValue(t,"reqid");e.resolve(t,s)}handleTicker(e,t,s){const i=t[3],r=this.safeValue(this.options.marketsByWsName,i).symbol,a=this.getMessageHash("ticker",void 0,r),o=t[1],c=this.safeString(o.p,0);let u;const h=this.safeString(o.v,0);h!==void 0&&c!==void 0&&(u=L.stringMul(h,c));const l=this.safeString(o.c,0),f=this.safeTicker({symbol:r,timestamp:void 0,datetime:void 0,high:this.safeString(o.h,0),low:this.safeString(o.l,0),bid:this.safeString(o.b,0),bidVolume:this.safeString(o.b,2),ask:this.safeString(o.a,0),askVolume:this.safeString(o.a,2),vwap:c,open:this.safeString(o.o,0),close:l,last:l,previousClose:void 0,change:void 0,percentage:void 0,average:void 0,baseVolume:h,quoteVolume:u,info:o});this.tickers[r]=f,e.resolve(f,a)}handleTrades(e,t,s){const i=this.safeString(t,3),n=this.safeString(t,2),r=this.safeValue(this.options.marketsByWsName,i),a=r.symbol,o=this.getMessageHash(n,void 0,a);let c=this.safeValue(this.trades,a);if(c===void 0){const l=this.safeInteger(this.options,"tradesLimit",1e3);c=new ct(l),this.trades[a]=c}const u=this.safeValue(t,1,[]),h=this.parseTrades(u,r);for(let l=0;l0?o.slice(c):o}customHandleDeltas(e,t,s=void 0){for(let i=0;i0){if(this.myTrades===void 0){const u=this.safeInteger(this.options,"tradesLimit",1e3);this.myTrades=new ct(u)}const r=this.myTrades,a={};for(let u=0;u0){const r=this.safeInteger(this.options,"ordersLimit",1e3);this.orders===void 0&&(this.orders=new tt(r));const a=this.orders,o={};for(let h=0;h=0?f.currency=t.quote:C.indexOf("fcib")>=0&&(f.currency=t.base)}const g=this.parseOrderStatus(this.safeString(e,"status"));let y=this.safeString(e,"id");if(y===void 0){const C=this.safeValue(e,"txid");y=this.safeString(C,0)}const w=this.safeString(e,"userref"),b=this.safeValue(e,"trades");let S;b!==void 0&&(S=this.parseTrades(b,t,void 0,void 0,{order:y}));const v=this.safeNumber(e,"stopprice");return this.safeOrder({id:y,clientOrderId:w,info:e,timestamp:h,datetime:this.iso8601(h),lastTradeTimestamp:void 0,status:g,symbol:u,type:r,timeInForce:void 0,postOnly:void 0,side:n,price:o,stopPrice:v,triggerPrice:v,cost:p,amount:c,filled:l,average:m,remaining:void 0,fee:f,trades:S})}async watchMultiHelper(e,t,s=void 0,i=void 0,n={}){await this.loadMarkets(),s=this.marketSymbols(s,void 0,!1,!0,!1);const r=[];for(let h=0;h0?"long":"short";return this.safePosition({info:e,id:void 0,symbol:this.safeSymbol(s),notional:void 0,marginMode:void 0,liquidationPrice:this.safeNumber(e,"liquidation_threshold"),entryPrice:this.safeNumber(e,"entry_price"),unrealizedPnl:this.safeNumber(e,"pnl"),percentage:this.safeNumber(e,"return_on_equity"),contracts:this.parseNumber(L.stringAbs(this.numberToString(n))),contractSize:void 0,markPrice:this.safeNumber(e,"mark_price"),side:r,hedged:i,timestamp:void 0,datetime:void 0,maintenanceMargin:this.safeNumber(e,"maintenance_margin"),maintenanceMarginPercentage:void 0,collateral:void 0,initialMargin:this.safeNumber(e,"initial_margin"),initialMarginPercentage:void 0,leverage:void 0,marginRatio:void 0})}async watchOrders(e=void 0,t=void 0,s=void 0,i={}){await this.loadMarkets();const n="open_orders";let r="orders";if(e!==void 0){const o=this.market(e);r+=":"+o.symbol}const a=await this.subscribePrivate(n,r,i);return this.newUpdates&&(s=a.getLimit(e,s)),this.filterBySinceLimit(a,t,s,"timestamp",!0)}async watchMyTrades(e=void 0,t=void 0,s=void 0,i={}){await this.loadMarkets();const n="fills";let r="myTrades";if(e!==void 0){const o=this.market(e);r+=":"+o.symbol}const a=await this.subscribePrivate(n,r,i);return this.newUpdates&&(s=a.getLimit(e,s)),this.filterBySinceLimit(a,t,s,"timestamp",!0)}async watchBalance(e={}){await this.loadMarkets();const t="balances";let s=t,i;if([i,e]=this.handleOptionAndParams(e,"watchBalance","account"),i!==void 0){if(i!=="futures"&&i!=="flex_futures")throw new G(this.id+" watchBalance account must be either 'futures' or 'flex_futures'");s+=":"+i}return await this.subscribePrivate(t,s,e)}handleTrade(e,t){const s=this.safeString(t,"feed"),i=this.safeString(t,"product_id");if(i!==void 0){const r=this.market(i).symbol,a=this.getMessageHash("trade",void 0,r);if(this.safeList(this.trades,r)===void 0){const c=this.safeInteger(this.options,"tradesLimit",1e3);this.trades[r]=new ct(c)}const o=this.trades[r];if(s==="trade_snapshot"){const c=this.safeList(t,"trades",[]),u=c.length;for(let h=0;h0){e.resolve(this.orders,"orders");const o=Object.keys(n);for(let c=0;c100)throw new G(this.id+" "+e+"() accepts a maximum of 100 symbols");const r=[];for(let f=0;f=0&&v.indexOf(o)>=0){y=e.subscriptions[v];break}}const w=this.safeInteger(y,"limit"),b=this.handleOption("watchOrderBook","snapshotDelay",5);m===b&&this.spawn(this.loadOrderBook,e,h,u,w,{}),l.cache.push(s);return}else if(f>=p)return}this.handleDelta(this.orderbooks[u],s),e.resolve(this.orderbooks[u],h)}getCacheIndex(e,t){const s=this.safeValue(t,0),i=this.safeInteger(e,"nonce"),n=this.safeInteger(s,"sequenceStart");if(i=o-1&&i=0&&(i="private"),this.options.urls[i]=void 0}this.handleErrors(void 0,void 0,e.url,void 0,void 0,s,t,void 0,void 0)}handleMessage(e,t){const s=this.safeString(t,"type"),i={welcome:this.handleSystemStatus,ack:this.handleSubscriptionStatus,message:this.handleSubject,pong:this.handlePong,error:this.handleErrorMessage},n=this.safeValue(i,s);n!==void 0&&n.call(this,e,t)}}class j3e extends A9{describe(){return this.deepExtend(super.describe(),{has:{ws:!0,watchLiquidations:!1,watchLiquidatinsForSymbols:!1,watchMyLiquidations:void 0,watchMyLiquidationsForSymbols:void 0,watchTicker:!0,watchTickers:!0,watchBidsAsks:!0,watchTrades:!0,watchOHLCV:!0,watchOrderBook:!0,watchOrders:!0,watchBalance:!0,watchPosition:!0,watchPositions:!1,watchPositionForSymbols:!1,watchTradesForSymbols:!0,watchOrderBookForSymbols:!0},options:{timeframes:{"1m":"1min","3m":"1min","5m":"5min","15m":"15min","30m":"30min","1h":"1hour","2h":"2hour","4h":"4hour","8h":"8hour","12h":"12hour","1d":"1day","1w":"1week","1M":"1month"},accountsByType:{swap:"future",cross:"margin"},tradesLimit:1e3,watchOrderBook:{snapshotDelay:20,snapshotMaxRetries:3},watchPosition:{fetchPositionSnapshot:!0,awaitPositionSnapshot:!0}},streaming:{ping:this.ping}})}async negotiate(e,t={}){const s=e?"private":"public",i=this.safeValue(this.options,"urls",{}),n=this.safeValue(i,s);return n!==void 0?await n:(i[s]=this.spawn(this.negotiateHelper,e,t),this.options.urls=i,await i[s])}async negotiateHelper(e,t={}){let s;const i=e?"private":"public";try{e?s=await this.futuresPrivatePostBulletPrivate(t):s=await this.futuresPublicPostBulletPublic(t);const n=this.safeValue(s,"data",{}),r=this.safeValue(n,"instanceServers",[]),a=this.safeValue(r,0),o=this.safeInteger(a,"pingInterval"),c=this.safeString(a,"endpoint"),u=this.safeString(n,"token"),h=c+"?"+this.urlencode({token:u,privateChannel:e,connectId:i}),l=this.client(h);return l.keepAlive=o,h}catch(n){this.safeValue(this.options.urls,i).reject(n),delete this.options.urls[i]}}requestId(){const e=this.sum(this.safeInteger(this.options,"requestId",0),1);return this.options.requestId=e,e}async subscribe(e,t,s,i,n={}){const r=this.requestId().toString(),a={id:r,type:"subscribe",topic:s,response:!0},o=this.extend(a,n),c={id:r};return i===void 0?i=c:i=this.extend(c,i),await this.watch(e,t,o,s,i)}async subscribeMultiple(e,t,s,i,n,r={}){const o={id:this.requestId().toString(),type:"subscribe",topic:s,response:!0};return await this.watchMultiple(e,t,this.extend(o,r),i,n)}async unSubscribeMultiple(e,t,s,i,n={},r=void 0){const a=this.requestId().toString(),o={id:a,type:"unsubscribe",topic:s,response:!0},c=this.extend(o,n);r!==void 0&&(r[a]=a);const u=this.client(e);for(let h=0;h100)throw new G(this.id+" "+e+"() accepts a maximum of 100 symbols");const a=[];for(let p=0;p=0&&v.indexOf(m)>=0){y=e.subscriptions[v];break}}const w=this.safeInteger(y,"limit"),b=this.handleOption("watchOrderBook","snapshotDelay",5);l===b&&this.spawn(this.loadOrderBook,e,o,a,w,{}),c.cache.push(s);return}else if(u>=h)return;this.handleDelta(c,s),e.resolve(c,o)}getCacheIndex(e,t){const s=this.safeValue(t,0),i=this.safeInteger(e,"nonce"),n=this.safeInteger(s,"sequence");if(i=0&&(i="private"),this.options.urls[i]=void 0}this.handleErrors(void 0,void 0,e.url,void 0,void 0,s,t,void 0,void 0)}handleSubscriptionStatus(e,t){const s=this.safeString(t,"id");if(!(s in e.subscriptions))return;const i=this.safeString(e.subscriptions,s),n=this.safeValue(e.subscriptions,i);delete e.subscriptions[s];const r=this.safeValue(n,"method");if(r!==void 0&&r.call(this,e,t,n),this.safeBool(n,"unsubscribe",!1)){const o=this.safeList(n,"messageHashes",[]),c=this.safeList(n,"subMessageHashes",[]);for(let u=0;u=s)return r}return t.length}handleOrderBook(e,t){const s=this.safeValue2(t,"d","data"),i=this.safeString2(t,"s","symbol"),n=this.safeSymbol(i),r="orderbook:"+n,a=this.safeValue(e.subscriptions,r),o=this.safeInteger(a,"limit");a===!0&&(e.subscriptions[r]=1,this.orderbooks[n]=this.countedOrderBook({}));const c=this.orderbooks[n];if(this.safeInteger(c,"nonce")===void 0){const h=c.cache.length,l=this.handleOption("watchOrderBook","snapshotDelay",25);h===l&&this.spawn(this.loadOrderBook,e,r,n,o,{}),c.cache.push(s);return}try{this.handleDelta(c,s);const h=this.safeInteger2(t,"t","ts");c.timestamp=h,c.datetime=this.iso8601(h)}catch(h){delete e.subscriptions[r],e.reject(h,r)}e.resolve(c,r)}handleBooksideDelta(e,t){for(let s=0;s-1){const i=s.split("@"),n=this.safeString(i,1),r={"public.increase.depth.v3.api":this.handleOrderBookSubscription},a=this.safeValue(r,n);a!==void 0&&a.call(this,e,t)}}handleMessage(e,t){if(typeof t=="string"){if(t==="Invalid listen key"){const r=new $(this.id+" invalid listen key");e.reject(r)}return}if("msg"in t){this.handleSubscriptionStatus(e,t);return}const s=this.safeString(t,"c");let i;if(s===void 0)i=this.safeString(t,"channel");else{const r=s.split("@");i=this.safeString(r,1)}const n={"public.deals.v3.api":this.handleTrades,"push.deal":this.handleTrades,"public.kline.v3.api":this.handleOHLCV,"push.kline":this.handleOHLCV,"public.bookTicker.v3.api":this.handleTicker,"public.miniTicker.v3.api":this.handleTicker,"public.miniTickers.v3.api":this.handleTickers,"push.ticker":this.handleTicker,"push.tickers":this.handleTickers,"public.increase.depth.v3.api":this.handleOrderBook,"push.depth":this.handleOrderBook,"private.orders.v3.api":this.handleOrder,"push.personal.order":this.handleOrder,"private.account.v3.api":this.handleBalance,"push.personal.asset":this.handleBalance,"private.deals.v3.api":this.handleMyTrade,"push.personal.order.deal":this.handleMyTrade,pong:this.handlePong};i in n&&n[i].call(this,e,t)}ping(e){return{method:"ping"}}}class X3e extends E9{describe(){return this.deepExtend(super.describe(),{has:{ws:!0,watchOrderBook:!0,watchTrades:!0,watchTradesForSymbols:!1,watchTicker:!0,watchOHLCV:!0},urls:{test:{ws:"wss://ndaxmarginstaging.cdnhop.net:10456/WSAdminGatewa/"},api:{ws:"wss://api.ndax.io/WSGateway"}}})}requestId(){const e=this.sum(this.safeInteger(this.options,"requestId",0),1);return this.options.requestId=e,e}async watchTicker(e,t={}){const s=this.safeInteger(this.options,"omsId",1);await this.loadMarkets();const i=this.market(e),n="SubscribeLevel1",r=n+":"+i.id,a=this.urls.api.ws,o=this.requestId(),c={OMSId:s,InstrumentId:parseInt(i.id)},u={m:0,i:o,n,o:this.json(c)},h=this.extend(u,t);return await this.watch(a,r,h,r)}handleTicker(e,t){const s=this.safeValue(t,"o",{}),i=this.parseTicker(s),n=i.symbol,r=this.market(n);this.tickers[n]=i;const o="SubscribeLevel1"+":"+r.id;e.resolve(i,o)}async watchTrades(e,t=void 0,s=void 0,i={}){const n=this.safeInteger(this.options,"omsId",1);await this.loadMarkets();const r=this.market(e);e=r.symbol;const a="SubscribeTrades",o=a+":"+r.id,c=this.urls.api.ws,u=this.requestId(),h={OMSId:n,InstrumentId:parseInt(r.id),IncludeLastCount:100},l={m:0,i:u,n:a,o:this.json(h)},f=this.extend(l,i),p=await this.watch(c,o,f,o);return this.newUpdates&&(s=p.getLimit(e,s)),this.filterBySinceLimit(p,t,s,"timestamp",!0)}handleTrades(e,t){const s=this.safeValue(t,"o",[]),i="SubscribeTrades",n={};for(let a=0;a=v&&b.shift(),i[c][p]=!0}}this.ohlcvs[h][p]=b}}const n="SubscribeTicker",r=Object.keys(i);for(let a=0;a0){const a=this.safeInteger(this.options,"ordersLimit",1e3);this.orders===void 0&&(this.orders=new tt(a));const o=this.orders,c={},u=this.parseOrders(n);for(let l=0;l=0&&(a=this.handleOHLCV),a!==void 0&&a.call(this,e,t)}}}class Y3e extends D9{describe(){return this.deepExtend(super.describe(),{has:{ws:!0,watchTicker:!0,watchMarkPrice:!0,watchMarkPrices:!0,watchTickers:!0,watchBidsAsks:!0,watchOrderBook:!0,watchTrades:!0,watchTradesForSymbols:!0,watchOrderBookForSymbols:!0,watchBalance:!0,watchLiquidations:"emulated",watchLiquidationsForSymbols:!0,watchMyLiquidations:"emulated",watchMyLiquidationsForSymbols:!0,watchOHLCV:!0,watchOHLCVForSymbols:!0,watchOrders:!0,watchMyTrades:!0,watchPositions:!0,watchFundingRate:!0,watchFundingRates:!0,createOrderWs:!0,editOrderWs:!0,cancelOrderWs:!0,cancelOrdersWs:!0,cancelAllOrdersWs:!0},urls:{api:{ws:"wss://ws.okx.com:8443/ws/v5"},test:{ws:"wss://wspap.okx.com:8443/ws/v5"}},options:{watchOrderBook:{checksum:!0,depth:"books"},watchBalance:"spot",watchTicker:{channel:"tickers"},watchTickers:{channel:"tickers"},watchOrders:{type:"ANY"},watchMyTrades:{type:"ANY"},createOrderWs:{op:"batch-orders"},editOrderWs:{op:"amend-order"},ws:{}},streaming:{ping:this.ping,keepAlive:18e3}})}getUrl(e,t="public"){const i=this.options.sandboxMode?"?brokerId=9999":"",n=t==="business",r=t==="public",a=this.urls.api.ws;return n||e.indexOf("candle")>-1||e==="orders-algo"?a+"/business"+i:r?a+"/public"+i:a+"/private"+i}async subscribeMultiple(e,t,s=void 0,i={}){await this.loadMarkets(),s===void 0&&(s=this.symbols),s=this.marketSymbols(s);const n=this.getUrl(t,e),r=[],a=[];for(let c=0;c1&&t<=5?i="books5":t===50?i="books50-l2-tbt":t===400&&(i="books")),i==="books-l2-tbt"||i==="books50-l2-tbt"){if(!this.checkRequiredCredentials(!1))throw new $(this.id+" watchOrderBook/watchOrderBookForSymbols requires authentication for this depth. Add credentials or change the depth option to books or books5");await this.authenticate({access:"public"})}const n=[],r=[];for(let u=0;u1&&i<=5?s="books5":i===50?s="books50-l2-tbt":i===400&&(s="books"));const n=[],r=[];for(let c=0;c0){const o=this.safeInteger(this.options,"ordersLimit",1e3);this.orders===void 0&&(this.orders=new tt(o),this.triggerOrders=new tt(o));const c=n==="orders-algo"?this.triggerOrders:this.orders,u=[],h=this.parseOrders(r);for(let l=0;l0){const m=this.parseOrder(f);r.push(m)}}if(r.length===0)return;if(this.myTrades===void 0){const l=this.safeInteger(this.options,"tradesLimit",1e3);this.myTrades=new tt(l)}const o=this.myTrades,c={};for(let l=0;l20)throw new T(this.id+" cancelOrdersWs() accepts up to 20 ids at a time");if(t===void 0)throw new T(this.id+" cancelOrdersWs() requires a symbol argument");await this.loadMarkets(),await this.authenticate();const n=this.getUrl("private","private"),r=this.requestId(),a=[];for(let c=0;c-1?this.handleUnsubscriptionTicker(e,r,i):i.startsWith("candle")&&this.handleUnsubscriptionOHLCV(e,r,i)}}class Z3e extends q9{describe(){return this.deepExtend(super.describe(),{has:{ws:!0,watchTrades:!0,watchTradesForSymbols:!0,watchOrderBook:!0,watchOrderBookForSymbols:!0,watchOHLCV:!0,watchOHLCVForSymbols:!0,watchOrders:!0,watchMyTrades:!1,watchTicker:!0,watchTickers:!0,watchBidsAsks:!0,watchBalance:!0,createOrderWs:!0,editOrderWs:!0,cancelOrderWs:!0,cancelOrdersWs:!0},urls:{api:{ws:"wss://api.ox.fun/v2/websocket",test:"wss://stgapi.ox.fun/v2/websocket"}},options:{timeframes:{"1m":"60s","3m":"180s","5m":"300s","15m":"900s","30m":"1800s","1h":"3600s","2h":"7200s","4h":"14400s","6h":"21600s","12h":"43200s","1d":"86400s"},watchOrderBook:{channel:"depth"}},streaming:{ping:this.ping,keepAlive:5e4}})}async subscribeMultiple(e,t,s={}){const i=this.urls.api.ws,n={op:"subscribe",args:t};return await this.watchMultiple(i,e,this.extend(n,s),e)}async watchTrades(e,t=void 0,s=void 0,i={}){return await this.watchTradesForSymbols([e],t,s,i)}async watchTradesForSymbols(e,t=void 0,s=void 0,i={}){await this.loadMarkets(),e=this.marketSymbols(e,void 0,!1);const n=[],r=[];for(let o=0;o20)throw new T(this.id+" cancelOrdersWs() accepts up to 20 ids at a time");if(t===void 0)throw new G(this.id+" cancelOrdersWs() requires a symbol argument");await this.loadMarkets(),await this.authenticate();const n=this.nonce().toString(),r=this.marketId(t),a=[];for(let u=0;u-1&&this.handleOHLCV(e,t),s.indexOf("depth")>-1&&this.handleOrderBook(e,t),s.indexOf("balance")>-1&&this.handleBalance(e,t),s.indexOf("position")>-1&&this.handlePositions(e,t),s.indexOf("order")>-1&&this.handleOrders(e,t),s==="bestBidAsk"&&this.handleBidAsk(e,t)):(n==="login"&&this.handleAuthenticationMessage(e,t),(n==="placeorder"||n==="modifyorder"||n==="cancelorder")&&this.handlePlaceOrders(e,t))}}class J3e extends V9{describe(){return this.deepExtend(super.describe(),{has:{ws:!0,cancelAllOrdersWs:!1,cancelOrdersWs:!1,cancelOrderWs:!1,createOrderWs:!1,editOrderWs:!1,fetchBalanceWs:!1,fetchOpenOrdersWs:!1,fetchOrderWs:!1,fetchTradesWs:!1,watchBalance:!1,watchMyTrades:!1,watchOHLCV:!0,watchOrderBook:!0,watchOrders:!1,watchTicker:!0,watchTickers:!0,watchTrades:!0,watchTradesForSymbols:!0},urls:{api:{ws:"wss://apiws.p2pb2b.com/"}},options:{OHLCVLimit:1e3,tradesLimit:1e3,timeframes:{"15m":900,"30m":1800,"1h":3600,"1d":86400},watchTicker:{name:"state"},watchTickers:{name:"state"},tickerSubs:this.createSafeDictionary()},streaming:{ping:this.ping}})}async subscribe(e,t,s,i={}){const n=this.urls.api.ws,r={method:e,params:s,id:this.milliseconds()},a=this.extend(r,i);return await this.watch(n,t,a,t)}async watchOHLCV(e,t="15m",s=void 0,i=void 0,n={}){await this.loadMarkets();const r=this.safeValue(this.options,"timeframes",{}),a=this.safeInteger(r,t);if(a===void 0)throw new T(this.id+" watchOHLCV cannot take a timeframe of "+t);const o=this.market(e),c=[o.id,a],u="kline::"+o.symbol,h=await this.subscribe("kline.subscribe",u,c,n);return this.newUpdates&&(i=h.getLimit(e,i)),this.filterBySinceLimit(h,s,i,0,!0)}async watchTicker(e,t={}){await this.loadMarkets();const s=this.safeDict(this.options,"watchTicker");let i=this.safeString(s,"name","state");[i,t]=this.handleOptionAndParams(t,"method","name",i);const n=this.market(e);e=n.symbol,this.options.tickerSubs[n.id]=!0;const r=this.options.tickerSubs,a=Object.keys(r),o=i+"::"+n.symbol;return await this.subscribe(i+".subscribe",o,a,t)}async watchTickers(e=void 0,t={}){await this.loadMarkets(),e=this.marketSymbols(e,void 0,!1);const s=this.safeDict(this.options,"watchTicker");let i=this.safeString(s,"name","state");[i,t]=this.handleOptionAndParams(t,"method","name",i);const n=[],r=[];for(let c=0;c=0){this.handleTicker(e,t);return}else if("trades"in t||"trades_p"in t){this.handleTrades(e,t);return}else if("kline"in t||"kline_p"in t){this.handleOHLCV(e,t);return}else if("book"in t||"orderbook_p"in t){this.handleOrderBook(e,t);return}if("orders"in t||"orders_p"in t){const n=this.safeValue2(t,"orders","orders_p",{});this.handleOrders(e,n)}if("accounts"in t||"accounts_p"in t||"wallets"in t){let n="accounts"in t?"swap":"spot";"accounts_p"in t&&(n="perpetual");const r=this.safeValueN(t,["accounts","accounts_p","wallets"],[]);this.handleBalance(n,e,r)}}handleAuthenticate(e,t){const s=this.safeValue(t,"result"),i=this.safeString(s,"status"),n="authenticated";if(i==="success")e.resolve(t,n);else{const r=new $(this.id+" "+this.json(t));e.reject(r,n),n in e.subscriptions&&delete e.subscriptions[n]}}async subscribePrivate(e,t,s={}){await this.loadMarkets(),await this.authenticate();const i=this.urls.api.ws,n=this.seconds(),r=this.safeValue(s,"settle","")==="USDT";s=this.omit(s,"settle");let a="aop.subscribe";e==="spot"&&(a="wo.subscribe"),r&&(a="aop_p.subscribe");let o={id:n,method:a,params:[]};return o=this.extend(o,s),await this.watch(i,t,o,a)}async authenticate(e={}){this.checkRequiredCredentials();const t=this.urls.api.ws,s=this.client(t),i=this.requestId(),n="authenticated";let r=this.safeValue(s.subscriptions,n);if(r===void 0){const a=this.safeInteger(this.options,"expires",120),o=this.seconds()+a,c=this.apiKey+o.toString(),u=this.hmac(this.encode(c),this.encode(this.secret),He),l={method:"user.auth",params:["API",this.apiKey,u,o],id:i},f=i.toString(),p=this.extend(l,e);n in s.subscriptions||(s.subscriptions[f]=this.handleAuthenticate),r=await this.watch(t,n,p,n),s.subscriptions[n]=r}return r}}class sFe extends G9{describe(){return this.deepExtend(super.describe(),{has:{ws:!0,watchOHLCV:!0,watchOrderBook:!0,watchTicker:!0,watchTickers:!0,watchTrades:!0,watchTradesForSymbols:!0,watchBalance:!0,watchStatus:!1,watchOrders:!0,watchMyTrades:!0,createOrderWs:!0,editOrderWs:!1,fetchOpenOrdersWs:!1,fetchOrderWs:!1,cancelOrderWs:!0,cancelOrdersWs:!0,cancelAllOrdersWs:!0,fetchTradesWs:!1,fetchBalanceWs:!1},urls:{api:{ws:{public:"wss://ws.poloniex.com/ws/public",private:"wss://ws.poloniex.com/ws/private"}}},options:{createMarketBuyOrderRequiresPrice:!0,tradesLimit:1e3,ordersLimit:1e3,OHLCVLimit:1e3,watchOrderBook:{name:"book_lv2"},connectionsLimit:2e3,requestsLimit:500,timeframes:{"1m":"candles_minute_1","5m":"candles_minute_5","10m":"candles_minute_10","15m":"candles_minute_15","30m":"candles_minute_30","1h":"candles_hour_1","2h":"candles_hour_2","4h":"candles_hour_4","6h":"candles_hour_6","12h":"candles_hour_12","1d":"candles_day_1","3d":"candles_day_3","1w":"candles_week_1","1M":"candles_month_1"}},streaming:{keepAlive:15e3,ping:this.ping}})}async authenticate(e={}){this.checkRequiredCredentials();const t=this.numberToString(this.milliseconds()),s=this.urls.api.ws.private,i="authenticated",n=this.client(s);let r=this.safeValue(n.subscriptions,i);if(r===void 0){const o=`GET `+"/ws"+` -signTimestamp=`+t,c=this.hmac(this.encode(o),this.encode(this.secret),He,"base64"),u={event:"subscribe",channel:["auth"],params:{key:this.apiKey,signTimestamp:t,signature:c,signatureMethod:"HmacSHA256",signatureVersion:"2"}},h=this.extend(u,e);r=await this.watch(s,i,h,i),n.subscriptions[i]=r}return r}async subscribe(e,t,s,i=void 0,n={}){const r=s?"private":"public",a=this.urls.api.ws[r],o={event:"subscribe",channel:[e]};let c=[];this.isEmpty(i)?c.push("all"):(t=t+"::"+i.join(","),c=this.marketIds(i)),e!=="balances"&&(o.symbols=c);const u=this.extend(o,n);return await this.watch(a,t,u,t)}async tradeRequest(e,t={}){const s=this.urls.api.ws.private,i=this.nonce().toString(),n={id:i,event:e,params:t};return await this.watch(s,i,n,i)}async createOrderWs(e,t,s,i,n=void 0,r={}){await this.loadMarkets(),await this.authenticate();const a=this.market(e);let o=t.toUpperCase();const c=s.toUpperCase();this.isPostOnly(o==="MARKET",o==="LIMIT_MAKER",r)&&(o="LIMIT_MAKER");const h={symbol:a.id,side:s.toUpperCase(),type:t.toUpperCase()};if(o==="MARKET"&&c==="BUY"){let l,f=!0;[f,r]=this.handleOptionAndParams(r,"createOrder","createMarketBuyOrderRequiresPrice",!0);const p=this.safeNumber(r,"cost");if(r=this.omit(r,"cost"),p!==void 0)l=this.costToPrecision(e,p);else if(f){if(n===void 0)throw new x(this.id+" createOrder() requires the price argument for market buy orders to calculate the total cost to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to false and pass the cost to spend (quote quantity) in the amount argument");{const m=this.numberToString(i),g=this.numberToString(n),y=L.stringMul(m,g);l=this.costToPrecision(e,y)}}else l=this.costToPrecision(e,i);h.amount=l}else h.quantity=this.amountToPrecision(a.symbol,i),n!==void 0&&(h.price=this.priceToPrecision(e,n));return await this.tradeRequest("createOrder",this.extend(h,r))}async cancelOrderWs(e,t=void 0,s={}){const i=this.safeString(s,"clientOrderId");if(i!==void 0){const n=this.safeValue(s,"clientOrderId",[]);s.clientOrderIds=this.arrayConcat(n,[i])}return await this.cancelOrdersWs([e],t,s)}async cancelOrdersWs(e,t=void 0,s={}){await this.loadMarkets(),await this.authenticate();const i={orderIds:e};return await this.tradeRequest("cancelOrders",this.extend(i,s))}async cancelAllOrdersWs(e=void 0,t={}){return await this.loadMarkets(),await this.authenticate(),await this.tradeRequest("cancelAllOrders",t)}handleOrderRequest(e,t){const s=this.safeString(t,"id"),i=this.safeValue(t,"data",[]),n=[];for(let r=0;r0&&r.call(this,e,t)}handleErrorMessage(e,t){const s=this.safeString(t,"id"),i=this.safeString(t,"event"),n=this.safeList(t,"data"),r=this.safeDict(n,0),a=this.safeString(r,"orderId");if(i==="error"||a==="0")try{const o=this.safeString(r,"message"),c=this.safeString(r,"code"),u=this.id+" "+this.json(t);throw this.throwExactlyMatchedException(this.exceptions.exact,c,u),this.throwBroadlyMatchedException(this.exceptions.broad,o,u),new I(u)}catch(o){if(o instanceof $){const c="authenticated";e.reject(o,c),c in e.subscriptions&&delete e.subscriptions[c]}else e.reject(o,s);return!0}return!1}handleAuthenticate(e,t){const s=this.safeValue(t,"data"),i=this.safeValue(s,"success"),n="authenticated";if(i)e.resolve(t,n);else{const r=new $(this.id+" "+this.json(t));e.reject(r,n),n in e.subscriptions&&delete e.subscriptions[n]}return t}ping(e){return{event:"ping"}}}class iFe extends U9{describe(){return this.deepExtend(super.describe(),{has:{ws:!0,cancelAllOrdersWs:!1,cancelOrdersWs:!1,cancelOrderWs:!1,createOrderWs:!1,editOrderWs:!1,fetchBalanceWs:!1,fetchOpenOrdersWs:!1,fetchOrderWs:!1,fetchTradesWs:!1,watchOHLCV:!1,watchOrderBook:!0,watchTicker:!0,watchTickers:!1,watchTrades:!0,watchTradesForSymbols:!1,watchBalance:!0,watchOrders:!0,watchMyTrades:!1,watchPosition:void 0,watchPositions:!1},urls:{api:{ws:"wss://futures-apiws.poloniex.com/endpoint"}},options:{tradesLimit:1e3,ordersLimit:1e3,watchTicker:{method:"/contractMarket/ticker"},watchOrders:{method:"/contractMarket/tradeOrders"},watchOrderBook:{method:"/contractMarket/level2",snapshotDelay:5,snapshotMaxRetries:3,checksum:!0},streamLimit:5,streamBySubscriptionsHash:{},streamIndex:-1},streaming:{keepAlive:3e4,maxPingPongMisses:2}})}async negotiate(e,t={}){const s=e?"private":"public",i=this.safeValue(this.options,"urls",{});return s in i?await i[s]:(i[s]=this.spawn(this.negotiateHelper,e,t),this.options.urls=i,await i[s])}async negotiateHelper(e,t={}){let s;const i=e?"private":"public";try{e?s=await this.privatePostBulletPrivate(t):s=await this.publicPostBulletPublic(t);const n=this.safeValue(s,"data",{}),r=this.safeValue(n,"instanceServers",[]),a=this.safeValue(r,0),o=this.safeInteger(a,"pingInterval"),c=this.safeString(a,"endpoint"),u=this.safeString(n,"token"),h=c+"?"+this.urlencode({token:u,privateChannel:e,connectId:i}),l=this.client(h);return l.keepAlive=o,h}catch(n){this.safeValue(this.options.urls,i).reject(n),delete this.options.urls[i]}}requestId(){const e=this.sum(this.safeInteger(this.options,"requestId",0),1);return this.options.requestId=e,e}async subscribe(e,t,s=void 0,i=void 0,n={}){const r=await this.negotiate(t);if(s!==void 0){const p=this.market(s).id;e+=":"+p}const a=e,o=await this.stream(r,a),c=this.requestId(),u={id:c,type:"subscribe",topic:e,privateChannel:t,response:!0,tunnelId:o},h={id:c};i===void 0?i=h:i=this.extend(h,i);const l=this.extend(u,n);return await this.watch(r,a,l,e,h)}onClose(e,t){this.options.streamBySubscriptionsHash={},super.onClose(e,t)}async stream(e,t){const s=this.safeValue(this.options,"streamBySubscriptionsHash",{});let i=this.safeString(s,t);if(i===void 0){let n=this.safeInteger(this.options,"streamIndex",-1);const r=this.safeValue(this.options,"streamLimit");n=n+1;const a=n%r;this.options.streamIndex=n,i="stream-"+this.numberToString(a),this.options.streamBySubscriptionsHash[t]=i;const c="tunnel:"+i,u={id:c,type:"openTunnel",newTunnelId:i,response:!0},h={id:c,method:this.handleNewStream};await this.watch(e,c,u,c,h)}return i}handleOrderBookSubscription(e,t,s){const i=this.safeString(s,"symbol"),n=this.safeInteger(s,"limit");this.orderbooks[i]=this.orderBook({},n)}handleSubscriptionStatus(e,t){const s=this.safeString(t,"id"),i=this.indexBy(e.subscriptions,"id"),n=this.safeValue(i,s,{}),r=this.safeValue(n,"method");return r!==void 0&&r.call(this,e,t,n),t}handleNewStream(e,t,s){const i=this.safeString(t,"id");e.resolve(t,i)}async watchTicker(e,t={}){return await this.loadMarkets(),e=this.symbol(e),await this.subscribe("/contractMarket/ticker",!1,e,void 0,t)}async watchTrades(e,t=void 0,s=void 0,i={}){await this.loadMarkets();const n=this.safeValue(this.options,"watchTrades");let r=this.safeString(n,"method","/contractMarket/execution");[r,i]=this.handleOptionAndParams(i,"method","name",r),e=this.symbol(e);const a=await this.subscribe(r,!1,e,void 0,i);return this.newUpdates&&(s=a.getLimit(e,s)),this.filterBySinceLimit(a,t,s,"timestamp",!0)}async watchOrderBook(e,t=void 0,s={}){await this.loadMarkets();const i=this.safeValue(this.options,"watchOrderBook");let n=this.safeString(i,"method","/contractMarket/level2");if([n,s]=this.handleOptionAndParams(s,"method","name",n),n==="/contractMarket/level2"&&t!==void 0){if(t!==5&&t!==50)throw new T(this.id+" watchOrderBook limit argument must be none, 5 or 50 if using method /contractMarket/level2");n+="Depth"+this.numberToString(t)}const r={symbol:e,limit:t,method:this.handleOrderBookSubscription};return(await this.subscribe(n,!1,e,r,s)).limit()}async watchOrders(e=void 0,t=void 0,s=void 0,i={}){await this.loadMarkets();const n=this.safeValue(this.options,"watchOrders"),r=this.safeString(n,"method","/contractMarket/tradeOrders");let a=await this.subscribe(r,!0,void 0,void 0,i);return this.newUpdates&&(s=a.getLimit(e,s)),a=this.filterBySymbolSinceLimit(a,e,t,s),a.length===0?await this.watchOrders(e,t,s,i):a}async watchBalance(e={}){return await this.loadMarkets(),await this.subscribe("/contractAccount/wallet",!0,void 0,void 0,e)}handleTrade(e,t){const s=this.safeValue(t,"data",{}),i=this.safeString(s,"symbol");if(i!==void 0){const n=this.parseWsTrade(s),r=n.symbol,a="/contractMarket/execution:"+i;let o=this.safeValue(this.trades,r);if(o===void 0){const c=this.safeInteger(this.options,"tradesLimit",1e3);o=new ct(c),this.trades[r]=o}o.append(n),e.resolve(o,a)}return t}parseWsTrade(e,t=void 0){const s=this.safeString(e,"symbol");t=this.safeMarket(s,t);const i=this.safeIntegerProduct(e,"ts",1e-6);return this.safeTrade({info:e,id:this.safeString(e,"tradeId"),symbol:this.safeString(t,"symbol"),timestamp:i,datetime:this.iso8601(i),order:this.safeString2(e,"takerOrderId","makerOrderId"),type:void 0,side:this.safeString(e,"side"),takerOrMaker:void 0,price:this.safeString(e,"price"),amount:this.safeString2(e,"matchSize","size"),cost:void 0,fee:void 0},t)}parseWsOrderTrade(e,t=void 0){const s=this.safeInteger(e,"tradeTime"),i=this.safeString(e,"symbol");return this.safeTrade({info:e,id:this.safeString(e,"tradeId"),symbol:this.safeSymbol(i,t),timestamp:s,datetime:this.iso8601(s),order:this.safeString(e,"orderId"),type:this.safeStringLower(e,"type"),side:this.safeString(e,"side"),takerOrMaker:this.safeStringLower(e,"matchRole"),price:this.safeString(e,"price"),amount:this.safeString(e,"tradeAmount"),cost:void 0,fee:{rate:void 0,cost:this.safeString(e,"tradeFee"),currency:this.safeString(e,"feeCurrency")}},t)}handleOrder(e,t){const s=this.safeValue(t,"data",{});let i=this.orders;if(i===void 0){const a=this.safeInteger(this.options,"ordersLimit");i=new tt(a),this.orders=i}const n="/contractMarket/tradeOrders",r=this.parseWsOrder(s);return i.append(r),e.resolve(i,n),t}parseOrderStatus(e,t){const s={canceled:"canceled",cancel:"canceled",filled:"closed"};let i=this.safeString(s,t);if(i===void 0){const n={open:"open",match:"open",done:"closed"};i=this.safeString(n,e,e)}return i}parseWsOrder(e,t=void 0){const s=this.safeString(e,"orderId"),i=this.safeString(e,"clientOid"),n=this.safeString(e,"symbol"),r=this.safeIntegerProduct2(e,"orderTime","ts",1e-6),a=this.safeString(e,"status"),o=this.safeString(e,"type");return this.safeOrder({info:e,symbol:this.safeSymbol(n,t),id:s,clientOrderId:i,timestamp:r,datetime:this.iso8601(r),lastTradeTimestamp:void 0,type:this.safeString(e,"orderType"),timeInForce:void 0,postOnly:void 0,side:this.safeString(e,"side"),price:this.safeString2(e,"price","orderPrice"),stopPrice:this.safeString(e,"stopPrice"),triggerPrice:void 0,amount:this.safeString(e,"size"),cost:void 0,average:void 0,filled:this.safeString(e,"filledSize"),remaining:this.safeString(e,"remainSize"),status:this.parseOrderStatus(a,o),fee:void 0,trades:void 0})}handleTicker(e,t){const s=this.safeValue(t,"data",{}),i=this.safeString(t,"topic"),n=this.getSymbolFromTopic(i);if(n!==void 0){const r=this.parseTicker(s);this.tickers[n]=r,e.resolve(r,i)}return t}handleL3OrderBook(e,t){const s=this.safeString(t,"topic");this.safeString(t,"subject")!=="received"&&e.resolve(t,s)}handleLevel2(e,t){if(this.safeString(t,"topic").indexOf("Depth")>=0){this.handeL2Snapshot(e,t);return}this.handleL2OrderBook(e,t)}handleL2OrderBook(e,t){const s=this.safeValue(t,"data",{}),i=this.safeString(t,"topic",""),n=this.getSymbolFromTopic(i);let r=this.safeValue(this.orderbooks,n);if(r===void 0&&(this.orderbooks[n]=this.orderBook({}),r=this.orderbooks[n],r.symbol=n),this.safeInteger(r,"nonce")===void 0){const o=r.cache.length,c=this.handleOption("watchOrderBook","snapshotDelay",5);o===c&&this.spawn(this.loadOrderBook,e,i,n,0,{}),r.cache.push(s);return}try{this.handleDelta(r,s),e.resolve(r,i)}catch(o){delete this.orderbooks[n],e.reject(o,i)}}handeL2Snapshot(e,t){const s=this.safeValue(t,"data",{}),i=this.safeString(t,"topic",""),n=this.getSymbolFromTopic(i),r=this.safeInteger(s,"timestamp"),a=this.parseOrderBook(s,n,r,"bids","asks"),o=this.orderBook(a);this.orderbooks[n]=o,e.resolve(o,i)}getSymbolFromTopic(e){const t=e.split(":"),s=this.safeString(t,1);return this.safeSymbol(s)}getCacheIndex(e,t){const s=this.safeValue(t,0),i=this.safeInteger(e,"nonce");if(this.safeInteger(s,"sequence")>i+1)return-1;for(let r=0;rs)return;if(n!==i&&this.handleOption("watchOrderBook","checksum",!0))throw new $r(this.id+" "+this.orderbookChecksumMessage(""));const r=this.safeList(t,"changes");for(let o=0;on){const a=await this.signIn(),c={type:"authorization",token:this.safeString(a,"access_token")};r=await this.watch(t,i,this.extend(c,e),i),s.subscriptions[i]=r}return r}}class rFe extends j9{describe(){return this.deepExtend(super.describe(),{has:{ws:!0,watchOrderBook:!0,watchTicker:!0,watchTickers:!0,watchTrades:!0,watchTradesForSymbols:!0,watchOrders:!0,watchMyTrades:!0,watchBalance:!0},urls:{api:{ws:"wss://{hostname}/websocket/v1"}},options:{tradesLimit:1e3}})}async watchPublic(e,t,s={}){await this.loadMarkets();const i=this.market(e);e=i.symbol;const n=i.id,r=this.implodeParams(this.urls.api.ws,{hostname:this.hostname});this.options[t]=this.safeValue(this.options,t,{}),this.options[t][e]=!0;const a=Object.keys(this.options[t]),o=this.marketIds(a),c=[{ticket:this.uuid()},{type:t,codes:o}],u=t+":"+n;return await this.watch(r,u,c,u)}async watchPublicMultiple(e,t,s={}){await this.loadMarkets(),e===void 0&&(e=this.symbols),e=this.marketSymbols(e);const i=this.marketIds(e),n=this.implodeParams(this.urls.api.ws,{hostname:this.hostname}),r=[];for(let o=0;oa&&(this.handleOrderBookMessage(e,t,r),e.resolve(r,s+"@book_depth"))}handleOrderBookMessage(e,t,s){const i=this.parseToInt(L.stringDiv(this.safeString(t,"last_max_timestamp"),"1000000")),n={bids:[],asks:[]},r=this.safeList(t,"bids",[]);for(let o=0;o1)throw new q(this.id+" watchPositions require only one symbol.");let n;[n,i]=this.handlePublicAddress("watchPositions",i);const r=this.urls.api.ws,a=this.client(r);this.setPositionsCache(a,e,i);const o=this.handleOption("watchPositions","fetchPositionsSnapshot",!0),c=this.handleOption("watchPositions","awaitPositionsSnapshot",!0);if(o&&c&&this.positions===void 0){const g=await a.future("fetchPositionsSnapshot");return this.filterBySymbolsSinceLimit(g,e,t,s,!0)}const u="position_change",h=this.market(e[0]),l=h.id+"@"+u,f={method:"subscribe",stream:{type:u,product_id:this.parseToNumeric(h.id),subaccount:this.convertAddressToSender(n)}},p=this.extend(f,i),m=await this.watchPublic(l,p);return this.newUpdates&&(s=m.getLimit(e[0],s)),this.filterBySymbolsSinceLimit(this.positions,e,t,s,!0)}setPositionsCache(e,t=void 0,s={}){if(this.handleOption("watchPositions","fetchPositionsSnapshot",!1)){const n="fetchPositionsSnapshot";n in e.futures||(e.future(n),this.spawn(this.loadPositionsSnapshot,e,n,t,s))}else this.positions=new Ks}async loadPositionsSnapshot(e,t,s,i){const n=await this.fetchPositions(s,i);this.positions=new Ks;const r=this.positions;for(let o=0;o-1){o[c[u]].call(this,e,t);return}throw new q(this.id+" this message type is not supported yet. Message: "+this.json(t))}async authenticate(e={}){const t=this.urls.api.ws,s=this.client(t),i="authenticated",n=this.milliseconds();let r=this.safeValue(s.subscriptions,i);const a=this.safeInteger(r,"expires");return(r===void 0||n>a)&&(r=await this.privatePostCreateAuthToken(),r.expires=n+this.safeInteger(r,"timeout_duration")*1e3,s.subscriptions[i]=r),this.safeString(r,"auth_key")}}class dFe extends K9{describe(){return this.deepExtend(super.describe(),{has:{ws:!0,watchBalance:!0,watchMyTrades:!0,watchOHLCV:!0,watchOrderBook:!0,watchOrders:!0,watchTicker:!0,watchTickers:!0,watchTrades:!0,watchTradesForSymbols:!1},urls:{api:{ws:"wss://api.whitebit.com/ws"}},options:{timeframes:{"1m":"60","5m":"300","15m":"900","30m":"1800","1h":"3600","4h":"14400","8h":"28800","1d":"86400","1w":"604800"},watchOrderBook:{priceInterval:0}},streaming:{ping:this.ping},exceptions:{ws:{exact:{1:T,2:T,4:T,6:$}}}})}async watchOHLCV(e,t="1m",s=void 0,i=void 0,n={}){await this.loadMarkets();const r=this.market(e);e=r.symbol;const a=this.safeValue(this.options,"timeframes",{}),o=this.safeInteger(a,t),c=r.id,u="candles:"+e,h=[c,o],f=await this.watchPublic(u,"candles_subscribe",h,n);return this.newUpdates&&(i=f.getLimit(e,i)),this.filterBySinceLimit(f,s,i,0,!0)}handleOHLCV(e,t){const s=this.safeValue(t,"params",[]);for(let i=0;i=0&&l.indexOf(r)>=0&&e.resolve(c,l)}return t}async watchTrades(e,t=void 0,s=void 0,i={}){await this.loadMarkets(),e=this.market(e).symbol;const r="trades:"+e,o=await this.watchMultipleSubscription(r,"trades_subscribe",e,!1,i);return this.newUpdates&&(s=o.getLimit(e,s)),this.filterBySinceLimit(o,t,s,"timestamp",!0)}handleTrades(e,t){const s=this.safeValue(t,"params",[]),i=this.safeString(s,0),n=this.safeMarket(i),r=n.symbol;let a=this.safeValue(this.trades,r);if(a===void 0){const h=this.safeInteger(this.options,"tradesLimit",1e3);a=new ct(h),this.trades[r]=a}const o=this.safeValue(s,1,[]),c=this.parseTrades(o,n);for(let h=0;h=0?h+="spot":h+="margin",e.resolve(this.balance,h)}async watchPublic(e,t,s=[],i={}){const n=this.urls.api.ws,a={id:this.nonce(),method:t,params:s},o=this.extend(a,i);return await this.watch(n,e,o,e)}async watchMultipleSubscription(e,t,s,i=!1,n={}){await this.loadMarkets();const r=this.urls.api.ws,a=this.nonce(),o=this.safeValue(this.clients,r);let c,u=[];if(o===void 0){const h={},f=this.market(s).id;h[f]=!0,u=[f],i&&(u=[u]),c={id:a,method:t,params:u};const p=this.extend(c,n);return await this.watch(r,e,p,t,h)}else{const h=this.safeValue(o.subscriptions,t,{});let l=!0;const p=this.market(s).id;if(this.safeBool(h,p,!1)||(h[p]=!0,l=!1),l)return await this.watch(r,e,c,t,h);{let g=[];g=Object.keys(h),i&&(g=[g]);const y={id:a,method:t,params:g};return t in o.subscriptions&&delete o.subscriptions[t],await this.watch(r,e,y,t,h)}}}async watchPrivate(e,t,s=[],i={}){this.checkRequiredCredentials(),await this.authenticate();const n=this.urls.api.ws,a={id:this.nonce(),method:t,params:s},o=this.extend(a,i);return await this.watch(n,e,o,e)}async authenticate(e={}){this.checkRequiredCredentials();const t=this.urls.api.ws,s="authenticated",i=this.client(t),n=i.future("authenticated");if(this.safeValue(i.subscriptions,s)===void 0){const a=await this.v4PrivatePostProfileWebsocketToken(),o=this.safeString(a,"websocket_token"),c=this.nonce(),u={id:c,method:"authorize",params:[o,"public"]},h={id:c,method:this.handleAuthenticate};try{await this.watch(t,s,u,s,h)}catch(l){delete i.subscriptions[s],n.reject(l)}}return await n}handleAuthenticate(e,t){return e.futures.authenticated.resolve(1),t}handleErrorMessage(e,t){const s=this.safeValue(t,"error");try{if(s!==void 0){const i=this.safeString(t,"code"),n=this.id+" "+this.json(t);this.throwExactlyMatchedException(this.exceptions.ws.exact,i,n)}}catch(i){if(i instanceof $)return e.reject(i,"authenticated"),"authenticated"in e.subscriptions&&delete e.subscriptions.authenticated,!1}return t}handleMessage(e,t){if(!this.handleErrorMessage(e,t))return;if(this.safeString(t,"result")==="pong"){this.handlePong(e,t);return}const i=this.safeInteger(t,"id");if(i!==void 0){this.handleSubscriptionStatus(e,t,i);return}const n={market_update:this.handleTicker,trades_update:this.handleTrades,depth_update:this.handleOrderBook,candles_update:this.handleOHLCV,ordersPending_update:this.handleOrder,ordersExecuted_update:this.handleOrder,balanceSpot_update:this.handleBalance,balanceMargin_update:this.handleBalance,deals_update:this.handleMyTrades},r=this.safeValue(t,"method"),a=this.safeValue(n,r);a!==void 0&&a.call(this,e,t)}handleSubscriptionStatus(e,t,s){const i=e.subscriptions,n=Object.values(i);for(let r=0;ru&&(this.handleOrderBookMessage(e,t,c),e.resolve(c,a))}catch(h){delete this.orderbooks[r],delete e.subscriptions[a],e.reject(h,a)}}else{if(!(r in this.orderbooks)){const l=this.safeInteger(this.options,"watchOrderBookLimit",1e3),f=e.subscriptions[a],p=this.safeInteger(f,"limit",l);this.orderbooks[r]=this.orderBook({},p)}const c=this.orderbooks[r],u=this.safeInteger(t,"ts"),h=this.parseOrderBook(s,r,u,"bids","asks");c.reset(h),e.resolve(c,a)}}handleOrderBookSubscription(e,t,s){const i=this.safeInteger(this.options,"watchOrderBookLimit",1e3),n=this.safeInteger(s,"limit",i),r=this.safeString(s,"symbol");r in this.orderbooks&&delete this.orderbooks[r],this.orderbooks[r]=this.orderBook({},n),this.spawn(this.fetchOrderBookSnapshot,e,t,s)}async fetchOrderBookSnapshot(e,t,s){const i=this.safeString(s,"symbol"),n=this.safeString(t,"topic");try{const r=this.safeInteger(this.options,"watchOrderBookLimit",1e3),a=this.safeInteger(s,"limit",r),o=this.safeValue(s,"params"),c=await this.fetchRestOrderBookSafe(i,a,o);if(this.safeValue(this.orderbooks,i)===void 0)return;const u=this.orderbooks[i];u.reset(c);const h=u.cache;for(let l=0;l=m&&(g-=m);const y=this.safeString(e,"status"),w=this.parseOrderStatus(y),b=void 0,S=this.safeString(e,"clientOrderId");return this.safeOrder({info:e,symbol:n,id:s,clientOrderId:S,timestamp:r,datetime:this.iso8601(r),lastTradeTimestamp:r,type:f,timeInForce:void 0,postOnly:void 0,side:l,price:c,stopPrice:void 0,triggerPrice:void 0,amount:h,cost:void 0,average:u,filled:p,remaining:g,status:w,fee:a,trades:b})}handleOrderUpdate(e,t){const s=this.safeString(t,"topic"),i=this.safeValue(t,"data");if(Array.isArray(i))for(let n=0;n0&&i.append(a)}e.futures[t].resolve(i),e.resolve(i,"positions")}handlePositions(e,t){const s=this.safeValue(t,"data",{}),i=this.safeValue(s,"positions",{}),n=Object.keys(i);this.positions===void 0&&(this.positions=new Ks);const r=this.positions,a=[];for(let o=0;o=0&&(u=u.split("ed25519:")[1]);const h=lg(this.encode(c),this.base58ToBinary(u),ni),l={event:n,params:{orderly_key:this.apiKey,sign:h,timestamp:o}},f=this.extend(l,e);this.watch(t,i,f,i)}return await r}async watchPrivate(e,t,s={}){await this.authenticate(s);const i=this.urls.api.ws.private+"/"+this.accountId,r={id:this.requestId(i)},a=this.extend(r,t);return await this.watch(i,e,a,e,r)}async watchPrivateMultiple(e,t,s={}){await this.authenticate(s);const i=this.urls.api.ws.private+"/"+this.accountId,r={id:this.requestId(i)},a=this.extend(r,t);return await this.watchMultiple(i,e,a,e,r)}async watchOrders(e=void 0,t=void 0,s=void 0,i={}){await this.loadMarkets();const r=this.safeBool2(i,"stop","trigger",!1)?"algoexecutionreport":"executionreport";i=this.omit(i,["stop","trigger"]);let a=r;e!==void 0&&(e=this.market(e).symbol,a+=":"+e);const o={event:"subscribe",topic:r},c=this.extend(o,i),u=await this.watchPrivate(a,c);return this.newUpdates&&(s=u.getLimit(e,s)),this.filterBySymbolSinceLimit(u,e,t,s,!0)}async watchMyTrades(e=void 0,t=void 0,s=void 0,i={}){await this.loadMarkets();const r=this.safeBool2(i,"stop","trigger",!1)?"algoexecutionreport":"executionreport";i=this.omit(i,"stop");let a="myTrades";e!==void 0&&(e=this.market(e).symbol,a+=":"+e);const o={event:"subscribe",topic:r},c=this.extend(o,i),u=await this.watchPrivate(a,c);return this.newUpdates&&(s=u.getLimit(e,s)),this.filterBySymbolSinceLimit(u,e,t,s,!0)}parseWsOrder(e,t=void 0){const s=this.safeString(e,"orderId"),i=this.safeString(e,"symbol");t=this.market(i);const n=t.symbol,r=this.safeInteger(e,"timestamp"),a={cost:this.safeString(e,"totalFee"),currency:this.safeString(e,"feeAsset")},o=this.safeString(e,"price");let c=this.safeNumber(e,"price");const u=this.safeNumber(e,"avgPrice");L.stringEq(o,"0")&&u!==void 0&&(c=u);const h=this.safeString(e,"quantity"),l=this.safeStringLower(e,"side"),f=this.safeStringLower(e,"type"),p=this.safeNumber(e,"totalExecutedQuantity"),m=this.safeString(e,"totalExecutedQuantity");let g=h;L.stringGe(h,m)&&(g=L.stringSub(g,m));const y=this.safeString(e,"status"),w=this.parseOrderStatus(y),b=void 0,S=this.safeString(e,"clientOrderId"),v=this.safeNumber(e,"triggerPrice");return this.safeOrder({info:e,symbol:n,id:s,clientOrderId:S,timestamp:r,datetime:this.iso8601(r),lastTradeTimestamp:r,type:f,timeInForce:void 0,postOnly:void 0,side:l,price:c,stopPrice:v,triggerPrice:v,amount:h,cost:void 0,average:void 0,filled:p,remaining:g,status:w,fee:a,trades:b})}handleOrderUpdate(e,t){const s=this.safeString(t,"topic"),i=this.safeValue(t,"data");if(Array.isArray(i))for(let n=0;n=s)return r}return t.length}handleDelta(e,t){e.nonce=this.safeInteger2(t,"i","u");const s=this.safeList(t,"a",[]),i=this.safeList(t,"b",[]),n=e.bids,r=e.asks;for(let a=0;a0&&e.resolve(m,h)}return e.resolve(this.tickers,o),t}handleOHLCV(e,t){const s=this.safeDict(t,"data",{}),i=this.safeString(s,"s");if(i!==void 0){const n=this.safeString(s,"i"),r="q"in s?"spot":"contract",a=this.safeMarket(i,void 0,void 0,r),o=a.symbol,c=this.parseOHLCV(s,a);this.ohlcvs[o]=this.safeDict(this.ohlcvs,o,{});let u=this.safeValue(this.ohlcvs[o],n);if(u===void 0){const f=this.safeInteger(this.options,"OHLCVLimit",1e3);u=new Jt(f),this.ohlcvs[o][n]=u}u.append(c);const l=this.safeString(t,"event")+"::"+r;e.resolve(u,l)}return t}handleTrade(e,t){const s=this.safeDict(t,"data"),i=this.safeStringLower(s,"s");if(i!==void 0){const n=this.parseTrade(s),a=this.safeString(s,"i")!==void 0?"spot":"contract",c=this.safeMarket(i,void 0,void 0,a).symbol,u=this.safeString(t,"event");let h=this.safeValue(this.trades,c);if(h===void 0){const f=this.safeInteger(this.options,"tradesLimit",1e3);h=new ct(f),this.trades[c]=h}h.append(n);const l=u+"::"+a;e.resolve(h,l)}return t}handleOrderBook(e,t){const s=this.safeDict(t,"data"),i=this.safeString(s,"s");if(i!==void 0){let n=this.safeString(t,"event");const r=n.split(",");n=this.safeString(r,0);const a="fu"in s?"contract":"spot",c=this.safeMarket(i,void 0,void 0,a).symbol,u=this.safeList(s,"a"),h=this.safeList(s,"b"),l=n+"::"+a;if(!(c in this.orderbooks)){const g=this.safeDict(e.subscriptions,l,{}),y=this.safeInteger(g,"limit");this.orderbooks[c]=this.orderBook({},y)}const f=this.orderbooks[c];if(this.safeInteger(f,"nonce")===void 0){const g=f.cache.length,y=this.handleOption("watchOrderBook","snapshotDelay",25);g===y&&this.spawn(this.loadOrderBook,e,l,c),f.cache.push(s);return}if(u!==void 0){const g=f.asks;for(let y=0;ysetTimeout(e,d))}function fFe(d,e,t,s){B.useEffect(()=>{if(!d.current)return;let i=!0;return(async()=>{for(console.log(`WS: Subscribed to ${t} candle of ${e}`);i;)try{const a=(await d.current.watchOHLCV(e,t)).at(-1);i&&s(a)}catch(r){if(r instanceof qs)console.log("WS: Socket connection closed. Delaying for 1s before reconnecting.",r),await lFe(1e3);else throw r}})(),()=>{i=!1,console.log("WS: Unsubscribed")}},[d,e,t])}const pFe={[Xa.OKX]:"okx",[Xa.BYBIT]:"bybit",[Xa.BITGET]:"bitget",[Xa.BINANCE]:"binance",[Xa.KRAKEN]:"kraken",[Xa.COINBASE]:"coinbase",[Xa.GATEIO]:"gateio"};function mFe(d){const e=pFe[d];return new Aw[e]}function gFe(d,e){const[t,s,i,n,r,a]=e;console.log(d,"open",s,"high",i,"low",n,"close",r,"volume",a,"timestamp",t,new Date(t).toISOString())}function yFe(d){const e=B.useRef(null);return B.useEffect(()=>{e.current=mFe(d)},[d]),e}function wFe(d){return YL(Date.now(),d)}function yF(d){const e=wFe(d);return n$(e,d)}function n$(d,e){const t=Eue(e);return d-t*vj}function bFe(d,e,t){const s=yFe(d),i=async(f,p,m)=>await s.current.fetchOHLCV(f,m,p,vj),n=B.useRef(!1),[r,a]=B.useState([]),[o,c]=B.useState(yF(t)),u=()=>{a([]),c(yF(t))};[cm(d),cm(e),cm(t)].includes(!0)&&u(),B.useEffect(()=>{let f=!0;return n.current=!0,i(e,o,t).then(p=>{f&&(a(m=>[...p,...m]),n.current=!1)}),()=>{f=!1}},[d,e,t,o]);const l=()=>{n.current||c(n$(o,t))};return fFe(s,e,t,f=>{const[p]=f;a(m=>m.some(y=>y[0]===p)?[...m.slice(0,-1),f]:(gFe(`WS: New ${t} candle`,f),[...m,f]))}),{candlesticks:r,fetchPrev:l}}const kFe=({children:d})=>P.jsx(dg,{sx:{position:"absolute",zIndex:2,top:4,left:4,borderRadius:4,p:1,display:"flex",justifyContent:"space-between",alignItems:"center",backgroundColor:"transparent"},children:d}),ux=14;function SFe(d){return(typeof d=="number"?d.toFixed(2):d).length*(ux*.85)}function vFe(d,e){const t=e-d,s=t/d*100,i=Math.abs(s);return t<0?`-${i.toFixed(2)}%`:t>0?`+${s.toFixed(2)}%`:"0%"}const r$=({color:d,children:e})=>P.jsx(_t,{sx:t=>({color:d==="success"?t.vars.palette.success.plainColor:t.vars.palette.danger.plainColor,display:"inline"}),children:e}),RS=({prefix:d,price:e,color:t})=>P.jsxs(_t,{sx:{lineHeight:1,fontSize:ux,width:SFe(e)},children:[d,":",P.jsx(r$,{color:t,children:e.toFixed(2)})]}),TFe=({open:d,close:e,color:t})=>{const s=e-d,i=Math.abs(s).toFixed(2),n=s>0?"+":"-",r=vFe(d,e);return P.jsx(_t,{sx:{lineHeight:1,fontSize:ux},children:P.jsxs(r$,{color:t,children:[n,i," (",r,")"]})})},OFe=({open:d,high:e,low:t,close:s})=>{const i=sP.jsx(_t,{sx:{lineHeight:1,fontSize:ux,mr:2},children:d});function PFe(d){const[e,t,s,i,n]=d;return{time:Sj(e),open:t,high:s,low:i,close:n}}const IFe=({symbolId:d,barSize:e,priceLines:t,dimmed:s,showPriceLines:i,markers:n,showMarkers:r,sx:a})=>{const[o]=kt.symbol.getOne.useSuspenseQuery({symbolId:d}),{candlesticks:c,fetchPrev:u}=bFe(o.exchangeCode,o.currencyPair,e),h=FMe({onScrollLeft:()=>{u()}});B.useEffect(()=>{var b,S,v;(b=h.series.current)==null||b.setData(c.map(PFe)),c.length===0&&((S=h.api.current)==null||S.timeScale().resetTimeScale(),(v=h.api.current)==null||v.priceScale("right").applyOptions({autoScale:!0}))},[c]),B.useEffect(()=>{if(!h.series.current||!t||!i)return;const w=h.series.current,b=t.map(S=>w.createPriceLine(S));return()=>{b.forEach(S=>{var v;(v=h.series.current)==null||v.removePriceLine(S)})}},[t,i]),B.useEffect(()=>!h.series.current||!n||!r?void 0:(h.series.current.setMarkers(n),()=>{var b;(b=h.series.current)==null||b.setMarkers([])}),[n,r]);const l=B.useRef(null),{width:f,height:p}=rIe({ref:l});B.useEffect(()=>{var w;(w=h.api.current)==null||w.applyOptions({width:f,height:p})},[f,p]);const[m,g]=B.useState(),y=B.useCallback(w=>{const b=w.seriesData.get(h.series.current);g(b||null)},[]);return B.useEffect(()=>{var w;return(w=h.api.current)==null||w.subscribeCrosshairMove(y),()=>{var b;(b=h.api.current)==null||b.unsubscribeCrosshairMove(y)}},[]),P.jsxs(_t,{ref:l,sx:{height:Xo,opacity:s?.5:1,transition:s?"opacity 0.1s 0.1s linear":"opacity 0s 0s linear",position:"relative",...a},children:[P.jsxs(kFe,{children:[P.jsx(xFe,{children:d}),m?P.jsx(OFe,{...m}):null]}),P.jsx("div",{ref:h.ref,style:{width:"100%",height:"100%"}})]})},CFe=({children:d})=>P.jsx(_t,{sx:{display:"flex",mb:1,gridGap:8},children:d}),MFe=({children:d})=>P.jsx(_t,{style:{width:"100%"},children:d}),hx=d=>{const{children:e,...t}=d;return P.jsxs(MFe,{children:[P.jsx(CFe,{children:e}),P.jsx(IFe,{...t,sx:{borderRadius:6,overflow:"hidden",border:"1px solid var(--joy-palette-neutral-outlinedBorder)"}})]})},_Fe=Ys(P.jsx("path",{d:"M3 3h18v2H3zm0 16h18v2H3zm0-8h18v2H3z"}),"DensityMedium"),AFe=Ys(P.jsx("path",{d:"M12 7c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.24 5-5-2.24-5-5-5m0-5C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"}),"RadioButtonChecked"),wF=d=>e=>({backgroundColor:e?d:void 0,"&:hover":{backgroundColor:e?d:"unset"}}),lx=({gridVisible:d,onGridVisibleChange:e,hideGridButton:t,tradesVisible:s,onTradesVisibleChange:i,hideTradesButton:n})=>P.jsxs(sOe,{size:"sm",variant:"outlined",children:[t?null:P.jsx(Es,{color:d?"primary":"neutral",onClick:()=>e==null?void 0:e(!d),startDecorator:P.jsx(_Fe,{}),sx:r=>({...wF(r.vars.palette.primary.outlinedHoverBg)(d)}),children:"Grid"}),n?null:P.jsx(Es,{color:s?"success":"neutral",onClick:()=>i==null?void 0:i(!s),startDecorator:P.jsx(AFe,{}),sx:r=>({...wF(r.vars.palette.success.outlinedHoverBg)(s)}),children:"Trades"})]}),LFe=kf(P.jsx("path",{d:"M7 10l5 5 5-5z"}),"ArrowDropDown"),BFe=kf(P.jsx("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 12z"}),"Cancel");function NFe(d){return Rt("MuiChipDelete",d)}Dt("MuiChipDelete",["root","disabled","focusVisible","colorPrimary","colorNeutral","colorDanger","colorSuccess","colorWarning","colorContext","variantPlain","variantSolid","variantSoft","variantOutlined"]);var bF;const EFe=["children","variant","color","disabled","onKeyDown","onDelete","onClick","component","slots","slotProps"],RFe=["onDelete"],DFe=d=>{const{focusVisible:e,variant:t,color:s,disabled:i}=d,n={root:["root",i&&"disabled",e&&"focusVisible",t&&`variant${De(t)}`,s&&`color${De(s)}`]};return Nt(n,NFe,{})},qFe=_e(ab,{name:"JoyChipDelete",slot:"Root",overridesResolver:(d,e)=>e.root})(({theme:d})=>({"--IconButton-size":"var(--Chip-deleteSize, 2rem)","--Icon-fontSize":"calc(var(--IconButton-size, 2rem) / 1.3)",minWidth:"var(--IconButton-size, 2rem)",minHeight:"var(--IconButton-size, 2rem)",fontSize:d.vars.fontSize.sm,paddingInline:"2px",pointerEvents:"visible",borderRadius:"var(--Chip-deleteRadius, 50%)",zIndex:1,padding:0})),VFe=B.forwardRef(function(e,t){const s=qt({props:e,name:"JoyChipDelete"}),{children:i,variant:n="plain",color:r="neutral",disabled:a,onKeyDown:o,onDelete:c,onClick:u,component:h,slots:l={},slotProps:f={}}=s,p=at(s,EFe),m=B.useContext(tW),{variant:g=n,color:y=r}=PO(e.variant,e.color,!0),w=e.color||y,b=a??m.disabled,S=B.useRef(null),v=Cs(S,t),{focusVisible:C,getRootProps:M}=Jo(W({},s,{disabled:b,rootRef:v})),_=W({},s,{disabled:b,variant:g,color:w,focusVisible:C}),N=DFe(_),A=W({},p,{component:h,slots:l,slotProps:f}),R=z=>{!b&&c&&c(z),u&&u(z)},D=z=>{["Backspace","Enter","Delete"].includes(z.key)&&(z.preventDefault(),!b&&c&&c(z)),o&&o(z)},[U,K]=Fe("root",{ref:t,elementType:qFe,getSlotProps:M,externalForwardedProps:A,ownerState:_,additionalProps:{as:h,onKeyDown:D,onClick:R},className:N.root}),j=at(K,RFe);return P.jsx(U,W({},j,{children:i??(bF||(bF=P.jsx(BFe,{})))}))});function FFe(d){return Rt("MuiListSubheader",d)}Dt("MuiListSubheader",["root","sticky","colorPrimary","colorNeutral","colorDanger","colorSuccess","colorWarning","colorContext","variantPlain","variantSoft","variantOutlined","variantSolid"]);const HFe=["component","className","children","id","sticky","variant","color","slots","slotProps"],GFe=d=>{const{variant:e,color:t,sticky:s}=d,i={root:["root",s&&"sticky",t&&`color${De(t)}`,e&&`variant${De(e)}`]};return Nt(i,FFe,{})},UFe=_e("div",{name:"JoyListSubheader",slot:"Root",overridesResolver:(d,e)=>e.root})(({theme:d,ownerState:e})=>{var t,s;return W({boxSizing:"border-box",display:"flex",alignItems:"center",marginInline:"var(--ListItem-marginInline)",paddingBlock:"var(--ListItem-paddingY)",paddingInlineStart:"var(--ListItem-paddingLeft)",paddingInlineEnd:"var(--ListItem-paddingRight)",minBlockSize:"var(--ListItem-minHeight)"},d.typography["body-xs"],{fontSize:"max(0.75em, 0.625rem)",textTransform:"uppercase",letterSpacing:"0.1em"},e.sticky&&{position:"sticky",top:"var(--ListItem-stickyTop, 0px)",zIndex:1,background:"var(--ListItem-stickyBackground)"},{color:e.color?`var(--_Link-color, rgba(${(t=d.vars.palette[e.color])==null?void 0:t.mainChannel} / 1))`:d.vars.palette.text.tertiary},e.instanceColor&&{[`&:not([${qm}])`]:{"--_Link-color":d.vars.palette.text.secondary}},(s=d.variants[e.variant])==null?void 0:s[e.color])}),WFe=B.forwardRef(function(e,t){const s=qt({props:e,name:"JoyListSubheader"}),{component:i,className:n,children:r,id:a,sticky:o=!1,variant:c,color:u,slots:h={},slotProps:l={}}=s,f=at(s,HFe),p=ln(a),m=B.useContext($W);B.useEffect(()=>{m&&m(p||"")},[m,p]);const g=W({instanceColor:e.color},s,{id:p,sticky:o,variant:c,color:c?u??"neutral":u}),y=GFe(g),w=W({},f,{component:i,slots:h,slotProps:l}),[b,S]=Fe("root",{ref:t,className:Gt(y.root,n),elementType:UFe,externalForwardedProps:w,ownerState:g,additionalProps:{as:i,id:p}});return P.jsx(b,W({},S,{children:r}))});function jFe(d){return Rt("MuiAutocomplete",d)}const zu=Dt("MuiAutocomplete",["root","wrapper","input","startDecorator","endDecorator","formControl","focused","disabled","error","multiple","limitTag","hasPopupIcon","hasClearIcon","clearIndicator","popupIndicator","popupIndicatorOpen","listbox","option","loading","noOptions","colorPrimary","colorNeutral","colorDanger","colorSuccess","colorWarning","colorContext","sizeSm","sizeMd","sizeLg","variantPlain","variantOutlined","variantSoft","variantSolid"]);function zFe(d){return Rt("MuiAutocompleteListbox",d)}Dt("MuiAutocompleteListbox",["root","sizeSm","sizeMd","sizeLg","colorPrimary","colorNeutral","colorDanger","colorSuccess","colorWarning","colorContext","variantPlain","variantOutlined","variantSoft","variantSolid"]);const $Fe=["anchorEl","direction","disablePortal","keepMounted","modifiers","open","placement","popperOptions","popperRef","TransitionProps"],KFe=["children","className","component","color","variant","size","slots","slotProps"],XFe=d=>{const{variant:e,color:t,size:s}=d,i={root:["root",e&&`variant${De(e)}`,t&&`color${De(t)}`,s&&`size${De(s)}`]};return Nt(i,zFe,{})},QFe=d=>at(d,$Fe),a$=_e(ag)(({theme:d,ownerState:e})=>{var t;const s=(t=d.variants[e.variant])==null?void 0:t[e.color];return W({"--focus-outline-offset":`calc(${d.vars.focus.thickness} * -1)`,"--ListItem-stickyBackground":(s==null?void 0:s.backgroundColor)||(s==null?void 0:s.background)||d.vars.palette.background.popup,"--ListItem-stickyTop":"calc(var(--List-padding, var(--ListDivider-gap)) * -1)"},CO,{boxShadow:d.shadow.md,borderRadius:`var(--List-radius, ${d.vars.radius.sm})`},!(s!=null&&s.backgroundColor)&&{backgroundColor:d.vars.palette.background.popup},{zIndex:d.vars.zIndex.popup,overflow:"auto",maxHeight:"40vh",position:"relative","&:empty":{visibility:"hidden"},[`& .${Bv.nested}, & .${Bv.nested} .${pSe.root}`]:{position:"initial"}})}),YFe=_e(a$,{name:"JoyAutocompleteListbox",slot:"Root",overridesResolver:(d,e)=>e.root})({}),ZFe=B.forwardRef(function(e,t){const s=qt({props:e,name:"JoyAutocompleteListbox"}),{children:i,className:n,component:r,color:a="neutral",variant:o="outlined",size:c="md",slots:u={},slotProps:h={}}=s,l=at(s,KFe),f=W({},s,{size:c,color:a,variant:o,nesting:!1,row:!1,wrap:!1}),p=QFe(l),m=XFe(f),g=W({},p,{component:r,slots:u,slotProps:h}),[y,w]=Fe("root",{ref:t,className:Gt(m.root,n),elementType:YFe,externalForwardedProps:g,ownerState:f,additionalProps:{role:"listbox"}});return P.jsx(hb,{variant:o,color:a,children:P.jsx(y,W({},w,{children:i}))})});function JFe(d){return Rt("MuiAutocompleteOption",d)}Dt("MuiAutocompleteOption",["root","focused","focusVisible","colorPrimary","colorNeutral","colorDanger","colorSuccess","colorWarning","colorContext","variantPlain","variantSoft","variantOutlined","variantSolid"]);const e4e=["children","component","color","variant","className","slots","slotProps"],t4e=d=>{const{color:e,variant:t}=d,s={root:["root",e&&`color${De(e)}`,t&&`variant${De(t)}`]};return Nt(s,JFe,{})},o$=_e(og)(({theme:d,ownerState:e})=>{var t,s;return{'&[aria-disabled="true"]':(t=d.variants[`${e.variant}Disabled`])==null?void 0:t[e.color],'&[aria-selected="true"]':W({},(s=d.variants[`${e.variant}Active`])==null?void 0:s[e.color],{fontWeight:d.vars.fontWeight.md})}}),s4e=_e(o$,{name:"JoyAutocompleteOption",slot:"Root",overridesResolver:(d,e)=>e.root})({}),d$=B.forwardRef(function(e,t){const s=qt({props:e,name:"JoyAutocompleteOption"}),{children:i,component:n="li",color:r="neutral",variant:a="plain",className:o,slots:c={},slotProps:u={}}=s,h=at(s,e4e),{variant:l=a,color:f=r}=PO(e.variant,e.color),p=W({},s,{component:n,color:f,variant:l}),m=t4e(p),g=W({},h,{component:n,slots:c,slotProps:u}),[y,w]=Fe("root",{ref:t,className:Gt(m.root,o),elementType:s4e,externalForwardedProps:g,ownerState:p,additionalProps:{as:n,role:"option"}});return P.jsx(y,W({},w,{children:i}))});var kF,SF;const i4e=["aria-describedby","aria-label","aria-labelledby","autoComplete","autoHighlight","autoSelect","autoFocus","blurOnSelect","clearIcon","clearOnBlur","clearOnEscape","clearText","closeText","defaultValue","disableCloseOnSelect","disabledItemsFocusable","disableListWrap","disableClearable","disabled","endDecorator","error","filterOptions","filterSelectedOptions","forcePopupIcon","freeSolo","getLimitTagsText","getOptionDisabled","getOptionKey","getOptionLabel","handleHomeEndKeys","includeInputInList","isOptionEqualToValue","groupBy","id","inputValue","limitTags","loading","loadingText","multiple","name","noOptionsText","onChange","onClose","onHighlightChange","onInputChange","onOpen","open","openOnFocus","openText","options","placeholder","popupIcon","readOnly","renderGroup","renderOption","renderTags","required","type","startDecorator","size","color","variant","value","component","selectOnFocus","slots","slotProps"],n4e=["onDelete"],r4e=["key"],a4e=["onBlur","onFocus","onMouseDown"],o4e=["key"],d4e=d=>d.current!==null&&d.current.contains(document.activeElement),c4e=d=>{var e;return(e=d.label)!=null?e:d},u4e=d=>`+${d}`,h4e=d=>P.jsxs(Er,{nested:!0,children:[P.jsx(WFe,{sticky:!0,children:d.group}),P.jsx(Dh,{children:d.children})]},d.key),l4e=d=>{const{disabled:e,focused:t,hasClearIcon:s,hasPopupIcon:i,popupOpen:n,variant:r,color:a,size:o,multiple:c}=d,u={root:["root",t&&"focused",s&&"hasClearIcon",i&&"hasPopupIcon",r&&`variant${De(r)}`,a&&`color${De(a)}`,o&&`size${De(o)}`],wrapper:["wrapper",c&&"multiple"],input:["input"],startDecorator:["startDecorator"],endDecorator:["endDecorator"],clearIndicator:["clearIndicator"],popupIndicator:["popupIndicator",n&&"popupIndicatorOpen",e&&"disabled"],listbox:["listbox"],option:["option"],loading:["loading"],noOptions:["noOptions"],limitTag:["limitTag"]};return Nt(u,jFe,{})},f4e=_e(nW,{name:"JoyAutocomplete",slot:"Root",overridesResolver:(d,e)=>e.root})(({ownerState:d})=>W({},d.size==="sm"&&{"--Autocomplete-wrapperGap":"3px"},d.size==="md"&&{"--Autocomplete-wrapperGap":"3px"},d.size==="lg"&&{"--Autocomplete-wrapperGap":"4px"},{"@media (pointer: fine)":{[`&:hover .${zu.clearIndicator}`]:{visibility:"visible"}}},d.multiple&&!d.startDecorator&&{paddingInlineStart:0})),p4e=_e("div",{name:"JoyAutocomplete",slot:"Wrapper",overridesResolver:(d,e)=>e.wrapper})(({ownerState:d})=>({flex:1,minWidth:0,display:"flex",alignItems:"center",flexWrap:"wrap",gap:"var(--Autocomplete-wrapperGap)",[`&.${zu.multiple}`]:W({paddingBlock:"var(--Autocomplete-wrapperGap)"},!d.startDecorator&&{paddingInlineStart:"var(--Autocomplete-wrapperGap)"},!d.endDecorator&&{paddingInlineEnd:"var(--Autocomplete-wrapperGap)"})})),m4e=_e(rW,{name:"JoyAutocomplete",slot:"Input",overridesResolver:(d,e)=>e.input})(({ownerState:d})=>W({minWidth:30,minHeight:"var(--Chip-minHeight)"},d.multiple&&{marginInlineStart:"calc(var(--Autocomplete-wrapperGap) * 2.5)"})),g4e=_e(aW,{name:"JoyAutocomplete",slot:"StartDecorator",overridesResolver:(d,e)=>e.startDecorator})({}),y4e=_e(oW,{name:"JoyAutocomplete",slot:"EndDecorator",overridesResolver:(d,e)=>e.endDecorator})(({ownerState:d})=>W({},(d.hasClearIcon||d.hasPopupIcon)&&{"--Button-margin":"0px","--IconButton-margin":"0px","--Icon-margin":"0px"})),w4e=_e(ab,{name:"JoyAutocomplete",slot:"ClearIndicator",overridesResolver:(d,e)=>e.clearIndicator})(({ownerState:d})=>W({alignSelf:"center"},!d.hasPopupIcon&&{marginInlineEnd:"calc(var(--Input-decoratorChildOffset) * -1)"},{marginInlineStart:"calc(var(--_Input-paddingBlock) / 2)",visibility:d.focused?"visible":"hidden"})),b4e=_e(ab,{name:"JoyAutocomplete",slot:"PopupIndicator",overridesResolver:(d,e)=>e.popupIndicator})({alignSelf:"center",marginInlineStart:"calc(var(--_Input-paddingBlock) / 2)",marginInlineEnd:"calc(var(--Input-decoratorChildOffset) * -1)",[`&.${zu.popupIndicatorOpen}`]:{transform:"rotate(180deg)","--Icon-color":"currentColor"}}),k4e=_e(a$,{name:"JoyAutocomplete",slot:"Listbox",overridesResolver:(d,e)=>e.listbox})(({theme:d})=>({zIndex:`var(--unstable_popup-zIndex, ${d.vars.zIndex.popup})`})),S4e=_e(o$,{name:"JoyAutocomplete",slot:"Option",overridesResolver:(d,e)=>e.option})({}),v4e=_e(Er,{name:"JoyAutocomplete",slot:"Loading",overridesResolver:(d,e)=>e.loading})(({theme:d})=>({color:(d.vars||d).palette.text.secondary})),T4e=_e(Er,{name:"JoyAutocomplete",slot:"NoOptions",overridesResolver:(d,e)=>e.noOptions})(({theme:d})=>({color:(d.vars||d).palette.text.secondary})),O4e=_e("div",{name:"JoyAutocomplete",slot:"NoOptions",overridesResolver:(d,e)=>e.noOptions})({marginInlineStart:"calc(var(--Input-paddingInline) / 2)",marginBlockStart:"var(--_Input-paddingBlock)"}),c$=B.forwardRef(function(e,t){var s,i,n,r,a,o,c;const u=qt({props:e,name:"JoyAutocomplete"}),{"aria-describedby":h,"aria-label":l,"aria-labelledby":f,autoFocus:p,clearIcon:m=kF||(kF=P.jsx(kU,{fontSize:"md"})),clearText:g="Clear",closeText:y="Close",disableClearable:w=!1,disabled:b,endDecorator:S,error:v=!1,forcePopupIcon:C="auto",freeSolo:M=!1,getLimitTagsText:_=u4e,getOptionLabel:N=c4e,groupBy:A,id:R,limitTags:D=-1,loading:U=!1,loadingText:K="Loading…",multiple:j=!1,name:z,noOptionsText:J="No options",openText:Y="Open",placeholder:X,popupIcon:Z=SF||(SF=P.jsx(LFe,{})),readOnly:te=!1,renderGroup:Q=h4e,renderOption:ie,renderTags:ne,required:oe,type:me,startDecorator:fe,size:he="md",color:Se="neutral",variant:ye="outlined",component:ge,slots:Te={},slotProps:Ge={}}=u,Ye=at(u,i4e),Re=B.useContext($o),Be=(s=(i=e.error)!=null?i:Re==null?void 0:Re.error)!=null?s:v,Me=(n=(r=e.size)!=null?r:Re==null?void 0:Re.size)!=null?n:he,Le=(a=e.color)!=null?a:Be?"danger":(o=Re==null?void 0:Re.color)!=null?o:Se,rt=(c=b??(Re==null?void 0:Re.disabled))!=null?c:!1,{getRootProps:ze,getInputProps:Ue,getPopupIndicatorProps:Je,getClearProps:st,getTagProps:ut,getListboxProps:yt,getOptionProps:Bt,value:lt,dirty:ht,popupOpen:ft,focused:se,focusedTag:F,anchorEl:V,setAnchorEl:re,inputValue:le,groupedOptions:ke}=rye(W({},u,{id:R??(Re==null?void 0:Re.htmlFor),componentName:"Autocomplete",unstable_classNamePrefix:"Mui",unstable_isActiveElementInListbox:d4e})),{onMouseDown:Ne}=Ue(),{onClick:wt}=ze(),Yt=!w&&!rt&&ht&&!te,zt=(!M||C===!0)&&C!==!1,Et=W({instanceColor:e.color},u,{value:lt,disabled:rt,focused:se,getOptionLabel:N,hasOptions:!!ke.length,hasClearIcon:Yt,hasPopupIcon:zt,inputFocused:F===-1,popupOpen:ft,size:Me,color:Le,variant:ye}),bt=l4e(Et),Ms=W({},Ye,{component:ge,slots:Te,slotProps:Ge});let ls;if(j&<.length>0){const Ut=Bn=>{const vi=ut(Bn),{onDelete:$n}=vi,Qr=at(vi,n4e);return W({disabled:rt,size:Me,onClick:$n},Qr)};ne?ls=ne(lt,Ut,Et):ls=lt.map((Bn,vi)=>{const $n=Ut({index:vi}),{key:Qr}=$n,ec=at($n,r4e);return P.jsx(nn,{size:Me,variant:"soft",color:"neutral",endDecorator:P.jsx(VFe,W({},ec),Qr),sx:{minWidth:0},children:N(Bn)},vi)})}const Or=Cs(t,re),An={[zu.disabled]:rt,[zu.error]:Be,[zu.focused]:se,[zu.formControl]:!!Re},[Rs,Qt]=Fe("root",{ref:Or,className:[bt.root,An],elementType:f4e,externalForwardedProps:Ms,ownerState:Et,getSlotProps:ze,additionalProps:{onClick:Ut=>{wt&&wt(Ut),Ut.currentTarget===Ut.target&&Ne&&Ne(Ut)}}}),[oi,Aa]=Fe("wrapper",{className:bt.wrapper,elementType:p4e,externalForwardedProps:Ms,ownerState:Et}),mn={[zu.disabled]:rt},[Xr,sd]=Fe("input",{className:[bt.input,mn],elementType:m4e,getSlotProps:Ut=>{const Bn=Ue(),{onBlur:vi,onFocus:$n,onMouseDown:Qr}=Bn,ec=at(Bn,a4e);return W({},ec,{onBlur:xr=>{var Pr;vi==null||vi(xr),(Pr=Ut.onBlur)==null||Pr.call(Ut,xr)},onFocus:xr=>{var Pr;$n==null||$n(xr),(Pr=Ut.onFocus)==null||Pr.call(Ut,xr)},onMouseDown:xr=>{var Pr;Qr==null||Qr(xr),(Pr=Ut.onMouseDown)==null||Pr.call(Ut,xr)}})},externalForwardedProps:Ms,ownerState:Et,additionalProps:{autoFocus:p,placeholder:X,name:z,readOnly:te,disabled:rt,required:oe??(Re==null?void 0:Re.required),type:me,"aria-invalid":Be||void 0,"aria-label":l,"aria-labelledby":f,"aria-describedby":h??(Re==null?void 0:Re["aria-describedby"])}}),[La,id]=Fe("startDecorator",{className:bt.startDecorator,elementType:g4e,externalForwardedProps:Ms,ownerState:Et}),[yo,nd]=Fe("endDecorator",{className:bt.endDecorator,elementType:y4e,externalForwardedProps:Ms,ownerState:Et}),[Jd,$t]=Fe("clearIndicator",{className:bt.clearIndicator,elementType:w4e,getSlotProps:st,externalForwardedProps:Ms,ownerState:Et,getSlotOwnerState:Ut=>({size:Ut.size||Me,variant:Ut.variant||fl(ye,Le).variant||"plain",color:Ut.color||fl(ye,Le).color||"neutral",disableColorInversion:!!e.color}),additionalProps:{"aria-label":g,title:g}}),[ms,ds]=Fe("popupIndicator",{className:bt.popupIndicator,elementType:b4e,getSlotProps:Je,externalForwardedProps:Ms,ownerState:Et,getSlotOwnerState:Ut=>({size:Ut.size||Me,variant:Ut.variant||fl(ye,Le).variant||"plain",color:Ut.color||fl(ye,Le).color||"neutral",disableColorInversion:!!e.color}),additionalProps:{disabled:rt,"aria-label":ft?y:Y,title:ft?y:Y,type:"button"}}),[Ce,xe]=Fe("listbox",{className:bt.listbox,elementType:k4e,getSlotProps:yt,externalForwardedProps:Ms,ownerState:Et,getSlotOwnerState:Ut=>({size:Ut.size||Me,variant:Ut.variant||ye,color:Ut.color||Le,disableColorInversion:!Ut.disablePortal}),additionalProps:{anchorEl:V,open:ft,style:V?{width:V.clientWidth}:{}}}),[dt,Ct]=Fe("loading",{className:bt.loading,elementType:v4e,externalForwardedProps:Ms,ownerState:Et}),[ns,Ts]=Fe("noOptions",{className:bt.noOptions,elementType:T4e,externalForwardedProps:Ms,ownerState:Et,additionalProps:{role:"presentation",onMouseDown:Ut=>{Ut.preventDefault()}}}),[Fs,Ln]=Fe("limitTag",{className:bt.limitTag,elementType:O4e,externalForwardedProps:Ms,ownerState:Et});if(D>-1&&Array.isArray(ls)){const Ut=ls.length-D;!se&&Ut>0&&(ls=ls.splice(0,D),ls.push(P.jsx(Fs,W({},Ln,{children:_(Ut)}),ls.length)))}const[Ba,Cf]=Fe("option",{className:bt.option,elementType:S4e,externalForwardedProps:Ms,ownerState:Et,getSlotOwnerState:Ut=>({variant:Ut.variant||fl(ye,Le).variant||"plain",color:Ut.color||fl(ye,Le).color||"neutral",disableColorInversion:!xe.disablePortal}),additionalProps:{as:"li"}}),Mf=ie||((Ut,Bn)=>{const{key:vi}=Ut,$n=at(Ut,o4e);return P.jsx(Ba,W({},$n,{children:N(Bn)}),vi)}),Kh=(Ut,Bn)=>{const vi=Bt({option:Ut,index:Bn});return Mf(W({},Cf,vi),Ut,{selected:!!vi["aria-selected"],inputValue:le,ownerState:Et})},_f=B.useMemo(()=>[{name:"offset",options:{offset:[0,4]}},...xe.modifiers||[]],[xe.modifiers]);let cu=null;if(V){var uu;cu=P.jsx(hb,{variant:ye,color:Le,children:P.jsx(rg,{nested:!0,children:P.jsxs(Ce,W({},xe,{className:Gt(xe.className),modifiers:_f},!((uu=u.slots)!=null&&uu.listbox)&&{as:lO,slots:{root:xe.as||"ul"}},{children:[ke.map((Ut,Bn)=>{if(A){const vi=Ut;return Q({key:String(vi.key),group:vi.group,children:vi.options.map(($n,Qr)=>Kh($n,vi.index+Qr))})}return Kh(Ut,Bn)}),U&&ke.length===0?P.jsx(dt,W({},Ct,{children:K})):null,ke.length===0&&!M&&!U?P.jsx(ns,W({},Ts,{children:J})):null]}))})})}return P.jsxs(B.Fragment,{children:[P.jsxs(Rs,W({},Qt,{children:[fe&&P.jsx(La,W({},id,{children:fe})),P.jsxs(oi,W({},Aa,{children:[ls,P.jsx(Xr,W({},sd))]})),S&&P.jsx(yo,W({},nd,{children:S})),Yt?P.jsx(Jd,W({},$t,{children:m})):null,zt?P.jsx(ms,W({},ds,{children:Z})):null]})),cu]})}),vF=d=>d.name,_b=({value:d,onChange:e,defaultExchangeAccounts:t,disabled:s})=>{const[i,n]=B.useState(d?vF(d):""),[r]=t?[t]:kt.exchangeAccount.list.useSuspenseQuery();return P.jsx(c$,{autoHighlight:!0,disableClearable:!0,getOptionLabel:vF,inputValue:i,isOptionEqualToValue:a=>d?d.id===a.id:!1,onChange:(a,o)=>{e(o)},onInputChange:(a,o)=>{n(o)},options:r,renderOption:(a,o)=>B.createElement(d$,{...a,key:o.id},P.jsx(qh,{children:P.jsx(wL,{exchangeCode:o.exchangeCode,height:20,size:64,width:20})}),P.jsxs(to,{sx:{fontSize:"sm"},children:[o.exchangeCode,P.jsx(ot,{level:"body-xs",children:o.name})]})),value:d||void 0,disabled:s,sx:{"&.Mui-disabled":{borderColor:"var(--joy-palette-neutral-outlinedBorder)"}}})};_b.displayName="ExchangeAccountSelect";function TF(d){if(d===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d}function $2(d,e){return $2=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,s){return t.__proto__=s,t},$2(d,e)}function x4e(d,e){d.prototype=Object.create(e.prototype),d.prototype.constructor=d,$2(d,e)}var OF=Number.isNaN||function(e){return typeof e=="number"&&e!==e};function P4e(d,e){return!!(d===e||OF(d)&&OF(e))}function I4e(d,e){if(d.length!==e.length)return!1;for(var t=0;t=e?d.call(null):i.id=requestAnimationFrame(s)}var i={id:requestAnimationFrame(s)};return i}var TC=-1;function IF(d){if(d===void 0&&(d=!1),TC===-1||d){var e=document.createElement("div"),t=e.style;t.width="50px",t.height="50px",t.overflow="scroll",document.body.appendChild(e),TC=e.offsetWidth-e.clientWidth,document.body.removeChild(e)}return TC}var lp=null;function CF(d){if(d===void 0&&(d=!1),lp===null||d){var e=document.createElement("div"),t=e.style;t.width="50px",t.height="50px",t.overflow="scroll",t.direction="rtl";var s=document.createElement("div"),i=s.style;return i.width="100px",i.height="100px",e.appendChild(s),document.body.appendChild(e),e.scrollLeft>0?lp="positive-descending":(e.scrollLeft=1,e.scrollLeft===0?lp="negative":lp="positive-ascending"),document.body.removeChild(e),lp}return lp}var _4e=150,A4e=function(e,t){return e};function L4e(d){var e,t=d.getItemOffset,s=d.getEstimatedTotalSize,i=d.getItemSize,n=d.getOffsetForIndexAndAlignment,r=d.getStartIndexForOffset,a=d.getStopIndexForStartIndex,o=d.initInstanceProps,c=d.shouldResetStyleCacheOnItemSizeChange,u=d.validateProps;return e=function(h){x4e(l,h);function l(p){var m;return m=h.call(this,p)||this,m._instanceProps=o(m.props,TF(m)),m._outerRef=void 0,m._resetIsScrollingTimeoutId=null,m.state={instance:TF(m),isScrolling:!1,scrollDirection:"forward",scrollOffset:typeof m.props.initialScrollOffset=="number"?m.props.initialScrollOffset:0,scrollUpdateWasRequested:!1},m._callOnItemsRendered=void 0,m._callOnItemsRendered=vC(function(g,y,w,b){return m.props.onItemsRendered({overscanStartIndex:g,overscanStopIndex:y,visibleStartIndex:w,visibleStopIndex:b})}),m._callOnScroll=void 0,m._callOnScroll=vC(function(g,y,w){return m.props.onScroll({scrollDirection:g,scrollOffset:y,scrollUpdateWasRequested:w})}),m._getItemStyle=void 0,m._getItemStyle=function(g){var y=m.props,w=y.direction,b=y.itemSize,S=y.layout,v=m._getItemStyleCache(c&&b,c&&S,c&&w),C;if(v.hasOwnProperty(g))C=v[g];else{var M=t(m.props,g,m._instanceProps),_=i(m.props,g,m._instanceProps),N=w==="horizontal"||S==="horizontal",A=w==="rtl",R=N?M:0;v[g]=C={position:"absolute",left:A?void 0:R,right:A?R:void 0,top:N?0:M,height:N?"100%":_,width:N?_:"100%"}}return C},m._getItemStyleCache=void 0,m._getItemStyleCache=vC(function(g,y,w){return{}}),m._onScrollHorizontal=function(g){var y=g.currentTarget,w=y.clientWidth,b=y.scrollLeft,S=y.scrollWidth;m.setState(function(v){if(v.scrollOffset===b)return null;var C=m.props.direction,M=b;if(C==="rtl")switch(CF()){case"negative":M=-b;break;case"positive-descending":M=S-w-b;break}return M=Math.max(0,Math.min(M,S-w)),{isScrolling:!0,scrollDirection:v.scrollOffsetC.clientWidth?IF():0:v=C.scrollHeight>C.clientHeight?IF():0}this.scrollTo(n(this.props,m,g,S,this._instanceProps,v))},f.componentDidMount=function(){var m=this.props,g=m.direction,y=m.initialScrollOffset,w=m.layout;if(typeof y=="number"&&this._outerRef!=null){var b=this._outerRef;g==="horizontal"||w==="horizontal"?b.scrollLeft=y:b.scrollTop=y}this._callPropsCallbacks()},f.componentDidUpdate=function(){var m=this.props,g=m.direction,y=m.layout,w=this.state,b=w.scrollOffset,S=w.scrollUpdateWasRequested;if(S&&this._outerRef!=null){var v=this._outerRef;if(g==="horizontal"||y==="horizontal")if(g==="rtl")switch(CF()){case"negative":v.scrollLeft=-b;break;case"positive-ascending":v.scrollLeft=b;break;default:var C=v.clientWidth,M=v.scrollWidth;v.scrollLeft=M-C-b;break}else v.scrollLeft=b;else v.scrollTop=b}this._callPropsCallbacks()},f.componentWillUnmount=function(){this._resetIsScrollingTimeoutId!==null&&PF(this._resetIsScrollingTimeoutId)},f.render=function(){var m=this.props,g=m.children,y=m.className,w=m.direction,b=m.height,S=m.innerRef,v=m.innerElementType,C=m.innerTagName,M=m.itemCount,_=m.itemData,N=m.itemKey,A=N===void 0?A4e:N,R=m.layout,D=m.outerElementType,U=m.outerTagName,K=m.style,j=m.useIsScrolling,z=m.width,J=this.state.isScrolling,Y=w==="horizontal"||R==="horizontal",X=Y?this._onScrollHorizontal:this._onScrollVertical,Z=this._getRangeToRender(),te=Z[0],Q=Z[1],ie=[];if(M>0)for(var ne=te;ne<=Q;ne++)ie.push(B.createElement(g,{data:_,key:A(ne,_),index:ne,isScrolling:j?J:void 0,style:this._getItemStyle(ne)}));var oe=s(this.props,this._instanceProps);return B.createElement(D||U||"div",{className:y,onScroll:X,ref:this._outerRefSetter,style:W({position:"relative",height:b,width:z,overflow:"auto",WebkitOverflowScrolling:"touch",willChange:"transform",direction:w},K)},B.createElement(v||C||"div",{children:ie,ref:S,style:{height:Y?"100%":oe,pointerEvents:J?"none":void 0,width:Y?oe:"100%"}}))},f._callPropsCallbacks=function(){if(typeof this.props.onItemsRendered=="function"){var m=this.props.itemCount;if(m>0){var g=this._getRangeToRender(),y=g[0],w=g[1],b=g[2],S=g[3];this._callOnItemsRendered(y,w,b,S)}}if(typeof this.props.onScroll=="function"){var v=this.state,C=v.scrollDirection,M=v.scrollOffset,_=v.scrollUpdateWasRequested;this._callOnScroll(C,M,_)}},f._getRangeToRender=function(){var m=this.props,g=m.itemCount,y=m.overscanCount,w=this.state,b=w.isScrolling,S=w.scrollDirection,v=w.scrollOffset;if(g===0)return[0,0,0,0];var C=r(this.props,v,this._instanceProps),M=a(this.props,C,v,this._instanceProps),_=!b||S==="backward"?Math.max(1,y):1,N=!b||S==="forward"?Math.max(1,y):1;return[Math.max(0,C-_),Math.max(0,Math.min(g-1,M+N)),C,M]},l}(B.PureComponent),e.defaultProps={direction:"ltr",itemData:void 0,layout:"vertical",overscanCount:2,useIsScrolling:!1},e}var B4e=function(e,t){e.children,e.direction,e.height,e.layout,e.innerTagName,e.outerTagName,e.width,t.instance},N4e=L4e({getItemOffset:function(e,t){var s=e.itemSize;return t*s},getItemSize:function(e,t){var s=e.itemSize;return s},getEstimatedTotalSize:function(e){var t=e.itemCount,s=e.itemSize;return s*t},getOffsetForIndexAndAlignment:function(e,t,s,i,n,r){var a=e.direction,o=e.height,c=e.itemCount,u=e.itemSize,h=e.layout,l=e.width,f=a==="horizontal"||h==="horizontal",p=f?l:o,m=Math.max(0,c*u-p),g=Math.min(m,t*u),y=Math.max(0,t*u-p+u+r);switch(s==="smart"&&(i>=y-p&&i<=g+p?s="auto":s="center"),s){case"start":return g;case"end":return y;case"center":{var w=Math.round(y+(g-y)/2);return wm+Math.floor(p/2)?m:w}case"auto":default:return i>=y&&i<=g?i:i{n||a(E4e(i)||document.body)},[i,n]),Iv(()=>{if(r&&!n)return r2(t,r),()=>{r2(t,null)}},[t,r,n]),n){if(B.isValidElement(s)){const c={ref:o};return B.cloneElement(s,c)}return s}return r&&bT.createPortal(s,r)}),u$="Popper";function D4e(d){return bL(u$,d)}AW(u$,["root"]);function q4e(d,e){if(e==="ltr")return d;switch(d){case"bottom-end":return"bottom-start";case"bottom-start":return"bottom-end";case"top-end":return"top-start";case"top-start":return"top-end";default:return d}}function K2(d){return typeof d=="function"?d():d}function V4e(d){return d.nodeType!==void 0}const F4e=()=>nL({root:["root"]},BW(D4e)),H4e={},G4e=B.forwardRef(function(e,t){const{anchorEl:s,children:i,direction:n,disablePortal:r,modifiers:a,open:o,placement:c,popperOptions:u,popperRef:h,slotProps:l={},slots:f={},TransitionProps:p,ownerState:m,...g}=e,y=B.useRef(null),w=Cv(y,t),b=B.useRef(null),S=Cv(b,h),v=B.useRef(S);Iv(()=>{v.current=S},[S]),B.useImperativeHandle(h,()=>b.current,[]);const C=q4e(c,n),[M,_]=B.useState(C),[N,A]=B.useState(K2(s));B.useEffect(()=>{b.current&&b.current.forceUpdate()}),B.useEffect(()=>{s&&A(K2(s))},[s]),Iv(()=>{if(!N||!o)return;const j=Y=>{_(Y.placement)};let z=[{name:"preventOverflow",options:{altBoundary:r}},{name:"flip",options:{altBoundary:r}},{name:"onUpdate",enabled:!0,phase:"afterWrite",fn:({state:Y})=>{j(Y)}}];a!=null&&(z=z.concat(a)),u&&u.modifiers!=null&&(z=z.concat(u.modifiers));const J=pU(N,y.current,{placement:C,...u,modifiers:z});return v.current(J),()=>{J.destroy(),v.current(null)}},[N,r,a,o,u,C]);const R={placement:M};p!==null&&(R.TransitionProps=p);const D=F4e(),U=f.root??"div",K=HU({elementType:U,externalSlotProps:l.root,externalForwardedProps:g,additionalProps:{role:"tooltip",ref:w},ownerState:e,className:D.root});return P.jsx(U,{...K,children:typeof i=="function"?i(R):i})}),U4e=B.forwardRef(function(e,t){const{anchorEl:s,children:i,container:n,direction:r="ltr",disablePortal:a=!1,keepMounted:o=!1,modifiers:c,open:u,placement:h="bottom",popperOptions:l=H4e,popperRef:f,style:p,transition:m=!1,slotProps:g={},slots:y={},...w}=e,[b,S]=B.useState(!0),v=()=>{S(!1)},C=()=>{S(!0)};if(!o&&!u&&(!m||b))return null;let M;if(n)M=n;else if(s){const A=K2(s);M=A&&V4e(A)?cV(A).body:cV(null).body}const _=!u&&o&&(!m||b)?"none":void 0,N=m?{in:u,onEnter:v,onExited:C}:void 0;return P.jsx(R4e,{disablePortal:a,container:M,children:P.jsx(G4e,{anchorEl:s,direction:r,disablePortal:a,modifiers:c,ref:t,open:m?!b:u,placement:h,popperOptions:l,popperRef:f,slotProps:g,slots:y,...w,style:{position:"fixed",top:0,left:0,display:_,...p},TransitionProps:N,children:i})})}),W4e=8,X2=48,j4e=8;function z4e(d){const{data:e,index:t,style:s}=d,[i,n]=e[t],r={...s,top:s.top+W4e,height:X2};return B.createElement(d$,{...i,key:n.symbolId,style:r},P.jsx(qh,{children:P.jsx(DL,{symbol:n.baseCurrency})}),P.jsx(to,{sx:{fontSize:"sm"},children:n.currencyPair}))}const h$=B.createContext({}),l$=B.forwardRef((d,e)=>{const t=B.useContext(h$);return P.jsx(ZFe,{...d,...t,component:"div",ref:e,sx:{"& ul":{padding:0,margin:0,flexShrink:0}}})});l$.displayName="OuterElementType";const $4e=Tn.forwardRef(function(e,t){const{children:s,anchorEl:i,open:n,modifiers:r,...a}=e,o=[];s[0].forEach(u=>{u&&(o.push(u),o.push(...u.children||[]))});const c=o.length;return P.jsx(U4e,{anchorEl:i,modifiers:r,open:n,ref:t,style:{zIndex:1e3},children:P.jsx(h$.Provider,{value:a,children:P.jsx(N4e,{height:X2*j4e,innerElementType:"ul",itemCount:c,itemData:o,itemSize:X2,outerElementType:l$,overscanCount:5,width:"100%",children:z4e})})})});function K4e(...d){return d}const MF=d=>d.currencyPair,X4e=bU({matchFrom:"any",trim:!0,stringify:d=>d.currencyPair}),Ab=({exchangeCode:d,value:e,onChange:t,defaultSymbols:s,disabled:i})=>{const[n,r]=B.useState(e?MF(e):""),[a]=s?[s]:kt.symbol.list.useSuspenseQuery(d);return P.jsx(c$,{autoHighlight:!0,disableClearable:!0,disableListWrap:!0,filterOptions:X4e,getOptionLabel:MF,inputValue:n,onChange:(o,c)=>t(c),onInputChange:(o,c)=>r(c),options:a,renderOption:(...o)=>K4e(...o),slots:{listbox:$4e},value:e||void 0,disabled:i,sx:{"&.Mui-disabled":{borderColor:"var(--joy-palette-neutral-outlinedBorder)"}}})};Ab.displayName="SymbolSelect";function wg({value:d,onChange:e,whitelist:t,optional:s}){const i=t||Object.values(mf);return P.jsxs(fb,{onChange:(n,r)=>{e(r)},required:!0,value:d,children:[s?P.jsx(ef,{value:null,children:""}):null,i.map(n=>P.jsx(ef,{value:n,children:n||""},n))]})}function Q4e(d){if(d.length===0)throw new Error("getWaitingGridLinePrice: empty array provided");if(d.length===1){const{entryOrder:s,takeProfitOrder:i}=d[0];return i.status==="Filled"?i.price:s.price}const e=d.filter(s=>s.entryOrder.status==="Filled");return e.length===0?d[0].takeProfitOrder.price:e.length===1?e[0].entryOrder.price:e.reduce((s,i)=>i.entryOrder.pricei.entryOrder.status==="Filled"?i.takeProfitOrder.price:i.entryOrder.price),e].sort((i,n)=>i-n);return s.map(i=>RMe(i,s,e))}function Z4e(d,e,t){return{time:Sj(e),position:t==="buy"?"belowBar":"aboveBar",color:t==="buy"?"#2196F3":"#e91e63",shape:t==="buy"?"arrowUp":"arrowDown",text:t==="buy"?`B #${d}`:`S #${d}`}}function KB(d,e){const t=J4e(d),s=_F(t.filter(r=>r.side==="buy"),e),i=_F(t.filter(r=>r.side==="sell"),e);return[...s,...i].sort((r,a)=>r.timestamp-a.timestamp).map(r=>Z4e(r.ordersCount,r.timestamp,r.side))}function J4e(d){return d.length===0?[]:d.filter(t=>{const{entryType:s,takeProfitType:i}=t;return s==="Order"&&(i==="Order"||i==="None")}).flatMap(t=>{if(t.entryOrder.filledPrice===null)return[];const s=[t.entryOrder];return t.takeProfitType==="Order"&&t.takeProfitOrder.filledPrice&&s.push(t.takeProfitOrder),s}).map(t=>{if(t.filledPrice===null)throw new Error("computeOrders: filledPrice is null");return{smartTradeId:t.smartTradeId,orderId:t.id,quantity:t.quantity,filledPrice:t.filledPrice,filledAt:YL(t.filledAt.getTime(),"1m"),side:t.side==="Buy"?"buy":"sell"}}).sort((t,s)=>t.filledAt-s.filledAt)}function _F(d,e){const t=d.reduce((s,i)=>{const n=YL(i.filledAt,e);let r=s[n];return r?(r.ordersCount+=1,r.averagePrice=Number(Ro(r.averagePrice+i.filledPrice).div(2).toNumber().toFixed(4))):r={timestamp:n,ordersCount:1,averagePrice:i.filledPrice,side:i.side},{...s,[n]:r}},{});return Object.values(t)}const e6e=["1d","4h","1h","5m","1m"],AF=()=>{},t6e=({botId:d})=>{const[e]=kt.gridBot.getOne.useSuspenseQuery(d),[t]=kt.exchangeAccount.getOne.useSuspenseQuery(e.exchangeAccountId),[s]=kt.symbol.getOne.useSuspenseQuery({symbolId:ZT(t.exchangeCode,JT(e.symbol),eO(e.symbol))}),[i]=kt.bot.activeSmartTrades.useSuspenseQuery({botId:d}),[n]=kt.bot.completedSmartTrades.useSuspenseQuery({botId:d}),r=B.useMemo(()=>Y4e(i),[i]),[a,o]=B.useState("1h"),[c,u]=B.useState(!0),h=B.useMemo(()=>KB(n,a),[n,a]),[l,f]=B.useState(!1);return P.jsx(B.Suspense,{fallback:P.jsx(mi,{animation:"wave",height:Xo,variant:"rectangular",width:"100%"}),children:P.jsxs(hx,{barSize:a,markers:h,priceLines:r,showMarkers:l,showPriceLines:c,symbolId:s.symbolId,children:[P.jsx(_b,{onChange:AF,value:t,disabled:!0}),P.jsx(Ab,{exchangeCode:t.exchangeCode,onChange:AF,value:s,disabled:!0}),P.jsx(wg,{onChange:p=>{o(p)},value:a,whitelist:e6e}),P.jsx(Rc,{}),P.jsx(_t,{display:"flex",children:P.jsx(lx,{gridVisible:c,onGridVisibleChange:u,onTradesVisibleChange:f,tradesVisible:l})})]})})};function fx(d){if(d.entryType==="Ladder")throw new Error("Entry type Ladder not supported yet");if(d.takeProfitType==="Ladder")throw new Error("Take profit type Ladder not supported yet");if(d.takeProfitType==="None"||!d.takeProfitOrder.filledPrice||!d.entryOrder.filledPrice)return{grossProfit:0,netProfit:0,entryOrderFee:0,tpOrderFee:0,fee:0};const{entryOrder:e,takeProfitOrder:t}=d,{quantity:s}=t,i=Ro(t.filledPrice).minus(e.filledPrice).times(s).toNumber(),n=Ro(e.fee??0).times(e.filledPrice),r=t.fee??0,a=Ro(n).plus(r).toNumber(),o=Ro(i).minus(a).toNumber();return{grossProfit:i,netProfit:o,entryOrderFee:n.toNumber(),tpOrderFee:r,fee:a}}function s6e(d){let e=Ro(0);for(const t of d){const{netProfit:s}=fx(t);e=e.plus(s)}return e.toNumber()}function i6e(d){return Ph(d,Date.now())}function I1(d,e){const t=ri(d),s=ri(e),i=t.getTime()-s.getTime();return i<0?-1:i>0?1:i}function n6e(d,e){const t=ri(d),s=ri(e),i=t.getFullYear()-s.getFullYear(),n=t.getMonth()-s.getMonth();return i*12+n}function r6e(d){const e=ri(d);return e.setHours(23,59,59,999),e}function a6e(d){const e=ri(d),t=e.getMonth();return e.setFullYear(e.getFullYear(),t+1,0),e.setHours(23,59,59,999),e}function o6e(d){const e=ri(d);return+r6e(e)==+a6e(e)}function d6e(d,e){const t=ri(d),s=ri(e),i=I1(t,s),n=Math.abs(n6e(t,s));let r;if(n<1)r=0;else{t.getMonth()===1&&t.getDate()>27&&t.setDate(30),t.setMonth(t.getMonth()-i*n);let a=I1(t,s)===-i;o6e(ri(d))&&n===1&&I1(d,s)===1&&(a=!1),r=i*(n-Number(a))}return r===0?0:r}function c6e(d){return e=>{const s=(d?Math[d]:Math.trunc)(e);return s===0?0:s}}function u6e(d,e){return+ri(d)-+ri(e)}function h6e(d,e,t){const s=u6e(d,e)/1e3;return c6e(t==null?void 0:t.roundingMethod)(s)}function l6e(d,e,t){const s=lb(),i=(t==null?void 0:t.locale)??s.locale??lW,n=2520,r=I1(d,e);if(isNaN(r))throw new RangeError("Invalid time value");const a=Object.assign({},t,{addSuffix:t==null?void 0:t.addSuffix,comparison:r});let o,c;r>0?(o=ri(e),c=ri(d)):(o=ri(d),c=ri(e));const u=h6e(c,o),h=(Nv(c)-Nv(o))/1e3,l=Math.round((u-h)/60);let f;if(l<2)return t!=null&&t.includeSeconds?u<5?i.formatDistance("lessThanXSeconds",5,a):u<10?i.formatDistance("lessThanXSeconds",10,a):u<20?i.formatDistance("lessThanXSeconds",20,a):u<40?i.formatDistance("halfAMinute",0,a):u<60?i.formatDistance("lessThanXMinutes",1,a):i.formatDistance("xMinutes",1,a):l===0?i.formatDistance("lessThanXMinutes",1,a):i.formatDistance("xMinutes",l,a);if(l<45)return i.formatDistance("xMinutes",l,a);if(l<90)return i.formatDistance("aboutXHours",1,a);if(l{var a,o;const{id:e,entryOrder:t,takeProfitOrder:s}=d,{fee:i}=fx(d),{baseCurrency:n,quoteCurrency:r}=Kd(d.symbol);return P.jsxs(_t,{sx:{display:"flex",flexDirection:"column",maxWidth:320,justifyContent:"center",p:1},children:[P.jsx(ot,{fontSize:"sm",children:"SmartTrade"}),P.jsxs(Dh,{size:"sm",children:[P.jsxs(Er,{children:[P.jsx(to,{children:"ID"}),e]}),P.jsxs(Er,{children:[P.jsx(to,{children:"Qty"}),s.quantity," ",n]}),P.jsxs(Er,{children:[P.jsx(to,{children:"Buy"}),(a=t.filledPrice)==null?void 0:a.toFixed(2)," ",r]}),P.jsxs(Er,{children:[P.jsx(to,{children:"Sell"}),(o=s.filledPrice)==null?void 0:o.toFixed(2)," ",r]}),P.jsxs(Er,{children:[P.jsx(to,{children:"Fee"}),i.toFixed(2)," ",r]})]})]})},XB=({profit:d,currency:e,size:t="md"})=>{const s=d>=0,i=s?"+":"",n=s?"var(--joy-palette-success-500)":"var(--joy-palette-danger-500)";return P.jsxs(ot,{level:`title-${t}`,sx:{color:n,fontWeight:"bold"},children:[i,d.toFixed(2)," ",e]})},g6e=({smartTrade:d})=>{const{netProfit:e}=fx(d),{filledAt:t}=d.takeProfitOrder,s=t?Jl(t.getTime()):"Missing date",{quoteCurrency:i}=Kd(d.symbol);return P.jsxs(Er,{children:[P.jsx(qh,{children:P.jsx(XB,{currency:i,profit:e})}),P.jsx(to,{}),P.jsx(In,{title:s,children:P.jsx(ot,{children:t?f6e(t):"Missing date"})}),P.jsx(In,{title:P.jsx(m6e,{smartTrade:d}),children:P.jsx(p6e,{})})]})},QB=({botId:d})=>{const[e]=kt.bot.getOne.useSuspenseQuery(d),[t]=kt.bot.completedSmartTrades.useSuspenseQuery({botId:d}),s=s6e(t),{quoteCurrency:i}=Kd(e.symbol);return P.jsxs(fn,{sx:{maxHeight:500},children:[P.jsxs(_t,{display:"flex",justifyContent:"space-between",children:[P.jsx(ot,{fontSize:"xl2",fontWeight:"xl",level:"h3",children:"Profits"}),t.length>0?P.jsx(In,{title:"Total profit",children:P.jsx(ot,{fontSize:"xl2",fontWeight:"xl",level:"h3",children:P.jsx(XB,{currency:i,profit:s,size:"lg"})})}):null]}),t.length>0?P.jsx(Oh,{sx:{overflowY:"scroll"},children:P.jsx(Dh,{size:"sm",children:t.map((n,r)=>P.jsxs(Tn.Fragment,{children:[P.jsx(g6e,{smartTrade:n},n.id),rP.jsx("thead",{children:P.jsxs("tr",{children:[P.jsx("th",{children:"Type"}),P.jsx("th",{style:{textAlign:"right"},children:"Quantity"}),P.jsx("th",{children:"Price"}),P.jsx("th",{children:"Status"}),P.jsx("th",{children:"Orders status"}),P.jsx("th",{children:"Amount"}),P.jsx("th",{style:{textAlign:"right"},children:"Created"}),P.jsx("th",{style:{width:f$,textAlign:"right"},children:"ID"})]})});function w6e(d){return Rt("MuiRadio",d)}const Lw=Dt("MuiRadio",["root","radio","icon","action","input","label","checked","disabled","focusVisible","colorPrimary","colorDanger","colorNeutral","colorSuccess","colorWarning","colorContext","sizeSm","sizeMd","sizeLg","variantOutlined","variantSoft","variantSolid"]),b6e=["checked","checkedIcon","defaultChecked","disabled","disableIcon","overlay","label","id","name","onBlur","onChange","onFocus","onFocusVisible","readOnly","required","color","variant","size","uncheckedIcon","value","component","slots","slotProps"],k6e=d=>{const{checked:e,disabled:t,disableIcon:s,focusVisible:i,color:n,variant:r,size:a}=d,o={root:["root",e&&"checked",t&&"disabled",i&&"focusVisible",r&&`variant${De(r)}`,n&&`color${De(n)}`,a&&`size${De(a)}`],radio:["radio",e&&"checked",t&&"disabled"],icon:["icon"],action:["action",e&&"checked",s&&t&&"disabled",i&&"focusVisible"],input:["input"],label:["label"]};return Nt(o,w6e,{})};function S6e(d,e){return typeof e=="object"&&e!==null?d===e:String(d)===String(e)}const v6e=_e("span",{name:"JoyRadio",slot:"Root",overridesResolver:(d,e)=>e.root})(({ownerState:d,theme:e})=>{var t,s,i;return[W({"--Icon-fontSize":"var(--Radio-size)","--Icon-color":"currentColor"},d.size==="sm"&&{"--Radio-size":"1rem","& ~ *":{"--FormHelperText-margin":"0 0 0 1.5rem"},fontSize:e.vars.fontSize.sm,gap:"var(--Radio-gap, 0.5rem)"},d.size==="md"&&{"--Radio-size":"1.25rem","& ~ *":{"--FormHelperText-margin":"0.25rem 0 0 1.875rem"},fontSize:e.vars.fontSize.md,gap:"var(--Radio-gap, 0.625rem)"},d.size==="lg"&&{"--Radio-size":"1.5rem","& ~ *":{"--FormHelperText-margin":"0.375rem 0 0 2.25rem"},fontSize:e.vars.fontSize.lg,gap:"var(--Radio-gap, 0.75rem)"},{position:d.overlay?"initial":"relative",display:"inline-flex",boxSizing:"border-box",minWidth:0,fontFamily:e.vars.fontFamily.body,lineHeight:"var(--Radio-size)",color:e.vars.palette.text.primary,[`&.${Lw.disabled}`]:{color:(t=e.variants.plainDisabled)==null||(t=t[d.color])==null?void 0:t.color}},d.disableIcon&&{color:(s=e.variants[d.variant])==null||(s=s[d.color])==null?void 0:s.color,[`&.${Lw.disabled}`]:{color:(i=e.variants[`${d.variant}Disabled`])==null||(i=i[d.color])==null?void 0:i.color}},d["data-parent"]==="RadioGroup"&&d["data-first-child"]===void 0&&{marginInlineStart:d.orientation==="horizontal"?"var(--RadioGroup-gap)":void 0,marginBlockStart:d.orientation==="horizontal"?void 0:"var(--RadioGroup-gap)"})]}),T6e=_e("span",{name:"JoyRadio",slot:"Radio",overridesResolver:(d,e)=>e.radio})(({ownerState:d,theme:e})=>{var t,s,i,n,r;const a=(t=e.variants[`${d.variant}`])==null?void 0:t[d.color];return[W({"--Icon-color":d.color!=="neutral"||d.variant==="solid"?"currentColor":e.vars.palette.text.icon,margin:0,boxSizing:"border-box",width:"var(--Radio-size)",height:"var(--Radio-size)",borderRadius:"var(--Radio-size)",display:"inline-flex",justifyContent:"center",alignItems:"center",flexShrink:0},d.disableIcon&&{display:"contents"},{[`&.${Lw.checked}`]:{"--Icon-color":"currentColor"}}),...d.disableIcon?[]:[W({},a,{backgroundColor:(s=a==null?void 0:a.backgroundColor)!=null?s:e.vars.palette.background.surface}),{"&:hover":{"@media (hover: hover)":(i=e.variants[`${d.variant}Hover`])==null?void 0:i[d.color]}},{"&:active":(n=e.variants[`${d.variant}Active`])==null?void 0:n[d.color]},{[`&.${Lw.disabled}`]:(r=e.variants[`${d.variant}Disabled`])==null?void 0:r[d.color]}]]}),O6e=_e("span",{name:"JoyRadio",slot:"Action",overridesResolver:(d,e)=>e.action})(({theme:d,ownerState:e})=>{var t,s,i,n;return[{position:"absolute",textAlign:"left",borderRadius:`var(--Radio-actionRadius, ${e.overlay?"var(--unstable_actionRadius, inherit)":"inherit"})`,top:"calc(-1 * var(--variant-borderWidth, 0px))",left:"calc(-1 * var(--variant-borderWidth, 0px))",bottom:"calc(-1 * var(--variant-borderWidth, 0px))",right:"calc(-1 * var(--variant-borderWidth, 0px))",zIndex:1,[d.focus.selector]:d.focus.default},...e.disableIcon?[(t=d.variants[e.variant])==null?void 0:t[e.color],{"&:hover":{"@media (hover: hover)":(s=d.variants[`${e.variant}Hover`])==null?void 0:s[e.color]}},{"&:active":(i=d.variants[`${e.variant}Active`])==null?void 0:i[e.color]},{[`&.${Lw.disabled}`]:(n=d.variants[`${e.variant}Disabled`])==null?void 0:n[e.color]}]:[]]}),x6e=_e("input",{name:"JoyRadio",slot:"Input",overridesResolver:(d,e)=>e.input})(()=>({margin:0,opacity:0,position:"absolute",height:"100%",width:"100%",cursor:"pointer"})),P6e=_e("label",{name:"JoyRadio",slot:"Label",overridesResolver:(d,e)=>e.label})(({ownerState:d})=>W({flex:1,minWidth:0},d.disableIcon&&{zIndex:1,pointerEvents:"none"})),I6e=_e("span",{name:"JoyRadio",slot:"Icon",overridesResolver:(d,e)=>e.icon})(({ownerState:d})=>({width:"calc(var(--Radio-size) / 2)",height:"calc(var(--Radio-size) / 2)",borderRadius:"inherit",color:"inherit",backgroundColor:"currentColor",transform:d.checked?"scale(1)":"scale(0)"})),C6e=B.forwardRef(function(e,t){var s,i,n,r,a,o,c;const u=qt({props:e,name:"JoyRadio"}),{checked:h,checkedIcon:l,defaultChecked:f,disabled:p,disableIcon:m=!1,overlay:g=!1,label:y,id:w,name:b,onBlur:S,onChange:v,onFocus:C,onFocusVisible:M,readOnly:_,required:N,color:A,variant:R="outlined",size:D="md",uncheckedIcon:U,value:K,component:j,slots:z={},slotProps:J={}}=u,Y=at(u,b6e),X=B.useContext($o),Z=ln(w??(X==null?void 0:X.htmlFor)),te=B.useContext(gL),Q=X!=null&&X.error?"danger":(s=(i=(n=e.color)!=null?n:X==null?void 0:X.color)!=null?i:A)!=null?s:"primary",ie=X!=null&&X.error?"danger":(r=(a=(o=e.color)!=null?o:X==null?void 0:X.color)!=null?a:A)!=null?r:"neutral",ne=e.size||(X==null?void 0:X.size)||(te==null?void 0:te.size)||D,oe=e.name||(te==null?void 0:te.name)||b,me=e.disableIcon||(te==null?void 0:te.disableIcon)||m,fe=e.overlay||(te==null?void 0:te.overlay)||g,Se={checked:typeof h>"u"&&K!=null?S6e(te==null?void 0:te.value,K):h,defaultChecked:f,disabled:e.disabled||(X==null?void 0:X.disabled)||p,onBlur:S,onChange:v,onFocus:C,onFocusVisible:M},{getInputProps:ye,checked:ge,disabled:Te,focusVisible:Ge}=JA(Se),Ye=(c=e.color)!=null?c:ge?Q:ie,Re=W({},u,{checked:ge,disabled:Te,focusVisible:Ge,color:Ye,variant:R,size:ne,disableIcon:me,overlay:fe,orientation:te==null?void 0:te.orientation}),Be=k6e(Re),Me=W({},Y,{component:j,slots:z,slotProps:J}),[Le,rt]=Fe("root",{ref:t,className:Be.root,elementType:v6e,externalForwardedProps:Me,ownerState:Re}),[ze,Ue]=Fe("radio",{className:Be.radio,elementType:T6e,externalForwardedProps:Me,ownerState:Re}),[Je,st]=Fe("icon",{className:Be.icon,elementType:I6e,externalForwardedProps:Me,ownerState:Re}),[ut,yt]=Fe("action",{className:Be.action,elementType:O6e,externalForwardedProps:Me,ownerState:Re}),[Bt,lt]=Fe("input",{additionalProps:{type:"radio",role:void 0,id:Z,name:oe,readOnly:_,required:N??(X==null?void 0:X.required),value:String(K),"aria-describedby":X==null?void 0:X["aria-describedby"]},className:Be.input,elementType:x6e,externalForwardedProps:Me,getSlotProps:()=>ye({onChange:te==null?void 0:te.onChange}),ownerState:Re}),[ht,ft]=Fe("label",{additionalProps:{htmlFor:Z},className:Be.label,elementType:P6e,externalForwardedProps:Me,ownerState:Re});return P.jsxs(Le,W({},rt,{children:[P.jsxs(ze,W({},Ue,{children:[ge&&!me&&l,!ge&&!me&&U,!l&&!U&&!me&&P.jsx(Je,W({},st)),P.jsx(ut,W({},yt,{children:P.jsx(Bt,W({},lt))}))]})),y&&P.jsx(ht,W({},ft,{children:P.jsx(xv.Provider,{value:!0,children:y})}))]}))});function M6e(d){return Rt("MuiRadioGroup",d)}Dt("MuiRadioGroup",["root","colorPrimary","colorNeutral","colorDanger","colorSuccess","colorWarning","variantPlain","variantOutlined","variantSoft","variantSolid","sizeSm","sizeMd","sizeLg","horizontal","vertical"]);const _6e=["className","component","children","name","defaultValue","disableIcon","overlay","value","onChange","color","variant","size","orientation","role","slots","slotProps"],A6e=d=>{const{orientation:e,size:t,variant:s,color:i}=d,n={root:["root",e,s&&`variant${De(s)}`,i&&`color${De(i)}`,t&&`size${De(t)}`]};return Nt(n,M6e,{})},L6e=_e("div",{name:"JoyRadioGroup",slot:"Root",overridesResolver:(d,e)=>e.root})(({ownerState:d,theme:e})=>{var t;return W({},d.size==="sm"&&{"--RadioGroup-gap":"0.625rem"},d.size==="md"&&{"--RadioGroup-gap":"0.875rem"},d.size==="lg"&&{"--RadioGroup-gap":"1.25rem"},{display:"flex",margin:"var(--unstable_RadioGroup-margin)",flexDirection:d.orientation==="horizontal"?"row":"column",borderRadius:e.vars.radius.sm},(t=e.variants[d.variant])==null?void 0:t[d.color])}),B6e=B.forwardRef(function(e,t){const s=qt({props:e,name:"JoyRadioGroup"}),{className:i,component:n,children:r,name:a,defaultValue:o,disableIcon:c=!1,overlay:u,value:h,onChange:l,color:f="neutral",variant:p="plain",size:m="md",orientation:g="vertical",role:y="radiogroup",slots:w={},slotProps:b={}}=s,S=at(s,_6e),[v,C]=ch({controlled:h,default:o,name:"RadioGroup"}),M=B.useContext($o),_=e.size||(M==null?void 0:M.size)||m,N=W({orientation:g,size:_,variant:p,color:f,role:y},s),A=A6e(N),R=ln(a),D=B.useMemo(()=>({disableIcon:c,overlay:u,orientation:g,size:_,name:R,value:v,onChange:j=>{C(j.target.value),l&&l(j)}}),[c,R,l,u,g,C,_,v]),[U,K]=Fe("root",{ref:t,className:Gt(A.root,i),elementType:L6e,externalForwardedProps:W({},S,{component:n,slots:w,slotProps:b}),ownerState:N,additionalProps:{as:n,role:y,id:M==null?void 0:M.htmlFor,"aria-labelledby":M==null?void 0:M.labelId,"aria-describedby":M==null?void 0:M["aria-describedby"]}});return P.jsx(gL.Provider,{value:D,children:P.jsx(U,W({},K,{children:P.jsx($o.Provider,{value:void 0,children:B.Children.map(r,(j,z)=>B.isValidElement(j)?B.cloneElement(j,W({},z===0&&{"data-first-child":""},z===B.Children.count(r)-1&&{"data-last-child":""},{"data-parent":"RadioGroup"})):j)})}))})}),N6e=["checked","defaultChecked","disabled","onBlur","onChange","onFocus","onFocusVisible","readOnly","required","id","color","variant","size","startDecorator","endDecorator","component","slots","slotProps"],E6e=d=>{const{checked:e,disabled:t,focusVisible:s,readOnly:i,color:n,variant:r,size:a}=d,o={root:["root",e&&"checked",t&&"disabled",s&&"focusVisible",i&&"readOnly",r&&`variant${De(r)}`,n&&`color${De(n)}`,a&&`size${De(a)}`],thumb:["thumb",e&&"checked"],track:["track",e&&"checked"],action:["action",s&&"focusVisible"],input:["input"],startDecorator:["startDecorator"],endDecorator:["endDecorator"]};return Nt(o,Gke,{})},R6e=({theme:d,ownerState:e})=>(t={})=>{var s,i,n;const r=((s=d.variants[`${e.variant}${t.state||""}`])==null?void 0:s[e.color])||{};return{"--Switch-trackBackground":(i=r.backgroundColor)!=null?i:d.vars.palette.background.surface,"--Switch-trackColor":r.color,"--Switch-trackBorderColor":e.variant==="outlined"?r.borderColor:"currentColor","--Switch-thumbBackground":r.color,"--Switch-thumbColor":(n=r.backgroundColor)!=null?n:d.vars.palette.background.surface}},D6e=_e("div",{name:"JoySwitch",slot:"Root",overridesResolver:(d,e)=>e.root})(({theme:d,ownerState:e})=>{var t;const s=R6e({theme:d,ownerState:e});return W({"--Icon-color":"currentColor","--variant-borderWidth":(t=d.variants[e.variant])==null||(t=t[e.color])==null?void 0:t["--variant-borderWidth"],"--Switch-trackRadius":d.vars.radius.xl,"--Switch-thumbShadow":e.variant==="soft"?"none":"0 0 0 1px var(--Switch-trackBackground)"},e.size==="sm"&&{"--Switch-trackWidth":"26px","--Switch-trackHeight":"16px","--Switch-thumbSize":"10px",fontSize:d.vars.fontSize.sm,gap:"var(--Switch-gap, 6px)"},e.size==="md"&&{"--Switch-trackWidth":"32px","--Switch-trackHeight":"20px","--Switch-thumbSize":"14px",fontSize:d.vars.fontSize.md,gap:"var(--Switch-gap, 8px)"},e.size==="lg"&&{"--Switch-trackWidth":"40px","--Switch-trackHeight":"24px","--Switch-thumbSize":"18px",gap:"var(--Switch-gap, 12px)"},{"--unstable_paddingBlock":"max((var(--Switch-trackHeight) - 2 * var(--variant-borderWidth, 0px) - var(--Switch-thumbSize)) / 2, 0px)","--Switch-thumbRadius":"max(var(--Switch-trackRadius) - var(--unstable_paddingBlock), min(var(--unstable_paddingBlock) / 2, var(--Switch-trackRadius) / 2))","--Switch-thumbWidth":"var(--Switch-thumbSize)","--Switch-thumbOffset":"max((var(--Switch-trackHeight) - var(--Switch-thumbSize)) / 2, 0px)"},s(),{"&:hover":{"@media (hover: hover)":W({},s({state:"Hover"}))},[`&.${Av.checked}`]:W({},s(),{"&:hover":{"@media (hover: hover)":W({},s({state:"Hover"}))}}),[`&.${Av.disabled}`]:W({pointerEvents:"none",color:d.vars.palette.text.tertiary},s({state:"Disabled"})),display:"inline-flex",alignItems:"center",alignSelf:"center",fontFamily:d.vars.fontFamily.body,position:"relative",padding:"calc((var(--Switch-thumbSize) / 2) - (var(--Switch-trackHeight) / 2)) calc(-1 * var(--Switch-thumbOffset))",backgroundColor:"initial",border:"none",margin:"var(--unstable_Switch-margin)"})}),q6e=_e("div",{name:"JoySwitch",slot:"Action",overridesResolver:(d,e)=>e.action})(({theme:d})=>({borderRadius:"var(--Switch-trackRadius)",position:"absolute",top:0,left:0,bottom:0,right:0,[d.focus.selector]:d.focus.default})),V6e=_e("input",{name:"JoySwitch",slot:"Input",overridesResolver:(d,e)=>e.input})({margin:0,height:"100%",width:"100%",opacity:0,position:"absolute",cursor:"pointer"}),F6e=_e("span",{name:"JoySwitch",slot:"Track",overridesResolver:(d,e)=>e.track})(({theme:d,ownerState:e})=>W({position:"relative",color:"var(--Switch-trackColor)",height:"var(--Switch-trackHeight)",width:"var(--Switch-trackWidth)",display:"flex",flexShrink:0,justifyContent:"space-between",alignItems:"center",boxSizing:"border-box",border:"var(--variant-borderWidth, 0px) solid",borderColor:"var(--Switch-trackBorderColor)",backgroundColor:"var(--Switch-trackBackground)",borderRadius:"var(--Switch-trackRadius)",fontFamily:d.vars.fontFamily.body},e.size==="sm"&&{fontSize:d.vars.fontSize.xs},e.size==="md"&&{fontSize:d.vars.fontSize.sm},e.size==="lg"&&{fontSize:d.vars.fontSize.md})),H6e=_e("span",{name:"JoySwitch",slot:"Thumb",overridesResolver:(d,e)=>e.thumb})({"--Icon-fontSize":"calc(var(--Switch-thumbSize) * 0.75)",display:"inline-flex",justifyContent:"center",alignItems:"center",position:"absolute",top:"50%",left:"calc(50% - var(--Switch-trackWidth) / 2 + var(--Switch-thumbWidth) / 2 + var(--Switch-thumbOffset))",transform:"translate(-50%, -50%)",width:"var(--Switch-thumbWidth)",height:"var(--Switch-thumbSize)",borderRadius:"var(--Switch-thumbRadius)",boxShadow:"var(--Switch-thumbShadow)",color:"var(--Switch-thumbColor)",backgroundColor:"var(--Switch-thumbBackground)",[`&.${Av.checked}`]:{left:"calc(50% + var(--Switch-trackWidth) / 2 - var(--Switch-thumbWidth) / 2 - var(--Switch-thumbOffset))"}}),G6e=_e("span",{name:"JoySwitch",slot:"StartDecorator",overridesResolver:(d,e)=>e.startDecorator})({display:"inline-flex"}),U6e=_e("span",{name:"JoySwitch",slot:"EndDecorator",overridesResolver:(d,e)=>e.endDecorator})({display:"inline-flex"}),W6e=B.forwardRef(function(e,t){var s,i,n,r,a,o;const c=qt({props:e,name:"JoySwitch"}),{disabled:u,id:h,color:l,variant:f="solid",size:p="md",startDecorator:m,endDecorator:g,component:y,slots:w={},slotProps:b={}}=c,S=at(c,N6e),v=B.useContext($o),C=(s=(i=e.size)!=null?i:v==null?void 0:v.size)!=null?s:p,M=(n=e.color)!=null?n:v!=null&&v.error?"danger":(r=v==null?void 0:v.color)!=null?r:l,_=W({disabled:(a=(o=e.disabled)!=null?o:v==null?void 0:v.disabled)!=null?a:u},c),{getInputProps:N,checked:A,disabled:R,focusVisible:D,readOnly:U}=JA(_),K=W({},c,{id:h,checked:A,disabled:R,focusVisible:D,readOnly:U,color:A?M||"primary":M||"neutral",variant:f,size:C}),j=E6e(K),z=W({},S,{component:y,slots:w,slotProps:b}),[J,Y]=Fe("root",{ref:t,className:j.root,elementType:D6e,externalForwardedProps:z,ownerState:K}),[X,Z]=Fe("startDecorator",{additionalProps:{"aria-hidden":!0},className:j.startDecorator,elementType:G6e,externalForwardedProps:z,ownerState:K}),[te,Q]=Fe("endDecorator",{additionalProps:{"aria-hidden":!0},className:j.endDecorator,elementType:U6e,externalForwardedProps:z,ownerState:K}),[ie,ne]=Fe("track",{className:j.track,elementType:F6e,externalForwardedProps:z,ownerState:K}),[oe,me]=Fe("thumb",{className:j.thumb,elementType:H6e,externalForwardedProps:z,ownerState:K}),[fe,he]=Fe("action",{className:j.action,elementType:q6e,externalForwardedProps:z,ownerState:K}),[Se,ye]=Fe("input",{additionalProps:{id:h??(v==null?void 0:v.htmlFor),"aria-describedby":v==null?void 0:v["aria-describedby"]},className:j.input,elementType:V6e,externalForwardedProps:z,getSlotProps:N,ownerState:K});return P.jsxs(J,W({},Y,{children:[m&&P.jsx(X,W({},Z,{children:typeof m=="function"?m(K):m})),P.jsxs(ie,W({},ne,{children:[ne==null?void 0:ne.children,P.jsx(oe,W({},me))]})),P.jsx(fe,W({},he,{children:P.jsx(Se,W({},ye))})),g&&P.jsx(te,W({},Q,{children:typeof g=="function"?g(K):g}))]}))});function j6e(d){return Rt("MuiTextarea",d)}const p$=Dt("MuiTextarea",["root","textarea","startDecorator","endDecorator","formControl","disabled","error","focused","colorPrimary","colorNeutral","colorDanger","colorSuccess","colorWarning","colorContext","sizeSm","sizeMd","sizeLg","variantPlain","variantOutlined","variantSoft"]),z6e=["propsToForward","rootStateClasses","inputStateClasses","getRootProps","getInputProps","formControl","focused","error","disabled","size","color","variant","startDecorator","endDecorator","minRows","maxRows","component","slots","slotProps"],$6e=d=>{const{disabled:e,variant:t,color:s,size:i}=d,n={root:["root",e&&"disabled",t&&`variant${De(t)}`,s&&`color${De(s)}`,i&&`size${De(i)}`],textarea:["textarea"],startDecorator:["startDecorator"],endDecorator:["endDecorator"]};return Nt(n,j6e,{})},K6e=_e("div",{name:"JoyTextarea",slot:"Root",overridesResolver:(d,e)=>e.root})(({theme:d,ownerState:e})=>{var t,s,i,n,r,a;const o=(t=d.variants[`${e.variant}`])==null?void 0:t[e.color];return[W({"--Textarea-radius":d.vars.radius.sm,"--Textarea-gap":"0.5rem","--Textarea-placeholderColor":"inherit","--Textarea-placeholderOpacity":.64,"--Textarea-decoratorColor":d.vars.palette.text.icon,"--Textarea-focused":"0","--Textarea-focusedThickness":d.vars.focus.thickness,"--Textarea-focusedHighlight":(s=d.vars.palette[e.color==="neutral"?"primary":e.color])==null?void 0:s[500],'&:not([data-inverted-colors="false"])':W({},e.instanceColor&&{"--_Textarea-focusedHighlight":(i=d.vars.palette[e.instanceColor==="neutral"?"primary":e.instanceColor])==null?void 0:i[500]},{"--Textarea-focusedHighlight":`var(--_Textarea-focusedHighlight, ${d.vars.palette.focusVisible})`})},e.size==="sm"&&{"--Textarea-minHeight":"2rem","--Textarea-paddingBlock":"calc(0.375rem - 0.5px - var(--variant-borderWidth, 0px))","--Textarea-paddingInline":"0.5rem","--Textarea-decoratorChildHeight":"min(1.5rem, var(--Textarea-minHeight))","--Icon-fontSize":d.vars.fontSize.xl},e.size==="md"&&{"--Textarea-minHeight":"2.25rem","--Textarea-paddingBlock":"calc(0.375rem - var(--variant-borderWidth, 0px))","--Textarea-paddingInline":"0.75rem","--Textarea-decoratorChildHeight":"min(1.75rem, var(--Textarea-minHeight))","--Icon-fontSize":d.vars.fontSize.xl2},e.size==="lg"&&{"--Textarea-minHeight":"3rem","--Textarea-paddingBlock":"calc(0.75rem - var(--variant-borderWidth, 0px))","--Textarea-paddingInline":"1rem","--Textarea-gap":"0.75rem","--Textarea-decoratorChildHeight":"min(2.375rem, var(--Textarea-minHeight))","--Icon-fontSize":d.vars.fontSize.xl2},{"--_Textarea-paddingBlock":"max((var(--Textarea-minHeight) - 2 * var(--variant-borderWidth, 0px) - var(--Textarea-decoratorChildHeight)) / 2, 0px)","--Textarea-decoratorChildRadius":"max(var(--Textarea-radius) - var(--variant-borderWidth, 0px) - var(--_Textarea-paddingBlock), min(var(--_Textarea-paddingBlock) + var(--variant-borderWidth, 0px), var(--Textarea-radius) / 2))","--Button-minHeight":"var(--Textarea-decoratorChildHeight)","--Button-paddingBlock":"0px","--IconButton-size":"var(--Textarea-decoratorChildHeight)","--Button-radius":"var(--Textarea-decoratorChildRadius)","--IconButton-radius":"var(--Textarea-decoratorChildRadius)",boxSizing:"border-box"},e.variant!=="plain"&&{boxShadow:d.shadow.xs},{minWidth:0,minHeight:"var(--Textarea-minHeight)",cursor:"text",position:"relative",display:"flex",flexDirection:"column",paddingInlineStart:"var(--Textarea-paddingInline)",paddingBlock:"var(--Textarea-paddingBlock)",borderRadius:"var(--Textarea-radius)"},d.typography[`body-${e.size}`],o,{backgroundColor:(n=o==null?void 0:o.backgroundColor)!=null?n:d.vars.palette.background.surface,"&::before":{boxSizing:"border-box",content:'""',display:"block",position:"absolute",pointerEvents:"none",top:0,left:0,right:0,bottom:0,zIndex:1,borderRadius:"inherit",margin:"calc(var(--variant-borderWidth, 0px) * -1)",boxShadow:"var(--Textarea-focusedInset, inset) 0 0 0 calc(var(--Textarea-focused) * var(--Textarea-focusedThickness)) var(--Textarea-focusedHighlight)"}}),{"&:hover":W({},(r=d.variants[`${e.variant}Hover`])==null?void 0:r[e.color],{backgroundColor:null,cursor:"text"}),[`&.${p$.disabled}`]:(a=d.variants[`${e.variant}Disabled`])==null?void 0:a[e.color],"&:focus-within::before":{"--Textarea-focused":"1"}}]}),X6e=_e(sye,{name:"JoyTextarea",slot:"Textarea",overridesResolver:(d,e)=>e.textarea})({resize:"none",border:"none",minWidth:0,outline:0,padding:0,paddingInlineEnd:"var(--Textarea-paddingInline)",flex:"auto",alignSelf:"stretch",color:"inherit",backgroundColor:"transparent",fontFamily:"inherit",fontSize:"inherit",fontStyle:"inherit",fontWeight:"inherit",lineHeight:"inherit","&::-webkit-input-placeholder":{color:"var(--Textarea-placeholderColor)",opacity:"var(--Textarea-placeholderOpacity)"},"&::-moz-placeholder":{color:"var(--Textarea-placeholderColor)",opacity:"var(--Textarea-placeholderOpacity)"},"&:-ms-input-placeholder":{color:"var(--Textarea-placeholderColor)",opacity:"var(--Textarea-placeholderOpacity)"},"&::-ms-input-placeholder":{color:"var(--Textarea-placeholderColor)",opacity:"var(--Textarea-placeholderOpacity)"}}),Q6e=_e("div",{name:"JoyTextarea",slot:"StartDecorator",overridesResolver:(d,e)=>e.startDecorator})({display:"flex",marginInlineStart:"calc(var(--Textarea-paddingBlock) - var(--Textarea-paddingInline))",marginInlineEnd:"var(--Textarea-paddingBlock)",marginBlockEnd:"var(--Textarea-gap)",color:"var(--Textarea-decoratorColor)",cursor:"initial"}),Y6e=_e("div",{name:"JoyTextarea",slot:"EndDecorator",overridesResolver:(d,e)=>e.endDecorator})({display:"flex",marginInlineStart:"calc(var(--Textarea-paddingBlock) - var(--Textarea-paddingInline))",marginInlineEnd:"var(--Textarea-paddingBlock)",marginBlockStart:"var(--Textarea-gap)",color:"var(--Textarea-decoratorColor)",cursor:"initial"}),Z6e=B.forwardRef(function(e,t){var s,i,n,r,a,o,c,u;const h=qt({props:e,name:"JoyTextarea"}),l=iW(h,p$),{propsToForward:f,rootStateClasses:p,inputStateClasses:m,getRootProps:g,getInputProps:y,formControl:w,focused:b,error:S=!1,disabled:v=!1,size:C="md",color:M="neutral",variant:_="outlined",startDecorator:N,endDecorator:A,minRows:R,maxRows:D,component:U,slots:K={},slotProps:j={}}=l,z=at(l,z6e),J=(s=(i=e.disabled)!=null?i:w==null?void 0:w.disabled)!=null?s:v,Y=(n=(r=e.error)!=null?r:w==null?void 0:w.error)!=null?n:S,X=(a=(o=e.size)!=null?o:w==null?void 0:w.size)!=null?a:C,Z=(c=e.color)!=null?c:Y?"danger":(u=w==null?void 0:w.color)!=null?u:M,te=W({instanceColor:Y?"danger":e.color},h,{color:Z,disabled:J,error:Y,focused:b,size:X,variant:_}),Q=$6e(te),ie=W({},z,{component:U,slots:K,slotProps:j}),[ne,oe]=Fe("root",{ref:t,className:[Q.root,p],elementType:K6e,externalForwardedProps:ie,getSlotProps:g,ownerState:te}),[me,fe]=Fe("textarea",{additionalProps:{id:w==null?void 0:w.htmlFor,"aria-describedby":w==null?void 0:w["aria-describedby"]},className:[Q.textarea,m],elementType:X6e,internalForwardedProps:W({},f,{minRows:R,maxRows:D}),externalForwardedProps:ie,getSlotProps:y,ownerState:te}),[he,Se]=Fe("startDecorator",{className:Q.startDecorator,elementType:Q6e,externalForwardedProps:ie,ownerState:te}),[ye,ge]=Fe("endDecorator",{className:Q.endDecorator,elementType:Y6e,externalForwardedProps:ie,ownerState:te});return P.jsxs(ne,W({},oe,{children:[N&&P.jsx(he,W({},Se,{children:N})),P.jsx(me,W({},fe)),A&&P.jsx(ye,W({},ge,{children:A}))]}))}),J6e=({smartTrade:d})=>d.entryOrder.status==="Filled"?P.jsx(nn,{color:"danger",variant:"soft",children:"Selling"}):P.jsx(nn,{color:"success",variant:"soft",children:"Buying"}),eHe=({type:d})=>P.jsx(nn,{color:"neutral",size:"sm",variant:"outlined",children:d}),tHe=({smartTrade:d})=>{const e=d.entryOrder.status==="Filled",t=new Ro(d.entryOrder.price||0).times(d.entryOrder.quantity).toFixed(2).toString(),s=Jl(new Date(d.createdAt).getTime(),!0),{entryOrder:i,takeProfitOrder:n}=d,r=e?n.price:i.price,{baseCurrency:a,quoteCurrency:o}=Kd(d.symbol);return P.jsxs("tr",{tabIndex:-1,children:[P.jsx("th",{scope:"row",children:P.jsx(eHe,{type:d.type})}),P.jsxs("th",{scope:"row",style:{textAlign:"right"},children:[d.entryOrder.quantity," ",a]}),P.jsx("th",{scope:"row",children:P.jsx(In,{title:`Buy ${d.entryOrder.price} / Sell ${d.takeProfitOrder.price}`,children:P.jsxs("span",{children:[r," ",o]})})}),P.jsx("th",{scope:"row",children:P.jsx(J6e,{smartTrade:d})}),P.jsx("th",{scope:"row",children:P.jsxs("div",{children:[P.jsx("span",{children:d.entryOrder.status}),P.jsx("span",{children:" / "}),P.jsx("span",{children:d.takeProfitOrder.status})]})}),P.jsxs("th",{scope:"row",children:[" ",t," ",o]}),P.jsx("th",{scope:"row",style:{textAlign:"right"},children:s}),P.jsx("th",{scope:"row",style:{width:f$,textAlign:"right"},children:P.jsx(In,{title:P.jsxs(_t,{children:[P.jsxs(ot,{children:["SmartTrade ID: ",d.id]}),P.jsxs(ot,{children:["SmartTrade Ref: ",d.ref]})]}),children:P.jsx(ot,{children:d.id})})})]})};function sHe(){return P.jsx("tbody",{children:P.jsx("tr",{children:P.jsx("td",{colSpan:8,children:P.jsx(ot,{fontWeight:"400",level:"h4",sx:{py:2},textAlign:"center",children:"No trades yet..."})})})})}const YB=({botId:d})=>{const[e]=kt.bot.activeSmartTrades.useSuspenseQuery({botId:d});return P.jsx(dg,{sx:{width:"100%",boxShadow:"sm",borderRadius:"sm"},variant:"outlined",children:P.jsxs(_O,{hoverRow:!0,sx:{"--TableCell-headBackground":"transparent","--TableCell-selectedBackground":t=>t.vars.palette.success.softBg,"& thead th:nth-child(1)":{width:"64px"}},children:[P.jsx(y6e,{}),e.length>0?P.jsx("tbody",{children:e.map(t=>P.jsx(tHe,{smartTrade:t},t.id))}):P.jsx(sHe,{})]})})},m$=72,g$=64,ZB=10,iHe=100,LF=({children:d})=>P.jsx("thead",{children:P.jsx("tr",{children:P.jsx("td",{colSpan:ZB,style:{backgroundColor:"var(--joy-palette-background-level1)"},children:P.jsx(_t,{sx:{display:"flex",alignItems:"center",gap:1,justifyContent:"center"},children:d})})})});function BF(d){return{entityType:d.entityType,side:d.side===vue.Buy?im.Buy:im.Sell,order:d,trade:d.smartTrade}}const nHe=_e("tr")({"&:hover":{backgroundColor:"unset !important"}}),NF=({placeholder:d})=>P.jsx("tbody",{children:P.jsx(nHe,{children:P.jsx("td",{colSpan:ZB,children:P.jsx(ot,{fontWeight:"400",level:"h4",sx:{py:2},textAlign:"center",children:d||"No orders"})})})}),EF=()=>P.jsx("thead",{children:P.jsxs("tr",{children:[P.jsx("th",{children:"Side"}),P.jsx("th",{style:{width:m$},children:"Type"}),P.jsx("th",{style:{textAlign:"right"},children:"Quantity"}),P.jsx("th",{children:"Price"}),P.jsx("th",{children:"Amount"}),P.jsx("th",{children:"Status"}),P.jsx("th",{children:"PnL"}),P.jsx("th",{style:{textAlign:"right"},children:"Opened"}),P.jsx("th",{style:{textAlign:"right"},children:"Filled"}),P.jsx("th",{style:{textAlign:"right",width:g$},children:"ID"})]})}),rHe=({children:d})=>P.jsx("tfoot",{children:P.jsx("tr",{children:P.jsx("td",{colSpan:ZB,children:P.jsx(_t,{sx:{display:"flex",alignItems:"center",gap:2,justifyContent:"center"},children:d})})})});function aHe(d){switch(d){case"EntryOrder":return"EO";case"TakeProfitOrder":return"TP";case"SafetyOrder":return"SO";case"StopLossOrder":return"SL";default:return"UKN"}}const oHe={EntryOrder:"success",TakeProfitOrder:"danger",SafetyOrder:"warning",StopLossOrder:"neutral"},dHe=({type:d})=>P.jsx(In,{title:d,children:P.jsx(nn,{color:oHe[d],size:"sm",variant:"solid",children:aHe(d)})}),RF=({orderInfo:d,displayEntityType:e})=>{const{order:t,trade:s}=d,{symbol:i}=s,{baseCurrency:n,quoteCurrency:r}=Kd(i),a=new Ro(t.filledPrice||t.price||0).times(t.quantity).toFixed(2).toString(),o=fx(s),c=Jl(t.createdAt.getTime(),!0),u=t.filledAt?Jl(t.filledAt.getTime(),!0):"-";return P.jsxs("tr",{tabIndex:-1,children:[P.jsx("th",{scope:"row",children:P.jsx(ot,{sx:h=>({color:d.side===im.Buy?h.palette.success.outlinedColor:h.palette.danger.outlinedColor}),children:P.jsxs(_t,{display:"flex",alignItems:"center",gap:1,children:[P.jsx("span",{children:d.side===im.Buy?"BUY":"SELL"}),e?P.jsx(dHe,{type:d.entityType}):null]})})}),P.jsx("th",{scope:"row",style:{width:m$},children:t.type}),P.jsxs("th",{scope:"row",style:{textAlign:"right"},children:[t.quantity," ",n]}),P.jsx("th",{scope:"row",children:t.type==="Market"?P.jsx(P.Fragment,{children:t.filledPrice||"-"}):P.jsx(In,{title:P.jsxs(_t,{children:[P.jsxs(ot,{children:["Limit price: ",t.price]}),P.jsxs(ot,{children:["Filled price: ",t.filledPrice]})]}),children:P.jsxs(ot,{children:[t.filledPrice||t.price," ",r]})})}),P.jsxs("th",{scope:"row",children:[a," ",r]}),P.jsx("th",{scope:"row",children:t.status}),P.jsx("th",{scope:"row",children:d.side===im.Sell&&t.status==="Filled"?P.jsx(XB,{profit:o.netProfit,currency:r,size:"sm"}):P.jsx(P.Fragment,{children:"-"})}),P.jsx("th",{scope:"row",style:{textAlign:"right"},children:c}),P.jsx("th",{scope:"row",style:{textAlign:"right"},children:u}),P.jsx("th",{scope:"row",style:{textAlign:"right",width:g$},children:P.jsx(In,{title:P.jsxs(_t,{children:[P.jsxs(ot,{children:["SmartTrade ID: ",t.smartTradeId]}),P.jsxs(ot,{children:["Order ID: ",t.id]}),P.jsxs(ot,{children:["ExchangeOrder ID: ",t.exchangeOrderId]})]}),children:P.jsx(ot,{children:t.smartTradeId})})})]})};function cHe(d){return d.order.status==="Filled"&&!d.order.exchangeOrderId}const JB=({botId:d,filterOrderStatuses:e=[],displayEntityType:t})=>{const[s]=kt.order.openOrders.useSuspenseQuery({botId:d}),i=s.map(BF),[{pages:n},{hasNextPage:r,fetchNextPage:a}]=kt.order.infiniteOrders.useSuspenseInfiniteQuery({botId:d,limit:iHe,statuses:e},{getNextPageParam:c=>c.nextCursor}),o=n.flatMap(c=>c.items).map(BF).filter(c=>!cHe(c));return P.jsx(dg,{sx:{width:"100%",boxShadow:"sm",borderRadius:"sm"},variant:"outlined",children:P.jsxs(_O,{hoverRow:!0,sx:{"--TableCell-headBackground":"transparent","--TableCell-selectedBackground":c=>c.vars.palette.success.softBg,"& thead th:nth-child(1)":{width:t?"88px":"80px"}},children:[P.jsx(LF,{children:P.jsx(ot,{level:"body-sm",fontWeight:700,sx:{textTransform:"uppercase"},color:"neutral",children:"Open orders"})}),P.jsx(EF,{}),i.length>0?P.jsx("tbody",{children:i.map(c=>P.jsx(RF,{orderInfo:c,displayEntityType:t},c.order.id))}):P.jsx(NF,{placeholder:"No open orders"}),P.jsx(LF,{children:P.jsx(ot,{level:"body-sm",fontWeight:700,sx:{textTransform:"uppercase"},color:"neutral",children:"Closed orders"})}),P.jsx(EF,{}),o.length>0?P.jsx("tbody",{children:o.map(c=>P.jsx(RF,{orderInfo:c,displayEntityType:t},c.order.id))}):P.jsx(NF,{placeholder:"No closed orders"}),P.jsx(rHe,{children:P.jsx(Es,{onClick:()=>a(),size:"sm",color:"neutral",variant:"outlined",disabled:!r,children:"Load more"})})]})})},eN=({value:d,onChange:e})=>{const t=s=>P.jsxs(ef,{value:s,children:[P.jsx(qh,{children:P.jsx(vf,{checked:d.includes(s)})}),s]});return P.jsxs(fb,{multiple:!0,defaultValue:d,onChange:(s,i)=>e(i),size:"sm",sx:{minWidth:"13rem"},placeholder:"Any status",children:[t(Jf.Filled),t(Jf.Placed),t(Jf.Canceled),t(Jf.Revoked),t(Jf.Deleted),t(Jf.Idle)]})};function uHe(d){const{botId:e}=d,[t]=go(),[s,i]=B.useState(["Filled"]),[n,r]=B.useState("Orders");return P.jsxs(It,{container:!0,spacing:2,children:[P.jsxs(It,{md:9,children:[P.jsx(B.Suspense,{fallback:P.jsx(mi,{animation:"wave",height:Xo,sx:{borderRadius:8},variant:"rectangular",width:"100%"}),children:P.jsx(t6e,{botId:e})}),P.jsx(_t,{sx:{mt:2}}),P.jsx(B.Suspense,{fallback:P.jsx(mi,{animation:"wave",height:250,sx:{borderRadius:8},variant:"rectangular",width:"100%"}),children:P.jsxs(xL,{value:n,onChange:r,actions:n==="Orders"&&t?P.jsx(eN,{value:s,onChange:i}):null,children:[n==="Orders"?P.jsx(JB,{botId:e,filterOrderStatuses:s}):null,n==="SmartTrades"?P.jsx(YB,{botId:e}):null,n==="StrategyLogs"?P.jsx(OL,{botId:e}):null]})})]}),P.jsxs(It,{md:3,children:[P.jsx(B.Suspense,{fallback:P.jsx(mi,{animation:"wave",height:Xo,sx:{borderRadius:8},variant:"rectangular",width:"100%"}),children:P.jsx(tIe,{botId:e})}),P.jsx(_t,{sx:{mt:2}}),P.jsx(B.Suspense,{fallback:P.jsx(mi,{animation:"wave",height:250,sx:{borderRadius:8},variant:"rectangular",width:"100%"}),children:P.jsx(QB,{botId:e})})]})]})}const y$=vr("/_layout/dashboard/grid-bot/$id")({component:()=>{const{id:d}=y$.useParams();return P.jsx(uHe,{botId:Number(d)})}}),hHe=d=>"value"in d&&d.value!==void 0;function Md(d){const e=hHe(d),[t,s]=B.useState(e?d.value:d.initialValue);return[e?d.value:t,r=>{var a;e?(a=d.onChange)==null||a.call(d,r):s(r)}]}const DF=["Amaranth","Amber","Amethyst","Apricot","Aqua","Aquamarine","Azure","Beige","Black","Blue","Blush","Bronze","Brown","Chocolate","Coffee","Copper","Coral","Crimson","Cyan","Emerald","Fuchsia","Gold","Gray","Green","Harlequin","Indigo","Ivory","Jade","Lavender","Lime","Magenta","Maroon","Moccasin","Olive","Orange","Peach","Pink","Plum","Purple","Red","Rose","Salmon","Sapphire","Scarlet","Silver","Tan","Teal","Tomato","Turquoise","Violet","White","Yellow"],qF=["Ackbar","Adi Gallia","Anakin Skywalker","Arvel Crynyd","Ayla Secura","Bail Prestor Organa","Barriss Offee","Ben Quadinaros","Beru Whitesun lars","Bib Fortuna","Biggs Darklighter","Boba Fett","Bossk","C-3PO","Chewbacca","Cliegg Lars","Cordé","Darth Maul","Darth Vader","Dexter Jettster","Dooku","Dormé","Dud Bolt","Eeth Koth","Finis Valorum","Gasgano","Greedo","Gregar Typho","Grievous","Han Solo","IG-88","Jabba Desilijic Tiure","Jango Fett","Jar Jar Binks","Jek Tono Porkins","Jocasta Nu","Ki-Adi-Mundi","Kit Fisto","Lama Su","Lando Calrissian","Leia Organa","Lobot","Luke Skywalker","Luminara Unduli","Mace Windu","Mas Amedda","Mon Mothma","Nien Nunb","Nute Gunray","Obi-Wan Kenobi","Owen Lars","Padmé Amidala","Palpatine","Plo Koon","Poggle the Lesser","Quarsh Panaka","Qui-Gon Jinn","R2-D2","R4-P17","R5-D4","Ratts Tyerel","Raymus Antilles","Ric Olié","Roos Tarpals","Rugor Nass","Saesee Tiin","San Hill","Sebulba","Shaak Ti","Shmi Skywalker","Sly Moore","Tarfful","Taun We","Tion Medon","Wat Tambor","Watto","Wedge Antilles","Wicket Systri Warrick","Wilhuff Tarkin","Yarael Poof","Yoda","Zam Wesell"];function VF(d){const e=Math.random();return Math.floor(e*d.length)}function tN(){const d=DF[VF(DF)]||"",e=qF[VF(qF)]||"";return`${d} ${e}`}const w$=({value:d,onChange:e,exchangeCode:t})=>P.jsxs(ki,{children:[P.jsx(zi,{children:"Symbol"}),P.jsx(Ab,{exchangeCode:t,onChange:s=>{s&&e(s)},value:d})]}),b$=({value:d,onChange:e})=>P.jsxs(ki,{children:[P.jsx(zi,{children:"Exchange"}),P.jsx(_b,{onChange:t=>{t&&e(t)},value:d})]}),lHe=Ys(P.jsx("path",{d:"M12 5V1L7 6l5 5V7c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6H4c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8"}),"Replay"),k$=({value:d,onChange:e})=>{const t=n=>{e(n.target.value)},s=()=>{e(tN())},i=d.length===0?"Must be defined":null;return P.jsxs(ki,{error:!!i,children:[P.jsx(zi,{children:"Bot name"}),P.jsx(Pn,{endDecorator:P.jsx(Vd,{onClick:s,children:P.jsx(lHe,{})}),onChange:t,value:d}),i?P.jsx(Gm,{children:i}):null]})},S$=({value:d,onChange:e})=>P.jsxs(ki,{children:[P.jsx(zi,{children:"Timeframe"}),P.jsx(wg,{onChange:e,optional:!0,value:d})]}),v$=({checked:d,onChange:e})=>P.jsx(vf,{checked:d,label:"Enabled Logging",onChange:t=>e(t.target.checked)}),FF=d=>{if(d.length===0)throw new Error("Empty symbols array provided");return d.find(t=>t.currencyPair==="BTC/USDT")||d[0]},fHe=d=>{if(d.length===0)throw new Error("Empty exchange accounts array provided");return d[0]},T$=d=>{const{onSubmit:e,isLoading:t,hideTimeframe:s}=d,[i]=go(),[n,r]=Md({value:d.botName,onChange:d.onBotNameChange,initialValue:tN()}),[a,o]=Md({value:d.timeframe,onChange:d.onTimeframeChange,initialValue:mf.ONE_HOUR}),[c,u]=Md({value:d.logging,onChange:d.onLoggingChange,initialValue:!0}),[h]=kt.exchangeAccount.list.useSuspenseQuery(),[l,f]=Md({value:d.exchangeAccount,onChange:d.onExchangeAccountChange,initialValue:fHe(h)}),[p]=kt.symbol.list.useSuspenseQuery(l.exchangeCode),[m,g]=Md({value:d.symbol,onChange:d.onSymbolChange,initialValue:FF(p)});cm(l.exchangeCode)&&g(FF(p));const y=()=>{e({botName:n,exchangeAccountId:l.id,exchangeCode:l.exchangeCode,symbolId:m.symbolId,timeframe:a,logging:c})},w=!n||!l||!m;return P.jsxs(_t,{sx:{display:"grid",flexWrap:1,gap:2},children:[P.jsx(k$,{onChange:r,value:n}),s?null:P.jsx(S$,{onChange:o,value:a}),P.jsx(b$,{onChange:f,value:l}),P.jsx(w$,{exchangeCode:l.exchangeCode,onChange:g,value:m}),i?P.jsx(v$,{checked:c,onChange:u}):null,P.jsx(Es,{color:"primary",disabled:w,loading:t,loadingPosition:"start",onClick:y,size:"lg",variant:"soft",children:"Create a bot"})]})},pHe=d=>{const{defaultBot:e,onSubmit:t,isLoading:s,hideTimeframe:i}=d,[n]=go(),[r,a]=Md({value:d.botName,onChange:d.onBotNameChange,initialValue:e.name}),[o,c]=Md({value:d.timeframe,onChange:d.onTimeframeChange,initialValue:e.timeframe}),[u,h]=Md({value:d.logging,onChange:d.onLoggingChange,initialValue:e.logging}),[l]=kt.exchangeAccount.getOne.useSuspenseQuery(e.exchangeAccountId),[f,p]=Md({value:d.exchangeAccount,onChange:d.onExchangeAccountChange,initialValue:l}),m=ZT(f.exchangeCode,JT(e.symbol),eO(e.symbol)),[g]=kt.symbol.getOne.useSuspenseQuery({symbolId:m}),[y,w]=Md({value:d.symbol,onChange:d.onSymbolChange,initialValue:g});cm(f.exchangeCode)&&w(g);const b=()=>{t({botId:e.id,botName:r,exchangeAccountId:f.id,exchangeCode:f.exchangeCode,symbolId:y.symbolId,timeframe:o,logging:u})},S=!r||!f||!y;return P.jsxs(_t,{sx:{display:"grid",flexWrap:1,gap:2},children:[P.jsx(k$,{onChange:a,value:r}),i?null:P.jsx(S$,{onChange:c,value:o}),P.jsx(b$,{value:f,onChange:p}),P.jsx(w$,{exchangeCode:f.exchangeCode,onChange:w,value:y}),n?P.jsx(v$,{checked:u,onChange:h}):null,P.jsx(Es,{color:"primary",disabled:S,loading:s,loadingPosition:"start",onClick:b,size:"lg",variant:"soft",children:"Update bot"})]})},Zd=()=>Wde(),Gn=zde;function mHe(){const{showSnackbar:d}=Tr(),e=Zc(),t=Gn(fhe),{mutate:s,isLoading:i}=kt.dcaBot.create.useMutation({onSuccess(r){d("Bot created successfully"),setTimeout(()=>{e({to:ai("dca-bot/:id",r.id)})},1e3)}});return{isLoading:i,handleSubmit:()=>{const r=gHe(t);s(r)}}}function gHe(d){const{entryOrderType:e,entryOrderQuantity:t,entryConditions:s,takeProfitPercent:i,safetyOrders:n,symbolId:r,exchangeAccountId:a,botName:o}=d,{currencyPairSymbol:c}=MA(r);return{exchangeAccountId:a,data:{name:o,settings:{entry:{type:e,quantity:Number(t),conditions:s},tp:{percent:i},safetyOrders:n},symbol:c}}}function yHe(d,e){return d.map(s=>e-s.priceDeviation/100*e).map((s,i)=>{const n=d[i].priceDeviation;return gb(s,"yellow",`SO ${n}%`)})}function wHe(d){return gb(d,"blue","Entry")}function bHe(d,e){const t=e+d/100*e;return gb(t,"red","TP")}function O$({entryPrice:d,safetyOrders:e,takeProfitPercent:t}){return B.useMemo(()=>{const s=wHe(d),i=yHe(e,d);return[bHe(t,d),s,...i]},[e,d,t])}const kHe=["1d","4h","1h","5m","1m"],HF=()=>{},SHe=({botId:d})=>{const[e]=kt.dcaBot.getOne.useSuspenseQuery(d),[t]=kt.exchangeAccount.getOne.useSuspenseQuery(e.exchangeAccountId),[s]=kt.symbol.getOne.useSuspenseQuery({symbolId:ZT(t.exchangeCode,JT(e.symbol),eO(e.symbol))}),[{price:i}]=kt.symbol.price.useSuspenseQuery({symbolId:s.symbolId}),[n,r]=B.useState("1h"),[a]=kt.smartTrade.list.useSuspenseQuery({botId:d}),o=O$({entryPrice:i,safetyOrders:e.settings.safetyOrders,takeProfitPercent:e.settings.tp.percent}),[c,u]=B.useState(!1),h=B.useMemo(()=>KB(a,n),[a,n]),[l,f]=B.useState(!0);return P.jsx(B.Suspense,{fallback:P.jsx(mi,{animation:"wave",height:Xo,variant:"rectangular",width:"100%"}),children:P.jsxs(hx,{barSize:n,markers:h,priceLines:o,showMarkers:l,showPriceLines:c,symbolId:s.symbolId,children:[P.jsx(_b,{onChange:HF,value:t,disabled:!0}),P.jsx(Ab,{exchangeCode:t.exchangeCode,onChange:HF,value:s,disabled:!0}),P.jsx(wg,{onChange:p=>{r(p)},value:n,whitelist:kHe}),P.jsx(Rc,{}),P.jsx(_t,{display:"flex",children:P.jsx(lx,{gridVisible:c,onGridVisibleChange:u,onTradesVisibleChange:f,tradesVisible:l})})]})})},vHe=({symbolId:d,barSize:e,onBarSizeChange:t,safetyOrders:s,takeProfitPercent:i,currentAssetPrice:n})=>{const r=B.useDeferredValue(d),a=d!==r,o=O$({entryPrice:n,safetyOrders:s,takeProfitPercent:i}),[c,u]=B.useState(!0);return P.jsx(B.Suspense,{fallback:P.jsx(mi,{animation:"wave",height:Xo,variant:"rectangular",width:"100%"}),children:P.jsxs(hx,{barSize:e,dimmed:a,priceLines:o,showPriceLines:c,symbolId:r,children:[P.jsx(wg,{onChange:h=>{t&&t(h)},value:e,whitelist:jue}),P.jsx(Rc,{}),P.jsx(_t,{display:"flex",children:P.jsx(lx,{gridVisible:c,hideTradesButton:!0,onGridVisibleChange:u})})]})})};function x$(d,e){var t={};for(var s in d)Object.prototype.hasOwnProperty.call(d,s)&&e.indexOf(s)<0&&(t[s]=d[s]);if(d!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,s=Object.getOwnPropertySymbols(d);i=a?i=i+GF("0",r-a):i=(i.substring(0,r)||"0")+"."+i.substring(r),t+i}function UF(d,e,t){if(["","-"].indexOf(d)!==-1)return d;var s=(d.indexOf(".")!==-1||t)&&e,i=sN(d),n=i.beforeDecimal,r=i.afterDecimal,a=i.hasNegation,o=parseFloat("0."+(r||"0")),c=r.length<=e?"0."+r:o.toFixed(e),u=c.split("."),h=n;n&&Number(u[0])&&(h=n.split("").reverse().reduce(function(m,g,y){return m.length>y?(Number(m[0])+Number(g)).toString()+m.substring(1,m.length):g+m},u[0]));var l=C$(u[1]||"",e,t),f=a?"-":"",p=s?".":"";return""+f+h+p+l}function wl(d,e){if(d.value=d.value,d!==null){if(d.createTextRange){var t=d.createTextRange();return t.move("character",e),t.select(),!0}return d.selectionStart||d.selectionStart===0?(d.focus(),d.setSelectionRange(e,e),!0):(d.focus(),!1)}}var _$=THe(function(d,e){for(var t=0,s=0,i=d.length,n=e.length;d[t]===e[t]&&tt&&i-s>t;)s++;return{from:{start:t,end:i-s},to:{start:t,end:n-s}}}),MHe=function(d,e){var t=Math.min(d.selectionStart,e);return{from:{start:t,end:d.selectionEnd},to:{start:t,end:e}}};function _He(d,e,t){return Math.min(Math.max(d,e),t)}function OC(d){return Math.max(d.selectionStart,d.selectionEnd)}function AHe(){return typeof navigator<"u"&&!(navigator.platform&&/iPhone|iPod/.test(navigator.platform))}function LHe(d){return{from:{start:0,end:0},to:{start:0,end:d.length},lastValue:""}}function BHe(d){var e=d.currentValue,t=d.formattedValue,s=d.currentValueIndex,i=d.formattedValueIndex;return e[s]===t[i]}function NHe(d,e,t,s,i,n,r){r===void 0&&(r=BHe);var a=i.findIndex(function(S){return S}),o=d.slice(0,a);!e&&!t.startsWith(o)&&(e=o,t=o+t,s=s+o.length);for(var c=t.length,u=d.length,h={},l=new Array(c),f=0;f0&&l[y]===-1;)y--;var b=y===-1||l[y]===-1?0:l[y]+1;return b>w?w:s-b=0&&!t[e];)e--;e===-1&&(e=t.indexOf(!0))}else{for(;e<=i&&!t[e];)e++;e>i&&(e=t.lastIndexOf(!0))}return e===-1&&(e=i),e}function EHe(d){for(var e=Array.from({length:d.length+1}).map(function(){return!0}),t=0,s=e.length;tM.length-r.length||CR||h>d.length-r.length)&&(A=h),d=d.substring(0,A),d=VHe(b?"-"+d:d,i),d=(d.match(FHe(p))||[]).join("");var D=d.indexOf(p);d=d.replace(new RegExp(I$(p),"g"),function(J,Y){return Y===D?".":""});var U=sN(d,i),K=U.beforeDecimal,j=U.afterDecimal,z=U.addNegation;return c.end-c.start0&&r.call(this,e,t)}handleErrorMessage(e,t){const s=this.safeString(t,"id"),i=this.safeString(t,"event"),n=this.safeList(t,"data"),r=this.safeDict(n,0),a=this.safeString(r,"orderId");if(i==="error"||a==="0")try{const o=this.safeString(r,"message"),c=this.safeString(r,"code"),u=this.id+" "+this.json(t);throw this.throwExactlyMatchedException(this.exceptions.exact,c,u),this.throwBroadlyMatchedException(this.exceptions.broad,o,u),new I(u)}catch(o){if(o instanceof $){const c="authenticated";e.reject(o,c),c in e.subscriptions&&delete e.subscriptions[c]}else e.reject(o,s);return!0}return!1}handleAuthenticate(e,t){const s=this.safeValue(t,"data"),i=this.safeValue(s,"success"),n="authenticated";if(i)e.resolve(t,n);else{const r=new $(this.id+" "+this.json(t));e.reject(r,n),n in e.subscriptions&&delete e.subscriptions[n]}return t}ping(e){return{event:"ping"}}}class iFe extends U9{describe(){return this.deepExtend(super.describe(),{has:{ws:!0,cancelAllOrdersWs:!1,cancelOrdersWs:!1,cancelOrderWs:!1,createOrderWs:!1,editOrderWs:!1,fetchBalanceWs:!1,fetchOpenOrdersWs:!1,fetchOrderWs:!1,fetchTradesWs:!1,watchOHLCV:!1,watchOrderBook:!0,watchTicker:!0,watchTickers:!1,watchTrades:!0,watchTradesForSymbols:!1,watchBalance:!0,watchOrders:!0,watchMyTrades:!1,watchPosition:void 0,watchPositions:!1},urls:{api:{ws:"wss://futures-apiws.poloniex.com/endpoint"}},options:{tradesLimit:1e3,ordersLimit:1e3,watchTicker:{method:"/contractMarket/ticker"},watchOrders:{method:"/contractMarket/tradeOrders"},watchOrderBook:{method:"/contractMarket/level2",snapshotDelay:5,snapshotMaxRetries:3,checksum:!0},streamLimit:5,streamBySubscriptionsHash:{},streamIndex:-1},streaming:{keepAlive:3e4,maxPingPongMisses:2}})}async negotiate(e,t={}){const s=e?"private":"public",i=this.safeValue(this.options,"urls",{});return s in i?await i[s]:(i[s]=this.spawn(this.negotiateHelper,e,t),this.options.urls=i,await i[s])}async negotiateHelper(e,t={}){let s;const i=e?"private":"public";try{e?s=await this.privatePostBulletPrivate(t):s=await this.publicPostBulletPublic(t);const n=this.safeValue(s,"data",{}),r=this.safeValue(n,"instanceServers",[]),a=this.safeValue(r,0),o=this.safeInteger(a,"pingInterval"),c=this.safeString(a,"endpoint"),u=this.safeString(n,"token"),h=c+"?"+this.urlencode({token:u,privateChannel:e,connectId:i}),l=this.client(h);return l.keepAlive=o,h}catch(n){this.safeValue(this.options.urls,i).reject(n),delete this.options.urls[i]}}requestId(){const e=this.sum(this.safeInteger(this.options,"requestId",0),1);return this.options.requestId=e,e}async subscribe(e,t,s=void 0,i=void 0,n={}){const r=await this.negotiate(t);if(s!==void 0){const p=this.market(s).id;e+=":"+p}const a=e,o=await this.stream(r,a),c=this.requestId(),u={id:c,type:"subscribe",topic:e,privateChannel:t,response:!0,tunnelId:o},h={id:c};i===void 0?i=h:i=this.extend(h,i);const l=this.extend(u,n);return await this.watch(r,a,l,e,h)}onClose(e,t){this.options.streamBySubscriptionsHash={},super.onClose(e,t)}async stream(e,t){const s=this.safeValue(this.options,"streamBySubscriptionsHash",{});let i=this.safeString(s,t);if(i===void 0){let n=this.safeInteger(this.options,"streamIndex",-1);const r=this.safeValue(this.options,"streamLimit");n=n+1;const a=n%r;this.options.streamIndex=n,i="stream-"+this.numberToString(a),this.options.streamBySubscriptionsHash[t]=i;const c="tunnel:"+i,u={id:c,type:"openTunnel",newTunnelId:i,response:!0},h={id:c,method:this.handleNewStream};await this.watch(e,c,u,c,h)}return i}handleOrderBookSubscription(e,t,s){const i=this.safeString(s,"symbol"),n=this.safeInteger(s,"limit");this.orderbooks[i]=this.orderBook({},n)}handleSubscriptionStatus(e,t){const s=this.safeString(t,"id"),i=this.indexBy(e.subscriptions,"id"),n=this.safeValue(i,s,{}),r=this.safeValue(n,"method");return r!==void 0&&r.call(this,e,t,n),t}handleNewStream(e,t,s){const i=this.safeString(t,"id");e.resolve(t,i)}async watchTicker(e,t={}){return await this.loadMarkets(),e=this.symbol(e),await this.subscribe("/contractMarket/ticker",!1,e,void 0,t)}async watchTrades(e,t=void 0,s=void 0,i={}){await this.loadMarkets();const n=this.safeValue(this.options,"watchTrades");let r=this.safeString(n,"method","/contractMarket/execution");[r,i]=this.handleOptionAndParams(i,"method","name",r),e=this.symbol(e);const a=await this.subscribe(r,!1,e,void 0,i);return this.newUpdates&&(s=a.getLimit(e,s)),this.filterBySinceLimit(a,t,s,"timestamp",!0)}async watchOrderBook(e,t=void 0,s={}){await this.loadMarkets();const i=this.safeValue(this.options,"watchOrderBook");let n=this.safeString(i,"method","/contractMarket/level2");if([n,s]=this.handleOptionAndParams(s,"method","name",n),n==="/contractMarket/level2"&&t!==void 0){if(t!==5&&t!==50)throw new T(this.id+" watchOrderBook limit argument must be none, 5 or 50 if using method /contractMarket/level2");n+="Depth"+this.numberToString(t)}const r={symbol:e,limit:t,method:this.handleOrderBookSubscription};return(await this.subscribe(n,!1,e,r,s)).limit()}async watchOrders(e=void 0,t=void 0,s=void 0,i={}){await this.loadMarkets();const n=this.safeValue(this.options,"watchOrders"),r=this.safeString(n,"method","/contractMarket/tradeOrders");let a=await this.subscribe(r,!0,void 0,void 0,i);return this.newUpdates&&(s=a.getLimit(e,s)),a=this.filterBySymbolSinceLimit(a,e,t,s),a.length===0?await this.watchOrders(e,t,s,i):a}async watchBalance(e={}){return await this.loadMarkets(),await this.subscribe("/contractAccount/wallet",!0,void 0,void 0,e)}handleTrade(e,t){const s=this.safeValue(t,"data",{}),i=this.safeString(s,"symbol");if(i!==void 0){const n=this.parseWsTrade(s),r=n.symbol,a="/contractMarket/execution:"+i;let o=this.safeValue(this.trades,r);if(o===void 0){const c=this.safeInteger(this.options,"tradesLimit",1e3);o=new ct(c),this.trades[r]=o}o.append(n),e.resolve(o,a)}return t}parseWsTrade(e,t=void 0){const s=this.safeString(e,"symbol");t=this.safeMarket(s,t);const i=this.safeIntegerProduct(e,"ts",1e-6);return this.safeTrade({info:e,id:this.safeString(e,"tradeId"),symbol:this.safeString(t,"symbol"),timestamp:i,datetime:this.iso8601(i),order:this.safeString2(e,"takerOrderId","makerOrderId"),type:void 0,side:this.safeString(e,"side"),takerOrMaker:void 0,price:this.safeString(e,"price"),amount:this.safeString2(e,"matchSize","size"),cost:void 0,fee:void 0},t)}parseWsOrderTrade(e,t=void 0){const s=this.safeInteger(e,"tradeTime"),i=this.safeString(e,"symbol");return this.safeTrade({info:e,id:this.safeString(e,"tradeId"),symbol:this.safeSymbol(i,t),timestamp:s,datetime:this.iso8601(s),order:this.safeString(e,"orderId"),type:this.safeStringLower(e,"type"),side:this.safeString(e,"side"),takerOrMaker:this.safeStringLower(e,"matchRole"),price:this.safeString(e,"price"),amount:this.safeString(e,"tradeAmount"),cost:void 0,fee:{rate:void 0,cost:this.safeString(e,"tradeFee"),currency:this.safeString(e,"feeCurrency")}},t)}handleOrder(e,t){const s=this.safeValue(t,"data",{});let i=this.orders;if(i===void 0){const a=this.safeInteger(this.options,"ordersLimit");i=new tt(a),this.orders=i}const n="/contractMarket/tradeOrders",r=this.parseWsOrder(s);return i.append(r),e.resolve(i,n),t}parseOrderStatus(e,t){const s={canceled:"canceled",cancel:"canceled",filled:"closed"};let i=this.safeString(s,t);if(i===void 0){const n={open:"open",match:"open",done:"closed"};i=this.safeString(n,e,e)}return i}parseWsOrder(e,t=void 0){const s=this.safeString(e,"orderId"),i=this.safeString(e,"clientOid"),n=this.safeString(e,"symbol"),r=this.safeIntegerProduct2(e,"orderTime","ts",1e-6),a=this.safeString(e,"status"),o=this.safeString(e,"type");return this.safeOrder({info:e,symbol:this.safeSymbol(n,t),id:s,clientOrderId:i,timestamp:r,datetime:this.iso8601(r),lastTradeTimestamp:void 0,type:this.safeString(e,"orderType"),timeInForce:void 0,postOnly:void 0,side:this.safeString(e,"side"),price:this.safeString2(e,"price","orderPrice"),stopPrice:this.safeString(e,"stopPrice"),triggerPrice:void 0,amount:this.safeString(e,"size"),cost:void 0,average:void 0,filled:this.safeString(e,"filledSize"),remaining:this.safeString(e,"remainSize"),status:this.parseOrderStatus(a,o),fee:void 0,trades:void 0})}handleTicker(e,t){const s=this.safeValue(t,"data",{}),i=this.safeString(t,"topic"),n=this.getSymbolFromTopic(i);if(n!==void 0){const r=this.parseTicker(s);this.tickers[n]=r,e.resolve(r,i)}return t}handleL3OrderBook(e,t){const s=this.safeString(t,"topic");this.safeString(t,"subject")!=="received"&&e.resolve(t,s)}handleLevel2(e,t){if(this.safeString(t,"topic").indexOf("Depth")>=0){this.handeL2Snapshot(e,t);return}this.handleL2OrderBook(e,t)}handleL2OrderBook(e,t){const s=this.safeValue(t,"data",{}),i=this.safeString(t,"topic",""),n=this.getSymbolFromTopic(i);let r=this.safeValue(this.orderbooks,n);if(r===void 0&&(this.orderbooks[n]=this.orderBook({}),r=this.orderbooks[n],r.symbol=n),this.safeInteger(r,"nonce")===void 0){const o=r.cache.length,c=this.handleOption("watchOrderBook","snapshotDelay",5);o===c&&this.spawn(this.loadOrderBook,e,i,n,0,{}),r.cache.push(s);return}try{this.handleDelta(r,s),e.resolve(r,i)}catch(o){delete this.orderbooks[n],e.reject(o,i)}}handeL2Snapshot(e,t){const s=this.safeValue(t,"data",{}),i=this.safeString(t,"topic",""),n=this.getSymbolFromTopic(i),r=this.safeInteger(s,"timestamp"),a=this.parseOrderBook(s,n,r,"bids","asks"),o=this.orderBook(a);this.orderbooks[n]=o,e.resolve(o,i)}getSymbolFromTopic(e){const t=e.split(":"),s=this.safeString(t,1);return this.safeSymbol(s)}getCacheIndex(e,t){const s=this.safeValue(t,0),i=this.safeInteger(e,"nonce");if(this.safeInteger(s,"sequence")>i+1)return-1;for(let r=0;rs)return;if(n!==i&&this.handleOption("watchOrderBook","checksum",!0))throw new $r(this.id+" "+this.orderbookChecksumMessage(""));const r=this.safeList(t,"changes");for(let o=0;on){const a=await this.signIn(),c={type:"authorization",token:this.safeString(a,"access_token")};r=await this.watch(t,i,this.extend(c,e),i),s.subscriptions[i]=r}return r}}class rFe extends j9{describe(){return this.deepExtend(super.describe(),{has:{ws:!0,watchOrderBook:!0,watchTicker:!0,watchTickers:!0,watchTrades:!0,watchTradesForSymbols:!0,watchOrders:!0,watchMyTrades:!0,watchBalance:!0},urls:{api:{ws:"wss://{hostname}/websocket/v1"}},options:{tradesLimit:1e3}})}async watchPublic(e,t,s={}){await this.loadMarkets();const i=this.market(e);e=i.symbol;const n=i.id,r=this.implodeParams(this.urls.api.ws,{hostname:this.hostname});this.options[t]=this.safeValue(this.options,t,{}),this.options[t][e]=!0;const a=Object.keys(this.options[t]),o=this.marketIds(a),c=[{ticket:this.uuid()},{type:t,codes:o}],u=t+":"+n;return await this.watch(r,u,c,u)}async watchPublicMultiple(e,t,s={}){await this.loadMarkets(),e===void 0&&(e=this.symbols),e=this.marketSymbols(e);const i=this.marketIds(e),n=this.implodeParams(this.urls.api.ws,{hostname:this.hostname}),r=[];for(let o=0;oa&&(this.handleOrderBookMessage(e,t,r),e.resolve(r,s+"@book_depth"))}handleOrderBookMessage(e,t,s){const i=this.parseToInt(L.stringDiv(this.safeString(t,"last_max_timestamp"),"1000000")),n={bids:[],asks:[]},r=this.safeList(t,"bids",[]);for(let o=0;o1)throw new q(this.id+" watchPositions require only one symbol.");let n;[n,i]=this.handlePublicAddress("watchPositions",i);const r=this.urls.api.ws,a=this.client(r);this.setPositionsCache(a,e,i);const o=this.handleOption("watchPositions","fetchPositionsSnapshot",!0),c=this.handleOption("watchPositions","awaitPositionsSnapshot",!0);if(o&&c&&this.positions===void 0){const g=await a.future("fetchPositionsSnapshot");return this.filterBySymbolsSinceLimit(g,e,t,s,!0)}const u="position_change",h=this.market(e[0]),l=h.id+"@"+u,f={method:"subscribe",stream:{type:u,product_id:this.parseToNumeric(h.id),subaccount:this.convertAddressToSender(n)}},p=this.extend(f,i),m=await this.watchPublic(l,p);return this.newUpdates&&(s=m.getLimit(e[0],s)),this.filterBySymbolsSinceLimit(this.positions,e,t,s,!0)}setPositionsCache(e,t=void 0,s={}){if(this.handleOption("watchPositions","fetchPositionsSnapshot",!1)){const n="fetchPositionsSnapshot";n in e.futures||(e.future(n),this.spawn(this.loadPositionsSnapshot,e,n,t,s))}else this.positions=new Ks}async loadPositionsSnapshot(e,t,s,i){const n=await this.fetchPositions(s,i);this.positions=new Ks;const r=this.positions;for(let o=0;o-1){o[c[u]].call(this,e,t);return}throw new q(this.id+" this message type is not supported yet. Message: "+this.json(t))}async authenticate(e={}){const t=this.urls.api.ws,s=this.client(t),i="authenticated",n=this.milliseconds();let r=this.safeValue(s.subscriptions,i);const a=this.safeInteger(r,"expires");return(r===void 0||n>a)&&(r=await this.privatePostCreateAuthToken(),r.expires=n+this.safeInteger(r,"timeout_duration")*1e3,s.subscriptions[i]=r),this.safeString(r,"auth_key")}}class dFe extends K9{describe(){return this.deepExtend(super.describe(),{has:{ws:!0,watchBalance:!0,watchMyTrades:!0,watchOHLCV:!0,watchOrderBook:!0,watchOrders:!0,watchTicker:!0,watchTickers:!0,watchTrades:!0,watchTradesForSymbols:!1},urls:{api:{ws:"wss://api.whitebit.com/ws"}},options:{timeframes:{"1m":"60","5m":"300","15m":"900","30m":"1800","1h":"3600","4h":"14400","8h":"28800","1d":"86400","1w":"604800"},watchOrderBook:{priceInterval:0}},streaming:{ping:this.ping},exceptions:{ws:{exact:{1:T,2:T,4:T,6:$}}}})}async watchOHLCV(e,t="1m",s=void 0,i=void 0,n={}){await this.loadMarkets();const r=this.market(e);e=r.symbol;const a=this.safeValue(this.options,"timeframes",{}),o=this.safeInteger(a,t),c=r.id,u="candles:"+e,h=[c,o],f=await this.watchPublic(u,"candles_subscribe",h,n);return this.newUpdates&&(i=f.getLimit(e,i)),this.filterBySinceLimit(f,s,i,0,!0)}handleOHLCV(e,t){const s=this.safeValue(t,"params",[]);for(let i=0;i=0&&l.indexOf(r)>=0&&e.resolve(c,l)}return t}async watchTrades(e,t=void 0,s=void 0,i={}){await this.loadMarkets(),e=this.market(e).symbol;const r="trades:"+e,o=await this.watchMultipleSubscription(r,"trades_subscribe",e,!1,i);return this.newUpdates&&(s=o.getLimit(e,s)),this.filterBySinceLimit(o,t,s,"timestamp",!0)}handleTrades(e,t){const s=this.safeValue(t,"params",[]),i=this.safeString(s,0),n=this.safeMarket(i),r=n.symbol;let a=this.safeValue(this.trades,r);if(a===void 0){const h=this.safeInteger(this.options,"tradesLimit",1e3);a=new ct(h),this.trades[r]=a}const o=this.safeValue(s,1,[]),c=this.parseTrades(o,n);for(let h=0;h=0?h+="spot":h+="margin",e.resolve(this.balance,h)}async watchPublic(e,t,s=[],i={}){const n=this.urls.api.ws,a={id:this.nonce(),method:t,params:s},o=this.extend(a,i);return await this.watch(n,e,o,e)}async watchMultipleSubscription(e,t,s,i=!1,n={}){await this.loadMarkets();const r=this.urls.api.ws,a=this.nonce(),o=this.safeValue(this.clients,r);let c,u=[];if(o===void 0){const h={},f=this.market(s).id;h[f]=!0,u=[f],i&&(u=[u]),c={id:a,method:t,params:u};const p=this.extend(c,n);return await this.watch(r,e,p,t,h)}else{const h=this.safeValue(o.subscriptions,t,{});let l=!0;const p=this.market(s).id;if(this.safeBool(h,p,!1)||(h[p]=!0,l=!1),l)return await this.watch(r,e,c,t,h);{let g=[];g=Object.keys(h),i&&(g=[g]);const y={id:a,method:t,params:g};return t in o.subscriptions&&delete o.subscriptions[t],await this.watch(r,e,y,t,h)}}}async watchPrivate(e,t,s=[],i={}){this.checkRequiredCredentials(),await this.authenticate();const n=this.urls.api.ws,a={id:this.nonce(),method:t,params:s},o=this.extend(a,i);return await this.watch(n,e,o,e)}async authenticate(e={}){this.checkRequiredCredentials();const t=this.urls.api.ws,s="authenticated",i=this.client(t),n=i.future("authenticated");if(this.safeValue(i.subscriptions,s)===void 0){const a=await this.v4PrivatePostProfileWebsocketToken(),o=this.safeString(a,"websocket_token"),c=this.nonce(),u={id:c,method:"authorize",params:[o,"public"]},h={id:c,method:this.handleAuthenticate};try{await this.watch(t,s,u,s,h)}catch(l){delete i.subscriptions[s],n.reject(l)}}return await n}handleAuthenticate(e,t){return e.futures.authenticated.resolve(1),t}handleErrorMessage(e,t){const s=this.safeValue(t,"error");try{if(s!==void 0){const i=this.safeString(t,"code"),n=this.id+" "+this.json(t);this.throwExactlyMatchedException(this.exceptions.ws.exact,i,n)}}catch(i){if(i instanceof $)return e.reject(i,"authenticated"),"authenticated"in e.subscriptions&&delete e.subscriptions.authenticated,!1}return t}handleMessage(e,t){if(!this.handleErrorMessage(e,t))return;if(this.safeString(t,"result")==="pong"){this.handlePong(e,t);return}const i=this.safeInteger(t,"id");if(i!==void 0){this.handleSubscriptionStatus(e,t,i);return}const n={market_update:this.handleTicker,trades_update:this.handleTrades,depth_update:this.handleOrderBook,candles_update:this.handleOHLCV,ordersPending_update:this.handleOrder,ordersExecuted_update:this.handleOrder,balanceSpot_update:this.handleBalance,balanceMargin_update:this.handleBalance,deals_update:this.handleMyTrades},r=this.safeValue(t,"method"),a=this.safeValue(n,r);a!==void 0&&a.call(this,e,t)}handleSubscriptionStatus(e,t,s){const i=e.subscriptions,n=Object.values(i);for(let r=0;ru&&(this.handleOrderBookMessage(e,t,c),e.resolve(c,a))}catch(h){delete this.orderbooks[r],delete e.subscriptions[a],e.reject(h,a)}}else{if(!(r in this.orderbooks)){const l=this.safeInteger(this.options,"watchOrderBookLimit",1e3),f=e.subscriptions[a],p=this.safeInteger(f,"limit",l);this.orderbooks[r]=this.orderBook({},p)}const c=this.orderbooks[r],u=this.safeInteger(t,"ts"),h=this.parseOrderBook(s,r,u,"bids","asks");c.reset(h),e.resolve(c,a)}}handleOrderBookSubscription(e,t,s){const i=this.safeInteger(this.options,"watchOrderBookLimit",1e3),n=this.safeInteger(s,"limit",i),r=this.safeString(s,"symbol");r in this.orderbooks&&delete this.orderbooks[r],this.orderbooks[r]=this.orderBook({},n),this.spawn(this.fetchOrderBookSnapshot,e,t,s)}async fetchOrderBookSnapshot(e,t,s){const i=this.safeString(s,"symbol"),n=this.safeString(t,"topic");try{const r=this.safeInteger(this.options,"watchOrderBookLimit",1e3),a=this.safeInteger(s,"limit",r),o=this.safeValue(s,"params"),c=await this.fetchRestOrderBookSafe(i,a,o);if(this.safeValue(this.orderbooks,i)===void 0)return;const u=this.orderbooks[i];u.reset(c);const h=u.cache;for(let l=0;l=m&&(g-=m);const y=this.safeString(e,"status"),w=this.parseOrderStatus(y),b=void 0,S=this.safeString(e,"clientOrderId");return this.safeOrder({info:e,symbol:n,id:s,clientOrderId:S,timestamp:r,datetime:this.iso8601(r),lastTradeTimestamp:r,type:f,timeInForce:void 0,postOnly:void 0,side:l,price:c,stopPrice:void 0,triggerPrice:void 0,amount:h,cost:void 0,average:u,filled:p,remaining:g,status:w,fee:a,trades:b})}handleOrderUpdate(e,t){const s=this.safeString(t,"topic"),i=this.safeValue(t,"data");if(Array.isArray(i))for(let n=0;n0&&i.append(a)}e.futures[t].resolve(i),e.resolve(i,"positions")}handlePositions(e,t){const s=this.safeValue(t,"data",{}),i=this.safeValue(s,"positions",{}),n=Object.keys(i);this.positions===void 0&&(this.positions=new Ks);const r=this.positions,a=[];for(let o=0;o=0&&(u=u.split("ed25519:")[1]);const h=lg(this.encode(c),this.base58ToBinary(u),ni),l={event:n,params:{orderly_key:this.apiKey,sign:h,timestamp:o}},f=this.extend(l,e);this.watch(t,i,f,i)}return await r}async watchPrivate(e,t,s={}){await this.authenticate(s);const i=this.urls.api.ws.private+"/"+this.accountId,r={id:this.requestId(i)},a=this.extend(r,t);return await this.watch(i,e,a,e,r)}async watchPrivateMultiple(e,t,s={}){await this.authenticate(s);const i=this.urls.api.ws.private+"/"+this.accountId,r={id:this.requestId(i)},a=this.extend(r,t);return await this.watchMultiple(i,e,a,e,r)}async watchOrders(e=void 0,t=void 0,s=void 0,i={}){await this.loadMarkets();const r=this.safeBool2(i,"stop","trigger",!1)?"algoexecutionreport":"executionreport";i=this.omit(i,["stop","trigger"]);let a=r;e!==void 0&&(e=this.market(e).symbol,a+=":"+e);const o={event:"subscribe",topic:r},c=this.extend(o,i),u=await this.watchPrivate(a,c);return this.newUpdates&&(s=u.getLimit(e,s)),this.filterBySymbolSinceLimit(u,e,t,s,!0)}async watchMyTrades(e=void 0,t=void 0,s=void 0,i={}){await this.loadMarkets();const r=this.safeBool2(i,"stop","trigger",!1)?"algoexecutionreport":"executionreport";i=this.omit(i,"stop");let a="myTrades";e!==void 0&&(e=this.market(e).symbol,a+=":"+e);const o={event:"subscribe",topic:r},c=this.extend(o,i),u=await this.watchPrivate(a,c);return this.newUpdates&&(s=u.getLimit(e,s)),this.filterBySymbolSinceLimit(u,e,t,s,!0)}parseWsOrder(e,t=void 0){const s=this.safeString(e,"orderId"),i=this.safeString(e,"symbol");t=this.market(i);const n=t.symbol,r=this.safeInteger(e,"timestamp"),a={cost:this.safeString(e,"totalFee"),currency:this.safeString(e,"feeAsset")},o=this.safeString(e,"price");let c=this.safeNumber(e,"price");const u=this.safeNumber(e,"avgPrice");L.stringEq(o,"0")&&u!==void 0&&(c=u);const h=this.safeString(e,"quantity"),l=this.safeStringLower(e,"side"),f=this.safeStringLower(e,"type"),p=this.safeNumber(e,"totalExecutedQuantity"),m=this.safeString(e,"totalExecutedQuantity");let g=h;L.stringGe(h,m)&&(g=L.stringSub(g,m));const y=this.safeString(e,"status"),w=this.parseOrderStatus(y),b=void 0,S=this.safeString(e,"clientOrderId"),v=this.safeNumber(e,"triggerPrice");return this.safeOrder({info:e,symbol:n,id:s,clientOrderId:S,timestamp:r,datetime:this.iso8601(r),lastTradeTimestamp:r,type:f,timeInForce:void 0,postOnly:void 0,side:l,price:c,stopPrice:v,triggerPrice:v,amount:h,cost:void 0,average:void 0,filled:p,remaining:g,status:w,fee:a,trades:b})}handleOrderUpdate(e,t){const s=this.safeString(t,"topic"),i=this.safeValue(t,"data");if(Array.isArray(i))for(let n=0;n=s)return r}return t.length}handleDelta(e,t){e.nonce=this.safeInteger2(t,"i","u");const s=this.safeList(t,"a",[]),i=this.safeList(t,"b",[]),n=e.bids,r=e.asks;for(let a=0;a0&&e.resolve(m,h)}return e.resolve(this.tickers,o),t}handleOHLCV(e,t){const s=this.safeDict(t,"data",{}),i=this.safeString(s,"s");if(i!==void 0){const n=this.safeString(s,"i"),r="q"in s?"spot":"contract",a=this.safeMarket(i,void 0,void 0,r),o=a.symbol,c=this.parseOHLCV(s,a);this.ohlcvs[o]=this.safeDict(this.ohlcvs,o,{});let u=this.safeValue(this.ohlcvs[o],n);if(u===void 0){const f=this.safeInteger(this.options,"OHLCVLimit",1e3);u=new Jt(f),this.ohlcvs[o][n]=u}u.append(c);const l=this.safeString(t,"event")+"::"+r;e.resolve(u,l)}return t}handleTrade(e,t){const s=this.safeDict(t,"data"),i=this.safeStringLower(s,"s");if(i!==void 0){const n=this.parseTrade(s),a=this.safeString(s,"i")!==void 0?"spot":"contract",c=this.safeMarket(i,void 0,void 0,a).symbol,u=this.safeString(t,"event");let h=this.safeValue(this.trades,c);if(h===void 0){const f=this.safeInteger(this.options,"tradesLimit",1e3);h=new ct(f),this.trades[c]=h}h.append(n);const l=u+"::"+a;e.resolve(h,l)}return t}handleOrderBook(e,t){const s=this.safeDict(t,"data"),i=this.safeString(s,"s");if(i!==void 0){let n=this.safeString(t,"event");const r=n.split(",");n=this.safeString(r,0);const a="fu"in s?"contract":"spot",c=this.safeMarket(i,void 0,void 0,a).symbol,u=this.safeList(s,"a"),h=this.safeList(s,"b"),l=n+"::"+a;if(!(c in this.orderbooks)){const g=this.safeDict(e.subscriptions,l,{}),y=this.safeInteger(g,"limit");this.orderbooks[c]=this.orderBook({},y)}const f=this.orderbooks[c];if(this.safeInteger(f,"nonce")===void 0){const g=f.cache.length,y=this.handleOption("watchOrderBook","snapshotDelay",25);g===y&&this.spawn(this.loadOrderBook,e,l,c),f.cache.push(s);return}if(u!==void 0){const g=f.asks;for(let y=0;ysetTimeout(e,d))}function fFe(d,e,t,s){B.useEffect(()=>{if(!d.current)return;let i=!0;return(async()=>{for(console.log(`WS: Subscribed to ${t} candle of ${e}`);i;)try{const a=(await d.current.watchOHLCV(e,t)).at(-1);i&&s(a)}catch(r){if(r instanceof qs)console.log("WS: Socket connection closed. Delaying for 1s before reconnecting.",r),await lFe(1e3);else throw r}})(),()=>{i=!1,console.log("WS: Unsubscribed")}},[d,e,t])}const pFe={[Xa.OKX]:"okx",[Xa.BYBIT]:"bybit",[Xa.BITGET]:"bitget",[Xa.BINANCE]:"binance",[Xa.KRAKEN]:"kraken",[Xa.COINBASE]:"coinbase",[Xa.GATEIO]:"gateio"};function mFe(d){const e=pFe[d];return new Aw[e]}function gFe(d,e){const[t,s,i,n,r,a]=e;console.log(d,"open",s,"high",i,"low",n,"close",r,"volume",a,"timestamp",t,new Date(t).toISOString())}function yFe(d){const e=B.useRef(null);return B.useEffect(()=>{e.current=mFe(d)},[d]),e}function wFe(d){return YL(Date.now(),d)}function yF(d){const e=wFe(d);return n$(e,d)}function n$(d,e){const t=Eue(e);return d-t*vj}function bFe(d,e,t){const s=yFe(d),i=async(f,p,m)=>await s.current.fetchOHLCV(f,m,p,vj),n=B.useRef(!1),[r,a]=B.useState([]),[o,c]=B.useState(yF(t)),u=()=>{a([]),c(yF(t))};[cm(d),cm(e),cm(t)].includes(!0)&&u(),B.useEffect(()=>{let f=!0;return n.current=!0,i(e,o,t).then(p=>{f&&(a(m=>[...p,...m]),n.current=!1)}),()=>{f=!1}},[d,e,t,o]);const l=()=>{n.current||c(n$(o,t))};return fFe(s,e,t,f=>{const[p]=f;a(m=>m.some(y=>y[0]===p)?[...m.slice(0,-1),f]:(gFe(`WS: New ${t} candle`,f),[...m,f]))}),{candlesticks:r,fetchPrev:l}}const kFe=({children:d})=>P.jsx(dg,{sx:{position:"absolute",zIndex:2,top:4,left:4,borderRadius:4,p:1,display:"flex",justifyContent:"space-between",alignItems:"center",backgroundColor:"transparent"},children:d}),ux=14;function SFe(d){return(typeof d=="number"?d.toFixed(2):d).length*(ux*.85)}function vFe(d,e){const t=e-d,s=t/d*100,i=Math.abs(s);return t<0?`-${i.toFixed(2)}%`:t>0?`+${s.toFixed(2)}%`:"0%"}const r$=({color:d,children:e})=>P.jsx(_t,{sx:t=>({color:d==="success"?t.vars.palette.success.plainColor:t.vars.palette.danger.plainColor,display:"inline"}),children:e}),RS=({prefix:d,price:e,color:t})=>P.jsxs(_t,{sx:{lineHeight:1,fontSize:ux,width:SFe(e)},children:[d,":",P.jsx(r$,{color:t,children:e.toFixed(2)})]}),TFe=({open:d,close:e,color:t})=>{const s=e-d,i=Math.abs(s).toFixed(2),n=s>0?"+":"-",r=vFe(d,e);return P.jsx(_t,{sx:{lineHeight:1,fontSize:ux},children:P.jsxs(r$,{color:t,children:[n,i," (",r,")"]})})},OFe=({open:d,high:e,low:t,close:s})=>{const i=sP.jsx(_t,{sx:{lineHeight:1,fontSize:ux,mr:2},children:d});function PFe(d){const[e,t,s,i,n]=d;return{time:Sj(e),open:t,high:s,low:i,close:n}}const IFe=({symbolId:d,barSize:e,priceLines:t,dimmed:s,showPriceLines:i,markers:n,showMarkers:r,sx:a})=>{const[o]=kt.symbol.getOne.useSuspenseQuery({symbolId:d}),{candlesticks:c,fetchPrev:u}=bFe(o.exchangeCode,o.currencyPair,e),h=FMe({onScrollLeft:()=>{u()}});B.useEffect(()=>{var b,S,v;(b=h.series.current)==null||b.setData(c.map(PFe)),c.length===0&&((S=h.api.current)==null||S.timeScale().resetTimeScale(),(v=h.api.current)==null||v.priceScale("right").applyOptions({autoScale:!0}))},[c]),B.useEffect(()=>{if(!h.series.current||!t||!i)return;const w=h.series.current,b=t.map(S=>w.createPriceLine(S));return()=>{b.forEach(S=>{var v;(v=h.series.current)==null||v.removePriceLine(S)})}},[t,i]),B.useEffect(()=>!h.series.current||!n||!r?void 0:(h.series.current.setMarkers(n),()=>{var b;(b=h.series.current)==null||b.setMarkers([])}),[n,r]);const l=B.useRef(null),{width:f,height:p}=rIe({ref:l});B.useEffect(()=>{var w;(w=h.api.current)==null||w.applyOptions({width:f,height:p})},[f,p]);const[m,g]=B.useState(),y=B.useCallback(w=>{const b=w.seriesData.get(h.series.current);g(b||null)},[]);return B.useEffect(()=>{var w;return(w=h.api.current)==null||w.subscribeCrosshairMove(y),()=>{var b;(b=h.api.current)==null||b.unsubscribeCrosshairMove(y)}},[]),P.jsxs(_t,{ref:l,sx:{height:Xo,opacity:s?.5:1,transition:s?"opacity 0.1s 0.1s linear":"opacity 0s 0s linear",position:"relative",...a},children:[P.jsxs(kFe,{children:[P.jsx(xFe,{children:d}),m?P.jsx(OFe,{...m}):null]}),P.jsx("div",{ref:h.ref,style:{width:"100%",height:"100%"}})]})},CFe=({children:d})=>P.jsx(_t,{sx:{display:"flex",mb:1,gridGap:8},children:d}),MFe=({children:d})=>P.jsx(_t,{style:{width:"100%"},children:d}),hx=d=>{const{children:e,...t}=d;return P.jsxs(MFe,{children:[P.jsx(CFe,{children:e}),P.jsx(IFe,{...t,sx:{borderRadius:6,overflow:"hidden",border:"1px solid var(--joy-palette-neutral-outlinedBorder)"}})]})},_Fe=Ys(P.jsx("path",{d:"M3 3h18v2H3zm0 16h18v2H3zm0-8h18v2H3z"}),"DensityMedium"),AFe=Ys(P.jsx("path",{d:"M12 7c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.24 5-5-2.24-5-5-5m0-5C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"}),"RadioButtonChecked"),wF=d=>e=>({backgroundColor:e?d:void 0,"&:hover":{backgroundColor:e?d:"unset"}}),lx=({gridVisible:d,onGridVisibleChange:e,hideGridButton:t,tradesVisible:s,onTradesVisibleChange:i,hideTradesButton:n})=>P.jsxs(sOe,{size:"sm",variant:"outlined",children:[t?null:P.jsx(Es,{color:d?"primary":"neutral",onClick:()=>e==null?void 0:e(!d),startDecorator:P.jsx(_Fe,{}),sx:r=>({...wF(r.vars.palette.primary.outlinedHoverBg)(d)}),children:"Grid"}),n?null:P.jsx(Es,{color:s?"success":"neutral",onClick:()=>i==null?void 0:i(!s),startDecorator:P.jsx(AFe,{}),sx:r=>({...wF(r.vars.palette.success.outlinedHoverBg)(s)}),children:"Trades"})]}),LFe=kf(P.jsx("path",{d:"M7 10l5 5 5-5z"}),"ArrowDropDown"),BFe=kf(P.jsx("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 12z"}),"Cancel");function NFe(d){return Rt("MuiChipDelete",d)}Dt("MuiChipDelete",["root","disabled","focusVisible","colorPrimary","colorNeutral","colorDanger","colorSuccess","colorWarning","colorContext","variantPlain","variantSolid","variantSoft","variantOutlined"]);var bF;const EFe=["children","variant","color","disabled","onKeyDown","onDelete","onClick","component","slots","slotProps"],RFe=["onDelete"],DFe=d=>{const{focusVisible:e,variant:t,color:s,disabled:i}=d,n={root:["root",i&&"disabled",e&&"focusVisible",t&&`variant${De(t)}`,s&&`color${De(s)}`]};return Nt(n,NFe,{})},qFe=_e(ab,{name:"JoyChipDelete",slot:"Root",overridesResolver:(d,e)=>e.root})(({theme:d})=>({"--IconButton-size":"var(--Chip-deleteSize, 2rem)","--Icon-fontSize":"calc(var(--IconButton-size, 2rem) / 1.3)",minWidth:"var(--IconButton-size, 2rem)",minHeight:"var(--IconButton-size, 2rem)",fontSize:d.vars.fontSize.sm,paddingInline:"2px",pointerEvents:"visible",borderRadius:"var(--Chip-deleteRadius, 50%)",zIndex:1,padding:0})),VFe=B.forwardRef(function(e,t){const s=qt({props:e,name:"JoyChipDelete"}),{children:i,variant:n="plain",color:r="neutral",disabled:a,onKeyDown:o,onDelete:c,onClick:u,component:h,slots:l={},slotProps:f={}}=s,p=at(s,EFe),m=B.useContext(tW),{variant:g=n,color:y=r}=PO(e.variant,e.color,!0),w=e.color||y,b=a??m.disabled,S=B.useRef(null),v=Cs(S,t),{focusVisible:C,getRootProps:M}=Jo(W({},s,{disabled:b,rootRef:v})),_=W({},s,{disabled:b,variant:g,color:w,focusVisible:C}),N=DFe(_),A=W({},p,{component:h,slots:l,slotProps:f}),R=z=>{!b&&c&&c(z),u&&u(z)},D=z=>{["Backspace","Enter","Delete"].includes(z.key)&&(z.preventDefault(),!b&&c&&c(z)),o&&o(z)},[U,K]=Fe("root",{ref:t,elementType:qFe,getSlotProps:M,externalForwardedProps:A,ownerState:_,additionalProps:{as:h,onKeyDown:D,onClick:R},className:N.root}),j=at(K,RFe);return P.jsx(U,W({},j,{children:i??(bF||(bF=P.jsx(BFe,{})))}))});function FFe(d){return Rt("MuiListSubheader",d)}Dt("MuiListSubheader",["root","sticky","colorPrimary","colorNeutral","colorDanger","colorSuccess","colorWarning","colorContext","variantPlain","variantSoft","variantOutlined","variantSolid"]);const HFe=["component","className","children","id","sticky","variant","color","slots","slotProps"],GFe=d=>{const{variant:e,color:t,sticky:s}=d,i={root:["root",s&&"sticky",t&&`color${De(t)}`,e&&`variant${De(e)}`]};return Nt(i,FFe,{})},UFe=_e("div",{name:"JoyListSubheader",slot:"Root",overridesResolver:(d,e)=>e.root})(({theme:d,ownerState:e})=>{var t,s;return W({boxSizing:"border-box",display:"flex",alignItems:"center",marginInline:"var(--ListItem-marginInline)",paddingBlock:"var(--ListItem-paddingY)",paddingInlineStart:"var(--ListItem-paddingLeft)",paddingInlineEnd:"var(--ListItem-paddingRight)",minBlockSize:"var(--ListItem-minHeight)"},d.typography["body-xs"],{fontSize:"max(0.75em, 0.625rem)",textTransform:"uppercase",letterSpacing:"0.1em"},e.sticky&&{position:"sticky",top:"var(--ListItem-stickyTop, 0px)",zIndex:1,background:"var(--ListItem-stickyBackground)"},{color:e.color?`var(--_Link-color, rgba(${(t=d.vars.palette[e.color])==null?void 0:t.mainChannel} / 1))`:d.vars.palette.text.tertiary},e.instanceColor&&{[`&:not([${qm}])`]:{"--_Link-color":d.vars.palette.text.secondary}},(s=d.variants[e.variant])==null?void 0:s[e.color])}),WFe=B.forwardRef(function(e,t){const s=qt({props:e,name:"JoyListSubheader"}),{component:i,className:n,children:r,id:a,sticky:o=!1,variant:c,color:u,slots:h={},slotProps:l={}}=s,f=at(s,HFe),p=ln(a),m=B.useContext($W);B.useEffect(()=>{m&&m(p||"")},[m,p]);const g=W({instanceColor:e.color},s,{id:p,sticky:o,variant:c,color:c?u??"neutral":u}),y=GFe(g),w=W({},f,{component:i,slots:h,slotProps:l}),[b,S]=Fe("root",{ref:t,className:Gt(y.root,n),elementType:UFe,externalForwardedProps:w,ownerState:g,additionalProps:{as:i,id:p}});return P.jsx(b,W({},S,{children:r}))});function jFe(d){return Rt("MuiAutocomplete",d)}const zu=Dt("MuiAutocomplete",["root","wrapper","input","startDecorator","endDecorator","formControl","focused","disabled","error","multiple","limitTag","hasPopupIcon","hasClearIcon","clearIndicator","popupIndicator","popupIndicatorOpen","listbox","option","loading","noOptions","colorPrimary","colorNeutral","colorDanger","colorSuccess","colorWarning","colorContext","sizeSm","sizeMd","sizeLg","variantPlain","variantOutlined","variantSoft","variantSolid"]);function zFe(d){return Rt("MuiAutocompleteListbox",d)}Dt("MuiAutocompleteListbox",["root","sizeSm","sizeMd","sizeLg","colorPrimary","colorNeutral","colorDanger","colorSuccess","colorWarning","colorContext","variantPlain","variantOutlined","variantSoft","variantSolid"]);const $Fe=["anchorEl","direction","disablePortal","keepMounted","modifiers","open","placement","popperOptions","popperRef","TransitionProps"],KFe=["children","className","component","color","variant","size","slots","slotProps"],XFe=d=>{const{variant:e,color:t,size:s}=d,i={root:["root",e&&`variant${De(e)}`,t&&`color${De(t)}`,s&&`size${De(s)}`]};return Nt(i,zFe,{})},QFe=d=>at(d,$Fe),a$=_e(ag)(({theme:d,ownerState:e})=>{var t;const s=(t=d.variants[e.variant])==null?void 0:t[e.color];return W({"--focus-outline-offset":`calc(${d.vars.focus.thickness} * -1)`,"--ListItem-stickyBackground":(s==null?void 0:s.backgroundColor)||(s==null?void 0:s.background)||d.vars.palette.background.popup,"--ListItem-stickyTop":"calc(var(--List-padding, var(--ListDivider-gap)) * -1)"},CO,{boxShadow:d.shadow.md,borderRadius:`var(--List-radius, ${d.vars.radius.sm})`},!(s!=null&&s.backgroundColor)&&{backgroundColor:d.vars.palette.background.popup},{zIndex:d.vars.zIndex.popup,overflow:"auto",maxHeight:"40vh",position:"relative","&:empty":{visibility:"hidden"},[`& .${Bv.nested}, & .${Bv.nested} .${pSe.root}`]:{position:"initial"}})}),YFe=_e(a$,{name:"JoyAutocompleteListbox",slot:"Root",overridesResolver:(d,e)=>e.root})({}),ZFe=B.forwardRef(function(e,t){const s=qt({props:e,name:"JoyAutocompleteListbox"}),{children:i,className:n,component:r,color:a="neutral",variant:o="outlined",size:c="md",slots:u={},slotProps:h={}}=s,l=at(s,KFe),f=W({},s,{size:c,color:a,variant:o,nesting:!1,row:!1,wrap:!1}),p=QFe(l),m=XFe(f),g=W({},p,{component:r,slots:u,slotProps:h}),[y,w]=Fe("root",{ref:t,className:Gt(m.root,n),elementType:YFe,externalForwardedProps:g,ownerState:f,additionalProps:{role:"listbox"}});return P.jsx(hb,{variant:o,color:a,children:P.jsx(y,W({},w,{children:i}))})});function JFe(d){return Rt("MuiAutocompleteOption",d)}Dt("MuiAutocompleteOption",["root","focused","focusVisible","colorPrimary","colorNeutral","colorDanger","colorSuccess","colorWarning","colorContext","variantPlain","variantSoft","variantOutlined","variantSolid"]);const e4e=["children","component","color","variant","className","slots","slotProps"],t4e=d=>{const{color:e,variant:t}=d,s={root:["root",e&&`color${De(e)}`,t&&`variant${De(t)}`]};return Nt(s,JFe,{})},o$=_e(og)(({theme:d,ownerState:e})=>{var t,s;return{'&[aria-disabled="true"]':(t=d.variants[`${e.variant}Disabled`])==null?void 0:t[e.color],'&[aria-selected="true"]':W({},(s=d.variants[`${e.variant}Active`])==null?void 0:s[e.color],{fontWeight:d.vars.fontWeight.md})}}),s4e=_e(o$,{name:"JoyAutocompleteOption",slot:"Root",overridesResolver:(d,e)=>e.root})({}),d$=B.forwardRef(function(e,t){const s=qt({props:e,name:"JoyAutocompleteOption"}),{children:i,component:n="li",color:r="neutral",variant:a="plain",className:o,slots:c={},slotProps:u={}}=s,h=at(s,e4e),{variant:l=a,color:f=r}=PO(e.variant,e.color),p=W({},s,{component:n,color:f,variant:l}),m=t4e(p),g=W({},h,{component:n,slots:c,slotProps:u}),[y,w]=Fe("root",{ref:t,className:Gt(m.root,o),elementType:s4e,externalForwardedProps:g,ownerState:p,additionalProps:{as:n,role:"option"}});return P.jsx(y,W({},w,{children:i}))});var kF,SF;const i4e=["aria-describedby","aria-label","aria-labelledby","autoComplete","autoHighlight","autoSelect","autoFocus","blurOnSelect","clearIcon","clearOnBlur","clearOnEscape","clearText","closeText","defaultValue","disableCloseOnSelect","disabledItemsFocusable","disableListWrap","disableClearable","disabled","endDecorator","error","filterOptions","filterSelectedOptions","forcePopupIcon","freeSolo","getLimitTagsText","getOptionDisabled","getOptionKey","getOptionLabel","handleHomeEndKeys","includeInputInList","isOptionEqualToValue","groupBy","id","inputValue","limitTags","loading","loadingText","multiple","name","noOptionsText","onChange","onClose","onHighlightChange","onInputChange","onOpen","open","openOnFocus","openText","options","placeholder","popupIcon","readOnly","renderGroup","renderOption","renderTags","required","type","startDecorator","size","color","variant","value","component","selectOnFocus","slots","slotProps"],n4e=["onDelete"],r4e=["key"],a4e=["onBlur","onFocus","onMouseDown"],o4e=["key"],d4e=d=>d.current!==null&&d.current.contains(document.activeElement),c4e=d=>{var e;return(e=d.label)!=null?e:d},u4e=d=>`+${d}`,h4e=d=>P.jsxs(Er,{nested:!0,children:[P.jsx(WFe,{sticky:!0,children:d.group}),P.jsx(Dh,{children:d.children})]},d.key),l4e=d=>{const{disabled:e,focused:t,hasClearIcon:s,hasPopupIcon:i,popupOpen:n,variant:r,color:a,size:o,multiple:c}=d,u={root:["root",t&&"focused",s&&"hasClearIcon",i&&"hasPopupIcon",r&&`variant${De(r)}`,a&&`color${De(a)}`,o&&`size${De(o)}`],wrapper:["wrapper",c&&"multiple"],input:["input"],startDecorator:["startDecorator"],endDecorator:["endDecorator"],clearIndicator:["clearIndicator"],popupIndicator:["popupIndicator",n&&"popupIndicatorOpen",e&&"disabled"],listbox:["listbox"],option:["option"],loading:["loading"],noOptions:["noOptions"],limitTag:["limitTag"]};return Nt(u,jFe,{})},f4e=_e(nW,{name:"JoyAutocomplete",slot:"Root",overridesResolver:(d,e)=>e.root})(({ownerState:d})=>W({},d.size==="sm"&&{"--Autocomplete-wrapperGap":"3px"},d.size==="md"&&{"--Autocomplete-wrapperGap":"3px"},d.size==="lg"&&{"--Autocomplete-wrapperGap":"4px"},{"@media (pointer: fine)":{[`&:hover .${zu.clearIndicator}`]:{visibility:"visible"}}},d.multiple&&!d.startDecorator&&{paddingInlineStart:0})),p4e=_e("div",{name:"JoyAutocomplete",slot:"Wrapper",overridesResolver:(d,e)=>e.wrapper})(({ownerState:d})=>({flex:1,minWidth:0,display:"flex",alignItems:"center",flexWrap:"wrap",gap:"var(--Autocomplete-wrapperGap)",[`&.${zu.multiple}`]:W({paddingBlock:"var(--Autocomplete-wrapperGap)"},!d.startDecorator&&{paddingInlineStart:"var(--Autocomplete-wrapperGap)"},!d.endDecorator&&{paddingInlineEnd:"var(--Autocomplete-wrapperGap)"})})),m4e=_e(rW,{name:"JoyAutocomplete",slot:"Input",overridesResolver:(d,e)=>e.input})(({ownerState:d})=>W({minWidth:30,minHeight:"var(--Chip-minHeight)"},d.multiple&&{marginInlineStart:"calc(var(--Autocomplete-wrapperGap) * 2.5)"})),g4e=_e(aW,{name:"JoyAutocomplete",slot:"StartDecorator",overridesResolver:(d,e)=>e.startDecorator})({}),y4e=_e(oW,{name:"JoyAutocomplete",slot:"EndDecorator",overridesResolver:(d,e)=>e.endDecorator})(({ownerState:d})=>W({},(d.hasClearIcon||d.hasPopupIcon)&&{"--Button-margin":"0px","--IconButton-margin":"0px","--Icon-margin":"0px"})),w4e=_e(ab,{name:"JoyAutocomplete",slot:"ClearIndicator",overridesResolver:(d,e)=>e.clearIndicator})(({ownerState:d})=>W({alignSelf:"center"},!d.hasPopupIcon&&{marginInlineEnd:"calc(var(--Input-decoratorChildOffset) * -1)"},{marginInlineStart:"calc(var(--_Input-paddingBlock) / 2)",visibility:d.focused?"visible":"hidden"})),b4e=_e(ab,{name:"JoyAutocomplete",slot:"PopupIndicator",overridesResolver:(d,e)=>e.popupIndicator})({alignSelf:"center",marginInlineStart:"calc(var(--_Input-paddingBlock) / 2)",marginInlineEnd:"calc(var(--Input-decoratorChildOffset) * -1)",[`&.${zu.popupIndicatorOpen}`]:{transform:"rotate(180deg)","--Icon-color":"currentColor"}}),k4e=_e(a$,{name:"JoyAutocomplete",slot:"Listbox",overridesResolver:(d,e)=>e.listbox})(({theme:d})=>({zIndex:`var(--unstable_popup-zIndex, ${d.vars.zIndex.popup})`})),S4e=_e(o$,{name:"JoyAutocomplete",slot:"Option",overridesResolver:(d,e)=>e.option})({}),v4e=_e(Er,{name:"JoyAutocomplete",slot:"Loading",overridesResolver:(d,e)=>e.loading})(({theme:d})=>({color:(d.vars||d).palette.text.secondary})),T4e=_e(Er,{name:"JoyAutocomplete",slot:"NoOptions",overridesResolver:(d,e)=>e.noOptions})(({theme:d})=>({color:(d.vars||d).palette.text.secondary})),O4e=_e("div",{name:"JoyAutocomplete",slot:"NoOptions",overridesResolver:(d,e)=>e.noOptions})({marginInlineStart:"calc(var(--Input-paddingInline) / 2)",marginBlockStart:"var(--_Input-paddingBlock)"}),c$=B.forwardRef(function(e,t){var s,i,n,r,a,o,c;const u=qt({props:e,name:"JoyAutocomplete"}),{"aria-describedby":h,"aria-label":l,"aria-labelledby":f,autoFocus:p,clearIcon:m=kF||(kF=P.jsx(kU,{fontSize:"md"})),clearText:g="Clear",closeText:y="Close",disableClearable:w=!1,disabled:b,endDecorator:S,error:v=!1,forcePopupIcon:C="auto",freeSolo:M=!1,getLimitTagsText:_=u4e,getOptionLabel:N=c4e,groupBy:A,id:R,limitTags:D=-1,loading:U=!1,loadingText:K="Loading…",multiple:j=!1,name:z,noOptionsText:J="No options",openText:Y="Open",placeholder:X,popupIcon:Z=SF||(SF=P.jsx(LFe,{})),readOnly:te=!1,renderGroup:Q=h4e,renderOption:ie,renderTags:ne,required:oe,type:me,startDecorator:fe,size:he="md",color:Se="neutral",variant:ye="outlined",component:ge,slots:Te={},slotProps:Ge={}}=u,Ye=at(u,i4e),Re=B.useContext($o),Be=(s=(i=e.error)!=null?i:Re==null?void 0:Re.error)!=null?s:v,Me=(n=(r=e.size)!=null?r:Re==null?void 0:Re.size)!=null?n:he,Le=(a=e.color)!=null?a:Be?"danger":(o=Re==null?void 0:Re.color)!=null?o:Se,rt=(c=b??(Re==null?void 0:Re.disabled))!=null?c:!1,{getRootProps:ze,getInputProps:Ue,getPopupIndicatorProps:Je,getClearProps:st,getTagProps:ut,getListboxProps:yt,getOptionProps:Bt,value:lt,dirty:ht,popupOpen:ft,focused:se,focusedTag:F,anchorEl:V,setAnchorEl:re,inputValue:le,groupedOptions:ke}=rye(W({},u,{id:R??(Re==null?void 0:Re.htmlFor),componentName:"Autocomplete",unstable_classNamePrefix:"Mui",unstable_isActiveElementInListbox:d4e})),{onMouseDown:Ne}=Ue(),{onClick:wt}=ze(),Yt=!w&&!rt&&ht&&!te,zt=(!M||C===!0)&&C!==!1,Et=W({instanceColor:e.color},u,{value:lt,disabled:rt,focused:se,getOptionLabel:N,hasOptions:!!ke.length,hasClearIcon:Yt,hasPopupIcon:zt,inputFocused:F===-1,popupOpen:ft,size:Me,color:Le,variant:ye}),bt=l4e(Et),Ms=W({},Ye,{component:ge,slots:Te,slotProps:Ge});let ls;if(j&<.length>0){const Ut=Bn=>{const vi=ut(Bn),{onDelete:$n}=vi,Qr=at(vi,n4e);return W({disabled:rt,size:Me,onClick:$n},Qr)};ne?ls=ne(lt,Ut,Et):ls=lt.map((Bn,vi)=>{const $n=Ut({index:vi}),{key:Qr}=$n,ec=at($n,r4e);return P.jsx(nn,{size:Me,variant:"soft",color:"neutral",endDecorator:P.jsx(VFe,W({},ec),Qr),sx:{minWidth:0},children:N(Bn)},vi)})}const Or=Cs(t,re),An={[zu.disabled]:rt,[zu.error]:Be,[zu.focused]:se,[zu.formControl]:!!Re},[Rs,Qt]=Fe("root",{ref:Or,className:[bt.root,An],elementType:f4e,externalForwardedProps:Ms,ownerState:Et,getSlotProps:ze,additionalProps:{onClick:Ut=>{wt&&wt(Ut),Ut.currentTarget===Ut.target&&Ne&&Ne(Ut)}}}),[oi,Aa]=Fe("wrapper",{className:bt.wrapper,elementType:p4e,externalForwardedProps:Ms,ownerState:Et}),mn={[zu.disabled]:rt},[Xr,sd]=Fe("input",{className:[bt.input,mn],elementType:m4e,getSlotProps:Ut=>{const Bn=Ue(),{onBlur:vi,onFocus:$n,onMouseDown:Qr}=Bn,ec=at(Bn,a4e);return W({},ec,{onBlur:xr=>{var Pr;vi==null||vi(xr),(Pr=Ut.onBlur)==null||Pr.call(Ut,xr)},onFocus:xr=>{var Pr;$n==null||$n(xr),(Pr=Ut.onFocus)==null||Pr.call(Ut,xr)},onMouseDown:xr=>{var Pr;Qr==null||Qr(xr),(Pr=Ut.onMouseDown)==null||Pr.call(Ut,xr)}})},externalForwardedProps:Ms,ownerState:Et,additionalProps:{autoFocus:p,placeholder:X,name:z,readOnly:te,disabled:rt,required:oe??(Re==null?void 0:Re.required),type:me,"aria-invalid":Be||void 0,"aria-label":l,"aria-labelledby":f,"aria-describedby":h??(Re==null?void 0:Re["aria-describedby"])}}),[La,id]=Fe("startDecorator",{className:bt.startDecorator,elementType:g4e,externalForwardedProps:Ms,ownerState:Et}),[yo,nd]=Fe("endDecorator",{className:bt.endDecorator,elementType:y4e,externalForwardedProps:Ms,ownerState:Et}),[Jd,$t]=Fe("clearIndicator",{className:bt.clearIndicator,elementType:w4e,getSlotProps:st,externalForwardedProps:Ms,ownerState:Et,getSlotOwnerState:Ut=>({size:Ut.size||Me,variant:Ut.variant||fl(ye,Le).variant||"plain",color:Ut.color||fl(ye,Le).color||"neutral",disableColorInversion:!!e.color}),additionalProps:{"aria-label":g,title:g}}),[ms,ds]=Fe("popupIndicator",{className:bt.popupIndicator,elementType:b4e,getSlotProps:Je,externalForwardedProps:Ms,ownerState:Et,getSlotOwnerState:Ut=>({size:Ut.size||Me,variant:Ut.variant||fl(ye,Le).variant||"plain",color:Ut.color||fl(ye,Le).color||"neutral",disableColorInversion:!!e.color}),additionalProps:{disabled:rt,"aria-label":ft?y:Y,title:ft?y:Y,type:"button"}}),[Ce,xe]=Fe("listbox",{className:bt.listbox,elementType:k4e,getSlotProps:yt,externalForwardedProps:Ms,ownerState:Et,getSlotOwnerState:Ut=>({size:Ut.size||Me,variant:Ut.variant||ye,color:Ut.color||Le,disableColorInversion:!Ut.disablePortal}),additionalProps:{anchorEl:V,open:ft,style:V?{width:V.clientWidth}:{}}}),[dt,Ct]=Fe("loading",{className:bt.loading,elementType:v4e,externalForwardedProps:Ms,ownerState:Et}),[ns,Ts]=Fe("noOptions",{className:bt.noOptions,elementType:T4e,externalForwardedProps:Ms,ownerState:Et,additionalProps:{role:"presentation",onMouseDown:Ut=>{Ut.preventDefault()}}}),[Fs,Ln]=Fe("limitTag",{className:bt.limitTag,elementType:O4e,externalForwardedProps:Ms,ownerState:Et});if(D>-1&&Array.isArray(ls)){const Ut=ls.length-D;!se&&Ut>0&&(ls=ls.splice(0,D),ls.push(P.jsx(Fs,W({},Ln,{children:_(Ut)}),ls.length)))}const[Ba,Cf]=Fe("option",{className:bt.option,elementType:S4e,externalForwardedProps:Ms,ownerState:Et,getSlotOwnerState:Ut=>({variant:Ut.variant||fl(ye,Le).variant||"plain",color:Ut.color||fl(ye,Le).color||"neutral",disableColorInversion:!xe.disablePortal}),additionalProps:{as:"li"}}),Mf=ie||((Ut,Bn)=>{const{key:vi}=Ut,$n=at(Ut,o4e);return P.jsx(Ba,W({},$n,{children:N(Bn)}),vi)}),Kh=(Ut,Bn)=>{const vi=Bt({option:Ut,index:Bn});return Mf(W({},Cf,vi),Ut,{selected:!!vi["aria-selected"],inputValue:le,ownerState:Et})},_f=B.useMemo(()=>[{name:"offset",options:{offset:[0,4]}},...xe.modifiers||[]],[xe.modifiers]);let cu=null;if(V){var uu;cu=P.jsx(hb,{variant:ye,color:Le,children:P.jsx(rg,{nested:!0,children:P.jsxs(Ce,W({},xe,{className:Gt(xe.className),modifiers:_f},!((uu=u.slots)!=null&&uu.listbox)&&{as:lO,slots:{root:xe.as||"ul"}},{children:[ke.map((Ut,Bn)=>{if(A){const vi=Ut;return Q({key:String(vi.key),group:vi.group,children:vi.options.map(($n,Qr)=>Kh($n,vi.index+Qr))})}return Kh(Ut,Bn)}),U&&ke.length===0?P.jsx(dt,W({},Ct,{children:K})):null,ke.length===0&&!M&&!U?P.jsx(ns,W({},Ts,{children:J})):null]}))})})}return P.jsxs(B.Fragment,{children:[P.jsxs(Rs,W({},Qt,{children:[fe&&P.jsx(La,W({},id,{children:fe})),P.jsxs(oi,W({},Aa,{children:[ls,P.jsx(Xr,W({},sd))]})),S&&P.jsx(yo,W({},nd,{children:S})),Yt?P.jsx(Jd,W({},$t,{children:m})):null,zt?P.jsx(ms,W({},ds,{children:Z})):null]})),cu]})}),vF=d=>d.name,_b=({value:d,onChange:e,defaultExchangeAccounts:t,disabled:s})=>{const[i,n]=B.useState(d?vF(d):""),[r]=t?[t]:kt.exchangeAccount.list.useSuspenseQuery();return P.jsx(c$,{autoHighlight:!0,disableClearable:!0,getOptionLabel:vF,inputValue:i,isOptionEqualToValue:a=>d?d.id===a.id:!1,onChange:(a,o)=>{e(o)},onInputChange:(a,o)=>{n(o)},options:r,renderOption:(a,o)=>B.createElement(d$,{...a,key:o.id},P.jsx(qh,{children:P.jsx(wL,{exchangeCode:o.exchangeCode,height:20,size:64,width:20})}),P.jsxs(to,{sx:{fontSize:"sm"},children:[o.exchangeCode,P.jsx(ot,{level:"body-xs",children:o.name})]})),value:d||void 0,disabled:s,sx:{"&.Mui-disabled":{borderColor:"var(--joy-palette-neutral-outlinedBorder)"}}})};_b.displayName="ExchangeAccountSelect";function TF(d){if(d===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d}function $2(d,e){return $2=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,s){return t.__proto__=s,t},$2(d,e)}function x4e(d,e){d.prototype=Object.create(e.prototype),d.prototype.constructor=d,$2(d,e)}var OF=Number.isNaN||function(e){return typeof e=="number"&&e!==e};function P4e(d,e){return!!(d===e||OF(d)&&OF(e))}function I4e(d,e){if(d.length!==e.length)return!1;for(var t=0;t=e?d.call(null):i.id=requestAnimationFrame(s)}var i={id:requestAnimationFrame(s)};return i}var TC=-1;function IF(d){if(d===void 0&&(d=!1),TC===-1||d){var e=document.createElement("div"),t=e.style;t.width="50px",t.height="50px",t.overflow="scroll",document.body.appendChild(e),TC=e.offsetWidth-e.clientWidth,document.body.removeChild(e)}return TC}var lp=null;function CF(d){if(d===void 0&&(d=!1),lp===null||d){var e=document.createElement("div"),t=e.style;t.width="50px",t.height="50px",t.overflow="scroll",t.direction="rtl";var s=document.createElement("div"),i=s.style;return i.width="100px",i.height="100px",e.appendChild(s),document.body.appendChild(e),e.scrollLeft>0?lp="positive-descending":(e.scrollLeft=1,e.scrollLeft===0?lp="negative":lp="positive-ascending"),document.body.removeChild(e),lp}return lp}var _4e=150,A4e=function(e,t){return e};function L4e(d){var e,t=d.getItemOffset,s=d.getEstimatedTotalSize,i=d.getItemSize,n=d.getOffsetForIndexAndAlignment,r=d.getStartIndexForOffset,a=d.getStopIndexForStartIndex,o=d.initInstanceProps,c=d.shouldResetStyleCacheOnItemSizeChange,u=d.validateProps;return e=function(h){x4e(l,h);function l(p){var m;return m=h.call(this,p)||this,m._instanceProps=o(m.props,TF(m)),m._outerRef=void 0,m._resetIsScrollingTimeoutId=null,m.state={instance:TF(m),isScrolling:!1,scrollDirection:"forward",scrollOffset:typeof m.props.initialScrollOffset=="number"?m.props.initialScrollOffset:0,scrollUpdateWasRequested:!1},m._callOnItemsRendered=void 0,m._callOnItemsRendered=vC(function(g,y,w,b){return m.props.onItemsRendered({overscanStartIndex:g,overscanStopIndex:y,visibleStartIndex:w,visibleStopIndex:b})}),m._callOnScroll=void 0,m._callOnScroll=vC(function(g,y,w){return m.props.onScroll({scrollDirection:g,scrollOffset:y,scrollUpdateWasRequested:w})}),m._getItemStyle=void 0,m._getItemStyle=function(g){var y=m.props,w=y.direction,b=y.itemSize,S=y.layout,v=m._getItemStyleCache(c&&b,c&&S,c&&w),C;if(v.hasOwnProperty(g))C=v[g];else{var M=t(m.props,g,m._instanceProps),_=i(m.props,g,m._instanceProps),N=w==="horizontal"||S==="horizontal",A=w==="rtl",R=N?M:0;v[g]=C={position:"absolute",left:A?void 0:R,right:A?R:void 0,top:N?0:M,height:N?"100%":_,width:N?_:"100%"}}return C},m._getItemStyleCache=void 0,m._getItemStyleCache=vC(function(g,y,w){return{}}),m._onScrollHorizontal=function(g){var y=g.currentTarget,w=y.clientWidth,b=y.scrollLeft,S=y.scrollWidth;m.setState(function(v){if(v.scrollOffset===b)return null;var C=m.props.direction,M=b;if(C==="rtl")switch(CF()){case"negative":M=-b;break;case"positive-descending":M=S-w-b;break}return M=Math.max(0,Math.min(M,S-w)),{isScrolling:!0,scrollDirection:v.scrollOffsetC.clientWidth?IF():0:v=C.scrollHeight>C.clientHeight?IF():0}this.scrollTo(n(this.props,m,g,S,this._instanceProps,v))},f.componentDidMount=function(){var m=this.props,g=m.direction,y=m.initialScrollOffset,w=m.layout;if(typeof y=="number"&&this._outerRef!=null){var b=this._outerRef;g==="horizontal"||w==="horizontal"?b.scrollLeft=y:b.scrollTop=y}this._callPropsCallbacks()},f.componentDidUpdate=function(){var m=this.props,g=m.direction,y=m.layout,w=this.state,b=w.scrollOffset,S=w.scrollUpdateWasRequested;if(S&&this._outerRef!=null){var v=this._outerRef;if(g==="horizontal"||y==="horizontal")if(g==="rtl")switch(CF()){case"negative":v.scrollLeft=-b;break;case"positive-ascending":v.scrollLeft=b;break;default:var C=v.clientWidth,M=v.scrollWidth;v.scrollLeft=M-C-b;break}else v.scrollLeft=b;else v.scrollTop=b}this._callPropsCallbacks()},f.componentWillUnmount=function(){this._resetIsScrollingTimeoutId!==null&&PF(this._resetIsScrollingTimeoutId)},f.render=function(){var m=this.props,g=m.children,y=m.className,w=m.direction,b=m.height,S=m.innerRef,v=m.innerElementType,C=m.innerTagName,M=m.itemCount,_=m.itemData,N=m.itemKey,A=N===void 0?A4e:N,R=m.layout,D=m.outerElementType,U=m.outerTagName,K=m.style,j=m.useIsScrolling,z=m.width,J=this.state.isScrolling,Y=w==="horizontal"||R==="horizontal",X=Y?this._onScrollHorizontal:this._onScrollVertical,Z=this._getRangeToRender(),te=Z[0],Q=Z[1],ie=[];if(M>0)for(var ne=te;ne<=Q;ne++)ie.push(B.createElement(g,{data:_,key:A(ne,_),index:ne,isScrolling:j?J:void 0,style:this._getItemStyle(ne)}));var oe=s(this.props,this._instanceProps);return B.createElement(D||U||"div",{className:y,onScroll:X,ref:this._outerRefSetter,style:W({position:"relative",height:b,width:z,overflow:"auto",WebkitOverflowScrolling:"touch",willChange:"transform",direction:w},K)},B.createElement(v||C||"div",{children:ie,ref:S,style:{height:Y?"100%":oe,pointerEvents:J?"none":void 0,width:Y?oe:"100%"}}))},f._callPropsCallbacks=function(){if(typeof this.props.onItemsRendered=="function"){var m=this.props.itemCount;if(m>0){var g=this._getRangeToRender(),y=g[0],w=g[1],b=g[2],S=g[3];this._callOnItemsRendered(y,w,b,S)}}if(typeof this.props.onScroll=="function"){var v=this.state,C=v.scrollDirection,M=v.scrollOffset,_=v.scrollUpdateWasRequested;this._callOnScroll(C,M,_)}},f._getRangeToRender=function(){var m=this.props,g=m.itemCount,y=m.overscanCount,w=this.state,b=w.isScrolling,S=w.scrollDirection,v=w.scrollOffset;if(g===0)return[0,0,0,0];var C=r(this.props,v,this._instanceProps),M=a(this.props,C,v,this._instanceProps),_=!b||S==="backward"?Math.max(1,y):1,N=!b||S==="forward"?Math.max(1,y):1;return[Math.max(0,C-_),Math.max(0,Math.min(g-1,M+N)),C,M]},l}(B.PureComponent),e.defaultProps={direction:"ltr",itemData:void 0,layout:"vertical",overscanCount:2,useIsScrolling:!1},e}var B4e=function(e,t){e.children,e.direction,e.height,e.layout,e.innerTagName,e.outerTagName,e.width,t.instance},N4e=L4e({getItemOffset:function(e,t){var s=e.itemSize;return t*s},getItemSize:function(e,t){var s=e.itemSize;return s},getEstimatedTotalSize:function(e){var t=e.itemCount,s=e.itemSize;return s*t},getOffsetForIndexAndAlignment:function(e,t,s,i,n,r){var a=e.direction,o=e.height,c=e.itemCount,u=e.itemSize,h=e.layout,l=e.width,f=a==="horizontal"||h==="horizontal",p=f?l:o,m=Math.max(0,c*u-p),g=Math.min(m,t*u),y=Math.max(0,t*u-p+u+r);switch(s==="smart"&&(i>=y-p&&i<=g+p?s="auto":s="center"),s){case"start":return g;case"end":return y;case"center":{var w=Math.round(y+(g-y)/2);return wm+Math.floor(p/2)?m:w}case"auto":default:return i>=y&&i<=g?i:i{n||a(E4e(i)||document.body)},[i,n]),Iv(()=>{if(r&&!n)return r2(t,r),()=>{r2(t,null)}},[t,r,n]),n){if(B.isValidElement(s)){const c={ref:o};return B.cloneElement(s,c)}return s}return r&&bT.createPortal(s,r)}),u$="Popper";function D4e(d){return bL(u$,d)}AW(u$,["root"]);function q4e(d,e){if(e==="ltr")return d;switch(d){case"bottom-end":return"bottom-start";case"bottom-start":return"bottom-end";case"top-end":return"top-start";case"top-start":return"top-end";default:return d}}function K2(d){return typeof d=="function"?d():d}function V4e(d){return d.nodeType!==void 0}const F4e=()=>nL({root:["root"]},BW(D4e)),H4e={},G4e=B.forwardRef(function(e,t){const{anchorEl:s,children:i,direction:n,disablePortal:r,modifiers:a,open:o,placement:c,popperOptions:u,popperRef:h,slotProps:l={},slots:f={},TransitionProps:p,ownerState:m,...g}=e,y=B.useRef(null),w=Cv(y,t),b=B.useRef(null),S=Cv(b,h),v=B.useRef(S);Iv(()=>{v.current=S},[S]),B.useImperativeHandle(h,()=>b.current,[]);const C=q4e(c,n),[M,_]=B.useState(C),[N,A]=B.useState(K2(s));B.useEffect(()=>{b.current&&b.current.forceUpdate()}),B.useEffect(()=>{s&&A(K2(s))},[s]),Iv(()=>{if(!N||!o)return;const j=Y=>{_(Y.placement)};let z=[{name:"preventOverflow",options:{altBoundary:r}},{name:"flip",options:{altBoundary:r}},{name:"onUpdate",enabled:!0,phase:"afterWrite",fn:({state:Y})=>{j(Y)}}];a!=null&&(z=z.concat(a)),u&&u.modifiers!=null&&(z=z.concat(u.modifiers));const J=pU(N,y.current,{placement:C,...u,modifiers:z});return v.current(J),()=>{J.destroy(),v.current(null)}},[N,r,a,o,u,C]);const R={placement:M};p!==null&&(R.TransitionProps=p);const D=F4e(),U=f.root??"div",K=HU({elementType:U,externalSlotProps:l.root,externalForwardedProps:g,additionalProps:{role:"tooltip",ref:w},ownerState:e,className:D.root});return P.jsx(U,{...K,children:typeof i=="function"?i(R):i})}),U4e=B.forwardRef(function(e,t){const{anchorEl:s,children:i,container:n,direction:r="ltr",disablePortal:a=!1,keepMounted:o=!1,modifiers:c,open:u,placement:h="bottom",popperOptions:l=H4e,popperRef:f,style:p,transition:m=!1,slotProps:g={},slots:y={},...w}=e,[b,S]=B.useState(!0),v=()=>{S(!1)},C=()=>{S(!0)};if(!o&&!u&&(!m||b))return null;let M;if(n)M=n;else if(s){const A=K2(s);M=A&&V4e(A)?cV(A).body:cV(null).body}const _=!u&&o&&(!m||b)?"none":void 0,N=m?{in:u,onEnter:v,onExited:C}:void 0;return P.jsx(R4e,{disablePortal:a,container:M,children:P.jsx(G4e,{anchorEl:s,direction:r,disablePortal:a,modifiers:c,ref:t,open:m?!b:u,placement:h,popperOptions:l,popperRef:f,slotProps:g,slots:y,...w,style:{position:"fixed",top:0,left:0,display:_,...p},TransitionProps:N,children:i})})}),W4e=8,X2=48,j4e=8;function z4e(d){const{data:e,index:t,style:s}=d,[i,n]=e[t],r={...s,top:s.top+W4e,height:X2};return B.createElement(d$,{...i,key:n.symbolId,style:r},P.jsx(qh,{children:P.jsx(DL,{symbol:n.baseCurrency})}),P.jsx(to,{sx:{fontSize:"sm"},children:n.currencyPair}))}const h$=B.createContext({}),l$=B.forwardRef((d,e)=>{const t=B.useContext(h$);return P.jsx(ZFe,{...d,...t,component:"div",ref:e,sx:{"& ul":{padding:0,margin:0,flexShrink:0}}})});l$.displayName="OuterElementType";const $4e=Tn.forwardRef(function(e,t){const{children:s,anchorEl:i,open:n,modifiers:r,...a}=e,o=[];s[0].forEach(u=>{u&&(o.push(u),o.push(...u.children||[]))});const c=o.length;return P.jsx(U4e,{anchorEl:i,modifiers:r,open:n,ref:t,style:{zIndex:1e3},children:P.jsx(h$.Provider,{value:a,children:P.jsx(N4e,{height:X2*j4e,innerElementType:"ul",itemCount:c,itemData:o,itemSize:X2,outerElementType:l$,overscanCount:5,width:"100%",children:z4e})})})});function K4e(...d){return d}const MF=d=>d.currencyPair,X4e=bU({matchFrom:"any",trim:!0,stringify:d=>d.currencyPair}),Ab=({exchangeCode:d,value:e,onChange:t,defaultSymbols:s,disabled:i})=>{const[n,r]=B.useState(e?MF(e):""),[a]=s?[s]:kt.symbol.list.useSuspenseQuery(d);return P.jsx(c$,{autoHighlight:!0,disableClearable:!0,disableListWrap:!0,filterOptions:X4e,getOptionLabel:MF,inputValue:n,onChange:(o,c)=>t(c),onInputChange:(o,c)=>r(c),options:a,renderOption:(...o)=>K4e(...o),slots:{listbox:$4e},value:e||void 0,disabled:i,sx:{"&.Mui-disabled":{borderColor:"var(--joy-palette-neutral-outlinedBorder)"}}})};Ab.displayName="SymbolSelect";function wg({value:d,onChange:e,whitelist:t,optional:s}){const i=t||Object.values(mf);return P.jsxs(fb,{onChange:(n,r)=>{e(r)},required:!0,value:d,children:[s?P.jsx(ef,{value:null,children:""}):null,i.map(n=>P.jsx(ef,{value:n,children:n||""},n))]})}function Q4e(d){if(d.length===0)throw new Error("getWaitingGridLinePrice: empty array provided");if(d.length===1){const{entryOrder:s,takeProfitOrder:i}=d[0];return i.status==="Filled"?i.price:s.price}const e=d.filter(s=>s.entryOrder.status==="Filled");return e.length===0?d[0].takeProfitOrder.price:e.length===1?e[0].entryOrder.price:e.reduce((s,i)=>i.entryOrder.pricei.entryOrder.status==="Filled"?i.takeProfitOrder.price:i.entryOrder.price),e].sort((i,n)=>i-n);return s.map(i=>RMe(i,s,e))}function Z4e(d,e,t){return{time:Sj(e),position:t==="buy"?"belowBar":"aboveBar",color:t==="buy"?"#2196F3":"#e91e63",shape:t==="buy"?"arrowUp":"arrowDown",text:t==="buy"?`B #${d}`:`S #${d}`}}function KB(d,e){const t=J4e(d),s=_F(t.filter(r=>r.side==="buy"),e),i=_F(t.filter(r=>r.side==="sell"),e);return[...s,...i].sort((r,a)=>r.timestamp-a.timestamp).map(r=>Z4e(r.ordersCount,r.timestamp,r.side))}function J4e(d){return d.length===0?[]:d.filter(t=>{const{entryType:s,takeProfitType:i}=t;return s==="Order"&&(i==="Order"||i==="None")}).flatMap(t=>{if(t.entryOrder.filledPrice===null)return[];const s=[t.entryOrder];return t.takeProfitType==="Order"&&t.takeProfitOrder.filledPrice&&s.push(t.takeProfitOrder),s}).map(t=>{if(t.filledPrice===null)throw new Error("computeOrders: filledPrice is null");return{smartTradeId:t.smartTradeId,orderId:t.id,quantity:t.quantity,filledPrice:t.filledPrice,filledAt:YL(t.filledAt.getTime(),"1m"),side:t.side==="Buy"?"buy":"sell"}}).sort((t,s)=>t.filledAt-s.filledAt)}function _F(d,e){const t=d.reduce((s,i)=>{const n=YL(i.filledAt,e);let r=s[n];return r?(r.ordersCount+=1,r.averagePrice=Number(Ro(r.averagePrice+i.filledPrice).div(2).toNumber().toFixed(4))):r={timestamp:n,ordersCount:1,averagePrice:i.filledPrice,side:i.side},{...s,[n]:r}},{});return Object.values(t)}const e6e=["1d","4h","1h","5m","1m"],AF=()=>{},t6e=({botId:d})=>{const[e]=kt.gridBot.getOne.useSuspenseQuery(d),[t]=kt.exchangeAccount.getOne.useSuspenseQuery(e.exchangeAccountId),[s]=kt.symbol.getOne.useSuspenseQuery({symbolId:ZT(t.exchangeCode,JT(e.symbol),eO(e.symbol))}),[i]=kt.bot.activeSmartTrades.useSuspenseQuery({botId:d}),[n]=kt.bot.completedSmartTrades.useSuspenseQuery({botId:d}),r=B.useMemo(()=>Y4e(i),[i]),[a,o]=B.useState("1h"),[c,u]=B.useState(!0),h=B.useMemo(()=>KB(n,a),[n,a]),[l,f]=B.useState(!1);return P.jsx(B.Suspense,{fallback:P.jsx(mi,{animation:"wave",height:Xo,variant:"rectangular",width:"100%"}),children:P.jsxs(hx,{barSize:a,markers:h,priceLines:r,showMarkers:l,showPriceLines:c,symbolId:s.symbolId,children:[P.jsx(_b,{onChange:AF,value:t,disabled:!0}),P.jsx(Ab,{exchangeCode:t.exchangeCode,onChange:AF,value:s,disabled:!0}),P.jsx(wg,{onChange:p=>{o(p)},value:a,whitelist:e6e}),P.jsx(Rc,{}),P.jsx(_t,{display:"flex",children:P.jsx(lx,{gridVisible:c,onGridVisibleChange:u,onTradesVisibleChange:f,tradesVisible:l})})]})})};function fx(d){if(d.entryType==="Ladder")throw new Error("Entry type Ladder not supported yet");if(d.takeProfitType==="Ladder")throw new Error("Take profit type Ladder not supported yet");if(d.takeProfitType==="None"||!d.takeProfitOrder.filledPrice||!d.entryOrder.filledPrice)return{grossProfit:0,netProfit:0,entryOrderFee:0,tpOrderFee:0,fee:0};const{entryOrder:e,takeProfitOrder:t}=d,{quantity:s}=t,i=Ro(t.filledPrice).minus(e.filledPrice).times(s).toNumber(),n=Ro(e.fee??0).times(e.filledPrice),r=t.fee??0,a=Ro(n).plus(r).toNumber(),o=Ro(i).minus(a).toNumber();return{grossProfit:i,netProfit:o,entryOrderFee:n.toNumber(),tpOrderFee:r,fee:a}}function s6e(d){let e=Ro(0);for(const t of d){const{netProfit:s}=fx(t);e=e.plus(s)}return e.toNumber()}function i6e(d){return Ph(d,Date.now())}function I1(d,e){const t=ri(d),s=ri(e),i=t.getTime()-s.getTime();return i<0?-1:i>0?1:i}function n6e(d,e){const t=ri(d),s=ri(e),i=t.getFullYear()-s.getFullYear(),n=t.getMonth()-s.getMonth();return i*12+n}function r6e(d){const e=ri(d);return e.setHours(23,59,59,999),e}function a6e(d){const e=ri(d),t=e.getMonth();return e.setFullYear(e.getFullYear(),t+1,0),e.setHours(23,59,59,999),e}function o6e(d){const e=ri(d);return+r6e(e)==+a6e(e)}function d6e(d,e){const t=ri(d),s=ri(e),i=I1(t,s),n=Math.abs(n6e(t,s));let r;if(n<1)r=0;else{t.getMonth()===1&&t.getDate()>27&&t.setDate(30),t.setMonth(t.getMonth()-i*n);let a=I1(t,s)===-i;o6e(ri(d))&&n===1&&I1(d,s)===1&&(a=!1),r=i*(n-Number(a))}return r===0?0:r}function c6e(d){return e=>{const s=(d?Math[d]:Math.trunc)(e);return s===0?0:s}}function u6e(d,e){return+ri(d)-+ri(e)}function h6e(d,e,t){const s=u6e(d,e)/1e3;return c6e(t==null?void 0:t.roundingMethod)(s)}function l6e(d,e,t){const s=lb(),i=(t==null?void 0:t.locale)??s.locale??lW,n=2520,r=I1(d,e);if(isNaN(r))throw new RangeError("Invalid time value");const a=Object.assign({},t,{addSuffix:t==null?void 0:t.addSuffix,comparison:r});let o,c;r>0?(o=ri(e),c=ri(d)):(o=ri(d),c=ri(e));const u=h6e(c,o),h=(Nv(c)-Nv(o))/1e3,l=Math.round((u-h)/60);let f;if(l<2)return t!=null&&t.includeSeconds?u<5?i.formatDistance("lessThanXSeconds",5,a):u<10?i.formatDistance("lessThanXSeconds",10,a):u<20?i.formatDistance("lessThanXSeconds",20,a):u<40?i.formatDistance("halfAMinute",0,a):u<60?i.formatDistance("lessThanXMinutes",1,a):i.formatDistance("xMinutes",1,a):l===0?i.formatDistance("lessThanXMinutes",1,a):i.formatDistance("xMinutes",l,a);if(l<45)return i.formatDistance("xMinutes",l,a);if(l<90)return i.formatDistance("aboutXHours",1,a);if(l{var a,o;const{id:e,entryOrder:t,takeProfitOrder:s}=d,{fee:i}=fx(d),{baseCurrency:n,quoteCurrency:r}=Kd(d.symbol);return P.jsxs(_t,{sx:{display:"flex",flexDirection:"column",maxWidth:320,justifyContent:"center",p:1},children:[P.jsx(ot,{fontSize:"sm",children:"SmartTrade"}),P.jsxs(Dh,{size:"sm",children:[P.jsxs(Er,{children:[P.jsx(to,{children:"ID"}),e]}),P.jsxs(Er,{children:[P.jsx(to,{children:"Qty"}),s.quantity," ",n]}),P.jsxs(Er,{children:[P.jsx(to,{children:"Buy"}),(a=t.filledPrice)==null?void 0:a.toFixed(2)," ",r]}),P.jsxs(Er,{children:[P.jsx(to,{children:"Sell"}),(o=s.filledPrice)==null?void 0:o.toFixed(2)," ",r]}),P.jsxs(Er,{children:[P.jsx(to,{children:"Fee"}),i.toFixed(2)," ",r]})]})]})},XB=({profit:d,currency:e,size:t="md"})=>{const s=d>=0,i=s?"+":"",n=s?"var(--joy-palette-success-500)":"var(--joy-palette-danger-500)";return P.jsxs(ot,{level:`title-${t}`,sx:{color:n,fontWeight:"bold"},children:[i,d.toFixed(2)," ",e]})},g6e=({smartTrade:d})=>{const{netProfit:e}=fx(d),{filledAt:t}=d.takeProfitOrder,s=t?Jl(t.getTime()):"Missing date",{quoteCurrency:i}=Kd(d.symbol);return P.jsxs(Er,{children:[P.jsx(qh,{children:P.jsx(XB,{currency:i,profit:e})}),P.jsx(to,{}),P.jsx(In,{title:s,children:P.jsx(ot,{children:t?f6e(t):"Missing date"})}),P.jsx(In,{title:P.jsx(m6e,{smartTrade:d}),children:P.jsx(p6e,{})})]})},QB=({botId:d})=>{const[e]=kt.bot.getOne.useSuspenseQuery(d),[t]=kt.bot.completedSmartTrades.useSuspenseQuery({botId:d}),s=s6e(t),{quoteCurrency:i}=Kd(e.symbol);return P.jsxs(fn,{sx:{maxHeight:500},children:[P.jsxs(_t,{display:"flex",justifyContent:"space-between",children:[P.jsx(ot,{fontSize:"xl2",fontWeight:"xl",level:"h3",children:"Profits"}),t.length>0?P.jsx(In,{title:"Total profit",children:P.jsx(ot,{fontSize:"xl2",fontWeight:"xl",level:"h3",children:P.jsx(XB,{currency:i,profit:s,size:"lg"})})}):null]}),t.length>0?P.jsx(Oh,{sx:{overflowY:"scroll"},children:P.jsx(Dh,{size:"sm",children:t.map((n,r)=>P.jsxs(Tn.Fragment,{children:[P.jsx(g6e,{smartTrade:n},n.id),rP.jsx("thead",{children:P.jsxs("tr",{children:[P.jsx("th",{children:"Type"}),P.jsx("th",{style:{textAlign:"right"},children:"Quantity"}),P.jsx("th",{children:"Price"}),P.jsx("th",{children:"Amount"}),P.jsx("th",{children:"Status"}),P.jsx("th",{children:"Orders status"}),P.jsx("th",{style:{textAlign:"right"},children:"Created"}),P.jsx("th",{style:{width:f$,textAlign:"right"},children:"ID"})]})});function b6e(d){return Rt("MuiRadio",d)}const Lw=Dt("MuiRadio",["root","radio","icon","action","input","label","checked","disabled","focusVisible","colorPrimary","colorDanger","colorNeutral","colorSuccess","colorWarning","colorContext","sizeSm","sizeMd","sizeLg","variantOutlined","variantSoft","variantSolid"]),k6e=["checked","checkedIcon","defaultChecked","disabled","disableIcon","overlay","label","id","name","onBlur","onChange","onFocus","onFocusVisible","readOnly","required","color","variant","size","uncheckedIcon","value","component","slots","slotProps"],S6e=d=>{const{checked:e,disabled:t,disableIcon:s,focusVisible:i,color:n,variant:r,size:a}=d,o={root:["root",e&&"checked",t&&"disabled",i&&"focusVisible",r&&`variant${De(r)}`,n&&`color${De(n)}`,a&&`size${De(a)}`],radio:["radio",e&&"checked",t&&"disabled"],icon:["icon"],action:["action",e&&"checked",s&&t&&"disabled",i&&"focusVisible"],input:["input"],label:["label"]};return Nt(o,b6e,{})};function v6e(d,e){return typeof e=="object"&&e!==null?d===e:String(d)===String(e)}const T6e=_e("span",{name:"JoyRadio",slot:"Root",overridesResolver:(d,e)=>e.root})(({ownerState:d,theme:e})=>{var t,s,i;return[W({"--Icon-fontSize":"var(--Radio-size)","--Icon-color":"currentColor"},d.size==="sm"&&{"--Radio-size":"1rem","& ~ *":{"--FormHelperText-margin":"0 0 0 1.5rem"},fontSize:e.vars.fontSize.sm,gap:"var(--Radio-gap, 0.5rem)"},d.size==="md"&&{"--Radio-size":"1.25rem","& ~ *":{"--FormHelperText-margin":"0.25rem 0 0 1.875rem"},fontSize:e.vars.fontSize.md,gap:"var(--Radio-gap, 0.625rem)"},d.size==="lg"&&{"--Radio-size":"1.5rem","& ~ *":{"--FormHelperText-margin":"0.375rem 0 0 2.25rem"},fontSize:e.vars.fontSize.lg,gap:"var(--Radio-gap, 0.75rem)"},{position:d.overlay?"initial":"relative",display:"inline-flex",boxSizing:"border-box",minWidth:0,fontFamily:e.vars.fontFamily.body,lineHeight:"var(--Radio-size)",color:e.vars.palette.text.primary,[`&.${Lw.disabled}`]:{color:(t=e.variants.plainDisabled)==null||(t=t[d.color])==null?void 0:t.color}},d.disableIcon&&{color:(s=e.variants[d.variant])==null||(s=s[d.color])==null?void 0:s.color,[`&.${Lw.disabled}`]:{color:(i=e.variants[`${d.variant}Disabled`])==null||(i=i[d.color])==null?void 0:i.color}},d["data-parent"]==="RadioGroup"&&d["data-first-child"]===void 0&&{marginInlineStart:d.orientation==="horizontal"?"var(--RadioGroup-gap)":void 0,marginBlockStart:d.orientation==="horizontal"?void 0:"var(--RadioGroup-gap)"})]}),O6e=_e("span",{name:"JoyRadio",slot:"Radio",overridesResolver:(d,e)=>e.radio})(({ownerState:d,theme:e})=>{var t,s,i,n,r;const a=(t=e.variants[`${d.variant}`])==null?void 0:t[d.color];return[W({"--Icon-color":d.color!=="neutral"||d.variant==="solid"?"currentColor":e.vars.palette.text.icon,margin:0,boxSizing:"border-box",width:"var(--Radio-size)",height:"var(--Radio-size)",borderRadius:"var(--Radio-size)",display:"inline-flex",justifyContent:"center",alignItems:"center",flexShrink:0},d.disableIcon&&{display:"contents"},{[`&.${Lw.checked}`]:{"--Icon-color":"currentColor"}}),...d.disableIcon?[]:[W({},a,{backgroundColor:(s=a==null?void 0:a.backgroundColor)!=null?s:e.vars.palette.background.surface}),{"&:hover":{"@media (hover: hover)":(i=e.variants[`${d.variant}Hover`])==null?void 0:i[d.color]}},{"&:active":(n=e.variants[`${d.variant}Active`])==null?void 0:n[d.color]},{[`&.${Lw.disabled}`]:(r=e.variants[`${d.variant}Disabled`])==null?void 0:r[d.color]}]]}),x6e=_e("span",{name:"JoyRadio",slot:"Action",overridesResolver:(d,e)=>e.action})(({theme:d,ownerState:e})=>{var t,s,i,n;return[{position:"absolute",textAlign:"left",borderRadius:`var(--Radio-actionRadius, ${e.overlay?"var(--unstable_actionRadius, inherit)":"inherit"})`,top:"calc(-1 * var(--variant-borderWidth, 0px))",left:"calc(-1 * var(--variant-borderWidth, 0px))",bottom:"calc(-1 * var(--variant-borderWidth, 0px))",right:"calc(-1 * var(--variant-borderWidth, 0px))",zIndex:1,[d.focus.selector]:d.focus.default},...e.disableIcon?[(t=d.variants[e.variant])==null?void 0:t[e.color],{"&:hover":{"@media (hover: hover)":(s=d.variants[`${e.variant}Hover`])==null?void 0:s[e.color]}},{"&:active":(i=d.variants[`${e.variant}Active`])==null?void 0:i[e.color]},{[`&.${Lw.disabled}`]:(n=d.variants[`${e.variant}Disabled`])==null?void 0:n[e.color]}]:[]]}),P6e=_e("input",{name:"JoyRadio",slot:"Input",overridesResolver:(d,e)=>e.input})(()=>({margin:0,opacity:0,position:"absolute",height:"100%",width:"100%",cursor:"pointer"})),I6e=_e("label",{name:"JoyRadio",slot:"Label",overridesResolver:(d,e)=>e.label})(({ownerState:d})=>W({flex:1,minWidth:0},d.disableIcon&&{zIndex:1,pointerEvents:"none"})),C6e=_e("span",{name:"JoyRadio",slot:"Icon",overridesResolver:(d,e)=>e.icon})(({ownerState:d})=>({width:"calc(var(--Radio-size) / 2)",height:"calc(var(--Radio-size) / 2)",borderRadius:"inherit",color:"inherit",backgroundColor:"currentColor",transform:d.checked?"scale(1)":"scale(0)"})),M6e=B.forwardRef(function(e,t){var s,i,n,r,a,o,c;const u=qt({props:e,name:"JoyRadio"}),{checked:h,checkedIcon:l,defaultChecked:f,disabled:p,disableIcon:m=!1,overlay:g=!1,label:y,id:w,name:b,onBlur:S,onChange:v,onFocus:C,onFocusVisible:M,readOnly:_,required:N,color:A,variant:R="outlined",size:D="md",uncheckedIcon:U,value:K,component:j,slots:z={},slotProps:J={}}=u,Y=at(u,k6e),X=B.useContext($o),Z=ln(w??(X==null?void 0:X.htmlFor)),te=B.useContext(gL),Q=X!=null&&X.error?"danger":(s=(i=(n=e.color)!=null?n:X==null?void 0:X.color)!=null?i:A)!=null?s:"primary",ie=X!=null&&X.error?"danger":(r=(a=(o=e.color)!=null?o:X==null?void 0:X.color)!=null?a:A)!=null?r:"neutral",ne=e.size||(X==null?void 0:X.size)||(te==null?void 0:te.size)||D,oe=e.name||(te==null?void 0:te.name)||b,me=e.disableIcon||(te==null?void 0:te.disableIcon)||m,fe=e.overlay||(te==null?void 0:te.overlay)||g,Se={checked:typeof h>"u"&&K!=null?v6e(te==null?void 0:te.value,K):h,defaultChecked:f,disabled:e.disabled||(X==null?void 0:X.disabled)||p,onBlur:S,onChange:v,onFocus:C,onFocusVisible:M},{getInputProps:ye,checked:ge,disabled:Te,focusVisible:Ge}=JA(Se),Ye=(c=e.color)!=null?c:ge?Q:ie,Re=W({},u,{checked:ge,disabled:Te,focusVisible:Ge,color:Ye,variant:R,size:ne,disableIcon:me,overlay:fe,orientation:te==null?void 0:te.orientation}),Be=S6e(Re),Me=W({},Y,{component:j,slots:z,slotProps:J}),[Le,rt]=Fe("root",{ref:t,className:Be.root,elementType:T6e,externalForwardedProps:Me,ownerState:Re}),[ze,Ue]=Fe("radio",{className:Be.radio,elementType:O6e,externalForwardedProps:Me,ownerState:Re}),[Je,st]=Fe("icon",{className:Be.icon,elementType:C6e,externalForwardedProps:Me,ownerState:Re}),[ut,yt]=Fe("action",{className:Be.action,elementType:x6e,externalForwardedProps:Me,ownerState:Re}),[Bt,lt]=Fe("input",{additionalProps:{type:"radio",role:void 0,id:Z,name:oe,readOnly:_,required:N??(X==null?void 0:X.required),value:String(K),"aria-describedby":X==null?void 0:X["aria-describedby"]},className:Be.input,elementType:P6e,externalForwardedProps:Me,getSlotProps:()=>ye({onChange:te==null?void 0:te.onChange}),ownerState:Re}),[ht,ft]=Fe("label",{additionalProps:{htmlFor:Z},className:Be.label,elementType:I6e,externalForwardedProps:Me,ownerState:Re});return P.jsxs(Le,W({},rt,{children:[P.jsxs(ze,W({},Ue,{children:[ge&&!me&&l,!ge&&!me&&U,!l&&!U&&!me&&P.jsx(Je,W({},st)),P.jsx(ut,W({},yt,{children:P.jsx(Bt,W({},lt))}))]})),y&&P.jsx(ht,W({},ft,{children:P.jsx(xv.Provider,{value:!0,children:y})}))]}))});function _6e(d){return Rt("MuiRadioGroup",d)}Dt("MuiRadioGroup",["root","colorPrimary","colorNeutral","colorDanger","colorSuccess","colorWarning","variantPlain","variantOutlined","variantSoft","variantSolid","sizeSm","sizeMd","sizeLg","horizontal","vertical"]);const A6e=["className","component","children","name","defaultValue","disableIcon","overlay","value","onChange","color","variant","size","orientation","role","slots","slotProps"],L6e=d=>{const{orientation:e,size:t,variant:s,color:i}=d,n={root:["root",e,s&&`variant${De(s)}`,i&&`color${De(i)}`,t&&`size${De(t)}`]};return Nt(n,_6e,{})},B6e=_e("div",{name:"JoyRadioGroup",slot:"Root",overridesResolver:(d,e)=>e.root})(({ownerState:d,theme:e})=>{var t;return W({},d.size==="sm"&&{"--RadioGroup-gap":"0.625rem"},d.size==="md"&&{"--RadioGroup-gap":"0.875rem"},d.size==="lg"&&{"--RadioGroup-gap":"1.25rem"},{display:"flex",margin:"var(--unstable_RadioGroup-margin)",flexDirection:d.orientation==="horizontal"?"row":"column",borderRadius:e.vars.radius.sm},(t=e.variants[d.variant])==null?void 0:t[d.color])}),N6e=B.forwardRef(function(e,t){const s=qt({props:e,name:"JoyRadioGroup"}),{className:i,component:n,children:r,name:a,defaultValue:o,disableIcon:c=!1,overlay:u,value:h,onChange:l,color:f="neutral",variant:p="plain",size:m="md",orientation:g="vertical",role:y="radiogroup",slots:w={},slotProps:b={}}=s,S=at(s,A6e),[v,C]=ch({controlled:h,default:o,name:"RadioGroup"}),M=B.useContext($o),_=e.size||(M==null?void 0:M.size)||m,N=W({orientation:g,size:_,variant:p,color:f,role:y},s),A=L6e(N),R=ln(a),D=B.useMemo(()=>({disableIcon:c,overlay:u,orientation:g,size:_,name:R,value:v,onChange:j=>{C(j.target.value),l&&l(j)}}),[c,R,l,u,g,C,_,v]),[U,K]=Fe("root",{ref:t,className:Gt(A.root,i),elementType:B6e,externalForwardedProps:W({},S,{component:n,slots:w,slotProps:b}),ownerState:N,additionalProps:{as:n,role:y,id:M==null?void 0:M.htmlFor,"aria-labelledby":M==null?void 0:M.labelId,"aria-describedby":M==null?void 0:M["aria-describedby"]}});return P.jsx(gL.Provider,{value:D,children:P.jsx(U,W({},K,{children:P.jsx($o.Provider,{value:void 0,children:B.Children.map(r,(j,z)=>B.isValidElement(j)?B.cloneElement(j,W({},z===0&&{"data-first-child":""},z===B.Children.count(r)-1&&{"data-last-child":""},{"data-parent":"RadioGroup"})):j)})}))})}),E6e=["checked","defaultChecked","disabled","onBlur","onChange","onFocus","onFocusVisible","readOnly","required","id","color","variant","size","startDecorator","endDecorator","component","slots","slotProps"],R6e=d=>{const{checked:e,disabled:t,focusVisible:s,readOnly:i,color:n,variant:r,size:a}=d,o={root:["root",e&&"checked",t&&"disabled",s&&"focusVisible",i&&"readOnly",r&&`variant${De(r)}`,n&&`color${De(n)}`,a&&`size${De(a)}`],thumb:["thumb",e&&"checked"],track:["track",e&&"checked"],action:["action",s&&"focusVisible"],input:["input"],startDecorator:["startDecorator"],endDecorator:["endDecorator"]};return Nt(o,Gke,{})},D6e=({theme:d,ownerState:e})=>(t={})=>{var s,i,n;const r=((s=d.variants[`${e.variant}${t.state||""}`])==null?void 0:s[e.color])||{};return{"--Switch-trackBackground":(i=r.backgroundColor)!=null?i:d.vars.palette.background.surface,"--Switch-trackColor":r.color,"--Switch-trackBorderColor":e.variant==="outlined"?r.borderColor:"currentColor","--Switch-thumbBackground":r.color,"--Switch-thumbColor":(n=r.backgroundColor)!=null?n:d.vars.palette.background.surface}},q6e=_e("div",{name:"JoySwitch",slot:"Root",overridesResolver:(d,e)=>e.root})(({theme:d,ownerState:e})=>{var t;const s=D6e({theme:d,ownerState:e});return W({"--Icon-color":"currentColor","--variant-borderWidth":(t=d.variants[e.variant])==null||(t=t[e.color])==null?void 0:t["--variant-borderWidth"],"--Switch-trackRadius":d.vars.radius.xl,"--Switch-thumbShadow":e.variant==="soft"?"none":"0 0 0 1px var(--Switch-trackBackground)"},e.size==="sm"&&{"--Switch-trackWidth":"26px","--Switch-trackHeight":"16px","--Switch-thumbSize":"10px",fontSize:d.vars.fontSize.sm,gap:"var(--Switch-gap, 6px)"},e.size==="md"&&{"--Switch-trackWidth":"32px","--Switch-trackHeight":"20px","--Switch-thumbSize":"14px",fontSize:d.vars.fontSize.md,gap:"var(--Switch-gap, 8px)"},e.size==="lg"&&{"--Switch-trackWidth":"40px","--Switch-trackHeight":"24px","--Switch-thumbSize":"18px",gap:"var(--Switch-gap, 12px)"},{"--unstable_paddingBlock":"max((var(--Switch-trackHeight) - 2 * var(--variant-borderWidth, 0px) - var(--Switch-thumbSize)) / 2, 0px)","--Switch-thumbRadius":"max(var(--Switch-trackRadius) - var(--unstable_paddingBlock), min(var(--unstable_paddingBlock) / 2, var(--Switch-trackRadius) / 2))","--Switch-thumbWidth":"var(--Switch-thumbSize)","--Switch-thumbOffset":"max((var(--Switch-trackHeight) - var(--Switch-thumbSize)) / 2, 0px)"},s(),{"&:hover":{"@media (hover: hover)":W({},s({state:"Hover"}))},[`&.${Av.checked}`]:W({},s(),{"&:hover":{"@media (hover: hover)":W({},s({state:"Hover"}))}}),[`&.${Av.disabled}`]:W({pointerEvents:"none",color:d.vars.palette.text.tertiary},s({state:"Disabled"})),display:"inline-flex",alignItems:"center",alignSelf:"center",fontFamily:d.vars.fontFamily.body,position:"relative",padding:"calc((var(--Switch-thumbSize) / 2) - (var(--Switch-trackHeight) / 2)) calc(-1 * var(--Switch-thumbOffset))",backgroundColor:"initial",border:"none",margin:"var(--unstable_Switch-margin)"})}),V6e=_e("div",{name:"JoySwitch",slot:"Action",overridesResolver:(d,e)=>e.action})(({theme:d})=>({borderRadius:"var(--Switch-trackRadius)",position:"absolute",top:0,left:0,bottom:0,right:0,[d.focus.selector]:d.focus.default})),F6e=_e("input",{name:"JoySwitch",slot:"Input",overridesResolver:(d,e)=>e.input})({margin:0,height:"100%",width:"100%",opacity:0,position:"absolute",cursor:"pointer"}),H6e=_e("span",{name:"JoySwitch",slot:"Track",overridesResolver:(d,e)=>e.track})(({theme:d,ownerState:e})=>W({position:"relative",color:"var(--Switch-trackColor)",height:"var(--Switch-trackHeight)",width:"var(--Switch-trackWidth)",display:"flex",flexShrink:0,justifyContent:"space-between",alignItems:"center",boxSizing:"border-box",border:"var(--variant-borderWidth, 0px) solid",borderColor:"var(--Switch-trackBorderColor)",backgroundColor:"var(--Switch-trackBackground)",borderRadius:"var(--Switch-trackRadius)",fontFamily:d.vars.fontFamily.body},e.size==="sm"&&{fontSize:d.vars.fontSize.xs},e.size==="md"&&{fontSize:d.vars.fontSize.sm},e.size==="lg"&&{fontSize:d.vars.fontSize.md})),G6e=_e("span",{name:"JoySwitch",slot:"Thumb",overridesResolver:(d,e)=>e.thumb})({"--Icon-fontSize":"calc(var(--Switch-thumbSize) * 0.75)",display:"inline-flex",justifyContent:"center",alignItems:"center",position:"absolute",top:"50%",left:"calc(50% - var(--Switch-trackWidth) / 2 + var(--Switch-thumbWidth) / 2 + var(--Switch-thumbOffset))",transform:"translate(-50%, -50%)",width:"var(--Switch-thumbWidth)",height:"var(--Switch-thumbSize)",borderRadius:"var(--Switch-thumbRadius)",boxShadow:"var(--Switch-thumbShadow)",color:"var(--Switch-thumbColor)",backgroundColor:"var(--Switch-thumbBackground)",[`&.${Av.checked}`]:{left:"calc(50% + var(--Switch-trackWidth) / 2 - var(--Switch-thumbWidth) / 2 - var(--Switch-thumbOffset))"}}),U6e=_e("span",{name:"JoySwitch",slot:"StartDecorator",overridesResolver:(d,e)=>e.startDecorator})({display:"inline-flex"}),W6e=_e("span",{name:"JoySwitch",slot:"EndDecorator",overridesResolver:(d,e)=>e.endDecorator})({display:"inline-flex"}),j6e=B.forwardRef(function(e,t){var s,i,n,r,a,o;const c=qt({props:e,name:"JoySwitch"}),{disabled:u,id:h,color:l,variant:f="solid",size:p="md",startDecorator:m,endDecorator:g,component:y,slots:w={},slotProps:b={}}=c,S=at(c,E6e),v=B.useContext($o),C=(s=(i=e.size)!=null?i:v==null?void 0:v.size)!=null?s:p,M=(n=e.color)!=null?n:v!=null&&v.error?"danger":(r=v==null?void 0:v.color)!=null?r:l,_=W({disabled:(a=(o=e.disabled)!=null?o:v==null?void 0:v.disabled)!=null?a:u},c),{getInputProps:N,checked:A,disabled:R,focusVisible:D,readOnly:U}=JA(_),K=W({},c,{id:h,checked:A,disabled:R,focusVisible:D,readOnly:U,color:A?M||"primary":M||"neutral",variant:f,size:C}),j=R6e(K),z=W({},S,{component:y,slots:w,slotProps:b}),[J,Y]=Fe("root",{ref:t,className:j.root,elementType:q6e,externalForwardedProps:z,ownerState:K}),[X,Z]=Fe("startDecorator",{additionalProps:{"aria-hidden":!0},className:j.startDecorator,elementType:U6e,externalForwardedProps:z,ownerState:K}),[te,Q]=Fe("endDecorator",{additionalProps:{"aria-hidden":!0},className:j.endDecorator,elementType:W6e,externalForwardedProps:z,ownerState:K}),[ie,ne]=Fe("track",{className:j.track,elementType:H6e,externalForwardedProps:z,ownerState:K}),[oe,me]=Fe("thumb",{className:j.thumb,elementType:G6e,externalForwardedProps:z,ownerState:K}),[fe,he]=Fe("action",{className:j.action,elementType:V6e,externalForwardedProps:z,ownerState:K}),[Se,ye]=Fe("input",{additionalProps:{id:h??(v==null?void 0:v.htmlFor),"aria-describedby":v==null?void 0:v["aria-describedby"]},className:j.input,elementType:F6e,externalForwardedProps:z,getSlotProps:N,ownerState:K});return P.jsxs(J,W({},Y,{children:[m&&P.jsx(X,W({},Z,{children:typeof m=="function"?m(K):m})),P.jsxs(ie,W({},ne,{children:[ne==null?void 0:ne.children,P.jsx(oe,W({},me))]})),P.jsx(fe,W({},he,{children:P.jsx(Se,W({},ye))})),g&&P.jsx(te,W({},Q,{children:typeof g=="function"?g(K):g}))]}))});function z6e(d){return Rt("MuiTextarea",d)}const p$=Dt("MuiTextarea",["root","textarea","startDecorator","endDecorator","formControl","disabled","error","focused","colorPrimary","colorNeutral","colorDanger","colorSuccess","colorWarning","colorContext","sizeSm","sizeMd","sizeLg","variantPlain","variantOutlined","variantSoft"]),$6e=["propsToForward","rootStateClasses","inputStateClasses","getRootProps","getInputProps","formControl","focused","error","disabled","size","color","variant","startDecorator","endDecorator","minRows","maxRows","component","slots","slotProps"],K6e=d=>{const{disabled:e,variant:t,color:s,size:i}=d,n={root:["root",e&&"disabled",t&&`variant${De(t)}`,s&&`color${De(s)}`,i&&`size${De(i)}`],textarea:["textarea"],startDecorator:["startDecorator"],endDecorator:["endDecorator"]};return Nt(n,z6e,{})},X6e=_e("div",{name:"JoyTextarea",slot:"Root",overridesResolver:(d,e)=>e.root})(({theme:d,ownerState:e})=>{var t,s,i,n,r,a;const o=(t=d.variants[`${e.variant}`])==null?void 0:t[e.color];return[W({"--Textarea-radius":d.vars.radius.sm,"--Textarea-gap":"0.5rem","--Textarea-placeholderColor":"inherit","--Textarea-placeholderOpacity":.64,"--Textarea-decoratorColor":d.vars.palette.text.icon,"--Textarea-focused":"0","--Textarea-focusedThickness":d.vars.focus.thickness,"--Textarea-focusedHighlight":(s=d.vars.palette[e.color==="neutral"?"primary":e.color])==null?void 0:s[500],'&:not([data-inverted-colors="false"])':W({},e.instanceColor&&{"--_Textarea-focusedHighlight":(i=d.vars.palette[e.instanceColor==="neutral"?"primary":e.instanceColor])==null?void 0:i[500]},{"--Textarea-focusedHighlight":`var(--_Textarea-focusedHighlight, ${d.vars.palette.focusVisible})`})},e.size==="sm"&&{"--Textarea-minHeight":"2rem","--Textarea-paddingBlock":"calc(0.375rem - 0.5px - var(--variant-borderWidth, 0px))","--Textarea-paddingInline":"0.5rem","--Textarea-decoratorChildHeight":"min(1.5rem, var(--Textarea-minHeight))","--Icon-fontSize":d.vars.fontSize.xl},e.size==="md"&&{"--Textarea-minHeight":"2.25rem","--Textarea-paddingBlock":"calc(0.375rem - var(--variant-borderWidth, 0px))","--Textarea-paddingInline":"0.75rem","--Textarea-decoratorChildHeight":"min(1.75rem, var(--Textarea-minHeight))","--Icon-fontSize":d.vars.fontSize.xl2},e.size==="lg"&&{"--Textarea-minHeight":"3rem","--Textarea-paddingBlock":"calc(0.75rem - var(--variant-borderWidth, 0px))","--Textarea-paddingInline":"1rem","--Textarea-gap":"0.75rem","--Textarea-decoratorChildHeight":"min(2.375rem, var(--Textarea-minHeight))","--Icon-fontSize":d.vars.fontSize.xl2},{"--_Textarea-paddingBlock":"max((var(--Textarea-minHeight) - 2 * var(--variant-borderWidth, 0px) - var(--Textarea-decoratorChildHeight)) / 2, 0px)","--Textarea-decoratorChildRadius":"max(var(--Textarea-radius) - var(--variant-borderWidth, 0px) - var(--_Textarea-paddingBlock), min(var(--_Textarea-paddingBlock) + var(--variant-borderWidth, 0px), var(--Textarea-radius) / 2))","--Button-minHeight":"var(--Textarea-decoratorChildHeight)","--Button-paddingBlock":"0px","--IconButton-size":"var(--Textarea-decoratorChildHeight)","--Button-radius":"var(--Textarea-decoratorChildRadius)","--IconButton-radius":"var(--Textarea-decoratorChildRadius)",boxSizing:"border-box"},e.variant!=="plain"&&{boxShadow:d.shadow.xs},{minWidth:0,minHeight:"var(--Textarea-minHeight)",cursor:"text",position:"relative",display:"flex",flexDirection:"column",paddingInlineStart:"var(--Textarea-paddingInline)",paddingBlock:"var(--Textarea-paddingBlock)",borderRadius:"var(--Textarea-radius)"},d.typography[`body-${e.size}`],o,{backgroundColor:(n=o==null?void 0:o.backgroundColor)!=null?n:d.vars.palette.background.surface,"&::before":{boxSizing:"border-box",content:'""',display:"block",position:"absolute",pointerEvents:"none",top:0,left:0,right:0,bottom:0,zIndex:1,borderRadius:"inherit",margin:"calc(var(--variant-borderWidth, 0px) * -1)",boxShadow:"var(--Textarea-focusedInset, inset) 0 0 0 calc(var(--Textarea-focused) * var(--Textarea-focusedThickness)) var(--Textarea-focusedHighlight)"}}),{"&:hover":W({},(r=d.variants[`${e.variant}Hover`])==null?void 0:r[e.color],{backgroundColor:null,cursor:"text"}),[`&.${p$.disabled}`]:(a=d.variants[`${e.variant}Disabled`])==null?void 0:a[e.color],"&:focus-within::before":{"--Textarea-focused":"1"}}]}),Q6e=_e(sye,{name:"JoyTextarea",slot:"Textarea",overridesResolver:(d,e)=>e.textarea})({resize:"none",border:"none",minWidth:0,outline:0,padding:0,paddingInlineEnd:"var(--Textarea-paddingInline)",flex:"auto",alignSelf:"stretch",color:"inherit",backgroundColor:"transparent",fontFamily:"inherit",fontSize:"inherit",fontStyle:"inherit",fontWeight:"inherit",lineHeight:"inherit","&::-webkit-input-placeholder":{color:"var(--Textarea-placeholderColor)",opacity:"var(--Textarea-placeholderOpacity)"},"&::-moz-placeholder":{color:"var(--Textarea-placeholderColor)",opacity:"var(--Textarea-placeholderOpacity)"},"&:-ms-input-placeholder":{color:"var(--Textarea-placeholderColor)",opacity:"var(--Textarea-placeholderOpacity)"},"&::-ms-input-placeholder":{color:"var(--Textarea-placeholderColor)",opacity:"var(--Textarea-placeholderOpacity)"}}),Y6e=_e("div",{name:"JoyTextarea",slot:"StartDecorator",overridesResolver:(d,e)=>e.startDecorator})({display:"flex",marginInlineStart:"calc(var(--Textarea-paddingBlock) - var(--Textarea-paddingInline))",marginInlineEnd:"var(--Textarea-paddingBlock)",marginBlockEnd:"var(--Textarea-gap)",color:"var(--Textarea-decoratorColor)",cursor:"initial"}),Z6e=_e("div",{name:"JoyTextarea",slot:"EndDecorator",overridesResolver:(d,e)=>e.endDecorator})({display:"flex",marginInlineStart:"calc(var(--Textarea-paddingBlock) - var(--Textarea-paddingInline))",marginInlineEnd:"var(--Textarea-paddingBlock)",marginBlockStart:"var(--Textarea-gap)",color:"var(--Textarea-decoratorColor)",cursor:"initial"}),J6e=B.forwardRef(function(e,t){var s,i,n,r,a,o,c,u;const h=qt({props:e,name:"JoyTextarea"}),l=iW(h,p$),{propsToForward:f,rootStateClasses:p,inputStateClasses:m,getRootProps:g,getInputProps:y,formControl:w,focused:b,error:S=!1,disabled:v=!1,size:C="md",color:M="neutral",variant:_="outlined",startDecorator:N,endDecorator:A,minRows:R,maxRows:D,component:U,slots:K={},slotProps:j={}}=l,z=at(l,$6e),J=(s=(i=e.disabled)!=null?i:w==null?void 0:w.disabled)!=null?s:v,Y=(n=(r=e.error)!=null?r:w==null?void 0:w.error)!=null?n:S,X=(a=(o=e.size)!=null?o:w==null?void 0:w.size)!=null?a:C,Z=(c=e.color)!=null?c:Y?"danger":(u=w==null?void 0:w.color)!=null?u:M,te=W({instanceColor:Y?"danger":e.color},h,{color:Z,disabled:J,error:Y,focused:b,size:X,variant:_}),Q=K6e(te),ie=W({},z,{component:U,slots:K,slotProps:j}),[ne,oe]=Fe("root",{ref:t,className:[Q.root,p],elementType:X6e,externalForwardedProps:ie,getSlotProps:g,ownerState:te}),[me,fe]=Fe("textarea",{additionalProps:{id:w==null?void 0:w.htmlFor,"aria-describedby":w==null?void 0:w["aria-describedby"]},className:[Q.textarea,m],elementType:Q6e,internalForwardedProps:W({},f,{minRows:R,maxRows:D}),externalForwardedProps:ie,getSlotProps:y,ownerState:te}),[he,Se]=Fe("startDecorator",{className:Q.startDecorator,elementType:Y6e,externalForwardedProps:ie,ownerState:te}),[ye,ge]=Fe("endDecorator",{className:Q.endDecorator,elementType:Z6e,externalForwardedProps:ie,ownerState:te});return P.jsxs(ne,W({},oe,{children:[N&&P.jsx(he,W({},Se,{children:N})),P.jsx(me,W({},fe)),A&&P.jsx(ye,W({},ge,{children:A}))]}))}),eHe=({smartTrade:d})=>d.entryOrder.status==="Filled"?P.jsx(nn,{color:"danger",variant:"soft",children:"Exiting"}):P.jsx(nn,{color:"success",variant:"soft",children:"Entering"}),tHe=({type:d})=>P.jsx(nn,{color:"neutral",size:"sm",variant:"outlined",children:d}),sHe=({smartTrade:d})=>{const e=d.entryOrder.status==="Filled",t=new Ro(d.entryOrder.price||0).times(d.entryOrder.quantity).toFixed(2).toString(),s=Jl(new Date(d.createdAt).getTime(),!0),{entryOrder:i,takeProfitOrder:n}=d,r=e?n.price:i.price,{baseCurrency:a,quoteCurrency:o}=Kd(d.symbol);return P.jsxs("tr",{tabIndex:-1,children:[P.jsx("th",{scope:"row",children:P.jsx(tHe,{type:d.type})}),P.jsxs("th",{scope:"row",style:{textAlign:"right"},children:[d.entryOrder.quantity," ",a]}),P.jsx("th",{scope:"row",children:P.jsx(In,{title:`Buy ${d.entryOrder.price} / Sell ${d.takeProfitOrder.price}`,children:P.jsxs("span",{children:[r," ",o]})})}),P.jsxs("th",{scope:"row",children:[t," ",o]}),P.jsx("th",{scope:"row",children:P.jsx(eHe,{smartTrade:d})}),P.jsx("th",{scope:"row",children:P.jsxs("div",{children:[P.jsx("span",{children:d.entryOrder.status}),P.jsx("span",{children:" / "}),P.jsx("span",{children:d.takeProfitOrder.status})]})}),P.jsx("th",{scope:"row",style:{textAlign:"right"},children:s}),P.jsx("th",{scope:"row",style:{width:f$,textAlign:"right"},children:P.jsx(In,{title:P.jsxs(_t,{children:[P.jsxs(ot,{children:["SmartTrade ID: ",d.id]}),P.jsxs(ot,{children:["SmartTrade Ref: ",d.ref]})]}),children:P.jsx(ot,{children:d.id})})})]})},iHe=_e("tr")({"&:hover":{backgroundColor:"unset !important"}}),nHe=({placeholder:d})=>P.jsx("tbody",{children:P.jsx(iHe,{children:P.jsx("td",{colSpan:y6e,children:P.jsx(ot,{fontWeight:"400",level:"h4",sx:{py:2},textAlign:"center",children:d||"No trades"})})})}),YB=({botId:d})=>{const[e]=kt.bot.activeSmartTrades.useSuspenseQuery({botId:d});return P.jsx(dg,{sx:{width:"100%",boxShadow:"sm",borderRadius:"sm"},variant:"outlined",children:P.jsxs(_O,{hoverRow:!0,sx:{"--TableCell-headBackground":"transparent","--TableCell-selectedBackground":t=>t.vars.palette.success.softBg,"& thead th:nth-child(1)":{width:"64px"}},children:[P.jsx(w6e,{}),e.length>0?P.jsx("tbody",{children:e.map(t=>P.jsx(sHe,{smartTrade:t},t.id))}):P.jsx(nHe,{placeholder:"No active trades"})]})})},m$=72,g$=64,ZB=10,rHe=100,LF=({children:d})=>P.jsx("thead",{children:P.jsx("tr",{children:P.jsx("td",{colSpan:ZB,style:{backgroundColor:"var(--joy-palette-background-level1)"},children:P.jsx(_t,{sx:{display:"flex",alignItems:"center",gap:1,justifyContent:"center"},children:d})})})});function BF(d){return{entityType:d.entityType,side:d.side===vue.Buy?im.Buy:im.Sell,order:d,trade:d.smartTrade}}const aHe=_e("tr")({"&:hover":{backgroundColor:"unset !important"}}),NF=({placeholder:d})=>P.jsx("tbody",{children:P.jsx(aHe,{children:P.jsx("td",{colSpan:ZB,children:P.jsx(ot,{fontWeight:"400",level:"h4",sx:{py:2},textAlign:"center",children:d||"No orders"})})})}),EF=()=>P.jsx("thead",{children:P.jsxs("tr",{children:[P.jsx("th",{children:"Side"}),P.jsx("th",{style:{width:m$},children:"Type"}),P.jsx("th",{style:{textAlign:"right"},children:"Quantity"}),P.jsx("th",{children:"Price"}),P.jsx("th",{children:"Amount"}),P.jsx("th",{children:"Status"}),P.jsx("th",{children:"PnL"}),P.jsx("th",{style:{textAlign:"right"},children:"Opened"}),P.jsx("th",{style:{textAlign:"right"},children:"Filled"}),P.jsx("th",{style:{textAlign:"right",width:g$},children:"ID"})]})}),oHe=({children:d})=>P.jsx("tfoot",{children:P.jsx("tr",{children:P.jsx("td",{colSpan:ZB,children:P.jsx(_t,{sx:{display:"flex",alignItems:"center",gap:2,justifyContent:"center"},children:d})})})});function dHe(d){switch(d){case"EntryOrder":return"EO";case"TakeProfitOrder":return"TP";case"SafetyOrder":return"SO";case"StopLossOrder":return"SL";default:return"UKN"}}const cHe={EntryOrder:"success",TakeProfitOrder:"danger",SafetyOrder:"warning",StopLossOrder:"neutral"},uHe=({type:d})=>P.jsx(In,{title:d,children:P.jsx(nn,{color:cHe[d],size:"sm",variant:"solid",children:dHe(d)})}),RF=({orderInfo:d,displayEntityType:e})=>{const{order:t,trade:s}=d,{symbol:i}=s,{baseCurrency:n,quoteCurrency:r}=Kd(i),a=new Ro(t.filledPrice||t.price||0).times(t.quantity).toFixed(2).toString(),o=fx(s),c=Jl(t.createdAt.getTime(),!0),u=t.filledAt?Jl(t.filledAt.getTime(),!0):"-";return P.jsxs("tr",{tabIndex:-1,children:[P.jsx("th",{scope:"row",children:P.jsx(ot,{sx:h=>({color:d.side===im.Buy?h.palette.success.outlinedColor:h.palette.danger.outlinedColor}),children:P.jsxs(_t,{display:"flex",alignItems:"center",gap:1,children:[P.jsx("span",{children:d.side===im.Buy?"BUY":"SELL"}),e?P.jsx(uHe,{type:d.entityType}):null]})})}),P.jsx("th",{scope:"row",style:{width:m$},children:t.type}),P.jsxs("th",{scope:"row",style:{textAlign:"right"},children:[t.quantity," ",n]}),P.jsx("th",{scope:"row",children:t.type==="Market"?P.jsx(P.Fragment,{children:t.filledPrice||"-"}):P.jsx(In,{title:P.jsxs(_t,{children:[P.jsxs(ot,{children:["Limit price: ",t.price]}),P.jsxs(ot,{children:["Filled price: ",t.filledPrice]})]}),children:P.jsxs(ot,{children:[t.filledPrice||t.price," ",r]})})}),P.jsxs("th",{scope:"row",children:[a," ",r]}),P.jsx("th",{scope:"row",children:t.status}),P.jsx("th",{scope:"row",children:d.side===im.Sell&&t.status==="Filled"?P.jsx(XB,{profit:o.netProfit,currency:r,size:"sm"}):P.jsx(P.Fragment,{children:"-"})}),P.jsx("th",{scope:"row",style:{textAlign:"right"},children:c}),P.jsx("th",{scope:"row",style:{textAlign:"right"},children:u}),P.jsx("th",{scope:"row",style:{textAlign:"right",width:g$},children:P.jsx(In,{title:P.jsxs(_t,{children:[P.jsxs(ot,{children:["SmartTrade ID: ",t.smartTradeId]}),P.jsxs(ot,{children:["Order ID: ",t.id]}),P.jsxs(ot,{children:["ExchangeOrder ID: ",t.exchangeOrderId]})]}),children:P.jsx(ot,{children:t.smartTradeId})})})]})};function hHe(d){return d.order.status==="Filled"&&!d.order.exchangeOrderId}const JB=({botId:d,filterOrderStatuses:e=[],displayEntityType:t})=>{const[s]=kt.order.openOrders.useSuspenseQuery({botId:d}),i=s.map(BF),[{pages:n},{hasNextPage:r,fetchNextPage:a}]=kt.order.infiniteOrders.useSuspenseInfiniteQuery({botId:d,limit:rHe,statuses:e},{getNextPageParam:c=>c.nextCursor}),o=n.flatMap(c=>c.items).map(BF).filter(c=>!hHe(c));return P.jsx(dg,{sx:{width:"100%",boxShadow:"sm",borderRadius:"sm"},variant:"outlined",children:P.jsxs(_O,{hoverRow:!0,sx:{"--TableCell-headBackground":"transparent","--TableCell-selectedBackground":c=>c.vars.palette.success.softBg,"& thead th:nth-child(1)":{width:t?"88px":"80px"}},children:[P.jsx(LF,{children:P.jsx(ot,{level:"body-sm",fontWeight:700,sx:{textTransform:"uppercase"},color:"neutral",children:"Open orders"})}),P.jsx(EF,{}),i.length>0?P.jsx("tbody",{children:i.map(c=>P.jsx(RF,{orderInfo:c,displayEntityType:t},c.order.id))}):P.jsx(NF,{placeholder:"No open orders"}),P.jsx(LF,{children:P.jsx(ot,{level:"body-sm",fontWeight:700,sx:{textTransform:"uppercase"},color:"neutral",children:"Closed orders"})}),P.jsx(EF,{}),o.length>0?P.jsx("tbody",{children:o.map(c=>P.jsx(RF,{orderInfo:c,displayEntityType:t},c.order.id))}):P.jsx(NF,{placeholder:"No closed orders"}),P.jsx(oHe,{children:P.jsx(Es,{onClick:()=>a(),size:"sm",color:"neutral",variant:"outlined",disabled:!r,children:"Load more"})})]})})},eN=({value:d,onChange:e})=>{const t=s=>P.jsxs(ef,{value:s,children:[P.jsx(qh,{children:P.jsx(vf,{checked:d.includes(s)})}),s]});return P.jsxs(fb,{multiple:!0,defaultValue:d,onChange:(s,i)=>e(i),size:"sm",sx:{minWidth:"13rem"},placeholder:"Any status",children:[t(Jf.Filled),t(Jf.Placed),t(Jf.Canceled),t(Jf.Revoked),t(Jf.Deleted),t(Jf.Idle)]})};function lHe(d){const{botId:e}=d,[t]=go(),[s,i]=B.useState(["Filled"]),[n,r]=B.useState("Orders");return P.jsxs(It,{container:!0,spacing:2,children:[P.jsxs(It,{md:9,children:[P.jsx(B.Suspense,{fallback:P.jsx(mi,{animation:"wave",height:Xo,sx:{borderRadius:8},variant:"rectangular",width:"100%"}),children:P.jsx(t6e,{botId:e})}),P.jsx(_t,{sx:{mt:2}}),P.jsx(B.Suspense,{fallback:P.jsx(mi,{animation:"wave",height:250,sx:{borderRadius:8},variant:"rectangular",width:"100%"}),children:P.jsxs(xL,{value:n,onChange:r,actions:n==="Orders"&&t?P.jsx(eN,{value:s,onChange:i}):null,children:[n==="Orders"?P.jsx(JB,{botId:e,filterOrderStatuses:s}):null,n==="SmartTrades"?P.jsx(YB,{botId:e}):null,n==="StrategyLogs"?P.jsx(OL,{botId:e}):null]})})]}),P.jsxs(It,{md:3,children:[P.jsx(B.Suspense,{fallback:P.jsx(mi,{animation:"wave",height:Xo,sx:{borderRadius:8},variant:"rectangular",width:"100%"}),children:P.jsx(tIe,{botId:e})}),P.jsx(_t,{sx:{mt:2}}),P.jsx(B.Suspense,{fallback:P.jsx(mi,{animation:"wave",height:250,sx:{borderRadius:8},variant:"rectangular",width:"100%"}),children:P.jsx(QB,{botId:e})})]})]})}const y$=vr("/_layout/dashboard/grid-bot/$id")({component:()=>{const{id:d}=y$.useParams();return P.jsx(lHe,{botId:Number(d)})}}),fHe=d=>"value"in d&&d.value!==void 0;function Md(d){const e=fHe(d),[t,s]=B.useState(e?d.value:d.initialValue);return[e?d.value:t,r=>{var a;e?(a=d.onChange)==null||a.call(d,r):s(r)}]}const DF=["Amaranth","Amber","Amethyst","Apricot","Aqua","Aquamarine","Azure","Beige","Black","Blue","Blush","Bronze","Brown","Chocolate","Coffee","Copper","Coral","Crimson","Cyan","Emerald","Fuchsia","Gold","Gray","Green","Harlequin","Indigo","Ivory","Jade","Lavender","Lime","Magenta","Maroon","Moccasin","Olive","Orange","Peach","Pink","Plum","Purple","Red","Rose","Salmon","Sapphire","Scarlet","Silver","Tan","Teal","Tomato","Turquoise","Violet","White","Yellow"],qF=["Ackbar","Adi Gallia","Anakin Skywalker","Arvel Crynyd","Ayla Secura","Bail Prestor Organa","Barriss Offee","Ben Quadinaros","Beru Whitesun lars","Bib Fortuna","Biggs Darklighter","Boba Fett","Bossk","C-3PO","Chewbacca","Cliegg Lars","Cordé","Darth Maul","Darth Vader","Dexter Jettster","Dooku","Dormé","Dud Bolt","Eeth Koth","Finis Valorum","Gasgano","Greedo","Gregar Typho","Grievous","Han Solo","IG-88","Jabba Desilijic Tiure","Jango Fett","Jar Jar Binks","Jek Tono Porkins","Jocasta Nu","Ki-Adi-Mundi","Kit Fisto","Lama Su","Lando Calrissian","Leia Organa","Lobot","Luke Skywalker","Luminara Unduli","Mace Windu","Mas Amedda","Mon Mothma","Nien Nunb","Nute Gunray","Obi-Wan Kenobi","Owen Lars","Padmé Amidala","Palpatine","Plo Koon","Poggle the Lesser","Quarsh Panaka","Qui-Gon Jinn","R2-D2","R4-P17","R5-D4","Ratts Tyerel","Raymus Antilles","Ric Olié","Roos Tarpals","Rugor Nass","Saesee Tiin","San Hill","Sebulba","Shaak Ti","Shmi Skywalker","Sly Moore","Tarfful","Taun We","Tion Medon","Wat Tambor","Watto","Wedge Antilles","Wicket Systri Warrick","Wilhuff Tarkin","Yarael Poof","Yoda","Zam Wesell"];function VF(d){const e=Math.random();return Math.floor(e*d.length)}function tN(){const d=DF[VF(DF)]||"",e=qF[VF(qF)]||"";return`${d} ${e}`}const w$=({value:d,onChange:e,exchangeCode:t})=>P.jsxs(ki,{children:[P.jsx(zi,{children:"Symbol"}),P.jsx(Ab,{exchangeCode:t,onChange:s=>{s&&e(s)},value:d})]}),b$=({value:d,onChange:e})=>P.jsxs(ki,{children:[P.jsx(zi,{children:"Exchange"}),P.jsx(_b,{onChange:t=>{t&&e(t)},value:d})]}),pHe=Ys(P.jsx("path",{d:"M12 5V1L7 6l5 5V7c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6H4c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8"}),"Replay"),k$=({value:d,onChange:e})=>{const t=n=>{e(n.target.value)},s=()=>{e(tN())},i=d.length===0?"Must be defined":null;return P.jsxs(ki,{error:!!i,children:[P.jsx(zi,{children:"Bot name"}),P.jsx(Pn,{endDecorator:P.jsx(Vd,{onClick:s,children:P.jsx(pHe,{})}),onChange:t,value:d}),i?P.jsx(Gm,{children:i}):null]})},S$=({value:d,onChange:e})=>P.jsxs(ki,{children:[P.jsx(zi,{children:"Timeframe"}),P.jsx(wg,{onChange:e,optional:!0,value:d})]}),v$=({checked:d,onChange:e})=>P.jsx(vf,{checked:d,label:"Enabled Logging",onChange:t=>e(t.target.checked)}),FF=d=>{if(d.length===0)throw new Error("Empty symbols array provided");return d.find(t=>t.currencyPair==="BTC/USDT")||d[0]},mHe=d=>{if(d.length===0)throw new Error("Empty exchange accounts array provided");return d[0]},T$=d=>{const{onSubmit:e,isLoading:t,hideTimeframe:s}=d,[i]=go(),[n,r]=Md({value:d.botName,onChange:d.onBotNameChange,initialValue:tN()}),[a,o]=Md({value:d.timeframe,onChange:d.onTimeframeChange,initialValue:mf.ONE_HOUR}),[c,u]=Md({value:d.logging,onChange:d.onLoggingChange,initialValue:!0}),[h]=kt.exchangeAccount.list.useSuspenseQuery(),[l,f]=Md({value:d.exchangeAccount,onChange:d.onExchangeAccountChange,initialValue:mHe(h)}),[p]=kt.symbol.list.useSuspenseQuery(l.exchangeCode),[m,g]=Md({value:d.symbol,onChange:d.onSymbolChange,initialValue:FF(p)});cm(l.exchangeCode)&&g(FF(p));const y=()=>{e({botName:n,exchangeAccountId:l.id,exchangeCode:l.exchangeCode,symbolId:m.symbolId,timeframe:a,logging:c})},w=!n||!l||!m;return P.jsxs(_t,{sx:{display:"grid",flexWrap:1,gap:2},children:[P.jsx(k$,{onChange:r,value:n}),s?null:P.jsx(S$,{onChange:o,value:a}),P.jsx(b$,{onChange:f,value:l}),P.jsx(w$,{exchangeCode:l.exchangeCode,onChange:g,value:m}),i?P.jsx(v$,{checked:c,onChange:u}):null,P.jsx(Es,{color:"primary",disabled:w,loading:t,loadingPosition:"start",onClick:y,size:"lg",variant:"soft",children:"Create a bot"})]})},gHe=d=>{const{defaultBot:e,onSubmit:t,isLoading:s,hideTimeframe:i}=d,[n]=go(),[r,a]=Md({value:d.botName,onChange:d.onBotNameChange,initialValue:e.name}),[o,c]=Md({value:d.timeframe,onChange:d.onTimeframeChange,initialValue:e.timeframe}),[u,h]=Md({value:d.logging,onChange:d.onLoggingChange,initialValue:e.logging}),[l]=kt.exchangeAccount.getOne.useSuspenseQuery(e.exchangeAccountId),[f,p]=Md({value:d.exchangeAccount,onChange:d.onExchangeAccountChange,initialValue:l}),m=ZT(f.exchangeCode,JT(e.symbol),eO(e.symbol)),[g]=kt.symbol.getOne.useSuspenseQuery({symbolId:m}),[y,w]=Md({value:d.symbol,onChange:d.onSymbolChange,initialValue:g});cm(f.exchangeCode)&&w(g);const b=()=>{t({botId:e.id,botName:r,exchangeAccountId:f.id,exchangeCode:f.exchangeCode,symbolId:y.symbolId,timeframe:o,logging:u})},S=!r||!f||!y;return P.jsxs(_t,{sx:{display:"grid",flexWrap:1,gap:2},children:[P.jsx(k$,{onChange:a,value:r}),i?null:P.jsx(S$,{onChange:c,value:o}),P.jsx(b$,{value:f,onChange:p}),P.jsx(w$,{exchangeCode:f.exchangeCode,onChange:w,value:y}),n?P.jsx(v$,{checked:u,onChange:h}):null,P.jsx(Es,{color:"primary",disabled:S,loading:s,loadingPosition:"start",onClick:b,size:"lg",variant:"soft",children:"Update bot"})]})},Zd=()=>Wde(),Gn=zde;function yHe(){const{showSnackbar:d}=Tr(),e=Zc(),t=Gn(fhe),{mutate:s,isLoading:i}=kt.dcaBot.create.useMutation({onSuccess(r){d("Bot created successfully"),setTimeout(()=>{e({to:ai("dca-bot/:id",r.id)})},1e3)}});return{isLoading:i,handleSubmit:()=>{const r=wHe(t);s(r)}}}function wHe(d){const{entryOrderType:e,entryOrderQuantity:t,entryConditions:s,takeProfitPercent:i,safetyOrders:n,symbolId:r,exchangeAccountId:a,botName:o}=d,{currencyPairSymbol:c}=MA(r);return{exchangeAccountId:a,data:{name:o,settings:{entry:{type:e,quantity:Number(t),conditions:s},tp:{percent:i},safetyOrders:n},symbol:c}}}function bHe(d,e){return d.map(s=>e-s.priceDeviation/100*e).map((s,i)=>{const n=d[i].priceDeviation;return gb(s,"yellow",`SO ${n}%`)})}function kHe(d){return gb(d,"blue","Entry")}function SHe(d,e){const t=e+d/100*e;return gb(t,"red","TP")}function O$({entryPrice:d,safetyOrders:e,takeProfitPercent:t}){return B.useMemo(()=>{const s=kHe(d),i=bHe(e,d);return[SHe(t,d),s,...i]},[e,d,t])}const vHe=["1d","4h","1h","5m","1m"],HF=()=>{},THe=({botId:d})=>{const[e]=kt.dcaBot.getOne.useSuspenseQuery(d),[t]=kt.exchangeAccount.getOne.useSuspenseQuery(e.exchangeAccountId),[s]=kt.symbol.getOne.useSuspenseQuery({symbolId:ZT(t.exchangeCode,JT(e.symbol),eO(e.symbol))}),[{price:i}]=kt.symbol.price.useSuspenseQuery({symbolId:s.symbolId}),[n,r]=B.useState("1h"),[a]=kt.smartTrade.list.useSuspenseQuery({botId:d}),o=O$({entryPrice:i,safetyOrders:e.settings.safetyOrders,takeProfitPercent:e.settings.tp.percent}),[c,u]=B.useState(!1),h=B.useMemo(()=>KB(a,n),[a,n]),[l,f]=B.useState(!0);return P.jsx(B.Suspense,{fallback:P.jsx(mi,{animation:"wave",height:Xo,variant:"rectangular",width:"100%"}),children:P.jsxs(hx,{barSize:n,markers:h,priceLines:o,showMarkers:l,showPriceLines:c,symbolId:s.symbolId,children:[P.jsx(_b,{onChange:HF,value:t,disabled:!0}),P.jsx(Ab,{exchangeCode:t.exchangeCode,onChange:HF,value:s,disabled:!0}),P.jsx(wg,{onChange:p=>{r(p)},value:n,whitelist:vHe}),P.jsx(Rc,{}),P.jsx(_t,{display:"flex",children:P.jsx(lx,{gridVisible:c,onGridVisibleChange:u,onTradesVisibleChange:f,tradesVisible:l})})]})})},OHe=({symbolId:d,barSize:e,onBarSizeChange:t,safetyOrders:s,takeProfitPercent:i,currentAssetPrice:n})=>{const r=B.useDeferredValue(d),a=d!==r,o=O$({entryPrice:n,safetyOrders:s,takeProfitPercent:i}),[c,u]=B.useState(!0);return P.jsx(B.Suspense,{fallback:P.jsx(mi,{animation:"wave",height:Xo,variant:"rectangular",width:"100%"}),children:P.jsxs(hx,{barSize:e,dimmed:a,priceLines:o,showPriceLines:c,symbolId:r,children:[P.jsx(wg,{onChange:h=>{t&&t(h)},value:e,whitelist:jue}),P.jsx(Rc,{}),P.jsx(_t,{display:"flex",children:P.jsx(lx,{gridVisible:c,hideTradesButton:!0,onGridVisibleChange:u})})]})})};function x$(d,e){var t={};for(var s in d)Object.prototype.hasOwnProperty.call(d,s)&&e.indexOf(s)<0&&(t[s]=d[s]);if(d!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,s=Object.getOwnPropertySymbols(d);i=a?i=i+GF("0",r-a):i=(i.substring(0,r)||"0")+"."+i.substring(r),t+i}function UF(d,e,t){if(["","-"].indexOf(d)!==-1)return d;var s=(d.indexOf(".")!==-1||t)&&e,i=sN(d),n=i.beforeDecimal,r=i.afterDecimal,a=i.hasNegation,o=parseFloat("0."+(r||"0")),c=r.length<=e?"0."+r:o.toFixed(e),u=c.split("."),h=n;n&&Number(u[0])&&(h=n.split("").reverse().reduce(function(m,g,y){return m.length>y?(Number(m[0])+Number(g)).toString()+m.substring(1,m.length):g+m},u[0]));var l=C$(u[1]||"",e,t),f=a?"-":"",p=s?".":"";return""+f+h+p+l}function wl(d,e){if(d.value=d.value,d!==null){if(d.createTextRange){var t=d.createTextRange();return t.move("character",e),t.select(),!0}return d.selectionStart||d.selectionStart===0?(d.focus(),d.setSelectionRange(e,e),!0):(d.focus(),!1)}}var _$=xHe(function(d,e){for(var t=0,s=0,i=d.length,n=e.length;d[t]===e[t]&&tt&&i-s>t;)s++;return{from:{start:t,end:i-s},to:{start:t,end:n-s}}}),AHe=function(d,e){var t=Math.min(d.selectionStart,e);return{from:{start:t,end:d.selectionEnd},to:{start:t,end:e}}};function LHe(d,e,t){return Math.min(Math.max(d,e),t)}function OC(d){return Math.max(d.selectionStart,d.selectionEnd)}function BHe(){return typeof navigator<"u"&&!(navigator.platform&&/iPhone|iPod/.test(navigator.platform))}function NHe(d){return{from:{start:0,end:0},to:{start:0,end:d.length},lastValue:""}}function EHe(d){var e=d.currentValue,t=d.formattedValue,s=d.currentValueIndex,i=d.formattedValueIndex;return e[s]===t[i]}function RHe(d,e,t,s,i,n,r){r===void 0&&(r=EHe);var a=i.findIndex(function(S){return S}),o=d.slice(0,a);!e&&!t.startsWith(o)&&(e=o,t=o+t,s=s+o.length);for(var c=t.length,u=d.length,h={},l=new Array(c),f=0;f0&&l[y]===-1;)y--;var b=y===-1||l[y]===-1?0:l[y]+1;return b>w?w:s-b=0&&!t[e];)e--;e===-1&&(e=t.indexOf(!0))}else{for(;e<=i&&!t[e];)e++;e>i&&(e=t.lastIndexOf(!0))}return e===-1&&(e=i),e}function DHe(d){for(var e=Array.from({length:d.length+1}).map(function(){return!0}),t=0,s=e.length;tM.length-r.length||CR||h>d.length-r.length)&&(A=h),d=d.substring(0,A),d=HHe(b?"-"+d:d,i),d=(d.match(GHe(p))||[]).join("");var D=d.indexOf(p);d=d.replace(new RegExp(I$(p),"g"),function(J,Y){return Y===D?".":""});var U=sN(d,i),K=U.beforeDecimal,j=U.afterDecimal,z=U.addNegation;return c.end-c.startte?!1:Z>=oe.start&&Z{s({target:{name:e.name,value:r.value}})},...i})});function $He(d){return{decimalScale:d.decimals.amount}}function KHe(d,e){var n,r,a,o,c,u;if(d.length===0)return null;const t=new Ro(d),s=(n=e.limits.amount)!=null&&n.min?t.lt((r=e.limits.amount)==null?void 0:r.min):null,i=(a=e.limits.amount)!=null&&a.max?t.gte((o=e.limits.amount)==null?void 0:o.max):null;return s?`Quantity cannot be lower than MIN: ${(c=e.limits.amount)==null?void 0:c.min}`:i?`Quantity cannot be higher than MAX: ${(u=e.limits.amount)==null?void 0:u.max}`:null}const B$=d=>{const{value:e,onChange:t,filter:s,label:i,...n}=d,r=$He(s),a=KHe(e,s);return P.jsxs(ki,{error:!!a,children:[P.jsx(zi,{children:i}),P.jsx(Pn,{onChange:t,slotProps:{input:{component:L$,NumericFormatProps:r}},value:e,...n}),a?P.jsx(Gm,{children:a}):null]})},N$=d=>{const{state:e,action:t,validate:s,toLocalValue:i,toReduxValue:n,allowEmpty:r=!0}=d;Zd();const[a,o]=B.useState(i(e));return B.useEffect(()=>{o(i(e))},[e]),{reduxValue:e,value:a,onChange:h=>{const{value:l}=h.target;if(r&&l===""){o(l),t(n(l));return}s(l)?(o(l),t(n(l))):o(l)},onBlur:()=>{(!s(a)||!r&&a==="")&&o(i(e))}}},iN=d=>{const{allowEmpty:e}=d;return N$({...d,toLocalValue:QHe,toReduxValue:e?YHe:ZHe,validate:E$,allowEmpty:e})},XHe=d=>{const{allowEmpty:e}=d;return N$({...d,toLocalValue:t=>t.toString(),toReduxValue:t=>t,validate:E$,allowEmpty:e})},QHe=d=>d.toString(),YHe=d=>d===""?"":Number(d),ZHe=d=>Number(d);function E$(d){return/^-?[0-9]+(\.[0-9]+)?$/.test(d)}const JHe=d=>{const{disabled:e,readOnly:t}=d,s=Zd(),i=Gn(tO),[n]=kt.symbol.getOne.useSuspenseQuery({symbolId:i}),{value:r,onChange:a,onBlur:o}=XHe({state:Gn(whe),action:c=>s(nhe(c))});return P.jsx(B$,{disabled:e,filter:n.filters,fullWidth:!0,label:"Entry order quantity",onBlur:o,onChange:a,readOnly:t,required:!0,value:r})},e8e=({value:d,onChange:e,label:t})=>{const s=P.jsx(MW,{value:d,onChange:(i,n)=>{e(n)},children:Object.values(CA).map(i=>P.jsx(Es,{value:i,children:i}))});return t?P.jsxs(ki,{children:[P.jsx(zi,{children:t}),s]}):s},t8e=()=>{const d=Gn(yhe),e=Zd(),t=s=>{s!==null&&e(she(s))};return P.jsx(e8e,{value:d,onChange:t,label:"Entry order type"})};var R$={"¼":"1/4","½":"1/2","¾":"3/4","⅐":"1/7","⅑":"1/9","⅒":"1/10","⅓":"1/3","⅔":"2/3","⅕":"1/5","⅖":"2/5","⅗":"3/5","⅘":"4/5","⅙":"1/6","⅚":"5/6","⅛":"1/8","⅜":"3/8","⅝":"5/8","⅞":"7/8","⅟":"1/"},nN=/^(?=-?\s*\.\d|-?\s*\d)(-)?\s*((?:\d(?:[\d,_]*\d)?)*)(([eE][+-]?\d(?:[\d,_]*\d)?)?|\.\d(?:[\d,_]*\d)?([eE][+-]?\d(?:[\d,_]*\d)?)?|(\s+\d(?:[\d,_]*\d)?\s*)?\s*\/\s*\d(?:[\d,_]*\d)?)?$/,s8e=new RegExp(nN.source.replace(/\$$/,"(?:\\s*[^\\.\\d\\/].*)?")),i8e=new RegExp(`(${Object.keys(R$).join("|")})`),DS={MMM:3e3,MM:2e3,M:1e3,CM:900,DCCC:800,DCC:700,DC:600,D:500,CD:400,CCC:300,CC:200,C:100,XC:90,LXXX:80,LXX:70,LX:60,L:50,XL:40,XXX:30,XX:20,XII:12,XI:11,X:10,IX:9,VIII:8,VII:7,VI:6,V:5,IV:4,III:3,II:2,I:1},D$={"Ⅰ":"I","Ⅱ":"II","Ⅲ":"III","Ⅳ":"IV","Ⅴ":"V","Ⅵ":"VI","Ⅶ":"VII","Ⅷ":"VIII","Ⅸ":"IX","Ⅹ":"X","Ⅺ":"XI","Ⅻ":"XII","Ⅼ":"L","Ⅽ":"C","Ⅾ":"D","Ⅿ":"M","ⅰ":"I","ⅱ":"II","ⅲ":"III","ⅳ":"IV","ⅴ":"V","ⅵ":"VI","ⅶ":"VII","ⅷ":"VIII","ⅸ":"IX","ⅹ":"X","ⅺ":"XI","ⅻ":"XII","ⅼ":"L","ⅽ":"C","ⅾ":"D","ⅿ":"M"},n8e=new RegExp(`(${Object.keys(D$).join("|")})`,"gi"),r8e=/^(?=[MDCLXVI])(M{0,3})(C[MD]|D?C{0,3})(X[CL]|L?X{0,3})(I[XV]|V?I{0,3})$/i,zF={round:3,allowTrailingInvalid:!1,romanNumerals:!1},a8e=d=>{const e=`${d}`.replace(n8e,(a,o)=>D$[o]).toUpperCase(),t=r8e.exec(e);if(!t)return NaN;const[,s,i,n,r]=t;return(DS[s]??0)+(DS[i]??0)+(DS[n]??0)+(DS[r]??0)},o8e=/^\s*\//,d8e=(d,e=zF)=>{if(typeof d=="number"||typeof d=="bigint")return d;let t=NaN;const s=`${d}`.replace(i8e,(l,f)=>` ${R$[f]}`).replace("⁄","/").trim();if(s.length===0)return NaN;const i={...zF,...e},n=(i.allowTrailingInvalid?s8e:nN).exec(s);if(!n)return i.romanNumerals?a8e(s):NaN;const[,r,a,o]=n,c=a.replace(/[,_]/g,""),u=o==null?void 0:o.replace(/[,_]/g,"");if(!c&&u&&u.startsWith(".")?t=0:t=parseInt(c),!u)return r?t*-1:t;const h=i.round===!1?NaN:parseFloat(`1e${Math.floor(Math.max(0,i.round))}`);if(u.startsWith(".")||u.startsWith("e")||u.startsWith("E")){const l=parseFloat(`${t}${u}`);t=isNaN(h)?l:Math.round(l*h)/h}else if(o8e.test(u)){const l=parseInt(c),f=parseInt(u.replace("/",""));t=isNaN(h)?l/f:Math.round(l*h/f)/h}else{const l=u.split("/"),[f,p]=l.map(m=>parseInt(m));t+=isNaN(h)?f/p:Math.round(f*h/p)/h}return r?t*-1:t},rN=B.createContext({}),fc=d=>B.createElement("button",{type:"button","data-testid":d.testID,disabled:d.disabled&&!d.disabledTranslation,className:d.className,title:d.disabledTranslation&&d.disabled?d.disabledTranslation.title:d.title,onClick:e=>d.handleOnClick(e)},d.disabledTranslation&&d.disabled?d.disabledTranslation.label:d.label),c8e=B.forwardRef((d,e)=>B.createElement("span",{"data-testid":d.testID,ref:e,className:d.className,title:d.title},d.label)),q$="~",mx="------",u8e=q$,h8e=mx,l8e=mx,f8e=q$,p8e=mx,m8e=mx,aN=",",V$={fields:{title:"Fields",placeholderName:u8e,placeholderLabel:h8e,placeholderGroupLabel:l8e},operators:{title:"Operators",placeholderName:f8e,placeholderLabel:p8e,placeholderGroupLabel:m8e},value:{title:"Value"},removeRule:{label:"⨯",title:"Remove rule"},removeGroup:{label:"⨯",title:"Remove group"},addRule:{label:"+ Rule",title:"Add rule"},addGroup:{label:"+ Group",title:"Add group"},combinators:{title:"Combinators"},notToggle:{label:"Not",title:"Invert this group"},cloneRule:{label:"⧉",title:"Clone rule"},cloneRuleGroup:{label:"⧉",title:"Clone group"},shiftActionUp:{label:"˄",title:"Shift up"},shiftActionDown:{label:"˅",title:"Shift down"},dragHandle:{label:"⁞⁞",title:"Drag handle"},lockRule:{label:"🔓",title:"Lock rule"},lockGroup:{label:"🔓",title:"Lock group"},lockRuleDisabled:{label:"🔒",title:"Unlock rule"},lockGroupDisabled:{label:"🔒",title:"Unlock group"},valueSourceSelector:{title:"Value source"}},g8e=[{name:"=",value:"=",label:"="},{name:"!=",value:"!=",label:"!="},{name:"<",value:"<",label:"<"},{name:">",value:">",label:">"},{name:"<=",value:"<=",label:"<="},{name:">=",value:">=",label:">="},{name:"contains",value:"contains",label:"contains"},{name:"beginsWith",value:"beginsWith",label:"begins with"},{name:"endsWith",value:"endsWith",label:"ends with"},{name:"doesNotContain",value:"doesNotContain",label:"does not contain"},{name:"doesNotBeginWith",value:"doesNotBeginWith",label:"does not begin with"},{name:"doesNotEndWith",value:"doesNotEndWith",label:"does not end with"},{name:"null",value:"null",label:"is null"},{name:"notNull",value:"notNull",label:"is not null"},{name:"in",value:"in",label:"in"},{name:"notIn",value:"notIn",label:"not in"},{name:"between",value:"between",label:"between"},{name:"notBetween",value:"notBetween",label:"not between"}],gx=[{name:"and",value:"and",label:"AND"},{name:"or",value:"or",label:"OR"}];[...gx];var ps={queryBuilder:"queryBuilder",ruleGroup:"ruleGroup",header:"ruleGroup-header",body:"ruleGroup-body",combinators:"ruleGroup-combinators",addRule:"ruleGroup-addRule",addGroup:"ruleGroup-addGroup",cloneRule:"rule-cloneRule",cloneGroup:"ruleGroup-cloneGroup",removeGroup:"ruleGroup-remove",notToggle:"ruleGroup-notToggle",rule:"rule",fields:"rule-fields",operators:"rule-operators",value:"rule-value",removeRule:"rule-remove",betweenRules:"betweenRules",valid:"queryBuilder-valid",invalid:"queryBuilder-invalid",shiftActions:"shiftActions",dndDragging:"dndDragging",dndOver:"dndOver",dndCopy:"dndCopy",dragHandle:"queryBuilder-dragHandle",disabled:"queryBuilder-disabled",lockRule:"rule-lock",lockGroup:"ruleGroup-lock",valueSource:"rule-valueSource",valueListItem:"rule-value-list-item",branches:"queryBuilder-branches"},y8e={queryBuilder:"",ruleGroup:"",header:"",body:"",combinators:"",addRule:"",addGroup:"",cloneRule:"",cloneGroup:"",removeGroup:"",notToggle:"",rule:"",fields:"",operators:"",value:"",removeRule:"",shiftActions:"",dragHandle:"",lockRule:"",lockGroup:"",valueSource:"",actionElement:"",valueSelector:"",betweenRules:"",valid:"",invalid:"",dndDragging:"",dndOver:"",dndCopy:"",disabled:"",valueListItem:"",branches:""},Ss={rule:"rule",ruleGroup:"rule-group",inlineCombinator:"inline-combinator",addGroup:"add-group",removeGroup:"remove-group",cloneGroup:"clone-group",cloneRule:"clone-rule",addRule:"add-rule",removeRule:"remove-rule",combinators:"combinators",fields:"fields",operators:"operators",valueEditor:"value-editor",notToggle:"not-toggle",shiftActions:"shift-actions",dragHandle:"drag-handle",lockRule:"lock-rule",lockGroup:"lock-group",valueSourceSelector:"value-source-selector"},ur={parentPathDisabled:"action aborted: parent path disabled",pathDisabled:"action aborted: path is disabled",queryUpdate:"query updated",onAddRuleFalse:"onAddRule callback returned false",onAddGroupFalse:"onAddGroup callback returned false",onMoveRuleFalse:"onMoveRule callback returned false",onMoveGroupFalse:"onMoveGroup callback returned false",onRemoveFalse:"onRemove callback returned false",add:"rule or group added",remove:"rule or group removed",update:"rule or group updated",move:"rule or group moved"};function F$(d){let e,t,s="";if(typeof d=="string"||typeof d=="number")s+=d;else if(typeof d=="object")if(Array.isArray(d)){const i=d.length;for(e=0;e{const{component:e,...t}=d,s=Ws(t.schema.suppressStandardClassnames||ps.betweenRules,t.schema.classNames.betweenRules);return B.createElement("div",{className:s,"data-testid":Ss.inlineCombinator},B.createElement(e,{...t,testID:Ss.combinators}))},k8e=d=>B.createElement("label",{"data-testid":d.testID,className:d.className,title:d.title},B.createElement("input",{type:"checkbox",onChange:e=>d.handleOnChange(e.target.checked),checked:!!d.checked,disabled:d.disabled}),d.label),S8e={},yx=XT({name:"queries",initialState:S8e,reducers:{setQueryState:(d,{payload:{qbId:e,query:t}})=>{d[e]=t}},selectors:{getQuerySelectorById:(d,e)=>d[e]}}),Lu={errorInvalidIndependentCombinatorsProp:"QueryBuilder was rendered with a truthy independentCombinators prop. This prop is deprecated and unnecessary. Furthermore, the initial query/defaultQuery prop was of type RuleGroupType instead of type RuleGroupIC. More info: https://react-querybuilder.js.org/docs/components/querybuilder#independent-combinators",errorUnnecessaryIndependentCombinatorsProp:"QueryBuilder was rendered with the deprecated and unnecessary independentCombinators prop. To use independent combinators, make sure the query/defaultQuery prop is of type RuleGroupIC when the component mounts. More info: https://react-querybuilder.js.org/docs/components/querybuilder#independent-combinators",errorDeprecatedRuleGroupProps:"A custom RuleGroup component has rendered a standard RuleGroup component with deprecated props. The combinator, not, and rules props should not be used. Instead, the full group object should be passed as the ruleGroup prop.",errorDeprecatedRuleProps:"A custom RuleGroup component has rendered a standard Rule component with deprecated props. The field, operator, value, and valueSource props should not be used. Instead, the full rule object should be passed as the rule prop.",errorBothQueryDefaultQuery:"QueryBuilder was rendered with both query and defaultQuery props. QueryBuilder must be either controlled or uncontrolled (specify either the query prop, or the defaultQuery prop, but not both). Decide between using a controlled or uncontrolled query builder and remove one of these props. More info: https://reactjs.org/link/controlled-components",errorUncontrolledToControlled:"QueryBuilder is changing from an uncontrolled component to be controlled. This is likely caused by the query changing from undefined to a defined value, which should not happen. Decide between using a controlled or uncontrolled query builder for the lifetime of the component. More info: https://reactjs.org/link/controlled-components",errorControlledToUncontrolled:"QueryBuilder is changing from a controlled component to be uncontrolled. This is likely caused by the query changing from defined to undefined, which should not happen. Decide between using a controlled or uncontrolled query builder for the lifetime of the component. More info: https://reactjs.org/link/controlled-components",errorEnabledDndWithoutReactDnD:"QueryBuilder was rendered with the enableDragAndDrop prop set to true, but either react-dnd or react-dnd-html5-backend (or both) was not installed. To enable drag-and-drop functionality, install both packages and wrap QueryBuilder in QueryBuilderDnD from @react-querybuilder/dnd."},v8e={[Lu.errorInvalidIndependentCombinatorsProp]:!1,[Lu.errorUnnecessaryIndependentCombinatorsProp]:!1,[Lu.errorDeprecatedRuleGroupProps]:!1,[Lu.errorDeprecatedRuleProps]:!1,[Lu.errorBothQueryDefaultQuery]:!1,[Lu.errorUncontrolledToControlled]:!1,[Lu.errorControlledToUncontrolled]:!1,[Lu.errorEnabledDndWithoutReactDnD]:!1},H$=XT({name:"warnings",initialState:v8e,reducers:{rqbWarn:(d,{payload:e})=>{d[e]||(console.error(e),d[e]=!0)}}}),T8e={queries:yx.getInitialState(),warnings:H$.getInitialState()},O8e=N8({reducer:{queries:yx.reducer,warnings:H$.reducer},preloadedState:T8e,middleware:d=>d({serializableCheck:{ignoredActions:["queries/setQueryState"],ignoredPaths:[/^queries\b.*\.rules\.\d+\.value$/]}})}),wx=B.createContext(null),x8e=k8(wx),P8e=(d,e)=>{const t=B.useContext(rN);return x8e(d,e)??(t==null?void 0:t.initialQuery)},fp=d=>e=>yx.selectors.getQuerySelectorById({queries:e.queries},d),xC=({payload:d,onQueryChange:e})=>t=>{t(yx.actions.setQueryState(d)),typeof e=="function"&&e(d.query)},oN=b8(wx),I8e=OA(wx),C8e=d=>{const e=B.useRef({value:d,prev:null}),t=e.current.value;return d!==t&&(e.current={value:d,prev:t}),e.current.prev},M8e=d=>{oN();const{defaultQuery:e,queryProp:t}=d;C8e(!!t)};function dN(d,e,t){oN()}var _8e=(d,e=aN)=>typeof d=="string"?d.split(`\\${e}`).map(t=>t.split(e)).reduce((t,s,i)=>i===0?s:[...t.slice(0,-1),`${t.at(-1)}${e}${s[0]}`,...s.slice(1)],[]):[],cN=(d,e=aN)=>d.map(t=>`${t??""}`.replaceAll(e[0],`\\${e[0]}`)).join(e),A8e=d=>typeof d=="string"?d.trim():d,Jv=(d,{retainEmptyStrings:e}={})=>Array.isArray(d)?d.map(t=>A8e(t)):typeof d=="string"?_8e(d,aN).filter(e?()=>!0:t=>!/^\s*$/.test(t)).map(t=>t.trim()):typeof d=="number"?[d]:[];new RegExp(nN.source.replace(/^\^/,String.raw`^\s*`).replace(/\$$/,String.raw`\s*$`));var _h=d=>d===null||typeof d!="object"?!1:Object.getPrototypeOf(d)===Object.prototype,Cn=d=>_h(d)&&Array.isArray(d.rules),Qm=d=>Cn(d)&&typeof d.combinator=="string",bx=d=>Cn(d)&&d.combinator===void 0,$F=d=>_h(d)&&"name"in d&&typeof d.name=="string",KF=d=>_h(d)&&"value"in d&&typeof d.value=="string";function Yo(d,e){return Gr(s=>{const i={};let n=!!e;if($F(s)&&!KF(s)?(i.value=s.name,n=!0):!$F(s)&&KF(s)&&(i.name=s.value,n=!0),n)return Object.assign({},e,s,i)})(d)}function dl(d,e){return Array.isArray(d)?Gr(s=>{if(ph(s))for(const i of s)for(const[n,r]of i.options.entries())i.options[n]=Yo(r,e);else for(const[i,n]of s.entries())s[i]=Yo(n,e)})(d):[]}function XF(d,e){return Object.fromEntries(Object.entries(d).map(([t,s])=>[t,Yo(s,e)]))}var Q2=d=>{const e=new Set,t=[];for(const s of d)e.has(s.value??s.name)||(e.add(s.value??s.name),t.push(s));return d.length===t.length?d:t},uN=d=>Array.isArray(d)&&d.length>0&&_h(d[0])&&"options"in d[0]&&Array.isArray(d[0].options),ph=d=>{if(Array.isArray(d)){for(const e of d)if(_h(e)&&"options"in e)for(const t of e.options)return!!(_h(t)&&("name"in t||"value"in t))}return!1},G$=(d,e)=>(uN(d)?d.flatMap(t=>t.options):d).find(t=>t.value===e||t.name===e),oo=d=>{if(!Array.isArray(d)||d.length===0)return null;if(ph(d)){for(const e of d)if(e.options.length>0)return e.options[0].value??e.options[0].name;return null}return d[0].value??d[0].name},Y2=d=>{const e=new Set,t=new Set,s=[];for(const i of d)if(!e.has(i.label)){e.add(i.label);const n=[];for(const r of i.options)t.has(r.value??r.name)||(t.add(r.value??r.name),n.push(Yo(r)));s.push({...i,options:n})}return s},L8e=d=>ph(d)?Y2(d):Q2(d.map(e=>Yo(e))),QF=(d,e,t)=>{var n;const s=Yo(d),i=Yo(t);return s.value===i.value?!1:typeof s.comparator=="string"?s[s.comparator]===i[s.comparator]:((n=s.comparator)==null?void 0:n.call(s,i,e))??!1},U$=(d,e,t)=>{if(!d.comparator){const s=i=>(i.value??i.name)!==(d.value??d.name);return ph(e)?e.map(i=>({...i,options:i.options.filter(n=>s(n))})):e.filter(i=>s(i))}return ph(e)?e.map(s=>({...s,options:s.options.filter(i=>QF(d,t,i))})).filter(s=>s.options.length>0):e.filter(s=>QF(d,t,s))},hN=(d,{parseNumbers:e}={})=>{if(!e||typeof d=="bigint"||typeof d=="number")return d;if(e==="native")return parseFloat(d);const t=d8e(d,{allowTrailingInvalid:e==="enhanced",romanNumerals:!1,round:!1});return isNaN(t)?d:t},Dr=(d,e)=>{let t=e,s=0;for(;sd.slice(0,-1),Ym=(d,e)=>d.length===e.length&&d.every((t,s)=>t===e[s]),B8e=(d,e)=>{const t=[],s=wn(d),i=wn(e);let n=0;for(;n{let t=!!e.disabled,s=e,i=0;for(;iYm([],d.path)?"Query builder":`Rule group at path ${d.path.join("-")}`,Sy=globalThis.crypto,Zo=()=>"00-0-4-2-000".replaceAll(/[^-]/g,d=>((Math.random()+Math.trunc(d))*65536>>parseInt(d)).toString(16).padStart(4,"0"));if(Sy){if(typeof Sy.randomUUID=="function")Zo=()=>Sy.randomUUID();else if(typeof Sy.getRandomValues=="function"){const d="89ab",e=new Uint32Array(32);Zo=()=>{Sy.getRandomValues(e);let t=(e[0]%16).toString(16);for(let s=1;s<32;s++)s===12?t=`${t}4`:s===16?t=`${t}${d[e[17]%4]}`:t=`${t}${(e[s]%16).toString(16)}`,(s===7||s===11||s===15||s===19)&&(t=`${t}-`);return t}}}var Qa=d=>B.useCallback((e,t)=>{e==null||e.preventDefault(),e==null||e.stopPropagation(),d(e,t)},[d]),E8e=B.memo(d=>{const e=D8e(d),t=Qa(e.cloneRule),s=Qa(e.toggleLockRule),i=Qa(e.removeRule),n=Qa(e.shiftRuleUp),r=Qa(e.shiftRuleDown);return B.createElement("div",{ref:e.dndRef,"data-testid":Ss.rule,"data-dragmonitorid":e.dragMonitorId,"data-dropmonitorid":e.dropMonitorId,className:e.outerClassName,"data-rule-id":e.id,"data-level":e.path.length,"data-path":JSON.stringify(e.path)},B.createElement(R8e,{...e,cloneRule:t,toggleLockRule:s,removeRule:i,shiftRuleUp:n,shiftRuleDown:r}))}),R8e=B.memo(d=>{const{schema:{controls:{shiftActions:e,dragHandle:t,fieldSelector:s,operatorSelector:i,valueSourceSelector:n,valueEditor:r,cloneRuleAction:a,lockRuleAction:o,removeRuleAction:c}}}=d;return B.createElement(B.Fragment,null,d.schema.showShiftActions&&B.createElement(e,{testID:Ss.shiftActions,level:d.path.length,path:d.path,titles:{shiftUp:d.translations.shiftActionUp.title,shiftDown:d.translations.shiftActionDown.title},labels:{shiftUp:d.translations.shiftActionUp.label,shiftDown:d.translations.shiftActionDown.label},className:d.classNames.shiftActions,disabled:d.disabled,shiftUp:d.shiftRuleUp,shiftDown:d.shiftRuleDown,shiftUpDisabled:d.shiftUpDisabled,shiftDownDisabled:d.shiftDownDisabled,context:d.context,validation:d.validationResult,schema:d.schema,ruleOrGroup:d.rule}),d.schema.enableDragAndDrop&&B.createElement(t,{testID:Ss.dragHandle,ref:d.dragRef,level:d.path.length,path:d.path,title:d.translations.dragHandle.title,label:d.translations.dragHandle.label,className:d.classNames.dragHandle,disabled:d.disabled,context:d.context,validation:d.validationResult,schema:d.schema,ruleOrGroup:d.rule}),B.createElement(s,{testID:Ss.fields,options:d.schema.fields,title:d.translations.fields.title,value:d.rule.field,operator:d.rule.operator,className:d.classNames.fields,handleOnChange:d.generateOnChangeHandler("field"),level:d.path.length,path:d.path,disabled:d.disabled,context:d.context,validation:d.validationResult,schema:d.schema,rule:d.rule}),(d.schema.autoSelectField||d.rule.field!==d.translations.fields.placeholderName)&&B.createElement(B.Fragment,null,B.createElement(i,{testID:Ss.operators,field:d.rule.field,fieldData:d.fieldData,title:d.translations.operators.title,options:d.operators,value:d.rule.operator,className:d.classNames.operators,handleOnChange:d.generateOnChangeHandler("operator"),level:d.path.length,path:d.path,disabled:d.disabled,context:d.context,validation:d.validationResult,schema:d.schema,rule:d.rule}),(d.schema.autoSelectOperator||d.rule.operator!==d.translations.operators.placeholderName)&&!d.hideValueControls&&B.createElement(B.Fragment,null,!["null","notNull"].includes(d.rule.operator)&&d.valueSources.length>1&&B.createElement(n,{testID:Ss.valueSourceSelector,field:d.rule.field,fieldData:d.fieldData,title:d.translations.valueSourceSelector.title,options:d.valueSourceOptions,value:d.rule.valueSource??"value",className:d.classNames.valueSource,handleOnChange:d.generateOnChangeHandler("valueSource"),level:d.path.length,path:d.path,disabled:d.disabled,context:d.context,validation:d.validationResult,schema:d.schema,rule:d.rule}),B.createElement(r,{testID:Ss.valueEditor,field:d.rule.field,fieldData:d.fieldData,title:d.translations.value.title,operator:d.rule.operator,value:d.rule.value,valueSource:d.rule.valueSource??"value",type:d.valueEditorType,inputType:d.inputType,values:d.values,listsAsArrays:d.schema.listsAsArrays,parseNumbers:d.schema.parseNumbers,separator:d.valueEditorSeparator,className:d.classNames.value,handleOnChange:d.generateOnChangeHandler("value"),level:d.path.length,path:d.path,disabled:d.disabled,context:d.context,validation:d.validationResult,schema:d.schema,rule:d.rule}))),d.schema.showCloneButtons&&B.createElement(a,{testID:Ss.cloneRule,label:d.translations.cloneRule.label,title:d.translations.cloneRule.title,className:d.classNames.cloneRule,handleOnClick:d.cloneRule,level:d.path.length,path:d.path,disabled:d.disabled,context:d.context,validation:d.validationResult,ruleOrGroup:d.rule,schema:d.schema}),d.schema.showLockButtons&&B.createElement(o,{testID:Ss.lockRule,label:d.translations.lockRule.label,title:d.translations.lockRule.title,className:d.classNames.lockRule,handleOnClick:d.toggleLockRule,level:d.path.length,path:d.path,disabled:d.disabled,disabledTranslation:d.parentDisabled?void 0:d.translations.lockRuleDisabled,context:d.context,validation:d.validationResult,ruleOrGroup:d.rule,schema:d.schema}),B.createElement(c,{testID:Ss.removeRule,label:d.translations.removeRule.label,title:d.translations.removeRule.title,className:d.classNames.removeRule,handleOnClick:d.removeRule,level:d.path.length,path:d.path,disabled:d.disabled,context:d.context,validation:d.validationResult,ruleOrGroup:d.rule,schema:d.schema}))}),D8e=d=>{const{id:e,path:t,rule:s,schema:{classNames:i,fields:n,fieldMap:r,getInputType:a,getOperators:o,getValueEditorType:c,getValueEditorSeparator:u,getValueSources:h,getValues:l,validationMap:f,enableDragAndDrop:p,getRuleClassname:m,suppressStandardClassnames:g},actions:{moveRule:y,onPropChange:w,onRuleRemove:b},disabled:S,parentDisabled:v,shiftUpDisabled:C,shiftDownDisabled:M,field:_,operator:N,value:A,valueSource:R,dropEffect:D="move",dragMonitorId:U="",dropMonitorId:K="",dndRef:j=null,dragRef:z=null,isDragging:J=!1,isOver:Y=!1}=d;dN();const X=!!v||!!S,Z=B.useMemo(()=>s??{id:e,field:_??"",operator:N??"",value:A,valueSource:R},[_,e,N,s,A,R]),te=B.useMemo(()=>({shiftActions:Ws(g||ps.shiftActions,i.shiftActions),dragHandle:Ws(g||ps.dragHandle,i.dragHandle),fields:Ws(g||ps.fields,i.valueSelector,i.fields),operators:Ws(g||ps.operators,i.valueSelector,i.operators),valueSource:Ws(g||ps.valueSource,i.valueSelector,i.valueSource),value:Ws(g||ps.value,i.value),cloneRule:Ws(g||ps.cloneRule,i.actionElement,i.cloneRule),lockRule:Ws(g||ps.lockRule,i.actionElement,i.lockRule),removeRule:Ws(g||ps.removeRule,i.actionElement,i.removeRule),valueListItem:Ws(g||ps.valueListItem,i.valueListItem)}),[i.shiftActions,i.dragHandle,i.valueSelector,i.fields,i.operators,i.valueSource,i.value,i.actionElement,i.cloneRule,i.lockRule,i.removeRule,i.valueListItem,g]),Q=B.useCallback(ut=>(yt,Bt)=>{X||w(ut,yt,t)},[X,w,t]),ie=B.useCallback(()=>{if(!X){const ut=[...wn(t),t.at(-1)+1];y(t,ut,!0)}},[X,y,t]),ne=B.useCallback((ut,yt)=>{w("disabled",!X,t)},[X,w,t]),oe=B.useCallback((ut,yt)=>{X||b(t)},[X,b,t]),me=B.useCallback((ut,yt)=>{!X&&!C&&y(t,"up",ut==null?void 0:ut.altKey)},[X,y,t,C]),fe=B.useCallback((ut,yt)=>{!X&&!M&&y(t,"down",ut==null?void 0:ut.altKey)},[X,y,t,M]),he=B.useMemo(()=>(r==null?void 0:r[Z.field])??{name:Z.field,value:Z.field,label:Z.field},[r,Z.field]),Se=B.useMemo(()=>he.inputType??a(Z.field,Z.operator,{fieldData:he}),[he,a,Z.field,Z.operator]),ye=B.useMemo(()=>o(Z.field,{fieldData:he}),[he,o,Z.field]),ge=B.useMemo(()=>G$(ye,Z.operator),[ye,Z.operator]),Te=ge==null?void 0:ge.arity,Ge=typeof Te=="string"&&Te==="unary"||typeof Te=="number"&&Te<2,Ye=B.useMemo(()=>typeof he.valueSources=="function"?he.valueSources(Z.operator):he.valueSources??h(Z.field,Z.operator,{fieldData:he}),[he,h,Z.field,Z.operator]),Re=B.useMemo(()=>Z.valueSource==="field"?"select":c(Z.field,Z.operator,{fieldData:he}),[he,c,Z.field,Z.operator,Z.valueSource]),Be=B.useMemo(()=>u(Z.field,Z.operator,{fieldData:he}),[he,u,Z.field,Z.operator]),Me=B.useMemo(()=>Z.valueSource==="field"?U$(he,n,Z.operator):he.values??l(Z.field,Z.operator,{fieldData:he}),[he,n,l,Z.field,Z.operator,Z.valueSource]),Le=B.useMemo(()=>Ye.map(ut=>({name:ut,value:ut,label:ut})),[Ye]),rt=B.useMemo(()=>f[e??""]??(typeof he.validator=="function"?he.validator(Z):null),[he,e,Z,f]),ze=B.useMemo(()=>z$(rt),[rt]),Ue=B.useMemo(()=>(he==null?void 0:he.className)??"",[he==null?void 0:he.className]),Je=B.useMemo(()=>(ge==null?void 0:ge.className)??"",[ge==null?void 0:ge.className]),st=B.useMemo(()=>Ws(m(Z,{fieldData:he}),Ue,Je,g||ps.rule,i.rule,X&&i.disabled,J&&i.dndDragging,Y&&i.dndOver,Y&&D==="copy"&&i.dndCopy,g||{[ps.disabled]:X,[ps.dndDragging]:J,[ps.dndOver]:Y,[ps.dndCopy]:Y&&D==="copy"},ze),[i.disabled,i.dndCopy,i.dndDragging,i.dndOver,i.rule,X,D,Ue,he,m,J,Y,Je,Z,g,ze]);return{...d,classNames:te,cloneRule:ie,disabled:X,dndRef:j,dragMonitorId:U,dragRef:z,dropMonitorId:K,fieldData:he,generateOnChangeHandler:Q,hideValueControls:Ge,inputType:Se,operators:ye,outerClassName:st,removeRule:oe,rule:Z,shiftRuleUp:me,shiftRuleDown:fe,toggleLockRule:ne,validationResult:rt,valueEditorSeparator:Be,valueEditorType:Re,values:Me,valueSourceOptions:Le,valueSources:Ye}},q8e=B.memo(d=>{const e=H8e(d),{schema:{controls:{ruleGroupBodyElements:t,ruleGroupHeaderElements:s}}}=e,i=Qa(e.addRule),n=Qa(e.addGroup),r=Qa(e.cloneGroup),a=Qa(e.toggleLockGroup),o=Qa(e.removeGroup),c=Qa(e.shiftGroupUp),u=Qa(e.shiftGroupDown);return B.createElement("div",{ref:e.previewRef,title:e.accessibleDescription,className:e.outerClassName,"data-testid":Ss.ruleGroup,"data-dragmonitorid":e.dragMonitorId,"data-dropmonitorid":e.dropMonitorId,"data-rule-group-id":e.id,"data-level":e.path.length,"data-path":JSON.stringify(e.path)},B.createElement("div",{ref:e.dropRef,className:e.classNames.header},B.createElement(s,{...e,addRule:i,addGroup:n,cloneGroup:r,toggleLockGroup:a,removeGroup:o,shiftGroupUp:c,shiftGroupDown:u})),B.createElement("div",{className:e.classNames.body},B.createElement(t,{...e,addRule:i,addGroup:n,cloneGroup:r,toggleLockGroup:a,removeGroup:o,shiftGroupUp:c,shiftGroupDown:u})))}),V8e=B.memo(d=>{const{schema:{controls:{shiftActions:e,dragHandle:t,combinatorSelector:s,notToggle:i,addRuleAction:n,addGroupAction:r,cloneGroupAction:a,lockGroupAction:o,removeGroupAction:c}}}=d;return B.createElement(B.Fragment,null,d.schema.showShiftActions&&d.path.length>0&&B.createElement(e,{key:Ss.shiftActions,testID:Ss.shiftActions,level:d.path.length,path:d.path,titles:{shiftUp:d.translations.shiftActionUp.title,shiftDown:d.translations.shiftActionDown.title},labels:{shiftUp:d.translations.shiftActionUp.label,shiftDown:d.translations.shiftActionDown.label},className:d.classNames.shiftActions,disabled:d.disabled,shiftUp:d.shiftGroupUp,shiftDown:d.shiftGroupDown,shiftUpDisabled:d.shiftUpDisabled,shiftDownDisabled:d.shiftDownDisabled,context:d.context,validation:d.validationResult,schema:d.schema,ruleOrGroup:d.ruleGroup}),d.path.length>0&&d.schema.enableDragAndDrop&&B.createElement(t,{key:Ss.dragHandle,testID:Ss.dragHandle,ref:d.dragRef,level:d.path.length,path:d.path,title:d.translations.dragHandle.title,label:d.translations.dragHandle.label,className:d.classNames.dragHandle,disabled:d.disabled,context:d.context,validation:d.validationResult,schema:d.schema,ruleOrGroup:d.ruleGroup}),!d.schema.showCombinatorsBetweenRules&&!d.schema.independentCombinators&&B.createElement(s,{key:Ss.combinators,testID:Ss.combinators,options:d.schema.combinators,value:d.combinator,title:d.translations.combinators.title,className:d.classNames.combinators,handleOnChange:d.onCombinatorChange,rules:d.ruleGroup.rules,level:d.path.length,path:d.path,disabled:d.disabled,context:d.context,validation:d.validationResult,schema:d.schema}),d.schema.showNotToggle&&B.createElement(i,{key:Ss.notToggle,testID:Ss.notToggle,className:d.classNames.notToggle,title:d.translations.notToggle.title,label:d.translations.notToggle.label,checked:d.ruleGroup.not,handleOnChange:d.onNotToggleChange,level:d.path.length,disabled:d.disabled,path:d.path,context:d.context,validation:d.validationResult,schema:d.schema,ruleGroup:d.ruleGroup}),B.createElement(n,{key:Ss.addRule,testID:Ss.addRule,label:d.translations.addRule.label,title:d.translations.addRule.title,className:d.classNames.addRule,handleOnClick:d.addRule,rules:d.ruleGroup.rules,level:d.path.length,path:d.path,disabled:d.disabled,context:d.context,validation:d.validationResult,ruleOrGroup:d.ruleGroup,schema:d.schema}),B.createElement(r,{key:Ss.addGroup,testID:Ss.addGroup,label:d.translations.addGroup.label,title:d.translations.addGroup.title,className:d.classNames.addGroup,handleOnClick:d.addGroup,rules:d.ruleGroup.rules,level:d.path.length,path:d.path,disabled:d.disabled,context:d.context,validation:d.validationResult,ruleOrGroup:d.ruleGroup,schema:d.schema}),d.schema.showCloneButtons&&d.path.length>0&&B.createElement(a,{key:Ss.cloneGroup,testID:Ss.cloneGroup,label:d.translations.cloneRuleGroup.label,title:d.translations.cloneRuleGroup.title,className:d.classNames.cloneGroup,handleOnClick:d.cloneGroup,rules:d.ruleGroup.rules,level:d.path.length,path:d.path,disabled:d.disabled,context:d.context,validation:d.validationResult,ruleOrGroup:d.ruleGroup,schema:d.schema}),d.schema.showLockButtons&&B.createElement(o,{key:Ss.lockGroup,testID:Ss.lockGroup,label:d.translations.lockGroup.label,title:d.translations.lockGroup.title,className:d.classNames.lockGroup,handleOnClick:d.toggleLockGroup,rules:d.ruleGroup.rules,level:d.path.length,path:d.path,disabled:d.disabled,disabledTranslation:d.parentDisabled?void 0:d.translations.lockGroupDisabled,context:d.context,validation:d.validationResult,ruleOrGroup:d.ruleGroup,schema:d.schema}),d.path.length>0&&B.createElement(c,{key:Ss.removeGroup,testID:Ss.removeGroup,label:d.translations.removeGroup.label,title:d.translations.removeGroup.title,className:d.classNames.removeGroup,handleOnClick:d.removeGroup,rules:d.ruleGroup.rules,level:d.path.length,path:d.path,disabled:d.disabled,context:d.context,validation:d.validationResult,ruleOrGroup:d.ruleGroup,schema:d.schema}))}),F8e=B.memo(d=>{const{schema:{controls:{combinatorSelector:e,inlineCombinator:t,ruleGroup:s,rule:i}}}=d;return d.ruleGroup.rules.map((n,r,{length:a})=>{const o=d.pathsMemo[r],c=o.path,u=o.disabled||typeof n!="string"&&n.disabled,h=Ym([0],c),l=d.path.length===0&&r===a-1,f=typeof n=="string"?[...c,n].join("-"):n.id;return B.createElement(B.Fragment,{key:f},r>0&&!d.schema.independentCombinators&&d.schema.showCombinatorsBetweenRules&&B.createElement(t,{key:Ss.inlineCombinator,options:d.schema.combinators,value:d.combinator,title:d.translations.combinators.title,className:d.classNames.combinators,handleOnChange:d.onCombinatorChange,rules:d.ruleGroup.rules,level:d.path.length,context:d.context,validation:d.validationResult,component:e,path:c,disabled:d.disabled,schema:d.schema}),typeof n=="string"?B.createElement(t,{key:`${Ss.inlineCombinator}-independent`,options:d.schema.combinators,value:n,title:d.translations.combinators.title,className:d.classNames.combinators,handleOnChange:p=>d.onIndependentCombinatorChange(p,r),rules:d.ruleGroup.rules,level:d.path.length,context:d.context,validation:d.validationResult,component:e,path:c,disabled:u,schema:d.schema}):Cn(n)?B.createElement(s,{key:Ss.ruleGroup,id:n.id,schema:d.schema,actions:d.actions,path:c,translations:d.translations,ruleGroup:n,rules:n.rules,combinator:Qm(n)?n.combinator:void 0,not:!!n.not,disabled:u,parentDisabled:d.parentDisabled||d.disabled,shiftUpDisabled:h,shiftDownDisabled:l,context:d.context}):B.createElement(i,{key:Ss.rule,id:n.id,rule:n,field:n.field,operator:n.operator,value:n.value,valueSource:n.valueSource,schema:d.schema,actions:d.actions,path:c,disabled:u,parentDisabled:d.parentDisabled||d.disabled,translations:d.translations,shiftUpDisabled:h,shiftDownDisabled:l,context:d.context}))})}),H8e=d=>{const{id:e,path:t,ruleGroup:s,schema:{qbId:i,accessibleDescriptionGenerator:n,classNames:r,combinators:a,createRule:o,createRuleGroup:c,disabledPaths:u,independentCombinators:h,validationMap:l,enableDragAndDrop:f,getRuleGroupClassname:p,suppressStandardClassnames:m},actions:{onGroupAdd:g,onGroupRemove:y,onPropChange:w,onRuleAdd:b,moveRule:S},disabled:v,parentDisabled:C,shiftUpDisabled:M,shiftDownDisabled:_,combinator:N,rules:A,not:R,dropEffect:D="move",dragMonitorId:U="",dropMonitorId:K="",previewRef:j=null,dragRef:z=null,dropRef:J=null,isDragging:Y=!1,isOver:X=!1}=d;dN();const Z=!!C||!!v,te=B.useMemo(()=>s&&Qm(s)?s.combinator:s?oo(a):N??oo(a),[N,a,s]),Q=B.useMemo(()=>{if(s){if(s.combinator===te||h)return s;const Ue=structuredClone(s);return Ue.combinator=te,Ue}return{rules:A,not:R}},[te,h,R,s,A]),ie=B.useMemo(()=>({header:Ws(m||ps.header,r.header,X&&D==="copy"&&r.dndCopy,m||{[ps.dndOver]:X,[ps.dndCopy]:X&&D==="copy"}),shiftActions:Ws(m||ps.shiftActions,r.shiftActions),dragHandle:Ws(m||ps.dragHandle,r.dragHandle),combinators:Ws(m||ps.combinators,r.valueSelector,r.combinators),notToggle:Ws(m||ps.notToggle,r.notToggle),addRule:Ws(m||ps.addRule,r.actionElement,r.addRule),addGroup:Ws(m||ps.addGroup,r.actionElement,r.addGroup),cloneGroup:Ws(m||ps.cloneGroup,r.actionElement,r.cloneGroup),lockGroup:Ws(m||ps.lockGroup,r.actionElement,r.lockGroup),removeGroup:Ws(m||ps.removeGroup,r.actionElement,r.removeGroup),body:Ws(m||ps.body,r.body)}),[r.actionElement,r.addGroup,r.addRule,r.body,r.cloneGroup,r.combinators,r.dndCopy,r.dragHandle,r.header,r.lockGroup,r.notToggle,r.removeGroup,r.shiftActions,r.valueSelector,D,X,m]),ne=B.useCallback(Ue=>{Z||w("combinator",Ue,t)},[Z,w,t]),oe=B.useCallback((Ue,Je,st)=>{Z||w("combinator",Ue,[...t,Je])},[Z,w,t]),me=B.useCallback((Ue,Je)=>{Z||w("not",Ue,t)},[Z,w,t]),fe=B.useCallback((Ue,Je)=>{if(!Z){const st=o();b(st,t,Je)}},[o,Z,b,t]),he=B.useCallback((Ue,Je)=>{if(!Z){const st=c(h);g(st,t,Je)}},[c,Z,h,g,t]),Se=B.useCallback(()=>{if(!Z){const Ue=[...wn(t),t.at(-1)+1];S(t,Ue,!0)}},[Z,S,t]),ye=B.useCallback((Ue,Je)=>{!Z&&!M&&S(t,"up",Ue==null?void 0:Ue.altKey)},[Z,S,t,M]),ge=B.useCallback((Ue,Je)=>{!Z&&!_&&S(t,"down",Ue==null?void 0:Ue.altKey)},[Z,S,t,_]),Te=B.useCallback(()=>{w("disabled",!Z,t)},[Z,w,t]),Ge=B.useCallback(()=>{Z||y(t)},[Z,y,t]),Ye=B.useMemo(()=>l[e??""],[e,l]),Re=B.useMemo(()=>z$(Ye),[Ye]),Be=B.useMemo(()=>{var Ue;return h?null:((Ue=G$(a,te))==null?void 0:Ue.className)??""},[te,a,h]),Me=B.useMemo(()=>p(Q),[p,Q]),Le=B.useMemo(()=>Ws(Me,Be,m||ps.ruleGroup,r.ruleGroup,Z&&r.disabled,Y&&r.dndDragging,m||{[ps.disabled]:Z,[ps.dndDragging]:Y},Re),[r.disabled,r.dndDragging,r.ruleGroup,Be,Z,Y,Me,m,Re]),rt=B.useMemo(()=>{const Ue=[];for(let Je=0;JeYm(st,ut))}}return Ue},[Z,t,Q.rules.length,u]),ze=B.useMemo(()=>n({path:t,qbId:i}),[n,t,i]);return{...d,addGroup:he,addRule:fe,accessibleDescription:ze,classNames:ie,cloneGroup:Se,combinator:te,disabled:Z,dragMonitorId:U,dragRef:z,dropMonitorId:K,dropRef:J,isDragging:Y,isOver:X,onCombinatorChange:ne,onGroupAdd:g,onIndependentCombinatorChange:oe,onNotToggleChange:me,outerClassName:Le,parentDisabled:C,pathsMemo:rt,previewRef:j,removeGroup:Ge,ruleGroup:Q,shiftGroupUp:ye,shiftGroupDown:ge,toggleLockGroup:Te,validationClassName:Re,validationResult:Ye}},G8e=d=>{var e,t,s,i;return B.createElement("div",{"data-testid":d.testID,className:d.className},B.createElement("button",{disabled:d.disabled||d.shiftUpDisabled,onClick:d.shiftUp,title:(e=d.titles)==null?void 0:e.shiftUp},(t=d.labels)==null?void 0:t.shiftUp),B.createElement("button",{disabled:d.disabled||d.shiftDownDisabled,onClick:d.shiftDown,title:(s=d.titles)==null?void 0:s.shiftDown},(i=d.labels)==null?void 0:i.shiftDown))},U8e=d=>{const{operator:e,value:t,handleOnChange:s,title:i,className:n,type:r="text",inputType:a="text",values:o=[],listsAsArrays:c,fieldData:u,disabled:h,separator:l=null,testID:f,selectorComponent:p=d.schema.controls.valueSelector,...m}=d,{valueAsArray:g,multiValueHandler:y,parseNumberMethod:w,valueListItemClassName:b}=W$(d);if(e==="null"||e==="notNull")return null;const S=(u==null?void 0:u.placeholder)??"",v=["in","notIn"].includes(e)?"text":a||"text";if((e==="between"||e==="notBetween")&&(r==="select"||r==="text")){const C=["from","to"].map((M,_)=>r==="text"?B.createElement("input",{key:M,type:v,placeholder:S,value:g[_]??"",className:b,disabled:h,onChange:N=>y(N.target.value,_)}):B.createElement(p,{key:M,...m,schema:d.schema,className:b,handleOnChange:N=>y(N,_),disabled:h,value:g[_]??oo(o),options:o,listsAsArrays:c}));return B.createElement("span",{"data-testid":f,className:n,title:i},C[0],l,C[1])}switch(r){case"select":case"multiselect":return B.createElement(p,{...m,schema:d.schema,testID:f,className:n,title:i,handleOnChange:s,disabled:h,value:t,options:o,multiple:r==="multiselect",listsAsArrays:c});case"textarea":return B.createElement("textarea",{"data-testid":f,placeholder:S,value:t,title:i,className:n,disabled:h,onChange:C=>s(C.target.value)});case"switch":case"checkbox":return B.createElement("input",{"data-testid":f,type:"checkbox",className:n,title:i,onChange:C=>s(C.target.checked),checked:!!t,disabled:h});case"radio":return B.createElement("span",{"data-testid":f,className:n,title:i},o.map(C=>B.createElement("label",{key:C.name},B.createElement("input",{type:"radio",value:C.name,disabled:h,checked:t===C.name,onChange:M=>s(M.target.value)}),C.label)))}return B.createElement("input",{"data-testid":f,type:v,placeholder:S,value:t,title:i,className:n,disabled:h,onChange:C=>s(hN(C.target.value,{parseNumbers:w}))})},W$=d=>{const{handleOnChange:e,inputType:t,operator:s,value:i,listsAsArrays:n,parseNumbers:r,values:a,type:o,skipHook:c,schema:{classNames:u,suppressStandardClassnames:h}}=d;B.useEffect(()=>{!c&&o!=="multiselect"&&!["between","notBetween","in","notIn"].includes(s)&&(Array.isArray(i)||t==="number"&&typeof i=="string"&&i.includes(","))&&e(Jv(i,{retainEmptyStrings:!0})[0]??"")},[e,t,s,c,o,i]);const l=B.useMemo(()=>Jv(i,{retainEmptyStrings:!0}),[i]),f=B.useMemo(()=>{if(typeof r=="string"){const[g,y]=r.split("-");return y==="limited"?t==="number"?g:!1:g}return r?"strict":!1},[t,r]),p=B.useCallback((g,y)=>{const w=Gr(l,b=>{b[y]=hN(g,{parseNumbers:f}),y===0&&(s==="between"||s==="notBetween")&&(b.length<2||b[1]===void 0)&&(b[1]=oo(a))});e(n?w:cN(w,","))},[e,n,s,f,l,a]),m=w8e(h||ps.valueListItem,u==null?void 0:u.valueListItem);return{valueAsArray:l,multiValueHandler:p,parseNumberMethod:f,valueListItemClassName:m}},W8e=d=>{const{multiple:e,onChange:t}=d;return B.useMemo(()=>e?i=>t(Array.from(i.target.selectedOptions).map(n=>n.value)):i=>t(i.target.value),[e,t])},vy=d=>{const{onChange:e,val:t}=j$(d),s=W8e({multiple:d.multiple,onChange:e});return B.createElement("select",{"data-testid":d.testID,className:d.className,value:t,title:d.title,disabled:d.disabled,multiple:!!d.multiple,onChange:s},oGe(d.options))},j$=d=>{const{handleOnChange:e,listsAsArrays:t=!1,multiple:s=!1,value:i}=d,n=B.useCallback(a=>{if(s){const o=Jv(a);e(t?o:cN(o,","))}else e(a)},[e,t,s]),r=B.useMemo(()=>s?Jv(i):i,[s,i]);return{onChange:n,val:r}},qS={actionElement:fc,addGroupAction:fc,addRuleAction:fc,cloneGroupAction:fc,cloneRuleAction:fc,combinatorSelector:vy,dragHandle:c8e,fieldSelector:vy,inlineCombinator:b8e,lockGroupAction:fc,lockRuleAction:fc,notToggle:k8e,operatorSelector:vy,removeGroupAction:fc,removeRuleAction:fc,rule:E8e,ruleGroup:q8e,ruleGroupBodyElements:F8e,ruleGroupHeaderElements:V8e,shiftActions:G8e,valueEditor:U8e,valueSelector:vy,valueSourceSelector:vy},j8e=(d,e)=>d===!1?!1:d?!0:e!==!1,z8e=(d,e)=>d?!0:d===!1?!1:!!e,$8e=(d,e,t)=>d?j8e(e,t):z8e(e,t),PC=(d,e,t)=>$8e(d,e,t),C1=()=>null,K8e=B.forwardRef(C1),pp={},X8e=({finalize:d,...e})=>{var w,b,S,v,C,M,_,N,A,R,D,U,K,j,z,J,Y,X,Z,te,Q,ie,ne,oe,me,fe,he,Se,ye,ge,Te,Ge,Ye,Re,Be,Me,Le,rt,ze,Ue,Je,st,ut,yt,Bt,lt,ht,ft,se,F,V,re,le,ke,Ne,wt,Yt,zt,Et,bt,Ms,ls,Or,An,Rs,Qt,oi,Aa,mn,Xr,sd,La,id,yo,nd,Jd,$t,ms;const t=B.useContext(rN),s=PC(!1,e.debugMode,t.debugMode),i=d?s:e.debugMode??t.debugMode,n=PC(!0,e.enableMountQueryChange,t.enableMountQueryChange),r=d?n:e.enableMountQueryChange??t.enableMountQueryChange,a=PC(!1,e.enableDragAndDrop,t.enableDragAndDrop)&&t.enableDragAndDrop!==!1,o=d?a:e.enableDragAndDrop??t.enableDragAndDrop,c=B.useMemo(()=>J8e(d?Object.assign({},y8e):pp,t.controlClassnames,e.controlClassnames),[t.controlClassnames,e.controlClassnames,d]),u=B.useMemo(()=>({actionElement:c.actionElement,addGroup:c.addGroup,addRule:c.addRule,body:c.body,cloneGroup:c.cloneGroup,cloneRule:c.cloneRule,combinators:c.combinators,dragHandle:c.dragHandle,fields:c.fields,header:c.header,lockGroup:c.lockGroup,lockRule:c.lockRule,notToggle:c.notToggle,operators:c.operators,queryBuilder:c.queryBuilder,removeGroup:c.removeGroup,removeRule:c.removeRule,rule:c.rule,ruleGroup:c.ruleGroup,shiftActions:c.shiftActions,value:c.value,valueSelector:c.valueSelector,valueSource:c.valueSource,betweenRules:c.betweenRules,valid:c.valid,invalid:c.invalid,dndDragging:c.dndDragging,dndOver:c.dndOver,dndCopy:c.dndCopy,disabled:c.disabled,valueListItem:c.valueListItem,branches:c.branches}),[c.actionElement,c.addGroup,c.addRule,c.betweenRules,c.body,c.branches,c.cloneGroup,c.cloneRule,c.combinators,c.disabled,c.dndCopy,c.dndDragging,c.dndOver,c.dragHandle,c.fields,c.header,c.invalid,c.lockGroup,c.lockRule,c.notToggle,c.operators,c.queryBuilder,c.removeGroup,c.removeRule,c.rule,c.ruleGroup,c.shiftActions,c.valid,c.value,c.valueListItem,c.valueSelector,c.valueSource]),h=t.controlElements??pp,l=e.controlElements??pp,f=B.useCallback((ds,Ce,xe)=>{const dt=ds==="dragHandle"?K8e:C1,Ct=(ds.endsWith("Action")&&l.actionElement?l.actionElement:void 0)??(ds.endsWith("Selector")&&l.valueSelector?l.valueSelector:void 0),ns=(ds.endsWith("Action")&&h.actionElement?h.actionElement:void 0)??(ds.endsWith("Selector")&&h.valueSelector?h.valueSelector:void 0),Ts=Ce===null?dt:Ce??(d?Ct:void 0)??(xe===null?dt:xe??(d?ns:void 0));return Ts?{[ds]:Ts}:d?{[ds]:qS[ds]}:pp},[h.actionElement,h.valueSelector,d,l.actionElement,l.valueSelector]),p=B.useMemo(()=>Object.assign({},f("addGroupAction",l.addGroupAction,h.addGroupAction),f("addRuleAction",l.addRuleAction,h.addRuleAction),f("cloneGroupAction",l.cloneGroupAction,h.cloneGroupAction),f("cloneRuleAction",l.cloneRuleAction,h.cloneRuleAction),f("combinatorSelector",l.combinatorSelector,h.combinatorSelector),f("dragHandle",l.dragHandle,h.dragHandle),f("fieldSelector",l.fieldSelector,h.fieldSelector),f("inlineCombinator",l.inlineCombinator,h.inlineCombinator),f("lockGroupAction",l.lockGroupAction,h.lockGroupAction),f("lockRuleAction",l.lockRuleAction,h.lockRuleAction),f("notToggle",l.notToggle,h.notToggle),f("operatorSelector",l.operatorSelector,h.operatorSelector),f("removeGroupAction",l.removeGroupAction,h.removeGroupAction),f("removeRuleAction",l.removeRuleAction,h.removeRuleAction),f("shiftActions",l.shiftActions,h.shiftActions),{valueEditor:l.valueEditor===null?C1:l.valueEditor??(h.valueEditor===null?C1:h.valueEditor)??qS.valueEditor},f("valueSourceSelector",l.valueSourceSelector,h.valueSourceSelector),f("rule",l.rule,h.rule),f("ruleGroup",l.ruleGroup,h.ruleGroup),f("ruleGroupBodyElements",l.ruleGroupBodyElements,h.ruleGroupBodyElements),f("ruleGroupHeaderElements",l.ruleGroupHeaderElements,h.ruleGroupHeaderElements),{actionElement:l.actionElement??h.actionElement??(d?qS.actionElement:void 0)},{valueSelector:l.valueSelector??h.valueSelector??(d?qS.valueSelector:void 0)}),[h.actionElement,h.addGroupAction,h.addRuleAction,h.cloneGroupAction,h.cloneRuleAction,h.combinatorSelector,h.dragHandle,h.fieldSelector,h.inlineCombinator,h.lockGroupAction,h.lockRuleAction,h.notToggle,h.operatorSelector,h.removeGroupAction,h.removeRuleAction,h.rule,h.ruleGroup,h.ruleGroupBodyElements,h.ruleGroupHeaderElements,h.shiftActions,h.valueEditor,h.valueSelector,h.valueSourceSelector,f,d,l.actionElement,l.addGroupAction,l.addRuleAction,l.cloneGroupAction,l.cloneRuleAction,l.combinatorSelector,l.dragHandle,l.fieldSelector,l.inlineCombinator,l.lockGroupAction,l.lockRuleAction,l.notToggle,l.operatorSelector,l.removeGroupAction,l.removeRuleAction,l.rule,l.ruleGroup,l.ruleGroupBodyElements,l.ruleGroupHeaderElements,l.shiftActions,l.valueEditor,l.valueSelector,l.valueSourceSelector]),m=e.translations??pp,g=t.translations??pp,y=B.useMemo(()=>{var ds,Ce,xe,dt,Ct,ns,Ts,Fs,Ln,Ba,Cf,du,Mf,Kh,_f,cu,uu,Ut,Bn,vi,$n,Qr,ec,xr,Pr,Af,Lb,kg,Xh,Sg,Bb,vg,Tg,Lf,Nb,Og,Bf,Nf,tc,xg,Pg,Eb,Ig,Cg,Mg,_g,Rb,Db,qb,Ag,Vb,Fb,Hb,Gb,Ef,Ub,Wb,jb,zb,$b,Zs,Hs,Kb,Xb,Qb,Yb,Zb,Jb,Lg,ek,Ji,Rf,rd,Bg,Df,ar,Ng,Eg;return Object.assign(d?Object.assign({},V$):{},on("addGroup",{label:[(ds=m.addGroup)==null?void 0:ds.label,(Ce=g.addGroup)==null?void 0:Ce.label],title:[(xe=m.addGroup)==null?void 0:xe.title,(dt=g.addGroup)==null?void 0:dt.title]},d),on("addRule",{label:[(Ct=m.addRule)==null?void 0:Ct.label,(ns=g.addRule)==null?void 0:ns.label],title:[(Ts=m.addRule)==null?void 0:Ts.title,(Fs=g.addRule)==null?void 0:Fs.title]},d),on("cloneRule",{label:[(Ln=m.cloneRule)==null?void 0:Ln.label,(Ba=g.cloneRule)==null?void 0:Ba.label],title:[(Cf=m.cloneRule)==null?void 0:Cf.title,(du=g.cloneRule)==null?void 0:du.title]},d),on("cloneRuleGroup",{label:[(Mf=m.cloneRuleGroup)==null?void 0:Mf.label,(Kh=g.cloneRuleGroup)==null?void 0:Kh.label],title:[(_f=m.cloneRuleGroup)==null?void 0:_f.title,(cu=g.cloneRuleGroup)==null?void 0:cu.title]},d),on("combinators",{title:[(uu=m.combinators)==null?void 0:uu.title,(Ut=g.combinators)==null?void 0:Ut.title]},d),on("dragHandle",{label:[(Bn=m.dragHandle)==null?void 0:Bn.label,(vi=g.dragHandle)==null?void 0:vi.label],title:[($n=m.dragHandle)==null?void 0:$n.title,(Qr=g.dragHandle)==null?void 0:Qr.title]},d),on("fields",{placeholderGroupLabel:[(ec=m.fields)==null?void 0:ec.placeholderGroupLabel,(xr=g.fields)==null?void 0:xr.placeholderGroupLabel],placeholderLabel:[(Pr=m.fields)==null?void 0:Pr.placeholderLabel,(Af=g.fields)==null?void 0:Af.placeholderLabel],placeholderName:[(Lb=m.fields)==null?void 0:Lb.placeholderName,(kg=g.fields)==null?void 0:kg.placeholderName],title:[(Xh=m.fields)==null?void 0:Xh.title,(Sg=g.fields)==null?void 0:Sg.title]},d),on("lockGroup",{label:[(Bb=m.lockGroup)==null?void 0:Bb.label,(vg=g.lockGroup)==null?void 0:vg.label],title:[(Tg=m.lockGroup)==null?void 0:Tg.title,(Lf=g.lockGroup)==null?void 0:Lf.title]},d),on("lockGroupDisabled",{label:[(Nb=m.lockGroupDisabled)==null?void 0:Nb.label,(Og=g.lockGroupDisabled)==null?void 0:Og.label],title:[(Bf=m.lockGroupDisabled)==null?void 0:Bf.title,(Nf=g.lockGroupDisabled)==null?void 0:Nf.title]},d),on("lockRule",{label:[(tc=m.lockRule)==null?void 0:tc.label,(xg=g.lockRule)==null?void 0:xg.label],title:[(Pg=m.lockRule)==null?void 0:Pg.title,(Eb=g.lockRule)==null?void 0:Eb.title]},d),on("lockRuleDisabled",{label:[(Ig=m.lockRuleDisabled)==null?void 0:Ig.label,(Cg=g.lockRuleDisabled)==null?void 0:Cg.label],title:[(Mg=m.lockRuleDisabled)==null?void 0:Mg.title,(_g=g.lockRuleDisabled)==null?void 0:_g.title]},d),on("notToggle",{label:[(Rb=m.notToggle)==null?void 0:Rb.label,(Db=g.notToggle)==null?void 0:Db.label],title:[(qb=m.notToggle)==null?void 0:qb.title,(Ag=g.notToggle)==null?void 0:Ag.title]},d),on("operators",{placeholderGroupLabel:[(Vb=m.operators)==null?void 0:Vb.placeholderGroupLabel,(Fb=g.operators)==null?void 0:Fb.placeholderGroupLabel],placeholderLabel:[(Hb=m.operators)==null?void 0:Hb.placeholderLabel,(Gb=g.operators)==null?void 0:Gb.placeholderLabel],placeholderName:[(Ef=m.operators)==null?void 0:Ef.placeholderName,(Ub=g.operators)==null?void 0:Ub.placeholderName],title:[(Wb=m.operators)==null?void 0:Wb.title,(jb=g.operators)==null?void 0:jb.title]},d),on("removeGroup",{label:[(zb=m.removeGroup)==null?void 0:zb.label,($b=g.removeGroup)==null?void 0:$b.label],title:[(Zs=m.removeGroup)==null?void 0:Zs.title,(Hs=g.removeGroup)==null?void 0:Hs.title]},d),on("removeRule",{label:[(Kb=m.removeRule)==null?void 0:Kb.label,(Xb=g.removeRule)==null?void 0:Xb.label],title:[(Qb=m.removeRule)==null?void 0:Qb.title,(Yb=g.removeRule)==null?void 0:Yb.title]},d),on("shiftActionDown",{label:[(Zb=m.shiftActionDown)==null?void 0:Zb.label,(Jb=g.shiftActionDown)==null?void 0:Jb.label],title:[(Lg=m.shiftActionDown)==null?void 0:Lg.title,(ek=g.shiftActionDown)==null?void 0:ek.title]},d),on("shiftActionUp",{label:[(Ji=m.shiftActionUp)==null?void 0:Ji.label,(Rf=g.shiftActionUp)==null?void 0:Rf.label],title:[(rd=m.shiftActionUp)==null?void 0:rd.title,(Bg=g.shiftActionUp)==null?void 0:Bg.title]},d),on("value",{title:[(Df=m.value)==null?void 0:Df.title,(ar=g.value)==null?void 0:ar.title]},d),on("valueSourceSelector",{title:[(Ng=m.valueSourceSelector)==null?void 0:Ng.title,(Eg=g.valueSourceSelector)==null?void 0:Eg.title]},d))},[(w=m.addGroup)==null?void 0:w.label,(b=m.addGroup)==null?void 0:b.title,(S=m.addRule)==null?void 0:S.label,(v=m.addRule)==null?void 0:v.title,(C=m.cloneRule)==null?void 0:C.label,(M=m.cloneRule)==null?void 0:M.title,(_=m.cloneRuleGroup)==null?void 0:_.label,(N=m.cloneRuleGroup)==null?void 0:N.title,(A=m.combinators)==null?void 0:A.title,(R=m.dragHandle)==null?void 0:R.label,(D=m.dragHandle)==null?void 0:D.title,(U=m.fields)==null?void 0:U.placeholderGroupLabel,(K=m.fields)==null?void 0:K.placeholderLabel,(j=m.fields)==null?void 0:j.placeholderName,(z=m.fields)==null?void 0:z.title,(J=m.lockGroup)==null?void 0:J.label,(Y=m.lockGroup)==null?void 0:Y.title,(X=m.lockGroupDisabled)==null?void 0:X.label,(Z=m.lockGroupDisabled)==null?void 0:Z.title,(te=m.lockRule)==null?void 0:te.label,(Q=m.lockRule)==null?void 0:Q.title,(ie=m.lockRuleDisabled)==null?void 0:ie.label,(ne=m.lockRuleDisabled)==null?void 0:ne.title,(oe=m.notToggle)==null?void 0:oe.label,(me=m.notToggle)==null?void 0:me.title,(fe=m.operators)==null?void 0:fe.placeholderGroupLabel,(he=m.operators)==null?void 0:he.placeholderLabel,(Se=m.operators)==null?void 0:Se.placeholderName,(ye=m.operators)==null?void 0:ye.title,(ge=m.removeGroup)==null?void 0:ge.label,(Te=m.removeGroup)==null?void 0:Te.title,(Ge=m.removeRule)==null?void 0:Ge.label,(Ye=m.removeRule)==null?void 0:Ye.title,(Re=m.shiftActionDown)==null?void 0:Re.label,(Be=m.shiftActionDown)==null?void 0:Be.title,(Me=m.shiftActionUp)==null?void 0:Me.label,(Le=m.shiftActionUp)==null?void 0:Le.title,(rt=m.value)==null?void 0:rt.title,(ze=m.valueSourceSelector)==null?void 0:ze.title,d,(Ue=g.addGroup)==null?void 0:Ue.label,(Je=g.addGroup)==null?void 0:Je.title,(st=g.addRule)==null?void 0:st.label,(ut=g.addRule)==null?void 0:ut.title,(yt=g.cloneRule)==null?void 0:yt.label,(Bt=g.cloneRule)==null?void 0:Bt.title,(lt=g.cloneRuleGroup)==null?void 0:lt.label,(ht=g.cloneRuleGroup)==null?void 0:ht.title,(ft=g.combinators)==null?void 0:ft.title,(se=g.dragHandle)==null?void 0:se.label,(F=g.dragHandle)==null?void 0:F.title,(V=g.fields)==null?void 0:V.placeholderGroupLabel,(re=g.fields)==null?void 0:re.placeholderLabel,(le=g.fields)==null?void 0:le.placeholderName,(ke=g.fields)==null?void 0:ke.title,(Ne=g.lockGroup)==null?void 0:Ne.label,(wt=g.lockGroup)==null?void 0:wt.title,(Yt=g.lockGroupDisabled)==null?void 0:Yt.label,(zt=g.lockGroupDisabled)==null?void 0:zt.title,(Et=g.lockRule)==null?void 0:Et.label,(bt=g.lockRule)==null?void 0:bt.title,(Ms=g.lockRuleDisabled)==null?void 0:Ms.label,(ls=g.lockRuleDisabled)==null?void 0:ls.title,(Or=g.notToggle)==null?void 0:Or.label,(An=g.notToggle)==null?void 0:An.title,(Rs=g.operators)==null?void 0:Rs.placeholderGroupLabel,(Qt=g.operators)==null?void 0:Qt.placeholderLabel,(oi=g.operators)==null?void 0:oi.placeholderName,(Aa=g.operators)==null?void 0:Aa.title,(mn=g.removeGroup)==null?void 0:mn.label,(Xr=g.removeGroup)==null?void 0:Xr.title,(sd=g.removeRule)==null?void 0:sd.label,(La=g.removeRule)==null?void 0:La.title,(id=g.shiftActionDown)==null?void 0:id.label,(yo=g.shiftActionDown)==null?void 0:yo.title,(nd=g.shiftActionUp)==null?void 0:nd.label,(Jd=g.shiftActionUp)==null?void 0:Jd.title,($t=g.value)==null?void 0:$t.title,(ms=g.valueSourceSelector)==null?void 0:ms.title]);return{controlClassnames:u,controlElements:p,debugMode:i,enableDragAndDrop:o,enableMountQueryChange:r,translations:y,initialQuery:e.initialQuery,qbId:e.qbId}},z$=d=>{const e=typeof d=="boolean"?d:typeof d=="object"&&d!==null?d.valid:null;return typeof e=="boolean"?e?ps.valid:ps.invalid:""},Q8e=["value"],Y8e={name:"name",value:"name",valueSources:null,label:"label"},Z8e=(d,e,t)=>{const s=d?Yo(d):Y8e;if(s.valueSources)return typeof s.valueSources=="function"?s.valueSources(e):s.valueSources;if(t){const i=t(s.value,e,{fieldData:Yo(s)});if(i)return i}return Q8e},As=(d,e)=>Ws(e.map(t=>Ws(t==null?void 0:t[d]))),J8e=(...d)=>({queryBuilder:As("queryBuilder",d),ruleGroup:As("ruleGroup",d),header:As("header",d),body:As("body",d),combinators:As("combinators",d),addRule:As("addRule",d),addGroup:As("addGroup",d),cloneRule:As("cloneRule",d),cloneGroup:As("cloneGroup",d),removeGroup:As("removeGroup",d),rule:As("rule",d),fields:As("fields",d),operators:As("operators",d),value:As("value",d),removeRule:As("removeRule",d),notToggle:As("notToggle",d),shiftActions:As("shiftActions",d),dragHandle:As("dragHandle",d),lockRule:As("lockRule",d),lockGroup:As("lockGroup",d),valueSource:As("valueSource",d),actionElement:As("actionElement",d),valueSelector:As("valueSelector",d),betweenRules:As("betweenRules",d),valid:As("valid",d),invalid:As("invalid",d),dndDragging:As("dndDragging",d),dndOver:As("dndOver",d),dndCopy:As("dndCopy",d),disabled:As("disabled",d),valueListItem:As("valueListItem",d),branches:As("branches",d)}),eGe=Object.keys,tGe=Object.entries,on=(d,e,t)=>{const s=tGe(e).map(([i,[n,r]])=>{var a;return[i,n??r??((a=(t?V$:{})[d])==null?void 0:a[i])]}).filter(i=>!!i[1]);return s.length>0?{[d]:Object.fromEntries(s)}:void 0},$$=(d,{idGenerator:e=Zo}={})=>Gr(d,t=>{t.id||(t.id=e())}),lN=(d,{idGenerator:e=Zo}={})=>Gr(d,t=>{t.id||(t.id=e()),t.rules=t.rules.map(s=>typeof s=="string"?s:Cn(s)?lN(s,{idGenerator:e}):$$(s,{idGenerator:e}))}),sGe=(d,{idGenerator:e=Zo}={})=>Cn(d)?lN(d,{idGenerator:e}):$$(d,{idGenerator:e}),YF=(d,{idGenerator:e=Zo}={})=>structuredClone({...d,id:e()}),Z2=(d,{idGenerator:e=Zo}={})=>{if(!_h(d))return d;if(!Cn(d))return structuredClone({...d,id:e()});if(Qm(d)){const s=d.rules.map(i=>Cn(i)?Z2(i,{idGenerator:e}):YF(i,{idGenerator:e}));return{...d,id:e(),rules:s}}const t=d.rules.map(s=>typeof s=="string"?s:Cn(s)?Z2(s,{idGenerator:e}):YF(s,{idGenerator:e}));return{...d,id:e(),rules:t}},ZF=(d,e,t,{combinators:s=gx,combinatorPreceding:i,idGenerator:n=Zo}={})=>Gr(d,r=>{const a=Dr(t,r);if(!(!a||!Cn(a))){if(bx(a)&&a.rules.length>0){const o=a.rules.at(-2);a.rules.push(i??(typeof o=="string"?o:oo(s)))}a.rules.push(sGe(e,{idGenerator:n}))}}),iGe=(d,e,t,s,{resetOnFieldChange:i=!0,resetOnOperatorChange:n=!1,getRuleDefaultOperator:r=()=>"=",getValueSources:a=()=>["value"],getRuleDefaultValue:o=()=>""}={})=>Gr(d,c=>{if(e==="combinator"&&!Qm(c)){const m=Dr(wn(s),c).rules;s.at(-1)%2===1&&(m[s.at(-1)]=t);return}const u=Dr(s,c);if(!u)return;const h=Cn(u);if(u[e]===t||(e!=="valueSource"&&(u[e]=t),h))return;let l=!1,f=!1;i&&e==="field"&&(u.operator=r(t),l=!0,f=!0),n&&e==="operator"&&(l=!0,f=!0);const p=a(u.field,u.operator)[0];(l&&u.valueSource&&p!==u.valueSource||e==="valueSource"&&t!==u.valueSource)&&(f=!!u.valueSource||!u.valueSource&&t!==p,u.valueSource=l?p:t),f&&(u.value=o(u))}),nGe=(d,e)=>e.length===0||!Qm(d)&&!Dr(e,d)?d:Gr(d,t=>{const s=e.at(-1),i=Dr(wn(e),t);if(i&&Cn(i))if(!Qm(i)&&i.rules.length>1){const n=s===0?0:s-1;i.rules.splice(n,2)}else i.rules.splice(s,1)}),rGe=(d,e,t)=>{if(Array.isArray(t))return t;const s=bx(d);if(t==="up"){if(Ym(e,[0]))return e;if(e.at(-1)===0){const i=wn(e);return[...wn(i),Math.max(0,i.at(-1)-(s?1:0))]}else{const i=[...wn(e),Math.max(0,e.at(-1)-(s?2:1))],n=Dr(i,d);return Cn(n)?[...i,n.rules.length]:[...wn(e),Math.max(0,e.at(-1)-(s?3:1))]}}else if(t==="down"){if(Ym([d.rules.length-1],e))return e;if(e.at(-1)===Dr(wn(e),d).rules.length-1){const i=wn(e);return[...wn(i),i.at(-1)+1]}else{const i=[...wn(e),e.at(-1)+(s?2:1)],n=Dr(i,d);return Cn(n)?[...i,0]:[...wn(e),e.at(-1)+(s?3:2)]}}return e},aGe=(d,e,t,{clone:s=!1,combinators:i=gx,idGenerator:n=Zo}={})=>{const r=rGe(d,e,t);if(e.length===0||Ym(e,r)||!Dr(wn(r),d))return d;const a=Dr(e,d);if(!a)return d;const o=s?Z2(a,{idGenerator:n}):a;return Gr(d,c=>{const u=bx(c),h=Dr(wn(e),c),l=e.at(-1),f=u&&l>0?h.rules[l-1]:null,p=u&&le[g.length]&&(m[g.length]-=u?2:1);const y=wn(m),w=Dr(y,c),b=m.at(-1),S=(...v)=>w.rules.splice(b,0,...v);if(w.rules.length===0||!u)S(o);else if(b===0)if(l===0&&p)S(o,p);else{const v=w.rules[1]??f??oo(i);S(o,v)}else if(f)S(f,o);else{const v=w.rules[b-2]??p??oo(i);S(v,o)}})},oGe=d=>uN(d)?d.map(e=>B.createElement("optgroup",{key:e.label,label:e.label},e.options.map(t=>B.createElement("option",{key:t.name,value:t.name,disabled:t.disabled},t.label)))):Array.isArray(d)?d.map(e=>B.createElement("option",{key:e.name,value:e.name,disabled:e.disabled},e.label)):null,dGe={},cGe={},uGe=[],hGe={},lGe=()=>null,JF=()=>"",Ty=()=>!0,fGe=(...d)=>{console.log(...d)};function pGe(d,e){const{query:t,defaultQuery:s,getValueEditorSeparator:i=lGe,getRuleClassname:n=JF,getRuleGroupClassname:r=JF,onAddRule:a=Ty,onAddGroup:o=Ty,onMoveRule:c=Ty,onMoveGroup:u=Ty,onRemove:h=Ty,onQueryChange:l,showCombinatorsBetweenRules:f=!1,showNotToggle:p=!1,showShiftActions:m=!1,showCloneButtons:g=!1,showLockButtons:y=!1,suppressStandardClassnames:w=!1,resetOnFieldChange:b=!0,resetOnOperatorChange:S=!1,autoSelectField:v=!0,autoSelectOperator:C=!0,addRuleToNewGroups:M=!1,listsAsArrays:_=!1,parseNumbers:N=!1,disabled:A=!1,validator:R,onLog:D=fGe,idGenerator:U,accessibleDescriptionGenerator:K=N8e}=d,{qbId:j,rqbContext:z,fields:J,fieldMap:Y,combinators:X,getOperatorsMain:Z,getRuleDefaultOperator:te,getValueEditorTypeMain:Q,getValueSourcesMain:ie,getValuesMain:ne,getRuleDefaultValue:oe,getInputTypeMain:me,createRule:fe,createRuleGroup:he}=e,{controlClassnames:Se,controlElements:ye,debugMode:ge,enableDragAndDrop:Te,enableMountQueryChange:Ge,translations:Ye}=z,Re=!!f,Be=!!p,Me=!!m,Le=!!g,rt=!!y,ze=!!b,Ue=!!S,Je=!!v,st=!!C,ut=!!M,yt=!!_,Bt=!!w,lt=B.useCallback((...$t)=>{ge&&D(...$t)},[ge,D]);M8e({defaultQuery:s,queryProp:t});const ht=I8e(),ft=oN(),se=B.useMemo(()=>fp(j),[j]),F=P8e(se),V=B.useCallback(()=>se(ht.getState()),[ht,se]),re=B.useMemo(()=>he(),[he]),le=t??F??s??re,ke=le.id?le:lN(le,{idGenerator:U}),[Ne]=B.useState(ke),wt=B.useMemo(()=>({...z,initialQuery:Ne}),[z,Ne]);B.useEffect(()=>{t&&!Object.is(t,F)&&ft(xC({payload:{qbId:j,query:t},onQueryChange:void 0}))},[t,j,F,ft]);const Yt=B.useMemo(()=>bx(ke),[ke]),zt=!!d.independentCombinators&&!Yt;dN("independentCombinators",zt||!zt&&(d.independentCombinators??"not present")!=="not present");const Et=B.useRef(!1);B.useEffect(()=>{Et.current||(Et.current=!0,ft(xC({payload:{qbId:j,query:ke},onQueryChange:Ge&&typeof l=="function"?l:void 0})))},[Ge,l,j,ft,ke]);const bt=B.useCallback($t=>{ft(xC({payload:{qbId:j,query:$t},onQueryChange:l}))},[l,j,ft]),Ms=B.useMemo(()=>Array.isArray(A)&&A||uGe,[A]),ls=A===!0,Or=B.useMemo(()=>ke.disabled||Ms.some($t=>$t.length===0),[Ms,ke.disabled]),An=B.useCallback(($t,ms,ds)=>{const Ce=fp(j)(ht.getState());if(!Ce)return;if(ky(ms,Ce)||ls){lt({qbId:j,type:ur.parentPathDisabled,rule:$t,parentPath:ms,query:Ce});return}const xe=a($t,ms,Ce,ds);if(!xe){lt({qbId:j,type:ur.onAddRuleFalse,rule:$t,parentPath:ms,query:Ce});return}const dt=xe===!0?$t:xe,Ct=ZF(Ce,dt,ms,{combinators:X,combinatorPreceding:dt.combinatorPreceding??void 0});lt({qbId:j,type:ur.add,query:Ce,newQuery:Ct,newRule:dt,parentPath:ms}),bt(Ct)},[j,ht,ls,a,X,bt,lt]),Rs=B.useCallback(($t,ms,ds)=>{const Ce=fp(j)(ht.getState());if(!Ce)return;if(ky(ms,Ce)||ls){lt({qbId:j,type:ur.parentPathDisabled,ruleGroup:$t,parentPath:ms,query:Ce});return}const xe=o($t,ms,Ce,ds);if(!xe){lt({qbId:j,type:ur.onAddGroupFalse,ruleGroup:$t,parentPath:ms,query:Ce});return}const dt=xe===!0?$t:xe,Ct=ZF(Ce,dt,ms,{combinators:X,combinatorPreceding:dt.combinatorPreceding??void 0});lt({qbId:j,type:ur.add,query:Ce,newQuery:Ct,newGroup:dt,parentPath:ms}),bt(Ct)},[j,ht,ls,o,X,lt,bt]),Qt=B.useCallback(($t,ms,ds)=>{const Ce=fp(j)(ht.getState());if(!Ce)return;if(ky(ds,Ce)&&$t!=="disabled"||ls){lt({qbId:j,type:ur.pathDisabled,path:ds,prop:$t,value:ms,query:Ce});return}const xe=iGe(Ce,$t,ms,ds,{resetOnFieldChange:ze,resetOnOperatorChange:Ue,getRuleDefaultOperator:te,getValueSources:ie,getRuleDefaultValue:oe});lt({qbId:j,type:ur.update,query:Ce,newQuery:xe,prop:$t,value:ms,path:ds}),bt(xe)},[j,ht,ls,ze,Ue,te,ie,oe,lt,bt]),oi=B.useCallback(($t,ms)=>{const ds=fp(j)(ht.getState());if(!ds)return;if(ky($t,ds)||ls){lt({qbId:j,type:ur.pathDisabled,path:$t,query:ds});return}const Ce=Dr($t,ds);if(Ce)if(h(Ce,$t,ds,ms)){const xe=nGe(ds,$t);lt({qbId:j,type:ur.remove,query:ds,newQuery:xe,path:$t,ruleOrGroup:Ce}),bt(xe)}else lt({qbId:j,type:ur.onRemoveFalse,ruleOrGroup:Ce,path:$t,query:ds})},[j,ht,ls,lt,h,bt]),Aa=B.useCallback(($t,ms,ds,Ce)=>{const xe=fp(j)(ht.getState());if(!xe)return;if(ky($t,xe)||ls){lt({qbId:j,type:ur.pathDisabled,oldPath:$t,newPath:ms,query:xe});return}const dt=aGe(xe,$t,ms,{clone:ds,combinators:X}),Ct=Dr($t,xe),ns=Cn(Ct),Ts=(ns?u:c)(Ct,$t,ms,xe,dt,{clone:ds,combinators:X},Ce);if(!Ts){lt({qbId:j,type:ns?ur.onMoveGroupFalse:ur.onMoveRuleFalse,ruleOrGroup:Ct,oldPath:$t,newPath:ms,clone:ds,query:xe,nextQuery:dt});return}const Fs=Cn(Ts)?Ts:dt;lt({qbId:j,type:ur.move,query:xe,newQuery:Fs,oldPath:$t,newPath:ms,clone:ds}),bt(Fs)},[j,ht,ls,X,u,c,lt,bt]),{validationResult:mn,validationMap:Xr}=B.useMemo(()=>{const $t=typeof R=="function"&&ke?R(ke):dGe;return{validationResult:$t,validationMap:typeof $t=="boolean"?cGe:$t}},[ke,R]),sd=B.useMemo(()=>Te?"enabled":"disabled",[Te]),La=B.useMemo(()=>Yt||Re?"enabled":"disabled",[Yt,Re]),id=B.useMemo(()=>typeof ke.combinator=="string"?{combinator:ke.combinator}:hGe,[ke.combinator]),yo=B.useMemo(()=>Ws(Bt||ps.queryBuilder,Ws(Se.queryBuilder),ls&&Se.disabled,typeof mn=="boolean"&&mn&&Se.valid,typeof mn=="boolean"&&!mn&&Se.invalid,Bt||{[ps.disabled]:ls,[ps.valid]:typeof mn=="boolean"&&mn,[ps.invalid]:typeof mn=="boolean"&&!mn}),[Se.disabled,Se.invalid,Se.queryBuilder,Se.valid,ls,Bt,mn]),nd=B.useMemo(()=>({addRuleToNewGroups:ut,accessibleDescriptionGenerator:K,autoSelectField:Je,autoSelectOperator:st,classNames:Se,combinators:X,controls:ye,createRule:fe,createRuleGroup:he,disabledPaths:Ms,enableDragAndDrop:Te,fieldMap:Y,fields:J,dispatchQuery:bt,getQuery:V,getInputType:me,getOperators:Z,getRuleClassname:n,getRuleGroupClassname:r,getValueEditorSeparator:i,getValueEditorType:Q,getValues:ne,getValueSources:ie,independentCombinators:Yt,listsAsArrays:yt,parseNumbers:N,qbId:j,showCloneButtons:Le,showCombinatorsBetweenRules:Re,showLockButtons:rt,showNotToggle:Be,showShiftActions:Me,suppressStandardClassnames:Bt,validationMap:Xr}),[K,ut,Je,st,X,Se,ye,fe,he,Ms,bt,Te,Y,J,me,Z,V,n,r,i,Q,ne,ie,Yt,yt,N,j,Le,Re,rt,Be,Me,Bt,Xr]);return{actions:B.useMemo(()=>({moveRule:Aa,onGroupAdd:Rs,onGroupRemove:oi,onPropChange:Qt,onRuleAdd:An,onRuleRemove:oi}),[Aa,Rs,Qt,An,oi]),rootGroup:ke,rootGroupDisabled:Or,queryDisabled:ls,rqbContext:wt,schema:nd,translations:Ye,wrapperClassName:yo,dndEnabledAttr:sd,inlineCombinatorsAttr:La,combinatorPropObject:id}}var e4=(d,e,t)=>{const s=oo(d);if(e.operator==="between"||e.operator==="notBetween"){const i=[s,s];return t?i:cN(i.map(n=>n??""),",")}return s},mGe=d=>{const[e]=B.useState(Zo),{fields:t,baseField:s,operators:i,baseOperator:n,combinators:r=gx,baseCombinator:a,translations:o,enableMountQueryChange:c=!0,controlClassnames:u,controlElements:h,getDefaultField:l,getDefaultOperator:f,getDefaultValue:p,getOperators:m,getValueEditorType:g,getValueSources:y,getInputType:w,getValues:b,autoSelectField:S=!0,autoSelectOperator:v=!0,addRuleToNewGroups:C=!1,enableDragAndDrop:M,listsAsArrays:_=!1,debugMode:N=!1,idGenerator:A=Zo}=d,R=i??g8e,[D]=B.useState(d.query??d.defaultQuery),U=X8e({controlClassnames:u,controlElements:h,debugMode:N,enableDragAndDrop:M,enableMountQueryChange:c,translations:o,initialQuery:D,qbId:e,finalize:!0}),{translations:K}=U,j=B.useMemo(()=>({id:K.fields.placeholderName,name:K.fields.placeholderName,value:K.fields.placeholderName,label:K.fields.placeholderLabel}),[K.fields.placeholderLabel,K.fields.placeholderName]),z=B.useMemo(()=>t??[j],[j,t]),J=B.useMemo(()=>{const ye=Array.isArray(z)?dl(z,s):eGe(XF(z,s)).map(ge=>({...z[ge],name:ge,value:ge})).sort((ge,Te)=>ge.label.localeCompare(Te.label));return ph(ye)?Y2(S?ye:[{label:K.fields.placeholderGroupLabel,options:[j]},...ye]):Q2(S?ye:[j,...ye])},[S,s,j,z,K.fields.placeholderGroupLabel]),Y=B.useMemo(()=>{if(!Array.isArray(z)){const ge=XF(z,s);return S?ge:{...ge,[K.fields.placeholderName]:j}}const ye={};if(ph(J))for(const ge of J)for(const Te of ge.options)ye[Te.value??Te.name]=Yo(Te,s);else for(const ge of J)ye[ge.value??ge.name]=Yo(ge,s);return ye},[S,s,j,J,z,K.fields.placeholderName]),X=B.useMemo(()=>dl(r,a),[a,r]),Z=B.useMemo(()=>({id:K.operators.placeholderName,name:K.operators.placeholderName,value:K.operators.placeholderName,label:K.operators.placeholderLabel}),[K.operators.placeholderLabel,K.operators.placeholderName]),te=B.useCallback((ye,{fieldData:ge})=>{let Te=dl(R,n);if(ge!=null&&ge.operators)Te=dl(ge.operators,n);else if(m){const Ge=m(ye,{fieldData:ge});Ge&&(Te=dl(Ge,n))}return v||(Te=ph(Te)?[{label:K.operators.placeholderGroupLabel,options:[Z]},...Te]:[Z,...Te]),L8e(Te)},[v,n,Z,m,R,K.operators.placeholderGroupLabel]),Q=B.useCallback(ye=>{const ge=Y[ye];if(ge!=null&&ge.defaultOperator)return ge.defaultOperator;if(f)return typeof f=="function"?f(ye,{fieldData:ge}):f;const Te=te(ye,{fieldData:ge})??[];return oo(Te)??""},[Y,f,te]),ie=B.useCallback((ye,ge,{fieldData:Te})=>Te.valueEditorType?typeof Te.valueEditorType=="function"?Te.valueEditorType(ge):Te.valueEditorType:(g==null?void 0:g(ye,ge,{fieldData:Te}))??"text",[g]),ne=B.useCallback((ye,ge)=>Z8e(Y[ye],ge,y),[Y,y]),oe=B.useCallback((ye,ge,{fieldData:Te})=>Te!=null&&Te.values?dl(Te.values):b?dl(b(ye,ge,{fieldData:Te})):[],[b]),me=B.useCallback(ye=>{const ge=Y[ye.field]??{};if((ge==null?void 0:ge.defaultValue)!==void 0&&ge.defaultValue!==null)return ge.defaultValue;if(p)return p(ye,{fieldData:ge});let Te="";const Ge=oe(ye.field,ye.operator,{fieldData:ge});if(ye.valueSource==="field"){const Ye=U$(ge,J,ye.operator);Te=Ye.length>0?e4(Ye,ye,_):""}else if(Ge.length>0){const Ye=ie(ye.field,ye.operator,{fieldData:ge});Ye==="multiselect"?Te=_?[]:"":(Ye==="select"||Ye==="radio")&&(Te=e4(Ge,ye,_))}else ie(ye.field,ye.operator,{fieldData:ge})==="checkbox"&&(Te=!1);return Te},[Y,J,p,ie,oe,_]),fe=B.useCallback((ye,ge,{fieldData:Te})=>{if(w){const Ge=w(ye,ge,{fieldData:Te});if(Ge)return Ge}return"text"},[w]),he=B.useCallback(()=>{let ye="";const ge=J;if((ge==null?void 0:ge.length)>0&&ge[0]){const Be=oo(ge);Be&&(ye=Be)}if(l)if(typeof l=="function"){const Be=l(ge);Be&&(ye=Be)}else ye=l;const Te=Q(ye),Ge=ne(ye,Te)[0]??"value",Ye={id:A(),field:ye,operator:Te,valueSource:Ge,value:""},Re=me(Ye);return{...Ye,value:Re}},[J,l,Q,me,ne,A]),Se=B.useCallback(ye=>ye?{id:A(),rules:C?[he()]:[],not:!1}:{id:A(),rules:C?[he()]:[],combinator:oo(X)??"",not:!1},[C,X,he,A]);return{qbId:e,rqbContext:U,fields:J,fieldMap:Y,combinators:X,getOperatorsMain:te,getRuleDefaultOperator:Q,getValueEditorTypeMain:ie,getValueSourcesMain:ne,getValuesMain:oe,getRuleDefaultValue:me,getInputTypeMain:fe,createRule:he,createRuleGroup:Se}},gGe=[],yGe=d=>B.createElement(y8,{context:wx,store:O8e},d.children),wGe=({props:d})=>{const e=kGe(d),t=e.schema.controls.ruleGroup,s=rN;return B.createElement(s.Provider,{key:e.dndEnabledAttr,value:e.rqbContext},B.createElement("div",{role:"form",className:e.wrapperClassName,"data-dnd":e.dndEnabledAttr,"data-inlinecombinators":e.inlineCombinatorsAttr},B.createElement(t,{translations:e.translations,ruleGroup:e.rootGroup,rules:e.rootGroup.rules,...e.combinatorPropObject,not:!!e.rootGroup.not,schema:e.schema,actions:e.actions,id:e.rootGroup.id,path:gGe,disabled:e.rootGroupDisabled,shiftUpDisabled:!0,shiftDownDisabled:!0,parentDisabled:e.queryDisabled,context:d.context})))},bGe=d=>B.createElement(yGe,null,B.createElement(wGe,{props:d})),kGe=d=>pGe(d,mGe(d));const SGe=({className:d,handleOnClick:e,label:t,title:s,disabled:i,disabledTranslation:n,testID:r,path:a,level:o,rules:c,context:u,validation:h,ruleOrGroup:l,schema:f,...p})=>{const m=n&&i?n.label:t;return P.jsx(Es,{variant:"soft",color:"primary",className:d,title:n&&i?n.title:s,size:"sm",disabled:i&&!n,onClick:g=>e(g),...p,children:m})},vGe=d=>{const{field:e,fieldData:t,value:s,handleOnChange:i,className:n,valueSource:r,disabled:a,extraProps:o}=d,c=(t==null?void 0:t.placeholder)??"";return s?P.jsxs(_t,{display:"flex",alignItems:"center",gap:1,children:[P.jsx(Pn,{className:n,sx:{maxWidth:88},placeholder:c,value:s.indicatorValue,disabled:a,onChange:u=>i({...s,indicatorValue:u.target.value}),...o}),P.jsx(ot,{children:"with periods"}),P.jsx(Pn,{className:n,sx:{maxWidth:64},placeholder:"Periods",value:s.periods,disabled:a,onChange:u=>i({...s,periods:u.target.value}),...o}),P.jsx(ot,{children:"on timeframe"}),P.jsx(wg,{value:s.timeframe,onChange:u=>i({...s,timeframe:u})})]}):P.jsx("div",{children:"Missing default indicator value"})},TGe=d=>{const{...e}=d,{field:t,fieldData:s,operator:i,value:n,handleOnChange:r,title:a,className:o,type:c,path:u,level:h,inputType:l,values:f=[],listsAsArrays:p,separator:m,valueSource:g,disabled:y,testID:w,selectorComponent:b=d.schema.controls.valueSelector,extraProps:S,...v}=e,{valueAsArray:C,multiValueHandler:M,parseNumberMethod:_,valueListItemClassName:N}=W$(e);if(i==="null"||i==="notNull")return null;const A=(s==null?void 0:s.placeholder)??"",R=["in","notIn"].includes(i)?"text":l||"text";if(Tue(n))return P.jsx(vGe,{...d});if((i==="between"||i==="notBetween")&&(c==="select"||c==="text")){const D=["from","to"].map((U,K)=>c==="text"?P.jsx(Pn,{type:R,className:N,placeholder:A,value:C[K]??"",disabled:y,onChange:j=>M(j.target.value,K),...S},U):P.jsx(b,{...v,path:u,level:h,className:N,handleOnChange:j=>M(j,K),disabled:y,value:C[K]??oo(f),options:f,listsAsArrays:p},U));return P.jsxs(ki,{"data-testid":w,className:o,title:a,disabled:y,children:[D[0],m,D[1]]})}switch(c){case"select":case"multiselect":return P.jsx(b,{...v,path:u,level:h,className:o,handleOnChange:r,options:f,value:n,disabled:y,title:a,multiple:c==="multiselect",listsAsArrays:p});case"textarea":return P.jsx(Z6e,{value:n,title:a,disabled:y,className:o,placeholder:A,onChange:D=>r(D.target.value),...S});case"switch":return P.jsx(W6e,{checked:!!n,title:a,disabled:y,className:o,onChange:D=>r(D.target.checked),...S});case"checkbox":return P.jsx(vf,{className:o,title:a,onChange:D=>r(D.target.checked),checked:!!n,disabled:y,...S});case"radio":return P.jsx(ki,{className:o,title:a,component:"fieldset",disabled:y,...S,children:P.jsx(B6e,{value:n,onChange:D=>r(D.target.value),children:f.map(D=>P.jsx(C6e,{disabled:y,value:D.name,label:D.label},D.name))})})}return P.jsx(Pn,{type:R,value:n,title:a,disabled:y,className:o,placeholder:A,onChange:D=>r(hN(D.target.value,{parseNumbers:_})),...S})},OGe=(d=[])=>{if(uN(d)){const e=[];for(const t of d)e.push(P.jsx(Er,{children:P.jsx(ot,{level:"body-xs",sx:{textTransform:"uppercase"},children:t.label})}),...t.options.map(s=>P.jsx(ef,{value:s.name,children:s.label},s.name)));return e}return Array.isArray(d)?d.map(e=>{const{name:t,label:s}=e;return P.jsx(ef,{value:t,children:s},t)}):null},xGe=({className:d,handleOnChange:e,options:t,value:s,disabled:i,title:n,multiple:r,listsAsArrays:a,testID:o,rule:c,rules:u,level:h,path:l,context:f,validation:p,operator:m,field:g,fieldData:y,schema:w,defaultValue:b,...S})=>{const{onChange:v,val:C}=j$({handleOnChange:e,listsAsArrays:a,multiple:r,value:s});return P.jsx(ki,{className:d,title:n,disabled:i,children:P.jsx(fb,{value:C,onChange:(M,_)=>v(_),multiple:r,disabled:i,...S,children:OGe(t)})})},PGe=d=>{const e=bde();return P.jsxs(P.Fragment,{children:[P.jsx(p8,{styles:{".queryBuilder":{".ruleGroup-header":{alignItems:"center",display:"flex",gap:8},".ruleGroup":{background:e.palette.background.surface,borderRadius:"var(--Card-radius)",display:"flex",flexDirection:"column",gap:8,".ruleGroup":{padding:".5rem",border:`1px solid ${e.palette.neutral.outlinedBorder}`}},".ruleGroup-body":{display:"flex",flexDirection:"column",gap:8},".rule":{alignItems:"center",display:"flex",gap:8}}}}),P.jsx(bGe,{...d,controlElements:{actionElement:SGe,valueEditor:TGe,valueSelector:xGe}},void 0)]})},IC=[{name:"=",value:"=",label:"="},{name:"!=",value:"!=",label:"!="},{name:"<",value:"<",label:"<"},{name:">",value:">",label:">"},{name:"<=",value:"<=",label:"<="},{name:">=",value:">=",label:">="}],IGe=[{name:"RSI",label:"RSI",operators:IC,defaultValue:U8},{name:"SMA",label:"SMA",operators:IC,defaultValue:Uue},{name:"EMA",label:"EMA",operators:IC,defaultValue:Wue}],CGe=({debug:d})=>{const e=Zd(),t=Gn(bhe);return P.jsxs(P.Fragment,{children:[P.jsx(PGe,{fields:IGe,query:t,onQueryChange:s=>e(ahe(s))}),d?P.jsx(_t,{children:P.jsx("pre",{children:JSON.stringify(t,null,2)})}):null]})},MGe=()=>P.jsxs(fn,{children:[P.jsx(ot,{level:"title-lg",children:"Entry order"}),P.jsx(Ia,{}),P.jsxs(It,{container:!0,spacing:2,children:[P.jsx(It,{md:6,xs:12,children:P.jsx(JHe,{})}),P.jsx(It,{md:6,xs:12,children:P.jsx(t8e,{})})]}),P.jsx(Ia,{}),P.jsx(ot,{level:"title-sm",children:"Entry condition"}),P.jsx(CGe,{})]}),_Ge=d=>{const{disabled:e,readOnly:t}=d,s=Zd(),{value:i,onChange:n,onBlur:r}=iN({state:Gn(z8),action:a=>s(dhe(a)),allowEmpty:!1});return P.jsxs(ki,{children:[P.jsx(zi,{children:"Take profit %"}),P.jsx(Pn,{autoComplete:"off",disabled:e,onBlur:r,onChange:n,readOnly:t,required:!0,value:i})]})},AGe=()=>P.jsxs(fn,{children:[P.jsx(ot,{level:"title-lg",children:"Take profit"}),P.jsx(Ia,{}),P.jsx(It,{container:!0,spacing:2,children:P.jsx(It,{md:6,xs:12,children:P.jsx(_Ge,{})})})]}),LGe=d=>{const{className:e,index:t}=d,s=Zd();return P.jsx(Es,{className:e,color:"danger",onClick:()=>s(uhe(t)),size:"sm",children:"Remove"})};function BGe(d){return{decimalScale:d.decimals.price}}function NGe(d,e){var n,r,a,o,c,u;if(d.length===0)return null;const t=new Ro(d),s=(n=e.limits.price)!=null&&n.min?t.lt((r=e.limits.price)==null?void 0:r.min):null,i=(a=e.limits.price)!=null&&a.max?t.gte((o=e.limits.price)==null?void 0:o.max):null;return s?`Price cannot be lower than MIN: ${(c=e.limits.price)==null?void 0:c.min}`:i?`Price cannot be higher than MAX: ${(u=e.limits.price)==null?void 0:u.max}`:null}const EGe=d=>{const{value:e,onChange:t,filter:s,label:i,...n}=d,r=BGe(s),a=NGe(e,s);return P.jsxs(ki,{error:!!a,children:[P.jsx(zi,{children:i}),P.jsx(Pn,{onChange:t,slotProps:{input:{component:L$,NumericFormatProps:r}},value:e,...n}),a?P.jsx(Gm,{children:a}):null]})},RGe=({className:d,index:e})=>{const t=Zd(),s=Gn(tO),[i]=kt.symbol.getOne.useSuspenseQuery({symbolId:s}),{priceDeviation:n}=Gn(K8(e)),{value:r,onChange:a,onBlur:o}=iN({state:n,action:c=>{c!==""&&t(hhe({index:e,priceDeviation:c}))},allowEmpty:!0});return P.jsx(EGe,{className:d,filter:i.filters,fullWidth:!0,label:"Price deviation %",onBlur:o,onChange:a,size:"sm",value:r})},DGe=d=>{const{className:e,index:t,disabled:s}=d,i=Zd(),n=Gn(tO),[r]=kt.symbol.getOne.useSuspenseQuery({symbolId:n}),{quantity:a}=Gn(K8(t)),{value:o,onChange:c,onBlur:u}=iN({state:a,action:h=>{h!==""&&i(lhe({index:t,quantity:h}))},allowEmpty:!0});return P.jsx(B$,{className:e,disabled:s,filter:r.filters,fullWidth:!0,label:"Quantity",onBlur:u,onChange:c,size:"sm",value:o})},qGe=({index:d})=>P.jsxs(It,{alignItems:"flex-end",container:!0,spacing:2,children:[P.jsx(It,{xs:!0,children:P.jsx(B.Suspense,{fallback:P.jsx(mi,{height:36,variant:"rectangular",width:200}),children:P.jsx(RGe,{index:d})})}),P.jsx(It,{xs:!0,children:P.jsx(B.Suspense,{fallback:P.jsx(mi,{height:36,variant:"rectangular",width:200}),children:P.jsx(DGe,{index:d})})}),P.jsx(It,{xs:"auto",children:P.jsx(LGe,{index:d})})]}),VGe=()=>{const d=Zd(),e=Gn($8),t=e.at(-1),s=()=>{d(bq(t?{priceDeviation:t.priceDeviation+1,quantity:t.quantity}:{priceDeviation:_A,quantity:G8}))};return P.jsxs(It,{container:!0,spacing:2,children:[P.jsx(It,{xs:12,children:e.map((i,n)=>P.jsx(qGe,{index:n},n))}),P.jsx(It,{xs:12,children:P.jsx(Es,{onClick:s,children:"Add"})})]})};function FGe(){const d=B.useRef(!0);return d.current?(d.current=!1,!0):d.current}function HGe(){const[d]=kt.exchangeAccount.list.useSuspenseQuery(),e=d[0],[t]=kt.symbol.list.useSuspenseQuery(e.exchangeCode),s=t.find(r=>r.currencyPair==="BTC/USDT")||t[0],[{price:i}]=kt.symbol.price.useSuspenseQuery({symbolId:s.symbolId}),[{price:n}]=kt.dcaBot.formOptions.useSuspenseQuery({symbolId:s.symbolId});return{exchangeAccount:e,symbol:s,currentAssetPrice:i,price:n}}function GGe(){var g;const d=Zd(),{exchangeAccount:e,symbol:t,currentAssetPrice:s}=HGe();if(FGe()){d($ue(e.id)),d(Xue(e.exchangeCode)),d(Que(t.symbolId)),d(Zue(tN()));const y=(g=t.filters.limits.amount)!=null&&g.min?t.filters.limits.amount.min*10:"";d(ihe(y.toString())),d(the(CA.Market)),d(rhe(W8)),d(ohe(H8)),d(che([{priceDeviation:_A,quantity:y||G8}]))}const n=Gn(ghe),[r]=kt.exchangeAccount.getOne.useSuspenseQuery(n),a=Gn(tO),[o]=kt.symbol.getOne.useSuspenseQuery({symbolId:a}),c=Gn(phe),u=Gn(mhe),h=y=>d(ehe(y)),l=Gn($8),f=Gn(z8),{handleSubmit:p,isLoading:m}=mHe();return P.jsx(It,{container:!0,spacing:2,children:P.jsxs(xO,{children:[P.jsx(It,{md:9,children:P.jsx(vHe,{barSize:u,currentAssetPrice:s,safetyOrders:l,takeProfitPercent:f,onBarSizeChange:h,symbolId:a})}),P.jsxs(It,{md:3,children:[P.jsx(ot,{level:"h2",sx:{mb:1},children:"Bot settings"}),P.jsx(B.Suspense,{fallback:P.jsx(mi,{animation:"wave",height:300,sx:{borderRadius:8},variant:"rectangular",width:"100%"}),children:P.jsx(T$,{hideTimeframe:!0,isLoading:m,onSubmit:p,botName:c,onBotNameChange:y=>d(Jue(y)),exchangeAccount:r,onExchangeAccountChange:({id:y})=>d(Kue(y)),symbol:o,onSymbolChange:({symbolId:y})=>d(Yue(y))})})]}),P.jsx(It,{md:9,children:P.jsxs(_t,{display:"flex",flexDirection:"column",gap:2,children:[P.jsx(MGe,{}),P.jsx(AGe,{}),P.jsxs(fn,{children:[P.jsx(ot,{level:"title-lg",children:"Safety orders"}),P.jsx(Ia,{}),P.jsx(VGe,{})]})]})}),P.jsx(It,{md:3})]})})}const UGe=vr("/_layout/dashboard/dca-bot/create")({component:GGe}),WGe=Ys(P.jsx("path",{d:"M9 18h12v-2H9zM3 6v2h18V6zm6 7h12v-2H9z"}),"Segment"),jGe=({bot:d})=>P.jsxs(Dh,{children:[P.jsx(RL,{bot:d}),P.jsx(fr,{inset:"startContent"}),P.jsx(qL,{bot:d}),P.jsx(fr,{inset:"startContent"}),P.jsxs(Id,{icon:P.jsx(KW,{}),name:"Target TP",children:[d.settings.tp.percent,"%"]}),P.jsx(fr,{inset:"startContent"}),P.jsx(Id,{icon:P.jsx(WGe,{}),name:"Safety orders",children:d.settings.safetyOrders.length}),P.jsx(fr,{inset:"startContent"}),P.jsx(Id,{icon:P.jsx(EL,{}),name:"Template",children:P.jsx(In,{title:P.jsx("pre",{children:JSON.stringify(d.settings,null,2)}),children:P.jsx(nn,{color:"primary",variant:"soft",children:d.template})})})]}),zGe=({botId:d})=>{const[e]=kt.dcaBot.getOne.useSuspenseQuery(d),[t]=go();return P.jsxs(fn,{children:[P.jsxs(_t,{display:"flex",justifyContent:"space-between",children:[P.jsx(ot,{fontSize:"xl2",fontWeight:"xl",level:"h3",children:e.name}),P.jsxs(ot,{color:"neutral",fontSize:"xl2",fontWeight:"xl",level:"h3",children:["#",e.id]})]}),P.jsx(jGe,{bot:e}),P.jsx(NL,{children:P.jsx(AL,{bot:e})}),P.jsxs(ML,{children:[P.jsx(LL,{bot:e,href:ai("dca-bot/edit/:id",e.id)}),P.jsx(BL,{bot:e,redirectPath:ai("bot")}),t?P.jsxs(P.Fragment,{children:[P.jsx(Ia,{children:"Debugging"}),P.jsx(PL,{polling:!1}),P.jsx(_L,{bot:e})]}):null]})]})};function $Ge(d){const{botId:e}=d,[t]=go(),[s,i]=B.useState(["Filled"]),[n,r]=B.useState("Orders");return P.jsxs(It,{container:!0,spacing:2,children:[P.jsxs(It,{md:9,children:[P.jsx(B.Suspense,{fallback:P.jsx(mi,{animation:"wave",height:Xo,sx:{borderRadius:8},variant:"rectangular",width:"100%"}),children:P.jsx(SHe,{botId:e})}),P.jsx(_t,{sx:{mt:2}}),P.jsx(B.Suspense,{fallback:P.jsx(mi,{animation:"wave",height:250,sx:{borderRadius:8},variant:"rectangular",width:"100%"}),children:P.jsxs(xL,{value:n,onChange:r,actions:n==="Orders"&&t?P.jsx(eN,{value:s,onChange:i}):null,children:[n==="Orders"?P.jsx(JB,{botId:e,filterOrderStatuses:s,displayEntityType:!0}):null,n==="SmartTrades"?P.jsx(YB,{botId:e}):null,n==="StrategyLogs"?P.jsx(OL,{botId:e}):null]})})]}),P.jsxs(It,{md:3,children:[P.jsx(B.Suspense,{fallback:P.jsx(mi,{animation:"wave",height:Xo,sx:{borderRadius:8},variant:"rectangular",width:"100%"}),children:P.jsx(zGe,{botId:e})}),P.jsx(_t,{sx:{mt:2}}),P.jsx(B.Suspense,{fallback:P.jsx(mi,{animation:"wave",height:250,sx:{borderRadius:8},variant:"rectangular",width:"100%"}),children:P.jsx(QB,{botId:e})})]})]})}const K$=vr("/_layout/dashboard/dca-bot/$id")({component:()=>{const{id:d}=K$.useParams();return P.jsx($Ge,{botId:Number(d)})}});var eT={exports:{}};/** + `),n=!1),Object.assign(Object.assign({},d),{allowNegative:n})}function $He(d){d=zHe(d),d.decimalSeparator,d.allowedDecimalSeparators,d.thousandsGroupStyle;var e=d.suffix,t=d.allowNegative,s=d.allowLeadingZeros,i=d.onKeyDown;i===void 0&&(i=$u);var n=d.onBlur;n===void 0&&(n=$u);var r=d.thousandSeparator,a=d.decimalScale,o=d.fixedDecimalScale,c=d.prefix;c===void 0&&(c="");var u=d.defaultValue,h=d.value,l=d.valueIsNumericString,f=d.onValueChange,p=x$(d,["decimalSeparator","allowedDecimalSeparators","thousandsGroupStyle","suffix","allowNegative","allowLeadingZeros","onKeyDown","onBlur","thousandSeparator","decimalScale","fixedDecimalScale","prefix","defaultValue","value","valueIsNumericString","onValueChange"]),m=px(d),g=m.decimalSeparator,y=m.allowedDecimalSeparators,w=function(z){return jF(z,d)},b=function(z,J){return WHe(z,J,d)},S=mm(h)?u:h,v=l??UHe(S,c,e);mm(h)?mm(u)||(v=v||typeof u=="number"):v=v||typeof h=="number";var C=function(z){return P$(z)?z:(typeof z=="number"&&(z=M$(z)),v&&typeof a=="number"?UF(z,a,!!o):z)},M=A$(C(h),C(u),!!v,w,b,f),_=M[0],N=_.numAsString,A=_.formattedValue,R=M[1],D=function(z){var J=z.target,Y=z.key,X=J.selectionStart,Z=J.selectionEnd,te=J.value;if(te===void 0&&(te=""),(Y==="Backspace"||Y==="Delete")&&Zte?!1:Z>=oe.start&&Z{s({target:{name:e.name,value:r.value}})},...i})});function XHe(d){return{decimalScale:d.decimals.amount}}function QHe(d,e){var n,r,a,o,c,u;if(d.length===0)return null;const t=new Ro(d),s=(n=e.limits.amount)!=null&&n.min?t.lt((r=e.limits.amount)==null?void 0:r.min):null,i=(a=e.limits.amount)!=null&&a.max?t.gte((o=e.limits.amount)==null?void 0:o.max):null;return s?`Quantity cannot be lower than MIN: ${(c=e.limits.amount)==null?void 0:c.min}`:i?`Quantity cannot be higher than MAX: ${(u=e.limits.amount)==null?void 0:u.max}`:null}const B$=d=>{const{value:e,onChange:t,filter:s,label:i,...n}=d,r=XHe(s),a=QHe(e,s);return P.jsxs(ki,{error:!!a,children:[P.jsx(zi,{children:i}),P.jsx(Pn,{onChange:t,slotProps:{input:{component:L$,NumericFormatProps:r}},value:e,...n}),a?P.jsx(Gm,{children:a}):null]})},N$=d=>{const{state:e,action:t,validate:s,toLocalValue:i,toReduxValue:n,allowEmpty:r=!0}=d;Zd();const[a,o]=B.useState(i(e));return B.useEffect(()=>{o(i(e))},[e]),{reduxValue:e,value:a,onChange:h=>{const{value:l}=h.target;if(r&&l===""){o(l),t(n(l));return}s(l)?(o(l),t(n(l))):o(l)},onBlur:()=>{(!s(a)||!r&&a==="")&&o(i(e))}}},iN=d=>{const{allowEmpty:e}=d;return N$({...d,toLocalValue:ZHe,toReduxValue:e?JHe:e8e,validate:E$,allowEmpty:e})},YHe=d=>{const{allowEmpty:e}=d;return N$({...d,toLocalValue:t=>t.toString(),toReduxValue:t=>t,validate:E$,allowEmpty:e})},ZHe=d=>d.toString(),JHe=d=>d===""?"":Number(d),e8e=d=>Number(d);function E$(d){return/^-?[0-9]+(\.[0-9]+)?$/.test(d)}const t8e=d=>{const{disabled:e,readOnly:t}=d,s=Zd(),i=Gn(tO),[n]=kt.symbol.getOne.useSuspenseQuery({symbolId:i}),{value:r,onChange:a,onBlur:o}=YHe({state:Gn(whe),action:c=>s(nhe(c))});return P.jsx(B$,{disabled:e,filter:n.filters,fullWidth:!0,label:"Entry order quantity",onBlur:o,onChange:a,readOnly:t,required:!0,value:r})},s8e=({value:d,onChange:e,label:t})=>{const s=P.jsx(MW,{value:d,onChange:(i,n)=>{e(n)},children:Object.values(CA).map(i=>P.jsx(Es,{value:i,children:i}))});return t?P.jsxs(ki,{children:[P.jsx(zi,{children:t}),s]}):s},i8e=()=>{const d=Gn(yhe),e=Zd(),t=s=>{s!==null&&e(she(s))};return P.jsx(s8e,{value:d,onChange:t,label:"Entry order type"})};var R$={"¼":"1/4","½":"1/2","¾":"3/4","⅐":"1/7","⅑":"1/9","⅒":"1/10","⅓":"1/3","⅔":"2/3","⅕":"1/5","⅖":"2/5","⅗":"3/5","⅘":"4/5","⅙":"1/6","⅚":"5/6","⅛":"1/8","⅜":"3/8","⅝":"5/8","⅞":"7/8","⅟":"1/"},nN=/^(?=-?\s*\.\d|-?\s*\d)(-)?\s*((?:\d(?:[\d,_]*\d)?)*)(([eE][+-]?\d(?:[\d,_]*\d)?)?|\.\d(?:[\d,_]*\d)?([eE][+-]?\d(?:[\d,_]*\d)?)?|(\s+\d(?:[\d,_]*\d)?\s*)?\s*\/\s*\d(?:[\d,_]*\d)?)?$/,n8e=new RegExp(nN.source.replace(/\$$/,"(?:\\s*[^\\.\\d\\/].*)?")),r8e=new RegExp(`(${Object.keys(R$).join("|")})`),DS={MMM:3e3,MM:2e3,M:1e3,CM:900,DCCC:800,DCC:700,DC:600,D:500,CD:400,CCC:300,CC:200,C:100,XC:90,LXXX:80,LXX:70,LX:60,L:50,XL:40,XXX:30,XX:20,XII:12,XI:11,X:10,IX:9,VIII:8,VII:7,VI:6,V:5,IV:4,III:3,II:2,I:1},D$={"Ⅰ":"I","Ⅱ":"II","Ⅲ":"III","Ⅳ":"IV","Ⅴ":"V","Ⅵ":"VI","Ⅶ":"VII","Ⅷ":"VIII","Ⅸ":"IX","Ⅹ":"X","Ⅺ":"XI","Ⅻ":"XII","Ⅼ":"L","Ⅽ":"C","Ⅾ":"D","Ⅿ":"M","ⅰ":"I","ⅱ":"II","ⅲ":"III","ⅳ":"IV","ⅴ":"V","ⅵ":"VI","ⅶ":"VII","ⅷ":"VIII","ⅸ":"IX","ⅹ":"X","ⅺ":"XI","ⅻ":"XII","ⅼ":"L","ⅽ":"C","ⅾ":"D","ⅿ":"M"},a8e=new RegExp(`(${Object.keys(D$).join("|")})`,"gi"),o8e=/^(?=[MDCLXVI])(M{0,3})(C[MD]|D?C{0,3})(X[CL]|L?X{0,3})(I[XV]|V?I{0,3})$/i,zF={round:3,allowTrailingInvalid:!1,romanNumerals:!1},d8e=d=>{const e=`${d}`.replace(a8e,(a,o)=>D$[o]).toUpperCase(),t=o8e.exec(e);if(!t)return NaN;const[,s,i,n,r]=t;return(DS[s]??0)+(DS[i]??0)+(DS[n]??0)+(DS[r]??0)},c8e=/^\s*\//,u8e=(d,e=zF)=>{if(typeof d=="number"||typeof d=="bigint")return d;let t=NaN;const s=`${d}`.replace(r8e,(l,f)=>` ${R$[f]}`).replace("⁄","/").trim();if(s.length===0)return NaN;const i={...zF,...e},n=(i.allowTrailingInvalid?n8e:nN).exec(s);if(!n)return i.romanNumerals?d8e(s):NaN;const[,r,a,o]=n,c=a.replace(/[,_]/g,""),u=o==null?void 0:o.replace(/[,_]/g,"");if(!c&&u&&u.startsWith(".")?t=0:t=parseInt(c),!u)return r?t*-1:t;const h=i.round===!1?NaN:parseFloat(`1e${Math.floor(Math.max(0,i.round))}`);if(u.startsWith(".")||u.startsWith("e")||u.startsWith("E")){const l=parseFloat(`${t}${u}`);t=isNaN(h)?l:Math.round(l*h)/h}else if(c8e.test(u)){const l=parseInt(c),f=parseInt(u.replace("/",""));t=isNaN(h)?l/f:Math.round(l*h/f)/h}else{const l=u.split("/"),[f,p]=l.map(m=>parseInt(m));t+=isNaN(h)?f/p:Math.round(f*h/p)/h}return r?t*-1:t},rN=B.createContext({}),fc=d=>B.createElement("button",{type:"button","data-testid":d.testID,disabled:d.disabled&&!d.disabledTranslation,className:d.className,title:d.disabledTranslation&&d.disabled?d.disabledTranslation.title:d.title,onClick:e=>d.handleOnClick(e)},d.disabledTranslation&&d.disabled?d.disabledTranslation.label:d.label),h8e=B.forwardRef((d,e)=>B.createElement("span",{"data-testid":d.testID,ref:e,className:d.className,title:d.title},d.label)),q$="~",mx="------",l8e=q$,f8e=mx,p8e=mx,m8e=q$,g8e=mx,y8e=mx,aN=",",V$={fields:{title:"Fields",placeholderName:l8e,placeholderLabel:f8e,placeholderGroupLabel:p8e},operators:{title:"Operators",placeholderName:m8e,placeholderLabel:g8e,placeholderGroupLabel:y8e},value:{title:"Value"},removeRule:{label:"⨯",title:"Remove rule"},removeGroup:{label:"⨯",title:"Remove group"},addRule:{label:"+ Rule",title:"Add rule"},addGroup:{label:"+ Group",title:"Add group"},combinators:{title:"Combinators"},notToggle:{label:"Not",title:"Invert this group"},cloneRule:{label:"⧉",title:"Clone rule"},cloneRuleGroup:{label:"⧉",title:"Clone group"},shiftActionUp:{label:"˄",title:"Shift up"},shiftActionDown:{label:"˅",title:"Shift down"},dragHandle:{label:"⁞⁞",title:"Drag handle"},lockRule:{label:"🔓",title:"Lock rule"},lockGroup:{label:"🔓",title:"Lock group"},lockRuleDisabled:{label:"🔒",title:"Unlock rule"},lockGroupDisabled:{label:"🔒",title:"Unlock group"},valueSourceSelector:{title:"Value source"}},w8e=[{name:"=",value:"=",label:"="},{name:"!=",value:"!=",label:"!="},{name:"<",value:"<",label:"<"},{name:">",value:">",label:">"},{name:"<=",value:"<=",label:"<="},{name:">=",value:">=",label:">="},{name:"contains",value:"contains",label:"contains"},{name:"beginsWith",value:"beginsWith",label:"begins with"},{name:"endsWith",value:"endsWith",label:"ends with"},{name:"doesNotContain",value:"doesNotContain",label:"does not contain"},{name:"doesNotBeginWith",value:"doesNotBeginWith",label:"does not begin with"},{name:"doesNotEndWith",value:"doesNotEndWith",label:"does not end with"},{name:"null",value:"null",label:"is null"},{name:"notNull",value:"notNull",label:"is not null"},{name:"in",value:"in",label:"in"},{name:"notIn",value:"notIn",label:"not in"},{name:"between",value:"between",label:"between"},{name:"notBetween",value:"notBetween",label:"not between"}],gx=[{name:"and",value:"and",label:"AND"},{name:"or",value:"or",label:"OR"}];[...gx];var ps={queryBuilder:"queryBuilder",ruleGroup:"ruleGroup",header:"ruleGroup-header",body:"ruleGroup-body",combinators:"ruleGroup-combinators",addRule:"ruleGroup-addRule",addGroup:"ruleGroup-addGroup",cloneRule:"rule-cloneRule",cloneGroup:"ruleGroup-cloneGroup",removeGroup:"ruleGroup-remove",notToggle:"ruleGroup-notToggle",rule:"rule",fields:"rule-fields",operators:"rule-operators",value:"rule-value",removeRule:"rule-remove",betweenRules:"betweenRules",valid:"queryBuilder-valid",invalid:"queryBuilder-invalid",shiftActions:"shiftActions",dndDragging:"dndDragging",dndOver:"dndOver",dndCopy:"dndCopy",dragHandle:"queryBuilder-dragHandle",disabled:"queryBuilder-disabled",lockRule:"rule-lock",lockGroup:"ruleGroup-lock",valueSource:"rule-valueSource",valueListItem:"rule-value-list-item",branches:"queryBuilder-branches"},b8e={queryBuilder:"",ruleGroup:"",header:"",body:"",combinators:"",addRule:"",addGroup:"",cloneRule:"",cloneGroup:"",removeGroup:"",notToggle:"",rule:"",fields:"",operators:"",value:"",removeRule:"",shiftActions:"",dragHandle:"",lockRule:"",lockGroup:"",valueSource:"",actionElement:"",valueSelector:"",betweenRules:"",valid:"",invalid:"",dndDragging:"",dndOver:"",dndCopy:"",disabled:"",valueListItem:"",branches:""},Ss={rule:"rule",ruleGroup:"rule-group",inlineCombinator:"inline-combinator",addGroup:"add-group",removeGroup:"remove-group",cloneGroup:"clone-group",cloneRule:"clone-rule",addRule:"add-rule",removeRule:"remove-rule",combinators:"combinators",fields:"fields",operators:"operators",valueEditor:"value-editor",notToggle:"not-toggle",shiftActions:"shift-actions",dragHandle:"drag-handle",lockRule:"lock-rule",lockGroup:"lock-group",valueSourceSelector:"value-source-selector"},ur={parentPathDisabled:"action aborted: parent path disabled",pathDisabled:"action aborted: path is disabled",queryUpdate:"query updated",onAddRuleFalse:"onAddRule callback returned false",onAddGroupFalse:"onAddGroup callback returned false",onMoveRuleFalse:"onMoveRule callback returned false",onMoveGroupFalse:"onMoveGroup callback returned false",onRemoveFalse:"onRemove callback returned false",add:"rule or group added",remove:"rule or group removed",update:"rule or group updated",move:"rule or group moved"};function F$(d){let e,t,s="";if(typeof d=="string"||typeof d=="number")s+=d;else if(typeof d=="object")if(Array.isArray(d)){const i=d.length;for(e=0;e{const{component:e,...t}=d,s=Ws(t.schema.suppressStandardClassnames||ps.betweenRules,t.schema.classNames.betweenRules);return B.createElement("div",{className:s,"data-testid":Ss.inlineCombinator},B.createElement(e,{...t,testID:Ss.combinators}))},v8e=d=>B.createElement("label",{"data-testid":d.testID,className:d.className,title:d.title},B.createElement("input",{type:"checkbox",onChange:e=>d.handleOnChange(e.target.checked),checked:!!d.checked,disabled:d.disabled}),d.label),T8e={},yx=XT({name:"queries",initialState:T8e,reducers:{setQueryState:(d,{payload:{qbId:e,query:t}})=>{d[e]=t}},selectors:{getQuerySelectorById:(d,e)=>d[e]}}),Lu={errorInvalidIndependentCombinatorsProp:"QueryBuilder was rendered with a truthy independentCombinators prop. This prop is deprecated and unnecessary. Furthermore, the initial query/defaultQuery prop was of type RuleGroupType instead of type RuleGroupIC. More info: https://react-querybuilder.js.org/docs/components/querybuilder#independent-combinators",errorUnnecessaryIndependentCombinatorsProp:"QueryBuilder was rendered with the deprecated and unnecessary independentCombinators prop. To use independent combinators, make sure the query/defaultQuery prop is of type RuleGroupIC when the component mounts. More info: https://react-querybuilder.js.org/docs/components/querybuilder#independent-combinators",errorDeprecatedRuleGroupProps:"A custom RuleGroup component has rendered a standard RuleGroup component with deprecated props. The combinator, not, and rules props should not be used. Instead, the full group object should be passed as the ruleGroup prop.",errorDeprecatedRuleProps:"A custom RuleGroup component has rendered a standard Rule component with deprecated props. The field, operator, value, and valueSource props should not be used. Instead, the full rule object should be passed as the rule prop.",errorBothQueryDefaultQuery:"QueryBuilder was rendered with both query and defaultQuery props. QueryBuilder must be either controlled or uncontrolled (specify either the query prop, or the defaultQuery prop, but not both). Decide between using a controlled or uncontrolled query builder and remove one of these props. More info: https://reactjs.org/link/controlled-components",errorUncontrolledToControlled:"QueryBuilder is changing from an uncontrolled component to be controlled. This is likely caused by the query changing from undefined to a defined value, which should not happen. Decide between using a controlled or uncontrolled query builder for the lifetime of the component. More info: https://reactjs.org/link/controlled-components",errorControlledToUncontrolled:"QueryBuilder is changing from a controlled component to be uncontrolled. This is likely caused by the query changing from defined to undefined, which should not happen. Decide between using a controlled or uncontrolled query builder for the lifetime of the component. More info: https://reactjs.org/link/controlled-components",errorEnabledDndWithoutReactDnD:"QueryBuilder was rendered with the enableDragAndDrop prop set to true, but either react-dnd or react-dnd-html5-backend (or both) was not installed. To enable drag-and-drop functionality, install both packages and wrap QueryBuilder in QueryBuilderDnD from @react-querybuilder/dnd."},O8e={[Lu.errorInvalidIndependentCombinatorsProp]:!1,[Lu.errorUnnecessaryIndependentCombinatorsProp]:!1,[Lu.errorDeprecatedRuleGroupProps]:!1,[Lu.errorDeprecatedRuleProps]:!1,[Lu.errorBothQueryDefaultQuery]:!1,[Lu.errorUncontrolledToControlled]:!1,[Lu.errorControlledToUncontrolled]:!1,[Lu.errorEnabledDndWithoutReactDnD]:!1},H$=XT({name:"warnings",initialState:O8e,reducers:{rqbWarn:(d,{payload:e})=>{d[e]||(console.error(e),d[e]=!0)}}}),x8e={queries:yx.getInitialState(),warnings:H$.getInitialState()},P8e=N8({reducer:{queries:yx.reducer,warnings:H$.reducer},preloadedState:x8e,middleware:d=>d({serializableCheck:{ignoredActions:["queries/setQueryState"],ignoredPaths:[/^queries\b.*\.rules\.\d+\.value$/]}})}),wx=B.createContext(null),I8e=k8(wx),C8e=(d,e)=>{const t=B.useContext(rN);return I8e(d,e)??(t==null?void 0:t.initialQuery)},fp=d=>e=>yx.selectors.getQuerySelectorById({queries:e.queries},d),xC=({payload:d,onQueryChange:e})=>t=>{t(yx.actions.setQueryState(d)),typeof e=="function"&&e(d.query)},oN=b8(wx),M8e=OA(wx),_8e=d=>{const e=B.useRef({value:d,prev:null}),t=e.current.value;return d!==t&&(e.current={value:d,prev:t}),e.current.prev},A8e=d=>{oN();const{defaultQuery:e,queryProp:t}=d;_8e(!!t)};function dN(d,e,t){oN()}var L8e=(d,e=aN)=>typeof d=="string"?d.split(`\\${e}`).map(t=>t.split(e)).reduce((t,s,i)=>i===0?s:[...t.slice(0,-1),`${t.at(-1)}${e}${s[0]}`,...s.slice(1)],[]):[],cN=(d,e=aN)=>d.map(t=>`${t??""}`.replaceAll(e[0],`\\${e[0]}`)).join(e),B8e=d=>typeof d=="string"?d.trim():d,Jv=(d,{retainEmptyStrings:e}={})=>Array.isArray(d)?d.map(t=>B8e(t)):typeof d=="string"?L8e(d,aN).filter(e?()=>!0:t=>!/^\s*$/.test(t)).map(t=>t.trim()):typeof d=="number"?[d]:[];new RegExp(nN.source.replace(/^\^/,String.raw`^\s*`).replace(/\$$/,String.raw`\s*$`));var _h=d=>d===null||typeof d!="object"?!1:Object.getPrototypeOf(d)===Object.prototype,Cn=d=>_h(d)&&Array.isArray(d.rules),Qm=d=>Cn(d)&&typeof d.combinator=="string",bx=d=>Cn(d)&&d.combinator===void 0,$F=d=>_h(d)&&"name"in d&&typeof d.name=="string",KF=d=>_h(d)&&"value"in d&&typeof d.value=="string";function Yo(d,e){return Gr(s=>{const i={};let n=!!e;if($F(s)&&!KF(s)?(i.value=s.name,n=!0):!$F(s)&&KF(s)&&(i.name=s.value,n=!0),n)return Object.assign({},e,s,i)})(d)}function dl(d,e){return Array.isArray(d)?Gr(s=>{if(ph(s))for(const i of s)for(const[n,r]of i.options.entries())i.options[n]=Yo(r,e);else for(const[i,n]of s.entries())s[i]=Yo(n,e)})(d):[]}function XF(d,e){return Object.fromEntries(Object.entries(d).map(([t,s])=>[t,Yo(s,e)]))}var Q2=d=>{const e=new Set,t=[];for(const s of d)e.has(s.value??s.name)||(e.add(s.value??s.name),t.push(s));return d.length===t.length?d:t},uN=d=>Array.isArray(d)&&d.length>0&&_h(d[0])&&"options"in d[0]&&Array.isArray(d[0].options),ph=d=>{if(Array.isArray(d)){for(const e of d)if(_h(e)&&"options"in e)for(const t of e.options)return!!(_h(t)&&("name"in t||"value"in t))}return!1},G$=(d,e)=>(uN(d)?d.flatMap(t=>t.options):d).find(t=>t.value===e||t.name===e),oo=d=>{if(!Array.isArray(d)||d.length===0)return null;if(ph(d)){for(const e of d)if(e.options.length>0)return e.options[0].value??e.options[0].name;return null}return d[0].value??d[0].name},Y2=d=>{const e=new Set,t=new Set,s=[];for(const i of d)if(!e.has(i.label)){e.add(i.label);const n=[];for(const r of i.options)t.has(r.value??r.name)||(t.add(r.value??r.name),n.push(Yo(r)));s.push({...i,options:n})}return s},N8e=d=>ph(d)?Y2(d):Q2(d.map(e=>Yo(e))),QF=(d,e,t)=>{var n;const s=Yo(d),i=Yo(t);return s.value===i.value?!1:typeof s.comparator=="string"?s[s.comparator]===i[s.comparator]:((n=s.comparator)==null?void 0:n.call(s,i,e))??!1},U$=(d,e,t)=>{if(!d.comparator){const s=i=>(i.value??i.name)!==(d.value??d.name);return ph(e)?e.map(i=>({...i,options:i.options.filter(n=>s(n))})):e.filter(i=>s(i))}return ph(e)?e.map(s=>({...s,options:s.options.filter(i=>QF(d,t,i))})).filter(s=>s.options.length>0):e.filter(s=>QF(d,t,s))},hN=(d,{parseNumbers:e}={})=>{if(!e||typeof d=="bigint"||typeof d=="number")return d;if(e==="native")return parseFloat(d);const t=u8e(d,{allowTrailingInvalid:e==="enhanced",romanNumerals:!1,round:!1});return isNaN(t)?d:t},Dr=(d,e)=>{let t=e,s=0;for(;sd.slice(0,-1),Ym=(d,e)=>d.length===e.length&&d.every((t,s)=>t===e[s]),E8e=(d,e)=>{const t=[],s=wn(d),i=wn(e);let n=0;for(;n{let t=!!e.disabled,s=e,i=0;for(;iYm([],d.path)?"Query builder":`Rule group at path ${d.path.join("-")}`,Sy=globalThis.crypto,Zo=()=>"00-0-4-2-000".replaceAll(/[^-]/g,d=>((Math.random()+Math.trunc(d))*65536>>parseInt(d)).toString(16).padStart(4,"0"));if(Sy){if(typeof Sy.randomUUID=="function")Zo=()=>Sy.randomUUID();else if(typeof Sy.getRandomValues=="function"){const d="89ab",e=new Uint32Array(32);Zo=()=>{Sy.getRandomValues(e);let t=(e[0]%16).toString(16);for(let s=1;s<32;s++)s===12?t=`${t}4`:s===16?t=`${t}${d[e[17]%4]}`:t=`${t}${(e[s]%16).toString(16)}`,(s===7||s===11||s===15||s===19)&&(t=`${t}-`);return t}}}var Qa=d=>B.useCallback((e,t)=>{e==null||e.preventDefault(),e==null||e.stopPropagation(),d(e,t)},[d]),D8e=B.memo(d=>{const e=V8e(d),t=Qa(e.cloneRule),s=Qa(e.toggleLockRule),i=Qa(e.removeRule),n=Qa(e.shiftRuleUp),r=Qa(e.shiftRuleDown);return B.createElement("div",{ref:e.dndRef,"data-testid":Ss.rule,"data-dragmonitorid":e.dragMonitorId,"data-dropmonitorid":e.dropMonitorId,className:e.outerClassName,"data-rule-id":e.id,"data-level":e.path.length,"data-path":JSON.stringify(e.path)},B.createElement(q8e,{...e,cloneRule:t,toggleLockRule:s,removeRule:i,shiftRuleUp:n,shiftRuleDown:r}))}),q8e=B.memo(d=>{const{schema:{controls:{shiftActions:e,dragHandle:t,fieldSelector:s,operatorSelector:i,valueSourceSelector:n,valueEditor:r,cloneRuleAction:a,lockRuleAction:o,removeRuleAction:c}}}=d;return B.createElement(B.Fragment,null,d.schema.showShiftActions&&B.createElement(e,{testID:Ss.shiftActions,level:d.path.length,path:d.path,titles:{shiftUp:d.translations.shiftActionUp.title,shiftDown:d.translations.shiftActionDown.title},labels:{shiftUp:d.translations.shiftActionUp.label,shiftDown:d.translations.shiftActionDown.label},className:d.classNames.shiftActions,disabled:d.disabled,shiftUp:d.shiftRuleUp,shiftDown:d.shiftRuleDown,shiftUpDisabled:d.shiftUpDisabled,shiftDownDisabled:d.shiftDownDisabled,context:d.context,validation:d.validationResult,schema:d.schema,ruleOrGroup:d.rule}),d.schema.enableDragAndDrop&&B.createElement(t,{testID:Ss.dragHandle,ref:d.dragRef,level:d.path.length,path:d.path,title:d.translations.dragHandle.title,label:d.translations.dragHandle.label,className:d.classNames.dragHandle,disabled:d.disabled,context:d.context,validation:d.validationResult,schema:d.schema,ruleOrGroup:d.rule}),B.createElement(s,{testID:Ss.fields,options:d.schema.fields,title:d.translations.fields.title,value:d.rule.field,operator:d.rule.operator,className:d.classNames.fields,handleOnChange:d.generateOnChangeHandler("field"),level:d.path.length,path:d.path,disabled:d.disabled,context:d.context,validation:d.validationResult,schema:d.schema,rule:d.rule}),(d.schema.autoSelectField||d.rule.field!==d.translations.fields.placeholderName)&&B.createElement(B.Fragment,null,B.createElement(i,{testID:Ss.operators,field:d.rule.field,fieldData:d.fieldData,title:d.translations.operators.title,options:d.operators,value:d.rule.operator,className:d.classNames.operators,handleOnChange:d.generateOnChangeHandler("operator"),level:d.path.length,path:d.path,disabled:d.disabled,context:d.context,validation:d.validationResult,schema:d.schema,rule:d.rule}),(d.schema.autoSelectOperator||d.rule.operator!==d.translations.operators.placeholderName)&&!d.hideValueControls&&B.createElement(B.Fragment,null,!["null","notNull"].includes(d.rule.operator)&&d.valueSources.length>1&&B.createElement(n,{testID:Ss.valueSourceSelector,field:d.rule.field,fieldData:d.fieldData,title:d.translations.valueSourceSelector.title,options:d.valueSourceOptions,value:d.rule.valueSource??"value",className:d.classNames.valueSource,handleOnChange:d.generateOnChangeHandler("valueSource"),level:d.path.length,path:d.path,disabled:d.disabled,context:d.context,validation:d.validationResult,schema:d.schema,rule:d.rule}),B.createElement(r,{testID:Ss.valueEditor,field:d.rule.field,fieldData:d.fieldData,title:d.translations.value.title,operator:d.rule.operator,value:d.rule.value,valueSource:d.rule.valueSource??"value",type:d.valueEditorType,inputType:d.inputType,values:d.values,listsAsArrays:d.schema.listsAsArrays,parseNumbers:d.schema.parseNumbers,separator:d.valueEditorSeparator,className:d.classNames.value,handleOnChange:d.generateOnChangeHandler("value"),level:d.path.length,path:d.path,disabled:d.disabled,context:d.context,validation:d.validationResult,schema:d.schema,rule:d.rule}))),d.schema.showCloneButtons&&B.createElement(a,{testID:Ss.cloneRule,label:d.translations.cloneRule.label,title:d.translations.cloneRule.title,className:d.classNames.cloneRule,handleOnClick:d.cloneRule,level:d.path.length,path:d.path,disabled:d.disabled,context:d.context,validation:d.validationResult,ruleOrGroup:d.rule,schema:d.schema}),d.schema.showLockButtons&&B.createElement(o,{testID:Ss.lockRule,label:d.translations.lockRule.label,title:d.translations.lockRule.title,className:d.classNames.lockRule,handleOnClick:d.toggleLockRule,level:d.path.length,path:d.path,disabled:d.disabled,disabledTranslation:d.parentDisabled?void 0:d.translations.lockRuleDisabled,context:d.context,validation:d.validationResult,ruleOrGroup:d.rule,schema:d.schema}),B.createElement(c,{testID:Ss.removeRule,label:d.translations.removeRule.label,title:d.translations.removeRule.title,className:d.classNames.removeRule,handleOnClick:d.removeRule,level:d.path.length,path:d.path,disabled:d.disabled,context:d.context,validation:d.validationResult,ruleOrGroup:d.rule,schema:d.schema}))}),V8e=d=>{const{id:e,path:t,rule:s,schema:{classNames:i,fields:n,fieldMap:r,getInputType:a,getOperators:o,getValueEditorType:c,getValueEditorSeparator:u,getValueSources:h,getValues:l,validationMap:f,enableDragAndDrop:p,getRuleClassname:m,suppressStandardClassnames:g},actions:{moveRule:y,onPropChange:w,onRuleRemove:b},disabled:S,parentDisabled:v,shiftUpDisabled:C,shiftDownDisabled:M,field:_,operator:N,value:A,valueSource:R,dropEffect:D="move",dragMonitorId:U="",dropMonitorId:K="",dndRef:j=null,dragRef:z=null,isDragging:J=!1,isOver:Y=!1}=d;dN();const X=!!v||!!S,Z=B.useMemo(()=>s??{id:e,field:_??"",operator:N??"",value:A,valueSource:R},[_,e,N,s,A,R]),te=B.useMemo(()=>({shiftActions:Ws(g||ps.shiftActions,i.shiftActions),dragHandle:Ws(g||ps.dragHandle,i.dragHandle),fields:Ws(g||ps.fields,i.valueSelector,i.fields),operators:Ws(g||ps.operators,i.valueSelector,i.operators),valueSource:Ws(g||ps.valueSource,i.valueSelector,i.valueSource),value:Ws(g||ps.value,i.value),cloneRule:Ws(g||ps.cloneRule,i.actionElement,i.cloneRule),lockRule:Ws(g||ps.lockRule,i.actionElement,i.lockRule),removeRule:Ws(g||ps.removeRule,i.actionElement,i.removeRule),valueListItem:Ws(g||ps.valueListItem,i.valueListItem)}),[i.shiftActions,i.dragHandle,i.valueSelector,i.fields,i.operators,i.valueSource,i.value,i.actionElement,i.cloneRule,i.lockRule,i.removeRule,i.valueListItem,g]),Q=B.useCallback(ut=>(yt,Bt)=>{X||w(ut,yt,t)},[X,w,t]),ie=B.useCallback(()=>{if(!X){const ut=[...wn(t),t.at(-1)+1];y(t,ut,!0)}},[X,y,t]),ne=B.useCallback((ut,yt)=>{w("disabled",!X,t)},[X,w,t]),oe=B.useCallback((ut,yt)=>{X||b(t)},[X,b,t]),me=B.useCallback((ut,yt)=>{!X&&!C&&y(t,"up",ut==null?void 0:ut.altKey)},[X,y,t,C]),fe=B.useCallback((ut,yt)=>{!X&&!M&&y(t,"down",ut==null?void 0:ut.altKey)},[X,y,t,M]),he=B.useMemo(()=>(r==null?void 0:r[Z.field])??{name:Z.field,value:Z.field,label:Z.field},[r,Z.field]),Se=B.useMemo(()=>he.inputType??a(Z.field,Z.operator,{fieldData:he}),[he,a,Z.field,Z.operator]),ye=B.useMemo(()=>o(Z.field,{fieldData:he}),[he,o,Z.field]),ge=B.useMemo(()=>G$(ye,Z.operator),[ye,Z.operator]),Te=ge==null?void 0:ge.arity,Ge=typeof Te=="string"&&Te==="unary"||typeof Te=="number"&&Te<2,Ye=B.useMemo(()=>typeof he.valueSources=="function"?he.valueSources(Z.operator):he.valueSources??h(Z.field,Z.operator,{fieldData:he}),[he,h,Z.field,Z.operator]),Re=B.useMemo(()=>Z.valueSource==="field"?"select":c(Z.field,Z.operator,{fieldData:he}),[he,c,Z.field,Z.operator,Z.valueSource]),Be=B.useMemo(()=>u(Z.field,Z.operator,{fieldData:he}),[he,u,Z.field,Z.operator]),Me=B.useMemo(()=>Z.valueSource==="field"?U$(he,n,Z.operator):he.values??l(Z.field,Z.operator,{fieldData:he}),[he,n,l,Z.field,Z.operator,Z.valueSource]),Le=B.useMemo(()=>Ye.map(ut=>({name:ut,value:ut,label:ut})),[Ye]),rt=B.useMemo(()=>f[e??""]??(typeof he.validator=="function"?he.validator(Z):null),[he,e,Z,f]),ze=B.useMemo(()=>z$(rt),[rt]),Ue=B.useMemo(()=>(he==null?void 0:he.className)??"",[he==null?void 0:he.className]),Je=B.useMemo(()=>(ge==null?void 0:ge.className)??"",[ge==null?void 0:ge.className]),st=B.useMemo(()=>Ws(m(Z,{fieldData:he}),Ue,Je,g||ps.rule,i.rule,X&&i.disabled,J&&i.dndDragging,Y&&i.dndOver,Y&&D==="copy"&&i.dndCopy,g||{[ps.disabled]:X,[ps.dndDragging]:J,[ps.dndOver]:Y,[ps.dndCopy]:Y&&D==="copy"},ze),[i.disabled,i.dndCopy,i.dndDragging,i.dndOver,i.rule,X,D,Ue,he,m,J,Y,Je,Z,g,ze]);return{...d,classNames:te,cloneRule:ie,disabled:X,dndRef:j,dragMonitorId:U,dragRef:z,dropMonitorId:K,fieldData:he,generateOnChangeHandler:Q,hideValueControls:Ge,inputType:Se,operators:ye,outerClassName:st,removeRule:oe,rule:Z,shiftRuleUp:me,shiftRuleDown:fe,toggleLockRule:ne,validationResult:rt,valueEditorSeparator:Be,valueEditorType:Re,values:Me,valueSourceOptions:Le,valueSources:Ye}},F8e=B.memo(d=>{const e=U8e(d),{schema:{controls:{ruleGroupBodyElements:t,ruleGroupHeaderElements:s}}}=e,i=Qa(e.addRule),n=Qa(e.addGroup),r=Qa(e.cloneGroup),a=Qa(e.toggleLockGroup),o=Qa(e.removeGroup),c=Qa(e.shiftGroupUp),u=Qa(e.shiftGroupDown);return B.createElement("div",{ref:e.previewRef,title:e.accessibleDescription,className:e.outerClassName,"data-testid":Ss.ruleGroup,"data-dragmonitorid":e.dragMonitorId,"data-dropmonitorid":e.dropMonitorId,"data-rule-group-id":e.id,"data-level":e.path.length,"data-path":JSON.stringify(e.path)},B.createElement("div",{ref:e.dropRef,className:e.classNames.header},B.createElement(s,{...e,addRule:i,addGroup:n,cloneGroup:r,toggleLockGroup:a,removeGroup:o,shiftGroupUp:c,shiftGroupDown:u})),B.createElement("div",{className:e.classNames.body},B.createElement(t,{...e,addRule:i,addGroup:n,cloneGroup:r,toggleLockGroup:a,removeGroup:o,shiftGroupUp:c,shiftGroupDown:u})))}),H8e=B.memo(d=>{const{schema:{controls:{shiftActions:e,dragHandle:t,combinatorSelector:s,notToggle:i,addRuleAction:n,addGroupAction:r,cloneGroupAction:a,lockGroupAction:o,removeGroupAction:c}}}=d;return B.createElement(B.Fragment,null,d.schema.showShiftActions&&d.path.length>0&&B.createElement(e,{key:Ss.shiftActions,testID:Ss.shiftActions,level:d.path.length,path:d.path,titles:{shiftUp:d.translations.shiftActionUp.title,shiftDown:d.translations.shiftActionDown.title},labels:{shiftUp:d.translations.shiftActionUp.label,shiftDown:d.translations.shiftActionDown.label},className:d.classNames.shiftActions,disabled:d.disabled,shiftUp:d.shiftGroupUp,shiftDown:d.shiftGroupDown,shiftUpDisabled:d.shiftUpDisabled,shiftDownDisabled:d.shiftDownDisabled,context:d.context,validation:d.validationResult,schema:d.schema,ruleOrGroup:d.ruleGroup}),d.path.length>0&&d.schema.enableDragAndDrop&&B.createElement(t,{key:Ss.dragHandle,testID:Ss.dragHandle,ref:d.dragRef,level:d.path.length,path:d.path,title:d.translations.dragHandle.title,label:d.translations.dragHandle.label,className:d.classNames.dragHandle,disabled:d.disabled,context:d.context,validation:d.validationResult,schema:d.schema,ruleOrGroup:d.ruleGroup}),!d.schema.showCombinatorsBetweenRules&&!d.schema.independentCombinators&&B.createElement(s,{key:Ss.combinators,testID:Ss.combinators,options:d.schema.combinators,value:d.combinator,title:d.translations.combinators.title,className:d.classNames.combinators,handleOnChange:d.onCombinatorChange,rules:d.ruleGroup.rules,level:d.path.length,path:d.path,disabled:d.disabled,context:d.context,validation:d.validationResult,schema:d.schema}),d.schema.showNotToggle&&B.createElement(i,{key:Ss.notToggle,testID:Ss.notToggle,className:d.classNames.notToggle,title:d.translations.notToggle.title,label:d.translations.notToggle.label,checked:d.ruleGroup.not,handleOnChange:d.onNotToggleChange,level:d.path.length,disabled:d.disabled,path:d.path,context:d.context,validation:d.validationResult,schema:d.schema,ruleGroup:d.ruleGroup}),B.createElement(n,{key:Ss.addRule,testID:Ss.addRule,label:d.translations.addRule.label,title:d.translations.addRule.title,className:d.classNames.addRule,handleOnClick:d.addRule,rules:d.ruleGroup.rules,level:d.path.length,path:d.path,disabled:d.disabled,context:d.context,validation:d.validationResult,ruleOrGroup:d.ruleGroup,schema:d.schema}),B.createElement(r,{key:Ss.addGroup,testID:Ss.addGroup,label:d.translations.addGroup.label,title:d.translations.addGroup.title,className:d.classNames.addGroup,handleOnClick:d.addGroup,rules:d.ruleGroup.rules,level:d.path.length,path:d.path,disabled:d.disabled,context:d.context,validation:d.validationResult,ruleOrGroup:d.ruleGroup,schema:d.schema}),d.schema.showCloneButtons&&d.path.length>0&&B.createElement(a,{key:Ss.cloneGroup,testID:Ss.cloneGroup,label:d.translations.cloneRuleGroup.label,title:d.translations.cloneRuleGroup.title,className:d.classNames.cloneGroup,handleOnClick:d.cloneGroup,rules:d.ruleGroup.rules,level:d.path.length,path:d.path,disabled:d.disabled,context:d.context,validation:d.validationResult,ruleOrGroup:d.ruleGroup,schema:d.schema}),d.schema.showLockButtons&&B.createElement(o,{key:Ss.lockGroup,testID:Ss.lockGroup,label:d.translations.lockGroup.label,title:d.translations.lockGroup.title,className:d.classNames.lockGroup,handleOnClick:d.toggleLockGroup,rules:d.ruleGroup.rules,level:d.path.length,path:d.path,disabled:d.disabled,disabledTranslation:d.parentDisabled?void 0:d.translations.lockGroupDisabled,context:d.context,validation:d.validationResult,ruleOrGroup:d.ruleGroup,schema:d.schema}),d.path.length>0&&B.createElement(c,{key:Ss.removeGroup,testID:Ss.removeGroup,label:d.translations.removeGroup.label,title:d.translations.removeGroup.title,className:d.classNames.removeGroup,handleOnClick:d.removeGroup,rules:d.ruleGroup.rules,level:d.path.length,path:d.path,disabled:d.disabled,context:d.context,validation:d.validationResult,ruleOrGroup:d.ruleGroup,schema:d.schema}))}),G8e=B.memo(d=>{const{schema:{controls:{combinatorSelector:e,inlineCombinator:t,ruleGroup:s,rule:i}}}=d;return d.ruleGroup.rules.map((n,r,{length:a})=>{const o=d.pathsMemo[r],c=o.path,u=o.disabled||typeof n!="string"&&n.disabled,h=Ym([0],c),l=d.path.length===0&&r===a-1,f=typeof n=="string"?[...c,n].join("-"):n.id;return B.createElement(B.Fragment,{key:f},r>0&&!d.schema.independentCombinators&&d.schema.showCombinatorsBetweenRules&&B.createElement(t,{key:Ss.inlineCombinator,options:d.schema.combinators,value:d.combinator,title:d.translations.combinators.title,className:d.classNames.combinators,handleOnChange:d.onCombinatorChange,rules:d.ruleGroup.rules,level:d.path.length,context:d.context,validation:d.validationResult,component:e,path:c,disabled:d.disabled,schema:d.schema}),typeof n=="string"?B.createElement(t,{key:`${Ss.inlineCombinator}-independent`,options:d.schema.combinators,value:n,title:d.translations.combinators.title,className:d.classNames.combinators,handleOnChange:p=>d.onIndependentCombinatorChange(p,r),rules:d.ruleGroup.rules,level:d.path.length,context:d.context,validation:d.validationResult,component:e,path:c,disabled:u,schema:d.schema}):Cn(n)?B.createElement(s,{key:Ss.ruleGroup,id:n.id,schema:d.schema,actions:d.actions,path:c,translations:d.translations,ruleGroup:n,rules:n.rules,combinator:Qm(n)?n.combinator:void 0,not:!!n.not,disabled:u,parentDisabled:d.parentDisabled||d.disabled,shiftUpDisabled:h,shiftDownDisabled:l,context:d.context}):B.createElement(i,{key:Ss.rule,id:n.id,rule:n,field:n.field,operator:n.operator,value:n.value,valueSource:n.valueSource,schema:d.schema,actions:d.actions,path:c,disabled:u,parentDisabled:d.parentDisabled||d.disabled,translations:d.translations,shiftUpDisabled:h,shiftDownDisabled:l,context:d.context}))})}),U8e=d=>{const{id:e,path:t,ruleGroup:s,schema:{qbId:i,accessibleDescriptionGenerator:n,classNames:r,combinators:a,createRule:o,createRuleGroup:c,disabledPaths:u,independentCombinators:h,validationMap:l,enableDragAndDrop:f,getRuleGroupClassname:p,suppressStandardClassnames:m},actions:{onGroupAdd:g,onGroupRemove:y,onPropChange:w,onRuleAdd:b,moveRule:S},disabled:v,parentDisabled:C,shiftUpDisabled:M,shiftDownDisabled:_,combinator:N,rules:A,not:R,dropEffect:D="move",dragMonitorId:U="",dropMonitorId:K="",previewRef:j=null,dragRef:z=null,dropRef:J=null,isDragging:Y=!1,isOver:X=!1}=d;dN();const Z=!!C||!!v,te=B.useMemo(()=>s&&Qm(s)?s.combinator:s?oo(a):N??oo(a),[N,a,s]),Q=B.useMemo(()=>{if(s){if(s.combinator===te||h)return s;const Ue=structuredClone(s);return Ue.combinator=te,Ue}return{rules:A,not:R}},[te,h,R,s,A]),ie=B.useMemo(()=>({header:Ws(m||ps.header,r.header,X&&D==="copy"&&r.dndCopy,m||{[ps.dndOver]:X,[ps.dndCopy]:X&&D==="copy"}),shiftActions:Ws(m||ps.shiftActions,r.shiftActions),dragHandle:Ws(m||ps.dragHandle,r.dragHandle),combinators:Ws(m||ps.combinators,r.valueSelector,r.combinators),notToggle:Ws(m||ps.notToggle,r.notToggle),addRule:Ws(m||ps.addRule,r.actionElement,r.addRule),addGroup:Ws(m||ps.addGroup,r.actionElement,r.addGroup),cloneGroup:Ws(m||ps.cloneGroup,r.actionElement,r.cloneGroup),lockGroup:Ws(m||ps.lockGroup,r.actionElement,r.lockGroup),removeGroup:Ws(m||ps.removeGroup,r.actionElement,r.removeGroup),body:Ws(m||ps.body,r.body)}),[r.actionElement,r.addGroup,r.addRule,r.body,r.cloneGroup,r.combinators,r.dndCopy,r.dragHandle,r.header,r.lockGroup,r.notToggle,r.removeGroup,r.shiftActions,r.valueSelector,D,X,m]),ne=B.useCallback(Ue=>{Z||w("combinator",Ue,t)},[Z,w,t]),oe=B.useCallback((Ue,Je,st)=>{Z||w("combinator",Ue,[...t,Je])},[Z,w,t]),me=B.useCallback((Ue,Je)=>{Z||w("not",Ue,t)},[Z,w,t]),fe=B.useCallback((Ue,Je)=>{if(!Z){const st=o();b(st,t,Je)}},[o,Z,b,t]),he=B.useCallback((Ue,Je)=>{if(!Z){const st=c(h);g(st,t,Je)}},[c,Z,h,g,t]),Se=B.useCallback(()=>{if(!Z){const Ue=[...wn(t),t.at(-1)+1];S(t,Ue,!0)}},[Z,S,t]),ye=B.useCallback((Ue,Je)=>{!Z&&!M&&S(t,"up",Ue==null?void 0:Ue.altKey)},[Z,S,t,M]),ge=B.useCallback((Ue,Je)=>{!Z&&!_&&S(t,"down",Ue==null?void 0:Ue.altKey)},[Z,S,t,_]),Te=B.useCallback(()=>{w("disabled",!Z,t)},[Z,w,t]),Ge=B.useCallback(()=>{Z||y(t)},[Z,y,t]),Ye=B.useMemo(()=>l[e??""],[e,l]),Re=B.useMemo(()=>z$(Ye),[Ye]),Be=B.useMemo(()=>{var Ue;return h?null:((Ue=G$(a,te))==null?void 0:Ue.className)??""},[te,a,h]),Me=B.useMemo(()=>p(Q),[p,Q]),Le=B.useMemo(()=>Ws(Me,Be,m||ps.ruleGroup,r.ruleGroup,Z&&r.disabled,Y&&r.dndDragging,m||{[ps.disabled]:Z,[ps.dndDragging]:Y},Re),[r.disabled,r.dndDragging,r.ruleGroup,Be,Z,Y,Me,m,Re]),rt=B.useMemo(()=>{const Ue=[];for(let Je=0;JeYm(st,ut))}}return Ue},[Z,t,Q.rules.length,u]),ze=B.useMemo(()=>n({path:t,qbId:i}),[n,t,i]);return{...d,addGroup:he,addRule:fe,accessibleDescription:ze,classNames:ie,cloneGroup:Se,combinator:te,disabled:Z,dragMonitorId:U,dragRef:z,dropMonitorId:K,dropRef:J,isDragging:Y,isOver:X,onCombinatorChange:ne,onGroupAdd:g,onIndependentCombinatorChange:oe,onNotToggleChange:me,outerClassName:Le,parentDisabled:C,pathsMemo:rt,previewRef:j,removeGroup:Ge,ruleGroup:Q,shiftGroupUp:ye,shiftGroupDown:ge,toggleLockGroup:Te,validationClassName:Re,validationResult:Ye}},W8e=d=>{var e,t,s,i;return B.createElement("div",{"data-testid":d.testID,className:d.className},B.createElement("button",{disabled:d.disabled||d.shiftUpDisabled,onClick:d.shiftUp,title:(e=d.titles)==null?void 0:e.shiftUp},(t=d.labels)==null?void 0:t.shiftUp),B.createElement("button",{disabled:d.disabled||d.shiftDownDisabled,onClick:d.shiftDown,title:(s=d.titles)==null?void 0:s.shiftDown},(i=d.labels)==null?void 0:i.shiftDown))},j8e=d=>{const{operator:e,value:t,handleOnChange:s,title:i,className:n,type:r="text",inputType:a="text",values:o=[],listsAsArrays:c,fieldData:u,disabled:h,separator:l=null,testID:f,selectorComponent:p=d.schema.controls.valueSelector,...m}=d,{valueAsArray:g,multiValueHandler:y,parseNumberMethod:w,valueListItemClassName:b}=W$(d);if(e==="null"||e==="notNull")return null;const S=(u==null?void 0:u.placeholder)??"",v=["in","notIn"].includes(e)?"text":a||"text";if((e==="between"||e==="notBetween")&&(r==="select"||r==="text")){const C=["from","to"].map((M,_)=>r==="text"?B.createElement("input",{key:M,type:v,placeholder:S,value:g[_]??"",className:b,disabled:h,onChange:N=>y(N.target.value,_)}):B.createElement(p,{key:M,...m,schema:d.schema,className:b,handleOnChange:N=>y(N,_),disabled:h,value:g[_]??oo(o),options:o,listsAsArrays:c}));return B.createElement("span",{"data-testid":f,className:n,title:i},C[0],l,C[1])}switch(r){case"select":case"multiselect":return B.createElement(p,{...m,schema:d.schema,testID:f,className:n,title:i,handleOnChange:s,disabled:h,value:t,options:o,multiple:r==="multiselect",listsAsArrays:c});case"textarea":return B.createElement("textarea",{"data-testid":f,placeholder:S,value:t,title:i,className:n,disabled:h,onChange:C=>s(C.target.value)});case"switch":case"checkbox":return B.createElement("input",{"data-testid":f,type:"checkbox",className:n,title:i,onChange:C=>s(C.target.checked),checked:!!t,disabled:h});case"radio":return B.createElement("span",{"data-testid":f,className:n,title:i},o.map(C=>B.createElement("label",{key:C.name},B.createElement("input",{type:"radio",value:C.name,disabled:h,checked:t===C.name,onChange:M=>s(M.target.value)}),C.label)))}return B.createElement("input",{"data-testid":f,type:v,placeholder:S,value:t,title:i,className:n,disabled:h,onChange:C=>s(hN(C.target.value,{parseNumbers:w}))})},W$=d=>{const{handleOnChange:e,inputType:t,operator:s,value:i,listsAsArrays:n,parseNumbers:r,values:a,type:o,skipHook:c,schema:{classNames:u,suppressStandardClassnames:h}}=d;B.useEffect(()=>{!c&&o!=="multiselect"&&!["between","notBetween","in","notIn"].includes(s)&&(Array.isArray(i)||t==="number"&&typeof i=="string"&&i.includes(","))&&e(Jv(i,{retainEmptyStrings:!0})[0]??"")},[e,t,s,c,o,i]);const l=B.useMemo(()=>Jv(i,{retainEmptyStrings:!0}),[i]),f=B.useMemo(()=>{if(typeof r=="string"){const[g,y]=r.split("-");return y==="limited"?t==="number"?g:!1:g}return r?"strict":!1},[t,r]),p=B.useCallback((g,y)=>{const w=Gr(l,b=>{b[y]=hN(g,{parseNumbers:f}),y===0&&(s==="between"||s==="notBetween")&&(b.length<2||b[1]===void 0)&&(b[1]=oo(a))});e(n?w:cN(w,","))},[e,n,s,f,l,a]),m=k8e(h||ps.valueListItem,u==null?void 0:u.valueListItem);return{valueAsArray:l,multiValueHandler:p,parseNumberMethod:f,valueListItemClassName:m}},z8e=d=>{const{multiple:e,onChange:t}=d;return B.useMemo(()=>e?i=>t(Array.from(i.target.selectedOptions).map(n=>n.value)):i=>t(i.target.value),[e,t])},vy=d=>{const{onChange:e,val:t}=j$(d),s=z8e({multiple:d.multiple,onChange:e});return B.createElement("select",{"data-testid":d.testID,className:d.className,value:t,title:d.title,disabled:d.disabled,multiple:!!d.multiple,onChange:s},cGe(d.options))},j$=d=>{const{handleOnChange:e,listsAsArrays:t=!1,multiple:s=!1,value:i}=d,n=B.useCallback(a=>{if(s){const o=Jv(a);e(t?o:cN(o,","))}else e(a)},[e,t,s]),r=B.useMemo(()=>s?Jv(i):i,[s,i]);return{onChange:n,val:r}},qS={actionElement:fc,addGroupAction:fc,addRuleAction:fc,cloneGroupAction:fc,cloneRuleAction:fc,combinatorSelector:vy,dragHandle:h8e,fieldSelector:vy,inlineCombinator:S8e,lockGroupAction:fc,lockRuleAction:fc,notToggle:v8e,operatorSelector:vy,removeGroupAction:fc,removeRuleAction:fc,rule:D8e,ruleGroup:F8e,ruleGroupBodyElements:G8e,ruleGroupHeaderElements:H8e,shiftActions:W8e,valueEditor:j8e,valueSelector:vy,valueSourceSelector:vy},$8e=(d,e)=>d===!1?!1:d?!0:e!==!1,K8e=(d,e)=>d?!0:d===!1?!1:!!e,X8e=(d,e,t)=>d?$8e(e,t):K8e(e,t),PC=(d,e,t)=>X8e(d,e,t),C1=()=>null,Q8e=B.forwardRef(C1),pp={},Y8e=({finalize:d,...e})=>{var w,b,S,v,C,M,_,N,A,R,D,U,K,j,z,J,Y,X,Z,te,Q,ie,ne,oe,me,fe,he,Se,ye,ge,Te,Ge,Ye,Re,Be,Me,Le,rt,ze,Ue,Je,st,ut,yt,Bt,lt,ht,ft,se,F,V,re,le,ke,Ne,wt,Yt,zt,Et,bt,Ms,ls,Or,An,Rs,Qt,oi,Aa,mn,Xr,sd,La,id,yo,nd,Jd,$t,ms;const t=B.useContext(rN),s=PC(!1,e.debugMode,t.debugMode),i=d?s:e.debugMode??t.debugMode,n=PC(!0,e.enableMountQueryChange,t.enableMountQueryChange),r=d?n:e.enableMountQueryChange??t.enableMountQueryChange,a=PC(!1,e.enableDragAndDrop,t.enableDragAndDrop)&&t.enableDragAndDrop!==!1,o=d?a:e.enableDragAndDrop??t.enableDragAndDrop,c=B.useMemo(()=>tGe(d?Object.assign({},b8e):pp,t.controlClassnames,e.controlClassnames),[t.controlClassnames,e.controlClassnames,d]),u=B.useMemo(()=>({actionElement:c.actionElement,addGroup:c.addGroup,addRule:c.addRule,body:c.body,cloneGroup:c.cloneGroup,cloneRule:c.cloneRule,combinators:c.combinators,dragHandle:c.dragHandle,fields:c.fields,header:c.header,lockGroup:c.lockGroup,lockRule:c.lockRule,notToggle:c.notToggle,operators:c.operators,queryBuilder:c.queryBuilder,removeGroup:c.removeGroup,removeRule:c.removeRule,rule:c.rule,ruleGroup:c.ruleGroup,shiftActions:c.shiftActions,value:c.value,valueSelector:c.valueSelector,valueSource:c.valueSource,betweenRules:c.betweenRules,valid:c.valid,invalid:c.invalid,dndDragging:c.dndDragging,dndOver:c.dndOver,dndCopy:c.dndCopy,disabled:c.disabled,valueListItem:c.valueListItem,branches:c.branches}),[c.actionElement,c.addGroup,c.addRule,c.betweenRules,c.body,c.branches,c.cloneGroup,c.cloneRule,c.combinators,c.disabled,c.dndCopy,c.dndDragging,c.dndOver,c.dragHandle,c.fields,c.header,c.invalid,c.lockGroup,c.lockRule,c.notToggle,c.operators,c.queryBuilder,c.removeGroup,c.removeRule,c.rule,c.ruleGroup,c.shiftActions,c.valid,c.value,c.valueListItem,c.valueSelector,c.valueSource]),h=t.controlElements??pp,l=e.controlElements??pp,f=B.useCallback((ds,Ce,xe)=>{const dt=ds==="dragHandle"?Q8e:C1,Ct=(ds.endsWith("Action")&&l.actionElement?l.actionElement:void 0)??(ds.endsWith("Selector")&&l.valueSelector?l.valueSelector:void 0),ns=(ds.endsWith("Action")&&h.actionElement?h.actionElement:void 0)??(ds.endsWith("Selector")&&h.valueSelector?h.valueSelector:void 0),Ts=Ce===null?dt:Ce??(d?Ct:void 0)??(xe===null?dt:xe??(d?ns:void 0));return Ts?{[ds]:Ts}:d?{[ds]:qS[ds]}:pp},[h.actionElement,h.valueSelector,d,l.actionElement,l.valueSelector]),p=B.useMemo(()=>Object.assign({},f("addGroupAction",l.addGroupAction,h.addGroupAction),f("addRuleAction",l.addRuleAction,h.addRuleAction),f("cloneGroupAction",l.cloneGroupAction,h.cloneGroupAction),f("cloneRuleAction",l.cloneRuleAction,h.cloneRuleAction),f("combinatorSelector",l.combinatorSelector,h.combinatorSelector),f("dragHandle",l.dragHandle,h.dragHandle),f("fieldSelector",l.fieldSelector,h.fieldSelector),f("inlineCombinator",l.inlineCombinator,h.inlineCombinator),f("lockGroupAction",l.lockGroupAction,h.lockGroupAction),f("lockRuleAction",l.lockRuleAction,h.lockRuleAction),f("notToggle",l.notToggle,h.notToggle),f("operatorSelector",l.operatorSelector,h.operatorSelector),f("removeGroupAction",l.removeGroupAction,h.removeGroupAction),f("removeRuleAction",l.removeRuleAction,h.removeRuleAction),f("shiftActions",l.shiftActions,h.shiftActions),{valueEditor:l.valueEditor===null?C1:l.valueEditor??(h.valueEditor===null?C1:h.valueEditor)??qS.valueEditor},f("valueSourceSelector",l.valueSourceSelector,h.valueSourceSelector),f("rule",l.rule,h.rule),f("ruleGroup",l.ruleGroup,h.ruleGroup),f("ruleGroupBodyElements",l.ruleGroupBodyElements,h.ruleGroupBodyElements),f("ruleGroupHeaderElements",l.ruleGroupHeaderElements,h.ruleGroupHeaderElements),{actionElement:l.actionElement??h.actionElement??(d?qS.actionElement:void 0)},{valueSelector:l.valueSelector??h.valueSelector??(d?qS.valueSelector:void 0)}),[h.actionElement,h.addGroupAction,h.addRuleAction,h.cloneGroupAction,h.cloneRuleAction,h.combinatorSelector,h.dragHandle,h.fieldSelector,h.inlineCombinator,h.lockGroupAction,h.lockRuleAction,h.notToggle,h.operatorSelector,h.removeGroupAction,h.removeRuleAction,h.rule,h.ruleGroup,h.ruleGroupBodyElements,h.ruleGroupHeaderElements,h.shiftActions,h.valueEditor,h.valueSelector,h.valueSourceSelector,f,d,l.actionElement,l.addGroupAction,l.addRuleAction,l.cloneGroupAction,l.cloneRuleAction,l.combinatorSelector,l.dragHandle,l.fieldSelector,l.inlineCombinator,l.lockGroupAction,l.lockRuleAction,l.notToggle,l.operatorSelector,l.removeGroupAction,l.removeRuleAction,l.rule,l.ruleGroup,l.ruleGroupBodyElements,l.ruleGroupHeaderElements,l.shiftActions,l.valueEditor,l.valueSelector,l.valueSourceSelector]),m=e.translations??pp,g=t.translations??pp,y=B.useMemo(()=>{var ds,Ce,xe,dt,Ct,ns,Ts,Fs,Ln,Ba,Cf,du,Mf,Kh,_f,cu,uu,Ut,Bn,vi,$n,Qr,ec,xr,Pr,Af,Lb,kg,Xh,Sg,Bb,vg,Tg,Lf,Nb,Og,Bf,Nf,tc,xg,Pg,Eb,Ig,Cg,Mg,_g,Rb,Db,qb,Ag,Vb,Fb,Hb,Gb,Ef,Ub,Wb,jb,zb,$b,Zs,Hs,Kb,Xb,Qb,Yb,Zb,Jb,Lg,ek,Ji,Rf,rd,Bg,Df,ar,Ng,Eg;return Object.assign(d?Object.assign({},V$):{},on("addGroup",{label:[(ds=m.addGroup)==null?void 0:ds.label,(Ce=g.addGroup)==null?void 0:Ce.label],title:[(xe=m.addGroup)==null?void 0:xe.title,(dt=g.addGroup)==null?void 0:dt.title]},d),on("addRule",{label:[(Ct=m.addRule)==null?void 0:Ct.label,(ns=g.addRule)==null?void 0:ns.label],title:[(Ts=m.addRule)==null?void 0:Ts.title,(Fs=g.addRule)==null?void 0:Fs.title]},d),on("cloneRule",{label:[(Ln=m.cloneRule)==null?void 0:Ln.label,(Ba=g.cloneRule)==null?void 0:Ba.label],title:[(Cf=m.cloneRule)==null?void 0:Cf.title,(du=g.cloneRule)==null?void 0:du.title]},d),on("cloneRuleGroup",{label:[(Mf=m.cloneRuleGroup)==null?void 0:Mf.label,(Kh=g.cloneRuleGroup)==null?void 0:Kh.label],title:[(_f=m.cloneRuleGroup)==null?void 0:_f.title,(cu=g.cloneRuleGroup)==null?void 0:cu.title]},d),on("combinators",{title:[(uu=m.combinators)==null?void 0:uu.title,(Ut=g.combinators)==null?void 0:Ut.title]},d),on("dragHandle",{label:[(Bn=m.dragHandle)==null?void 0:Bn.label,(vi=g.dragHandle)==null?void 0:vi.label],title:[($n=m.dragHandle)==null?void 0:$n.title,(Qr=g.dragHandle)==null?void 0:Qr.title]},d),on("fields",{placeholderGroupLabel:[(ec=m.fields)==null?void 0:ec.placeholderGroupLabel,(xr=g.fields)==null?void 0:xr.placeholderGroupLabel],placeholderLabel:[(Pr=m.fields)==null?void 0:Pr.placeholderLabel,(Af=g.fields)==null?void 0:Af.placeholderLabel],placeholderName:[(Lb=m.fields)==null?void 0:Lb.placeholderName,(kg=g.fields)==null?void 0:kg.placeholderName],title:[(Xh=m.fields)==null?void 0:Xh.title,(Sg=g.fields)==null?void 0:Sg.title]},d),on("lockGroup",{label:[(Bb=m.lockGroup)==null?void 0:Bb.label,(vg=g.lockGroup)==null?void 0:vg.label],title:[(Tg=m.lockGroup)==null?void 0:Tg.title,(Lf=g.lockGroup)==null?void 0:Lf.title]},d),on("lockGroupDisabled",{label:[(Nb=m.lockGroupDisabled)==null?void 0:Nb.label,(Og=g.lockGroupDisabled)==null?void 0:Og.label],title:[(Bf=m.lockGroupDisabled)==null?void 0:Bf.title,(Nf=g.lockGroupDisabled)==null?void 0:Nf.title]},d),on("lockRule",{label:[(tc=m.lockRule)==null?void 0:tc.label,(xg=g.lockRule)==null?void 0:xg.label],title:[(Pg=m.lockRule)==null?void 0:Pg.title,(Eb=g.lockRule)==null?void 0:Eb.title]},d),on("lockRuleDisabled",{label:[(Ig=m.lockRuleDisabled)==null?void 0:Ig.label,(Cg=g.lockRuleDisabled)==null?void 0:Cg.label],title:[(Mg=m.lockRuleDisabled)==null?void 0:Mg.title,(_g=g.lockRuleDisabled)==null?void 0:_g.title]},d),on("notToggle",{label:[(Rb=m.notToggle)==null?void 0:Rb.label,(Db=g.notToggle)==null?void 0:Db.label],title:[(qb=m.notToggle)==null?void 0:qb.title,(Ag=g.notToggle)==null?void 0:Ag.title]},d),on("operators",{placeholderGroupLabel:[(Vb=m.operators)==null?void 0:Vb.placeholderGroupLabel,(Fb=g.operators)==null?void 0:Fb.placeholderGroupLabel],placeholderLabel:[(Hb=m.operators)==null?void 0:Hb.placeholderLabel,(Gb=g.operators)==null?void 0:Gb.placeholderLabel],placeholderName:[(Ef=m.operators)==null?void 0:Ef.placeholderName,(Ub=g.operators)==null?void 0:Ub.placeholderName],title:[(Wb=m.operators)==null?void 0:Wb.title,(jb=g.operators)==null?void 0:jb.title]},d),on("removeGroup",{label:[(zb=m.removeGroup)==null?void 0:zb.label,($b=g.removeGroup)==null?void 0:$b.label],title:[(Zs=m.removeGroup)==null?void 0:Zs.title,(Hs=g.removeGroup)==null?void 0:Hs.title]},d),on("removeRule",{label:[(Kb=m.removeRule)==null?void 0:Kb.label,(Xb=g.removeRule)==null?void 0:Xb.label],title:[(Qb=m.removeRule)==null?void 0:Qb.title,(Yb=g.removeRule)==null?void 0:Yb.title]},d),on("shiftActionDown",{label:[(Zb=m.shiftActionDown)==null?void 0:Zb.label,(Jb=g.shiftActionDown)==null?void 0:Jb.label],title:[(Lg=m.shiftActionDown)==null?void 0:Lg.title,(ek=g.shiftActionDown)==null?void 0:ek.title]},d),on("shiftActionUp",{label:[(Ji=m.shiftActionUp)==null?void 0:Ji.label,(Rf=g.shiftActionUp)==null?void 0:Rf.label],title:[(rd=m.shiftActionUp)==null?void 0:rd.title,(Bg=g.shiftActionUp)==null?void 0:Bg.title]},d),on("value",{title:[(Df=m.value)==null?void 0:Df.title,(ar=g.value)==null?void 0:ar.title]},d),on("valueSourceSelector",{title:[(Ng=m.valueSourceSelector)==null?void 0:Ng.title,(Eg=g.valueSourceSelector)==null?void 0:Eg.title]},d))},[(w=m.addGroup)==null?void 0:w.label,(b=m.addGroup)==null?void 0:b.title,(S=m.addRule)==null?void 0:S.label,(v=m.addRule)==null?void 0:v.title,(C=m.cloneRule)==null?void 0:C.label,(M=m.cloneRule)==null?void 0:M.title,(_=m.cloneRuleGroup)==null?void 0:_.label,(N=m.cloneRuleGroup)==null?void 0:N.title,(A=m.combinators)==null?void 0:A.title,(R=m.dragHandle)==null?void 0:R.label,(D=m.dragHandle)==null?void 0:D.title,(U=m.fields)==null?void 0:U.placeholderGroupLabel,(K=m.fields)==null?void 0:K.placeholderLabel,(j=m.fields)==null?void 0:j.placeholderName,(z=m.fields)==null?void 0:z.title,(J=m.lockGroup)==null?void 0:J.label,(Y=m.lockGroup)==null?void 0:Y.title,(X=m.lockGroupDisabled)==null?void 0:X.label,(Z=m.lockGroupDisabled)==null?void 0:Z.title,(te=m.lockRule)==null?void 0:te.label,(Q=m.lockRule)==null?void 0:Q.title,(ie=m.lockRuleDisabled)==null?void 0:ie.label,(ne=m.lockRuleDisabled)==null?void 0:ne.title,(oe=m.notToggle)==null?void 0:oe.label,(me=m.notToggle)==null?void 0:me.title,(fe=m.operators)==null?void 0:fe.placeholderGroupLabel,(he=m.operators)==null?void 0:he.placeholderLabel,(Se=m.operators)==null?void 0:Se.placeholderName,(ye=m.operators)==null?void 0:ye.title,(ge=m.removeGroup)==null?void 0:ge.label,(Te=m.removeGroup)==null?void 0:Te.title,(Ge=m.removeRule)==null?void 0:Ge.label,(Ye=m.removeRule)==null?void 0:Ye.title,(Re=m.shiftActionDown)==null?void 0:Re.label,(Be=m.shiftActionDown)==null?void 0:Be.title,(Me=m.shiftActionUp)==null?void 0:Me.label,(Le=m.shiftActionUp)==null?void 0:Le.title,(rt=m.value)==null?void 0:rt.title,(ze=m.valueSourceSelector)==null?void 0:ze.title,d,(Ue=g.addGroup)==null?void 0:Ue.label,(Je=g.addGroup)==null?void 0:Je.title,(st=g.addRule)==null?void 0:st.label,(ut=g.addRule)==null?void 0:ut.title,(yt=g.cloneRule)==null?void 0:yt.label,(Bt=g.cloneRule)==null?void 0:Bt.title,(lt=g.cloneRuleGroup)==null?void 0:lt.label,(ht=g.cloneRuleGroup)==null?void 0:ht.title,(ft=g.combinators)==null?void 0:ft.title,(se=g.dragHandle)==null?void 0:se.label,(F=g.dragHandle)==null?void 0:F.title,(V=g.fields)==null?void 0:V.placeholderGroupLabel,(re=g.fields)==null?void 0:re.placeholderLabel,(le=g.fields)==null?void 0:le.placeholderName,(ke=g.fields)==null?void 0:ke.title,(Ne=g.lockGroup)==null?void 0:Ne.label,(wt=g.lockGroup)==null?void 0:wt.title,(Yt=g.lockGroupDisabled)==null?void 0:Yt.label,(zt=g.lockGroupDisabled)==null?void 0:zt.title,(Et=g.lockRule)==null?void 0:Et.label,(bt=g.lockRule)==null?void 0:bt.title,(Ms=g.lockRuleDisabled)==null?void 0:Ms.label,(ls=g.lockRuleDisabled)==null?void 0:ls.title,(Or=g.notToggle)==null?void 0:Or.label,(An=g.notToggle)==null?void 0:An.title,(Rs=g.operators)==null?void 0:Rs.placeholderGroupLabel,(Qt=g.operators)==null?void 0:Qt.placeholderLabel,(oi=g.operators)==null?void 0:oi.placeholderName,(Aa=g.operators)==null?void 0:Aa.title,(mn=g.removeGroup)==null?void 0:mn.label,(Xr=g.removeGroup)==null?void 0:Xr.title,(sd=g.removeRule)==null?void 0:sd.label,(La=g.removeRule)==null?void 0:La.title,(id=g.shiftActionDown)==null?void 0:id.label,(yo=g.shiftActionDown)==null?void 0:yo.title,(nd=g.shiftActionUp)==null?void 0:nd.label,(Jd=g.shiftActionUp)==null?void 0:Jd.title,($t=g.value)==null?void 0:$t.title,(ms=g.valueSourceSelector)==null?void 0:ms.title]);return{controlClassnames:u,controlElements:p,debugMode:i,enableDragAndDrop:o,enableMountQueryChange:r,translations:y,initialQuery:e.initialQuery,qbId:e.qbId}},z$=d=>{const e=typeof d=="boolean"?d:typeof d=="object"&&d!==null?d.valid:null;return typeof e=="boolean"?e?ps.valid:ps.invalid:""},Z8e=["value"],J8e={name:"name",value:"name",valueSources:null,label:"label"},eGe=(d,e,t)=>{const s=d?Yo(d):J8e;if(s.valueSources)return typeof s.valueSources=="function"?s.valueSources(e):s.valueSources;if(t){const i=t(s.value,e,{fieldData:Yo(s)});if(i)return i}return Z8e},As=(d,e)=>Ws(e.map(t=>Ws(t==null?void 0:t[d]))),tGe=(...d)=>({queryBuilder:As("queryBuilder",d),ruleGroup:As("ruleGroup",d),header:As("header",d),body:As("body",d),combinators:As("combinators",d),addRule:As("addRule",d),addGroup:As("addGroup",d),cloneRule:As("cloneRule",d),cloneGroup:As("cloneGroup",d),removeGroup:As("removeGroup",d),rule:As("rule",d),fields:As("fields",d),operators:As("operators",d),value:As("value",d),removeRule:As("removeRule",d),notToggle:As("notToggle",d),shiftActions:As("shiftActions",d),dragHandle:As("dragHandle",d),lockRule:As("lockRule",d),lockGroup:As("lockGroup",d),valueSource:As("valueSource",d),actionElement:As("actionElement",d),valueSelector:As("valueSelector",d),betweenRules:As("betweenRules",d),valid:As("valid",d),invalid:As("invalid",d),dndDragging:As("dndDragging",d),dndOver:As("dndOver",d),dndCopy:As("dndCopy",d),disabled:As("disabled",d),valueListItem:As("valueListItem",d),branches:As("branches",d)}),sGe=Object.keys,iGe=Object.entries,on=(d,e,t)=>{const s=iGe(e).map(([i,[n,r]])=>{var a;return[i,n??r??((a=(t?V$:{})[d])==null?void 0:a[i])]}).filter(i=>!!i[1]);return s.length>0?{[d]:Object.fromEntries(s)}:void 0},$$=(d,{idGenerator:e=Zo}={})=>Gr(d,t=>{t.id||(t.id=e())}),lN=(d,{idGenerator:e=Zo}={})=>Gr(d,t=>{t.id||(t.id=e()),t.rules=t.rules.map(s=>typeof s=="string"?s:Cn(s)?lN(s,{idGenerator:e}):$$(s,{idGenerator:e}))}),nGe=(d,{idGenerator:e=Zo}={})=>Cn(d)?lN(d,{idGenerator:e}):$$(d,{idGenerator:e}),YF=(d,{idGenerator:e=Zo}={})=>structuredClone({...d,id:e()}),Z2=(d,{idGenerator:e=Zo}={})=>{if(!_h(d))return d;if(!Cn(d))return structuredClone({...d,id:e()});if(Qm(d)){const s=d.rules.map(i=>Cn(i)?Z2(i,{idGenerator:e}):YF(i,{idGenerator:e}));return{...d,id:e(),rules:s}}const t=d.rules.map(s=>typeof s=="string"?s:Cn(s)?Z2(s,{idGenerator:e}):YF(s,{idGenerator:e}));return{...d,id:e(),rules:t}},ZF=(d,e,t,{combinators:s=gx,combinatorPreceding:i,idGenerator:n=Zo}={})=>Gr(d,r=>{const a=Dr(t,r);if(!(!a||!Cn(a))){if(bx(a)&&a.rules.length>0){const o=a.rules.at(-2);a.rules.push(i??(typeof o=="string"?o:oo(s)))}a.rules.push(nGe(e,{idGenerator:n}))}}),rGe=(d,e,t,s,{resetOnFieldChange:i=!0,resetOnOperatorChange:n=!1,getRuleDefaultOperator:r=()=>"=",getValueSources:a=()=>["value"],getRuleDefaultValue:o=()=>""}={})=>Gr(d,c=>{if(e==="combinator"&&!Qm(c)){const m=Dr(wn(s),c).rules;s.at(-1)%2===1&&(m[s.at(-1)]=t);return}const u=Dr(s,c);if(!u)return;const h=Cn(u);if(u[e]===t||(e!=="valueSource"&&(u[e]=t),h))return;let l=!1,f=!1;i&&e==="field"&&(u.operator=r(t),l=!0,f=!0),n&&e==="operator"&&(l=!0,f=!0);const p=a(u.field,u.operator)[0];(l&&u.valueSource&&p!==u.valueSource||e==="valueSource"&&t!==u.valueSource)&&(f=!!u.valueSource||!u.valueSource&&t!==p,u.valueSource=l?p:t),f&&(u.value=o(u))}),aGe=(d,e)=>e.length===0||!Qm(d)&&!Dr(e,d)?d:Gr(d,t=>{const s=e.at(-1),i=Dr(wn(e),t);if(i&&Cn(i))if(!Qm(i)&&i.rules.length>1){const n=s===0?0:s-1;i.rules.splice(n,2)}else i.rules.splice(s,1)}),oGe=(d,e,t)=>{if(Array.isArray(t))return t;const s=bx(d);if(t==="up"){if(Ym(e,[0]))return e;if(e.at(-1)===0){const i=wn(e);return[...wn(i),Math.max(0,i.at(-1)-(s?1:0))]}else{const i=[...wn(e),Math.max(0,e.at(-1)-(s?2:1))],n=Dr(i,d);return Cn(n)?[...i,n.rules.length]:[...wn(e),Math.max(0,e.at(-1)-(s?3:1))]}}else if(t==="down"){if(Ym([d.rules.length-1],e))return e;if(e.at(-1)===Dr(wn(e),d).rules.length-1){const i=wn(e);return[...wn(i),i.at(-1)+1]}else{const i=[...wn(e),e.at(-1)+(s?2:1)],n=Dr(i,d);return Cn(n)?[...i,0]:[...wn(e),e.at(-1)+(s?3:2)]}}return e},dGe=(d,e,t,{clone:s=!1,combinators:i=gx,idGenerator:n=Zo}={})=>{const r=oGe(d,e,t);if(e.length===0||Ym(e,r)||!Dr(wn(r),d))return d;const a=Dr(e,d);if(!a)return d;const o=s?Z2(a,{idGenerator:n}):a;return Gr(d,c=>{const u=bx(c),h=Dr(wn(e),c),l=e.at(-1),f=u&&l>0?h.rules[l-1]:null,p=u&&le[g.length]&&(m[g.length]-=u?2:1);const y=wn(m),w=Dr(y,c),b=m.at(-1),S=(...v)=>w.rules.splice(b,0,...v);if(w.rules.length===0||!u)S(o);else if(b===0)if(l===0&&p)S(o,p);else{const v=w.rules[1]??f??oo(i);S(o,v)}else if(f)S(f,o);else{const v=w.rules[b-2]??p??oo(i);S(v,o)}})},cGe=d=>uN(d)?d.map(e=>B.createElement("optgroup",{key:e.label,label:e.label},e.options.map(t=>B.createElement("option",{key:t.name,value:t.name,disabled:t.disabled},t.label)))):Array.isArray(d)?d.map(e=>B.createElement("option",{key:e.name,value:e.name,disabled:e.disabled},e.label)):null,uGe={},hGe={},lGe=[],fGe={},pGe=()=>null,JF=()=>"",Ty=()=>!0,mGe=(...d)=>{console.log(...d)};function gGe(d,e){const{query:t,defaultQuery:s,getValueEditorSeparator:i=pGe,getRuleClassname:n=JF,getRuleGroupClassname:r=JF,onAddRule:a=Ty,onAddGroup:o=Ty,onMoveRule:c=Ty,onMoveGroup:u=Ty,onRemove:h=Ty,onQueryChange:l,showCombinatorsBetweenRules:f=!1,showNotToggle:p=!1,showShiftActions:m=!1,showCloneButtons:g=!1,showLockButtons:y=!1,suppressStandardClassnames:w=!1,resetOnFieldChange:b=!0,resetOnOperatorChange:S=!1,autoSelectField:v=!0,autoSelectOperator:C=!0,addRuleToNewGroups:M=!1,listsAsArrays:_=!1,parseNumbers:N=!1,disabled:A=!1,validator:R,onLog:D=mGe,idGenerator:U,accessibleDescriptionGenerator:K=R8e}=d,{qbId:j,rqbContext:z,fields:J,fieldMap:Y,combinators:X,getOperatorsMain:Z,getRuleDefaultOperator:te,getValueEditorTypeMain:Q,getValueSourcesMain:ie,getValuesMain:ne,getRuleDefaultValue:oe,getInputTypeMain:me,createRule:fe,createRuleGroup:he}=e,{controlClassnames:Se,controlElements:ye,debugMode:ge,enableDragAndDrop:Te,enableMountQueryChange:Ge,translations:Ye}=z,Re=!!f,Be=!!p,Me=!!m,Le=!!g,rt=!!y,ze=!!b,Ue=!!S,Je=!!v,st=!!C,ut=!!M,yt=!!_,Bt=!!w,lt=B.useCallback((...$t)=>{ge&&D(...$t)},[ge,D]);A8e({defaultQuery:s,queryProp:t});const ht=M8e(),ft=oN(),se=B.useMemo(()=>fp(j),[j]),F=C8e(se),V=B.useCallback(()=>se(ht.getState()),[ht,se]),re=B.useMemo(()=>he(),[he]),le=t??F??s??re,ke=le.id?le:lN(le,{idGenerator:U}),[Ne]=B.useState(ke),wt=B.useMemo(()=>({...z,initialQuery:Ne}),[z,Ne]);B.useEffect(()=>{t&&!Object.is(t,F)&&ft(xC({payload:{qbId:j,query:t},onQueryChange:void 0}))},[t,j,F,ft]);const Yt=B.useMemo(()=>bx(ke),[ke]),zt=!!d.independentCombinators&&!Yt;dN("independentCombinators",zt||!zt&&(d.independentCombinators??"not present")!=="not present");const Et=B.useRef(!1);B.useEffect(()=>{Et.current||(Et.current=!0,ft(xC({payload:{qbId:j,query:ke},onQueryChange:Ge&&typeof l=="function"?l:void 0})))},[Ge,l,j,ft,ke]);const bt=B.useCallback($t=>{ft(xC({payload:{qbId:j,query:$t},onQueryChange:l}))},[l,j,ft]),Ms=B.useMemo(()=>Array.isArray(A)&&A||lGe,[A]),ls=A===!0,Or=B.useMemo(()=>ke.disabled||Ms.some($t=>$t.length===0),[Ms,ke.disabled]),An=B.useCallback(($t,ms,ds)=>{const Ce=fp(j)(ht.getState());if(!Ce)return;if(ky(ms,Ce)||ls){lt({qbId:j,type:ur.parentPathDisabled,rule:$t,parentPath:ms,query:Ce});return}const xe=a($t,ms,Ce,ds);if(!xe){lt({qbId:j,type:ur.onAddRuleFalse,rule:$t,parentPath:ms,query:Ce});return}const dt=xe===!0?$t:xe,Ct=ZF(Ce,dt,ms,{combinators:X,combinatorPreceding:dt.combinatorPreceding??void 0});lt({qbId:j,type:ur.add,query:Ce,newQuery:Ct,newRule:dt,parentPath:ms}),bt(Ct)},[j,ht,ls,a,X,bt,lt]),Rs=B.useCallback(($t,ms,ds)=>{const Ce=fp(j)(ht.getState());if(!Ce)return;if(ky(ms,Ce)||ls){lt({qbId:j,type:ur.parentPathDisabled,ruleGroup:$t,parentPath:ms,query:Ce});return}const xe=o($t,ms,Ce,ds);if(!xe){lt({qbId:j,type:ur.onAddGroupFalse,ruleGroup:$t,parentPath:ms,query:Ce});return}const dt=xe===!0?$t:xe,Ct=ZF(Ce,dt,ms,{combinators:X,combinatorPreceding:dt.combinatorPreceding??void 0});lt({qbId:j,type:ur.add,query:Ce,newQuery:Ct,newGroup:dt,parentPath:ms}),bt(Ct)},[j,ht,ls,o,X,lt,bt]),Qt=B.useCallback(($t,ms,ds)=>{const Ce=fp(j)(ht.getState());if(!Ce)return;if(ky(ds,Ce)&&$t!=="disabled"||ls){lt({qbId:j,type:ur.pathDisabled,path:ds,prop:$t,value:ms,query:Ce});return}const xe=rGe(Ce,$t,ms,ds,{resetOnFieldChange:ze,resetOnOperatorChange:Ue,getRuleDefaultOperator:te,getValueSources:ie,getRuleDefaultValue:oe});lt({qbId:j,type:ur.update,query:Ce,newQuery:xe,prop:$t,value:ms,path:ds}),bt(xe)},[j,ht,ls,ze,Ue,te,ie,oe,lt,bt]),oi=B.useCallback(($t,ms)=>{const ds=fp(j)(ht.getState());if(!ds)return;if(ky($t,ds)||ls){lt({qbId:j,type:ur.pathDisabled,path:$t,query:ds});return}const Ce=Dr($t,ds);if(Ce)if(h(Ce,$t,ds,ms)){const xe=aGe(ds,$t);lt({qbId:j,type:ur.remove,query:ds,newQuery:xe,path:$t,ruleOrGroup:Ce}),bt(xe)}else lt({qbId:j,type:ur.onRemoveFalse,ruleOrGroup:Ce,path:$t,query:ds})},[j,ht,ls,lt,h,bt]),Aa=B.useCallback(($t,ms,ds,Ce)=>{const xe=fp(j)(ht.getState());if(!xe)return;if(ky($t,xe)||ls){lt({qbId:j,type:ur.pathDisabled,oldPath:$t,newPath:ms,query:xe});return}const dt=dGe(xe,$t,ms,{clone:ds,combinators:X}),Ct=Dr($t,xe),ns=Cn(Ct),Ts=(ns?u:c)(Ct,$t,ms,xe,dt,{clone:ds,combinators:X},Ce);if(!Ts){lt({qbId:j,type:ns?ur.onMoveGroupFalse:ur.onMoveRuleFalse,ruleOrGroup:Ct,oldPath:$t,newPath:ms,clone:ds,query:xe,nextQuery:dt});return}const Fs=Cn(Ts)?Ts:dt;lt({qbId:j,type:ur.move,query:xe,newQuery:Fs,oldPath:$t,newPath:ms,clone:ds}),bt(Fs)},[j,ht,ls,X,u,c,lt,bt]),{validationResult:mn,validationMap:Xr}=B.useMemo(()=>{const $t=typeof R=="function"&&ke?R(ke):uGe;return{validationResult:$t,validationMap:typeof $t=="boolean"?hGe:$t}},[ke,R]),sd=B.useMemo(()=>Te?"enabled":"disabled",[Te]),La=B.useMemo(()=>Yt||Re?"enabled":"disabled",[Yt,Re]),id=B.useMemo(()=>typeof ke.combinator=="string"?{combinator:ke.combinator}:fGe,[ke.combinator]),yo=B.useMemo(()=>Ws(Bt||ps.queryBuilder,Ws(Se.queryBuilder),ls&&Se.disabled,typeof mn=="boolean"&&mn&&Se.valid,typeof mn=="boolean"&&!mn&&Se.invalid,Bt||{[ps.disabled]:ls,[ps.valid]:typeof mn=="boolean"&&mn,[ps.invalid]:typeof mn=="boolean"&&!mn}),[Se.disabled,Se.invalid,Se.queryBuilder,Se.valid,ls,Bt,mn]),nd=B.useMemo(()=>({addRuleToNewGroups:ut,accessibleDescriptionGenerator:K,autoSelectField:Je,autoSelectOperator:st,classNames:Se,combinators:X,controls:ye,createRule:fe,createRuleGroup:he,disabledPaths:Ms,enableDragAndDrop:Te,fieldMap:Y,fields:J,dispatchQuery:bt,getQuery:V,getInputType:me,getOperators:Z,getRuleClassname:n,getRuleGroupClassname:r,getValueEditorSeparator:i,getValueEditorType:Q,getValues:ne,getValueSources:ie,independentCombinators:Yt,listsAsArrays:yt,parseNumbers:N,qbId:j,showCloneButtons:Le,showCombinatorsBetweenRules:Re,showLockButtons:rt,showNotToggle:Be,showShiftActions:Me,suppressStandardClassnames:Bt,validationMap:Xr}),[K,ut,Je,st,X,Se,ye,fe,he,Ms,bt,Te,Y,J,me,Z,V,n,r,i,Q,ne,ie,Yt,yt,N,j,Le,Re,rt,Be,Me,Bt,Xr]);return{actions:B.useMemo(()=>({moveRule:Aa,onGroupAdd:Rs,onGroupRemove:oi,onPropChange:Qt,onRuleAdd:An,onRuleRemove:oi}),[Aa,Rs,Qt,An,oi]),rootGroup:ke,rootGroupDisabled:Or,queryDisabled:ls,rqbContext:wt,schema:nd,translations:Ye,wrapperClassName:yo,dndEnabledAttr:sd,inlineCombinatorsAttr:La,combinatorPropObject:id}}var e4=(d,e,t)=>{const s=oo(d);if(e.operator==="between"||e.operator==="notBetween"){const i=[s,s];return t?i:cN(i.map(n=>n??""),",")}return s},yGe=d=>{const[e]=B.useState(Zo),{fields:t,baseField:s,operators:i,baseOperator:n,combinators:r=gx,baseCombinator:a,translations:o,enableMountQueryChange:c=!0,controlClassnames:u,controlElements:h,getDefaultField:l,getDefaultOperator:f,getDefaultValue:p,getOperators:m,getValueEditorType:g,getValueSources:y,getInputType:w,getValues:b,autoSelectField:S=!0,autoSelectOperator:v=!0,addRuleToNewGroups:C=!1,enableDragAndDrop:M,listsAsArrays:_=!1,debugMode:N=!1,idGenerator:A=Zo}=d,R=i??w8e,[D]=B.useState(d.query??d.defaultQuery),U=Y8e({controlClassnames:u,controlElements:h,debugMode:N,enableDragAndDrop:M,enableMountQueryChange:c,translations:o,initialQuery:D,qbId:e,finalize:!0}),{translations:K}=U,j=B.useMemo(()=>({id:K.fields.placeholderName,name:K.fields.placeholderName,value:K.fields.placeholderName,label:K.fields.placeholderLabel}),[K.fields.placeholderLabel,K.fields.placeholderName]),z=B.useMemo(()=>t??[j],[j,t]),J=B.useMemo(()=>{const ye=Array.isArray(z)?dl(z,s):sGe(XF(z,s)).map(ge=>({...z[ge],name:ge,value:ge})).sort((ge,Te)=>ge.label.localeCompare(Te.label));return ph(ye)?Y2(S?ye:[{label:K.fields.placeholderGroupLabel,options:[j]},...ye]):Q2(S?ye:[j,...ye])},[S,s,j,z,K.fields.placeholderGroupLabel]),Y=B.useMemo(()=>{if(!Array.isArray(z)){const ge=XF(z,s);return S?ge:{...ge,[K.fields.placeholderName]:j}}const ye={};if(ph(J))for(const ge of J)for(const Te of ge.options)ye[Te.value??Te.name]=Yo(Te,s);else for(const ge of J)ye[ge.value??ge.name]=Yo(ge,s);return ye},[S,s,j,J,z,K.fields.placeholderName]),X=B.useMemo(()=>dl(r,a),[a,r]),Z=B.useMemo(()=>({id:K.operators.placeholderName,name:K.operators.placeholderName,value:K.operators.placeholderName,label:K.operators.placeholderLabel}),[K.operators.placeholderLabel,K.operators.placeholderName]),te=B.useCallback((ye,{fieldData:ge})=>{let Te=dl(R,n);if(ge!=null&&ge.operators)Te=dl(ge.operators,n);else if(m){const Ge=m(ye,{fieldData:ge});Ge&&(Te=dl(Ge,n))}return v||(Te=ph(Te)?[{label:K.operators.placeholderGroupLabel,options:[Z]},...Te]:[Z,...Te]),N8e(Te)},[v,n,Z,m,R,K.operators.placeholderGroupLabel]),Q=B.useCallback(ye=>{const ge=Y[ye];if(ge!=null&&ge.defaultOperator)return ge.defaultOperator;if(f)return typeof f=="function"?f(ye,{fieldData:ge}):f;const Te=te(ye,{fieldData:ge})??[];return oo(Te)??""},[Y,f,te]),ie=B.useCallback((ye,ge,{fieldData:Te})=>Te.valueEditorType?typeof Te.valueEditorType=="function"?Te.valueEditorType(ge):Te.valueEditorType:(g==null?void 0:g(ye,ge,{fieldData:Te}))??"text",[g]),ne=B.useCallback((ye,ge)=>eGe(Y[ye],ge,y),[Y,y]),oe=B.useCallback((ye,ge,{fieldData:Te})=>Te!=null&&Te.values?dl(Te.values):b?dl(b(ye,ge,{fieldData:Te})):[],[b]),me=B.useCallback(ye=>{const ge=Y[ye.field]??{};if((ge==null?void 0:ge.defaultValue)!==void 0&&ge.defaultValue!==null)return ge.defaultValue;if(p)return p(ye,{fieldData:ge});let Te="";const Ge=oe(ye.field,ye.operator,{fieldData:ge});if(ye.valueSource==="field"){const Ye=U$(ge,J,ye.operator);Te=Ye.length>0?e4(Ye,ye,_):""}else if(Ge.length>0){const Ye=ie(ye.field,ye.operator,{fieldData:ge});Ye==="multiselect"?Te=_?[]:"":(Ye==="select"||Ye==="radio")&&(Te=e4(Ge,ye,_))}else ie(ye.field,ye.operator,{fieldData:ge})==="checkbox"&&(Te=!1);return Te},[Y,J,p,ie,oe,_]),fe=B.useCallback((ye,ge,{fieldData:Te})=>{if(w){const Ge=w(ye,ge,{fieldData:Te});if(Ge)return Ge}return"text"},[w]),he=B.useCallback(()=>{let ye="";const ge=J;if((ge==null?void 0:ge.length)>0&&ge[0]){const Be=oo(ge);Be&&(ye=Be)}if(l)if(typeof l=="function"){const Be=l(ge);Be&&(ye=Be)}else ye=l;const Te=Q(ye),Ge=ne(ye,Te)[0]??"value",Ye={id:A(),field:ye,operator:Te,valueSource:Ge,value:""},Re=me(Ye);return{...Ye,value:Re}},[J,l,Q,me,ne,A]),Se=B.useCallback(ye=>ye?{id:A(),rules:C?[he()]:[],not:!1}:{id:A(),rules:C?[he()]:[],combinator:oo(X)??"",not:!1},[C,X,he,A]);return{qbId:e,rqbContext:U,fields:J,fieldMap:Y,combinators:X,getOperatorsMain:te,getRuleDefaultOperator:Q,getValueEditorTypeMain:ie,getValueSourcesMain:ne,getValuesMain:oe,getRuleDefaultValue:me,getInputTypeMain:fe,createRule:he,createRuleGroup:Se}},wGe=[],bGe=d=>B.createElement(y8,{context:wx,store:P8e},d.children),kGe=({props:d})=>{const e=vGe(d),t=e.schema.controls.ruleGroup,s=rN;return B.createElement(s.Provider,{key:e.dndEnabledAttr,value:e.rqbContext},B.createElement("div",{role:"form",className:e.wrapperClassName,"data-dnd":e.dndEnabledAttr,"data-inlinecombinators":e.inlineCombinatorsAttr},B.createElement(t,{translations:e.translations,ruleGroup:e.rootGroup,rules:e.rootGroup.rules,...e.combinatorPropObject,not:!!e.rootGroup.not,schema:e.schema,actions:e.actions,id:e.rootGroup.id,path:wGe,disabled:e.rootGroupDisabled,shiftUpDisabled:!0,shiftDownDisabled:!0,parentDisabled:e.queryDisabled,context:d.context})))},SGe=d=>B.createElement(bGe,null,B.createElement(kGe,{props:d})),vGe=d=>gGe(d,yGe(d));const TGe=({className:d,handleOnClick:e,label:t,title:s,disabled:i,disabledTranslation:n,testID:r,path:a,level:o,rules:c,context:u,validation:h,ruleOrGroup:l,schema:f,...p})=>{const m=n&&i?n.label:t;return P.jsx(Es,{variant:"soft",color:"primary",className:d,title:n&&i?n.title:s,size:"sm",disabled:i&&!n,onClick:g=>e(g),...p,children:m})},OGe=d=>{const{field:e,fieldData:t,value:s,handleOnChange:i,className:n,valueSource:r,disabled:a,extraProps:o}=d,c=(t==null?void 0:t.placeholder)??"";return s?P.jsxs(_t,{display:"flex",alignItems:"center",gap:1,children:[P.jsx(Pn,{className:n,sx:{maxWidth:88},placeholder:c,value:s.indicatorValue,disabled:a,onChange:u=>i({...s,indicatorValue:u.target.value}),...o}),P.jsx(ot,{children:"with periods"}),P.jsx(Pn,{className:n,sx:{maxWidth:64},placeholder:"Periods",value:s.periods,disabled:a,onChange:u=>i({...s,periods:u.target.value}),...o}),P.jsx(ot,{children:"on timeframe"}),P.jsx(wg,{value:s.timeframe,onChange:u=>i({...s,timeframe:u})})]}):P.jsx("div",{children:"Missing default indicator value"})},xGe=d=>{const{...e}=d,{field:t,fieldData:s,operator:i,value:n,handleOnChange:r,title:a,className:o,type:c,path:u,level:h,inputType:l,values:f=[],listsAsArrays:p,separator:m,valueSource:g,disabled:y,testID:w,selectorComponent:b=d.schema.controls.valueSelector,extraProps:S,...v}=e,{valueAsArray:C,multiValueHandler:M,parseNumberMethod:_,valueListItemClassName:N}=W$(e);if(i==="null"||i==="notNull")return null;const A=(s==null?void 0:s.placeholder)??"",R=["in","notIn"].includes(i)?"text":l||"text";if(Tue(n))return P.jsx(OGe,{...d});if((i==="between"||i==="notBetween")&&(c==="select"||c==="text")){const D=["from","to"].map((U,K)=>c==="text"?P.jsx(Pn,{type:R,className:N,placeholder:A,value:C[K]??"",disabled:y,onChange:j=>M(j.target.value,K),...S},U):P.jsx(b,{...v,path:u,level:h,className:N,handleOnChange:j=>M(j,K),disabled:y,value:C[K]??oo(f),options:f,listsAsArrays:p},U));return P.jsxs(ki,{"data-testid":w,className:o,title:a,disabled:y,children:[D[0],m,D[1]]})}switch(c){case"select":case"multiselect":return P.jsx(b,{...v,path:u,level:h,className:o,handleOnChange:r,options:f,value:n,disabled:y,title:a,multiple:c==="multiselect",listsAsArrays:p});case"textarea":return P.jsx(J6e,{value:n,title:a,disabled:y,className:o,placeholder:A,onChange:D=>r(D.target.value),...S});case"switch":return P.jsx(j6e,{checked:!!n,title:a,disabled:y,className:o,onChange:D=>r(D.target.checked),...S});case"checkbox":return P.jsx(vf,{className:o,title:a,onChange:D=>r(D.target.checked),checked:!!n,disabled:y,...S});case"radio":return P.jsx(ki,{className:o,title:a,component:"fieldset",disabled:y,...S,children:P.jsx(N6e,{value:n,onChange:D=>r(D.target.value),children:f.map(D=>P.jsx(M6e,{disabled:y,value:D.name,label:D.label},D.name))})})}return P.jsx(Pn,{type:R,value:n,title:a,disabled:y,className:o,placeholder:A,onChange:D=>r(hN(D.target.value,{parseNumbers:_})),...S})},PGe=(d=[])=>{if(uN(d)){const e=[];for(const t of d)e.push(P.jsx(Er,{children:P.jsx(ot,{level:"body-xs",sx:{textTransform:"uppercase"},children:t.label})}),...t.options.map(s=>P.jsx(ef,{value:s.name,children:s.label},s.name)));return e}return Array.isArray(d)?d.map(e=>{const{name:t,label:s}=e;return P.jsx(ef,{value:t,children:s},t)}):null},IGe=({className:d,handleOnChange:e,options:t,value:s,disabled:i,title:n,multiple:r,listsAsArrays:a,testID:o,rule:c,rules:u,level:h,path:l,context:f,validation:p,operator:m,field:g,fieldData:y,schema:w,defaultValue:b,...S})=>{const{onChange:v,val:C}=j$({handleOnChange:e,listsAsArrays:a,multiple:r,value:s});return P.jsx(ki,{className:d,title:n,disabled:i,children:P.jsx(fb,{value:C,onChange:(M,_)=>v(_),multiple:r,disabled:i,...S,children:PGe(t)})})},CGe=d=>{const e=bde();return P.jsxs(P.Fragment,{children:[P.jsx(p8,{styles:{".queryBuilder":{".ruleGroup-header":{alignItems:"center",display:"flex",gap:8},".ruleGroup":{background:e.palette.background.surface,borderRadius:"var(--Card-radius)",display:"flex",flexDirection:"column",gap:8,".ruleGroup":{padding:".5rem",border:`1px solid ${e.palette.neutral.outlinedBorder}`}},".ruleGroup-body":{display:"flex",flexDirection:"column",gap:8},".rule":{alignItems:"center",display:"flex",gap:8}}}}),P.jsx(SGe,{...d,controlElements:{actionElement:TGe,valueEditor:xGe,valueSelector:IGe}},void 0)]})},IC=[{name:"=",value:"=",label:"="},{name:"!=",value:"!=",label:"!="},{name:"<",value:"<",label:"<"},{name:">",value:">",label:">"},{name:"<=",value:"<=",label:"<="},{name:">=",value:">=",label:">="}],MGe=[{name:"RSI",label:"RSI",operators:IC,defaultValue:U8},{name:"SMA",label:"SMA",operators:IC,defaultValue:Uue},{name:"EMA",label:"EMA",operators:IC,defaultValue:Wue}],_Ge=({debug:d})=>{const e=Zd(),t=Gn(bhe);return P.jsxs(P.Fragment,{children:[P.jsx(CGe,{fields:MGe,query:t,onQueryChange:s=>e(ahe(s))}),d?P.jsx(_t,{children:P.jsx("pre",{children:JSON.stringify(t,null,2)})}):null]})},AGe=()=>P.jsxs(fn,{children:[P.jsx(ot,{level:"title-lg",children:"Entry order"}),P.jsx(Ia,{}),P.jsxs(It,{container:!0,spacing:2,children:[P.jsx(It,{md:6,xs:12,children:P.jsx(t8e,{})}),P.jsx(It,{md:6,xs:12,children:P.jsx(i8e,{})})]}),P.jsx(Ia,{}),P.jsx(ot,{level:"title-sm",children:"Entry condition"}),P.jsx(_Ge,{})]}),LGe=d=>{const{disabled:e,readOnly:t}=d,s=Zd(),{value:i,onChange:n,onBlur:r}=iN({state:Gn(z8),action:a=>s(dhe(a)),allowEmpty:!1});return P.jsxs(ki,{children:[P.jsx(zi,{children:"Take profit %"}),P.jsx(Pn,{autoComplete:"off",disabled:e,onBlur:r,onChange:n,readOnly:t,required:!0,value:i})]})},BGe=()=>P.jsxs(fn,{children:[P.jsx(ot,{level:"title-lg",children:"Take profit"}),P.jsx(Ia,{}),P.jsx(It,{container:!0,spacing:2,children:P.jsx(It,{md:6,xs:12,children:P.jsx(LGe,{})})})]}),NGe=d=>{const{className:e,index:t}=d,s=Zd();return P.jsx(Es,{className:e,color:"danger",onClick:()=>s(uhe(t)),size:"sm",children:"Remove"})};function EGe(d){return{decimalScale:d.decimals.price}}function RGe(d,e){var n,r,a,o,c,u;if(d.length===0)return null;const t=new Ro(d),s=(n=e.limits.price)!=null&&n.min?t.lt((r=e.limits.price)==null?void 0:r.min):null,i=(a=e.limits.price)!=null&&a.max?t.gte((o=e.limits.price)==null?void 0:o.max):null;return s?`Price cannot be lower than MIN: ${(c=e.limits.price)==null?void 0:c.min}`:i?`Price cannot be higher than MAX: ${(u=e.limits.price)==null?void 0:u.max}`:null}const DGe=d=>{const{value:e,onChange:t,filter:s,label:i,...n}=d,r=EGe(s),a=RGe(e,s);return P.jsxs(ki,{error:!!a,children:[P.jsx(zi,{children:i}),P.jsx(Pn,{onChange:t,slotProps:{input:{component:L$,NumericFormatProps:r}},value:e,...n}),a?P.jsx(Gm,{children:a}):null]})},qGe=({className:d,index:e})=>{const t=Zd(),s=Gn(tO),[i]=kt.symbol.getOne.useSuspenseQuery({symbolId:s}),{priceDeviation:n}=Gn(K8(e)),{value:r,onChange:a,onBlur:o}=iN({state:n,action:c=>{c!==""&&t(hhe({index:e,priceDeviation:c}))},allowEmpty:!0});return P.jsx(DGe,{className:d,filter:i.filters,fullWidth:!0,label:"Price deviation %",onBlur:o,onChange:a,size:"sm",value:r})},VGe=d=>{const{className:e,index:t,disabled:s}=d,i=Zd(),n=Gn(tO),[r]=kt.symbol.getOne.useSuspenseQuery({symbolId:n}),{quantity:a}=Gn(K8(t)),{value:o,onChange:c,onBlur:u}=iN({state:a,action:h=>{h!==""&&i(lhe({index:t,quantity:h}))},allowEmpty:!0});return P.jsx(B$,{className:e,disabled:s,filter:r.filters,fullWidth:!0,label:"Quantity",onBlur:u,onChange:c,size:"sm",value:o})},FGe=({index:d})=>P.jsxs(It,{alignItems:"flex-end",container:!0,spacing:2,children:[P.jsx(It,{xs:!0,children:P.jsx(B.Suspense,{fallback:P.jsx(mi,{height:36,variant:"rectangular",width:200}),children:P.jsx(qGe,{index:d})})}),P.jsx(It,{xs:!0,children:P.jsx(B.Suspense,{fallback:P.jsx(mi,{height:36,variant:"rectangular",width:200}),children:P.jsx(VGe,{index:d})})}),P.jsx(It,{xs:"auto",children:P.jsx(NGe,{index:d})})]}),HGe=()=>{const d=Zd(),e=Gn($8),t=e.at(-1),s=()=>{d(bq(t?{priceDeviation:t.priceDeviation+1,quantity:t.quantity}:{priceDeviation:_A,quantity:G8}))};return P.jsxs(It,{container:!0,spacing:2,children:[P.jsx(It,{xs:12,children:e.map((i,n)=>P.jsx(FGe,{index:n},n))}),P.jsx(It,{xs:12,children:P.jsx(Es,{onClick:s,children:"Add"})})]})};function GGe(){const d=B.useRef(!0);return d.current?(d.current=!1,!0):d.current}function UGe(){const[d]=kt.exchangeAccount.list.useSuspenseQuery(),e=d[0],[t]=kt.symbol.list.useSuspenseQuery(e.exchangeCode),s=t.find(r=>r.currencyPair==="BTC/USDT")||t[0],[{price:i}]=kt.symbol.price.useSuspenseQuery({symbolId:s.symbolId}),[{price:n}]=kt.dcaBot.formOptions.useSuspenseQuery({symbolId:s.symbolId});return{exchangeAccount:e,symbol:s,currentAssetPrice:i,price:n}}function WGe(){var g;const d=Zd(),{exchangeAccount:e,symbol:t,currentAssetPrice:s}=UGe();if(GGe()){d($ue(e.id)),d(Xue(e.exchangeCode)),d(Que(t.symbolId)),d(Zue(tN()));const y=(g=t.filters.limits.amount)!=null&&g.min?t.filters.limits.amount.min*10:"";d(ihe(y.toString())),d(the(CA.Market)),d(rhe(W8)),d(ohe(H8)),d(che([{priceDeviation:_A,quantity:y||G8}]))}const n=Gn(ghe),[r]=kt.exchangeAccount.getOne.useSuspenseQuery(n),a=Gn(tO),[o]=kt.symbol.getOne.useSuspenseQuery({symbolId:a}),c=Gn(phe),u=Gn(mhe),h=y=>d(ehe(y)),l=Gn($8),f=Gn(z8),{handleSubmit:p,isLoading:m}=yHe();return P.jsx(It,{container:!0,spacing:2,children:P.jsxs(xO,{children:[P.jsx(It,{md:9,children:P.jsx(OHe,{barSize:u,currentAssetPrice:s,safetyOrders:l,takeProfitPercent:f,onBarSizeChange:h,symbolId:a})}),P.jsxs(It,{md:3,children:[P.jsx(ot,{level:"h2",sx:{mb:1},children:"Bot settings"}),P.jsx(B.Suspense,{fallback:P.jsx(mi,{animation:"wave",height:300,sx:{borderRadius:8},variant:"rectangular",width:"100%"}),children:P.jsx(T$,{hideTimeframe:!0,isLoading:m,onSubmit:p,botName:c,onBotNameChange:y=>d(Jue(y)),exchangeAccount:r,onExchangeAccountChange:({id:y})=>d(Kue(y)),symbol:o,onSymbolChange:({symbolId:y})=>d(Yue(y))})})]}),P.jsx(It,{md:9,children:P.jsxs(_t,{display:"flex",flexDirection:"column",gap:2,children:[P.jsx(AGe,{}),P.jsx(BGe,{}),P.jsxs(fn,{children:[P.jsx(ot,{level:"title-lg",children:"Safety orders"}),P.jsx(Ia,{}),P.jsx(HGe,{})]})]})}),P.jsx(It,{md:3})]})})}const jGe=vr("/_layout/dashboard/dca-bot/create")({component:WGe}),zGe=Ys(P.jsx("path",{d:"M9 18h12v-2H9zM3 6v2h18V6zm6 7h12v-2H9z"}),"Segment"),$Ge=({bot:d})=>P.jsxs(Dh,{children:[P.jsx(RL,{bot:d}),P.jsx(fr,{inset:"startContent"}),P.jsx(qL,{bot:d}),P.jsx(fr,{inset:"startContent"}),P.jsxs(Id,{icon:P.jsx(KW,{}),name:"Target TP",children:[d.settings.tp.percent,"%"]}),P.jsx(fr,{inset:"startContent"}),P.jsx(Id,{icon:P.jsx(zGe,{}),name:"Safety orders",children:d.settings.safetyOrders.length}),P.jsx(fr,{inset:"startContent"}),P.jsx(Id,{icon:P.jsx(EL,{}),name:"Template",children:P.jsx(In,{title:P.jsx("pre",{children:JSON.stringify(d.settings,null,2)}),children:P.jsx(nn,{color:"primary",variant:"soft",children:d.template})})})]}),KGe=({botId:d})=>{const[e]=kt.dcaBot.getOne.useSuspenseQuery(d),[t]=go();return P.jsxs(fn,{children:[P.jsxs(_t,{display:"flex",justifyContent:"space-between",children:[P.jsx(ot,{fontSize:"xl2",fontWeight:"xl",level:"h3",children:e.name}),P.jsxs(ot,{color:"neutral",fontSize:"xl2",fontWeight:"xl",level:"h3",children:["#",e.id]})]}),P.jsx($Ge,{bot:e}),P.jsx(NL,{children:P.jsx(AL,{bot:e})}),P.jsxs(ML,{children:[P.jsx(LL,{bot:e,href:ai("dca-bot/edit/:id",e.id)}),P.jsx(BL,{bot:e,redirectPath:ai("bot")}),t?P.jsxs(P.Fragment,{children:[P.jsx(Ia,{children:"Debugging"}),P.jsx(PL,{polling:!1}),P.jsx(_L,{bot:e})]}):null]})]})};function XGe(d){const{botId:e}=d,[t]=go(),[s,i]=B.useState(["Filled"]),[n,r]=B.useState("Orders");return P.jsxs(It,{container:!0,spacing:2,children:[P.jsxs(It,{md:9,children:[P.jsx(B.Suspense,{fallback:P.jsx(mi,{animation:"wave",height:Xo,sx:{borderRadius:8},variant:"rectangular",width:"100%"}),children:P.jsx(THe,{botId:e})}),P.jsx(_t,{sx:{mt:2}}),P.jsx(B.Suspense,{fallback:P.jsx(mi,{animation:"wave",height:250,sx:{borderRadius:8},variant:"rectangular",width:"100%"}),children:P.jsxs(xL,{value:n,onChange:r,actions:n==="Orders"&&t?P.jsx(eN,{value:s,onChange:i}):null,children:[n==="Orders"?P.jsx(JB,{botId:e,filterOrderStatuses:s,displayEntityType:!0}):null,n==="SmartTrades"?P.jsx(YB,{botId:e}):null,n==="StrategyLogs"?P.jsx(OL,{botId:e}):null]})})]}),P.jsxs(It,{md:3,children:[P.jsx(B.Suspense,{fallback:P.jsx(mi,{animation:"wave",height:Xo,sx:{borderRadius:8},variant:"rectangular",width:"100%"}),children:P.jsx(KGe,{botId:e})}),P.jsx(_t,{sx:{mt:2}}),P.jsx(B.Suspense,{fallback:P.jsx(mi,{animation:"wave",height:250,sx:{borderRadius:8},variant:"rectangular",width:"100%"}),children:P.jsx(QB,{botId:e})})]})]})}const K$=vr("/_layout/dashboard/dca-bot/$id")({component:()=>{const{id:d}=K$.useParams();return P.jsx(XGe,{botId:Number(d)})}});var eT={exports:{}};/** * @license * Lodash * Copyright OpenJS Foundation and other contributors @@ -305,14 +305,14 @@ __p += '`),ks&&(Ke+=`' + function print() { __p += __j.call(arguments, '') } `:`; `)+Ke+`return __p -}`;var us=yR(function(){return Ls(ue,At+"return "+Ke).apply(t,pe)});if(us.source=Ke,lP(us))throw us;return us}function WJ(k){return Ds(k).toLowerCase()}function jJ(k){return Ds(k).toUpperCase()}function zJ(k,O,E){if(k=Ds(k),k&&(E||O===t))return PN(k);if(!k||!(O=Jr(O)))return k;var H=wo(k),ee=wo(O),ue=IN(H,ee),pe=CN(H,ee)+1;return wu(H,ue,pe).join("")}function $J(k,O,E){if(k=Ds(k),k&&(E||O===t))return k.slice(0,_N(k)+1);if(!k||!(O=Jr(O)))return k;var H=wo(k),ee=CN(H,wo(O))+1;return wu(H,0,ee).join("")}function KJ(k,O,E){if(k=Ds(k),k&&(E||O===t))return k.replace(La,"");if(!k||!(O=Jr(O)))return k;var H=wo(k),ee=IN(H,wo(O));return wu(H,ee).join("")}function XJ(k,O){var E=A,H=R;if(Ti(O)){var ee="separator"in O?O.separator:ee;E="length"in O?cs(O.length):E,H="omission"in O?Jr(O.omission):H}k=Ds(k);var ue=k.length;if(Vf(k)){var pe=wo(k);ue=pe.length}if(E>=ue)return k;var be=E-Ff(H);if(be<1)return H;var Oe=pe?wu(pe,0,be).join(""):k.slice(0,be);if(ee===t)return Oe+H;if(pe&&(be+=Oe.length-be),fP(ee)){if(k.slice(be).search(ee)){var We,je=Oe;for(ee.global||(ee=Mx(ee.source,Ds(xe.exec(ee))+"g")),ee.lastIndex=0;We=ee.exec(je);)var Ke=We.index;Oe=Oe.slice(0,Ke===t?be:Ke)}}else if(k.indexOf(Jr(ee),be)!=be){var pt=Oe.lastIndexOf(ee);pt>-1&&(Oe=Oe.slice(0,pt))}return Oe+H}function QJ(k){return k=Ds(k),k&&ls.test(k)?k.replace(bt,xK):k}var YJ=$f(function(k,O,E){return k+(E?" ":"")+O.toUpperCase()}),gP=wE("toUpperCase");function gR(k,O,E){return k=Ds(k),O=E?t:O,O===t?kK(k)?CK(k):hK(k):k.match(O)||[]}var yR=fs(function(k,O){try{return Yr(k,t,O)}catch(E){return lP(E)?E:new ss(E)}}),ZJ=ac(function(k,O){return Na(O,function(E){E=dd(E),nc(k,E,uP(k[E],k))}),k});function JJ(k){var O=k==null?0:k.length,E=Ht();return k=O?gi(k,function(H){if(typeof H[1]!="function")throw new Ea(r);return[E(H[0]),H[1]]}):[],fs(function(H){for(var ee=-1;++eeY)return[];var E=te,H=Kn(k,te);O=Ht(O),k-=te;for(var ee=Px(H,O);++E0||O<0)?new bs(E):(k<0?E=E.takeRight(-k):k&&(E=E.drop(k)),O!==t&&(O=cs(O),E=O<0?E.dropRight(-O):E.take(O-k)),E)},bs.prototype.takeRightWhile=function(k){return this.reverse().takeWhile(k).reverse()},bs.prototype.toArray=function(){return this.take(te)},ad(bs.prototype,function(k,O){var E=/^(?:filter|find|map|reject)|While$/.test(O),H=/^(?:head|last)$/.test(O),ee=ae[H?"take"+(O=="last"?"Right":""):O],ue=H||/^find/.test(O);ee&&(ae.prototype[O]=function(){var pe=this.__wrapped__,be=H?[1]:arguments,Oe=pe instanceof bs,We=be[0],je=Oe||rs(pe),Ke=function(gs){var ks=ee.apply(ae,lu([gs],be));return H&&pt?ks[0]:ks};je&&E&&typeof We=="function"&&We.length!=1&&(Oe=je=!1);var pt=this.__chain__,At=!!this.__actions__.length,Wt=ue&&!pt,us=Oe&&!At;if(!ue&&je){pe=us?pe:new bs(this);var jt=k.apply(pe,be);return jt.__actions__.push({func:Lk,args:[Ke],thisArg:t}),new Ra(jt,pt)}return Wt&&us?k.apply(this,be):(jt=this.thru(Ke),Wt?H?jt.value()[0]:jt.value():jt)})}),Na(["pop","push","shift","sort","splice","unshift"],function(k){var O=nk[k],E=/^(?:push|sort|unshift)$/.test(k)?"tap":"thru",H=/^(?:pop|shift)$/.test(k);ae.prototype[k]=function(){var ee=arguments;if(H&&!this.__chain__){var ue=this.value();return O.apply(rs(ue)?ue:[],ee)}return this[E](function(pe){return O.apply(rs(pe)?pe:[],ee)})}}),ad(bs.prototype,function(k,O){var E=ae[O];if(E){var H=E.name+"";Gs.call(Wf,H)||(Wf[H]=[]),Wf[H].push({name:O,func:E})}}),Wf[xk(t,y).name]=[{name:"wrapper",func:t}],bs.prototype.clone=QK,bs.prototype.reverse=YK,bs.prototype.value=ZK,ae.prototype.at=IY,ae.prototype.chain=CY,ae.prototype.commit=MY,ae.prototype.next=_Y,ae.prototype.plant=LY,ae.prototype.reverse=BY,ae.prototype.toJSON=ae.prototype.valueOf=ae.prototype.value=NY,ae.prototype.first=ae.prototype.head,Dg&&(ae.prototype[Dg]=AY),ae},Hf=MK();rd?((rd.exports=Hf)._=Hf,Rf._=Hf):Ji._=Hf}).call(Sc)})(eT,eT.exports);var KGe=eT.exports;const bl=sT(KGe),XGe={};function QGe(d,e){switch(e.type){case"set":return Gr(d,t=>{bl.set(t,e.path,e.value)});case"arr.push":{const t=bl.get(d,e.path)||[],s=`${e.path}[${t.length}]`;return Gr(d,i=>{bl.set(i,s,e.value)})}case"arr.rm":return Gr(d,t=>{const i=bl.get(t,e.path).filter((n,r)=>r!==e.index);bl.set(t,e.path,i)});case"reset":return e.defaultState?e.defaultState:{}}return console.warn("Unrecognized action type",e),d}const X$=B.createContext(void 0),Q$=({children:d,initialState:e})=>{const[t,s]=B.useReducer(QGe,e||XGe);return P.jsx(X$.Provider,{value:{state:t,dispatch:s},children:d})},bg=()=>{const d=B.useContext(X$);if(d===void 0)throw new Error('"useStrategyParams" must be used within a ');return d},YGe=d=>{const{state:e,dispatch:t}=bg();return[bl.get(e,d)||"",n=>{t({type:"set",path:d,value:n})}]},ZGe=d=>{const{state:e,dispatch:t}=bg(),s=bl.get(e,d)||[];return{value:s,setValue:a=>t({type:"set",path:d,value:a}),push:a=>t({type:"arr.push",path:d,value:a}),remove:a=>t({type:"arr.rm",path:d,index:a}),length:s.length}};function fN(d,e){return{path:d?`${d}.${e}`:e}}function Ew(d){function e(t){if(t.default!==void 0)return t.default;if(t.type==="object"&&t.properties){const s={};for(const[i,n]of Object.entries(t.properties))s[i]=e(n);return s}if(t.type==="array"&&t.items)return[e(t.items)];if(t.type==="string"||t.type==="number")return""}return e(d)}const pN=d=>"type"in d&&d.type==="object"&&"properties"in d&&!!d.properties,JGe=d=>"type"in d&&d.type==="array"&&"items"in d&&!!d.items,eUe=Ys(P.jsx("path",{d:"M9.4 16.6 4.8 12l4.6-4.6L8 6l-6 6 6 6zm5.2 0 4.6-4.6-4.6-4.6L16 6l6 6-6 6z"}),"Code"),tUe=({name:d,basePath:e,schema:t})=>{const{path:s}=fN(e,d),[i,n]=YGe(s),r="type"in t&&(t.type==="number"||t.type==="integer"),[a,o]=B.useState(i.toString());B.useEffect(()=>{o(i.toString())},[i]);const c=l=>{o(l.target.value)},u=()=>{if(a.length===0){n("");return}r?!isNaN(Number(a))?n(Number(a)):o(i.toString()):n(a)},h=a.length===0?"Must be defined":"";return"type"in t?P.jsxs(ki,{error:!!h,children:[P.jsxs(zi,{children:[d,P.jsx(In,{size:"sm",title:P.jsxs("div",{children:["path: ",s]}),children:P.jsx(eUe,{fontSize:"small"})})]}),P.jsx(Pn,{onBlur:u,onChange:c,value:a}),h?P.jsx(Gm,{children:h}):t.description?P.jsx(Gm,{children:t.description}):null]}):P.jsxs("div",{children:["Unsupported input: ",JSON.stringify(t)]})},sUe=Ys(P.jsx("path",{d:"M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m-2 10h-4v4h-2v-4H7v-2h4V7h2v4h4z"}),"AddBox"),iUe=({name:d,basePath:e,schema:t})=>{const{path:s}=fN(e,d),i=ZGe(s),{items:n}=t;return n?pN(n)?P.jsxs(fn,{children:[P.jsxs(_t,{sx:{display:"flex",justifyContent:"space-between"},children:[P.jsxs(ot,{children:["array: ",P.jsx(ot,{level:"body-sm",children:d})]}),P.jsx(Vd,{children:P.jsx(sUe,{onClick:()=>i.push(Ew(n))})})]}),Array.from({length:i.length}).map((r,a)=>P.jsx(mN,{action:P.jsx(Vd,{onClick:()=>i.remove(a),children:P.jsx(yW,{})}),basePath:e,name:`${d}[${a}]`,schema:n},a))]}):P.jsxs("div",{children:["Unsupported array `",d,"` items schema: ",JSON.stringify(t)]}):P.jsxs("div",{children:["Schema missing `items` property: ",JSON.stringify(t)]})},mN=({name:d,basePath:e,schema:t,action:s,root:i})=>{const{path:n}=fN(e,d),r=Object.entries(t.properties).flatMap(([a,o])=>"type"in o?JGe(o)?P.jsx(iUe,{basePath:n,name:a,schema:o}):pN(o)?P.jsx(mN,{basePath:n,name:a,schema:o}):o.type==="string"||o.type==="number"||o.type==="boolean"?P.jsx(tUe,{basePath:n,name:a,schema:o}):P.jsxs("div",{children:["Unsupported schema: ",JSON.stringify(o)]},a):null);return i?P.jsx(_t,{sx:{display:"grid",gap:2,flexWrap:"wrap"},children:r}):P.jsxs(fn,{children:[P.jsxs(_t,{sx:{display:"flex",justifyContent:"space-between"},children:[P.jsxs(ot,{children:["object: ",P.jsx(ot,{level:"body-sm",children:d})]}),s]}),r]})},Y$=({schema:d,debug:e})=>{const{state:t,dispatch:s}=bg();return cm(d)&&s({type:"reset",defaultState:Ew(d)}),pN(d)?P.jsxs(P.Fragment,{children:[P.jsx(mN,{basePath:"",name:"",root:!0,schema:d}),e?P.jsxs(fn,{children:[P.jsx(ot,{children:"State"}),P.jsx("pre",{children:JSON.stringify(t,null,2)})]}):null,e?P.jsxs(fn,{children:[P.jsx(ot,{children:"Schema"}),P.jsx("pre",{children:JSON.stringify(d,null,2)})]}):null]}):P.jsxs("div",{children:["Unsupported schema. It must be object type. Schema: ",JSON.stringify(d)]})},Z$=({strategy:d})=>P.jsx(fn,{children:P.jsxs(ot,{children:["Strategy ",P.jsx("strong",{children:d})," has no params"]})}),nUe=({value:d,onChange:e,templates:t})=>{const[s]=go(),i=Object.fromEntries(Object.entries(t).filter(([r,a])=>!a.hidden)),n=s?t:i;return P.jsx(fb,{onChange:(r,a)=>e(a),required:!0,value:d,children:Object.keys(n).map(r=>P.jsx(ef,{value:r,children:r},r))})},J$=({value:d,onChange:e,templates:t})=>P.jsxs(ki,{children:[P.jsx(zi,{children:"Strategy"}),P.jsx(nUe,{onChange:e,value:d,templates:t})]}),eK=(d,e)=>d.anyOf.length?d.anyOf.length===1?Mn(d.anyOf[0],{...e,path:[...e.path,"anyOf",0]}):`z.union([${d.anyOf.map((t,s)=>Mn(t,{...e,path:[...e.path,"anyOf",s]})).join(", ")}])`:"z.any()",rUe=d=>"z.boolean()",aUe=d=>"z.any()",oUe=(d,e)=>`z.union([${d.type.map(t=>Mn({...d,type:t},e)).join(", ")}])`,dUe=(d,e)=>`z.any().refine((value) => !${Mn(d.not,{...e,path:[...e.path,"not"]})}.safeParse(value).success, "Invalid input: Should NOT be valid against schema")`,cUe=d=>"z.null()",uUe=d=>[d.slice(0,d.length/2),d.slice(d.length/2)],Fy=Symbol("Original index"),hUe=d=>{let e=[];for(let t=0;t{if(Array.isArray(d.items))return`z.tuple([${d.items.map((s,i)=>Mn(s,{...e,path:[...e.path,"items",i]}))}])`;let t=d.items?`z.array(${Mn(d.items,{...e,path:[...e.path,"items"]})})`:"z.array(z.any())";return t+=bn(d,"minItems",({json:s})=>[`.min(${s}`,", ",")"]),t+=bn(d,"maxItems",({json:s})=>[`.max(${s}`,", ",")"]),t},fUe=d=>`z.literal(${JSON.stringify(d.const)})`,pUe=d=>d.enum.length===0?"z.never()":d.enum.length===1?`z.literal(${JSON.stringify(d.enum[0])})`:d.enum.every(e=>typeof e=="string")?`z.enum([${d.enum.map(e=>JSON.stringify(e))}])`:`z.union([${d.enum.map(e=>`z.literal(${JSON.stringify(e)})`).join(", ")}])`,mUe=(d,e)=>{const t=Mn(d.if,{...e,path:[...e.path,"if"]}),s=Mn(d.then,{...e,path:[...e.path,"then"]}),i=Mn(d.else,{...e,path:[...e.path,"else"]});return`z.union([${s}, ${i}]).superRefine((value,ctx) => { +}`;var us=yR(function(){return Ls(ue,At+"return "+Ke).apply(t,pe)});if(us.source=Ke,lP(us))throw us;return us}function WJ(k){return Ds(k).toLowerCase()}function jJ(k){return Ds(k).toUpperCase()}function zJ(k,O,E){if(k=Ds(k),k&&(E||O===t))return PN(k);if(!k||!(O=Jr(O)))return k;var H=wo(k),ee=wo(O),ue=IN(H,ee),pe=CN(H,ee)+1;return wu(H,ue,pe).join("")}function $J(k,O,E){if(k=Ds(k),k&&(E||O===t))return k.slice(0,_N(k)+1);if(!k||!(O=Jr(O)))return k;var H=wo(k),ee=CN(H,wo(O))+1;return wu(H,0,ee).join("")}function KJ(k,O,E){if(k=Ds(k),k&&(E||O===t))return k.replace(La,"");if(!k||!(O=Jr(O)))return k;var H=wo(k),ee=IN(H,wo(O));return wu(H,ee).join("")}function XJ(k,O){var E=A,H=R;if(Ti(O)){var ee="separator"in O?O.separator:ee;E="length"in O?cs(O.length):E,H="omission"in O?Jr(O.omission):H}k=Ds(k);var ue=k.length;if(Vf(k)){var pe=wo(k);ue=pe.length}if(E>=ue)return k;var be=E-Ff(H);if(be<1)return H;var Oe=pe?wu(pe,0,be).join(""):k.slice(0,be);if(ee===t)return Oe+H;if(pe&&(be+=Oe.length-be),fP(ee)){if(k.slice(be).search(ee)){var We,je=Oe;for(ee.global||(ee=Mx(ee.source,Ds(xe.exec(ee))+"g")),ee.lastIndex=0;We=ee.exec(je);)var Ke=We.index;Oe=Oe.slice(0,Ke===t?be:Ke)}}else if(k.indexOf(Jr(ee),be)!=be){var pt=Oe.lastIndexOf(ee);pt>-1&&(Oe=Oe.slice(0,pt))}return Oe+H}function QJ(k){return k=Ds(k),k&&ls.test(k)?k.replace(bt,xK):k}var YJ=$f(function(k,O,E){return k+(E?" ":"")+O.toUpperCase()}),gP=wE("toUpperCase");function gR(k,O,E){return k=Ds(k),O=E?t:O,O===t?kK(k)?CK(k):hK(k):k.match(O)||[]}var yR=fs(function(k,O){try{return Yr(k,t,O)}catch(E){return lP(E)?E:new ss(E)}}),ZJ=ac(function(k,O){return Na(O,function(E){E=dd(E),nc(k,E,uP(k[E],k))}),k});function JJ(k){var O=k==null?0:k.length,E=Ht();return k=O?gi(k,function(H){if(typeof H[1]!="function")throw new Ea(r);return[E(H[0]),H[1]]}):[],fs(function(H){for(var ee=-1;++eeY)return[];var E=te,H=Kn(k,te);O=Ht(O),k-=te;for(var ee=Px(H,O);++E0||O<0)?new bs(E):(k<0?E=E.takeRight(-k):k&&(E=E.drop(k)),O!==t&&(O=cs(O),E=O<0?E.dropRight(-O):E.take(O-k)),E)},bs.prototype.takeRightWhile=function(k){return this.reverse().takeWhile(k).reverse()},bs.prototype.toArray=function(){return this.take(te)},ad(bs.prototype,function(k,O){var E=/^(?:filter|find|map|reject)|While$/.test(O),H=/^(?:head|last)$/.test(O),ee=ae[H?"take"+(O=="last"?"Right":""):O],ue=H||/^find/.test(O);ee&&(ae.prototype[O]=function(){var pe=this.__wrapped__,be=H?[1]:arguments,Oe=pe instanceof bs,We=be[0],je=Oe||rs(pe),Ke=function(gs){var ks=ee.apply(ae,lu([gs],be));return H&&pt?ks[0]:ks};je&&E&&typeof We=="function"&&We.length!=1&&(Oe=je=!1);var pt=this.__chain__,At=!!this.__actions__.length,Wt=ue&&!pt,us=Oe&&!At;if(!ue&&je){pe=us?pe:new bs(this);var jt=k.apply(pe,be);return jt.__actions__.push({func:Lk,args:[Ke],thisArg:t}),new Ra(jt,pt)}return Wt&&us?k.apply(this,be):(jt=this.thru(Ke),Wt?H?jt.value()[0]:jt.value():jt)})}),Na(["pop","push","shift","sort","splice","unshift"],function(k){var O=nk[k],E=/^(?:push|sort|unshift)$/.test(k)?"tap":"thru",H=/^(?:pop|shift)$/.test(k);ae.prototype[k]=function(){var ee=arguments;if(H&&!this.__chain__){var ue=this.value();return O.apply(rs(ue)?ue:[],ee)}return this[E](function(pe){return O.apply(rs(pe)?pe:[],ee)})}}),ad(bs.prototype,function(k,O){var E=ae[O];if(E){var H=E.name+"";Gs.call(Wf,H)||(Wf[H]=[]),Wf[H].push({name:O,func:E})}}),Wf[xk(t,y).name]=[{name:"wrapper",func:t}],bs.prototype.clone=QK,bs.prototype.reverse=YK,bs.prototype.value=ZK,ae.prototype.at=IY,ae.prototype.chain=CY,ae.prototype.commit=MY,ae.prototype.next=_Y,ae.prototype.plant=LY,ae.prototype.reverse=BY,ae.prototype.toJSON=ae.prototype.valueOf=ae.prototype.value=NY,ae.prototype.first=ae.prototype.head,Dg&&(ae.prototype[Dg]=AY),ae},Hf=MK();rd?((rd.exports=Hf)._=Hf,Rf._=Hf):Ji._=Hf}).call(Sc)})(eT,eT.exports);var QGe=eT.exports;const bl=sT(QGe),YGe={};function ZGe(d,e){switch(e.type){case"set":return Gr(d,t=>{bl.set(t,e.path,e.value)});case"arr.push":{const t=bl.get(d,e.path)||[],s=`${e.path}[${t.length}]`;return Gr(d,i=>{bl.set(i,s,e.value)})}case"arr.rm":return Gr(d,t=>{const i=bl.get(t,e.path).filter((n,r)=>r!==e.index);bl.set(t,e.path,i)});case"reset":return e.defaultState?e.defaultState:{}}return console.warn("Unrecognized action type",e),d}const X$=B.createContext(void 0),Q$=({children:d,initialState:e})=>{const[t,s]=B.useReducer(ZGe,e||YGe);return P.jsx(X$.Provider,{value:{state:t,dispatch:s},children:d})},bg=()=>{const d=B.useContext(X$);if(d===void 0)throw new Error('"useStrategyParams" must be used within a ');return d},JGe=d=>{const{state:e,dispatch:t}=bg();return[bl.get(e,d)||"",n=>{t({type:"set",path:d,value:n})}]},eUe=d=>{const{state:e,dispatch:t}=bg(),s=bl.get(e,d)||[];return{value:s,setValue:a=>t({type:"set",path:d,value:a}),push:a=>t({type:"arr.push",path:d,value:a}),remove:a=>t({type:"arr.rm",path:d,index:a}),length:s.length}};function fN(d,e){return{path:d?`${d}.${e}`:e}}function Ew(d){function e(t){if(t.default!==void 0)return t.default;if(t.type==="object"&&t.properties){const s={};for(const[i,n]of Object.entries(t.properties))s[i]=e(n);return s}if(t.type==="array"&&t.items)return[e(t.items)];if(t.type==="string"||t.type==="number")return""}return e(d)}const pN=d=>"type"in d&&d.type==="object"&&"properties"in d&&!!d.properties,tUe=d=>"type"in d&&d.type==="array"&&"items"in d&&!!d.items,sUe=Ys(P.jsx("path",{d:"M9.4 16.6 4.8 12l4.6-4.6L8 6l-6 6 6 6zm5.2 0 4.6-4.6-4.6-4.6L16 6l6 6-6 6z"}),"Code"),iUe=({name:d,basePath:e,schema:t})=>{const{path:s}=fN(e,d),[i,n]=JGe(s),r="type"in t&&(t.type==="number"||t.type==="integer"),[a,o]=B.useState(i.toString());B.useEffect(()=>{o(i.toString())},[i]);const c=l=>{o(l.target.value)},u=()=>{if(a.length===0){n("");return}r?!isNaN(Number(a))?n(Number(a)):o(i.toString()):n(a)},h=a.length===0?"Must be defined":"";return"type"in t?P.jsxs(ki,{error:!!h,children:[P.jsxs(zi,{children:[d,P.jsx(In,{size:"sm",title:P.jsxs("div",{children:["path: ",s]}),children:P.jsx(sUe,{fontSize:"small"})})]}),P.jsx(Pn,{onBlur:u,onChange:c,value:a}),h?P.jsx(Gm,{children:h}):t.description?P.jsx(Gm,{children:t.description}):null]}):P.jsxs("div",{children:["Unsupported input: ",JSON.stringify(t)]})},nUe=Ys(P.jsx("path",{d:"M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m-2 10h-4v4h-2v-4H7v-2h4V7h2v4h4z"}),"AddBox"),rUe=({name:d,basePath:e,schema:t})=>{const{path:s}=fN(e,d),i=eUe(s),{items:n}=t;return n?pN(n)?P.jsxs(fn,{children:[P.jsxs(_t,{sx:{display:"flex",justifyContent:"space-between"},children:[P.jsxs(ot,{children:["array: ",P.jsx(ot,{level:"body-sm",children:d})]}),P.jsx(Vd,{children:P.jsx(nUe,{onClick:()=>i.push(Ew(n))})})]}),Array.from({length:i.length}).map((r,a)=>P.jsx(mN,{action:P.jsx(Vd,{onClick:()=>i.remove(a),children:P.jsx(yW,{})}),basePath:e,name:`${d}[${a}]`,schema:n},a))]}):P.jsxs("div",{children:["Unsupported array `",d,"` items schema: ",JSON.stringify(t)]}):P.jsxs("div",{children:["Schema missing `items` property: ",JSON.stringify(t)]})},mN=({name:d,basePath:e,schema:t,action:s,root:i})=>{const{path:n}=fN(e,d),r=Object.entries(t.properties).flatMap(([a,o])=>"type"in o?tUe(o)?P.jsx(rUe,{basePath:n,name:a,schema:o}):pN(o)?P.jsx(mN,{basePath:n,name:a,schema:o}):o.type==="string"||o.type==="number"||o.type==="boolean"?P.jsx(iUe,{basePath:n,name:a,schema:o}):P.jsxs("div",{children:["Unsupported schema: ",JSON.stringify(o)]},a):null);return i?P.jsx(_t,{sx:{display:"grid",gap:2,flexWrap:"wrap"},children:r}):P.jsxs(fn,{children:[P.jsxs(_t,{sx:{display:"flex",justifyContent:"space-between"},children:[P.jsxs(ot,{children:["object: ",P.jsx(ot,{level:"body-sm",children:d})]}),s]}),r]})},Y$=({schema:d,debug:e})=>{const{state:t,dispatch:s}=bg();return cm(d)&&s({type:"reset",defaultState:Ew(d)}),pN(d)?P.jsxs(P.Fragment,{children:[P.jsx(mN,{basePath:"",name:"",root:!0,schema:d}),e?P.jsxs(fn,{children:[P.jsx(ot,{children:"State"}),P.jsx("pre",{children:JSON.stringify(t,null,2)})]}):null,e?P.jsxs(fn,{children:[P.jsx(ot,{children:"Schema"}),P.jsx("pre",{children:JSON.stringify(d,null,2)})]}):null]}):P.jsxs("div",{children:["Unsupported schema. It must be object type. Schema: ",JSON.stringify(d)]})},Z$=({strategy:d})=>P.jsx(fn,{children:P.jsxs(ot,{children:["Strategy ",P.jsx("strong",{children:d})," has no params"]})}),aUe=({value:d,onChange:e,templates:t})=>{const[s]=go(),i=Object.fromEntries(Object.entries(t).filter(([r,a])=>!a.hidden)),n=s?t:i;return P.jsx(fb,{onChange:(r,a)=>e(a),required:!0,value:d,children:Object.keys(n).map(r=>P.jsx(ef,{value:r,children:r},r))})},J$=({value:d,onChange:e,templates:t})=>P.jsxs(ki,{children:[P.jsx(zi,{children:"Strategy"}),P.jsx(aUe,{onChange:e,value:d,templates:t})]}),eK=(d,e)=>d.anyOf.length?d.anyOf.length===1?Mn(d.anyOf[0],{...e,path:[...e.path,"anyOf",0]}):`z.union([${d.anyOf.map((t,s)=>Mn(t,{...e,path:[...e.path,"anyOf",s]})).join(", ")}])`:"z.any()",oUe=d=>"z.boolean()",dUe=d=>"z.any()",cUe=(d,e)=>`z.union([${d.type.map(t=>Mn({...d,type:t},e)).join(", ")}])`,uUe=(d,e)=>`z.any().refine((value) => !${Mn(d.not,{...e,path:[...e.path,"not"]})}.safeParse(value).success, "Invalid input: Should NOT be valid against schema")`,hUe=d=>"z.null()",lUe=d=>[d.slice(0,d.length/2),d.slice(d.length/2)],Fy=Symbol("Original index"),fUe=d=>{let e=[];for(let t=0;t{if(Array.isArray(d.items))return`z.tuple([${d.items.map((s,i)=>Mn(s,{...e,path:[...e.path,"items",i]}))}])`;let t=d.items?`z.array(${Mn(d.items,{...e,path:[...e.path,"items"]})})`:"z.array(z.any())";return t+=bn(d,"minItems",({json:s})=>[`.min(${s}`,", ",")"]),t+=bn(d,"maxItems",({json:s})=>[`.max(${s}`,", ",")"]),t},mUe=d=>`z.literal(${JSON.stringify(d.const)})`,gUe=d=>d.enum.length===0?"z.never()":d.enum.length===1?`z.literal(${JSON.stringify(d.enum[0])})`:d.enum.every(e=>typeof e=="string")?`z.enum([${d.enum.map(e=>JSON.stringify(e))}])`:`z.union([${d.enum.map(e=>`z.literal(${JSON.stringify(e)})`).join(", ")}])`,yUe=(d,e)=>{const t=Mn(d.if,{...e,path:[...e.path,"if"]}),s=Mn(d.then,{...e,path:[...e.path,"then"]}),i=Mn(d.else,{...e,path:[...e.path,"else"]});return`z.union([${s}, ${i}]).superRefine((value,ctx) => { const result = ${t}.safeParse(value).success ? ${s}.safeParse(value) : ${i}.safeParse(value); if (!result.success) { result.error.errors.forEach((error) => ctx.addIssue(error)) } -})`},gUe=d=>{let e="z.number()";return d.type==="integer"?e+=bn(d,"type",()=>[".int(",")"]):e+=bn(d,"format",({value:t})=>{if(t==="int64")return[".int(",")"]}),e+=bn(d,"multipleOf",({value:t,json:s})=>t===1?e.startsWith("z.number().int(")?void 0:[".int(",")"]:[`.multipleOf(${s}`,", ",")"]),typeof d.minimum=="number"?d.exclusiveMinimum===!0?e+=bn(d,"minimum",({json:t})=>[`.gt(${t}`,", ",")"]):e+=bn(d,"minimum",({json:t})=>[`.gte(${t}`,", ",")"]):typeof d.exclusiveMinimum=="number"&&(e+=bn(d,"exclusiveMinimum",({json:t})=>[`.gt(${t}`,", ",")"])),typeof d.maximum=="number"?d.exclusiveMaximum===!0?e+=bn(d,"maximum",({json:t})=>[`.lt(${t}`,", ",")"]):e+=bn(d,"maximum",({json:t})=>[`.lte(${t}`,", ",")"]):typeof d.exclusiveMaximum=="number"&&(e+=bn(d,"exclusiveMaximum",({json:t})=>[`.lt(${t}`,", ",")"])),e},tK=(d,e)=>d.oneOf.length?d.oneOf.length===1?Mn(d.oneOf[0],{...e,path:[...e.path,"oneOf",0]}):`z.any().superRefine((x, ctx) => { +})`},wUe=d=>{let e="z.number()";return d.type==="integer"?e+=bn(d,"type",()=>[".int(",")"]):e+=bn(d,"format",({value:t})=>{if(t==="int64")return[".int(",")"]}),e+=bn(d,"multipleOf",({value:t,json:s})=>t===1?e.startsWith("z.number().int(")?void 0:[".int(",")"]:[`.multipleOf(${s}`,", ",")"]),typeof d.minimum=="number"?d.exclusiveMinimum===!0?e+=bn(d,"minimum",({json:t})=>[`.gt(${t}`,", ",")"]):e+=bn(d,"minimum",({json:t})=>[`.gte(${t}`,", ",")"]):typeof d.exclusiveMinimum=="number"&&(e+=bn(d,"exclusiveMinimum",({json:t})=>[`.gt(${t}`,", ",")"])),typeof d.maximum=="number"?d.exclusiveMaximum===!0?e+=bn(d,"maximum",({json:t})=>[`.lt(${t}`,", ",")"]):e+=bn(d,"maximum",({json:t})=>[`.lte(${t}`,", ",")"]):typeof d.exclusiveMaximum=="number"&&(e+=bn(d,"exclusiveMaximum",({json:t})=>[`.lt(${t}`,", ",")"])),e},tK=(d,e)=>d.oneOf.length?d.oneOf.length===1?Mn(d.oneOf[0],{...e,path:[...e.path,"oneOf",0]}):`z.any().superRefine((x, ctx) => { const schemas = [${d.oneOf.map((t,s)=>Mn(t,{...e,path:[...e.path,"oneOf",s]})).join(", ")}]; const errors = schemas.reduce( (errors, schema) => @@ -330,7 +330,7 @@ function print() { __p += __j.call(arguments, '') } message: "Invalid input: Should pass single schema", }); } - })`:"z.any()";function yUe(d,e){let t;d.properties&&(Object.keys(d.properties).length?(t="z.object({ ",t+=Object.keys(d.properties).map(r=>{const a=d.properties[r],o=`${JSON.stringify(r)}: ${Mn(a,{...e,path:[...e.path,"properties",r]})}`,c=typeof a=="object"&&a.default!==void 0,u=Array.isArray(d.required)?d.required.includes(r):typeof a=="object"&&a.required===!0;return!c&&!u?`${o}.optional()`:o}).join(", "),t+=" })"):t="z.object({})");const s=d.additionalProperties!==void 0?Mn(d.additionalProperties,{...e,path:[...e.path,"additionalProperties"]}):void 0;let i;if(d.patternProperties){const r=Object.fromEntries(Object.entries(d.patternProperties).map(([a,o])=>[a,Mn(o,{...e,path:[...e.path,"patternProperties",a]})],{}));i="",t?s?i+=`.catchall(z.union([${[...Object.values(r),s].join(", ")}]))`:Object.keys(r).length>1?i+=`.catchall(z.union([${Object.values(r).join(", ")}]))`:i+=`.catchall(${Object.values(r)})`:s?i+=`z.record(z.union([${[...Object.values(r),s].join(", ")}]))`:Object.keys(r).length>1?i+=`z.record(z.union([${Object.values(r).join(", ")}]))`:i+=`z.record(${Object.values(r)})`,i+=`.superRefine((value, ctx) => { + })`:"z.any()";function bUe(d,e){let t;d.properties&&(Object.keys(d.properties).length?(t="z.object({ ",t+=Object.keys(d.properties).map(r=>{const a=d.properties[r],o=`${JSON.stringify(r)}: ${Mn(a,{...e,path:[...e.path,"properties",r]})}`,c=typeof a=="object"&&a.default!==void 0,u=Array.isArray(d.required)?d.required.includes(r):typeof a=="object"&&a.required===!0;return!c&&!u?`${o}.optional()`:o}).join(", "),t+=" })"):t="z.object({})");const s=d.additionalProperties!==void 0?Mn(d.additionalProperties,{...e,path:[...e.path,"additionalProperties"]}):void 0;let i;if(d.patternProperties){const r=Object.fromEntries(Object.entries(d.patternProperties).map(([a,o])=>[a,Mn(o,{...e,path:[...e.path,"patternProperties",a]})],{}));i="",t?s?i+=`.catchall(z.union([${[...Object.values(r),s].join(", ")}]))`:Object.keys(r).length>1?i+=`.catchall(z.union([${Object.values(r).join(", ")}]))`:i+=`.catchall(${Object.values(r)})`:s?i+=`z.record(z.union([${[...Object.values(r),s].join(", ")}]))`:Object.keys(r).length>1?i+=`z.record(z.union([${Object.values(r).join(", ")}]))`:i+=`z.record(${Object.values(r)})`,i+=`.superRefine((value, ctx) => { `,i+=`for (const key in value) { `,s&&(d.properties?i+=`let evaluated = [${Object.keys(d.properties).map(a=>JSON.stringify(a)).join(", ")}].includes(key) `:i+=`let evaluated = false @@ -362,11 +362,11 @@ function print() { __p += __j.call(arguments, '') } `,i+=`} `,i+=`} `),i+=`} -`,i+="})"}let n=t?i?t+i:s?s==="z.never()"?t+".strict()":t+`.catchall(${s})`:t:i||(s?`z.record(${s})`:"z.record(z.any())");return dn.an.anyOf(d)&&(n+=`.and(${eK({...d,anyOf:d.anyOf.map(r=>typeof r=="object"&&!r.type&&(r.properties||r.additionalProperties||r.patternProperties)?{...r,type:"object"}:r)},e)})`),dn.a.oneOf(d)&&(n+=`.and(${tK({...d,oneOf:d.oneOf.map(r=>typeof r=="object"&&!r.type&&(r.properties||r.additionalProperties||r.patternProperties)?{...r,type:"object"}:r)},e)})`),dn.an.allOf(d)&&(n+=`.and(${tT({...d,allOf:d.allOf.map(r=>typeof r=="object"&&!r.type&&(r.properties||r.additionalProperties||r.patternProperties)?{...r,type:"object"}:r)},e)})`),n}const wUe=d=>{let e="z.string()";e+=bn(d,"format",({value:s})=>{switch(s){case"email":return[".email(",")"];case"ip":return[".ip(",")"];case"ipv4":return['.ip({ version: "v4"',", message: "," })"];case"ipv6":return['.ip({ version: "v6"',", message: "," })"];case"uri":return[".url(",")"];case"uuid":return[".uuid(",")"];case"date-time":return[".datetime({ offset: true",", message: "," })"];case"time":return[".time(",")"];case"date":return[".date(",")"];case"binary":return[".base64(",")"];case"duration":return[".duration(",")"]}}),e+=bn(d,"pattern",({json:s})=>[`.regex(new RegExp(${s})`,", ",")"]),e+=bn(d,"minLength",({json:s})=>[`.min(${s}`,", ",")"]),e+=bn(d,"maxLength",({json:s})=>[`.max(${s}`,", ",")"]),e+=bn(d,"contentEncoding",({value:s})=>{if(s==="base64")return[".base64(",")"]});const t=bn(d,"contentMediaType",({value:s})=>{if(s==="application/json")return['.transform((str, ctx) => { try { return JSON.parse(str); } catch (err) { ctx.addIssue({ code: "custom", message: "Invalid JSON" }); }}',", ",")"]});return t!=""&&(e+=t,e+=bn(d,"contentSchema",({value:s})=>{if(s&&s instanceof Object)return[`.pipe(${Mn(s)}`,", ",")"]})),e},bUe=(d,...e)=>Object.keys(d).reduce((t,s)=>(e.includes(s)||(t[s]=d[s]),t),{}),kUe=(d,e)=>`${Mn(bUe(d,"nullable"),e,!0)}.nullable()`,Mn=(d,e={seen:new Map,path:[]},t)=>{if(typeof d!="object")return d?"z.any()":"z.never()";if(e.parserOverride){const n=e.parserOverride(d,e);if(typeof n=="string")return n}let s=e.seen.get(d);if(s){if(s.r!==void 0)return s.r;if(e.depth===void 0||s.n>=e.depth)return"z.any()";s.n+=1}else s={r:void 0,n:0},e.seen.set(d,s);let i=OUe(d,e);return t||(e.withoutDescribes||(i=SUe(d,i)),e.withoutDefaults||(i=vUe(d,i)),i=TUe(d,i)),s.r=i,i},SUe=(d,e)=>(d.description&&(e+=`.describe(${JSON.stringify(d.description)})`),e),vUe=(d,e)=>(d.default!==void 0&&(e+=`.default(${JSON.stringify(d.default)})`),e),TUe=(d,e)=>(d.readOnly&&(e+=".readonly()"),e),OUe=(d,e)=>dn.a.nullable(d)?kUe(d,e):dn.an.object(d)?yUe(d,e):dn.an.array(d)?lUe(d,e):dn.an.anyOf(d)?eK(d,e):dn.an.allOf(d)?tT(d,e):dn.a.oneOf(d)?tK(d,e):dn.a.not(d)?dUe(d,e):dn.an.enum(d)?pUe(d):dn.a.const(d)?fUe(d):dn.a.multipleType(d)?oUe(d,e):dn.a.primitive(d,"string")?wUe(d):dn.a.primitive(d,"number")||dn.a.primitive(d,"integer")?gUe(d):dn.a.primitive(d,"boolean")?rUe():dn.a.primitive(d,"null")?cUe():dn.a.conditional(d)?mUe(d,e):aUe(),dn={an:{object:d=>d.type==="object",array:d=>d.type==="array",anyOf:d=>d.anyOf!==void 0,allOf:d=>d.allOf!==void 0,enum:d=>d.enum!==void 0},a:{nullable:d=>d.nullable===!0,multipleType:d=>Array.isArray(d.type),not:d=>d.not!==void 0,const:d=>d.const!==void 0,primitive:(d,e)=>d.type===e,conditional:d=>!!("if"in d&&d.if&&"then"in d&&"else"in d&&d.then&&d.else),oneOf:d=>d.oneOf!==void 0}},xUe=(d,{module:e,name:t,type:s,noImport:i,...n}={})=>{if(s&&(!t||e!=="esm"))throw new Error("Option `type` requires `name` to be set and `module` to be `esm`");let r=Mn(d,{module:e,name:t,path:[],seen:new Map,...n});if(e==="cjs"?(r=`module.exports = ${t?`{ ${JSON.stringify(t)}: ${r} }`:r} +`,i+="})"}let n=t?i?t+i:s?s==="z.never()"?t+".strict()":t+`.catchall(${s})`:t:i||(s?`z.record(${s})`:"z.record(z.any())");return dn.an.anyOf(d)&&(n+=`.and(${eK({...d,anyOf:d.anyOf.map(r=>typeof r=="object"&&!r.type&&(r.properties||r.additionalProperties||r.patternProperties)?{...r,type:"object"}:r)},e)})`),dn.a.oneOf(d)&&(n+=`.and(${tK({...d,oneOf:d.oneOf.map(r=>typeof r=="object"&&!r.type&&(r.properties||r.additionalProperties||r.patternProperties)?{...r,type:"object"}:r)},e)})`),dn.an.allOf(d)&&(n+=`.and(${tT({...d,allOf:d.allOf.map(r=>typeof r=="object"&&!r.type&&(r.properties||r.additionalProperties||r.patternProperties)?{...r,type:"object"}:r)},e)})`),n}const kUe=d=>{let e="z.string()";e+=bn(d,"format",({value:s})=>{switch(s){case"email":return[".email(",")"];case"ip":return[".ip(",")"];case"ipv4":return['.ip({ version: "v4"',", message: "," })"];case"ipv6":return['.ip({ version: "v6"',", message: "," })"];case"uri":return[".url(",")"];case"uuid":return[".uuid(",")"];case"date-time":return[".datetime({ offset: true",", message: "," })"];case"time":return[".time(",")"];case"date":return[".date(",")"];case"binary":return[".base64(",")"];case"duration":return[".duration(",")"]}}),e+=bn(d,"pattern",({json:s})=>[`.regex(new RegExp(${s})`,", ",")"]),e+=bn(d,"minLength",({json:s})=>[`.min(${s}`,", ",")"]),e+=bn(d,"maxLength",({json:s})=>[`.max(${s}`,", ",")"]),e+=bn(d,"contentEncoding",({value:s})=>{if(s==="base64")return[".base64(",")"]});const t=bn(d,"contentMediaType",({value:s})=>{if(s==="application/json")return['.transform((str, ctx) => { try { return JSON.parse(str); } catch (err) { ctx.addIssue({ code: "custom", message: "Invalid JSON" }); }}',", ",")"]});return t!=""&&(e+=t,e+=bn(d,"contentSchema",({value:s})=>{if(s&&s instanceof Object)return[`.pipe(${Mn(s)}`,", ",")"]})),e},SUe=(d,...e)=>Object.keys(d).reduce((t,s)=>(e.includes(s)||(t[s]=d[s]),t),{}),vUe=(d,e)=>`${Mn(SUe(d,"nullable"),e,!0)}.nullable()`,Mn=(d,e={seen:new Map,path:[]},t)=>{if(typeof d!="object")return d?"z.any()":"z.never()";if(e.parserOverride){const n=e.parserOverride(d,e);if(typeof n=="string")return n}let s=e.seen.get(d);if(s){if(s.r!==void 0)return s.r;if(e.depth===void 0||s.n>=e.depth)return"z.any()";s.n+=1}else s={r:void 0,n:0},e.seen.set(d,s);let i=PUe(d,e);return t||(e.withoutDescribes||(i=TUe(d,i)),e.withoutDefaults||(i=OUe(d,i)),i=xUe(d,i)),s.r=i,i},TUe=(d,e)=>(d.description&&(e+=`.describe(${JSON.stringify(d.description)})`),e),OUe=(d,e)=>(d.default!==void 0&&(e+=`.default(${JSON.stringify(d.default)})`),e),xUe=(d,e)=>(d.readOnly&&(e+=".readonly()"),e),PUe=(d,e)=>dn.a.nullable(d)?vUe(d,e):dn.an.object(d)?bUe(d,e):dn.an.array(d)?pUe(d,e):dn.an.anyOf(d)?eK(d,e):dn.an.allOf(d)?tT(d,e):dn.a.oneOf(d)?tK(d,e):dn.a.not(d)?uUe(d,e):dn.an.enum(d)?gUe(d):dn.a.const(d)?mUe(d):dn.a.multipleType(d)?cUe(d,e):dn.a.primitive(d,"string")?kUe(d):dn.a.primitive(d,"number")||dn.a.primitive(d,"integer")?wUe(d):dn.a.primitive(d,"boolean")?oUe():dn.a.primitive(d,"null")?hUe():dn.a.conditional(d)?yUe(d,e):dUe(),dn={an:{object:d=>d.type==="object",array:d=>d.type==="array",anyOf:d=>d.anyOf!==void 0,allOf:d=>d.allOf!==void 0,enum:d=>d.enum!==void 0},a:{nullable:d=>d.nullable===!0,multipleType:d=>Array.isArray(d.type),not:d=>d.not!==void 0,const:d=>d.const!==void 0,primitive:(d,e)=>d.type===e,conditional:d=>!!("if"in d&&d.if&&"then"in d&&"else"in d&&d.then&&d.else),oneOf:d=>d.oneOf!==void 0}},IUe=(d,{module:e,name:t,type:s,noImport:i,...n}={})=>{if(s&&(!t||e!=="esm"))throw new Error("Option `type` requires `name` to be set and `module` to be `esm`");let r=Mn(d,{module:e,name:t,path:[],seen:new Map,...n});if(e==="cjs"?(r=`module.exports = ${t?`{ ${JSON.stringify(t)}: ${r} }`:r} `,i||(r=`const { z } = require("zod") ${r}`)):e==="esm"?(r=`export ${t?`const ${t} =`:"default"} ${r} `,i||(r=`import { z } from "zod" ${r}`)):t&&(r=`const ${t} = ${r}`),s&&t){let a=typeof s=="string"?s:`${t[0].toUpperCase()}${t.substring(1)}`;r+=`export type ${a} = z.infer -`}return r};function PUe(d,e,t){const{botName:s,exchangeCode:i,exchangeAccountId:n,symbolId:r,timeframe:a,logging:o}=d,{currencyPairSymbol:c}=MA(r);return{exchangeAccountId:n,data:{name:s,template:e,settings:t,timeframe:a,symbol:c,logging:o}}}function sK(d,e){const t=gN(e[d].schema);return t instanceof Oo.ZodObject?Object.keys(t.shape).length>0:!1}function gN(d){const e=xUe(d,{module:"none"});return new Function("z",`return ${e}`)(Oo)}function J2(d,e){if(d in e)return e[d].schema;throw new Error(`Cannot extract strategy schema. Strategy ${d} not found`)}function iK(d,e){const{dispatch:t}=bg(),[s,i]=B.useState(d),[n,r]=B.useState(J2(s,e));return{strategy:s,onStrategyChange:o=>{i(o);const c=J2(o,e);r(c);const u=Ew(c);t({type:"reset",defaultState:u})},schema:n,defaultValues:Ew(n)}}function IUe({strategies:d}){const{strategy:e,onStrategyChange:t,schema:s}=iK("rsi",d),{state:i}=bg(),{showSnackbar:n}=Tr(),r=Zc(),{mutate:a,isLoading:o}=kt.bot.create.useMutation({onSuccess(h){n("Bot created successfully"),setTimeout(()=>{r({to:ai("bot/:id",h.id)})},1e3)}}),c=h=>{const f=gN(s).safeParse(i);if(!f.success){console.warn("Strategy params are not valid",f.error),n("Strategy params are not valid.",{color:"danger"});return}const p=PUe(h,e,f.data);a(p)},u=sK(e,d);return P.jsxs(It,{container:!0,spacing:2,children:[P.jsxs(It,{md:6,xs:12,children:[P.jsx(ot,{level:"h2",sx:{mb:1},children:"Strategy settings"}),P.jsx(J$,{onChange:t,value:e,templates:d}),P.jsx(ot,{level:"body-sm",sx:{mt:2,mb:1},children:"Strategy params"}),u?P.jsx(Y$,{schema:s,strategy:e}):P.jsx(Z$,{strategy:e})]}),P.jsxs(It,{md:6,xs:12,children:[P.jsx(ot,{level:"h2",sx:{mb:1},children:"Bot settings"}),P.jsx(B.Suspense,{fallback:P.jsx(mi,{animation:"wave",height:300,sx:{borderRadius:8},variant:"rectangular",width:"100%"}),children:P.jsx(T$,{isLoading:o,onSubmit:c})})]})]})}function CUe(){const[d]=kt.bot.getStrategies.useSuspenseQuery(),e=J2("rsi",d),t=Ew(e);return P.jsx(xO,{children:P.jsx(Q$,{initialState:t,children:P.jsx(IUe,{strategies:d})})})}const MUe=vr("/_layout/dashboard/bot/create")({component:CUe}),_Ue=Ys(P.jsx("path",{d:"M9 4H7v2H5v12h2v2h2v-2h2V6H9zm10 4h-2V4h-2v4h-2v7h2v5h2v-5h2z"}),"CandlestickChart"),AUe=({bot:d})=>P.jsxs(Dh,{children:[P.jsx(RL,{bot:d}),P.jsx(fr,{inset:"startContent"}),P.jsx(qL,{bot:d}),P.jsx(fr,{inset:"startContent"}),P.jsx(Id,{icon:P.jsx(EL,{}),name:"Template",children:P.jsx(In,{title:P.jsx("pre",{children:JSON.stringify(d.settings,null,2)}),children:P.jsx(nn,{color:"primary",variant:"soft",children:d.template})})}),P.jsx(fr,{inset:"startContent"}),P.jsx(Id,{icon:P.jsx(_Ue,{}),name:"Timeframe",children:d.timeframe?d.timeframe:"No timeframe"})]}),LUe=({botId:d})=>{const[e]=kt.bot.getOne.useSuspenseQuery(d),[t]=go();return P.jsxs(fn,{children:[P.jsxs(_t,{display:"flex",justifyContent:"space-between",children:[P.jsx(ot,{fontSize:"xl2",fontWeight:"xl",level:"h3",children:e.name}),P.jsxs(ot,{color:"neutral",fontSize:"xl2",fontWeight:"xl",level:"h3",children:["#",e.id]})]}),P.jsx(AUe,{bot:e}),P.jsx(NL,{children:P.jsx(AL,{bot:e})}),P.jsxs(ML,{children:[P.jsx(LL,{bot:e,href:ai("bot/edit/:id",e.id)}),P.jsx(BL,{bot:e,redirectPath:ai("bot")}),t?P.jsxs(P.Fragment,{children:[P.jsx(Ia,{children:"Debugging"}),P.jsx(PL,{polling:!1}),P.jsx(_L,{bot:e})]}):null]})]})};function BUe(d){return d.filter(t=>{const{entryType:s,takeProfitType:i}=t;return s==="Order"&&(i==="Order"||i==="None")}).flatMap(t=>{const{entryOrder:s,takeProfitOrder:i}=t,n=[s];return i&&n.push(i),n}).filter(t=>t.status==="Placed"&&t.type==="Limit").map(t=>{const s=t.side==="Buy"?"green":"red";return gb(t.price,s,"")})}const NUe=["1d","4h","1h","5m","1m"],t4=()=>{},EUe=({botId:d})=>{const[e]=kt.bot.getOne.useSuspenseQuery(d),[t]=kt.exchangeAccount.getOne.useSuspenseQuery(e.exchangeAccountId),[s]=kt.symbol.getOne.useSuspenseQuery({symbolId:ZT(t.exchangeCode,JT(e.symbol),eO(e.symbol))}),[i,n]=B.useState("1h"),[r]=kt.bot.openSmartTrades.useSuspenseQuery({botId:d}),[a]=kt.smartTrade.list.useSuspenseQuery({botId:d}),o=B.useMemo(()=>BUe(r),[r]),[c,u]=B.useState(!0),h=B.useMemo(()=>KB(a,i),[a,i]),[l,f]=B.useState(!0);return P.jsx(B.Suspense,{fallback:P.jsx(mi,{animation:"wave",height:Xo,variant:"rectangular",width:"100%"}),children:P.jsxs(hx,{barSize:i,markers:h,priceLines:o,showMarkers:l,showPriceLines:c,symbolId:s.symbolId,children:[P.jsx(_b,{onChange:t4,value:t,disabled:!0}),P.jsx(Ab,{exchangeCode:t.exchangeCode,onChange:t4,value:s,disabled:!0}),P.jsx(wg,{onChange:p=>{n(p)},value:i,whitelist:NUe}),P.jsx(Rc,{}),P.jsx(_t,{display:"flex",children:P.jsx(lx,{gridVisible:c,onGridVisibleChange:u,onTradesVisibleChange:f,tradesVisible:l})})]})})};function RUe(d){const{botId:e}=d,[t]=go(),[s,i]=B.useState(["Filled"]),[n,r]=B.useState("Orders");return P.jsxs(It,{container:!0,spacing:2,children:[P.jsxs(It,{md:9,children:[P.jsx(B.Suspense,{fallback:P.jsx(mi,{animation:"wave",height:Xo,sx:{borderRadius:8},variant:"rectangular",width:"100%"}),children:P.jsx(EUe,{botId:e})}),P.jsx(_t,{sx:{mt:2}}),P.jsx(B.Suspense,{fallback:P.jsx(mi,{animation:"wave",height:250,sx:{borderRadius:8},variant:"rectangular",width:"100%"}),children:P.jsxs(xL,{value:n,onChange:r,actions:n==="Orders"&&t?P.jsx(eN,{value:s,onChange:i}):null,children:[n==="Orders"?P.jsx(JB,{botId:e,filterOrderStatuses:s}):null,n==="SmartTrades"?P.jsx(YB,{botId:e}):null,n==="StrategyLogs"?P.jsx(OL,{botId:e}):null]})})]}),P.jsxs(It,{md:3,children:[P.jsx(B.Suspense,{fallback:P.jsx(mi,{animation:"wave",height:Xo,sx:{borderRadius:8},variant:"rectangular",width:"100%"}),children:P.jsx(LUe,{botId:e})}),P.jsx(_t,{sx:{mt:2}}),P.jsx(B.Suspense,{fallback:P.jsx(mi,{animation:"wave",height:250,sx:{borderRadius:8},variant:"rectangular",width:"100%"}),children:P.jsx(QB,{botId:e})})]})]})}const nK=vr("/_layout/dashboard/bot/$id")({component:()=>{const{id:d}=nK.useParams();return P.jsx(RUe,{botId:Number(d)})}}),DUe=TL(()=>Po(()=>import("./page-DXvJlC_-.js"),__vite__mapDeps([8,1])),P.jsx(vL,{})),qUe=vr("/_layout/dashboard/grid-bot/edit/$id")({component:DUe}),VUe=TL(()=>Po(()=>import("./page-Dg9uQDXn.js"),[]),P.jsx(vL,{})),FUe=vr("/_layout/dashboard/dca-bot/edit/$id")({component:VUe});function HUe(d,e,t){const{botId:s,botName:i,exchangeCode:n,exchangeAccountId:r,symbolId:a,timeframe:o,logging:c}=d,{currencyPairSymbol:u}=MA(a);return{botId:s,data:{name:i,template:e,settings:t,timeframe:o,symbol:u,exchangeAccountId:r,logging:c}}}const GUe=({bot:d,strategies:e})=>{const{strategy:t,onStrategyChange:s,schema:i}=iK(d.template,e),{state:n}=bg(),{showSnackbar:r}=Tr(),a=Zc(),{mutate:o,isLoading:c}=kt.bot.update.useMutation({onSuccess(l){r("Bot updated successfully"),setTimeout(()=>{a({to:ai("bot/:id",l.id)})},1e3)}}),u=l=>{const p=gN(i).safeParse(n);if(!p.success){console.warn("Strategy params are not valid",p.error),r("Strategy params are not valid.",{color:"danger"});return}const m=HUe(l,t,p.data);o(m)},h=sK(t,e);return P.jsxs(It,{container:!0,spacing:2,children:[P.jsxs(It,{md:6,xs:12,children:[P.jsx(ot,{level:"h2",sx:{mb:1},children:"Strategy settings"}),P.jsx(J$,{onChange:s,value:t,templates:e}),P.jsx(ot,{level:"body-sm",sx:{mt:2,mb:1},children:"Strategy params"}),h?P.jsx(Y$,{schema:i,strategy:t}):P.jsx(Z$,{strategy:t})]}),P.jsxs(It,{md:6,xs:12,children:[P.jsx(ot,{level:"h2",sx:{mb:1},children:"Bot settings"}),P.jsx(B.Suspense,{fallback:P.jsx(mi,{animation:"wave",height:300,sx:{borderRadius:8},variant:"rectangular",width:"100%"}),children:P.jsx(pHe,{defaultBot:d,isLoading:c,onSubmit:u})})]})]})};function UUe(){const{id:d}=rK.useParams(),e=Number(d),[t]=kt.bot.getStrategies.useSuspenseQuery(),[s]=kt.bot.getOne.useSuspenseQuery(e);return P.jsx(xO,{children:P.jsx(Q$,{initialState:s.settings,children:P.jsx(GUe,{bot:s,strategies:t})})})}const rK=vr("/_layout/dashboard/bot/edit/$id")({component:UUe}),Kr=m1e.update({id:"/_layout",getParentRoute:()=>fL}),WUe=y1e.update({id:"/",path:"/",getParentRoute:()=>fL}),jUe=V1e.update({id:"/dashboard/settings",path:"/dashboard/settings",getParentRoute:()=>Kr}),zUe=j1e.update({id:"/dashboard/login",path:"/dashboard/login",getParentRoute:()=>Kr}),$Ue=XOe.update({id:"/dashboard/accounts",path:"/dashboard/accounts",getParentRoute:()=>Kr}),KUe=Axe.update({id:"/dashboard/bot/",path:"/dashboard/bot/",getParentRoute:()=>Kr}),XUe=Exe.update({id:"/dashboard/grid-bot/create",path:"/dashboard/grid-bot/create",getParentRoute:()=>Kr}),QUe=y$.update({id:"/dashboard/grid-bot/$id",path:"/dashboard/grid-bot/$id",getParentRoute:()=>Kr}),YUe=UGe.update({id:"/dashboard/dca-bot/create",path:"/dashboard/dca-bot/create",getParentRoute:()=>Kr}),ZUe=K$.update({id:"/dashboard/dca-bot/$id",path:"/dashboard/dca-bot/$id",getParentRoute:()=>Kr}),JUe=MUe.update({id:"/dashboard/bot/create",path:"/dashboard/bot/create",getParentRoute:()=>Kr}),eWe=nK.update({id:"/dashboard/bot/$id",path:"/dashboard/bot/$id",getParentRoute:()=>Kr}),tWe=qUe.update({id:"/dashboard/grid-bot/edit/$id",path:"/dashboard/grid-bot/edit/$id",getParentRoute:()=>Kr}),sWe=FUe.update({id:"/dashboard/dca-bot/edit/$id",path:"/dashboard/dca-bot/edit/$id",getParentRoute:()=>Kr}),iWe=rK.update({id:"/dashboard/bot/edit/$id",path:"/dashboard/bot/edit/$id",getParentRoute:()=>Kr}),nWe={LayoutDashboardAccountsRoute:$Ue,LayoutDashboardLoginRoute:zUe,LayoutDashboardSettingsRoute:jUe,LayoutDashboardBotIdRoute:eWe,LayoutDashboardBotCreateRoute:JUe,LayoutDashboardDcaBotIdRoute:ZUe,LayoutDashboardDcaBotCreateRoute:YUe,LayoutDashboardGridBotIdRoute:QUe,LayoutDashboardGridBotCreateRoute:XUe,LayoutDashboardBotIndexRoute:KUe,LayoutDashboardBotEditIdRoute:iWe,LayoutDashboardDcaBotEditIdRoute:sWe,LayoutDashboardGridBotEditIdRoute:tWe},rWe=Kr._addFileChildren(nWe),aWe={IndexRoute:WUe,LayoutRoute:rWe},oWe=fL._addFileChildren(aWe)._addFileTypes(),dWe=die(),cWe=Zie({routeTree:oWe,history:dWe}),s4=document.getElementById("root");s4.innerHTML||MC.createRoot(s4).render(P.jsx(B.StrictMode,{children:P.jsx(zne,{router:cWe})}));export{Ab as $,HW as A,Es as B,fO as C,Ia as D,xO as E,CWe as F,It as G,LWe as H,Ro as I,yU as J,ln as K,Cs as L,jA as M,Rt as N,pWe as O,Dt as P,_e as Q,qUe as R,mi as S,qt as T,zW as U,at as V,Fe as W,De as X,Nt as Y,_b as Z,W as _,Zc as a,uWe as a$,kWe as a0,RMe as a1,Xo as a2,hx as a3,wg as a4,mWe as a5,Rc as a6,lx as a7,dPe as a8,iPe as a9,Zue as aA,ihe as aB,the as aC,rhe as aD,ohe as aE,che as aF,ghe as aG,tO as aH,phe as aI,mhe as aJ,$8 as aK,z8 as aL,vHe as aM,ot as aN,pHe as aO,Jue as aP,Kue as aQ,Yue as aR,MGe as aS,AGe as aT,VGe as aU,ehe as aV,xH as aW,sm as aX,sT as aY,fne as aZ,Sc as a_,Xxe as aa,_I as ab,gWe as ac,ki as ad,zi as ae,Pn as af,Vd as ag,lHe as ah,Gm as ai,_We as aj,EWe as ak,EGe as al,RWe as am,B$ as an,DWe as ao,NWe as ap,IWe as aq,xWe as ar,vWe as as,OWe as at,fhe as au,FUe as av,VWe as aw,$ue as ax,Xue as ay,Que as az,Gn as b,lWe as b0,ai as c,MA as d,Zd as e,cm as f,SWe as g,TWe as h,BWe as i,P as j,fn as k,_t as l,FGe as m,yWe as n,wWe as o,bWe as p,MWe as q,B as r,PWe as s,kt as t,Tr as u,tN as v,AWe as w,ZT as x,eO as y,JT as z}; +`}return r};function CUe(d,e,t){const{botName:s,exchangeCode:i,exchangeAccountId:n,symbolId:r,timeframe:a,logging:o}=d,{currencyPairSymbol:c}=MA(r);return{exchangeAccountId:n,data:{name:s,template:e,settings:t,timeframe:a,symbol:c,logging:o}}}function sK(d,e){const t=gN(e[d].schema);return t instanceof Oo.ZodObject?Object.keys(t.shape).length>0:!1}function gN(d){const e=IUe(d,{module:"none"});return new Function("z",`return ${e}`)(Oo)}function J2(d,e){if(d in e)return e[d].schema;throw new Error(`Cannot extract strategy schema. Strategy ${d} not found`)}function iK(d,e){const{dispatch:t}=bg(),[s,i]=B.useState(d),[n,r]=B.useState(J2(s,e));return{strategy:s,onStrategyChange:o=>{i(o);const c=J2(o,e);r(c);const u=Ew(c);t({type:"reset",defaultState:u})},schema:n,defaultValues:Ew(n)}}function MUe({strategies:d}){const{strategy:e,onStrategyChange:t,schema:s}=iK("rsi",d),{state:i}=bg(),{showSnackbar:n}=Tr(),r=Zc(),{mutate:a,isLoading:o}=kt.bot.create.useMutation({onSuccess(h){n("Bot created successfully"),setTimeout(()=>{r({to:ai("bot/:id",h.id)})},1e3)}}),c=h=>{const f=gN(s).safeParse(i);if(!f.success){console.warn("Strategy params are not valid",f.error),n("Strategy params are not valid.",{color:"danger"});return}const p=CUe(h,e,f.data);a(p)},u=sK(e,d);return P.jsxs(It,{container:!0,spacing:2,children:[P.jsxs(It,{md:6,xs:12,children:[P.jsx(ot,{level:"h2",sx:{mb:1},children:"Strategy settings"}),P.jsx(J$,{onChange:t,value:e,templates:d}),P.jsx(ot,{level:"body-sm",sx:{mt:2,mb:1},children:"Strategy params"}),u?P.jsx(Y$,{schema:s,strategy:e}):P.jsx(Z$,{strategy:e})]}),P.jsxs(It,{md:6,xs:12,children:[P.jsx(ot,{level:"h2",sx:{mb:1},children:"Bot settings"}),P.jsx(B.Suspense,{fallback:P.jsx(mi,{animation:"wave",height:300,sx:{borderRadius:8},variant:"rectangular",width:"100%"}),children:P.jsx(T$,{isLoading:o,onSubmit:c})})]})]})}function _Ue(){const[d]=kt.bot.getStrategies.useSuspenseQuery(),e=J2("rsi",d),t=Ew(e);return P.jsx(xO,{children:P.jsx(Q$,{initialState:t,children:P.jsx(MUe,{strategies:d})})})}const AUe=vr("/_layout/dashboard/bot/create")({component:_Ue}),LUe=Ys(P.jsx("path",{d:"M9 4H7v2H5v12h2v2h2v-2h2V6H9zm10 4h-2V4h-2v4h-2v7h2v5h2v-5h2z"}),"CandlestickChart"),BUe=({bot:d})=>P.jsxs(Dh,{children:[P.jsx(RL,{bot:d}),P.jsx(fr,{inset:"startContent"}),P.jsx(qL,{bot:d}),P.jsx(fr,{inset:"startContent"}),P.jsx(Id,{icon:P.jsx(EL,{}),name:"Template",children:P.jsx(In,{title:P.jsx("pre",{children:JSON.stringify(d.settings,null,2)}),children:P.jsx(nn,{color:"primary",variant:"soft",children:d.template})})}),P.jsx(fr,{inset:"startContent"}),P.jsx(Id,{icon:P.jsx(LUe,{}),name:"Timeframe",children:d.timeframe?d.timeframe:"No timeframe"})]}),NUe=({botId:d})=>{const[e]=kt.bot.getOne.useSuspenseQuery(d),[t]=go();return P.jsxs(fn,{children:[P.jsxs(_t,{display:"flex",justifyContent:"space-between",children:[P.jsx(ot,{fontSize:"xl2",fontWeight:"xl",level:"h3",children:e.name}),P.jsxs(ot,{color:"neutral",fontSize:"xl2",fontWeight:"xl",level:"h3",children:["#",e.id]})]}),P.jsx(BUe,{bot:e}),P.jsx(NL,{children:P.jsx(AL,{bot:e})}),P.jsxs(ML,{children:[P.jsx(LL,{bot:e,href:ai("bot/edit/:id",e.id)}),P.jsx(BL,{bot:e,redirectPath:ai("bot")}),t?P.jsxs(P.Fragment,{children:[P.jsx(Ia,{children:"Debugging"}),P.jsx(PL,{polling:!1}),P.jsx(_L,{bot:e})]}):null]})]})};function EUe(d){return d.filter(t=>{const{entryType:s,takeProfitType:i}=t;return s==="Order"&&(i==="Order"||i==="None")}).flatMap(t=>{const{entryOrder:s,takeProfitOrder:i}=t,n=[s];return i&&n.push(i),n}).filter(t=>t.status==="Placed"&&t.type==="Limit").map(t=>{const s=t.side==="Buy"?"green":"red";return gb(t.price,s,"")})}const RUe=["1d","4h","1h","5m","1m"],t4=()=>{},DUe=({botId:d})=>{const[e]=kt.bot.getOne.useSuspenseQuery(d),[t]=kt.exchangeAccount.getOne.useSuspenseQuery(e.exchangeAccountId),[s]=kt.symbol.getOne.useSuspenseQuery({symbolId:ZT(t.exchangeCode,JT(e.symbol),eO(e.symbol))}),[i,n]=B.useState("1h"),[r]=kt.bot.openSmartTrades.useSuspenseQuery({botId:d}),[a]=kt.smartTrade.list.useSuspenseQuery({botId:d}),o=B.useMemo(()=>EUe(r),[r]),[c,u]=B.useState(!0),h=B.useMemo(()=>KB(a,i),[a,i]),[l,f]=B.useState(!0);return P.jsx(B.Suspense,{fallback:P.jsx(mi,{animation:"wave",height:Xo,variant:"rectangular",width:"100%"}),children:P.jsxs(hx,{barSize:i,markers:h,priceLines:o,showMarkers:l,showPriceLines:c,symbolId:s.symbolId,children:[P.jsx(_b,{onChange:t4,value:t,disabled:!0}),P.jsx(Ab,{exchangeCode:t.exchangeCode,onChange:t4,value:s,disabled:!0}),P.jsx(wg,{onChange:p=>{n(p)},value:i,whitelist:RUe}),P.jsx(Rc,{}),P.jsx(_t,{display:"flex",children:P.jsx(lx,{gridVisible:c,onGridVisibleChange:u,onTradesVisibleChange:f,tradesVisible:l})})]})})};function qUe(d){const{botId:e}=d,[t]=go(),[s,i]=B.useState(["Filled"]),[n,r]=B.useState("Orders");return P.jsxs(It,{container:!0,spacing:2,children:[P.jsxs(It,{md:9,children:[P.jsx(B.Suspense,{fallback:P.jsx(mi,{animation:"wave",height:Xo,sx:{borderRadius:8},variant:"rectangular",width:"100%"}),children:P.jsx(DUe,{botId:e})}),P.jsx(_t,{sx:{mt:2}}),P.jsx(B.Suspense,{fallback:P.jsx(mi,{animation:"wave",height:250,sx:{borderRadius:8},variant:"rectangular",width:"100%"}),children:P.jsxs(xL,{value:n,onChange:r,actions:n==="Orders"&&t?P.jsx(eN,{value:s,onChange:i}):null,children:[n==="Orders"?P.jsx(JB,{botId:e,filterOrderStatuses:s}):null,n==="SmartTrades"?P.jsx(YB,{botId:e}):null,n==="StrategyLogs"?P.jsx(OL,{botId:e}):null]})})]}),P.jsxs(It,{md:3,children:[P.jsx(B.Suspense,{fallback:P.jsx(mi,{animation:"wave",height:Xo,sx:{borderRadius:8},variant:"rectangular",width:"100%"}),children:P.jsx(NUe,{botId:e})}),P.jsx(_t,{sx:{mt:2}}),P.jsx(B.Suspense,{fallback:P.jsx(mi,{animation:"wave",height:250,sx:{borderRadius:8},variant:"rectangular",width:"100%"}),children:P.jsx(QB,{botId:e})})]})]})}const nK=vr("/_layout/dashboard/bot/$id")({component:()=>{const{id:d}=nK.useParams();return P.jsx(qUe,{botId:Number(d)})}}),VUe=TL(()=>Po(()=>import("./page-DokNskun.js"),__vite__mapDeps([8,1])),P.jsx(vL,{})),FUe=vr("/_layout/dashboard/grid-bot/edit/$id")({component:VUe}),HUe=TL(()=>Po(()=>import("./page-DHylC053.js"),[]),P.jsx(vL,{})),GUe=vr("/_layout/dashboard/dca-bot/edit/$id")({component:HUe});function UUe(d,e,t){const{botId:s,botName:i,exchangeCode:n,exchangeAccountId:r,symbolId:a,timeframe:o,logging:c}=d,{currencyPairSymbol:u}=MA(a);return{botId:s,data:{name:i,template:e,settings:t,timeframe:o,symbol:u,exchangeAccountId:r,logging:c}}}const WUe=({bot:d,strategies:e})=>{const{strategy:t,onStrategyChange:s,schema:i}=iK(d.template,e),{state:n}=bg(),{showSnackbar:r}=Tr(),a=Zc(),{mutate:o,isLoading:c}=kt.bot.update.useMutation({onSuccess(l){r("Bot updated successfully"),setTimeout(()=>{a({to:ai("bot/:id",l.id)})},1e3)}}),u=l=>{const p=gN(i).safeParse(n);if(!p.success){console.warn("Strategy params are not valid",p.error),r("Strategy params are not valid.",{color:"danger"});return}const m=UUe(l,t,p.data);o(m)},h=sK(t,e);return P.jsxs(It,{container:!0,spacing:2,children:[P.jsxs(It,{md:6,xs:12,children:[P.jsx(ot,{level:"h2",sx:{mb:1},children:"Strategy settings"}),P.jsx(J$,{onChange:s,value:t,templates:e}),P.jsx(ot,{level:"body-sm",sx:{mt:2,mb:1},children:"Strategy params"}),h?P.jsx(Y$,{schema:i,strategy:t}):P.jsx(Z$,{strategy:t})]}),P.jsxs(It,{md:6,xs:12,children:[P.jsx(ot,{level:"h2",sx:{mb:1},children:"Bot settings"}),P.jsx(B.Suspense,{fallback:P.jsx(mi,{animation:"wave",height:300,sx:{borderRadius:8},variant:"rectangular",width:"100%"}),children:P.jsx(gHe,{defaultBot:d,isLoading:c,onSubmit:u})})]})]})};function jUe(){const{id:d}=rK.useParams(),e=Number(d),[t]=kt.bot.getStrategies.useSuspenseQuery(),[s]=kt.bot.getOne.useSuspenseQuery(e);return P.jsx(xO,{children:P.jsx(Q$,{initialState:s.settings,children:P.jsx(WUe,{bot:s,strategies:t})})})}const rK=vr("/_layout/dashboard/bot/edit/$id")({component:jUe}),Kr=m1e.update({id:"/_layout",getParentRoute:()=>fL}),zUe=y1e.update({id:"/",path:"/",getParentRoute:()=>fL}),$Ue=V1e.update({id:"/dashboard/settings",path:"/dashboard/settings",getParentRoute:()=>Kr}),KUe=j1e.update({id:"/dashboard/login",path:"/dashboard/login",getParentRoute:()=>Kr}),XUe=XOe.update({id:"/dashboard/accounts",path:"/dashboard/accounts",getParentRoute:()=>Kr}),QUe=Axe.update({id:"/dashboard/bot/",path:"/dashboard/bot/",getParentRoute:()=>Kr}),YUe=Exe.update({id:"/dashboard/grid-bot/create",path:"/dashboard/grid-bot/create",getParentRoute:()=>Kr}),ZUe=y$.update({id:"/dashboard/grid-bot/$id",path:"/dashboard/grid-bot/$id",getParentRoute:()=>Kr}),JUe=jGe.update({id:"/dashboard/dca-bot/create",path:"/dashboard/dca-bot/create",getParentRoute:()=>Kr}),eWe=K$.update({id:"/dashboard/dca-bot/$id",path:"/dashboard/dca-bot/$id",getParentRoute:()=>Kr}),tWe=AUe.update({id:"/dashboard/bot/create",path:"/dashboard/bot/create",getParentRoute:()=>Kr}),sWe=nK.update({id:"/dashboard/bot/$id",path:"/dashboard/bot/$id",getParentRoute:()=>Kr}),iWe=FUe.update({id:"/dashboard/grid-bot/edit/$id",path:"/dashboard/grid-bot/edit/$id",getParentRoute:()=>Kr}),nWe=GUe.update({id:"/dashboard/dca-bot/edit/$id",path:"/dashboard/dca-bot/edit/$id",getParentRoute:()=>Kr}),rWe=rK.update({id:"/dashboard/bot/edit/$id",path:"/dashboard/bot/edit/$id",getParentRoute:()=>Kr}),aWe={LayoutDashboardAccountsRoute:XUe,LayoutDashboardLoginRoute:KUe,LayoutDashboardSettingsRoute:$Ue,LayoutDashboardBotIdRoute:sWe,LayoutDashboardBotCreateRoute:tWe,LayoutDashboardDcaBotIdRoute:eWe,LayoutDashboardDcaBotCreateRoute:JUe,LayoutDashboardGridBotIdRoute:ZUe,LayoutDashboardGridBotCreateRoute:YUe,LayoutDashboardBotIndexRoute:QUe,LayoutDashboardBotEditIdRoute:rWe,LayoutDashboardDcaBotEditIdRoute:nWe,LayoutDashboardGridBotEditIdRoute:iWe},oWe=Kr._addFileChildren(aWe),dWe={IndexRoute:zUe,LayoutRoute:oWe},cWe=fL._addFileChildren(dWe)._addFileTypes(),uWe=die(),hWe=Zie({routeTree:cWe,history:uWe}),s4=document.getElementById("root");s4.innerHTML||MC.createRoot(s4).render(P.jsx(B.StrictMode,{children:P.jsx(zne,{router:hWe})}));export{Ab as $,HW as A,Es as B,fO as C,Ia as D,xO as E,_We as F,It as G,NWe as H,Ro as I,yU as J,ln as K,Cs as L,jA as M,Rt as N,gWe as O,Dt as P,_e as Q,FUe as R,mi as S,qt as T,zW as U,at as V,Fe as W,De as X,Nt as Y,_b as Z,W as _,Zc as a,lWe as a$,vWe as a0,RMe as a1,Xo as a2,hx as a3,wg as a4,yWe as a5,Rc as a6,lx as a7,dPe as a8,iPe as a9,Zue as aA,ihe as aB,the as aC,rhe as aD,ohe as aE,che as aF,ghe as aG,tO as aH,phe as aI,mhe as aJ,$8 as aK,z8 as aL,OHe as aM,ot as aN,gHe as aO,Jue as aP,Kue as aQ,Yue as aR,AGe as aS,BGe as aT,HGe as aU,ehe as aV,xH as aW,sm as aX,sT as aY,fne as aZ,Sc as a_,Xxe as aa,_I as ab,wWe as ac,ki as ad,zi as ae,Pn as af,Vd as ag,pHe as ah,Gm as ai,LWe as aj,DWe as ak,DGe as al,qWe as am,B$ as an,VWe as ao,RWe as ap,MWe as aq,IWe as ar,OWe as as,PWe as at,fhe as au,GUe as av,HWe as aw,$ue as ax,Xue as ay,Que as az,Gn as b,pWe as b0,ai as c,MA as d,Zd as e,cm as f,TWe as g,xWe as h,EWe as i,P as j,fn as k,_t as l,GGe as m,bWe as n,kWe as o,SWe as p,AWe as q,B as r,CWe as s,kt as t,Tr as u,tN as v,BWe as w,ZT as x,eO as y,JT as z}; diff --git a/apps/cli/frontend/assets/index-Cxn6EJsJ.js b/apps/cli/frontend/assets/index-C9ivc5Jj.js similarity index 99% rename from apps/cli/frontend/assets/index-Cxn6EJsJ.js rename to apps/cli/frontend/assets/index-C9ivc5Jj.js index 18aee7c5..aef07793 100644 --- a/apps/cli/frontend/assets/index-Cxn6EJsJ.js +++ b/apps/cli/frontend/assets/index-C9ivc5Jj.js @@ -1,4 +1,4 @@ -import{aZ as U,a_ as Oe,aY as _r,aX as wr}from"./index-C0B7FSMw.js";import{z as G}from"./__vite-browser-external-v7f2oYTb.js";import{u as ue,S as se,f as ne,r as ft,t as ze,g as Wr,c as kr,b as lt}from"./browser-DplhMTqm.js";class He extends Error{constructor(e,t){super(e),Error.captureStackTrace(this,this.constructor),this.type=t}get name(){return this.constructor.name}get[Symbol.toStringTag](){return this.constructor.name}}class ie extends He{constructor(e,t,n){super(e,t),n&&(this.code=this.errno=n.code,this.erroredSysCall=n.syscall)}}const Be=Symbol.toStringTag,zr=r=>typeof r=="object"&&typeof r.append=="function"&&typeof r.delete=="function"&&typeof r.get=="function"&&typeof r.getAll=="function"&&typeof r.has=="function"&&typeof r.set=="function"&&typeof r.sort=="function"&&r[Be]==="URLSearchParams",Ue=r=>r&&typeof r=="object"&&typeof r.arrayBuffer=="function"&&typeof r.type=="string"&&typeof r.stream=="function"&&typeof r.constructor=="function"&&/^(Blob|File)$/.test(r[Be]),ut=r=>typeof r=="object"&&(r[Be]==="AbortSignal"||r[Be]==="EventTarget"),ct=(r,e)=>{const t=new URL(e).hostname,n=new URL(r).hostname;return t===n||t.endsWith(`.${n}`)},ht=(r,e)=>{const t=new URL(e).protocol,n=new URL(r).protocol;return t===n},pt=ue.promisify(se.pipeline),K=Symbol("Body internals");class Ce{constructor(e,{size:t=0}={}){let n=null;e===null?e=null:zr(e)?e=U.from(e.toString()):Ue(e)||U.isBuffer(e)||(ue.types.isAnyArrayBuffer(e)?e=U.from(e):ArrayBuffer.isView(e)?e=U.from(e.buffer,e.byteOffset,e.byteLength):e instanceof se||(e=U.from(String(e))));let a=e;U.isBuffer(e)?a=se.Readable.from(e):Ue(e)&&(a=se.Readable.from(e.stream())),this[K]={body:e,stream:a,boundary:n,disturbed:!1,error:null},this.size=t,e instanceof se&&e.on("error",o=>{const s=o instanceof He?o:new ie(`Invalid response body while trying to fetch ${this.url}: ${o.message}`,"system",o);this[K].error=s})}get body(){return this[K].stream}get bodyUsed(){return this[K].disturbed}async arrayBuffer(){const{buffer:e,byteOffset:t,byteLength:n}=await Je(this);return e.slice(t,t+n)}async blob(){const e=this.headers&&this.headers.get("content-type")||this[K].body&&this[K].body.type||"",t=await this.arrayBuffer();return new Blob([t],{type:e})}async json(){const e=await this.text();return JSON.parse(e)}async text(){const e=await Je(this);return new TextDecoder().decode(e)}buffer(){return Je(this)}}Ce.prototype.buffer=ue.deprecate(Ce.prototype.buffer,"Please use 'response.arrayBuffer()' instead of 'response.buffer()'","node-fetch#buffer");Object.defineProperties(Ce.prototype,{body:{enumerable:!0},bodyUsed:{enumerable:!0},arrayBuffer:{enumerable:!0},blob:{enumerable:!0},json:{enumerable:!0},text:{enumerable:!0},data:{get:ue.deprecate(()=>{},"data doesn't exist, use json(), text(), arrayBuffer(), or body instead","https://github.com/node-fetch/node-fetch/issues/1000 (response)")}});async function Je(r){if(r[K].disturbed)throw new TypeError(`body used already for: ${r.url}`);if(r[K].disturbed=!0,r[K].error)throw r[K].error;const{body:e}=r;if(e===null)return U.alloc(0);if(!(e instanceof se))return U.alloc(0);const t=[];let n=0;try{for await(const a of e){if(r.size>0&&n+a.length>r.size){const o=new ie(`content size at ${r.url} over limit: ${r.size}`,"max-size");throw e.destroy(o),o}n+=a.length,t.push(a)}}catch(a){throw a instanceof He?a:new ie(`Invalid response body while trying to fetch ${r.url}: ${a.message}`,"system",a)}if(e.readableEnded===!0||e._readableState.ended===!0)try{return t.every(a=>typeof a=="string")?U.from(t.join("")):U.concat(t,n)}catch(a){throw new ie(`Could not create Buffer from response body for ${r.url}: ${a.message}`,"system",a)}else throw new ie(`Premature close of server response while trying to fetch ${r.url}`)}const dr=(r,e)=>{let t,n,{body:a}=r[K];if(r.bodyUsed)throw new Error("cannot clone body after it is used");return a instanceof se&&typeof a.getBoundary!="function"&&(t=new ne.PassThrough({highWaterMark:e}),n=new ne.PassThrough({highWaterMark:e}),a.pipe(t),a.pipe(n),r[K].stream=t,a=n),a},dt=ue.deprecate(r=>r.getBoundary(),"form-data doesn't follow the spec and requires special treatment. Use alternative package","https://github.com/node-fetch/node-fetch/issues/1167"),Hr=(r,e)=>r===null?null:typeof r=="string"?"text/plain;charset=UTF-8":zr(r)?"application/x-www-form-urlencoded;charset=UTF-8":Ue(r)?r.type||null:U.isBuffer(r)||ue.types.isAnyArrayBuffer(r)||ArrayBuffer.isView(r)?null:r&&typeof r.getBoundary=="function"?`multipart/form-data;boundary=${dt(r)}`:r instanceof se?null:"text/plain;charset=UTF-8",yt=r=>{const{body:e}=r[K];return e===null?0:Ue(e)?e.size:U.isBuffer(e)?e.length:e&&typeof e.getLengthSync=="function"&&e.hasKnownLength&&e.hasKnownLength()?e.getLengthSync():null},mt=async(r,{body:e})=>{e===null?r.end():await pt(e,r)},Me=typeof G.validateHeaderName=="function"?G.validateHeaderName:r=>{if(!/^[\^`\-\w!#$%&'*+.|~]+$/.test(r)){const e=new TypeError(`Header name must be a valid HTTP token [${r}]`);throw Object.defineProperty(e,"code",{value:"ERR_INVALID_HTTP_TOKEN"}),e}},ar=typeof G.validateHeaderValue=="function"?G.validateHeaderValue:(r,e)=>{if(/[^\t\u0020-\u007E\u0080-\u00FF]/.test(e)){const t=new TypeError(`Invalid character in header content ["${r}"]`);throw Object.defineProperty(t,"code",{value:"ERR_INVALID_CHAR"}),t}};class ce extends URLSearchParams{constructor(e){let t=[];if(e instanceof ce){const n=e.raw();for(const[a,o]of Object.entries(n))t.push(...o.map(s=>[a,s]))}else if(e!=null)if(typeof e=="object"&&!ue.types.isBoxedPrimitive(e)){const n=e[Symbol.iterator];if(n==null)t.push(...Object.entries(e));else{if(typeof n!="function")throw new TypeError("Header pairs must be iterable");t=[...e].map(a=>{if(typeof a!="object"||ue.types.isBoxedPrimitive(a))throw new TypeError("Each header pair must be an iterable object");return[...a]}).map(a=>{if(a.length!==2)throw new TypeError("Each header pair must be a name/value tuple");return[...a]})}}else throw new TypeError("Failed to construct 'Headers': The provided value is not of type '(sequence> or record)");return t=t.length>0?t.map(([n,a])=>(Me(n),ar(n,String(a)),[String(n).toLowerCase(),String(a)])):void 0,super(t),new Proxy(this,{get(n,a,o){switch(a){case"append":case"set":return(s,i)=>(Me(s),ar(s,String(i)),URLSearchParams.prototype[a].call(n,String(s).toLowerCase(),String(i)));case"delete":case"has":case"getAll":return s=>(Me(s),URLSearchParams.prototype[a].call(n,String(s).toLowerCase()));case"keys":return()=>(n.sort(),new Set(URLSearchParams.prototype.keys.call(n)).keys());default:return Reflect.get(n,a,o)}}})}get[Symbol.toStringTag](){return this.constructor.name}toString(){return Object.prototype.toString.call(this)}get(e){const t=this.getAll(e);if(t.length===0)return null;let n=t.join(", ");return/^content-encoding$/i.test(e)&&(n=n.toLowerCase()),n}forEach(e,t=void 0){for(const n of this.keys())Reflect.apply(e,t,[this.get(n),n,this])}*values(){for(const e of this.keys())yield this.get(e)}*entries(){for(const e of this.keys())yield[e,this.get(e)]}[Symbol.iterator](){return this.entries()}raw(){return[...this.keys()].reduce((e,t)=>(e[t]=this.getAll(t),e),{})}[Symbol.for("nodejs.util.inspect.custom")](){return[...this.keys()].reduce((e,t)=>{const n=this.getAll(t);return t==="host"?e[t]=n[0]:e[t]=n.length>1?n:n[0],e},{})}}Object.defineProperties(ce.prototype,["get","entries","forEach","values"].reduce((r,e)=>(r[e]={enumerable:!0},r),{}));function gt(r=[]){return new ce(r.reduce((e,t,n,a)=>(n%2===0&&e.push(a.slice(n,n+2)),e),[]).filter(([e,t])=>{try{return Me(e),ar(e,String(t)),!0}catch{return!1}}))}const vt=new Set([301,302,303,307,308]),qr=r=>vt.has(r),j=Symbol("Response internals");class Q extends Ce{constructor(e=null,t={}){super(e,t);const n=t.status!=null?t.status:200,a=new ce(t.headers);if(e!==null&&!a.has("Content-Type")){const o=Hr(e);o&&a.append("Content-Type",o)}this[j]={type:"default",url:t.url,status:n,statusText:t.statusText||"",headers:a,counter:t.counter,highWaterMark:t.highWaterMark}}get type(){return this[j].type}get url(){return this[j].url||""}get status(){return this[j].status}get ok(){return this[j].status>=200&&this[j].status<300}get redirected(){return this[j].counter>0}get statusText(){return this[j].statusText}get headers(){return this[j].headers}get highWaterMark(){return this[j].highWaterMark}clone(){return new Q(dr(this,this.highWaterMark),{type:this.type,url:this.url,status:this.status,statusText:this.statusText,headers:this.headers,ok:this.ok,redirected:this.redirected,size:this.size,highWaterMark:this.highWaterMark})}static redirect(e,t=302){if(!qr(t))throw new RangeError('Failed to execute "redirect" on "response": Invalid status code');return new Q(null,{headers:{location:new URL(e).toString()},status:t})}static error(){const e=new Q(null,{status:0,statusText:""});return e[j].type="error",e}static json(e=void 0,t={}){const n=JSON.stringify(e);if(n===void 0)throw new TypeError("data is not JSON serializable");const a=new ce(t&&t.headers);return a.has("content-type")||a.set("content-type","application/json"),new Q(n,{...t,headers:a})}get[Symbol.toStringTag](){return"Response"}}Object.defineProperties(Q.prototype,{type:{enumerable:!0},url:{enumerable:!0},status:{enumerable:!0},ok:{enumerable:!0},redirected:{enumerable:!0},statusText:{enumerable:!0},headers:{enumerable:!0},clone:{enumerable:!0}});var _e={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */_e.exports;(function(r,e){(function(t){var n=e&&!e.nodeType&&e,a=!r.nodeType&&r,o=typeof Oe=="object"&&Oe;(o.global===o||o.window===o||o.self===o)&&(t=o);var s,i=2147483647,l=36,f=1,c=26,b=38,u=700,m=72,h=128,T="-",g=/^xn--/,O=/[^\x20-\x7E]/,p=/[\x2E\u3002\uFF0E\uFF61]/g,y={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},S=l-f,v=Math.floor,x=String.fromCharCode,D;function $(d){throw new RangeError(y[d])}function C(d,w){for(var E=d.length,R=[];E--;)R[E]=w(d[E]);return R}function F(d,w){var E=d.split("@"),R="";E.length>1&&(R=E[0]+"@",d=E[1]),d=d.replace(p,".");var P=d.split("."),z=C(P,w).join(".");return R+z}function J(d){for(var w=[],E=0,R=d.length,P,z;E=55296&&P<=56319&&E65535&&(w-=65536,E+=x(w>>>10&1023|55296),w=56320|w&1023),E+=x(w),E}).join("")}function L(d){return d-48<10?d-22:d-65<26?d-65:d-97<26?d-97:l}function W(d,w){return d+22+75*(d<26)-((w!=0)<<5)}function k(d,w,E){var R=0;for(d=E?v(d/u):d>>1,d+=v(d/w);d>S*c>>1;R+=l)d=v(d/S);return v(R+(S+1)*d/(d+b))}function H(d){var w=[],E=d.length,R,P=0,z=h,N=m,q,Y,re,fe,B,V,X,pe,me;for(q=d.lastIndexOf(T),q<0&&(q=0),Y=0;Y=128&&$("not-basic"),w.push(d.charCodeAt(Y));for(re=q>0?q+1:0;re=E&&$("invalid-input"),X=L(d.charCodeAt(re++)),(X>=l||X>v((i-P)/B))&&$("overflow"),P+=X*B,pe=V<=N?f:V>=N+c?c:V-N,!(Xv(i/me)&&$("overflow"),B*=me;R=w.length+1,N=k(P-fe,R,fe==0),v(P/R)>i-z&&$("overflow"),z+=v(P/R),P%=R,w.splice(P++,0,z)}return Z(w)}function he(d){var w,E,R,P,z,N,q,Y,re,fe,B,V=[],X,pe,me,Qe;for(d=J(d),X=d.length,w=h,E=0,z=m,N=0;N=w&&Bv((i-E)/pe)&&$("overflow"),E+=(q-w)*pe,w=q,N=0;Ni&&$("overflow"),B==w){for(Y=E,re=l;fe=re<=z?f:re>=z+c?c:re-z,!(Y-1e3&&r<1e3||Kr.call(/e/,e))return e;var t=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof r=="number"){var n=r<0?-Or(-r):Or(r);if(n!==r){var a=String(n),o=gr.call(e,a.length+1);return de.call(a,t,"$&_")+"."+de.call(de.call(o,/([0-9]{3})/g,"$&_"),/_$/,"")}}return de.call(e,t,"$&_")}var sr=ft,Ar=sr.custom,Cr=Jr(Ar)?Ar:null,Gr={__proto__:null,double:'"',single:"'"},Pt={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},qe=function r(e,t,n,a){var o=t||{};if(le(o,"quoteStyle")&&!le(Gr,o.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(le(o,"maxStringLength")&&(typeof o.maxStringLength=="number"?o.maxStringLength<0&&o.maxStringLength!==1/0:o.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var s=le(o,"customInspect")?o.customInspect:!0;if(typeof s!="boolean"&&s!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(le(o,"indent")&&o.indent!==null&&o.indent!==" "&&!(parseInt(o.indent,10)===o.indent&&o.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(le(o,"numericSeparator")&&typeof o.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var i=o.numericSeparator;if(typeof e>"u")return"undefined";if(e===null)return"null";if(typeof e=="boolean")return e?"true":"false";if(typeof e=="string")return Yr(e,o);if(typeof e=="number"){if(e===0)return 1/0/e>0?"0":"-0";var l=String(e);return i?Rr(e,l):l}if(typeof e=="bigint"){var f=String(e)+"n";return i?Rr(e,f):f}var c=typeof o.depth>"u"?5:o.depth;if(typeof n>"u"&&(n=0),n>=c&&c>0&&typeof e=="object")return fr(e)?"[Array]":"[Object]";var b=Qt(o,n);if(typeof a>"u")a=[];else if(Zr(a,e)>=0)return"[Circular]";function u(L,W,k){if(W&&(a=Ct.call(a),a.push(W)),k){var H={depth:o.depth};return le(o,"quoteStyle")&&(H.quoteStyle=o.quoteStyle),r(L,H,n+1,a)}return r(L,o,n+1,a)}if(typeof e=="function"&&!Pr(e)){var m=_t(e),h=De(e,u);return"[Function"+(m?": "+m:" (anonymous)")+"]"+(h.length>0?" { "+oe.call(h,", ")+" }":"")}if(Jr(e)){var T=Se?de.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):ir.call(e);return typeof e=="object"&&!Se?Ee(T):T}if(Kt(e)){for(var g="<"+Er.call(String(e.nodeName)),O=e.attributes||[],p=0;p",g}if(fr(e)){if(e.length===0)return"[]";var y=De(e,u);return b&&!Gt(y)?"["+lr(y,b)+"]":"[ "+oe.call(y,", ")+" ]"}if(Dt(e)){var S=De(e,u);return!("cause"in Error.prototype)&&"cause"in e&&!Vr.call(e,"cause")?"{ ["+String(e)+"] "+oe.call(Tr.call("[cause]: "+u(e.cause),S),", ")+" }":S.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+oe.call(S,", ")+" }"}if(typeof e=="object"&&s){if(Cr&&typeof e[Cr]=="function"&&sr)return sr(e,{depth:c-n});if(s!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if(Wt(e)){var v=[];return br&&br.call(e,function(L,W){v.push(u(W,e,!0)+" => "+u(L,e))}),Lr("Map",We.call(e),v,b)}if(Ht(e)){var x=[];return Sr&&Sr.call(e,function(L){x.push(u(L,e))}),Lr("Set",ke.call(e),x,b)}if(kt(e))return je("WeakMap");if(qt(e))return je("WeakSet");if(zt(e))return je("WeakRef");if(Mt(e))return Ee(u(Number(e)));if(Bt(e))return Ee(u(or.call(e)));if(Nt(e))return Ee(Tt.call(e));if(Ft(e))return Ee(u(String(e)));if(typeof window<"u"&&e===window)return"{ [object Window] }";if(typeof globalThis<"u"&&e===globalThis||typeof Oe<"u"&&e===Oe)return"{ [object globalThis] }";if(!It(e)&&!Pr(e)){var D=De(e,u),$=$r?$r(e)===Object.prototype:e instanceof Object||e.constructor===Object,C=e instanceof Object?"":"null prototype",F=!$&&_&&Object(e)===e&&_ in e?gr.call(ye(e),8,-1):C?"Object":"",J=$||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",Z=J+(F||C?"["+oe.call(Tr.call([],F||[],C||[]),": ")+"] ":"");return D.length===0?Z+"{}":b?Z+"{"+lr(D,b)+"}":Z+"{ "+oe.call(D,", ")+" }"}return String(e)};function Qr(r,e,t){var n=t.quoteStyle||e,a=Gr[n];return a+r+a}function Lt(r){return de.call(String(r),/"/g,""")}function fr(r){return ye(r)==="[object Array]"&&(!_||!(typeof r=="object"&&_ in r))}function It(r){return ye(r)==="[object Date]"&&(!_||!(typeof r=="object"&&_ in r))}function Pr(r){return ye(r)==="[object RegExp]"&&(!_||!(typeof r=="object"&&_ in r))}function Dt(r){return ye(r)==="[object Error]"&&(!_||!(typeof r=="object"&&_ in r))}function Ft(r){return ye(r)==="[object String]"&&(!_||!(typeof r=="object"&&_ in r))}function Mt(r){return ye(r)==="[object Number]"&&(!_||!(typeof r=="object"&&_ in r))}function Nt(r){return ye(r)==="[object Boolean]"&&(!_||!(typeof r=="object"&&_ in r))}function Jr(r){if(Se)return r&&typeof r=="object"&&r instanceof Symbol;if(typeof r=="symbol")return!0;if(!r||typeof r!="object"||!ir)return!1;try{return ir.call(r),!0}catch{}return!1}function Bt(r){if(!r||typeof r!="object"||!or)return!1;try{return or.call(r),!0}catch{}return!1}var Ut=Object.prototype.hasOwnProperty||function(r){return r in this};function le(r,e){return Ut.call(r,e)}function ye(r){return Ot.call(r)}function _t(r){if(r.name)return r.name;var e=Rt.call($t.call(r),/^function\s*([\w$]+)/);return e?e[1]:null}function Zr(r,e){if(r.indexOf)return r.indexOf(e);for(var t=0,n=r.length;te.maxStringLength){var t=r.length-e.maxStringLength,n="... "+t+" more character"+(t>1?"s":"");return Yr(gr.call(r,0,e.maxStringLength),e)+n}var a=Pt[e.quoteStyle||"single"];a.lastIndex=0;var o=de.call(de.call(r,a,"\\$1"),/[\x00-\x1f]/g,Vt);return Qr(o,"single",e)}function Vt(r){var e=r.charCodeAt(0),t={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return t?"\\"+t:"\\x"+(e<16?"0":"")+At.call(e.toString(16))}function Ee(r){return"Object("+r+")"}function je(r){return r+" { ? }"}function Lr(r,e,t,n){var a=n?lr(t,n):oe.call(t,", ");return r+" ("+e+") {"+a+"}"}function Gt(r){for(var e=0;etypeof r=="object"&&typeof r.append=="function"&&typeof r.delete=="function"&&typeof r.get=="function"&&typeof r.getAll=="function"&&typeof r.has=="function"&&typeof r.set=="function"&&typeof r.sort=="function"&&r[Be]==="URLSearchParams",Ue=r=>r&&typeof r=="object"&&typeof r.arrayBuffer=="function"&&typeof r.type=="string"&&typeof r.stream=="function"&&typeof r.constructor=="function"&&/^(Blob|File)$/.test(r[Be]),ut=r=>typeof r=="object"&&(r[Be]==="AbortSignal"||r[Be]==="EventTarget"),ct=(r,e)=>{const t=new URL(e).hostname,n=new URL(r).hostname;return t===n||t.endsWith(`.${n}`)},ht=(r,e)=>{const t=new URL(e).protocol,n=new URL(r).protocol;return t===n},pt=ue.promisify(se.pipeline),K=Symbol("Body internals");class Ce{constructor(e,{size:t=0}={}){let n=null;e===null?e=null:zr(e)?e=U.from(e.toString()):Ue(e)||U.isBuffer(e)||(ue.types.isAnyArrayBuffer(e)?e=U.from(e):ArrayBuffer.isView(e)?e=U.from(e.buffer,e.byteOffset,e.byteLength):e instanceof se||(e=U.from(String(e))));let a=e;U.isBuffer(e)?a=se.Readable.from(e):Ue(e)&&(a=se.Readable.from(e.stream())),this[K]={body:e,stream:a,boundary:n,disturbed:!1,error:null},this.size=t,e instanceof se&&e.on("error",o=>{const s=o instanceof He?o:new ie(`Invalid response body while trying to fetch ${this.url}: ${o.message}`,"system",o);this[K].error=s})}get body(){return this[K].stream}get bodyUsed(){return this[K].disturbed}async arrayBuffer(){const{buffer:e,byteOffset:t,byteLength:n}=await Je(this);return e.slice(t,t+n)}async blob(){const e=this.headers&&this.headers.get("content-type")||this[K].body&&this[K].body.type||"",t=await this.arrayBuffer();return new Blob([t],{type:e})}async json(){const e=await this.text();return JSON.parse(e)}async text(){const e=await Je(this);return new TextDecoder().decode(e)}buffer(){return Je(this)}}Ce.prototype.buffer=ue.deprecate(Ce.prototype.buffer,"Please use 'response.arrayBuffer()' instead of 'response.buffer()'","node-fetch#buffer");Object.defineProperties(Ce.prototype,{body:{enumerable:!0},bodyUsed:{enumerable:!0},arrayBuffer:{enumerable:!0},blob:{enumerable:!0},json:{enumerable:!0},text:{enumerable:!0},data:{get:ue.deprecate(()=>{},"data doesn't exist, use json(), text(), arrayBuffer(), or body instead","https://github.com/node-fetch/node-fetch/issues/1000 (response)")}});async function Je(r){if(r[K].disturbed)throw new TypeError(`body used already for: ${r.url}`);if(r[K].disturbed=!0,r[K].error)throw r[K].error;const{body:e}=r;if(e===null)return U.alloc(0);if(!(e instanceof se))return U.alloc(0);const t=[];let n=0;try{for await(const a of e){if(r.size>0&&n+a.length>r.size){const o=new ie(`content size at ${r.url} over limit: ${r.size}`,"max-size");throw e.destroy(o),o}n+=a.length,t.push(a)}}catch(a){throw a instanceof He?a:new ie(`Invalid response body while trying to fetch ${r.url}: ${a.message}`,"system",a)}if(e.readableEnded===!0||e._readableState.ended===!0)try{return t.every(a=>typeof a=="string")?U.from(t.join("")):U.concat(t,n)}catch(a){throw new ie(`Could not create Buffer from response body for ${r.url}: ${a.message}`,"system",a)}else throw new ie(`Premature close of server response while trying to fetch ${r.url}`)}const dr=(r,e)=>{let t,n,{body:a}=r[K];if(r.bodyUsed)throw new Error("cannot clone body after it is used");return a instanceof se&&typeof a.getBoundary!="function"&&(t=new ne.PassThrough({highWaterMark:e}),n=new ne.PassThrough({highWaterMark:e}),a.pipe(t),a.pipe(n),r[K].stream=t,a=n),a},dt=ue.deprecate(r=>r.getBoundary(),"form-data doesn't follow the spec and requires special treatment. Use alternative package","https://github.com/node-fetch/node-fetch/issues/1167"),Hr=(r,e)=>r===null?null:typeof r=="string"?"text/plain;charset=UTF-8":zr(r)?"application/x-www-form-urlencoded;charset=UTF-8":Ue(r)?r.type||null:U.isBuffer(r)||ue.types.isAnyArrayBuffer(r)||ArrayBuffer.isView(r)?null:r&&typeof r.getBoundary=="function"?`multipart/form-data;boundary=${dt(r)}`:r instanceof se?null:"text/plain;charset=UTF-8",yt=r=>{const{body:e}=r[K];return e===null?0:Ue(e)?e.size:U.isBuffer(e)?e.length:e&&typeof e.getLengthSync=="function"&&e.hasKnownLength&&e.hasKnownLength()?e.getLengthSync():null},mt=async(r,{body:e})=>{e===null?r.end():await pt(e,r)},Me=typeof G.validateHeaderName=="function"?G.validateHeaderName:r=>{if(!/^[\^`\-\w!#$%&'*+.|~]+$/.test(r)){const e=new TypeError(`Header name must be a valid HTTP token [${r}]`);throw Object.defineProperty(e,"code",{value:"ERR_INVALID_HTTP_TOKEN"}),e}},ar=typeof G.validateHeaderValue=="function"?G.validateHeaderValue:(r,e)=>{if(/[^\t\u0020-\u007E\u0080-\u00FF]/.test(e)){const t=new TypeError(`Invalid character in header content ["${r}"]`);throw Object.defineProperty(t,"code",{value:"ERR_INVALID_CHAR"}),t}};class ce extends URLSearchParams{constructor(e){let t=[];if(e instanceof ce){const n=e.raw();for(const[a,o]of Object.entries(n))t.push(...o.map(s=>[a,s]))}else if(e!=null)if(typeof e=="object"&&!ue.types.isBoxedPrimitive(e)){const n=e[Symbol.iterator];if(n==null)t.push(...Object.entries(e));else{if(typeof n!="function")throw new TypeError("Header pairs must be iterable");t=[...e].map(a=>{if(typeof a!="object"||ue.types.isBoxedPrimitive(a))throw new TypeError("Each header pair must be an iterable object");return[...a]}).map(a=>{if(a.length!==2)throw new TypeError("Each header pair must be a name/value tuple");return[...a]})}}else throw new TypeError("Failed to construct 'Headers': The provided value is not of type '(sequence> or record)");return t=t.length>0?t.map(([n,a])=>(Me(n),ar(n,String(a)),[String(n).toLowerCase(),String(a)])):void 0,super(t),new Proxy(this,{get(n,a,o){switch(a){case"append":case"set":return(s,i)=>(Me(s),ar(s,String(i)),URLSearchParams.prototype[a].call(n,String(s).toLowerCase(),String(i)));case"delete":case"has":case"getAll":return s=>(Me(s),URLSearchParams.prototype[a].call(n,String(s).toLowerCase()));case"keys":return()=>(n.sort(),new Set(URLSearchParams.prototype.keys.call(n)).keys());default:return Reflect.get(n,a,o)}}})}get[Symbol.toStringTag](){return this.constructor.name}toString(){return Object.prototype.toString.call(this)}get(e){const t=this.getAll(e);if(t.length===0)return null;let n=t.join(", ");return/^content-encoding$/i.test(e)&&(n=n.toLowerCase()),n}forEach(e,t=void 0){for(const n of this.keys())Reflect.apply(e,t,[this.get(n),n,this])}*values(){for(const e of this.keys())yield this.get(e)}*entries(){for(const e of this.keys())yield[e,this.get(e)]}[Symbol.iterator](){return this.entries()}raw(){return[...this.keys()].reduce((e,t)=>(e[t]=this.getAll(t),e),{})}[Symbol.for("nodejs.util.inspect.custom")](){return[...this.keys()].reduce((e,t)=>{const n=this.getAll(t);return t==="host"?e[t]=n[0]:e[t]=n.length>1?n:n[0],e},{})}}Object.defineProperties(ce.prototype,["get","entries","forEach","values"].reduce((r,e)=>(r[e]={enumerable:!0},r),{}));function gt(r=[]){return new ce(r.reduce((e,t,n,a)=>(n%2===0&&e.push(a.slice(n,n+2)),e),[]).filter(([e,t])=>{try{return Me(e),ar(e,String(t)),!0}catch{return!1}}))}const vt=new Set([301,302,303,307,308]),qr=r=>vt.has(r),j=Symbol("Response internals");class Q extends Ce{constructor(e=null,t={}){super(e,t);const n=t.status!=null?t.status:200,a=new ce(t.headers);if(e!==null&&!a.has("Content-Type")){const o=Hr(e);o&&a.append("Content-Type",o)}this[j]={type:"default",url:t.url,status:n,statusText:t.statusText||"",headers:a,counter:t.counter,highWaterMark:t.highWaterMark}}get type(){return this[j].type}get url(){return this[j].url||""}get status(){return this[j].status}get ok(){return this[j].status>=200&&this[j].status<300}get redirected(){return this[j].counter>0}get statusText(){return this[j].statusText}get headers(){return this[j].headers}get highWaterMark(){return this[j].highWaterMark}clone(){return new Q(dr(this,this.highWaterMark),{type:this.type,url:this.url,status:this.status,statusText:this.statusText,headers:this.headers,ok:this.ok,redirected:this.redirected,size:this.size,highWaterMark:this.highWaterMark})}static redirect(e,t=302){if(!qr(t))throw new RangeError('Failed to execute "redirect" on "response": Invalid status code');return new Q(null,{headers:{location:new URL(e).toString()},status:t})}static error(){const e=new Q(null,{status:0,statusText:""});return e[j].type="error",e}static json(e=void 0,t={}){const n=JSON.stringify(e);if(n===void 0)throw new TypeError("data is not JSON serializable");const a=new ce(t&&t.headers);return a.has("content-type")||a.set("content-type","application/json"),new Q(n,{...t,headers:a})}get[Symbol.toStringTag](){return"Response"}}Object.defineProperties(Q.prototype,{type:{enumerable:!0},url:{enumerable:!0},status:{enumerable:!0},ok:{enumerable:!0},redirected:{enumerable:!0},statusText:{enumerable:!0},headers:{enumerable:!0},clone:{enumerable:!0}});var _e={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */_e.exports;(function(r,e){(function(t){var n=e&&!e.nodeType&&e,a=!r.nodeType&&r,o=typeof Oe=="object"&&Oe;(o.global===o||o.window===o||o.self===o)&&(t=o);var s,i=2147483647,l=36,f=1,c=26,b=38,u=700,m=72,h=128,T="-",g=/^xn--/,O=/[^\x20-\x7E]/,p=/[\x2E\u3002\uFF0E\uFF61]/g,y={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},S=l-f,v=Math.floor,x=String.fromCharCode,D;function $(d){throw new RangeError(y[d])}function C(d,w){for(var E=d.length,R=[];E--;)R[E]=w(d[E]);return R}function F(d,w){var E=d.split("@"),R="";E.length>1&&(R=E[0]+"@",d=E[1]),d=d.replace(p,".");var P=d.split("."),z=C(P,w).join(".");return R+z}function J(d){for(var w=[],E=0,R=d.length,P,z;E=55296&&P<=56319&&E65535&&(w-=65536,E+=x(w>>>10&1023|55296),w=56320|w&1023),E+=x(w),E}).join("")}function L(d){return d-48<10?d-22:d-65<26?d-65:d-97<26?d-97:l}function W(d,w){return d+22+75*(d<26)-((w!=0)<<5)}function k(d,w,E){var R=0;for(d=E?v(d/u):d>>1,d+=v(d/w);d>S*c>>1;R+=l)d=v(d/S);return v(R+(S+1)*d/(d+b))}function H(d){var w=[],E=d.length,R,P=0,z=h,N=m,q,Y,re,fe,B,V,X,pe,me;for(q=d.lastIndexOf(T),q<0&&(q=0),Y=0;Y=128&&$("not-basic"),w.push(d.charCodeAt(Y));for(re=q>0?q+1:0;re=E&&$("invalid-input"),X=L(d.charCodeAt(re++)),(X>=l||X>v((i-P)/B))&&$("overflow"),P+=X*B,pe=V<=N?f:V>=N+c?c:V-N,!(Xv(i/me)&&$("overflow"),B*=me;R=w.length+1,N=k(P-fe,R,fe==0),v(P/R)>i-z&&$("overflow"),z+=v(P/R),P%=R,w.splice(P++,0,z)}return Z(w)}function he(d){var w,E,R,P,z,N,q,Y,re,fe,B,V=[],X,pe,me,Qe;for(d=J(d),X=d.length,w=h,E=0,z=m,N=0;N=w&&Bv((i-E)/pe)&&$("overflow"),E+=(q-w)*pe,w=q,N=0;Ni&&$("overflow"),B==w){for(Y=E,re=l;fe=re<=z?f:re>=z+c?c:re-z,!(Y-1e3&&r<1e3||Kr.call(/e/,e))return e;var t=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof r=="number"){var n=r<0?-Or(-r):Or(r);if(n!==r){var a=String(n),o=gr.call(e,a.length+1);return de.call(a,t,"$&_")+"."+de.call(de.call(o,/([0-9]{3})/g,"$&_"),/_$/,"")}}return de.call(e,t,"$&_")}var sr=ft,Ar=sr.custom,Cr=Jr(Ar)?Ar:null,Gr={__proto__:null,double:'"',single:"'"},Pt={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},qe=function r(e,t,n,a){var o=t||{};if(le(o,"quoteStyle")&&!le(Gr,o.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(le(o,"maxStringLength")&&(typeof o.maxStringLength=="number"?o.maxStringLength<0&&o.maxStringLength!==1/0:o.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var s=le(o,"customInspect")?o.customInspect:!0;if(typeof s!="boolean"&&s!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(le(o,"indent")&&o.indent!==null&&o.indent!==" "&&!(parseInt(o.indent,10)===o.indent&&o.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(le(o,"numericSeparator")&&typeof o.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var i=o.numericSeparator;if(typeof e>"u")return"undefined";if(e===null)return"null";if(typeof e=="boolean")return e?"true":"false";if(typeof e=="string")return Yr(e,o);if(typeof e=="number"){if(e===0)return 1/0/e>0?"0":"-0";var l=String(e);return i?Rr(e,l):l}if(typeof e=="bigint"){var f=String(e)+"n";return i?Rr(e,f):f}var c=typeof o.depth>"u"?5:o.depth;if(typeof n>"u"&&(n=0),n>=c&&c>0&&typeof e=="object")return fr(e)?"[Array]":"[Object]";var b=Qt(o,n);if(typeof a>"u")a=[];else if(Zr(a,e)>=0)return"[Circular]";function u(L,W,k){if(W&&(a=Ct.call(a),a.push(W)),k){var H={depth:o.depth};return le(o,"quoteStyle")&&(H.quoteStyle=o.quoteStyle),r(L,H,n+1,a)}return r(L,o,n+1,a)}if(typeof e=="function"&&!Pr(e)){var m=_t(e),h=De(e,u);return"[Function"+(m?": "+m:" (anonymous)")+"]"+(h.length>0?" { "+oe.call(h,", ")+" }":"")}if(Jr(e)){var T=Se?de.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):ir.call(e);return typeof e=="object"&&!Se?Ee(T):T}if(Kt(e)){for(var g="<"+Er.call(String(e.nodeName)),O=e.attributes||[],p=0;p",g}if(fr(e)){if(e.length===0)return"[]";var y=De(e,u);return b&&!Gt(y)?"["+lr(y,b)+"]":"[ "+oe.call(y,", ")+" ]"}if(Dt(e)){var S=De(e,u);return!("cause"in Error.prototype)&&"cause"in e&&!Vr.call(e,"cause")?"{ ["+String(e)+"] "+oe.call(Tr.call("[cause]: "+u(e.cause),S),", ")+" }":S.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+oe.call(S,", ")+" }"}if(typeof e=="object"&&s){if(Cr&&typeof e[Cr]=="function"&&sr)return sr(e,{depth:c-n});if(s!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if(Wt(e)){var v=[];return br&&br.call(e,function(L,W){v.push(u(W,e,!0)+" => "+u(L,e))}),Lr("Map",We.call(e),v,b)}if(Ht(e)){var x=[];return Sr&&Sr.call(e,function(L){x.push(u(L,e))}),Lr("Set",ke.call(e),x,b)}if(kt(e))return je("WeakMap");if(qt(e))return je("WeakSet");if(zt(e))return je("WeakRef");if(Mt(e))return Ee(u(Number(e)));if(Bt(e))return Ee(u(or.call(e)));if(Nt(e))return Ee(Tt.call(e));if(Ft(e))return Ee(u(String(e)));if(typeof window<"u"&&e===window)return"{ [object Window] }";if(typeof globalThis<"u"&&e===globalThis||typeof Oe<"u"&&e===Oe)return"{ [object globalThis] }";if(!It(e)&&!Pr(e)){var D=De(e,u),$=$r?$r(e)===Object.prototype:e instanceof Object||e.constructor===Object,C=e instanceof Object?"":"null prototype",F=!$&&_&&Object(e)===e&&_ in e?gr.call(ye(e),8,-1):C?"Object":"",J=$||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",Z=J+(F||C?"["+oe.call(Tr.call([],F||[],C||[]),": ")+"] ":"");return D.length===0?Z+"{}":b?Z+"{"+lr(D,b)+"}":Z+"{ "+oe.call(D,", ")+" }"}return String(e)};function Qr(r,e,t){var n=t.quoteStyle||e,a=Gr[n];return a+r+a}function Lt(r){return de.call(String(r),/"/g,""")}function fr(r){return ye(r)==="[object Array]"&&(!_||!(typeof r=="object"&&_ in r))}function It(r){return ye(r)==="[object Date]"&&(!_||!(typeof r=="object"&&_ in r))}function Pr(r){return ye(r)==="[object RegExp]"&&(!_||!(typeof r=="object"&&_ in r))}function Dt(r){return ye(r)==="[object Error]"&&(!_||!(typeof r=="object"&&_ in r))}function Ft(r){return ye(r)==="[object String]"&&(!_||!(typeof r=="object"&&_ in r))}function Mt(r){return ye(r)==="[object Number]"&&(!_||!(typeof r=="object"&&_ in r))}function Nt(r){return ye(r)==="[object Boolean]"&&(!_||!(typeof r=="object"&&_ in r))}function Jr(r){if(Se)return r&&typeof r=="object"&&r instanceof Symbol;if(typeof r=="symbol")return!0;if(!r||typeof r!="object"||!ir)return!1;try{return ir.call(r),!0}catch{}return!1}function Bt(r){if(!r||typeof r!="object"||!or)return!1;try{return or.call(r),!0}catch{}return!1}var Ut=Object.prototype.hasOwnProperty||function(r){return r in this};function le(r,e){return Ut.call(r,e)}function ye(r){return Ot.call(r)}function _t(r){if(r.name)return r.name;var e=Rt.call($t.call(r),/^function\s*([\w$]+)/);return e?e[1]:null}function Zr(r,e){if(r.indexOf)return r.indexOf(e);for(var t=0,n=r.length;te.maxStringLength){var t=r.length-e.maxStringLength,n="... "+t+" more character"+(t>1?"s":"");return Yr(gr.call(r,0,e.maxStringLength),e)+n}var a=Pt[e.quoteStyle||"single"];a.lastIndex=0;var o=de.call(de.call(r,a,"\\$1"),/[\x00-\x1f]/g,Vt);return Qr(o,"single",e)}function Vt(r){var e=r.charCodeAt(0),t={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return t?"\\"+t:"\\x"+(e<16?"0":"")+At.call(e.toString(16))}function Ee(r){return"Object("+r+")"}function je(r){return r+" { ? }"}function Lr(r,e,t,n){var a=n?lr(t,n):oe.call(t,", ");return r+" ("+e+") {"+a+"}"}function Gt(r){for(var e=0;e=0)return!1;return!0}function Qt(r,e){var t;if(r.indent===" ")t=" ";else if(typeof r.indent=="number"&&r.indent>0)t=oe.call(Array(r.indent+1)," ");else return null;return{base:t,prev:oe.call(Array(e+1),t)}}function lr(r,e){if(r.length===0)return"";var t=` `+e.prev+e.base;return t+oe.call(r,","+t)+` `+e.prev}function De(r,e){var t=fr(r),n=[];if(t){n.length=r.length;for(var a=0;a1;){var t=e.pop(),n=t.obj[t.prop];if(ge(n)){for(var a=[],o=0;o=tr?s.slice(l,l+tr):s,c=[],b=0;b=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||o===An.RFC1738&&(u===40||u===41)){c[c.length]=f.charAt(b);continue}if(u<128){c[c.length]=te[u];continue}if(u<2048){c[c.length]=te[192|u>>6]+te[128|u&63];continue}if(u<55296||u>=57344){c[c.length]=te[224|u>>12]+te[128|u>>6&63]+te[128|u&63];continue}b+=1,u=65536+((u&1023)<<10|f.charCodeAt(b)&1023),c[c.length]=te[240|u>>18]+te[128|u>>12&63]+te[128|u>>6&63]+te[128|u&63]}i+=c.join("")}return i},Fn=function(e){for(var t=[{obj:{o:e},prop:"o"}],n=[],a=0;a"u"&&(v=0)}if(typeof c=="function"?y=c(t,y):y instanceof Date?y=m(y):n==="comma"&&ae(y)&&(y=Ne.maybeMap(y,function(d){return d instanceof Date?m(d):d})),y===null){if(s)return f&&!g?f(t,I.encoder,O,"key",h):t;y=""}if(zn(y)||Ne.isBuffer(y)){if(f){var $=g?t:f(t,I.encoder,O,"key",h);return[T($)+"="+T(f(y,I.encoder,O,"value",h))]}return[T(t)+"="+T(String(y))]}var C=[];if(typeof y>"u")return C;var F;if(n==="comma"&&ae(y))g&&f&&(y=Ne.maybeMap(y,f)),F=[{value:y.length>0?y.join(",")||null:void 0}];else if(ae(c))F=c;else{var J=Object.keys(y);F=b?J.sort(b):J}var Z=l?t.replace(/\./g,"%2E"):t,L=a&&ae(y)&&y.length===1?Z+"[]":Z;if(o&&ae(y)&&y.length===0)return L+"[]";for(var W=0;W"u"?e.encodeDotInKeys===!0?!0:I.allowDots:!!e.allowDots;return{addQueryPrefix:typeof e.addQueryPrefix=="boolean"?e.addQueryPrefix:I.addQueryPrefix,allowDots:i,allowEmptyArrays:typeof e.allowEmptyArrays=="boolean"?!!e.allowEmptyArrays:I.allowEmptyArrays,arrayFormat:s,charset:t,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:I.charsetSentinel,commaRoundTrip:e.commaRoundTrip,delimiter:typeof e.delimiter>"u"?I.delimiter:e.delimiter,encode:typeof e.encode=="boolean"?e.encode:I.encode,encodeDotInKeys:typeof e.encodeDotInKeys=="boolean"?e.encodeDotInKeys:I.encodeDotInKeys,encoder:typeof e.encoder=="function"?e.encoder:I.encoder,encodeValuesOnly:typeof e.encodeValuesOnly=="boolean"?e.encodeValuesOnly:I.encodeValuesOnly,filter:o,format:n,formatter:a,serializeDate:typeof e.serializeDate=="function"?e.serializeDate:I.serializeDate,skipNulls:typeof e.skipNulls=="boolean"?e.skipNulls:I.skipNulls,sort:typeof e.sort=="function"?e.sort:null,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:I.strictNullHandling}},Kn=function(r,e){var t=r,n=qn(e),a,o;typeof n.filter=="function"?(o=n.filter,t=o("",t)):ae(n.filter)&&(o=n.filter,a=o);var s=[];if(typeof t!="object"||t===null)return"";var i=tt[n.arrayFormat],l=i==="comma"&&n.commaRoundTrip;a||(a=Object.keys(t)),n.sort&&a.sort(n.sort);for(var f=rt(),c=0;c0?m+u:""},xe=et,ur=Object.prototype.hasOwnProperty,Vn=Array.isArray,A={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:xe.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictNullHandling:!1},Gn=function(r){return r.replace(/&#(\d+);/g,function(e,t){return String.fromCharCode(parseInt(t,10))})},at=function(r,e){return r&&typeof r=="string"&&e.comma&&r.indexOf(",")>-1?r.split(","):r},Qn="utf8=%26%2310003%3B",Jn="utf8=%E2%9C%93",Zn=function(e,t){var n={__proto__:null},a=t.ignoreQueryPrefix?e.replace(/^\?/,""):e;a=a.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var o=t.parameterLimit===1/0?void 0:t.parameterLimit,s=a.split(t.delimiter,o),i=-1,l,f=t.charset;if(t.charsetSentinel)for(l=0;l-1&&(h=Vn(h)?[h]:h);var T=ur.call(n,m);T&&t.duplicates==="combine"?n[m]=xe.combine(n[m],h):(!T||t.duplicates==="last")&&(n[m]=h)}return n},Yn=function(r,e,t,n){for(var a=n?e:at(e,t),o=r.length-1;o>=0;--o){var s,i=r[o];if(i==="[]"&&t.parseArrays)s=t.allowEmptyArrays&&(a===""||t.strictNullHandling&&a===null)?[]:[].concat(a);else{s=t.plainObjects?Object.create(null):{};var l=i.charAt(0)==="["&&i.charAt(i.length-1)==="]"?i.slice(1,-1):i,f=t.decodeDotInKeys?l.replace(/%2E/g,"."):l,c=parseInt(f,10);!t.parseArrays&&f===""?s={0:a}:!isNaN(c)&&i!==f&&String(c)===f&&c>=0&&t.parseArrays&&c<=t.arrayLimit?(s=[],s[c]=a):f!=="__proto__"&&(s[f]=a)}a=s}return a},Xn=function(e,t,n,a){if(e){var o=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,s=/(\[[^[\]]*])/,i=/(\[[^[\]]*])/g,l=n.depth>0&&s.exec(o),f=l?o.slice(0,l.index):o,c=[];if(f){if(!n.plainObjects&&ur.call(Object.prototype,f)&&!n.allowPrototypes)return;c.push(f)}for(var b=0;n.depth>0&&(l=i.exec(o))!==null&&b"u"?A.charset:e.charset,n=typeof e.duplicates>"u"?A.duplicates:e.duplicates;if(n!=="combine"&&n!=="first"&&n!=="last")throw new TypeError("The duplicates option must be either combine, first, or last");var a=typeof e.allowDots>"u"?e.decodeDotInKeys===!0?!0:A.allowDots:!!e.allowDots;return{allowDots:a,allowEmptyArrays:typeof e.allowEmptyArrays=="boolean"?!!e.allowEmptyArrays:A.allowEmptyArrays,allowPrototypes:typeof e.allowPrototypes=="boolean"?e.allowPrototypes:A.allowPrototypes,allowSparse:typeof e.allowSparse=="boolean"?e.allowSparse:A.allowSparse,arrayLimit:typeof e.arrayLimit=="number"?e.arrayLimit:A.arrayLimit,charset:t,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:A.charsetSentinel,comma:typeof e.comma=="boolean"?e.comma:A.comma,decodeDotInKeys:typeof e.decodeDotInKeys=="boolean"?e.decodeDotInKeys:A.decodeDotInKeys,decoder:typeof e.decoder=="function"?e.decoder:A.decoder,delimiter:typeof e.delimiter=="string"||xe.isRegExp(e.delimiter)?e.delimiter:A.delimiter,depth:typeof e.depth=="number"||e.depth===!1?+e.depth:A.depth,duplicates:n,ignoreQueryPrefix:e.ignoreQueryPrefix===!0,interpretNumericEntities:typeof e.interpretNumericEntities=="boolean"?e.interpretNumericEntities:A.interpretNumericEntities,parameterLimit:typeof e.parameterLimit=="number"?e.parameterLimit:A.parameterLimit,parseArrays:e.parseArrays!==!1,plainObjects:typeof e.plainObjects=="boolean"?e.plainObjects:A.plainObjects,strictDepth:typeof e.strictDepth=="boolean"?!!e.strictDepth:A.strictDepth,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:A.strictNullHandling}},ea=function(r,e){var t=jn(e);if(r===""||r===null||typeof r>"u")return t.plainObjects?Object.create(null):{};for(var n=typeof r=="string"?Zn(r,t):r,a=t.plainObjects?Object.create(null):{},o=Object.keys(n),s=0;s",'"',"`"," ","\r",` diff --git a/apps/cli/frontend/assets/index-D5ks1fN6.js b/apps/cli/frontend/assets/index-DTsNrB5y.js similarity index 99% rename from apps/cli/frontend/assets/index-D5ks1fN6.js rename to apps/cli/frontend/assets/index-DTsNrB5y.js index b42a12bf..423f5ba8 100644 --- a/apps/cli/frontend/assets/index-D5ks1fN6.js +++ b/apps/cli/frontend/assets/index-DTsNrB5y.js @@ -1,4 +1,4 @@ -import{aX as ae,aY as mt,aW as ut}from"./index-C0B7FSMw.js";import{u as Oe,s as Et,c as wt,e as Ot,g as St,a as Ge,h as jt,d as Pt,b as je}from"./browser-DplhMTqm.js";import{A as Rt}from"./index-C4_N9hxJ.js";import"./__vite-browser-external-v7f2oYTb.js";var Ae={exports:{}},Ne={},Ce;function ft(){if(Ce)return Ne;Ce=1;function p(i){"@babel/helpers - typeof";return p=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(c){return typeof c}:function(c){return c&&typeof Symbol=="function"&&c.constructor===Symbol&&c!==Symbol.prototype?"symbol":typeof c},p(i)}function g(i,c,d){return Object.defineProperty(i,"prototype",{writable:!1}),i}function v(i,c){if(!(i instanceof c))throw new TypeError("Cannot call a class as a function")}function b(i,c){if(typeof c!="function"&&c!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(c&&c.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),Object.defineProperty(i,"prototype",{writable:!1}),c&&$(i,c)}function $(i,c){return $=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(P,L){return P.__proto__=L,P},$(i,c)}function I(i){var c=G();return function(){var P=T(i),L;if(c){var R=T(this).constructor;L=Reflect.construct(P,arguments,R)}else L=P.apply(this,arguments);return A(this,L)}}function A(i,c){if(c&&(p(c)==="object"||typeof c=="function"))return c;if(c!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return z(i)}function z(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}function G(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function T(i){return T=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(d){return d.__proto__||Object.getPrototypeOf(d)},T(i)}var D={},x,j;function m(i,c,d){d||(d=Error);function P(R,W,F){return typeof c=="string"?c:c(R,W,F)}var L=function(R){b(F,R);var W=I(F);function F(te,re,H){var Q;return v(this,F),Q=W.call(this,P(te,re,H)),Q.code=i,Q}return g(F)}(d);D[i]=L}function k(i,c){if(Array.isArray(i)){var d=i.length;return i=i.map(function(P){return String(P)}),d>2?"one of ".concat(c," ").concat(i.slice(0,d-1).join(", "),", or ")+i[d-1]:d===2?"one of ".concat(c," ").concat(i[0]," or ").concat(i[1]):"of ".concat(c," ").concat(i[0])}else return"of ".concat(c," ").concat(String(i))}function X(i,c,d){return i.substr(0,c.length)===c}function J(i,c,d){return(d===void 0||d>i.length)&&(d=i.length),i.substring(d-c.length,d)===c}function B(i,c,d){return typeof d!="number"&&(d=0),d+c.length>i.length?!1:i.indexOf(c,d)!==-1}return m("ERR_AMBIGUOUS_ARGUMENT",'The "%s" argument is ambiguous. %s',TypeError),m("ERR_INVALID_ARG_TYPE",function(i,c,d){x===void 0&&(x=Ve()),x(typeof i=="string","'name' must be a string");var P;typeof c=="string"&&X(c,"not ")?(P="must not be",c=c.replace(/^not /,"")):P="must be";var L;if(J(i," argument"))L="The ".concat(i," ").concat(P," ").concat(k(c,"type"));else{var R=B(i,".")?"property":"argument";L='The "'.concat(i,'" ').concat(R," ").concat(P," ").concat(k(c,"type"))}return L+=". Received type ".concat(p(d)),L},TypeError),m("ERR_INVALID_ARG_VALUE",function(i,c){var d=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"is invalid";j===void 0&&(j=Oe);var P=j.inspect(c);return P.length>128&&(P="".concat(P.slice(0,128),"...")),"The argument '".concat(i,"' ").concat(d,". Received ").concat(P)},TypeError),m("ERR_INVALID_RETURN_VALUE",function(i,c,d){var P;return d&&d.constructor&&d.constructor.name?P="instance of ".concat(d.constructor.name):P="type ".concat(p(d)),"Expected ".concat(i,' to be returned from the "').concat(c,'"')+" function but got ".concat(P,".")},TypeError),m("ERR_MISSING_ARGS",function(){for(var i=arguments.length,c=new Array(i),d=0;d0,"At least one arg needs to be specified");var P="The ",L=c.length;switch(c=c.map(function(R){return'"'.concat(R,'"')}),L){case 1:P+="".concat(c[0]," argument");break;case 2:P+="".concat(c[0]," and ").concat(c[1]," arguments");break;default:P+=c.slice(0,L-1).join(", "),P+=", and ".concat(c[L-1]," arguments");break}return"".concat(P," must be specified")},TypeError),Ne.codes=D,Ne}var Ie,ze;function qt(){if(ze)return Ie;ze=1;function p(a,u){var w=Object.keys(a);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(a);u&&(y=y.filter(function(q){return Object.getOwnPropertyDescriptor(a,q).enumerable})),w.push.apply(w,y)}return w}function g(a){for(var u=1;u"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function X(a){return Function.toString.call(a).indexOf("[native code]")!==-1}function J(a,u){return J=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(y,q){return y.__proto__=q,y},J(a,u)}function B(a){return B=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(w){return w.__proto__||Object.getPrototypeOf(w)},B(a)}function i(a){"@babel/helpers - typeof";return i=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(u){return typeof u}:function(u){return u&&typeof Symbol=="function"&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u},i(a)}var c=Oe,d=c.inspect,P=ft(),L=P.codes.ERR_INVALID_ARG_TYPE;function R(a,u,w){return(w===void 0||w>a.length)&&(w=a.length),a.substring(w-u.length,w)===u}function W(a,u){if(u=Math.floor(u),a.length==0||u==0)return"";var w=a.length*u;for(u=Math.floor(Math.log(u)/Math.log(2));u;)a+=a,u--;return a+=a.substring(0,w-a.length),a}var F="",te="",re="",H="",Q={deepStrictEqual:"Expected values to be strictly deep-equal:",strictEqual:"Expected values to be strictly equal:",strictEqualObject:'Expected "actual" to be reference-equal to "expected":',deepEqual:"Expected values to be loosely deep-equal:",equal:"Expected values to be loosely equal:",notDeepStrictEqual:'Expected "actual" not to be strictly deep-equal to:',notStrictEqual:'Expected "actual" to be strictly unequal to:',notStrictEqualObject:'Expected "actual" not to be reference-equal to "expected":',notDeepEqual:'Expected "actual" not to be loosely deep-equal to:',notEqual:'Expected "actual" to be loosely unequal to:',notIdentical:"Values identical but not reference-equal:"},he=10;function ge(a){var u=Object.keys(a),w=Object.create(Object.getPrototypeOf(a));return u.forEach(function(y){w[y]=a[y]}),Object.defineProperty(w,"message",{value:a.message}),w}function ie(a){return d(a,{compact:!1,customInspect:!1,depth:1e3,maxArrayLength:1/0,showHidden:!1,breakLength:1/0,showProxy:!1,sorted:!0,getters:!0})}function ye(a,u,w){var y="",q="",n=0,t="",o=!1,l=ie(a),f=l.split(` +import{aX as ae,aY as mt,aW as ut}from"./index-BcZMUM3W.js";import{u as Oe,s as Et,c as wt,e as Ot,g as St,a as Ge,h as jt,d as Pt,b as je}from"./browser-9oIzATog.js";import{A as Rt}from"./index-Dc5kAPfD.js";import"./__vite-browser-external-v7f2oYTb.js";var Ae={exports:{}},Ne={},Ce;function ft(){if(Ce)return Ne;Ce=1;function p(i){"@babel/helpers - typeof";return p=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(c){return typeof c}:function(c){return c&&typeof Symbol=="function"&&c.constructor===Symbol&&c!==Symbol.prototype?"symbol":typeof c},p(i)}function g(i,c,d){return Object.defineProperty(i,"prototype",{writable:!1}),i}function v(i,c){if(!(i instanceof c))throw new TypeError("Cannot call a class as a function")}function b(i,c){if(typeof c!="function"&&c!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(c&&c.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),Object.defineProperty(i,"prototype",{writable:!1}),c&&$(i,c)}function $(i,c){return $=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(P,L){return P.__proto__=L,P},$(i,c)}function I(i){var c=G();return function(){var P=T(i),L;if(c){var R=T(this).constructor;L=Reflect.construct(P,arguments,R)}else L=P.apply(this,arguments);return A(this,L)}}function A(i,c){if(c&&(p(c)==="object"||typeof c=="function"))return c;if(c!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return z(i)}function z(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}function G(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function T(i){return T=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(d){return d.__proto__||Object.getPrototypeOf(d)},T(i)}var D={},x,j;function m(i,c,d){d||(d=Error);function P(R,W,F){return typeof c=="string"?c:c(R,W,F)}var L=function(R){b(F,R);var W=I(F);function F(te,re,H){var Q;return v(this,F),Q=W.call(this,P(te,re,H)),Q.code=i,Q}return g(F)}(d);D[i]=L}function k(i,c){if(Array.isArray(i)){var d=i.length;return i=i.map(function(P){return String(P)}),d>2?"one of ".concat(c," ").concat(i.slice(0,d-1).join(", "),", or ")+i[d-1]:d===2?"one of ".concat(c," ").concat(i[0]," or ").concat(i[1]):"of ".concat(c," ").concat(i[0])}else return"of ".concat(c," ").concat(String(i))}function X(i,c,d){return i.substr(0,c.length)===c}function J(i,c,d){return(d===void 0||d>i.length)&&(d=i.length),i.substring(d-c.length,d)===c}function B(i,c,d){return typeof d!="number"&&(d=0),d+c.length>i.length?!1:i.indexOf(c,d)!==-1}return m("ERR_AMBIGUOUS_ARGUMENT",'The "%s" argument is ambiguous. %s',TypeError),m("ERR_INVALID_ARG_TYPE",function(i,c,d){x===void 0&&(x=Ve()),x(typeof i=="string","'name' must be a string");var P;typeof c=="string"&&X(c,"not ")?(P="must not be",c=c.replace(/^not /,"")):P="must be";var L;if(J(i," argument"))L="The ".concat(i," ").concat(P," ").concat(k(c,"type"));else{var R=B(i,".")?"property":"argument";L='The "'.concat(i,'" ').concat(R," ").concat(P," ").concat(k(c,"type"))}return L+=". Received type ".concat(p(d)),L},TypeError),m("ERR_INVALID_ARG_VALUE",function(i,c){var d=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"is invalid";j===void 0&&(j=Oe);var P=j.inspect(c);return P.length>128&&(P="".concat(P.slice(0,128),"...")),"The argument '".concat(i,"' ").concat(d,". Received ").concat(P)},TypeError),m("ERR_INVALID_RETURN_VALUE",function(i,c,d){var P;return d&&d.constructor&&d.constructor.name?P="instance of ".concat(d.constructor.name):P="type ".concat(p(d)),"Expected ".concat(i,' to be returned from the "').concat(c,'"')+" function but got ".concat(P,".")},TypeError),m("ERR_MISSING_ARGS",function(){for(var i=arguments.length,c=new Array(i),d=0;d0,"At least one arg needs to be specified");var P="The ",L=c.length;switch(c=c.map(function(R){return'"'.concat(R,'"')}),L){case 1:P+="".concat(c[0]," argument");break;case 2:P+="".concat(c[0]," and ").concat(c[1]," arguments");break;default:P+=c.slice(0,L-1).join(", "),P+=", and ".concat(c[L-1]," arguments");break}return"".concat(P," must be specified")},TypeError),Ne.codes=D,Ne}var Ie,ze;function qt(){if(ze)return Ie;ze=1;function p(a,u){var w=Object.keys(a);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(a);u&&(y=y.filter(function(q){return Object.getOwnPropertyDescriptor(a,q).enumerable})),w.push.apply(w,y)}return w}function g(a){for(var u=1;u"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function X(a){return Function.toString.call(a).indexOf("[native code]")!==-1}function J(a,u){return J=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(y,q){return y.__proto__=q,y},J(a,u)}function B(a){return B=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(w){return w.__proto__||Object.getPrototypeOf(w)},B(a)}function i(a){"@babel/helpers - typeof";return i=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(u){return typeof u}:function(u){return u&&typeof Symbol=="function"&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u},i(a)}var c=Oe,d=c.inspect,P=ft(),L=P.codes.ERR_INVALID_ARG_TYPE;function R(a,u,w){return(w===void 0||w>a.length)&&(w=a.length),a.substring(w-u.length,w)===u}function W(a,u){if(u=Math.floor(u),a.length==0||u==0)return"";var w=a.length*u;for(u=Math.floor(Math.log(u)/Math.log(2));u;)a+=a,u--;return a+=a.substring(0,w-a.length),a}var F="",te="",re="",H="",Q={deepStrictEqual:"Expected values to be strictly deep-equal:",strictEqual:"Expected values to be strictly equal:",strictEqualObject:'Expected "actual" to be reference-equal to "expected":',deepEqual:"Expected values to be loosely deep-equal:",equal:"Expected values to be loosely equal:",notDeepStrictEqual:'Expected "actual" not to be strictly deep-equal to:',notStrictEqual:'Expected "actual" to be strictly unequal to:',notStrictEqualObject:'Expected "actual" not to be reference-equal to "expected":',notDeepEqual:'Expected "actual" not to be loosely deep-equal to:',notEqual:'Expected "actual" to be loosely unequal to:',notIdentical:"Values identical but not reference-equal:"},he=10;function ge(a){var u=Object.keys(a),w=Object.create(Object.getPrototypeOf(a));return u.forEach(function(y){w[y]=a[y]}),Object.defineProperty(w,"message",{value:a.message}),w}function ie(a){return d(a,{compact:!1,customInspect:!1,depth:1e3,maxArrayLength:1/0,showHidden:!1,breakLength:1/0,showProxy:!1,sorted:!0,getters:!0})}function ye(a,u,w){var y="",q="",n=0,t="",o=!1,l=ie(a),f=l.split(` `),h=ie(u).split(` `),O=0,U="";if(w==="strictEqual"&&i(a)==="object"&&i(u)==="object"&&a!==null&&u!==null&&(w="strictEqualObject"),f.length===1&&h.length===1&&f[0]!==h[0]){var C=f[0].length+h[0].length;if(C<=he){if((i(a)!=="object"||a===null)&&(i(u)!=="object"||u===null)&&(a!==0||u!==0))return"".concat(Q[w],` diff --git a/apps/cli/frontend/assets/index-C4_N9hxJ.js b/apps/cli/frontend/assets/index-Dc5kAPfD.js similarity index 93% rename from apps/cli/frontend/assets/index-C4_N9hxJ.js rename to apps/cli/frontend/assets/index-Dc5kAPfD.js index b5e6f92a..83f804b4 100644 --- a/apps/cli/frontend/assets/index-C4_N9hxJ.js +++ b/apps/cli/frontend/assets/index-Dc5kAPfD.js @@ -1,2 +1,2 @@ -import"./index-C0B7FSMw.js";function u(){const{stack:r}=new Error;return typeof r!="string"?!1:r.split(` +import"./index-BcZMUM3W.js";function u(){const{stack:r}=new Error;return typeof r!="string"?!1:r.split(` `).some(t=>t.indexOf("(https.js:")!==-1||t.indexOf("node:https:")!==-1)}const e=Symbol("AgentBaseInternalState");class d extends(void 0){constructor(t){super(t),this[e]={}}createSocket(t,n,c){let o=typeof n.secureEndpoint=="boolean"?n.secureEndpoint:void 0;typeof o>"u"&&typeof n.protocol=="string"&&(o=n.protocol==="https:"),typeof o>"u"&&(o=u());const i={...n,secureEndpoint:o};Promise.resolve().then(()=>this.connect(t,i)).then(s=>{if(s instanceof void 0)return s.addRequest(t,i);this[e].currentSocket=s,super.createSocket(t,n,c)},c)}createConnection(){const t=this[e].currentSocket;if(this[e].currentSocket=void 0,!t)throw new Error("No socket was returned in the `connect()` function");return t}get defaultPort(){return this[e].defaultPort??(this.protocol==="https:"?443:80)}set defaultPort(t){this[e]&&(this[e].defaultPort=t)}get protocol(){return this[e].protocol??(u()?"https:":"http:")}set protocol(t){this[e]&&(this[e].protocol=t)}}export{d as A}; diff --git a/apps/cli/frontend/assets/index-lYdp9a7W.js b/apps/cli/frontend/assets/index-Dm5rXNPH.js similarity index 92% rename from apps/cli/frontend/assets/index-lYdp9a7W.js rename to apps/cli/frontend/assets/index-Dm5rXNPH.js index dde0fa1b..f3666c36 100644 --- a/apps/cli/frontend/assets/index-lYdp9a7W.js +++ b/apps/cli/frontend/assets/index-Dm5rXNPH.js @@ -1,3 +1,3 @@ -import{aW as l}from"./index-C0B7FSMw.js";import{b as y,o as x}from"./browser-DplhMTqm.js";import{A as m}from"./index-C4_N9hxJ.js";import"./__vite-browser-external-v7f2oYTb.js";function g(s){return typeof s=="string"?/^https:?$/i.test(s):!1}class H extends m{constructor(t,e){super(e),this.proxy=typeof t=="string"?new URL(t):t,this.proxyHeaders=(e==null?void 0:e.headers)??{};const o=(this.proxy.hostname||this.proxy.host).replace(/^\[|\]$/g,""),a=this.proxy.port?parseInt(this.proxy.port,10):this.secureProxy?443:80;this.connectOpts={...e?P(e,"headers"):null,host:o,port:a}}get secureProxy(){return g(this.proxy.protocol)}async connect(t,e){const{proxy:o}=this,a=e.secureEndpoint?"https:":"http:",d=t.getHeader("host")||"localhost",f=`${a}//${d}`,p=new URL(t.path,f);e.port!==80&&(p.port=String(e.port)),t.path=String(p),t._header=null;const n=typeof this.proxyHeaders=="function"?this.proxyHeaders():{...this.proxyHeaders};if(o.username||o.password){const i=`${decodeURIComponent(o.username)}:${decodeURIComponent(o.password)}`;n["Proxy-Authorization"]=`Basic ${l.from(i).toString("base64")}`}n["Proxy-Connection"]||(n["Proxy-Connection"]=this.keepAlive?"Keep-Alive":"close");for(const i of Object.keys(n)){const u=n[i];u&&t.setHeader(i,u)}let r;this.secureProxy?r=(void 0)(this.connectOpts):r=y.connect(this.connectOpts);let c,h;return t._implicitHeader(),t.outputData&&t.outputData.length>0&&(c=t.outputData[0].data,h=c.indexOf(`\r +import{aW as l}from"./index-BcZMUM3W.js";import{b as y,o as x}from"./browser-9oIzATog.js";import{A as m}from"./index-Dc5kAPfD.js";import"./__vite-browser-external-v7f2oYTb.js";function g(s){return typeof s=="string"?/^https:?$/i.test(s):!1}class H extends m{constructor(t,e){super(e),this.proxy=typeof t=="string"?new URL(t):t,this.proxyHeaders=(e==null?void 0:e.headers)??{};const o=(this.proxy.hostname||this.proxy.host).replace(/^\[|\]$/g,""),a=this.proxy.port?parseInt(this.proxy.port,10):this.secureProxy?443:80;this.connectOpts={...e?P(e,"headers"):null,host:o,port:a}}get secureProxy(){return g(this.proxy.protocol)}async connect(t,e){const{proxy:o}=this,a=e.secureEndpoint?"https:":"http:",d=t.getHeader("host")||"localhost",f=`${a}//${d}`,p=new URL(t.path,f);e.port!==80&&(p.port=String(e.port)),t.path=String(p),t._header=null;const n=typeof this.proxyHeaders=="function"?this.proxyHeaders():{...this.proxyHeaders};if(o.username||o.password){const i=`${decodeURIComponent(o.username)}:${decodeURIComponent(o.password)}`;n["Proxy-Authorization"]=`Basic ${l.from(i).toString("base64")}`}n["Proxy-Connection"]||(n["Proxy-Connection"]=this.keepAlive?"Keep-Alive":"close");for(const i of Object.keys(n)){const u=n[i];u&&t.setHeader(i,u)}let r;this.secureProxy?r=(void 0)(this.connectOpts):r=y.connect(this.connectOpts);let c,h;return t._implicitHeader(),t.outputData&&t.outputData.length>0&&(c=t.outputData[0].data,h=c.indexOf(`\r \r `)+4,t.outputData[0].data=t._header+c.substring(h)),await x(r,"connect"),r}}H.protocols=["http","https"];function P(s,...t){const e={};let o;for(o in s)t.includes(o)||(e[o]=s[o]);return e}export{H as HttpProxyAgent}; diff --git a/apps/cli/frontend/assets/page-D3nC2yWj.js b/apps/cli/frontend/assets/page-CoZS_l39.js similarity index 93% rename from apps/cli/frontend/assets/page-D3nC2yWj.js rename to apps/cli/frontend/assets/page-CoZS_l39.js index 1b1cfb01..fc879d62 100644 --- a/apps/cli/frontend/assets/page-D3nC2yWj.js +++ b/apps/cli/frontend/assets/page-CoZS_l39.js @@ -1 +1 @@ -import{d as G,u as F,a as I,b as c,t as l,c as C,j as s,B as w,C as A,e as S,f as d,s as f,g as P,h as j,i as L,k as Q,r as p,S as v,D as k,l as N,G as u,m as D,n as z,o as E,p as T,q as O,v as R,E as q,w as W}from"./index-C0B7FSMw.js";import{s as H,a as B,b as M,c as U,d as J,e as K,f as V,F as X,A as Y,S as Z,I as _,g as $,B as ss,h as es,i as ts,G as is}from"./SimpleGridForm-BMdftmE-.js";function rs(r){const{gridLines:n,symbolId:t,exchangeAccountId:i,botName:a}=r,{currencyPairSymbol:e}=G(t);return{exchangeAccountId:i,data:{name:a,settings:{gridLines:n},symbol:e}}}const ns=()=>{const{showSnackbar:r}=F(),n=I(),t=c(H),{mutate:i,isLoading:a}=l.gridBot.create.useMutation({onSuccess(o){r("Bot created successfully"),setTimeout(()=>{n({to:C("grid-bot/:id",o.id)})},1e3)}}),e=()=>{const o=rs(t);i(o)};return s.jsx(w,{color:"primary",disabled:a,onClick:e,startDecorator:a?s.jsx(A,{size:"md"}):null,type:"submit",variant:"outlined",children:"Create"})},as=()=>{var h;const r=S(),n=c(B),{data:t}=l.symbol.getOne.useQuery({symbolId:n},{refetchOnWindowFocus:!1});if(d(t)&&t){const x=((h=t.filters.limits.amount)!=null&&h.min?t.filters.limits.amount.min*10:"").toString()||"";r(f(x))}const{data:i}=l.gridBot.formOptions.useQuery({symbolId:n},{refetchOnWindowFocus:!1});d(i)&&i&&(r(P(i.highPrice)),r(j(i.lowPrice)));const a=c(M),e=c(U),o=c(J),m=c(K);if([d(a),d(e),d(o),d(m),d(t)].includes(!0)&&t){const g=V(a,e,o,Number(m),t.filters);r(L(g))}return s.jsxs(Q,{sx:{padding:0},children:[s.jsx(X,{advancedForm:s.jsx(p.Suspense,{fallback:s.jsx(v,{height:60,variant:"rectangular",width:"100%"}),children:s.jsx(Y,{})}),simpleForm:s.jsx(Z,{})}),s.jsx(k,{}),s.jsx(N,{sx:{px:2,pt:1,pb:2},children:s.jsxs(u,{container:!0,spacing:2,children:[s.jsx(u,{xs:12,children:s.jsx(p.Suspense,{fallback:s.jsx(_,{withLabel:!0}),children:s.jsx($,{})})}),s.jsx(u,{xs:12,children:s.jsx(ss,{})}),s.jsx(u,{xs:12,children:s.jsx(ns,{})})]})})]})};function os(){const[r]=l.exchangeAccount.list.useSuspenseQuery(),n=r[0],[t]=l.symbol.list.useSuspenseQuery(n.exchangeCode),i=t.find(m=>m.currencyPair==="BTC/USDT")||t[0],[{price:a}]=l.symbol.price.useSuspenseQuery({symbolId:i.symbolId}),[{lowPrice:e,highPrice:o}]=l.gridBot.formOptions.useSuspenseQuery({symbolId:i.symbolId});return{exchangeAccount:n,symbol:i,currentAssetPrice:a,lowPrice:e,highPrice:o}}function ls(){var x;const{exchangeAccount:r,symbol:n,lowPrice:t,highPrice:i,currentAssetPrice:a}=os(),e=S();if(D()){const b=(x=n.filters.limits.amount)!=null&&x.min?n.filters.limits.amount.min*10:"";e(z(r.id)),e(E(r.exchangeCode)),e(T(n.symbolId)),e(f(b.toString()||"")),e(j(t)),e(P(i)),e(O(R()))}const m=c(B),y=c(es),h=b=>e(W(b)),g=c(ts);return s.jsx(u,{container:!0,spacing:2,children:s.jsxs(q,{children:[s.jsx(u,{md:9,children:s.jsx(is,{barSize:y,currentAssetPrice:a,gridLines:g,onBarSizeChange:h,symbolId:m})}),s.jsx(u,{md:3,children:s.jsx(as,{})})]})})}export{ls as default}; +import{d as G,u as F,a as I,b as c,t as l,c as C,j as s,B as w,C as A,e as S,f as d,s as f,g as P,h as j,i as L,k as Q,r as p,S as v,D as k,l as N,G as u,m as D,n as z,o as E,p as T,q as O,v as R,E as q,w as W}from"./index-BcZMUM3W.js";import{s as H,a as B,b as M,c as U,d as J,e as K,f as V,F as X,A as Y,S as Z,I as _,g as $,B as ss,h as es,i as ts,G as is}from"./SimpleGridForm-E2pE-hYE.js";function rs(r){const{gridLines:n,symbolId:t,exchangeAccountId:i,botName:a}=r,{currencyPairSymbol:e}=G(t);return{exchangeAccountId:i,data:{name:a,settings:{gridLines:n},symbol:e}}}const ns=()=>{const{showSnackbar:r}=F(),n=I(),t=c(H),{mutate:i,isLoading:a}=l.gridBot.create.useMutation({onSuccess(o){r("Bot created successfully"),setTimeout(()=>{n({to:C("grid-bot/:id",o.id)})},1e3)}}),e=()=>{const o=rs(t);i(o)};return s.jsx(w,{color:"primary",disabled:a,onClick:e,startDecorator:a?s.jsx(A,{size:"md"}):null,type:"submit",variant:"outlined",children:"Create"})},as=()=>{var h;const r=S(),n=c(B),{data:t}=l.symbol.getOne.useQuery({symbolId:n},{refetchOnWindowFocus:!1});if(d(t)&&t){const x=((h=t.filters.limits.amount)!=null&&h.min?t.filters.limits.amount.min*10:"").toString()||"";r(f(x))}const{data:i}=l.gridBot.formOptions.useQuery({symbolId:n},{refetchOnWindowFocus:!1});d(i)&&i&&(r(P(i.highPrice)),r(j(i.lowPrice)));const a=c(M),e=c(U),o=c(J),m=c(K);if([d(a),d(e),d(o),d(m),d(t)].includes(!0)&&t){const g=V(a,e,o,Number(m),t.filters);r(L(g))}return s.jsxs(Q,{sx:{padding:0},children:[s.jsx(X,{advancedForm:s.jsx(p.Suspense,{fallback:s.jsx(v,{height:60,variant:"rectangular",width:"100%"}),children:s.jsx(Y,{})}),simpleForm:s.jsx(Z,{})}),s.jsx(k,{}),s.jsx(N,{sx:{px:2,pt:1,pb:2},children:s.jsxs(u,{container:!0,spacing:2,children:[s.jsx(u,{xs:12,children:s.jsx(p.Suspense,{fallback:s.jsx(_,{withLabel:!0}),children:s.jsx($,{})})}),s.jsx(u,{xs:12,children:s.jsx(ss,{})}),s.jsx(u,{xs:12,children:s.jsx(ns,{})})]})})]})};function os(){const[r]=l.exchangeAccount.list.useSuspenseQuery(),n=r[0],[t]=l.symbol.list.useSuspenseQuery(n.exchangeCode),i=t.find(m=>m.currencyPair==="BTC/USDT")||t[0],[{price:a}]=l.symbol.price.useSuspenseQuery({symbolId:i.symbolId}),[{lowPrice:e,highPrice:o}]=l.gridBot.formOptions.useSuspenseQuery({symbolId:i.symbolId});return{exchangeAccount:n,symbol:i,currentAssetPrice:a,lowPrice:e,highPrice:o}}function ls(){var x;const{exchangeAccount:r,symbol:n,lowPrice:t,highPrice:i,currentAssetPrice:a}=os(),e=S();if(D()){const b=(x=n.filters.limits.amount)!=null&&x.min?n.filters.limits.amount.min*10:"";e(z(r.id)),e(E(r.exchangeCode)),e(T(n.symbolId)),e(f(b.toString()||"")),e(j(t)),e(P(i)),e(O(R()))}const m=c(B),y=c(es),h=b=>e(W(b)),g=c(ts);return s.jsx(u,{container:!0,spacing:2,children:s.jsxs(q,{children:[s.jsx(u,{md:9,children:s.jsx(is,{barSize:y,currentAssetPrice:a,gridLines:g,onBarSizeChange:h,symbolId:m})}),s.jsx(u,{md:3,children:s.jsx(as,{})})]})})}export{ls as default}; diff --git a/apps/cli/frontend/assets/page-Dg9uQDXn.js b/apps/cli/frontend/assets/page-DHylC053.js similarity index 97% rename from apps/cli/frontend/assets/page-Dg9uQDXn.js rename to apps/cli/frontend/assets/page-DHylC053.js index 3b93b04c..33e5ab9a 100644 --- a/apps/cli/frontend/assets/page-Dg9uQDXn.js +++ b/apps/cli/frontend/assets/page-DHylC053.js @@ -1 +1 @@ -import{t as d,x as O,y as P,z as C,u as E,a as F,b as i,au as k,c as N,d as Q,av as D,e as T,m as v,aw as z,ax as R,ay as w,az as G,aA as L,aB as q,aC as M,aD as U,aE as H,aF as J,aG as K,aH as V,aI as W,aJ as X,aK as Y,aL as Z,j as t,G as l,E as _,aM as $,aN as b,r as ee,S as te,aO as se,aP as ae,aQ as ne,aR as oe,l as ce,aS as re,aT as ie,k as de,D as ue,aU as le,aV as ye}from"./index-C0B7FSMw.js";function me(n){const[a]=d.dcaBot.getOne.useSuspenseQuery(n),[s]=d.exchangeAccount.getOne.useSuspenseQuery(a.exchangeAccountId),o=O(s.exchangeCode,C(a.symbol),P(a.symbol)),[c]=d.symbol.getOne.useSuspenseQuery({symbolId:o}),[{price:u}]=d.symbol.price.useSuspenseQuery({symbolId:c.symbolId});return{bot:a,exchangeAccount:s,symbol:c,currentAssetPrice:u}}function ge(){const{showSnackbar:n}=E(),a=F(),s=i(k),{mutate:o,isLoading:c}=d.dcaBot.update.useMutation({onSuccess(e){n("Bot created successfully"),setTimeout(()=>{a({to:N("dca-bot/:id",e.id)})},1e3)}});return{isLoading:c,handleSubmit:()=>{const e=he(s);o(e)}}}function he(n){const{entryOrderType:a,entryOrderQuantity:s,entryConditions:o,takeProfitPercent:c,safetyOrders:u,symbolId:e,exchangeAccountId:g,botName:y}=n,{currencyPairSymbol:m}=Q(e);return{botId:n.botId,data:{name:y,settings:{entry:{type:a,quantity:Number(s),conditions:o},tp:{percent:c},safetyOrders:u},symbol:m,exchangeAccountId:g}}}function xe(){const{id:n}=D.useParams(),a=Number(n),{bot:s,exchangeAccount:o,symbol:c,currentAssetPrice:u}=me(a),e=T();v()&&(e(z(s.id)),e(R(o.id)),e(w(o.exchangeCode)),e(G(c.symbolId)),e(L(s.name)),e(q(s.settings.entry.quantity.toString())),e(M(s.settings.entry.type)),e(U(s.settings.entry.conditions)),e(H(s.settings.tp.percent)),e(J(s.settings.safetyOrders)));const y=i(K),[m]=d.exchangeAccount.getOne.useSuspenseQuery(y),h=i(V),[x]=d.symbol.getOne.useSuspenseQuery({symbolId:h}),S=i(W),p=i(X),f=r=>e(ye(r)),I=i(Y),B=i(Z),{handleSubmit:j,isLoading:A}=ge();return t.jsx(l,{container:!0,spacing:2,children:t.jsxs(_,{children:[t.jsx(l,{md:9,children:t.jsx($,{barSize:p,currentAssetPrice:u,safetyOrders:I,takeProfitPercent:B,onBarSizeChange:f,symbolId:h})}),t.jsxs(l,{md:3,children:[t.jsx(b,{level:"h2",sx:{mb:1},children:"Bot settings"}),t.jsx(ee.Suspense,{fallback:t.jsx(te,{animation:"wave",height:300,sx:{borderRadius:8},variant:"rectangular",width:"100%"}),children:t.jsx(se,{hideTimeframe:!0,defaultBot:s,isLoading:A,onSubmit:j,botName:S,onBotNameChange:r=>e(ae(r)),exchangeAccount:m,onExchangeAccountChange:({id:r})=>e(ne(r)),symbol:x,onSymbolChange:({symbolId:r})=>e(oe(r))})})]}),t.jsx(l,{md:9,children:t.jsxs(ce,{display:"flex",flexDirection:"column",gap:2,children:[t.jsx(re,{}),t.jsx(ie,{}),t.jsxs(de,{children:[t.jsx(b,{level:"title-lg",children:"Safety orders"}),t.jsx(ue,{}),t.jsx(le,{})]})]})}),t.jsx(l,{md:3})]})})}export{xe as default}; +import{t as d,x as O,y as P,z as C,u as E,a as F,b as i,au as k,c as N,d as Q,av as D,e as T,m as v,aw as z,ax as R,ay as w,az as G,aA as L,aB as q,aC as M,aD as U,aE as H,aF as J,aG as K,aH as V,aI as W,aJ as X,aK as Y,aL as Z,j as t,G as l,E as _,aM as $,aN as b,r as ee,S as te,aO as se,aP as ae,aQ as ne,aR as oe,l as ce,aS as re,aT as ie,k as de,D as ue,aU as le,aV as ye}from"./index-BcZMUM3W.js";function me(n){const[a]=d.dcaBot.getOne.useSuspenseQuery(n),[s]=d.exchangeAccount.getOne.useSuspenseQuery(a.exchangeAccountId),o=O(s.exchangeCode,C(a.symbol),P(a.symbol)),[c]=d.symbol.getOne.useSuspenseQuery({symbolId:o}),[{price:u}]=d.symbol.price.useSuspenseQuery({symbolId:c.symbolId});return{bot:a,exchangeAccount:s,symbol:c,currentAssetPrice:u}}function ge(){const{showSnackbar:n}=E(),a=F(),s=i(k),{mutate:o,isLoading:c}=d.dcaBot.update.useMutation({onSuccess(e){n("Bot created successfully"),setTimeout(()=>{a({to:N("dca-bot/:id",e.id)})},1e3)}});return{isLoading:c,handleSubmit:()=>{const e=he(s);o(e)}}}function he(n){const{entryOrderType:a,entryOrderQuantity:s,entryConditions:o,takeProfitPercent:c,safetyOrders:u,symbolId:e,exchangeAccountId:g,botName:y}=n,{currencyPairSymbol:m}=Q(e);return{botId:n.botId,data:{name:y,settings:{entry:{type:a,quantity:Number(s),conditions:o},tp:{percent:c},safetyOrders:u},symbol:m,exchangeAccountId:g}}}function xe(){const{id:n}=D.useParams(),a=Number(n),{bot:s,exchangeAccount:o,symbol:c,currentAssetPrice:u}=me(a),e=T();v()&&(e(z(s.id)),e(R(o.id)),e(w(o.exchangeCode)),e(G(c.symbolId)),e(L(s.name)),e(q(s.settings.entry.quantity.toString())),e(M(s.settings.entry.type)),e(U(s.settings.entry.conditions)),e(H(s.settings.tp.percent)),e(J(s.settings.safetyOrders)));const y=i(K),[m]=d.exchangeAccount.getOne.useSuspenseQuery(y),h=i(V),[x]=d.symbol.getOne.useSuspenseQuery({symbolId:h}),S=i(W),p=i(X),f=r=>e(ye(r)),I=i(Y),B=i(Z),{handleSubmit:j,isLoading:A}=ge();return t.jsx(l,{container:!0,spacing:2,children:t.jsxs(_,{children:[t.jsx(l,{md:9,children:t.jsx($,{barSize:p,currentAssetPrice:u,safetyOrders:I,takeProfitPercent:B,onBarSizeChange:f,symbolId:h})}),t.jsxs(l,{md:3,children:[t.jsx(b,{level:"h2",sx:{mb:1},children:"Bot settings"}),t.jsx(ee.Suspense,{fallback:t.jsx(te,{animation:"wave",height:300,sx:{borderRadius:8},variant:"rectangular",width:"100%"}),children:t.jsx(se,{hideTimeframe:!0,defaultBot:s,isLoading:A,onSubmit:j,botName:S,onBotNameChange:r=>e(ae(r)),exchangeAccount:m,onExchangeAccountChange:({id:r})=>e(ne(r)),symbol:x,onSymbolChange:({symbolId:r})=>e(oe(r))})})]}),t.jsx(l,{md:9,children:t.jsxs(ce,{display:"flex",flexDirection:"column",gap:2,children:[t.jsx(re,{}),t.jsx(ie,{}),t.jsxs(de,{children:[t.jsx(b,{level:"title-lg",children:"Safety orders"}),t.jsx(ue,{}),t.jsx(le,{})]})]})}),t.jsx(l,{md:3})]})})}export{xe as default}; diff --git a/apps/cli/frontend/assets/page-DXvJlC_-.js b/apps/cli/frontend/assets/page-DokNskun.js similarity index 95% rename from apps/cli/frontend/assets/page-DXvJlC_-.js rename to apps/cli/frontend/assets/page-DokNskun.js index b93a0876..4a6d2c1c 100644 --- a/apps/cli/frontend/assets/page-DXvJlC_-.js +++ b/apps/cli/frontend/assets/page-DokNskun.js @@ -1 +1 @@ -import{d as G,u as F,a as L,b as d,t as u,c as A,j as e,B as C,C as w,e as S,f as m,i as Q,k as v,r as y,S as k,D as N,l as z,G as l,x as D,y as E,z as R,R as O,m as T,A as U,n as q,o as H,p as W,s as M,h as J,g as K,q as V,F as X,H as Y,E as Z,w as _}from"./index-C0B7FSMw.js";import{s as $,a as j,b as ee,c as se,d as te,e as ie,f as ne,F as re,A as ae,S as oe,I as ce,g as de,B as le,h as ue,i as me,G as ge}from"./SimpleGridForm-BMdftmE-.js";function he(c){const{gridLines:s,symbolId:t,exchangeAccountId:a,botName:i}=c,{currencyPairSymbol:r}=G(t);return{botId:c.botId,data:{name:i,settings:{gridLines:s},symbol:r,exchangeAccountId:a}}}const be=()=>{const{showSnackbar:c}=F(),s=L(),t=d($),{mutate:a,isLoading:i}=u.gridBot.update.useMutation({onSuccess(o){c("Bot updated successfully"),setTimeout(()=>{s({to:A("grid-bot/:id",o.id)})},1e3)}}),r=()=>{const o=he(t);a(o)};return e.jsx(C,{color:"primary",disabled:i,onClick:r,startDecorator:i?e.jsx(w,{size:"md"}):null,type:"submit",variant:"outlined",children:"Update"})},pe=()=>{const c=S(),s=d(j),{data:t}=u.symbol.getOne.useQuery({symbolId:s},{refetchOnWindowFocus:!1}),a=d(ee),i=d(se),r=d(te),o=d(ie);if([m(a),m(i),m(r),m(o),m(t)].includes(!0)&&t){const n=ne(a,i,r,Number(o),t.filters);c(Q(n))}return e.jsxs(v,{sx:{padding:0},children:[e.jsx(re,{advancedForm:e.jsx(y.Suspense,{fallback:e.jsx(k,{height:60,variant:"rectangular",width:"100%"}),children:e.jsx(ae,{})}),simpleForm:e.jsx(oe,{})}),e.jsx(N,{}),e.jsx(z,{sx:{px:2,pt:1,pb:2},children:e.jsxs(l,{container:!0,spacing:2,children:[e.jsx(l,{xs:12,children:e.jsx(y.Suspense,{fallback:e.jsx(ce,{withLabel:!0}),children:e.jsx(de,{})})}),e.jsx(l,{xs:12,children:e.jsx(le,{})}),e.jsx(l,{xs:12,children:e.jsx(be,{})})]})})]})};function xe(c){var b,h;const[s]=u.gridBot.getOne.useSuspenseQuery(c),[t]=u.exchangeAccount.getOne.useSuspenseQuery(s.exchangeAccountId),a=D(t.exchangeCode,R(s.symbol),E(s.symbol)),[i]=u.symbol.getOne.useSuspenseQuery({symbolId:a}),[{price:r}]=u.symbol.price.useSuspenseQuery({symbolId:i.symbolId}),o=r*.3,g=(b=s.settings.gridLines[0])==null?void 0:b.price,n=(h=s.settings.gridLines[s.settings.gridLines.length-1])==null?void 0:h.price;return{bot:s,exchangeAccount:t,symbol:i,currentAssetPrice:r,lowPrice:g||r-o,highPrice:n||r+o}}function je(){var x;const{id:c}=O.useParams(),s=Number(c),{bot:t,exchangeAccount:a,symbol:i,lowPrice:r,highPrice:o,currentAssetPrice:g}=xe(s),n=S();if(T()){const p=(x=i.filters.limits.amount)!=null&&x.min?i.filters.limits.amount.min*10:"",f=U(t.settings.gridLines)||p||"";n(q(a.id)),n(H(a.exchangeCode)),n(W(i.symbolId)),n(M(f.toString())),n(J(r)),n(K(o)),n(V(t.name)),n(X(t.id)),n(Y(t.settings.gridLines))}const h=d(j),P=d(ue),I=p=>n(_(p)),B=d(me);return e.jsx(l,{container:!0,spacing:2,children:e.jsxs(Z,{children:[e.jsx(l,{md:9,children:e.jsx(ge,{barSize:P,currentAssetPrice:g,gridLines:B,onBarSizeChange:I,symbolId:h})}),e.jsx(l,{md:3,children:e.jsx(pe,{})})]})})}export{je as default}; +import{d as G,u as F,a as L,b as d,t as u,c as A,j as e,B as C,C as w,e as S,f as m,i as Q,k as v,r as y,S as k,D as N,l as z,G as l,x as D,y as E,z as R,R as O,m as T,A as U,n as q,o as H,p as W,s as M,h as J,g as K,q as V,F as X,H as Y,E as Z,w as _}from"./index-BcZMUM3W.js";import{s as $,a as j,b as ee,c as se,d as te,e as ie,f as ne,F as re,A as ae,S as oe,I as ce,g as de,B as le,h as ue,i as me,G as ge}from"./SimpleGridForm-E2pE-hYE.js";function he(c){const{gridLines:s,symbolId:t,exchangeAccountId:a,botName:i}=c,{currencyPairSymbol:r}=G(t);return{botId:c.botId,data:{name:i,settings:{gridLines:s},symbol:r,exchangeAccountId:a}}}const be=()=>{const{showSnackbar:c}=F(),s=L(),t=d($),{mutate:a,isLoading:i}=u.gridBot.update.useMutation({onSuccess(o){c("Bot updated successfully"),setTimeout(()=>{s({to:A("grid-bot/:id",o.id)})},1e3)}}),r=()=>{const o=he(t);a(o)};return e.jsx(C,{color:"primary",disabled:i,onClick:r,startDecorator:i?e.jsx(w,{size:"md"}):null,type:"submit",variant:"outlined",children:"Update"})},pe=()=>{const c=S(),s=d(j),{data:t}=u.symbol.getOne.useQuery({symbolId:s},{refetchOnWindowFocus:!1}),a=d(ee),i=d(se),r=d(te),o=d(ie);if([m(a),m(i),m(r),m(o),m(t)].includes(!0)&&t){const n=ne(a,i,r,Number(o),t.filters);c(Q(n))}return e.jsxs(v,{sx:{padding:0},children:[e.jsx(re,{advancedForm:e.jsx(y.Suspense,{fallback:e.jsx(k,{height:60,variant:"rectangular",width:"100%"}),children:e.jsx(ae,{})}),simpleForm:e.jsx(oe,{})}),e.jsx(N,{}),e.jsx(z,{sx:{px:2,pt:1,pb:2},children:e.jsxs(l,{container:!0,spacing:2,children:[e.jsx(l,{xs:12,children:e.jsx(y.Suspense,{fallback:e.jsx(ce,{withLabel:!0}),children:e.jsx(de,{})})}),e.jsx(l,{xs:12,children:e.jsx(le,{})}),e.jsx(l,{xs:12,children:e.jsx(be,{})})]})})]})};function xe(c){var b,h;const[s]=u.gridBot.getOne.useSuspenseQuery(c),[t]=u.exchangeAccount.getOne.useSuspenseQuery(s.exchangeAccountId),a=D(t.exchangeCode,R(s.symbol),E(s.symbol)),[i]=u.symbol.getOne.useSuspenseQuery({symbolId:a}),[{price:r}]=u.symbol.price.useSuspenseQuery({symbolId:i.symbolId}),o=r*.3,g=(b=s.settings.gridLines[0])==null?void 0:b.price,n=(h=s.settings.gridLines[s.settings.gridLines.length-1])==null?void 0:h.price;return{bot:s,exchangeAccount:t,symbol:i,currentAssetPrice:r,lowPrice:g||r-o,highPrice:n||r+o}}function je(){var x;const{id:c}=O.useParams(),s=Number(c),{bot:t,exchangeAccount:a,symbol:i,lowPrice:r,highPrice:o,currentAssetPrice:g}=xe(s),n=S();if(T()){const p=(x=i.filters.limits.amount)!=null&&x.min?i.filters.limits.amount.min*10:"",f=U(t.settings.gridLines)||p||"";n(q(a.id)),n(H(a.exchangeCode)),n(W(i.symbolId)),n(M(f.toString())),n(J(r)),n(K(o)),n(V(t.name)),n(X(t.id)),n(Y(t.settings.gridLines))}const h=d(j),P=d(ue),I=p=>n(_(p)),B=d(me);return e.jsx(l,{container:!0,spacing:2,children:e.jsxs(Z,{children:[e.jsx(l,{md:9,children:e.jsx(ge,{barSize:P,currentAssetPrice:g,gridLines:B,onBarSizeChange:I,symbolId:h})}),e.jsx(l,{md:3,children:e.jsx(pe,{})})]})})}export{je as default}; diff --git a/apps/cli/frontend/index.html b/apps/cli/frontend/index.html index aa22ed37..dd49ecd7 100644 --- a/apps/cli/frontend/index.html +++ b/apps/cli/frontend/index.html @@ -5,7 +5,7 @@ Opentrader - +