import t from"../../../../../_virtual/index19.mjs";import{isString as e,isRegExp as r}from"../../utils/validateTypes.mjs";import o from"../../utils/arrayEqual.mjs";import{basicKeywords as n}from"../../reference/keywords.mjs";import i from"../../utils/eachDeclarationBlock.mjs";import{longhandSubPropertiesOfShorthandProperties as s}from"../../reference/properties.mjs";import a from"../../utils/optionsMatches.mjs";import l from"../../utils/report.mjs";import u from"../../utils/ruleMessages.mjs";import p from"../../utils/validateOptions.mjs";import m from"../../utils/vendor.mjs";const g="declaration-block-no-redundant-longhand-properties",c=u(g,{expected:t=>`Expected shorthand property "${t}"`}),d=new Map([["font-synthesis",t=>{const e=t.get("font-synthesis-weight")?.value.trim(),r=t.get("font-synthesis-style")?.value.trim(),o=t.get("font-synthesis-small-caps")?.value.trim(),n=t=>"none"===t||"auto"===t;if(!n(e)||!n(r)||!n(o))return;const i=[];return"auto"===e&&i.push("weight"),"auto"===r&&i.push("style"),"auto"===o&&i.push("small-caps"),0===i.length?"none":i.join(" ")}],["grid-column",t=>{const e=t.get("grid-column-start")?.value.trim(),r=t.get("grid-column-end")?.value.trim();if(e&&r)return`${e} / ${r}`}],["grid-row",t=>{const e=t.get("grid-row-start")?.value.trim(),r=t.get("grid-row-end")?.value.trim();if(e&&r)return`${e} / ${r}`}],["grid-template",t=>{const e=t.get("grid-template-areas")?.value.trim(),r=t.get("grid-template-columns")?.value.trim(),o=t.get("grid-template-rows")?.value.trim();if(!(e&&r&&o))return;if(r.includes("repeat(")||o.includes("repeat("))return;const n=[...e.matchAll(/"[^"]+"/g)].map(t=>t[0]),i=o.split(" ");if(0===n.length||0===i.length)return;if(n.length!==i.length)return;return`${n.map((t,e)=>`${t} ${i[e]}`).join(" ")} / ${r}`}],["transition",r=>{const o=(e="")=>{let r=e.trim();if(!r)return[];if(-1===r.indexOf(","))return[r];let o=t(r),n=[];{let t=[];o.nodes.forEach(e=>{if("div"===e.type&&","===e.value)return n.push(t),void(t=[]);t.push(e)}),n.push(t)}return n.map(e=>t.stringify(e).trim()).filter(t=>t.length>0)},n=o(r.get("transition-delay")?.value),i=o(r.get("transition-duration")?.value),s=o(r.get("transition-timing-function")?.value),a=o(r.get("transition-property")?.value);if(n.length&&i.length&&s.length&&a.length)return a.map((t,r)=>[t,i[r%i.length],s[r%s.length],n[r%n.length]].filter(e).join(" ")).join(", ")}]]),f=["border-width","border-style","border-color","border-top","border-right","border-bottom","border-left","grid-column","grid-row"],h=(t,e,r)=>{const o=d.get(t);if(void 0===o){const t=e.map(t=>r.get(t)?.value.trim()).filter(Boolean);return t.length>0?t.join(" "):void 0}return o(r)},v=(t,u)=>(d,v)=>{if(!p(v,g,{actual:t},{actual:u,possible:{ignoreShorthands:[e,r],ignoreLonghands:[e]},optional:!0}))return;const w=new Map,y=[u?.ignoreLonghands??[]].flat();for(const[t,e]of s.entries())if(!a(u,"ignoreShorthands",t))for(const r of e){if(y.includes(r))continue;const e=w.get(r)||[];e.push(t),w.set(r,e)}i(d,t=>{const e=new Map,r=new Map;t(t=>{if(n.has(t.value))return;const i=t.prop.toLowerCase(),a=m.unprefixed(i),u=m.prefix(i),p=w.get(a);if(p)for(const n of p){const a=u+n,p=e.get(a)||[],m=r.get(a)||[];p.push(i),e.set(a,p),m.push(t),r.set(a,m);const d=new Set(s.get(n));y.forEach(t=>d.delete(t));const w=Array.from(d,t=>u+t),j=[...w];if(!o(j.sort(),p.sort()))continue;const b=r.get(a)||[],x=b.reduce((t,e)=>e.important?t+=1:t,0);if(x&&x!==b.length)continue;const[$]=b;let M;if($){const t=new Map(b.map(t=>[t.prop.toLowerCase(),t]));M=h(a,w,t)}const E=$&&M?()=>{const t=$.clone({prop:a,value:M});$.replaceWith(t),b.forEach(t=>t.remove()),f.includes(n)&&e.forEach((t,r)=>{e.set(r,t.filter(t=>!p.includes(t)))})}:void 0;l({ruleName:g,result:v,node:t,word:t.prop,message:c.expected,messageArgs:[a],fix:{apply:E,node:t.parent}})}})})};v.ruleName=g,v.messages=c,v.meta={url:"https://stylelint.io/user-guide/rules/declaration-block-no-redundant-longhand-properties",fixable:!0};export{v as default};