UNPKG

32.9 kBJavaScriptView Raw
1/* Sutton SignWriting TrueType Font Module v1.3.2 (https://github.com/sutton-signwriting/font-ttf), author: Steve Slevinski (https://SteveSlevinski.me), license: MIT */
2!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).ssw=t.ssw||{},t.ssw.ttf={}))}(this,(function(t){"use strict";let e={};const o=152;let i;const l=function(t){if(t in e)return[...e[t]];if(!i){const t=document.createElement("canvas");t.width=o,t.height=o,i=t.getContext("2d")}i.clearRect(0,0,o,o),i.font="60px 'SuttonSignWritingLine'",i.fillText(String.fromCodePoint(t+983040),0,0);const l=i.getImageData(0,0,o,o).data;let n,s,a,r;t:for(n=151;n>=0;n--)for(s=0;s<o;s+=1)for(r=0;r<4;r+=1)if(a=4*n+4*s*o+r,l[a])break t;var d=n;t:for(s=151;s>=0;s--)for(n=0;n<d;n+=1)for(r=0;r<4;r+=1)if(a=4*n+4*s*o+r,l[a])break t;var c=s+1;if(d=Math.ceil(d/2),c=Math.ceil(c/2),14394==t&&(d=19),[10468,10480,10496,10512,10500,10532,10548,10862,10878,10894,11058,11074,11476,11488,11492,11504,11508,11520,10516,10910,10926,11042,11082,10942].includes(t)&&(d=20),31921==t&&(d=22),38460==t&&(d=23),[20164,20212].includes(t)&&(d=25),31894==t&&(d=28),46698==t&&(d=29),29606==t&&(d=30),44855==t&&(d=40),32667==t&&(d=50),[11088,11474,11490,11506].includes(t)&&(c=20),6285==t&&(c=21),40804==t&&(c=31),41475==t&&(c=36),0==d&&0==c){const e={9:[15,30],10:[21,30],11:[30,15],12:[30,21],13:[15,30],14:[21,30]};t in e&&(d=e[t][0],c=e[t][1])}return 0!=d||0!=c?(e[t]=[d,c],[d,c]):void 0},n=function(t){return String.fromCodePoint(t+983040)},s=function(t){return String.fromCodePoint(t+1048576)},a=function(t){return` <text class="sym-fill" fill="white" style="pointer-events:none;font-family:'SuttonSignWritingFill';font-size:30px;">${s(t)}</text>\n <text class="sym-line" fill="black" style="pointer-events:none;font-family:'SuttonSignWritingLine';font-size:30px;">${n(t)}</text>`},r=function(t){if(l(1))t();else{const e=setInterval((function(){l(1)&&(clearInterval(e),t())}),100)}},d=function(t){const e=function(){const t=document.createElement("canvas");t.width=15,t.height=30;const e=t.getContext("2d");e.font="30px 'SuttonSignWritingFill'",e.fillText(s(1),0,0);return!e.getImageData(0,0,15,30).data.every((t=>0===t))};if(e())t();else{const o=setInterval((function(){e()&&(clearInterval(o),t())}),100)}};var c=Object.freeze({__proto__:null,cssAppend:function(t=""){if(!document.getElementById("SgnwFontCss")){const e=document.createElement("style");e.setAttribute("id","SgnwFontCss"),e.appendChild(document.createTextNode(`\n @font-face {\n font-family: "SuttonSignWritingLine";\n src: \n local('SuttonSignWritingLine'),\n ${t?`url('${t}SuttonSignWritingLine.ttf') format('truetype'),`:""}\n url('https://cdn.jsdelivr.net/npm/@sutton-signwriting/font-ttf@1.0.0/font/SuttonSignWritingLine.ttf') format('truetype');\n }\n @font-face {\n font-family: "SuttonSignWritingFill";\n src: \n local('SuttonSignWritingFill'),\n ${t?`url('${t}SuttonSignWritingFill.ttf') format('truetype'),`:""}\n url('https://cdn.jsdelivr.net/npm/@sutton-signwriting/font-ttf@1.0.0/font/SuttonSignWritingFill.ttf') format('truetype');\n }\n @font-face {\n font-family: "SuttonSignWritingOneD";\n src: \n local('SuttonSignWritingOneD'),\n ${t?`url('${t}SuttonSignWritingOneD.ttf') format('truetype'),`:""}\n url('https://cdn.jsdelivr.net/npm/@sutton-signwriting/font-ttf@1.0.0/font/SuttonSignWritingOneD.ttf') format('truetype');\n }\n `)),document.head.appendChild(e)}},cssLoaded:function(t){let e=!1,o=!1;r((()=>{e=!0})),d((()=>{o=!0}));const i=setInterval((function(){e&&o&&(clearInterval(i),t())}),100)},cssLoadedLine:r,cssLoadedFill:d,symbolSize:l,symbolLine:n,symbolFill:s,symbolText:a});const m=t=>t.map((t=>(t=>String.fromCodePoint(120844+parseInt(t)-250))(t))).join(""),g=t=>(t=>parseInt(t.codePointAt(0)))(t)-262144,p=t=>1+96*(parseInt(t.slice(1,4),16)-256)+16*parseInt(t.slice(4,5),16)+parseInt(t.slice(5,6),16),f=function(t){return l(p(t))},u=function(t){return n(p(t))},y=function(t){return s(p(t))},h=function(t){return a(p(t))};let x={colorize:"C",colorhex:"(?:[0-9a-fA-F]{3}){1,2}",colorname:"[a-zA-Z]+",padding:"P[0-9]{2}",zoom:"Z(?:[0-9]+(?:\\.[0-9]+)?|x)",classbase:"-?[_a-zA-Z][_a-zA-Z0-9-]{0,100}",id:"[a-zA-Z][_a-zA-Z0-9-]{0,100}"};x.colorbase=`(?:${x.colorhex}|${x.colorname})`,x.color=`_${x.colorbase}_`,x.colors=`_${x.colorbase}(?:,${x.colorbase})?_`,x.background=`G${x.color}`,x.detail=`D${x.colors}`,x.detailsym=`D[0-9]{2}${x.colors}`,x.classes=`${x.classbase}(?: ${x.classbase})*`,x.full=`-(${x.colorize})?(${x.padding})?(${x.background})?(${x.detail})?(${x.zoom})?(?:-((?:${x.detailsym})*))?(?:-(${x.classes})?!(?:(${x.id})!)?)?`;const b=t=>(new RegExp(`^${x.colorhex}$`).test(t)?"#":"")+t,$=t=>{const e=`^${x.full}`,o=("string"==typeof t?t.match(new RegExp(e)):[])||[];return i={colorize:o[1]?!!o[1]:void 0,padding:o[2]?parseInt(o[2].slice(1)):void 0,background:o[3]?b(o[3].slice(2,-1)):void 0,detail:o[4]?o[4].slice(2,-1).split(",").map(b):void 0,zoom:o[5]?"Zx"===o[5]?"x":parseFloat(o[5].slice(1)):void 0,detailsym:o[6]?o[6].match(new RegExp(x.detailsym,"g")).map((t=>{const e=t.split("_"),o=e[1].split(",").map(b);return{index:parseInt(e[0].slice(1)),detail:o}})):void 0,classes:o[7]?o[7]:void 0,id:o[8]?o[8]:void 0},Object.fromEntries(Object.entries(i).filter((([t,e])=>void 0!==e)));var i},v=t=>{if("object"!=typeof t||null===t)return;let e="-";e+=t.colorize?"C":"";const o=parseInt(t.padding);e+=!o||o<=0||o>99?"":"P"+(o>9?o:"0"+o);const i=t.background&&"string"==typeof t.background?t.background.match(x.colorbase)[0]:void 0;e+=i?"G_"+i+"_":"";const l=t.detail&&t.detail[0]&&"string"==typeof t.detail[0]?t.detail[0].match(x.colorbase)[0]:void 0,n=t.detail&&t.detail[1]&&"string"==typeof t.detail[1]?t.detail[1].match(x.colorbase)[0]:void 0;l&&(e+="D_"+l,n&&(e+=","+n),e+="_");const s="x"===t.zoom?"x":parseFloat(t.zoom);e+=!s||s<=0?"":"Z"+s;let a="";const r=t.detailsym&&Array.isArray(t.detailsym)?t.detailsym.map((t=>{const e=parseInt(t.index);if(!e||e<=0||e>99)return"";let o="D"+(e>9?e:"0"+e);const i=t.detail&&t.detail[0]?t.detail[0].match(x.colorbase)[0]:void 0,l=t.detail&&t.detail[1]?t.detail[1].match(x.colorbase)[0]:void 0;return i&&(o+="_"+i,l&&(o+=","+l),o+="_"),o})):[];a+=r.join("");let d="";const c=t.classes&&"string"==typeof t.classes?t.classes.match(x.classes)[0]:void 0;d+=c||"";const m=t.id&&"string"==typeof t.id?t.id.match(x.id)[0]:void 0;return d+=c||m?"!":"",d+=m?m+"!":"",e+(a||d?"-"+a:"")+(d?"-"+d:"")};let w={symbol:"S[123][0-9a-f]{2}[0-5][0-9a-f]",coord:"[0-9]{3}x[0-9]{3}",sort:"A",box:"[BLMR]"};w.prefix=`(?:${w.sort}(?:${w.symbol})+)`,w.spatial=`${w.symbol}${w.coord}`,w.signbox=`${w.box}${w.coord}(?:${w.spatial})*`,w.sign=`${w.prefix}?${w.signbox}`,w.sortable=`${w.prefix}${w.signbox}`;let z={colorize:"C",colorhex:"(?:[0-9a-fA-F]{3}){1,2}",colorname:"[a-zA-Z]+",padding:"P[0-9]{2}",zoom:"Z(?:[0-9]+(?:\\.[0-9]+)?|x)",classbase:"-?[_a-zA-Z][_a-zA-Z0-9-]{0,100}",id:"[a-zA-Z][_a-zA-Z0-9-]{0,100}"};z.colorbase=`(?:${z.colorhex}|${z.colorname})`,z.color=`_${z.colorbase}_`,z.colors=`_${z.colorbase}(?:,${z.colorbase})?_`,z.background=`G${z.color}`,z.detail=`D${z.colors}`,z.detailsym=`D[0-9]{2}${z.colors}`,z.classes=`${z.classbase}(?: ${z.classbase})*`,z.full=`-(${z.colorize})?(${z.padding})?(${z.background})?(${z.detail})?(${z.zoom})?(?:-((?:${z.detailsym})*))?(?:-(${z.classes})?!(?:(${z.id})!)?)?`;const S=t=>(new RegExp(`^${z.colorhex}$`).test(t)?"#":"")+t,I=t=>{const e=`^${z.full}`,o=("string"==typeof t?t.match(new RegExp(e)):[])||[];return i={colorize:o[1]?!!o[1]:void 0,padding:o[2]?parseInt(o[2].slice(1)):void 0,background:o[3]?S(o[3].slice(2,-1)):void 0,detail:o[4]?o[4].slice(2,-1).split(",").map(S):void 0,zoom:o[5]?"Zx"===o[5]?"x":parseFloat(o[5].slice(1)):void 0,detailsym:o[6]?o[6].match(new RegExp(z.detailsym,"g")).map((t=>{const e=t.split("_"),o=e[1].split(",").map(S);return{index:parseInt(e[0].slice(1)),detail:o}})):void 0,classes:o[7]?o[7]:void 0,id:o[8]?o[8]:void 0},Object.fromEntries(Object.entries(i).filter((([t,e])=>void 0!==e)));var i},k=t=>t.split("x").map((t=>parseInt(t))),_=t=>{const e=`^(${w.symbol})(${w.coord})?(${z.full})?`,o="string"==typeof t?t.match(new RegExp(e)):void 0;return{symbol:o?o[1]:void 0,coord:o&&o[2]?k(o[2]):void 0,style:o?o[3]:void 0}},j=t=>{const e=`^(${w.prefix})?(${w.signbox})(${z.full})?`,o="string"==typeof t?t.match(new RegExp(e)):void 0;return o?{sequence:o[1]?o[1].slice(1).match(/.{6}/g):void 0,box:o[2][0],max:k(o[2].slice(1,8)),spatials:o[2].length<9?void 0:o[2].slice(8).match(/(.{13})/g).map((t=>({symbol:t.slice(0,6),coord:[parseInt(t.slice(6,9)),parseInt(t.slice(10,13))]}))),style:o[3]}:{}},E=t=>{if("string"!=typeof t)return[];const e=`(${w.sign}(${z.full})?|${w.spatial}(${z.full})?)`,o=t.match(new RegExp(e,"g"));return o?[...o]:[]},M=t=>{let e,o,i,l,n,s,a,r,d=j(t);d.spatials?(l=Math.min(...d.spatials.map((t=>t.coord[0]))),n=d.max[0],e=n-l,s=Math.min(...d.spatials.map((t=>t.coord[1]))),a=d.max[1],o=a-s,i="sign",r=d.box):(d=_(t),r="M",d.coord?(l=d.coord[0],e=2*(500-l),s=d.coord[1],o=2*(500-s),i="symbol"):(l=490,e=20,s=490,o=20,i="none"));let c=I(d.style),m=c.zoom||1,g=c.padding||0;return{minX:l,minY:s,width:e,height:o,segment:i,lane:{B:0,L:-1,M:0,R:1}[r],padding:g,zoom:m}},F={height:500,width:150,offset:50,pad:20,margin:5,dynamic:!1,background:void 0,punctuation:{spacing:!0,pad:30,pull:!0},style:{detail:["black","white"],zoom:1}},C=(t,e)=>{if("string"!=typeof t)return{};const o=(t=>("object"!=typeof t&&(t={}),{...F,...t,punctuation:{...F.punctuation,...t.punctuation},style:{...F.style,...t.style}}))(e);let i=E(t),l=0,n=[],s=[],a=0,r=parseInt(o.width/2),d=o.height-o.margin,c=!0,m=!1;for(let t of i){let e=M(t);l+=a,o.punctuation.spacing?l+="sign"==e.segment?o.pad:0:l+=o.pad,m=l+e.height>d,m&&"symbol"==e.segment&&o.punctuation.pull&&c&&(m=!1,c=!1),0==s.length&&(m=!1),m&&(l=o.pad,n.push(s),s=[],c=!0),s.push(Object.assign(e,{x:r+o.offset*e.lane-(500-e.minX)*e.zoom*o.style.zoom,y:l,text:t})),l+=e.height*e.zoom*o.style.zoom,a=o.punctuation.spacing?"sign"==e.segment?o.pad:o.punctuation.pad:o.pad}if(s.length&&n.push(s),o.punctuation.pull)for(let t of n){let e=t[t.length-1],i=e.y+e.height-(o.height-o.margin);if(i>0){let e=parseInt(i/t.length)+1;for(let o in t)t[o].y-=e*o+e}}let g=[];for(let t of n){let e=[r-o.offset-o.pad],i=[r+o.offset+o.pad];for(let l of t)e.push(l.x-o.pad),i.push(l.x+l.width+o.pad);e=Math.min(...e),i=Math.max(...i);let l=o.width,n=0;o.dynamic?(l=i-e,n=-e):n=r-parseInt((e+i)/2);for(let e of t)e.x+=n;g.push(l)}return{options:o,widths:g,columns:n}},W=[256,517,759,767,877,895,903],A=[767,876],L=[767,885],R=["#0000CC","#CC0000","#FF0099","#006600","#000000","#884411","#FF9900"],O=t=>{const e=_(t);let o="#000000";if(e.symbol){const t=parseInt(e.symbol.slice(1,4),16),i=W.findIndex((e=>e>t));o=R[i<0?6:i-1]}return o},Z=t=>{const e=_(t);if(!e.symbol)return"";let o,i,l,n,s=$(e.style);if(e.coord)o=e.coord[0],i=e.coord[1],l=500-o+500,n=500-i+500;else{let t=f(e.symbol);if(!t)return"";o=500-parseInt((t[0]+1)/2),i=500-parseInt((t[1]+1)/2),l=500-o+500,n=500-i+500}let a,r=h(e.symbol);r=` <g transform="translate(${o},${i})">\n${r}\n </g>`,s.colorize?a=O(e.symbol):s.detail&&(a=s.detail[0]),a&&(r=r.replace(/class="sym-line" fill="black"/,`class="sym-line" fill="${a}"`));let d=s.detail&&s.detail[1];d&&(r=r.replace(/class="sym-fill" fill="white"/,`class="sym-fill" fill="${d}"`));let c="";return s.padding&&(o-=s.padding,i-=s.padding,l+=s.padding,n+=s.padding),s.background&&(c=`\n <rect x="${o}" y="${i}" width="${l-o}" height="${n-i}" style="fill:${s.background};" />`),` <text font-size="0">${t}</text>${c}\n${r}`},D=t=>{let e=j(t);if(e.spatials){let o=$(e.style);o.detailsym&&o.detailsym.forEach((t=>{e.spatials[t.index-1]&&(e.spatials[t.index-1].detail=t.detail)}));let i=Math.min(...e.spatials.map((t=>t.coord[0]))),l=Math.min(...e.spatials.map((t=>t.coord[1]))),n=e.max[0],s=e.max[1],a="";o.padding&&(i-=o.padding,l-=o.padding,n+=o.padding,s+=o.padding),o.background&&(a=`\n <rect x="${i}" y="${l}" width="${n-i}" height="${s-l}" style="fill:${o.background};" />`);let r=` <text font-size="0">${t}</text>${a}`;const d=o.detail&&o.detail[0],c=o.detail&&o.detail[1];return r+="\n"+e.spatials.map((t=>{let e=h(t.symbol),i=d;t.detail?i=t.detail[0]:o.colorize&&(i=O(t.symbol)),i&&(e=e.replace(/class="sym-line" fill="black"/,`class="sym-line" fill="${i}"`));let l=c;return t.detail&&t.detail[1]&&(l=t.detail[1]),l&&(e=e.replace(/class="sym-fill" fill="white"/,`class="sym-fill" fill="${l}"`)),` <g transform="translate(${t.coord[0]},${t.coord[1]})">\n${e}\n </g>`})).join("\n"),r}return""},P=(t,e)=>{"object"!=typeof e&&(e={});const o=Object.assign(F,e);let i=o.width,l=o.height,n="";o.background&&(n=`\n <rect x="0" y="0" width="${i-0}" height="${l-0}" style="fill:${o.background};" />`);let s=`<svg version="1.1" xmlns="http://www.w3.org/2000/svg"${` width="${o.width}" height="${o.height}"`} viewBox="0 0 ${i-0} ${l-0}">\n ${n}`;return s+=t.map((t=>{const e=t.text.indexOf("-");if(e>0){const i=t.text.substring(e),l={...o.style,...$(i)};t.text=t.text.replace(i,v(l))}else t.text+=v(o.style);return t.zoom=t.zoom*o.style.zoom,'<g transform="translate('+t.x+","+t.y+") scale("+t.zoom+") translate("+-t.minX+","+-t.minY+') ">'+("sign"==t.segment?D(t.text):Z(t.text))+"</g>"})).join("\n"),s+="\n</svg>",s},T=(t,e)=>{const o=function(t,e){"object"!=typeof e&&(e={});const o=Object.assign(F,e),i=document.createElement("canvas");i.width=o.width,i.height=o.height;const l=i.getContext("2d");return o.background&&(l.rect(0,0,o.width,o.height),l.fillStyle=o.background,l.fill()),t.map((t=>{const e=t.text.indexOf("-");if(e>0){const i=t.text.substring(e),l={...o.style,...$(i)};t.text=t.text.replace(i,v(l))}else t.text+=v(o.style);t.zoom=t.zoom*o.style.zoom;let i={};if("sign"==t.segment)i=j(t.text);else{let e=_(t.text);i.style=e.style,i.spatials=[e]}let n=$(i.style);n.background&&(l.fillStyle=n.background,l.fillRect(t.x-n.padding*t.zoom,t.y-n.padding*t.zoom,(t.width+2*n.padding)*t.zoom,(t.height+2*n.padding)*t.zoom)),n.detailsym&&n.detailsym.forEach((t=>{i.spatials[t.index-1]&&(i.spatials[t.index-1].detail=t.detail)}));const s=n.detail&&n.detail[0]||"black",a=n.detail&&n.detail[1]||"white";i.spatials.forEach((e=>{let o=s;e.detail?o=e.detail[0]:n.colorize&&(o=O(e.symbol));let i=a;e.detail&&e.detail[1]&&(i=e.detail[1]),l.font=30*t.zoom+"px 'SuttonSignWritingFill'",l.fillStyle=i,l.fillText(y(e.symbol),t.x+(e.coord[0]-t.minX)*t.zoom,t.y+(e.coord[1]-t.minY)*t.zoom),l.font=30*t.zoom+"px 'SuttonSignWritingLine'",l.fillStyle=o,l.fillText(u(e.symbol),t.x+(e.coord[0]-t.minX)*t.zoom,t.y+(e.coord[1]-t.minY)*t.zoom)}))})),i}(t,e),i=o.toDataURL("image/png");return o.remove(),i};var B=Object.freeze({__proto__:null,symbolSize:f,symbolLine:u,symbolFill:y,symbolText:h,symbolSvgBody:Z,symbolSvg:t=>{const e=_(t),o='<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="1" height="1"></svg>';if(!e.symbol)return o;let i,l,n,s,a=$(e.style);if(e.coord)i=e.coord[0],l=e.coord[1],n=500-i+500,s=500-l+500;else{let t=f(e.symbol);if(!t)return o;i=parseInt(500-t[0]/2),l=parseInt(500-t[1]/2),n=i+t[0],s=l+t[1]}let r="";a.classes&&(r=` class="${a.classes}"`);let d="";a.id&&(d=` id="${a.id}"`),a.padding&&(i-=a.padding,l-=a.padding,n+=a.padding,s+=a.padding);let c="";return"x"!=a.zoom&&(c=` width="${(n-i)*(a.zoom?a.zoom:1)}" height="${(s-l)*(a.zoom?a.zoom:1)}"`),`<svg${r}${d} version="1.1" xmlns="http://www.w3.org/2000/svg"${c} viewBox="${i} ${l} ${n-i} ${s-l}">\n${Z(t)}\n</svg>`},symbolPng:t=>{const e=function(t){const e=_(t);if(e.symbol){let t=f(e.symbol);if(t){const o=document.createElement("canvas"),i=o.getContext("2d");let l=$(e.style),n="black";l.colorize?n=O(e.symbol):l.detail&&(n=l.detail[0]);let s=l.detail&&l.detail[1]||"white",a=500,r=a+t[0],d=500,c=d+t[1];l.padding&&(a-=l.padding,d-=l.padding,r+=l.padding,c+=l.padding);let m=1;"x"!=l.zoom&&(m=l.zoom);let g=(r-a)*m,p=(c-d)*m;return o.width=g||1,o.height=p||1,l.background&&(i.rect(0,0,g,p),i.fillStyle=l.background,i.fill()),i.font=30*m+"px 'SuttonSignWritingFill'",i.fillStyle=s,i.fillText(y(e.symbol),(500-a)*m,(500-d)*m),i.font=30*m+"px 'SuttonSignWritingLine'",i.fillStyle=n,i.fillText(u(e.symbol),(500-a)*m,(500-d)*m),o}}}(t),o=e.toDataURL("image/png");return e.remove(),o},symbolNormalize:t=>{const e=_(t);if(!e.symbol)return null;{let t=f(e.symbol);if(t)return`${e.symbol}${500-parseInt((t[0]+1)/2)}x${500-parseInt((t[1]+1)/2)}${e.style||""}`}},signSvgBody:D,signSvg:t=>{let e=j(t);if(e.spatials){let o=$(e.style),i=Math.min(...e.spatials.map((t=>t.coord[0]))),l=Math.min(...e.spatials.map((t=>t.coord[1]))),n=e.max[0],s=e.max[1],a="";o.classes&&(a=` class="${o.classes}"`);let r="";o.id&&(r=` id="${o.id}"`),o.padding&&(i-=o.padding,l-=o.padding,n+=o.padding,s+=o.padding);let d="";"x"!=o.zoom&&(d=` width="${(n-i)*(o.zoom?o.zoom:1)}" height="${(s-l)*(o.zoom?o.zoom:1)}"`);let c=`<svg${a}${r} version="1.1" xmlns="http://www.w3.org/2000/svg"${d} viewBox="${i} ${l} ${n-i} ${s-l}">\n`;return c+=D(t),c+="\n</svg>",c}return'<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="1" height="1"></svg>'},signPng:t=>{const e=function(t){const e=j(t);if(e.spatials){const t=document.createElement("canvas"),o=t.getContext("2d");let i=$(e.style);i.detailsym&&i.detailsym.forEach((t=>{e.spatials[t.index-1]&&(e.spatials[t.index-1].detail=t.detail)}));let l=Math.min(...e.spatials.map((t=>t.coord[0]))),n=Math.min(...e.spatials.map((t=>t.coord[1]))),s=e.max[0],a=e.max[1];i.padding&&(l-=i.padding,n-=i.padding,s+=i.padding,a+=i.padding);let r=1;"x"!=i.zoom&&(r=i.zoom);let d=(s-l)*r,c=(a-n)*r;t.width=d||1,t.height=c||1,i.background&&(o.rect(0,0,d,c),o.fillStyle=i.background,o.fill());const m=i.detail&&i.detail[0]||"black",g=i.detail&&i.detail[1]||"white";return e.spatials.forEach((t=>{let e=m;t.detail?e=t.detail[0]:i.colorize&&(e=O(t.symbol));let s=g;t.detail&&t.detail[1]&&(s=t.detail[1]),o.font=30*r+"px 'SuttonSignWritingFill'",o.fillStyle=s,o.fillText(y(t.symbol),(t.coord[0]-l)*r,(t.coord[1]-n)*r),o.font=30*r+"px 'SuttonSignWritingLine'",o.fillStyle=e,o.fillText(u(t.symbol),(t.coord[0]-l)*r,(t.coord[1]-n)*r)})),t}}(t),o=e.toDataURL("image/png");return e.remove(),o},signNormalize:t=>{const e=j(t);if(e.spatials){const t=e.spatials.reduce(((t,e)=>{const o=f(e.symbol);return t[e.symbol]={width:o[0],height:o[1]},t}),{}),o=e=>({x1:Math.min(...e.map((t=>t.coord[0]))),y1:Math.min(...e.map((t=>t.coord[1]))),x2:Math.max(...e.map((e=>e.coord[0]+parseInt(t[e.symbol].width)))),y2:Math.max(...e.map((e=>e.coord[1]+parseInt(t[e.symbol].height))))}),i=A,l=e.spatials.filter((t=>{const e=parseInt(t.symbol.slice(1,4),16);return i[0]<=e&&i[1]>=e})),n=L,s=e.spatials.filter((t=>{const e=parseInt(t.symbol.slice(1,4),16);return n[0]<=e&&n[1]>=e}));let a=o(e.spatials),r=[a.x2,a.y2];if(l.length){const t=o(l);a.x1=t.x1,a.x2=t.x2}if(s.length){const t=o(s);a.y1=t.y1,a.y2=t.y2}const d=[parseInt((a.x2+a.x1)/2)-500,parseInt((a.y2+a.y1)/2)-500];return(e.sequence?"A"+e.sequence.join(""):"")+e.box+(r[0]-d[0])+"x"+(r[1]-d[1])+e.spatials.map((t=>t.symbol+(t.coord[0]-d[0])+"x"+(t.coord[1]-d[1]))).join("")+(e.style||"")}},columnSvg:P,columnsSvg:function(t,e){"object"!=typeof e&&(e={});let o=C(t,e);return o.columns.map(((t,e)=>P(t,{...o.options,width:o.widths[e]})))},columnPng:T,columnsPng:function(t,e){"object"!=typeof e&&(e={});let o=C(t,e);return o.columns.map(((t,e)=>T(t,{...o.options,width:o.widths[e]})))}});const X=function(t){return l(g(t))},Y=function(t){return n(g(t))},q=function(t){return s(g(t))},U=function(t){return a(g(t))};let N={symbol:"(?:(?:\ud8c0[\udc01-\udfff])|(?:[\ud8c1-\ud8fc][\udc00-\udfff])|(?:\ud8fd[\udc00-\udc80]))",coord:"(?:\ud836[\udc0c-\uddff]){2}",sort:"𝠀",box:"\ud836[\udc01-\udc04]"};N.prefix=`(?:${N.sort}(?:${N.symbol})+)`,N.spatial=`${N.symbol}${N.coord}`,N.signbox=`${N.box}${N.coord}(?:${N.spatial})*`,N.sign=`${N.prefix}?${N.signbox}`,N.sortable=`${N.prefix}${N.signbox}`;let G={colorize:"C",colorhex:"(?:[0-9a-fA-F]{3}){1,2}",colorname:"[a-zA-Z]+",padding:"P[0-9]{2}",zoom:"Z(?:[0-9]+(?:\\.[0-9]+)?|x)",classbase:"-?[_a-zA-Z][_a-zA-Z0-9-]{0,100}",id:"[a-zA-Z][_a-zA-Z0-9-]{0,100}"};G.colorbase=`(?:${G.colorhex}|${G.colorname})`,G.color=`_${G.colorbase}_`,G.colors=`_${G.colorbase}(?:,${G.colorbase})?_`,G.background=`G${G.color}`,G.detail=`D${G.colors}`,G.detailsym=`D[0-9]{2}${G.colors}`,G.classes=`${G.classbase}(?: ${G.classbase})*`,G.full=`-(${G.colorize})?(${G.padding})?(${G.background})?(${G.detail})?(${G.zoom})?(?:-((?:${G.detailsym})*))?(?:-(${G.classes})?!(?:(${G.id})!)?)?`;const H=t=>(new RegExp(`^${G.colorhex}$`).test(t)?"#":"")+t,J=t=>{const e=`^${G.full}`,o=("string"==typeof t?t.match(new RegExp(e)):[])||[];return i={colorize:o[1]?!!o[1]:void 0,padding:o[2]?parseInt(o[2].slice(1)):void 0,background:o[3]?H(o[3].slice(2,-1)):void 0,detail:o[4]?o[4].slice(2,-1).split(",").map(H):void 0,zoom:o[5]?"Zx"===o[5]?"x":parseFloat(o[5].slice(1)):void 0,detailsym:o[6]?o[6].match(new RegExp(G.detailsym,"g")).map((t=>{const e=t.split("_"),o=e[1].split(",").map(H);return{index:parseInt(e[0].slice(1)),detail:o}})):void 0,classes:o[7]?o[7]:void 0,id:o[8]?o[8]:void 0},Object.fromEntries(Object.entries(i).filter((([t,e])=>void 0!==e)));var i},K=t=>parseInt(t.codePointAt(0))-120844+250,Q=t=>[K(t.slice(0,2)),K(t.slice(2,4))],V=t=>{const e=`^(${N.symbol})(${N.coord})?(${G.full})?`,o="string"==typeof t?t.match(new RegExp(e)):void 0;return{symbol:o?o[1]:void 0,coord:o&&o[2]?Q(o[2]):void 0,style:o?o[3]:void 0}},tt=t=>{const e=`^(${N.prefix})?(${N.signbox})(${G.full})?`,o="string"==typeof t?t.match(new RegExp(e)):void 0;return o?{sequence:o[1]?o[1].slice(2).match(/.{2}/g):void 0,box:o[2].slice(0,2),max:Q(o[2].slice(2,6)),spatials:o[2].length<7?void 0:o[2].slice(6).match(/(.{6})/g).map((t=>({symbol:t.slice(0,2),coord:Q(t.slice(2))}))),style:o[3]}:{}},et=t=>{if("string"!=typeof t)return[];const e=`(${N.sign}(${G.full})?|${N.spatial}(${G.full})?)`,o=t.match(new RegExp(e,"g"));return o?[...o]:[]},ot=t=>{let e,o,i,l,n,s,a,r,d=tt(t);d.spatials?(l=Math.min(...d.spatials.map((t=>t.coord[0]))),n=d.max[0],e=n-l,s=Math.min(...d.spatials.map((t=>t.coord[1]))),a=d.max[1],o=a-s,i="sign",r=d.box):(d=V(t),r="𝠃",d.coord?(l=d.coord[0],e=2*(500-l),s=d.coord[1],o=2*(500-s),i="symbol"):(l=490,e=20,s=490,o=20,i="none"));let c=J(d.style),m=c.zoom||1,g=c.padding||0;return{minX:l,minY:s,width:e,height:o,segment:i,lane:{"𝠁":0,"𝠂":-1,"𝠃":0,"𝠄":1}[r],padding:g,zoom:m}},it={height:500,width:150,offset:50,pad:20,margin:5,dynamic:!1,background:void 0,punctuation:{spacing:!0,pad:30,pull:!0},style:{detail:["black","white"],zoom:1}},lt=(t,e)=>{if("string"!=typeof t)return{};const o=(t=>("object"!=typeof t&&(t={}),{...it,...t,punctuation:{...it.punctuation,...t.punctuation},style:{...it.style,...t.style}}))(e);let i=et(t),l=0,n=[],s=[],a=0,r=parseInt(o.width/2),d=o.height-o.margin,c=!0,m=!1;for(let t of i){let e=ot(t);l+=a,o.punctuation.spacing?l+="sign"==e.segment?o.pad:0:l+=o.pad,m=l+e.height>d,m&&"symbol"==e.segment&&o.punctuation.pull&&c&&(m=!1,c=!1),0==s.length&&(m=!1),m&&(l=o.pad,n.push(s),s=[],c=!0),s.push(Object.assign(e,{x:r+o.offset*e.lane-(500-e.minX)*e.zoom*o.style.zoom,y:l,text:t})),l+=e.height*e.zoom*o.style.zoom,a=o.punctuation.spacing?"sign"==e.segment?o.pad:o.punctuation.pad:o.pad}if(s.length&&n.push(s),o.punctuation.pull)for(let t of n){let e=t[t.length-1],i=e.y+e.height-(o.height-o.margin);if(i>0){let e=parseInt(i/t.length)+1;for(let o in t)t[o].y-=e*o+e}}let g=[];for(let t of n){let e=[r-o.offset-o.pad],i=[r+o.offset+o.pad];for(let l of t)e.push(l.x-o.pad),i.push(l.x+l.width+o.pad);e=Math.min(...e),i=Math.max(...i);let l=o.width,n=0;o.dynamic?(l=i-e,n=-e):n=r-parseInt((e+i)/2);for(let e of t)e.x+=n;g.push(l)}return{options:o,widths:g,columns:n}},nt=[262145,287201,310433,311201,321761,323489,324257],st=[311201,321760],at=[311201,322624],rt=["#0000CC","#CC0000","#FF0099","#006600","#000000","#884411","#FF9900"],dt=t=>{const e=V(t);let o="#000000";if(e.symbol){const t=(t=>parseInt(t.codePointAt(0)))(e.symbol),i=nt.findIndex((e=>e>t));o=rt[i<0?6:i-1]}return o},ct=t=>{const e=V(t);if(!e.symbol)return"";let o,i,l,n,s=$(e.style);if(e.coord)o=e.coord[0],i=e.coord[1],l=500-o+500,n=500-i+500;else{let t=X(e.symbol);if(!t)return"";o=500-parseInt((t[0]+1)/2),i=500-parseInt((t[1]+1)/2),l=500-o+500,n=500-i+500}let a,r=U(e.symbol);r=` <g transform="translate(${o},${i})">\n${r}\n </g>`,s.colorize?a=dt(e.symbol):s.detail&&(a=s.detail[0]),a&&(r=r.replace(/class="sym-line" fill="black"/,`class="sym-line" fill="${a}"`));let d=s.detail&&s.detail[1];d&&(r=r.replace(/class="sym-fill" fill="white"/,`class="sym-fill" fill="${d}"`));let c="";return s.padding&&(o-=s.padding,i-=s.padding,l+=s.padding,n+=s.padding),s.background&&(c=`\n <rect x="${o}" y="${i}" width="${l-o}" height="${n-i}" style="fill:${s.background};" />`),` <text font-size="0">${t}</text>${c}\n${r}`},mt=t=>{let e=tt(t);if(e.spatials){let o=$(e.style);o.detailsym&&o.detailsym.forEach((t=>{e.spatials[t.index-1]&&(e.spatials[t.index-1].detail=t.detail)}));let i=Math.min(...e.spatials.map((t=>t.coord[0]))),l=Math.min(...e.spatials.map((t=>t.coord[1]))),n=e.max[0],s=e.max[1],a="";o.padding&&(i-=o.padding,l-=o.padding,n+=o.padding,s+=o.padding),o.background&&(a=`\n <rect x="${i}" y="${l}" width="${n-i}" height="${s-l}" style="fill:${o.background};" />`);let r=` <text font-size="0">${t}</text>${a}`;const d=o.detail&&o.detail[0],c=o.detail&&o.detail[1];return r+="\n"+e.spatials.map((t=>{let e=U(t.symbol),i=d;t.detail?i=t.detail[0]:o.colorize&&(i=dt(t.symbol)),i&&(e=e.replace(/class="sym-line" fill="black"/,`class="sym-line" fill="${i}"`));let l=c;return t.detail&&t.detail[1]&&(l=t.detail[1]),l&&(e=e.replace(/class="sym-fill" fill="white"/,`class="sym-fill" fill="${l}"`)),` <g transform="translate(${t.coord[0]},${t.coord[1]})">\n${e}\n </g>`})).join("\n"),r}return""},gt=(t,e)=>{"object"!=typeof e&&(e={});const o=Object.assign(it,e);let i=o.width,l=o.height,n="";o.background&&(n=`\n <rect x="0" y="0" width="${i-0}" height="${l-0}" style="fill:${o.background};" />`);let s=`<svg version="1.1" xmlns="http://www.w3.org/2000/svg"${` width="${o.width}" height="${o.height}"`} viewBox="0 0 ${i-0} ${l-0}">\n <text font-size="0">0</text>${n}`;return s+=t.map((t=>{const e=t.text.indexOf("-");if(e>0){const i=t.text.substring(e),l={...o.style,...$(i)};t.text=t.text.replace(i,v(l))}else t.text+=v(o.style);return t.zoom=t.zoom*o.style.zoom,'<g transform="translate('+t.x+","+t.y+") scale("+t.zoom+") translate("+-t.minX+","+-t.minY+') ">'+("sign"==t.segment?mt(t.text):ct(t.text))+"</g>"})).join("\n"),s+="\n</svg>",s},pt=(t,e)=>{const o=function(t,e){"object"!=typeof e&&(e={});const o=Object.assign(it,e),i=document.createElement("canvas");i.width=o.width,i.height=o.height;const l=i.getContext("2d");return o.background&&(l.rect(0,0,o.width,o.height),l.fillStyle=o.background,l.fill()),t.map((t=>{const e=t.text.indexOf("-");if(e>0){const i=t.text.substring(e),l={...o.style,...$(i)};t.text=t.text.replace(i,v(l))}else t.text+=v(o.style);t.zoom=t.zoom*o.style.zoom;let i={};if("sign"==t.segment)i=tt(t.text);else{let e=V(t.text);i.style=e.style,i.spatials=[e]}let n=$(i.style);n.background&&(l.fillStyle=n.background,l.fillRect(t.x-n.padding*t.zoom,t.y-n.padding*t.zoom,(t.width+2*n.padding)*t.zoom,(t.height+2*n.padding)*t.zoom)),n.detailsym&&n.detailsym.forEach((t=>{i.spatials[t.index-1]&&(i.spatials[t.index-1].detail=t.detail)}));const s=n.detail&&n.detail[0]||"black",a=n.detail&&n.detail[1]||"white";i.spatials.forEach((e=>{let o=s;e.detail?o=e.detail[0]:n.colorize&&(o=dt(e.symbol));let i=a;e.detail&&e.detail[1]&&(i=e.detail[1]),l.font=30*t.zoom+"px 'SuttonSignWritingFill'",l.fillStyle=i,l.fillText(q(e.symbol),t.x+(e.coord[0]-t.minX)*t.zoom,t.y+(e.coord[1]-t.minY)*t.zoom),l.font=30*t.zoom+"px 'SuttonSignWritingLine'",l.fillStyle=o,l.fillText(Y(e.symbol),t.x+(e.coord[0]-t.minX)*t.zoom,t.y+(e.coord[1]-t.minY)*t.zoom)}))})),i}(t,e),i=o.toDataURL("image/png");return o.remove(),i};var ft=Object.freeze({__proto__:null,symbolSize:X,symbolLine:Y,symbolFill:q,symbolText:U,symbolSvgBody:ct,symbolSvg:t=>{const e=V(t),o='<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="1" height="1"></svg>';if(!e.symbol)return o;let i,l,n,s,a=$(e.style);if(e.coord)i=e.coord[0],l=e.coord[1],n=500-i+500,s=500-l+500;else{let t=X(e.symbol);if(!t)return o;i=parseInt(500-t[0]/2),l=parseInt(500-t[1]/2),n=i+t[0],s=l+t[1]}let r="";a.classes&&(r=` class="${a.classes}"`);let d="";a.id&&(d=` id="${a.id}"`),a.padding&&(i-=a.padding,l-=a.padding,n+=a.padding,s+=a.padding);let c="";return"x"!=a.zoom&&(c=` width="${(n-i)*(a.zoom?a.zoom:1)}" height="${(s-l)*(a.zoom?a.zoom:1)}"`),`<svg${r}${d} version="1.1" xmlns="http://www.w3.org/2000/svg"${c} viewBox="${i} ${l} ${n-i} ${s-l}">\n${ct(t)}\n</svg>`},symbolPng:t=>{const e=function(t){const e=V(t);if(e.symbol){let t=X(e.symbol);if(t){const o=document.createElement("canvas"),i=o.getContext("2d");let l=$(e.style),n="black";l.colorize?n=dt(e.symbol):l.detail&&(n=l.detail[0]);let s=l.detail&&l.detail[1]||"white",a=500,r=a+t[0],d=500,c=d+t[1];l.padding&&(a-=l.padding,d-=l.padding,r+=l.padding,c+=l.padding);let m=1;"x"!=l.zoom&&(m=l.zoom);let g=(r-a)*m,p=(c-d)*m;return o.width=g||1,o.height=p||1,l.background&&(i.rect(0,0,g,p),i.fillStyle=l.background,i.fill()),i.font=30*m+"px 'SuttonSignWritingFill'",i.fillStyle=s,i.fillText(q(e.symbol),(500-a)*m,(500-d)*m),i.font=30*m+"px 'SuttonSignWritingLine'",i.fillStyle=n,i.fillText(Y(e.symbol),(500-a)*m,(500-d)*m),o}}}(t),o=e.toDataURL("image/png");return e.remove(),o},symbolNormalize:t=>{const e=V(t);if(!e.symbol)return null;{let t=X(e.symbol);if(t)return`${e.symbol}${m([500-parseInt((t[0]+1)/2),500-parseInt((t[1]+1)/2)])}${e.style||""}`}},signSvgBody:mt,signSvg:t=>{let e=tt(t);if(e.spatials){let o=$(e.style),i=Math.min(...e.spatials.map((t=>t.coord[0]))),l=Math.min(...e.spatials.map((t=>t.coord[1]))),n=e.max[0],s=e.max[1],a="";o.classes&&(a=` class="${o.classes}"`);let r="";o.id&&(r=` id="${o.id}"`),o.padding&&(i-=o.padding,l-=o.padding,n+=o.padding,s+=o.padding);let d="";"x"!=o.zoom&&(d=` width="${(n-i)*(o.zoom?o.zoom:1)}" height="${(s-l)*(o.zoom?o.zoom:1)}"`);let c=`<svg${a}${r} version="1.1" xmlns="http://www.w3.org/2000/svg"${d} viewBox="${i} ${l} ${n-i} ${s-l}">\n`;return c+=mt(t),c+="\n</svg>",c}return'<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="1" height="1"></svg>'},signPng:t=>{const e=function(t){const e=tt(t);if(e.spatials){const t=document.createElement("canvas"),o=t.getContext("2d");let i=$(e.style);i.detailsym&&i.detailsym.forEach((t=>{e.spatials[t.index-1]&&(e.spatials[t.index-1].detail=t.detail)}));let l=Math.min(...e.spatials.map((t=>t.coord[0]))),n=Math.min(...e.spatials.map((t=>t.coord[1]))),s=e.max[0],a=e.max[1];i.padding&&(l-=i.padding,n-=i.padding,s+=i.padding,a+=i.padding);let r=1;"x"!=i.zoom&&(r=i.zoom);let d=(s-l)*r,c=(a-n)*r;t.width=d||1,t.height=c||1,i.background&&(o.rect(0,0,d,c),o.fillStyle=i.background,o.fill());const m=i.detail&&i.detail[0]||"black",g=i.detail&&i.detail[1]||"white";return e.spatials.forEach((t=>{let e=m;t.detail?e=t.detail[0]:i.colorize&&(e=dt(t.symbol));let s=g;t.detail&&t.detail[1]&&(s=t.detail[1]),o.font=30*r+"px 'SuttonSignWritingFill'",o.fillStyle=s,o.fillText(q(t.symbol),(t.coord[0]-l)*r,(t.coord[1]-n)*r),o.font=30*r+"px 'SuttonSignWritingLine'",o.fillStyle=e,o.fillText(Y(t.symbol),(t.coord[0]-l)*r,(t.coord[1]-n)*r)})),t}}(t),o=e.toDataURL("image/png");return e.remove(),o},signNormalize:t=>{const e=tt(t);if(e.spatials){const t=e.spatials.reduce(((t,e)=>{const o=X(e.symbol);return t[e.symbol]={width:o[0],height:o[1]},t}),{}),o=e=>({x1:Math.min(...e.map((t=>t.coord[0]))),y1:Math.min(...e.map((t=>t.coord[1]))),x2:Math.max(...e.map((e=>e.coord[0]+parseInt(t[e.symbol].width)))),y2:Math.max(...e.map((e=>e.coord[1]+parseInt(t[e.symbol].height))))}),i=st,l=e.spatials.filter((t=>{const e=parseInt(t.symbol.slice(1,4),16);return i[0]<=e&&i[1]>=e})),n=at,s=e.spatials.filter((t=>{const e=parseInt(t.symbol.slice(1,4),16);return n[0]<=e&&n[1]>=e}));let a=o(e.spatials),r=[a.x2,a.y2];if(l.length){const t=o(l);a.x1=t.x1,a.x2=t.x2}if(s.length){const t=o(s);a.y1=t.y1,a.y2=t.y2}const d=[parseInt((a.x2+a.x1)/2)-500,parseInt((a.y2+a.y1)/2)-500];return(e.sequence?"𝠀"+e.sequence.join(""):"")+e.box+m([r[0]-d[0],r[1]-d[1]])+e.spatials.map((t=>t.symbol+m([t.coord[0]-d[0],t.coord[1]-d[1]]))).join("")+(e.style||"")}},columnSvg:gt,columnsSvg:function(t,e){"object"!=typeof e&&(e={});let o=lt(t,e);return o.columns.map(((t,e)=>gt(t,{...o.options,width:o.widths[e]})))},columnPng:pt,columnsPng:function(t,e){"object"!=typeof e&&(e={});let o=lt(t,e);return o.columns.map(((t,e)=>pt(t,{...o.options,width:o.widths[e]})))}});t.font=c,t.fsw=B,t.swu=ft,Object.defineProperty(t,"__esModule",{value:!0})}));