const f=/(https?):\/\/[-\w+&@#/%?=~|!:,.;]+[-\w+&@#/%=~|]/;function c(t){return new Promise((r,e)=>{const n=new XMLHttpRequest;n.timeout=6e3;let a=u(t.url);t.method==="GET"&&(a+=`${l(t.data)}`),n.open(t.method,a),n.ontimeout=e,n.onerror=e,n.setRequestHeader("Content-Type","application/json"),n.onload=s=>{r(s.target.response)},n.send(JSON.stringify(h(t.data,t.paramType)))})}function l(t){let r="";return t.forEach(e=>{e[0]&&(r+=`&${e[0]}=${e[1]}`)}),r?`?${r}`:""}function h(t,r){if(!t)return"";if(r==="array")return t;const e={};return t.forEach(n=>{n[0]&&(e[n[0]]=n[1])}),e}function u(t){return t.startsWith("http")?t:`https://${t}`}async function o(t){const r=t==null?void 0:t.url;let e=!1;return(r&&!/^\d+$/.test(r)||f.test(u(r)))&&(e=await c(t)),e}export{u as g,o as r,f as u};
