import{isString as e,isRegExp as t}from"../../utils/validateTypes.mjs";import m from"../../utils/fixEmptyLinesBefore.mjs";import r from"../../utils/hasEmptyLine.mjs";import o from"../../utils/isAfterComment.mjs";import{isConfigurationComment as s}from"../../utils/configurationComment.mjs";import i from"../../utils/isFirstNested.mjs";import n from"../../utils/isFirstNodeOfRoot.mjs";import l from"../../utils/isSharedLineComment.mjs";import a from"../../utils/isStandardSyntaxComment.mjs";import f from"../../utils/optionsMatches.mjs";import p from"../../utils/report.mjs";import u from"../../utils/ruleMessages.mjs";import c from"../../utils/validateOptions.mjs";const d="comment-empty-line-before",j=u(d,{expected:"Expected empty line before comment",rejected:"Unexpected empty line before comment"}),y=(u,y,g)=>(x,b)=>{c(b,d,{actual:u,possible:["always","never"]},{actual:y,possible:{except:["first-nested"],ignore:["stylelint-commands","after-comment"],ignoreComments:[e,t]},optional:!0})&&x.walkComments(e=>{if(n(e))return;if(s(e,g.configurationComment)&&f(y,"ignore","stylelint-commands"))return;if(f(y,"ignore","after-comment")&&o(e))return;if(f(y,"ignoreComments",e.text))return;if(l(e))return;if(!a(e))return;const t=!(f(y,"except","first-nested")&&i(e)||"always"!==u),c=e.raws.before||"";if(t===r(c))return;const x=t?j.expected:j.rejected,C=t?"add":"remove";p({message:x,messageArgs:[],node:e,result:b,ruleName:d,fix:{apply:()=>m({node:e,newline:g.newline,action:C}),node:e.parent}})})};y.ruleName=d,y.messages=j,y.meta={url:"https://stylelint.io/user-guide/rules/comment-empty-line-before",fixable:!0};export{y as default};