UNPKG

@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.2 kB
/* Sutton SignWriting Core Module v2.0.1 (https://github.com/sutton-signwriting/core), author: Steve Slevinski (https://SteveSlevinski.me), license: MIT */ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});let e={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]"};e.nullorsymbol=`(?:${e.null}|${e.symbol})`,e.prefix=`(?:${e.sort}${e.nullorsymbol}+)`,e.spatial=`${e.symbol}${e.coord}`,e.signbox=`${e.box}${e.coord}(?:${e.spatial})*`,e.sign=`${e.prefix}?${e.signbox}`,e.sortable=`${e.prefix}${e.signbox}`;let t={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}"};t.colorbase=`(?:${t.colorhex}|${t.colorname})`,t.color=`_${t.colorbase}_`,t.colors=`_${t.colorbase}(?:,${t.colorbase})?_`,t.background=`G${t.color}`,t.detail=`D${t.colors}`,t.detailsym=`D[0-9]{2}${t.colors}`,t.classes=`${t.classbase}(?: ${t.classbase})*`,t.full=`-(${t.colorize})?(${t.padding})?(${t.background})?(${t.detail})?(${t.zoom})?(?:-((?:${t.detailsym})*))?(?:-(${t.classes})?!(?:(${t.id})!)?)?`;const o=e=>(new RegExp(`^${t.colorhex}$`).test(e)?"#":"")+e,r=e=>{const r=`^${t.full}`,n=("string"==typeof e?e.match(new RegExp(r)):[])||[];return s={colorize:n[1]?!!n[1]:void 0,padding:n[2]?parseInt(n[2].slice(1)):void 0,background:n[3]?o(n[3].slice(2,-1)):void 0,detail:n[4]?n[4].slice(2,-1).split(",").map(o):void 0,zoom:n[5]?"Zx"===n[5]?"x":parseFloat(n[5].slice(1)):void 0,detailsym:n[6]?n[6].match(new RegExp(t.detailsym,"g")).map((e=>{const t=e.split("_"),r=t[1].split(",").map(o);return{index:parseInt(t[0].slice(1)),detail:r}})):void 0,classes:n[7]?n[7]:void 0,id:n[8]?n[8]:void 0},Object.fromEntries(Object.entries(s).filter((([e,t])=>void 0!==t)));var s},n=e=>"string"!=typeof e?[0,0,0]:e.replace(/rgba?\((.+?)\)/gi,((e,t)=>t)).split(",").map(Number),s=e=>e.slice(0,3).map((e=>e.toString(16).padStart(2,"0"))).join("");var i=Object.freeze({__proto__:null,re:t,parse:r,compose:e=>{if("object"!=typeof e||null===e)return;let o="-";o+=e.colorize?"C":"";const r=parseInt(e.padding);o+=!r||r<=0||r>99?"":"P"+(r>9?r:"0"+r);const n=e.background&&"string"==typeof e.background?e.background.match(t.colorbase)[0]:void 0;o+=n?"G_"+n+"_":"";const s=e.detail&&e.detail[0]&&"string"==typeof e.detail[0]?e.detail[0].match(t.colorbase)[0]:void 0,i=e.detail&&e.detail[1]&&"string"==typeof e.detail[1]?e.detail[1].match(t.colorbase)[0]:void 0;s&&(o+="D_"+s,i&&(o+=","+i),o+="_");const l="x"===e.zoom?"x":parseFloat(e.zoom);o+=!l||l<=0?"":"Z"+l;let a="";const c=e.detailsym&&Array.isArray(e.detailsym)?e.detailsym.map((e=>{const o=parseInt(e.index);if(!o||o<=0||o>99)return"";let r="D"+(o>9?o:"0"+o);const n=e.detail&&e.detail[0]?e.detail[0].match(t.colorbase)[0]:void 0,s=e.detail&&e.detail[1]?e.detail[1].match(t.colorbase)[0]:void 0;return n&&(r+="_"+n,s&&(r+=","+s),r+="_"),r})):[];a+=c.join("");let u="";const p=e.classes&&"string"==typeof e.classes?e.classes.match(t.classes)[0]:void 0;u+=p||"";const d=e.id&&"string"==typeof e.id?e.id.match(t.id)[0]:void 0;return u+=p||d?"!":"",u+=d?d+"!":"",o+(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,r="zoom"in t?"x"===t.zoom?1:t.zoom:1;return{...e,...t,zoom:o*r}},rgb2hex:(e,t=0)=>{const o=n(e);return 4==o.length&&o[3]<=t?"transparent":s(o)},rgba2hex:(e,t)=>{const o=n(t),r=n(e),i=4==r.length?r[3]:1;return 0==i?"transparent":s(r.map(((e,t)=>parseInt((1-i)*o[t]+i*e))))}});let l={null:"񀀀",symbol:"(?:(?:\ud8c0[\udc01-\udfff])|(?:[\ud8c1-\ud8fc][\udc00-\udfff])|(?:\ud8fd[\udc00-\udc80]))",coord:"(?:\ud836[\udc0c-\uddff]){2}",sort:"𝠀",box:"\ud836[\udc01-\udc04]"};l.nullorsymbol=`(?:${l.null}|${l.symbol})`,l.prefix=`(?:${l.sort}(?:${l.nullorsymbol})+)`,l.spatial=`${l.symbol}${l.coord}`,l.signbox=`${l.box}${l.coord}(?:${l.spatial})*`,l.sign=`${l.prefix}?${l.signbox}`,l.sortable=`${l.prefix}${l.signbox}`;const a=["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"],c=e=>({A:"𝠀",B:"𝠁",L:"𝠂",M:"𝠃",R:"𝠄"}[e]),u=e=>parseInt(e.codePointAt(0))-120844+250,p=e=>String.fromCodePoint(120844+parseInt(e)-250),d=e=>[u(e.slice(0,2)),u(e.slice(2,4))],f=e=>e.map((e=>p(e))).join(""),m=e=>e.split("x").map((e=>parseInt(e))),g=e=>parseInt(e.codePointAt(0)),h=e=>String.fromCodePoint(e),y=e=>{if("񀀀"===e)return"S00000";const t=g(e)-262145,o=parseInt(t/96),r=parseInt((t-96*o)/16),n=parseInt(t-96*o-16*r);return"S"+(o+256).toString(16)+r.toString(16)+n.toString(16)},x=e=>h("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)),b=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 $=Object.freeze({__proto__:null,swu2mark:e=>({"𝠀":"A","𝠁":"B","𝠂":"L","𝠃":"M","𝠄":"R"}[e]),mark2swu:c,swu2num:u,num2swu:p,swu2coord:d,coord2swu:f,fsw2coord:m,coord2fsw:e=>e.join("x"),swu2code:g,code2swu:h,swu2id:e=>g(e)-262144,id2swu:e=>h(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),r=parseInt((t-96*o)/16),n=parseInt(t-96*o-16*r);return"S"+(o+256).toString(16)+r.toString(16)+n.toString(16)},swu2key:y,key2swu:x,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(l.nullorsymbol,"g"));o&&o.forEach((function(e){t=t.replace(e,y(e))}));const r=t.match(new RegExp(l.coord,"g"));return r&&r.forEach((function(e){t=t.replace(e,d(e).join("x"))})),t},fsw2swu:t=>{if(!t)return"";const o=t.match(new RegExp(e.prefix,"g"));o&&o.forEach((function(e){t=t.replace(e,"𝠀"+e.slice(1).match(/.{6}/g).map((e=>x(e))).join(""))}));const r=t.match(new RegExp(e.box+e.coord,"g"));r&&r.forEach((function(e){t=t.replace(e,c(e.slice(0,1))+f(m(e.slice(1,8))))}));const n=t.match(new RegExp(e.spatial,"g"));return n&&n.forEach((function(e){t=t.replace(e,x(e.slice(0,6))+f(m(e.slice(6,13))))})),t},symidArr:a,symidMax:b,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],r=a.indexOf(o);return-1===r?"":t[5]?"S"+(256+r).toString(16)+(parseInt(t[5],10)-1)+(parseInt(t[6],10)-1).toString(16):"S"+(256+r).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>=a.length?"":t[3]?b(a[o])+"-0"+(1+parseInt(t[2]))+"-"+(parseInt(t[3],16)+1).toString().padStart(2,"0"):b(a[o])}});const v={symbol:o=>{const r=`^(${e.symbol})(${e.coord})?(${t.full})?`,n="string"==typeof o?o.match(new RegExp(r)):void 0;return{symbol:n?n[1]:void 0,coord:n&&n[2]?m(n[2]):void 0,style:n?n[3]:void 0}},sign:o=>{const r=`^(${e.prefix})?(${e.signbox})(${t.full})?`,n="string"==typeof o?o.match(new RegExp(r)):void 0;return n?{sequence:n[1]?n[1].slice(1).match(/.{6}/g):void 0,box:n[2][0],max:m(n[2].slice(1,8)),spatials:n[2].length<9?void 0:n[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:n[3]}:{}},text:o=>{if("string"!=typeof o)return[];const r=`(${e.sign}(${t.full})?|${e.spatial}(${t.full})?)`,n=o.match(new RegExp(r,"g"));return n?[...n]:[]}},A={symbol:o=>{if("string"==typeof o.symbol){const r=(o.symbol.match(e.symbol)||[""])[0];if(r){return r+((((o.coord&&o.coord[0]||"").toString()+"x"+(o.coord&&o.coord[1]||"").toString()).match(e.coord)||[""])[0]||"")+("string"==typeof o.style&&(o.style.match(t.full)||[""])[0]||"")}}},sign:o=>{let r="string"!=typeof o.box?"M":(o.box+"M").match(e.box);const n=(((o.max&&o.max[0]||"").toString()+"x"+(o.max&&o.max[1]||"").toString()).match(e.coord)||[""])[0]||"";if(!n)return;let s="";o.sequence&&Array.isArray(o.sequence)&&(s=o.sequence.map((t=>(t.match(e.nullorsymbol)||[""])[0])).join(""),s=s?"A"+s:"");let i="";o.spatials&&Array.isArray(o.spatials)&&(i=o.spatials.map((t=>{if("string"==typeof t.symbol){const o=(t.symbol.match(e.symbol)||[""])[0];if(o){const r=(((t.coord&&t.coord[0]||"").toString()+"x"+(t.coord&&t.coord[1]||"").toString()).match(e.coord)||[""])[0]||"";if(r)return o+r}}return""})).join(""));return s+r+n+i+("string"==typeof o.style&&(o.style.match(t.full)||[""])[0]||"")}},w=e=>{let t,o,n,s,i,l,a,c,u=v.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=v.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}},S=[{index:0,name:"UNK",value:"[UNK]"},{index:1,name:"PAD",value:"[PAD]"},{index:2,name:"CLS",value:"[CLS]"},{index:3,name:"SEP",value:"[SEP]"}],R=(e,{sequence:t=!0,signbox:o=!0,sep:r="[SEP]"}={})=>{const n=e=>[e.slice(0,4),`c${e.charAt(4)}`,`r${e.charAt(5)}`],s=e=>e.map((e=>`p${e}`));return v.text(e).map((e=>{if(/[BLMR]/.test(e)){const i=v.sign(e),l=[];return i.sequence&&t&&l.push("A",...i.sequence.map((e=>n(e))).flat()),o&&l.push(i.box,...s(i.max),...i.spatials.flatMap((e=>[...n(e.symbol),...s(e.coord)]))),r?[...l,r]:l}{const i=v.symbol(e);if(!o&&!t)return[];let l=[];return l=!o&&t?["A",...n(i.symbol)]:["M",...s(i.coord.map((e=>1e3-e))),...n(i.symbol),...s(i.coord)],l.length>0&&r?[...l,r]:l}})).flatMap((e=>e))},E=(e,t=S)=>{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")},j={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}},z=e=>("object"!=typeof e&&(e={}),{...j,...e,punctuation:{...j.punctuation,...e.punctuation},style:{...j.style,...e.style}}),I=[256,517,759,767,877,895,903],_={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]},O=["#0000CC","#CC0000","#FF0099","#006600","#000000","#884411","#FF9900"];var k=Object.freeze({__proto__:null,re:e,parse:v,compose:A,info:w,tokenize:R,detokenize:E,createTokenizer:(e=S,t=null)=>{const o=(e=>{const t={},o={},r={},n=new Set;return e.forEach((e=>{if(n.has(e.index))throw new Error(`Duplicate token index: ${e.index}`);n.add(e.index),t[e.index]=e,o[e.name]=e,r[e.value]=e})),{byIndex:t,byName:o,byValue:r,getByIndex:o=>t[o]||t[e.find((e=>"UNK"===e.name)).index],getByName:e=>o[e]||o.UNK,getByValue:e=>r[e]||o.UNK,getAllValues:()=>e.map((e=>e.value)),getAllIndices:()=>e.map((e=>e.index))}})(e),r=t??(o.getAllIndices().length>0?Math.max(...o.getAllIndices())+1:0),n=(()=>{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 r={},n={};return Object.values(t.byIndex).forEach((e=>{r[e.index]=e.value,n[e.value]=e.index})),e.forEach(((e,t)=>{const s=o+t;r[s]=e,n[e]=s})),{i2s:r,s2i:n}})(n,o,r),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 r=R(e,{...t,sep:o.getByName("SEP").value});return l.encodeTokens(r)},decode:t=>{if(0===t.length)return"";if(Array.isArray(t[0])){const o=t.map((e=>l.decodeTokens(e)));return E(o.flat(),e)}const o=l.decodeTokens(t);return E(o,e)},chunk:(e,t)=>((e,t,{cls:o="[CLS]",sep:r="[SEP]",pad:n="[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]!==r;)o++;const n=o-l+1;if(i.length+n>t-1)break;for(;l<=o;)i.push(e[l]),l++}for(;i.length<t;)i.push(n);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:j,columnDefaultsMerge:z,columns:(e,t)=>{if("string"!=typeof e)return{};let o=z(t);"x"==o.style.zoom&&(o.style.zoom=1);let r=v.text(e),n=0,s=[],i=[],l=0,a=parseInt(o.width/2),c=o.height-o.margin,u=!0,p=!1;for(let e of r){let t=w(e);"x"==t.zoom&&(t.zoom=1),n+=l,o.punctuation.spacing?n+="sign"==t.segment?o.pad:0:n+=o.pad,p=n+t.height>c,p&&"symbol"==t.segment&&o.punctuation.pull&&u&&(p=!1,u=!1),0==i.length&&(p=!1),p&&(n=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:n,text:e})),n+=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],r=t.y+t.height-(o.height-o.margin);if(r>0){let t=parseInt(r/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],r=[a+o.offset+o.pad];for(let n of e)t.push(n.x-o.pad),r.push(n.x+n.width+o.pad);t=Math.min(...t),r=Math.max(...r);let n=o.width,s=0;o.dynamic?(n=r-t,s=-t):s=a-parseInt((t+r)/2);for(let t of e)t.x+=s;d.push(n)}return{options:o,widths:d,columns:s}},kind:[256,895,903],category:I,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:_,isType:(e,t)=>{const o=v.symbol(e);if(o.symbol){const e=parseInt(o.symbol.slice(1,4),16),r=_[t];if(r)return r[0]<=e&&r[1]>=e}return!1},colors:O,colorize:e=>{const t=v.symbol(e);let o="#000000";if(t.symbol){const e=parseInt(t.symbol.slice(1,4),16),r=I.findIndex((t=>t>e));o=O[r<0?6:r-1]}return o}});let C={null:"S00000",base:"[123][0-9a-f]{2}",coord:"(?:[0-9]{3}x[0-9]{3})?",var:"V[0-9]+"};C.symbol=`S${C.base}[0-5u][0-9a-fu]`,C.nullorsymbol=`(?:${C.null}|${C.symbol})`,C.range=`R${C.base}t${C.base}`,C.item=`(?:${C.null}|${C.symbol}|${C.range})`,C.list=`${C.item}(?:o${C.item})*`,C.prefix=`(?:A(?:${C.list})+)?T`,C.signbox=`(?:${C.list}${C.coord})*`,C.full=`Q(${C.prefix})?(${C.signbox})?(${C.var})?(-?)`;const F=e=>e.match(new RegExp(`(${C.list}${C.coord})`,"g")).map((e=>{let t,o;return e.includes("x")?(t=m(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}})),M=(e,t,o)=>{const r=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 n=e[0],s=e[1],i=e[2],l=t[0],a=t[1],c=t[2],u=r?"0123456789abcdef":"0123456789",p=u.indexOf(n),d=u.indexOf(l);if(p>d)throw new Error("Start is greater than end");if(n===l){const e=function(e,t,o){const r=e[0],n=e[1],s=t[0],i=t[1],l=o?"0123456789abcdef":"0123456789",a=l.indexOf(r),c=l.indexOf(s);if(a<c){const e=[`${r}${q(n,l[l.length-1],o)}`],t=l.slice(a+1,c);return t.length>0&&e.push(q(t[0],t[t.length-1],o)+(o?"[0-9a-f]":"[0-9]")),e.push(`${s}${q(l[0],i,o)}`),e.join("|")}return`${r}${q(n,i,o)}`}(s+i,a+c,r);return e.includes("|")?`${n}(?:${e})`:`${n}${e}`}{const e=[],t=function(e,t,o){const r=o?"0123456789abcdef":"0123456789",n=r[r.length-1],s=r.indexOf(e);if(t===r[0])return q(e,n,o)+(o?"[0-9a-f]":"[0-9]");{const i=q(t,n,o),l=s+1<r.length?r[s+1]:null;if(l){return e+i+"|"+q(l,n,o)+(o?"[0-9a-f]":"[0-9]")}return e+i}}(s,i,r);if(e.push(t.includes("|")?`${n}(?:${t})`:`${n}${t}`),p+1<d){const t=u.slice(p+1,d),o=q(t[0],t[t.length-1],r),n=r?"[0-9a-f]":"[0-9]";e.push(o+n+n)}const o=function(e,t,o){const r=o?"0123456789abcdef":"0123456789",n=r[0],s=r.indexOf(e);if(s>0){return q(n,r[s-1],o)+(o?"[0-9a-f]":"[0-9]")+"|"+e+q(n,t,o)}return e+q(n,t,o)}(a,c,r);return e.push(o.includes("|")?`${l}(?:${o})`:`${l}${o}`),`(?:${e.join("|")})`}};function q(e,t,o){if(e===t)return e;if(!o)return`[${e}-${t}]`;const r="0123456789abcdef",n=r.indexOf(e),s=r.indexOf(t),i=r.slice(n,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 T=e=>{let t=e.slice(0,4),o=e.slice(4,5);t+="u"==o?"[0-5]":o;let r=e.slice(5,6);return t+="u"==r?"[0-9a-f]":r,t},D=e=>{let t=e.slice(1,4),o=e.slice(5,8);return"S"+M(t,o,"hex")+"[0-5][0-9a-f]"},B=o=>{if(!(o=o.match(new RegExp(`^${C.full}`))[0]))return"";var r,n,s,i,l,a,c,u,p,d,f,g=20,h="(?:"+t.full+")?";if("Q"==o)return[e.prefix+"?"+e.signbox];if("Q-"==o)return[e.prefix+"?"+e.signbox+h];if("QT"==o)return[e.prefix+e.signbox];if("QT-"==o)return[e.prefix+e.signbox+h];var y=[],x=o.indexOf("T")+1;if(x){f="(?:A";var b=o.slice(0,x);if(o=o.replace(b,""),"QT"==b)f+=e.nullorsymbol+"+)";else if(r=b.match(new RegExp(C.list,"g"))){for(l=0;l<r.length;l+=1)if(i=[],n=r[l].match(new RegExp(C.item,"g"))){for(a=0;a<n.length;a+=1)(s=n[a].match(new RegExp(C.nullorsymbol)))?i.push(T(s[0])):i.push(D(n[a]));1==i.length?f+=i[0]:f+="(?:"+i.join("|")+")"}f+=e.nullorsymbol+"*)"}}if((r=o.match(new RegExp(C.var,"g")))&&(g=1*r.toString().slice(1)),r=o.match(new RegExp(C.list+C.coord,"g")))for(l=0;l<r.length;l+=1){if(i=[],n=r[l].match(new RegExp("("+C.symbol+"|"+C.range+")","g"))){for(a=0;a<n.length;a+=1)(s=n[a].match(new RegExp(C.symbol)))?i.push(T(s[0])):i.push(D(n[a]));c=1==i.length?i[0]:"(?:"+i.join("|")+")"}r[l].includes("x")?(p=(u=m(r[l].slice(-7)))[0],d=u[1],c+=M(p-g,p+g),c+="x",c+=M(d-g,d+g)):c+=e.coord,c=e.signbox+c+"(?:"+e.symbol+e.coord+")*",c=x?f+c:e.prefix+"?"+c,o.indexOf("-")>0&&(c+=h),y.push(c)}return y.length||(o.indexOf("-")>0&&(c+=h),y.push(f+e.signbox)),y};var P=Object.freeze({__proto__:null,re:C,parse:e=>{const t="string"==typeof e?e.match(new RegExp(`^${C.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(`${C.list}`,"g")).map((e=>e.includes("o")?["or"].concat(e.match(new RegExp(`(${C.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]?F(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(`^${C.full}`))[0],t},fsw2query:(e,t)=>{let o="";const r=v.sign(e);if(r.box){const e=t.indexOf("A")>-1,n=t.indexOf("a")>-1,s=t.indexOf("S")>-1,i=t.indexOf("s")>-1,l=t.indexOf("L")>-1;return(e||n||s||i)&&((e||n)&&r.sequence&&(o+="A",o+=r.sequence.map((e=>e.slice(0,4)+(n?"uu":e.slice(4,6)))).join(""),o+="T"),(s||i)&&r.spatials&&(o+=r.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:M,regex:B,results:(e,t)=>{if(!t)return[];let o,r,n,s,i,l=B(e);if(!l)return[];for(i=0;i<l.length;i+=1)o=l[i],r=t.match(new RegExp(o,"g")),t=r?r.join(" "):"";return t?(n=t.split(" "),s=n.filter((function(e){return!(e in n)&&(n[e]=!0)}),{})):s=[],s},lines:(e,t)=>{if(!t)return[];let o,r,n,s,i,l=B(e);if(!l)return[];for(i=0;i<l.length;i+=1)o=l[i],o="^"+o+".*",r=t.match(new RegExp(o,"mg")),t=r?r.join("\n"):"";return t?(n=t.split("\n"),s=n.filter((function(e){return!(e in n)&&(n[e]=!0)}),{})):s=[],s}});const Q={symbol:e=>{const o=`^(${l.symbol})(${l.coord})?(${t.full})?`,r="string"==typeof e?e.match(new RegExp(o)):void 0;return{symbol:r?r[1]:void 0,coord:r&&r[2]?d(r[2]):void 0,style:r?r[3]:void 0}},sign:e=>{const o=`^(${l.prefix})?(${l.signbox})(${t.full})?`,r="string"==typeof e?e.match(new RegExp(o)):void 0;return r?{sequence:r[1]?r[1].slice(2).match(/.{2}/g):void 0,box:r[2].slice(0,2),max:d(r[2].slice(2,6)),spatials:r[2].length<7?void 0:r[2].slice(6).match(/(.{6})/g).map((e=>({symbol:e.slice(0,2),coord:d(e.slice(2))}))),style:r[3]}:{}},text:e=>{if("string"!=typeof e)return[];const o=`(${l.sign}(${t.full})?|${l.spatial}(${t.full})?)`,r=e.match(new RegExp(o,"g"));return r?[...r]:[]}},L=e=>e.replace(/\\u([0-9A-F]{4})/g,(function(e,t){return String.fromCharCode(parseInt(t,16))})),N=e=>[e.charCodeAt(0).toString(16).toUpperCase(),e.charCodeAt(1).toString(16).toUpperCase()],U={symbol:e=>{if("object"==typeof e&&null!==e&&"string"==typeof e.symbol){const o=(e.symbol.match(l.symbol)||[""])[0];if(o){const r=e.coord&&e.coord[0]||"",n=e.coord&&e.coord[1]||"";return o+(r&&n?f([r,n]):"")+("string"==typeof e.style&&(e.style.match(t.full)||[""])[0]||"")}}},sign:e=>{if("object"!=typeof e||null===e)return;let o="string"!=typeof e.box?"𝠃":(e.box+"𝠃").match(l.box);const r=e.max&&e.max[0]||"",n=e.max&&e.max[1]||"",s=r&&n?f([r,n]):void 0;if(!s)return;let i="";e.sequence&&Array.isArray(e.sequence)&&(i=e.sequence.map((e=>(e.match(l.nullorsymbol)||[""])[0])).join(""),i=i?"𝠀"+i:"");let a="";e.spatials&&Array.isArray(e.spatials)&&(a=e.spatials.map((e=>{if("string"==typeof e.symbol){const t=(e.symbol.match(l.symbol)||[""])[0];if(t){const o=e.coord&&e.coord[0]||"",r=e.coord&&e.coord[1]||"",n=o&&r?f([o,r]):"";if(n)return t+n}}return""})).join(""));return i+o+s+a+("string"==typeof e.style&&(e.style.match(t.full)||[""])[0]||"")}},V=e=>{let t,o,n,s,i,l,a,c,u=Q.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=Q.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}},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}},K=e=>("object"!=typeof e&&(e={}),{...Z,...e,punctuation:{...Z.punctuation,...e.punctuation},style:{...Z.style,...e.style}}),X=[262145,287201,310433,311201,321761,323489,324257],G={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]},Y=["#0000CC","#CC0000","#FF0099","#006600","#000000","#884411","#FF9900"];var H=Object.freeze({__proto__:null,re:l,parse:Q,encode:e=>e.replace(/[\u007F-\uFFFF]/g,(function(e){return"\\u"+("0000"+e.charCodeAt(0).toString(16)).substr(-4).toUpperCase()})),decode:L,pair:N,compose:U,info:V,columnDefaults:Z,columnDefaultsMerge:K,columns:(e,t)=>{if("string"!=typeof e)return{};let o=K(t);"x"==o.style.zoom&&(o.style.zoom=1);let r=Q.text(e),n=0,s=[],i=[],l=0,a=parseInt(o.width/2),c=o.height-o.margin,u=!0,p=!1;for(let e of r){let t=V(e);"x"==t.zoom&&(t.zoom=1),n+=l,o.punctuation.spacing?n+="sign"==t.segment?o.pad:0:n+=o.pad,p=n+t.height>c,p&&"symbol"==t.segment&&o.punctuation.pull&&u&&(p=!1,u=!1),0==i.length&&(p=!1),p&&(n=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:n,text:e})),n+=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],r=t.y+t.height-(o.height-o.margin);if(r>0){let t=parseInt(r/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],r=[a+o.offset+o.pad];for(let n of e)t.push(n.x-o.pad),r.push(n.x+n.width+o.pad);t=Math.min(...t),r=Math.max(...r);let n=o.width,s=0;o.dynamic?(n=r-t,s=-t):s=a-parseInt((t+r)/2);for(let t of e)t.x+=s;d.push(n)}return{options:o,widths:d,columns:s}},kind:[262145,323489,324257],category:X,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:G,isType:(e,t)=>{const o=Q.symbol(e);if(o.symbol){const e=g(o.symbol),r=G[t];if(r)return r[0]<=e&&r[1]>=e}return!1},colors:Y,colorize:e=>{const t=Q.symbol(e);let o="#000000";if(t.symbol){const e=g(t.symbol),r=X.findIndex((t=>t>e));o=Y[r<0?6:r-1]}return o}});let J={null:"񀀀",base:"(?:(?:\ud8c0[\udc01-\udfff])|(?:[\ud8c1-\ud8fc][\udc00-\udfff])|(?:\ud8fd[\udc00-\udc80]))",coord:"(?:(?:\ud836[\udc0c-\uddff]){2})?",var:"V[0-9]+"};J.symbol=`${J.base}f?r?`,J.nullorsymbol=`(?:${J.null}|${J.symbol})`,J.range=`R${J.base}${J.base}`,J.item=`(?:${J.null}|${J.symbol}|${J.range})`,J.list=`${J.item}(?:o${J.item})*`,J.prefix=`(?:A(?:${J.list})+)?T`,J.signbox=`(?:${J.list}${J.coord})*`,J.full=`Q(${J.prefix})?(${J.signbox})?(${J.var})?(-?)`;const W=e=>e.match(new RegExp(`(${J.list}${J.coord})`,"g")).map((e=>{let t,o;return t=e.match(new RegExp(`${l.coord}`)),t?(t=d(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}})),ee=(e,t)=>{if(e>t)return"";let o,r="",n=[];if(e=N(e),t=N(t),2!=e.length&&2!=t.length)return"";if(e[0]==t[0])e[1]==t[1]?(r="\\u"+e[0]+"\\u"+e[1],n.push(r)):(r="\\u"+e[0]+"[\\u"+e[1]+"-\\u"+t[1]+"]",n.push(r));else{r="DFFF"==e[1]?"\\u"+e[0]+"\\uDFFF":"\\u"+e[0]+"[\\u"+e[1]+"-\\uDFFF]",n.push(r);let o=parseInt(t[0],16)-parseInt(e[0],16);2==o&&(r="\\u"+(parseInt(e[0],16)+1).toString(16).toUpperCase(),r+="[\\uDC00-\\uDFFF]",n.push(r)),o>2&&(r="[",r+="\\u"+(parseInt(e[0],16)+1).toString(16).toUpperCase(),r+="-\\u"+(parseInt(t[0],16)-1).toString(16).toUpperCase(),r+="][\\uDC00-\\uDFFF]",n.push(r)),r="DC00"==t[1]?"\\u"+t[0]+"\\uDC00":"\\u"+t[0]+"[\\uDC00-\\u"+t[1]+"]",n.push(r)}return o=n.length,1==o?r=n[0]:(r=n.join(")|("),r="(("+r+"))"),L(r)},te=e=>{let t=e.match(new RegExp(J.symbol));if(t){let e,o,r=t[0].slice(0,2),n=y(r),s=n.slice(0,4);if("fr"==t[0].slice(-2))return e=x(s+"00"),o=x(s+"5f"),ee(e,o);if("r"==t[0].slice(-1))return e=x(n.slice(0,5)+"0"),o=x(n.slice(0,5)+"f"),ee(e,o);if("f"==t[0].slice(-1)){return"("+[0,1,2,3,4,5].map((function(e){return x(s+e+n.slice(-1))})).join("|")+")"}return r}return""},oe=e=>{let t=y(e.slice(1,3)),o=y(e.slice(-2));return t=x(t.slice(0,4)+"00"),o=x(o.slice(0,4)+"5f"),ee(t,o)},re=e=>{if(!(e=e.match(new RegExp(`^${J.full}`))[0]))return"";let o,r,n,s,i,a,c,u,f,m,g,h=20,y=l.box+l.coord+"(?:"+l.symbol+l.coord+")*",x="(?:"+l.sort+l.nullorsymbol+"+)",b="(?:"+t.full+")?";if("Q"==e)return[l.sign];if("Q-"==e)return[l.sign+"("+t.full+")?"];if("QT"==e)return[l.sortable];if("QT-"==e)return[l.sortable+"("+t.full+")?"];let $=[],v=e.indexOf("T")+1;if(v){g="(?:"+l.sort;let t=e.slice(0,v);if(e=e.replace(t,""),"QT"==t)g+=l.nullorsymbol+"+)";else if(o=t.match(new RegExp(J.list,"g")),o){for(i=0;i<o.length;i+=1)if(s=[],r=o[i].match(new RegExp(J.item,"g")),r){for(a=0;a<r.length;a+=1)n=r[a].match(new RegExp(J.range)),n?s.push(oe(r[a])):s.push(te(r[a]));1==s.length?g+=s[0]:g+="(?:"+s.join("|")+")"}g+=l.nullorsymbol+"*)"}}if(o=e.match(new RegExp("(?:V[0-9]+)","g")),o&&(h=1*o.toString().slice(1)),o=e.match(new RegExp(J.list+J.coord,"g")),o)for(i=0;i<o.length;i+=1){if(s=[],r=o[i].match(new RegExp("("+J.range+"|"+J.symbol+")","g")),r){for(a=0;a<r.length;a+=1)n=r[a].match(new RegExp(J.range)),n?s.push(oe(r[a])):s.push(te(r[a]));u=1==s.length?s[0]:"(?:"+s.join("|")+")"}c=o[i].match(new RegExp(`${l.coord}`)),c?(c=d(c[0]),f=c[0],m=c[1],u+=ee(p(f-h),p(f+h)),u+=ee(p(m-h),p(m+h))):u+=l.coord,u=y+u+"(?:"+l.symbol+l.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 ne=Object.freeze({__proto__:null,re:J,parse:e=>{const t="string"==typeof e?e.match(new RegExp(`^${J.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(`(${J.list})`,"g")).map((e=>e.includes("o")?["or"].concat(e.match(new RegExp(`(${J.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]?W(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?f(e.coord):"")})).join("")),e.variance&&(t+="V"+e.variance),t+=e.style?"-":"",t=t.match(new RegExp(`^${J.full}`))[0],t},swu2query:(e,t)=>{let o="";const r=Q.sign(e);if(r.box){const e=t.indexOf("A")>-1,n=t.indexOf("a")>-1,s=t.indexOf("S")>-1,i=t.indexOf("s")>-1,l=t.indexOf("L")>-1;return(e||n||s||i)&&((e||n)&&r.sequence&&(o+="A",o+=r.sequence.map((e=>e+(n?"fr":""))).join(""),o+="T"),(s||i)&&r.spatials&&(o+=r.spatials.map((e=>e.symbol+(i?"fr":"")+(l?f(e.coord):""))).join(""))),o?"Q"+o:void 0}},range:ee,symbolRanges:te,regex:re,results:(e,t)=>{if(!t)return[];let o,r,n,s,i,l=re(e);if(!l)return[];for(i=0;i<l.length;i+=1)o=l[i],r=t.match(new RegExp(o,"g")),t=r?r.join(" "):"";return t?(n=t.split(" "),s=n.filter((function(e){return!(e in n)&&(n[e]=!0)}),{})):s=[],s},lines:(e,t)=>{if(!t)return[];let o,r,n,s,i,l=re(e);if(!l)return[];for(i=0;i<l.length;i+=1)o=l[i],o="^"+o+".*",r=t.match(new RegExp(o,"mg")),t=r?r.join("\n"):"";return t?(n=t.split("\n"),s=n.filter((function(e){return!(e in n)&&(n[e]=!0)}),{})):s=[],s}});exports.convert=$,exports.fsw=k,exports.fswquery=P,exports.style=i,exports.swu=H,exports.swuquery=ne;