@kurtinatlanta/prettier 3.8.0-dev → 3.8.0-hoyt.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/THIRD-PARTY-NOTICES.md +1694 -112
- package/doc.js +112 -110
- package/doc.mjs +112 -110
- package/index.cjs +1 -1
- package/index.mjs +153 -169
- package/internal/experimental-cli.mjs +1 -1
- package/internal/legacy-cli.mjs +2 -2
- package/package.json +2 -2
- package/plugins/acorn.js +7 -7
- package/plugins/acorn.mjs +8 -8
- package/plugins/angular.js +1 -1
- package/plugins/angular.mjs +1 -1
- package/plugins/babel.js +2 -2
- package/plugins/babel.mjs +2 -2
- package/plugins/estree.js +34 -34
- package/plugins/estree.mjs +34 -34
- package/plugins/flow.js +3 -3
- package/plugins/flow.mjs +3 -3
- package/plugins/glimmer.js +1 -1
- package/plugins/glimmer.mjs +1 -1
- package/plugins/graphql.js +1 -1
- package/plugins/graphql.mjs +1 -1
- package/plugins/html.js +1 -1
- package/plugins/html.mjs +1 -1
- package/plugins/markdown.js +62 -55
- package/plugins/markdown.mjs +62 -55
- package/plugins/meriyah.js +4 -4
- package/plugins/meriyah.mjs +4 -4
- package/plugins/postcss.js +31 -31
- package/plugins/postcss.mjs +31 -31
- package/plugins/typescript.js +13 -13
- package/plugins/typescript.mjs +13 -13
- package/plugins/yaml.js +1 -1
- package/plugins/yaml.mjs +1 -1
- package/standalone.js +27 -27
- package/standalone.mjs +27 -27
package/plugins/yaml.js
CHANGED
|
@@ -159,4 +159,4 @@ ${t}`;function Ar(t,e){switch(t.type){case"comment":if(wr(t.value))return null;b
|
|
|
159
159
|
`).map((i,o,a)=>o===0&&o===a.length-1?i:o!==0&&o!==a.length-1?i.trim():o===0?i.trimEnd():i.trimStart());if(n.proseWrap==="preserve")return r.map(i=>i?[i]:[]);let s=[];for(let[i,o]of r.entries()){let a=Rr(o);i>0&&r[i-1].length>0&&a.length>0&&!(t==="quoteDouble"&&D(0,D(0,s,-1),-1).endsWith("\\"))?s[s.length-1]=[...D(0,s,-1),...a]:s.push(a)}return n.proseWrap==="never"?s.map(i=>[i.join(" ")]):s}function $r(t,{parentIndent:e,isLastDescendant:n,options:r}){let s=t.position.start.line===t.position.end.line?"":r.originalText.slice(t.position.start.offset,t.position.end.offset).match(/^[^\n]*\n(.*)$/s)[1];if(s==="")return[];let i;if(t.indent===null){let l=s.match(/^(?<leadingSpace> *)[^\n\r ]/m);i=l?l.groups.leadingSpace.length:Number.POSITIVE_INFINITY}else i=t.indent-1+e;let o=s.split(`
|
|
160
160
|
`).map(l=>l.slice(i));if(r.proseWrap==="preserve"||t.type==="blockLiteral")return c(o.map(l=>l?[l]:[]));let a=[];for(let[l,f]of o.entries()){let m=Rr(f);l>0&&m.length>0&&o[l-1].length>0&&!/^\s/.test(m[0])&&!/^\s|\s$/.test(D(0,a,-1))?a[a.length-1]=[...D(0,a,-1),...m]:a.push(m)}return a=a.map(l=>{let f=[];for(let m of l)f.length>0&&/\s$/.test(D(0,f,-1))?f[f.length-1]+=" "+m:f.push(m);return f}),r.proseWrap==="never"&&(a=a.map(l=>[l.join(" ")])),c(a);function c(l){if(t.chomping==="keep")return s.endsWith(`
|
|
161
161
|
`)&&D(0,l,-1).length===0?l.slice(0,-1):l;let f=0;for(let m=l.length-1;m>=0&&l[m].every(g=>g.replace(/[ \t]+$/,"")==="");m--)f++;return f===0?l:f>=2&&!n?l.slice(0,-(f-1)):l.slice(0,-f)}}function nt(t){if(!t)return!0;switch(t.type){case"plain":case"quoteDouble":case"quoteSingle":case"alias":case"flowMapping":case"flowSequence":return!0;default:return!1}}var yn=new WeakMap;function Pt(t,e){let{node:n,root:r}=t,s;return yn.has(r)?s=yn.get(r):(s=new Set,yn.set(r,s)),!s.has(n.position.end.line)&&(s.add(n.position.end.line),_r(n,e)&&!En(t.parent))?Tt:""}function En(t){return I(t)&&!W(t,["documentHead","documentBody","flowMapping","flowSequence"])}function _(t,e){return Je(" ".repeat(t),e)}function eo(t,e,n){let{node:r}=t,s=t.ancestors.filter(l=>l.type==="sequence"||l.type==="mapping").length,i=Ct(t),o=[r.type==="blockFolded"?">":"|"];r.indent!==null&&o.push(r.indent.toString()),r.chomping!=="clip"&&o.push(r.chomping==="keep"?"+":"-"),gn(r)&&o.push(" ",n("indicatorComment"));let a=$r(r,{parentIndent:s,isLastDescendant:i,options:e}),c=[];for(let[l,f]of a.entries())l===0&&c.push(N),c.push(Lt(v(se,f))),l!==a.length-1?c.push(f.length===0?N:ur(He)):r.chomping==="keep"&&i&&c.push(cn(f.length===0?N:He));return r.indent===null?o.push(pr(_(e.tabWidth,c))):o.push(cn(_(r.indent-1+s,c))),o}var Yr=eo;function vt(t,e,n){let{node:r}=t,s=r.type==="flowMapping",i=s?"{":"[",o=s?"}":"]",a=Tt;s&&r.children.length>0&&e.bracketSpacing&&(a=se);let c=D(0,r.children,-1),l=c?.type==="flowMappingItem"&&_e(c.key)&&_e(c.value);return[i,_(e.tabWidth,[a,to(t,e,n),e.trailingComma==="none"?"":ze(","),I(r)?[N,v(N,t.map(n,"endComments"))]:""]),l?"":a,o]}function to(t,e,n){return t.map(({isLast:r,node:s,next:i})=>[n(),r?"":[",",se,s.position.start.line!==i.position.start.line?Pt(t,e.originalText):""]],"children")}function no(t,e,n){let{node:r,parent:s}=t,{key:i,value:o}=r,a=_e(i),c=_e(o);if(a&&c)return": ";let l=n("key"),f=ro(r)?" ":"";if(c)return r.type==="flowMappingItem"&&s.type==="flowMapping"?l:r.type==="mappingItem"&&It(i.content,e)&&!V(i.content)&&s.tag?.value!=="tag:yaml.org,2002:set"?[l,f,":"]:["? ",_(2,l)];let m=n("value");if(a)return[": ",_(2,m)];if(te(o)||!nt(i.content))return["? ",_(2,l),N,...t.map(()=>[n(),N],"value","leadingComments"),": ",_(2,m)];if(so(i.content)&&!te(i.content)&&!ae(i.content)&&!V(i.content)&&!I(i)&&!te(o.content)&&!ae(o.content)&&!I(o)&&It(o.content,e)&&It(i.content,e))return[l,f,": ",m];let g=Symbol("mappingKey"),y=Pe([ze("? "),Pe(_(2,l),{id:g})]),h=[N,": ",_(2,m)],d=[f,":"];I(o)&&o.content&&W(o.content,["flowMapping","flowSequence"])&&o.content.children.length===0?d.push(" "):te(o.content)||I(o)&&o.content&&!W(o.content,["mapping","sequence"])||s.type==="mapping"&&V(i.content)&&nt(o.content)||W(o.content,["mapping","sequence"])&&o.content.tag===null&&o.content.anchor===null?d.push(N):o.content?d.push(se):V(o)&&d.push(" "),d.push(m);let w=_(e.tabWidth,d);return It(i.content,e)&&!te(i.content)&&!ae(i.content)&&!V(i.content)&&!I(i)?ln([[l,w]]):ln([[y,ze(h,w,{groupId:g})]])}function It(t,e){if(!t)return!0;switch(t.type){case"plain":case"quoteSingle":case"quoteDouble":break;case"alias":return!0;default:return!1}if(e.proseWrap==="preserve")return t.position.start.line===t.position.end.line;if(/\\$/m.test(e.originalText.slice(t.position.start.offset,t.position.end.offset)))return!1;switch(e.proseWrap){case"never":return!t.value.includes(`
|
|
162
|
-
`);case"always":return!/[\n ]/.test(t.value);default:return!1}}function ro(t){return t.key.content?.type==="alias"}function so(t){if(!t)return!0;switch(t.type){case"plain":case"quoteDouble":case"quoteSingle":return t.position.start.line===t.position.end.line;case"alias":return!0;default:return!1}}var Br=no;function io(t){return dn(t,oo)}function oo(t){switch(t.type){case"document":Ie(t,"head",()=>t.children[0]),Ie(t,"body",()=>t.children[1]);break;case"documentBody":case"sequenceItem":case"flowSequenceItem":case"mappingKey":case"mappingValue":Ie(t,"content",()=>t.children[0]);break;case"mappingItem":case"flowMappingItem":Ie(t,"key",()=>t.children[0]),Ie(t,"value",()=>t.children[1]);break}return t}var Fr=io;function ao(t,e,n){let{node:r}=t,s=[];r.type!=="mappingValue"&&te(r)&&s.push([v(N,t.map(n,"leadingComments")),N]);let{tag:i,anchor:o}=r;i&&s.push(n("tag")),i&&o&&s.push(" "),o&&s.push(n("anchor"));let a="";return W(r,["mapping","sequence","comment","directive","mappingItem","sequenceItem"])&&!Ct(t)&&(a=Pt(t,e.originalText)),(i||o)&&(W(r,["sequence","mapping"])&&!ae(r)?s.push(N):s.push(" ")),ae(r)&&s.push([r.middleComments.length===1?"":N,v(N,t.map(n,"middleComments")),N]),xr(t)?s.push(cr(e.originalText.slice(r.position.start.offset,r.position.end.offset).trimEnd())):s.push(Pe(co(t,e,n))),V(r)&&!W(r,["document","documentHead"])&&s.push(mr([r.type==="mappingValue"&&!r.content?"":" ",t.parent.type==="mappingKey"&&t.getParentNode(2).type==="mapping"&&nt(r)?"":Xe,n("trailingComment")])),En(r)&&s.push(_(r.type==="sequenceItem"?2:0,[N,v(N,t.map(({node:c})=>[pn(e.originalText,tt(c))?N:"",n()],"endComments"))])),s.push(a),s}function co(t,e,n){let{node:r}=t;switch(r.type){case"root":{let s=kt(r),i=!(W(s,["blockLiteral","blockFolded"])&&s.chomping==="keep"),o=[];return t.each(({node:a,isFirst:c})=>{c||o.push(N),o.push(n()),fo(t)&&(i&&o.push(N),o.push("..."),V(a)&&o.push(" ",n("trailingComment")))},"children"),i&&o.push(N),o}case"document":{let s=[];return uo(t)&&((r.head.children.length>0||r.head.endComments.length>0)&&s.push(n("head")),V(r.head)?s.push(["---"," ",n(["head","trailingComment"])]):s.push("---")),lo(r)&&s.push(n("body")),v(N,s)}case"documentHead":return v(N,[...t.map(n,"children"),...t.map(n,"endComments")]);case"documentBody":{let{children:s,endComments:i}=r,o="";if(s.length>0&&i.length>0){let a=kt(r);if(W(a,["blockFolded","blockLiteral"]))a.chomping!=="keep"&&(o=[N,N]);else{let c=D(0,s,-1);o=W(c,["mapping"])&&pn(e.originalText,tt(i[0]))?[N,N]:N}}return[v(N,t.map(n,"children")),o,v(N,t.map(n,"endComments"))]}case"directive":return["%",v(" ",[r.name,...r.parameters])];case"comment":return["#",r.value];case"alias":return["*",r.value];case"tag":return e.originalText.slice(r.position.start.offset,r.position.end.offset);case"anchor":return["&",r.value];case"plain":return rt(r.type,e.originalText.slice(r.position.start.offset,r.position.end.offset),e);case"quoteDouble":case"quoteSingle":{let o=e.originalText.slice(r.position.start.offset+1,r.position.end.offset-1);if(r.type==="quoteSingle"&&o.includes("\\")||r.type==="quoteDouble"&&/\\[^"]/.test(o)){let c=r.type==="quoteDouble"?'"':"'";return[c,rt(r.type,o,e),c]}if(o.includes('"'))return["'",rt(r.type,r.type==="quoteDouble"?dt(0,dt(0,o,'\\"','"'),"'","'".repeat(2)):o,e),"'"];if(o.includes("'"))return['"',rt(r.type,r.type==="quoteSingle"?dt(0,o,"''","'"):o,e),'"'];let a=e.singleQuote?"'":'"';return[a,rt(r.type,o,e),a]}case"blockFolded":case"blockLiteral":return Yr(t,e,n);case"mapping":case"sequence":return v(N,t.map(n,"children"));case"sequenceItem":return["- ",_(2,r.content?n("content"):"")];case"mappingKey":case"mappingValue":return r.content?n("content"):"";case"mappingItem":case"flowMappingItem":return Br(t,e,n);case"flowMapping":return vt(t,e,n);case"flowSequence":return vt(t,e,n);case"flowSequenceItem":return n("content");default:throw new dr(r,"YAML")}}function lo(t){return t.body.children.length>0||I(t.body)}function fo(t){let e=t.node;if(e.documentEndMarker||V(e))return!0;if(t.isLast)return!1;let n=t.next;return n.head.children.length>0||I(n.head)}function uo(t){let e=t.node;return e.directivesEndMarker||e.head.children.length>0||I(e.head)||V(e.head)}function rt(t,e,n){let r=Dr(t,e,n);return v(N,r.map(s=>Lt(v(se,s))))}var po={preprocess:Fr,embed:Mr,print:ao,massageAstNode:Lr,insertPragma:Or,getVisitorKeys:Pr},qr=po;var Ur=[{name:"YAML",type:"data",aceMode:"yaml",extensions:[".yml",".mir",".reek",".rviz",".sublime-syntax",".syntax",".yaml",".yaml-tmlanguage",".yaml.sed",".yml.mysql"],filenames:[".clang-format",".clang-tidy",".clangd",".gemrc","CITATION.cff","glide.lock","pixi.lock",".prettierrc",".stylelintrc",".lintstagedrc"],tmScope:"source.yaml",aliases:["yml"],codemirrorMode:"yaml",codemirrorMimeType:"text/x-yaml",parsers:["yaml"],vscodeLanguageIds:["yaml","ansible","dockercompose","github-actions-workflow","home-assistant"],linguistLanguageId:407}];var _t={bracketSpacing:{category:"Common",type:"boolean",default:!0,description:"Print spaces between brackets.",oppositeDescription:"Do not print spaces between brackets."},objectWrap:{category:"Common",type:"choice",default:"preserve",description:"How to wrap object literals.",choices:[{value:"preserve",description:"Keep as multi-line, if there is a newline between the opening brace and first property."},{value:"collapse",description:"Fit to a single line when possible."}]},singleQuote:{category:"Common",type:"boolean",default:!1,description:"Use single quotes instead of double quotes."},proseWrap:{category:"Common",type:"choice",default:"preserve",description:"How to wrap prose.",choices:[{value:"always",description:"Wrap prose if it exceeds the print width."},{value:"never",description:"Do not wrap prose."},{value:"preserve",description:"Wrap prose as-is."}]},bracketSameLine:{category:"Common",type:"boolean",default:!1,description:"Put > of opening tags on the last line instead of on a new line."},singleAttributePerLine:{category:"Common",type:"boolean",default:!1,description:"Enforce single attribute per line in HTML, Vue and JSX."}};var mo={bracketSpacing:_t.bracketSpacing,singleQuote:_t.singleQuote,proseWrap:_t.proseWrap},Kr=mo;var rr={};sr(rr,{yaml:()=>Za});var nr=or(Ps(),1);var J=or(vs(),1),vf=J.default.findPair,If=J.default.toJSON,_f=J.default.parseMap,xf=J.default.parseSeq,Rf=J.default.stringifyNumber,Df=J.default.stringifyString,$f=J.default.Type,Yf=J.default.YAMLError,Bf=J.default.YAMLReferenceError,Is=J.default.YAMLSemanticError,Ff=J.default.YAMLSyntaxError,qf=J.default.YAMLWarning;function F(t,e=null){"children"in t&&t.children.forEach(n=>F(n,t)),"anchor"in t&&t.anchor&&F(t.anchor,t),"tag"in t&&t.tag&&F(t.tag,t),"leadingComments"in t&&t.leadingComments.forEach(n=>F(n,t)),"middleComments"in t&&t.middleComments.forEach(n=>F(n,t)),"indicatorComment"in t&&t.indicatorComment&&F(t.indicatorComment,t),"trailingComment"in t&&t.trailingComment&&F(t.trailingComment,t),"endComments"in t&&t.endComments.forEach(n=>F(n,t)),Object.defineProperty(t,"_parent",{value:e,enumerable:!1})}function Oe(t){return`${t.line}:${t.column}`}function _s(t){F(t);let e=xa(t),n=t.children.slice();t.comments.sort((r,s)=>r.position.start.offset-s.position.end.offset).filter(r=>!r._parent).forEach(r=>{for(;n.length>1&&r.position.start.line>n[0].position.end.line;)n.shift();Ra(r,e,n[0])})}function xa(t){let e=Array.from(new Array(t.position.end.line),()=>({}));for(let n of t.comments)e[n.position.start.line-1].comment=n;return xs(e,t),e}function xs(t,e){if(e.position.start.offset!==e.position.end.offset){if("leadingComments"in e){let{start:n}=e.position,{leadingAttachableNode:r}=t[n.line-1];(!r||n.column<r.position.start.column)&&(t[n.line-1].leadingAttachableNode=e)}if("trailingComment"in e&&e.position.end.column>1&&e.type!=="document"&&e.type!=="documentHead"){let{end:n}=e.position,{trailingAttachableNode:r}=t[n.line-1];(!r||n.column>=r.position.end.column)&&(t[n.line-1].trailingAttachableNode=e)}if(e.type!=="root"&&e.type!=="document"&&e.type!=="documentHead"&&e.type!=="documentBody"){let{start:n,end:r}=e.position,s=[r.line].concat(n.line===r.line?[]:n.line);for(let i of s){let o=t[i-1].trailingNode;(!o||r.column>=o.position.end.column)&&(t[i-1].trailingNode=e)}}"children"in e&&e.children.forEach(n=>{xs(t,n)})}}function Ra(t,e,n){let r=t.position.start.line,{trailingAttachableNode:s}=e[r-1];if(s){if(s.trailingComment)throw new Error(`Unexpected multiple trailing comment at ${Oe(t.position.start)}`);F(t,s),s.trailingComment=t;return}for(let o=r;o>=n.position.start.line;o--){let{trailingNode:a}=e[o-1],c;if(a)c=a;else if(o!==r&&e[o-1].comment)c=e[o-1].comment._parent;else continue;if((c.type==="sequence"||c.type==="mapping")&&(c=c.children[0]),c.type==="mappingItem"){let[l,f]=c.children;c=Rs(l)?l:f}for(;;){if(Da(c,t)){F(t,c),c.endComments.push(t);return}if(!c._parent)break;c=c._parent}break}for(let o=r+1;o<=n.position.end.line;o++){let{leadingAttachableNode:a}=e[o-1];if(a){F(t,a),a.leadingComments.push(t);return}}let i=n.children[1];F(t,i),i.endComments.push(t)}function Da(t,e){if(t.position.start.offset<e.position.start.offset&&t.position.end.offset>e.position.end.offset)switch(t.type){case"flowMapping":case"flowSequence":return t.children.length===0||e.position.start.line>t.children[t.children.length-1].position.end.line}if(e.position.end.offset<t.position.end.offset)return!1;switch(t.type){case"sequenceItem":return e.position.start.column>t.position.start.column;case"mappingKey":case"mappingValue":return e.position.start.column>t._parent.position.start.column&&(t.children.length===0||t.children.length===1&&t.children[0].type!=="blockFolded"&&t.children[0].type!=="blockLiteral")&&(t.type==="mappingValue"||Rs(t));default:return!1}}function Rs(t){return t.position.start!==t.position.end&&(t.children.length===0||t.position.start.offset!==t.children[0].position.start.offset)}function b(t,e){return{type:t,position:e}}function Ds(t,e,n){return{...b("root",t),children:e,comments:n}}function pt(t){switch(t.type){case"DOCUMENT":for(let e=t.contents.length-1;e>=0;e--)t.contents[e].type==="BLANK_LINE"?t.contents.splice(e,1):pt(t.contents[e]);for(let e=t.directives.length-1;e>=0;e--)t.directives[e].type==="BLANK_LINE"&&t.directives.splice(e,1);break;case"FLOW_MAP":case"FLOW_SEQ":case"MAP":case"SEQ":for(let e=t.items.length-1;e>=0;e--){let n=t.items[e];"char"in n||(n.type==="BLANK_LINE"?t.items.splice(e,1):pt(n))}break;case"MAP_KEY":case"MAP_VALUE":case"SEQ_ITEM":t.node&&pt(t.node);break;case"ALIAS":case"BLANK_LINE":case"BLOCK_FOLDED":case"BLOCK_LITERAL":case"COMMENT":case"DIRECTIVE":case"PLAIN":case"QUOTE_DOUBLE":case"QUOTE_SINGLE":break;default:throw new Error(`Unexpected node type ${JSON.stringify(t.type)}`)}}function X(t,e){return{start:t,end:e}}function Qn(t){return{start:t,end:t}}var me;(function(t){t.Tag="!",t.Anchor="&",t.Comment="#"})(me||(me={}));function $s(t,e){return{...b("anchor",t),value:e}}function Ke(t,e){return{...b("comment",t),value:e}}function Ys(t,e,n){return{anchor:e,tag:t,middleComments:n}}function Bs(t,e){return{...b("tag",t),value:e}}function Xt(t,e,n=()=>!1){let r=t.cstNode,s=[],i=null,o=null,a=null;for(let c of r.props){let l=e.text[c.origStart];switch(l){case me.Tag:i=i||c,o=Bs(e.transformRange(c),t.tag);break;case me.Anchor:i=i||c,a=$s(e.transformRange(c),r.anchor);break;case me.Comment:{let f=Ke(e.transformRange(c),e.text.slice(c.origStart+1,c.origEnd));e.comments.push(f),!n(f)&&i&&i.origEnd<=c.origStart&&c.origEnd<=r.valueRange.origStart&&s.push(f);break}default:throw new Error(`Unexpected leading character ${JSON.stringify(l)}`)}}return Ys(o,a,s)}function z(){return{leadingComments:[]}}function he(t=null){return{trailingComment:t}}function q(){return{...z(),...he()}}function Fs(t,e,n){return{...b("alias",t),...q(),...e,value:n}}function qs(t,e){let n=t.cstNode;return Fs(e.transformRange({origStart:n.valueRange.origStart-1,origEnd:n.valueRange.origEnd}),e.transformContent(t),n.rawValue)}function Us(t){return{...t,type:"blockFolded"}}function Ks(t,e,n,r,s,i){return{...b("blockValue",t),...z(),...e,chomping:n,indent:r,value:s,indicatorComment:i}}var Gn;(function(t){t.CLIP="clip",t.STRIP="strip",t.KEEP="keep"})(Gn||(Gn={}));function zt(t,e){let n=t.cstNode,r=1,s=n.chomping==="CLIP"?0:1,o=n.header.origEnd-n.header.origStart-r-s!==0,a=e.transformRange({origStart:n.header.origStart,origEnd:n.valueRange.origEnd}),c=null,l=Xt(t,e,f=>{if(!(a.start.offset<f.position.start.offset&&f.position.end.offset<a.end.offset))return!1;if(c)throw new Error(`Unexpected multiple indicator comments at ${Oe(f.position.start)}`);return c=f,!0});return Ks(a,l,Gn[n.chomping],o?n.blockIndent:null,n.strValue,c)}function Ws(t,e){return Us(zt(t,e))}function Vs(t){return{...t,type:"blockLiteral"}}function js(t,e){return Vs(zt(t,e))}function Qs(t,e){return Ke(e.transformRange(t.range),t.comment)}function Gs(t,e,n){return{...b("directive",t),...q(),name:e,parameters:n}}function We(t,e){for(let n of t.props){let r=e.text[n.origStart];switch(r){case me.Comment:e.comments.push(Ke(e.transformRange(n),e.text.slice(n.origStart+1,n.origEnd)));break;default:throw new Error(`Unexpected leading character ${JSON.stringify(r)}`)}}}function Hs(t,e){return We(t,e),Gs(e.transformRange(t.range),t.name,t.parameters)}function Js(t,e,n,r,s,i){return{...b("document",t),...he(i),directivesEndMarker:e,documentEndMarker:n,children:[r,s]}}function U(t=[]){return{endComments:t}}function Xs(t,e,n){return{...b("documentBody",t),...U(n),children:e?[e]:[]}}function K(t){return t[t.length-1]}function Zt(t,e){let n=t.match(e);return n?n.index:-1}function zs(t,e,n){let r=t.cstNode,{comments:s,endComments:i,documentTrailingComment:o,documentHeadTrailingComment:a}=$a(r,e,n),c=e.transformNode(t.contents),{position:l,documentEndPoint:f}=Ya(r,c,e);return e.comments.push(...s,...i),{documentBody:Xs(l,c,i),documentEndPoint:f,documentTrailingComment:o,documentHeadTrailingComment:a}}function $a(t,e,n){let r=[],s=[],i=[],o=[],a=!1;for(let c=t.contents.length-1;c>=0;c--){let l=t.contents[c];if(l.type==="COMMENT"){let f=e.transformNode(l);n&&n.line===f.position.start.line?o.unshift(f):a?r.unshift(f):f.position.start.offset>=t.valueRange.origEnd?i.unshift(f):r.unshift(f)}else a=!0}if(i.length>1)throw new Error(`Unexpected multiple document trailing comments at ${Oe(i[1].position.start)}`);if(o.length>1)throw new Error(`Unexpected multiple documentHead trailing comments at ${Oe(o[1].position.start)}`);return{comments:r,endComments:s,documentTrailingComment:K(i)||null,documentHeadTrailingComment:K(o)||null}}function Ya(t,e,n){let r=Zt(n.text.slice(t.valueRange.origEnd),/^\.\.\./),s=r===-1?t.valueRange.origEnd:Math.max(0,t.valueRange.origEnd-1);n.text[s-1]==="\r"&&s--;let i=n.transformRange({origStart:e!==null?e.position.start.offset:s,origEnd:s}),o=r===-1?i.end:n.transformOffset(t.valueRange.origEnd+3);return{position:i,documentEndPoint:o}}function Zs(t,e,n,r){return{...b("documentHead",t),...U(n),...he(r),children:e}}function ei(t,e){let n=t.cstNode,{directives:r,comments:s,endComments:i}=Ba(n,e),{position:o,documentEndMarkererPoint:a}=Fa(n,r,e);return e.comments.push(...s,...i),{createDocumentHeadWithTrailingComment:l=>(l&&e.comments.push(l),Zs(o,r,i,l)),documentHeadEndMarkerPoint:a}}function Ba(t,e){let n=[],r=[],s=[],i=!1;for(let o=t.directives.length-1;o>=0;o--){let a=e.transformNode(t.directives[o]);a.type==="comment"?i?r.unshift(a):s.unshift(a):(i=!0,n.unshift(a))}return{directives:n,comments:r,endComments:s}}function Fa(t,e,n){let r=Zt(n.text.slice(0,t.valueRange.origStart),/---\s*$/);r>0&&!/[\r\n]/.test(n.text[r-1])&&(r=-1);let s=r===-1?{origStart:t.valueRange.origStart,origEnd:t.valueRange.origStart}:{origStart:r,origEnd:r+3};return e.length!==0&&(s.origStart=e[0].position.start.offset),{position:n.transformRange(s),documentEndMarkererPoint:r===-1?null:n.transformOffset(r)}}function ti(t,e){let{createDocumentHeadWithTrailingComment:n,documentHeadEndMarkerPoint:r}=ei(t,e),{documentBody:s,documentEndPoint:i,documentTrailingComment:o,documentHeadTrailingComment:a}=zs(t,e,r),c=n(a);o&&e.comments.push(o);let l=t.cstNode;return Js(X(c.position.start,i),!!l.directivesEndMarker,!!l.documentEndMarker,c,s,o)}function en(t,e,n){return{...b("flowCollection",t),...q(),...U(),...e,children:n}}function ni(t,e,n){return{...en(t,e,n),type:"flowMapping"}}function tn(t,e,n){return{...b("flowMappingItem",t),...z(),children:[e,n]}}function de(t,e){let n=[];for(let r of t)r&&"type"in r&&r.type==="COMMENT"?e.comments.push(e.transformNode(r)):n.push(r);return n}function nn(t){let[e,n]=["?",":"].map(r=>{let s=t.find(i=>"char"in i&&i.char===r);return s?{origStart:s.origOffset,origEnd:s.origOffset+1}:null});return{additionalKeyRange:e,additionalValueRange:n}}function rn(t,e){let n=e;return r=>t.slice(n,n=r)}function sn(t){let e=[],n=rn(t,1),r=!1;for(let s=1;s<t.length-1;s++){let i=t[s];if("char"in i&&i.char===","){e.push(n(s)),n(s+1),r=!1;continue}r=!0}return r&&e.push(n(t.length-1)),e}function Hn(t,e){return{...b("mappingKey",t),...he(),...U(),children:e?[e]:[]}}function Jn(t,e){return{...b("mappingValue",t),...q(),...U(),children:e?[e]:[]}}function Ve(t,e,n,r,s){let i=e.transformNode(t.key),o=e.transformNode(t.value),a=i||r?Hn(e.transformRange({origStart:r?r.origStart:i.position.start.offset,origEnd:i?i.position.end.offset:r.origStart+1}),i):null,c=o||s?Jn(e.transformRange({origStart:s?s.origStart:o.position.start.offset,origEnd:o?o.position.end.offset:s.origStart+1}),o):null;return n(X(a?a.position.start:c.position.start,c?c.position.end:a.position.end),a||Hn(Qn(c.position.start),null),c||Jn(Qn(a.position.end),null))}function ri(t,e){let n=de(t.cstNode.items,e),r=sn(n),s=t.items.map((a,c)=>{let l=r[c],{additionalKeyRange:f,additionalValueRange:m}=nn(l);return Ve(a,e,tn,f,m)}),i=n[0],o=K(n);return ni(e.transformRange({origStart:i.origOffset,origEnd:o.origOffset+1}),e.transformContent(t),s)}function si(t,e,n){return{...en(t,e,n),type:"flowSequence"}}function ii(t,e){return{...b("flowSequenceItem",t),children:[e]}}function oi(t,e){let n=de(t.cstNode.items,e),r=sn(n),s=t.items.map((a,c)=>{if(a.type!=="PAIR"){let l=e.transformNode(a);return ii(X(l.position.start,l.position.end),l)}else{let l=r[c],{additionalKeyRange:f,additionalValueRange:m}=nn(l);return Ve(a,e,tn,f,m)}}),i=n[0],o=K(n);return si(e.transformRange({origStart:i.origOffset,origEnd:o.origOffset+1}),e.transformContent(t),s)}function ai(t,e,n){return{...b("mapping",t),...z(),...e,children:n}}function ci(t,e,n){return{...b("mappingItem",t),...z(),children:[e,n]}}function li(t,e){let n=t.cstNode;n.items.filter(o=>o.type==="MAP_KEY"||o.type==="MAP_VALUE").forEach(o=>We(o,e));let r=de(n.items,e),s=qa(r),i=t.items.map((o,a)=>{let c=s[a],[l,f]=c[0].type==="MAP_VALUE"?[null,c[0].range]:[c[0].range,c.length===1?null:c[1].range];return Ve(o,e,ci,l,f)});return ai(X(i[0].position.start,K(i).position.end),e.transformContent(t),i)}function qa(t){let e=[],n=rn(t,0),r=!1;for(let s=0;s<t.length;s++){if(t[s].type==="MAP_VALUE"){e.push(n(s+1)),r=!1;continue}r&&e.push(n(s)),r=!0}return r&&e.push(n(1/0)),e}function fi(t,e,n){return{...b("plain",t),...q(),...e,value:n}}function ui(t,e,n){for(let r=e;r>=0;r--)if(n.test(t[r]))return r;return-1}function pi(t,e){let n=t.cstNode;return fi(e.transformRange({origStart:n.valueRange.origStart,origEnd:ui(e.text,n.valueRange.origEnd-1,/\S/)+1}),e.transformContent(t),n.strValue)}function mi(t){return{...t,type:"quoteDouble"}}function hi(t,e,n){return{...b("quoteValue",t),...e,...q(),value:n}}function on(t,e){let n=t.cstNode;return hi(e.transformRange(n.valueRange),e.transformContent(t),n.strValue)}function di(t,e){return mi(on(t,e))}function gi(t){return{...t,type:"quoteSingle"}}function yi(t,e){return gi(on(t,e))}function Ei(t,e,n){return{...b("sequence",t),...z(),...U(),...e,children:n}}function Si(t,e){return{...b("sequenceItem",t),...q(),...U(),children:e?[e]:[]}}function wi(t,e){let r=de(t.cstNode.items,e).map((s,i)=>{We(s,e);let o=e.transformNode(t.items[i]);return Si(X(e.transformOffset(s.valueRange.origStart),o===null?e.transformOffset(s.valueRange.origStart+1):o.position.end),o)});return Ei(X(r[0].position.start,K(r).position.end),e.transformContent(t),r)}function bi(t,e){if(t===null||t.type===void 0&&t.value===null)return null;switch(t.type){case"ALIAS":return qs(t,e);case"BLOCK_FOLDED":return Ws(t,e);case"BLOCK_LITERAL":return js(t,e);case"COMMENT":return Qs(t,e);case"DIRECTIVE":return Hs(t,e);case"DOCUMENT":return ti(t,e);case"FLOW_MAP":return ri(t,e);case"FLOW_SEQ":return oi(t,e);case"MAP":return li(t,e);case"PLAIN":return pi(t,e);case"QUOTE_DOUBLE":return di(t,e);case"QUOTE_SINGLE":return yi(t,e);case"SEQ":return wi(t,e);default:throw new Error(`Unexpected node type ${t.type}`)}}var Xn,zn=class{text;comments=[];#e;#t;constructor(e,n){this.text=n,this.#e=e,this.setOrigRanges()}setOrigRanges(){if(!this.#e.setOrigRanges())for(let e of this.#e)e.setOrigRanges([],0)}#n(e){if(!Xn){let[o]=this.#e,a=Object.getPrototypeOf(Object.getPrototypeOf(o));Xn=Object.getOwnPropertyDescriptor(a,"rangeAsLinePos").get}if(this.#t??(this.#t={root:{context:{src:this.text}}}),this.text===""&&e.origStart===0&&e.origEnd===0)return{start:{offset:0,line:1,column:1},end:{offset:0,line:1,column:1}};let{start:{line:n,col:r},end:{line:s,col:i}}=Xn.call({range:{start:this.#r(e.origStart),end:this.#r(e.origEnd)},context:this.#t});return{start:{offset:e.origStart,line:n,column:r},end:{offset:e.origEnd,line:s,column:i}}}#r(e){return e<0?0:e>this.text.length?this.text.length:e}transformOffset(e){return this.#n({origStart:e,origEnd:e}).start}transformRange(e){let{start:n,end:r}=this.#n(e);return X(n,r)}transformNode(e){return bi(e,this)}transformContent(e){return Xt(e,this)}},Ni=zn;function Oi(t,e,n){let r=new SyntaxError(t);return r.name="YAMLSyntaxError",r.source=e,r.position=n,r}function Ai(t,e){let n=t.source.range||t.source.valueRange;return Oi(t.message,e.text,e.transformRange(n))}function Zn(t){if("children"in t){if(t.children.length===1){let e=t.children[0];if(e.type==="plain"&&e.tag===null&&e.anchor===null&&e.value==="")return t.children.splice(0,1),t}t.children.forEach(Zn)}return t}function er(t,e,n,r){let s=e(t);return i=>{r(s,i)&&n(t,s=i)}}function tr(t){if(t===null||!("children"in t))return;let e=t.children;if(e.forEach(tr),t.type==="document"){let[i,o]=t.children;i.position.start.offset===i.position.end.offset?i.position.start=i.position.end=o.position.start:o.position.start.offset===o.position.end.offset&&(o.position.start=o.position.end=i.position.end)}let n=er(t.position,Ua,Ka,ja),r=er(t.position,Wa,Va,Qa);"endComments"in t&&t.endComments.length!==0&&(n(t.endComments[0].position.start),r(K(t.endComments).position.end));let s=e.filter(i=>i!==null);if(s.length!==0){let i=s[0],o=K(s);n(i.position.start),r(o.position.end),"leadingComments"in i&&i.leadingComments.length!==0&&n(i.leadingComments[0].position.start),"tag"in i&&i.tag&&n(i.tag.position.start),"anchor"in i&&i.anchor&&n(i.anchor.position.start),"trailingComment"in o&&o.trailingComment&&r(o.trailingComment.position.end)}}function Ua(t){return t.start}function Ka(t,e){t.start=e}function Wa(t){return t.end}function Va(t,e){t.end=e}function ja(t,e){return e.offset<t.offset}function Qa(t,e){return e.offset>t.offset}var Li='Map keys must be unique; "',Ti='" is repeated',Ga=`${Li}<<${Ti}`;function Ha(t,e){if(!(t instanceof Is))return!1;let{message:n}=t;return n===Ga||e&&n.startsWith(Li)&&n.endsWith(Ti)}function Mi(t,e){let n=e?.allowDuplicateKeysInMap,r=nr.default.parseCST(t),s=new Ni(r,t),i=[];for(let a of r){let c=new nr.default.Document({merge:!1,keepCstNodes:!0}).parse(a);for(let f of c.errors)if(!Ha(f,n))throw Ai(f,s);pt(c.cstNode);let l=s.transformNode(c);i.push(l)}let o=Ds(s.transformRange({origStart:0,origEnd:t.length}),i,s.comments);return _s(o),tr(o),Zn(o),o}function Ja(t,e){let n=new SyntaxError(t+" ("+e.loc.start.line+":"+e.loc.start.column+")");return Object.assign(n,e)}var Ci=Ja;var Xa={allowDuplicateKeysInMap:!0};function za(t){try{let e=Mi(t,Xa);return delete e.comments,e}catch(e){throw e?.position?Ci(e.message,{loc:e.position,cause:e}):e}}var Za={astFormat:"yaml",parse:za,hasPragma:br,hasIgnorePragma:Nr,locStart:tt,locEnd:vr};var ec={yaml:qr};return Ri(tc);});
|
|
162
|
+
`);case"always":return!/[\n ]/.test(t.value);default:return!1}}function ro(t){return t.key.content?.type==="alias"}function so(t){if(!t)return!0;switch(t.type){case"plain":case"quoteDouble":case"quoteSingle":return t.position.start.line===t.position.end.line;case"alias":return!0;default:return!1}}var Br=no;function io(t){return dn(t,oo)}function oo(t){switch(t.type){case"document":Ie(t,"head",()=>t.children[0]),Ie(t,"body",()=>t.children[1]);break;case"documentBody":case"sequenceItem":case"flowSequenceItem":case"mappingKey":case"mappingValue":Ie(t,"content",()=>t.children[0]);break;case"mappingItem":case"flowMappingItem":Ie(t,"key",()=>t.children[0]),Ie(t,"value",()=>t.children[1]);break}return t}var Fr=io;function ao(t,e,n){let{node:r}=t,s=[];r.type!=="mappingValue"&&te(r)&&s.push([v(N,t.map(n,"leadingComments")),N]);let{tag:i,anchor:o}=r;i&&s.push(n("tag")),i&&o&&s.push(" "),o&&s.push(n("anchor"));let a="";return W(r,["mapping","sequence","comment","directive","mappingItem","sequenceItem"])&&!Ct(t)&&(a=Pt(t,e.originalText)),(i||o)&&(W(r,["sequence","mapping"])&&!ae(r)?s.push(N):s.push(" ")),ae(r)&&s.push([r.middleComments.length===1?"":N,v(N,t.map(n,"middleComments")),N]),xr(t)?s.push(cr(e.originalText.slice(r.position.start.offset,r.position.end.offset).trimEnd())):s.push(Pe(co(t,e,n))),V(r)&&!W(r,["document","documentHead"])&&s.push(mr([r.type==="mappingValue"&&!r.content?"":" ",t.parent.type==="mappingKey"&&t.getParentNode(2).type==="mapping"&&nt(r)?"":Xe,n("trailingComment")])),En(r)&&s.push(_(r.type==="sequenceItem"?2:0,[N,v(N,t.map(({node:c})=>[pn(e.originalText,tt(c))?N:"",n()],"endComments"))])),s.push(a),s}function co(t,e,n){let{node:r}=t;switch(r.type){case"root":{let s=kt(r),i=!(W(s,["blockLiteral","blockFolded"])&&s.chomping==="keep"),o=[];return t.each(({node:a,isFirst:c})=>{c||o.push(N),o.push(n()),fo(t)&&(i&&o.push(N),o.push("..."),V(a)&&o.push(" ",n("trailingComment")))},"children"),i&&o.push(N),o}case"document":{let s=[];return uo(t)&&((r.head.children.length>0||r.head.endComments.length>0)&&s.push(n("head")),V(r.head)?s.push(["---"," ",n(["head","trailingComment"])]):s.push("---")),lo(r)&&s.push(n("body")),v(N,s)}case"documentHead":return v(N,[...t.map(n,"children"),...t.map(n,"endComments")]);case"documentBody":{let{children:s,endComments:i}=r,o="";if(s.length>0&&i.length>0){let a=kt(r);if(W(a,["blockFolded","blockLiteral"]))a.chomping!=="keep"&&(o=[N,N]);else{let c=D(0,s,-1);o=W(c,["mapping"])&&pn(e.originalText,tt(i[0]))?[N,N]:N}}return[v(N,t.map(n,"children")),o,v(N,t.map(n,"endComments"))]}case"directive":return["%",v(" ",[r.name,...r.parameters])];case"comment":return["#",r.value];case"alias":return["*",r.value];case"tag":return e.originalText.slice(r.position.start.offset,r.position.end.offset);case"anchor":return["&",r.value];case"plain":return rt(r.type,e.originalText.slice(r.position.start.offset,r.position.end.offset),e);case"quoteDouble":case"quoteSingle":{let o=e.originalText.slice(r.position.start.offset+1,r.position.end.offset-1);if(r.type==="quoteSingle"&&o.includes("\\")||r.type==="quoteDouble"&&/\\[^"]/.test(o)){let c=r.type==="quoteDouble"?'"':"'";return[c,rt(r.type,o,e),c]}if(o.includes('"'))return["'",rt(r.type,r.type==="quoteDouble"?dt(0,dt(0,o,'\\"','"'),"'","'".repeat(2)):o,e),"'"];if(o.includes("'"))return['"',rt(r.type,r.type==="quoteSingle"?dt(0,o,"''","'"):o,e),'"'];let a=e.singleQuote?"'":'"';return[a,rt(r.type,o,e),a]}case"blockFolded":case"blockLiteral":return Yr(t,e,n);case"mapping":case"sequence":return v(N,t.map(n,"children"));case"sequenceItem":return["- ",_(2,r.content?n("content"):"")];case"mappingKey":case"mappingValue":return r.content?n("content"):"";case"mappingItem":case"flowMappingItem":return Br(t,e,n);case"flowMapping":return vt(t,e,n);case"flowSequence":return vt(t,e,n);case"flowSequenceItem":return n("content");default:throw new dr(r,"YAML")}}function lo(t){return t.body.children.length>0||I(t.body)}function fo(t){let e=t.node;if(e.documentEndMarker||V(e))return!0;if(t.isLast)return!1;let n=t.next;return n.head.children.length>0||I(n.head)}function uo(t){let e=t.node;return e.directivesEndMarker||e.head.children.length>0||I(e.head)||V(e.head)}function rt(t,e,n){let r=Dr(t,e,n);return v(N,r.map(s=>Lt(v(se,s))))}var po={preprocess:Fr,embed:Mr,print:ao,massageAstNode:Lr,insertPragma:Or,getVisitorKeys:Pr},qr=po;var Ur=[{name:"YAML",type:"data",aceMode:"yaml",extensions:[".yml",".mir",".reek",".rviz",".sublime-syntax",".syntax",".yaml",".yaml-tmlanguage",".yaml.sed",".yml.mysql"],filenames:[".clang-format",".clang-tidy",".clangd",".gemrc","CITATION.cff","glide.lock","pixi.lock",".prettierrc",".stylelintrc",".lintstagedrc"],tmScope:"source.yaml",aliases:["yml"],codemirrorMode:"yaml",codemirrorMimeType:"text/x-yaml",parsers:["yaml"],vscodeLanguageIds:["yaml","ansible","dockercompose","github-actions-workflow","home-assistant"],linguistLanguageId:407}];var _t={bracketSpacing:{category:"Common",type:"boolean",default:!0,description:"Print spaces between brackets.",oppositeDescription:"Do not print spaces between brackets."},objectWrap:{category:"Common",type:"choice",default:"preserve",description:"How to wrap object literals.",choices:[{value:"preserve",description:"Keep as multi-line, if there is a newline between the opening brace and first property."},{value:"collapse",description:"Fit to a single line when possible."}]},singleQuote:{category:"Common",type:"boolean",default:!1,description:"Use single quotes instead of double quotes."},proseWrap:{category:"Common",type:"choice",default:"preserve",description:"How to wrap prose.",choices:[{value:"always",description:"Wrap prose if it exceeds the print width."},{value:"never",description:"Do not wrap prose."},{value:"preserve",description:"Wrap prose as-is."}]},bracketSameLine:{category:"Common",type:"boolean",default:!1,description:"Put > of opening tags on the last line instead of on a new line."},singleAttributePerLine:{category:"Common",type:"boolean",default:!1,description:"Enforce single attribute per line in HTML, Vue and JSX."}};var mo={bracketSpacing:_t.bracketSpacing,singleQuote:_t.singleQuote,proseWrap:_t.proseWrap},Kr=mo;var rr={};sr(rr,{yaml:()=>Za});var nr=or(Ps(),1);var J=or(vs(),1),vf=J.default.findPair,If=J.default.toJSON,_f=J.default.parseMap,xf=J.default.parseSeq,Rf=J.default.stringifyNumber,Df=J.default.stringifyString,$f=J.default.Type,Yf=J.default.YAMLError,Bf=J.default.YAMLReferenceError,Is=J.default.YAMLSemanticError,Ff=J.default.YAMLSyntaxError,qf=J.default.YAMLWarning;function F(t,e=null){"children"in t&&t.children.forEach(n=>F(n,t)),"anchor"in t&&t.anchor&&F(t.anchor,t),"tag"in t&&t.tag&&F(t.tag,t),"leadingComments"in t&&t.leadingComments.forEach(n=>F(n,t)),"middleComments"in t&&t.middleComments.forEach(n=>F(n,t)),"indicatorComment"in t&&t.indicatorComment&&F(t.indicatorComment,t),"trailingComment"in t&&t.trailingComment&&F(t.trailingComment,t),"endComments"in t&&t.endComments.forEach(n=>F(n,t)),Object.defineProperty(t,"_parent",{value:e,enumerable:!1})}function Oe(t){return`${t.line}:${t.column}`}function _s(t){F(t);let e=xa(t),n=t.children.slice();t.comments.sort((r,s)=>r.position.start.offset-s.position.end.offset).filter(r=>!r._parent).forEach(r=>{for(;n.length>1&&r.position.start.line>n[0].position.end.line;)n.shift();Ra(r,e,n[0])})}function xa(t){let e=Array.from(new Array(t.position.end.line),()=>({}));for(let n of t.comments)e[n.position.start.line-1].comment=n;return xs(e,t),e}function xs(t,e){if(e.position.start.offset!==e.position.end.offset){if("leadingComments"in e){let{start:n}=e.position,{leadingAttachableNode:r}=t[n.line-1];(!r||n.column<r.position.start.column)&&(t[n.line-1].leadingAttachableNode=e)}if("trailingComment"in e&&e.position.end.column>1&&e.type!=="document"&&e.type!=="documentHead"){let{end:n}=e.position,{trailingAttachableNode:r}=t[n.line-1];(!r||n.column>=r.position.end.column)&&(t[n.line-1].trailingAttachableNode=e)}if(e.type!=="root"&&e.type!=="document"&&e.type!=="documentHead"&&e.type!=="documentBody"){let{start:n,end:r}=e.position,s=[r.line].concat(n.line===r.line?[]:n.line);for(let i of s){let o=t[i-1].trailingNode;(!o||r.column>=o.position.end.column)&&(t[i-1].trailingNode=e)}}"children"in e&&e.children.forEach(n=>{xs(t,n)})}}function Ra(t,e,n){let r=t.position.start.line,{trailingAttachableNode:s}=e[r-1];if(s){if(s.trailingComment)throw new Error(`Unexpected multiple trailing comment at ${Oe(t.position.start)}`);F(t,s),s.trailingComment=t;return}for(let o=r;o>=n.position.start.line;o--){let{trailingNode:a}=e[o-1],c;if(a)c=a;else if(o!==r&&e[o-1].comment)c=e[o-1].comment._parent;else continue;if((c.type==="sequence"||c.type==="mapping")&&(c=c.children[0]),c.type==="mappingItem"){let[l,f]=c.children;c=Rs(l)?l:f}for(;;){if(Da(c,t)){F(t,c),c.endComments.push(t);return}if(!c._parent)break;c=c._parent}break}for(let o=r+1;o<=n.position.end.line;o++){let{leadingAttachableNode:a}=e[o-1];if(a){F(t,a),a.leadingComments.push(t);return}}let i=n.children[1];F(t,i),i.endComments.push(t)}function Da(t,e){if(t.position.start.offset<e.position.start.offset&&t.position.end.offset>e.position.end.offset)switch(t.type){case"flowMapping":case"flowSequence":return t.children.length===0||e.position.start.line>t.children[t.children.length-1].position.end.line}if(e.position.end.offset<t.position.end.offset)return!1;switch(t.type){case"sequenceItem":return e.position.start.column>t.position.start.column;case"mappingKey":case"mappingValue":return e.position.start.column>t._parent.position.start.column&&(t.children.length===0||t.children.length===1&&t.children[0].type!=="blockFolded"&&t.children[0].type!=="blockLiteral")&&(t.type==="mappingValue"||Rs(t));default:return!1}}function Rs(t){return t.position.start!==t.position.end&&(t.children.length===0||t.position.start.offset!==t.children[0].position.start.offset)}function b(t,e){return{type:t,position:e}}function Ds(t,e,n){return{...b("root",t),children:e,comments:n}}function pt(t){switch(t.type){case"DOCUMENT":for(let e=t.contents.length-1;e>=0;e--)t.contents[e].type==="BLANK_LINE"?t.contents.splice(e,1):pt(t.contents[e]);for(let e=t.directives.length-1;e>=0;e--)t.directives[e].type==="BLANK_LINE"&&t.directives.splice(e,1);break;case"FLOW_MAP":case"FLOW_SEQ":case"MAP":case"SEQ":for(let e=t.items.length-1;e>=0;e--){let n=t.items[e];"char"in n||(n.type==="BLANK_LINE"?t.items.splice(e,1):pt(n))}break;case"MAP_KEY":case"MAP_VALUE":case"SEQ_ITEM":t.node&&pt(t.node);break;case"ALIAS":case"BLANK_LINE":case"BLOCK_FOLDED":case"BLOCK_LITERAL":case"COMMENT":case"DIRECTIVE":case"PLAIN":case"QUOTE_DOUBLE":case"QUOTE_SINGLE":break;default:throw new Error(`Unexpected node type ${JSON.stringify(t.type)}`)}}function X(t,e){return{start:t,end:e}}function Qn(t){return{start:t,end:t}}var me;(function(t){t.Tag="!",t.Anchor="&",t.Comment="#"})(me||(me={}));function $s(t,e){return{...b("anchor",t),value:e}}function Ke(t,e){return{...b("comment",t),value:e}}function Ys(t,e,n){return{anchor:e,tag:t,middleComments:n}}function Bs(t,e){return{...b("tag",t),value:e}}function Xt(t,e,n=()=>!1){let r=t.cstNode,s=[],i=null,o=null,a=null;for(let c of r.props){let l=e.text[c.origStart];switch(l){case me.Tag:i=i||c,o=Bs(e.transformRange(c),t.tag);break;case me.Anchor:i=i||c,a=$s(e.transformRange(c),r.anchor);break;case me.Comment:{let f=Ke(e.transformRange(c),e.text.slice(c.origStart+1,c.origEnd));e.comments.push(f),!n(f)&&i&&i.origEnd<=c.origStart&&c.origEnd<=r.valueRange.origStart&&s.push(f);break}default:throw new Error(`Unexpected leading character ${JSON.stringify(l)}`)}}return Ys(o,a,s)}function z(){return{leadingComments:[]}}function he(t=null){return{trailingComment:t}}function q(){return{...z(),...he()}}function Fs(t,e,n){return{...b("alias",t),...q(),...e,value:n}}function qs(t,e){let n=t.cstNode;return Fs(e.transformRange({origStart:n.valueRange.origStart-1,origEnd:n.valueRange.origEnd}),e.transformContent(t),n.rawValue)}function Us(t){return{...t,type:"blockFolded"}}function Ks(t,e,n,r,s,i){return{...b("blockValue",t),...z(),...e,chomping:n,indent:r,value:s,indicatorComment:i}}var Gn;(function(t){t.CLIP="clip",t.STRIP="strip",t.KEEP="keep"})(Gn||(Gn={}));function zt(t,e){let n=t.cstNode,r=1,s=n.chomping==="CLIP"?0:1,o=n.header.origEnd-n.header.origStart-r-s!==0,a=e.transformRange({origStart:n.header.origStart,origEnd:n.valueRange.origEnd}),c=null,l=Xt(t,e,f=>{if(!(a.start.offset<f.position.start.offset&&f.position.end.offset<a.end.offset))return!1;if(c)throw new Error(`Unexpected multiple indicator comments at ${Oe(f.position.start)}`);return c=f,!0});return Ks(a,l,Gn[n.chomping],o?n.blockIndent:null,n.strValue,c)}function Ws(t,e){return Us(zt(t,e))}function Vs(t){return{...t,type:"blockLiteral"}}function js(t,e){return Vs(zt(t,e))}function Qs(t,e){return Ke(e.transformRange(t.range),t.comment)}function Gs(t,e,n){return{...b("directive",t),...q(),name:e,parameters:n}}function We(t,e){for(let n of t.props){let r=e.text[n.origStart];if(r===me.Comment)e.comments.push(Ke(e.transformRange(n),e.text.slice(n.origStart+1,n.origEnd)));else throw new Error(`Unexpected leading character ${JSON.stringify(r)}`)}}function Hs(t,e){return We(t,e),Gs(e.transformRange(t.range),t.name,t.parameters)}function Js(t,e,n,r,s,i){return{...b("document",t),...he(i),directivesEndMarker:e,documentEndMarker:n,children:[r,s]}}function U(t=[]){return{endComments:t}}function Xs(t,e,n){return{...b("documentBody",t),...U(n),children:e?[e]:[]}}function K(t){return t[t.length-1]}function Zt(t,e){let n=t.match(e);return n?n.index:-1}function zs(t,e,n){let r=t.cstNode,{comments:s,endComments:i,documentTrailingComment:o,documentHeadTrailingComment:a}=$a(r,e,n),c=e.transformNode(t.contents),{position:l,documentEndPoint:f}=Ya(r,c,e);return e.comments.push(...s,...i),{documentBody:Xs(l,c,i),documentEndPoint:f,documentTrailingComment:o,documentHeadTrailingComment:a}}function $a(t,e,n){let r=[],s=[],i=[],o=[],a=!1;for(let c=t.contents.length-1;c>=0;c--){let l=t.contents[c];if(l.type==="COMMENT"){let f=e.transformNode(l);n&&n.line===f.position.start.line?o.unshift(f):a?r.unshift(f):f.position.start.offset>=t.valueRange.origEnd?i.unshift(f):r.unshift(f)}else a=!0}if(i.length>1)throw new Error(`Unexpected multiple document trailing comments at ${Oe(i[1].position.start)}`);if(o.length>1)throw new Error(`Unexpected multiple documentHead trailing comments at ${Oe(o[1].position.start)}`);return{comments:r,endComments:s,documentTrailingComment:K(i)||null,documentHeadTrailingComment:K(o)||null}}function Ya(t,e,n){let r=Zt(n.text.slice(t.valueRange.origEnd),/^\.\.\./),s=r===-1?t.valueRange.origEnd:Math.max(0,t.valueRange.origEnd-1);n.text[s-1]==="\r"&&s--;let i=n.transformRange({origStart:e!==null?e.position.start.offset:s,origEnd:s}),o=r===-1?i.end:n.transformOffset(t.valueRange.origEnd+3);return{position:i,documentEndPoint:o}}function Zs(t,e,n,r){return{...b("documentHead",t),...U(n),...he(r),children:e}}function ei(t,e){let n=t.cstNode,{directives:r,comments:s,endComments:i}=Ba(n,e),{position:o,documentEndMarkererPoint:a}=Fa(n,r,e);return e.comments.push(...s,...i),{createDocumentHeadWithTrailingComment:l=>(l&&e.comments.push(l),Zs(o,r,i,l)),documentHeadEndMarkerPoint:a}}function Ba(t,e){let n=[],r=[],s=[],i=!1;for(let o=t.directives.length-1;o>=0;o--){let a=e.transformNode(t.directives[o]);a.type==="comment"?i?r.unshift(a):s.unshift(a):(i=!0,n.unshift(a))}return{directives:n,comments:r,endComments:s}}function Fa(t,e,n){let r=Zt(n.text.slice(0,t.valueRange.origStart),/---\s*$/);r>0&&!/[\r\n]/.test(n.text[r-1])&&(r=-1);let s=r===-1?{origStart:t.valueRange.origStart,origEnd:t.valueRange.origStart}:{origStart:r,origEnd:r+3};return e.length!==0&&(s.origStart=e[0].position.start.offset),{position:n.transformRange(s),documentEndMarkererPoint:r===-1?null:n.transformOffset(r)}}function ti(t,e){let{createDocumentHeadWithTrailingComment:n,documentHeadEndMarkerPoint:r}=ei(t,e),{documentBody:s,documentEndPoint:i,documentTrailingComment:o,documentHeadTrailingComment:a}=zs(t,e,r),c=n(a);o&&e.comments.push(o);let l=t.cstNode;return Js(X(c.position.start,i),!!l.directivesEndMarker,!!l.documentEndMarker,c,s,o)}function en(t,e,n){return{...b("flowCollection",t),...q(),...U(),...e,children:n}}function ni(t,e,n){return{...en(t,e,n),type:"flowMapping"}}function tn(t,e,n){return{...b("flowMappingItem",t),...z(),children:[e,n]}}function de(t,e){let n=[];for(let r of t)r&&"type"in r&&r.type==="COMMENT"?e.comments.push(e.transformNode(r)):n.push(r);return n}function nn(t){let[e,n]=["?",":"].map(r=>{let s=t.find(i=>"char"in i&&i.char===r);return s?{origStart:s.origOffset,origEnd:s.origOffset+1}:null});return{additionalKeyRange:e,additionalValueRange:n}}function rn(t,e){let n=e;return r=>t.slice(n,n=r)}function sn(t){let e=[],n=rn(t,1),r=!1;for(let s=1;s<t.length-1;s++){let i=t[s];if("char"in i&&i.char===","){e.push(n(s)),n(s+1),r=!1;continue}r=!0}return r&&e.push(n(t.length-1)),e}function Hn(t,e){return{...b("mappingKey",t),...he(),...U(),children:e?[e]:[]}}function Jn(t,e){return{...b("mappingValue",t),...q(),...U(),children:e?[e]:[]}}function Ve(t,e,n,r,s){let i=e.transformNode(t.key),o=e.transformNode(t.value),a=i||r?Hn(e.transformRange({origStart:r?r.origStart:i.position.start.offset,origEnd:i?i.position.end.offset:r.origStart+1}),i):null,c=o||s?Jn(e.transformRange({origStart:s?s.origStart:o.position.start.offset,origEnd:o?o.position.end.offset:s.origStart+1}),o):null;return n(X(a?a.position.start:c.position.start,c?c.position.end:a.position.end),a||Hn(Qn(c.position.start),null),c||Jn(Qn(a.position.end),null))}function ri(t,e){let n=de(t.cstNode.items,e),r=sn(n),s=t.items.map((a,c)=>{let l=r[c],{additionalKeyRange:f,additionalValueRange:m}=nn(l);return Ve(a,e,tn,f,m)}),i=n[0],o=K(n);return ni(e.transformRange({origStart:i.origOffset,origEnd:o.origOffset+1}),e.transformContent(t),s)}function si(t,e,n){return{...en(t,e,n),type:"flowSequence"}}function ii(t,e){return{...b("flowSequenceItem",t),children:[e]}}function oi(t,e){let n=de(t.cstNode.items,e),r=sn(n),s=t.items.map((a,c)=>{if(a.type!=="PAIR"){let l=e.transformNode(a);return ii(X(l.position.start,l.position.end),l)}else{let l=r[c],{additionalKeyRange:f,additionalValueRange:m}=nn(l);return Ve(a,e,tn,f,m)}}),i=n[0],o=K(n);return si(e.transformRange({origStart:i.origOffset,origEnd:o.origOffset+1}),e.transformContent(t),s)}function ai(t,e,n){return{...b("mapping",t),...z(),...e,children:n}}function ci(t,e,n){return{...b("mappingItem",t),...z(),children:[e,n]}}function li(t,e){let n=t.cstNode;n.items.filter(o=>o.type==="MAP_KEY"||o.type==="MAP_VALUE").forEach(o=>We(o,e));let r=de(n.items,e),s=qa(r),i=t.items.map((o,a)=>{let c=s[a],[l,f]=c[0].type==="MAP_VALUE"?[null,c[0].range]:[c[0].range,c.length===1?null:c[1].range];return Ve(o,e,ci,l,f)});return ai(X(i[0].position.start,K(i).position.end),e.transformContent(t),i)}function qa(t){let e=[],n=rn(t,0),r=!1;for(let s=0;s<t.length;s++){if(t[s].type==="MAP_VALUE"){e.push(n(s+1)),r=!1;continue}r&&e.push(n(s)),r=!0}return r&&e.push(n(1/0)),e}function fi(t,e,n){return{...b("plain",t),...q(),...e,value:n}}function ui(t,e,n){for(let r=e;r>=0;r--)if(n.test(t[r]))return r;return-1}function pi(t,e){let n=t.cstNode;return fi(e.transformRange({origStart:n.valueRange.origStart,origEnd:ui(e.text,n.valueRange.origEnd-1,/\S/)+1}),e.transformContent(t),n.strValue)}function mi(t){return{...t,type:"quoteDouble"}}function hi(t,e,n){return{...b("quoteValue",t),...e,...q(),value:n}}function on(t,e){let n=t.cstNode;return hi(e.transformRange(n.valueRange),e.transformContent(t),n.strValue)}function di(t,e){return mi(on(t,e))}function gi(t){return{...t,type:"quoteSingle"}}function yi(t,e){return gi(on(t,e))}function Ei(t,e,n){return{...b("sequence",t),...z(),...U(),...e,children:n}}function Si(t,e){return{...b("sequenceItem",t),...q(),...U(),children:e?[e]:[]}}function wi(t,e){let r=de(t.cstNode.items,e).map((s,i)=>{We(s,e);let o=e.transformNode(t.items[i]);return Si(X(e.transformOffset(s.valueRange.origStart),o===null?e.transformOffset(s.valueRange.origStart+1):o.position.end),o)});return Ei(X(r[0].position.start,K(r).position.end),e.transformContent(t),r)}function bi(t,e){if(t===null||t.type===void 0&&t.value===null)return null;switch(t.type){case"ALIAS":return qs(t,e);case"BLOCK_FOLDED":return Ws(t,e);case"BLOCK_LITERAL":return js(t,e);case"COMMENT":return Qs(t,e);case"DIRECTIVE":return Hs(t,e);case"DOCUMENT":return ti(t,e);case"FLOW_MAP":return ri(t,e);case"FLOW_SEQ":return oi(t,e);case"MAP":return li(t,e);case"PLAIN":return pi(t,e);case"QUOTE_DOUBLE":return di(t,e);case"QUOTE_SINGLE":return yi(t,e);case"SEQ":return wi(t,e);default:throw new Error(`Unexpected node type ${t.type}`)}}var Xn,zn=class{text;comments=[];#e;#t;constructor(e,n){this.text=n,this.#e=e,this.setOrigRanges()}setOrigRanges(){if(!this.#e.setOrigRanges())for(let e of this.#e)e.setOrigRanges([],0)}#n(e){if(!Xn){let[o]=this.#e,a=Object.getPrototypeOf(Object.getPrototypeOf(o));Xn=Object.getOwnPropertyDescriptor(a,"rangeAsLinePos").get}if(this.#t??(this.#t={root:{context:{src:this.text}}}),this.text===""&&e.origStart===0&&e.origEnd===0)return{start:{offset:0,line:1,column:1},end:{offset:0,line:1,column:1}};let{start:{line:n,col:r},end:{line:s,col:i}}=Xn.call({range:{start:this.#r(e.origStart),end:this.#r(e.origEnd)},context:this.#t});return{start:{offset:e.origStart,line:n,column:r},end:{offset:e.origEnd,line:s,column:i}}}#r(e){return e<0?0:e>this.text.length?this.text.length:e}transformOffset(e){return this.#n({origStart:e,origEnd:e}).start}transformRange(e){let{start:n,end:r}=this.#n(e);return X(n,r)}transformNode(e){return bi(e,this)}transformContent(e){return Xt(e,this)}},Ni=zn;function Oi(t,e,n){let r=new SyntaxError(t);return r.name="YAMLSyntaxError",r.source=e,r.position=n,r}function Ai(t,e){let n=t.source.range||t.source.valueRange;return Oi(t.message,e.text,e.transformRange(n))}function Zn(t){if("children"in t){if(t.children.length===1){let e=t.children[0];if(e.type==="plain"&&e.tag===null&&e.anchor===null&&e.value==="")return t.children.splice(0,1),t}t.children.forEach(Zn)}return t}function er(t,e,n,r){let s=e(t);return i=>{r(s,i)&&n(t,s=i)}}function tr(t){if(t===null||!("children"in t))return;let e=t.children;if(e.forEach(tr),t.type==="document"){let[i,o]=t.children;i.position.start.offset===i.position.end.offset?i.position.start=i.position.end=o.position.start:o.position.start.offset===o.position.end.offset&&(o.position.start=o.position.end=i.position.end)}let n=er(t.position,Ua,Ka,ja),r=er(t.position,Wa,Va,Qa);"endComments"in t&&t.endComments.length!==0&&(n(t.endComments[0].position.start),r(K(t.endComments).position.end));let s=e.filter(i=>i!==null);if(s.length!==0){let i=s[0],o=K(s);n(i.position.start),r(o.position.end),"leadingComments"in i&&i.leadingComments.length!==0&&n(i.leadingComments[0].position.start),"tag"in i&&i.tag&&n(i.tag.position.start),"anchor"in i&&i.anchor&&n(i.anchor.position.start),"trailingComment"in o&&o.trailingComment&&r(o.trailingComment.position.end)}}function Ua(t){return t.start}function Ka(t,e){t.start=e}function Wa(t){return t.end}function Va(t,e){t.end=e}function ja(t,e){return e.offset<t.offset}function Qa(t,e){return e.offset>t.offset}var Li='Map keys must be unique; "',Ti='" is repeated',Ga=`${Li}<<${Ti}`;function Ha(t,e){if(!(t instanceof Is))return!1;let{message:n}=t;return n===Ga||e&&n.startsWith(Li)&&n.endsWith(Ti)}function Mi(t,e){let n=e?.allowDuplicateKeysInMap,r=nr.default.parseCST(t),s=new Ni(r,t),i=[];for(let a of r){let c=new nr.default.Document({merge:!1,keepCstNodes:!0}).parse(a);for(let f of c.errors)if(!Ha(f,n))throw Ai(f,s);pt(c.cstNode);let l=s.transformNode(c);i.push(l)}let o=Ds(s.transformRange({origStart:0,origEnd:t.length}),i,s.comments);return _s(o),tr(o),Zn(o),o}function Ja(t,e){let n=new SyntaxError(t+" ("+e.loc.start.line+":"+e.loc.start.column+")");return Object.assign(n,e)}var Ci=Ja;var Xa={allowDuplicateKeysInMap:!0};function za(t){try{let e=Mi(t,Xa);return delete e.comments,e}catch(e){throw e?.position?Ci(e.message,{loc:e.position,cause:e}):e}}var Za={astFormat:"yaml",parse:za,hasPragma:br,hasIgnorePragma:Nr,locStart:tt,locEnd:vr};var ec={yaml:qr};return Ri(tc);});
|
package/plugins/yaml.mjs
CHANGED
|
@@ -159,4 +159,4 @@ ${t}`;function Ar(t,e){switch(t.type){case"comment":if(wr(t.value))return null;b
|
|
|
159
159
|
`).map((i,o,a)=>o===0&&o===a.length-1?i:o!==0&&o!==a.length-1?i.trim():o===0?i.trimEnd():i.trimStart());if(n.proseWrap==="preserve")return r.map(i=>i?[i]:[]);let s=[];for(let[i,o]of r.entries()){let a=Rr(o);i>0&&r[i-1].length>0&&a.length>0&&!(t==="quoteDouble"&&D(0,D(0,s,-1),-1).endsWith("\\"))?s[s.length-1]=[...D(0,s,-1),...a]:s.push(a)}return n.proseWrap==="never"?s.map(i=>[i.join(" ")]):s}function $r(t,{parentIndent:e,isLastDescendant:n,options:r}){let s=t.position.start.line===t.position.end.line?"":r.originalText.slice(t.position.start.offset,t.position.end.offset).match(/^[^\n]*\n(.*)$/s)[1];if(s==="")return[];let i;if(t.indent===null){let l=s.match(/^(?<leadingSpace> *)[^\n\r ]/m);i=l?l.groups.leadingSpace.length:Number.POSITIVE_INFINITY}else i=t.indent-1+e;let o=s.split(`
|
|
160
160
|
`).map(l=>l.slice(i));if(r.proseWrap==="preserve"||t.type==="blockLiteral")return c(o.map(l=>l?[l]:[]));let a=[];for(let[l,f]of o.entries()){let m=Rr(f);l>0&&m.length>0&&o[l-1].length>0&&!/^\s/.test(m[0])&&!/^\s|\s$/.test(D(0,a,-1))?a[a.length-1]=[...D(0,a,-1),...m]:a.push(m)}return a=a.map(l=>{let f=[];for(let m of l)f.length>0&&/\s$/.test(D(0,f,-1))?f[f.length-1]+=" "+m:f.push(m);return f}),r.proseWrap==="never"&&(a=a.map(l=>[l.join(" ")])),c(a);function c(l){if(t.chomping==="keep")return s.endsWith(`
|
|
161
161
|
`)&&D(0,l,-1).length===0?l.slice(0,-1):l;let f=0;for(let m=l.length-1;m>=0&&l[m].every(g=>g.replace(/[ \t]+$/,"")==="");m--)f++;return f===0?l:f>=2&&!n?l.slice(0,-(f-1)):l.slice(0,-f)}}function nt(t){if(!t)return!0;switch(t.type){case"plain":case"quoteDouble":case"quoteSingle":case"alias":case"flowMapping":case"flowSequence":return!0;default:return!1}}var En=new WeakMap;function kt(t,e){let{node:n,root:r}=t,s;return En.has(r)?s=En.get(r):(s=new Set,En.set(r,s)),!s.has(n.position.end.line)&&(s.add(n.position.end.line),_r(n,e)&&!Sn(t.parent))?Lt:""}function Sn(t){return I(t)&&!W(t,["documentHead","documentBody","flowMapping","flowSequence"])}function _(t,e){return Je(" ".repeat(t),e)}function to(t,e,n){let{node:r}=t,s=t.ancestors.filter(l=>l.type==="sequence"||l.type==="mapping").length,i=Mt(t),o=[r.type==="blockFolded"?">":"|"];r.indent!==null&&o.push(r.indent.toString()),r.chomping!=="clip"&&o.push(r.chomping==="keep"?"+":"-"),yn(r)&&o.push(" ",n("indicatorComment"));let a=$r(r,{parentIndent:s,isLastDescendant:i,options:e}),c=[];for(let[l,f]of a.entries())l===0&&c.push(N),c.push(At(v(se,f))),l!==a.length-1?c.push(f.length===0?N:ur(He)):r.chomping==="keep"&&i&&c.push(ln(f.length===0?N:He));return r.indent===null?o.push(pr(_(e.tabWidth,c))):o.push(ln(_(r.indent-1+s,c))),o}var Yr=to;function Pt(t,e,n){let{node:r}=t,s=r.type==="flowMapping",i=s?"{":"[",o=s?"}":"]",a=Lt;s&&r.children.length>0&&e.bracketSpacing&&(a=se);let c=D(0,r.children,-1),l=c?.type==="flowMappingItem"&&_e(c.key)&&_e(c.value);return[i,_(e.tabWidth,[a,no(t,e,n),e.trailingComma==="none"?"":ze(","),I(r)?[N,v(N,t.map(n,"endComments"))]:""]),l?"":a,o]}function no(t,e,n){return t.map(({isLast:r,node:s,next:i})=>[n(),r?"":[",",se,s.position.start.line!==i.position.start.line?kt(t,e.originalText):""]],"children")}function ro(t,e,n){let{node:r,parent:s}=t,{key:i,value:o}=r,a=_e(i),c=_e(o);if(a&&c)return": ";let l=n("key"),f=so(r)?" ":"";if(c)return r.type==="flowMappingItem"&&s.type==="flowMapping"?l:r.type==="mappingItem"&&vt(i.content,e)&&!V(i.content)&&s.tag?.value!=="tag:yaml.org,2002:set"?[l,f,":"]:["? ",_(2,l)];let m=n("value");if(a)return[": ",_(2,m)];if(te(o)||!nt(i.content))return["? ",_(2,l),N,...t.map(()=>[n(),N],"value","leadingComments"),": ",_(2,m)];if(io(i.content)&&!te(i.content)&&!ae(i.content)&&!V(i.content)&&!I(i)&&!te(o.content)&&!ae(o.content)&&!I(o)&&vt(o.content,e)&&vt(i.content,e))return[l,f,": ",m];let g=Symbol("mappingKey"),y=Pe([ze("? "),Pe(_(2,l),{id:g})]),h=[N,": ",_(2,m)],d=[f,":"];I(o)&&o.content&&W(o.content,["flowMapping","flowSequence"])&&o.content.children.length===0?d.push(" "):te(o.content)||I(o)&&o.content&&!W(o.content,["mapping","sequence"])||s.type==="mapping"&&V(i.content)&&nt(o.content)||W(o.content,["mapping","sequence"])&&o.content.tag===null&&o.content.anchor===null?d.push(N):o.content?d.push(se):V(o)&&d.push(" "),d.push(m);let w=_(e.tabWidth,d);return vt(i.content,e)&&!te(i.content)&&!ae(i.content)&&!V(i.content)&&!I(i)?fn([[l,w]]):fn([[y,ze(h,w,{groupId:g})]])}function vt(t,e){if(!t)return!0;switch(t.type){case"plain":case"quoteSingle":case"quoteDouble":break;case"alias":return!0;default:return!1}if(e.proseWrap==="preserve")return t.position.start.line===t.position.end.line;if(/\\$/m.test(e.originalText.slice(t.position.start.offset,t.position.end.offset)))return!1;switch(e.proseWrap){case"never":return!t.value.includes(`
|
|
162
|
-
`);case"always":return!/[\n ]/.test(t.value);default:return!1}}function so(t){return t.key.content?.type==="alias"}function io(t){if(!t)return!0;switch(t.type){case"plain":case"quoteDouble":case"quoteSingle":return t.position.start.line===t.position.end.line;case"alias":return!0;default:return!1}}var Br=ro;function oo(t){return gn(t,ao)}function ao(t){switch(t.type){case"document":Ie(t,"head",()=>t.children[0]),Ie(t,"body",()=>t.children[1]);break;case"documentBody":case"sequenceItem":case"flowSequenceItem":case"mappingKey":case"mappingValue":Ie(t,"content",()=>t.children[0]);break;case"mappingItem":case"flowMappingItem":Ie(t,"key",()=>t.children[0]),Ie(t,"value",()=>t.children[1]);break}return t}var Fr=oo;function co(t,e,n){let{node:r}=t,s=[];r.type!=="mappingValue"&&te(r)&&s.push([v(N,t.map(n,"leadingComments")),N]);let{tag:i,anchor:o}=r;i&&s.push(n("tag")),i&&o&&s.push(" "),o&&s.push(n("anchor"));let a="";return W(r,["mapping","sequence","comment","directive","mappingItem","sequenceItem"])&&!Mt(t)&&(a=kt(t,e.originalText)),(i||o)&&(W(r,["sequence","mapping"])&&!ae(r)?s.push(N):s.push(" ")),ae(r)&&s.push([r.middleComments.length===1?"":N,v(N,t.map(n,"middleComments")),N]),xr(t)?s.push(cr(e.originalText.slice(r.position.start.offset,r.position.end.offset).trimEnd())):s.push(Pe(lo(t,e,n))),V(r)&&!W(r,["document","documentHead"])&&s.push(mr([r.type==="mappingValue"&&!r.content?"":" ",t.parent.type==="mappingKey"&&t.getParentNode(2).type==="mapping"&&nt(r)?"":Xe,n("trailingComment")])),Sn(r)&&s.push(_(r.type==="sequenceItem"?2:0,[N,v(N,t.map(({node:c})=>[mn(e.originalText,tt(c))?N:"",n()],"endComments"))])),s.push(a),s}function lo(t,e,n){let{node:r}=t;switch(r.type){case"root":{let s=Ct(r),i=!(W(s,["blockLiteral","blockFolded"])&&s.chomping==="keep"),o=[];return t.each(({node:a,isFirst:c})=>{c||o.push(N),o.push(n()),uo(t)&&(i&&o.push(N),o.push("..."),V(a)&&o.push(" ",n("trailingComment")))},"children"),i&&o.push(N),o}case"document":{let s=[];return po(t)&&((r.head.children.length>0||r.head.endComments.length>0)&&s.push(n("head")),V(r.head)?s.push(["---"," ",n(["head","trailingComment"])]):s.push("---")),fo(r)&&s.push(n("body")),v(N,s)}case"documentHead":return v(N,[...t.map(n,"children"),...t.map(n,"endComments")]);case"documentBody":{let{children:s,endComments:i}=r,o="";if(s.length>0&&i.length>0){let a=Ct(r);if(W(a,["blockFolded","blockLiteral"]))a.chomping!=="keep"&&(o=[N,N]);else{let c=D(0,s,-1);o=W(c,["mapping"])&&mn(e.originalText,tt(i[0]))?[N,N]:N}}return[v(N,t.map(n,"children")),o,v(N,t.map(n,"endComments"))]}case"directive":return["%",v(" ",[r.name,...r.parameters])];case"comment":return["#",r.value];case"alias":return["*",r.value];case"tag":return e.originalText.slice(r.position.start.offset,r.position.end.offset);case"anchor":return["&",r.value];case"plain":return rt(r.type,e.originalText.slice(r.position.start.offset,r.position.end.offset),e);case"quoteDouble":case"quoteSingle":{let o=e.originalText.slice(r.position.start.offset+1,r.position.end.offset-1);if(r.type==="quoteSingle"&&o.includes("\\")||r.type==="quoteDouble"&&/\\[^"]/.test(o)){let c=r.type==="quoteDouble"?'"':"'";return[c,rt(r.type,o,e),c]}if(o.includes('"'))return["'",rt(r.type,r.type==="quoteDouble"?ht(0,ht(0,o,'\\"','"'),"'","'".repeat(2)):o,e),"'"];if(o.includes("'"))return['"',rt(r.type,r.type==="quoteSingle"?ht(0,o,"''","'"):o,e),'"'];let a=e.singleQuote?"'":'"';return[a,rt(r.type,o,e),a]}case"blockFolded":case"blockLiteral":return Yr(t,e,n);case"mapping":case"sequence":return v(N,t.map(n,"children"));case"sequenceItem":return["- ",_(2,r.content?n("content"):"")];case"mappingKey":case"mappingValue":return r.content?n("content"):"";case"mappingItem":case"flowMappingItem":return Br(t,e,n);case"flowMapping":return Pt(t,e,n);case"flowSequence":return Pt(t,e,n);case"flowSequenceItem":return n("content");default:throw new dr(r,"YAML")}}function fo(t){return t.body.children.length>0||I(t.body)}function uo(t){let e=t.node;if(e.documentEndMarker||V(e))return!0;if(t.isLast)return!1;let n=t.next;return n.head.children.length>0||I(n.head)}function po(t){let e=t.node;return e.directivesEndMarker||e.head.children.length>0||I(e.head)||V(e.head)}function rt(t,e,n){let r=Dr(t,e,n);return v(N,r.map(s=>At(v(se,s))))}var mo={preprocess:Fr,embed:Mr,print:co,massageAstNode:Lr,insertPragma:Or,getVisitorKeys:Pr},qr=mo;var Ur=[{name:"YAML",type:"data",aceMode:"yaml",extensions:[".yml",".mir",".reek",".rviz",".sublime-syntax",".syntax",".yaml",".yaml-tmlanguage",".yaml.sed",".yml.mysql"],filenames:[".clang-format",".clang-tidy",".clangd",".gemrc","CITATION.cff","glide.lock","pixi.lock",".prettierrc",".stylelintrc",".lintstagedrc"],tmScope:"source.yaml",aliases:["yml"],codemirrorMode:"yaml",codemirrorMimeType:"text/x-yaml",parsers:["yaml"],vscodeLanguageIds:["yaml","ansible","dockercompose","github-actions-workflow","home-assistant"],linguistLanguageId:407}];var It={bracketSpacing:{category:"Common",type:"boolean",default:!0,description:"Print spaces between brackets.",oppositeDescription:"Do not print spaces between brackets."},objectWrap:{category:"Common",type:"choice",default:"preserve",description:"How to wrap object literals.",choices:[{value:"preserve",description:"Keep as multi-line, if there is a newline between the opening brace and first property."},{value:"collapse",description:"Fit to a single line when possible."}]},singleQuote:{category:"Common",type:"boolean",default:!1,description:"Use single quotes instead of double quotes."},proseWrap:{category:"Common",type:"choice",default:"preserve",description:"How to wrap prose.",choices:[{value:"always",description:"Wrap prose if it exceeds the print width."},{value:"never",description:"Do not wrap prose."},{value:"preserve",description:"Wrap prose as-is."}]},bracketSameLine:{category:"Common",type:"boolean",default:!1,description:"Put > of opening tags on the last line instead of on a new line."},singleAttributePerLine:{category:"Common",type:"boolean",default:!1,description:"Enforce single attribute per line in HTML, Vue and JSX."}};var ho={bracketSpacing:It.bracketSpacing,singleQuote:It.singleQuote,proseWrap:It.proseWrap},Kr=ho;var ir={};or(ir,{yaml:()=>ec});var sr=an(Gn(),1);var J=an(Ps(),1),If=J.default.findPair,_f=J.default.toJSON,xf=J.default.parseMap,Rf=J.default.parseSeq,Df=J.default.stringifyNumber,$f=J.default.stringifyString,Yf=J.default.Type,Bf=J.default.YAMLError,Ff=J.default.YAMLReferenceError,vs=J.default.YAMLSemanticError,qf=J.default.YAMLSyntaxError,Uf=J.default.YAMLWarning;function F(t,e=null){"children"in t&&t.children.forEach(n=>F(n,t)),"anchor"in t&&t.anchor&&F(t.anchor,t),"tag"in t&&t.tag&&F(t.tag,t),"leadingComments"in t&&t.leadingComments.forEach(n=>F(n,t)),"middleComments"in t&&t.middleComments.forEach(n=>F(n,t)),"indicatorComment"in t&&t.indicatorComment&&F(t.indicatorComment,t),"trailingComment"in t&&t.trailingComment&&F(t.trailingComment,t),"endComments"in t&&t.endComments.forEach(n=>F(n,t)),Object.defineProperty(t,"_parent",{value:e,enumerable:!1})}function Oe(t){return`${t.line}:${t.column}`}function Is(t){F(t);let e=Ra(t),n=t.children.slice();t.comments.sort((r,s)=>r.position.start.offset-s.position.end.offset).filter(r=>!r._parent).forEach(r=>{for(;n.length>1&&r.position.start.line>n[0].position.end.line;)n.shift();Da(r,e,n[0])})}function Ra(t){let e=Array.from(new Array(t.position.end.line),()=>({}));for(let n of t.comments)e[n.position.start.line-1].comment=n;return _s(e,t),e}function _s(t,e){if(e.position.start.offset!==e.position.end.offset){if("leadingComments"in e){let{start:n}=e.position,{leadingAttachableNode:r}=t[n.line-1];(!r||n.column<r.position.start.column)&&(t[n.line-1].leadingAttachableNode=e)}if("trailingComment"in e&&e.position.end.column>1&&e.type!=="document"&&e.type!=="documentHead"){let{end:n}=e.position,{trailingAttachableNode:r}=t[n.line-1];(!r||n.column>=r.position.end.column)&&(t[n.line-1].trailingAttachableNode=e)}if(e.type!=="root"&&e.type!=="document"&&e.type!=="documentHead"&&e.type!=="documentBody"){let{start:n,end:r}=e.position,s=[r.line].concat(n.line===r.line?[]:n.line);for(let i of s){let o=t[i-1].trailingNode;(!o||r.column>=o.position.end.column)&&(t[i-1].trailingNode=e)}}"children"in e&&e.children.forEach(n=>{_s(t,n)})}}function Da(t,e,n){let r=t.position.start.line,{trailingAttachableNode:s}=e[r-1];if(s){if(s.trailingComment)throw new Error(`Unexpected multiple trailing comment at ${Oe(t.position.start)}`);F(t,s),s.trailingComment=t;return}for(let o=r;o>=n.position.start.line;o--){let{trailingNode:a}=e[o-1],c;if(a)c=a;else if(o!==r&&e[o-1].comment)c=e[o-1].comment._parent;else continue;if((c.type==="sequence"||c.type==="mapping")&&(c=c.children[0]),c.type==="mappingItem"){let[l,f]=c.children;c=xs(l)?l:f}for(;;){if($a(c,t)){F(t,c),c.endComments.push(t);return}if(!c._parent)break;c=c._parent}break}for(let o=r+1;o<=n.position.end.line;o++){let{leadingAttachableNode:a}=e[o-1];if(a){F(t,a),a.leadingComments.push(t);return}}let i=n.children[1];F(t,i),i.endComments.push(t)}function $a(t,e){if(t.position.start.offset<e.position.start.offset&&t.position.end.offset>e.position.end.offset)switch(t.type){case"flowMapping":case"flowSequence":return t.children.length===0||e.position.start.line>t.children[t.children.length-1].position.end.line}if(e.position.end.offset<t.position.end.offset)return!1;switch(t.type){case"sequenceItem":return e.position.start.column>t.position.start.column;case"mappingKey":case"mappingValue":return e.position.start.column>t._parent.position.start.column&&(t.children.length===0||t.children.length===1&&t.children[0].type!=="blockFolded"&&t.children[0].type!=="blockLiteral")&&(t.type==="mappingValue"||xs(t));default:return!1}}function xs(t){return t.position.start!==t.position.end&&(t.children.length===0||t.position.start.offset!==t.children[0].position.start.offset)}function b(t,e){return{type:t,position:e}}function Rs(t,e,n){return{...b("root",t),children:e,comments:n}}function pt(t){switch(t.type){case"DOCUMENT":for(let e=t.contents.length-1;e>=0;e--)t.contents[e].type==="BLANK_LINE"?t.contents.splice(e,1):pt(t.contents[e]);for(let e=t.directives.length-1;e>=0;e--)t.directives[e].type==="BLANK_LINE"&&t.directives.splice(e,1);break;case"FLOW_MAP":case"FLOW_SEQ":case"MAP":case"SEQ":for(let e=t.items.length-1;e>=0;e--){let n=t.items[e];"char"in n||(n.type==="BLANK_LINE"?t.items.splice(e,1):pt(n))}break;case"MAP_KEY":case"MAP_VALUE":case"SEQ_ITEM":t.node&&pt(t.node);break;case"ALIAS":case"BLANK_LINE":case"BLOCK_FOLDED":case"BLOCK_LITERAL":case"COMMENT":case"DIRECTIVE":case"PLAIN":case"QUOTE_DOUBLE":case"QUOTE_SINGLE":break;default:throw new Error(`Unexpected node type ${JSON.stringify(t.type)}`)}}function X(t,e){return{start:t,end:e}}function Hn(t){return{start:t,end:t}}var me;(function(t){t.Tag="!",t.Anchor="&",t.Comment="#"})(me||(me={}));function Ds(t,e){return{...b("anchor",t),value:e}}function Ke(t,e){return{...b("comment",t),value:e}}function $s(t,e,n){return{anchor:e,tag:t,middleComments:n}}function Ys(t,e){return{...b("tag",t),value:e}}function Jt(t,e,n=()=>!1){let r=t.cstNode,s=[],i=null,o=null,a=null;for(let c of r.props){let l=e.text[c.origStart];switch(l){case me.Tag:i=i||c,o=Ys(e.transformRange(c),t.tag);break;case me.Anchor:i=i||c,a=Ds(e.transformRange(c),r.anchor);break;case me.Comment:{let f=Ke(e.transformRange(c),e.text.slice(c.origStart+1,c.origEnd));e.comments.push(f),!n(f)&&i&&i.origEnd<=c.origStart&&c.origEnd<=r.valueRange.origStart&&s.push(f);break}default:throw new Error(`Unexpected leading character ${JSON.stringify(l)}`)}}return $s(o,a,s)}function z(){return{leadingComments:[]}}function he(t=null){return{trailingComment:t}}function q(){return{...z(),...he()}}function Bs(t,e,n){return{...b("alias",t),...q(),...e,value:n}}function Fs(t,e){let n=t.cstNode;return Bs(e.transformRange({origStart:n.valueRange.origStart-1,origEnd:n.valueRange.origEnd}),e.transformContent(t),n.rawValue)}function qs(t){return{...t,type:"blockFolded"}}function Us(t,e,n,r,s,i){return{...b("blockValue",t),...z(),...e,chomping:n,indent:r,value:s,indicatorComment:i}}var Jn;(function(t){t.CLIP="clip",t.STRIP="strip",t.KEEP="keep"})(Jn||(Jn={}));function Xt(t,e){let n=t.cstNode,r=1,s=n.chomping==="CLIP"?0:1,o=n.header.origEnd-n.header.origStart-r-s!==0,a=e.transformRange({origStart:n.header.origStart,origEnd:n.valueRange.origEnd}),c=null,l=Jt(t,e,f=>{if(!(a.start.offset<f.position.start.offset&&f.position.end.offset<a.end.offset))return!1;if(c)throw new Error(`Unexpected multiple indicator comments at ${Oe(f.position.start)}`);return c=f,!0});return Us(a,l,Jn[n.chomping],o?n.blockIndent:null,n.strValue,c)}function Ks(t,e){return qs(Xt(t,e))}function Ws(t){return{...t,type:"blockLiteral"}}function Vs(t,e){return Ws(Xt(t,e))}function js(t,e){return Ke(e.transformRange(t.range),t.comment)}function Qs(t,e,n){return{...b("directive",t),...q(),name:e,parameters:n}}function We(t,e){for(let n of t.props){let r=e.text[n.origStart];switch(r){case me.Comment:e.comments.push(Ke(e.transformRange(n),e.text.slice(n.origStart+1,n.origEnd)));break;default:throw new Error(`Unexpected leading character ${JSON.stringify(r)}`)}}}function Gs(t,e){return We(t,e),Qs(e.transformRange(t.range),t.name,t.parameters)}function Hs(t,e,n,r,s,i){return{...b("document",t),...he(i),directivesEndMarker:e,documentEndMarker:n,children:[r,s]}}function U(t=[]){return{endComments:t}}function Js(t,e,n){return{...b("documentBody",t),...U(n),children:e?[e]:[]}}function K(t){return t[t.length-1]}function zt(t,e){let n=t.match(e);return n?n.index:-1}function Xs(t,e,n){let r=t.cstNode,{comments:s,endComments:i,documentTrailingComment:o,documentHeadTrailingComment:a}=Ya(r,e,n),c=e.transformNode(t.contents),{position:l,documentEndPoint:f}=Ba(r,c,e);return e.comments.push(...s,...i),{documentBody:Js(l,c,i),documentEndPoint:f,documentTrailingComment:o,documentHeadTrailingComment:a}}function Ya(t,e,n){let r=[],s=[],i=[],o=[],a=!1;for(let c=t.contents.length-1;c>=0;c--){let l=t.contents[c];if(l.type==="COMMENT"){let f=e.transformNode(l);n&&n.line===f.position.start.line?o.unshift(f):a?r.unshift(f):f.position.start.offset>=t.valueRange.origEnd?i.unshift(f):r.unshift(f)}else a=!0}if(i.length>1)throw new Error(`Unexpected multiple document trailing comments at ${Oe(i[1].position.start)}`);if(o.length>1)throw new Error(`Unexpected multiple documentHead trailing comments at ${Oe(o[1].position.start)}`);return{comments:r,endComments:s,documentTrailingComment:K(i)||null,documentHeadTrailingComment:K(o)||null}}function Ba(t,e,n){let r=zt(n.text.slice(t.valueRange.origEnd),/^\.\.\./),s=r===-1?t.valueRange.origEnd:Math.max(0,t.valueRange.origEnd-1);n.text[s-1]==="\r"&&s--;let i=n.transformRange({origStart:e!==null?e.position.start.offset:s,origEnd:s}),o=r===-1?i.end:n.transformOffset(t.valueRange.origEnd+3);return{position:i,documentEndPoint:o}}function zs(t,e,n,r){return{...b("documentHead",t),...U(n),...he(r),children:e}}function Zs(t,e){let n=t.cstNode,{directives:r,comments:s,endComments:i}=Fa(n,e),{position:o,documentEndMarkererPoint:a}=qa(n,r,e);return e.comments.push(...s,...i),{createDocumentHeadWithTrailingComment:l=>(l&&e.comments.push(l),zs(o,r,i,l)),documentHeadEndMarkerPoint:a}}function Fa(t,e){let n=[],r=[],s=[],i=!1;for(let o=t.directives.length-1;o>=0;o--){let a=e.transformNode(t.directives[o]);a.type==="comment"?i?r.unshift(a):s.unshift(a):(i=!0,n.unshift(a))}return{directives:n,comments:r,endComments:s}}function qa(t,e,n){let r=zt(n.text.slice(0,t.valueRange.origStart),/---\s*$/);r>0&&!/[\r\n]/.test(n.text[r-1])&&(r=-1);let s=r===-1?{origStart:t.valueRange.origStart,origEnd:t.valueRange.origStart}:{origStart:r,origEnd:r+3};return e.length!==0&&(s.origStart=e[0].position.start.offset),{position:n.transformRange(s),documentEndMarkererPoint:r===-1?null:n.transformOffset(r)}}function ei(t,e){let{createDocumentHeadWithTrailingComment:n,documentHeadEndMarkerPoint:r}=Zs(t,e),{documentBody:s,documentEndPoint:i,documentTrailingComment:o,documentHeadTrailingComment:a}=Xs(t,e,r),c=n(a);o&&e.comments.push(o);let l=t.cstNode;return Hs(X(c.position.start,i),!!l.directivesEndMarker,!!l.documentEndMarker,c,s,o)}function Zt(t,e,n){return{...b("flowCollection",t),...q(),...U(),...e,children:n}}function ti(t,e,n){return{...Zt(t,e,n),type:"flowMapping"}}function en(t,e,n){return{...b("flowMappingItem",t),...z(),children:[e,n]}}function de(t,e){let n=[];for(let r of t)r&&"type"in r&&r.type==="COMMENT"?e.comments.push(e.transformNode(r)):n.push(r);return n}function tn(t){let[e,n]=["?",":"].map(r=>{let s=t.find(i=>"char"in i&&i.char===r);return s?{origStart:s.origOffset,origEnd:s.origOffset+1}:null});return{additionalKeyRange:e,additionalValueRange:n}}function nn(t,e){let n=e;return r=>t.slice(n,n=r)}function rn(t){let e=[],n=nn(t,1),r=!1;for(let s=1;s<t.length-1;s++){let i=t[s];if("char"in i&&i.char===","){e.push(n(s)),n(s+1),r=!1;continue}r=!0}return r&&e.push(n(t.length-1)),e}function Xn(t,e){return{...b("mappingKey",t),...he(),...U(),children:e?[e]:[]}}function zn(t,e){return{...b("mappingValue",t),...q(),...U(),children:e?[e]:[]}}function Ve(t,e,n,r,s){let i=e.transformNode(t.key),o=e.transformNode(t.value),a=i||r?Xn(e.transformRange({origStart:r?r.origStart:i.position.start.offset,origEnd:i?i.position.end.offset:r.origStart+1}),i):null,c=o||s?zn(e.transformRange({origStart:s?s.origStart:o.position.start.offset,origEnd:o?o.position.end.offset:s.origStart+1}),o):null;return n(X(a?a.position.start:c.position.start,c?c.position.end:a.position.end),a||Xn(Hn(c.position.start),null),c||zn(Hn(a.position.end),null))}function ni(t,e){let n=de(t.cstNode.items,e),r=rn(n),s=t.items.map((a,c)=>{let l=r[c],{additionalKeyRange:f,additionalValueRange:m}=tn(l);return Ve(a,e,en,f,m)}),i=n[0],o=K(n);return ti(e.transformRange({origStart:i.origOffset,origEnd:o.origOffset+1}),e.transformContent(t),s)}function ri(t,e,n){return{...Zt(t,e,n),type:"flowSequence"}}function si(t,e){return{...b("flowSequenceItem",t),children:[e]}}function ii(t,e){let n=de(t.cstNode.items,e),r=rn(n),s=t.items.map((a,c)=>{if(a.type!=="PAIR"){let l=e.transformNode(a);return si(X(l.position.start,l.position.end),l)}else{let l=r[c],{additionalKeyRange:f,additionalValueRange:m}=tn(l);return Ve(a,e,en,f,m)}}),i=n[0],o=K(n);return ri(e.transformRange({origStart:i.origOffset,origEnd:o.origOffset+1}),e.transformContent(t),s)}function oi(t,e,n){return{...b("mapping",t),...z(),...e,children:n}}function ai(t,e,n){return{...b("mappingItem",t),...z(),children:[e,n]}}function ci(t,e){let n=t.cstNode;n.items.filter(o=>o.type==="MAP_KEY"||o.type==="MAP_VALUE").forEach(o=>We(o,e));let r=de(n.items,e),s=Ua(r),i=t.items.map((o,a)=>{let c=s[a],[l,f]=c[0].type==="MAP_VALUE"?[null,c[0].range]:[c[0].range,c.length===1?null:c[1].range];return Ve(o,e,ai,l,f)});return oi(X(i[0].position.start,K(i).position.end),e.transformContent(t),i)}function Ua(t){let e=[],n=nn(t,0),r=!1;for(let s=0;s<t.length;s++){if(t[s].type==="MAP_VALUE"){e.push(n(s+1)),r=!1;continue}r&&e.push(n(s)),r=!0}return r&&e.push(n(1/0)),e}function li(t,e,n){return{...b("plain",t),...q(),...e,value:n}}function fi(t,e,n){for(let r=e;r>=0;r--)if(n.test(t[r]))return r;return-1}function ui(t,e){let n=t.cstNode;return li(e.transformRange({origStart:n.valueRange.origStart,origEnd:fi(e.text,n.valueRange.origEnd-1,/\S/)+1}),e.transformContent(t),n.strValue)}function pi(t){return{...t,type:"quoteDouble"}}function mi(t,e,n){return{...b("quoteValue",t),...e,...q(),value:n}}function sn(t,e){let n=t.cstNode;return mi(e.transformRange(n.valueRange),e.transformContent(t),n.strValue)}function hi(t,e){return pi(sn(t,e))}function di(t){return{...t,type:"quoteSingle"}}function gi(t,e){return di(sn(t,e))}function yi(t,e,n){return{...b("sequence",t),...z(),...U(),...e,children:n}}function Ei(t,e){return{...b("sequenceItem",t),...q(),...U(),children:e?[e]:[]}}function Si(t,e){let r=de(t.cstNode.items,e).map((s,i)=>{We(s,e);let o=e.transformNode(t.items[i]);return Ei(X(e.transformOffset(s.valueRange.origStart),o===null?e.transformOffset(s.valueRange.origStart+1):o.position.end),o)});return yi(X(r[0].position.start,K(r).position.end),e.transformContent(t),r)}function wi(t,e){if(t===null||t.type===void 0&&t.value===null)return null;switch(t.type){case"ALIAS":return Fs(t,e);case"BLOCK_FOLDED":return Ks(t,e);case"BLOCK_LITERAL":return Vs(t,e);case"COMMENT":return js(t,e);case"DIRECTIVE":return Gs(t,e);case"DOCUMENT":return ei(t,e);case"FLOW_MAP":return ni(t,e);case"FLOW_SEQ":return ii(t,e);case"MAP":return ci(t,e);case"PLAIN":return ui(t,e);case"QUOTE_DOUBLE":return hi(t,e);case"QUOTE_SINGLE":return gi(t,e);case"SEQ":return Si(t,e);default:throw new Error(`Unexpected node type ${t.type}`)}}var Zn,er=class{text;comments=[];#e;#t;constructor(e,n){this.text=n,this.#e=e,this.setOrigRanges()}setOrigRanges(){if(!this.#e.setOrigRanges())for(let e of this.#e)e.setOrigRanges([],0)}#n(e){if(!Zn){let[o]=this.#e,a=Object.getPrototypeOf(Object.getPrototypeOf(o));Zn=Object.getOwnPropertyDescriptor(a,"rangeAsLinePos").get}if(this.#t??(this.#t={root:{context:{src:this.text}}}),this.text===""&&e.origStart===0&&e.origEnd===0)return{start:{offset:0,line:1,column:1},end:{offset:0,line:1,column:1}};let{start:{line:n,col:r},end:{line:s,col:i}}=Zn.call({range:{start:this.#r(e.origStart),end:this.#r(e.origEnd)},context:this.#t});return{start:{offset:e.origStart,line:n,column:r},end:{offset:e.origEnd,line:s,column:i}}}#r(e){return e<0?0:e>this.text.length?this.text.length:e}transformOffset(e){return this.#n({origStart:e,origEnd:e}).start}transformRange(e){let{start:n,end:r}=this.#n(e);return X(n,r)}transformNode(e){return wi(e,this)}transformContent(e){return Jt(e,this)}},bi=er;function Ni(t,e,n){let r=new SyntaxError(t);return r.name="YAMLSyntaxError",r.source=e,r.position=n,r}function Oi(t,e){let n=t.source.range||t.source.valueRange;return Ni(t.message,e.text,e.transformRange(n))}function tr(t){if("children"in t){if(t.children.length===1){let e=t.children[0];if(e.type==="plain"&&e.tag===null&&e.anchor===null&&e.value==="")return t.children.splice(0,1),t}t.children.forEach(tr)}return t}function nr(t,e,n,r){let s=e(t);return i=>{r(s,i)&&n(t,s=i)}}function rr(t){if(t===null||!("children"in t))return;let e=t.children;if(e.forEach(rr),t.type==="document"){let[i,o]=t.children;i.position.start.offset===i.position.end.offset?i.position.start=i.position.end=o.position.start:o.position.start.offset===o.position.end.offset&&(o.position.start=o.position.end=i.position.end)}let n=nr(t.position,Ka,Wa,Qa),r=nr(t.position,Va,ja,Ga);"endComments"in t&&t.endComments.length!==0&&(n(t.endComments[0].position.start),r(K(t.endComments).position.end));let s=e.filter(i=>i!==null);if(s.length!==0){let i=s[0],o=K(s);n(i.position.start),r(o.position.end),"leadingComments"in i&&i.leadingComments.length!==0&&n(i.leadingComments[0].position.start),"tag"in i&&i.tag&&n(i.tag.position.start),"anchor"in i&&i.anchor&&n(i.anchor.position.start),"trailingComment"in o&&o.trailingComment&&r(o.trailingComment.position.end)}}function Ka(t){return t.start}function Wa(t,e){t.start=e}function Va(t){return t.end}function ja(t,e){t.end=e}function Qa(t,e){return e.offset<t.offset}function Ga(t,e){return e.offset>t.offset}var Ai='Map keys must be unique; "',Li='" is repeated',Ha=`${Ai}<<${Li}`;function Ja(t,e){if(!(t instanceof vs))return!1;let{message:n}=t;return n===Ha||e&&n.startsWith(Ai)&&n.endsWith(Li)}function Ti(t,e){let n=e?.allowDuplicateKeysInMap,r=sr.default.parseCST(t),s=new bi(r,t),i=[];for(let a of r){let c=new sr.default.Document({merge:!1,keepCstNodes:!0}).parse(a);for(let f of c.errors)if(!Ja(f,n))throw Oi(f,s);pt(c.cstNode);let l=s.transformNode(c);i.push(l)}let o=Rs(s.transformRange({origStart:0,origEnd:t.length}),i,s.comments);return Is(o),rr(o),tr(o),o}function Xa(t,e){let n=new SyntaxError(t+" ("+e.loc.start.line+":"+e.loc.start.column+")");return Object.assign(n,e)}var Mi=Xa;var za={allowDuplicateKeysInMap:!0};function Za(t){try{let e=Ti(t,za);return delete e.comments,e}catch(e){throw e?.position?Mi(e.message,{loc:e.position,cause:e}):e}}var ec={astFormat:"yaml",parse:Za,hasPragma:br,hasIgnorePragma:Nr,locStart:tt,locEnd:vr};var tc={yaml:qr};var Ci=an(Gn(),1),nc=Ci.default.parse;export{nc as __parsePrettierYamlConfig,ki as default,Ur as languages,Kr as options,ir as parsers,tc as printers};
|
|
162
|
+
`);case"always":return!/[\n ]/.test(t.value);default:return!1}}function so(t){return t.key.content?.type==="alias"}function io(t){if(!t)return!0;switch(t.type){case"plain":case"quoteDouble":case"quoteSingle":return t.position.start.line===t.position.end.line;case"alias":return!0;default:return!1}}var Br=ro;function oo(t){return gn(t,ao)}function ao(t){switch(t.type){case"document":Ie(t,"head",()=>t.children[0]),Ie(t,"body",()=>t.children[1]);break;case"documentBody":case"sequenceItem":case"flowSequenceItem":case"mappingKey":case"mappingValue":Ie(t,"content",()=>t.children[0]);break;case"mappingItem":case"flowMappingItem":Ie(t,"key",()=>t.children[0]),Ie(t,"value",()=>t.children[1]);break}return t}var Fr=oo;function co(t,e,n){let{node:r}=t,s=[];r.type!=="mappingValue"&&te(r)&&s.push([v(N,t.map(n,"leadingComments")),N]);let{tag:i,anchor:o}=r;i&&s.push(n("tag")),i&&o&&s.push(" "),o&&s.push(n("anchor"));let a="";return W(r,["mapping","sequence","comment","directive","mappingItem","sequenceItem"])&&!Mt(t)&&(a=kt(t,e.originalText)),(i||o)&&(W(r,["sequence","mapping"])&&!ae(r)?s.push(N):s.push(" ")),ae(r)&&s.push([r.middleComments.length===1?"":N,v(N,t.map(n,"middleComments")),N]),xr(t)?s.push(cr(e.originalText.slice(r.position.start.offset,r.position.end.offset).trimEnd())):s.push(Pe(lo(t,e,n))),V(r)&&!W(r,["document","documentHead"])&&s.push(mr([r.type==="mappingValue"&&!r.content?"":" ",t.parent.type==="mappingKey"&&t.getParentNode(2).type==="mapping"&&nt(r)?"":Xe,n("trailingComment")])),Sn(r)&&s.push(_(r.type==="sequenceItem"?2:0,[N,v(N,t.map(({node:c})=>[mn(e.originalText,tt(c))?N:"",n()],"endComments"))])),s.push(a),s}function lo(t,e,n){let{node:r}=t;switch(r.type){case"root":{let s=Ct(r),i=!(W(s,["blockLiteral","blockFolded"])&&s.chomping==="keep"),o=[];return t.each(({node:a,isFirst:c})=>{c||o.push(N),o.push(n()),uo(t)&&(i&&o.push(N),o.push("..."),V(a)&&o.push(" ",n("trailingComment")))},"children"),i&&o.push(N),o}case"document":{let s=[];return po(t)&&((r.head.children.length>0||r.head.endComments.length>0)&&s.push(n("head")),V(r.head)?s.push(["---"," ",n(["head","trailingComment"])]):s.push("---")),fo(r)&&s.push(n("body")),v(N,s)}case"documentHead":return v(N,[...t.map(n,"children"),...t.map(n,"endComments")]);case"documentBody":{let{children:s,endComments:i}=r,o="";if(s.length>0&&i.length>0){let a=Ct(r);if(W(a,["blockFolded","blockLiteral"]))a.chomping!=="keep"&&(o=[N,N]);else{let c=D(0,s,-1);o=W(c,["mapping"])&&mn(e.originalText,tt(i[0]))?[N,N]:N}}return[v(N,t.map(n,"children")),o,v(N,t.map(n,"endComments"))]}case"directive":return["%",v(" ",[r.name,...r.parameters])];case"comment":return["#",r.value];case"alias":return["*",r.value];case"tag":return e.originalText.slice(r.position.start.offset,r.position.end.offset);case"anchor":return["&",r.value];case"plain":return rt(r.type,e.originalText.slice(r.position.start.offset,r.position.end.offset),e);case"quoteDouble":case"quoteSingle":{let o=e.originalText.slice(r.position.start.offset+1,r.position.end.offset-1);if(r.type==="quoteSingle"&&o.includes("\\")||r.type==="quoteDouble"&&/\\[^"]/.test(o)){let c=r.type==="quoteDouble"?'"':"'";return[c,rt(r.type,o,e),c]}if(o.includes('"'))return["'",rt(r.type,r.type==="quoteDouble"?ht(0,ht(0,o,'\\"','"'),"'","'".repeat(2)):o,e),"'"];if(o.includes("'"))return['"',rt(r.type,r.type==="quoteSingle"?ht(0,o,"''","'"):o,e),'"'];let a=e.singleQuote?"'":'"';return[a,rt(r.type,o,e),a]}case"blockFolded":case"blockLiteral":return Yr(t,e,n);case"mapping":case"sequence":return v(N,t.map(n,"children"));case"sequenceItem":return["- ",_(2,r.content?n("content"):"")];case"mappingKey":case"mappingValue":return r.content?n("content"):"";case"mappingItem":case"flowMappingItem":return Br(t,e,n);case"flowMapping":return Pt(t,e,n);case"flowSequence":return Pt(t,e,n);case"flowSequenceItem":return n("content");default:throw new dr(r,"YAML")}}function fo(t){return t.body.children.length>0||I(t.body)}function uo(t){let e=t.node;if(e.documentEndMarker||V(e))return!0;if(t.isLast)return!1;let n=t.next;return n.head.children.length>0||I(n.head)}function po(t){let e=t.node;return e.directivesEndMarker||e.head.children.length>0||I(e.head)||V(e.head)}function rt(t,e,n){let r=Dr(t,e,n);return v(N,r.map(s=>At(v(se,s))))}var mo={preprocess:Fr,embed:Mr,print:co,massageAstNode:Lr,insertPragma:Or,getVisitorKeys:Pr},qr=mo;var Ur=[{name:"YAML",type:"data",aceMode:"yaml",extensions:[".yml",".mir",".reek",".rviz",".sublime-syntax",".syntax",".yaml",".yaml-tmlanguage",".yaml.sed",".yml.mysql"],filenames:[".clang-format",".clang-tidy",".clangd",".gemrc","CITATION.cff","glide.lock","pixi.lock",".prettierrc",".stylelintrc",".lintstagedrc"],tmScope:"source.yaml",aliases:["yml"],codemirrorMode:"yaml",codemirrorMimeType:"text/x-yaml",parsers:["yaml"],vscodeLanguageIds:["yaml","ansible","dockercompose","github-actions-workflow","home-assistant"],linguistLanguageId:407}];var It={bracketSpacing:{category:"Common",type:"boolean",default:!0,description:"Print spaces between brackets.",oppositeDescription:"Do not print spaces between brackets."},objectWrap:{category:"Common",type:"choice",default:"preserve",description:"How to wrap object literals.",choices:[{value:"preserve",description:"Keep as multi-line, if there is a newline between the opening brace and first property."},{value:"collapse",description:"Fit to a single line when possible."}]},singleQuote:{category:"Common",type:"boolean",default:!1,description:"Use single quotes instead of double quotes."},proseWrap:{category:"Common",type:"choice",default:"preserve",description:"How to wrap prose.",choices:[{value:"always",description:"Wrap prose if it exceeds the print width."},{value:"never",description:"Do not wrap prose."},{value:"preserve",description:"Wrap prose as-is."}]},bracketSameLine:{category:"Common",type:"boolean",default:!1,description:"Put > of opening tags on the last line instead of on a new line."},singleAttributePerLine:{category:"Common",type:"boolean",default:!1,description:"Enforce single attribute per line in HTML, Vue and JSX."}};var ho={bracketSpacing:It.bracketSpacing,singleQuote:It.singleQuote,proseWrap:It.proseWrap},Kr=ho;var ir={};or(ir,{yaml:()=>ec});var sr=an(Gn(),1);var J=an(Ps(),1),If=J.default.findPair,_f=J.default.toJSON,xf=J.default.parseMap,Rf=J.default.parseSeq,Df=J.default.stringifyNumber,$f=J.default.stringifyString,Yf=J.default.Type,Bf=J.default.YAMLError,Ff=J.default.YAMLReferenceError,vs=J.default.YAMLSemanticError,qf=J.default.YAMLSyntaxError,Uf=J.default.YAMLWarning;function F(t,e=null){"children"in t&&t.children.forEach(n=>F(n,t)),"anchor"in t&&t.anchor&&F(t.anchor,t),"tag"in t&&t.tag&&F(t.tag,t),"leadingComments"in t&&t.leadingComments.forEach(n=>F(n,t)),"middleComments"in t&&t.middleComments.forEach(n=>F(n,t)),"indicatorComment"in t&&t.indicatorComment&&F(t.indicatorComment,t),"trailingComment"in t&&t.trailingComment&&F(t.trailingComment,t),"endComments"in t&&t.endComments.forEach(n=>F(n,t)),Object.defineProperty(t,"_parent",{value:e,enumerable:!1})}function Oe(t){return`${t.line}:${t.column}`}function Is(t){F(t);let e=Ra(t),n=t.children.slice();t.comments.sort((r,s)=>r.position.start.offset-s.position.end.offset).filter(r=>!r._parent).forEach(r=>{for(;n.length>1&&r.position.start.line>n[0].position.end.line;)n.shift();Da(r,e,n[0])})}function Ra(t){let e=Array.from(new Array(t.position.end.line),()=>({}));for(let n of t.comments)e[n.position.start.line-1].comment=n;return _s(e,t),e}function _s(t,e){if(e.position.start.offset!==e.position.end.offset){if("leadingComments"in e){let{start:n}=e.position,{leadingAttachableNode:r}=t[n.line-1];(!r||n.column<r.position.start.column)&&(t[n.line-1].leadingAttachableNode=e)}if("trailingComment"in e&&e.position.end.column>1&&e.type!=="document"&&e.type!=="documentHead"){let{end:n}=e.position,{trailingAttachableNode:r}=t[n.line-1];(!r||n.column>=r.position.end.column)&&(t[n.line-1].trailingAttachableNode=e)}if(e.type!=="root"&&e.type!=="document"&&e.type!=="documentHead"&&e.type!=="documentBody"){let{start:n,end:r}=e.position,s=[r.line].concat(n.line===r.line?[]:n.line);for(let i of s){let o=t[i-1].trailingNode;(!o||r.column>=o.position.end.column)&&(t[i-1].trailingNode=e)}}"children"in e&&e.children.forEach(n=>{_s(t,n)})}}function Da(t,e,n){let r=t.position.start.line,{trailingAttachableNode:s}=e[r-1];if(s){if(s.trailingComment)throw new Error(`Unexpected multiple trailing comment at ${Oe(t.position.start)}`);F(t,s),s.trailingComment=t;return}for(let o=r;o>=n.position.start.line;o--){let{trailingNode:a}=e[o-1],c;if(a)c=a;else if(o!==r&&e[o-1].comment)c=e[o-1].comment._parent;else continue;if((c.type==="sequence"||c.type==="mapping")&&(c=c.children[0]),c.type==="mappingItem"){let[l,f]=c.children;c=xs(l)?l:f}for(;;){if($a(c,t)){F(t,c),c.endComments.push(t);return}if(!c._parent)break;c=c._parent}break}for(let o=r+1;o<=n.position.end.line;o++){let{leadingAttachableNode:a}=e[o-1];if(a){F(t,a),a.leadingComments.push(t);return}}let i=n.children[1];F(t,i),i.endComments.push(t)}function $a(t,e){if(t.position.start.offset<e.position.start.offset&&t.position.end.offset>e.position.end.offset)switch(t.type){case"flowMapping":case"flowSequence":return t.children.length===0||e.position.start.line>t.children[t.children.length-1].position.end.line}if(e.position.end.offset<t.position.end.offset)return!1;switch(t.type){case"sequenceItem":return e.position.start.column>t.position.start.column;case"mappingKey":case"mappingValue":return e.position.start.column>t._parent.position.start.column&&(t.children.length===0||t.children.length===1&&t.children[0].type!=="blockFolded"&&t.children[0].type!=="blockLiteral")&&(t.type==="mappingValue"||xs(t));default:return!1}}function xs(t){return t.position.start!==t.position.end&&(t.children.length===0||t.position.start.offset!==t.children[0].position.start.offset)}function b(t,e){return{type:t,position:e}}function Rs(t,e,n){return{...b("root",t),children:e,comments:n}}function pt(t){switch(t.type){case"DOCUMENT":for(let e=t.contents.length-1;e>=0;e--)t.contents[e].type==="BLANK_LINE"?t.contents.splice(e,1):pt(t.contents[e]);for(let e=t.directives.length-1;e>=0;e--)t.directives[e].type==="BLANK_LINE"&&t.directives.splice(e,1);break;case"FLOW_MAP":case"FLOW_SEQ":case"MAP":case"SEQ":for(let e=t.items.length-1;e>=0;e--){let n=t.items[e];"char"in n||(n.type==="BLANK_LINE"?t.items.splice(e,1):pt(n))}break;case"MAP_KEY":case"MAP_VALUE":case"SEQ_ITEM":t.node&&pt(t.node);break;case"ALIAS":case"BLANK_LINE":case"BLOCK_FOLDED":case"BLOCK_LITERAL":case"COMMENT":case"DIRECTIVE":case"PLAIN":case"QUOTE_DOUBLE":case"QUOTE_SINGLE":break;default:throw new Error(`Unexpected node type ${JSON.stringify(t.type)}`)}}function X(t,e){return{start:t,end:e}}function Hn(t){return{start:t,end:t}}var me;(function(t){t.Tag="!",t.Anchor="&",t.Comment="#"})(me||(me={}));function Ds(t,e){return{...b("anchor",t),value:e}}function Ke(t,e){return{...b("comment",t),value:e}}function $s(t,e,n){return{anchor:e,tag:t,middleComments:n}}function Ys(t,e){return{...b("tag",t),value:e}}function Jt(t,e,n=()=>!1){let r=t.cstNode,s=[],i=null,o=null,a=null;for(let c of r.props){let l=e.text[c.origStart];switch(l){case me.Tag:i=i||c,o=Ys(e.transformRange(c),t.tag);break;case me.Anchor:i=i||c,a=Ds(e.transformRange(c),r.anchor);break;case me.Comment:{let f=Ke(e.transformRange(c),e.text.slice(c.origStart+1,c.origEnd));e.comments.push(f),!n(f)&&i&&i.origEnd<=c.origStart&&c.origEnd<=r.valueRange.origStart&&s.push(f);break}default:throw new Error(`Unexpected leading character ${JSON.stringify(l)}`)}}return $s(o,a,s)}function z(){return{leadingComments:[]}}function he(t=null){return{trailingComment:t}}function q(){return{...z(),...he()}}function Bs(t,e,n){return{...b("alias",t),...q(),...e,value:n}}function Fs(t,e){let n=t.cstNode;return Bs(e.transformRange({origStart:n.valueRange.origStart-1,origEnd:n.valueRange.origEnd}),e.transformContent(t),n.rawValue)}function qs(t){return{...t,type:"blockFolded"}}function Us(t,e,n,r,s,i){return{...b("blockValue",t),...z(),...e,chomping:n,indent:r,value:s,indicatorComment:i}}var Jn;(function(t){t.CLIP="clip",t.STRIP="strip",t.KEEP="keep"})(Jn||(Jn={}));function Xt(t,e){let n=t.cstNode,r=1,s=n.chomping==="CLIP"?0:1,o=n.header.origEnd-n.header.origStart-r-s!==0,a=e.transformRange({origStart:n.header.origStart,origEnd:n.valueRange.origEnd}),c=null,l=Jt(t,e,f=>{if(!(a.start.offset<f.position.start.offset&&f.position.end.offset<a.end.offset))return!1;if(c)throw new Error(`Unexpected multiple indicator comments at ${Oe(f.position.start)}`);return c=f,!0});return Us(a,l,Jn[n.chomping],o?n.blockIndent:null,n.strValue,c)}function Ks(t,e){return qs(Xt(t,e))}function Ws(t){return{...t,type:"blockLiteral"}}function Vs(t,e){return Ws(Xt(t,e))}function js(t,e){return Ke(e.transformRange(t.range),t.comment)}function Qs(t,e,n){return{...b("directive",t),...q(),name:e,parameters:n}}function We(t,e){for(let n of t.props){let r=e.text[n.origStart];if(r===me.Comment)e.comments.push(Ke(e.transformRange(n),e.text.slice(n.origStart+1,n.origEnd)));else throw new Error(`Unexpected leading character ${JSON.stringify(r)}`)}}function Gs(t,e){return We(t,e),Qs(e.transformRange(t.range),t.name,t.parameters)}function Hs(t,e,n,r,s,i){return{...b("document",t),...he(i),directivesEndMarker:e,documentEndMarker:n,children:[r,s]}}function U(t=[]){return{endComments:t}}function Js(t,e,n){return{...b("documentBody",t),...U(n),children:e?[e]:[]}}function K(t){return t[t.length-1]}function zt(t,e){let n=t.match(e);return n?n.index:-1}function Xs(t,e,n){let r=t.cstNode,{comments:s,endComments:i,documentTrailingComment:o,documentHeadTrailingComment:a}=Ya(r,e,n),c=e.transformNode(t.contents),{position:l,documentEndPoint:f}=Ba(r,c,e);return e.comments.push(...s,...i),{documentBody:Js(l,c,i),documentEndPoint:f,documentTrailingComment:o,documentHeadTrailingComment:a}}function Ya(t,e,n){let r=[],s=[],i=[],o=[],a=!1;for(let c=t.contents.length-1;c>=0;c--){let l=t.contents[c];if(l.type==="COMMENT"){let f=e.transformNode(l);n&&n.line===f.position.start.line?o.unshift(f):a?r.unshift(f):f.position.start.offset>=t.valueRange.origEnd?i.unshift(f):r.unshift(f)}else a=!0}if(i.length>1)throw new Error(`Unexpected multiple document trailing comments at ${Oe(i[1].position.start)}`);if(o.length>1)throw new Error(`Unexpected multiple documentHead trailing comments at ${Oe(o[1].position.start)}`);return{comments:r,endComments:s,documentTrailingComment:K(i)||null,documentHeadTrailingComment:K(o)||null}}function Ba(t,e,n){let r=zt(n.text.slice(t.valueRange.origEnd),/^\.\.\./),s=r===-1?t.valueRange.origEnd:Math.max(0,t.valueRange.origEnd-1);n.text[s-1]==="\r"&&s--;let i=n.transformRange({origStart:e!==null?e.position.start.offset:s,origEnd:s}),o=r===-1?i.end:n.transformOffset(t.valueRange.origEnd+3);return{position:i,documentEndPoint:o}}function zs(t,e,n,r){return{...b("documentHead",t),...U(n),...he(r),children:e}}function Zs(t,e){let n=t.cstNode,{directives:r,comments:s,endComments:i}=Fa(n,e),{position:o,documentEndMarkererPoint:a}=qa(n,r,e);return e.comments.push(...s,...i),{createDocumentHeadWithTrailingComment:l=>(l&&e.comments.push(l),zs(o,r,i,l)),documentHeadEndMarkerPoint:a}}function Fa(t,e){let n=[],r=[],s=[],i=!1;for(let o=t.directives.length-1;o>=0;o--){let a=e.transformNode(t.directives[o]);a.type==="comment"?i?r.unshift(a):s.unshift(a):(i=!0,n.unshift(a))}return{directives:n,comments:r,endComments:s}}function qa(t,e,n){let r=zt(n.text.slice(0,t.valueRange.origStart),/---\s*$/);r>0&&!/[\r\n]/.test(n.text[r-1])&&(r=-1);let s=r===-1?{origStart:t.valueRange.origStart,origEnd:t.valueRange.origStart}:{origStart:r,origEnd:r+3};return e.length!==0&&(s.origStart=e[0].position.start.offset),{position:n.transformRange(s),documentEndMarkererPoint:r===-1?null:n.transformOffset(r)}}function ei(t,e){let{createDocumentHeadWithTrailingComment:n,documentHeadEndMarkerPoint:r}=Zs(t,e),{documentBody:s,documentEndPoint:i,documentTrailingComment:o,documentHeadTrailingComment:a}=Xs(t,e,r),c=n(a);o&&e.comments.push(o);let l=t.cstNode;return Hs(X(c.position.start,i),!!l.directivesEndMarker,!!l.documentEndMarker,c,s,o)}function Zt(t,e,n){return{...b("flowCollection",t),...q(),...U(),...e,children:n}}function ti(t,e,n){return{...Zt(t,e,n),type:"flowMapping"}}function en(t,e,n){return{...b("flowMappingItem",t),...z(),children:[e,n]}}function de(t,e){let n=[];for(let r of t)r&&"type"in r&&r.type==="COMMENT"?e.comments.push(e.transformNode(r)):n.push(r);return n}function tn(t){let[e,n]=["?",":"].map(r=>{let s=t.find(i=>"char"in i&&i.char===r);return s?{origStart:s.origOffset,origEnd:s.origOffset+1}:null});return{additionalKeyRange:e,additionalValueRange:n}}function nn(t,e){let n=e;return r=>t.slice(n,n=r)}function rn(t){let e=[],n=nn(t,1),r=!1;for(let s=1;s<t.length-1;s++){let i=t[s];if("char"in i&&i.char===","){e.push(n(s)),n(s+1),r=!1;continue}r=!0}return r&&e.push(n(t.length-1)),e}function Xn(t,e){return{...b("mappingKey",t),...he(),...U(),children:e?[e]:[]}}function zn(t,e){return{...b("mappingValue",t),...q(),...U(),children:e?[e]:[]}}function Ve(t,e,n,r,s){let i=e.transformNode(t.key),o=e.transformNode(t.value),a=i||r?Xn(e.transformRange({origStart:r?r.origStart:i.position.start.offset,origEnd:i?i.position.end.offset:r.origStart+1}),i):null,c=o||s?zn(e.transformRange({origStart:s?s.origStart:o.position.start.offset,origEnd:o?o.position.end.offset:s.origStart+1}),o):null;return n(X(a?a.position.start:c.position.start,c?c.position.end:a.position.end),a||Xn(Hn(c.position.start),null),c||zn(Hn(a.position.end),null))}function ni(t,e){let n=de(t.cstNode.items,e),r=rn(n),s=t.items.map((a,c)=>{let l=r[c],{additionalKeyRange:f,additionalValueRange:m}=tn(l);return Ve(a,e,en,f,m)}),i=n[0],o=K(n);return ti(e.transformRange({origStart:i.origOffset,origEnd:o.origOffset+1}),e.transformContent(t),s)}function ri(t,e,n){return{...Zt(t,e,n),type:"flowSequence"}}function si(t,e){return{...b("flowSequenceItem",t),children:[e]}}function ii(t,e){let n=de(t.cstNode.items,e),r=rn(n),s=t.items.map((a,c)=>{if(a.type!=="PAIR"){let l=e.transformNode(a);return si(X(l.position.start,l.position.end),l)}else{let l=r[c],{additionalKeyRange:f,additionalValueRange:m}=tn(l);return Ve(a,e,en,f,m)}}),i=n[0],o=K(n);return ri(e.transformRange({origStart:i.origOffset,origEnd:o.origOffset+1}),e.transformContent(t),s)}function oi(t,e,n){return{...b("mapping",t),...z(),...e,children:n}}function ai(t,e,n){return{...b("mappingItem",t),...z(),children:[e,n]}}function ci(t,e){let n=t.cstNode;n.items.filter(o=>o.type==="MAP_KEY"||o.type==="MAP_VALUE").forEach(o=>We(o,e));let r=de(n.items,e),s=Ua(r),i=t.items.map((o,a)=>{let c=s[a],[l,f]=c[0].type==="MAP_VALUE"?[null,c[0].range]:[c[0].range,c.length===1?null:c[1].range];return Ve(o,e,ai,l,f)});return oi(X(i[0].position.start,K(i).position.end),e.transformContent(t),i)}function Ua(t){let e=[],n=nn(t,0),r=!1;for(let s=0;s<t.length;s++){if(t[s].type==="MAP_VALUE"){e.push(n(s+1)),r=!1;continue}r&&e.push(n(s)),r=!0}return r&&e.push(n(1/0)),e}function li(t,e,n){return{...b("plain",t),...q(),...e,value:n}}function fi(t,e,n){for(let r=e;r>=0;r--)if(n.test(t[r]))return r;return-1}function ui(t,e){let n=t.cstNode;return li(e.transformRange({origStart:n.valueRange.origStart,origEnd:fi(e.text,n.valueRange.origEnd-1,/\S/)+1}),e.transformContent(t),n.strValue)}function pi(t){return{...t,type:"quoteDouble"}}function mi(t,e,n){return{...b("quoteValue",t),...e,...q(),value:n}}function sn(t,e){let n=t.cstNode;return mi(e.transformRange(n.valueRange),e.transformContent(t),n.strValue)}function hi(t,e){return pi(sn(t,e))}function di(t){return{...t,type:"quoteSingle"}}function gi(t,e){return di(sn(t,e))}function yi(t,e,n){return{...b("sequence",t),...z(),...U(),...e,children:n}}function Ei(t,e){return{...b("sequenceItem",t),...q(),...U(),children:e?[e]:[]}}function Si(t,e){let r=de(t.cstNode.items,e).map((s,i)=>{We(s,e);let o=e.transformNode(t.items[i]);return Ei(X(e.transformOffset(s.valueRange.origStart),o===null?e.transformOffset(s.valueRange.origStart+1):o.position.end),o)});return yi(X(r[0].position.start,K(r).position.end),e.transformContent(t),r)}function wi(t,e){if(t===null||t.type===void 0&&t.value===null)return null;switch(t.type){case"ALIAS":return Fs(t,e);case"BLOCK_FOLDED":return Ks(t,e);case"BLOCK_LITERAL":return Vs(t,e);case"COMMENT":return js(t,e);case"DIRECTIVE":return Gs(t,e);case"DOCUMENT":return ei(t,e);case"FLOW_MAP":return ni(t,e);case"FLOW_SEQ":return ii(t,e);case"MAP":return ci(t,e);case"PLAIN":return ui(t,e);case"QUOTE_DOUBLE":return hi(t,e);case"QUOTE_SINGLE":return gi(t,e);case"SEQ":return Si(t,e);default:throw new Error(`Unexpected node type ${t.type}`)}}var Zn,er=class{text;comments=[];#e;#t;constructor(e,n){this.text=n,this.#e=e,this.setOrigRanges()}setOrigRanges(){if(!this.#e.setOrigRanges())for(let e of this.#e)e.setOrigRanges([],0)}#n(e){if(!Zn){let[o]=this.#e,a=Object.getPrototypeOf(Object.getPrototypeOf(o));Zn=Object.getOwnPropertyDescriptor(a,"rangeAsLinePos").get}if(this.#t??(this.#t={root:{context:{src:this.text}}}),this.text===""&&e.origStart===0&&e.origEnd===0)return{start:{offset:0,line:1,column:1},end:{offset:0,line:1,column:1}};let{start:{line:n,col:r},end:{line:s,col:i}}=Zn.call({range:{start:this.#r(e.origStart),end:this.#r(e.origEnd)},context:this.#t});return{start:{offset:e.origStart,line:n,column:r},end:{offset:e.origEnd,line:s,column:i}}}#r(e){return e<0?0:e>this.text.length?this.text.length:e}transformOffset(e){return this.#n({origStart:e,origEnd:e}).start}transformRange(e){let{start:n,end:r}=this.#n(e);return X(n,r)}transformNode(e){return wi(e,this)}transformContent(e){return Jt(e,this)}},bi=er;function Ni(t,e,n){let r=new SyntaxError(t);return r.name="YAMLSyntaxError",r.source=e,r.position=n,r}function Oi(t,e){let n=t.source.range||t.source.valueRange;return Ni(t.message,e.text,e.transformRange(n))}function tr(t){if("children"in t){if(t.children.length===1){let e=t.children[0];if(e.type==="plain"&&e.tag===null&&e.anchor===null&&e.value==="")return t.children.splice(0,1),t}t.children.forEach(tr)}return t}function nr(t,e,n,r){let s=e(t);return i=>{r(s,i)&&n(t,s=i)}}function rr(t){if(t===null||!("children"in t))return;let e=t.children;if(e.forEach(rr),t.type==="document"){let[i,o]=t.children;i.position.start.offset===i.position.end.offset?i.position.start=i.position.end=o.position.start:o.position.start.offset===o.position.end.offset&&(o.position.start=o.position.end=i.position.end)}let n=nr(t.position,Ka,Wa,Qa),r=nr(t.position,Va,ja,Ga);"endComments"in t&&t.endComments.length!==0&&(n(t.endComments[0].position.start),r(K(t.endComments).position.end));let s=e.filter(i=>i!==null);if(s.length!==0){let i=s[0],o=K(s);n(i.position.start),r(o.position.end),"leadingComments"in i&&i.leadingComments.length!==0&&n(i.leadingComments[0].position.start),"tag"in i&&i.tag&&n(i.tag.position.start),"anchor"in i&&i.anchor&&n(i.anchor.position.start),"trailingComment"in o&&o.trailingComment&&r(o.trailingComment.position.end)}}function Ka(t){return t.start}function Wa(t,e){t.start=e}function Va(t){return t.end}function ja(t,e){t.end=e}function Qa(t,e){return e.offset<t.offset}function Ga(t,e){return e.offset>t.offset}var Ai='Map keys must be unique; "',Li='" is repeated',Ha=`${Ai}<<${Li}`;function Ja(t,e){if(!(t instanceof vs))return!1;let{message:n}=t;return n===Ha||e&&n.startsWith(Ai)&&n.endsWith(Li)}function Ti(t,e){let n=e?.allowDuplicateKeysInMap,r=sr.default.parseCST(t),s=new bi(r,t),i=[];for(let a of r){let c=new sr.default.Document({merge:!1,keepCstNodes:!0}).parse(a);for(let f of c.errors)if(!Ja(f,n))throw Oi(f,s);pt(c.cstNode);let l=s.transformNode(c);i.push(l)}let o=Rs(s.transformRange({origStart:0,origEnd:t.length}),i,s.comments);return Is(o),rr(o),tr(o),o}function Xa(t,e){let n=new SyntaxError(t+" ("+e.loc.start.line+":"+e.loc.start.column+")");return Object.assign(n,e)}var Mi=Xa;var za={allowDuplicateKeysInMap:!0};function Za(t){try{let e=Ti(t,za);return delete e.comments,e}catch(e){throw e?.position?Mi(e.message,{loc:e.position,cause:e}):e}}var ec={astFormat:"yaml",parse:Za,hasPragma:br,hasIgnorePragma:Nr,locStart:tt,locEnd:vr};var tc={yaml:qr};var Ci=an(Gn(),1),nc=Ci.default.parse;export{nc as __parsePrettierYamlConfig,ki as default,Ur as languages,Kr as options,ir as parsers,tc as printers};
|