prettier 3.9.5 → 3.9.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/standalone.js CHANGED
@@ -19,11 +19,11 @@ The range will extend backwards to the start of the first line containing the se
19
19
  `,u.gutter(h.replace(/\d/g," "))," ",B,u.marker("^").repeat(J)].join(""),P&&r.message&&(A+=" "+u.message(r.message))}return[u.marker(">"),u.gutter(h),F.length>0?` ${F}`:"",A].join("")}else return` ${u.gutter(h)}${F.length>0?` ${F}`:""}`}).join(`
20
20
  `);return r.message&&!p&&(f=`${" ".repeat(l+1)}${r.message}
21
21
  ${f}`),u.reset(f)}function eu(t,e,r={}){return Zn(t,e,r)}async function ci(t,e){let r=await Ue(e),n=r.preprocess?await r.preprocess(t,e):t;e.originalText=n;let u;try{u=await r.parse(n,e,e)}catch(o){fi(o,t)}return{text:n,ast:u}}function fi(t,e){let{loc:r}=t;if(r){let{start:n,end:u}=r;n&&(n={line:n.line,column:n.column-1}),u&&(u={line:u.line,column:u.column-1});let o=eu(e,{start:n,end:u},{highlightCode:!0});t.message+=`
22
- `+o,t.codeFrame=o}throw t}var me=ci;async function tu(t,e,r,n,u){if(r.embeddedLanguageFormatting!=="auto")return;let{printer:o}=r,{embed:i}=o;if(!i)return;if(i.length>2)throw new Error("printer.embed has too many parameters. The API changed in Prettier v3. Please update your plugin. See https://prettier.io/docs/plugins#optional-embed");let{hasPrettierIgnore:D}=o,{getVisitorKeys:s}=i,a=[];l();let c=t.stack;for(let{print:m,node:f,pathStack:F}of a)try{t.stack=F;let d=await m(p,e,t,r);d&&u.set(f,d)}catch(d){if(globalThis.PRETTIER_DEBUG)throw d}t.stack=c;function p(m,f){return li(m,f,r,n)}function l(){let{node:m}=t;if(m===null||typeof m!="object"||D?.(t))return;for(let F of s(m))Array.isArray(m[F])?t.each(l,F):t.call(l,F);let f=i(t,r);if(f){if(typeof f=="function"){a.push({print:f,node:m,pathStack:[...t.stack]});return}u.set(m,f)}}}async function li(t,e,r,n){let u=await se({...r,...e,parentParser:r.parser,originalText:t,cursorOffset:void 0,rangeStart:void 0,rangeEnd:void 0},{passThrough:!0}),{ast:o}=await me(t,u),i=await n(o,u);return He(i)}function pi(t,e,r,n){let{originalText:u,[ue]:o,locStart:i,locEnd:D,[Symbol.for("printedComments")]:s}=e,{node:a}=t,c=i(a),p=D(a);for(let m of o)i(m)>=c&&D(m)<=p&&s.add(m);let{printPrettierIgnored:l}=e.printer;return l?l(t,e,r,n):u.slice(c,p)}var ru=pi;async function Ve(t,e){({ast:t}=await or(t,e));let r=new Map,n=new tn(t),u=Fn(e),o=new Map;await tu(n,D,e,Ve,o);let i=await nu(n,e,D,void 0,o);if(dn(e),e.cursorOffset>=0){if(e.nodeAfterCursor&&!e.nodeBeforeCursor)return[ee,i];if(e.nodeBeforeCursor&&!e.nodeAfterCursor)return[i,ee]}return i;function D(a,c){return a===void 0||a===n?s(c):Array.isArray(a)?n.call(()=>s(c),...a):n.call(()=>s(c),a)}function s(a){u(n);let c=n.node;if(c==null)return"";let p=ge(c)&&a===void 0;if(p&&r.has(c))return r.get(c);let l=nu(n,e,D,a,o);return p&&r.set(c,l),l}}function nu(t,e,r,n,u){let{node:o}=t,{printer:i}=e,D;switch(i.hasPrettierIgnore?.(t)?D=ru(t,e,r,n):u.has(o)?D=u.get(o):D=i.print(t,e,r,n),o){case e.cursorNode:D=Ee(D,s=>[ee,s,ee]);break;case e.nodeBeforeCursor:D=Ee(D,s=>[s,ee]);break;case e.nodeAfterCursor:D=Ee(D,s=>[ee,s]);break}return i.printComment&&rt(o.comments)&&!i.willPrintOwnComments?.(t,e)&&(D=mn(t,D,e)),D}async function or(t,e){let r=t.comments??[];e[ue]=r,e[Symbol.for("printedComments")]=new Set,cn(t,e);let{printer:{preprocess:n}}=e;return t=n?await n(t,e):t,{ast:t,comments:r}}function mi(t,e){let{cursorOffset:r,locStart:n,locEnd:u,getVisitorKeys:o}=e,i=m=>n(m)<=r&&u(m)>=r,D=t,s=[t];for(let m of un(t,{getVisitorKeys:o,filter:i}))s.push(m),D=m;if(on(D,{getVisitorKeys:o}))return{cursorNode:D};let a,c,p=-1,l=Number.POSITIVE_INFINITY;for(;s.length>0&&(a===void 0||c===void 0);){D=s.pop();let m=a!==void 0,f=c!==void 0;for(let F of ye(D,{getVisitorKeys:o})){if(!m){let d=u(F);d<=r&&d>p&&(a=F,p=d)}if(!f){let d=n(F);d>=r&&d<l&&(c=F,l=d)}}}return{nodeBeforeCursor:a,nodeAfterCursor:c}}var ir=mi;function di(t,e){let{printer:r}=e,n=r.massageAstNode;if(!n)return t;let{getVisitorKeys:u}=r,{ignoredProperties:o}=n;return i(t);function i(D,s){if(!ge(D))return D;if(Array.isArray(D))return D.map(l=>i(l,s)).filter(Boolean);let a={},c=new Set(u(D));for(let l in D)!le(D,l)||o?.has(l)||(c.has(l)?a[l]=i(D[l],D):a[l]=D[l]);let p=n(D,a,s);if(p!==null)return p??a}}var uu=di;var Fi=Array.prototype.findLastIndex??function(t){for(let e=this.length-1;e>=0;e--){let r=this[e];if(t(r,e,this))return e}return-1},Ei=X("findLastIndex",function(){if(Array.isArray(this))return Fi}),ou=Ei;function Ci(t,e){return e=new Set(e),t.find(r=>Du.has(r.type)&&e.has(r))}function iu(t){let e=ou(0,t,r=>r.type!=="Program"&&r.type!=="File");return e===-1?t:t.slice(0,e+1)}function hi(t,e,{locStart:r,locEnd:n}){let[u,...o]=t,[i,...D]=e;if(u===i)return[u,i];let s=r(u);for(let c of iu(D))if(r(c)>=s)i=c;else break;let a=n(i);for(let c of iu(o)){if(n(c)<=a)u=c;else break;if(u===i)break}return[u,i]}function sr(t,e,r,n,u=[],o,i){let{locStart:D,locEnd:s}=i,a=D(t),c=s(t);if(e>c||e<a||o==="rangeEnd"&&e===a||o==="rangeStart"&&e===c)return;let p=[t,...u],l=ot(t,p,{cache:Vt,locStart:D,locEnd:s,getVisitorKeys:r.getVisitorKeys,filter:r.printer.canAttachComment,getChildren:r.printer.getCommentChildNodes});for(let m of l){let f=sr(m,e,r,n,p,o,i);if(f)return f}if(n(t,u[0]))return p}function gi(t,e){return e!=="DeclareExportDeclaration"&&t!=="TypeParameterDeclaration"&&(t==="Directive"||t==="TypeAlias"||t==="TSExportAssignment"||t.startsWith("Declare")||t.startsWith("TSDeclare")||t.endsWith("Statement")||t.endsWith("Declaration"))}var Du=new Set(["JsonRoot","ObjectExpression","ArrayExpression","StringLiteral","NumericLiteral","BooleanLiteral","NullLiteral","UnaryExpression","TemplateLiteral"]),_i=new Set(["OperationDefinition","FragmentDefinition","VariableDefinition","TypeExtensionDefinition","ObjectTypeDefinition","FieldDefinition","DirectiveDefinition","EnumTypeDefinition","EnumValueDefinition","InputValueDefinition","InputObjectTypeDefinition","SchemaDefinition","OperationTypeDefinition","InterfaceTypeDefinition","UnionTypeDefinition","ScalarTypeDefinition"]);function su(t,e,r){if(!e)return!1;switch(t.parser){case"flow":case"hermes":case"babel":case"babel-flow":case"babel-ts":case"typescript":case"acorn":case"espree":case"meriyah":case"oxc":case"oxc-ts":case"__babel_estree":return gi(e.type,r?.type);case"json":case"json5":case"jsonc":case"json-stringify":return Du.has(e.type);case"graphql":return _i.has(e.kind);case"vue":return e.tag!=="root"}return!1}function au(t,e,r){let{rangeStart:n,rangeEnd:u}=e;k(u>n);let o=t.slice(n,u).search(/\S/),i=o===-1;if(!i)for(n+=o;u>n&&!/\S/.test(t[u-1]);--u);let D=e.printer.features?.experimental_locForRangeFormat??e,s=sr(r,n,e,(f,F)=>su(e,f,F),[],"rangeStart",D);if(!s)return;let a=i?s:sr(r,u,e,f=>su(e,f),[],"rangeEnd",D);if(!a)return;let c,p;if(r.type==="JsonRoot"){let f=Ci(s,a);c=f,p=f}else[c,p]=hi(s,a,e);let{locStart:l,locEnd:m}=D;return[Math.min(l(c),l(p)),Math.max(m(c),m(p))]}var pu="\uFEFF",cu=Symbol("cursor");async function mu(t,e,r=0){if(!t||t.trim().length===0)return{formatted:"",cursorOffset:-1,comments:[]};let{ast:n,text:u}=await me(t,e);e.cursorOffset>=0&&(e={...e,...ir(n,e)});let o=await Ve(n,e,r);r>0&&(o=Qe([W,o],r,e.tabWidth));let i=Ce(o,e);if(r>0){let s=i.formatted.trim();i.cursorNodeStart!==void 0&&(i.cursorNodeStart-=i.formatted.indexOf(s),i.cursorNodeStart<0&&(i.cursorNodeStart=0,i.cursorNodeText=i.cursorNodeText.trimStart()),i.cursorNodeStart+i.cursorNodeText.length>s.length&&(i.cursorNodeText=i.cursorNodeText.trimEnd())),i.formatted=s+we(e.endOfLine)}let D=e[ue];if(e.cursorOffset>=0){let s,a,c,p;if((e.cursorNode||e.nodeBeforeCursor||e.nodeAfterCursor)&&i.cursorNodeText)if(c=i.cursorNodeStart,p=i.cursorNodeText,e.cursorNode)s=e.locStart(e.cursorNode),a=u.slice(s,e.locEnd(e.cursorNode));else{if(!e.nodeBeforeCursor&&!e.nodeAfterCursor)throw new Error("Cursor location must contain at least one of cursorNode, nodeBeforeCursor, nodeAfterCursor");s=e.nodeBeforeCursor?e.locEnd(e.nodeBeforeCursor):0;let E=e.nodeAfterCursor?e.locStart(e.nodeAfterCursor):u.length;a=u.slice(s,E)}else s=0,a=u,c=0,p=i.formatted;let l=e.cursorOffset-s;if(a===p)return{formatted:i.formatted,cursorOffset:c+l,comments:D};let m=a.split("");m.splice(l,0,cu);let f=p.split(""),F=Bt(m,f),d=c;for(let E of F)if(E.removed){if(E.value.includes(cu))break}else d+=E.count;return{formatted:i.formatted,cursorOffset:d,comments:D}}return{formatted:i.formatted,cursorOffset:-1,comments:D}}async function yi(t,e){let{ast:r,text:n}=await me(t,e),[u,o]=au(n,e,r)??[0,0],i=n.slice(u,o),D=Math.min(u,n.lastIndexOf(`
22
+ `+o,t.codeFrame=o}throw t}var me=ci;async function tu(t,e,r,n,u){if(r.embeddedLanguageFormatting!=="auto")return;let{printer:o}=r,{embed:i}=o;if(!i)return;if(i.length>2)throw new Error("printer.embed has too many parameters. The API changed in Prettier v3. Please update your plugin. See https://prettier.io/docs/plugins#optional-embed");let{hasPrettierIgnore:D}=o,{getVisitorKeys:s}=i,a=[];l();let c=t.stack;for(let{print:m,node:f,pathStack:F}of a)try{t.stack=F;let d=await m(p,e,t,r);d&&u.set(f,d)}catch(d){if(globalThis.PRETTIER_DEBUG)throw d}t.stack=c;function p(m,f){return li(m,f,r,n)}function l(){let{node:m}=t;if(m===null||typeof m!="object"||D?.(t))return;for(let F of s(m))Array.isArray(m[F])?t.each(l,F):t.call(l,F);let f=i(t,r);if(f){if(typeof f=="function"){a.push({print:f,node:m,pathStack:[...t.stack]});return}u.set(m,f)}}}async function li(t,e,r,n){let u=await se({...r,...e,parentParser:r.parser,originalText:t,cursorOffset:void 0,rangeStart:void 0,rangeEnd:void 0},{passThrough:!0}),{ast:o}=await me(t,u),i=await n(o,u);return He(i)}function pi(t,e,r,n){let{originalText:u,[ue]:o,locStart:i,locEnd:D,[Symbol.for("printedComments")]:s}=e,{node:a}=t,c=i(a),p=D(a);for(let m of o)i(m)>=c&&D(m)<=p&&s.add(m);let{printPrettierIgnored:l}=e.printer;return l?l(t,e,r,n):u.slice(c,p)}var ru=pi;async function Ve(t,e){({ast:t}=await or(t,e));let r=new Map,n=new tn(t),u=Fn(e),o=new Map;await tu(n,D,e,Ve,o);let i=await nu(n,e,D,void 0,o);if(dn(e),e.cursorOffset>=0){if(e.nodeAfterCursor&&!e.nodeBeforeCursor)return[ee,i];if(e.nodeBeforeCursor&&!e.nodeAfterCursor)return[i,ee]}return i;function D(a,c){return a===void 0||a===n?s(c):Array.isArray(a)?n.call(()=>s(c),...a):n.call(()=>s(c),a)}function s(a){u(n);let c=n.node;if(c==null)return"";let p=ge(c)&&a===void 0;if(p&&r.has(c))return r.get(c);let l=nu(n,e,D,a,o);return p&&r.set(c,l),l}}function nu(t,e,r,n,u){let{node:o}=t,{printer:i}=e,D;switch(i.hasPrettierIgnore?.(t)?D=ru(t,e,r,n):u.has(o)?D=u.get(o):D=i.print(t,e,r,n),o){case e.cursorNode:D=Ee(D,s=>[ee,s,ee]);break;case e.nodeBeforeCursor:D=Ee(D,s=>[s,ee]);break;case e.nodeAfterCursor:D=Ee(D,s=>[ee,s]);break}return i.printComment&&rt(o.comments)&&!i.willPrintOwnComments?.(t,e)&&(D=mn(t,D,e)),D}async function or(t,e){let r=t.comments??[];e[ue]=r,e[Symbol.for("printedComments")]=new Set,cn(t,e);let{printer:{preprocess:n}}=e;return t=n?await n(t,e):t,{ast:t,comments:r}}function mi(t,e){let{cursorOffset:r,locStart:n,locEnd:u,getVisitorKeys:o}=e,i=m=>n(m)<=r&&u(m)>=r,D=t,s=[t];for(let m of un(t,{getVisitorKeys:o,filter:i}))s.push(m),D=m;if(on(D,{getVisitorKeys:o}))return{cursorNode:D};let a,c,p=-1,l=Number.POSITIVE_INFINITY;for(;s.length>0&&(a===void 0||c===void 0);){D=s.pop();let m=a!==void 0,f=c!==void 0;for(let F of ye(D,{getVisitorKeys:o})){if(!m){let d=u(F);d<=r&&d>p&&(a=F,p=d)}if(!f){let d=n(F);d>=r&&d<l&&(c=F,l=d)}}}return{nodeBeforeCursor:a,nodeAfterCursor:c}}var ir=mi;function di(t,e){let{printer:r}=e,n=r.massageAstNode;if(!n)return t;let{getVisitorKeys:u}=r,{ignoredProperties:o}=n;return i(t);function i(D,s){if(!ge(D))return D;if(Array.isArray(D))return D.map(l=>i(l,s)).filter(Boolean);let a={},c=new Set(u(D));for(let l in D)!le(D,l)||o?.has(l)||(c.has(l)?a[l]=i(D[l],D):a[l]=D[l]);let p=n(D,a,s);if(p!==null)return p??a}}var uu=di;var Fi=Array.prototype.findLastIndex??function(t){for(let e=this.length-1;e>=0;e--){let r=this[e];if(t(r,e,this))return e}return-1},Ei=X("findLastIndex",function(){if(Array.isArray(this))return Fi}),ou=Ei;function Ci(t,e){return e=new Set(e),t.find(r=>Du.has(r.type)&&e.has(r))}function iu(t){let e=ou(0,t,r=>r.type!=="Program"&&r.type!=="File");return e===-1?t:t.slice(0,e+1)}function hi(t,e,{locStart:r,locEnd:n}){let[u,...o]=t,[i,...D]=e;if(u===i)return[u,i];let s=r(u);for(let c of iu(D))if(r(c)>=s)i=c;else break;let a=n(i);for(let c of iu(o)){if(n(c)<=a)u=c;else break;if(u===i)break}return[u,i]}function sr(t,e,r,n,u=[],o,i){let{locStart:D,locEnd:s}=i,a=D(t),c=s(t);if(e>c||e<a||o==="rangeEnd"&&e===a||o==="rangeStart"&&e===c)return;let p=[t,...u],l=ot(t,p,{cache:Vt,locStart:D,locEnd:s,getVisitorKeys:r.getVisitorKeys,filter:r.printer.canAttachComment,getChildren:r.printer.getCommentChildNodes});for(let m of l){let f=sr(m,e,r,n,p,o,i);if(f)return f}if(n(t,u[0]))return p}function gi(t,e){return e!=="DeclareExportDeclaration"&&t!=="TypeParameterDeclaration"&&(t==="Directive"||t==="TypeAlias"||t==="TSExportAssignment"||t.startsWith("Declare")||t.startsWith("TSDeclare")||t.endsWith("Statement")||t.endsWith("Declaration"))}var Du=new Set(["JsonRoot","ObjectExpression","ArrayExpression","StringLiteral","NumericLiteral","BooleanLiteral","NullLiteral","UnaryExpression","TemplateLiteral"]),_i=new Set(["OperationDefinition","FragmentDefinition","VariableDefinition","TypeExtensionDefinition","ObjectTypeDefinition","FieldDefinition","DirectiveDefinition","EnumTypeDefinition","EnumValueDefinition","InputValueDefinition","InputObjectTypeDefinition","SchemaDefinition","OperationTypeDefinition","InterfaceTypeDefinition","UnionTypeDefinition","ScalarTypeDefinition"]);function su(t,e,r){if(!e)return!1;switch(t.parser){case"flow":case"hermes":case"babel":case"babel-flow":case"babel-ts":case"typescript":case"acorn":case"espree":case"meriyah":case"oxc":case"oxc-ts":case"yuku":case"yuku-ts":case"__babel_estree":return gi(e.type,r?.type);case"json":case"json5":case"jsonc":case"json-stringify":return Du.has(e.type);case"graphql":return _i.has(e.kind);case"vue":return e.tag!=="root"}return!1}function au(t,e,r){let{rangeStart:n,rangeEnd:u}=e;k(u>n);let o=t.slice(n,u).search(/\S/),i=o===-1;if(!i)for(n+=o;u>n&&!/\S/.test(t[u-1]);--u);let D=e.printer.features?.experimental_locForRangeFormat??e,s=sr(r,n,e,(f,F)=>su(e,f,F),[],"rangeStart",D);if(!s)return;let a=i?s:sr(r,u,e,f=>su(e,f),[],"rangeEnd",D);if(!a)return;let c,p;if(r.type==="JsonRoot"){let f=Ci(s,a);c=f,p=f}else[c,p]=hi(s,a,e);let{locStart:l,locEnd:m}=D;return[Math.min(l(c),l(p)),Math.max(m(c),m(p))]}var pu="\uFEFF",cu=Symbol("cursor");async function mu(t,e,r=0){if(!t||t.trim().length===0)return{formatted:"",cursorOffset:-1,comments:[]};let{ast:n,text:u}=await me(t,e);e.cursorOffset>=0&&(e={...e,...ir(n,e)});let o=await Ve(n,e,r);r>0&&(o=Qe([W,o],r,e.tabWidth));let i=Ce(o,e);if(r>0){let s=i.formatted.trim();i.cursorNodeStart!==void 0&&(i.cursorNodeStart-=i.formatted.indexOf(s),i.cursorNodeStart<0&&(i.cursorNodeStart=0,i.cursorNodeText=i.cursorNodeText.trimStart()),i.cursorNodeStart+i.cursorNodeText.length>s.length&&(i.cursorNodeText=i.cursorNodeText.trimEnd())),i.formatted=s+we(e.endOfLine)}let D=e[ue];if(e.cursorOffset>=0){let s,a,c,p;if((e.cursorNode||e.nodeBeforeCursor||e.nodeAfterCursor)&&i.cursorNodeText)if(c=i.cursorNodeStart,p=i.cursorNodeText,e.cursorNode)s=e.locStart(e.cursorNode),a=u.slice(s,e.locEnd(e.cursorNode));else{if(!e.nodeBeforeCursor&&!e.nodeAfterCursor)throw new Error("Cursor location must contain at least one of cursorNode, nodeBeforeCursor, nodeAfterCursor");s=e.nodeBeforeCursor?e.locEnd(e.nodeBeforeCursor):0;let E=e.nodeAfterCursor?e.locStart(e.nodeAfterCursor):u.length;a=u.slice(s,E)}else s=0,a=u,c=0,p=i.formatted;let l=e.cursorOffset-s;if(a===p)return{formatted:i.formatted,cursorOffset:c+l,comments:D};let m=a.split("");m.splice(l,0,cu);let f=p.split(""),F=Bt(m,f),d=c;for(let E of F)if(E.removed){if(E.value.includes(cu))break}else d+=E.count;return{formatted:i.formatted,cursorOffset:d,comments:D}}return{formatted:i.formatted,cursorOffset:-1,comments:D}}async function yi(t,e){let{ast:r,text:n}=await me(t,e),[u,o]=au(n,e,r)??[0,0],i=n.slice(u,o),D=Math.min(u,n.lastIndexOf(`
23
23
  `,u)+1),s=n.slice(D,u).match(/^\s*/)[0],a=he(s,e.tabWidth),c=await mu(i,{...e,rangeStart:0,rangeEnd:Number.POSITIVE_INFINITY,cursorOffset:e.cursorOffset>u&&e.cursorOffset<=o?e.cursorOffset-u:-1,endOfLine:"lf"},a),p=c.formatted.trimEnd(),{cursorOffset:l}=e;l>o?l+=p.length-i.length:c.cursorOffset>=0&&(l=c.cursorOffset+u);let m=n.slice(0,u)+p+n.slice(o);if(e.endOfLine!=="lf"){let f=we(e.endOfLine);l>=0&&f===`\r
24
24
  `&&(l+=Nt(m.slice(0,l),`
25
25
  `)),m=ne(0,m,`
26
26
  `,f)}return{formatted:m,cursorOffset:l,comments:c.comments}}function Dr(t,e,r){return typeof e!="number"||Number.isNaN(e)||e<0||e>t.length?r:e}function fu(t,e){let{cursorOffset:r,rangeStart:n,rangeEnd:u}=e;return r=Dr(t,r,-1),n=Dr(t,n,0),u=Dr(t,u,t.length),{...e,cursorOffset:r,rangeStart:n,rangeEnd:u}}function du(t,e){let{cursorOffset:r,rangeStart:n,rangeEnd:u,endOfLine:o}=fu(t,e),i=t.charAt(0)===pu;if(i&&(t=t.slice(1),r--,n--,u--),o==="auto"&&(o=hr(t)),t.includes("\r")){let D=s=>Nt(t.slice(0,Math.max(s,0)),`\r
27
- `);r-=D(r),n-=D(n),u-=D(u),t=gr(t)}return{hasBOM:i,text:t,options:fu(t,{...e,cursorOffset:r,rangeStart:n,rangeEnd:u,endOfLine:o})}}async function lu(t,e){let r=await Ue(e);return!r.hasPragma||r.hasPragma(t)}async function Ai(t,e){return(await Ue(e)).hasIgnorePragma?.(t)}async function ar(t,e){let{hasBOM:r,text:n,options:u}=du(t,await se(e));if(u.rangeStart>=u.rangeEnd&&n!==""||u.requirePragma&&!await lu(n,u)||u.checkIgnorePragma&&await Ai(n,u))return{formatted:t,cursorOffset:e.cursorOffset,comments:[]};let o;return u.rangeStart>0||u.rangeEnd<n.length?o=await yi(n,u):(!u.requirePragma&&u.insertPragma&&u.printer.insertPragma&&!await lu(n,u)&&(n=u.printer.insertPragma(n)),o=await mu(n,u)),r&&(o.formatted=pu+o.formatted,o.cursorOffset>=0&&o.cursorOffset++),o}async function Fu(t,e,r){let{text:n,options:u}=du(t,await se(e)),o=await me(n,u);return r&&(r.preprocessForPrint&&(o.ast=await or(o.ast,u)),r.massage&&(o.ast=uu(o.ast,u))),o}async function Eu(t,e){e=await se(e);let r=await Ve(t,e);return Ce(r,e)}async function Cu(t,e){let r=Vr(t),{formatted:n}=await ar(r,{...e,parser:"__js_expression"});return n}async function hu(t,e){e=await se(e);let{ast:r}=await me(t,e);return e.cursorOffset>=0&&(e={...e,...ir(r,e)}),Ve(r,e)}async function gu(t,e){return Ce(t,await se(e))}var cr={};At(cr,{builders:()=>Bi,printer:()=>Ti,utils:()=>Ni});var Bi={join:be,line:Ze,softline:Yr,hardline:W,literalline:Je,group:Ot,conditionalGroup:Rr,fill:Ir,lineSuffix:Ie,lineSuffixBoundary:jr,cursor:ee,breakParent:ae,ifBreak:vr,trim:Ur,indent:oe,indentIfBreak:Lr,align:De,addAlignmentToDoc:Qe,markAsRoot:Xe,dedentToRoot:br,dedent:kr,hardlineWithoutBreakParent:ke,literallineWithoutBreakParent:Pt,label:Mr,concat:t=>t},Ti={printDocToString:Ce},Ni={willBreak:Br,traverseDoc:Oe,findInDoc:Ke,mapDoc:Se,removeLines:Nr,stripTrailingHardline:He,replaceEndOfLine:wr,canBreak:Or};var _u="3.9.5";var lr={};At(lr,{addDanglingComment:()=>re,addLeadingComment:()=>ce,addTrailingComment:()=>fe,getAlignmentSize:()=>he,getIndentSize:()=>yu,getMaxContinuousCount:()=>Au,getNextNonSpaceNonCommentCharacter:()=>xu,getNextNonSpaceNonCommentCharacterIndex:()=>ji,getPreferredQuote:()=>Nu,getStringWidth:()=>Re,hasNewline:()=>H,hasNewlineInRange:()=>wu,hasSpaces:()=>Ou,isNextLineEmpty:()=>zi,isNextLineEmptyAfterIndex:()=>gt,isPreviousLineEmpty:()=>Vi,makeString:()=>$i,skip:()=>_e,skipEverythingButNewLine:()=>ut,skipInlineComment:()=>Be,skipNewline:()=>$,skipSpaces:()=>j,skipToLineEnd:()=>nt,skipTrailingComment:()=>Te,skipWhitespace:()=>rn});function wi(t,e){if(e===!1)return!1;if(t.charAt(e)==="/"&&t.charAt(e+1)==="*"){for(let r=e+2;r<t.length;++r)if(t.charAt(r)==="*"&&t.charAt(r+1)==="/")return r+2}return e}var Be=wi;function Oi(t,e){return e===!1?!1:t.charAt(e)==="/"&&t.charAt(e+1)==="/"?ut(t,e):e}var Te=Oi;function Pi(t,e){let r=null,n=e;for(;n!==r;)r=n,n=j(t,n),n=Be(t,n),n=Te(t,n),n=$(t,n);return n}var We=Pi;function Si(t,e){let r=null,n=e;for(;n!==r;)r=n,n=nt(t,n),n=Be(t,n),n=j(t,n);return n=Te(t,n),n=$(t,n),n!==!1&&H(t,n)}var gt=Si;function bi(t,e){let r=t.lastIndexOf(`
27
+ `);r-=D(r),n-=D(n),u-=D(u),t=gr(t)}return{hasBOM:i,text:t,options:fu(t,{...e,cursorOffset:r,rangeStart:n,rangeEnd:u,endOfLine:o})}}async function lu(t,e){let r=await Ue(e);return!r.hasPragma||r.hasPragma(t)}async function Ai(t,e){return(await Ue(e)).hasIgnorePragma?.(t)}async function ar(t,e){let{hasBOM:r,text:n,options:u}=du(t,await se(e));if(u.rangeStart>=u.rangeEnd&&n!==""||u.requirePragma&&!await lu(n,u)||u.checkIgnorePragma&&await Ai(n,u))return{formatted:t,cursorOffset:e.cursorOffset,comments:[]};let o;return u.rangeStart>0||u.rangeEnd<n.length?o=await yi(n,u):(!u.requirePragma&&u.insertPragma&&u.printer.insertPragma&&!await lu(n,u)&&(n=u.printer.insertPragma(n)),o=await mu(n,u)),r&&(o.formatted=pu+o.formatted,o.cursorOffset>=0&&o.cursorOffset++),o}async function Fu(t,e,r){let{text:n,options:u}=du(t,await se(e)),o=await me(n,u);return r&&(r.preprocessForPrint&&(o.ast=await or(o.ast,u)),r.massage&&(o.ast=uu(o.ast,u))),o}async function Eu(t,e){e=await se(e);let r=await Ve(t,e);return Ce(r,e)}async function Cu(t,e){let r=Vr(t),{formatted:n}=await ar(r,{...e,parser:"__js_expression"});return n}async function hu(t,e){e=await se(e);let{ast:r}=await me(t,e);return e.cursorOffset>=0&&(e={...e,...ir(r,e)}),Ve(r,e)}async function gu(t,e){return Ce(t,await se(e))}var cr={};At(cr,{builders:()=>Bi,printer:()=>Ti,utils:()=>Ni});var Bi={join:be,line:Ze,softline:Yr,hardline:W,literalline:Je,group:Ot,conditionalGroup:Rr,fill:Ir,lineSuffix:Ie,lineSuffixBoundary:jr,cursor:ee,breakParent:ae,ifBreak:vr,trim:Ur,indent:oe,indentIfBreak:Lr,align:De,addAlignmentToDoc:Qe,markAsRoot:Xe,dedentToRoot:br,dedent:kr,hardlineWithoutBreakParent:ke,literallineWithoutBreakParent:Pt,label:Mr,concat:t=>t},Ti={printDocToString:Ce},Ni={willBreak:Br,traverseDoc:Oe,findInDoc:Ke,mapDoc:Se,removeLines:Nr,stripTrailingHardline:He,replaceEndOfLine:wr,canBreak:Or};var _u="3.9.6";var lr={};At(lr,{addDanglingComment:()=>re,addLeadingComment:()=>ce,addTrailingComment:()=>fe,getAlignmentSize:()=>he,getIndentSize:()=>yu,getMaxContinuousCount:()=>Au,getNextNonSpaceNonCommentCharacter:()=>xu,getNextNonSpaceNonCommentCharacterIndex:()=>ji,getPreferredQuote:()=>Nu,getStringWidth:()=>Re,hasNewline:()=>H,hasNewlineInRange:()=>wu,hasSpaces:()=>Ou,isNextLineEmpty:()=>zi,isNextLineEmptyAfterIndex:()=>gt,isPreviousLineEmpty:()=>Vi,makeString:()=>$i,skip:()=>_e,skipEverythingButNewLine:()=>ut,skipInlineComment:()=>Be,skipNewline:()=>$,skipSpaces:()=>j,skipToLineEnd:()=>nt,skipTrailingComment:()=>Te,skipWhitespace:()=>rn});function wi(t,e){if(e===!1)return!1;if(t.charAt(e)==="/"&&t.charAt(e+1)==="*"){for(let r=e+2;r<t.length;++r)if(t.charAt(r)==="*"&&t.charAt(r+1)==="/")return r+2}return e}var Be=wi;function Oi(t,e){return e===!1?!1:t.charAt(e)==="/"&&t.charAt(e+1)==="/"?ut(t,e):e}var Te=Oi;function Pi(t,e){let r=null,n=e;for(;n!==r;)r=n,n=j(t,n),n=Be(t,n),n=Te(t,n),n=$(t,n);return n}var We=Pi;function Si(t,e){let r=null,n=e;for(;n!==r;)r=n,n=nt(t,n),n=Be(t,n),n=j(t,n);return n=Te(t,n),n=$(t,n),n!==!1&&H(t,n)}var gt=Si;function bi(t,e){let r=t.lastIndexOf(`
28
28
  `);return r===-1?0:he(t.slice(r+1).match(/^[\t ]*/)[0],e)}var yu=bi;function fr(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function ki(t,e){let r=t.matchAll(new RegExp(`(?:${fr(e)})+`,"g"));return r.reduce||(r=[...r]),r.reduce((n,[u])=>Math.max(n,u.length),0)/e.length}var Au=ki;function Ii(t,e){let r=We(t,e);return r===!1?"":t.charAt(r)}var xu=Ii;var Bu=Object.freeze({character:"'",codePoint:39}),Tu=Object.freeze({character:'"',codePoint:34}),Ri=Object.freeze({preferred:Bu,alternate:Tu}),vi=Object.freeze({preferred:Tu,alternate:Bu});function Nu(t,e){let{preferred:r,alternate:n}=e===!0||e==="'"?Ri:vi,{length:u}=t,o=0,i=0;for(let D=0;D<u;D++){let s=t.charCodeAt(D);s===r.codePoint?o++:s===n.codePoint&&i++}return(o>i?n:r).character}function Li(t,e,r){for(let n=e;n<r;++n)if(t.charAt(n)===`
29
29
  `)return!0;return!1}var wu=Li;function Mi(t,e,r={}){return j(t,r.backwards?e-1:e,r)!==e}var Ou=Mi;function Yi(t,e,r){return We(t,r(e))}function ji(t,e){return arguments.length===2||typeof e=="number"?We(t,e):Yi(...arguments)}function Ui(t,e,r){return ve(t,r(e))}function Vi(t,e){return arguments.length===2||typeof e=="number"?ve(t,e):Ui(...arguments)}function Wi(t,e,r){return gt(t,r(e))}function $i(t,e,r){let n=e==='"'?"'":'"',o=ne(0,t,/\\(.)|(["'])/gs,(i,D,s)=>D===n?D:s===e?"\\"+s:s||(r&&/^[^\n\r"'0-7\\bfnrt-vx\u2028\u2029]$/.test(D)?D:"\\"+D));return e+o+e}function zi(t,e){return arguments.length===2||typeof e=="number"?gt(t,e):Wi(...arguments)}function de(t,e=1){return async(...r)=>{let n=r[e]??{},u=n.plugins??[];return r[e]={...n,plugins:Array.isArray(u)?u:Object.values(u)},await t(...r)}}var Pu=de(ar);async function Su(t,e){let{formatted:r}=await Pu(t,{...e,cursorOffset:-1});return r}async function Gi(t,e){return await Su(t,e)===t}var Ki=de(it,0),Hi={parse:de(Fu),formatAST:de(Eu),formatDoc:de(Cu),printToDoc:de(hu),printDocToString:de(gu)};return Yu(Ji);});
package/standalone.mjs CHANGED
@@ -19,11 +19,11 @@ The range will extend backwards to the start of the first line containing the se
19
19
  `,u.gutter(h.replace(/\d/g," "))," ",B,u.marker("^").repeat(J)].join(""),P&&r.message&&(A+=" "+u.message(r.message))}return[u.marker(">"),u.gutter(h),F.length>0?` ${F}`:"",A].join("")}else return` ${u.gutter(h)}${F.length>0?` ${F}`:""}`}).join(`
20
20
  `);return r.message&&!p&&(f=`${" ".repeat(l+1)}${r.message}
21
21
  ${f}`),u.reset(f)}function Zn(t,e,r={}){return Qn(t,e,r)}async function ii(t,e){let r=await Ue(e),n=r.preprocess?await r.preprocess(t,e):t;e.originalText=n;let u;try{u=await r.parse(n,e,e)}catch(o){si(o,t)}return{text:n,ast:u}}function si(t,e){let{loc:r}=t;if(r){let{start:n,end:u}=r;n&&(n={line:n.line,column:n.column-1}),u&&(u={line:u.line,column:u.column-1});let o=Zn(e,{start:n,end:u},{highlightCode:!0});t.message+=`
22
- `+o,t.codeFrame=o}throw t}var me=ii;async function eu(t,e,r,n,u){if(r.embeddedLanguageFormatting!=="auto")return;let{printer:o}=r,{embed:i}=o;if(!i)return;if(i.length>2)throw new Error("printer.embed has too many parameters. The API changed in Prettier v3. Please update your plugin. See https://prettier.io/docs/plugins#optional-embed");let{hasPrettierIgnore:D}=o,{getVisitorKeys:s}=i,a=[];l();let c=t.stack;for(let{print:m,node:f,pathStack:F}of a)try{t.stack=F;let d=await m(p,e,t,r);d&&u.set(f,d)}catch(d){if(globalThis.PRETTIER_DEBUG)throw d}t.stack=c;function p(m,f){return Di(m,f,r,n)}function l(){let{node:m}=t;if(m===null||typeof m!="object"||D?.(t))return;for(let F of s(m))Array.isArray(m[F])?t.each(l,F):t.call(l,F);let f=i(t,r);if(f){if(typeof f=="function"){a.push({print:f,node:m,pathStack:[...t.stack]});return}u.set(m,f)}}}async function Di(t,e,r,n){let u=await se({...r,...e,parentParser:r.parser,originalText:t,cursorOffset:void 0,rangeStart:void 0,rangeEnd:void 0},{passThrough:!0}),{ast:o}=await me(t,u),i=await n(o,u);return He(i)}function ai(t,e,r,n){let{originalText:u,[ue]:o,locStart:i,locEnd:D,[Symbol.for("printedComments")]:s}=e,{node:a}=t,c=i(a),p=D(a);for(let m of o)i(m)>=c&&D(m)<=p&&s.add(m);let{printPrettierIgnored:l}=e.printer;return l?l(t,e,r,n):u.slice(c,p)}var tu=ai;async function Ve(t,e){({ast:t}=await ur(t,e));let r=new Map,n=new en(t),u=dn(e),o=new Map;await eu(n,D,e,Ve,o);let i=await ru(n,e,D,void 0,o);if(mn(e),e.cursorOffset>=0){if(e.nodeAfterCursor&&!e.nodeBeforeCursor)return[ee,i];if(e.nodeBeforeCursor&&!e.nodeAfterCursor)return[i,ee]}return i;function D(a,c){return a===void 0||a===n?s(c):Array.isArray(a)?n.call(()=>s(c),...a):n.call(()=>s(c),a)}function s(a){u(n);let c=n.node;if(c==null)return"";let p=ge(c)&&a===void 0;if(p&&r.has(c))return r.get(c);let l=ru(n,e,D,a,o);return p&&r.set(c,l),l}}function ru(t,e,r,n,u){let{node:o}=t,{printer:i}=e,D;switch(i.hasPrettierIgnore?.(t)?D=tu(t,e,r,n):u.has(o)?D=u.get(o):D=i.print(t,e,r,n),o){case e.cursorNode:D=Ee(D,s=>[ee,s,ee]);break;case e.nodeBeforeCursor:D=Ee(D,s=>[s,ee]);break;case e.nodeAfterCursor:D=Ee(D,s=>[ee,s]);break}return i.printComment&&rt(o.comments)&&!i.willPrintOwnComments?.(t,e)&&(D=pn(t,D,e)),D}async function ur(t,e){let r=t.comments??[];e[ue]=r,e[Symbol.for("printedComments")]=new Set,an(t,e);let{printer:{preprocess:n}}=e;return t=n?await n(t,e):t,{ast:t,comments:r}}function ci(t,e){let{cursorOffset:r,locStart:n,locEnd:u,getVisitorKeys:o}=e,i=m=>n(m)<=r&&u(m)>=r,D=t,s=[t];for(let m of nn(t,{getVisitorKeys:o,filter:i}))s.push(m),D=m;if(un(D,{getVisitorKeys:o}))return{cursorNode:D};let a,c,p=-1,l=Number.POSITIVE_INFINITY;for(;s.length>0&&(a===void 0||c===void 0);){D=s.pop();let m=a!==void 0,f=c!==void 0;for(let F of ye(D,{getVisitorKeys:o})){if(!m){let d=u(F);d<=r&&d>p&&(a=F,p=d)}if(!f){let d=n(F);d>=r&&d<l&&(c=F,l=d)}}}return{nodeBeforeCursor:a,nodeAfterCursor:c}}var or=ci;function fi(t,e){let{printer:r}=e,n=r.massageAstNode;if(!n)return t;let{getVisitorKeys:u}=r,{ignoredProperties:o}=n;return i(t);function i(D,s){if(!ge(D))return D;if(Array.isArray(D))return D.map(l=>i(l,s)).filter(Boolean);let a={},c=new Set(u(D));for(let l in D)!le(D,l)||o?.has(l)||(c.has(l)?a[l]=i(D[l],D):a[l]=D[l]);let p=n(D,a,s);if(p!==null)return p??a}}var nu=fi;var li=Array.prototype.findLastIndex??function(t){for(let e=this.length-1;e>=0;e--){let r=this[e];if(t(r,e,this))return e}return-1},pi=X("findLastIndex",function(){if(Array.isArray(this))return li}),uu=pi;function mi(t,e){return e=new Set(e),t.find(r=>su.has(r.type)&&e.has(r))}function ou(t){let e=uu(0,t,r=>r.type!=="Program"&&r.type!=="File");return e===-1?t:t.slice(0,e+1)}function di(t,e,{locStart:r,locEnd:n}){let[u,...o]=t,[i,...D]=e;if(u===i)return[u,i];let s=r(u);for(let c of ou(D))if(r(c)>=s)i=c;else break;let a=n(i);for(let c of ou(o)){if(n(c)<=a)u=c;else break;if(u===i)break}return[u,i]}function ir(t,e,r,n,u=[],o,i){let{locStart:D,locEnd:s}=i,a=D(t),c=s(t);if(e>c||e<a||o==="rangeEnd"&&e===a||o==="rangeStart"&&e===c)return;let p=[t,...u],l=ot(t,p,{cache:Ut,locStart:D,locEnd:s,getVisitorKeys:r.getVisitorKeys,filter:r.printer.canAttachComment,getChildren:r.printer.getCommentChildNodes});for(let m of l){let f=ir(m,e,r,n,p,o,i);if(f)return f}if(n(t,u[0]))return p}function Fi(t,e){return e!=="DeclareExportDeclaration"&&t!=="TypeParameterDeclaration"&&(t==="Directive"||t==="TypeAlias"||t==="TSExportAssignment"||t.startsWith("Declare")||t.startsWith("TSDeclare")||t.endsWith("Statement")||t.endsWith("Declaration"))}var su=new Set(["JsonRoot","ObjectExpression","ArrayExpression","StringLiteral","NumericLiteral","BooleanLiteral","NullLiteral","UnaryExpression","TemplateLiteral"]),Ei=new Set(["OperationDefinition","FragmentDefinition","VariableDefinition","TypeExtensionDefinition","ObjectTypeDefinition","FieldDefinition","DirectiveDefinition","EnumTypeDefinition","EnumValueDefinition","InputValueDefinition","InputObjectTypeDefinition","SchemaDefinition","OperationTypeDefinition","InterfaceTypeDefinition","UnionTypeDefinition","ScalarTypeDefinition"]);function iu(t,e,r){if(!e)return!1;switch(t.parser){case"flow":case"hermes":case"babel":case"babel-flow":case"babel-ts":case"typescript":case"acorn":case"espree":case"meriyah":case"oxc":case"oxc-ts":case"__babel_estree":return Fi(e.type,r?.type);case"json":case"json5":case"jsonc":case"json-stringify":return su.has(e.type);case"graphql":return Ei.has(e.kind);case"vue":return e.tag!=="root"}return!1}function Du(t,e,r){let{rangeStart:n,rangeEnd:u}=e;k(u>n);let o=t.slice(n,u).search(/\S/),i=o===-1;if(!i)for(n+=o;u>n&&!/\S/.test(t[u-1]);--u);let D=e.printer.features?.experimental_locForRangeFormat??e,s=ir(r,n,e,(f,F)=>iu(e,f,F),[],"rangeStart",D);if(!s)return;let a=i?s:ir(r,u,e,f=>iu(e,f),[],"rangeEnd",D);if(!a)return;let c,p;if(r.type==="JsonRoot"){let f=mi(s,a);c=f,p=f}else[c,p]=di(s,a,e);let{locStart:l,locEnd:m}=D;return[Math.min(l(c),l(p)),Math.max(m(c),m(p))]}var lu="\uFEFF",au=Symbol("cursor");async function pu(t,e,r=0){if(!t||t.trim().length===0)return{formatted:"",cursorOffset:-1,comments:[]};let{ast:n,text:u}=await me(t,e);e.cursorOffset>=0&&(e={...e,...or(n,e)});let o=await Ve(n,e,r);r>0&&(o=Qe([W,o],r,e.tabWidth));let i=Ce(o,e);if(r>0){let s=i.formatted.trim();i.cursorNodeStart!==void 0&&(i.cursorNodeStart-=i.formatted.indexOf(s),i.cursorNodeStart<0&&(i.cursorNodeStart=0,i.cursorNodeText=i.cursorNodeText.trimStart()),i.cursorNodeStart+i.cursorNodeText.length>s.length&&(i.cursorNodeText=i.cursorNodeText.trimEnd())),i.formatted=s+we(e.endOfLine)}let D=e[ue];if(e.cursorOffset>=0){let s,a,c,p;if((e.cursorNode||e.nodeBeforeCursor||e.nodeAfterCursor)&&i.cursorNodeText)if(c=i.cursorNodeStart,p=i.cursorNodeText,e.cursorNode)s=e.locStart(e.cursorNode),a=u.slice(s,e.locEnd(e.cursorNode));else{if(!e.nodeBeforeCursor&&!e.nodeAfterCursor)throw new Error("Cursor location must contain at least one of cursorNode, nodeBeforeCursor, nodeAfterCursor");s=e.nodeBeforeCursor?e.locEnd(e.nodeBeforeCursor):0;let E=e.nodeAfterCursor?e.locStart(e.nodeAfterCursor):u.length;a=u.slice(s,E)}else s=0,a=u,c=0,p=i.formatted;let l=e.cursorOffset-s;if(a===p)return{formatted:i.formatted,cursorOffset:c+l,comments:D};let m=a.split("");m.splice(l,0,au);let f=p.split(""),F=xt(m,f),d=c;for(let E of F)if(E.removed){if(E.value.includes(au))break}else d+=E.count;return{formatted:i.formatted,cursorOffset:d,comments:D}}return{formatted:i.formatted,cursorOffset:-1,comments:D}}async function Ci(t,e){let{ast:r,text:n}=await me(t,e),[u,o]=Du(n,e,r)??[0,0],i=n.slice(u,o),D=Math.min(u,n.lastIndexOf(`
22
+ `+o,t.codeFrame=o}throw t}var me=ii;async function eu(t,e,r,n,u){if(r.embeddedLanguageFormatting!=="auto")return;let{printer:o}=r,{embed:i}=o;if(!i)return;if(i.length>2)throw new Error("printer.embed has too many parameters. The API changed in Prettier v3. Please update your plugin. See https://prettier.io/docs/plugins#optional-embed");let{hasPrettierIgnore:D}=o,{getVisitorKeys:s}=i,a=[];l();let c=t.stack;for(let{print:m,node:f,pathStack:F}of a)try{t.stack=F;let d=await m(p,e,t,r);d&&u.set(f,d)}catch(d){if(globalThis.PRETTIER_DEBUG)throw d}t.stack=c;function p(m,f){return Di(m,f,r,n)}function l(){let{node:m}=t;if(m===null||typeof m!="object"||D?.(t))return;for(let F of s(m))Array.isArray(m[F])?t.each(l,F):t.call(l,F);let f=i(t,r);if(f){if(typeof f=="function"){a.push({print:f,node:m,pathStack:[...t.stack]});return}u.set(m,f)}}}async function Di(t,e,r,n){let u=await se({...r,...e,parentParser:r.parser,originalText:t,cursorOffset:void 0,rangeStart:void 0,rangeEnd:void 0},{passThrough:!0}),{ast:o}=await me(t,u),i=await n(o,u);return He(i)}function ai(t,e,r,n){let{originalText:u,[ue]:o,locStart:i,locEnd:D,[Symbol.for("printedComments")]:s}=e,{node:a}=t,c=i(a),p=D(a);for(let m of o)i(m)>=c&&D(m)<=p&&s.add(m);let{printPrettierIgnored:l}=e.printer;return l?l(t,e,r,n):u.slice(c,p)}var tu=ai;async function Ve(t,e){({ast:t}=await ur(t,e));let r=new Map,n=new en(t),u=dn(e),o=new Map;await eu(n,D,e,Ve,o);let i=await ru(n,e,D,void 0,o);if(mn(e),e.cursorOffset>=0){if(e.nodeAfterCursor&&!e.nodeBeforeCursor)return[ee,i];if(e.nodeBeforeCursor&&!e.nodeAfterCursor)return[i,ee]}return i;function D(a,c){return a===void 0||a===n?s(c):Array.isArray(a)?n.call(()=>s(c),...a):n.call(()=>s(c),a)}function s(a){u(n);let c=n.node;if(c==null)return"";let p=ge(c)&&a===void 0;if(p&&r.has(c))return r.get(c);let l=ru(n,e,D,a,o);return p&&r.set(c,l),l}}function ru(t,e,r,n,u){let{node:o}=t,{printer:i}=e,D;switch(i.hasPrettierIgnore?.(t)?D=tu(t,e,r,n):u.has(o)?D=u.get(o):D=i.print(t,e,r,n),o){case e.cursorNode:D=Ee(D,s=>[ee,s,ee]);break;case e.nodeBeforeCursor:D=Ee(D,s=>[s,ee]);break;case e.nodeAfterCursor:D=Ee(D,s=>[ee,s]);break}return i.printComment&&rt(o.comments)&&!i.willPrintOwnComments?.(t,e)&&(D=pn(t,D,e)),D}async function ur(t,e){let r=t.comments??[];e[ue]=r,e[Symbol.for("printedComments")]=new Set,an(t,e);let{printer:{preprocess:n}}=e;return t=n?await n(t,e):t,{ast:t,comments:r}}function ci(t,e){let{cursorOffset:r,locStart:n,locEnd:u,getVisitorKeys:o}=e,i=m=>n(m)<=r&&u(m)>=r,D=t,s=[t];for(let m of nn(t,{getVisitorKeys:o,filter:i}))s.push(m),D=m;if(un(D,{getVisitorKeys:o}))return{cursorNode:D};let a,c,p=-1,l=Number.POSITIVE_INFINITY;for(;s.length>0&&(a===void 0||c===void 0);){D=s.pop();let m=a!==void 0,f=c!==void 0;for(let F of ye(D,{getVisitorKeys:o})){if(!m){let d=u(F);d<=r&&d>p&&(a=F,p=d)}if(!f){let d=n(F);d>=r&&d<l&&(c=F,l=d)}}}return{nodeBeforeCursor:a,nodeAfterCursor:c}}var or=ci;function fi(t,e){let{printer:r}=e,n=r.massageAstNode;if(!n)return t;let{getVisitorKeys:u}=r,{ignoredProperties:o}=n;return i(t);function i(D,s){if(!ge(D))return D;if(Array.isArray(D))return D.map(l=>i(l,s)).filter(Boolean);let a={},c=new Set(u(D));for(let l in D)!le(D,l)||o?.has(l)||(c.has(l)?a[l]=i(D[l],D):a[l]=D[l]);let p=n(D,a,s);if(p!==null)return p??a}}var nu=fi;var li=Array.prototype.findLastIndex??function(t){for(let e=this.length-1;e>=0;e--){let r=this[e];if(t(r,e,this))return e}return-1},pi=X("findLastIndex",function(){if(Array.isArray(this))return li}),uu=pi;function mi(t,e){return e=new Set(e),t.find(r=>su.has(r.type)&&e.has(r))}function ou(t){let e=uu(0,t,r=>r.type!=="Program"&&r.type!=="File");return e===-1?t:t.slice(0,e+1)}function di(t,e,{locStart:r,locEnd:n}){let[u,...o]=t,[i,...D]=e;if(u===i)return[u,i];let s=r(u);for(let c of ou(D))if(r(c)>=s)i=c;else break;let a=n(i);for(let c of ou(o)){if(n(c)<=a)u=c;else break;if(u===i)break}return[u,i]}function ir(t,e,r,n,u=[],o,i){let{locStart:D,locEnd:s}=i,a=D(t),c=s(t);if(e>c||e<a||o==="rangeEnd"&&e===a||o==="rangeStart"&&e===c)return;let p=[t,...u],l=ot(t,p,{cache:Ut,locStart:D,locEnd:s,getVisitorKeys:r.getVisitorKeys,filter:r.printer.canAttachComment,getChildren:r.printer.getCommentChildNodes});for(let m of l){let f=ir(m,e,r,n,p,o,i);if(f)return f}if(n(t,u[0]))return p}function Fi(t,e){return e!=="DeclareExportDeclaration"&&t!=="TypeParameterDeclaration"&&(t==="Directive"||t==="TypeAlias"||t==="TSExportAssignment"||t.startsWith("Declare")||t.startsWith("TSDeclare")||t.endsWith("Statement")||t.endsWith("Declaration"))}var su=new Set(["JsonRoot","ObjectExpression","ArrayExpression","StringLiteral","NumericLiteral","BooleanLiteral","NullLiteral","UnaryExpression","TemplateLiteral"]),Ei=new Set(["OperationDefinition","FragmentDefinition","VariableDefinition","TypeExtensionDefinition","ObjectTypeDefinition","FieldDefinition","DirectiveDefinition","EnumTypeDefinition","EnumValueDefinition","InputValueDefinition","InputObjectTypeDefinition","SchemaDefinition","OperationTypeDefinition","InterfaceTypeDefinition","UnionTypeDefinition","ScalarTypeDefinition"]);function iu(t,e,r){if(!e)return!1;switch(t.parser){case"flow":case"hermes":case"babel":case"babel-flow":case"babel-ts":case"typescript":case"acorn":case"espree":case"meriyah":case"oxc":case"oxc-ts":case"yuku":case"yuku-ts":case"__babel_estree":return Fi(e.type,r?.type);case"json":case"json5":case"jsonc":case"json-stringify":return su.has(e.type);case"graphql":return Ei.has(e.kind);case"vue":return e.tag!=="root"}return!1}function Du(t,e,r){let{rangeStart:n,rangeEnd:u}=e;k(u>n);let o=t.slice(n,u).search(/\S/),i=o===-1;if(!i)for(n+=o;u>n&&!/\S/.test(t[u-1]);--u);let D=e.printer.features?.experimental_locForRangeFormat??e,s=ir(r,n,e,(f,F)=>iu(e,f,F),[],"rangeStart",D);if(!s)return;let a=i?s:ir(r,u,e,f=>iu(e,f),[],"rangeEnd",D);if(!a)return;let c,p;if(r.type==="JsonRoot"){let f=mi(s,a);c=f,p=f}else[c,p]=di(s,a,e);let{locStart:l,locEnd:m}=D;return[Math.min(l(c),l(p)),Math.max(m(c),m(p))]}var lu="\uFEFF",au=Symbol("cursor");async function pu(t,e,r=0){if(!t||t.trim().length===0)return{formatted:"",cursorOffset:-1,comments:[]};let{ast:n,text:u}=await me(t,e);e.cursorOffset>=0&&(e={...e,...or(n,e)});let o=await Ve(n,e,r);r>0&&(o=Qe([W,o],r,e.tabWidth));let i=Ce(o,e);if(r>0){let s=i.formatted.trim();i.cursorNodeStart!==void 0&&(i.cursorNodeStart-=i.formatted.indexOf(s),i.cursorNodeStart<0&&(i.cursorNodeStart=0,i.cursorNodeText=i.cursorNodeText.trimStart()),i.cursorNodeStart+i.cursorNodeText.length>s.length&&(i.cursorNodeText=i.cursorNodeText.trimEnd())),i.formatted=s+we(e.endOfLine)}let D=e[ue];if(e.cursorOffset>=0){let s,a,c,p;if((e.cursorNode||e.nodeBeforeCursor||e.nodeAfterCursor)&&i.cursorNodeText)if(c=i.cursorNodeStart,p=i.cursorNodeText,e.cursorNode)s=e.locStart(e.cursorNode),a=u.slice(s,e.locEnd(e.cursorNode));else{if(!e.nodeBeforeCursor&&!e.nodeAfterCursor)throw new Error("Cursor location must contain at least one of cursorNode, nodeBeforeCursor, nodeAfterCursor");s=e.nodeBeforeCursor?e.locEnd(e.nodeBeforeCursor):0;let E=e.nodeAfterCursor?e.locStart(e.nodeAfterCursor):u.length;a=u.slice(s,E)}else s=0,a=u,c=0,p=i.formatted;let l=e.cursorOffset-s;if(a===p)return{formatted:i.formatted,cursorOffset:c+l,comments:D};let m=a.split("");m.splice(l,0,au);let f=p.split(""),F=xt(m,f),d=c;for(let E of F)if(E.removed){if(E.value.includes(au))break}else d+=E.count;return{formatted:i.formatted,cursorOffset:d,comments:D}}return{formatted:i.formatted,cursorOffset:-1,comments:D}}async function Ci(t,e){let{ast:r,text:n}=await me(t,e),[u,o]=Du(n,e,r)??[0,0],i=n.slice(u,o),D=Math.min(u,n.lastIndexOf(`
23
23
  `,u)+1),s=n.slice(D,u).match(/^\s*/)[0],a=he(s,e.tabWidth),c=await pu(i,{...e,rangeStart:0,rangeEnd:Number.POSITIVE_INFINITY,cursorOffset:e.cursorOffset>u&&e.cursorOffset<=o?e.cursorOffset-u:-1,endOfLine:"lf"},a),p=c.formatted.trimEnd(),{cursorOffset:l}=e;l>o?l+=p.length-i.length:c.cursorOffset>=0&&(l=c.cursorOffset+u);let m=n.slice(0,u)+p+n.slice(o);if(e.endOfLine!=="lf"){let f=we(e.endOfLine);l>=0&&f===`\r
24
24
  `&&(l+=Tt(m.slice(0,l),`
25
25
  `)),m=ne(0,m,`
26
26
  `,f)}return{formatted:m,cursorOffset:l,comments:c.comments}}function sr(t,e,r){return typeof e!="number"||Number.isNaN(e)||e<0||e>t.length?r:e}function cu(t,e){let{cursorOffset:r,rangeStart:n,rangeEnd:u}=e;return r=sr(t,r,-1),n=sr(t,n,0),u=sr(t,u,t.length),{...e,cursorOffset:r,rangeStart:n,rangeEnd:u}}function mu(t,e){let{cursorOffset:r,rangeStart:n,rangeEnd:u,endOfLine:o}=cu(t,e),i=t.charAt(0)===lu;if(i&&(t=t.slice(1),r--,n--,u--),o==="auto"&&(o=Cr(t)),t.includes("\r")){let D=s=>Tt(t.slice(0,Math.max(s,0)),`\r
27
- `);r-=D(r),n-=D(n),u-=D(u),t=hr(t)}return{hasBOM:i,text:t,options:cu(t,{...e,cursorOffset:r,rangeStart:n,rangeEnd:u,endOfLine:o})}}async function fu(t,e){let r=await Ue(e);return!r.hasPragma||r.hasPragma(t)}async function hi(t,e){return(await Ue(e)).hasIgnorePragma?.(t)}async function Dr(t,e){let{hasBOM:r,text:n,options:u}=mu(t,await se(e));if(u.rangeStart>=u.rangeEnd&&n!==""||u.requirePragma&&!await fu(n,u)||u.checkIgnorePragma&&await hi(n,u))return{formatted:t,cursorOffset:e.cursorOffset,comments:[]};let o;return u.rangeStart>0||u.rangeEnd<n.length?o=await Ci(n,u):(!u.requirePragma&&u.insertPragma&&u.printer.insertPragma&&!await fu(n,u)&&(n=u.printer.insertPragma(n)),o=await pu(n,u)),r&&(o.formatted=lu+o.formatted,o.cursorOffset>=0&&o.cursorOffset++),o}async function du(t,e,r){let{text:n,options:u}=mu(t,await se(e)),o=await me(n,u);return r&&(r.preprocessForPrint&&(o.ast=await ur(o.ast,u)),r.massage&&(o.ast=nu(o.ast,u))),o}async function Fu(t,e){e=await se(e);let r=await Ve(t,e);return Ce(r,e)}async function Eu(t,e){let r=Ur(t),{formatted:n}=await Dr(r,{...e,parser:"__js_expression"});return n}async function Cu(t,e){e=await se(e);let{ast:r}=await me(t,e);return e.cursorOffset>=0&&(e={...e,...or(r,e)}),Ve(r,e)}async function hu(t,e){return Ce(t,await se(e))}var ar={};yt(ar,{builders:()=>_i,printer:()=>yi,utils:()=>Ai});var _i={join:be,line:Ze,softline:Mr,hardline:W,literalline:Je,group:wt,conditionalGroup:Ir,fill:kr,lineSuffix:Ie,lineSuffixBoundary:Yr,cursor:ee,breakParent:ae,ifBreak:Rr,trim:jr,indent:oe,indentIfBreak:vr,align:De,addAlignmentToDoc:Qe,markAsRoot:Xe,dedentToRoot:Sr,dedent:br,hardlineWithoutBreakParent:ke,literallineWithoutBreakParent:Ot,label:Lr,concat:t=>t},yi={printDocToString:Ce},Ai={willBreak:xr,traverseDoc:Oe,findInDoc:Ke,mapDoc:Se,removeLines:Tr,stripTrailingHardline:He,replaceEndOfLine:Nr,canBreak:wr};var gu="3.9.5";var fr={};yt(fr,{addDanglingComment:()=>re,addLeadingComment:()=>ce,addTrailingComment:()=>fe,getAlignmentSize:()=>he,getIndentSize:()=>_u,getMaxContinuousCount:()=>yu,getNextNonSpaceNonCommentCharacter:()=>Au,getNextNonSpaceNonCommentCharacterIndex:()=>vi,getPreferredQuote:()=>Tu,getStringWidth:()=>Re,hasNewline:()=>H,hasNewlineInRange:()=>Nu,hasSpaces:()=>wu,isNextLineEmpty:()=>Ui,isNextLineEmptyAfterIndex:()=>gt,isPreviousLineEmpty:()=>Mi,makeString:()=>ji,skip:()=>_e,skipEverythingButNewLine:()=>ut,skipInlineComment:()=>Be,skipNewline:()=>$,skipSpaces:()=>j,skipToLineEnd:()=>nt,skipTrailingComment:()=>Te,skipWhitespace:()=>tn});function xi(t,e){if(e===!1)return!1;if(t.charAt(e)==="/"&&t.charAt(e+1)==="*"){for(let r=e+2;r<t.length;++r)if(t.charAt(r)==="*"&&t.charAt(r+1)==="/")return r+2}return e}var Be=xi;function Bi(t,e){return e===!1?!1:t.charAt(e)==="/"&&t.charAt(e+1)==="/"?ut(t,e):e}var Te=Bi;function Ti(t,e){let r=null,n=e;for(;n!==r;)r=n,n=j(t,n),n=Be(t,n),n=Te(t,n),n=$(t,n);return n}var We=Ti;function Ni(t,e){let r=null,n=e;for(;n!==r;)r=n,n=nt(t,n),n=Be(t,n),n=j(t,n);return n=Te(t,n),n=$(t,n),n!==!1&&H(t,n)}var gt=Ni;function wi(t,e){let r=t.lastIndexOf(`
27
+ `);r-=D(r),n-=D(n),u-=D(u),t=hr(t)}return{hasBOM:i,text:t,options:cu(t,{...e,cursorOffset:r,rangeStart:n,rangeEnd:u,endOfLine:o})}}async function fu(t,e){let r=await Ue(e);return!r.hasPragma||r.hasPragma(t)}async function hi(t,e){return(await Ue(e)).hasIgnorePragma?.(t)}async function Dr(t,e){let{hasBOM:r,text:n,options:u}=mu(t,await se(e));if(u.rangeStart>=u.rangeEnd&&n!==""||u.requirePragma&&!await fu(n,u)||u.checkIgnorePragma&&await hi(n,u))return{formatted:t,cursorOffset:e.cursorOffset,comments:[]};let o;return u.rangeStart>0||u.rangeEnd<n.length?o=await Ci(n,u):(!u.requirePragma&&u.insertPragma&&u.printer.insertPragma&&!await fu(n,u)&&(n=u.printer.insertPragma(n)),o=await pu(n,u)),r&&(o.formatted=lu+o.formatted,o.cursorOffset>=0&&o.cursorOffset++),o}async function du(t,e,r){let{text:n,options:u}=mu(t,await se(e)),o=await me(n,u);return r&&(r.preprocessForPrint&&(o.ast=await ur(o.ast,u)),r.massage&&(o.ast=nu(o.ast,u))),o}async function Fu(t,e){e=await se(e);let r=await Ve(t,e);return Ce(r,e)}async function Eu(t,e){let r=Ur(t),{formatted:n}=await Dr(r,{...e,parser:"__js_expression"});return n}async function Cu(t,e){e=await se(e);let{ast:r}=await me(t,e);return e.cursorOffset>=0&&(e={...e,...or(r,e)}),Ve(r,e)}async function hu(t,e){return Ce(t,await se(e))}var ar={};yt(ar,{builders:()=>_i,printer:()=>yi,utils:()=>Ai});var _i={join:be,line:Ze,softline:Mr,hardline:W,literalline:Je,group:wt,conditionalGroup:Ir,fill:kr,lineSuffix:Ie,lineSuffixBoundary:Yr,cursor:ee,breakParent:ae,ifBreak:Rr,trim:jr,indent:oe,indentIfBreak:vr,align:De,addAlignmentToDoc:Qe,markAsRoot:Xe,dedentToRoot:Sr,dedent:br,hardlineWithoutBreakParent:ke,literallineWithoutBreakParent:Ot,label:Lr,concat:t=>t},yi={printDocToString:Ce},Ai={willBreak:xr,traverseDoc:Oe,findInDoc:Ke,mapDoc:Se,removeLines:Tr,stripTrailingHardline:He,replaceEndOfLine:Nr,canBreak:wr};var gu="3.9.6";var fr={};yt(fr,{addDanglingComment:()=>re,addLeadingComment:()=>ce,addTrailingComment:()=>fe,getAlignmentSize:()=>he,getIndentSize:()=>_u,getMaxContinuousCount:()=>yu,getNextNonSpaceNonCommentCharacter:()=>Au,getNextNonSpaceNonCommentCharacterIndex:()=>vi,getPreferredQuote:()=>Tu,getStringWidth:()=>Re,hasNewline:()=>H,hasNewlineInRange:()=>Nu,hasSpaces:()=>wu,isNextLineEmpty:()=>Ui,isNextLineEmptyAfterIndex:()=>gt,isPreviousLineEmpty:()=>Mi,makeString:()=>ji,skip:()=>_e,skipEverythingButNewLine:()=>ut,skipInlineComment:()=>Be,skipNewline:()=>$,skipSpaces:()=>j,skipToLineEnd:()=>nt,skipTrailingComment:()=>Te,skipWhitespace:()=>tn});function xi(t,e){if(e===!1)return!1;if(t.charAt(e)==="/"&&t.charAt(e+1)==="*"){for(let r=e+2;r<t.length;++r)if(t.charAt(r)==="*"&&t.charAt(r+1)==="/")return r+2}return e}var Be=xi;function Bi(t,e){return e===!1?!1:t.charAt(e)==="/"&&t.charAt(e+1)==="/"?ut(t,e):e}var Te=Bi;function Ti(t,e){let r=null,n=e;for(;n!==r;)r=n,n=j(t,n),n=Be(t,n),n=Te(t,n),n=$(t,n);return n}var We=Ti;function Ni(t,e){let r=null,n=e;for(;n!==r;)r=n,n=nt(t,n),n=Be(t,n),n=j(t,n);return n=Te(t,n),n=$(t,n),n!==!1&&H(t,n)}var gt=Ni;function wi(t,e){let r=t.lastIndexOf(`
28
28
  `);return r===-1?0:he(t.slice(r+1).match(/^[\t ]*/)[0],e)}var _u=wi;function cr(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function Oi(t,e){let r=t.matchAll(new RegExp(`(?:${cr(e)})+`,"g"));return r.reduce||(r=[...r]),r.reduce((n,[u])=>Math.max(n,u.length),0)/e.length}var yu=Oi;function Pi(t,e){let r=We(t,e);return r===!1?"":t.charAt(r)}var Au=Pi;var xu=Object.freeze({character:"'",codePoint:39}),Bu=Object.freeze({character:'"',codePoint:34}),Si=Object.freeze({preferred:xu,alternate:Bu}),bi=Object.freeze({preferred:Bu,alternate:xu});function Tu(t,e){let{preferred:r,alternate:n}=e===!0||e==="'"?Si:bi,{length:u}=t,o=0,i=0;for(let D=0;D<u;D++){let s=t.charCodeAt(D);s===r.codePoint?o++:s===n.codePoint&&i++}return(o>i?n:r).character}function ki(t,e,r){for(let n=e;n<r;++n)if(t.charAt(n)===`
29
29
  `)return!0;return!1}var Nu=ki;function Ii(t,e,r={}){return j(t,r.backwards?e-1:e,r)!==e}var wu=Ii;function Ri(t,e,r){return We(t,r(e))}function vi(t,e){return arguments.length===2||typeof e=="number"?We(t,e):Ri(...arguments)}function Li(t,e,r){return ve(t,r(e))}function Mi(t,e){return arguments.length===2||typeof e=="number"?ve(t,e):Li(...arguments)}function Yi(t,e,r){return gt(t,r(e))}function ji(t,e,r){let n=e==='"'?"'":'"',o=ne(0,t,/\\(.)|(["'])/gs,(i,D,s)=>D===n?D:s===e?"\\"+s:s||(r&&/^[^\n\r"'0-7\\bfnrt-vx\u2028\u2029]$/.test(D)?D:"\\"+D));return e+o+e}function Ui(t,e){return arguments.length===2||typeof e=="number"?gt(t,e):Yi(...arguments)}function de(t,e=1){return async(...r)=>{let n=r[e]??{},u=n.plugins??[];return r[e]={...n,plugins:Array.isArray(u)?u:Object.values(u)},await t(...r)}}var Ou=de(Dr);async function Pu(t,e){let{formatted:r}=await Ou(t,{...e,cursorOffset:-1});return r}async function Vi(t,e){return await Pu(t,e)===t}var Wi=de(it,0),$i={parse:de(du),formatAST:de(Fu),formatDoc:de(Eu),printToDoc:de(Cu),printDocToString:de(hu)};export{$i as __debug,Vi as check,Su as default,ar as doc,Pu as format,Ou as formatWithCursor,Wi as getSupportInfo,fr as util,gu as version};