File: //var/www/ridesyre-land/node_modules/postcss-nesting/dist/index.mjs
import e from"postcss-selector-parser";import t from"@csstools/selector-specificity";function n(e){if(!e.nodes.length)return void e.remove();const t=e.nodes.filter((e=>"comment"===e.type));t.length===e.nodes.length&&e.replaceWith(...t)}function o(e){const t=e.parent,o=t.index(e);if(o){n(t.cloneBefore().removeAll().append(t.nodes.slice(0,o)))}return t.before(e),t}function r(e,t){if(t<2)throw new Error("n must be greater than 1");if(e.length<2)throw new Error("s must be greater than 1");if(Math.pow(e.length,t)>1e4)throw new Error("Too many combinations when trying to resolve a nested selector with lists, reduce the complexity of your selectors");const n=[];for(let e=0;e<t;e++)n[e]=0;const o=[];for(;;){const r=[];for(let s=t-1;s>=0;s--){let t=n[s];if(t>=e.length){if(t=0,n[s]=0,0===s)return o;n[s-1]+=1}r[s]=e[t]}o.push(r),n[n.length-1]++}}const s=e.pseudo({value:":is"});function c(e){const t=e.nodes.filter((e=>"tag"===e.type));t.length>1&&t.slice(1).forEach((e=>{const t=s.clone();e.replaceWith(t),t.append(e)}))}function l(t,n){let o=[],r=!1;const s=[...t.nodes];for(let t=0;t<s.length+1;t++){const l=s[t];if(l&&"combinator"!==l.type)"nesting"===l.type&&(r=!0),o.push(l);else{if(r){o=[];continue}if(o.length>1){const t=e.selector();o[0].replaceWith(t),o.slice(1).forEach((e=>{e.remove()})),o.forEach((e=>{t.append(e)})),i(t),n&&c(t),t.replaceWith(...t.nodes)}o=[]}}}function i(e){e.nodes.sort(((e,t)=>p(e,e.type)-p(t,t.type)))}function p(t,n){return e.isPseudoElement(t)?a.pseudoElement:a[n]}const a={universal:0,tag:1,id:2,class:3,attribute:4,selector:5,pseudo:6,pseudoElement:7,string:8,root:9,comment:10,nesting:9999};function u(n,o,s){let p=[];p=function(n){const o=n.map((t=>e().astSync(t))).map((e=>t(e))),r=o[0];for(let e=1;e<o.length;e++)if(r.a!==o[e].a||r.b!==o[e].b||r.c!==o[e].c)return!1;return!0}(n)||s.noIsPseudoSelector?n.map((t=>e().astSync(t))):[e().astSync(`:is(${n.join(",")})`)];let a=[];for(let t=0;t<o.length;t++){const n=o[t];let u=1,y=[],g=0;if(e().astSync(n).walkNesting((()=>{g++})),g>1&&p.length>1)y=r(p,g),u=y.length;else{u=p.length;for(let e=0;e<p.length;e++){y.push([]);for(let t=0;t<g;t++)y[e].push(p[e])}}for(let t=0;t<u;t++){let o=0;const r=e().astSync(n);r.walk((n=>{if("nesting"!==n.type)return;let r=y[t][o];o++,"root"===r.type&&1===r.nodes.length&&(r=r.nodes[0]);const p=e().astSync(`:is(${r.toString()})`),a=d(r.nodes[0]),u=f(r.nodes[0]),g=d(n),v=f(n);if(a&&g)return void n.replaceWith(r.clone());if((a||u)&&(g||v)){const e=n.parent;return a&&"selector"===r.type?n.replaceWith(r.clone().nodes[0]):n.replaceWith(...r.clone().nodes),void(e&&e.nodes.length>1&&(i(e),s.noIsPseudoSelector||c(e)))}if(a){const e=n.parent;return n.replaceWith(r.clone().nodes[0]),void(e&&l(e,!s.noIsPseudoSelector))}if(u){const e=n.parent;return n.replaceWith(...r.clone().nodes),void(e&&l(e,!s.noIsPseudoSelector))}if(h(n)){const e=n.parent;return n.replaceWith(...r.clone().nodes),void(e&&l(e,!s.noIsPseudoSelector))}if(m(n)){const e=n.parent;return n.replaceWith(...r.clone().nodes),void(e&&l(e,!s.noIsPseudoSelector))}const b=n.parent;s.noIsPseudoSelector?n.replaceWith(...r.clone().nodes):n.replaceWith(...p.clone().nodes),b&&l(b,!s.noIsPseudoSelector)})),a.push(r.toString())}}return a}function d(e){return"combinator"!==e.type&&!(e.parent&&e.parent.nodes.length>1)}function f(e,t=null){if(d(e))return!1;if(!e.parent)return!1;if(!!e.parent.nodes.find((e=>"combinator"===e.type||"comment"===e.type)))return!1;return!(!!e.parent.nodes.find((e=>"nesting"===e.type))&&t&&!f(t))}function h(e){if(!e.parent)return!1;if(0!==e.parent.nodes.indexOf(e))return!1;for(let t=1;t<e.parent.nodes.length;t++)if("combinator"===e.parent.nodes[t].type&&" "!==e.parent.nodes[t].value&&">"!==e.parent.nodes[t].value)return!1;return!0}function m(e){if(d(e))return!0;if(!e.parent)return!1;for(let t=0;t<e.parent.nodes.length;t++)if("nesting"!==!e.parent.nodes[t].type&&(e.parent.nodes[t].prev()||e.parent.nodes[t].next())){if(e.parent.nodes[t].prev()&&"combinator"!==e.parent.nodes[t].prev().type)return!1;if(e.parent.nodes[t].next()&&"combinator"!==e.parent.nodes[t].next().type)return!1}return!0}const y=e=>{let t=[],n="",o=!1,r=0,s=!1,c=!1;for(let l of e)c?c=!1:"\\"===l?c=!0:s?l===s&&(s=!1):'"'===l||"'"===l?s=l:"("===l?r+=1:")"===l?r>0&&(r-=1):0===r&&","===l&&(o=!0),o?(""!==n&&t.push(n.trim()),n="",o=!1):n+=l;return t.push(n.trim()),t};var g=["container","document","media","supports"];function v(e){const t=o(e);var r,s;e.params=(r=t.params,s=e.params,y(r).map((e=>y(s).map((t=>`${e} and ${t}`)).join(", "))).join(", ")),n(t)}function b(e,t){e.each((e=>{(e=>"rule"===e.type&&"rule"===Object(e.parent).type&&e.selectors.every((e=>0===e.trim().indexOf("&")&&-1===e.indexOf("|"))))(e)?function(e,t){const r=o(e);e.selectors=u(r.selectors,e.selectors,t),("rule"===e.type&&"rule"===r.type&&e.selector===r.selector||"atrule"===e.type&&"atrule"===r.type&&e.params===r.params)&&e.append(...r.nodes),n(r)}(e,t):(e=>"atrule"===e.type&&"nest"===e.name&&"rule"===Object(e.parent).type&&y(e.params).every((e=>e.split("&").length>=2&&-1===e.indexOf("|"))))(e)?function(e,t,r){const s=o(e),c=s.clone().removeAll().append(e.nodes);e.replaceWith(c),c.selectors=u(s.selectors,y(e.params),r),n(s),t(c,r)}(e,b,t):(e=>"atrule"===e.type&&g.includes(e.name)&&"rule"===Object(e.parent).type)(e)?function(e,t,r){const s=o(e),c=s.clone().removeAll().append(e.nodes);e.append(c),n(s),t(c,r)}(e,b,t):(e=>"atrule"===e.type&&g.includes(e.name)&&"atrule"===Object(e.parent).type&&e.name===e.parent.name)(e)&&v(e),Object(e.nodes).length&&b(e,t)}))}function S(e){const t=Object(e).noIsPseudoSelector||!1;return{postcssPlugin:"postcss-nesting",Rule(e){b(e,{noIsPseudoSelector:t})}}}S.postcss=!0;export{S as default};