UNPKG

ll-package

Version:

2 lines (1 loc) 2.83 kB
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function p(e){if(typeof e=="number")return[e];const n=String(e).split(/\s+/);let d="",t=0;return n.reduce((r,o)=>(o.includes("(")?(d+=o,t+=o.split("(").length-1):o.includes(")")?(d+=` ${o}`,t-=o.split(")").length-1,t===0&&(r.push(d),d="")):t>0?d+=` ${o}`:r.push(o),r),[])}function l(e){return e.notSplit=!0,e}const c={inset:["top","right","bottom","left"],insetBlock:["top","bottom"],insetBlockStart:["top"],insetBlockEnd:["bottom"],insetInline:["left","right"],insetInlineStart:["left"],insetInlineEnd:["right"],marginBlock:["marginTop","marginBottom"],marginBlockStart:["marginTop"],marginBlockEnd:["marginBottom"],marginInline:["marginLeft","marginRight"],marginInlineStart:["marginLeft"],marginInlineEnd:["marginRight"],paddingBlock:["paddingTop","paddingBottom"],paddingBlockStart:["paddingTop"],paddingBlockEnd:["paddingBottom"],paddingInline:["paddingLeft","paddingRight"],paddingInlineStart:["paddingLeft"],paddingInlineEnd:["paddingRight"],borderBlock:l(["borderTop","borderBottom"]),borderBlockStart:l(["borderTop"]),borderBlockEnd:l(["borderBottom"]),borderInline:l(["borderLeft","borderRight"]),borderInlineStart:l(["borderLeft"]),borderInlineEnd:l(["borderRight"]),borderBlockWidth:["borderTopWidth","borderBottomWidth"],borderBlockStartWidth:["borderTopWidth"],borderBlockEndWidth:["borderBottomWidth"],borderInlineWidth:["borderLeftWidth","borderRightWidth"],borderInlineStartWidth:["borderLeftWidth"],borderInlineEndWidth:["borderRightWidth"],borderBlockStyle:["borderTopStyle","borderBottomStyle"],borderBlockStartStyle:["borderTopStyle"],borderBlockEndStyle:["borderBottomStyle"],borderInlineStyle:["borderLeftStyle","borderRightStyle"],borderInlineStartStyle:["borderLeftStyle"],borderInlineEndStyle:["borderRightStyle"],borderBlockColor:["borderTopColor","borderBottomColor"],borderBlockStartColor:["borderTopColor"],borderBlockEndColor:["borderBottomColor"],borderInlineColor:["borderLeftColor","borderRightColor"],borderInlineStartColor:["borderLeftColor"],borderInlineEndColor:["borderRightColor"],borderStartStartRadius:["borderTopLeftRadius"],borderStartEndRadius:["borderTopRightRadius"],borderEndStartRadius:["borderBottomLeftRadius"],borderEndEndRadius:["borderBottomRightRadius"]};function g(e){return{_skip_check_:!0,value:e}}const h={visit:e=>{const n={};return Object.keys(e).forEach(d=>{const t=e[d],r=c[d];if(r&&(typeof t=="number"||typeof t=="string")){const o=p(t);r.length&&r.notSplit?r.forEach(a=>{n[a]=g(t)}):r.length===1?n[r[0]]=g(t):r.length===2?r.forEach((a,b)=>{var i;n[a]=g((i=o[b])!==null&&i!==void 0?i:o[0])}):r.length===4?r.forEach((a,b)=>{var i,s;n[a]=g((s=(i=o[b])!==null&&i!==void 0?i:o[b-2])!==null&&s!==void 0?s:o[0])}):n[d]=t}else n[d]=t}),n}},f=h;exports.default=f;