"use strict";const t=require("../utils.js");function o(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function u(e,s){if(!s)return e;let c;if(t.isURLSearchParams(s))c=s.toString();else{const r=[];t.forEach(s,(n,f)=>{n===null||typeof n>"u"||(t.isArray(n)?f=`${f}[]`:n=[n],t.forEach(n,i=>{t.isDate(i)?i=i.toISOString():t.isObject(i)&&(i=JSON.stringify(i)),r.push(`${o(f)}=${o(i)}`)}))}),c=r.join("&")}if(c){const r=e.indexOf("#");r!==-1&&(e=e.slice(0,r)),e+=(e.indexOf("?")===-1?"?":"&")+c}return e}exports.buildURL=u;
