"use strict";function r(r,{encode:e=!1}={}){return r.filter((({name:r})=>"string"==typeof r&&r.trim().length>0)).map((({name:r,value:n})=>{const t=e?encodeURIComponent(r):r;if(void 0===n)return t;return`${t}=${e?encodeURIComponent(n):n}`})).join("&")}function e(r,{decode:e=!1}={}){if(!r||!r.length)return[];try{const[n,...t]=r.split("#"),o=n.split("&");return o.map((r=>{const[n,...t]=r.split("=");if(!n)return null;const o=r.includes("=")?e?decodeURIComponent(t.join("=")):t.join("="):void 0;return{name:e?decodeURIComponent(n):n,value:o}})).filter((r=>null!==r))}catch(r){return console.error("Error parsing query params:",r),[]}}const n=/\{\{([^}]+)\}\}/g;const t=/[^{}\s](?:[^{}]*[^{}\s])?/,o=new RegExp(`^\\?(${t.source})$`),a=new RegExp(`{{\\?(${t.source})}}`,"g"),s=r=>{const e=new Set;let n;for(;null!==(n=a.exec(r));)e.add(n[1]);return Array.from(e)};exports.PROMPT_VARIABLE_TEMPLATE_PATTERN=a,exports.PROMPT_VARIABLE_TEXT_PATTERN=o,exports.buildFormUrlEncodedPayload=r=>{var e;if(!Array.isArray(r))return"";const n=new URLSearchParams;for(const t of r)"object"==typeof t&&null!==t&&"name"in t&&n.append(t.name,String(null!==(e=t.value)&&void 0!==e?e:""));return n.toString()},exports.buildQueryString=r,exports.encodeUrl=n=>{if(!n||"string"!=typeof n)return n;const[t,...o]=n.split("#"),[a,...s]=t.split("?");if(!s||0===s.length)return n;return`${a}?${r(e(s.join("?"),{decode:!1}),{encode:!0})}${o.length>0?`#${o.join("#")}`:""}`},exports.extractBoundaryFromContentType=r=>{if("string"!=typeof r)return null;const e=r.match(/boundary="([^"]+)"|boundary=([^;\s]+)/i);return e?e[1]||e[2]:null},exports.extractPromptVariables=function r(e){const n=new Set;try{if("string"==typeof e){s(e).forEach((r=>n.add(r)))}else if(Array.isArray(e))for(const t of e){r(t).forEach((r=>n.add(r)))}else if("object"==typeof e&&null!==e)for(const t in e){r(e[t]).forEach((r=>n.add(r)))}}catch(r){console.error("Error extracting prompt variables:",r)}return Array.from(n)},exports.extractPromptVariablesFromString=s,exports.isFormData=r=>{var e;return"FormData"===(null===(e=null==r?void 0:r.constructor)||void 0===e?void 0:e.name)},exports.jsonToDotenv=r=>Array.isArray(r)?r.filter((r=>r.name&&""!==r.name.trim())).map((r=>{const e=r.value||"";if(e.includes("\n")||e.includes("\r")){const n=e.replace(/\r/g,"\\r").replace(/\n/g,"\\n");return`${r.name}="${n}"`}if(e.includes("#")){if(!e.includes("'"))return`${r.name}='${e}'`;if(!e.includes("`"))return`${r.name}=\`${e}\``;const n=e.replace(/"/g,'\\"');return`${r.name}="${n}"`}return e!==e.trim()?e.includes("'")?e.includes("`")?`${r.name}="${e}"`:`${r.name}=\`${e}\``:`${r.name}='${e}'`:`${r.name}=${e}`})).join("\n"):"",exports.parseQueryParams=e,exports.patternHasher=function(r,e=n){const t=new RegExp(e,"g"),o={};let a=r,s=!1;return t.test(r)&&(s=!0,a=r.replace(t,(function(r){const e=`bruno-var-hash-${function(r){let e,n=5381;for(let t=0;t<r.length;t++)e=r.charCodeAt(t),n=(n<<5)+n+e|0;return""+n}(r)}`;return o[e]=r,e}))),{hashed:a,restore(r){if(!s)return r;let e=r;for(const r in o){const n=o[r];e=e.replaceAll(r,n)}return e}}},exports.stripOrigin=r=>r.replace(/^https?:\/\/[^/?#]*/,"")||"/";
//# sourceMappingURL=index.js.map
