"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const z=require("./Enum.js"),e=require("./Utility.js"),r=require("./Tokenizer.js");function C(c){return r.dealloc(M("",null,null,null,[""],c=r.alloc(c),0,[0],c))}function M(c,k,b,i,f,E,O,o,v){for(var u=0,l=0,s=O,y=0,h=0,p=0,n=1,q=1,m=1,t=0,w="",T=f,g=E,d=i,a=w;q;)switch(p=t,t=r.next()){case 40:if(p!=108&&e.charat(a,s-1)==58){e.indexof(a+=e.replace(r.delimit(t),"&","&\f"),"&\f",e.abs(u?o[u-1]:0))!=-1&&(m=-1);break}case 34:case 39:case 91:a+=r.delimit(t);break;case 9:case 10:case 13:case 32:a+=r.whitespace(p);break;case 92:a+=r.escaping(r.caret()-1,7);continue;case 47:switch(r.peek()){case 42:case 47:e.append(A(r.commenter(r.next(),r.caret()),k,b,v),v),(r.token(p||1)==5||r.token(r.peek()||1)==5)&&e.strlen(a)&&e.substr(a,-1,void 0)!==" "&&(a+=" ");break;default:a+="/"}break;case 123*n:o[u++]=e.strlen(a)*m;case 125*n:case 59:case 0:switch(t){case 0:case 125:q=0;case 59+l:m==-1&&(a=e.replace(a,/\f/g,"")),h>0&&(e.strlen(a)-s||n===0&&p===47)&&e.append(h>32?x(a+";",i,b,s-1,v):x(e.replace(a," ","")+";",i,b,s-2,v),v);break;case 59:a+=";";default:if(e.append(d=S(a,k,b,u,l,f,o,w,T=[],g=[],s,E),E),t===123)if(l===0)M(a,k,d,d,T,E,s,o,g);else{switch(y){case 99:if(e.charat(a,3)===110)break;case 108:if(e.charat(a,2)===97)break;default:l=0;case 100:case 109:case 115:}l?M(c,d,d,i&&e.append(S(c,d,d,0,0,f,o,w,f,T=[],s,g),g),f,g,s,o,i?T:g):M(a,d,d,d,[""],g,0,o,g)}}u=l=h=0,n=m=1,w=a="",s=O;break;case 58:s=1+e.strlen(a),h=p;default:if(n<1){if(t==123)--n;else if(t==125&&n++==0&&r.prev()==125)continue}switch(a+=e.from(t),t*n){case 38:m=l>0?1:(a+="\f",-1);break;case 44:o[u++]=(e.strlen(a)-1)*m,m=1;break;case 64:r.peek()===45&&(a+=r.delimit(r.next())),y=r.peek(),l=s=e.strlen(w=a+=r.identifier(r.caret())),t++;break;case 45:p===45&&e.strlen(a)==2&&(n=0)}}return E}function S(c,k,b,i,f,E,O,o,v,u,l,s){for(var y=f-1,h=f===0?E:[""],p=e.sizeof(h),n=0,q=0,m=0;n<i;++n)for(var t=0,w=e.substr(c,y+1,y=e.abs(q=O[n])),T=c;t<p;++t)(T=e.trim(q>0?h[t]+" "+w:e.replace(w,/&\f/g,h[t])))&&(v[m++]=T);return r.node(c,k,b,f===0?z.RULESET:o,v,u,l,s)}function A(c,k,b,i){return r.node(c,k,b,z.COMMENT,e.from(r.char()),e.substr(c,2,-2),0,i)}function x(c,k,b,i,f){return r.node(c,k,b,z.DECLARATION,e.substr(c,0,i),e.substr(c,i+1,-1),i,f)}exports.comment=A;exports.compile=C;exports.declaration=x;exports.parse=M;exports.ruleset=S;
