import{createCustomError as e}from"../utils/create-custom-error.mjs";const n="    ";function t({source:e,line:t,column:r,baseLine:a,baseColumn:s},o){function l(e,n){return i.slice(e,n).map((n,t)=>String(e+t+1).padStart(m)+" |"+n).join("\n")}const i=("\n".repeat(Math.max(a-1,0))+" ".repeat(Math.max(s-1,0))+e).split(/\r\n?|\n|\f/),u=Math.max(1,t-o)-1,c=Math.min(t+o,i.length+1),m=Math.max(4,String(c).length)+1;let g=0;(r+=3*(i[t-1].substr(0,r-1).match(/\t/g)||[]).length)>100&&(g=r-60+3,r=58);for(let e=u;e<=c;e++)e>=0&&e<i.length&&(i[e]=i[e].replace(/\t/g,n),i[e]=(g>0&&i[e].length>g?"…":"")+i[e].substr(g,98)+(i[e].length>g+100-1?"…":""));return[l(u,t),new Array(r+m+2).join("-")+"^",l(t,c)].filter(Boolean).join("\n").replace(/^(\s+\d+\s+\|\n)+/,"").replace(/\n(\s+\d+\s+\|)+$/,"")}function r(n,r,a,s,o,l=1,i=1){return Object.assign(e("SyntaxError",n),{source:r,offset:a,line:s,column:o,sourceFragment:e=>t({source:r,line:s,column:o,baseLine:l,baseColumn:i},isNaN(e)?0:e),get formattedMessage(){return`Parse error: ${n}\n`+t({source:r,line:s,column:o,baseLine:l,baseColumn:i},2)}})}export{r as SyntaxError};