@sutton-signwriting/core
Version:
a javascript package for node and browsers that supports general processing of the Sutton SignWriting script
3 lines (2 loc) • 37.4 kB
JavaScript
/* Sutton SignWriting Core Module v2.0.1 (https://github.com/sutton-signwriting/core), author: Steve Slevinski (https://SteveSlevinski.me), license: MIT */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).ssw=e.ssw||{},e.ssw.core={}))}(this,(function(e){"use strict";let t={null:"S00000",symbol:"S[123][0-9a-f]{2}[0-5][0-9a-f]",coord:"[0-9]{3}x[0-9]{3}",sort:"A",box:"[BLMR]"};t.nullorsymbol=`(?:${t.null}|${t.symbol})`,t.prefix=`(?:${t.sort}${t.nullorsymbol}+)`,t.spatial=`${t.symbol}${t.coord}`,t.signbox=`${t.box}${t.coord}(?:${t.spatial})*`,t.sign=`${t.prefix}?${t.signbox}`,t.sortable=`${t.prefix}${t.signbox}`;let o={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}"};o.colorbase=`(?:${o.colorhex}|${o.colorname})`,o.color=`_${o.colorbase}_`,o.colors=`_${o.colorbase}(?:,${o.colorbase})?_`,o.background=`G${o.color}`,o.detail=`D${o.colors}`,o.detailsym=`D[0-9]{2}${o.colors}`,o.classes=`${o.classbase}(?: ${o.classbase})*`,o.full=`-(${o.colorize})?(${o.padding})?(${o.background})?(${o.detail})?(${o.zoom})?(?:-((?:${o.detailsym})*))?(?:-(${o.classes})?!(?:(${o.id})!)?)?`;const n=e=>(new RegExp(`^${o.colorhex}$`).test(e)?"#":"")+e,r=e=>{const t=`^${o.full}`,r=("string"==typeof e?e.match(new RegExp(t)):[])||[];return s={colorize:r[1]?!!r[1]:void 0,padding:r[2]?parseInt(r[2].slice(1)):void 0,background:r[3]?n(r[3].slice(2,-1)):void 0,detail:r[4]?r[4].slice(2,-1).split(",").map(n):void 0,zoom:r[5]?"Zx"===r[5]?"x":parseFloat(r[5].slice(1)):void 0,detailsym:r[6]?r[6].match(new RegExp(o.detailsym,"g")).map((e=>{const t=e.split("_"),o=t[1].split(",").map(n);return{index:parseInt(t[0].slice(1)),detail:o}})):void 0,classes:r[7]?r[7]:void 0,id:r[8]?r[8]:void 0},Object.fromEntries(Object.entries(s).filter((([e,t])=>void 0!==t)));var s},s=e=>"string"!=typeof e?[0,0,0]:e.replace(/rgba?\((.+?)\)/gi,((e,t)=>t)).split(",").map(Number),i=e=>e.slice(0,3).map((e=>e.toString(16).padStart(2,"0"))).join("");var l=Object.freeze({__proto__:null,re:o,parse:r,compose:e=>{if("object"!=typeof e||null===e)return;let t="-";t+=e.colorize?"C":"";const n=parseInt(e.padding);t+=!n||n<=0||n>99?"":"P"+(n>9?n:"0"+n);const r=e.background&&"string"==typeof e.background?e.background.match(o.colorbase)[0]:void 0;t+=r?"G_"+r+"_":"";const s=e.detail&&e.detail[0]&&"string"==typeof e.detail[0]?e.detail[0].match(o.colorbase)[0]:void 0,i=e.detail&&e.detail[1]&&"string"==typeof e.detail[1]?e.detail[1].match(o.colorbase)[0]:void 0;s&&(t+="D_"+s,i&&(t+=","+i),t+="_");const l="x"===e.zoom?"x":parseFloat(e.zoom);t+=!l||l<=0?"":"Z"+l;let a="";const c=e.detailsym&&Array.isArray(e.detailsym)?e.detailsym.map((e=>{const t=parseInt(e.index);if(!t||t<=0||t>99)return"";let n="D"+(t>9?t:"0"+t);const r=e.detail&&e.detail[0]?e.detail[0].match(o.colorbase)[0]:void 0,s=e.detail&&e.detail[1]?e.detail[1].match(o.colorbase)[0]:void 0;return r&&(n+="_"+r,s&&(n+=","+s),n+="_"),n})):[];a+=c.join("");let u="";const p=e.classes&&"string"==typeof e.classes?e.classes.match(o.classes)[0]:void 0;u+=p||"";const d=e.id&&"string"==typeof e.id?e.id.match(o.id)[0]:void 0;return u+=p||d?"!":"",u+=d?d+"!":"",t+(a||u?"-"+a:"")+(u?"-"+u:"")},merge:(e,t)=>{"object"!=typeof e&&(e={}),"object"!=typeof t&&(t={});const o="zoom"in e?"x"===e.zoom?1:e.zoom:1,n="zoom"in t?"x"===t.zoom?1:t.zoom:1;return{...e,...t,zoom:o*n}},rgb2hex:(e,t=0)=>{const o=s(e);return 4==o.length&&o[3]<=t?"transparent":i(o)},rgba2hex:(e,t)=>{const o=s(t),n=s(e),r=4==n.length?n[3]:1;return 0==r?"transparent":i(n.map(((e,t)=>parseInt((1-r)*o[t]+r*e))))}});let a={null:"",symbol:"(?:(?:\ud8c0[\udc01-\udfff])|(?:[\ud8c1-\ud8fc][\udc00-\udfff])|(?:\ud8fd[\udc00-\udc80]))",coord:"(?:\ud836[\udc0c-\uddff]){2}",sort:"𝠀",box:"\ud836[\udc01-\udc04]"};a.nullorsymbol=`(?:${a.null}|${a.symbol})`,a.prefix=`(?:${a.sort}(?:${a.nullorsymbol})+)`,a.spatial=`${a.symbol}${a.coord}`,a.signbox=`${a.box}${a.coord}(?:${a.spatial})*`,a.sign=`${a.prefix}?${a.signbox}`,a.sortable=`${a.prefix}${a.signbox}`;const c=["101011","101021","101031","101041","101051","101061","101071","101081","101091","101101","101111","101121","101131","101141","102011","102021","102031","102041","102051","102061","102071","102081","102091","102101","102111","102121","102131","102141","102151","102161","103011","103021","103031","103041","103051","103061","103071","103081","103091","103101","103111","103121","103131","103141","103151","103161","103171","103181","103191","103201","103211","103221","103231","103241","103251","103261","103271","103281","103291","103301","103311","103321","103331","103341","103351","103361","103371","103381","104011","104021","104031","104041","104051","104061","104071","104081","105011","105021","105031","105041","105051","105061","105071","105081","105091","105101","105111","105121","105131","105141","105151","105161","105171","105181","105191","105201","105211","105221","105231","105241","105251","105261","105271","105281","105291","105301","105311","105321","105331","105341","105351","105361","105371","105381","105391","105401","105411","105421","105431","105441","105451","105461","105471","105481","105491","105501","105511","105521","105531","105541","105551","105561","105571","105581","106011","106021","106031","106041","106051","106061","106071","106081","106091","106101","106111","106121","106131","106141","106151","106161","106171","106181","106191","106201","106211","106221","106231","106241","106251","106261","106271","106281","106291","106301","107011","107021","107031","107041","107051","107061","107071","107081","107091","107101","107111","107121","107131","107141","107151","107161","107171","107181","107191","107201","107211","107221","108011","108021","108031","108041","108051","108061","108071","108081","108091","108101","108111","108121","108131","108141","108151","108161","108171","108181","108191","109011","109021","109031","109041","109051","109061","109071","109081","109091","109101","109111","109121","109131","109141","109151","109161","109171","109181","109191","109201","109211","109221","109231","109241","109251","109261","109271","109281","109291","109301","109311","109321","109331","109341","109351","109361","109371","109381","109391","109401","110011","110021","110031","110041","110051","110061","110071","110081","110091","110101","110111","110121","110131","110141","110151","110161","201011","201021","201031","201041","201051","201061","201071","201081","201091","201101","201111","201121","201131","201141","201151","201161","201171","202011","202012","202021","202022","202031","202041","202042","202051","202052","202061","202071","202081","202082","202091","202092","202101","202102","202111","202121","202131","203011","203012","203013","203014","203015","203021","203022","203031","203032","203041","203051","203052","203061","203062","203071","203072","203073","203081","203082","203083","203084","203091","203092","203093","203101","203102","203103","203111","203112","203113","203121","203122","203123","203131","203141","203151","203161","203171","203181","203191","203201","203202","203203","204011","204012","204013","204014","204021","204022","204023","204024","204031","204032","204033","204034","204041","204042","204043","204044","205011","205012","205013","205014","205015","205021","205022","205031","205032","205041","205051","205052","205061","205062","205071","205081","205082","205083","205091","205101","205102","205103","205111","205112","205113","205121","205122","205123","205131","205141","205151","205161","205171","205181","205191","206011","206012","206013","206014","206021","206022","206023","206024","206031","206032","206041","206042","206043","206051","206052","206053","206054","206061","206062","206063","206064","206065","206066","206071","206072","206073","206081","206091","206101","206111","207011","207021","207031","207041","207051","207061","207071","207091","207101","207111","207121","207131","207141","207151","207161","207162","207163","208011","208012","208021","208022","208023","208024","208031","208032","208033","208034","208041","208042","208051","208061","208071","208081","208082","208091","208092","208093","208094","208101","208102","208103","208104","208111","208112","208121","208131","208141","209011","209012","209013","209014","209015","209021","209031","209041","209042","209043","209051","209061","209071","209081","210011","210012","210021","210022","210031","210032","210033","210041","210042","210043","210051","210052","210061","210062","210071","210072","210073","210074","210081","210082","301011","301021","301031","301032","301041","301042","301043","301044","401011","401021","401031","401041","401051","401061","401071","401081","401091","401101","401102","402011","402012","402013","402021","402022","402023","402024","402031","402032","402033","402041","402042","402043","402044","402045","402051","402052","402053","402054","402055","402061","402062","402063","402071","402072","402073","402081","402082","402083","402091","402101","402111","403011","403012","403013","403021","403022","403023","403031","403041","403042","403043","403044","403051","403052","403061","403062","403071","403072","404011","404012","404013","404021","404022","404023","404031","404032","404033","404041","404042","404043","404051","404052","404053","404061","404062","404063","404071","404072","404073","404081","404082","404083","404091","404092","404093","404101","404111","404112","405011","405012","405013","405014","405015","405021","405031","405041","405051","405052","405061","405062","405071","405072","405081","405091","405101","405111","405121","405131","501011","501021","501031","501041","501051","501061","501071","501081","501091","502011","502021","502022","502023","502024","502031","502032","502033","502041","601011","601012","601021","601031","601041","601051","601061","601071","701011","701012","701021","701022","701031"],u=e=>({A:"𝠀",B:"𝠁",L:"𝠂",M:"𝠃",R:"𝠄"}[e]),p=e=>parseInt(e.codePointAt(0))-120844+250,d=e=>String.fromCodePoint(120844+parseInt(e)-250),f=e=>[p(e.slice(0,2)),p(e.slice(2,4))],m=e=>e.map((e=>d(e))).join(""),g=e=>e.split("x").map((e=>parseInt(e))),h=e=>parseInt(e.codePointAt(0)),y=e=>String.fromCodePoint(e),x=e=>{if(""===e)return"S00000";const t=h(e)-262145,o=parseInt(t/96),n=parseInt((t-96*o)/16),r=parseInt(t-96*o-16*n);return"S"+(o+256).toString(16)+n.toString(16)+r.toString(16)},b=e=>y("S00000"===e?262144:262145+96*(parseInt(e.slice(1,4),16)-256)+16*parseInt(e.slice(4,5),16)+parseInt(e.slice(5,6),16)),$=e=>{if(!/^\d{6}(?:\d{3})?$/.test(e))return"";let t=`0${e.charAt(0)}-${e.charAt(1)}${e.charAt(2)}-0${e.charAt(3)}${e.charAt(4)}-0${e.charAt(5)}`;return e.length>6&&(t+=`-0${e.charAt(6)}-${e.charAt(7)}${e.charAt(8)}`),t};var v=Object.freeze({__proto__:null,swu2mark:e=>({"𝠀":"A","𝠁":"B","𝠂":"L","𝠃":"M","𝠄":"R"}[e]),mark2swu:u,swu2num:p,num2swu:d,swu2coord:f,coord2swu:m,fsw2coord:g,coord2fsw:e=>e.join("x"),swu2code:h,code2swu:y,swu2id:e=>h(e)-262144,id2swu:e=>y(e+262144),key2id:e=>"S00000"===e?0:1+96*(parseInt(e.slice(1,4),16)-256)+16*parseInt(e.slice(4,5),16)+parseInt(e.slice(5,6),16),id2key:e=>{if(0===e)return"S00000";const t=e-1,o=parseInt(t/96),n=parseInt((t-96*o)/16),r=parseInt(t-96*o-16*n);return"S"+(o+256).toString(16)+n.toString(16)+r.toString(16)},swu2key:x,key2swu:b,swu2fsw:e=>{if(!e)return"";let t=e.replace(/𝠀/g,"A").replace(/𝠁/g,"B").replace(/𝠂/g,"L").replace(/𝠃/g,"M").replace(/𝠄/g,"R");const o=t.match(new RegExp(a.nullorsymbol,"g"));o&&o.forEach((function(e){t=t.replace(e,x(e))}));const n=t.match(new RegExp(a.coord,"g"));return n&&n.forEach((function(e){t=t.replace(e,f(e).join("x"))})),t},fsw2swu:e=>{if(!e)return"";const o=e.match(new RegExp(t.prefix,"g"));o&&o.forEach((function(t){e=e.replace(t,"𝠀"+t.slice(1).match(/.{6}/g).map((e=>b(e))).join(""))}));const n=e.match(new RegExp(t.box+t.coord,"g"));n&&n.forEach((function(t){e=e.replace(t,u(t.slice(0,1))+m(g(t.slice(1,8))))}));const r=e.match(new RegExp(t.spatial,"g"));return r&&r.forEach((function(t){e=e.replace(t,b(t.slice(0,6))+m(g(t.slice(6,13))))})),e},symidArr:c,symidMax:$,symidMin:e=>{const t=e.match(/^0(\d)-(\d{2})-0(\d{2})-0(\d)(?:-0(\d)-(\d{2}))?$/);return t?t[5]?t[1]+t[2]+t[3]+t[4]+t[5]+t[6]:t[1]+t[2]+t[3]+t[4]:""},symid2key:e=>{const t=e.match(/^0(\d)-(\d{2})-0(\d{2})-0(\d)(?:-0(\d)-(\d{2}))?$/);if(!t)return"";const o=t[1]+t[2]+t[3]+t[4],n=c.indexOf(o);return-1===n?"":t[5]?"S"+(256+n).toString(16)+(parseInt(t[5],10)-1)+(parseInt(t[6],10)-1).toString(16):"S"+(256+n).toString(16)},key2symid:e=>{const t=e.match(/^S([1-3][0-9a-f]{2})(?:([0-5])([0-9a-f]))?$/);if(!t)return"";const o=parseInt(t[1],16)-256;return o>=c.length?"":t[3]?$(c[o])+"-0"+(1+parseInt(t[2]))+"-"+(parseInt(t[3],16)+1).toString().padStart(2,"0"):$(c[o])}});const w={symbol:e=>{const n=`^(${t.symbol})(${t.coord})?(${o.full})?`,r="string"==typeof e?e.match(new RegExp(n)):void 0;return{symbol:r?r[1]:void 0,coord:r&&r[2]?g(r[2]):void 0,style:r?r[3]:void 0}},sign:e=>{const n=`^(${t.prefix})?(${t.signbox})(${o.full})?`,r="string"==typeof e?e.match(new RegExp(n)):void 0;return r?{sequence:r[1]?r[1].slice(1).match(/.{6}/g):void 0,box:r[2][0],max:g(r[2].slice(1,8)),spatials:r[2].length<9?void 0:r[2].slice(8).match(/(.{13})/g).map((e=>({symbol:e.slice(0,6),coord:[parseInt(e.slice(6,9)),parseInt(e.slice(10,13))]}))),style:r[3]}:{}},text:e=>{if("string"!=typeof e)return[];const n=`(${t.sign}(${o.full})?|${t.spatial}(${o.full})?)`,r=e.match(new RegExp(n,"g"));return r?[...r]:[]}},A={symbol:e=>{if("string"==typeof e.symbol){const n=(e.symbol.match(t.symbol)||[""])[0];if(n){return n+((((e.coord&&e.coord[0]||"").toString()+"x"+(e.coord&&e.coord[1]||"").toString()).match(t.coord)||[""])[0]||"")+("string"==typeof e.style&&(e.style.match(o.full)||[""])[0]||"")}}},sign:e=>{let n="string"!=typeof e.box?"M":(e.box+"M").match(t.box);const r=(((e.max&&e.max[0]||"").toString()+"x"+(e.max&&e.max[1]||"").toString()).match(t.coord)||[""])[0]||"";if(!r)return;let s="";e.sequence&&Array.isArray(e.sequence)&&(s=e.sequence.map((e=>(e.match(t.nullorsymbol)||[""])[0])).join(""),s=s?"A"+s:"");let i="";e.spatials&&Array.isArray(e.spatials)&&(i=e.spatials.map((e=>{if("string"==typeof e.symbol){const o=(e.symbol.match(t.symbol)||[""])[0];if(o){const n=(((e.coord&&e.coord[0]||"").toString()+"x"+(e.coord&&e.coord[1]||"").toString()).match(t.coord)||[""])[0]||"";if(n)return o+n}}return""})).join(""));return s+n+r+i+("string"==typeof e.style&&(e.style.match(o.full)||[""])[0]||"")}},S=e=>{let t,o,n,s,i,l,a,c,u=w.sign(e);u.spatials?(s=Math.min(...u.spatials.map((e=>e.coord[0]))),i=u.max[0],t=i-s,l=Math.min(...u.spatials.map((e=>e.coord[1]))),a=u.max[1],o=a-l,n="sign",c=u.box):(u=w.symbol(e),c="M",u.coord?(s=u.coord[0],t=2*(500-s),l=u.coord[1],o=2*(500-l),n="symbol"):(s=490,t=20,l=490,o=20,n="none"));let p=r(u.style),d=p.zoom||1,f=p.padding||0;return{minX:s,minY:l,width:t,height:o,segment:n,lane:{B:0,L:-1,M:0,R:1}[c],padding:f,zoom:d}},R=[{index:0,name:"UNK",value:"[UNK]"},{index:1,name:"PAD",value:"[PAD]"},{index:2,name:"CLS",value:"[CLS]"},{index:3,name:"SEP",value:"[SEP]"}],E=(e,{sequence:t=!0,signbox:o=!0,sep:n="[SEP]"}={})=>{const r=e=>[e.slice(0,4),`c${e.charAt(4)}`,`r${e.charAt(5)}`],s=e=>e.map((e=>`p${e}`));return w.text(e).map((e=>{if(/[BLMR]/.test(e)){const i=w.sign(e),l=[];return i.sequence&&t&&l.push("A",...i.sequence.map((e=>r(e))).flat()),o&&l.push(i.box,...s(i.max),...i.spatials.flatMap((e=>[...r(e.symbol),...s(e.coord)]))),n?[...l,n]:l}{const i=w.symbol(e);if(!o&&!t)return[];let l=[];return l=!o&&t?["A",...r(i.symbol)]:["M",...s(i.coord.map((e=>1e3-e))),...r(i.symbol),...s(i.coord)],l.length>0&&n?[...l,n]:l}})).flatMap((e=>e))},j=(e,t=R)=>{const o=new Set(t.map((e=>e.value)));return e.filter((e=>!o.has(e))).join(" ").replace(/\bp(\d{3})\s+p(\d{3})/g,"$1x$2").replace(/ c(\d)\d? r(.)/g,"$1$2").replace(/ c(\d)\d?/g,"$10").replace(/ r(.)/g,"0$1").replace(/ /g,"").replace(/(\d)([BLMR])/g,"$1 $2").replace(/(\d)(AS)/g,"$1 $2").replace(/(A(?:S00000|S[123][0-9a-f]{2}[0-5][0-9a-f])+)( )([BLMR])/g,"$1$3")},z={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}},I=e=>("object"!=typeof e&&(e={}),{...z,...e,punctuation:{...z.punctuation,...e.punctuation},style:{...z.style,...e.style}}),_=[256,517,759,767,877,895,903],O={all:[256,907],writing:[256,894],hand:[256,516],movement:[517,758],dynamic:[759,766],head:[767,876],hcenter:[767,876],vcenter:[767,885],trunk:[877,885],limb:[886,894],location:[895,902],punctuation:[903,907]},k=["#0000CC","#CC0000","#FF0099","#006600","#000000","#884411","#FF9900"];var C=Object.freeze({__proto__:null,re:t,parse:w,compose:A,info:S,tokenize:E,detokenize:j,createTokenizer:(e=R,t=null)=>{const o=(e=>{const t={},o={},n={},r=new Set;return e.forEach((e=>{if(r.has(e.index))throw new Error(`Duplicate token index: ${e.index}`);r.add(e.index),t[e.index]=e,o[e.name]=e,n[e.value]=e})),{byIndex:t,byName:o,byValue:n,getByIndex:o=>t[o]||t[e.find((e=>"UNK"===e.name)).index],getByName:e=>o[e]||o.UNK,getByValue:e=>n[e]||o.UNK,getAllValues:()=>e.map((e=>e.value)),getAllIndices:()=>e.map((e=>e.index))}})(e),n=t??(o.getAllIndices().length>0?Math.max(...o.getAllIndices())+1:0),r=(()=>{const e=(e,t)=>Array.from({length:t-e},((t,o)=>e+o)),t=(t,o)=>e(t,o+1).map((e=>e.toString(16)));return["A","B","L","M","R","S000",...e(256,908).map((e=>`S${e.toString(16)}`)),...t(0,15).map((e=>`r${e}`)),...t(0,5).map((e=>`c${e}`)),...e(250,750).map((e=>`p${e}`))]})(),{i2s:s,s2i:i}=((e,t,o)=>{const n={},r={};return Object.values(t.byIndex).forEach((e=>{n[e.index]=e.value,r[e.value]=e.index})),e.forEach(((e,t)=>{const s=o+t;n[s]=e,r[e]=s})),{i2s:n,s2i:r}})(r,o,n),l={i2s:s,s2i:i,specialTokens:o,length:Object.keys(s).length,vocab:()=>Object.values(s),encodeTokens:e=>e.map((e=>void 0!==i[e]?i[e]:o.getByValue(e).index)),decodeTokens:e=>e.map((e=>s[e]||o.getByName("UNK").value)),encode:(e,t={})=>{const n=E(e,{...t,sep:o.getByName("SEP").value});return l.encodeTokens(n)},decode:t=>{if(0===t.length)return"";if(Array.isArray(t[0])){const o=t.map((e=>l.decodeTokens(e)));return j(o.flat(),e)}const o=l.decodeTokens(t);return j(o,e)},chunk:(e,t)=>((e,t,{cls:o="[CLS]",sep:n="[SEP]",pad:r="[PAD]"}={})=>{if(t<60)throw new Error("Chunk size must be at least 60 tokens to accommodate a typical sign");const s=[];let i=[],l=0;for(;l<e.length;){for(i=[o];l<e.length;){e[l];let o=l;for(;o<e.length&&e[o]!==n;)o++;const r=o-l+1;if(i.length+r>t-1)break;for(;l<=o;)i.push(e[l]),l++}for(;i.length<t;)i.push(r);s.push(i)}return s})(e,t,{cls:o.getByName("CLS").value,sep:o.getByName("SEP").value,pad:o.getByName("PAD").value})};return l},columnDefaults:z,columnDefaultsMerge:I,columns:(e,t)=>{if("string"!=typeof e)return{};let o=I(t);"x"==o.style.zoom&&(o.style.zoom=1);let n=w.text(e),r=0,s=[],i=[],l=0,a=parseInt(o.width/2),c=o.height-o.margin,u=!0,p=!1;for(let e of n){let t=S(e);"x"==t.zoom&&(t.zoom=1),r+=l,o.punctuation.spacing?r+="sign"==t.segment?o.pad:0:r+=o.pad,p=r+t.height>c,p&&"symbol"==t.segment&&o.punctuation.pull&&u&&(p=!1,u=!1),0==i.length&&(p=!1),p&&(r=o.pad,s.push(i),i=[],u=!0),i.push(Object.assign(t,{x:a+o.offset*t.lane-(500-t.minX)*t.zoom*o.style.zoom,y:r,text:e})),r+=t.height*t.zoom*o.style.zoom,l=o.punctuation.spacing?"sign"==t.segment?o.pad:o.punctuation.pad:o.pad}if(i.length&&s.push(i),o.punctuation.pull)for(let e of s){let t=e[e.length-1],n=t.y+t.height-(o.height-o.margin);if(n>0){let t=parseInt(n/e.length)+1;for(let o in e)e[o].y-=t*o+t}}let d=[];for(let e of s){let t=[a-o.offset-o.pad],n=[a+o.offset+o.pad];for(let r of e)t.push(r.x-o.pad),n.push(r.x+r.width+o.pad);t=Math.min(...t),n=Math.max(...n);let r=o.width,s=0;o.dynamic?(r=n-t,s=-t):s=a-parseInt((t+n)/2);for(let t of e)t.x+=s;d.push(r)}return{options:o,widths:d,columns:s}},kind:[256,895,903],category:_,group:[256,270,286,324,332,390,420,442,461,501,517,534,554,597,613,648,678,695,725,739,759,767,778,810,827,857,877,886,895,903],ranges:O,isType:(e,t)=>{const o=w.symbol(e);if(o.symbol){const e=parseInt(o.symbol.slice(1,4),16),n=O[t];if(n)return n[0]<=e&&n[1]>=e}return!1},colors:k,colorize:e=>{const t=w.symbol(e);let o="#000000";if(t.symbol){const e=parseInt(t.symbol.slice(1,4),16),n=_.findIndex((t=>t>e));o=k[n<0?6:n-1]}return o}});let F={null:"S00000",base:"[123][0-9a-f]{2}",coord:"(?:[0-9]{3}x[0-9]{3})?",var:"V[0-9]+"};F.symbol=`S${F.base}[0-5u][0-9a-fu]`,F.nullorsymbol=`(?:${F.null}|${F.symbol})`,F.range=`R${F.base}t${F.base}`,F.item=`(?:${F.null}|${F.symbol}|${F.range})`,F.list=`${F.item}(?:o${F.item})*`,F.prefix=`(?:A(?:${F.list})+)?T`,F.signbox=`(?:${F.list}${F.coord})*`,F.full=`Q(${F.prefix})?(${F.signbox})?(${F.var})?(-?)`;const M=e=>e.match(new RegExp(`(${F.list}${F.coord})`,"g")).map((e=>{let t,o;return e.includes("x")?(t=g(e.slice(-7)),o=e.slice(0,-7)):o=e,o.includes("o")?{or:o.split("o").map((e=>e.includes("S")?e:e.slice(1).split("t"))),coord:t,coord:t}:o.includes("S")?{symbol:o,coord:t}:{range:o.slice(1).split("t"),coord:t}})),q=(e,t,o)=>{const n=o||!1;e="number"==typeof e?e.toString().padStart(3,"0"):("000"+e).slice(-3),t="number"==typeof t?t.toString().padStart(3,"0"):""+t;const r=e[0],s=e[1],i=e[2],l=t[0],a=t[1],c=t[2],u=n?"0123456789abcdef":"0123456789",p=u.indexOf(r),d=u.indexOf(l);if(p>d)throw new Error("Start is greater than end");if(r===l){const e=function(e,t,o){const n=e[0],r=e[1],s=t[0],i=t[1],l=o?"0123456789abcdef":"0123456789",a=l.indexOf(n),c=l.indexOf(s);if(a<c){const e=[`${n}${T(r,l[l.length-1],o)}`],t=l.slice(a+1,c);return t.length>0&&e.push(T(t[0],t[t.length-1],o)+(o?"[0-9a-f]":"[0-9]")),e.push(`${s}${T(l[0],i,o)}`),e.join("|")}return`${n}${T(r,i,o)}`}(s+i,a+c,n);return e.includes("|")?`${r}(?:${e})`:`${r}${e}`}{const e=[],t=function(e,t,o){const n=o?"0123456789abcdef":"0123456789",r=n[n.length-1],s=n.indexOf(e);if(t===n[0])return T(e,r,o)+(o?"[0-9a-f]":"[0-9]");{const i=T(t,r,o),l=s+1<n.length?n[s+1]:null;if(l){return e+i+"|"+T(l,r,o)+(o?"[0-9a-f]":"[0-9]")}return e+i}}(s,i,n);if(e.push(t.includes("|")?`${r}(?:${t})`:`${r}${t}`),p+1<d){const t=u.slice(p+1,d),o=T(t[0],t[t.length-1],n),r=n?"[0-9a-f]":"[0-9]";e.push(o+r+r)}const o=function(e,t,o){const n=o?"0123456789abcdef":"0123456789",r=n[0],s=n.indexOf(e);if(s>0){return T(r,n[s-1],o)+(o?"[0-9a-f]":"[0-9]")+"|"+e+T(r,t,o)}return e+T(r,t,o)}(a,c,n);return e.push(o.includes("|")?`${l}(?:${o})`:`${l}${o}`),`(?:${e.join("|")})`}};function T(e,t,o){if(e===t)return e;if(!o)return`[${e}-${t}]`;const n="0123456789abcdef",r=n.indexOf(e),s=n.indexOf(t),i=n.slice(r,s+1);if(i.includes("9")&&i.includes("a")){const e=i.match(/[0-9]+/)[0],t=i.match(/[a-f]+/)[0];return`[${e[0]}-${e.slice(-1)}${t[0]}-${t.slice(-1)}]`}return`[${i[0]}-${i.slice(-1)}]`}const D=e=>{let t=e.slice(0,4),o=e.slice(4,5);t+="u"==o?"[0-5]":o;let n=e.slice(5,6);return t+="u"==n?"[0-9a-f]":n,t},B=e=>{let t=e.slice(1,4),o=e.slice(5,8);return"S"+q(t,o,"hex")+"[0-5][0-9a-f]"},P=e=>{if(!(e=e.match(new RegExp(`^${F.full}`))[0]))return"";var n,r,s,i,l,a,c,u,p,d,f,m=20,h="(?:"+o.full+")?";if("Q"==e)return[t.prefix+"?"+t.signbox];if("Q-"==e)return[t.prefix+"?"+t.signbox+h];if("QT"==e)return[t.prefix+t.signbox];if("QT-"==e)return[t.prefix+t.signbox+h];var y=[],x=e.indexOf("T")+1;if(x){f="(?:A";var b=e.slice(0,x);if(e=e.replace(b,""),"QT"==b)f+=t.nullorsymbol+"+)";else if(n=b.match(new RegExp(F.list,"g"))){for(l=0;l<n.length;l+=1)if(i=[],r=n[l].match(new RegExp(F.item,"g"))){for(a=0;a<r.length;a+=1)(s=r[a].match(new RegExp(F.nullorsymbol)))?i.push(D(s[0])):i.push(B(r[a]));1==i.length?f+=i[0]:f+="(?:"+i.join("|")+")"}f+=t.nullorsymbol+"*)"}}if((n=e.match(new RegExp(F.var,"g")))&&(m=1*n.toString().slice(1)),n=e.match(new RegExp(F.list+F.coord,"g")))for(l=0;l<n.length;l+=1){if(i=[],r=n[l].match(new RegExp("("+F.symbol+"|"+F.range+")","g"))){for(a=0;a<r.length;a+=1)(s=r[a].match(new RegExp(F.symbol)))?i.push(D(s[0])):i.push(B(r[a]));c=1==i.length?i[0]:"(?:"+i.join("|")+")"}n[l].includes("x")?(p=(u=g(n[l].slice(-7)))[0],d=u[1],c+=q(p-m,p+m),c+="x",c+=q(d-m,d+m)):c+=t.coord,c=t.signbox+c+"(?:"+t.symbol+t.coord+")*",c=x?f+c:t.prefix+"?"+c,e.indexOf("-")>0&&(c+=h),y.push(c)}return y.length||(e.indexOf("-")>0&&(c+=h),y.push(f+t.signbox)),y};var Q=Object.freeze({__proto__:null,re:F,parse:e=>{const t="string"==typeof e?e.match(new RegExp(`^${F.full}`)):void 0;return{query:!!t||void 0,prefix:t&&t[1]?(o=t[1],{required:!0,parts:"T"==o?void 0:o.match(new RegExp(`${F.list}`,"g")).map((e=>e.includes("o")?["or"].concat(e.match(new RegExp(`(${F.item})`,"g")).map((e=>"S"==e[0]?e:e.slice(1).split("t")))):"S"==e[0]?e:e.slice(1).split("t")))}):void 0,signbox:t&&t[2]?M(t[2]):void 0,variance:t&&t[3]?parseInt(t[3].slice(1)):void 0,style:!(!t||!t[4])||void 0};var o},compose:e=>{if(!e||!e.query)return;let t="Q";return e.prefix&&e.prefix.required&&(Array.isArray(e.prefix.parts)&&(t+="A",t+=e.prefix.parts.map((e=>"string"==typeof e?e:Array.isArray(e)&&2==e.length?`R${e[0]}t${e[1]}`:Array.isArray(e)&&e.length>2&&"or"==e[0]?(e.shift(),e.map((e=>"string"==typeof e?e:Array.isArray(e)&&2==e.length?`R${e[0]}t${e[1]}`:void 0)).join("o")):void 0)).join("")),t+="T"),Array.isArray(e.signbox)&&(t+=e.signbox.map((e=>{let t;return e.or?t=e.or.map((e=>"string"==typeof e?e:Array.isArray(e)&&2==e.length?`R${e[0]}t${e[1]}`:void 0)).join("o"):e.symbol?t=e.symbol:e.range&&Array.isArray(e.range)&&2==e.range.length&&(t=`R${e.range[0]}t${e.range[1]}`),t+(Array.isArray(e.coord)&&2==e.coord.length?e.coord.join("x"):"")})).join("")),e.variance&&(t+="V"+e.variance),t+=e.style?"-":"",t=t.match(new RegExp(`^${F.full}`))[0],t},fsw2query:(e,t)=>{let o="";const n=w.sign(e);if(n.box){const e=t.indexOf("A")>-1,r=t.indexOf("a")>-1,s=t.indexOf("S")>-1,i=t.indexOf("s")>-1,l=t.indexOf("L")>-1;return(e||r||s||i)&&((e||r)&&n.sequence&&(o+="A",o+=n.sequence.map((e=>e.slice(0,4)+(r?"uu":e.slice(4,6)))).join(""),o+="T"),(s||i)&&n.spatials&&(o+=n.spatials.map((e=>e.symbol.slice(0,4)+(i?"uu":e.symbol.slice(4,6))+(l?e.coord.join("x"):""))).join(""))),o?"Q"+o:void 0}},range:q,regex:P,results:(e,t)=>{if(!t)return[];let o,n,r,s,i,l=P(e);if(!l)return[];for(i=0;i<l.length;i+=1)o=l[i],n=t.match(new RegExp(o,"g")),t=n?n.join(" "):"";return t?(r=t.split(" "),s=r.filter((function(e){return!(e in r)&&(r[e]=!0)}),{})):s=[],s},lines:(e,t)=>{if(!t)return[];let o,n,r,s,i,l=P(e);if(!l)return[];for(i=0;i<l.length;i+=1)o=l[i],o="^"+o+".*",n=t.match(new RegExp(o,"mg")),t=n?n.join("\n"):"";return t?(r=t.split("\n"),s=r.filter((function(e){return!(e in r)&&(r[e]=!0)}),{})):s=[],s}});const L={symbol:e=>{const t=`^(${a.symbol})(${a.coord})?(${o.full})?`,n="string"==typeof e?e.match(new RegExp(t)):void 0;return{symbol:n?n[1]:void 0,coord:n&&n[2]?f(n[2]):void 0,style:n?n[3]:void 0}},sign:e=>{const t=`^(${a.prefix})?(${a.signbox})(${o.full})?`,n="string"==typeof e?e.match(new RegExp(t)):void 0;return n?{sequence:n[1]?n[1].slice(2).match(/.{2}/g):void 0,box:n[2].slice(0,2),max:f(n[2].slice(2,6)),spatials:n[2].length<7?void 0:n[2].slice(6).match(/(.{6})/g).map((e=>({symbol:e.slice(0,2),coord:f(e.slice(2))}))),style:n[3]}:{}},text:e=>{if("string"!=typeof e)return[];const t=`(${a.sign}(${o.full})?|${a.spatial}(${o.full})?)`,n=e.match(new RegExp(t,"g"));return n?[...n]:[]}},N=e=>e.replace(/\\u([0-9A-F]{4})/g,(function(e,t){return String.fromCharCode(parseInt(t,16))})),U=e=>[e.charCodeAt(0).toString(16).toUpperCase(),e.charCodeAt(1).toString(16).toUpperCase()],V={symbol:e=>{if("object"==typeof e&&null!==e&&"string"==typeof e.symbol){const t=(e.symbol.match(a.symbol)||[""])[0];if(t){const n=e.coord&&e.coord[0]||"",r=e.coord&&e.coord[1]||"";return t+(n&&r?m([n,r]):"")+("string"==typeof e.style&&(e.style.match(o.full)||[""])[0]||"")}}},sign:e=>{if("object"!=typeof e||null===e)return;let t="string"!=typeof e.box?"𝠃":(e.box+"𝠃").match(a.box);const n=e.max&&e.max[0]||"",r=e.max&&e.max[1]||"",s=n&&r?m([n,r]):void 0;if(!s)return;let i="";e.sequence&&Array.isArray(e.sequence)&&(i=e.sequence.map((e=>(e.match(a.nullorsymbol)||[""])[0])).join(""),i=i?"𝠀"+i:"");let l="";e.spatials&&Array.isArray(e.spatials)&&(l=e.spatials.map((e=>{if("string"==typeof e.symbol){const t=(e.symbol.match(a.symbol)||[""])[0];if(t){const o=e.coord&&e.coord[0]||"",n=e.coord&&e.coord[1]||"",r=o&&n?m([o,n]):"";if(r)return t+r}}return""})).join(""));return i+t+s+l+("string"==typeof e.style&&(e.style.match(o.full)||[""])[0]||"")}},Z=e=>{let t,o,n,s,i,l,a,c,u=L.sign(e);u.spatials?(s=Math.min(...u.spatials.map((e=>e.coord[0]))),i=u.max[0],t=i-s,l=Math.min(...u.spatials.map((e=>e.coord[1]))),a=u.max[1],o=a-l,n="sign",c=u.box):(u=L.symbol(e),c="𝠃",u.coord?(s=u.coord[0],t=2*(500-s),l=u.coord[1],o=2*(500-l),n="symbol"):(s=490,t=20,l=490,o=20,n="none"));let p=r(u.style),d=p.zoom||1,f=p.padding||0;return{minX:s,minY:l,width:t,height:o,segment:n,lane:{"𝠁":0,"𝠂":-1,"𝠃":0,"𝠄":1}[c],padding:f,zoom:d}},K={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}},X=e=>("object"!=typeof e&&(e={}),{...K,...e,punctuation:{...K.punctuation,...e.punctuation},style:{...K.style,...e.style}}),G=[262145,287201,310433,311201,321761,323489,324257],Y={all:[262145,324736],writing:[262145,323488],hand:[262145,287200],movement:[287201,310432],dynamic:[310433,311200],head:[311201,321760],hcenter:[311201,321760],vcenter:[311201,322624],trunk:[321761,322624],limb:[322625,323488],location:[323489,324256],punctuation:[324257,324736]},H=["#0000CC","#CC0000","#FF0099","#006600","#000000","#884411","#FF9900"];var J=Object.freeze({__proto__:null,re:a,parse:L,encode:e=>e.replace(/[\u007F-\uFFFF]/g,(function(e){return"\\u"+("0000"+e.charCodeAt(0).toString(16)).substr(-4).toUpperCase()})),decode:N,pair:U,compose:V,info:Z,columnDefaults:K,columnDefaultsMerge:X,columns:(e,t)=>{if("string"!=typeof e)return{};let o=X(t);"x"==o.style.zoom&&(o.style.zoom=1);let n=L.text(e),r=0,s=[],i=[],l=0,a=parseInt(o.width/2),c=o.height-o.margin,u=!0,p=!1;for(let e of n){let t=Z(e);"x"==t.zoom&&(t.zoom=1),r+=l,o.punctuation.spacing?r+="sign"==t.segment?o.pad:0:r+=o.pad,p=r+t.height>c,p&&"symbol"==t.segment&&o.punctuation.pull&&u&&(p=!1,u=!1),0==i.length&&(p=!1),p&&(r=o.pad,s.push(i),i=[],u=!0),i.push(Object.assign(t,{x:a+o.offset*t.lane-(500-t.minX)*t.zoom*o.style.zoom,y:r,text:e})),r+=t.height*t.zoom*o.style.zoom,l=o.punctuation.spacing?"sign"==t.segment?o.pad:o.punctuation.pad:o.pad}if(i.length&&s.push(i),o.punctuation.pull)for(let e of s){let t=e[e.length-1],n=t.y+t.height-(o.height-o.margin);if(n>0){let t=parseInt(n/e.length)+1;for(let o in e)e[o].y-=t*o+t}}let d=[];for(let e of s){let t=[a-o.offset-o.pad],n=[a+o.offset+o.pad];for(let r of e)t.push(r.x-o.pad),n.push(r.x+r.width+o.pad);t=Math.min(...t),n=Math.max(...n);let r=o.width,s=0;o.dynamic?(r=n-t,s=-t):s=a-parseInt((t+n)/2);for(let t of e)t.x+=s;d.push(r)}return{options:o,widths:d,columns:s}},kind:[262145,323489,324257],category:G,group:[262145,263489,265025,268673,269441,275009,277889,280001,281825,285665,287201,288833,290753,294881,296417,299777,302657,304289,307169,308513,310433,311201,312257,315329,316961,319841,321761,322625,323489,324257],ranges:Y,isType:(e,t)=>{const o=L.symbol(e);if(o.symbol){const e=h(o.symbol),n=Y[t];if(n)return n[0]<=e&&n[1]>=e}return!1},colors:H,colorize:e=>{const t=L.symbol(e);let o="#000000";if(t.symbol){const e=h(t.symbol),n=G.findIndex((t=>t>e));o=H[n<0?6:n-1]}return o}});let W={null:"",base:"(?:(?:\ud8c0[\udc01-\udfff])|(?:[\ud8c1-\ud8fc][\udc00-\udfff])|(?:\ud8fd[\udc00-\udc80]))",coord:"(?:(?:\ud836[\udc0c-\uddff]){2})?",var:"V[0-9]+"};W.symbol=`${W.base}f?r?`,W.nullorsymbol=`(?:${W.null}|${W.symbol})`,W.range=`R${W.base}${W.base}`,W.item=`(?:${W.null}|${W.symbol}|${W.range})`,W.list=`${W.item}(?:o${W.item})*`,W.prefix=`(?:A(?:${W.list})+)?T`,W.signbox=`(?:${W.list}${W.coord})*`,W.full=`Q(${W.prefix})?(${W.signbox})?(${W.var})?(-?)`;const ee=e=>e.match(new RegExp(`(${W.list}${W.coord})`,"g")).map((e=>{let t,o;return t=e.match(new RegExp(`${a.coord}`)),t?(t=f(t[0]),o=e.slice(0,-4)):(t=void 0,o=e),o.includes("o")?{or:o.split("o").map((e=>e.includes("R")?[e.slice(1,3),e.slice(3,5)]:e)),coord:t,coord:t}:o.includes("R")?{range:[o.slice(1,3),o.slice(3,5)],coord:t}:{symbol:o,coord:t}})),te=(e,t)=>{if(e>t)return"";let o,n="",r=[];if(e=U(e),t=U(t),2!=e.length&&2!=t.length)return"";if(e[0]==t[0])e[1]==t[1]?(n="\\u"+e[0]+"\\u"+e[1],r.push(n)):(n="\\u"+e[0]+"[\\u"+e[1]+"-\\u"+t[1]+"]",r.push(n));else{n="DFFF"==e[1]?"\\u"+e[0]+"\\uDFFF":"\\u"+e[0]+"[\\u"+e[1]+"-\\uDFFF]",r.push(n);let o=parseInt(t[0],16)-parseInt(e[0],16);2==o&&(n="\\u"+(parseInt(e[0],16)+1).toString(16).toUpperCase(),n+="[\\uDC00-\\uDFFF]",r.push(n)),o>2&&(n="[",n+="\\u"+(parseInt(e[0],16)+1).toString(16).toUpperCase(),n+="-\\u"+(parseInt(t[0],16)-1).toString(16).toUpperCase(),n+="][\\uDC00-\\uDFFF]",r.push(n)),n="DC00"==t[1]?"\\u"+t[0]+"\\uDC00":"\\u"+t[0]+"[\\uDC00-\\u"+t[1]+"]",r.push(n)}return o=r.length,1==o?n=r[0]:(n=r.join(")|("),n="(("+n+"))"),N(n)},oe=e=>{let t=e.match(new RegExp(W.symbol));if(t){let e,o,n=t[0].slice(0,2),r=x(n),s=r.slice(0,4);if("fr"==t[0].slice(-2))return e=b(s+"00"),o=b(s+"5f"),te(e,o);if("r"==t[0].slice(-1))return e=b(r.slice(0,5)+"0"),o=b(r.slice(0,5)+"f"),te(e,o);if("f"==t[0].slice(-1)){return"("+[0,1,2,3,4,5].map((function(e){return b(s+e+r.slice(-1))})).join("|")+")"}return n}return""},ne=e=>{let t=x(e.slice(1,3)),o=x(e.slice(-2));return t=b(t.slice(0,4)+"00"),o=b(o.slice(0,4)+"5f"),te(t,o)},re=e=>{if(!(e=e.match(new RegExp(`^${W.full}`))[0]))return"";let t,n,r,s,i,l,c,u,p,m,g,h=20,y=a.box+a.coord+"(?:"+a.symbol+a.coord+")*",x="(?:"+a.sort+a.nullorsymbol+"+)",b="(?:"+o.full+")?";if("Q"==e)return[a.sign];if("Q-"==e)return[a.sign+"("+o.full+")?"];if("QT"==e)return[a.sortable];if("QT-"==e)return[a.sortable+"("+o.full+")?"];let $=[],v=e.indexOf("T")+1;if(v){g="(?:"+a.sort;let o=e.slice(0,v);if(e=e.replace(o,""),"QT"==o)g+=a.nullorsymbol+"+)";else if(t=o.match(new RegExp(W.list,"g")),t){for(i=0;i<t.length;i+=1)if(s=[],n=t[i].match(new RegExp(W.item,"g")),n){for(l=0;l<n.length;l+=1)r=n[l].match(new RegExp(W.range)),r?s.push(ne(n[l])):s.push(oe(n[l]));1==s.length?g+=s[0]:g+="(?:"+s.join("|")+")"}g+=a.nullorsymbol+"*)"}}if(t=e.match(new RegExp("(?:V[0-9]+)","g")),t&&(h=1*t.toString().slice(1)),t=e.match(new RegExp(W.list+W.coord,"g")),t)for(i=0;i<t.length;i+=1){if(s=[],n=t[i].match(new RegExp("("+W.range+"|"+W.symbol+")","g")),n){for(l=0;l<n.length;l+=1)r=n[l].match(new RegExp(W.range)),r?s.push(ne(n[l])):s.push(oe(n[l]));u=1==s.length?s[0]:"(?:"+s.join("|")+")"}c=t[i].match(new RegExp(`${a.coord}`)),c?(c=f(c[0]),p=c[0],m=c[1],u+=te(d(p-h),d(p+h)),u+=te(d(m-h),d(m+h))):u+=a.coord,u=y+u+"(?:"+a.symbol+a.coord+")*",u=v?g+u:x+"?"+u,e.indexOf("-")>0&&(u+=b),$.push(u)}return $.length||(e.indexOf("-")>0&&(u+=b),$.push(g+y)),$};var se=Object.freeze({__proto__:null,re:W,parse:e=>{const t="string"==typeof e?e.match(new RegExp(`^${W.full}`)):void 0;return{query:!!t||void 0,prefix:t&&t[1]?(o=t[1],{required:!0,parts:"T"==o?void 0:o.match(new RegExp(`(${W.list})`,"g")).map((e=>e.includes("o")?["or"].concat(e.match(new RegExp(`(${W.item})`,"g")).map((e=>"R"!=e[0]?e:[e.slice(1,3),e.slice(3,5)]))):"R"!=e[0]?e:[e.slice(1,3),e.slice(3,5)]))}):void 0,signbox:t&&t[2]?ee(t[2]):void 0,variance:t&&t[3]?parseInt(t[3].slice(1)):void 0,style:!(!t||!t[4])||void 0};var o},compose:e=>{if(!e||!e.query)return;let t="Q";return e.prefix&&e.prefix.required&&(Array.isArray(e.prefix.parts)&&(t+="A",t+=e.prefix.parts.map((e=>"string"==typeof e?e:Array.isArray(e)&&2==e.length?`R${e[0]}${e[1]}`:Array.isArray(e)&&e.length>2&&"or"==e[0]?(e.shift(),e.map((e=>"string"==typeof e?e:Array.isArray(e)&&2==e.length?`R${e[0]}${e[1]}`:void 0)).join("o")):void 0)).join("")),t+="T"),Array.isArray(e.signbox)&&(t+=e.signbox.map((e=>{let t;return e.or?t=e.or.map((e=>"string"==typeof e?e:Array.isArray(e)&&2==e.length?`R${e[0]}${e[1]}`:void 0)).join("o"):e.symbol?t=e.symbol:e.range&&Array.isArray(e.range)&&2==e.range.length&&(t=`R${e.range[0]}${e.range[1]}`),t+(Array.isArray(e.coord)&&2==e.coord.length?m(e.coord):"")})).join("")),e.variance&&(t+="V"+e.variance),t+=e.style?"-":"",t=t.match(new RegExp(`^${W.full}`))[0],t},swu2query:(e,t)=>{let o="";const n=L.sign(e);if(n.box){const e=t.indexOf("A")>-1,r=t.indexOf("a")>-1,s=t.indexOf("S")>-1,i=t.indexOf("s")>-1,l=t.indexOf("L")>-1;return(e||r||s||i)&&((e||r)&&n.sequence&&(o+="A",o+=n.sequence.map((e=>e+(r?"fr":""))).join(""),o+="T"),(s||i)&&n.spatials&&(o+=n.spatials.map((e=>e.symbol+(i?"fr":"")+(l?m(e.coord):""))).join(""))),o?"Q"+o:void 0}},range:te,symbolRanges:oe,regex:re,results:(e,t)=>{if(!t)return[];let o,n,r,s,i,l=re(e);if(!l)return[];for(i=0;i<l.length;i+=1)o=l[i],n=t.match(new RegExp(o,"g")),t=n?n.join(" "):"";return t?(r=t.split(" "),s=r.filter((function(e){return!(e in r)&&(r[e]=!0)}),{})):s=[],s},lines:(e,t)=>{if(!t)return[];let o,n,r,s,i,l=re(e);if(!l)return[];for(i=0;i<l.length;i+=1)o=l[i],o="^"+o+".*",n=t.match(new RegExp(o,"mg")),t=n?n.join("\n"):"";return t?(r=t.split("\n"),s=r.filter((function(e){return!(e in r)&&(r[e]=!0)}),{})):s=[],s}});e.convert=v,e.fsw=C,e.fswquery=Q,e.style=l,e.swu=J,e.swuquery=se,Object.defineProperty(e,"__esModule",{value:!0})}));