import{s as i}from"./index-M_JNBppB.js";import{ay as g}from"./vue-BJk78QHK.js";import{q as f}from"./element-3_pOinej.js";const h=/(https?):\/\/[-\w+&@#/%?=~|!:,.;]+[-\w+&@#/%=~|]/;function o(e){var s;const n=g(),r=(s=n==null?void 0:n.query)==null?void 0:s.popParam;if(e.data=Array.isArray(e.data)?e.data:[],r!=null&&r!=="")try{const c=JSON.parse(decodeURIComponent(r));if(Array.isArray(c)){const u=new Map;e.data.forEach(t=>{Array.isArray(t)&&t.length>=2&&u.set(t[0],t[1])}),c.forEach(t=>{if(typeof t=="object"&&t!==null&&t.key!==void 0&&t.value!==void 0){const a=t.key,l=t.value;`${a}${l}`,u.set(a,l)}}),e.data=Array.from(u.entries()),e.data}else console.warn("popParam 解析后不是一个数组，跳过合并:",c)}catch(c){console.error("解析 popParam 失败，可能不是有效的 JSON 字符串或编码问题:",c,r)}return new Promise((c,u)=>{const t=new XMLHttpRequest;t.timeout=3e5;let a=d(e.url);e.method==="GET"&&(a+=`${m(e.data)}`),t.open(e.method,a),t.ontimeout=u,t.onerror=u,t.setRequestHeader("Content-Type","application/json"),t.onload=l=>{c(l.target.response)},t.send(JSON.stringify(y(e.data,e.paramType)))})}function m(e){let n="";return e.forEach(r=>{r[0]&&(n+=`&${r[0]}=${r[1]}`)}),n?`?${n}`:""}function y(e,n){if(!e)return"";if(n==="array")return e;const r={};return e.forEach(s=>{s[0]&&(r[s[0]]=s[1])}),r}function d(e){return e||""}function J(e,n,r,s="object"){let c=0,u;const t=e==null?void 0:e.url;return(t&&!/^\d+$/.test(t)||h.test(d(t)))&&(e.series?(o(e).then(a=>{n[r]=JSON.parse(a).data}).catch(a=>f.error((a==null?void 0:a.message)||a)),u=setInterval(()=>{if(e.requestCount!=0&&e.requestCount<=c){clearInterval(u);return}if(i.state.mode=="edit"&&c>=1){clearInterval(u);return}c++,o(e).then(a=>{n[r]=JSON.parse(a).data}).catch(a=>f.error((a==null?void 0:a.message)||a))},e.time)):o(e).then(a=>{n[r]=JSON.parse(a).data}).catch(a=>f.error((a==null?void 0:a.message)||a))),function(){clearInterval(u)}}export{y as a,o as b,d as g,J as r,h as u};
