forked from Slevinski/SignWriting_Character_Viewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SuttonSignWriting.min.js
8 lines (7 loc) · 30.3 KB
/
SuttonSignWriting.min.js
1
2
3
4
5
6
7
/**
* Sutton SignWriting JavaScript Library v1.4.0
* https://github.com/Slevinski/SuttonSignWriting
* Copyright (c) 2007-2017, Stephen E Slevinski Jr
* SuttonSignWriting.min.js is released under the MIT License.
*/
var ssw={key:function(e,a){if(!e)return"";var s="S[123][0-9a-f]{2}[0-5][0-9a-f]([0-9]{3}x[0-9]{3})?";a&&(s+="("+ssw.regex("-")+")?");var r=e.match(new RegExp(s));return r?r[0]:""},pair:function(e){var a=parseInt(e,16),s=String.fromCharCode(55296+(a-65536>>10),56320+(a-65536&1023));return e&&2==s.length?[s.charCodeAt(0).toString(16).toUpperCase(),s.charCodeAt(1).toString(16).toUpperCase()]:[]},keyu:function(e,a){if(!e)return"";var s="((\\uD8C0[\\uDC01-\\uDFFF])|([\\uD8C1-\\uD8FC][\\uDC00-\\uDFFF])|(\\uD8FD[\\uDC00-\\uDC21]))(�[�-�]�[�-�])?";a&&(s+="("+ssw.regex("-")+")?");var r=e.match(new RegExp(s));return r?r[0]:""},fsw:function(e,a){if(!e)return"";var s;s=a?ssw.regex("Q-"):ssw.regex("Q");var r=e.match(new RegExp(s));return r?r[0]:""},fswu:function(e,a){if(!e)return"";var s;s=a?ssw.regex("Q-"):ssw.regex("Q");var r=e.match(new RegExp(s));return r?r[0]:""},styling:function(e){if(!e)return"";var a=e.match(new RegExp(ssw.regex("-")));return a?a[0]:""},mirror:function(e){if(e=ssw.key(e),!ssw.size(e))return"";var a,s=e.slice(0,4),r=e.slice(4,5),t=parseInt(e.slice(5,6),16),n=s+"08",i=s+"18";for(ssw.size(n)||ssw.size(i)?a=8:((0===t||4==t)&&(a=0),(1==t||5==t)&&(a=6),(2==t||6==t)&&(a=4),(3==t||7==t)&&(a=2)),e="";!ssw.size(e);)t+=a,t>7&&8>a&&(t-=8),t>15&&(t-=16),e=s+r+t.toString(16);return e},fill:function(e,a){if(e=ssw.key(e),!ssw.size(e))return"";-1!=a&&(a=1);var s=e.slice(0,4),r=parseInt(e.slice(4,5)),t=e.slice(5,6);for(e="";!ssw.size(e);)r+=a,r>5&&(r=0),0>r&&(r=5),e=s+r+t;return e},rotate:function(e,a){if(e=ssw.key(e),!ssw.size(e))return"";-1!=a&&(a=1);var s=e.slice(0,4),r=e.slice(4,5),t=parseInt(e.slice(5,6),16);for(e="";!ssw.size(e);)t>7?(t+=a,t>15&&(t=8),8>t&&(t=15),e=s+r+t.toString(16)):(t-=a,t>7&&(t=0),0>t&&(t=7),e=s+r+t);return e},scroll:function(e,a){if(e=ssw.key(e),!ssw.size(e))return"";-1!=a&&(a=1);var s=parseInt(e.slice(1,4),16)+a,r=e.slice(4,5),t=e.slice(5,6),n="S"+s.toString(16)+r+t;return ssw.size(n)?n:e},structure:function(e,a,s){var r={kind:["S100","S37f","S387"],category:["S100","S205","S2f7","S2ff","S36d","S37f","S387"],group:["S100","S10e","S11e","S144","S14c","S186","S1a4","S1ba","S1cd","S1f5","S205","S216","S22a","S255","S265","S288","S2a6","S2b7","S2d5","S2e3","S2f7","S2ff","S30a","S32a","S33b","S359","S36d","S376","S37f","S387"]},t=r[e];if(!t)return a?"is"==s?!1:"":[];if(!a&&!s)return t;s||(s="");var n;switch(s){case"is":return-1==t.indexOf(a.slice(0,4))?!1:!0;case"first":return t[0];case"last":return t.slice(-1)[0];case"prev":n=-2;break;case"":n=-1;break;case"next":n=0;break;default:return""}var i,f=t.length;for(i=0;i<t.length;i+=1)if(parseInt(a.slice(1,4),16)<parseInt(t[i].slice(1,4),16)){f=i;break}return f+=n,f=0>f?0:f>=t.length?t.length-1:f,t[f]},type:function(e){var a,s;switch(e){case"writing":a="100",s="37e";break;case"hand":a="100",s="204";break;case"movement":a="205",s="2f6";break;case"dynamic":a="2f7",s="2fe";break;case"head":case"hcenter":a="2ff",s="36c";break;case"vcenter":a="2ff",s="375";break;case"trunk":a="36d",s="375";break;case"limb":a="376",s="37e";break;case"location":a="37f",s="386";break;case"punctuation":a="387",s="38b";break;default:a="100",s="38b"}return[a,s]},is:function(e,a){if(6==e.length&&!ssw.size(e))return!1;var s=ssw.type(a),r=s[0],t=s[1],n=e.slice(1,4);return parseInt(r,16)<=parseInt(n,16)&&parseInt(t,16)>=parseInt(n,16)},filter:function(e,a){var s=ssw.type(a),r=s[0],t=s[1],n="S"+ssw.range(r,t,1)+"[0-5][0-9a-f][0-9]{3}x[0-9]{3}",i=e.match(new RegExp(n,"g"));return i?i.join(""):""},random:function(e){var a=ssw.type(e),s=a[0],r=a[1],t=Math.floor(Math.random()*(parseInt(r,16)-parseInt(s,16)+1)+parseInt(s,16)),n=Math.floor(6*Math.random()),i=Math.floor(16*Math.random()),f="S"+t.toString(16)+n.toString(16)+i.toString(16);return ssw.size(f)?f:ssw.random(e)},colorize:function(e){var a="000000";return ssw.is(e,"hand")&&(a="0000CC"),ssw.is(e,"movement")&&(a="CC0000"),ssw.is(e,"dynamic")&&(a="FF0099"),ssw.is(e,"head")&&(a="006600"),ssw.is(e,"location")&&(a="884411"),ssw.is(e,"punctuation")&&(a="FF9900"),a},view:function(e,a){if(!ssw.is(e))return"";var s=e.slice(0,4);return a?s+(ssw.size(s+"00")?"0":"1")+"0":s+(ssw.is(s,"hand")&&!ssw.structure("group",s,"is")?"1":"0")+"0"},uni:function(e,a,s){var r,t,n=ssw.fsw(e);if(n){var i="S[123][0-9a-f]{2}[0-5][0-9a-f]",f=n.match(new RegExp(i,"g")),c=f?f.length:0;for(t=0;c>t;t+=1)r=f[t],n=n.replace(r,ssw.uni(r,a,s));return n}if(r=ssw.key(e),!r)return"";var l=parseInt(a+"0000",16)+96*(parseInt(r.slice(1,4),16)-256)+16*parseInt(r.slice(4,5),16)+parseInt(r.slice(5,6),16)+1;return r=r.replace(r.substr(0,6),s?l.toString(16).toUpperCase():String.fromCharCode(55296+(l-65536>>10),56320+(l-65536&1023)))},code:function(e,a){return ssw.uni(e,"4",a)},pua:function(e,a){return ssw.uni(e,"10",a)},uni8:function(e,a){var s,r,t=ssw.fsw(e);if(t){var n="S[123][0-9a-f]{2}[0-5][0-9a-f]",i=t.match(new RegExp(n,"g"));for(r=0;r<i.length;r+=1)s=i[r],t=t.replace(s,ssw.uni8(s,a));return t}if(s=ssw.key(e),!s)return"";var f=parseInt(s.substr(1,3),16)+parseInt("1D700",16),c=a?f.toString(16).toUpperCase():String.fromCharCode(55296+(f-65536>>10),56320+(f-65536&1023)),l=s.substr(4,1);l=parseInt(l,16)+parseInt("1DA9A",16),c+=a?l.toString(16).toUpperCase():String.fromCharCode(55296+(l-65536>>10),56320+(l-65536&1023));var p=s.substr(5,1);return p=parseInt(p,16)+parseInt("1DAA0",16),c+=a?p.toString(16).toUpperCase():String.fromCharCode(55296+(p-65536>>10),56320+(p-65536&1023)),c=s.replace(s.substr(0,6),c)},uni8inherent:function(e,a){var s=ssw.uni8(e,a);return a?(s=s.replace(/1DA9A/g,""),s=s.replace(/1DAA0/g,"")):(s=s.replace(/\uD836\uDE9A/g,""),s=s.replace(/\uD836\uDEA0/g,"")),s},opt:function(e,a){var s,r,t,n,i=ssw.fsw(e);if(i){t=parseInt("1D800",16),i=i.replace("B","B!"),i=i.replace("A",a?t.toString(16).toUpperCase():String.fromCharCode(55296+(t-65536>>10),56320+(t-65536&1023))),i=i.replace("B!",a?(t+1).toString(16).toUpperCase():String.fromCharCode(55296+(t+1-65536>>10),56320+(t+1-65536&1023))),i=i.replace("L",a?(t+2).toString(16).toUpperCase():String.fromCharCode(55296+(t+2-65536>>10),56320+(t+2-65536&1023))),i=i.replace("M",a?(t+3).toString(16).toUpperCase():String.fromCharCode(55296+(t+3-65536>>10),56320+(t+3-65536&1023))),i=i.replace("R",a?(t+4).toString(16).toUpperCase():String.fromCharCode(55296+(t+4-65536>>10),56320+(t+4-65536&1023)));var f,c="[0-9]{3}x[0-9]{3}",l=i.match(new RegExp(c,"g"));for(f=0;f<l.length;f+=1)r=l[f],n=r.split("x"),n=n.map(function(e){return e=120844+parseInt(e)-250,a?e.toString(16).toUpperCase():String.fromCharCode(55296+(e-65536>>10),56320+(e-65536&1023))}),i=i.replace(r,n.join(""));var c="S[123][0-9a-f]{2}[0-5][0-9a-f]",l=i.match(new RegExp(c,"g"));for(f=0;f<l.length;f+=1)s=l[f],i=i.replace(s,ssw.uni(s,"4",a));return i}s=ssw.key(e);var p=ssw.uni(s,"4",a),c="[0-9]{3}x[0-9]{3}",l=p.match(new RegExp(c,"g"));return l&&(r=l[0],n=r.split("x"),n=n.map(function(e){return e=120844+parseInt(e)-250,a?e.toString(16).toUpperCase():String.fromCharCode(55296+(e-65536>>10),56320+(e-65536&1023))}),p=p.replace(r,n.join(""))),p},unicode:function(e,a){var s,r=ssw.fsw(e);if(r){var t,n,i;n=parseInt("1DABA",16),r=r.replace("B","B!"),r=r.replace("A",a?n.toString(16).toUpperCase():String.fromCharCode(55296+(n-65536>>10),56320+(n-65536&1023))),r=r.replace("B!",a?(n+1).toString(16).toUpperCase():String.fromCharCode(55296+(n+1-65536>>10),56320+(n+1-65536&1023))),r=r.replace("L",a?(n+2).toString(16).toUpperCase():String.fromCharCode(55296+(n+2-65536>>10),56320+(n+2-65536&1023))),r=r.replace("M",a?(n+3).toString(16).toUpperCase():String.fromCharCode(55296+(n+3-65536>>10),56320+(n+3-65536&1023))),r=r.replace("R",a?(n+4).toString(16).toUpperCase():String.fromCharCode(55296+(n+4-65536>>10),56320+(n+4-65536&1023)));var f,c="[0-9]{3}x[0-9]{3}",l=r.match(new RegExp(c,"g"));for(f=0;f<l.length;f+=1)t=l[f],i=t.replace("x","").split(""),i=i.map(function(e){return e=121520+parseInt(e),a?e.toString(16).toUpperCase():String.fromCharCode(55296+(e-65536>>10),56320+(e-65536&1023))}),r=r.replace(t,i.join(""));c="S[123][0-9a-f]{2}[0-5][0-9a-f]",l=r.match(new RegExp(c,"g"));var p=l?l.length:0;for(f=0;p>f;f+=1)s=l[f],r=r.replace(s,ssw.uni8(s,a));return r}s=ssw.key(e);var u=ssw.uni8(s,a),c="[0-9]{3}x[0-9]{3}",l=u.match(new RegExp(c,"g"));return l.length&&(i=l[0].replace("x","").split(""),i=i.map(function(e){return e=121520+parseInt(e),a?e.toString(16).toUpperCase():String.fromCharCode(55296+(e-65536>>10),56320+(e-65536&1023))}),u=u.replace(l[0],i.join(""))),u},bbox:function(e){var a,s,r,t,n,i,f=/[0-9]{3}x[0-9]{3}/g,c=e.match(f);if(c){var l;for(l=0;l<c.length;l+=1)a=parseInt(c[l].slice(0,3)),s=parseInt(c[l].slice(4,7)),0===l?(r=a,t=a,n=s,i=s):(r=Math.min(r,a),t=Math.max(t,a),n=Math.min(n,s),i=Math.max(i,s));return r==t&&n==i&&(r>500?r=1e3-r:t=1e3-t,n>500?n=1e3-n:i=1e3-i),""+r+" "+t+" "+n+" "+i}return""},displace:function(e,a,s){var r,t,n="[0-9]{3}x[0-9]{3}",i=e.match(new RegExp(n,"g"));if(i){var f;for(f=0;f<i.length;f+=1)r=parseInt(i[f].slice(0,3))+a,t=parseInt(i[f].slice(4,7))+s,e=e.replace(i[f],r+"X"+t);e=e.replace(/X/g,"x")}return e},sizes:{},size:function(e){var a,s,r,t,n=ssw.fsw(e);if(n){var i=ssw.bbox(n);i=i.split(" ");var f=i[0],c=i[1],l=i[2],p=i[3];return t=c-f+"x"+(p-l),"0x0"==t?"":t}var u=ssw.key(e);if(!u)return"";if(ssw.sizes[u])return ssw.sizes[u];var g,o,h=2,w=76*h;ssw.canvaser||(ssw.canvaser=document.createElement("canvas"),ssw.canvaser.width=w,ssw.canvaser.height=w);var x=ssw.canvaser,S=x.getContext("2d");S.clearRect(0,0,w,w),S.font=30*h+"px 'SuttonSignWritingLine'",S.fillText(ssw.uni(u,"F"),0,0),g=S.getImageData(0,0,w,w).data;e:for(a=w-1;a>=0;a--)for(s=0;w>s;s+=1)for(r=0;4>r;r+=1)if(o=4*a+4*s*w+r,g[o])break e;var d=a;e:for(s=w-1;s>=0;s--)for(a=0;d>a;a+=1)for(r=0;4>r;r+=1)if(o=4*a+4*s*w+r,g[o])break e;var m=s+1;if(d=""+Math.ceil(d/h),m=""+Math.ceil(m/h),"S19559".indexOf(u)>-1&&(d="19"),"S16d03 S16d0f S16d1f S16d2f S16d23 S16d43 S16d53 S1710d S1711d S1712d S17311 S17321 S17733 S1773f S17743 S1774f S17753 S1775f S16d33 S1713d S1714d S17301 S17329 S1715d".indexOf(u)>-1&&(d="20"),"S24c15 S24c30".indexOf(u)>-1&&(d="22"),"S2903b".indexOf(u)>-1&&(d="23"),"S1d203 S1d233".indexOf(u)>-1&&(d="25"),"S24c15".indexOf(u)>-1&&(d="28"),"S2e629".indexOf(u)>-1&&(d="29"),"S23425".indexOf(u)>-1&&(d="30"),"S2d316".indexOf(u)>-1&&(d="40"),"S2541a".indexOf(u)>-1&&(d="50"),"S1732f S17731 S17741 S17751".indexOf(u)>-1&&(m="20"),"S1412c".indexOf(u)>-1&&(m="21"),"S2a903".indexOf(u)>-1&&(m="31"),"S2b002".indexOf(u)>-1&&(m="36"),t=d+"x"+m,"0x0"==t){var b="S1000815x30 S1000921x30 S1000a30x15 S1000b30x21 S1000c15x30 S1000d21x30 ",v=b.indexOf(u);if(-1==v)t="";else{var F=b.indexOf(" ",v);t=b.slice(v+6,F)}}else ssw.sizes[u]=t;return t},max:function(e,a){var s=ssw.type(a),r=s[0],t=s[1],n="S"+ssw.range(r,t,1)+"[0-5][0-9a-f][0-9]{3}x[0-9]{3}",i=e.match(new RegExp(n,"g"));if(i){var f,c,l,p,u,g="";for(u=0;u<i.length;u+=1)f=i[u].slice(0,6),c=parseInt(i[u].slice(6,9)),l=parseInt(i[u].slice(10,13)),p=ssw.size(f).split("x"),g+=f+c+"x"+l+(c+parseInt(p[0]))+"x"+(l+parseInt(p[1]));return g}return""},norm:function(e){var a,s,r,t,n=ssw.bbox(ssw.max(e,"hcenter")),i=ssw.bbox(ssw.max(e,"vcenter")),f=ssw.bbox(ssw.max(e));if(!f)return"";i?(a=parseInt(i.slice(0,3)),s=parseInt(i.slice(4,7))):(a=parseInt(f.slice(0,3)),s=parseInt(f.slice(4,7))),n?(r=parseInt(n.slice(8,11)),t=parseInt(n.slice(12,15))):(r=parseInt(f.slice(8,11)),t=parseInt(f.slice(12,15)));var c=parseInt((a+s)/2),l=parseInt((r+t)/2),p=500-c,u=500-l,g=e.match(/(A(S[123][0-9a-f]{2}[0-5][0-9a-f])+)?[BLMR]/);return g=g?g[0]:"M",e=g+parseInt(f.slice(4,7))+"x"+parseInt(f.slice(12,15))+ssw.filter(e),ssw.displace(e,p,u)},svg:function(e,a){var s,r,t,n,i,f,c=ssw.fsw(e,!0),l=ssw.styling(c);if(!c){var p=ssw.key(e);if(t=ssw.size(p),!t)return"";c=6==p.length?p+"500x500":p}if(a||(a={}),a.size?a.size=parseFloat(a.size)||"x":a.size=1,a.colorize?a.colorize=!0:a.colorize=!1,a.pad?a.pad=parseInt(a.pad):a.pad=0,a.line?a.line=/^[0-9a-fA-F]{3}([0-9a-fA-F]{3})?$/g.test(a.line)?"#"+a.line:a.line:a.line="black",a.fill?a.fill=/^[0-9a-fA-F]{3}([0-9a-fA-F]{3})?$/g.test(a.fill)?"#"+a.fill:a.fill:a.fill="white",a.back?a.back=/^[0-9a-fA-F]{3}([0-9a-fA-F]{3})?$/g.test(a.back)?"#"+a.back:a.back:a.back="",a.E=[],a.F=[],a.copy=a.copy||"fsw",l){var u;if(s=l.split("-"),u=s[1].match(/C/),a.colorize=u?!0:!1,u=s[1].match(/P[0-9]{2}/),u&&(a.pad=parseInt(u[0].substring(1,u[0].length))),u=s[1].match(/G_([0-9a-fA-F]{3}([0-9a-fA-F]{3})?|[a-zA-Z]+)_/)){var g=u[0].substring(2,u[0].length-1);a.back=/^[0-9a-fA-F]{3}([0-9a-fA-F]{3})?$/g.test(g)?"#"+g:g}if(u=s[1].match(/D_([0-9a-f]{3}([0-9a-f]{3})?|[a-zA-Z]+)(,([0-9a-f]{3}([0-9a-f]{3})?|[a-zA-Z]+))?_/),u&&(n=u[0].substring(2,u[0].length-1).split(","),n[0]&&(a.line=/^[0-9a-fA-F]{3}([0-9a-fA-F]{3})?$/g.test(n[0])?"#"+n[0]:n[0]),n[1]&&(a.fill=/^[0-9a-fA-F]{3}([0-9a-fA-F]{3})?$/g.test(n[1])?"#"+n[1]:n[1])),u=s[1].match(/Z([0-9]+(\.[0-9]+)?|x)/),u&&(a.size=parseFloat(u[0].substring(1,u[0].length))||"x"),s[2]||(s[2]=""),u=s[2].match(/D[0-9]{2}_([0-9a-f]{3}([0-9a-f]{3})?|[a-wyzA-Z]+)(,([0-9a-f]{3}([0-9a-f]{3})?|[a-wyzA-Z]+))?_/g))for(i=0;i<u.length;i+=1)r=parseInt(u[i].substring(1,3)),n=u[i].substring(4,u[i].length-1).split(","),n[0]&&(n[0]=/^[0-9a-fA-F]{3}([0-9a-fA-F]{3})?$/g.test(n[0])?"#"+n[0]:n[0]),n[1]&&(n[1]=/^[0-9a-fA-F]{3}([0-9a-fA-F]{3})?$/g.test(n[1])?"#"+n[1]:n[1]),a.E[r]=n;if(u=s[2].match(/Z[0-9]{2},[0-9]+(\.[0-9]+)?(,[0-9]{3}x[0-9]{3})?/g))for(i=0;i<u.length;i+=1)r=parseInt(u[i].substring(1,3)),f=u[i].substring(4,u[i].length).split(","),f[0]=parseFloat(f[0]),a.F[r]=f;s.length>3&&(s=s.slice(3).join("-").split("!"),a["class"]=s[0]?s[0]:"",a.id=s[1]?s[1]:"")}var o,h,w,x=/S[123][0-9a-f]{2}[0-5][0-9a-f][0-9]{3}x[0-9]{3}/g,S={};S.L=-1,S.R=1;var d,m,b,v,F,I,A=500,k=500,z=500,C=500;b=c.charAt(0);var D=ssw.bbox(c);D=D.split(" "),A=parseInt(D[0]),k=parseInt(D[1]),z=parseInt(D[2]),C=parseInt(D[3]),"S"==b&&(500==A&&500==z?(f=t.split("x"),k=500+parseInt(f[0]),C=500+parseInt(f[1])):(k=1e3-A,C=1e3-z)),h=c.match(x),h||(h=[]);var y;for(i=0;i<h.length;i+=1)o=h[i].slice(0,6),d=h[i].slice(6,9),m=h[i].slice(10,13),a.F[i+1]&&(a.F[i+1][1]&&(d=parseInt(d)+parseInt(a.F[i+1][1].slice(0,3))-500,m=parseInt(m)+parseInt(a.F[i+1][1].slice(4,7))-500,A=Math.min(A,d),z=Math.min(z,m)),y=ssw.size(o),y&&(y=y.split("x"),k=Math.max(k,parseInt(d)+a.F[i+1][0]*parseInt(y[0])),C=Math.max(C,parseInt(m)+a.F[i+1][0]*parseInt(y[1])))),m=parseInt(m),w='<g transform="translate('+d+","+m+')">',w+="<text ",w+='class="sym-fill" ',a.css||(w+="style=\"pointer-events:none;font-family:'SuttonSignWritingFill';font-size:"+(a.F[i+1]?30*a.F[i+1][0]:30)+"px;fill:"+(a.E[i+1]&&a.E[i+1][1]?a.E[i+1][1]:a.fill)+";",w+='"'),w+=">",w+=ssw.uni(o,"10"),w+="</text>",w+="<text ",w+='class="sym-line" ',a.css||(w+='style="pointer-events:none;',w+="font-family:'SuttonSignWritingLine';font-size:"+(a.F[i+1]?30*a.F[i+1][0]:30)+"px;fill:"+(a.E[i+1]?a.E[i+1][0]:a.colorize?"#"+ssw.colorize(o):a.line)+";",w+='"'),w+=">",w+=ssw.uni(o,"F"),w+="</text>",w+="</g>",h[i]=w;A-=a.pad,k+=a.pad,z-=a.pad,C+=a.pad,v=k-A,F=C-z,I=S[b]||0,I=75*I+A-400;var R="<svg ";switch(a["class"]&&(R+='class="'+a["class"]+'" '),a.id&&(R+='id="'+a.id+'" '),R+='version="1.1" xmlns="http://www.w3.org/2000/svg" ',"x"!=a.size&&(R+='width="'+v*a.size+'" height="'+F*a.size+'" '),R+='viewBox="'+A+" "+z+" "+v+" "+F+'">',R+='<text style="font-size:0%;">',a.copy){case"uni8":R+=ssw.uni8(e);break;case"code":R+=ssw.code(e);break;case"opt":R+=ssw.opt(e);break;case"unicode":R+=ssw.unicode(e);break;default:R+=e}return R+="</text>",a.back&&(R+=' <rect x="'+A+'" y="'+z+'" width="'+v+'" height="'+F+'" style="fill:'+a.back+';" />'),R+=h.join("")+"</svg>",a.laned&&(R='<div style="padding:10px;position:relative;width:'+v+"px;height:"+F+"px;left:"+I+'px;">'+R+"</div>"),R},canvas:function(e,a){var s,r,t,n,i,f,c,l=document.createElement("canvas"),p=ssw.fsw(e,!0),u=ssw.styling(p);if(!p){var g=ssw.key(e);if(t=ssw.size(g),!g)return"";p=6==g.length?g+"500x500":g}if(a||(a={}),a.size?a.size=parseFloat(a.size):a.size=1,a.colorize?a.colorize=!0:a.colorize=!1,a.pad?a.pad=parseInt(a.pad):a.pad=0,a.line?a.line=/^[0-9a-fA-F]{3}([0-9a-fA-F]{3})?$/g.test(a.line)?"#"+a.line:a.line:a.line="black",a.fill?a.fill=/^[0-9a-fA-F]{3}([0-9a-fA-F]{3})?$/g.test(a.fill)?"#"+a.fill:a.fill:a.fill="white",a.back?a.back=/^[0-9a-fA-F]{3}([0-9a-fA-F]{3})?$/g.test(a.back)?"#"+a.back:a.back:a.back="",a.E=[],a.F=[],u){var o;if(s=u.split("-"),o=s[1].match(/C/),a.colorize=o?!0:!1,o=s[1].match(/P[0-9]{2}/),o&&(a.pad=parseInt(o[0].substring(1,o[0].length))),o=s[1].match(/G_([0-9a-fA-F]{3}([0-9a-fA-F]{3})?|[a-zA-Z]+)_/)){var h=o[0].substring(2,o[0].length-1);a.back=/^[0-9a-fA-F]{3}([0-9a-fA-F]{3})?$/g.test(h)?"#"+h:h}if(o=s[1].match(/D_([0-9a-f]{3}([0-9a-f]{3})?|[a-zA-Z]+)(,([0-9a-f]{3}([0-9a-f]{3})?|[a-zA-Z]+))?_/),o&&(r=o[0].substring(2,o[0].length-1).split(","),r[0]&&(a.line=/^[0-9a-fA-F]{3}([0-9a-fA-F]{3})?$/g.test(r[0])?"#"+r[0]:r[0]),r[1]&&(a.fill=/^[0-9a-fA-F]{3}([0-9a-fA-F]{3})?$/g.test(r[1])?"#"+r[1]:r[1])),o=s[1].match(/Z[0-9]+(\.[0-9]+)?/),o&&(a.size=o[0].substring(1,o[0].length)),s[2]||(s[2]=""),o=s[2].match(/D[0-9]{2}_([0-9a-f]{3}([0-9a-f]{3})?|[a-wyzA-Z]+)(,([0-9a-f]{3}([0-9a-f]{3})?|[a-wyzA-Z]+))?_/g))for(f=0;f<o.length;f+=1)c=parseInt(o[f].substring(1,3)),r=o[f].substring(4,o[f].length-1).split(","),r[0]&&(r[0]=/^[0-9a-fA-F]{3}([0-9a-fA-F]{3})?$/g.test(r[0])?"#"+r[0]:r[0]),r[1]&&(r[1]=/^[0-9a-fA-F]{3}([0-9a-fA-F]{3})?$/g.test(r[1])?"#"+r[1]:r[1]),a.E[c]=r;if(o=s[2].match(/Z[0-9]{2},[0-9]+(\.[0-9]+)?(,[0-9]{3}x[0-9]{3})?/g))for(f=0;f<o.length;f+=1)c=parseInt(o[f].substring(1,3)),i=o[f].substring(4,o[f].length).split(","),i[0]=parseFloat(i[0]),a.F[c]=i}var w,x,S=/S[123][0-9a-f]{2}[0-5][0-9a-f][0-9]{3}x[0-9]{3}/g,d={};d.L=-1,d.R=1;var m,b,v,F,I,A=500,k=500,z=500,C=500;v=p.charAt(0);var D=ssw.bbox(p);D=D.split(" "),A=parseInt(D[0]),k=parseInt(D[1]),z=parseInt(D[2]),C=parseInt(D[3]),"S"==v&&(500==A&&500==z?(i=t.split("x"),k=500+parseInt(i[0]),C=500+parseInt(i[1])):(k=1e3-A,C=1e3-z)),x=p.match(S);var y=x?x.length:0;for(f=0;y>f;f+=1)w=x[f].slice(0,6),m=x[f].slice(6,9),b=x[f].slice(10,13),a.F[f+1]&&(a.F[f+1][1]&&(m=parseInt(m)+parseInt(a.F[f+1][1].slice(0,3))-500,b=parseInt(b)+parseInt(a.F[f+1][1].slice(4,7))-500,A=Math.min(A,m),z=Math.min(z,b)),n=ssw.size(w),n&&(n=n.split("x"),k=Math.max(k,parseInt(m)+a.F[f+1][0]*parseInt(n[0])),C=Math.max(C,parseInt(b)+a.F[f+1][0]*parseInt(n[1]))));A-=a.pad,k+=a.pad,z-=a.pad,C+=a.pad,F=(k-A)*a.size,I=(C-z)*a.size,l.width=F?F:1,l.height=I?I:1;var R=l.getContext("2d");for(a.back&&(R.rect(0,0,F,I),R.fillStyle=a.back,R.fill()),x=p.match(S),f=0;y>f;f+=1)w=x[f].slice(0,6),m=x[f].slice(6,9),b=x[f].slice(10,13),a.F[f+1]&&(a.F[f+1][1]&&(m=parseInt(m)+parseInt(a.F[f+1][1].slice(0,3))-500,b=parseInt(b)+parseInt(a.F[f+1][1].slice(4,7))-500,A=Math.min(A,m),z=Math.min(z,b)),n=ssw.size(w),n&&(n=n.split("x"),k=Math.max(k,parseInt(m)+a.F[f+1][0]*parseInt(n[0])),C=Math.max(C,parseInt(b)+a.F[f+1][0]*parseInt(n[1])))),R.font=(a.F[f+1]?30*a.size*a.F[f+1][0]:30*a.size)+"px 'SuttonSignWritingFill'",R.fillStyle=a.E[f+1]&&a.E[f+1][1]?a.E[f+1][1]:a.fill,R.fillText(ssw.uni(w,"10"),(m-A)*a.size,(b-z)*a.size),R.font=(a.F[f+1]?30*a.size*a.F[f+1][0]:30*a.size)+"px 'SuttonSignWritingLine'",R.fillStyle=a.E[f+1]?a.E[f+1][0]:a.colorize?"#"+ssw.colorize(w):a.line,R.fillText(ssw.uni(w,"F"),(m-A)*a.size,(b-z)*a.size);return l},png:function(e,a){if(ssw.fsw(e,!0)||ssw.key(e,!0)){var s=ssw.canvas(e,a),r=s.toDataURL("image/png");return s.remove(),r}return""},query:function(e){return"-"==e?"-":(e=e.match(/Q((A(S[123][0-9a-f]{2}[0-5u][0-9a-fu]|R[123][0-9a-f]{2}t[123][0-9a-f]{2})+)?T)?((R[123][0-9a-f]{2}t[123][0-9a-f]{2}([0-9]{3}x[0-9]{3})?)|(S[123][0-9a-f]{2}[0-5u][0-9a-fu]([0-9]{3}x[0-9]{3})?))*(V[0-9]+)?-?/),e?e[0]:"")},queryu:function(e){if("-"==e)return"-";var a=ssw.rangeu("40001","4F480"),s=ssw.rangeu("1D80C","1D9FF"),r=("(("+ssw.rangeu("1D801")+")|("+ssw.rangeu("1D802")+")|("+ssw.rangeu("1D803")+")|("+ssw.rangeu("1D804")+"))",ssw.rangeu("1D800"),a+"f?r?"),t="("+s+s+")?",n="Q((A("+r+"|R"+r+r+")+)?T)?((R"+r+r+t+")|("+r+t+"))*(V[0-9]+)?-?";return e=e.match(new RegExp(n)),e?e[0]:""},range:function(e,a,s){var r,t,n,i,f,c,l;if(s||(s=""),e=("000"+e).slice(-3),a=""+a,r="",e===a)return e;if(t=[],(e[0]!=a[0]||e[1]!=a[1])&&"0"!=e[2])if(r=e[0]+e[1],s){switch(e[2]){case"f":r+="f";break;case"e":r+="[ef]";break;case"d":case"c":case"b":case"a":r+="["+e[2]+"-f]";break;default:switch(e[2]){case"9":r+="[9a-f]";break;case"8":r+="[89a-f]";break;default:r+="["+e[2]+"-9a-f]"}}n=15-parseInt(e[2],16)+1,e=""+(parseInt(e,16)+n).toString(16),t.push(r)}else{switch(e[2]){case"9":r+="9";break;case"8":r+="[89]";break;default:r+="["+e[2]+"-9]"}n=9-e[2]+1,e=""+(1*e+n),t.push(r)}if(r="",e[0]!=a[0]&&"0"!=e[1])if(s){switch(r=e[0],e[1]){case"f":r+="f";break;case"e":r+="[ef]";break;case"d":case"c":case"b":case"a":r+="["+e[1]+"-f]";break;case"9":r+="[9a-f]";break;case"8":r+="[89a-f]";break;default:r+="["+e[1]+"-9a-f]"}r+="[0-9a-f]",n=15-parseInt(e[1],16)+1,e=""+(parseInt(e,16)+16*n).toString(16),t.push(r)}else{switch(r=e[0],n=9-e[1]+1,e[1]){case"9":r+="9";break;case"8":r+="[89]";break;default:r+="["+e[1]+"-9]"}r+="[0-9]",n=9-e[1]+1,e=""+(1*e+10*n),t.push(r)}if(r="",e[0]!=a[0])if(s){switch(n=parseInt(a[0],16)-parseInt(e[0],16),i=(parseInt(e[0],16)+n-1).toString(16),n){case 1:r=e[0];break;case 2:r="["+e[0]+i+"]";break;default:switch(c=parseInt(e[0],16)>9?"h":"d",l=parseInt(i,16)>9?"h":"d",c+l){case"dd":r+="["+e[0]+"-"+i+"]";break;case"dh":switch(n=9-e[0]){case 0:r+="[9";break;case 1:r+="[89";break;default:r+="["+e[0]+"-9"}switch(i[0]){case"a":r+="a]";break;case"b":r+="ab]";break;default:r+="a-"+i+"]"}break;case"hh":r+="["+e[0]+"-"+i+"]"}}r+="[0-9a-f][0-9a-f]",n=parseInt(a[0],16)-parseInt(e[0],16),e=""+(parseInt(e,16)+256*n).toString(16),t.push(r)}else{switch(n=a[0]-e[0],i=1*e[0]+n-1,n){case 1:r=e[0];break;case 2:r="["+e[0]+i+"]";break;default:r="["+e[0]+"-"+i+"]"}r+="[0-9][0-9]",e=""+(1*e+100*n),t.push(r)}if(r="",e[1]!=a[1])if(s){switch(n=parseInt(a[1],16)-parseInt(e[1],16),i=(parseInt(e[1],16)+n-1).toString(16),r=e[0],n){case 1:r+=e[1];break;case 2:r+="["+e[1]+i+"]";break;default:switch(c=parseInt(e[1],16)>9?"h":"d",l=parseInt(i,16)>9?"h":"d",c+l){case"dd":r+="["+e[1],n>1&&(r+="-"),r+=i+"]";break;case"dh":switch(n=9-e[1]){case 0:r+="[9";break;case 1:r+="[89";break;default:r+="["+e[1]+"-9"}switch(a[1]){case"a":r+="]";break;case"b":r+="a]";break;default:r+="a-"+(parseInt(a[1],16)-1).toString(16)+"]"}break;case"hh":r+="["+e[1],n>1&&(r+="-"),r+=(parseInt(a[1],16)-1).toString(16)+"]"}}r+="[0-9a-f]",n=parseInt(a[1],16)-parseInt(e[1],16),e=""+(parseInt(e,16)+16*n).toString(16),t.push(r)}else{switch(n=a[1]-e[1],i=1*e[1]+n-1,r=e[0],n){case 1:r+=e[1];break;case 2:r+="["+e[1]+i+"]";break;default:r+="["+e[1]+"-"+i+"]"}r+="[0-9]",e=""+(1*e+10*n),t.push(r)}if(r="",e[2]!=a[2])if(s){switch(r=e[0]+e[1],n=parseInt(a[2],16)-parseInt(e[2],16),c=parseInt(e[2],16)>9?"h":"d",l=parseInt(a[2],16)>9?"h":"d",c+l){case"dd":r+="["+e[2],n>1&&(r+="-"),r+=a[2]+"]";break;case"dh":switch(n=9-e[2]){case 0:r+="[9";break;case 1:r+="[89";break;default:r+="["+e[2]+"-9"}switch(a[2]){case"a":r+="a]";break;case"b":r+="ab]";break;default:r+="a-"+a[2]+"]"}break;case"hh":r+="["+e[2],n>1&&(r+="-"),r+=a[2]+"]"}n=parseInt(a[2],16)-parseInt(e[2],16),e=""+(parseInt(e,16)+n).toString(16),t.push(r)}else{switch(n=a[2]-e[2],r=e[0]+e[1],n){case 0:r+=e[2];break;case 1:r+="["+e[2]+a[2]+"]";break;default:r+="["+e[2]+"-"+a[2]+"]"}e=""+(1*e+n),t.push(r)}return r="","0"==e[2]&&"0"==a[2]&&(r=a,t.push(r)),r="",f=t.length,1==f?r=t[0]:(r=t.join(")|("),r="(("+r+"))"),r},rangeu:function(e,a){if(a=a||e,e>a)return"";var s="",r=[],e=ssw.pair(e),a=ssw.pair(a);if(2!=e.length&&2!=a.length)return"";if(e[0]==a[0])e[1]==a[1]?(s="\\u"+e[0]+"\\u"+e[1],r.push(s)):(s="\\u"+e[0]+"[\\u"+e[1]+"-\\u"+a[1]+"]",r.push(s));else{s="DFFF"==e[1]?"\\u"+e[0]+"\\uDFFF":"\\u"+e[0]+"[\\u"+e[1]+"-\\uDFFF]",r.push(s);var t=parseInt(a[0],16)-parseInt(e[0],16);2==t&&(s="\\u"+(parseInt(e[0],16)+1).toString(16).toUpperCase(),s+="[\\uDC00-\\uDFFF]",r.push(s)),t>2&&(s="[",s+="\\u"+(parseInt(e[0],16)+1).toString(16).toUpperCase(),s+="-\\u"+(parseInt(a[0],16)-1).toString(16).toUpperCase(),s+="][\\uDC00-\\uDFFF]",r.push(s)),s="DC00"==e[1]?"\\u"+a[0]+"\\uDC00":"\\u"+a[0]+"[\\uDC00-\\u"+a[1]+"]",r.push(s)}return cnt=r.length,1==cnt?s=r[0]:(s=r.join(")|("),s="(("+s+"))"),s},regex:function(e,a){if(e=ssw.query(e),!e)return"";var s,r,t,n,i,f,c,l,p,u,g,o,h;a||(a=20);var w,x="S[123][0-9a-f]{2}[0-5][0-9a-f]",S="[0-9]{3}x[0-9]{3}",d="[BLMR]("+S+")("+x+S+")*",m="(A("+x+")+)",b="R[123][0-9a-f]{2}t[123][0-9a-f]{2}",v="S[123][0-9a-f]{2}[0-5u][0-9a-fu]",F="([0-9]{3}x[0-9]{3})?",I="(V[0-9]+)",A="-C?(P[0-9]{2})?(G_([0-9a-fA-F]{3}([0-9a-fA-F]{3})?|[a-zA-Z]+)_)?(D_([0-9a-fA-F]{3}([0-9a-fA-F]{3})?|[a-zA-Z]+)(,([0-9a-fA-F]{3}([0-9a-fA-F]{3})?|[a-zA-Z]+))?_)?(Z([0-9]+(.[0-9]+)?|x))?(-(D[0-9]{2}_([0-9a-fA-F]{3}([0-9a-fA-F]{3})?|[a-zA-Z]+)(,([0-9a-fA-F]{3}([0-9a-fA-F]{3})?|[a-zA-Z]+))?_)*(Z[0-9]{2},[0-9]+(.[0-9]+)?(,[0-9]{3}x[0-9]{3})?)*)?(--?[_a-zA-Z][_a-zA-Z0-9-]{0,100}( -?[_a-zA-Z][_a-zA-Z0-9-]{0,100})*!([a-zA-Z][_a-zA-Z0-9-]{0,100}!)?)?",k="("+A+")?";if(e=ssw.query(e),!e)return"";if("-"==e)return[A];if("Q"==e)return[m+"?"+d];if("Q-"==e)return[m+"?"+d+k];if("QT"==e)return[m+d];if("QT-"==e)return[m+d+k];var z=[],C=e.indexOf("T")+1;if(C){w="(A";var D=e.slice(0,C);if(e=e.replace(D,""),"QT"==D)w+="("+x+")+)";else if(s=D.match(new RegExp("("+v+"|"+b+")","g"))){var y;for(r=0;r<s.length;r+=1)y=s[r].match(new RegExp(v)),y?(l=y[0].slice(0,4),o=y[0].slice(4,5),l+="u"==o?"[0-5]":o,h=y[0].slice(5,6),l+="u"==h?"[0-9a-f]":h,w+=l):(i=s[r].slice(1,4),f=s[r].slice(5,8),c=ssw.range(i,f,"hex"),l="S"+c+"[0-5][0-9a-f]",w+=l);w+="("+x+")*)"}}if(s=e.match(new RegExp(I,"g")),s&&(a=1*s.toString().slice(1)),t=v+F,s=e.match(new RegExp(t,"g")))for(r=0;r<s.length;r+=1)n=s[r].toString(),g=n.slice(1,4),l="S"+g,o=n.slice(4,5),l+="u"==o?"[0-5]":o,h=n.slice(5,6),l+="u"==h?"[0-9a-f]":h,n.length>6?(p=1*n.slice(6,9),u=1*n.slice(10,13),l+=ssw.range(p-a,p+a),l+="x",l+=ssw.range(u-a,u+a)):l+=S,l=d+l+"("+x+S+")*",l=C?w+l:m+"?"+l,e.indexOf("-")>0&&(l+=k),z.push(l);if(t=b+F,s=e.match(new RegExp(t,"g")))for(r=0;r<s.length;r+=1)n=s[r].toString(),i=n.slice(1,4),f=n.slice(5,8),c=ssw.range(i,f,"hex"),l="S"+c+"[0-5][0-9a-f]",n.length>8?(p=1*n.slice(8,11),u=1*n.slice(12,15),l+=ssw.range(p-a,p+a),l+="x",l+=ssw.range(u-a,u+a)):l+=S,l=d+l+"("+x+S+")*",l=C?w+l:m+"?"+l,e.indexOf("-")>0&&(l+=k),z.push(l);return z.length||(e.indexOf("-")>0&&(l+=k),z.push(w+d)),z},regexu:function(e,a){if(e=ssw.query(e),!e)return"";var s,r,t,n,i,f,c,l,p,u,g,o,h;a||(a=20);var w=ssw.rangeu("40001","4F480"),x=ssw.rangeu("1D80C","1D9FF"),S=x+x,d="(("+ssw.rangeu("1D801")+")|("+ssw.rangeu("1D802")+")|("+ssw.rangeu("1D803")+")|("+ssw.rangeu("1D804")+"))",m=ssw.rangeu("1D800"),b=d+S+"("+w+S+")*",v="("+m+"("+w+")+)",F="R"+w+w,I=w+"f?r?",A="("+x+x+")?",k="(V[0-9]+)",z="-C?(P[0-9]{2})?(G_([0-9a-fA-F]{3}([0-9a-fA-F]{3})?|[a-zA-Z]+)_)?(D_([0-9a-fA-F]{3}([0-9a-fA-F]{3})?|[a-zA-Z]+)(,([0-9a-fA-F]{3}([0-9a-fA-F]{3})?|[a-zA-Z]+))?_)?(Z([0-9]+(.[0-9]+)?|x))?(-(D[0-9]{2}_([0-9a-fA-F]{3}([0-9a-fA-F]{3})?|[a-zA-Z]+)(,([0-9a-fA-F]{3}([0-9a-fA-F]{3})?|[a-zA-Z]+))?_)*(Z[0-9]{2},[0-9]+(.[0-9]+)?(,[0-9]{3}x[0-9]{3})?)*)?(--?[_a-zA-Z][_a-zA-Z0-9-]{0,100}( -?[_a-zA-Z][_a-zA-Z0-9-]{0,100})*!([a-zA-Z][_a-zA-Z0-9-]{0,100}!)?)?",C="("+z+")?";if(e=ssw.query(e),!e)return"";if("-"==e)return[z];if("Q"==e)return[v+"?"+b];if("Q-"==e)return[v+"?"+b+C];if("QT"==e)return[v+b];if("QT-"==e)return[v+b+C];var D=[],y=e.indexOf("T")+1;if(y){q_term="(A";var R=e.slice(0,y);if(e=e.replace(R,""),"QT"==R)q_term+="("+w+")+)";else if(s=R.match(new RegExp("("+I+"|"+F+")","g"))){var E;for(r=0;r<s.length;r+=1)E=s[r].match(new RegExp(I)),E?(l=E[0].slice(0,4),o=E[0].slice(4,5),l+="u"==o?"[0-5]":o,h=E[0].slice(5,6),l+="u"==h?"[0-9a-f]":h,q_term+=l):(i=s[r].slice(1,4),f=s[r].slice(5,8),c=ssw.range(i,f,"hex"),l="S"+c+"[0-5][0-9a-f]",q_term+=l);q_term+="("+w+")*)"}}if(s=e.match(new RegExp(k,"g")),s&&(a=1*s.toString().slice(1)),t=I+A,s=e.match(new RegExp(t,"g")))for(r=0;r<s.length;r+=1)n=s[r].toString(),g=n.slice(1,4),l="S"+g,o=n.slice(4,5),l+="u"==o?"[0-5]":o,h=n.slice(5,6),l+="u"==h?"[0-9a-f]":h,n.length>6?(p=1*n.slice(6,9),u=1*n.slice(10,13),l+=ssw.range(p-a,p+a),l+="x",l+=ssw.range(u-a,u+a)):l+=S,l=b+l+"("+w+S+")*",l=y?q_term+l:v+"?"+l,e.indexOf("-")>0&&(l+=C),D.push(l);if(t=F+A,s=e.match(new RegExp(t,"g")))for(r=0;r<s.length;r+=1)n=s[r].toString(),i=n.slice(1,4),f=n.slice(5,8),c=ssw.range(i,f,"hex"),l="S"+c+"[0-5][0-9a-f]",n.length>8?(p=1*n.slice(8,11),u=1*n.slice(12,15),l+=ssw.range(p-a,p+a),l+="x",l+=ssw.range(u-a,u+a)):l+=S,l=b+l+"("+w+S+")*",l=y?q_term+l:v+"?"+l,e.indexOf("-")>0&&(l+=C),D.push(l);return D.length||(e.indexOf("-")>0&&(l+=C),D.push(q_term+b)),D},results:function(e,a,s){if(!a)return[];(-1==="BLMR".indexOf(s)||s.length>1)&&(s="");var r,t,n,i,f=ssw.regex(e);if(!f)return[];var c;for(c=0;c<f.length;c+=1)r=f[c],t=a.match(new RegExp(r,"g")),a=t?t.join(" "):"";return a?(s&&(a=a.replace(/B/g,s),a=a.replace(/L/g,s),a=a.replace(/M/g,s),a=a.replace(/R/g,s)),n=a.split(" "),i=n.filter(function(e){return e in n?!1:n[e]=!0},{})):i=[],i},lines:function(e,a,s){if(!a)return[];(-1==="BLMR".indexOf(s)||s.length>1)&&(s="");var r,t,n,i,f=ssw.regex(e);if(!f)return[];var c;for(c=0;c<f.length;c+=1)r=f[c],r="^"+r+".*",t=a.match(new RegExp(r,"mg")),a=t?t.join("\n"):"";return a?(s&&(a=a.replace(/B/g,s),a=a.replace(/L/g,s),a=a.replace(/M/g,s),a=a.replace(/R/g,s)),n=a.split("\n"),i=n.filter(function(e){return e in n?!1:n[e]=!0},{})):i=[],i},convert:function(e,a){var s,r="";if(ssw.fsw(e)&&/^[Aa]?([Ss]L?)?$/.test(a)){var t,n,i="S[123][0-9a-f]{2}",f=i+"[0-5][0-9a-f]",c="[0-9]{3}x[0-9]{3}";if((a.indexOf("A")>-1||a.indexOf("a")>-1)&&(t=e.match(new RegExp("A("+f+")*","g"))))if(n=t[0],a.indexOf("A")>-1)r+=n+"T";else{for(t=n.match(new RegExp(i,"g")),r+="A",s=0;s<t.length;s+=1)r+=t[s]+"uu";r+="T"}if((a.indexOf("S")>-1||a.indexOf("s")>-1)&&(t=e.match(new RegExp(f+c,"g"))))for(s=0;s<t.length;s+=1)r+=a.indexOf("S")>-1?t[s].slice(0,6):t[s].slice(0,4)+"uu",a.indexOf("L")>-1&&(r+=t[s].slice(6,13))}return r?"Q"+r:""},signtext:function(e){var a=ssw.regex("Q");a=a[0],a="("+a+"|S3[0-9a-f]{2}[0-5][0-9a-f]([0-9]{3}x[0-9]{3}))("+ssw.regex("-")[0]+")?";var s=e.match(new RegExp(a,"mg"));return s?s:[]},paragraph:function(e){var a=ssw.signtext(e).map(function(e){var a=e.match(/Z([0-9]+(\.[0-9]+)?)/);a=a?parseFloat(a[1]):1;var s=ssw.bbox(e).split(" "),r=(s[1]-s[0])*a,t=(s[3]-s[2])*a,n=(1e3-s[0]-s[1])*a;n+=2,e.indexOf("L")>-1&&(n+=150),e.indexOf("R")>-1&&(n-=150);var i="width: "+r+"px;height: "+t+"px;";return n>0?i+="margin-right: "+n+"px;":0>n&&(n=-n,i+="border-left: "+n+"px solid transparent;"),'<div class="sign" style="'+i+'">'+ssw.svg(e)+"</div>"});return'<span class="outside"><span class="middle"><span class="inside">'+a.join("")+"</span></span></span>"}};