const t=Object.freeze({left:0,top:0,width:16,height:16}),e=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),n=Object.freeze({...t,...e}),i=Object.freeze({...n,body:"",hidden:!1}),r=Object.freeze({width:null,height:null}),o=Object.freeze({...r,...e}),l=(t,e,n,i="")=>{const r=t.split(":");if("@"===t.slice(0,1)){if(r.length<2||r.length>3)return null;i=r.shift().slice(1)}if(r.length>3||!r.length)return null;if(r.length>1){const t=r.pop(),e=r.pop(),n={provider:r.length>0?r[0]:i,prefix:e,name:t};return s(n)?n:null}const o=r[0],l=o.split("-");if(l.length>1){const t={provider:i,prefix:l.shift(),name:l.join("-")};return s(t)?t:null}if(n&&""===i){const t={provider:i,prefix:"",name:o};return s(t,n)?t:null}return null},s=(t,e)=>!!t&&!(!(e&&""===t.prefix||t.prefix)||!t.name);function c(t,n){const r=function(t,e){const n={};!t.hFlip!=!e.hFlip&&(n.hFlip=!0),!t.vFlip!=!e.vFlip&&(n.vFlip=!0);const i=((t.rotate||0)+(e.rotate||0))%4;return i&&(n.rotate=i),n}(t,n);for(const o in i)o in e?o in t&&!(o in r)&&(r[o]=e[o]):o in n?r[o]=n[o]:o in t&&(r[o]=t[o]);return r}function f(t,e,n){const i=t.icons,r=t.aliases||Object.create(null);let o={};function l(t){o=c(i[t]||r[t],o)}return l(e),n.forEach(l),c(t,o)}function h(t,e){if(t.icons[e])return f(t,e,[]);const n=function(t,e){const n=t.icons,i=t.aliases||Object.create(null),r=Object.create(null);return(e||Object.keys(n).concat(Object.keys(i))).forEach(function t(e){if(n[e])return r[e]=[];if(!(e in r)){r[e]=null;const n=i[e]&&i[e].parent,o=n&&t(n);o&&(r[e]=[n].concat(o))}return r[e]}),r}(t,[e])[e];return n?f(t,e,n):null}const u=/(-?[0-9.]*[0-9]+[0-9.]*)/g,a=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function p(t,e,n){if(1===e)return t;if(n=n||100,"number"==typeof t)return Math.ceil(t*e*n)/n;if("string"!=typeof t)return t;const i=t.split(u);if(null===i||!i.length)return t;const r=[];let o=i.shift(),l=a.test(o);for(;;){if(l){const t=parseFloat(o);isNaN(t)?r.push(o):r.push(Math.ceil(t*e*n)/n)}else r.push(o);if(o=i.shift(),void 0===o)return r.join("");l=!l}}function g(t,e){const i={...n,...t},r={...o,...e},l={left:i.left,top:i.top,width:i.width,height:i.height};let s=i.body;[i,r].forEach(t=>{const e=[],n=t.hFlip,i=t.vFlip;let r,o=t.rotate;switch(n?i?o+=2:(e.push("translate("+(l.width+l.left).toString()+" "+(0-l.top).toString()+")"),e.push("scale(-1 1)"),l.top=l.left=0):i&&(e.push("translate("+(0-l.left).toString()+" "+(l.height+l.top).toString()+")"),e.push("scale(1 -1)"),l.top=l.left=0),o<0&&(o-=4*Math.floor(o/4)),o%=4,o){case 1:r=l.height/2+l.top,e.unshift("rotate(90 "+r.toString()+" "+r.toString()+")");break;case 2:e.unshift("rotate(180 "+(l.width/2+l.left).toString()+" "+(l.height/2+l.top).toString()+")");break;case 3:r=l.width/2+l.left,e.unshift("rotate(-90 "+r.toString()+" "+r.toString()+")")}o%2==1&&(l.left!==l.top&&(r=l.left,l.left=l.top,l.top=r),l.width!==l.height&&(r=l.width,l.width=l.height,l.height=r)),e.length&&(s=function(t,e,n){const i=function(t,e="defs"){let n="";const i=t.indexOf("<"+e);for(;i>=0;){const r=t.indexOf(">",i),o=t.indexOf("</"+e);if(-1===r||-1===o)break;const l=t.indexOf(">",o);if(-1===l)break;n+=t.slice(r+1,o).trim(),t=t.slice(0,i).trim()+t.slice(l+1)}return{defs:n,content:t}}(t);return r=i.defs,o=e+i.content+n,r?"<defs>"+r+"</defs>"+o:o;var r,o}(s,'<g transform="'+e.join(" ")+'">',"</g>"))});const c=r.width,f=r.height,h=l.width,u=l.height;let a,g;null===c?(g=null===f?"1em":"auto"===f?u:f,a=p(g,h/u)):(a="auto"===c?h:c,g=null===f?p(a,u/h):"auto"===f?u:f);const d={},w=(t,e)=>{(t=>"unset"===t||"undefined"===t||"none"===t)(e)||(d[t]=e.toString())};w("width",a),w("height",g);const x=[l.left,l.top,h,u];return d.viewBox=x.join(" "),{attributes:d,viewBox:x,body:s}}const d=/\sid="(\S+)"/g,w=new Map;function x(t){const e=[];let n;for(;n=d.exec(t);)e.push(n[1]);if(!e.length)return t;const i="suffix"+(16777216*Math.random()|Date.now()).toString(16);return e.forEach(e=>{const n=function(t){t=t.replace(/[0-9]+$/,"")||"a";const e=w.get(t)||0;return w.set(t,e+1),e?`${t}${e}`:t}(e),r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");t=t.replace(new RegExp('([#;"])('+r+')([")]|\\.[a-z])',"g"),"$1"+n+i+"$3")}),t=t.replace(new RegExp(i,"g"),"")}function b(t,e){let n=-1===t.indexOf("xlink:")?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(const i in e)n+=" "+i+'="'+e[i]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+n+">"+t+"</svg>"}export{b as a,h as g,g as i,x as r,l as s};
