import e from"../../../../../_virtual/index19.mjs";import{declarationValueIndex as r}from"../../utils/nodeFieldIndices.mjs";import o from"../../utils/isStandardSyntaxDeclaration.mjs";import t from"../../utils/isStandardSyntaxProperty.mjs";import n from"../../utils/isStandardSyntaxValue.mjs";import i from"../../utils/isVarFunction.mjs";import s from"../../utils/optionsMatches.mjs";import a from"../../utils/report.mjs";import l from"../../utils/ruleMessages.mjs";import d from"../../utils/validateOptions.mjs";import u from"../../utils/vendor.mjs";import{isValueDiv as c,isValueWord as m,isValueFunction as f}from"../../utils/typeGuards.mjs";const p="shorthand-property-no-redundant-values",g=l(p,{expected:(e,r)=>`Expected "${e}" to be "${r}"`}),h=new Set(["margin","margin-block","margin-inline","padding","padding-block","padding-inline","border-color","border-style","border-width","border-radius","border-block-color","border-block-style","border-block-width","border-inline-color","border-inline-style","border-inline-width","gap","grid-gap","overflow","overscroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-inline","scroll-padding","scroll-padding-block","scroll-padding-inline","inset","inset-block","inset-inline"]),b=new Set(["margin","padding","border-color","border-style","border-width","scroll-margin","scroll-padding","inset"]);function v(e,r,o,t){const n=e.toLowerCase(),i=r.toLowerCase(),s=o&&o.toLowerCase(),a=t&&t.toLowerCase();return function(e,r,o,t){if(e!==r)return!1;return e===o&&(o===t||!t)||!o&&!t}(n,i,s,a)?[e]:function(e,r,o,t){return e===o&&r===t||e===o&&!t&&e!==r}(n,i,s,a)?[e,r]:function(e,r,o,t){return r===t}(0,i,0,a)?[e,r,o]:[e,r,o,t]}const w=(l,w)=>(j,x)=>{d(x,p,{actual:l},{actual:w,possible:{ignore:["four-into-three-edge-values"]},optional:!0})&&j.walkDecls(l=>{if(!o(l))return;const{prop:d,value:j}=l;if(!t(d))return;if(!n(j))return;const y=u.unprefixed(d.toLowerCase());if(!h.has(y))return;if("border-radius"===y){const{horizontal:o,vertical:t,sawSlash:n,horizontalHasVar:s,verticalHasVar:d}=function(r){const o=[],t=[];let n=!1,s=!1,a=!1;for(const l of e(r).nodes){if(c(l)){if("/"===l.value){n=!0;continue}return{horizontal:[],vertical:[],sawSlash:!1,horizontalHasVar:!1,verticalHasVar:!1}}if(i(l)&&(n?a=!0:s=!0),m(l)||f(l)){const r=e.stringify(l);n?t.push(r):o.push(r)}}return{horizontal:o,vertical:t,sawSlash:n,horizontalHasVar:s,verticalHasVar:a}}(j);if(n)return void function(e,o,t,n,i,s){const[l="",d="",u="",c=""]=t,[m="",f="",h="",b=""]=n,w=`${i?t.join(" "):v(l,d,u,c).filter(Boolean).join(" ")} / ${s?n.join(" "):v(m,f,h,b).filter(Boolean).join(" ")}`.trim();if(o.value.trim().toLowerCase().replace(/\s+/g," ")===w.toLowerCase())return;const j=r(o),x=j+o.value.length;a({message:g.expected,messageArgs:[o.value,w],node:o,index:j,endIndex:x,result:e,ruleName:p,fix:{apply:()=>{o.value=w},node:o}})}(x,l,o,t,s,d)}const S=[];for(const r of e(j).nodes){if(c(r))return;if(i(r))return;(m(r)||f(r))&&S.push(e.stringify(r))}if(S.length<=1||S.length>4)return;const[k="",C="",L="",V=""]=S,z=v(k,C,L,V);if(s(w,"ignore","four-into-three-edge-values")&&b.has(y)&&4===S.length&&3===z.length)return;const H=z.filter(Boolean).join(" "),$=S.join(" ");if(H.toLowerCase()===$.toLowerCase())return;const B=r(l),I=B+l.value.length;a({message:g.expected,messageArgs:[j,H],node:l,index:B,endIndex:I,result:x,ruleName:p,fix:{apply:()=>{l.value=l.value.replace(j,H)},node:l}})})};w.ruleName=p,w.messages=g,w.meta={url:"https://stylelint.io/user-guide/rules/shorthand-property-no-redundant-values",fixable:!0};export{w as default};