import{m as u}from"./vendor-mockjs.1d07e924.js";import{p as h}from"./vendor-path-to-regexp.a7bc300e.js";const s=u;function _(t){s.XHR.prototype.__send=s.XHR.prototype.send,s.XHR.prototype.send=function(){if(this.custom.xhr&&(this.custom.xhr.withCredentials=this.withCredentials||!1,this.responseType&&(this.custom.xhr.responseType=this.responseType)),this.custom.requestHeaders){const e={};for(let o in this.custom.requestHeaders)e[o.toString().toLowerCase()]=this.custom.requestHeaders[o];this.custom.options=Object.assign({},this.custom.options,{headers:e})}this.__send.apply(this,arguments)},s.XHR.prototype.proxy_open=s.XHR.prototype.open,s.XHR.prototype.open=function(){let e=this.responseType;this.proxy_open(...arguments),this.custom.xhr&&e&&(this.custom.xhr.responseType=e)};for(const{url:e,method:o,response:r,timeout:p}of t)m(p),s.mock(h(e,void 0,{end:!1}),o||"get",f(r))}function a(t){const e=t.split("?")[1];return e?JSON.parse('{"'+decodeURIComponent(e).replace(/"/g,'\\"').replace(/&/g,'","').replace(/=/g,'":"').replace(/\+/g," ")+'"}'):{}}function f(t){return function(e){let o=null;if(typeof t=="function"){const{body:r,type:p,url:i,headers:c}=e;let n=r;try{n=JSON.parse(r)}catch(y){}o=t({method:p,body:n,query:a(i),headers:c})}else o=t;return s.mock(o)}}function m(t=0){t&&s.setup({timeout:t})}export{_ as c};
