import{X as t,Y as a,H as e}from"./auth-d668f6b9.js";import{at as r}from"./app-a12cf07d.js";const s=()=>!!navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i),n=(t,a="array")=>{const e=Object.prototype.toString.call(t);if("array"===a)return"[object Array]"===e},i=()=>window.location,o=(t,a)=>{for(let e=0;e<t.length;e++){const r=t[e];if("string"==typeof a[r]&&!a[r])return!1;if(Array.isArray(a[r])&&!a[r].length)return!1}return!0},l=t=>{const a={};for(const e in t)""!==t[e]&&null!==t[e]&&void 0!==t[e]&&(a[e]=t[e]);return a},c=(t,a)=>{const e={};for(const r in t)a.includes(r)||(e[r]=t[r]);return e},p=(t,a)=>{let e=[t[a]];if(0===a)return t;for(let r=0;r<t.length;r++)r!==a&&e.push(t[r]);return e},d=()=>r.get("/admin-api/api/contract/assets",{headers:t()}),u=a=>r.get("/admin-api/api/contract/position",{params:a,headers:t()}),g=a=>r.get("/admin-api/api/contract/entrust",{params:a,headers:t()}),f=a=>r.get("/admin-api/api/contract/history",{params:a,headers:t()}),m=a=>r.post("/admin-api/api/contract/close",a,{headers:t()}),h=()=>r.get("/admin-api/api/contract/strategy",{headers:t()}),y=a=>r.post("/admin-api/api/contract/operation",a,{headers:t()}),w=a=>r.post("/admin-api/api/contract/cancel",a,{headers:t()}),S=a=>r.get("/admin-api/api/spot/assets",{params:a,headers:t()}),b=()=>r.get("/admin-api/api/spot/strategy",{headers:t()}),v=a=>r.post("/admin-api/api/spot/operation",a,{headers:t()}),O=a=>r.get("/admin-api/api/spot/entrust",{params:a,headers:t()}),_=a=>r.post("/admin-api/api/spot/cancel",a,{headers:t()}),I=a=>r.get("/admin-api/api/spot/history",{params:a,headers:t()}),N="trade_user",J="contract_help",x="spot_help",A="symbol_list",j="contract_record",D="spot_record",E="contract_symbol_record",H="spot_symbol_record",P=(t,a,e="local")=>{"local"===e?window.localStorage.setItem(t,JSON.stringify(a)):window.sessionStorage.setItem(t,JSON.stringify(a))},k=(t,a="local")=>{let e=null;if("local"===a){let a=window.localStorage.getItem(t);a&&(e=JSON.parse(a))}else{let a=window.sessionStorage.getItem(t);a&&(e=JSON.parse(a))}return e},q=(t,a)=>{let e=window.localStorage.getItem(t);if(!e)return!0;{e=JSON.parse(e);const t=e.time;if((new Date).valueOf()-t>a)return!0}return!1},z=(t,a)=>{let e={time:(new Date).valueOf(),list:a};window.localStorage.setItem(t,JSON.stringify(e))},B=t=>{let a=window.localStorage.getItem(N);if(a){a=JSON.parse(a);let e=a.list.find((a=>a.id==t));if(e)return e.name}return"Null"},C=(t=!0,a=!0)=>{let e=window.localStorage.getItem(N);if(e){e=JSON.parse(e);const r=e.list;if(r&&r.length){if(t){let t=r.map((t=>({label:t.name,value:t.id})));return a&&t.unshift({label:"全部",value:""}),t}return r}}return[]},F=async()=>{if(q(N,36e5))try{const t=await e();0==t.code&&z(N,t.data.data)}catch(t){}},G=async(a=!1)=>{if(q(J,864e5)||a)try{const a=await r.get("/admin-api/api/helper/contracts",{headers:t()});if(0==a.code)return z(J,a.data),a.data}catch(e){}return null},X=t=>{let a=window.localStorage.getItem(J);if(a){a=JSON.parse(a);const e=a.list;let r=[];return"order_type"==t?r=e.order_type:"position_side"==t?r=e.position_side:"side"==t?r=e.side:"exchange"==t&&(r=e.exchange),r}return[]},Y=(t,a)=>{const e=X(t);if(e.length){const t=e.find((t=>t.value==a));return t?t.label:"error"}},K=(t,a=!0)=>{const e=X(t);if(e.length){let t=e.map((t=>({label:t.label,value:t.value})));return a&&t.unshift({label:"全部",value:""}),t}return[]},L=async(a,e=!1)=>{if(q(x,864e5)||e)try{const a=await r.get("/admin-api/api/helper/spots",{headers:t()});if(0==a.code)return z(x,a.data),a.data}catch(s){}return null},M=t=>{let a=window.localStorage.getItem(x);if(a){a=JSON.parse(a);const e=a.list;let r=[];return"direction"==t?r=e.direction:"order_type"==t?r=e.order_type:"status"==t&&(r=e.status),r}return[]},Q=(t,a)=>{const e=M(t);if(e.length){const t=e.find((t=>t.value==a));return t?t.label:a}return a},R=(t,a=!0)=>{const e=M(t);if(e.length){let t=e.map((t=>({label:t.label,value:t.value})));return a&&t.unshift({label:"全部",value:""}),t}return[]},T=async(t,e)=>{if(t){let t=window.localStorage.getItem(A);if(t&&!q(A,3e5)){const a=JSON.parse(t);return U(a.list,e)}}try{const t=await a();return 0==t.code?(z(A,t.data),U(t.data,e)):[]}catch(r){return[]}},U=(t,a)=>{const e=k(a);let r=JSON.parse(JSON.stringify(t));if(e){for(let t=e.length-1;t>=0;t--){const a=e[t],s=r.findIndex((t=>t.value===a));-1!==s&&(r=p(r,s))}return r}return t},V=(t,a,e)=>{const r=a.findIndex((t=>t===e));-1===r?a.unshift(e):a=p(a,r),P(t,a)},W=(t,a)=>{let e=k(t);e&&e.length?"string"==typeof a?V(t,e,a):n(a,"array")&&a.forEach((a=>{V(t,e,a)})):"string"==typeof a?P(t,[a]):n(a,"array")&&P(t,a)};export{_ as A,I as B,d as C,S as D,v as E,D as F,H as G,b as H,R as I,O as S,F as a,G as b,Y as c,g as d,f as e,u as f,B as g,T as h,s as i,o as j,c as k,E as l,l as m,y as n,j as o,W as p,h as q,k as r,P as s,C as t,K as u,i as v,L as w,Q as x,m as y,w as z};
