@pubann/textae 14.3.1 → 14.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -40965,7 +40965,7 @@ var __webpack_exports__ = {};
40965
40965
  "use strict";
40966
40966
 
40967
40967
  ;// ./package.json
40968
- const package_namespaceObject = {"rE":"14.3.1"};
40968
+ const package_namespaceObject = {"rE":"14.3.2"};
40969
40969
  // EXTERNAL MODULE: ./node_modules/alertifyjs/build/alertify.js
40970
40970
  var alertify = __webpack_require__(3053);
40971
40971
  var alertify_default = /*#__PURE__*/__webpack_require__.n(alertify);
@@ -43920,7 +43920,7 @@ function getForwardMatchID(typeIds, id) {
43920
43920
 
43921
43921
 
43922
43922
  class DefinedTypeContainer {
43923
- /** @type {Array} **/
43923
+ /** @type {Array<DefinedType>} */
43924
43924
  #types
43925
43925
 
43926
43926
  // Expected values is an array of object.
@@ -44115,7 +44115,7 @@ class DefinitionContainer {
44115
44115
  }
44116
44116
 
44117
44117
  get(id) {
44118
- const type = { ...this.#definedTypes.map.get(id) }
44118
+ const type = this.#definedTypes.map.get(id).toJSON()
44119
44119
 
44120
44120
  if (this.#defaultType === id) {
44121
44121
  type.default = true
@@ -171,7 +171,7 @@ var i,n=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?
171
171
  * Copyright OpenJS Foundation and other contributors
172
172
  * Released under the MIT license.
173
173
  * https://jquery.org/license
174
- */!function(){"use strict";o=[i(4692),i(6883)],void 0===(s="function"==typeof(n=function(t){return t.extend(t.expr.pseudos,{data:t.expr.createPseudo(function(e){return function(i){return!!t.data(i,e)}})})})?n.apply(e,o):n)||(t.exports=s)}()}},e={};function i(n){var o=e[n];if(void 0!==o)return o.exports;var s=e[n]={exports:{}};return t[n].call(s.exports,s,s.exports,i),s.exports}i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},i.d=(t,e)=>{for(var n in e)i.o(e,n)&&!i.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{"use strict";const t="14.3.1";var e=i(3053),n=i.n(e);class o{constructor(t){this._editor=t}set annotation(t){this._editor.load(t)}set inspectCallback(t){this._editor.setInspector(t)}set lastSelectedDenotationIDCallback(t){this._editor.setLastSelectedDenotationIDCallback(t)}set autocompletionCallback(t){this._editor.setAutocompletionFunction(t)}get id(){return this._editor.HTMLElementID}focusDenotation(t){this._editor.focusDenotation(t)}selectDenotation(t){this._editor.selectDenotation(t)}}var s=i(5408),r=i.n(s);function a(t,e=100,i={}){if("function"!=typeof t)throw new TypeError(`Expected the first parameter to be a function, got \`${typeof t}\`.`);if(e<0)throw new RangeError("`wait` must not be negative.");if("boolean"==typeof i)throw new TypeError("The `options` parameter must be an object, not a boolean. Use `{immediate: true}` instead.");const{immediate:n}=i;let o,s,r,a,l;function c(){const e=o,i=s;return o=void 0,s=void 0,l=t.apply(e,i),l}function h(){const t=Date.now()-a;t<e&&t>=0?r=setTimeout(h,e-t):(r=void 0,n||(l=c()))}const u=function(...t){if(o&&this!==o&&Object.getPrototypeOf(this)===Object.getPrototypeOf(o))throw new Error("Debounced method called with different contexts of the same prototype.");o=this,s=t,a=Date.now();const i=n&&!r;if(r||(r=setTimeout(h,e)),i)return l=c(),l};return Object.defineProperty(u,"isPending",{get:()=>void 0!==r}),u.clear=()=>{r&&(clearTimeout(r),r=void 0,o=void 0,s=void 0)},u.flush=()=>{r&&u.trigger()},u.trigger=()=>{l=c(),u.clear()},u}var l=i(7512),c=i.n(l),h=(i(1193),i(5385)),u=i.n(h),d=i(4692),f=i.n(d);class p{constructor(t,e,i={}){this._el=u().create(`\n <div title="${t}">\n ${e}\n </div>\n `),this._$dialog=f()(this._el),this._$dialog.on("dialogclose",()=>{requestAnimationFrame(()=>this._$dialog.dialog("destroy"))}),this._option=i}get el(){return this._el}get button(){return this._$dialog.dialog("widget")[0].querySelector(".ui-dialog-buttonpane button")}open(){this._$dialog.dialog({classes:{"ui-dialog":"textae-editor__dialog"},height:"auto",modal:!0,resizable:!1,width:"calc(100% - 10px)",create:t=>{f()(t.target.parentElement).css("maxWidth",`${this._option.maxWidth||550}px`)},...this._option})}close(){this._$dialog.dialog("close")}}class m extends p{constructor(){super("Help (Keyboard short-cuts)",'<div class="textae-tool__key-help"></div>\n <ul>\n <li>\n cut\n : Ctrl+x\n </li>\n <li>\n copy\n : Ctrl+c\n </li>\n <li>\n paste\n : Ctrl+v\n </li>\n </ul>\n ',{maxWidth:523})}}function g(t){return t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement}const v=new m,y=new class extends p{constructor(){super("For security reason, the shortcut keys for cut/copy/paste are changed as follows:",'<table class="textae-editor__tips-dialog__table">\n <thead>\n <tr><th></th><th>before</th><th>after</th></tr>\n </thead>\n <tbody>\n <tr><td>cut</td><td>x</td><td>Ctrl-x</td></tr>\n <tr><td>copy</td><td>c</td><td>Ctrl-c</td></tr>\n <tr><td>paste</td><td>v</td><td>Ctrl-v</td></tr>\n </tbody>\n </table>\n ',{maxWidth:785})}};class O{#t;#e;#i;constructor(){this.#t=new Map,this.#e=null,this.#i=0,c()(window,".textae-editor","keyup",t=>{if(this.selected)switch(t.key){case"h":v.open();break;case"c":case"x":case"v":t.ctrlKey||t.metaKey||y.open()}}),this.#n()}set(t,e){this.#t.set(t,e),this.#i++}remove(t){this.#t.get(t).dispose(),this.#t.delete(t),this.selected===t&&(this.#e=null)}get selected(){return this.#e}set selected(t){null===t?(this.#o.deactivate(),this.#e=null):(this.#e=t,this.#o.activate())}drawGridsInSight(){for(const t of this.#t.values())t.drawGridsInSight()}updateDenotationEntitiesWidth(){for(const t of this.#t.values())t.updateDenotationEntitiesWidth()}reLayout(){for(const t of this.#t.values())t.reLayout()}has(t){return this.#t.has(t)}get nextID(){return`editor${this.#i}`}#n(){document.addEventListener("scroll",r()(()=>{this.drawGridsInSight()},300)),document.addEventListener("copy",t=>{g(t.target)||this.selected&&this.#t.get(this.selected).copyEntitiesToSystemClipboard(t)}),document.addEventListener("cut",t=>{g(t.target)||this.selected&&this.#t.get(this.selected).cutEntitiesToSystemClipboard(t)}),document.addEventListener("paste",t=>{g(t.target)||this.selected&&this.#t.get(this.selected).pasteEntitiesFromSystemClipboard(t)}),document.addEventListener("selectionchange",a(()=>{this.selected&&this.#t.get(this.selected).applyTextSelectionWithTouchDevice()},100)),document.addEventListener("contextmenu",()=>{this.selected&&this.#t.get(this.selected).applyTextSelectionWithTouchDevice()}),document.addEventListener("click",t=>{if(3!==t.which)for(const t of this.#t.values())t.hideContextMenu()}),document.addEventListener("contextmenu",t=>{for(const t of this.#t.values())t.hideContextMenu();const e=t.target.closest(".textae-editor");if(e===this.#e){if(e.classList.contains("textae-editor__mode--view-with-relation")||e.classList.contains("textae-editor__mode--view-without-relation"))return;t.preventDefault(),this.#o.showContextMenu(t)}})}get#o(){return this.#t.get(this.#e)}}const b={};document.querySelector("html").addEventListener("mousemove",t=>{b.clientY=t.clientY,b.pageY=t.pageY,b.clientX=t.clientX});const x={attributes:!0,attributeFilter:["class"]};class w{#s;#r;constructor(){this.#s=new Set}setObserver(t){this.#r||(this.#r=u().create('<div class="textae-editor-veil" style="display: none;"></div>'),document.body.appendChild(this.#r)),new MutationObserver(t=>this._mutationCallback(t)).observe(t,x)}_mutationCallback(t){this._collectWaitingEditors(t),this.#s.size>0?this._show():this._hide()}_collectWaitingEditors(t){t.forEach(({target:t})=>{t.classList.contains("textae-editor--wait")?this.#s.add(t):this.#s.delete(t)})}_show(){this.#r.style.display="block"}_hide(){this.#r.style.display="none"}}var _=i(7007);class S{constructor(t,e){this.valueType=t,this.pred=e}get values(){return console.assert(this._values,"this._values to return!"),this._values}get externalFormat(){return{pred:this.pred}}get _valuesClone(){if(console.assert(this._values,"this._values is necessary to clone!"),Array.isArray(this._values)&&0===this._values.length)return;const t=[];for(const e of this._values)t.push({...e});return t}}function k(t,e){return t<e}function $(t,e){return t<=e}function T(t){if(t.startsWith("["))return e=>$(new Number(t.replace("[","")),e);if(t.startsWith("("))return e=>k(new Number(t.replace("(","")),e);throw`${t} is not valid interval notation`}function C(t){if(t.endsWith("]"))return e=>$(e,new Number(t.replace("]","")));if(t.endsWith(")"))return e=>k(e,new Number(t.replace(")","")));throw`${t} is not valid interval notation`}class P{constructor(t){const[e,i]=t.split(",");if(i?(this._lowwerCond=T(e),this._upperCond=C(i)):((e.startsWith("[")||e.startsWith("("))&&(this._lowwerCond=T(e),this._upperCond=t=>!0),(e.endsWith("]")||e.endsWith(")"))&&(this._lowwerCond=t=>!0,this._upperCond=C(e))),!this._lowwerCond||!this._upperCond)throw`${t} is not valid interval notation`}test(t){return this._lowwerCond(t)&&this._upperCond(t)}}function E(t){return!Number.isNaN(parseFloat(t))}class A extends S{constructor(t,e){super(t,e.pred),this.default=E(e.default)?parseFloat(e.default):0,E(e.min)&&(this.min=parseFloat(e.min)),E(e.max)&&(this.max=parseFloat(e.max)),this.step=E(e.step)?parseFloat(e.step):2,this._values=e.values||[]}getLabel(t){const e=this.#a(t);if(e&&e.label)return e.label}getDisplayName(t){return this.getLabel(t)||String(t)}getColor(t){const e=this.#a(t);return e&&e.color?e.color:null}#a(t){const e=this._values.filter(t=>"default"!==t.range).find(e=>new P(e.range).test(t));if(e)return e;const i=this._values.find(t=>"default"===t.range);return i||null}get externalFormat(){return{...super.externalFormat,"value type":"numeric",default:this.default,min:this.min,max:this.max,step:this.step,values:super._valuesClone}}}class M extends S{constructor(t,e){super(t,e.pred),this.default=!0,this.label=e.label,this.color=e.color}getLabel(){return this.label}getDisplayName(){return this.label?this.label:this.pred}getColor(){return this.color}get externalFormat(){return{...super.externalFormat,"value type":"flag",default:this.default,label:this.label,color:this.color}}}class Q extends S{constructor(t,e){super(t,e.pred),this._values=e.values||[]}get default(){return this.values.find(t=>t.default).id}getLabel(t){const e=this.#a(t);if(e&&e.label)return e.label}getDisplayName(t){return this.getLabel(t)}getColor(t){const e=this.#a(t);return e&&e.color?e.color:null}get values(){return this._values}get hasOnlyOneValue(){return 1===this._values.length}#a(t){return this.values.find(e=>e.id==t)}get externalFormat(){return{...super.externalFormat,"value type":"selection",values:super._valuesClone}}}class D extends S{constructor(t,e){super(t,e.pred),this.autocompletionWs=e.autocompletion_ws,this.default=e.default,E(e["media height"])&&(this.mediaHeight=parseFloat(e["media height"])),this._values=e.values||[]}getLabel(t){const e=this.#a(t);if(e&&e.label)return e.label}getDisplayName(t){return this.getLabel(t)}getColor(t){const e=this.#a(t);return e&&e.color?e.color:null}#a(t){const e=this._values.filter(t=>"default"!==t.pattern).find(e=>new RegExp(e.pattern).test(t));if(e)return e;const i=this._values.find(t=>"default"===t.pattern);return i||null}get externalFormat(){return{...super.externalFormat,"value type":"string",autocompletion_ws:this.autocompletionWs,default:this.default,values:super._valuesClone,"media height":this.mediaHeight}}}function R(t,e){switch(t){case"flag":return new M(t,e);case"numeric":return new A(t,e);case"selection":return new Q(t,e);case"string":return new D(t,e);default:throw new Error(`${t} of ${JSON.stringify(e)} is Uknown Attribute`)}}class I{#l;#c;#h=new Map;constructor(t,e){this.#l=t,this.#c=e}get config(){return this.attributes.map(t=>t.externalFormat)}set config(t){this.#h=new Map((t||[]).map(t=>[t.pred,R(t["value type"],t)]))}create(t,e,i=null){null!==i&&this.#h.size!==i?this.#h=new Map(Array.from(this.#h.entries()).reduce((n,[o,s],r)=>(r===i&&n.push([e.pred,R(t,e)]),n.push([o,s]),n),[])):this.#h.set(e.pred,R(t,e)),this.#l.emit("textae-event.type-definition.attribute.create",e.pred)}get(t){return this.#h.get(t)}update(t,e){return this.#h=new Map(Array.from(this.#h.entries()).map(([i,n])=>i===t?[e.pred,R(n.valueType,e)]:[i,n])),this.#l.emit("textae-event.type-definition.attribute.change",e.pred),this.get(e.pred)}updateValues(t,e){const i=this.get(t).externalFormat;return this.update(t,{...i,values:e})}move(t,e){var i,n,o;this.#h=new Map((i=this.attributes,n=t,o=e,function(t,e,i){const n=e<0?t.length+e:e;if(n>=0&&n<t.length){const n=i<0?t.length+i:i,[o]=t.splice(e,1);t.splice(n,0,o)}}(i=[...i],n,o),i).map(t=>[t.pred,t]));const{pred:s}=this.attributes[-1===e?this.attributes.length-1:e];this.#l.emit("textae-event.type-definition.attribute.move",s)}delete(t){this.#h.delete(t),this.#l.emit("textae-event.type-definition.attribute.delete")}get attributes(){return Array.from(this.#h.values())||[]}isSelectionAttributeValueIndelible(t,e){return!!this.get(t).hasOnlyOneValue||!!this.#c().some(i=>i.equalsTo(t,e))}getLabel(t,e){return console.assert(this.#h.has(t),`There is no attribute definition for ${t}.`),this.get(t).getLabel(e)}getDisplayName(t,e){return console.assert(this.#h.has(t),`There is no attribute definition for ${t}.`),this.get(t).getDisplayName(e)}getColor(t,e){if(this.#h.has(t))return this.get(t).getColor(e)}getIndexOf(t){return Array.from(this.#h.values()).findIndex(e=>e.pred===t)}getAttributeAt(t){return Array.from(this.#h.values())[t-1]}attributeCompareFunction(t,e){const i=this.getIndexOf(t.pred),n=this.getIndexOf(e.pred);return i!==n?i-n:t.id&&e.id?t.id.localeCompare(e.id):0}}function L(t,e,i){for(const n of i)t[n]=(...t)=>{const i=e();return console.assert(i[n],`No ${n} method to forward`,i),i[n].apply(i,t)};return t}function N(t){const{typesettings:e,denotations:i,blocks:n}=t;return(e||[]).concat(i||[]).concat(n||[])}function j(t){const{span:e}=t;return{...t,span:z(e)}}function z(t){return{...t,begin:parseInt(t.begin),end:parseInt(t.end)}}class B{constructor(t){this._trackNumber=t}addTrackNumberAsIDPrefix(t,e,i,n){const o=t.map(t=>({...t,id:this._prependToIDOf(t)})),s=e.map(t=>({...t,id:this._prependToIDOf(t)})),r=n.map(t=>({...t,id:this._prependToIDOf(t),subj:this._prependTrackNumberTo(t.subj),obj:t.obj})),a=i.map(t=>({...t,id:this._prependToIDOf(t),subj:this._prependTrackNumberTo(t.subj),obj:this._prependTrackNumberTo(t.obj)}));return{denotations:o,blocks:s,relations:a,attributes:r}}_prependToIDOf(t){return t.id?this._prependTrackNumberTo(t.id):null}_prependTrackNumberTo(t){return this._trackNumber+t}}function Z(t,e,i,n,o,s=""){const[r,a,l]=function(t,e,i){return[t.map(j),e.map(j),i.map(j)]}(o.typeSetting,o.denotation,o.block),{relation:c,attribute:h}=o,{denotations:u,blocks:d,relations:f,attributes:p}=new B(s).addTrackNumberAsIDPrefix(a,l,c,h);t.addSource(r,"typesetting"),t.addSource(u,"denotation"),t.addSource(d,"block"),e.addSource(u,"denotation"),e.addSource(d,"block"),n.addSource(f),i.addSource(p)}function W(t,e){for(const[i,n]of e.getInhibitors("isNotCrossing"))console.warn(`Crossing ${t}: [${i.span.begin}:${i.span.end}](${i.id}) crosses with ${n.map(({id:t,span:e})=>`[${e.begin}:${e.end}](${t})`).join(", ")}`)}class F{constructor(){this._map=new Map}set(t,e,i){this._map.set(t,[e,i])}getErrors(t){return this._map.has(t)?this._map.get(t)[0]:[]}getInhibitors(t){return this._map.has(t)?this._map.get(t)[1]:[]}get size(){return this._map.size}}function X(t,e){return e.reduce((e,i)=>e.concat(i.getErrors(t)),[])}class q{constructor(t,e,i="",n=()=>!0,o){this._candidates=t||[],this._name=i,this._predicate=n,this._prevValidation=o,this._sourcePropertyName=e}and(t,e){return new q(this._candidates,this._sourcePropertyName,t,e,this)}validateAll(){const t=new F;let e,i;for(e=this,i=this._candidates;e;e=e._prevValidation)i=e._validate(i,this._candidates,t);return[i,t]}_validate(t,e,i){return this._getRejects(e).length>0&&i.set(this._name,this._getRejects(e),this._getInhibitors(e)),this._getAccepts(t)}_getAccepts(t){return t.filter(t=>this._test(t))}_getRejects(t){return t.filter(t=>!this._test(t)).map(t=>function(t,e){return t.sourceProperty=e,t}(t,this._sourcePropertyName))}_getInhibitors(t){const e=new Map;for(const i of t){const t=this._predicate(i);Array.isArray(t)&&!t[0]&&e.set(i,t[1])}return e}_test(t){const e=this._predicate(t);return Array.isArray(e)?e[0]:e}}function H(t,e){return t.some(t=>t.id===e)}function V(t,e,i){const n=i.begin<t&&t<i.end&&i.end<e,o=t<i.begin&&i.begin<e&&e<i.end;return n||o}function Y(t,e,i){return t.filter(({span:t})=>V(e,i,t))}function U(t,e){return 0<=t&&t<=e.length}function G(t,e,i,n){return new q(t,n).and("hasLength",t=>t.span.end-t.span.begin>0).and("inText",t=>function(t,e){return U(e.begin,t)&&U(e.end,t)}(e,t.span)).and("isNotCrossing",t=>{const e=Y(i,t.span.begin,t.span.end);return[0===e.length,e]})}function K(t,e){return void 0===e.id||1===t.filter(t=>e.id&&e.id===t.id).length}function J(t,e,i){const[n,o]=function(t,e,i){return G(e,t,i,"typesettings").validateAll()}(t,i.typesettings,e),s=N(i),[r,a]=function(t,e,i,n){return G(e,t,i,"denotations").and("uniqueID",t=>K(n,t)).validateAll()}(t,i.denotations,e,s),[l,c]=function(t,e,i,n){return G(e,t,i,"blocks").and("uniqueID",t=>K(n,t)).and("uniqueRange",({span:t})=>1===e.filter(({span:e})=>t.begin===e.begin&t.end===e.end).length).validateAll()}(t,i.blocks,e,s),[h,u]=(d=r.concat(l),f=i.relations,new q(f).and("object",t=>H(d,t.obj)).and("subject",t=>H(d,t.subj)).validateAll());var d,f;const[p,m]=(g=r.concat(l).concat(h),v=i.attributes,new q(v).and("subject",t=>H(g,t.subj)).and("unique",t=>function(t,e){return 1===t.filter(t=>t.subj===e.subj&&t.pred===e.pred&&t.obj===e.obj).length}(v,t)).validateAll());var g,v,y,O,b;return W("TypeSettings",o),W("Denotations",a),W("Blocks",c),{accept:{denotation:r,attribute:p,relation:h,typeSetting:n,block:l},reject:{wrongRangeDenotations:a.getErrors("hasLength"),outOfTextDenotations:a.getErrors("inText"),wrongRangeBlocks:c.getErrors("hasLength"),outOfTextBlocks:c.getErrors("inText"),duplicatedRangeBlocks:c.getErrors("uniqueRange"),wrongRangeTypesettings:o.getErrors("hasLength"),outOfTextTypesettings:o.getErrors("inText"),duplicatedIDs:X("uniqueID",[a,c]),boundaryCrossingSpans:X("isNotCrossing",[o,a,c]),referencedEntitiesDoNotExist:(y=m.getErrors("subject"),O=u.getErrors("object"),b=u.getErrors("subject"),y.map(t=>(t.sourceProperty="attributes",t.alertSubj=!0,t)).concat(O.map(t=>(t.sourceProperty="relations",t.alertObj=!0,t))).concat(b.map(t=>(t.sourceProperty="relations",t.alertSubj=!0,t)))),duplicatedAttributes:m.getErrors("unique"),hasError:a.size||c.size||m.size||u.size||o.size}}}class tt{#u;#d;#f;#p;#m;#g;#v;#y;constructor(t,e){const{namespaceInstanceContainer:i,spanInstanceContainer:n,entityInstanceContainer:o,attributeInstanceContainer:s,relationInstanceContainer:r}=t;this.#u=i,this.#d=n,this.#f=o,this.#p=r,this.#m=s,this.#g=e}eval(){this.#g.namespaces?this.#u.addSource(this.#g.namespaces.map(t=>({id:t.prefix,...t}))):this.#u.addSource([]);const{accept:t,reject:e}=J(this.#O,this.#b,this.#g);Z(this.#d,this.#f,this.#m,this.#p,t),e.name="Root annotations.",this.#v=e,this.hasMultiTracks&&(this.#y=function(t,e,i,n,o,s,r){console.assert(r.tracks);const{tracks:a}=r;return a.map((r,a)=>{const l=a+1,c=`track${l}_`,{accept:h,reject:u}=J(o,s,r);return Z(t,e,i,n,h,c),u.name=`Track ${l} annotations.`,u})}(this.#d,this.#f,this.#m,this.#p,this.#O,this.#b,this.#g))}get hasMultiTracks(){return Boolean(this.#g.tracks)}get rejects(){return this.hasMultiTracks?[this.#v].concat(this.#y):[this.#v]}get#O(){return this.#g.text}get#b(){return function(t){let e=N(t);if(t.tracks)for(const i of t.tracks)e=e.concat(N(i));return e}(this.#g)}}class et{#x;#w;#_;constructor(t,e){this.#x=t,this.#w=e,this.#_=new Map}addSource(t,e){for(const i of t.map(t=>this._toInstance(t,e)))this._addToContainer(i)}add(t){const e=this._addToContainer(t);return this._emit(`textae-event.annotation-data.${this.#w}.add`,e),e}get(t){return this.#_.get(t)}get all(){return Array.from(this.#_.values())}get selectedItems(){return this.all.filter(({isSelected:t})=>t)}findByType(t){return this.all.filter(e=>e.typeName===t)}get some(){return!!this.#_.size}changeType(t,e){const i=this.#_.get(t);return i.typeName=e,this._emit(`textae-event.annotation-data.${this.#w}.change`,i),i}remove(t){const e=this.#_.get(t);return e&&(this.#_.delete(t),this._emit(`textae-event.annotation-data.${this.#w}.remove`,e)),e}clear(){this.#_.clear()}get _container(){return this.#_}_toInstance(t){return t}_addToContainer(t){return this.#_.set(t.id,t),t}_emit(t,e){this.#x.emit(t,e)}}class it extends et{#S;constructor(t,e,i){super(t,e),this.#S=i}addSource(t,e){const i=t.map(t=>this._toInstance(t,e));i.sort((t,e)=>t.id?e.id?t.id<e.id?-1:t.id>e.id?1:0:-1:1);for(const t of i)super._addToContainer(this.#k(t))}add(t){return super.add(this.#k(t))}#k(t){return t.id||(t.id=this.#$(t)),t}#$(t){const e=this.#S(t),i=new Set;for(const t of super._container.keys())new RegExp(`^${e}\\d+$`).test(t)&&i.add(t.slice(1));if(0===i.size)return`${e}1`;return`${e}${Math.max(...i.values())+1}`}}var nt=i(7901),ot=i.n(nt);function st(t){const[e,...i]=t;let n=e;for(const t of[...arguments].slice(1))n=`${n}${rt(t)}${i.shift()}`;return n}function rt(t){if(Array.isArray(t)&&"function"==typeof t.at(0))return t.map(t=>t()).join("");if("function"==typeof t){const e=t();return Array.isArray(e)?e.join(""):e}return ot()(t)}function at(t){return t.trim().startsWith("http")}function lt(t,e){const i=t.all.filter(t=>"_base"!==t.prefix).filter(t=>0===e.indexOf(`${t.prefix}:`));return 1===i.length?i[0]:null}function ct(t){return/\(?(?:(http|https|ftp):\/\/)?(?:((?:[^\W\s]|\.|-|[:]{1})+)@{1})?((?:www.)?(?:[^\W\s]|\.|-)+[.][^\W\s]{2,4}|localhost|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(?::(\d*))?([/]?[^\s?]*[/]{1})*(?:\/?([^\s\n?[\]{}#]*(?:(?=\.)){1}|[^\s\n?[\]{}.#]*)?([.]{1}[^\s?#]*)?)?(?:\?{1}([^\s\n#[\]]*))?([#][^\s\n]*)?\)?/gi.exec(t)}function ht(t,e,i){if(i)return i;if(at(e))return function(t){if(at(t)){const e=ct(t);if(e)return e[9]?e[9].slice(1):e[6]?e[6]+(e[7]||""):e[5]&&e[5].length>1?e[5].split("/").filter(t=>""!==t).pop():e[3]}return t}(e);const n=lt(t,e);return n?e.replace(`${n.prefix}:`,""):e}function ut(t,e){const i=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return console.assert(i,`${t} is not a hexadecimal color values!`),`rgba(${parseInt(i[1],16)}, ${parseInt(i[2],16)}, ${parseInt(i[3],16)}, ${e})`}function dt(){return ut("#FFFFFF",.6)}function ft(t,e,i){if(at(e))return e;if(i)return i;if(t.some){const i=lt(t,e);if(i)return`${i.uri}${e.replace(`${i.prefix}:`,"")}`;const n=t.all.find(t=>"_base"===t.prefix);if(n)return`${n.uri}${e}`}return null}function pt(t,e){return()=>e?st`<a target="_blank" href="${e}">${t}</a>`:st`${t}`}class mt{#T;#C;#P;#E;#f;#p;#u;#A;#M;constructor({id:t,subj:e,pred:i,obj:n},o,s,r,a,l){this.#T=t,this.#C=e,this.#P=i,this.#E=n,this.#f=o,this.#p=s,this.#u=r,this.#A=a,this.#M=l,"string"!==this.#Q||this.#D||this.#M.acquireContentTypeOf(this.#R).then(t=>{t&&this.updateElement()})}get id(){return this.#T}set id(t){this.#T=t}get subj(){return this.#C}set subj(t){this.#C=t}get pred(){return this.#P}set pred(t){this.#P=t}get obj(){return this.#E}set obj(t){"numeric"===this.#Q?this.#E=parseFloat(t):this.#E=t}get subjectInstance(){return this.#f.get(this.subj)||this.#p.get(this.subj)}get externalFormat(){return{id:this.id,subj:this.subj,pred:this.pred,obj:this.#E}}equalsTo(t,e){return this.pred===t&&String(this.#E)===e}updateElement(){this.subjectInstance.updateElement()}clarifyLabelIn(t){t.querySelector(st`[data-id="${this.id}"] .textae-editor__signboard__attribute-label`).style.backgroundColor=dt()}declarifyLabelIn(t){t.querySelector(st`[data-id="${this.id}"] .textae-editor__signboard__attribute-label`).style.backgroundColor=ut(this.#I,1)}get contentHTML(){return()=>st`
174
+ */!function(){"use strict";o=[i(4692),i(6883)],void 0===(s="function"==typeof(n=function(t){return t.extend(t.expr.pseudos,{data:t.expr.createPseudo(function(e){return function(i){return!!t.data(i,e)}})})})?n.apply(e,o):n)||(t.exports=s)}()}},e={};function i(n){var o=e[n];if(void 0!==o)return o.exports;var s=e[n]={exports:{}};return t[n].call(s.exports,s,s.exports,i),s.exports}i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},i.d=(t,e)=>{for(var n in e)i.o(e,n)&&!i.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{"use strict";const t="14.3.2";var e=i(3053),n=i.n(e);class o{constructor(t){this._editor=t}set annotation(t){this._editor.load(t)}set inspectCallback(t){this._editor.setInspector(t)}set lastSelectedDenotationIDCallback(t){this._editor.setLastSelectedDenotationIDCallback(t)}set autocompletionCallback(t){this._editor.setAutocompletionFunction(t)}get id(){return this._editor.HTMLElementID}focusDenotation(t){this._editor.focusDenotation(t)}selectDenotation(t){this._editor.selectDenotation(t)}}var s=i(5408),r=i.n(s);function a(t,e=100,i={}){if("function"!=typeof t)throw new TypeError(`Expected the first parameter to be a function, got \`${typeof t}\`.`);if(e<0)throw new RangeError("`wait` must not be negative.");if("boolean"==typeof i)throw new TypeError("The `options` parameter must be an object, not a boolean. Use `{immediate: true}` instead.");const{immediate:n}=i;let o,s,r,a,l;function c(){const e=o,i=s;return o=void 0,s=void 0,l=t.apply(e,i),l}function h(){const t=Date.now()-a;t<e&&t>=0?r=setTimeout(h,e-t):(r=void 0,n||(l=c()))}const u=function(...t){if(o&&this!==o&&Object.getPrototypeOf(this)===Object.getPrototypeOf(o))throw new Error("Debounced method called with different contexts of the same prototype.");o=this,s=t,a=Date.now();const i=n&&!r;if(r||(r=setTimeout(h,e)),i)return l=c(),l};return Object.defineProperty(u,"isPending",{get:()=>void 0!==r}),u.clear=()=>{r&&(clearTimeout(r),r=void 0,o=void 0,s=void 0)},u.flush=()=>{r&&u.trigger()},u.trigger=()=>{l=c(),u.clear()},u}var l=i(7512),c=i.n(l),h=(i(1193),i(5385)),u=i.n(h),d=i(4692),f=i.n(d);class p{constructor(t,e,i={}){this._el=u().create(`\n <div title="${t}">\n ${e}\n </div>\n `),this._$dialog=f()(this._el),this._$dialog.on("dialogclose",()=>{requestAnimationFrame(()=>this._$dialog.dialog("destroy"))}),this._option=i}get el(){return this._el}get button(){return this._$dialog.dialog("widget")[0].querySelector(".ui-dialog-buttonpane button")}open(){this._$dialog.dialog({classes:{"ui-dialog":"textae-editor__dialog"},height:"auto",modal:!0,resizable:!1,width:"calc(100% - 10px)",create:t=>{f()(t.target.parentElement).css("maxWidth",`${this._option.maxWidth||550}px`)},...this._option})}close(){this._$dialog.dialog("close")}}class m extends p{constructor(){super("Help (Keyboard short-cuts)",'<div class="textae-tool__key-help"></div>\n <ul>\n <li>\n cut\n : Ctrl+x\n </li>\n <li>\n copy\n : Ctrl+c\n </li>\n <li>\n paste\n : Ctrl+v\n </li>\n </ul>\n ',{maxWidth:523})}}function g(t){return t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement}const v=new m,y=new class extends p{constructor(){super("For security reason, the shortcut keys for cut/copy/paste are changed as follows:",'<table class="textae-editor__tips-dialog__table">\n <thead>\n <tr><th></th><th>before</th><th>after</th></tr>\n </thead>\n <tbody>\n <tr><td>cut</td><td>x</td><td>Ctrl-x</td></tr>\n <tr><td>copy</td><td>c</td><td>Ctrl-c</td></tr>\n <tr><td>paste</td><td>v</td><td>Ctrl-v</td></tr>\n </tbody>\n </table>\n ',{maxWidth:785})}};class O{#t;#e;#i;constructor(){this.#t=new Map,this.#e=null,this.#i=0,c()(window,".textae-editor","keyup",t=>{if(this.selected)switch(t.key){case"h":v.open();break;case"c":case"x":case"v":t.ctrlKey||t.metaKey||y.open()}}),this.#n()}set(t,e){this.#t.set(t,e),this.#i++}remove(t){this.#t.get(t).dispose(),this.#t.delete(t),this.selected===t&&(this.#e=null)}get selected(){return this.#e}set selected(t){null===t?(this.#o.deactivate(),this.#e=null):(this.#e=t,this.#o.activate())}drawGridsInSight(){for(const t of this.#t.values())t.drawGridsInSight()}updateDenotationEntitiesWidth(){for(const t of this.#t.values())t.updateDenotationEntitiesWidth()}reLayout(){for(const t of this.#t.values())t.reLayout()}has(t){return this.#t.has(t)}get nextID(){return`editor${this.#i}`}#n(){document.addEventListener("scroll",r()(()=>{this.drawGridsInSight()},300)),document.addEventListener("copy",t=>{g(t.target)||this.selected&&this.#t.get(this.selected).copyEntitiesToSystemClipboard(t)}),document.addEventListener("cut",t=>{g(t.target)||this.selected&&this.#t.get(this.selected).cutEntitiesToSystemClipboard(t)}),document.addEventListener("paste",t=>{g(t.target)||this.selected&&this.#t.get(this.selected).pasteEntitiesFromSystemClipboard(t)}),document.addEventListener("selectionchange",a(()=>{this.selected&&this.#t.get(this.selected).applyTextSelectionWithTouchDevice()},100)),document.addEventListener("contextmenu",()=>{this.selected&&this.#t.get(this.selected).applyTextSelectionWithTouchDevice()}),document.addEventListener("click",t=>{if(3!==t.which)for(const t of this.#t.values())t.hideContextMenu()}),document.addEventListener("contextmenu",t=>{for(const t of this.#t.values())t.hideContextMenu();const e=t.target.closest(".textae-editor");if(e===this.#e){if(e.classList.contains("textae-editor__mode--view-with-relation")||e.classList.contains("textae-editor__mode--view-without-relation"))return;t.preventDefault(),this.#o.showContextMenu(t)}})}get#o(){return this.#t.get(this.#e)}}const b={};document.querySelector("html").addEventListener("mousemove",t=>{b.clientY=t.clientY,b.pageY=t.pageY,b.clientX=t.clientX});const x={attributes:!0,attributeFilter:["class"]};class w{#s;#r;constructor(){this.#s=new Set}setObserver(t){this.#r||(this.#r=u().create('<div class="textae-editor-veil" style="display: none;"></div>'),document.body.appendChild(this.#r)),new MutationObserver(t=>this._mutationCallback(t)).observe(t,x)}_mutationCallback(t){this._collectWaitingEditors(t),this.#s.size>0?this._show():this._hide()}_collectWaitingEditors(t){t.forEach(({target:t})=>{t.classList.contains("textae-editor--wait")?this.#s.add(t):this.#s.delete(t)})}_show(){this.#r.style.display="block"}_hide(){this.#r.style.display="none"}}var _=i(7007);class S{constructor(t,e){this.valueType=t,this.pred=e}get values(){return console.assert(this._values,"this._values to return!"),this._values}get externalFormat(){return{pred:this.pred}}get _valuesClone(){if(console.assert(this._values,"this._values is necessary to clone!"),Array.isArray(this._values)&&0===this._values.length)return;const t=[];for(const e of this._values)t.push({...e});return t}}function k(t,e){return t<e}function $(t,e){return t<=e}function T(t){if(t.startsWith("["))return e=>$(new Number(t.replace("[","")),e);if(t.startsWith("("))return e=>k(new Number(t.replace("(","")),e);throw`${t} is not valid interval notation`}function C(t){if(t.endsWith("]"))return e=>$(e,new Number(t.replace("]","")));if(t.endsWith(")"))return e=>k(e,new Number(t.replace(")","")));throw`${t} is not valid interval notation`}class P{constructor(t){const[e,i]=t.split(",");if(i?(this._lowwerCond=T(e),this._upperCond=C(i)):((e.startsWith("[")||e.startsWith("("))&&(this._lowwerCond=T(e),this._upperCond=t=>!0),(e.endsWith("]")||e.endsWith(")"))&&(this._lowwerCond=t=>!0,this._upperCond=C(e))),!this._lowwerCond||!this._upperCond)throw`${t} is not valid interval notation`}test(t){return this._lowwerCond(t)&&this._upperCond(t)}}function E(t){return!Number.isNaN(parseFloat(t))}class A extends S{constructor(t,e){super(t,e.pred),this.default=E(e.default)?parseFloat(e.default):0,E(e.min)&&(this.min=parseFloat(e.min)),E(e.max)&&(this.max=parseFloat(e.max)),this.step=E(e.step)?parseFloat(e.step):2,this._values=e.values||[]}getLabel(t){const e=this.#a(t);if(e&&e.label)return e.label}getDisplayName(t){return this.getLabel(t)||String(t)}getColor(t){const e=this.#a(t);return e&&e.color?e.color:null}#a(t){const e=this._values.filter(t=>"default"!==t.range).find(e=>new P(e.range).test(t));if(e)return e;const i=this._values.find(t=>"default"===t.range);return i||null}get externalFormat(){return{...super.externalFormat,"value type":"numeric",default:this.default,min:this.min,max:this.max,step:this.step,values:super._valuesClone}}}class M extends S{constructor(t,e){super(t,e.pred),this.default=!0,this.label=e.label,this.color=e.color}getLabel(){return this.label}getDisplayName(){return this.label?this.label:this.pred}getColor(){return this.color}get externalFormat(){return{...super.externalFormat,"value type":"flag",default:this.default,label:this.label,color:this.color}}}class Q extends S{constructor(t,e){super(t,e.pred),this._values=e.values||[]}get default(){return this.values.find(t=>t.default).id}getLabel(t){const e=this.#a(t);if(e&&e.label)return e.label}getDisplayName(t){return this.getLabel(t)}getColor(t){const e=this.#a(t);return e&&e.color?e.color:null}get values(){return this._values}get hasOnlyOneValue(){return 1===this._values.length}#a(t){return this.values.find(e=>e.id==t)}get externalFormat(){return{...super.externalFormat,"value type":"selection",values:super._valuesClone}}}class D extends S{constructor(t,e){super(t,e.pred),this.autocompletionWs=e.autocompletion_ws,this.default=e.default,E(e["media height"])&&(this.mediaHeight=parseFloat(e["media height"])),this._values=e.values||[]}getLabel(t){const e=this.#a(t);if(e&&e.label)return e.label}getDisplayName(t){return this.getLabel(t)}getColor(t){const e=this.#a(t);return e&&e.color?e.color:null}#a(t){const e=this._values.filter(t=>"default"!==t.pattern).find(e=>new RegExp(e.pattern).test(t));if(e)return e;const i=this._values.find(t=>"default"===t.pattern);return i||null}get externalFormat(){return{...super.externalFormat,"value type":"string",autocompletion_ws:this.autocompletionWs,default:this.default,values:super._valuesClone,"media height":this.mediaHeight}}}function R(t,e){switch(t){case"flag":return new M(t,e);case"numeric":return new A(t,e);case"selection":return new Q(t,e);case"string":return new D(t,e);default:throw new Error(`${t} of ${JSON.stringify(e)} is Uknown Attribute`)}}class I{#l;#c;#h=new Map;constructor(t,e){this.#l=t,this.#c=e}get config(){return this.attributes.map(t=>t.externalFormat)}set config(t){this.#h=new Map((t||[]).map(t=>[t.pred,R(t["value type"],t)]))}create(t,e,i=null){null!==i&&this.#h.size!==i?this.#h=new Map(Array.from(this.#h.entries()).reduce((n,[o,s],r)=>(r===i&&n.push([e.pred,R(t,e)]),n.push([o,s]),n),[])):this.#h.set(e.pred,R(t,e)),this.#l.emit("textae-event.type-definition.attribute.create",e.pred)}get(t){return this.#h.get(t)}update(t,e){return this.#h=new Map(Array.from(this.#h.entries()).map(([i,n])=>i===t?[e.pred,R(n.valueType,e)]:[i,n])),this.#l.emit("textae-event.type-definition.attribute.change",e.pred),this.get(e.pred)}updateValues(t,e){const i=this.get(t).externalFormat;return this.update(t,{...i,values:e})}move(t,e){var i,n,o;this.#h=new Map((i=this.attributes,n=t,o=e,function(t,e,i){const n=e<0?t.length+e:e;if(n>=0&&n<t.length){const n=i<0?t.length+i:i,[o]=t.splice(e,1);t.splice(n,0,o)}}(i=[...i],n,o),i).map(t=>[t.pred,t]));const{pred:s}=this.attributes[-1===e?this.attributes.length-1:e];this.#l.emit("textae-event.type-definition.attribute.move",s)}delete(t){this.#h.delete(t),this.#l.emit("textae-event.type-definition.attribute.delete")}get attributes(){return Array.from(this.#h.values())||[]}isSelectionAttributeValueIndelible(t,e){return!!this.get(t).hasOnlyOneValue||!!this.#c().some(i=>i.equalsTo(t,e))}getLabel(t,e){return console.assert(this.#h.has(t),`There is no attribute definition for ${t}.`),this.get(t).getLabel(e)}getDisplayName(t,e){return console.assert(this.#h.has(t),`There is no attribute definition for ${t}.`),this.get(t).getDisplayName(e)}getColor(t,e){if(this.#h.has(t))return this.get(t).getColor(e)}getIndexOf(t){return Array.from(this.#h.values()).findIndex(e=>e.pred===t)}getAttributeAt(t){return Array.from(this.#h.values())[t-1]}attributeCompareFunction(t,e){const i=this.getIndexOf(t.pred),n=this.getIndexOf(e.pred);return i!==n?i-n:t.id&&e.id?t.id.localeCompare(e.id):0}}function L(t,e,i){for(const n of i)t[n]=(...t)=>{const i=e();return console.assert(i[n],`No ${n} method to forward`,i),i[n].apply(i,t)};return t}function N(t){const{typesettings:e,denotations:i,blocks:n}=t;return(e||[]).concat(i||[]).concat(n||[])}function j(t){const{span:e}=t;return{...t,span:z(e)}}function z(t){return{...t,begin:parseInt(t.begin),end:parseInt(t.end)}}class B{constructor(t){this._trackNumber=t}addTrackNumberAsIDPrefix(t,e,i,n){const o=t.map(t=>({...t,id:this._prependToIDOf(t)})),s=e.map(t=>({...t,id:this._prependToIDOf(t)})),r=n.map(t=>({...t,id:this._prependToIDOf(t),subj:this._prependTrackNumberTo(t.subj),obj:t.obj})),a=i.map(t=>({...t,id:this._prependToIDOf(t),subj:this._prependTrackNumberTo(t.subj),obj:this._prependTrackNumberTo(t.obj)}));return{denotations:o,blocks:s,relations:a,attributes:r}}_prependToIDOf(t){return t.id?this._prependTrackNumberTo(t.id):null}_prependTrackNumberTo(t){return this._trackNumber+t}}function Z(t,e,i,n,o,s=""){const[r,a,l]=function(t,e,i){return[t.map(j),e.map(j),i.map(j)]}(o.typeSetting,o.denotation,o.block),{relation:c,attribute:h}=o,{denotations:u,blocks:d,relations:f,attributes:p}=new B(s).addTrackNumberAsIDPrefix(a,l,c,h);t.addSource(r,"typesetting"),t.addSource(u,"denotation"),t.addSource(d,"block"),e.addSource(u,"denotation"),e.addSource(d,"block"),n.addSource(f),i.addSource(p)}function W(t,e){for(const[i,n]of e.getInhibitors("isNotCrossing"))console.warn(`Crossing ${t}: [${i.span.begin}:${i.span.end}](${i.id}) crosses with ${n.map(({id:t,span:e})=>`[${e.begin}:${e.end}](${t})`).join(", ")}`)}class F{constructor(){this._map=new Map}set(t,e,i){this._map.set(t,[e,i])}getErrors(t){return this._map.has(t)?this._map.get(t)[0]:[]}getInhibitors(t){return this._map.has(t)?this._map.get(t)[1]:[]}get size(){return this._map.size}}function X(t,e){return e.reduce((e,i)=>e.concat(i.getErrors(t)),[])}class q{constructor(t,e,i="",n=()=>!0,o){this._candidates=t||[],this._name=i,this._predicate=n,this._prevValidation=o,this._sourcePropertyName=e}and(t,e){return new q(this._candidates,this._sourcePropertyName,t,e,this)}validateAll(){const t=new F;let e,i;for(e=this,i=this._candidates;e;e=e._prevValidation)i=e._validate(i,this._candidates,t);return[i,t]}_validate(t,e,i){return this._getRejects(e).length>0&&i.set(this._name,this._getRejects(e),this._getInhibitors(e)),this._getAccepts(t)}_getAccepts(t){return t.filter(t=>this._test(t))}_getRejects(t){return t.filter(t=>!this._test(t)).map(t=>function(t,e){return t.sourceProperty=e,t}(t,this._sourcePropertyName))}_getInhibitors(t){const e=new Map;for(const i of t){const t=this._predicate(i);Array.isArray(t)&&!t[0]&&e.set(i,t[1])}return e}_test(t){const e=this._predicate(t);return Array.isArray(e)?e[0]:e}}function H(t,e){return t.some(t=>t.id===e)}function V(t,e,i){const n=i.begin<t&&t<i.end&&i.end<e,o=t<i.begin&&i.begin<e&&e<i.end;return n||o}function Y(t,e,i){return t.filter(({span:t})=>V(e,i,t))}function U(t,e){return 0<=t&&t<=e.length}function G(t,e,i,n){return new q(t,n).and("hasLength",t=>t.span.end-t.span.begin>0).and("inText",t=>function(t,e){return U(e.begin,t)&&U(e.end,t)}(e,t.span)).and("isNotCrossing",t=>{const e=Y(i,t.span.begin,t.span.end);return[0===e.length,e]})}function K(t,e){return void 0===e.id||1===t.filter(t=>e.id&&e.id===t.id).length}function J(t,e,i){const[n,o]=function(t,e,i){return G(e,t,i,"typesettings").validateAll()}(t,i.typesettings,e),s=N(i),[r,a]=function(t,e,i,n){return G(e,t,i,"denotations").and("uniqueID",t=>K(n,t)).validateAll()}(t,i.denotations,e,s),[l,c]=function(t,e,i,n){return G(e,t,i,"blocks").and("uniqueID",t=>K(n,t)).and("uniqueRange",({span:t})=>1===e.filter(({span:e})=>t.begin===e.begin&t.end===e.end).length).validateAll()}(t,i.blocks,e,s),[h,u]=(d=r.concat(l),f=i.relations,new q(f).and("object",t=>H(d,t.obj)).and("subject",t=>H(d,t.subj)).validateAll());var d,f;const[p,m]=(g=r.concat(l).concat(h),v=i.attributes,new q(v).and("subject",t=>H(g,t.subj)).and("unique",t=>function(t,e){return 1===t.filter(t=>t.subj===e.subj&&t.pred===e.pred&&t.obj===e.obj).length}(v,t)).validateAll());var g,v,y,O,b;return W("TypeSettings",o),W("Denotations",a),W("Blocks",c),{accept:{denotation:r,attribute:p,relation:h,typeSetting:n,block:l},reject:{wrongRangeDenotations:a.getErrors("hasLength"),outOfTextDenotations:a.getErrors("inText"),wrongRangeBlocks:c.getErrors("hasLength"),outOfTextBlocks:c.getErrors("inText"),duplicatedRangeBlocks:c.getErrors("uniqueRange"),wrongRangeTypesettings:o.getErrors("hasLength"),outOfTextTypesettings:o.getErrors("inText"),duplicatedIDs:X("uniqueID",[a,c]),boundaryCrossingSpans:X("isNotCrossing",[o,a,c]),referencedEntitiesDoNotExist:(y=m.getErrors("subject"),O=u.getErrors("object"),b=u.getErrors("subject"),y.map(t=>(t.sourceProperty="attributes",t.alertSubj=!0,t)).concat(O.map(t=>(t.sourceProperty="relations",t.alertObj=!0,t))).concat(b.map(t=>(t.sourceProperty="relations",t.alertSubj=!0,t)))),duplicatedAttributes:m.getErrors("unique"),hasError:a.size||c.size||m.size||u.size||o.size}}}class tt{#u;#d;#f;#p;#m;#g;#v;#y;constructor(t,e){const{namespaceInstanceContainer:i,spanInstanceContainer:n,entityInstanceContainer:o,attributeInstanceContainer:s,relationInstanceContainer:r}=t;this.#u=i,this.#d=n,this.#f=o,this.#p=r,this.#m=s,this.#g=e}eval(){this.#g.namespaces?this.#u.addSource(this.#g.namespaces.map(t=>({id:t.prefix,...t}))):this.#u.addSource([]);const{accept:t,reject:e}=J(this.#O,this.#b,this.#g);Z(this.#d,this.#f,this.#m,this.#p,t),e.name="Root annotations.",this.#v=e,this.hasMultiTracks&&(this.#y=function(t,e,i,n,o,s,r){console.assert(r.tracks);const{tracks:a}=r;return a.map((r,a)=>{const l=a+1,c=`track${l}_`,{accept:h,reject:u}=J(o,s,r);return Z(t,e,i,n,h,c),u.name=`Track ${l} annotations.`,u})}(this.#d,this.#f,this.#m,this.#p,this.#O,this.#b,this.#g))}get hasMultiTracks(){return Boolean(this.#g.tracks)}get rejects(){return this.hasMultiTracks?[this.#v].concat(this.#y):[this.#v]}get#O(){return this.#g.text}get#b(){return function(t){let e=N(t);if(t.tracks)for(const i of t.tracks)e=e.concat(N(i));return e}(this.#g)}}class et{#x;#w;#_;constructor(t,e){this.#x=t,this.#w=e,this.#_=new Map}addSource(t,e){for(const i of t.map(t=>this._toInstance(t,e)))this._addToContainer(i)}add(t){const e=this._addToContainer(t);return this._emit(`textae-event.annotation-data.${this.#w}.add`,e),e}get(t){return this.#_.get(t)}get all(){return Array.from(this.#_.values())}get selectedItems(){return this.all.filter(({isSelected:t})=>t)}findByType(t){return this.all.filter(e=>e.typeName===t)}get some(){return!!this.#_.size}changeType(t,e){const i=this.#_.get(t);return i.typeName=e,this._emit(`textae-event.annotation-data.${this.#w}.change`,i),i}remove(t){const e=this.#_.get(t);return e&&(this.#_.delete(t),this._emit(`textae-event.annotation-data.${this.#w}.remove`,e)),e}clear(){this.#_.clear()}get _container(){return this.#_}_toInstance(t){return t}_addToContainer(t){return this.#_.set(t.id,t),t}_emit(t,e){this.#x.emit(t,e)}}class it extends et{#S;constructor(t,e,i){super(t,e),this.#S=i}addSource(t,e){const i=t.map(t=>this._toInstance(t,e));i.sort((t,e)=>t.id?e.id?t.id<e.id?-1:t.id>e.id?1:0:-1:1);for(const t of i)super._addToContainer(this.#k(t))}add(t){return super.add(this.#k(t))}#k(t){return t.id||(t.id=this.#$(t)),t}#$(t){const e=this.#S(t),i=new Set;for(const t of super._container.keys())new RegExp(`^${e}\\d+$`).test(t)&&i.add(t.slice(1));if(0===i.size)return`${e}1`;return`${e}${Math.max(...i.values())+1}`}}var nt=i(7901),ot=i.n(nt);function st(t){const[e,...i]=t;let n=e;for(const t of[...arguments].slice(1))n=`${n}${rt(t)}${i.shift()}`;return n}function rt(t){if(Array.isArray(t)&&"function"==typeof t.at(0))return t.map(t=>t()).join("");if("function"==typeof t){const e=t();return Array.isArray(e)?e.join(""):e}return ot()(t)}function at(t){return t.trim().startsWith("http")}function lt(t,e){const i=t.all.filter(t=>"_base"!==t.prefix).filter(t=>0===e.indexOf(`${t.prefix}:`));return 1===i.length?i[0]:null}function ct(t){return/\(?(?:(http|https|ftp):\/\/)?(?:((?:[^\W\s]|\.|-|[:]{1})+)@{1})?((?:www.)?(?:[^\W\s]|\.|-)+[.][^\W\s]{2,4}|localhost|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(?::(\d*))?([/]?[^\s?]*[/]{1})*(?:\/?([^\s\n?[\]{}#]*(?:(?=\.)){1}|[^\s\n?[\]{}.#]*)?([.]{1}[^\s?#]*)?)?(?:\?{1}([^\s\n#[\]]*))?([#][^\s\n]*)?\)?/gi.exec(t)}function ht(t,e,i){if(i)return i;if(at(e))return function(t){if(at(t)){const e=ct(t);if(e)return e[9]?e[9].slice(1):e[6]?e[6]+(e[7]||""):e[5]&&e[5].length>1?e[5].split("/").filter(t=>""!==t).pop():e[3]}return t}(e);const n=lt(t,e);return n?e.replace(`${n.prefix}:`,""):e}function ut(t,e){const i=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return console.assert(i,`${t} is not a hexadecimal color values!`),`rgba(${parseInt(i[1],16)}, ${parseInt(i[2],16)}, ${parseInt(i[3],16)}, ${e})`}function dt(){return ut("#FFFFFF",.6)}function ft(t,e,i){if(at(e))return e;if(i)return i;if(t.some){const i=lt(t,e);if(i)return`${i.uri}${e.replace(`${i.prefix}:`,"")}`;const n=t.all.find(t=>"_base"===t.prefix);if(n)return`${n.uri}${e}`}return null}function pt(t,e){return()=>e?st`<a target="_blank" href="${e}">${t}</a>`:st`${t}`}class mt{#T;#C;#P;#E;#f;#p;#u;#A;#M;constructor({id:t,subj:e,pred:i,obj:n},o,s,r,a,l){this.#T=t,this.#C=e,this.#P=i,this.#E=n,this.#f=o,this.#p=s,this.#u=r,this.#A=a,this.#M=l,"string"!==this.#Q||this.#D||this.#M.acquireContentTypeOf(this.#R).then(t=>{t&&this.updateElement()})}get id(){return this.#T}set id(t){this.#T=t}get subj(){return this.#C}set subj(t){this.#C=t}get pred(){return this.#P}set pred(t){this.#P=t}get obj(){return this.#E}set obj(t){"numeric"===this.#Q?this.#E=parseFloat(t):this.#E=t}get subjectInstance(){return this.#f.get(this.subj)||this.#p.get(this.subj)}get externalFormat(){return{id:this.id,subj:this.subj,pred:this.pred,obj:this.#E}}equalsTo(t,e){return this.pred===t&&String(this.#E)===e}updateElement(){this.subjectInstance.updateElement()}clarifyLabelIn(t){t.querySelector(st`[data-id="${this.id}"] .textae-editor__signboard__attribute-label`).style.backgroundColor=dt()}declarifyLabelIn(t){t.querySelector(st`[data-id="${this.id}"] .textae-editor__signboard__attribute-label`).style.backgroundColor=ut(this.#I,1)}get contentHTML(){return()=>st`
175
175
  <div
176
176
  class="textae-editor__signboard__attribute"
177
177
  title="${this.#L}"
@@ -185,7 +185,7 @@ var i,n=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?
185
185
  ${this.#N}
186
186
  </span>
187
187
  </div>
188
- `}get height(){return this.#A.get(this.pred).mediaHeight?this.#A.get(this.pred).mediaHeight:18}get#L(){return`[${this.id}] pred: ${this.pred}, value: ${this.#E}`}get#N(){return this.#j?()=>`<img src="${this.obj}" height="${this.height}" >`:pt(this.#z,this.#R)}get#j(){return"string"===this.#Q&&(this.#D||this.#M.hasImageContentTypeOf(this.#R))}get#D(){return/\.(jpg|png|gif)$/.test(this.#R)}get#z(){return ht(this.#u,"string"==typeof this.#E?this.#E:"",this.#A.getDisplayName(this.pred,this.#E))}get#R(){return ft(this.#u,"string"==typeof this.#E?this.#E:"")}get#I(){return this.#A.getColor(this.pred,this.#E)||this.subjectInstance.color}get#Q(){return this.#A.get(this.pred).valueType}}class gt{#B=new Map;async acquireContentTypeOf(t){if(!t)return Promise.resolve(!1);if(this.#B.has(t))return this.#B.get(t);const e=new Request(t,{method:"get",mode:"cors",cache:"force-cache"}),i=new Promise(n=>{fetch(e).then(t=>{const e=/image\/(jpg|png|gif)$/.test(t.headers.get("content-type"));i.value=e,n(e)}).catch(e=>{console.warn(e.message,t),n(!1)})});return this.#B.set(t,i),i}hasImageContentTypeOf(t){return!!t&&(!!this.#B.has(t)&&this.#B.get(t).value)}}class vt extends it{#f;#p;#u;#A;#M;constructor(t,e,i,n,o){super(t,"attribute",()=>"A"),this.#f=e,this.#p=i,this.#u=n,this.#A=o,this.#M=new gt}_toInstance(t){return new mt(t,this.#f,this.#p,this.#u,this.#A,this.#M)}add(t){return t=t instanceof mt?t:this._toInstance(t),super.add(t),t.updateElement(),t}change(t,e,i){const n=this.get(t);return e&&(n.pred=e),i&&(n.obj=i),n}remove(t){const e=super.remove(t);console.assert(e,`There are no attribute ${t} to delete!`),e.updateElement()}getSameDefinitionsAttributes(t){return this.all.filter(e=>e.pred===t)}getSameAttributes(t,e){return this.all.filter(i=>i.equalsTo(t,e))}getAttributesFor(t){return this.all.filter(e=>e.subj===t).sort((t,e)=>this.#A.attributeCompareFunction(t,e))}}function yt(t){const e=parseInt(t,10);return isNaN(e)?0:e}class Ot{#Z;#r;#W;#F;constructor(t,e,i){this.#Z=t,this.#r=t.querySelector(".textae-editor__text-box"),this.#W=e,this.#F=i}get boundingClientRect(){return this.#r.getBoundingClientRect()}get lineHeight(){return t=this.#r,yt(window.getComputedStyle(t).lineHeight);var t}set lineHeight(t){var e,i,n;e=this.#r,i=t,n=this.#F,e.style.lineHeight=`${i}px`,e.style.paddingTop=`${i/2+n}px`,this.forceUpdate(),this.#W.updatePosition()}render(t){this.#r.innerHTML=t.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#039;")}updateLineHeight(){const t=this.#W.spanInstanceContainer.maxHeight;t?this.lineHeight=t:this.#X()}forceUpdate(){!function(t,e){const i=window.getComputedStyle(t);t.style.height="auto",t.style.height=`${t.offsetHeight-yt(i.paddingTop)+20+e}px`}(this.#r,this.#F),this.#q()}#X(){const{lineHeight:t}=window.getComputedStyle(this.#Z);this.lineHeight=yt(t)}#q(){const t=this.#Z.querySelector(".textae-editor__relation-box");t.style.height=this.#r.style.height;const e=parseFloat(window.getComputedStyle(this.#r).width);t.style.width=e-10+"px"}}function bt(t,e,i){const n='\n <div class="textae-editor__body">\n <div class="textae-editor__annotation-box"></div>\n <svg\n namespace="http://www.w3.org/2000/svg"\n class="textae-editor__relation-box">\n </svg>\n <div class="textae-editor__text-box"></div>\n </div>\n ';return t.innerHTML=n.replace(/[\n\r]+/g,""),function(t){new MutationObserver(e=>{e.forEach(e=>{e.removedNodes.length&&1===e.removedNodes[0].nodeType&&(e.removedNodes[0].classList.contains("textae-editor__span")||e.removedNodes[0].classList.contains("textae-editor__type"))&&"BODY"===document.activeElement.tagName&&t.focus()})}).observe(t.querySelector(".textae-editor__body"),{childList:!0,subtree:!0})}(t),new Ot(t,e,i)}function xt(t,e){const i=new URL(t,location);return i.searchParams.append("term",e),fetch(i.href).then(t=>t.ok?t.json():[])}class wt{#T;#I;#H;#V;constructor(t,e,i,n){this.#T=t,this.#I=e,this.#H=i,this.#V=n}get id(){return this.#T}get color(){return this.#I}get label(){return this.#H}get default(){return this.#V}toJSON(){return{id:this.#T,color:this.#I,label:this.#H,default:this.#V}}}function _t(t,e){for(const[e,i]of t.entries())t.set(e,{...i,usage:0});return e.reduce((t,{typeName:e})=>(t.get(e).usage+=1,t),t)}class St{#Y;constructor(t=[]){this.#Y=t.map(t=>new wt(t.id,t.color,t.label,t.default))}has(t){return this.map.has(t)}get default(){return this.#Y.find(t=>!0===t.default)}replace(t,e){e=new wt(e.id,e.color,e.label,e.default);const i=this.#Y.findIndex(e=>e.id===t);-1!==i?this.#Y.splice(i,1,e):this.#Y.push(e)}delete(t){this.#Y=this.#Y.filter(e=>e.id!==t)}ids(){return this.map.keys()}getColorOf(t){return this.#U(t)?.color}getLabelOf(t){return this.#U(t)?.label}labelsIncludes(t){return this.#Y.filter(t=>t.label).filter(e=>e.label.includes(t))}get map(){return new Map(this.#Y.map(t=>[t.id,t]))}#U(t){if(this.has(t))return this.map.get(t);const e=function(t,e){const i=function(t,e){const i=[];for(const n of t)-1!==n.indexOf("*")&&0===e.indexOf(n.slice(0,-1))&&i.push(n);return i}(t,e);return 0===i.length?null:function(t){let e="";for(const i of t)i.length>e.length&&(e=i);return e}(i)}(this.ids(),t);return this.map.get(e)}}function kt(t){const e=Array.from(t.keys());return e.sort((e,i)=>{const n=t.get(i).usage-t.get(e).usage;return 0!==n?n:e>i?1:e<i?-1:0}),e}class $t{#l;#G;#h=new St([]);#c;#K;#J;#tt="";#et;constructor(t,e,i,n){this.#l=t,this.#G=e,this.#c=i,this.#K=n}set autocompletionWs(t){this.#tt=t}set autocompletionFunction(t){this.#et=t}get autocompletionWs(){return this.#tt}get annotationType(){return this.#G}get config(){const t=this.#it;for(const[e,i]of t.entries()){const n=i.toJSON();i.id===this.defaultType?n.default=!0:delete n.default,t.set(e,n)}return[...t.values()]}set config(t){this.#h=new St(t);const e=this.#h.default;e?(delete e.default,this.#J=e.id):this.#J=null}has(t){return this.#h.has(t)}get(t){const e={...this.#h.map.get(t)};return this.#J===t?(e.default=!0,e):(delete e.default,e)}replace(t,e){this.#h.replace(t,e),this.#l.emit(`textae-event.type-definition.${this.#G}.change`,e.id)}addDefinedType(t){if(void 0===t.color){const e=this.getColor(t.id);e!==this.#K&&(t.color=e)}if(void 0===t.label){const e=this.getLabel(t.id);e&&(t.label=e)}t.default&&(this.#J=t.id),this.replace(t.id,t)}get defaultType(){return this.#J?this.#J:this.#c().length>0?kt(_t(this.#it,this.#c()))[0]:"something"}set defaultType(t){this.#J=t,this.#l.emit(`textae-event.type-definition.${this.#G}.change-default`,t)}get defaultColor(){return this.#K}getColor(t){return this.#h.getColorOf(t)||this.#K}getLabel(t){return this.#h.getLabelOf(t)}getURI(t){return ct(t)?t:void 0}searchByLabel(t,e){if("function"==typeof this.#et){const i=this.#et(t),n=this.mergeWithLocalData(i,t);return void e(n)}this.#tt?xt(this.#tt,t).then(i=>{const n=this.mergeWithLocalData(i,t);e(n)}):e(this.findByLabel(t))}findByLabel(t){return this.#h.labelsIncludes(t)}mergeWithLocalData(t,e){const i=this.findByLabel(e),n=(t||[]).filter(t=>!i.some(e=>t.id===e.id));return i.concat(n)}get pallet(){const t=_t(this.#it,this.#c());return function(t,e,i,n,o){return t.map(t=>({id:t,label:i.getLabelOf(t)||void 0,defaultType:t===n,uri:ct(t)?t:void 0,color:i.getColorOf(t)||o,useNumber:e.get(t).usage}))}(kt(t),t,this.#h,this.defaultType,this.#K)}get#it(){const t=this.#h.map;for(const{typeName:e}of this.#c())t.has(e)||t.set(e,new wt(e));return t}delete(t,e){this.#h.delete(t),this.#J=e,this.#l.emit(`textae-event.type-definition.${this.#G}.delete`,t)}}class Tt{#nt;#ot;constructor(t,e=[]){this.#nt=t,this.#ot=e}get typeName(){return this.#nt}get attributes(){return this.#ot}get externalFormat(){return{obj:this.#nt,attributes:this.#ot.map(({externalFormat:t})=>t)}}isSameType(t,e=null){return e?this.typeName===t&&this._hasSameAttributes(e):this.typeName===t}hasSpecificPredicateAttribute(t){return this.attributes.some(e=>e.pred===t)}_hasSameAttributes(t){if(t.length!=this.attributes.length)return!1;const e=[...t];for(const t of this.attributes){const i=e.findIndex(e=>e.pred===t.pred&&e.obj===String(t.obj));if(-1===i)return!1;e.splice(i,1)}return 0===e.length||void 0}}function Ct(t){return Math.round(100*t)/100}const Pt="textae-editor__signboard--selected",Et="textae-editor__signboard--cutting";class At{#st;#rt;constructor(t,e,i){this.#st=t,this.#rt=u().create(this.#at(i,e))}get element(){return this.#rt}addEventListener(t,e){this.#rt.addEventListener(t,e)}hover(){this.#rt.classList.add("textae-editor__signboard--hovered")}select(){this.#rt.classList.add(Pt)}deselect(){this.#rt.classList.remove(Pt)}startCut(){this.#rt.classList.add(Et)}cancelCut(){this.#rt.classList.remove(Et)}clearCSSClass(){this.element.className="",this.element.classList.add("textae-editor__signboard")}updateLabel(){const t=this.element.querySelector(".textae-editor__signboard__type-values");t.style.backgroundColor=ut(this.#st.color,.4),t.querySelector(".textae-editor__signboard__type-label").innerHTML=st`${this.#st.anchorHTML}`;for(const e of t.querySelectorAll(".textae-editor__signboard__attribute"))e.remove();for(const e of this.#st.attributes)t.insertAdjacentHTML("beforeend",st`${e.contentHTML}`)}clarifyLabel(){this.element.querySelector(".textae-editor__signboard__type-label").style.backgroundColor=dt();for(const t of this.#st.attributes)t.clarifyLabelIn(this.element)}declarifyLabel(){this.element.querySelector(".textae-editor__signboard__type-label").style.backgroundColor=ut(this.#st.color,1);for(const t of this.#st.attributes)t.declarifyLabelIn(this.element)}focus(){this.#rt.querySelector(".textae-editor__signboard__type-label").focus()}replaceWith(t){return this.#rt.replaceWith(t.element),t}reflectTypeGapInTheHeight(t){this.#rt.setAttribute("style",`padding-top: ${t}px;`)}remove(){this.#rt.remove()}#at(t,e){return st`
188
+ `}get height(){return this.#A.get(this.pred).mediaHeight?this.#A.get(this.pred).mediaHeight:18}get#L(){return`[${this.id}] pred: ${this.pred}, value: ${this.#E}`}get#N(){return this.#j?()=>`<img src="${this.obj}" height="${this.height}" >`:pt(this.#z,this.#R)}get#j(){return"string"===this.#Q&&(this.#D||this.#M.hasImageContentTypeOf(this.#R))}get#D(){return/\.(jpg|png|gif)$/.test(this.#R)}get#z(){return ht(this.#u,"string"==typeof this.#E?this.#E:"",this.#A.getDisplayName(this.pred,this.#E))}get#R(){return ft(this.#u,"string"==typeof this.#E?this.#E:"")}get#I(){return this.#A.getColor(this.pred,this.#E)||this.subjectInstance.color}get#Q(){return this.#A.get(this.pred).valueType}}class gt{#B=new Map;async acquireContentTypeOf(t){if(!t)return Promise.resolve(!1);if(this.#B.has(t))return this.#B.get(t);const e=new Request(t,{method:"get",mode:"cors",cache:"force-cache"}),i=new Promise(n=>{fetch(e).then(t=>{const e=/image\/(jpg|png|gif)$/.test(t.headers.get("content-type"));i.value=e,n(e)}).catch(e=>{console.warn(e.message,t),n(!1)})});return this.#B.set(t,i),i}hasImageContentTypeOf(t){return!!t&&(!!this.#B.has(t)&&this.#B.get(t).value)}}class vt extends it{#f;#p;#u;#A;#M;constructor(t,e,i,n,o){super(t,"attribute",()=>"A"),this.#f=e,this.#p=i,this.#u=n,this.#A=o,this.#M=new gt}_toInstance(t){return new mt(t,this.#f,this.#p,this.#u,this.#A,this.#M)}add(t){return t=t instanceof mt?t:this._toInstance(t),super.add(t),t.updateElement(),t}change(t,e,i){const n=this.get(t);return e&&(n.pred=e),i&&(n.obj=i),n}remove(t){const e=super.remove(t);console.assert(e,`There are no attribute ${t} to delete!`),e.updateElement()}getSameDefinitionsAttributes(t){return this.all.filter(e=>e.pred===t)}getSameAttributes(t,e){return this.all.filter(i=>i.equalsTo(t,e))}getAttributesFor(t){return this.all.filter(e=>e.subj===t).sort((t,e)=>this.#A.attributeCompareFunction(t,e))}}function yt(t){const e=parseInt(t,10);return isNaN(e)?0:e}class Ot{#Z;#r;#W;#F;constructor(t,e,i){this.#Z=t,this.#r=t.querySelector(".textae-editor__text-box"),this.#W=e,this.#F=i}get boundingClientRect(){return this.#r.getBoundingClientRect()}get lineHeight(){return t=this.#r,yt(window.getComputedStyle(t).lineHeight);var t}set lineHeight(t){var e,i,n;e=this.#r,i=t,n=this.#F,e.style.lineHeight=`${i}px`,e.style.paddingTop=`${i/2+n}px`,this.forceUpdate(),this.#W.updatePosition()}render(t){this.#r.innerHTML=t.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#039;")}updateLineHeight(){const t=this.#W.spanInstanceContainer.maxHeight;t?this.lineHeight=t:this.#X()}forceUpdate(){!function(t,e){const i=window.getComputedStyle(t);t.style.height="auto",t.style.height=`${t.offsetHeight-yt(i.paddingTop)+20+e}px`}(this.#r,this.#F),this.#q()}#X(){const{lineHeight:t}=window.getComputedStyle(this.#Z);this.lineHeight=yt(t)}#q(){const t=this.#Z.querySelector(".textae-editor__relation-box");t.style.height=this.#r.style.height;const e=parseFloat(window.getComputedStyle(this.#r).width);t.style.width=e-10+"px"}}function bt(t,e,i){const n='\n <div class="textae-editor__body">\n <div class="textae-editor__annotation-box"></div>\n <svg\n namespace="http://www.w3.org/2000/svg"\n class="textae-editor__relation-box">\n </svg>\n <div class="textae-editor__text-box"></div>\n </div>\n ';return t.innerHTML=n.replace(/[\n\r]+/g,""),function(t){new MutationObserver(e=>{e.forEach(e=>{e.removedNodes.length&&1===e.removedNodes[0].nodeType&&(e.removedNodes[0].classList.contains("textae-editor__span")||e.removedNodes[0].classList.contains("textae-editor__type"))&&"BODY"===document.activeElement.tagName&&t.focus()})}).observe(t.querySelector(".textae-editor__body"),{childList:!0,subtree:!0})}(t),new Ot(t,e,i)}function xt(t,e){const i=new URL(t,location);return i.searchParams.append("term",e),fetch(i.href).then(t=>t.ok?t.json():[])}class wt{#T;#I;#H;#V;constructor(t,e,i,n){this.#T=t,this.#I=e,this.#H=i,this.#V=n}get id(){return this.#T}get color(){return this.#I}get label(){return this.#H}get default(){return this.#V}toJSON(){return{id:this.#T,color:this.#I,label:this.#H,default:this.#V}}}function _t(t,e){for(const[e,i]of t.entries())t.set(e,{...i,usage:0});return e.reduce((t,{typeName:e})=>(t.get(e).usage+=1,t),t)}class St{#Y;constructor(t=[]){this.#Y=t.map(t=>new wt(t.id,t.color,t.label,t.default))}has(t){return this.map.has(t)}get default(){return this.#Y.find(t=>!0===t.default)}replace(t,e){e=new wt(e.id,e.color,e.label,e.default);const i=this.#Y.findIndex(e=>e.id===t);-1!==i?this.#Y.splice(i,1,e):this.#Y.push(e)}delete(t){this.#Y=this.#Y.filter(e=>e.id!==t)}ids(){return this.map.keys()}getColorOf(t){return this.#U(t)?.color}getLabelOf(t){return this.#U(t)?.label}labelsIncludes(t){return this.#Y.filter(t=>t.label).filter(e=>e.label.includes(t))}get map(){return new Map(this.#Y.map(t=>[t.id,t]))}#U(t){if(this.has(t))return this.map.get(t);const e=function(t,e){const i=function(t,e){const i=[];for(const n of t)-1!==n.indexOf("*")&&0===e.indexOf(n.slice(0,-1))&&i.push(n);return i}(t,e);return 0===i.length?null:function(t){let e="";for(const i of t)i.length>e.length&&(e=i);return e}(i)}(this.ids(),t);return this.map.get(e)}}function kt(t){const e=Array.from(t.keys());return e.sort((e,i)=>{const n=t.get(i).usage-t.get(e).usage;return 0!==n?n:e>i?1:e<i?-1:0}),e}class $t{#l;#G;#h=new St([]);#c;#K;#J;#tt="";#et;constructor(t,e,i,n){this.#l=t,this.#G=e,this.#c=i,this.#K=n}set autocompletionWs(t){this.#tt=t}set autocompletionFunction(t){this.#et=t}get autocompletionWs(){return this.#tt}get annotationType(){return this.#G}get config(){const t=this.#it;for(const[e,i]of t.entries()){const n=i.toJSON();i.id===this.defaultType?n.default=!0:delete n.default,t.set(e,n)}return[...t.values()]}set config(t){this.#h=new St(t);const e=this.#h.default;e?(delete e.default,this.#J=e.id):this.#J=null}has(t){return this.#h.has(t)}get(t){const e=this.#h.map.get(t).toJSON();return this.#J===t?(e.default=!0,e):(delete e.default,e)}replace(t,e){this.#h.replace(t,e),this.#l.emit(`textae-event.type-definition.${this.#G}.change`,e.id)}addDefinedType(t){if(void 0===t.color){const e=this.getColor(t.id);e!==this.#K&&(t.color=e)}if(void 0===t.label){const e=this.getLabel(t.id);e&&(t.label=e)}t.default&&(this.#J=t.id),this.replace(t.id,t)}get defaultType(){return this.#J?this.#J:this.#c().length>0?kt(_t(this.#it,this.#c()))[0]:"something"}set defaultType(t){this.#J=t,this.#l.emit(`textae-event.type-definition.${this.#G}.change-default`,t)}get defaultColor(){return this.#K}getColor(t){return this.#h.getColorOf(t)||this.#K}getLabel(t){return this.#h.getLabelOf(t)}getURI(t){return ct(t)?t:void 0}searchByLabel(t,e){if("function"==typeof this.#et){const i=this.#et(t),n=this.mergeWithLocalData(i,t);return void e(n)}this.#tt?xt(this.#tt,t).then(i=>{const n=this.mergeWithLocalData(i,t);e(n)}):e(this.findByLabel(t))}findByLabel(t){return this.#h.labelsIncludes(t)}mergeWithLocalData(t,e){const i=this.findByLabel(e),n=(t||[]).filter(t=>!i.some(e=>t.id===e.id));return i.concat(n)}get pallet(){const t=_t(this.#it,this.#c());return function(t,e,i,n,o){return t.map(t=>({id:t,label:i.getLabelOf(t)||void 0,defaultType:t===n,uri:ct(t)?t:void 0,color:i.getColorOf(t)||o,useNumber:e.get(t).usage}))}(kt(t),t,this.#h,this.defaultType,this.#K)}get#it(){const t=this.#h.map;for(const{typeName:e}of this.#c())t.has(e)||t.set(e,new wt(e));return t}delete(t,e){this.#h.delete(t),this.#J=e,this.#l.emit(`textae-event.type-definition.${this.#G}.delete`,t)}}class Tt{#nt;#ot;constructor(t,e=[]){this.#nt=t,this.#ot=e}get typeName(){return this.#nt}get attributes(){return this.#ot}get externalFormat(){return{obj:this.#nt,attributes:this.#ot.map(({externalFormat:t})=>t)}}isSameType(t,e=null){return e?this.typeName===t&&this._hasSameAttributes(e):this.typeName===t}hasSpecificPredicateAttribute(t){return this.attributes.some(e=>e.pred===t)}_hasSameAttributes(t){if(t.length!=this.attributes.length)return!1;const e=[...t];for(const t of this.attributes){const i=e.findIndex(e=>e.pred===t.pred&&e.obj===String(t.obj));if(-1===i)return!1;e.splice(i,1)}return 0===e.length||void 0}}function Ct(t){return Math.round(100*t)/100}const Pt="textae-editor__signboard--selected",Et="textae-editor__signboard--cutting";class At{#st;#rt;constructor(t,e,i){this.#st=t,this.#rt=u().create(this.#at(i,e))}get element(){return this.#rt}addEventListener(t,e){this.#rt.addEventListener(t,e)}hover(){this.#rt.classList.add("textae-editor__signboard--hovered")}select(){this.#rt.classList.add(Pt)}deselect(){this.#rt.classList.remove(Pt)}startCut(){this.#rt.classList.add(Et)}cancelCut(){this.#rt.classList.remove(Et)}clearCSSClass(){this.element.className="",this.element.classList.add("textae-editor__signboard")}updateLabel(){const t=this.element.querySelector(".textae-editor__signboard__type-values");t.style.backgroundColor=ut(this.#st.color,.4),t.querySelector(".textae-editor__signboard__type-label").innerHTML=st`${this.#st.anchorHTML}`;for(const e of t.querySelectorAll(".textae-editor__signboard__attribute"))e.remove();for(const e of this.#st.attributes)t.insertAdjacentHTML("beforeend",st`${e.contentHTML}`)}clarifyLabel(){this.element.querySelector(".textae-editor__signboard__type-label").style.backgroundColor=dt();for(const t of this.#st.attributes)t.clarifyLabelIn(this.element)}declarifyLabel(){this.element.querySelector(".textae-editor__signboard__type-label").style.backgroundColor=ut(this.#st.color,1);for(const t of this.#st.attributes)t.declarifyLabelIn(this.element)}focus(){this.#rt.querySelector(".textae-editor__signboard__type-label").focus()}replaceWith(t){return this.#rt.replaceWith(t.element),t}reflectTypeGapInTheHeight(t){this.#rt.setAttribute("style",`padding-top: ${t}px;`)}remove(){this.#rt.remove()}#at(t,e){return st`
189
189
  <div
190
190
  class="textae-editor__signboard"
191
191
  ${t?`id="${t}"`:""}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pubann/textae",
3
3
  "description": "text annotation editor",
4
- "version": "14.3.1",
4
+ "version": "14.3.2",
5
5
  "author": "jdkim",
6
6
  "bugs": {
7
7
  "url": "https://github.com/pubannotation/textae/issues"