UNPKG

code-server

Version:

Run VS Code on a remote server.

2 lines (1 loc) • 5.88 kB
import{H as M,u as G}from"./chunk-5Z3D3SW5.js";import{b as d}from"./chunk-SNB7PWCV.js";import{a as h}from"./chunk-5ZAMBDF5.js";var B=Object.freeze({left:0,top:0,width:16,height:16}),u=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),T=Object.freeze({...B,...u}),P=Object.freeze({...T,body:"",hidden:!1});var K=Object.freeze({width:null,height:null}),$=Object.freeze({...K,...u});var v=(t,o,n,r="")=>{let e=t.split(":");if(t.slice(0,1)==="@"){if(e.length<2||e.length>3)return null;r=e.shift().slice(1)}if(e.length>3||!e.length)return null;if(e.length>1){let c=e.pop(),l=e.pop(),m={provider:e.length>0?e[0]:r,prefix:l,name:c};return o&&!w(m)?null:m}let s=e[0],i=s.split("-");if(i.length>1){let c={provider:r,prefix:i.shift(),name:i.join("-")};return o&&!w(c)?null:c}if(n&&r===""){let c={provider:r,prefix:"",name:s};return o&&!w(c,n)?null:c}return null},w=(t,o)=>t?!!((o&&t.prefix===""||t.prefix)&&t.name):!1;function z(t,o){let n={};!t.hFlip!=!o.hFlip&&(n.hFlip=!0),!t.vFlip!=!o.vFlip&&(n.vFlip=!0);let r=((t.rotate||0)+(o.rotate||0))%4;return r&&(n.rotate=r),n}function E(t,o){let n=z(t,o);for(let r in P)r in u?r in t&&!(r in n)&&(n[r]=u[r]):r in o?n[r]=o[r]:r in t&&(n[r]=t[r]);return n}function A(t,o){let n=t.icons,r=t.aliases||Object.create(null),e=Object.create(null);function s(i){if(n[i])return e[i]=[];if(!(i in e)){e[i]=null;let c=r[i]&&r[i].parent,l=c&&s(c);l&&(e[i]=[c].concat(l))}return e[i]}return(o||Object.keys(n).concat(Object.keys(r))).forEach(s),e}function U(t,o,n){let r=t.icons,e=t.aliases||Object.create(null),s={};function i(c){s=E(r[c]||e[c],s)}return i(o),n.forEach(i),E(t,s)}function b(t,o){if(t.icons[o])return U(t,o,[]);let n=A(t,[o])[o];return n?U(t,o,n):null}var W=/(-?[0-9.]*[0-9]+[0-9.]*)/g,_=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function j(t,o,n){if(o===1)return t;if(n=n||100,typeof t=="number")return Math.ceil(t*o*n)/n;if(typeof t!="string")return t;let r=t.split(W);if(r===null||!r.length)return t;let e=[],s=r.shift(),i=_.test(s);for(;;){if(i){let c=parseFloat(s);isNaN(c)?e.push(s):e.push(Math.ceil(c*o*n)/n)}else e.push(s);if(s=r.shift(),s===void 0)return e.join("");i=!i}}function Q(t,o="defs"){let n="",r=t.indexOf("<"+o);for(;r>=0;){let e=t.indexOf(">",r),s=t.indexOf("</"+o);if(e===-1||s===-1)break;let i=t.indexOf(">",s);if(i===-1)break;n+=t.slice(e+1,s).trim(),t=t.slice(0,r).trim()+t.slice(i+1)}return{defs:n,content:t}}function J(t,o){return t?"<defs>"+t+"</defs>"+o:o}function q(t,o,n){let r=Q(t);return J(r.defs,o+r.content+n)}var X=t=>t==="unset"||t==="undefined"||t==="none";function D(t,o){let n={...T,...t},r={...$,...o},e={left:n.left,top:n.top,width:n.width,height:n.height},s=n.body;[n,r].forEach(g=>{let a=[],N=g.hFlip,k=g.vFlip,p=g.rotate;N?k?p+=2:(a.push("translate("+(e.width+e.left).toString()+" "+(0-e.top).toString()+")"),a.push("scale(-1 1)"),e.top=e.left=0):k&&(a.push("translate("+(0-e.left).toString()+" "+(e.height+e.top).toString()+")"),a.push("scale(1 -1)"),e.top=e.left=0);let f;switch(p<0&&(p-=Math.floor(p/4)*4),p=p%4,p){case 1:f=e.height/2+e.top,a.unshift("rotate(90 "+f.toString()+" "+f.toString()+")");break;case 2:a.unshift("rotate(180 "+(e.width/2+e.left).toString()+" "+(e.height/2+e.top).toString()+")");break;case 3:f=e.width/2+e.left,a.unshift("rotate(-90 "+f.toString()+" "+f.toString()+")");break}p%2===1&&(e.left!==e.top&&(f=e.left,e.left=e.top,e.top=f),e.width!==e.height&&(f=e.width,e.width=e.height,e.height=f)),a.length&&(s=q(s,'<g transform="'+a.join(" ")+'">',"</g>"))});let i=r.width,c=r.height,l=e.width,m=e.height,I,S;i===null?(S=c===null?"1em":c==="auto"?m:c,I=j(S,l/m)):(I=i==="auto"?l:i,S=c===null?j(I,m/l):c==="auto"?m:c);let x={},O=(g,a)=>{X(a)||(x[g]=a.toString())};O("width",I),O("height",S);let V=[e.left,e.top,l,m];return x.viewBox=V.join(" "),{attributes:x,viewBox:V,body:s}}var Y=/\sid="(\S+)"/g,R=new Map;function Z(t){t=t.replace(/[0-9]+$/,"")||"a";let o=R.get(t)||0;return R.set(t,o+1),o?`${t}${o}`:t}function F(t){let o=[],n;for(;n=Y.exec(t);)o.push(n[1]);if(!o.length)return t;let r="suffix"+(Math.random()*16777216|Date.now()).toString(16);return o.forEach(e=>{let s=Z(e),i=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");t=t.replace(new RegExp('([#;"])('+i+')([")]|\\.[a-z])',"g"),"$1"+s+r+"$3")}),t=t.replace(new RegExp(r,"g"),""),t}function C(t,o){let n=t.indexOf("xlink:")===-1?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(let r in o)n+=" "+r+'="'+o[r]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+n+">"+t+"</svg>"}var tt={body:'<g><rect width="80" height="80" style="fill: #087ebf; stroke-width: 0px;"/><text transform="translate(21.16 64.67)" style="fill: #fff; font-family: ArialMT, Arial; font-size: 67.75px;"><tspan x="0" y="0">?</tspan></text></g>',height:80,width:80},y=new Map,L=new Map,Mt=h(t=>{for(let o of t){if(!o.name)throw new Error('Invalid icon loader. Must have a "name" property with non-empty string value.');if(d.debug("Registering icon pack:",o.name),"loader"in o)L.set(o.name,o.loader);else if("icons"in o)y.set(o.name,o.icons);else throw d.error("Invalid icon loader:",o),new Error('Invalid icon loader. Must have either "icons" or "loader" property.')}},"registerIconPacks"),H=h(async(t,o)=>{let n=v(t,!0,o!==void 0);if(!n)throw new Error(`Invalid icon name: ${t}`);let r=n.prefix||o;if(!r)throw new Error(`Icon name must contain a prefix: ${t}`);let e=y.get(r);if(!e){let i=L.get(r);if(!i)throw new Error(`Icon set not found: ${n.prefix}`);try{e={...await i(),prefix:r},y.set(r,e)}catch(c){throw d.error(c),new Error(`Failed to load icon set: ${n.prefix}`)}}let s=b(e,n.name);if(!s)throw new Error(`Icon not found: ${t}`);return s},"getRegisteredIconData"),Pt=h(async t=>{try{return await H(t),!0}catch{return!1}},"isIconAvailable"),$t=h(async(t,o,n)=>{let r;try{r=await H(t,o?.fallbackPrefix)}catch(i){d.error(i),r=tt}let e=D(r,o),s=C(F(e.body),{...e.attributes,...n});return M(s,G())},"getIconSVG");export{tt as a,Mt as b,Pt as c,$t as d};