import{getLastItem as r}from"./array.js";import{isNumber as e,isObject as n}from"./assertion.js";import{fromEntries as t}from"./object.js";function a(r){if(null==r)return r;var{unitless:n}=function(r){var e=parseFloat(r.toString()),n=r.toString().replace(String(e),"");return{unitless:!n,value:e,unit:n}}(r);return n||e(r)?r+"px":r}var u=(r,e)=>parseInt(r[1],10)>parseInt(e[1],10)?1:-1,l=r=>t(Object.entries(r).sort(u));function i(r){var e=l(r);return Object.assign(Object.values(e),e)}function s(r,e){var n=[];return r&&n.push("@media screen and (min-width: "+a(r)+")"),n.length>0&&e&&n.push("and"),e&&n.push("@media screen and (max-width: "+a(e)+")"),n.join(" ")}function o(t){var o;if(!t)return null;t.base=null!=(o=t.base)?o:"0px";var c=i(t),p=Object.entries(t).sort(u).map(((r,n,t)=>{var u,[l,i]=r,[,o]=null!=(u=t[n+1])?u:[];return{breakpoint:l,minW:i,maxW:o=parseFloat(o)>0?function(r){var n;if(!r)return r;var t=(r=null!=(n=a(r))?n:r).endsWith("px")?-1:-.0635;return e(r)?""+(r+t):r.replace(/([0-9]+\.?[0-9]*)/,(r=>""+(parseFloat(r)+t)))}(o):void 0,maxWQuery:s(null,o),minWQuery:s(i),minMaxQuery:s(i,o)}})),m=function(r){var e=Object.keys(l(r));return new Set(e)}(t),v=Array.from(m.values());return{keys:m,normalized:c,isResponsive(r){var e=Object.keys(r);return e.length>0&&e.every((r=>m.has(r)))},asObject:l(t),asArray:i(t),details:p,media:[null,...c.map((r=>s(r))).slice(1)],toArrayValue(e){if(!n(e))throw new Error("toArrayValue: value must be an object");for(var t=v.map((r=>{var n;return null!=(n=e[r])?n:null}));null===r(t);)t.pop();return t},toObjectValue(r){if(!Array.isArray(r))throw new Error("toObjectValue: value must be an array");return r.reduce(((r,e,n)=>{var t=v[n];return null!=t&&null!=e&&(r[t]=e),r}),{})}}}export{o as analyzeBreakpoints,a as px};
//# sourceMappingURL=breakpoint.js.map
