@prettier/plugin-pug
Advanced tools
Comparing version 3.1.0 to 3.2.0
@@ -17,3 +17,3 @@ import { Plugin, SupportLanguage, Parser, Printer, SupportOptions, RequiredOptions } from 'prettier'; | ||
constructor(logger?: ILogger, level?: LogLevel); | ||
static isSupportedLogLevel(value: any): value is LogLevel; | ||
static isSupportedLogLevel(value: unknown): value is LogLevel; | ||
setLogLevel(level: LogLevel): void; | ||
@@ -20,0 +20,0 @@ isDebugEnabled(): boolean; |
@@ -1,2 +0,2 @@ | ||
import Rt from"pug-lexer";var I=(s=>(s.DEBUG="debug",s.LOG="log",s.INFO="info",s.WARN="warn",s.ERROR="error",s.OFF="off",s))(I||{}),P=class{constructor(t=console,e="info"){this.logger=t;this.level=e}static isSupportedLogLevel(t){return typeof t=="string"&&(t==="debug"||t==="log"||t==="info"||t==="warn"||t==="error"||t==="off")}setLogLevel(t){this.level=t}isDebugEnabled(){return this.level<="debug"}debug(t,...e){this.message("debug",t,...e)}log(t,...e){this.message("log",t,...e)}info(t,...e){this.message("info",t,...e)}warn(t,...e){this.message("warn",t,...e)}error(t,...e){this.message("error",t,...e)}message(t,e,...i){this.level!=="off"&&this.level<=t&&t!=="off"&&this.logger[t](e,...i)}};function E(r=console){return new P(r)}var p=E(console);process.env.NODE_ENV==="test"&&p.setLogLevel("debug");var y=process.env.PRETTIER_PLUGIN_PUG_LOG_LEVEL;y&&(y=y.toLowerCase(),P.isSupportedLogLevel(y)&&p.setLogLevel(y));var c="Pug";var _={category:c,type:"path",array:!0,default:[{value:[]}],description:""},O={..._,description:"Define a list of patterns for attributes that are sorted to the beginning."},L={..._,description:"Define a list of patterns for attributes that are sorted at the end."},C={category:c,type:"choice",default:"as-is",description:"Change how the attributes between _beginning_ and _end_ should be sorted.",choices:[{value:"asc",description:"Sort middle attributes ascending."},{value:"desc",description:"Sort middle attributes descending."},{value:"as-is",description:"Middle attributes are leave untouched."}]};var N={category:c,type:"int",default:-1,description:"The line length where Prettier will try wrap.",range:{start:-1,end:Number.POSITIVE_INFINITY,step:1}},R={category:c,type:"choice",default:null,description:"",choices:[{value:null,description:"Use `singleQuote` value."},{value:!0,description:"Use single quotes instead of double quotes."},{value:"true",description:"Use single quotes instead of double quotes."},{value:!1,description:"Use double quotes instead of double quotes."}]},U={category:c,type:"int",default:-1,description:"Number of spaces per indentation level.",range:{start:-1,end:Number.POSITIVE_INFINITY,step:1}},$={category:c,type:"choice",default:null,description:"",choices:[{value:null,description:"Use `useTabs` value."},{value:!0,description:"Indent with tabs instead of spaces."},{value:"true",description:"Indent with tabs instead of spaces."},{value:!1,description:"Indent with spaces instead of tabs."}]},B={category:c,type:"choice",default:null,description:"",choices:[{value:null,description:"Use `bracketSpacing` value."},{value:!0,description:"Print spaces between brackets."},{value:"true",description:"Print spaces between brackets."},{value:!1,description:"Do not print spaces between brackets."}]},G={category:c,type:"choice",default:null,description:"",choices:[{value:null,description:"Use `bracketSpacing` value."},{value:!0,description:"Print semicolons."},{value:"true",description:"Print semicolons."},{value:!1,description:"Do not print semicolons, except at the beginning of lines which may need them."}]},D={category:c,type:"choice",default:null,description:"Include parentheses around a sole arrow function parameter.",choices:[{value:null,description:"Use `arrowParens` value."},{value:"always",description:"Always add parens. Example: `(x) => x`"},{value:"avoid",description:"Omit parens when possible. Example: `x => x`"}]},F={category:c,type:"choice",default:null,description:"Determines position of closing bracket which wraps attributes.",choices:[{value:null,description:"Use `bracketSameLine` value."},{value:!0,description:` | ||
import Nt from"pug-lexer";var w=(s=>(s.DEBUG="debug",s.LOG="log",s.INFO="info",s.WARN="warn",s.ERROR="error",s.OFF="off",s))(w||{}),P=class{constructor(t=console,i="info"){this.logger=t;this.level=i}static isSupportedLogLevel(t){return typeof t=="string"&&(t==="debug"||t==="log"||t==="info"||t==="warn"||t==="error"||t==="off")}setLogLevel(t){this.level=t}isDebugEnabled(){return this.level<="debug"}debug(t,...i){this.message("debug",t,...i)}log(t,...i){this.message("log",t,...i)}info(t,...i){this.message("info",t,...i)}warn(t,...i){this.message("warn",t,...i)}error(t,...i){this.message("error",t,...i)}message(t,i,...e){this.level!=="off"&&this.level<=t&&t!=="off"&&this.logger[t](i,...e)}};function E(r=console){return new P(r)}var l=E(console);process.env.NODE_ENV==="test"&&l.setLogLevel("debug");var y=process.env.PRETTIER_PLUGIN_PUG_LOG_LEVEL;y&&(y=y.toLowerCase(),P.isSupportedLogLevel(y)&&l.setLogLevel(y));var p="Pug";var O={category:p,type:"path",array:!0,default:[{value:[]}],description:""},_={...O,description:"Define a list of patterns for attributes that are sorted to the beginning."},L={...O,description:"Define a list of patterns for attributes that are sorted at the end."},C={category:p,type:"choice",default:"as-is",description:"Change how the attributes between _beginning_ and _end_ should be sorted.",choices:[{value:"asc",description:"Sort middle attributes ascending."},{value:"desc",description:"Sort middle attributes descending."},{value:"as-is",description:"Middle attributes are leave untouched."}]};var N={category:p,type:"int",default:-1,description:"The line length where Prettier will try wrap.",range:{start:-1,end:Number.POSITIVE_INFINITY,step:1}},R={category:p,type:"choice",default:null,description:"",choices:[{value:null,description:"Use `singleQuote` value."},{value:!0,description:"Use single quotes instead of double quotes."},{value:"true",description:"Use single quotes instead of double quotes."},{value:!1,description:"Use double quotes instead of double quotes."}]},U={category:p,type:"int",default:-1,description:"Number of spaces per indentation level.",range:{start:-1,end:Number.POSITIVE_INFINITY,step:1}},$={category:p,type:"choice",default:null,description:"",choices:[{value:null,description:"Use `useTabs` value."},{value:!0,description:"Indent with tabs instead of spaces."},{value:"true",description:"Indent with tabs instead of spaces."},{value:!1,description:"Indent with spaces instead of tabs."}]},B={category:p,type:"choice",default:null,description:"",choices:[{value:null,description:"Use `bracketSpacing` value."},{value:!0,description:"Print spaces between brackets."},{value:"true",description:"Print spaces between brackets."},{value:!1,description:"Do not print spaces between brackets."}]},G={category:p,type:"choice",default:null,description:"",choices:[{value:null,description:"Use `bracketSpacing` value."},{value:!0,description:"Print semicolons."},{value:"true",description:"Print semicolons."},{value:!1,description:"Do not print semicolons, except at the beginning of lines which may need them."}]},D={category:p,type:"choice",default:null,description:"Include parentheses around a sole arrow function parameter.",choices:[{value:null,description:"Use `arrowParens` value."},{value:"always",description:"Always add parens. Example: `(x) => x`"},{value:"avoid",description:"Omit parens when possible. Example: `x => x`"}]},F={category:p,type:"choice",default:null,description:"Determines position of closing bracket which wraps attributes.",choices:[{value:null,description:"Use `bracketSameLine` value."},{value:!0,description:` | ||
Closing bracket remains with last attribute's line. | ||
@@ -29,3 +29,3 @@ Example: | ||
) | ||
`}]};var W={category:c,type:"choice",default:"as-is",description:"Change behavior of boolean attributes.",choices:[{value:"as-is",description:"Nothing is changed."},{value:"none",description:"Every attribute with empty quotes will have them removed."},{value:"all",description:"Every boolean attribute will be expressed with empty quotes."}]},Q={category:c,type:"path",default:[{value:[]}],array:!0,description:'Define a list of patterns for attributes that will be forced to have empty quotes even with "none" selected.'};var V={category:c,type:"choice",default:"always",description:"Change when attributes are separated by commas in tags.",choices:[{value:"always",description:'Always separate attributes with commas. Example: `button(type="submit", (click)="play()", disabled)`'},{value:"as-needed",description:'Only add commas between attributes where required. Example: `button(type="submit", (click)="play()" disabled)`'},{value:"none",description:'Never add commas between attributes. Example: `button(type="submit" @click="play()" :style="style" disabled)`'}]};function j(r){switch(r){case"always":case"as-needed":case"none":return r}throw new Error(`Invalid option for pugAttributeSeparator. Found '${r}'. Possible options: 'always', 'as-needed' or 'none'`)}var M={category:c,type:"choice",default:"before-attributes",description:"Define where classes be placed.",choices:[{value:"before-attributes",description:"Forces all valid class literals to be placed before attributes."},{value:"after-attributes",description:"Forces all valid class literals to be placed after attributes."}]};var Y={category:c,type:"choice",default:"literal",description:"Define how classes should be formatted.",choices:[{value:"literal",description:"Forces all valid classes to be printed as literals."},{value:"attribute",description:"Forces all valid classes to be printed in class attribute."},{value:"as-is",description:"Disables class formatting."}]};var q={category:c,type:"choice",default:0,description:"Determines the indent level of closing brackets when wrapping attributes.",choices:[{value:0,description:` | ||
`}]};var W={category:p,type:"choice",default:"as-is",description:"Change behavior of boolean attributes.",choices:[{value:"as-is",description:"Nothing is changed."},{value:"none",description:"Every attribute with empty quotes will have them removed."},{value:"all",description:"Every boolean attribute will be expressed with empty quotes."}]},Q={category:p,type:"path",default:[{value:[]}],array:!0,description:'Define a list of patterns for attributes that will be forced to have empty quotes even with "none" selected.'};var j={category:p,type:"choice",default:"always",description:"Change when attributes are separated by commas in tags.",choices:[{value:"always",description:'Always separate attributes with commas. Example: `button(type="submit", (click)="play()", disabled)`'},{value:"as-needed",description:'Only add commas between attributes where required. Example: `button(type="submit", (click)="play()" disabled)`'},{value:"none",description:'Never add commas between attributes. Example: `button(type="submit" @click="play()" :style="style" disabled)`'}]};function V(r){switch(r){case"always":case"as-needed":case"none":return r}throw new Error(`Invalid option for pugAttributeSeparator. Found '${r}'. Possible options: 'always', 'as-needed' or 'none'`)}var M={category:p,type:"choice",default:"before-attributes",description:"Define where classes be placed.",choices:[{value:"before-attributes",description:"Forces all valid class literals to be placed before attributes."},{value:"after-attributes",description:"Forces all valid class literals to be placed after attributes."}]};var Y={category:p,type:"choice",default:"literal",description:"Define how classes should be formatted.",choices:[{value:"literal",description:"Forces all valid classes to be printed as literals."},{value:"attribute",description:"Forces all valid classes to be printed in class attribute."},{value:"as-is",description:"Disables class formatting."}]};var q={category:p,type:"choice",default:0,description:"Determines the indent level of closing brackets when wrapping attributes.",choices:[{value:0,description:` | ||
Closing bracket aligns with the element. | ||
@@ -50,36 +50,36 @@ Example: | ||
) | ||
`}]};var H={category:c,type:"choice",default:"keep-all",description:"Change behavior of spaces within comments.",choices:[{value:"keep-all",description:"Keep all spaces within comments. Example: `// this is a comment`"},{value:"keep-leading",description:"Keep leading spaces within comments. Example: `// this is a comment`"},{value:"trim-all",description:"Trim all spaces within comments. Example: `// this is a comment`"}]};function x(r,t,e=!1){switch(t){case"keep-leading":{let i="",n=0;for(n;n<r.length&&r[n]===" ";n++)i+=" ";return i+=r.slice(n).trim().replaceAll(/\s\s+/g," "),i}case"trim-all":{let i=r.trim();return i=i.replaceAll(/\s\s+/g," "),!e&&r[0]===" "&&(i=` ${i}`),i}case"keep-all":default:return r}}var K={category:c,type:"boolean",default:!1,description:"Include `div` tag when followed by literal class or id syntax"};var J={category:c,type:"choice",default:"auto",description:"Define which framework is used in the project.",choices:[{value:"auto",description:"Try to identify used framework, if there is one."},{value:"vue",description:"Uses Vue.js."},{value:"svelte",description:"Uses Svelte."},{value:"angular",description:"Uses Angular."}]};var z={category:c,type:"choice",default:"literal",description:"Define how the id should be formatted.",choices:[{value:"literal",description:"Forces all valid ids to be printed as literals."},{value:"as-is",description:"Disables id formatting."}]};var X={category:c,type:"boolean",default:!1,description:"Preserve attribute brackets."};var Z={category:c,type:"boolean",default:!1,description:"Indent pug in template tags in single file components such as from vue or svelte."};var tt={category:c,type:"int",default:-1,description:"The maximum amount of attributes that an element can appear with on one line before it gets wrapped.",range:{start:-1,end:Number.POSITIVE_INFINITY,step:1}},et={category:c,type:"path",default:"",description:"Regex pattern to match attributes against that should always trigger wrapping."};var it={pugPrintWidth:N,pugSingleQuote:R,pugTabWidth:U,pugUseTabs:$,pugBracketSpacing:B,pugArrowParens:D,pugSemi:G,pugBracketSameLine:F,pugClosingBracketIndentDepth:q,pugAttributeSeparator:V,pugCommentPreserveSpaces:H,pugSortAttributes:C,pugSortAttributesBeginning:O,pugSortAttributesEnd:L,pugWrapAttributesThreshold:tt,pugWrapAttributesPattern:et,pugEmptyAttributes:W,pugClassNotation:Y,pugIdNotation:z,pugClassLocation:M,pugExplicitDiv:K,pugEmptyAttributesForceQuotes:Q,pugSingleFileComponentIndentation:Z,pugFramework:J,pugPreserveAttributeBrackets:X};function rt(r){return{printWidth:r.printWidth,pugPrintWidth:r.pugPrintWidth===-1?r.printWidth:r.pugPrintWidth,singleQuote:r.singleQuote,pugSingleQuote:r.pugSingleQuote??r.singleQuote,tabWidth:r.tabWidth,pugTabWidth:r.pugTabWidth===-1?r.tabWidth:r.pugTabWidth,useTabs:r.useTabs??!1,pugUseTabs:r.pugUseTabs??r.useTabs??!1,bracketSpacing:r.bracketSpacing,pugBracketSpacing:r.pugBracketSpacing??r.bracketSpacing,arrowParens:r.arrowParens,pugArrowParens:r.pugArrowParens??r.arrowParens,semi:r.semi,pugSemi:r.pugSemi??r.semi,bracketSameLine:r.bracketSameLine,pugBracketSameLine:r.pugBracketSameLine??r.bracketSameLine,pugAttributeSeparator:r.pugAttributeSeparator,pugCommentPreserveSpaces:r.pugCommentPreserveSpaces,pugSortAttributes:r.pugSortAttributes,pugSortAttributesBeginning:r.pugSortAttributesBeginning,pugSortAttributesEnd:r.pugSortAttributesEnd,pugWrapAttributesThreshold:r.pugWrapAttributesThreshold,pugWrapAttributesPattern:r.pugWrapAttributesPattern,pugClassNotation:r.pugClassNotation,pugIdNotation:r.pugIdNotation,pugClassLocation:r.pugClassLocation,pugEmptyAttributes:r.pugEmptyAttributes,pugEmptyAttributesForceQuotes:r.pugEmptyAttributesForceQuotes,pugSingleFileComponentIndentation:r.pugSingleFileComponentIndentation&&r.__embeddedInHtml===!0,pugFramework:r.pugFramework,pugExplicitDiv:r.pugExplicitDiv,pugPreserveAttributeBrackets:r.pugPreserveAttributeBrackets,pugClosingBracketIndentDepth:r.pugClosingBracketIndentDepth??0}}import{types as Nt}from"node:util";import{format as f}from"prettier";var nt={"<!doctype html>":"doctype html",'<?xml version="1.0" encoding="utf-8" ?>':"doctype xml",'<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">':"doctype transitional",'<!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd">':"doctype strict",'<!doctype html public "-//w3c//dtd xhtml 1.0 frameset//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-frameset.dtd">':"doctype frameset",'<!doctype html public "-//w3c//dtd xhtml 1.1//en" "http://www.w3.org/tr/xhtml11/dtd/xhtml11.dtd">':"doctype 1.1",'<!doctype html public "-//w3c//dtd xhtml basic 1.1//en" "http://www.w3.org/tr/xhtml-basic/xhtml-basic11.dtd">':"doctype basic",'<!doctype html public "-//wapforum//dtd xhtml mobile 1.2//en" "http://www.openmobilealliance.org/tech/dtd/xhtml-mobile12.dtd">':"doctype mobile",'<!doctype plist public "-//apple//dtd plist 1.0//en" "http://www.apple.com/dtds/propertylist-1.0.dtd">':"doctype plist"};function st(r,t,e,i,n){let o=i.map(u=>new RegExp(u)).reverse(),s=n.map(u=>new RegExp(u)),a=r.name,l=t.name;if(o.length>0){let u=o.findIndex(d=>d.test(a)),h=o.findIndex(d=>d.test(l)),g=u-h;if(g>0)return-1;if(g<0)return 1}if(s.length>0){let u=s.findIndex(d=>d.test(a)),h=s.findIndex(d=>d.test(l)),g=u-h;if(g>0)return 1;if(g<0)return-1}switch(e){case"asc":{if(a>l)return 1;if(a<l)return-1;break}case"desc":{if(a>l)return-1;if(a<l)return 1;break}}return 0}function Et(r,t){let e=r.map((i,n)=>[i,n]);return e.sort((i,n)=>{let o=t(i[0],n[0]);return o===0?i[1]-n[1]:o}),e.map(([i])=>i)}function ot(r,t,e,i){let n=r.slice(0,t),o=r.slice(e),s=r.slice(t,e),a=Et(s,i);return[...n,...a,...o]}var _t=new Set([!0,'""',"''"]);function at(r,t,e){let{val:i,name:n}=r;if(e.map(a=>new RegExp(a)).some(a=>a.test(n))){r.val===!0&&(r.val='""');return}if(!(t==="as-is"||!_t.has(i)))switch(t){case"all":{r.val===!0&&(r.val='""');break}case"none":{(r.val==='""'||r.val==="''")&&(r.val=!0);break}}}function lt(r,t){for(let e=t-1;e>=0;e--){let i=r[e];if(!i)return;if(i.type==="tag")return i}}function pt(r,t){for(let e=t-1;e>0;e--){let i=r[e];if(!i||i.type==="start-attributes")return;if(i.type==="attribute"&&i.name!=="class"&&i.name!=="id")return i}}function ut(r,t){for(let e=t-1;e>0;e--){let i=r[e];if(!i||i.type==="start-attributes"||i.type==="tag")return;if(i.type==="attribute"&&i.name==="type")return i}}function T(r){return r.includes(` | ||
`}]};var H={category:p,type:"choice",default:"keep-all",description:"Change behavior of spaces within comments.",choices:[{value:"keep-all",description:"Keep all spaces within comments. Example: `// this is a comment`"},{value:"keep-leading",description:"Keep leading spaces within comments. Example: `// this is a comment`"},{value:"trim-all",description:"Trim all spaces within comments. Example: `// this is a comment`"}]};function A(r,t,i=!1){switch(t){case"keep-leading":{let e="",n=0;for(n;n<r.length&&r[n]===" ";n++)e+=" ";return e+=r.slice(n).trim().replaceAll(/\s\s+/g," "),e}case"trim-all":{let e=r.trim();return e=e.replaceAll(/\s\s+/g," "),!i&&r[0]===" "&&(e=` ${e}`),e}case"keep-all":default:return r}}var K={category:p,type:"boolean",default:!1,description:"Include `div` tag when followed by literal class or id syntax"};var J={category:p,type:"choice",default:"auto",description:"Define which framework is used in the project.",choices:[{value:"auto",description:"Try to identify used framework, if there is one."},{value:"vue",description:"Uses Vue.js."},{value:"svelte",description:"Uses Svelte."},{value:"angular",description:"Uses Angular."}]};var z={category:p,type:"choice",default:"literal",description:"Define how the id should be formatted.",choices:[{value:"literal",description:"Forces all valid ids to be printed as literals."},{value:"as-is",description:"Disables id formatting."}]};var X={category:p,type:"boolean",default:!1,description:"Preserve attribute brackets."};var Z={category:p,type:"boolean",default:!1,description:"Indent pug in template tags in single file components such as from vue or svelte."};var tt={category:p,type:"int",default:-1,description:"The maximum amount of attributes that an element can appear with on one line before it gets wrapped.",range:{start:-1,end:Number.POSITIVE_INFINITY,step:1}},et={category:p,type:"path",default:"",description:"Regex pattern to match attributes against that should always trigger wrapping."};var it={pugPrintWidth:N,pugSingleQuote:R,pugTabWidth:U,pugUseTabs:$,pugBracketSpacing:B,pugArrowParens:D,pugSemi:G,pugBracketSameLine:F,pugClosingBracketIndentDepth:q,pugAttributeSeparator:j,pugCommentPreserveSpaces:H,pugSortAttributes:C,pugSortAttributesBeginning:_,pugSortAttributesEnd:L,pugWrapAttributesThreshold:tt,pugWrapAttributesPattern:et,pugEmptyAttributes:W,pugClassNotation:Y,pugIdNotation:z,pugClassLocation:M,pugExplicitDiv:K,pugEmptyAttributesForceQuotes:Q,pugSingleFileComponentIndentation:Z,pugFramework:J,pugPreserveAttributeBrackets:X};function rt(r){return{printWidth:r.printWidth,pugPrintWidth:r.pugPrintWidth===-1?r.printWidth:r.pugPrintWidth,singleQuote:r.singleQuote,pugSingleQuote:r.pugSingleQuote??r.singleQuote,tabWidth:r.tabWidth,pugTabWidth:r.pugTabWidth===-1?r.tabWidth:r.pugTabWidth,useTabs:r.useTabs??!1,pugUseTabs:r.pugUseTabs??r.useTabs??!1,bracketSpacing:r.bracketSpacing,pugBracketSpacing:r.pugBracketSpacing??r.bracketSpacing,arrowParens:r.arrowParens,pugArrowParens:r.pugArrowParens??r.arrowParens,semi:r.semi,pugSemi:r.pugSemi??r.semi,bracketSameLine:r.bracketSameLine,pugBracketSameLine:r.pugBracketSameLine??r.bracketSameLine,pugAttributeSeparator:r.pugAttributeSeparator,pugCommentPreserveSpaces:r.pugCommentPreserveSpaces,pugSortAttributes:r.pugSortAttributes,pugSortAttributesBeginning:r.pugSortAttributesBeginning,pugSortAttributesEnd:r.pugSortAttributesEnd,pugWrapAttributesThreshold:r.pugWrapAttributesThreshold,pugWrapAttributesPattern:r.pugWrapAttributesPattern,pugClassNotation:r.pugClassNotation,pugIdNotation:r.pugIdNotation,pugClassLocation:r.pugClassLocation,pugEmptyAttributes:r.pugEmptyAttributes,pugEmptyAttributesForceQuotes:r.pugEmptyAttributesForceQuotes,pugSingleFileComponentIndentation:r.pugSingleFileComponentIndentation&&r.__embeddedInHtml===!0,pugFramework:r.pugFramework,pugExplicitDiv:r.pugExplicitDiv,pugPreserveAttributeBrackets:r.pugPreserveAttributeBrackets,pugClosingBracketIndentDepth:r.pugClosingBracketIndentDepth??0}}import{types as Ct}from"node:util";import{format as f}from"prettier";var nt={"<!doctype html>":"doctype html",'<?xml version="1.0" encoding="utf-8" ?>':"doctype xml",'<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">':"doctype transitional",'<!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd">':"doctype strict",'<!doctype html public "-//w3c//dtd xhtml 1.0 frameset//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-frameset.dtd">':"doctype frameset",'<!doctype html public "-//w3c//dtd xhtml 1.1//en" "http://www.w3.org/tr/xhtml11/dtd/xhtml11.dtd">':"doctype 1.1",'<!doctype html public "-//w3c//dtd xhtml basic 1.1//en" "http://www.w3.org/tr/xhtml-basic/xhtml-basic11.dtd">':"doctype basic",'<!doctype html public "-//wapforum//dtd xhtml mobile 1.2//en" "http://www.openmobilealliance.org/tech/dtd/xhtml-mobile12.dtd">':"doctype mobile",'<!doctype plist public "-//apple//dtd plist 1.0//en" "http://www.apple.com/dtds/propertylist-1.0.dtd">':"doctype plist"};function st(r,t,i,e,n){let o=e.map(g=>new RegExp(g)).reverse(),s=n.map(g=>new RegExp(g)),a=r.name,u=t.name;if(o.length>0){let g=o.findIndex(m=>m.test(a)),c=o.findIndex(m=>m.test(u)),h=g-c;if(h>0)return-1;if(h<0)return 1}if(s.length>0){let g=s.findIndex(m=>m.test(a)),c=s.findIndex(m=>m.test(u)),h=g-c;if(h>0)return 1;if(h<0)return-1}switch(i){case"asc":{if(a>u)return 1;if(a<u)return-1;break}case"desc":{if(a>u)return-1;if(a<u)return 1;break}}return 0}function wt(r,t){let i=r.map((e,n)=>[e,n]);return i.sort((e,n)=>{let o=t(e[0],n[0]);return o===0?e[1]-n[1]:o}),i.map(([e])=>e)}function ot(r,t,i,e){let n=r.slice(0,t),o=r.slice(i),s=r.slice(t,i),a=wt(s,e);return[...n,...a,...o]}var Et=new Set([!0,'""',"''"]);function at(r,t,i){let{val:e,name:n}=r;if(i.map(a=>new RegExp(a)).some(a=>a.test(n))){r.val===!0&&(r.val='""');return}if(!(t==="as-is"||!Et.has(e)))switch(t){case"all":{r.val===!0&&(r.val='""');break}case"none":{(r.val==='""'||r.val==="''")&&(r.val=!0);break}}}function lt(r,t){for(let i=t-1;i>=0;i--){let e=r[i];if(!e)return;if(e.type==="tag")return e}}function pt(r,t){for(let i=t-1;i>0;i--){let e=r[i];if(!e||e.type==="start-attributes")return;if(e.type==="attribute"&&e.name!=="class"&&e.name!=="id")return e}}function ut(r,t){for(let i=t-1;i>0;i--){let e=r[i];if(!e||e.type==="start-attributes"||e.type==="tag")return;if(e.type==="attribute"&&e.name==="type")return e}}function T(r){return r.includes(` | ||
`)?r.split(` | ||
`).map(t=>t.trim()).map(t=>(t[0]==="."?"":" ")+t).join("").trim():r}function ct(r,t){return r==="style"&&m(t)}function k(r,t,e,i=0){return r.startsWith(t,i)&&r.endsWith(e,r.length-i)}function m(r){return/^(["'`])(.*)\1$/.test(r)?!new RegExp(`${r[0]}(?<!\\\\${r[0]})`).test(r.slice(1,-1)):!1}function gt(r){return/^`[\S\s]*`$/.test(r)&&r.includes("${")}function ht(r){return/^`[\S\s]*`$/m.test(r)&&r.includes(` | ||
`)}function b(r,t,[e,i]=["{{","}}"]){return r?`${e} ${t} ${i}`:`${e}${t}${i}`}function S(r,t,e=!1){let i=t==='"'?"'":'"',n=r.replaceAll(/\\([\S\s])|(["'])/g,(o,s,a)=>s===i?s:a===t?`\\${a}`:a||(e&&/^[^\n\r"'0-7\\bfnrt-vx\u2028\u2029]$/.test(s)?s:`\\${s}`));return t+n+t}function w(r,t,e,i){let n=r.indexOf(t),o=r.indexOf(e),s=r.indexOf("`");return n>=0&&o>=0&&o>n&&(s<0||n<s)?(i.log({code:r,quotes:t,otherQuotes:e,q1:n,q2:o,qb:s}),!0):!1}function dt(){try{let r=Object.keys(process.env).filter(t=>t.startsWith("npm_package_")).filter(t=>/(dev)?[Dd]ependencies_+/.test(t));if(r.some(t=>t.includes("vue")&&!t.includes("vuepress")))return"vue";if(r.some(t=>t.includes("svelte")))return"svelte";if(r.some(t=>t.includes("angular")))return"angular"}catch{return"auto"}return"auto"}function mt(r){return r.length>=3&&r[0]==="["&&r.at(-1)==="]"}function ft(r){return r.length>=3&&r[0]==="("&&r.at(-1)===")"}function bt(r){return r.length>=2&&r[0]==="*"}function Tt(r){return r.length>=5&&m(r)&&k(r,"{{","}}",1)&&!r.includes("{{",3)}var Ot=/\+(json|yaml)$/i,Lt=/(^(["'`]))|((["'`])$)/g,Ct=new Map([["application/ecmascript","babel"],["application/javascript","babel"],["application/json","json"],["text/ecmascript","babel"],["text/javascript","babel"],["text/markdown","markdown"],["text/typescript","typescript"],["module","babel"]]);function yt(r){if(!r)return"babel";let t=r.val;if(typeof t!="string")return;let e=t.replaceAll(Lt,"");if(!e)return"babel";let i=Ot.exec(e);return i?i[1]:Ct.get(e)}function Pt(r){return r.length>=3&&m(r)&&k(r,"{","}",1)&&!r.includes("{",2)}function vt(r){return/^(v-on:|@).*/.test(r)}function kt(r){return/^((v-(bind|slot))?:|v-(model|slot|if|for|else-if|text|html|t)|#).*/.test(r)}function St(r,t){return r==="v-for"&&t.includes("of")}function At(r){return r==="v-bind"}function xt(r){return r==="v-on"}function wt(r){return r.startsWith("v-")}var A=class{constructor(t,e,i){this.content=t;this.tokens=e;this.options=i;this.indentString=i.pugUseTabs?" ":" ".repeat(i.pugTabWidth),i.pugSingleFileComponentIndentation&&this.indentLevel++,this.framework=i.pugFramework==="auto"?dt():i.pugFramework,this.quotes=this.options.pugSingleQuote?"'":'"',this.otherQuotes=this.options.pugSingleQuote?'"':"'";let n=j(i.pugAttributeSeparator);this.alwaysUseAttributeSeparator=n==="always",this.neverUseAttributeSeparator=n==="none";let o=i.pugWrapAttributesPattern;this.wrapAttributesPattern=o?new RegExp(o):null,this.codeInterpolationOptions={semi:i.pugSemi??i.semi,singleQuote:i.pugSingleQuote??i.singleQuote,bracketSpacing:i.pugBracketSpacing??i.bracketSpacing,arrowParens:i.pugArrowParens??i.arrowParens,printWidth:9e3,endOfLine:"lf",useTabs:i.pugUseTabs??i.useTabs,tabWidth:i.pugTabWidth??i.tabWidth,bracketSameLine:i.pugBracketSameLine??i.bracketSameLine}}result="";currentIndex=-1;currentLineLength=0;indentString;indentLevel=0;framework="auto";quotes;otherQuotes;alwaysUseAttributeSeparator;neverUseAttributeSeparator;wrapAttributesPattern;codeInterpolationOptions;currentTagPosition=0;possibleIdPosition=0;possibleClassPosition=0;previousAttributeRemapped=!1;wrapAttributes=!1;pipelessText=!1;pipelessComment=!1;currentlyInPugInterpolation=!1;classLiteralToAttribute=[];classLiteralAfterAttributes=[];get computedIndent(){var t;switch((t=this.previousToken)==null?void 0:t.type){case"newline":case"outdent":return this.indentString.repeat(this.indentLevel);case"indent":return this.indentString;case"start-pug-interpolation":return""}return this.options.pugSingleFileComponentIndentation?this.indentString:""}get previousToken(){return this.tokens[this.currentIndex-1]}get nextToken(){return this.tokens[this.currentIndex+1]}async build(){var i,n;p.isDebugEnabled()&&p.debug("[PugPrinter]:",JSON.stringify(this.tokens));let t=[];if(((i=this.tokens[0])==null?void 0:i.type)==="text")t.push("| ");else if(((n=this.tokens[0])==null?void 0:n.type)==="eos")return"";let e=this.getNextToken();for(;e;){p.debug("[PugPrinter]:",JSON.stringify(e));try{switch(e.type){case"attribute":case"class":case"end-attributes":case"id":case"eos":{this.result=t.join(""),await this[e.type](e),t.length=0,t.push(this.result);break}case"tag":case"start-attributes":case"interpolation":case"call":case":":this.result=t.join("");default:{if(typeof this[e.type]!="function")throw new Error("Unhandled token: "+JSON.stringify(e));t.push(await this[e.type](e));break}}}catch(o){throw new Error(o)}e=this.getNextToken()}return t.join("")}getNextToken(){return this.currentIndex++,this.tokens[this.currentIndex]??null}quoteString(t){return`${this.quotes}${t}${this.quotes}`}checkTokenType(t,e,i=!1){return!!t&&e.includes(t.type)!==i}tokenNeedsSeparator(t){return this.neverUseAttributeSeparator?!1:this.alwaysUseAttributeSeparator||/^([(:[]).*/.test(t.name)}getUnformattedContentLines(t,e){let{start:i}=t.loc,{end:n}=e.loc,o=this.content.split(/\r\n|\n|\r/),s=i.line-1,a=n.line-1,l=[],u=o[s];u!==void 0&&l.push(u.slice(i.column-1));for(let g=s+1;g<a;g++){let d=o[g];d!==void 0&&l.push(d)}let h=o[a];return h!==void 0&&l.push(h.slice(0,n.column-1)),l}replaceTagWithLiteralIfPossible(t,e){if(this.options.pugExplicitDiv)return;let i=Math.max(this.possibleIdPosition,this.possibleClassPosition),n=this.result.slice(this.currentTagPosition,i),o=n.replace(t,e);if(o!==n){let s=this.result.slice(0,this.currentTagPosition),a=this.result.slice(i);this.result=`${s}${o}${a}`;let l=n.length-o.length;this.possibleIdPosition-=l,this.possibleClassPosition-=l}}async frameworkFormat(t){let e={...this.codeInterpolationOptions,singleQuote:this.options.singleQuote};switch(this.framework){case"angular":{e.parser="__ng_interpolation";break}case"svelte":case"vue":default:e.parser="babel",e.semi=!1}let i=await f(t,e);return i[0]===";"&&(i=i.slice(1)),i}async formatText(t){let e="";for(;t;){let i=t.indexOf("{{");if(i===-1){let n=t.indexOf("{");if(this.options.pugFramework==="svelte"&&n!==-1){e+=t.slice(0,n),t=t.slice(n+1);let o=t.indexOf("}");if(o===-1)e+="{",e+=t,t="";else{let s=t.slice(0,o);try{if(w(s,this.quotes,this.otherQuotes,p)){p.warn("The following expression could not be formatted correctly. Please try to fix it yourself and if there is a problem, please open a bug issue:",s),e+=b(this.options.pugBracketSpacing,s),t=t.slice(o+1);continue}else s=await this.frameworkFormat(s)}catch(a){p.warn("[PugPrinter:formatText]: ",a);try{s=await f(s,{parser:"babel",...this.codeInterpolationOptions,semi:!1}),s[0]===";"&&(s=s.slice(1))}catch(l){p.warn(l)}}s=T(s),e+=b(this.options.pugBracketSpacing,s,["{","}"]),t=t.slice(o+1)}}else e+=t,t=""}else{e+=t.slice(0,i),t=t.slice(i+2);let n=t.indexOf("}}");if(n===-1)e+="{{",e+=t,t="";else{let o=t.slice(0,n);try{if(w(o,this.quotes,this.otherQuotes,p)){p.warn("The following expression could not be formatted correctly. Please try to fix it yourself and if there is a problem, please open a bug issue:",o),e+=b(this.options.pugBracketSpacing,o),t=t.slice(n+2);continue}else o=await this.frameworkFormat(o)}catch(s){typeof s=="string"?s.includes("Unexpected token Lexer Error")?s.includes("Unexpected character [`]")||p.debug("[PugPrinter:formatText]: Using fallback strategy"):s.includes("Bindings cannot contain assignments")?p.warn("[PugPrinter:formatText]: Bindings should not contain assignments:",`code: \`${o.trim()}\``):s.includes("Unexpected token '('")?this.framework!=="vue"&&p.warn("[PugPrinter:formatText]: Found unexpected token `(`.",`code: \`${o.trim()}\``):s.includes("Missing expected `)`")?this.framework!=="vue"&&p.warn("[PugPrinter:formatText]: Missing expected `)`.",`code: \`${o.trim()}\``):s.includes("Missing expected `:`")?this.framework!=="vue"&&p.warn("[PugPrinter:formatText]: Missing expected `:`.",`code: \`${o.trim()}\``):p.warn("[PugPrinter:formatText]: ",s):p.warn("[PugPrinter:formatText]: ",s);try{o=await f(o,{parser:"babel",...this.codeInterpolationOptions,semi:!1}),o[0]===";"&&(o=o.slice(1))}catch(a){p.warn(a)}}o=T(o),e+=b(this.options.pugBracketSpacing,o),t=t.slice(n+2)}}}return e}async formatDelegatePrettier(t,e,i={}){let{trimTrailingSemicolon:n=!1,trimLeadingSemicolon:o=!0}=i;t=t.trim();let s={...this.codeInterpolationOptions},a=m(t);return a&&(s.singleQuote=!this.options.pugSingleQuote,t=t.slice(1,-1)),t=await f(t,{parser:e,...s}),t=this.quotes==='"'?t.replaceAll('"','\\"'):t.replaceAll("'","\\'"),t=T(t),n&&t.at(-1)===";"&&(t=t.slice(0,-1)),o&&t[0]===";"&&(t=t.slice(1)),a?this.quoteString(t):t}async formatStyleAttribute(t){return this.formatDelegatePrettier(t,"css",{trimTrailingSemicolon:!0})}async formatVueEventBinding(t){return this.formatDelegatePrettier(t,"__vue_event_binding",{trimTrailingSemicolon:!0})}async formatVueExpression(t){return this.formatDelegatePrettier(t,"__vue_expression")}async formatAngularBinding(t){return this.formatDelegatePrettier(t,"__ng_binding")}async formatAngularAction(t){return this.formatDelegatePrettier(t,"__ng_action")}async formatAngularDirective(t){return this.formatDelegatePrettier(t,"__ng_directive")}async formatFrameworkInterpolation(t,e,[i,n]){if(t=t.slice(1,-1),t=t.slice(i.length,-n.length),t=t.trim(),t.includes(`\\${this.otherQuotes}`))p.warn("The following expression could not be formatted correctly. Please try to fix it yourself and if there is a problem, please open a bug issue:",t);else{let o={...this.codeInterpolationOptions,singleQuote:!this.options.pugSingleQuote};try{t=await f(t,{parser:e,...o})}catch{p.warn("The following expression could not be formatted correctly. Please try to fix it yourself and if there is a problem, please open a bug issue:",t)}t=T(t)}return t=b(this.options.pugBracketSpacing,t,[i,n]),this.quoteString(t)}async formatAngularInterpolation(t){return this.formatFrameworkInterpolation(t,"__ng_interpolation",["{{","}}"])}async formatSvelteInterpolation(t){return this.formatFrameworkInterpolation(t,"__ng_interpolation",["{","}"])}tag(t){let e=t.val;e==="div"&&!this.options.pugExplicitDiv&&this.nextToken&&(this.nextToken.type==="class"&&this.options.pugClassLocation==="before-attributes"||this.nextToken.type==="id")&&(e=""),this.currentLineLength+=e.length;let i=`${this.computedIndent}${e}`;return p.debug("tag",{result:i,val:t.val,length:t.val.length},this.currentLineLength),this.currentTagPosition=this.result.length+this.computedIndent.length,this.possibleIdPosition=this.result.length+i.length,this.possibleClassPosition=this.result.length+i.length,i}"start-attributes"(t){var i,n,o;let e="";if(((i=this.nextToken)==null?void 0:i.type)==="attribute"){this.previousAttributeRemapped=!1,this.possibleClassPosition=this.result.length,e="(",p.debug(this.currentLineLength);let s=this.nextToken,a=this.currentIndex+1,l=!1,u=0;for(;s.type==="attribute";){switch(!this.currentlyInPugInterpolation&&!this.wrapAttributes&&((n=this.wrapAttributesPattern)!=null&&n.test(s.name))&&(this.wrapAttributes=!0),s.name){case"class":case"id":{(s.name==="class"&&this.options.pugClassNotation!=="literal"||s.name==="id"&&this.options.pugIdNotation!=="literal")&&u++,l=!0;let h=s.val.toString();m(h)&&(this.currentLineLength-=2),this.currentLineLength+=1+h.length,p.debug({tokenName:s.name,length:s.name.length},this.currentLineLength);break}default:{this.currentLineLength+=s.name.length,u>0&&(this.currentLineLength+=1,this.tokenNeedsSeparator(s)&&(this.currentLineLength+=1)),p.debug({tokenName:s.name,length:s.name.length},this.currentLineLength);let h=s.val.toString();h.length>0&&h!=="true"&&(this.currentLineLength+=1+h.length,p.debug({tokenVal:h,length:h.length},this.currentLineLength)),u++;break}}s=this.tokens[++a]}if(p.debug("after token",this.currentLineLength),l&&((o=this.previousToken)==null?void 0:o.type)==="tag"&&this.previousToken.val==="div"&&!this.options.pugExplicitDiv&&(this.currentLineLength-=3),u>0&&(this.currentLineLength+=2),this.options.pugClassLocation==="after-attributes"){let h=a,g=this.tokens[++h];for(;g.type==="class";){let d=g.val.toString();this.currentLineLength+=1+d.length,p.debug({tokenVal:d,length:d.length},this.currentLineLength),g=this.tokens[++h]}}if(p.debug("final line length",{currentLineLength:this.currentLineLength}),!this.currentlyInPugInterpolation&&!this.wrapAttributes&&(this.currentLineLength>this.options.pugPrintWidth||this.options.pugWrapAttributesThreshold>=0&&u>this.options.pugWrapAttributesThreshold)&&(this.wrapAttributes=!0),this.options.pugSortAttributes!=="as-is"||this.options.pugSortAttributesEnd.length>0||this.options.pugSortAttributesBeginning.length>0){let h=this.tokens.indexOf(t),g=a;g-h>2&&(this.tokens=ot(this.tokens,h+1,g,(d,It)=>st(d,It,this.options.pugSortAttributes,this.options.pugSortAttributesBeginning,this.options.pugSortAttributesEnd)))}}return e}async attribute(t){var i;if(at(t,this.options.pugEmptyAttributes,this.options.pugEmptyAttributesForceQuotes),typeof t.val=="string"&&m(t.val)&&t.val[0]!=="`"){if(t.name==="class"&&this.options.pugClassNotation==="literal"){let o=t.val.slice(1,-1).trim().split(/\s+/),s=[],a=[],l=/^-?[A-Z_a-z]+[\w-]*$/;for(let u of o)l.test(u)?this.options.pugClassLocation==="after-attributes"?this.classLiteralAfterAttributes.push(u):a.push(u):s.push(u);if(a.length>0){let u=this.possibleClassPosition;this.result=[this.result.slice(0,u),".",a.join("."),this.result.slice(u)].join(""),this.possibleClassPosition+=1+a.join(".").length,this.options.pugClassLocation==="before-attributes"&&this.replaceTagWithLiteralIfPossible(/div\./,".")}if(s.length>0)t.val=S(s.join(" "),this.quotes),this.previousAttributeRemapped=!1;else{this.previousAttributeRemapped=!0;return}}else if(t.name==="id"&&this.options.pugIdNotation!=="as-is"){let n=t.val;if(n=n.slice(1,-1),n=n.trim(),!/^-?[A-Z_a-z]+[\w-]*$/.test(n)){n=S(n,this.quotes),this.result+="id",t.mustEscape===!1&&(this.result+="!"),this.result+=`=${n}`;return}let s=this.possibleIdPosition,a=`#${n}`;this.result=[this.result.slice(0,s),a,this.result.slice(s)].join(""),this.possibleClassPosition+=a.length,this.replaceTagWithLiteralIfPossible(/div#/,"#"),this.previousAttributeRemapped=!0;return}}let e=pt(this.tokens,this.currentIndex);if(((i=this.previousToken)==null?void 0:i.type)==="attribute"&&(!this.previousAttributeRemapped||e)&&(this.tokenNeedsSeparator(t)&&(this.result+=","),this.wrapAttributes||(this.result+=" ")),this.previousAttributeRemapped=!1,this.wrapAttributes&&(this.result+=` | ||
`,this.result+=this.indentString.repeat(this.indentLevel+1)),this.result+=`${t.name}`,typeof t.val=="boolean")t.val!==!0&&(this.result+=`=${t.val}`);else if(t.name==="class"&&this.options.pugClassNotation==="attribute"){let o=(m(t.val)?t.val.slice(1,-1).trim():t.val).split(/\s+/);if(this.classLiteralToAttribute.length>0)for(let s=this.classLiteralToAttribute.length-1;s>-1;s--){let a=this.classLiteralToAttribute.splice(s,1)[0];a&&o.unshift(a)}this.result+=`=${m(t.val)?this.quoteString(o.join(" ")):o.join(" ")}`}else{let n=t.val;if(!ht(n)){if(!gt(n))if(St(t.name,n))n=await this.formatDelegatePrettier(n,"vue");else if(kt(t.name))n=await this.formatVueExpression(n);else if(vt(t.name))n=await this.formatVueEventBinding(n);else if(this.framework==="vue"&&wt(t.name))n=await this.formatVueExpression(n);else if(At(t.name))n=await this.formatDelegatePrettier(n,"__js_expression");else if(xt(t.name))n=await this.formatDelegatePrettier(n,"__js_expression");else if(mt(t.name))n=await this.formatAngularBinding(n);else if(ft(t.name))n=await this.formatAngularAction(n);else if(bt(t.name))n=await this.formatAngularDirective(n);else if(Tt(n))n=await this.formatAngularInterpolation(n);else if(Pt(n))n=await this.formatSvelteInterpolation(n);else if(ct(t.name,t.val))n=await this.formatStyleAttribute(n);else{let o=n.trimEnd();if(m(o))n=S(o.slice(1,-1),this.quotes);else{if(n==="true")return;if(t.mustEscape){n=await f(n,{parser:"__js_expression",...this.codeInterpolationOptions});let s=n.split(` | ||
`),a=this.wrapAttributes?this.indentLevel+1:this.indentLevel;if(s.length>1){n=s[0]??"";for(let l=1;l<s.length;l++)n+=` | ||
`,n+=this.indentString.repeat(a),n+=s[l]}}else n=n.trim(),n=n.replaceAll(/\s\s+/g," "),n[0]==="{"&&n[1]===" "&&(n=`{${n.slice(2)}`)}}}t.mustEscape===!1&&(this.result+="!"),this.result+=`=${n}`}}"end-attributes"(t){var e,i,n,o,s,a,l;if(this.wrapAttributes&&this.result.at(-1)!=="("&&(this.options.pugBracketSameLine||(this.result+=` | ||
`),this.result+=this.indentString.repeat(this.indentLevel+this.options.pugClosingBracketIndentDepth)),this.wrapAttributes=!1,this.classLiteralToAttribute.length>0){((e=this.previousToken)==null?void 0:e.type)==="start-attributes"?this.result+="(":((i=this.previousToken)==null?void 0:i.type)==="attribute"&&(this.result+=" ");let u=this.classLiteralToAttribute.splice(0,this.classLiteralToAttribute.length);this.result+=`class=${this.quoteString(u.join(" "))}`,((n=this.previousToken)==null?void 0:n.type)==="start-attributes"&&(this.result+=")")}if(this.result.at(-1)==="("?this.result=this.result.slice(0,-1):((o=this.previousToken)==null?void 0:o.type)==="attribute"?(this.options.pugBracketSameLine&&(this.result=this.result.trimEnd()),this.result+=")"):this.options.pugPreserveAttributeBrackets&&((s=this.previousToken)==null?void 0:s.type)==="start-attributes"&&(this.result+="()"),this.result.at(-1)===")"&&this.classLiteralAfterAttributes.length>0){let u=this.classLiteralAfterAttributes.splice(0,this.classLiteralAfterAttributes.length);this.result+=`.${u.join(".")}`}this.options.pugClassLocation==="after-attributes"&&(this.possibleClassPosition=this.result.length),(((a=this.nextToken)==null?void 0:a.type)==="text"||((l=this.nextToken)==null?void 0:l.type)==="path")&&(this.result+=" ")}indent(t){let e=` | ||
${this.indentString.repeat(this.indentLevel)}`;return this.indentLevel++,this.currentLineLength=e.length-1+1+this.options.pugTabWidth,p.debug("indent",{result:e,indentLevel:this.indentLevel,pugTabWidth:this.options.pugTabWidth},this.currentLineLength),e}outdent(t){let e="";return this.previousToken&&this.previousToken.type!=="outdent"&&(t.loc.start.line-this.previousToken.loc.end.line>1&&(e+=` | ||
`),e+=` | ||
`),this.indentLevel--,this.currentLineLength=1+this.indentString.repeat(this.indentLevel).length,p.debug("outdent",{result:e,indentLevel:this.indentLevel},this.currentLineLength),e}class(t){var e,i,n,o,s;if(this.options.pugClassNotation==="attribute"){if(this.classLiteralToAttribute.push(t.val),((e=this.previousToken)==null?void 0:e.type)!=="tag"&&((i=this.previousToken)==null?void 0:i.type)!=="class"&&(this.result+=`${this.computedIndent}div`),this.nextToken&&["text","newline","indent","outdent","eos"].includes(this.nextToken.type)){let a=this.classLiteralToAttribute.splice(0,this.classLiteralToAttribute.length);this.result+=`(class=${this.quoteString(a.join(" "))})`,this.nextToken.type==="text"&&(this.result+=" ")}}else{let a=`.${t.val}`;switch(this.currentLineLength+=a.length,p.debug("before class",{result:this.result,val:a,length:a.length,previousToken:this.previousToken},this.currentLineLength),(n=this.previousToken)==null?void 0:n.type){case void 0:case"newline":case"outdent":case"indent":{let l=this.options.pugExplicitDiv||this.options.pugClassLocation==="after-attributes"?"div":"",u=`${this.computedIndent}${l}`;this.options.pugClassLocation==="after-attributes"?this.classLiteralAfterAttributes.push(a.slice(1)):u+=a,this.currentLineLength+=l.length,this.possibleIdPosition=this.result.length+this.computedIndent.length+l.length,this.result+=u,this.possibleClassPosition=this.result.length;break}case"end-attributes":{let l=this.result.slice(0,this.possibleClassPosition);this.result=[l,a,this.result.slice(this.possibleClassPosition)].join(""),this.possibleClassPosition+=a.length;break}default:{if(this.options.pugClassLocation==="after-attributes")this.classLiteralAfterAttributes.push(a.slice(1));else{let l=this.result.slice(0,this.possibleClassPosition);this.result=[l,a,this.result.slice(this.possibleClassPosition)].join(""),this.possibleClassPosition+=a.length}break}}if(this.options.pugClassLocation==="after-attributes"&&this.classLiteralAfterAttributes.length>0){let l=this.result.slice(0,this.possibleClassPosition);if(["text","newline","indent","outdent","eos","code",":",void 0].includes((o=this.nextToken)==null?void 0:o.type)){let u=this.classLiteralAfterAttributes.splice(0,this.classLiteralAfterAttributes.length);l+="."+u.join(".")}this.result=[l,this.result.slice(this.possibleClassPosition)].join(""),this.possibleClassPosition=this.result.length,this.replaceTagWithLiteralIfPossible(/div\./,".")}p.debug("after class",{result:this.result,val:a,length:a.length},this.currentLineLength),((s=this.nextToken)==null?void 0:s.type)==="text"&&!/^\s+$/.test(this.nextToken.val)&&(this.currentLineLength+=1,this.result+=" ")}}eos(t){for(;this.result.at(-1)===` | ||
`).map(t=>t.trim()).map(t=>(t[0]==="."?"":" ")+t).join("").trim():r}function ct(r,t){return r==="style"&&d(t)}function k(r,t,i,e=0){return r.startsWith(t,e)&&r.endsWith(i,r.length-e)}function d(r){return/^(["'`])(.*)\1$/.test(r)?!new RegExp(`${r[0]}(?<!\\\\${r[0]})`).test(r.slice(1,-1)):!1}function gt(r){return/^`[\S\s]*`$/.test(r)&&r.includes("${")}function ht(r){return/^`[\S\s]*`$/m.test(r)&&r.includes(` | ||
`)}function b(r,t,[i,e]=["{{","}}"]){return r?`${i} ${t} ${e}`:`${i}${t}${e}`}function S(r,t,i=!1){let e=t==='"'?"'":'"',n=r.replaceAll(/\\([\S\s])|(["'])/g,(o,s,a)=>s===e?s:a===t?`\\${a}`:a||(i&&/^[^\n\r"'0-7\\bfnrt-vx\u2028\u2029]$/.test(s)?s:`\\${s}`));return t+n+t}function I(r,t,i,e){let n=r.indexOf(t),o=r.indexOf(i),s=r.indexOf("`");return n>=0&&o>=0&&o>n&&(s<0||n<s)?(e.log({code:r,quotes:t,otherQuotes:i,q1:n,q2:o,qb:s}),!0):!1}function dt(){try{let r=Object.keys(process.env).filter(t=>t.startsWith("npm_package_")).filter(t=>/(dev)?[Dd]ependencies_+/.test(t));if(r.some(t=>t.includes("vue")&&!t.includes("vuepress")))return"vue";if(r.some(t=>t.includes("svelte")))return"svelte";if(r.some(t=>t.includes("angular")))return"angular"}catch{return"auto"}return"auto"}function mt(r){return r.length>=3&&r[0]==="["&&r.at(-1)==="]"}function ft(r){return r.length>=3&&r[0]==="("&&r.at(-1)===")"}function bt(r){return r.length>=2&&r[0]==="*"}function Tt(r){return r.length>=5&&d(r)&&k(r,"{{","}}",1)&&!r.includes("{{",3)}var Ot=/\+(json|yaml)$/i,_t=/(^(["'`]))|((["'`])$)/g,Lt=new Map([["application/ecmascript","babel"],["application/javascript","babel"],["application/json","json"],["text/ecmascript","babel"],["text/javascript","babel"],["text/markdown","markdown"],["text/typescript","typescript"],["module","babel"]]);function yt(r){if(!r)return"babel";let t=r.val;if(typeof t!="string")return;let i=t.replaceAll(_t,"");if(!i)return"babel";let e=Ot.exec(i);return e?e[1]:Lt.get(i)}function Pt(r){return r.length>=3&&d(r)&&k(r,"{","}",1)&&!r.includes("{",2)}function vt(r){return/^(v-on:|@).*/.test(r)}function kt(r){return/^((v-(bind|slot))?:|v-(model|slot|if|for|else-if|text|html|t)|#).*/.test(r)}function St(r,t){return r==="v-for"&&t.includes("of")}function xt(r){return r==="v-bind"}function At(r){return r==="v-on"}function It(r){return r.startsWith("v-")}var x=class{constructor(t,i,e){this.content=t;this.tokens=i;this.options=e;this.indentString=e.pugUseTabs?" ":" ".repeat(e.pugTabWidth),e.pugSingleFileComponentIndentation&&this.indentLevel++,this.framework=e.pugFramework==="auto"?dt():e.pugFramework,this.quotes=this.options.pugSingleQuote?"'":'"',this.otherQuotes=this.options.pugSingleQuote?'"':"'";let n=V(e.pugAttributeSeparator);this.alwaysUseAttributeSeparator=n==="always",this.neverUseAttributeSeparator=n==="none";let o=e.pugWrapAttributesPattern;this.wrapAttributesPattern=o?new RegExp(o):null,this.codeInterpolationOptions={semi:e.pugSemi??e.semi,singleQuote:e.pugSingleQuote??e.singleQuote,bracketSpacing:e.pugBracketSpacing??e.bracketSpacing,arrowParens:e.pugArrowParens??e.arrowParens,printWidth:9e3,endOfLine:"lf",useTabs:e.pugUseTabs??e.useTabs,tabWidth:e.pugTabWidth??e.tabWidth,bracketSameLine:e.pugBracketSameLine??e.bracketSameLine}}result="";currentIndex=-1;currentLineLength=0;indentString;indentLevel=0;framework="auto";quotes;otherQuotes;alwaysUseAttributeSeparator;neverUseAttributeSeparator;wrapAttributesPattern;codeInterpolationOptions;currentTagPosition=0;possibleIdPosition=0;possibleClassPosition=0;previousAttributeRemapped=!1;wrapAttributes=!1;pipelessText=!1;pipelessComment=!1;currentlyInPugInterpolation=!1;classLiteralToAttribute=[];classLiteralAfterAttributes=[];get computedIndent(){switch(this.previousToken?.type){case"newline":case"outdent":return this.indentString.repeat(this.indentLevel);case"indent":return this.indentString;case"start-pug-interpolation":return""}return this.options.pugSingleFileComponentIndentation?this.indentString:""}get previousToken(){return this.tokens[this.currentIndex-1]}get nextToken(){return this.tokens[this.currentIndex+1]}async build(){l.isDebugEnabled()&&l.debug("[PugPrinter]:",JSON.stringify(this.tokens));let t=[];if(this.tokens[0]?.type==="text")t.push("| ");else if(this.tokens[0]?.type==="eos")return"";let i=this.getNextToken();for(;i;){l.debug("[PugPrinter]:",JSON.stringify(i));try{switch(i.type){case"attribute":case"class":case"end-attributes":case"id":case"eos":{this.result=t.join(""),await this[i.type](i),t.length=0,t.push(this.result);break}case"tag":case"start-attributes":case"interpolation":case"call":case":":this.result=t.join("");default:{if(typeof this[i.type]!="function")throw new Error("Unhandled token: "+JSON.stringify(i));t.push(await this[i.type](i));break}}}catch(e){throw new Error(e)}i=this.getNextToken()}return t.join("")}getNextToken(){return this.currentIndex++,this.tokens[this.currentIndex]??null}quoteString(t){return`${this.quotes}${t}${this.quotes}`}checkTokenType(t,i,e=!1){return!!t&&i.includes(t.type)!==e}tokenNeedsSeparator(t){return this.neverUseAttributeSeparator?!1:this.alwaysUseAttributeSeparator||/^([(:[]).*/.test(t.name)}getUnformattedContentLines(t,i){let{start:e}=t.loc,{end:n}=i.loc,o=this.content.split(/\r\n|\n|\r/),s=e.line-1,a=n.line-1,u=[],g=o[s];g!==void 0&&u.push(g.slice(e.column-1));for(let h=s+1;h<a;h++){let m=o[h];m!==void 0&&u.push(m)}let c=o[a];return c!==void 0&&u.push(c.slice(0,n.column-1)),u}replaceTagWithLiteralIfPossible(t,i){if(this.options.pugExplicitDiv)return;let e=Math.max(this.possibleIdPosition,this.possibleClassPosition),n=this.result.slice(this.currentTagPosition,e),o=n.replace(t,i);if(o!==n){let s=this.result.slice(0,this.currentTagPosition),a=this.result.slice(e);this.result=`${s}${o}${a}`;let u=n.length-o.length;this.possibleIdPosition-=u,this.possibleClassPosition-=u}}async frameworkFormat(t){let i={...this.codeInterpolationOptions,singleQuote:this.options.singleQuote};switch(this.framework){case"angular":{i.parser="__ng_interpolation";break}case"svelte":case"vue":default:i.parser="babel",i.semi=!1}let e=await f(t,i);return e[0]===";"&&(e=e.slice(1)),e}async formatText(t){let i="";for(;t;){let e=t.indexOf("{{");if(e===-1){let n=t.indexOf("{");if(this.options.pugFramework==="svelte"&&n!==-1){i+=t.slice(0,n),t=t.slice(n+1);let o=t.indexOf("}");if(o===-1)i+="{",i+=t,t="";else{let s=t.slice(0,o);try{if(I(s,this.quotes,this.otherQuotes,l)){l.warn("The following expression could not be formatted correctly. Please try to fix it yourself and if there is a problem, please open a bug issue:",s),i+=b(this.options.pugBracketSpacing,s),t=t.slice(o+1);continue}else s=await this.frameworkFormat(s)}catch(a){l.warn("[PugPrinter:formatText]: ",a);try{s=await f(s,{parser:"babel",...this.codeInterpolationOptions,semi:!1}),s[0]===";"&&(s=s.slice(1))}catch(u){l.warn(u)}}s=T(s),i+=b(this.options.pugBracketSpacing,s,["{","}"]),t=t.slice(o+1)}}else i+=t,t=""}else{i+=t.slice(0,e),t=t.slice(e+2);let n=t.indexOf("}}");if(n===-1)i+="{{",i+=t,t="";else{let o=t.slice(0,n);try{if(I(o,this.quotes,this.otherQuotes,l)){l.warn("The following expression could not be formatted correctly. Please try to fix it yourself and if there is a problem, please open a bug issue:",o),i+=b(this.options.pugBracketSpacing,o),t=t.slice(n+2);continue}else o=await this.frameworkFormat(o)}catch(s){typeof s=="string"?s.includes("Unexpected token Lexer Error")?s.includes("Unexpected character [`]")||l.debug("[PugPrinter:formatText]: Using fallback strategy"):s.includes("Bindings cannot contain assignments")?l.warn("[PugPrinter:formatText]: Bindings should not contain assignments:",`code: \`${o.trim()}\``):s.includes("Unexpected token '('")?this.framework!=="vue"&&l.warn("[PugPrinter:formatText]: Found unexpected token `(`.",`code: \`${o.trim()}\``):s.includes("Missing expected `)`")?this.framework!=="vue"&&l.warn("[PugPrinter:formatText]: Missing expected `)`.",`code: \`${o.trim()}\``):s.includes("Missing expected `:`")?this.framework!=="vue"&&l.warn("[PugPrinter:formatText]: Missing expected `:`.",`code: \`${o.trim()}\``):l.warn("[PugPrinter:formatText]: ",s):l.warn("[PugPrinter:formatText]: ",s);try{o=await f(o,{parser:"babel",...this.codeInterpolationOptions,semi:!1}),o[0]===";"&&(o=o.slice(1))}catch(a){l.warn(a)}}o=T(o),i+=b(this.options.pugBracketSpacing,o),t=t.slice(n+2)}}}return i}async formatDelegatePrettier(t,i,e={}){let{trimTrailingSemicolon:n=!1,trimLeadingSemicolon:o=!0}=e;t=t.trim();let s={...this.codeInterpolationOptions},a=d(t);return a&&(s.singleQuote=!this.options.pugSingleQuote,t=t.slice(1,-1)),t=await f(t,{parser:i,...s}),t=this.quotes==='"'?t.replaceAll('"','\\"'):t.replaceAll("'","\\'"),t=T(t),n&&t.at(-1)===";"&&(t=t.slice(0,-1)),o&&t[0]===";"&&(t=t.slice(1)),a?this.quoteString(t):t}async formatStyleAttribute(t){return this.formatDelegatePrettier(t,"css",{trimTrailingSemicolon:!0})}async formatVueEventBinding(t){return this.formatDelegatePrettier(t,"__vue_event_binding",{trimTrailingSemicolon:!0})}async formatVueExpression(t){return this.formatDelegatePrettier(t,"__vue_expression")}async formatAngularBinding(t){return this.formatDelegatePrettier(t,"__ng_binding")}async formatAngularAction(t){return this.formatDelegatePrettier(t,"__ng_action")}async formatAngularDirective(t){return this.formatDelegatePrettier(t,"__ng_directive")}async formatFrameworkInterpolation(t,i,[e,n]){if(t=t.slice(1,-1),t=t.slice(e.length,-n.length),t=t.trim(),t.includes(`\\${this.otherQuotes}`))l.warn("The following expression could not be formatted correctly. Please try to fix it yourself and if there is a problem, please open a bug issue:",t);else{let o={...this.codeInterpolationOptions,singleQuote:!this.options.pugSingleQuote};try{t=await f(t,{parser:i,...o})}catch{l.warn("The following expression could not be formatted correctly. Please try to fix it yourself and if there is a problem, please open a bug issue:",t)}t=T(t)}return t=b(this.options.pugBracketSpacing,t,[e,n]),this.quoteString(t)}async formatAngularInterpolation(t){return this.formatFrameworkInterpolation(t,"__ng_interpolation",["{{","}}"])}async formatSvelteInterpolation(t){return this.formatFrameworkInterpolation(t,"__ng_interpolation",["{","}"])}tag(t){let i=t.val;i==="div"&&!this.options.pugExplicitDiv&&this.nextToken&&(this.nextToken.type==="class"&&this.options.pugClassLocation==="before-attributes"||this.nextToken.type==="id")&&(i=""),this.currentLineLength+=i.length;let e=`${this.computedIndent}${i}`;return l.debug("tag",{result:e,val:t.val,length:t.val.length},this.currentLineLength),this.currentTagPosition=this.result.length+this.computedIndent.length,this.possibleIdPosition=this.result.length+e.length,this.possibleClassPosition=this.result.length+e.length,e}"start-attributes"(t){let i="";if(this.nextToken?.type==="attribute"){this.previousAttributeRemapped=!1,this.possibleClassPosition=this.result.length,i="(",l.debug(this.currentLineLength);let e=this.nextToken,n=this.currentIndex+1,o=!1,s=0;for(;e.type==="attribute";){switch(!this.currentlyInPugInterpolation&&!this.wrapAttributes&&this.wrapAttributesPattern?.test(e.name)&&(this.wrapAttributes=!0),e.name){case"class":case"id":{(e.name==="class"&&this.options.pugClassNotation!=="literal"||e.name==="id"&&this.options.pugIdNotation!=="literal")&&s++,o=!0;let a=e.val.toString();d(a)&&(this.currentLineLength-=2),this.currentLineLength+=1+a.length,l.debug({tokenName:e.name,length:e.name.length},this.currentLineLength);break}default:{this.currentLineLength+=e.name.length,s>0&&(this.currentLineLength+=1,this.tokenNeedsSeparator(e)&&(this.currentLineLength+=1)),l.debug({tokenName:e.name,length:e.name.length},this.currentLineLength);let a=e.val.toString();a.length>0&&a!=="true"&&(this.currentLineLength+=1+a.length,l.debug({tokenVal:a,length:a.length},this.currentLineLength)),s++;break}}e=this.tokens[++n]}if(l.debug("after token",this.currentLineLength),o&&this.previousToken?.type==="tag"&&this.previousToken.val==="div"&&!this.options.pugExplicitDiv&&(this.currentLineLength-=3),s>0&&(this.currentLineLength+=2),this.options.pugClassLocation==="after-attributes"){let a=n,u=this.tokens[++a];for(;u.type==="class";){let g=u.val.toString();this.currentLineLength+=1+g.length,l.debug({tokenVal:g,length:g.length},this.currentLineLength),u=this.tokens[++a]}}if(l.debug("final line length",{currentLineLength:this.currentLineLength}),!this.currentlyInPugInterpolation&&!this.wrapAttributes&&(this.currentLineLength>this.options.pugPrintWidth||this.options.pugWrapAttributesThreshold>=0&&s>this.options.pugWrapAttributesThreshold)&&(this.wrapAttributes=!0),this.options.pugSortAttributes!=="as-is"||this.options.pugSortAttributesEnd.length>0||this.options.pugSortAttributesBeginning.length>0){let a=this.tokens.indexOf(t),u=n;u-a>2&&(this.tokens=ot(this.tokens,a+1,u,(g,c)=>st(g,c,this.options.pugSortAttributes,this.options.pugSortAttributesBeginning,this.options.pugSortAttributesEnd)))}}return i}async attribute(t){if(at(t,this.options.pugEmptyAttributes,this.options.pugEmptyAttributesForceQuotes),typeof t.val=="string"&&d(t.val)&&t.val[0]!=="`"){if(t.name==="class"&&this.options.pugClassNotation==="literal"){let n=t.val.slice(1,-1).trim().split(/\s+/),o=[],s=[],a=/^-?[A-Z_a-z]+[\w-]*$/;for(let u of n)a.test(u)?this.options.pugClassLocation==="after-attributes"?this.classLiteralAfterAttributes.push(u):s.push(u):o.push(u);if(s.length>0){let u=this.possibleClassPosition;this.result=[this.result.slice(0,u),".",s.join("."),this.result.slice(u)].join(""),this.possibleClassPosition+=1+s.join(".").length,this.options.pugClassLocation==="before-attributes"&&this.replaceTagWithLiteralIfPossible(/div\./,".")}if(o.length>0)t.val=S(o.join(" "),this.quotes),this.previousAttributeRemapped=!1;else{this.previousAttributeRemapped=!0;return}}else if(t.name==="id"&&this.options.pugIdNotation!=="as-is"){let e=t.val;if(e=e.slice(1,-1),e=e.trim(),!/^-?[A-Z_a-z]+[\w-]*$/.test(e)){e=S(e,this.quotes),this.result+="id",t.mustEscape||(this.result+="!"),this.result+=`=${e}`;return}let o=this.possibleIdPosition,s=`#${e}`;this.result=[this.result.slice(0,o),s,this.result.slice(o)].join(""),this.possibleClassPosition+=s.length,this.replaceTagWithLiteralIfPossible(/div#/,"#"),this.previousAttributeRemapped=!0;return}}let i=pt(this.tokens,this.currentIndex);if(this.previousToken?.type==="attribute"&&(!this.previousAttributeRemapped||i)&&(this.tokenNeedsSeparator(t)&&(this.result+=","),this.wrapAttributes||(this.result+=" ")),this.previousAttributeRemapped=!1,this.wrapAttributes&&(this.result+=` | ||
`,this.result+=this.indentString.repeat(this.indentLevel+1)),this.result+=t.name,typeof t.val=="boolean")t.val||(this.result+=`=${t.val}`);else if(t.name==="class"&&this.options.pugClassNotation==="attribute"){let n=(d(t.val)?t.val.slice(1,-1).trim():t.val).split(/\s+/);if(this.classLiteralToAttribute.length>0)for(let o=this.classLiteralToAttribute.length-1;o>-1;o--){let s=this.classLiteralToAttribute.splice(o,1)[0];s&&n.unshift(s)}this.result+=`=${d(t.val)?this.quoteString(n.join(" ")):n.join(" ")}`}else{let e=t.val;if(!ht(e)){if(!gt(e))if(St(t.name,e))e=await this.formatDelegatePrettier(e,"vue");else if(kt(t.name))e=await this.formatVueExpression(e);else if(vt(t.name))e=await this.formatVueEventBinding(e);else if(this.framework==="vue"&&It(t.name))e=await this.formatVueExpression(e);else if(xt(t.name))e=await this.formatDelegatePrettier(e,"__js_expression");else if(At(t.name))e=await this.formatDelegatePrettier(e,"__js_expression");else if(mt(t.name))e=await this.formatAngularBinding(e);else if(ft(t.name))e=await this.formatAngularAction(e);else if(bt(t.name))e=await this.formatAngularDirective(e);else if(Tt(e))e=await this.formatAngularInterpolation(e);else if(Pt(e))e=await this.formatSvelteInterpolation(e);else if(ct(t.name,t.val))e=await this.formatStyleAttribute(e);else{let n=e.trimEnd();if(d(n))e=S(n.slice(1,-1),this.quotes);else{if(e==="true")return;if(t.mustEscape){e=await f(e,{parser:"__js_expression",...this.codeInterpolationOptions});let o=e.split(` | ||
`),s=this.wrapAttributes?this.indentLevel+1:this.indentLevel;if(o.length>1){e=o[0]??"";for(let a=1;a<o.length;a++)e+=` | ||
`,e+=this.indentString.repeat(s),e+=o[a]}}else e=e.trim(),e=e.replaceAll(/\s\s+/g," "),e[0]==="{"&&e[1]===" "&&(e=`{${e.slice(2)}`)}}}t.mustEscape||(this.result+="!"),this.result+=`=${e}`}}"end-attributes"(t){if(this.wrapAttributes&&this.result.at(-1)!=="("&&(this.options.pugBracketSameLine||(this.result+=` | ||
`),this.result+=this.indentString.repeat(this.indentLevel+this.options.pugClosingBracketIndentDepth)),this.wrapAttributes=!1,this.classLiteralToAttribute.length>0){this.previousToken?.type==="start-attributes"?this.result+="(":this.previousToken?.type==="attribute"&&(this.result+=" ");let i=this.classLiteralToAttribute.splice(0,this.classLiteralToAttribute.length);this.result+=`class=${this.quoteString(i.join(" "))}`,this.previousToken?.type==="start-attributes"&&(this.result+=")")}if(this.result.at(-1)==="("?this.result=this.result.slice(0,-1):this.previousToken?.type==="attribute"?(this.options.pugBracketSameLine&&(this.result=this.result.trimEnd()),this.result+=")"):this.options.pugPreserveAttributeBrackets&&this.previousToken?.type==="start-attributes"&&(this.result+="()"),this.result.at(-1)===")"&&this.classLiteralAfterAttributes.length>0){let i=this.classLiteralAfterAttributes.splice(0,this.classLiteralAfterAttributes.length);this.result+=`.${i.join(".")}`}this.options.pugClassLocation==="after-attributes"&&(this.possibleClassPosition=this.result.length),(this.nextToken?.type==="text"||this.nextToken?.type==="path")&&(this.result+=" ")}indent(t){let i=` | ||
${this.indentString.repeat(this.indentLevel)}`;return this.indentLevel++,this.currentLineLength=i.length-1+1+this.options.pugTabWidth,l.debug("indent",{result:i,indentLevel:this.indentLevel,pugTabWidth:this.options.pugTabWidth},this.currentLineLength),i}outdent(t){let i="";return this.previousToken&&this.previousToken.type!=="outdent"&&(t.loc.start.line-this.previousToken.loc.end.line>1&&(i+=` | ||
`),i+=` | ||
`),this.indentLevel--,this.currentLineLength=1+this.indentString.repeat(this.indentLevel).length,l.debug("outdent",{result:i,indentLevel:this.indentLevel},this.currentLineLength),i}class(t){if(this.options.pugClassNotation==="attribute"){if(this.classLiteralToAttribute.push(t.val),(this.previousToken===void 0||this.checkTokenType(this.previousToken,["tag","class","end-attributes"],!0)||this.previousToken.type==="tag"&&this.previousToken.val==="div"&&this.nextToken?.type!=="attribute"&&!this.options.pugExplicitDiv)&&(this.result+=`${this.computedIndent}div`),this.checkTokenType(this.nextToken,["text","newline","indent","outdent","eos",":"])){let i=this.classLiteralToAttribute.splice(0,this.classLiteralToAttribute.length);if(this.result.at(-1)===")"){let e=this.result.lastIndexOf("("),n=this.result.indexOf("class=",e);n>-1?this.result=[this.result.slice(0,n+7),i.join(" ")," ",this.result.slice(n+7)].join(""):this.result=this.result.slice(0,-1)+`${this.neverUseAttributeSeparator?" ":", "}class=${this.quoteString(i.join(" "))})`}else this.result+=`(class=${this.quoteString(i.join(" "))})`;this.nextToken?.type==="text"&&(this.result+=" ")}}else{let i=`.${t.val}`;switch(this.currentLineLength+=i.length,l.debug("before class",{result:this.result,val:i,length:i.length,previousToken:this.previousToken},this.currentLineLength),this.previousToken?.type){case void 0:case"newline":case"outdent":case"indent":{let e=this.options.pugExplicitDiv||this.options.pugClassLocation==="after-attributes"?"div":"",n=`${this.computedIndent}${e}`;this.options.pugClassLocation==="after-attributes"?this.classLiteralAfterAttributes.push(i.slice(1)):n+=i,this.currentLineLength+=e.length,this.possibleIdPosition=this.result.length+this.computedIndent.length+e.length,this.result+=n,this.possibleClassPosition=this.result.length;break}case"end-attributes":{let e=this.result.slice(0,this.possibleClassPosition);this.result=[e,i,this.result.slice(this.possibleClassPosition)].join(""),this.possibleClassPosition+=i.length;break}default:{if(this.options.pugClassLocation==="after-attributes")this.classLiteralAfterAttributes.push(i.slice(1));else{let e=this.result.slice(0,this.possibleClassPosition);this.result=[e,i,this.result.slice(this.possibleClassPosition)].join(""),this.possibleClassPosition+=i.length}break}}if(this.options.pugClassLocation==="after-attributes"&&this.classLiteralAfterAttributes.length>0){let e=this.result.slice(0,this.possibleClassPosition);if(["text","newline","indent","outdent","eos","code",":",void 0].includes(this.nextToken?.type)){let n=this.classLiteralAfterAttributes.splice(0,this.classLiteralAfterAttributes.length);e+="."+n.join(".")}this.result=[e,this.result.slice(this.possibleClassPosition)].join(""),this.possibleClassPosition=this.result.length,this.replaceTagWithLiteralIfPossible(/div\./,".")}l.debug("after class",{result:this.result,val:i,length:i.length},this.currentLineLength),this.nextToken?.type==="text"&&!/^\s+$/.test(this.nextToken.val)&&(this.currentLineLength+=1,this.result+=" ")}}eos(t){for(;this.result.at(-1)===` | ||
`;)this.result=this.result.slice(0,-1);this.result+=` | ||
`}comment(t){var i;let e=this.computedIndent;if(/^ prettier-ignore($|[ :])/.test(t.val)){let n=this.getNextToken();if(n){let o=n.type==="newline",s=0;for(;n;){let{type:a}=n;if(a==="newline"&&s===0)if(o)o=!1;else break;else if(a==="indent")s++;else if(a==="outdent"){if(s--,s<=0){s<0&&this.indentLevel--;break}}else if(a==="eos")break;n=this.getNextToken()}if(n){let a=this.getUnformattedContentLines(t,n),l=a.pop();l!==void 0&&a.push(l.trimEnd()),e+=a.join(` | ||
`),n.type==="eos"&&(e+=` | ||
`)}}}else this.checkTokenType(this.previousToken,["newline","indent","outdent"],!0)&&(e+=" "),e+="//",t.buffer||(e+="-"),e+=x(t.val,this.options.pugCommentPreserveSpaces),((i=this.nextToken)==null?void 0:i.type)==="start-pipeless-text"&&(this.pipelessComment=!0);return e}newline(t){let e="";return this.previousToken&&t.loc.start.line-this.previousToken.loc.end.line>1&&(e+=` | ||
`),e+=` | ||
`,this.currentLineLength=1+this.indentString.repeat(this.indentLevel).length,p.debug("newline",{result:e,indentLevel:this.indentLevel},this.currentLineLength),e}async text(t){var s,a,l,u,h;let e="",i=t.val,n=!1,o=i.at(-1)===" "&&!/^\s+$/.test(i);if(this.pipelessText){switch((s=this.previousToken)==null?void 0:s.type){case"newline":{i.trim().length>0&&(e+=this.indentString.repeat(this.indentLevel+1));break}case"start-pipeless-text":{e+=this.indentString;break}}this.pipelessComment&&(i=x(i,this.options.pugCommentPreserveSpaces,!0))}else{if(this.nextToken&&o)switch(this.nextToken.type){case"interpolated-code":case"start-pug-interpolation":{n=!0;break}}switch(i=i.replaceAll(/\s\s+/g," "),(a=this.previousToken)==null?void 0:a.type){case"newline":{e+=this.indentString.repeat(this.indentLevel),/^ .+$/.test(i)&&(e+=`| | ||
`,e+=this.indentString.repeat(this.indentLevel)),e+="|",(/.*\S.*/.test(t.val)||((l=this.nextToken)==null?void 0:l.type)==="start-pug-interpolation")&&(e+=" ");break}case"indent":case"outdent":{e+=this.computedIndent,/^ .+$/.test(i)&&(e+=`| | ||
`,e+=this.indentString.repeat(this.indentLevel)),e+="|",/.*\S.*/.test(t.val)&&(e+=" ");break}case"interpolated-code":case"end-pug-interpolation":{/^ .+$/.test(i)||i===" "?e+=" ":/^.+ $/.test(i)&&(n=!0);break}}i=i.trim(),i=await this.formatText(i),i=i.replaceAll(/#([[{])/g,"\\#$1")}return this.checkTokenType(this.previousToken,["tag","id","interpolation","call","&attributes","filter"])&&(i.length===0&&((u=this.nextToken)==null?void 0:u.type)==="indent"?o=!1:i=` ${i}`),e+=i,n&&(e+=" "),o&&((h=this.nextToken)==null?void 0:h.type)==="indent"&&(e+=` | ||
`+this.indentString.repeat(this.indentLevel+1)+"|"),e}"interpolated-code"(t){var i;let e="";switch((i=this.previousToken)==null?void 0:i.type){case"tag":case"class":case"id":case"end-attributes":{e=" ";break}case"start-pug-interpolation":{e="| ";break}case"indent":case"newline":case"outdent":{e=this.computedIndent,e+=this.pipelessText?this.indentString:"| ";break}}return e+=t.mustEscape?"#":"!",e+=b(this.options.pugBracketSpacing,t.val.trim(),["{","}"]),e}async code(t){let e=this.computedIndent;!t.mustEscape&&t.buffer&&(e+="!"),e+=t.buffer?"=":"-";let i=this.options.pugSemi;i&&(t.mustEscape||t.buffer)&&(i=!1);let n=t.val;try{let o=n;n=await f(n,{parser:"babel",...this.codeInterpolationOptions,semi:i,endOfLine:"lf"}),n=n.slice(0,-1),n[0]===";"&&(n=n.slice(1)),n.includes(` | ||
`)&&(n=o)}catch(o){p.warn("[PugPrinter]:",o)}return e+=` ${n}`,e}id(t){var i;let e=`#${t.val}`;switch(this.currentLineLength+=e.length,(i=this.previousToken)==null?void 0:i.type){case void 0:case"newline":case"outdent":case"indent":{let n=this.options.pugExplicitDiv?"div":"",o=`${this.computedIndent}${n}${e}`;this.currentLineLength+=n.length,this.result+=o,this.possibleClassPosition=this.result.length;break}default:{let n=this.result.slice(0,this.possibleIdPosition);this.possibleClassPosition+=e.length,this.result=[n,e,this.result.slice(this.possibleIdPosition)].join("");break}}}async"start-pipeless-text"(t){var i;this.pipelessText=!0;let e=` | ||
${this.indentString.repeat(this.indentLevel)}`;if(((i=this.previousToken)==null?void 0:i.type)==="dot"){let n=lt(this.tokens,this.currentIndex),o;switch(n==null?void 0:n.val){case"script":{o=yt(ut(this.tokens,this.currentIndex));break}case"style":{o="css";break}default:break}if(o){let s=this.currentIndex+1,a=this.tokens[s],l="",u=!1;for(;a&&(a==null?void 0:a.type)!=="end-pipeless-text";){switch(a.type){case"text":{l+=a.val;break}case"newline":{l+=` | ||
`;break}case"interpolated-code":{u=!0,l+=a.mustEscape?"#":"!",l+=`{${a.val}}`;break}default:{p.warn("[PugPrinter:start-pipeless-text]:","Unhandled token for pipeless script tag:",JSON.stringify(a));break}}s++,a=this.tokens[s]}try{e=await f(l,{parser:o,...this.codeInterpolationOptions})}catch(g){if(!u)throw p.error(g),g;let d=["[PugPrinter:start-pipeless-text]:","The following expression could not be formatted correctly.","This is likely a syntax error or an issue caused by the missing execution context.","If you think this is a bug, please open a bug issue."];d.push(` | ||
code: \`${l.trim()}\``,` | ||
You used interpolated code in your pipeless script tag, so you may ignore this warning.`),Nt.isNativeError(g)?d.push(` | ||
Found ${o} ${g.name}: ${g.message}.`):(p.debug("typeof error:",typeof g),d.push(` | ||
Unexpected error for parser ${o}.`,g)),p.warn(...d),e=l}e=e.trimEnd();let h=this.indentString.repeat(this.indentLevel+1);e=e.split(` | ||
`).map(g=>g?h+g:"").join(` | ||
`),e=` | ||
${e}`,a=this.tokens[s-1],(a==null?void 0:a.type)==="text"&&a.val===""&&(e+=` | ||
`),this.currentIndex=s-1}}return e}"end-pipeless-text"(t){return this.pipelessText=!1,this.pipelessComment=!1,""}doctype(t){let e=`${this.computedIndent}doctype`;return t.val&&(e+=` ${t.val}`),e}dot(t){return"."}block(t){let e=`${this.computedIndent}block `;return t.mode!=="replace"&&(e+=`${t.mode} `),e+=t.val,e}extends(t){return`${this.options.pugSingleFileComponentIndentation?this.indentString:""}extends `}path(t){let e="";return this.checkTokenType(this.previousToken,["include","filter"])&&(e+=" "),e+=t.val,e}"start-pug-interpolation"(t){var i,n;let e="";return((i=this.tokens[this.currentIndex-2])==null?void 0:i.type)==="newline"&&((n=this.previousToken)==null?void 0:n.type)==="text"&&this.previousToken.val.trim().length===0&&(e+=this.indentString.repeat(this.indentLevel+1)),this.currentlyInPugInterpolation=!0,e+="#[",e}"end-pug-interpolation"(t){return this.currentlyInPugInterpolation=!1,"]"}interpolation(t){let e=`${this.computedIndent}#{${t.val}}`;return this.currentLineLength+=e.length,this.possibleIdPosition=this.result.length+e.length,this.possibleClassPosition=this.result.length+e.length,e}include(t){return`${this.computedIndent}include`}filter(t){return`${this.computedIndent}:${t.val}`}call(t){let e=`${this.computedIndent}+${t.val}`,i=t.args;return i&&(i=i.trim(),i=i.replaceAll(/\s\s+/g," "),e+=`(${i})`),this.currentLineLength+=e.length,this.possibleIdPosition=this.result.length+e.length,this.possibleClassPosition=this.result.length+e.length,e}mixin(t){let e=`${this.computedIndent}mixin ${t.val}`,i=t.args;return i&&(i=i.trim(),i=i.replaceAll(/\s\s+/g," "),e+=`(${i})`),e}if(t){let e=this.computedIndent,i=/^!\((.*)\)$/.exec(t.val);return p.debug("[PugPrinter]:",i),e+=i?`unless ${i[1]}`:`if ${t.val}`,e}"mixin-block"(t){return`${this.computedIndent}block`}else(t){return`${this.computedIndent}else`}"&attributes"(t){let e=`&attributes(${t.val})`;return this.currentLineLength+=e.length,e}"text-html"(t){let e=/^<(.*?)>(.*)<\/(.*?)>$/.exec(t.val);if(p.debug("[PugPrinter]:",e),e)return`${this.computedIndent}${e[1]} ${e[2]}`;let i=Object.entries(nt).find(([n])=>n===t.val.toLowerCase());return i?`${this.computedIndent}${i[1]}`:`${this.computedIndent}${t.val}`}each(t){let e=`${this.computedIndent}each ${t.val}`;return t.key!==null&&(e+=`, ${t.key}`),e+=` in ${t.code}`,e}async eachOf(t){let e=t.value.trim();e=await f(e,{parser:"babel",...this.codeInterpolationOptions,semi:!1}),e[0]===";"&&(e=e.slice(1)),e=T(e);let i=t.code.trim();return`${this.computedIndent}each ${e} of ${i}`}while(t){return`${this.computedIndent}while ${t.val}`}case(t){return`${this.computedIndent}case ${t.val}`}when(t){return`${this.computedIndent}when ${t.val}`}":"(t){return this.possibleIdPosition=this.result.length+2,this.possibleClassPosition=this.result.length+2,": "}default(t){return`${this.computedIndent}default`}"else-if"(t){return`${this.computedIndent}else if ${t.val}`}blockcode(t){return`${this.computedIndent}-`}yield(t){return`${this.computedIndent}yield`}slash(t){var i;let e="/";return((i=this.nextToken)==null?void 0:i.type)==="text"&&(e+=" "),e}};var v={languages:[{name:"Pug",parsers:["pug"],tmScope:"text.jade",aceMode:"jade",codemirrorMode:"pug",codemirrorMimeType:"text/x-pug",extensions:[".jade",".pug"],linguistLanguageId:179,vscodeLanguageIds:["jade","pug"]}],parsers:{pug:{parse(r,t){p.debug("[parsers:pug:parse]:",{text:r});let e=r.replace(/^\s*\n/,""),i=/^\s*/.exec(e);if(i!=null&&i[0]){let s=new RegExp(`(^|\\n)${i[0]}`,"g");e=e.replace(s,"$1")}let n=e,o=Rt(n);return{content:n,tokens:o}},astFormat:"pug-ast",hasPragma(r){return r.startsWith(`//- @prettier | ||
`}comment(t){let i=this.computedIndent;if(/^ prettier-ignore($|[ :])/.test(t.val)){let e=this.getNextToken();if(e){let n=e.type==="newline",o=0;for(;e;){let{type:s}=e;if(s==="newline"&&o===0)if(n)n=!1;else break;else if(s==="indent")o++;else if(s==="outdent"){if(o--,o<=0){o<0&&this.indentLevel--;break}}else if(s==="eos")break;e=this.getNextToken()}if(e){let s=this.getUnformattedContentLines(t,e),a=s.pop();a!==void 0&&s.push(a.trimEnd()),i+=s.join(` | ||
`),e.type==="eos"&&(i+=` | ||
`)}}}else this.checkTokenType(this.previousToken,["newline","indent","outdent"],!0)&&(i+=" "),i+="//",t.buffer||(i+="-"),i+=A(t.val,this.options.pugCommentPreserveSpaces),this.nextToken?.type==="start-pipeless-text"&&(this.pipelessComment=!0);return i}newline(t){let i="";return this.previousToken&&t.loc.start.line-this.previousToken.loc.end.line>1&&(i+=` | ||
`),i+=` | ||
`,this.currentLineLength=1+this.indentString.repeat(this.indentLevel).length,l.debug("newline",{result:i,indentLevel:this.indentLevel},this.currentLineLength),i}async text(t){let i="",e=t.val,n=!1,o=e.at(-1)===" "&&!/^\s+$/.test(e);if(this.pipelessText){switch(this.previousToken?.type){case"newline":{e.trim().length>0&&(i+=this.indentString.repeat(this.indentLevel+1));break}case"start-pipeless-text":{i+=this.indentString;break}}this.pipelessComment&&(e=A(e,this.options.pugCommentPreserveSpaces,!0))}else{if(this.nextToken&&o)switch(this.nextToken.type){case"interpolated-code":case"start-pug-interpolation":{n=!0;break}}switch(e=e.replaceAll(/\s\s+/g," "),this.previousToken?.type){case"newline":{i+=this.indentString.repeat(this.indentLevel),/^ .+$/.test(e)&&(i+=`| | ||
`,i+=this.indentString.repeat(this.indentLevel)),i+="|",(/.*\S.*/.test(t.val)||this.nextToken?.type==="start-pug-interpolation")&&(i+=" ");break}case"indent":case"outdent":{i+=this.computedIndent,/^ .+$/.test(e)&&(i+=`| | ||
`,i+=this.indentString.repeat(this.indentLevel)),i+="|",/.*\S.*/.test(t.val)&&(i+=" ");break}case"interpolated-code":case"end-pug-interpolation":{/^ .+$/.test(e)||e===" "?i+=" ":/^.+ $/.test(e)&&(n=!0);break}}e=e.trim(),e=await this.formatText(e),e=e.replaceAll(/#([[{])/g,"\\#$1")}return this.checkTokenType(this.previousToken,["tag","id","interpolation","call","&attributes","filter"])&&(e.length===0&&this.nextToken?.type==="indent"?o=!1:e=` ${e}`),i+=e,n&&(i+=" "),o&&this.nextToken?.type==="indent"&&(i+=` | ||
`+this.indentString.repeat(this.indentLevel+1)+"|"),i}"interpolated-code"(t){let i="";switch(this.previousToken?.type){case"tag":case"class":case"id":case"end-attributes":{i=" ";break}case"start-pug-interpolation":{i="| ";break}case"indent":case"newline":case"outdent":{i=this.computedIndent,i+=this.pipelessText?this.indentString:"| ";break}}return i+=t.mustEscape?"#":"!",i+=b(this.options.pugBracketSpacing,t.val.trim(),["{","}"]),i}async code(t){let i=this.computedIndent;!t.mustEscape&&t.buffer&&(i+="!"),i+=t.buffer?"=":"-";let e=this.options.pugSemi;e&&(t.mustEscape||t.buffer)&&(e=!1);let n=t.val;try{let o=n;n=await f(n,{parser:"babel",...this.codeInterpolationOptions,semi:e,endOfLine:"lf"}),n=n.slice(0,-1),n[0]===";"&&(n=n.slice(1)),n.includes(` | ||
`)&&(n=o)}catch(o){l.warn("[PugPrinter]:",o)}return i+=` ${n}`,i}id(t){let i=`#${t.val}`;switch(this.currentLineLength+=i.length,this.previousToken?.type){case void 0:case"newline":case"outdent":case"indent":{let e=this.options.pugExplicitDiv?"div":"",n=`${this.computedIndent}${e}${i}`;this.currentLineLength+=e.length,this.result+=n,this.possibleClassPosition=this.result.length;break}default:{let e=this.result.slice(0,this.possibleIdPosition);this.possibleClassPosition+=i.length,this.result=[e,i,this.result.slice(this.possibleIdPosition)].join("");break}}}async"start-pipeless-text"(t){this.pipelessText=!0;let i=` | ||
${this.indentString.repeat(this.indentLevel)}`;if(this.previousToken?.type==="dot"){let e=lt(this.tokens,this.currentIndex),n;switch(e?.val){case"script":{n=yt(ut(this.tokens,this.currentIndex));break}case"style":{n="css";break}default:break}if(n){let o=this.currentIndex+1,s=this.tokens[o],a="",u=!1;for(;s&&s.type!=="end-pipeless-text";){switch(s.type){case"text":{a+=s.val;break}case"newline":{a+=` | ||
`;break}case"interpolated-code":{u=!0,a+=s.mustEscape?"#":"!",a+=`{${s.val}}`;break}default:{l.warn("[PugPrinter:start-pipeless-text]:","Unhandled token for pipeless script tag:",JSON.stringify(s));break}}o++,s=this.tokens[o]}try{i=await f(a,{parser:n,...this.codeInterpolationOptions})}catch(c){if(!u)throw l.error(c),c;let h=["[PugPrinter:start-pipeless-text]:","The following expression could not be formatted correctly.","This is likely a syntax error or an issue caused by the missing execution context.","If you think this is a bug, please open a bug issue."];h.push(` | ||
code: \`${a.trim()}\``,` | ||
You used interpolated code in your pipeless script tag, so you may ignore this warning.`),Ct.isNativeError(c)?h.push(` | ||
Found ${n} ${c.name}: ${c.message}.`):(l.debug("typeof error:",typeof c),h.push(` | ||
Unexpected error for parser ${n}.`,c)),l.warn(...h),i=a}i=i.trimEnd();let g=this.indentString.repeat(this.indentLevel+1);i=i.split(` | ||
`).map(c=>c?g+c:"").join(` | ||
`),i=` | ||
${i}`,s=this.tokens[o-1],s?.type==="text"&&s.val===""&&(i+=` | ||
`),this.currentIndex=o-1}}return i}"end-pipeless-text"(t){return this.pipelessText=!1,this.pipelessComment=!1,""}doctype(t){let i=`${this.computedIndent}doctype`;return t.val&&(i+=` ${t.val}`),i}dot(t){return"."}block(t){let i=`${this.computedIndent}block `;return t.mode!=="replace"&&(i+=`${t.mode} `),i+=t.val,i}extends(t){return`${this.options.pugSingleFileComponentIndentation?this.indentString:""}extends `}path(t){let i="";return this.checkTokenType(this.previousToken,["include","filter"])&&(i+=" "),i+=t.val,i}"start-pug-interpolation"(t){let i="";return this.tokens[this.currentIndex-2]?.type==="newline"&&this.previousToken?.type==="text"&&this.previousToken.val.trim().length===0&&(i+=this.indentString.repeat(this.indentLevel+1)),this.currentlyInPugInterpolation=!0,i+="#[",i}"end-pug-interpolation"(t){return this.currentlyInPugInterpolation=!1,"]"}interpolation(t){let i=`${this.computedIndent}#{${t.val}}`;return this.currentLineLength+=i.length,this.possibleIdPosition=this.result.length+i.length,this.possibleClassPosition=this.result.length+i.length,i}include(t){return`${this.computedIndent}include`}filter(t){return`${this.computedIndent}:${t.val}`}call(t){let i=`${this.computedIndent}+${t.val}`,e=t.args;return e&&(e=e.trim(),e=e.replaceAll(/\s\s+/g," "),i+=`(${e})`),this.currentLineLength+=i.length,this.possibleIdPosition=this.result.length+i.length,this.possibleClassPosition=this.result.length+i.length,i}mixin(t){let i=`${this.computedIndent}mixin ${t.val}`,e=t.args;return e&&(e=e.trim(),e=e.replaceAll(/\s\s+/g," "),i+=`(${e})`),i}if(t){let i=this.computedIndent,e=/^!\((.*)\)$/.exec(t.val);return l.debug("[PugPrinter]:",e),i+=e?`unless ${e[1]}`:`if ${t.val}`,i}"mixin-block"(t){return`${this.computedIndent}block`}else(t){return`${this.computedIndent}else`}"&attributes"(t){let i=`&attributes(${t.val})`;return this.currentLineLength+=i.length,i}"text-html"(t){let i=/^<(.*?)>(.*)<\/(.*?)>$/.exec(t.val);if(l.debug("[PugPrinter]:",i),i)return`${this.computedIndent}${i[1]} ${i[2]}`;let e=Object.entries(nt).find(([n])=>n===t.val.toLowerCase());return e?`${this.computedIndent}${e[1]}`:`${this.computedIndent}${t.val}`}each(t){let i=`${this.computedIndent}each ${t.val}`;return t.key!==null&&(i+=`, ${t.key}`),i+=` in ${t.code}`,i}async eachOf(t){let i=t.value.trim();i=await f(i,{parser:"babel",...this.codeInterpolationOptions,semi:!1}),i[0]===";"&&(i=i.slice(1)),i=T(i);let e=t.code.trim();return`${this.computedIndent}each ${i} of ${e}`}while(t){return`${this.computedIndent}while ${t.val}`}case(t){return`${this.computedIndent}case ${t.val}`}when(t){return`${this.computedIndent}when ${t.val}`}":"(t){return this.possibleIdPosition=this.result.length+2,this.possibleClassPosition=this.result.length+2,": "}default(t){return`${this.computedIndent}default`}"else-if"(t){return`${this.computedIndent}else if ${t.val}`}blockcode(t){return`${this.computedIndent}-`}yield(t){return`${this.computedIndent}yield`}slash(t){let i="/";return this.nextToken?.type==="text"&&(i+=" "),i}};var v={languages:[{name:"Pug",parsers:["pug"],tmScope:"text.jade",aceMode:"jade",codemirrorMode:"pug",codemirrorMimeType:"text/x-pug",extensions:[".jade",".pug"],linguistLanguageId:179,vscodeLanguageIds:["jade","pug"]}],parsers:{pug:{parse(r,t){l.debug("[parsers:pug:parse]:",{text:r});let i=r.replace(/^\s*\n/,""),e=/^\s*/.exec(i);if(e?.[0]){let s=new RegExp(`(^|\\n)${e[0]}`,"g");i=i.replace(s,"$1")}let n=i,o=Nt(n);return{content:n,tokens:o}},astFormat:"pug-ast",hasPragma(r){return r.startsWith(`//- @prettier | ||
`)||r.startsWith(`//- @format | ||
`)},locStart(r){return p.debug("[parsers:pug:locStart]:",{node:r}),0},locEnd(r){return p.debug("[parsers:pug:locEnd]:",{node:r}),0},preprocess(r,t){return p.debug("[parsers:pug:preprocess]:",{text:r}),r}}},printers:{"pug-ast":{async print(r,t){let e=r.stack[0],{content:i,tokens:n}=e,o=rt(t),a=await new A(i,n,o).build();return p.debug("[printers:pug-ast:print]:",a),a},insertPragma(r){return`//- @prettier | ||
${r}`}}},options:it,defaultOptions:{}},ri=v.languages,ni=v.parsers,si=v.printers,oi=v.options,ai=v.defaultOptions;export{I as LogLevel,P as Logger,E as createLogger,ai as defaultOptions,ri as languages,p as logger,oi as options,ni as parsers,v as plugin,si as printers}; | ||
`)},locStart(r){return l.debug("[parsers:pug:locStart]:",{node:r}),0},locEnd(r){return l.debug("[parsers:pug:locEnd]:",{node:r}),0},preprocess(r,t){return l.debug("[parsers:pug:preprocess]:",{text:r}),r}}},printers:{"pug-ast":{async print(r,t){let i=r.stack[0],{content:e,tokens:n}=i,o=rt(t),a=await new x(e,n,o).build();return l.debug("[printers:pug-ast:print]:",a),a},insertPragma(r){return`//- @prettier | ||
${r}`}}},options:it,defaultOptions:{}},ii=v.languages,ri=v.parsers,ni=v.printers,si=v.options,oi=v.defaultOptions;export{w as LogLevel,P as Logger,E as createLogger,oi as defaultOptions,ii as languages,l as logger,si as options,ri as parsers,v as plugin,ni as printers}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@prettier/plugin-pug", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"description": "Prettier Pug Plugin", | ||
"type": "module", | ||
"main": "dist/index.js", | ||
"module": "dist/index.js", | ||
"exports": { | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/index.js" | ||
}, | ||
"./src/*": { | ||
"types": "./src/*.d.ts", | ||
"default": "./src/*.ts" | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"keywords": [ | ||
@@ -25,7 +11,3 @@ "pug", | ||
], | ||
"author": { | ||
"name": "Christopher Quadflieg", | ||
"email": "chrissi92@hotmail.de", | ||
"url": "https://github.com/Shinigami92" | ||
}, | ||
"bugs": "https://github.com/prettier/plugin-pug/issues", | ||
"repository": { | ||
@@ -45,4 +27,18 @@ "type": "git", | ||
], | ||
"bugs": "https://github.com/prettier/plugin-pug/issues", | ||
"license": "MIT", | ||
"author": { | ||
"name": "Christopher Quadflieg", | ||
"email": "chrissi92@hotmail.de", | ||
"url": "https://github.com/Shinigami92" | ||
}, | ||
"type": "module", | ||
"exports": { | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/index.js" | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"main": "dist/index.js", | ||
"module": "dist/index.js", | ||
"files": [ | ||
@@ -58,12 +54,11 @@ "dist", | ||
"devDependencies": { | ||
"@eslint-types/jsdoc": "48.2.2", | ||
"@eslint-types/prettier": "5.1.3", | ||
"@eslint-types/typescript-eslint": "7.5.0", | ||
"@eslint-types/unicorn": "52.0.0", | ||
"@types/node": "20.16.5", | ||
"@typescript-eslint/eslint-plugin": "7.18.0", | ||
"@typescript-eslint/parser": "7.18.0", | ||
"@vitest/coverage-v8": "2.0.5", | ||
"@eslint/compat": "1.2.0", | ||
"@eslint/js": "9.12.0", | ||
"@stylistic/eslint-plugin": "2.9.0", | ||
"@types/eslint__js": "8.42.3", | ||
"@types/node": "20.16.11", | ||
"@vitest/coverage-v8": "2.1.2", | ||
"@vitest/eslint-plugin": "1.1.7", | ||
"benchmark": "2.1.4", | ||
"eslint": "8.57.0", | ||
"eslint": "9.12.0", | ||
"eslint-config-prettier": "9.1.0", | ||
@@ -73,15 +68,18 @@ "eslint-define-config": "2.1.0", | ||
"eslint-plugin-inclusive-language": "2.2.1", | ||
"eslint-plugin-jsdoc": "50.2.2", | ||
"eslint-plugin-jsdoc": "50.3.1", | ||
"eslint-plugin-prettier": "5.2.1", | ||
"eslint-plugin-spellcheck": "0.0.20", | ||
"eslint-plugin-unicorn": "55.0.0", | ||
"npm-run-all2": "6.2.2", | ||
"eslint-plugin-unicorn": "56.0.0", | ||
"jiti": "2.3.3", | ||
"npm-run-all2": "6.2.3", | ||
"prettier": "3.3.3", | ||
"prettier-plugin-organize-imports": "4.0.0", | ||
"prettier-plugin-organize-imports": "4.1.0", | ||
"prettier-plugin-packagejson": "2.5.3", | ||
"rimraf": "6.0.1", | ||
"tsup": "8.2.4", | ||
"typescript": "5.5.4", | ||
"vite": "5.4.3", | ||
"vitepress": "1.3.4", | ||
"vitest": "2.0.5" | ||
"tsup": "8.3.0", | ||
"typescript": "5.6.3", | ||
"typescript-eslint": "8.8.1", | ||
"vite": "5.4.8", | ||
"vitepress": "1.4.0", | ||
"vitest": "2.1.2" | ||
}, | ||
@@ -104,3 +102,3 @@ "peerDependencies": { | ||
"format": "prettier --cache --write .", | ||
"lint": "eslint --cache --cache-strategy content --report-unused-disable-directives .", | ||
"lint": "eslint --cache --cache-strategy content --flag unstable_ts_config .", | ||
"ts-check": "tsc", | ||
@@ -107,0 +105,0 @@ "test": "vitest", |
@@ -60,2 +60,3 @@ import type { | ||
} | ||
const content: string = trimmedAndAlignedContent; | ||
@@ -62,0 +63,0 @@ |
@@ -36,3 +36,3 @@ /** Log levels. */ | ||
*/ | ||
public static isSupportedLogLevel(value: any): value is LogLevel { | ||
public static isSupportedLogLevel(value: unknown): value is LogLevel { | ||
return ( | ||
@@ -39,0 +39,0 @@ typeof value === 'string' && |
@@ -48,2 +48,3 @@ import type { AttributeToken } from 'pug-lexer'; | ||
} | ||
if (beginning < 0) { | ||
@@ -66,2 +67,3 @@ return 1; | ||
} | ||
if (end < 0) { | ||
@@ -77,7 +79,10 @@ return -1; | ||
} | ||
if (aName < bName) { | ||
return -1; | ||
} | ||
break; | ||
} | ||
case 'desc': { | ||
@@ -87,5 +92,7 @@ if (aName > bName) { | ||
} | ||
if (aName < bName) { | ||
return 1; | ||
} | ||
break; | ||
@@ -92,0 +99,0 @@ } |
@@ -33,2 +33,3 @@ import type { AttributeToken } from 'pug-lexer'; | ||
} | ||
return; | ||
@@ -46,4 +47,6 @@ } | ||
} | ||
break; | ||
} | ||
case 'none': { | ||
@@ -53,2 +56,3 @@ if (token.val === '""' || token.val === "''") { | ||
} | ||
break; | ||
@@ -55,0 +59,0 @@ } |
@@ -51,2 +51,3 @@ import type { ChoiceSupportOption } from 'prettier'; | ||
} | ||
throw new Error( | ||
@@ -53,0 +54,0 @@ `Invalid option for pugAttributeSeparator. Found '${pugAttributeSeparator}'. Possible options: 'always', 'as-needed' or 'none'`, |
@@ -58,5 +58,7 @@ import type { ChoiceSupportOption } from 'prettier'; | ||
} | ||
result += input.slice(firstNonSpace).trim().replaceAll(/\s\s+/g, ' '); | ||
return result; | ||
} | ||
case 'trim-all': { | ||
@@ -68,4 +70,6 @@ let result: string = input.trim(); | ||
} | ||
return result; | ||
} | ||
case 'keep-all': | ||
@@ -72,0 +76,0 @@ default: { |
@@ -21,2 +21,3 @@ import type { AttributeToken, TagToken, Token } from 'pug-lexer'; | ||
} | ||
if (token.type === 'tag') { | ||
@@ -26,2 +27,3 @@ return token; | ||
} | ||
return; | ||
@@ -46,2 +48,3 @@ } | ||
} | ||
if ( | ||
@@ -55,2 +58,3 @@ token.type === 'attribute' && | ||
} | ||
return; | ||
@@ -75,2 +79,3 @@ } | ||
} | ||
if (token.type === 'attribute' && token.name === 'type') { | ||
@@ -80,2 +85,3 @@ return token; | ||
} | ||
return; | ||
@@ -195,2 +201,3 @@ } | ||
} | ||
return false; | ||
@@ -260,8 +267,12 @@ } | ||
} | ||
if (quote === enclosingQuote) { | ||
return `\\${quote}`; | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
if (quote) { | ||
return quote; | ||
} | ||
return unescapeUnnecessaryEscapes && | ||
@@ -298,2 +309,3 @@ /^[^\n\r"'0-7\\bfnrt-vx\u2028\u2029]$/.test(escaped) | ||
// eslint-disable-next-line unicorn/consistent-existence-index-check | ||
if (q1 >= 0 && q2 >= 0 && q2 > q1 && (qb < 0 || q1 < qb)) { | ||
@@ -331,3 +343,4 @@ logger.log({ code, quotes, otherQuotes, q1, q2, qb }); | ||
} | ||
return 'auto'; | ||
} |
{ | ||
"compilerOptions": { | ||
"target": "ES2022", | ||
"target": "ESNext", | ||
"moduleResolution": "Bundler", | ||
"module": "ESNext", | ||
"moduleResolution": "Bundler", | ||
"strict": true, | ||
@@ -11,2 +11,3 @@ "noEmit": true, | ||
"stripInternal": true, | ||
"verbatimModuleSyntax": true, | ||
"noImplicitOverride": true, | ||
@@ -13,0 +14,0 @@ "noUncheckedIndexedAccess": true, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
359009
4301
29