@pubann/textae 14.1.1 → 14.2.0

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.
@@ -207,7 +207,7 @@ var i,n=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?
207
207
  ${this.#Et.attributes.map(t=>t.contentHTML)}
208
208
  </div>
209
209
  </div>
210
- `}}class Ft{#c;#mt;#Qt;#Dt;#Rt;#It;constructor(t,e,i,n,s,o){this.#c=I(t),this.#mt=e,this.#Qt=i,this.#Dt=l().create('<div class="textae-editor__relation__signboard-location"></div>'),this.#Lt(),this.#Rt=new Zt(e,"relation",null),this.#Dt.appendChild(this.#Rt.element),this.#c.appendChild(this.#Dt),this.#Dt.addEventListener("click",n),this.#Dt.addEventListener("mouseenter",s),this.#Dt.addEventListener("mouseleave",o)}updateValue(){this.#Lt(),this.#Rt.updateLabel()}updateHighlighting(){this.#Lt(),this.#Rt.clearCSSClass(),this.#mt.isSelected?this.#Rt.select():this.#mt.isHovered&&this.#Rt.hover()}destructor(){this.#c.removeChild(this.#Dt)}get y(){return this.#It.getBBox().y}get width(){return this.#Dt.getBBox().width}get height(){return this.#Dt.getBBox().height}#Lt(){this.#Dt.style.width="0px",this.#Dt.style.left=`${this.#Qt.highestX}px`,this.#Dt.style.top=this.#Qt.top-18-18*this.#mt.attributes.length+"px"}}class Xt{#Q;#Nt;#U;#jt;#H;#ft;#W;#Y;#K;#J;#gt;#u;#zt;#Qt;#Bt;constructor(t,e,i,n,s,{id:o,pred:r,subj:a,obj:l},c,h){this.#Q=t,this.#Nt=e,this.#U=i,this.#jt=n,this.#H=o,this.#W=a,this.#Y=l,this.#K=s,this.#J=c,this.#gt=h,this.#u=!1,this.#zt=!1,this.typeName=r}get id(){return this.#H}set id(t){this.#H=t}get typeName(){return this.#ft}set typeName(t){this.#ft=String(t)}get typeValues(){return new Ot(this.#ft,this.#jt.getAttributesFor(this.#H))}get subj(){return this.#W}get obj(){return this.#Y}get attributes(){return this.#jt.getAttributesFor(this.#H)}get sourceEntity(){return this.#U.get(this.subj)}get targetEntity(){return this.#U.get(this.obj)}get sourceColor(){return this.sourceEntity.color}get targetColor(){return this.targetEntity.color}get isSelected(){return this.#u}get isHovered(){return this.#zt}select(){this.#u||(this.#u=!0,this.#Bt&&this.#Bt.updateHighlighting())}deselect(){this.#u&&(this.#u=!1,(this.#Qt||this.#Bt)&&this.redrawLineConsideringSelection())}render(t,e){this.sourceEntity.isInViewport(t,e)||this.targetEntity.isInViewport(t,e)?(this.#Qt?this.#qt():(this.#Qt=new zt(this.#Q,this,this.#gt,t=>{this.#Nt.emit("textae-event.editor.relation.click",t,this),t.stopPropagation()},(t,e)=>{this.#Nt.emit("textae-event.editor.relation-bollard.click",t,e),t.stopPropagation()},()=>this.#Zt(),()=>this.#Ft()),this.#Bt=new Ft(this.#Q,this,this.#Qt,(t,e)=>{this.#Nt.emit("textae-event.editor.relation.click",t,this,e),t.stopPropagation()},()=>this.#Zt(),()=>this.#Ft())),this.sourceEntity.clientTop>this.targetEntity.clientTop&&this.targetEntity.isInViewport(t,e)||this.sourceEntity.clientTop<this.targetEntity.clientTop&&this.sourceEntity.isInViewport(t,e)||this.sourceEntity.clientTop===this.targetEntity.clientTop?this.#Bt?this.#Xt():(this.#Bt=new Ft(this.#Q,this,this.#Qt,(t,e)=>{this.#Nt.emit("textae-event.editor.relation.click",t,this,e),t.stopPropagation()},()=>this.#Zt(),()=>this.#Ft()),this.#Bt.updateHighlighting()):this.#Bt&&(this.#Bt.destructor(),this.#Bt=void 0)):(this.#Qt||this.#Bt)&&this.erase()}updateElement(){this.#Qt&&this.#Qt.update(this.isSelected,this.isSelected,this.isSelected),this.#Bt&&this.#Bt.updateValue()}redrawLineConsideringSelection(){this.#qt(),this.#Xt()}pointUpPathAndSourceBollards(){this.#Qt&&(this.targetEntity.isSelected?this.#Qt.update(!0,!0,!0):this.#Qt.update(!0,!0,this.isSelected)),this.#Bt&&this.#Bt.updateHighlighting()}pointUpPathAndTargetBollards(){this.#Qt&&(this.sourceEntity.isSelected?this.#Qt.update(!0,!0,!0):this.#Qt.update(!0,this.isSelected,!0)),this.#Bt&&this.#Bt.updateHighlighting()}pointUpSourceBollardsAndTargetBollards(){this.#Qt&&this.#Qt.update(this.isSelected,!0,!0),this.#Bt&&this.#Bt.updateHighlighting()}pointUpSourceBollards(){this.#Qt&&this.#Qt.update(this.isSelected,!0,this.isSelected),this.#Bt&&this.#Bt.updateHighlighting()}pointUpTargetBollards(){this.#Qt&&this.#Qt.update(this.isSelected,this.isSelected,!0),this.#Bt&&this.#Bt.updateHighlighting()}erase(){this.#Qt&&(this.#Qt.destructor(),this.#Qt=void 0),this.#Bt&&(this.#Bt.destructor(),this.#Bt=void 0)}get title(){return`[${this.id}] pred: type, value: ${this.typeName}`}get color(){return this.#J.getColor(this.typeName)}get anchorHTML(){return pt(this.#lt,this.#nt)}get#lt(){return ht(this.#K,this.typeName,this.#J.getLabel(this.typeName))}get#nt(){return ft(this.#K,this.typeName,this.#J.getURI(this.typeName))}#Zt(){this.#zt=!0,this.#Qt.update(!0,!0,!0),this.#Bt&&this.#Bt.updateHighlighting();const t=new Set,e=new Set,i=new Set;for(const i of this.sourceEntity.relationsWhereThisIsSource)i!==this&&(i.targetEntity==this.targetEntity?t.add(i):e.add(i));for(const e of this.sourceEntity.relationsWhereThisIsTarget)e!==this&&(e.sourceEntity==this.targetEntity?t.add(e):i.add(e));for(const i of this.targetEntity.relationsWhereThisIsSource)i!==this&&(i.targetEntity==this.sourceEntity?t.add(i):e.add(i));for(const e of this.targetEntity.relationsWhereThisIsTarget)e!==this&&(e.sourceEntity==this.sourceEntity?t.add(e):i.add(e));for(const e of t)e.pointUpSourceBollardsAndTargetBollards();for(const t of e)t.pointUpSourceBollards();for(const t of i)t.pointUpTargetBollards()}#Ft(){this.#zt=!1;const t=new Set;for(const e of this.sourceEntity.relations)t.add(e);for(const e of this.targetEntity.relations)t.add(e);for(const e of t)e.redrawLineConsideringSelection()}#qt(){this.#Qt&&(this.sourceEntity.isSelected&&this.targetEntity.isSelected?this.#Qt.update(!0,!0,!0):this.sourceEntity.isSelected?this.#Qt.update(!0,!0,this.isSelected):this.targetEntity.isSelected?this.#Qt.update(!0,this.isSelected,!0):this.#Qt.update(this.isSelected,this.isSelected,this.isSelected))}#Xt(){this.#Bt&&this.#Bt.updateHighlighting()}}class Ht extends gt{#Q;#Nt;#Ht;#K;#J;#gt;constructor(t,e,i,n){super(e,"relation",()=>"R"),this.#Q=t,this.#Nt=e,this.#Ht=i,this.#K=i.namespaceInstanceContainer,this.#J=n}set toolBarHeight(t){this.#gt=t}_toInstance(t){return new Xt(this.#Q,this.#Nt,this.#Ht.entityInstanceContainer,this.#Ht.attributeInstanceContainer,this.#K,t,this.#J,this.#gt)}add(t){t=t instanceof Xt?t:new Xt(this.#Q,this.#Nt,this.#Ht.entityInstanceContainer,this.#Ht.attributeInstanceContainer,this.#K,t,this.#J,this.#gt);const e=super.add(t),{clientHeight:i,clientWidth:n}=document.documentElement;return e.render(i,n),e}changeType(t,e){const i=super.changeType(t,e);return i.updateElement(),i}remove(t){console.assert(t,"id is necessary!");super.remove(t).erase()}clear(){for(const t of this.all)t.erase();super.clear()}}class Wt{#M;#H;#jt;#G;#K;#Wt;#Vt;#gt;#u=!1;#zt=!1;#Yt=!1;#Rt=null;#Ut;#ft;constructor(t,e,i,n,s,o,r,a,l,c=null){this.#M=t,this.#H=c,this.#jt=e,this.#G=i,this.#Wt=s,this.#Vt=o,this.#K=n,this.#gt=l,this.span=r,this.typeName=a}get id(){return this.#H}set id(t){this.#H=t}get title(){return`[${this.id}] pred: type, value: ${this.#ft}`}get color(){return this.#J.getColor(this.typeName)}get anchorHTML(){return pt(this.#lt,this.#nt)}get span(){return this.#Ut}set span(t){this.#Ut=t,t.add(this)}get typeName(){return this.#ft}set typeName(t){this.#ft=String(t)}get typeValues(){return new Ot(this.#ft,this.#jt.getAttributesFor(this.#H))}get relations(){return this.relationsWhereThisIsSource.concat(this.relationsWhereThisIsTarget)}get attributes(){return this.#jt.getAttributesFor(this.#H)}get relationsWhereThisIsSource(){return this.#G.all.filter(t=>t.subj===this.id)}get relationsWhereThisIsTarget(){return this.#G.all.filter(t=>t.obj===this.id)}get hasMultipleEndpoints(){const t=new Map;t.set("whereThisIsSourceAndTargetIsOnTheLeft",new Set),t.set("whereThisIsSourceAndTargetIsOnTheRight",new Set),t.set("whereThisIsSourceAndTargetIsUpOrDown",new Set);for(const e of this.relationsWhereThisIsSource)e.targetEntity.offsetCenter<this.offsetCenter?t.get("whereThisIsSourceAndTargetIsOnTheLeft").add(e):this.offsetCenter<e.targetEntity.offsetCenter?t.get("whereThisIsSourceAndTargetIsOnTheRight").add(e):t.get("whereThisIsSourceAndTargetIsUpOrDown").add(e);t.set("whereThisIsTargetAndSourceIsOnTheLeft",new Set),t.set("whereThisIsTargetAndSourceIsOnTheRight",new Set),t.set("whereThisIsTargetAndSourceIsUpOrDown",new Set);for(const e of this.relationsWhereThisIsTarget)e.sourceEntity.offsetCenter<this.offsetCenter?t.get("whereThisIsTargetAndSourceIsOnTheLeft").add(e):this.offsetCenter<e.targetEntity.offsetCenter?t.get("whereThisIsTargetAndSourceIsOnTheRight").add(e):t.get("whereThisIsTargetAndSourceIsUpOrDown").add(e);return[...t.values()].filter(t=>t.size).length>1}get clientTop(){const{span:t}=this;if(t.isDenotation){let e=t.clientTopOfGrid+this.#Wt.height;for(const i of t.entities){if(i===this)break;e+=this.#Wt.height+i.height}return T(e)}if(t.isBlock){const e=15;return T(t.clientBottomOfGrid-this.height-e)}throw new Error("Unexpected type of span")}get offsetTop(){return this.clientTop-this.span.element.offsetParent.offsetParent.getBoundingClientRect().top}get clientBottom(){return this.clientTop+this.height}isInViewport(t){return this.#gt<=this.clientBottom&&this.clientTop<=t}get width(){return this.span.widthOfGrid}get height(){return 18+this.#Gt}get heightWithTypeGap(){return this.height+this.#Wt.height}get offsetCenter(){return T(this.span.offsetCenterOfGrid)}get isDenotation(){return this.#Ut.isDenotation}get isBlock(){return this.#Ut.isBlock}get isSelected(){return this.#u}getSourceAnchorPosition(t){const e=this.width/2>=28||this.hasMultipleEndpoints&&t;return{left:e?this.offsetCenter-24:this.offsetCenter,right:e?this.offsetCenter+24:this.offsetCenter}}getTargetAnchorPosition(t){const e=this.width/2>=28||this.hasMultipleEndpoints&&t;return{left:e?this.offsetCenter-8:this.offsetCenter,right:e?this.offsetCenter+8:this.offsetCenter}}focus(){if(this.isDenotation)this.span.focus();else{if(!this.isBlock)throw new Error("Unexpected type of entity");this.span.forceRenderGrid(),this.#Rt.focus()}}select(){this.#u||(this.#u=!0,this.#Kt(),this.#Jt())}deselect(){this.#u&&(this.#u=!1,this.#Rt&&this.#Rt.deselect(),this.#Jt())}startCut(){this.#Rt&&this.#Rt.startCut()}cancelCut(){this.#Rt&&this.#Rt.cancelCut()}render(){if(!this.#Rt&&this.span.isGridRendered){this.#Rt=this.#te(),this.span.addEntityElementToGridElement(this.#Rt.element),this.reflectTypeGapInTheHeight();for(const t of this.span.entities.filter(t=>t!==this))for(const e of t.relations)e.redrawLineConsideringSelection();this.#u&&this.#Rt.select()}}updateElement(){if(this.#Rt){this.#Rt=this.#Rt.replaceWith(this.#te()),this.#u&&this.#Kt(),this.reflectTypeGapInTheHeight(),this.span.updateSelfAndAncestorsGridPosition();for(const t of this.span.entities)for(const e of t.relations)e.redrawLineConsideringSelection()}}reflectTypeGapInTheHeight(){this.isDenotation&&this.#Rt&&this.#Rt.reflectTypeGapInTheHeight(this.#Wt.height)}clarifyLabel(){this.#Rt&&this.#Rt.clarifyLabel(),this.#Yt=!0}declarifyLabel(){!this.#zt&&this.#Rt&&this.#Rt.declarifyLabel(),this.#Yt=!1}erase(){this.#Rt&&(this.#Rt.remove(),this.#Rt=null,this.span.updateSelfAndAncestorsGridPosition())}#te(){const t=new Zt(this,this.isDenotation?"denotation":"block",`${this.#M}__E${this.id.replace(/[:¥.]/g,"")}`);return t.addEventListener("mouseenter",()=>{t.clarifyLabel(),this.#ee(),this.#zt=!0}),t.addEventListener("mouseleave",()=>{this.#Yt||t.declarifyLabel(),this.#Jt(),this.#zt=!1}),t}#Kt(){this.span.forceRenderGrid(),this.#Rt.select(),this.span.isGridBeforePositioned?this.span.entityToFocusOn=this:this.focus()}get#J(){if(this.isDenotation)return this.#Vt.denotation;if(this.isBlock)return this.#Vt.block;throw"unknown entity type"}get#lt(){return ht(this.#K,this.typeName,this.#J.getLabel(this.typeName))}get#nt(){return ft(this.#K,this.typeName,this.#J.getURI(this.typeName))}get#Gt(){return this.attributes.map(({height:t})=>t).reduce((t,e)=>t+e,0)}#ee(){for(const t of this.relationsWhereThisIsSource)t.pointUpPathAndSourceBollards();for(const t of this.relationsWhereThisIsTarget)t.pointUpPathAndTargetBollards()}#Jt(){for(const t of this.relations)t.redrawLineConsideringSelection()}}class Vt extends gt{#M;#Ht;#Wt;#K;#gt;constructor(t,e,i,n){super(e,"entity",t=>t.isDenotation?"T":"B"),this.#M=t,this.#Ht=i,this.#Wt=n,this.#K=i.namespaceInstanceContainer}get#T(){return this.#Ht.spanInstanceContainer}get#jt(){return this.#Ht.attributeInstanceContainer}get#G(){return this.#Ht.relationInstanceContainer}set toolBarHeight(t){this.#gt=t}_toInstance(t,e){const i=this.#ie(e,t);return new Wt(this.#M,this.#jt,this.#G,this.#K,this.#Wt,this.#Ht.typeDictionary,i,t.obj,this.#gt,t.id)}add(t){if(t instanceof Wt){if(!t.span)throw new Error(`entity has no span! ${JSON.stringify(t)}`);return super.add(t),t.span.add(t),t.render(),t}if(void 0===t.spanType||void 0===t.begin||void 0===t.end)throw new Error(`entity has no span information! ${JSON.stringify(t)}`);const e=this.#T.find(t.spanType,t.begin,t.end),i=new Wt(this.#M,this.#jt,this.#G,this.#K,this.#Wt,this.#Ht.typeDictionary,e,t.typeName,this.#gt);return console.assert(i.span.isDenotation||i.span.entities.length>0,"A block span cannot have more than one entity."),super.add(i),i.render(),i}remove(t){const e=super.get(t);e.span.remove(e),super.remove(t),e.erase()}changeType(t,e){const i=super.changeType(t,e);return i.updateElement(),i}moveEntities(t,e){for(const i of e){i.erase();const e=i.span;e.remove(i),e.updateSelfAndAncestorsGridPosition(),i.span=t,i.render();for(const t of i.relations)t.redrawLineConsideringSelection()}super._emit("textae-event.annotation-data.entity.move")}get denotations(){return this.all.filter(t=>t.isDenotation)}get blocks(){return this.all.filter(t=>t.isBlock)}redrawEntitiesWithSpecifiedAttribute(t){const e=this.all.filter(e=>e.typeValues.hasSpecificPredicateAttribute(t));for(const t of e)t.updateElement();for(const t of new Set([...e.map(({span:t})=>t)]))t.updateGridPosition()}clarifyLabelOfAll(){for(const t of this.all)t.clarifyLabel()}declarifyLabelOfAll(){for(const t of this.all)t.declarifyLabel()}#ie(t,e){return this.#T.find(t,e.span.begin,e.span.end)}hasDenotation(t){return this.denotations.some(e=>e.id===t)}}class Yt{constructor(t){this._trackNumber=t}addTrackNumberAsIDPrefix(t,e,i,n){const s=t.map(t=>({...t,id:this._prependToIDOf(t)})),o=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:s,blocks:o,relations:a,attributes:r}}_prependToIDOf(t){return t.id?this._prependTrackNumberTo(t.id):null}_prependTrackNumberTo(t){return this._trackNumber+t}}function Ut(t){const{span:e}=t;return{...t,span:Gt(e)}}function Gt(t){return{...t,begin:parseInt(t.begin),end:parseInt(t.end)}}function Kt(t,e,i,n,s,o=""){const[r,a,l]=function(t,e,i){return[t.map(Ut),e.map(Ut),i.map(Ut)]}(s.typeSetting,s.denotation,s.block),{relation:c,attribute:h}=s,{denotations:u,blocks:d,relations:f,attributes:p}=new Yt(o).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 Jt(t,e){return 0<=t&&t<=e.length}class te{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 ee(t,e){return e.reduce((e,i)=>e.concat(i.getErrors(t)),[])}class ie{constructor(t,e,i="",n=()=>!0,s){this._candidates=t||[],this._name=i,this._predicate=n,this._prevValidation=s,this._sourcePropertyName=e}and(t,e){return new ie(this._candidates,this._sourcePropertyName,t,e,this)}validateAll(){const t=new te;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 ne(t,e,i,n){return new ie(t,n).and("hasLength",t=>t.span.end-t.span.begin>0).and("inText",t=>function(t,e){return Jt(e.begin,t)&&Jt(e.end,t)}(e,t.span)).and("isNotCrossing",t=>{const e=H(i,t.span.begin,t.span.end);return[0===e.length,e]})}function se(t,e){return t.some(t=>t.id===e)}function oe(t,e){return void 0===e.id||1===t.filter(t=>e.id&&e.id===t.id).length}function re(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(", ")}`)}function ae(t){const{typesettings:e,denotations:i,blocks:n}=t;return(e||[]).concat(i||[]).concat(n||[])}function le(t,e,i){const[n,s]=function(t,e,i){return ne(e,t,i,"typesettings").validateAll()}(t,i.typesettings,e),o=ae(i),[r,a]=function(t,e,i,n){return ne(e,t,i,"denotations").and("uniqueID",t=>oe(n,t)).validateAll()}(t,i.denotations,e,o),[l,c]=function(t,e,i,n){return ne(e,t,i,"blocks").and("uniqueID",t=>oe(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,o),[h,u]=(d=r.concat(l),f=i.relations,new ie(f).and("object",t=>se(d,t.obj)).and("subject",t=>se(d,t.subj)).validateAll());var d,f;const[p,m]=(g=r.concat(l).concat(h),v=i.attributes,new ie(v).and("subject",t=>se(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 re("TypeSettings",s),re("Denotations",a),re("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:s.getErrors("hasLength"),outOfTextTypesettings:s.getErrors("inText"),duplicatedIDs:ee("uniqueID",[a,c]),boundaryCrossingSpans:ee("isNotCrossing",[s,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||s.size}}}class ce{#K;#T;#U;#G;#jt;#ne;#se;#oe;constructor(t,e){const{namespaceInstanceContainer:i,spanInstanceContainer:n,entityInstanceContainer:s,attributeInstanceContainer:o,relationInstanceContainer:r}=t;this.#K=i,this.#T=n,this.#U=s,this.#G=r,this.#jt=o,this.#ne=e}eval(){this.#ne.namespaces?this.#K.addSource(this.#ne.namespaces.map(t=>({id:t.prefix,...t}))):this.#K.addSource([]);const{accept:t,reject:e}=le(this.#re,this.#ae,this.#ne);Kt(this.#T,this.#U,this.#jt,this.#G,t),e.name="Root annotations.",this.#se=e,this.hasMultiTracks&&(this.#oe=function(t,e,i,n,s,o,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}=le(s,o,r);return Kt(t,e,i,n,h,c),u.name=`Track ${l} annotations.`,u})}(this.#T,this.#U,this.#jt,this.#G,this.#re,this.#ae,this.#ne))}get hasMultiTracks(){return Boolean(this.#ne.tracks)}get rejects(){return this.hasMultiTracks?[this.#se].concat(this.#oe):[this.#se]}get#re(){return this.#ne.text}get#ae(){return function(t){let e=ae(t);if(t.tracks)for(const i of t.tracks)e=e.concat(ae(i));return e}(this.#ne)}}function he(t){return t.relationInstanceContainer.all.map(t=>({id:t.id,pred:t.typeName,subj:t.subj,obj:t.obj}))}function ue(t){return t.entityInstanceContainer.blocks.map(t=>({id:t.id,span:{begin:t.span.begin,end:t.span.end},obj:t.typeName}))}class de{constructor(t){this._isGapShown=!0,this._numberOfGap=1,this._callback=t}set show(t){this._isGapShown!==t&&(this._isGapShown=t,this._callback(this.value))}get show(){return this._isGapShown}get value(){return this._isGapShown?this._numberOfGap:0}get height(){return 24*this.value}set value(t){this._numberOfGap!==t&&(this._numberOfGap=t,this._callback(t))}}function fe(t){const e=parseInt(t,10);return isNaN(e)?0:e}class pe{#Q;#r;#Ht;#le;constructor(t,e,i){this.#Q=t,this.#r=t.querySelector(".textae-editor__text-box"),this.#Ht=e,this.#le=i}get boundingClientRect(){return this.#r.getBoundingClientRect()}get lineHeight(){return t=this.#r,fe(window.getComputedStyle(t).lineHeight);var t}set lineHeight(t){var e,i,n;e=this.#r,i=t,n=this.#le,e.style.lineHeight=`${i}px`,e.style.paddingTop=`${i/2+n}px`,this.forceUpdate(),this.#Ht.updatePosition()}render(t){this.#r.innerHTML=t.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#039;")}updateLineHeight(){const t=this.#Ht.spanInstanceContainer.maxHeight;t?this.lineHeight=t:this.#ce()}forceUpdate(){!function(t,e){const i=window.getComputedStyle(t);t.style.height="auto",t.style.height=`${t.offsetHeight-fe(i.paddingTop)+20+e}px`}(this.#r,this.#le),this.#he()}#ce(){const{lineHeight:t}=window.getComputedStyle(this.#Q);this.lineHeight=fe(t)}#he(){const t=this.#Q.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 me(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 pe(t,e,i)}var ge=i(504),ve=i.n(ge);class ye{#Nt;#ue;#de;#fe;#pe;#me=new(ve())(!1);constructor(t,e,i,n,s,o=!0){this.#Nt=t,this.#ue=e,this.#de=i,this.#fe=n,this.#pe=s,this.#me(()=>this.#Nt.emit("textae-event.type-definition.lock")),this.#me.set(o)}set autocompletionWs(t){this.#ue.autocompletionWs=t,this.#fe.autocompletionWs=t,this.#de.autocompletionWs=t}set autocompletionFunction(t){this.#ue.autocompletionFunction=t,this.#fe.autocompletionFunction=t,this.#de.autocompletionFunction=t}get denotation(){return this.#ue}get block(){return this.#de}get relation(){return this.#fe}get attribute(){return this.#pe}get autocompletionWs(){return this.#ue.autocompletionWs}get config(){const t={};return this.#ue.config.length&&(t["entity types"]=this.#ue.config),this.#fe.config.length&&(t["relation types"]=this.#fe.config),this.#pe.config.length&&(t["attribute types"]=this.#pe.config),this.#de.config.length&&(t["block types"]=this.#de.config),t}get isLock(){return this.#me()}lockEdit(){this.#me.set(!0)}unlockEdit(){this.#me.set(!1)}setTypeConfig(t){t?(this.#ue.config=t["entity types"],this.#fe.config=t["relation types"],this.#pe.config=t["attribute types"],this.#de.config=t["block types"],this.autocompletionWs=t.autocompletion_ws):(this.#ue.config=null,this.#fe.config=null,this.#pe.config=null,this.#de.config=null,this.autocompletionWs=""),this.#Nt.emit("textae-event.type-definition.reset")}}function Oe(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}function be(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 xe{#H;#st;#Bt;#ge;constructor(t,e,i,n){this.#H=t,this.#st=e,this.#Bt=i,this.#ge=n}get id(){return this.#H}get color(){return this.#st}get label(){return this.#Bt}get default(){return this.#ge}toJSON(){return{id:this.#H,color:this.#st,label:this.#Bt,default:this.#ge}}}class we{#ve;constructor(t=[]){this.#ve=t.map(t=>new xe(t.id,t.color,t.label,t.default))}has(t){return this.map.has(t)}get default(){return this.#ve.find(t=>!0===t.default)}replace(t,e){e=new xe(e.id,e.color,e.label,e.default);const i=this.#ve.findIndex(e=>e.id===t);-1!==i?this.#ve.splice(i,1,e):this.#ve.push(e)}delete(t){this.#ve=this.#ve.filter(e=>e.id!==t)}ids(){return this.map.keys()}getColorOf(t){return this.#ye(t)?.color}getLabelOf(t){return this.#ye(t)?.label}labelsIncludes(t){return this.#ve.filter(t=>t.label).filter(e=>e.label.includes(t))}get map(){return new Map(this.#ve.map(t=>[t.id,t]))}#ye(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 _e(t,e){const i=new URL(t,location);return i.searchParams.append("term",e),fetch(i.href).then(t=>t.ok?t.json():[])}class Se{#Nt;#Oe;#be=new we([]);#xe;#we;#_e;#Se="";#ke;constructor(t,e,i,n){this.#Nt=t,this.#Oe=e,this.#xe=i,this.#we=n}set autocompletionWs(t){this.#Se=t}set autocompletionFunction(t){this.#ke=t}get autocompletionWs(){return this.#Se}get annotationType(){return this.#Oe}get config(){const t=this.#$e;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.#be=new we(t);const e=this.#be.default;e?(delete e.default,this.#_e=e.id):this.#_e=null}has(t){return this.#be.has(t)}get(t){const e={...this.#be.map.get(t)};return this.#_e===t?(e.default=!0,e):(delete e.default,e)}replace(t,e){this.#be.replace(t,e),this.#Nt.emit(`textae-event.type-definition.${this.#Oe}.change`,e.id)}addDefinedType(t){if(void 0===t.color){const e=this.getColor(t.id);e!==this.#we&&(t.color=e)}if(void 0===t.label){const e=this.getLabel(t.id);e&&(t.label=e)}t.default&&(this.#_e=t.id),this.replace(t.id,t)}get defaultType(){return this.#_e?this.#_e:this.#xe().length>0?Oe(be(this.#$e,this.#xe()))[0]:"something"}set defaultType(t){this.#_e=t,this.#Nt.emit(`textae-event.type-definition.${this.#Oe}.change-default`,t)}get defaultColor(){return this.#we}getColor(t){return this.#be.getColorOf(t)||this.#we}getLabel(t){return this.#be.getLabelOf(t)}getURI(t){return ct(t)?t:void 0}searchByLabel(t,e){if("function"==typeof this.#ke){const i=this.#ke(t),n=this.mergeWithLocalData(i,t);return void e(n)}this.#Se?_e(this.#Se,t).then(i=>{const n=this.mergeWithLocalData(i,t);e(n)}):e(this.findByLabel(t))}findByLabel(t){return this.#be.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=be(this.#$e,this.#xe());return function(t,e,i,n,s){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)||s,useNumber:e.get(t).usage}))}(Oe(t),t,this.#be,this.defaultType,this.#we)}get#$e(){const t=this.#be.map;for(const{typeName:e}of this.#xe())t.has(e)||t.set(e,new xe(e));return t}delete(t,e){this.#be.delete(t),this.#_e=e,this.#Nt.emit(`textae-event.type-definition.${this.#Oe}.delete`,t)}}class ke{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}}class $e extends ke{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}}}function Ce(t,e){return t<=e}function Te(t,e){return t<e}function Pe(t){if(t.startsWith("["))return e=>Ce(new Number(t.replace("[","")),e);if(t.startsWith("("))return e=>Te(new Number(t.replace("(","")),e);throw`${t} is not valid interval notation`}function Ee(t){if(t.endsWith("]"))return e=>Ce(e,new Number(t.replace("]","")));if(t.endsWith(")"))return e=>Te(e,new Number(t.replace(")","")));throw`${t} is not valid interval notation`}class Ae{constructor(t){const[e,i]=t.split(",");if(i?(this._lowwerCond=Pe(e),this._upperCond=Ee(i)):((e.startsWith("[")||e.startsWith("("))&&(this._lowwerCond=Pe(e),this._upperCond=t=>!0),(e.endsWith("]")||e.endsWith(")"))&&(this._lowwerCond=t=>!0,this._upperCond=Ee(e))),!this._lowwerCond||!this._upperCond)throw`${t} is not valid interval notation`}test(t){return this._lowwerCond(t)&&this._upperCond(t)}}function Me(t){return!Number.isNaN(parseFloat(t))}class Qe extends ke{constructor(t,e){super(t,e.pred),this.default=Me(e.default)?parseFloat(e.default):0,Me(e.min)&&(this.min=parseFloat(e.min)),Me(e.max)&&(this.max=parseFloat(e.max)),this.step=Me(e.step)?parseFloat(e.step):2,this._values=e.values||[]}getLabel(t){const e=this.#Ce(t);if(e&&e.label)return e.label}getDisplayName(t){return this.getLabel(t)||String(t)}getColor(t){const e=this.#Ce(t);return e&&e.color?e.color:null}#Ce(t){const e=this._values.filter(t=>"default"!==t.range).find(e=>new Ae(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 De extends ke{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.#Ce(t);if(e&&e.label)return e.label}getDisplayName(t){return this.getLabel(t)}getColor(t){const e=this.#Ce(t);return e&&e.color?e.color:null}get values(){return this._values}get hasOnlyOneValue(){return 1===this._values.length}#Ce(t){return this.values.find(e=>e.id==t)}get externalFormat(){return{...super.externalFormat,"value type":"selection",values:super._valuesClone}}}class Re extends ke{constructor(t,e){super(t,e.pred),this.autocompletionWs=e.autocompletion_ws,this.default=e.default,Me(e["media height"])&&(this.mediaHeight=parseFloat(e["media height"])),this._values=e.values||[]}getLabel(t){const e=this.#Ce(t);if(e&&e.label)return e.label}getDisplayName(t){return this.getLabel(t)}getColor(t){const e=this.#Ce(t);return e&&e.color?e.color:null}#Ce(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 Ie(t,e){switch(t){case"flag":return new $e(t,e);case"numeric":return new Qe(t,e);case"selection":return new De(t,e);case"string":return new Re(t,e);default:throw new Error(`${t} of ${JSON.stringify(e)} is Uknown Attribute`)}}class Le{#Nt;#xe;#be=new Map;constructor(t,e){this.#Nt=t,this.#xe=e}get config(){return this.attributes.map(t=>t.externalFormat)}set config(t){this.#be=new Map((t||[]).map(t=>[t.pred,Ie(t["value type"],t)]))}create(t,e,i=null){null!==i&&this.#be.size!==i?this.#be=new Map(Array.from(this.#be.entries()).reduce((n,[s,o],r)=>(r===i&&n.push([e.pred,Ie(t,e)]),n.push([s,o]),n),[])):this.#be.set(e.pred,Ie(t,e)),this.#Nt.emit("textae-event.type-definition.attribute.create",e.pred)}get(t){return this.#be.get(t)}update(t,e){return this.#be=new Map(Array.from(this.#be.entries()).map(([i,n])=>i===t?[e.pred,Ie(n.valueType,e)]:[i,n])),this.#Nt.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,s;this.#be=new Map((i=this.attributes,n=t,s=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,[s]=t.splice(e,1);t.splice(n,0,s)}}(i=[...i],n,s),i).map(t=>[t.pred,t]));const{pred:o}=this.attributes[-1===e?this.attributes.length-1:e];this.#Nt.emit("textae-event.type-definition.attribute.move",o)}delete(t){this.#be.delete(t),this.#Nt.emit("textae-event.type-definition.attribute.delete")}get attributes(){return Array.from(this.#be.values())||[]}isSelectionAttributeValueIndelible(t,e){return!!this.get(t).hasOnlyOneValue||!!this.#xe().some(i=>i.equalsTo(t,e))}getLabel(t,e){return console.assert(this.#be.has(t),`There is no attribute definition for ${t}.`),this.get(t).getLabel(e)}getDisplayName(t,e){return console.assert(this.#be.has(t),`There is no attribute definition for ${t}.`),this.get(t).getDisplayName(e)}getColor(t,e){if(this.#be.has(t))return this.get(t).getColor(e)}getIndexOf(t){return Array.from(this.#be.values()).findIndex(e=>e.pred===t)}getAttributeAt(t){return Array.from(this.#be.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}}class Ne{constructor(t,e){this._textBox=e,this._enable=!1,t.on("textae-event.control.button.push",({name:t,isPushed:e})=>{"auto adjust lineheight"===t&&(this._enable=e)})}updateLineHeight(){this._enable&&this._textBox.updateLineHeight()}}function je(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}class ze{#Te;#Wt;#O;#Pe;#K;#T;#U;#G;#jt;#Vt;#Q;#Nt;constructor(t,e,i,n,s,o,r,a){this.#Te="",this.#K=new w(i,"namespace");const l=new Se(i,"relation",()=>this.#G.all,"#00CC66");this.#G=new Ht(e,i,this,l),this.#Wt=new de(()=>{for(const t of this.entityInstanceContainer.denotations)t.reflectTypeGapInTheHeight();this.#O.updateLineHeight(),i.emit("textae-event.annotation-data.entity-gap.change")}),this.#U=new Vt(t,i,this,this.#Wt),this.attributeDefinitionContainer=new Le(i,()=>this.#jt.all),this.#jt=new yt(i,this.#U,this.#G,this.#K,this.attributeDefinitionContainer),this.updatePosition=()=>{try{n.startWait(),s(),this.#Ee()}catch(t){console.error(t)}finally{n.endWait(),o()}},this.#O=me(e,this,a),this.#Pe=new Ne(i,this.#O),this.#T=new it(t,e,i,this.#O),je(this,()=>this.#T,["getDenotationSpan","isBoundaryCrossingWithOtherSpans","hasParentOf","validateNewDenotationSpan","validateNewBlockSpan","validateEditableText"]),this.denotationDefinitionContainer=new Se(i,"entity",()=>this.#U.denotations,"#77DDDD");const c=new Se(i,"entity",()=>this.#U.blocks,"#77DDDD");this.#Vt=new ye(i,this.denotationDefinitionContainer,c,l,this.attributeDefinitionContainer,r),i.on("textae-event.annotation-data.span.add",t=>{(t.isDenotation||t.isBlock)&&(this.#O.forceUpdate(),this.#Ee())}).on("textae-event.annotation-data.span.remove",t=>{(t.isDenotation||t.isBlock)&&(this.#O.forceUpdate(),this.#Ee())}).on("textae-event.annotation-data.entity.add",t=>{t.span.isDenotation&&this.#Pe.updateLineHeight()}).on("textae-event.annotation-data.entity.remove",t=>{t.span.isDenotation&&this.#Pe.updateLineHeight()}),i.on("textae-event.type-definition.entity.change",t=>{for(const e of this.#U.all)(e.typeName===t||t.lastIndexOf("*")===t.length-1&&e.typeName.indexOf(0===t.slice(0,-1)))&&e.updateElement()}).on("textae-event.type-definition.attribute.change",t=>this.#U.redrawEntitiesWithSpecifiedAttribute(t)).on("textae-event.type-definition.attribute.move",t=>this.#U.redrawEntitiesWithSpecifiedAttribute(t)).on("textae-event.type-definition.relation.change",t=>{for(const e of this.#G.all)(e.typeName===t||t.lastIndexOf("*")===t.length-1&&e.typeName.indexOf(0===t.slice(0,-1)))&&e.updateElement()}),this.#Q=e,this.#Nt=i}reset(t,e){console.assert(t.text,"This is not a json file of annotations."),this.#Vt.setTypeConfig(e),this.#Te=t.text,this.#O.render(this.sourceDoc),this.#Ae();const i=new ce(this,t);i.eval(),this.#Me(),this.#Nt.emit("textae-event.annotation-data.all.change",i.hasMultiTracks,i.rejects),this.reLayout()}set autocompletionFunction(t){this.#Vt.autocompletionFunction=t}get externalFormat(){return{text:this.#Te,denotations:(t=this,t.entityInstanceContainer.denotations.map(t=>({id:t.id,span:{begin:t.span.begin,end:t.span.end},obj:t.typeName}))),attributes:this.#jt.all.map(({externalFormat:t})=>t),relations:he(this),blocks:ue(this)};var t}getReplicationRanges(t,e){return function(t,e,i,n,s){return function(t,e,i){const n=t.substring(e,i),s=i-e,o=[];let r=0;for(let e=t.indexOf(n);-1!==e;e=t.indexOf(n,r))r=e+s,o.push({begin:e,end:r});return o}(t,e,i).filter(({begin:t})=>t!==e).filter(({begin:e,end:i})=>function(t,e,i,n){const s=t.charAt(e-1),o=t.charAt(i);return n(s)&&n(o)}(t,e,i,s)).filter(({begin:t,end:e})=>!n.find("denotation",t,e)).filter(({begin:t,end:e})=>!n.isBoundaryCrossingWithOtherSpans(t,e))}(this.sourceDoc,t.begin,t.end,this.#T,e)}get typeGap(){return this.#Wt}get textBox(){return this.#O}get sourceDoc(){return this.#Te.replaceAll(/\r\n/g," \n")}get typeDictionary(){return this.#Vt}get spanInstanceContainer(){return this.#T}getSpan(t){return this.#T.get(t)}get entityInstanceContainer(){return this.#U}get relationInstanceContainer(){return this.#G}get attributeInstanceContainer(){return this.#jt}get namespaceInstanceContainer(){return this.#K}get textSelection(){return this.#T.textSelection}findDenotation(t,e){return this.#T.find("denotation",t,e)}findBlock(t,e){return this.#T.find("block",t,e)}getTextBetween(t,e){return this.sourceDoc.substring(t,e)}changeTextBetween(t,e,i){this.#Te=`${this.#Te.slice(0,t)}${i}${this.#Te.slice(e)}`;const n=i.length-(e-t),s=this.#T.offsetSpans(t,e,n);return this.#O.render(this.sourceDoc),this.#Me(),this.#Nt.emit("textae-event.annotation-data.text.change"),s}hasCharacters(t){const{begin:e,end:i}=this.textSelection,n=this.getTextBetween(e,i);return t.removeBlankCharacters(n).length>0}getTextSelection(t,e){const{begin:i,end:n}=this.textSelection;return{begin:e.backFromBegin(this.sourceDoc,i,t),end:e.forwardFromEnd(this.sourceDoc,n-1,t)+1}}getInstanceContainerFor(t){switch(t){case"span":return this.#T;case"relation":return this.#G;case"entity":return this.#U;case"attribute":return this.#jt}}drawGridsInSight(){if(this.#Qe){const{clientHeight:t,clientWidth:e}=document.documentElement;for(const i of this.#T.allDenotationSpans)i.drawGrid(t,e);for(const i of this.#T.allBlockSpans)i.drawGrid(t,e),i.updateBackgroundPosition();for(const i of this.#G.all)i.render(t,e)}}reLayout(){this.#O.forceUpdate(),this.#Qe&&this.updatePosition()}set toolBarHeight(t){this.#U.toolBarHeight=t,this.#G.toolBarHeight=t}get#Qe(){const{clientHeight:t}=document.documentElement,{top:e,bottom:i}=this.#Q.getBoundingClientRect();return 0<=i&&e<=t}focusDenotation(t){console.assert(this.#U.hasDenotation(t),"The denotation does not exist.");const{span:e}=this.#U.get(t);e.focus()}#Me(){this.#T.renderAll(),this.#O.updateLineHeight(),this.drawGridsInSight()}#Ee(){this.#T.arrangeDenotationEntityPosition(),this.#T.arrangeBackgroundOfBlockSpanPosition(),this.#T.arrangeBlockEntityPosition();for(const t of this.#G.all)t.sourceEntity.span.isGridRendered&&t.targetEntity.span.isGridRendered&&t.redrawLineConsideringSelection()}#Ae(){this.#T.clear(),this.#U.clear(),this.#jt.clear(),this.#G.clear(),this.#K.clear(),I(this.#Q).innerHTML=""}}const Be={"delimiter characters":[" ",".","!","?",",",":",";","-","/","&","(",")","{","}","[","]","+","*","\\",'"',"'","\n","–"],"non-edge characters":[" ","\n"]};class qe{#De;#Re;constructor(){this.#De=[],this.#Re=[]}get delimiterCharacters(){return this.#De}get blankCharacters(){return this.#Re}set(t){const e={...Be,...t};return this.#De=e["delimiter characters"],this.#Re=e["non-edge characters"],t}isDelimiter(t){return this.#De.indexOf("ANY")>=0?1:this.#De.indexOf(t)>=0}isBlankCharacter(t){return this.#Re.indexOf(t)>=0}removeBlankCharacters(t){for(const e of this.#Re)t=t.replaceAll(e,"");return t}}class Ze{constructor(t){this._resetHistory(),this._eventEmitter=t,t.on("textae-event.type-definition.reset",()=>{this._removeConfigurationOperationsFromHistory(),this._trigger()}).on("textae-event.annotation-data.all.change",()=>{this._resetHistory(),this._trigger()}).on("textae-event.resource.annotation.save",()=>{this._trigger()}).on("textae-event.resource.configuration.save",()=>{this._trigger()})}push(t){this._histories.splice(this._pointer+1,this._histories.length-this._pointer,t),this._pointer++,this._trigger()}next(){this._pointer++;const t=this._histories[this._pointer];return this._trigger(),t}prev(){const t=this._histories[this._pointer];return this._pointer--,this._trigger(),t}get hasAnythingToUndo(){return this._pointer>-1}get hasAnythingToRedo(){return this._pointer<this._histories.length-1}_trigger(){this._eventEmitter.emit("textae-event.history.change",this)}_removeConfigurationOperationsFromHistory(){for(let t=0;t<this._histories.length;t++)this._histories[t].isExactly("configuration_command")&&(this._pointer--,this._histories.splice(t,1))}_resetHistory(){this._pointer=-1,this._histories=[]}}function Fe(t,e,i){i?console.log(`[${t.constructor.name}]`,e,i):console.log(`[${t.constructor.name}]`,e)}class Xe{get isEmpty(){return!1}isExactly(t){return this.kind.has(t)&&1===this.kind.size}}class He extends Xe{get kind(){return new Set(["annotation_command"])}}class We extends He{#Ht;#Oe;#Et;#Ie;constructor(t,e,i,n=null){super(),this.#Ht=t,this.#Oe=e,this.#Et=i,this.#Ie=n}execute(){this.#Et=this.#Ht.getInstanceContainerFor(this.#Oe).add(this.#Et),this.#Ie&&this.#Ie.add(this.#Oe,[this.#Et.id]),Fe(this,`${this.#Oe}: ${this.#Et.id}`)}revert(){return new Ve(this.#Ht,this.#Oe,this.#Et)}}class Ve extends He{#Ht;#Oe;#Et;constructor(t,e,i){super(),this.#Ht=t,this.#Oe=e,this.#Et=i}execute(){this.#Ht.getInstanceContainerFor(this.#Oe).remove(this.#Et.id),Fe(this,`${this.#Oe}: ${this.#Et.id}`)}revert(){return new We(this.#Ht,this.#Oe,this.#Et)}}class Ye extends Xe{get kind(){return new Set(["configuration_command"])}}class Ue extends Ye{constructor(t,e,i,n=null){super(),this._definitionContainer=t,this._attrDef=e,this._index=i,this._indexThatAddDefaultTo=n}execute(){const t=[...this._attrDef.values];if("selection"===this._attrDef.valueType&&t[this._index].default&&null===this._indexThatAddDefaultTo){let e=null;t.forEach((t,i)=>{null===e&&i!=this._index&&(e=i)}),t[e]={...t[e],default:!0}}this._deletedValue=t.splice(this._index,1)[0],"selection"===this._attrDef.valueType&&null!==this._indexThatAddDefaultTo&&(t[this._indexThatAddDefaultTo]={...t[this._indexThatAddDefaultTo],default:!0}),this._updatedAttrDef=this._definitionContainer.updateValues(this._attrDef.pred,t),Fe(this,`remove a value from an attrribute:${this._attrDef.pred}, index:${this._index}, updated values: \n ${t.map(t=>JSON.stringify(t)).join("\n ")}`)}revert(){return new Ge(this._definitionContainer,this._updatedAttrDef,this._deletedValue,this._index)}}class Ge extends Ye{constructor(t,e,i,n=null){super(),this._definitionContainer=t,this._pred=e.pred,this._index=n,this._value=i;const s=[...e.values];if("selection"===e.valueType&&i.default){this._indexThatRemoveDefaultFrom||(this._indexThatRemoveDefaultFrom=s.findIndex(t=>t.default));const t={...s[this._indexThatRemoveDefaultFrom]};delete t.default,s[this._indexThatRemoveDefaultFrom]=t}s.splice(n||s.length,0,i),this._modifiedValues=s}execute(){this._updatedAttrDef=this._definitionContainer.updateValues(this._pred,this._modifiedValues),Fe(this,`add a new value to attrribute:${this._pred}, value: ${JSON.stringify(this._value)}, index: ${this._index}, updated values: \n ${this._modifiedValues.map(t=>JSON.stringify(t)).join("\n ")}`)}revert(){return new Ue(this._definitionContainer,this._updatedAttrDef,this._updatedAttrDef.values.length-1,this._indexThatRemoveDefaultFrom)}}class Ke extends Xe{constructor(){super(),this._isExecuteSubCommandsInReverseOrderWhenRevert=!0}execute(){if(console.assert(this._subCommands,"_subCommands is necessary!"),this.isEmpty)return void(this.revert=()=>({execute(){}}));for(const t of this._subCommands)t.execute();this._afterInvoke&&this._afterInvoke();const t=this;this.revert=()=>({_subCommands:this._subCommands,_logMessage:this._logMessage,_afterInvoke:this._afterInvoke,_isExecuteSubCommandsInReverseOrderWhenRevert:this._isExecuteSubCommandsInReverseOrderWhenRevert,execute(){let e=this._subCommands.map(t=>t.revert());this._isExecuteSubCommandsInReverseOrderWhenRevert&&(e=e.reverse());for(const t of e)t.execute();this._afterInvoke&&this._afterInvoke(),Fe(t,`revert: ${this._logMessage}`)}}),Fe(this,this._logMessage)}get kind(){return this._subCommands.reduce((t,e)=>new Set([...t,...e.kind]),new Set)}get isEmpty(){return!this._subCommands||0===this._subCommands.length}}class Je extends Ye{constructor(t,e,i){super(),this._definitionContainer=t,this._attrDef=e,this._changedProperties=i}execute(){const t=this._attrDef.pred,[e,i]=function(t,e){const i=t.externalFormat,n=new Map;for(const[s,o]of e.entries())null===o&&void 0!==t[s]?(delete i[s],n.set(s,t[s])):null!==o&&(i[s]=o,n.set(s,void 0===t[s]?null:t[s]));return[i,n]}(this._attrDef,this._changedProperties);this._revertAttrDef=this._definitionContainer.update(t,e),this._revertChangedProperties=i,Fe(this,`change old pred:${t} to new attridute definition:${JSON.stringify(e)}`)}revert(){return new Je(this._definitionContainer,this._revertAttrDef,this._revertChangedProperties)}}class ti extends He{#Ht;#Le;#Ne;#je;#ze;#Be;#qe;constructor(t,e,i,n){super(),this.#Ht=t,this.#Le=e,this.#Ne=e.pred,this.#je=e.obj,this.#ze=i,this.#Be=n}execute(){this.#qe=this.#Ht.attributeInstanceContainer.change(this.#Le.id,this.#ze,this.#Be),Fe(this,`attribute: ${this.#Le.id} changed from ${this.#Ne}:${this.#je} to ${this.#qe.pred}:${this.#qe.obj}.`)}revert(){return new ti(this.#Ht,this.#qe,this.#Ne,this.#je)}}class ei extends Ke{constructor(t,e,i,n,s){super(),this._isExecuteSubCommandsInReverseOrderWhenRevert=!1;const o=[new Je(i,n,s)];let r=[];if(s.has("pred")){const i=e.attributeInstanceContainer.getSameDefinitionsAttributes(n.pred);r=i.map(t=>new ti(e,t,s.get("pred"),t.obj)),this._afterInvoke=()=>{t.emit("textae-event.commander.attributes.change",i)}}this._subCommands=o.concat(r),this._logMessage=`set ${[...s.entries()].map(([t,e])=>`${t}:${e}`)} to attribute definition ${n.pred}`}}class ii extends Ke{constructor(t,e,i,n,s){super();const o=[];for(const t of i){const e=t.attributes.find(t=>t.pred==n.pred&&t.obj!==s);e&&o.push(e)}this._subCommands=o.map(t=>new ti(e,t,null,s)),o.length&&(this._afterInvoke=()=>t.emit("textae-event.commander.attributes.change",o)),this._logMessage=`update obj ${s} to attributes: ${o.map(t=>t.id).join(",")}`}}function ni(t,e,i,n){if("string"===e.valueType&&n&&!e.values.some(t=>t.pattern===i)&&n!==e.getLabel(i))return new Ge(t,e,{pattern:i,label:n})}class si extends Ke{constructor(t,e,i,n,s,o,r=null){super();const a=[];for(const t of n){const e=t.attributes.find(t=>t.pred==s.pred&&t.obj!==o);e&&a.push(e)}this._subCommands=a.map(t=>new ti(e,t,null,o)),a.length&&(this._afterInvoke=()=>t.emit("textae-event.commander.attributes.change",a));const l=ni(i,s,o,r);l&&this._subCommands.push(l),this._logMessage=`update obj ${o} to attributes: ${a.map(t=>t.id).join(",")}`}}class oi extends He{#Ze;#Oe;#H;#Fe;constructor(t,e,i,n){super(),this.#Ze=t,this.#Oe=e,this.#H=i,this.#Fe=n}execute(){this.oldType=this.#Ze.getInstanceContainerFor(this.#Oe).get(this.#H).typeName;const t=this.#Ze.getInstanceContainerFor(this.#Oe).changeType(this.#H,this.#Fe);Fe(this,`change type of a ${this.#Oe}. old type:${this.oldType} ${this.#Oe}:`,t)}revert(){return new oi(this.#Ze,this.#Oe,this.#H,this.oldType)}}class ri extends Ke{constructor(t,e,i,n,s){super();const o=e[i].all.filter(t=>!t.typeValues.isSameType(n,s));this._subCommands=o.map(e=>new oi(t,i,e.id,n)),this._subCommands=this._subCommands.concat(function(t,e,i){const n=[];for(const s of t){if(s.typeValues)for(const t of s.attributes){const s=e.find(e=>t.equalsTo(e.pred,e.obj));s?String(t.obj)!==s.obj&&n.push(new ti(i,t,s.pred,s.obj)):n.push(new Ve(i,"attribute",t))}for(const t of e)s.attributes.some(e=>e.equalsTo(t.pred,t.obj))||n.push(new We(i,"attribute",{subj:s.id,pred:t.pred,obj:t.obj}))}return n}(o,s,t));for(const{pred:e,obj:i,label:n}of s){const s=t.typeDictionary.attribute,o=s.get(e),r=ni(s,o,i,n);r&&this._subCommands.push(r)}this._logMessage=`set type ${n}${s.length>0?` and attributes ${JSON.stringify(s)}`:""} to ${i} items ${o.map(t=>t.id)}`}}class ai extends Ye{constructor(t,e,i,n,s){super(),this._annotationModel=t,this._definitionContainer=e,this._id=i,this._changedProperties=n,this._newDefaultTypeId=s}execute(){const t=this._definitionContainer.get(this._id),[e,i]=function(t,e){const i={...e},n=new Map;for(const[s,o]of t.entries())null===o&&void 0!==e[s]?(delete i[s],n.set(s,e[s])):null!==o&&(i[s]=o,n.set(s,void 0===e[s]?null:e[s]));return[i,n]}(this._changedProperties,t);this._definitionContainer.replace(this._id,e),e.default?(this.revertDefaultTypeId=this._definitionContainer.defaultType,this._definitionContainer.defaultType=e.id):this._newDefaultTypeId&&(this._definitionContainer.defaultType=this._newDefaultTypeId),this.revertId=e.id,this.revertChangedProperties=i,Fe(this,`change old type:${JSON.stringify(t)} to new type:${JSON.stringify(e)}, default is ${this._definitionContainer.defaultType}`)}revert(){return new ai(this._annotationModel,this._definitionContainer,this.revertId,this.revertChangedProperties,this.revertDefaultTypeId)}}class li extends Ye{constructor(t,e,i){super(),this._definitionContainer=t,this._removeType=e,this._revertDefaultTypeId=i}execute(){const{id:t}=this._removeType,e=this._definitionContainer.get(t);this._definitionContainer.delete(t,this._revertDefaultTypeId),e&&(this._removeType=e),Fe(this,`remove a type:${JSON.stringify(this._removeType)}, default is ${this._definitionContainer.defaultType}`)}revert(){return new ci(this._definitionContainer,this._removeType)}}class ci extends Ye{constructor(t,e){super(),this._definitionContainer=t,this._newType=e}execute(){this._revertDefaultTypeId=this._definitionContainer._defaultType,this._definitionContainer.addDefinedType(this._newType),Fe(this,`create a new type:${JSON.stringify(this._newType)}, default is ${this._definitionContainer.defaultType}`)}revert(){return new li(this._definitionContainer,this._newType,this._revertDefaultTypeId)}}function hi(t,e,i,n){return t.has(e)?new ai(i,t,e,n,null):new ci(t,{id:e,...Object.fromEntries(n)})}class ui extends Ke{constructor(t,e,i,n,s,o){super();const r=[];i&&r.push(hi(s,n,t,new Map([["label",i]])));const a=new ri(t,e,s.annotationType,n,o);a.isEmpty||r.push(a),this._subCommands=r,this._logMessage=`change ${s.annotationType} value:"${n}"${i?`, label:"${i}"`:""}${o.length>0?`, attributes:${JSON.stringify(o)}`:""}`}}class di extends Ke{constructor(t,e,i,n,s){super();const o=[hi(e,n,t,s)];let r=[];s.has("id")&&(r=function(t,e,i,n){return t.getInstanceContainerFor(e).all.filter(t=>t.typeName===i).map(i=>new oi(t,e,i.id,n))}(t,i,n,s.get("id"))),this._subCommands=o.concat(r),this._logMessage=`set ${[...s.entries()].map(([t,e])=>`${t}:${e}`)} to type definition ${n}`}}class fi extends Ke{constructor(t,e,i,n){super();const s=e[i].all.filter(t=>!t.typeValues.isSameType(n));this._subCommands=s.map(e=>new oi(t,i,e.id,n)),this._logMessage=`set type ${n} to ${i} items ${s}`}}class pi extends Ye{constructor(t,e,i,n,s){super(),this._definitionContainer=t,this._attrDef=e,this._targetIndex=i,this._newValue=n,this._indexThatRemoveDefaultFrom=s}execute(){if("selection"===this._attrDef["value type"]&&(!this._attrDef.values[this._targetIndex].default&&this._newValue.default&&(this._indexThatRemoveDefaultFrom||(this._indexThatRemoveDefaultFrom=this._attrDef.values.findIndex(t=>t.default)),delete this._attrDef.values[this._indexThatRemoveDefaultFrom].default),this._attrDef.values[this._targetIndex].default&&!this._newValue.default))if(1===this._attrDef.values.length)this._newValue.default=!0;else if(this._indexThatRemoveDefaultFrom)this._attrDef.values[this._indexThatRemoveDefaultFrom].default=!0;else{let t=null;this._attrDef.values.forEach((e,i)=>{null===t&&i!=this._targetIndex&&(t=i)}),this._attrDef.values[t].default=!0,this._indexThatRemoveDefaultFrom=t}this._valueBeforeChange=this._attrDef.values.splice(this._targetIndex,1,this._newValue)[0],this._definitionContainer.update(this._attrDef.pred,this._attrDef),Fe(this,`change value of attrribute:${this._attrDef.pred}, oldValue: ${JSON.stringify(this._valueBeforeChange)}, newValue: ${JSON.stringify(this._newValue)}`)}revert(){return new pi(this._definitionContainer,this._attrDef,this._targetIndex,this._valueBeforeChange,this._indexThatRemoveDefaultFrom)}}class mi extends Ke{constructor(t,e,i,n,s,o,r){if(super(),this._subCommands=[new pi(i,n,s,o,r)],"selection"===n["value type"]&&n.values[s].id!==o.id){const i=e.attributeInstanceContainer.getSameAttributes(n.pred,n.values[s].id),r=i.map(t=>new ti(e,t,null,o.id));this._subCommands=this._subCommands.concat(r),this._afterInvoke=()=>t.emit("textae-event.commander.attributes.change",i)}this._logMessage=`attribute: ${n.pred}`}}class gi extends Ye{constructor(t,e){super(),this._definitionContainer=t,this._removeAttrdef=e,this._index=t.getIndexOf(e.pred)}execute(){this._definitionContainer.delete(this._removeAttrdef.pred),Fe(this,`remove an attrribute definition:${JSON.stringify(this._removeAttrdef)}, index:${this._index}`)}revert(){return new vi(this._definitionContainer,this._removeAttrdef,this._index)}}class vi extends Ye{constructor(t,e,i){super(),this._definitionContainer=t,this._newAttrDef=e,this._index=i}execute(){"selection"!==this._newAttrDef.valueType||this._newAttrDef.values||(this._newAttrDef.values=[{id:"default",default:!0}]),this._definitionContainer.create(this._newAttrDef.valueType,this._newAttrDef,this._index),Fe(this,`create a new attrribute definition:${JSON.stringify(this._newAttrDef)}, index: ${this._index}`)}revert(){return new gi(this._definitionContainer,this._newAttrDef)}}function yi(t,e,i,n){return e.filter(t=>!t.typeValues.hasSpecificPredicateAttribute(i)).map(({id:e})=>new We(t,"attribute",{id:null,subj:e,pred:i,obj:n}))}class Oi extends Ke{constructor(t,e,i,n){super(),this._subCommands=yi(t,e,i.pred,n||i.default),this._logMessage=`create attirbute ${i.pred}:${i.default} to item ${e.map(({id:t})=>t).join(", ")}`}}class bi extends We{constructor(t,e,i){super(t,"attribute",{obj:e,pred:i})}execute(){const t=this._annotationModel.entityInstanceContainer.all.pop().id;return this._instance.subj=t,super.execute()}}class xi extends Ke{constructor(t,e,i,n,s,o,r){super(),this._subCommands=[new We(t,"entity",{spanType:i,begin:n,end:s,typeName:o},e)].concat(r.map(({obj:e,pred:i})=>new bi(t,e,i))),this._logMessage=`span: ${n}:${s}, type: ${o}${r.length?`, attributes: ${r.map(({pred:t})=>t).join(", ")}`:""}`}}class wi extends Ke{constructor(t,e,i,n,s,o){super();const r=new We(e,"span",{begin:n,end:s,isBlock:!0},i),a=new xi(e,i,"block",n,s,o,[]);this._subCommands=[r,a],this._logMessage=`create a span ${n}:${s} with type ${o}`}}class _i extends Ke{constructor(t,e,i){super();const n=e.span.all.filter(t=>t.isDenotation);this._subCommands=n.map(n=>new We(t,"entity",{spanType:"denotation",begin:n.begin,end:n.end,typeName:i},e)),this._logMessage=`create a ${i} type entity to ${n}`}}class Si extends Ke{constructor(t,e,i,n,s,o){super(),this._subCommands=[new We(t,"span",{begin:n,end:s},e)].concat(o.map(i=>new xi(t,e,"denotation",n,s,i.typeName,i.attributes))),this._logMessage=`span: ${n}:${s}, types: ${o.map(({typeName:t})=>t).join(", ")}`}}class ki extends Ke{constructor(t,e,i,n,s,o){super(),console.log(n),this._subCommands=e.getReplicationRanges(n,o).map(({begin:n,end:o})=>new Si(e,i,t,n,o,s)),this._logMessage=`from span: ${n.id}`}}class $i extends Ke{constructor(t,e,i,n,s,o,r){super();const a=[new Ot(s)];this._subCommands=[new Si(e,i,t,n.begin,n.end,a)],this._logMessage=`create a span ${n.begin}:${n.end} with type ${a[0].typeName}`,o&&n.end-n.begin<=100&&(this._subCommands.push(new ki(t,e,i,{begin:n.begin,end:n.end},a,r)),this._logMessage=`${this._logMessage} and replicate auto`)}}class Ci extends Ye{constructor(t,e,i){super(),this._definitionContainer=t,this._oldIndex=e,this._newIndex=i}execute(){this._definitionContainer.move(this._oldIndex,this._newIndex),Fe(this,`move the attrribute definition: from ${this._oldIndex} to ${this._newIndex}`)}revert(){return new Ci(this._definitionContainer,this._newIndex,this._oldIndex)}}class Ti extends He{#T;#Xe;#He;#We;#Ve;constructor(t,e,i,n,s){super(),this.#T=t,this.#Xe=e,this.#He=i,this.#We=n,this.#Ve=s}execute(){this.#T.moveBlockSpan(this.#Xe,this.#He,this.#We,this.#Ve),Fe(this,`move span: from {begin: ${this.#Xe}, end: ${this.#He} } to {begin: ${this.#We}, end: ${this.#Ve}}`)}revert(){return new Ti(this.#T,this.#We,this.#Ve,this.#Xe,this.#He)}}class Pi extends He{#T;#Xe;#He;#We;#Ve;constructor(t,e,i,n,s){super(),this.#T=t,this.#Xe=e,this.#He=i,this.#We=n,this.#Ve=s}execute(){this.#T.moveDenotationSpan(this.#Xe,this.#He,this.#We,this.#Ve),Fe(this,`move span: from {begin: ${this.#Xe}, end: ${this.#He} } to {begin: ${this.#We}, end: ${this.#Ve}}`)}revert(){return new Pi(this.#T,this.#We,this.#Ve,this.#Xe,this.#He)}}function Ei(t,e){return t.entities.every(t=>e.includes(t))}class Ai extends Ke{constructor(t,e){super(),this._subCommands=[];for(const[i,n]of e.entries())this._subCommands.push(new Mi(t,i,n));this._logMessage=`revert: move entities ${Array.from(e.values()).flat().map(t=>t.id).join(", ")}`}}class Mi extends He{constructor(t,e,i){super(),this._annotationModel=t,this._span=e,this._entities=i}execute(){this._moveMap=this._entities.reduce((t,e)=>(t.has(e.span)?t.get(e.span).push(e):t.set(e.span,[e]),t),new Map);const t=`${Array.from(this._moveMap.entries()).map(([t,e])=>`${e.map(t=>t.id).join(", ")} from ${e[0].span.id} to ${this._span.id}`).join(", ")}`;this._annotationModel.entityInstanceContainer.moveEntities(this._span,this._entities),Fe(this,t)}revert(){return new Ai(this._annotationModel,this._moveMap)}}class Qi extends Ke{constructor(t,e,i){console.assert(e.span.single,"There must be one span to be pasted."),super();const n=[new Mi(t,e.span.single,i)];for(const e of i.map(t=>t.span).reduce((t,e)=>(t.add(e),t),new Set).values())Ei(e,i)&&n.push(new Ve(t,"span",e));this._subCommands=n,this._logMessage="paste cut entities"}}class Di extends Ke{constructor(t,e,i,n,s,o){super();const r=e.span.all;this._subCommands=[];for(const e of n)this._subCommands.push(new ci(t.denotationDefinitionContainer,e));for(const e of s)this._subCommands.push(new vi(t.attributeInstanceContainerDefinitionContainer,{valueType:e["value type"],...e}));for(const{pred:e,value:i}of o)this._subCommands.push(new Ge(t.attributeInstanceContainerDefinitionContainer,t.attributeInstanceContainerDefinitionContainer.get(e),i));this._subCommands=this._subCommands.concat(r.map(n=>i.map(i=>new xi(t,e,"denotation",n.begin,n.end,i.typeName,i.attributes))).flat()),this._logMessage=`paste types [${i.map(({typeName:t,attributes:e})=>[`{type:${t}}`].concat(e.map(({pred:t,obj:e})=>`{${t}:${e}}`)))}] to ${r}`}}function Ri(t,e,i){return e.reduce((t,{attributes:e})=>t.concat(e),[]).filter(t=>t.pred===i).map(e=>new Ve(t,"attribute",e))}class Ii extends Ke{constructor(t,e,i){super();const n=Ri(t,e,i.pred);this._subCommands=n,this._logMessage=`remove ${i.pred} attribute from items ${e.map(t=>t.id).join(", ")}`}}function Li(t,e,i){t.add(i);for(const t of i.attributes)e.add(t)}function Ni(t,e,i,n){t.add(n);for(const t of n.attributes)i.add(t);for(const t of n.relations)Li(e,i,t)}class ji extends Ke{constructor(t,e){super();const i=new Set,n=new Set,s=new Set,o=new Set;for(const t of e.span.all){i.add(t);for(const e of t.entities)Ni(n,s,o,e)}for(const t of e.entity.all)Ni(n,s,o,t);for(const t of e.relation.all)Li(s,o,t);for(const n of t.spanInstanceContainer.all)n.entities.every(t=>e.entity.all.includes(t))&&(n.styleOnly||i.add(n));this._subCommands=[];for(const e of o)this._subCommands.push(new Ve(t,"attribute",e));for(const e of s)this._subCommands.push(new Ve(t,"relation",e));for(const e of n)this._subCommands.push(new Ve(t,"entity",e));for(const e of i)this._subCommands.push(new Ve(t,"span",e));this._logMessage=`remove selected ${[...i,...n,...s,...o].map(({id:t})=>t).join(", ")}`}}class zi extends Ke{constructor(t,e){super();const i=new Ve(t,"relation",e),n=e.attributes.map(e=>new Ve(t,"attribute",e));this._subCommands=n.concat(i),this._logMessage=`remove a relation ${e.id}`}}class Bi extends Ke{constructor(t,e){super();const i=new Ve(t,"entity",e),n=e.relations.map(e=>new zi(t,e)),s=e.attributes.map(e=>new Ve(t,"attribute",e));this._subCommands=n.concat(s).concat(i),this._logMessage=`remove an entity ${e.id}`}}class qi extends Ke{constructor(t,e){super();const i=t.getSpan(e),n=i.entities.map(e=>new Bi(t,e)),s=new Ve(t,"span",i);this._subCommands=n.concat(s),this._logMessage=`remove a span ${e}`}}class Zi extends Ke{constructor(t,e,i){super(),this._subCommands=yi(t,e,i.pred,i.default);const n=Ri(t,e,i.pred);this._subCommands=this._subCommands.concat(n),this._logMessage=`toggle flag attirbute ${i.pred} to item ${e.map(({id:t})=>t).join(", ")}`}}class Fi extends He{#Ht;#Ye;#Ue;#Ge;#Ke;#Je;constructor(t,e,i){super(),this.#Ht=t,this.#Ye=e.begin,this.#Ue=e.end,this.#Ge=i}execute(){this.#Ke=this.#Ye+this.#Ge.length,this.#Je=this.#Ht.getTextBetween(this.#Ye,this.#Ue);const t=this.#Ht.changeTextBetween(this.#Ye,this.#Ue,this.#Ge);Fe(this,`change text at ${this.#Ye}:${this.#Ue} to ${this.#Ge} and spans [${t.map(({begin:t,end:e})=>`${t}:${e}`).join(", ")}] are effected.`)}revert(){return new Fi(this.#Ht,{begin:this.#Ye,end:this.#Ke},this.#Je)}}class Xi extends Ke{constructor(t,e,i,n){super(),this._isExecuteSubCommandsInReverseOrderWhenRevert=!1,this._subCommands=[new Fi(t,{begin:e,end:i},n)],this._logMessage=`change text from ${e} to ${i} to ${n}`}}class Hi{#M;#Nt;#Ht;#Ie;constructor(t,e,i,n){this.#M=t,this.#Nt=e,this.#Ht=i,this.#Ie=n}addValueToAttributeDefinitionCommand(t,e){return new Ge(this.#Ht.typeDictionary.attribute,t,e)}changeAttributeDefinitionCommand(t,e){return new ei(this.#Nt,this.#Ht,this.#Ht.typeDictionary.attribute,t,e)}changeAttributeObjOfItemsCommand(t,e,i){return new ii(this.#Nt,this.#Ht,t,e,i)}changeStringAttributeObjOfItemsCommand(t,e,i,n){return new si(this.#Nt,this.#Ht,this.#Ht.typeDictionary.attribute,t,e,i,n)}changeTypeValuesCommand(t,e,i,n){return new ui(this.#Ht,this.#Ie,t,e,i,n)}changeTypeDefinitionCommand(t,e,i,n){return new di(this.#Ht,t,e,i,n)}changeTypeOfSelectedItemsCommand(t,e){return new fi(this.#Ht,this.#Ie,t,e)}changeValueOfAttributeDefinitionAndObjectOfSelectionAttributeCommand(t,e,i){return new mi(this.#Nt,this.#Ht,this.#Ht.typeDictionary.attribute,t,e,i)}createAttributeDefinitionCommand(t){return new vi(this.#Ht.typeDictionary.attribute,t)}createAttributeToItemsCommand(t,e,i=null){return new Oi(this.#Ht,t,e,i)}createBlockSpanCommand(t){return new wi(this.#M,this.#Ht,this.#Ie,t.begin,t.end,this.#Ht.typeDictionary.block.defaultType)}createDefaultTypeEntityToSelectedSpansCommand(t){return new _i(this.#Ht,this.#Ie,t)}createRelationCommand(t){return new We(this.#Ht,"relation",t,this.#Ie)}createSpanAndAutoReplicateCommand(t,e,i){return new $i(this.#M,this.#Ht,this.#Ie,t,this.#Ht.typeDictionary.denotation.defaultType,e,i)}createTypeDefinitionCommand(t,e){return new ci(t,e)}deleteAttributeDefinitionCommand(t){return new gi(this.#Ht.typeDictionary.attribute,t)}moveAttributeDefinitionCommand(t,e){return new Ci(this.#Ht.typeDictionary.attribute,t,e)}moveBlockSpanCommand(t,e,i){const{begin:n,end:s}=this.#Ht.getSpan(t);return new Ti(this.#Ht.spanInstanceContainer,n,s,e,i)}moveDenotationSpanCommand(t,e,i){const{begin:n,end:s}=this.#Ht.getSpan(t);return new Pi(this.#Ht.spanInstanceContainer,n,s,e,i)}moveEntitiesToSelectedSpanCommand(t){return new Qi(this.#Ht,this.#Ie,t)}pasteTypesToSelectedSpansCommand(t,e=[],i=[],n=[]){return new Di(this.#Ht,this.#Ie,t,e,i,n)}replicateSpanCommand(t,e,i){return new ki(this.#M,this.#Ht,this.#Ie,t,e,i)}removeAttributesFromItemsByPredCommand(t,e){return new Ii(this.#Ht,t,e)}removeSpanCommand(t){return new qi(this.#Ht,t)}removeSelectedCommand(){return new ji(this.#Ht,this.#Ie)}removeTypeDefinitionCommand(t,e){return new li(t,e)}removeValueFromAttributeDefinitionCommand(t,e){return new Ue(this.#Ht.typeDictionary.attribute,t,e)}toggleFlagAttributeToItemsCommand(t,e){return new Zi(this.#Ht,t,e)}changeTextAndMoveSpanCommand(t,e,i){return new Xi(this.#Ht,t,e,i)}}class Wi{#Q;#M;#Nt;#Ht;#Ie;#ti;constructor(t,e,i,n,s){this.#Q=t,this.#M=e,this.#Nt=i,this.#Ht=n,this.#Ie=s,this.#ti=new Ze(i)}invoke(t){t.isEmpty||(t.execute(),this.#ti.push(t))}undo(){if(this.#ti.hasAnythingToUndo){this.#Ie.removeAll(),this.#Q.focus();const t=this.#ti.prev();t.kind.has("configuration_command")&&e().success("configuration has been undone"),t.revert().execute()}}redo(){if(this.#ti.hasAnythingToRedo){this.#Ie.removeAll();const t=this.#ti.next();t.kind.has("configuration_command")&&e().success("configuration has been redo"),t.execute()}}get factory(){return new Hi(this.#M,this.#Nt,this.#Ht,this.#Ie,this.#Ht.typeDictionary)}}class Vi{constructor(t,e){this._editorHTMLElement=t,this._selectionModel=e}left(t){const e=this._searchLeft(".textae-editor__span");if(e)return void(t?this._selectionModel.add("span",[e.id]):this._selectionModel.selectSpan(e.id));const i=this._searchLeft(".textae-editor__grid .textae-editor__signboard");i&&(t?this._selectionModel.add("entity",[i.dataset.id]):this._selectionModel.selectEntity(i.dataset.id))}right(t){const e=this._searchRight(".textae-editor__span");if(e)return void(t?this._selectionModel.add("span",[e.id]):this._selectionModel.selectSpan(e.id));const i=this._searchRight(".textae-editor__grid .textae-editor__signboard");i&&(t?this._selectionModel.add("entity",[i.dataset.id]):this._selectionModel.selectEntity(i.dataset.id))}_searchLeft(t){const e=this._editorHTMLElement.querySelectorAll(t),i=[...e].findIndex(t=>t.classList.contains("ui-selected")||t.classList.contains("textae-editor__signboard--selected"));if(i>0)return e[i-1]}_searchRight(t){const e=this._editorHTMLElement.querySelectorAll(t),i=[...e].reverse().findIndex(t=>t.classList.contains("ui-selected")||t.classList.contains("textae-editor__signboard--selected"));if(e.length-i>0)return e[e.length-i]}}class Yi{constructor(t,e){this._editorHTMLElement=t,this._selectionModel=e}up(){if(this._selectionModel.span.single){const t=this._selectionModel.span.single.gridElement.querySelector(".textae-editor__signboard");this._selectionModel.selectEntity(t.dataset.id)}}down(){const t=this._editorHTMLElement.querySelector(".textae-editor__signboard--selected");if(t){const e=t.closest(".textae-editor__grid").id.substring(1);this._selectionModel.selectSpan(e)}}}function Ui(t){return s()(t,300)}function Gi(t,e){r()(t,".textae-editor__setting-dialog__line-height-text","change",Ui(t=>{e.lineHeight=t.target.value,function(){const t=new Event("resize");window.dispatchEvent(t)}()}))}function Ki(t,e,i,n,s,o){!function(t,e,i){r()(t,".textae-editor__setting-dialog__type-gap-text","change",Ui(n=>{e.value=Number(n.target.value),t.querySelector(".textae-editor__setting-dialog__line-height-text").value=i.lineHeight}))}(t,i,s),Gi(t,s),function(t,e){r()(t,".textae-editor__setting-dialog__lock-config-text","change",Ui(t=>{t.target.checked?e.lockEdit():e.unlockEdit()}))}(t,n),function(t,e,i){r()(t,".textae-editor__setting-dialog__function-availability-checkbox","change",Ui(({target:t})=>{const n=t.closest(".textae-editor__setting-dialog__function-availability-label").textContent.trim();t.checked?(i.enable(n),e.emit("textae-event.configuration.reset")):(i.disable(n),e.emit("textae-event.configuration.reset"))}))}(t,e,o)}const Ji="14.1.1";class tn{static escape(t){return t.replace(/\n/g,"\\n").replace(/\t/g,"\\t").replace(/\r/g,"\\r")}static decode(t){return t.replace(/\\n/g,"\n").replace(/\\t/g,"\t").replace(/\\r/g,"\r")}}function en(t){const e=tn.escape(t);return st()(e)}function nn(t){const{typeGap:e,typeGapDisabled:i,lineHeight:n,autocompletionWs:s,typeDictionaryLocked:o,delimiterCharacters:r,blankCharacters:a,functionAvailability:l,version:c}=t;return ot`
210
+ `}}class Ft{#c;#mt;#Qt;#Dt;#Rt;#It;constructor(t,e,i,n,s,o){this.#c=I(t),this.#mt=e,this.#Qt=i,this.#Dt=l().create('<div class="textae-editor__relation__signboard-location"></div>'),this.#Lt(),this.#Rt=new Zt(e,"relation",null),this.#Dt.appendChild(this.#Rt.element),this.#c.appendChild(this.#Dt),this.#Dt.addEventListener("click",n),this.#Dt.addEventListener("mouseenter",s),this.#Dt.addEventListener("mouseleave",o)}updateValue(){this.#Lt(),this.#Rt.updateLabel()}updateHighlighting(){this.#Lt(),this.#Rt.clearCSSClass(),this.#mt.isSelected?this.#Rt.select():this.#mt.isHovered&&this.#Rt.hover()}destructor(){this.#c.removeChild(this.#Dt)}get y(){return this.#It.getBBox().y}get width(){return this.#Dt.getBBox().width}get height(){return this.#Dt.getBBox().height}#Lt(){this.#Dt.style.width="0px",this.#Dt.style.left=`${this.#Qt.highestX}px`,this.#Dt.style.top=this.#Qt.top-18-18*this.#mt.attributes.length+"px"}}class Xt{#Q;#Nt;#U;#jt;#H;#ft;#W;#Y;#K;#J;#gt;#u;#zt;#Qt;#Bt;constructor(t,e,i,n,s,{id:o,pred:r,subj:a,obj:l},c,h){this.#Q=t,this.#Nt=e,this.#U=i,this.#jt=n,this.#H=o,this.#W=a,this.#Y=l,this.#K=s,this.#J=c,this.#gt=h,this.#u=!1,this.#zt=!1,this.typeName=r}get id(){return this.#H}set id(t){this.#H=t}get typeName(){return this.#ft}set typeName(t){this.#ft=String(t)}get typeValues(){return new Ot(this.#ft,this.#jt.getAttributesFor(this.#H))}get subj(){return this.#W}get obj(){return this.#Y}get attributes(){return this.#jt.getAttributesFor(this.#H)}get sourceEntity(){return this.#U.get(this.subj)}get targetEntity(){return this.#U.get(this.obj)}get sourceColor(){return this.sourceEntity.color}get targetColor(){return this.targetEntity.color}get isSelected(){return this.#u}get isHovered(){return this.#zt}select(){this.#u||(this.#u=!0,this.#Bt&&this.#Bt.updateHighlighting())}deselect(){this.#u&&(this.#u=!1,(this.#Qt||this.#Bt)&&this.redrawLineConsideringSelection())}render(t,e){this.sourceEntity.isInViewport(t,e)||this.targetEntity.isInViewport(t,e)?(this.#Qt?this.#qt():(this.#Qt=new zt(this.#Q,this,this.#gt,t=>{this.#Nt.emit("textae-event.editor.relation.click",t,this),t.stopPropagation()},(t,e)=>{this.#Nt.emit("textae-event.editor.relation-bollard.click",t,e),t.stopPropagation()},()=>this.#Zt(),()=>this.#Ft()),this.#Bt=new Ft(this.#Q,this,this.#Qt,(t,e)=>{this.#Nt.emit("textae-event.editor.relation.click",t,this,e),t.stopPropagation()},()=>this.#Zt(),()=>this.#Ft())),this.sourceEntity.clientTop>this.targetEntity.clientTop&&this.targetEntity.isInViewport(t,e)||this.sourceEntity.clientTop<this.targetEntity.clientTop&&this.sourceEntity.isInViewport(t,e)||this.sourceEntity.clientTop===this.targetEntity.clientTop?this.#Bt?this.#Xt():(this.#Bt=new Ft(this.#Q,this,this.#Qt,(t,e)=>{this.#Nt.emit("textae-event.editor.relation.click",t,this,e),t.stopPropagation()},()=>this.#Zt(),()=>this.#Ft()),this.#Bt.updateHighlighting()):this.#Bt&&(this.#Bt.destructor(),this.#Bt=void 0)):(this.#Qt||this.#Bt)&&this.erase()}updateElement(){this.#Qt&&this.#Qt.update(this.isSelected,this.isSelected,this.isSelected),this.#Bt&&this.#Bt.updateValue()}redrawLineConsideringSelection(){this.#qt(),this.#Xt()}pointUpPathAndSourceBollards(){this.#Qt&&(this.targetEntity.isSelected?this.#Qt.update(!0,!0,!0):this.#Qt.update(!0,!0,this.isSelected)),this.#Bt&&this.#Bt.updateHighlighting()}pointUpPathAndTargetBollards(){this.#Qt&&(this.sourceEntity.isSelected?this.#Qt.update(!0,!0,!0):this.#Qt.update(!0,this.isSelected,!0)),this.#Bt&&this.#Bt.updateHighlighting()}pointUpSourceBollardsAndTargetBollards(){this.#Qt&&this.#Qt.update(this.isSelected,!0,!0),this.#Bt&&this.#Bt.updateHighlighting()}pointUpSourceBollards(){this.#Qt&&this.#Qt.update(this.isSelected,!0,this.isSelected),this.#Bt&&this.#Bt.updateHighlighting()}pointUpTargetBollards(){this.#Qt&&this.#Qt.update(this.isSelected,this.isSelected,!0),this.#Bt&&this.#Bt.updateHighlighting()}erase(){this.#Qt&&(this.#Qt.destructor(),this.#Qt=void 0),this.#Bt&&(this.#Bt.destructor(),this.#Bt=void 0)}get title(){return`[${this.id}] pred: type, value: ${this.typeName}`}get color(){return this.#J.getColor(this.typeName)}get anchorHTML(){return pt(this.#lt,this.#nt)}get#lt(){return ht(this.#K,this.typeName,this.#J.getLabel(this.typeName))}get#nt(){return ft(this.#K,this.typeName,this.#J.getURI(this.typeName))}#Zt(){this.#zt=!0,this.#Qt.update(!0,!0,!0),this.#Bt&&this.#Bt.updateHighlighting();const t=new Set,e=new Set,i=new Set;for(const i of this.sourceEntity.relationsWhereThisIsSource)i!==this&&(i.targetEntity==this.targetEntity?t.add(i):e.add(i));for(const e of this.sourceEntity.relationsWhereThisIsTarget)e!==this&&(e.sourceEntity==this.targetEntity?t.add(e):i.add(e));for(const i of this.targetEntity.relationsWhereThisIsSource)i!==this&&(i.targetEntity==this.sourceEntity?t.add(i):e.add(i));for(const e of this.targetEntity.relationsWhereThisIsTarget)e!==this&&(e.sourceEntity==this.sourceEntity?t.add(e):i.add(e));for(const e of t)e.pointUpSourceBollardsAndTargetBollards();for(const t of e)t.pointUpSourceBollards();for(const t of i)t.pointUpTargetBollards()}#Ft(){this.#zt=!1;const t=new Set;for(const e of this.sourceEntity.relations)t.add(e);for(const e of this.targetEntity.relations)t.add(e);for(const e of t)e.redrawLineConsideringSelection()}#qt(){this.#Qt&&(this.sourceEntity.isSelected&&this.targetEntity.isSelected?this.#Qt.update(!0,!0,!0):this.sourceEntity.isSelected?this.#Qt.update(!0,!0,this.isSelected):this.targetEntity.isSelected?this.#Qt.update(!0,this.isSelected,!0):this.#Qt.update(this.isSelected,this.isSelected,this.isSelected))}#Xt(){this.#Bt&&this.#Bt.updateHighlighting()}}class Ht extends gt{#Q;#Nt;#Ht;#K;#J;#gt;constructor(t,e,i,n){super(e,"relation",()=>"R"),this.#Q=t,this.#Nt=e,this.#Ht=i,this.#K=i.namespaceInstanceContainer,this.#J=n}set toolBarHeight(t){this.#gt=t}_toInstance(t){return new Xt(this.#Q,this.#Nt,this.#Ht.entityInstanceContainer,this.#Ht.attributeInstanceContainer,this.#K,t,this.#J,this.#gt)}add(t){t=t instanceof Xt?t:new Xt(this.#Q,this.#Nt,this.#Ht.entityInstanceContainer,this.#Ht.attributeInstanceContainer,this.#K,t,this.#J,this.#gt);const e=super.add(t),{clientHeight:i,clientWidth:n}=document.documentElement;return e.render(i,n),e}changeType(t,e){const i=super.changeType(t,e);return i.updateElement(),i}remove(t){console.assert(t,"id is necessary!");super.remove(t).erase()}clear(){for(const t of this.all)t.erase();super.clear()}}class Wt{#M;#H;#jt;#G;#K;#Wt;#Vt;#gt;#u=!1;#zt=!1;#Yt=!1;#Rt=null;#Ut;#ft;constructor(t,e,i,n,s,o,r,a,l,c=null){this.#M=t,this.#H=c,this.#jt=e,this.#G=i,this.#Wt=s,this.#Vt=o,this.#K=n,this.#gt=l,this.span=r,this.typeName=a}get id(){return this.#H}set id(t){this.#H=t}get title(){return`[${this.id}] pred: type, value: ${this.#ft}`}get color(){return this.#J.getColor(this.typeName)}get anchorHTML(){return pt(this.#lt,this.#nt)}get span(){return this.#Ut}set span(t){this.#Ut=t,t.add(this)}get typeName(){return this.#ft}set typeName(t){this.#ft=String(t)}get typeValues(){return new Ot(this.#ft,this.#jt.getAttributesFor(this.#H))}get relations(){return this.relationsWhereThisIsSource.concat(this.relationsWhereThisIsTarget)}get attributes(){return this.#jt.getAttributesFor(this.#H)}get relationsWhereThisIsSource(){return this.#G.all.filter(t=>t.subj===this.id)}get relationsWhereThisIsTarget(){return this.#G.all.filter(t=>t.obj===this.id)}get hasMultipleEndpoints(){const t=new Map;t.set("whereThisIsSourceAndTargetIsOnTheLeft",new Set),t.set("whereThisIsSourceAndTargetIsOnTheRight",new Set),t.set("whereThisIsSourceAndTargetIsUpOrDown",new Set);for(const e of this.relationsWhereThisIsSource)e.targetEntity.offsetCenter<this.offsetCenter?t.get("whereThisIsSourceAndTargetIsOnTheLeft").add(e):this.offsetCenter<e.targetEntity.offsetCenter?t.get("whereThisIsSourceAndTargetIsOnTheRight").add(e):t.get("whereThisIsSourceAndTargetIsUpOrDown").add(e);t.set("whereThisIsTargetAndSourceIsOnTheLeft",new Set),t.set("whereThisIsTargetAndSourceIsOnTheRight",new Set),t.set("whereThisIsTargetAndSourceIsUpOrDown",new Set);for(const e of this.relationsWhereThisIsTarget)e.sourceEntity.offsetCenter<this.offsetCenter?t.get("whereThisIsTargetAndSourceIsOnTheLeft").add(e):this.offsetCenter<e.targetEntity.offsetCenter?t.get("whereThisIsTargetAndSourceIsOnTheRight").add(e):t.get("whereThisIsTargetAndSourceIsUpOrDown").add(e);return[...t.values()].filter(t=>t.size).length>1}get clientTop(){const{span:t}=this;if(t.isDenotation){let e=t.clientTopOfGrid+this.#Wt.height;for(const i of t.entities){if(i===this)break;e+=this.#Wt.height+i.height}return T(e)}if(t.isBlock){const e=15;return T(t.clientBottomOfGrid-this.height-e)}throw new Error("Unexpected type of span")}get offsetTop(){return this.clientTop-this.span.element.offsetParent.offsetParent.getBoundingClientRect().top}get clientBottom(){return this.clientTop+this.height}isInViewport(t){return this.#gt<=this.clientBottom&&this.clientTop<=t}get width(){return this.span.widthOfGrid}get height(){return 18+this.#Gt}get heightWithTypeGap(){return this.height+this.#Wt.height}get offsetCenter(){return T(this.span.offsetCenterOfGrid)}get isDenotation(){return this.#Ut.isDenotation}get isBlock(){return this.#Ut.isBlock}get isSelected(){return this.#u}getSourceAnchorPosition(t){const e=this.width/2>=28||this.hasMultipleEndpoints&&t;return{left:e?this.offsetCenter-24:this.offsetCenter,right:e?this.offsetCenter+24:this.offsetCenter}}getTargetAnchorPosition(t){const e=this.width/2>=28||this.hasMultipleEndpoints&&t;return{left:e?this.offsetCenter-8:this.offsetCenter,right:e?this.offsetCenter+8:this.offsetCenter}}focus(){if(this.isDenotation)this.span.focus();else{if(!this.isBlock)throw new Error("Unexpected type of entity");this.span.forceRenderGrid(),this.#Rt.focus()}}select(){this.#u||(this.#u=!0,this.#Kt(),this.#Jt())}deselect(){this.#u&&(this.#u=!1,this.#Rt&&this.#Rt.deselect(),this.#Jt())}startCut(){this.#Rt&&this.#Rt.startCut()}cancelCut(){this.#Rt&&this.#Rt.cancelCut()}render(){if(!this.#Rt&&this.span.isGridRendered){this.#Rt=this.#te(),this.span.addEntityElementToGridElement(this.#Rt.element),this.reflectTypeGapInTheHeight();for(const t of this.span.entities.filter(t=>t!==this))for(const e of t.relations)e.redrawLineConsideringSelection();this.#u&&this.#Rt.select()}}updateElement(){if(this.#Rt){this.#Rt=this.#Rt.replaceWith(this.#te()),this.#u&&this.#Kt(),this.reflectTypeGapInTheHeight(),this.span.updateSelfAndAncestorsGridPosition();for(const t of this.span.entities)for(const e of t.relations)e.redrawLineConsideringSelection()}}reflectTypeGapInTheHeight(){this.isDenotation&&this.#Rt&&this.#Rt.reflectTypeGapInTheHeight(this.#Wt.height)}clarifyLabel(){this.#Rt&&this.#Rt.clarifyLabel(),this.#Yt=!0}declarifyLabel(){!this.#zt&&this.#Rt&&this.#Rt.declarifyLabel(),this.#Yt=!1}erase(){this.#Rt&&(this.#Rt.remove(),this.#Rt=null,this.span.updateSelfAndAncestorsGridPosition())}#te(){const t=new Zt(this,this.isDenotation?"denotation":"block",`${this.#M}__E${this.id.replace(/[:¥.]/g,"")}`);return t.addEventListener("mouseenter",()=>{t.clarifyLabel(),this.#ee(),this.#zt=!0}),t.addEventListener("mouseleave",()=>{this.#Yt||t.declarifyLabel(),this.#Jt(),this.#zt=!1}),t}#Kt(){this.span.forceRenderGrid(),this.#Rt.select(),this.span.isGridBeforePositioned?this.span.entityToFocusOn=this:this.focus()}get#J(){if(this.isDenotation)return this.#Vt.denotation;if(this.isBlock)return this.#Vt.block;throw"unknown entity type"}get#lt(){return ht(this.#K,this.typeName,this.#J.getLabel(this.typeName))}get#nt(){return ft(this.#K,this.typeName,this.#J.getURI(this.typeName))}get#Gt(){return this.attributes.map(({height:t})=>t).reduce((t,e)=>t+e,0)}#ee(){for(const t of this.relationsWhereThisIsSource)t.pointUpPathAndSourceBollards();for(const t of this.relationsWhereThisIsTarget)t.pointUpPathAndTargetBollards()}#Jt(){for(const t of this.relations)t.redrawLineConsideringSelection()}}class Vt extends gt{#M;#Ht;#Wt;#K;#gt;constructor(t,e,i,n){super(e,"entity",t=>t.isDenotation?"T":"B"),this.#M=t,this.#Ht=i,this.#Wt=n,this.#K=i.namespaceInstanceContainer}get#T(){return this.#Ht.spanInstanceContainer}get#jt(){return this.#Ht.attributeInstanceContainer}get#G(){return this.#Ht.relationInstanceContainer}set toolBarHeight(t){this.#gt=t}_toInstance(t,e){const i=this.#ie(e,t);return new Wt(this.#M,this.#jt,this.#G,this.#K,this.#Wt,this.#Ht.typeDictionary,i,t.obj,this.#gt,t.id)}add(t){if(t instanceof Wt){if(!t.span)throw new Error(`entity has no span! ${JSON.stringify(t)}`);return super.add(t),t.span.add(t),t.render(),t}if(void 0===t.spanType||void 0===t.begin||void 0===t.end)throw new Error(`entity has no span information! ${JSON.stringify(t)}`);const e=this.#T.find(t.spanType,t.begin,t.end),i=new Wt(this.#M,this.#jt,this.#G,this.#K,this.#Wt,this.#Ht.typeDictionary,e,t.typeName,this.#gt);return console.assert(i.span.isDenotation||i.span.entities.length>0,"A block span cannot have more than one entity."),super.add(i),i.render(),i}remove(t){const e=super.get(t);e.span.remove(e),super.remove(t),e.erase()}changeType(t,e){const i=super.changeType(t,e);return i.updateElement(),i}moveEntities(t,e){for(const i of e){i.erase();const e=i.span;e.remove(i),e.updateSelfAndAncestorsGridPosition(),i.span=t,i.render();for(const t of i.relations)t.redrawLineConsideringSelection()}super._emit("textae-event.annotation-data.entity.move")}get denotations(){return this.all.filter(t=>t.isDenotation)}get blocks(){return this.all.filter(t=>t.isBlock)}redrawEntitiesWithSpecifiedAttribute(t){const e=this.all.filter(e=>e.typeValues.hasSpecificPredicateAttribute(t));for(const t of e)t.updateElement();for(const t of new Set([...e.map(({span:t})=>t)]))t.updateGridPosition()}clarifyLabelOfAll(){for(const t of this.all)t.clarifyLabel()}declarifyLabelOfAll(){for(const t of this.all)t.declarifyLabel()}#ie(t,e){return this.#T.find(t,e.span.begin,e.span.end)}hasDenotation(t){return this.denotations.some(e=>e.id===t)}}class Yt{constructor(t){this._trackNumber=t}addTrackNumberAsIDPrefix(t,e,i,n){const s=t.map(t=>({...t,id:this._prependToIDOf(t)})),o=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:s,blocks:o,relations:a,attributes:r}}_prependToIDOf(t){return t.id?this._prependTrackNumberTo(t.id):null}_prependTrackNumberTo(t){return this._trackNumber+t}}function Ut(t){const{span:e}=t;return{...t,span:Gt(e)}}function Gt(t){return{...t,begin:parseInt(t.begin),end:parseInt(t.end)}}function Kt(t,e,i,n,s,o=""){const[r,a,l]=function(t,e,i){return[t.map(Ut),e.map(Ut),i.map(Ut)]}(s.typeSetting,s.denotation,s.block),{relation:c,attribute:h}=s,{denotations:u,blocks:d,relations:f,attributes:p}=new Yt(o).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 Jt(t,e){return 0<=t&&t<=e.length}class te{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 ee(t,e){return e.reduce((e,i)=>e.concat(i.getErrors(t)),[])}class ie{constructor(t,e,i="",n=()=>!0,s){this._candidates=t||[],this._name=i,this._predicate=n,this._prevValidation=s,this._sourcePropertyName=e}and(t,e){return new ie(this._candidates,this._sourcePropertyName,t,e,this)}validateAll(){const t=new te;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 ne(t,e,i,n){return new ie(t,n).and("hasLength",t=>t.span.end-t.span.begin>0).and("inText",t=>function(t,e){return Jt(e.begin,t)&&Jt(e.end,t)}(e,t.span)).and("isNotCrossing",t=>{const e=H(i,t.span.begin,t.span.end);return[0===e.length,e]})}function se(t,e){return t.some(t=>t.id===e)}function oe(t,e){return void 0===e.id||1===t.filter(t=>e.id&&e.id===t.id).length}function re(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(", ")}`)}function ae(t){const{typesettings:e,denotations:i,blocks:n}=t;return(e||[]).concat(i||[]).concat(n||[])}function le(t,e,i){const[n,s]=function(t,e,i){return ne(e,t,i,"typesettings").validateAll()}(t,i.typesettings,e),o=ae(i),[r,a]=function(t,e,i,n){return ne(e,t,i,"denotations").and("uniqueID",t=>oe(n,t)).validateAll()}(t,i.denotations,e,o),[l,c]=function(t,e,i,n){return ne(e,t,i,"blocks").and("uniqueID",t=>oe(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,o),[h,u]=(d=r.concat(l),f=i.relations,new ie(f).and("object",t=>se(d,t.obj)).and("subject",t=>se(d,t.subj)).validateAll());var d,f;const[p,m]=(g=r.concat(l).concat(h),v=i.attributes,new ie(v).and("subject",t=>se(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 re("TypeSettings",s),re("Denotations",a),re("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:s.getErrors("hasLength"),outOfTextTypesettings:s.getErrors("inText"),duplicatedIDs:ee("uniqueID",[a,c]),boundaryCrossingSpans:ee("isNotCrossing",[s,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||s.size}}}class ce{#K;#T;#U;#G;#jt;#ne;#se;#oe;constructor(t,e){const{namespaceInstanceContainer:i,spanInstanceContainer:n,entityInstanceContainer:s,attributeInstanceContainer:o,relationInstanceContainer:r}=t;this.#K=i,this.#T=n,this.#U=s,this.#G=r,this.#jt=o,this.#ne=e}eval(){this.#ne.namespaces?this.#K.addSource(this.#ne.namespaces.map(t=>({id:t.prefix,...t}))):this.#K.addSource([]);const{accept:t,reject:e}=le(this.#re,this.#ae,this.#ne);Kt(this.#T,this.#U,this.#jt,this.#G,t),e.name="Root annotations.",this.#se=e,this.hasMultiTracks&&(this.#oe=function(t,e,i,n,s,o,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}=le(s,o,r);return Kt(t,e,i,n,h,c),u.name=`Track ${l} annotations.`,u})}(this.#T,this.#U,this.#jt,this.#G,this.#re,this.#ae,this.#ne))}get hasMultiTracks(){return Boolean(this.#ne.tracks)}get rejects(){return this.hasMultiTracks?[this.#se].concat(this.#oe):[this.#se]}get#re(){return this.#ne.text}get#ae(){return function(t){let e=ae(t);if(t.tracks)for(const i of t.tracks)e=e.concat(ae(i));return e}(this.#ne)}}function he(t){return t.relationInstanceContainer.all.map(t=>({id:t.id,pred:t.typeName,subj:t.subj,obj:t.obj}))}function ue(t){return t.entityInstanceContainer.blocks.map(t=>({id:t.id,span:{begin:t.span.begin,end:t.span.end},obj:t.typeName}))}class de{constructor(t){this._isGapShown=!0,this._numberOfGap=1,this._callback=t}set show(t){this._isGapShown!==t&&(this._isGapShown=t,this._callback(this.value))}get show(){return this._isGapShown}get value(){return this._isGapShown?this._numberOfGap:0}get height(){return 24*this.value}set value(t){this._numberOfGap!==t&&(this._numberOfGap=t,this._callback(t))}}function fe(t){const e=parseInt(t,10);return isNaN(e)?0:e}class pe{#Q;#r;#Ht;#le;constructor(t,e,i){this.#Q=t,this.#r=t.querySelector(".textae-editor__text-box"),this.#Ht=e,this.#le=i}get boundingClientRect(){return this.#r.getBoundingClientRect()}get lineHeight(){return t=this.#r,fe(window.getComputedStyle(t).lineHeight);var t}set lineHeight(t){var e,i,n;e=this.#r,i=t,n=this.#le,e.style.lineHeight=`${i}px`,e.style.paddingTop=`${i/2+n}px`,this.forceUpdate(),this.#Ht.updatePosition()}render(t){this.#r.innerHTML=t.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#039;")}updateLineHeight(){const t=this.#Ht.spanInstanceContainer.maxHeight;t?this.lineHeight=t:this.#ce()}forceUpdate(){!function(t,e){const i=window.getComputedStyle(t);t.style.height="auto",t.style.height=`${t.offsetHeight-fe(i.paddingTop)+20+e}px`}(this.#r,this.#le),this.#he()}#ce(){const{lineHeight:t}=window.getComputedStyle(this.#Q);this.lineHeight=fe(t)}#he(){const t=this.#Q.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 me(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 pe(t,e,i)}var ge=i(504),ve=i.n(ge);class ye{#Nt;#ue;#de;#fe;#pe;#me=new(ve())(!1);constructor(t,e,i,n,s,o=!0){this.#Nt=t,this.#ue=e,this.#de=i,this.#fe=n,this.#pe=s,this.#me(()=>this.#Nt.emit("textae-event.type-definition.lock")),this.#me.set(o)}set autocompletionWs(t){this.#ue.autocompletionWs=t,this.#fe.autocompletionWs=t,this.#de.autocompletionWs=t}set autocompletionFunction(t){this.#ue.autocompletionFunction=t,this.#fe.autocompletionFunction=t,this.#de.autocompletionFunction=t}get denotation(){return this.#ue}get block(){return this.#de}get relation(){return this.#fe}get attribute(){return this.#pe}get autocompletionWs(){return this.#ue.autocompletionWs}get config(){const t={};return this.#ue.config.length&&(t["entity types"]=this.#ue.config),this.#fe.config.length&&(t["relation types"]=this.#fe.config),this.#pe.config.length&&(t["attribute types"]=this.#pe.config),this.#de.config.length&&(t["block types"]=this.#de.config),t}get isLock(){return this.#me()}lockEdit(){this.#me.set(!0)}unlockEdit(){this.#me.set(!1)}setTypeConfig(t){t?(this.#ue.config=t["entity types"],this.#fe.config=t["relation types"],this.#pe.config=t["attribute types"],this.#de.config=t["block types"],this.autocompletionWs=t.autocompletion_ws):(this.#ue.config=null,this.#fe.config=null,this.#pe.config=null,this.#de.config=null,this.autocompletionWs=""),this.#Nt.emit("textae-event.type-definition.reset")}}function Oe(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}function be(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 xe{#H;#st;#Bt;#ge;constructor(t,e,i,n){this.#H=t,this.#st=e,this.#Bt=i,this.#ge=n}get id(){return this.#H}get color(){return this.#st}get label(){return this.#Bt}get default(){return this.#ge}toJSON(){return{id:this.#H,color:this.#st,label:this.#Bt,default:this.#ge}}}class we{#ve;constructor(t=[]){this.#ve=t.map(t=>new xe(t.id,t.color,t.label,t.default))}has(t){return this.map.has(t)}get default(){return this.#ve.find(t=>!0===t.default)}replace(t,e){e=new xe(e.id,e.color,e.label,e.default);const i=this.#ve.findIndex(e=>e.id===t);-1!==i?this.#ve.splice(i,1,e):this.#ve.push(e)}delete(t){this.#ve=this.#ve.filter(e=>e.id!==t)}ids(){return this.map.keys()}getColorOf(t){return this.#ye(t)?.color}getLabelOf(t){return this.#ye(t)?.label}labelsIncludes(t){return this.#ve.filter(t=>t.label).filter(e=>e.label.includes(t))}get map(){return new Map(this.#ve.map(t=>[t.id,t]))}#ye(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 _e(t,e){const i=new URL(t,location);return i.searchParams.append("term",e),fetch(i.href).then(t=>t.ok?t.json():[])}class Se{#Nt;#Oe;#be=new we([]);#xe;#we;#_e;#Se="";#ke;constructor(t,e,i,n){this.#Nt=t,this.#Oe=e,this.#xe=i,this.#we=n}set autocompletionWs(t){this.#Se=t}set autocompletionFunction(t){this.#ke=t}get autocompletionWs(){return this.#Se}get annotationType(){return this.#Oe}get config(){const t=this.#$e;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.#be=new we(t);const e=this.#be.default;e?(delete e.default,this.#_e=e.id):this.#_e=null}has(t){return this.#be.has(t)}get(t){const e={...this.#be.map.get(t)};return this.#_e===t?(e.default=!0,e):(delete e.default,e)}replace(t,e){this.#be.replace(t,e),this.#Nt.emit(`textae-event.type-definition.${this.#Oe}.change`,e.id)}addDefinedType(t){if(void 0===t.color){const e=this.getColor(t.id);e!==this.#we&&(t.color=e)}if(void 0===t.label){const e=this.getLabel(t.id);e&&(t.label=e)}t.default&&(this.#_e=t.id),this.replace(t.id,t)}get defaultType(){return this.#_e?this.#_e:this.#xe().length>0?Oe(be(this.#$e,this.#xe()))[0]:"something"}set defaultType(t){this.#_e=t,this.#Nt.emit(`textae-event.type-definition.${this.#Oe}.change-default`,t)}get defaultColor(){return this.#we}getColor(t){return this.#be.getColorOf(t)||this.#we}getLabel(t){return this.#be.getLabelOf(t)}getURI(t){return ct(t)?t:void 0}searchByLabel(t,e){if("function"==typeof this.#ke){const i=this.#ke(t),n=this.mergeWithLocalData(i,t);return void e(n)}this.#Se?_e(this.#Se,t).then(i=>{const n=this.mergeWithLocalData(i,t);e(n)}):e(this.findByLabel(t))}findByLabel(t){return this.#be.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=be(this.#$e,this.#xe());return function(t,e,i,n,s){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)||s,useNumber:e.get(t).usage}))}(Oe(t),t,this.#be,this.defaultType,this.#we)}get#$e(){const t=this.#be.map;for(const{typeName:e}of this.#xe())t.has(e)||t.set(e,new xe(e));return t}delete(t,e){this.#be.delete(t),this.#_e=e,this.#Nt.emit(`textae-event.type-definition.${this.#Oe}.delete`,t)}}class ke{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}}class $e extends ke{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}}}function Ce(t,e){return t<=e}function Te(t,e){return t<e}function Pe(t){if(t.startsWith("["))return e=>Ce(new Number(t.replace("[","")),e);if(t.startsWith("("))return e=>Te(new Number(t.replace("(","")),e);throw`${t} is not valid interval notation`}function Ee(t){if(t.endsWith("]"))return e=>Ce(e,new Number(t.replace("]","")));if(t.endsWith(")"))return e=>Te(e,new Number(t.replace(")","")));throw`${t} is not valid interval notation`}class Ae{constructor(t){const[e,i]=t.split(",");if(i?(this._lowwerCond=Pe(e),this._upperCond=Ee(i)):((e.startsWith("[")||e.startsWith("("))&&(this._lowwerCond=Pe(e),this._upperCond=t=>!0),(e.endsWith("]")||e.endsWith(")"))&&(this._lowwerCond=t=>!0,this._upperCond=Ee(e))),!this._lowwerCond||!this._upperCond)throw`${t} is not valid interval notation`}test(t){return this._lowwerCond(t)&&this._upperCond(t)}}function Me(t){return!Number.isNaN(parseFloat(t))}class Qe extends ke{constructor(t,e){super(t,e.pred),this.default=Me(e.default)?parseFloat(e.default):0,Me(e.min)&&(this.min=parseFloat(e.min)),Me(e.max)&&(this.max=parseFloat(e.max)),this.step=Me(e.step)?parseFloat(e.step):2,this._values=e.values||[]}getLabel(t){const e=this.#Ce(t);if(e&&e.label)return e.label}getDisplayName(t){return this.getLabel(t)||String(t)}getColor(t){const e=this.#Ce(t);return e&&e.color?e.color:null}#Ce(t){const e=this._values.filter(t=>"default"!==t.range).find(e=>new Ae(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 De extends ke{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.#Ce(t);if(e&&e.label)return e.label}getDisplayName(t){return this.getLabel(t)}getColor(t){const e=this.#Ce(t);return e&&e.color?e.color:null}get values(){return this._values}get hasOnlyOneValue(){return 1===this._values.length}#Ce(t){return this.values.find(e=>e.id==t)}get externalFormat(){return{...super.externalFormat,"value type":"selection",values:super._valuesClone}}}class Re extends ke{constructor(t,e){super(t,e.pred),this.autocompletionWs=e.autocompletion_ws,this.default=e.default,Me(e["media height"])&&(this.mediaHeight=parseFloat(e["media height"])),this._values=e.values||[]}getLabel(t){const e=this.#Ce(t);if(e&&e.label)return e.label}getDisplayName(t){return this.getLabel(t)}getColor(t){const e=this.#Ce(t);return e&&e.color?e.color:null}#Ce(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 Ie(t,e){switch(t){case"flag":return new $e(t,e);case"numeric":return new Qe(t,e);case"selection":return new De(t,e);case"string":return new Re(t,e);default:throw new Error(`${t} of ${JSON.stringify(e)} is Uknown Attribute`)}}class Le{#Nt;#xe;#be=new Map;constructor(t,e){this.#Nt=t,this.#xe=e}get config(){return this.attributes.map(t=>t.externalFormat)}set config(t){this.#be=new Map((t||[]).map(t=>[t.pred,Ie(t["value type"],t)]))}create(t,e,i=null){null!==i&&this.#be.size!==i?this.#be=new Map(Array.from(this.#be.entries()).reduce((n,[s,o],r)=>(r===i&&n.push([e.pred,Ie(t,e)]),n.push([s,o]),n),[])):this.#be.set(e.pred,Ie(t,e)),this.#Nt.emit("textae-event.type-definition.attribute.create",e.pred)}get(t){return this.#be.get(t)}update(t,e){return this.#be=new Map(Array.from(this.#be.entries()).map(([i,n])=>i===t?[e.pred,Ie(n.valueType,e)]:[i,n])),this.#Nt.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,s;this.#be=new Map((i=this.attributes,n=t,s=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,[s]=t.splice(e,1);t.splice(n,0,s)}}(i=[...i],n,s),i).map(t=>[t.pred,t]));const{pred:o}=this.attributes[-1===e?this.attributes.length-1:e];this.#Nt.emit("textae-event.type-definition.attribute.move",o)}delete(t){this.#be.delete(t),this.#Nt.emit("textae-event.type-definition.attribute.delete")}get attributes(){return Array.from(this.#be.values())||[]}isSelectionAttributeValueIndelible(t,e){return!!this.get(t).hasOnlyOneValue||!!this.#xe().some(i=>i.equalsTo(t,e))}getLabel(t,e){return console.assert(this.#be.has(t),`There is no attribute definition for ${t}.`),this.get(t).getLabel(e)}getDisplayName(t,e){return console.assert(this.#be.has(t),`There is no attribute definition for ${t}.`),this.get(t).getDisplayName(e)}getColor(t,e){if(this.#be.has(t))return this.get(t).getColor(e)}getIndexOf(t){return Array.from(this.#be.values()).findIndex(e=>e.pred===t)}getAttributeAt(t){return Array.from(this.#be.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}}class Ne{constructor(t,e){this._textBox=e,this._enable=!1,t.on("textae-event.control.button.push",({name:t,isPushed:e})=>{"auto adjust lineheight"===t&&(this._enable=e)})}updateLineHeight(){this._enable&&this._textBox.updateLineHeight()}}function je(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}class ze{#Te;#Wt;#O;#Pe;#K;#T;#U;#G;#jt;#Vt;#Q;#Nt;constructor(t,e,i,n,s,o,r,a){this.#Te="",this.#K=new w(i,"namespace");const l=new Se(i,"relation",()=>this.#G.all,"#00CC66");this.#G=new Ht(e,i,this,l),this.#Wt=new de(()=>{for(const t of this.entityInstanceContainer.denotations)t.reflectTypeGapInTheHeight();this.#O.updateLineHeight(),i.emit("textae-event.annotation-data.entity-gap.change")}),this.#U=new Vt(t,i,this,this.#Wt),this.attributeDefinitionContainer=new Le(i,()=>this.#jt.all),this.#jt=new yt(i,this.#U,this.#G,this.#K,this.attributeDefinitionContainer),this.updatePosition=()=>{try{n.startWait(),s(),this.#Ee()}catch(t){console.error(t)}finally{n.endWait(),o()}},this.#O=me(e,this,a),this.#Pe=new Ne(i,this.#O),this.#T=new it(t,e,i,this.#O),je(this,()=>this.#T,["getDenotationSpan","isBoundaryCrossingWithOtherSpans","hasParentOf","validateNewDenotationSpan","validateNewBlockSpan","validateEditableText"]),this.denotationDefinitionContainer=new Se(i,"entity",()=>this.#U.denotations,"#77DDDD");const c=new Se(i,"entity",()=>this.#U.blocks,"#77DDDD");this.#Vt=new ye(i,this.denotationDefinitionContainer,c,l,this.attributeDefinitionContainer,r),i.on("textae-event.annotation-data.span.add",t=>{(t.isDenotation||t.isBlock)&&(this.#O.forceUpdate(),this.#Ee())}).on("textae-event.annotation-data.span.remove",t=>{(t.isDenotation||t.isBlock)&&(this.#O.forceUpdate(),this.#Ee())}).on("textae-event.annotation-data.entity.add",t=>{t.span.isDenotation&&this.#Pe.updateLineHeight()}).on("textae-event.annotation-data.entity.remove",t=>{t.span.isDenotation&&this.#Pe.updateLineHeight()}),i.on("textae-event.type-definition.entity.change",t=>{for(const e of this.#U.all)(e.typeName===t||t.lastIndexOf("*")===t.length-1&&e.typeName.indexOf(0===t.slice(0,-1)))&&e.updateElement()}).on("textae-event.type-definition.attribute.change",t=>this.#U.redrawEntitiesWithSpecifiedAttribute(t)).on("textae-event.type-definition.attribute.move",t=>this.#U.redrawEntitiesWithSpecifiedAttribute(t)).on("textae-event.type-definition.relation.change",t=>{for(const e of this.#G.all)(e.typeName===t||t.lastIndexOf("*")===t.length-1&&e.typeName.indexOf(0===t.slice(0,-1)))&&e.updateElement()}),this.#Q=e,this.#Nt=i}reset(t,e){console.assert(t.text,"This is not a json file of annotations."),this.#Vt.setTypeConfig(e),this.#Te=t.text,this.#O.render(this.sourceDoc),this.#Ae();const i=new ce(this,t);i.eval(),this.#Me(),this.#Nt.emit("textae-event.annotation-data.all.change",i.hasMultiTracks,i.rejects),this.reLayout()}set autocompletionFunction(t){this.#Vt.autocompletionFunction=t}get externalFormat(){return{text:this.#Te,denotations:(t=this,t.entityInstanceContainer.denotations.map(t=>({id:t.id,span:{begin:t.span.begin,end:t.span.end},obj:t.typeName}))),attributes:this.#jt.all.map(({externalFormat:t})=>t),relations:he(this),blocks:ue(this)};var t}getReplicationRanges(t,e){return function(t,e,i,n,s){return function(t,e,i){const n=t.substring(e,i),s=i-e,o=[];let r=0;for(let e=t.indexOf(n);-1!==e;e=t.indexOf(n,r))r=e+s,o.push({begin:e,end:r});return o}(t,e,i).filter(({begin:t})=>t!==e).filter(({begin:e,end:i})=>function(t,e,i,n){const s=t.charAt(e-1),o=t.charAt(i);return n(s)&&n(o)}(t,e,i,s)).filter(({begin:t,end:e})=>!n.find("denotation",t,e)).filter(({begin:t,end:e})=>!n.isBoundaryCrossingWithOtherSpans(t,e))}(this.sourceDoc,t.begin,t.end,this.#T,e)}get typeGap(){return this.#Wt}get textBox(){return this.#O}get sourceDoc(){return this.#Te.replaceAll(/\r\n/g," \n")}get typeDictionary(){return this.#Vt}get spanInstanceContainer(){return this.#T}getSpan(t){return this.#T.get(t)}get entityInstanceContainer(){return this.#U}get relationInstanceContainer(){return this.#G}get attributeInstanceContainer(){return this.#jt}get namespaceInstanceContainer(){return this.#K}get textSelection(){return this.#T.textSelection}findDenotation(t,e){return this.#T.find("denotation",t,e)}findBlock(t,e){return this.#T.find("block",t,e)}getTextBetween(t,e){return this.sourceDoc.substring(t,e)}changeTextBetween(t,e,i){this.#Te=`${this.#Te.slice(0,t)}${i}${this.#Te.slice(e)}`;const n=i.length-(e-t),s=this.#T.offsetSpans(t,e,n);return this.#O.render(this.sourceDoc),this.#Me(),this.#Nt.emit("textae-event.annotation-data.text.change"),s}hasCharacters(t){const{begin:e,end:i}=this.textSelection,n=this.getTextBetween(e,i);return t.removeBlankCharacters(n).length>0}getTextSelection(t,e){const{begin:i,end:n}=this.textSelection;return{begin:e.backFromBegin(this.sourceDoc,i,t),end:e.forwardFromEnd(this.sourceDoc,n-1,t)+1}}getInstanceContainerFor(t){switch(t){case"span":return this.#T;case"relation":return this.#G;case"entity":return this.#U;case"attribute":return this.#jt}}drawGridsInSight(){if(this.#Qe){const{clientHeight:t,clientWidth:e}=document.documentElement;for(const i of this.#T.allDenotationSpans)i.drawGrid(t,e);for(const i of this.#T.allBlockSpans)i.drawGrid(t,e),i.updateBackgroundPosition();for(const i of this.#G.all)i.render(t,e)}}reLayout(){this.#O.forceUpdate(),this.#Qe&&this.updatePosition()}set toolBarHeight(t){this.#U.toolBarHeight=t,this.#G.toolBarHeight=t}get#Qe(){const{clientHeight:t}=document.documentElement,{top:e,bottom:i}=this.#Q.getBoundingClientRect();return 0<=i&&e<=t}focusDenotation(t){console.assert(this.#U.hasDenotation(t),"The denotation does not exist.");const{span:e}=this.#U.get(t);e.focus()}#Me(){this.#T.renderAll(),this.#O.updateLineHeight(),this.drawGridsInSight()}#Ee(){this.#T.arrangeDenotationEntityPosition(),this.#T.arrangeBackgroundOfBlockSpanPosition(),this.#T.arrangeBlockEntityPosition();for(const t of this.#G.all)t.sourceEntity.span.isGridRendered&&t.targetEntity.span.isGridRendered&&t.redrawLineConsideringSelection()}#Ae(){this.#T.clear(),this.#U.clear(),this.#jt.clear(),this.#G.clear(),this.#K.clear(),I(this.#Q).innerHTML=""}}const Be={"delimiter characters":[" ",".","!","?",",",":",";","-","/","&","(",")","{","}","[","]","+","*","\\",'"',"'","\n","–"],"non-edge characters":[" ","\n"]};class qe{#De;#Re;constructor(){this.#De=[],this.#Re=[]}get delimiterCharacters(){return this.#De}get blankCharacters(){return this.#Re}set(t){const e={...Be,...t};return this.#De=e["delimiter characters"],this.#Re=e["non-edge characters"],t}isDelimiter(t){return this.#De.indexOf("ANY")>=0?1:this.#De.indexOf(t)>=0}isBlankCharacter(t){return this.#Re.indexOf(t)>=0}removeBlankCharacters(t){for(const e of this.#Re)t=t.replaceAll(e,"");return t}}class Ze{constructor(t){this._resetHistory(),this._eventEmitter=t,t.on("textae-event.type-definition.reset",()=>{this._removeConfigurationOperationsFromHistory(),this._trigger()}).on("textae-event.annotation-data.all.change",()=>{this._resetHistory(),this._trigger()}).on("textae-event.resource.annotation.save",()=>{this._trigger()}).on("textae-event.resource.configuration.save",()=>{this._trigger()})}push(t){this._histories.splice(this._pointer+1,this._histories.length-this._pointer,t),this._pointer++,this._trigger()}next(){this._pointer++;const t=this._histories[this._pointer];return this._trigger(),t}prev(){const t=this._histories[this._pointer];return this._pointer--,this._trigger(),t}get hasAnythingToUndo(){return this._pointer>-1}get hasAnythingToRedo(){return this._pointer<this._histories.length-1}_trigger(){this._eventEmitter.emit("textae-event.history.change",this)}_removeConfigurationOperationsFromHistory(){for(let t=0;t<this._histories.length;t++)this._histories[t].isExactly("configuration_command")&&(this._pointer--,this._histories.splice(t,1))}_resetHistory(){this._pointer=-1,this._histories=[]}}function Fe(t,e,i){i?console.log(`[${t.constructor.name}]`,e,i):console.log(`[${t.constructor.name}]`,e)}class Xe{get isEmpty(){return!1}isExactly(t){return this.kind.has(t)&&1===this.kind.size}}class He extends Xe{get kind(){return new Set(["annotation_command"])}}class We extends He{#Ht;#Oe;#Et;#Ie;constructor(t,e,i,n=null){super(),this.#Ht=t,this.#Oe=e,this.#Et=i,this.#Ie=n}execute(){this.#Et=this.#Ht.getInstanceContainerFor(this.#Oe).add(this.#Et),this.#Ie&&this.#Ie.add(this.#Oe,[this.#Et.id]),Fe(this,`${this.#Oe}: ${this.#Et.id}`)}revert(){return new Ve(this.#Ht,this.#Oe,this.#Et)}}class Ve extends He{#Ht;#Oe;#Et;constructor(t,e,i){super(),this.#Ht=t,this.#Oe=e,this.#Et=i}execute(){this.#Ht.getInstanceContainerFor(this.#Oe).remove(this.#Et.id),Fe(this,`${this.#Oe}: ${this.#Et.id}`)}revert(){return new We(this.#Ht,this.#Oe,this.#Et)}}class Ye extends Xe{get kind(){return new Set(["configuration_command"])}}class Ue extends Ye{constructor(t,e,i,n=null){super(),this._definitionContainer=t,this._attrDef=e,this._index=i,this._indexThatAddDefaultTo=n}execute(){const t=[...this._attrDef.values];if("selection"===this._attrDef.valueType&&t[this._index].default&&null===this._indexThatAddDefaultTo){let e=null;t.forEach((t,i)=>{null===e&&i!=this._index&&(e=i)}),t[e]={...t[e],default:!0}}this._deletedValue=t.splice(this._index,1)[0],"selection"===this._attrDef.valueType&&null!==this._indexThatAddDefaultTo&&(t[this._indexThatAddDefaultTo]={...t[this._indexThatAddDefaultTo],default:!0}),this._updatedAttrDef=this._definitionContainer.updateValues(this._attrDef.pred,t),Fe(this,`remove a value from an attrribute:${this._attrDef.pred}, index:${this._index}, updated values: \n ${t.map(t=>JSON.stringify(t)).join("\n ")}`)}revert(){return new Ge(this._definitionContainer,this._updatedAttrDef,this._deletedValue,this._index)}}class Ge extends Ye{constructor(t,e,i,n=null){super(),this._definitionContainer=t,this._pred=e.pred,this._index=n,this._value=i;const s=[...e.values];if("selection"===e.valueType&&i.default){this._indexThatRemoveDefaultFrom||(this._indexThatRemoveDefaultFrom=s.findIndex(t=>t.default));const t={...s[this._indexThatRemoveDefaultFrom]};delete t.default,s[this._indexThatRemoveDefaultFrom]=t}s.splice(n||s.length,0,i),this._modifiedValues=s}execute(){this._updatedAttrDef=this._definitionContainer.updateValues(this._pred,this._modifiedValues),Fe(this,`add a new value to attrribute:${this._pred}, value: ${JSON.stringify(this._value)}, index: ${this._index}, updated values: \n ${this._modifiedValues.map(t=>JSON.stringify(t)).join("\n ")}`)}revert(){return new Ue(this._definitionContainer,this._updatedAttrDef,this._updatedAttrDef.values.length-1,this._indexThatRemoveDefaultFrom)}}class Ke extends Xe{constructor(){super(),this._isExecuteSubCommandsInReverseOrderWhenRevert=!0}execute(){if(console.assert(this._subCommands,"_subCommands is necessary!"),this.isEmpty)return void(this.revert=()=>({execute(){}}));for(const t of this._subCommands)t.execute();this._afterInvoke&&this._afterInvoke();const t=this;this.revert=()=>({_subCommands:this._subCommands,_logMessage:this._logMessage,_afterInvoke:this._afterInvoke,_isExecuteSubCommandsInReverseOrderWhenRevert:this._isExecuteSubCommandsInReverseOrderWhenRevert,execute(){let e=this._subCommands.map(t=>t.revert());this._isExecuteSubCommandsInReverseOrderWhenRevert&&(e=e.reverse());for(const t of e)t.execute();this._afterInvoke&&this._afterInvoke(),Fe(t,`revert: ${this._logMessage}`)}}),Fe(this,this._logMessage)}get kind(){return this._subCommands.reduce((t,e)=>new Set([...t,...e.kind]),new Set)}get isEmpty(){return!this._subCommands||0===this._subCommands.length}}class Je extends Ye{constructor(t,e,i){super(),this._definitionContainer=t,this._attrDef=e,this._changedProperties=i}execute(){const t=this._attrDef.pred,[e,i]=function(t,e){const i=t.externalFormat,n=new Map;for(const[s,o]of e.entries())null===o&&void 0!==t[s]?(delete i[s],n.set(s,t[s])):null!==o&&(i[s]=o,n.set(s,void 0===t[s]?null:t[s]));return[i,n]}(this._attrDef,this._changedProperties);this._revertAttrDef=this._definitionContainer.update(t,e),this._revertChangedProperties=i,Fe(this,`change old pred:${t} to new attridute definition:${JSON.stringify(e)}`)}revert(){return new Je(this._definitionContainer,this._revertAttrDef,this._revertChangedProperties)}}class ti extends He{#Ht;#Le;#Ne;#je;#ze;#Be;#qe;constructor(t,e,i,n){super(),this.#Ht=t,this.#Le=e,this.#Ne=e.pred,this.#je=e.obj,this.#ze=i,this.#Be=n}execute(){this.#qe=this.#Ht.attributeInstanceContainer.change(this.#Le.id,this.#ze,this.#Be),Fe(this,`attribute: ${this.#Le.id} changed from ${this.#Ne}:${this.#je} to ${this.#qe.pred}:${this.#qe.obj}.`)}revert(){return new ti(this.#Ht,this.#qe,this.#Ne,this.#je)}}class ei extends Ke{constructor(t,e,i,n,s){super(),this._isExecuteSubCommandsInReverseOrderWhenRevert=!1;const o=[new Je(i,n,s)];let r=[];if(s.has("pred")){const i=e.attributeInstanceContainer.getSameDefinitionsAttributes(n.pred);r=i.map(t=>new ti(e,t,s.get("pred"),t.obj)),this._afterInvoke=()=>{t.emit("textae-event.commander.attributes.change",i)}}this._subCommands=o.concat(r),this._logMessage=`set ${[...s.entries()].map(([t,e])=>`${t}:${e}`)} to attribute definition ${n.pred}`}}class ii extends Ke{constructor(t,e,i,n,s){super();const o=[];for(const t of i){const e=t.attributes.find(t=>t.pred==n.pred&&t.obj!==s);e&&o.push(e)}this._subCommands=o.map(t=>new ti(e,t,null,s)),o.length&&(this._afterInvoke=()=>t.emit("textae-event.commander.attributes.change",o)),this._logMessage=`update obj ${s} to attributes: ${o.map(t=>t.id).join(",")}`}}function ni(t,e,i,n){if("string"===e.valueType&&n&&!e.values.some(t=>t.pattern===i)&&n!==e.getLabel(i))return new Ge(t,e,{pattern:i,label:n})}class si extends Ke{constructor(t,e,i,n,s,o,r=null){super();const a=[];for(const t of n){const e=t.attributes.find(t=>t.pred==s.pred&&t.obj!==o);e&&a.push(e)}this._subCommands=a.map(t=>new ti(e,t,null,o)),a.length&&(this._afterInvoke=()=>t.emit("textae-event.commander.attributes.change",a));const l=ni(i,s,o,r);l&&this._subCommands.push(l),this._logMessage=`update obj ${o} to attributes: ${a.map(t=>t.id).join(",")}`}}class oi extends He{#Ze;#Oe;#H;#Fe;constructor(t,e,i,n){super(),this.#Ze=t,this.#Oe=e,this.#H=i,this.#Fe=n}execute(){this.oldType=this.#Ze.getInstanceContainerFor(this.#Oe).get(this.#H).typeName;const t=this.#Ze.getInstanceContainerFor(this.#Oe).changeType(this.#H,this.#Fe);Fe(this,`change type of a ${this.#Oe}. old type:${this.oldType} ${this.#Oe}:`,t)}revert(){return new oi(this.#Ze,this.#Oe,this.#H,this.oldType)}}class ri extends Ke{constructor(t,e,i,n,s){super();const o=e[i].all.filter(t=>!t.typeValues.isSameType(n,s));this._subCommands=o.map(e=>new oi(t,i,e.id,n)),this._subCommands=this._subCommands.concat(function(t,e,i){const n=[];for(const s of t){if(s.typeValues)for(const t of s.attributes){const s=e.find(e=>t.equalsTo(e.pred,e.obj));s?String(t.obj)!==s.obj&&n.push(new ti(i,t,s.pred,s.obj)):n.push(new Ve(i,"attribute",t))}for(const t of e)s.attributes.some(e=>e.equalsTo(t.pred,t.obj))||n.push(new We(i,"attribute",{subj:s.id,pred:t.pred,obj:t.obj}))}return n}(o,s,t));for(const{pred:e,obj:i,label:n}of s){const s=t.typeDictionary.attribute,o=s.get(e),r=ni(s,o,i,n);r&&this._subCommands.push(r)}this._logMessage=`set type ${n}${s.length>0?` and attributes ${JSON.stringify(s)}`:""} to ${i} items ${o.map(t=>t.id)}`}}class ai extends Ye{constructor(t,e,i,n,s){super(),this._annotationModel=t,this._definitionContainer=e,this._id=i,this._changedProperties=n,this._newDefaultTypeId=s}execute(){const t=this._definitionContainer.get(this._id),[e,i]=function(t,e){const i={...e},n=new Map;for(const[s,o]of t.entries())null===o&&void 0!==e[s]?(delete i[s],n.set(s,e[s])):null!==o&&(i[s]=o,n.set(s,void 0===e[s]?null:e[s]));return[i,n]}(this._changedProperties,t);this._definitionContainer.replace(this._id,e),e.default?(this.revertDefaultTypeId=this._definitionContainer.defaultType,this._definitionContainer.defaultType=e.id):this._newDefaultTypeId&&(this._definitionContainer.defaultType=this._newDefaultTypeId),this.revertId=e.id,this.revertChangedProperties=i,Fe(this,`change old type:${JSON.stringify(t)} to new type:${JSON.stringify(e)}, default is ${this._definitionContainer.defaultType}`)}revert(){return new ai(this._annotationModel,this._definitionContainer,this.revertId,this.revertChangedProperties,this.revertDefaultTypeId)}}class li extends Ye{constructor(t,e,i){super(),this._definitionContainer=t,this._removeType=e,this._revertDefaultTypeId=i}execute(){const{id:t}=this._removeType,e=this._definitionContainer.get(t);this._definitionContainer.delete(t,this._revertDefaultTypeId),e&&(this._removeType=e),Fe(this,`remove a type:${JSON.stringify(this._removeType)}, default is ${this._definitionContainer.defaultType}`)}revert(){return new ci(this._definitionContainer,this._removeType)}}class ci extends Ye{constructor(t,e){super(),this._definitionContainer=t,this._newType=e}execute(){this._revertDefaultTypeId=this._definitionContainer._defaultType,this._definitionContainer.addDefinedType(this._newType),Fe(this,`create a new type:${JSON.stringify(this._newType)}, default is ${this._definitionContainer.defaultType}`)}revert(){return new li(this._definitionContainer,this._newType,this._revertDefaultTypeId)}}function hi(t,e,i,n){return t.has(e)?new ai(i,t,e,n,null):new ci(t,{id:e,...Object.fromEntries(n)})}class ui extends Ke{constructor(t,e,i,n,s,o){super();const r=[];i&&r.push(hi(s,n,t,new Map([["label",i]])));const a=new ri(t,e,s.annotationType,n,o);a.isEmpty||r.push(a),this._subCommands=r,this._logMessage=`change ${s.annotationType} value:"${n}"${i?`, label:"${i}"`:""}${o.length>0?`, attributes:${JSON.stringify(o)}`:""}`}}class di extends Ke{constructor(t,e,i,n,s){super();const o=[hi(e,n,t,s)];let r=[];s.has("id")&&(r=function(t,e,i,n){return t.getInstanceContainerFor(e).all.filter(t=>t.typeName===i).map(i=>new oi(t,e,i.id,n))}(t,i,n,s.get("id"))),this._subCommands=o.concat(r),this._logMessage=`set ${[...s.entries()].map(([t,e])=>`${t}:${e}`)} to type definition ${n}`}}class fi extends Ke{constructor(t,e,i,n){super();const s=e[i].all.filter(t=>!t.typeValues.isSameType(n));this._subCommands=s.map(e=>new oi(t,i,e.id,n)),this._logMessage=`set type ${n} to ${i} items ${s}`}}class pi extends Ye{constructor(t,e,i,n,s){super(),this._definitionContainer=t,this._attrDef=e,this._targetIndex=i,this._newValue=n,this._indexThatRemoveDefaultFrom=s}execute(){if("selection"===this._attrDef["value type"]&&(!this._attrDef.values[this._targetIndex].default&&this._newValue.default&&(this._indexThatRemoveDefaultFrom||(this._indexThatRemoveDefaultFrom=this._attrDef.values.findIndex(t=>t.default)),delete this._attrDef.values[this._indexThatRemoveDefaultFrom].default),this._attrDef.values[this._targetIndex].default&&!this._newValue.default))if(1===this._attrDef.values.length)this._newValue.default=!0;else if(this._indexThatRemoveDefaultFrom)this._attrDef.values[this._indexThatRemoveDefaultFrom].default=!0;else{let t=null;this._attrDef.values.forEach((e,i)=>{null===t&&i!=this._targetIndex&&(t=i)}),this._attrDef.values[t].default=!0,this._indexThatRemoveDefaultFrom=t}this._valueBeforeChange=this._attrDef.values.splice(this._targetIndex,1,this._newValue)[0],this._definitionContainer.update(this._attrDef.pred,this._attrDef),Fe(this,`change value of attrribute:${this._attrDef.pred}, oldValue: ${JSON.stringify(this._valueBeforeChange)}, newValue: ${JSON.stringify(this._newValue)}`)}revert(){return new pi(this._definitionContainer,this._attrDef,this._targetIndex,this._valueBeforeChange,this._indexThatRemoveDefaultFrom)}}class mi extends Ke{constructor(t,e,i,n,s,o,r){if(super(),this._subCommands=[new pi(i,n,s,o,r)],"selection"===n["value type"]&&n.values[s].id!==o.id){const i=e.attributeInstanceContainer.getSameAttributes(n.pred,n.values[s].id),r=i.map(t=>new ti(e,t,null,o.id));this._subCommands=this._subCommands.concat(r),this._afterInvoke=()=>t.emit("textae-event.commander.attributes.change",i)}this._logMessage=`attribute: ${n.pred}`}}class gi extends Ye{constructor(t,e){super(),this._definitionContainer=t,this._removeAttrdef=e,this._index=t.getIndexOf(e.pred)}execute(){this._definitionContainer.delete(this._removeAttrdef.pred),Fe(this,`remove an attrribute definition:${JSON.stringify(this._removeAttrdef)}, index:${this._index}`)}revert(){return new vi(this._definitionContainer,this._removeAttrdef,this._index)}}class vi extends Ye{constructor(t,e,i){super(),this._definitionContainer=t,this._newAttrDef=e,this._index=i}execute(){"selection"!==this._newAttrDef.valueType||this._newAttrDef.values||(this._newAttrDef.values=[{id:"default",default:!0}]),this._definitionContainer.create(this._newAttrDef.valueType,this._newAttrDef,this._index),Fe(this,`create a new attrribute definition:${JSON.stringify(this._newAttrDef)}, index: ${this._index}`)}revert(){return new gi(this._definitionContainer,this._newAttrDef)}}function yi(t,e,i,n){return e.filter(t=>!t.typeValues.hasSpecificPredicateAttribute(i)).map(({id:e})=>new We(t,"attribute",{id:null,subj:e,pred:i,obj:n}))}class Oi extends Ke{constructor(t,e,i,n){super(),this._subCommands=yi(t,e,i.pred,n||i.default),this._logMessage=`create attirbute ${i.pred}:${i.default} to item ${e.map(({id:t})=>t).join(", ")}`}}class bi extends We{constructor(t,e,i){super(t,"attribute",{obj:e,pred:i})}execute(){const t=this._annotationModel.entityInstanceContainer.all.pop().id;return this._instance.subj=t,super.execute()}}class xi extends Ke{constructor(t,e,i,n,s,o,r){super(),this._subCommands=[new We(t,"entity",{spanType:i,begin:n,end:s,typeName:o},e)].concat(r.map(({obj:e,pred:i})=>new bi(t,e,i))),this._logMessage=`span: ${n}:${s}, type: ${o}${r.length?`, attributes: ${r.map(({pred:t})=>t).join(", ")}`:""}`}}class wi extends Ke{constructor(t,e,i,n,s,o){super();const r=new We(e,"span",{begin:n,end:s,isBlock:!0},i),a=new xi(e,i,"block",n,s,o,[]);this._subCommands=[r,a],this._logMessage=`create a span ${n}:${s} with type ${o}`}}class _i extends Ke{constructor(t,e,i){super();const n=e.span.all.filter(t=>t.isDenotation);this._subCommands=n.map(n=>new We(t,"entity",{spanType:"denotation",begin:n.begin,end:n.end,typeName:i},e)),this._logMessage=`create a ${i} type entity to ${n}`}}class Si extends Ke{constructor(t,e,i,n,s,o){super(),this._subCommands=[new We(t,"span",{begin:n,end:s},e)].concat(o.map(i=>new xi(t,e,"denotation",n,s,i.typeName,i.attributes))),this._logMessage=`span: ${n}:${s}, types: ${o.map(({typeName:t})=>t).join(", ")}`}}class ki extends Ke{constructor(t,e,i,n,s,o){super(),console.log(n),this._subCommands=e.getReplicationRanges(n,o).map(({begin:n,end:o})=>new Si(e,i,t,n,o,s)),this._logMessage=`from span: ${n.id}`}}class $i extends Ke{constructor(t,e,i,n,s,o,r){super();const a=[new Ot(s)];this._subCommands=[new Si(e,i,t,n.begin,n.end,a)],this._logMessage=`create a span ${n.begin}:${n.end} with type ${a[0].typeName}`,o&&n.end-n.begin<=100&&(this._subCommands.push(new ki(t,e,i,{begin:n.begin,end:n.end},a,r)),this._logMessage=`${this._logMessage} and replicate auto`)}}class Ci extends Ye{constructor(t,e,i){super(),this._definitionContainer=t,this._oldIndex=e,this._newIndex=i}execute(){this._definitionContainer.move(this._oldIndex,this._newIndex),Fe(this,`move the attrribute definition: from ${this._oldIndex} to ${this._newIndex}`)}revert(){return new Ci(this._definitionContainer,this._newIndex,this._oldIndex)}}class Ti extends He{#T;#Xe;#He;#We;#Ve;constructor(t,e,i,n,s){super(),this.#T=t,this.#Xe=e,this.#He=i,this.#We=n,this.#Ve=s}execute(){this.#T.moveBlockSpan(this.#Xe,this.#He,this.#We,this.#Ve),Fe(this,`move span: from {begin: ${this.#Xe}, end: ${this.#He} } to {begin: ${this.#We}, end: ${this.#Ve}}`)}revert(){return new Ti(this.#T,this.#We,this.#Ve,this.#Xe,this.#He)}}class Pi extends He{#T;#Xe;#He;#We;#Ve;constructor(t,e,i,n,s){super(),this.#T=t,this.#Xe=e,this.#He=i,this.#We=n,this.#Ve=s}execute(){this.#T.moveDenotationSpan(this.#Xe,this.#He,this.#We,this.#Ve),Fe(this,`move span: from {begin: ${this.#Xe}, end: ${this.#He} } to {begin: ${this.#We}, end: ${this.#Ve}}`)}revert(){return new Pi(this.#T,this.#We,this.#Ve,this.#Xe,this.#He)}}function Ei(t,e){return t.entities.every(t=>e.includes(t))}class Ai extends Ke{constructor(t,e){super(),this._subCommands=[];for(const[i,n]of e.entries())this._subCommands.push(new Mi(t,i,n));this._logMessage=`revert: move entities ${Array.from(e.values()).flat().map(t=>t.id).join(", ")}`}}class Mi extends He{constructor(t,e,i){super(),this._annotationModel=t,this._span=e,this._entities=i}execute(){this._moveMap=this._entities.reduce((t,e)=>(t.has(e.span)?t.get(e.span).push(e):t.set(e.span,[e]),t),new Map);const t=`${Array.from(this._moveMap.entries()).map(([t,e])=>`${e.map(t=>t.id).join(", ")} from ${e[0].span.id} to ${this._span.id}`).join(", ")}`;this._annotationModel.entityInstanceContainer.moveEntities(this._span,this._entities),Fe(this,t)}revert(){return new Ai(this._annotationModel,this._moveMap)}}class Qi extends Ke{constructor(t,e,i){console.assert(e.span.single,"There must be one span to be pasted."),super();const n=[new Mi(t,e.span.single,i)];for(const e of i.map(t=>t.span).reduce((t,e)=>(t.add(e),t),new Set).values())Ei(e,i)&&n.push(new Ve(t,"span",e));this._subCommands=n,this._logMessage="paste cut entities"}}class Di extends Ke{constructor(t,e,i,n,s,o){super();const r=e.span.all;this._subCommands=[];for(const e of n)this._subCommands.push(new ci(t.denotationDefinitionContainer,e));for(const e of s)this._subCommands.push(new vi(t.attributeInstanceContainerDefinitionContainer,{valueType:e["value type"],...e}));for(const{pred:e,value:i}of o)this._subCommands.push(new Ge(t.attributeInstanceContainerDefinitionContainer,t.attributeInstanceContainerDefinitionContainer.get(e),i));this._subCommands=this._subCommands.concat(r.map(n=>i.map(i=>new xi(t,e,"denotation",n.begin,n.end,i.typeName,i.attributes))).flat()),this._logMessage=`paste types [${i.map(({typeName:t,attributes:e})=>[`{type:${t}}`].concat(e.map(({pred:t,obj:e})=>`{${t}:${e}}`)))}] to ${r}`}}function Ri(t,e,i){return e.reduce((t,{attributes:e})=>t.concat(e),[]).filter(t=>t.pred===i).map(e=>new Ve(t,"attribute",e))}class Ii extends Ke{constructor(t,e,i){super();const n=Ri(t,e,i.pred);this._subCommands=n,this._logMessage=`remove ${i.pred} attribute from items ${e.map(t=>t.id).join(", ")}`}}function Li(t,e,i){t.add(i);for(const t of i.attributes)e.add(t)}function Ni(t,e,i,n){t.add(n);for(const t of n.attributes)i.add(t);for(const t of n.relations)Li(e,i,t)}class ji extends Ke{constructor(t,e){super();const i=new Set,n=new Set,s=new Set,o=new Set;for(const t of e.span.all){i.add(t);for(const e of t.entities)Ni(n,s,o,e)}for(const t of e.entity.all)Ni(n,s,o,t);for(const t of e.relation.all)Li(s,o,t);for(const n of t.spanInstanceContainer.all)n.entities.every(t=>e.entity.all.includes(t))&&(n.styleOnly||i.add(n));this._subCommands=[];for(const e of o)this._subCommands.push(new Ve(t,"attribute",e));for(const e of s)this._subCommands.push(new Ve(t,"relation",e));for(const e of n)this._subCommands.push(new Ve(t,"entity",e));for(const e of i)this._subCommands.push(new Ve(t,"span",e));this._logMessage=`remove selected ${[...i,...n,...s,...o].map(({id:t})=>t).join(", ")}`}}class zi extends Ke{constructor(t,e){super();const i=new Ve(t,"relation",e),n=e.attributes.map(e=>new Ve(t,"attribute",e));this._subCommands=n.concat(i),this._logMessage=`remove a relation ${e.id}`}}class Bi extends Ke{constructor(t,e){super();const i=new Ve(t,"entity",e),n=e.relations.map(e=>new zi(t,e)),s=e.attributes.map(e=>new Ve(t,"attribute",e));this._subCommands=n.concat(s).concat(i),this._logMessage=`remove an entity ${e.id}`}}class qi extends Ke{constructor(t,e){super();const i=t.getSpan(e),n=i.entities.map(e=>new Bi(t,e)),s=new Ve(t,"span",i);this._subCommands=n.concat(s),this._logMessage=`remove a span ${e}`}}class Zi extends Ke{constructor(t,e,i){super(),this._subCommands=yi(t,e,i.pred,i.default);const n=Ri(t,e,i.pred);this._subCommands=this._subCommands.concat(n),this._logMessage=`toggle flag attirbute ${i.pred} to item ${e.map(({id:t})=>t).join(", ")}`}}class Fi extends He{#Ht;#Ye;#Ue;#Ge;#Ke;#Je;constructor(t,e,i){super(),this.#Ht=t,this.#Ye=e.begin,this.#Ue=e.end,this.#Ge=i}execute(){this.#Ke=this.#Ye+this.#Ge.length,this.#Je=this.#Ht.getTextBetween(this.#Ye,this.#Ue);const t=this.#Ht.changeTextBetween(this.#Ye,this.#Ue,this.#Ge);Fe(this,`change text at ${this.#Ye}:${this.#Ue} to ${this.#Ge} and spans [${t.map(({begin:t,end:e})=>`${t}:${e}`).join(", ")}] are effected.`)}revert(){return new Fi(this.#Ht,{begin:this.#Ye,end:this.#Ke},this.#Je)}}class Xi extends Ke{constructor(t,e,i,n){super(),this._isExecuteSubCommandsInReverseOrderWhenRevert=!1,this._subCommands=[new Fi(t,{begin:e,end:i},n)],this._logMessage=`change text from ${e} to ${i} to ${n}`}}class Hi{#M;#Nt;#Ht;#Ie;constructor(t,e,i,n){this.#M=t,this.#Nt=e,this.#Ht=i,this.#Ie=n}addValueToAttributeDefinitionCommand(t,e){return new Ge(this.#Ht.typeDictionary.attribute,t,e)}changeAttributeDefinitionCommand(t,e){return new ei(this.#Nt,this.#Ht,this.#Ht.typeDictionary.attribute,t,e)}changeAttributeObjOfItemsCommand(t,e,i){return new ii(this.#Nt,this.#Ht,t,e,i)}changeStringAttributeObjOfItemsCommand(t,e,i,n){return new si(this.#Nt,this.#Ht,this.#Ht.typeDictionary.attribute,t,e,i,n)}changeTypeValuesCommand(t,e,i,n){return new ui(this.#Ht,this.#Ie,t,e,i,n)}changeTypeDefinitionCommand(t,e,i,n){return new di(this.#Ht,t,e,i,n)}changeTypeOfSelectedItemsCommand(t,e){return new fi(this.#Ht,this.#Ie,t,e)}changeValueOfAttributeDefinitionAndObjectOfSelectionAttributeCommand(t,e,i){return new mi(this.#Nt,this.#Ht,this.#Ht.typeDictionary.attribute,t,e,i)}createAttributeDefinitionCommand(t){return new vi(this.#Ht.typeDictionary.attribute,t)}createAttributeToItemsCommand(t,e,i=null){return new Oi(this.#Ht,t,e,i)}createBlockSpanCommand(t){return new wi(this.#M,this.#Ht,this.#Ie,t.begin,t.end,this.#Ht.typeDictionary.block.defaultType)}createDefaultTypeEntityToSelectedSpansCommand(t){return new _i(this.#Ht,this.#Ie,t)}createRelationCommand(t){return new We(this.#Ht,"relation",t,this.#Ie)}createSpanAndAutoReplicateCommand(t,e,i){return new $i(this.#M,this.#Ht,this.#Ie,t,this.#Ht.typeDictionary.denotation.defaultType,e,i)}createTypeDefinitionCommand(t,e){return new ci(t,e)}deleteAttributeDefinitionCommand(t){return new gi(this.#Ht.typeDictionary.attribute,t)}moveAttributeDefinitionCommand(t,e){return new Ci(this.#Ht.typeDictionary.attribute,t,e)}moveBlockSpanCommand(t,e,i){const{begin:n,end:s}=this.#Ht.getSpan(t);return new Ti(this.#Ht.spanInstanceContainer,n,s,e,i)}moveDenotationSpanCommand(t,e,i){const{begin:n,end:s}=this.#Ht.getSpan(t);return new Pi(this.#Ht.spanInstanceContainer,n,s,e,i)}moveEntitiesToSelectedSpanCommand(t){return new Qi(this.#Ht,this.#Ie,t)}pasteTypesToSelectedSpansCommand(t,e=[],i=[],n=[]){return new Di(this.#Ht,this.#Ie,t,e,i,n)}replicateSpanCommand(t,e,i){return new ki(this.#M,this.#Ht,this.#Ie,t,e,i)}removeAttributesFromItemsByPredCommand(t,e){return new Ii(this.#Ht,t,e)}removeSpanCommand(t){return new qi(this.#Ht,t)}removeSelectedCommand(){return new ji(this.#Ht,this.#Ie)}removeTypeDefinitionCommand(t,e){return new li(t,e)}removeValueFromAttributeDefinitionCommand(t,e){return new Ue(this.#Ht.typeDictionary.attribute,t,e)}toggleFlagAttributeToItemsCommand(t,e){return new Zi(this.#Ht,t,e)}changeTextAndMoveSpanCommand(t,e,i){return new Xi(this.#Ht,t,e,i)}}class Wi{#Q;#M;#Nt;#Ht;#Ie;#ti;constructor(t,e,i,n,s){this.#Q=t,this.#M=e,this.#Nt=i,this.#Ht=n,this.#Ie=s,this.#ti=new Ze(i)}invoke(t){t.isEmpty||(t.execute(),this.#ti.push(t))}undo(){if(this.#ti.hasAnythingToUndo){this.#Ie.removeAll(),this.#Q.focus();const t=this.#ti.prev();t.kind.has("configuration_command")&&e().success("configuration has been undone"),t.revert().execute()}}redo(){if(this.#ti.hasAnythingToRedo){this.#Ie.removeAll();const t=this.#ti.next();t.kind.has("configuration_command")&&e().success("configuration has been redo"),t.execute()}}get factory(){return new Hi(this.#M,this.#Nt,this.#Ht,this.#Ie,this.#Ht.typeDictionary)}}class Vi{constructor(t,e){this._editorHTMLElement=t,this._selectionModel=e}left(t){const e=this._searchLeft(".textae-editor__span");if(e)return void(t?this._selectionModel.add("span",[e.id]):this._selectionModel.selectSpan(e.id));const i=this._searchLeft(".textae-editor__grid .textae-editor__signboard");i&&(t?this._selectionModel.add("entity",[i.dataset.id]):this._selectionModel.selectEntity(i.dataset.id))}right(t){const e=this._searchRight(".textae-editor__span");if(e)return void(t?this._selectionModel.add("span",[e.id]):this._selectionModel.selectSpan(e.id));const i=this._searchRight(".textae-editor__grid .textae-editor__signboard");i&&(t?this._selectionModel.add("entity",[i.dataset.id]):this._selectionModel.selectEntity(i.dataset.id))}_searchLeft(t){const e=this._editorHTMLElement.querySelectorAll(t),i=[...e].findIndex(t=>t.classList.contains("ui-selected")||t.classList.contains("textae-editor__signboard--selected"));if(i>0)return e[i-1]}_searchRight(t){const e=this._editorHTMLElement.querySelectorAll(t),i=[...e].reverse().findIndex(t=>t.classList.contains("ui-selected")||t.classList.contains("textae-editor__signboard--selected"));if(e.length-i>0)return e[e.length-i]}}class Yi{constructor(t,e){this._editorHTMLElement=t,this._selectionModel=e}up(){if(this._selectionModel.span.single){const t=this._selectionModel.span.single.gridElement.querySelector(".textae-editor__signboard");this._selectionModel.selectEntity(t.dataset.id)}}down(){const t=this._editorHTMLElement.querySelector(".textae-editor__signboard--selected");if(t){const e=t.closest(".textae-editor__grid").id.substring(1);this._selectionModel.selectSpan(e)}}}function Ui(t){return s()(t,300)}function Gi(t,e){r()(t,".textae-editor__setting-dialog__line-height-text","change",Ui(t=>{e.lineHeight=t.target.value,function(){const t=new Event("resize");window.dispatchEvent(t)}()}))}function Ki(t,e,i,n,s,o){!function(t,e,i){r()(t,".textae-editor__setting-dialog__type-gap-text","change",Ui(n=>{e.value=Number(n.target.value),t.querySelector(".textae-editor__setting-dialog__line-height-text").value=i.lineHeight}))}(t,i,s),Gi(t,s),function(t,e){r()(t,".textae-editor__setting-dialog__lock-config-text","change",Ui(t=>{t.target.checked?e.lockEdit():e.unlockEdit()}))}(t,n),function(t,e,i){r()(t,".textae-editor__setting-dialog__function-availability-checkbox","change",Ui(({target:t})=>{const n=t.closest(".textae-editor__setting-dialog__function-availability-label").textContent.trim();t.checked?(i.enable(n),e.emit("textae-event.configuration.reset")):(i.disable(n),e.emit("textae-event.configuration.reset"))}))}(t,e,o)}const Ji="14.2.0";class tn{static escape(t){return t.replace(/\n/g,"\\n").replace(/\t/g,"\\t").replace(/\r/g,"\\r")}static decode(t){return t.replace(/\\n/g,"\n").replace(/\\t/g,"\t").replace(/\\r/g,"\r")}}function en(t){const e=tn.escape(t);return st()(e)}function nn(t){const{typeGap:e,typeGapDisabled:i,lineHeight:n,autocompletionWs:s,typeDictionaryLocked:o,delimiterCharacters:r,blankCharacters:a,functionAvailability:l,version:c}=t;return ot`
211
211
  <div class="textae-editor__setting-dialog__container">
212
212
  <div class="textae-editor__setting-dialog__row">
213
213
  <label>Type Gap</label>
@@ -286,22 +286,22 @@ var i,n=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?
286
286
  <span class="textae-editor__setting-dialog__${i}-character">${s}</span>
287
287
  </td>
288
288
  <td><button class="textae-editor__setting-dialog__${i}-character-delete-button">&times;</button></td>
289
- </tr>`;t.querySelector(`.textae-editor__setting-dialog__${i}-character-add-row`).insertAdjacentHTML("afterend",o),n.value=""}class fn extends u{constructor(t,e,i,n,s,o){super("Setting",nn({typeGapDisabled:!i.show,typeGap:i.value,lineHeight:n.lineHeight,autocompletionWs:e.autocompletionWs,typeDictionaryLocked:e.isLock,delimiterCharacters:s.delimiterCharacters,blankCharacters:s.blankCharacters,functionAvailability:o,version:Ji})),Ki(super.el,t,i,e,n,o),r()(super.el,".textae-editor__dialog","keyup",t=>{13===t.keyCode&&super.close()}),function(t){r()(t,".textae-editor__setting-dialog__delimiter-character-add-button","click",()=>dn(t,"delimiter")),r()(t,".textae-editor__setting-dialog__blank-character-add-button","click",()=>dn(t,"blank"))}(super.el),function(t){r()(t,".textae-editor__setting-dialog__delimiter-character-delete-button","click",({target:t})=>{t.closest(".textae-editor__setting-dialog__delimiter-character-row").remove()}),r()(t,".textae-editor__setting-dialog__blank-character-delete-button","click",({target:t})=>{t.closest(".textae-editor__setting-dialog__blank-character-row").remove()})}(super.el),h()(this.el).on("dialogclose",()=>{!function(t,e){const i=t.querySelector(".textae-editor__setting-dialog__autocompletion_ws-text").value;un({autocompletion_ws:i}),e.autocompletionWs=i}(super.el,e),function(t,e){const i=t.querySelectorAll(".textae-editor__setting-dialog__delimiter-character"),n=Array.from(i).map(t=>tn.decode(t.textContent)).reverse(),s=t.querySelectorAll(".textae-editor__setting-dialog__blank-character"),o=Array.from(s).map(t=>tn.decode(t.textContent)).reverse(),r={"delimiter characters":Array.from(n),"non-edge characters":Array.from(o)};un(r),e.set(r)}(super.el,s)})}}function pn(t,e){return t.isPushed("boundary detection")?t=>e.isDelimiter(t):()=>!0}const mn="Init",gn="View",vn="Term",yn="Block",On="Relation",bn="Text";class xn{#Q;#Nt;#ei;#Ie;#Ht;#ii;#ni;#si;#oi;#ri;#ai;#li;#ci;#hi;constructor(t,i,n,s,o,r,a,l,c,h,u,d){i.on("textae-event.annotation-data.all.change",t=>{h.isEditMode&&t&&e().success("track annotations have been merged to root annotations."),u.reset()}).on("textae-event.edit-mode.transition",t=>{if(s.removeAll(),t===gn)n.entityInstanceContainer.clarifyLabelOfAll();else n.entityInstanceContainer.declarifyLabelOfAll()}),this.#Q=t,this.#Nt=i,this.#ei=o,this.#Ie=s,this.#Ht=n,this.#ii=c,this.#ni=r,this.#si=a,this.#oi=l,this.#ri=u,this.#ai=new Vi(t,s),this.#li=new Yi(t,s),this.#ci=!1,this.#hi=d,je(this,()=>this.#ri,["toViewMode","toTermEditMode","toBlockEditMode","toRelationEditMode","toTextEditMode","toggleSimpleMode","changeModeByShortcut"]),je(this,()=>this.#oi,["copyEntitiesToLocalClipboard","copyEntitiesToSystemClipboard","cutEntitiesToLocalClipboard","cutEntitiesToSystemClipboard","pasteEntitiesFromLocalClipboard","pasteEntitiesFromSystemClipboard"]),je(this,()=>this.#ii,["toggleButton"])}removeSelectedElements(){const t=this.#ei.factory.removeSelectedCommand();this.#ai.right(null),this.#ei.invoke(t)}createEntity(){const t=this.#ei.factory.createDefaultTypeEntityToSelectedSpansCommand(this.#Ht.typeDictionary.denotation.defaultType);t.isEmpty||this.#ei.invoke(t)}replicate(){const t=pn(this.#ii,this.#ni);this.#Ie.span.single?this.#ei.invoke(this.#ei.factory.replicateSpanCommand(this.#Ie.span.single,this.#Ie.span.single.entities.map(t=>t.typeValues),t)):e().warning("You can replicate span annotation when there is only span selected.")}cancelSelect(){this.#ri.hidePallet(),this.#Ie.removeAll(),this.#Q.focus()}showSettingDialog(){new fn(this.#Nt,this.#Ht.typeDictionary,this.#Ht.typeGap,this.#Ht.textBox,this.#ni,this.#si).open()}get isActive(){return this.#ci}activate(){this.#Q.classList.add("textae-editor--active"),this.#ci=!0}deactivate(){this.#Q.classList.remove("textae-editor--active"),this.#Nt.emit("textae-event.editor.unselect"),this.#ci=!1}selectLeft(t){this.#ri.isTypeValuesPalletShown?this.#hi.current.selectLeftAttributeTab():this.#ai.left(t)}selectRight(t){this.#ri.isTypeValuesPalletShown?this.#hi.current.selectRightAttributeTab():this.#ai.right(t)}selectUp(){this.#ri.isEditDenotation&&this.#li.up()}selectDown(){this.#ri.isEditDenotation&&this.#li.down()}applyTextSelectionWithTouchDevice(){this.#ci&&this.#hi.current.applyTextSelectionWithTouchDevice()}}function wn(t,e){e?t.removeAttribute("disabled"):t.setAttribute("disabled","disabled")}function _n(t){if("string"!=typeof t)return!1;try{JSON.parse(t)}catch(t){return!1}return!0}let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,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(t=>t?parseInt(t,36):1);for(let e=0,i=0;e<t.length;e++)(e%2?kn:Sn).push(i+=t[e])})();function Tn(t,e,i=!0,n=!0){return(i?Pn:En)(t,e,n)}function Pn(t,e,i){if(e==t.length)return e;e&&Mn(t.charCodeAt(e))&&Qn(t.charCodeAt(e-1))&&e--;let n=An(t,e);for(e+=Dn(n);e<t.length;){let s=An(t,e);if(8205==n||8205==s||i&&$n(s))e+=Dn(s),n=s;else{if(!Cn(s))break;{let i=0,n=e-2;for(;n>=0&&Cn(An(t,n));)i++,n-=2;if(i%2==0)break;e+=2}}}return e}function En(t,e,i){for(;e>0;){let n=Pn(t,e-2,i);if(n<e)return n;e--}return 0}function An(t,e){let i=t.charCodeAt(e);if(!Qn(i)||e+1==t.length)return i;let n=t.charCodeAt(e+1);return Mn(n)?n-56320+(i-55296<<10)+65536:i}function Mn(t){return t>=56320&&t<57344}function Qn(t){return t>=55296&&t<56320}function Dn(t){return t<65536?1:2}class Rn{lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,i){[t,e]=Fn(this,t,e);let n=[];return this.decompose(0,t,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(e,this.length,n,1),Ln.from(n,this.length-(e-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){[t,e]=Fn(this,t,e);let i=[];return this.decompose(t,e,i,0),Ln.from(i,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=this.scanIdentical(t,1),i=this.length-this.scanIdentical(t,-1),n=new zn(this),s=new zn(t);for(let t=e,o=e;;){if(n.next(t),s.next(t),t=0,n.lineBreak!=s.lineBreak||n.done!=s.done||n.value!=s.value)return!1;if(o+=n.value.length,n.done||o>=i)return!0}}iter(t=1){return new zn(this,t)}iterRange(t,e=this.length){return new Bn(this,t,e)}iterLines(t,e){let i;if(null==t)i=this.iter();else{null==e&&(e=this.lines+1);let n=this.line(t).from;i=this.iterRange(n,Math.max(n,e==this.lines+1?this.length:e<=1?0:this.line(e-1).to))}return new qn(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(0==t.length)throw new RangeError("A document must have at least one line");return 1!=t.length||t[0]?t.length<=32?new In(t):Ln.from(In.split(t,[])):Rn.empty}}class In extends Rn{constructor(t,e=function(t){let e=-1;for(let i of t)e+=i.length+1;return e}(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,i,n){for(let s=0;;s++){let o=this.text[s],r=n+o.length;if((e?i:r)>=t)return new Zn(n,r,i,o);n=r+1,i++}}decompose(t,e,i,n){let s=t<=0&&e>=this.length?this:new In(jn(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(1&n){let t=i.pop(),e=Nn(s.text,t.text.slice(),0,s.length);if(e.length<=32)i.push(new In(e,t.length+s.length));else{let t=e.length>>1;i.push(new In(e.slice(0,t)),new In(e.slice(t)))}}else i.push(s)}replace(t,e,i){if(!(i instanceof In))return super.replace(t,e,i);[t,e]=Fn(this,t,e);let n=Nn(this.text,Nn(i.text,jn(this.text,0,t)),e),s=this.length+i.length-(e-t);return n.length<=32?new In(n,s):Ln.from(In.split(n,[]),s)}sliceString(t,e=this.length,i="\n"){[t,e]=Fn(this,t,e);let n="";for(let s=0,o=0;s<=e&&o<this.text.length;o++){let r=this.text[o],a=s+r.length;s>t&&o&&(n+=i),t<a&&e>s&&(n+=r.slice(Math.max(0,t-s),e-s)),s=a+1}return n}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let i=[],n=-1;for(let s of t)i.push(s),n+=s.length+1,32==i.length&&(e.push(new In(i,n)),i=[],n=-1);return n>-1&&e.push(new In(i,n)),e}}class Ln extends Rn{constructor(t,e){super(),this.children=t,this.length=e,this.lines=0;for(let e of t)this.lines+=e.lines}lineInner(t,e,i,n){for(let s=0;;s++){let o=this.children[s],r=n+o.length,a=i+o.lines-1;if((e?a:r)>=t)return o.lineInner(t,e,i,n);n=r+1,i=a+1}}decompose(t,e,i,n){for(let s=0,o=0;o<=e&&s<this.children.length;s++){let r=this.children[s],a=o+r.length;if(t<=a&&e>=o){let s=n&((o<=t?1:0)|(a>=e?2:0));o>=t&&a<=e&&!s?i.push(r):r.decompose(t-o,e-o,i,s)}o=a+1}}replace(t,e,i){if([t,e]=Fn(this,t,e),i.lines<this.lines)for(let n=0,s=0;n<this.children.length;n++){let o=this.children[n],r=s+o.length;if(t>=s&&e<=r){let a=o.replace(t-s,e-s,i),l=this.lines-o.lines+a.lines;if(a.lines<l>>4&&a.lines>l>>6){let s=this.children.slice();return s[n]=a,new Ln(s,this.length-(e-t)+i.length)}return super.replace(s,r,a)}s=r+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i="\n"){[t,e]=Fn(this,t,e);let n="";for(let s=0,o=0;s<this.children.length&&o<=e;s++){let r=this.children[s],a=o+r.length;o>t&&s&&(n+=i),t<a&&e>o&&(n+=r.sliceString(t-o,e-o,i)),o=a+1}return n}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof Ln))return 0;let i=0,[n,s,o,r]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;n+=e,s+=e){if(n==o||s==r)return i;let a=this.children[n],l=t.children[s];if(a!=l)return i+a.scanIdentical(l,e);i+=a.length+1}}static from(t,e=t.reduce((t,e)=>t+e.length+1,-1)){let i=0;for(let e of t)i+=e.lines;if(i<32){let i=[];for(let e of t)e.flatten(i);return new In(i,e)}let n=Math.max(32,i>>5),s=n<<1,o=n>>1,r=[],a=0,l=-1,c=[];function h(t){let e;if(t.lines>s&&t instanceof Ln)for(let e of t.children)h(e);else t.lines>o&&(a>o||!a)?(u(),r.push(t)):t instanceof In&&a&&(e=c[c.length-1])instanceof In&&t.lines+e.lines<=32?(a+=t.lines,l+=t.length+1,c[c.length-1]=new In(e.text.concat(t.text),e.length+1+t.length)):(a+t.lines>n&&u(),a+=t.lines,l+=t.length+1,c.push(t))}function u(){0!=a&&(r.push(1==c.length?c[0]:Ln.from(c,l)),l=-1,a=c.length=0)}for(let e of t)h(e);return u(),1==r.length?r[0]:new Ln(r,e)}}function Nn(t,e,i=0,n=1e9){for(let s=0,o=0,r=!0;o<t.length&&s<=n;o++){let a=t[o],l=s+a.length;l>=i&&(l>n&&(a=a.slice(0,n-s)),s<i&&(a=a.slice(i-s)),r?(e[e.length-1]+=a,r=!1):e.push(a)),s=l+1}return e}function jn(t,e,i){return Nn(t,[""],e,i)}Rn.empty=new In([""],0);class zn{constructor(t,e=1){this.dir=e,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[e>0?1:(t instanceof In?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],s=this.offsets[i],o=s>>1,r=n instanceof In?n.text.length:n.children.length;if(o==(e>0?r:0)){if(0==i)return this.done=!0,this.value="",this;e>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&s)==(e>0?0:1)){if(this.offsets[i]+=e,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(n instanceof In){let s=n.text[o+(e<0?-1:0)];if(this.offsets[i]+=e,s.length>Math.max(0,t))return this.value=0==t?s:e>0?s.slice(t):s.slice(0,s.length-t),this;t-=s.length}else{let s=n.children[o+(e<0?-1:0)];t>s.length?(t-=s.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(s),this.offsets.push(e>0?1:(s instanceof In?s.text.length:s.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class Bn{constructor(t,e,i){this.value="",this.done=!1,this.cursor=new zn(t,e>i?-1:1),this.pos=e>i?t.length:0,this.from=Math.min(e,i),this.to=Math.max(e,i)}nextInner(t,e){if(e<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;t+=Math.max(0,e<0?this.pos-this.to:this.from-this.pos);let i=e<0?this.pos-this.from:this.to-this.pos;t>i&&(t=i),i-=t;let{value:n}=this.cursor.next(t);return this.pos+=(n.length+t)*e,this.value=n.length<=i?n:e<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(t=0){return t<0?t=Math.max(t,this.from-this.pos):t>0&&(t=Math.min(t,this.to-this.pos)),this.nextInner(t,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class qn{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:i,value:n}=this.inner.next(t);return e&&this.afterBreak?(this.value="",this.afterBreak=!1):e?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(Rn.prototype[Symbol.iterator]=function(){return this.iter()},zn.prototype[Symbol.iterator]=Bn.prototype[Symbol.iterator]=qn.prototype[Symbol.iterator]=function(){return this});class Zn{constructor(t,e,i,n){this.from=t,this.to=e,this.number=i,this.text=n}get length(){return this.to-this.from}}function Fn(t,e,i){return[e=Math.max(0,Math.min(t.length,e)),Math.max(e,Math.min(t.length,i))]}function Xn(t,e,i=!0,n=!0){return Tn(t,e,i,n)}function Hn(t,e){let i=t.charCodeAt(e);if(!(n=i,n>=55296&&n<56320&&e+1!=t.length))return i;var n;let s=t.charCodeAt(e+1);return function(t){return t>=56320&&t<57344}(s)?s-56320+(i-55296<<10)+65536:i}function Wn(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10),56320+(1023&t)))}function Vn(t){return t<65536?1:2}const Yn=/\r\n?|\n/;var Un=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(Un||(Un={}));class Gn{constructor(t){this.sections=t}get length(){let t=0;for(let e=0;e<this.sections.length;e+=2)t+=this.sections[e];return t}get newLength(){let t=0;for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e+1];t+=i<0?this.sections[e]:i}return t}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(t){for(let e=0,i=0,n=0;e<this.sections.length;){let s=this.sections[e++],o=this.sections[e++];o<0?(t(i,n,s),n+=s):n+=o,i+=s}}iterChangedRanges(t,e=!1){es(this,t,e)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];n<0?t.push(i,n):t.push(n,i)}return new Gn(t)}composeDesc(t){return this.empty?t:t.empty?this:ns(this,t)}mapDesc(t,e=!1){return t.empty?this:is(this,t,e)}mapPos(t,e=-1,i=Un.Simple){let n=0,s=0;for(let o=0;o<this.sections.length;){let r=this.sections[o++],a=this.sections[o++],l=n+r;if(a<0){if(l>t)return s+(t-n);s+=r}else{if(i!=Un.Simple&&l>=t&&(i==Un.TrackDel&&n<t&&l>t||i==Un.TrackBefore&&n<t||i==Un.TrackAfter&&l>t))return null;if(l>t||l==t&&e<0&&!r)return t==n||e<0?s:s+a;s+=a}n=l}if(t>n)throw new RangeError(`Position ${t} is out of range for changeset of length ${n}`);return s}touchesRange(t,e=t){for(let i=0,n=0;i<this.sections.length&&n<=e;){let s=n+this.sections[i++];if(this.sections[i++]>=0&&n<=e&&s>=t)return!(n<t&&s>e)||"cover";n=s}return!1}toString(){let t="";for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];t+=(t?" ":"")+i+(n>=0?":"+n:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(t=>"number"!=typeof t))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Gn(t)}static create(t){return new Gn(t)}}class Kn extends Gn{constructor(t,e){super(t),this.inserted=e}apply(t){if(this.length!=t.length)throw new RangeError("Applying change set to a document with the wrong length");return es(this,(e,i,n,s,o)=>t=t.replace(n,n+(i-e),o),!1),t}mapDesc(t,e=!1){return is(this,t,e,!0)}invert(t){let e=this.sections.slice(),i=[];for(let n=0,s=0;n<e.length;n+=2){let o=e[n],r=e[n+1];if(r>=0){e[n]=r,e[n+1]=o;let a=n>>1;for(;i.length<a;)i.push(Rn.empty);i.push(o?t.slice(s,s+o):Rn.empty)}s+=o}return new Kn(e,i)}compose(t){return this.empty?t:t.empty?this:ns(this,t,!0)}map(t,e=!1){return t.empty?this:is(this,t,e,!0)}iterChanges(t,e=!1){es(this,t,e)}get desc(){return Gn.create(this.sections)}filter(t){let e=[],i=[],n=[],s=new ss(this);t:for(let o=0,r=0;;){let a=o==t.length?1e9:t[o++];for(;r<a||r==a&&0==s.len;){if(s.done)break t;let t=Math.min(s.len,a-r);Jn(n,t,-1);let o=-1==s.ins?-1:0==s.off?s.ins:0;Jn(e,t,o),o>0&&ts(i,e,s.text),s.forward(t),r+=t}let l=t[o++];for(;r<l;){if(s.done)break t;let t=Math.min(s.len,l-r);Jn(e,t,-1),Jn(n,t,-1==s.ins?-1:0==s.off?s.ins:0),s.forward(t),r+=t}}return{changes:new Kn(e,i),filtered:Gn.create(n)}}toJSON(){let t=[];for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e],n=this.sections[e+1];n<0?t.push(i):0==n?t.push([i]):t.push([i].concat(this.inserted[e>>1].toJSON()))}return t}static of(t,e,i){let n=[],s=[],o=0,r=null;function a(t=!1){if(!t&&!n.length)return;o<e&&Jn(n,e-o,-1);let i=new Kn(n,s);r=r?r.compose(i.map(r)):i,n=[],s=[],o=0}return function t(l){if(Array.isArray(l))for(let e of l)t(e);else if(l instanceof Kn){if(l.length!=e)throw new RangeError(`Mismatched change set length (got ${l.length}, expected ${e})`);a(),r=r?r.compose(l.map(r)):l}else{let{from:t,to:r=t,insert:c}=l;if(t>r||t<0||r>e)throw new RangeError(`Invalid change range ${t} to ${r} (in doc of length ${e})`);let h=c?"string"==typeof c?Rn.of(c.split(i||Yn)):c:Rn.empty,u=h.length;if(t==r&&0==u)return;t<o&&a(),t>o&&Jn(n,t-o,-1),Jn(n,r-t,u),ts(s,n,h),o=r}}(t),a(!r),r}static empty(t){return new Kn(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let e=[],i=[];for(let n=0;n<t.length;n++){let s=t[n];if("number"==typeof s)e.push(s,-1);else{if(!Array.isArray(s)||"number"!=typeof s[0]||s.some((t,e)=>e&&"string"!=typeof t))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==s.length)e.push(s[0],0);else{for(;i.length<n;)i.push(Rn.empty);i[n]=Rn.of(s.slice(1)),e.push(s[0],i[n].length)}}}return new Kn(e,i)}static createSet(t,e){return new Kn(t,e)}}function Jn(t,e,i,n=!1){if(0==e&&i<=0)return;let s=t.length-2;s>=0&&i<=0&&i==t[s+1]?t[s]+=e:s>=0&&0==e&&0==t[s]?t[s+1]+=i:n?(t[s]+=e,t[s+1]+=i):t.push(e,i)}function ts(t,e,i){if(0==i.length)return;let n=e.length-2>>1;if(n<t.length)t[t.length-1]=t[t.length-1].append(i);else{for(;t.length<n;)t.push(Rn.empty);t.push(i)}}function es(t,e,i){let n=t.inserted;for(let s=0,o=0,r=0;r<t.sections.length;){let a=t.sections[r++],l=t.sections[r++];if(l<0)s+=a,o+=a;else{let c=s,h=o,u=Rn.empty;for(;c+=a,h+=l,l&&n&&(u=u.append(n[r-2>>1])),!(i||r==t.sections.length||t.sections[r+1]<0);)a=t.sections[r++],l=t.sections[r++];e(s,c,o,h,u),s=c,o=h}}}function is(t,e,i,n=!1){let s=[],o=n?[]:null,r=new ss(t),a=new ss(e);for(let t=-1;;){if(r.done&&a.len||a.done&&r.len)throw new Error("Mismatched change set lengths");if(-1==r.ins&&-1==a.ins){let t=Math.min(r.len,a.len);Jn(s,t,-1),r.forward(t),a.forward(t)}else if(a.ins>=0&&(r.ins<0||t==r.i||0==r.off&&(a.len<r.len||a.len==r.len&&!i))){let e=a.len;for(Jn(s,a.ins,-1);e;){let i=Math.min(r.len,e);r.ins>=0&&t<r.i&&r.len<=i&&(Jn(s,0,r.ins),o&&ts(o,s,r.text),t=r.i),r.forward(i),e-=i}a.next()}else{if(!(r.ins>=0)){if(r.done&&a.done)return o?Kn.createSet(s,o):Gn.create(s);throw new Error("Mismatched change set lengths")}{let e=0,i=r.len;for(;i;)if(-1==a.ins){let t=Math.min(i,a.len);e+=t,i-=t,a.forward(t)}else{if(!(0==a.ins&&a.len<i))break;i-=a.len,a.next()}Jn(s,e,t<r.i?r.ins:0),o&&t<r.i&&ts(o,s,r.text),t=r.i,r.forward(r.len-i)}}}}function ns(t,e,i=!1){let n=[],s=i?[]:null,o=new ss(t),r=new ss(e);for(let t=!1;;){if(o.done&&r.done)return s?Kn.createSet(n,s):Gn.create(n);if(0==o.ins)Jn(n,o.len,0,t),o.next();else if(0!=r.len||r.done){if(o.done||r.done)throw new Error("Mismatched change set lengths");{let e=Math.min(o.len2,r.len),i=n.length;if(-1==o.ins){let i=-1==r.ins?-1:r.off?0:r.ins;Jn(n,e,i,t),s&&i&&ts(s,n,r.text)}else-1==r.ins?(Jn(n,o.off?0:o.len,e,t),s&&ts(s,n,o.textBit(e))):(Jn(n,o.off?0:o.len,r.off?0:r.ins,t),s&&!r.off&&ts(s,n,r.text));t=(o.ins>e||r.ins>=0&&r.len>e)&&(t||n.length>i),o.forward2(e),r.forward(e)}}else Jn(n,0,r.ins,t),s&&ts(s,n,r.text),r.next()}}class ss{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i<t.length?(this.len=t[this.i++],this.ins=t[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return-2==this.ins}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:t}=this.set,e=this.i-2>>1;return e>=t.length?Rn.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?Rn.empty:e[i].slice(this.off,null==t?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){-1==this.ins?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}}class os{constructor(t,e,i){this.from=t,this.to=e,this.flags=i}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let t=7&this.flags;return 7==t?null:t}get goalColumn(){let t=this.flags>>6;return 16777215==t?void 0:t}map(t,e=-1){let i,n;return this.empty?i=n=t.mapPos(this.from,e):(i=t.mapPos(this.from,1),n=t.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new os(i,n,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return rs.range(t,e);let i=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return rs.range(this.anchor,i)}eq(t,e=!1){return!(this.anchor!=t.anchor||this.head!=t.head||e&&this.empty&&this.assoc!=t.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||"number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid JSON representation for SelectionRange");return rs.range(t.anchor,t.head)}static create(t,e,i){return new os(t,e,i)}}class rs{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:rs.create(this.ranges.map(i=>i.map(t,e)),this.mainIndex)}eq(t,e=!1){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(t.ranges[i],e))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new rs([this.main],0)}addRange(t,e=!0){return rs.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let i=this.ranges.slice();return i[e]=t,rs.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(t=>t.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||"number"!=typeof t.main||t.main>=t.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new rs(t.ranges.map(t=>os.fromJSON(t)),t.main)}static single(t,e=t){return new rs([rs.range(t,e)],0)}static create(t,e=0){if(0==t.length)throw new RangeError("A selection needs at least one range");for(let i=0,n=0;n<t.length;n++){let s=t[n];if(s.empty?s.from<=i:s.from<i)return rs.normalized(t.slice(),e);i=s.to}return new rs(t,e)}static cursor(t,e=0,i,n){return os.create(t,t,(0==e?0:e<0?8:16)|(null==i?7:Math.min(6,i))|(null!=n?n:16777215)<<6)}static range(t,e,i,n){let s=(null!=i?i:16777215)<<6|(null==n?7:Math.min(6,n));return e<t?os.create(e,t,48|s):os.create(t,e,(e>t?8:0)|s)}static normalized(t,e=0){let i=t[e];t.sort((t,e)=>t.from-e.from),e=t.indexOf(i);for(let i=1;i<t.length;i++){let n=t[i],s=t[i-1];if(n.empty?n.from<=s.to:n.from<s.to){let o=s.from,r=Math.max(n.to,s.to);i<=e&&e--,t.splice(--i,2,n.anchor>n.head?rs.range(r,o):rs.range(o,r))}}return new rs(t,e)}}function as(t,e){for(let i of t.ranges)if(i.to>e)throw new RangeError("Selection points outside of document")}let ls=0;class cs{constructor(t,e,i,n,s){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.id=ls++,this.default=t([]),this.extensions="function"==typeof s?s(this):s}get reader(){return this}static define(t={}){return new cs(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(t.combine?(t,e)=>t===e:hs),!!t.static,t.enables)}of(t){return new us([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new us(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new us(t,this,2,e)}from(t,e){return e||(e=t=>t),this.compute([t],i=>e(i.field(t)))}}function hs(t,e){return t==e||t.length==e.length&&t.every((t,i)=>t===e[i])}class us{constructor(t,e,i,n){this.dependencies=t,this.facet=e,this.type=i,this.value=n,this.id=ls++}dynamicSlot(t){var e;let i=this.value,n=this.facet.compareInput,s=this.id,o=t[s]>>1,r=2==this.type,a=!1,l=!1,c=[];for(let i of this.dependencies)"doc"==i?a=!0:"selection"==i?l=!0:1&(null!==(e=t[i.id])&&void 0!==e?e:1)||c.push(t[i.id]);return{create:t=>(t.values[o]=i(t),1),update(t,e){if(a&&e.docChanged||l&&(e.docChanged||e.selection)||fs(t,c)){let e=i(t);if(r?!ds(e,t.values[o],n):!n(e,t.values[o]))return t.values[o]=e,1}return 0},reconfigure:(t,e)=>{let a,l=e.config.address[s];if(null!=l){let s=Ts(e,l);if(this.dependencies.every(i=>i instanceof cs?e.facet(i)===t.facet(i):!(i instanceof gs)||e.field(i,!1)==t.field(i,!1))||(r?ds(a=i(t),s,n):n(a=i(t),s)))return t.values[o]=s,0}else a=i(t);return t.values[o]=a,1}}}}function ds(t,e,i){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!i(t[n],e[n]))return!1;return!0}function fs(t,e){let i=!1;for(let n of e)1&Cs(t,n)&&(i=!0);return i}function ps(t,e,i){let n=i.map(e=>t[e.id]),s=i.map(t=>t.type),o=n.filter(t=>!(1&t)),r=t[e.id]>>1;function a(t){let i=[];for(let e=0;e<n.length;e++){let o=Ts(t,n[e]);if(2==s[e])for(let t of o)i.push(t);else i.push(o)}return e.combine(i)}return{create(t){for(let e of n)Cs(t,e);return t.values[r]=a(t),1},update(t,i){if(!fs(t,o))return 0;let n=a(t);return e.compare(n,t.values[r])?0:(t.values[r]=n,1)},reconfigure(t,s){let o=fs(t,n),l=s.config.facets[e.id],c=s.facet(e);if(l&&!o&&hs(i,l))return t.values[r]=c,0;let h=a(t);return e.compare(h,c)?(t.values[r]=c,0):(t.values[r]=h,1)}}}const ms=cs.define({static:!0});class gs{constructor(t,e,i,n,s){this.id=t,this.createF=e,this.updateF=i,this.compareF=n,this.spec=s,this.provides=void 0}static define(t){let e=new gs(ls++,t.create,t.update,t.compare||((t,e)=>t===e),t);return t.provide&&(e.provides=t.provide(e)),e}create(t){let e=t.facet(ms).find(t=>t.field==this);return((null==e?void 0:e.create)||this.createF)(t)}slot(t){let e=t[this.id]>>1;return{create:t=>(t.values[e]=this.create(t),1),update:(t,i)=>{let n=t.values[e],s=this.updateF(n,i);return this.compareF(n,s)?0:(t.values[e]=s,1)},reconfigure:(t,i)=>{let n,s=t.facet(ms),o=i.facet(ms);return(n=s.find(t=>t.field==this))&&n!=o.find(t=>t.field==this)?(t.values[e]=n.create(t),1):null!=i.config.address[this.id]?(t.values[e]=i.field(this),0):(t.values[e]=this.create(t),1)}}}init(t){return[this,ms.of({field:this,create:t})]}get extension(){return this}}const vs=4,ys=3,Os=2,bs=1;function xs(t){return e=>new _s(e,t)}const ws={highest:xs(0),high:xs(bs),default:xs(Os),low:xs(ys),lowest:xs(vs)};class _s{constructor(t,e){this.inner=t,this.prec=e}}class Ss{of(t){return new ks(this,t)}reconfigure(t){return Ss.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class ks{constructor(t,e){this.compartment=t,this.inner=e}}class $s{constructor(t,e,i,n,s,o){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=n,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(t){let e=this.address[t.id];return null==e?t.default:this.staticValues[e>>1]}static resolve(t,e,i){let n=[],s=Object.create(null),o=new Map;for(let i of function(t,e,i){let n=[[],[],[],[],[]],s=new Map;function o(t,r){let a=s.get(t);if(null!=a){if(a<=r)return;let e=n[a].indexOf(t);e>-1&&n[a].splice(e,1),t instanceof ks&&i.delete(t.compartment)}if(s.set(t,r),Array.isArray(t))for(let e of t)o(e,r);else if(t instanceof ks){if(i.has(t.compartment))throw new RangeError("Duplicate use of compartment in extensions");let n=e.get(t.compartment)||t.inner;i.set(t.compartment,n),o(n,r)}else if(t instanceof _s)o(t.inner,t.prec);else if(t instanceof gs)n[r].push(t),t.provides&&o(t.provides,r);else if(t instanceof us)n[r].push(t),t.facet.extensions&&o(t.facet.extensions,Os);else{let e=t.extension;if(!e)throw new Error(`Unrecognized extension value in extension set (${t}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);o(e,r)}}return o(t,Os),n.reduce((t,e)=>t.concat(e))}(t,e,o))i instanceof gs?n.push(i):(s[i.facet.id]||(s[i.facet.id]=[])).push(i);let r=Object.create(null),a=[],l=[];for(let t of n)r[t.id]=l.length<<1,l.push(e=>t.slot(e));let c=null==i?void 0:i.config.facets;for(let t in s){let e=s[t],n=e[0].facet,o=c&&c[t]||[];if(e.every(t=>0==t.type))if(r[n.id]=a.length<<1|1,hs(o,e))a.push(i.facet(n));else{let t=n.combine(e.map(t=>t.value));a.push(i&&n.compare(t,i.facet(n))?i.facet(n):t)}else{for(let t of e)0==t.type?(r[t.id]=a.length<<1|1,a.push(t.value)):(r[t.id]=l.length<<1,l.push(e=>t.dynamicSlot(e)));r[n.id]=l.length<<1,l.push(t=>ps(t,n,e))}}let h=l.map(t=>t(r));return new $s(t,o,h,r,a,s)}}function Cs(t,e){if(1&e)return 2;let i=e>>1,n=t.status[i];if(4==n)throw new Error("Cyclic dependency between fields and/or facets");if(2&n)return n;t.status[i]=4;let s=t.computeSlot(t,t.config.dynamicSlots[i]);return t.status[i]=2|s}function Ts(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}const Ps=cs.define(),Es=cs.define({combine:t=>t.some(t=>t),static:!0}),As=cs.define({combine:t=>t.length?t[0]:void 0,static:!0}),Ms=cs.define(),Qs=cs.define(),Ds=cs.define(),Rs=cs.define({combine:t=>!!t.length&&t[0]});class Is{constructor(t,e){this.type=t,this.value=e}static define(){return new Ls}}class Ls{of(t){return new Is(this,t)}}class Ns{constructor(t){this.map=t}of(t){return new js(this,t)}}class js{constructor(t,e){this.type=t,this.value=e}map(t){let e=this.type.map(this.value,t);return void 0===e?void 0:e==this.value?this:new js(this.type,e)}is(t){return this.type==t}static define(t={}){return new Ns(t.map||(t=>t))}static mapEffects(t,e){if(!t.length)return t;let i=[];for(let n of t){let t=n.map(e);t&&i.push(t)}return i}}js.reconfigure=js.define(),js.appendConfig=js.define();class zs{constructor(t,e,i,n,s,o){this.startState=t,this.changes=e,this.selection=i,this.effects=n,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,i&&as(i,e.newLength),s.some(t=>t.type==zs.time)||(this.annotations=s.concat(zs.time.of(Date.now())))}static create(t,e,i,n,s,o){return new zs(t,e,i,n,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(t){for(let e of this.annotations)if(e.type==t)return e.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let e=this.annotation(zs.userEvent);return!(!e||!(e==t||e.length>t.length&&e.slice(0,t.length)==t&&"."==e[t.length]))}}function Bs(t,e){let i=[];for(let n=0,s=0;;){let o,r;if(n<t.length&&(s==e.length||e[s]>=t[n]))o=t[n++],r=t[n++];else{if(!(s<e.length))return i;o=e[s++],r=e[s++]}!i.length||i[i.length-1]<o?i.push(o,r):i[i.length-1]<r&&(i[i.length-1]=r)}}function qs(t,e,i){var n;let s,o,r;return i?(s=e.changes,o=Kn.empty(e.changes.length),r=t.changes.compose(e.changes)):(s=e.changes.map(t.changes),o=t.changes.mapDesc(e.changes,!0),r=t.changes.compose(s)),{changes:r,selection:e.selection?e.selection.map(o):null===(n=t.selection)||void 0===n?void 0:n.map(s),effects:js.mapEffects(t.effects,s).concat(js.mapEffects(e.effects,o)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function Zs(t,e,i){let n=e.selection,s=Hs(e.annotations);return e.userEvent&&(s=s.concat(zs.userEvent.of(e.userEvent))),{changes:e.changes instanceof Kn?e.changes:Kn.of(e.changes||[],i,t.facet(As)),selection:n&&(n instanceof rs?n:rs.single(n.anchor,n.head)),effects:Hs(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function Fs(t,e,i){let n=Zs(t,e.length?e[0]:{},t.doc.length);e.length&&!1===e[0].filter&&(i=!1);for(let s=1;s<e.length;s++){!1===e[s].filter&&(i=!1);let o=!!e[s].sequential;n=qs(n,Zs(t,e[s],o?n.changes.newLength:t.doc.length),o)}let s=zs.create(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return function(t){let e=t.startState,i=e.facet(Ds),n=t;for(let s=i.length-1;s>=0;s--){let o=i[s](t);o&&Object.keys(o).length&&(n=qs(n,Zs(e,o,t.changes.newLength),!0))}return n==t?t:zs.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}(i?function(t){let e=t.startState,i=!0;for(let n of e.facet(Ms)){let e=n(t);if(!1===e){i=!1;break}Array.isArray(e)&&(i=!0===i?e:Bs(i,e))}if(!0!==i){let n,s;if(!1===i)s=t.changes.invertedDesc,n=Kn.empty(e.doc.length);else{let e=t.changes.filter(i);n=e.changes,s=e.filtered.mapDesc(e.changes).invertedDesc}t=zs.create(e,n,t.selection&&t.selection.map(s),js.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let n=e.facet(Qs);for(let i=n.length-1;i>=0;i--){let s=n[i](t);t=s instanceof zs?s:Array.isArray(s)&&1==s.length&&s[0]instanceof zs?s[0]:Fs(e,Hs(s),!1)}return t}(s):s)}zs.time=Is.define(),zs.userEvent=Is.define(),zs.addToHistory=Is.define(),zs.remote=Is.define();const Xs=[];function Hs(t){return null==t?Xs:Array.isArray(t)?t:[t]}var Ws=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(Ws||(Ws={}));const Vs=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Ys;try{Ys=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(t){}function Us(t){return e=>{if(!/\S/.test(e))return Ws.Space;if(function(t){if(Ys)return Ys.test(t);for(let e=0;e<t.length;e++){let i=t[e];if(/\w/.test(i)||i>"€"&&(i.toUpperCase()!=i.toLowerCase()||Vs.test(i)))return!0}return!1}(e))return Ws.Word;for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>-1)return Ws.Word;return Ws.Other}}class Gs{constructor(t,e,i,n,s,o){this.config=t,this.doc=e,this.selection=i,this.values=n,this.status=t.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let t=0;t<this.config.dynamicSlots.length;t++)Cs(this,t<<1);this.computeSlot=null}field(t,e=!0){let i=this.config.address[t.id];if(null!=i)return Cs(this,i),Ts(this,i);if(e)throw new RangeError("Field is not present in this state")}update(...t){return Fs(this,t,!0)}applyTransaction(t){let e,i=this.config,{base:n,compartments:s}=i;for(let e of t.effects)e.is(Ss.reconfigure)?(i&&(s=new Map,i.compartments.forEach((t,e)=>s.set(e,t)),i=null),s.set(e.value.compartment,e.value.extension)):e.is(js.reconfigure)?(i=null,n=e.value):e.is(js.appendConfig)&&(i=null,n=Hs(n).concat(e.value));if(i)e=t.startState.values.slice();else{i=$s.resolve(n,s,this),e=new Gs(i,this.doc,this.selection,i.dynamicSlots.map(()=>null),(t,e)=>e.reconfigure(t,this),null).values}let o=t.startState.facet(Es)?t.newSelection:t.newSelection.asSingle();new Gs(i,t.newDoc,o,e,(e,i)=>i.update(e,t),t)}replaceSelection(t){return"string"==typeof t&&(t=this.toText(t)),this.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:t},range:rs.cursor(e.from+t.length)}))}changeByRange(t){let e=this.selection,i=t(e.ranges[0]),n=this.changes(i.changes),s=[i.range],o=Hs(i.effects);for(let i=1;i<e.ranges.length;i++){let r=t(e.ranges[i]),a=this.changes(r.changes),l=a.map(n);for(let t=0;t<i;t++)s[t]=s[t].map(l);let c=n.mapDesc(a,!0);s.push(r.range.map(c)),n=n.compose(l),o=js.mapEffects(o,l).concat(js.mapEffects(Hs(r.effects),c))}return{changes:n,selection:rs.create(s,e.mainIndex),effects:o}}changes(t=[]){return t instanceof Kn?t:Kn.of(t,this.doc.length,this.facet(Gs.lineSeparator))}toText(t){return Rn.of(t.split(this.facet(Gs.lineSeparator)||Yn))}sliceDoc(t=0,e=this.doc.length){return this.doc.sliceString(t,e,this.lineBreak)}facet(t){let e=this.config.address[t.id];return null==e?t.default:(Cs(this,e),Ts(this,e))}toJSON(t){let e={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(t)for(let i in t){let n=t[i];n instanceof gs&&null!=this.config.address[n.id]&&(e[i]=n.spec.toJSON(this.field(t[i]),this))}return e}static fromJSON(t,e={},i){if(!t||"string"!=typeof t.doc)throw new RangeError("Invalid JSON representation for EditorState");let n=[];if(i)for(let e in i)if(Object.prototype.hasOwnProperty.call(t,e)){let s=i[e],o=t[e];n.push(s.init(t=>s.spec.fromJSON(o,t)))}return Gs.create({doc:t.doc,selection:rs.fromJSON(t.selection),extensions:e.extensions?n.concat([e.extensions]):n})}static create(t={}){let e=$s.resolve(t.extensions||[],new Map),i=t.doc instanceof Rn?t.doc:Rn.of((t.doc||"").split(e.staticFacet(Gs.lineSeparator)||Yn)),n=t.selection?t.selection instanceof rs?t.selection:rs.single(t.selection.anchor,t.selection.head):rs.single(0);return as(n,i.length),e.staticFacet(Es)||(n=n.asSingle()),new Gs(e,i,n,e.dynamicSlots.map(()=>null),(t,e)=>e.create(t),null)}get tabSize(){return this.facet(Gs.tabSize)}get lineBreak(){return this.facet(Gs.lineSeparator)||"\n"}get readOnly(){return this.facet(Rs)}phrase(t,...e){for(let e of this.facet(Gs.phrases))if(Object.prototype.hasOwnProperty.call(e,t)){t=e[t];break}return e.length&&(t=t.replace(/\$(\$|\d*)/g,(t,i)=>{if("$"==i)return"$";let n=+(i||1);return!n||n>e.length?t:e[n-1]})),t}languageDataAt(t,e,i=-1){let n=[];for(let s of this.facet(Ps))for(let o of s(this,e,i))Object.prototype.hasOwnProperty.call(o,t)&&n.push(o[t]);return n}charCategorizer(t){return Us(this.languageDataAt("wordChars",t).join(""))}wordAt(t){let{text:e,from:i,length:n}=this.doc.lineAt(t),s=this.charCategorizer(t),o=t-i,r=t-i;for(;o>0;){let t=Xn(e,o,!1);if(s(e.slice(t,o))!=Ws.Word)break;o=t}for(;r<n;){let t=Xn(e,r);if(s(e.slice(r,t))!=Ws.Word)break;r=t}return o==r?null:rs.range(o+i,r+i)}}function Ks(t,e,i={}){let n={};for(let e of t)for(let t of Object.keys(e)){let s=e[t],o=n[t];if(void 0===o)n[t]=s;else if(o===s||void 0===s);else{if(!Object.hasOwnProperty.call(i,t))throw new Error("Config merge conflict for field "+t);n[t]=i[t](o,s)}}for(let t in e)void 0===n[t]&&(n[t]=e[t]);return n}Gs.allowMultipleSelections=Es,Gs.tabSize=cs.define({combine:t=>t.length?t[0]:4}),Gs.lineSeparator=As,Gs.readOnly=Rs,Gs.phrases=cs.define({compare(t,e){let i=Object.keys(t),n=Object.keys(e);return i.length==n.length&&i.every(i=>t[i]==e[i])}}),Gs.languageData=Ps,Gs.changeFilter=Ms,Gs.transactionFilter=Qs,Gs.transactionExtender=Ds,Ss.reconfigure=js.define();class Js{eq(t){return this==t}range(t,e=t){return to.create(t,e,this)}}Js.prototype.startSide=Js.prototype.endSide=0,Js.prototype.point=!1,Js.prototype.mapMode=Un.TrackDel;class to{constructor(t,e,i){this.from=t,this.to=e,this.value=i}static create(t,e,i){return new to(t,e,i)}}function eo(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class io{constructor(t,e,i,n){this.from=t,this.to=e,this.value=i,this.maxPoint=n}get length(){return this.to[this.to.length-1]}findIndex(t,e,i,n=0){let s=i?this.to:this.from;for(let o=n,r=s.length;;){if(o==r)return o;let n=o+r>>1,a=s[n]-t||(i?this.value[n].endSide:this.value[n].startSide)-e;if(n==o)return a>=0?o:r;a>=0?r=n:o=n+1}}between(t,e,i,n){for(let s=this.findIndex(e,-1e9,!0),o=this.findIndex(i,1e9,!1,s);s<o;s++)if(!1===n(this.from[s]+t,this.to[s]+t,this.value[s]))return!1}map(t,e){let i=[],n=[],s=[],o=-1,r=-1;for(let a=0;a<this.value.length;a++){let l,c,h=this.value[a],u=this.from[a]+t,d=this.to[a]+t;if(u==d){let t=e.mapPos(u,h.startSide,h.mapMode);if(null==t)continue;if(l=c=t,h.startSide!=h.endSide&&(c=e.mapPos(u,h.endSide),c<l))continue}else if(l=e.mapPos(u,h.startSide),c=e.mapPos(d,h.endSide),l>c||l==c&&h.startSide>0&&h.endSide<=0)continue;(c-l||h.endSide-h.startSide)<0||(o<0&&(o=l),h.point&&(r=Math.max(r,c-l)),i.push(h),n.push(l-o),s.push(c-o))}return{mapped:i.length?new io(n,s,i,r):null,pos:o}}}class no{constructor(t,e,i,n){this.chunkPos=t,this.chunk=e,this.nextLayer=i,this.maxPoint=n}static create(t,e,i,n){return new no(t,e,i,n)}get length(){let t=this.chunk.length-1;return t<0?0:Math.max(this.chunkEnd(t),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let t=this.nextLayer.size;for(let e of this.chunk)t+=e.value.length;return t}chunkEnd(t){return this.chunkPos[t]+this.chunk[t].length}update(t){let{add:e=[],sort:i=!1,filterFrom:n=0,filterTo:s=this.length}=t,o=t.filter;if(0==e.length&&!o)return this;if(i&&(e=e.slice().sort(eo)),this.isEmpty)return e.length?no.of(e):this;let r=new ro(this,null,-1).goto(0),a=0,l=[],c=new so;for(;r.value||a<e.length;)if(a<e.length&&(r.from-e[a].from||r.startSide-e[a].value.startSide)>=0){let t=e[a++];c.addInner(t.from,t.to,t.value)||l.push(t)}else 1==r.rangeIndex&&r.chunkIndex<this.chunk.length&&(a==e.length||this.chunkEnd(r.chunkIndex)<e[a].from)&&(!o||n>this.chunkEnd(r.chunkIndex)||s<this.chunkPos[r.chunkIndex])&&c.addChunk(this.chunkPos[r.chunkIndex],this.chunk[r.chunkIndex])?r.nextChunk():((!o||n>r.to||s<r.from||o(r.from,r.to,r.value))&&(c.addInner(r.from,r.to,r.value)||l.push(to.create(r.from,r.to,r.value))),r.next());return c.finishInner(this.nextLayer.isEmpty&&!l.length?no.empty:this.nextLayer.update({add:l,filter:o,filterFrom:n,filterTo:s}))}map(t){if(t.empty||this.isEmpty)return this;let e=[],i=[],n=-1;for(let s=0;s<this.chunk.length;s++){let o=this.chunkPos[s],r=this.chunk[s],a=t.touchesRange(o,o+r.length);if(!1===a)n=Math.max(n,r.maxPoint),e.push(r),i.push(t.mapPos(o));else if(!0===a){let{mapped:s,pos:a}=r.map(o,t);s&&(n=Math.max(n,s.maxPoint),e.push(s),i.push(a))}}let s=this.nextLayer.map(t);return 0==e.length?s:new no(i,e,s||no.empty,n)}between(t,e,i){if(!this.isEmpty){for(let n=0;n<this.chunk.length;n++){let s=this.chunkPos[n],o=this.chunk[n];if(e>=s&&t<=s+o.length&&!1===o.between(s,t-s,e-s,i))return}this.nextLayer.between(t,e,i)}}iter(t=0){return ao.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return ao.from(t).goto(e)}static compare(t,e,i,n,s=-1){let o=t.filter(t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=s),r=e.filter(t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=s),a=oo(o,r,i),l=new co(o,a,s),c=new co(r,a,s);i.iterGaps((t,e,i)=>ho(l,t,c,e,i,n)),i.empty&&0==i.length&&ho(l,0,c,0,0,n)}static eq(t,e,i=0,n){null==n&&(n=999999999);let s=t.filter(t=>!t.isEmpty&&e.indexOf(t)<0),o=e.filter(e=>!e.isEmpty&&t.indexOf(e)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let r=oo(s,o),a=new co(s,r,0).goto(i),l=new co(o,r,0).goto(i);for(;;){if(a.to!=l.to||!uo(a.active,l.active)||a.point&&(!l.point||!a.point.eq(l.point)))return!1;if(a.to>n)return!0;a.next(),l.next()}}static spans(t,e,i,n,s=-1){let o=new co(t,null,s).goto(e),r=e,a=o.openStart;for(;;){let t=Math.min(o.to,i);if(o.point){let i=o.activeForPoint(o.to),s=o.pointFrom<e?i.length+1:o.point.startSide<0?i.length:Math.min(i.length,a);n.point(r,t,o.point,i,s,o.pointRank),a=Math.min(o.openEnd(t),i.length)}else t>r&&(n.span(r,t,o.active,a),a=o.openEnd(t));if(o.to>i)return a+(o.point&&o.to>i?1:0);r=o.to,o.next()}}static of(t,e=!1){let i=new so;for(let n of t instanceof to?[t]:e?function(t){if(t.length>1)for(let e=t[0],i=1;i<t.length;i++){let n=t[i];if(eo(e,n)>0)return t.slice().sort(eo);e=n}return t}(t):t)i.add(n.from,n.to,n.value);return i.finish()}static join(t){if(!t.length)return no.empty;let e=t[t.length-1];for(let i=t.length-2;i>=0;i--)for(let n=t[i];n!=no.empty;n=n.nextLayer)e=new no(n.chunkPos,n.chunk,e,Math.max(n.maxPoint,e.maxPoint));return e}}no.empty=new no([],[],null,-1),no.empty.nextLayer=no.empty;class so{finishChunk(t){this.chunks.push(new io(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,t&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(t,e,i){this.addInner(t,e,i)||(this.nextLayer||(this.nextLayer=new so)).add(t,e,i)}addInner(t,e,i){let n=t-this.lastTo||i.startSide-this.last.endSide;if(n<=0&&(t-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(n<0)&&(250==this.from.length&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=t),this.from.push(t-this.chunkStart),this.to.push(e-this.chunkStart),this.last=i,this.lastFrom=t,this.lastTo=e,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,e-t)),!0)}addChunk(t,e){if((t-this.lastTo||e.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,e.maxPoint),this.chunks.push(e),this.chunkPos.push(t);let i=e.value.length-1;return this.last=e.value[i],this.lastFrom=e.from[i]+t,this.lastTo=e.to[i]+t,!0}finish(){return this.finishInner(no.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=no.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function oo(t,e,i){let n=new Map;for(let e of t)for(let t=0;t<e.chunk.length;t++)e.chunk[t].maxPoint<=0&&n.set(e.chunk[t],e.chunkPos[t]);let s=new Set;for(let t of e)for(let e=0;e<t.chunk.length;e++){let o=n.get(t.chunk[e]);null==o||(i?i.mapPos(o):o)!=t.chunkPos[e]||(null==i?void 0:i.touchesRange(o,o+t.chunk[e].length))||s.add(t.chunk[e])}return s}class ro{constructor(t,e,i,n=0){this.layer=t,this.skip=e,this.minPoint=i,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,i){for(;this.chunkIndex<this.layer.chunk.length;){let e=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(e)||this.layer.chunkEnd(this.chunkIndex)<t||e.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let n=this.layer.chunk[this.chunkIndex].findIndex(t-this.layer.chunkPos[this.chunkIndex],e,!0);(!i||this.rangeIndex<n)&&this.setRangeIndex(n)}this.next()}forward(t,e){(this.to-t||this.endSide-e)<0&&this.gotoInner(t,e,!0)}next(){for(;;){if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}{let t=this.layer.chunkPos[this.chunkIndex],e=this.layer.chunk[this.chunkIndex],i=t+e.from[this.rangeIndex];if(this.from=i,this.to=t+e.to[this.rangeIndex],this.value=e.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}}setRangeIndex(t){if(t==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=t}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.rank-t.rank||this.to-t.to||this.endSide-t.endSide}}class ao{constructor(t){this.heap=t}static from(t,e=null,i=-1){let n=[];for(let s=0;s<t.length;s++)for(let o=t[s];!o.isEmpty;o=o.nextLayer)o.maxPoint>=i&&n.push(new ro(o,e,i,s));return 1==n.length?n[0]:new ao(n)}get startSide(){return this.value?this.value.startSide:0}goto(t,e=-1e9){for(let i of this.heap)i.goto(t,e);for(let t=this.heap.length>>1;t>=0;t--)lo(this.heap,t);return this.next(),this}forward(t,e){for(let i of this.heap)i.forward(t,e);for(let t=this.heap.length>>1;t>=0;t--)lo(this.heap,t);(this.to-t||this.value.endSide-e)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),lo(this.heap,0)}}}function lo(t,e){for(let i=t[e];;){let n=1+(e<<1);if(n>=t.length)break;let s=t[n];if(n+1<t.length&&s.compare(t[n+1])>=0&&(s=t[n+1],n++),i.compare(s)<0)break;t[n]=i,t[e]=s,e=n}}class co{constructor(t,e,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=ao.from(t,e,i)}goto(t,e=-1e9){return this.cursor.goto(t,e),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=t,this.endSide=e,this.openStart=-1,this.next(),this}forward(t,e){for(;this.minActive>-1&&(this.activeTo[this.minActive]-t||this.active[this.minActive].endSide-e)<0;)this.removeActive(this.minActive);this.cursor.forward(t,e)}removeActive(t){fo(this.active,t),fo(this.activeTo,t),fo(this.activeRank,t),this.minActive=mo(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:n,rank:s}=this.cursor;for(;e<this.activeRank.length&&(s-this.activeRank[e]||n-this.activeTo[e])>0;)e++;po(this.active,e,i),po(this.activeTo,e,n),po(this.activeRank,e,s),t&&po(t,e,this.cursor.from),this.minActive=mo(this.active,this.activeTo)}next(){let t=this.to,e=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)<0){if(this.activeTo[n]>t){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),i&&fo(i,n)}else{if(!this.cursor.value){this.to=this.endSide=1e9;break}if(this.cursor.from>t){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}{let t=this.cursor.value;if(t.point){if(!(e&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){this.point=t,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=t.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(i),this.cursor.next()}}}if(i){this.openStart=0;for(let e=i.length-1;e>=0&&i[e]<t;e--)this.openStart++}}activeForPoint(t){if(!this.active.length)return this.active;let e=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>t||this.activeTo[i]==t&&this.active[i].endSide>=this.point.endSide)&&e.push(this.active[i]);return e.reverse()}openEnd(t){let e=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>t;i--)e++;return e}}function ho(t,e,i,n,s,o){t.goto(e),i.goto(n);let r=n+s,a=n,l=n-e;for(;;){let e=t.to+l-i.to,n=e||t.endSide-i.endSide,s=n<0?t.to+l:i.to,c=Math.min(s,r);if(t.point||i.point?t.point&&i.point&&(t.point==i.point||t.point.eq(i.point))&&uo(t.activeForPoint(t.to),i.activeForPoint(i.to))||o.comparePoint(a,c,t.point,i.point):c>a&&!uo(t.active,i.active)&&o.compareRange(a,c,t.active,i.active),s>r)break;(e||t.openEnd!=i.openEnd)&&o.boundChange&&o.boundChange(s),a=s,n<=0&&t.next(),n>=0&&i.next()}}function uo(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(t[i]!=e[i]&&!t[i].eq(e[i]))return!1;return!0}function fo(t,e){for(let i=e,n=t.length-1;i<n;i++)t[i]=t[i+1];t.pop()}function po(t,e,i){for(let i=t.length-1;i>=e;i--)t[i+1]=t[i];t[e]=i}function mo(t,e){let i=-1,n=1e9;for(let s=0;s<e.length;s++)(e[s]-n||t[s].endSide-t[i].endSide)<0&&(i=s,n=e[s]);return i}function go(t,e,i=t.length){let n=0;for(let s=0;s<i&&s<t.length;)9==t.charCodeAt(s)?(n+=e-n%e,s++):(n++,s=Xn(t,s));return n}function vo(t,e,i,n){for(let n=0,s=0;;){if(s>=e)return n;if(n==t.length)break;s+=9==t.charCodeAt(n)?i-s%i:1,n=Xn(t,n)}return!0===n?-1:t.length}const yo="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),Oo="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),bo="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class xo{constructor(t,e){this.rules=[];let{finish:i}=e||{};function n(t){return/^@/.test(t)?[t]:t.split(/,\s*/)}function s(t,e,o,r){let a=[],l=/^@(\w+)\b/.exec(t[0]),c=l&&"keyframes"==l[1];if(l&&null==e)return o.push(t[0]+";");for(let i in e){let r=e[i];if(/&/.test(i))s(i.split(/,\s*/).map(e=>t.map(t=>e.replace(/&/,t))).reduce((t,e)=>t.concat(e)),r,o);else if(r&&"object"==typeof r){if(!l)throw new RangeError("The value of a property ("+i+") should be a primitive value.");s(n(i),r,a,c)}else null!=r&&a.push(i.replace(/_.*/,"").replace(/[A-Z]/g,t=>"-"+t.toLowerCase())+": "+r+";")}(a.length||c)&&o.push((!i||l||r?t:t.map(i)).join(", ")+" {"+a.join(" ")+"}")}for(let e in t)s(n(e),t[e],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let t=bo[yo]||1;return bo[yo]=t+1,"ͼ"+t.toString(36)}static mount(t,e,i){let n=t[Oo],s=i&&i.nonce;n?s&&n.setNonce(s):n=new _o(t,s),n.mount(Array.isArray(e)?e:[e],t)}}let wo=new Map;class _o{constructor(t,e){let i=t.ownerDocument||t,n=i.defaultView;if(!t.head&&t.adoptedStyleSheets&&n.CSSStyleSheet){let e=wo.get(i);if(e)return t[Oo]=e;this.sheet=new n.CSSStyleSheet,wo.set(i,this)}else this.styleTag=i.createElement("style"),e&&this.styleTag.setAttribute("nonce",e);this.modules=[],t[Oo]=this}mount(t,e){let i=this.sheet,n=0,s=0;for(let e=0;e<t.length;e++){let o=t[e],r=this.modules.indexOf(o);if(r<s&&r>-1&&(this.modules.splice(r,1),s--,r=-1),-1==r){if(this.modules.splice(s++,0,o),i)for(let t=0;t<o.rules.length;t++)i.insertRule(o.rules[t],n++)}else{for(;s<r;)n+=this.modules[s++].rules.length;n+=o.rules.length,s++}}if(i)e.adoptedStyleSheets.indexOf(this.sheet)<0&&(e.adoptedStyleSheets=[this.sheet,...e.adoptedStyleSheets]);else{let t="";for(let e=0;e<this.modules.length;e++)t+=this.modules[e].getRules()+"\n";this.styleTag.textContent=t;let i=e.head||e;this.styleTag.parentNode!=i&&i.insertBefore(this.styleTag,i.firstChild)}}setNonce(t){this.styleTag&&this.styleTag.getAttribute("nonce")!=t&&this.styleTag.setAttribute("nonce",t)}}for(var So={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},ko={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},$o="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Co="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),To=0;To<10;To++)So[48+To]=So[96+To]=String(To);for(To=1;To<=24;To++)So[To+111]="F"+To;for(To=65;To<=90;To++)So[To]=String.fromCharCode(To+32),ko[To]=String.fromCharCode(To);for(var Po in So)ko.hasOwnProperty(Po)||(ko[Po]=So[Po]);function Eo(t){let e;return e=11==t.nodeType?t.getSelection?t:t.ownerDocument:t,e.getSelection()}function Ao(t,e){return!!e&&(t==e||t.contains(1!=e.nodeType?e.parentNode:e))}function Mo(t,e){if(!e.anchorNode)return!1;try{return Ao(t,e.anchorNode)}catch(t){return!1}}function Qo(t){return 3==t.nodeType?Ho(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function Do(t,e,i,n){return!!i&&(Lo(t,e,i,n,-1)||Lo(t,e,i,n,1))}function Ro(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function Io(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function Lo(t,e,i,n,s){for(;;){if(t==i&&e==n)return!0;if(e==(s<0?0:No(t))){if("DIV"==t.nodeName)return!1;let i=t.parentNode;if(!i||1!=i.nodeType)return!1;e=Ro(t)+(s<0?0:1),t=i}else{if(1!=t.nodeType)return!1;if(1==(t=t.childNodes[e+(s<0?-1:0)]).nodeType&&"false"==t.contentEditable)return!1;e=s<0?No(t):0}}}function No(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function jo(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function zo(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function Bo(t,e){let i=e.width/t.offsetWidth,n=e.height/t.offsetHeight;return(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.width-t.offsetWidth)<1)&&(i=1),(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.height-t.offsetHeight)<1)&&(n=1),{scaleX:i,scaleY:n}}class qo{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){let{anchorNode:e,focusNode:i}=t;this.set(e,Math.min(t.anchorOffset,e?No(e):0),i,Math.min(t.focusOffset,i?No(i):0))}set(t,e,i,n){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=n}}let Zo,Fo=null;function Xo(t){if(t.setActive)return t.setActive();if(Fo)return t.focus(Fo);let e=[];for(let i=t;i&&(e.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(t.focus(null==Fo?{get preventScroll(){return Fo={preventScroll:!0},!0}}:void 0),!Fo){Fo=!1;for(let t=0;t<e.length;){let i=e[t++],n=e[t++],s=e[t++];i.scrollTop!=n&&(i.scrollTop=n),i.scrollLeft!=s&&(i.scrollLeft=s)}}}function Ho(t,e,i=e){let n=Zo||(Zo=document.createRange());return n.setEnd(t,i),n.setStart(t,e),n}function Wo(t,e,i,n){let s={key:e,code:e,keyCode:i,which:i,cancelable:!0};n&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=n);let o=new KeyboardEvent("keydown",s);o.synthetic=!0,t.dispatchEvent(o);let r=new KeyboardEvent("keyup",s);return r.synthetic=!0,t.dispatchEvent(r),o.defaultPrevented||r.defaultPrevented}function Vo(t){for(;t.attributes.length;)t.removeAttributeNode(t.attributes[0])}function Yo(t){return t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function Uo(t,e){for(let i=t,n=e;;){if(3==i.nodeType&&n>0)return{node:i,offset:n};if(1==i.nodeType&&n>0){if("false"==i.contentEditable)return null;i=i.childNodes[n-1],n=No(i)}else{if(!i.parentNode||Io(i))return null;n=Ro(i),i=i.parentNode}}}function Go(t,e){for(let i=t,n=e;;){if(3==i.nodeType&&n<i.nodeValue.length)return{node:i,offset:n};if(1==i.nodeType&&n<i.childNodes.length){if("false"==i.contentEditable)return null;i=i.childNodes[n],n=0}else{if(!i.parentNode||Io(i))return null;n=Ro(i)+1,i=i.parentNode}}}class Ko{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new Ko(t.parentNode,Ro(t),e)}static after(t,e){return new Ko(t.parentNode,Ro(t)+1,e)}}const Jo=[];class tr{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(t){let e=this.posAtStart;for(let i of this.children){if(i==t)return e;e+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(t){return this.posBefore(t)+t.length}sync(t,e){if(2&this.flags){let i,n=this.dom,s=null;for(let o of this.children){if(7&o.flags){if(!o.dom&&(i=s?s.nextSibling:n.firstChild)){let t=tr.get(i);(!t||!t.parent&&t.canReuseDOM(o))&&o.reuseDOM(i)}o.sync(t,e),o.flags&=-8}if(i=s?s.nextSibling:n.firstChild,e&&!e.written&&e.node==n&&i!=o.dom&&(e.written=!0),o.dom.parentNode==n)for(;i&&i!=o.dom;)i=er(i);else n.insertBefore(o.dom,i);s=o.dom}for(i=s?s.nextSibling:n.firstChild,i&&e&&e.node==n&&(e.written=!0);i;)i=er(i)}else if(1&this.flags)for(let i of this.children)7&i.flags&&(i.sync(t,e),i.flags&=-8)}reuseDOM(t){}localPosFromDOM(t,e){let i;if(t==this.dom)i=this.dom.childNodes[e];else{let n=0==No(t)?0:0==e?-1:1;for(;;){let e=t.parentNode;if(e==this.dom)break;0==n&&e.firstChild!=e.lastChild&&(n=t==e.firstChild?-1:1),t=e}i=n<0?t:t.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!tr.get(i);)i=i.nextSibling;if(!i)return this.length;for(let t=0,e=0;;t++){let n=this.children[t];if(n.dom==i)return e;e+=n.length+n.breakAfter}}domBoundsAround(t,e,i=0){let n=-1,s=-1,o=-1,r=-1;for(let a=0,l=i,c=i;a<this.children.length;a++){let i=this.children[a],h=l+i.length;if(l<t&&h>e)return i.domBoundsAround(t,e,l);if(h>=t&&-1==n&&(n=a,s=l),l>e&&i.dom.parentNode==this.dom){o=a,r=c;break}c=h,l=h+i.breakAfter}return{from:s,to:r<0?i+this.length:r,startDOM:(n?this.children[n-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:o<this.children.length&&o>=0?this.children[o].dom:null}}markDirty(t=!1){this.flags|=2,this.markParentsDirty(t)}markParentsDirty(t){for(let e=this.parent;e;e=e.parent){if(t&&(e.flags|=2),1&e.flags)return;e.flags|=1,t=!1}}setParent(t){this.parent!=t&&(this.parent=t,7&this.flags&&this.markParentsDirty(!0))}setDOM(t){this.dom!=t&&(this.dom&&(this.dom.cmView=null),this.dom=t,t.cmView=this)}get rootView(){for(let t=this;;){let e=t.parent;if(!e)return t;t=e}}replaceChildren(t,e,i=Jo){this.markDirty();for(let n=t;n<e;n++){let t=this.children[n];t.parent==this&&i.indexOf(t)<0&&t.destroy()}i.length<250?this.children.splice(t,e-t,...i):this.children=[].concat(this.children.slice(0,t),i,this.children.slice(e));for(let t=0;t<i.length;t++)i[t].setParent(this)}ignoreMutation(t){return!1}ignoreEvent(t){return!1}childCursor(t=this.length){return new ir(this.children,t,this.children.length)}childPos(t,e=1){return this.childCursor().findPos(t,e)}toString(){let t=this.constructor.name.replace("View","");return t+(this.children.length?"("+this.children.join()+")":this.length?"["+("Text"==t?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(t){return t.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(t,e,i,n,s,o){return!1}become(t){return!1}canReuseDOM(t){return t.constructor==this.constructor&&!(8&(this.flags|t.flags))}getSide(){return 0}destroy(){for(let t of this.children)t.parent==this&&t.destroy();this.parent=null}}function er(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}tr.prototype.breakAfter=0;class ir{constructor(t,e,i){this.children=t,this.pos=e,this.i=i,this.off=0}findPos(t,e=1){for(;;){if(t>this.pos||t==this.pos&&(e>0||0==this.i||this.children[this.i-1].breakAfter))return this.off=t-this.pos,this;let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}}function nr(t,e,i,n,s,o,r,a,l){let{children:c}=t,h=c.length?c[e]:null,u=o.length?o[o.length-1]:null,d=u?u.breakAfter:r;if(!(e==n&&h&&!r&&!d&&o.length<2&&h.merge(i,s,o.length?u:null,0==i,a,l))){if(n<c.length){let t=c[n];t&&(s<t.length||t.breakAfter&&(null==u?void 0:u.breakAfter))?(e==n&&(t=t.split(s),s=0),!d&&u&&t.merge(0,s,u,!0,0,l)?o[o.length-1]=t:((s||t.children.length&&!t.children[0].length)&&t.merge(0,s,null,!1,0,l),o.push(t))):(null==t?void 0:t.breakAfter)&&(u?u.breakAfter=1:r=1),n++}for(h&&(h.breakAfter=r,i>0&&(!r&&o.length&&h.merge(i,h.length,o[0],!1,a,0)?h.breakAfter=o.shift().breakAfter:(i<h.length||h.children.length&&0==h.children[h.children.length-1].length)&&h.merge(i,h.length,null,!1,a,0),e++));e<n&&o.length;)if(c[n-1].become(o[o.length-1]))n--,o.pop(),l=o.length?0:a;else{if(!c[e].become(o[0]))break;e++,o.shift(),a=o.length?0:l}!o.length&&e&&n<c.length&&!c[e-1].breakAfter&&c[n].merge(0,0,c[e-1],!1,a,l)&&e--,(e<n||o.length)&&t.replaceChildren(e,n,o)}}function sr(t,e,i,n,s,o){let r=t.childCursor(),{i:a,off:l}=r.findPos(i,1),{i:c,off:h}=r.findPos(e,-1),u=e-i;for(let t of n)u+=t.length;t.length+=u,nr(t,c,h,a,l,n,0,s,o)}let or="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},rr="undefined"!=typeof document?document:{documentElement:{style:{}}};const ar=/Edge\/(\d+)/.exec(or.userAgent),lr=/MSIE \d/.test(or.userAgent),cr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(or.userAgent),hr=!!(lr||cr||ar),ur=!hr&&/gecko\/(\d+)/i.test(or.userAgent),dr=!hr&&/Chrome\/(\d+)/.exec(or.userAgent),fr="webkitFontSmoothing"in rr.documentElement.style,pr=!hr&&/Apple Computer/.test(or.vendor),mr=pr&&(/Mobile\/\w+/.test(or.userAgent)||or.maxTouchPoints>2);var gr={mac:mr||/Mac/.test(or.platform),windows:/Win/.test(or.platform),linux:/Linux|X11/.test(or.platform),ie:hr,ie_version:lr?rr.documentMode||6:cr?+cr[1]:ar?+ar[1]:0,gecko:ur,gecko_version:ur?+(/Firefox\/(\d+)/.exec(or.userAgent)||[0,0])[1]:0,chrome:!!dr,chrome_version:dr?+dr[1]:0,ios:mr,android:/Android\b/.test(or.userAgent),webkit:fr,safari:pr,webkit_version:fr?+(/\bAppleWebKit\/(\d+)/.exec(or.userAgent)||[0,0])[1]:0,tabSize:null!=rr.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};class vr extends tr{constructor(t){super(),this.text=t}get length(){return this.text.length}createDOM(t){this.setDOM(t||document.createTextNode(this.text))}sync(t,e){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text)}reuseDOM(t){3==t.nodeType&&this.createDOM(t)}merge(t,e,i){return!(8&this.flags||i&&(!(i instanceof vr)||this.length-(e-t)+i.length>256||8&i.flags))&&(this.text=this.text.slice(0,t)+(i?i.text:"")+this.text.slice(e),this.markDirty(),!0)}split(t){let e=new vr(this.text.slice(t));return this.text=this.text.slice(0,t),this.markDirty(),e.flags|=8&this.flags,e}localPosFromDOM(t,e){return t==this.dom?e:e?this.text.length:0}domAtPos(t){return new Ko(this.dom,t)}domBoundsAround(t,e,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(t,e){return function(t,e,i){let n=t.nodeValue.length;e>n&&(e=n);let s=e,o=e,r=0;0==e&&i<0||e==n&&i>=0?gr.chrome||gr.gecko||(e?(s--,r=1):o<n&&(o++,r=-1)):i<0?s--:o<n&&o++;let a=Ho(t,s,o).getClientRects();if(!a.length)return null;let l=a[(r?r<0:i>=0)?0:a.length-1];gr.safari&&!r&&0==l.width&&(l=Array.prototype.find.call(a,t=>t.width)||l);return r?jo(l,r<0):l||null}(this.dom,t,e)}}class yr extends tr{constructor(t,e=[],i=0){super(),this.mark=t,this.children=e,this.length=i;for(let t of e)t.setParent(this)}setAttrs(t){if(Vo(t),this.mark.class&&(t.className=this.mark.class),this.mark.attrs)for(let e in this.mark.attrs)t.setAttribute(e,this.mark.attrs[e]);return t}canReuseDOM(t){return super.canReuseDOM(t)&&!(8&(this.flags|t.flags))}reuseDOM(t){t.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(t),this.flags|=6)}sync(t,e){this.dom?4&this.flags&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(t,e)}merge(t,e,i,n,s,o){return(!i||!(!(i instanceof yr&&i.mark.eq(this.mark))||t&&s<=0||e<this.length&&o<=0))&&(sr(this,t,e,i?i.children.slice():[],s-1,o-1),this.markDirty(),!0)}split(t){let e=[],i=0,n=-1,s=0;for(let o of this.children){let r=i+o.length;r>t&&e.push(i<t?o.split(t-i):o),n<0&&i>=t&&(n=s),i=r,s++}let o=this.length-t;return this.length=t,n>-1&&(this.children.length=n,this.markDirty()),new yr(this.mark,e,o)}domAtPos(t){return xr(this,t)}coordsAt(t,e){return _r(this,t,e)}}class Or extends tr{static create(t,e,i){return new Or(t,e,i)}constructor(t,e,i){super(),this.widget=t,this.length=e,this.side=i,this.prevWidget=null}split(t){let e=Or.create(this.widget,this.length-t,this.side);return this.length-=t,e}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(t,e,i,n,s,o){return!(i&&(!(i instanceof Or&&this.widget.compare(i.widget))||t>0&&s<=0||e<this.length&&o<=0))&&(this.length=t+(i?i.length:0)+(this.length-e),!0)}become(t){return t instanceof Or&&t.side==this.side&&this.widget.constructor==t.widget.constructor&&(this.widget.compare(t.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get overrideDOMText(){if(0==this.length)return Rn.empty;let t=this;for(;t.parent;)t=t.parent;let{view:e}=t,i=e&&e.state.doc,n=this.posAtStart;return i?i.slice(n,n+this.length):Rn.empty}domAtPos(t){return(this.length?0==t:this.side>0)?Ko.before(this.dom):Ko.after(this.dom,t==this.length)}domBoundsAround(){return null}coordsAt(t,e){let i=this.widget.coordsAt(this.dom,t,e);if(i)return i;let n=this.dom.getClientRects(),s=null;if(!n.length)return null;let o=this.side?this.side<0:t>0;for(let e=o?n.length-1:0;s=n[e],!(t>0?0==e:e==n.length-1||s.top<s.bottom);e+=o?-1:1);return jo(s,!o)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class br extends tr{constructor(t){super(),this.side=t}get length(){return 0}merge(){return!1}become(t){return t instanceof br&&t.side==this.side}split(){return new br(this.side)}sync(){if(!this.dom){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),this.setDOM(t)}}getSide(){return this.side}domAtPos(t){return this.side>0?Ko.before(this.dom):Ko.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){return this.dom.getBoundingClientRect()}get overrideDOMText(){return Rn.empty}get isHidden(){return!0}}function xr(t,e){let i=t.dom,{children:n}=t,s=0;for(let t=0;s<n.length;s++){let o=n[s],r=t+o.length;if(!(r==t&&o.getSide()<=0)){if(e>t&&e<r&&o.dom.parentNode==i)return o.domAtPos(e-t);if(e<=t)break;t=r}}for(let t=s;t>0;t--){let e=n[t-1];if(e.dom.parentNode==i)return e.domAtPos(e.length)}for(let t=s;t<n.length;t++){let e=n[t];if(e.dom.parentNode==i)return e.domAtPos(0)}return new Ko(i,0)}function wr(t,e,i){let n,{children:s}=t;i>0&&e instanceof yr&&s.length&&(n=s[s.length-1])instanceof yr&&n.mark.eq(e.mark)?wr(n,e.children[0],i-1):(s.push(e),e.setParent(t)),t.length+=e.length}function _r(t,e,i){let n=null,s=-1,o=null,r=-1;!function t(e,a){for(let l=0,c=0;l<e.children.length&&c<=a;l++){let h=e.children[l],u=c+h.length;u>=a&&(h.children.length?t(h,a-c):(!o||o.isHidden&&(i>0||Sr(o,h)))&&(u>a||c==u&&h.getSide()>0)?(o=h,r=a-c):(c<a||c==u&&h.getSide()<0&&!h.isHidden)&&(n=h,s=a-c)),c=u}}(t,e);let a=(i<0?n:o)||n||o;return a?a.coordsAt(Math.max(0,a==n?s:r),i):function(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let i=Qo(e);return i[i.length-1]||null}(t)}function Sr(t,e){let i=t.coordsAt(0,1),n=e.coordsAt(0,1);return i&&n&&n.top<i.bottom}function kr(t,e){for(let i in t)"class"==i&&e.class?e.class+=" "+t.class:"style"==i&&e.style?e.style+=";"+t.style:e[i]=t[i];return e}vr.prototype.children=Or.prototype.children=br.prototype.children=Jo;const $r=Object.create(null);function Cr(t,e,i){if(t==e)return!0;t||(t=$r),e||(e=$r);let n=Object.keys(t),s=Object.keys(e);if(n.length-(i&&n.indexOf(i)>-1?1:0)!=s.length-(i&&s.indexOf(i)>-1?1:0))return!1;for(let o of n)if(o!=i&&(-1==s.indexOf(o)||t[o]!==e[o]))return!1;return!0}function Tr(t,e,i){let n=!1;if(e)for(let s in e)i&&s in i||(n=!0,"style"==s?t.style.cssText="":t.removeAttribute(s));if(i)for(let s in i)e&&e[s]==i[s]||(n=!0,"style"==s?t.style.cssText=i[s]:t.setAttribute(s,i[s]));return n}function Pr(t){let e=Object.create(null);for(let i=0;i<t.attributes.length;i++){let n=t.attributes[i];e[n.name]=n.value}return e}class Er{eq(t){return!1}updateDOM(t,e){return!1}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(t){return!0}coordsAt(t,e,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(t){}}var Ar=function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t}(Ar||(Ar={}));class Mr extends Js{constructor(t,e,i,n){super(),this.startSide=t,this.endSide=e,this.widget=i,this.spec=n}get heightRelevant(){return!1}static mark(t){return new Qr(t)}static widget(t){let e=Math.max(-1e4,Math.min(1e4,t.side||0)),i=!!t.block;return e+=i&&!t.inlineOrder?e>0?3e8:-4e8:e>0?1e8:-1e8,new Rr(t,e,e,i,t.widget||null,!1)}static replace(t){let e,i,n=!!t.block;if(t.isBlockGap)e=-5e8,i=4e8;else{let{start:s,end:o}=Ir(t,n);e=(s?n?-3e8:-1:5e8)-1,i=1+(o?n?2e8:1:-6e8)}return new Rr(t,e,i,n,t.widget||null,!0)}static line(t){return new Dr(t)}static set(t,e=!1){return no.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}Mr.none=no.empty;class Qr extends Mr{constructor(t){let{start:e,end:i}=Ir(t);super(e?-1:5e8,i?1:-6e8,null,t),this.tagName=t.tagName||"span",this.class=t.class||"",this.attrs=t.attributes||null}eq(t){var e,i;return this==t||t instanceof Qr&&this.tagName==t.tagName&&(this.class||(null===(e=this.attrs)||void 0===e?void 0:e.class))==(t.class||(null===(i=t.attrs)||void 0===i?void 0:i.class))&&Cr(this.attrs,t.attrs,"class")}range(t,e=t){if(t>=e)throw new RangeError("Mark decorations may not be empty");return super.range(t,e)}}Qr.prototype.point=!1;class Dr extends Mr{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof Dr&&this.spec.class==t.spec.class&&Cr(this.spec.attributes,t.spec.attributes)}range(t,e=t){if(e!=t)throw new RangeError("Line decoration ranges must be zero-length");return super.range(t,e)}}Dr.prototype.mapMode=Un.TrackBefore,Dr.prototype.point=!0;class Rr extends Mr{constructor(t,e,i,n,s,o){super(e,i,s,t),this.block=n,this.isReplace=o,this.mapMode=n?e<=0?Un.TrackBefore:Un.TrackAfter:Un.TrackDel}get type(){return this.startSide!=this.endSide?Ar.WidgetRange:this.startSide<=0?Ar.WidgetBefore:Ar.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof Rr&&(e=this.widget,i=t.widget,e==i||!!(e&&i&&e.compare(i)))&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide;var e,i}range(t,e=t){if(this.isReplace&&(t>e||t==e&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&e!=t)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(t,e)}}function Ir(t,e=!1){let{inclusiveStart:i,inclusiveEnd:n}=t;return null==i&&(i=t.inclusive),null==n&&(n=t.inclusive),{start:null!=i?i:e,end:null!=n?n:e}}function Lr(t,e,i,n=0){let s=i.length-1;s>=0&&i[s]+n>=t?i[s]=Math.max(i[s],e):i.push(t,e)}Rr.prototype.point=!0;class Nr extends tr{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(t,e,i,n,s,o){if(i){if(!(i instanceof Nr))return!1;this.dom||i.transferDOM(this)}return n&&this.setDeco(i?i.attrs:null),sr(this,t,e,i?i.children.slice():[],s,o),!0}split(t){let e=new Nr;if(e.breakAfter=this.breakAfter,0==this.length)return e;let{i,off:n}=this.childPos(t);n&&(e.append(this.children[i].split(n),0),this.children[i].merge(n,this.children[i].length,null,!1,0,0),i++);for(let t=i;t<this.children.length;t++)e.append(this.children[t],0);for(;i>0&&0==this.children[i-1].length;)this.children[--i].destroy();return this.children.length=i,this.markDirty(),this.length=t,e}transferDOM(t){this.dom&&(this.markDirty(),t.setDOM(this.dom),t.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(t){Cr(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){wr(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=kr(e,this.attrs||{})),i&&(this.attrs=kr({class:i},this.attrs||{}))}domAtPos(t){return xr(this,t)}reuseDOM(t){"DIV"==t.nodeName&&(this.setDOM(t),this.flags|=6)}sync(t,e){var i;this.dom?4&this.flags&&(Vo(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),void 0!==this.prevAttrs&&(Tr(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(t,e);let n=this.dom.lastChild;for(;n&&tr.get(n)instanceof yr;)n=n.lastChild;if(!(n&&this.length&&("BR"==n.nodeName||0!=(null===(i=tr.get(n))||void 0===i?void 0:i.isEditable)||gr.ios&&this.children.some(t=>t instanceof vr)))){let t=document.createElement("BR");t.cmIgnore=!0,this.dom.appendChild(t)}}measureTextSize(){if(0==this.children.length||this.length>20)return null;let t,e=0;for(let i of this.children){if(!(i instanceof vr)||/[^ -~]/.test(i.text))return null;let n=Qo(i.dom);if(1!=n.length)return null;e+=n[0].width,t=n[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(t,e){let i=_r(this,t,e);if(!this.children.length&&i&&this.parent){let{heightOracle:t}=this.parent.view.viewState,e=i.bottom-i.top;if(Math.abs(e-t.lineHeight)<2&&t.textHeight<e){let n=(e-t.textHeight)/2;return{top:i.top+n,bottom:i.bottom-n,left:i.left,right:i.left}}}return i}become(t){return t instanceof Nr&&0==this.children.length&&0==t.children.length&&Cr(this.attrs,t.attrs)&&this.breakAfter==t.breakAfter}covers(){return!0}static find(t,e){for(let i=0,n=0;i<t.children.length;i++){let s=t.children[i],o=n+s.length;if(o>=e){if(s instanceof Nr)return s;if(o>e)break}n=o+s.breakAfter}return null}}class jr extends tr{constructor(t,e,i){super(),this.widget=t,this.length=e,this.deco=i,this.breakAfter=0,this.prevWidget=null}merge(t,e,i,n,s,o){return!(i&&(!(i instanceof jr&&this.widget.compare(i.widget))||t>0&&s<=0||e<this.length&&o<=0))&&(this.length=t+(i?i.length:0)+(this.length-e),!0)}domAtPos(t){return 0==t?Ko.before(this.dom):Ko.after(this.dom,t==this.length)}split(t){let e=this.length-t;this.length=t;let i=new jr(this.widget,e,this.deco);return i.breakAfter=this.breakAfter,i}get children(){return Jo}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.widget.editable||(this.dom.contentEditable="false"))}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):Rn.empty}domBoundsAround(){return null}become(t){return t instanceof jr&&t.widget.constructor==this.widget.constructor&&(t.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,this.deco=t.deco,this.breakAfter=t.breakAfter,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(t,e){let i=this.widget.coordsAt(this.dom,t,e);return i||(this.widget instanceof zr?null:jo(this.dom.getBoundingClientRect(),this.length?0==t:e<=0))}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(t){let{startSide:e,endSide:i}=this.deco;return e!=i&&(t<0?e<0:i>0)}}class zr extends Er{constructor(t){super(),this.height=t}toDOM(){let t=document.createElement("div");return t.className="cm-gap",this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}class Br{constructor(t,e,i,n){this.doc=t,this.pos=e,this.end=i,this.disallowBlockEffectsFor=n,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=t.iter(),this.skip=e}posCovered(){if(0==this.content.length)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let t=this.content[this.content.length-1];return!(t.breakAfter||t instanceof jr&&t.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new Nr),this.atCursorPos=!0),this.curLine}flushBuffer(t=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(qr(new br(-1),t),t.length),this.pendingBuffer=0)}addBlockWidget(t){this.flushBuffer(),this.curLine=null,this.content.push(t)}finish(t){this.pendingBuffer&&t<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,this.posCovered()||t&&this.content.length&&this.content[this.content.length-1]instanceof jr||this.getLine()}buildText(t,e,i){for(;t>0;){if(this.textOff==this.text.length){let{value:e,lineBreak:i,done:n}=this.cursor.next(this.skip);if(this.skip=0,n)throw new Error("Ran out of text content when drawing inline views");if(i){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,t--;continue}this.text=e,this.textOff=0}let n=Math.min(this.text.length-this.textOff,t,512);this.flushBuffer(e.slice(e.length-i)),this.getLine().append(qr(new vr(this.text.slice(this.textOff,this.textOff+n)),e),i),this.atCursorPos=!0,this.textOff+=n,t-=n,i=0}}span(t,e,i,n){this.buildText(e-t,i,n),this.pos=e,this.openStart<0&&(this.openStart=n)}point(t,e,i,n,s,o){if(this.disallowBlockEffectsFor[o]&&i instanceof Rr){if(i.block)throw new RangeError("Block decorations may not be specified via plugins");if(e>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let r=e-t;if(i instanceof Rr)if(i.block)i.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new jr(i.widget||Zr.block,r,i));else{let o=Or.create(i.widget||Zr.inline,r,r?0:i.startSide),a=this.atCursorPos&&!o.isEditable&&s<=n.length&&(t<e||i.startSide>0),l=!o.isEditable&&(t<e||s>n.length||i.startSide<=0),c=this.getLine();2!=this.pendingBuffer||a||o.isEditable||(this.pendingBuffer=0),this.flushBuffer(n),a&&(c.append(qr(new br(1),n),s),s=n.length+Math.max(0,s-n.length)),c.append(qr(o,n),s),this.atCursorPos=l,this.pendingBuffer=l?t<e||s>n.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=n.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);r&&(this.textOff+r<=this.text.length?this.textOff+=r:(this.skip+=r-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=e),this.openStart<0&&(this.openStart=s)}static build(t,e,i,n,s){let o=new Br(t,e,i,s);return o.openEnd=no.spans(n,e,i,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}}function qr(t,e){for(let i of e)t=new yr(i,[t],t.length);return t}class Zr extends Er{constructor(t){super(),this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}Zr.inline=new Zr("span"),Zr.block=new Zr("div");var Fr=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(Fr||(Fr={}));const Xr=Fr.LTR,Hr=Fr.RTL;function Wr(t){let e=[];for(let i=0;i<t.length;i++)e.push(1<<+t[i]);return e}const Vr=Wr("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Yr=Wr("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Ur=Object.create(null),Gr=[];for(let t of["()","[]","{}"]){let e=t.charCodeAt(0),i=t.charCodeAt(1);Ur[e]=i,Ur[i]=-e}function Kr(t){return t<=247?Vr[t]:1424<=t&&t<=1524?2:1536<=t&&t<=1785?Yr[t-1536]:1774<=t&&t<=2220?4:8192<=t&&t<=8204?256:64336<=t&&t<=65023?4:1}const Jr=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class ta{get dir(){return this.level%2?Hr:Xr}constructor(t,e,i){this.from=t,this.to=e,this.level=i}side(t,e){return this.dir==e==t?this.to:this.from}forward(t,e){return t==(this.dir==e)}static find(t,e,i,n){let s=-1;for(let o=0;o<t.length;o++){let r=t[o];if(r.from<=e&&r.to>=e){if(r.level==i)return o;(s<0||(0!=n?n<0?r.from<e:r.to>e:t[s].level>r.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}}function ea(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let n=t[i],s=e[i];if(n.from!=s.from||n.to!=s.to||n.direction!=s.direction||!ea(n.inner,s.inner))return!1}return!0}const ia=[];function na(t,e,i,n,s,o,r){let a=n%2?2:1;if(n%2==s%2)for(let l=e,c=0;l<i;){let e=!0,h=!1;if(c==o.length||l<o[c].from){let t=ia[l];t!=a&&(e=!1,h=16==t)}let u=e||1!=a?null:[],d=e?n:n+1,f=l;t:for(;;)if(c<o.length&&f==o[c].from){if(h)break t;let p=o[c];if(!e)for(let t=p.to,e=c+1;;){if(t==i)break t;if(!(e<o.length&&o[e].from==t)){if(ia[t]==a)break t;break}t=o[e++].to}if(c++,u)u.push(p);else{p.from>l&&r.push(new ta(l,p.from,d)),sa(t,p.direction==Xr!=!(d%2)?n+1:n,s,p.inner,p.from,p.to,r),l=p.to}f=p.to}else{if(f==i||(e?ia[f]!=a:ia[f]==a))break;f++}u?na(t,l,f,n+1,s,u,r):l<f&&r.push(new ta(l,f,d)),l=f}else for(let l=i,c=o.length;l>e;){let i=!0,h=!1;if(!c||l>o[c-1].to){let t=ia[l-1];t!=a&&(i=!1,h=16==t)}let u=i||1!=a?null:[],d=i?n:n+1,f=l;t:for(;;)if(c&&f==o[c-1].to){if(h)break t;let p=o[--c];if(!i)for(let t=p.from,i=c;;){if(t==e)break t;if(!i||o[i-1].to!=t){if(ia[t-1]==a)break t;break}t=o[--i].from}if(u)u.push(p);else{p.to<l&&r.push(new ta(p.to,l,d)),sa(t,p.direction==Xr!=!(d%2)?n+1:n,s,p.inner,p.from,p.to,r),l=p.from}f=p.from}else{if(f==e||(i?ia[f-1]!=a:ia[f-1]==a))break;f--}u?na(t,f,l,n+1,s,u,r):f<l&&r.push(new ta(f,l,d)),l=f}}function sa(t,e,i,n,s,o,r){let a=e%2?2:1;!function(t,e,i,n,s){for(let o=0;o<=n.length;o++){let r=o?n[o-1].to:e,a=o<n.length?n[o].from:i,l=o?256:s;for(let e=r,i=l,n=l;e<a;e++){let s=Kr(t.charCodeAt(e));512==s?s=i:8==s&&4==n&&(s=16),ia[e]=4==s?2:s,7&s&&(n=s),i=s}for(let t=r,e=l,n=l;t<a;t++){let s=ia[t];if(128==s)t<a-1&&e==ia[t+1]&&24&e?s=ia[t]=e:ia[t]=256;else if(64==s){let s=t+1;for(;s<a&&64==ia[s];)s++;let o=t&&8==e||s<i&&8==ia[s]?1==n?1:8:256;for(let e=t;e<s;e++)ia[e]=o;t=s-1}else 8==s&&1==n&&(ia[t]=1);e=s,7&s&&(n=s)}}}(t,s,o,n,a),function(t,e,i,n,s){let o=1==s?2:1;for(let r=0,a=0,l=0;r<=n.length;r++){let c=r?n[r-1].to:e,h=r<n.length?n[r].from:i;for(let e,i,n,r=c;r<h;r++)if(i=Ur[e=t.charCodeAt(r)])if(i<0){for(let t=a-3;t>=0;t-=3)if(Gr[t+1]==-i){let e=Gr[t+2],i=2&e?s:4&e?1&e?o:s:0;i&&(ia[r]=ia[Gr[t]]=i),a=t;break}}else{if(189==Gr.length)break;Gr[a++]=r,Gr[a++]=e,Gr[a++]=l}else if(2==(n=ia[r])||1==n){let t=n==s;l=t?0:1;for(let e=a-3;e>=0;e-=3){let i=Gr[e+2];if(2&i)break;if(t)Gr[e+2]|=2;else{if(4&i)break;Gr[e+2]|=4}}}}}(t,s,o,n,a),function(t,e,i,n){for(let s=0,o=n;s<=i.length;s++){let r=s?i[s-1].to:t,a=s<i.length?i[s].from:e;for(let l=r;l<a;){let r=ia[l];if(256==r){let r=l+1;for(;;)if(r==a){if(s==i.length)break;r=i[s++].to,a=s<i.length?i[s].from:e}else{if(256!=ia[r])break;r++}let c=1==o,h=c==(1==(r<e?ia[r]:n))?c?1:2:n;for(let e=r,n=s,o=n?i[n-1].to:t;e>l;)e==o&&(e=i[--n].from,o=n?i[n-1].to:t),ia[--e]=h;l=r}else o=r,l++}}}(s,o,n,a),na(t,s,o,e,i,n,r)}function oa(t,e,i){if(!t)return[new ta(0,0,e==Hr?1:0)];if(e==Xr&&!i.length&&!Jr.test(t))return ra(t.length);if(i.length)for(;t.length>ia.length;)ia[ia.length]=256;let n=[],s=e==Xr?0:1;return sa(t,s,s,i,0,t.length,n),n}function ra(t){return[new ta(0,t,0)]}let aa="";function la(t,e,i,n,s){var o;let r=n.head-t.from,a=ta.find(e,r,null!==(o=n.bidiLevel)&&void 0!==o?o:-1,n.assoc),l=e[a],c=l.side(s,i);if(r==c){let t=a+=s?1:-1;if(t<0||t>=e.length)return null;l=e[a=t],r=l.side(!s,i),c=l.side(s,i)}let h=Xn(t.text,r,l.forward(s,i));(h<l.from||h>l.to)&&(h=c),aa=t.text.slice(Math.min(r,h),Math.max(r,h));let u=a==(s?e.length-1:0)?null:e[a+(s?1:-1)];return u&&h==c&&u.level+(s?0:1)<l.level?rs.cursor(u.side(!s,i)+t.from,u.forward(s,i)?1:-1,u.level):rs.cursor(h+t.from,l.forward(s,i)?-1:1,l.level)}function ca(t,e,i){for(let n=e;n<i;n++){let e=Kr(t.charCodeAt(n));if(1==e)return Xr;if(2==e||4==e)return Hr}return Xr}const ha=cs.define(),ua=cs.define(),da=cs.define(),fa=cs.define(),pa=cs.define(),ma=cs.define(),ga=cs.define(),va=cs.define(),ya=cs.define(),Oa=cs.define({combine:t=>t.some(t=>t)}),ba=cs.define({combine:t=>t.some(t=>t)}),xa=cs.define();class wa{constructor(t,e="nearest",i="nearest",n=5,s=5,o=!1){this.range=t,this.y=e,this.x=i,this.yMargin=n,this.xMargin=s,this.isSnapshot=o}map(t){return t.empty?this:new wa(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new wa(rs.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const _a=js.define({map:(t,e)=>t.map(e)}),Sa=js.define();function ka(t,e,i){let n=t.facet(fa);n.length?n[0](e):window.onerror&&window.onerror(String(e),i,void 0,void 0,e)||(i?console.error(i+":",e):console.error(e))}const $a=cs.define({combine:t=>!t.length||t[0]});let Ca=0;const Ta=cs.define({combine:t=>t.filter((e,i)=>{for(let n=0;n<i;n++)if(t[n].plugin==e.plugin)return!1;return!0})});class Pa{constructor(t,e,i,n,s){this.id=t,this.create=e,this.domEventHandlers=i,this.domEventObservers=n,this.baseExtensions=s(this),this.extension=this.baseExtensions.concat(Ta.of({plugin:this,arg:void 0}))}of(t){return this.baseExtensions.concat(Ta.of({plugin:this,arg:t}))}static define(t,e){const{eventHandlers:i,eventObservers:n,provide:s,decorations:o}=e||{};return new Pa(Ca++,t,i,n,t=>{let e=[];return o&&e.push(Qa.of(e=>{let i=e.plugin(t);return i?o(i):Mr.none})),s&&e.push(s(t)),e})}static fromClass(t,e){return Pa.define((e,i)=>new t(e,i),e)}}class Ea{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(t){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(e){if(ka(t.state,e,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(t){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(t,this.spec.arg)}catch(e){ka(t.state,e,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(t){var e;if(null===(e=this.value)||void 0===e?void 0:e.destroy)try{this.value.destroy()}catch(e){ka(t.state,e,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const Aa=cs.define(),Ma=cs.define(),Qa=cs.define(),Da=cs.define(),Ra=cs.define(),Ia=cs.define();function La(t,e){let i=t.state.facet(Ia);if(!i.length)return i;let n=i.map(e=>e instanceof Function?e(t):e),s=[];return no.spans(n,e.from,e.to,{point(){},span(t,i,n,o){let r=t-e.from,a=i-e.from,l=s;for(let t=n.length-1;t>=0;t--,o--){let i,s=n[t].spec.bidiIsolate;if(null==s&&(s=ca(e.text,r,a)),o>0&&l.length&&(i=l[l.length-1]).to==r&&i.direction==s)i.to=a,l=i.inner;else{let t={from:r,to:a,direction:s,inner:[]};l.push(t),l=t.inner}}}}),s}const Na=cs.define();function ja(t){let e=0,i=0,n=0,s=0;for(let o of t.state.facet(Na)){let r=o(t);r&&(null!=r.left&&(e=Math.max(e,r.left)),null!=r.right&&(i=Math.max(i,r.right)),null!=r.top&&(n=Math.max(n,r.top)),null!=r.bottom&&(s=Math.max(s,r.bottom)))}return{left:e,right:i,top:n,bottom:s}}const za=cs.define();class Ba{constructor(t,e,i,n){this.fromA=t,this.toA=e,this.fromB=i,this.toB=n}join(t){return new Ba(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,i=this;for(;e>0;e--){let n=t[e-1];if(!(n.fromA>i.toA)){if(n.toA<i.fromA)break;i=i.join(n),t.splice(e-1,1)}}return t.splice(e,0,i),t}static extendWithRanges(t,e){if(0==e.length)return t;let i=[];for(let n=0,s=0,o=0,r=0;;n++){let a=n==t.length?null:t[n],l=o-r,c=a?a.fromB:1e9;for(;s<e.length&&e[s]<c;){let t=e[s],n=e[s+1],o=Math.max(r,t),a=Math.min(c,n);if(o<=a&&new Ba(o+l,a+l,o,a).addToSet(i),n>c)break;s+=2}if(!a)return i;new Ba(a.fromA,a.toA,a.fromB,a.toB).addToSet(i),o=a.toA,r=a.toB}}}class qa{constructor(t,e,i){this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=Kn.empty(this.startState.doc.length);for(let t of i)this.changes=this.changes.compose(t.changes);let n=[];this.changes.iterChangedRanges((t,e,i,s)=>n.push(new Ba(t,e,i,s))),this.changedRanges=n}static create(t,e,i){return new qa(t,e,i)}get viewportChanged(){return(4&this.flags)>0}get viewportMoved(){return(8&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(18&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(t=>t.selection)}get empty(){return 0==this.flags&&0==this.transactions.length}}class Za extends tr{get length(){return this.view.state.doc.length}constructor(t){super(),this.view=t,this.decorations=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.editContextFormatting=Mr.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(t.contentDOM),this.children=[new Nr],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new Ba(0,0,0,t.state.doc.length)],0,null)}update(t){var e;let i=t.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:t,toA:e})=>e<this.minWidthFrom||t>this.minWidthTo)?(this.minWidthFrom=t.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=t.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(t);let n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&((null===(e=this.domChanged)||void 0===e?void 0:e.newSel)?n=this.domChanged.newSel.head:function(t,e){let i=!1;e&&t.iterChangedRanges((t,n)=>{t<e.to&&n>e.from&&(i=!0)});return i}(t.changes,this.hasComposition)||t.selectionSet||(n=t.state.selection.main.head));let s=n>-1?function(t,e,i){let n=Fa(t,i);if(!n)return null;let{node:s,from:o,to:r}=n,a=s.nodeValue;if(/[\n\r]/.test(a))return null;if(t.state.doc.sliceString(n.from,n.to)!=a)return null;let l=e.invertedDesc,c=new Ba(l.mapPos(o),l.mapPos(r),o,r),h=[];for(let e=s.parentNode;;e=e.parentNode){let i=tr.get(e);if(i instanceof yr)h.push({node:e,deco:i.mark});else{if(i instanceof Nr||"DIV"==e.nodeName&&e.parentNode==t.contentDOM)return{range:c,text:s,marks:h,line:e};if(e==t.contentDOM)return null;h.push({node:e,deco:new Qr({inclusive:!0,attributes:Pr(e),tagName:e.tagName.toLowerCase()})})}}}(this.view,t.changes,n):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:e,to:n}=this.hasComposition;i=new Ba(e,n,t.changes.mapPos(e,-1),t.changes.mapPos(n,1)).addToSet(i.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(gr.ie||gr.chrome)&&!s&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let o=function(t,e,i){let n=new Xa;return no.compare(t,e,i,n),n.changes}(this.decorations,this.updateDeco(),t.changes);return i=Ba.extendWithRanges(i,o),!!(7&this.flags||0!=i.length)&&(this.updateInner(i,t.startState.doc.length,s),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,e,i){this.view.viewState.mustMeasureContent=!0,this.updateChildren(t,e,i);let{observer:n}=this.view;n.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let t=gr.chrome||gr.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,t),this.flags&=-8,t&&(t.written||n.selectionRange.focusNode!=t.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(t=>t.flags&=-9);let s=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let t of this.children)t instanceof jr&&t.widget instanceof zr&&s.push(t.dom);n.updateGaps(s)}updateChildren(t,e,i){let n=i?i.range.addToSet(t.slice()):t,s=this.childCursor(e);for(let t=n.length-1;;t--){let e=t>=0?n[t]:null;if(!e)break;let o,r,a,l,{fromA:c,toA:h,fromB:u,toB:d}=e;if(i&&i.range.fromB<d&&i.range.toB>u){let t=Br.build(this.view.state.doc,u,i.range.fromB,this.decorations,this.dynamicDecorationMap),e=Br.build(this.view.state.doc,i.range.toB,d,this.decorations,this.dynamicDecorationMap);r=t.breakAtStart,a=t.openStart,l=e.openEnd;let n=this.compositionView(i);e.breakAtStart?n.breakAfter=1:e.content.length&&n.merge(n.length,n.length,e.content[0],!1,e.openStart,0)&&(n.breakAfter=e.content[0].breakAfter,e.content.shift()),t.content.length&&n.merge(0,0,t.content[t.content.length-1],!0,0,t.openEnd)&&t.content.pop(),o=t.content.concat(n).concat(e.content)}else({content:o,breakAtStart:r,openStart:a,openEnd:l}=Br.build(this.view.state.doc,u,d,this.decorations,this.dynamicDecorationMap));let{i:f,off:p}=s.findPos(h,1),{i:m,off:g}=s.findPos(c,-1);nr(this,m,g,f,p,o,r,a,l)}i&&this.fixCompositionDOM(i)}updateEditContextFormatting(t){this.editContextFormatting=this.editContextFormatting.map(t.changes);for(let e of t.transactions)for(let t of e.effects)t.is(Sa)&&(this.editContextFormatting=t.value)}compositionView(t){let e=new vr(t.text.nodeValue);e.flags|=8;for(let{deco:i}of t.marks)e=new yr(i,[e],e.length);let i=new Nr;return i.append(e,0),i}fixCompositionDOM(t){let e=(t,e)=>{e.flags|=8|(e.children.some(t=>7&t.flags)?1:0),this.markedForComposition.add(e);let i=tr.get(t);i&&i!=e&&(i.dom=null),e.setDOM(t)},i=this.childPos(t.range.fromB,1),n=this.children[i.i];e(t.line,n);for(let s=t.marks.length-1;s>=-1;s--)i=n.childPos(i.off,1),n=n.children[i.i],e(s>=0?t.marks[s].node:t.text,n)}updateSelection(t=!1,e=!1){!t&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let i=this.view.root.activeElement,n=i==this.dom,s=!n&&!(this.view.state.facet($a)||this.dom.tabIndex>-1)&&Mo(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(n||e||s))return;let o=this.forceSelection;this.forceSelection=!1;let r=this.view.state.selection.main,a=this.moveToLine(this.domAtPos(r.anchor)),l=r.empty?a:this.moveToLine(this.domAtPos(r.head));if(gr.gecko&&r.empty&&!this.hasComposition&&(1==(c=a).node.nodeType&&c.node.firstChild&&(0==c.offset||"false"==c.node.childNodes[c.offset-1].contentEditable)&&(c.offset==c.node.childNodes.length||"false"==c.node.childNodes[c.offset].contentEditable))){let t=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(t,a.node.childNodes[a.offset]||null)),a=l=new Ko(t,0),o=!0}var c;let h=this.view.observer.selectionRange;!o&&h.focusNode&&(Do(a.node,a.offset,h.anchorNode,h.anchorOffset)&&Do(l.node,l.offset,h.focusNode,h.focusOffset)||this.suppressWidgetCursorChange(h,r))||(this.view.observer.ignore(()=>{gr.android&&gr.chrome&&this.dom.contains(h.focusNode)&&function(t,e){for(let i=t;i&&i!=e;i=i.assignedSlot||i.parentNode)if(1==i.nodeType&&"false"==i.contentEditable)return!0;return!1}(h.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let t=Eo(this.view.root);if(t)if(r.empty){if(gr.gecko){let t=(e=a.node,n=a.offset,1!=e.nodeType?0:(n&&"false"==e.childNodes[n-1].contentEditable?1:0)|(n<e.childNodes.length&&"false"==e.childNodes[n].contentEditable?2:0));if(t&&3!=t){let e=(1==t?Uo:Go)(a.node,a.offset);e&&(a=new Ko(e.node,e.offset))}}t.collapse(a.node,a.offset),null!=r.bidiLevel&&void 0!==t.caretBidiLevel&&(t.caretBidiLevel=r.bidiLevel)}else if(t.extend){t.collapse(a.node,a.offset);try{t.extend(l.node,l.offset)}catch(t){}}else{let e=document.createRange();r.anchor>r.head&&([a,l]=[l,a]),e.setEnd(l.node,l.offset),e.setStart(a.node,a.offset),t.removeAllRanges(),t.addRange(e)}else;var e,n;s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(a,l)),this.impreciseAnchor=a.precise?null:new Ko(h.anchorNode,h.anchorOffset),this.impreciseHead=l.precise?null:new Ko(h.focusNode,h.focusOffset)}suppressWidgetCursorChange(t,e){return this.hasComposition&&e.empty&&Do(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)&&this.posFromDOM(t.focusNode,t.focusOffset)==e.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:t}=this,e=t.state.selection.main,i=Eo(t.root),{anchorNode:n,anchorOffset:s}=t.observer.selectionRange;if(!(i&&e.empty&&e.assoc&&i.modify))return;let o=Nr.find(this,e.head);if(!o)return;let r=o.posAtStart;if(e.head==r||e.head==r+o.length)return;let a=this.coordsAt(e.head,-1),l=this.coordsAt(e.head,1);if(!a||!l||a.bottom>l.top)return;let c=this.domAtPos(e.head+e.assoc);i.collapse(c.node,c.offset),i.modify("move",e.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let h=t.observer.selectionRange;t.docView.posFromDOM(h.anchorNode,h.anchorOffset)!=e.from&&i.collapse(n,s)}moveToLine(t){let e,i=this.dom;if(t.node!=i)return t;for(let n=t.offset;!e&&n<i.childNodes.length;n++){let t=tr.get(i.childNodes[n]);t instanceof Nr&&(e=t.domAtPos(0))}for(let n=t.offset-1;!e&&n>=0;n--){let t=tr.get(i.childNodes[n]);t instanceof Nr&&(e=t.domAtPos(t.length))}return e?new Ko(e.node,e.offset,!0):t}nearest(t){for(let e=t;e;){let t=tr.get(e);if(t&&t.rootView==this)return t;e=e.parentNode}return null}posFromDOM(t,e){let i=this.nearest(t);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(t,e)+i.posAtStart}domAtPos(t){let{i:e,off:i}=this.childCursor().findPos(t,-1);for(;e<this.children.length-1;){let t=this.children[e];if(i<t.length||t instanceof Nr)break;e++,i=0}return this.children[e].domAtPos(i)}coordsAt(t,e){let i=null,n=0;for(let s=this.length,o=this.children.length-1;o>=0;o--){let r=this.children[o],a=s-r.breakAfter,l=a-r.length;if(a<t)break;if(l<=t&&(l<t||r.covers(-1))&&(a>t||r.covers(1))&&(!i||r instanceof Nr&&!(i instanceof Nr&&e>=0)))i=r,n=l;else if(i&&l==t&&a==t&&r instanceof jr&&Math.abs(e)<2){if(r.deco.startSide<0)break;o&&(i=null)}s=l}return i?i.coordsAt(t-n,e):null}coordsForChar(t){let{i:e,off:i}=this.childPos(t,1),n=this.children[e];if(!(n instanceof Nr))return null;for(;n.children.length;){let{i:t,off:e}=n.childPos(i,1);for(;;t++){if(t==n.children.length)return null;if((n=n.children[t]).length)break}i=e}if(!(n instanceof vr))return null;let s=Xn(n.text,i);if(s==i)return null;let o=Ho(n.dom,i,s).getClientRects();for(let t=0;t<o.length;t++){let e=o[t];if(t==o.length-1||e.top<e.bottom&&e.left<e.right)return e}return null}measureVisibleLineHeights(t){let e=[],{from:i,to:n}=t,s=this.view.contentDOM.clientWidth,o=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,r=-1,a=this.view.textDirection==Fr.LTR;for(let t=0,l=0;l<this.children.length;l++){let c=this.children[l],h=t+c.length;if(h>n)break;if(t>=i){let i=c.dom.getBoundingClientRect();if(e.push(i.height),o){let e=c.dom.lastChild,n=e?Qo(e):[];if(n.length){let e=n[n.length-1],o=a?e.right-i.left:i.right-e.left;o>r&&(r=o,this.minWidth=s,this.minWidthFrom=t,this.minWidthTo=h)}}}t=h+c.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return"rtl"==getComputedStyle(this.children[e].dom).direction?Fr.RTL:Fr.LTR}measureTextSize(){for(let t of this.children)if(t instanceof Nr){let e=t.measureTextSize();if(e)return e}let t,e,i,n=document.createElement("div");return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(n);let s=Qo(n.firstChild)[0];t=n.getBoundingClientRect().height,e=s?s.width/27:7,i=s?s.height:t,n.remove()}),{lineHeight:t,charWidth:e,textHeight:i}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new ir(this.children,t,e)}computeBlockGapDeco(){let t=[],e=this.view.viewState;for(let i=0,n=0;;n++){let s=n==e.viewports.length?null:e.viewports[n],o=s?s.from-1:this.length;if(o>i){let n=(e.lineBlockAt(o).bottom-e.lineBlockAt(i).top)/this.view.scaleY;t.push(Mr.replace({widget:new zr(n),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!s)break;i=s.to+1}return Mr.set(t)}updateDeco(){let t=1,e=this.view.state.facet(Qa).map(e=>(this.dynamicDecorationMap[t++]="function"==typeof e)?e(this.view):e),i=!1,n=this.view.state.facet(Da).map((t,e)=>{let n="function"==typeof t;return n&&(i=!0),n?t(this.view):t});for(n.length&&(this.dynamicDecorationMap[t++]=i,e.push(no.join(n))),this.decorations=[this.editContextFormatting,...e,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];t<this.decorations.length;)this.dynamicDecorationMap[t++]=!1;return this.decorations}scrollIntoView(t){if(t.isSnapshot){let e=this.view.viewState.lineBlockAt(t.range.head);return this.view.scrollDOM.scrollTop=e.top-t.yMargin,void(this.view.scrollDOM.scrollLeft=t.xMargin)}for(let e of this.view.state.facet(xa))try{if(e(this.view,t.range,t))return!0}catch(t){ka(this.view.state,t,"scroll handler")}let e,{range:i}=t,n=this.coordsAt(i.head,i.empty?i.assoc:i.head>i.anchor?-1:1);if(!n)return;!i.empty&&(e=this.coordsAt(i.anchor,i.anchor>i.head?-1:1))&&(n={left:Math.min(n.left,e.left),top:Math.min(n.top,e.top),right:Math.max(n.right,e.right),bottom:Math.max(n.bottom,e.bottom)});let s=ja(this.view),o={left:n.left-s.left,top:n.top-s.top,right:n.right+s.right,bottom:n.bottom+s.bottom},{offsetWidth:r,offsetHeight:a}=this.view.scrollDOM;!function(t,e,i,n,s,o,r,a){let l=t.ownerDocument,c=l.defaultView||window;for(let h=t,u=!1;h&&!u;)if(1==h.nodeType){let t,d=h==l.body,f=1,p=1;if(d)t=zo(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(h).position)&&(u=!0),h.scrollHeight<=h.clientHeight&&h.scrollWidth<=h.clientWidth){h=h.assignedSlot||h.parentNode;continue}let e=h.getBoundingClientRect();({scaleX:f,scaleY:p}=Bo(h,e)),t={left:e.left,right:e.left+h.clientWidth*f,top:e.top,bottom:e.top+h.clientHeight*p}}let m=0,g=0;if("nearest"==s)e.top<t.top?(g=e.top-(t.top+r),i>0&&e.bottom>t.bottom+g&&(g=e.bottom-t.bottom+r)):e.bottom>t.bottom&&(g=e.bottom-t.bottom+r,i<0&&e.top-g<t.top&&(g=e.top-(t.top+r)));else{let n=e.bottom-e.top,o=t.bottom-t.top;g=("center"==s&&n<=o?e.top+n/2-o/2:"start"==s||"center"==s&&i<0?e.top-r:e.bottom-o+r)-t.top}if("nearest"==n?e.left<t.left?(m=e.left-(t.left+o),i>0&&e.right>t.right+m&&(m=e.right-t.right+o)):e.right>t.right&&(m=e.right-t.right+o,i<0&&e.left<t.left+m&&(m=e.left-(t.left+o))):m=("center"==n?e.left+(e.right-e.left)/2-(t.right-t.left)/2:"start"==n==a?e.left-o:e.right-(t.right-t.left)+o)-t.left,m||g)if(d)c.scrollBy(m,g);else{let t=0,i=0;if(g){let t=h.scrollTop;h.scrollTop+=g/p,i=(h.scrollTop-t)*p}if(m){let e=h.scrollLeft;h.scrollLeft+=m/f,t=(h.scrollLeft-e)*f}e={left:e.left-t,top:e.top-i,right:e.right-t,bottom:e.bottom-i},t&&Math.abs(t-m)<1&&(n="nearest"),i&&Math.abs(i-g)<1&&(s="nearest")}if(d)break;(e.top<t.top||e.bottom>t.bottom||e.left<t.left||e.right>t.right)&&(e={left:Math.max(e.left,t.left),right:Math.min(e.right,t.right),top:Math.max(e.top,t.top),bottom:Math.min(e.bottom,t.bottom)}),h=h.assignedSlot||h.parentNode}else{if(11!=h.nodeType)break;h=h.host}}(this.view.scrollDOM,o,i.head<i.anchor?-1:1,t.x,t.y,Math.max(Math.min(t.xMargin,r),-r),Math.max(Math.min(t.yMargin,a),-a),this.view.textDirection==Fr.LTR)}}function Fa(t,e){let i=t.observer.selectionRange;if(!i.focusNode)return null;let n=Uo(i.focusNode,i.focusOffset),s=Go(i.focusNode,i.focusOffset),o=n||s;if(s&&n&&s.node!=n.node){let e=tr.get(s.node);if(!e||e instanceof vr&&e.text!=s.node.nodeValue)o=s;else if(t.docView.lastCompositionAfterCursor){let t=tr.get(n.node);!t||t instanceof vr&&t.text!=n.node.nodeValue||(o=s)}}if(t.docView.lastCompositionAfterCursor=o!=n,!o)return null;let r=e-o.offset;return{from:r,to:r+o.node.nodeValue.length,node:o.node}}let Xa=class{constructor(){this.changes=[]}compareRange(t,e){Lr(t,e,this.changes)}comparePoint(t,e){Lr(t,e,this.changes)}boundChange(t){Lr(t,t,this.changes)}};function Ha(t,e){return e.left>t?e.left-t:Math.max(0,t-e.right)}function Wa(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function Va(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function Ya(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function Ua(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function Ga(t,e,i){let n,s,o,r,a,l,c,h,u=!1;for(let d=t.firstChild;d;d=d.nextSibling){let t=Qo(d);for(let f=0;f<t.length;f++){let p=t[f];s&&Va(s,p)&&(p=Ya(Ua(p,s.bottom),s.top));let m=Ha(e,p),g=Wa(i,p);if(0==m&&0==g)return 3==d.nodeType?Ka(d,e,i):Ga(d,e,i);(!n||r>g||r==g&&o>m)&&(n=d,s=p,o=m,r=g,u=!m||(e<p.left?f>0:f<t.length-1)),0==m?i>p.bottom&&(!c||c.bottom<p.bottom)?(a=d,c=p):i<p.top&&(!h||h.top>p.top)&&(l=d,h=p):c&&Va(c,p)?c=Ua(c,p.bottom):h&&Va(h,p)&&(h=Ya(h,p.top))}}if(c&&c.bottom>=i?(n=a,s=c):h&&h.top<=i&&(n=l,s=h),!n)return{node:t,offset:0};let d=Math.max(s.left,Math.min(s.right,e));return 3==n.nodeType?Ka(n,d,i):u&&"false"!=n.contentEditable?Ga(n,d,i):{node:t,offset:Array.prototype.indexOf.call(t.childNodes,n)+(e>=(s.left+s.right)/2?1:0)}}function Ka(t,e,i){let n=t.nodeValue.length,s=-1,o=1e9,r=0;for(let a=0;a<n;a++){let n=Ho(t,a,a+1).getClientRects();for(let l=0;l<n.length;l++){let c=n[l];if(c.top==c.bottom)continue;r||(r=e-c.left);let h=(c.top>i?c.top-i:i-c.bottom)-1;if(c.left-1<=e&&c.right+1>=e&&h<o){let i=e>=(c.left+c.right)/2,n=i;if(gr.chrome||gr.gecko){Ho(t,a).getBoundingClientRect().left==c.right&&(n=!i)}if(h<=0)return{node:t,offset:a+(n?1:0)};s=a+(n?1:0),o=h}}}return{node:t,offset:s>-1?s:r>0?t.nodeValue.length:0}}function Ja(t,e,i,n=-1){var s,o;let r,a=t.contentDOM.getBoundingClientRect(),l=a.top+t.viewState.paddingTop,{docHeight:c}=t.viewState,{x:h,y:u}=e,d=u-l;if(d<0)return 0;if(d>c)return t.state.doc.length;for(let e=t.viewState.heightOracle.textHeight/2,s=!1;r=t.elementAtHeight(d),r.type!=Ar.Text;)for(;d=n>0?r.bottom+e:r.top-e,!(d>=0&&d<=c);){if(s)return i?null:0;s=!0,n=-n}u=l+d;let f=r.from;if(f<t.viewport.from)return 0==t.viewport.from?0:i?null:tl(t,a,r,h,u);if(f>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:i?null:tl(t,a,r,h,u);let p=t.dom.ownerDocument,m=t.root.elementFromPoint?t.root:p,g=m.elementFromPoint(h,u);g&&!t.contentDOM.contains(g)&&(g=null),g||(h=Math.max(a.left+1,Math.min(a.right-1,h)),g=m.elementFromPoint(h,u),g&&!t.contentDOM.contains(g)&&(g=null));let v,y=-1;if(g&&0!=(null===(s=t.docView.nearest(g))||void 0===s?void 0:s.isEditable)){if(p.caretPositionFromPoint){let t=p.caretPositionFromPoint(h,u);t&&({offsetNode:v,offset:y}=t)}else if(p.caretRangeFromPoint){let e=p.caretRangeFromPoint(h,u);e&&(({startContainer:v,startOffset:y}=e),(!t.contentDOM.contains(v)||gr.safari&&function(t,e,i){let n,s=t;if(3!=t.nodeType||e!=(n=t.nodeValue.length))return!1;for(;;){let t=s.nextSibling;if(t){if("BR"==t.nodeName)break;return!1}{let t=s.parentNode;if(!t||"DIV"==t.nodeName)break;s=t}}return Ho(t,n-1,n).getBoundingClientRect().right>i}(v,y,h)||gr.chrome&&function(t,e,i){if(0!=e)return!1;for(let e=t;;){let t=e.parentNode;if(!t||1!=t.nodeType||t.firstChild!=e)return!1;if(t.classList.contains("cm-line"))break;e=t}let n=1==t.nodeType?t.getBoundingClientRect():Ho(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect();return i-n.left>5}(v,y,h))&&(v=void 0))}v&&(y=Math.min(No(v),y))}if(!v||!t.docView.dom.contains(v)){let e=Nr.find(t.docView,f);if(!e)return d>r.top+r.height/2?r.to:r.from;({node:v,offset:y}=Ga(e.dom,h,u))}let O=t.docView.nearest(v);if(!O)return null;if(O.isWidget&&1==(null===(o=O.dom)||void 0===o?void 0:o.nodeType)){let t=O.dom.getBoundingClientRect();return e.y<t.top||e.y<=t.bottom&&e.x<=(t.left+t.right)/2?O.posAtStart:O.posAtEnd}return O.localPosFromDOM(v,y)+O.posAtStart}function tl(t,e,i,n,s){let o=Math.round((n-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&i.height>1.5*t.defaultLineHeight){let e=t.viewState.heightOracle.textHeight;o+=Math.floor((s-i.top-.5*(t.defaultLineHeight-e))/e)*t.viewState.heightOracle.lineLength}let r=t.state.sliceDoc(i.from,i.to);return i.from+vo(r,o,t.state.tabSize)}function el(t,e,i){let n=t.lineBlockAt(e);if(Array.isArray(n.type)){let t;for(let s of n.type){if(s.from>e)break;if(!(s.to<e)){if(s.from<e&&s.to>e)return s;t&&(s.type!=Ar.Text||t.type==s.type&&!(i<0?s.from<e:s.to>e))||(t=s)}}return t||n}return n}function il(t,e,i,n){let s=t.state.doc.lineAt(e.head),o=t.bidiSpans(s),r=t.textDirectionAt(s.from);for(let a=e,l=null;;){let e=la(s,o,r,a,i),c=aa;if(!e){if(s.number==(i?t.state.doc.lines:1))return a;c="\n",s=t.state.doc.line(s.number+(i?1:-1)),o=t.bidiSpans(s),e=t.visualLineSide(s,!i)}if(l){if(!l(c))return a}else{if(!n)return e;l=n(c)}a=e}}function nl(t,e,i){for(;;){let n=0;for(let s of t)s.between(e-1,e+1,(t,s,o)=>{if(e>t&&e<s){let o=n||i||(e-t<s-e?-1:1);e=o<0?t:s,n=o}});if(!n)return e}}function sl(t,e,i){let n=nl(t.state.facet(Ra).map(e=>e(t)),i.from,e.head>i.from?-1:1);return n==i.from?i:rs.cursor(n,n<i.from?1:-1)}const ol="￿";class rl{constructor(t,e){this.points=t,this.text="",this.lineSeparator=e.facet(Gs.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=ol}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let n=t;;){this.findPointBefore(i,n);let t=this.text.length;this.readNode(n);let s=n.nextSibling;if(s==e)break;let o=tr.get(n),r=tr.get(s);(o&&r?o.breakAfter:(o?o.breakAfter:Io(n))||Io(s)&&("BR"!=n.nodeName||n.cmIgnore)&&this.text.length>t)&&this.lineBreak(),n=s}return this.findPointBefore(i,e),this}readTextNode(t){let e=t.nodeValue;for(let i of this.points)i.node==t&&(i.pos=this.text.length+Math.min(i.offset,e.length));for(let i=0,n=this.lineSeparator?null:/\r\n?|\n/g;;){let s,o=-1,r=1;if(this.lineSeparator?(o=e.indexOf(this.lineSeparator,i),r=this.lineSeparator.length):(s=n.exec(e))&&(o=s.index,r=s[0].length),this.append(e.slice(i,o<0?e.length:o)),o<0)break;if(this.lineBreak(),r>1)for(let e of this.points)e.node==t&&e.pos>this.text.length&&(e.pos-=r-1);i=o+r}}readNode(t){if(t.cmIgnore)return;let e=tr.get(t),i=e&&e.overrideDOMText;if(null!=i){this.findPointInside(t,i.length);for(let t=i.iter();!t.next().done;)t.lineBreak?this.lineBreak():this.append(t.value)}else 3==t.nodeType?this.readTextNode(t):"BR"==t.nodeName?t.nextSibling&&this.lineBreak():1==t.nodeType&&this.readRange(t.firstChild,null)}findPointBefore(t,e){for(let i of this.points)i.node==t&&t.childNodes[i.offset]==e&&(i.pos=this.text.length)}findPointInside(t,e){for(let i of this.points)(3==t.nodeType?i.node==t:t.contains(i.node))&&(i.pos=this.text.length+(al(t,i.node,i.offset)?e:0))}}function al(t,e,i){for(;;){if(!e||i<No(e))return!1;if(e==t)return!0;i=Ro(e)+1,e=e.parentNode}}class ll{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class cl{constructor(t,e,i,n){this.typeOver=n,this.bounds=null,this.text="",this.domChanged=e>-1;let{impreciseHead:s,impreciseAnchor:o}=t.docView;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=t.docView.domBoundsAround(e,i,0))){let e=s||o?[]:function(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:i,anchorOffset:n,focusNode:s,focusOffset:o}=t.observer.selectionRange;i&&(e.push(new ll(i,n)),s==i&&o==n||e.push(new ll(s,o)));return e}(t),i=new rl(e,t.state);i.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=i.text,this.newSel=function(t,e){if(0==t.length)return null;let i=t[0].pos,n=2==t.length?t[1].pos:i;return i>-1&&n>-1?rs.single(i+e,n+e):null}(e,this.bounds.from)}else{let e=t.observer.selectionRange,i=s&&s.node==e.focusNode&&s.offset==e.focusOffset||!Ao(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),n=o&&o.node==e.anchorNode&&o.offset==e.anchorOffset||!Ao(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset),r=t.viewport;if((gr.ios||gr.chrome)&&t.state.selection.main.empty&&i!=n&&(r.from>0||r.to<t.state.doc.length)){let e=Math.min(i,n),s=Math.max(i,n),o=r.from-e,a=r.to-s;0!=o&&1!=o&&0!=e||0!=a&&-1!=a&&s!=t.state.doc.length||(i=0,n=t.state.doc.length)}this.newSel=rs.single(n,i)}}}function hl(t,e){let i,{newSel:n}=e,s=t.state.selection.main,o=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:n,to:r}=e.bounds,a=s.from,l=null;(8===o||gr.android&&e.text.length<r-n)&&(a=s.to,l="end");let c=function(t,e,i,n){let s=Math.min(t.length,e.length),o=0;for(;o<s&&t.charCodeAt(o)==e.charCodeAt(o);)o++;if(o==s&&t.length==e.length)return null;let r=t.length,a=e.length;for(;r>0&&a>0&&t.charCodeAt(r-1)==e.charCodeAt(a-1);)r--,a--;if("end"==n){i-=r+Math.max(0,o-Math.min(r,a))-o}if(r<o&&t.length<e.length){o-=i<=o&&i>=r?o-i:0,a=o+(a-r),r=o}else if(a<o){o-=i<=o&&i>=a?o-i:0,r=o+(r-a),a=o}return{from:o,toA:r,toB:a}}(t.state.doc.sliceString(n,r,ol),e.text,a-n,l);c&&(gr.chrome&&13==o&&c.toB==c.from+2&&e.text.slice(c.from,c.toB)==ol+ol&&c.toB--,i={from:n+c.from,to:n+c.toA,insert:Rn.of(e.text.slice(c.from,c.toB).split(ol))})}else n&&(!t.hasFocus&&t.state.facet($a)||n.main.eq(s))&&(n=null);if(!i&&!n)return!1;if(!i&&e.typeOver&&!s.empty&&n&&n.main.empty?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,s.to)}:(gr.mac||gr.android)&&i&&i.from==i.to&&i.from==s.head-1&&/^\. ?$/.test(i.insert.toString())&&"off"==t.contentDOM.getAttribute("autocorrect")?(n&&2==i.insert.length&&(n=rs.single(n.main.anchor-1,n.main.head-1)),i={from:i.from,to:i.to,insert:Rn.of([i.insert.toString().replace("."," ")])}):i&&i.from>=s.from&&i.to<=s.to&&(i.from!=s.from||i.to!=s.to)&&s.to-s.from-(i.to-i.from)<=4?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,i.from).append(i.insert).append(t.state.doc.slice(i.to,s.to))}:gr.chrome&&i&&i.from==i.to&&i.from==s.head&&"\n "==i.insert.toString()&&t.lineWrapping&&(n&&(n=rs.single(n.main.anchor-1,n.main.head-1)),i={from:s.from,to:s.to,insert:Rn.of([" "])}),i)return ul(t,i,n,o);if(n&&!n.main.eq(s)){let e=!1,i="select";return t.inputState.lastSelectionTime>Date.now()-50&&("select"==t.inputState.lastSelectionOrigin&&(e=!0),i=t.inputState.lastSelectionOrigin),t.dispatch({selection:n,scrollIntoView:e,userEvent:i}),!0}return!1}function ul(t,e,i,n=-1){if(gr.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(gr.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&" "==t.state.sliceDoc(e.from,s.from))&&1==e.insert.length&&2==e.insert.lines&&Wo(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&0==e.insert.length||8==n&&e.insert.length<e.to-e.from&&e.to>s.head)&&Wo(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&0==e.insert.length&&Wo(t.contentDOM,"Delete",46)))return!0;let o,r=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let a=()=>o||(o=function(t,e,i){let n,s=t.state,o=s.selection.main;if(e.from>=o.from&&e.to<=o.to&&e.to-e.from>=(o.to-o.from)/3&&(!i||i.main.empty&&i.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let i=o.from<e.from?s.sliceDoc(o.from,e.from):"",r=o.to>e.to?s.sliceDoc(e.to,o.to):"";n=s.replaceSelection(t.state.toText(i+e.insert.sliceString(0,void 0,t.state.lineBreak)+r))}else{let r=s.changes(e),a=i&&i.main.to<=r.newLength?i.main:void 0;if(s.selection.ranges.length>1&&t.inputState.composing>=0&&e.to<=o.to&&e.to>=o.to-10){let l,c=t.state.sliceDoc(e.from,e.to),h=i&&Fa(t,i.main.head);if(h){let t=e.insert.length-(e.to-e.from);l={from:h.from,to:h.to-t}}else l=t.state.doc.lineAt(o.head);let u=o.to-e.to,d=o.to-o.from;n=s.changeByRange(i=>{if(i.from==o.from&&i.to==o.to)return{changes:r,range:a||i.map(r)};let n=i.to-u,h=n-c.length;if(i.to-i.from!=d||t.state.sliceDoc(h,n)!=c||i.to>=l.from&&i.from<=l.to)return{range:i};let f=s.changes({from:h,to:n,insert:e.insert}),p=i.to-o.to;return{changes:f,range:a?rs.range(Math.max(0,a.anchor+p),Math.max(0,a.head+p)):i.map(f)}})}else n={changes:r,selection:a&&s.selection.replaceRange(a)}}let r="input.type";(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,r+=".compose",t.inputState.compositionFirstChange&&(r+=".start",t.inputState.compositionFirstChange=!1));return s.update(n,{userEvent:r,scrollIntoView:!0})}(t,e,i));return t.state.facet(ma).some(i=>i(t,e.from,e.to,r,a))||t.dispatch(a()),!0}class dl{setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}constructor(t){this.view=t,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=t.hasFocus,gr.safari&&t.contentDOM.addEventListener("input",()=>null),gr.gecko&&function(t){jl.has(t)||(jl.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}(t.contentDOM.ownerDocument)}handleEvent(t){(function(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let i,n=e.target;n!=t.contentDOM;n=n.parentNode)if(!n||11==n.nodeType||(i=tr.get(n))&&i.ignoreEvent(e))return!1;return!0})(this.view,t)&&!this.ignoreDuringComposition(t)&&("keydown"==t.type&&this.keydown(t)||(0!=this.view.updateState?Promise.resolve().then(()=>this.runHandlers(t.type,t)):this.runHandlers(t.type,t)))}runHandlers(t,e){let i=this.handlers[t];if(i){for(let t of i.observers)t(this.view,e);for(let t of i.handlers){if(e.defaultPrevented)break;if(t(this.view,e)){e.preventDefault();break}}}}ensureHandlers(t){let e=pl(t),i=this.handlers,n=this.view.contentDOM;for(let t in e)if("scroll"!=t){let s=!e[t].handlers.length,o=i[t];o&&s!=!o.handlers.length&&(n.removeEventListener(t,this.handleEvent),o=null),o||n.addEventListener(t,this.handleEvent,{passive:s})}for(let t in i)"scroll"==t||e[t]||n.removeEventListener(t,this.handleEvent);this.handlers=e}keydown(t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),9==t.keyCode&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&27!=t.keyCode&&vl.indexOf(t.keyCode)<0&&(this.tabFocusMode=-1),gr.android&&gr.chrome&&!t.synthetic&&(13==t.keyCode||8==t.keyCode))return this.view.observer.delayAndroidKey(t.key,t.keyCode),!0;let e;return!gr.ios||t.synthetic||t.altKey||t.metaKey||!((e=ml.find(e=>e.keyCode==t.keyCode))&&!t.ctrlKey||gl.indexOf(t.key)>-1&&t.ctrlKey&&!t.shiftKey)?(229!=t.keyCode&&this.view.observer.forceFlush(),!1):(this.pendingIOSKey=e||t,setTimeout(()=>this.flushIOSKey(),250),!0)}flushIOSKey(t){let e=this.pendingIOSKey;return!!e&&(!("Enter"==e.key&&t&&t.from<t.to&&/^\S+$/.test(t.insert.toString()))&&(this.pendingIOSKey=void 0,Wo(this.view.contentDOM,e.key,e.keyCode,e instanceof KeyboardEvent?e:void 0)))}ignoreDuringComposition(t){return!!/^key/.test(t.type)&&(this.composing>0||!!(gr.safari&&!gr.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.view.observer.update(t),this.mouseSelection&&this.mouseSelection.update(t),this.draggedContent&&t.docChanged&&(this.draggedContent=this.draggedContent.map(t.changes)),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function fl(t,e){return(i,n)=>{try{return e.call(t,n,i)}catch(t){ka(i.state,t)}}}function pl(t){let e=Object.create(null);function i(t){return e[t]||(e[t]={observers:[],handlers:[]})}for(let e of t){let t=e.spec,n=t&&t.plugin.domEventHandlers,s=t&&t.plugin.domEventObservers;if(n)for(let t in n){let s=n[t];s&&i(t).handlers.push(fl(e.value,s))}if(s)for(let t in s){let n=s[t];n&&i(t).observers.push(fl(e.value,n))}}for(let t in bl)i(t).handlers.push(bl[t]);for(let t in xl)i(t).observers.push(xl[t]);return e}const ml=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],gl="dthko",vl=[16,17,18,20,91,92,224,225];function yl(t){return.7*Math.max(0,t)+8}class Ol{constructor(t,e,i,n){this.view=t,this.startEvent=e,this.style=i,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParents=function(t){let e,i,n=t.ownerDocument;for(let s=t.parentNode;s&&!(s==n.body||e&&i);)if(1==s.nodeType)!i&&s.scrollHeight>s.clientHeight&&(i=s),!e&&s.scrollWidth>s.clientWidth&&(e=s),s=s.assignedSlot||s.parentNode;else{if(11!=s.nodeType)break;s=s.host}return{x:e,y:i}}(t.contentDOM),this.atoms=t.state.facet(Ra).map(e=>e(t));let s=t.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet(Gs.allowMultipleSelections)&&function(t,e){let i=t.state.facet(ha);return i.length?i[0](e):gr.mac?e.metaKey:e.ctrlKey}(t,e),this.dragging=!(!function(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let n=Eo(t.root);if(!n||0==n.rangeCount)return!0;let s=n.getRangeAt(0).getClientRects();for(let t=0;t<s.length;t++){let i=s[t];if(i.left<=e.clientX&&i.right>=e.clientX&&i.top<=e.clientY&&i.bottom>=e.clientY)return!0}return!1}(t,e)||1!=Ql(e))&&null}start(t){!1===this.dragging&&this.select(t)}move(t){if(0==t.buttons)return this.destroy();if(this.dragging||null==this.dragging&&(e=this.startEvent,i=t,Math.max(Math.abs(e.clientX-i.clientX),Math.abs(e.clientY-i.clientY))<10))return;var e,i;this.select(this.lastEvent=t);let n=0,s=0,o=0,r=0,a=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:o,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:r,bottom:l}=this.scrollParents.y.getBoundingClientRect());let c=ja(this.view);t.clientX-c.left<=o+6?n=-yl(o-t.clientX):t.clientX+c.right>=a-6&&(n=yl(t.clientX-a)),t.clientY-c.top<=r+6?s=-yl(r-t.clientY):t.clientY+c.bottom>=l-6&&(s=yl(t.clientY-l)),this.setScrollSpeed(n,s)}up(t){null==this.dragging&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(t,e){this.scrollSpeed={x:t,y:e},t||e?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:t,y:e}=this.scrollSpeed;t&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=t,t=0),e&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=e,e=0),(t||e)&&this.view.win.scrollBy(t,e),!1===this.dragging&&this.select(this.lastEvent)}skipAtoms(t){let e=null;for(let i=0;i<t.ranges.length;i++){let n=t.ranges[i],s=null;if(n.empty){let t=nl(this.atoms,n.from,0);t!=n.from&&(s=rs.cursor(t,-1))}else{let t=nl(this.atoms,n.from,-1),e=nl(this.atoms,n.to,1);t==n.from&&e==n.to||(s=rs.range(n.from==n.anchor?t:e,n.from==n.head?t:e))}s&&(e||(e=t.ranges.slice()),e[i]=s)}return e?rs.create(e,t.mainIndex):t}select(t){let{view:e}=this,i=this.skipAtoms(this.style.get(t,this.extend,this.multiple));!this.mustSelect&&i.eq(e.state.selection,!1===this.dragging)||this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(t){t.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(t)&&setTimeout(()=>this.select(this.lastEvent),20)}}const bl=Object.create(null),xl=Object.create(null),wl=gr.ie&&gr.ie_version<15||gr.ios&&gr.webkit_version<604;function _l(t,e,i){for(let n of t.facet(e))i=n(i,t);return i}function Sl(t,e){e=_l(t.state,va,e);let i,{state:n}=t,s=1,o=n.toText(e),r=o.lines==n.selection.ranges.length;if(null!=Rl&&n.selection.ranges.every(t=>t.empty)&&Rl==o.toString()){let t=-1;i=n.changeByRange(i=>{let a=n.doc.lineAt(i.from);if(a.from==t)return{range:i};t=a.from;let l=n.toText((r?o.line(s++).text:e)+n.lineBreak);return{changes:{from:a.from,insert:l},range:rs.cursor(i.from+l.length)}})}else i=r?n.changeByRange(t=>{let e=o.line(s++);return{changes:{from:t.from,to:t.to,insert:e.text},range:rs.cursor(t.from+e.length)}}):n.replaceSelection(o);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}function kl(t,e,i,n){if(1==n)return rs.cursor(e,i);if(2==n)return function(t,e,i=1){let n=t.charCategorizer(e),s=t.doc.lineAt(e),o=e-s.from;if(0==s.length)return rs.cursor(e);0==o?i=1:o==s.length&&(i=-1);let r=o,a=o;i<0?r=Xn(s.text,o,!1):a=Xn(s.text,o);let l=n(s.text.slice(r,a));for(;r>0;){let t=Xn(s.text,r,!1);if(n(s.text.slice(t,r))!=l)break;r=t}for(;a<s.length;){let t=Xn(s.text,a);if(n(s.text.slice(a,t))!=l)break;a=t}return rs.range(r+s.from,a+s.from)}(t.state,e,i);{let i=Nr.find(t.docView,e),n=t.state.doc.lineAt(i?i.posAtEnd:e),s=i?i.posAtStart:n.from,o=i?i.posAtEnd:n.to;return o<t.state.doc.length&&o==n.to&&o++,rs.range(s,o)}}xl.scroll=t=>{t.inputState.lastScrollTop=t.scrollDOM.scrollTop,t.inputState.lastScrollLeft=t.scrollDOM.scrollLeft},bl.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),27==e.keyCode&&0!=t.inputState.tabFocusMode&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),xl.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},xl.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},bl.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let i=null;for(let n of t.state.facet(da))if(i=n(t,e),i)break;if(i||0!=e.button||(i=function(t,e){let i=Tl(t,e),n=Ql(e),s=t.state.selection;return{update(t){t.docChanged&&(i.pos=t.changes.mapPos(i.pos),s=s.map(t.changes))},get(e,o,r){let a,l=Tl(t,e),c=kl(t,l.pos,l.bias,n);if(i.pos!=l.pos&&!o){let e=kl(t,i.pos,i.bias,n),s=Math.min(e.from,c.from),o=Math.max(e.to,c.to);c=s<c.from?rs.range(s,o):rs.range(o,s)}return o?s.replaceRange(s.main.extend(c.from,c.to)):r&&1==n&&s.ranges.length>1&&(a=function(t,e){for(let i=0;i<t.ranges.length;i++){let{from:n,to:s}=t.ranges[i];if(n<=e&&s>=e)return rs.create(t.ranges.slice(0,i).concat(t.ranges.slice(i+1)),t.mainIndex==i?0:t.mainIndex-(t.mainIndex>i?1:0))}return null}(s,l.pos))?a:r?s.addRange(c):rs.create([c])}}}(t,e)),i){let n=!t.hasFocus;t.inputState.startMouseSelection(new Ol(t,e,i,n)),n&&t.observer.ignore(()=>{Xo(t.contentDOM);let e=t.root.activeElement;e&&!e.contains(t.contentDOM)&&e.blur()});let s=t.inputState.mouseSelection;if(s)return s.start(e),!1===s.dragging}return!1};let $l=(t,e,i)=>e>=i.top&&e<=i.bottom&&t>=i.left&&t<=i.right;function Cl(t,e,i,n){let s=Nr.find(t.docView,e);if(!s)return 1;let o=e-s.posAtStart;if(0==o)return 1;if(o==s.length)return-1;let r=s.coordsAt(o,-1);if(r&&$l(i,n,r))return-1;let a=s.coordsAt(o,1);return a&&$l(i,n,a)?1:r&&r.bottom>=n?-1:1}function Tl(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:i,bias:Cl(t,i,e.clientX,e.clientY)}}const Pl=gr.ie&&gr.ie_version<=11;let El=null,Al=0,Ml=0;function Ql(t){if(!Pl)return t.detail;let e=El,i=Ml;return El=t,Ml=Date.now(),Al=!e||i>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Al+1)%3:1}function Dl(t,e,i,n){if(!(i=_l(t.state,va,i)))return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:o}=t.inputState,r=n&&o&&function(t,e){let i=t.state.facet(ua);return i.length?i[0](e):gr.mac?!e.altKey:!e.ctrlKey}(t,e)?{from:o.from,to:o.to}:null,a={from:s,insert:i},l=t.state.changes(r?[r,a]:a);t.focus(),t.dispatch({changes:l,selection:{anchor:l.mapPos(s,-1),head:l.mapPos(s,1)},userEvent:r?"move.drop":"input.drop"}),t.inputState.draggedContent=null}bl.dragstart=(t,e)=>{let{selection:{main:i}}=t.state;if(e.target.draggable){let n=t.docView.nearest(e.target);if(n&&n.isWidget){let t=n.posAtStart,e=t+n.length;(t>=i.to||e<=i.from)&&(i=rs.range(t,e))}}let{inputState:n}=t;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=i,e.dataTransfer&&(e.dataTransfer.setData("Text",_l(t.state,ya,t.state.sliceDoc(i.from,i.to))),e.dataTransfer.effectAllowed="copyMove"),!1},bl.dragend=t=>(t.inputState.draggedContent=null,!1),bl.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let i=e.dataTransfer.files;if(i&&i.length){let n=Array(i.length),s=0,o=()=>{++s==i.length&&Dl(t,e,n.filter(t=>null!=t).join(t.state.lineBreak),!1)};for(let t=0;t<i.length;t++){let e=new FileReader;e.onerror=o,e.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(e.result)||(n[t]=e.result),o()},e.readAsText(i[t])}return!0}{let i=e.dataTransfer.getData("Text");if(i)return Dl(t,e,i,!0),!0}return!1},bl.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let i=wl?null:e.clipboardData;return i?(Sl(t,i.getData("text/plain")||i.getData("text/uri-list")),!0):(function(t){let e=t.dom.parentNode;if(!e)return;let i=e.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus(),setTimeout(()=>{t.focus(),i.remove(),Sl(t,i.value)},50)}(t),!1)};let Rl=null;bl.copy=bl.cut=(t,e)=>{let{text:i,ranges:n,linewise:s}=function(t){let e=[],i=[],n=!1;for(let n of t.selection.ranges)n.empty||(e.push(t.sliceDoc(n.from,n.to)),i.push(n));if(!e.length){let s=-1;for(let{from:n}of t.selection.ranges){let o=t.doc.lineAt(n);o.number>s&&(e.push(o.text),i.push({from:o.from,to:Math.min(t.doc.length,o.to+1)})),s=o.number}n=!0}return{text:_l(t,ya,e.join(t.lineBreak)),ranges:i,linewise:n}}(t.state);if(!i&&!s)return!1;Rl=s?i:null,"cut"!=e.type||t.state.readOnly||t.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let o=wl?null:e.clipboardData;return o?(o.clearData(),o.setData("text/plain",i),!0):(function(t,e){let i=t.dom.parentNode;if(!i)return;let n=i.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout(()=>{n.remove(),t.focus()},50)}(t,i),!1)};const Il=Is.define();function Ll(t,e){let i=[];for(let n of t.facet(ga)){let s=n(t,e);s&&i.push(s)}return i.length?t.update({effects:i,annotations:Il.of(!0)}):null}function Nl(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=Ll(t.state,e);i?t.dispatch(i):t.update([])}},10)}xl.focus=t=>{t.inputState.lastFocusTime=Date.now(),t.scrollDOM.scrollTop||!t.inputState.lastScrollTop&&!t.inputState.lastScrollLeft||(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),Nl(t)},xl.blur=t=>{t.observer.clearSelectionRange(),Nl(t)},xl.compositionstart=xl.compositionupdate=t=>{t.observer.editContext||(null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},xl.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,gr.chrome&&gr.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},xl.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},bl.beforeinput=(t,e)=>{var i,n;if("insertReplacementText"==e.inputType&&t.observer.editContext){let n=null===(i=e.dataTransfer)||void 0===i?void 0:i.getData("text/plain"),s=e.getTargetRanges();if(n&&s.length){let e=s[0],i=t.posAtDOM(e.startContainer,e.startOffset),o=t.posAtDOM(e.endContainer,e.endOffset);return ul(t,{from:i,to:o,insert:t.state.toText(n)},null),!0}}let s;if(gr.chrome&&gr.android&&(s=ml.find(t=>t.inputType==e.inputType))&&(t.observer.delayAndroidKey(s.key,s.keyCode),"Backspace"==s.key||"Delete"==s.key)){let e=(null===(n=window.visualViewport)||void 0===n?void 0:n.height)||0;setTimeout(()=>{var i;((null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0)>e+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return gr.ios&&"deleteContentForward"==e.inputType&&t.observer.flushSoon(),gr.safari&&"insertText"==e.inputType&&t.inputState.composing>=0&&setTimeout(()=>xl.compositionend(t,e),20),!1};const jl=new Set;const zl=["pre-wrap","normal","pre-line","break-spaces"];let Bl=!1;function ql(){Bl=!1}class Zl{constructor(t){this.lineWrapping=t,this.doc=Rn.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(t,e){let i=this.doc.lineAt(e).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(t){if(!this.lineWrapping)return this.lineHeight;return(1+Math.max(0,Math.ceil((t-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return zl.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i<t.length;i++){let n=t[i];n<0?i++:this.heightSamples[Math.floor(10*n)]||(e=!0,this.heightSamples[Math.floor(10*n)]=!0)}return e}refresh(t,e,i,n,s,o){let r=zl.indexOf(t)>-1,a=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=r;if(this.lineWrapping=r,this.lineHeight=e,this.charWidth=i,this.textHeight=n,this.lineLength=s,a){this.heightSamples={};for(let t=0;t<o.length;t++){let e=o[t];e<0?t++:this.heightSamples[Math.floor(10*e)]=!0}}return a}}class Fl{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class Xl{constructor(t,e,i,n,s){this.from=t,this.length=e,this.top=i,this.height=n,this._content=s}get type(){return"number"==typeof this._content?Ar.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof Rr?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(t){let e=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new Xl(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var Hl=function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t}(Hl||(Hl={}));const Wl=.001;class Vl{constructor(t,e,i=2){this.length=t,this.height=e,this.flags=i}get outdated(){return(2&this.flags)>0}set outdated(t){this.flags=(t?2:0)|-3&this.flags}setHeight(t){this.height!=t&&(Math.abs(this.height-t)>Wl&&(Bl=!0),this.height=t)}replace(t,e,i){return Vl.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,n){let s=this,o=i.doc;for(let r=n.length-1;r>=0;r--){let{fromA:a,toA:l,fromB:c,toB:h}=n[r],u=s.lineAt(a,Hl.ByPosNoHeight,i.setDoc(e),0,0),d=u.to>=l?u:s.lineAt(l,Hl.ByPosNoHeight,i,0,0);for(h+=d.to-l,l=d.to;r>0&&u.from<=n[r-1].toA;)a=n[r-1].fromA,c=n[r-1].fromB,r--,a<u.from&&(u=s.lineAt(a,Hl.ByPosNoHeight,i,0,0));c+=u.from-a,a=u.from;let f=ec.build(i.setDoc(o),t,c,h);s=Yl(s,s.replace(a,l,f))}return s.updateHeight(i,0)}static empty(){return new Gl(0,0)}static of(t){if(1==t.length)return t[0];let e=0,i=t.length,n=0,s=0;for(;;)if(e==i)if(n>2*s){let s=t[e-1];s.break?t.splice(--e,1,s.left,null,s.right):t.splice(--e,1,s.left,s.right),i+=1+s.break,n-=s.size}else{if(!(s>2*n))break;{let e=t[i];e.break?t.splice(i,1,e.left,null,e.right):t.splice(i,1,e.left,e.right),i+=2+e.break,s-=e.size}}else if(n<s){let i=t[e++];i&&(n+=i.size)}else{let e=t[--i];e&&(s+=e.size)}let o=0;return null==t[e-1]?(o=1,e--):null==t[e]&&(o=1,i++),new Jl(Vl.of(t.slice(0,e)),o,Vl.of(t.slice(i)))}}function Yl(t,e){return t==e?t:(t.constructor!=e.constructor&&(Bl=!0),e)}Vl.prototype.size=1;class Ul extends Vl{constructor(t,e,i){super(t,e),this.deco=i}blockAt(t,e,i,n){return new Xl(n,this.length,i,this.height,this.deco||0)}lineAt(t,e,i,n,s){return this.blockAt(0,i,n,s)}forEachLine(t,e,i,n,s,o){t<=s+this.length&&e>=s&&o(this.blockAt(0,i,n,s))}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more&&this.setHeight(n.heights[n.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Gl extends Ul{constructor(t,e){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(t,e,i,n){return new Xl(n,this.length,i,this.height,this.breaks)}replace(t,e,i){let n=i[0];return 1==i.length&&(n instanceof Gl||n instanceof Kl&&4&n.flags)&&Math.abs(this.length-n.length)<10?(n instanceof Kl?n=new Gl(n.length,this.height):n.height=this.height,this.outdated||(n.outdated=!1),n):Vl.of(i)}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more?this.setHeight(n.heights[n.index++]):(i||this.outdated)&&this.setHeight(Math.max(this.widgetHeight,t.heightForLine(this.length-this.collapsed))+this.breaks*t.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Kl extends Vl{constructor(t){super(t,0)}heightMetrics(t,e){let i,n=t.doc.lineAt(e).number,s=t.doc.lineAt(e+this.length).number,o=s-n+1,r=0;if(t.lineWrapping){let e=Math.min(this.height,t.lineHeight*o);i=e/o,this.length>o+1&&(r=(this.height-e)/(this.length-o-1))}else i=this.height/o;return{firstLine:n,lastLine:s,perLine:i,perChar:r}}blockAt(t,e,i,n){let{firstLine:s,lastLine:o,perLine:r,perChar:a}=this.heightMetrics(e,n);if(e.lineWrapping){let s=n+(t<e.lineHeight?0:Math.round(Math.max(0,Math.min(1,(t-i)/this.height))*this.length)),o=e.doc.lineAt(s),l=r+o.length*a,c=Math.max(i,t-l/2);return new Xl(o.from,o.length,c,l,0)}{let n=Math.max(0,Math.min(o-s,Math.floor((t-i)/r))),{from:a,length:l}=e.doc.line(s+n);return new Xl(a,l,i+r*n,r,0)}}lineAt(t,e,i,n,s){if(e==Hl.ByHeight)return this.blockAt(t,i,n,s);if(e==Hl.ByPosNoHeight){let{from:e,to:n}=i.doc.lineAt(t);return new Xl(e,n-e,0,0,0)}let{firstLine:o,perLine:r,perChar:a}=this.heightMetrics(i,s),l=i.doc.lineAt(t),c=r+l.length*a,h=l.number-o,u=n+r*h+a*(l.from-s-h);return new Xl(l.from,l.length,Math.max(n,Math.min(u,n+this.height-c)),c,0)}forEachLine(t,e,i,n,s,o){t=Math.max(t,s),e=Math.min(e,s+this.length);let{firstLine:r,perLine:a,perChar:l}=this.heightMetrics(i,s);for(let c=t,h=n;c<=e;){let e=i.doc.lineAt(c);if(c==t){let i=e.number-r;h+=a*i+l*(t-s-i)}let n=a+l*e.length;o(new Xl(e.from,e.length,h,n,0)),h+=n,c=e.to+1}}replace(t,e,i){let n=this.length-e;if(n>0){let t=i[i.length-1];t instanceof Kl?i[i.length-1]=new Kl(t.length+n):i.push(null,new Kl(n-1))}if(t>0){let e=i[0];e instanceof Kl?i[0]=new Kl(t+e.length):i.unshift(new Kl(t-1),null)}return Vl.of(i)}decomposeLeft(t,e){e.push(new Kl(t-1),null)}decomposeRight(t,e){e.push(null,new Kl(this.length-t-1))}updateHeight(t,e=0,i=!1,n){let s=e+this.length;if(n&&n.from<=e+this.length&&n.more){let i=[],o=Math.max(e,n.from),r=-1;for(n.from>e&&i.push(new Kl(n.from-e-1).updateHeight(t,e));o<=s&&n.more;){let e=t.doc.lineAt(o).length;i.length&&i.push(null);let s=n.heights[n.index++];-1==r?r=s:Math.abs(s-r)>=Wl&&(r=-2);let a=new Gl(e,s);a.outdated=!1,i.push(a),o+=e+1}o<=s&&i.push(null,new Kl(s-o).updateHeight(t,o));let a=Vl.of(i);return(r<0||Math.abs(a.height-this.height)>=Wl||Math.abs(r-this.heightMetrics(t,e).perLine)>=Wl)&&(Bl=!0),Yl(this,a)}return(i||this.outdated)&&(this.setHeight(t.heightForGap(e,e+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class Jl extends Vl{constructor(t,e,i){super(t.length+e+i.length,t.height+i.height,e|(t.outdated||i.outdated?2:0)),this.left=t,this.right=i,this.size=t.size+i.size}get break(){return 1&this.flags}blockAt(t,e,i,n){let s=i+this.left.height;return t<s?this.left.blockAt(t,e,i,n):this.right.blockAt(t,e,s,n+this.left.length+this.break)}lineAt(t,e,i,n,s){let o=n+this.left.height,r=s+this.left.length+this.break,a=e==Hl.ByHeight?t<o:t<r,l=a?this.left.lineAt(t,e,i,n,s):this.right.lineAt(t,e,i,o,r);if(this.break||(a?l.to<r:l.from>r))return l;let c=e==Hl.ByPosNoHeight?Hl.ByPosNoHeight:Hl.ByPos;return a?l.join(this.right.lineAt(r,c,i,o,r)):this.left.lineAt(r,c,i,n,s).join(l)}forEachLine(t,e,i,n,s,o){let r=n+this.left.height,a=s+this.left.length+this.break;if(this.break)t<a&&this.left.forEachLine(t,e,i,n,s,o),e>=a&&this.right.forEachLine(t,e,i,r,a,o);else{let l=this.lineAt(a,Hl.ByPos,i,n,s);t<l.from&&this.left.forEachLine(t,l.from-1,i,n,s,o),l.to>=t&&l.from<=e&&o(l),e>l.to&&this.right.forEachLine(l.to+1,e,i,r,a,o)}}replace(t,e,i){let n=this.left.length+this.break;if(e<n)return this.balanced(this.left.replace(t,e,i),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-n,e-n,i));let s=[];t>0&&this.decomposeLeft(t,s);let o=s.length;for(let t of i)s.push(t);if(t>0&&tc(s,o-1),e<this.length){let t=s.length;this.decomposeRight(e,s),tc(s,t)}return Vl.of(s)}decomposeLeft(t,e){let i=this.left.length;if(t<=i)return this.left.decomposeLeft(t,e);e.push(this.left),this.break&&(i++,t>=i&&e.push(null)),t>i&&this.right.decomposeLeft(t-i,e)}decomposeRight(t,e){let i=this.left.length,n=i+this.break;if(t>=n)return this.right.decomposeRight(t-n,e);t<i&&this.left.decomposeRight(t,e),this.break&&t<n&&e.push(null),e.push(this.right)}balanced(t,e){return t.size>2*e.size||e.size>2*t.size?Vl.of(this.break?[t,null,e]:[t,e]):(this.left=Yl(this.left,t),this.right=Yl(this.right,e),this.setHeight(t.height+e.height),this.outdated=t.outdated||e.outdated,this.size=t.size+e.size,this.length=t.length+this.break+e.length,this)}updateHeight(t,e=0,i=!1,n){let{left:s,right:o}=this,r=e+s.length+this.break,a=null;return n&&n.from<=e+s.length&&n.more?a=s=s.updateHeight(t,e,i,n):s.updateHeight(t,e,i),n&&n.from<=r+o.length&&n.more?a=o=o.updateHeight(t,r,i,n):o.updateHeight(t,r,i),a?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function tc(t,e){let i,n;null==t[e]&&(i=t[e-1])instanceof Kl&&(n=t[e+1])instanceof Kl&&t.splice(e-1,3,new Kl(i.length+1+n.length))}class ec{constructor(t,e){this.pos=t,this.oracle=e,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,e){if(this.lineStart>-1){let t=Math.min(e,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof Gl?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new Gl(t-this.pos,-1)),this.writtenTo=t,e>t&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=e}point(t,e,i){if(t<e||i.heightRelevant){let n=i.widget?i.widget.estimatedHeight:0,s=i.widget?i.widget.lineBreaks:0;n<0&&(n=this.oracle.lineHeight);let o=e-t;i.block?this.addBlock(new Ul(o,n,i)):(o||s||n>=5)&&this.addLineDeco(n,s,o)}else e>t&&this.span(t,e);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:t,to:e}=this.oracle.doc.lineAt(this.pos);this.lineStart=t,this.lineEnd=e,this.writtenTo<t&&((this.writtenTo<t-1||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,t-1)),this.nodes.push(null)),this.pos>t&&this.nodes.push(new Gl(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new Kl(e-t);return this.oracle.doc.lineAt(t).to==e&&(i.flags|=4),i}ensureLine(){this.enterLine();let t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof Gl)return t;let e=new Gl(0,-1);return this.nodes.push(e),e}addBlock(t){this.enterLine();let e=t.deco;e&&e.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,e&&e.endSide>0&&(this.covering=t)}addLineDeco(t,e,i){let n=this.ensureLine();n.length+=i,n.collapsed+=i,n.widgetHeight=Math.max(n.widgetHeight,t),n.breaks+=e,this.writtenTo=this.pos=this.pos+i}finish(t){let e=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||e instanceof Gl||this.isCovered?(this.writtenTo<this.pos||null==e)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new Gl(0,-1));let i=t;for(let t of this.nodes)t instanceof Gl&&t.updateHeight(this.oracle,i),i+=t?t.length:1;return this.nodes}static build(t,e,i,n){let s=new ec(i,t);return no.spans(e,i,n,s,0),s.finish(i)}}class ic{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,n){(t<e||i&&i.heightRelevant||n&&n.heightRelevant)&&Lr(t,e,this.changes,5)}}function nc(t,e){let i=t.getBoundingClientRect(),n=t.ownerDocument,s=n.defaultView||window,o=Math.max(0,i.left),r=Math.min(s.innerWidth,i.right),a=Math.max(0,i.top),l=Math.min(s.innerHeight,i.bottom);for(let e=t.parentNode;e&&e!=n.body;)if(1==e.nodeType){let i=e,n=window.getComputedStyle(i);if((i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)&&"visible"!=n.overflow){let n=i.getBoundingClientRect();o=Math.max(o,n.left),r=Math.min(r,n.right),a=Math.max(a,n.top),l=Math.min(e==t.parentNode?s.innerHeight:l,n.bottom)}e="absolute"==n.position||"fixed"==n.position?i.offsetParent:i.parentNode}else{if(11!=e.nodeType)break;e=e.host}return{left:o-i.left,right:Math.max(o,r)-i.left,top:a-(i.top+e),bottom:Math.max(a,l)-(i.top+e)}}function sc(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}class oc{constructor(t,e,i,n){this.from=t,this.to=e,this.size=i,this.displaySize=n}static same(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let n=t[i],s=e[i];if(n.from!=s.from||n.to!=s.to||n.size!=s.size)return!1}return!0}draw(t,e){return Mr.replace({widget:new rc(this.displaySize*(e?t.scaleY:t.scaleX),e)}).range(this.from,this.to)}}class rc extends Er{constructor(t,e){super(),this.size=t,this.vertical=e}eq(t){return t.size==this.size&&t.vertical==this.vertical}toDOM(){let t=document.createElement("div");return this.vertical?t.style.height=this.size+"px":(t.style.width=this.size+"px",t.style.height="2px",t.style.display="inline-block"),t}get estimatedHeight(){return this.vertical?this.size:-1}}class ac{constructor(t){this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=uc,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Fr.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let e=t.facet(Ma).some(t=>"function"!=typeof t&&"cm-lineWrapping"==t.class);this.heightOracle=new Zl(e),this.stateDeco=t.facet(Qa).filter(t=>"function"!=typeof t),this.heightMap=Vl.empty().applyChanges(this.stateDeco,Rn.empty,this.heightOracle.setDoc(t.doc),[new Ba(0,0,0,t.doc.length)]);for(let t=0;t<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());t++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Mr.set(this.lineGaps.map(t=>t.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let t=[this.viewport],{main:e}=this.state.selection;for(let i=0;i<=1;i++){let n=i?e.head:e.anchor;if(!t.some(({from:t,to:e})=>n>=t&&n<=e)){let{from:e,to:i}=this.lineBlockAt(n);t.push(new lc(e,i))}}return this.viewports=t.sort((t,e)=>t.from-e.from),this.updateScaler()}updateScaler(){let t=this.scaler;return this.scaler=this.heightMap.height<=7e6?uc:new dc(this.heightOracle,this.heightMap,this.viewports),t.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,t=>{this.viewportLines.push(fc(t,this.scaler))})}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=this.state.facet(Qa).filter(t=>"function"!=typeof t);let n=t.changedRanges,s=Ba.extendWithRanges(n,function(t,e,i){let n=new ic;return no.compare(t,e,i,n,0),n.changes}(i,this.stateDeco,t?t.changes:Kn.empty(this.state.doc.length))),o=this.heightMap.height,r=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);ql(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||Bl)&&(t.flags|=2),r?(this.scrollAnchorPos=t.changes.mapPos(r.from,-1),this.scrollAnchorHeight=r.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=s.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<a.from||e.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,e));let l=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,t.flags|=this.updateForViewport(),(l||!t.changes.empty||2&t.flags)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,t.changes))),t.flags|=this.computeVisibleRanges(t.changes),e&&(this.scrollTarget=e),!this.mustEnforceCursorAssoc&&t.selectionSet&&t.view.lineWrapping&&t.state.selection.main.empty&&t.state.selection.main.assoc&&!t.state.facet(ba)&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,i=window.getComputedStyle(e),n=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection="rtl"==i.direction?Fr.RTL:Fr.LTR;let o=this.heightOracle.mustRefreshForWrapping(s),r=e.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=r.height;this.contentDOMHeight=r.height,this.mustMeasureContent=!1;let l=0,c=0;if(r.width&&r.height){let{scaleX:t,scaleY:i}=Bo(e,r);(t>.005&&Math.abs(this.scaleX-t)>.005||i>.005&&Math.abs(this.scaleY-i)>.005)&&(this.scaleX=t,this.scaleY=i,l|=16,o=a=!0)}let h=(parseInt(i.paddingTop)||0)*this.scaleY,u=(parseInt(i.paddingBottom)||0)*this.scaleY;this.paddingTop==h&&this.paddingBottom==u||(this.paddingTop=h,this.paddingBottom=u,l|=18),this.editorWidth!=t.scrollDOM.clientWidth&&(n.lineWrapping&&(a=!0),this.editorWidth=t.scrollDOM.clientWidth,l|=16);let d=t.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=d&&(this.scrollAnchorHeight=-1,this.scrollTop=d),this.scrolledToBottom=Yo(t.scrollDOM);let f=(this.printing?sc:nc)(e,this.paddingTop),p=f.top-this.pixelViewport.top,m=f.bottom-this.pixelViewport.bottom;this.pixelViewport=f;let g=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(g!=this.inView&&(this.inView=g,g&&(a=!0)),!this.inView&&!this.scrollTarget&&!function(t){let e=t.getBoundingClientRect(),i=t.ownerDocument.defaultView||window;return e.left<i.innerWidth&&e.right>0&&e.top<i.innerHeight&&e.bottom>0}(t.dom))return 0;let v=r.width;if(this.contentDOMWidth==v&&this.editorHeight==t.scrollDOM.clientHeight||(this.contentDOMWidth=r.width,this.editorHeight=t.scrollDOM.clientHeight,l|=16),a){let e=t.docView.measureVisibleLineHeights(this.viewport);if(n.mustRefreshForHeights(e)&&(o=!0),o||n.lineWrapping&&Math.abs(v-this.contentDOMWidth)>n.charWidth){let{lineHeight:i,charWidth:r,textHeight:a}=t.docView.measureTextSize();o=i>0&&n.refresh(s,i,r,a,Math.max(5,v/r),e),o&&(t.docView.minWidth=0,l|=16)}p>0&&m>0?c=Math.max(p,m):p<0&&m<0&&(c=Math.min(p,m)),ql();for(let i of this.viewports){let s=i.from==this.viewport.from?e:t.docView.measureVisibleLineHeights(i);this.heightMap=(o?Vl.empty().applyChanges(this.stateDeco,Rn.empty,this.heightOracle,[new Ba(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(n,0,o,new Fl(i.from,s))}Bl&&(l|=2)}let y=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return y&&(2&l&&(l|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),l|=this.updateForViewport()),(2&l||y)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,t)),l|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),l}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),n=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:r}=this,a=new lc(n.lineAt(o-1e3*i,Hl.ByHeight,s,0,0).from,n.lineAt(r+1e3*(1-i),Hl.ByHeight,s,0,0).to);if(e){let{head:t}=e.range;if(t<a.from||t>a.to){let i,o=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),r=n.lineAt(t,Hl.ByPos,s,0,0);i="center"==e.y?(r.top+r.bottom)/2-o/2:"start"==e.y||"nearest"==e.y&&t<a.from?r.top:r.bottom-o,a=new lc(n.lineAt(i-500,Hl.ByHeight,s,0,0).from,n.lineAt(i+o+500,Hl.ByHeight,s,0,0).to)}}return a}mapViewport(t,e){let i=e.mapPos(t.from,-1),n=e.mapPos(t.to,1);return new lc(this.heightMap.lineAt(i,Hl.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(n,Hl.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){if(!this.inView)return!0;let{top:n}=this.heightMap.lineAt(t,Hl.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(e,Hl.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:r}=this;return(0==t||n<=o-Math.max(10,Math.min(-i,250)))&&(e==this.state.doc.length||s>=r+Math.max(10,Math.min(i,250)))&&n>o-2e3&&s<r+2e3}mapLineGaps(t,e){if(!t.length||e.empty)return t;let i=[];for(let n of t)e.touchesRange(n.from,n.to)||i.push(new oc(e.mapPos(n.from),e.mapPos(n.to),n.size,n.displaySize));return i}ensureLineGaps(t,e){let i=this.heightOracle.lineWrapping,n=i?1e4:2e3,s=n>>1,o=n<<1;if(this.defaultTextDirection!=Fr.LTR&&!i)return[];let r=[],a=(n,o,l,c)=>{if(o-n<s)return;let h=this.state.selection.main,u=[h.from];h.empty||u.push(h.to);for(let t of u)if(t>n&&t<o)return a(n,t-10,l,c),void a(t+10,o,l,c);let d=function(t,e){for(let i of t)if(e(i))return i;return}(t,t=>t.from>=l.from&&t.to<=l.to&&Math.abs(t.from-n)<s&&Math.abs(t.to-o)<s&&!u.some(e=>t.from<e&&t.to>e));if(!d){if(o<l.to&&e&&i&&e.visibleRanges.some(t=>t.from<=o&&t.to>=o)){let t=e.moveToLineBoundary(rs.cursor(o),!1,!0).head;t>n&&(o=t)}let t=this.gapSize(l,n,o,c);d=new oc(n,o,t,i||t<2e6?t:2e6)}r.push(d)},l=e=>{if(e.length<o||e.type!=Ar.Text)return;let s=function(t,e,i){let n=[],s=t,o=0;no.spans(i,t,e,{span(){},point(t,e){t>s&&(n.push({from:s,to:t}),o+=t-s),s=e}},20),s<e&&(n.push({from:s,to:e}),o+=e-s);return{total:o,ranges:n}}(e.from,e.to,this.stateDeco);if(s.total<o)return;let r,l,c=this.scrollTarget?this.scrollTarget.range.head:null;if(i){let t,i,o=n/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=c){let n=hc(s,c),r=((this.visibleBottom-this.visibleTop)/2+o)/e.height;t=n-r,i=n+r}else t=(this.visibleTop-e.top-o)/e.height,i=(this.visibleBottom-e.top+o)/e.height;r=cc(s,t),l=cc(s,i)}else{let i=s.total*this.heightOracle.charWidth,o=n*this.heightOracle.charWidth,a=0;if(i>2e6)for(let i of t)i.from>=e.from&&i.from<e.to&&i.size!=i.displaySize&&i.from*this.heightOracle.charWidth+a<this.pixelViewport.left&&(a=i.size-i.displaySize);let h,u,d=this.pixelViewport.left+a,f=this.pixelViewport.right+a;if(null!=c){let t=hc(s,c),e=((f-d)/2+o)/i;h=t-e,u=t+e}else h=(d-o)/i,u=(f+o)/i;r=cc(s,h),l=cc(s,u)}r>e.from&&a(e.from,r,e,s),l<e.to&&a(l,e.to,e,s)};for(let t of this.viewportLines)Array.isArray(t.type)?t.type.forEach(l):l(t);return r}gapSize(t,e,i,n){let s=hc(n,i)-hc(n,e);return this.heightOracle.lineWrapping?t.height*s:n.total*this.heightOracle.charWidth*s}updateLineGaps(t){oc.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=Mr.set(t.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(t){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let i=[];no.spans(e,this.viewport.from,this.viewport.to,{span(t,e){i.push({from:t,to:e})},point(){}},20);let n=0;if(i.length!=this.visibleRanges.length)n=12;else for(let e=0;e<i.length&&!(8&n);e++){let s=this.visibleRanges[e],o=i[e];s.from==o.from&&s.to==o.to||(n|=4,t&&t.mapPos(s.from,-1)==o.from&&t.mapPos(s.to,1)==o.to||(n|=8))}return this.visibleRanges=i,n}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find(e=>e.from<=t&&e.to>=t)||fc(this.heightMap.lineAt(t,Hl.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return t>=this.viewportLines[0].top&&t<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(e=>e.top<=t&&e.bottom>=t)||fc(this.heightMap.lineAt(this.scaler.fromDOM(t),Hl.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(t){let e=this.lineBlockAtHeight(t+8);return e.from>=this.viewport.from||this.viewportLines[0].top-t>200?e:this.viewportLines[0]}elementAtHeight(t){return fc(this.heightMap.blockAt(this.scaler.fromDOM(t),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class lc{constructor(t,e){this.from=t,this.to=e}}function cc({total:t,ranges:e},i){if(i<=0)return e[0].from;if(i>=1)return e[e.length-1].to;let n=Math.floor(t*i);for(let t=0;;t++){let{from:i,to:s}=e[t],o=s-i;if(n<=o)return i+n;n-=o}}function hc(t,e){let i=0;for(let{from:n,to:s}of t.ranges){if(e<=s){i+=e-n;break}i+=s-n}return i/t.total}const uc={toDOM:t=>t,fromDOM:t=>t,scale:1,eq(t){return t==this}};class dc{constructor(t,e,i){let n=0,s=0,o=0;this.viewports=i.map(({from:i,to:s})=>{let o=e.lineAt(i,Hl.ByPos,t,0,0).top,r=e.lineAt(s,Hl.ByPos,t,0,0).bottom;return n+=r-o,{from:i,to:s,top:o,bottom:r,domTop:0,domBottom:0}}),this.scale=(7e6-n)/(e.height-n);for(let t of this.viewports)t.domTop=o+(t.top-s)*this.scale,o=t.domBottom=t.domTop+(t.bottom-t.top),s=t.bottom}toDOM(t){for(let e=0,i=0,n=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.top)return n+(t-i)*this.scale;if(t<=s.bottom)return s.domTop+(t-s.top);i=s.bottom,n=s.domBottom}}fromDOM(t){for(let e=0,i=0,n=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.domTop)return i+(t-n)/this.scale;if(t<=s.domBottom)return s.top+(t-s.domTop);i=s.bottom,n=s.domBottom}}eq(t){return t instanceof dc&&(this.scale==t.scale&&this.viewports.length==t.viewports.length&&this.viewports.every((e,i)=>e.from==t.viewports[i].from&&e.to==t.viewports[i].to))}}function fc(t,e){if(1==e.scale)return t;let i=e.toDOM(t.top),n=e.toDOM(t.bottom);return new Xl(t.from,t.length,i,n-i,Array.isArray(t._content)?t._content.map(t=>fc(t,e)):t._content)}const pc=cs.define({combine:t=>t.join(" ")}),mc=cs.define({combine:t=>t.indexOf(!0)>-1}),gc=xo.newName(),vc=xo.newName(),yc=xo.newName(),Oc={"&light":"."+vc,"&dark":"."+yc};function bc(t,e,i){return new xo(e,{finish:e=>/&/.test(e)?e.replace(/&\w*/,e=>{if("&"==e)return t;if(!i||!i[e])throw new RangeError(`Unsupported selector: ${e}`);return i[e]}):t+" "+e})}const xc=bc("."+gc,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Oc),wc={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},_c=gr.ie&&gr.ie_version<=11;class Sc{constructor(t){this.view=t,this.active=!1,this.editContext=null,this.selectionRange=new qo,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver(e=>{for(let t of e)this.queue.push(t);(gr.ie&&gr.ie_version<=11||gr.ios&&t.composing)&&e.some(t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length)?this.flushSoon():this.flush()}),!window.EditContext||!gr.android||!1===t.constructor.EDIT_CONTEXT||gr.chrome&&gr.chrome_version<126||(this.editContext=new Cc(t),t.state.facet($a)&&(t.contentDOM.editContext=this.editContext.editContext)),_c&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver(()=>{var t;(null===(t=this.view.docView)||void 0===t?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(t.scrollDOM)),this.addWindowListeners(this.win=t.win),this.start(),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(t){this.view.inputState.runHandlers("scroll",t),this.intersecting&&this.view.measure()}onScroll(t){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(t){("change"!=t.type&&t.type||t.matches)&&(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some((e,i)=>e!=t[i]))){this.gapIntersection.disconnect();for(let e of t)this.gapIntersection.observe(e);this.gaps=t}}onSelectionChange(t){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,n=this.selectionRange;if(i.state.facet($a)?i.root.activeElement!=this.dom:!Mo(this.dom,n))return;let s=n.anchorNode&&i.docView.nearest(n.anchorNode);s&&s.ignoreEvent(t)?e||(this.selectionChanged=!1):(gr.ie&&gr.ie_version<=11||gr.android&&gr.chrome)&&!i.state.selection.main.empty&&n.focusNode&&Do(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=Eo(t.root);if(!e)return!1;let i=gr.safari&&11==t.root.nodeType&&t.root.activeElement==this.dom&&function(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return $c(t,i)}let i=null;function n(t){t.preventDefault(),t.stopImmediatePropagation(),i=t.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",n,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",n,!0),i?$c(t,i):null}(this.view,e)||e;if(!i||this.selectionRange.eq(i))return!1;let n=Mo(this.dom,i);return n&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&function(t,e){let i=e.focusNode,n=e.focusOffset;if(!i||e.anchorNode!=i||e.anchorOffset!=n)return!1;for(n=Math.min(n,No(i));;)if(n){if(1!=i.nodeType)return!1;let t=i.childNodes[n-1];"false"==t.contentEditable?n--:(i=t,n=No(i))}else{if(i==t)return!0;n=Ro(i),i=i.parentNode}}(this.dom,i)?(this.view.inputState.lastFocusTime=0,t.docView.updateSelection(),!1):(this.selectionRange.setRange(i),n&&(this.selectionChanged=!0),!0)}setSelectionRange(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let t=0,e=null;for(let i=this.dom;i;)if(1==i.nodeType)!e&&t<this.scrollTargets.length&&this.scrollTargets[t]==i?t++:e||(e=this.scrollTargets.slice(0,t)),e&&e.push(i),i=i.assignedSlot||i.parentNode;else{if(11!=i.nodeType)break;i=i.host}if(t<this.scrollTargets.length&&!e&&(e=this.scrollTargets.slice(0,t)),e){for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);for(let t of this.scrollTargets=e)t.addEventListener("scroll",this.onScroll)}}ignore(t){if(!this.active)return t();try{return this.stop(),t()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,wc),_c&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),_c&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(t,e){var i;if(!this.delayedAndroidKey){let t=()=>{let t=this.delayedAndroidKey;if(t){this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=t.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&t.force&&Wo(this.dom,t.key,t.keyCode)}};this.flushingAndroidKey=this.view.win.requestAnimationFrame(t)}this.delayedAndroidKey&&"Enter"!=t||(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange<Date.now()-50||!!(null===(i=this.delayedAndroidKey)||void 0===i?void 0:i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,i=-1,n=!1;for(let s of t){let t=this.readMutation(s);t&&(t.typeOver&&(n=!0),-1==e?({from:e,to:i}=t):(e=Math.min(t.from,e),i=Math.max(t.to,i)))}return{from:e,to:i,typeOver:n}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords(),n=this.selectionChanged&&Mo(this.dom,this.selectionRange);if(t<0&&!n)return null;t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new cl(this.view,t,e,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return this.view.requestMeasure(),!1;let i=this.view.state,n=hl(this.view,e);return this.view.state==i&&(e.domChanged||e.newSel&&!e.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),n}readMutation(t){let e=this.view.docView.nearest(t.target);if(!e||e.ignoreMutation(t))return null;if(e.markDirty("attributes"==t.type),"attributes"==t.type&&(e.flags|=4),"childList"==t.type){let i=kc(e,t.previousSibling||t.target.previousSibling,-1),n=kc(e,t.nextSibling||t.target.nextSibling,1);return{from:i?e.posAfter(i):e.posAtStart,to:n?e.posBefore(n):e.posAtEnd,typeOver:!1}}return"characterData"==t.type?{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}:null}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}update(t){this.editContext&&(this.editContext.update(t),t.startState.facet($a)!=t.state.facet($a)&&(t.view.contentDOM.editContext=t.state.facet($a)?this.editContext.editContext:null))}destroy(){var t,e,i;this.stop(),null===(t=this.intersection)||void 0===t||t.disconnect(),null===(e=this.gapIntersection)||void 0===e||e.disconnect(),null===(i=this.resizeScroll)||void 0===i||i.disconnect();for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function kc(t,e,i){for(;e;){let n=tr.get(e);if(n&&n.parent==t)return n;let s=e.parentNode;e=s!=t.dom?s:i>0?e.nextSibling:e.previousSibling}return null}function $c(t,e){let i=e.startContainer,n=e.startOffset,s=e.endContainer,o=e.endOffset,r=t.docView.domAtPos(t.state.selection.main.anchor);return Do(r.node,r.offset,s,o)&&([i,n,s,o]=[s,o,i,n]),{anchorNode:i,anchorOffset:n,focusNode:s,focusOffset:o}}class Cc{constructor(t){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(t.state);let e=this.editContext=new window.EditContext({text:t.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,t.state.selection.main.anchor))),selectionEnd:this.toContextPos(t.state.selection.main.head)});this.handlers.textupdate=e=>{let i=t.state.selection.main,{anchor:n,head:s}=i,o=this.toEditorPos(e.updateRangeStart),r=this.toEditorPos(e.updateRangeEnd);t.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:e.updateRangeStart,editorBase:o,drifted:!1});let a={from:o,to:r,insert:Rn.of(e.text.split("\n"))};if(a.from==this.from&&n<this.from?a.from=n:a.to==this.to&&n>this.to&&(a.to=n),a.from==a.to&&!a.insert.length){let n=rs.single(this.toEditorPos(e.selectionStart),this.toEditorPos(e.selectionEnd));return void(n.main.eq(i)||t.dispatch({selection:n,userEvent:"select"}))}if((gr.mac||gr.android)&&a.from==s-1&&/^\. ?$/.test(e.text)&&"off"==t.contentDOM.getAttribute("autocorrect")&&(a={from:o,to:r,insert:Rn.of([e.text.replace("."," ")])}),this.pendingContextChange=a,!t.state.readOnly){let i=this.to-this.from+(a.to-a.from+a.insert.length);ul(t,a,rs.single(this.toEditorPos(e.selectionStart,i),this.toEditorPos(e.selectionEnd,i)))}this.pendingContextChange&&(this.revertPending(t.state),this.setSelection(t.state))},this.handlers.characterboundsupdate=i=>{let n=[],s=null;for(let e=this.toEditorPos(i.rangeStart),o=this.toEditorPos(i.rangeEnd);e<o;e++){let i=t.coordsForChar(e);s=i&&new DOMRect(i.left,i.top,i.right-i.left,i.bottom-i.top)||s||new DOMRect,n.push(s)}e.updateCharacterBounds(i.rangeStart,n)},this.handlers.textformatupdate=e=>{let i=[];for(let t of e.getTextFormats()){let e=t.underlineStyle,n=t.underlineThickness;if("None"!=e&&"None"!=n){let s=this.toEditorPos(t.rangeStart),o=this.toEditorPos(t.rangeEnd);if(s<o){let t=`text-decoration: underline ${"Dashed"==e?"dashed ":"Squiggle"==e?"wavy ":""}${"Thin"==n?1:2}px`;i.push(Mr.mark({attributes:{style:t}}).range(s,o))}}}t.dispatch({effects:Sa.of(Mr.set(i))})},this.handlers.compositionstart=()=>{t.inputState.composing<0&&(t.inputState.composing=0,t.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(t.inputState.composing=-1,t.inputState.compositionFirstChange=null,this.composing){let{drifted:e}=this.composing;this.composing=null,e&&this.reset(t.state)}};for(let t in this.handlers)e.addEventListener(t,this.handlers[t]);this.measureReq={read:t=>{this.editContext.updateControlBounds(t.contentDOM.getBoundingClientRect());let e=Eo(t.root);e&&e.rangeCount&&this.editContext.updateSelectionBounds(e.getRangeAt(0).getBoundingClientRect())}}}applyEdits(t){let e=0,i=!1,n=this.pendingContextChange;return t.changes.iterChanges((s,o,r,a,l)=>{if(i)return;let c=l.length-(o-s);if(n&&o>=n.to){if(n.from==s&&n.to==o&&n.insert.eq(l))return n=this.pendingContextChange=null,e+=c,void(this.to+=c);n=null,this.revertPending(t.state)}if(s+=e,(o+=e)<=this.from)this.from+=c,this.to+=c;else if(s<this.to){if(s<this.from||o>this.to||this.to-this.from+l.length>3e4)return void(i=!0);this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),l.toString()),this.to+=c}e+=c}),n&&!i&&this.revertPending(t.state),!i}update(t){let e=this.pendingContextChange,i=t.startState.selection.main;this.composing&&(this.composing.drifted||!t.changes.touchesRange(i.from,i.to)&&t.transactions.some(t=>!t.isUserEvent("input.type")&&t.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=t.changes.mapPos(this.composing.editorBase)):this.applyEdits(t)&&this.rangeIsValid(t.state)?(t.docChanged||t.selectionSet||e)&&this.setSelection(t.state):(this.pendingContextChange=null,this.reset(t.state)),(t.geometryChanged||t.docChanged||t.selectionSet)&&t.view.requestMeasure(this.measureReq)}resetRange(t){let{head:e}=t.selection.main;this.from=Math.max(0,e-1e4),this.to=Math.min(t.doc.length,e+1e4)}reset(t){this.resetRange(t),this.editContext.updateText(0,this.editContext.text.length,t.doc.sliceString(this.from,this.to)),this.setSelection(t)}revertPending(t){let e=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(e.from),this.toContextPos(e.from+e.insert.length),t.doc.sliceString(e.from,e.to))}setSelection(t){let{main:e}=t.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,e.anchor))),n=this.toContextPos(e.head);this.editContext.selectionStart==i&&this.editContext.selectionEnd==n||this.editContext.updateSelection(i,n)}rangeIsValid(t){let{head:e}=t.selection.main;return!(this.from>0&&e-this.from<500||this.to<t.doc.length&&this.to-e<500||this.to-this.from>3e4)}toEditorPos(t,e=this.to-this.from){t=Math.min(t,e);let i=this.composing;return i&&i.drifted?i.editorBase+(t-i.contextBase):t+this.from}toContextPos(t){let e=this.composing;return e&&e.drifted?e.contextBase+(t-e.editorBase):t-this.from}destroy(){for(let t in this.handlers)this.editContext.removeEventListener(t,this.handlers[t])}}class Tc{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(t={}){var e;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),t.parent&&t.parent.appendChild(this.dom);let{dispatch:i}=t;this.dispatchTransactions=t.dispatchTransactions||i&&(t=>t.forEach(t=>i(t,this)))||(t=>this.update(t)),this.dispatch=this.dispatch.bind(this),this._root=t.root||function(t){for(;t;){if(t&&(9==t.nodeType||11==t.nodeType&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}(t.parent)||document,this.viewState=new ac(t.state||Gs.create(t)),t.scrollTo&&t.scrollTo.is(_a)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Ta).map(t=>new Ea(t));for(let t of this.plugins)t.update(this);this.observer=new Sc(this),this.inputState=new dl(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Za(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),(null===(e=document.fonts)||void 0===e?void 0:e.ready)&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...t){let e=1==t.length&&t[0]instanceof zs?t:1==t.length&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(e,this)}update(t){if(0!=this.updateState)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let e,i=!1,n=!1,s=this.state;for(let e of t){if(e.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=e.state}if(this.destroyed)return void(this.viewState.state=s);let o=this.hasFocus,r=0,a=null;t.some(t=>t.annotation(Il))?(this.inputState.notifiedFocused=o,r=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=Ll(s,o),a||(r=1));let l=this.observer.delayedAndroidKey,c=null;if(l?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(c=null)):this.observer.clear(),s.facet(Gs.phrases)!=this.state.facet(Gs.phrases))return this.setState(s);e=qa.create(this,s,t),e.flags|=r;let h=this.viewState.scrollTarget;try{this.updateState=2;for(let e of t){if(h&&(h=h.map(e.changes)),e.scrollIntoView){let{main:t}=e.state.selection;h=new wa(t.empty?t:rs.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(_a)&&(h=t.value.clip(this.state))}this.viewState.update(e,h),this.bidiCache=Ac.update(this.bidiCache,e.changes),e.empty||(this.updatePlugins(e),this.inputState.update(e)),i=this.docView.update(e),this.state.facet(za)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(i,t.some(t=>t.isUserEvent("select.pointer")))}finally{this.updateState=0}if(e.startState.facet(pc)!=e.state.facet(pc)&&(this.viewState.mustMeasureContent=!0),(i||n||h||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),i&&this.docViewUpdate(),!e.empty)for(let t of this.state.facet(pa))try{t(e)}catch(t){ka(this.state,t,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!hl(this,c)&&l.force&&Wo(this.contentDOM,l.key,l.keyCode)})}setState(t){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed)return void(this.viewState.state=t);this.updateState=2;let e=this.hasFocus;try{for(let t of this.plugins)t.destroy(this);this.viewState=new ac(t),this.plugins=t.facet(Ta).map(t=>new Ea(t)),this.pluginMap.clear();for(let t of this.plugins)t.update(this);this.docView.destroy(),this.docView=new Za(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(Ta),i=t.state.facet(Ta);if(e!=i){let n=[];for(let s of i){let i=e.indexOf(s);if(i<0)n.push(new Ea(s));else{let e=this.plugins[i];e.mustUpdate=t,n.push(e)}}for(let e of this.plugins)e.mustUpdate!=t&&e.destroy(this);this.plugins=n,this.pluginMap.clear()}else for(let e of this.plugins)e.mustUpdate=t;for(let t=0;t<this.plugins.length;t++)this.plugins[t].update(this);e!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let t of this.plugins){let e=t.value;if(e&&e.docViewUpdate)try{e.docViewUpdate(this)}catch(t){ka(this.state,t,"doc view update listener")}}}measure(t=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey)return this.measureScheduled=-1,void this.requestMeasure();this.measureScheduled=0,t&&this.observer.forceFlush();let e=null,i=this.scrollDOM,n=i.scrollTop*this.scaleY,{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(n-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let t=0;;t++){if(o<0)if(Yo(i))s=-1,o=this.viewState.heightMap.height;else{let t=this.viewState.scrollAnchorAt(n);s=t.from,o=t.top}this.updateState=1;let r=this.viewState.measure(this);if(!r&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(t>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let a=[];4&r||([this.measureRequests,a]=[a,this.measureRequests]);let l=a.map(t=>{try{return t.read(this)}catch(t){return ka(this.state,t),Ec}}),c=qa.create(this,this.state,[]),h=!1;c.flags|=r,e?e.flags|=r:e=c,this.updateState=2,c.empty||(this.updatePlugins(c),this.inputState.update(c),this.updateAttrs(),h=this.docView.update(c),h&&this.docViewUpdate());for(let t=0;t<a.length;t++)if(l[t]!=Ec)try{let e=a[t];e.write&&e.write(l[t],this)}catch(t){ka(this.state,t)}if(h&&this.docView.updateSelection(!0),!c.viewportChanged&&0==this.measureRequests.length){if(this.viewState.editorHeight){if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}{let t=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-o;if(t>1||t<-1){n+=t,i.scrollTop=n/this.scaleY,o=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let t of this.state.facet(pa))t(e)}get themeClasses(){return gc+" "+(this.state.facet(mc)?yc:vc)+" "+this.state.facet(pc)}updateAttrs(){let t=Mc(this,Aa,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet($a)?"true":"false",class:"cm-content",style:`${gr.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),Mc(this,Ma,e);let i=this.observer.ignore(()=>{let i=Tr(this.contentDOM,this.contentAttrs,e),n=Tr(this.dom,this.editorAttrs,t);return i||n});return this.editorAttrs=t,this.contentAttrs=e,i}showAnnouncements(t){let e=!0;for(let i of t)for(let t of i.effects)if(t.is(Tc.announce)){e&&(this.announceDOM.textContent=""),e=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(za);let t=this.state.facet(Tc.cspNonce);xo.mount(this.root,this.styleModules.concat(xc).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(2==this.updateState)throw new Error("Reading the editor layout isn't allowed during an update");0==this.updateState&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(t){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),t){if(this.measureRequests.indexOf(t)>-1)return;if(null!=t.key)for(let e=0;e<this.measureRequests.length;e++)if(this.measureRequests[e].key===t.key)return void(this.measureRequests[e]=t);this.measureRequests.push(t)}}plugin(t){let e=this.pluginMap.get(t);return(void 0===e||e&&e.plugin!=t)&&this.pluginMap.set(t,e=this.plugins.find(e=>e.plugin==t)||null),e&&e.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,i){return sl(this,t,il(this,t,e,i))}moveByGroup(t,e){return sl(this,t,il(this,t,e,e=>function(t,e,i){let n=t.state.charCategorizer(e),s=n(i);return t=>{let e=n(t);return s==Ws.Space&&(s=e),s==e}}(this,t.head,e)))}visualLineSide(t,e){let i=this.bidiSpans(t),n=this.textDirectionAt(t.from),s=i[e?i.length-1:0];return rs.cursor(s.side(e,n)+t.from,s.forward(!e,n)?1:-1)}moveToLineBoundary(t,e,i=!0){return function(t,e,i,n){let s=el(t,e.head,e.assoc||-1),o=n&&s.type==Ar.Text&&(t.lineWrapping||s.widgetLineBreaks)?t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head):null;if(o){let e=t.dom.getBoundingClientRect(),n=t.textDirectionAt(s.from),r=t.posAtCoords({x:i==(n==Fr.LTR)?e.right-1:e.left+1,y:(o.top+o.bottom)/2});if(null!=r)return rs.cursor(r,i?-1:1)}return rs.cursor(i?s.to:s.from,i?-1:1)}(this,t,e,i)}moveVertically(t,e,i){return sl(this,t,function(t,e,i,n){let s=e.head,o=i?1:-1;if(s==(i?t.state.doc.length:0))return rs.cursor(s,e.assoc);let r,a=e.goalColumn,l=t.contentDOM.getBoundingClientRect(),c=t.coordsAtPos(s,e.assoc||-1),h=t.documentTop;if(c)null==a&&(a=c.left-l.left),r=o<0?c.top:c.bottom;else{let e=t.viewState.lineBlockAt(s);null==a&&(a=Math.min(l.right-l.left,t.defaultCharacterWidth*(s-e.from))),r=(o<0?e.top:e.bottom)+h}let u=l.left+a,d=null!=n?n:t.viewState.heightOracle.textHeight>>1;for(let e=0;;e+=10){let i=r+(d+e)*o,n=Ja(t,{x:u,y:i},!1,o);if(i<l.top||i>l.bottom||(o<0?n<s:n>s)){let e=t.docView.coordsForChar(n),s=!e||i<e.top?-1:1;return rs.cursor(n,s,void 0,a)}}}(this,t,e,i))}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){return this.readMeasured(),Ja(this,t,e)}coordsAtPos(t,e=1){this.readMeasured();let i=this.docView.coordsAt(t,e);if(!i||i.left==i.right)return i;let n=this.state.doc.lineAt(t),s=this.bidiSpans(n);return jo(i,s[ta.find(s,t-n.from,-1,e)].dir==Fr.LTR==e>0)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(Oa)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>Pc)return ra(t.length);let e,i=this.textDirectionAt(t.from);for(let n of this.bidiCache)if(n.from==t.from&&n.dir==i&&(n.fresh||ea(n.isolates,e=La(this,t))))return n.order;e||(e=La(this,t));let n=oa(t.text,i,e);return this.bidiCache.push(new Ac(t.from,t.to,i,e,!0,n)),n}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||gr.safari&&(null===(t=this.inputState)||void 0===t?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Xo(this.contentDOM),this.docView.updateSelection()})}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((9==t.nodeType?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,e={}){return _a.of(new wa("number"==typeof t?rs.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}scrollSnapshot(){let{scrollTop:t,scrollLeft:e}=this.scrollDOM,i=this.viewState.scrollAnchorAt(t);return _a.of(new wa(rs.cursor(i.from),"start","start",i.top-t,e,!0))}setTabFocusMode(t){null==t?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:"boolean"==typeof t?this.inputState.tabFocusMode=t?0:-1:0!=this.inputState.tabFocusMode&&(this.inputState.tabFocusMode=Date.now()+t)}static domEventHandlers(t){return Pa.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return Pa.define(()=>({}),{eventObservers:t})}static theme(t,e){let i=xo.newName(),n=[pc.of(i),za.of(bc(`.${i}`,t))];return e&&e.dark&&n.push(mc.of(!0)),n}static baseTheme(t){return ws.lowest(za.of(bc("."+gc,t,Oc)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),n=i&&tr.get(i)||tr.get(t);return(null===(e=null==n?void 0:n.rootView)||void 0===e?void 0:e.view)||null}}Tc.styleModule=za,Tc.inputHandler=ma,Tc.clipboardInputFilter=va,Tc.clipboardOutputFilter=ya,Tc.scrollHandler=xa,Tc.focusChangeEffect=ga,Tc.perLineTextDirection=Oa,Tc.exceptionSink=fa,Tc.updateListener=pa,Tc.editable=$a,Tc.mouseSelectionStyle=da,Tc.dragMovesSelection=ua,Tc.clickAddsSelectionRange=ha,Tc.decorations=Qa,Tc.outerDecorations=Da,Tc.atomicRanges=Ra,Tc.bidiIsolatedRanges=Ia,Tc.scrollMargins=Na,Tc.darkTheme=mc,Tc.cspNonce=cs.define({combine:t=>t.length?t[0]:""}),Tc.contentAttributes=Ma,Tc.editorAttributes=Aa,Tc.lineWrapping=Tc.contentAttributes.of({class:"cm-lineWrapping"}),Tc.announce=js.define();const Pc=4096,Ec={};class Ac{constructor(t,e,i,n,s,o){this.from=t,this.to=e,this.dir=i,this.isolates=n,this.fresh=s,this.order=o}static update(t,e){if(e.empty&&!t.some(t=>t.fresh))return t;let i=[],n=t.length?t[t.length-1].dir:Fr.LTR;for(let s=Math.max(0,t.length-10);s<t.length;s++){let o=t[s];o.dir!=n||e.touchesRange(o.from,o.to)||i.push(new Ac(e.mapPos(o.from,1),e.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return i}}function Mc(t,e,i){for(let n=t.state.facet(e),s=n.length-1;s>=0;s--){let e=n[s],o="function"==typeof e?e(t):e;o&&kr(o,i)}return i}const Qc=gr.mac?"mac":gr.windows?"win":gr.linux?"linux":"key";function Dc(t,e,i){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),!1!==i&&e.shiftKey&&(t="Shift-"+t),t}const Rc=ws.default(Tc.domEventHandlers({keydown:(t,e)=>qc(Nc(e.state),t,e,"editor")})),Ic=cs.define({enables:Rc}),Lc=new WeakMap;function Nc(t){let e=t.facet(Ic),i=Lc.get(e);return i||Lc.set(e,i=function(t,e=Qc){let i=Object.create(null),n=Object.create(null),s=(t,e)=>{let i=n[t];if(null==i)n[t]=e;else if(i!=e)throw new Error("Key binding "+t+" is used both as a regular binding and as a multi-stroke prefix")},o=(t,n,o,r,a)=>{var l,c;let h=i[t]||(i[t]=Object.create(null)),u=n.split(/ (?!$)/).map(t=>function(t,e){const i=t.split(/-(?!$)/);let n,s,o,r,a=i[i.length-1];"Space"==a&&(a=" ");for(let t=0;t<i.length-1;++t){const a=i[t];if(/^(cmd|meta|m)$/i.test(a))r=!0;else if(/^a(lt)?$/i.test(a))n=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))o=!0;else{if(!/^mod$/i.test(a))throw new Error("Unrecognized modifier name: "+a);"mac"==e?r=!0:s=!0}}return n&&(a="Alt-"+a),s&&(a="Ctrl-"+a),r&&(a="Meta-"+a),o&&(a="Shift-"+a),a}(t,e));for(let e=1;e<u.length;e++){let i=u.slice(0,e).join(" ");s(i,!0),h[i]||(h[i]={preventDefault:!0,stopPropagation:!1,run:[e=>{let n=jc={view:e,prefix:i,scope:t};return setTimeout(()=>{jc==n&&(jc=null)},zc),!0}]})}let d=u.join(" ");s(d,!1);let f=h[d]||(h[d]={preventDefault:!1,stopPropagation:!1,run:(null===(c=null===(l=h._any)||void 0===l?void 0:l.run)||void 0===c?void 0:c.slice())||[]});o&&f.run.push(o),r&&(f.preventDefault=!0),a&&(f.stopPropagation=!0)};for(let n of t){let t=n.scope?n.scope.split(" "):["editor"];if(n.any)for(let e of t){let t=i[e]||(i[e]=Object.create(null));t._any||(t._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:s}=n;for(let e in t)t[e].run.push(t=>s(t,Bc))}let s=n[e]||n.key;if(s)for(let e of t)o(e,s,n.run,n.preventDefault,n.stopPropagation),n.shift&&o(e,"Shift-"+s,n.shift,n.preventDefault,n.stopPropagation)}return i}(e.reduce((t,e)=>t.concat(e),[]))),i}let jc=null;const zc=4e3;let Bc=null;function qc(t,e,i,n){Bc=e;let s=function(t){var e=!($o&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Co&&t.shiftKey&&t.key&&1==t.key.length||"Unidentified"==t.key)&&t.key||(t.shiftKey?ko:So)[t.keyCode]||t.key||"Unidentified";return"Esc"==e&&(e="Escape"),"Del"==e&&(e="Delete"),"Left"==e&&(e="ArrowLeft"),"Up"==e&&(e="ArrowUp"),"Right"==e&&(e="ArrowRight"),"Down"==e&&(e="ArrowDown"),e}(e),o=Vn(Hn(s,0))==s.length&&" "!=s,r="",a=!1,l=!1,c=!1;jc&&jc.view==i&&jc.scope==n&&(r=jc.prefix+" ",vl.indexOf(e.keyCode)<0&&(l=!0,jc=null));let h,u,d=new Set,f=t=>{if(t){for(let e of t.run)if(!d.has(e)&&(d.add(e),e(i)))return t.stopPropagation&&(c=!0),!0;t.preventDefault&&(t.stopPropagation&&(c=!0),l=!0)}return!1},p=t[n];return p&&(f(p[r+Dc(s,e,!o)])?a=!0:!o||!(e.altKey||e.metaKey||e.ctrlKey)||gr.windows&&e.ctrlKey&&e.altKey||gr.mac&&e.altKey&&!e.ctrlKey||!(h=So[e.keyCode])||h==s?o&&e.shiftKey&&f(p[r+Dc(s,e,!0)])&&(a=!0):(f(p[r+Dc(h,e,!0)])||e.shiftKey&&(u=ko[e.keyCode])!=s&&u!=h&&f(p[r+Dc(u,e,!1)]))&&(a=!0),!a&&f(p._any)&&(a=!0)),l&&(a=!0),a&&c&&e.stopPropagation(),Bc=null,a}class Zc{constructor(t,e,i,n,s){this.className=t,this.left=e,this.top=i,this.width=n,this.height=s}draw(){let t=document.createElement("div");return t.className=this.className,this.adjust(t),t}update(t,e){return e.className==this.className&&(this.adjust(t),!0)}adjust(t){t.style.left=this.left+"px",t.style.top=this.top+"px",null!=this.width&&(t.style.width=this.width+"px"),t.style.height=this.height+"px"}eq(t){return this.left==t.left&&this.top==t.top&&this.width==t.width&&this.height==t.height&&this.className==t.className}static forRange(t,e,i){if(i.empty){let n=t.coordsAtPos(i.head,i.assoc||1);if(!n)return[];let s=Fc(t);return[new Zc(e,n.left-s.left,n.top-s.top,null,n.bottom-n.top)]}return function(t,e,i){if(i.to<=t.viewport.from||i.from>=t.viewport.to)return[];let n=Math.max(i.from,t.viewport.from),s=Math.min(i.to,t.viewport.to),o=t.textDirection==Fr.LTR,r=t.contentDOM,a=r.getBoundingClientRect(),l=Fc(t),c=r.querySelector(".cm-line"),h=c&&window.getComputedStyle(c),u=a.left+(h?parseInt(h.paddingLeft)+Math.min(0,parseInt(h.textIndent)):0),d=a.right-(h?parseInt(h.paddingRight):0),f=el(t,n,1),p=el(t,s,-1),m=f.type==Ar.Text?f:null,g=p.type==Ar.Text?p:null;m&&(t.lineWrapping||f.widgetLineBreaks)&&(m=Xc(t,n,1,m));g&&(t.lineWrapping||p.widgetLineBreaks)&&(g=Xc(t,s,-1,g));if(m&&g&&m.from==g.from&&m.to==g.to)return y(O(i.from,i.to,m));{let e=m?O(i.from,null,m):b(f,!1),n=g?O(null,i.to,g):b(p,!0),s=[];return(m||f).to<(g||p).from-(m&&g?1:0)||f.widgetLineBreaks>1&&e.bottom+t.defaultLineHeight/2<n.top?s.push(v(u,e.bottom,d,n.top)):e.bottom<n.top&&t.elementAtHeight((e.bottom+n.top)/2).type==Ar.Text&&(e.bottom=n.top=(e.bottom+n.top)/2),y(e).concat(s).concat(y(n))}function v(t,i,n,s){return new Zc(e,t-l.left,i-l.top,n-t,s-i)}function y({top:t,bottom:e,horizontal:i}){let n=[];for(let s=0;s<i.length;s+=2)n.push(v(i[s],t,i[s+1],e));return n}function O(e,i,n){let s=1e9,r=-1e9,a=[];function l(e,i,l,c,h){let f=t.coordsAtPos(e,e==n.to?-2:2),p=t.coordsAtPos(l,l==n.from?2:-2);f&&p&&(s=Math.min(f.top,p.top,s),r=Math.max(f.bottom,p.bottom,r),h==Fr.LTR?a.push(o&&i?u:f.left,o&&c?d:p.right):a.push(!o&&c?u:p.left,!o&&i?d:f.right))}let c=null!=e?e:n.from,h=null!=i?i:n.to;for(let n of t.visibleRanges)if(n.to>c&&n.from<h)for(let s=Math.max(n.from,c),o=Math.min(n.to,h);;){let n=t.state.doc.lineAt(s);for(let r of t.bidiSpans(n)){let t=r.from+n.from,a=r.to+n.from;if(t>=o)break;a>s&&l(Math.max(t,s),null==e&&t<=c,Math.min(a,o),null==i&&a>=h,r.dir)}if(s=n.to+1,s>=o)break}return 0==a.length&&l(c,null==e,h,null==i,t.textDirection),{top:s,bottom:r,horizontal:a}}function b(t,e){let i=a.top+(e?t.top:t.bottom);return{top:i,bottom:i,horizontal:[]}}}(t,e,i)}}function Fc(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Fr.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function Xc(t,e,i,n){let s=t.coordsAtPos(e,2*i);if(!s)return n;let o=t.dom.getBoundingClientRect(),r=(s.top+s.bottom)/2,a=t.posAtCoords({x:o.left+1,y:r}),l=t.posAtCoords({x:o.right-1,y:r});return null==a||null==l?n:{from:Math.max(n.from,Math.min(a,l)),to:Math.min(n.to,Math.max(a,l))}}class Hc{constructor(t,e){this.view=t,this.layer=e,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=t.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),e.above&&this.dom.classList.add("cm-layer-above"),e.class&&this.dom.classList.add(e.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(t.state),t.requestMeasure(this.measureReq),e.mount&&e.mount(this.dom,t)}update(t){t.startState.facet(Wc)!=t.state.facet(Wc)&&this.setOrder(t.state),(this.layer.update(t,this.dom)||t.geometryChanged)&&(this.scale(),t.view.requestMeasure(this.measureReq))}docViewUpdate(t){!1!==this.layer.updateOnDocViewUpdate&&t.requestMeasure(this.measureReq)}setOrder(t){let e=0,i=t.facet(Wc);for(;e<i.length&&i[e]!=this.layer;)e++;this.dom.style.zIndex=String((this.layer.above?150:-1)-e)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:t,scaleY:e}=this.view;t==this.scaleX&&e==this.scaleY||(this.scaleX=t,this.scaleY=e,this.dom.style.transform=`scale(${1/t}, ${1/e})`)}draw(t){if(t.length!=this.drawn.length||t.some((t,e)=>{return i=t,n=this.drawn[e],!(i.constructor==n.constructor&&i.eq(n));var i,n})){let e=this.dom.firstChild,i=0;for(let n of t)n.update&&e&&n.constructor&&this.drawn[i].constructor&&n.update(e,this.drawn[i])?(e=e.nextSibling,i++):this.dom.insertBefore(n.draw(),e);for(;e;){let t=e.nextSibling;e.remove(),e=t}this.drawn=t}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const Wc=cs.define();function Vc(t){return[Pa.define(e=>new Hc(e,t)),Wc.of(t)]}const Yc=cs.define({combine:t=>Ks(t,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,e)=>Math.min(t,e),drawRangeCursor:(t,e)=>t||e})});function Uc(t={}){return[Yc.of(t),Kc,th,eh,ba.of(!0)]}function Gc(t){return t.startState.facet(Yc)!=t.state.facet(Yc)}const Kc=Vc({above:!0,markers(t){let{state:e}=t,i=e.facet(Yc),n=[];for(let s of e.selection.ranges){let o=s==e.selection.main;if(s.empty||i.drawRangeCursor){let e=o?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",i=s.empty?s:rs.cursor(s.head,s.head>s.anchor?-1:1);for(let s of Zc.forRange(t,e,i))n.push(s)}}return n},update(t,e){t.transactions.some(t=>t.selection)&&(e.style.animationName="cm-blink"==e.style.animationName?"cm-blink2":"cm-blink");let i=Gc(t);return i&&Jc(t.state,e),t.docChanged||t.selectionSet||i},mount(t,e){Jc(e.state,t)},class:"cm-cursorLayer"});function Jc(t,e){e.style.animationDuration=t.facet(Yc).cursorBlinkRate+"ms"}const th=Vc({above:!1,markers:t=>t.state.selection.ranges.map(e=>e.empty?[]:Zc.forRange(t,"cm-selectionBackground",e)).reduce((t,e)=>t.concat(e)),update:(t,e)=>t.docChanged||t.selectionSet||t.viewportChanged||Gc(t),class:"cm-selectionLayer"}),eh=ws.highest(Tc.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),ih=js.define({map:(t,e)=>null==t?null:e.mapPos(t)}),nh=gs.define({create:()=>null,update:(t,e)=>(null!=t&&(t=e.changes.mapPos(t)),e.effects.reduce((t,e)=>e.is(ih)?e.value:t,t))}),sh=Pa.fromClass(class{constructor(t){this.view=t,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(t){var e;let i=t.state.field(nh);null==i?null!=this.cursor&&(null===(e=this.cursor)||void 0===e||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(t.startState.field(nh)!=i||t.docChanged||t.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:t}=this,e=t.state.field(nh),i=null!=e&&t.coordsAtPos(e);if(!i)return null;let n=t.scrollDOM.getBoundingClientRect();return{left:i.left-n.left+t.scrollDOM.scrollLeft*t.scaleX,top:i.top-n.top+t.scrollDOM.scrollTop*t.scaleY,height:i.bottom-i.top}}drawCursor(t){if(this.cursor){let{scaleX:e,scaleY:i}=this.view;t?(this.cursor.style.left=t.left/e+"px",this.cursor.style.top=t.top/i+"px",this.cursor.style.height=t.height/i+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(t){this.view.state.field(nh)!=t&&this.view.dispatch({effects:ih.of(t)})}},{eventObservers:{dragover(t){this.setDropPos(this.view.posAtCoords({x:t.clientX,y:t.clientY}))},dragleave(t){t.target!=this.view.contentDOM&&this.view.contentDOM.contains(t.relatedTarget)||this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function oh(t,e,i,n,s){e.lastIndex=0;for(let o,r=t.iterRange(i,n),a=i;!r.next().done;a+=r.value.length)if(!r.lineBreak)for(;o=e.exec(r.value);)s(a+o.index,o)}class rh{constructor(t){const{regexp:e,decoration:i,decorate:n,boundary:s,maxLength:o=1e3}=t;if(!e.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=e,n)this.addMatch=(t,e,i,s)=>n(s,i,i+t[0].length,t,e);else if("function"==typeof i)this.addMatch=(t,e,n,s)=>{let o=i(t,e,n);o&&s(n,n+t[0].length,o)};else{if(!i)throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.addMatch=(t,e,n,s)=>s(n,n+t[0].length,i)}this.boundary=s,this.maxLength=o}createDeco(t){let e=new so,i=e.add.bind(e);for(let{from:e,to:n}of function(t,e){let i=t.visibleRanges;if(1==i.length&&i[0].from==t.viewport.from&&i[0].to==t.viewport.to)return i;let n=[];for(let{from:s,to:o}of i)s=Math.max(t.state.doc.lineAt(s).from,s-e),o=Math.min(t.state.doc.lineAt(o).to,o+e),n.length&&n[n.length-1].to>=s?n[n.length-1].to=o:n.push({from:s,to:o});return n}(t,this.maxLength))oh(t.state.doc,this.regexp,e,n,(e,n)=>this.addMatch(n,t,e,i));return e.finish()}updateDeco(t,e){let i=1e9,n=-1;return t.docChanged&&t.changes.iterChanges((e,s,o,r)=>{r>=t.view.viewport.from&&o<=t.view.viewport.to&&(i=Math.min(o,i),n=Math.max(r,n))}),t.viewportMoved||n-i>1e3?this.createDeco(t.view):n>-1?this.updateRange(t.view,e.map(t.changes),i,n):e}updateRange(t,e,i,n){for(let s of t.visibleRanges){let o=Math.max(s.from,i),r=Math.min(s.to,n);if(r>=o){let i=t.state.doc.lineAt(o),n=i.to<r?t.state.doc.lineAt(r):i,a=Math.max(s.from,i.from),l=Math.min(s.to,n.to);if(this.boundary){for(;o>i.from;o--)if(this.boundary.test(i.text[o-1-i.from])){a=o;break}for(;r<n.to;r++)if(this.boundary.test(n.text[r-n.from])){l=r;break}}let c,h=[],u=(t,e,i)=>h.push(i.range(t,e));if(i==n)for(this.regexp.lastIndex=a-i.from;(c=this.regexp.exec(i.text))&&c.index<l-i.from;)this.addMatch(c,t,c.index+i.from,u);else oh(t.state.doc,this.regexp,a,l,(e,i)=>this.addMatch(i,t,e,u));e=e.update({filterFrom:a,filterTo:l,filter:(t,e)=>t<a||e>l,add:h})}}return e}}const ah=null!=/x/.unicode?"gu":"g",lh=new RegExp("[\0-\b\n--Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\ufeff-]",ah),ch={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let hh=null;const uh=cs.define({combine(t){let e=Ks(t,{render:null,specialChars:lh,addSpecialChars:null});return(e.replaceTabs=!function(){var t;if(null==hh&&"undefined"!=typeof document&&document.body){let e=document.body.style;hh=null!=(null!==(t=e.tabSize)&&void 0!==t?t:e.MozTabSize)}return hh||!1}())&&(e.specialChars=new RegExp("\t|"+e.specialChars.source,ah)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,ah)),e}});function dh(t={}){return[uh.of(t),fh||(fh=Pa.fromClass(class{constructor(t){this.view=t,this.decorations=Mr.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(t.state.facet(uh)),this.decorations=this.decorator.createDeco(t)}makeDecorator(t){return new rh({regexp:t.specialChars,decoration:(e,i,n)=>{let{doc:s}=i.state,o=Hn(e[0],0);if(9==o){let t=s.lineAt(n),e=i.state.tabSize,o=go(t.text,e,n-t.from);return Mr.replace({widget:new mh((e-o%e)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[o]||(this.decorationCache[o]=Mr.replace({widget:new ph(t,o)}))},boundary:t.replaceTabs?void 0:/[^]/})}update(t){let e=t.state.facet(uh);t.startState.facet(uh)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(t.view)):this.decorations=this.decorator.updateDeco(t,this.decorations)}},{decorations:t=>t.decorations}))]}let fh=null;class ph extends Er{constructor(t,e){super(),this.options=t,this.code=e}eq(t){return t.code==this.code}toDOM(t){let e=function(t){return t>=32?"•":10==t?"␤":String.fromCharCode(9216+t)}(this.code),i=t.state.phrase("Control character")+" "+(ch[this.code]||"0x"+this.code.toString(16)),n=this.options.render&&this.options.render(this.code,i,e);if(n)return n;let s=document.createElement("span");return s.textContent=e,s.title=i,s.setAttribute("aria-label",i),s.className="cm-specialChar",s}ignoreEvent(){return!1}}class mh extends Er{constructor(t){super(),this.width=t}eq(t){return t.width==this.width}toDOM(){let t=document.createElement("span");return t.textContent="\t",t.className="cm-tab",t.style.width=this.width+"px",t}ignoreEvent(){return!1}}const gh=Mr.line({class:"cm-activeLine"}),vh=Pa.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,i=[];for(let n of t.state.selection.ranges){let s=t.lineBlockAt(n.head);s.from>e&&(i.push(gh.range(s.from)),e=s.from)}return Mr.set(i)}},{decorations:t=>t.decorations});const yh=2e3;function Oh(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1),n=t.state.doc.lineAt(i),s=i-n.from,o=s>yh?-1:s==n.length?function(t,e){let i=t.coordsAtPos(t.viewport.from);return i?Math.round(Math.abs((i.left-e)/t.defaultCharacterWidth)):-1}(t,e.clientX):go(n.text,t.state.tabSize,i-n.from);return{line:n.number,col:o,off:s}}function bh(t,e){let i=Oh(t,e),n=t.state.selection;return i?{update(t){if(t.docChanged){let e=t.changes.mapPos(t.startState.doc.line(i.line).from),s=t.state.doc.lineAt(e);i={line:s.number,col:i.col,off:Math.min(i.off,s.length)},n=n.map(t.changes)}},get(e,s,o){let r=Oh(t,e);if(!r)return n;let a=function(t,e,i){let n=Math.min(e.line,i.line),s=Math.max(e.line,i.line),o=[];if(e.off>yh||i.off>yh||e.col<0||i.col<0){let r=Math.min(e.off,i.off),a=Math.max(e.off,i.off);for(let e=n;e<=s;e++){let i=t.doc.line(e);i.length<=a&&o.push(rs.range(i.from+r,i.to+a))}}else{let r=Math.min(e.col,i.col),a=Math.max(e.col,i.col);for(let e=n;e<=s;e++){let i=t.doc.line(e),n=vo(i.text,r,t.tabSize,!0);if(n<0)o.push(rs.cursor(i.to));else{let e=vo(i.text,a,t.tabSize);o.push(rs.range(i.from+n,i.from+e))}}}return o}(t.state,i,r);return a.length?o?rs.create(a.concat(n.ranges)):rs.create(a):n}}:null}function xh(t){let e=(null==t?void 0:t.eventFilter)||(t=>t.altKey&&0==t.button);return Tc.mouseSelectionStyle.of((t,i)=>e(i)?bh(t,i):null)}const wh={Alt:[18,t=>!!t.altKey],Control:[17,t=>!!t.ctrlKey],Shift:[16,t=>!!t.shiftKey],Meta:[91,t=>!!t.metaKey]},_h={style:"cursor: crosshair"};function Sh(t={}){let[e,i]=wh[t.key||"Alt"],n=Pa.fromClass(class{constructor(t){this.view=t,this.isDown=!1}set(t){this.isDown!=t&&(this.isDown=t,this.view.update([]))}},{eventObservers:{keydown(t){this.set(t.keyCode==e||i(t))},keyup(t){t.keyCode!=e&&i(t)||this.set(!1)},mousemove(t){this.set(i(t))}}});return[n,Tc.contentAttributes.of(t=>{var e;return(null===(e=t.plugin(n))||void 0===e?void 0:e.isDown)?_h:null})]}const kh="-10000px";class $h{constructor(t,e,i,n){this.facet=e,this.createTooltipView=i,this.removeTooltipView=n,this.input=t.state.facet(e),this.tooltips=this.input.filter(t=>t);let s=null;this.tooltipViews=this.tooltips.map(t=>s=i(t,s))}update(t,e){var i;let n=t.state.facet(this.facet),s=n.filter(t=>t);if(n===this.input){for(let e of this.tooltipViews)e.update&&e.update(t);return!1}let o=[],r=e?[]:null;for(let i=0;i<s.length;i++){let n=s[i],a=-1;if(n){for(let t=0;t<this.tooltips.length;t++){let e=this.tooltips[t];e&&e.create==n.create&&(a=t)}if(a<0)o[i]=this.createTooltipView(n,i?o[i-1]:null),r&&(r[i]=!!n.above);else{let n=o[i]=this.tooltipViews[a];r&&(r[i]=e[a]),n.update&&n.update(t)}}}for(let t of this.tooltipViews)o.indexOf(t)<0&&(this.removeTooltipView(t),null===(i=t.destroy)||void 0===i||i.call(t));return e&&(r.forEach((t,i)=>e[i]=t),e.length=r.length),this.input=n,this.tooltips=s,this.tooltipViews=o,!0}}function Ch(t){let e=t.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const Th=cs.define({combine:t=>{var e,i,n;return{position:gr.ios?"absolute":(null===(e=t.find(t=>t.position))||void 0===e?void 0:e.position)||"fixed",parent:(null===(i=t.find(t=>t.parent))||void 0===i?void 0:i.parent)||null,tooltipSpace:(null===(n=t.find(t=>t.tooltipSpace))||void 0===n?void 0:n.tooltipSpace)||Ch}}}),Ph=new WeakMap,Eh=Pa.fromClass(class{constructor(t){this.view=t,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=t.state.facet(Th);this.position=e.position,this.parent=e.parent,this.classes=t.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver="function"==typeof ResizeObserver?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new $h(t,Dh,(t,e)=>this.createTooltip(t,e),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver="function"==typeof IntersectionObserver?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),t.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let t of this.manager.tooltipViews)this.intersectionObserver.observe(t.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(t){t.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(t,this.above);e&&this.observeIntersection();let i=e||t.geometryChanged,n=t.state.facet(Th);if(n.position!=this.position&&!this.madeAbsolute){this.position=n.position;for(let t of this.manager.tooltipViews)t.dom.style.position=this.position;i=!0}if(n.parent!=this.parent){this.parent&&this.container.remove(),this.parent=n.parent,this.createContainer();for(let t of this.manager.tooltipViews)this.container.appendChild(t.dom);i=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);i&&this.maybeMeasure()}createTooltip(t,e){let i=t.create(this.view),n=e?e.dom:null;if(i.dom.classList.add("cm-tooltip"),t.arrow&&!i.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let t=document.createElement("div");t.className="cm-tooltip-arrow",i.dom.appendChild(t)}return i.dom.style.position=this.position,i.dom.style.top=kh,i.dom.style.left="0px",this.container.insertBefore(i.dom,n),i.mount&&i.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(i.dom),i}destroy(){var t,e,i;this.view.win.removeEventListener("resize",this.measureSoon);for(let e of this.manager.tooltipViews)e.dom.remove(),null===(t=e.destroy)||void 0===t||t.call(e);this.parent&&this.container.remove(),null===(e=this.resizeObserver)||void 0===e||e.disconnect(),null===(i=this.intersectionObserver)||void 0===i||i.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=1,e=1,i=!1;if("fixed"==this.position&&this.manager.tooltipViews.length){let{dom:t}=this.manager.tooltipViews[0];if(gr.gecko)i=t.offsetParent!=this.container.ownerDocument.body;else if(t.style.top==kh&&"0px"==t.style.left){let e=t.getBoundingClientRect();i=Math.abs(e.top+1e4)>1||Math.abs(e.left)>1}}if(i||"absolute"==this.position)if(this.parent){let i=this.parent.getBoundingClientRect();i.width&&i.height&&(t=i.width/this.parent.offsetWidth,e=i.height/this.parent.offsetHeight)}else({scaleX:t,scaleY:e}=this.view.viewState);let n=this.view.scrollDOM.getBoundingClientRect(),s=ja(this.view);return{visible:{left:n.left+s.left,top:n.top+s.top,right:n.right-s.right,bottom:n.bottom-s.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((t,e)=>{let i=this.manager.tooltipViews[e];return i.getCoords?i.getCoords(t.pos):this.view.coordsAtPos(t.pos)}),size:this.manager.tooltipViews.map(({dom:t})=>t.getBoundingClientRect()),space:this.view.state.facet(Th).tooltipSpace(this.view),scaleX:t,scaleY:e,makeAbsolute:i}}writeMeasure(t){var e;if(t.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let t of this.manager.tooltipViews)t.dom.style.position="absolute"}let{visible:i,space:n,scaleX:s,scaleY:o}=t,r=[];for(let a=0;a<this.manager.tooltips.length;a++){let l=this.manager.tooltips[a],c=this.manager.tooltipViews[a],{dom:h}=c,u=t.pos[a],d=t.size[a];if(!u||!1!==l.clip&&(u.bottom<=Math.max(i.top,n.top)||u.top>=Math.min(i.bottom,n.bottom)||u.right<Math.max(i.left,n.left)-.1||u.left>Math.min(i.right,n.right)+.1)){h.style.top=kh;continue}let f=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=f?7:0,m=d.right-d.left,g=null!==(e=Ph.get(c))&&void 0!==e?e:d.bottom-d.top,v=c.offset||Qh,y=this.view.textDirection==Fr.LTR,O=d.width>n.right-n.left?y?n.left:n.right-d.width:y?Math.max(n.left,Math.min(u.left-(f?14:0)+v.x,n.right-m)):Math.min(Math.max(n.left,u.left-m+(f?14:0)-v.x),n.right-m),b=this.above[a];!l.strictSide&&(b?u.top-g-p-v.y<n.top:u.bottom+g+p+v.y>n.bottom)&&b==n.bottom-u.bottom>u.top-n.top&&(b=this.above[a]=!b);let x=(b?u.top-n.top:n.bottom-u.bottom)-p;if(x<g&&!1!==c.resize){if(x<this.view.defaultLineHeight){h.style.top=kh;continue}Ph.set(c,g),h.style.height=(g=x)/o+"px"}else h.style.height&&(h.style.height="");let w=b?u.top-g-p-v.y:u.bottom+p+v.y,_=O+m;if(!0!==c.overlap)for(let t of r)t.left<_&&t.right>O&&t.top<w+g&&t.bottom>w&&(w=b?t.top-g-2-p:t.bottom+p+2);if("absolute"==this.position?(h.style.top=(w-t.parent.top)/o+"px",Ah(h,(O-t.parent.left)/s)):(h.style.top=w/o+"px",Ah(h,O/s)),f){let t=u.left+(y?v.x:-v.x)-(O+14-7);f.style.left=t/s+"px"}!0!==c.overlap&&r.push({left:O,top:w,right:_,bottom:w+g}),h.classList.toggle("cm-tooltip-above",b),h.classList.toggle("cm-tooltip-below",!b),c.positioned&&c.positioned(t.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let t of this.manager.tooltipViews)t.dom.style.top=kh}},{eventObservers:{scroll(){this.maybeMeasure()}}});function Ah(t,e){let i=parseInt(t.style.left,10);(isNaN(i)||Math.abs(e-i)>1)&&(t.style.left=e+"px")}const Mh=Tc.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),Qh={x:0,y:0},Dh=cs.define({enables:[Eh,Mh]}),Rh=cs.define({combine:t=>t.reduce((t,e)=>t.concat(e),[])});class Ih{static create(t){return new Ih(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new $h(t,Rh,(t,e)=>this.createHostedView(t,e),t=>t.dom.remove())}createHostedView(t,e){let i=t.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,e?e.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}mount(t){for(let e of this.manager.tooltipViews)e.mount&&e.mount(t);this.mounted=!0}positioned(t){for(let e of this.manager.tooltipViews)e.positioned&&e.positioned(t)}update(t){this.manager.update(t)}destroy(){var t;for(let e of this.manager.tooltipViews)null===(t=e.destroy)||void 0===t||t.call(e)}passProp(t){let e;for(let i of this.manager.tooltipViews){let n=i[t];if(void 0!==n)if(void 0===e)e=n;else if(e!==n)return}return e}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const Lh=Dh.compute([Rh],t=>{let e=t.facet(Rh);return 0===e.length?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var e;return null!==(e=t.end)&&void 0!==e?e:t.pos})),create:Ih.create,above:e[0].above,arrow:e.some(t=>t.arrow)}});class Nh{constructor(t,e,i,n,s){this.view=t,this.source=e,this.field=i,this.setHover=n,this.hoverTime=s,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:t.dom,time:0},this.checkHover=this.checkHover.bind(this),t.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),t.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let t=Date.now()-this.lastMove.time;t<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-t):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:t,lastMove:e}=this,i=t.docView.nearest(e.target);if(!i)return;let n,s=1;if(i instanceof Or)n=i.posAtStart;else{if(n=t.posAtCoords(e),null==n)return;let i=t.coordsAtPos(n);if(!i||e.y<i.top||e.y>i.bottom||e.x<i.left-t.defaultCharacterWidth||e.x>i.right+t.defaultCharacterWidth)return;let o=t.bidiSpans(t.state.doc.lineAt(n)).find(t=>t.from<=n&&t.to>=n),r=o&&o.dir==Fr.RTL?-1:1;s=e.x<i.left?-r:r}let o=this.source(t,n,s);if(null==o?void 0:o.then){let e=this.pending={pos:n};o.then(i=>{this.pending==e&&(this.pending=null,!i||Array.isArray(i)&&!i.length||t.dispatch({effects:this.setHover.of(Array.isArray(i)?i:[i])}))},e=>ka(t.state,e,"hover tooltip"))}else!o||Array.isArray(o)&&!o.length||t.dispatch({effects:this.setHover.of(Array.isArray(o)?o:[o])})}get tooltip(){let t=this.view.plugin(Eh),e=t?t.manager.tooltips.findIndex(t=>t.create==Ih.create):-1;return e>-1?t.manager.tooltipViews[e]:null}mousemove(t){var e,i;this.lastMove={x:t.clientX,y:t.clientY,target:t.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:n,tooltip:s}=this;if(n.length&&s&&!function(t,e){let i,{left:n,right:s,top:o,bottom:r}=t.getBoundingClientRect();if(i=t.querySelector(".cm-tooltip-arrow")){let t=i.getBoundingClientRect();o=Math.min(t.top,o),r=Math.max(t.bottom,r)}return e.clientX>=n-jh&&e.clientX<=s+jh&&e.clientY>=o-jh&&e.clientY<=r+jh}(s.dom,t)||this.pending){let{pos:s}=n[0]||this.pending,o=null!==(i=null===(e=n[0])||void 0===e?void 0:e.end)&&void 0!==i?i:s;(s==o?this.view.posAtCoords(this.lastMove)==s:function(t,e,i,n,s){let o=t.scrollDOM.getBoundingClientRect(),r=t.documentTop+t.documentPadding.top+t.contentHeight;if(o.left>n||o.right<n||o.top>s||Math.min(o.bottom,r)<s)return!1;let a=t.posAtCoords({x:n,y:s},!1);return a>=e&&a<=i}(this.view,s,o,t.clientX,t.clientY))||(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(t){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:e}=this;if(e.length){let{tooltip:e}=this;e&&e.dom.contains(t.relatedTarget)?this.watchTooltipLeave(e.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(t){let e=i=>{t.removeEventListener("mouseleave",e),this.active.length&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};t.addEventListener("mouseleave",e)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const jh=4;function zh(t,e={}){let i=js.define(),n=gs.define({create:()=>[],update(t,n){if(t.length&&(e.hideOnChange&&(n.docChanged||n.selection)?t=[]:e.hideOn&&(t=t.filter(t=>!e.hideOn(n,t))),n.docChanged)){let e=[];for(let i of t){let t=n.changes.mapPos(i.pos,-1,Un.TrackDel);if(null!=t){let s=Object.assign(Object.create(null),i);s.pos=t,null!=s.end&&(s.end=n.changes.mapPos(s.end)),e.push(s)}}t=e}for(let e of n.effects)e.is(i)&&(t=e.value),e.is(qh)&&(t=[]);return t},provide:t=>Rh.from(t)});return{active:n,extension:[n,Pa.define(s=>new Nh(s,t,n,i,e.hoverTime||300)),Lh]}}function Bh(t,e){let i=t.plugin(Eh);if(!i)return null;let n=i.manager.tooltips.indexOf(e);return n<0?null:i.manager.tooltipViews[n]}const qh=js.define();const Zh=cs.define({combine(t){let e,i;for(let n of t)e=e||n.topContainer,i=i||n.bottomContainer;return{topContainer:e,bottomContainer:i}}});function Fh(t,e){let i=t.plugin(Xh),n=i?i.specs.indexOf(e):-1;return n>-1?i.panels[n]:null}const Xh=Pa.fromClass(class{constructor(t){this.input=t.state.facet(Vh),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(e=>e(t));let e=t.state.facet(Zh);this.top=new Hh(t,!0,e.topContainer),this.bottom=new Hh(t,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(t){let e=t.state.facet(Zh);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Hh(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Hh(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let i=t.state.facet(Vh);if(i!=this.input){let e=i.filter(t=>t),n=[],s=[],o=[],r=[];for(let i of e){let e,a=this.specs.indexOf(i);a<0?(e=i(t.view),r.push(e)):(e=this.panels[a],e.update&&e.update(t)),n.push(e),(e.top?s:o).push(e)}this.specs=e,this.panels=n,this.top.sync(s),this.bottom.sync(o);for(let t of r)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}else for(let e of this.panels)e.update&&e.update(t)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:t=>Tc.scrollMargins.of(e=>{let i=e.plugin(t);return i&&{top:i.top.scrollMargin(),bottom:i.bottom.scrollMargin()}})});class Hh{constructor(t,e,i){this.view=t,this.top=e,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(t){for(let e of this.panels)e.destroy&&t.indexOf(e)<0&&e.destroy();this.panels=t,this.syncDOM()}syncDOM(){if(0==this.panels.length)return void(this.dom&&(this.dom.remove(),this.dom=void 0));if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let t=this.dom.firstChild;for(let e of this.panels)if(e.dom.parentNode==this.dom){for(;t!=e.dom;)t=Wh(t);t=t.nextSibling}else this.dom.insertBefore(e.dom,t);for(;t;)t=Wh(t)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(this.container&&this.classes!=this.view.themeClasses){for(let t of this.classes.split(" "))t&&this.container.classList.remove(t);for(let t of(this.classes=this.view.themeClasses).split(" "))t&&this.container.classList.add(t)}}}function Wh(t){let e=t.nextSibling;return t.remove(),e}const Vh=cs.define({enables:Xh});class Yh extends Js{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}Yh.prototype.elementClass="",Yh.prototype.toDOM=void 0,Yh.prototype.mapMode=Un.TrackBefore,Yh.prototype.startSide=Yh.prototype.endSide=-1,Yh.prototype.point=!0;const Uh=cs.define(),Gh=cs.define(),Kh={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>no.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},Jh=cs.define();function tu(t){return[iu(),Jh.of({...Kh,...t})]}const eu=cs.define({combine:t=>t.some(t=>t)});function iu(t){let e=[nu];return t&&!1===t.fixed&&e.push(eu.of(!0)),e}const nu=Pa.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(Jh).map(e=>new au(t,e)),this.fixed=!t.state.facet(eu);for(let t of this.gutters)"after"==t.config.side?this.getDOMAfter().appendChild(t.dom):this.dom.appendChild(t.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(t){if(this.updateGutters(t)){let e=this.prevViewport,i=t.view.viewport,n=Math.min(e.to,i.to)-Math.max(e.from,i.from);this.syncGutters(n<.8*(i.to-i.from))}if(t.geometryChanged){let t=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=t,this.domAfter&&(this.domAfter.style.minHeight=t)}this.view.state.facet(eu)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let i=no.iter(this.view.state.facet(Uh),this.view.viewport.from),n=[],s=this.gutters.map(t=>new ru(t,this.view.viewport,-this.view.documentPadding.top));for(let t of this.view.viewportLineBlocks)if(n.length&&(n=[]),Array.isArray(t.type)){let e=!0;for(let o of t.type)if(o.type==Ar.Text&&e){ou(i,n,o.from);for(let t of s)t.line(this.view,o,n);e=!1}else if(o.widget)for(let t of s)t.widget(this.view,o)}else if(t.type==Ar.Text){ou(i,n,t.from);for(let e of s)e.line(this.view,t,n)}else if(t.widget)for(let e of s)e.widget(this.view,t);for(let t of s)t.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(Jh),i=t.state.facet(Jh),n=t.docChanged||t.heightChanged||t.viewportChanged||!no.eq(t.startState.facet(Uh),t.state.facet(Uh),t.view.viewport.from,t.view.viewport.to);if(e==i)for(let e of this.gutters)e.update(t)&&(n=!0);else{n=!0;let s=[];for(let n of i){let i=e.indexOf(n);i<0?s.push(new au(this.view,n)):(this.gutters[i].update(t),s.push(this.gutters[i]))}for(let t of this.gutters)t.dom.remove(),s.indexOf(t)<0&&t.destroy();for(let t of s)"after"==t.config.side?this.getDOMAfter().appendChild(t.dom):this.dom.appendChild(t.dom);this.gutters=s}return n}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>Tc.scrollMargins.of(e=>{let i=e.plugin(t);if(!i||0==i.gutters.length||!i.fixed)return null;let n=i.dom.offsetWidth*e.scaleX,s=i.domAfter?i.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Fr.LTR?{left:n,right:s}:{right:n,left:s}})});function su(t){return Array.isArray(t)?t:[t]}function ou(t,e,i){for(;t.value&&t.from<=i;)t.from==i&&e.push(t.value),t.next()}class ru{constructor(t,e,i){this.gutter=t,this.height=i,this.i=0,this.cursor=no.iter(t.markers,e.from)}addElement(t,e,i){let{gutter:n}=this,s=(e.top-this.height)/t.scaleY,o=e.height/t.scaleY;if(this.i==n.elements.length){let e=new lu(t,o,s,i);n.elements.push(e),n.dom.appendChild(e.dom)}else n.elements[this.i].update(t,o,s,i);this.height=e.bottom,this.i++}line(t,e,i){let n=[];ou(this.cursor,n,e.from),i.length&&(n=n.concat(i));let s=this.gutter.config.lineMarker(t,e,n);s&&n.unshift(s);let o=this.gutter;(0!=n.length||o.config.renderEmptyElements)&&this.addElement(t,e,n)}widget(t,e){let i=this.gutter.config.widgetMarker(t,e.widget,e),n=i?[i]:null;for(let i of t.state.facet(Gh)){let s=i(t,e.widget,e);s&&(n||(n=[])).push(s)}n&&this.addElement(t,e,n)}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let e=t.elements.pop();t.dom.removeChild(e.dom),e.destroy()}}}class au{constructor(t,e){this.view=t,this.config=e,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in e.domEventHandlers)this.dom.addEventListener(i,n=>{let s,o=n.target;if(o!=this.dom&&this.dom.contains(o)){for(;o.parentNode!=this.dom;)o=o.parentNode;let t=o.getBoundingClientRect();s=(t.top+t.bottom)/2}else s=n.clientY;let r=t.lineBlockAtHeight(s-t.documentTop);e.domEventHandlers[i](t,r,n)&&n.preventDefault()});this.markers=su(e.markers(t)),e.initialSpacer&&(this.spacer=new lu(t,0,0,[e.initialSpacer(t)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(t){let e=this.markers;if(this.markers=su(this.config.markers(t.view)),this.spacer&&this.config.updateSpacer){let e=this.config.updateSpacer(this.spacer.markers[0],t);e!=this.spacer.markers[0]&&this.spacer.update(t.view,0,0,[e])}let i=t.view.viewport;return!no.eq(this.markers,e,i.from,i.to)||!!this.config.lineMarkerChange&&this.config.lineMarkerChange(t)}destroy(){for(let t of this.elements)t.destroy()}}class lu{constructor(t,e,i,n){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,e,i,n)}update(t,e,i,n){this.height!=e&&(this.height=e,this.dom.style.height=e+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),function(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(!t[i].compare(e[i]))return!1;return!0}(this.markers,n)||this.setMarkers(t,n)}setMarkers(t,e){let i="cm-gutterElement",n=this.dom.firstChild;for(let s=0,o=0;;){let r=o,a=s<e.length?e[s++]:null,l=!1;if(a){let t=a.elementClass;t&&(i+=" "+t);for(let t=o;t<this.markers.length;t++)if(this.markers[t].compare(a)){r=t,l=!0;break}}else r=this.markers.length;for(;o<r;){let t=this.markers[o++];if(t.toDOM){t.destroy(n);let e=n.nextSibling;n.remove(),n=e}}if(!a)break;a.toDOM&&(l?n=n.nextSibling:this.dom.insertBefore(a.toDOM(t),n)),l&&o++}this.dom.className=i,this.markers=e}destroy(){this.setMarkers(null,[])}}const cu=cs.define(),hu=cs.define(),uu=cs.define({combine:t=>Ks(t,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(t,e){let i=Object.assign({},t);for(let t in e){let n=i[t],s=e[t];i[t]=n?(t,e,i)=>n(t,e,i)||s(t,e,i):s}return i}})});class du extends Yh{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function fu(t,e){return t.state.facet(uu).formatNumber(e,t.state)}const pu=Jh.compute([uu],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:t=>t.state.facet(cu),lineMarker:(t,e,i)=>i.some(t=>t.toDOM)?null:new du(fu(t,t.state.doc.lineAt(e.from).number)),widgetMarker:(t,e,i)=>{for(let n of t.state.facet(hu)){let s=n(t,e,i);if(s)return s}return null},lineMarkerChange:t=>t.startState.facet(uu)!=t.state.facet(uu),initialSpacer:t=>new du(fu(t,gu(t.state.doc.lines))),updateSpacer(t,e){let i=fu(e.view,gu(e.view.state.doc.lines));return i==t.number?t:new du(i)},domEventHandlers:t.facet(uu).domEventHandlers,side:"before"}));function mu(t={}){return[uu.of(t),iu(),pu]}function gu(t){let e=9;for(;e<t;)e=10*e+9;return e}const vu=new class extends Yh{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},yu=Uh.compute(["selection"],t=>{let e=[],i=-1;for(let n of t.selection.ranges){let s=t.doc.lineAt(n.head).from;s>i&&(i=s,e.push(vu.range(s)))}return no.of(e)});const Ou=1024;let bu=0;class xu{constructor(t,e){this.from=t,this.to=e}}class wu{constructor(t={}){this.id=bu++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof t&&(t=ku.match(t)),e=>{let i=t(e);return void 0===i?null:[this,i]}}}wu.closedBy=new wu({deserialize:t=>t.split(" ")}),wu.openedBy=new wu({deserialize:t=>t.split(" ")}),wu.group=new wu({deserialize:t=>t.split(" ")}),wu.isolate=new wu({deserialize:t=>{if(t&&"rtl"!=t&&"ltr"!=t&&"auto"!=t)throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),wu.contextHash=new wu({perNode:!0}),wu.lookAhead=new wu({perNode:!0}),wu.mounted=new wu({perNode:!0});class _u{constructor(t,e,i){this.tree=t,this.overlay=e,this.parser=i}static get(t){return t&&t.props&&t.props[wu.mounted.id]}}const Su=Object.create(null);class ku{constructor(t,e,i,n=0){this.name=t,this.props=e,this.id=i,this.flags=n}static define(t){let e=t.props&&t.props.length?Object.create(null):Su,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),n=new ku(t.name||"",e,t.id,i);if(t.props)for(let i of t.props)if(Array.isArray(i)||(i=i(n)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[i[0].id]=i[1]}return n}prop(t){return this.props[t.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(t){if("string"==typeof t){if(this.name==t)return!0;let e=this.prop(wu.group);return!!e&&e.indexOf(t)>-1}return this.id==t}static match(t){let e=Object.create(null);for(let i in t)for(let n of i.split(" "))e[n]=t[i];return t=>{for(let i=t.prop(wu.group),n=-1;n<(i?i.length:0);n++){let s=e[n<0?t.name:i[n]];if(s)return s}}}}ku.none=new ku("",Object.create(null),0,8);class $u{constructor(t){this.types=t;for(let e=0;e<t.length;e++)if(t[e].id!=e)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let e=[];for(let i of this.types){let n=null;for(let e of t){let t=e(i);t&&(n||(n=Object.assign({},i.props)),n[t[0].id]=t[1])}e.push(n?new ku(i.name,n,i.id,i.flags):i)}return new $u(e)}}const Cu=new WeakMap,Tu=new WeakMap;var Pu;!function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays"}(Pu||(Pu={}));class Eu{constructor(t,e,i,n,s){if(this.type=t,this.children=e,this.positions=i,this.length=n,this.props=null,s&&s.length){this.props=Object.create(null);for(let[t,e]of s)this.props["number"==typeof t?t:t.id]=e}}toString(){let t=_u.get(this);if(t&&!t.overlay)return t.tree.toString();let e="";for(let t of this.children){let i=t.toString();i&&(e&&(e+=","),e+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(e.length?"("+e+")":""):e}cursor(t=0){return new Zu(this.topNode,t)}cursorAt(t,e=0,i=0){let n=Cu.get(this)||this.topNode,s=new Zu(n);return s.moveTo(t,e),Cu.set(this,s._tree),s}get topNode(){return new Iu(this,0,0,null)}resolve(t,e=0){let i=Du(Cu.get(this)||this.topNode,t,e,!1);return Cu.set(this,i),i}resolveInner(t,e=0){let i=Du(Tu.get(this)||this.topNode,t,e,!0);return Tu.set(this,i),i}resolveStack(t,e=0){return function(t,e,i){let n=t.resolveInner(e,i),s=null;for(let t=n instanceof Iu?n:n.context.parent;t;t=t.parent)if(t.index<0){let o=t.parent;(s||(s=[n])).push(o.resolve(e,i)),t=o}else{let o=_u.get(t.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let r=new Iu(o.tree,o.overlay[0].from+t.from,-1,t);(s||(s=[n])).push(Du(r,e,i,!1))}}return s?Bu(s):n}(this,t,e)}iterate(t){let{enter:e,leave:i,from:n=0,to:s=this.length}=t,o=t.mode||0,r=(o&Pu.IncludeAnonymous)>0;for(let t=this.cursor(o|Pu.IncludeAnonymous);;){let o=!1;if(t.from<=s&&t.to>=n&&(!r&&t.type.isAnonymous||!1!==e(t))){if(t.firstChild())continue;o=!0}for(;o&&i&&(r||!t.type.isAnonymous)&&i(t),!t.nextSibling();){if(!t.parent())return;o=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:Wu(ku.none,this.children,this.positions,0,this.children.length,0,this.length,(t,e,i)=>new Eu(this.type,t,e,i,this.propValues),t.makeTree||((t,e,i)=>new Eu(ku.none,t,e,i)))}static build(t){return function(t){var e;let{buffer:i,nodeSet:n,maxBufferLength:s=Ou,reused:o=[],minRepeatType:r=n.types.length}=t,a=Array.isArray(i)?new Au(i,i.length):i,l=n.types,c=0,h=0;function u(t,e,i,y,O,b){let{id:x,start:w,end:_,size:S}=a,k=h,$=c;for(;S<0;){if(a.next(),-1==S){let e=o[x];return i.push(e),void y.push(w-t)}if(-3==S)return void(c=x);if(-4==S)return void(h=x);throw new RangeError(`Unrecognized record size: ${S}`)}let C,T,P=l[x],E=w-t;if(_-w<=s&&(T=g(a.pos-e,O))){let e=new Uint16Array(T.size-T.skip),i=a.pos-T.size,s=e.length;for(;a.pos>i;)s=v(T.start,e,s);C=new Mu(e,_-T.start,n),E=T.start-t}else{let t=a.pos-S;a.next();let e=[],i=[],n=x>=r?x:-1,o=0,l=_;for(;a.pos>t;)n>=0&&a.id==n&&a.size>=0?(a.end<=l-s&&(p(e,i,w,o,a.end,l,n,k,$),o=e.length,l=a.end),a.next()):b>2500?d(w,t,e,i):u(w,t,e,i,n,b+1);if(n>=0&&o>0&&o<e.length&&p(e,i,w,o,w,l,n,k,$),e.reverse(),i.reverse(),n>-1&&o>0){let t=f(P,$);C=Wu(P,e,i,0,e.length,0,_-w,t,t)}else C=m(P,e,i,_-w,k-_,$)}i.push(C),y.push(E)}function d(t,e,i,o){let r=[],l=0,c=-1;for(;a.pos>e;){let{id:t,start:e,end:i,size:n}=a;if(n>4)a.next();else{if(c>-1&&e<c)break;c<0&&(c=i-s),r.push(t,e,i),l++,a.next()}}if(l){let e=new Uint16Array(4*l),s=r[r.length-2];for(let t=r.length-3,i=0;t>=0;t-=3)e[i++]=r[t],e[i++]=r[t+1]-s,e[i++]=r[t+2]-s,e[i++]=i;i.push(new Mu(e,r[2]-s,n)),o.push(s-t)}}function f(t,e){return(i,n,s)=>{let o,r,a=0,l=i.length-1;if(l>=0&&(o=i[l])instanceof Eu){if(!l&&o.type==t&&o.length==s)return o;(r=o.prop(wu.lookAhead))&&(a=n[l]+o.length+r)}return m(t,i,n,s,a,e)}}function p(t,e,i,s,o,r,a,l,c){let h=[],u=[];for(;t.length>s;)h.push(t.pop()),u.push(e.pop()+i-o);t.push(m(n.types[a],h,u,r-o,l-r,c)),e.push(o-i)}function m(t,e,i,n,s,o,r){if(o){let t=[wu.contextHash,o];r=r?[t].concat(r):[t]}if(s>25){let t=[wu.lookAhead,s];r=r?[t].concat(r):[t]}return new Eu(t,e,i,n,r)}function g(t,e){let i=a.fork(),n=0,o=0,l=0,c=i.end-s,h={size:0,start:0,skip:0};t:for(let s=i.pos-t;i.pos>s;){let t=i.size;if(i.id==e&&t>=0){h.size=n,h.start=o,h.skip=l,l+=4,n+=4,i.next();continue}let a=i.pos-t;if(t<0||a<s||i.start<c)break;let u=i.id>=r?4:0,d=i.start;for(i.next();i.pos>a;){if(i.size<0){if(-3!=i.size)break t;u+=4}else i.id>=r&&(u+=4);i.next()}o=d,n+=t,l+=u}return(e<0||n==t)&&(h.size=n,h.start=o,h.skip=l),h.size>4?h:void 0}function v(t,e,i){let{id:n,start:s,end:o,size:l}=a;if(a.next(),l>=0&&n<r){let r=i;if(l>4){let n=a.pos-(l-4);for(;a.pos>n;)i=v(t,e,i)}e[--i]=r,e[--i]=o-t,e[--i]=s-t,e[--i]=n}else-3==l?c=n:-4==l&&(h=n);return i}let y=[],O=[];for(;a.pos>0;)u(t.start||0,t.bufferStart||0,y,O,-1,0);let b=null!==(e=t.length)&&void 0!==e?e:y.length?O[0]+y[0].length:0;return new Eu(l[t.topID],y.reverse(),O.reverse(),b)}(t)}}Eu.empty=new Eu(ku.none,[],[],0);class Au{constructor(t,e){this.buffer=t,this.index=e}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Au(this.buffer,this.index)}}class Mu{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return ku.none}toString(){let t=[];for(let e=0;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];return t.join(",")}childString(t){let e=this.buffer[t],i=this.buffer[t+3],n=this.set.types[e],s=n.name;if(/\W/.test(s)&&!n.isError&&(s=JSON.stringify(s)),i==(t+=4))return s;let o=[];for(;t<i;)o.push(this.childString(t)),t=this.buffer[t+3];return s+"("+o.join(",")+")"}findChild(t,e,i,n,s){let{buffer:o}=this,r=-1;for(let a=t;a!=e&&!(Qu(s,n,o[a+1],o[a+2])&&(r=a,i>0));a=o[a+3]);return r}slice(t,e,i){let n=this.buffer,s=new Uint16Array(e-t),o=0;for(let r=t,a=0;r<e;){s[a++]=n[r++],s[a++]=n[r++]-i;let e=s[a++]=n[r++]-i;s[a++]=n[r++]-t,o=Math.max(o,e)}return new Mu(s,o,this.set)}}function Qu(t,e,i,n){switch(t){case-2:return i<e;case-1:return n>=e&&i<e;case 0:return i<e&&n>e;case 1:return i<=e&&n>e;case 2:return n>e;case 4:return!0}}function Du(t,e,i,n){for(var s;t.from==t.to||(i<1?t.from>=e:t.from>e)||(i>-1?t.to<=e:t.to<e);){let e=!n&&t instanceof Iu&&t.index<0?null:t.parent;if(!e)return t;t=e}let o=n?0:Pu.IgnoreOverlays;if(n)for(let n=t,r=n.parent;r;n=r,r=n.parent)n instanceof Iu&&n.index<0&&(null===(s=r.enter(e,i,o))||void 0===s?void 0:s.from)!=n.from&&(t=r);for(;;){let n=t.enter(e,i,o);if(!n)return t;t=n}}class Ru{cursor(t=0){return new Zu(this,t)}getChild(t,e=null,i=null){let n=Lu(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return Lu(this,t,e,i)}resolve(t,e=0){return Du(this,t,e,!1)}resolveInner(t,e=0){return Du(this,t,e,!0)}matchContext(t){return Nu(this.parent,t)}enterUnfinishedNodesBefore(t){let e=this.childBefore(t),i=this;for(;e;){let t=e.lastChild;if(!t||t.to!=e.to)break;t.type.isError&&t.from==t.to?(i=e,e=t.prevSibling):e=t}return i}get node(){return this}get next(){return this.parent}}class Iu extends Ru{constructor(t,e,i,n){super(),this._tree=t,this.from=e,this.index=i,this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,i,n,s=0){for(let o=this;;){for(let{children:r,positions:a}=o._tree,l=e>0?r.length:-1;t!=l;t+=e){let l=r[t],c=a[t]+o.from;if(Qu(n,i,c,c+l.length))if(l instanceof Mu){if(s&Pu.ExcludeBuffers)continue;let r=l.findChild(0,l.buffer.length,e,i-c,n);if(r>-1)return new zu(new ju(o,l,t,c),null,r)}else if(s&Pu.IncludeAnonymous||!l.type.isAnonymous||Fu(l)){let r;if(!(s&Pu.IgnoreMounts)&&(r=_u.get(l))&&!r.overlay)return new Iu(r.tree,c,t,o);let a=new Iu(l,c,t,o);return s&Pu.IncludeAnonymous||!a.type.isAnonymous?a:a.nextChild(e<0?l.children.length-1:0,e,i,n)}}if(s&Pu.IncludeAnonymous||!o.type.isAnonymous)return null;if(t=o.index>=0?o.index+e:e<0?-1:o._parent._tree.children.length,o=o._parent,!o)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}enter(t,e,i=0){let n;if(!(i&Pu.IgnoreOverlays)&&(n=_u.get(this._tree))&&n.overlay){let i=t-this.from;for(let{from:t,to:s}of n.overlay)if((e>0?t<=i:t<i)&&(e<0?s>=i:s>i))return new Iu(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,i)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function Lu(t,e,i,n){let s=t.cursor(),o=[];if(!s.firstChild())return o;if(null!=i)for(let t=!1;!t;)if(t=s.type.is(i),!s.nextSibling())return o;for(;;){if(null!=n&&s.type.is(n))return o;if(s.type.is(e)&&o.push(s.node),!s.nextSibling())return null==n?o:[]}}function Nu(t,e,i=e.length-1){for(let n=t;i>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[i]&&e[i]!=n.name)return!1;i--}}return!0}class ju{constructor(t,e,i,n){this.parent=t,this.buffer=e,this.index=i,this.start=n}}class zu extends Ru{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,e,i){super(),this.context=t,this._parent=e,this.index=i,this.type=t.buffer.set.types[t.buffer.buffer[i]]}child(t,e,i){let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.context.start,i);return s<0?null:new zu(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}enter(t,e,i=0){if(i&Pu.ExcludeBuffers)return null;let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return s<0?null:new zu(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new zu(this.context,this._parent,e):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;return this.index==e?this.externalSibling(-1):new zu(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],e=[],{buffer:i}=this.context,n=this.index+4,s=i.buffer[this.index+3];if(s>n){let o=i.buffer[this.index+1];t.push(i.slice(n,s,o)),e.push(0)}return new Eu(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Bu(t){if(!t.length)return null;let e=0,i=t[0];for(let n=1;n<t.length;n++){let s=t[n];(s.from>i.from||s.to<i.to)&&(i=s,e=n)}let n=i instanceof Iu&&i.index<0?null:i.parent,s=t.slice();return n?s[e]=n:s.splice(e,1),new qu(s,i)}class qu{constructor(t,e){this.heads=t,this.node=e}get next(){return Bu(this.heads)}}class Zu{get name(){return this.type.name}constructor(t,e=0){if(this.mode=e,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,t instanceof Iu)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let e=t._parent;e;e=e._parent)this.stack.unshift(e.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return!!t&&(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0)}yieldBuf(t,e){this.index=t;let{start:i,buffer:n}=this.buffer;return this.type=e||n.set.types[n.buffer[t]],this.from=i+n.buffer[t+1],this.to=i+n.buffer[t+2],!0}yield(t){return!!t&&(t instanceof Iu?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,i){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,e,i,this.mode));let{buffer:n}=this.buffer,s=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.buffer.start,i);return!(s<0)&&(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,i=this.mode){return this.buffer?!(i&Pu.ExcludeBuffers)&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Pu.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&Pu.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode));let{buffer:e}=this.buffer,i=this.stack.length-1;if(t<0){let t=i<0?0:this.stack[i]+4;if(this.index!=t)return this.yieldBuf(e.findChild(t,this.index,-1,0,4))}else{let t=e.buffer[this.index+3];if(t<(i<0?e.buffer.length:e.buffer[this.stack[i]+3]))return this.yieldBuf(t)}return i<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,i,{buffer:n}=this;if(n){if(t>0){if(this.index<n.buffer.buffer.length)return!1}else for(let t=0;t<this.index;t++)if(n.buffer.buffer[t+3]<this.index)return!1;({index:e,parent:i}=n)}else({index:e,_parent:i}=this._tree);for(;i;({index:e,_parent:i}=i))if(e>-1)for(let n=e+t,s=t<0?-1:i._tree.children.length;n!=s;n+=t){let t=i._tree.children[n];if(this.mode&Pu.IncludeAnonymous||t instanceof Mu||!t.type.isAnonymous||Fu(t))return!1}return!0}move(t,e){if(e&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,e););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,i=0;if(t&&t.context==this.buffer)t:for(let n=this.index,s=this.stack.length;s>=0;){for(let o=t;o;o=o._parent)if(o.index==n){if(n==this.index)return o;e=o,i=s+1;break t}n=this.stack[--s]}for(let t=i;t<this.stack.length;t++)e=new zu(this.buffer,e,this.stack[t]);return this.bufferNode=new zu(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let i=0;;){let n=!1;if(this.type.isAnonymous||!1!==t(this)){if(this.firstChild()){i++;continue}this.type.isAnonymous||(n=!0)}for(;;){if(n&&e&&e(this),n=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,n=!0}}}matchContext(t){if(!this.buffer)return Nu(this.node.parent,t);let{buffer:e}=this.buffer,{types:i}=e.set;for(let n=t.length-1,s=this.stack.length-1;n>=0;s--){if(s<0)return Nu(this._tree,t,n);let o=i[e.buffer[this.stack[s]]];if(!o.isAnonymous){if(t[n]&&t[n]!=o.name)return!1;n--}}return!0}}function Fu(t){return t.children.some(t=>t instanceof Mu||!t.type.isAnonymous||Fu(t))}const Xu=new WeakMap;function Hu(t,e){if(!t.isAnonymous||e instanceof Mu||e.type!=t)return 1;let i=Xu.get(e);if(null==i){i=1;for(let n of e.children){if(n.type!=t||!(n instanceof Eu)){i=1;break}i+=Hu(t,n)}Xu.set(e,i)}return i}function Wu(t,e,i,n,s,o,r,a,l){let c=0;for(let i=n;i<s;i++)c+=Hu(t,e[i]);let h=Math.ceil(1.5*c/8),u=[],d=[];return function e(i,n,s,r,a){for(let c=s;c<r;){let s=c,f=n[c],p=Hu(t,i[c]);for(c++;c<r;c++){let e=Hu(t,i[c]);if(p+e>=h)break;p+=e}if(c==s+1){if(p>h){let t=i[s];e(t.children,t.positions,0,t.children.length,n[s]+a);continue}u.push(i[s])}else{let e=n[c-1]+i[c-1].length-f;u.push(Wu(t,i,n,s,c,f,e,null,l))}d.push(f+a-o)}}(e,i,n,s,0),(a||l)(u,d,r)}class Vu{constructor(){this.map=new WeakMap}setBuffer(t,e,i){let n=this.map.get(t);n||this.map.set(t,n=new Map),n.set(e,i)}getBuffer(t,e){let i=this.map.get(t);return i&&i.get(e)}set(t,e){t instanceof zu?this.setBuffer(t.context.buffer,t.index,e):t instanceof Iu&&this.map.set(t.tree,e)}get(t){return t instanceof zu?this.getBuffer(t.context.buffer,t.index):t instanceof Iu?this.map.get(t.tree):void 0}cursorSet(t,e){t.buffer?this.setBuffer(t.buffer.buffer,t.index,e):this.map.set(t.tree,e)}cursorGet(t){return t.buffer?this.getBuffer(t.buffer.buffer,t.index):this.map.get(t.tree)}}class Yu{constructor(t,e,i,n,s=!1,o=!1){this.from=t,this.to=e,this.tree=i,this.offset=n,this.open=(s?1:0)|(o?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(t,e=[],i=!1){let n=[new Yu(0,t.length,t,0,!1,i)];for(let i of e)i.to>t.length&&n.push(i);return n}static applyChanges(t,e,i=128){if(!e.length)return t;let n=[],s=1,o=t.length?t[0]:null;for(let r=0,a=0,l=0;;r++){let c=r<e.length?e[r]:null,h=c?c.fromA:1e9;if(h-a>=i)for(;o&&o.from<h;){let e=o;if(a>=e.from||h<=e.to||l){let t=Math.max(e.from,a)-l,i=Math.min(e.to,h)-l;e=t>=i?null:new Yu(t,i,e.tree,e.offset+l,r>0,!!c)}if(e&&n.push(e),o.to>h)break;o=s<t.length?t[s++]:null}if(!c)break;a=c.toA,l=c.toA-c.toB}return n}}class Uu{startParse(t,e,i){return"string"==typeof t&&(t=new Gu(t)),i=i?i.length?i.map(t=>new xu(t.from,t.to)):[new xu(0,0)]:[new xu(0,t.length)],this.createParse(t,e||[],i)}parse(t,e,i){let n=this.startParse(t,e,i);for(;;){let t=n.advance();if(t)return t}}}class Gu{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,e){return this.string.slice(t,e)}}new wu({perNode:!0});let Ku=0;class Ju{constructor(t,e,i,n){this.name=t,this.set=e,this.base=i,this.modified=n,this.id=Ku++}toString(){let{name:t}=this;for(let e of this.modified)e.name&&(t=`${e.name}(${t})`);return t}static define(t,e){let i="string"==typeof t?t:"?";if(t instanceof Ju&&(e=t),null==e?void 0:e.base)throw new Error("Can not derive from a modified tag");let n=new Ju(i,[],null,[]);if(n.set.push(n),e)for(let t of e.set)n.set.push(t);return n}static defineModifier(t){let e=new ed(t);return t=>t.modified.indexOf(e)>-1?t:ed.get(t.base||t,t.modified.concat(e).sort((t,e)=>t.id-e.id))}}let td=0;class ed{constructor(t){this.name=t,this.instances=[],this.id=td++}static get(t,e){if(!e.length)return t;let i=e[0].instances.find(i=>{return i.base==t&&(n=e,s=i.modified,n.length==s.length&&n.every((t,e)=>t==s[e]));var n,s});if(i)return i;let n=[],s=new Ju(t.name,n,t,e);for(let t of e)t.instances.push(s);let o=function(t){let e=[[]];for(let i=0;i<t.length;i++)for(let n=0,s=e.length;n<s;n++)e.push(e[n].concat(t[i]));return e.sort((t,e)=>e.length-t.length)}(e);for(let e of t.set)if(!e.modified.length)for(let t of o)n.push(ed.get(e,t));return s}}function id(t){let e=Object.create(null);for(let i in t){let n=t[i];Array.isArray(n)||(n=[n]);for(let t of i.split(" "))if(t){let i=[],s=2,o=t;for(let e=0;;){if("..."==o&&e>0&&e+3==t.length){s=1;break}let n=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(o);if(!n)throw new RangeError("Invalid path: "+t);if(i.push("*"==n[0]?"":'"'==n[0][0]?JSON.parse(n[0]):n[0]),e+=n[0].length,e==t.length)break;let r=t[e++];if(e==t.length&&"!"==r){s=0;break}if("/"!=r)throw new RangeError("Invalid path: "+t);o=t.slice(e)}let r=i.length-1,a=i[r];if(!a)throw new RangeError("Invalid path: "+t);let l=new sd(n,s,r>0?i.slice(0,r):null);e[a]=l.sort(e[a])}}return nd.add(e)}const nd=new wu;class sd{constructor(t,e,i,n){this.tags=t,this.mode=e,this.context=i,this.next=n}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(t){return!t||t.depth<this.depth?(this.next=t,this):(t.next=this.sort(t.next),t)}get depth(){return this.context?this.context.length:0}}function od(t,e){let i=Object.create(null);for(let e of t)if(Array.isArray(e.tag))for(let t of e.tag)i[t.id]=e.class;else i[e.tag.id]=e.class;let{scope:n,all:s=null}=e||{};return{style:t=>{let e=s;for(let n of t)for(let t of n.set){let n=i[t.id];if(n){e=e?e+" "+n:n;break}}return e},scope:n}}function rd(t,e,i,n=0,s=t.length){let o=new ad(n,Array.isArray(e)?e:[e],i);o.highlightRange(t.cursor(),n,s,"",o.highlighters),o.flush(s)}sd.empty=new sd([],2,null);class ad{constructor(t,e,i){this.at=t,this.highlighters=e,this.span=i,this.class=""}startSpan(t,e){e!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=e)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,e,i,n,s){let{type:o,from:r,to:a}=t;if(r>=i||a<=e)return;o.isTop&&(s=this.highlighters.filter(t=>!t.scope||t.scope(o)));let l=n,c=function(t){let e=t.type.prop(nd);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}(t)||sd.empty,h=function(t,e){let i=null;for(let n of t){let t=n.style(e);t&&(i=i?i+" "+t:t)}return i}(s,c.tags);if(h&&(l&&(l+=" "),l+=h,1==c.mode&&(n+=(n?" ":"")+h)),this.startSpan(Math.max(e,r),l),c.opaque)return;let u=t.tree&&t.tree.prop(wu.mounted);if(u&&u.overlay){let o=t.node.enter(u.overlay[0].from+r,1),c=this.highlighters.filter(t=>!t.scope||t.scope(u.tree.type)),h=t.firstChild();for(let d=0,f=r;;d++){let p=d<u.overlay.length?u.overlay[d]:null,m=p?p.from+r:a,g=Math.max(e,f),v=Math.min(i,m);if(g<v&&h)for(;t.from<v&&(this.highlightRange(t,g,v,n,s),this.startSpan(Math.min(v,t.to),l),!(t.to>=m)&&t.nextSibling()););if(!p||m>i)break;f=p.to+r,f>e&&(this.highlightRange(o.cursor(),Math.max(e,p.from+r),Math.min(i,f),"",c),this.startSpan(Math.min(i,f),l))}h&&t.parent()}else if(t.firstChild()){u&&(n="");do{if(!(t.to<=e)){if(t.from>=i)break;this.highlightRange(t,e,i,n,s),this.startSpan(Math.min(i,t.to),l)}}while(t.nextSibling());t.parent()}}}const ld=Ju.define,cd=ld(),hd=ld(),ud=ld(hd),dd=ld(hd),fd=ld(),pd=ld(fd),md=ld(fd),gd=ld(),vd=ld(gd),yd=ld(),Od=ld(),bd=ld(),xd=ld(bd),wd=ld(),_d={comment:cd,lineComment:ld(cd),blockComment:ld(cd),docComment:ld(cd),name:hd,variableName:ld(hd),typeName:ud,tagName:ld(ud),propertyName:dd,attributeName:ld(dd),className:ld(hd),labelName:ld(hd),namespace:ld(hd),macroName:ld(hd),literal:fd,string:pd,docString:ld(pd),character:ld(pd),attributeValue:ld(pd),number:md,integer:ld(md),float:ld(md),bool:ld(fd),regexp:ld(fd),escape:ld(fd),color:ld(fd),url:ld(fd),keyword:yd,self:ld(yd),null:ld(yd),atom:ld(yd),unit:ld(yd),modifier:ld(yd),operatorKeyword:ld(yd),controlKeyword:ld(yd),definitionKeyword:ld(yd),moduleKeyword:ld(yd),operator:Od,derefOperator:ld(Od),arithmeticOperator:ld(Od),logicOperator:ld(Od),bitwiseOperator:ld(Od),compareOperator:ld(Od),updateOperator:ld(Od),definitionOperator:ld(Od),typeOperator:ld(Od),controlOperator:ld(Od),punctuation:bd,separator:ld(bd),bracket:xd,angleBracket:ld(xd),squareBracket:ld(xd),paren:ld(xd),brace:ld(xd),content:gd,heading:vd,heading1:ld(vd),heading2:ld(vd),heading3:ld(vd),heading4:ld(vd),heading5:ld(vd),heading6:ld(vd),contentSeparator:ld(gd),list:ld(gd),quote:ld(gd),emphasis:ld(gd),strong:ld(gd),link:ld(gd),monospace:ld(gd),strikethrough:ld(gd),inserted:ld(),deleted:ld(),changed:ld(),invalid:ld(),meta:wd,documentMeta:ld(wd),annotation:ld(wd),processingInstruction:ld(wd),definition:Ju.defineModifier("definition"),constant:Ju.defineModifier("constant"),function:Ju.defineModifier("function"),standard:Ju.defineModifier("standard"),local:Ju.defineModifier("local"),special:Ju.defineModifier("special")};for(let t in _d){let e=_d[t];e instanceof Ju&&(e.name=t)}od([{tag:_d.link,class:"tok-link"},{tag:_d.heading,class:"tok-heading"},{tag:_d.emphasis,class:"tok-emphasis"},{tag:_d.strong,class:"tok-strong"},{tag:_d.keyword,class:"tok-keyword"},{tag:_d.atom,class:"tok-atom"},{tag:_d.bool,class:"tok-bool"},{tag:_d.url,class:"tok-url"},{tag:_d.labelName,class:"tok-labelName"},{tag:_d.inserted,class:"tok-inserted"},{tag:_d.deleted,class:"tok-deleted"},{tag:_d.literal,class:"tok-literal"},{tag:_d.string,class:"tok-string"},{tag:_d.number,class:"tok-number"},{tag:[_d.regexp,_d.escape,_d.special(_d.string)],class:"tok-string2"},{tag:_d.variableName,class:"tok-variableName"},{tag:_d.local(_d.variableName),class:"tok-variableName tok-local"},{tag:_d.definition(_d.variableName),class:"tok-variableName tok-definition"},{tag:_d.special(_d.variableName),class:"tok-variableName2"},{tag:_d.definition(_d.propertyName),class:"tok-propertyName tok-definition"},{tag:_d.typeName,class:"tok-typeName"},{tag:_d.namespace,class:"tok-namespace"},{tag:_d.className,class:"tok-className"},{tag:_d.macroName,class:"tok-macroName"},{tag:_d.propertyName,class:"tok-propertyName"},{tag:_d.operator,class:"tok-operator"},{tag:_d.comment,class:"tok-comment"},{tag:_d.meta,class:"tok-meta"},{tag:_d.invalid,class:"tok-invalid"},{tag:_d.punctuation,class:"tok-punctuation"}]);var Sd;const kd=new wu;function $d(t){return cs.define({combine:t?e=>e.concat(t):void 0})}const Cd=new wu;class Td{constructor(t,e,i=[],n=""){this.data=t,this.name=n,Gs.prototype.hasOwnProperty("tree")||Object.defineProperty(Gs.prototype,"tree",{get(){return Ad(this)}}),this.parser=e,this.extension=[zd.of(this),Gs.languageData.of((t,e,i)=>{let n=Pd(t,e,i),s=n.type.prop(kd);if(!s)return[];let o=t.facet(s),r=n.type.prop(Cd);if(r){let s=n.resolve(e-n.from,i);for(let e of r)if(e.test(s,t)){let i=t.facet(e.facet);return"replace"==e.type?i:i.concat(o)}}return o})].concat(i)}isActiveAt(t,e,i=-1){return Pd(t,e,i).type.prop(kd)==this.data}findRegions(t){let e=t.facet(zd);if((null==e?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let i=[],n=(t,e)=>{if(t.prop(kd)==this.data)return void i.push({from:e,to:e+t.length});let s=t.prop(wu.mounted);if(s){if(s.tree.prop(kd)==this.data){if(s.overlay)for(let t of s.overlay)i.push({from:t.from+e,to:t.to+e});else i.push({from:e,to:e+t.length});return}if(s.overlay){let t=i.length;if(n(s.tree,s.overlay[0].from+e),i.length>t)return}}for(let i=0;i<t.children.length;i++){let s=t.children[i];s instanceof Eu&&n(s,t.positions[i]+e)}};return n(Ad(t),0),i}get allowsNesting(){return!0}}function Pd(t,e,i){let n=t.facet(zd),s=Ad(t).topNode;if(!n||n.allowsNesting)for(let t=s;t;t=t.enter(e,i,Pu.ExcludeBuffers))t.type.isTop&&(s=t);return s}Td.setState=js.define();class Ed extends Td{constructor(t,e,i){super(t,e,[],i),this.parser=e}static define(t){let e=$d(t.languageData);return new Ed(e,t.parser.configure({props:[kd.add(t=>t.isTop?e:void 0)]}),t.name)}configure(t,e){return new Ed(this.data,this.parser.configure(t),e||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Ad(t){let e=t.field(Td.state,!1);return e?e.tree:Eu.empty}class Md{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let i=this.cursorPos-this.string.length;return t<i||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-i,e-i)}}let Qd=null;class Dd{constructor(t,e,i=[],n,s,o,r,a){this.parser=t,this.state=e,this.fragments=i,this.tree=n,this.treeLen=s,this.viewport=o,this.skipped=r,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(t,e,i){return new Dd(t,e,[],Eu.empty,0,i,[],null)}startParse(){return this.parser.startParse(new Md(this.state.doc),this.fragments)}work(t,e){return null!=e&&e>=this.state.doc.length&&(e=void 0),this.tree!=Eu.empty&&this.isDone(null!=e?e:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if("number"==typeof t){let e=Date.now()+t;t=()=>Date.now()>e}for(this.parse||(this.parse=this.startParse()),null!=e&&(null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&e<this.state.doc.length&&this.parse.stopAt(e);;){let n=this.parse.advance();if(n){if(this.fragments=this.withoutTempSkipped(Yu.addTree(n,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(i=this.parse.stoppedAt)&&void 0!==i?i:this.state.doc.length,this.tree=n,this.parse=null,!(this.treeLen<(null!=e?e:this.state.doc.length)))return!0;this.parse=this.startParse()}if(t())return!1}})}takeTree(){let t,e;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(e=this.parse.advance()););}),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(Yu.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=Qd;Qd=this;try{return t()}finally{Qd=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=Rd(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:n,treeLen:s,viewport:o,skipped:r}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges((t,i,n,s)=>e.push({fromA:t,toA:i,fromB:n,toB:s})),i=Yu.applyChanges(i,e),n=Eu.empty,s=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){r=[];for(let e of this.skipped){let i=t.mapPos(e.from,1),n=t.mapPos(e.to,-1);i<n&&r.push({from:i,to:n})}}}return new Dd(this.parser,e,i,n,s,o,r,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let e=this.skipped.length;for(let e=0;e<this.skipped.length;e++){let{from:i,to:n}=this.skipped[e];i<t.to&&n>t.from&&(this.fragments=Rd(this.fragments,i,n),this.skipped.splice(e--,1))}return!(this.skipped.length>=e)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends Uu{createParse(e,i,n){let s=n[0].from,o=n[n.length-1].to;return{parsedPos:s,advance(){let e=Qd;if(e){for(let t of n)e.tempSkipped.push(t);t&&(e.scheduleOn=e.scheduleOn?Promise.all([e.scheduleOn,t]):t)}return this.parsedPos=o,new Eu(ku.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&0==e[0].from&&e[0].to>=t}static get(){return Qd}}function Rd(t,e,i){return Yu.applyChanges(t,[{fromA:e,toA:i,fromB:e,toB:i}])}class Id{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let e=this.context.changes(t.changes,t.state),i=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,i)||e.takeTree(),new Id(e)}static init(t){let e=Math.min(3e3,t.doc.length),i=Dd.create(t.facet(zd).parser,t,{from:0,to:e});return i.work(20,e)||i.takeTree(),new Id(i)}}Td.state=gs.define({create:Id.init,update(t,e){for(let t of e.effects)if(t.is(Td.setState))return t.value;return e.startState.facet(zd)!=e.state.facet(zd)?Id.init(e.state):t.apply(e)}});let Ld=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};"undefined"!=typeof requestIdleCallback&&(Ld=t=>{let e=-1,i=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(i):cancelIdleCallback(e)});const Nd="undefined"!=typeof navigator&&(null===(Sd=navigator.scheduling)||void 0===Sd?void 0:Sd.isInputPending)?()=>navigator.scheduling.isInputPending():null,jd=Pa.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let e=this.view.state.field(Td.state).context;(e.updateViewport(t.view.viewport)||this.view.viewport.to>e.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(e)}scheduleWork(){if(this.working)return;let{state:t}=this.view,e=t.field(Td.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=Ld(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEnd<e&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=e+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:n}}=this.view,s=i.field(Td.state);if(s.tree==s.context.tree&&s.context.isDone(n+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,t&&!Nd?Math.max(25,t.timeRemaining()-5):1e9),r=s.context.treeLen<n&&i.doc.length>n+1e3,a=s.context.work(()=>Nd&&Nd()||Date.now()>o,n+(r?0:1e5));this.chunkBudget-=Date.now()-e,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Td.setState.of(new Id(s.context))})),this.chunkBudget>0&&(!a||r)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(t=>ka(this.view.state,t)).then(()=>this.workScheduled--),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),zd=cs.define({combine:t=>t.length?t[0]:null,enables:t=>[Td.state,jd,Tc.contentAttributes.compute([t],e=>{let i=e.facet(t);return i&&i.name?{"data-language":i.name}:{}})]});class Bd{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}}const qd=cs.define(),Zd=cs.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Fd(t){let e=t.facet(Zd);return 9==e.charCodeAt(0)?t.tabSize*e.length:e.length}function Xd(t,e){let i="",n=t.tabSize,s=t.facet(Zd)[0];if("\t"==s){for(;e>=n;)i+="\t",e-=n;s=" "}for(let t=0;t<e;t++)i+=s;return i}function Hd(t,e){t instanceof Gs&&(t=new Wd(t));for(let i of t.state.facet(qd)){let n=i(t,e);if(void 0!==n)return n}let i=Ad(t.state);return i.length>=e?function(t,e,i){let n=e.resolveStack(i),s=e.resolveInner(i,-1).resolve(i,0).enterUnfinishedNodesBefore(i);if(s!=n.node){let t=[];for(let e=s;e&&!(e.from<n.node.from||e.to>n.node.to||e.from==n.node.from&&e.type==n.node.type);e=e.parent)t.push(e);for(let e=t.length-1;e>=0;e--)n={node:t[e],next:n}}return Yd(n,t,i)}(t,i,e):null}class Wd{constructor(t,e={}){this.state=t,this.options=e,this.unit=Fd(t)}lineAt(t,e=1){let i=this.state.doc.lineAt(t),{simulateBreak:n,simulateDoubleBreak:s}=this.options;return null!=n&&n>=i.from&&n<=i.to?s&&n==t?{text:"",from:t}:(e<0?n<t:n<=t)?{text:i.text.slice(n-i.from),from:n}:{text:i.text.slice(0,n-i.from),from:i.from}:i}textAfterPos(t,e=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:i,from:n}=this.lineAt(t,e);return i.slice(t-n,Math.min(i.length,t+100-n))}column(t,e=1){let{text:i,from:n}=this.lineAt(t,e),s=this.countColumn(i,t-n),o=this.options.overrideIndentation?this.options.overrideIndentation(n):-1;return o>-1&&(s+=o-this.countColumn(i,i.search(/\S|$/))),s}countColumn(t,e=t.length){return go(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:i,from:n}=this.lineAt(t,e),s=this.options.overrideIndentation;if(s){let t=s(n);if(t>-1)return t}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Vd=new wu;function Yd(t,e,i){for(let n=t;n;n=n.next){let t=Ud(n.node);if(t)return t(Kd.create(e,i,n))}return 0}function Ud(t){let e=t.type.prop(Vd);if(e)return e;let i,n=t.firstChild;if(n&&(i=n.type.prop(wu.closedBy))){let e=t.lastChild,n=e&&i.indexOf(e.name)>-1;return t=>ef(t,!0,1,void 0,n&&!function(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}(t)?e.from:void 0)}return null==t.parent?Gd:null}function Gd(){return 0}class Kd extends Wd{constructor(t,e,i){super(t.state,t.options),this.base=t,this.pos=e,this.context=i}get node(){return this.context.node}static create(t,e,i){return new Kd(t,e,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let e=this.state.doc.lineAt(t.from);for(;;){let i=t.resolve(e.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(Jd(i,t))break;e=this.state.doc.lineAt(i.from)}return this.lineIndent(e.from)}continue(){return Yd(this.context.next,this.base,this.pos)}}function Jd(t,e){for(let i=e;i;i=i.parent)if(t==i)return!0;return!1}function tf({closing:t,align:e=!0,units:i=1}){return n=>ef(n,e,i,t)}function ef(t,e,i,n,s){let o=t.textAfter,r=o.match(/^\s*/)[0].length,a=n&&o.slice(r,r+n.length)==n||s==t.pos+r,l=e?function(t){let e=t.node,i=e.childAfter(e.from),n=e.lastChild;if(!i)return null;let s=t.options.simulateBreak,o=t.state.doc.lineAt(i.from),r=null==s||s<=o.from?o.to:Math.min(o.to,s);for(let t=i.to;;){let s=e.childAfter(t);if(!s||s==n)return null;if(!s.type.isSkipped){if(s.from>=r)return null;let t=/^ */.exec(o.text.slice(i.to-o.from))[0].length;return{from:i.from,to:i.to+t}}t=s.to}}(t):null;return l?a?t.column(l.from):t.column(l.to):t.baseIndent+(a?0:t.unit*i)}function nf({except:t,units:e=1}={}){return i=>{let n=t&&t.test(i.textAfter);return i.baseIndent+(n?0:e*i.unit)}}const sf=cs.define(),of=new wu;function rf(t){let e=t.lastChild;return e&&e.to==t.to&&e.type.isError}function af(t,e,i){for(let n of t.facet(sf)){let s=n(t,e,i);if(s)return s}return function(t,e,i){let n=Ad(t);if(n.length<i)return null;let s=null;for(let o=n.resolveStack(i,1);o;o=o.next){let r=o.node;if(r.to<=i||r.from>i)continue;if(s&&r.from<e)break;let a=r.type.prop(of);if(a&&(r.to<n.length-50||n.length==t.doc.length||!rf(r))){let n=a(r,t);n&&n.from<=i&&n.from>=e&&n.to>i&&(s=n)}}return s}(t,e,i)}function lf(t,e){let i=e.mapPos(t.from,1),n=e.mapPos(t.to,-1);return i>=n?void 0:{from:i,to:n}}const cf=js.define({map:lf}),hf=js.define({map:lf});function uf(t){let e=[];for(let{head:i}of t.state.selection.ranges)e.some(t=>t.from<=i&&t.to>=i)||e.push(t.lineBlockAt(i));return e}const df=gs.define({create:()=>Mr.none,update(t,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((e,i)=>t=ff(t,e,i)),t=t.map(e.changes);for(let i of e.effects)if(i.is(cf)&&!mf(t,i.value.from,i.value.to)){let{preparePlaceholder:n}=e.state.facet(bf),s=n?Mr.replace({widget:new Sf(n(e.state,i.value))}):_f;t=t.update({add:[s.range(i.value.from,i.value.to)]})}else i.is(hf)&&(t=t.update({filter:(t,e)=>i.value.from!=t||i.value.to!=e,filterFrom:i.value.from,filterTo:i.value.to}));return e.selection&&(t=ff(t,e.selection.main.head)),t},provide:t=>Tc.decorations.from(t),toJSON(t,e){let i=[];return t.between(0,e.doc.length,(t,e)=>{i.push(t,e)}),i},fromJSON(t){if(!Array.isArray(t)||t.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let i=0;i<t.length;){let n=t[i++],s=t[i++];if("number"!=typeof n||"number"!=typeof s)throw new RangeError("Invalid JSON for fold state");e.push(_f.range(n,s))}return Mr.set(e,!0)}});function ff(t,e,i=e){let n=!1;return t.between(e,i,(t,s)=>{t<i&&s>e&&(n=!0)}),n?t.update({filterFrom:e,filterTo:i,filter:(t,n)=>t>=i||n<=e}):t}function pf(t,e,i){var n;let s=null;return null===(n=t.field(df,!1))||void 0===n||n.between(e,i,(t,e)=>{(!s||s.from>t)&&(s={from:t,to:e})}),s}function mf(t,e,i){let n=!1;return t.between(e,e,(t,s)=>{t==e&&s==i&&(n=!0)}),n}function gf(t,e){return t.field(df,!1)?e:e.concat(js.appendConfig.of(xf()))}function vf(t,e,i=!0){let n=t.state.doc.lineAt(e.from).number,s=t.state.doc.lineAt(e.to).number;return Tc.announce.of(`${t.state.phrase(i?"Folded lines":"Unfolded lines")} ${n} ${t.state.phrase("to")} ${s}.`)}const yf=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:t=>{for(let e of uf(t)){let i=af(t.state,e.from,e.to);if(i)return t.dispatch({effects:gf(t.state,[cf.of(i),vf(t,i)])}),!0}return!1}},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:t=>{if(!t.state.field(df,!1))return!1;let e=[];for(let i of uf(t)){let n=pf(t.state,i.from,i.to);n&&e.push(hf.of(n),vf(t,n,!1))}return e.length&&t.dispatch({effects:e}),e.length>0}},{key:"Ctrl-Alt-[",run:t=>{let{state:e}=t,i=[];for(let n=0;n<e.doc.length;){let s=t.lineBlockAt(n),o=af(e,s.from,s.to);o&&i.push(cf.of(o)),n=(o?t.lineBlockAt(o.to):s).to+1}return i.length&&t.dispatch({effects:gf(t.state,i)}),!!i.length}},{key:"Ctrl-Alt-]",run:t=>{let e=t.state.field(df,!1);if(!e||!e.size)return!1;let i=[];return e.between(0,t.state.doc.length,(t,e)=>{i.push(hf.of({from:t,to:e}))}),t.dispatch({effects:i}),!0}}],Of={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},bf=cs.define({combine:t=>Ks(t,Of)});function xf(t){let e=[df,Tf];return t&&e.push(bf.of(t)),e}function wf(t,e){let{state:i}=t,n=i.facet(bf),s=e=>{let i=t.lineBlockAt(t.posAtDOM(e.target)),n=pf(t.state,i.from,i.to);n&&t.dispatch({effects:hf.of(n)}),e.preventDefault()};if(n.placeholderDOM)return n.placeholderDOM(t,s,e);let o=document.createElement("span");return o.textContent=n.placeholderText,o.setAttribute("aria-label",i.phrase("folded code")),o.title=i.phrase("unfold"),o.className="cm-foldPlaceholder",o.onclick=s,o}const _f=Mr.replace({widget:new class extends Er{toDOM(t){return wf(t,null)}}});class Sf extends Er{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return wf(t,this.value)}}const kf={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class $f extends Yh{constructor(t,e){super(),this.config=t,this.open=e}eq(t){return this.config==t.config&&this.open==t.open}toDOM(t){if(this.config.markerDOM)return this.config.markerDOM(this.open);let e=document.createElement("span");return e.textContent=this.open?this.config.openText:this.config.closedText,e.title=t.state.phrase(this.open?"Fold line":"Unfold line"),e}}function Cf(t={}){let e={...kf,...t},i=new $f(e,!0),n=new $f(e,!1),s=Pa.fromClass(class{constructor(t){this.from=t.viewport.from,this.markers=this.buildMarkers(t)}update(t){(t.docChanged||t.viewportChanged||t.startState.facet(zd)!=t.state.facet(zd)||t.startState.field(df,!1)!=t.state.field(df,!1)||Ad(t.startState)!=Ad(t.state)||e.foldingChanged(t))&&(this.markers=this.buildMarkers(t.view))}buildMarkers(t){let e=new so;for(let s of t.viewportLineBlocks){let o=pf(t.state,s.from,s.to)?n:af(t.state,s.from,s.to)?i:null;o&&e.add(s.from,s.from,o)}return e.finish()}}),{domEventHandlers:o}=e;return[s,tu({class:"cm-foldGutter",markers(t){var e;return(null===(e=t.plugin(s))||void 0===e?void 0:e.markers)||no.empty},initialSpacer:()=>new $f(e,!1),domEventHandlers:{...o,click:(t,e,i)=>{if(o.click&&o.click(t,e,i))return!0;let n=pf(t.state,e.from,e.to);if(n)return t.dispatch({effects:hf.of(n)}),!0;let s=af(t.state,e.from,e.to);return!!s&&(t.dispatch({effects:cf.of(s)}),!0)}}}),xf()]}const Tf=Tc.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class Pf{constructor(t,e){let i;function n(t){let e=xo.newName();return(i||(i=Object.create(null)))["."+e]=t,e}this.specs=t;const s="string"==typeof e.all?e.all:e.all?n(e.all):void 0,o=e.scope;this.scope=o instanceof Td?t=>t.prop(kd)==o.data:o?t=>t==o:void 0,this.style=od(t.map(t=>({tag:t.tag,class:t.class||n(Object.assign({},t,{tag:null}))})),{all:s}).style,this.module=i?new xo(i):null,this.themeType=e.themeType}static define(t,e){return new Pf(t,e||{})}}const Ef=cs.define(),Af=cs.define({combine:t=>t.length?[t[0]]:null});function Mf(t){let e=t.facet(Ef);return e.length?e:t.facet(Af)}function Qf(t,e){let i,n=[Rf];return t instanceof Pf&&(t.module&&n.push(Tc.styleModule.of(t.module)),i=t.themeType),(null==e?void 0:e.fallback)?n.push(Af.of(t)):i?n.push(Ef.computeN([Tc.darkTheme],e=>e.facet(Tc.darkTheme)==("dark"==i)?[t]:[])):n.push(Ef.of(t)),n}class Df{constructor(t){this.markCache=Object.create(null),this.tree=Ad(t.state),this.decorations=this.buildDeco(t,Mf(t.state)),this.decoratedTo=t.viewport.to}update(t){let e=Ad(t.state),i=Mf(t.state),n=i!=Mf(t.startState),{viewport:s}=t.view,o=t.changes.mapPos(this.decoratedTo,1);e.length<s.to&&!n&&e.type==this.tree.type&&o>=s.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=o):(e!=this.tree||t.viewportChanged||n)&&(this.tree=e,this.decorations=this.buildDeco(t.view,i),this.decoratedTo=s.to)}buildDeco(t,e){if(!e||!this.tree.length)return Mr.none;let i=new so;for(let{from:n,to:s}of t.visibleRanges)rd(this.tree,e,(t,e,n)=>{i.add(t,e,this.markCache[n]||(this.markCache[n]=Mr.mark({class:n})))},n,s);return i.finish()}}const Rf=ws.high(Pa.fromClass(Df,{decorations:t=>t.decorations})),If=Pf.define([{tag:_d.meta,color:"#404740"},{tag:_d.link,textDecoration:"underline"},{tag:_d.heading,textDecoration:"underline",fontWeight:"bold"},{tag:_d.emphasis,fontStyle:"italic"},{tag:_d.strong,fontWeight:"bold"},{tag:_d.strikethrough,textDecoration:"line-through"},{tag:_d.keyword,color:"#708"},{tag:[_d.atom,_d.bool,_d.url,_d.contentSeparator,_d.labelName],color:"#219"},{tag:[_d.literal,_d.inserted],color:"#164"},{tag:[_d.string,_d.deleted],color:"#a11"},{tag:[_d.regexp,_d.escape,_d.special(_d.string)],color:"#e40"},{tag:_d.definition(_d.variableName),color:"#00f"},{tag:_d.local(_d.variableName),color:"#30a"},{tag:[_d.typeName,_d.namespace],color:"#085"},{tag:_d.className,color:"#167"},{tag:[_d.special(_d.variableName),_d.macroName],color:"#256"},{tag:_d.definition(_d.propertyName),color:"#00c"},{tag:_d.comment,color:"#940"},{tag:_d.invalid,color:"#f00"}]),Lf=Tc.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Nf="()[]{}",jf=cs.define({combine:t=>Ks(t,{afterCursor:!0,brackets:Nf,maxScanDistance:1e4,renderMatch:qf})}),zf=Mr.mark({class:"cm-matchingBracket"}),Bf=Mr.mark({class:"cm-nonmatchingBracket"});function qf(t){let e=[],i=t.matched?zf:Bf;return e.push(i.range(t.start.from,t.start.to)),t.end&&e.push(i.range(t.end.from,t.end.to)),e}const Zf=gs.define({create:()=>Mr.none,update(t,e){if(!e.docChanged&&!e.selection)return t;let i=[],n=e.state.facet(jf);for(let t of e.state.selection.ranges){if(!t.empty)continue;let s=Yf(e.state,t.head,-1,n)||t.head>0&&Yf(e.state,t.head-1,1,n)||n.afterCursor&&(Yf(e.state,t.head,1,n)||t.head<e.state.doc.length&&Yf(e.state,t.head+1,-1,n));s&&(i=i.concat(n.renderMatch(s,e.state)))}return Mr.set(i,!0)},provide:t=>Tc.decorations.from(t)}),Ff=[Zf,Lf];function Xf(t={}){return[jf.of(t),Ff]}const Hf=new wu;function Wf(t,e,i){let n=t.prop(e<0?wu.openedBy:wu.closedBy);if(n)return n;if(1==t.name.length){let n=i.indexOf(t.name);if(n>-1&&n%2==(e<0?1:0))return[i[n+e]]}return null}function Vf(t){let e=t.type.prop(Hf);return e?e(t.node):t}function Yf(t,e,i,n={}){let s=n.maxScanDistance||1e4,o=n.brackets||Nf,r=Ad(t),a=r.resolveInner(e,i);for(let n=a;n;n=n.parent){let s=Wf(n.type,i,o);if(s&&n.from<n.to){let r=Vf(n);if(r&&(i>0?e>=r.from&&e<r.to:e>r.from&&e<=r.to))return Uf(t,e,i,n,r,s,o)}}return function(t,e,i,n,s,o,r){let a=i<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),l=r.indexOf(a);if(l<0||l%2==0!=i>0)return null;let c={from:i<0?e-1:e,to:i>0?e+1:e},h=t.doc.iterRange(e,i>0?t.doc.length:0),u=0;for(let t=0;!h.next().done&&t<=o;){let o=h.value;i<0&&(t+=o.length);let a=e+t*i;for(let t=i>0?0:o.length-1,e=i>0?o.length:-1;t!=e;t+=i){let e=r.indexOf(o[t]);if(!(e<0||n.resolveInner(a+t,1).type!=s))if(e%2==0==i>0)u++;else{if(1==u)return{start:c,end:{from:a+t,to:a+t+1},matched:e>>1==l>>1};u--}}i>0&&(t+=o.length)}return h.done?{start:c,matched:!1}:null}(t,e,i,r,a.type,s,o)}function Uf(t,e,i,n,s,o,r){let a=n.parent,l={from:s.from,to:s.to},c=0,h=null==a?void 0:a.cursor();if(h&&(i<0?h.childBefore(n.from):h.childAfter(n.to)))do{if(i<0?h.to<=n.from:h.from>=n.to){if(0==c&&o.indexOf(h.type.name)>-1&&h.from<h.to){let t=Vf(h);return{start:l,end:t?{from:t.from,to:t.to}:void 0,matched:!0}}if(Wf(h.type,i,r))c++;else if(Wf(h.type,-i,r)){if(0==c){let t=Vf(h);return{start:l,end:t&&t.from<t.to?{from:t.from,to:t.to}:void 0,matched:!1}}c--}}}while(i<0?h.prevSibling():h.nextSibling());return{start:l,matched:!1}}const Gf=Object.create(null),Kf=[ku.none],Jf=[],tp=Object.create(null),ep=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])ep[t]=np(Gf,e);function ip(t,e){Jf.indexOf(t)>-1||(Jf.push(t),console.warn(e))}function np(t,e){let i=[];for(let n of e.split(" ")){let e=[];for(let i of n.split(".")){let n=t[i]||_d[i];n?"function"==typeof n?e.length?e=e.map(n):ip(i,`Modifier ${i} used at start of tag`):e.length?ip(i,`Tag ${i} used as modifier`):e=Array.isArray(n)?n:[n]:ip(i,`Unknown highlighting tag ${i}`)}for(let t of e)i.push(t)}if(!i.length)return 0;let n=e.replace(/ /g,"_"),s=n+" "+i.map(t=>t.id),o=tp[s];if(o)return o.id;let r=tp[s]=ku.define({id:Kf.length,name:n,props:[id({[n]:i})]});return Kf.push(r),r.id}Fr.RTL,Fr.LTR;function sp(t,e){return({state:i,dispatch:n})=>{if(i.readOnly)return!1;let s=t(e,i);return!!s&&(n(i.update(s)),!0)}}const op=sp(up,0),rp=sp(hp,0),ap=sp((t,e)=>hp(t,e,function(t){let e=[];for(let i of t.selection.ranges){let n=t.doc.lineAt(i.from),s=i.to<=n.to?n:t.doc.lineAt(i.to);s.from>n.from&&s.from==i.to&&(s=i.to==n.to+1?n:t.doc.lineAt(i.to-1));let o=e.length-1;o>=0&&e[o].to>n.from?e[o].to=s.to:e.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:s.to})}return e}(e)),0);function lp(t,e){let i=t.languageDataAt("commentTokens",e,1);return i.length?i[0]:{}}const cp=50;function hp(t,e,i=e.selection.ranges){let n=i.map(t=>lp(e,t.from).block);if(!n.every(t=>t))return null;let s=i.map((t,i)=>function(t,{open:e,close:i},n,s){let o,r,a=t.sliceDoc(n-cp,n),l=t.sliceDoc(s,s+cp),c=/\s*$/.exec(a)[0].length,h=/^\s*/.exec(l)[0].length,u=a.length-c;if(a.slice(u-e.length,u)==e&&l.slice(h,h+i.length)==i)return{open:{pos:n-c,margin:c&&1},close:{pos:s+h,margin:h&&1}};s-n<=2*cp?o=r=t.sliceDoc(n,s):(o=t.sliceDoc(n,n+cp),r=t.sliceDoc(s-cp,s));let d=/^\s*/.exec(o)[0].length,f=/\s*$/.exec(r)[0].length,p=r.length-f-i.length;return o.slice(d,d+e.length)==e&&r.slice(p,p+i.length)==i?{open:{pos:n+d+e.length,margin:/\s/.test(o.charAt(d+e.length))?1:0},close:{pos:s-f-i.length,margin:/\s/.test(r.charAt(p-1))?1:0}}:null}(e,n[i],t.from,t.to));if(2!=t&&!s.every(t=>t))return{changes:e.changes(i.map((t,e)=>s[e]?[]:[{from:t.from,insert:n[e].open+" "},{from:t.to,insert:" "+n[e].close}]))};if(1!=t&&s.some(t=>t)){let t=[];for(let e,i=0;i<s.length;i++)if(e=s[i]){let s=n[i],{open:o,close:r}=e;t.push({from:o.pos-s.open.length,to:o.pos+o.margin},{from:r.pos-r.margin,to:r.pos+s.close.length})}return{changes:t}}return null}function up(t,e,i=e.selection.ranges){let n=[],s=-1;for(let{from:t,to:o}of i){let i=n.length,r=1e9,a=lp(e,t).line;if(a){for(let i=t;i<=o;){let l=e.doc.lineAt(i);if(l.from>s&&(t==o||o>l.from)){s=l.from;let t=/^\s*/.exec(l.text)[0].length,e=t==l.length,i=l.text.slice(t,t+a.length)==a?t:-1;t<l.text.length&&t<r&&(r=t),n.push({line:l,comment:i,token:a,indent:t,empty:e,single:!1})}i=l.to+1}if(r<1e9)for(let t=i;t<n.length;t++)n[t].indent<n[t].line.text.length&&(n[t].indent=r);n.length==i+1&&(n[i].single=!0)}}if(2!=t&&n.some(t=>t.comment<0&&(!t.empty||t.single))){let t=[];for(let{line:e,token:i,indent:s,empty:o,single:r}of n)!r&&o||t.push({from:e.from+s,insert:i+" "});let i=e.changes(t);return{changes:i,selection:e.selection.map(i,1)}}if(1!=t&&n.some(t=>t.comment>=0)){let t=[];for(let{line:e,comment:i,token:s}of n)if(i>=0){let n=e.from+i,o=n+s.length;" "==e.text[o-e.from]&&o++,t.push({from:n,to:o})}return{changes:t}}return null}const dp=Is.define(),fp=Is.define(),pp=cs.define(),mp=cs.define({combine:t=>Ks(t,{minDepth:100,newGroupDelay:500,joinToEvent:(t,e)=>e},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,e)=>(i,n)=>t(i,n)||e(i,n)})}),gp=gs.define({create:()=>Qp.empty,update(t,e){let i=e.state.facet(mp),n=e.annotation(dp);if(n){let s=_p.fromTransaction(e,n.selection),o=n.side,r=0==o?t.undone:t.done;return r=s?Sp(r,r.length,i.minDepth,s):Tp(r,e.startState.selection),new Qp(0==o?n.rest:r,0==o?r:n.rest)}let s=e.annotation(fp);if("full"!=s&&"before"!=s||(t=t.isolate()),!1===e.annotation(zs.addToHistory))return e.changes.empty?t:t.addMapping(e.changes.desc);let o=_p.fromTransaction(e),r=e.annotation(zs.time),a=e.annotation(zs.userEvent);return o?t=t.addChanges(o,r,a,i,e):e.selection&&(t=t.addSelection(e.startState.selection,r,a,i.newGroupDelay)),"full"!=s&&"after"!=s||(t=t.isolate()),t},toJSON:t=>({done:t.done.map(t=>t.toJSON()),undone:t.undone.map(t=>t.toJSON())}),fromJSON:t=>new Qp(t.done.map(_p.fromJSON),t.undone.map(_p.fromJSON))});function vp(t={}){return[gp,mp.of(t),Tc.domEventHandlers({beforeinput(t,e){let i="historyUndo"==t.inputType?Op:"historyRedo"==t.inputType?bp:null;return!!i&&(t.preventDefault(),i(e))}})]}function yp(t,e){return function({state:i,dispatch:n}){if(!e&&i.readOnly)return!1;let s=i.field(gp,!1);if(!s)return!1;let o=s.pop(t,i,e);return!!o&&(n(o),!0)}}const Op=yp(0,!1),bp=yp(1,!1),xp=yp(0,!0),wp=yp(1,!0);class _p{constructor(t,e,i,n,s){this.changes=t,this.effects=e,this.mapped=i,this.startSelection=n,this.selectionsAfter=s}setSelAfter(t){return new _p(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,e,i;return{changes:null===(t=this.changes)||void 0===t?void 0:t.toJSON(),mapped:null===(e=this.mapped)||void 0===e?void 0:e.toJSON(),startSelection:null===(i=this.startSelection)||void 0===i?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(t=>t.toJSON())}}static fromJSON(t){return new _p(t.changes&&Kn.fromJSON(t.changes),[],t.mapped&&Gn.fromJSON(t.mapped),t.startSelection&&rs.fromJSON(t.startSelection),t.selectionsAfter.map(rs.fromJSON))}static fromTransaction(t,e){let i=$p;for(let e of t.startState.facet(pp)){let n=e(t);n.length&&(i=i.concat(n))}return!i.length&&t.changes.empty?null:new _p(t.changes.invert(t.startState.doc),i,void 0,e||t.startState.selection,$p)}static selection(t){return new _p(void 0,$p,void 0,void 0,t)}}function Sp(t,e,i,n){let s=e+1>i+20?e-i-1:0,o=t.slice(s,e);return o.push(n),o}function kp(t,e){return t.length?e.length?t.concat(e):t:e}const $p=[],Cp=200;function Tp(t,e){if(t.length){let i=t[t.length-1],n=i.selectionsAfter.slice(Math.max(0,i.selectionsAfter.length-Cp));return n.length&&n[n.length-1].eq(e)?t:(n.push(e),Sp(t,t.length-1,1e9,i.setSelAfter(n)))}return[_p.selection([e])]}function Pp(t){let e=t[t.length-1],i=t.slice();return i[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),i}function Ep(t,e){if(!t.length)return t;let i=t.length,n=$p;for(;i;){let s=Ap(t[i-1],e,n);if(s.changes&&!s.changes.empty||s.effects.length){let e=t.slice(0,i);return e[i-1]=s,e}e=s.mapped,i--,n=s.selectionsAfter}return n.length?[_p.selection(n)]:$p}function Ap(t,e,i){let n=kp(t.selectionsAfter.length?t.selectionsAfter.map(t=>t.map(e)):$p,i);if(!t.changes)return _p.selection(n);let s=t.changes.map(e),o=e.mapDesc(t.changes,!0),r=t.mapped?t.mapped.composeDesc(o):o;return new _p(s,js.mapEffects(t.effects,e),r,t.startSelection.map(o),n)}const Mp=/^(input\.type|delete)($|\.)/;class Qp{constructor(t,e,i=0,n=void 0){this.done=t,this.undone=e,this.prevTime=i,this.prevUserEvent=n}isolate(){return this.prevTime?new Qp(this.done,this.undone):this}addChanges(t,e,i,n,s){let o=this.done,r=o[o.length-1];return o=r&&r.changes&&!r.changes.empty&&t.changes&&(!i||Mp.test(i))&&(!r.selectionsAfter.length&&e-this.prevTime<n.newGroupDelay&&n.joinToEvent(s,function(t,e){let i=[],n=!1;return t.iterChangedRanges((t,e)=>i.push(t,e)),e.iterChangedRanges((t,e,s,o)=>{for(let t=0;t<i.length;){let e=i[t++],r=i[t++];o>=e&&s<=r&&(n=!0)}}),n}(r.changes,t.changes))||"input.type.compose"==i)?Sp(o,o.length-1,n.minDepth,new _p(t.changes.compose(r.changes),kp(js.mapEffects(t.effects,r.changes),r.effects),r.mapped,r.startSelection,$p)):Sp(o,o.length,n.minDepth,t),new Qp(o,$p,e,i)}addSelection(t,e,i,n){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:$p;return s.length>0&&e-this.prevTime<n&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&(o=s[s.length-1],r=t,o.ranges.length==r.ranges.length&&0===o.ranges.filter((t,e)=>t.empty!=r.ranges[e].empty).length)?this:new Qp(Tp(this.done,t),this.undone,e,i);var o,r}addMapping(t){return new Qp(Ep(this.done,t),Ep(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,e,i){let n=0==t?this.done:this.undone;if(0==n.length)return null;let s=n[n.length-1],o=s.selectionsAfter[0]||e.selection;if(i&&s.selectionsAfter.length)return e.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:dp.of({side:t,rest:Pp(n),selection:o}),userEvent:0==t?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let i=1==n.length?$p:n.slice(0,n.length-1);return s.mapped&&(i=Ep(i,s.mapped)),e.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:dp.of({side:t,rest:i,selection:o}),filter:!1,userEvent:0==t?"undo":"redo",scrollIntoView:!0})}return null}}Qp.empty=new Qp($p,$p);const Dp=[{key:"Mod-z",run:Op,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:bp,preventDefault:!0},{linux:"Ctrl-Shift-z",run:bp,preventDefault:!0},{key:"Mod-u",run:xp,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:wp,preventDefault:!0}];function Rp(t,e){return rs.create(t.ranges.map(e),t.mainIndex)}function Ip(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function Lp({state:t,dispatch:e},i){let n=Rp(t.selection,i);return!n.eq(t.selection,!0)&&(e(Ip(t,n)),!0)}function Np(t,e){return rs.cursor(e?t.to:t.from)}function jp(t,e){return Lp(t,i=>i.empty?t.moveByChar(i,e):Np(i,e))}function zp(t){return t.textDirectionAt(t.state.selection.main.head)==Fr.LTR}const Bp=t=>jp(t,!zp(t)),qp=t=>jp(t,zp(t));function Zp(t,e){return Lp(t,i=>i.empty?t.moveByGroup(i,e):Np(i,e))}"undefined"!=typeof Intl&&Intl.Segmenter;function Fp(t,e,i){if(e.type.prop(i))return!0;let n=e.to-e.from;return n&&(n>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Xp(t,e,i){let n,s,o=Ad(t).resolveInner(e.head),r=i?wu.closedBy:wu.openedBy;for(let n=e.head;;){let e=i?o.childAfter(n):o.childBefore(n);if(!e)break;Fp(t,e,r)?o=e:n=i?e.to:e.from}return s=o.type.prop(r)&&(n=i?Yf(t,o.from,1):Yf(t,o.to,-1))&&n.matched?i?n.end.to:n.end.from:i?o.to:o.from,rs.cursor(s,i?-1:1)}function Hp(t,e){return Lp(t,i=>{if(!i.empty)return Np(i,e);let n=t.moveVertically(i,e);return n.head!=i.head?n:t.moveToLineBoundary(i,e)})}const Wp=t=>Hp(t,!1),Vp=t=>Hp(t,!0);function Yp(t){let e,i=t.scrollDOM.clientHeight<t.scrollDOM.scrollHeight-2,n=0,s=0;if(i){for(let e of t.state.facet(Tc.scrollMargins)){let i=e(t);(null==i?void 0:i.top)&&(n=Math.max(null==i?void 0:i.top,n)),(null==i?void 0:i.bottom)&&(s=Math.max(null==i?void 0:i.bottom,s))}e=t.scrollDOM.clientHeight-n-s}else e=(t.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:s,selfScroll:i,height:Math.max(t.defaultLineHeight,e-5)}}function Up(t,e){let i,n=Yp(t),{state:s}=t,o=Rp(s.selection,i=>i.empty?t.moveVertically(i,e,n.height):Np(i,e));if(o.eq(s.selection))return!1;if(n.selfScroll){let e=t.coordsAtPos(s.selection.main.head),r=t.scrollDOM.getBoundingClientRect(),a=r.top+n.marginTop,l=r.bottom-n.marginBottom;e&&e.top>a&&e.bottom<l&&(i=Tc.scrollIntoView(o.main.head,{y:"start",yMargin:e.top-a}))}return t.dispatch(Ip(s,o),{effects:i}),!0}const Gp=t=>Up(t,!1),Kp=t=>Up(t,!0);function Jp(t,e,i){let n=t.lineBlockAt(e.head),s=t.moveToLineBoundary(e,i);if(s.head==e.head&&s.head!=(i?n.to:n.from)&&(s=t.moveToLineBoundary(e,i,!1)),!i&&s.head==n.from&&n.length){let i=/^\s*/.exec(t.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;i&&e.head!=n.from+i&&(s=rs.cursor(n.from+i))}return s}function tm(t,e,i){let n=!1,s=Rp(t.selection,e=>{let s=Yf(t,e.head,-1)||Yf(t,e.head,1)||e.head>0&&Yf(t,e.head-1,1)||e.head<t.doc.length&&Yf(t,e.head+1,-1);if(!s||!s.end)return e;n=!0;let o=s.start.from==e.head?s.end.to:s.end.from;return i?rs.range(e.anchor,o):rs.cursor(o)});return!!n&&(e(Ip(t,s)),!0)}function em(t,e){let i=Rp(t.state.selection,t=>{let i=e(t);return rs.range(t.anchor,i.head,i.goalColumn,i.bidiLevel||void 0)});return!i.eq(t.state.selection)&&(t.dispatch(Ip(t.state,i)),!0)}function im(t,e){return em(t,i=>t.moveByChar(i,e))}const nm=t=>im(t,!zp(t)),sm=t=>im(t,zp(t));function om(t,e){return em(t,i=>t.moveByGroup(i,e))}function rm(t,e){return em(t,i=>t.moveVertically(i,e))}const am=t=>rm(t,!1),lm=t=>rm(t,!0);function cm(t,e){return em(t,i=>t.moveVertically(i,e,Yp(t).height))}const hm=t=>cm(t,!1),um=t=>cm(t,!0),dm=({state:t,dispatch:e})=>(e(Ip(t,{anchor:0})),!0),fm=({state:t,dispatch:e})=>(e(Ip(t,{anchor:t.doc.length})),!0),pm=({state:t,dispatch:e})=>(e(Ip(t,{anchor:t.selection.main.anchor,head:0})),!0),mm=({state:t,dispatch:e})=>(e(Ip(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0);function gm(t,e){if(t.state.readOnly)return!1;let i="delete.selection",{state:n}=t,s=n.changeByRange(n=>{let{from:s,to:o}=n;if(s==o){let r=e(n);r<s?(i="delete.backward",r=vm(t,r,!1)):r>s&&(i="delete.forward",r=vm(t,r,!0)),s=Math.min(s,r),o=Math.max(o,r)}else s=vm(t,s,!1),o=vm(t,o,!0);return s==o?{range:n}:{changes:{from:s,to:o},range:rs.cursor(s,s<n.head?-1:1)}});return!s.changes.empty&&(t.dispatch(n.update(s,{scrollIntoView:!0,userEvent:i,effects:"delete.selection"==i?Tc.announce.of(n.phrase("Selection deleted")):void 0})),!0)}function vm(t,e,i){if(t instanceof Tc)for(let n of t.state.facet(Tc.atomicRanges).map(e=>e(t)))n.between(e,e,(t,n)=>{t<e&&n>e&&(e=i?n:t)});return e}const ym=(t,e,i)=>gm(t,n=>{let s,o,r=n.from,{state:a}=t,l=a.doc.lineAt(r);if(i&&!e&&r>l.from&&r<l.from+200&&!/[^ \t]/.test(s=l.text.slice(0,r-l.from))){if("\t"==s[s.length-1])return r-1;let t=go(s,a.tabSize)%Fd(a)||Fd(a);for(let e=0;e<t&&" "==s[s.length-1-e];e++)r--;o=r}else o=Xn(l.text,r-l.from,e,e)+l.from,o==r&&l.number!=(e?a.doc.lines:1)?o+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(l.text.slice(o-l.from,r-l.from))&&(o=Xn(l.text,o-l.from,!1,!1)+l.from);return o}),Om=t=>ym(t,!1,!0),bm=t=>ym(t,!0,!1),xm=(t,e)=>gm(t,i=>{let n=i.head,{state:s}=t,o=s.doc.lineAt(n),r=s.charCategorizer(n);for(let t=null;;){if(n==(e?o.to:o.from)){n==i.head&&o.number!=(e?s.doc.lines:1)&&(n+=e?1:-1);break}let a=Xn(o.text,n-o.from,e)+o.from,l=o.text.slice(Math.min(n,a)-o.from,Math.max(n,a)-o.from),c=r(l);if(null!=t&&c!=t)break;" "==l&&n==i.head||(t=c),n=a}return n}),wm=t=>xm(t,!1);function _m(t){let e=[],i=-1;for(let n of t.selection.ranges){let s=t.doc.lineAt(n.from),o=t.doc.lineAt(n.to);if(n.empty||n.to!=o.from||(o=t.doc.lineAt(n.to-1)),i>=s.number){let t=e[e.length-1];t.to=o.to,t.ranges.push(n)}else e.push({from:s.from,to:o.to,ranges:[n]});i=o.number+1}return e}function Sm(t,e,i){if(t.readOnly)return!1;let n=[],s=[];for(let e of _m(t)){if(i?e.to==t.doc.length:0==e.from)continue;let o=t.doc.lineAt(i?e.to+1:e.from-1),r=o.length+1;if(i){n.push({from:e.to,to:o.to},{from:e.from,insert:o.text+t.lineBreak});for(let i of e.ranges)s.push(rs.range(Math.min(t.doc.length,i.anchor+r),Math.min(t.doc.length,i.head+r)))}else{n.push({from:o.from,to:e.from},{from:e.to,insert:t.lineBreak+o.text});for(let t of e.ranges)s.push(rs.range(t.anchor-r,t.head-r))}}return!!n.length&&(e(t.update({changes:n,scrollIntoView:!0,selection:rs.create(s,t.selection.mainIndex),userEvent:"move.line"})),!0)}function km(t,e,i){if(t.readOnly)return!1;let n=[];for(let e of _m(t))i?n.push({from:e.from,insert:t.doc.slice(e.from,e.to)+t.lineBreak}):n.push({from:e.to,insert:t.lineBreak+t.doc.slice(e.from,e.to)});return e(t.update({changes:n,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const $m=Cm(!1);function Cm(t){return({state:e,dispatch:i})=>{if(e.readOnly)return!1;let n=e.changeByRange(i=>{let{from:n,to:s}=i,o=e.doc.lineAt(n),r=!t&&n==s&&function(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let i,n=Ad(t).resolveInner(e),s=n.childBefore(e),o=n.childAfter(e);return s&&o&&s.to<=e&&o.from>=e&&(i=s.type.prop(wu.closedBy))&&i.indexOf(o.name)>-1&&t.doc.lineAt(s.to).from==t.doc.lineAt(o.from).from&&!/\S/.test(t.sliceDoc(s.to,o.from))?{from:s.to,to:o.from}:null}(e,n);t&&(n=s=(s<=o.to?o:e.doc.lineAt(s)).to);let a=new Wd(e,{simulateBreak:n,simulateDoubleBreak:!!r}),l=Hd(a,n);for(null==l&&(l=go(/^\s*/.exec(e.doc.lineAt(n).text)[0],e.tabSize));s<o.to&&/\s/.test(o.text[s-o.from]);)s++;r?({from:n,to:s}=r):n>o.from&&n<o.from+100&&!/\S/.test(o.text.slice(0,n))&&(n=o.from);let c=["",Xd(e,l)];return r&&c.push(Xd(e,a.lineIndent(o.from,-1))),{changes:{from:n,to:s,insert:Rn.of(c)},range:rs.cursor(n+1+c[1].length)}});return i(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}}function Tm(t,e){let i=-1;return t.changeByRange(n=>{let s=[];for(let o=n.from;o<=n.to;){let r=t.doc.lineAt(o);r.number>i&&(n.empty||n.to>r.from)&&(e(r,s,n),i=r.number),o=r.to+1}let o=t.changes(s);return{changes:s,range:rs.range(o.mapPos(n.anchor,1),o.mapPos(n.head,1))}})}const Pm=({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(Tm(t,(e,i)=>{i.push({from:e.from,insert:t.facet(Zd)})}),{userEvent:"input.indent"})),!0),Em=({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(Tm(t,(e,i)=>{let n=/^\s*/.exec(e.text)[0];if(!n)return;let s=go(n,t.tabSize),o=0,r=Xd(t,Math.max(0,s-Fd(t)));for(;o<n.length&&o<r.length&&n.charCodeAt(o)==r.charCodeAt(o);)o++;i.push({from:e.from+o,to:e.from+n.length,insert:r.slice(o)})}),{userEvent:"delete.dedent"})),!0),Am=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:t=>Lp(t,e=>Xp(t.state,e,!zp(t))),shift:t=>em(t,e=>Xp(t.state,e,!zp(t)))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:t=>Lp(t,e=>Xp(t.state,e,zp(t))),shift:t=>em(t,e=>Xp(t.state,e,zp(t)))},{key:"Alt-ArrowUp",run:({state:t,dispatch:e})=>Sm(t,e,!1)},{key:"Shift-Alt-ArrowUp",run:({state:t,dispatch:e})=>km(t,e,!1)},{key:"Alt-ArrowDown",run:({state:t,dispatch:e})=>Sm(t,e,!0)},{key:"Shift-Alt-ArrowDown",run:({state:t,dispatch:e})=>km(t,e,!0)},{key:"Escape",run:({state:t,dispatch:e})=>{let i=t.selection,n=null;return i.ranges.length>1?n=rs.create([i.main]):i.main.empty||(n=rs.create([rs.cursor(i.main.head)])),!!n&&(e(Ip(t,n)),!0)}},{key:"Mod-Enter",run:Cm(!0)},{key:"Alt-l",mac:"Ctrl-l",run:({state:t,dispatch:e})=>{let i=_m(t).map(({from:e,to:i})=>rs.range(e,Math.min(i+1,t.doc.length)));return e(t.update({selection:rs.create(i),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:t,dispatch:e})=>{let i=Rp(t.selection,e=>{let i=Ad(t),n=i.resolveStack(e.from,1);if(e.empty){let t=i.resolveStack(e.from,-1);t.node.from>=n.node.from&&t.node.to<=n.node.to&&(n=t)}for(let t=n;t;t=t.next){let{node:i}=t;if((i.from<e.from&&i.to>=e.to||i.to>e.to&&i.from<=e.from)&&t.next)return rs.range(i.to,i.from)}return e});return!i.eq(t.selection)&&(e(Ip(t,i)),!0)},preventDefault:!0},{key:"Mod-[",run:Em},{key:"Mod-]",run:Pm},{key:"Mod-Alt-\\",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=Object.create(null),n=new Wd(t,{overrideIndentation:t=>{let e=i[t];return null==e?-1:e}}),s=Tm(t,(e,s,o)=>{let r=Hd(n,e.from);if(null==r)return;/\S/.test(e.text)||(r=0);let a=/^\s*/.exec(e.text)[0],l=Xd(t,r);(a!=l||o.from<e.from+a.length)&&(i[e.from]=r,s.push({from:e.from,to:e.from+a.length,insert:l}))});return s.changes.empty||e(t.update(s,{userEvent:"indent"})),!0}},{key:"Shift-Mod-k",run:t=>{if(t.state.readOnly)return!1;let{state:e}=t,i=e.changes(_m(e).map(({from:t,to:i})=>(t>0?t--:i<e.doc.length&&i++,{from:t,to:i}))),n=Rp(e.selection,e=>{let i;if(t.lineWrapping){let n=t.lineBlockAt(e.head),s=t.coordsAtPos(e.head,e.assoc||1);s&&(i=n.bottom+t.documentTop-s.bottom+t.defaultLineHeight/2)}return t.moveVertically(e,!0,i)}).map(i);return t.dispatch({changes:i,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:({state:t,dispatch:e})=>tm(t,e,!1)},{key:"Mod-/",run:t=>{let{state:e}=t,i=e.doc.lineAt(e.selection.main.from),n=lp(t.state,i.from);return n.line?op(t):!!n.block&&ap(t)}},{key:"Alt-A",run:rp},{key:"Ctrl-m",mac:"Shift-Alt-m",run:t=>(t.setTabFocusMode(),!0)}].concat([{key:"ArrowLeft",run:Bp,shift:nm,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:t=>Zp(t,!zp(t)),shift:t=>om(t,!zp(t)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:t=>Lp(t,e=>Jp(t,e,!zp(t))),shift:t=>em(t,e=>Jp(t,e,!zp(t))),preventDefault:!0},{key:"ArrowRight",run:qp,shift:sm,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:t=>Zp(t,zp(t)),shift:t=>om(t,zp(t)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:t=>Lp(t,e=>Jp(t,e,zp(t))),shift:t=>em(t,e=>Jp(t,e,zp(t))),preventDefault:!0},{key:"ArrowUp",run:Wp,shift:am,preventDefault:!0},{mac:"Cmd-ArrowUp",run:dm,shift:pm},{mac:"Ctrl-ArrowUp",run:Gp,shift:hm},{key:"ArrowDown",run:Vp,shift:lm,preventDefault:!0},{mac:"Cmd-ArrowDown",run:fm,shift:mm},{mac:"Ctrl-ArrowDown",run:Kp,shift:um},{key:"PageUp",run:Gp,shift:hm},{key:"PageDown",run:Kp,shift:um},{key:"Home",run:t=>Lp(t,e=>Jp(t,e,!1)),shift:t=>em(t,e=>Jp(t,e,!1)),preventDefault:!0},{key:"Mod-Home",run:dm,shift:pm},{key:"End",run:t=>Lp(t,e=>Jp(t,e,!0)),shift:t=>em(t,e=>Jp(t,e,!0)),preventDefault:!0},{key:"Mod-End",run:fm,shift:mm},{key:"Enter",run:$m,shift:$m},{key:"Mod-a",run:({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:Om,shift:Om},{key:"Delete",run:bm},{key:"Mod-Backspace",mac:"Alt-Backspace",run:wm},{key:"Mod-Delete",mac:"Alt-Delete",run:t=>xm(t,!0)},{mac:"Mod-Backspace",run:t=>gm(t,e=>{let i=t.moveToLineBoundary(e,!1).head;return e.head>i?i:Math.max(0,e.head-1)})},{mac:"Mod-Delete",run:t=>gm(t,e=>{let i=t.moveToLineBoundary(e,!0).head;return e.head<i?i:Math.min(t.state.doc.length,e.head+1)})}].concat([{key:"Ctrl-b",run:Bp,shift:nm,preventDefault:!0},{key:"Ctrl-f",run:qp,shift:sm},{key:"Ctrl-p",run:Wp,shift:am},{key:"Ctrl-n",run:Vp,shift:lm},{key:"Ctrl-a",run:t=>Lp(t,e=>rs.cursor(t.lineBlockAt(e.head).from,1)),shift:t=>em(t,e=>rs.cursor(t.lineBlockAt(e.head).from))},{key:"Ctrl-e",run:t=>Lp(t,e=>rs.cursor(t.lineBlockAt(e.head).to,-1)),shift:t=>em(t,e=>rs.cursor(t.lineBlockAt(e.head).to))},{key:"Ctrl-d",run:bm},{key:"Ctrl-h",run:Om},{key:"Ctrl-k",run:t=>gm(t,e=>{let i=t.lineBlockAt(e.head).to;return e.head<i?i:Math.min(t.state.doc.length,e.head+1)})},{key:"Ctrl-Alt-h",run:wm},{key:"Ctrl-o",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:Rn.of(["",""])},range:rs.cursor(t.from)}));return e(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange(e=>{if(!e.empty||0==e.from||e.from==t.doc.length)return{range:e};let i=e.from,n=t.doc.lineAt(i),s=i==n.from?i-1:Xn(n.text,i-n.from,!1)+n.from,o=i==n.to?i+1:Xn(n.text,i-n.from,!0)+n.from;return{changes:{from:s,to:o,insert:t.doc.slice(i,o).append(t.doc.slice(s,i))},range:rs.cursor(o)}});return!i.changes.empty&&(e(t.update(i,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:Kp}].map(t=>({mac:t.key,run:t.run,shift:t.shift}))));function Mm(){var t=arguments[0];"string"==typeof t&&(t=document.createElement(t));var e=1,i=arguments[1];if(i&&"object"==typeof i&&null==i.nodeType&&!Array.isArray(i)){for(var n in i)if(Object.prototype.hasOwnProperty.call(i,n)){var s=i[n];"string"==typeof s?t.setAttribute(n,s):null!=s&&(t[n]=s)}e++}for(;e<arguments.length;e++)Qm(t,arguments[e]);return t}function Qm(t,e){if("string"==typeof e)t.appendChild(document.createTextNode(e));else if(null==e);else if(null!=e.nodeType)t.appendChild(e);else{if(!Array.isArray(e))throw new RangeError("Unsupported child node: "+e);for(var i=0;i<e.length;i++)Qm(t,e[i])}}const Dm="function"==typeof String.prototype.normalize?t=>t.normalize("NFKD"):t=>t;class Rm{constructor(t,e,i=0,n=t.length,s,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=t.iterRange(i,n),this.bufferStart=i,this.normalize=s?t=>s(Dm(t)):Dm,this.query=this.normalize(e)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return Hn(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let t=this.peek();if(t<0)return this.done=!0,this;let e=Wn(t),i=this.bufferStart+this.bufferPos;this.bufferPos+=Vn(t);let n=this.normalize(e);if(n.length)for(let t=0,s=i;;t++){let o=n.charCodeAt(t),r=this.match(o,s,this.bufferPos+this.bufferStart);if(t==n.length-1){if(r)return this.value=r,this;break}s==i&&t<e.length&&e.charCodeAt(t)==o&&s++}}}match(t,e,i){let n=null;for(let e=0;e<this.matches.length;e+=2){let s=this.matches[e],o=!1;this.query.charCodeAt(s)==t&&(s==this.query.length-1?n={from:this.matches[e+1],to:i}:(this.matches[e]++,o=!0)),o||(this.matches.splice(e,2),e-=2)}return this.query.charCodeAt(0)==t&&(1==this.query.length?n={from:e,to:i}:this.matches.push(1,e)),n&&this.test&&!this.test(n.from,n.to,this.buffer,this.bufferStart)&&(n=null),n}}"undefined"!=typeof Symbol&&(Rm.prototype[Symbol.iterator]=function(){return this});const Im={from:-1,to:-1,match:/.*/.exec("")},Lm="gm"+(null==/x/.unicode?"":"u");class Nm{constructor(t,e,i,n=0,s=t.length){if(this.text=t,this.to=s,this.curLine="",this.done=!1,this.value=Im,/\\[sWDnr]|\n|\r|\[\^/.test(e))return new Bm(t,e,i,n,s);this.re=new RegExp(e,Lm+((null==i?void 0:i.ignoreCase)?"i":"")),this.test=null==i?void 0:i.test,this.iter=t.iter();let o=t.lineAt(n);this.curLineStart=o.from,this.matchPos=qm(t,n),this.getLine(this.curLineStart)}getLine(t){this.iter.next(t),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let t=this.matchPos-this.curLineStart;;){this.re.lastIndex=t;let e=this.matchPos<=this.to&&this.re.exec(this.curLine);if(e){let i=this.curLineStart+e.index,n=i+e[0].length;if(this.matchPos=qm(this.text,n+(i==n?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(i<n||i>this.value.to)&&(!this.test||this.test(i,n,e)))return this.value={from:i,to:n,match:e},this;t=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length<this.to))return this.done=!0,this;this.nextLine(),t=0}}}}const jm=new WeakMap;class zm{constructor(t,e){this.from=t,this.text=e}get to(){return this.from+this.text.length}static get(t,e,i){let n=jm.get(t);if(!n||n.from>=i||n.to<=e){let n=new zm(e,t.sliceString(e,i));return jm.set(t,n),n}if(n.from==e&&n.to==i)return n;let{text:s,from:o}=n;return o>e&&(s=t.sliceString(e,o)+s,o=e),n.to<i&&(s+=t.sliceString(n.to,i)),jm.set(t,new zm(o,s)),new zm(e,s.slice(e-o,i-o))}}class Bm{constructor(t,e,i,n,s){this.text=t,this.to=s,this.done=!1,this.value=Im,this.matchPos=qm(t,n),this.re=new RegExp(e,Lm+((null==i?void 0:i.ignoreCase)?"i":"")),this.test=null==i?void 0:i.test,this.flat=zm.get(t,n,this.chunkEnd(n+5e3))}chunkEnd(t){return t>=this.to?this.to:this.text.lineAt(t).to}next(){for(;;){let t=this.re.lastIndex=this.matchPos-this.flat.from,e=this.re.exec(this.flat.text);if(e&&!e[0]&&e.index==t&&(this.re.lastIndex=t+1,e=this.re.exec(this.flat.text)),e){let t=this.flat.from+e.index,i=t+e[0].length;if((this.flat.to>=this.to||e.index+e[0].length<=this.flat.text.length-10)&&(!this.test||this.test(t,i,e)))return this.value={from:t,to:i,match:e},this.matchPos=qm(this.text,i+(t==i?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=zm.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function qm(t,e){if(e>=t.length)return e;let i,n=t.lineAt(e);for(;e<n.to&&(i=n.text.charCodeAt(e-n.from))>=56320&&i<57344;)e++;return e}function Zm(t){let e=Mm("input",{class:"cm-textfield",name:"line",value:String(t.state.doc.lineAt(t.state.selection.main.head).number)});function i(){let i=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(e.value);if(!i)return;let{state:n}=t,s=n.doc.lineAt(n.selection.main.head),[,o,r,a,l]=i,c=a?+a.slice(1):0,h=r?+r:s.number;if(r&&l){let t=h/100;o&&(t=t*("-"==o?-1:1)+s.number/n.doc.lines),h=Math.round(n.doc.lines*t)}else r&&o&&(h=h*("-"==o?-1:1)+s.number);let u=n.doc.line(Math.max(1,Math.min(n.doc.lines,h))),d=rs.cursor(u.from+Math.max(0,Math.min(c,u.length)));t.dispatch({effects:[Fm.of(!1),Tc.scrollIntoView(d.from,{y:"center"})],selection:d}),t.focus()}return{dom:Mm("form",{class:"cm-gotoLine",onkeydown:e=>{27==e.keyCode?(e.preventDefault(),t.dispatch({effects:Fm.of(!1)}),t.focus()):13==e.keyCode&&(e.preventDefault(),i())},onsubmit:t=>{t.preventDefault(),i()}},Mm("label",t.state.phrase("Go to line"),": ",e)," ",Mm("button",{class:"cm-button",type:"submit"},t.state.phrase("go")),Mm("button",{name:"close",onclick:()=>{t.dispatch({effects:Fm.of(!1)}),t.focus()},"aria-label":t.state.phrase("close"),type:"button"},["×"]))}}"undefined"!=typeof Symbol&&(Nm.prototype[Symbol.iterator]=Bm.prototype[Symbol.iterator]=function(){return this});const Fm=js.define(),Xm=gs.define({create:()=>!0,update(t,e){for(let i of e.effects)i.is(Fm)&&(t=i.value);return t},provide:t=>Vh.from(t,t=>t?Zm:null)}),Hm=Tc.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px",position:"relative","& label":{fontSize:"80%"},"& [name=close]":{position:"absolute",top:"0",bottom:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:"0"}}}),Wm={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Vm=cs.define({combine:t=>Ks(t,Wm,{highlightWordAroundCursor:(t,e)=>t||e,minSelectionLength:Math.min,maxMatches:Math.min})});function Ym(t){let e=[tg,Jm];return t&&e.push(Vm.of(t)),e}const Um=Mr.mark({class:"cm-selectionMatch"}),Gm=Mr.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function Km(t,e,i,n){return!(0!=i&&t(e.sliceDoc(i-1,i))==Ws.Word||n!=e.doc.length&&t(e.sliceDoc(n,n+1))==Ws.Word)}const Jm=Pa.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.selectionSet||t.docChanged||t.viewportChanged)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=t.state.facet(Vm),{state:i}=t,n=i.selection;if(n.ranges.length>1)return Mr.none;let s,o=n.main,r=null;if(o.empty){if(!e.highlightWordAroundCursor)return Mr.none;let t=i.wordAt(o.head);if(!t)return Mr.none;r=i.charCategorizer(o.head),s=i.sliceDoc(t.from,t.to)}else{let t=o.to-o.from;if(t<e.minSelectionLength||t>200)return Mr.none;if(e.wholeWords){if(s=i.sliceDoc(o.from,o.to),r=i.charCategorizer(o.head),!Km(r,i,o.from,o.to)||!function(t,e,i,n){return t(e.sliceDoc(i,i+1))==Ws.Word&&t(e.sliceDoc(n-1,n))==Ws.Word}(r,i,o.from,o.to))return Mr.none}else if(s=i.sliceDoc(o.from,o.to),!s)return Mr.none}let a=[];for(let n of t.visibleRanges){let t=new Rm(i.doc,s,n.from,n.to);for(;!t.next().done;){let{from:n,to:s}=t.value;if((!r||Km(r,i,n,s))&&(o.empty&&n<=o.from&&s>=o.to?a.push(Gm.range(n,s)):(n>=o.to||s<=o.from)&&a.push(Um.range(n,s)),a.length>e.maxMatches))return Mr.none}}return Mr.set(a)}},{decorations:t=>t.decorations}),tg=Tc.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}});const eg=cs.define({combine:t=>Ks(t,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:t=>new Eg(t),scrollToMatch:t=>Tc.scrollIntoView(t)})});class ig{constructor(t){this.search=t.search,this.caseSensitive=!!t.caseSensitive,this.literal=!!t.literal,this.regexp=!!t.regexp,this.replace=t.replace||"",this.valid=!!this.search&&(!this.regexp||function(t){try{return new RegExp(t,Lm),!0}catch(t){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!t.wholeWord}unquote(t){return this.literal?t:t.replace(/\\([nrt\\])/g,(t,e)=>"n"==e?"\n":"r"==e?"\r":"t"==e?"\t":"\\")}eq(t){return this.search==t.search&&this.replace==t.replace&&this.caseSensitive==t.caseSensitive&&this.regexp==t.regexp&&this.wholeWord==t.wholeWord}create(){return this.regexp?new cg(this):new og(this)}getCursor(t,e=0,i){let n=t.doc?t:Gs.create({doc:t});return null==i&&(i=n.doc.length),this.regexp?rg(this,n,e,i):sg(this,n,e,i)}}class ng{constructor(t){this.spec=t}}function sg(t,e,i,n){return new Rm(e.doc,t.unquoted,i,n,t.caseSensitive?void 0:t=>t.toLowerCase(),t.wholeWord?function(t,e){return(i,n,s,o)=>((o>i||o+s.length<n)&&(o=Math.max(0,i-2),s=t.sliceString(o,Math.min(t.length,n+2))),!(e(ag(s,i-o))==Ws.Word&&e(lg(s,i-o))==Ws.Word||e(lg(s,n-o))==Ws.Word&&e(ag(s,n-o))==Ws.Word))}(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}class og extends ng{constructor(t){super(t)}nextMatch(t,e,i){let n=sg(this.spec,t,i,t.doc.length).nextOverlapping();if(n.done){let i=Math.min(t.doc.length,e+this.spec.unquoted.length);n=sg(this.spec,t,0,i).nextOverlapping()}return n.done||n.value.from==e&&n.value.to==i?null:n.value}prevMatchInRange(t,e,i){for(let n=i;;){let i=Math.max(e,n-1e4-this.spec.unquoted.length),s=sg(this.spec,t,i,n),o=null;for(;!s.nextOverlapping().done;)o=s.value;if(o)return o;if(i==e)return null;n-=1e4}}prevMatch(t,e,i){let n=this.prevMatchInRange(t,0,e);return n||(n=this.prevMatchInRange(t,Math.max(0,i-this.spec.unquoted.length),t.doc.length)),!n||n.from==e&&n.to==i?null:n}getReplacement(t){return this.spec.unquote(this.spec.replace)}matchAll(t,e){let i=sg(this.spec,t,0,t.doc.length),n=[];for(;!i.next().done;){if(n.length>=e)return null;n.push(i.value)}return n}highlight(t,e,i,n){let s=sg(this.spec,t,Math.max(0,e-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,t.doc.length));for(;!s.next().done;)n(s.value.from,s.value.to)}}function rg(t,e,i,n){return new Nm(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:t.wholeWord?(s=e.charCategorizer(e.selection.main.head),(t,e,i)=>!i[0].length||(s(ag(i.input,i.index))!=Ws.Word||s(lg(i.input,i.index))!=Ws.Word)&&(s(lg(i.input,i.index+i[0].length))!=Ws.Word||s(ag(i.input,i.index+i[0].length))!=Ws.Word)):void 0},i,n);var s}function ag(t,e){return t.slice(Xn(t,e,!1),e)}function lg(t,e){return t.slice(e,Xn(t,e))}class cg extends ng{nextMatch(t,e,i){let n=rg(this.spec,t,i,t.doc.length).next();return n.done&&(n=rg(this.spec,t,0,e).next()),n.done?null:n.value}prevMatchInRange(t,e,i){for(let n=1;;n++){let s=Math.max(e,i-1e4*n),o=rg(this.spec,t,s,i),r=null;for(;!o.next().done;)r=o.value;if(r&&(s==e||r.from>s+10))return r;if(s==e)return null}}prevMatch(t,e,i){return this.prevMatchInRange(t,0,e)||this.prevMatchInRange(t,i,t.doc.length)}getReplacement(t){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(e,i)=>{if("&"==i)return t.match[0];if("$"==i)return"$";for(let e=i.length;e>0;e--){let n=+i.slice(0,e);if(n>0&&n<t.match.length)return t.match[n]+i.slice(e)}return e})}matchAll(t,e){let i=rg(this.spec,t,0,t.doc.length),n=[];for(;!i.next().done;){if(n.length>=e)return null;n.push(i.value)}return n}highlight(t,e,i,n){let s=rg(this.spec,t,Math.max(0,e-250),Math.min(i+250,t.doc.length));for(;!s.next().done;)n(s.value.from,s.value.to)}}const hg=js.define(),ug=js.define(),dg=gs.define({create:t=>new fg(Sg(t).create(),null),update(t,e){for(let i of e.effects)i.is(hg)?t=new fg(i.value.create(),t.panel):i.is(ug)&&(t=new fg(t.query,i.value?_g:null));return t},provide:t=>Vh.from(t,t=>t.panel)});class fg{constructor(t,e){this.query=t,this.panel=e}}const pg=Mr.mark({class:"cm-searchMatch"}),mg=Mr.mark({class:"cm-searchMatch cm-searchMatch-selected"}),gg=Pa.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(dg))}update(t){let e=t.state.field(dg);(e!=t.startState.field(dg)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return Mr.none;let{view:i}=this,n=new so;for(let e=0,s=i.visibleRanges,o=s.length;e<o;e++){let{from:r,to:a}=s[e];for(;e<o-1&&a>s[e+1].from-500;)a=s[++e].to;t.highlight(i.state,r,a,(t,e)=>{let s=i.state.selection.ranges.some(i=>i.from==t&&i.to==e);n.add(t,e,s?mg:pg)})}return n.finish()}},{decorations:t=>t.decorations});function vg(t){return e=>{let i=e.state.field(dg,!1);return i&&i.query.spec.valid?t(e,i):Cg(e)}}const yg=vg((t,{query:e})=>{let{to:i}=t.state.selection.main,n=e.nextMatch(t.state,i,i);if(!n)return!1;let s=rs.single(n.from,n.to),o=t.state.facet(eg);return t.dispatch({selection:s,effects:[Dg(t,n),o.scrollToMatch(s.main,t)],userEvent:"select.search"}),$g(t),!0}),Og=vg((t,{query:e})=>{let{state:i}=t,{from:n}=i.selection.main,s=e.prevMatch(i,n,n);if(!s)return!1;let o=rs.single(s.from,s.to),r=t.state.facet(eg);return t.dispatch({selection:o,effects:[Dg(t,s),r.scrollToMatch(o.main,t)],userEvent:"select.search"}),$g(t),!0}),bg=vg((t,{query:e})=>{let i=e.matchAll(t.state,1e3);return!(!i||!i.length)&&(t.dispatch({selection:rs.create(i.map(t=>rs.range(t.from,t.to))),userEvent:"select.search.matches"}),!0)}),xg=vg((t,{query:e})=>{let{state:i}=t,{from:n,to:s}=i.selection.main;if(i.readOnly)return!1;let o=e.nextMatch(i,n,n);if(!o)return!1;let r,a,l=o,c=[],h=[];l.from==n&&l.to==s&&(a=i.toText(e.getReplacement(l)),c.push({from:l.from,to:l.to,insert:a}),l=e.nextMatch(i,l.from,l.to),h.push(Tc.announce.of(i.phrase("replaced match on line $",i.doc.lineAt(n).number)+".")));let u=t.state.changes(c);return l&&(r=rs.single(l.from,l.to).map(u),h.push(Dg(t,l)),h.push(i.facet(eg).scrollToMatch(r.main,t))),t.dispatch({changes:u,selection:r,effects:h,userEvent:"input.replace"}),!0}),wg=vg((t,{query:e})=>{if(t.state.readOnly)return!1;let i=e.matchAll(t.state,1e9).map(t=>{let{from:i,to:n}=t;return{from:i,to:n,insert:e.getReplacement(t)}});if(!i.length)return!1;let n=t.state.phrase("replaced $ matches",i.length)+".";return t.dispatch({changes:i,effects:Tc.announce.of(n),userEvent:"input.replace.all"}),!0});function _g(t){return t.state.facet(eg).createPanel(t)}function Sg(t,e){var i,n,s,o,r;let a=t.selection.main,l=a.empty||a.to>a.from+100?"":t.sliceDoc(a.from,a.to);if(e&&!l)return e;let c=t.facet(eg);return new ig({search:(null!==(i=null==e?void 0:e.literal)&&void 0!==i?i:c.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:null!==(n=null==e?void 0:e.caseSensitive)&&void 0!==n?n:c.caseSensitive,literal:null!==(s=null==e?void 0:e.literal)&&void 0!==s?s:c.literal,regexp:null!==(o=null==e?void 0:e.regexp)&&void 0!==o?o:c.regexp,wholeWord:null!==(r=null==e?void 0:e.wholeWord)&&void 0!==r?r:c.wholeWord})}function kg(t){let e=Fh(t,_g);return e&&e.dom.querySelector("[main-field]")}function $g(t){let e=kg(t);e&&e==t.root.activeElement&&e.select()}const Cg=t=>{let e=t.state.field(dg,!1);if(e&&e.panel){let i=kg(t);if(i&&i!=t.root.activeElement){let n=Sg(t.state,e.query.spec);n.valid&&t.dispatch({effects:hg.of(n)}),i.focus(),i.select()}}else t.dispatch({effects:[ug.of(!0),e?hg.of(Sg(t.state,e.query.spec)):js.appendConfig.of(Ig)]});return!0},Tg=t=>{let e=t.state.field(dg,!1);if(!e||!e.panel)return!1;let i=Fh(t,_g);return i&&i.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:ug.of(!1)}),!0},Pg=[{key:"Mod-f",run:Cg,scope:"editor search-panel"},{key:"F3",run:yg,shift:Og,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:yg,shift:Og,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Tg,scope:"editor search-panel"},{key:"Mod-Shift-l",run:({state:t,dispatch:e})=>{let i=t.selection;if(i.ranges.length>1||i.main.empty)return!1;let{from:n,to:s}=i.main,o=[],r=0;for(let e=new Rm(t.doc,t.sliceDoc(n,s));!e.next().done;){if(o.length>1e3)return!1;e.value.from==n&&(r=o.length),o.push(rs.range(e.value.from,e.value.to))}return e(t.update({selection:rs.create(o,r),userEvent:"select.search.matches"})),!0}},{key:"Mod-Alt-g",run:t=>{let e=Fh(t,Zm);if(!e){let i=[Fm.of(!0)];null==t.state.field(Xm,!1)&&i.push(js.appendConfig.of([Xm,Hm])),t.dispatch({effects:i}),e=Fh(t,Zm)}return e&&e.dom.querySelector("input").select(),!0}},{key:"Mod-d",run:({state:t,dispatch:e})=>{let{ranges:i}=t.selection;if(i.some(t=>t.from===t.to))return(({state:t,dispatch:e})=>{let{selection:i}=t,n=rs.create(i.ranges.map(e=>t.wordAt(e.head)||rs.cursor(e.head)),i.mainIndex);return!n.eq(i)&&(e(t.update({selection:n})),!0)})({state:t,dispatch:e});let n=t.sliceDoc(i[0].from,i[0].to);if(t.selection.ranges.some(e=>t.sliceDoc(e.from,e.to)!=n))return!1;let s=function(t,e){let{main:i,ranges:n}=t.selection,s=t.wordAt(i.head),o=s&&s.from==i.from&&s.to==i.to;for(let i=!1,s=new Rm(t.doc,e,n[n.length-1].to);;){if(s.next(),!s.done){if(i&&n.some(t=>t.from==s.value.from))continue;if(o){let e=t.wordAt(s.value.from);if(!e||e.from!=s.value.from||e.to!=s.value.to)continue}return s.value}if(i)return null;s=new Rm(t.doc,e,0,Math.max(0,n[n.length-1].from-1)),i=!0}}(t,n);return!!s&&(e(t.update({selection:t.selection.addRange(rs.range(s.from,s.to),!1),effects:Tc.scrollIntoView(s.to)})),!0)},preventDefault:!0}];class Eg{constructor(t){this.view=t;let e=this.query=t.state.field(dg).query.spec;function i(t,e,i){return Mm("button",{class:"cm-button",name:t,onclick:e,type:"button"},i)}this.commit=this.commit.bind(this),this.searchField=Mm("input",{value:e.search,placeholder:Ag(t,"Find"),"aria-label":Ag(t,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Mm("input",{value:e.replace,placeholder:Ag(t,"Replace"),"aria-label":Ag(t,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=Mm("input",{type:"checkbox",name:"case",form:"",checked:e.caseSensitive,onchange:this.commit}),this.reField=Mm("input",{type:"checkbox",name:"re",form:"",checked:e.regexp,onchange:this.commit}),this.wordField=Mm("input",{type:"checkbox",name:"word",form:"",checked:e.wholeWord,onchange:this.commit}),this.dom=Mm("div",{onkeydown:t=>this.keydown(t),class:"cm-search"},[this.searchField,i("next",()=>yg(t),[Ag(t,"next")]),i("prev",()=>Og(t),[Ag(t,"previous")]),i("select",()=>bg(t),[Ag(t,"all")]),Mm("label",null,[this.caseField,Ag(t,"match case")]),Mm("label",null,[this.reField,Ag(t,"regexp")]),Mm("label",null,[this.wordField,Ag(t,"by word")]),...t.state.readOnly?[]:[Mm("br"),this.replaceField,i("replace",()=>xg(t),[Ag(t,"replace")]),i("replaceAll",()=>wg(t),[Ag(t,"replace all")])],Mm("button",{name:"close",onclick:()=>Tg(t),"aria-label":Ag(t,"close"),type:"button"},["×"])])}commit(){let t=new ig({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});t.eq(this.query)||(this.query=t,this.view.dispatch({effects:hg.of(t)}))}keydown(t){var e,i,n;e=this.view,i=t,n="search-panel",qc(Nc(e.state),i,e,n)?t.preventDefault():13==t.keyCode&&t.target==this.searchField?(t.preventDefault(),(t.shiftKey?Og:yg)(this.view)):13==t.keyCode&&t.target==this.replaceField&&(t.preventDefault(),xg(this.view))}update(t){for(let e of t.transactions)for(let t of e.effects)t.is(hg)&&!t.value.eq(this.query)&&this.setQuery(t.value)}setQuery(t){this.query=t,this.searchField.value=t.search,this.replaceField.value=t.replace,this.caseField.checked=t.caseSensitive,this.reField.checked=t.regexp,this.wordField.checked=t.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(eg).top}}function Ag(t,e){return t.state.phrase(e)}const Mg=30,Qg=/[\s\.,:;?!]/;function Dg(t,{from:e,to:i}){let n=t.state.doc.lineAt(e),s=t.state.doc.lineAt(i).to,o=Math.max(n.from,e-Mg),r=Math.min(s,i+Mg),a=t.state.sliceDoc(o,r);if(o!=n.from)for(let t=0;t<Mg;t++)if(!Qg.test(a[t+1])&&Qg.test(a[t])){a=a.slice(t);break}if(r!=s)for(let t=a.length-1;t>a.length-Mg;t--)if(!Qg.test(a[t-1])&&Qg.test(a[t])){a=a.slice(0,t);break}return Tc.announce.of(`${t.state.phrase("current match")}. ${a} ${t.state.phrase("on line")} ${n.number}.`)}const Rg=Tc.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),Ig=[dg,ws.low(gg),Rg];class Lg{constructor(t,e,i,n){this.state=t,this.pos=e,this.explicit=i,this.view=n,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let e=Ad(this.state).resolveInner(this.pos,-1);for(;e&&t.indexOf(e.name)<0;)e=e.parent;return e?{from:e.from,to:this.pos,text:this.state.sliceDoc(e.from,this.pos),type:e.type}:null}matchBefore(t){let e=this.state.doc.lineAt(this.pos),i=Math.max(e.from,this.pos-250),n=e.text.slice(i-e.from,this.pos-e.from),s=n.search(qg(t,!1));return s<0?null:{from:i+s,to:this.pos,text:n.slice(s)}}get aborted(){return null==this.abortListeners}addEventListener(t,e,i){"abort"==t&&this.abortListeners&&(this.abortListeners.push(e),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function Ng(t){let e=Object.keys(t).join(""),i=/\w/.test(e);return i&&(e=e.replace(/\w/g,"")),`[${i?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function jg(t){let e=t.map(t=>"string"==typeof t?{label:t}:t),[i,n]=e.every(t=>/^\w+$/.test(t.label))?[/\w*$/,/\w+$/]:function(t){let e=Object.create(null),i=Object.create(null);for(let{label:n}of t){e[n[0]]=!0;for(let t=1;t<n.length;t++)i[n[t]]=!0}let n=Ng(e)+Ng(i)+"*$";return[new RegExp("^"+n),new RegExp(n)]}(e);return t=>{let s=t.matchBefore(n);return s||t.explicit?{from:s?s.from:t.pos,options:e,validFor:i}:null}}class zg{constructor(t,e,i,n){this.completion=t,this.source=e,this.match=i,this.score=n}}function Bg(t){return t.selection.main.from}function qg(t,e){var i;let{source:n}=t,s=e&&"^"!=n[0],o="$"!=n[n.length-1];return s||o?new RegExp(`${s?"^":""}(?:${n})${o?"$":""}`,null!==(i=t.flags)&&void 0!==i?i:t.ignoreCase?"i":""):t}const Zg=Is.define();const Fg=new WeakMap;function Xg(t){if(!Array.isArray(t))return t;let e=Fg.get(t);return e||Fg.set(t,e=jg(t)),e}const Hg=js.define(),Wg=js.define();class Vg{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let e=0;e<t.length;){let i=Hn(t,e),n=Vn(i);this.chars.push(i);let s=t.slice(e,e+n),o=s.toUpperCase();this.folded.push(Hn(o==s?s.toLowerCase():o,0)),e+=n}this.astral=t.length!=this.chars.length}ret(t,e){return this.score=t,this.matched=e,this}match(t){if(0==this.pattern.length)return this.ret(-100,[]);if(t.length<this.pattern.length)return null;let{chars:e,folded:i,any:n,precise:s,byWord:o}=this;if(1==e.length){let n=Hn(t,0),s=Vn(n),o=s==t.length?0:-100;if(n==e[0]);else{if(n!=i[0])return null;o+=-200}return this.ret(o,[0,s])}let r=t.indexOf(this.pattern);if(0==r)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=e.length,l=0;if(r<0){for(let s=0,o=Math.min(t.length,200);s<o&&l<a;){let o=Hn(t,s);o!=e[l]&&o!=i[l]||(n[l++]=s),s+=Vn(o)}if(l<a)return null}let c=0,h=0,u=!1,d=0,f=-1,p=-1,m=/[a-z]/.test(t),g=!0;for(let n=0,l=Math.min(t.length,200),v=0;n<l&&h<a;){let l=Hn(t,n);r<0&&(c<a&&l==e[c]&&(s[c++]=n),d<a&&(l==e[d]||l==i[d]?(0==d&&(f=n),p=n+1,d++):d=0));let y,O=l<255?l>=48&&l<=57||l>=97&&l<=122?2:l>=65&&l<=90?1:0:(y=Wn(l))!=y.toLowerCase()?1:y!=y.toUpperCase()?2:0;(!n||1==O&&m||0==v&&0!=O)&&(e[h]==l||i[h]==l&&(u=!0)?o[h++]=n:o.length&&(g=!1)),v=O,n+=Vn(l)}return h==a&&0==o[0]&&g?this.result((u?-200:0)-100,o,t):d==a&&0==f?this.ret(-200-t.length+(p==t.length?0:-100),[0,p]):r>-1?this.ret(-700-t.length,[r,r+this.pattern.length]):d==a?this.ret(-900-t.length,[f,p]):h==a?this.result((u?-200:0)-100-700+(g?0:-1100),o,t):2==e.length?null:this.result((n[0]?-700:0)-200-1100,n,t)}result(t,e,i){let n=[],s=0;for(let t of e){let e=t+(this.astral?Vn(Hn(i,t)):1);s&&n[s-1]==t?n[s-1]=e:(n[s++]=t,n[s++]=e)}return this.ret(t-i.length,n)}}class Yg{constructor(t){this.pattern=t,this.matched=[],this.score=0,this.folded=t.toLowerCase()}match(t){if(t.length<this.pattern.length)return null;let e=t.slice(0,this.pattern.length),i=e==this.pattern?0:e.toLowerCase()==this.folded?-200:null;return null==i?null:(this.matched=[0,e.length],this.score=i+(t.length==this.pattern.length?0:-100),this)}}const Ug=cs.define({combine:t=>Ks(t,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Kg,filterStrict:!1,compareCompletions:(t,e)=>t.label.localeCompare(e.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(t,e)=>t&&e,closeOnBlur:(t,e)=>t&&e,icons:(t,e)=>t&&e,tooltipClass:(t,e)=>i=>Gg(t(i),e(i)),optionClass:(t,e)=>i=>Gg(t(i),e(i)),addToOptions:(t,e)=>t.concat(e),filterStrict:(t,e)=>t||e})});function Gg(t,e){return t?e?t+" "+e:t:e}function Kg(t,e,i,n,s,o){let r,a,l=t.textDirection==Fr.RTL,c=l,h=!1,u="top",d=e.left-s.left,f=s.right-e.right,p=n.right-n.left,m=n.bottom-n.top;if(c&&d<Math.min(p,f)?c=!1:!c&&f<Math.min(p,d)&&(c=!0),p<=(c?d:f))r=Math.max(s.top,Math.min(i.top,s.bottom-m))-e.top,a=Math.min(400,c?d:f);else{h=!0,a=Math.min(400,(l?e.right:s.right-e.left)-30);let t=s.bottom-e.bottom;t>=m||t>e.top?r=i.bottom-e.top:(u="bottom",r=e.bottom-i.top)}return{style:`${u}: ${r/((e.bottom-e.top)/o.offsetHeight)}px; max-width: ${a/((e.right-e.left)/o.offsetWidth)}px`,class:"cm-completionInfo-"+(h?l?"left-narrow":"right-narrow":c?"left":"right")}}function Jg(t,e,i){if(t<=i)return{from:0,to:t};if(e<0&&(e=0),e<=t>>1){let t=Math.floor(e/i);return{from:t*i,to:(t+1)*i}}let n=Math.floor((t-e)/i);return{from:t-(n+1)*i,to:t-n*i}}class tv{constructor(t,e,i){this.view=t,this.stateField=e,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:t=>this.placeInfo(t),key:this},this.space=null,this.currentClass="";let n=t.state.field(e),{options:s,selected:o}=n.open,r=t.state.facet(Ug);this.optionContent=function(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(t){let e=document.createElement("div");return e.classList.add("cm-completionIcon"),t.type&&e.classList.add(...t.type.split(/\s+/g).map(t=>"cm-completionIcon-"+t)),e.setAttribute("aria-hidden","true"),e},position:20}),e.push({render(t,e,i,n){let s=document.createElement("span");s.className="cm-completionLabel";let o=t.displayLabel||t.label,r=0;for(let t=0;t<n.length;){let e=n[t++],i=n[t++];e>r&&s.appendChild(document.createTextNode(o.slice(r,e)));let a=s.appendChild(document.createElement("span"));a.appendChild(document.createTextNode(o.slice(e,i))),a.className="cm-completionMatchedText",r=i}return r<o.length&&s.appendChild(document.createTextNode(o.slice(r))),s},position:50},{render(t){if(!t.detail)return null;let e=document.createElement("span");return e.className="cm-completionDetail",e.textContent=t.detail,e},position:80}),e.sort((t,e)=>t.position-e.position).map(t=>t.render)}(r),this.optionClass=r.optionClass,this.tooltipClass=r.tooltipClass,this.range=Jg(s.length,o,r.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",i=>{let{options:n}=t.state.field(e).open;for(let e,s=i.target;s&&s!=this.dom;s=s.parentNode)if("LI"==s.nodeName&&(e=/-(\d+)$/.exec(s.id))&&+e[1]<n.length)return this.applyCompletion(t,n[+e[1]]),void i.preventDefault()}),this.dom.addEventListener("focusout",e=>{let i=t.state.field(this.stateField,!1);i&&i.tooltip&&t.state.facet(Ug).closeOnBlur&&e.relatedTarget!=t.contentDOM&&t.dispatch({effects:Wg.of(null)})}),this.showOptions(s,n.id)}mount(){this.updateSel()}showOptions(t,e){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t,e,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(t){var e;let i=t.state.field(this.stateField),n=t.startState.field(this.stateField);if(this.updateTooltipClass(t.state),i!=n){let{options:s,selected:o,disabled:r}=i.open;n.open&&n.open.options==s||(this.range=Jg(s.length,o,t.state.facet(Ug).maxRenderedOptions),this.showOptions(s,i.id)),this.updateSel(),r!=(null===(e=n.open)||void 0===e?void 0:e.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!r)}}updateTooltipClass(t){let e=this.tooltipClass(t);if(e!=this.currentClass){for(let t of this.currentClass.split(" "))t&&this.dom.classList.remove(t);for(let t of e.split(" "))t&&this.dom.classList.add(t);this.currentClass=e}}positioned(t){this.space=t,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let t=this.view.state.field(this.stateField),e=t.open;if((e.selected>-1&&e.selected<this.range.from||e.selected>=this.range.to)&&(this.range=Jg(e.options.length,e.selected,this.view.state.facet(Ug).maxRenderedOptions),this.showOptions(e.options,t.id)),this.updateSelectedOption(e.selected)){this.destroyInfo();let{completion:i}=e.options[e.selected],{info:n}=i;if(!n)return;let s="string"==typeof n?document.createTextNode(n):n(i);if(!s)return;"then"in s?s.then(e=>{e&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(e,i)}).catch(t=>ka(this.view.state,t,"completion info")):this.addInfoPane(s,i)}}addInfoPane(t,e){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",null!=t.nodeType)i.appendChild(t),this.infoDestroy=null;else{let{dom:e,destroy:n}=t;i.appendChild(e),this.infoDestroy=n||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){let e=null;for(let i=this.list.firstChild,n=this.range.from;i;i=i.nextSibling,n++)"LI"==i.nodeName&&i.id?n==t?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),e=i):i.hasAttribute("aria-selected")&&i.removeAttribute("aria-selected"):n--;return e&&function(t,e){let i=t.getBoundingClientRect(),n=e.getBoundingClientRect(),s=i.height/t.offsetHeight;n.top<i.top?t.scrollTop-=(i.top-n.top)/s:n.bottom>i.bottom&&(t.scrollTop+=(n.bottom-i.bottom)/s)}(this.list,e),e}measureInfo(){let t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;let e=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),n=t.getBoundingClientRect(),s=this.space;if(!s){let t=this.dom.ownerDocument.documentElement;s={left:0,top:0,right:t.clientWidth,bottom:t.clientHeight}}return n.top>Math.min(s.bottom,e.bottom)-10||n.bottom<Math.max(s.top,e.top)+10?null:this.view.state.facet(Ug).positionInfo(this.view,e,n,i,s,this.dom)}placeInfo(t){this.info&&(t?(t.style&&(this.info.style.cssText=t.style),this.info.className="cm-tooltip cm-completionInfo "+(t.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(t,e,i){const n=document.createElement("ul");n.id=e,n.setAttribute("role","listbox"),n.setAttribute("aria-expanded","true"),n.setAttribute("aria-label",this.view.state.phrase("Completions")),n.addEventListener("mousedown",t=>{t.target==n&&t.preventDefault()});let s=null;for(let o=i.from;o<i.to;o++){let{completion:r,match:a}=t[o],{section:l}=r;if(l){let t="string"==typeof l?l:l.name;if(t!=s&&(o>i.from||0==i.from))if(s=t,"string"!=typeof l&&l.header)n.appendChild(l.header(l));else{n.appendChild(document.createElement("completion-section")).textContent=t}}const c=n.appendChild(document.createElement("li"));c.id=e+"-"+o,c.setAttribute("role","option");let h=this.optionClass(r);h&&(c.className=h);for(let t of this.optionContent){let e=t(r,this.view.state,this.view,a);e&&c.appendChild(e)}}return i.from&&n.classList.add("cm-completionListIncompleteTop"),i.to<t.length&&n.classList.add("cm-completionListIncompleteBottom"),n}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function ev(t,e){return i=>new tv(i,t,e)}function iv(t){return 100*(t.boost||0)+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}class nv{constructor(t,e,i,n,s,o){this.options=t,this.attrs=e,this.tooltip=i,this.timestamp=n,this.selected=s,this.disabled=o}setSelected(t,e){return t==this.selected||t>=this.options.length?this:new nv(this.options,av(e,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,e,i,n,s,o){if(n&&!o&&t.some(t=>t.isPending))return n.setDisabled();let r=function(t,e){let i=[],n=null,s=t=>{i.push(t);let{section:e}=t.completion;if(e){n||(n=[]);let t="string"==typeof e?e:e.name;n.some(e=>e.name==t)||n.push("string"==typeof e?{name:t}:e)}},o=e.facet(Ug);for(let n of t)if(n.hasResult()){let t=n.result.getMatch;if(!1===n.result.filter)for(let e of n.result.options)s(new zg(e,n.source,t?t(e):[],1e9-i.length));else{let i,r=e.sliceDoc(n.from,n.to),a=o.filterStrict?new Yg(r):new Vg(r);for(let e of n.result.options)if(i=a.match(e.label)){let o=e.displayLabel?t?t(e,i.matched):[]:i.matched;s(new zg(e,n.source,o,i.score+(e.boost||0)))}}}if(n){let t=Object.create(null),e=0,s=(t,e)=>{var i,n;return(null!==(i=t.rank)&&void 0!==i?i:1e9)-(null!==(n=e.rank)&&void 0!==n?n:1e9)||(t.name<e.name?-1:1)};for(let i of n.sort(s))e-=1e5,t[i.name]=e;for(let e of i){let{section:i}=e.completion;i&&(e.score+=t["string"==typeof i?i:i.name])}}let r=[],a=null,l=o.compareCompletions;for(let t of i.sort((t,e)=>e.score-t.score||l(t.completion,e.completion))){let e=t.completion;!a||a.label!=e.label||a.detail!=e.detail||null!=a.type&&null!=e.type&&a.type!=e.type||a.apply!=e.apply||a.boost!=e.boost?r.push(t):iv(t.completion)>iv(a)&&(r[r.length-1]=t),a=t.completion}return r}(t,e);if(!r.length)return n&&t.some(t=>t.isPending)?n.setDisabled():null;let a=e.facet(Ug).selectOnOpen?0:-1;if(n&&n.selected!=a&&-1!=n.selected){let t=n.options[n.selected].completion;for(let e=0;e<r.length;e++)if(r[e].completion==t){a=e;break}}return new nv(r,av(i,a),{pos:t.reduce((t,e)=>e.hasResult()?Math.min(t,e.from):t,1e8),create:gv,above:s.aboveCursor},n?n.timestamp:Date.now(),a,!1)}map(t){return new nv(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:t.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}setDisabled(){return new nv(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class sv{constructor(t,e,i){this.active=t,this.id=e,this.open=i}static start(){return new sv(lv,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(t){let{state:e}=t,i=e.facet(Ug),n=(i.override||e.languageDataAt("autocomplete",Bg(e)).map(Xg)).map(e=>(this.active.find(t=>t.source==e)||new hv(e,this.active.some(t=>0!=t.state)?1:0)).update(t,i));n.length==this.active.length&&n.every((t,e)=>t==this.active[e])&&(n=this.active);let s=this.open,o=t.effects.some(t=>t.is(dv));s&&t.docChanged&&(s=s.map(t.changes)),t.selection||n.some(e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to))||!function(t,e){if(t==e)return!0;for(let i=0,n=0;;){for(;i<t.length&&!t[i].hasResult();)i++;for(;n<e.length&&!e[n].hasResult();)n++;let s=i==t.length,o=n==e.length;if(s||o)return s==o;if(t[i++].result!=e[n++].result)return!1}}(n,this.active)||o?s=nv.build(n,e,this.id,s,i,o):s&&s.disabled&&!n.some(t=>t.isPending)&&(s=null),!s&&n.every(t=>!t.isPending)&&n.some(t=>t.hasResult())&&(n=n.map(t=>t.hasResult()?new hv(t.source,0):t));for(let e of t.effects)e.is(fv)&&(s=s&&s.setSelected(e.value,this.id));return n==this.active&&s==this.open?this:new sv(n,this.id,s)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?ov:rv}}const ov={"aria-autocomplete":"list"},rv={};function av(t,e){let i={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(i["aria-activedescendant"]=t+"-"+e),i}const lv=[];function cv(t,e){if(t.isUserEvent("input.complete")){let i=t.annotation(Zg);if(i&&e.activateOnCompletion(i))return 12}let i=t.isUserEvent("input.type");return i&&e.activateOnTyping?5:i?1:t.isUserEvent("delete.backward")?2:t.selection?8:t.docChanged?16:0}class hv{constructor(t,e,i=!1){this.source=t,this.state=e,this.explicit=i}hasResult(){return!1}get isPending(){return 1==this.state}update(t,e){let i=cv(t,e),n=this;(8&i||16&i&&this.touches(t))&&(n=new hv(n.source,0)),4&i&&0==n.state&&(n=new hv(this.source,1)),n=n.updateFor(t,i);for(let e of t.effects)if(e.is(Hg))n=new hv(n.source,1,e.value);else if(e.is(Wg))n=new hv(n.source,0);else if(e.is(dv))for(let t of e.value)t.source==n.source&&(n=t);return n}updateFor(t,e){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(Bg(t.state))}}class uv extends hv{constructor(t,e,i,n,s,o){super(t,3,e),this.limit=i,this.result=n,this.from=s,this.to=o}hasResult(){return!0}updateFor(t,e){var i;if(!(3&e))return this.map(t.changes);let n=this.result;n.map&&!t.changes.empty&&(n=n.map(n,t.changes));let s=t.changes.mapPos(this.from),o=t.changes.mapPos(this.to,1),r=Bg(t.state);if(r>o||!n||2&e&&(Bg(t.startState)==this.from||r<this.limit))return new hv(this.source,4&e?1:0);let a=t.changes.mapPos(this.limit);return function(t,e,i,n){if(!t)return!1;let s=e.sliceDoc(i,n);return"function"==typeof t?t(s,i,n,e):qg(t,!0).test(s)}(n.validFor,t.state,s,o)?new uv(this.source,this.explicit,a,n,s,o):n.update&&(n=n.update(n,s,o,new Lg(t.state,r,!1)))?new uv(this.source,this.explicit,a,n,n.from,null!==(i=n.to)&&void 0!==i?i:Bg(t.state)):new hv(this.source,1,this.explicit)}map(t){if(t.empty)return this;return(this.result.map?this.result.map(this.result,t):this.result)?new uv(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new hv(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}const dv=js.define({map:(t,e)=>t.map(t=>t.map(e))}),fv=js.define(),pv=gs.define({create:()=>sv.start(),update:(t,e)=>t.update(e),provide:t=>[Dh.from(t,t=>t.tooltip),Tc.contentAttributes.from(t,t=>t.attrs)]});function mv(t,e){const i=e.completion.apply||e.completion.label;let n=t.state.field(pv).active.find(t=>t.source==e.source);return n instanceof uv&&("string"==typeof i?t.dispatch(Object.assign(Object.assign({},function(t,e,i,n){let{main:s}=t.selection,o=i-s.from,r=n-s.from;return Object.assign(Object.assign({},t.changeByRange(a=>{if(a!=s&&i!=n&&t.sliceDoc(a.from+o,a.from+r)!=t.sliceDoc(i,n))return{range:a};let l=t.toText(e);return{changes:{from:a.from+o,to:n==s.from?a.to:a.from+r,insert:l},range:rs.cursor(a.from+o+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}(t.state,i,n.from,n.to)),{annotations:Zg.of(e.completion)})):i(t,e.completion,n.from,n.to),!0)}const gv=ev(pv,mv);function vv(t,e="option"){return i=>{let n=i.state.field(pv,!1);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp<i.state.facet(Ug).interactionDelay)return!1;let s,o=1;"page"==e&&(s=Bh(i,n.open.tooltip))&&(o=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let{length:r}=n.open.options,a=n.open.selected>-1?n.open.selected+o*(t?1:-1):t?0:r-1;return a<0?a="page"==e?0:r-1:a>=r&&(a="page"==e?r-1:0),i.dispatch({effects:fv.of(a)}),!0}}const yv=t=>!!t.state.field(pv,!1)&&(t.dispatch({effects:Hg.of(!0)}),!0);class Ov{constructor(t,e){this.active=t,this.context=e,this.time=Date.now(),this.updates=[],this.done=void 0}}const bv=Pa.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of t.state.field(pv).active)e.isPending&&this.startQuery(e)}update(t){let e=t.state.field(pv),i=t.state.facet(Ug);if(!t.selectionSet&&!t.docChanged&&t.startState.field(pv)==e)return;let n=t.transactions.some(t=>{let e=cv(t,i);return 8&e||(t.selection||t.docChanged)&&!(3&e)});for(let e=0;e<this.running.length;e++){let i=this.running[e];if(n||i.context.abortOnDocChange&&t.docChanged||i.updates.length+t.transactions.length>50&&Date.now()-i.time>1e3){for(let t of i.context.abortListeners)try{t()}catch(t){ka(this.view.state,t)}i.context.abortListeners=null,this.running.splice(e--,1)}else i.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some(t=>t.effects.some(t=>t.is(Hg)))&&(this.pendingStart=!0);let s=this.pendingStart?50:i.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(t=>t.isPending&&!this.running.some(e=>e.active.source==t.source))?setTimeout(()=>this.startUpdate(),s):-1,0!=this.composing)for(let e of t.transactions)e.isUserEvent("input.type")?this.composing=2:2==this.composing&&e.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field(pv);for(let t of e.active)t.isPending&&!this.running.some(e=>e.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Ug).updateSyncTime))}startQuery(t){let{state:e}=this.view,i=Bg(e),n=new Lg(e,i,t.explicit,this.view),s=new Ov(t,n);this.running.push(s),Promise.resolve(t.source(n)).then(t=>{s.context.aborted||(s.done=t||null,this.scheduleAccept())},t=>{this.view.dispatch({effects:Wg.of(null)}),ka(this.view.state,t)})}scheduleAccept(){this.running.every(t=>void 0!==t.done)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Ug).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],i=this.view.state.facet(Ug),n=this.view.state.field(pv);for(let s=0;s<this.running.length;s++){let o=this.running[s];if(void 0===o.done)continue;if(this.running.splice(s--,1),o.done){let n=Bg(o.updates.length?o.updates[0].startState:this.view.state),s=Math.min(n,o.done.from+(o.active.explicit?0:1)),r=new uv(o.active.source,o.active.explicit,s,o.done,o.done.from,null!==(t=o.done.to)&&void 0!==t?t:n);for(let t of o.updates)r=r.update(t,i);if(r.hasResult()){e.push(r);continue}}let r=n.active.find(t=>t.source==o.active.source);if(r&&r.isPending)if(null==o.done){let t=new hv(o.active.source,0);for(let e of o.updates)t=t.update(e,i);t.isPending||e.push(t)}else this.startQuery(r)}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:dv.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field(pv,!1);if(e&&e.tooltip&&this.view.state.facet(Ug).closeOnBlur){let i=e.open&&Bh(this.view,e.open.tooltip);i&&i.dom.contains(t.relatedTarget)||setTimeout(()=>this.view.dispatch({effects:Wg.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout(()=>this.view.dispatch({effects:Hg.of(!1)}),20),this.composing=0}}}),xv="object"==typeof navigator&&/Win/.test(navigator.platform),wv=ws.highest(Tc.domEventHandlers({keydown(t,e){let i=e.state.field(pv,!1);if(!i||!i.open||i.open.disabled||i.open.selected<0||t.key.length>1||t.ctrlKey&&(!xv||!t.altKey)||t.metaKey)return!1;let n=i.open.options[i.open.selected],s=i.active.find(t=>t.source==n.source),o=n.completion.commitCharacters||s.result.commitCharacters;return o&&o.indexOf(t.key)>-1&&mv(e,n),!1}})),_v=Tc.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class Sv{constructor(t,e,i,n){this.field=t,this.line=e,this.from=i,this.to=n}}class kv{constructor(t,e,i){this.field=t,this.from=e,this.to=i}map(t){let e=t.mapPos(this.from,-1,Un.TrackDel),i=t.mapPos(this.to,1,Un.TrackDel);return null==e||null==i?null:new kv(this.field,e,i)}}class $v{constructor(t,e){this.lines=t,this.fieldPositions=e}instantiate(t,e){let i=[],n=[e],s=t.doc.lineAt(e),o=/^\s*/.exec(s.text)[0];for(let s of this.lines){if(i.length){let i=o,r=/^\t*/.exec(s)[0].length;for(let e=0;e<r;e++)i+=t.facet(Zd);n.push(e+i.length-r),s=i+s.slice(r)}i.push(s),e+=s.length+1}let r=this.fieldPositions.map(t=>new kv(t.field,n[t.line]+t.from,n[t.line]+t.to));return{text:i,ranges:r}}static parse(t){let e,i=[],n=[],s=[];for(let o of t.split(/\r\n?|\n/)){for(;e=/[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(o);){let t=e[1]?+e[1]:null,r=e[2]||e[3]||"",a=-1,l=r.replace(/\\[{}]/g,t=>t[1]);for(let e=0;e<i.length;e++)(null!=t?i[e].seq==t:l&&i[e].name==l)&&(a=e);if(a<0){let e=0;for(;e<i.length&&(null==t||null!=i[e].seq&&i[e].seq<t);)e++;i.splice(e,0,{seq:t,name:l}),a=e;for(let t of s)t.field>=a&&t.field++}s.push(new Sv(a,n.length,e.index,e.index+l.length)),o=o.slice(0,e.index)+r+o.slice(e.index+e[0].length)}o=o.replace(/\\([{}])/g,(t,e,i)=>{for(let t of s)t.line==n.length&&t.from>i&&(t.from--,t.to--);return e}),n.push(o)}return new $v(n,s)}}let Cv=Mr.widget({widget:new class extends Er{toDOM(){let t=document.createElement("span");return t.className="cm-snippetFieldPosition",t}ignoreEvent(){return!1}}}),Tv=Mr.mark({class:"cm-snippetField"});class Pv{constructor(t,e){this.ranges=t,this.active=e,this.deco=Mr.set(t.map(t=>(t.from==t.to?Cv:Tv).range(t.from,t.to)))}map(t){let e=[];for(let i of this.ranges){let n=i.map(t);if(!n)return null;e.push(n)}return new Pv(e,this.active)}selectionInsideField(t){return t.ranges.every(t=>this.ranges.some(e=>e.field==this.active&&e.from<=t.from&&e.to>=t.to))}}const Ev=js.define({map:(t,e)=>t&&t.map(e)}),Av=js.define(),Mv=gs.define({create:()=>null,update(t,e){for(let i of e.effects){if(i.is(Ev))return i.value;if(i.is(Av)&&t)return new Pv(t.ranges,i.value)}return t&&e.docChanged&&(t=t.map(e.changes)),t&&e.selection&&!t.selectionInsideField(e.selection)&&(t=null),t},provide:t=>Tc.decorations.from(t,t=>t?t.deco:Mr.none)});function Qv(t,e){return rs.create(t.filter(t=>t.field==e).map(t=>rs.range(t.from,t.to)))}function Dv(t){let e=$v.parse(t);return(t,i,n,s)=>{let{text:o,ranges:r}=e.instantiate(t.state,n),{main:a}=t.state.selection,l={changes:{from:n,to:s==a.from?a.to:s,insert:Rn.of(o)},scrollIntoView:!0,annotations:i?[Zg.of(i),zs.userEvent.of("input.complete")]:void 0};if(r.length&&(l.selection=Qv(r,0)),r.some(t=>t.field>0)){let e=new Pv(r,0),i=l.effects=[Ev.of(e)];void 0===t.state.field(Mv,!1)&&i.push(js.appendConfig.of([Mv,Nv,zv,_v]))}t.dispatch(t.state.update(l))}}function Rv(t){return({state:e,dispatch:i})=>{let n=e.field(Mv,!1);if(!n||t<0&&0==n.active)return!1;let s=n.active+t,o=t>0&&!n.ranges.some(e=>e.field==s+t);return i(e.update({selection:Qv(n.ranges,s),effects:Ev.of(o?null:new Pv(n.ranges,s)),scrollIntoView:!0})),!0}}const Iv=[{key:"Tab",run:Rv(1),shift:Rv(-1)},{key:"Escape",run:({state:t,dispatch:e})=>!!t.field(Mv,!1)&&(e(t.update({effects:Ev.of(null)})),!0)}],Lv=cs.define({combine:t=>t.length?t[0]:Iv}),Nv=ws.highest(Ic.compute([Lv],t=>t.facet(Lv)));function jv(t,e){return Object.assign(Object.assign({},e),{apply:Dv(t)})}const zv=Tc.domEventHandlers({mousedown(t,e){let i,n=e.state.field(Mv,!1);if(!n||null==(i=e.posAtCoords({x:t.clientX,y:t.clientY})))return!1;let s=n.ranges.find(t=>t.from<=i&&t.to>=i);return!(!s||s.field==n.active)&&(e.dispatch({selection:Qv(n.ranges,s.field),effects:Ev.of(n.ranges.some(t=>t.field>s.field)?new Pv(n.ranges,s.field):null),scrollIntoView:!0}),!0)}});const Bv={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},qv=js.define({map(t,e){let i=e.mapPos(t,-1,Un.TrackAfter);return null==i?void 0:i}}),Zv=new class extends Js{};Zv.startSide=1,Zv.endSide=-1;const Fv=gs.define({create:()=>no.empty,update(t,e){if(t=t.map(e.changes),e.selection){let i=e.state.doc.lineAt(e.selection.main.head);t=t.update({filter:t=>t>=i.from&&t<=i.to})}for(let i of e.effects)i.is(qv)&&(t=t.update({add:[Zv.range(i.value,i.value+1)]}));return t}});const Xv="()[]{}<>«»»«[]{}";function Hv(t){for(let e=0;e<16;e+=2)if(Xv.charCodeAt(e)==t)return Xv.charAt(e+1);return Wn(t<128?t:t+1)}function Wv(t,e){return t.languageDataAt("closeBrackets",e)[0]||Bv}const Vv="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),Yv=Tc.inputHandler.of((t,e,i,n)=>{if((Vv?t.composing:t.compositionStarted)||t.state.readOnly)return!1;let s=t.state.selection.main;if(n.length>2||2==n.length&&1==Vn(Hn(n,0))||e!=s.from||i!=s.to)return!1;let o=function(t,e){let i=Wv(t,t.selection.main.head),n=i.brackets||Bv.brackets;for(let s of n){let o=Hv(Hn(s,0));if(e==s)return o==s?ey(t,s,n.indexOf(s+s+s)>-1,i):Jv(t,s,o,i.before||Bv.before);if(e==o&&Gv(t,t.selection.main.from))return ty(t,s,o)}return null}(t.state,n);return!!o&&(t.dispatch(o),!0)}),Uv=[{key:"Backspace",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=Wv(t,t.selection.main.head).brackets||Bv.brackets,n=null,s=t.changeByRange(e=>{if(e.empty){let n=function(t,e){let i=t.sliceString(e-2,e);return Vn(Hn(i,0))==i.length?i:i.slice(1)}(t.doc,e.head);for(let s of i)if(s==n&&Kv(t.doc,e.head)==Hv(Hn(s,0)))return{changes:{from:e.head-s.length,to:e.head+s.length},range:rs.cursor(e.head-s.length)}}return{range:n=e}});return n||e(t.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!n}}];function Gv(t,e){let i=!1;return t.field(Fv).between(0,t.doc.length,t=>{t==e&&(i=!0)}),i}function Kv(t,e){let i=t.sliceString(e,e+2);return i.slice(0,Vn(Hn(i,0)))}function Jv(t,e,i,n){let s=null,o=t.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:i,from:o.to}],effects:qv.of(o.to+e.length),range:rs.range(o.anchor+e.length,o.head+e.length)};let r=Kv(t.doc,o.head);return!r||/\s/.test(r)||n.indexOf(r)>-1?{changes:{insert:e+i,from:o.head},effects:qv.of(o.head+e.length),range:rs.cursor(o.head+e.length)}:{range:s=o}});return s?null:t.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function ty(t,e,i){let n=null,s=t.changeByRange(e=>e.empty&&Kv(t.doc,e.head)==i?{changes:{from:e.head,to:e.head+i.length,insert:i},range:rs.cursor(e.head+i.length)}:n={range:e});return n?null:t.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function ey(t,e,i,n){let s=n.stringPrefixes||Bv.stringPrefixes,o=null,r=t.changeByRange(n=>{if(!n.empty)return{changes:[{insert:e,from:n.from},{insert:e,from:n.to}],effects:qv.of(n.to+e.length),range:rs.range(n.anchor+e.length,n.head+e.length)};let r,a=n.head,l=Kv(t.doc,a);if(l==e){if(iy(t,a))return{changes:{insert:e+e,from:a},effects:qv.of(a+e.length),range:rs.cursor(a+e.length)};if(Gv(t,a)){let n=i&&t.sliceDoc(a,a+3*e.length)==e+e+e?e+e+e:e;return{changes:{from:a,to:a+n.length,insert:n},range:rs.cursor(a+n.length)}}}else{if(i&&t.sliceDoc(a-2*e.length,a)==e+e&&(r=ny(t,a-2*e.length,s))>-1&&iy(t,r))return{changes:{insert:e+e+e+e,from:a},effects:qv.of(a+e.length),range:rs.cursor(a+e.length)};if(t.charCategorizer(a)(l)!=Ws.Word&&ny(t,a,s)>-1&&!function(t,e,i,n){let s=Ad(t).resolveInner(e,-1),o=n.reduce((t,e)=>Math.max(t,e.length),0);for(let r=0;r<5;r++){let r=t.sliceDoc(s.from,Math.min(s.to,s.from+i.length+o)),a=r.indexOf(i);if(!a||a>-1&&n.indexOf(r.slice(0,a))>-1){let e=s.firstChild;for(;e&&e.from==s.from&&e.to-e.from>i.length+a;){if(t.sliceDoc(e.to-i.length,e.to)==i)return!1;e=e.firstChild}return!0}let l=s.to==e&&s.parent;if(!l)break;s=l}return!1}(t,a,e,s))return{changes:{insert:e+e,from:a},effects:qv.of(a+e.length),range:rs.cursor(a+e.length)}}return{range:o=n}});return o?null:t.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function iy(t,e){let i=Ad(t).resolveInner(e+1);return i.parent&&i.from==e}function ny(t,e,i){let n=t.charCategorizer(e);if(n(t.sliceDoc(e-1,e))!=Ws.Word)return e;for(let s of i){let i=e-s.length;if(t.sliceDoc(i,e)==s&&n(t.sliceDoc(i-1,i))!=Ws.Word)return i}return-1}function sy(t={}){return[wv,pv,Ug.of(t),bv,ry,_v]}const oy=[{key:"Ctrl-Space",run:yv},{mac:"Alt-`",run:yv},{key:"Escape",run:t=>{let e=t.state.field(pv,!1);return!(!e||!e.active.some(t=>0!=t.state))&&(t.dispatch({effects:Wg.of(null)}),!0)}},{key:"ArrowDown",run:vv(!0)},{key:"ArrowUp",run:vv(!1)},{key:"PageDown",run:vv(!0,"page")},{key:"PageUp",run:vv(!1,"page")},{key:"Enter",run:t=>{let e=t.state.field(pv,!1);return!(t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(Ug).interactionDelay)&&mv(t,e.open.options[e.open.selected])}}],ry=ws.highest(Ic.computeN([Ug],t=>t.facet(Ug).defaultKeymap?[oy]:[]));class ay{constructor(t,e,i){this.from=t,this.to=e,this.diagnostic=i}}class ly{constructor(t,e,i){this.diagnostics=t,this.panel=e,this.selected=i}static init(t,e,i){let n=i.facet(xy).markerFilter;n&&(t=n(t,i));let s=t.slice().sort((t,e)=>t.from-e.from||t.to-e.to),o=new so,r=[],a=0;for(let t=0;;){let e,n,l=t==s.length?null:s[t];if(!l&&!r.length)break;for(r.length?(e=a,n=r.reduce((t,e)=>Math.min(t,e.to),l&&l.from>e?l.from:1e8)):(e=l.from,n=l.to,r.push(l),t++);t<s.length;){let i=s[t];if(i.from!=e||!(i.to>i.from||i.to==e)){n=Math.min(i.from,n);break}r.push(i),t++,n=Math.min(i.to,n)}let c=Ay(r);if(r.some(t=>t.from==t.to||t.from==t.to-1&&i.doc.lineAt(t.from).to==t.from))o.add(e,e,Mr.widget({widget:new Sy(c),diagnostics:r.slice()}));else{let t=r.reduce((t,e)=>e.markClass?t+" "+e.markClass:t,"");o.add(e,n,Mr.mark({class:"cm-lintRange cm-lintRange-"+c+t,diagnostics:r.slice(),inclusiveEnd:r.some(t=>t.to>n)}))}a=n;for(let t=0;t<r.length;t++)r[t].to<=a&&r.splice(t--,1)}let l=o.finish();return new ly(l,e,cy(l))}}function cy(t,e=null,i=0){let n=null;return t.between(i,1e9,(t,i,{spec:s})=>{if(!(e&&s.diagnostics.indexOf(e)<0))if(n){if(s.diagnostics.indexOf(n.diagnostic)<0)return!1;n=new ay(n.from,i,n.diagnostic)}else n=new ay(t,i,e||s.diagnostics[0])}),n}function hy(t,e){let i=e.pos,n=e.end||i,s=t.state.facet(xy).hideOn(t,i,n);if(null!=s)return s;let o=t.startState.doc.lineAt(e.pos);return!(!t.effects.some(t=>t.is(dy))&&!t.changes.touchesRange(o.from,Math.max(o.to,n)))}function uy(t,e){return t.field(my,!1)?e:e.concat(js.appendConfig.of(My))}const dy=js.define(),fy=js.define(),py=js.define(),my=gs.define({create:()=>new ly(Mr.none,null,null),update(t,e){if(e.docChanged&&t.diagnostics.size){let i=t.diagnostics.map(e.changes),n=null,s=t.panel;if(t.selected){let s=e.changes.mapPos(t.selected.from,1);n=cy(i,t.selected.diagnostic,s)||cy(i,null,s)}!i.size&&s&&e.state.facet(xy).autoPanel&&(s=null),t=new ly(i,s,n)}for(let i of e.effects)if(i.is(dy)){let n=e.state.facet(xy).autoPanel?i.value.length?$y.open:null:t.panel;t=ly.init(i.value,n,e.state)}else i.is(fy)?t=new ly(t.diagnostics,i.value?$y.open:null,t.selected):i.is(py)&&(t=new ly(t.diagnostics,t.panel,i.value));return t},provide:t=>[Vh.from(t,t=>t.panel),Tc.decorations.from(t,t=>t.diagnostics)]});const gy=Mr.mark({class:"cm-lintRange cm-lintRange-active"});function vy(t,e,i){let n,{diagnostics:s}=t.state.field(my),o=-1,r=-1;s.between(e-(i<0?1:0),e+(i>0?1:0),(t,s,{spec:a})=>{if(e>=t&&e<=s&&(t==s||(e>t||i>0)&&(e<s||i<0)))return n=a.diagnostics,o=t,r=s,!1});let a=t.state.facet(xy).tooltipFilter;return n&&a&&(n=a(n,t.state)),n?{pos:o,end:r,above:t.state.doc.lineAt(o).to<r,create:()=>({dom:yy(t,n)})}:null}function yy(t,e){return Mm("ul",{class:"cm-tooltip-lint"},e.map(e=>_y(t,e,!1)))}const Oy=t=>{let e=t.state.field(my,!1);return!(!e||!e.panel)&&(t.dispatch({effects:fy.of(!1)}),!0)},by=[{key:"Mod-Shift-m",run:t=>{let e=t.state.field(my,!1);e&&e.panel||t.dispatch({effects:uy(t.state,[fy.of(!0)])});let i=Fh(t,$y.open);return i&&i.dom.querySelector(".cm-panel-lint ul").focus(),!0},preventDefault:!0},{key:"F8",run:t=>{let e=t.state.field(my,!1);if(!e)return!1;let i=t.state.selection.main,n=e.diagnostics.iter(i.to+1);return!(!n.value&&(n=e.diagnostics.iter(0),!n.value||n.from==i.from&&n.to==i.to))&&(t.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0}),!0)}}];const xy=cs.define({combine:t=>Object.assign({sources:t.map(t=>t.source).filter(t=>null!=t)},Ks(t.map(t=>t.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(t,e)=>t?e?i=>t(i)||e(i):t:e}))});function wy(t){let e=[];if(t)t:for(let{name:i}of t){for(let t=0;t<i.length;t++){let n=i[t];if(/[a-zA-Z]/.test(n)&&!e.some(t=>t.toLowerCase()==n.toLowerCase())){e.push(n);continue t}}e.push("")}return e}function _y(t,e,i){var n;let s=i?wy(e.actions):[];return Mm("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},Mm("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),null===(n=e.actions)||void 0===n?void 0:n.map((i,n)=>{let o=!1,r=n=>{if(n.preventDefault(),o)return;o=!0;let s=cy(t.state.field(my).diagnostics,e);s&&i.apply(t,s.from,s.to)},{name:a}=i,l=s[n]?a.indexOf(s[n]):-1,c=l<0?a:[a.slice(0,l),Mm("u",a.slice(l,l+1)),a.slice(l+1)];return Mm("button",{type:"button",class:"cm-diagnosticAction",onclick:r,onmousedown:r,"aria-label":` Action: ${a}${l<0?"":` (access key "${s[n]})"`}.`},c)}),e.source&&Mm("div",{class:"cm-diagnosticSource"},e.source))}class Sy extends Er{constructor(t){super(),this.sev=t}eq(t){return t.sev==this.sev}toDOM(){return Mm("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class ky{constructor(t,e){this.diagnostic=e,this.id="item_"+Math.floor(4294967295*Math.random()).toString(16),this.dom=_y(t,e,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class $y{constructor(t){this.view=t,this.items=[];this.list=Mm("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:e=>{if(27==e.keyCode)Oy(this.view),this.view.focus();else if(38==e.keyCode||33==e.keyCode)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(40==e.keyCode||34==e.keyCode)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(36==e.keyCode)this.moveSelection(0);else if(35==e.keyCode)this.moveSelection(this.items.length-1);else if(13==e.keyCode)this.view.focus();else{if(!(e.keyCode>=65&&e.keyCode<=90&&this.selectedIndex>=0))return;{let{diagnostic:i}=this.items[this.selectedIndex],n=wy(i.actions);for(let s=0;s<n.length;s++)if(n[s].toUpperCase().charCodeAt(0)==e.keyCode){let e=cy(this.view.state.field(my).diagnostics,i);e&&i.actions[s].apply(t,e.from,e.to)}}}e.preventDefault()},onclick:t=>{for(let e=0;e<this.items.length;e++)this.items[e].dom.contains(t.target)&&this.moveSelection(e)}}),this.dom=Mm("div",{class:"cm-panel-lint"},this.list,Mm("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>Oy(this.view)},"×")),this.update()}get selectedIndex(){let t=this.view.state.field(my).selected;if(!t)return-1;for(let e=0;e<this.items.length;e++)if(this.items[e].diagnostic==t.diagnostic)return e;return-1}update(){let{diagnostics:t,selected:e}=this.view.state.field(my),i=0,n=!1,s=null,o=new Set;for(t.between(0,this.view.state.doc.length,(t,r,{spec:a})=>{for(let t of a.diagnostics){if(o.has(t))continue;o.add(t);let r,a=-1;for(let e=i;e<this.items.length;e++)if(this.items[e].diagnostic==t){a=e;break}a<0?(r=new ky(this.view,t),this.items.splice(i,0,r),n=!0):(r=this.items[a],a>i&&(this.items.splice(i,a-i),n=!0)),e&&r.diagnostic==e.diagnostic?r.dom.hasAttribute("aria-selected")||(r.dom.setAttribute("aria-selected","true"),s=r):r.dom.hasAttribute("aria-selected")&&r.dom.removeAttribute("aria-selected"),i++}});i<this.items.length&&!(1==this.items.length&&this.items[0].diagnostic.from<0);)n=!0,this.items.pop();0==this.items.length&&(this.items.push(new ky(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),n=!0),s?(this.list.setAttribute("aria-activedescendant",s.id),this.view.requestMeasure({key:this,read:()=>({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:t,panel:e})=>{let i=e.height/this.list.offsetHeight;t.top<e.top?this.list.scrollTop-=(e.top-t.top)/i:t.bottom>e.bottom&&(this.list.scrollTop+=(t.bottom-e.bottom)/i)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),n&&this.sync()}sync(){let t=this.list.firstChild;function e(){let e=t;t=e.nextSibling,e.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;t!=i.dom;)e();t=i.dom.nextSibling}else this.list.insertBefore(i.dom,t);for(;t;)e()}moveSelection(t){if(this.selectedIndex<0)return;let e=cy(this.view.state.field(my).diagnostics,this.items[t].diagnostic);e&&this.view.dispatch({selection:{anchor:e.from,head:e.to},scrollIntoView:!0,effects:py.of(e)})}static open(t){return new $y(t)}}function Cy(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`}function Ty(t){return Cy(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const Py=Tc.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:Ty("#d11")},".cm-lintRange-warning":{backgroundImage:Ty("orange")},".cm-lintRange-info":{backgroundImage:Ty("#999")},".cm-lintRange-hint":{backgroundImage:Ty("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});function Ey(t){return"error"==t?4:"warning"==t?3:"info"==t?2:1}function Ay(t){let e="hint",i=1;for(let n of t){let t=Ey(n.severity);t>i&&(i=t,e=n.severity)}return e}const My=[my,Tc.decorations.compute([my],t=>{let{selected:e,panel:i}=t.field(my);return e&&i&&e.from!=e.to?Mr.set([gy.range(e.from,e.to)]):Mr.none}),zh(vy,{hideOn:hy}),Py];const Qy=(()=>[mu(),yu,dh(),vp(),Cf(),Uc(),[nh,sh],Gs.allowMultipleSelections.of(!0),Gs.transactionFilter.of(t=>{if(!t.docChanged||!t.isUserEvent("input.type")&&!t.isUserEvent("input.complete"))return t;let e=t.startState.languageDataAt("indentOnInput",t.startState.selection.main.head);if(!e.length)return t;let i=t.newDoc,{head:n}=t.newSelection.main,s=i.lineAt(n);if(n>s.from+200)return t;let o=i.sliceString(s.from,n);if(!e.some(t=>t.test(o)))return t;let{state:r}=t,a=-1,l=[];for(let{head:t}of r.selection.ranges){let e=r.doc.lineAt(t);if(e.from==a)continue;a=e.from;let i=Hd(r,e.from);if(null==i)continue;let n=/^\s*/.exec(e.text)[0],s=Xd(r,i);n!=s&&l.push({from:e.from,to:e.from+n.length,insert:s})}return l.length?[t,{changes:l,sequential:!0}]:t}),Qf(If,{fallback:!0}),Xf(),[Yv,Fv],sy(),xh(),Sh(),vh,Ym(),Ic.of([...Uv,...Am,...Pg,...Dp,...yf,...oy,...by])])();class Dy{constructor(t,e,i,n,s,o,r,a,l,c=0,h){this.p=t,this.stack=e,this.state=i,this.reducePos=n,this.pos=s,this.score=o,this.buffer=r,this.bufferBase=a,this.curContext=l,this.lookAhead=c,this.parent=h}toString(){return`[${this.stack.filter((t,e)=>e%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(t,e,i=0){let n=t.parser.context;return new Dy(t,[],e,i,i,0,[],0,n?new Ry(n,n.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(t,e){this.stack.push(this.state,e,this.bufferBase+this.buffer.length),this.state=t}reduce(t){var e;let i=t>>19,n=65535&t,{parser:s}=this.p,o=this.reducePos<this.pos-25;o&&this.setLookAhead(this.pos);let r=s.dynamicPrecedence(n);if(r&&(this.score+=r),0==i)return this.pushState(s.getGoto(this.state,n,!0),this.reducePos),n<s.minRepeatTerm&&this.storeNode(n,this.reducePos,this.reducePos,o?8:4,!0),void this.reduceContext(n,this.reducePos);let a=this.stack.length-3*(i-1)-(262144&t?6:0),l=a?this.stack[a-2]:this.p.ranges[0].from,c=this.reducePos-l;c>=2e3&&!(null===(e=this.p.parser.nodeSet.types[n])||void 0===e?void 0:e.isAnonymous)&&(l==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=l,this.p.lastBigReductionSize=c));let h=a?this.stack[a-1]:0,u=this.bufferBase+this.buffer.length-h;if(n<s.minRepeatTerm||131072&t){let t=s.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(n,l,t,u+4,!0)}if(262144&t)this.state=this.stack[a];else{let t=this.stack[a-3];this.state=s.getGoto(t,n,!0)}for(;this.stack.length>a;)this.stack.pop();this.reduceContext(n,l)}storeNode(t,e,i,n=4,s=!1){if(0==t&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let t=this,n=this.buffer.length;if(0==n&&t.parent&&(n=t.bufferBase-t.parent.bufferBase,t=t.parent),n>0&&0==t.buffer[n-4]&&t.buffer[n-1]>-1){if(e==i)return;if(t.buffer[n-2]>=e)return void(t.buffer[n-2]=i)}}if(s&&this.pos!=i){let s=this.buffer.length;if(s>0&&0!=this.buffer[s-4]){let t=!1;for(let e=s;e>0&&this.buffer[e-2]>i;e-=4)if(this.buffer[e-1]>=0){t=!0;break}if(t)for(;s>0&&this.buffer[s-2]>i;)this.buffer[s]=this.buffer[s-4],this.buffer[s+1]=this.buffer[s-3],this.buffer[s+2]=this.buffer[s-2],this.buffer[s+3]=this.buffer[s-1],s-=4,n>4&&(n-=4)}this.buffer[s]=t,this.buffer[s+1]=e,this.buffer[s+2]=i,this.buffer[s+3]=n}else this.buffer.push(t,e,i,n)}shift(t,e,i,n){if(131072&t)this.pushState(65535&t,this.pos);else if(262144&t)this.pos=n,this.shiftContext(e,i),e<=this.p.parser.maxNode&&this.buffer.push(e,i,n,4);else{let s=t,{parser:o}=this.p;(n>this.pos||e<=o.maxNode)&&(this.pos=n,o.stateFlag(s,1)||(this.reducePos=n)),this.pushState(s,i),this.shiftContext(e,i),e<=o.maxNode&&this.buffer.push(e,i,n,4)}}apply(t,e,i,n){65536&t?this.reduce(t):this.shift(t,e,i,n)}useNode(t,e){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=t)&&(this.p.reused.push(t),i++);let n=this.pos;this.reducePos=this.pos=n+t.length,this.pushState(e,n),this.buffer.push(i,n,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,t,this,this.p.stream.reset(this.pos-t.length)))}split(){let t=this,e=t.buffer.length;for(;e>0&&t.buffer[e-2]>t.reducePos;)e-=4;let i=t.buffer.slice(e),n=t.bufferBase+e;for(;t&&n==t.bufferBase;)t=t.parent;return new Dy(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,n,this.curContext,this.lookAhead,t)}recoverByDelete(t,e){let i=t<=this.p.parser.maxNode;i&&this.storeNode(t,this.pos,e,4),this.storeNode(0,this.pos,e,i?8:4),this.pos=this.reducePos=e,this.score-=190}canShift(t){for(let e=new Iy(this);;){let i=this.p.parser.stateSlot(e.state,4)||this.p.parser.hasAction(e.state,t);if(0==i)return!1;if(!(65536&i))return!0;e.reduce(i)}}recoverByInsert(t){if(this.stack.length>=300)return[];let e=this.p.parser.nextStates(this.state);if(e.length>8||this.stack.length>=120){let i=[];for(let n,s=0;s<e.length;s+=2)(n=e[s+1])!=this.state&&this.p.parser.hasAction(n,t)&&i.push(e[s],n);if(this.stack.length<120)for(let t=0;i.length<8&&t<e.length;t+=2){let n=e[t+1];i.some((t,e)=>1&e&&t==n)||i.push(e[t],n)}e=i}let i=[];for(let t=0;t<e.length&&i.length<4;t+=2){let n=e[t+1];if(n==this.state)continue;let s=this.split();s.pushState(n,this.pos),s.storeNode(0,s.pos,s.pos,4,!0),s.shiftContext(e[t],this.pos),s.reducePos=this.pos,s.score-=200,i.push(s)}return i}forceReduce(){let{parser:t}=this.p,e=t.stateSlot(this.state,5);if(!(65536&e))return!1;if(!t.validAction(this.state,e)){let i=e>>19,n=65535&e,s=this.stack.length-3*i;if(s<0||t.getGoto(this.stack[s],n,!1)<0){let t=this.findForcedReduction();if(null==t)return!1;e=t}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(e),!0}findForcedReduction(){let{parser:t}=this.p,e=[],i=(n,s)=>{if(!e.includes(n))return e.push(n),t.allActions(n,e=>{if(393216&e);else if(65536&e){let i=(e>>19)-s;if(i>1){let n=65535&e,s=this.stack.length-3*i;if(s>=0&&t.getGoto(this.stack[s],n,!1)>=0)return i<<19|65536|n}}else{let t=i(e,s+1);if(null!=t)return t}})};return i(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(3!=this.stack.length)return!1;let{parser:t}=this.p;return 65535==t.data[t.stateSlot(this.state,1)]&&!t.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(t){if(this.state!=t.state||this.stack.length!=t.stack.length)return!1;for(let e=0;e<this.stack.length;e+=3)if(this.stack[e]!=t.stack[e])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(t){return this.p.parser.dialect.flags[t]}shiftContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,t,this,this.p.stream.reset(e)))}reduceContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,t,this,this.p.stream.reset(e)))}emitContext(){let t=this.buffer.length-1;(t<0||-3!=this.buffer[t])&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let t=this.buffer.length-1;(t<0||-4!=this.buffer[t])&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(t){if(t!=this.curContext.context){let e=new Ry(this.curContext.tracker,t);e.hash!=this.curContext.hash&&this.emitContext(),this.curContext=e}}setLookAhead(t){t>this.lookAhead&&(this.emitLookAhead(),this.lookAhead=t)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class Ry{constructor(t,e){this.tracker=t,this.context=e,this.hash=t.strict?t.hash(e):0}}class Iy{constructor(t){this.start=t,this.state=t.state,this.stack=t.stack,this.base=this.stack.length}reduce(t){let e=65535&t,i=t>>19;0==i?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=3*(i-1);let n=this.start.p.parser.getGoto(this.stack[this.base-3],e,!0);this.state=n}}class Ly{constructor(t,e,i){this.stack=t,this.pos=e,this.index=i,this.buffer=t.buffer,0==this.index&&this.maybeNext()}static create(t,e=t.bufferBase+t.buffer.length){return new Ly(t,e,e-t.bufferBase)}maybeNext(){let t=this.stack.parent;null!=t&&(this.index=this.stack.bufferBase-t.bufferBase,this.stack=t,this.buffer=t.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,0==this.index&&this.maybeNext()}fork(){return new Ly(this.stack,this.pos,this.index)}}function Ny(t,e=Uint16Array){if("string"!=typeof t)return t;let i=null;for(let n=0,s=0;n<t.length;){let o=0;for(;;){let e=t.charCodeAt(n++),i=!1;if(126==e){o=65535;break}e>=92&&e--,e>=34&&e--;let s=e-32;if(s>=46&&(s-=46,i=!0),o+=s,i)break;o*=46}i?i[s++]=o:i=new e(o)}return i}class jy{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const zy=new jy;class By{constructor(t,e){this.input=t,this.ranges=e,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=zy,this.rangeIndex=0,this.pos=this.chunkPos=e[0].from,this.range=e[0],this.end=e[e.length-1].to,this.readNext()}resolveOffset(t,e){let i=this.range,n=this.rangeIndex,s=this.pos+t;for(;s<i.from;){if(!n)return null;let t=this.ranges[--n];s-=i.from-t.to,i=t}for(;e<0?s>i.to:s>=i.to;){if(n==this.ranges.length-1)return null;let t=this.ranges[++n];s+=t.from-i.to,i=t}return s}clipPos(t){if(t>=this.range.from&&t<this.range.to)return t;for(let e of this.ranges)if(e.to>t)return Math.max(t,e.from);return this.end}peek(t){let e,i,n=this.chunkOff+t;if(n>=0&&n<this.chunk.length)e=this.pos+t,i=this.chunk.charCodeAt(n);else{let n=this.resolveOffset(t,1);if(null==n)return-1;if(e=n,e>=this.chunk2Pos&&e<this.chunk2Pos+this.chunk2.length)i=this.chunk2.charCodeAt(e-this.chunk2Pos);else{let t=this.rangeIndex,n=this.range;for(;n.to<=e;)n=this.ranges[++t];this.chunk2=this.input.chunk(this.chunk2Pos=e),e+this.chunk2.length>n.to&&(this.chunk2=this.chunk2.slice(0,n.to-e)),i=this.chunk2.charCodeAt(0)}}return e>=this.token.lookAhead&&(this.token.lookAhead=e+1),i}acceptToken(t,e=0){let i=e?this.resolveOffset(e,-1):this.pos;if(null==i||i<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=t,this.token.end=i}acceptTokenTo(t,e){this.token.value=t,this.token.end=e}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:t,chunkPos:e}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=t,this.chunk2Pos=e,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let t=this.input.chunk(this.pos),e=this.pos+t.length;this.chunk=e>this.range.to?t.slice(0,this.range.to-this.pos):t,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(t=1){for(this.chunkOff+=t;this.pos+t>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();t-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=t,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(t,e){if(e?(this.token=e,e.start=t,e.lookAhead=t+1,e.value=e.extended=-1):this.token=zy,this.pos!=t){if(this.pos=t,t==this.end)return this.setDone(),this;for(;t<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;t>=this.range.to;)this.range=this.ranges[++this.rangeIndex];t>=this.chunkPos&&t<this.chunkPos+this.chunk.length?this.chunkOff=t-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(t,e){if(t>=this.chunkPos&&e<=this.chunkPos+this.chunk.length)return this.chunk.slice(t-this.chunkPos,e-this.chunkPos);if(t>=this.chunk2Pos&&e<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(t-this.chunk2Pos,e-this.chunk2Pos);if(t>=this.range.from&&e<=this.range.to)return this.input.read(t,e);let i="";for(let n of this.ranges){if(n.from>=e)break;n.to>t&&(i+=this.input.read(Math.max(n.from,t),Math.min(n.to,e)))}return i}}class qy{constructor(t,e){this.data=t,this.id=e}token(t,e){let{parser:i}=e.p;Xy(this.data,t,e,this.id,i.data,i.tokenPrecTable)}}qy.prototype.contextual=qy.prototype.fallback=qy.prototype.extend=!1;class Zy{constructor(t,e,i){this.precTable=e,this.elseToken=i,this.data="string"==typeof t?Ny(t):t}token(t,e){let i=t.pos,n=0;for(;;){let i=t.next<0,s=t.resolveOffset(1,1);if(Xy(this.data,t,e,0,this.data,this.precTable),t.token.value>-1)break;if(null==this.elseToken)return;if(i||n++,null==s)break;t.reset(s,t.token)}n&&(t.reset(i,t.token),t.acceptToken(this.elseToken,n))}}Zy.prototype.contextual=qy.prototype.fallback=qy.prototype.extend=!1;class Fy{constructor(t,e={}){this.token=t,this.contextual=!!e.contextual,this.fallback=!!e.fallback,this.extend=!!e.extend}}function Xy(t,e,i,n,s,o){let r=0,a=1<<n,{dialect:l}=i.p.parser;t:for(;0!=(a&t[r]);){let i=t[r+1];for(let n=r+3;n<i;n+=2)if((t[n+1]&a)>0){let i=t[n];if(l.allows(i)&&(-1==e.token.value||e.token.value==i||Wy(i,e.token.value,s,o))){e.acceptToken(i);break}}let n=e.next,c=0,h=t[r+2];if(!(e.next<0&&h>c&&65535==t[i+3*h-3])){for(;c<h;){let s=c+h>>1,o=i+s+(s<<1),a=t[o],l=t[o+1]||65536;if(n<a)h=s;else{if(!(n>=l)){r=t[o+2],e.advance();continue t}c=s+1}}break}r=t[i+3*h-1]}}function Hy(t,e,i){for(let n,s=e;65535!=(n=t[s]);s++)if(n==i)return s-e;return-1}function Wy(t,e,i,n){let s=Hy(i,n,e);return s<0||Hy(i,n,t)<s}const Vy="undefined"!=typeof process&&process.env&&/\bparse\b/.test(process.env.LOG);let Yy=null;function Uy(t,e,i){let n=t.cursor(Pu.IncludeAnonymous);for(n.moveTo(e);;)if(!(i<0?n.childBefore(e):n.childAfter(e)))for(;;){if((i<0?n.to<e:n.from>e)&&!n.type.isError)return i<0?Math.max(0,Math.min(n.to-1,e-25)):Math.min(t.length,Math.max(n.from+1,e+25));if(i<0?n.prevSibling():n.nextSibling())break;if(!n.parent())return i<0?0:t.length}}class Gy{constructor(t,e){this.fragments=t,this.nodeSet=e,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let t=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(t){for(this.safeFrom=t.openStart?Uy(t.tree,t.from+t.offset,1)-t.offset:t.from,this.safeTo=t.openEnd?Uy(t.tree,t.to+t.offset,-1)-t.offset:t.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(t.tree),this.start.push(-t.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(t){if(t<this.nextStart)return null;for(;this.fragment&&this.safeTo<=t;)this.nextFragment();if(!this.fragment)return null;for(;;){let e=this.trees.length-1;if(e<0)return this.nextFragment(),null;let i=this.trees[e],n=this.index[e];if(n==i.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let s=i.children[n],o=this.start[e]+i.positions[n];if(o>t)return this.nextStart=o,null;if(s instanceof Eu){if(o==t){if(o<this.safeFrom)return null;let t=o+s.length;if(t<=this.safeTo){let e=s.prop(wu.lookAhead);if(!e||t+e<this.fragment.to)return s}}this.index[e]++,o+s.length>=Math.max(this.safeFrom,t)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[e]++,this.nextStart=o+s.length}}}class Ky{constructor(t,e){this.stream=e,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=t.tokenizers.map(t=>new jy)}getActions(t){let e=0,i=null,{parser:n}=t.p,{tokenizers:s}=n,o=n.stateSlot(t.state,3),r=t.curContext?t.curContext.hash:0,a=0;for(let n=0;n<s.length;n++){if(!(1<<n&o))continue;let l=s[n],c=this.tokens[n];if((!i||l.fallback)&&((l.contextual||c.start!=t.pos||c.mask!=o||c.context!=r)&&(this.updateCachedToken(c,l,t),c.mask=o,c.context=r),c.lookAhead>c.end+25&&(a=Math.max(c.lookAhead,a)),0!=c.value)){let n=e;if(c.extended>-1&&(e=this.addActions(t,c.extended,c.end,e)),e=this.addActions(t,c.value,c.end,e),!l.extend&&(i=c,e>n))break}}for(;this.actions.length>e;)this.actions.pop();return a&&t.setLookAhead(a),i||t.pos!=this.stream.end||(i=new jy,i.value=t.p.parser.eofTerm,i.start=i.end=t.pos,e=this.addActions(t,i.value,i.end,e)),this.mainToken=i,this.actions}getMainToken(t){if(this.mainToken)return this.mainToken;let e=new jy,{pos:i,p:n}=t;return e.start=i,e.end=Math.min(i+1,n.stream.end),e.value=i==n.stream.end?n.parser.eofTerm:0,e}updateCachedToken(t,e,i){let n=this.stream.clipPos(i.pos);if(e.token(this.stream.reset(n,t),i),t.value>-1){let{parser:e}=i.p;for(let n=0;n<e.specialized.length;n++)if(e.specialized[n]==t.value){let s=e.specializers[n](this.stream.read(t.start,t.end),i);if(s>=0&&i.p.parser.dialect.allows(s>>1)){1&s?t.extended=s>>1:t.value=s>>1;break}}}else t.value=0,t.end=this.stream.clipPos(n+1)}putAction(t,e,i,n){for(let e=0;e<n;e+=3)if(this.actions[e]==t)return n;return this.actions[n++]=t,this.actions[n++]=e,this.actions[n++]=i,n}addActions(t,e,i,n){let{state:s}=t,{parser:o}=t.p,{data:r}=o;for(let t=0;t<2;t++)for(let a=o.stateSlot(s,t?2:1);;a+=3){if(65535==r[a]){if(1!=r[a+1]){0==n&&2==r[a+1]&&(n=this.putAction(sO(r,a+2),e,i,n));break}a=sO(r,a+2)}r[a]==e&&(n=this.putAction(sO(r,a+1),e,i,n))}return n}}class Jy{constructor(t,e,i,n){this.parser=t,this.input=e,this.ranges=n,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new By(e,n),this.tokens=new Ky(t,this.stream),this.topTerm=t.top[1];let{from:s}=n[0];this.stacks=[Dy.start(this,t.top[0],s)],this.fragments=i.length&&this.stream.end-s>4*t.bufferLength?new Gy(i,t.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let t,e,i=this.stacks,n=this.minStackPos,s=this.stacks=[];if(this.bigReductionCount>300&&1==i.length){let[t]=i;for(;t.forceReduce()&&t.stack.length&&t.stack[t.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<i.length;o++){let r=i[o];for(;;){if(this.tokens.mainToken=null,r.pos>n)s.push(r);else{if(this.advanceStack(r,s,i))continue;{t||(t=[],e=[]),t.push(r);let i=this.tokens.getMainToken(r);e.push(i.value,i.end)}}break}}if(!s.length){let e=t&&function(t){let e=null;for(let i of t){let t=i.p.stoppedAt;(i.pos==i.p.stream.end||null!=t&&i.pos>t)&&i.p.parser.stateFlag(i.state,2)&&(!e||e.score<i.score)&&(e=i)}return e}(t);if(e)return Vy&&console.log("Finish with "+this.stackID(e)),this.stackToTree(e);if(this.parser.strict)throw Vy&&t&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+n);this.recovering||(this.recovering=5)}if(this.recovering&&t){let i=null!=this.stoppedAt&&t[0].pos>this.stoppedAt?t[0]:this.runRecovery(t,e,s);if(i)return Vy&&console.log("Force-finish "+this.stackID(i)),this.stackToTree(i.forceAll())}if(this.recovering){let t=1==this.recovering?1:3*this.recovering;if(s.length>t)for(s.sort((t,e)=>e.score-t.score);s.length>t;)s.pop();s.some(t=>t.reducePos>n)&&this.recovering--}else if(s.length>1){t:for(let t=0;t<s.length-1;t++){let e=s[t];for(let i=t+1;i<s.length;i++){let n=s[i];if(e.sameState(n)||e.buffer.length>500&&n.buffer.length>500){if(!((e.score-n.score||e.buffer.length-n.buffer.length)>0)){s.splice(t--,1);continue t}s.splice(i--,1)}}}s.length>12&&s.splice(12,s.length-12)}this.minStackPos=s[0].pos;for(let t=1;t<s.length;t++)s[t].pos<this.minStackPos&&(this.minStackPos=s[t].pos);return null}stopAt(t){if(null!=this.stoppedAt&&this.stoppedAt<t)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=t}advanceStack(t,e,i){let n=t.pos,{parser:s}=this,o=Vy?this.stackID(t)+" -> ":"";if(null!=this.stoppedAt&&n>this.stoppedAt)return t.forceReduce()?t:null;if(this.fragments){let e=t.curContext&&t.curContext.tracker.strict,i=e?t.curContext.hash:0;for(let r=this.fragments.nodeAt(n);r;){let n=this.parser.nodeSet.types[r.type.id]==r.type?s.getGoto(t.state,r.type.id):-1;if(n>-1&&r.length&&(!e||(r.prop(wu.contextHash)||0)==i))return t.useNode(r,n),Vy&&console.log(o+this.stackID(t)+` (via reuse of ${s.getName(r.type.id)})`),!0;if(!(r instanceof Eu)||0==r.children.length||r.positions[0]>0)break;let a=r.children[0];if(!(a instanceof Eu&&0==r.positions[0]))break;r=a}}let r=s.stateSlot(t.state,4);if(r>0)return t.reduce(r),Vy&&console.log(o+this.stackID(t)+` (via always-reduce ${s.getName(65535&r)})`),!0;if(t.stack.length>=8400)for(;t.stack.length>6e3&&t.forceReduce(););let a=this.tokens.getActions(t);for(let r=0;r<a.length;){let l=a[r++],c=a[r++],h=a[r++],u=r==a.length||!i,d=u?t:t.split(),f=this.tokens.mainToken;if(d.apply(l,c,f?f.start:d.pos,h),Vy&&console.log(o+this.stackID(d)+` (via ${65536&l?`reduce of ${s.getName(65535&l)}`:"shift"} for ${s.getName(c)} @ ${n}${d==t?"":", split"})`),u)return!0;d.pos>n?e.push(d):i.push(d)}return!1}advanceFully(t,e){let i=t.pos;for(;;){if(!this.advanceStack(t,null,null))return!1;if(t.pos>i)return tO(t,e),!0}}runRecovery(t,e,i){let n=null,s=!1;for(let o=0;o<t.length;o++){let r=t[o],a=e[o<<1],l=e[1+(o<<1)],c=Vy?this.stackID(r)+" -> ":"";if(r.deadEnd){if(s)continue;if(s=!0,r.restart(),Vy&&console.log(c+this.stackID(r)+" (restarted)"),this.advanceFully(r,i))continue}let h=r.split(),u=c;for(let t=0;h.forceReduce()&&t<10;t++){if(Vy&&console.log(u+this.stackID(h)+" (via force-reduce)"),this.advanceFully(h,i))break;Vy&&(u=this.stackID(h)+" -> ")}for(let t of r.recoverByInsert(a))Vy&&console.log(c+this.stackID(t)+" (via recover-insert)"),this.advanceFully(t,i);this.stream.end>r.pos?(l==r.pos&&(l++,a=0),r.recoverByDelete(a,l),Vy&&console.log(c+this.stackID(r)+` (via recover-delete ${this.parser.getName(a)})`),tO(r,i)):(!n||n.score<r.score)&&(n=r)}return n}stackToTree(t){return t.close(),Eu.build({buffer:Ly.create(t),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:t.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(t){let e=(Yy||(Yy=new WeakMap)).get(t);return e||Yy.set(t,e=String.fromCodePoint(this.nextStackID++)),e+t}}function tO(t,e){for(let i=0;i<e.length;i++){let n=e[i];if(n.pos==t.pos&&n.sameState(t))return void(e[i].score<t.score&&(e[i]=t))}e.push(t)}class eO{constructor(t,e,i){this.source=t,this.flags=e,this.disabled=i}allows(t){return!this.disabled||0==this.disabled[t]}}const iO=t=>t;class nO extends Uu{constructor(t){if(super(),this.wrappers=[],14!=t.version)throw new RangeError(`Parser version (${t.version}) doesn't match runtime version (14)`);let e=t.nodeNames.split(" ");this.minRepeatTerm=e.length;for(let i=0;i<t.repeatNodeCount;i++)e.push("");let i=Object.keys(t.topRules).map(e=>t.topRules[e][1]),n=[];for(let t=0;t<e.length;t++)n.push([]);function s(t,e,i){n[t].push([e,e.deserialize(String(i))])}if(t.nodeProps)for(let e of t.nodeProps){let t=e[0];"string"==typeof t&&(t=wu[t]);for(let i=1;i<e.length;){let n=e[i++];if(n>=0)s(n,t,e[i++]);else{let o=e[i+-n];for(let r=-n;r>0;r--)s(e[i++],t,o);i++}}}this.nodeSet=new $u(e.map((e,s)=>ku.define({name:s>=this.minRepeatTerm?void 0:e,id:s,props:n[s],top:i.indexOf(s)>-1,error:0==s,skipped:t.skippedNodes&&t.skippedNodes.indexOf(s)>-1}))),t.propSources&&(this.nodeSet=this.nodeSet.extend(...t.propSources)),this.strict=!1,this.bufferLength=Ou;let o=Ny(t.tokenData);this.context=t.context,this.specializerSpecs=t.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let t=0;t<this.specializerSpecs.length;t++)this.specialized[t]=this.specializerSpecs[t].term;this.specializers=this.specializerSpecs.map(oO),this.states=Ny(t.states,Uint32Array),this.data=Ny(t.stateData),this.goto=Ny(t.goto),this.maxTerm=t.maxTerm,this.tokenizers=t.tokenizers.map(t=>"number"==typeof t?new qy(o,t):t),this.topRules=t.topRules,this.dialects=t.dialects||{},this.dynamicPrecedences=t.dynamicPrecedences||null,this.tokenPrecTable=t.tokenPrec,this.termNames=t.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(t,e,i){let n=new Jy(this,t,e,i);for(let s of this.wrappers)n=s(n,t,e,i);return n}getGoto(t,e,i=!1){let n=this.goto;if(e>=n[0])return-1;for(let s=n[e+1];;){let e=n[s++],o=1&e,r=n[s++];if(o&&i)return r;for(let i=s+(e>>1);s<i;s++)if(n[s]==t)return r;if(o)return-1}}hasAction(t,e){let i=this.data;for(let n=0;n<2;n++)for(let s,o=this.stateSlot(t,n?2:1);;o+=3){if(65535==(s=i[o])){if(1!=i[o+1]){if(2==i[o+1])return sO(i,o+2);break}s=i[o=sO(i,o+2)]}if(s==e||0==s)return sO(i,o+1)}return 0}stateSlot(t,e){return this.states[6*t+e]}stateFlag(t,e){return(this.stateSlot(t,0)&e)>0}validAction(t,e){return!!this.allActions(t,t=>t==e||null)}allActions(t,e){let i=this.stateSlot(t,4),n=i?e(i):void 0;for(let i=this.stateSlot(t,1);null==n;i+=3){if(65535==this.data[i]){if(1!=this.data[i+1])break;i=sO(this.data,i+2)}n=e(sO(this.data,i+1))}return n}nextStates(t){let e=[];for(let i=this.stateSlot(t,1);;i+=3){if(65535==this.data[i]){if(1!=this.data[i+1])break;i=sO(this.data,i+2)}if(!(1&this.data[i+2])){let t=this.data[i+1];e.some((e,i)=>1&i&&e==t)||e.push(this.data[i],t)}}return e}configure(t){let e=Object.assign(Object.create(nO.prototype),this);if(t.props&&(e.nodeSet=this.nodeSet.extend(...t.props)),t.top){let i=this.topRules[t.top];if(!i)throw new RangeError(`Invalid top rule name ${t.top}`);e.top=i}return t.tokenizers&&(e.tokenizers=this.tokenizers.map(e=>{let i=t.tokenizers.find(t=>t.from==e);return i?i.to:e})),t.specializers&&(e.specializers=this.specializers.slice(),e.specializerSpecs=this.specializerSpecs.map((i,n)=>{let s=t.specializers.find(t=>t.from==i.external);if(!s)return i;let o=Object.assign(Object.assign({},i),{external:s.to});return e.specializers[n]=oO(o),o})),t.contextTracker&&(e.context=t.contextTracker),t.dialect&&(e.dialect=this.parseDialect(t.dialect)),null!=t.strict&&(e.strict=t.strict),t.wrap&&(e.wrappers=e.wrappers.concat(t.wrap)),null!=t.bufferLength&&(e.bufferLength=t.bufferLength),e}hasWrappers(){return this.wrappers.length>0}getName(t){return this.termNames?this.termNames[t]:String(t<=this.maxNode&&this.nodeSet.types[t].name||t)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(t){let e=this.dynamicPrecedences;return null==e?0:e[t]||0}parseDialect(t){let e=Object.keys(this.dialects),i=e.map(()=>!1);if(t)for(let n of t.split(" ")){let t=e.indexOf(n);t>=0&&(i[t]=!0)}let n=null;for(let t=0;t<e.length;t++)if(!i[t])for(let i,s=this.dialects[e[t]];65535!=(i=this.data[s++]);)(n||(n=new Uint8Array(this.maxTerm+1)))[i]=1;return new eO(t,i,n)}static deserialize(t){return new nO(t)}}function sO(t,e){return t[e]|t[e+1]<<16}function oO(t){if(t.external){let e=t.extend?1:0;return(i,n)=>t.external(i,n)<<1|e}return t.get}const rO=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],aO=new class{constructor(t){this.start=t.start,this.shift=t.shift||iO,this.reduce=t.reduce||iO,this.reuse=t.reuse||iO,this.hash=t.hash||(()=>0),this.strict=!1!==t.strict}}({start:!1,shift:(t,e)=>5==e||6==e||319==e?t:320==e,strict:!1}),lO=new Fy((t,e)=>{let{next:i}=t;(125==i||-1==i||e.context)&&t.acceptToken(317)},{contextual:!0,fallback:!0}),cO=new Fy((t,e)=>{let i,{next:n}=t;rO.indexOf(n)>-1||(47!=n||47!=(i=t.peek(1))&&42!=i)&&(125==n||59==n||-1==n||e.context||t.acceptToken(315))},{contextual:!0}),hO=new Fy((t,e)=>{91!=t.next||e.context||t.acceptToken(316)},{contextual:!0}),uO=new Fy((t,e)=>{let{next:i}=t;if(43==i||45==i){if(t.advance(),i==t.next){t.advance();let i=!e.context&&e.canShift(1);t.acceptToken(i?1:2)}}else 63==i&&46==t.peek(1)&&(t.advance(),t.advance(),(t.next<48||t.next>57)&&t.acceptToken(3))},{contextual:!0});function dO(t,e){return t>=65&&t<=90||t>=97&&t<=122||95==t||t>=192||!e&&t>=48&&t<=57}const fO=new Fy((t,e)=>{if(60!=t.next||!e.dialectEnabled(0))return;if(t.advance(),47==t.next)return;let i=0;for(;rO.indexOf(t.next)>-1;)t.advance(),i++;if(dO(t.next,!0)){for(t.advance(),i++;dO(t.next,!1);)t.advance(),i++;for(;rO.indexOf(t.next)>-1;)t.advance(),i++;if(44==t.next)return;for(let e=0;;e++){if(7==e){if(!dO(t.next,!0))return;break}if(t.next!="extends".charCodeAt(e))break;t.advance(),i++}}t.acceptToken(4,-i)}),pO=id({"get set async static":_d.modifier,"for while do if else switch try catch finally return throw break continue default case":_d.controlKeyword,"in of await yield void typeof delete instanceof as satisfies":_d.operatorKeyword,"let var const using function class extends":_d.definitionKeyword,"import export from":_d.moduleKeyword,"with debugger new":_d.keyword,TemplateString:_d.special(_d.string),super:_d.atom,BooleanLiteral:_d.bool,this:_d.self,null:_d.null,Star:_d.modifier,VariableName:_d.variableName,"CallExpression/VariableName TaggedTemplateExpression/VariableName":_d.function(_d.variableName),VariableDefinition:_d.definition(_d.variableName),Label:_d.labelName,PropertyName:_d.propertyName,PrivatePropertyName:_d.special(_d.propertyName),"CallExpression/MemberExpression/PropertyName":_d.function(_d.propertyName),"FunctionDeclaration/VariableDefinition":_d.function(_d.definition(_d.variableName)),"ClassDeclaration/VariableDefinition":_d.definition(_d.className),"NewExpression/VariableName":_d.className,PropertyDefinition:_d.definition(_d.propertyName),PrivatePropertyDefinition:_d.definition(_d.special(_d.propertyName)),UpdateOp:_d.updateOperator,"LineComment Hashbang":_d.lineComment,BlockComment:_d.blockComment,Number:_d.number,String:_d.string,Escape:_d.escape,ArithOp:_d.arithmeticOperator,LogicOp:_d.logicOperator,BitOp:_d.bitwiseOperator,CompareOp:_d.compareOperator,RegExp:_d.regexp,Equals:_d.definitionOperator,Arrow:_d.function(_d.punctuation),": Spread":_d.punctuation,"( )":_d.paren,"[ ]":_d.squareBracket,"{ }":_d.brace,"InterpolationStart InterpolationEnd":_d.special(_d.brace),".":_d.derefOperator,", ;":_d.separator,"@":_d.meta,TypeName:_d.typeName,TypeDefinition:_d.definition(_d.typeName),"type enum interface implements namespace module declare":_d.definitionKeyword,"abstract global Privacy readonly override":_d.modifier,"is keyof unique infer asserts":_d.operatorKeyword,JSXAttributeValue:_d.attributeValue,JSXText:_d.content,"JSXStartTag JSXStartCloseTag JSXSelfCloseEndTag JSXEndTag":_d.angleBracket,"JSXIdentifier JSXNameSpacedName":_d.tagName,"JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName":_d.attributeName,"JSXBuiltin/JSXIdentifier":_d.standard(_d.tagName)}),mO={__proto__:null,export:20,as:25,from:33,default:36,async:41,function:42,in:52,out:55,const:56,extends:60,this:64,true:72,false:72,null:84,void:88,typeof:92,super:108,new:142,delete:154,yield:163,await:167,class:172,public:235,private:235,protected:235,readonly:237,instanceof:256,satisfies:259,import:292,keyof:349,unique:353,infer:359,asserts:395,is:397,abstract:417,implements:419,type:421,let:424,var:426,using:429,interface:435,enum:439,namespace:445,module:447,declare:451,global:455,for:474,of:483,while:486,with:490,do:494,if:498,else:500,switch:504,case:510,try:516,catch:520,finally:524,return:528,throw:532,break:536,continue:540,debugger:544},gO={__proto__:null,async:129,get:131,set:133,declare:195,public:197,private:197,protected:197,static:199,abstract:201,override:203,readonly:209,accessor:211,new:401},vO={__proto__:null,"<":193},yO=nO.deserialize({version:14,states:"$EOQ%TQlOOO%[QlOOO'_QpOOP(lO`OOO*zQ!0MxO'#CiO+RO#tO'#CjO+aO&jO'#CjO+oO#@ItO'#DaO.QQlO'#DgO.bQlO'#DrO%[QlO'#DzO0fQlO'#ESOOQ!0Lf'#E['#E[O1PQ`O'#EXOOQO'#Ep'#EpOOQ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SR,b&eQ&T|R+z&UR+p&OT&n!W&qT&o!W&qT2U,s2V",nodeNames:"⚠ ArithOp ArithOp ?. JSXStartTag LineComment BlockComment Script Hashbang ExportDeclaration export Star as VariableName String Escape from ; default FunctionDeclaration async function VariableDefinition > < TypeParamList in out const TypeDefinition extends ThisType this LiteralType ArithOp Number BooleanLiteral TemplateType InterpolationEnd Interpolation InterpolationStart NullType null VoidType void TypeofType typeof MemberExpression . PropertyName [ TemplateString Escape Interpolation super RegExp ] ArrayExpression Spread , } { ObjectExpression Property async get set PropertyDefinition Block : NewTarget new NewExpression ) ( ArgList UnaryExpression delete LogicOp BitOp YieldExpression yield AwaitExpression await ParenthesizedExpression ClassExpression class ClassBody MethodDeclaration Decorator @ MemberExpression PrivatePropertyName CallExpression TypeArgList CompareOp < declare Privacy static abstract override PrivatePropertyDefinition PropertyDeclaration readonly accessor Optional TypeAnnotation Equals StaticBlock FunctionExpression ArrowFunction ParamList ParamList ArrayPattern ObjectPattern PatternProperty Privacy readonly Arrow MemberExpression BinaryExpression ArithOp ArithOp ArithOp ArithOp BitOp CompareOp instanceof satisfies CompareOp BitOp BitOp BitOp LogicOp LogicOp ConditionalExpression LogicOp LogicOp AssignmentExpression UpdateOp PostfixExpression CallExpression InstantiationExpression TaggedTemplateExpression DynamicImport import ImportMeta JSXElement JSXSelfCloseEndTag JSXSelfClosingTag JSXIdentifier JSXBuiltin JSXIdentifier JSXNamespacedName JSXMemberExpression JSXSpreadAttribute JSXAttribute JSXAttributeValue JSXEscape JSXEndTag JSXOpenTag JSXFragmentTag JSXText JSXEscape JSXStartCloseTag JSXCloseTag PrefixCast < ArrowFunction TypeParamList SequenceExpression InstantiationExpression KeyofType keyof UniqueType unique ImportType InferredType infer TypeName ParenthesizedType FunctionSignature ParamList NewSignature IndexedType TupleType Label ArrayType ReadonlyType ObjectType MethodType PropertyType IndexSignature PropertyDefinition CallSignature TypePredicate asserts is NewSignature new UnionType LogicOp IntersectionType LogicOp ConditionalType ParameterizedType ClassDeclaration abstract implements type VariableDeclaration let var using TypeAliasDeclaration InterfaceDeclaration interface EnumDeclaration enum EnumBody NamespaceDeclaration namespace module AmbientDeclaration declare GlobalDeclaration global ClassDeclaration ClassBody AmbientFunctionDeclaration ExportGroup VariableName VariableName ImportDeclaration ImportGroup ForStatement for ForSpec ForInSpec ForOfSpec of WhileStatement while WithStatement with DoStatement do IfStatement if else SwitchStatement switch SwitchBody CaseLabel case DefaultLabel TryStatement try CatchClause catch FinallyClause finally ReturnStatement return ThrowStatement throw BreakStatement break ContinueStatement continue DebuggerStatement debugger LabeledStatement ExpressionStatement SingleExpression SingleClassItem",maxTerm:379,context:aO,nodeProps:[["isolate",-8,5,6,14,37,39,51,53,55,""],["group",-26,9,17,19,68,207,211,215,216,218,221,224,234,236,242,244,246,248,251,257,263,265,267,269,271,273,274,"Statement",-34,13,14,32,35,36,42,51,54,55,57,62,70,72,76,80,82,84,85,110,111,120,121,136,139,141,142,143,144,145,147,148,167,169,171,"Expression",-23,31,33,37,41,43,45,173,175,177,178,180,181,182,184,185,186,188,189,190,201,203,205,206,"Type",-3,88,103,109,"ClassItem"],["openedBy",23,"<",38,"InterpolationStart",56,"[",60,"{",73,"(",160,"JSXStartCloseTag"],["closedBy",-2,24,168,">",40,"InterpolationEnd",50,"]",61,"}",74,")",165,"JSXEndTag"]],propSources:[pO],skippedNodes:[0,5,6,277],repeatNodeCount:37,tokenData:"$Fq07[R!bOX%ZXY+gYZ-yZ[+g[]%Z]^.c^p%Zpq+gqr/mrs3cst:_tuEruvJSvwLkwx! Yxy!'iyz!(sz{!)}{|!,q|}!.O}!O!,q!O!P!/Y!P!Q!9j!Q!R#:O!R![#<_![!]#I_!]!^#Jk!^!_#Ku!_!`$![!`!a$$v!a!b$*T!b!c$,r!c!}Er!}#O$-|#O#P$/W#P#Q$4o#Q#R$5y#R#SEr#S#T$7W#T#o$8b#o#p$<r#p#q$=h#q#r$>x#r#s$@U#s$f%Z$f$g+g$g#BYEr#BY#BZ$A`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R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$f%Z$f$g+g$g#BYEr#BY#BZ$A`#BZ$ISEr$IS$I_$A`$I_$JTEr$JT$JU$A`$JU$KVEr$KV$KW$A`$KW&FUEr&FU&FV$A`&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$A`?HUOEr07[$D|k$i&j(Vp(Y!b'|0/l$]#t(S,2j(d$I[OY%ZYZ&cZr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$g%Z$g;'SEr;'S;=`I|<%lOEr",tokenizers:[cO,hO,uO,fO,2,3,4,5,6,7,8,9,10,11,12,13,14,lO,new Zy("$S~RRtu[#O#Pg#S#T#|~_P#o#pb~gOx~~jVO#i!P#i#j!U#j#l!P#l#m!q#m;'S!P;'S;=`#v<%lO!P~!UO!U~~!XS!Q![!e!c!i!e#T#Z!e#o#p#Z~!hR!Q![!q!c!i!q#T#Z!q~!tR!Q![!}!c!i!}#T#Z!}~#QR!Q![!P!c!i!P#T#Z!P~#^R!Q![#g!c!i#g#T#Z#g~#jS!Q![#g!c!i#g#T#Z#g#q#r!P~#yP;=`<%l!P~$RO(b~~",141,339),new Zy("j~RQYZXz{^~^O(P~~aP!P!Qd~iO(Q~~",25,322)],topRules:{Script:[0,7],SingleExpression:[1,275],SingleClassItem:[2,276]},dialects:{jsx:0,ts:15098},dynamicPrecedences:{80:1,82:1,94:1,169:1,199:1},specialized:[{term:326,get:t=>mO[t]||-1},{term:342,get:t=>gO[t]||-1},{term:95,get:t=>vO[t]||-1}],tokenPrec:15124}),OO=[jv("function ${name}(${params}) {\n\t${}\n}",{label:"function",detail:"definition",type:"keyword"}),jv("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n\t${}\n}",{label:"for",detail:"loop",type:"keyword"}),jv("for (let ${name} of ${collection}) {\n\t${}\n}",{label:"for",detail:"of loop",type:"keyword"}),jv("do {\n\t${}\n} while (${})",{label:"do",detail:"loop",type:"keyword"}),jv("while (${}) {\n\t${}\n}",{label:"while",detail:"loop",type:"keyword"}),jv("try {\n\t${}\n} catch (${error}) {\n\t${}\n}",{label:"try",detail:"/ catch block",type:"keyword"}),jv("if (${}) {\n\t${}\n}",{label:"if",detail:"block",type:"keyword"}),jv("if (${}) {\n\t${}\n} else {\n\t${}\n}",{label:"if",detail:"/ else block",type:"keyword"}),jv("class ${name} {\n\tconstructor(${params}) {\n\t\t${}\n\t}\n}",{label:"class",detail:"definition",type:"keyword"}),jv('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),jv('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],bO=OO.concat([jv("interface ${name} {\n\t${}\n}",{label:"interface",detail:"definition",type:"keyword"}),jv("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),jv("enum ${name} {\n\t${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),xO=new Vu,wO=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function _O(t){return(e,i)=>{let n=e.node.getChild("VariableDefinition");return n&&i(n,t),!0}}const SO=["FunctionDeclaration"],kO={FunctionDeclaration:_O("function"),ClassDeclaration:_O("class"),ClassExpression:()=>!0,EnumDeclaration:_O("constant"),TypeAliasDeclaration:_O("type"),NamespaceDeclaration:_O("namespace"),VariableDefinition(t,e){t.matchContext(SO)||e(t,"variable")},TypeDefinition(t,e){e(t,"type")},__proto__:null};function $O(t,e){let i=xO.get(e);if(i)return i;let n=[],s=!0;function o(e,i){let s=t.sliceString(e.from,e.to);n.push({label:s,type:i})}return e.cursor(Pu.IncludeAnonymous).iterate(e=>{if(s)s=!1;else if(e.name){let t=kO[e.name];if(t&&t(e,o)||wO.has(e.name))return!1}else if(e.to-e.from>8192){for(let i of $O(t,e.node))n.push(i);return!1}}),xO.set(e,n),n}const CO=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,TO=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName","JSXText","JSXAttributeValue","JSXOpenTag","JSXCloseTag","JSXSelfClosingTag",".","?."];function PO(t){let e=Ad(t.state).resolveInner(t.pos,-1);if(TO.indexOf(e.name)>-1)return null;let i="VariableName"==e.name||e.to-e.from<20&&CO.test(t.state.sliceDoc(e.from,e.to));if(!i&&!t.explicit)return null;let n=[];for(let i=e;i;i=i.parent)wO.has(i.name)&&(n=n.concat($O(t.state.doc,i)));return{options:n,from:i?e.from:t.pos,validFor:CO}}const EO=Ed.define({name:"javascript",parser:yO.configure({props:[Vd.add({IfStatement:nf({except:/^\s*({|else\b)/}),TryStatement:nf({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:t=>t.baseIndent,SwitchBody:t=>{let e=t.textAfter,i=/^\s*\}/.test(e),n=/^\s*(case|default)\b/.test(e);return t.baseIndent+(i?0:n?1:2)*t.unit},Block:tf({closing:"}"}),ArrowFunction:t=>t.baseIndent+t.unit,"TemplateString BlockComment":()=>null,"Statement Property":nf({except:/^\s*{/}),JSXElement(t){let e=/^\s*<\//.test(t.textAfter);return t.lineIndent(t.node.from)+(e?0:t.unit)},JSXEscape(t){let e=/\s*\}/.test(t.textAfter);return t.lineIndent(t.node.from)+(e?0:t.unit)},"JSXOpenTag JSXSelfClosingTag":t=>t.column(t.node.from)+t.unit}),of.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":function(t){let e=t.firstChild,i=t.lastChild;return e&&e.to<i.from?{from:e.to,to:i.type.isError?t.to:i.from}:null},BlockComment:t=>({from:t.from+2,to:t.to-2})})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),AO={test:t=>/^JSX/.test(t.name),facet:$d({commentTokens:{block:{open:"{/*",close:"*/}"}}})},MO=EO.configure({dialect:"ts"},"typescript"),QO=EO.configure({dialect:"jsx",props:[Cd.add(t=>t.isTop?[AO]:void 0)]}),DO=EO.configure({dialect:"jsx ts",props:[Cd.add(t=>t.isTop?[AO]:void 0)]},"typescript");let RO=t=>({label:t,type:"keyword"});const IO="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(RO),LO=IO.concat(["declare","implements","private","protected","public"].map(RO));function NO(t={}){let e=t.jsx?t.typescript?DO:QO:t.typescript?MO:EO,i=t.typescript?bO.concat(LO):OO.concat(IO);return new Bd(e,[EO.data.of({autocomplete:(n=TO,s=jg(i),t=>{for(let e=Ad(t.state).resolveInner(t.pos,-1);e;e=e.parent){if(n.indexOf(e.name)>-1)return null;if(e.type.isTop)break}return s(t)})}),EO.data.of({autocomplete:PO}),t.jsx?BO:[]]);var n,s}function jO(t,e,i=t.length){for(let n=null==e?void 0:e.firstChild;n;n=n.nextSibling)if("JSXIdentifier"==n.name||"JSXBuiltin"==n.name||"JSXNamespacedName"==n.name||"JSXMemberExpression"==n.name)return t.sliceString(n.from,Math.min(n.to,i));return""}const zO="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),BO=Tc.inputHandler.of((t,e,i,n,s)=>{if((zO?t.composing:t.compositionStarted)||t.state.readOnly||e!=i||">"!=n&&"/"!=n||!EO.isActiveAt(t.state,e,-1))return!1;let o=s(),{state:r}=o,a=r.changeByRange(t=>{var e;let i,{head:s}=t,o=Ad(r).resolveInner(s-1,-1);if("JSXStartTag"==o.name&&(o=o.parent),r.doc.sliceString(s-1,s)!=n||"JSXAttributeValue"==o.name&&o.to>s);else{if(">"==n&&"JSXFragmentTag"==o.name)return{range:t,changes:{from:s,insert:"</>"}};if("/"==n&&"JSXStartCloseTag"==o.name){let t=o.parent,n=t.parent;if(n&&t.from==s-2&&((i=jO(r.doc,n.firstChild,s))||"JSXFragmentTag"==(null===(e=n.firstChild)||void 0===e?void 0:e.name))){let t=`${i}>`;return{range:rs.cursor(s+t.length,-1),changes:{from:s,insert:t}}}}else if(">"==n){let e=function(t){for(;;){if("JSXOpenTag"==t.name||"JSXSelfClosingTag"==t.name||"JSXFragmentTag"==t.name)return t;if("JSXEscape"==t.name||!t.parent)return null;t=t.parent}}(o);if(e&&"JSXOpenTag"==e.name&&!/^\/?>|^<\//.test(r.doc.sliceString(s,s+2))&&(i=jO(r.doc,e,s)))return{range:t,changes:{from:s,insert:`</${i}>`}}}}return{range:t}});return!a.changes.empty&&(t.dispatch([o,r.update(a,{userEvent:"input.complete",scrollIntoView:!0})]),!0)});function qO(t,e){const i=Tc.theme({"&":{height:.6*e+"px"}}),n=new Tc({doc:t.value,extensions:[Qy,NO(),Qf(If),i]});return t.parentNode.insertBefore(n.dom,t),t.style.display="none",n}function ZO(t){return!t||window.confirm("There is a change that has not been saved. If you proceed now, you will lose it.")}class FO{#ui;constructor(t){this.#ui=t}get template(){return ot`
289
+ </tr>`;t.querySelector(`.textae-editor__setting-dialog__${i}-character-add-row`).insertAdjacentHTML("afterend",o),n.value=""}class fn extends u{constructor(t,e,i,n,s,o){super("Setting",nn({typeGapDisabled:!i.show,typeGap:i.value,lineHeight:n.lineHeight,autocompletionWs:e.autocompletionWs,typeDictionaryLocked:e.isLock,delimiterCharacters:s.delimiterCharacters,blankCharacters:s.blankCharacters,functionAvailability:o,version:Ji})),Ki(super.el,t,i,e,n,o),r()(super.el,".textae-editor__dialog","keyup",t=>{13===t.keyCode&&super.close()}),function(t){r()(t,".textae-editor__setting-dialog__delimiter-character-add-button","click",()=>dn(t,"delimiter")),r()(t,".textae-editor__setting-dialog__blank-character-add-button","click",()=>dn(t,"blank"))}(super.el),function(t){r()(t,".textae-editor__setting-dialog__delimiter-character-delete-button","click",({target:t})=>{t.closest(".textae-editor__setting-dialog__delimiter-character-row").remove()}),r()(t,".textae-editor__setting-dialog__blank-character-delete-button","click",({target:t})=>{t.closest(".textae-editor__setting-dialog__blank-character-row").remove()})}(super.el),h()(this.el).on("dialogclose",()=>{!function(t,e){const i=t.querySelector(".textae-editor__setting-dialog__autocompletion_ws-text").value;un({autocompletion_ws:i}),e.autocompletionWs=i}(super.el,e),function(t,e){const i=t.querySelectorAll(".textae-editor__setting-dialog__delimiter-character"),n=Array.from(i).map(t=>tn.decode(t.textContent)).reverse(),s=t.querySelectorAll(".textae-editor__setting-dialog__blank-character"),o=Array.from(s).map(t=>tn.decode(t.textContent)).reverse(),r={"delimiter characters":Array.from(n),"non-edge characters":Array.from(o)};un(r),e.set(r)}(super.el,s)})}}function pn(t,e){return t.isPushed("boundary detection")?t=>e.isDelimiter(t):()=>!0}const mn="Init",gn="View",vn="Term",yn="Block",On="Relation",bn="Text";class xn{#Q;#Nt;#ei;#Ie;#Ht;#ii;#ni;#si;#oi;#ri;#ai;#li;#ci;constructor(t,e,i,n,s,o,r,a,l,c){e.on("textae-event.edit-mode.transition",t=>{if(n.removeAll(),t===gn)i.entityInstanceContainer.clarifyLabelOfAll();else i.entityInstanceContainer.declarifyLabelOfAll()}),this.#Q=t,this.#Nt=e,this.#ei=s,this.#Ie=n,this.#Ht=i,this.#ii=l,this.#ni=o,this.#si=r,this.#oi=a,this.#ri=new Vi(t,n),this.#ai=new Yi(t,n),this.#li=!1,this.#ci=c,je(this,()=>this.#oi,["copyEntitiesToLocalClipboard","copyEntitiesToSystemClipboard","cutEntitiesToLocalClipboard","cutEntitiesToSystemClipboard","pasteEntitiesFromLocalClipboard","pasteEntitiesFromSystemClipboard"]),je(this,()=>this.#ii,["toggleButton"])}removeSelectedElements(){const t=this.#ei.factory.removeSelectedCommand();this.#ri.right(null),this.#ei.invoke(t)}createEntity(){const t=this.#ei.factory.createDefaultTypeEntityToSelectedSpansCommand(this.#Ht.typeDictionary.denotation.defaultType);t.isEmpty||this.#ei.invoke(t)}replicate(){const t=pn(this.#ii,this.#ni);this.#Ie.span.single?this.#ei.invoke(this.#ei.factory.replicateSpanCommand(this.#Ie.span.single,this.#Ie.span.single.entities.map(t=>t.typeValues),t)):e().warning("You can replicate span annotation when there is only span selected.")}cancelSelect(){this.#ci.hidePallet(),this.#Ie.removeAll(),this.#Q.focus()}showSettingDialog(){new fn(this.#Nt,this.#Ht.typeDictionary,this.#Ht.typeGap,this.#Ht.textBox,this.#ni,this.#si).open()}get isActive(){return this.#li}activate(){this.#Q.classList.add("textae-editor--active"),this.#li=!0}deactivate(){this.#Q.classList.remove("textae-editor--active"),this.#Nt.emit("textae-event.editor.unselect"),this.#li=!1}selectLeft(t){this.#ci.isTypeValuesPalletShown?this.#ci.selectLeftAttributeTab():this.#ri.left(t)}selectRight(t){this.#ci.isTypeValuesPalletShown?this.#ci.selectRightAttributeTab():this.#ri.right(t)}selectUp(){this.#ci.isEditDenotation&&this.#ai.up()}selectDown(){this.#ci.isEditDenotation&&this.#ai.down()}applyTextSelectionWithTouchDevice(){this.#li&&this.#ci.applyTextSelectionWithTouchDevice()}}function wn(t,e){e?t.removeAttribute("disabled"):t.setAttribute("disabled","disabled")}function _n(t){if("string"!=typeof t)return!1;try{JSON.parse(t)}catch(t){return!1}return!0}let Sn=[],kn=[];function $n(t){if(t<768)return!1;for(let e=0,i=Sn.length;;){let n=e+i>>1;if(t<Sn[n])i=n;else{if(!(t>=kn[n]))return!0;e=n+1}if(e==i)return!1}}function Cn(t){return t>=127462&&t<=127487}(()=>{let t="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2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36):1);for(let e=0,i=0;e<t.length;e++)(e%2?kn:Sn).push(i+=t[e])})();function Tn(t,e,i=!0,n=!0){return(i?Pn:En)(t,e,n)}function Pn(t,e,i){if(e==t.length)return e;e&&Mn(t.charCodeAt(e))&&Qn(t.charCodeAt(e-1))&&e--;let n=An(t,e);for(e+=Dn(n);e<t.length;){let s=An(t,e);if(8205==n||8205==s||i&&$n(s))e+=Dn(s),n=s;else{if(!Cn(s))break;{let i=0,n=e-2;for(;n>=0&&Cn(An(t,n));)i++,n-=2;if(i%2==0)break;e+=2}}}return e}function En(t,e,i){for(;e>0;){let n=Pn(t,e-2,i);if(n<e)return n;e--}return 0}function An(t,e){let i=t.charCodeAt(e);if(!Qn(i)||e+1==t.length)return i;let n=t.charCodeAt(e+1);return Mn(n)?n-56320+(i-55296<<10)+65536:i}function Mn(t){return t>=56320&&t<57344}function Qn(t){return t>=55296&&t<56320}function Dn(t){return t<65536?1:2}class Rn{lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,i){[t,e]=Fn(this,t,e);let n=[];return this.decompose(0,t,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(e,this.length,n,1),Ln.from(n,this.length-(e-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){[t,e]=Fn(this,t,e);let i=[];return this.decompose(t,e,i,0),Ln.from(i,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=this.scanIdentical(t,1),i=this.length-this.scanIdentical(t,-1),n=new zn(this),s=new zn(t);for(let t=e,o=e;;){if(n.next(t),s.next(t),t=0,n.lineBreak!=s.lineBreak||n.done!=s.done||n.value!=s.value)return!1;if(o+=n.value.length,n.done||o>=i)return!0}}iter(t=1){return new zn(this,t)}iterRange(t,e=this.length){return new Bn(this,t,e)}iterLines(t,e){let i;if(null==t)i=this.iter();else{null==e&&(e=this.lines+1);let n=this.line(t).from;i=this.iterRange(n,Math.max(n,e==this.lines+1?this.length:e<=1?0:this.line(e-1).to))}return new qn(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(0==t.length)throw new RangeError("A document must have at least one line");return 1!=t.length||t[0]?t.length<=32?new In(t):Ln.from(In.split(t,[])):Rn.empty}}class In extends Rn{constructor(t,e=function(t){let e=-1;for(let i of t)e+=i.length+1;return e}(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,i,n){for(let s=0;;s++){let o=this.text[s],r=n+o.length;if((e?i:r)>=t)return new Zn(n,r,i,o);n=r+1,i++}}decompose(t,e,i,n){let s=t<=0&&e>=this.length?this:new In(jn(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(1&n){let t=i.pop(),e=Nn(s.text,t.text.slice(),0,s.length);if(e.length<=32)i.push(new In(e,t.length+s.length));else{let t=e.length>>1;i.push(new In(e.slice(0,t)),new In(e.slice(t)))}}else i.push(s)}replace(t,e,i){if(!(i instanceof In))return super.replace(t,e,i);[t,e]=Fn(this,t,e);let n=Nn(this.text,Nn(i.text,jn(this.text,0,t)),e),s=this.length+i.length-(e-t);return n.length<=32?new In(n,s):Ln.from(In.split(n,[]),s)}sliceString(t,e=this.length,i="\n"){[t,e]=Fn(this,t,e);let n="";for(let s=0,o=0;s<=e&&o<this.text.length;o++){let r=this.text[o],a=s+r.length;s>t&&o&&(n+=i),t<a&&e>s&&(n+=r.slice(Math.max(0,t-s),e-s)),s=a+1}return n}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let i=[],n=-1;for(let s of t)i.push(s),n+=s.length+1,32==i.length&&(e.push(new In(i,n)),i=[],n=-1);return n>-1&&e.push(new In(i,n)),e}}class Ln extends Rn{constructor(t,e){super(),this.children=t,this.length=e,this.lines=0;for(let e of t)this.lines+=e.lines}lineInner(t,e,i,n){for(let s=0;;s++){let o=this.children[s],r=n+o.length,a=i+o.lines-1;if((e?a:r)>=t)return o.lineInner(t,e,i,n);n=r+1,i=a+1}}decompose(t,e,i,n){for(let s=0,o=0;o<=e&&s<this.children.length;s++){let r=this.children[s],a=o+r.length;if(t<=a&&e>=o){let s=n&((o<=t?1:0)|(a>=e?2:0));o>=t&&a<=e&&!s?i.push(r):r.decompose(t-o,e-o,i,s)}o=a+1}}replace(t,e,i){if([t,e]=Fn(this,t,e),i.lines<this.lines)for(let n=0,s=0;n<this.children.length;n++){let o=this.children[n],r=s+o.length;if(t>=s&&e<=r){let a=o.replace(t-s,e-s,i),l=this.lines-o.lines+a.lines;if(a.lines<l>>4&&a.lines>l>>6){let s=this.children.slice();return s[n]=a,new Ln(s,this.length-(e-t)+i.length)}return super.replace(s,r,a)}s=r+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i="\n"){[t,e]=Fn(this,t,e);let n="";for(let s=0,o=0;s<this.children.length&&o<=e;s++){let r=this.children[s],a=o+r.length;o>t&&s&&(n+=i),t<a&&e>o&&(n+=r.sliceString(t-o,e-o,i)),o=a+1}return n}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof Ln))return 0;let i=0,[n,s,o,r]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;n+=e,s+=e){if(n==o||s==r)return i;let a=this.children[n],l=t.children[s];if(a!=l)return i+a.scanIdentical(l,e);i+=a.length+1}}static from(t,e=t.reduce((t,e)=>t+e.length+1,-1)){let i=0;for(let e of t)i+=e.lines;if(i<32){let i=[];for(let e of t)e.flatten(i);return new In(i,e)}let n=Math.max(32,i>>5),s=n<<1,o=n>>1,r=[],a=0,l=-1,c=[];function h(t){let e;if(t.lines>s&&t instanceof Ln)for(let e of t.children)h(e);else t.lines>o&&(a>o||!a)?(u(),r.push(t)):t instanceof In&&a&&(e=c[c.length-1])instanceof In&&t.lines+e.lines<=32?(a+=t.lines,l+=t.length+1,c[c.length-1]=new In(e.text.concat(t.text),e.length+1+t.length)):(a+t.lines>n&&u(),a+=t.lines,l+=t.length+1,c.push(t))}function u(){0!=a&&(r.push(1==c.length?c[0]:Ln.from(c,l)),l=-1,a=c.length=0)}for(let e of t)h(e);return u(),1==r.length?r[0]:new Ln(r,e)}}function Nn(t,e,i=0,n=1e9){for(let s=0,o=0,r=!0;o<t.length&&s<=n;o++){let a=t[o],l=s+a.length;l>=i&&(l>n&&(a=a.slice(0,n-s)),s<i&&(a=a.slice(i-s)),r?(e[e.length-1]+=a,r=!1):e.push(a)),s=l+1}return e}function jn(t,e,i){return Nn(t,[""],e,i)}Rn.empty=new In([""],0);class zn{constructor(t,e=1){this.dir=e,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[e>0?1:(t instanceof In?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],s=this.offsets[i],o=s>>1,r=n instanceof In?n.text.length:n.children.length;if(o==(e>0?r:0)){if(0==i)return this.done=!0,this.value="",this;e>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&s)==(e>0?0:1)){if(this.offsets[i]+=e,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(n instanceof In){let s=n.text[o+(e<0?-1:0)];if(this.offsets[i]+=e,s.length>Math.max(0,t))return this.value=0==t?s:e>0?s.slice(t):s.slice(0,s.length-t),this;t-=s.length}else{let s=n.children[o+(e<0?-1:0)];t>s.length?(t-=s.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(s),this.offsets.push(e>0?1:(s instanceof In?s.text.length:s.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class Bn{constructor(t,e,i){this.value="",this.done=!1,this.cursor=new zn(t,e>i?-1:1),this.pos=e>i?t.length:0,this.from=Math.min(e,i),this.to=Math.max(e,i)}nextInner(t,e){if(e<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;t+=Math.max(0,e<0?this.pos-this.to:this.from-this.pos);let i=e<0?this.pos-this.from:this.to-this.pos;t>i&&(t=i),i-=t;let{value:n}=this.cursor.next(t);return this.pos+=(n.length+t)*e,this.value=n.length<=i?n:e<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(t=0){return t<0?t=Math.max(t,this.from-this.pos):t>0&&(t=Math.min(t,this.to-this.pos)),this.nextInner(t,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class qn{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:i,value:n}=this.inner.next(t);return e&&this.afterBreak?(this.value="",this.afterBreak=!1):e?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(Rn.prototype[Symbol.iterator]=function(){return this.iter()},zn.prototype[Symbol.iterator]=Bn.prototype[Symbol.iterator]=qn.prototype[Symbol.iterator]=function(){return this});class Zn{constructor(t,e,i,n){this.from=t,this.to=e,this.number=i,this.text=n}get length(){return this.to-this.from}}function Fn(t,e,i){return[e=Math.max(0,Math.min(t.length,e)),Math.max(e,Math.min(t.length,i))]}function Xn(t,e,i=!0,n=!0){return Tn(t,e,i,n)}function Hn(t,e){let i=t.charCodeAt(e);if(!(n=i,n>=55296&&n<56320&&e+1!=t.length))return i;var n;let s=t.charCodeAt(e+1);return function(t){return t>=56320&&t<57344}(s)?s-56320+(i-55296<<10)+65536:i}function Wn(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10),56320+(1023&t)))}function Vn(t){return t<65536?1:2}const Yn=/\r\n?|\n/;var Un=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(Un||(Un={}));class Gn{constructor(t){this.sections=t}get length(){let t=0;for(let e=0;e<this.sections.length;e+=2)t+=this.sections[e];return t}get newLength(){let t=0;for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e+1];t+=i<0?this.sections[e]:i}return t}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(t){for(let e=0,i=0,n=0;e<this.sections.length;){let s=this.sections[e++],o=this.sections[e++];o<0?(t(i,n,s),n+=s):n+=o,i+=s}}iterChangedRanges(t,e=!1){es(this,t,e)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];n<0?t.push(i,n):t.push(n,i)}return new Gn(t)}composeDesc(t){return this.empty?t:t.empty?this:ns(this,t)}mapDesc(t,e=!1){return t.empty?this:is(this,t,e)}mapPos(t,e=-1,i=Un.Simple){let n=0,s=0;for(let o=0;o<this.sections.length;){let r=this.sections[o++],a=this.sections[o++],l=n+r;if(a<0){if(l>t)return s+(t-n);s+=r}else{if(i!=Un.Simple&&l>=t&&(i==Un.TrackDel&&n<t&&l>t||i==Un.TrackBefore&&n<t||i==Un.TrackAfter&&l>t))return null;if(l>t||l==t&&e<0&&!r)return t==n||e<0?s:s+a;s+=a}n=l}if(t>n)throw new RangeError(`Position ${t} is out of range for changeset of length ${n}`);return s}touchesRange(t,e=t){for(let i=0,n=0;i<this.sections.length&&n<=e;){let s=n+this.sections[i++];if(this.sections[i++]>=0&&n<=e&&s>=t)return!(n<t&&s>e)||"cover";n=s}return!1}toString(){let t="";for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];t+=(t?" ":"")+i+(n>=0?":"+n:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(t=>"number"!=typeof t))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Gn(t)}static create(t){return new Gn(t)}}class Kn extends Gn{constructor(t,e){super(t),this.inserted=e}apply(t){if(this.length!=t.length)throw new RangeError("Applying change set to a document with the wrong length");return es(this,(e,i,n,s,o)=>t=t.replace(n,n+(i-e),o),!1),t}mapDesc(t,e=!1){return is(this,t,e,!0)}invert(t){let e=this.sections.slice(),i=[];for(let n=0,s=0;n<e.length;n+=2){let o=e[n],r=e[n+1];if(r>=0){e[n]=r,e[n+1]=o;let a=n>>1;for(;i.length<a;)i.push(Rn.empty);i.push(o?t.slice(s,s+o):Rn.empty)}s+=o}return new Kn(e,i)}compose(t){return this.empty?t:t.empty?this:ns(this,t,!0)}map(t,e=!1){return t.empty?this:is(this,t,e,!0)}iterChanges(t,e=!1){es(this,t,e)}get desc(){return Gn.create(this.sections)}filter(t){let e=[],i=[],n=[],s=new ss(this);t:for(let o=0,r=0;;){let a=o==t.length?1e9:t[o++];for(;r<a||r==a&&0==s.len;){if(s.done)break t;let t=Math.min(s.len,a-r);Jn(n,t,-1);let o=-1==s.ins?-1:0==s.off?s.ins:0;Jn(e,t,o),o>0&&ts(i,e,s.text),s.forward(t),r+=t}let l=t[o++];for(;r<l;){if(s.done)break t;let t=Math.min(s.len,l-r);Jn(e,t,-1),Jn(n,t,-1==s.ins?-1:0==s.off?s.ins:0),s.forward(t),r+=t}}return{changes:new Kn(e,i),filtered:Gn.create(n)}}toJSON(){let t=[];for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e],n=this.sections[e+1];n<0?t.push(i):0==n?t.push([i]):t.push([i].concat(this.inserted[e>>1].toJSON()))}return t}static of(t,e,i){let n=[],s=[],o=0,r=null;function a(t=!1){if(!t&&!n.length)return;o<e&&Jn(n,e-o,-1);let i=new Kn(n,s);r=r?r.compose(i.map(r)):i,n=[],s=[],o=0}return function t(l){if(Array.isArray(l))for(let e of l)t(e);else if(l instanceof Kn){if(l.length!=e)throw new RangeError(`Mismatched change set length (got ${l.length}, expected ${e})`);a(),r=r?r.compose(l.map(r)):l}else{let{from:t,to:r=t,insert:c}=l;if(t>r||t<0||r>e)throw new RangeError(`Invalid change range ${t} to ${r} (in doc of length ${e})`);let h=c?"string"==typeof c?Rn.of(c.split(i||Yn)):c:Rn.empty,u=h.length;if(t==r&&0==u)return;t<o&&a(),t>o&&Jn(n,t-o,-1),Jn(n,r-t,u),ts(s,n,h),o=r}}(t),a(!r),r}static empty(t){return new Kn(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let e=[],i=[];for(let n=0;n<t.length;n++){let s=t[n];if("number"==typeof s)e.push(s,-1);else{if(!Array.isArray(s)||"number"!=typeof s[0]||s.some((t,e)=>e&&"string"!=typeof t))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==s.length)e.push(s[0],0);else{for(;i.length<n;)i.push(Rn.empty);i[n]=Rn.of(s.slice(1)),e.push(s[0],i[n].length)}}}return new Kn(e,i)}static createSet(t,e){return new Kn(t,e)}}function Jn(t,e,i,n=!1){if(0==e&&i<=0)return;let s=t.length-2;s>=0&&i<=0&&i==t[s+1]?t[s]+=e:s>=0&&0==e&&0==t[s]?t[s+1]+=i:n?(t[s]+=e,t[s+1]+=i):t.push(e,i)}function ts(t,e,i){if(0==i.length)return;let n=e.length-2>>1;if(n<t.length)t[t.length-1]=t[t.length-1].append(i);else{for(;t.length<n;)t.push(Rn.empty);t.push(i)}}function es(t,e,i){let n=t.inserted;for(let s=0,o=0,r=0;r<t.sections.length;){let a=t.sections[r++],l=t.sections[r++];if(l<0)s+=a,o+=a;else{let c=s,h=o,u=Rn.empty;for(;c+=a,h+=l,l&&n&&(u=u.append(n[r-2>>1])),!(i||r==t.sections.length||t.sections[r+1]<0);)a=t.sections[r++],l=t.sections[r++];e(s,c,o,h,u),s=c,o=h}}}function is(t,e,i,n=!1){let s=[],o=n?[]:null,r=new ss(t),a=new ss(e);for(let t=-1;;){if(r.done&&a.len||a.done&&r.len)throw new Error("Mismatched change set lengths");if(-1==r.ins&&-1==a.ins){let t=Math.min(r.len,a.len);Jn(s,t,-1),r.forward(t),a.forward(t)}else if(a.ins>=0&&(r.ins<0||t==r.i||0==r.off&&(a.len<r.len||a.len==r.len&&!i))){let e=a.len;for(Jn(s,a.ins,-1);e;){let i=Math.min(r.len,e);r.ins>=0&&t<r.i&&r.len<=i&&(Jn(s,0,r.ins),o&&ts(o,s,r.text),t=r.i),r.forward(i),e-=i}a.next()}else{if(!(r.ins>=0)){if(r.done&&a.done)return o?Kn.createSet(s,o):Gn.create(s);throw new Error("Mismatched change set lengths")}{let e=0,i=r.len;for(;i;)if(-1==a.ins){let t=Math.min(i,a.len);e+=t,i-=t,a.forward(t)}else{if(!(0==a.ins&&a.len<i))break;i-=a.len,a.next()}Jn(s,e,t<r.i?r.ins:0),o&&t<r.i&&ts(o,s,r.text),t=r.i,r.forward(r.len-i)}}}}function ns(t,e,i=!1){let n=[],s=i?[]:null,o=new ss(t),r=new ss(e);for(let t=!1;;){if(o.done&&r.done)return s?Kn.createSet(n,s):Gn.create(n);if(0==o.ins)Jn(n,o.len,0,t),o.next();else if(0!=r.len||r.done){if(o.done||r.done)throw new Error("Mismatched change set lengths");{let e=Math.min(o.len2,r.len),i=n.length;if(-1==o.ins){let i=-1==r.ins?-1:r.off?0:r.ins;Jn(n,e,i,t),s&&i&&ts(s,n,r.text)}else-1==r.ins?(Jn(n,o.off?0:o.len,e,t),s&&ts(s,n,o.textBit(e))):(Jn(n,o.off?0:o.len,r.off?0:r.ins,t),s&&!r.off&&ts(s,n,r.text));t=(o.ins>e||r.ins>=0&&r.len>e)&&(t||n.length>i),o.forward2(e),r.forward(e)}}else Jn(n,0,r.ins,t),s&&ts(s,n,r.text),r.next()}}class ss{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i<t.length?(this.len=t[this.i++],this.ins=t[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return-2==this.ins}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:t}=this.set,e=this.i-2>>1;return e>=t.length?Rn.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?Rn.empty:e[i].slice(this.off,null==t?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){-1==this.ins?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}}class os{constructor(t,e,i){this.from=t,this.to=e,this.flags=i}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let t=7&this.flags;return 7==t?null:t}get goalColumn(){let t=this.flags>>6;return 16777215==t?void 0:t}map(t,e=-1){let i,n;return this.empty?i=n=t.mapPos(this.from,e):(i=t.mapPos(this.from,1),n=t.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new os(i,n,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return rs.range(t,e);let i=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return rs.range(this.anchor,i)}eq(t,e=!1){return!(this.anchor!=t.anchor||this.head!=t.head||e&&this.empty&&this.assoc!=t.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||"number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid JSON representation for SelectionRange");return rs.range(t.anchor,t.head)}static create(t,e,i){return new os(t,e,i)}}class rs{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:rs.create(this.ranges.map(i=>i.map(t,e)),this.mainIndex)}eq(t,e=!1){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(t.ranges[i],e))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new rs([this.main],0)}addRange(t,e=!0){return rs.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let i=this.ranges.slice();return i[e]=t,rs.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(t=>t.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||"number"!=typeof t.main||t.main>=t.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new rs(t.ranges.map(t=>os.fromJSON(t)),t.main)}static single(t,e=t){return new rs([rs.range(t,e)],0)}static create(t,e=0){if(0==t.length)throw new RangeError("A selection needs at least one range");for(let i=0,n=0;n<t.length;n++){let s=t[n];if(s.empty?s.from<=i:s.from<i)return rs.normalized(t.slice(),e);i=s.to}return new rs(t,e)}static cursor(t,e=0,i,n){return os.create(t,t,(0==e?0:e<0?8:16)|(null==i?7:Math.min(6,i))|(null!=n?n:16777215)<<6)}static range(t,e,i,n){let s=(null!=i?i:16777215)<<6|(null==n?7:Math.min(6,n));return e<t?os.create(e,t,48|s):os.create(t,e,(e>t?8:0)|s)}static normalized(t,e=0){let i=t[e];t.sort((t,e)=>t.from-e.from),e=t.indexOf(i);for(let i=1;i<t.length;i++){let n=t[i],s=t[i-1];if(n.empty?n.from<=s.to:n.from<s.to){let o=s.from,r=Math.max(n.to,s.to);i<=e&&e--,t.splice(--i,2,n.anchor>n.head?rs.range(r,o):rs.range(o,r))}}return new rs(t,e)}}function as(t,e){for(let i of t.ranges)if(i.to>e)throw new RangeError("Selection points outside of document")}let ls=0;class cs{constructor(t,e,i,n,s){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.id=ls++,this.default=t([]),this.extensions="function"==typeof s?s(this):s}get reader(){return this}static define(t={}){return new cs(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(t.combine?(t,e)=>t===e:hs),!!t.static,t.enables)}of(t){return new us([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new us(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new us(t,this,2,e)}from(t,e){return e||(e=t=>t),this.compute([t],i=>e(i.field(t)))}}function hs(t,e){return t==e||t.length==e.length&&t.every((t,i)=>t===e[i])}class us{constructor(t,e,i,n){this.dependencies=t,this.facet=e,this.type=i,this.value=n,this.id=ls++}dynamicSlot(t){var e;let i=this.value,n=this.facet.compareInput,s=this.id,o=t[s]>>1,r=2==this.type,a=!1,l=!1,c=[];for(let i of this.dependencies)"doc"==i?a=!0:"selection"==i?l=!0:1&(null!==(e=t[i.id])&&void 0!==e?e:1)||c.push(t[i.id]);return{create:t=>(t.values[o]=i(t),1),update(t,e){if(a&&e.docChanged||l&&(e.docChanged||e.selection)||fs(t,c)){let e=i(t);if(r?!ds(e,t.values[o],n):!n(e,t.values[o]))return t.values[o]=e,1}return 0},reconfigure:(t,e)=>{let a,l=e.config.address[s];if(null!=l){let s=Ts(e,l);if(this.dependencies.every(i=>i instanceof cs?e.facet(i)===t.facet(i):!(i instanceof gs)||e.field(i,!1)==t.field(i,!1))||(r?ds(a=i(t),s,n):n(a=i(t),s)))return t.values[o]=s,0}else a=i(t);return t.values[o]=a,1}}}}function ds(t,e,i){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!i(t[n],e[n]))return!1;return!0}function fs(t,e){let i=!1;for(let n of e)1&Cs(t,n)&&(i=!0);return i}function ps(t,e,i){let n=i.map(e=>t[e.id]),s=i.map(t=>t.type),o=n.filter(t=>!(1&t)),r=t[e.id]>>1;function a(t){let i=[];for(let e=0;e<n.length;e++){let o=Ts(t,n[e]);if(2==s[e])for(let t of o)i.push(t);else i.push(o)}return e.combine(i)}return{create(t){for(let e of n)Cs(t,e);return t.values[r]=a(t),1},update(t,i){if(!fs(t,o))return 0;let n=a(t);return e.compare(n,t.values[r])?0:(t.values[r]=n,1)},reconfigure(t,s){let o=fs(t,n),l=s.config.facets[e.id],c=s.facet(e);if(l&&!o&&hs(i,l))return t.values[r]=c,0;let h=a(t);return e.compare(h,c)?(t.values[r]=c,0):(t.values[r]=h,1)}}}const ms=cs.define({static:!0});class gs{constructor(t,e,i,n,s){this.id=t,this.createF=e,this.updateF=i,this.compareF=n,this.spec=s,this.provides=void 0}static define(t){let e=new gs(ls++,t.create,t.update,t.compare||((t,e)=>t===e),t);return t.provide&&(e.provides=t.provide(e)),e}create(t){let e=t.facet(ms).find(t=>t.field==this);return((null==e?void 0:e.create)||this.createF)(t)}slot(t){let e=t[this.id]>>1;return{create:t=>(t.values[e]=this.create(t),1),update:(t,i)=>{let n=t.values[e],s=this.updateF(n,i);return this.compareF(n,s)?0:(t.values[e]=s,1)},reconfigure:(t,i)=>{let n,s=t.facet(ms),o=i.facet(ms);return(n=s.find(t=>t.field==this))&&n!=o.find(t=>t.field==this)?(t.values[e]=n.create(t),1):null!=i.config.address[this.id]?(t.values[e]=i.field(this),0):(t.values[e]=this.create(t),1)}}}init(t){return[this,ms.of({field:this,create:t})]}get extension(){return this}}const vs=4,ys=3,Os=2,bs=1;function xs(t){return e=>new _s(e,t)}const ws={highest:xs(0),high:xs(bs),default:xs(Os),low:xs(ys),lowest:xs(vs)};class _s{constructor(t,e){this.inner=t,this.prec=e}}class Ss{of(t){return new ks(this,t)}reconfigure(t){return Ss.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class ks{constructor(t,e){this.compartment=t,this.inner=e}}class $s{constructor(t,e,i,n,s,o){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=n,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(t){let e=this.address[t.id];return null==e?t.default:this.staticValues[e>>1]}static resolve(t,e,i){let n=[],s=Object.create(null),o=new Map;for(let i of function(t,e,i){let n=[[],[],[],[],[]],s=new Map;function o(t,r){let a=s.get(t);if(null!=a){if(a<=r)return;let e=n[a].indexOf(t);e>-1&&n[a].splice(e,1),t instanceof ks&&i.delete(t.compartment)}if(s.set(t,r),Array.isArray(t))for(let e of t)o(e,r);else if(t instanceof ks){if(i.has(t.compartment))throw new RangeError("Duplicate use of compartment in extensions");let n=e.get(t.compartment)||t.inner;i.set(t.compartment,n),o(n,r)}else if(t instanceof _s)o(t.inner,t.prec);else if(t instanceof gs)n[r].push(t),t.provides&&o(t.provides,r);else if(t instanceof us)n[r].push(t),t.facet.extensions&&o(t.facet.extensions,Os);else{let e=t.extension;if(!e)throw new Error(`Unrecognized extension value in extension set (${t}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);o(e,r)}}return o(t,Os),n.reduce((t,e)=>t.concat(e))}(t,e,o))i instanceof gs?n.push(i):(s[i.facet.id]||(s[i.facet.id]=[])).push(i);let r=Object.create(null),a=[],l=[];for(let t of n)r[t.id]=l.length<<1,l.push(e=>t.slot(e));let c=null==i?void 0:i.config.facets;for(let t in s){let e=s[t],n=e[0].facet,o=c&&c[t]||[];if(e.every(t=>0==t.type))if(r[n.id]=a.length<<1|1,hs(o,e))a.push(i.facet(n));else{let t=n.combine(e.map(t=>t.value));a.push(i&&n.compare(t,i.facet(n))?i.facet(n):t)}else{for(let t of e)0==t.type?(r[t.id]=a.length<<1|1,a.push(t.value)):(r[t.id]=l.length<<1,l.push(e=>t.dynamicSlot(e)));r[n.id]=l.length<<1,l.push(t=>ps(t,n,e))}}let h=l.map(t=>t(r));return new $s(t,o,h,r,a,s)}}function Cs(t,e){if(1&e)return 2;let i=e>>1,n=t.status[i];if(4==n)throw new Error("Cyclic dependency between fields and/or facets");if(2&n)return n;t.status[i]=4;let s=t.computeSlot(t,t.config.dynamicSlots[i]);return t.status[i]=2|s}function Ts(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}const Ps=cs.define(),Es=cs.define({combine:t=>t.some(t=>t),static:!0}),As=cs.define({combine:t=>t.length?t[0]:void 0,static:!0}),Ms=cs.define(),Qs=cs.define(),Ds=cs.define(),Rs=cs.define({combine:t=>!!t.length&&t[0]});class Is{constructor(t,e){this.type=t,this.value=e}static define(){return new Ls}}class Ls{of(t){return new Is(this,t)}}class Ns{constructor(t){this.map=t}of(t){return new js(this,t)}}class js{constructor(t,e){this.type=t,this.value=e}map(t){let e=this.type.map(this.value,t);return void 0===e?void 0:e==this.value?this:new js(this.type,e)}is(t){return this.type==t}static define(t={}){return new Ns(t.map||(t=>t))}static mapEffects(t,e){if(!t.length)return t;let i=[];for(let n of t){let t=n.map(e);t&&i.push(t)}return i}}js.reconfigure=js.define(),js.appendConfig=js.define();class zs{constructor(t,e,i,n,s,o){this.startState=t,this.changes=e,this.selection=i,this.effects=n,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,i&&as(i,e.newLength),s.some(t=>t.type==zs.time)||(this.annotations=s.concat(zs.time.of(Date.now())))}static create(t,e,i,n,s,o){return new zs(t,e,i,n,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(t){for(let e of this.annotations)if(e.type==t)return e.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let e=this.annotation(zs.userEvent);return!(!e||!(e==t||e.length>t.length&&e.slice(0,t.length)==t&&"."==e[t.length]))}}function Bs(t,e){let i=[];for(let n=0,s=0;;){let o,r;if(n<t.length&&(s==e.length||e[s]>=t[n]))o=t[n++],r=t[n++];else{if(!(s<e.length))return i;o=e[s++],r=e[s++]}!i.length||i[i.length-1]<o?i.push(o,r):i[i.length-1]<r&&(i[i.length-1]=r)}}function qs(t,e,i){var n;let s,o,r;return i?(s=e.changes,o=Kn.empty(e.changes.length),r=t.changes.compose(e.changes)):(s=e.changes.map(t.changes),o=t.changes.mapDesc(e.changes,!0),r=t.changes.compose(s)),{changes:r,selection:e.selection?e.selection.map(o):null===(n=t.selection)||void 0===n?void 0:n.map(s),effects:js.mapEffects(t.effects,s).concat(js.mapEffects(e.effects,o)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function Zs(t,e,i){let n=e.selection,s=Hs(e.annotations);return e.userEvent&&(s=s.concat(zs.userEvent.of(e.userEvent))),{changes:e.changes instanceof Kn?e.changes:Kn.of(e.changes||[],i,t.facet(As)),selection:n&&(n instanceof rs?n:rs.single(n.anchor,n.head)),effects:Hs(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function Fs(t,e,i){let n=Zs(t,e.length?e[0]:{},t.doc.length);e.length&&!1===e[0].filter&&(i=!1);for(let s=1;s<e.length;s++){!1===e[s].filter&&(i=!1);let o=!!e[s].sequential;n=qs(n,Zs(t,e[s],o?n.changes.newLength:t.doc.length),o)}let s=zs.create(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return function(t){let e=t.startState,i=e.facet(Ds),n=t;for(let s=i.length-1;s>=0;s--){let o=i[s](t);o&&Object.keys(o).length&&(n=qs(n,Zs(e,o,t.changes.newLength),!0))}return n==t?t:zs.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}(i?function(t){let e=t.startState,i=!0;for(let n of e.facet(Ms)){let e=n(t);if(!1===e){i=!1;break}Array.isArray(e)&&(i=!0===i?e:Bs(i,e))}if(!0!==i){let n,s;if(!1===i)s=t.changes.invertedDesc,n=Kn.empty(e.doc.length);else{let e=t.changes.filter(i);n=e.changes,s=e.filtered.mapDesc(e.changes).invertedDesc}t=zs.create(e,n,t.selection&&t.selection.map(s),js.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let n=e.facet(Qs);for(let i=n.length-1;i>=0;i--){let s=n[i](t);t=s instanceof zs?s:Array.isArray(s)&&1==s.length&&s[0]instanceof zs?s[0]:Fs(e,Hs(s),!1)}return t}(s):s)}zs.time=Is.define(),zs.userEvent=Is.define(),zs.addToHistory=Is.define(),zs.remote=Is.define();const Xs=[];function Hs(t){return null==t?Xs:Array.isArray(t)?t:[t]}var Ws=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(Ws||(Ws={}));const Vs=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Ys;try{Ys=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(t){}function Us(t){return e=>{if(!/\S/.test(e))return Ws.Space;if(function(t){if(Ys)return Ys.test(t);for(let e=0;e<t.length;e++){let i=t[e];if(/\w/.test(i)||i>"€"&&(i.toUpperCase()!=i.toLowerCase()||Vs.test(i)))return!0}return!1}(e))return Ws.Word;for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>-1)return Ws.Word;return Ws.Other}}class Gs{constructor(t,e,i,n,s,o){this.config=t,this.doc=e,this.selection=i,this.values=n,this.status=t.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let t=0;t<this.config.dynamicSlots.length;t++)Cs(this,t<<1);this.computeSlot=null}field(t,e=!0){let i=this.config.address[t.id];if(null!=i)return Cs(this,i),Ts(this,i);if(e)throw new RangeError("Field is not present in this state")}update(...t){return Fs(this,t,!0)}applyTransaction(t){let e,i=this.config,{base:n,compartments:s}=i;for(let e of t.effects)e.is(Ss.reconfigure)?(i&&(s=new Map,i.compartments.forEach((t,e)=>s.set(e,t)),i=null),s.set(e.value.compartment,e.value.extension)):e.is(js.reconfigure)?(i=null,n=e.value):e.is(js.appendConfig)&&(i=null,n=Hs(n).concat(e.value));if(i)e=t.startState.values.slice();else{i=$s.resolve(n,s,this),e=new Gs(i,this.doc,this.selection,i.dynamicSlots.map(()=>null),(t,e)=>e.reconfigure(t,this),null).values}let o=t.startState.facet(Es)?t.newSelection:t.newSelection.asSingle();new Gs(i,t.newDoc,o,e,(e,i)=>i.update(e,t),t)}replaceSelection(t){return"string"==typeof t&&(t=this.toText(t)),this.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:t},range:rs.cursor(e.from+t.length)}))}changeByRange(t){let e=this.selection,i=t(e.ranges[0]),n=this.changes(i.changes),s=[i.range],o=Hs(i.effects);for(let i=1;i<e.ranges.length;i++){let r=t(e.ranges[i]),a=this.changes(r.changes),l=a.map(n);for(let t=0;t<i;t++)s[t]=s[t].map(l);let c=n.mapDesc(a,!0);s.push(r.range.map(c)),n=n.compose(l),o=js.mapEffects(o,l).concat(js.mapEffects(Hs(r.effects),c))}return{changes:n,selection:rs.create(s,e.mainIndex),effects:o}}changes(t=[]){return t instanceof Kn?t:Kn.of(t,this.doc.length,this.facet(Gs.lineSeparator))}toText(t){return Rn.of(t.split(this.facet(Gs.lineSeparator)||Yn))}sliceDoc(t=0,e=this.doc.length){return this.doc.sliceString(t,e,this.lineBreak)}facet(t){let e=this.config.address[t.id];return null==e?t.default:(Cs(this,e),Ts(this,e))}toJSON(t){let e={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(t)for(let i in t){let n=t[i];n instanceof gs&&null!=this.config.address[n.id]&&(e[i]=n.spec.toJSON(this.field(t[i]),this))}return e}static fromJSON(t,e={},i){if(!t||"string"!=typeof t.doc)throw new RangeError("Invalid JSON representation for EditorState");let n=[];if(i)for(let e in i)if(Object.prototype.hasOwnProperty.call(t,e)){let s=i[e],o=t[e];n.push(s.init(t=>s.spec.fromJSON(o,t)))}return Gs.create({doc:t.doc,selection:rs.fromJSON(t.selection),extensions:e.extensions?n.concat([e.extensions]):n})}static create(t={}){let e=$s.resolve(t.extensions||[],new Map),i=t.doc instanceof Rn?t.doc:Rn.of((t.doc||"").split(e.staticFacet(Gs.lineSeparator)||Yn)),n=t.selection?t.selection instanceof rs?t.selection:rs.single(t.selection.anchor,t.selection.head):rs.single(0);return as(n,i.length),e.staticFacet(Es)||(n=n.asSingle()),new Gs(e,i,n,e.dynamicSlots.map(()=>null),(t,e)=>e.create(t),null)}get tabSize(){return this.facet(Gs.tabSize)}get lineBreak(){return this.facet(Gs.lineSeparator)||"\n"}get readOnly(){return this.facet(Rs)}phrase(t,...e){for(let e of this.facet(Gs.phrases))if(Object.prototype.hasOwnProperty.call(e,t)){t=e[t];break}return e.length&&(t=t.replace(/\$(\$|\d*)/g,(t,i)=>{if("$"==i)return"$";let n=+(i||1);return!n||n>e.length?t:e[n-1]})),t}languageDataAt(t,e,i=-1){let n=[];for(let s of this.facet(Ps))for(let o of s(this,e,i))Object.prototype.hasOwnProperty.call(o,t)&&n.push(o[t]);return n}charCategorizer(t){return Us(this.languageDataAt("wordChars",t).join(""))}wordAt(t){let{text:e,from:i,length:n}=this.doc.lineAt(t),s=this.charCategorizer(t),o=t-i,r=t-i;for(;o>0;){let t=Xn(e,o,!1);if(s(e.slice(t,o))!=Ws.Word)break;o=t}for(;r<n;){let t=Xn(e,r);if(s(e.slice(r,t))!=Ws.Word)break;r=t}return o==r?null:rs.range(o+i,r+i)}}function Ks(t,e,i={}){let n={};for(let e of t)for(let t of Object.keys(e)){let s=e[t],o=n[t];if(void 0===o)n[t]=s;else if(o===s||void 0===s);else{if(!Object.hasOwnProperty.call(i,t))throw new Error("Config merge conflict for field "+t);n[t]=i[t](o,s)}}for(let t in e)void 0===n[t]&&(n[t]=e[t]);return n}Gs.allowMultipleSelections=Es,Gs.tabSize=cs.define({combine:t=>t.length?t[0]:4}),Gs.lineSeparator=As,Gs.readOnly=Rs,Gs.phrases=cs.define({compare(t,e){let i=Object.keys(t),n=Object.keys(e);return i.length==n.length&&i.every(i=>t[i]==e[i])}}),Gs.languageData=Ps,Gs.changeFilter=Ms,Gs.transactionFilter=Qs,Gs.transactionExtender=Ds,Ss.reconfigure=js.define();class Js{eq(t){return this==t}range(t,e=t){return to.create(t,e,this)}}Js.prototype.startSide=Js.prototype.endSide=0,Js.prototype.point=!1,Js.prototype.mapMode=Un.TrackDel;class to{constructor(t,e,i){this.from=t,this.to=e,this.value=i}static create(t,e,i){return new to(t,e,i)}}function eo(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class io{constructor(t,e,i,n){this.from=t,this.to=e,this.value=i,this.maxPoint=n}get length(){return this.to[this.to.length-1]}findIndex(t,e,i,n=0){let s=i?this.to:this.from;for(let o=n,r=s.length;;){if(o==r)return o;let n=o+r>>1,a=s[n]-t||(i?this.value[n].endSide:this.value[n].startSide)-e;if(n==o)return a>=0?o:r;a>=0?r=n:o=n+1}}between(t,e,i,n){for(let s=this.findIndex(e,-1e9,!0),o=this.findIndex(i,1e9,!1,s);s<o;s++)if(!1===n(this.from[s]+t,this.to[s]+t,this.value[s]))return!1}map(t,e){let i=[],n=[],s=[],o=-1,r=-1;for(let a=0;a<this.value.length;a++){let l,c,h=this.value[a],u=this.from[a]+t,d=this.to[a]+t;if(u==d){let t=e.mapPos(u,h.startSide,h.mapMode);if(null==t)continue;if(l=c=t,h.startSide!=h.endSide&&(c=e.mapPos(u,h.endSide),c<l))continue}else if(l=e.mapPos(u,h.startSide),c=e.mapPos(d,h.endSide),l>c||l==c&&h.startSide>0&&h.endSide<=0)continue;(c-l||h.endSide-h.startSide)<0||(o<0&&(o=l),h.point&&(r=Math.max(r,c-l)),i.push(h),n.push(l-o),s.push(c-o))}return{mapped:i.length?new io(n,s,i,r):null,pos:o}}}class no{constructor(t,e,i,n){this.chunkPos=t,this.chunk=e,this.nextLayer=i,this.maxPoint=n}static create(t,e,i,n){return new no(t,e,i,n)}get length(){let t=this.chunk.length-1;return t<0?0:Math.max(this.chunkEnd(t),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let t=this.nextLayer.size;for(let e of this.chunk)t+=e.value.length;return t}chunkEnd(t){return this.chunkPos[t]+this.chunk[t].length}update(t){let{add:e=[],sort:i=!1,filterFrom:n=0,filterTo:s=this.length}=t,o=t.filter;if(0==e.length&&!o)return this;if(i&&(e=e.slice().sort(eo)),this.isEmpty)return e.length?no.of(e):this;let r=new ro(this,null,-1).goto(0),a=0,l=[],c=new so;for(;r.value||a<e.length;)if(a<e.length&&(r.from-e[a].from||r.startSide-e[a].value.startSide)>=0){let t=e[a++];c.addInner(t.from,t.to,t.value)||l.push(t)}else 1==r.rangeIndex&&r.chunkIndex<this.chunk.length&&(a==e.length||this.chunkEnd(r.chunkIndex)<e[a].from)&&(!o||n>this.chunkEnd(r.chunkIndex)||s<this.chunkPos[r.chunkIndex])&&c.addChunk(this.chunkPos[r.chunkIndex],this.chunk[r.chunkIndex])?r.nextChunk():((!o||n>r.to||s<r.from||o(r.from,r.to,r.value))&&(c.addInner(r.from,r.to,r.value)||l.push(to.create(r.from,r.to,r.value))),r.next());return c.finishInner(this.nextLayer.isEmpty&&!l.length?no.empty:this.nextLayer.update({add:l,filter:o,filterFrom:n,filterTo:s}))}map(t){if(t.empty||this.isEmpty)return this;let e=[],i=[],n=-1;for(let s=0;s<this.chunk.length;s++){let o=this.chunkPos[s],r=this.chunk[s],a=t.touchesRange(o,o+r.length);if(!1===a)n=Math.max(n,r.maxPoint),e.push(r),i.push(t.mapPos(o));else if(!0===a){let{mapped:s,pos:a}=r.map(o,t);s&&(n=Math.max(n,s.maxPoint),e.push(s),i.push(a))}}let s=this.nextLayer.map(t);return 0==e.length?s:new no(i,e,s||no.empty,n)}between(t,e,i){if(!this.isEmpty){for(let n=0;n<this.chunk.length;n++){let s=this.chunkPos[n],o=this.chunk[n];if(e>=s&&t<=s+o.length&&!1===o.between(s,t-s,e-s,i))return}this.nextLayer.between(t,e,i)}}iter(t=0){return ao.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return ao.from(t).goto(e)}static compare(t,e,i,n,s=-1){let o=t.filter(t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=s),r=e.filter(t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=s),a=oo(o,r,i),l=new co(o,a,s),c=new co(r,a,s);i.iterGaps((t,e,i)=>ho(l,t,c,e,i,n)),i.empty&&0==i.length&&ho(l,0,c,0,0,n)}static eq(t,e,i=0,n){null==n&&(n=999999999);let s=t.filter(t=>!t.isEmpty&&e.indexOf(t)<0),o=e.filter(e=>!e.isEmpty&&t.indexOf(e)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let r=oo(s,o),a=new co(s,r,0).goto(i),l=new co(o,r,0).goto(i);for(;;){if(a.to!=l.to||!uo(a.active,l.active)||a.point&&(!l.point||!a.point.eq(l.point)))return!1;if(a.to>n)return!0;a.next(),l.next()}}static spans(t,e,i,n,s=-1){let o=new co(t,null,s).goto(e),r=e,a=o.openStart;for(;;){let t=Math.min(o.to,i);if(o.point){let i=o.activeForPoint(o.to),s=o.pointFrom<e?i.length+1:o.point.startSide<0?i.length:Math.min(i.length,a);n.point(r,t,o.point,i,s,o.pointRank),a=Math.min(o.openEnd(t),i.length)}else t>r&&(n.span(r,t,o.active,a),a=o.openEnd(t));if(o.to>i)return a+(o.point&&o.to>i?1:0);r=o.to,o.next()}}static of(t,e=!1){let i=new so;for(let n of t instanceof to?[t]:e?function(t){if(t.length>1)for(let e=t[0],i=1;i<t.length;i++){let n=t[i];if(eo(e,n)>0)return t.slice().sort(eo);e=n}return t}(t):t)i.add(n.from,n.to,n.value);return i.finish()}static join(t){if(!t.length)return no.empty;let e=t[t.length-1];for(let i=t.length-2;i>=0;i--)for(let n=t[i];n!=no.empty;n=n.nextLayer)e=new no(n.chunkPos,n.chunk,e,Math.max(n.maxPoint,e.maxPoint));return e}}no.empty=new no([],[],null,-1),no.empty.nextLayer=no.empty;class so{finishChunk(t){this.chunks.push(new io(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,t&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(t,e,i){this.addInner(t,e,i)||(this.nextLayer||(this.nextLayer=new so)).add(t,e,i)}addInner(t,e,i){let n=t-this.lastTo||i.startSide-this.last.endSide;if(n<=0&&(t-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(n<0)&&(250==this.from.length&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=t),this.from.push(t-this.chunkStart),this.to.push(e-this.chunkStart),this.last=i,this.lastFrom=t,this.lastTo=e,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,e-t)),!0)}addChunk(t,e){if((t-this.lastTo||e.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,e.maxPoint),this.chunks.push(e),this.chunkPos.push(t);let i=e.value.length-1;return this.last=e.value[i],this.lastFrom=e.from[i]+t,this.lastTo=e.to[i]+t,!0}finish(){return this.finishInner(no.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=no.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function oo(t,e,i){let n=new Map;for(let e of t)for(let t=0;t<e.chunk.length;t++)e.chunk[t].maxPoint<=0&&n.set(e.chunk[t],e.chunkPos[t]);let s=new Set;for(let t of e)for(let e=0;e<t.chunk.length;e++){let o=n.get(t.chunk[e]);null==o||(i?i.mapPos(o):o)!=t.chunkPos[e]||(null==i?void 0:i.touchesRange(o,o+t.chunk[e].length))||s.add(t.chunk[e])}return s}class ro{constructor(t,e,i,n=0){this.layer=t,this.skip=e,this.minPoint=i,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,i){for(;this.chunkIndex<this.layer.chunk.length;){let e=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(e)||this.layer.chunkEnd(this.chunkIndex)<t||e.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let n=this.layer.chunk[this.chunkIndex].findIndex(t-this.layer.chunkPos[this.chunkIndex],e,!0);(!i||this.rangeIndex<n)&&this.setRangeIndex(n)}this.next()}forward(t,e){(this.to-t||this.endSide-e)<0&&this.gotoInner(t,e,!0)}next(){for(;;){if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}{let t=this.layer.chunkPos[this.chunkIndex],e=this.layer.chunk[this.chunkIndex],i=t+e.from[this.rangeIndex];if(this.from=i,this.to=t+e.to[this.rangeIndex],this.value=e.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}}setRangeIndex(t){if(t==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=t}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.rank-t.rank||this.to-t.to||this.endSide-t.endSide}}class ao{constructor(t){this.heap=t}static from(t,e=null,i=-1){let n=[];for(let s=0;s<t.length;s++)for(let o=t[s];!o.isEmpty;o=o.nextLayer)o.maxPoint>=i&&n.push(new ro(o,e,i,s));return 1==n.length?n[0]:new ao(n)}get startSide(){return this.value?this.value.startSide:0}goto(t,e=-1e9){for(let i of this.heap)i.goto(t,e);for(let t=this.heap.length>>1;t>=0;t--)lo(this.heap,t);return this.next(),this}forward(t,e){for(let i of this.heap)i.forward(t,e);for(let t=this.heap.length>>1;t>=0;t--)lo(this.heap,t);(this.to-t||this.value.endSide-e)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),lo(this.heap,0)}}}function lo(t,e){for(let i=t[e];;){let n=1+(e<<1);if(n>=t.length)break;let s=t[n];if(n+1<t.length&&s.compare(t[n+1])>=0&&(s=t[n+1],n++),i.compare(s)<0)break;t[n]=i,t[e]=s,e=n}}class co{constructor(t,e,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=ao.from(t,e,i)}goto(t,e=-1e9){return this.cursor.goto(t,e),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=t,this.endSide=e,this.openStart=-1,this.next(),this}forward(t,e){for(;this.minActive>-1&&(this.activeTo[this.minActive]-t||this.active[this.minActive].endSide-e)<0;)this.removeActive(this.minActive);this.cursor.forward(t,e)}removeActive(t){fo(this.active,t),fo(this.activeTo,t),fo(this.activeRank,t),this.minActive=mo(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:n,rank:s}=this.cursor;for(;e<this.activeRank.length&&(s-this.activeRank[e]||n-this.activeTo[e])>0;)e++;po(this.active,e,i),po(this.activeTo,e,n),po(this.activeRank,e,s),t&&po(t,e,this.cursor.from),this.minActive=mo(this.active,this.activeTo)}next(){let t=this.to,e=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)<0){if(this.activeTo[n]>t){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),i&&fo(i,n)}else{if(!this.cursor.value){this.to=this.endSide=1e9;break}if(this.cursor.from>t){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}{let t=this.cursor.value;if(t.point){if(!(e&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){this.point=t,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=t.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(i),this.cursor.next()}}}if(i){this.openStart=0;for(let e=i.length-1;e>=0&&i[e]<t;e--)this.openStart++}}activeForPoint(t){if(!this.active.length)return this.active;let e=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>t||this.activeTo[i]==t&&this.active[i].endSide>=this.point.endSide)&&e.push(this.active[i]);return e.reverse()}openEnd(t){let e=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>t;i--)e++;return e}}function ho(t,e,i,n,s,o){t.goto(e),i.goto(n);let r=n+s,a=n,l=n-e;for(;;){let e=t.to+l-i.to,n=e||t.endSide-i.endSide,s=n<0?t.to+l:i.to,c=Math.min(s,r);if(t.point||i.point?t.point&&i.point&&(t.point==i.point||t.point.eq(i.point))&&uo(t.activeForPoint(t.to),i.activeForPoint(i.to))||o.comparePoint(a,c,t.point,i.point):c>a&&!uo(t.active,i.active)&&o.compareRange(a,c,t.active,i.active),s>r)break;(e||t.openEnd!=i.openEnd)&&o.boundChange&&o.boundChange(s),a=s,n<=0&&t.next(),n>=0&&i.next()}}function uo(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(t[i]!=e[i]&&!t[i].eq(e[i]))return!1;return!0}function fo(t,e){for(let i=e,n=t.length-1;i<n;i++)t[i]=t[i+1];t.pop()}function po(t,e,i){for(let i=t.length-1;i>=e;i--)t[i+1]=t[i];t[e]=i}function mo(t,e){let i=-1,n=1e9;for(let s=0;s<e.length;s++)(e[s]-n||t[s].endSide-t[i].endSide)<0&&(i=s,n=e[s]);return i}function go(t,e,i=t.length){let n=0;for(let s=0;s<i&&s<t.length;)9==t.charCodeAt(s)?(n+=e-n%e,s++):(n++,s=Xn(t,s));return n}function vo(t,e,i,n){for(let n=0,s=0;;){if(s>=e)return n;if(n==t.length)break;s+=9==t.charCodeAt(n)?i-s%i:1,n=Xn(t,n)}return!0===n?-1:t.length}const yo="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),Oo="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),bo="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class xo{constructor(t,e){this.rules=[];let{finish:i}=e||{};function n(t){return/^@/.test(t)?[t]:t.split(/,\s*/)}function s(t,e,o,r){let a=[],l=/^@(\w+)\b/.exec(t[0]),c=l&&"keyframes"==l[1];if(l&&null==e)return o.push(t[0]+";");for(let i in e){let r=e[i];if(/&/.test(i))s(i.split(/,\s*/).map(e=>t.map(t=>e.replace(/&/,t))).reduce((t,e)=>t.concat(e)),r,o);else if(r&&"object"==typeof r){if(!l)throw new RangeError("The value of a property ("+i+") should be a primitive value.");s(n(i),r,a,c)}else null!=r&&a.push(i.replace(/_.*/,"").replace(/[A-Z]/g,t=>"-"+t.toLowerCase())+": "+r+";")}(a.length||c)&&o.push((!i||l||r?t:t.map(i)).join(", ")+" {"+a.join(" ")+"}")}for(let e in t)s(n(e),t[e],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let t=bo[yo]||1;return bo[yo]=t+1,"ͼ"+t.toString(36)}static mount(t,e,i){let n=t[Oo],s=i&&i.nonce;n?s&&n.setNonce(s):n=new _o(t,s),n.mount(Array.isArray(e)?e:[e],t)}}let wo=new Map;class _o{constructor(t,e){let i=t.ownerDocument||t,n=i.defaultView;if(!t.head&&t.adoptedStyleSheets&&n.CSSStyleSheet){let e=wo.get(i);if(e)return t[Oo]=e;this.sheet=new n.CSSStyleSheet,wo.set(i,this)}else this.styleTag=i.createElement("style"),e&&this.styleTag.setAttribute("nonce",e);this.modules=[],t[Oo]=this}mount(t,e){let i=this.sheet,n=0,s=0;for(let e=0;e<t.length;e++){let o=t[e],r=this.modules.indexOf(o);if(r<s&&r>-1&&(this.modules.splice(r,1),s--,r=-1),-1==r){if(this.modules.splice(s++,0,o),i)for(let t=0;t<o.rules.length;t++)i.insertRule(o.rules[t],n++)}else{for(;s<r;)n+=this.modules[s++].rules.length;n+=o.rules.length,s++}}if(i)e.adoptedStyleSheets.indexOf(this.sheet)<0&&(e.adoptedStyleSheets=[this.sheet,...e.adoptedStyleSheets]);else{let t="";for(let e=0;e<this.modules.length;e++)t+=this.modules[e].getRules()+"\n";this.styleTag.textContent=t;let i=e.head||e;this.styleTag.parentNode!=i&&i.insertBefore(this.styleTag,i.firstChild)}}setNonce(t){this.styleTag&&this.styleTag.getAttribute("nonce")!=t&&this.styleTag.setAttribute("nonce",t)}}for(var So={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},ko={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},$o="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Co="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),To=0;To<10;To++)So[48+To]=So[96+To]=String(To);for(To=1;To<=24;To++)So[To+111]="F"+To;for(To=65;To<=90;To++)So[To]=String.fromCharCode(To+32),ko[To]=String.fromCharCode(To);for(var Po in So)ko.hasOwnProperty(Po)||(ko[Po]=So[Po]);function Eo(t){let e;return e=11==t.nodeType?t.getSelection?t:t.ownerDocument:t,e.getSelection()}function Ao(t,e){return!!e&&(t==e||t.contains(1!=e.nodeType?e.parentNode:e))}function Mo(t,e){if(!e.anchorNode)return!1;try{return Ao(t,e.anchorNode)}catch(t){return!1}}function Qo(t){return 3==t.nodeType?Ho(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function Do(t,e,i,n){return!!i&&(Lo(t,e,i,n,-1)||Lo(t,e,i,n,1))}function Ro(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function Io(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function Lo(t,e,i,n,s){for(;;){if(t==i&&e==n)return!0;if(e==(s<0?0:No(t))){if("DIV"==t.nodeName)return!1;let i=t.parentNode;if(!i||1!=i.nodeType)return!1;e=Ro(t)+(s<0?0:1),t=i}else{if(1!=t.nodeType)return!1;if(1==(t=t.childNodes[e+(s<0?-1:0)]).nodeType&&"false"==t.contentEditable)return!1;e=s<0?No(t):0}}}function No(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function jo(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function zo(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function Bo(t,e){let i=e.width/t.offsetWidth,n=e.height/t.offsetHeight;return(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.width-t.offsetWidth)<1)&&(i=1),(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.height-t.offsetHeight)<1)&&(n=1),{scaleX:i,scaleY:n}}class qo{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){let{anchorNode:e,focusNode:i}=t;this.set(e,Math.min(t.anchorOffset,e?No(e):0),i,Math.min(t.focusOffset,i?No(i):0))}set(t,e,i,n){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=n}}let Zo,Fo=null;function Xo(t){if(t.setActive)return t.setActive();if(Fo)return t.focus(Fo);let e=[];for(let i=t;i&&(e.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(t.focus(null==Fo?{get preventScroll(){return Fo={preventScroll:!0},!0}}:void 0),!Fo){Fo=!1;for(let t=0;t<e.length;){let i=e[t++],n=e[t++],s=e[t++];i.scrollTop!=n&&(i.scrollTop=n),i.scrollLeft!=s&&(i.scrollLeft=s)}}}function Ho(t,e,i=e){let n=Zo||(Zo=document.createRange());return n.setEnd(t,i),n.setStart(t,e),n}function Wo(t,e,i,n){let s={key:e,code:e,keyCode:i,which:i,cancelable:!0};n&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=n);let o=new KeyboardEvent("keydown",s);o.synthetic=!0,t.dispatchEvent(o);let r=new KeyboardEvent("keyup",s);return r.synthetic=!0,t.dispatchEvent(r),o.defaultPrevented||r.defaultPrevented}function Vo(t){for(;t.attributes.length;)t.removeAttributeNode(t.attributes[0])}function Yo(t){return t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function Uo(t,e){for(let i=t,n=e;;){if(3==i.nodeType&&n>0)return{node:i,offset:n};if(1==i.nodeType&&n>0){if("false"==i.contentEditable)return null;i=i.childNodes[n-1],n=No(i)}else{if(!i.parentNode||Io(i))return null;n=Ro(i),i=i.parentNode}}}function Go(t,e){for(let i=t,n=e;;){if(3==i.nodeType&&n<i.nodeValue.length)return{node:i,offset:n};if(1==i.nodeType&&n<i.childNodes.length){if("false"==i.contentEditable)return null;i=i.childNodes[n],n=0}else{if(!i.parentNode||Io(i))return null;n=Ro(i)+1,i=i.parentNode}}}class Ko{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new Ko(t.parentNode,Ro(t),e)}static after(t,e){return new Ko(t.parentNode,Ro(t)+1,e)}}const Jo=[];class tr{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(t){let e=this.posAtStart;for(let i of this.children){if(i==t)return e;e+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(t){return this.posBefore(t)+t.length}sync(t,e){if(2&this.flags){let i,n=this.dom,s=null;for(let o of this.children){if(7&o.flags){if(!o.dom&&(i=s?s.nextSibling:n.firstChild)){let t=tr.get(i);(!t||!t.parent&&t.canReuseDOM(o))&&o.reuseDOM(i)}o.sync(t,e),o.flags&=-8}if(i=s?s.nextSibling:n.firstChild,e&&!e.written&&e.node==n&&i!=o.dom&&(e.written=!0),o.dom.parentNode==n)for(;i&&i!=o.dom;)i=er(i);else n.insertBefore(o.dom,i);s=o.dom}for(i=s?s.nextSibling:n.firstChild,i&&e&&e.node==n&&(e.written=!0);i;)i=er(i)}else if(1&this.flags)for(let i of this.children)7&i.flags&&(i.sync(t,e),i.flags&=-8)}reuseDOM(t){}localPosFromDOM(t,e){let i;if(t==this.dom)i=this.dom.childNodes[e];else{let n=0==No(t)?0:0==e?-1:1;for(;;){let e=t.parentNode;if(e==this.dom)break;0==n&&e.firstChild!=e.lastChild&&(n=t==e.firstChild?-1:1),t=e}i=n<0?t:t.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!tr.get(i);)i=i.nextSibling;if(!i)return this.length;for(let t=0,e=0;;t++){let n=this.children[t];if(n.dom==i)return e;e+=n.length+n.breakAfter}}domBoundsAround(t,e,i=0){let n=-1,s=-1,o=-1,r=-1;for(let a=0,l=i,c=i;a<this.children.length;a++){let i=this.children[a],h=l+i.length;if(l<t&&h>e)return i.domBoundsAround(t,e,l);if(h>=t&&-1==n&&(n=a,s=l),l>e&&i.dom.parentNode==this.dom){o=a,r=c;break}c=h,l=h+i.breakAfter}return{from:s,to:r<0?i+this.length:r,startDOM:(n?this.children[n-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:o<this.children.length&&o>=0?this.children[o].dom:null}}markDirty(t=!1){this.flags|=2,this.markParentsDirty(t)}markParentsDirty(t){for(let e=this.parent;e;e=e.parent){if(t&&(e.flags|=2),1&e.flags)return;e.flags|=1,t=!1}}setParent(t){this.parent!=t&&(this.parent=t,7&this.flags&&this.markParentsDirty(!0))}setDOM(t){this.dom!=t&&(this.dom&&(this.dom.cmView=null),this.dom=t,t.cmView=this)}get rootView(){for(let t=this;;){let e=t.parent;if(!e)return t;t=e}}replaceChildren(t,e,i=Jo){this.markDirty();for(let n=t;n<e;n++){let t=this.children[n];t.parent==this&&i.indexOf(t)<0&&t.destroy()}i.length<250?this.children.splice(t,e-t,...i):this.children=[].concat(this.children.slice(0,t),i,this.children.slice(e));for(let t=0;t<i.length;t++)i[t].setParent(this)}ignoreMutation(t){return!1}ignoreEvent(t){return!1}childCursor(t=this.length){return new ir(this.children,t,this.children.length)}childPos(t,e=1){return this.childCursor().findPos(t,e)}toString(){let t=this.constructor.name.replace("View","");return t+(this.children.length?"("+this.children.join()+")":this.length?"["+("Text"==t?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(t){return t.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(t,e,i,n,s,o){return!1}become(t){return!1}canReuseDOM(t){return t.constructor==this.constructor&&!(8&(this.flags|t.flags))}getSide(){return 0}destroy(){for(let t of this.children)t.parent==this&&t.destroy();this.parent=null}}function er(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}tr.prototype.breakAfter=0;class ir{constructor(t,e,i){this.children=t,this.pos=e,this.i=i,this.off=0}findPos(t,e=1){for(;;){if(t>this.pos||t==this.pos&&(e>0||0==this.i||this.children[this.i-1].breakAfter))return this.off=t-this.pos,this;let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}}function nr(t,e,i,n,s,o,r,a,l){let{children:c}=t,h=c.length?c[e]:null,u=o.length?o[o.length-1]:null,d=u?u.breakAfter:r;if(!(e==n&&h&&!r&&!d&&o.length<2&&h.merge(i,s,o.length?u:null,0==i,a,l))){if(n<c.length){let t=c[n];t&&(s<t.length||t.breakAfter&&(null==u?void 0:u.breakAfter))?(e==n&&(t=t.split(s),s=0),!d&&u&&t.merge(0,s,u,!0,0,l)?o[o.length-1]=t:((s||t.children.length&&!t.children[0].length)&&t.merge(0,s,null,!1,0,l),o.push(t))):(null==t?void 0:t.breakAfter)&&(u?u.breakAfter=1:r=1),n++}for(h&&(h.breakAfter=r,i>0&&(!r&&o.length&&h.merge(i,h.length,o[0],!1,a,0)?h.breakAfter=o.shift().breakAfter:(i<h.length||h.children.length&&0==h.children[h.children.length-1].length)&&h.merge(i,h.length,null,!1,a,0),e++));e<n&&o.length;)if(c[n-1].become(o[o.length-1]))n--,o.pop(),l=o.length?0:a;else{if(!c[e].become(o[0]))break;e++,o.shift(),a=o.length?0:l}!o.length&&e&&n<c.length&&!c[e-1].breakAfter&&c[n].merge(0,0,c[e-1],!1,a,l)&&e--,(e<n||o.length)&&t.replaceChildren(e,n,o)}}function sr(t,e,i,n,s,o){let r=t.childCursor(),{i:a,off:l}=r.findPos(i,1),{i:c,off:h}=r.findPos(e,-1),u=e-i;for(let t of n)u+=t.length;t.length+=u,nr(t,c,h,a,l,n,0,s,o)}let or="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},rr="undefined"!=typeof document?document:{documentElement:{style:{}}};const ar=/Edge\/(\d+)/.exec(or.userAgent),lr=/MSIE \d/.test(or.userAgent),cr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(or.userAgent),hr=!!(lr||cr||ar),ur=!hr&&/gecko\/(\d+)/i.test(or.userAgent),dr=!hr&&/Chrome\/(\d+)/.exec(or.userAgent),fr="webkitFontSmoothing"in rr.documentElement.style,pr=!hr&&/Apple Computer/.test(or.vendor),mr=pr&&(/Mobile\/\w+/.test(or.userAgent)||or.maxTouchPoints>2);var gr={mac:mr||/Mac/.test(or.platform),windows:/Win/.test(or.platform),linux:/Linux|X11/.test(or.platform),ie:hr,ie_version:lr?rr.documentMode||6:cr?+cr[1]:ar?+ar[1]:0,gecko:ur,gecko_version:ur?+(/Firefox\/(\d+)/.exec(or.userAgent)||[0,0])[1]:0,chrome:!!dr,chrome_version:dr?+dr[1]:0,ios:mr,android:/Android\b/.test(or.userAgent),webkit:fr,safari:pr,webkit_version:fr?+(/\bAppleWebKit\/(\d+)/.exec(or.userAgent)||[0,0])[1]:0,tabSize:null!=rr.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};class vr extends tr{constructor(t){super(),this.text=t}get length(){return this.text.length}createDOM(t){this.setDOM(t||document.createTextNode(this.text))}sync(t,e){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text)}reuseDOM(t){3==t.nodeType&&this.createDOM(t)}merge(t,e,i){return!(8&this.flags||i&&(!(i instanceof vr)||this.length-(e-t)+i.length>256||8&i.flags))&&(this.text=this.text.slice(0,t)+(i?i.text:"")+this.text.slice(e),this.markDirty(),!0)}split(t){let e=new vr(this.text.slice(t));return this.text=this.text.slice(0,t),this.markDirty(),e.flags|=8&this.flags,e}localPosFromDOM(t,e){return t==this.dom?e:e?this.text.length:0}domAtPos(t){return new Ko(this.dom,t)}domBoundsAround(t,e,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(t,e){return function(t,e,i){let n=t.nodeValue.length;e>n&&(e=n);let s=e,o=e,r=0;0==e&&i<0||e==n&&i>=0?gr.chrome||gr.gecko||(e?(s--,r=1):o<n&&(o++,r=-1)):i<0?s--:o<n&&o++;let a=Ho(t,s,o).getClientRects();if(!a.length)return null;let l=a[(r?r<0:i>=0)?0:a.length-1];gr.safari&&!r&&0==l.width&&(l=Array.prototype.find.call(a,t=>t.width)||l);return r?jo(l,r<0):l||null}(this.dom,t,e)}}class yr extends tr{constructor(t,e=[],i=0){super(),this.mark=t,this.children=e,this.length=i;for(let t of e)t.setParent(this)}setAttrs(t){if(Vo(t),this.mark.class&&(t.className=this.mark.class),this.mark.attrs)for(let e in this.mark.attrs)t.setAttribute(e,this.mark.attrs[e]);return t}canReuseDOM(t){return super.canReuseDOM(t)&&!(8&(this.flags|t.flags))}reuseDOM(t){t.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(t),this.flags|=6)}sync(t,e){this.dom?4&this.flags&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(t,e)}merge(t,e,i,n,s,o){return(!i||!(!(i instanceof yr&&i.mark.eq(this.mark))||t&&s<=0||e<this.length&&o<=0))&&(sr(this,t,e,i?i.children.slice():[],s-1,o-1),this.markDirty(),!0)}split(t){let e=[],i=0,n=-1,s=0;for(let o of this.children){let r=i+o.length;r>t&&e.push(i<t?o.split(t-i):o),n<0&&i>=t&&(n=s),i=r,s++}let o=this.length-t;return this.length=t,n>-1&&(this.children.length=n,this.markDirty()),new yr(this.mark,e,o)}domAtPos(t){return xr(this,t)}coordsAt(t,e){return _r(this,t,e)}}class Or extends tr{static create(t,e,i){return new Or(t,e,i)}constructor(t,e,i){super(),this.widget=t,this.length=e,this.side=i,this.prevWidget=null}split(t){let e=Or.create(this.widget,this.length-t,this.side);return this.length-=t,e}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(t,e,i,n,s,o){return!(i&&(!(i instanceof Or&&this.widget.compare(i.widget))||t>0&&s<=0||e<this.length&&o<=0))&&(this.length=t+(i?i.length:0)+(this.length-e),!0)}become(t){return t instanceof Or&&t.side==this.side&&this.widget.constructor==t.widget.constructor&&(this.widget.compare(t.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get overrideDOMText(){if(0==this.length)return Rn.empty;let t=this;for(;t.parent;)t=t.parent;let{view:e}=t,i=e&&e.state.doc,n=this.posAtStart;return i?i.slice(n,n+this.length):Rn.empty}domAtPos(t){return(this.length?0==t:this.side>0)?Ko.before(this.dom):Ko.after(this.dom,t==this.length)}domBoundsAround(){return null}coordsAt(t,e){let i=this.widget.coordsAt(this.dom,t,e);if(i)return i;let n=this.dom.getClientRects(),s=null;if(!n.length)return null;let o=this.side?this.side<0:t>0;for(let e=o?n.length-1:0;s=n[e],!(t>0?0==e:e==n.length-1||s.top<s.bottom);e+=o?-1:1);return jo(s,!o)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class br extends tr{constructor(t){super(),this.side=t}get length(){return 0}merge(){return!1}become(t){return t instanceof br&&t.side==this.side}split(){return new br(this.side)}sync(){if(!this.dom){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),this.setDOM(t)}}getSide(){return this.side}domAtPos(t){return this.side>0?Ko.before(this.dom):Ko.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){return this.dom.getBoundingClientRect()}get overrideDOMText(){return Rn.empty}get isHidden(){return!0}}function xr(t,e){let i=t.dom,{children:n}=t,s=0;for(let t=0;s<n.length;s++){let o=n[s],r=t+o.length;if(!(r==t&&o.getSide()<=0)){if(e>t&&e<r&&o.dom.parentNode==i)return o.domAtPos(e-t);if(e<=t)break;t=r}}for(let t=s;t>0;t--){let e=n[t-1];if(e.dom.parentNode==i)return e.domAtPos(e.length)}for(let t=s;t<n.length;t++){let e=n[t];if(e.dom.parentNode==i)return e.domAtPos(0)}return new Ko(i,0)}function wr(t,e,i){let n,{children:s}=t;i>0&&e instanceof yr&&s.length&&(n=s[s.length-1])instanceof yr&&n.mark.eq(e.mark)?wr(n,e.children[0],i-1):(s.push(e),e.setParent(t)),t.length+=e.length}function _r(t,e,i){let n=null,s=-1,o=null,r=-1;!function t(e,a){for(let l=0,c=0;l<e.children.length&&c<=a;l++){let h=e.children[l],u=c+h.length;u>=a&&(h.children.length?t(h,a-c):(!o||o.isHidden&&(i>0||Sr(o,h)))&&(u>a||c==u&&h.getSide()>0)?(o=h,r=a-c):(c<a||c==u&&h.getSide()<0&&!h.isHidden)&&(n=h,s=a-c)),c=u}}(t,e);let a=(i<0?n:o)||n||o;return a?a.coordsAt(Math.max(0,a==n?s:r),i):function(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let i=Qo(e);return i[i.length-1]||null}(t)}function Sr(t,e){let i=t.coordsAt(0,1),n=e.coordsAt(0,1);return i&&n&&n.top<i.bottom}function kr(t,e){for(let i in t)"class"==i&&e.class?e.class+=" "+t.class:"style"==i&&e.style?e.style+=";"+t.style:e[i]=t[i];return e}vr.prototype.children=Or.prototype.children=br.prototype.children=Jo;const $r=Object.create(null);function Cr(t,e,i){if(t==e)return!0;t||(t=$r),e||(e=$r);let n=Object.keys(t),s=Object.keys(e);if(n.length-(i&&n.indexOf(i)>-1?1:0)!=s.length-(i&&s.indexOf(i)>-1?1:0))return!1;for(let o of n)if(o!=i&&(-1==s.indexOf(o)||t[o]!==e[o]))return!1;return!0}function Tr(t,e,i){let n=!1;if(e)for(let s in e)i&&s in i||(n=!0,"style"==s?t.style.cssText="":t.removeAttribute(s));if(i)for(let s in i)e&&e[s]==i[s]||(n=!0,"style"==s?t.style.cssText=i[s]:t.setAttribute(s,i[s]));return n}function Pr(t){let e=Object.create(null);for(let i=0;i<t.attributes.length;i++){let n=t.attributes[i];e[n.name]=n.value}return e}class Er{eq(t){return!1}updateDOM(t,e){return!1}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(t){return!0}coordsAt(t,e,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(t){}}var Ar=function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t}(Ar||(Ar={}));class Mr extends Js{constructor(t,e,i,n){super(),this.startSide=t,this.endSide=e,this.widget=i,this.spec=n}get heightRelevant(){return!1}static mark(t){return new Qr(t)}static widget(t){let e=Math.max(-1e4,Math.min(1e4,t.side||0)),i=!!t.block;return e+=i&&!t.inlineOrder?e>0?3e8:-4e8:e>0?1e8:-1e8,new Rr(t,e,e,i,t.widget||null,!1)}static replace(t){let e,i,n=!!t.block;if(t.isBlockGap)e=-5e8,i=4e8;else{let{start:s,end:o}=Ir(t,n);e=(s?n?-3e8:-1:5e8)-1,i=1+(o?n?2e8:1:-6e8)}return new Rr(t,e,i,n,t.widget||null,!0)}static line(t){return new Dr(t)}static set(t,e=!1){return no.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}Mr.none=no.empty;class Qr extends Mr{constructor(t){let{start:e,end:i}=Ir(t);super(e?-1:5e8,i?1:-6e8,null,t),this.tagName=t.tagName||"span",this.class=t.class||"",this.attrs=t.attributes||null}eq(t){var e,i;return this==t||t instanceof Qr&&this.tagName==t.tagName&&(this.class||(null===(e=this.attrs)||void 0===e?void 0:e.class))==(t.class||(null===(i=t.attrs)||void 0===i?void 0:i.class))&&Cr(this.attrs,t.attrs,"class")}range(t,e=t){if(t>=e)throw new RangeError("Mark decorations may not be empty");return super.range(t,e)}}Qr.prototype.point=!1;class Dr extends Mr{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof Dr&&this.spec.class==t.spec.class&&Cr(this.spec.attributes,t.spec.attributes)}range(t,e=t){if(e!=t)throw new RangeError("Line decoration ranges must be zero-length");return super.range(t,e)}}Dr.prototype.mapMode=Un.TrackBefore,Dr.prototype.point=!0;class Rr extends Mr{constructor(t,e,i,n,s,o){super(e,i,s,t),this.block=n,this.isReplace=o,this.mapMode=n?e<=0?Un.TrackBefore:Un.TrackAfter:Un.TrackDel}get type(){return this.startSide!=this.endSide?Ar.WidgetRange:this.startSide<=0?Ar.WidgetBefore:Ar.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof Rr&&(e=this.widget,i=t.widget,e==i||!!(e&&i&&e.compare(i)))&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide;var e,i}range(t,e=t){if(this.isReplace&&(t>e||t==e&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&e!=t)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(t,e)}}function Ir(t,e=!1){let{inclusiveStart:i,inclusiveEnd:n}=t;return null==i&&(i=t.inclusive),null==n&&(n=t.inclusive),{start:null!=i?i:e,end:null!=n?n:e}}function Lr(t,e,i,n=0){let s=i.length-1;s>=0&&i[s]+n>=t?i[s]=Math.max(i[s],e):i.push(t,e)}Rr.prototype.point=!0;class Nr extends tr{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(t,e,i,n,s,o){if(i){if(!(i instanceof Nr))return!1;this.dom||i.transferDOM(this)}return n&&this.setDeco(i?i.attrs:null),sr(this,t,e,i?i.children.slice():[],s,o),!0}split(t){let e=new Nr;if(e.breakAfter=this.breakAfter,0==this.length)return e;let{i,off:n}=this.childPos(t);n&&(e.append(this.children[i].split(n),0),this.children[i].merge(n,this.children[i].length,null,!1,0,0),i++);for(let t=i;t<this.children.length;t++)e.append(this.children[t],0);for(;i>0&&0==this.children[i-1].length;)this.children[--i].destroy();return this.children.length=i,this.markDirty(),this.length=t,e}transferDOM(t){this.dom&&(this.markDirty(),t.setDOM(this.dom),t.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(t){Cr(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){wr(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=kr(e,this.attrs||{})),i&&(this.attrs=kr({class:i},this.attrs||{}))}domAtPos(t){return xr(this,t)}reuseDOM(t){"DIV"==t.nodeName&&(this.setDOM(t),this.flags|=6)}sync(t,e){var i;this.dom?4&this.flags&&(Vo(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),void 0!==this.prevAttrs&&(Tr(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(t,e);let n=this.dom.lastChild;for(;n&&tr.get(n)instanceof yr;)n=n.lastChild;if(!(n&&this.length&&("BR"==n.nodeName||0!=(null===(i=tr.get(n))||void 0===i?void 0:i.isEditable)||gr.ios&&this.children.some(t=>t instanceof vr)))){let t=document.createElement("BR");t.cmIgnore=!0,this.dom.appendChild(t)}}measureTextSize(){if(0==this.children.length||this.length>20)return null;let t,e=0;for(let i of this.children){if(!(i instanceof vr)||/[^ -~]/.test(i.text))return null;let n=Qo(i.dom);if(1!=n.length)return null;e+=n[0].width,t=n[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(t,e){let i=_r(this,t,e);if(!this.children.length&&i&&this.parent){let{heightOracle:t}=this.parent.view.viewState,e=i.bottom-i.top;if(Math.abs(e-t.lineHeight)<2&&t.textHeight<e){let n=(e-t.textHeight)/2;return{top:i.top+n,bottom:i.bottom-n,left:i.left,right:i.left}}}return i}become(t){return t instanceof Nr&&0==this.children.length&&0==t.children.length&&Cr(this.attrs,t.attrs)&&this.breakAfter==t.breakAfter}covers(){return!0}static find(t,e){for(let i=0,n=0;i<t.children.length;i++){let s=t.children[i],o=n+s.length;if(o>=e){if(s instanceof Nr)return s;if(o>e)break}n=o+s.breakAfter}return null}}class jr extends tr{constructor(t,e,i){super(),this.widget=t,this.length=e,this.deco=i,this.breakAfter=0,this.prevWidget=null}merge(t,e,i,n,s,o){return!(i&&(!(i instanceof jr&&this.widget.compare(i.widget))||t>0&&s<=0||e<this.length&&o<=0))&&(this.length=t+(i?i.length:0)+(this.length-e),!0)}domAtPos(t){return 0==t?Ko.before(this.dom):Ko.after(this.dom,t==this.length)}split(t){let e=this.length-t;this.length=t;let i=new jr(this.widget,e,this.deco);return i.breakAfter=this.breakAfter,i}get children(){return Jo}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.widget.editable||(this.dom.contentEditable="false"))}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):Rn.empty}domBoundsAround(){return null}become(t){return t instanceof jr&&t.widget.constructor==this.widget.constructor&&(t.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,this.deco=t.deco,this.breakAfter=t.breakAfter,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(t,e){let i=this.widget.coordsAt(this.dom,t,e);return i||(this.widget instanceof zr?null:jo(this.dom.getBoundingClientRect(),this.length?0==t:e<=0))}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(t){let{startSide:e,endSide:i}=this.deco;return e!=i&&(t<0?e<0:i>0)}}class zr extends Er{constructor(t){super(),this.height=t}toDOM(){let t=document.createElement("div");return t.className="cm-gap",this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}class Br{constructor(t,e,i,n){this.doc=t,this.pos=e,this.end=i,this.disallowBlockEffectsFor=n,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=t.iter(),this.skip=e}posCovered(){if(0==this.content.length)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let t=this.content[this.content.length-1];return!(t.breakAfter||t instanceof jr&&t.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new Nr),this.atCursorPos=!0),this.curLine}flushBuffer(t=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(qr(new br(-1),t),t.length),this.pendingBuffer=0)}addBlockWidget(t){this.flushBuffer(),this.curLine=null,this.content.push(t)}finish(t){this.pendingBuffer&&t<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,this.posCovered()||t&&this.content.length&&this.content[this.content.length-1]instanceof jr||this.getLine()}buildText(t,e,i){for(;t>0;){if(this.textOff==this.text.length){let{value:e,lineBreak:i,done:n}=this.cursor.next(this.skip);if(this.skip=0,n)throw new Error("Ran out of text content when drawing inline views");if(i){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,t--;continue}this.text=e,this.textOff=0}let n=Math.min(this.text.length-this.textOff,t,512);this.flushBuffer(e.slice(e.length-i)),this.getLine().append(qr(new vr(this.text.slice(this.textOff,this.textOff+n)),e),i),this.atCursorPos=!0,this.textOff+=n,t-=n,i=0}}span(t,e,i,n){this.buildText(e-t,i,n),this.pos=e,this.openStart<0&&(this.openStart=n)}point(t,e,i,n,s,o){if(this.disallowBlockEffectsFor[o]&&i instanceof Rr){if(i.block)throw new RangeError("Block decorations may not be specified via plugins");if(e>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let r=e-t;if(i instanceof Rr)if(i.block)i.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new jr(i.widget||Zr.block,r,i));else{let o=Or.create(i.widget||Zr.inline,r,r?0:i.startSide),a=this.atCursorPos&&!o.isEditable&&s<=n.length&&(t<e||i.startSide>0),l=!o.isEditable&&(t<e||s>n.length||i.startSide<=0),c=this.getLine();2!=this.pendingBuffer||a||o.isEditable||(this.pendingBuffer=0),this.flushBuffer(n),a&&(c.append(qr(new br(1),n),s),s=n.length+Math.max(0,s-n.length)),c.append(qr(o,n),s),this.atCursorPos=l,this.pendingBuffer=l?t<e||s>n.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=n.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);r&&(this.textOff+r<=this.text.length?this.textOff+=r:(this.skip+=r-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=e),this.openStart<0&&(this.openStart=s)}static build(t,e,i,n,s){let o=new Br(t,e,i,s);return o.openEnd=no.spans(n,e,i,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}}function qr(t,e){for(let i of e)t=new yr(i,[t],t.length);return t}class Zr extends Er{constructor(t){super(),this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}Zr.inline=new Zr("span"),Zr.block=new Zr("div");var Fr=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(Fr||(Fr={}));const Xr=Fr.LTR,Hr=Fr.RTL;function Wr(t){let e=[];for(let i=0;i<t.length;i++)e.push(1<<+t[i]);return e}const Vr=Wr("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Yr=Wr("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Ur=Object.create(null),Gr=[];for(let t of["()","[]","{}"]){let e=t.charCodeAt(0),i=t.charCodeAt(1);Ur[e]=i,Ur[i]=-e}function Kr(t){return t<=247?Vr[t]:1424<=t&&t<=1524?2:1536<=t&&t<=1785?Yr[t-1536]:1774<=t&&t<=2220?4:8192<=t&&t<=8204?256:64336<=t&&t<=65023?4:1}const Jr=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class ta{get dir(){return this.level%2?Hr:Xr}constructor(t,e,i){this.from=t,this.to=e,this.level=i}side(t,e){return this.dir==e==t?this.to:this.from}forward(t,e){return t==(this.dir==e)}static find(t,e,i,n){let s=-1;for(let o=0;o<t.length;o++){let r=t[o];if(r.from<=e&&r.to>=e){if(r.level==i)return o;(s<0||(0!=n?n<0?r.from<e:r.to>e:t[s].level>r.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}}function ea(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let n=t[i],s=e[i];if(n.from!=s.from||n.to!=s.to||n.direction!=s.direction||!ea(n.inner,s.inner))return!1}return!0}const ia=[];function na(t,e,i,n,s,o,r){let a=n%2?2:1;if(n%2==s%2)for(let l=e,c=0;l<i;){let e=!0,h=!1;if(c==o.length||l<o[c].from){let t=ia[l];t!=a&&(e=!1,h=16==t)}let u=e||1!=a?null:[],d=e?n:n+1,f=l;t:for(;;)if(c<o.length&&f==o[c].from){if(h)break t;let p=o[c];if(!e)for(let t=p.to,e=c+1;;){if(t==i)break t;if(!(e<o.length&&o[e].from==t)){if(ia[t]==a)break t;break}t=o[e++].to}if(c++,u)u.push(p);else{p.from>l&&r.push(new ta(l,p.from,d)),sa(t,p.direction==Xr!=!(d%2)?n+1:n,s,p.inner,p.from,p.to,r),l=p.to}f=p.to}else{if(f==i||(e?ia[f]!=a:ia[f]==a))break;f++}u?na(t,l,f,n+1,s,u,r):l<f&&r.push(new ta(l,f,d)),l=f}else for(let l=i,c=o.length;l>e;){let i=!0,h=!1;if(!c||l>o[c-1].to){let t=ia[l-1];t!=a&&(i=!1,h=16==t)}let u=i||1!=a?null:[],d=i?n:n+1,f=l;t:for(;;)if(c&&f==o[c-1].to){if(h)break t;let p=o[--c];if(!i)for(let t=p.from,i=c;;){if(t==e)break t;if(!i||o[i-1].to!=t){if(ia[t-1]==a)break t;break}t=o[--i].from}if(u)u.push(p);else{p.to<l&&r.push(new ta(p.to,l,d)),sa(t,p.direction==Xr!=!(d%2)?n+1:n,s,p.inner,p.from,p.to,r),l=p.from}f=p.from}else{if(f==e||(i?ia[f-1]!=a:ia[f-1]==a))break;f--}u?na(t,f,l,n+1,s,u,r):f<l&&r.push(new ta(f,l,d)),l=f}}function sa(t,e,i,n,s,o,r){let a=e%2?2:1;!function(t,e,i,n,s){for(let o=0;o<=n.length;o++){let r=o?n[o-1].to:e,a=o<n.length?n[o].from:i,l=o?256:s;for(let e=r,i=l,n=l;e<a;e++){let s=Kr(t.charCodeAt(e));512==s?s=i:8==s&&4==n&&(s=16),ia[e]=4==s?2:s,7&s&&(n=s),i=s}for(let t=r,e=l,n=l;t<a;t++){let s=ia[t];if(128==s)t<a-1&&e==ia[t+1]&&24&e?s=ia[t]=e:ia[t]=256;else if(64==s){let s=t+1;for(;s<a&&64==ia[s];)s++;let o=t&&8==e||s<i&&8==ia[s]?1==n?1:8:256;for(let e=t;e<s;e++)ia[e]=o;t=s-1}else 8==s&&1==n&&(ia[t]=1);e=s,7&s&&(n=s)}}}(t,s,o,n,a),function(t,e,i,n,s){let o=1==s?2:1;for(let r=0,a=0,l=0;r<=n.length;r++){let c=r?n[r-1].to:e,h=r<n.length?n[r].from:i;for(let e,i,n,r=c;r<h;r++)if(i=Ur[e=t.charCodeAt(r)])if(i<0){for(let t=a-3;t>=0;t-=3)if(Gr[t+1]==-i){let e=Gr[t+2],i=2&e?s:4&e?1&e?o:s:0;i&&(ia[r]=ia[Gr[t]]=i),a=t;break}}else{if(189==Gr.length)break;Gr[a++]=r,Gr[a++]=e,Gr[a++]=l}else if(2==(n=ia[r])||1==n){let t=n==s;l=t?0:1;for(let e=a-3;e>=0;e-=3){let i=Gr[e+2];if(2&i)break;if(t)Gr[e+2]|=2;else{if(4&i)break;Gr[e+2]|=4}}}}}(t,s,o,n,a),function(t,e,i,n){for(let s=0,o=n;s<=i.length;s++){let r=s?i[s-1].to:t,a=s<i.length?i[s].from:e;for(let l=r;l<a;){let r=ia[l];if(256==r){let r=l+1;for(;;)if(r==a){if(s==i.length)break;r=i[s++].to,a=s<i.length?i[s].from:e}else{if(256!=ia[r])break;r++}let c=1==o,h=c==(1==(r<e?ia[r]:n))?c?1:2:n;for(let e=r,n=s,o=n?i[n-1].to:t;e>l;)e==o&&(e=i[--n].from,o=n?i[n-1].to:t),ia[--e]=h;l=r}else o=r,l++}}}(s,o,n,a),na(t,s,o,e,i,n,r)}function oa(t,e,i){if(!t)return[new ta(0,0,e==Hr?1:0)];if(e==Xr&&!i.length&&!Jr.test(t))return ra(t.length);if(i.length)for(;t.length>ia.length;)ia[ia.length]=256;let n=[],s=e==Xr?0:1;return sa(t,s,s,i,0,t.length,n),n}function ra(t){return[new ta(0,t,0)]}let aa="";function la(t,e,i,n,s){var o;let r=n.head-t.from,a=ta.find(e,r,null!==(o=n.bidiLevel)&&void 0!==o?o:-1,n.assoc),l=e[a],c=l.side(s,i);if(r==c){let t=a+=s?1:-1;if(t<0||t>=e.length)return null;l=e[a=t],r=l.side(!s,i),c=l.side(s,i)}let h=Xn(t.text,r,l.forward(s,i));(h<l.from||h>l.to)&&(h=c),aa=t.text.slice(Math.min(r,h),Math.max(r,h));let u=a==(s?e.length-1:0)?null:e[a+(s?1:-1)];return u&&h==c&&u.level+(s?0:1)<l.level?rs.cursor(u.side(!s,i)+t.from,u.forward(s,i)?1:-1,u.level):rs.cursor(h+t.from,l.forward(s,i)?-1:1,l.level)}function ca(t,e,i){for(let n=e;n<i;n++){let e=Kr(t.charCodeAt(n));if(1==e)return Xr;if(2==e||4==e)return Hr}return Xr}const ha=cs.define(),ua=cs.define(),da=cs.define(),fa=cs.define(),pa=cs.define(),ma=cs.define(),ga=cs.define(),va=cs.define(),ya=cs.define(),Oa=cs.define({combine:t=>t.some(t=>t)}),ba=cs.define({combine:t=>t.some(t=>t)}),xa=cs.define();class wa{constructor(t,e="nearest",i="nearest",n=5,s=5,o=!1){this.range=t,this.y=e,this.x=i,this.yMargin=n,this.xMargin=s,this.isSnapshot=o}map(t){return t.empty?this:new wa(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new wa(rs.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const _a=js.define({map:(t,e)=>t.map(e)}),Sa=js.define();function ka(t,e,i){let n=t.facet(fa);n.length?n[0](e):window.onerror&&window.onerror(String(e),i,void 0,void 0,e)||(i?console.error(i+":",e):console.error(e))}const $a=cs.define({combine:t=>!t.length||t[0]});let Ca=0;const Ta=cs.define({combine:t=>t.filter((e,i)=>{for(let n=0;n<i;n++)if(t[n].plugin==e.plugin)return!1;return!0})});class Pa{constructor(t,e,i,n,s){this.id=t,this.create=e,this.domEventHandlers=i,this.domEventObservers=n,this.baseExtensions=s(this),this.extension=this.baseExtensions.concat(Ta.of({plugin:this,arg:void 0}))}of(t){return this.baseExtensions.concat(Ta.of({plugin:this,arg:t}))}static define(t,e){const{eventHandlers:i,eventObservers:n,provide:s,decorations:o}=e||{};return new Pa(Ca++,t,i,n,t=>{let e=[];return o&&e.push(Qa.of(e=>{let i=e.plugin(t);return i?o(i):Mr.none})),s&&e.push(s(t)),e})}static fromClass(t,e){return Pa.define((e,i)=>new t(e,i),e)}}class Ea{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(t){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(e){if(ka(t.state,e,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(t){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(t,this.spec.arg)}catch(e){ka(t.state,e,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(t){var e;if(null===(e=this.value)||void 0===e?void 0:e.destroy)try{this.value.destroy()}catch(e){ka(t.state,e,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const Aa=cs.define(),Ma=cs.define(),Qa=cs.define(),Da=cs.define(),Ra=cs.define(),Ia=cs.define();function La(t,e){let i=t.state.facet(Ia);if(!i.length)return i;let n=i.map(e=>e instanceof Function?e(t):e),s=[];return no.spans(n,e.from,e.to,{point(){},span(t,i,n,o){let r=t-e.from,a=i-e.from,l=s;for(let t=n.length-1;t>=0;t--,o--){let i,s=n[t].spec.bidiIsolate;if(null==s&&(s=ca(e.text,r,a)),o>0&&l.length&&(i=l[l.length-1]).to==r&&i.direction==s)i.to=a,l=i.inner;else{let t={from:r,to:a,direction:s,inner:[]};l.push(t),l=t.inner}}}}),s}const Na=cs.define();function ja(t){let e=0,i=0,n=0,s=0;for(let o of t.state.facet(Na)){let r=o(t);r&&(null!=r.left&&(e=Math.max(e,r.left)),null!=r.right&&(i=Math.max(i,r.right)),null!=r.top&&(n=Math.max(n,r.top)),null!=r.bottom&&(s=Math.max(s,r.bottom)))}return{left:e,right:i,top:n,bottom:s}}const za=cs.define();class Ba{constructor(t,e,i,n){this.fromA=t,this.toA=e,this.fromB=i,this.toB=n}join(t){return new Ba(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,i=this;for(;e>0;e--){let n=t[e-1];if(!(n.fromA>i.toA)){if(n.toA<i.fromA)break;i=i.join(n),t.splice(e-1,1)}}return t.splice(e,0,i),t}static extendWithRanges(t,e){if(0==e.length)return t;let i=[];for(let n=0,s=0,o=0,r=0;;n++){let a=n==t.length?null:t[n],l=o-r,c=a?a.fromB:1e9;for(;s<e.length&&e[s]<c;){let t=e[s],n=e[s+1],o=Math.max(r,t),a=Math.min(c,n);if(o<=a&&new Ba(o+l,a+l,o,a).addToSet(i),n>c)break;s+=2}if(!a)return i;new Ba(a.fromA,a.toA,a.fromB,a.toB).addToSet(i),o=a.toA,r=a.toB}}}class qa{constructor(t,e,i){this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=Kn.empty(this.startState.doc.length);for(let t of i)this.changes=this.changes.compose(t.changes);let n=[];this.changes.iterChangedRanges((t,e,i,s)=>n.push(new Ba(t,e,i,s))),this.changedRanges=n}static create(t,e,i){return new qa(t,e,i)}get viewportChanged(){return(4&this.flags)>0}get viewportMoved(){return(8&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(18&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(t=>t.selection)}get empty(){return 0==this.flags&&0==this.transactions.length}}class Za extends tr{get length(){return this.view.state.doc.length}constructor(t){super(),this.view=t,this.decorations=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.editContextFormatting=Mr.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(t.contentDOM),this.children=[new Nr],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new Ba(0,0,0,t.state.doc.length)],0,null)}update(t){var e;let i=t.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:t,toA:e})=>e<this.minWidthFrom||t>this.minWidthTo)?(this.minWidthFrom=t.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=t.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(t);let n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&((null===(e=this.domChanged)||void 0===e?void 0:e.newSel)?n=this.domChanged.newSel.head:function(t,e){let i=!1;e&&t.iterChangedRanges((t,n)=>{t<e.to&&n>e.from&&(i=!0)});return i}(t.changes,this.hasComposition)||t.selectionSet||(n=t.state.selection.main.head));let s=n>-1?function(t,e,i){let n=Fa(t,i);if(!n)return null;let{node:s,from:o,to:r}=n,a=s.nodeValue;if(/[\n\r]/.test(a))return null;if(t.state.doc.sliceString(n.from,n.to)!=a)return null;let l=e.invertedDesc,c=new Ba(l.mapPos(o),l.mapPos(r),o,r),h=[];for(let e=s.parentNode;;e=e.parentNode){let i=tr.get(e);if(i instanceof yr)h.push({node:e,deco:i.mark});else{if(i instanceof Nr||"DIV"==e.nodeName&&e.parentNode==t.contentDOM)return{range:c,text:s,marks:h,line:e};if(e==t.contentDOM)return null;h.push({node:e,deco:new Qr({inclusive:!0,attributes:Pr(e),tagName:e.tagName.toLowerCase()})})}}}(this.view,t.changes,n):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:e,to:n}=this.hasComposition;i=new Ba(e,n,t.changes.mapPos(e,-1),t.changes.mapPos(n,1)).addToSet(i.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(gr.ie||gr.chrome)&&!s&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let o=function(t,e,i){let n=new Xa;return no.compare(t,e,i,n),n.changes}(this.decorations,this.updateDeco(),t.changes);return i=Ba.extendWithRanges(i,o),!!(7&this.flags||0!=i.length)&&(this.updateInner(i,t.startState.doc.length,s),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,e,i){this.view.viewState.mustMeasureContent=!0,this.updateChildren(t,e,i);let{observer:n}=this.view;n.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let t=gr.chrome||gr.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,t),this.flags&=-8,t&&(t.written||n.selectionRange.focusNode!=t.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(t=>t.flags&=-9);let s=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let t of this.children)t instanceof jr&&t.widget instanceof zr&&s.push(t.dom);n.updateGaps(s)}updateChildren(t,e,i){let n=i?i.range.addToSet(t.slice()):t,s=this.childCursor(e);for(let t=n.length-1;;t--){let e=t>=0?n[t]:null;if(!e)break;let o,r,a,l,{fromA:c,toA:h,fromB:u,toB:d}=e;if(i&&i.range.fromB<d&&i.range.toB>u){let t=Br.build(this.view.state.doc,u,i.range.fromB,this.decorations,this.dynamicDecorationMap),e=Br.build(this.view.state.doc,i.range.toB,d,this.decorations,this.dynamicDecorationMap);r=t.breakAtStart,a=t.openStart,l=e.openEnd;let n=this.compositionView(i);e.breakAtStart?n.breakAfter=1:e.content.length&&n.merge(n.length,n.length,e.content[0],!1,e.openStart,0)&&(n.breakAfter=e.content[0].breakAfter,e.content.shift()),t.content.length&&n.merge(0,0,t.content[t.content.length-1],!0,0,t.openEnd)&&t.content.pop(),o=t.content.concat(n).concat(e.content)}else({content:o,breakAtStart:r,openStart:a,openEnd:l}=Br.build(this.view.state.doc,u,d,this.decorations,this.dynamicDecorationMap));let{i:f,off:p}=s.findPos(h,1),{i:m,off:g}=s.findPos(c,-1);nr(this,m,g,f,p,o,r,a,l)}i&&this.fixCompositionDOM(i)}updateEditContextFormatting(t){this.editContextFormatting=this.editContextFormatting.map(t.changes);for(let e of t.transactions)for(let t of e.effects)t.is(Sa)&&(this.editContextFormatting=t.value)}compositionView(t){let e=new vr(t.text.nodeValue);e.flags|=8;for(let{deco:i}of t.marks)e=new yr(i,[e],e.length);let i=new Nr;return i.append(e,0),i}fixCompositionDOM(t){let e=(t,e)=>{e.flags|=8|(e.children.some(t=>7&t.flags)?1:0),this.markedForComposition.add(e);let i=tr.get(t);i&&i!=e&&(i.dom=null),e.setDOM(t)},i=this.childPos(t.range.fromB,1),n=this.children[i.i];e(t.line,n);for(let s=t.marks.length-1;s>=-1;s--)i=n.childPos(i.off,1),n=n.children[i.i],e(s>=0?t.marks[s].node:t.text,n)}updateSelection(t=!1,e=!1){!t&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let i=this.view.root.activeElement,n=i==this.dom,s=!n&&!(this.view.state.facet($a)||this.dom.tabIndex>-1)&&Mo(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(n||e||s))return;let o=this.forceSelection;this.forceSelection=!1;let r=this.view.state.selection.main,a=this.moveToLine(this.domAtPos(r.anchor)),l=r.empty?a:this.moveToLine(this.domAtPos(r.head));if(gr.gecko&&r.empty&&!this.hasComposition&&(1==(c=a).node.nodeType&&c.node.firstChild&&(0==c.offset||"false"==c.node.childNodes[c.offset-1].contentEditable)&&(c.offset==c.node.childNodes.length||"false"==c.node.childNodes[c.offset].contentEditable))){let t=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(t,a.node.childNodes[a.offset]||null)),a=l=new Ko(t,0),o=!0}var c;let h=this.view.observer.selectionRange;!o&&h.focusNode&&(Do(a.node,a.offset,h.anchorNode,h.anchorOffset)&&Do(l.node,l.offset,h.focusNode,h.focusOffset)||this.suppressWidgetCursorChange(h,r))||(this.view.observer.ignore(()=>{gr.android&&gr.chrome&&this.dom.contains(h.focusNode)&&function(t,e){for(let i=t;i&&i!=e;i=i.assignedSlot||i.parentNode)if(1==i.nodeType&&"false"==i.contentEditable)return!0;return!1}(h.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let t=Eo(this.view.root);if(t)if(r.empty){if(gr.gecko){let t=(e=a.node,n=a.offset,1!=e.nodeType?0:(n&&"false"==e.childNodes[n-1].contentEditable?1:0)|(n<e.childNodes.length&&"false"==e.childNodes[n].contentEditable?2:0));if(t&&3!=t){let e=(1==t?Uo:Go)(a.node,a.offset);e&&(a=new Ko(e.node,e.offset))}}t.collapse(a.node,a.offset),null!=r.bidiLevel&&void 0!==t.caretBidiLevel&&(t.caretBidiLevel=r.bidiLevel)}else if(t.extend){t.collapse(a.node,a.offset);try{t.extend(l.node,l.offset)}catch(t){}}else{let e=document.createRange();r.anchor>r.head&&([a,l]=[l,a]),e.setEnd(l.node,l.offset),e.setStart(a.node,a.offset),t.removeAllRanges(),t.addRange(e)}else;var e,n;s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(a,l)),this.impreciseAnchor=a.precise?null:new Ko(h.anchorNode,h.anchorOffset),this.impreciseHead=l.precise?null:new Ko(h.focusNode,h.focusOffset)}suppressWidgetCursorChange(t,e){return this.hasComposition&&e.empty&&Do(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)&&this.posFromDOM(t.focusNode,t.focusOffset)==e.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:t}=this,e=t.state.selection.main,i=Eo(t.root),{anchorNode:n,anchorOffset:s}=t.observer.selectionRange;if(!(i&&e.empty&&e.assoc&&i.modify))return;let o=Nr.find(this,e.head);if(!o)return;let r=o.posAtStart;if(e.head==r||e.head==r+o.length)return;let a=this.coordsAt(e.head,-1),l=this.coordsAt(e.head,1);if(!a||!l||a.bottom>l.top)return;let c=this.domAtPos(e.head+e.assoc);i.collapse(c.node,c.offset),i.modify("move",e.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let h=t.observer.selectionRange;t.docView.posFromDOM(h.anchorNode,h.anchorOffset)!=e.from&&i.collapse(n,s)}moveToLine(t){let e,i=this.dom;if(t.node!=i)return t;for(let n=t.offset;!e&&n<i.childNodes.length;n++){let t=tr.get(i.childNodes[n]);t instanceof Nr&&(e=t.domAtPos(0))}for(let n=t.offset-1;!e&&n>=0;n--){let t=tr.get(i.childNodes[n]);t instanceof Nr&&(e=t.domAtPos(t.length))}return e?new Ko(e.node,e.offset,!0):t}nearest(t){for(let e=t;e;){let t=tr.get(e);if(t&&t.rootView==this)return t;e=e.parentNode}return null}posFromDOM(t,e){let i=this.nearest(t);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(t,e)+i.posAtStart}domAtPos(t){let{i:e,off:i}=this.childCursor().findPos(t,-1);for(;e<this.children.length-1;){let t=this.children[e];if(i<t.length||t instanceof Nr)break;e++,i=0}return this.children[e].domAtPos(i)}coordsAt(t,e){let i=null,n=0;for(let s=this.length,o=this.children.length-1;o>=0;o--){let r=this.children[o],a=s-r.breakAfter,l=a-r.length;if(a<t)break;if(l<=t&&(l<t||r.covers(-1))&&(a>t||r.covers(1))&&(!i||r instanceof Nr&&!(i instanceof Nr&&e>=0)))i=r,n=l;else if(i&&l==t&&a==t&&r instanceof jr&&Math.abs(e)<2){if(r.deco.startSide<0)break;o&&(i=null)}s=l}return i?i.coordsAt(t-n,e):null}coordsForChar(t){let{i:e,off:i}=this.childPos(t,1),n=this.children[e];if(!(n instanceof Nr))return null;for(;n.children.length;){let{i:t,off:e}=n.childPos(i,1);for(;;t++){if(t==n.children.length)return null;if((n=n.children[t]).length)break}i=e}if(!(n instanceof vr))return null;let s=Xn(n.text,i);if(s==i)return null;let o=Ho(n.dom,i,s).getClientRects();for(let t=0;t<o.length;t++){let e=o[t];if(t==o.length-1||e.top<e.bottom&&e.left<e.right)return e}return null}measureVisibleLineHeights(t){let e=[],{from:i,to:n}=t,s=this.view.contentDOM.clientWidth,o=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,r=-1,a=this.view.textDirection==Fr.LTR;for(let t=0,l=0;l<this.children.length;l++){let c=this.children[l],h=t+c.length;if(h>n)break;if(t>=i){let i=c.dom.getBoundingClientRect();if(e.push(i.height),o){let e=c.dom.lastChild,n=e?Qo(e):[];if(n.length){let e=n[n.length-1],o=a?e.right-i.left:i.right-e.left;o>r&&(r=o,this.minWidth=s,this.minWidthFrom=t,this.minWidthTo=h)}}}t=h+c.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return"rtl"==getComputedStyle(this.children[e].dom).direction?Fr.RTL:Fr.LTR}measureTextSize(){for(let t of this.children)if(t instanceof Nr){let e=t.measureTextSize();if(e)return e}let t,e,i,n=document.createElement("div");return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(n);let s=Qo(n.firstChild)[0];t=n.getBoundingClientRect().height,e=s?s.width/27:7,i=s?s.height:t,n.remove()}),{lineHeight:t,charWidth:e,textHeight:i}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new ir(this.children,t,e)}computeBlockGapDeco(){let t=[],e=this.view.viewState;for(let i=0,n=0;;n++){let s=n==e.viewports.length?null:e.viewports[n],o=s?s.from-1:this.length;if(o>i){let n=(e.lineBlockAt(o).bottom-e.lineBlockAt(i).top)/this.view.scaleY;t.push(Mr.replace({widget:new zr(n),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!s)break;i=s.to+1}return Mr.set(t)}updateDeco(){let t=1,e=this.view.state.facet(Qa).map(e=>(this.dynamicDecorationMap[t++]="function"==typeof e)?e(this.view):e),i=!1,n=this.view.state.facet(Da).map((t,e)=>{let n="function"==typeof t;return n&&(i=!0),n?t(this.view):t});for(n.length&&(this.dynamicDecorationMap[t++]=i,e.push(no.join(n))),this.decorations=[this.editContextFormatting,...e,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];t<this.decorations.length;)this.dynamicDecorationMap[t++]=!1;return this.decorations}scrollIntoView(t){if(t.isSnapshot){let e=this.view.viewState.lineBlockAt(t.range.head);return this.view.scrollDOM.scrollTop=e.top-t.yMargin,void(this.view.scrollDOM.scrollLeft=t.xMargin)}for(let e of this.view.state.facet(xa))try{if(e(this.view,t.range,t))return!0}catch(t){ka(this.view.state,t,"scroll handler")}let e,{range:i}=t,n=this.coordsAt(i.head,i.empty?i.assoc:i.head>i.anchor?-1:1);if(!n)return;!i.empty&&(e=this.coordsAt(i.anchor,i.anchor>i.head?-1:1))&&(n={left:Math.min(n.left,e.left),top:Math.min(n.top,e.top),right:Math.max(n.right,e.right),bottom:Math.max(n.bottom,e.bottom)});let s=ja(this.view),o={left:n.left-s.left,top:n.top-s.top,right:n.right+s.right,bottom:n.bottom+s.bottom},{offsetWidth:r,offsetHeight:a}=this.view.scrollDOM;!function(t,e,i,n,s,o,r,a){let l=t.ownerDocument,c=l.defaultView||window;for(let h=t,u=!1;h&&!u;)if(1==h.nodeType){let t,d=h==l.body,f=1,p=1;if(d)t=zo(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(h).position)&&(u=!0),h.scrollHeight<=h.clientHeight&&h.scrollWidth<=h.clientWidth){h=h.assignedSlot||h.parentNode;continue}let e=h.getBoundingClientRect();({scaleX:f,scaleY:p}=Bo(h,e)),t={left:e.left,right:e.left+h.clientWidth*f,top:e.top,bottom:e.top+h.clientHeight*p}}let m=0,g=0;if("nearest"==s)e.top<t.top?(g=e.top-(t.top+r),i>0&&e.bottom>t.bottom+g&&(g=e.bottom-t.bottom+r)):e.bottom>t.bottom&&(g=e.bottom-t.bottom+r,i<0&&e.top-g<t.top&&(g=e.top-(t.top+r)));else{let n=e.bottom-e.top,o=t.bottom-t.top;g=("center"==s&&n<=o?e.top+n/2-o/2:"start"==s||"center"==s&&i<0?e.top-r:e.bottom-o+r)-t.top}if("nearest"==n?e.left<t.left?(m=e.left-(t.left+o),i>0&&e.right>t.right+m&&(m=e.right-t.right+o)):e.right>t.right&&(m=e.right-t.right+o,i<0&&e.left<t.left+m&&(m=e.left-(t.left+o))):m=("center"==n?e.left+(e.right-e.left)/2-(t.right-t.left)/2:"start"==n==a?e.left-o:e.right-(t.right-t.left)+o)-t.left,m||g)if(d)c.scrollBy(m,g);else{let t=0,i=0;if(g){let t=h.scrollTop;h.scrollTop+=g/p,i=(h.scrollTop-t)*p}if(m){let e=h.scrollLeft;h.scrollLeft+=m/f,t=(h.scrollLeft-e)*f}e={left:e.left-t,top:e.top-i,right:e.right-t,bottom:e.bottom-i},t&&Math.abs(t-m)<1&&(n="nearest"),i&&Math.abs(i-g)<1&&(s="nearest")}if(d)break;(e.top<t.top||e.bottom>t.bottom||e.left<t.left||e.right>t.right)&&(e={left:Math.max(e.left,t.left),right:Math.min(e.right,t.right),top:Math.max(e.top,t.top),bottom:Math.min(e.bottom,t.bottom)}),h=h.assignedSlot||h.parentNode}else{if(11!=h.nodeType)break;h=h.host}}(this.view.scrollDOM,o,i.head<i.anchor?-1:1,t.x,t.y,Math.max(Math.min(t.xMargin,r),-r),Math.max(Math.min(t.yMargin,a),-a),this.view.textDirection==Fr.LTR)}}function Fa(t,e){let i=t.observer.selectionRange;if(!i.focusNode)return null;let n=Uo(i.focusNode,i.focusOffset),s=Go(i.focusNode,i.focusOffset),o=n||s;if(s&&n&&s.node!=n.node){let e=tr.get(s.node);if(!e||e instanceof vr&&e.text!=s.node.nodeValue)o=s;else if(t.docView.lastCompositionAfterCursor){let t=tr.get(n.node);!t||t instanceof vr&&t.text!=n.node.nodeValue||(o=s)}}if(t.docView.lastCompositionAfterCursor=o!=n,!o)return null;let r=e-o.offset;return{from:r,to:r+o.node.nodeValue.length,node:o.node}}let Xa=class{constructor(){this.changes=[]}compareRange(t,e){Lr(t,e,this.changes)}comparePoint(t,e){Lr(t,e,this.changes)}boundChange(t){Lr(t,t,this.changes)}};function Ha(t,e){return e.left>t?e.left-t:Math.max(0,t-e.right)}function Wa(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function Va(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function Ya(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function Ua(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function Ga(t,e,i){let n,s,o,r,a,l,c,h,u=!1;for(let d=t.firstChild;d;d=d.nextSibling){let t=Qo(d);for(let f=0;f<t.length;f++){let p=t[f];s&&Va(s,p)&&(p=Ya(Ua(p,s.bottom),s.top));let m=Ha(e,p),g=Wa(i,p);if(0==m&&0==g)return 3==d.nodeType?Ka(d,e,i):Ga(d,e,i);(!n||r>g||r==g&&o>m)&&(n=d,s=p,o=m,r=g,u=!m||(e<p.left?f>0:f<t.length-1)),0==m?i>p.bottom&&(!c||c.bottom<p.bottom)?(a=d,c=p):i<p.top&&(!h||h.top>p.top)&&(l=d,h=p):c&&Va(c,p)?c=Ua(c,p.bottom):h&&Va(h,p)&&(h=Ya(h,p.top))}}if(c&&c.bottom>=i?(n=a,s=c):h&&h.top<=i&&(n=l,s=h),!n)return{node:t,offset:0};let d=Math.max(s.left,Math.min(s.right,e));return 3==n.nodeType?Ka(n,d,i):u&&"false"!=n.contentEditable?Ga(n,d,i):{node:t,offset:Array.prototype.indexOf.call(t.childNodes,n)+(e>=(s.left+s.right)/2?1:0)}}function Ka(t,e,i){let n=t.nodeValue.length,s=-1,o=1e9,r=0;for(let a=0;a<n;a++){let n=Ho(t,a,a+1).getClientRects();for(let l=0;l<n.length;l++){let c=n[l];if(c.top==c.bottom)continue;r||(r=e-c.left);let h=(c.top>i?c.top-i:i-c.bottom)-1;if(c.left-1<=e&&c.right+1>=e&&h<o){let i=e>=(c.left+c.right)/2,n=i;if(gr.chrome||gr.gecko){Ho(t,a).getBoundingClientRect().left==c.right&&(n=!i)}if(h<=0)return{node:t,offset:a+(n?1:0)};s=a+(n?1:0),o=h}}}return{node:t,offset:s>-1?s:r>0?t.nodeValue.length:0}}function Ja(t,e,i,n=-1){var s,o;let r,a=t.contentDOM.getBoundingClientRect(),l=a.top+t.viewState.paddingTop,{docHeight:c}=t.viewState,{x:h,y:u}=e,d=u-l;if(d<0)return 0;if(d>c)return t.state.doc.length;for(let e=t.viewState.heightOracle.textHeight/2,s=!1;r=t.elementAtHeight(d),r.type!=Ar.Text;)for(;d=n>0?r.bottom+e:r.top-e,!(d>=0&&d<=c);){if(s)return i?null:0;s=!0,n=-n}u=l+d;let f=r.from;if(f<t.viewport.from)return 0==t.viewport.from?0:i?null:tl(t,a,r,h,u);if(f>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:i?null:tl(t,a,r,h,u);let p=t.dom.ownerDocument,m=t.root.elementFromPoint?t.root:p,g=m.elementFromPoint(h,u);g&&!t.contentDOM.contains(g)&&(g=null),g||(h=Math.max(a.left+1,Math.min(a.right-1,h)),g=m.elementFromPoint(h,u),g&&!t.contentDOM.contains(g)&&(g=null));let v,y=-1;if(g&&0!=(null===(s=t.docView.nearest(g))||void 0===s?void 0:s.isEditable)){if(p.caretPositionFromPoint){let t=p.caretPositionFromPoint(h,u);t&&({offsetNode:v,offset:y}=t)}else if(p.caretRangeFromPoint){let e=p.caretRangeFromPoint(h,u);e&&(({startContainer:v,startOffset:y}=e),(!t.contentDOM.contains(v)||gr.safari&&function(t,e,i){let n,s=t;if(3!=t.nodeType||e!=(n=t.nodeValue.length))return!1;for(;;){let t=s.nextSibling;if(t){if("BR"==t.nodeName)break;return!1}{let t=s.parentNode;if(!t||"DIV"==t.nodeName)break;s=t}}return Ho(t,n-1,n).getBoundingClientRect().right>i}(v,y,h)||gr.chrome&&function(t,e,i){if(0!=e)return!1;for(let e=t;;){let t=e.parentNode;if(!t||1!=t.nodeType||t.firstChild!=e)return!1;if(t.classList.contains("cm-line"))break;e=t}let n=1==t.nodeType?t.getBoundingClientRect():Ho(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect();return i-n.left>5}(v,y,h))&&(v=void 0))}v&&(y=Math.min(No(v),y))}if(!v||!t.docView.dom.contains(v)){let e=Nr.find(t.docView,f);if(!e)return d>r.top+r.height/2?r.to:r.from;({node:v,offset:y}=Ga(e.dom,h,u))}let O=t.docView.nearest(v);if(!O)return null;if(O.isWidget&&1==(null===(o=O.dom)||void 0===o?void 0:o.nodeType)){let t=O.dom.getBoundingClientRect();return e.y<t.top||e.y<=t.bottom&&e.x<=(t.left+t.right)/2?O.posAtStart:O.posAtEnd}return O.localPosFromDOM(v,y)+O.posAtStart}function tl(t,e,i,n,s){let o=Math.round((n-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&i.height>1.5*t.defaultLineHeight){let e=t.viewState.heightOracle.textHeight;o+=Math.floor((s-i.top-.5*(t.defaultLineHeight-e))/e)*t.viewState.heightOracle.lineLength}let r=t.state.sliceDoc(i.from,i.to);return i.from+vo(r,o,t.state.tabSize)}function el(t,e,i){let n=t.lineBlockAt(e);if(Array.isArray(n.type)){let t;for(let s of n.type){if(s.from>e)break;if(!(s.to<e)){if(s.from<e&&s.to>e)return s;t&&(s.type!=Ar.Text||t.type==s.type&&!(i<0?s.from<e:s.to>e))||(t=s)}}return t||n}return n}function il(t,e,i,n){let s=t.state.doc.lineAt(e.head),o=t.bidiSpans(s),r=t.textDirectionAt(s.from);for(let a=e,l=null;;){let e=la(s,o,r,a,i),c=aa;if(!e){if(s.number==(i?t.state.doc.lines:1))return a;c="\n",s=t.state.doc.line(s.number+(i?1:-1)),o=t.bidiSpans(s),e=t.visualLineSide(s,!i)}if(l){if(!l(c))return a}else{if(!n)return e;l=n(c)}a=e}}function nl(t,e,i){for(;;){let n=0;for(let s of t)s.between(e-1,e+1,(t,s,o)=>{if(e>t&&e<s){let o=n||i||(e-t<s-e?-1:1);e=o<0?t:s,n=o}});if(!n)return e}}function sl(t,e,i){let n=nl(t.state.facet(Ra).map(e=>e(t)),i.from,e.head>i.from?-1:1);return n==i.from?i:rs.cursor(n,n<i.from?1:-1)}const ol="￿";class rl{constructor(t,e){this.points=t,this.text="",this.lineSeparator=e.facet(Gs.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=ol}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let n=t;;){this.findPointBefore(i,n);let t=this.text.length;this.readNode(n);let s=n.nextSibling;if(s==e)break;let o=tr.get(n),r=tr.get(s);(o&&r?o.breakAfter:(o?o.breakAfter:Io(n))||Io(s)&&("BR"!=n.nodeName||n.cmIgnore)&&this.text.length>t)&&this.lineBreak(),n=s}return this.findPointBefore(i,e),this}readTextNode(t){let e=t.nodeValue;for(let i of this.points)i.node==t&&(i.pos=this.text.length+Math.min(i.offset,e.length));for(let i=0,n=this.lineSeparator?null:/\r\n?|\n/g;;){let s,o=-1,r=1;if(this.lineSeparator?(o=e.indexOf(this.lineSeparator,i),r=this.lineSeparator.length):(s=n.exec(e))&&(o=s.index,r=s[0].length),this.append(e.slice(i,o<0?e.length:o)),o<0)break;if(this.lineBreak(),r>1)for(let e of this.points)e.node==t&&e.pos>this.text.length&&(e.pos-=r-1);i=o+r}}readNode(t){if(t.cmIgnore)return;let e=tr.get(t),i=e&&e.overrideDOMText;if(null!=i){this.findPointInside(t,i.length);for(let t=i.iter();!t.next().done;)t.lineBreak?this.lineBreak():this.append(t.value)}else 3==t.nodeType?this.readTextNode(t):"BR"==t.nodeName?t.nextSibling&&this.lineBreak():1==t.nodeType&&this.readRange(t.firstChild,null)}findPointBefore(t,e){for(let i of this.points)i.node==t&&t.childNodes[i.offset]==e&&(i.pos=this.text.length)}findPointInside(t,e){for(let i of this.points)(3==t.nodeType?i.node==t:t.contains(i.node))&&(i.pos=this.text.length+(al(t,i.node,i.offset)?e:0))}}function al(t,e,i){for(;;){if(!e||i<No(e))return!1;if(e==t)return!0;i=Ro(e)+1,e=e.parentNode}}class ll{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class cl{constructor(t,e,i,n){this.typeOver=n,this.bounds=null,this.text="",this.domChanged=e>-1;let{impreciseHead:s,impreciseAnchor:o}=t.docView;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=t.docView.domBoundsAround(e,i,0))){let e=s||o?[]:function(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:i,anchorOffset:n,focusNode:s,focusOffset:o}=t.observer.selectionRange;i&&(e.push(new ll(i,n)),s==i&&o==n||e.push(new ll(s,o)));return e}(t),i=new rl(e,t.state);i.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=i.text,this.newSel=function(t,e){if(0==t.length)return null;let i=t[0].pos,n=2==t.length?t[1].pos:i;return i>-1&&n>-1?rs.single(i+e,n+e):null}(e,this.bounds.from)}else{let e=t.observer.selectionRange,i=s&&s.node==e.focusNode&&s.offset==e.focusOffset||!Ao(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),n=o&&o.node==e.anchorNode&&o.offset==e.anchorOffset||!Ao(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset),r=t.viewport;if((gr.ios||gr.chrome)&&t.state.selection.main.empty&&i!=n&&(r.from>0||r.to<t.state.doc.length)){let e=Math.min(i,n),s=Math.max(i,n),o=r.from-e,a=r.to-s;0!=o&&1!=o&&0!=e||0!=a&&-1!=a&&s!=t.state.doc.length||(i=0,n=t.state.doc.length)}this.newSel=rs.single(n,i)}}}function hl(t,e){let i,{newSel:n}=e,s=t.state.selection.main,o=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:n,to:r}=e.bounds,a=s.from,l=null;(8===o||gr.android&&e.text.length<r-n)&&(a=s.to,l="end");let c=function(t,e,i,n){let s=Math.min(t.length,e.length),o=0;for(;o<s&&t.charCodeAt(o)==e.charCodeAt(o);)o++;if(o==s&&t.length==e.length)return null;let r=t.length,a=e.length;for(;r>0&&a>0&&t.charCodeAt(r-1)==e.charCodeAt(a-1);)r--,a--;if("end"==n){i-=r+Math.max(0,o-Math.min(r,a))-o}if(r<o&&t.length<e.length){o-=i<=o&&i>=r?o-i:0,a=o+(a-r),r=o}else if(a<o){o-=i<=o&&i>=a?o-i:0,r=o+(r-a),a=o}return{from:o,toA:r,toB:a}}(t.state.doc.sliceString(n,r,ol),e.text,a-n,l);c&&(gr.chrome&&13==o&&c.toB==c.from+2&&e.text.slice(c.from,c.toB)==ol+ol&&c.toB--,i={from:n+c.from,to:n+c.toA,insert:Rn.of(e.text.slice(c.from,c.toB).split(ol))})}else n&&(!t.hasFocus&&t.state.facet($a)||n.main.eq(s))&&(n=null);if(!i&&!n)return!1;if(!i&&e.typeOver&&!s.empty&&n&&n.main.empty?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,s.to)}:(gr.mac||gr.android)&&i&&i.from==i.to&&i.from==s.head-1&&/^\. ?$/.test(i.insert.toString())&&"off"==t.contentDOM.getAttribute("autocorrect")?(n&&2==i.insert.length&&(n=rs.single(n.main.anchor-1,n.main.head-1)),i={from:i.from,to:i.to,insert:Rn.of([i.insert.toString().replace("."," ")])}):i&&i.from>=s.from&&i.to<=s.to&&(i.from!=s.from||i.to!=s.to)&&s.to-s.from-(i.to-i.from)<=4?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,i.from).append(i.insert).append(t.state.doc.slice(i.to,s.to))}:gr.chrome&&i&&i.from==i.to&&i.from==s.head&&"\n "==i.insert.toString()&&t.lineWrapping&&(n&&(n=rs.single(n.main.anchor-1,n.main.head-1)),i={from:s.from,to:s.to,insert:Rn.of([" "])}),i)return ul(t,i,n,o);if(n&&!n.main.eq(s)){let e=!1,i="select";return t.inputState.lastSelectionTime>Date.now()-50&&("select"==t.inputState.lastSelectionOrigin&&(e=!0),i=t.inputState.lastSelectionOrigin),t.dispatch({selection:n,scrollIntoView:e,userEvent:i}),!0}return!1}function ul(t,e,i,n=-1){if(gr.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(gr.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&" "==t.state.sliceDoc(e.from,s.from))&&1==e.insert.length&&2==e.insert.lines&&Wo(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&0==e.insert.length||8==n&&e.insert.length<e.to-e.from&&e.to>s.head)&&Wo(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&0==e.insert.length&&Wo(t.contentDOM,"Delete",46)))return!0;let o,r=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let a=()=>o||(o=function(t,e,i){let n,s=t.state,o=s.selection.main;if(e.from>=o.from&&e.to<=o.to&&e.to-e.from>=(o.to-o.from)/3&&(!i||i.main.empty&&i.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let i=o.from<e.from?s.sliceDoc(o.from,e.from):"",r=o.to>e.to?s.sliceDoc(e.to,o.to):"";n=s.replaceSelection(t.state.toText(i+e.insert.sliceString(0,void 0,t.state.lineBreak)+r))}else{let r=s.changes(e),a=i&&i.main.to<=r.newLength?i.main:void 0;if(s.selection.ranges.length>1&&t.inputState.composing>=0&&e.to<=o.to&&e.to>=o.to-10){let l,c=t.state.sliceDoc(e.from,e.to),h=i&&Fa(t,i.main.head);if(h){let t=e.insert.length-(e.to-e.from);l={from:h.from,to:h.to-t}}else l=t.state.doc.lineAt(o.head);let u=o.to-e.to,d=o.to-o.from;n=s.changeByRange(i=>{if(i.from==o.from&&i.to==o.to)return{changes:r,range:a||i.map(r)};let n=i.to-u,h=n-c.length;if(i.to-i.from!=d||t.state.sliceDoc(h,n)!=c||i.to>=l.from&&i.from<=l.to)return{range:i};let f=s.changes({from:h,to:n,insert:e.insert}),p=i.to-o.to;return{changes:f,range:a?rs.range(Math.max(0,a.anchor+p),Math.max(0,a.head+p)):i.map(f)}})}else n={changes:r,selection:a&&s.selection.replaceRange(a)}}let r="input.type";(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,r+=".compose",t.inputState.compositionFirstChange&&(r+=".start",t.inputState.compositionFirstChange=!1));return s.update(n,{userEvent:r,scrollIntoView:!0})}(t,e,i));return t.state.facet(ma).some(i=>i(t,e.from,e.to,r,a))||t.dispatch(a()),!0}class dl{setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}constructor(t){this.view=t,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=t.hasFocus,gr.safari&&t.contentDOM.addEventListener("input",()=>null),gr.gecko&&function(t){jl.has(t)||(jl.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}(t.contentDOM.ownerDocument)}handleEvent(t){(function(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let i,n=e.target;n!=t.contentDOM;n=n.parentNode)if(!n||11==n.nodeType||(i=tr.get(n))&&i.ignoreEvent(e))return!1;return!0})(this.view,t)&&!this.ignoreDuringComposition(t)&&("keydown"==t.type&&this.keydown(t)||(0!=this.view.updateState?Promise.resolve().then(()=>this.runHandlers(t.type,t)):this.runHandlers(t.type,t)))}runHandlers(t,e){let i=this.handlers[t];if(i){for(let t of i.observers)t(this.view,e);for(let t of i.handlers){if(e.defaultPrevented)break;if(t(this.view,e)){e.preventDefault();break}}}}ensureHandlers(t){let e=pl(t),i=this.handlers,n=this.view.contentDOM;for(let t in e)if("scroll"!=t){let s=!e[t].handlers.length,o=i[t];o&&s!=!o.handlers.length&&(n.removeEventListener(t,this.handleEvent),o=null),o||n.addEventListener(t,this.handleEvent,{passive:s})}for(let t in i)"scroll"==t||e[t]||n.removeEventListener(t,this.handleEvent);this.handlers=e}keydown(t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),9==t.keyCode&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&27!=t.keyCode&&vl.indexOf(t.keyCode)<0&&(this.tabFocusMode=-1),gr.android&&gr.chrome&&!t.synthetic&&(13==t.keyCode||8==t.keyCode))return this.view.observer.delayAndroidKey(t.key,t.keyCode),!0;let e;return!gr.ios||t.synthetic||t.altKey||t.metaKey||!((e=ml.find(e=>e.keyCode==t.keyCode))&&!t.ctrlKey||gl.indexOf(t.key)>-1&&t.ctrlKey&&!t.shiftKey)?(229!=t.keyCode&&this.view.observer.forceFlush(),!1):(this.pendingIOSKey=e||t,setTimeout(()=>this.flushIOSKey(),250),!0)}flushIOSKey(t){let e=this.pendingIOSKey;return!!e&&(!("Enter"==e.key&&t&&t.from<t.to&&/^\S+$/.test(t.insert.toString()))&&(this.pendingIOSKey=void 0,Wo(this.view.contentDOM,e.key,e.keyCode,e instanceof KeyboardEvent?e:void 0)))}ignoreDuringComposition(t){return!!/^key/.test(t.type)&&(this.composing>0||!!(gr.safari&&!gr.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.view.observer.update(t),this.mouseSelection&&this.mouseSelection.update(t),this.draggedContent&&t.docChanged&&(this.draggedContent=this.draggedContent.map(t.changes)),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function fl(t,e){return(i,n)=>{try{return e.call(t,n,i)}catch(t){ka(i.state,t)}}}function pl(t){let e=Object.create(null);function i(t){return e[t]||(e[t]={observers:[],handlers:[]})}for(let e of t){let t=e.spec,n=t&&t.plugin.domEventHandlers,s=t&&t.plugin.domEventObservers;if(n)for(let t in n){let s=n[t];s&&i(t).handlers.push(fl(e.value,s))}if(s)for(let t in s){let n=s[t];n&&i(t).observers.push(fl(e.value,n))}}for(let t in bl)i(t).handlers.push(bl[t]);for(let t in xl)i(t).observers.push(xl[t]);return e}const ml=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],gl="dthko",vl=[16,17,18,20,91,92,224,225];function yl(t){return.7*Math.max(0,t)+8}class Ol{constructor(t,e,i,n){this.view=t,this.startEvent=e,this.style=i,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParents=function(t){let e,i,n=t.ownerDocument;for(let s=t.parentNode;s&&!(s==n.body||e&&i);)if(1==s.nodeType)!i&&s.scrollHeight>s.clientHeight&&(i=s),!e&&s.scrollWidth>s.clientWidth&&(e=s),s=s.assignedSlot||s.parentNode;else{if(11!=s.nodeType)break;s=s.host}return{x:e,y:i}}(t.contentDOM),this.atoms=t.state.facet(Ra).map(e=>e(t));let s=t.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet(Gs.allowMultipleSelections)&&function(t,e){let i=t.state.facet(ha);return i.length?i[0](e):gr.mac?e.metaKey:e.ctrlKey}(t,e),this.dragging=!(!function(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let n=Eo(t.root);if(!n||0==n.rangeCount)return!0;let s=n.getRangeAt(0).getClientRects();for(let t=0;t<s.length;t++){let i=s[t];if(i.left<=e.clientX&&i.right>=e.clientX&&i.top<=e.clientY&&i.bottom>=e.clientY)return!0}return!1}(t,e)||1!=Ql(e))&&null}start(t){!1===this.dragging&&this.select(t)}move(t){if(0==t.buttons)return this.destroy();if(this.dragging||null==this.dragging&&(e=this.startEvent,i=t,Math.max(Math.abs(e.clientX-i.clientX),Math.abs(e.clientY-i.clientY))<10))return;var e,i;this.select(this.lastEvent=t);let n=0,s=0,o=0,r=0,a=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:o,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:r,bottom:l}=this.scrollParents.y.getBoundingClientRect());let c=ja(this.view);t.clientX-c.left<=o+6?n=-yl(o-t.clientX):t.clientX+c.right>=a-6&&(n=yl(t.clientX-a)),t.clientY-c.top<=r+6?s=-yl(r-t.clientY):t.clientY+c.bottom>=l-6&&(s=yl(t.clientY-l)),this.setScrollSpeed(n,s)}up(t){null==this.dragging&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(t,e){this.scrollSpeed={x:t,y:e},t||e?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:t,y:e}=this.scrollSpeed;t&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=t,t=0),e&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=e,e=0),(t||e)&&this.view.win.scrollBy(t,e),!1===this.dragging&&this.select(this.lastEvent)}skipAtoms(t){let e=null;for(let i=0;i<t.ranges.length;i++){let n=t.ranges[i],s=null;if(n.empty){let t=nl(this.atoms,n.from,0);t!=n.from&&(s=rs.cursor(t,-1))}else{let t=nl(this.atoms,n.from,-1),e=nl(this.atoms,n.to,1);t==n.from&&e==n.to||(s=rs.range(n.from==n.anchor?t:e,n.from==n.head?t:e))}s&&(e||(e=t.ranges.slice()),e[i]=s)}return e?rs.create(e,t.mainIndex):t}select(t){let{view:e}=this,i=this.skipAtoms(this.style.get(t,this.extend,this.multiple));!this.mustSelect&&i.eq(e.state.selection,!1===this.dragging)||this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(t){t.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(t)&&setTimeout(()=>this.select(this.lastEvent),20)}}const bl=Object.create(null),xl=Object.create(null),wl=gr.ie&&gr.ie_version<15||gr.ios&&gr.webkit_version<604;function _l(t,e,i){for(let n of t.facet(e))i=n(i,t);return i}function Sl(t,e){e=_l(t.state,va,e);let i,{state:n}=t,s=1,o=n.toText(e),r=o.lines==n.selection.ranges.length;if(null!=Rl&&n.selection.ranges.every(t=>t.empty)&&Rl==o.toString()){let t=-1;i=n.changeByRange(i=>{let a=n.doc.lineAt(i.from);if(a.from==t)return{range:i};t=a.from;let l=n.toText((r?o.line(s++).text:e)+n.lineBreak);return{changes:{from:a.from,insert:l},range:rs.cursor(i.from+l.length)}})}else i=r?n.changeByRange(t=>{let e=o.line(s++);return{changes:{from:t.from,to:t.to,insert:e.text},range:rs.cursor(t.from+e.length)}}):n.replaceSelection(o);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}function kl(t,e,i,n){if(1==n)return rs.cursor(e,i);if(2==n)return function(t,e,i=1){let n=t.charCategorizer(e),s=t.doc.lineAt(e),o=e-s.from;if(0==s.length)return rs.cursor(e);0==o?i=1:o==s.length&&(i=-1);let r=o,a=o;i<0?r=Xn(s.text,o,!1):a=Xn(s.text,o);let l=n(s.text.slice(r,a));for(;r>0;){let t=Xn(s.text,r,!1);if(n(s.text.slice(t,r))!=l)break;r=t}for(;a<s.length;){let t=Xn(s.text,a);if(n(s.text.slice(a,t))!=l)break;a=t}return rs.range(r+s.from,a+s.from)}(t.state,e,i);{let i=Nr.find(t.docView,e),n=t.state.doc.lineAt(i?i.posAtEnd:e),s=i?i.posAtStart:n.from,o=i?i.posAtEnd:n.to;return o<t.state.doc.length&&o==n.to&&o++,rs.range(s,o)}}xl.scroll=t=>{t.inputState.lastScrollTop=t.scrollDOM.scrollTop,t.inputState.lastScrollLeft=t.scrollDOM.scrollLeft},bl.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),27==e.keyCode&&0!=t.inputState.tabFocusMode&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),xl.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},xl.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},bl.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let i=null;for(let n of t.state.facet(da))if(i=n(t,e),i)break;if(i||0!=e.button||(i=function(t,e){let i=Tl(t,e),n=Ql(e),s=t.state.selection;return{update(t){t.docChanged&&(i.pos=t.changes.mapPos(i.pos),s=s.map(t.changes))},get(e,o,r){let a,l=Tl(t,e),c=kl(t,l.pos,l.bias,n);if(i.pos!=l.pos&&!o){let e=kl(t,i.pos,i.bias,n),s=Math.min(e.from,c.from),o=Math.max(e.to,c.to);c=s<c.from?rs.range(s,o):rs.range(o,s)}return o?s.replaceRange(s.main.extend(c.from,c.to)):r&&1==n&&s.ranges.length>1&&(a=function(t,e){for(let i=0;i<t.ranges.length;i++){let{from:n,to:s}=t.ranges[i];if(n<=e&&s>=e)return rs.create(t.ranges.slice(0,i).concat(t.ranges.slice(i+1)),t.mainIndex==i?0:t.mainIndex-(t.mainIndex>i?1:0))}return null}(s,l.pos))?a:r?s.addRange(c):rs.create([c])}}}(t,e)),i){let n=!t.hasFocus;t.inputState.startMouseSelection(new Ol(t,e,i,n)),n&&t.observer.ignore(()=>{Xo(t.contentDOM);let e=t.root.activeElement;e&&!e.contains(t.contentDOM)&&e.blur()});let s=t.inputState.mouseSelection;if(s)return s.start(e),!1===s.dragging}return!1};let $l=(t,e,i)=>e>=i.top&&e<=i.bottom&&t>=i.left&&t<=i.right;function Cl(t,e,i,n){let s=Nr.find(t.docView,e);if(!s)return 1;let o=e-s.posAtStart;if(0==o)return 1;if(o==s.length)return-1;let r=s.coordsAt(o,-1);if(r&&$l(i,n,r))return-1;let a=s.coordsAt(o,1);return a&&$l(i,n,a)?1:r&&r.bottom>=n?-1:1}function Tl(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:i,bias:Cl(t,i,e.clientX,e.clientY)}}const Pl=gr.ie&&gr.ie_version<=11;let El=null,Al=0,Ml=0;function Ql(t){if(!Pl)return t.detail;let e=El,i=Ml;return El=t,Ml=Date.now(),Al=!e||i>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Al+1)%3:1}function Dl(t,e,i,n){if(!(i=_l(t.state,va,i)))return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:o}=t.inputState,r=n&&o&&function(t,e){let i=t.state.facet(ua);return i.length?i[0](e):gr.mac?!e.altKey:!e.ctrlKey}(t,e)?{from:o.from,to:o.to}:null,a={from:s,insert:i},l=t.state.changes(r?[r,a]:a);t.focus(),t.dispatch({changes:l,selection:{anchor:l.mapPos(s,-1),head:l.mapPos(s,1)},userEvent:r?"move.drop":"input.drop"}),t.inputState.draggedContent=null}bl.dragstart=(t,e)=>{let{selection:{main:i}}=t.state;if(e.target.draggable){let n=t.docView.nearest(e.target);if(n&&n.isWidget){let t=n.posAtStart,e=t+n.length;(t>=i.to||e<=i.from)&&(i=rs.range(t,e))}}let{inputState:n}=t;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=i,e.dataTransfer&&(e.dataTransfer.setData("Text",_l(t.state,ya,t.state.sliceDoc(i.from,i.to))),e.dataTransfer.effectAllowed="copyMove"),!1},bl.dragend=t=>(t.inputState.draggedContent=null,!1),bl.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let i=e.dataTransfer.files;if(i&&i.length){let n=Array(i.length),s=0,o=()=>{++s==i.length&&Dl(t,e,n.filter(t=>null!=t).join(t.state.lineBreak),!1)};for(let t=0;t<i.length;t++){let e=new FileReader;e.onerror=o,e.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(e.result)||(n[t]=e.result),o()},e.readAsText(i[t])}return!0}{let i=e.dataTransfer.getData("Text");if(i)return Dl(t,e,i,!0),!0}return!1},bl.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let i=wl?null:e.clipboardData;return i?(Sl(t,i.getData("text/plain")||i.getData("text/uri-list")),!0):(function(t){let e=t.dom.parentNode;if(!e)return;let i=e.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus(),setTimeout(()=>{t.focus(),i.remove(),Sl(t,i.value)},50)}(t),!1)};let Rl=null;bl.copy=bl.cut=(t,e)=>{let{text:i,ranges:n,linewise:s}=function(t){let e=[],i=[],n=!1;for(let n of t.selection.ranges)n.empty||(e.push(t.sliceDoc(n.from,n.to)),i.push(n));if(!e.length){let s=-1;for(let{from:n}of t.selection.ranges){let o=t.doc.lineAt(n);o.number>s&&(e.push(o.text),i.push({from:o.from,to:Math.min(t.doc.length,o.to+1)})),s=o.number}n=!0}return{text:_l(t,ya,e.join(t.lineBreak)),ranges:i,linewise:n}}(t.state);if(!i&&!s)return!1;Rl=s?i:null,"cut"!=e.type||t.state.readOnly||t.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let o=wl?null:e.clipboardData;return o?(o.clearData(),o.setData("text/plain",i),!0):(function(t,e){let i=t.dom.parentNode;if(!i)return;let n=i.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout(()=>{n.remove(),t.focus()},50)}(t,i),!1)};const Il=Is.define();function Ll(t,e){let i=[];for(let n of t.facet(ga)){let s=n(t,e);s&&i.push(s)}return i.length?t.update({effects:i,annotations:Il.of(!0)}):null}function Nl(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=Ll(t.state,e);i?t.dispatch(i):t.update([])}},10)}xl.focus=t=>{t.inputState.lastFocusTime=Date.now(),t.scrollDOM.scrollTop||!t.inputState.lastScrollTop&&!t.inputState.lastScrollLeft||(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),Nl(t)},xl.blur=t=>{t.observer.clearSelectionRange(),Nl(t)},xl.compositionstart=xl.compositionupdate=t=>{t.observer.editContext||(null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},xl.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,gr.chrome&&gr.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},xl.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},bl.beforeinput=(t,e)=>{var i,n;if("insertReplacementText"==e.inputType&&t.observer.editContext){let n=null===(i=e.dataTransfer)||void 0===i?void 0:i.getData("text/plain"),s=e.getTargetRanges();if(n&&s.length){let e=s[0],i=t.posAtDOM(e.startContainer,e.startOffset),o=t.posAtDOM(e.endContainer,e.endOffset);return ul(t,{from:i,to:o,insert:t.state.toText(n)},null),!0}}let s;if(gr.chrome&&gr.android&&(s=ml.find(t=>t.inputType==e.inputType))&&(t.observer.delayAndroidKey(s.key,s.keyCode),"Backspace"==s.key||"Delete"==s.key)){let e=(null===(n=window.visualViewport)||void 0===n?void 0:n.height)||0;setTimeout(()=>{var i;((null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0)>e+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return gr.ios&&"deleteContentForward"==e.inputType&&t.observer.flushSoon(),gr.safari&&"insertText"==e.inputType&&t.inputState.composing>=0&&setTimeout(()=>xl.compositionend(t,e),20),!1};const jl=new Set;const zl=["pre-wrap","normal","pre-line","break-spaces"];let Bl=!1;function ql(){Bl=!1}class Zl{constructor(t){this.lineWrapping=t,this.doc=Rn.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(t,e){let i=this.doc.lineAt(e).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(t){if(!this.lineWrapping)return this.lineHeight;return(1+Math.max(0,Math.ceil((t-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return zl.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i<t.length;i++){let n=t[i];n<0?i++:this.heightSamples[Math.floor(10*n)]||(e=!0,this.heightSamples[Math.floor(10*n)]=!0)}return e}refresh(t,e,i,n,s,o){let r=zl.indexOf(t)>-1,a=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=r;if(this.lineWrapping=r,this.lineHeight=e,this.charWidth=i,this.textHeight=n,this.lineLength=s,a){this.heightSamples={};for(let t=0;t<o.length;t++){let e=o[t];e<0?t++:this.heightSamples[Math.floor(10*e)]=!0}}return a}}class Fl{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class Xl{constructor(t,e,i,n,s){this.from=t,this.length=e,this.top=i,this.height=n,this._content=s}get type(){return"number"==typeof this._content?Ar.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof Rr?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(t){let e=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new Xl(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var Hl=function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t}(Hl||(Hl={}));const Wl=.001;class Vl{constructor(t,e,i=2){this.length=t,this.height=e,this.flags=i}get outdated(){return(2&this.flags)>0}set outdated(t){this.flags=(t?2:0)|-3&this.flags}setHeight(t){this.height!=t&&(Math.abs(this.height-t)>Wl&&(Bl=!0),this.height=t)}replace(t,e,i){return Vl.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,n){let s=this,o=i.doc;for(let r=n.length-1;r>=0;r--){let{fromA:a,toA:l,fromB:c,toB:h}=n[r],u=s.lineAt(a,Hl.ByPosNoHeight,i.setDoc(e),0,0),d=u.to>=l?u:s.lineAt(l,Hl.ByPosNoHeight,i,0,0);for(h+=d.to-l,l=d.to;r>0&&u.from<=n[r-1].toA;)a=n[r-1].fromA,c=n[r-1].fromB,r--,a<u.from&&(u=s.lineAt(a,Hl.ByPosNoHeight,i,0,0));c+=u.from-a,a=u.from;let f=ec.build(i.setDoc(o),t,c,h);s=Yl(s,s.replace(a,l,f))}return s.updateHeight(i,0)}static empty(){return new Gl(0,0)}static of(t){if(1==t.length)return t[0];let e=0,i=t.length,n=0,s=0;for(;;)if(e==i)if(n>2*s){let s=t[e-1];s.break?t.splice(--e,1,s.left,null,s.right):t.splice(--e,1,s.left,s.right),i+=1+s.break,n-=s.size}else{if(!(s>2*n))break;{let e=t[i];e.break?t.splice(i,1,e.left,null,e.right):t.splice(i,1,e.left,e.right),i+=2+e.break,s-=e.size}}else if(n<s){let i=t[e++];i&&(n+=i.size)}else{let e=t[--i];e&&(s+=e.size)}let o=0;return null==t[e-1]?(o=1,e--):null==t[e]&&(o=1,i++),new Jl(Vl.of(t.slice(0,e)),o,Vl.of(t.slice(i)))}}function Yl(t,e){return t==e?t:(t.constructor!=e.constructor&&(Bl=!0),e)}Vl.prototype.size=1;class Ul extends Vl{constructor(t,e,i){super(t,e),this.deco=i}blockAt(t,e,i,n){return new Xl(n,this.length,i,this.height,this.deco||0)}lineAt(t,e,i,n,s){return this.blockAt(0,i,n,s)}forEachLine(t,e,i,n,s,o){t<=s+this.length&&e>=s&&o(this.blockAt(0,i,n,s))}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more&&this.setHeight(n.heights[n.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Gl extends Ul{constructor(t,e){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(t,e,i,n){return new Xl(n,this.length,i,this.height,this.breaks)}replace(t,e,i){let n=i[0];return 1==i.length&&(n instanceof Gl||n instanceof Kl&&4&n.flags)&&Math.abs(this.length-n.length)<10?(n instanceof Kl?n=new Gl(n.length,this.height):n.height=this.height,this.outdated||(n.outdated=!1),n):Vl.of(i)}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more?this.setHeight(n.heights[n.index++]):(i||this.outdated)&&this.setHeight(Math.max(this.widgetHeight,t.heightForLine(this.length-this.collapsed))+this.breaks*t.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Kl extends Vl{constructor(t){super(t,0)}heightMetrics(t,e){let i,n=t.doc.lineAt(e).number,s=t.doc.lineAt(e+this.length).number,o=s-n+1,r=0;if(t.lineWrapping){let e=Math.min(this.height,t.lineHeight*o);i=e/o,this.length>o+1&&(r=(this.height-e)/(this.length-o-1))}else i=this.height/o;return{firstLine:n,lastLine:s,perLine:i,perChar:r}}blockAt(t,e,i,n){let{firstLine:s,lastLine:o,perLine:r,perChar:a}=this.heightMetrics(e,n);if(e.lineWrapping){let s=n+(t<e.lineHeight?0:Math.round(Math.max(0,Math.min(1,(t-i)/this.height))*this.length)),o=e.doc.lineAt(s),l=r+o.length*a,c=Math.max(i,t-l/2);return new Xl(o.from,o.length,c,l,0)}{let n=Math.max(0,Math.min(o-s,Math.floor((t-i)/r))),{from:a,length:l}=e.doc.line(s+n);return new Xl(a,l,i+r*n,r,0)}}lineAt(t,e,i,n,s){if(e==Hl.ByHeight)return this.blockAt(t,i,n,s);if(e==Hl.ByPosNoHeight){let{from:e,to:n}=i.doc.lineAt(t);return new Xl(e,n-e,0,0,0)}let{firstLine:o,perLine:r,perChar:a}=this.heightMetrics(i,s),l=i.doc.lineAt(t),c=r+l.length*a,h=l.number-o,u=n+r*h+a*(l.from-s-h);return new Xl(l.from,l.length,Math.max(n,Math.min(u,n+this.height-c)),c,0)}forEachLine(t,e,i,n,s,o){t=Math.max(t,s),e=Math.min(e,s+this.length);let{firstLine:r,perLine:a,perChar:l}=this.heightMetrics(i,s);for(let c=t,h=n;c<=e;){let e=i.doc.lineAt(c);if(c==t){let i=e.number-r;h+=a*i+l*(t-s-i)}let n=a+l*e.length;o(new Xl(e.from,e.length,h,n,0)),h+=n,c=e.to+1}}replace(t,e,i){let n=this.length-e;if(n>0){let t=i[i.length-1];t instanceof Kl?i[i.length-1]=new Kl(t.length+n):i.push(null,new Kl(n-1))}if(t>0){let e=i[0];e instanceof Kl?i[0]=new Kl(t+e.length):i.unshift(new Kl(t-1),null)}return Vl.of(i)}decomposeLeft(t,e){e.push(new Kl(t-1),null)}decomposeRight(t,e){e.push(null,new Kl(this.length-t-1))}updateHeight(t,e=0,i=!1,n){let s=e+this.length;if(n&&n.from<=e+this.length&&n.more){let i=[],o=Math.max(e,n.from),r=-1;for(n.from>e&&i.push(new Kl(n.from-e-1).updateHeight(t,e));o<=s&&n.more;){let e=t.doc.lineAt(o).length;i.length&&i.push(null);let s=n.heights[n.index++];-1==r?r=s:Math.abs(s-r)>=Wl&&(r=-2);let a=new Gl(e,s);a.outdated=!1,i.push(a),o+=e+1}o<=s&&i.push(null,new Kl(s-o).updateHeight(t,o));let a=Vl.of(i);return(r<0||Math.abs(a.height-this.height)>=Wl||Math.abs(r-this.heightMetrics(t,e).perLine)>=Wl)&&(Bl=!0),Yl(this,a)}return(i||this.outdated)&&(this.setHeight(t.heightForGap(e,e+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class Jl extends Vl{constructor(t,e,i){super(t.length+e+i.length,t.height+i.height,e|(t.outdated||i.outdated?2:0)),this.left=t,this.right=i,this.size=t.size+i.size}get break(){return 1&this.flags}blockAt(t,e,i,n){let s=i+this.left.height;return t<s?this.left.blockAt(t,e,i,n):this.right.blockAt(t,e,s,n+this.left.length+this.break)}lineAt(t,e,i,n,s){let o=n+this.left.height,r=s+this.left.length+this.break,a=e==Hl.ByHeight?t<o:t<r,l=a?this.left.lineAt(t,e,i,n,s):this.right.lineAt(t,e,i,o,r);if(this.break||(a?l.to<r:l.from>r))return l;let c=e==Hl.ByPosNoHeight?Hl.ByPosNoHeight:Hl.ByPos;return a?l.join(this.right.lineAt(r,c,i,o,r)):this.left.lineAt(r,c,i,n,s).join(l)}forEachLine(t,e,i,n,s,o){let r=n+this.left.height,a=s+this.left.length+this.break;if(this.break)t<a&&this.left.forEachLine(t,e,i,n,s,o),e>=a&&this.right.forEachLine(t,e,i,r,a,o);else{let l=this.lineAt(a,Hl.ByPos,i,n,s);t<l.from&&this.left.forEachLine(t,l.from-1,i,n,s,o),l.to>=t&&l.from<=e&&o(l),e>l.to&&this.right.forEachLine(l.to+1,e,i,r,a,o)}}replace(t,e,i){let n=this.left.length+this.break;if(e<n)return this.balanced(this.left.replace(t,e,i),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-n,e-n,i));let s=[];t>0&&this.decomposeLeft(t,s);let o=s.length;for(let t of i)s.push(t);if(t>0&&tc(s,o-1),e<this.length){let t=s.length;this.decomposeRight(e,s),tc(s,t)}return Vl.of(s)}decomposeLeft(t,e){let i=this.left.length;if(t<=i)return this.left.decomposeLeft(t,e);e.push(this.left),this.break&&(i++,t>=i&&e.push(null)),t>i&&this.right.decomposeLeft(t-i,e)}decomposeRight(t,e){let i=this.left.length,n=i+this.break;if(t>=n)return this.right.decomposeRight(t-n,e);t<i&&this.left.decomposeRight(t,e),this.break&&t<n&&e.push(null),e.push(this.right)}balanced(t,e){return t.size>2*e.size||e.size>2*t.size?Vl.of(this.break?[t,null,e]:[t,e]):(this.left=Yl(this.left,t),this.right=Yl(this.right,e),this.setHeight(t.height+e.height),this.outdated=t.outdated||e.outdated,this.size=t.size+e.size,this.length=t.length+this.break+e.length,this)}updateHeight(t,e=0,i=!1,n){let{left:s,right:o}=this,r=e+s.length+this.break,a=null;return n&&n.from<=e+s.length&&n.more?a=s=s.updateHeight(t,e,i,n):s.updateHeight(t,e,i),n&&n.from<=r+o.length&&n.more?a=o=o.updateHeight(t,r,i,n):o.updateHeight(t,r,i),a?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function tc(t,e){let i,n;null==t[e]&&(i=t[e-1])instanceof Kl&&(n=t[e+1])instanceof Kl&&t.splice(e-1,3,new Kl(i.length+1+n.length))}class ec{constructor(t,e){this.pos=t,this.oracle=e,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,e){if(this.lineStart>-1){let t=Math.min(e,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof Gl?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new Gl(t-this.pos,-1)),this.writtenTo=t,e>t&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=e}point(t,e,i){if(t<e||i.heightRelevant){let n=i.widget?i.widget.estimatedHeight:0,s=i.widget?i.widget.lineBreaks:0;n<0&&(n=this.oracle.lineHeight);let o=e-t;i.block?this.addBlock(new Ul(o,n,i)):(o||s||n>=5)&&this.addLineDeco(n,s,o)}else e>t&&this.span(t,e);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:t,to:e}=this.oracle.doc.lineAt(this.pos);this.lineStart=t,this.lineEnd=e,this.writtenTo<t&&((this.writtenTo<t-1||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,t-1)),this.nodes.push(null)),this.pos>t&&this.nodes.push(new Gl(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new Kl(e-t);return this.oracle.doc.lineAt(t).to==e&&(i.flags|=4),i}ensureLine(){this.enterLine();let t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof Gl)return t;let e=new Gl(0,-1);return this.nodes.push(e),e}addBlock(t){this.enterLine();let e=t.deco;e&&e.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,e&&e.endSide>0&&(this.covering=t)}addLineDeco(t,e,i){let n=this.ensureLine();n.length+=i,n.collapsed+=i,n.widgetHeight=Math.max(n.widgetHeight,t),n.breaks+=e,this.writtenTo=this.pos=this.pos+i}finish(t){let e=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||e instanceof Gl||this.isCovered?(this.writtenTo<this.pos||null==e)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new Gl(0,-1));let i=t;for(let t of this.nodes)t instanceof Gl&&t.updateHeight(this.oracle,i),i+=t?t.length:1;return this.nodes}static build(t,e,i,n){let s=new ec(i,t);return no.spans(e,i,n,s,0),s.finish(i)}}class ic{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,n){(t<e||i&&i.heightRelevant||n&&n.heightRelevant)&&Lr(t,e,this.changes,5)}}function nc(t,e){let i=t.getBoundingClientRect(),n=t.ownerDocument,s=n.defaultView||window,o=Math.max(0,i.left),r=Math.min(s.innerWidth,i.right),a=Math.max(0,i.top),l=Math.min(s.innerHeight,i.bottom);for(let e=t.parentNode;e&&e!=n.body;)if(1==e.nodeType){let i=e,n=window.getComputedStyle(i);if((i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)&&"visible"!=n.overflow){let n=i.getBoundingClientRect();o=Math.max(o,n.left),r=Math.min(r,n.right),a=Math.max(a,n.top),l=Math.min(e==t.parentNode?s.innerHeight:l,n.bottom)}e="absolute"==n.position||"fixed"==n.position?i.offsetParent:i.parentNode}else{if(11!=e.nodeType)break;e=e.host}return{left:o-i.left,right:Math.max(o,r)-i.left,top:a-(i.top+e),bottom:Math.max(a,l)-(i.top+e)}}function sc(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}class oc{constructor(t,e,i,n){this.from=t,this.to=e,this.size=i,this.displaySize=n}static same(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let n=t[i],s=e[i];if(n.from!=s.from||n.to!=s.to||n.size!=s.size)return!1}return!0}draw(t,e){return Mr.replace({widget:new rc(this.displaySize*(e?t.scaleY:t.scaleX),e)}).range(this.from,this.to)}}class rc extends Er{constructor(t,e){super(),this.size=t,this.vertical=e}eq(t){return t.size==this.size&&t.vertical==this.vertical}toDOM(){let t=document.createElement("div");return this.vertical?t.style.height=this.size+"px":(t.style.width=this.size+"px",t.style.height="2px",t.style.display="inline-block"),t}get estimatedHeight(){return this.vertical?this.size:-1}}class ac{constructor(t){this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=uc,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Fr.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let e=t.facet(Ma).some(t=>"function"!=typeof t&&"cm-lineWrapping"==t.class);this.heightOracle=new Zl(e),this.stateDeco=t.facet(Qa).filter(t=>"function"!=typeof t),this.heightMap=Vl.empty().applyChanges(this.stateDeco,Rn.empty,this.heightOracle.setDoc(t.doc),[new Ba(0,0,0,t.doc.length)]);for(let t=0;t<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());t++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Mr.set(this.lineGaps.map(t=>t.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let t=[this.viewport],{main:e}=this.state.selection;for(let i=0;i<=1;i++){let n=i?e.head:e.anchor;if(!t.some(({from:t,to:e})=>n>=t&&n<=e)){let{from:e,to:i}=this.lineBlockAt(n);t.push(new lc(e,i))}}return this.viewports=t.sort((t,e)=>t.from-e.from),this.updateScaler()}updateScaler(){let t=this.scaler;return this.scaler=this.heightMap.height<=7e6?uc:new dc(this.heightOracle,this.heightMap,this.viewports),t.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,t=>{this.viewportLines.push(fc(t,this.scaler))})}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=this.state.facet(Qa).filter(t=>"function"!=typeof t);let n=t.changedRanges,s=Ba.extendWithRanges(n,function(t,e,i){let n=new ic;return no.compare(t,e,i,n,0),n.changes}(i,this.stateDeco,t?t.changes:Kn.empty(this.state.doc.length))),o=this.heightMap.height,r=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);ql(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||Bl)&&(t.flags|=2),r?(this.scrollAnchorPos=t.changes.mapPos(r.from,-1),this.scrollAnchorHeight=r.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=s.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<a.from||e.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,e));let l=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,t.flags|=this.updateForViewport(),(l||!t.changes.empty||2&t.flags)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,t.changes))),t.flags|=this.computeVisibleRanges(t.changes),e&&(this.scrollTarget=e),!this.mustEnforceCursorAssoc&&t.selectionSet&&t.view.lineWrapping&&t.state.selection.main.empty&&t.state.selection.main.assoc&&!t.state.facet(ba)&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,i=window.getComputedStyle(e),n=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection="rtl"==i.direction?Fr.RTL:Fr.LTR;let o=this.heightOracle.mustRefreshForWrapping(s),r=e.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=r.height;this.contentDOMHeight=r.height,this.mustMeasureContent=!1;let l=0,c=0;if(r.width&&r.height){let{scaleX:t,scaleY:i}=Bo(e,r);(t>.005&&Math.abs(this.scaleX-t)>.005||i>.005&&Math.abs(this.scaleY-i)>.005)&&(this.scaleX=t,this.scaleY=i,l|=16,o=a=!0)}let h=(parseInt(i.paddingTop)||0)*this.scaleY,u=(parseInt(i.paddingBottom)||0)*this.scaleY;this.paddingTop==h&&this.paddingBottom==u||(this.paddingTop=h,this.paddingBottom=u,l|=18),this.editorWidth!=t.scrollDOM.clientWidth&&(n.lineWrapping&&(a=!0),this.editorWidth=t.scrollDOM.clientWidth,l|=16);let d=t.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=d&&(this.scrollAnchorHeight=-1,this.scrollTop=d),this.scrolledToBottom=Yo(t.scrollDOM);let f=(this.printing?sc:nc)(e,this.paddingTop),p=f.top-this.pixelViewport.top,m=f.bottom-this.pixelViewport.bottom;this.pixelViewport=f;let g=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(g!=this.inView&&(this.inView=g,g&&(a=!0)),!this.inView&&!this.scrollTarget&&!function(t){let e=t.getBoundingClientRect(),i=t.ownerDocument.defaultView||window;return e.left<i.innerWidth&&e.right>0&&e.top<i.innerHeight&&e.bottom>0}(t.dom))return 0;let v=r.width;if(this.contentDOMWidth==v&&this.editorHeight==t.scrollDOM.clientHeight||(this.contentDOMWidth=r.width,this.editorHeight=t.scrollDOM.clientHeight,l|=16),a){let e=t.docView.measureVisibleLineHeights(this.viewport);if(n.mustRefreshForHeights(e)&&(o=!0),o||n.lineWrapping&&Math.abs(v-this.contentDOMWidth)>n.charWidth){let{lineHeight:i,charWidth:r,textHeight:a}=t.docView.measureTextSize();o=i>0&&n.refresh(s,i,r,a,Math.max(5,v/r),e),o&&(t.docView.minWidth=0,l|=16)}p>0&&m>0?c=Math.max(p,m):p<0&&m<0&&(c=Math.min(p,m)),ql();for(let i of this.viewports){let s=i.from==this.viewport.from?e:t.docView.measureVisibleLineHeights(i);this.heightMap=(o?Vl.empty().applyChanges(this.stateDeco,Rn.empty,this.heightOracle,[new Ba(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(n,0,o,new Fl(i.from,s))}Bl&&(l|=2)}let y=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return y&&(2&l&&(l|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),l|=this.updateForViewport()),(2&l||y)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,t)),l|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),l}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),n=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:r}=this,a=new lc(n.lineAt(o-1e3*i,Hl.ByHeight,s,0,0).from,n.lineAt(r+1e3*(1-i),Hl.ByHeight,s,0,0).to);if(e){let{head:t}=e.range;if(t<a.from||t>a.to){let i,o=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),r=n.lineAt(t,Hl.ByPos,s,0,0);i="center"==e.y?(r.top+r.bottom)/2-o/2:"start"==e.y||"nearest"==e.y&&t<a.from?r.top:r.bottom-o,a=new lc(n.lineAt(i-500,Hl.ByHeight,s,0,0).from,n.lineAt(i+o+500,Hl.ByHeight,s,0,0).to)}}return a}mapViewport(t,e){let i=e.mapPos(t.from,-1),n=e.mapPos(t.to,1);return new lc(this.heightMap.lineAt(i,Hl.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(n,Hl.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){if(!this.inView)return!0;let{top:n}=this.heightMap.lineAt(t,Hl.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(e,Hl.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:r}=this;return(0==t||n<=o-Math.max(10,Math.min(-i,250)))&&(e==this.state.doc.length||s>=r+Math.max(10,Math.min(i,250)))&&n>o-2e3&&s<r+2e3}mapLineGaps(t,e){if(!t.length||e.empty)return t;let i=[];for(let n of t)e.touchesRange(n.from,n.to)||i.push(new oc(e.mapPos(n.from),e.mapPos(n.to),n.size,n.displaySize));return i}ensureLineGaps(t,e){let i=this.heightOracle.lineWrapping,n=i?1e4:2e3,s=n>>1,o=n<<1;if(this.defaultTextDirection!=Fr.LTR&&!i)return[];let r=[],a=(n,o,l,c)=>{if(o-n<s)return;let h=this.state.selection.main,u=[h.from];h.empty||u.push(h.to);for(let t of u)if(t>n&&t<o)return a(n,t-10,l,c),void a(t+10,o,l,c);let d=function(t,e){for(let i of t)if(e(i))return i;return}(t,t=>t.from>=l.from&&t.to<=l.to&&Math.abs(t.from-n)<s&&Math.abs(t.to-o)<s&&!u.some(e=>t.from<e&&t.to>e));if(!d){if(o<l.to&&e&&i&&e.visibleRanges.some(t=>t.from<=o&&t.to>=o)){let t=e.moveToLineBoundary(rs.cursor(o),!1,!0).head;t>n&&(o=t)}let t=this.gapSize(l,n,o,c);d=new oc(n,o,t,i||t<2e6?t:2e6)}r.push(d)},l=e=>{if(e.length<o||e.type!=Ar.Text)return;let s=function(t,e,i){let n=[],s=t,o=0;no.spans(i,t,e,{span(){},point(t,e){t>s&&(n.push({from:s,to:t}),o+=t-s),s=e}},20),s<e&&(n.push({from:s,to:e}),o+=e-s);return{total:o,ranges:n}}(e.from,e.to,this.stateDeco);if(s.total<o)return;let r,l,c=this.scrollTarget?this.scrollTarget.range.head:null;if(i){let t,i,o=n/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=c){let n=hc(s,c),r=((this.visibleBottom-this.visibleTop)/2+o)/e.height;t=n-r,i=n+r}else t=(this.visibleTop-e.top-o)/e.height,i=(this.visibleBottom-e.top+o)/e.height;r=cc(s,t),l=cc(s,i)}else{let i=s.total*this.heightOracle.charWidth,o=n*this.heightOracle.charWidth,a=0;if(i>2e6)for(let i of t)i.from>=e.from&&i.from<e.to&&i.size!=i.displaySize&&i.from*this.heightOracle.charWidth+a<this.pixelViewport.left&&(a=i.size-i.displaySize);let h,u,d=this.pixelViewport.left+a,f=this.pixelViewport.right+a;if(null!=c){let t=hc(s,c),e=((f-d)/2+o)/i;h=t-e,u=t+e}else h=(d-o)/i,u=(f+o)/i;r=cc(s,h),l=cc(s,u)}r>e.from&&a(e.from,r,e,s),l<e.to&&a(l,e.to,e,s)};for(let t of this.viewportLines)Array.isArray(t.type)?t.type.forEach(l):l(t);return r}gapSize(t,e,i,n){let s=hc(n,i)-hc(n,e);return this.heightOracle.lineWrapping?t.height*s:n.total*this.heightOracle.charWidth*s}updateLineGaps(t){oc.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=Mr.set(t.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(t){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let i=[];no.spans(e,this.viewport.from,this.viewport.to,{span(t,e){i.push({from:t,to:e})},point(){}},20);let n=0;if(i.length!=this.visibleRanges.length)n=12;else for(let e=0;e<i.length&&!(8&n);e++){let s=this.visibleRanges[e],o=i[e];s.from==o.from&&s.to==o.to||(n|=4,t&&t.mapPos(s.from,-1)==o.from&&t.mapPos(s.to,1)==o.to||(n|=8))}return this.visibleRanges=i,n}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find(e=>e.from<=t&&e.to>=t)||fc(this.heightMap.lineAt(t,Hl.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return t>=this.viewportLines[0].top&&t<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(e=>e.top<=t&&e.bottom>=t)||fc(this.heightMap.lineAt(this.scaler.fromDOM(t),Hl.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(t){let e=this.lineBlockAtHeight(t+8);return e.from>=this.viewport.from||this.viewportLines[0].top-t>200?e:this.viewportLines[0]}elementAtHeight(t){return fc(this.heightMap.blockAt(this.scaler.fromDOM(t),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class lc{constructor(t,e){this.from=t,this.to=e}}function cc({total:t,ranges:e},i){if(i<=0)return e[0].from;if(i>=1)return e[e.length-1].to;let n=Math.floor(t*i);for(let t=0;;t++){let{from:i,to:s}=e[t],o=s-i;if(n<=o)return i+n;n-=o}}function hc(t,e){let i=0;for(let{from:n,to:s}of t.ranges){if(e<=s){i+=e-n;break}i+=s-n}return i/t.total}const uc={toDOM:t=>t,fromDOM:t=>t,scale:1,eq(t){return t==this}};class dc{constructor(t,e,i){let n=0,s=0,o=0;this.viewports=i.map(({from:i,to:s})=>{let o=e.lineAt(i,Hl.ByPos,t,0,0).top,r=e.lineAt(s,Hl.ByPos,t,0,0).bottom;return n+=r-o,{from:i,to:s,top:o,bottom:r,domTop:0,domBottom:0}}),this.scale=(7e6-n)/(e.height-n);for(let t of this.viewports)t.domTop=o+(t.top-s)*this.scale,o=t.domBottom=t.domTop+(t.bottom-t.top),s=t.bottom}toDOM(t){for(let e=0,i=0,n=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.top)return n+(t-i)*this.scale;if(t<=s.bottom)return s.domTop+(t-s.top);i=s.bottom,n=s.domBottom}}fromDOM(t){for(let e=0,i=0,n=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.domTop)return i+(t-n)/this.scale;if(t<=s.domBottom)return s.top+(t-s.domTop);i=s.bottom,n=s.domBottom}}eq(t){return t instanceof dc&&(this.scale==t.scale&&this.viewports.length==t.viewports.length&&this.viewports.every((e,i)=>e.from==t.viewports[i].from&&e.to==t.viewports[i].to))}}function fc(t,e){if(1==e.scale)return t;let i=e.toDOM(t.top),n=e.toDOM(t.bottom);return new Xl(t.from,t.length,i,n-i,Array.isArray(t._content)?t._content.map(t=>fc(t,e)):t._content)}const pc=cs.define({combine:t=>t.join(" ")}),mc=cs.define({combine:t=>t.indexOf(!0)>-1}),gc=xo.newName(),vc=xo.newName(),yc=xo.newName(),Oc={"&light":"."+vc,"&dark":"."+yc};function bc(t,e,i){return new xo(e,{finish:e=>/&/.test(e)?e.replace(/&\w*/,e=>{if("&"==e)return t;if(!i||!i[e])throw new RangeError(`Unsupported selector: ${e}`);return i[e]}):t+" "+e})}const xc=bc("."+gc,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Oc),wc={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},_c=gr.ie&&gr.ie_version<=11;class Sc{constructor(t){this.view=t,this.active=!1,this.editContext=null,this.selectionRange=new qo,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver(e=>{for(let t of e)this.queue.push(t);(gr.ie&&gr.ie_version<=11||gr.ios&&t.composing)&&e.some(t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length)?this.flushSoon():this.flush()}),!window.EditContext||!gr.android||!1===t.constructor.EDIT_CONTEXT||gr.chrome&&gr.chrome_version<126||(this.editContext=new Cc(t),t.state.facet($a)&&(t.contentDOM.editContext=this.editContext.editContext)),_c&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver(()=>{var t;(null===(t=this.view.docView)||void 0===t?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(t.scrollDOM)),this.addWindowListeners(this.win=t.win),this.start(),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(t){this.view.inputState.runHandlers("scroll",t),this.intersecting&&this.view.measure()}onScroll(t){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(t){("change"!=t.type&&t.type||t.matches)&&(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some((e,i)=>e!=t[i]))){this.gapIntersection.disconnect();for(let e of t)this.gapIntersection.observe(e);this.gaps=t}}onSelectionChange(t){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,n=this.selectionRange;if(i.state.facet($a)?i.root.activeElement!=this.dom:!Mo(this.dom,n))return;let s=n.anchorNode&&i.docView.nearest(n.anchorNode);s&&s.ignoreEvent(t)?e||(this.selectionChanged=!1):(gr.ie&&gr.ie_version<=11||gr.android&&gr.chrome)&&!i.state.selection.main.empty&&n.focusNode&&Do(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=Eo(t.root);if(!e)return!1;let i=gr.safari&&11==t.root.nodeType&&t.root.activeElement==this.dom&&function(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return $c(t,i)}let i=null;function n(t){t.preventDefault(),t.stopImmediatePropagation(),i=t.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",n,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",n,!0),i?$c(t,i):null}(this.view,e)||e;if(!i||this.selectionRange.eq(i))return!1;let n=Mo(this.dom,i);return n&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&function(t,e){let i=e.focusNode,n=e.focusOffset;if(!i||e.anchorNode!=i||e.anchorOffset!=n)return!1;for(n=Math.min(n,No(i));;)if(n){if(1!=i.nodeType)return!1;let t=i.childNodes[n-1];"false"==t.contentEditable?n--:(i=t,n=No(i))}else{if(i==t)return!0;n=Ro(i),i=i.parentNode}}(this.dom,i)?(this.view.inputState.lastFocusTime=0,t.docView.updateSelection(),!1):(this.selectionRange.setRange(i),n&&(this.selectionChanged=!0),!0)}setSelectionRange(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let t=0,e=null;for(let i=this.dom;i;)if(1==i.nodeType)!e&&t<this.scrollTargets.length&&this.scrollTargets[t]==i?t++:e||(e=this.scrollTargets.slice(0,t)),e&&e.push(i),i=i.assignedSlot||i.parentNode;else{if(11!=i.nodeType)break;i=i.host}if(t<this.scrollTargets.length&&!e&&(e=this.scrollTargets.slice(0,t)),e){for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);for(let t of this.scrollTargets=e)t.addEventListener("scroll",this.onScroll)}}ignore(t){if(!this.active)return t();try{return this.stop(),t()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,wc),_c&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),_c&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(t,e){var i;if(!this.delayedAndroidKey){let t=()=>{let t=this.delayedAndroidKey;if(t){this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=t.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&t.force&&Wo(this.dom,t.key,t.keyCode)}};this.flushingAndroidKey=this.view.win.requestAnimationFrame(t)}this.delayedAndroidKey&&"Enter"!=t||(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange<Date.now()-50||!!(null===(i=this.delayedAndroidKey)||void 0===i?void 0:i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,i=-1,n=!1;for(let s of t){let t=this.readMutation(s);t&&(t.typeOver&&(n=!0),-1==e?({from:e,to:i}=t):(e=Math.min(t.from,e),i=Math.max(t.to,i)))}return{from:e,to:i,typeOver:n}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords(),n=this.selectionChanged&&Mo(this.dom,this.selectionRange);if(t<0&&!n)return null;t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new cl(this.view,t,e,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return this.view.requestMeasure(),!1;let i=this.view.state,n=hl(this.view,e);return this.view.state==i&&(e.domChanged||e.newSel&&!e.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),n}readMutation(t){let e=this.view.docView.nearest(t.target);if(!e||e.ignoreMutation(t))return null;if(e.markDirty("attributes"==t.type),"attributes"==t.type&&(e.flags|=4),"childList"==t.type){let i=kc(e,t.previousSibling||t.target.previousSibling,-1),n=kc(e,t.nextSibling||t.target.nextSibling,1);return{from:i?e.posAfter(i):e.posAtStart,to:n?e.posBefore(n):e.posAtEnd,typeOver:!1}}return"characterData"==t.type?{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}:null}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}update(t){this.editContext&&(this.editContext.update(t),t.startState.facet($a)!=t.state.facet($a)&&(t.view.contentDOM.editContext=t.state.facet($a)?this.editContext.editContext:null))}destroy(){var t,e,i;this.stop(),null===(t=this.intersection)||void 0===t||t.disconnect(),null===(e=this.gapIntersection)||void 0===e||e.disconnect(),null===(i=this.resizeScroll)||void 0===i||i.disconnect();for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function kc(t,e,i){for(;e;){let n=tr.get(e);if(n&&n.parent==t)return n;let s=e.parentNode;e=s!=t.dom?s:i>0?e.nextSibling:e.previousSibling}return null}function $c(t,e){let i=e.startContainer,n=e.startOffset,s=e.endContainer,o=e.endOffset,r=t.docView.domAtPos(t.state.selection.main.anchor);return Do(r.node,r.offset,s,o)&&([i,n,s,o]=[s,o,i,n]),{anchorNode:i,anchorOffset:n,focusNode:s,focusOffset:o}}class Cc{constructor(t){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(t.state);let e=this.editContext=new window.EditContext({text:t.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,t.state.selection.main.anchor))),selectionEnd:this.toContextPos(t.state.selection.main.head)});this.handlers.textupdate=e=>{let i=t.state.selection.main,{anchor:n,head:s}=i,o=this.toEditorPos(e.updateRangeStart),r=this.toEditorPos(e.updateRangeEnd);t.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:e.updateRangeStart,editorBase:o,drifted:!1});let a={from:o,to:r,insert:Rn.of(e.text.split("\n"))};if(a.from==this.from&&n<this.from?a.from=n:a.to==this.to&&n>this.to&&(a.to=n),a.from==a.to&&!a.insert.length){let n=rs.single(this.toEditorPos(e.selectionStart),this.toEditorPos(e.selectionEnd));return void(n.main.eq(i)||t.dispatch({selection:n,userEvent:"select"}))}if((gr.mac||gr.android)&&a.from==s-1&&/^\. ?$/.test(e.text)&&"off"==t.contentDOM.getAttribute("autocorrect")&&(a={from:o,to:r,insert:Rn.of([e.text.replace("."," ")])}),this.pendingContextChange=a,!t.state.readOnly){let i=this.to-this.from+(a.to-a.from+a.insert.length);ul(t,a,rs.single(this.toEditorPos(e.selectionStart,i),this.toEditorPos(e.selectionEnd,i)))}this.pendingContextChange&&(this.revertPending(t.state),this.setSelection(t.state))},this.handlers.characterboundsupdate=i=>{let n=[],s=null;for(let e=this.toEditorPos(i.rangeStart),o=this.toEditorPos(i.rangeEnd);e<o;e++){let i=t.coordsForChar(e);s=i&&new DOMRect(i.left,i.top,i.right-i.left,i.bottom-i.top)||s||new DOMRect,n.push(s)}e.updateCharacterBounds(i.rangeStart,n)},this.handlers.textformatupdate=e=>{let i=[];for(let t of e.getTextFormats()){let e=t.underlineStyle,n=t.underlineThickness;if("None"!=e&&"None"!=n){let s=this.toEditorPos(t.rangeStart),o=this.toEditorPos(t.rangeEnd);if(s<o){let t=`text-decoration: underline ${"Dashed"==e?"dashed ":"Squiggle"==e?"wavy ":""}${"Thin"==n?1:2}px`;i.push(Mr.mark({attributes:{style:t}}).range(s,o))}}}t.dispatch({effects:Sa.of(Mr.set(i))})},this.handlers.compositionstart=()=>{t.inputState.composing<0&&(t.inputState.composing=0,t.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(t.inputState.composing=-1,t.inputState.compositionFirstChange=null,this.composing){let{drifted:e}=this.composing;this.composing=null,e&&this.reset(t.state)}};for(let t in this.handlers)e.addEventListener(t,this.handlers[t]);this.measureReq={read:t=>{this.editContext.updateControlBounds(t.contentDOM.getBoundingClientRect());let e=Eo(t.root);e&&e.rangeCount&&this.editContext.updateSelectionBounds(e.getRangeAt(0).getBoundingClientRect())}}}applyEdits(t){let e=0,i=!1,n=this.pendingContextChange;return t.changes.iterChanges((s,o,r,a,l)=>{if(i)return;let c=l.length-(o-s);if(n&&o>=n.to){if(n.from==s&&n.to==o&&n.insert.eq(l))return n=this.pendingContextChange=null,e+=c,void(this.to+=c);n=null,this.revertPending(t.state)}if(s+=e,(o+=e)<=this.from)this.from+=c,this.to+=c;else if(s<this.to){if(s<this.from||o>this.to||this.to-this.from+l.length>3e4)return void(i=!0);this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),l.toString()),this.to+=c}e+=c}),n&&!i&&this.revertPending(t.state),!i}update(t){let e=this.pendingContextChange,i=t.startState.selection.main;this.composing&&(this.composing.drifted||!t.changes.touchesRange(i.from,i.to)&&t.transactions.some(t=>!t.isUserEvent("input.type")&&t.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=t.changes.mapPos(this.composing.editorBase)):this.applyEdits(t)&&this.rangeIsValid(t.state)?(t.docChanged||t.selectionSet||e)&&this.setSelection(t.state):(this.pendingContextChange=null,this.reset(t.state)),(t.geometryChanged||t.docChanged||t.selectionSet)&&t.view.requestMeasure(this.measureReq)}resetRange(t){let{head:e}=t.selection.main;this.from=Math.max(0,e-1e4),this.to=Math.min(t.doc.length,e+1e4)}reset(t){this.resetRange(t),this.editContext.updateText(0,this.editContext.text.length,t.doc.sliceString(this.from,this.to)),this.setSelection(t)}revertPending(t){let e=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(e.from),this.toContextPos(e.from+e.insert.length),t.doc.sliceString(e.from,e.to))}setSelection(t){let{main:e}=t.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,e.anchor))),n=this.toContextPos(e.head);this.editContext.selectionStart==i&&this.editContext.selectionEnd==n||this.editContext.updateSelection(i,n)}rangeIsValid(t){let{head:e}=t.selection.main;return!(this.from>0&&e-this.from<500||this.to<t.doc.length&&this.to-e<500||this.to-this.from>3e4)}toEditorPos(t,e=this.to-this.from){t=Math.min(t,e);let i=this.composing;return i&&i.drifted?i.editorBase+(t-i.contextBase):t+this.from}toContextPos(t){let e=this.composing;return e&&e.drifted?e.contextBase+(t-e.editorBase):t-this.from}destroy(){for(let t in this.handlers)this.editContext.removeEventListener(t,this.handlers[t])}}class Tc{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(t={}){var e;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),t.parent&&t.parent.appendChild(this.dom);let{dispatch:i}=t;this.dispatchTransactions=t.dispatchTransactions||i&&(t=>t.forEach(t=>i(t,this)))||(t=>this.update(t)),this.dispatch=this.dispatch.bind(this),this._root=t.root||function(t){for(;t;){if(t&&(9==t.nodeType||11==t.nodeType&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}(t.parent)||document,this.viewState=new ac(t.state||Gs.create(t)),t.scrollTo&&t.scrollTo.is(_a)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Ta).map(t=>new Ea(t));for(let t of this.plugins)t.update(this);this.observer=new Sc(this),this.inputState=new dl(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Za(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),(null===(e=document.fonts)||void 0===e?void 0:e.ready)&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...t){let e=1==t.length&&t[0]instanceof zs?t:1==t.length&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(e,this)}update(t){if(0!=this.updateState)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let e,i=!1,n=!1,s=this.state;for(let e of t){if(e.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=e.state}if(this.destroyed)return void(this.viewState.state=s);let o=this.hasFocus,r=0,a=null;t.some(t=>t.annotation(Il))?(this.inputState.notifiedFocused=o,r=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=Ll(s,o),a||(r=1));let l=this.observer.delayedAndroidKey,c=null;if(l?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(c=null)):this.observer.clear(),s.facet(Gs.phrases)!=this.state.facet(Gs.phrases))return this.setState(s);e=qa.create(this,s,t),e.flags|=r;let h=this.viewState.scrollTarget;try{this.updateState=2;for(let e of t){if(h&&(h=h.map(e.changes)),e.scrollIntoView){let{main:t}=e.state.selection;h=new wa(t.empty?t:rs.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(_a)&&(h=t.value.clip(this.state))}this.viewState.update(e,h),this.bidiCache=Ac.update(this.bidiCache,e.changes),e.empty||(this.updatePlugins(e),this.inputState.update(e)),i=this.docView.update(e),this.state.facet(za)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(i,t.some(t=>t.isUserEvent("select.pointer")))}finally{this.updateState=0}if(e.startState.facet(pc)!=e.state.facet(pc)&&(this.viewState.mustMeasureContent=!0),(i||n||h||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),i&&this.docViewUpdate(),!e.empty)for(let t of this.state.facet(pa))try{t(e)}catch(t){ka(this.state,t,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!hl(this,c)&&l.force&&Wo(this.contentDOM,l.key,l.keyCode)})}setState(t){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed)return void(this.viewState.state=t);this.updateState=2;let e=this.hasFocus;try{for(let t of this.plugins)t.destroy(this);this.viewState=new ac(t),this.plugins=t.facet(Ta).map(t=>new Ea(t)),this.pluginMap.clear();for(let t of this.plugins)t.update(this);this.docView.destroy(),this.docView=new Za(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(Ta),i=t.state.facet(Ta);if(e!=i){let n=[];for(let s of i){let i=e.indexOf(s);if(i<0)n.push(new Ea(s));else{let e=this.plugins[i];e.mustUpdate=t,n.push(e)}}for(let e of this.plugins)e.mustUpdate!=t&&e.destroy(this);this.plugins=n,this.pluginMap.clear()}else for(let e of this.plugins)e.mustUpdate=t;for(let t=0;t<this.plugins.length;t++)this.plugins[t].update(this);e!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let t of this.plugins){let e=t.value;if(e&&e.docViewUpdate)try{e.docViewUpdate(this)}catch(t){ka(this.state,t,"doc view update listener")}}}measure(t=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey)return this.measureScheduled=-1,void this.requestMeasure();this.measureScheduled=0,t&&this.observer.forceFlush();let e=null,i=this.scrollDOM,n=i.scrollTop*this.scaleY,{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(n-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let t=0;;t++){if(o<0)if(Yo(i))s=-1,o=this.viewState.heightMap.height;else{let t=this.viewState.scrollAnchorAt(n);s=t.from,o=t.top}this.updateState=1;let r=this.viewState.measure(this);if(!r&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(t>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let a=[];4&r||([this.measureRequests,a]=[a,this.measureRequests]);let l=a.map(t=>{try{return t.read(this)}catch(t){return ka(this.state,t),Ec}}),c=qa.create(this,this.state,[]),h=!1;c.flags|=r,e?e.flags|=r:e=c,this.updateState=2,c.empty||(this.updatePlugins(c),this.inputState.update(c),this.updateAttrs(),h=this.docView.update(c),h&&this.docViewUpdate());for(let t=0;t<a.length;t++)if(l[t]!=Ec)try{let e=a[t];e.write&&e.write(l[t],this)}catch(t){ka(this.state,t)}if(h&&this.docView.updateSelection(!0),!c.viewportChanged&&0==this.measureRequests.length){if(this.viewState.editorHeight){if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}{let t=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-o;if(t>1||t<-1){n+=t,i.scrollTop=n/this.scaleY,o=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let t of this.state.facet(pa))t(e)}get themeClasses(){return gc+" "+(this.state.facet(mc)?yc:vc)+" "+this.state.facet(pc)}updateAttrs(){let t=Mc(this,Aa,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet($a)?"true":"false",class:"cm-content",style:`${gr.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),Mc(this,Ma,e);let i=this.observer.ignore(()=>{let i=Tr(this.contentDOM,this.contentAttrs,e),n=Tr(this.dom,this.editorAttrs,t);return i||n});return this.editorAttrs=t,this.contentAttrs=e,i}showAnnouncements(t){let e=!0;for(let i of t)for(let t of i.effects)if(t.is(Tc.announce)){e&&(this.announceDOM.textContent=""),e=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(za);let t=this.state.facet(Tc.cspNonce);xo.mount(this.root,this.styleModules.concat(xc).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(2==this.updateState)throw new Error("Reading the editor layout isn't allowed during an update");0==this.updateState&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(t){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),t){if(this.measureRequests.indexOf(t)>-1)return;if(null!=t.key)for(let e=0;e<this.measureRequests.length;e++)if(this.measureRequests[e].key===t.key)return void(this.measureRequests[e]=t);this.measureRequests.push(t)}}plugin(t){let e=this.pluginMap.get(t);return(void 0===e||e&&e.plugin!=t)&&this.pluginMap.set(t,e=this.plugins.find(e=>e.plugin==t)||null),e&&e.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,i){return sl(this,t,il(this,t,e,i))}moveByGroup(t,e){return sl(this,t,il(this,t,e,e=>function(t,e,i){let n=t.state.charCategorizer(e),s=n(i);return t=>{let e=n(t);return s==Ws.Space&&(s=e),s==e}}(this,t.head,e)))}visualLineSide(t,e){let i=this.bidiSpans(t),n=this.textDirectionAt(t.from),s=i[e?i.length-1:0];return rs.cursor(s.side(e,n)+t.from,s.forward(!e,n)?1:-1)}moveToLineBoundary(t,e,i=!0){return function(t,e,i,n){let s=el(t,e.head,e.assoc||-1),o=n&&s.type==Ar.Text&&(t.lineWrapping||s.widgetLineBreaks)?t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head):null;if(o){let e=t.dom.getBoundingClientRect(),n=t.textDirectionAt(s.from),r=t.posAtCoords({x:i==(n==Fr.LTR)?e.right-1:e.left+1,y:(o.top+o.bottom)/2});if(null!=r)return rs.cursor(r,i?-1:1)}return rs.cursor(i?s.to:s.from,i?-1:1)}(this,t,e,i)}moveVertically(t,e,i){return sl(this,t,function(t,e,i,n){let s=e.head,o=i?1:-1;if(s==(i?t.state.doc.length:0))return rs.cursor(s,e.assoc);let r,a=e.goalColumn,l=t.contentDOM.getBoundingClientRect(),c=t.coordsAtPos(s,e.assoc||-1),h=t.documentTop;if(c)null==a&&(a=c.left-l.left),r=o<0?c.top:c.bottom;else{let e=t.viewState.lineBlockAt(s);null==a&&(a=Math.min(l.right-l.left,t.defaultCharacterWidth*(s-e.from))),r=(o<0?e.top:e.bottom)+h}let u=l.left+a,d=null!=n?n:t.viewState.heightOracle.textHeight>>1;for(let e=0;;e+=10){let i=r+(d+e)*o,n=Ja(t,{x:u,y:i},!1,o);if(i<l.top||i>l.bottom||(o<0?n<s:n>s)){let e=t.docView.coordsForChar(n),s=!e||i<e.top?-1:1;return rs.cursor(n,s,void 0,a)}}}(this,t,e,i))}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){return this.readMeasured(),Ja(this,t,e)}coordsAtPos(t,e=1){this.readMeasured();let i=this.docView.coordsAt(t,e);if(!i||i.left==i.right)return i;let n=this.state.doc.lineAt(t),s=this.bidiSpans(n);return jo(i,s[ta.find(s,t-n.from,-1,e)].dir==Fr.LTR==e>0)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(Oa)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>Pc)return ra(t.length);let e,i=this.textDirectionAt(t.from);for(let n of this.bidiCache)if(n.from==t.from&&n.dir==i&&(n.fresh||ea(n.isolates,e=La(this,t))))return n.order;e||(e=La(this,t));let n=oa(t.text,i,e);return this.bidiCache.push(new Ac(t.from,t.to,i,e,!0,n)),n}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||gr.safari&&(null===(t=this.inputState)||void 0===t?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Xo(this.contentDOM),this.docView.updateSelection()})}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((9==t.nodeType?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,e={}){return _a.of(new wa("number"==typeof t?rs.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}scrollSnapshot(){let{scrollTop:t,scrollLeft:e}=this.scrollDOM,i=this.viewState.scrollAnchorAt(t);return _a.of(new wa(rs.cursor(i.from),"start","start",i.top-t,e,!0))}setTabFocusMode(t){null==t?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:"boolean"==typeof t?this.inputState.tabFocusMode=t?0:-1:0!=this.inputState.tabFocusMode&&(this.inputState.tabFocusMode=Date.now()+t)}static domEventHandlers(t){return Pa.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return Pa.define(()=>({}),{eventObservers:t})}static theme(t,e){let i=xo.newName(),n=[pc.of(i),za.of(bc(`.${i}`,t))];return e&&e.dark&&n.push(mc.of(!0)),n}static baseTheme(t){return ws.lowest(za.of(bc("."+gc,t,Oc)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),n=i&&tr.get(i)||tr.get(t);return(null===(e=null==n?void 0:n.rootView)||void 0===e?void 0:e.view)||null}}Tc.styleModule=za,Tc.inputHandler=ma,Tc.clipboardInputFilter=va,Tc.clipboardOutputFilter=ya,Tc.scrollHandler=xa,Tc.focusChangeEffect=ga,Tc.perLineTextDirection=Oa,Tc.exceptionSink=fa,Tc.updateListener=pa,Tc.editable=$a,Tc.mouseSelectionStyle=da,Tc.dragMovesSelection=ua,Tc.clickAddsSelectionRange=ha,Tc.decorations=Qa,Tc.outerDecorations=Da,Tc.atomicRanges=Ra,Tc.bidiIsolatedRanges=Ia,Tc.scrollMargins=Na,Tc.darkTheme=mc,Tc.cspNonce=cs.define({combine:t=>t.length?t[0]:""}),Tc.contentAttributes=Ma,Tc.editorAttributes=Aa,Tc.lineWrapping=Tc.contentAttributes.of({class:"cm-lineWrapping"}),Tc.announce=js.define();const Pc=4096,Ec={};class Ac{constructor(t,e,i,n,s,o){this.from=t,this.to=e,this.dir=i,this.isolates=n,this.fresh=s,this.order=o}static update(t,e){if(e.empty&&!t.some(t=>t.fresh))return t;let i=[],n=t.length?t[t.length-1].dir:Fr.LTR;for(let s=Math.max(0,t.length-10);s<t.length;s++){let o=t[s];o.dir!=n||e.touchesRange(o.from,o.to)||i.push(new Ac(e.mapPos(o.from,1),e.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return i}}function Mc(t,e,i){for(let n=t.state.facet(e),s=n.length-1;s>=0;s--){let e=n[s],o="function"==typeof e?e(t):e;o&&kr(o,i)}return i}const Qc=gr.mac?"mac":gr.windows?"win":gr.linux?"linux":"key";function Dc(t,e,i){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),!1!==i&&e.shiftKey&&(t="Shift-"+t),t}const Rc=ws.default(Tc.domEventHandlers({keydown:(t,e)=>qc(Nc(e.state),t,e,"editor")})),Ic=cs.define({enables:Rc}),Lc=new WeakMap;function Nc(t){let e=t.facet(Ic),i=Lc.get(e);return i||Lc.set(e,i=function(t,e=Qc){let i=Object.create(null),n=Object.create(null),s=(t,e)=>{let i=n[t];if(null==i)n[t]=e;else if(i!=e)throw new Error("Key binding "+t+" is used both as a regular binding and as a multi-stroke prefix")},o=(t,n,o,r,a)=>{var l,c;let h=i[t]||(i[t]=Object.create(null)),u=n.split(/ (?!$)/).map(t=>function(t,e){const i=t.split(/-(?!$)/);let n,s,o,r,a=i[i.length-1];"Space"==a&&(a=" ");for(let t=0;t<i.length-1;++t){const a=i[t];if(/^(cmd|meta|m)$/i.test(a))r=!0;else if(/^a(lt)?$/i.test(a))n=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))o=!0;else{if(!/^mod$/i.test(a))throw new Error("Unrecognized modifier name: "+a);"mac"==e?r=!0:s=!0}}return n&&(a="Alt-"+a),s&&(a="Ctrl-"+a),r&&(a="Meta-"+a),o&&(a="Shift-"+a),a}(t,e));for(let e=1;e<u.length;e++){let i=u.slice(0,e).join(" ");s(i,!0),h[i]||(h[i]={preventDefault:!0,stopPropagation:!1,run:[e=>{let n=jc={view:e,prefix:i,scope:t};return setTimeout(()=>{jc==n&&(jc=null)},zc),!0}]})}let d=u.join(" ");s(d,!1);let f=h[d]||(h[d]={preventDefault:!1,stopPropagation:!1,run:(null===(c=null===(l=h._any)||void 0===l?void 0:l.run)||void 0===c?void 0:c.slice())||[]});o&&f.run.push(o),r&&(f.preventDefault=!0),a&&(f.stopPropagation=!0)};for(let n of t){let t=n.scope?n.scope.split(" "):["editor"];if(n.any)for(let e of t){let t=i[e]||(i[e]=Object.create(null));t._any||(t._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:s}=n;for(let e in t)t[e].run.push(t=>s(t,Bc))}let s=n[e]||n.key;if(s)for(let e of t)o(e,s,n.run,n.preventDefault,n.stopPropagation),n.shift&&o(e,"Shift-"+s,n.shift,n.preventDefault,n.stopPropagation)}return i}(e.reduce((t,e)=>t.concat(e),[]))),i}let jc=null;const zc=4e3;let Bc=null;function qc(t,e,i,n){Bc=e;let s=function(t){var e=!($o&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Co&&t.shiftKey&&t.key&&1==t.key.length||"Unidentified"==t.key)&&t.key||(t.shiftKey?ko:So)[t.keyCode]||t.key||"Unidentified";return"Esc"==e&&(e="Escape"),"Del"==e&&(e="Delete"),"Left"==e&&(e="ArrowLeft"),"Up"==e&&(e="ArrowUp"),"Right"==e&&(e="ArrowRight"),"Down"==e&&(e="ArrowDown"),e}(e),o=Vn(Hn(s,0))==s.length&&" "!=s,r="",a=!1,l=!1,c=!1;jc&&jc.view==i&&jc.scope==n&&(r=jc.prefix+" ",vl.indexOf(e.keyCode)<0&&(l=!0,jc=null));let h,u,d=new Set,f=t=>{if(t){for(let e of t.run)if(!d.has(e)&&(d.add(e),e(i)))return t.stopPropagation&&(c=!0),!0;t.preventDefault&&(t.stopPropagation&&(c=!0),l=!0)}return!1},p=t[n];return p&&(f(p[r+Dc(s,e,!o)])?a=!0:!o||!(e.altKey||e.metaKey||e.ctrlKey)||gr.windows&&e.ctrlKey&&e.altKey||gr.mac&&e.altKey&&!e.ctrlKey||!(h=So[e.keyCode])||h==s?o&&e.shiftKey&&f(p[r+Dc(s,e,!0)])&&(a=!0):(f(p[r+Dc(h,e,!0)])||e.shiftKey&&(u=ko[e.keyCode])!=s&&u!=h&&f(p[r+Dc(u,e,!1)]))&&(a=!0),!a&&f(p._any)&&(a=!0)),l&&(a=!0),a&&c&&e.stopPropagation(),Bc=null,a}class Zc{constructor(t,e,i,n,s){this.className=t,this.left=e,this.top=i,this.width=n,this.height=s}draw(){let t=document.createElement("div");return t.className=this.className,this.adjust(t),t}update(t,e){return e.className==this.className&&(this.adjust(t),!0)}adjust(t){t.style.left=this.left+"px",t.style.top=this.top+"px",null!=this.width&&(t.style.width=this.width+"px"),t.style.height=this.height+"px"}eq(t){return this.left==t.left&&this.top==t.top&&this.width==t.width&&this.height==t.height&&this.className==t.className}static forRange(t,e,i){if(i.empty){let n=t.coordsAtPos(i.head,i.assoc||1);if(!n)return[];let s=Fc(t);return[new Zc(e,n.left-s.left,n.top-s.top,null,n.bottom-n.top)]}return function(t,e,i){if(i.to<=t.viewport.from||i.from>=t.viewport.to)return[];let n=Math.max(i.from,t.viewport.from),s=Math.min(i.to,t.viewport.to),o=t.textDirection==Fr.LTR,r=t.contentDOM,a=r.getBoundingClientRect(),l=Fc(t),c=r.querySelector(".cm-line"),h=c&&window.getComputedStyle(c),u=a.left+(h?parseInt(h.paddingLeft)+Math.min(0,parseInt(h.textIndent)):0),d=a.right-(h?parseInt(h.paddingRight):0),f=el(t,n,1),p=el(t,s,-1),m=f.type==Ar.Text?f:null,g=p.type==Ar.Text?p:null;m&&(t.lineWrapping||f.widgetLineBreaks)&&(m=Xc(t,n,1,m));g&&(t.lineWrapping||p.widgetLineBreaks)&&(g=Xc(t,s,-1,g));if(m&&g&&m.from==g.from&&m.to==g.to)return y(O(i.from,i.to,m));{let e=m?O(i.from,null,m):b(f,!1),n=g?O(null,i.to,g):b(p,!0),s=[];return(m||f).to<(g||p).from-(m&&g?1:0)||f.widgetLineBreaks>1&&e.bottom+t.defaultLineHeight/2<n.top?s.push(v(u,e.bottom,d,n.top)):e.bottom<n.top&&t.elementAtHeight((e.bottom+n.top)/2).type==Ar.Text&&(e.bottom=n.top=(e.bottom+n.top)/2),y(e).concat(s).concat(y(n))}function v(t,i,n,s){return new Zc(e,t-l.left,i-l.top,n-t,s-i)}function y({top:t,bottom:e,horizontal:i}){let n=[];for(let s=0;s<i.length;s+=2)n.push(v(i[s],t,i[s+1],e));return n}function O(e,i,n){let s=1e9,r=-1e9,a=[];function l(e,i,l,c,h){let f=t.coordsAtPos(e,e==n.to?-2:2),p=t.coordsAtPos(l,l==n.from?2:-2);f&&p&&(s=Math.min(f.top,p.top,s),r=Math.max(f.bottom,p.bottom,r),h==Fr.LTR?a.push(o&&i?u:f.left,o&&c?d:p.right):a.push(!o&&c?u:p.left,!o&&i?d:f.right))}let c=null!=e?e:n.from,h=null!=i?i:n.to;for(let n of t.visibleRanges)if(n.to>c&&n.from<h)for(let s=Math.max(n.from,c),o=Math.min(n.to,h);;){let n=t.state.doc.lineAt(s);for(let r of t.bidiSpans(n)){let t=r.from+n.from,a=r.to+n.from;if(t>=o)break;a>s&&l(Math.max(t,s),null==e&&t<=c,Math.min(a,o),null==i&&a>=h,r.dir)}if(s=n.to+1,s>=o)break}return 0==a.length&&l(c,null==e,h,null==i,t.textDirection),{top:s,bottom:r,horizontal:a}}function b(t,e){let i=a.top+(e?t.top:t.bottom);return{top:i,bottom:i,horizontal:[]}}}(t,e,i)}}function Fc(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Fr.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function Xc(t,e,i,n){let s=t.coordsAtPos(e,2*i);if(!s)return n;let o=t.dom.getBoundingClientRect(),r=(s.top+s.bottom)/2,a=t.posAtCoords({x:o.left+1,y:r}),l=t.posAtCoords({x:o.right-1,y:r});return null==a||null==l?n:{from:Math.max(n.from,Math.min(a,l)),to:Math.min(n.to,Math.max(a,l))}}class Hc{constructor(t,e){this.view=t,this.layer=e,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=t.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),e.above&&this.dom.classList.add("cm-layer-above"),e.class&&this.dom.classList.add(e.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(t.state),t.requestMeasure(this.measureReq),e.mount&&e.mount(this.dom,t)}update(t){t.startState.facet(Wc)!=t.state.facet(Wc)&&this.setOrder(t.state),(this.layer.update(t,this.dom)||t.geometryChanged)&&(this.scale(),t.view.requestMeasure(this.measureReq))}docViewUpdate(t){!1!==this.layer.updateOnDocViewUpdate&&t.requestMeasure(this.measureReq)}setOrder(t){let e=0,i=t.facet(Wc);for(;e<i.length&&i[e]!=this.layer;)e++;this.dom.style.zIndex=String((this.layer.above?150:-1)-e)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:t,scaleY:e}=this.view;t==this.scaleX&&e==this.scaleY||(this.scaleX=t,this.scaleY=e,this.dom.style.transform=`scale(${1/t}, ${1/e})`)}draw(t){if(t.length!=this.drawn.length||t.some((t,e)=>{return i=t,n=this.drawn[e],!(i.constructor==n.constructor&&i.eq(n));var i,n})){let e=this.dom.firstChild,i=0;for(let n of t)n.update&&e&&n.constructor&&this.drawn[i].constructor&&n.update(e,this.drawn[i])?(e=e.nextSibling,i++):this.dom.insertBefore(n.draw(),e);for(;e;){let t=e.nextSibling;e.remove(),e=t}this.drawn=t}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const Wc=cs.define();function Vc(t){return[Pa.define(e=>new Hc(e,t)),Wc.of(t)]}const Yc=cs.define({combine:t=>Ks(t,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,e)=>Math.min(t,e),drawRangeCursor:(t,e)=>t||e})});function Uc(t={}){return[Yc.of(t),Kc,th,eh,ba.of(!0)]}function Gc(t){return t.startState.facet(Yc)!=t.state.facet(Yc)}const Kc=Vc({above:!0,markers(t){let{state:e}=t,i=e.facet(Yc),n=[];for(let s of e.selection.ranges){let o=s==e.selection.main;if(s.empty||i.drawRangeCursor){let e=o?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",i=s.empty?s:rs.cursor(s.head,s.head>s.anchor?-1:1);for(let s of Zc.forRange(t,e,i))n.push(s)}}return n},update(t,e){t.transactions.some(t=>t.selection)&&(e.style.animationName="cm-blink"==e.style.animationName?"cm-blink2":"cm-blink");let i=Gc(t);return i&&Jc(t.state,e),t.docChanged||t.selectionSet||i},mount(t,e){Jc(e.state,t)},class:"cm-cursorLayer"});function Jc(t,e){e.style.animationDuration=t.facet(Yc).cursorBlinkRate+"ms"}const th=Vc({above:!1,markers:t=>t.state.selection.ranges.map(e=>e.empty?[]:Zc.forRange(t,"cm-selectionBackground",e)).reduce((t,e)=>t.concat(e)),update:(t,e)=>t.docChanged||t.selectionSet||t.viewportChanged||Gc(t),class:"cm-selectionLayer"}),eh=ws.highest(Tc.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),ih=js.define({map:(t,e)=>null==t?null:e.mapPos(t)}),nh=gs.define({create:()=>null,update:(t,e)=>(null!=t&&(t=e.changes.mapPos(t)),e.effects.reduce((t,e)=>e.is(ih)?e.value:t,t))}),sh=Pa.fromClass(class{constructor(t){this.view=t,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(t){var e;let i=t.state.field(nh);null==i?null!=this.cursor&&(null===(e=this.cursor)||void 0===e||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(t.startState.field(nh)!=i||t.docChanged||t.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:t}=this,e=t.state.field(nh),i=null!=e&&t.coordsAtPos(e);if(!i)return null;let n=t.scrollDOM.getBoundingClientRect();return{left:i.left-n.left+t.scrollDOM.scrollLeft*t.scaleX,top:i.top-n.top+t.scrollDOM.scrollTop*t.scaleY,height:i.bottom-i.top}}drawCursor(t){if(this.cursor){let{scaleX:e,scaleY:i}=this.view;t?(this.cursor.style.left=t.left/e+"px",this.cursor.style.top=t.top/i+"px",this.cursor.style.height=t.height/i+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(t){this.view.state.field(nh)!=t&&this.view.dispatch({effects:ih.of(t)})}},{eventObservers:{dragover(t){this.setDropPos(this.view.posAtCoords({x:t.clientX,y:t.clientY}))},dragleave(t){t.target!=this.view.contentDOM&&this.view.contentDOM.contains(t.relatedTarget)||this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function oh(t,e,i,n,s){e.lastIndex=0;for(let o,r=t.iterRange(i,n),a=i;!r.next().done;a+=r.value.length)if(!r.lineBreak)for(;o=e.exec(r.value);)s(a+o.index,o)}class rh{constructor(t){const{regexp:e,decoration:i,decorate:n,boundary:s,maxLength:o=1e3}=t;if(!e.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=e,n)this.addMatch=(t,e,i,s)=>n(s,i,i+t[0].length,t,e);else if("function"==typeof i)this.addMatch=(t,e,n,s)=>{let o=i(t,e,n);o&&s(n,n+t[0].length,o)};else{if(!i)throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.addMatch=(t,e,n,s)=>s(n,n+t[0].length,i)}this.boundary=s,this.maxLength=o}createDeco(t){let e=new so,i=e.add.bind(e);for(let{from:e,to:n}of function(t,e){let i=t.visibleRanges;if(1==i.length&&i[0].from==t.viewport.from&&i[0].to==t.viewport.to)return i;let n=[];for(let{from:s,to:o}of i)s=Math.max(t.state.doc.lineAt(s).from,s-e),o=Math.min(t.state.doc.lineAt(o).to,o+e),n.length&&n[n.length-1].to>=s?n[n.length-1].to=o:n.push({from:s,to:o});return n}(t,this.maxLength))oh(t.state.doc,this.regexp,e,n,(e,n)=>this.addMatch(n,t,e,i));return e.finish()}updateDeco(t,e){let i=1e9,n=-1;return t.docChanged&&t.changes.iterChanges((e,s,o,r)=>{r>=t.view.viewport.from&&o<=t.view.viewport.to&&(i=Math.min(o,i),n=Math.max(r,n))}),t.viewportMoved||n-i>1e3?this.createDeco(t.view):n>-1?this.updateRange(t.view,e.map(t.changes),i,n):e}updateRange(t,e,i,n){for(let s of t.visibleRanges){let o=Math.max(s.from,i),r=Math.min(s.to,n);if(r>=o){let i=t.state.doc.lineAt(o),n=i.to<r?t.state.doc.lineAt(r):i,a=Math.max(s.from,i.from),l=Math.min(s.to,n.to);if(this.boundary){for(;o>i.from;o--)if(this.boundary.test(i.text[o-1-i.from])){a=o;break}for(;r<n.to;r++)if(this.boundary.test(n.text[r-n.from])){l=r;break}}let c,h=[],u=(t,e,i)=>h.push(i.range(t,e));if(i==n)for(this.regexp.lastIndex=a-i.from;(c=this.regexp.exec(i.text))&&c.index<l-i.from;)this.addMatch(c,t,c.index+i.from,u);else oh(t.state.doc,this.regexp,a,l,(e,i)=>this.addMatch(i,t,e,u));e=e.update({filterFrom:a,filterTo:l,filter:(t,e)=>t<a||e>l,add:h})}}return e}}const ah=null!=/x/.unicode?"gu":"g",lh=new RegExp("[\0-\b\n--Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\ufeff-]",ah),ch={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let hh=null;const uh=cs.define({combine(t){let e=Ks(t,{render:null,specialChars:lh,addSpecialChars:null});return(e.replaceTabs=!function(){var t;if(null==hh&&"undefined"!=typeof document&&document.body){let e=document.body.style;hh=null!=(null!==(t=e.tabSize)&&void 0!==t?t:e.MozTabSize)}return hh||!1}())&&(e.specialChars=new RegExp("\t|"+e.specialChars.source,ah)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,ah)),e}});function dh(t={}){return[uh.of(t),fh||(fh=Pa.fromClass(class{constructor(t){this.view=t,this.decorations=Mr.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(t.state.facet(uh)),this.decorations=this.decorator.createDeco(t)}makeDecorator(t){return new rh({regexp:t.specialChars,decoration:(e,i,n)=>{let{doc:s}=i.state,o=Hn(e[0],0);if(9==o){let t=s.lineAt(n),e=i.state.tabSize,o=go(t.text,e,n-t.from);return Mr.replace({widget:new mh((e-o%e)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[o]||(this.decorationCache[o]=Mr.replace({widget:new ph(t,o)}))},boundary:t.replaceTabs?void 0:/[^]/})}update(t){let e=t.state.facet(uh);t.startState.facet(uh)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(t.view)):this.decorations=this.decorator.updateDeco(t,this.decorations)}},{decorations:t=>t.decorations}))]}let fh=null;class ph extends Er{constructor(t,e){super(),this.options=t,this.code=e}eq(t){return t.code==this.code}toDOM(t){let e=function(t){return t>=32?"•":10==t?"␤":String.fromCharCode(9216+t)}(this.code),i=t.state.phrase("Control character")+" "+(ch[this.code]||"0x"+this.code.toString(16)),n=this.options.render&&this.options.render(this.code,i,e);if(n)return n;let s=document.createElement("span");return s.textContent=e,s.title=i,s.setAttribute("aria-label",i),s.className="cm-specialChar",s}ignoreEvent(){return!1}}class mh extends Er{constructor(t){super(),this.width=t}eq(t){return t.width==this.width}toDOM(){let t=document.createElement("span");return t.textContent="\t",t.className="cm-tab",t.style.width=this.width+"px",t}ignoreEvent(){return!1}}const gh=Mr.line({class:"cm-activeLine"}),vh=Pa.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,i=[];for(let n of t.state.selection.ranges){let s=t.lineBlockAt(n.head);s.from>e&&(i.push(gh.range(s.from)),e=s.from)}return Mr.set(i)}},{decorations:t=>t.decorations});const yh=2e3;function Oh(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1),n=t.state.doc.lineAt(i),s=i-n.from,o=s>yh?-1:s==n.length?function(t,e){let i=t.coordsAtPos(t.viewport.from);return i?Math.round(Math.abs((i.left-e)/t.defaultCharacterWidth)):-1}(t,e.clientX):go(n.text,t.state.tabSize,i-n.from);return{line:n.number,col:o,off:s}}function bh(t,e){let i=Oh(t,e),n=t.state.selection;return i?{update(t){if(t.docChanged){let e=t.changes.mapPos(t.startState.doc.line(i.line).from),s=t.state.doc.lineAt(e);i={line:s.number,col:i.col,off:Math.min(i.off,s.length)},n=n.map(t.changes)}},get(e,s,o){let r=Oh(t,e);if(!r)return n;let a=function(t,e,i){let n=Math.min(e.line,i.line),s=Math.max(e.line,i.line),o=[];if(e.off>yh||i.off>yh||e.col<0||i.col<0){let r=Math.min(e.off,i.off),a=Math.max(e.off,i.off);for(let e=n;e<=s;e++){let i=t.doc.line(e);i.length<=a&&o.push(rs.range(i.from+r,i.to+a))}}else{let r=Math.min(e.col,i.col),a=Math.max(e.col,i.col);for(let e=n;e<=s;e++){let i=t.doc.line(e),n=vo(i.text,r,t.tabSize,!0);if(n<0)o.push(rs.cursor(i.to));else{let e=vo(i.text,a,t.tabSize);o.push(rs.range(i.from+n,i.from+e))}}}return o}(t.state,i,r);return a.length?o?rs.create(a.concat(n.ranges)):rs.create(a):n}}:null}function xh(t){let e=(null==t?void 0:t.eventFilter)||(t=>t.altKey&&0==t.button);return Tc.mouseSelectionStyle.of((t,i)=>e(i)?bh(t,i):null)}const wh={Alt:[18,t=>!!t.altKey],Control:[17,t=>!!t.ctrlKey],Shift:[16,t=>!!t.shiftKey],Meta:[91,t=>!!t.metaKey]},_h={style:"cursor: crosshair"};function Sh(t={}){let[e,i]=wh[t.key||"Alt"],n=Pa.fromClass(class{constructor(t){this.view=t,this.isDown=!1}set(t){this.isDown!=t&&(this.isDown=t,this.view.update([]))}},{eventObservers:{keydown(t){this.set(t.keyCode==e||i(t))},keyup(t){t.keyCode!=e&&i(t)||this.set(!1)},mousemove(t){this.set(i(t))}}});return[n,Tc.contentAttributes.of(t=>{var e;return(null===(e=t.plugin(n))||void 0===e?void 0:e.isDown)?_h:null})]}const kh="-10000px";class $h{constructor(t,e,i,n){this.facet=e,this.createTooltipView=i,this.removeTooltipView=n,this.input=t.state.facet(e),this.tooltips=this.input.filter(t=>t);let s=null;this.tooltipViews=this.tooltips.map(t=>s=i(t,s))}update(t,e){var i;let n=t.state.facet(this.facet),s=n.filter(t=>t);if(n===this.input){for(let e of this.tooltipViews)e.update&&e.update(t);return!1}let o=[],r=e?[]:null;for(let i=0;i<s.length;i++){let n=s[i],a=-1;if(n){for(let t=0;t<this.tooltips.length;t++){let e=this.tooltips[t];e&&e.create==n.create&&(a=t)}if(a<0)o[i]=this.createTooltipView(n,i?o[i-1]:null),r&&(r[i]=!!n.above);else{let n=o[i]=this.tooltipViews[a];r&&(r[i]=e[a]),n.update&&n.update(t)}}}for(let t of this.tooltipViews)o.indexOf(t)<0&&(this.removeTooltipView(t),null===(i=t.destroy)||void 0===i||i.call(t));return e&&(r.forEach((t,i)=>e[i]=t),e.length=r.length),this.input=n,this.tooltips=s,this.tooltipViews=o,!0}}function Ch(t){let e=t.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const Th=cs.define({combine:t=>{var e,i,n;return{position:gr.ios?"absolute":(null===(e=t.find(t=>t.position))||void 0===e?void 0:e.position)||"fixed",parent:(null===(i=t.find(t=>t.parent))||void 0===i?void 0:i.parent)||null,tooltipSpace:(null===(n=t.find(t=>t.tooltipSpace))||void 0===n?void 0:n.tooltipSpace)||Ch}}}),Ph=new WeakMap,Eh=Pa.fromClass(class{constructor(t){this.view=t,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=t.state.facet(Th);this.position=e.position,this.parent=e.parent,this.classes=t.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver="function"==typeof ResizeObserver?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new $h(t,Dh,(t,e)=>this.createTooltip(t,e),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver="function"==typeof IntersectionObserver?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),t.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let t of this.manager.tooltipViews)this.intersectionObserver.observe(t.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(t){t.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(t,this.above);e&&this.observeIntersection();let i=e||t.geometryChanged,n=t.state.facet(Th);if(n.position!=this.position&&!this.madeAbsolute){this.position=n.position;for(let t of this.manager.tooltipViews)t.dom.style.position=this.position;i=!0}if(n.parent!=this.parent){this.parent&&this.container.remove(),this.parent=n.parent,this.createContainer();for(let t of this.manager.tooltipViews)this.container.appendChild(t.dom);i=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);i&&this.maybeMeasure()}createTooltip(t,e){let i=t.create(this.view),n=e?e.dom:null;if(i.dom.classList.add("cm-tooltip"),t.arrow&&!i.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let t=document.createElement("div");t.className="cm-tooltip-arrow",i.dom.appendChild(t)}return i.dom.style.position=this.position,i.dom.style.top=kh,i.dom.style.left="0px",this.container.insertBefore(i.dom,n),i.mount&&i.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(i.dom),i}destroy(){var t,e,i;this.view.win.removeEventListener("resize",this.measureSoon);for(let e of this.manager.tooltipViews)e.dom.remove(),null===(t=e.destroy)||void 0===t||t.call(e);this.parent&&this.container.remove(),null===(e=this.resizeObserver)||void 0===e||e.disconnect(),null===(i=this.intersectionObserver)||void 0===i||i.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=1,e=1,i=!1;if("fixed"==this.position&&this.manager.tooltipViews.length){let{dom:t}=this.manager.tooltipViews[0];if(gr.gecko)i=t.offsetParent!=this.container.ownerDocument.body;else if(t.style.top==kh&&"0px"==t.style.left){let e=t.getBoundingClientRect();i=Math.abs(e.top+1e4)>1||Math.abs(e.left)>1}}if(i||"absolute"==this.position)if(this.parent){let i=this.parent.getBoundingClientRect();i.width&&i.height&&(t=i.width/this.parent.offsetWidth,e=i.height/this.parent.offsetHeight)}else({scaleX:t,scaleY:e}=this.view.viewState);let n=this.view.scrollDOM.getBoundingClientRect(),s=ja(this.view);return{visible:{left:n.left+s.left,top:n.top+s.top,right:n.right-s.right,bottom:n.bottom-s.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((t,e)=>{let i=this.manager.tooltipViews[e];return i.getCoords?i.getCoords(t.pos):this.view.coordsAtPos(t.pos)}),size:this.manager.tooltipViews.map(({dom:t})=>t.getBoundingClientRect()),space:this.view.state.facet(Th).tooltipSpace(this.view),scaleX:t,scaleY:e,makeAbsolute:i}}writeMeasure(t){var e;if(t.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let t of this.manager.tooltipViews)t.dom.style.position="absolute"}let{visible:i,space:n,scaleX:s,scaleY:o}=t,r=[];for(let a=0;a<this.manager.tooltips.length;a++){let l=this.manager.tooltips[a],c=this.manager.tooltipViews[a],{dom:h}=c,u=t.pos[a],d=t.size[a];if(!u||!1!==l.clip&&(u.bottom<=Math.max(i.top,n.top)||u.top>=Math.min(i.bottom,n.bottom)||u.right<Math.max(i.left,n.left)-.1||u.left>Math.min(i.right,n.right)+.1)){h.style.top=kh;continue}let f=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=f?7:0,m=d.right-d.left,g=null!==(e=Ph.get(c))&&void 0!==e?e:d.bottom-d.top,v=c.offset||Qh,y=this.view.textDirection==Fr.LTR,O=d.width>n.right-n.left?y?n.left:n.right-d.width:y?Math.max(n.left,Math.min(u.left-(f?14:0)+v.x,n.right-m)):Math.min(Math.max(n.left,u.left-m+(f?14:0)-v.x),n.right-m),b=this.above[a];!l.strictSide&&(b?u.top-g-p-v.y<n.top:u.bottom+g+p+v.y>n.bottom)&&b==n.bottom-u.bottom>u.top-n.top&&(b=this.above[a]=!b);let x=(b?u.top-n.top:n.bottom-u.bottom)-p;if(x<g&&!1!==c.resize){if(x<this.view.defaultLineHeight){h.style.top=kh;continue}Ph.set(c,g),h.style.height=(g=x)/o+"px"}else h.style.height&&(h.style.height="");let w=b?u.top-g-p-v.y:u.bottom+p+v.y,_=O+m;if(!0!==c.overlap)for(let t of r)t.left<_&&t.right>O&&t.top<w+g&&t.bottom>w&&(w=b?t.top-g-2-p:t.bottom+p+2);if("absolute"==this.position?(h.style.top=(w-t.parent.top)/o+"px",Ah(h,(O-t.parent.left)/s)):(h.style.top=w/o+"px",Ah(h,O/s)),f){let t=u.left+(y?v.x:-v.x)-(O+14-7);f.style.left=t/s+"px"}!0!==c.overlap&&r.push({left:O,top:w,right:_,bottom:w+g}),h.classList.toggle("cm-tooltip-above",b),h.classList.toggle("cm-tooltip-below",!b),c.positioned&&c.positioned(t.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let t of this.manager.tooltipViews)t.dom.style.top=kh}},{eventObservers:{scroll(){this.maybeMeasure()}}});function Ah(t,e){let i=parseInt(t.style.left,10);(isNaN(i)||Math.abs(e-i)>1)&&(t.style.left=e+"px")}const Mh=Tc.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),Qh={x:0,y:0},Dh=cs.define({enables:[Eh,Mh]}),Rh=cs.define({combine:t=>t.reduce((t,e)=>t.concat(e),[])});class Ih{static create(t){return new Ih(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new $h(t,Rh,(t,e)=>this.createHostedView(t,e),t=>t.dom.remove())}createHostedView(t,e){let i=t.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,e?e.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}mount(t){for(let e of this.manager.tooltipViews)e.mount&&e.mount(t);this.mounted=!0}positioned(t){for(let e of this.manager.tooltipViews)e.positioned&&e.positioned(t)}update(t){this.manager.update(t)}destroy(){var t;for(let e of this.manager.tooltipViews)null===(t=e.destroy)||void 0===t||t.call(e)}passProp(t){let e;for(let i of this.manager.tooltipViews){let n=i[t];if(void 0!==n)if(void 0===e)e=n;else if(e!==n)return}return e}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const Lh=Dh.compute([Rh],t=>{let e=t.facet(Rh);return 0===e.length?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var e;return null!==(e=t.end)&&void 0!==e?e:t.pos})),create:Ih.create,above:e[0].above,arrow:e.some(t=>t.arrow)}});class Nh{constructor(t,e,i,n,s){this.view=t,this.source=e,this.field=i,this.setHover=n,this.hoverTime=s,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:t.dom,time:0},this.checkHover=this.checkHover.bind(this),t.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),t.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let t=Date.now()-this.lastMove.time;t<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-t):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:t,lastMove:e}=this,i=t.docView.nearest(e.target);if(!i)return;let n,s=1;if(i instanceof Or)n=i.posAtStart;else{if(n=t.posAtCoords(e),null==n)return;let i=t.coordsAtPos(n);if(!i||e.y<i.top||e.y>i.bottom||e.x<i.left-t.defaultCharacterWidth||e.x>i.right+t.defaultCharacterWidth)return;let o=t.bidiSpans(t.state.doc.lineAt(n)).find(t=>t.from<=n&&t.to>=n),r=o&&o.dir==Fr.RTL?-1:1;s=e.x<i.left?-r:r}let o=this.source(t,n,s);if(null==o?void 0:o.then){let e=this.pending={pos:n};o.then(i=>{this.pending==e&&(this.pending=null,!i||Array.isArray(i)&&!i.length||t.dispatch({effects:this.setHover.of(Array.isArray(i)?i:[i])}))},e=>ka(t.state,e,"hover tooltip"))}else!o||Array.isArray(o)&&!o.length||t.dispatch({effects:this.setHover.of(Array.isArray(o)?o:[o])})}get tooltip(){let t=this.view.plugin(Eh),e=t?t.manager.tooltips.findIndex(t=>t.create==Ih.create):-1;return e>-1?t.manager.tooltipViews[e]:null}mousemove(t){var e,i;this.lastMove={x:t.clientX,y:t.clientY,target:t.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:n,tooltip:s}=this;if(n.length&&s&&!function(t,e){let i,{left:n,right:s,top:o,bottom:r}=t.getBoundingClientRect();if(i=t.querySelector(".cm-tooltip-arrow")){let t=i.getBoundingClientRect();o=Math.min(t.top,o),r=Math.max(t.bottom,r)}return e.clientX>=n-jh&&e.clientX<=s+jh&&e.clientY>=o-jh&&e.clientY<=r+jh}(s.dom,t)||this.pending){let{pos:s}=n[0]||this.pending,o=null!==(i=null===(e=n[0])||void 0===e?void 0:e.end)&&void 0!==i?i:s;(s==o?this.view.posAtCoords(this.lastMove)==s:function(t,e,i,n,s){let o=t.scrollDOM.getBoundingClientRect(),r=t.documentTop+t.documentPadding.top+t.contentHeight;if(o.left>n||o.right<n||o.top>s||Math.min(o.bottom,r)<s)return!1;let a=t.posAtCoords({x:n,y:s},!1);return a>=e&&a<=i}(this.view,s,o,t.clientX,t.clientY))||(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(t){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:e}=this;if(e.length){let{tooltip:e}=this;e&&e.dom.contains(t.relatedTarget)?this.watchTooltipLeave(e.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(t){let e=i=>{t.removeEventListener("mouseleave",e),this.active.length&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};t.addEventListener("mouseleave",e)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const jh=4;function zh(t,e={}){let i=js.define(),n=gs.define({create:()=>[],update(t,n){if(t.length&&(e.hideOnChange&&(n.docChanged||n.selection)?t=[]:e.hideOn&&(t=t.filter(t=>!e.hideOn(n,t))),n.docChanged)){let e=[];for(let i of t){let t=n.changes.mapPos(i.pos,-1,Un.TrackDel);if(null!=t){let s=Object.assign(Object.create(null),i);s.pos=t,null!=s.end&&(s.end=n.changes.mapPos(s.end)),e.push(s)}}t=e}for(let e of n.effects)e.is(i)&&(t=e.value),e.is(qh)&&(t=[]);return t},provide:t=>Rh.from(t)});return{active:n,extension:[n,Pa.define(s=>new Nh(s,t,n,i,e.hoverTime||300)),Lh]}}function Bh(t,e){let i=t.plugin(Eh);if(!i)return null;let n=i.manager.tooltips.indexOf(e);return n<0?null:i.manager.tooltipViews[n]}const qh=js.define();const Zh=cs.define({combine(t){let e,i;for(let n of t)e=e||n.topContainer,i=i||n.bottomContainer;return{topContainer:e,bottomContainer:i}}});function Fh(t,e){let i=t.plugin(Xh),n=i?i.specs.indexOf(e):-1;return n>-1?i.panels[n]:null}const Xh=Pa.fromClass(class{constructor(t){this.input=t.state.facet(Vh),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(e=>e(t));let e=t.state.facet(Zh);this.top=new Hh(t,!0,e.topContainer),this.bottom=new Hh(t,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(t){let e=t.state.facet(Zh);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Hh(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Hh(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let i=t.state.facet(Vh);if(i!=this.input){let e=i.filter(t=>t),n=[],s=[],o=[],r=[];for(let i of e){let e,a=this.specs.indexOf(i);a<0?(e=i(t.view),r.push(e)):(e=this.panels[a],e.update&&e.update(t)),n.push(e),(e.top?s:o).push(e)}this.specs=e,this.panels=n,this.top.sync(s),this.bottom.sync(o);for(let t of r)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}else for(let e of this.panels)e.update&&e.update(t)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:t=>Tc.scrollMargins.of(e=>{let i=e.plugin(t);return i&&{top:i.top.scrollMargin(),bottom:i.bottom.scrollMargin()}})});class Hh{constructor(t,e,i){this.view=t,this.top=e,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(t){for(let e of this.panels)e.destroy&&t.indexOf(e)<0&&e.destroy();this.panels=t,this.syncDOM()}syncDOM(){if(0==this.panels.length)return void(this.dom&&(this.dom.remove(),this.dom=void 0));if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let t=this.dom.firstChild;for(let e of this.panels)if(e.dom.parentNode==this.dom){for(;t!=e.dom;)t=Wh(t);t=t.nextSibling}else this.dom.insertBefore(e.dom,t);for(;t;)t=Wh(t)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(this.container&&this.classes!=this.view.themeClasses){for(let t of this.classes.split(" "))t&&this.container.classList.remove(t);for(let t of(this.classes=this.view.themeClasses).split(" "))t&&this.container.classList.add(t)}}}function Wh(t){let e=t.nextSibling;return t.remove(),e}const Vh=cs.define({enables:Xh});class Yh extends Js{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}Yh.prototype.elementClass="",Yh.prototype.toDOM=void 0,Yh.prototype.mapMode=Un.TrackBefore,Yh.prototype.startSide=Yh.prototype.endSide=-1,Yh.prototype.point=!0;const Uh=cs.define(),Gh=cs.define(),Kh={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>no.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},Jh=cs.define();function tu(t){return[iu(),Jh.of({...Kh,...t})]}const eu=cs.define({combine:t=>t.some(t=>t)});function iu(t){let e=[nu];return t&&!1===t.fixed&&e.push(eu.of(!0)),e}const nu=Pa.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(Jh).map(e=>new au(t,e)),this.fixed=!t.state.facet(eu);for(let t of this.gutters)"after"==t.config.side?this.getDOMAfter().appendChild(t.dom):this.dom.appendChild(t.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(t){if(this.updateGutters(t)){let e=this.prevViewport,i=t.view.viewport,n=Math.min(e.to,i.to)-Math.max(e.from,i.from);this.syncGutters(n<.8*(i.to-i.from))}if(t.geometryChanged){let t=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=t,this.domAfter&&(this.domAfter.style.minHeight=t)}this.view.state.facet(eu)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let i=no.iter(this.view.state.facet(Uh),this.view.viewport.from),n=[],s=this.gutters.map(t=>new ru(t,this.view.viewport,-this.view.documentPadding.top));for(let t of this.view.viewportLineBlocks)if(n.length&&(n=[]),Array.isArray(t.type)){let e=!0;for(let o of t.type)if(o.type==Ar.Text&&e){ou(i,n,o.from);for(let t of s)t.line(this.view,o,n);e=!1}else if(o.widget)for(let t of s)t.widget(this.view,o)}else if(t.type==Ar.Text){ou(i,n,t.from);for(let e of s)e.line(this.view,t,n)}else if(t.widget)for(let e of s)e.widget(this.view,t);for(let t of s)t.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(Jh),i=t.state.facet(Jh),n=t.docChanged||t.heightChanged||t.viewportChanged||!no.eq(t.startState.facet(Uh),t.state.facet(Uh),t.view.viewport.from,t.view.viewport.to);if(e==i)for(let e of this.gutters)e.update(t)&&(n=!0);else{n=!0;let s=[];for(let n of i){let i=e.indexOf(n);i<0?s.push(new au(this.view,n)):(this.gutters[i].update(t),s.push(this.gutters[i]))}for(let t of this.gutters)t.dom.remove(),s.indexOf(t)<0&&t.destroy();for(let t of s)"after"==t.config.side?this.getDOMAfter().appendChild(t.dom):this.dom.appendChild(t.dom);this.gutters=s}return n}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>Tc.scrollMargins.of(e=>{let i=e.plugin(t);if(!i||0==i.gutters.length||!i.fixed)return null;let n=i.dom.offsetWidth*e.scaleX,s=i.domAfter?i.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Fr.LTR?{left:n,right:s}:{right:n,left:s}})});function su(t){return Array.isArray(t)?t:[t]}function ou(t,e,i){for(;t.value&&t.from<=i;)t.from==i&&e.push(t.value),t.next()}class ru{constructor(t,e,i){this.gutter=t,this.height=i,this.i=0,this.cursor=no.iter(t.markers,e.from)}addElement(t,e,i){let{gutter:n}=this,s=(e.top-this.height)/t.scaleY,o=e.height/t.scaleY;if(this.i==n.elements.length){let e=new lu(t,o,s,i);n.elements.push(e),n.dom.appendChild(e.dom)}else n.elements[this.i].update(t,o,s,i);this.height=e.bottom,this.i++}line(t,e,i){let n=[];ou(this.cursor,n,e.from),i.length&&(n=n.concat(i));let s=this.gutter.config.lineMarker(t,e,n);s&&n.unshift(s);let o=this.gutter;(0!=n.length||o.config.renderEmptyElements)&&this.addElement(t,e,n)}widget(t,e){let i=this.gutter.config.widgetMarker(t,e.widget,e),n=i?[i]:null;for(let i of t.state.facet(Gh)){let s=i(t,e.widget,e);s&&(n||(n=[])).push(s)}n&&this.addElement(t,e,n)}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let e=t.elements.pop();t.dom.removeChild(e.dom),e.destroy()}}}class au{constructor(t,e){this.view=t,this.config=e,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in e.domEventHandlers)this.dom.addEventListener(i,n=>{let s,o=n.target;if(o!=this.dom&&this.dom.contains(o)){for(;o.parentNode!=this.dom;)o=o.parentNode;let t=o.getBoundingClientRect();s=(t.top+t.bottom)/2}else s=n.clientY;let r=t.lineBlockAtHeight(s-t.documentTop);e.domEventHandlers[i](t,r,n)&&n.preventDefault()});this.markers=su(e.markers(t)),e.initialSpacer&&(this.spacer=new lu(t,0,0,[e.initialSpacer(t)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(t){let e=this.markers;if(this.markers=su(this.config.markers(t.view)),this.spacer&&this.config.updateSpacer){let e=this.config.updateSpacer(this.spacer.markers[0],t);e!=this.spacer.markers[0]&&this.spacer.update(t.view,0,0,[e])}let i=t.view.viewport;return!no.eq(this.markers,e,i.from,i.to)||!!this.config.lineMarkerChange&&this.config.lineMarkerChange(t)}destroy(){for(let t of this.elements)t.destroy()}}class lu{constructor(t,e,i,n){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,e,i,n)}update(t,e,i,n){this.height!=e&&(this.height=e,this.dom.style.height=e+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),function(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(!t[i].compare(e[i]))return!1;return!0}(this.markers,n)||this.setMarkers(t,n)}setMarkers(t,e){let i="cm-gutterElement",n=this.dom.firstChild;for(let s=0,o=0;;){let r=o,a=s<e.length?e[s++]:null,l=!1;if(a){let t=a.elementClass;t&&(i+=" "+t);for(let t=o;t<this.markers.length;t++)if(this.markers[t].compare(a)){r=t,l=!0;break}}else r=this.markers.length;for(;o<r;){let t=this.markers[o++];if(t.toDOM){t.destroy(n);let e=n.nextSibling;n.remove(),n=e}}if(!a)break;a.toDOM&&(l?n=n.nextSibling:this.dom.insertBefore(a.toDOM(t),n)),l&&o++}this.dom.className=i,this.markers=e}destroy(){this.setMarkers(null,[])}}const cu=cs.define(),hu=cs.define(),uu=cs.define({combine:t=>Ks(t,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(t,e){let i=Object.assign({},t);for(let t in e){let n=i[t],s=e[t];i[t]=n?(t,e,i)=>n(t,e,i)||s(t,e,i):s}return i}})});class du extends Yh{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function fu(t,e){return t.state.facet(uu).formatNumber(e,t.state)}const pu=Jh.compute([uu],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:t=>t.state.facet(cu),lineMarker:(t,e,i)=>i.some(t=>t.toDOM)?null:new du(fu(t,t.state.doc.lineAt(e.from).number)),widgetMarker:(t,e,i)=>{for(let n of t.state.facet(hu)){let s=n(t,e,i);if(s)return s}return null},lineMarkerChange:t=>t.startState.facet(uu)!=t.state.facet(uu),initialSpacer:t=>new du(fu(t,gu(t.state.doc.lines))),updateSpacer(t,e){let i=fu(e.view,gu(e.view.state.doc.lines));return i==t.number?t:new du(i)},domEventHandlers:t.facet(uu).domEventHandlers,side:"before"}));function mu(t={}){return[uu.of(t),iu(),pu]}function gu(t){let e=9;for(;e<t;)e=10*e+9;return e}const vu=new class extends Yh{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},yu=Uh.compute(["selection"],t=>{let e=[],i=-1;for(let n of t.selection.ranges){let s=t.doc.lineAt(n.head).from;s>i&&(i=s,e.push(vu.range(s)))}return no.of(e)});const Ou=1024;let bu=0;class xu{constructor(t,e){this.from=t,this.to=e}}class wu{constructor(t={}){this.id=bu++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof t&&(t=ku.match(t)),e=>{let i=t(e);return void 0===i?null:[this,i]}}}wu.closedBy=new wu({deserialize:t=>t.split(" ")}),wu.openedBy=new wu({deserialize:t=>t.split(" ")}),wu.group=new wu({deserialize:t=>t.split(" ")}),wu.isolate=new wu({deserialize:t=>{if(t&&"rtl"!=t&&"ltr"!=t&&"auto"!=t)throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),wu.contextHash=new wu({perNode:!0}),wu.lookAhead=new wu({perNode:!0}),wu.mounted=new wu({perNode:!0});class _u{constructor(t,e,i){this.tree=t,this.overlay=e,this.parser=i}static get(t){return t&&t.props&&t.props[wu.mounted.id]}}const Su=Object.create(null);class ku{constructor(t,e,i,n=0){this.name=t,this.props=e,this.id=i,this.flags=n}static define(t){let e=t.props&&t.props.length?Object.create(null):Su,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),n=new ku(t.name||"",e,t.id,i);if(t.props)for(let i of t.props)if(Array.isArray(i)||(i=i(n)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[i[0].id]=i[1]}return n}prop(t){return this.props[t.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(t){if("string"==typeof t){if(this.name==t)return!0;let e=this.prop(wu.group);return!!e&&e.indexOf(t)>-1}return this.id==t}static match(t){let e=Object.create(null);for(let i in t)for(let n of i.split(" "))e[n]=t[i];return t=>{for(let i=t.prop(wu.group),n=-1;n<(i?i.length:0);n++){let s=e[n<0?t.name:i[n]];if(s)return s}}}}ku.none=new ku("",Object.create(null),0,8);class $u{constructor(t){this.types=t;for(let e=0;e<t.length;e++)if(t[e].id!=e)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let e=[];for(let i of this.types){let n=null;for(let e of t){let t=e(i);t&&(n||(n=Object.assign({},i.props)),n[t[0].id]=t[1])}e.push(n?new ku(i.name,n,i.id,i.flags):i)}return new $u(e)}}const Cu=new WeakMap,Tu=new WeakMap;var Pu;!function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays"}(Pu||(Pu={}));class Eu{constructor(t,e,i,n,s){if(this.type=t,this.children=e,this.positions=i,this.length=n,this.props=null,s&&s.length){this.props=Object.create(null);for(let[t,e]of s)this.props["number"==typeof t?t:t.id]=e}}toString(){let t=_u.get(this);if(t&&!t.overlay)return t.tree.toString();let e="";for(let t of this.children){let i=t.toString();i&&(e&&(e+=","),e+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(e.length?"("+e+")":""):e}cursor(t=0){return new Zu(this.topNode,t)}cursorAt(t,e=0,i=0){let n=Cu.get(this)||this.topNode,s=new Zu(n);return s.moveTo(t,e),Cu.set(this,s._tree),s}get topNode(){return new Iu(this,0,0,null)}resolve(t,e=0){let i=Du(Cu.get(this)||this.topNode,t,e,!1);return Cu.set(this,i),i}resolveInner(t,e=0){let i=Du(Tu.get(this)||this.topNode,t,e,!0);return Tu.set(this,i),i}resolveStack(t,e=0){return function(t,e,i){let n=t.resolveInner(e,i),s=null;for(let t=n instanceof Iu?n:n.context.parent;t;t=t.parent)if(t.index<0){let o=t.parent;(s||(s=[n])).push(o.resolve(e,i)),t=o}else{let o=_u.get(t.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let r=new Iu(o.tree,o.overlay[0].from+t.from,-1,t);(s||(s=[n])).push(Du(r,e,i,!1))}}return s?Bu(s):n}(this,t,e)}iterate(t){let{enter:e,leave:i,from:n=0,to:s=this.length}=t,o=t.mode||0,r=(o&Pu.IncludeAnonymous)>0;for(let t=this.cursor(o|Pu.IncludeAnonymous);;){let o=!1;if(t.from<=s&&t.to>=n&&(!r&&t.type.isAnonymous||!1!==e(t))){if(t.firstChild())continue;o=!0}for(;o&&i&&(r||!t.type.isAnonymous)&&i(t),!t.nextSibling();){if(!t.parent())return;o=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:Wu(ku.none,this.children,this.positions,0,this.children.length,0,this.length,(t,e,i)=>new Eu(this.type,t,e,i,this.propValues),t.makeTree||((t,e,i)=>new Eu(ku.none,t,e,i)))}static build(t){return function(t){var e;let{buffer:i,nodeSet:n,maxBufferLength:s=Ou,reused:o=[],minRepeatType:r=n.types.length}=t,a=Array.isArray(i)?new Au(i,i.length):i,l=n.types,c=0,h=0;function u(t,e,i,y,O,b){let{id:x,start:w,end:_,size:S}=a,k=h,$=c;for(;S<0;){if(a.next(),-1==S){let e=o[x];return i.push(e),void y.push(w-t)}if(-3==S)return void(c=x);if(-4==S)return void(h=x);throw new RangeError(`Unrecognized record size: ${S}`)}let C,T,P=l[x],E=w-t;if(_-w<=s&&(T=g(a.pos-e,O))){let e=new Uint16Array(T.size-T.skip),i=a.pos-T.size,s=e.length;for(;a.pos>i;)s=v(T.start,e,s);C=new Mu(e,_-T.start,n),E=T.start-t}else{let t=a.pos-S;a.next();let e=[],i=[],n=x>=r?x:-1,o=0,l=_;for(;a.pos>t;)n>=0&&a.id==n&&a.size>=0?(a.end<=l-s&&(p(e,i,w,o,a.end,l,n,k,$),o=e.length,l=a.end),a.next()):b>2500?d(w,t,e,i):u(w,t,e,i,n,b+1);if(n>=0&&o>0&&o<e.length&&p(e,i,w,o,w,l,n,k,$),e.reverse(),i.reverse(),n>-1&&o>0){let t=f(P,$);C=Wu(P,e,i,0,e.length,0,_-w,t,t)}else C=m(P,e,i,_-w,k-_,$)}i.push(C),y.push(E)}function d(t,e,i,o){let r=[],l=0,c=-1;for(;a.pos>e;){let{id:t,start:e,end:i,size:n}=a;if(n>4)a.next();else{if(c>-1&&e<c)break;c<0&&(c=i-s),r.push(t,e,i),l++,a.next()}}if(l){let e=new Uint16Array(4*l),s=r[r.length-2];for(let t=r.length-3,i=0;t>=0;t-=3)e[i++]=r[t],e[i++]=r[t+1]-s,e[i++]=r[t+2]-s,e[i++]=i;i.push(new Mu(e,r[2]-s,n)),o.push(s-t)}}function f(t,e){return(i,n,s)=>{let o,r,a=0,l=i.length-1;if(l>=0&&(o=i[l])instanceof Eu){if(!l&&o.type==t&&o.length==s)return o;(r=o.prop(wu.lookAhead))&&(a=n[l]+o.length+r)}return m(t,i,n,s,a,e)}}function p(t,e,i,s,o,r,a,l,c){let h=[],u=[];for(;t.length>s;)h.push(t.pop()),u.push(e.pop()+i-o);t.push(m(n.types[a],h,u,r-o,l-r,c)),e.push(o-i)}function m(t,e,i,n,s,o,r){if(o){let t=[wu.contextHash,o];r=r?[t].concat(r):[t]}if(s>25){let t=[wu.lookAhead,s];r=r?[t].concat(r):[t]}return new Eu(t,e,i,n,r)}function g(t,e){let i=a.fork(),n=0,o=0,l=0,c=i.end-s,h={size:0,start:0,skip:0};t:for(let s=i.pos-t;i.pos>s;){let t=i.size;if(i.id==e&&t>=0){h.size=n,h.start=o,h.skip=l,l+=4,n+=4,i.next();continue}let a=i.pos-t;if(t<0||a<s||i.start<c)break;let u=i.id>=r?4:0,d=i.start;for(i.next();i.pos>a;){if(i.size<0){if(-3!=i.size)break t;u+=4}else i.id>=r&&(u+=4);i.next()}o=d,n+=t,l+=u}return(e<0||n==t)&&(h.size=n,h.start=o,h.skip=l),h.size>4?h:void 0}function v(t,e,i){let{id:n,start:s,end:o,size:l}=a;if(a.next(),l>=0&&n<r){let r=i;if(l>4){let n=a.pos-(l-4);for(;a.pos>n;)i=v(t,e,i)}e[--i]=r,e[--i]=o-t,e[--i]=s-t,e[--i]=n}else-3==l?c=n:-4==l&&(h=n);return i}let y=[],O=[];for(;a.pos>0;)u(t.start||0,t.bufferStart||0,y,O,-1,0);let b=null!==(e=t.length)&&void 0!==e?e:y.length?O[0]+y[0].length:0;return new Eu(l[t.topID],y.reverse(),O.reverse(),b)}(t)}}Eu.empty=new Eu(ku.none,[],[],0);class Au{constructor(t,e){this.buffer=t,this.index=e}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Au(this.buffer,this.index)}}class Mu{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return ku.none}toString(){let t=[];for(let e=0;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];return t.join(",")}childString(t){let e=this.buffer[t],i=this.buffer[t+3],n=this.set.types[e],s=n.name;if(/\W/.test(s)&&!n.isError&&(s=JSON.stringify(s)),i==(t+=4))return s;let o=[];for(;t<i;)o.push(this.childString(t)),t=this.buffer[t+3];return s+"("+o.join(",")+")"}findChild(t,e,i,n,s){let{buffer:o}=this,r=-1;for(let a=t;a!=e&&!(Qu(s,n,o[a+1],o[a+2])&&(r=a,i>0));a=o[a+3]);return r}slice(t,e,i){let n=this.buffer,s=new Uint16Array(e-t),o=0;for(let r=t,a=0;r<e;){s[a++]=n[r++],s[a++]=n[r++]-i;let e=s[a++]=n[r++]-i;s[a++]=n[r++]-t,o=Math.max(o,e)}return new Mu(s,o,this.set)}}function Qu(t,e,i,n){switch(t){case-2:return i<e;case-1:return n>=e&&i<e;case 0:return i<e&&n>e;case 1:return i<=e&&n>e;case 2:return n>e;case 4:return!0}}function Du(t,e,i,n){for(var s;t.from==t.to||(i<1?t.from>=e:t.from>e)||(i>-1?t.to<=e:t.to<e);){let e=!n&&t instanceof Iu&&t.index<0?null:t.parent;if(!e)return t;t=e}let o=n?0:Pu.IgnoreOverlays;if(n)for(let n=t,r=n.parent;r;n=r,r=n.parent)n instanceof Iu&&n.index<0&&(null===(s=r.enter(e,i,o))||void 0===s?void 0:s.from)!=n.from&&(t=r);for(;;){let n=t.enter(e,i,o);if(!n)return t;t=n}}class Ru{cursor(t=0){return new Zu(this,t)}getChild(t,e=null,i=null){let n=Lu(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return Lu(this,t,e,i)}resolve(t,e=0){return Du(this,t,e,!1)}resolveInner(t,e=0){return Du(this,t,e,!0)}matchContext(t){return Nu(this.parent,t)}enterUnfinishedNodesBefore(t){let e=this.childBefore(t),i=this;for(;e;){let t=e.lastChild;if(!t||t.to!=e.to)break;t.type.isError&&t.from==t.to?(i=e,e=t.prevSibling):e=t}return i}get node(){return this}get next(){return this.parent}}class Iu extends Ru{constructor(t,e,i,n){super(),this._tree=t,this.from=e,this.index=i,this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,i,n,s=0){for(let o=this;;){for(let{children:r,positions:a}=o._tree,l=e>0?r.length:-1;t!=l;t+=e){let l=r[t],c=a[t]+o.from;if(Qu(n,i,c,c+l.length))if(l instanceof Mu){if(s&Pu.ExcludeBuffers)continue;let r=l.findChild(0,l.buffer.length,e,i-c,n);if(r>-1)return new zu(new ju(o,l,t,c),null,r)}else if(s&Pu.IncludeAnonymous||!l.type.isAnonymous||Fu(l)){let r;if(!(s&Pu.IgnoreMounts)&&(r=_u.get(l))&&!r.overlay)return new Iu(r.tree,c,t,o);let a=new Iu(l,c,t,o);return s&Pu.IncludeAnonymous||!a.type.isAnonymous?a:a.nextChild(e<0?l.children.length-1:0,e,i,n)}}if(s&Pu.IncludeAnonymous||!o.type.isAnonymous)return null;if(t=o.index>=0?o.index+e:e<0?-1:o._parent._tree.children.length,o=o._parent,!o)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}enter(t,e,i=0){let n;if(!(i&Pu.IgnoreOverlays)&&(n=_u.get(this._tree))&&n.overlay){let i=t-this.from;for(let{from:t,to:s}of n.overlay)if((e>0?t<=i:t<i)&&(e<0?s>=i:s>i))return new Iu(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,i)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function Lu(t,e,i,n){let s=t.cursor(),o=[];if(!s.firstChild())return o;if(null!=i)for(let t=!1;!t;)if(t=s.type.is(i),!s.nextSibling())return o;for(;;){if(null!=n&&s.type.is(n))return o;if(s.type.is(e)&&o.push(s.node),!s.nextSibling())return null==n?o:[]}}function Nu(t,e,i=e.length-1){for(let n=t;i>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[i]&&e[i]!=n.name)return!1;i--}}return!0}class ju{constructor(t,e,i,n){this.parent=t,this.buffer=e,this.index=i,this.start=n}}class zu extends Ru{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,e,i){super(),this.context=t,this._parent=e,this.index=i,this.type=t.buffer.set.types[t.buffer.buffer[i]]}child(t,e,i){let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.context.start,i);return s<0?null:new zu(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}enter(t,e,i=0){if(i&Pu.ExcludeBuffers)return null;let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return s<0?null:new zu(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new zu(this.context,this._parent,e):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;return this.index==e?this.externalSibling(-1):new zu(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],e=[],{buffer:i}=this.context,n=this.index+4,s=i.buffer[this.index+3];if(s>n){let o=i.buffer[this.index+1];t.push(i.slice(n,s,o)),e.push(0)}return new Eu(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Bu(t){if(!t.length)return null;let e=0,i=t[0];for(let n=1;n<t.length;n++){let s=t[n];(s.from>i.from||s.to<i.to)&&(i=s,e=n)}let n=i instanceof Iu&&i.index<0?null:i.parent,s=t.slice();return n?s[e]=n:s.splice(e,1),new qu(s,i)}class qu{constructor(t,e){this.heads=t,this.node=e}get next(){return Bu(this.heads)}}class Zu{get name(){return this.type.name}constructor(t,e=0){if(this.mode=e,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,t instanceof Iu)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let e=t._parent;e;e=e._parent)this.stack.unshift(e.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return!!t&&(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0)}yieldBuf(t,e){this.index=t;let{start:i,buffer:n}=this.buffer;return this.type=e||n.set.types[n.buffer[t]],this.from=i+n.buffer[t+1],this.to=i+n.buffer[t+2],!0}yield(t){return!!t&&(t instanceof Iu?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,i){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,e,i,this.mode));let{buffer:n}=this.buffer,s=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.buffer.start,i);return!(s<0)&&(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,i=this.mode){return this.buffer?!(i&Pu.ExcludeBuffers)&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Pu.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&Pu.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode));let{buffer:e}=this.buffer,i=this.stack.length-1;if(t<0){let t=i<0?0:this.stack[i]+4;if(this.index!=t)return this.yieldBuf(e.findChild(t,this.index,-1,0,4))}else{let t=e.buffer[this.index+3];if(t<(i<0?e.buffer.length:e.buffer[this.stack[i]+3]))return this.yieldBuf(t)}return i<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,i,{buffer:n}=this;if(n){if(t>0){if(this.index<n.buffer.buffer.length)return!1}else for(let t=0;t<this.index;t++)if(n.buffer.buffer[t+3]<this.index)return!1;({index:e,parent:i}=n)}else({index:e,_parent:i}=this._tree);for(;i;({index:e,_parent:i}=i))if(e>-1)for(let n=e+t,s=t<0?-1:i._tree.children.length;n!=s;n+=t){let t=i._tree.children[n];if(this.mode&Pu.IncludeAnonymous||t instanceof Mu||!t.type.isAnonymous||Fu(t))return!1}return!0}move(t,e){if(e&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,e););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,i=0;if(t&&t.context==this.buffer)t:for(let n=this.index,s=this.stack.length;s>=0;){for(let o=t;o;o=o._parent)if(o.index==n){if(n==this.index)return o;e=o,i=s+1;break t}n=this.stack[--s]}for(let t=i;t<this.stack.length;t++)e=new zu(this.buffer,e,this.stack[t]);return this.bufferNode=new zu(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let i=0;;){let n=!1;if(this.type.isAnonymous||!1!==t(this)){if(this.firstChild()){i++;continue}this.type.isAnonymous||(n=!0)}for(;;){if(n&&e&&e(this),n=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,n=!0}}}matchContext(t){if(!this.buffer)return Nu(this.node.parent,t);let{buffer:e}=this.buffer,{types:i}=e.set;for(let n=t.length-1,s=this.stack.length-1;n>=0;s--){if(s<0)return Nu(this._tree,t,n);let o=i[e.buffer[this.stack[s]]];if(!o.isAnonymous){if(t[n]&&t[n]!=o.name)return!1;n--}}return!0}}function Fu(t){return t.children.some(t=>t instanceof Mu||!t.type.isAnonymous||Fu(t))}const Xu=new WeakMap;function Hu(t,e){if(!t.isAnonymous||e instanceof Mu||e.type!=t)return 1;let i=Xu.get(e);if(null==i){i=1;for(let n of e.children){if(n.type!=t||!(n instanceof Eu)){i=1;break}i+=Hu(t,n)}Xu.set(e,i)}return i}function Wu(t,e,i,n,s,o,r,a,l){let c=0;for(let i=n;i<s;i++)c+=Hu(t,e[i]);let h=Math.ceil(1.5*c/8),u=[],d=[];return function e(i,n,s,r,a){for(let c=s;c<r;){let s=c,f=n[c],p=Hu(t,i[c]);for(c++;c<r;c++){let e=Hu(t,i[c]);if(p+e>=h)break;p+=e}if(c==s+1){if(p>h){let t=i[s];e(t.children,t.positions,0,t.children.length,n[s]+a);continue}u.push(i[s])}else{let e=n[c-1]+i[c-1].length-f;u.push(Wu(t,i,n,s,c,f,e,null,l))}d.push(f+a-o)}}(e,i,n,s,0),(a||l)(u,d,r)}class Vu{constructor(){this.map=new WeakMap}setBuffer(t,e,i){let n=this.map.get(t);n||this.map.set(t,n=new Map),n.set(e,i)}getBuffer(t,e){let i=this.map.get(t);return i&&i.get(e)}set(t,e){t instanceof zu?this.setBuffer(t.context.buffer,t.index,e):t instanceof Iu&&this.map.set(t.tree,e)}get(t){return t instanceof zu?this.getBuffer(t.context.buffer,t.index):t instanceof Iu?this.map.get(t.tree):void 0}cursorSet(t,e){t.buffer?this.setBuffer(t.buffer.buffer,t.index,e):this.map.set(t.tree,e)}cursorGet(t){return t.buffer?this.getBuffer(t.buffer.buffer,t.index):this.map.get(t.tree)}}class Yu{constructor(t,e,i,n,s=!1,o=!1){this.from=t,this.to=e,this.tree=i,this.offset=n,this.open=(s?1:0)|(o?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(t,e=[],i=!1){let n=[new Yu(0,t.length,t,0,!1,i)];for(let i of e)i.to>t.length&&n.push(i);return n}static applyChanges(t,e,i=128){if(!e.length)return t;let n=[],s=1,o=t.length?t[0]:null;for(let r=0,a=0,l=0;;r++){let c=r<e.length?e[r]:null,h=c?c.fromA:1e9;if(h-a>=i)for(;o&&o.from<h;){let e=o;if(a>=e.from||h<=e.to||l){let t=Math.max(e.from,a)-l,i=Math.min(e.to,h)-l;e=t>=i?null:new Yu(t,i,e.tree,e.offset+l,r>0,!!c)}if(e&&n.push(e),o.to>h)break;o=s<t.length?t[s++]:null}if(!c)break;a=c.toA,l=c.toA-c.toB}return n}}class Uu{startParse(t,e,i){return"string"==typeof t&&(t=new Gu(t)),i=i?i.length?i.map(t=>new xu(t.from,t.to)):[new xu(0,0)]:[new xu(0,t.length)],this.createParse(t,e||[],i)}parse(t,e,i){let n=this.startParse(t,e,i);for(;;){let t=n.advance();if(t)return t}}}class Gu{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,e){return this.string.slice(t,e)}}new wu({perNode:!0});let Ku=0;class Ju{constructor(t,e,i,n){this.name=t,this.set=e,this.base=i,this.modified=n,this.id=Ku++}toString(){let{name:t}=this;for(let e of this.modified)e.name&&(t=`${e.name}(${t})`);return t}static define(t,e){let i="string"==typeof t?t:"?";if(t instanceof Ju&&(e=t),null==e?void 0:e.base)throw new Error("Can not derive from a modified tag");let n=new Ju(i,[],null,[]);if(n.set.push(n),e)for(let t of e.set)n.set.push(t);return n}static defineModifier(t){let e=new ed(t);return t=>t.modified.indexOf(e)>-1?t:ed.get(t.base||t,t.modified.concat(e).sort((t,e)=>t.id-e.id))}}let td=0;class ed{constructor(t){this.name=t,this.instances=[],this.id=td++}static get(t,e){if(!e.length)return t;let i=e[0].instances.find(i=>{return i.base==t&&(n=e,s=i.modified,n.length==s.length&&n.every((t,e)=>t==s[e]));var n,s});if(i)return i;let n=[],s=new Ju(t.name,n,t,e);for(let t of e)t.instances.push(s);let o=function(t){let e=[[]];for(let i=0;i<t.length;i++)for(let n=0,s=e.length;n<s;n++)e.push(e[n].concat(t[i]));return e.sort((t,e)=>e.length-t.length)}(e);for(let e of t.set)if(!e.modified.length)for(let t of o)n.push(ed.get(e,t));return s}}function id(t){let e=Object.create(null);for(let i in t){let n=t[i];Array.isArray(n)||(n=[n]);for(let t of i.split(" "))if(t){let i=[],s=2,o=t;for(let e=0;;){if("..."==o&&e>0&&e+3==t.length){s=1;break}let n=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(o);if(!n)throw new RangeError("Invalid path: "+t);if(i.push("*"==n[0]?"":'"'==n[0][0]?JSON.parse(n[0]):n[0]),e+=n[0].length,e==t.length)break;let r=t[e++];if(e==t.length&&"!"==r){s=0;break}if("/"!=r)throw new RangeError("Invalid path: "+t);o=t.slice(e)}let r=i.length-1,a=i[r];if(!a)throw new RangeError("Invalid path: "+t);let l=new sd(n,s,r>0?i.slice(0,r):null);e[a]=l.sort(e[a])}}return nd.add(e)}const nd=new wu;class sd{constructor(t,e,i,n){this.tags=t,this.mode=e,this.context=i,this.next=n}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(t){return!t||t.depth<this.depth?(this.next=t,this):(t.next=this.sort(t.next),t)}get depth(){return this.context?this.context.length:0}}function od(t,e){let i=Object.create(null);for(let e of t)if(Array.isArray(e.tag))for(let t of e.tag)i[t.id]=e.class;else i[e.tag.id]=e.class;let{scope:n,all:s=null}=e||{};return{style:t=>{let e=s;for(let n of t)for(let t of n.set){let n=i[t.id];if(n){e=e?e+" "+n:n;break}}return e},scope:n}}function rd(t,e,i,n=0,s=t.length){let o=new ad(n,Array.isArray(e)?e:[e],i);o.highlightRange(t.cursor(),n,s,"",o.highlighters),o.flush(s)}sd.empty=new sd([],2,null);class ad{constructor(t,e,i){this.at=t,this.highlighters=e,this.span=i,this.class=""}startSpan(t,e){e!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=e)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,e,i,n,s){let{type:o,from:r,to:a}=t;if(r>=i||a<=e)return;o.isTop&&(s=this.highlighters.filter(t=>!t.scope||t.scope(o)));let l=n,c=function(t){let e=t.type.prop(nd);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}(t)||sd.empty,h=function(t,e){let i=null;for(let n of t){let t=n.style(e);t&&(i=i?i+" "+t:t)}return i}(s,c.tags);if(h&&(l&&(l+=" "),l+=h,1==c.mode&&(n+=(n?" ":"")+h)),this.startSpan(Math.max(e,r),l),c.opaque)return;let u=t.tree&&t.tree.prop(wu.mounted);if(u&&u.overlay){let o=t.node.enter(u.overlay[0].from+r,1),c=this.highlighters.filter(t=>!t.scope||t.scope(u.tree.type)),h=t.firstChild();for(let d=0,f=r;;d++){let p=d<u.overlay.length?u.overlay[d]:null,m=p?p.from+r:a,g=Math.max(e,f),v=Math.min(i,m);if(g<v&&h)for(;t.from<v&&(this.highlightRange(t,g,v,n,s),this.startSpan(Math.min(v,t.to),l),!(t.to>=m)&&t.nextSibling()););if(!p||m>i)break;f=p.to+r,f>e&&(this.highlightRange(o.cursor(),Math.max(e,p.from+r),Math.min(i,f),"",c),this.startSpan(Math.min(i,f),l))}h&&t.parent()}else if(t.firstChild()){u&&(n="");do{if(!(t.to<=e)){if(t.from>=i)break;this.highlightRange(t,e,i,n,s),this.startSpan(Math.min(i,t.to),l)}}while(t.nextSibling());t.parent()}}}const ld=Ju.define,cd=ld(),hd=ld(),ud=ld(hd),dd=ld(hd),fd=ld(),pd=ld(fd),md=ld(fd),gd=ld(),vd=ld(gd),yd=ld(),Od=ld(),bd=ld(),xd=ld(bd),wd=ld(),_d={comment:cd,lineComment:ld(cd),blockComment:ld(cd),docComment:ld(cd),name:hd,variableName:ld(hd),typeName:ud,tagName:ld(ud),propertyName:dd,attributeName:ld(dd),className:ld(hd),labelName:ld(hd),namespace:ld(hd),macroName:ld(hd),literal:fd,string:pd,docString:ld(pd),character:ld(pd),attributeValue:ld(pd),number:md,integer:ld(md),float:ld(md),bool:ld(fd),regexp:ld(fd),escape:ld(fd),color:ld(fd),url:ld(fd),keyword:yd,self:ld(yd),null:ld(yd),atom:ld(yd),unit:ld(yd),modifier:ld(yd),operatorKeyword:ld(yd),controlKeyword:ld(yd),definitionKeyword:ld(yd),moduleKeyword:ld(yd),operator:Od,derefOperator:ld(Od),arithmeticOperator:ld(Od),logicOperator:ld(Od),bitwiseOperator:ld(Od),compareOperator:ld(Od),updateOperator:ld(Od),definitionOperator:ld(Od),typeOperator:ld(Od),controlOperator:ld(Od),punctuation:bd,separator:ld(bd),bracket:xd,angleBracket:ld(xd),squareBracket:ld(xd),paren:ld(xd),brace:ld(xd),content:gd,heading:vd,heading1:ld(vd),heading2:ld(vd),heading3:ld(vd),heading4:ld(vd),heading5:ld(vd),heading6:ld(vd),contentSeparator:ld(gd),list:ld(gd),quote:ld(gd),emphasis:ld(gd),strong:ld(gd),link:ld(gd),monospace:ld(gd),strikethrough:ld(gd),inserted:ld(),deleted:ld(),changed:ld(),invalid:ld(),meta:wd,documentMeta:ld(wd),annotation:ld(wd),processingInstruction:ld(wd),definition:Ju.defineModifier("definition"),constant:Ju.defineModifier("constant"),function:Ju.defineModifier("function"),standard:Ju.defineModifier("standard"),local:Ju.defineModifier("local"),special:Ju.defineModifier("special")};for(let t in _d){let e=_d[t];e instanceof Ju&&(e.name=t)}od([{tag:_d.link,class:"tok-link"},{tag:_d.heading,class:"tok-heading"},{tag:_d.emphasis,class:"tok-emphasis"},{tag:_d.strong,class:"tok-strong"},{tag:_d.keyword,class:"tok-keyword"},{tag:_d.atom,class:"tok-atom"},{tag:_d.bool,class:"tok-bool"},{tag:_d.url,class:"tok-url"},{tag:_d.labelName,class:"tok-labelName"},{tag:_d.inserted,class:"tok-inserted"},{tag:_d.deleted,class:"tok-deleted"},{tag:_d.literal,class:"tok-literal"},{tag:_d.string,class:"tok-string"},{tag:_d.number,class:"tok-number"},{tag:[_d.regexp,_d.escape,_d.special(_d.string)],class:"tok-string2"},{tag:_d.variableName,class:"tok-variableName"},{tag:_d.local(_d.variableName),class:"tok-variableName tok-local"},{tag:_d.definition(_d.variableName),class:"tok-variableName tok-definition"},{tag:_d.special(_d.variableName),class:"tok-variableName2"},{tag:_d.definition(_d.propertyName),class:"tok-propertyName tok-definition"},{tag:_d.typeName,class:"tok-typeName"},{tag:_d.namespace,class:"tok-namespace"},{tag:_d.className,class:"tok-className"},{tag:_d.macroName,class:"tok-macroName"},{tag:_d.propertyName,class:"tok-propertyName"},{tag:_d.operator,class:"tok-operator"},{tag:_d.comment,class:"tok-comment"},{tag:_d.meta,class:"tok-meta"},{tag:_d.invalid,class:"tok-invalid"},{tag:_d.punctuation,class:"tok-punctuation"}]);var Sd;const kd=new wu;function $d(t){return cs.define({combine:t?e=>e.concat(t):void 0})}const Cd=new wu;class Td{constructor(t,e,i=[],n=""){this.data=t,this.name=n,Gs.prototype.hasOwnProperty("tree")||Object.defineProperty(Gs.prototype,"tree",{get(){return Ad(this)}}),this.parser=e,this.extension=[zd.of(this),Gs.languageData.of((t,e,i)=>{let n=Pd(t,e,i),s=n.type.prop(kd);if(!s)return[];let o=t.facet(s),r=n.type.prop(Cd);if(r){let s=n.resolve(e-n.from,i);for(let e of r)if(e.test(s,t)){let i=t.facet(e.facet);return"replace"==e.type?i:i.concat(o)}}return o})].concat(i)}isActiveAt(t,e,i=-1){return Pd(t,e,i).type.prop(kd)==this.data}findRegions(t){let e=t.facet(zd);if((null==e?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let i=[],n=(t,e)=>{if(t.prop(kd)==this.data)return void i.push({from:e,to:e+t.length});let s=t.prop(wu.mounted);if(s){if(s.tree.prop(kd)==this.data){if(s.overlay)for(let t of s.overlay)i.push({from:t.from+e,to:t.to+e});else i.push({from:e,to:e+t.length});return}if(s.overlay){let t=i.length;if(n(s.tree,s.overlay[0].from+e),i.length>t)return}}for(let i=0;i<t.children.length;i++){let s=t.children[i];s instanceof Eu&&n(s,t.positions[i]+e)}};return n(Ad(t),0),i}get allowsNesting(){return!0}}function Pd(t,e,i){let n=t.facet(zd),s=Ad(t).topNode;if(!n||n.allowsNesting)for(let t=s;t;t=t.enter(e,i,Pu.ExcludeBuffers))t.type.isTop&&(s=t);return s}Td.setState=js.define();class Ed extends Td{constructor(t,e,i){super(t,e,[],i),this.parser=e}static define(t){let e=$d(t.languageData);return new Ed(e,t.parser.configure({props:[kd.add(t=>t.isTop?e:void 0)]}),t.name)}configure(t,e){return new Ed(this.data,this.parser.configure(t),e||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Ad(t){let e=t.field(Td.state,!1);return e?e.tree:Eu.empty}class Md{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let i=this.cursorPos-this.string.length;return t<i||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-i,e-i)}}let Qd=null;class Dd{constructor(t,e,i=[],n,s,o,r,a){this.parser=t,this.state=e,this.fragments=i,this.tree=n,this.treeLen=s,this.viewport=o,this.skipped=r,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(t,e,i){return new Dd(t,e,[],Eu.empty,0,i,[],null)}startParse(){return this.parser.startParse(new Md(this.state.doc),this.fragments)}work(t,e){return null!=e&&e>=this.state.doc.length&&(e=void 0),this.tree!=Eu.empty&&this.isDone(null!=e?e:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if("number"==typeof t){let e=Date.now()+t;t=()=>Date.now()>e}for(this.parse||(this.parse=this.startParse()),null!=e&&(null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&e<this.state.doc.length&&this.parse.stopAt(e);;){let n=this.parse.advance();if(n){if(this.fragments=this.withoutTempSkipped(Yu.addTree(n,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(i=this.parse.stoppedAt)&&void 0!==i?i:this.state.doc.length,this.tree=n,this.parse=null,!(this.treeLen<(null!=e?e:this.state.doc.length)))return!0;this.parse=this.startParse()}if(t())return!1}})}takeTree(){let t,e;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(e=this.parse.advance()););}),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(Yu.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=Qd;Qd=this;try{return t()}finally{Qd=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=Rd(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:n,treeLen:s,viewport:o,skipped:r}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges((t,i,n,s)=>e.push({fromA:t,toA:i,fromB:n,toB:s})),i=Yu.applyChanges(i,e),n=Eu.empty,s=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){r=[];for(let e of this.skipped){let i=t.mapPos(e.from,1),n=t.mapPos(e.to,-1);i<n&&r.push({from:i,to:n})}}}return new Dd(this.parser,e,i,n,s,o,r,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let e=this.skipped.length;for(let e=0;e<this.skipped.length;e++){let{from:i,to:n}=this.skipped[e];i<t.to&&n>t.from&&(this.fragments=Rd(this.fragments,i,n),this.skipped.splice(e--,1))}return!(this.skipped.length>=e)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends Uu{createParse(e,i,n){let s=n[0].from,o=n[n.length-1].to;return{parsedPos:s,advance(){let e=Qd;if(e){for(let t of n)e.tempSkipped.push(t);t&&(e.scheduleOn=e.scheduleOn?Promise.all([e.scheduleOn,t]):t)}return this.parsedPos=o,new Eu(ku.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&0==e[0].from&&e[0].to>=t}static get(){return Qd}}function Rd(t,e,i){return Yu.applyChanges(t,[{fromA:e,toA:i,fromB:e,toB:i}])}class Id{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let e=this.context.changes(t.changes,t.state),i=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,i)||e.takeTree(),new Id(e)}static init(t){let e=Math.min(3e3,t.doc.length),i=Dd.create(t.facet(zd).parser,t,{from:0,to:e});return i.work(20,e)||i.takeTree(),new Id(i)}}Td.state=gs.define({create:Id.init,update(t,e){for(let t of e.effects)if(t.is(Td.setState))return t.value;return e.startState.facet(zd)!=e.state.facet(zd)?Id.init(e.state):t.apply(e)}});let Ld=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};"undefined"!=typeof requestIdleCallback&&(Ld=t=>{let e=-1,i=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(i):cancelIdleCallback(e)});const Nd="undefined"!=typeof navigator&&(null===(Sd=navigator.scheduling)||void 0===Sd?void 0:Sd.isInputPending)?()=>navigator.scheduling.isInputPending():null,jd=Pa.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let e=this.view.state.field(Td.state).context;(e.updateViewport(t.view.viewport)||this.view.viewport.to>e.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(e)}scheduleWork(){if(this.working)return;let{state:t}=this.view,e=t.field(Td.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=Ld(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEnd<e&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=e+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:n}}=this.view,s=i.field(Td.state);if(s.tree==s.context.tree&&s.context.isDone(n+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,t&&!Nd?Math.max(25,t.timeRemaining()-5):1e9),r=s.context.treeLen<n&&i.doc.length>n+1e3,a=s.context.work(()=>Nd&&Nd()||Date.now()>o,n+(r?0:1e5));this.chunkBudget-=Date.now()-e,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Td.setState.of(new Id(s.context))})),this.chunkBudget>0&&(!a||r)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(t=>ka(this.view.state,t)).then(()=>this.workScheduled--),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),zd=cs.define({combine:t=>t.length?t[0]:null,enables:t=>[Td.state,jd,Tc.contentAttributes.compute([t],e=>{let i=e.facet(t);return i&&i.name?{"data-language":i.name}:{}})]});class Bd{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}}const qd=cs.define(),Zd=cs.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Fd(t){let e=t.facet(Zd);return 9==e.charCodeAt(0)?t.tabSize*e.length:e.length}function Xd(t,e){let i="",n=t.tabSize,s=t.facet(Zd)[0];if("\t"==s){for(;e>=n;)i+="\t",e-=n;s=" "}for(let t=0;t<e;t++)i+=s;return i}function Hd(t,e){t instanceof Gs&&(t=new Wd(t));for(let i of t.state.facet(qd)){let n=i(t,e);if(void 0!==n)return n}let i=Ad(t.state);return i.length>=e?function(t,e,i){let n=e.resolveStack(i),s=e.resolveInner(i,-1).resolve(i,0).enterUnfinishedNodesBefore(i);if(s!=n.node){let t=[];for(let e=s;e&&!(e.from<n.node.from||e.to>n.node.to||e.from==n.node.from&&e.type==n.node.type);e=e.parent)t.push(e);for(let e=t.length-1;e>=0;e--)n={node:t[e],next:n}}return Yd(n,t,i)}(t,i,e):null}class Wd{constructor(t,e={}){this.state=t,this.options=e,this.unit=Fd(t)}lineAt(t,e=1){let i=this.state.doc.lineAt(t),{simulateBreak:n,simulateDoubleBreak:s}=this.options;return null!=n&&n>=i.from&&n<=i.to?s&&n==t?{text:"",from:t}:(e<0?n<t:n<=t)?{text:i.text.slice(n-i.from),from:n}:{text:i.text.slice(0,n-i.from),from:i.from}:i}textAfterPos(t,e=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:i,from:n}=this.lineAt(t,e);return i.slice(t-n,Math.min(i.length,t+100-n))}column(t,e=1){let{text:i,from:n}=this.lineAt(t,e),s=this.countColumn(i,t-n),o=this.options.overrideIndentation?this.options.overrideIndentation(n):-1;return o>-1&&(s+=o-this.countColumn(i,i.search(/\S|$/))),s}countColumn(t,e=t.length){return go(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:i,from:n}=this.lineAt(t,e),s=this.options.overrideIndentation;if(s){let t=s(n);if(t>-1)return t}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Vd=new wu;function Yd(t,e,i){for(let n=t;n;n=n.next){let t=Ud(n.node);if(t)return t(Kd.create(e,i,n))}return 0}function Ud(t){let e=t.type.prop(Vd);if(e)return e;let i,n=t.firstChild;if(n&&(i=n.type.prop(wu.closedBy))){let e=t.lastChild,n=e&&i.indexOf(e.name)>-1;return t=>ef(t,!0,1,void 0,n&&!function(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}(t)?e.from:void 0)}return null==t.parent?Gd:null}function Gd(){return 0}class Kd extends Wd{constructor(t,e,i){super(t.state,t.options),this.base=t,this.pos=e,this.context=i}get node(){return this.context.node}static create(t,e,i){return new Kd(t,e,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let e=this.state.doc.lineAt(t.from);for(;;){let i=t.resolve(e.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(Jd(i,t))break;e=this.state.doc.lineAt(i.from)}return this.lineIndent(e.from)}continue(){return Yd(this.context.next,this.base,this.pos)}}function Jd(t,e){for(let i=e;i;i=i.parent)if(t==i)return!0;return!1}function tf({closing:t,align:e=!0,units:i=1}){return n=>ef(n,e,i,t)}function ef(t,e,i,n,s){let o=t.textAfter,r=o.match(/^\s*/)[0].length,a=n&&o.slice(r,r+n.length)==n||s==t.pos+r,l=e?function(t){let e=t.node,i=e.childAfter(e.from),n=e.lastChild;if(!i)return null;let s=t.options.simulateBreak,o=t.state.doc.lineAt(i.from),r=null==s||s<=o.from?o.to:Math.min(o.to,s);for(let t=i.to;;){let s=e.childAfter(t);if(!s||s==n)return null;if(!s.type.isSkipped){if(s.from>=r)return null;let t=/^ */.exec(o.text.slice(i.to-o.from))[0].length;return{from:i.from,to:i.to+t}}t=s.to}}(t):null;return l?a?t.column(l.from):t.column(l.to):t.baseIndent+(a?0:t.unit*i)}function nf({except:t,units:e=1}={}){return i=>{let n=t&&t.test(i.textAfter);return i.baseIndent+(n?0:e*i.unit)}}const sf=cs.define(),of=new wu;function rf(t){let e=t.lastChild;return e&&e.to==t.to&&e.type.isError}function af(t,e,i){for(let n of t.facet(sf)){let s=n(t,e,i);if(s)return s}return function(t,e,i){let n=Ad(t);if(n.length<i)return null;let s=null;for(let o=n.resolveStack(i,1);o;o=o.next){let r=o.node;if(r.to<=i||r.from>i)continue;if(s&&r.from<e)break;let a=r.type.prop(of);if(a&&(r.to<n.length-50||n.length==t.doc.length||!rf(r))){let n=a(r,t);n&&n.from<=i&&n.from>=e&&n.to>i&&(s=n)}}return s}(t,e,i)}function lf(t,e){let i=e.mapPos(t.from,1),n=e.mapPos(t.to,-1);return i>=n?void 0:{from:i,to:n}}const cf=js.define({map:lf}),hf=js.define({map:lf});function uf(t){let e=[];for(let{head:i}of t.state.selection.ranges)e.some(t=>t.from<=i&&t.to>=i)||e.push(t.lineBlockAt(i));return e}const df=gs.define({create:()=>Mr.none,update(t,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((e,i)=>t=ff(t,e,i)),t=t.map(e.changes);for(let i of e.effects)if(i.is(cf)&&!mf(t,i.value.from,i.value.to)){let{preparePlaceholder:n}=e.state.facet(bf),s=n?Mr.replace({widget:new Sf(n(e.state,i.value))}):_f;t=t.update({add:[s.range(i.value.from,i.value.to)]})}else i.is(hf)&&(t=t.update({filter:(t,e)=>i.value.from!=t||i.value.to!=e,filterFrom:i.value.from,filterTo:i.value.to}));return e.selection&&(t=ff(t,e.selection.main.head)),t},provide:t=>Tc.decorations.from(t),toJSON(t,e){let i=[];return t.between(0,e.doc.length,(t,e)=>{i.push(t,e)}),i},fromJSON(t){if(!Array.isArray(t)||t.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let i=0;i<t.length;){let n=t[i++],s=t[i++];if("number"!=typeof n||"number"!=typeof s)throw new RangeError("Invalid JSON for fold state");e.push(_f.range(n,s))}return Mr.set(e,!0)}});function ff(t,e,i=e){let n=!1;return t.between(e,i,(t,s)=>{t<i&&s>e&&(n=!0)}),n?t.update({filterFrom:e,filterTo:i,filter:(t,n)=>t>=i||n<=e}):t}function pf(t,e,i){var n;let s=null;return null===(n=t.field(df,!1))||void 0===n||n.between(e,i,(t,e)=>{(!s||s.from>t)&&(s={from:t,to:e})}),s}function mf(t,e,i){let n=!1;return t.between(e,e,(t,s)=>{t==e&&s==i&&(n=!0)}),n}function gf(t,e){return t.field(df,!1)?e:e.concat(js.appendConfig.of(xf()))}function vf(t,e,i=!0){let n=t.state.doc.lineAt(e.from).number,s=t.state.doc.lineAt(e.to).number;return Tc.announce.of(`${t.state.phrase(i?"Folded lines":"Unfolded lines")} ${n} ${t.state.phrase("to")} ${s}.`)}const yf=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:t=>{for(let e of uf(t)){let i=af(t.state,e.from,e.to);if(i)return t.dispatch({effects:gf(t.state,[cf.of(i),vf(t,i)])}),!0}return!1}},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:t=>{if(!t.state.field(df,!1))return!1;let e=[];for(let i of uf(t)){let n=pf(t.state,i.from,i.to);n&&e.push(hf.of(n),vf(t,n,!1))}return e.length&&t.dispatch({effects:e}),e.length>0}},{key:"Ctrl-Alt-[",run:t=>{let{state:e}=t,i=[];for(let n=0;n<e.doc.length;){let s=t.lineBlockAt(n),o=af(e,s.from,s.to);o&&i.push(cf.of(o)),n=(o?t.lineBlockAt(o.to):s).to+1}return i.length&&t.dispatch({effects:gf(t.state,i)}),!!i.length}},{key:"Ctrl-Alt-]",run:t=>{let e=t.state.field(df,!1);if(!e||!e.size)return!1;let i=[];return e.between(0,t.state.doc.length,(t,e)=>{i.push(hf.of({from:t,to:e}))}),t.dispatch({effects:i}),!0}}],Of={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},bf=cs.define({combine:t=>Ks(t,Of)});function xf(t){let e=[df,Tf];return t&&e.push(bf.of(t)),e}function wf(t,e){let{state:i}=t,n=i.facet(bf),s=e=>{let i=t.lineBlockAt(t.posAtDOM(e.target)),n=pf(t.state,i.from,i.to);n&&t.dispatch({effects:hf.of(n)}),e.preventDefault()};if(n.placeholderDOM)return n.placeholderDOM(t,s,e);let o=document.createElement("span");return o.textContent=n.placeholderText,o.setAttribute("aria-label",i.phrase("folded code")),o.title=i.phrase("unfold"),o.className="cm-foldPlaceholder",o.onclick=s,o}const _f=Mr.replace({widget:new class extends Er{toDOM(t){return wf(t,null)}}});class Sf extends Er{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return wf(t,this.value)}}const kf={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class $f extends Yh{constructor(t,e){super(),this.config=t,this.open=e}eq(t){return this.config==t.config&&this.open==t.open}toDOM(t){if(this.config.markerDOM)return this.config.markerDOM(this.open);let e=document.createElement("span");return e.textContent=this.open?this.config.openText:this.config.closedText,e.title=t.state.phrase(this.open?"Fold line":"Unfold line"),e}}function Cf(t={}){let e={...kf,...t},i=new $f(e,!0),n=new $f(e,!1),s=Pa.fromClass(class{constructor(t){this.from=t.viewport.from,this.markers=this.buildMarkers(t)}update(t){(t.docChanged||t.viewportChanged||t.startState.facet(zd)!=t.state.facet(zd)||t.startState.field(df,!1)!=t.state.field(df,!1)||Ad(t.startState)!=Ad(t.state)||e.foldingChanged(t))&&(this.markers=this.buildMarkers(t.view))}buildMarkers(t){let e=new so;for(let s of t.viewportLineBlocks){let o=pf(t.state,s.from,s.to)?n:af(t.state,s.from,s.to)?i:null;o&&e.add(s.from,s.from,o)}return e.finish()}}),{domEventHandlers:o}=e;return[s,tu({class:"cm-foldGutter",markers(t){var e;return(null===(e=t.plugin(s))||void 0===e?void 0:e.markers)||no.empty},initialSpacer:()=>new $f(e,!1),domEventHandlers:{...o,click:(t,e,i)=>{if(o.click&&o.click(t,e,i))return!0;let n=pf(t.state,e.from,e.to);if(n)return t.dispatch({effects:hf.of(n)}),!0;let s=af(t.state,e.from,e.to);return!!s&&(t.dispatch({effects:cf.of(s)}),!0)}}}),xf()]}const Tf=Tc.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class Pf{constructor(t,e){let i;function n(t){let e=xo.newName();return(i||(i=Object.create(null)))["."+e]=t,e}this.specs=t;const s="string"==typeof e.all?e.all:e.all?n(e.all):void 0,o=e.scope;this.scope=o instanceof Td?t=>t.prop(kd)==o.data:o?t=>t==o:void 0,this.style=od(t.map(t=>({tag:t.tag,class:t.class||n(Object.assign({},t,{tag:null}))})),{all:s}).style,this.module=i?new xo(i):null,this.themeType=e.themeType}static define(t,e){return new Pf(t,e||{})}}const Ef=cs.define(),Af=cs.define({combine:t=>t.length?[t[0]]:null});function Mf(t){let e=t.facet(Ef);return e.length?e:t.facet(Af)}function Qf(t,e){let i,n=[Rf];return t instanceof Pf&&(t.module&&n.push(Tc.styleModule.of(t.module)),i=t.themeType),(null==e?void 0:e.fallback)?n.push(Af.of(t)):i?n.push(Ef.computeN([Tc.darkTheme],e=>e.facet(Tc.darkTheme)==("dark"==i)?[t]:[])):n.push(Ef.of(t)),n}class Df{constructor(t){this.markCache=Object.create(null),this.tree=Ad(t.state),this.decorations=this.buildDeco(t,Mf(t.state)),this.decoratedTo=t.viewport.to}update(t){let e=Ad(t.state),i=Mf(t.state),n=i!=Mf(t.startState),{viewport:s}=t.view,o=t.changes.mapPos(this.decoratedTo,1);e.length<s.to&&!n&&e.type==this.tree.type&&o>=s.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=o):(e!=this.tree||t.viewportChanged||n)&&(this.tree=e,this.decorations=this.buildDeco(t.view,i),this.decoratedTo=s.to)}buildDeco(t,e){if(!e||!this.tree.length)return Mr.none;let i=new so;for(let{from:n,to:s}of t.visibleRanges)rd(this.tree,e,(t,e,n)=>{i.add(t,e,this.markCache[n]||(this.markCache[n]=Mr.mark({class:n})))},n,s);return i.finish()}}const Rf=ws.high(Pa.fromClass(Df,{decorations:t=>t.decorations})),If=Pf.define([{tag:_d.meta,color:"#404740"},{tag:_d.link,textDecoration:"underline"},{tag:_d.heading,textDecoration:"underline",fontWeight:"bold"},{tag:_d.emphasis,fontStyle:"italic"},{tag:_d.strong,fontWeight:"bold"},{tag:_d.strikethrough,textDecoration:"line-through"},{tag:_d.keyword,color:"#708"},{tag:[_d.atom,_d.bool,_d.url,_d.contentSeparator,_d.labelName],color:"#219"},{tag:[_d.literal,_d.inserted],color:"#164"},{tag:[_d.string,_d.deleted],color:"#a11"},{tag:[_d.regexp,_d.escape,_d.special(_d.string)],color:"#e40"},{tag:_d.definition(_d.variableName),color:"#00f"},{tag:_d.local(_d.variableName),color:"#30a"},{tag:[_d.typeName,_d.namespace],color:"#085"},{tag:_d.className,color:"#167"},{tag:[_d.special(_d.variableName),_d.macroName],color:"#256"},{tag:_d.definition(_d.propertyName),color:"#00c"},{tag:_d.comment,color:"#940"},{tag:_d.invalid,color:"#f00"}]),Lf=Tc.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Nf="()[]{}",jf=cs.define({combine:t=>Ks(t,{afterCursor:!0,brackets:Nf,maxScanDistance:1e4,renderMatch:qf})}),zf=Mr.mark({class:"cm-matchingBracket"}),Bf=Mr.mark({class:"cm-nonmatchingBracket"});function qf(t){let e=[],i=t.matched?zf:Bf;return e.push(i.range(t.start.from,t.start.to)),t.end&&e.push(i.range(t.end.from,t.end.to)),e}const Zf=gs.define({create:()=>Mr.none,update(t,e){if(!e.docChanged&&!e.selection)return t;let i=[],n=e.state.facet(jf);for(let t of e.state.selection.ranges){if(!t.empty)continue;let s=Yf(e.state,t.head,-1,n)||t.head>0&&Yf(e.state,t.head-1,1,n)||n.afterCursor&&(Yf(e.state,t.head,1,n)||t.head<e.state.doc.length&&Yf(e.state,t.head+1,-1,n));s&&(i=i.concat(n.renderMatch(s,e.state)))}return Mr.set(i,!0)},provide:t=>Tc.decorations.from(t)}),Ff=[Zf,Lf];function Xf(t={}){return[jf.of(t),Ff]}const Hf=new wu;function Wf(t,e,i){let n=t.prop(e<0?wu.openedBy:wu.closedBy);if(n)return n;if(1==t.name.length){let n=i.indexOf(t.name);if(n>-1&&n%2==(e<0?1:0))return[i[n+e]]}return null}function Vf(t){let e=t.type.prop(Hf);return e?e(t.node):t}function Yf(t,e,i,n={}){let s=n.maxScanDistance||1e4,o=n.brackets||Nf,r=Ad(t),a=r.resolveInner(e,i);for(let n=a;n;n=n.parent){let s=Wf(n.type,i,o);if(s&&n.from<n.to){let r=Vf(n);if(r&&(i>0?e>=r.from&&e<r.to:e>r.from&&e<=r.to))return Uf(t,e,i,n,r,s,o)}}return function(t,e,i,n,s,o,r){let a=i<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),l=r.indexOf(a);if(l<0||l%2==0!=i>0)return null;let c={from:i<0?e-1:e,to:i>0?e+1:e},h=t.doc.iterRange(e,i>0?t.doc.length:0),u=0;for(let t=0;!h.next().done&&t<=o;){let o=h.value;i<0&&(t+=o.length);let a=e+t*i;for(let t=i>0?0:o.length-1,e=i>0?o.length:-1;t!=e;t+=i){let e=r.indexOf(o[t]);if(!(e<0||n.resolveInner(a+t,1).type!=s))if(e%2==0==i>0)u++;else{if(1==u)return{start:c,end:{from:a+t,to:a+t+1},matched:e>>1==l>>1};u--}}i>0&&(t+=o.length)}return h.done?{start:c,matched:!1}:null}(t,e,i,r,a.type,s,o)}function Uf(t,e,i,n,s,o,r){let a=n.parent,l={from:s.from,to:s.to},c=0,h=null==a?void 0:a.cursor();if(h&&(i<0?h.childBefore(n.from):h.childAfter(n.to)))do{if(i<0?h.to<=n.from:h.from>=n.to){if(0==c&&o.indexOf(h.type.name)>-1&&h.from<h.to){let t=Vf(h);return{start:l,end:t?{from:t.from,to:t.to}:void 0,matched:!0}}if(Wf(h.type,i,r))c++;else if(Wf(h.type,-i,r)){if(0==c){let t=Vf(h);return{start:l,end:t&&t.from<t.to?{from:t.from,to:t.to}:void 0,matched:!1}}c--}}}while(i<0?h.prevSibling():h.nextSibling());return{start:l,matched:!1}}const Gf=Object.create(null),Kf=[ku.none],Jf=[],tp=Object.create(null),ep=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])ep[t]=np(Gf,e);function ip(t,e){Jf.indexOf(t)>-1||(Jf.push(t),console.warn(e))}function np(t,e){let i=[];for(let n of e.split(" ")){let e=[];for(let i of n.split(".")){let n=t[i]||_d[i];n?"function"==typeof n?e.length?e=e.map(n):ip(i,`Modifier ${i} used at start of tag`):e.length?ip(i,`Tag ${i} used as modifier`):e=Array.isArray(n)?n:[n]:ip(i,`Unknown highlighting tag ${i}`)}for(let t of e)i.push(t)}if(!i.length)return 0;let n=e.replace(/ /g,"_"),s=n+" "+i.map(t=>t.id),o=tp[s];if(o)return o.id;let r=tp[s]=ku.define({id:Kf.length,name:n,props:[id({[n]:i})]});return Kf.push(r),r.id}Fr.RTL,Fr.LTR;function sp(t,e){return({state:i,dispatch:n})=>{if(i.readOnly)return!1;let s=t(e,i);return!!s&&(n(i.update(s)),!0)}}const op=sp(up,0),rp=sp(hp,0),ap=sp((t,e)=>hp(t,e,function(t){let e=[];for(let i of t.selection.ranges){let n=t.doc.lineAt(i.from),s=i.to<=n.to?n:t.doc.lineAt(i.to);s.from>n.from&&s.from==i.to&&(s=i.to==n.to+1?n:t.doc.lineAt(i.to-1));let o=e.length-1;o>=0&&e[o].to>n.from?e[o].to=s.to:e.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:s.to})}return e}(e)),0);function lp(t,e){let i=t.languageDataAt("commentTokens",e,1);return i.length?i[0]:{}}const cp=50;function hp(t,e,i=e.selection.ranges){let n=i.map(t=>lp(e,t.from).block);if(!n.every(t=>t))return null;let s=i.map((t,i)=>function(t,{open:e,close:i},n,s){let o,r,a=t.sliceDoc(n-cp,n),l=t.sliceDoc(s,s+cp),c=/\s*$/.exec(a)[0].length,h=/^\s*/.exec(l)[0].length,u=a.length-c;if(a.slice(u-e.length,u)==e&&l.slice(h,h+i.length)==i)return{open:{pos:n-c,margin:c&&1},close:{pos:s+h,margin:h&&1}};s-n<=2*cp?o=r=t.sliceDoc(n,s):(o=t.sliceDoc(n,n+cp),r=t.sliceDoc(s-cp,s));let d=/^\s*/.exec(o)[0].length,f=/\s*$/.exec(r)[0].length,p=r.length-f-i.length;return o.slice(d,d+e.length)==e&&r.slice(p,p+i.length)==i?{open:{pos:n+d+e.length,margin:/\s/.test(o.charAt(d+e.length))?1:0},close:{pos:s-f-i.length,margin:/\s/.test(r.charAt(p-1))?1:0}}:null}(e,n[i],t.from,t.to));if(2!=t&&!s.every(t=>t))return{changes:e.changes(i.map((t,e)=>s[e]?[]:[{from:t.from,insert:n[e].open+" "},{from:t.to,insert:" "+n[e].close}]))};if(1!=t&&s.some(t=>t)){let t=[];for(let e,i=0;i<s.length;i++)if(e=s[i]){let s=n[i],{open:o,close:r}=e;t.push({from:o.pos-s.open.length,to:o.pos+o.margin},{from:r.pos-r.margin,to:r.pos+s.close.length})}return{changes:t}}return null}function up(t,e,i=e.selection.ranges){let n=[],s=-1;for(let{from:t,to:o}of i){let i=n.length,r=1e9,a=lp(e,t).line;if(a){for(let i=t;i<=o;){let l=e.doc.lineAt(i);if(l.from>s&&(t==o||o>l.from)){s=l.from;let t=/^\s*/.exec(l.text)[0].length,e=t==l.length,i=l.text.slice(t,t+a.length)==a?t:-1;t<l.text.length&&t<r&&(r=t),n.push({line:l,comment:i,token:a,indent:t,empty:e,single:!1})}i=l.to+1}if(r<1e9)for(let t=i;t<n.length;t++)n[t].indent<n[t].line.text.length&&(n[t].indent=r);n.length==i+1&&(n[i].single=!0)}}if(2!=t&&n.some(t=>t.comment<0&&(!t.empty||t.single))){let t=[];for(let{line:e,token:i,indent:s,empty:o,single:r}of n)!r&&o||t.push({from:e.from+s,insert:i+" "});let i=e.changes(t);return{changes:i,selection:e.selection.map(i,1)}}if(1!=t&&n.some(t=>t.comment>=0)){let t=[];for(let{line:e,comment:i,token:s}of n)if(i>=0){let n=e.from+i,o=n+s.length;" "==e.text[o-e.from]&&o++,t.push({from:n,to:o})}return{changes:t}}return null}const dp=Is.define(),fp=Is.define(),pp=cs.define(),mp=cs.define({combine:t=>Ks(t,{minDepth:100,newGroupDelay:500,joinToEvent:(t,e)=>e},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,e)=>(i,n)=>t(i,n)||e(i,n)})}),gp=gs.define({create:()=>Qp.empty,update(t,e){let i=e.state.facet(mp),n=e.annotation(dp);if(n){let s=_p.fromTransaction(e,n.selection),o=n.side,r=0==o?t.undone:t.done;return r=s?Sp(r,r.length,i.minDepth,s):Tp(r,e.startState.selection),new Qp(0==o?n.rest:r,0==o?r:n.rest)}let s=e.annotation(fp);if("full"!=s&&"before"!=s||(t=t.isolate()),!1===e.annotation(zs.addToHistory))return e.changes.empty?t:t.addMapping(e.changes.desc);let o=_p.fromTransaction(e),r=e.annotation(zs.time),a=e.annotation(zs.userEvent);return o?t=t.addChanges(o,r,a,i,e):e.selection&&(t=t.addSelection(e.startState.selection,r,a,i.newGroupDelay)),"full"!=s&&"after"!=s||(t=t.isolate()),t},toJSON:t=>({done:t.done.map(t=>t.toJSON()),undone:t.undone.map(t=>t.toJSON())}),fromJSON:t=>new Qp(t.done.map(_p.fromJSON),t.undone.map(_p.fromJSON))});function vp(t={}){return[gp,mp.of(t),Tc.domEventHandlers({beforeinput(t,e){let i="historyUndo"==t.inputType?Op:"historyRedo"==t.inputType?bp:null;return!!i&&(t.preventDefault(),i(e))}})]}function yp(t,e){return function({state:i,dispatch:n}){if(!e&&i.readOnly)return!1;let s=i.field(gp,!1);if(!s)return!1;let o=s.pop(t,i,e);return!!o&&(n(o),!0)}}const Op=yp(0,!1),bp=yp(1,!1),xp=yp(0,!0),wp=yp(1,!0);class _p{constructor(t,e,i,n,s){this.changes=t,this.effects=e,this.mapped=i,this.startSelection=n,this.selectionsAfter=s}setSelAfter(t){return new _p(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,e,i;return{changes:null===(t=this.changes)||void 0===t?void 0:t.toJSON(),mapped:null===(e=this.mapped)||void 0===e?void 0:e.toJSON(),startSelection:null===(i=this.startSelection)||void 0===i?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(t=>t.toJSON())}}static fromJSON(t){return new _p(t.changes&&Kn.fromJSON(t.changes),[],t.mapped&&Gn.fromJSON(t.mapped),t.startSelection&&rs.fromJSON(t.startSelection),t.selectionsAfter.map(rs.fromJSON))}static fromTransaction(t,e){let i=$p;for(let e of t.startState.facet(pp)){let n=e(t);n.length&&(i=i.concat(n))}return!i.length&&t.changes.empty?null:new _p(t.changes.invert(t.startState.doc),i,void 0,e||t.startState.selection,$p)}static selection(t){return new _p(void 0,$p,void 0,void 0,t)}}function Sp(t,e,i,n){let s=e+1>i+20?e-i-1:0,o=t.slice(s,e);return o.push(n),o}function kp(t,e){return t.length?e.length?t.concat(e):t:e}const $p=[],Cp=200;function Tp(t,e){if(t.length){let i=t[t.length-1],n=i.selectionsAfter.slice(Math.max(0,i.selectionsAfter.length-Cp));return n.length&&n[n.length-1].eq(e)?t:(n.push(e),Sp(t,t.length-1,1e9,i.setSelAfter(n)))}return[_p.selection([e])]}function Pp(t){let e=t[t.length-1],i=t.slice();return i[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),i}function Ep(t,e){if(!t.length)return t;let i=t.length,n=$p;for(;i;){let s=Ap(t[i-1],e,n);if(s.changes&&!s.changes.empty||s.effects.length){let e=t.slice(0,i);return e[i-1]=s,e}e=s.mapped,i--,n=s.selectionsAfter}return n.length?[_p.selection(n)]:$p}function Ap(t,e,i){let n=kp(t.selectionsAfter.length?t.selectionsAfter.map(t=>t.map(e)):$p,i);if(!t.changes)return _p.selection(n);let s=t.changes.map(e),o=e.mapDesc(t.changes,!0),r=t.mapped?t.mapped.composeDesc(o):o;return new _p(s,js.mapEffects(t.effects,e),r,t.startSelection.map(o),n)}const Mp=/^(input\.type|delete)($|\.)/;class Qp{constructor(t,e,i=0,n=void 0){this.done=t,this.undone=e,this.prevTime=i,this.prevUserEvent=n}isolate(){return this.prevTime?new Qp(this.done,this.undone):this}addChanges(t,e,i,n,s){let o=this.done,r=o[o.length-1];return o=r&&r.changes&&!r.changes.empty&&t.changes&&(!i||Mp.test(i))&&(!r.selectionsAfter.length&&e-this.prevTime<n.newGroupDelay&&n.joinToEvent(s,function(t,e){let i=[],n=!1;return t.iterChangedRanges((t,e)=>i.push(t,e)),e.iterChangedRanges((t,e,s,o)=>{for(let t=0;t<i.length;){let e=i[t++],r=i[t++];o>=e&&s<=r&&(n=!0)}}),n}(r.changes,t.changes))||"input.type.compose"==i)?Sp(o,o.length-1,n.minDepth,new _p(t.changes.compose(r.changes),kp(js.mapEffects(t.effects,r.changes),r.effects),r.mapped,r.startSelection,$p)):Sp(o,o.length,n.minDepth,t),new Qp(o,$p,e,i)}addSelection(t,e,i,n){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:$p;return s.length>0&&e-this.prevTime<n&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&(o=s[s.length-1],r=t,o.ranges.length==r.ranges.length&&0===o.ranges.filter((t,e)=>t.empty!=r.ranges[e].empty).length)?this:new Qp(Tp(this.done,t),this.undone,e,i);var o,r}addMapping(t){return new Qp(Ep(this.done,t),Ep(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,e,i){let n=0==t?this.done:this.undone;if(0==n.length)return null;let s=n[n.length-1],o=s.selectionsAfter[0]||e.selection;if(i&&s.selectionsAfter.length)return e.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:dp.of({side:t,rest:Pp(n),selection:o}),userEvent:0==t?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let i=1==n.length?$p:n.slice(0,n.length-1);return s.mapped&&(i=Ep(i,s.mapped)),e.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:dp.of({side:t,rest:i,selection:o}),filter:!1,userEvent:0==t?"undo":"redo",scrollIntoView:!0})}return null}}Qp.empty=new Qp($p,$p);const Dp=[{key:"Mod-z",run:Op,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:bp,preventDefault:!0},{linux:"Ctrl-Shift-z",run:bp,preventDefault:!0},{key:"Mod-u",run:xp,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:wp,preventDefault:!0}];function Rp(t,e){return rs.create(t.ranges.map(e),t.mainIndex)}function Ip(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function Lp({state:t,dispatch:e},i){let n=Rp(t.selection,i);return!n.eq(t.selection,!0)&&(e(Ip(t,n)),!0)}function Np(t,e){return rs.cursor(e?t.to:t.from)}function jp(t,e){return Lp(t,i=>i.empty?t.moveByChar(i,e):Np(i,e))}function zp(t){return t.textDirectionAt(t.state.selection.main.head)==Fr.LTR}const Bp=t=>jp(t,!zp(t)),qp=t=>jp(t,zp(t));function Zp(t,e){return Lp(t,i=>i.empty?t.moveByGroup(i,e):Np(i,e))}"undefined"!=typeof Intl&&Intl.Segmenter;function Fp(t,e,i){if(e.type.prop(i))return!0;let n=e.to-e.from;return n&&(n>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Xp(t,e,i){let n,s,o=Ad(t).resolveInner(e.head),r=i?wu.closedBy:wu.openedBy;for(let n=e.head;;){let e=i?o.childAfter(n):o.childBefore(n);if(!e)break;Fp(t,e,r)?o=e:n=i?e.to:e.from}return s=o.type.prop(r)&&(n=i?Yf(t,o.from,1):Yf(t,o.to,-1))&&n.matched?i?n.end.to:n.end.from:i?o.to:o.from,rs.cursor(s,i?-1:1)}function Hp(t,e){return Lp(t,i=>{if(!i.empty)return Np(i,e);let n=t.moveVertically(i,e);return n.head!=i.head?n:t.moveToLineBoundary(i,e)})}const Wp=t=>Hp(t,!1),Vp=t=>Hp(t,!0);function Yp(t){let e,i=t.scrollDOM.clientHeight<t.scrollDOM.scrollHeight-2,n=0,s=0;if(i){for(let e of t.state.facet(Tc.scrollMargins)){let i=e(t);(null==i?void 0:i.top)&&(n=Math.max(null==i?void 0:i.top,n)),(null==i?void 0:i.bottom)&&(s=Math.max(null==i?void 0:i.bottom,s))}e=t.scrollDOM.clientHeight-n-s}else e=(t.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:s,selfScroll:i,height:Math.max(t.defaultLineHeight,e-5)}}function Up(t,e){let i,n=Yp(t),{state:s}=t,o=Rp(s.selection,i=>i.empty?t.moveVertically(i,e,n.height):Np(i,e));if(o.eq(s.selection))return!1;if(n.selfScroll){let e=t.coordsAtPos(s.selection.main.head),r=t.scrollDOM.getBoundingClientRect(),a=r.top+n.marginTop,l=r.bottom-n.marginBottom;e&&e.top>a&&e.bottom<l&&(i=Tc.scrollIntoView(o.main.head,{y:"start",yMargin:e.top-a}))}return t.dispatch(Ip(s,o),{effects:i}),!0}const Gp=t=>Up(t,!1),Kp=t=>Up(t,!0);function Jp(t,e,i){let n=t.lineBlockAt(e.head),s=t.moveToLineBoundary(e,i);if(s.head==e.head&&s.head!=(i?n.to:n.from)&&(s=t.moveToLineBoundary(e,i,!1)),!i&&s.head==n.from&&n.length){let i=/^\s*/.exec(t.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;i&&e.head!=n.from+i&&(s=rs.cursor(n.from+i))}return s}function tm(t,e,i){let n=!1,s=Rp(t.selection,e=>{let s=Yf(t,e.head,-1)||Yf(t,e.head,1)||e.head>0&&Yf(t,e.head-1,1)||e.head<t.doc.length&&Yf(t,e.head+1,-1);if(!s||!s.end)return e;n=!0;let o=s.start.from==e.head?s.end.to:s.end.from;return i?rs.range(e.anchor,o):rs.cursor(o)});return!!n&&(e(Ip(t,s)),!0)}function em(t,e){let i=Rp(t.state.selection,t=>{let i=e(t);return rs.range(t.anchor,i.head,i.goalColumn,i.bidiLevel||void 0)});return!i.eq(t.state.selection)&&(t.dispatch(Ip(t.state,i)),!0)}function im(t,e){return em(t,i=>t.moveByChar(i,e))}const nm=t=>im(t,!zp(t)),sm=t=>im(t,zp(t));function om(t,e){return em(t,i=>t.moveByGroup(i,e))}function rm(t,e){return em(t,i=>t.moveVertically(i,e))}const am=t=>rm(t,!1),lm=t=>rm(t,!0);function cm(t,e){return em(t,i=>t.moveVertically(i,e,Yp(t).height))}const hm=t=>cm(t,!1),um=t=>cm(t,!0),dm=({state:t,dispatch:e})=>(e(Ip(t,{anchor:0})),!0),fm=({state:t,dispatch:e})=>(e(Ip(t,{anchor:t.doc.length})),!0),pm=({state:t,dispatch:e})=>(e(Ip(t,{anchor:t.selection.main.anchor,head:0})),!0),mm=({state:t,dispatch:e})=>(e(Ip(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0);function gm(t,e){if(t.state.readOnly)return!1;let i="delete.selection",{state:n}=t,s=n.changeByRange(n=>{let{from:s,to:o}=n;if(s==o){let r=e(n);r<s?(i="delete.backward",r=vm(t,r,!1)):r>s&&(i="delete.forward",r=vm(t,r,!0)),s=Math.min(s,r),o=Math.max(o,r)}else s=vm(t,s,!1),o=vm(t,o,!0);return s==o?{range:n}:{changes:{from:s,to:o},range:rs.cursor(s,s<n.head?-1:1)}});return!s.changes.empty&&(t.dispatch(n.update(s,{scrollIntoView:!0,userEvent:i,effects:"delete.selection"==i?Tc.announce.of(n.phrase("Selection deleted")):void 0})),!0)}function vm(t,e,i){if(t instanceof Tc)for(let n of t.state.facet(Tc.atomicRanges).map(e=>e(t)))n.between(e,e,(t,n)=>{t<e&&n>e&&(e=i?n:t)});return e}const ym=(t,e,i)=>gm(t,n=>{let s,o,r=n.from,{state:a}=t,l=a.doc.lineAt(r);if(i&&!e&&r>l.from&&r<l.from+200&&!/[^ \t]/.test(s=l.text.slice(0,r-l.from))){if("\t"==s[s.length-1])return r-1;let t=go(s,a.tabSize)%Fd(a)||Fd(a);for(let e=0;e<t&&" "==s[s.length-1-e];e++)r--;o=r}else o=Xn(l.text,r-l.from,e,e)+l.from,o==r&&l.number!=(e?a.doc.lines:1)?o+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(l.text.slice(o-l.from,r-l.from))&&(o=Xn(l.text,o-l.from,!1,!1)+l.from);return o}),Om=t=>ym(t,!1,!0),bm=t=>ym(t,!0,!1),xm=(t,e)=>gm(t,i=>{let n=i.head,{state:s}=t,o=s.doc.lineAt(n),r=s.charCategorizer(n);for(let t=null;;){if(n==(e?o.to:o.from)){n==i.head&&o.number!=(e?s.doc.lines:1)&&(n+=e?1:-1);break}let a=Xn(o.text,n-o.from,e)+o.from,l=o.text.slice(Math.min(n,a)-o.from,Math.max(n,a)-o.from),c=r(l);if(null!=t&&c!=t)break;" "==l&&n==i.head||(t=c),n=a}return n}),wm=t=>xm(t,!1);function _m(t){let e=[],i=-1;for(let n of t.selection.ranges){let s=t.doc.lineAt(n.from),o=t.doc.lineAt(n.to);if(n.empty||n.to!=o.from||(o=t.doc.lineAt(n.to-1)),i>=s.number){let t=e[e.length-1];t.to=o.to,t.ranges.push(n)}else e.push({from:s.from,to:o.to,ranges:[n]});i=o.number+1}return e}function Sm(t,e,i){if(t.readOnly)return!1;let n=[],s=[];for(let e of _m(t)){if(i?e.to==t.doc.length:0==e.from)continue;let o=t.doc.lineAt(i?e.to+1:e.from-1),r=o.length+1;if(i){n.push({from:e.to,to:o.to},{from:e.from,insert:o.text+t.lineBreak});for(let i of e.ranges)s.push(rs.range(Math.min(t.doc.length,i.anchor+r),Math.min(t.doc.length,i.head+r)))}else{n.push({from:o.from,to:e.from},{from:e.to,insert:t.lineBreak+o.text});for(let t of e.ranges)s.push(rs.range(t.anchor-r,t.head-r))}}return!!n.length&&(e(t.update({changes:n,scrollIntoView:!0,selection:rs.create(s,t.selection.mainIndex),userEvent:"move.line"})),!0)}function km(t,e,i){if(t.readOnly)return!1;let n=[];for(let e of _m(t))i?n.push({from:e.from,insert:t.doc.slice(e.from,e.to)+t.lineBreak}):n.push({from:e.to,insert:t.lineBreak+t.doc.slice(e.from,e.to)});return e(t.update({changes:n,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const $m=Cm(!1);function Cm(t){return({state:e,dispatch:i})=>{if(e.readOnly)return!1;let n=e.changeByRange(i=>{let{from:n,to:s}=i,o=e.doc.lineAt(n),r=!t&&n==s&&function(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let i,n=Ad(t).resolveInner(e),s=n.childBefore(e),o=n.childAfter(e);return s&&o&&s.to<=e&&o.from>=e&&(i=s.type.prop(wu.closedBy))&&i.indexOf(o.name)>-1&&t.doc.lineAt(s.to).from==t.doc.lineAt(o.from).from&&!/\S/.test(t.sliceDoc(s.to,o.from))?{from:s.to,to:o.from}:null}(e,n);t&&(n=s=(s<=o.to?o:e.doc.lineAt(s)).to);let a=new Wd(e,{simulateBreak:n,simulateDoubleBreak:!!r}),l=Hd(a,n);for(null==l&&(l=go(/^\s*/.exec(e.doc.lineAt(n).text)[0],e.tabSize));s<o.to&&/\s/.test(o.text[s-o.from]);)s++;r?({from:n,to:s}=r):n>o.from&&n<o.from+100&&!/\S/.test(o.text.slice(0,n))&&(n=o.from);let c=["",Xd(e,l)];return r&&c.push(Xd(e,a.lineIndent(o.from,-1))),{changes:{from:n,to:s,insert:Rn.of(c)},range:rs.cursor(n+1+c[1].length)}});return i(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}}function Tm(t,e){let i=-1;return t.changeByRange(n=>{let s=[];for(let o=n.from;o<=n.to;){let r=t.doc.lineAt(o);r.number>i&&(n.empty||n.to>r.from)&&(e(r,s,n),i=r.number),o=r.to+1}let o=t.changes(s);return{changes:s,range:rs.range(o.mapPos(n.anchor,1),o.mapPos(n.head,1))}})}const Pm=({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(Tm(t,(e,i)=>{i.push({from:e.from,insert:t.facet(Zd)})}),{userEvent:"input.indent"})),!0),Em=({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(Tm(t,(e,i)=>{let n=/^\s*/.exec(e.text)[0];if(!n)return;let s=go(n,t.tabSize),o=0,r=Xd(t,Math.max(0,s-Fd(t)));for(;o<n.length&&o<r.length&&n.charCodeAt(o)==r.charCodeAt(o);)o++;i.push({from:e.from+o,to:e.from+n.length,insert:r.slice(o)})}),{userEvent:"delete.dedent"})),!0),Am=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:t=>Lp(t,e=>Xp(t.state,e,!zp(t))),shift:t=>em(t,e=>Xp(t.state,e,!zp(t)))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:t=>Lp(t,e=>Xp(t.state,e,zp(t))),shift:t=>em(t,e=>Xp(t.state,e,zp(t)))},{key:"Alt-ArrowUp",run:({state:t,dispatch:e})=>Sm(t,e,!1)},{key:"Shift-Alt-ArrowUp",run:({state:t,dispatch:e})=>km(t,e,!1)},{key:"Alt-ArrowDown",run:({state:t,dispatch:e})=>Sm(t,e,!0)},{key:"Shift-Alt-ArrowDown",run:({state:t,dispatch:e})=>km(t,e,!0)},{key:"Escape",run:({state:t,dispatch:e})=>{let i=t.selection,n=null;return i.ranges.length>1?n=rs.create([i.main]):i.main.empty||(n=rs.create([rs.cursor(i.main.head)])),!!n&&(e(Ip(t,n)),!0)}},{key:"Mod-Enter",run:Cm(!0)},{key:"Alt-l",mac:"Ctrl-l",run:({state:t,dispatch:e})=>{let i=_m(t).map(({from:e,to:i})=>rs.range(e,Math.min(i+1,t.doc.length)));return e(t.update({selection:rs.create(i),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:t,dispatch:e})=>{let i=Rp(t.selection,e=>{let i=Ad(t),n=i.resolveStack(e.from,1);if(e.empty){let t=i.resolveStack(e.from,-1);t.node.from>=n.node.from&&t.node.to<=n.node.to&&(n=t)}for(let t=n;t;t=t.next){let{node:i}=t;if((i.from<e.from&&i.to>=e.to||i.to>e.to&&i.from<=e.from)&&t.next)return rs.range(i.to,i.from)}return e});return!i.eq(t.selection)&&(e(Ip(t,i)),!0)},preventDefault:!0},{key:"Mod-[",run:Em},{key:"Mod-]",run:Pm},{key:"Mod-Alt-\\",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=Object.create(null),n=new Wd(t,{overrideIndentation:t=>{let e=i[t];return null==e?-1:e}}),s=Tm(t,(e,s,o)=>{let r=Hd(n,e.from);if(null==r)return;/\S/.test(e.text)||(r=0);let a=/^\s*/.exec(e.text)[0],l=Xd(t,r);(a!=l||o.from<e.from+a.length)&&(i[e.from]=r,s.push({from:e.from,to:e.from+a.length,insert:l}))});return s.changes.empty||e(t.update(s,{userEvent:"indent"})),!0}},{key:"Shift-Mod-k",run:t=>{if(t.state.readOnly)return!1;let{state:e}=t,i=e.changes(_m(e).map(({from:t,to:i})=>(t>0?t--:i<e.doc.length&&i++,{from:t,to:i}))),n=Rp(e.selection,e=>{let i;if(t.lineWrapping){let n=t.lineBlockAt(e.head),s=t.coordsAtPos(e.head,e.assoc||1);s&&(i=n.bottom+t.documentTop-s.bottom+t.defaultLineHeight/2)}return t.moveVertically(e,!0,i)}).map(i);return t.dispatch({changes:i,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:({state:t,dispatch:e})=>tm(t,e,!1)},{key:"Mod-/",run:t=>{let{state:e}=t,i=e.doc.lineAt(e.selection.main.from),n=lp(t.state,i.from);return n.line?op(t):!!n.block&&ap(t)}},{key:"Alt-A",run:rp},{key:"Ctrl-m",mac:"Shift-Alt-m",run:t=>(t.setTabFocusMode(),!0)}].concat([{key:"ArrowLeft",run:Bp,shift:nm,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:t=>Zp(t,!zp(t)),shift:t=>om(t,!zp(t)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:t=>Lp(t,e=>Jp(t,e,!zp(t))),shift:t=>em(t,e=>Jp(t,e,!zp(t))),preventDefault:!0},{key:"ArrowRight",run:qp,shift:sm,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:t=>Zp(t,zp(t)),shift:t=>om(t,zp(t)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:t=>Lp(t,e=>Jp(t,e,zp(t))),shift:t=>em(t,e=>Jp(t,e,zp(t))),preventDefault:!0},{key:"ArrowUp",run:Wp,shift:am,preventDefault:!0},{mac:"Cmd-ArrowUp",run:dm,shift:pm},{mac:"Ctrl-ArrowUp",run:Gp,shift:hm},{key:"ArrowDown",run:Vp,shift:lm,preventDefault:!0},{mac:"Cmd-ArrowDown",run:fm,shift:mm},{mac:"Ctrl-ArrowDown",run:Kp,shift:um},{key:"PageUp",run:Gp,shift:hm},{key:"PageDown",run:Kp,shift:um},{key:"Home",run:t=>Lp(t,e=>Jp(t,e,!1)),shift:t=>em(t,e=>Jp(t,e,!1)),preventDefault:!0},{key:"Mod-Home",run:dm,shift:pm},{key:"End",run:t=>Lp(t,e=>Jp(t,e,!0)),shift:t=>em(t,e=>Jp(t,e,!0)),preventDefault:!0},{key:"Mod-End",run:fm,shift:mm},{key:"Enter",run:$m,shift:$m},{key:"Mod-a",run:({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:Om,shift:Om},{key:"Delete",run:bm},{key:"Mod-Backspace",mac:"Alt-Backspace",run:wm},{key:"Mod-Delete",mac:"Alt-Delete",run:t=>xm(t,!0)},{mac:"Mod-Backspace",run:t=>gm(t,e=>{let i=t.moveToLineBoundary(e,!1).head;return e.head>i?i:Math.max(0,e.head-1)})},{mac:"Mod-Delete",run:t=>gm(t,e=>{let i=t.moveToLineBoundary(e,!0).head;return e.head<i?i:Math.min(t.state.doc.length,e.head+1)})}].concat([{key:"Ctrl-b",run:Bp,shift:nm,preventDefault:!0},{key:"Ctrl-f",run:qp,shift:sm},{key:"Ctrl-p",run:Wp,shift:am},{key:"Ctrl-n",run:Vp,shift:lm},{key:"Ctrl-a",run:t=>Lp(t,e=>rs.cursor(t.lineBlockAt(e.head).from,1)),shift:t=>em(t,e=>rs.cursor(t.lineBlockAt(e.head).from))},{key:"Ctrl-e",run:t=>Lp(t,e=>rs.cursor(t.lineBlockAt(e.head).to,-1)),shift:t=>em(t,e=>rs.cursor(t.lineBlockAt(e.head).to))},{key:"Ctrl-d",run:bm},{key:"Ctrl-h",run:Om},{key:"Ctrl-k",run:t=>gm(t,e=>{let i=t.lineBlockAt(e.head).to;return e.head<i?i:Math.min(t.state.doc.length,e.head+1)})},{key:"Ctrl-Alt-h",run:wm},{key:"Ctrl-o",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:Rn.of(["",""])},range:rs.cursor(t.from)}));return e(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange(e=>{if(!e.empty||0==e.from||e.from==t.doc.length)return{range:e};let i=e.from,n=t.doc.lineAt(i),s=i==n.from?i-1:Xn(n.text,i-n.from,!1)+n.from,o=i==n.to?i+1:Xn(n.text,i-n.from,!0)+n.from;return{changes:{from:s,to:o,insert:t.doc.slice(i,o).append(t.doc.slice(s,i))},range:rs.cursor(o)}});return!i.changes.empty&&(e(t.update(i,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:Kp}].map(t=>({mac:t.key,run:t.run,shift:t.shift}))));function Mm(){var t=arguments[0];"string"==typeof t&&(t=document.createElement(t));var e=1,i=arguments[1];if(i&&"object"==typeof i&&null==i.nodeType&&!Array.isArray(i)){for(var n in i)if(Object.prototype.hasOwnProperty.call(i,n)){var s=i[n];"string"==typeof s?t.setAttribute(n,s):null!=s&&(t[n]=s)}e++}for(;e<arguments.length;e++)Qm(t,arguments[e]);return t}function Qm(t,e){if("string"==typeof e)t.appendChild(document.createTextNode(e));else if(null==e);else if(null!=e.nodeType)t.appendChild(e);else{if(!Array.isArray(e))throw new RangeError("Unsupported child node: "+e);for(var i=0;i<e.length;i++)Qm(t,e[i])}}const Dm="function"==typeof String.prototype.normalize?t=>t.normalize("NFKD"):t=>t;class Rm{constructor(t,e,i=0,n=t.length,s,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=t.iterRange(i,n),this.bufferStart=i,this.normalize=s?t=>s(Dm(t)):Dm,this.query=this.normalize(e)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return Hn(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let t=this.peek();if(t<0)return this.done=!0,this;let e=Wn(t),i=this.bufferStart+this.bufferPos;this.bufferPos+=Vn(t);let n=this.normalize(e);if(n.length)for(let t=0,s=i;;t++){let o=n.charCodeAt(t),r=this.match(o,s,this.bufferPos+this.bufferStart);if(t==n.length-1){if(r)return this.value=r,this;break}s==i&&t<e.length&&e.charCodeAt(t)==o&&s++}}}match(t,e,i){let n=null;for(let e=0;e<this.matches.length;e+=2){let s=this.matches[e],o=!1;this.query.charCodeAt(s)==t&&(s==this.query.length-1?n={from:this.matches[e+1],to:i}:(this.matches[e]++,o=!0)),o||(this.matches.splice(e,2),e-=2)}return this.query.charCodeAt(0)==t&&(1==this.query.length?n={from:e,to:i}:this.matches.push(1,e)),n&&this.test&&!this.test(n.from,n.to,this.buffer,this.bufferStart)&&(n=null),n}}"undefined"!=typeof Symbol&&(Rm.prototype[Symbol.iterator]=function(){return this});const Im={from:-1,to:-1,match:/.*/.exec("")},Lm="gm"+(null==/x/.unicode?"":"u");class Nm{constructor(t,e,i,n=0,s=t.length){if(this.text=t,this.to=s,this.curLine="",this.done=!1,this.value=Im,/\\[sWDnr]|\n|\r|\[\^/.test(e))return new Bm(t,e,i,n,s);this.re=new RegExp(e,Lm+((null==i?void 0:i.ignoreCase)?"i":"")),this.test=null==i?void 0:i.test,this.iter=t.iter();let o=t.lineAt(n);this.curLineStart=o.from,this.matchPos=qm(t,n),this.getLine(this.curLineStart)}getLine(t){this.iter.next(t),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let t=this.matchPos-this.curLineStart;;){this.re.lastIndex=t;let e=this.matchPos<=this.to&&this.re.exec(this.curLine);if(e){let i=this.curLineStart+e.index,n=i+e[0].length;if(this.matchPos=qm(this.text,n+(i==n?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(i<n||i>this.value.to)&&(!this.test||this.test(i,n,e)))return this.value={from:i,to:n,match:e},this;t=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length<this.to))return this.done=!0,this;this.nextLine(),t=0}}}}const jm=new WeakMap;class zm{constructor(t,e){this.from=t,this.text=e}get to(){return this.from+this.text.length}static get(t,e,i){let n=jm.get(t);if(!n||n.from>=i||n.to<=e){let n=new zm(e,t.sliceString(e,i));return jm.set(t,n),n}if(n.from==e&&n.to==i)return n;let{text:s,from:o}=n;return o>e&&(s=t.sliceString(e,o)+s,o=e),n.to<i&&(s+=t.sliceString(n.to,i)),jm.set(t,new zm(o,s)),new zm(e,s.slice(e-o,i-o))}}class Bm{constructor(t,e,i,n,s){this.text=t,this.to=s,this.done=!1,this.value=Im,this.matchPos=qm(t,n),this.re=new RegExp(e,Lm+((null==i?void 0:i.ignoreCase)?"i":"")),this.test=null==i?void 0:i.test,this.flat=zm.get(t,n,this.chunkEnd(n+5e3))}chunkEnd(t){return t>=this.to?this.to:this.text.lineAt(t).to}next(){for(;;){let t=this.re.lastIndex=this.matchPos-this.flat.from,e=this.re.exec(this.flat.text);if(e&&!e[0]&&e.index==t&&(this.re.lastIndex=t+1,e=this.re.exec(this.flat.text)),e){let t=this.flat.from+e.index,i=t+e[0].length;if((this.flat.to>=this.to||e.index+e[0].length<=this.flat.text.length-10)&&(!this.test||this.test(t,i,e)))return this.value={from:t,to:i,match:e},this.matchPos=qm(this.text,i+(t==i?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=zm.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function qm(t,e){if(e>=t.length)return e;let i,n=t.lineAt(e);for(;e<n.to&&(i=n.text.charCodeAt(e-n.from))>=56320&&i<57344;)e++;return e}function Zm(t){let e=Mm("input",{class:"cm-textfield",name:"line",value:String(t.state.doc.lineAt(t.state.selection.main.head).number)});function i(){let i=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(e.value);if(!i)return;let{state:n}=t,s=n.doc.lineAt(n.selection.main.head),[,o,r,a,l]=i,c=a?+a.slice(1):0,h=r?+r:s.number;if(r&&l){let t=h/100;o&&(t=t*("-"==o?-1:1)+s.number/n.doc.lines),h=Math.round(n.doc.lines*t)}else r&&o&&(h=h*("-"==o?-1:1)+s.number);let u=n.doc.line(Math.max(1,Math.min(n.doc.lines,h))),d=rs.cursor(u.from+Math.max(0,Math.min(c,u.length)));t.dispatch({effects:[Fm.of(!1),Tc.scrollIntoView(d.from,{y:"center"})],selection:d}),t.focus()}return{dom:Mm("form",{class:"cm-gotoLine",onkeydown:e=>{27==e.keyCode?(e.preventDefault(),t.dispatch({effects:Fm.of(!1)}),t.focus()):13==e.keyCode&&(e.preventDefault(),i())},onsubmit:t=>{t.preventDefault(),i()}},Mm("label",t.state.phrase("Go to line"),": ",e)," ",Mm("button",{class:"cm-button",type:"submit"},t.state.phrase("go")),Mm("button",{name:"close",onclick:()=>{t.dispatch({effects:Fm.of(!1)}),t.focus()},"aria-label":t.state.phrase("close"),type:"button"},["×"]))}}"undefined"!=typeof Symbol&&(Nm.prototype[Symbol.iterator]=Bm.prototype[Symbol.iterator]=function(){return this});const Fm=js.define(),Xm=gs.define({create:()=>!0,update(t,e){for(let i of e.effects)i.is(Fm)&&(t=i.value);return t},provide:t=>Vh.from(t,t=>t?Zm:null)}),Hm=Tc.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px",position:"relative","& label":{fontSize:"80%"},"& [name=close]":{position:"absolute",top:"0",bottom:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:"0"}}}),Wm={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Vm=cs.define({combine:t=>Ks(t,Wm,{highlightWordAroundCursor:(t,e)=>t||e,minSelectionLength:Math.min,maxMatches:Math.min})});function Ym(t){let e=[tg,Jm];return t&&e.push(Vm.of(t)),e}const Um=Mr.mark({class:"cm-selectionMatch"}),Gm=Mr.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function Km(t,e,i,n){return!(0!=i&&t(e.sliceDoc(i-1,i))==Ws.Word||n!=e.doc.length&&t(e.sliceDoc(n,n+1))==Ws.Word)}const Jm=Pa.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.selectionSet||t.docChanged||t.viewportChanged)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=t.state.facet(Vm),{state:i}=t,n=i.selection;if(n.ranges.length>1)return Mr.none;let s,o=n.main,r=null;if(o.empty){if(!e.highlightWordAroundCursor)return Mr.none;let t=i.wordAt(o.head);if(!t)return Mr.none;r=i.charCategorizer(o.head),s=i.sliceDoc(t.from,t.to)}else{let t=o.to-o.from;if(t<e.minSelectionLength||t>200)return Mr.none;if(e.wholeWords){if(s=i.sliceDoc(o.from,o.to),r=i.charCategorizer(o.head),!Km(r,i,o.from,o.to)||!function(t,e,i,n){return t(e.sliceDoc(i,i+1))==Ws.Word&&t(e.sliceDoc(n-1,n))==Ws.Word}(r,i,o.from,o.to))return Mr.none}else if(s=i.sliceDoc(o.from,o.to),!s)return Mr.none}let a=[];for(let n of t.visibleRanges){let t=new Rm(i.doc,s,n.from,n.to);for(;!t.next().done;){let{from:n,to:s}=t.value;if((!r||Km(r,i,n,s))&&(o.empty&&n<=o.from&&s>=o.to?a.push(Gm.range(n,s)):(n>=o.to||s<=o.from)&&a.push(Um.range(n,s)),a.length>e.maxMatches))return Mr.none}}return Mr.set(a)}},{decorations:t=>t.decorations}),tg=Tc.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}});const eg=cs.define({combine:t=>Ks(t,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:t=>new Eg(t),scrollToMatch:t=>Tc.scrollIntoView(t)})});class ig{constructor(t){this.search=t.search,this.caseSensitive=!!t.caseSensitive,this.literal=!!t.literal,this.regexp=!!t.regexp,this.replace=t.replace||"",this.valid=!!this.search&&(!this.regexp||function(t){try{return new RegExp(t,Lm),!0}catch(t){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!t.wholeWord}unquote(t){return this.literal?t:t.replace(/\\([nrt\\])/g,(t,e)=>"n"==e?"\n":"r"==e?"\r":"t"==e?"\t":"\\")}eq(t){return this.search==t.search&&this.replace==t.replace&&this.caseSensitive==t.caseSensitive&&this.regexp==t.regexp&&this.wholeWord==t.wholeWord}create(){return this.regexp?new cg(this):new og(this)}getCursor(t,e=0,i){let n=t.doc?t:Gs.create({doc:t});return null==i&&(i=n.doc.length),this.regexp?rg(this,n,e,i):sg(this,n,e,i)}}class ng{constructor(t){this.spec=t}}function sg(t,e,i,n){return new Rm(e.doc,t.unquoted,i,n,t.caseSensitive?void 0:t=>t.toLowerCase(),t.wholeWord?function(t,e){return(i,n,s,o)=>((o>i||o+s.length<n)&&(o=Math.max(0,i-2),s=t.sliceString(o,Math.min(t.length,n+2))),!(e(ag(s,i-o))==Ws.Word&&e(lg(s,i-o))==Ws.Word||e(lg(s,n-o))==Ws.Word&&e(ag(s,n-o))==Ws.Word))}(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}class og extends ng{constructor(t){super(t)}nextMatch(t,e,i){let n=sg(this.spec,t,i,t.doc.length).nextOverlapping();if(n.done){let i=Math.min(t.doc.length,e+this.spec.unquoted.length);n=sg(this.spec,t,0,i).nextOverlapping()}return n.done||n.value.from==e&&n.value.to==i?null:n.value}prevMatchInRange(t,e,i){for(let n=i;;){let i=Math.max(e,n-1e4-this.spec.unquoted.length),s=sg(this.spec,t,i,n),o=null;for(;!s.nextOverlapping().done;)o=s.value;if(o)return o;if(i==e)return null;n-=1e4}}prevMatch(t,e,i){let n=this.prevMatchInRange(t,0,e);return n||(n=this.prevMatchInRange(t,Math.max(0,i-this.spec.unquoted.length),t.doc.length)),!n||n.from==e&&n.to==i?null:n}getReplacement(t){return this.spec.unquote(this.spec.replace)}matchAll(t,e){let i=sg(this.spec,t,0,t.doc.length),n=[];for(;!i.next().done;){if(n.length>=e)return null;n.push(i.value)}return n}highlight(t,e,i,n){let s=sg(this.spec,t,Math.max(0,e-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,t.doc.length));for(;!s.next().done;)n(s.value.from,s.value.to)}}function rg(t,e,i,n){return new Nm(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:t.wholeWord?(s=e.charCategorizer(e.selection.main.head),(t,e,i)=>!i[0].length||(s(ag(i.input,i.index))!=Ws.Word||s(lg(i.input,i.index))!=Ws.Word)&&(s(lg(i.input,i.index+i[0].length))!=Ws.Word||s(ag(i.input,i.index+i[0].length))!=Ws.Word)):void 0},i,n);var s}function ag(t,e){return t.slice(Xn(t,e,!1),e)}function lg(t,e){return t.slice(e,Xn(t,e))}class cg extends ng{nextMatch(t,e,i){let n=rg(this.spec,t,i,t.doc.length).next();return n.done&&(n=rg(this.spec,t,0,e).next()),n.done?null:n.value}prevMatchInRange(t,e,i){for(let n=1;;n++){let s=Math.max(e,i-1e4*n),o=rg(this.spec,t,s,i),r=null;for(;!o.next().done;)r=o.value;if(r&&(s==e||r.from>s+10))return r;if(s==e)return null}}prevMatch(t,e,i){return this.prevMatchInRange(t,0,e)||this.prevMatchInRange(t,i,t.doc.length)}getReplacement(t){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(e,i)=>{if("&"==i)return t.match[0];if("$"==i)return"$";for(let e=i.length;e>0;e--){let n=+i.slice(0,e);if(n>0&&n<t.match.length)return t.match[n]+i.slice(e)}return e})}matchAll(t,e){let i=rg(this.spec,t,0,t.doc.length),n=[];for(;!i.next().done;){if(n.length>=e)return null;n.push(i.value)}return n}highlight(t,e,i,n){let s=rg(this.spec,t,Math.max(0,e-250),Math.min(i+250,t.doc.length));for(;!s.next().done;)n(s.value.from,s.value.to)}}const hg=js.define(),ug=js.define(),dg=gs.define({create:t=>new fg(Sg(t).create(),null),update(t,e){for(let i of e.effects)i.is(hg)?t=new fg(i.value.create(),t.panel):i.is(ug)&&(t=new fg(t.query,i.value?_g:null));return t},provide:t=>Vh.from(t,t=>t.panel)});class fg{constructor(t,e){this.query=t,this.panel=e}}const pg=Mr.mark({class:"cm-searchMatch"}),mg=Mr.mark({class:"cm-searchMatch cm-searchMatch-selected"}),gg=Pa.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(dg))}update(t){let e=t.state.field(dg);(e!=t.startState.field(dg)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return Mr.none;let{view:i}=this,n=new so;for(let e=0,s=i.visibleRanges,o=s.length;e<o;e++){let{from:r,to:a}=s[e];for(;e<o-1&&a>s[e+1].from-500;)a=s[++e].to;t.highlight(i.state,r,a,(t,e)=>{let s=i.state.selection.ranges.some(i=>i.from==t&&i.to==e);n.add(t,e,s?mg:pg)})}return n.finish()}},{decorations:t=>t.decorations});function vg(t){return e=>{let i=e.state.field(dg,!1);return i&&i.query.spec.valid?t(e,i):Cg(e)}}const yg=vg((t,{query:e})=>{let{to:i}=t.state.selection.main,n=e.nextMatch(t.state,i,i);if(!n)return!1;let s=rs.single(n.from,n.to),o=t.state.facet(eg);return t.dispatch({selection:s,effects:[Dg(t,n),o.scrollToMatch(s.main,t)],userEvent:"select.search"}),$g(t),!0}),Og=vg((t,{query:e})=>{let{state:i}=t,{from:n}=i.selection.main,s=e.prevMatch(i,n,n);if(!s)return!1;let o=rs.single(s.from,s.to),r=t.state.facet(eg);return t.dispatch({selection:o,effects:[Dg(t,s),r.scrollToMatch(o.main,t)],userEvent:"select.search"}),$g(t),!0}),bg=vg((t,{query:e})=>{let i=e.matchAll(t.state,1e3);return!(!i||!i.length)&&(t.dispatch({selection:rs.create(i.map(t=>rs.range(t.from,t.to))),userEvent:"select.search.matches"}),!0)}),xg=vg((t,{query:e})=>{let{state:i}=t,{from:n,to:s}=i.selection.main;if(i.readOnly)return!1;let o=e.nextMatch(i,n,n);if(!o)return!1;let r,a,l=o,c=[],h=[];l.from==n&&l.to==s&&(a=i.toText(e.getReplacement(l)),c.push({from:l.from,to:l.to,insert:a}),l=e.nextMatch(i,l.from,l.to),h.push(Tc.announce.of(i.phrase("replaced match on line $",i.doc.lineAt(n).number)+".")));let u=t.state.changes(c);return l&&(r=rs.single(l.from,l.to).map(u),h.push(Dg(t,l)),h.push(i.facet(eg).scrollToMatch(r.main,t))),t.dispatch({changes:u,selection:r,effects:h,userEvent:"input.replace"}),!0}),wg=vg((t,{query:e})=>{if(t.state.readOnly)return!1;let i=e.matchAll(t.state,1e9).map(t=>{let{from:i,to:n}=t;return{from:i,to:n,insert:e.getReplacement(t)}});if(!i.length)return!1;let n=t.state.phrase("replaced $ matches",i.length)+".";return t.dispatch({changes:i,effects:Tc.announce.of(n),userEvent:"input.replace.all"}),!0});function _g(t){return t.state.facet(eg).createPanel(t)}function Sg(t,e){var i,n,s,o,r;let a=t.selection.main,l=a.empty||a.to>a.from+100?"":t.sliceDoc(a.from,a.to);if(e&&!l)return e;let c=t.facet(eg);return new ig({search:(null!==(i=null==e?void 0:e.literal)&&void 0!==i?i:c.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:null!==(n=null==e?void 0:e.caseSensitive)&&void 0!==n?n:c.caseSensitive,literal:null!==(s=null==e?void 0:e.literal)&&void 0!==s?s:c.literal,regexp:null!==(o=null==e?void 0:e.regexp)&&void 0!==o?o:c.regexp,wholeWord:null!==(r=null==e?void 0:e.wholeWord)&&void 0!==r?r:c.wholeWord})}function kg(t){let e=Fh(t,_g);return e&&e.dom.querySelector("[main-field]")}function $g(t){let e=kg(t);e&&e==t.root.activeElement&&e.select()}const Cg=t=>{let e=t.state.field(dg,!1);if(e&&e.panel){let i=kg(t);if(i&&i!=t.root.activeElement){let n=Sg(t.state,e.query.spec);n.valid&&t.dispatch({effects:hg.of(n)}),i.focus(),i.select()}}else t.dispatch({effects:[ug.of(!0),e?hg.of(Sg(t.state,e.query.spec)):js.appendConfig.of(Ig)]});return!0},Tg=t=>{let e=t.state.field(dg,!1);if(!e||!e.panel)return!1;let i=Fh(t,_g);return i&&i.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:ug.of(!1)}),!0},Pg=[{key:"Mod-f",run:Cg,scope:"editor search-panel"},{key:"F3",run:yg,shift:Og,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:yg,shift:Og,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Tg,scope:"editor search-panel"},{key:"Mod-Shift-l",run:({state:t,dispatch:e})=>{let i=t.selection;if(i.ranges.length>1||i.main.empty)return!1;let{from:n,to:s}=i.main,o=[],r=0;for(let e=new Rm(t.doc,t.sliceDoc(n,s));!e.next().done;){if(o.length>1e3)return!1;e.value.from==n&&(r=o.length),o.push(rs.range(e.value.from,e.value.to))}return e(t.update({selection:rs.create(o,r),userEvent:"select.search.matches"})),!0}},{key:"Mod-Alt-g",run:t=>{let e=Fh(t,Zm);if(!e){let i=[Fm.of(!0)];null==t.state.field(Xm,!1)&&i.push(js.appendConfig.of([Xm,Hm])),t.dispatch({effects:i}),e=Fh(t,Zm)}return e&&e.dom.querySelector("input").select(),!0}},{key:"Mod-d",run:({state:t,dispatch:e})=>{let{ranges:i}=t.selection;if(i.some(t=>t.from===t.to))return(({state:t,dispatch:e})=>{let{selection:i}=t,n=rs.create(i.ranges.map(e=>t.wordAt(e.head)||rs.cursor(e.head)),i.mainIndex);return!n.eq(i)&&(e(t.update({selection:n})),!0)})({state:t,dispatch:e});let n=t.sliceDoc(i[0].from,i[0].to);if(t.selection.ranges.some(e=>t.sliceDoc(e.from,e.to)!=n))return!1;let s=function(t,e){let{main:i,ranges:n}=t.selection,s=t.wordAt(i.head),o=s&&s.from==i.from&&s.to==i.to;for(let i=!1,s=new Rm(t.doc,e,n[n.length-1].to);;){if(s.next(),!s.done){if(i&&n.some(t=>t.from==s.value.from))continue;if(o){let e=t.wordAt(s.value.from);if(!e||e.from!=s.value.from||e.to!=s.value.to)continue}return s.value}if(i)return null;s=new Rm(t.doc,e,0,Math.max(0,n[n.length-1].from-1)),i=!0}}(t,n);return!!s&&(e(t.update({selection:t.selection.addRange(rs.range(s.from,s.to),!1),effects:Tc.scrollIntoView(s.to)})),!0)},preventDefault:!0}];class Eg{constructor(t){this.view=t;let e=this.query=t.state.field(dg).query.spec;function i(t,e,i){return Mm("button",{class:"cm-button",name:t,onclick:e,type:"button"},i)}this.commit=this.commit.bind(this),this.searchField=Mm("input",{value:e.search,placeholder:Ag(t,"Find"),"aria-label":Ag(t,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Mm("input",{value:e.replace,placeholder:Ag(t,"Replace"),"aria-label":Ag(t,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=Mm("input",{type:"checkbox",name:"case",form:"",checked:e.caseSensitive,onchange:this.commit}),this.reField=Mm("input",{type:"checkbox",name:"re",form:"",checked:e.regexp,onchange:this.commit}),this.wordField=Mm("input",{type:"checkbox",name:"word",form:"",checked:e.wholeWord,onchange:this.commit}),this.dom=Mm("div",{onkeydown:t=>this.keydown(t),class:"cm-search"},[this.searchField,i("next",()=>yg(t),[Ag(t,"next")]),i("prev",()=>Og(t),[Ag(t,"previous")]),i("select",()=>bg(t),[Ag(t,"all")]),Mm("label",null,[this.caseField,Ag(t,"match case")]),Mm("label",null,[this.reField,Ag(t,"regexp")]),Mm("label",null,[this.wordField,Ag(t,"by word")]),...t.state.readOnly?[]:[Mm("br"),this.replaceField,i("replace",()=>xg(t),[Ag(t,"replace")]),i("replaceAll",()=>wg(t),[Ag(t,"replace all")])],Mm("button",{name:"close",onclick:()=>Tg(t),"aria-label":Ag(t,"close"),type:"button"},["×"])])}commit(){let t=new ig({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});t.eq(this.query)||(this.query=t,this.view.dispatch({effects:hg.of(t)}))}keydown(t){var e,i,n;e=this.view,i=t,n="search-panel",qc(Nc(e.state),i,e,n)?t.preventDefault():13==t.keyCode&&t.target==this.searchField?(t.preventDefault(),(t.shiftKey?Og:yg)(this.view)):13==t.keyCode&&t.target==this.replaceField&&(t.preventDefault(),xg(this.view))}update(t){for(let e of t.transactions)for(let t of e.effects)t.is(hg)&&!t.value.eq(this.query)&&this.setQuery(t.value)}setQuery(t){this.query=t,this.searchField.value=t.search,this.replaceField.value=t.replace,this.caseField.checked=t.caseSensitive,this.reField.checked=t.regexp,this.wordField.checked=t.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(eg).top}}function Ag(t,e){return t.state.phrase(e)}const Mg=30,Qg=/[\s\.,:;?!]/;function Dg(t,{from:e,to:i}){let n=t.state.doc.lineAt(e),s=t.state.doc.lineAt(i).to,o=Math.max(n.from,e-Mg),r=Math.min(s,i+Mg),a=t.state.sliceDoc(o,r);if(o!=n.from)for(let t=0;t<Mg;t++)if(!Qg.test(a[t+1])&&Qg.test(a[t])){a=a.slice(t);break}if(r!=s)for(let t=a.length-1;t>a.length-Mg;t--)if(!Qg.test(a[t-1])&&Qg.test(a[t])){a=a.slice(0,t);break}return Tc.announce.of(`${t.state.phrase("current match")}. ${a} ${t.state.phrase("on line")} ${n.number}.`)}const Rg=Tc.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),Ig=[dg,ws.low(gg),Rg];class Lg{constructor(t,e,i,n){this.state=t,this.pos=e,this.explicit=i,this.view=n,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let e=Ad(this.state).resolveInner(this.pos,-1);for(;e&&t.indexOf(e.name)<0;)e=e.parent;return e?{from:e.from,to:this.pos,text:this.state.sliceDoc(e.from,this.pos),type:e.type}:null}matchBefore(t){let e=this.state.doc.lineAt(this.pos),i=Math.max(e.from,this.pos-250),n=e.text.slice(i-e.from,this.pos-e.from),s=n.search(qg(t,!1));return s<0?null:{from:i+s,to:this.pos,text:n.slice(s)}}get aborted(){return null==this.abortListeners}addEventListener(t,e,i){"abort"==t&&this.abortListeners&&(this.abortListeners.push(e),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function Ng(t){let e=Object.keys(t).join(""),i=/\w/.test(e);return i&&(e=e.replace(/\w/g,"")),`[${i?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function jg(t){let e=t.map(t=>"string"==typeof t?{label:t}:t),[i,n]=e.every(t=>/^\w+$/.test(t.label))?[/\w*$/,/\w+$/]:function(t){let e=Object.create(null),i=Object.create(null);for(let{label:n}of t){e[n[0]]=!0;for(let t=1;t<n.length;t++)i[n[t]]=!0}let n=Ng(e)+Ng(i)+"*$";return[new RegExp("^"+n),new RegExp(n)]}(e);return t=>{let s=t.matchBefore(n);return s||t.explicit?{from:s?s.from:t.pos,options:e,validFor:i}:null}}class zg{constructor(t,e,i,n){this.completion=t,this.source=e,this.match=i,this.score=n}}function Bg(t){return t.selection.main.from}function qg(t,e){var i;let{source:n}=t,s=e&&"^"!=n[0],o="$"!=n[n.length-1];return s||o?new RegExp(`${s?"^":""}(?:${n})${o?"$":""}`,null!==(i=t.flags)&&void 0!==i?i:t.ignoreCase?"i":""):t}const Zg=Is.define();const Fg=new WeakMap;function Xg(t){if(!Array.isArray(t))return t;let e=Fg.get(t);return e||Fg.set(t,e=jg(t)),e}const Hg=js.define(),Wg=js.define();class Vg{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let e=0;e<t.length;){let i=Hn(t,e),n=Vn(i);this.chars.push(i);let s=t.slice(e,e+n),o=s.toUpperCase();this.folded.push(Hn(o==s?s.toLowerCase():o,0)),e+=n}this.astral=t.length!=this.chars.length}ret(t,e){return this.score=t,this.matched=e,this}match(t){if(0==this.pattern.length)return this.ret(-100,[]);if(t.length<this.pattern.length)return null;let{chars:e,folded:i,any:n,precise:s,byWord:o}=this;if(1==e.length){let n=Hn(t,0),s=Vn(n),o=s==t.length?0:-100;if(n==e[0]);else{if(n!=i[0])return null;o+=-200}return this.ret(o,[0,s])}let r=t.indexOf(this.pattern);if(0==r)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=e.length,l=0;if(r<0){for(let s=0,o=Math.min(t.length,200);s<o&&l<a;){let o=Hn(t,s);o!=e[l]&&o!=i[l]||(n[l++]=s),s+=Vn(o)}if(l<a)return null}let c=0,h=0,u=!1,d=0,f=-1,p=-1,m=/[a-z]/.test(t),g=!0;for(let n=0,l=Math.min(t.length,200),v=0;n<l&&h<a;){let l=Hn(t,n);r<0&&(c<a&&l==e[c]&&(s[c++]=n),d<a&&(l==e[d]||l==i[d]?(0==d&&(f=n),p=n+1,d++):d=0));let y,O=l<255?l>=48&&l<=57||l>=97&&l<=122?2:l>=65&&l<=90?1:0:(y=Wn(l))!=y.toLowerCase()?1:y!=y.toUpperCase()?2:0;(!n||1==O&&m||0==v&&0!=O)&&(e[h]==l||i[h]==l&&(u=!0)?o[h++]=n:o.length&&(g=!1)),v=O,n+=Vn(l)}return h==a&&0==o[0]&&g?this.result((u?-200:0)-100,o,t):d==a&&0==f?this.ret(-200-t.length+(p==t.length?0:-100),[0,p]):r>-1?this.ret(-700-t.length,[r,r+this.pattern.length]):d==a?this.ret(-900-t.length,[f,p]):h==a?this.result((u?-200:0)-100-700+(g?0:-1100),o,t):2==e.length?null:this.result((n[0]?-700:0)-200-1100,n,t)}result(t,e,i){let n=[],s=0;for(let t of e){let e=t+(this.astral?Vn(Hn(i,t)):1);s&&n[s-1]==t?n[s-1]=e:(n[s++]=t,n[s++]=e)}return this.ret(t-i.length,n)}}class Yg{constructor(t){this.pattern=t,this.matched=[],this.score=0,this.folded=t.toLowerCase()}match(t){if(t.length<this.pattern.length)return null;let e=t.slice(0,this.pattern.length),i=e==this.pattern?0:e.toLowerCase()==this.folded?-200:null;return null==i?null:(this.matched=[0,e.length],this.score=i+(t.length==this.pattern.length?0:-100),this)}}const Ug=cs.define({combine:t=>Ks(t,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Kg,filterStrict:!1,compareCompletions:(t,e)=>t.label.localeCompare(e.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(t,e)=>t&&e,closeOnBlur:(t,e)=>t&&e,icons:(t,e)=>t&&e,tooltipClass:(t,e)=>i=>Gg(t(i),e(i)),optionClass:(t,e)=>i=>Gg(t(i),e(i)),addToOptions:(t,e)=>t.concat(e),filterStrict:(t,e)=>t||e})});function Gg(t,e){return t?e?t+" "+e:t:e}function Kg(t,e,i,n,s,o){let r,a,l=t.textDirection==Fr.RTL,c=l,h=!1,u="top",d=e.left-s.left,f=s.right-e.right,p=n.right-n.left,m=n.bottom-n.top;if(c&&d<Math.min(p,f)?c=!1:!c&&f<Math.min(p,d)&&(c=!0),p<=(c?d:f))r=Math.max(s.top,Math.min(i.top,s.bottom-m))-e.top,a=Math.min(400,c?d:f);else{h=!0,a=Math.min(400,(l?e.right:s.right-e.left)-30);let t=s.bottom-e.bottom;t>=m||t>e.top?r=i.bottom-e.top:(u="bottom",r=e.bottom-i.top)}return{style:`${u}: ${r/((e.bottom-e.top)/o.offsetHeight)}px; max-width: ${a/((e.right-e.left)/o.offsetWidth)}px`,class:"cm-completionInfo-"+(h?l?"left-narrow":"right-narrow":c?"left":"right")}}function Jg(t,e,i){if(t<=i)return{from:0,to:t};if(e<0&&(e=0),e<=t>>1){let t=Math.floor(e/i);return{from:t*i,to:(t+1)*i}}let n=Math.floor((t-e)/i);return{from:t-(n+1)*i,to:t-n*i}}class tv{constructor(t,e,i){this.view=t,this.stateField=e,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:t=>this.placeInfo(t),key:this},this.space=null,this.currentClass="";let n=t.state.field(e),{options:s,selected:o}=n.open,r=t.state.facet(Ug);this.optionContent=function(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(t){let e=document.createElement("div");return e.classList.add("cm-completionIcon"),t.type&&e.classList.add(...t.type.split(/\s+/g).map(t=>"cm-completionIcon-"+t)),e.setAttribute("aria-hidden","true"),e},position:20}),e.push({render(t,e,i,n){let s=document.createElement("span");s.className="cm-completionLabel";let o=t.displayLabel||t.label,r=0;for(let t=0;t<n.length;){let e=n[t++],i=n[t++];e>r&&s.appendChild(document.createTextNode(o.slice(r,e)));let a=s.appendChild(document.createElement("span"));a.appendChild(document.createTextNode(o.slice(e,i))),a.className="cm-completionMatchedText",r=i}return r<o.length&&s.appendChild(document.createTextNode(o.slice(r))),s},position:50},{render(t){if(!t.detail)return null;let e=document.createElement("span");return e.className="cm-completionDetail",e.textContent=t.detail,e},position:80}),e.sort((t,e)=>t.position-e.position).map(t=>t.render)}(r),this.optionClass=r.optionClass,this.tooltipClass=r.tooltipClass,this.range=Jg(s.length,o,r.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",i=>{let{options:n}=t.state.field(e).open;for(let e,s=i.target;s&&s!=this.dom;s=s.parentNode)if("LI"==s.nodeName&&(e=/-(\d+)$/.exec(s.id))&&+e[1]<n.length)return this.applyCompletion(t,n[+e[1]]),void i.preventDefault()}),this.dom.addEventListener("focusout",e=>{let i=t.state.field(this.stateField,!1);i&&i.tooltip&&t.state.facet(Ug).closeOnBlur&&e.relatedTarget!=t.contentDOM&&t.dispatch({effects:Wg.of(null)})}),this.showOptions(s,n.id)}mount(){this.updateSel()}showOptions(t,e){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t,e,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(t){var e;let i=t.state.field(this.stateField),n=t.startState.field(this.stateField);if(this.updateTooltipClass(t.state),i!=n){let{options:s,selected:o,disabled:r}=i.open;n.open&&n.open.options==s||(this.range=Jg(s.length,o,t.state.facet(Ug).maxRenderedOptions),this.showOptions(s,i.id)),this.updateSel(),r!=(null===(e=n.open)||void 0===e?void 0:e.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!r)}}updateTooltipClass(t){let e=this.tooltipClass(t);if(e!=this.currentClass){for(let t of this.currentClass.split(" "))t&&this.dom.classList.remove(t);for(let t of e.split(" "))t&&this.dom.classList.add(t);this.currentClass=e}}positioned(t){this.space=t,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let t=this.view.state.field(this.stateField),e=t.open;if((e.selected>-1&&e.selected<this.range.from||e.selected>=this.range.to)&&(this.range=Jg(e.options.length,e.selected,this.view.state.facet(Ug).maxRenderedOptions),this.showOptions(e.options,t.id)),this.updateSelectedOption(e.selected)){this.destroyInfo();let{completion:i}=e.options[e.selected],{info:n}=i;if(!n)return;let s="string"==typeof n?document.createTextNode(n):n(i);if(!s)return;"then"in s?s.then(e=>{e&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(e,i)}).catch(t=>ka(this.view.state,t,"completion info")):this.addInfoPane(s,i)}}addInfoPane(t,e){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",null!=t.nodeType)i.appendChild(t),this.infoDestroy=null;else{let{dom:e,destroy:n}=t;i.appendChild(e),this.infoDestroy=n||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){let e=null;for(let i=this.list.firstChild,n=this.range.from;i;i=i.nextSibling,n++)"LI"==i.nodeName&&i.id?n==t?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),e=i):i.hasAttribute("aria-selected")&&i.removeAttribute("aria-selected"):n--;return e&&function(t,e){let i=t.getBoundingClientRect(),n=e.getBoundingClientRect(),s=i.height/t.offsetHeight;n.top<i.top?t.scrollTop-=(i.top-n.top)/s:n.bottom>i.bottom&&(t.scrollTop+=(n.bottom-i.bottom)/s)}(this.list,e),e}measureInfo(){let t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;let e=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),n=t.getBoundingClientRect(),s=this.space;if(!s){let t=this.dom.ownerDocument.documentElement;s={left:0,top:0,right:t.clientWidth,bottom:t.clientHeight}}return n.top>Math.min(s.bottom,e.bottom)-10||n.bottom<Math.max(s.top,e.top)+10?null:this.view.state.facet(Ug).positionInfo(this.view,e,n,i,s,this.dom)}placeInfo(t){this.info&&(t?(t.style&&(this.info.style.cssText=t.style),this.info.className="cm-tooltip cm-completionInfo "+(t.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(t,e,i){const n=document.createElement("ul");n.id=e,n.setAttribute("role","listbox"),n.setAttribute("aria-expanded","true"),n.setAttribute("aria-label",this.view.state.phrase("Completions")),n.addEventListener("mousedown",t=>{t.target==n&&t.preventDefault()});let s=null;for(let o=i.from;o<i.to;o++){let{completion:r,match:a}=t[o],{section:l}=r;if(l){let t="string"==typeof l?l:l.name;if(t!=s&&(o>i.from||0==i.from))if(s=t,"string"!=typeof l&&l.header)n.appendChild(l.header(l));else{n.appendChild(document.createElement("completion-section")).textContent=t}}const c=n.appendChild(document.createElement("li"));c.id=e+"-"+o,c.setAttribute("role","option");let h=this.optionClass(r);h&&(c.className=h);for(let t of this.optionContent){let e=t(r,this.view.state,this.view,a);e&&c.appendChild(e)}}return i.from&&n.classList.add("cm-completionListIncompleteTop"),i.to<t.length&&n.classList.add("cm-completionListIncompleteBottom"),n}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function ev(t,e){return i=>new tv(i,t,e)}function iv(t){return 100*(t.boost||0)+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}class nv{constructor(t,e,i,n,s,o){this.options=t,this.attrs=e,this.tooltip=i,this.timestamp=n,this.selected=s,this.disabled=o}setSelected(t,e){return t==this.selected||t>=this.options.length?this:new nv(this.options,av(e,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,e,i,n,s,o){if(n&&!o&&t.some(t=>t.isPending))return n.setDisabled();let r=function(t,e){let i=[],n=null,s=t=>{i.push(t);let{section:e}=t.completion;if(e){n||(n=[]);let t="string"==typeof e?e:e.name;n.some(e=>e.name==t)||n.push("string"==typeof e?{name:t}:e)}},o=e.facet(Ug);for(let n of t)if(n.hasResult()){let t=n.result.getMatch;if(!1===n.result.filter)for(let e of n.result.options)s(new zg(e,n.source,t?t(e):[],1e9-i.length));else{let i,r=e.sliceDoc(n.from,n.to),a=o.filterStrict?new Yg(r):new Vg(r);for(let e of n.result.options)if(i=a.match(e.label)){let o=e.displayLabel?t?t(e,i.matched):[]:i.matched;s(new zg(e,n.source,o,i.score+(e.boost||0)))}}}if(n){let t=Object.create(null),e=0,s=(t,e)=>{var i,n;return(null!==(i=t.rank)&&void 0!==i?i:1e9)-(null!==(n=e.rank)&&void 0!==n?n:1e9)||(t.name<e.name?-1:1)};for(let i of n.sort(s))e-=1e5,t[i.name]=e;for(let e of i){let{section:i}=e.completion;i&&(e.score+=t["string"==typeof i?i:i.name])}}let r=[],a=null,l=o.compareCompletions;for(let t of i.sort((t,e)=>e.score-t.score||l(t.completion,e.completion))){let e=t.completion;!a||a.label!=e.label||a.detail!=e.detail||null!=a.type&&null!=e.type&&a.type!=e.type||a.apply!=e.apply||a.boost!=e.boost?r.push(t):iv(t.completion)>iv(a)&&(r[r.length-1]=t),a=t.completion}return r}(t,e);if(!r.length)return n&&t.some(t=>t.isPending)?n.setDisabled():null;let a=e.facet(Ug).selectOnOpen?0:-1;if(n&&n.selected!=a&&-1!=n.selected){let t=n.options[n.selected].completion;for(let e=0;e<r.length;e++)if(r[e].completion==t){a=e;break}}return new nv(r,av(i,a),{pos:t.reduce((t,e)=>e.hasResult()?Math.min(t,e.from):t,1e8),create:gv,above:s.aboveCursor},n?n.timestamp:Date.now(),a,!1)}map(t){return new nv(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:t.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}setDisabled(){return new nv(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class sv{constructor(t,e,i){this.active=t,this.id=e,this.open=i}static start(){return new sv(lv,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(t){let{state:e}=t,i=e.facet(Ug),n=(i.override||e.languageDataAt("autocomplete",Bg(e)).map(Xg)).map(e=>(this.active.find(t=>t.source==e)||new hv(e,this.active.some(t=>0!=t.state)?1:0)).update(t,i));n.length==this.active.length&&n.every((t,e)=>t==this.active[e])&&(n=this.active);let s=this.open,o=t.effects.some(t=>t.is(dv));s&&t.docChanged&&(s=s.map(t.changes)),t.selection||n.some(e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to))||!function(t,e){if(t==e)return!0;for(let i=0,n=0;;){for(;i<t.length&&!t[i].hasResult();)i++;for(;n<e.length&&!e[n].hasResult();)n++;let s=i==t.length,o=n==e.length;if(s||o)return s==o;if(t[i++].result!=e[n++].result)return!1}}(n,this.active)||o?s=nv.build(n,e,this.id,s,i,o):s&&s.disabled&&!n.some(t=>t.isPending)&&(s=null),!s&&n.every(t=>!t.isPending)&&n.some(t=>t.hasResult())&&(n=n.map(t=>t.hasResult()?new hv(t.source,0):t));for(let e of t.effects)e.is(fv)&&(s=s&&s.setSelected(e.value,this.id));return n==this.active&&s==this.open?this:new sv(n,this.id,s)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?ov:rv}}const ov={"aria-autocomplete":"list"},rv={};function av(t,e){let i={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(i["aria-activedescendant"]=t+"-"+e),i}const lv=[];function cv(t,e){if(t.isUserEvent("input.complete")){let i=t.annotation(Zg);if(i&&e.activateOnCompletion(i))return 12}let i=t.isUserEvent("input.type");return i&&e.activateOnTyping?5:i?1:t.isUserEvent("delete.backward")?2:t.selection?8:t.docChanged?16:0}class hv{constructor(t,e,i=!1){this.source=t,this.state=e,this.explicit=i}hasResult(){return!1}get isPending(){return 1==this.state}update(t,e){let i=cv(t,e),n=this;(8&i||16&i&&this.touches(t))&&(n=new hv(n.source,0)),4&i&&0==n.state&&(n=new hv(this.source,1)),n=n.updateFor(t,i);for(let e of t.effects)if(e.is(Hg))n=new hv(n.source,1,e.value);else if(e.is(Wg))n=new hv(n.source,0);else if(e.is(dv))for(let t of e.value)t.source==n.source&&(n=t);return n}updateFor(t,e){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(Bg(t.state))}}class uv extends hv{constructor(t,e,i,n,s,o){super(t,3,e),this.limit=i,this.result=n,this.from=s,this.to=o}hasResult(){return!0}updateFor(t,e){var i;if(!(3&e))return this.map(t.changes);let n=this.result;n.map&&!t.changes.empty&&(n=n.map(n,t.changes));let s=t.changes.mapPos(this.from),o=t.changes.mapPos(this.to,1),r=Bg(t.state);if(r>o||!n||2&e&&(Bg(t.startState)==this.from||r<this.limit))return new hv(this.source,4&e?1:0);let a=t.changes.mapPos(this.limit);return function(t,e,i,n){if(!t)return!1;let s=e.sliceDoc(i,n);return"function"==typeof t?t(s,i,n,e):qg(t,!0).test(s)}(n.validFor,t.state,s,o)?new uv(this.source,this.explicit,a,n,s,o):n.update&&(n=n.update(n,s,o,new Lg(t.state,r,!1)))?new uv(this.source,this.explicit,a,n,n.from,null!==(i=n.to)&&void 0!==i?i:Bg(t.state)):new hv(this.source,1,this.explicit)}map(t){if(t.empty)return this;return(this.result.map?this.result.map(this.result,t):this.result)?new uv(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new hv(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}const dv=js.define({map:(t,e)=>t.map(t=>t.map(e))}),fv=js.define(),pv=gs.define({create:()=>sv.start(),update:(t,e)=>t.update(e),provide:t=>[Dh.from(t,t=>t.tooltip),Tc.contentAttributes.from(t,t=>t.attrs)]});function mv(t,e){const i=e.completion.apply||e.completion.label;let n=t.state.field(pv).active.find(t=>t.source==e.source);return n instanceof uv&&("string"==typeof i?t.dispatch(Object.assign(Object.assign({},function(t,e,i,n){let{main:s}=t.selection,o=i-s.from,r=n-s.from;return Object.assign(Object.assign({},t.changeByRange(a=>{if(a!=s&&i!=n&&t.sliceDoc(a.from+o,a.from+r)!=t.sliceDoc(i,n))return{range:a};let l=t.toText(e);return{changes:{from:a.from+o,to:n==s.from?a.to:a.from+r,insert:l},range:rs.cursor(a.from+o+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}(t.state,i,n.from,n.to)),{annotations:Zg.of(e.completion)})):i(t,e.completion,n.from,n.to),!0)}const gv=ev(pv,mv);function vv(t,e="option"){return i=>{let n=i.state.field(pv,!1);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp<i.state.facet(Ug).interactionDelay)return!1;let s,o=1;"page"==e&&(s=Bh(i,n.open.tooltip))&&(o=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let{length:r}=n.open.options,a=n.open.selected>-1?n.open.selected+o*(t?1:-1):t?0:r-1;return a<0?a="page"==e?0:r-1:a>=r&&(a="page"==e?r-1:0),i.dispatch({effects:fv.of(a)}),!0}}const yv=t=>!!t.state.field(pv,!1)&&(t.dispatch({effects:Hg.of(!0)}),!0);class Ov{constructor(t,e){this.active=t,this.context=e,this.time=Date.now(),this.updates=[],this.done=void 0}}const bv=Pa.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of t.state.field(pv).active)e.isPending&&this.startQuery(e)}update(t){let e=t.state.field(pv),i=t.state.facet(Ug);if(!t.selectionSet&&!t.docChanged&&t.startState.field(pv)==e)return;let n=t.transactions.some(t=>{let e=cv(t,i);return 8&e||(t.selection||t.docChanged)&&!(3&e)});for(let e=0;e<this.running.length;e++){let i=this.running[e];if(n||i.context.abortOnDocChange&&t.docChanged||i.updates.length+t.transactions.length>50&&Date.now()-i.time>1e3){for(let t of i.context.abortListeners)try{t()}catch(t){ka(this.view.state,t)}i.context.abortListeners=null,this.running.splice(e--,1)}else i.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some(t=>t.effects.some(t=>t.is(Hg)))&&(this.pendingStart=!0);let s=this.pendingStart?50:i.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(t=>t.isPending&&!this.running.some(e=>e.active.source==t.source))?setTimeout(()=>this.startUpdate(),s):-1,0!=this.composing)for(let e of t.transactions)e.isUserEvent("input.type")?this.composing=2:2==this.composing&&e.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field(pv);for(let t of e.active)t.isPending&&!this.running.some(e=>e.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Ug).updateSyncTime))}startQuery(t){let{state:e}=this.view,i=Bg(e),n=new Lg(e,i,t.explicit,this.view),s=new Ov(t,n);this.running.push(s),Promise.resolve(t.source(n)).then(t=>{s.context.aborted||(s.done=t||null,this.scheduleAccept())},t=>{this.view.dispatch({effects:Wg.of(null)}),ka(this.view.state,t)})}scheduleAccept(){this.running.every(t=>void 0!==t.done)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Ug).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],i=this.view.state.facet(Ug),n=this.view.state.field(pv);for(let s=0;s<this.running.length;s++){let o=this.running[s];if(void 0===o.done)continue;if(this.running.splice(s--,1),o.done){let n=Bg(o.updates.length?o.updates[0].startState:this.view.state),s=Math.min(n,o.done.from+(o.active.explicit?0:1)),r=new uv(o.active.source,o.active.explicit,s,o.done,o.done.from,null!==(t=o.done.to)&&void 0!==t?t:n);for(let t of o.updates)r=r.update(t,i);if(r.hasResult()){e.push(r);continue}}let r=n.active.find(t=>t.source==o.active.source);if(r&&r.isPending)if(null==o.done){let t=new hv(o.active.source,0);for(let e of o.updates)t=t.update(e,i);t.isPending||e.push(t)}else this.startQuery(r)}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:dv.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field(pv,!1);if(e&&e.tooltip&&this.view.state.facet(Ug).closeOnBlur){let i=e.open&&Bh(this.view,e.open.tooltip);i&&i.dom.contains(t.relatedTarget)||setTimeout(()=>this.view.dispatch({effects:Wg.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout(()=>this.view.dispatch({effects:Hg.of(!1)}),20),this.composing=0}}}),xv="object"==typeof navigator&&/Win/.test(navigator.platform),wv=ws.highest(Tc.domEventHandlers({keydown(t,e){let i=e.state.field(pv,!1);if(!i||!i.open||i.open.disabled||i.open.selected<0||t.key.length>1||t.ctrlKey&&(!xv||!t.altKey)||t.metaKey)return!1;let n=i.open.options[i.open.selected],s=i.active.find(t=>t.source==n.source),o=n.completion.commitCharacters||s.result.commitCharacters;return o&&o.indexOf(t.key)>-1&&mv(e,n),!1}})),_v=Tc.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class Sv{constructor(t,e,i,n){this.field=t,this.line=e,this.from=i,this.to=n}}class kv{constructor(t,e,i){this.field=t,this.from=e,this.to=i}map(t){let e=t.mapPos(this.from,-1,Un.TrackDel),i=t.mapPos(this.to,1,Un.TrackDel);return null==e||null==i?null:new kv(this.field,e,i)}}class $v{constructor(t,e){this.lines=t,this.fieldPositions=e}instantiate(t,e){let i=[],n=[e],s=t.doc.lineAt(e),o=/^\s*/.exec(s.text)[0];for(let s of this.lines){if(i.length){let i=o,r=/^\t*/.exec(s)[0].length;for(let e=0;e<r;e++)i+=t.facet(Zd);n.push(e+i.length-r),s=i+s.slice(r)}i.push(s),e+=s.length+1}let r=this.fieldPositions.map(t=>new kv(t.field,n[t.line]+t.from,n[t.line]+t.to));return{text:i,ranges:r}}static parse(t){let e,i=[],n=[],s=[];for(let o of t.split(/\r\n?|\n/)){for(;e=/[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(o);){let t=e[1]?+e[1]:null,r=e[2]||e[3]||"",a=-1,l=r.replace(/\\[{}]/g,t=>t[1]);for(let e=0;e<i.length;e++)(null!=t?i[e].seq==t:l&&i[e].name==l)&&(a=e);if(a<0){let e=0;for(;e<i.length&&(null==t||null!=i[e].seq&&i[e].seq<t);)e++;i.splice(e,0,{seq:t,name:l}),a=e;for(let t of s)t.field>=a&&t.field++}s.push(new Sv(a,n.length,e.index,e.index+l.length)),o=o.slice(0,e.index)+r+o.slice(e.index+e[0].length)}o=o.replace(/\\([{}])/g,(t,e,i)=>{for(let t of s)t.line==n.length&&t.from>i&&(t.from--,t.to--);return e}),n.push(o)}return new $v(n,s)}}let Cv=Mr.widget({widget:new class extends Er{toDOM(){let t=document.createElement("span");return t.className="cm-snippetFieldPosition",t}ignoreEvent(){return!1}}}),Tv=Mr.mark({class:"cm-snippetField"});class Pv{constructor(t,e){this.ranges=t,this.active=e,this.deco=Mr.set(t.map(t=>(t.from==t.to?Cv:Tv).range(t.from,t.to)))}map(t){let e=[];for(let i of this.ranges){let n=i.map(t);if(!n)return null;e.push(n)}return new Pv(e,this.active)}selectionInsideField(t){return t.ranges.every(t=>this.ranges.some(e=>e.field==this.active&&e.from<=t.from&&e.to>=t.to))}}const Ev=js.define({map:(t,e)=>t&&t.map(e)}),Av=js.define(),Mv=gs.define({create:()=>null,update(t,e){for(let i of e.effects){if(i.is(Ev))return i.value;if(i.is(Av)&&t)return new Pv(t.ranges,i.value)}return t&&e.docChanged&&(t=t.map(e.changes)),t&&e.selection&&!t.selectionInsideField(e.selection)&&(t=null),t},provide:t=>Tc.decorations.from(t,t=>t?t.deco:Mr.none)});function Qv(t,e){return rs.create(t.filter(t=>t.field==e).map(t=>rs.range(t.from,t.to)))}function Dv(t){let e=$v.parse(t);return(t,i,n,s)=>{let{text:o,ranges:r}=e.instantiate(t.state,n),{main:a}=t.state.selection,l={changes:{from:n,to:s==a.from?a.to:s,insert:Rn.of(o)},scrollIntoView:!0,annotations:i?[Zg.of(i),zs.userEvent.of("input.complete")]:void 0};if(r.length&&(l.selection=Qv(r,0)),r.some(t=>t.field>0)){let e=new Pv(r,0),i=l.effects=[Ev.of(e)];void 0===t.state.field(Mv,!1)&&i.push(js.appendConfig.of([Mv,Nv,zv,_v]))}t.dispatch(t.state.update(l))}}function Rv(t){return({state:e,dispatch:i})=>{let n=e.field(Mv,!1);if(!n||t<0&&0==n.active)return!1;let s=n.active+t,o=t>0&&!n.ranges.some(e=>e.field==s+t);return i(e.update({selection:Qv(n.ranges,s),effects:Ev.of(o?null:new Pv(n.ranges,s)),scrollIntoView:!0})),!0}}const Iv=[{key:"Tab",run:Rv(1),shift:Rv(-1)},{key:"Escape",run:({state:t,dispatch:e})=>!!t.field(Mv,!1)&&(e(t.update({effects:Ev.of(null)})),!0)}],Lv=cs.define({combine:t=>t.length?t[0]:Iv}),Nv=ws.highest(Ic.compute([Lv],t=>t.facet(Lv)));function jv(t,e){return Object.assign(Object.assign({},e),{apply:Dv(t)})}const zv=Tc.domEventHandlers({mousedown(t,e){let i,n=e.state.field(Mv,!1);if(!n||null==(i=e.posAtCoords({x:t.clientX,y:t.clientY})))return!1;let s=n.ranges.find(t=>t.from<=i&&t.to>=i);return!(!s||s.field==n.active)&&(e.dispatch({selection:Qv(n.ranges,s.field),effects:Ev.of(n.ranges.some(t=>t.field>s.field)?new Pv(n.ranges,s.field):null),scrollIntoView:!0}),!0)}});const Bv={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},qv=js.define({map(t,e){let i=e.mapPos(t,-1,Un.TrackAfter);return null==i?void 0:i}}),Zv=new class extends Js{};Zv.startSide=1,Zv.endSide=-1;const Fv=gs.define({create:()=>no.empty,update(t,e){if(t=t.map(e.changes),e.selection){let i=e.state.doc.lineAt(e.selection.main.head);t=t.update({filter:t=>t>=i.from&&t<=i.to})}for(let i of e.effects)i.is(qv)&&(t=t.update({add:[Zv.range(i.value,i.value+1)]}));return t}});const Xv="()[]{}<>«»»«[]{}";function Hv(t){for(let e=0;e<16;e+=2)if(Xv.charCodeAt(e)==t)return Xv.charAt(e+1);return Wn(t<128?t:t+1)}function Wv(t,e){return t.languageDataAt("closeBrackets",e)[0]||Bv}const Vv="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),Yv=Tc.inputHandler.of((t,e,i,n)=>{if((Vv?t.composing:t.compositionStarted)||t.state.readOnly)return!1;let s=t.state.selection.main;if(n.length>2||2==n.length&&1==Vn(Hn(n,0))||e!=s.from||i!=s.to)return!1;let o=function(t,e){let i=Wv(t,t.selection.main.head),n=i.brackets||Bv.brackets;for(let s of n){let o=Hv(Hn(s,0));if(e==s)return o==s?ey(t,s,n.indexOf(s+s+s)>-1,i):Jv(t,s,o,i.before||Bv.before);if(e==o&&Gv(t,t.selection.main.from))return ty(t,s,o)}return null}(t.state,n);return!!o&&(t.dispatch(o),!0)}),Uv=[{key:"Backspace",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=Wv(t,t.selection.main.head).brackets||Bv.brackets,n=null,s=t.changeByRange(e=>{if(e.empty){let n=function(t,e){let i=t.sliceString(e-2,e);return Vn(Hn(i,0))==i.length?i:i.slice(1)}(t.doc,e.head);for(let s of i)if(s==n&&Kv(t.doc,e.head)==Hv(Hn(s,0)))return{changes:{from:e.head-s.length,to:e.head+s.length},range:rs.cursor(e.head-s.length)}}return{range:n=e}});return n||e(t.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!n}}];function Gv(t,e){let i=!1;return t.field(Fv).between(0,t.doc.length,t=>{t==e&&(i=!0)}),i}function Kv(t,e){let i=t.sliceString(e,e+2);return i.slice(0,Vn(Hn(i,0)))}function Jv(t,e,i,n){let s=null,o=t.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:i,from:o.to}],effects:qv.of(o.to+e.length),range:rs.range(o.anchor+e.length,o.head+e.length)};let r=Kv(t.doc,o.head);return!r||/\s/.test(r)||n.indexOf(r)>-1?{changes:{insert:e+i,from:o.head},effects:qv.of(o.head+e.length),range:rs.cursor(o.head+e.length)}:{range:s=o}});return s?null:t.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function ty(t,e,i){let n=null,s=t.changeByRange(e=>e.empty&&Kv(t.doc,e.head)==i?{changes:{from:e.head,to:e.head+i.length,insert:i},range:rs.cursor(e.head+i.length)}:n={range:e});return n?null:t.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function ey(t,e,i,n){let s=n.stringPrefixes||Bv.stringPrefixes,o=null,r=t.changeByRange(n=>{if(!n.empty)return{changes:[{insert:e,from:n.from},{insert:e,from:n.to}],effects:qv.of(n.to+e.length),range:rs.range(n.anchor+e.length,n.head+e.length)};let r,a=n.head,l=Kv(t.doc,a);if(l==e){if(iy(t,a))return{changes:{insert:e+e,from:a},effects:qv.of(a+e.length),range:rs.cursor(a+e.length)};if(Gv(t,a)){let n=i&&t.sliceDoc(a,a+3*e.length)==e+e+e?e+e+e:e;return{changes:{from:a,to:a+n.length,insert:n},range:rs.cursor(a+n.length)}}}else{if(i&&t.sliceDoc(a-2*e.length,a)==e+e&&(r=ny(t,a-2*e.length,s))>-1&&iy(t,r))return{changes:{insert:e+e+e+e,from:a},effects:qv.of(a+e.length),range:rs.cursor(a+e.length)};if(t.charCategorizer(a)(l)!=Ws.Word&&ny(t,a,s)>-1&&!function(t,e,i,n){let s=Ad(t).resolveInner(e,-1),o=n.reduce((t,e)=>Math.max(t,e.length),0);for(let r=0;r<5;r++){let r=t.sliceDoc(s.from,Math.min(s.to,s.from+i.length+o)),a=r.indexOf(i);if(!a||a>-1&&n.indexOf(r.slice(0,a))>-1){let e=s.firstChild;for(;e&&e.from==s.from&&e.to-e.from>i.length+a;){if(t.sliceDoc(e.to-i.length,e.to)==i)return!1;e=e.firstChild}return!0}let l=s.to==e&&s.parent;if(!l)break;s=l}return!1}(t,a,e,s))return{changes:{insert:e+e,from:a},effects:qv.of(a+e.length),range:rs.cursor(a+e.length)}}return{range:o=n}});return o?null:t.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function iy(t,e){let i=Ad(t).resolveInner(e+1);return i.parent&&i.from==e}function ny(t,e,i){let n=t.charCategorizer(e);if(n(t.sliceDoc(e-1,e))!=Ws.Word)return e;for(let s of i){let i=e-s.length;if(t.sliceDoc(i,e)==s&&n(t.sliceDoc(i-1,i))!=Ws.Word)return i}return-1}function sy(t={}){return[wv,pv,Ug.of(t),bv,ry,_v]}const oy=[{key:"Ctrl-Space",run:yv},{mac:"Alt-`",run:yv},{key:"Escape",run:t=>{let e=t.state.field(pv,!1);return!(!e||!e.active.some(t=>0!=t.state))&&(t.dispatch({effects:Wg.of(null)}),!0)}},{key:"ArrowDown",run:vv(!0)},{key:"ArrowUp",run:vv(!1)},{key:"PageDown",run:vv(!0,"page")},{key:"PageUp",run:vv(!1,"page")},{key:"Enter",run:t=>{let e=t.state.field(pv,!1);return!(t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(Ug).interactionDelay)&&mv(t,e.open.options[e.open.selected])}}],ry=ws.highest(Ic.computeN([Ug],t=>t.facet(Ug).defaultKeymap?[oy]:[]));class ay{constructor(t,e,i){this.from=t,this.to=e,this.diagnostic=i}}class ly{constructor(t,e,i){this.diagnostics=t,this.panel=e,this.selected=i}static init(t,e,i){let n=i.facet(xy).markerFilter;n&&(t=n(t,i));let s=t.slice().sort((t,e)=>t.from-e.from||t.to-e.to),o=new so,r=[],a=0;for(let t=0;;){let e,n,l=t==s.length?null:s[t];if(!l&&!r.length)break;for(r.length?(e=a,n=r.reduce((t,e)=>Math.min(t,e.to),l&&l.from>e?l.from:1e8)):(e=l.from,n=l.to,r.push(l),t++);t<s.length;){let i=s[t];if(i.from!=e||!(i.to>i.from||i.to==e)){n=Math.min(i.from,n);break}r.push(i),t++,n=Math.min(i.to,n)}let c=Ay(r);if(r.some(t=>t.from==t.to||t.from==t.to-1&&i.doc.lineAt(t.from).to==t.from))o.add(e,e,Mr.widget({widget:new Sy(c),diagnostics:r.slice()}));else{let t=r.reduce((t,e)=>e.markClass?t+" "+e.markClass:t,"");o.add(e,n,Mr.mark({class:"cm-lintRange cm-lintRange-"+c+t,diagnostics:r.slice(),inclusiveEnd:r.some(t=>t.to>n)}))}a=n;for(let t=0;t<r.length;t++)r[t].to<=a&&r.splice(t--,1)}let l=o.finish();return new ly(l,e,cy(l))}}function cy(t,e=null,i=0){let n=null;return t.between(i,1e9,(t,i,{spec:s})=>{if(!(e&&s.diagnostics.indexOf(e)<0))if(n){if(s.diagnostics.indexOf(n.diagnostic)<0)return!1;n=new ay(n.from,i,n.diagnostic)}else n=new ay(t,i,e||s.diagnostics[0])}),n}function hy(t,e){let i=e.pos,n=e.end||i,s=t.state.facet(xy).hideOn(t,i,n);if(null!=s)return s;let o=t.startState.doc.lineAt(e.pos);return!(!t.effects.some(t=>t.is(dy))&&!t.changes.touchesRange(o.from,Math.max(o.to,n)))}function uy(t,e){return t.field(my,!1)?e:e.concat(js.appendConfig.of(My))}const dy=js.define(),fy=js.define(),py=js.define(),my=gs.define({create:()=>new ly(Mr.none,null,null),update(t,e){if(e.docChanged&&t.diagnostics.size){let i=t.diagnostics.map(e.changes),n=null,s=t.panel;if(t.selected){let s=e.changes.mapPos(t.selected.from,1);n=cy(i,t.selected.diagnostic,s)||cy(i,null,s)}!i.size&&s&&e.state.facet(xy).autoPanel&&(s=null),t=new ly(i,s,n)}for(let i of e.effects)if(i.is(dy)){let n=e.state.facet(xy).autoPanel?i.value.length?$y.open:null:t.panel;t=ly.init(i.value,n,e.state)}else i.is(fy)?t=new ly(t.diagnostics,i.value?$y.open:null,t.selected):i.is(py)&&(t=new ly(t.diagnostics,t.panel,i.value));return t},provide:t=>[Vh.from(t,t=>t.panel),Tc.decorations.from(t,t=>t.diagnostics)]});const gy=Mr.mark({class:"cm-lintRange cm-lintRange-active"});function vy(t,e,i){let n,{diagnostics:s}=t.state.field(my),o=-1,r=-1;s.between(e-(i<0?1:0),e+(i>0?1:0),(t,s,{spec:a})=>{if(e>=t&&e<=s&&(t==s||(e>t||i>0)&&(e<s||i<0)))return n=a.diagnostics,o=t,r=s,!1});let a=t.state.facet(xy).tooltipFilter;return n&&a&&(n=a(n,t.state)),n?{pos:o,end:r,above:t.state.doc.lineAt(o).to<r,create:()=>({dom:yy(t,n)})}:null}function yy(t,e){return Mm("ul",{class:"cm-tooltip-lint"},e.map(e=>_y(t,e,!1)))}const Oy=t=>{let e=t.state.field(my,!1);return!(!e||!e.panel)&&(t.dispatch({effects:fy.of(!1)}),!0)},by=[{key:"Mod-Shift-m",run:t=>{let e=t.state.field(my,!1);e&&e.panel||t.dispatch({effects:uy(t.state,[fy.of(!0)])});let i=Fh(t,$y.open);return i&&i.dom.querySelector(".cm-panel-lint ul").focus(),!0},preventDefault:!0},{key:"F8",run:t=>{let e=t.state.field(my,!1);if(!e)return!1;let i=t.state.selection.main,n=e.diagnostics.iter(i.to+1);return!(!n.value&&(n=e.diagnostics.iter(0),!n.value||n.from==i.from&&n.to==i.to))&&(t.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0}),!0)}}];const xy=cs.define({combine:t=>Object.assign({sources:t.map(t=>t.source).filter(t=>null!=t)},Ks(t.map(t=>t.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(t,e)=>t?e?i=>t(i)||e(i):t:e}))});function wy(t){let e=[];if(t)t:for(let{name:i}of t){for(let t=0;t<i.length;t++){let n=i[t];if(/[a-zA-Z]/.test(n)&&!e.some(t=>t.toLowerCase()==n.toLowerCase())){e.push(n);continue t}}e.push("")}return e}function _y(t,e,i){var n;let s=i?wy(e.actions):[];return Mm("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},Mm("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),null===(n=e.actions)||void 0===n?void 0:n.map((i,n)=>{let o=!1,r=n=>{if(n.preventDefault(),o)return;o=!0;let s=cy(t.state.field(my).diagnostics,e);s&&i.apply(t,s.from,s.to)},{name:a}=i,l=s[n]?a.indexOf(s[n]):-1,c=l<0?a:[a.slice(0,l),Mm("u",a.slice(l,l+1)),a.slice(l+1)];return Mm("button",{type:"button",class:"cm-diagnosticAction",onclick:r,onmousedown:r,"aria-label":` Action: ${a}${l<0?"":` (access key "${s[n]})"`}.`},c)}),e.source&&Mm("div",{class:"cm-diagnosticSource"},e.source))}class Sy extends Er{constructor(t){super(),this.sev=t}eq(t){return t.sev==this.sev}toDOM(){return Mm("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class ky{constructor(t,e){this.diagnostic=e,this.id="item_"+Math.floor(4294967295*Math.random()).toString(16),this.dom=_y(t,e,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class $y{constructor(t){this.view=t,this.items=[];this.list=Mm("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:e=>{if(27==e.keyCode)Oy(this.view),this.view.focus();else if(38==e.keyCode||33==e.keyCode)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(40==e.keyCode||34==e.keyCode)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(36==e.keyCode)this.moveSelection(0);else if(35==e.keyCode)this.moveSelection(this.items.length-1);else if(13==e.keyCode)this.view.focus();else{if(!(e.keyCode>=65&&e.keyCode<=90&&this.selectedIndex>=0))return;{let{diagnostic:i}=this.items[this.selectedIndex],n=wy(i.actions);for(let s=0;s<n.length;s++)if(n[s].toUpperCase().charCodeAt(0)==e.keyCode){let e=cy(this.view.state.field(my).diagnostics,i);e&&i.actions[s].apply(t,e.from,e.to)}}}e.preventDefault()},onclick:t=>{for(let e=0;e<this.items.length;e++)this.items[e].dom.contains(t.target)&&this.moveSelection(e)}}),this.dom=Mm("div",{class:"cm-panel-lint"},this.list,Mm("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>Oy(this.view)},"×")),this.update()}get selectedIndex(){let t=this.view.state.field(my).selected;if(!t)return-1;for(let e=0;e<this.items.length;e++)if(this.items[e].diagnostic==t.diagnostic)return e;return-1}update(){let{diagnostics:t,selected:e}=this.view.state.field(my),i=0,n=!1,s=null,o=new Set;for(t.between(0,this.view.state.doc.length,(t,r,{spec:a})=>{for(let t of a.diagnostics){if(o.has(t))continue;o.add(t);let r,a=-1;for(let e=i;e<this.items.length;e++)if(this.items[e].diagnostic==t){a=e;break}a<0?(r=new ky(this.view,t),this.items.splice(i,0,r),n=!0):(r=this.items[a],a>i&&(this.items.splice(i,a-i),n=!0)),e&&r.diagnostic==e.diagnostic?r.dom.hasAttribute("aria-selected")||(r.dom.setAttribute("aria-selected","true"),s=r):r.dom.hasAttribute("aria-selected")&&r.dom.removeAttribute("aria-selected"),i++}});i<this.items.length&&!(1==this.items.length&&this.items[0].diagnostic.from<0);)n=!0,this.items.pop();0==this.items.length&&(this.items.push(new ky(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),n=!0),s?(this.list.setAttribute("aria-activedescendant",s.id),this.view.requestMeasure({key:this,read:()=>({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:t,panel:e})=>{let i=e.height/this.list.offsetHeight;t.top<e.top?this.list.scrollTop-=(e.top-t.top)/i:t.bottom>e.bottom&&(this.list.scrollTop+=(t.bottom-e.bottom)/i)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),n&&this.sync()}sync(){let t=this.list.firstChild;function e(){let e=t;t=e.nextSibling,e.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;t!=i.dom;)e();t=i.dom.nextSibling}else this.list.insertBefore(i.dom,t);for(;t;)e()}moveSelection(t){if(this.selectedIndex<0)return;let e=cy(this.view.state.field(my).diagnostics,this.items[t].diagnostic);e&&this.view.dispatch({selection:{anchor:e.from,head:e.to},scrollIntoView:!0,effects:py.of(e)})}static open(t){return new $y(t)}}function Cy(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`}function Ty(t){return Cy(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const Py=Tc.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:Ty("#d11")},".cm-lintRange-warning":{backgroundImage:Ty("orange")},".cm-lintRange-info":{backgroundImage:Ty("#999")},".cm-lintRange-hint":{backgroundImage:Ty("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});function Ey(t){return"error"==t?4:"warning"==t?3:"info"==t?2:1}function Ay(t){let e="hint",i=1;for(let n of t){let t=Ey(n.severity);t>i&&(i=t,e=n.severity)}return e}const My=[my,Tc.decorations.compute([my],t=>{let{selected:e,panel:i}=t.field(my);return e&&i&&e.from!=e.to?Mr.set([gy.range(e.from,e.to)]):Mr.none}),zh(vy,{hideOn:hy}),Py];const Qy=(()=>[mu(),yu,dh(),vp(),Cf(),Uc(),[nh,sh],Gs.allowMultipleSelections.of(!0),Gs.transactionFilter.of(t=>{if(!t.docChanged||!t.isUserEvent("input.type")&&!t.isUserEvent("input.complete"))return t;let e=t.startState.languageDataAt("indentOnInput",t.startState.selection.main.head);if(!e.length)return t;let i=t.newDoc,{head:n}=t.newSelection.main,s=i.lineAt(n);if(n>s.from+200)return t;let o=i.sliceString(s.from,n);if(!e.some(t=>t.test(o)))return t;let{state:r}=t,a=-1,l=[];for(let{head:t}of r.selection.ranges){let e=r.doc.lineAt(t);if(e.from==a)continue;a=e.from;let i=Hd(r,e.from);if(null==i)continue;let n=/^\s*/.exec(e.text)[0],s=Xd(r,i);n!=s&&l.push({from:e.from,to:e.from+n.length,insert:s})}return l.length?[t,{changes:l,sequential:!0}]:t}),Qf(If,{fallback:!0}),Xf(),[Yv,Fv],sy(),xh(),Sh(),vh,Ym(),Ic.of([...Uv,...Am,...Pg,...Dp,...yf,...oy,...by])])();class Dy{constructor(t,e,i,n,s,o,r,a,l,c=0,h){this.p=t,this.stack=e,this.state=i,this.reducePos=n,this.pos=s,this.score=o,this.buffer=r,this.bufferBase=a,this.curContext=l,this.lookAhead=c,this.parent=h}toString(){return`[${this.stack.filter((t,e)=>e%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(t,e,i=0){let n=t.parser.context;return new Dy(t,[],e,i,i,0,[],0,n?new Ry(n,n.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(t,e){this.stack.push(this.state,e,this.bufferBase+this.buffer.length),this.state=t}reduce(t){var e;let i=t>>19,n=65535&t,{parser:s}=this.p,o=this.reducePos<this.pos-25;o&&this.setLookAhead(this.pos);let r=s.dynamicPrecedence(n);if(r&&(this.score+=r),0==i)return this.pushState(s.getGoto(this.state,n,!0),this.reducePos),n<s.minRepeatTerm&&this.storeNode(n,this.reducePos,this.reducePos,o?8:4,!0),void this.reduceContext(n,this.reducePos);let a=this.stack.length-3*(i-1)-(262144&t?6:0),l=a?this.stack[a-2]:this.p.ranges[0].from,c=this.reducePos-l;c>=2e3&&!(null===(e=this.p.parser.nodeSet.types[n])||void 0===e?void 0:e.isAnonymous)&&(l==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=l,this.p.lastBigReductionSize=c));let h=a?this.stack[a-1]:0,u=this.bufferBase+this.buffer.length-h;if(n<s.minRepeatTerm||131072&t){let t=s.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(n,l,t,u+4,!0)}if(262144&t)this.state=this.stack[a];else{let t=this.stack[a-3];this.state=s.getGoto(t,n,!0)}for(;this.stack.length>a;)this.stack.pop();this.reduceContext(n,l)}storeNode(t,e,i,n=4,s=!1){if(0==t&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let t=this,n=this.buffer.length;if(0==n&&t.parent&&(n=t.bufferBase-t.parent.bufferBase,t=t.parent),n>0&&0==t.buffer[n-4]&&t.buffer[n-1]>-1){if(e==i)return;if(t.buffer[n-2]>=e)return void(t.buffer[n-2]=i)}}if(s&&this.pos!=i){let s=this.buffer.length;if(s>0&&0!=this.buffer[s-4]){let t=!1;for(let e=s;e>0&&this.buffer[e-2]>i;e-=4)if(this.buffer[e-1]>=0){t=!0;break}if(t)for(;s>0&&this.buffer[s-2]>i;)this.buffer[s]=this.buffer[s-4],this.buffer[s+1]=this.buffer[s-3],this.buffer[s+2]=this.buffer[s-2],this.buffer[s+3]=this.buffer[s-1],s-=4,n>4&&(n-=4)}this.buffer[s]=t,this.buffer[s+1]=e,this.buffer[s+2]=i,this.buffer[s+3]=n}else this.buffer.push(t,e,i,n)}shift(t,e,i,n){if(131072&t)this.pushState(65535&t,this.pos);else if(262144&t)this.pos=n,this.shiftContext(e,i),e<=this.p.parser.maxNode&&this.buffer.push(e,i,n,4);else{let s=t,{parser:o}=this.p;(n>this.pos||e<=o.maxNode)&&(this.pos=n,o.stateFlag(s,1)||(this.reducePos=n)),this.pushState(s,i),this.shiftContext(e,i),e<=o.maxNode&&this.buffer.push(e,i,n,4)}}apply(t,e,i,n){65536&t?this.reduce(t):this.shift(t,e,i,n)}useNode(t,e){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=t)&&(this.p.reused.push(t),i++);let n=this.pos;this.reducePos=this.pos=n+t.length,this.pushState(e,n),this.buffer.push(i,n,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,t,this,this.p.stream.reset(this.pos-t.length)))}split(){let t=this,e=t.buffer.length;for(;e>0&&t.buffer[e-2]>t.reducePos;)e-=4;let i=t.buffer.slice(e),n=t.bufferBase+e;for(;t&&n==t.bufferBase;)t=t.parent;return new Dy(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,n,this.curContext,this.lookAhead,t)}recoverByDelete(t,e){let i=t<=this.p.parser.maxNode;i&&this.storeNode(t,this.pos,e,4),this.storeNode(0,this.pos,e,i?8:4),this.pos=this.reducePos=e,this.score-=190}canShift(t){for(let e=new Iy(this);;){let i=this.p.parser.stateSlot(e.state,4)||this.p.parser.hasAction(e.state,t);if(0==i)return!1;if(!(65536&i))return!0;e.reduce(i)}}recoverByInsert(t){if(this.stack.length>=300)return[];let e=this.p.parser.nextStates(this.state);if(e.length>8||this.stack.length>=120){let i=[];for(let n,s=0;s<e.length;s+=2)(n=e[s+1])!=this.state&&this.p.parser.hasAction(n,t)&&i.push(e[s],n);if(this.stack.length<120)for(let t=0;i.length<8&&t<e.length;t+=2){let n=e[t+1];i.some((t,e)=>1&e&&t==n)||i.push(e[t],n)}e=i}let i=[];for(let t=0;t<e.length&&i.length<4;t+=2){let n=e[t+1];if(n==this.state)continue;let s=this.split();s.pushState(n,this.pos),s.storeNode(0,s.pos,s.pos,4,!0),s.shiftContext(e[t],this.pos),s.reducePos=this.pos,s.score-=200,i.push(s)}return i}forceReduce(){let{parser:t}=this.p,e=t.stateSlot(this.state,5);if(!(65536&e))return!1;if(!t.validAction(this.state,e)){let i=e>>19,n=65535&e,s=this.stack.length-3*i;if(s<0||t.getGoto(this.stack[s],n,!1)<0){let t=this.findForcedReduction();if(null==t)return!1;e=t}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(e),!0}findForcedReduction(){let{parser:t}=this.p,e=[],i=(n,s)=>{if(!e.includes(n))return e.push(n),t.allActions(n,e=>{if(393216&e);else if(65536&e){let i=(e>>19)-s;if(i>1){let n=65535&e,s=this.stack.length-3*i;if(s>=0&&t.getGoto(this.stack[s],n,!1)>=0)return i<<19|65536|n}}else{let t=i(e,s+1);if(null!=t)return t}})};return i(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(3!=this.stack.length)return!1;let{parser:t}=this.p;return 65535==t.data[t.stateSlot(this.state,1)]&&!t.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(t){if(this.state!=t.state||this.stack.length!=t.stack.length)return!1;for(let e=0;e<this.stack.length;e+=3)if(this.stack[e]!=t.stack[e])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(t){return this.p.parser.dialect.flags[t]}shiftContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,t,this,this.p.stream.reset(e)))}reduceContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,t,this,this.p.stream.reset(e)))}emitContext(){let t=this.buffer.length-1;(t<0||-3!=this.buffer[t])&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let t=this.buffer.length-1;(t<0||-4!=this.buffer[t])&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(t){if(t!=this.curContext.context){let e=new Ry(this.curContext.tracker,t);e.hash!=this.curContext.hash&&this.emitContext(),this.curContext=e}}setLookAhead(t){t>this.lookAhead&&(this.emitLookAhead(),this.lookAhead=t)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class Ry{constructor(t,e){this.tracker=t,this.context=e,this.hash=t.strict?t.hash(e):0}}class Iy{constructor(t){this.start=t,this.state=t.state,this.stack=t.stack,this.base=this.stack.length}reduce(t){let e=65535&t,i=t>>19;0==i?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=3*(i-1);let n=this.start.p.parser.getGoto(this.stack[this.base-3],e,!0);this.state=n}}class Ly{constructor(t,e,i){this.stack=t,this.pos=e,this.index=i,this.buffer=t.buffer,0==this.index&&this.maybeNext()}static create(t,e=t.bufferBase+t.buffer.length){return new Ly(t,e,e-t.bufferBase)}maybeNext(){let t=this.stack.parent;null!=t&&(this.index=this.stack.bufferBase-t.bufferBase,this.stack=t,this.buffer=t.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,0==this.index&&this.maybeNext()}fork(){return new Ly(this.stack,this.pos,this.index)}}function Ny(t,e=Uint16Array){if("string"!=typeof t)return t;let i=null;for(let n=0,s=0;n<t.length;){let o=0;for(;;){let e=t.charCodeAt(n++),i=!1;if(126==e){o=65535;break}e>=92&&e--,e>=34&&e--;let s=e-32;if(s>=46&&(s-=46,i=!0),o+=s,i)break;o*=46}i?i[s++]=o:i=new e(o)}return i}class jy{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const zy=new jy;class By{constructor(t,e){this.input=t,this.ranges=e,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=zy,this.rangeIndex=0,this.pos=this.chunkPos=e[0].from,this.range=e[0],this.end=e[e.length-1].to,this.readNext()}resolveOffset(t,e){let i=this.range,n=this.rangeIndex,s=this.pos+t;for(;s<i.from;){if(!n)return null;let t=this.ranges[--n];s-=i.from-t.to,i=t}for(;e<0?s>i.to:s>=i.to;){if(n==this.ranges.length-1)return null;let t=this.ranges[++n];s+=t.from-i.to,i=t}return s}clipPos(t){if(t>=this.range.from&&t<this.range.to)return t;for(let e of this.ranges)if(e.to>t)return Math.max(t,e.from);return this.end}peek(t){let e,i,n=this.chunkOff+t;if(n>=0&&n<this.chunk.length)e=this.pos+t,i=this.chunk.charCodeAt(n);else{let n=this.resolveOffset(t,1);if(null==n)return-1;if(e=n,e>=this.chunk2Pos&&e<this.chunk2Pos+this.chunk2.length)i=this.chunk2.charCodeAt(e-this.chunk2Pos);else{let t=this.rangeIndex,n=this.range;for(;n.to<=e;)n=this.ranges[++t];this.chunk2=this.input.chunk(this.chunk2Pos=e),e+this.chunk2.length>n.to&&(this.chunk2=this.chunk2.slice(0,n.to-e)),i=this.chunk2.charCodeAt(0)}}return e>=this.token.lookAhead&&(this.token.lookAhead=e+1),i}acceptToken(t,e=0){let i=e?this.resolveOffset(e,-1):this.pos;if(null==i||i<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=t,this.token.end=i}acceptTokenTo(t,e){this.token.value=t,this.token.end=e}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:t,chunkPos:e}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=t,this.chunk2Pos=e,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let t=this.input.chunk(this.pos),e=this.pos+t.length;this.chunk=e>this.range.to?t.slice(0,this.range.to-this.pos):t,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(t=1){for(this.chunkOff+=t;this.pos+t>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();t-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=t,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(t,e){if(e?(this.token=e,e.start=t,e.lookAhead=t+1,e.value=e.extended=-1):this.token=zy,this.pos!=t){if(this.pos=t,t==this.end)return this.setDone(),this;for(;t<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;t>=this.range.to;)this.range=this.ranges[++this.rangeIndex];t>=this.chunkPos&&t<this.chunkPos+this.chunk.length?this.chunkOff=t-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(t,e){if(t>=this.chunkPos&&e<=this.chunkPos+this.chunk.length)return this.chunk.slice(t-this.chunkPos,e-this.chunkPos);if(t>=this.chunk2Pos&&e<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(t-this.chunk2Pos,e-this.chunk2Pos);if(t>=this.range.from&&e<=this.range.to)return this.input.read(t,e);let i="";for(let n of this.ranges){if(n.from>=e)break;n.to>t&&(i+=this.input.read(Math.max(n.from,t),Math.min(n.to,e)))}return i}}class qy{constructor(t,e){this.data=t,this.id=e}token(t,e){let{parser:i}=e.p;Xy(this.data,t,e,this.id,i.data,i.tokenPrecTable)}}qy.prototype.contextual=qy.prototype.fallback=qy.prototype.extend=!1;class Zy{constructor(t,e,i){this.precTable=e,this.elseToken=i,this.data="string"==typeof t?Ny(t):t}token(t,e){let i=t.pos,n=0;for(;;){let i=t.next<0,s=t.resolveOffset(1,1);if(Xy(this.data,t,e,0,this.data,this.precTable),t.token.value>-1)break;if(null==this.elseToken)return;if(i||n++,null==s)break;t.reset(s,t.token)}n&&(t.reset(i,t.token),t.acceptToken(this.elseToken,n))}}Zy.prototype.contextual=qy.prototype.fallback=qy.prototype.extend=!1;class Fy{constructor(t,e={}){this.token=t,this.contextual=!!e.contextual,this.fallback=!!e.fallback,this.extend=!!e.extend}}function Xy(t,e,i,n,s,o){let r=0,a=1<<n,{dialect:l}=i.p.parser;t:for(;0!=(a&t[r]);){let i=t[r+1];for(let n=r+3;n<i;n+=2)if((t[n+1]&a)>0){let i=t[n];if(l.allows(i)&&(-1==e.token.value||e.token.value==i||Wy(i,e.token.value,s,o))){e.acceptToken(i);break}}let n=e.next,c=0,h=t[r+2];if(!(e.next<0&&h>c&&65535==t[i+3*h-3])){for(;c<h;){let s=c+h>>1,o=i+s+(s<<1),a=t[o],l=t[o+1]||65536;if(n<a)h=s;else{if(!(n>=l)){r=t[o+2],e.advance();continue t}c=s+1}}break}r=t[i+3*h-1]}}function Hy(t,e,i){for(let n,s=e;65535!=(n=t[s]);s++)if(n==i)return s-e;return-1}function Wy(t,e,i,n){let s=Hy(i,n,e);return s<0||Hy(i,n,t)<s}const Vy="undefined"!=typeof process&&process.env&&/\bparse\b/.test(process.env.LOG);let Yy=null;function Uy(t,e,i){let n=t.cursor(Pu.IncludeAnonymous);for(n.moveTo(e);;)if(!(i<0?n.childBefore(e):n.childAfter(e)))for(;;){if((i<0?n.to<e:n.from>e)&&!n.type.isError)return i<0?Math.max(0,Math.min(n.to-1,e-25)):Math.min(t.length,Math.max(n.from+1,e+25));if(i<0?n.prevSibling():n.nextSibling())break;if(!n.parent())return i<0?0:t.length}}class Gy{constructor(t,e){this.fragments=t,this.nodeSet=e,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let t=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(t){for(this.safeFrom=t.openStart?Uy(t.tree,t.from+t.offset,1)-t.offset:t.from,this.safeTo=t.openEnd?Uy(t.tree,t.to+t.offset,-1)-t.offset:t.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(t.tree),this.start.push(-t.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(t){if(t<this.nextStart)return null;for(;this.fragment&&this.safeTo<=t;)this.nextFragment();if(!this.fragment)return null;for(;;){let e=this.trees.length-1;if(e<0)return this.nextFragment(),null;let i=this.trees[e],n=this.index[e];if(n==i.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let s=i.children[n],o=this.start[e]+i.positions[n];if(o>t)return this.nextStart=o,null;if(s instanceof Eu){if(o==t){if(o<this.safeFrom)return null;let t=o+s.length;if(t<=this.safeTo){let e=s.prop(wu.lookAhead);if(!e||t+e<this.fragment.to)return s}}this.index[e]++,o+s.length>=Math.max(this.safeFrom,t)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[e]++,this.nextStart=o+s.length}}}class Ky{constructor(t,e){this.stream=e,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=t.tokenizers.map(t=>new jy)}getActions(t){let e=0,i=null,{parser:n}=t.p,{tokenizers:s}=n,o=n.stateSlot(t.state,3),r=t.curContext?t.curContext.hash:0,a=0;for(let n=0;n<s.length;n++){if(!(1<<n&o))continue;let l=s[n],c=this.tokens[n];if((!i||l.fallback)&&((l.contextual||c.start!=t.pos||c.mask!=o||c.context!=r)&&(this.updateCachedToken(c,l,t),c.mask=o,c.context=r),c.lookAhead>c.end+25&&(a=Math.max(c.lookAhead,a)),0!=c.value)){let n=e;if(c.extended>-1&&(e=this.addActions(t,c.extended,c.end,e)),e=this.addActions(t,c.value,c.end,e),!l.extend&&(i=c,e>n))break}}for(;this.actions.length>e;)this.actions.pop();return a&&t.setLookAhead(a),i||t.pos!=this.stream.end||(i=new jy,i.value=t.p.parser.eofTerm,i.start=i.end=t.pos,e=this.addActions(t,i.value,i.end,e)),this.mainToken=i,this.actions}getMainToken(t){if(this.mainToken)return this.mainToken;let e=new jy,{pos:i,p:n}=t;return e.start=i,e.end=Math.min(i+1,n.stream.end),e.value=i==n.stream.end?n.parser.eofTerm:0,e}updateCachedToken(t,e,i){let n=this.stream.clipPos(i.pos);if(e.token(this.stream.reset(n,t),i),t.value>-1){let{parser:e}=i.p;for(let n=0;n<e.specialized.length;n++)if(e.specialized[n]==t.value){let s=e.specializers[n](this.stream.read(t.start,t.end),i);if(s>=0&&i.p.parser.dialect.allows(s>>1)){1&s?t.extended=s>>1:t.value=s>>1;break}}}else t.value=0,t.end=this.stream.clipPos(n+1)}putAction(t,e,i,n){for(let e=0;e<n;e+=3)if(this.actions[e]==t)return n;return this.actions[n++]=t,this.actions[n++]=e,this.actions[n++]=i,n}addActions(t,e,i,n){let{state:s}=t,{parser:o}=t.p,{data:r}=o;for(let t=0;t<2;t++)for(let a=o.stateSlot(s,t?2:1);;a+=3){if(65535==r[a]){if(1!=r[a+1]){0==n&&2==r[a+1]&&(n=this.putAction(sO(r,a+2),e,i,n));break}a=sO(r,a+2)}r[a]==e&&(n=this.putAction(sO(r,a+1),e,i,n))}return n}}class Jy{constructor(t,e,i,n){this.parser=t,this.input=e,this.ranges=n,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new By(e,n),this.tokens=new Ky(t,this.stream),this.topTerm=t.top[1];let{from:s}=n[0];this.stacks=[Dy.start(this,t.top[0],s)],this.fragments=i.length&&this.stream.end-s>4*t.bufferLength?new Gy(i,t.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let t,e,i=this.stacks,n=this.minStackPos,s=this.stacks=[];if(this.bigReductionCount>300&&1==i.length){let[t]=i;for(;t.forceReduce()&&t.stack.length&&t.stack[t.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<i.length;o++){let r=i[o];for(;;){if(this.tokens.mainToken=null,r.pos>n)s.push(r);else{if(this.advanceStack(r,s,i))continue;{t||(t=[],e=[]),t.push(r);let i=this.tokens.getMainToken(r);e.push(i.value,i.end)}}break}}if(!s.length){let e=t&&function(t){let e=null;for(let i of t){let t=i.p.stoppedAt;(i.pos==i.p.stream.end||null!=t&&i.pos>t)&&i.p.parser.stateFlag(i.state,2)&&(!e||e.score<i.score)&&(e=i)}return e}(t);if(e)return Vy&&console.log("Finish with "+this.stackID(e)),this.stackToTree(e);if(this.parser.strict)throw Vy&&t&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+n);this.recovering||(this.recovering=5)}if(this.recovering&&t){let i=null!=this.stoppedAt&&t[0].pos>this.stoppedAt?t[0]:this.runRecovery(t,e,s);if(i)return Vy&&console.log("Force-finish "+this.stackID(i)),this.stackToTree(i.forceAll())}if(this.recovering){let t=1==this.recovering?1:3*this.recovering;if(s.length>t)for(s.sort((t,e)=>e.score-t.score);s.length>t;)s.pop();s.some(t=>t.reducePos>n)&&this.recovering--}else if(s.length>1){t:for(let t=0;t<s.length-1;t++){let e=s[t];for(let i=t+1;i<s.length;i++){let n=s[i];if(e.sameState(n)||e.buffer.length>500&&n.buffer.length>500){if(!((e.score-n.score||e.buffer.length-n.buffer.length)>0)){s.splice(t--,1);continue t}s.splice(i--,1)}}}s.length>12&&s.splice(12,s.length-12)}this.minStackPos=s[0].pos;for(let t=1;t<s.length;t++)s[t].pos<this.minStackPos&&(this.minStackPos=s[t].pos);return null}stopAt(t){if(null!=this.stoppedAt&&this.stoppedAt<t)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=t}advanceStack(t,e,i){let n=t.pos,{parser:s}=this,o=Vy?this.stackID(t)+" -> ":"";if(null!=this.stoppedAt&&n>this.stoppedAt)return t.forceReduce()?t:null;if(this.fragments){let e=t.curContext&&t.curContext.tracker.strict,i=e?t.curContext.hash:0;for(let r=this.fragments.nodeAt(n);r;){let n=this.parser.nodeSet.types[r.type.id]==r.type?s.getGoto(t.state,r.type.id):-1;if(n>-1&&r.length&&(!e||(r.prop(wu.contextHash)||0)==i))return t.useNode(r,n),Vy&&console.log(o+this.stackID(t)+` (via reuse of ${s.getName(r.type.id)})`),!0;if(!(r instanceof Eu)||0==r.children.length||r.positions[0]>0)break;let a=r.children[0];if(!(a instanceof Eu&&0==r.positions[0]))break;r=a}}let r=s.stateSlot(t.state,4);if(r>0)return t.reduce(r),Vy&&console.log(o+this.stackID(t)+` (via always-reduce ${s.getName(65535&r)})`),!0;if(t.stack.length>=8400)for(;t.stack.length>6e3&&t.forceReduce(););let a=this.tokens.getActions(t);for(let r=0;r<a.length;){let l=a[r++],c=a[r++],h=a[r++],u=r==a.length||!i,d=u?t:t.split(),f=this.tokens.mainToken;if(d.apply(l,c,f?f.start:d.pos,h),Vy&&console.log(o+this.stackID(d)+` (via ${65536&l?`reduce of ${s.getName(65535&l)}`:"shift"} for ${s.getName(c)} @ ${n}${d==t?"":", split"})`),u)return!0;d.pos>n?e.push(d):i.push(d)}return!1}advanceFully(t,e){let i=t.pos;for(;;){if(!this.advanceStack(t,null,null))return!1;if(t.pos>i)return tO(t,e),!0}}runRecovery(t,e,i){let n=null,s=!1;for(let o=0;o<t.length;o++){let r=t[o],a=e[o<<1],l=e[1+(o<<1)],c=Vy?this.stackID(r)+" -> ":"";if(r.deadEnd){if(s)continue;if(s=!0,r.restart(),Vy&&console.log(c+this.stackID(r)+" (restarted)"),this.advanceFully(r,i))continue}let h=r.split(),u=c;for(let t=0;h.forceReduce()&&t<10;t++){if(Vy&&console.log(u+this.stackID(h)+" (via force-reduce)"),this.advanceFully(h,i))break;Vy&&(u=this.stackID(h)+" -> ")}for(let t of r.recoverByInsert(a))Vy&&console.log(c+this.stackID(t)+" (via recover-insert)"),this.advanceFully(t,i);this.stream.end>r.pos?(l==r.pos&&(l++,a=0),r.recoverByDelete(a,l),Vy&&console.log(c+this.stackID(r)+` (via recover-delete ${this.parser.getName(a)})`),tO(r,i)):(!n||n.score<r.score)&&(n=r)}return n}stackToTree(t){return t.close(),Eu.build({buffer:Ly.create(t),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:t.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(t){let e=(Yy||(Yy=new WeakMap)).get(t);return e||Yy.set(t,e=String.fromCodePoint(this.nextStackID++)),e+t}}function tO(t,e){for(let i=0;i<e.length;i++){let n=e[i];if(n.pos==t.pos&&n.sameState(t))return void(e[i].score<t.score&&(e[i]=t))}e.push(t)}class eO{constructor(t,e,i){this.source=t,this.flags=e,this.disabled=i}allows(t){return!this.disabled||0==this.disabled[t]}}const iO=t=>t;class nO extends Uu{constructor(t){if(super(),this.wrappers=[],14!=t.version)throw new RangeError(`Parser version (${t.version}) doesn't match runtime version (14)`);let e=t.nodeNames.split(" ");this.minRepeatTerm=e.length;for(let i=0;i<t.repeatNodeCount;i++)e.push("");let i=Object.keys(t.topRules).map(e=>t.topRules[e][1]),n=[];for(let t=0;t<e.length;t++)n.push([]);function s(t,e,i){n[t].push([e,e.deserialize(String(i))])}if(t.nodeProps)for(let e of t.nodeProps){let t=e[0];"string"==typeof t&&(t=wu[t]);for(let i=1;i<e.length;){let n=e[i++];if(n>=0)s(n,t,e[i++]);else{let o=e[i+-n];for(let r=-n;r>0;r--)s(e[i++],t,o);i++}}}this.nodeSet=new $u(e.map((e,s)=>ku.define({name:s>=this.minRepeatTerm?void 0:e,id:s,props:n[s],top:i.indexOf(s)>-1,error:0==s,skipped:t.skippedNodes&&t.skippedNodes.indexOf(s)>-1}))),t.propSources&&(this.nodeSet=this.nodeSet.extend(...t.propSources)),this.strict=!1,this.bufferLength=Ou;let o=Ny(t.tokenData);this.context=t.context,this.specializerSpecs=t.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let t=0;t<this.specializerSpecs.length;t++)this.specialized[t]=this.specializerSpecs[t].term;this.specializers=this.specializerSpecs.map(oO),this.states=Ny(t.states,Uint32Array),this.data=Ny(t.stateData),this.goto=Ny(t.goto),this.maxTerm=t.maxTerm,this.tokenizers=t.tokenizers.map(t=>"number"==typeof t?new qy(o,t):t),this.topRules=t.topRules,this.dialects=t.dialects||{},this.dynamicPrecedences=t.dynamicPrecedences||null,this.tokenPrecTable=t.tokenPrec,this.termNames=t.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(t,e,i){let n=new Jy(this,t,e,i);for(let s of this.wrappers)n=s(n,t,e,i);return n}getGoto(t,e,i=!1){let n=this.goto;if(e>=n[0])return-1;for(let s=n[e+1];;){let e=n[s++],o=1&e,r=n[s++];if(o&&i)return r;for(let i=s+(e>>1);s<i;s++)if(n[s]==t)return r;if(o)return-1}}hasAction(t,e){let i=this.data;for(let n=0;n<2;n++)for(let s,o=this.stateSlot(t,n?2:1);;o+=3){if(65535==(s=i[o])){if(1!=i[o+1]){if(2==i[o+1])return sO(i,o+2);break}s=i[o=sO(i,o+2)]}if(s==e||0==s)return sO(i,o+1)}return 0}stateSlot(t,e){return this.states[6*t+e]}stateFlag(t,e){return(this.stateSlot(t,0)&e)>0}validAction(t,e){return!!this.allActions(t,t=>t==e||null)}allActions(t,e){let i=this.stateSlot(t,4),n=i?e(i):void 0;for(let i=this.stateSlot(t,1);null==n;i+=3){if(65535==this.data[i]){if(1!=this.data[i+1])break;i=sO(this.data,i+2)}n=e(sO(this.data,i+1))}return n}nextStates(t){let e=[];for(let i=this.stateSlot(t,1);;i+=3){if(65535==this.data[i]){if(1!=this.data[i+1])break;i=sO(this.data,i+2)}if(!(1&this.data[i+2])){let t=this.data[i+1];e.some((e,i)=>1&i&&e==t)||e.push(this.data[i],t)}}return e}configure(t){let e=Object.assign(Object.create(nO.prototype),this);if(t.props&&(e.nodeSet=this.nodeSet.extend(...t.props)),t.top){let i=this.topRules[t.top];if(!i)throw new RangeError(`Invalid top rule name ${t.top}`);e.top=i}return t.tokenizers&&(e.tokenizers=this.tokenizers.map(e=>{let i=t.tokenizers.find(t=>t.from==e);return i?i.to:e})),t.specializers&&(e.specializers=this.specializers.slice(),e.specializerSpecs=this.specializerSpecs.map((i,n)=>{let s=t.specializers.find(t=>t.from==i.external);if(!s)return i;let o=Object.assign(Object.assign({},i),{external:s.to});return e.specializers[n]=oO(o),o})),t.contextTracker&&(e.context=t.contextTracker),t.dialect&&(e.dialect=this.parseDialect(t.dialect)),null!=t.strict&&(e.strict=t.strict),t.wrap&&(e.wrappers=e.wrappers.concat(t.wrap)),null!=t.bufferLength&&(e.bufferLength=t.bufferLength),e}hasWrappers(){return this.wrappers.length>0}getName(t){return this.termNames?this.termNames[t]:String(t<=this.maxNode&&this.nodeSet.types[t].name||t)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(t){let e=this.dynamicPrecedences;return null==e?0:e[t]||0}parseDialect(t){let e=Object.keys(this.dialects),i=e.map(()=>!1);if(t)for(let n of t.split(" ")){let t=e.indexOf(n);t>=0&&(i[t]=!0)}let n=null;for(let t=0;t<e.length;t++)if(!i[t])for(let i,s=this.dialects[e[t]];65535!=(i=this.data[s++]);)(n||(n=new Uint8Array(this.maxTerm+1)))[i]=1;return new eO(t,i,n)}static deserialize(t){return new nO(t)}}function sO(t,e){return t[e]|t[e+1]<<16}function oO(t){if(t.external){let e=t.extend?1:0;return(i,n)=>t.external(i,n)<<1|e}return t.get}const rO=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],aO=new class{constructor(t){this.start=t.start,this.shift=t.shift||iO,this.reduce=t.reduce||iO,this.reuse=t.reuse||iO,this.hash=t.hash||(()=>0),this.strict=!1!==t.strict}}({start:!1,shift:(t,e)=>5==e||6==e||319==e?t:320==e,strict:!1}),lO=new Fy((t,e)=>{let{next:i}=t;(125==i||-1==i||e.context)&&t.acceptToken(317)},{contextual:!0,fallback:!0}),cO=new Fy((t,e)=>{let i,{next:n}=t;rO.indexOf(n)>-1||(47!=n||47!=(i=t.peek(1))&&42!=i)&&(125==n||59==n||-1==n||e.context||t.acceptToken(315))},{contextual:!0}),hO=new Fy((t,e)=>{91!=t.next||e.context||t.acceptToken(316)},{contextual:!0}),uO=new Fy((t,e)=>{let{next:i}=t;if(43==i||45==i){if(t.advance(),i==t.next){t.advance();let i=!e.context&&e.canShift(1);t.acceptToken(i?1:2)}}else 63==i&&46==t.peek(1)&&(t.advance(),t.advance(),(t.next<48||t.next>57)&&t.acceptToken(3))},{contextual:!0});function dO(t,e){return t>=65&&t<=90||t>=97&&t<=122||95==t||t>=192||!e&&t>=48&&t<=57}const fO=new Fy((t,e)=>{if(60!=t.next||!e.dialectEnabled(0))return;if(t.advance(),47==t.next)return;let i=0;for(;rO.indexOf(t.next)>-1;)t.advance(),i++;if(dO(t.next,!0)){for(t.advance(),i++;dO(t.next,!1);)t.advance(),i++;for(;rO.indexOf(t.next)>-1;)t.advance(),i++;if(44==t.next)return;for(let e=0;;e++){if(7==e){if(!dO(t.next,!0))return;break}if(t.next!="extends".charCodeAt(e))break;t.advance(),i++}}t.acceptToken(4,-i)}),pO=id({"get set async static":_d.modifier,"for while do if else switch try catch finally return throw break continue default case":_d.controlKeyword,"in of await yield void typeof delete instanceof as satisfies":_d.operatorKeyword,"let var const using function class extends":_d.definitionKeyword,"import export from":_d.moduleKeyword,"with debugger new":_d.keyword,TemplateString:_d.special(_d.string),super:_d.atom,BooleanLiteral:_d.bool,this:_d.self,null:_d.null,Star:_d.modifier,VariableName:_d.variableName,"CallExpression/VariableName TaggedTemplateExpression/VariableName":_d.function(_d.variableName),VariableDefinition:_d.definition(_d.variableName),Label:_d.labelName,PropertyName:_d.propertyName,PrivatePropertyName:_d.special(_d.propertyName),"CallExpression/MemberExpression/PropertyName":_d.function(_d.propertyName),"FunctionDeclaration/VariableDefinition":_d.function(_d.definition(_d.variableName)),"ClassDeclaration/VariableDefinition":_d.definition(_d.className),"NewExpression/VariableName":_d.className,PropertyDefinition:_d.definition(_d.propertyName),PrivatePropertyDefinition:_d.definition(_d.special(_d.propertyName)),UpdateOp:_d.updateOperator,"LineComment Hashbang":_d.lineComment,BlockComment:_d.blockComment,Number:_d.number,String:_d.string,Escape:_d.escape,ArithOp:_d.arithmeticOperator,LogicOp:_d.logicOperator,BitOp:_d.bitwiseOperator,CompareOp:_d.compareOperator,RegExp:_d.regexp,Equals:_d.definitionOperator,Arrow:_d.function(_d.punctuation),": Spread":_d.punctuation,"( )":_d.paren,"[ ]":_d.squareBracket,"{ }":_d.brace,"InterpolationStart InterpolationEnd":_d.special(_d.brace),".":_d.derefOperator,", ;":_d.separator,"@":_d.meta,TypeName:_d.typeName,TypeDefinition:_d.definition(_d.typeName),"type enum interface implements namespace module declare":_d.definitionKeyword,"abstract global Privacy readonly override":_d.modifier,"is keyof unique infer asserts":_d.operatorKeyword,JSXAttributeValue:_d.attributeValue,JSXText:_d.content,"JSXStartTag JSXStartCloseTag JSXSelfCloseEndTag JSXEndTag":_d.angleBracket,"JSXIdentifier JSXNameSpacedName":_d.tagName,"JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName":_d.attributeName,"JSXBuiltin/JSXIdentifier":_d.standard(_d.tagName)}),mO={__proto__:null,export:20,as:25,from:33,default:36,async:41,function:42,in:52,out:55,const:56,extends:60,this:64,true:72,false:72,null:84,void:88,typeof:92,super:108,new:142,delete:154,yield:163,await:167,class:172,public:235,private:235,protected:235,readonly:237,instanceof:256,satisfies:259,import:292,keyof:349,unique:353,infer:359,asserts:395,is:397,abstract:417,implements:419,type:421,let:424,var:426,using:429,interface:435,enum:439,namespace:445,module:447,declare:451,global:455,for:474,of:483,while:486,with:490,do:494,if:498,else:500,switch:504,case:510,try:516,catch:520,finally:524,return:528,throw:532,break:536,continue:540,debugger:544},gO={__proto__:null,async:129,get:131,set:133,declare:195,public:197,private:197,protected:197,static:199,abstract:201,override:203,readonly:209,accessor:211,new:401},vO={__proto__:null,"<":193},yO=nO.deserialize({version:14,states:"$EOQ%TQlOOO%[QlOOO'_QpOOP(lO`OOO*zQ!0MxO'#CiO+RO#tO'#CjO+aO&jO'#CjO+oO#@ItO'#DaO.QQlO'#DgO.bQlO'#DrO%[QlO'#DzO0fQlO'#ESOOQ!0Lf'#E['#E[O1PQ`O'#EXOOQO'#Ep'#EpOOQO'#Ik'#IkO1XQ`O'#GsO1dQ`O'#EoO1iQ`O'#EoO3hQ!0MxO'#JqO6[Q!0MxO'#JrO6uQ`O'#F]O6zQ,UO'#FtOOQ!0Lf'#Ff'#FfO7VO7dO'#FfO7eQMhO'#F|O9[Q`O'#F{OOQ!0Lf'#Jr'#JrOOQ!0Lb'#Jq'#JqO9aQ`O'#GwOOQ['#K^'#K^O9lQ`O'#IXO9qQ!0LrO'#IYOOQ['#J_'#J_OOQ['#I^'#I^Q`QlOOQ`QlOOO9yQ!L^O'#DvO:QQlO'#EOO:XQlO'#EQO9gQ`O'#GsO:`QMhO'#CoO:nQ`O'#EnO:yQ`O'#EyO;OQMhO'#FeO;mQ`O'#GsOOQO'#K_'#K_O;rQ`O'#K_O<QQ`O'#G{O<QQ`O'#G|O<QQ`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q5sS'T!e-WU*g$|*X*lS-T'U']S0O*h*nQ0W*oQ2m-^Q4m0UR4r0XR(y#xQ!fQT-_'^-`]!qQ!r'^-`1g5qQ#p]R'g;wR)d$dY!uQ'^-`1g5qQ'i!rS's!v!yS'u!z5sS-o'j'kQ-q'lR2{-pT#kZ%dS#jZ%dS%jm,jU(e#h#i#lS.T(f(gQ.X(hQ0n+ZQ3Q.UU3R.V.W.YS6x3S3TR9T6yd#^W#W#Z%g(R([*W+W.O/hr#gZm#h#i#l%d(f(g(h+Z.U.V.W.Y3S3T6yS*Z$x*_Q/o*[Q1|,jQ2d-QQ4W/kQ6g2[Q7i4XQ8{6hT=_'V+XV#aW%g*WU#`W%g*WS(S#W([U(X#Z+W/hS-V'V+XT-y(R.OV'[!e%h*XQ$lfR)v$qT)k$l)lR3}/PT*]$x*_T*e${*WQ0q+cQ1_,QQ3V.aQ5j1aQ5u1iQ6}3ZQ8g5xQ9W6|Q:Q8fQ:d9VQ:|:SQ;U:fQ;`:}R;c;VnqOXst!Z#d%l&p&r&s&u,n,s2S2VQ&j!VR,c&gtmOXst!U!V!Z#d%l&g&p&r&s&u,n,s2S2VR,j&mT%km,jR1c,SR,b&eQ&T|R+z&UR+p&OT&n!W&qT&o!W&qT2U,s2V",nodeNames:"⚠ ArithOp ArithOp ?. JSXStartTag LineComment BlockComment Script Hashbang ExportDeclaration export Star as VariableName String Escape from ; default FunctionDeclaration async function VariableDefinition > < TypeParamList in out const TypeDefinition extends ThisType this LiteralType ArithOp Number BooleanLiteral TemplateType InterpolationEnd Interpolation InterpolationStart NullType null VoidType void TypeofType typeof MemberExpression . PropertyName [ TemplateString Escape Interpolation super RegExp ] ArrayExpression Spread , } { ObjectExpression Property async get set PropertyDefinition Block : NewTarget new NewExpression ) ( ArgList UnaryExpression delete LogicOp BitOp YieldExpression yield AwaitExpression await ParenthesizedExpression ClassExpression class ClassBody MethodDeclaration Decorator @ MemberExpression PrivatePropertyName CallExpression TypeArgList CompareOp < declare Privacy static abstract override PrivatePropertyDefinition PropertyDeclaration readonly accessor Optional TypeAnnotation Equals StaticBlock FunctionExpression ArrowFunction ParamList ParamList ArrayPattern ObjectPattern PatternProperty Privacy readonly Arrow MemberExpression BinaryExpression ArithOp ArithOp ArithOp ArithOp BitOp CompareOp instanceof satisfies CompareOp BitOp BitOp BitOp LogicOp LogicOp ConditionalExpression LogicOp LogicOp AssignmentExpression UpdateOp PostfixExpression CallExpression InstantiationExpression TaggedTemplateExpression DynamicImport import ImportMeta JSXElement JSXSelfCloseEndTag JSXSelfClosingTag JSXIdentifier JSXBuiltin JSXIdentifier JSXNamespacedName JSXMemberExpression JSXSpreadAttribute JSXAttribute JSXAttributeValue JSXEscape JSXEndTag JSXOpenTag JSXFragmentTag JSXText JSXEscape JSXStartCloseTag JSXCloseTag PrefixCast < ArrowFunction TypeParamList SequenceExpression InstantiationExpression KeyofType keyof UniqueType unique ImportType InferredType infer TypeName ParenthesizedType FunctionSignature ParamList NewSignature IndexedType TupleType Label ArrayType ReadonlyType ObjectType MethodType PropertyType IndexSignature PropertyDefinition CallSignature TypePredicate asserts is NewSignature new UnionType LogicOp IntersectionType LogicOp ConditionalType ParameterizedType ClassDeclaration abstract implements type VariableDeclaration let var using TypeAliasDeclaration InterfaceDeclaration interface EnumDeclaration enum EnumBody NamespaceDeclaration namespace module AmbientDeclaration declare GlobalDeclaration global ClassDeclaration ClassBody AmbientFunctionDeclaration ExportGroup VariableName VariableName ImportDeclaration ImportGroup ForStatement for ForSpec ForInSpec ForOfSpec of WhileStatement while WithStatement with DoStatement do IfStatement if else SwitchStatement switch SwitchBody CaseLabel case DefaultLabel TryStatement try CatchClause catch FinallyClause finally ReturnStatement return ThrowStatement throw BreakStatement break ContinueStatement continue DebuggerStatement debugger LabeledStatement ExpressionStatement SingleExpression SingleClassItem",maxTerm:379,context:aO,nodeProps:[["isolate",-8,5,6,14,37,39,51,53,55,""],["group",-26,9,17,19,68,207,211,215,216,218,221,224,234,236,242,244,246,248,251,257,263,265,267,269,271,273,274,"Statement",-34,13,14,32,35,36,42,51,54,55,57,62,70,72,76,80,82,84,85,110,111,120,121,136,139,141,142,143,144,145,147,148,167,169,171,"Expression",-23,31,33,37,41,43,45,173,175,177,178,180,181,182,184,185,186,188,189,190,201,203,205,206,"Type",-3,88,103,109,"ClassItem"],["openedBy",23,"<",38,"InterpolationStart",56,"[",60,"{",73,"(",160,"JSXStartCloseTag"],["closedBy",-2,24,168,">",40,"InterpolationEnd",50,"]",61,"}",74,")",165,"JSXEndTag"]],propSources:[pO],skippedNodes:[0,5,6,277],repeatNodeCount:37,tokenData:"$Fq07[R!bOX%ZXY+gYZ-yZ[+g[]%Z]^.c^p%Zpq+gqr/mrs3cst:_tuEruvJSvwLkwx! Yxy!'iyz!(sz{!)}{|!,q|}!.O}!O!,q!O!P!/Y!P!Q!9j!Q!R#:O!R![#<_![!]#I_!]!^#Jk!^!_#Ku!_!`$![!`!a$$v!a!b$*T!b!c$,r!c!}Er!}#O$-|#O#P$/W#P#Q$4o#Q#R$5y#R#SEr#S#T$7W#T#o$8b#o#p$<r#p#q$=h#q#r$>x#r#s$@U#s$f%Z$f$g+g$g#BYEr#BY#BZ$A`#BZ$ISEr$IS$I_$A`$I_$I|Er$I|$I}$Dk$I}$JO$Dk$JO$JTEr$JT$JU$A`$JU$KVEr$KV$KW$A`$KW&FUEr&FU&FV$A`&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$A`?HUOEr(n%d_$i&j(Vp(Y!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z&j&hT$i&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c&j&zP;=`<%l&c'|'U]$i&j(Y!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!b(SU(Y!bOY'}Zw'}x#O'}#P;'S'};'S;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S~RRtu[#O#Pg#S#T#|~_P#o#pb~gOx~~jVO#i!P#i#j!U#j#l!P#l#m!q#m;'S!P;'S;=`#v<%lO!P~!UO!U~~!XS!Q![!e!c!i!e#T#Z!e#o#p#Z~!hR!Q![!q!c!i!q#T#Z!q~!tR!Q![!}!c!i!}#T#Z!}~#QR!Q![!P!c!i!P#T#Z!P~#^R!Q![#g!c!i#g#T#Z#g~#jS!Q![#g!c!i#g#T#Z#g#q#r!P~#yP;=`<%l!P~$RO(b~~",141,339),new Zy("j~RQYZXz{^~^O(P~~aP!P!Qd~iO(Q~~",25,322)],topRules:{Script:[0,7],SingleExpression:[1,275],SingleClassItem:[2,276]},dialects:{jsx:0,ts:15098},dynamicPrecedences:{80:1,82:1,94:1,169:1,199:1},specialized:[{term:326,get:t=>mO[t]||-1},{term:342,get:t=>gO[t]||-1},{term:95,get:t=>vO[t]||-1}],tokenPrec:15124}),OO=[jv("function ${name}(${params}) {\n\t${}\n}",{label:"function",detail:"definition",type:"keyword"}),jv("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n\t${}\n}",{label:"for",detail:"loop",type:"keyword"}),jv("for (let ${name} of ${collection}) {\n\t${}\n}",{label:"for",detail:"of loop",type:"keyword"}),jv("do {\n\t${}\n} while (${})",{label:"do",detail:"loop",type:"keyword"}),jv("while (${}) {\n\t${}\n}",{label:"while",detail:"loop",type:"keyword"}),jv("try {\n\t${}\n} catch (${error}) {\n\t${}\n}",{label:"try",detail:"/ catch block",type:"keyword"}),jv("if (${}) {\n\t${}\n}",{label:"if",detail:"block",type:"keyword"}),jv("if (${}) {\n\t${}\n} else {\n\t${}\n}",{label:"if",detail:"/ else block",type:"keyword"}),jv("class ${name} {\n\tconstructor(${params}) {\n\t\t${}\n\t}\n}",{label:"class",detail:"definition",type:"keyword"}),jv('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),jv('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],bO=OO.concat([jv("interface ${name} {\n\t${}\n}",{label:"interface",detail:"definition",type:"keyword"}),jv("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),jv("enum ${name} {\n\t${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),xO=new Vu,wO=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function _O(t){return(e,i)=>{let n=e.node.getChild("VariableDefinition");return n&&i(n,t),!0}}const SO=["FunctionDeclaration"],kO={FunctionDeclaration:_O("function"),ClassDeclaration:_O("class"),ClassExpression:()=>!0,EnumDeclaration:_O("constant"),TypeAliasDeclaration:_O("type"),NamespaceDeclaration:_O("namespace"),VariableDefinition(t,e){t.matchContext(SO)||e(t,"variable")},TypeDefinition(t,e){e(t,"type")},__proto__:null};function $O(t,e){let i=xO.get(e);if(i)return i;let n=[],s=!0;function o(e,i){let s=t.sliceString(e.from,e.to);n.push({label:s,type:i})}return e.cursor(Pu.IncludeAnonymous).iterate(e=>{if(s)s=!1;else if(e.name){let t=kO[e.name];if(t&&t(e,o)||wO.has(e.name))return!1}else if(e.to-e.from>8192){for(let i of $O(t,e.node))n.push(i);return!1}}),xO.set(e,n),n}const CO=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,TO=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName","JSXText","JSXAttributeValue","JSXOpenTag","JSXCloseTag","JSXSelfClosingTag",".","?."];function PO(t){let e=Ad(t.state).resolveInner(t.pos,-1);if(TO.indexOf(e.name)>-1)return null;let i="VariableName"==e.name||e.to-e.from<20&&CO.test(t.state.sliceDoc(e.from,e.to));if(!i&&!t.explicit)return null;let n=[];for(let i=e;i;i=i.parent)wO.has(i.name)&&(n=n.concat($O(t.state.doc,i)));return{options:n,from:i?e.from:t.pos,validFor:CO}}const EO=Ed.define({name:"javascript",parser:yO.configure({props:[Vd.add({IfStatement:nf({except:/^\s*({|else\b)/}),TryStatement:nf({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:t=>t.baseIndent,SwitchBody:t=>{let e=t.textAfter,i=/^\s*\}/.test(e),n=/^\s*(case|default)\b/.test(e);return t.baseIndent+(i?0:n?1:2)*t.unit},Block:tf({closing:"}"}),ArrowFunction:t=>t.baseIndent+t.unit,"TemplateString BlockComment":()=>null,"Statement Property":nf({except:/^\s*{/}),JSXElement(t){let e=/^\s*<\//.test(t.textAfter);return t.lineIndent(t.node.from)+(e?0:t.unit)},JSXEscape(t){let e=/\s*\}/.test(t.textAfter);return t.lineIndent(t.node.from)+(e?0:t.unit)},"JSXOpenTag JSXSelfClosingTag":t=>t.column(t.node.from)+t.unit}),of.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":function(t){let e=t.firstChild,i=t.lastChild;return e&&e.to<i.from?{from:e.to,to:i.type.isError?t.to:i.from}:null},BlockComment:t=>({from:t.from+2,to:t.to-2})})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),AO={test:t=>/^JSX/.test(t.name),facet:$d({commentTokens:{block:{open:"{/*",close:"*/}"}}})},MO=EO.configure({dialect:"ts"},"typescript"),QO=EO.configure({dialect:"jsx",props:[Cd.add(t=>t.isTop?[AO]:void 0)]}),DO=EO.configure({dialect:"jsx ts",props:[Cd.add(t=>t.isTop?[AO]:void 0)]},"typescript");let RO=t=>({label:t,type:"keyword"});const IO="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(RO),LO=IO.concat(["declare","implements","private","protected","public"].map(RO));function NO(t={}){let e=t.jsx?t.typescript?DO:QO:t.typescript?MO:EO,i=t.typescript?bO.concat(LO):OO.concat(IO);return new Bd(e,[EO.data.of({autocomplete:(n=TO,s=jg(i),t=>{for(let e=Ad(t.state).resolveInner(t.pos,-1);e;e=e.parent){if(n.indexOf(e.name)>-1)return null;if(e.type.isTop)break}return s(t)})}),EO.data.of({autocomplete:PO}),t.jsx?BO:[]]);var n,s}function jO(t,e,i=t.length){for(let n=null==e?void 0:e.firstChild;n;n=n.nextSibling)if("JSXIdentifier"==n.name||"JSXBuiltin"==n.name||"JSXNamespacedName"==n.name||"JSXMemberExpression"==n.name)return t.sliceString(n.from,Math.min(n.to,i));return""}const zO="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),BO=Tc.inputHandler.of((t,e,i,n,s)=>{if((zO?t.composing:t.compositionStarted)||t.state.readOnly||e!=i||">"!=n&&"/"!=n||!EO.isActiveAt(t.state,e,-1))return!1;let o=s(),{state:r}=o,a=r.changeByRange(t=>{var e;let i,{head:s}=t,o=Ad(r).resolveInner(s-1,-1);if("JSXStartTag"==o.name&&(o=o.parent),r.doc.sliceString(s-1,s)!=n||"JSXAttributeValue"==o.name&&o.to>s);else{if(">"==n&&"JSXFragmentTag"==o.name)return{range:t,changes:{from:s,insert:"</>"}};if("/"==n&&"JSXStartCloseTag"==o.name){let t=o.parent,n=t.parent;if(n&&t.from==s-2&&((i=jO(r.doc,n.firstChild,s))||"JSXFragmentTag"==(null===(e=n.firstChild)||void 0===e?void 0:e.name))){let t=`${i}>`;return{range:rs.cursor(s+t.length,-1),changes:{from:s,insert:t}}}}else if(">"==n){let e=function(t){for(;;){if("JSXOpenTag"==t.name||"JSXSelfClosingTag"==t.name||"JSXFragmentTag"==t.name)return t;if("JSXEscape"==t.name||!t.parent)return null;t=t.parent}}(o);if(e&&"JSXOpenTag"==e.name&&!/^\/?>|^<\//.test(r.doc.sliceString(s,s+2))&&(i=jO(r.doc,e,s)))return{range:t,changes:{from:s,insert:`</${i}>`}}}}return{range:t}});return!a.changes.empty&&(t.dispatch([o,r.update(a,{userEvent:"input.complete",scrollIntoView:!0})]),!0)});function qO(t,e){const i=Tc.theme({"&":{height:.6*e+"px"}}),n=new Tc({doc:t.value,extensions:[Qy,NO(),Qf(If),i]});return t.parentNode.insertBefore(n.dom,t),t.style.display="none",n}function ZO(t){return!t||window.confirm("There is a change that has not been saved. If you proceed now, you will lose it.")}class FO{#hi;constructor(t){this.#hi=t}get template(){return ot`
290
290
  <div class="textae-editor__load-dialog__row">
291
291
  <label>
292
292
  URL
293
293
  </label>
294
294
  <input
295
295
  type="text"
296
- value="${this.#ui}"
296
+ value="${this.#hi}"
297
297
  class="textae-editor__load-dialog__url-text">
298
298
  <input
299
299
  type="button"
300
300
  class="textae-editor__load-dialog__url-button"
301
- ${this.#ui?"":'disabled="disabled"'}
301
+ ${this.#hi?"":'disabled="disabled"'}
302
302
  value="Open">
303
303
  </div>
304
- `}bind(t,e){r()(t,".textae-editor__load-dialog__url-text","input",t=>{wn(t.target.nextElementSibling,t.target.value)}),r()(t,".textae-editor__load-dialog__url-button","click",t=>e(t.target.previousElementSibling.value))}}var XO=i(2628),HO=i.n(XO);function WO(t,e){t.element.classList.remove("textae-editor__load-dialog__overlay-dropzone--maximized"),t.element.style.zIndex=e}class VO{#di;get template(){return'\n<div class="textae-editor__load-dialog__row">\n <label>\n Local\n </label>\n <form class="dropzone textae-editor__load-dialog__dropzone">\n <div class="dz-message">\n Drop a file here or click to select\n </div>\n </form>\n <div class="textae-editor__load-dialog__dz-file-preview">\n <div class="dz-filename"><span data-dz-name>No file selected</span></div>\n </div>\n <input\n type="button"\n class="textae-editor__load-dialog__local-button"\n disabled="disabled"\n value="Open">\n</div>\n'}bind(t,e){r()(t,".textae-editor__load-dialog__local-button","click",()=>e(this.#di))}intiializeDropzone(t){const e={url:"nothing",previewsContainer:".textae-editor__load-dialog__dz-file-preview",previewTemplate:t.querySelector(".textae-editor__load-dialog__dz-file-preview").innerHTML},i=new(HO())("body > div.ui-widget-overlay.ui-front",{...e,clickable:!1}),n=i.element.style.zIndex;i.on("dragenter",()=>function(t){const{element:e}=t;e.classList.add("textae-editor__load-dialog__overlay-dropzone--maximized"),e.style.zIndex=parseInt(e.style.zIndex)+1}(i)).on("dragleave",()=>WO(i,n)).on("addedfile",e=>{WO(i,n),this.#fi(t,e)});new(HO())(".textae-editor__load-dialog__dropzone",e).on("addedfile",e=>{this.#fi(t,e)})}#fi(t,e){t.querySelector(".textae-editor__load-dialog__dz-file-preview").firstElementChild.remove(),t.querySelector(".textae-editor__load-dialog__dz-file-preview > div").setAttribute("title",e.name),this.#di=e,wn(t.querySelector(".textae-editor__load-dialog__local-button"),!0)}}class YO extends u{#pi;constructor(t,e,i,n,s,o){const a=new FO(e),l=new VO;super(t,function(t){const{url:e,local:i}=t;return`\n<div class="textae-editor__load-dialog__container">\n ${e}\n ${i}\n <div class="textae-editor__load-dialog__row">\n <div class="textae-editor__load-dialog__format">\n <label class="textae-editor__load-dialog__format-button">\n <input type="radio" name="format" value="json" checked>JSON\n </label>\n <label class="textae-editor__load-dialog__format-button">\n <input type="radio" name="format" value="inline">Text\n </label>\n </div>\n <textarea class="textae-editor__load-dialog__textarea"></textarea>\n <input type="button" value="Edit" class="edit" disabled="disabled">\n <input type="button" value="Open" class="instant" disabled="disabled">\n </div>\n</div>`}({url:a.template,local:l.template})),this.#pi=l,a.bind(super.el,t=>{ZO(o)&&i(t),super.close()}),this.#pi.bind(super.el,t=>{ZO(o)&&n(t),super.close()}),r()(super.el,".textae-editor__load-dialog__textarea","input",t=>{wn(super.el.querySelector('[type="button"].instant'),t.target.value),wn(super.el.querySelector('[type="button"].edit'),t.target.value)});let c=null;r()(super.el,'[type="button"].instant',"click",()=>{const t=c?c.state.doc.toString():super.el.querySelector(".textae-editor__load-dialog__textarea").value,e=this.#mi();ZO(o)&&s(t,e),super.close()}),r()(super.el,'[type="button"].edit',"click",()=>{this.#gi();const t=super.el.querySelector(".textae-editor__load-dialog__textarea"),e=this.#mi();"json"===e&&_n(t.value)&&(t.value=JSON.stringify(JSON.parse(t.value),null,2));const i=super.el.closest(".textae-editor__dialog").clientHeight;c="json"===e?qO(t,i):function(t,e){const i=Tc.theme({"&":{height:.6*e+"px"}}),n=new Tc({doc:t.value,extensions:[Qy,Qf(If),i]});return t.parentNode.insertBefore(n.dom,t),t.style.display="none",n}(t,i);const n=super.el.querySelectorAll('.textae-editor__load-dialog__format-button input[type="radio"]');for(const t of n)t.disabled=!0;super.el.querySelector('[type="button"].edit').disabled=!0})}open(){super.open(),this.#pi.intiializeDropzone(super.el)}#gi(){super.el.closest(".textae-editor__dialog").classList.add("textae-editor__load-dialog--expanded")}#mi(){return super.el.querySelector('input[name="format"]:checked').value}}class UO extends u{#pi;constructor(t,e,i,n,s,o){const a=new FO(e),l=new VO;super(t,function(t){const{url:e,local:i}=t;return`\n<div class="textae-editor__load-dialog__container">\n ${e}\n ${i}\n <div class="textae-editor__load-dialog__row json">\n <label>\n JSON\n </label>\n <textarea class="textae-editor__load-dialog__textarea"></textarea>\n <input type="button" value="Edit" class="edit" disabled="disabled">\n <input type="button" value="Open" class="instant" disabled="disabled">\n </div>\n</div>`}({url:a.template,local:l.template})),this.#pi=l,a.bind(super.el,t=>{ZO(o)&&i(t),super.close()}),this.#pi.bind(super.el,t=>{ZO(o)&&n(t),super.close()}),r()(super.el,".textae-editor__load-dialog__textarea","input",t=>{wn(super.el.querySelector('[type="button"].instant'),t.target.value),wn(super.el.querySelector('[type="button"].edit'),t.target.value)});let c=null;r()(super.el,'[type="button"].instant',"click",()=>{const t=c?c.state.doc.toString():super.el.querySelector(".textae-editor__load-dialog__textarea").value;ZO(o)&&s(t),super.close()}),r()(super.el,'[type="button"].edit',"click",()=>{this.#gi();const t=super.el.querySelector(".textae-editor__load-dialog__textarea");_n(t.value)&&(t.value=JSON.stringify(JSON.parse(t.value),null,2));const e=super.el.closest(".textae-editor__dialog").clientHeight;c=qO(t,e),super.el.querySelector('[type="button"].edit').disabled=!0})}open(){super.open(),this.#pi.intiializeDropzone(super.el)}#gi(){super.el.closest(".textae-editor__dialog").classList.add("textae-editor__load-dialog--expanded")}}function GO(t){const e=new Blob([JSON.stringify(t)],{type:"application/json"});return URL.createObjectURL(e)}const KO=class{#vi;#yi;#Y;#H;constructor(t,e,i,n=null){this.#vi=t,this.#yi=e,this.#Y=i,this.#H=n}get beginPos(){return this.#vi}get endPos(){return this.#yi}get obj(){return this.#Y}get id(){return this.#H}get span(){return{begin:this.#vi,end:this.#yi}}toObject(){const t={span:this.span,obj:this.#Y};return this.#H&&(t.id=this.#H),t}isNestedWithin(t){return t.beginPos<=this.#vi&&this.#yi<=t.endPos}get isPositionNotInteger(){return!(Number.isInteger(this.#vi)&&Number.isInteger(this.endPos))}get isPositionNegative(){return this.#vi<0||this.#yi<0}get isPositionInvalid(){return this.#vi>this.#yi}isOutOfBounds(t){return this.#vi>=t||this.#yi>t}isBoundaryCrossing(t){const e=this.#vi>t.beginPos&&this.#vi<t.endPos,i=this.#yi>t.beginPos&&this.#yi<t.endPos;return e||i}};const JO=class{validateDenotations(t,e){let i=this.#Oi(t);return i=this.#bi(i),i=this.#xi(i),i=this.#wi(i),i=this.#_i(i,e),i=this.#Si(i),this.#ki(i)}#Oi(t){const e=new Set;return t.filter(t=>{const i=JSON.stringify(t.span);return!e.has(i)&&(e.add(i),!0)})}#bi(t){return t.filter(t=>!t.isPositionNotInteger)}#xi(t){return t.filter(t=>!t.isPositionNegative)}#wi(t){return t.filter(t=>!t.isPositionInvalid)}#_i(t,e){return t.filter(t=>!t.isOutOfBounds(e))}#Si(t){const e=t.sort((t,e)=>t.beginPos===e.beginPos?e.endPos-t.endPos:t.beginPos-e.beginPos),i=[];return e.forEach(t=>{i.some(e=>t.isNestedWithin(e))||i.push(t)}),i}#ki(t){return t.filter(e=>!t.some(t=>e!==t&&e.isBoundaryCrossing(t)))}};class tb extends Error{constructor(t){super(t),this.name=this.constructor.name}}const eb=tb;const ib=class{validateRelations(t){return this.#$i(t)}#$i(t){return t.filter(t=>t.subj&&t.pred&&t.obj)}};const nb=class{constructor(t){this.source=Object.freeze({...t}),this.denotations=this.#Ci(t.denotations||[]),this.config=this.source.config}generate(){const t=this.source.text;if(!t)throw new eb('The "text" key is missing.');const e=(new JO).validateDenotations(this.denotations,t.length),i=(new ib).validateRelations(this.source.relations||[]);return[this.#Ti(t,e,i),this.#Pi()].filter(Boolean).join("\n\n")}#Ci(t){return t.map(t=>new KO(t.span.begin,t.span.end,t.obj,t.id||null))}#Ti(t,e,i){return e.sort((t,e)=>e.beginPos-t.beginPos).forEach(e=>{const n=e.beginPos,s=e.endPos,o=e.id?this.#Ei(e,i):this.#Ai(e.obj),r=`[${t.slice(n,s)}][${o}]`;t=t.slice(0,n)+r+t.slice(s)}),t}#Pi(){const t=this.#Mi();return t&&0!==t.length?t.map(t=>`[${t.label}]: ${t.id}`).join("\n"):null}#Mi(){return this.config&&this.config["entity types"]?.filter(t=>t.hasOwnProperty("label"))||null}#Ei(t,e){const i=e.find(e=>e.subj===t.id)||null,n=[t.id,t.obj,i?.pred,i?.obj];if(!this.#Mi())return n.filter(t=>null!=t).join(", ");n[1]=this.#Ai(t.obj);this.#Mi().find(e=>e.id===t.obj);return n.filter(t=>null!=t).join(", ")}#Ai(t){if(!this.#Mi())return t;const e=this.#Mi().find(e=>e.id===t);return e?e.label:t}},sb=/^\s*\[([^\]]+)\]:\s+(\S+)(?:\s+(?:"[^"]*"|'[^']*'))?\s*$/,ob=new RegExp(`(?:\\A|\\n\\s*\\n)((?:${sb.source}(?:\\n|$))+)`,"gm");const rb=class{#Qi;#Di=null;constructor(t){this.#Qi=t}get(t){return this.#Ri[t]}get config(){return Object.entries(this.#Ri).map(([t,e])=>({id:e,label:t}))}get#Ri(){return this.#Di||(this.#Di=this.#Ii()),this.#Di}#Ii(){const t={},e=Array.from(this.#Qi.matchAll(ob));for(const i of e)this.#Li(i,t);return t}#Li(t,e){const i=t[0].split("\n");for(const t of i)this.#Ni(t,e)}#Ni(t,e){const i=t.trim().match(sb);if(!i)return;const[n,s,o]=i;s!==o&&(e[s]||(e[s]=o))}},ab=new RegExp(`(?:\\A|\\n\\s*\\n)((?:${/^\s*\[([^\]]+)\]:\s+(\S+)(?:\s+(?:"[^"]*"|'[^']*'))?\s*$/.source}(?:\\n|$))+)`,"gm"),lb=/(?<!\\)\[([^\[]+?)\]\[([^\]]+?)\]/;const cb=class{#Qi;#D;#ji;#zi;constructor(t){this.#Qi=t,this.#ji=new rb(t)}parse(){this.#D=[],this.#zi=[];let t=this.#Bi();return t=this.#qi(t),new ub(t,this.#D,this.#zi,this.#ji)}#Bi(){return this.#Qi.replace(ab,t=>t.startsWith("\n\n")?"\n\n":"").trim()}#Zi(t){return this.#ji.get(t)||t}#qi(t){const e=new RegExp(lb,"g");let i;for(;null!==(i=e.exec(t));){const n=i[1],s=i.index,o=s+n.length,r=i[2].split(", ");switch(r.length){case 1:this.#Fi(s,o,r[0]);break;case 2:this.#Xi(s,o,r);break;case 4:this.#Hi(s,o,r);break;default:e.lastIndex=i.index+i[0].length;continue}t=t.slice(0,i.index)+n+t.slice(i.index+i[0].length),e.lastIndex=o}return t}#Fi(t,e,i){const n=this.#Zi(i);this.#D.push(new KO(t,e,n))}#Xi(t,e,i){const[n,s]=i,o=this.#Zi(s);this.#D.push(new KO(t,e,o,n))}#Hi(t,e,i){const[n,s,o,r]=i,a=this.#Zi(s);this.#D.push(new KO(t,e,a,n)),this.#zi.push({pred:o,subj:n,obj:r})}},hb=/\\(?=\[[^\]]+\]\[[^\]]+\])/;const ub=class{#re;#D;#zi;#ji;constructor(t,e,i,n){this.#re=t,this.#D=e,this.#zi=i,this.#ji=n}static parse(t){return new cb(t).parse().toObject()}static generate(t){return new nb(t).generate()}toObject(){const t={text:this.#Wi(this.#re),denotations:this.#D.map(t=>t.toObject())};this.#zi&&this.#zi.length>0&&(t.relations=this.#zi);const e=this.#Vi();return e&&Object.keys(e).length>0&&!Object.values(e).every(t=>null==t||Array.isArray(t)&&0===t.length)&&(t.config=e),t}#Wi(t){let e=this.#Yi(t);return this.#Ui(e)}#Yi(t){return t.replace(hb,"")}#Ui(t){return t.replace(/\n{2,}/g,"\n\n")}#Vi(){return this.#ji&&0!==this.#ji.length?{"entity types":this.#ji.config}:null}};function db(t,e){if("json"===e)return GO(t);if("inline"===e){const e=ub.generate(t),i=new Blob([e],{type:"text/plain;charset=utf-8"});return URL.createObjectURL(i)}}function fb(t,e,i,n){t.preventDefault();!function(t,e){const i=document.createElement("a");i.setAttribute("href",t),i.setAttribute("download",e),document.body.appendChild(i),i.click(),document.body.removeChild(i)}(db(e,i),t.target.previousElementSibling.value),n.emit("textae-event.resource.annotation.save",e)}function pb(t,i,n,s,o,a){r()(i,".textae-editor__save-dialog__url-text","input",t=>{wn(t.target.nextElementSibling,t.target.value)}),r()(i,".textae-editor__save-dialog__url-text","keyup",t=>{if(13===t.keyCode){const e=a();o(t.target.value,e),s()}}),r()(i,".textae-editor__save-dialog__url-button","click",t=>{const e=a();o(t.target.previousElementSibling.value,e),s()}),r()(i,".textae-editor__save-dialog__download-link","click",i=>{const o=a();try{fb(i,n,o,t)}catch(t){e().error(`Failed to download the source as ${o} format.`)}finally{s()}}),r()(i,".textae-editor__save-dialog__viewsource-link","click",()=>{const i=a();try{!function(t,e,i){const n=db(t,e);window.open(n,"_blank"),i.emit("textae-event.resource.annotation.save",t)}(n,i,t)}catch(t){e().error(`Failed to view the source as ${i} format.`)}finally{s()}})}class mb extends u{constructor(t,e,i,n,s){super("Save Annotations",function(t){const{url:e,filename:i}=t;return`\n<div class="textae-editor__save-dialog__container">\n <div class="textae-editor__save-dialog__row">\n <span>Format</span>\n <div class="textae-editor__save-dialog__format">\n <label class="textae-editor__save-dialog__format-button">\n <input type="radio" name="format" value="json" checked>JSON\n </label>\n <label class="textae-editor__save-dialog__format-button">\n <input type="radio" name="format" value="inline">Text\n </label>\n </div>\n </div>\n <div class="textae-editor__save-dialog__row">\n <label>URL</label>\n <input\n type="text"\n value="${e}"\n class="textae-editor__save-dialog__url-text">\n <input\n type="button"\n class="textae-editor__save-dialog__url-button"\n ${e?"":'disabled="disabled"'}\n value="Save">\n </div>\n <div class="textae-editor__save-dialog__row">\n <label>Local</label>\n <input\n type="text"\n value="${i||""}"\n >\n <a class="textae-editor__save-dialog__download-link" href="#">Download</a>\n </div>\n <div class="textae-editor__save-dialog__row">\n <a class="textae-editor__save-dialog__viewsource-link" href="#">Click to see the source in a new window.</a>\n </div>\n</div>\n`}({filename:i,url:e})),pb(t,super.el,n,()=>super.close(),s,()=>super.el.querySelector('input[name="format"]:checked').value)}}function gb(t,e){if(t.length<2)throw new Error(e||"Expected an array with at least 2 items")}const vb=class{format(t,e){const i={};this.prepareContext(i);const n=i;return this.recurse(n,t,e),this.finalize(n)}prepareContext(t){t.buffer=[],t.out=function(...t){if(!this.buffer)throw new Error("context buffer is not initialized");this.buffer.push(...t)}}typeFormattterNotFound(t,e){throw new Error(`cannot format delta type: ${e}`)}typeFormattterErrorFormatter(t,e,i,n,s,o,r){}finalize({buffer:t}){return Array.isArray(t)?t.join(""):""}recurse(t,e,i,n,s,o,r){const a=e&&o?o.value:i;if(void 0===e&&void 0===n)return;const l=this.getDeltaType(e,o),c="node"===l?"a"===e._t?"array":"object":"";let h;void 0!==n?this.nodeBegin(t,n,s,l,c,null!=r&&r):this.rootBegin(t,l,c);try{h="unknown"!==l?this[`format_${l}`]:this.typeFormattterNotFound(t,l),h.call(this,t,e,a,n,s,o)}catch(i){this.typeFormattterErrorFormatter(t,i,e,a,n,s,o),"undefined"!=typeof console&&console.error&&console.error(i.stack)}void 0!==n?this.nodeEnd(t,n,s,l,c,null!=r&&r):this.rootEnd(t,l,c)}formatDeltaChildren(t,e,i){this.forEachDeltaKey(e,i,(n,s,o,r)=>{this.recurse(t,e[n],i?i[s]:void 0,n,s,o,r)})}forEachDeltaKey(t,e,i){const n=[];if(!("a"===t._t)){const s=Object.keys(t);"object"==typeof e&&null!==e&&n.push(...Object.keys(e));for(const t of s)n.indexOf(t)>=0||n.push(t);for(let t=0;t<n.length;t++){const e=n[t];if(void 0===e)continue;const s=t===n.length-1;i(e,e,void 0,s)}return}const s={};for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e)){const i=t[e];if(Array.isArray(i)&&3===i[2]){s[i[1]]=Number.parseInt(e.substring(1))}}const o=t;let r=0,a=0;const l=Array.isArray(e)?e:void 0,c=l?l.length:Object.keys(o).reduce((t,e)=>{if("_t"===e)return t;if("_"===e.substring(0,1)){const i=o[e],n=Number.parseInt(e.substring(1)),s=Array.isArray(i)&&i.length>=3&&3===i[2]?i[1]:void 0,r=Math.max(n,null!=s?s:0);return r>t?r:t}const i=Number.parseInt(e),n=s[i],r=Math.max(null!=n?n:0,null!=i?i:0);return r>t?r:t},0)+1;let h,u=c;const d=(...t)=>{h&&i(...h),h=t};for(;r<c||a<u||`${a}`in o;){let t=!1;const e=`_${r}`,i=`${a}`,n=a in s?s[a]:void 0;if(e in o){t=!0;const i=o[e];d(e,null!=n?n:r,n?{key:`_${n}`,value:l?l[n]:void 0}:void 0,!1),Array.isArray(i)?0===i[2]?(u--,r++):(i[2],r++):r++}if(i in o){t=!0;const e=o[i],s=Array.isArray(e)&&1===e.length;d(i,null!=n?n:r,n?{key:`_${n}`,value:l?l[n]:void 0}:void 0,!1),s?(u++,a++):void 0===n?(r++,a++):a++}t||((l&&void 0===n||!1!==this.includeMoveDestinations)&&d(i,null!=n?n:r,n?{key:`_${n}`,value:l?l[n]:void 0}:void 0,!1),void 0!==n||r++,a++)}h&&i(h[0],h[1],h[2],!0)}getDeltaType(t,e){if(void 0===t)return void 0!==e?"movedestination":"unchanged";if(Array.isArray(t)){if(1===t.length)return"added";if(2===t.length)return"modified";if(3===t.length&&0===t[2])return"deleted";if(3===t.length&&2===t[2])return"textdiff";if(3===t.length&&3===t[2])return"moved"}else if("object"==typeof t)return"node";return"unknown"}parseTextDiff(t){var e;const i=[],n=t.split("\n@@ ");for(const t of n){const n={pieces:[]},s=null===(e=/^(?:@@ )?[-+]?(\d+),(\d+)/.exec(t))||void 0===e?void 0:e.slice(1);if(!s)throw new Error("invalid text diff format");gb(s),n.location={line:s[0],chr:s[1]};const o=t.split("\n").slice(1);for(let t=0,e=o.length;t<e;t++){const e=o[t];if(void 0===e||!e.length)continue;const i={type:"context"};"+"===e.substring(0,1)?i.type="added":"-"===e.substring(0,1)&&(i.type="deleted"),i.text=e.slice(1),n.pieces.push(i)}i.push(n)}return i}};class yb extends vb{typeFormattterErrorFormatter(t,e){const i="object"==typeof e&&null!==e&&"message"in e&&"string"==typeof e.message?e.message:String(e);t.out(`<pre class="jsondiffpatch-error">${Ob(i)}</pre>`)}formatValue(t,e){const i=void 0===e?"undefined":Ob(JSON.stringify(e,null,2));t.out(`<pre>${i}</pre>`)}formatTextDiffString(t,e){const i=this.parseTextDiff(e);t.out('<ul class="jsondiffpatch-textdiff">');for(let e=0,n=i.length;e<n;e++){const n=i[e];if(void 0===n)return;t.out(`<li><div class="jsondiffpatch-textdiff-location"><span class="jsondiffpatch-textdiff-line-number">${n.location.line}</span><span class="jsondiffpatch-textdiff-char">${n.location.chr}</span></div><div class="jsondiffpatch-textdiff-line">`);const s=n.pieces;for(let e=0,i=s.length;e<i;e++){const i=s[e];if(void 0===i)return;t.out(`<span class="jsondiffpatch-textdiff-${i.type}">${Ob(decodeURI(i.text))}</span>`)}t.out("</div></li>")}t.out("</ul>")}rootBegin(t,e,i){const n=`jsondiffpatch-${e}${i?` jsondiffpatch-child-node-type-${i}`:""}`;t.out(`<div class="jsondiffpatch-delta ${n}">`)}rootEnd(t){t.out("</div>"+(t.hasArrows?`<script type="text/javascript">setTimeout(${bb.toString()},10);<\/script>`:""))}nodeBegin(t,e,i,n,s){const o=`jsondiffpatch-${n}${s?` jsondiffpatch-child-node-type-${s}`:""}`,r="number"==typeof i&&"_"===e.substring(0,1)?e.substring(1):e;t.out(`<li class="${o}" data-key="${Ob(e)}"><div class="jsondiffpatch-property-name">${Ob(r)}</div>`)}nodeEnd(t){t.out("</li>")}format_unchanged(t,e,i){void 0!==i&&(t.out('<div class="jsondiffpatch-value">'),this.formatValue(t,i),t.out("</div>"))}format_movedestination(t,e,i){void 0!==i&&(t.out('<div class="jsondiffpatch-value">'),this.formatValue(t,i),t.out("</div>"))}format_node(t,e,i){const n="a"===e._t?"array":"object";t.out(`<ul class="jsondiffpatch-node jsondiffpatch-node-type-${n}">`),this.formatDeltaChildren(t,e,i),t.out("</ul>")}format_added(t,e){t.out('<div class="jsondiffpatch-value">'),this.formatValue(t,e[0]),t.out("</div>")}format_modified(t,e){t.out('<div class="jsondiffpatch-value jsondiffpatch-left-value">'),this.formatValue(t,e[0]),t.out('</div><div class="jsondiffpatch-value jsondiffpatch-right-value">'),this.formatValue(t,e[1]),t.out("</div>")}format_deleted(t,e){t.out('<div class="jsondiffpatch-value">'),this.formatValue(t,e[0]),t.out("</div>")}format_moved(t,e){t.out('<div class="jsondiffpatch-value">'),this.formatValue(t,e[0]),t.out(`</div><div class="jsondiffpatch-moved-destination">${e[1]}</div>`),t.out('<div class="jsondiffpatch-arrow" style="position: relative; left: -34px;">\n <svg width="30" height="60" style="position: absolute; display: none;">\n <defs>\n <marker id="markerArrow" markerWidth="8" markerHeight="8"\n refx="2" refy="4" stroke="#88f"\n orient="auto" markerUnits="userSpaceOnUse">\n <path d="M1,1 L1,7 L7,4 L1,1" style="fill: #339;" />\n </marker>\n </defs>\n <path d="M30,0 Q-10,25 26,50"\n style="stroke: #88f; stroke-width: 2px; fill: none; stroke-opacity: 0.5; marker-end: url(#markerArrow);"\n ></path>\n </svg>\n </div>'),t.hasArrows=!0}format_textdiff(t,e){t.out('<div class="jsondiffpatch-value">'),this.formatTextDiffString(t,e[0]),t.out("</div>")}}function Ob(t){if("number"==typeof t)return t;let e=String(t);const i=[[/&/g,"&amp;"],[/</g,"&lt;"],[/>/g,"&gt;"],[/'/g,"&apos;"],[/"/g,"&quot;"]];for(const t of i)e=e.replace(t[0],t[1]);return e}const bb=function(t){const e=t||document;((t,e,i)=>{const n=t.querySelectorAll(e);for(let t=0,e=n.length;t<e;t++)i(n[t])})(e,".jsondiffpatch-arrow",({parentNode:t,children:e,style:i})=>{const n=t,s=e[0],o=s.children[1];s.style.display="none";const r=n.querySelector(".jsondiffpatch-moved-destination");if(!(r instanceof HTMLElement))return;const a=(({textContent:t,innerText:e})=>t||e)(r),l=n.parentNode;if(!l)return;let c;if((({children:t},e)=>{for(let i=0,n=t.length;i<n;i++){const n=t[i];n&&e(n,i)}})(l,t=>{t.getAttribute("data-key")===a&&(c=t)}),c)try{const t=c.offsetTop-n.offsetTop;s.setAttribute("height",`${Math.abs(t)+6}`),i.top=`${-8+(t>0?0:t)}px`;const e=t>0?`M30,0 Q-10,${Math.round(t/2)} 26,${t-4}`:`M30,${-t} Q-10,${Math.round(-t/2)} 26,4`;o.setAttribute("d",e),s.style.display=""}catch(t){console.debug(`[jsondiffpatch] error adjusting arrows: ${t}`)}})},xb=(t,e)=>((t,e,i)=>{const n=e||document.body,s="jsondiffpatch-unchanged-",o={showing:`${s}showing`,hiding:`${s}hiding`,visible:`${s}visible`,hidden:`${s}hidden`},r=n.classList;if(!r)return;if(!i)return r.remove(o.showing),r.remove(o.hiding),r.remove(o.visible),r.remove(o.hidden),void(!1===t&&r.add(o.hidden));!1===t?(r.remove(o.showing),r.add(o.visible),setTimeout(()=>{r.add(o.hiding)},10)):(r.remove(o.hiding),r.add(o.showing),r.remove(o.hidden));const a=setInterval(()=>{bb(n)},100);setTimeout(()=>{r.remove(o.showing),r.remove(o.hiding),!1===t?(r.add(o.hidden),r.remove(o.visible)):(r.add(o.visible),r.remove(o.hidden)),setTimeout(()=>{r.remove(o.visible),clearInterval(a)},i+400)},i)})(!1,t,e);let wb;function _b(t){if("object"!=typeof t)return t;if(null===t)return null;if(Array.isArray(t))return t.map(_b);if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp)return function(t){var e;const i=/^\/(.*)\/([gimyu]*)$/.exec(t.toString());if(!i)throw new Error("Invalid RegExp");return new RegExp(null!==(e=i[1])&&void 0!==e?e:"",i[2])}(t);const e={};for(const i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=_b(t[i]));return e}class Sb{setResult(t){return this.result=t,this.hasResult=!0,this}exit(){return this.exiting=!0,this}push(t,e){var i;return t.parent=this,void 0!==e&&(t.childName=e),t.root=this.root||this,t.options=t.options||this.options,this.children?(!function(t,e){if(0===t.length)throw new Error(e||"Expected a non-empty array")}(this.children),(i=this.children,i[i.length-1]).next=t,this.children.push(t)):(this.children=[t],this.nextAfterChildren=this.next||null,this.next=t),t.next=this,this}}const kb=class extends Sb{constructor(t,e){super(),this.left=t,this.right=e,this.pipe="diff"}prepareDeltaResult(t){var e,i,n,s;if("object"==typeof t&&((null===(e=this.options)||void 0===e?void 0:e.omitRemovedValues)&&Array.isArray(t)&&t.length>1&&(2===t.length||0===t[2]||3===t[2])&&(t[0]=0),null===(i=this.options)||void 0===i?void 0:i.cloneDiffValues)){const e="function"==typeof(null===(n=this.options)||void 0===n?void 0:n.cloneDiffValues)?null===(s=this.options)||void 0===s?void 0:s.cloneDiffValues:_b;"object"==typeof t[0]&&(t[0]=e(t[0])),"object"==typeof t[1]&&(t[1]=e(t[1]))}return t}setResult(t){return this.prepareDeltaResult(t),super.setResult(t)}};const $b=class extends Sb{constructor(t,e){super(),this.left=t,this.delta=e,this.pipe="patch"}};const Cb=class extends Sb{constructor(t){super(),this.delta=t,this.pipe="reverse"}};const Tb=class{constructor(t){this.name=t,this.filters=[]}process(t){if(!this.processor)throw new Error("add this pipe to a processor before using it");const e=this.debug,i=this.filters.length,n=t;for(let t=0;t<i;t++){const i=this.filters[t];if(i&&(e&&this.log(`filter: ${i.filterName}`),i(n),"object"==typeof n&&n.exiting)){n.exiting=!1;break}}!n.next&&this.resultCheck&&this.resultCheck(n)}log(t){console.log(`[jsondiffpatch] ${this.name} pipe, ${t}`)}append(...t){return this.filters.push(...t),this}prepend(...t){return this.filters.unshift(...t),this}indexOf(t){if(!t)throw new Error("a filter name is required");for(let e=0;e<this.filters.length;e++){const i=this.filters[e];if((null==i?void 0:i.filterName)===t)return e}throw new Error(`filter not found: ${t}`)}list(){return this.filters.map(t=>t.filterName)}after(t,...e){const i=this.indexOf(t);return this.filters.splice(i+1,0,...e),this}before(t,...e){const i=this.indexOf(t);return this.filters.splice(i,0,...e),this}replace(t,...e){const i=this.indexOf(t);return this.filters.splice(i,1,...e),this}remove(t){const e=this.indexOf(t);return this.filters.splice(e,1),this}clear(){return this.filters.length=0,this}shouldHaveResult(t){return!1===t?(this.resultCheck=null,this):(this.resultCheck||(this.resultCheck=t=>{if(!t.hasResult){console.log(t);const e=new Error(`${this.name} failed`);throw e.noResult=!0,e}}),this)}};const Pb=class{constructor(t){this.selfOptions=t||{},this.pipes={}}options(t){return t&&(this.selfOptions=t),this.selfOptions}pipe(t,e){let i=e;if("string"==typeof t){if(void 0===i)return this.pipes[t];this.pipes[t]=i}if(t&&t.name){if(i=t,i.processor===this)return i;this.pipes[i.name]=i}if(!i)throw new Error(`pipe is not defined: ${t}`);return i.processor=this,i}process(t,e){let i=t;i.options=this.options();let n,s=e||t.pipe||"default";for(;s;)void 0!==i.nextAfterChildren&&(i.next=i.nextAfterChildren,i.nextAfterChildren=null),"string"==typeof s&&(s=this.pipe(s)),s.process(i),n=s,s=null,i&&i.next&&(i=i.next,s=i.pipe||n);return i.hasResult?i.result:void 0}},Eb=(t,e,i,n)=>t[i]===e[n],Ab=(t,e,i,n)=>{const s=n||{},o=((t,e,i,n)=>{var s,o,r;const a=t.length,l=e.length;let c,h;const u=new Array(a+1);for(c=0;c<a+1;c++){const t=new Array(l+1);for(h=0;h<l+1;h++)t[h]=0;u[c]=t}for(u.match=i,c=1;c<a+1;c++){const a=u[c];if(void 0===a)throw new Error("LCS matrix row is undefined");const d=u[c-1];if(void 0===d)throw new Error("LCS matrix row is undefined");for(h=1;h<l+1;h++)i(t,e,c-1,h-1,n)?a[h]=(null!==(s=d[h-1])&&void 0!==s?s:0)+1:a[h]=Math.max(null!==(o=d[h])&&void 0!==o?o:0,null!==(r=a[h-1])&&void 0!==r?r:0)}return u})(t,e,i||Eb,s);return((t,e,i,n)=>{let s=e.length,o=i.length;const r={sequence:[],indices1:[],indices2:[]};for(;0!==s&&0!==o;){if(void 0===t.match)throw new Error("LCS matrix match function is undefined");if(t.match(e,i,s-1,o-1,n))r.sequence.unshift(e[s-1]),r.indices1.unshift(s-1),r.indices2.unshift(o-1),--s,--o;else{const e=t[s];if(void 0===e)throw new Error("LCS matrix row is undefined");const i=e[o-1];if(void 0===i)throw new Error("LCS matrix value is undefined");const n=t[s-1];if(void 0===n)throw new Error("LCS matrix row is undefined");const r=n[o];if(void 0===r)throw new Error("LCS matrix value is undefined");i>r?--o:--s}}return r})(o,t,e,s)};function Mb(t,e,i,n,s){const o=t[i],r=e[n];if(o===r)return!0;if("object"!=typeof o||"object"!=typeof r)return!1;const a=s.objectHash;if(!a)return s.matchByPosition&&i===n;s.hashCache1=s.hashCache1||[];let l=s.hashCache1[i];if(void 0===l&&(s.hashCache1[i]=l=a(o,i)),void 0===l)return!1;s.hashCache2=s.hashCache2||[];let c=s.hashCache2[n];return void 0===c&&(s.hashCache2[n]=c=a(r,n)),void 0!==c&&l===c}const Qb=function(t){var e,i,n,s,o;if(!t.leftIsArray)return;const r={objectHash:null===(e=t.options)||void 0===e?void 0:e.objectHash,matchByPosition:null===(i=t.options)||void 0===i?void 0:i.matchByPosition};let a,l,c,h=0,u=0;const d=t.left,f=t.right,p=d.length,m=f.length;let g,v;for(p>0&&m>0&&!r.objectHash&&"boolean"!=typeof r.matchByPosition&&(r.matchByPosition=!function(t,e,i,n){for(let s=0;s<i;s++){const i=t[s];for(let t=0;t<n;t++){const n=e[t];if(s!==t&&i===n)return!0}}return!1}(d,f,p,m));h<p&&h<m&&Mb(d,f,h,h,r);)a=h,g=new kb(d[a],f[a]),t.push(g,a),h++;for(;u+h<p&&u+h<m&&Mb(d,f,p-1-u,m-1-u,r);)l=p-1-u,c=m-1-u,g=new kb(d[l],f[c]),t.push(g,c),u++;if(h+u===p){if(p===m)return void t.setResult(void 0).exit();for(v=v||{_t:"a"},a=h;a<m-u;a++)v[a]=[f[a]],t.prepareDeltaResult(v[a]);return void t.setResult(v).exit()}if(h+u===m){for(v=v||{_t:"a"},a=h;a<p-u;a++){const e=`_${a}`;v[e]=[d[a],0,0],t.prepareDeltaResult(v[e])}return void t.setResult(v).exit()}r.hashCache1=void 0,r.hashCache2=void 0;const y=d.slice(h,p-u),O=f.slice(h,m-u),b=Ab(y,O,Mb,r),x=[];for(v=v||{_t:"a"},a=h;a<p-u;a++)if(b.indices1.indexOf(a-h)<0){const e=`_${a}`;v[e]=[d[a],0,0],t.prepareDeltaResult(v[e]),x.push(a)}let w=!0;(null===(n=t.options)||void 0===n?void 0:n.arrays)&&!1===t.options.arrays.detectMove&&(w=!1);let _=!1;(null===(o=null===(s=t.options)||void 0===s?void 0:s.arrays)||void 0===o?void 0:o.includeValueOnMove)&&(_=!0);const S=x.length;for(a=h;a<m-u;a++){const e=b.indices2.indexOf(a-h);if(e<0){let e=!1;if(w&&S>0)for(let i=0;i<S;i++){l=x[i];const n=void 0===l?void 0:v[`_${l}`];if(void 0!==l&&n&&Mb(y,O,l-h,a-h,r)){n.splice(1,2,a,3),n.splice(1,2,a,3),_||(n[0]=""),c=a,g=new kb(d[l],f[c]),t.push(g,c),x.splice(i,1),e=!0;break}}e||(v[a]=[f[a]],t.prepareDeltaResult(v[a]))}else{if(void 0===b.indices1[e])throw new Error(`Invalid indexOnArray2: ${e}, seq.indices1: ${b.indices1}`);if(l=b.indices1[e]+h,void 0===b.indices2[e])throw new Error(`Invalid indexOnArray2: ${e}, seq.indices2: ${b.indices2}`);c=b.indices2[e]+h,g=new kb(d[l],f[c]),t.push(g,c)}}t.setResult(v).exit()};Qb.filterName="arrays";const Db={numerically:(t,e)=>t-e,numericallyBy:t=>(e,i)=>e[t]-i[t]},Rb=function(t){var e;if(!t.nested)return;const i=t.delta;if("a"!==i._t)return;let n,s;const o=i,r=t.left;let a=[],l=[];const c=[];for(n in o)if("_t"!==n)if("_"===n[0]){const t=n;if(void 0===o[t]||0!==o[t][2]&&3!==o[t][2])throw new Error(`only removal or move can be applied at original array indices, invalid diff type: ${null===(e=o[t])||void 0===e?void 0:e[2]}`);a.push(Number.parseInt(n.slice(1),10))}else{const t=n;1===o[t].length?l.push({index:Number.parseInt(t,10),value:o[t][0]}):c.push({index:Number.parseInt(t,10),delta:o[t]})}for(a=a.sort(Db.numerically),n=a.length-1;n>=0;n--){if(s=a[n],void 0===s)continue;const t=o[`_${s}`],e=r.splice(s,1)[0];3===(null==t?void 0:t[2])&&l.push({index:t[1],value:e})}l=l.sort(Db.numericallyBy("index"));const h=l.length;for(n=0;n<h;n++){const t=l[n];void 0!==t&&r.splice(t.index,0,t.value)}const u=c.length;if(u>0)for(n=0;n<u;n++){const e=c[n];if(void 0===e)continue;const i=new $b(r[e.index],e.delta);t.push(i,e.index)}t.children?t.exit():t.setResult(r).exit()};Rb.filterName="arrays";const Ib=function(t){if(!t||!t.children)return;if("a"!==t.delta._t)return;const e=t.left,i=t.children.length;for(let n=0;n<i;n++){const i=t.children[n];if(void 0===i)continue;e[i.childName]=i.result}t.setResult(e).exit()};Ib.filterName="arraysCollectChildren";const Lb=function(t){if(!t.nested){const e=t.delta;if(3===e[2]){const i=e;t.newName=`_${i[1]}`,t.setResult([i[0],Number.parseInt(t.childName.substring(1),10),3]).exit()}return}const e=t.delta;if("a"!==e._t)return;const i=e;for(const e in i){if("_t"===e)continue;const n=new Cb(i[e]);t.push(n,e)}t.exit()};Lb.filterName="arrays";const Nb=(t,e,i)=>{if("string"==typeof e&&"_"===e[0])return Number.parseInt(e.substring(1),10);if(Array.isArray(i)&&0===i[2])return`_${e}`;let n=+e;for(const i in t){const s=t[i];if(Array.isArray(s))if(3===s[2]){const t=Number.parseInt(i.substring(1),10),o=s[1];if(o===+e)return t;t<=n&&o>n?n++:t>=n&&o<n&&n--}else if(0===s[2]){Number.parseInt(i.substring(1),10)<=n&&n++}else 1===s.length&&Number.parseInt(i,10)<=n&&n--}return n},jb=t=>{if(!t||!t.children)return;const e=t.delta;if("a"!==e._t)return;const i=e,n=t.children.length,s={_t:"a"};for(let e=0;e<n;e++){const n=t.children[e];if(void 0===n)continue;let o=n.newName;if(void 0===o){if(void 0===n.childName)throw new Error("child.childName is undefined");o=Nb(i,n.childName,n.result)}s[o]!==n.result&&(s[o]=n.result)}t.setResult(s).exit()};jb.filterName="arraysCollectChildren";const zb=function(t){t.left instanceof Date?(t.right instanceof Date?t.left.getTime()!==t.right.getTime()?t.setResult([t.left,t.right]):t.setResult(void 0):t.setResult([t.left,t.right]),t.exit()):t.right instanceof Date&&t.setResult([t.left,t.right]).exit()};zb.filterName="dates";const Bb=t=>{if(!t||!t.children)return;const e=t.children.length;let i=t.result;for(let n=0;n<e;n++){const e=t.children[n];if(void 0!==e&&void 0!==e.result){if(i=i||{},void 0===e.childName)throw new Error("diff child.childName is undefined");i[e.childName]=e.result}}i&&t.leftIsArray&&(i._t="a"),t.setResult(i).exit()};Bb.filterName="collectChildren";const qb=t=>{var e;if(t.leftIsArray||"object"!==t.leftType)return;const i=t.left,n=t.right,s=null===(e=t.options)||void 0===e?void 0:e.propertyFilter;for(const e in i){if(!Object.prototype.hasOwnProperty.call(i,e))continue;if(s&&!s(e,t))continue;const o=new kb(i[e],n[e]);t.push(o,e)}for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e)&&(!s||s(e,t))&&void 0===i[e]){const i=new kb(void 0,n[e]);t.push(i,e)}t.children&&0!==t.children.length?t.exit():t.setResult(void 0).exit()};qb.filterName="objects";const Zb=function(t){if(!t.nested)return;const e=t.delta;if(e._t)return;const i=e;for(const e in i){const n=new $b(t.left[e],i[e]);t.push(n,e)}t.exit()};Zb.filterName="objects";const Fb=function(t){if(!t||!t.children)return;if(t.delta._t)return;const e=t.left,i=t.children.length;for(let n=0;n<i;n++){const i=t.children[n];if(void 0===i)continue;const s=i.childName;Object.prototype.hasOwnProperty.call(t.left,s)&&void 0===i.result?delete e[s]:e[s]!==i.result&&(e[s]=i.result)}t.setResult(e).exit()};Fb.filterName="collectChildren";const Xb=function(t){if(!t.nested)return;if(t.delta._t)return;const e=t.delta;for(const i in e){const n=new Cb(e[i]);t.push(n,i)}t.exit()};Xb.filterName="objects";const Hb=t=>{if(!t||!t.children)return;if(t.delta._t)return;const e=t.children.length,i={};for(let n=0;n<e;n++){const e=t.children[n];if(void 0===e)continue;const s=e.childName;i[s]!==e.result&&(i[s]=e.result)}t.setResult(i).exit()};Hb.filterName="collectChildren";let Wb=null;function Vb(t,e){var i;if(!Wb){let n;if(!(null===(i=null==t?void 0:t.textDiff)||void 0===i?void 0:i.diffMatchPatch)){if(!e)return null;const t=new Error("The diff-match-patch library was not provided. Pass the library in through the options or use the `jsondiffpatch/with-text-diffs` entry-point.");throw t.diff_match_patch_not_found=!0,t}n=new t.textDiff.diffMatchPatch,Wb={diff:(t,e)=>n.patch_toText(n.patch_make(t,e)),patch:(t,e)=>{const i=n.patch_apply(n.patch_fromText(e),t);for(const t of i[1])if(!t){const t=new Error("text patch failed");throw t.textPatchFailed=!0,t}return i[0]}}}return Wb}const Yb=function(t){var e,i;if("string"!==t.leftType)return;const n=t.left,s=t.right,o=(null===(i=null===(e=t.options)||void 0===e?void 0:e.textDiff)||void 0===i?void 0:i.minLength)||60;if(n.length<o||s.length<o)return void t.setResult([n,s]).exit();const r=Vb(t.options);if(!r)return void t.setResult([n,s]).exit();const a=r.diff;t.setResult([a(n,s),0,2]).exit()};Yb.filterName="texts";const Ub=function(t){if(t.nested)return;const e=t.delta;if(2!==e[2])return;const i=e,n=Vb(t.options,!0).patch;t.setResult(n(t.left,i[0])).exit()};Ub.filterName="texts";const Gb=t=>{var e,i,n;const s=/^@@ +-(\d+),(\d+) +\+(\d+),(\d+) +@@$/,o=t.split("\n");for(let t=0;t<o.length;t++){const r=o[t];if(void 0===r)continue;const a=r.slice(0,1);if("@"===a){const e=s.exec(r);if(null!==e){o[t]=`@@ -${e[3]},${e[4]} +${e[1]},${e[2]} @@`}}else if("+"===a){if(o[t]=`-${null===(e=o[t])||void 0===e?void 0:e.slice(1)}`,"+"===(null===(i=o[t-1])||void 0===i?void 0:i.slice(0,1))){const e=o[t];o[t]=o[t-1],o[t-1]=e}}else"-"===a&&(o[t]=`+${null===(n=o[t])||void 0===n?void 0:n.slice(1)}`)}return o.join("\n")},Kb=function(t){if(t.nested)return;const e=t.delta;if(2!==e[2])return;const i=e;t.setResult([Gb(i[0]),0,2]).exit()};Kb.filterName="texts";const Jb=function(t){if(t.left!==t.right)if(void 0!==t.left)if(void 0!==t.right){if("function"==typeof t.left||"function"==typeof t.right)throw new Error("functions are not supported");t.leftType=null===t.left?"null":typeof t.left,t.rightType=null===t.right?"null":typeof t.right,t.leftType===t.rightType&&"boolean"!==t.leftType&&"number"!==t.leftType?("object"===t.leftType&&(t.leftIsArray=Array.isArray(t.left)),"object"===t.rightType&&(t.rightIsArray=Array.isArray(t.right)),t.leftIsArray===t.rightIsArray?t.left instanceof RegExp&&(t.right instanceof RegExp?t.setResult([t.left.toString(),t.right.toString()]).exit():t.setResult([t.left,t.right]).exit()):t.setResult([t.left,t.right]).exit()):t.setResult([t.left,t.right]).exit()}else t.setResult([t.left,0,0]).exit();else{if("function"==typeof t.right)throw new Error("functions are not supported");t.setResult([t.right]).exit()}else t.setResult(void 0).exit()};Jb.filterName="trivial";const tx=function(t){if(void 0===t.delta)return void t.setResult(t.left).exit();if(t.nested=!Array.isArray(t.delta),t.nested)return;const e=t.delta;if(1!==e.length)if(2!==e.length)3===e.length&&0===e[2]&&t.setResult(void 0).exit();else{if(t.left instanceof RegExp){const i=/^\/(.*)\/([gimyu]+)$/.exec(e[1]);if(null==i?void 0:i[1])return void t.setResult(new RegExp(i[1],i[2])).exit()}t.setResult(e[1]).exit()}else t.setResult(e[0]).exit()};tx.filterName="trivial";const ex=function(t){if(void 0===t.delta)return void t.setResult(t.delta).exit();if(t.nested=!Array.isArray(t.delta),t.nested)return;const e=t.delta;1!==e.length?2!==e.length?3===e.length&&0===e[2]&&t.setResult([e[0]]).exit():t.setResult([e[1],e[0]]).exit():t.setResult([e[0],0,0]).exit()};ex.filterName="trivial";const ix=class{constructor(t){this.processor=new Pb(t),this.processor.pipe(new Tb("diff").append(Bb,Jb,zb,Yb,qb,Qb).shouldHaveResult()),this.processor.pipe(new Tb("patch").append(Fb,Ib,tx,Ub,Zb,Rb).shouldHaveResult()),this.processor.pipe(new Tb("reverse").append(Hb,jb,ex,Kb,Xb,Lb).shouldHaveResult())}options(t){return this.processor.options(t)}diff(t,e){return this.processor.process(new kb(t,e))}patch(t,e){return this.processor.process(new $b(t,e))}reverse(t){return this.processor.process(new Cb(t))}unpatch(t,e){return this.patch(t,this.reverse(e))}clone(t){return _b(t)}};let nx;function sx(t,e){return nx||(nx=new ix),nx.diff(t,e)}const ox=new ix({objectHash:(t,e)=>t.id||`$$index:${e}`});function rx(t,e){return function(t,e){return wb||(wb=new yb),wb.format(t,e)}(ox.diff(t,e),t)}class ax extends u{constructor(t,e,i,n,s,o){super("Save Configurations",function(t){const{url:e,filename:i,diff:n}=t;return`\n<div class="textae-editor__save-dialog__container">\n <div class="textae-editor__save-dialog__row">\n <label>URL</label>\n <input\n type="text" value="${e}"\n class="textae-editor__save-dialog__url-text">\n <input\n type="button"\n class="textae-editor__save-dialog__url-button"\n ${e?"":'disabled="disabled"'}\n value="Save">\n </div>\n <div class="textae-editor__save-dialog__row">\n <label>Local</label>\n <input\n type="text" value="${i||""}"\n >\n <a class="textae-editor__save-dialog__download-link" href="#">Download</a>\n </div>\n <div class="textae-editor__save-dialog__row">\n <div class="textae-editor__save-dialog__diff-title">\n Configuration differences\n <span class="textae-editor__save-dialog__diff-add-legend">added</span>\n <span class="textae-editor__save-dialog__diff-remove-legend">removed</span>\n </div>\n <div class="textae-editor__save-dialog__diff-viewer">${n}</div>\n </div>\n</div>\n`}({filename:i,url:e,diff:rx(n,s)||"nothing."}),{maxWidth:550}),this._$dialog.on("dialogopen",()=>xb()),function(t,e,i,n,s){r()(e,".textae-editor__save-dialog__url-text","input",t=>{wn(t.target.nextElementSibling,t.target.value)}),r()(e,".textae-editor__save-dialog__url-text","keyup",t=>{13===t.keyCode&&(s(t.target.value),n())}),r()(e,".textae-editor__save-dialog__url-button","click",t=>{s(t.target.previousElementSibling.value),n()}),r()(e,".textae-editor__save-dialog__download-link","click",e=>{const s=e.target,o=GO(i);s.setAttribute("href",o),s.setAttribute("download",s.previousElementSibling.value),t.emit("textae-event.resource.configuration.save",i),n()})}(t,super.el,s,()=>super.close(),o)}}async function lx(t){return new Promise(e=>{const i=new FileReader;i.onload=t=>e(t),i.readAsText(t)})}var cx=i(7975),hx=i.n(cx);const ux=Object.freeze({QUERY_PARAMETER:"parameter",INLINE:"inline",REMOTE_URL:"remote",INSTANT:"instant",LOCAL_FILE:"local file",UNKNOWN:"unknown"});class dx{#Gi;#H;#Ki;static createURLSource(t,e){return console.assert("string"==typeof t,"id must be a string when type is url."),new dx(ux.REMOTE_URL,t,e)}static createFileSource(t,e){return console.assert("string"==typeof t,"id must be a string when type is local file."),new dx(ux.LOCAL_FILE,t,e)}static createInstantSource(t){return new dx(ux.INSTANT,null,t)}static createInlineSource(t){return new dx(ux.INLINE,null,t)}static createParameterSource(t){return new dx(ux.QUERY_PARAMETER,null,t)}constructor(t,e,i){console.assert(Object.values(ux).includes(t),`type must be a member of RESOURCE_TYPE. type: ${t}`),t===ux.REMOTE_URL||t===ux.LOCAL_FILE?console.assert("string"==typeof e,"id must be a string when type is url or local file."):console.assert(null===e,"id must be null when type is not url."),this.#Gi=t,this.#H=e,this.#Ki=i}get resourceType(){return this.#Gi}get id(){return this.#H}get data(){return this.#Ki}get displayName(){switch(this.#Gi){case ux.REMOTE_URL:return new URL(this.#H,location.href).href;case ux.LOCAL_FILE:return`${this.#H}(local file)`;default:return`${this.#Gi}`}}}async function fx(t,i){const n=(await lx(t)).target.result;if(s=t.name,".txt"===hx().extname(s)){const s=function(t){try{return ub.parse(t)}catch{return null}}(n);if(!s){const i=dx.createFileSource(t.name);return void e().error(`Failed to load annotation from ${i.displayName}.`)}if(s.text)return void i.emit("textae-event.resource.annotation.load.success",dx.createFileSource(t.name,s))}var s;if(_n(n)){const e=JSON.parse(n);if(e.text)return void i.emit("textae-event.resource.annotation.load.success",dx.createFileSource(t.name,e))}i.emit("textae-event.resource.annotation.format.error",dx.createFileSource(t.name))}function px(t,e){return!!e.text&&(t.emit("textae-event.resource.annotation.load.success",dx.createInstantSource(e)),!0)}class mx{#Ji;#tn;constructor(t){t.on("textae-event.original-data.annotation.reset",t=>{t.resourceType===ux.REMOTE_URL&&(this.#Ji=t.id)}).on("textae-event.original-data.configuration.reset",t=>{t.resourceType===ux.REMOTE_URL&&(this.#tn=t.id)})}get annotation(){return this.#Ji||""}get configuration(){return this.#tn||""}}class gx{#Ji;#tn;constructor(t){t.on("textae-event.original-data.annotation.reset",t=>{t.resourceType===ux.LOCAL_FILE&&(this.#Ji=t.id)}).on("textae-event.original-data.configuration.reset",t=>{t.resourceType===ux.LOCAL_FILE&&(this.#tn=t.id)})}get annotation(){return this.#Ji}get configuration(){return this.#tn}}class vx{#Nt;#en;#Ht;#in;#nn;#sn;#on;#ii;#rn;#an;constructor(t,e,i,n,s,o,r,a){this.#Nt=t,this.#en=e,this.#Ht=i,this.#in=n,this.#nn=s,this.#sn=o,this.#on=r,this.#ii=a,this.#rn=new mx(t),this.#an=new gx(t),t.on("textae-event.pallet.import-button.click",()=>this.importConfiguration()).on("textae-event.pallet.upload-button.click",()=>this.uploadConfiguration())}importAnnotation(){new YO("Load Annotations",this.#rn.annotation,t=>this.#en.loadAnnotation(t),t=>fx(t,this.#Nt),(t,i)=>function(t,i,n){if("json"===n)_n(i)?px(t,JSON.parse(i)):t.emit("textae-event.resource.annotation.format.error",dx.createInstantSource());else if("inline"===n)try{px(t,ub.parse(i))}catch{const t=dx.createInstantSource();e().error(`Failed to load annotation from ${t.displayName}.`)}}(this.#Nt,t,i),this.#on.hasChange).open()}uploadAnnotation(){const t=this.#sn||this.#rn.annotation||"https://pubannotatoin.org/annotations.json";new mb(this.#Nt,t,this.#an.annotation,this.#ln,(t,e)=>this.#en.saveAnnotation(t,this.#ln,e)).open()}saveAnnotation(){this.#en.saveAnnotation(this.#sn||this.#rn.annotation,this.#ln,"json")}importConfiguration(){new UO("Load Configurations",this.#rn.configuration,t=>this.#en.loadConfiguration(t),t=>function(t,e){lx(t).then(({target:i})=>{_n(i.result)?e.emit("textae-event.resource.configuration.load.success",dx.createFileSource(t.name,JSON.parse(i.result))):e.emit("textae-event.resource.configuration.format.error",dx.createFileSource(t.name))})}(t,this.#Nt),t=>{_n(t)?this.#Nt.emit("textae-event.resource.configuration.load.success",dx.createInstantSource(JSON.parse(t))):this.#Nt.emit("textae-event.resource.configuration.format.error",dx.createInstantSource())},this.#ii.diffOfConfiguration).open()}uploadConfiguration(){const t={...this.#nn(),...this.#Ht.typeDictionary.config};new ax(this.#Nt,this.#rn.configuration,this.#an.configuration,this.#nn(),t,e=>this.#en.saveConfiguration(e,t)).open()}get#ln(){const t={...this.#in(),...this.#Ht.externalFormat,config:this.#Ht.typeDictionary.config};return delete t.tracks,t}}function yx(t,e,i,n,s,o){e.setPushButtons(t),i.set(t),n.reset(s,t),o.availability=t["function availability"]}function Ox(t){if(!0===t)return"flag";if("number"==typeof t)return"numeric";if("string"==typeof t)return"string";throw`${JSON.stringify(t)} is an unexpected value for an Attribute.`}function bx(t){const e=t.reduce((t,e)=>t.has(e)?t.set(e,t.get(e)+1):t.set(e,1),new Map),i=Math.max(...e.values());for(const[t,n]of e.entries())if(n===i)return t}function xx(t){const e=Math.max(...t.map(t=>{const[e,i]=String(t).split(".");return i?i.length:0}));return Number(Array.from(Array(e)).reduce((t,e)=>.1*t,1).toFixed(e))}class wx{constructor({pred:t,obj:e}){this._pred=t,this._objects=[e]}push(t){this._objects.push(t)}get definition(){switch(Ox(this._objects[0])){case"flag":return this._prototype;case"numeric":return this._numericAttribute;case"string":return this._stringAttribute;default:throw new Error(`prototype: ${JSON.stringify(this._prototype)}`)}}get mostFrequentObject(){return bx(this._objects)}get _prototype(){return{pred:this._pred,"value type":Ox(this._objects[0])}}get _numericAttribute(){return{min:Math.min(...this._objects),max:Math.max(...this._objects),step:xx(this._objects),default:bx(this._objects),...this._prototype}}get _stringAttribute(){return{default:bx(this._objects),...this._prototype}}}function _x(t){return t.reduce((t,e)=>(t.has(e.pred)?t.get(e.pred).push(e.obj):t.set(e.pred,new wx(e)),t),new Map)}function Sx(t,e){const i=function(t){return[..._x(t).values()].map(t=>t.definition)}(e);return function(t,e){for(const i of e){const e=t.findIndex(t=>t.pred===i.pred);-1!==e?t[e]={...i,...t[e]}:t.push(i)}return t}(t,i)}function kx(t){return t?JSON.parse(JSON.stringify(t)):{}}class $x{constructor(t=[],e=[]){this._annotations=e,this._config=t}get configuration(){let t=Sx(this._config,this._annotations);return t=function(t){t=kx(t);for(const e of t.filter(t=>"numeric"===t["value type"]))Object.prototype.hasOwnProperty.call(e,"default")||(e.default=0),Object.prototype.hasOwnProperty.call(e,"step")||(e.step=2);return t}(t),t=function(t,e){t=kx(t);const i=_x(e);for(const e of function(t){return t.filter(t=>"selection"===t["value type"])}(t))if(e.values&&0!==e.values.length)if(e.values.find(t=>!0===t.default));else if(i.has(e.pred)){const t=i.get(e.pred);e.values.find(e=>e.id===t.mostFrequentObject).default=!0}else e.values[0].default=!0;else e.values=[{id:"default",default:!0}];return t}(t,this._annotations),t}}function Cx(t,e){if(console.assert(t),(e=kx(e))["attribute types"]=new $x(e["attribute types"],t.attributes).configuration,t.tracks)for(const i of t.tracks)e["attribute types"]=new $x(e["attribute types"],i.attributes).configuration;return e}const Tx=new(on())({verbose:!0});an()(Tx,["uri-reference","regex"]);const Px=Tx.compile(ln);function Ex(t){return console.assert(t,"config is required."),Px(t)?null:(console.warn(Px.errors),function(t){for(const e of t){if("required"===e.keyword)return`Invalid configuration: The attribute type whose predicate is '${e.data.pred}' misses a mandatory property, '${e.params.missingProperty}'.`;if(e.instancePath.includes("color"))return ot`Invalid configuration: '${e.data}' is invalid color format.`}}(Px.errors))}function Ax(t,i){const n=function(t,e){if(console.assert(e,"If you don't have a configuration, generate a configuration from the annotation."),t.attributes){const i=e["attribute types"],n=t.attributes.filter(t=>i.some(e=>e.pred===t.pred&&"selection"===e["value type"])).filter(t=>!i.some(e=>e.pred===t.pred&&e.values.some(e=>e.id===t.obj)));if(n.length)return console.warn("selection attribute values without definition",n),`selection attribute value definition for "${n.map(t=>t.obj).join(", ")}" in configuration is missing. `}}(t,i);if(!n)return i;e().error(n)}function Mx(t,i){const n=Cx(t,i),s=Ex(n);if(!s)return Ax(t,n);e().error(s)}function Qx(t){(function(t){if(t.denotations)for(const e of t.denotations){if(e.span.begin!==parseInt(e.span.begin))return!0;if(e.span.end!==parseInt(e.span.end))return!0}})(t)&&e().warning("In the annotation file, some of the begin and end offsets of denotations were not integer values.\n TextAE converted them to integer values.\n However, to avoid a chance of unexpected rendering, please fix them.",15)}function Dx(t,i,n,s,o,r,a,l){if(!t.data.config&&i)n.loadConfiguration(i,t);else{if(Qx(t.data),t.data.config&&"object"!=typeof t.data.config)return void e().error("configuration in annotation file is invalid.");const i=Mx(t.data,t.data.config);i&&(yx(i,s,o,r,t.data,a),l.annotation=t)}}const Rx='\n<div class="textae-editor__footer">\n <div class="textae-editor__footer__message"></div>\n</div>\n';class Ix{#Q;#cn;constructor(t,e){this.#Q=t,this.#cn=e}set status(t){var e;this.#cn&&(""!==t&&((e=this.#Q,e.querySelector(".textae-editor__footer__message")||(e.insertAdjacentHTML("beforeend",Rx.replace(/[\n\r]+/g,"")),e.querySelector(".textae-editor__footer__message"))).innerHTML=at(t)?`Source: <a class="textae-editor__footer__message__link" href="${t}">${decodeURI(t)}</a>`:`Source: ${t}`))}}class Lx{#Nt;#hn;#Ji;#tn;constructor(t,e,i){this.#Nt=t,this.#hn=new Ix(e,i),t.on("textae-event.resource.annotation.save",t=>{this.#un=t}).on("textae-event.resource.configuration.save",t=>{this.#tn=t})}get defaultAnnotation(){return{text:"Currently, the document is empty. Use the `import` button or press the key `i` to open a document with annotation."}}get defaultConfiguration(){return Cx(this.defaultAnnotation)}get annotation(){return this.#Ji?this.#Ji:this.defaultAnnotation}set annotation(t){this.#un=t.data,this.#hn.status=t.displayName,this.#Nt.emit("textae-event.original-data.annotation.reset",t)}get configuration(){return this.#tn?this.#tn:{}}set configuration(t){this.#tn=t.data,this.#Nt.emit("textae-event.original-data.configuration.reset",t)}set#un(t){this.#Ji=t,t.config&&(this.#tn=t.config)}}const Nx=[{usage:{"keyboard device":["control bar","context menu"],"touch device":["control bar"]},list:[{type:"import",title:"Import [I]"},{type:"upload",title:"Upload [U]"},{type:"upload automatically",title:"Upload Automatically",push:!0}]},{usage:{"keyboard device":["control bar","context menu"],"touch device":["control bar"]},list:[{type:"view mode",title:"View Mode",push:!0},{type:"term edit mode",title:"Term Edit Mode",push:!0},{type:"block edit mode",title:"Block Edit Mode",push:!0},{type:"relation edit mode",title:"Relation Edit Mode",push:!0},{type:"text edit mode",title:"Text Edit Mode",push:!0}]},{usage:{"keyboard device":["control bar","context menu"],"touch device":["control bar"]},list:[{type:"simple view",title:"Simple View",push:!0},{type:"adjust lineheight",title:"Adjust LineHeight"},{type:"auto adjust lineheight",title:"Auto Adjust LineHeight",push:!0}]},{usage:{"keyboard device":["control bar","context menu"],"touch device":["control bar"]},list:[{type:"undo",title:"Undo [Z]"},{type:"redo",title:"Redo [A]"}]},{usage:{"keyboard device":["control bar","context menu"],"touch device":["control bar"]},list:[{type:"replicate span annotation",title:"Replicate span annotation [R]",enableWhenSelecting:t=>t.span.single&&t.span.single.isDenotation},{type:"auto replicate",title:"Auto replicate",push:!0},{type:"boundary detection",title:"Boundary Detection [B]",push:!0}]},{usage:{"keyboard device":[],"touch device":["control bar","context menu"]},list:[{type:"create span by touch",title:"Create span",availableModes:[vn,yn]},{type:"expand span by touch",title:"Expand span",availableModes:[vn,yn]},{type:"shrink span by touch",title:"Shrink span",availableModes:[vn,yn]},{type:"edit text by touch",title:"Edit text",availableModes:[bn]}]},{usage:{"keyboard device":["control bar","context menu"],"touch device":["control bar"]},list:[{type:"new entity",title:"New entity [E]",enableWhenSelecting:t=>t.span.contains(t=>t.isDenotation)},{type:"pallet"},{type:"edit properties",title:"Edit Properties [W]",enableWhenSelecting:t=>t.entity.some||t.relation.some},{type:"delete",title:"Delete [D]",enableWhenSelecting:t=>t.span.some||t.entity.some||t.relation.some}]},{usage:{"keyboard device":[],"touch device":["control bar"]},list:[{type:"copy",title:"Copy [C]",enableWhenSelecting:t=>t.span.contains(t=>t.isDenotation)||t.entity.contains(t=>t.isDenotation)},{type:"cut",title:"Cut [X]",enableWhenSelecting:t=>t.span.contains(t=>t.isDenotation)||t.entity.contains(t=>t.isDenotation)},{type:"paste",title:"Paste [V]",enableWhenSelecting:(t,e)=>e.hasCopyingItem&&t.span.some||e.hasCuttingItem&&Boolean(t.span.single)}]},{usage:{"keyboard device":["control bar"],"touch device":["control bar"]},list:[{type:"setting",title:"Setting"}]},{usage:{"keyboard device":["control bar"],"touch device":[]},list:[{type:"help",title:"Help [H]"}]}];function jx(){return/Android/.test(navigator.userAgent)}class zx{#dn;#fn;constructor(t,e){this.#dn=t,this.#fn=e}isShowOnControlBar(){return jx()||/iPad/.test(navigator.userAgent)||/iPhone/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&q()?this.#dn["touch device"].includes("control bar"):this.#dn["keyboard device"].includes("control bar")}isShowOnContextMenu(){return q()?this.#dn["touch device"].includes("context menu"):this.#dn["keyboard device"].includes("context menu")}getButtonsFor(t){const e=this.#fn.filter(({availableModes:e})=>e.includes(t));return new zx(this.#dn,e)}get buttonList(){return this.#fn}get displayProperties(){return{list:this.#fn.map(t=>t.displayProperties)}}}class Bx{#Gi;#ot;#pn=!1;#mn=null;#gn=[gn,vn,yn,On,bn];constructor(t,e,i=!1,n=null,s=null){this.#Gi=t,this.#ot=e,this.#pn=i,n&&(this.#mn=n),s&&(this.#gn=s)}get displayProperties(){return{type:this.#Gi,title:this.#ot}}get type(){return this.#Gi}get push(){return this.#pn}get enableWhenSelecting(){return this.#mn}get availableModes(){return this.#gn}}class qx{#vn;constructor(){this.#vn=Nx.map(({usage:t,list:e})=>new zx(t,e.map(({type:t,title:e,push:i,enableWhenSelecting:n,availableModes:s})=>new Bx(t,e,i,n,s))))}get controlBar(){return this.#vn.filter(t=>t.isShowOnControlBar()).map(t=>t.displayProperties)}getContextMenuFor(t){return this.#vn.filter(t=>t.isShowOnContextMenu()).map(e=>e.getButtonsFor(t)).map(t=>t.displayProperties)}get pasteButton(){return this.#fn.find(({type:t})=>"paste"===t)}get enableButtonsWhenSelecting(){return this.#fn.filter(t=>t.enableWhenSelecting)}get pushButtons(){return this.#fn.filter(t=>t.push).map(t=>t.type)}get#fn(){return this.#vn.flatMap(t=>t.buttonList)}}class Zx{#l;#Nt;#yn;constructor(t,e=null){this.#l=t,this.#Nt=e,this.#yn=!1}get name(){return this.#l}get isPushed(){return this.#yn}set isPushed(t){this.#yn=t,this.#On()}toggle(){this.#yn=!this.#yn,this.#On()}#On(){this.#Nt&&this.#Nt.emit("textae-event.control.button.push",this)}}class Fx{#bn;constructor(t){this.#bn=(new qx).pushButtons.reduce((e,i)=>(e.set(i,new Zx(i,t)),e),new Map),t.on("textae-event.edit-mode.transition",(t,e)=>this.#xn(t,!e))}get(t){return this.#bn.has(t)?this.#bn.get(t):new Zx(t)}get names(){return this.#bn.keys()}#xn(t,e){switch(t){case gn:this.#wn(!0,!1,!1,!1,!1,e);break;case vn:this.#wn(!1,!0,!1,!1,!1,e);break;case yn:this.#wn(!1,!1,!0,!1,!1,e);break;case On:this.#wn(!1,!1,!1,!0,!1,!1);break;case bn:this.#wn(!1,!1,!1,!1,!0,e);break;default:throw`unknown edit mode!${t}`}}#wn(t,e,i,n,s,o){this.#bn.get("view mode").isPushed=t,this.#bn.get("term edit mode").isPushed=e,this.#bn.get("block edit mode").isPushed=i,this.#bn.get("relation edit mode").isPushed=n,this.#bn.get("text edit mode").isPushed=s,this.#bn.get("simple view").isPushed=o}}class Xx{#_n;#Nt;#Ie;#oi;constructor(t,e,i){this.#_n=new Map([["import",!0],["upload",!0],["view mode",!0],["term edit mode",!0],["block edit mode",!0],["relation edit mode",!0],["text edit mode",!0],["simple view",!0],["setting",!0],["help",!0]]),this.#Nt=t,this.#Ie=e,this.#oi=i,t.on("textae-event.history.change",t=>{this.enable("undo",t.hasAnythingToUndo),this.enable("redo",t.hasAnythingToRedo)}).on("textae-event.selection.span.change",()=>this.#Sn()).on("textae-event.selection.relation.change",()=>this.#Sn()).on("textae-event.selection.entity.change",()=>this.#Sn()).on("textae-event.edit-mode.transition",t=>this.#kn(t)).on("textae-event.clip-board.change",()=>this.#$n()).on("textae-event.annotation-auto-saver.enable",t=>this.enable("upload automatically",t))}get(t){return this.#_n.get(t)}enable(t,e){this.#_n.set(t,e),this.#On()}updateButtonsToOperateSpanWithTouchDevice(t,e,i,n){this.#_n.set("create span by touch",t),this.#_n.set("expand span by touch",e),this.#_n.set("shrink span by touch",i),this.#_n.set("edit text by touch",n),this.#On()}#Sn(){for(const{type:t,enableWhenSelecting:e}of(new qx).enableButtonsWhenSelecting)this.enable(t,e(this.#Ie,this.#oi));this.#On()}#$n(){this.enable("paste",(new qx).pasteButton.enableWhenSelecting(this.#Ie,this.#oi))}#On(){this.#Nt.emit("textae-event.control.buttons.change",this.#_n.keys())}#kn(t){switch(t){case gn:this.#Cn(!0,!1,!1,!1,!1,!1,!1);break;case vn:this.#Cn(!0,!0,!0,!0,!0,!0,!0);break;case yn:this.#Cn(!0,!1,!0,!0,!0,!0,!0);break;case On:this.#Cn(!1,!1,!1,!0,!0,!1,!0);break;case bn:this.#Cn(!0,!1,!0,!0,!0,!1,!1);break;default:throw`unknown edit mode!${t}`}this.#On()}#Cn(t,e,i,n,s,o,r){this.#_n.set("simple view",t),this.#_n.set("auto replicate",e),this.#_n.set("boundary detection",i),this.#_n.set("adjust lineheight",n),this.#_n.set("auto adjust lineheight",s),this.#_n.set("create span by touch",o),this.#_n.set("expand span by touch",o),this.#_n.set("shrink span by touch",o),this.#_n.set("pallet",r)}}function Hx(t,e,i,n,s){for(;s(t(i,n));)n+=e;return n}const Wx=function(t,e){return t.charAt(e)},Vx=function(t,e,i){return Hx(Wx,1,t,e,i)},Yx=function(t,e,i){return Hx(Wx,-1,t,e,i)};class Ux{backFromBegin(t,e,i){}forwardFromEnd(t,e,i){}forwardFromBegin(t,e,i){}backFromEnd(t,e,i){}}function Gx(t,e){return[t.charAt(e),t.charAt(e-1)]}function Kx(t,e){return[t.charAt(e),t.charAt(e+1)]}function Jx(t,e,i){return""!==i[0]&&!t(i[1])&&!e(i[1])||e(i[0])}class tw extends Ux{backFromBegin(t,e,i){const n=function(t,e,i){return Hx(Gx,-1,t,e,t=>t[1]&&!i(t[0])&&!i(t[1]))}(t,Vx(t,e,t=>i.isBlankCharacter(t)),t=>i.isDelimiter(t));return n}forwardFromEnd(t,e,i){const n=function(t,e,i){return Hx(Kx,1,t,e,t=>t[1]&&!i(t[0])&&!i(t[1]))}(t,Yx(t,e,t=>i.isBlankCharacter(t)),t=>i.isDelimiter(t));return n}forwardFromBegin(t,e,i){return function(t,e,i){return Hx(Gx,1,t,e,i)}(t,e,t=>Jx(t=>i.isBlankCharacter(t),t=>i.isDelimiter(t),t))}backFromEnd(t,e,i){return function(t,e,i){return Hx(Kx,-1,t,e,i)}(t,e,t=>Jx(t=>i.isBlankCharacter(t),t=>i.isDelimiter(t),t))}}class ew extends Ux{backFromBegin(t,e,i){return Vx(t,e,t=>i.isBlankCharacter(t))}forwardFromEnd(t,e,i){return Yx(t,e,t=>i.isBlankCharacter(t))}forwardFromBegin(t,e,i){return Vx(t,e,t=>i.isBlankCharacter(t))}backFromEnd(t,e,i){return Yx(t,e,t=>i.isBlankCharacter(t))}}function iw(t){switch(t){case vn:return"Term Configuration";case yn:return"Block Configuration";case On:return"Relation Configuration";default:return""}}class nw{#Tn;#Pn;#on;#En;#Vt;#si;#An;constructor(t,e,i,n,s,o,r,a){this.#Tn=new Xx(t,e,i),this.#Pn=new Fx(t),this.#on=n,this.#En=s,this.#Vt=o,this.#si=r,this.#An=a}get pushButtonNames(){return this.#Pn.names}isPushed(t){return this.#Pn.get(t).isPushed}push(t){this.#Pn.get(t).isPushed=!0}release(t){this.#Pn.get(t).isPushed=!1}toggleButton(t){return this.#Pn.get(t).toggle()}get textSelectionAdjuster(){return this.isPushed("boundary detection")?new tw:new ew}get controlBarButton(){return(new qx).controlBar.map(({list:t})=>t.filter(({type:t})=>this.#si.isAvailable(t)).map(({type:t,title:e})=>this.#Mn(t,e)).map(({type:t,title:e})=>({type:t,title:e,pushed:this.getState(t,"pushed"),disabled:this.getState(t,"disabled")}))).filter(t=>t.length)}get contextMenuButton(){return(new qx).getContextMenuFor(this.#An.currentState).map(({list:t})=>t.filter(({type:t})=>this.#si.isAvailable(t)).map(({type:t,title:e})=>this.#Mn(t,e)).reduce((t,{type:e,title:i})=>(!q()&&this.getState(e,"disabled")||t.push(this.#Qn(e,i)),t),[])).filter(t=>t.length)}getState(t,e){switch(e){case"pushed":return this.#Pn.get(t).isPushed;case"disabled":return!this.#Tn.get(t);case"transit":switch(t){case"upload":return this.#on.hasChange;case"pallet":return this.diffOfConfiguration;default:new Error("Unknown name")}break;default:new Error("Unknown state")}}updateButtonsToOperateSpanWithTouchDevice(t,e,i,n){this.#Tn.updateButtonsToOperateSpanWithTouchDevice(t,e,i,n)}get diffOfConfiguration(){return sx(this.#En.configuration,{...this.#En.configuration,...this.#Vt.config})}setPushButtons(t){!0===t.autosave?this.push("upload automatically"):this.release("upload automatically"),!1===t.autolineheight?this.release("auto adjust lineheight"):this.push("auto adjust lineheight"),!1===t.boundarydetection?this.release("boundary detection"):this.push("boundary detection")}get detailModifierClassName(){return this.#si.isAvailable("show logo")?"textae-control-details--show-logo":"textae-control-details--hide-logo"}#Mn(t,e){return"pallet"==t?{type:t,title:iw(this.#An.currentState)}:{type:t,title:e}}#Qn(t,e){return{type:t,title:e,pushed:this.getState(t,"pushed"),disabled:this.getState(t,"disabled"),transit:this.getState(t,"transit")}}}class sw{#Nt;#ei;#Ie;#Dn;#Rn;#Vt;#In;#Ln;constructor(t,e,i,n,s,o){this.#Nt=t,this.#ei=e,this.#Ie=i,this.#Dn=n,this.#Rn=s,this.#Vt=o,this.#In=[],this.#Ln=D(),t.on("textae-event.annotation-data.entity.remove",t=>{this.hasCuttingItem&&this.#Nn(this.#In.filter(e=>e!=t))}).on("textae-event.edit-mode.transition",()=>this.#Nn())}get hasCopyingItem(){return this.#In[0]instanceof Ot}get hasCuttingItem(){return this.#In[0]instanceof Wt}copyEntitiesToLocalClipboard(){this.#Nn(this.#Ie.copyingTargets)}copyEntitiesToSystemClipboard(t){if(this.#Ie.span.contains(t=>t.isBlock))return;const{copyingTargets:e}=this.#Ie;if(e.length>0){const i=this.#Dn.config.filter(({id:t})=>e.some(({typeName:e})=>e===t)),n=this.#Rn.config.filter(({pred:t})=>e.some(({attributes:e})=>e.some(e=>e.pred===t))),s=JSON.stringify({typeValues:e.map(({externalFormat:t})=>t),config:{"entity types":i,"attribute types":n}});t.clipboardData.setData("text/plain",s),t.clipboardData.setData("application/x-textae-type-values",s),t.preventDefault()}}cutEntitiesToLocalClipboard(){const{cuttingTargets:t}=this.#Ie;this.#jn.length&&this.#jn.every(e=>t.has(e))&&[...t].every(t=>this.#jn.includes(t))?this.#Nn():this.#Nn([...t])}cutEntitiesToSystemClipboard(t){this.#Ie.span.contains(t=>t.isBlock)||(this.cutEntitiesToLocalClipboard(),t.clipboardData.setData("application/x-textae-editor-uuid",this.#Ln),this.copyEntitiesToSystemClipboard(t))}pasteEntitiesFromLocalClipboard(){if(this.#zn.length&&this.#Ie.span.single)this.#Bn();else if(this.hasCopyingItem){const t=this.#ei.factory.pasteTypesToSelectedSpansCommand(this.#In);this.#ei.invoke(t)}}pasteEntitiesFromSystemClipboard(t){if(this.#Ie.span.contains(t=>t.isBlock))return;if(t.clipboardData.getData("application/x-textae-editor-uuid")===this.#Ln&&this.#zn.length&&this.#Ie.span.single)return void this.#Bn();const e=t.clipboardData.getData("application/x-textae-type-values");if(e){const t=JSON.parse(e),i=new Le;if(i.definedTypes=t.config["attribute types"],this.#Vt.isLock){const e=t.typeValues.map(({obj:t,attributes:e})=>new Ot(t,e.filter(({pred:t})=>this.#Rn.get(t)&&this.#Rn.get(t).valueType===i.get(t).valueType))),n=this.#ei.factory.pasteTypesToSelectedSpansCommand(e);this.#ei.invoke(n)}else{const e=t.typeValues.map(({obj:t,attributes:e})=>new Ot(t,e.filter(({pred:t})=>!this.#Rn.get(t)||this.#Rn.get(t).valueType===i.get(t).valueType))),n=t.config["entity types"].filter(({id:t})=>!this.#Dn.config.some(e=>e.id===t)),s=t.config["attribute types"].filter(({pred:t})=>!this.#Rn.get(t)),o=this.#ei.factory.pasteTypesToSelectedSpansCommand(e,n,s,this.#qn(e,i));this.#ei.invoke(o)}return void(this.hasCuttingItem&&this.#Nn())}}#qn(t,e){const i=[],n=t.reduce((t,i)=>t.concat(i.attributes.filter(({pred:t})=>"selection"===e.get(t).valueType)),[]);for(const{pred:t,obj:s}of n)if(this.#Rn.get(t)&&!this.#Rn.get(t).values.some(({id:t})=>t===s)){const n=e.get(t).values.find(({id:t})=>t===s);i.push({pred:t,value:n})}return i}#Bn(){const t=this.#ei.factory.moveEntitiesToSelectedSpanCommand(this.#zn);this.#ei.invoke(t),this.#Nn()}#Nn(t=[]){const e=this.#jn.filter(e=>!t.includes(e));this.#In=t,this.#Nt.emit("textae-event.clip-board.change",this.#jn,e)}get#zn(){return this.#jn.filter(t=>t.span.id!==(this.#Ie.span.single&&this.#Ie.span.single.id))}get#jn(){return this.hasCuttingItem?this.#In:[]}}class ow{#ii;constructor(t,e,i,n,o){this.#ii=e;const r=s()(()=>i.saveAnnotation(),5e3);t.on("textae-event.resource.annotation.load.success",()=>this.#Zn()).on("textae-event.resource.save.error",()=>this.#Zn()).on("textae-event.resource.annotation.url.set",e=>t.emit("textae-event.annotation-auto-saver.enable",Boolean(n||e.id))).on("textae-event.control.button.push",({name:t,isPushed:e})=>{"upload automatically"===t&&!0===e&&o.hasChange&&i.saveAnnotation()}).on("textae-event.annotation-data.events-observer.unsaved-change",t=>{t&&e.isPushed("upload automatically")&&r()})}#Zn(){this.#ii.isPushed("upload automatically")&&this.#ii.toggleButton("upload automatically")}}const rw=new d;class aw{#r;constructor(t,e){const i=l().create(t);this.#r=i,function(t,e){r()(t,".textae-control-icon","touchstart",({target:t})=>{if(t.classList.contains("textae-control-icon--disabled"))return;const{buttonType:i}=t.dataset;switch(i){case"create span by touch":case"expand span by touch":case"shrink span by touch":case"edit text by touch":e.handle(i)}},{passive:!0}),r()(t,".textae-control-icon","click",({target:t})=>{if(t.classList.contains("textae-control-icon--disabled"))return;const{buttonType:i}=t.dataset;switch(i){case"help":rw.open();break;case"create span by touch":case"expand span by touch":case"shrink span by touch":case"edit text by touch":break;default:e.handle(i)}});const i=t.querySelector(".textae-control-hamburger-menu-button");i&&i.addEventListener("click",t=>t.target.closest(".textae-control").querySelector(".textae-control-details").classList.toggle("textae-control-details--force-show"))}(this.#r,e)}get el(){return this.#r}_querySelector(t){return this.#r.querySelector(t)}}function lw({type:t,title:e,classList:i}){return`\n<span \nclass="${i.join(" ")}" \ntitle="${e}" \ndata-button-type="${t}">\n</span>\n`}var cw=i(6438),hw=i.n(cw);function uw(t){return t.map(t=>{const e=[];for(const{type:i,title:n,pushed:s,disabled:o,transit:r}of t){const t=["textae-control-icon",`textae-control-${i.replaceAll(" ","-")}-button`];s&&t.push("textae-control-icon--pushed"),o&&t.push("textae-control-icon--disabled"),r&&t.push("textae-control-icon--transit"),e.push({type:i,title:n,classList:t})}return e})}function dw(t){return`\n<div class="textae-control ${q()?"textae-touch-bar":"textae-control-bar"}">\n <div class="textae-control-summary">\n <span class="textae-control-title">\n <a href="http://textae.pubannotation.org/" target="_blank">TextAE</a>\n </span>\n <button type="button" class="textae-control-hamburger-menu-button" >\n <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" class="bi" fill="currentColor" viewBox="0 0 16 16">\n <path fill-rule="evenodd" d="M2.5 11.5A.5.5 0 0 1 3 11h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm0-4A.5.5 0 0 1 3 7h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm0-4A.5.5 0 0 1 3 3h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5z"></path>\n </svg>\n </button>\n </div>\n <div class="textae-control-details ${t.detailModifierClassName}">\n <span class="textae-control-title">\n <a href="http://textae.pubannotation.org/" target="_blank">TextAE</a>\n </span>\n ${uw(t.controlBarButton).map(t=>`\n <span class="textae-control-separator"></span>\n ${t.map(lw).join("\n")}\n `).join("\n")}\n </div>\n</div>\n`}class fw extends aw{#ii;constructor(t,e,i){super(dw(e),i),this.#ii=e,q()&&Math.max(document.documentElement.clientWidth,window.innerWidth)<768&&new(hw())(".textae-touch-bar",{stickyContainer:".textae-editor"}),t.on("textae-event.control.button.push",({name:t})=>{this.#Fn(t,"pushed")}).on("textae-event.control.buttons.change",t=>{for(const e of t)this.#Fn(e,"disabled")}).on("textae-event.annotation-data.events-observer.unsaved-change",()=>{this.#Fn("upload","transit")}).on("textae-event.edit-mode.transition",t=>{const e=iw(t);super._querySelector(".textae-control-pallet-button").title=e}).on("textae-event.configuration.reset",()=>this.#Xn()).on("textae-event.type-definition.entity.change",()=>this.#Fn("pallet","transit")).on("textae-event.type-definition.entity.delete",()=>this.#Fn("pallet","transit")).on("textae-event.type-definition.entity.change-default",()=>this.#Fn("pallet","transit")).on("textae-event.type-definition.relation.change",()=>this.#Fn("pallet","transit")).on("textae-event.type-definition.relation.delete",()=>this.#Fn("pallet","transit")).on("textae-event.type-definition.relation.change-default",()=>this.#Fn("pallet","transit")).on("textae-event.type-definition.attribute.create",()=>this.#Fn("pallet","transit")).on("textae-event.type-definition.attribute.change",()=>this.#Fn("pallet","transit")).on("textae-event.type-definition.attribute.delete",()=>this.#Fn("pallet","transit")).on("textae-event.type-definition.attribute.move",()=>this.#Fn("pallet","transit"))}#Fn(t,e){const i=super._querySelector(`.textae-control-${t.replaceAll(" ","-")}-button`);i&&(this.#ii.getState(t,e)?i.classList.add(`textae-control-icon--${e}`):i.classList.remove(`textae-control-icon--${e}`))}#Xn(){super.el.innerHTML="",super.el.insertAdjacentHTML("beforeend",dw(this.#ii))}}function pw({type:t,title:e,classList:i}){return`<p \n class="${i.join(" ")}" \n data-button-type="${t}">${e}\n </p>`}class mw extends aw{#Q;#ii;constructor(t,e,i){super(`<div class="textae-control ${q()?"textae-android-context-menu":"textae-context-menu"}"></div>`,i),this.#Q=t,this.#ii=e}show(t){const e=window.getSelection(),i=this.#Q.getBoundingClientRect();if(q()&&1===e.rangeCount){const t=e.getRangeAt(0).getBoundingClientRect(),n=this.#Q.querySelector(".textae-editor__text-box").getBoundingClientRect();this.#Hn(t.y-i.y,t.x-n.x)}else this.#Wn(t.pageY-i.y,t.pageX-i.x)}hide(){this.#Vn&&(super.el.classList.remove("textae-context-menu--show"),super.el.classList.add("textae-context-menu--hide"))}get#Vn(){return super.el.classList.contains("textae-context-menu--show")}#Hn(t,e){this.#Yn();const{height:i}=this.el.getBoundingClientRect();super.el.setAttribute("style",`top: ${t-i}px; left: ${e}px`)}#Wn(t,e){this.#Yn(),super.el.setAttribute("style",`top: ${t}px; left: ${e}px`)}#Yn(){const t=uw(this.#ii.contextMenuButton);if(0===t.length)return;const e=`\n <div">\n ${t.map(t=>t.map(pw).join("")).join('<p class="textae-control-separator"></p>\n')}\n </div>\n `;super.el.replaceChildren(...l().create(e).children),super.el.classList.remove("textae-context-menu--hide"),super.el.classList.add("textae-context-menu--show")}}class gw{constructor(t,e,i,n,s){this._map=new Map([["1",t=>s.current.manipulateAttribute(1,t)],["2",t=>s.current.manipulateAttribute(2,t)],["3",t=>s.current.manipulateAttribute(3,t)],["4",t=>s.current.manipulateAttribute(4,t)],["5",t=>s.current.manipulateAttribute(5,t)],["6",t=>s.current.manipulateAttribute(6,t)],["7",t=>s.current.manipulateAttribute(7,t)],["8",t=>s.current.manipulateAttribute(8,t)],["9",t=>s.current.manipulateAttribute(9,t)],["a",()=>n.isAvailable("redo")&&t.redo()],["b",()=>n.isAvailable("boundary detection")&&e.toggleButton("boundary detection")],["d",()=>n.isAvailable("delete")&&e.removeSelectedElements()],["e",()=>n.isAvailable("new entity")&&e.createEntity()],["f",()=>e.changeModeByShortcut()],["i",()=>n.isAvailable("import")&&i.importAnnotation()],["m",()=>e.changeModeByShortcut()],["q",()=>n.isAvailable("pallet")&&s.current.showPallet()],["r",()=>n.isAvailable("replicate span annotation")&&e.replicate()],["u",()=>n.isAvailable("upload")&&i.uploadAnnotation()],["w",()=>n.isAvailable("edit properties")&&s.current.editProperties()],["y",()=>n.isAvailable("redo")&&t.redo()],["z",()=>n.isAvailable("undo")&&t.undo()],["ArrowDown",()=>e.selectDown()],["ArrowLeft",t=>e.selectLeft(t)],["ArrowRight",t=>e.selectRight(t)],["ArrowUp",()=>e.selectUp()],["Backspace",()=>e.removeSelectedElements()],["Delete",()=>e.removeSelectedElements()],["Escape",()=>e.cancelSelect()]])}handle(t){const e=t.shiftKey&&48<=t.keyCode&&t.keyCode<=57?String.fromCharCode(t.keyCode):t.key;this._map.has(e)&&this._map.get(e)(t.shiftKey)}}class vw{constructor(t,e,i,n,s,o){this._map=new Map([["view mode",()=>e.toViewMode()],["term edit mode",()=>e.toTermEditMode()],["block edit mode",()=>e.toBlockEditMode()],["relation edit mode",()=>e.toRelationEditMode()],["text edit mode",()=>e.toTextEditMode()],["simple view",()=>e.toggleSimpleMode()],["import",()=>i.importAnnotation()],["upload",()=>i.uploadAnnotation()],["undo",()=>t.undo()],["redo",()=>t.redo()],["replicate span annotation",()=>e.replicate()],["create span by touch",()=>o.current.createSpanWithTouchDevice()],["expand span by touch",()=>o.current.expandSpanWithTouchDevice()],["shrink span by touch",()=>o.current.shrinkSpanWithTouchDevice()],["edit text by touch",()=>o.current.editTextWithTouchDevice()],["new entity",()=>e.createEntity()],["edit properties",()=>o.current.editProperties()],["pallet",()=>e.showPallet()],["delete",()=>e.removeSelectedElements()],["copy",()=>e.copyEntitiesToLocalClipboard()],["cut",()=>e.cutEntitiesToLocalClipboard()],["paste",()=>e.pasteEntitiesFromLocalClipboard()],["setting",()=>e.showSettingDialog()],["adjust lineheight",()=>s.textBox.updateLineHeight()]]);for(const t of n.pushButtonNames)this._map.has(t)||this._map.set(t,()=>e.toggleButton(t))}handle(t){this._map.has(t)&&this._map.get(t)()}}function yw(t,e){return t.id<e.id?-1:t.id>e.id?1:0}function Ow({text:t,denotations:e=[],attributes:i=[],relations:n=[],blocks:s=[],selectedText:o}){return{text:t,denotations:e.sort(yw),attributes:i.sort(yw),relations:n.sort(yw),blocks:s.sort(yw),selectedText:o}}function bw(t,e){return sx(Ow(t),Ow(e))}class xw{#Nt;#En;#Ht;#Un=new(ve())(!1);constructor(t,e,i){this.#Nt=t,this.#En=e,this.#Ht=i,t.on("textae-event.resource.annotation.save",()=>{this.#Un.set(!1),this.#Gn()}).on("textae-event.annotation-data.all.change",()=>{this.#Un.set(!1),this.#Gn()}).on("textae-event.annotation-data.span.add",()=>this.#Kn()).on("textae-event.annotation-data.span.change",()=>this.#Kn()).on("textae-event.annotation-data.span.remove",()=>this.#Kn()).on("textae-event.annotation-data.entity.add",()=>this.#Kn()).on("textae-event.annotation-data.entity.change",()=>this.#Kn()).on("textae-event.annotation-data.entity.remove",()=>this.#Kn()).on("textae-event.annotation-data.entity.move",()=>this.#Kn()).on("textae-event.annotation-data.relation.add",()=>this.#Kn()).on("textae-event.annotation-data.relation.change",()=>this.#Kn()).on("textae-event.annotation-data.relation.remove",()=>this.#Kn()).on("textae-event.annotation-data.attribute.add",()=>this.#Kn()).on("textae-event.annotation-data.attribute.remove",()=>this.#Kn()).on("textae-event.annotation-data.text.change",()=>this.#Kn()),this.#Un(()=>t.emit("textae-event.annotation-data.events-observer.unsaved-change",this.#Un()))}get hasChange(){return this.#Un()}#Kn(){this.#Un.set(bw(this.#En.annotation,this.#Ht.externalFormat)),this.#Gn()}#Gn(){this.#Nt.emit("textae-event.annotation-data.events-observer.change",this.#Ht)}}async function ww(t,e){if(function(t,e){const i=hx().extname(e),n=t.headers.get("Content-Type");return".json"===i||n&&n.includes("application/json")}(t,e))return await t.json();if(function(t,e){const i=hx().extname(e),n=t.headers.get("Content-Type");return".txt"===i||n&&n.includes("text/plain")}(t,e)){const e=await t.text();return ub.parse(e)}throw new Error("The content type of the loaded content is not supported.")}class _w extends Error{constructor(t){super(t),this.name="FormatConversionError"}}class Sw{#Nt;constructor(t){this.#Nt=t}async loadFrom(t){console.assert(t,"url is necessary!"),this.#Nt.emit("textae-event.resource.startLoad");try{const e=await fetch(t,{method:"GET",cache:"no-cache",credentials:"omit",headers:{Accept:"application/json, text/plain"},signal:AbortSignal.timeout(3e4)});if(e.ok){const i=await ww(e,t);this.#Jn(t,i)}else 401===e.status?await this.#ts(t):this.#es(t)}catch(e){e instanceof _w||console.error(e),this.#es(t)}finally{this.#Nt.emit("textae-event.resource.endLoad")}}#Jn(t,e){const i=dx.createURLSource(t,e);e&&e.text?(this.#Nt.emit("textae-event.resource.annotation.load.success",i),this.#Nt.emit("textae-event.resource.annotation.url.set",i)):this.#Nt.emit("textae-event.resource.annotation.format.error",i)}async#ts(t){try{const e=await fetch(t,{method:"GET",cache:"no-cache",credentials:"include",headers:{Accept:"application/json, text/plain"},signal:AbortSignal.timeout(3e4)});if(e.ok){const i=await ww(e,t);this.#Jn(t,i)}else 401===e.status?await this.#ts(t):this.#es(t)}catch{this.#es(t)}}#es(t){e().error(`Could not load the file from the location you specified.: ${t}`),this.#Nt.emit("textae-event.resource.annotation.load.error",t)}}class kw{#Nt;constructor(t){this.#Nt=t}loadFrom(t,e){console.assert(t,"url is necessary!"),this.#Nt.emit("textae-event.resource.startLoad"),fetch(t,{method:"GET",cache:"no-cache",credentials:"omit",headers:{Accept:"application/json","Content-Type":"application/json"},signal:AbortSignal.timeout(3e4)}).then(i=>{if(i.ok)return i.json().then(i=>this.#Jn(t,i,e));this.#es(t)}).catch(()=>this.#es(t)).finally(()=>this.#Nt.emit("textae-event.resource.endLoad"))}#Jn(t,e,i){this.#Nt.emit("textae-event.resource.configuration.load.success",dx.createURLSource(t,e),i)}#es(t){e().error(`Could not load the file from the location you specified.: ${t}`),this.#Nt.emit("textae-event.resource.configuration.load.error",t)}}function $w(t,e,i){return 401===t&&e&&"ServerPage"===e&&i?i:null}function Cw(t){return window.open(t,"_blank","width=600, height=500")}function Tw(t,e){return"json"===e?JSON.stringify(t):"inline"===e?ub.generate(t):void 0}class Pw{#is;#Nt;constructor(t,e){this.#is=t,this.#Nt=e}async saveTo(t,e){if(t){this.#Nt.emit("textae-event.resource.startSave");try{const i=Tw(e,this.#is),n=await this.#ns(t,i);await this.#ss(n,t,e)}catch(t){t instanceof _w||console.error(t),this.#es()}finally{this.#Nt.emit("textae-event.resource.endSave")}}}async#ns(t,e){const i="json"===this.#is?"application/json":"text/plain";return fetch(t,{method:"POST",headers:{"Content-Type":i,"App-Name":"TextAE"},body:e,credentials:"include"})}async#ss(t,e,i){if(t.ok)this.#os(i);else if(401===t.status){const n=$w(t.status,t.headers.get("WWW-Authenticate"),t.headers.get("Location"));n&&await this.#rs(n,e,i)}else this.#es()}#os(t){e().success("annotation saved"),this.#Nt.emit("textae-event.resource.annotation.save",t)}async#rs(t,e,i){const n=Cw(t);if(!n)return this.#es();await async function(t){return new Promise(e=>{const i=setInterval(()=>{t.closed&&(clearInterval(i),e())},1e3)})}(n),await this.#as(i,e)}async#as(t,e){const i=Tw(t,this.#is);(await this.#ns(e,i)).ok?this.#os(t):this.#es()}#es(){e().error("could not save"),this.#Nt.emit("textae-event.resource.save.error")}}class Ew{#Nt;constructor(t){this.#Nt=t}saveTo(t,e){if(t){this.#Nt.emit("textae-event.resource.startSave");const i={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),credentials:"include"};fetch(t,i).then(i=>{if(i.ok)return this.#os(e);if(401===i.status){const n=$w(i.status,i.headers.get("WWW-Authenticate"),i.headers.get("Location"));if(n)return this.#rs(n,t,e)}this.#es()}).finally(()=>this.#Nt.emit("textae-event.resource.endSave"))}}#os(t){e().success("configuration saved"),this.#Nt.emit("textae-event.resource.configuration.save",t)}#rs(t,e,i){if(!Cw(t))return this.#es();const n=setInterval(()=>{clearInterval(n),this.#as(i,e)},1e3)}#as(t,e){{const i={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),credentials:"include"};fetch(e,i).then(e=>{e.ok?this.#os(t):this.#es()})}}#es(){e().error("could not save"),this.#Nt.emit("textae-event.resource.save.error")}}class Aw{#Nt;constructor(t){this.#Nt=t}loadAnnotation(t){new Sw(this.#Nt).loadFrom(t)}loadConfiguration(t,e=null){new kw(this.#Nt).loadFrom(t,e)}saveAnnotation(t,e,i){new Pw(i,this.#Nt).saveTo(t,e)}saveConfiguration(t,e){new Ew(this.#Nt).saveTo(t,e)}}class Mw{#ls;constructor(){this.#ls=new Map([["logo",{name:"show logo",enabled:!0}],["read",{name:"import",enabled:!0}],["write",{name:"upload",enabled:!0}],["write-auto",{name:"upload automatically",enabled:!0}],["view",{name:"view mode",enabled:!0}],["term",{name:"term edit mode",enabled:!0}],["term-edit",{alias:"term"}],["block",{name:"block edit mode",enabled:!0}],["block-edit",{alias:"block"}],["relation",{name:"relation edit mode",enabled:!0}],["relation-edit",{alias:"relation"}],["text-edit",{name:"text edit mode",enabled:!0}],["simple",{name:"simple view",enabled:!0}],["line-height",{name:"adjust lineheight",enabled:!0}],["line-height-auto",{name:"auto adjust lineheight",enabled:!0}],["undo",{name:"undo",enabled:!0}],["redo",{name:"redo",enabled:!0}],["replicate",{name:"replicate span annotation",enabled:!0}],["replicate-auto",{name:"auto replicate",enabled:!0}],["boundary-detection",{name:"boundary detection",enabled:!0}],["create-span-by-touch",{name:"create span by touch",enabled:!0}],["expand-span-by-touch",{name:"expand span by touch",enabled:!0}],["shrink-span-by-touch",{name:"shrink span by touch",enabled:!0}],["edit-text-by-touch",{name:"edit text by touch",enabled:!0}],["entity",{name:"new entity",enabled:!0}],["pallet",{name:"pallet",enabled:!0}],["edit-properties",{name:"edit properties",enabled:!0}],["delete",{name:"delete",enabled:!0}],["copy",{name:"copy",enabled:!0}],["cut",{name:"cut",enabled:!0}],["paste",{name:"paste",enabled:!0}],["setting",{name:"setting",enabled:!0}],["help",{name:"help",enabled:!0}]])}get defaultAvailabilities(){return Array.from(this.#ls.values()).filter(({name:t,enabled:e})=>void 0!==t&&void 0!==e).reduce((t,{name:e,enabled:i})=>t.set(e,i),new Map)}translateToInnerNameFrom(t){if(this.#ls.has(t)){const e=this.#ls.get(t);return e.alias?this.#ls.get(e.alias).name:e.name}return e().warning(`'${t}' is an unknown function name for function availabilities.`),t}}class Qw{#cs;#hs;constructor(){this.#cs=new Mw,this.#hs=this.#cs.defaultAvailabilities}isAvailable(t){return this.#hs.get(t)}enable(t){this.#hs.set(t,!0)}disable(t){this.#hs.set(t,!1)}get names(){return Array.from(this.#hs.keys())}set availability(t){const e=this.#cs.defaultAvailabilities;if(t)for(const[i,n]of Object.entries(t))e.set(this.#cs.translateToInnerNameFrom(i),n);this.#hs=e}}class Dw{#us;#ds;#fe;#Nt;#si;constructor(t,e,i){this.#us=!1,this.#ds=mn,this.#fe=t,this.#Nt=e,this.#si=i}get currentState(){return this.#ds}toViewMode(t){this.#us=t,this.#ds=gn,this.#fs()}toTermEditMode(t){this.#us=t,this.#ds=vn,this.#fs()}toBlockEditMode(t){this.#us=t,this.#ds=yn,this.#fs()}toRelationEditMode(){this.#us=!0,this.#ds=On,this.#fs()}toTextEditMode(t){this.#us=t,this.#ds=bn,this.#fs()}toggleSimpleMode(){switch(this.currentState){case vn:this.toTermEditMode(!this.#us);break;case yn:this.toBlockEditMode(!this.#us);break;case bn:this.toTextEditMode(!this.#us);break;case gn:this.toViewMode(!this.#us);break;default:throw new Error(`Invalid state: ${this.currentState}`)}}changeModeByShortcut(){const t=this.#ps;if(t.length<=1)return;const e=t.findIndex(t=>t.name===this.currentState);e<t.length-1?this[t[e+1].funcName](this.nextShowRelation):this[t[0].funcName](this.nextShowRelation)}get nextShowRelation(){return this.#ds===On?this.#fe.some:this.#us}#fs(){this.#Nt.emit("textae-event.edit-mode.transition",this.#ds,this.#us)}get#ps(){return[{name:gn,availabilityName:"view mode",funcName:"toViewMode"},{name:vn,availabilityName:"term edit mode",funcName:"toTermEditMode"},{name:yn,availabilityName:"block edit mode",funcName:"toBlockEditMode"},{name:On,availabilityName:"relation edit mode",funcName:"toRelationEditMode"}].filter(t=>this.#si.isAvailable(t.availabilityName))}}class Rw{#An;#Ht;#ms;#hi;constructor(t,e,i,n){this.#hi=n,this.#An=i,this.#Ht=t,this.#ms=e}toViewMode(){this.hidePallet(),this.#An.toViewMode(this.#An.nextShowRelation)}toTermEditMode(){this.hidePallet(),this.#An.toTermEditMode(this.#An.nextShowRelation)}toBlockEditMode(){this.hidePallet(),this.#An.toBlockEditMode(this.#An.nextShowRelation)}toRelationEditMode(){this.hidePallet(),this.#An.toRelationEditMode()}toTextEditMode(){this.hidePallet(),this.#An.toTextEditMode(this.#An.nextShowRelation)}toggleSimpleMode(){this.hidePallet(),this.#An.toggleSimpleMode()}changeModeByShortcut(){this.hidePallet(),this.#An.changeModeByShortcut()}get isEditDenotation(){return this.#hi.isEditDenotation}reset(){this.#ms.isEditTermMode?this.#An.toTermEditMode(this.#Ht.relationInstanceContainer.some):this.#ms.isEditBlockMode?this.#An.toBlockEditMode(this.#Ht.relationInstanceContainer.some):this.#ms.isEditRelationMode?this.#An.toRelationEditMode():this.#ms.isTextEditMode?this.#An.toTextEditMode(this.#Ht.relationInstanceContainer.some):this.#An.toViewMode(this.#Ht.relationInstanceContainer.some)}hidePallet(){this.#hi.current.hidePallet()}get isTypeValuesPalletShown(){return this.#hi.current.isPalletShown}selectLeftAttributeTab(){this.#hi.current.pallet.selectLeftAttributeTab()}selectRightAttributeTab(){this.#hi.current.pallet.selectRightAttributeTab()}}function Iw(){window.getSelection().removeAllRanges()}function Lw(t,i,n,s,o,r,a,l,c){if(a){s.removeAll();const h=L(t,a),u=function(t,i,n,s,o,r,a){const{begin:l,end:c}=t.getSpan(o).getShortenInAnchorNodeToFocusNodeDirection(s,i,r);if(t.isBoundaryCrossingWithOtherSpans(l,c))return e().warning("A span cannot be shrunken to make a boundary crossing."),!1;const h=t.findDenotation(l,c);return l<c&&!h?(a(l,c),!1):(n.invoke(n.factory.removeSpanCommand(o)),!0)}(i,n,o,r,a,l,c);u&&h&&s.selectSpan(h.id)}}class Nw{constructor(){this.selection=window.getSelection(),console.assert(this.parentOfAnchorNode.closest(".textae-editor__text-box")===this.parentOfFocusNode.closest(".textae-editor__text-box"),"Text selection across editors is disabled")}get isParentOfAnchorNodeTextBox(){return Y(this.parentOfAnchorNode)}get isParentOfAnchorNodeDenotationSpan(){return U(this.parentOfAnchorNode)}get isParentOfAnchorNodeBlockSpan(){return K(this.parentOfAnchorNode)}get isParentOfAnchorNodeStyleSpan(){return G(this.parentOfAnchorNode)}get isParentOfFocusNodeTextBox(){return Y(this.parentOfFocusNode)}get isParentOfFocusNodeDenotationSpan(){return U(this.parentOfFocusNode)}get isParentOfFocusNodeBlockSpan(){return K(this.parentOfFocusNode)}get isParentOfFocusNodeStyleSpan(){return G(this.parentOfFocusNode)}get isParentOfBothNodesSame(){return this.parentOfAnchorNode===this.parentOfFocusNode}get isParentOfBothNodesTextBox(){return this.isParentOfAnchorNodeTextBox&&this.isParentOfFocusNodeTextBox}get isParentsParentOfAnchorNodeAndFocusedNodeSame(){return this.parentOfAnchorNode.parentElement===this.parentOfFocusNode.parentElement}get isAnchorNodeParentIsDescendantOfFocusNodeParent(){return this.parentOfAnchorNode.closest(`#${this.parentOfFocusNode.id}`)}get ancestorDenotationSpanOfAnchorNode(){return this.parentOfAnchorNode.closest(".textae-editor__span")}get ancestorDenotationSpanOfFocusNode(){return this.parentOfFocusNode.closest(".textae-editor__span")}get ancestorBlockSpanOfAnchorNode(){return this.parentOfAnchorNode.closest(".textae-editor__block")}get ancestorBlockSpanOfFocusNode(){return this.parentOfFocusNode.closest(".textae-editor__block")}get doesFitInOneBlockSpan(){return this.ancestorBlockSpanOfAnchorNode===this.ancestorBlockSpanOfFocusNode}get parentOfAnchorNode(){return this.selection.anchorNode.parentElement}get parentOfFocusNode(){return this.selection.focusNode.parentElement}}class jw{#Q;#Ht;#ni;#ei;#ii;#Ie;constructor(t,e,i,n,s,o){this.#Q=t,this.#Ht=e,this.#ni=i,this.#ei=n,this.#ii=s,this.#Ie=o}editFor(){const t=new Nw;if(t.isParentOfAnchorNodeTextBox){if(t.isParentOfFocusNodeTextBox)return void this.#gs();if(t.isParentOfFocusNodeDenotationSpan||t.isParentOfFocusNodeStyleSpan)return void(t.ancestorBlockSpanOfFocusNode?this.#vs(t):this.#gs());if(t.isParentOfFocusNodeBlockSpan)return void this.#vs(t)}if(t.isParentOfAnchorNodeDenotationSpan||t.isParentOfAnchorNodeStyleSpan){if(t.isParentOfFocusNodeTextBox||t.isParentOfFocusNodeDenotationSpan||t.isParentOfFocusNodeStyleSpan){if(t.ancestorBlockSpanOfAnchorNode)if(t.doesFitInOneBlockSpan){const{anchor:e,focus:i}=this.#Ht.textSelection,n=this.#Ht.getSpan(t.parentOfAnchorNode.id),s=this.#Ht.getSpan(t.ancestorBlockSpanOfAnchorNode.id);e<i&&n.begin===s.begin||i<e&&n.end===s.end?this.#vs(t):Iw()}else this.#ys(t);else t.ancestorBlockSpanOfFocusNode?this.#vs(t):this.#gs();return}if(t.isParentOfFocusNodeBlockSpan)return void this.#vs(t)}if(t.isParentOfAnchorNodeBlockSpan){if(t.isParentOfFocusNodeTextBox||t.isParentOfFocusNodeDenotationSpan||t.isParentOfFocusNodeStyleSpan)return void(t.ancestorBlockSpanOfFocusNode?this.#vs(t):this.#ys(t));if(t.isParentOfFocusNodeBlockSpan){const{anchor:e}=this.#Ht.textSelection,i=this.#Ht.getSpan(t.parentOfFocusNode.id);if(e===i.begin||e===i.end)return void this.#vs(t)}}Iw()}cerateSpanForTouchDevice(){(new Nw).isParentOfBothNodesTextBox&&this.#gs()}expandForTouchDevice(){const t=this.#Os();if(t){const{spanID:e,begin:i,end:n}=t;this.#Ht.validateNewBlockSpan(i,n,e)&&this.#ei.invoke(this.#ei.factory.moveBlockSpanCommand(e,i,n))}}shrinkForTouchDevice(){const t=this.#bs();if(t){const{spanID:i,begin:n,end:s}=t,o=L(this.#Q,i);if(this.#Ht.isBoundaryCrossingWithOtherSpans(n,s))return void e().warning("A span cannot be modified to make a boundary crossing.");if(this.#Ht.hasParentOf(n,s,i))return;const r=this.#Ht.findBlock(n,s);n<s&&!r?this.#ei.invoke(this.#ei.factory.moveBlockSpanCommand(i,n,s)):(this.#ei.invoke(this.#ei.factory.removeSpanCommand(i)),o&&this.#Ie.selectSpan(o.id))}}#gs(){this.#Ht.hasCharacters(this.#ni)&&(this.#Ie.removeAll(),function(t,e,i,n){const{begin:s,end:o}=t.getTextSelection(n,i);if(t.validateNewBlockSpan(s,o)){const t=e.factory.createBlockSpanCommand({begin:s,end:o});e.invoke(t)}}(this.#Ht,this.#ei,this.#ii.textSelectionAdjuster,this.#ni)),Iw()}#ys(t){const e=t.ancestorBlockSpanOfAnchorNode.id;this.#Ie.removeAll();const{begin:i,end:n}=this.#Ht.getSpan(e).getExpandedInAnchorNodeToFocusNodeDirection(this.#ii.textSelectionAdjuster,this.#Ht.sourceDoc,this.#ni);this.#Ht.validateNewBlockSpan(i,n,e)&&this.#ei.invoke(this.#ei.factory.moveBlockSpanCommand(e,i,n)),Iw()}#vs(t){const e=t.ancestorBlockSpanOfFocusNode.id;Lw(this.#Q,this.#Ht,this.#Ht.sourceDoc,this.#Ie,this.#ei,this.#ii.textSelectionAdjuster,e,this.#ni,(t,i)=>{this.#ei.invoke(this.#ei.factory.moveBlockSpanCommand(e,t,i))}),Iw()}#Os(){const t=new Nw;if(null==t.ancestorBlockSpanOfAnchorNode&&null==t.ancestorBlockSpanOfFocusNode)return null;if(t.parentOfFocusNode.contains(t.parentOfAnchorNode)){const e=t.parentOfAnchorNode.id;return{spanID:e,...this.#Ht.getSpan(e).getExpandedInAnchorNodeToFocusNodeDirection(this.#ii.textSelectionAdjuster,this.#Ht.sourceDoc,this.#ni)}}if(t.parentOfAnchorNode.contains(t.parentOfFocusNode)){const e=t.parentOfFocusNode.id;return{spanID:e,...this.#Ht.getSpan(e).getExpandedInFocusNodeToAnchorNodeDirection(this.#ii.textSelectionAdjuster,this.#Ht.sourceDoc,this.#ni)}}}#bs(){const t=new Nw;if(null==t.ancestorBlockSpanOfAnchorNode&&null==t.ancestorBlockSpanOfFocusNode)return null;if(t.parentOfAnchorNode===t.parentOfFocusNode)return null;if(t.parentOfFocusNode.contains(t.parentOfAnchorNode)){const e=t.parentOfAnchorNode.id;return{spanID:e,...this.#Ht.getSpan(e).getShortenInFocusNodeToAnchorNodeDirection(this.#ii.textSelectionAdjuster,this.#Ht.sourceDoc,this.#ni)}}if(t.parentOfAnchorNode.contains(t.parentOfFocusNode)){const e=t.parentOfFocusNode.id;return{spanID:e,...this.#Ht.getSpan(e).getShortenInAnchorNodeToFocusNodeDirection(this.#ii.textSelectionAdjuster,this.#Ht.sourceDoc,this.#ni)}}}}function zw(t,e,i,n){e.length?t.selectSpanRange(e):i.ctrlKey||i.metaKey?t.span.toggle(n):t.selectSpan(n)}function Bw(t){const e=window.getSelection();return"Range"===e.type&&t.contains(e.anchorNode)&&t.contains(e.focusNode)}function qw(t){return t.closest(".textae-editor__signboard")}class Zw{#Q;#Ht;#Ie;#xs;#ws;constructor(t,e,i,n,s){this.#Q=t,this.#Ht=e,this.#Ie=i,this.#xs=n,this.#ws=s}bind(){const t=[];return t.push(r()(this.#Q,".textae-editor__text-box","click",t=>{t.target.classList.contains("textae-editor__text-box")&&this.#_s()})),t.push(r()(this.#Q,".textae-editor","click",t=>{t.target.classList.contains("textae-editor")&&this.#Ss()})),t.push(r()(this.#Q,".textae-editor__signboard","mousedown",()=>this.#ks())),t.push(r()(this.#Q,".textae-editor__signboard__type-values","click",t=>{const e=qw(t.target).dataset.id;this.#$s(t,e)})),t.push(r()(this.#Q,".textae-editor__block","mouseup",t=>{t.target.classList.contains("textae-editor__block")&&this.#Cs()})),t.push(r()(this.#Q,".textae-editor__block-hit-area","mouseup",t=>{t.target.classList.contains("textae-editor__block-hit-area")&&this.#Ts(t)})),t.push(r()(this.#Q,".textae-editor__style","mouseup",t=>{t.target.classList.contains("textae-editor__style")&&this.#Ps(t)})),t.push(r()(this.#Q,".textae-editor__span","mouseup",t=>{t.target.classList.contains("textae-editor__span")&&this.#Es(t)})),t}#Ss(){this.#ws.hide(),this.#Ie.removeAll()}#_s(){"Caret"===window.getSelection().type&&(this.#ws.hide(),this.#Ie.removeAll()),Bw(this.#Q.querySelector(".textae-editor__text-box"))&&this.#xs.editFor()}#Cs(){"Caret"===window.getSelection().type&&(this.#ws.hide(),Iw(),this.#Ie.removeAll()),Bw(this.#Q.querySelector(".textae-editor__text-box"))&&this.#xs.editFor()}#Ts(t){2===t.button&&Iw();const e=window.getSelection();if("Caret"===e.type||"None"===e.type){const e=t.target.dataset.id;this.#As(t,e)}}#Ps(t){"Caret"===window.getSelection().type&&this.#Ie.removeAll(),Bw(this.#Q.querySelector(".textae-editor__text-box"))&&(this.#xs.editFor(),t.stopPropagation())}#Es(t){"Caret"===window.getSelection().type&&this.#Ie.removeAll(),Bw(this.#Q.querySelector(".textae-editor__text-box"))&&(this.#xs.editFor(),t.stopPropagation())}#ks(){this.#Q.focus()}#$s(t,e){if(this.#Ht.entityInstanceContainer.get(e).isBlock){t.ctrlKey||t.metaKey?this.#Ie.entity.toggle(e):this.#Ie.selectEntity(e);const i=this.#Ie.entity.all.map(t=>t.span).map(t=>t.id);this.#Ie.add("span",i)}}#As(t,e){const i=this.#Ie.span.singleId,n=t.shiftKey&&i?this.#Ht.spanInstanceContainer.rangeBlockSpan(i,e):[];zw(this.#Ie,n,t,e);const s=this.#Ie.span.all.map(t=>t.entities.at(0)).map(t=>t.id);this.#Ie.add("entity",s)}}class Fw{createSpanWithTouchDevice(){}expandSpanWithTouchDevice(){}shrinkSpanWithTouchDevice(){}editTextWithTouchDevice(){}editProperties(){}relationClicked(){}relationBollardClicked(t){t.focus()}applyTextSelectionWithTouchDevice(){}manipulateAttribute(){}showPallet(){}hidePallet(){}get isPalletShown(){return!1}}class Xw extends u{constructor(t,e,i,n){const s=()=>{const t=n();t&&this.resolveFunc(t),super.close()},o={text:"OK",click:s};i.buttons=i.buttons?i.buttons.concat([o]):[o],super(t,e,i),r()(super.el,".textae-editor__promise-dialog__observable-element","keyup",t=>{13===t.keyCode&&s()})}open(){return super.open(),new Promise(t=>this.resolveFunc=t)}}class Hw extends Xw{constructor(t,e,i,n,s,o){const a=[];n&&a.unshift({class:"textae-editor__edit-numeric-attribute-dialog__remove-attribute",click:()=>{this.close(),this.resolveFunc({newObj:null})}}),o&&a.unshift({text:"...",title:"configuration",click:()=>{this.close(),o.show(),o.showAttribute(e.pred)}}),super(`Attribute [${i.map(({id:t})=>t||"-").join(",")}]`,function(t){const{subjects:e,pred:i,min:n,max:s,step:o,value:r}=t;return ot`
304
+ `}bind(t,e){r()(t,".textae-editor__load-dialog__url-text","input",t=>{wn(t.target.nextElementSibling,t.target.value)}),r()(t,".textae-editor__load-dialog__url-button","click",t=>e(t.target.previousElementSibling.value))}}var XO=i(2628),HO=i.n(XO);function WO(t,e){t.element.classList.remove("textae-editor__load-dialog__overlay-dropzone--maximized"),t.element.style.zIndex=e}class VO{#ui;get template(){return'\n<div class="textae-editor__load-dialog__row">\n <label>\n Local\n </label>\n <form class="dropzone textae-editor__load-dialog__dropzone">\n <div class="dz-message">\n Drop a file here or click to select\n </div>\n </form>\n <div class="textae-editor__load-dialog__dz-file-preview">\n <div class="dz-filename"><span data-dz-name>No file selected</span></div>\n </div>\n <input\n type="button"\n class="textae-editor__load-dialog__local-button"\n disabled="disabled"\n value="Open">\n</div>\n'}bind(t,e){r()(t,".textae-editor__load-dialog__local-button","click",()=>e(this.#ui))}intiializeDropzone(t){const e={url:"nothing",previewsContainer:".textae-editor__load-dialog__dz-file-preview",previewTemplate:t.querySelector(".textae-editor__load-dialog__dz-file-preview").innerHTML},i=new(HO())("body > div.ui-widget-overlay.ui-front",{...e,clickable:!1}),n=i.element.style.zIndex;i.on("dragenter",()=>function(t){const{element:e}=t;e.classList.add("textae-editor__load-dialog__overlay-dropzone--maximized"),e.style.zIndex=parseInt(e.style.zIndex)+1}(i)).on("dragleave",()=>WO(i,n)).on("addedfile",e=>{WO(i,n),this.#di(t,e)});new(HO())(".textae-editor__load-dialog__dropzone",e).on("addedfile",e=>{this.#di(t,e)})}#di(t,e){t.querySelector(".textae-editor__load-dialog__dz-file-preview").firstElementChild.remove(),t.querySelector(".textae-editor__load-dialog__dz-file-preview > div").setAttribute("title",e.name),this.#ui=e,wn(t.querySelector(".textae-editor__load-dialog__local-button"),!0)}}class YO extends u{#fi;constructor(t,e,i,n,s,o){const a=new FO(e),l=new VO;super(t,function(t){const{url:e,local:i}=t;return`\n<div class="textae-editor__load-dialog__container">\n ${e}\n ${i}\n <div class="textae-editor__load-dialog__row">\n <div class="textae-editor__load-dialog__format">\n <label class="textae-editor__load-dialog__format-button">\n <input type="radio" name="format" value="json" checked>JSON\n </label>\n <label class="textae-editor__load-dialog__format-button">\n <input type="radio" name="format" value="inline">Text\n </label>\n </div>\n <textarea class="textae-editor__load-dialog__textarea"></textarea>\n <input type="button" value="Edit" class="edit" disabled="disabled">\n <input type="button" value="Open" class="instant" disabled="disabled">\n </div>\n</div>`}({url:a.template,local:l.template})),this.#fi=l,a.bind(super.el,t=>{ZO(o)&&i(t),super.close()}),this.#fi.bind(super.el,t=>{ZO(o)&&n(t),super.close()}),r()(super.el,".textae-editor__load-dialog__textarea","input",t=>{wn(super.el.querySelector('[type="button"].instant'),t.target.value),wn(super.el.querySelector('[type="button"].edit'),t.target.value)});let c=null;r()(super.el,'[type="button"].instant',"click",()=>{const t=c?c.state.doc.toString():super.el.querySelector(".textae-editor__load-dialog__textarea").value,e=this.#pi();ZO(o)&&s(t,e),super.close()}),r()(super.el,'[type="button"].edit',"click",()=>{this.#mi();const t=super.el.querySelector(".textae-editor__load-dialog__textarea"),e=this.#pi();"json"===e&&_n(t.value)&&(t.value=JSON.stringify(JSON.parse(t.value),null,2));const i=super.el.closest(".textae-editor__dialog").clientHeight;c="json"===e?qO(t,i):function(t,e){const i=Tc.theme({"&":{height:.6*e+"px"}}),n=new Tc({doc:t.value,extensions:[Qy,Qf(If),i]});return t.parentNode.insertBefore(n.dom,t),t.style.display="none",n}(t,i);const n=super.el.querySelectorAll('.textae-editor__load-dialog__format-button input[type="radio"]');for(const t of n)t.disabled=!0;super.el.querySelector('[type="button"].edit').disabled=!0})}open(){super.open(),this.#fi.intiializeDropzone(super.el)}#mi(){super.el.closest(".textae-editor__dialog").classList.add("textae-editor__load-dialog--expanded")}#pi(){return super.el.querySelector('input[name="format"]:checked').value}}class UO extends u{#fi;constructor(t,e,i,n,s,o){const a=new FO(e),l=new VO;super(t,function(t){const{url:e,local:i}=t;return`\n<div class="textae-editor__load-dialog__container">\n ${e}\n ${i}\n <div class="textae-editor__load-dialog__row json">\n <label>\n JSON\n </label>\n <textarea class="textae-editor__load-dialog__textarea"></textarea>\n <input type="button" value="Edit" class="edit" disabled="disabled">\n <input type="button" value="Open" class="instant" disabled="disabled">\n </div>\n</div>`}({url:a.template,local:l.template})),this.#fi=l,a.bind(super.el,t=>{ZO(o)&&i(t),super.close()}),this.#fi.bind(super.el,t=>{ZO(o)&&n(t),super.close()}),r()(super.el,".textae-editor__load-dialog__textarea","input",t=>{wn(super.el.querySelector('[type="button"].instant'),t.target.value),wn(super.el.querySelector('[type="button"].edit'),t.target.value)});let c=null;r()(super.el,'[type="button"].instant',"click",()=>{const t=c?c.state.doc.toString():super.el.querySelector(".textae-editor__load-dialog__textarea").value;ZO(o)&&s(t),super.close()}),r()(super.el,'[type="button"].edit',"click",()=>{this.#mi();const t=super.el.querySelector(".textae-editor__load-dialog__textarea");_n(t.value)&&(t.value=JSON.stringify(JSON.parse(t.value),null,2));const e=super.el.closest(".textae-editor__dialog").clientHeight;c=qO(t,e),super.el.querySelector('[type="button"].edit').disabled=!0})}open(){super.open(),this.#fi.intiializeDropzone(super.el)}#mi(){super.el.closest(".textae-editor__dialog").classList.add("textae-editor__load-dialog--expanded")}}function GO(t){const e=new Blob([JSON.stringify(t)],{type:"application/json"});return URL.createObjectURL(e)}const KO=class{#gi;#vi;#Y;#H;constructor(t,e,i,n=null){this.#gi=t,this.#vi=e,this.#Y=i,this.#H=n}get beginPos(){return this.#gi}get endPos(){return this.#vi}get obj(){return this.#Y}get id(){return this.#H}get span(){return{begin:this.#gi,end:this.#vi}}toObject(){const t={span:this.span,obj:this.#Y};return this.#H&&(t.id=this.#H),t}isNestedWithin(t){return t.beginPos<=this.#gi&&this.#vi<=t.endPos}get isPositionNotInteger(){return!(Number.isInteger(this.#gi)&&Number.isInteger(this.endPos))}get isPositionNegative(){return this.#gi<0||this.#vi<0}get isPositionInvalid(){return this.#gi>this.#vi}isOutOfBounds(t){return this.#gi>=t||this.#vi>t}isBoundaryCrossing(t){const e=this.#gi>t.beginPos&&this.#gi<t.endPos,i=this.#vi>t.beginPos&&this.#vi<t.endPos;return e||i}};const JO=class{validateDenotations(t,e){let i=this.#yi(t);return i=this.#Oi(i),i=this.#bi(i),i=this.#xi(i),i=this.#wi(i,e),i=this.#_i(i),this.#Si(i)}#yi(t){const e=new Set;return t.filter(t=>{const i=JSON.stringify(t.span);return!e.has(i)&&(e.add(i),!0)})}#Oi(t){return t.filter(t=>!t.isPositionNotInteger)}#bi(t){return t.filter(t=>!t.isPositionNegative)}#xi(t){return t.filter(t=>!t.isPositionInvalid)}#wi(t,e){return t.filter(t=>!t.isOutOfBounds(e))}#_i(t){const e=t.sort((t,e)=>t.beginPos===e.beginPos?e.endPos-t.endPos:t.beginPos-e.beginPos),i=[];return e.forEach(t=>{i.some(e=>t.isNestedWithin(e))||i.push(t)}),i}#Si(t){return t.filter(e=>!t.some(t=>e!==t&&e.isBoundaryCrossing(t)))}};class tb extends Error{constructor(t){super(t),this.name=this.constructor.name}}const eb=tb;const ib=class{validateRelations(t){return this.#ki(t)}#ki(t){return t.filter(t=>t.subj&&t.pred&&t.obj)}};const nb=class{constructor(t){this.source=Object.freeze({...t}),this.denotations=this.#$i(t.denotations||[]),this.config=this.source.config}generate(){const t=this.source.text;if(!t)throw new eb('The "text" key is missing.');const e=(new JO).validateDenotations(this.denotations,t.length),i=(new ib).validateRelations(this.source.relations||[]);return[this.#Ci(t,e,i),this.#Ti()].filter(Boolean).join("\n\n")}#$i(t){return t.map(t=>new KO(t.span.begin,t.span.end,t.obj,t.id||null))}#Ci(t,e,i){return e.sort((t,e)=>e.beginPos-t.beginPos).forEach(e=>{const n=e.beginPos,s=e.endPos,o=e.id?this.#Pi(e,i):this.#Ei(e.obj),r=`[${t.slice(n,s)}][${o}]`;t=t.slice(0,n)+r+t.slice(s)}),t}#Ti(){const t=this.#Ai();return t&&0!==t.length?t.map(t=>`[${t.label}]: ${t.id}`).join("\n"):null}#Ai(){return this.config&&this.config["entity types"]?.filter(t=>t.hasOwnProperty("label"))||null}#Pi(t,e){const i=e.find(e=>e.subj===t.id)||null,n=[t.id,t.obj,i?.pred,i?.obj];if(!this.#Ai())return n.filter(t=>null!=t).join(", ");n[1]=this.#Ei(t.obj);this.#Ai().find(e=>e.id===t.obj);return n.filter(t=>null!=t).join(", ")}#Ei(t){if(!this.#Ai())return t;const e=this.#Ai().find(e=>e.id===t);return e?e.label:t}},sb=/^\s*\[([^\]]+)\]:\s+(\S+)(?:\s+(?:"[^"]*"|'[^']*'))?\s*$/,ob=new RegExp(`(?:\\A|\\n\\s*\\n)((?:${sb.source}(?:\\n|$))+)`,"gm");const rb=class{#Mi;#Qi=null;constructor(t){this.#Mi=t}get(t){return this.#Di[t]}get config(){return Object.entries(this.#Di).map(([t,e])=>({id:e,label:t}))}get#Di(){return this.#Qi||(this.#Qi=this.#Ri()),this.#Qi}#Ri(){const t={},e=Array.from(this.#Mi.matchAll(ob));for(const i of e)this.#Ii(i,t);return t}#Ii(t,e){const i=t[0].split("\n");for(const t of i)this.#Li(t,e)}#Li(t,e){const i=t.trim().match(sb);if(!i)return;const[n,s,o]=i;s!==o&&(e[s]||(e[s]=o))}},ab=new RegExp(`(?:\\A|\\n\\s*\\n)((?:${/^\s*\[([^\]]+)\]:\s+(\S+)(?:\s+(?:"[^"]*"|'[^']*'))?\s*$/.source}(?:\\n|$))+)`,"gm"),lb=/(?<!\\)\[([^\[]+?)\]\[([^\]]+?)\]/;const cb=class{#Mi;#D;#Ni;#ji;constructor(t){this.#Mi=t,this.#Ni=new rb(t)}parse(){this.#D=[],this.#ji=[];let t=this.#zi();return t=this.#Bi(t),new ub(t,this.#D,this.#ji,this.#Ni)}#zi(){return this.#Mi.replace(ab,t=>t.startsWith("\n\n")?"\n\n":"").trim()}#qi(t){return this.#Ni.get(t)||t}#Bi(t){const e=new RegExp(lb,"g");let i;for(;null!==(i=e.exec(t));){const n=i[1],s=i.index,o=s+n.length,r=i[2].split(", ");switch(r.length){case 1:this.#Zi(s,o,r[0]);break;case 2:this.#Fi(s,o,r);break;case 4:this.#Xi(s,o,r);break;default:e.lastIndex=i.index+i[0].length;continue}t=t.slice(0,i.index)+n+t.slice(i.index+i[0].length),e.lastIndex=o}return t}#Zi(t,e,i){const n=this.#qi(i);this.#D.push(new KO(t,e,n))}#Fi(t,e,i){const[n,s]=i,o=this.#qi(s);this.#D.push(new KO(t,e,o,n))}#Xi(t,e,i){const[n,s,o,r]=i,a=this.#qi(s);this.#D.push(new KO(t,e,a,n)),this.#ji.push({pred:o,subj:n,obj:r})}},hb=/\\(?=\[[^\]]+\]\[[^\]]+\])/;const ub=class{#re;#D;#ji;#Ni;constructor(t,e,i,n){this.#re=t,this.#D=e,this.#ji=i,this.#Ni=n}static parse(t){return new cb(t).parse().toObject()}static generate(t){return new nb(t).generate()}toObject(){const t={text:this.#Hi(this.#re),denotations:this.#D.map(t=>t.toObject())};this.#ji&&this.#ji.length>0&&(t.relations=this.#ji);const e=this.#Wi();return e&&Object.keys(e).length>0&&!Object.values(e).every(t=>null==t||Array.isArray(t)&&0===t.length)&&(t.config=e),t}#Hi(t){let e=this.#Vi(t);return this.#Yi(e)}#Vi(t){return t.replace(hb,"")}#Yi(t){return t.replace(/\n{2,}/g,"\n\n")}#Wi(){return this.#Ni&&0!==this.#Ni.length?{"entity types":this.#Ni.config}:null}};function db(t,e){if("json"===e)return GO(t);if("inline"===e){const e=ub.generate(t),i=new Blob([e],{type:"text/plain;charset=utf-8"});return URL.createObjectURL(i)}}function fb(t,e,i,n){t.preventDefault();!function(t,e){const i=document.createElement("a");i.setAttribute("href",t),i.setAttribute("download",e),document.body.appendChild(i),i.click(),document.body.removeChild(i)}(db(e,i),t.target.previousElementSibling.value),n.emit("textae-event.resource.annotation.save",e)}function pb(t,i,n,s,o,a){r()(i,".textae-editor__save-dialog__url-text","input",t=>{wn(t.target.nextElementSibling,t.target.value)}),r()(i,".textae-editor__save-dialog__url-text","keyup",t=>{if(13===t.keyCode){const e=a();o(t.target.value,e),s()}}),r()(i,".textae-editor__save-dialog__url-button","click",t=>{const e=a();o(t.target.previousElementSibling.value,e),s()}),r()(i,".textae-editor__save-dialog__download-link","click",i=>{const o=a();try{fb(i,n,o,t)}catch(t){e().error(`Failed to download the source as ${o} format.`)}finally{s()}}),r()(i,".textae-editor__save-dialog__viewsource-link","click",()=>{const i=a();try{!function(t,e,i){const n=db(t,e);window.open(n,"_blank"),i.emit("textae-event.resource.annotation.save",t)}(n,i,t)}catch(t){e().error(`Failed to view the source as ${i} format.`)}finally{s()}})}class mb extends u{constructor(t,e,i,n,s){super("Save Annotations",function(t){const{url:e,filename:i}=t;return`\n<div class="textae-editor__save-dialog__container">\n <div class="textae-editor__save-dialog__row">\n <span>Format</span>\n <div class="textae-editor__save-dialog__format">\n <label class="textae-editor__save-dialog__format-button">\n <input type="radio" name="format" value="json" checked>JSON\n </label>\n <label class="textae-editor__save-dialog__format-button">\n <input type="radio" name="format" value="inline">Text\n </label>\n </div>\n </div>\n <div class="textae-editor__save-dialog__row">\n <label>URL</label>\n <input\n type="text"\n value="${e}"\n class="textae-editor__save-dialog__url-text">\n <input\n type="button"\n class="textae-editor__save-dialog__url-button"\n ${e?"":'disabled="disabled"'}\n value="Save">\n </div>\n <div class="textae-editor__save-dialog__row">\n <label>Local</label>\n <input\n type="text"\n value="${i||""}"\n >\n <a class="textae-editor__save-dialog__download-link" href="#">Download</a>\n </div>\n <div class="textae-editor__save-dialog__row">\n <a class="textae-editor__save-dialog__viewsource-link" href="#">Click to see the source in a new window.</a>\n </div>\n</div>\n`}({filename:i,url:e})),pb(t,super.el,n,()=>super.close(),s,()=>super.el.querySelector('input[name="format"]:checked').value)}}function gb(t,e){if(t.length<2)throw new Error(e||"Expected an array with at least 2 items")}const vb=class{format(t,e){const i={};this.prepareContext(i);const n=i;return this.recurse(n,t,e),this.finalize(n)}prepareContext(t){t.buffer=[],t.out=function(...t){if(!this.buffer)throw new Error("context buffer is not initialized");this.buffer.push(...t)}}typeFormattterNotFound(t,e){throw new Error(`cannot format delta type: ${e}`)}typeFormattterErrorFormatter(t,e,i,n,s,o,r){}finalize({buffer:t}){return Array.isArray(t)?t.join(""):""}recurse(t,e,i,n,s,o,r){const a=e&&o?o.value:i;if(void 0===e&&void 0===n)return;const l=this.getDeltaType(e,o),c="node"===l?"a"===e._t?"array":"object":"";let h;void 0!==n?this.nodeBegin(t,n,s,l,c,null!=r&&r):this.rootBegin(t,l,c);try{h="unknown"!==l?this[`format_${l}`]:this.typeFormattterNotFound(t,l),h.call(this,t,e,a,n,s,o)}catch(i){this.typeFormattterErrorFormatter(t,i,e,a,n,s,o),"undefined"!=typeof console&&console.error&&console.error(i.stack)}void 0!==n?this.nodeEnd(t,n,s,l,c,null!=r&&r):this.rootEnd(t,l,c)}formatDeltaChildren(t,e,i){this.forEachDeltaKey(e,i,(n,s,o,r)=>{this.recurse(t,e[n],i?i[s]:void 0,n,s,o,r)})}forEachDeltaKey(t,e,i){const n=[];if(!("a"===t._t)){const s=Object.keys(t);"object"==typeof e&&null!==e&&n.push(...Object.keys(e));for(const t of s)n.indexOf(t)>=0||n.push(t);for(let t=0;t<n.length;t++){const e=n[t];if(void 0===e)continue;const s=t===n.length-1;i(e,e,void 0,s)}return}const s={};for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e)){const i=t[e];if(Array.isArray(i)&&3===i[2]){s[i[1]]=Number.parseInt(e.substring(1))}}const o=t;let r=0,a=0;const l=Array.isArray(e)?e:void 0,c=l?l.length:Object.keys(o).reduce((t,e)=>{if("_t"===e)return t;if("_"===e.substring(0,1)){const i=o[e],n=Number.parseInt(e.substring(1)),s=Array.isArray(i)&&i.length>=3&&3===i[2]?i[1]:void 0,r=Math.max(n,null!=s?s:0);return r>t?r:t}const i=Number.parseInt(e),n=s[i],r=Math.max(null!=n?n:0,null!=i?i:0);return r>t?r:t},0)+1;let h,u=c;const d=(...t)=>{h&&i(...h),h=t};for(;r<c||a<u||`${a}`in o;){let t=!1;const e=`_${r}`,i=`${a}`,n=a in s?s[a]:void 0;if(e in o){t=!0;const i=o[e];d(e,null!=n?n:r,n?{key:`_${n}`,value:l?l[n]:void 0}:void 0,!1),Array.isArray(i)?0===i[2]?(u--,r++):(i[2],r++):r++}if(i in o){t=!0;const e=o[i],s=Array.isArray(e)&&1===e.length;d(i,null!=n?n:r,n?{key:`_${n}`,value:l?l[n]:void 0}:void 0,!1),s?(u++,a++):void 0===n?(r++,a++):a++}t||((l&&void 0===n||!1!==this.includeMoveDestinations)&&d(i,null!=n?n:r,n?{key:`_${n}`,value:l?l[n]:void 0}:void 0,!1),void 0!==n||r++,a++)}h&&i(h[0],h[1],h[2],!0)}getDeltaType(t,e){if(void 0===t)return void 0!==e?"movedestination":"unchanged";if(Array.isArray(t)){if(1===t.length)return"added";if(2===t.length)return"modified";if(3===t.length&&0===t[2])return"deleted";if(3===t.length&&2===t[2])return"textdiff";if(3===t.length&&3===t[2])return"moved"}else if("object"==typeof t)return"node";return"unknown"}parseTextDiff(t){var e;const i=[],n=t.split("\n@@ ");for(const t of n){const n={pieces:[]},s=null===(e=/^(?:@@ )?[-+]?(\d+),(\d+)/.exec(t))||void 0===e?void 0:e.slice(1);if(!s)throw new Error("invalid text diff format");gb(s),n.location={line:s[0],chr:s[1]};const o=t.split("\n").slice(1);for(let t=0,e=o.length;t<e;t++){const e=o[t];if(void 0===e||!e.length)continue;const i={type:"context"};"+"===e.substring(0,1)?i.type="added":"-"===e.substring(0,1)&&(i.type="deleted"),i.text=e.slice(1),n.pieces.push(i)}i.push(n)}return i}};class yb extends vb{typeFormattterErrorFormatter(t,e){const i="object"==typeof e&&null!==e&&"message"in e&&"string"==typeof e.message?e.message:String(e);t.out(`<pre class="jsondiffpatch-error">${Ob(i)}</pre>`)}formatValue(t,e){const i=void 0===e?"undefined":Ob(JSON.stringify(e,null,2));t.out(`<pre>${i}</pre>`)}formatTextDiffString(t,e){const i=this.parseTextDiff(e);t.out('<ul class="jsondiffpatch-textdiff">');for(let e=0,n=i.length;e<n;e++){const n=i[e];if(void 0===n)return;t.out(`<li><div class="jsondiffpatch-textdiff-location"><span class="jsondiffpatch-textdiff-line-number">${n.location.line}</span><span class="jsondiffpatch-textdiff-char">${n.location.chr}</span></div><div class="jsondiffpatch-textdiff-line">`);const s=n.pieces;for(let e=0,i=s.length;e<i;e++){const i=s[e];if(void 0===i)return;t.out(`<span class="jsondiffpatch-textdiff-${i.type}">${Ob(decodeURI(i.text))}</span>`)}t.out("</div></li>")}t.out("</ul>")}rootBegin(t,e,i){const n=`jsondiffpatch-${e}${i?` jsondiffpatch-child-node-type-${i}`:""}`;t.out(`<div class="jsondiffpatch-delta ${n}">`)}rootEnd(t){t.out("</div>"+(t.hasArrows?`<script type="text/javascript">setTimeout(${bb.toString()},10);<\/script>`:""))}nodeBegin(t,e,i,n,s){const o=`jsondiffpatch-${n}${s?` jsondiffpatch-child-node-type-${s}`:""}`,r="number"==typeof i&&"_"===e.substring(0,1)?e.substring(1):e;t.out(`<li class="${o}" data-key="${Ob(e)}"><div class="jsondiffpatch-property-name">${Ob(r)}</div>`)}nodeEnd(t){t.out("</li>")}format_unchanged(t,e,i){void 0!==i&&(t.out('<div class="jsondiffpatch-value">'),this.formatValue(t,i),t.out("</div>"))}format_movedestination(t,e,i){void 0!==i&&(t.out('<div class="jsondiffpatch-value">'),this.formatValue(t,i),t.out("</div>"))}format_node(t,e,i){const n="a"===e._t?"array":"object";t.out(`<ul class="jsondiffpatch-node jsondiffpatch-node-type-${n}">`),this.formatDeltaChildren(t,e,i),t.out("</ul>")}format_added(t,e){t.out('<div class="jsondiffpatch-value">'),this.formatValue(t,e[0]),t.out("</div>")}format_modified(t,e){t.out('<div class="jsondiffpatch-value jsondiffpatch-left-value">'),this.formatValue(t,e[0]),t.out('</div><div class="jsondiffpatch-value jsondiffpatch-right-value">'),this.formatValue(t,e[1]),t.out("</div>")}format_deleted(t,e){t.out('<div class="jsondiffpatch-value">'),this.formatValue(t,e[0]),t.out("</div>")}format_moved(t,e){t.out('<div class="jsondiffpatch-value">'),this.formatValue(t,e[0]),t.out(`</div><div class="jsondiffpatch-moved-destination">${e[1]}</div>`),t.out('<div class="jsondiffpatch-arrow" style="position: relative; left: -34px;">\n <svg width="30" height="60" style="position: absolute; display: none;">\n <defs>\n <marker id="markerArrow" markerWidth="8" markerHeight="8"\n refx="2" refy="4" stroke="#88f"\n orient="auto" markerUnits="userSpaceOnUse">\n <path d="M1,1 L1,7 L7,4 L1,1" style="fill: #339;" />\n </marker>\n </defs>\n <path d="M30,0 Q-10,25 26,50"\n style="stroke: #88f; stroke-width: 2px; fill: none; stroke-opacity: 0.5; marker-end: url(#markerArrow);"\n ></path>\n </svg>\n </div>'),t.hasArrows=!0}format_textdiff(t,e){t.out('<div class="jsondiffpatch-value">'),this.formatTextDiffString(t,e[0]),t.out("</div>")}}function Ob(t){if("number"==typeof t)return t;let e=String(t);const i=[[/&/g,"&amp;"],[/</g,"&lt;"],[/>/g,"&gt;"],[/'/g,"&apos;"],[/"/g,"&quot;"]];for(const t of i)e=e.replace(t[0],t[1]);return e}const bb=function(t){const e=t||document;((t,e,i)=>{const n=t.querySelectorAll(e);for(let t=0,e=n.length;t<e;t++)i(n[t])})(e,".jsondiffpatch-arrow",({parentNode:t,children:e,style:i})=>{const n=t,s=e[0],o=s.children[1];s.style.display="none";const r=n.querySelector(".jsondiffpatch-moved-destination");if(!(r instanceof HTMLElement))return;const a=(({textContent:t,innerText:e})=>t||e)(r),l=n.parentNode;if(!l)return;let c;if((({children:t},e)=>{for(let i=0,n=t.length;i<n;i++){const n=t[i];n&&e(n,i)}})(l,t=>{t.getAttribute("data-key")===a&&(c=t)}),c)try{const t=c.offsetTop-n.offsetTop;s.setAttribute("height",`${Math.abs(t)+6}`),i.top=`${-8+(t>0?0:t)}px`;const e=t>0?`M30,0 Q-10,${Math.round(t/2)} 26,${t-4}`:`M30,${-t} Q-10,${Math.round(-t/2)} 26,4`;o.setAttribute("d",e),s.style.display=""}catch(t){console.debug(`[jsondiffpatch] error adjusting arrows: ${t}`)}})},xb=(t,e)=>((t,e,i)=>{const n=e||document.body,s="jsondiffpatch-unchanged-",o={showing:`${s}showing`,hiding:`${s}hiding`,visible:`${s}visible`,hidden:`${s}hidden`},r=n.classList;if(!r)return;if(!i)return r.remove(o.showing),r.remove(o.hiding),r.remove(o.visible),r.remove(o.hidden),void(!1===t&&r.add(o.hidden));!1===t?(r.remove(o.showing),r.add(o.visible),setTimeout(()=>{r.add(o.hiding)},10)):(r.remove(o.hiding),r.add(o.showing),r.remove(o.hidden));const a=setInterval(()=>{bb(n)},100);setTimeout(()=>{r.remove(o.showing),r.remove(o.hiding),!1===t?(r.add(o.hidden),r.remove(o.visible)):(r.add(o.visible),r.remove(o.hidden)),setTimeout(()=>{r.remove(o.visible),clearInterval(a)},i+400)},i)})(!1,t,e);let wb;function _b(t){if("object"!=typeof t)return t;if(null===t)return null;if(Array.isArray(t))return t.map(_b);if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp)return function(t){var e;const i=/^\/(.*)\/([gimyu]*)$/.exec(t.toString());if(!i)throw new Error("Invalid RegExp");return new RegExp(null!==(e=i[1])&&void 0!==e?e:"",i[2])}(t);const e={};for(const i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=_b(t[i]));return e}class Sb{setResult(t){return this.result=t,this.hasResult=!0,this}exit(){return this.exiting=!0,this}push(t,e){var i;return t.parent=this,void 0!==e&&(t.childName=e),t.root=this.root||this,t.options=t.options||this.options,this.children?(!function(t,e){if(0===t.length)throw new Error(e||"Expected a non-empty array")}(this.children),(i=this.children,i[i.length-1]).next=t,this.children.push(t)):(this.children=[t],this.nextAfterChildren=this.next||null,this.next=t),t.next=this,this}}const kb=class extends Sb{constructor(t,e){super(),this.left=t,this.right=e,this.pipe="diff"}prepareDeltaResult(t){var e,i,n,s;if("object"==typeof t&&((null===(e=this.options)||void 0===e?void 0:e.omitRemovedValues)&&Array.isArray(t)&&t.length>1&&(2===t.length||0===t[2]||3===t[2])&&(t[0]=0),null===(i=this.options)||void 0===i?void 0:i.cloneDiffValues)){const e="function"==typeof(null===(n=this.options)||void 0===n?void 0:n.cloneDiffValues)?null===(s=this.options)||void 0===s?void 0:s.cloneDiffValues:_b;"object"==typeof t[0]&&(t[0]=e(t[0])),"object"==typeof t[1]&&(t[1]=e(t[1]))}return t}setResult(t){return this.prepareDeltaResult(t),super.setResult(t)}};const $b=class extends Sb{constructor(t,e){super(),this.left=t,this.delta=e,this.pipe="patch"}};const Cb=class extends Sb{constructor(t){super(),this.delta=t,this.pipe="reverse"}};const Tb=class{constructor(t){this.name=t,this.filters=[]}process(t){if(!this.processor)throw new Error("add this pipe to a processor before using it");const e=this.debug,i=this.filters.length,n=t;for(let t=0;t<i;t++){const i=this.filters[t];if(i&&(e&&this.log(`filter: ${i.filterName}`),i(n),"object"==typeof n&&n.exiting)){n.exiting=!1;break}}!n.next&&this.resultCheck&&this.resultCheck(n)}log(t){console.log(`[jsondiffpatch] ${this.name} pipe, ${t}`)}append(...t){return this.filters.push(...t),this}prepend(...t){return this.filters.unshift(...t),this}indexOf(t){if(!t)throw new Error("a filter name is required");for(let e=0;e<this.filters.length;e++){const i=this.filters[e];if((null==i?void 0:i.filterName)===t)return e}throw new Error(`filter not found: ${t}`)}list(){return this.filters.map(t=>t.filterName)}after(t,...e){const i=this.indexOf(t);return this.filters.splice(i+1,0,...e),this}before(t,...e){const i=this.indexOf(t);return this.filters.splice(i,0,...e),this}replace(t,...e){const i=this.indexOf(t);return this.filters.splice(i,1,...e),this}remove(t){const e=this.indexOf(t);return this.filters.splice(e,1),this}clear(){return this.filters.length=0,this}shouldHaveResult(t){return!1===t?(this.resultCheck=null,this):(this.resultCheck||(this.resultCheck=t=>{if(!t.hasResult){console.log(t);const e=new Error(`${this.name} failed`);throw e.noResult=!0,e}}),this)}};const Pb=class{constructor(t){this.selfOptions=t||{},this.pipes={}}options(t){return t&&(this.selfOptions=t),this.selfOptions}pipe(t,e){let i=e;if("string"==typeof t){if(void 0===i)return this.pipes[t];this.pipes[t]=i}if(t&&t.name){if(i=t,i.processor===this)return i;this.pipes[i.name]=i}if(!i)throw new Error(`pipe is not defined: ${t}`);return i.processor=this,i}process(t,e){let i=t;i.options=this.options();let n,s=e||t.pipe||"default";for(;s;)void 0!==i.nextAfterChildren&&(i.next=i.nextAfterChildren,i.nextAfterChildren=null),"string"==typeof s&&(s=this.pipe(s)),s.process(i),n=s,s=null,i&&i.next&&(i=i.next,s=i.pipe||n);return i.hasResult?i.result:void 0}},Eb=(t,e,i,n)=>t[i]===e[n],Ab=(t,e,i,n)=>{const s=n||{},o=((t,e,i,n)=>{var s,o,r;const a=t.length,l=e.length;let c,h;const u=new Array(a+1);for(c=0;c<a+1;c++){const t=new Array(l+1);for(h=0;h<l+1;h++)t[h]=0;u[c]=t}for(u.match=i,c=1;c<a+1;c++){const a=u[c];if(void 0===a)throw new Error("LCS matrix row is undefined");const d=u[c-1];if(void 0===d)throw new Error("LCS matrix row is undefined");for(h=1;h<l+1;h++)i(t,e,c-1,h-1,n)?a[h]=(null!==(s=d[h-1])&&void 0!==s?s:0)+1:a[h]=Math.max(null!==(o=d[h])&&void 0!==o?o:0,null!==(r=a[h-1])&&void 0!==r?r:0)}return u})(t,e,i||Eb,s);return((t,e,i,n)=>{let s=e.length,o=i.length;const r={sequence:[],indices1:[],indices2:[]};for(;0!==s&&0!==o;){if(void 0===t.match)throw new Error("LCS matrix match function is undefined");if(t.match(e,i,s-1,o-1,n))r.sequence.unshift(e[s-1]),r.indices1.unshift(s-1),r.indices2.unshift(o-1),--s,--o;else{const e=t[s];if(void 0===e)throw new Error("LCS matrix row is undefined");const i=e[o-1];if(void 0===i)throw new Error("LCS matrix value is undefined");const n=t[s-1];if(void 0===n)throw new Error("LCS matrix row is undefined");const r=n[o];if(void 0===r)throw new Error("LCS matrix value is undefined");i>r?--o:--s}}return r})(o,t,e,s)};function Mb(t,e,i,n,s){const o=t[i],r=e[n];if(o===r)return!0;if("object"!=typeof o||"object"!=typeof r)return!1;const a=s.objectHash;if(!a)return s.matchByPosition&&i===n;s.hashCache1=s.hashCache1||[];let l=s.hashCache1[i];if(void 0===l&&(s.hashCache1[i]=l=a(o,i)),void 0===l)return!1;s.hashCache2=s.hashCache2||[];let c=s.hashCache2[n];return void 0===c&&(s.hashCache2[n]=c=a(r,n)),void 0!==c&&l===c}const Qb=function(t){var e,i,n,s,o;if(!t.leftIsArray)return;const r={objectHash:null===(e=t.options)||void 0===e?void 0:e.objectHash,matchByPosition:null===(i=t.options)||void 0===i?void 0:i.matchByPosition};let a,l,c,h=0,u=0;const d=t.left,f=t.right,p=d.length,m=f.length;let g,v;for(p>0&&m>0&&!r.objectHash&&"boolean"!=typeof r.matchByPosition&&(r.matchByPosition=!function(t,e,i,n){for(let s=0;s<i;s++){const i=t[s];for(let t=0;t<n;t++){const n=e[t];if(s!==t&&i===n)return!0}}return!1}(d,f,p,m));h<p&&h<m&&Mb(d,f,h,h,r);)a=h,g=new kb(d[a],f[a]),t.push(g,a),h++;for(;u+h<p&&u+h<m&&Mb(d,f,p-1-u,m-1-u,r);)l=p-1-u,c=m-1-u,g=new kb(d[l],f[c]),t.push(g,c),u++;if(h+u===p){if(p===m)return void t.setResult(void 0).exit();for(v=v||{_t:"a"},a=h;a<m-u;a++)v[a]=[f[a]],t.prepareDeltaResult(v[a]);return void t.setResult(v).exit()}if(h+u===m){for(v=v||{_t:"a"},a=h;a<p-u;a++){const e=`_${a}`;v[e]=[d[a],0,0],t.prepareDeltaResult(v[e])}return void t.setResult(v).exit()}r.hashCache1=void 0,r.hashCache2=void 0;const y=d.slice(h,p-u),O=f.slice(h,m-u),b=Ab(y,O,Mb,r),x=[];for(v=v||{_t:"a"},a=h;a<p-u;a++)if(b.indices1.indexOf(a-h)<0){const e=`_${a}`;v[e]=[d[a],0,0],t.prepareDeltaResult(v[e]),x.push(a)}let w=!0;(null===(n=t.options)||void 0===n?void 0:n.arrays)&&!1===t.options.arrays.detectMove&&(w=!1);let _=!1;(null===(o=null===(s=t.options)||void 0===s?void 0:s.arrays)||void 0===o?void 0:o.includeValueOnMove)&&(_=!0);const S=x.length;for(a=h;a<m-u;a++){const e=b.indices2.indexOf(a-h);if(e<0){let e=!1;if(w&&S>0)for(let i=0;i<S;i++){l=x[i];const n=void 0===l?void 0:v[`_${l}`];if(void 0!==l&&n&&Mb(y,O,l-h,a-h,r)){n.splice(1,2,a,3),n.splice(1,2,a,3),_||(n[0]=""),c=a,g=new kb(d[l],f[c]),t.push(g,c),x.splice(i,1),e=!0;break}}e||(v[a]=[f[a]],t.prepareDeltaResult(v[a]))}else{if(void 0===b.indices1[e])throw new Error(`Invalid indexOnArray2: ${e}, seq.indices1: ${b.indices1}`);if(l=b.indices1[e]+h,void 0===b.indices2[e])throw new Error(`Invalid indexOnArray2: ${e}, seq.indices2: ${b.indices2}`);c=b.indices2[e]+h,g=new kb(d[l],f[c]),t.push(g,c)}}t.setResult(v).exit()};Qb.filterName="arrays";const Db={numerically:(t,e)=>t-e,numericallyBy:t=>(e,i)=>e[t]-i[t]},Rb=function(t){var e;if(!t.nested)return;const i=t.delta;if("a"!==i._t)return;let n,s;const o=i,r=t.left;let a=[],l=[];const c=[];for(n in o)if("_t"!==n)if("_"===n[0]){const t=n;if(void 0===o[t]||0!==o[t][2]&&3!==o[t][2])throw new Error(`only removal or move can be applied at original array indices, invalid diff type: ${null===(e=o[t])||void 0===e?void 0:e[2]}`);a.push(Number.parseInt(n.slice(1),10))}else{const t=n;1===o[t].length?l.push({index:Number.parseInt(t,10),value:o[t][0]}):c.push({index:Number.parseInt(t,10),delta:o[t]})}for(a=a.sort(Db.numerically),n=a.length-1;n>=0;n--){if(s=a[n],void 0===s)continue;const t=o[`_${s}`],e=r.splice(s,1)[0];3===(null==t?void 0:t[2])&&l.push({index:t[1],value:e})}l=l.sort(Db.numericallyBy("index"));const h=l.length;for(n=0;n<h;n++){const t=l[n];void 0!==t&&r.splice(t.index,0,t.value)}const u=c.length;if(u>0)for(n=0;n<u;n++){const e=c[n];if(void 0===e)continue;const i=new $b(r[e.index],e.delta);t.push(i,e.index)}t.children?t.exit():t.setResult(r).exit()};Rb.filterName="arrays";const Ib=function(t){if(!t||!t.children)return;if("a"!==t.delta._t)return;const e=t.left,i=t.children.length;for(let n=0;n<i;n++){const i=t.children[n];if(void 0===i)continue;e[i.childName]=i.result}t.setResult(e).exit()};Ib.filterName="arraysCollectChildren";const Lb=function(t){if(!t.nested){const e=t.delta;if(3===e[2]){const i=e;t.newName=`_${i[1]}`,t.setResult([i[0],Number.parseInt(t.childName.substring(1),10),3]).exit()}return}const e=t.delta;if("a"!==e._t)return;const i=e;for(const e in i){if("_t"===e)continue;const n=new Cb(i[e]);t.push(n,e)}t.exit()};Lb.filterName="arrays";const Nb=(t,e,i)=>{if("string"==typeof e&&"_"===e[0])return Number.parseInt(e.substring(1),10);if(Array.isArray(i)&&0===i[2])return`_${e}`;let n=+e;for(const i in t){const s=t[i];if(Array.isArray(s))if(3===s[2]){const t=Number.parseInt(i.substring(1),10),o=s[1];if(o===+e)return t;t<=n&&o>n?n++:t>=n&&o<n&&n--}else if(0===s[2]){Number.parseInt(i.substring(1),10)<=n&&n++}else 1===s.length&&Number.parseInt(i,10)<=n&&n--}return n},jb=t=>{if(!t||!t.children)return;const e=t.delta;if("a"!==e._t)return;const i=e,n=t.children.length,s={_t:"a"};for(let e=0;e<n;e++){const n=t.children[e];if(void 0===n)continue;let o=n.newName;if(void 0===o){if(void 0===n.childName)throw new Error("child.childName is undefined");o=Nb(i,n.childName,n.result)}s[o]!==n.result&&(s[o]=n.result)}t.setResult(s).exit()};jb.filterName="arraysCollectChildren";const zb=function(t){t.left instanceof Date?(t.right instanceof Date?t.left.getTime()!==t.right.getTime()?t.setResult([t.left,t.right]):t.setResult(void 0):t.setResult([t.left,t.right]),t.exit()):t.right instanceof Date&&t.setResult([t.left,t.right]).exit()};zb.filterName="dates";const Bb=t=>{if(!t||!t.children)return;const e=t.children.length;let i=t.result;for(let n=0;n<e;n++){const e=t.children[n];if(void 0!==e&&void 0!==e.result){if(i=i||{},void 0===e.childName)throw new Error("diff child.childName is undefined");i[e.childName]=e.result}}i&&t.leftIsArray&&(i._t="a"),t.setResult(i).exit()};Bb.filterName="collectChildren";const qb=t=>{var e;if(t.leftIsArray||"object"!==t.leftType)return;const i=t.left,n=t.right,s=null===(e=t.options)||void 0===e?void 0:e.propertyFilter;for(const e in i){if(!Object.prototype.hasOwnProperty.call(i,e))continue;if(s&&!s(e,t))continue;const o=new kb(i[e],n[e]);t.push(o,e)}for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e)&&(!s||s(e,t))&&void 0===i[e]){const i=new kb(void 0,n[e]);t.push(i,e)}t.children&&0!==t.children.length?t.exit():t.setResult(void 0).exit()};qb.filterName="objects";const Zb=function(t){if(!t.nested)return;const e=t.delta;if(e._t)return;const i=e;for(const e in i){const n=new $b(t.left[e],i[e]);t.push(n,e)}t.exit()};Zb.filterName="objects";const Fb=function(t){if(!t||!t.children)return;if(t.delta._t)return;const e=t.left,i=t.children.length;for(let n=0;n<i;n++){const i=t.children[n];if(void 0===i)continue;const s=i.childName;Object.prototype.hasOwnProperty.call(t.left,s)&&void 0===i.result?delete e[s]:e[s]!==i.result&&(e[s]=i.result)}t.setResult(e).exit()};Fb.filterName="collectChildren";const Xb=function(t){if(!t.nested)return;if(t.delta._t)return;const e=t.delta;for(const i in e){const n=new Cb(e[i]);t.push(n,i)}t.exit()};Xb.filterName="objects";const Hb=t=>{if(!t||!t.children)return;if(t.delta._t)return;const e=t.children.length,i={};for(let n=0;n<e;n++){const e=t.children[n];if(void 0===e)continue;const s=e.childName;i[s]!==e.result&&(i[s]=e.result)}t.setResult(i).exit()};Hb.filterName="collectChildren";let Wb=null;function Vb(t,e){var i;if(!Wb){let n;if(!(null===(i=null==t?void 0:t.textDiff)||void 0===i?void 0:i.diffMatchPatch)){if(!e)return null;const t=new Error("The diff-match-patch library was not provided. Pass the library in through the options or use the `jsondiffpatch/with-text-diffs` entry-point.");throw t.diff_match_patch_not_found=!0,t}n=new t.textDiff.diffMatchPatch,Wb={diff:(t,e)=>n.patch_toText(n.patch_make(t,e)),patch:(t,e)=>{const i=n.patch_apply(n.patch_fromText(e),t);for(const t of i[1])if(!t){const t=new Error("text patch failed");throw t.textPatchFailed=!0,t}return i[0]}}}return Wb}const Yb=function(t){var e,i;if("string"!==t.leftType)return;const n=t.left,s=t.right,o=(null===(i=null===(e=t.options)||void 0===e?void 0:e.textDiff)||void 0===i?void 0:i.minLength)||60;if(n.length<o||s.length<o)return void t.setResult([n,s]).exit();const r=Vb(t.options);if(!r)return void t.setResult([n,s]).exit();const a=r.diff;t.setResult([a(n,s),0,2]).exit()};Yb.filterName="texts";const Ub=function(t){if(t.nested)return;const e=t.delta;if(2!==e[2])return;const i=e,n=Vb(t.options,!0).patch;t.setResult(n(t.left,i[0])).exit()};Ub.filterName="texts";const Gb=t=>{var e,i,n;const s=/^@@ +-(\d+),(\d+) +\+(\d+),(\d+) +@@$/,o=t.split("\n");for(let t=0;t<o.length;t++){const r=o[t];if(void 0===r)continue;const a=r.slice(0,1);if("@"===a){const e=s.exec(r);if(null!==e){o[t]=`@@ -${e[3]},${e[4]} +${e[1]},${e[2]} @@`}}else if("+"===a){if(o[t]=`-${null===(e=o[t])||void 0===e?void 0:e.slice(1)}`,"+"===(null===(i=o[t-1])||void 0===i?void 0:i.slice(0,1))){const e=o[t];o[t]=o[t-1],o[t-1]=e}}else"-"===a&&(o[t]=`+${null===(n=o[t])||void 0===n?void 0:n.slice(1)}`)}return o.join("\n")},Kb=function(t){if(t.nested)return;const e=t.delta;if(2!==e[2])return;const i=e;t.setResult([Gb(i[0]),0,2]).exit()};Kb.filterName="texts";const Jb=function(t){if(t.left!==t.right)if(void 0!==t.left)if(void 0!==t.right){if("function"==typeof t.left||"function"==typeof t.right)throw new Error("functions are not supported");t.leftType=null===t.left?"null":typeof t.left,t.rightType=null===t.right?"null":typeof t.right,t.leftType===t.rightType&&"boolean"!==t.leftType&&"number"!==t.leftType?("object"===t.leftType&&(t.leftIsArray=Array.isArray(t.left)),"object"===t.rightType&&(t.rightIsArray=Array.isArray(t.right)),t.leftIsArray===t.rightIsArray?t.left instanceof RegExp&&(t.right instanceof RegExp?t.setResult([t.left.toString(),t.right.toString()]).exit():t.setResult([t.left,t.right]).exit()):t.setResult([t.left,t.right]).exit()):t.setResult([t.left,t.right]).exit()}else t.setResult([t.left,0,0]).exit();else{if("function"==typeof t.right)throw new Error("functions are not supported");t.setResult([t.right]).exit()}else t.setResult(void 0).exit()};Jb.filterName="trivial";const tx=function(t){if(void 0===t.delta)return void t.setResult(t.left).exit();if(t.nested=!Array.isArray(t.delta),t.nested)return;const e=t.delta;if(1!==e.length)if(2!==e.length)3===e.length&&0===e[2]&&t.setResult(void 0).exit();else{if(t.left instanceof RegExp){const i=/^\/(.*)\/([gimyu]+)$/.exec(e[1]);if(null==i?void 0:i[1])return void t.setResult(new RegExp(i[1],i[2])).exit()}t.setResult(e[1]).exit()}else t.setResult(e[0]).exit()};tx.filterName="trivial";const ex=function(t){if(void 0===t.delta)return void t.setResult(t.delta).exit();if(t.nested=!Array.isArray(t.delta),t.nested)return;const e=t.delta;1!==e.length?2!==e.length?3===e.length&&0===e[2]&&t.setResult([e[0]]).exit():t.setResult([e[1],e[0]]).exit():t.setResult([e[0],0,0]).exit()};ex.filterName="trivial";const ix=class{constructor(t){this.processor=new Pb(t),this.processor.pipe(new Tb("diff").append(Bb,Jb,zb,Yb,qb,Qb).shouldHaveResult()),this.processor.pipe(new Tb("patch").append(Fb,Ib,tx,Ub,Zb,Rb).shouldHaveResult()),this.processor.pipe(new Tb("reverse").append(Hb,jb,ex,Kb,Xb,Lb).shouldHaveResult())}options(t){return this.processor.options(t)}diff(t,e){return this.processor.process(new kb(t,e))}patch(t,e){return this.processor.process(new $b(t,e))}reverse(t){return this.processor.process(new Cb(t))}unpatch(t,e){return this.patch(t,this.reverse(e))}clone(t){return _b(t)}};let nx;function sx(t,e){return nx||(nx=new ix),nx.diff(t,e)}const ox=new ix({objectHash:(t,e)=>t.id||`$$index:${e}`});function rx(t,e){return function(t,e){return wb||(wb=new yb),wb.format(t,e)}(ox.diff(t,e),t)}class ax extends u{constructor(t,e,i,n,s,o){super("Save Configurations",function(t){const{url:e,filename:i,diff:n}=t;return`\n<div class="textae-editor__save-dialog__container">\n <div class="textae-editor__save-dialog__row">\n <label>URL</label>\n <input\n type="text" value="${e}"\n class="textae-editor__save-dialog__url-text">\n <input\n type="button"\n class="textae-editor__save-dialog__url-button"\n ${e?"":'disabled="disabled"'}\n value="Save">\n </div>\n <div class="textae-editor__save-dialog__row">\n <label>Local</label>\n <input\n type="text" value="${i||""}"\n >\n <a class="textae-editor__save-dialog__download-link" href="#">Download</a>\n </div>\n <div class="textae-editor__save-dialog__row">\n <div class="textae-editor__save-dialog__diff-title">\n Configuration differences\n <span class="textae-editor__save-dialog__diff-add-legend">added</span>\n <span class="textae-editor__save-dialog__diff-remove-legend">removed</span>\n </div>\n <div class="textae-editor__save-dialog__diff-viewer">${n}</div>\n </div>\n</div>\n`}({filename:i,url:e,diff:rx(n,s)||"nothing."}),{maxWidth:550}),this._$dialog.on("dialogopen",()=>xb()),function(t,e,i,n,s){r()(e,".textae-editor__save-dialog__url-text","input",t=>{wn(t.target.nextElementSibling,t.target.value)}),r()(e,".textae-editor__save-dialog__url-text","keyup",t=>{13===t.keyCode&&(s(t.target.value),n())}),r()(e,".textae-editor__save-dialog__url-button","click",t=>{s(t.target.previousElementSibling.value),n()}),r()(e,".textae-editor__save-dialog__download-link","click",e=>{const s=e.target,o=GO(i);s.setAttribute("href",o),s.setAttribute("download",s.previousElementSibling.value),t.emit("textae-event.resource.configuration.save",i),n()})}(t,super.el,s,()=>super.close(),o)}}async function lx(t){return new Promise(e=>{const i=new FileReader;i.onload=t=>e(t),i.readAsText(t)})}var cx=i(7975),hx=i.n(cx);const ux=Object.freeze({QUERY_PARAMETER:"parameter",INLINE:"inline",REMOTE_URL:"remote",INSTANT:"instant",LOCAL_FILE:"local file",UNKNOWN:"unknown"});class dx{#Ui;#H;#Gi;static createURLSource(t,e){return console.assert("string"==typeof t,"id must be a string when type is url."),new dx(ux.REMOTE_URL,t,e)}static createFileSource(t,e){return console.assert("string"==typeof t,"id must be a string when type is local file."),new dx(ux.LOCAL_FILE,t,e)}static createInstantSource(t){return new dx(ux.INSTANT,null,t)}static createInlineSource(t){return new dx(ux.INLINE,null,t)}static createParameterSource(t){return new dx(ux.QUERY_PARAMETER,null,t)}constructor(t,e,i){console.assert(Object.values(ux).includes(t),`type must be a member of RESOURCE_TYPE. type: ${t}`),t===ux.REMOTE_URL||t===ux.LOCAL_FILE?console.assert("string"==typeof e,"id must be a string when type is url or local file."):console.assert(null===e,"id must be null when type is not url."),this.#Ui=t,this.#H=e,this.#Gi=i}get resourceType(){return this.#Ui}get id(){return this.#H}get data(){return this.#Gi}get displayName(){switch(this.#Ui){case ux.REMOTE_URL:return new URL(this.#H,location.href).href;case ux.LOCAL_FILE:return`${this.#H}(local file)`;default:return`${this.#Ui}`}}}async function fx(t,i){const n=(await lx(t)).target.result;if(s=t.name,".txt"===hx().extname(s)){const s=function(t){try{return ub.parse(t)}catch{return null}}(n);if(!s){const i=dx.createFileSource(t.name);return void e().error(`Failed to load annotation from ${i.displayName}.`)}if(s.text)return void i.emit("textae-event.resource.annotation.load.success",dx.createFileSource(t.name,s))}var s;if(_n(n)){const e=JSON.parse(n);if(e.text)return void i.emit("textae-event.resource.annotation.load.success",dx.createFileSource(t.name,e))}i.emit("textae-event.resource.annotation.format.error",dx.createFileSource(t.name))}function px(t,e){return!!e.text&&(t.emit("textae-event.resource.annotation.load.success",dx.createInstantSource(e)),!0)}class mx{#Ki;#Ji;constructor(t){t.on("textae-event.original-data.annotation.reset",t=>{t.resourceType===ux.REMOTE_URL&&(this.#Ki=t.id)}).on("textae-event.original-data.configuration.reset",t=>{t.resourceType===ux.REMOTE_URL&&(this.#Ji=t.id)})}get annotation(){return this.#Ki||""}get configuration(){return this.#Ji||""}}class gx{#Ki;#Ji;constructor(t){t.on("textae-event.original-data.annotation.reset",t=>{t.resourceType===ux.LOCAL_FILE&&(this.#Ki=t.id)}).on("textae-event.original-data.configuration.reset",t=>{t.resourceType===ux.LOCAL_FILE&&(this.#Ji=t.id)})}get annotation(){return this.#Ki}get configuration(){return this.#Ji}}class vx{#Nt;#tn;#Ht;#en;#in;#nn;#sn;#ii;#on;#rn;constructor(t,e,i,n,s,o,r,a){this.#Nt=t,this.#tn=e,this.#Ht=i,this.#en=n,this.#in=s,this.#nn=o,this.#sn=r,this.#ii=a,this.#on=new mx(t),this.#rn=new gx(t),t.on("textae-event.pallet.import-button.click",()=>this.importConfiguration()).on("textae-event.pallet.upload-button.click",()=>this.uploadConfiguration())}importAnnotation(){new YO("Load Annotations",this.#on.annotation,t=>this.#tn.loadAnnotation(t),t=>fx(t,this.#Nt),(t,i)=>function(t,i,n){if("json"===n)_n(i)?px(t,JSON.parse(i)):t.emit("textae-event.resource.annotation.format.error",dx.createInstantSource());else if("inline"===n)try{px(t,ub.parse(i))}catch{const t=dx.createInstantSource();e().error(`Failed to load annotation from ${t.displayName}.`)}}(this.#Nt,t,i),this.#sn.hasChange).open()}uploadAnnotation(){const t=this.#nn||this.#on.annotation||"https://pubannotatoin.org/annotations.json";new mb(this.#Nt,t,this.#rn.annotation,this.#an,(t,e)=>this.#tn.saveAnnotation(t,this.#an,e)).open()}saveAnnotation(){this.#tn.saveAnnotation(this.#nn||this.#on.annotation,this.#an,"json")}importConfiguration(){new UO("Load Configurations",this.#on.configuration,t=>this.#tn.loadConfiguration(t),t=>function(t,e){lx(t).then(({target:i})=>{_n(i.result)?e.emit("textae-event.resource.configuration.load.success",dx.createFileSource(t.name,JSON.parse(i.result))):e.emit("textae-event.resource.configuration.format.error",dx.createFileSource(t.name))})}(t,this.#Nt),t=>{_n(t)?this.#Nt.emit("textae-event.resource.configuration.load.success",dx.createInstantSource(JSON.parse(t))):this.#Nt.emit("textae-event.resource.configuration.format.error",dx.createInstantSource())},this.#ii.diffOfConfiguration).open()}uploadConfiguration(){const t={...this.#in(),...this.#Ht.typeDictionary.config};new ax(this.#Nt,this.#on.configuration,this.#rn.configuration,this.#in(),t,e=>this.#tn.saveConfiguration(e,t)).open()}get#an(){const t={...this.#en(),...this.#Ht.externalFormat,config:this.#Ht.typeDictionary.config};return delete t.tracks,t}}function yx(t,e,i,n,s,o){e.setPushButtons(t),i.set(t),n.reset(s,t),o.availability=t["function availability"]}function Ox(t){if(!0===t)return"flag";if("number"==typeof t)return"numeric";if("string"==typeof t)return"string";throw`${JSON.stringify(t)} is an unexpected value for an Attribute.`}function bx(t){const e=t.reduce((t,e)=>t.has(e)?t.set(e,t.get(e)+1):t.set(e,1),new Map),i=Math.max(...e.values());for(const[t,n]of e.entries())if(n===i)return t}function xx(t){const e=Math.max(...t.map(t=>{const[e,i]=String(t).split(".");return i?i.length:0}));return Number(Array.from(Array(e)).reduce((t,e)=>.1*t,1).toFixed(e))}class wx{constructor({pred:t,obj:e}){this._pred=t,this._objects=[e]}push(t){this._objects.push(t)}get definition(){switch(Ox(this._objects[0])){case"flag":return this._prototype;case"numeric":return this._numericAttribute;case"string":return this._stringAttribute;default:throw new Error(`prototype: ${JSON.stringify(this._prototype)}`)}}get mostFrequentObject(){return bx(this._objects)}get _prototype(){return{pred:this._pred,"value type":Ox(this._objects[0])}}get _numericAttribute(){return{min:Math.min(...this._objects),max:Math.max(...this._objects),step:xx(this._objects),default:bx(this._objects),...this._prototype}}get _stringAttribute(){return{default:bx(this._objects),...this._prototype}}}function _x(t){return t.reduce((t,e)=>(t.has(e.pred)?t.get(e.pred).push(e.obj):t.set(e.pred,new wx(e)),t),new Map)}function Sx(t,e){const i=function(t){return[..._x(t).values()].map(t=>t.definition)}(e);return function(t,e){for(const i of e){const e=t.findIndex(t=>t.pred===i.pred);-1!==e?t[e]={...i,...t[e]}:t.push(i)}return t}(t,i)}function kx(t){return t?JSON.parse(JSON.stringify(t)):{}}class $x{constructor(t=[],e=[]){this._annotations=e,this._config=t}get configuration(){let t=Sx(this._config,this._annotations);return t=function(t){t=kx(t);for(const e of t.filter(t=>"numeric"===t["value type"]))Object.prototype.hasOwnProperty.call(e,"default")||(e.default=0),Object.prototype.hasOwnProperty.call(e,"step")||(e.step=2);return t}(t),t=function(t,e){t=kx(t);const i=_x(e);for(const e of function(t){return t.filter(t=>"selection"===t["value type"])}(t))if(e.values&&0!==e.values.length)if(e.values.find(t=>!0===t.default));else if(i.has(e.pred)){const t=i.get(e.pred);e.values.find(e=>e.id===t.mostFrequentObject).default=!0}else e.values[0].default=!0;else e.values=[{id:"default",default:!0}];return t}(t,this._annotations),t}}function Cx(t,e){if(console.assert(t),(e=kx(e))["attribute types"]=new $x(e["attribute types"],t.attributes).configuration,t.tracks)for(const i of t.tracks)e["attribute types"]=new $x(e["attribute types"],i.attributes).configuration;return e}const Tx=new(on())({verbose:!0});an()(Tx,["uri-reference","regex"]);const Px=Tx.compile(ln);function Ex(t){return console.assert(t,"config is required."),Px(t)?null:(console.warn(Px.errors),function(t){for(const e of t){if("required"===e.keyword)return`Invalid configuration: The attribute type whose predicate is '${e.data.pred}' misses a mandatory property, '${e.params.missingProperty}'.`;if(e.instancePath.includes("color"))return ot`Invalid configuration: '${e.data}' is invalid color format.`}}(Px.errors))}function Ax(t,i){const n=function(t,e){if(console.assert(e,"If you don't have a configuration, generate a configuration from the annotation."),t.attributes){const i=e["attribute types"],n=t.attributes.filter(t=>i.some(e=>e.pred===t.pred&&"selection"===e["value type"])).filter(t=>!i.some(e=>e.pred===t.pred&&e.values.some(e=>e.id===t.obj)));if(n.length)return console.warn("selection attribute values without definition",n),`selection attribute value definition for "${n.map(t=>t.obj).join(", ")}" in configuration is missing. `}}(t,i);if(!n)return i;e().error(n)}function Mx(t,i){const n=Cx(t,i),s=Ex(n);if(!s)return Ax(t,n);e().error(s)}function Qx(t){(function(t){if(t.denotations)for(const e of t.denotations){if(e.span.begin!==parseInt(e.span.begin))return!0;if(e.span.end!==parseInt(e.span.end))return!0}})(t)&&e().warning("In the annotation file, some of the begin and end offsets of denotations were not integer values.\n TextAE converted them to integer values.\n However, to avoid a chance of unexpected rendering, please fix them.",15)}function Dx(t,i,n,s,o,r,a,l){if(!t.data.config&&i)n.loadConfiguration(i,t);else{if(Qx(t.data),t.data.config&&"object"!=typeof t.data.config)return void e().error("configuration in annotation file is invalid.");const i=Mx(t.data,t.data.config);i&&(yx(i,s,o,r,t.data,a),l.annotation=t)}}const Rx='\n<div class="textae-editor__footer">\n <div class="textae-editor__footer__message"></div>\n</div>\n';class Ix{#Q;#ln;constructor(t,e){this.#Q=t,this.#ln=e}set status(t){var e;this.#ln&&(""!==t&&((e=this.#Q,e.querySelector(".textae-editor__footer__message")||(e.insertAdjacentHTML("beforeend",Rx.replace(/[\n\r]+/g,"")),e.querySelector(".textae-editor__footer__message"))).innerHTML=at(t)?`Source: <a class="textae-editor__footer__message__link" href="${t}">${decodeURI(t)}</a>`:`Source: ${t}`))}}class Lx{#Nt;#cn;#Ki;#Ji;constructor(t,e,i){this.#Nt=t,this.#cn=new Ix(e,i),t.on("textae-event.resource.annotation.save",t=>{this.#hn=t}).on("textae-event.resource.configuration.save",t=>{this.#Ji=t})}get defaultAnnotation(){return{text:"Currently, the document is empty. Use the `import` button or press the key `i` to open a document with annotation."}}get defaultConfiguration(){return Cx(this.defaultAnnotation)}get annotation(){return this.#Ki?this.#Ki:this.defaultAnnotation}set annotation(t){this.#hn=t.data,this.#cn.status=t.displayName,this.#Nt.emit("textae-event.original-data.annotation.reset",t)}get configuration(){return this.#Ji?this.#Ji:{}}set configuration(t){this.#Ji=t.data,this.#Nt.emit("textae-event.original-data.configuration.reset",t)}set#hn(t){this.#Ki=t,t.config&&(this.#Ji=t.config)}}const Nx=[{usage:{"keyboard device":["control bar","context menu"],"touch device":["control bar"]},list:[{type:"import",title:"Import [I]"},{type:"upload",title:"Upload [U]"},{type:"upload automatically",title:"Upload Automatically",push:!0}]},{usage:{"keyboard device":["control bar","context menu"],"touch device":["control bar"]},list:[{type:"view mode",title:"View Mode",push:!0},{type:"term edit mode",title:"Term Edit Mode",push:!0},{type:"block edit mode",title:"Block Edit Mode",push:!0},{type:"relation edit mode",title:"Relation Edit Mode",push:!0},{type:"text edit mode",title:"Text Edit Mode",push:!0}]},{usage:{"keyboard device":["control bar","context menu"],"touch device":["control bar"]},list:[{type:"simple view",title:"Simple View",push:!0},{type:"adjust lineheight",title:"Adjust LineHeight"},{type:"auto adjust lineheight",title:"Auto Adjust LineHeight",push:!0}]},{usage:{"keyboard device":["control bar","context menu"],"touch device":["control bar"]},list:[{type:"undo",title:"Undo [Z]"},{type:"redo",title:"Redo [A]"}]},{usage:{"keyboard device":["control bar","context menu"],"touch device":["control bar"]},list:[{type:"replicate span annotation",title:"Replicate span annotation [R]",enableWhenSelecting:t=>t.span.single&&t.span.single.isDenotation},{type:"auto replicate",title:"Auto replicate",push:!0},{type:"boundary detection",title:"Boundary Detection [B]",push:!0}]},{usage:{"keyboard device":[],"touch device":["control bar","context menu"]},list:[{type:"create span by touch",title:"Create span",availableModes:[vn,yn]},{type:"expand span by touch",title:"Expand span",availableModes:[vn,yn]},{type:"shrink span by touch",title:"Shrink span",availableModes:[vn,yn]},{type:"edit text by touch",title:"Edit text",availableModes:[bn]}]},{usage:{"keyboard device":["control bar","context menu"],"touch device":["control bar"]},list:[{type:"new entity",title:"New entity [E]",enableWhenSelecting:t=>t.span.contains(t=>t.isDenotation)},{type:"pallet"},{type:"edit properties",title:"Edit Properties [W]",enableWhenSelecting:t=>t.entity.some||t.relation.some},{type:"delete",title:"Delete [D]",enableWhenSelecting:t=>t.span.some||t.entity.some||t.relation.some}]},{usage:{"keyboard device":[],"touch device":["control bar"]},list:[{type:"copy",title:"Copy [C]",enableWhenSelecting:t=>t.span.contains(t=>t.isDenotation)||t.entity.contains(t=>t.isDenotation)},{type:"cut",title:"Cut [X]",enableWhenSelecting:t=>t.span.contains(t=>t.isDenotation)||t.entity.contains(t=>t.isDenotation)},{type:"paste",title:"Paste [V]",enableWhenSelecting:(t,e)=>e.hasCopyingItem&&t.span.some||e.hasCuttingItem&&Boolean(t.span.single)}]},{usage:{"keyboard device":["control bar"],"touch device":["control bar"]},list:[{type:"setting",title:"Setting"}]},{usage:{"keyboard device":["control bar"],"touch device":[]},list:[{type:"help",title:"Help [H]"}]}];function jx(){return/Android/.test(navigator.userAgent)}class zx{#un;#dn;constructor(t,e){this.#un=t,this.#dn=e}isShowOnControlBar(){return jx()||/iPad/.test(navigator.userAgent)||/iPhone/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&q()?this.#un["touch device"].includes("control bar"):this.#un["keyboard device"].includes("control bar")}isShowOnContextMenu(){return q()?this.#un["touch device"].includes("context menu"):this.#un["keyboard device"].includes("context menu")}getButtonsFor(t){const e=this.#dn.filter(({availableModes:e})=>e.includes(t));return new zx(this.#un,e)}get buttonList(){return this.#dn}get displayProperties(){return{list:this.#dn.map(t=>t.displayProperties)}}}class Bx{#Ui;#ot;#fn=!1;#pn=null;#mn=[gn,vn,yn,On,bn];constructor(t,e,i=!1,n=null,s=null){this.#Ui=t,this.#ot=e,this.#fn=i,n&&(this.#pn=n),s&&(this.#mn=s)}get displayProperties(){return{type:this.#Ui,title:this.#ot}}get type(){return this.#Ui}get push(){return this.#fn}get enableWhenSelecting(){return this.#pn}get availableModes(){return this.#mn}}class qx{#gn;constructor(){this.#gn=Nx.map(({usage:t,list:e})=>new zx(t,e.map(({type:t,title:e,push:i,enableWhenSelecting:n,availableModes:s})=>new Bx(t,e,i,n,s))))}get controlBar(){return this.#gn.filter(t=>t.isShowOnControlBar()).map(t=>t.displayProperties)}getContextMenuFor(t){return this.#gn.filter(t=>t.isShowOnContextMenu()).map(e=>e.getButtonsFor(t)).map(t=>t.displayProperties)}get pasteButton(){return this.#dn.find(({type:t})=>"paste"===t)}get enableButtonsWhenSelecting(){return this.#dn.filter(t=>t.enableWhenSelecting)}get pushButtons(){return this.#dn.filter(t=>t.push).map(t=>t.type)}get#dn(){return this.#gn.flatMap(t=>t.buttonList)}}class Zx{#l;#Nt;#vn;constructor(t,e=null){this.#l=t,this.#Nt=e,this.#vn=!1}get name(){return this.#l}get isPushed(){return this.#vn}set isPushed(t){this.#vn=t,this.#yn()}toggle(){this.#vn=!this.#vn,this.#yn()}#yn(){this.#Nt&&this.#Nt.emit("textae-event.control.button.push",this)}}class Fx{#On;constructor(t){this.#On=(new qx).pushButtons.reduce((e,i)=>(e.set(i,new Zx(i,t)),e),new Map),t.on("textae-event.edit-mode.transition",(t,e)=>this.#bn(t,!e))}get(t){return this.#On.has(t)?this.#On.get(t):new Zx(t)}get names(){return this.#On.keys()}#bn(t,e){switch(t){case gn:this.#xn(!0,!1,!1,!1,!1,e);break;case vn:this.#xn(!1,!0,!1,!1,!1,e);break;case yn:this.#xn(!1,!1,!0,!1,!1,e);break;case On:this.#xn(!1,!1,!1,!0,!1,!1);break;case bn:this.#xn(!1,!1,!1,!1,!0,e);break;default:throw`unknown edit mode!${t}`}}#xn(t,e,i,n,s,o){this.#On.get("view mode").isPushed=t,this.#On.get("term edit mode").isPushed=e,this.#On.get("block edit mode").isPushed=i,this.#On.get("relation edit mode").isPushed=n,this.#On.get("text edit mode").isPushed=s,this.#On.get("simple view").isPushed=o}}class Xx{#wn;#Nt;#Ie;#oi;constructor(t,e,i){this.#wn=new Map([["import",!0],["upload",!0],["view mode",!0],["term edit mode",!0],["block edit mode",!0],["relation edit mode",!0],["text edit mode",!0],["simple view",!0],["setting",!0],["help",!0]]),this.#Nt=t,this.#Ie=e,this.#oi=i,t.on("textae-event.history.change",t=>{this.enable("undo",t.hasAnythingToUndo),this.enable("redo",t.hasAnythingToRedo)}).on("textae-event.selection.span.change",()=>this.#_n()).on("textae-event.selection.relation.change",()=>this.#_n()).on("textae-event.selection.entity.change",()=>this.#_n()).on("textae-event.edit-mode.transition",t=>this.#Sn(t)).on("textae-event.clip-board.change",()=>this.#kn()).on("textae-event.annotation-auto-saver.enable",t=>this.enable("upload automatically",t))}get(t){return this.#wn.get(t)}enable(t,e){this.#wn.set(t,e),this.#yn()}updateButtonsToOperateSpanWithTouchDevice(t,e,i,n){this.#wn.set("create span by touch",t),this.#wn.set("expand span by touch",e),this.#wn.set("shrink span by touch",i),this.#wn.set("edit text by touch",n),this.#yn()}#_n(){for(const{type:t,enableWhenSelecting:e}of(new qx).enableButtonsWhenSelecting)this.enable(t,e(this.#Ie,this.#oi));this.#yn()}#kn(){this.enable("paste",(new qx).pasteButton.enableWhenSelecting(this.#Ie,this.#oi))}#yn(){this.#Nt.emit("textae-event.control.buttons.change",this.#wn.keys())}#Sn(t){switch(t){case gn:this.#$n(!0,!1,!1,!1,!1,!1,!1);break;case vn:this.#$n(!0,!0,!0,!0,!0,!0,!0);break;case yn:this.#$n(!0,!1,!0,!0,!0,!0,!0);break;case On:this.#$n(!1,!1,!1,!0,!0,!1,!0);break;case bn:this.#$n(!0,!1,!0,!0,!0,!1,!1);break;default:throw`unknown edit mode!${t}`}this.#yn()}#$n(t,e,i,n,s,o,r){this.#wn.set("simple view",t),this.#wn.set("auto replicate",e),this.#wn.set("boundary detection",i),this.#wn.set("adjust lineheight",n),this.#wn.set("auto adjust lineheight",s),this.#wn.set("create span by touch",o),this.#wn.set("expand span by touch",o),this.#wn.set("shrink span by touch",o),this.#wn.set("pallet",r)}}function Hx(t,e,i,n,s){for(;s(t(i,n));)n+=e;return n}const Wx=function(t,e){return t.charAt(e)},Vx=function(t,e,i){return Hx(Wx,1,t,e,i)},Yx=function(t,e,i){return Hx(Wx,-1,t,e,i)};class Ux{backFromBegin(t,e,i){}forwardFromEnd(t,e,i){}forwardFromBegin(t,e,i){}backFromEnd(t,e,i){}}function Gx(t,e){return[t.charAt(e),t.charAt(e-1)]}function Kx(t,e){return[t.charAt(e),t.charAt(e+1)]}function Jx(t,e,i){return""!==i[0]&&!t(i[1])&&!e(i[1])||e(i[0])}class tw extends Ux{backFromBegin(t,e,i){const n=function(t,e,i){return Hx(Gx,-1,t,e,t=>t[1]&&!i(t[0])&&!i(t[1]))}(t,Vx(t,e,t=>i.isBlankCharacter(t)),t=>i.isDelimiter(t));return n}forwardFromEnd(t,e,i){const n=function(t,e,i){return Hx(Kx,1,t,e,t=>t[1]&&!i(t[0])&&!i(t[1]))}(t,Yx(t,e,t=>i.isBlankCharacter(t)),t=>i.isDelimiter(t));return n}forwardFromBegin(t,e,i){return function(t,e,i){return Hx(Gx,1,t,e,i)}(t,e,t=>Jx(t=>i.isBlankCharacter(t),t=>i.isDelimiter(t),t))}backFromEnd(t,e,i){return function(t,e,i){return Hx(Kx,-1,t,e,i)}(t,e,t=>Jx(t=>i.isBlankCharacter(t),t=>i.isDelimiter(t),t))}}class ew extends Ux{backFromBegin(t,e,i){return Vx(t,e,t=>i.isBlankCharacter(t))}forwardFromEnd(t,e,i){return Yx(t,e,t=>i.isBlankCharacter(t))}forwardFromBegin(t,e,i){return Vx(t,e,t=>i.isBlankCharacter(t))}backFromEnd(t,e,i){return Yx(t,e,t=>i.isBlankCharacter(t))}}function iw(t){switch(t){case vn:return"Term Configuration";case yn:return"Block Configuration";case On:return"Relation Configuration";default:return""}}class nw{#Cn;#Tn;#sn;#Pn;#Vt;#si;#En;constructor(t,e,i,n,s,o,r,a){this.#Cn=new Xx(t,e,i),this.#Tn=new Fx(t),this.#sn=n,this.#Pn=s,this.#Vt=o,this.#si=r,this.#En=a}get pushButtonNames(){return this.#Tn.names}isPushed(t){return this.#Tn.get(t).isPushed}push(t){this.#Tn.get(t).isPushed=!0}release(t){this.#Tn.get(t).isPushed=!1}toggleButton(t){return this.#Tn.get(t).toggle()}get textSelectionAdjuster(){return this.isPushed("boundary detection")?new tw:new ew}get controlBarButton(){return(new qx).controlBar.map(({list:t})=>t.filter(({type:t})=>this.#si.isAvailable(t)).map(({type:t,title:e})=>this.#An(t,e)).map(({type:t,title:e})=>({type:t,title:e,pushed:this.getState(t,"pushed"),disabled:this.getState(t,"disabled")}))).filter(t=>t.length)}get contextMenuButton(){return(new qx).getContextMenuFor(this.#En.currentState).map(({list:t})=>t.filter(({type:t})=>this.#si.isAvailable(t)).map(({type:t,title:e})=>this.#An(t,e)).reduce((t,{type:e,title:i})=>(!q()&&this.getState(e,"disabled")||t.push(this.#Mn(e,i)),t),[])).filter(t=>t.length)}getState(t,e){switch(e){case"pushed":return this.#Tn.get(t).isPushed;case"disabled":return!this.#Cn.get(t);case"transit":switch(t){case"upload":return this.#sn.hasChange;case"pallet":return this.diffOfConfiguration;default:new Error("Unknown name")}break;default:new Error("Unknown state")}}updateButtonsToOperateSpanWithTouchDevice(t,e,i,n){this.#Cn.updateButtonsToOperateSpanWithTouchDevice(t,e,i,n)}get diffOfConfiguration(){return sx(this.#Pn.configuration,{...this.#Pn.configuration,...this.#Vt.config})}setPushButtons(t){!0===t.autosave?this.push("upload automatically"):this.release("upload automatically"),!1===t.autolineheight?this.release("auto adjust lineheight"):this.push("auto adjust lineheight"),!1===t.boundarydetection?this.release("boundary detection"):this.push("boundary detection")}get detailModifierClassName(){return this.#si.isAvailable("show logo")?"textae-control-details--show-logo":"textae-control-details--hide-logo"}#An(t,e){return"pallet"==t?{type:t,title:iw(this.#En.currentState)}:{type:t,title:e}}#Mn(t,e){return{type:t,title:e,pushed:this.getState(t,"pushed"),disabled:this.getState(t,"disabled"),transit:this.getState(t,"transit")}}}class sw{#Nt;#ei;#Ie;#Qn;#Dn;#Vt;#Rn;#In;constructor(t,e,i,n,s,o){this.#Nt=t,this.#ei=e,this.#Ie=i,this.#Qn=n,this.#Dn=s,this.#Vt=o,this.#Rn=[],this.#In=D(),t.on("textae-event.annotation-data.entity.remove",t=>{this.hasCuttingItem&&this.#Ln(this.#Rn.filter(e=>e!=t))}).on("textae-event.edit-mode.transition",()=>this.#Ln())}get hasCopyingItem(){return this.#Rn[0]instanceof Ot}get hasCuttingItem(){return this.#Rn[0]instanceof Wt}copyEntitiesToLocalClipboard(){this.#Ln(this.#Ie.copyingTargets)}copyEntitiesToSystemClipboard(t){if(this.#Ie.span.contains(t=>t.isBlock))return;const{copyingTargets:e}=this.#Ie;if(e.length>0){const i=this.#Qn.config.filter(({id:t})=>e.some(({typeName:e})=>e===t)),n=this.#Dn.config.filter(({pred:t})=>e.some(({attributes:e})=>e.some(e=>e.pred===t))),s=JSON.stringify({typeValues:e.map(({externalFormat:t})=>t),config:{"entity types":i,"attribute types":n}});t.clipboardData.setData("text/plain",s),t.clipboardData.setData("application/x-textae-type-values",s),t.preventDefault()}}cutEntitiesToLocalClipboard(){const{cuttingTargets:t}=this.#Ie;this.#Nn.length&&this.#Nn.every(e=>t.has(e))&&[...t].every(t=>this.#Nn.includes(t))?this.#Ln():this.#Ln([...t])}cutEntitiesToSystemClipboard(t){this.#Ie.span.contains(t=>t.isBlock)||(this.cutEntitiesToLocalClipboard(),t.clipboardData.setData("application/x-textae-editor-uuid",this.#In),this.copyEntitiesToSystemClipboard(t))}pasteEntitiesFromLocalClipboard(){if(this.#jn.length&&this.#Ie.span.single)this.#zn();else if(this.hasCopyingItem){const t=this.#ei.factory.pasteTypesToSelectedSpansCommand(this.#Rn);this.#ei.invoke(t)}}pasteEntitiesFromSystemClipboard(t){if(this.#Ie.span.contains(t=>t.isBlock))return;if(t.clipboardData.getData("application/x-textae-editor-uuid")===this.#In&&this.#jn.length&&this.#Ie.span.single)return void this.#zn();const e=t.clipboardData.getData("application/x-textae-type-values");if(e){const t=JSON.parse(e),i=new Le;if(i.definedTypes=t.config["attribute types"],this.#Vt.isLock){const e=t.typeValues.map(({obj:t,attributes:e})=>new Ot(t,e.filter(({pred:t})=>this.#Dn.get(t)&&this.#Dn.get(t).valueType===i.get(t).valueType))),n=this.#ei.factory.pasteTypesToSelectedSpansCommand(e);this.#ei.invoke(n)}else{const e=t.typeValues.map(({obj:t,attributes:e})=>new Ot(t,e.filter(({pred:t})=>!this.#Dn.get(t)||this.#Dn.get(t).valueType===i.get(t).valueType))),n=t.config["entity types"].filter(({id:t})=>!this.#Qn.config.some(e=>e.id===t)),s=t.config["attribute types"].filter(({pred:t})=>!this.#Dn.get(t)),o=this.#ei.factory.pasteTypesToSelectedSpansCommand(e,n,s,this.#Bn(e,i));this.#ei.invoke(o)}return void(this.hasCuttingItem&&this.#Ln())}}#Bn(t,e){const i=[],n=t.reduce((t,i)=>t.concat(i.attributes.filter(({pred:t})=>"selection"===e.get(t).valueType)),[]);for(const{pred:t,obj:s}of n)if(this.#Dn.get(t)&&!this.#Dn.get(t).values.some(({id:t})=>t===s)){const n=e.get(t).values.find(({id:t})=>t===s);i.push({pred:t,value:n})}return i}#zn(){const t=this.#ei.factory.moveEntitiesToSelectedSpanCommand(this.#jn);this.#ei.invoke(t),this.#Ln()}#Ln(t=[]){const e=this.#Nn.filter(e=>!t.includes(e));this.#Rn=t,this.#Nt.emit("textae-event.clip-board.change",this.#Nn,e)}get#jn(){return this.#Nn.filter(t=>t.span.id!==(this.#Ie.span.single&&this.#Ie.span.single.id))}get#Nn(){return this.hasCuttingItem?this.#Rn:[]}}class ow{#ii;constructor(t,e,i,n,o){this.#ii=e;const r=s()(()=>i.saveAnnotation(),5e3);t.on("textae-event.resource.annotation.load.success",()=>this.#qn()).on("textae-event.resource.save.error",()=>this.#qn()).on("textae-event.resource.annotation.url.set",e=>t.emit("textae-event.annotation-auto-saver.enable",Boolean(n||e.id))).on("textae-event.control.button.push",({name:t,isPushed:e})=>{"upload automatically"===t&&!0===e&&o.hasChange&&i.saveAnnotation()}).on("textae-event.annotation-data.events-observer.unsaved-change",t=>{t&&e.isPushed("upload automatically")&&r()})}#qn(){this.#ii.isPushed("upload automatically")&&this.#ii.toggleButton("upload automatically")}}const rw=new d;class aw{#r;constructor(t,e){const i=l().create(t);this.#r=i,function(t,e){r()(t,".textae-control-icon","touchstart",({target:t})=>{if(t.classList.contains("textae-control-icon--disabled"))return;const{buttonType:i}=t.dataset;switch(i){case"create span by touch":case"expand span by touch":case"shrink span by touch":case"edit text by touch":e.handle(i)}},{passive:!0}),r()(t,".textae-control-icon","click",({target:t})=>{if(t.classList.contains("textae-control-icon--disabled"))return;const{buttonType:i}=t.dataset;switch(i){case"help":rw.open();break;case"create span by touch":case"expand span by touch":case"shrink span by touch":case"edit text by touch":break;default:e.handle(i)}});const i=t.querySelector(".textae-control-hamburger-menu-button");i&&i.addEventListener("click",t=>t.target.closest(".textae-control").querySelector(".textae-control-details").classList.toggle("textae-control-details--force-show"))}(this.#r,e)}get el(){return this.#r}_querySelector(t){return this.#r.querySelector(t)}}function lw({type:t,title:e,classList:i}){return`\n<span \nclass="${i.join(" ")}" \ntitle="${e}" \ndata-button-type="${t}">\n</span>\n`}var cw=i(6438),hw=i.n(cw);function uw(t){return t.map(t=>{const e=[];for(const{type:i,title:n,pushed:s,disabled:o,transit:r}of t){const t=["textae-control-icon",`textae-control-${i.replaceAll(" ","-")}-button`];s&&t.push("textae-control-icon--pushed"),o&&t.push("textae-control-icon--disabled"),r&&t.push("textae-control-icon--transit"),e.push({type:i,title:n,classList:t})}return e})}function dw(t){return`\n<div class="textae-control ${q()?"textae-touch-bar":"textae-control-bar"}">\n <div class="textae-control-summary">\n <span class="textae-control-title">\n <a href="http://textae.pubannotation.org/" target="_blank">TextAE</a>\n </span>\n <button type="button" class="textae-control-hamburger-menu-button" >\n <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" class="bi" fill="currentColor" viewBox="0 0 16 16">\n <path fill-rule="evenodd" d="M2.5 11.5A.5.5 0 0 1 3 11h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm0-4A.5.5 0 0 1 3 7h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm0-4A.5.5 0 0 1 3 3h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5z"></path>\n </svg>\n </button>\n </div>\n <div class="textae-control-details ${t.detailModifierClassName}">\n <span class="textae-control-title">\n <a href="http://textae.pubannotation.org/" target="_blank">TextAE</a>\n </span>\n ${uw(t.controlBarButton).map(t=>`\n <span class="textae-control-separator"></span>\n ${t.map(lw).join("\n")}\n `).join("\n")}\n </div>\n</div>\n`}class fw extends aw{#ii;constructor(t,e,i){super(dw(e),i),this.#ii=e,q()&&Math.max(document.documentElement.clientWidth,window.innerWidth)<768&&new(hw())(".textae-touch-bar",{stickyContainer:".textae-editor"}),t.on("textae-event.control.button.push",({name:t})=>{this.#Zn(t,"pushed")}).on("textae-event.control.buttons.change",t=>{for(const e of t)this.#Zn(e,"disabled")}).on("textae-event.annotation-data.events-observer.unsaved-change",()=>{this.#Zn("upload","transit")}).on("textae-event.edit-mode.transition",t=>{const e=iw(t);super._querySelector(".textae-control-pallet-button").title=e}).on("textae-event.configuration.reset",()=>this.#Fn()).on("textae-event.type-definition.entity.change",()=>this.#Zn("pallet","transit")).on("textae-event.type-definition.entity.delete",()=>this.#Zn("pallet","transit")).on("textae-event.type-definition.entity.change-default",()=>this.#Zn("pallet","transit")).on("textae-event.type-definition.relation.change",()=>this.#Zn("pallet","transit")).on("textae-event.type-definition.relation.delete",()=>this.#Zn("pallet","transit")).on("textae-event.type-definition.relation.change-default",()=>this.#Zn("pallet","transit")).on("textae-event.type-definition.attribute.create",()=>this.#Zn("pallet","transit")).on("textae-event.type-definition.attribute.change",()=>this.#Zn("pallet","transit")).on("textae-event.type-definition.attribute.delete",()=>this.#Zn("pallet","transit")).on("textae-event.type-definition.attribute.move",()=>this.#Zn("pallet","transit"))}#Zn(t,e){const i=super._querySelector(`.textae-control-${t.replaceAll(" ","-")}-button`);i&&(this.#ii.getState(t,e)?i.classList.add(`textae-control-icon--${e}`):i.classList.remove(`textae-control-icon--${e}`))}#Fn(){super.el.innerHTML="",super.el.insertAdjacentHTML("beforeend",dw(this.#ii))}}function pw({type:t,title:e,classList:i}){return`<p \n class="${i.join(" ")}" \n data-button-type="${t}">${e}\n </p>`}class mw extends aw{#Q;#ii;constructor(t,e,i){super(`<div class="textae-control ${q()?"textae-android-context-menu":"textae-context-menu"}"></div>`,i),this.#Q=t,this.#ii=e}show(t){const e=window.getSelection(),i=this.#Q.getBoundingClientRect();if(q()&&1===e.rangeCount){const t=e.getRangeAt(0).getBoundingClientRect(),n=this.#Q.querySelector(".textae-editor__text-box").getBoundingClientRect();this.#Xn(t.y-i.y,t.x-n.x)}else this.#Hn(t.pageY-i.y,t.pageX-i.x)}hide(){this.#Wn&&(super.el.classList.remove("textae-context-menu--show"),super.el.classList.add("textae-context-menu--hide"))}get#Wn(){return super.el.classList.contains("textae-context-menu--show")}#Xn(t,e){this.#Vn();const{height:i}=this.el.getBoundingClientRect();super.el.setAttribute("style",`top: ${t-i}px; left: ${e}px`)}#Hn(t,e){this.#Vn(),super.el.setAttribute("style",`top: ${t}px; left: ${e}px`)}#Vn(){const t=uw(this.#ii.contextMenuButton);if(0===t.length)return;const e=`\n <div">\n ${t.map(t=>t.map(pw).join("")).join('<p class="textae-control-separator"></p>\n')}\n </div>\n `;super.el.replaceChildren(...l().create(e).children),super.el.classList.remove("textae-context-menu--hide"),super.el.classList.add("textae-context-menu--show")}}class gw{constructor(t,e,i,n,s,o){this._map=new Map([["1",t=>s.manipulateAttribute(1,t)],["2",t=>s.manipulateAttribute(2,t)],["3",t=>s.manipulateAttribute(3,t)],["4",t=>s.manipulateAttribute(4,t)],["5",t=>s.manipulateAttribute(5,t)],["6",t=>s.manipulateAttribute(6,t)],["7",t=>s.manipulateAttribute(7,t)],["8",t=>s.manipulateAttribute(8,t)],["9",t=>s.manipulateAttribute(9,t)],["a",()=>n.isAvailable("redo")&&t.redo()],["b",()=>n.isAvailable("boundary detection")&&e.toggleButton("boundary detection")],["d",()=>n.isAvailable("delete")&&e.removeSelectedElements()],["e",()=>n.isAvailable("new entity")&&e.createEntity()],["f",()=>o.changeModeByShortcut()],["i",()=>n.isAvailable("import")&&i.importAnnotation()],["m",()=>o.changeModeByShortcut()],["q",()=>n.isAvailable("pallet")&&s.showPallet()],["r",()=>n.isAvailable("replicate span annotation")&&e.replicate()],["u",()=>n.isAvailable("upload")&&i.uploadAnnotation()],["w",()=>n.isAvailable("edit properties")&&s.editProperties()],["y",()=>n.isAvailable("redo")&&t.redo()],["z",()=>n.isAvailable("undo")&&t.undo()],["ArrowDown",()=>e.selectDown()],["ArrowLeft",t=>e.selectLeft(t)],["ArrowRight",t=>e.selectRight(t)],["ArrowUp",()=>e.selectUp()],["Backspace",()=>e.removeSelectedElements()],["Delete",()=>e.removeSelectedElements()],["Escape",()=>e.cancelSelect()]])}handle(t){const e=t.shiftKey&&48<=t.keyCode&&t.keyCode<=57?String.fromCharCode(t.keyCode):t.key;this._map.has(e)&&this._map.get(e)(t.shiftKey)}}class vw{constructor(t,e,i,n,s,o,r){this._map=new Map([["view mode",()=>r.toViewMode()],["term edit mode",()=>r.toTermEditMode()],["block edit mode",()=>r.toBlockEditMode()],["relation edit mode",()=>r.toRelationEditMode()],["text edit mode",()=>r.toTextEditMode()],["simple view",()=>r.toggleSimpleMode()],["import",()=>i.importAnnotation()],["upload",()=>i.uploadAnnotation()],["undo",()=>t.undo()],["redo",()=>t.redo()],["replicate span annotation",()=>e.replicate()],["create span by touch",()=>o.createSpanWithTouchDevice()],["expand span by touch",()=>o.expandSpanWithTouchDevice()],["shrink span by touch",()=>o.shrinkSpanWithTouchDevice()],["edit text by touch",()=>o.editTextWithTouchDevice()],["new entity",()=>e.createEntity()],["edit properties",()=>o.editProperties()],["pallet",()=>o.showPallet()],["delete",()=>e.removeSelectedElements()],["copy",()=>e.copyEntitiesToLocalClipboard()],["cut",()=>e.cutEntitiesToLocalClipboard()],["paste",()=>e.pasteEntitiesFromLocalClipboard()],["setting",()=>e.showSettingDialog()],["adjust lineheight",()=>s.textBox.updateLineHeight()]]);for(const t of n.pushButtonNames)this._map.has(t)||this._map.set(t,()=>e.toggleButton(t))}handle(t){this._map.has(t)&&this._map.get(t)()}}function yw(t,e){return t.id<e.id?-1:t.id>e.id?1:0}function Ow({text:t,denotations:e=[],attributes:i=[],relations:n=[],blocks:s=[],selectedText:o}){return{text:t,denotations:e.sort(yw),attributes:i.sort(yw),relations:n.sort(yw),blocks:s.sort(yw),selectedText:o}}function bw(t,e){return sx(Ow(t),Ow(e))}class xw{#Nt;#Pn;#Ht;#Yn=new(ve())(!1);constructor(t,e,i){this.#Nt=t,this.#Pn=e,this.#Ht=i,t.on("textae-event.resource.annotation.save",()=>{this.#Yn.set(!1),this.#Un()}).on("textae-event.annotation-data.all.change",()=>{this.#Yn.set(!1),this.#Un()}).on("textae-event.annotation-data.span.add",()=>this.#Gn()).on("textae-event.annotation-data.span.change",()=>this.#Gn()).on("textae-event.annotation-data.span.remove",()=>this.#Gn()).on("textae-event.annotation-data.entity.add",()=>this.#Gn()).on("textae-event.annotation-data.entity.change",()=>this.#Gn()).on("textae-event.annotation-data.entity.remove",()=>this.#Gn()).on("textae-event.annotation-data.entity.move",()=>this.#Gn()).on("textae-event.annotation-data.relation.add",()=>this.#Gn()).on("textae-event.annotation-data.relation.change",()=>this.#Gn()).on("textae-event.annotation-data.relation.remove",()=>this.#Gn()).on("textae-event.annotation-data.attribute.add",()=>this.#Gn()).on("textae-event.annotation-data.attribute.remove",()=>this.#Gn()).on("textae-event.annotation-data.text.change",()=>this.#Gn()),this.#Yn(()=>t.emit("textae-event.annotation-data.events-observer.unsaved-change",this.#Yn()))}get hasChange(){return this.#Yn()}#Gn(){this.#Yn.set(bw(this.#Pn.annotation,this.#Ht.externalFormat)),this.#Un()}#Un(){this.#Nt.emit("textae-event.annotation-data.events-observer.change",this.#Ht)}}async function ww(t,e){if(function(t,e){const i=hx().extname(e),n=t.headers.get("Content-Type");return".json"===i||n&&n.includes("application/json")}(t,e))return await t.json();if(function(t,e){const i=hx().extname(e),n=t.headers.get("Content-Type");return".txt"===i||n&&n.includes("text/plain")}(t,e)){const e=await t.text();return ub.parse(e)}throw new Error("The content type of the loaded content is not supported.")}class _w extends Error{constructor(t){super(t),this.name="FormatConversionError"}}class Sw{#Nt;constructor(t){this.#Nt=t}async loadFrom(t){console.assert(t,"url is necessary!"),this.#Nt.emit("textae-event.resource.startLoad");try{const e=await fetch(t,{method:"GET",cache:"no-cache",credentials:"omit",headers:{Accept:"application/json, text/plain"},signal:AbortSignal.timeout(3e4)});if(e.ok){const i=await ww(e,t);this.#Kn(t,i)}else 401===e.status?await this.#Jn(t):this.#ts(t)}catch(e){e instanceof _w||console.error(e),this.#ts(t)}finally{this.#Nt.emit("textae-event.resource.endLoad")}}#Kn(t,e){const i=dx.createURLSource(t,e);e&&e.text?(this.#Nt.emit("textae-event.resource.annotation.load.success",i),this.#Nt.emit("textae-event.resource.annotation.url.set",i)):this.#Nt.emit("textae-event.resource.annotation.format.error",i)}async#Jn(t){try{const e=await fetch(t,{method:"GET",cache:"no-cache",credentials:"include",headers:{Accept:"application/json, text/plain"},signal:AbortSignal.timeout(3e4)});if(e.ok){const i=await ww(e,t);this.#Kn(t,i)}else 401===e.status?await this.#Jn(t):this.#ts(t)}catch{this.#ts(t)}}#ts(t){e().error(`Could not load the file from the location you specified.: ${t}`),this.#Nt.emit("textae-event.resource.annotation.load.error",t)}}class kw{#Nt;constructor(t){this.#Nt=t}loadFrom(t,e){console.assert(t,"url is necessary!"),this.#Nt.emit("textae-event.resource.startLoad"),fetch(t,{method:"GET",cache:"no-cache",credentials:"omit",headers:{Accept:"application/json","Content-Type":"application/json"},signal:AbortSignal.timeout(3e4)}).then(i=>{if(i.ok)return i.json().then(i=>this.#Kn(t,i,e));this.#ts(t)}).catch(()=>this.#ts(t)).finally(()=>this.#Nt.emit("textae-event.resource.endLoad"))}#Kn(t,e,i){this.#Nt.emit("textae-event.resource.configuration.load.success",dx.createURLSource(t,e),i)}#ts(t){e().error(`Could not load the file from the location you specified.: ${t}`),this.#Nt.emit("textae-event.resource.configuration.load.error",t)}}function $w(t,e,i){return 401===t&&e&&"ServerPage"===e&&i?i:null}function Cw(t){return window.open(t,"_blank","width=600, height=500")}function Tw(t,e){return"json"===e?JSON.stringify(t):"inline"===e?ub.generate(t):void 0}class Pw{#es;#Nt;constructor(t,e){this.#es=t,this.#Nt=e}async saveTo(t,e){if(t){this.#Nt.emit("textae-event.resource.startSave");try{const i=Tw(e,this.#es),n=await this.#is(t,i);await this.#ns(n,t,e)}catch(t){t instanceof _w||console.error(t),this.#ts()}finally{this.#Nt.emit("textae-event.resource.endSave")}}}async#is(t,e){const i="json"===this.#es?"application/json":"text/plain";return fetch(t,{method:"POST",headers:{"Content-Type":i,"App-Name":"TextAE"},body:e,credentials:"include"})}async#ns(t,e,i){if(t.ok)this.#ss(i);else if(401===t.status){const n=$w(t.status,t.headers.get("WWW-Authenticate"),t.headers.get("Location"));n&&await this.#os(n,e,i)}else this.#ts()}#ss(t){e().success("annotation saved"),this.#Nt.emit("textae-event.resource.annotation.save",t)}async#os(t,e,i){const n=Cw(t);if(!n)return this.#ts();await async function(t){return new Promise(e=>{const i=setInterval(()=>{t.closed&&(clearInterval(i),e())},1e3)})}(n),await this.#rs(i,e)}async#rs(t,e){const i=Tw(t,this.#es);(await this.#is(e,i)).ok?this.#ss(t):this.#ts()}#ts(){e().error("could not save"),this.#Nt.emit("textae-event.resource.save.error")}}class Ew{#Nt;constructor(t){this.#Nt=t}saveTo(t,e){if(t){this.#Nt.emit("textae-event.resource.startSave");const i={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),credentials:"include"};fetch(t,i).then(i=>{if(i.ok)return this.#ss(e);if(401===i.status){const n=$w(i.status,i.headers.get("WWW-Authenticate"),i.headers.get("Location"));if(n)return this.#os(n,t,e)}this.#ts()}).finally(()=>this.#Nt.emit("textae-event.resource.endSave"))}}#ss(t){e().success("configuration saved"),this.#Nt.emit("textae-event.resource.configuration.save",t)}#os(t,e,i){if(!Cw(t))return this.#ts();const n=setInterval(()=>{clearInterval(n),this.#rs(i,e)},1e3)}#rs(t,e){{const i={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),credentials:"include"};fetch(e,i).then(e=>{e.ok?this.#ss(t):this.#ts()})}}#ts(){e().error("could not save"),this.#Nt.emit("textae-event.resource.save.error")}}class Aw{#Nt;constructor(t){this.#Nt=t}loadAnnotation(t){new Sw(this.#Nt).loadFrom(t)}loadConfiguration(t,e=null){new kw(this.#Nt).loadFrom(t,e)}saveAnnotation(t,e,i){new Pw(i,this.#Nt).saveTo(t,e)}saveConfiguration(t,e){new Ew(this.#Nt).saveTo(t,e)}}class Mw{#as;constructor(){this.#as=new Map([["logo",{name:"show logo",enabled:!0}],["read",{name:"import",enabled:!0}],["write",{name:"upload",enabled:!0}],["write-auto",{name:"upload automatically",enabled:!0}],["view",{name:"view mode",enabled:!0}],["term",{name:"term edit mode",enabled:!0}],["term-edit",{alias:"term"}],["block",{name:"block edit mode",enabled:!0}],["block-edit",{alias:"block"}],["relation",{name:"relation edit mode",enabled:!0}],["relation-edit",{alias:"relation"}],["text-edit",{name:"text edit mode",enabled:!0}],["simple",{name:"simple view",enabled:!0}],["line-height",{name:"adjust lineheight",enabled:!0}],["line-height-auto",{name:"auto adjust lineheight",enabled:!0}],["undo",{name:"undo",enabled:!0}],["redo",{name:"redo",enabled:!0}],["replicate",{name:"replicate span annotation",enabled:!0}],["replicate-auto",{name:"auto replicate",enabled:!0}],["boundary-detection",{name:"boundary detection",enabled:!0}],["create-span-by-touch",{name:"create span by touch",enabled:!0}],["expand-span-by-touch",{name:"expand span by touch",enabled:!0}],["shrink-span-by-touch",{name:"shrink span by touch",enabled:!0}],["edit-text-by-touch",{name:"edit text by touch",enabled:!0}],["entity",{name:"new entity",enabled:!0}],["pallet",{name:"pallet",enabled:!0}],["edit-properties",{name:"edit properties",enabled:!0}],["delete",{name:"delete",enabled:!0}],["copy",{name:"copy",enabled:!0}],["cut",{name:"cut",enabled:!0}],["paste",{name:"paste",enabled:!0}],["setting",{name:"setting",enabled:!0}],["help",{name:"help",enabled:!0}]])}get defaultAvailabilities(){return Array.from(this.#as.values()).filter(({name:t,enabled:e})=>void 0!==t&&void 0!==e).reduce((t,{name:e,enabled:i})=>t.set(e,i),new Map)}translateToInnerNameFrom(t){if(this.#as.has(t)){const e=this.#as.get(t);return e.alias?this.#as.get(e.alias).name:e.name}return e().warning(`'${t}' is an unknown function name for function availabilities.`),t}}class Qw{#ls;#cs;constructor(){this.#ls=new Mw,this.#cs=this.#ls.defaultAvailabilities}isAvailable(t){return this.#cs.get(t)}enable(t){this.#cs.set(t,!0)}disable(t){this.#cs.set(t,!1)}get names(){return Array.from(this.#cs.keys())}set availability(t){const e=this.#ls.defaultAvailabilities;if(t)for(const[i,n]of Object.entries(t))e.set(this.#ls.translateToInnerNameFrom(i),n);this.#cs=e}}class Dw{#hs;#us;#fe;#Nt;#si;constructor(t,e,i){this.#hs=!1,this.#us=mn,this.#fe=t,this.#Nt=e,this.#si=i}get currentState(){return this.#us}toViewMode(t){this.#hs=t,this.#us=gn,this.#ds()}toTermEditMode(t){this.#hs=t,this.#us=vn,this.#ds()}toBlockEditMode(t){this.#hs=t,this.#us=yn,this.#ds()}toRelationEditMode(){this.#hs=!0,this.#us=On,this.#ds()}toTextEditMode(t){this.#hs=t,this.#us=bn,this.#ds()}toggleSimpleMode(){switch(this.currentState){case vn:this.toTermEditMode(!this.#hs);break;case yn:this.toBlockEditMode(!this.#hs);break;case bn:this.toTextEditMode(!this.#hs);break;case gn:this.toViewMode(!this.#hs);break;default:throw new Error(`Invalid state: ${this.currentState}`)}}changeModeByShortcut(){const t=this.#fs;if(t.length<=1)return;const e=t.findIndex(t=>t.name===this.currentState);e<t.length-1?this[t[e+1].funcName](this.nextShowRelation):this[t[0].funcName](this.nextShowRelation)}get nextShowRelation(){return this.#us===On?this.#fe.some:this.#hs}#ds(){this.#Nt.emit("textae-event.edit-mode.transition",this.#us,this.#hs)}get#fs(){return[{name:gn,availabilityName:"view mode",funcName:"toViewMode"},{name:vn,availabilityName:"term edit mode",funcName:"toTermEditMode"},{name:yn,availabilityName:"block edit mode",funcName:"toBlockEditMode"},{name:On,availabilityName:"relation edit mode",funcName:"toRelationEditMode"}].filter(t=>this.#si.isAvailable(t.availabilityName))}}class Rw{#En;#ps;#G;#ms;constructor(t,e,i,n){this.#ps=t,this.#En=e,this.#G=i,this.#ms=n}toViewMode(){this.#ms(),this.#En.toViewMode(this.#En.nextShowRelation)}toTermEditMode(){this.#ms(),this.#En.toTermEditMode(this.#En.nextShowRelation)}toBlockEditMode(){this.#ms(),this.#En.toBlockEditMode(this.#En.nextShowRelation)}toRelationEditMode(){this.#ms(),this.#En.toRelationEditMode()}toTextEditMode(){this.#ms(),this.#En.toTextEditMode(this.#En.nextShowRelation)}toggleSimpleMode(){this.#ms(),this.#En.toggleSimpleMode()}changeModeByShortcut(){this.#ms(),this.#En.changeModeByShortcut()}reset(){this.#ps.isEditTermMode?this.#En.toTermEditMode(this.#G.some):this.#ps.isEditBlockMode?this.#En.toBlockEditMode(this.#G.some):this.#ps.isEditRelationMode?this.#En.toRelationEditMode():this.#ps.isTextEditMode?this.#En.toTextEditMode(this.#G.some):this.#En.toViewMode(this.#G.some)}}function Iw(){window.getSelection().removeAllRanges()}function Lw(t,i,n,s,o,r,a,l,c){if(a){s.removeAll();const h=L(t,a),u=function(t,i,n,s,o,r,a){const{begin:l,end:c}=t.getSpan(o).getShortenInAnchorNodeToFocusNodeDirection(s,i,r);if(t.isBoundaryCrossingWithOtherSpans(l,c))return e().warning("A span cannot be shrunken to make a boundary crossing."),!1;const h=t.findDenotation(l,c);return l<c&&!h?(a(l,c),!1):(n.invoke(n.factory.removeSpanCommand(o)),!0)}(i,n,o,r,a,l,c);u&&h&&s.selectSpan(h.id)}}class Nw{constructor(){this.selection=window.getSelection(),console.assert(this.parentOfAnchorNode.closest(".textae-editor__text-box")===this.parentOfFocusNode.closest(".textae-editor__text-box"),"Text selection across editors is disabled")}get isParentOfAnchorNodeTextBox(){return Y(this.parentOfAnchorNode)}get isParentOfAnchorNodeDenotationSpan(){return U(this.parentOfAnchorNode)}get isParentOfAnchorNodeBlockSpan(){return K(this.parentOfAnchorNode)}get isParentOfAnchorNodeStyleSpan(){return G(this.parentOfAnchorNode)}get isParentOfFocusNodeTextBox(){return Y(this.parentOfFocusNode)}get isParentOfFocusNodeDenotationSpan(){return U(this.parentOfFocusNode)}get isParentOfFocusNodeBlockSpan(){return K(this.parentOfFocusNode)}get isParentOfFocusNodeStyleSpan(){return G(this.parentOfFocusNode)}get isParentOfBothNodesSame(){return this.parentOfAnchorNode===this.parentOfFocusNode}get isParentOfBothNodesTextBox(){return this.isParentOfAnchorNodeTextBox&&this.isParentOfFocusNodeTextBox}get isParentsParentOfAnchorNodeAndFocusedNodeSame(){return this.parentOfAnchorNode.parentElement===this.parentOfFocusNode.parentElement}get isAnchorNodeParentIsDescendantOfFocusNodeParent(){return this.parentOfAnchorNode.closest(`#${this.parentOfFocusNode.id}`)}get ancestorDenotationSpanOfAnchorNode(){return this.parentOfAnchorNode.closest(".textae-editor__span")}get ancestorDenotationSpanOfFocusNode(){return this.parentOfFocusNode.closest(".textae-editor__span")}get ancestorBlockSpanOfAnchorNode(){return this.parentOfAnchorNode.closest(".textae-editor__block")}get ancestorBlockSpanOfFocusNode(){return this.parentOfFocusNode.closest(".textae-editor__block")}get doesFitInOneBlockSpan(){return this.ancestorBlockSpanOfAnchorNode===this.ancestorBlockSpanOfFocusNode}get parentOfAnchorNode(){return this.selection.anchorNode.parentElement}get parentOfFocusNode(){return this.selection.focusNode.parentElement}}class jw{#Q;#Ht;#ni;#ei;#ii;#Ie;constructor(t,e,i,n,s,o){this.#Q=t,this.#Ht=e,this.#ni=i,this.#ei=n,this.#ii=s,this.#Ie=o}editFor(){const t=new Nw;if(t.isParentOfAnchorNodeTextBox){if(t.isParentOfFocusNodeTextBox)return void this.#gs();if(t.isParentOfFocusNodeDenotationSpan||t.isParentOfFocusNodeStyleSpan)return void(t.ancestorBlockSpanOfFocusNode?this.#vs(t):this.#gs());if(t.isParentOfFocusNodeBlockSpan)return void this.#vs(t)}if(t.isParentOfAnchorNodeDenotationSpan||t.isParentOfAnchorNodeStyleSpan){if(t.isParentOfFocusNodeTextBox||t.isParentOfFocusNodeDenotationSpan||t.isParentOfFocusNodeStyleSpan){if(t.ancestorBlockSpanOfAnchorNode)if(t.doesFitInOneBlockSpan){const{anchor:e,focus:i}=this.#Ht.textSelection,n=this.#Ht.getSpan(t.parentOfAnchorNode.id),s=this.#Ht.getSpan(t.ancestorBlockSpanOfAnchorNode.id);e<i&&n.begin===s.begin||i<e&&n.end===s.end?this.#vs(t):Iw()}else this.#ys(t);else t.ancestorBlockSpanOfFocusNode?this.#vs(t):this.#gs();return}if(t.isParentOfFocusNodeBlockSpan)return void this.#vs(t)}if(t.isParentOfAnchorNodeBlockSpan){if(t.isParentOfFocusNodeTextBox||t.isParentOfFocusNodeDenotationSpan||t.isParentOfFocusNodeStyleSpan)return void(t.ancestorBlockSpanOfFocusNode?this.#vs(t):this.#ys(t));if(t.isParentOfFocusNodeBlockSpan){const{anchor:e}=this.#Ht.textSelection,i=this.#Ht.getSpan(t.parentOfFocusNode.id);if(e===i.begin||e===i.end)return void this.#vs(t)}}Iw()}cerateSpanForTouchDevice(){(new Nw).isParentOfBothNodesTextBox&&this.#gs()}expandForTouchDevice(){const t=this.#Os();if(t){const{spanID:e,begin:i,end:n}=t;this.#Ht.validateNewBlockSpan(i,n,e)&&this.#ei.invoke(this.#ei.factory.moveBlockSpanCommand(e,i,n))}}shrinkForTouchDevice(){const t=this.#bs();if(t){const{spanID:i,begin:n,end:s}=t,o=L(this.#Q,i);if(this.#Ht.isBoundaryCrossingWithOtherSpans(n,s))return void e().warning("A span cannot be modified to make a boundary crossing.");if(this.#Ht.hasParentOf(n,s,i))return;const r=this.#Ht.findBlock(n,s);n<s&&!r?this.#ei.invoke(this.#ei.factory.moveBlockSpanCommand(i,n,s)):(this.#ei.invoke(this.#ei.factory.removeSpanCommand(i)),o&&this.#Ie.selectSpan(o.id))}}#gs(){this.#Ht.hasCharacters(this.#ni)&&(this.#Ie.removeAll(),function(t,e,i,n){const{begin:s,end:o}=t.getTextSelection(n,i);if(t.validateNewBlockSpan(s,o)){const t=e.factory.createBlockSpanCommand({begin:s,end:o});e.invoke(t)}}(this.#Ht,this.#ei,this.#ii.textSelectionAdjuster,this.#ni)),Iw()}#ys(t){const e=t.ancestorBlockSpanOfAnchorNode.id;this.#Ie.removeAll();const{begin:i,end:n}=this.#Ht.getSpan(e).getExpandedInAnchorNodeToFocusNodeDirection(this.#ii.textSelectionAdjuster,this.#Ht.sourceDoc,this.#ni);this.#Ht.validateNewBlockSpan(i,n,e)&&this.#ei.invoke(this.#ei.factory.moveBlockSpanCommand(e,i,n)),Iw()}#vs(t){const e=t.ancestorBlockSpanOfFocusNode.id;Lw(this.#Q,this.#Ht,this.#Ht.sourceDoc,this.#Ie,this.#ei,this.#ii.textSelectionAdjuster,e,this.#ni,(t,i)=>{this.#ei.invoke(this.#ei.factory.moveBlockSpanCommand(e,t,i))}),Iw()}#Os(){const t=new Nw;if(null==t.ancestorBlockSpanOfAnchorNode&&null==t.ancestorBlockSpanOfFocusNode)return null;if(t.parentOfFocusNode.contains(t.parentOfAnchorNode)){const e=t.parentOfAnchorNode.id;return{spanID:e,...this.#Ht.getSpan(e).getExpandedInAnchorNodeToFocusNodeDirection(this.#ii.textSelectionAdjuster,this.#Ht.sourceDoc,this.#ni)}}if(t.parentOfAnchorNode.contains(t.parentOfFocusNode)){const e=t.parentOfFocusNode.id;return{spanID:e,...this.#Ht.getSpan(e).getExpandedInFocusNodeToAnchorNodeDirection(this.#ii.textSelectionAdjuster,this.#Ht.sourceDoc,this.#ni)}}}#bs(){const t=new Nw;if(null==t.ancestorBlockSpanOfAnchorNode&&null==t.ancestorBlockSpanOfFocusNode)return null;if(t.parentOfAnchorNode===t.parentOfFocusNode)return null;if(t.parentOfFocusNode.contains(t.parentOfAnchorNode)){const e=t.parentOfAnchorNode.id;return{spanID:e,...this.#Ht.getSpan(e).getShortenInFocusNodeToAnchorNodeDirection(this.#ii.textSelectionAdjuster,this.#Ht.sourceDoc,this.#ni)}}if(t.parentOfAnchorNode.contains(t.parentOfFocusNode)){const e=t.parentOfFocusNode.id;return{spanID:e,...this.#Ht.getSpan(e).getShortenInAnchorNodeToFocusNodeDirection(this.#ii.textSelectionAdjuster,this.#Ht.sourceDoc,this.#ni)}}}}function zw(t,e,i,n){e.length?t.selectSpanRange(e):i.ctrlKey||i.metaKey?t.span.toggle(n):t.selectSpan(n)}function Bw(t){const e=window.getSelection();return"Range"===e.type&&t.contains(e.anchorNode)&&t.contains(e.focusNode)}function qw(t){return t.closest(".textae-editor__signboard")}class Zw{#Q;#Ht;#Ie;#xs;#ws;constructor(t,e,i,n,s){this.#Q=t,this.#Ht=e,this.#Ie=i,this.#xs=n,this.#ws=s}bind(){const t=[];return t.push(r()(this.#Q,".textae-editor__text-box","click",t=>{t.target.classList.contains("textae-editor__text-box")&&this.#_s()})),t.push(r()(this.#Q,".textae-editor","click",t=>{t.target.classList.contains("textae-editor")&&this.#Ss()})),t.push(r()(this.#Q,".textae-editor__signboard","mousedown",()=>this.#ks())),t.push(r()(this.#Q,".textae-editor__signboard__type-values","click",t=>{const e=qw(t.target).dataset.id;this.#$s(t,e)})),t.push(r()(this.#Q,".textae-editor__block","mouseup",t=>{t.target.classList.contains("textae-editor__block")&&this.#Cs()})),t.push(r()(this.#Q,".textae-editor__block-hit-area","mouseup",t=>{t.target.classList.contains("textae-editor__block-hit-area")&&this.#Ts(t)})),t.push(r()(this.#Q,".textae-editor__style","mouseup",t=>{t.target.classList.contains("textae-editor__style")&&this.#Ps(t)})),t.push(r()(this.#Q,".textae-editor__span","mouseup",t=>{t.target.classList.contains("textae-editor__span")&&this.#Es(t)})),t}#Ss(){this.#ws.hide(),this.#Ie.removeAll()}#_s(){"Caret"===window.getSelection().type&&(this.#ws.hide(),this.#Ie.removeAll()),Bw(this.#Q.querySelector(".textae-editor__text-box"))&&this.#xs.editFor()}#Cs(){"Caret"===window.getSelection().type&&(this.#ws.hide(),Iw(),this.#Ie.removeAll()),Bw(this.#Q.querySelector(".textae-editor__text-box"))&&this.#xs.editFor()}#Ts(t){2===t.button&&Iw();const e=window.getSelection();if("Caret"===e.type||"None"===e.type){const e=t.target.dataset.id;this.#As(t,e)}}#Ps(t){"Caret"===window.getSelection().type&&this.#Ie.removeAll(),Bw(this.#Q.querySelector(".textae-editor__text-box"))&&(this.#xs.editFor(),t.stopPropagation())}#Es(t){"Caret"===window.getSelection().type&&this.#Ie.removeAll(),Bw(this.#Q.querySelector(".textae-editor__text-box"))&&(this.#xs.editFor(),t.stopPropagation())}#ks(){this.#Q.focus()}#$s(t,e){if(this.#Ht.entityInstanceContainer.get(e).isBlock){t.ctrlKey||t.metaKey?this.#Ie.entity.toggle(e):this.#Ie.selectEntity(e);const i=this.#Ie.entity.all.map(t=>t.span).map(t=>t.id);this.#Ie.add("span",i)}}#As(t,e){const i=this.#Ie.span.singleId,n=t.shiftKey&&i?this.#Ht.spanInstanceContainer.rangeBlockSpan(i,e):[];zw(this.#Ie,n,t,e);const s=this.#Ie.span.all.map(t=>t.entities.at(0)).map(t=>t.id);this.#Ie.add("entity",s)}}class Fw{createSpanWithTouchDevice(){}expandSpanWithTouchDevice(){}shrinkSpanWithTouchDevice(){}editTextWithTouchDevice(){}editProperties(){}relationClicked(){}relationBollardClicked(t){t.focus()}applyTextSelectionWithTouchDevice(){}manipulateAttribute(){}showPallet(){}hidePallet(){}get isPalletShown(){return!1}updateSelectedTextOffsets(){}}class Xw extends u{constructor(t,e,i,n){const s=()=>{const t=n();t&&this.resolveFunc(t),super.close()},o={text:"OK",click:s};i.buttons=i.buttons?i.buttons.concat([o]):[o],super(t,e,i),r()(super.el,".textae-editor__promise-dialog__observable-element","keyup",t=>{13===t.keyCode&&s()})}open(){return super.open(),new Promise(t=>this.resolveFunc=t)}}class Hw extends Xw{constructor(t,e,i,n,s,o){const a=[];n&&a.unshift({class:"textae-editor__edit-numeric-attribute-dialog__remove-attribute",click:()=>{this.close(),this.resolveFunc({newObj:null})}}),o&&a.unshift({text:"...",title:"configuration",click:()=>{this.close(),o.show(),o.showAttribute(e.pred)}}),super(`Attribute [${i.map(({id:t})=>t||"-").join(",")}]`,function(t){const{subjects:e,pred:i,min:n,max:s,step:o,value:r}=t;return ot`
305
305
  <div class="textae-editor__edit-numeric-attribute-dialog__container">
306
306
  <div class="textae-editor__edit-numeric-attribute-dialog__row">
307
307
  <label>Subject</label>
@@ -332,7 +332,7 @@ var i,n=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?
332
332
  value="${r}"
333
333
  autofocus>
334
334
  </div>
335
- </div>`}({subjects:`${i.map(({subj:t})=>t||"-").join(", ")}`,pred:e.pred,value:e.obj,min:t.min,max:t.max,step:t.step}),{buttons:a},()=>({newObj:super.el.querySelector(".textae-editor__edit-numeric-attribute-dialog__value").value})),s&&r()(super.el,".textae-editor__edit-numeric-attribute-dialog__subject-edit-button","click",()=>{this.close(),s()})}}function Ww(t,e,i,n,s,o){new Hw(e,i,t.all.reduce((t,e)=>(t.push(e.attributes.find(t=>t.pred==i.pred)),t),[]),!0,s,o).open().then(({newObj:i})=>{const s=i?n.factory.changeAttributeObjOfItemsCommand(t.all,e,i):n.factory.removeAttributesFromItemsByPredCommand(t.all,e);n.invoke(s)})}class Vw{#Ms;#Qs;#c;constructor(t,e){this.#Ms=t,this.#Qs=e,this.#c=document.createElement("ul"),this.#c.setAttribute("popover","manual"),this.#c.classList.add("popover-autocomplete-container"),this.#c.style.margin=0,t.parentElement.appendChild(this.#c)}get element(){return this.#c}set items(t){if(t.length>0){this.#c.innerHTML="";const e=t.map((t,e)=>function(t,e,i){const n=document.createElement("li");if(n.classList.add("popover-autocomplete-item"),"object"==typeof t&&null!==t)for(const[e,i]of Object.entries(t))n.dataset[e]=i;else n.dataset.value=t;return n.dataset.index=e,n.textContent=i(t),n}(t,e,this.#Qs));this.#c.append(...e),this.#Ds(),this.#c.showPopover()}else this.#c.hidePopover()}highlight(t){this.#Rs();const e=this.#c.querySelector(`li:nth-child(${t+1})`);e&&e.classList.add("popover-autocomplete-item-highlighted")}#Ds(){const t=this.#Ms.getBoundingClientRect();Object.assign(this.#c.style,{position:"absolute",top:`${t.bottom+window.scrollY}px`,left:`${t.left+window.scrollX}px`})}#Rs(){const t=this.#c.querySelector(".popover-autocomplete-item-highlighted");t&&t.classList.remove("popover-autocomplete-item-highlighted")}}class Yw{#Is;#Ls;#Ns;#js;#zs="";#In=[];#Bs=-1;constructor(t,e,i,n){this.#Is=t,this.#Ls=e,this.#Ns=i,this.#js=n}get term(){return this.#zs}set term(t){this.#zs=t,this.#zs.length>=this.#js?this.#Is(this.#zs):this.clearItems()}get itemsCount(){return this.#In.length}get hasItems(){return this.#In.length>0}get hasNoItems(){return 0===this.#In.length}set items(t){this.#In=t,this.clearHighlight(),this.#Ls(this.#In)}get highlightedIndex(){return this.#Bs}set highlightedIndex(t){this.#Bs=t,this.#Ns(this.#Bs)}clearItems(){this.items=[]}clearHighlight(){this.highlightedIndex=-1}moveHighlightIndexPrevious(){this.highlightedIndex>=0?this.highlightedIndex--:this.highlightedIndex=this.itemsCount-1}moveHighlightIndexNext(){this.highlightedIndex<this.itemsCount-1?this.highlightedIndex++:this.clearHighlight()}}class Uw{#qs;#Zs;#Fs;constructor({inputElement:t,onSearch:e,onSelect:i,onRender:n=t=>t,minLength:s=3}){this.#qs=i,this.#Zs=new Vw(t,n),this.#Fs=new Yw(t=>e(t,t=>this.#Fs.items=t),t=>this.#Zs.items=t,t=>this.#Zs.highlight(t),s),this.#Xs(t),this.#Hs(this.#Zs.element),this.#Ws()}#Xs(t){const e=n(t=>{this.#Fs.term=t},300);t.addEventListener("input",({target:t})=>e(t.value)),t.addEventListener("keydown",t=>this.#Vs(t)),t.addEventListener("keyup",t=>this.#Ys(t))}#Hs(t){this.#Us(t,"mousedown","li",({delegateTarget:e})=>{this.#qs(e.dataset),t.hidePopover()}),this.#Us(t,"mouseover","li",({delegateTarget:t})=>{this.#Fs.highlightedIndex=Number(t.dataset.index)}),this.#Us(t,"mouseout","li",()=>{this.#Fs.clearHighlight()})}#Ws(){document.addEventListener("mousedown",({target:t})=>{this.#Zs.element.contains(t)||this.#Fs.clearItems()}),window.addEventListener("resize",()=>this.#Fs.clearItems())}#Us(t,e,i,n){t.addEventListener(e,({target:t})=>{const e=t.closest(i);e&&n({delegateTarget:e})})}#Vs(t){if(!this.#Fs.hasNoItems)switch(t.key){case"ArrowDown":t.preventDefault(),this.#Fs.moveHighlightIndexNext();break;case"ArrowUp":t.preventDefault(),this.#Fs.moveHighlightIndexPrevious();break;case"Tab":t.preventDefault(),t.shiftKey?this.#Fs.moveHighlightIndexPrevious():this.#Fs.moveHighlightIndexNext();break;case"Escape":t.preventDefault(),this.#Fs.clearItems()}}#Ys(t){if("Enter"===t.key&&this.#Fs.hasItems){t.stopPropagation();const e=document.querySelector(".popover-autocomplete-item-highlighted");e&&this.#qs(e.dataset),this.#Fs.clearItems()}}}class Gw extends Xw{constructor(t,e,i,n,s,o){const a=[];n&&a.unshift({class:"textae-editor__edit-string-attribute-dialog__remove-attribute",click:()=>{this.close(),this.resolveFunc({newObj:null})}}),o&&a.unshift({text:"...",title:"configuration",click:()=>{this.close(),o.show(),o.showAttribute(e.pred)}}),super(`Attribute [${i.map(({id:t})=>t||"-").join(",")}]`,function(t){const{subjects:e,pred:i,value:n,label:s}=t;return ot`
335
+ </div>`}({subjects:`${i.map(({subj:t})=>t||"-").join(", ")}`,pred:e.pred,value:e.obj,min:t.min,max:t.max,step:t.step}),{buttons:a},()=>({newObj:super.el.querySelector(".textae-editor__edit-numeric-attribute-dialog__value").value})),s&&r()(super.el,".textae-editor__edit-numeric-attribute-dialog__subject-edit-button","click",()=>{this.close(),s()})}}function Ww(t,e,i,n,s,o){new Hw(e,i,t.all.reduce((t,e)=>(t.push(e.attributes.find(t=>t.pred==i.pred)),t),[]),!0,s,o).open().then(({newObj:i})=>{const s=i?n.factory.changeAttributeObjOfItemsCommand(t.all,e,i):n.factory.removeAttributesFromItemsByPredCommand(t.all,e);n.invoke(s)})}class Vw{#Ms;#Qs;#c;constructor(t,e){this.#Ms=t,this.#Qs=e,this.#c=document.createElement("ul"),this.#c.setAttribute("popover","manual"),this.#c.classList.add("popover-autocomplete-container"),this.#c.style.margin=0,t.parentElement.appendChild(this.#c)}get element(){return this.#c}set items(t){if(t.length>0){this.#c.innerHTML="";const e=t.map((t,e)=>function(t,e,i){const n=document.createElement("li");if(n.classList.add("popover-autocomplete-item"),"object"==typeof t&&null!==t)for(const[e,i]of Object.entries(t))n.dataset[e]=i;else n.dataset.value=t;return n.dataset.index=e,n.textContent=i(t),n}(t,e,this.#Qs));this.#c.append(...e),this.#Ds(),this.#c.showPopover()}else this.#c.hidePopover()}highlight(t){this.#Rs();const e=this.#c.querySelector(`li:nth-child(${t+1})`);e&&e.classList.add("popover-autocomplete-item-highlighted")}#Ds(){const t=this.#Ms.getBoundingClientRect();Object.assign(this.#c.style,{position:"absolute",top:`${t.bottom+window.scrollY}px`,left:`${t.left+window.scrollX}px`})}#Rs(){const t=this.#c.querySelector(".popover-autocomplete-item-highlighted");t&&t.classList.remove("popover-autocomplete-item-highlighted")}}class Yw{#Is;#Ls;#Ns;#js;#zs="";#Rn=[];#Bs=-1;constructor(t,e,i,n){this.#Is=t,this.#Ls=e,this.#Ns=i,this.#js=n}get term(){return this.#zs}set term(t){this.#zs=t,this.#zs.length>=this.#js?this.#Is(this.#zs):this.clearItems()}get itemsCount(){return this.#Rn.length}get hasItems(){return this.#Rn.length>0}get hasNoItems(){return 0===this.#Rn.length}set items(t){this.#Rn=t,this.clearHighlight(),this.#Ls(this.#Rn)}get highlightedIndex(){return this.#Bs}set highlightedIndex(t){this.#Bs=t,this.#Ns(this.#Bs)}clearItems(){this.items=[]}clearHighlight(){this.highlightedIndex=-1}moveHighlightIndexPrevious(){this.highlightedIndex>=0?this.highlightedIndex--:this.highlightedIndex=this.itemsCount-1}moveHighlightIndexNext(){this.highlightedIndex<this.itemsCount-1?this.highlightedIndex++:this.clearHighlight()}}class Uw{#qs;#Zs;#Fs;constructor({inputElement:t,onSearch:e,onSelect:i,onRender:n=t=>t,minLength:s=3}){this.#qs=i,this.#Zs=new Vw(t,n),this.#Fs=new Yw(t=>e(t,t=>this.#Fs.items=t),t=>this.#Zs.items=t,t=>this.#Zs.highlight(t),s),this.#Xs(t),this.#Hs(this.#Zs.element),this.#Ws()}#Xs(t){const e=n(t=>{this.#Fs.term=t},300);t.addEventListener("input",({target:t})=>e(t.value)),t.addEventListener("keydown",t=>this.#Vs(t)),t.addEventListener("keyup",t=>this.#Ys(t))}#Hs(t){this.#Us(t,"mousedown","li",({delegateTarget:e})=>{this.#qs(e.dataset),t.hidePopover()}),this.#Us(t,"mouseover","li",({delegateTarget:t})=>{this.#Fs.highlightedIndex=Number(t.dataset.index)}),this.#Us(t,"mouseout","li",()=>{this.#Fs.clearHighlight()})}#Ws(){document.addEventListener("mousedown",({target:t})=>{this.#Zs.element.contains(t)||this.#Fs.clearItems()}),window.addEventListener("resize",()=>this.#Fs.clearItems())}#Us(t,e,i,n){t.addEventListener(e,({target:t})=>{const e=t.closest(i);e&&n({delegateTarget:e})})}#Vs(t){if(!this.#Fs.hasNoItems)switch(t.key){case"ArrowDown":t.preventDefault(),this.#Fs.moveHighlightIndexNext();break;case"ArrowUp":t.preventDefault(),this.#Fs.moveHighlightIndexPrevious();break;case"Tab":t.preventDefault(),t.shiftKey?this.#Fs.moveHighlightIndexPrevious():this.#Fs.moveHighlightIndexNext();break;case"Escape":t.preventDefault(),this.#Fs.clearItems()}}#Ys(t){if("Enter"===t.key&&this.#Fs.hasItems){t.stopPropagation();const e=document.querySelector(".popover-autocomplete-item-highlighted");e&&this.#qs(e.dataset),this.#Fs.clearItems()}}}class Gw extends Xw{constructor(t,e,i,n,s,o){const a=[];n&&a.unshift({class:"textae-editor__edit-string-attribute-dialog__remove-attribute",click:()=>{this.close(),this.resolveFunc({newObj:null})}}),o&&a.unshift({text:"...",title:"configuration",click:()=>{this.close(),o.show(),o.showAttribute(e.pred)}}),super(`Attribute [${i.map(({id:t})=>t||"-").join(",")}]`,function(t){const{subjects:e,pred:i,value:n,label:s}=t;return ot`
336
336
  <div class="textae-editor__edit-string-attribute-dialog__container">
337
337
  <div class="textae-editor__edit-numeric-attribute-dialog__row">
338
338
  <label>Subject</label>
@@ -886,7 +886,7 @@ var i,n=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?
886
886
  color: "${i||""}"
887
887
  </div>
888
888
  </div>
889
- `}(c);case"numeric":return D_(c);case"selection":return R_(c,s);case"string":return I_(c);default:throw"attrDef.valueType is unknown attribute"}}function N_(t){for(const e of t.querySelectorAll(".textae-editor__pallet__attribute"))e.addEventListener("mousedown",t=>{t.stopPropagation()})}class j_ extends e_{#Vt;#jt;#J;#Gs;#ii;#do;constructor(t,e,i,n,s,o,a,l,c,h){super(t,l,h),this.#Vt=i,this.#jt=n,this.#J=s,this.#Gs=o,this.#ii=c,r()(this._el,".textae-editor__pallet__import-button","click",()=>e.emit("textae-event.pallet.import-button.click")),r()(this._el,".textae-editor__pallet__upload-button","click",()=>e.emit("textae-event.pallet.upload-button.click")),C_(this,this._el,a,o),e.on("textae-event.type-definition.attribute.create",t=>{this.showAttribute(t)}).on("textae-event.type-definition.attribute.change",t=>{this.showAttribute(t)}).on("textae-event.type-definition.attribute.delete",()=>{this.showAttribute(null)}).on("textae-event.type-definition.attribute.move",()=>{this.updateDisplay()}),e.on("textae-event.annotation-data.events-observer.unsaved-change",()=>this.updateDisplay()),e.on("textae-event.selection.entity.change",()=>this.updateDisplay()),e.on("textae-event.editor.unselect",()=>this.hide()).on("textae-event.resource.configuration.save",()=>this.updateDisplay()).on("textae-event.type-definition.lock",()=>this.updateDisplay()),e.on("textae-event.type-definition.entity.change",()=>this.updateDisplay()).on("textae-event.type-definition.entity.delete",()=>this.updateDisplay()).on("textae-event.type-definition.entity.change-default",()=>this.updateDisplay()).on("textae-event.type-definition.relation.change",()=>this.updateDisplay()).on("textae-event.type-definition.relation.delete",()=>this.updateDisplay()).on("textae-event.type-definition.relation.change-default",()=>this.updateDisplay())}updateDisplay(){super.updateDisplay(),N_(this._el)}showPallet(){this.show()}hidePallet(){this.hide()}show(){this.#do=null,super.show(),N_(this._el)}showAttribute(t){this.#do=t,this.updateDisplay()}selectLeftAttributeTab(){this.#do&&(0===this.#fo?this.showAttribute():this.showAttribute(this.#po[this.#fo-1].pred))}selectRightAttributeTab(){if(this.#do){if(this.#fo===this.#po.length-1)return;this.showAttribute(this.#po[this.#fo+1].pred)}else this.#po.length&&this.showAttribute(this.#po[0].pred)}get#fo(){return this.#po.findIndex(t=>t.pred===this.#do)}get _content(){return L_(this.#J.pallet,this.#ii.diffOfConfiguration,this.#do,this.#Gs,this.#Vt.attribute,this.#jt.all,this.#Vt.isLock)}get attrDef(){return this.#Vt.attribute.get(this.#do)}get#po(){return this.#Vt.attribute.attributes}}class z_{static create(t,e,i,n,s,o,a,l,c,h,u,d,f,p){const m=new j_(t,e,i,n,s,o,a,l,c,h);return function(t,e,i,n,s,o){r()(t.el,".textae-editor__pallet__add-button","click",()=>{new d_(i).open().then(({newType:t})=>e.invoke(e.factory.createTypeDefinitionCommand(i,t)))}),r()(t.el,".textae-editor__pallet__label","click",t=>e.invoke(e.factory.changeTypeOfSelectedItemsCommand(n,t.delegateTarget.dataset.id))),r()(t.el,".textae-editor__pallet__select-all","click",t=>{if(!p_(t.target))return;s.removeAll();const e=o.getInstanceContainerFor(n).findByType(t.delegateTarget.dataset.id).map(({id:t})=>t);s.add(n,e)}),r()(t.el,".textae-editor__pallet__edit-type","click",t=>{new f_(i,t.target.dataset.id,t.target.dataset.color.toLowerCase(),"true"===t.target.dataset.isDefault).open().then(({id:t,changedProperties:s})=>{s.size&&e.invoke(e.factory.changeTypeDefinitionCommand(i,n,t,s))})}),r()(t.el,".textae-editor__pallet__remove","click",t=>{if(!p_(t.target))return;const{id:n}=t.delegateTarget.dataset,{label:s}=t.delegateTarget.dataset,o={id:n,label:s||""};if(void 0===n)throw new Error("You must set the type id to remove.");e.invoke(e.factory.removeTypeDefinitionCommand(i,o))})}(m,a,s,u,d,f),je(p,()=>m,["showPallet","hidePallet","selectLeftAttributeTab","selectRightAttributeTab"]),this.#mo(t,m),m}static#mo(t,e){t.appendChild(e.el)}}class B_ extends Fw{#go;#xs;#O;#vo;#Ht;#Ie;#ii;#ws;constructor(t,e,i,n,s,o,r,a){super(),this.#ws=z_.create(t,e,i.typeDictionary,i.attributeInstanceContainer,i.typeDictionary.block,n.entity,o,"Block configuration",r,a,"entity",n,i,this);const l=new jw(t,i,s,o,r,n);this.#go=new Zw(t,i,n,l,this.#ws),this.#vo=new h_(t,o,this.#ws,"Block",a,i.typeDictionary.block,i,"Entity"),this.#Ie=n,this.#xs=l,this.#O=t.querySelector(".textae-editor__text-box"),this.#Ht=i,this.#ii=r;const c=new Jw(o,i.typeDictionary,n.entity,new i_(t,a),()=>this.editProperties(),this.#ws);je(this,()=>c,["manipulateAttribute"])}bindMouseEvents(){return this.#go.bind()}editProperties(){this.#vo.startEditing(this.#Ie.entity)}get isPalletShown(){return this.#ws.visibly}createSpanWithTouchDevice(){console.log("createSpanWithTouchDevice"),this.#xs.cerateSpanForTouchDevice()}expandSpanWithTouchDevice(){this.#xs.expandForTouchDevice()}shrinkSpanWithTouchDevice(){this.#xs.shrinkForTouchDevice()}applyTextSelectionWithTouchDevice(){if(Bw(this.#O)){const{begin:t,end:e}=this.#Ht.textSelection,i=this.#Ht.isBoundaryCrossingWithOtherSpans(t,e),{isParentOfBothNodesTextBox:n}=new Nw;this.#ii.updateButtonsToOperateSpanWithTouchDevice(n,i,i,!1)}else this.#ii.updateButtonsToOperateSpanWithTouchDevice(!1,!1,!1,!1)}}class q_{#Q;#Ie;#ei;#Vt;#ws;constructor(t,e,i,n,s){this.#Q=t,this.#Ie=e,this.#ei=i,this.#Vt=n,this.#ws=s}bind(){const t=[];return t.push(r()(this.#Q,".textae-editor__text-box","click",()=>this.#Ss())),t.push(r()(this.#Q,".textae-editor","click",t=>{t.target.classList.contains("textae-editor")&&this.#Ss()})),t.push(r()(this.#Q,".textae-editor__signboard","mousedown",()=>this.#ks())),t.push(r()(this.#Q,".textae-editor__signboard__type-values","click",t=>{const e=qw(t.target).dataset.id;this.#$s(t,e)})),t}#Ss(){this.#ws.hide(),this.#Ie.removeAll()}#ks(){this.#Q.focus()}#$s(t,e){!function(t,e,i,n,s){if(t.entity.some){const o=t.entity.singleId,r=s;o===r?t.entity.toggle(o):(e.invoke(e.factory.createRelationCommand({subj:o,obj:r,pred:i.defaultType})),function(t,e,i,n){t.ctrlKey||t.metaKey?e.remove("entity",n):t.shiftKey?(e.remove("entity",i),e.add("entity",[n])):(e.remove("entity",i),e.remove("entity",n))}(n,t,o,r))}else t.selectEntity(s)}(this.#Ie,this.#ei,this.#Vt.relation,t,e)}}class Z_ extends Fw{#go;#vo;#Ie;#ws;constructor(t,e,i,n,s,o,r){super(),this.#ws=z_.create(t,e,i.typeDictionary,i.attributeInstanceContainer,i.typeDictionary.relation,n.relation,s,"Relation configuration",o,r,"relation",n,i,this),this.#go=new q_(t,n,s,i.typeDictionary,this.#ws),this.#vo=new h_(t,s,this.#ws,"Relation",r,i.typeDictionary.relation,i,"Relation"),this.#Ie=n;const a=new Jw(s,i.typeDictionary,n.relation,new i_(t,r),()=>this.editProperties(),this.#ws);je(this,()=>a,["manipulateAttribute"])}bindMouseEvents(){return this.#go.bind()}editProperties(){this.#vo.startEditing(this.#Ie.relation)}get isPalletShown(){return this.#ws.visibly}relationClicked(t,e){t.ctrlKey||t.metaKey?this.#Ie.relation.toggle(e.id):this.#Ie.selectRelation(e.id)}relationBollardClicked(t){t.span.forceRenderGrid(),this.#Ie.selectEntity(t.id)}}class F_{#Q;#Ht;#Ie;#xs;#ws;constructor(t,e,i,n,s){this.#Q=t,this.#Ht=e,this.#Ie=i,this.#xs=s,this.#ws=n}bind(){const t=[];let e=!1;return t.push(r()(this.#Q,".textae-editor__text-box","click",t=>{t.target.classList.contains("textae-editor__text-box")&&!e&&this.#_s()})),t.push(r()(this.#Q,".textae-editor","click",t=>{t.target.classList.contains("textae-editor")&&this.#Ss()})),t.push(r()(this.#Q,".textae-editor__signboard","mousedown",()=>this.#ks())),t.push(r()(this.#Q,".textae-editor__signboard__type-values","click",t=>{const e=qw(t.target).dataset.id;this.#$s(t,e)})),t.push(r()(this.#Q,".textae-editor__span","mouseup",t=>{t.target.classList.contains("textae-editor__span")&&(this.#Es(t),e=!0,setTimeout(()=>e=!1,0))})),t.push(r()(this.#Q,".textae-editor__block","mouseup",t=>{t.target.classList.contains("textae-editor__block")&&this.#Cs(t)})),t.push(r()(this.#Q,".textae-editor__style","mouseup",t=>{t.target.classList.contains("textae-editor__style")&&this.#Ps(t)})),t}#Ss(){this.#ws.hide(),this.#Ie.removeAll()}#_s(){this.#ws.hide();window.getSelection();Bw(this.#Q.querySelector(".textae-editor__text-box"))?this.#xs.editFor():this.#Ie.removeAll()}#Es(t){2===t.button&&Iw();const e=window.getSelection();"Caret"!==e.type&&"None"!==e.type||this.#yo(t,t.target.id),Bw(this.#Q.querySelector(".textae-editor__text-box"))&&this.#xs.editFor()}#Cs(t){2===t.button&&Iw();"Caret"===window.getSelection().type&&this.#Ie.removeAll(),Bw(this.#Q.querySelector(".textae-editor__text-box"))&&this.#xs.editFor()}#Ps(t){2===t.button&&Iw();if("Caret"===window.getSelection().type){const e=t.target.closest(".textae-editor__span");e?this.#yo(t,e.id):this.#Ie.removeAll()}Bw(this.#Q.querySelector(".textae-editor__text-box"))&&this.#xs.editFor()}#ks(){this.#Q.focus()}#$s(t,e){this.#Ht.entityInstanceContainer.get(e).isDenotation&&(t.ctrlKey||t.metaKey?this.#Ie.entity.toggle(e):this.#Ie.selectEntity(e))}#yo(t,e){const i=this.#Ie.span.singleId,n=t.shiftKey&&i?this.#Ht.spanInstanceContainer.rangeDenotationSpan(i,e):[];zw(this.#Ie,n,t,e)}}class X_{#Q;#Ht;#Ie;#ei;#ii;#ni;constructor(t,e,i,n,s,o){this.#Q=t,this.#Ht=e,this.#Ie=i,this.#ei=n,this.#ii=s,this.#ni=o}editFor(){const t=new Nw;if(t.isParentOfAnchorNodeTextBox){if(t.isParentOfFocusNodeTextBox)return void this.#Oo();if(t.isParentOfFocusNodeDenotationSpan)return void this.#bo(t);if(t.isParentOfFocusNodeBlockSpan)return void this.#xo(t);if(t.isParentOfFocusNodeStyleSpan)return void this.#wo(t)}if(t.isParentOfAnchorNodeDenotationSpan){if(t.isParentOfFocusNodeTextBox)return void this.#_o(t);if(t.isParentOfFocusNodeDenotationSpan)return void this.#So(t);if(t.isParentOfFocusNodeBlockSpan)return void this.#ko(t);if(t.isParentOfFocusNodeStyleSpan)return void this.#$o(t)}if(t.isParentOfAnchorNodeBlockSpan){if(t.isParentOfFocusNodeTextBox)return void this.#Co(t);if(t.isParentOfFocusNodeDenotationSpan)return void this.#To(t);if(t.isParentOfFocusNodeBlockSpan)return void this.#Po(t);if(t.isParentOfFocusNodeStyleSpan)return void this.#Eo(t)}if(t.isParentOfAnchorNodeStyleSpan){if(t.isParentOfFocusNodeTextBox)return void this.#Ao(t);if(t.isParentOfFocusNodeDenotationSpan)return void this.#Mo(t);if(t.isParentOfFocusNodeBlockSpan)return void this.#Qo(t);if(t.isParentOfFocusNodeStyleSpan)return void this.#Do(t)}}cerateSpanForTouchDevice(){(new Nw).isParentOfBothNodesSame&&this.#gs()}expandForTouchDevice(){const t=this.#Os();if(t){const{spanID:e,begin:i,end:n}=t;if(this.#Ht.isBoundaryCrossingWithOtherSpans(i,n))return;if(this.#Ht.findDenotation(i,n))return;this.#ei.invoke(this.#ei.factory.moveDenotationSpanCommand(e,i,n))}}shrinkForTouchDevice(){const t=this.#bs();if(t){const{spanID:i,begin:n,end:s}=t,o=L(this.#Q,i);if(this.#Ht.isBoundaryCrossingWithOtherSpans(n,s))return void e().warning("A span cannot be shrunken to make a boundary crossing.");const r=this.#Ht.findDenotation(n,s);n<s&&!r?this.#ei.invoke(this.#ei.factory.moveDenotationSpanCommand(i,n,s)):(this.#ei.invoke(this.#ei.factory.removeSpanCommand(i)),o&&this.#Ie.selectSpan(o.id))}}#Os(){const t=new Nw;if(null==t.ancestorDenotationSpanOfAnchorNode&&null==t.ancestorDenotationSpanOfFocusNode)return null;if(t.parentOfFocusNode.contains(t.parentOfAnchorNode)){const e=t.ancestorDenotationSpanOfAnchorNode.id;return{spanID:e,...this.#Ht.getSpan(e).getExpandedInAnchorNodeToFocusNodeDirection(this.#ii.textSelectionAdjuster,this.#Ht.sourceDoc,this.#ni)}}if(t.parentOfAnchorNode.contains(t.parentOfFocusNode)){const e=t.ancestorDenotationSpanOfFocusNode.id;return{spanID:e,...this.#Ht.getSpan(e).getExpandedInFocusNodeToAnchorNodeDirection(this.#ii.textSelectionAdjuster,this.#Ht.sourceDoc,this.#ni)}}}#bs(){const t=new Nw;if(null==t.ancestorDenotationSpanOfAnchorNode&&null==t.ancestorDenotationSpanOfFocusNode)return null;if(t.parentOfAnchorNode===t.parentOfFocusNode)return null;if(t.parentOfFocusNode.contains(t.parentOfAnchorNode)){const e=t.ancestorDenotationSpanOfAnchorNode.id;return{spanID:e,...this.#Ht.getSpan(e).getShortenInFocusNodeToAnchorNodeDirection(this.#ii.textSelectionAdjuster,this.#Ht.sourceDoc,this.#ni)}}if(t.parentOfAnchorNode.contains(t.parentOfFocusNode)){const e=t.ancestorDenotationSpanOfFocusNode.id;return{spanID:e,...this.#Ht.getSpan(e).getShortenInAnchorNodeToFocusNodeDirection(this.#ii.textSelectionAdjuster,this.#Ht.sourceDoc,this.#ni)}}}#Oo(){this.#gs()}#bo(t){const e=this.#Ro(t);e?this.#vs(e):Iw()}#xo(){Iw()}#wo(t){const e=this.#Ro(t);e?this.#vs(e):this.#gs()}#_o(t){this.#ys(t.parentOfAnchorNode.id)}#So(t){const e=this.#Io(t);if(e)return void this.#vs(e);if(t.isParentOfBothNodesSame)return void this.#gs();const i=this.#Ro(t);i?this.#vs(i):this.#ys(t.parentOfAnchorNode.id)}#ko(t){t.parentOfFocusNode.contains(t.parentOfAnchorNode)?this.#ys(t.parentOfAnchorNode.id):Iw()}#$o(t){const e=this.#Io(t);if(e)return void this.#vs(e);if(t.parentOfAnchorNode===t.ancestorDenotationSpanOfFocusNode)return void this.#gs();const i=this.#Lo(t);if(i)return void this.#ys(i);const n=this.#Ro(t);n&&this.#vs(n)}#Co(){Iw()}#To(t){const e=this.#Ro(t);e?this.#vs(e):Iw()}#Po(t){this.#gs()}#Eo(t){const e=this.#Ro(t);e?this.#vs(e):Iw()}#Ao(t){if(t.ancestorDenotationSpanOfAnchorNode){const e=t.ancestorDenotationSpanOfAnchorNode.id;return void(e&&this.#ys(e))}this.#gs()}#Mo(t){const e=this.#Io(t);if(e)return void this.#vs(e);if(t.ancestorDenotationSpanOfAnchorNode===t.parentOfFocusNode)return void this.#gs();const i=this.#Ro(t);if(i)return void this.#vs(i);const n=this.#Lo(t);n?this.#ys(n):Iw()}#Qo(t){const e=this.#Lo(t);e?this.#ys(e):this.#gs()}#Do(t){const e=this.#Io(t);if(e)return void this.#vs(e);if(t.isParentOfBothNodesSame||t.isParentsParentOfAnchorNodeAndFocusedNodeSame)return void this.#gs();const i=this.#Lo(t);i?this.#ys(i):Iw()}#Io(t){if(t.ancestorDenotationSpanOfAnchorNode){const{anchor:e}=this.#Ht.textSelection,{begin:i,end:n}=this.#Ht.getDenotationSpan(t.ancestorDenotationSpanOfAnchorNode.id);if(e===i||e===n){if(t.ancestorDenotationSpanOfAnchorNode===t.ancestorDenotationSpanOfFocusNode)return t.ancestorDenotationSpanOfAnchorNode.id;if(t.ancestorDenotationSpanOfAnchorNode!==t.ancestorDenotationSpanOfFocusNode&&t.ancestorDenotationSpanOfFocusNode.contains(t.ancestorDenotationSpanOfAnchorNode))return t.ancestorDenotationSpanOfFocusNode.id}}}#Ro(t){const e=t.ancestorDenotationSpanOfFocusNode;return!e||t.ancestorDenotationSpanOfAnchorNode===e||t.ancestorDenotationSpanOfAnchorNode&&!t.ancestorDenotationSpanOfAnchorNode.contains(e)?t.isAnchorNodeParentIsDescendantOfFocusNodeParent&&(i=this.#Ie.span.single,n=this.#Ht.textSelection.focus,i&&i.begin<n&&n<i.end)?this.#Ie.span.single.element.id:void 0:e.id;var i,n}#Lo(t){const e=t.ancestorDenotationSpanOfAnchorNode;if(e){const{ancestorDenotationSpanOfFocusNode:i}=t;if(!i)return e.id;if(e!==i&&(e.parentElement===i.parentElement||i.contains(e)))return e.id}}#gs(){this.#Ht.hasCharacters(this.#ni)&&(this.#Ie.removeAll(),function(t,e,i,n,s,o){const{begin:r,end:a}=t.getTextSelection(s,i);if(t.validateNewDenotationSpan(r,a)){const t=e.factory.createSpanAndAutoReplicateCommand({begin:r,end:a},n,o);e.invoke(t)}}(this.#Ht,this.#ei,this.#ii.textSelectionAdjuster,this.#No,this.#ni,pn(this.#ii,this.#ni))),Iw()}#ys(t){this.#Ie.removeAll();const{begin:e,end:i}=this.#Ht.getSpan(t).getExpandedInAnchorNodeToFocusNodeDirection(this.#ii.textSelectionAdjuster,this.#Ht.sourceDoc,this.#ni);this.#Ht.validateNewDenotationSpan(e,i)&&this.#ei.invoke(this.#ei.factory.moveDenotationSpanCommand(t,e,i)),Iw()}#vs(t){Lw(this.#Q,this.#Ht,this.#Ht.sourceDoc,this.#Ie,this.#ei,this.#ii.textSelectionAdjuster,t,this.#ni,(e,i)=>{this.#ei.invoke(this.#ei.factory.moveDenotationSpanCommand(t,e,i))}),Iw()}get#No(){return this.#ii.isPushed("auto replicate")}}class H_ extends Fw{#go;#xs;#O;#Ht;#vo;#Ie;#ii;#ws;constructor(t,e,i,n,s,o,r,a){super(),this.#ws=z_.create(t,e,i.typeDictionary,i.attributeInstanceContainer,i.typeDictionary.denotation,n.entity,s,"Term configuration",o,a,"entity",n,i,this);const l=new X_(t,i,n,s,o,r);this.#go=new F_(t,i,n,this.#ws,l),this.#vo=new h_(t,s,this.#ws,"Entity",a,i.typeDictionary.denotation,i,"Denotation"),this.#Ie=n,this.#xs=l,this.#O=t.querySelector(".textae-editor__text-box"),this.#Ht=i,this.#ii=o;const c=new Jw(s,i.typeDictionary,n.entity,new i_(t,a),()=>this.editProperties(),this.#ws);je(this,()=>c,["manipulateAttribute"])}bindMouseEvents(){return this.#go.bind()}editProperties(){this.#vo.startEditing(this.#Ie.entity)}get isPalletShown(){return this.#ws.visibly}createSpanWithTouchDevice(){this.#xs.cerateSpanForTouchDevice()}expandSpanWithTouchDevice(){this.#xs.expandForTouchDevice()}shrinkSpanWithTouchDevice(){this.#xs.shrinkForTouchDevice()}applyTextSelectionWithTouchDevice(){if(Bw(this.#O)){const{begin:t,end:e}=this.#Ht.textSelection,i=this.#Ht.isBoundaryCrossingWithOtherSpans(t,e),{isParentOfBothNodesSame:n}=new Nw;this.#ii.updateButtonsToOperateSpanWithTouchDevice(n,i,i,!1)}else this.#ii.updateButtonsToOperateSpanWithTouchDevice(!1,!1,!1,!1)}}class W_{#jo;constructor(t,e){const i=document.createElement("dialog");i.classList.add("textae-editor__text-edit-dialog"),t.appendChild(i),i.addEventListener("close",t=>{const i=t.target,{returnValue:n}=i;if("OK"===n){const t=i.querySelector("form"),n=parseInt(t.begin.value),s=parseInt(t.end.value),o=t.originalText.value,r=t.editedText.value;e(n,s,o,r)}}),r()(i,".textae-editor__text-edit-dialog__close-button","click",t=>{i.close()}),r()(i,".textae-editor__text-edit-dialog__text-box","keyup",t=>{t.stopPropagation()}),this.#jo=i}open(t,e,i){this.#jo.innerHTML=this.#zo({begin:t,end:e,text:i}),this.#jo.showModal()}#zo(t){const{text:e,begin:i,end:n}=t;return ot`
889
+ `}(c);case"numeric":return D_(c);case"selection":return R_(c,s);case"string":return I_(c);default:throw"attrDef.valueType is unknown attribute"}}function N_(t){for(const e of t.querySelectorAll(".textae-editor__pallet__attribute"))e.addEventListener("mousedown",t=>{t.stopPropagation()})}class j_ extends e_{#Vt;#jt;#J;#Gs;#ii;#do;constructor(t,e,i,n,s,o,a,l,c,h){super(t,l,h),this.#Vt=i,this.#jt=n,this.#J=s,this.#Gs=o,this.#ii=c,r()(this._el,".textae-editor__pallet__import-button","click",()=>e.emit("textae-event.pallet.import-button.click")),r()(this._el,".textae-editor__pallet__upload-button","click",()=>e.emit("textae-event.pallet.upload-button.click")),C_(this,this._el,a,o),e.on("textae-event.type-definition.attribute.create",t=>{this.showAttribute(t)}).on("textae-event.type-definition.attribute.change",t=>{this.showAttribute(t)}).on("textae-event.type-definition.attribute.delete",()=>{this.showAttribute(null)}).on("textae-event.type-definition.attribute.move",()=>{this.updateDisplay()}),e.on("textae-event.annotation-data.events-observer.unsaved-change",()=>this.updateDisplay()),e.on("textae-event.selection.entity.change",()=>this.updateDisplay()),e.on("textae-event.editor.unselect",()=>this.hide()).on("textae-event.resource.configuration.save",()=>this.updateDisplay()).on("textae-event.type-definition.lock",()=>this.updateDisplay()),e.on("textae-event.type-definition.entity.change",()=>this.updateDisplay()).on("textae-event.type-definition.entity.delete",()=>this.updateDisplay()).on("textae-event.type-definition.entity.change-default",()=>this.updateDisplay()).on("textae-event.type-definition.relation.change",()=>this.updateDisplay()).on("textae-event.type-definition.relation.delete",()=>this.updateDisplay()).on("textae-event.type-definition.relation.change-default",()=>this.updateDisplay())}updateDisplay(){super.updateDisplay(),N_(this._el)}showPallet(){this.show()}hidePallet(){this.hide()}show(){this.#do=null,super.show(),N_(this._el)}showAttribute(t){this.#do=t,this.updateDisplay()}selectLeftAttributeTab(){this.#do&&(0===this.#fo?this.showAttribute():this.showAttribute(this.#po[this.#fo-1].pred))}selectRightAttributeTab(){if(this.#do){if(this.#fo===this.#po.length-1)return;this.showAttribute(this.#po[this.#fo+1].pred)}else this.#po.length&&this.showAttribute(this.#po[0].pred)}get#fo(){return this.#po.findIndex(t=>t.pred===this.#do)}get _content(){return L_(this.#J.pallet,this.#ii.diffOfConfiguration,this.#do,this.#Gs,this.#Vt.attribute,this.#jt.all,this.#Vt.isLock)}get attrDef(){return this.#Vt.attribute.get(this.#do)}get#po(){return this.#Vt.attribute.attributes}}class z_{static create(t,e,i,n,s,o,a,l,c,h,u,d,f,p){const m=new j_(t,e,i,n,s,o,a,l,c,h);return function(t,e,i,n,s,o){r()(t.el,".textae-editor__pallet__add-button","click",()=>{new d_(i).open().then(({newType:t})=>e.invoke(e.factory.createTypeDefinitionCommand(i,t)))}),r()(t.el,".textae-editor__pallet__label","click",t=>e.invoke(e.factory.changeTypeOfSelectedItemsCommand(n,t.delegateTarget.dataset.id))),r()(t.el,".textae-editor__pallet__select-all","click",t=>{if(!p_(t.target))return;s.removeAll();const e=o.getInstanceContainerFor(n).findByType(t.delegateTarget.dataset.id).map(({id:t})=>t);s.add(n,e)}),r()(t.el,".textae-editor__pallet__edit-type","click",t=>{new f_(i,t.target.dataset.id,t.target.dataset.color.toLowerCase(),"true"===t.target.dataset.isDefault).open().then(({id:t,changedProperties:s})=>{s.size&&e.invoke(e.factory.changeTypeDefinitionCommand(i,n,t,s))})}),r()(t.el,".textae-editor__pallet__remove","click",t=>{if(!p_(t.target))return;const{id:n}=t.delegateTarget.dataset,{label:s}=t.delegateTarget.dataset,o={id:n,label:s||""};if(void 0===n)throw new Error("You must set the type id to remove.");e.invoke(e.factory.removeTypeDefinitionCommand(i,o))})}(m,a,s,u,d,f),je(p,()=>m,["showPallet","hidePallet","selectLeftAttributeTab","selectRightAttributeTab"]),this.#mo(t,m),m}static#mo(t,e){t.appendChild(e.el)}}class B_ extends Fw{#go;#xs;#O;#vo;#Ht;#Ie;#ii;#ws;constructor(t,e,i,n,s,o,r,a){super(),this.#ws=z_.create(t,e,i.typeDictionary,i.attributeInstanceContainer,i.typeDictionary.block,n.entity,o,"Block configuration",r,a,"entity",n,i,this);const l=new jw(t,i,s,o,r,n);this.#go=new Zw(t,i,n,l,this.#ws),this.#vo=new h_(t,o,this.#ws,"Block",a,i.typeDictionary.block,i,"Entity"),this.#Ie=n,this.#xs=l,this.#O=t.querySelector(".textae-editor__text-box"),this.#Ht=i,this.#ii=r;const c=new Jw(o,i.typeDictionary,n.entity,new i_(t,a),()=>this.editProperties(),this.#ws);je(this,()=>c,["manipulateAttribute"])}bindMouseEvents(){return this.#go.bind()}editProperties(){this.#vo.startEditing(this.#Ie.entity)}get isPalletShown(){return this.#ws.visibly}createSpanWithTouchDevice(){console.log("createSpanWithTouchDevice"),this.#xs.cerateSpanForTouchDevice()}expandSpanWithTouchDevice(){this.#xs.expandForTouchDevice()}shrinkSpanWithTouchDevice(){this.#xs.shrinkForTouchDevice()}applyTextSelectionWithTouchDevice(){if(Bw(this.#O)){const{begin:t,end:e}=this.#Ht.textSelection,i=this.#Ht.isBoundaryCrossingWithOtherSpans(t,e),{isParentOfBothNodesTextBox:n}=new Nw;this.#ii.updateButtonsToOperateSpanWithTouchDevice(n,i,i,!1)}else this.#ii.updateButtonsToOperateSpanWithTouchDevice(!1,!1,!1,!1)}}class q_{#Q;#Ie;#ei;#Vt;#ws;constructor(t,e,i,n,s){this.#Q=t,this.#Ie=e,this.#ei=i,this.#Vt=n,this.#ws=s}bind(){const t=[];return t.push(r()(this.#Q,".textae-editor__text-box","click",()=>this.#Ss())),t.push(r()(this.#Q,".textae-editor","click",t=>{t.target.classList.contains("textae-editor")&&this.#Ss()})),t.push(r()(this.#Q,".textae-editor__signboard","mousedown",()=>this.#ks())),t.push(r()(this.#Q,".textae-editor__signboard__type-values","click",t=>{const e=qw(t.target).dataset.id;this.#$s(t,e)})),t}#Ss(){this.#ws.hide(),this.#Ie.removeAll()}#ks(){this.#Q.focus()}#$s(t,e){!function(t,e,i,n,s){if(t.entity.some){const o=t.entity.singleId,r=s;o===r?t.entity.toggle(o):(e.invoke(e.factory.createRelationCommand({subj:o,obj:r,pred:i.defaultType})),function(t,e,i,n){t.ctrlKey||t.metaKey?e.remove("entity",n):t.shiftKey?(e.remove("entity",i),e.add("entity",[n])):(e.remove("entity",i),e.remove("entity",n))}(n,t,o,r))}else t.selectEntity(s)}(this.#Ie,this.#ei,this.#Vt.relation,t,e)}}class Z_ extends Fw{#go;#vo;#Ie;#ws;constructor(t,e,i,n,s,o,r){super(),this.#ws=z_.create(t,e,i.typeDictionary,i.attributeInstanceContainer,i.typeDictionary.relation,n.relation,s,"Relation configuration",o,r,"relation",n,i,this),this.#go=new q_(t,n,s,i.typeDictionary,this.#ws),this.#vo=new h_(t,s,this.#ws,"Relation",r,i.typeDictionary.relation,i,"Relation"),this.#Ie=n;const a=new Jw(s,i.typeDictionary,n.relation,new i_(t,r),()=>this.editProperties(),this.#ws);je(this,()=>a,["manipulateAttribute"])}bindMouseEvents(){return this.#go.bind()}editProperties(){this.#vo.startEditing(this.#Ie.relation)}get isPalletShown(){return this.#ws.visibly}relationClicked(t,e){t.ctrlKey||t.metaKey?this.#Ie.relation.toggle(e.id):this.#Ie.selectRelation(e.id)}relationBollardClicked(t){t.span.forceRenderGrid(),this.#Ie.selectEntity(t.id)}}class F_{#Q;#Ht;#Ie;#xs;#ws;constructor(t,e,i,n,s){this.#Q=t,this.#Ht=e,this.#Ie=i,this.#xs=s,this.#ws=n}bind(){const t=[];let e=!1;return t.push(r()(this.#Q,".textae-editor__text-box","click",t=>{t.target.classList.contains("textae-editor__text-box")&&!e&&this.#_s()})),t.push(r()(this.#Q,".textae-editor","click",t=>{t.target.classList.contains("textae-editor")&&this.#Ss()})),t.push(r()(this.#Q,".textae-editor__signboard","mousedown",()=>this.#ks())),t.push(r()(this.#Q,".textae-editor__signboard__type-values","click",t=>{const e=qw(t.target).dataset.id;this.#$s(t,e)})),t.push(r()(this.#Q,".textae-editor__span","mouseup",t=>{t.target.classList.contains("textae-editor__span")&&(this.#Es(t),e=!0,setTimeout(()=>e=!1,0))})),t.push(r()(this.#Q,".textae-editor__block","mouseup",t=>{t.target.classList.contains("textae-editor__block")&&this.#Cs(t)})),t.push(r()(this.#Q,".textae-editor__style","mouseup",t=>{t.target.classList.contains("textae-editor__style")&&this.#Ps(t)})),t}#Ss(){this.#ws.hide(),this.#Ie.removeAll()}#_s(){this.#ws.hide();window.getSelection();Bw(this.#Q.querySelector(".textae-editor__text-box"))?this.#xs.editFor():this.#Ie.removeAll()}#Es(t){2===t.button&&Iw();const e=window.getSelection();"Caret"!==e.type&&"None"!==e.type||this.#yo(t,t.target.id),Bw(this.#Q.querySelector(".textae-editor__text-box"))&&this.#xs.editFor()}#Cs(t){2===t.button&&Iw();"Caret"===window.getSelection().type&&this.#Ie.removeAll(),Bw(this.#Q.querySelector(".textae-editor__text-box"))&&this.#xs.editFor()}#Ps(t){2===t.button&&Iw();if("Caret"===window.getSelection().type){const e=t.target.closest(".textae-editor__span");e?this.#yo(t,e.id):this.#Ie.removeAll()}Bw(this.#Q.querySelector(".textae-editor__text-box"))&&this.#xs.editFor()}#ks(){this.#Q.focus()}#$s(t,e){this.#Ht.entityInstanceContainer.get(e).isDenotation&&(t.ctrlKey||t.metaKey?this.#Ie.entity.toggle(e):this.#Ie.selectEntity(e))}#yo(t,e){const i=this.#Ie.span.singleId,n=t.shiftKey&&i?this.#Ht.spanInstanceContainer.rangeDenotationSpan(i,e):[];zw(this.#Ie,n,t,e)}}class X_{#Q;#Ht;#Ie;#ei;#ii;#ni;constructor(t,e,i,n,s,o){this.#Q=t,this.#Ht=e,this.#Ie=i,this.#ei=n,this.#ii=s,this.#ni=o}editFor(){const t=new Nw;if(t.isParentOfAnchorNodeTextBox){if(t.isParentOfFocusNodeTextBox)return void this.#Oo();if(t.isParentOfFocusNodeDenotationSpan)return void this.#bo(t);if(t.isParentOfFocusNodeBlockSpan)return void this.#xo(t);if(t.isParentOfFocusNodeStyleSpan)return void this.#wo(t)}if(t.isParentOfAnchorNodeDenotationSpan){if(t.isParentOfFocusNodeTextBox)return void this.#_o(t);if(t.isParentOfFocusNodeDenotationSpan)return void this.#So(t);if(t.isParentOfFocusNodeBlockSpan)return void this.#ko(t);if(t.isParentOfFocusNodeStyleSpan)return void this.#$o(t)}if(t.isParentOfAnchorNodeBlockSpan){if(t.isParentOfFocusNodeTextBox)return void this.#Co(t);if(t.isParentOfFocusNodeDenotationSpan)return void this.#To(t);if(t.isParentOfFocusNodeBlockSpan)return void this.#Po(t);if(t.isParentOfFocusNodeStyleSpan)return void this.#Eo(t)}if(t.isParentOfAnchorNodeStyleSpan){if(t.isParentOfFocusNodeTextBox)return void this.#Ao(t);if(t.isParentOfFocusNodeDenotationSpan)return void this.#Mo(t);if(t.isParentOfFocusNodeBlockSpan)return void this.#Qo(t);if(t.isParentOfFocusNodeStyleSpan)return void this.#Do(t)}}cerateSpanForTouchDevice(){(new Nw).isParentOfBothNodesSame&&this.#gs()}expandForTouchDevice(){const t=this.#Os();if(t){const{spanID:e,begin:i,end:n}=t;if(this.#Ht.isBoundaryCrossingWithOtherSpans(i,n))return;if(this.#Ht.findDenotation(i,n))return;this.#ei.invoke(this.#ei.factory.moveDenotationSpanCommand(e,i,n))}}shrinkForTouchDevice(){const t=this.#bs();if(t){const{spanID:i,begin:n,end:s}=t,o=L(this.#Q,i);if(this.#Ht.isBoundaryCrossingWithOtherSpans(n,s))return void e().warning("A span cannot be shrunken to make a boundary crossing.");const r=this.#Ht.findDenotation(n,s);n<s&&!r?this.#ei.invoke(this.#ei.factory.moveDenotationSpanCommand(i,n,s)):(this.#ei.invoke(this.#ei.factory.removeSpanCommand(i)),o&&this.#Ie.selectSpan(o.id))}}#Os(){const t=new Nw;if(null==t.ancestorDenotationSpanOfAnchorNode&&null==t.ancestorDenotationSpanOfFocusNode)return null;if(t.parentOfFocusNode.contains(t.parentOfAnchorNode)){const e=t.ancestorDenotationSpanOfAnchorNode.id;return{spanID:e,...this.#Ht.getSpan(e).getExpandedInAnchorNodeToFocusNodeDirection(this.#ii.textSelectionAdjuster,this.#Ht.sourceDoc,this.#ni)}}if(t.parentOfAnchorNode.contains(t.parentOfFocusNode)){const e=t.ancestorDenotationSpanOfFocusNode.id;return{spanID:e,...this.#Ht.getSpan(e).getExpandedInFocusNodeToAnchorNodeDirection(this.#ii.textSelectionAdjuster,this.#Ht.sourceDoc,this.#ni)}}}#bs(){const t=new Nw;if(null==t.ancestorDenotationSpanOfAnchorNode&&null==t.ancestorDenotationSpanOfFocusNode)return null;if(t.parentOfAnchorNode===t.parentOfFocusNode)return null;if(t.parentOfFocusNode.contains(t.parentOfAnchorNode)){const e=t.ancestorDenotationSpanOfAnchorNode.id;return{spanID:e,...this.#Ht.getSpan(e).getShortenInFocusNodeToAnchorNodeDirection(this.#ii.textSelectionAdjuster,this.#Ht.sourceDoc,this.#ni)}}if(t.parentOfAnchorNode.contains(t.parentOfFocusNode)){const e=t.ancestorDenotationSpanOfFocusNode.id;return{spanID:e,...this.#Ht.getSpan(e).getShortenInAnchorNodeToFocusNodeDirection(this.#ii.textSelectionAdjuster,this.#Ht.sourceDoc,this.#ni)}}}#Oo(){this.#gs()}#bo(t){const e=this.#Ro(t);e?this.#vs(e):Iw()}#xo(){Iw()}#wo(t){const e=this.#Ro(t);e?this.#vs(e):this.#gs()}#_o(t){this.#ys(t.parentOfAnchorNode.id)}#So(t){const e=this.#Io(t);if(e)return void this.#vs(e);if(t.isParentOfBothNodesSame)return void this.#gs();const i=this.#Ro(t);i?this.#vs(i):this.#ys(t.parentOfAnchorNode.id)}#ko(t){t.parentOfFocusNode.contains(t.parentOfAnchorNode)?this.#ys(t.parentOfAnchorNode.id):Iw()}#$o(t){const e=this.#Io(t);if(e)return void this.#vs(e);if(t.parentOfAnchorNode===t.ancestorDenotationSpanOfFocusNode)return void this.#gs();const i=this.#Lo(t);if(i)return void this.#ys(i);const n=this.#Ro(t);n&&this.#vs(n)}#Co(){Iw()}#To(t){const e=this.#Ro(t);e?this.#vs(e):Iw()}#Po(t){this.#gs()}#Eo(t){const e=this.#Ro(t);e?this.#vs(e):Iw()}#Ao(t){if(t.ancestorDenotationSpanOfAnchorNode){const e=t.ancestorDenotationSpanOfAnchorNode.id;return void(e&&this.#ys(e))}this.#gs()}#Mo(t){const e=this.#Io(t);if(e)return void this.#vs(e);if(t.ancestorDenotationSpanOfAnchorNode===t.parentOfFocusNode)return void this.#gs();const i=this.#Ro(t);if(i)return void this.#vs(i);const n=this.#Lo(t);n?this.#ys(n):Iw()}#Qo(t){const e=this.#Lo(t);e?this.#ys(e):this.#gs()}#Do(t){const e=this.#Io(t);if(e)return void this.#vs(e);if(t.isParentOfBothNodesSame||t.isParentsParentOfAnchorNodeAndFocusedNodeSame)return void this.#gs();const i=this.#Lo(t);i?this.#ys(i):Iw()}#Io(t){if(t.ancestorDenotationSpanOfAnchorNode){const{anchor:e}=this.#Ht.textSelection,{begin:i,end:n}=this.#Ht.getDenotationSpan(t.ancestorDenotationSpanOfAnchorNode.id);if(e===i||e===n){if(t.ancestorDenotationSpanOfAnchorNode===t.ancestorDenotationSpanOfFocusNode)return t.ancestorDenotationSpanOfAnchorNode.id;if(t.ancestorDenotationSpanOfAnchorNode!==t.ancestorDenotationSpanOfFocusNode&&t.ancestorDenotationSpanOfFocusNode.contains(t.ancestorDenotationSpanOfAnchorNode))return t.ancestorDenotationSpanOfFocusNode.id}}}#Ro(t){const e=t.ancestorDenotationSpanOfFocusNode;return!e||t.ancestorDenotationSpanOfAnchorNode===e||t.ancestorDenotationSpanOfAnchorNode&&!t.ancestorDenotationSpanOfAnchorNode.contains(e)?t.isAnchorNodeParentIsDescendantOfFocusNodeParent&&(i=this.#Ie.span.single,n=this.#Ht.textSelection.focus,i&&i.begin<n&&n<i.end)?this.#Ie.span.single.element.id:void 0:e.id;var i,n}#Lo(t){const e=t.ancestorDenotationSpanOfAnchorNode;if(e){const{ancestorDenotationSpanOfFocusNode:i}=t;if(!i)return e.id;if(e!==i&&(e.parentElement===i.parentElement||i.contains(e)))return e.id}}#gs(){this.#Ht.hasCharacters(this.#ni)&&(this.#Ie.removeAll(),function(t,e,i,n,s,o){const{begin:r,end:a}=t.getTextSelection(s,i);if(t.validateNewDenotationSpan(r,a)){const t=e.factory.createSpanAndAutoReplicateCommand({begin:r,end:a},n,o);e.invoke(t)}}(this.#Ht,this.#ei,this.#ii.textSelectionAdjuster,this.#No,this.#ni,pn(this.#ii,this.#ni))),Iw()}#ys(t){this.#Ie.removeAll();const{begin:e,end:i}=this.#Ht.getSpan(t).getExpandedInAnchorNodeToFocusNodeDirection(this.#ii.textSelectionAdjuster,this.#Ht.sourceDoc,this.#ni);this.#Ht.validateNewDenotationSpan(e,i)&&this.#ei.invoke(this.#ei.factory.moveDenotationSpanCommand(t,e,i)),Iw()}#vs(t){Lw(this.#Q,this.#Ht,this.#Ht.sourceDoc,this.#Ie,this.#ei,this.#ii.textSelectionAdjuster,t,this.#ni,(e,i)=>{this.#ei.invoke(this.#ei.factory.moveDenotationSpanCommand(t,e,i))}),Iw()}get#No(){return this.#ii.isPushed("auto replicate")}}class H_ extends Fw{#go;#xs;#O;#Ht;#vo;#Ie;#ii;#ws;constructor(t,e,i,n,s,o,r,a){super(),this.#ws=z_.create(t,e,i.typeDictionary,i.attributeInstanceContainer,i.typeDictionary.denotation,n.entity,o,"Term configuration",r,a,"entity",n,i,this);const l=new X_(t,i,n,o,r,s);this.#go=new F_(t,i,n,this.#ws,l),this.#vo=new h_(t,o,this.#ws,"Entity",a,i.typeDictionary.denotation,i,"Denotation"),this.#Ie=n,this.#xs=l,this.#O=t.querySelector(".textae-editor__text-box"),this.#Ht=i,this.#ii=r;const c=new Jw(o,i.typeDictionary,n.entity,new i_(t,a),()=>this.editProperties(),this.#ws);je(this,()=>c,["manipulateAttribute"])}bindMouseEvents(){return this.#go.bind()}editProperties(){this.#vo.startEditing(this.#Ie.entity)}get isPalletShown(){return this.#ws.visibly}createSpanWithTouchDevice(){this.#xs.cerateSpanForTouchDevice()}expandSpanWithTouchDevice(){this.#xs.expandForTouchDevice()}shrinkSpanWithTouchDevice(){this.#xs.shrinkForTouchDevice()}applyTextSelectionWithTouchDevice(){if(Bw(this.#O)){const{begin:t,end:e}=this.#Ht.textSelection,i=this.#Ht.isBoundaryCrossingWithOtherSpans(t,e),{isParentOfBothNodesSame:n}=new Nw;this.#ii.updateButtonsToOperateSpanWithTouchDevice(n,i,i,!1)}else this.#ii.updateButtonsToOperateSpanWithTouchDevice(!1,!1,!1,!1)}}class W_{#jo;constructor(t,e){const i=document.createElement("dialog");i.classList.add("textae-editor__text-edit-dialog"),t.appendChild(i),i.addEventListener("close",t=>{const i=t.target,{returnValue:n}=i;if("OK"===n){const t=i.querySelector("form"),n=parseInt(t.begin.value),s=parseInt(t.end.value),o=t.originalText.value,r=t.editedText.value;e(n,s,o,r)}}),r()(i,".textae-editor__text-edit-dialog__close-button","click",t=>{i.close()}),r()(i,".textae-editor__text-edit-dialog__text-box","keyup",t=>{t.stopPropagation()}),this.#jo=i}open(t,e,i){this.#jo.innerHTML=this.#zo({begin:t,end:e,text:i}),this.#jo.showModal()}#zo(t){const{text:e,begin:i,end:n}=t;return ot`
890
890
  <div class="textae-editor__text-edit-dialog__title-bar">
891
891
  <h1>Edit text dialog</h1>
892
892
  <button class="textae-editor__text-edit-dialog__close-button">X</button>
@@ -904,7 +904,7 @@ var i,n=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?
904
904
  <button value="OK">OK</button>
905
905
  </div>
906
906
  </form>
907
- `}}class V_ extends Fw{#Q;#Ht;#ni;#ii;#ei;#jo;constructor(t,e,i,n,s){super(),this.#Q=t,this.#Ht=e,this.#ni=i,this.#ii=n,this.#ei=s,this.#jo=new W_(t,(t,e,i,n)=>{if(i===n)return;const s=this.#ei.factory.changeTextAndMoveSpanCommand(t,e,n);this.#ei.invoke(s)})}bindMouseEvents(){const t=[];return t.push(r()(this.#Q,".textae-editor__text-box","click",()=>this.#Bo())),t}applyTextSelectionWithTouchDevice(){this.#ii.updateButtonsToOperateSpanWithTouchDevice(!1,!1,!1,this.#qo)}editTextWithTouchDevice(){this.#Bo()}#Bo(){if(!this.#qo)return;const{begin:t,end:e}=this.#Ht.getTextSelection(this.#ni,this.#ii.textSelectionAdjuster);if(!this.#Ht.validateEditableText(t,e))return!1;const i=this.#Ht.getTextBetween(t,e);this.#jo.open(t,e,i)}get#qo(){return!!Bw(this.#O)&&!!this.#Ht.hasCharacters(this.#ni)}get#O(){return this.#Q.querySelector(".textae-editor__text-box")}}class Y_ extends Fw{#Q;#Ht;#Zo;#Fo;#Xo;constructor(t,e,i){super(),this.#Q=t,this.#Ht=i,this.#Xo=Ui(()=>{this.#Ho(),e.emit("textae-event.editor.selected-text.change")}),document.addEventListener("selectionchange",this.#Xo)}get selectedText(){return void 0===this.#Zo||void 0===this.#Fo?{status:"unselected"}:this.#Ht.isBoundaryCrossingWithOtherSpans(this.#Zo,this.#Fo)?{status:"cross boundary detected"}:{begin:this.#Zo,end:this.#Fo,status:"selected"}}#Ho(){const t=document.getSelection();if(t&&t.rangeCount>0){const e=t.getRangeAt(0),i=this.#Q.querySelector(".textae-editor__text-box");i.contains(e.startContainer)&&i.contains(e.endContainer)&&(this.#Zo=this.#Ht.textSelection.begin,this.#Fo=this.#Ht.textSelection.end)}else this.#Zo=void 0,this.#Fo=void 0}}class U_{static createTermEditMode(t,e,i,n,s,o,r,a){return new H_(t,e,i,n,s,o,r,a)}static createBlockEditMode(t,e,i,n,s,o,r){return new B_(t,e,i,n,s,o,r)}static createRelationEditMode(t,e,i,n,s,o,r){return new Z_(t,e,i,n,s,o,r)}static createTextEditMode(t,e,i,n,s){return new V_(t,e,i,n,s)}static createViewMode(t,e,i){return new Y_(t,e,i)}}class G_{#An;#Wo;#Vo;#Yo;#Uo;#Go;constructor(t,e,i,n,s,o,r){this.#An=t,this.#Wo=e,this.#Vo=i,this.#Yo=n,this.#Uo=s,this.#Go=o,r.on("textae-event.editor.relation.click",(t,e)=>this.current.relationClicked(t,e)).on("textae-event.editor.relation-bollard.click",(t,e)=>this.current.relationBollardClicked(e))}get isEditDenotation(){return this.#An.currentState===vn}get current(){switch(this.#An.currentState){case vn:return this.#Wo;case yn:return this.#Vo;case On:return this.#Yo;case bn:return this.#Uo;default:return this.#Go}}}class K_{constructor(t){this._editorHTMLElement=t}clear(){for(const t of this._editorHTMLElement.classList)t.startsWith("textae-editor__mode")&&this._editorHTMLElement.classList.remove(t)}setFor(t){this._editorHTMLElement.classList.add(`textae-editor__mode--${t}`)}}class J_{#Ko;constructor(t,e,i,n,s,o,r){this.#Ko=[];const a=new K_(t);e.on("textae-event.edit-mode.transition",(t,e)=>{switch(this.#Jo(),a.clear(),t){case gn:i.typeGap.show=e,e?a.setFor("view-with-relation"):a.setFor("view-without-relation");break;case vn:i.typeGap.show=e,this.#Ko=n.bindMouseEvents(),e?a.setFor("denotation-with-relation"):a.setFor("denotation-without-relation");break;case yn:i.typeGap.show=e,this.#Ko=s.bindMouseEvents(),e?a.setFor("block-with-relation"):a.setFor("block-without-relation");break;case On:i.typeGap.show=!0,this.#Ko=o.bindMouseEvents(),a.setFor("relation");break;case bn:i.typeGap.show=e,this.#Ko=r.bindMouseEvents(),e?a.setFor("text-with-relation"):a.setFor("text-without-relation");break;default:throw new Error(`Unknown mode: ${t}`)}})}#Jo(){for(const t of this.#Ko)t.destroy();this.#Ko=[]}}class tS{#tr;#er;#Ht;#An;#Go;constructor(t,i,n,s,o,r,a){const l=new qe,c=new Wi(t,i,s,o,a),h=new sw(s,c,a,o.denotationDefinitionContainer,o.attributeDefinitionContainer,o.typeDictionary),u=new Lx(s,t,r.statusBar),d=new xw(s,u,o),f=new Qw,p=new Dw(o.relationInstanceContainer,s,f);this.#An=p;const m=new nw(s,a,h,d,u,o.typeDictionary,f,p),g=U_.createTermEditMode(t,s,o,a,c,m,l,n),v=U_.createBlockEditMode(t,s,o,a,l,c,m,n),y=U_.createRelationEditMode(t,s,o,a,c,m,n),O=U_.createTextEditMode(t,o,l,m,c),b=U_.createViewMode(t,s,o);this.#Go=b;const x=new G_(p,g,v,y,O,b,s),w=new Rw(o,r,p,x),_=new xn(t,s,o,a,c,l,f,h,m,r,w,x);this.#er=_,this.#Ht=o;const S=new Aw(s),k=new vx(s,S,o,()=>u.annotation,()=>u.configuration,r.saveTo,d,m);new ow(s,m,k,r.saveTo,d),new J_(t,s,o,g,v,y,O),function(t,i,n,s,o,r,a,l){t.on("textae-event.resource.annotation.load.success",c=>{if(!c.data.config&&i.config)n.loadConfiguration(i.config,c);else{if(Qx(c.data),c.data.config&&"object"!=typeof c.data.config)return void e().error("configuration in annotation file is invalid.");const n=Mx(c.data,c.data.config);if(n){if(yx(n,s,o,r,c.data,a),t.emit("textae-event.configuration.reset"),i.isFocusFirstDenotation){const t=r.spanInstanceContainer.allDenotationSpans.at(0);t&&t.focus()}l.annotation=c}}}).on("textae-event.resource.configuration.load.success",(i,n=null)=>{if("object"!=typeof i.data)return void e().error(`${i.displayName} is not a configuration file or its format is invalid.`);n&&Qx(n.data);const c=n&&n.data||{...l.annotation,...r.externalFormat},h=Mx(c,i.data);h&&(yx(h,s,o,r,c,a),t.emit("textae-event.configuration.reset"),n&&(l.annotation=n),l.configuration=i)})}(s,r,S,m,l,o,f,u);const $=new vw(c,_,k,m,o,x),C=new fw(s,m,$).el;switch(t.insertBefore(C,t.childNodes[0]),r.control){case"hidden":t.classList.add("textae-editor--control-hidden");break;case"visible":t.classList.add("textae-editor--control-visible");break;default:r.isEditMode||t.classList.add("textae-editor--control-hidden")}o.toolBarHeight=C.getBoundingClientRect().height,function(t,i,n,s,o,r,a){switch(r.resourceType){case ux.QUERY_PARAMETER:{const l=r.annotation();l?Dx(dx.createParameterSource(l),r.config,n,s,t,i,a,o):e().error("failed to load annotation from query parameter.");break}case ux.INLINE:{const l=r.annotation();l?Dx(dx.createInlineSource(l),r.config,n,s,t,i,a,o):e().error("failed to load annotation from directly included in the div element.");break}case ux.REMOTE_URL:n.loadAnnotation(r.annotationURL);break;default:r.config?n.loadConfiguration(r.config):yx(o.defaultConfiguration,s,t,i,o.defaultAnnotation,a)}}(l,o,S,m,u,r,f);const T=new mw(t,m,$);t.appendChild(T.el),t.addEventListener("keyup",t=>{T.hide(),_.isActive&&new gw(c,_,k,f,x).handle(t)}),je(this,()=>_,["copyEntitiesToSystemClipboard","cutEntitiesToSystemClipboard","pasteEntitiesFromSystemClipboard","activate","deactivate","applyTextSelectionWithTouchDevice"]),this.#tr=T}showContextMenu(t){this.#tr.show(t)}hideContextMenu(){this.#tr.hide()}focusDenotation(t){this.#er.toTermEditMode(),this.#Ht.focusDenotation(t)}getSelectedText(){return this.#An.currentState===gn?this.#Go.selectedText:{status:"unselected"}}}var eS=i(7007);class iS{#Ji;#ir;constructor(t,e,i){if(i)this.#Ji=i;else if(e)this.#ir=e;else{const e=this.#nr(t);e&&(this.#Ji=e)}}get isLoaded(){return Boolean(this.#Ji)}get isRemote(){return Boolean(this.#ir)}get URL(){return this.#ir}annotation(){try{return _n(this.#Ji)?JSON.parse(this.#Ji):ub.parse(this.#Ji)}catch{return null}}#nr(t){const e=t.textContent;return t.innerHTML="",e}}class nS{#At;#sr;constructor(t){this.#At=t,this.#sr=new iS(this.#At,this.#ir,this.#or)}get resourceType(){return this.#or?ux.QUERY_PARAMETER:this.#sr.isLoaded?ux.INLINE:this.annotationURL?ux.REMOTE_URL:ux.UNKNOWN}get annotationURL(){return this.#sr.isRemote?this.#sr.URL:null}get config(){return this.#rr("config")}get configLock(){if(this.#ir){const t=new URLSearchParams(this.#ir.split("?")[1]);if(t.has("config_lock"))return t.get("config_lock")}return this.#ar("config_lock")}get control(){return this.#ar("control")}get inspect(){return this.#ar("inspect")}get isEditMode(){switch(this.#ar("mode")){case"edit":case"term-edit":case"block-edit":case"relation-edit":case"text-edit":return!0;default:return!1}}get isEditTermMode(){return"edit"===this.#ar("mode")||"term-edit"===this.#ar("mode")}get isEditBlockMode(){return"block-edit"===this.#ar("mode")}get isEditRelationMode(){return"relation-edit"===this.#ar("mode")}get isTextEditMode(){return"text-edit"===this.#ar("mode")}get statusBar(){return this.#ar("status_bar")}get saveTo(){return this.#rr("save_to")}get isFocusFirstDenotation(){const t="true"===this.#ar("focus_first_denotation");if(t&&this.isEditMode)throw new Error("focus_first_denotation is only available in view mode.");return t}get additionalPaddingTop(){return this.#ar("padding_top")?parseInt(this.#ar("padding_top"),10):0}get#ir(){return this.#rr("source")||this.#rr("target")}annotation(){return this.#sr.isLoaded?this.#sr.annotation():null}#ar(t){return this.#At.hasAttribute(t)?this.#At.getAttribute(t):null}#rr(t){return this.#At.hasAttribute(t)?decodeURIComponent(this.#At.getAttribute(t)):null}get#or(){if(this.#lr)return null;const t=new URLSearchParams(window.location.search);return t.has("annotation")?decodeURIComponent(t.get("annotation")):null}get#lr(){return Boolean(this.#At.getAttribute("ignore_annotation_parameter"))}}class sS{constructor(t){this._editorHTMLElement=t}startWait(){this._editorHTMLElement.classList.add("textae-editor--wait")}endWait(){this._editorHTMLElement.classList.remove("textae-editor--wait")}}function oS(t){return t.length?ot`
907
+ `}}class V_ extends Fw{#Q;#Ht;#ni;#ii;#ei;#jo;constructor(t,e,i,n,s){super(),this.#Q=t,this.#Ht=e,this.#ni=i,this.#ii=n,this.#ei=s,this.#jo=new W_(t,(t,e,i,n)=>{if(i===n)return;const s=this.#ei.factory.changeTextAndMoveSpanCommand(t,e,n);this.#ei.invoke(s)})}bindMouseEvents(){const t=[];return t.push(r()(this.#Q,".textae-editor__text-box","click",()=>this.#Bo())),t}applyTextSelectionWithTouchDevice(){this.#ii.updateButtonsToOperateSpanWithTouchDevice(!1,!1,!1,this.#qo)}editTextWithTouchDevice(){this.#Bo()}#Bo(){if(!this.#qo)return;const{begin:t,end:e}=this.#Ht.getTextSelection(this.#ni,this.#ii.textSelectionAdjuster);if(!this.#Ht.validateEditableText(t,e))return!1;const i=this.#Ht.getTextBetween(t,e);this.#jo.open(t,e,i)}get#qo(){return!!Bw(this.#O)&&!!this.#Ht.hasCharacters(this.#ni)}get#O(){return this.#Q.querySelector(".textae-editor__text-box")}}function Y_(t,e){let i=0;return function t(n){for(const s of n.childNodes)if(s.nodeType===Node.TEXT_NODE){const t=s.textContent.length;if(i+t>=e)return{node:s,offset:e-i};i+=t}else if(s.nodeType===Node.ELEMENT_NODE){const e=t(s);if(e)return e}return null}(t)}class U_ extends Fw{#Q;#Nt;#Ht;#Zo;#Fo;#ni;#ii;constructor(t,e,i,n,s){super(),this.#Q=t,this.#Nt=e,this.#Ht=i,this.#ni=n,this.#ii=s}get selectedText(){return void 0===this.#Zo||void 0===this.#Fo?{status:"unselected"}:this.#Ht.isBoundaryCrossingWithOtherSpans(this.#Zo,this.#Fo)?{status:"cross boundary detected"}:{begin:this.#Zo,end:this.#Fo,status:"selected"}}updateSelectedTextOffsets(){const t=document.getSelection();if(t&&t.rangeCount>0){const e=t.getRangeAt(0),i=this.#Q.querySelector(".textae-editor__text-box");if(i.contains(e.startContainer)&&i.contains(e.endContainer)){const{begin:e,end:n}=this.#Ht.getTextSelection(this.#ni,this.#ii.textSelectionAdjuster);!function(t,e,i,n){const s=Y_(e,i),o=Y_(e,n),r=document.createRange();r.setStart(s.node,s.offset),r.setEnd(o.node,o.offset),t.removeAllRanges(),t.addRange(r)}(t,i,e,n),this.#Zo=e,this.#Fo=n}}else this.#Zo=void 0,this.#Fo=void 0;this.#Nt.emit("textae-event.editor.selected-text.change")}}class G_{static createTermEditMode(t,e,i,n,s,o,r,a){return new H_(t,e,i,n,s,o,r,a)}static createBlockEditMode(t,e,i,n,s,o,r,a){return new B_(t,e,i,n,s,o,r,a)}static createRelationEditMode(t,e,i,n,s,o,r){return new Z_(t,e,i,n,s,o,r)}static createTextEditMode(t,e,i,n,s){return new V_(t,e,i,n,s)}static createViewMode(t,e,i,n,s){return new U_(t,e,i,n,s)}}class K_{#En;#Xo;#Ho;#Wo;#Vo;#Yo;constructor(t,e,i,n,s,o,r){this.#En=t,this.#Xo=e,this.#Ho=i,this.#Wo=n,this.#Vo=s,this.#Yo=o;const a=Ui(()=>this.#Uo.updateSelectedTextOffsets());document.addEventListener("selectionchange",a),r.on("textae-event.editor.relation.click",(t,e)=>this.#Uo.relationClicked(t,e)).on("textae-event.editor.relation-bollard.click",(t,e)=>this.#Uo.relationBollardClicked(e)),je(this,()=>this.#Uo,["showPallet","hidePallet","selectLeftAttributeTab","selectRightAttributeTab","createSpanWithTouchDevice","expandSpanWithTouchDevice","shrinkSpanWithTouchDevice","editTextWithTouchDevice","applyTextSelectionWithTouchDevice","editProperties","manipulateAttribute"])}get isEditDenotation(){return this.#En.currentState===vn}get isTypeValuesPalletShown(){return this.#Uo.isPalletShown}get#Uo(){switch(this.#En.currentState){case vn:return this.#Xo;case yn:return this.#Ho;case On:return this.#Wo;case bn:return this.#Vo;default:return this.#Yo}}}class J_{constructor(t){this._editorHTMLElement=t}clear(){for(const t of this._editorHTMLElement.classList)t.startsWith("textae-editor__mode")&&this._editorHTMLElement.classList.remove(t)}setFor(t){this._editorHTMLElement.classList.add(`textae-editor__mode--${t}`)}}class tS{#Go;constructor(t,e,i,n,s,o,r){this.#Go=[];const a=new J_(t);e.on("textae-event.edit-mode.transition",(t,e)=>{switch(this.#Ko(),a.clear(),t){case gn:i.typeGap.show=e,e?a.setFor("view-with-relation"):a.setFor("view-without-relation");break;case vn:i.typeGap.show=e,this.#Go=n.bindMouseEvents(),e?a.setFor("denotation-with-relation"):a.setFor("denotation-without-relation");break;case yn:i.typeGap.show=e,this.#Go=s.bindMouseEvents(),e?a.setFor("block-with-relation"):a.setFor("block-without-relation");break;case On:i.typeGap.show=!0,this.#Go=o.bindMouseEvents(),a.setFor("relation");break;case bn:i.typeGap.show=e,this.#Go=r.bindMouseEvents(),e?a.setFor("text-with-relation"):a.setFor("text-without-relation");break;default:throw new Error(`Unknown mode: ${t}`)}})}#Ko(){for(const t of this.#Go)t.destroy();this.#Go=[]}}class eS{#Jo;#Ht;#En;#Yo;#tr;constructor(t,i,n,s,o,r,a){this.#Ht=o;const l=new qe,c=new Wi(t,i,s,o,a),h=new sw(s,c,a,o.denotationDefinitionContainer,o.attributeDefinitionContainer,o.typeDictionary),u=new Lx(s,t,r.statusBar),d=new xw(s,u,o),f=new Qw,p=new Dw(o.relationInstanceContainer,s,f);this.#En=p;const m=new nw(s,a,h,d,u,o.typeDictionary,f,p),g=G_.createTermEditMode(t,s,o,a,l,c,m,n),v=G_.createBlockEditMode(t,s,o,a,l,c,m,n),y=G_.createRelationEditMode(t,s,o,a,c,m,n),O=G_.createTextEditMode(t,o,l,m,c),b=G_.createViewMode(t,s,o,l,m);this.#Yo=b;const x=new K_(p,g,v,y,O,b,s),w=new Rw(r,p,o.relationInstanceContainer,()=>x.hidePallet());s.on("textae-event.annotation-data.all.change",t=>{r.isEditMode&&t&&e().success("track annotations have been merged to root annotations."),w.reset()}),this.#tr=w;const _=new xn(t,s,o,a,c,l,f,h,m,x),S=new Aw(s),k=new vx(s,S,o,()=>u.annotation,()=>u.configuration,r.saveTo,d,m);new ow(s,m,k,r.saveTo,d),new tS(t,s,o,g,v,y,O),function(t,i,n,s,o,r,a,l){t.on("textae-event.resource.annotation.load.success",c=>{if(!c.data.config&&i.config)n.loadConfiguration(i.config,c);else{if(Qx(c.data),c.data.config&&"object"!=typeof c.data.config)return void e().error("configuration in annotation file is invalid.");const n=Mx(c.data,c.data.config);if(n){if(yx(n,s,o,r,c.data,a),t.emit("textae-event.configuration.reset"),i.isFocusFirstDenotation){const t=r.spanInstanceContainer.allDenotationSpans.at(0);t&&t.focus()}l.annotation=c}}}).on("textae-event.resource.configuration.load.success",(i,n=null)=>{if("object"!=typeof i.data)return void e().error(`${i.displayName} is not a configuration file or its format is invalid.`);n&&Qx(n.data);const c=n&&n.data||{...l.annotation,...r.externalFormat},h=Mx(c,i.data);h&&(yx(h,s,o,r,c,a),t.emit("textae-event.configuration.reset"),n&&(l.annotation=n),l.configuration=i)})}(s,r,S,m,l,o,f,u);const $=new vw(c,_,k,m,o,x,w),C=new fw(s,m,$).el;switch(t.insertBefore(C,t.childNodes[0]),r.control){case"hidden":t.classList.add("textae-editor--control-hidden");break;case"visible":t.classList.add("textae-editor--control-visible");break;default:r.isEditMode||t.classList.add("textae-editor--control-hidden")}o.toolBarHeight=C.getBoundingClientRect().height,function(t,i,n,s,o,r,a){switch(r.resourceType){case ux.QUERY_PARAMETER:{const l=r.annotation();l?Dx(dx.createParameterSource(l),r.config,n,s,t,i,a,o):e().error("failed to load annotation from query parameter.");break}case ux.INLINE:{const l=r.annotation();l?Dx(dx.createInlineSource(l),r.config,n,s,t,i,a,o):e().error("failed to load annotation from directly included in the div element.");break}case ux.REMOTE_URL:n.loadAnnotation(r.annotationURL);break;default:r.config?n.loadConfiguration(r.config):yx(o.defaultConfiguration,s,t,i,o.defaultAnnotation,a)}}(l,o,S,m,u,r,f);const T=new mw(t,m,$);t.appendChild(T.el),t.addEventListener("keyup",t=>{T.hide(),_.isActive&&new gw(c,_,k,f,x,w).handle(t)}),je(this,()=>_,["copyEntitiesToSystemClipboard","cutEntitiesToSystemClipboard","pasteEntitiesFromSystemClipboard","activate","deactivate","applyTextSelectionWithTouchDevice"]),this.#Jo=T}showContextMenu(t){this.#Jo.show(t)}hideContextMenu(){this.#Jo.hide()}focusDenotation(t){this.#tr.toTermEditMode(),this.#Ht.focusDenotation(t)}getSelectedText(){return this.#En.currentState===gn?this.#Yo.selectedText:{status:"unselected"}}}var iS=i(7007);class nS{#Ki;#er;constructor(t,e,i){if(i)this.#Ki=i;else if(e)this.#er=e;else{const e=this.#ir(t);e&&(this.#Ki=e)}}get isLoaded(){return Boolean(this.#Ki)}get isRemote(){return Boolean(this.#er)}get URL(){return this.#er}annotation(){try{return _n(this.#Ki)?JSON.parse(this.#Ki):ub.parse(this.#Ki)}catch{return null}}#ir(t){const e=t.textContent;return t.innerHTML="",e}}class sS{#At;#nr;constructor(t){this.#At=t,this.#nr=new nS(this.#At,this.#er,this.#sr)}get resourceType(){return this.#sr?ux.QUERY_PARAMETER:this.#nr.isLoaded?ux.INLINE:this.annotationURL?ux.REMOTE_URL:ux.UNKNOWN}get annotationURL(){return this.#nr.isRemote?this.#nr.URL:null}get config(){return this.#or("config")}get configLock(){if(this.#er){const t=new URLSearchParams(this.#er.split("?")[1]);if(t.has("config_lock"))return t.get("config_lock")}return this.#rr("config_lock")}get control(){return this.#rr("control")}get inspect(){return this.#rr("inspect")}get isEditMode(){switch(this.#rr("mode")){case"edit":case"term-edit":case"block-edit":case"relation-edit":case"text-edit":return!0;default:return!1}}get isEditTermMode(){return"edit"===this.#rr("mode")||"term-edit"===this.#rr("mode")}get isEditBlockMode(){return"block-edit"===this.#rr("mode")}get isEditRelationMode(){return"relation-edit"===this.#rr("mode")}get isTextEditMode(){return"text-edit"===this.#rr("mode")}get statusBar(){return this.#rr("status_bar")}get saveTo(){return this.#or("save_to")}get isFocusFirstDenotation(){const t="true"===this.#rr("focus_first_denotation");if(t&&this.isEditMode)throw new Error("focus_first_denotation is only available in view mode.");return t}get additionalPaddingTop(){return this.#rr("padding_top")?parseInt(this.#rr("padding_top"),10):0}get#er(){return this.#or("source")||this.#or("target")}annotation(){return this.#nr.isLoaded?this.#nr.annotation():null}#rr(t){return this.#At.hasAttribute(t)?this.#At.getAttribute(t):null}#or(t){return this.#At.hasAttribute(t)?decodeURIComponent(this.#At.getAttribute(t)):null}get#sr(){if(this.#ar)return null;const t=new URLSearchParams(window.location.search);return t.has("annotation")?decodeURIComponent(t.get("annotation")):null}get#ar(){return Boolean(this.#At.getAttribute("ignore_annotation_parameter"))}}class oS{constructor(t){this._editorHTMLElement=t}startWait(){this._editorHTMLElement.classList.add("textae-editor--wait")}endWait(){this._editorHTMLElement.classList.remove("textae-editor--wait")}}function rS(t){return t.length?ot`
908
908
  <table>
909
909
  <caption>Denotations or Blocks or Typesettings with boundary-cross.</caption>
910
910
  <thead>
@@ -928,7 +928,7 @@ var i,n=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?
928
928
  `}(t,e,i,n,s))}
929
929
  </tbody>
930
930
  </table>
931
- `:""}function rS(t){return t.length?ot`
931
+ `:""}function aS(t){return t.length?ot`
932
932
  <table>
933
933
  <caption>Duplicated attributes.</caption>
934
934
  <thead>
@@ -950,7 +950,7 @@ var i,n=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?
950
950
  `}(t,e,i,n))}
951
951
  </tbody>
952
952
  </table>
953
- `:""}function aS(t){return t.length?ot`
953
+ `:""}function lS(t){return t.length?ot`
954
954
  <table>
955
955
  <caption>Duplicated IDs in Denotations and Blocks.</caption>
956
956
  <thead>
@@ -974,7 +974,7 @@ var i,n=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?
974
974
  `}(t,e,i,n))}
975
975
  </tbody>
976
976
  </table>
977
- `:""}function lS(t){return t.length?ot`
977
+ `:""}function cS(t){return t.length?ot`
978
978
  <table>
979
979
  <caption>Duplicated range blocks.</caption>
980
980
  <thead>
@@ -996,7 +996,7 @@ var i,n=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?
996
996
  `}(t,e,i))}
997
997
  </tbody>
998
998
  </table>
999
- `:""}function cS(t){return t.length?ot`
999
+ `:""}function hS(t){return t.length?ot`
1000
1000
  <table>
1001
1001
  <caption>Out of text blocks.</caption>
1002
1002
  <thead>
@@ -1018,7 +1018,7 @@ var i,n=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?
1018
1018
  `}(t,e,i))}
1019
1019
  </tbody>
1020
1020
  </table>
1021
- `:""}function hS(t){return t.length?ot`
1021
+ `:""}function uS(t){return t.length?ot`
1022
1022
  <table>
1023
1023
  <caption>Out of text denotations.</caption>
1024
1024
  <thead>
@@ -1039,7 +1039,7 @@ var i,n=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?
1039
1039
  </tr>
1040
1040
  `}(t,e,i))}
1041
1041
  </tbody>
1042
- </table>`:""}function uS(t){return t.length?ot`
1042
+ </table>`:""}function dS(t){return t.length?ot`
1043
1043
  <table>
1044
1044
  <caption>Out of text typesettings.</caption>
1045
1045
  <thead>
@@ -1061,7 +1061,7 @@ var i,n=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?
1061
1061
  `}(t,e,i))}
1062
1062
  </tbody>
1063
1063
  </table>
1064
- `:""}function dS(t){return t.length?ot`
1064
+ `:""}function fS(t){return t.length?ot`
1065
1065
  <table>
1066
1066
  <caption>Referenced entities do not exist.</caption>
1067
1067
  <thead>
@@ -1085,7 +1085,7 @@ var i,n=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?
1085
1085
  `}(t,e,i,n,s,o,r))}
1086
1086
  </tbody>
1087
1087
  </table>
1088
- `:""}function fS(t){return t.length?ot`
1088
+ `:""}function pS(t){return t.length?ot`
1089
1089
  <table>
1090
1090
  <caption>Wrong range blocks.</caption>
1091
1091
  <thead>
@@ -1107,7 +1107,7 @@ var i,n=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?
1107
1107
  `}(t,e,i))}
1108
1108
  </tbody>
1109
1109
  </table>
1110
- `:""}function pS(t){return t.length?ot`
1110
+ `:""}function mS(t){return t.length?ot`
1111
1111
  <table>
1112
1112
  <caption>Wrong range denotations.</caption>
1113
1113
  <thead>
@@ -1128,4 +1128,4 @@ var i,n=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?
1128
1128
  </tr>
1129
1129
  `}(t,e,i))}
1130
1130
  </tbody>
1131
- </table>`:""}class mS extends u{constructor(t){const e=t.map(({name:t,wrongRangeDenotations:e,outOfTextDenotations:i,wrongRangeBlocks:n,outOfTextBlocks:s,duplicatedRangeBlocks:o,wrongRangeTypesettings:r,outOfTextTypesettings:a,duplicatedIDs:l,boundaryCrossingSpans:c,referencedEntitiesDoNotExist:h,duplicatedAttributes:u},d)=>`\n ${1===d?'\n <div class="textae-editor__validate-dialog__content">\n <h1>Track annotations will be merged to the root annotations.</h1>\n </div>':""}\n <div class="textae-editor__validate-dialog__content">\n <h2>${t}</h2>\n ${pS(e)}\n ${hS(i)}\n ${fS(n)}\n ${cS(s)}\n ${lS(o)}\n ${function(t){return t.length?`\n <table>\n <caption>Wrong range typesettings.</caption>\n <thead>\n <tr>\n <th class="id">id</th>\n <th class="range">begin</th>\n <th class="range">end</th>\n <th>style</th>\n </tr>\n </thead>\n <tbody>\n ${t.map(({id:t,span:e,style:i})=>`\n <tr>\n <td>${t||""}</td>\n <td class="alert">${e.begin}</td>\n <td class="alert">${e.end}</td>\n <td>${i}</td>\n </tr>\n `).join("\n")}\n </tbody>\n </table>\n `:""}(r)}\n ${uS(a)}\n ${aS(l)}\n ${oS(c)}\n ${dS(h)}\n ${rS(u)}\n </div>\n `).join("\n");super("The following erroneous annotations ignored",e,{maxWidth:900})}}class gS{#Nt;#cr;#hr;constructor(t,e,i){this.#Nt=t,this.#cr=e,this.#hr=i;for(const i of e)t.on(i,this.#hr)}dispose(){for(const t of this.#cr)this.#Nt.off(t,this.#hr)}}class vS{#ur;#dr;#hr;constructor(t,e,i){this.#ur=t,this.#dr=e,this.#hr=i,this.#fr()}dispose(){this.#ur.removeEventListener(this.#dr,this.#hr)}#fr(){this.#ur.addEventListener(this.#dr,this.#hr)}}class yS{#a;#Oe;#pr;constructor(t,e,i){this.#a=t,this.#Oe=e,this.#pr=i.getInstanceContainerFor(e)}add(t){const e=this.#pr.get(t);console.assert(e,`${t} is not a instance of ${this.#Oe}.`),e.isSelected||(e.select(),this.triggerChange())}has(t){const e=this.#pr.get(t);return!!e&&e.isSelected}contains(t){for(const e of this.#pr.selectedItems)if(t(e))return!0;return!1}get all(){return this.#pr.selectedItems}get size(){return this.#pr.selectedItems.length}get some(){return this.size>0}get singleId(){const t=this.single;return t?t.id:null}get single(){return 1===this.size?this.#pr.selectedItems[0]:null}toggle(t){this.has(t)?this.remove(t):this.add(t)}remove(t){this.has(t)&&(this.#pr.get(t).deselect(),this.triggerChange())}removeInstance(t){this.remove(t.id)}removeAll(){if(0!==this.size){for(const t of this.all)t.deselect();this.triggerChange()}}triggerChange(){this.#a.emit(`textae-event.selection.${this.#Oe}.change`)}}class OS extends yS{selectedWithAttributeOf(t){return this.all.some(e=>e.attributes.some(e=>e.pred===t))}onlySelectedWithJustOneAttributeOf(t){return this.all.every(e=>1===e.attributes.filter(e=>e.pred===t).length)}selectedWithoutAttributeOf(t){return this.all.some(e=>!e.attributes.some(e=>e.pred===t))}isDuplicatedPredAttributeSelected(t){return this.all.some(e=>e.attributes.filter(e=>e.pred===t).length>1)}findSelectedWithSamePredicateAttribute(t){return this.all.find(e=>e.attributes.find(e=>e.pred===t))}findSelectedAttributeWithSamePredicate(t){const e=this.findSelectedWithSamePredicateAttribute(t);if(e)return e.attributes.find(e=>e.pred===t)}}class bS{#Ht;#Nt;constructor(t,e){this.#Nt=t,this.#Ht=e,this.span=new yS(t,"span",e),this.entity=new OS(t,"entity",e),this.relation=new OS(t,"relation",e),t.on("textae-event.annotation-data.span.remove",t=>this.span.removeInstance(t)).on("textae-event.annotation-data.entity.remove",t=>this.entity.removeInstance(t)).on("textae-event.annotation-data.relation.remove",t=>this.relation.removeInstance(t)).on("textae-event.annotation-data.all.change",()=>{this.span.triggerChange(),this.entity.triggerChange(),this.relation.triggerChange()})}get copyingTargets(){return[...this.#mr].map(({typeValues:t})=>t)}get cuttingTargets(){return this.#mr}add(t,e){console.assert(this[t]);for(const i of e)this[t].add(i);"entity"===t&&this.#gr(e[e.length-1])&&this.#Nt.emit("textae-event.selection-model.last-selected-denotation-id.change",e[e.length-1])}remove(t,e){console.assert(this[t]),this[t].remove(e)}removeAll(){this.span.removeAll(),this.entity.removeAll(),this.relation.removeAll()}selectSpan(t){this.removeAll(),this.span.add(t)}selectSpanRange(t){this.removeAll();for(const e of t)this.span.add(e)}selectEntity(t){this.removeAll(),this.entity.add(t),this.#gr(t)&&this.#Nt.emit("textae-event.selection-model.last-selected-denotation-id.change",t)}selectDenotation(t){if(!this.#gr(t))throw new Error(`Denotation ${t} not found`);this.selectEntity(t)}selectRelation(t){this.removeAll(),this.relation.add(t)}get#mr(){return new Set(this.span.all.map(t=>t.entities).flat().concat(this.entity.all))}#gr(t){return this.#Ht.entityInstanceContainer.hasDenotation(t)}}class xS{#At;#Ht;#Nt;#vr;#yr;#Or;#br;constructor(t,i,n,s,o){t.tabIndex=-1,jx()&&t.classList.add("textae-editor--android"),function(t){t.addEventListener("mousedown",t=>{t.shiftKey&&t.preventDefault()}),r()(t,".textae-editor__signboard","mousedown",t=>t.preventDefault())}(t);const a=new eS.EventEmitter;!function(t){t.on("textae-event.resource.annotation.format.error",({displayName:t})=>e().error(`${t} is not a annotation file or its format is invalid.`)).on("textae-event.resource.configuration.format.error",({displayName:t})=>e().error(`${t} is not a configuration file or its format is invalid.!`)).on("textae-event.annotation-data.all.change",(t,e)=>{e.some(t=>t.hasError)&&new mS(e).open()}).on("textae-event.annotation-data.events-observer.unsaved-change",t=>{window.onbeforeunload=jx()||t?()=>!0:null}),t.on("textae-event.clip-board.change",(t,e)=>{for(const e of t)e.startCut();for(const t of e)t.cancelCut()}),t.on("textae-event.commander.attributes.change",t=>{for(const e of t.reduce((t,e)=>t.add(e.subjectInstance),new Set))e.updateElement()})}(a);const l=new sS(t);!function(t,e){t.on("textae-event.resource.startLoad",()=>e.startWait()).on("textae-event.resource.endLoad",()=>e.endWait()).on("textae-event.resource.startSave",()=>e.startWait()).on("textae-event.resource.endSave",()=>e.endWait())}(a,l);const c=new nS(t),h=new ze(i,t,a,l,s,o,"true"===c.configLock,c.additionalPaddingTop);this.#At=t,this.#Ht=h,this.#Nt=a;const u=new bS(a,h);if(this.#br=new tS(t,i,n,a,h,c,u),c.inspect){const t=t=>{const e=document.querySelector(`#${c.inspect}`);e&&(e.textContent=JSON.stringify(t,null,2))};this.#xr(t)}this.#Or=this.#wr(h,t),je(this,()=>this.#br,["copyEntitiesToSystemClipboard","cutEntitiesToSystemClipboard","pasteEntitiesFromSystemClipboard","activate","deactivate","applyTextSelectionWithTouchDevice","showContextMenu","hideContextMenu","focusDenotation"]),je(this,()=>u,["selectDenotation"]),je(this,()=>h,["drawGridsInSight","reLayout"])}updateDenotationEntitiesWidth(){for(const t of this.#Ht.spanInstanceContainer.allDenotationSpans)t.updateDenotationEntitiesWidth()}load(t){px(this.#Nt,t)}setInspector(t){this.#vr&&(this.#vr.dispose(),this.#vr=null),"function"==typeof t&&(this.#vr=this.#xr(t))}setLastSelectedDenotationIDCallback(t){this.#yr&&(this.#yr.dispose(),this.#yr=null),"function"==typeof t&&(this.#yr=new gS(this.#Nt,["textae-event.selection-model.last-selected-denotation-id.change"],t))}setAutocompletionFunction(t){if("function"!=typeof t)throw new TypeError("autocompletionFunction must be a function");this.#Ht.autocompletionFunction=t}get HTMLElementID(){return this.#At.id}dispose(){for(const t of this.#Or)t.dispose()}focusDenotation(t){if(!this.#Ht.denotations.has(t))throw new Error(`Denotation ${t} not found`);this.#br.focusDenotation(t)}#wr(t,e){const i=new Set,n=()=>t.drawGridsInSight(),s=new vS(e,"scroll",n);i.add(s);const o=e.closest(".textae-container");if(o){const t=new vS(o,"scroll",n);i.add(t)}return i}#xr(t){const e=function(t){let e=t;return function(t,i){bw(e,t)&&(e=t,i(t))}}(this.#_r);return new gS(this.#Nt,["textae-event.annotation-data.events-observer.change","textae-event.editor.selected-text.change"],()=>e(this.#_r,t))}get#_r(){return{...this.#Ht.externalFormat,selectedText:this.#br.getSelectedText()}}}function wS(t,e){const i=function(t,e){return new xS(t,e.nextID,e.mousePoint,()=>{for(const t of document.querySelectorAll(".ui-dialog"))t.classList.add("textae-editor--wait");for(const t of document.querySelectorAll(".ui-widget-overlay"))t.classList.add("textae-editor--wait")},()=>{for(const t of document.querySelectorAll(".ui-dialog"))t.classList.remove("textae-editor--wait");for(const t of document.querySelectorAll(".ui-widget-overlay"))t.classList.remove("textae-editor--wait")})}(e,t);return t.registerEditor(e,i),e.dataset.textaeInitialized=!0,i}class _S{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)}}const SS=new class{#Sr;#kr;#so;constructor(){this.#Sr=new y,this.#kr=new b,this.#so=x,window.addEventListener("load",()=>{return t=this.#Sr,document.body.addEventListener("focus",e=>{const i=e.target.closest(".textae-editor");i&&(t.selected&&t.selected!==i&&(t.selected=null),t.selected=i)},!0),document.body.addEventListener("click",e=>{null===e.target.closest(".textae-editor__dialog")&&null===e.target.closest(".ui-autocomplete")&&null===e.target.closest(".ui-widget-overlay")&&null===e.target.closest(".textae-editor__pallet__content")&&(t.has(e.target.closest(".textae-editor"))||t.selected&&(t.selected=null))}),void new MutationObserver(e=>{for(const i of e)if("childList"===i.type)for(const e of i.removedNodes)if(e instanceof HTMLElement){e.classList.contains("textae-editor")&&t.remove(e);for(const i of e.querySelectorAll(".textae-editor"))t.remove(i)}}).observe(document.body,{childList:!0,subtree:!0});var t}),window.addEventListener("resize",m()(()=>{this.#Sr.reLayout(),this.#Sr.drawGridsInSight(),this.#Sr.updateDenotationEntitiesWidth()},500))}get nextID(){return this.#Sr.nextID}get mousePoint(){return this.#so}registerEditor(t,e){this.#kr.setObserver(t),this.#Sr.set(t,e)}};function kS(){return e().set("notifier","position","top-right"),Array.from(document.querySelectorAll(".textae-editor")).filter(t=>!t.dataset.textaeInitialized).map(t=>wS(SS,t)).map(t=>new _S(t))}document.addEventListener("DOMContentLoaded",kS),window.initializeTextAEEditor=kS,console.log(`TextAE Version ${Ji} loaded.`)})()})();
1131
+ </table>`:""}class gS extends u{constructor(t){const e=t.map(({name:t,wrongRangeDenotations:e,outOfTextDenotations:i,wrongRangeBlocks:n,outOfTextBlocks:s,duplicatedRangeBlocks:o,wrongRangeTypesettings:r,outOfTextTypesettings:a,duplicatedIDs:l,boundaryCrossingSpans:c,referencedEntitiesDoNotExist:h,duplicatedAttributes:u},d)=>`\n ${1===d?'\n <div class="textae-editor__validate-dialog__content">\n <h1>Track annotations will be merged to the root annotations.</h1>\n </div>':""}\n <div class="textae-editor__validate-dialog__content">\n <h2>${t}</h2>\n ${mS(e)}\n ${uS(i)}\n ${pS(n)}\n ${hS(s)}\n ${cS(o)}\n ${function(t){return t.length?`\n <table>\n <caption>Wrong range typesettings.</caption>\n <thead>\n <tr>\n <th class="id">id</th>\n <th class="range">begin</th>\n <th class="range">end</th>\n <th>style</th>\n </tr>\n </thead>\n <tbody>\n ${t.map(({id:t,span:e,style:i})=>`\n <tr>\n <td>${t||""}</td>\n <td class="alert">${e.begin}</td>\n <td class="alert">${e.end}</td>\n <td>${i}</td>\n </tr>\n `).join("\n")}\n </tbody>\n </table>\n `:""}(r)}\n ${dS(a)}\n ${lS(l)}\n ${rS(c)}\n ${fS(h)}\n ${aS(u)}\n </div>\n `).join("\n");super("The following erroneous annotations ignored",e,{maxWidth:900})}}class vS{#Nt;#lr;#cr;constructor(t,e,i){this.#Nt=t,this.#lr=e,this.#cr=i;for(const i of e)t.on(i,this.#cr)}dispose(){for(const t of this.#lr)this.#Nt.off(t,this.#cr)}}class yS{#hr;#ur;#cr;constructor(t,e,i){this.#hr=t,this.#ur=e,this.#cr=i,this.#dr()}dispose(){this.#hr.removeEventListener(this.#ur,this.#cr)}#dr(){this.#hr.addEventListener(this.#ur,this.#cr)}}class OS{#a;#Oe;#fr;constructor(t,e,i){this.#a=t,this.#Oe=e,this.#fr=i.getInstanceContainerFor(e)}add(t){const e=this.#fr.get(t);console.assert(e,`${t} is not a instance of ${this.#Oe}.`),e.isSelected||(e.select(),this.triggerChange())}has(t){const e=this.#fr.get(t);return!!e&&e.isSelected}contains(t){for(const e of this.#fr.selectedItems)if(t(e))return!0;return!1}get all(){return this.#fr.selectedItems}get size(){return this.#fr.selectedItems.length}get some(){return this.size>0}get singleId(){const t=this.single;return t?t.id:null}get single(){return 1===this.size?this.#fr.selectedItems[0]:null}toggle(t){this.has(t)?this.remove(t):this.add(t)}remove(t){this.has(t)&&(this.#fr.get(t).deselect(),this.triggerChange())}removeInstance(t){this.remove(t.id)}removeAll(){if(0!==this.size){for(const t of this.all)t.deselect();this.triggerChange()}}triggerChange(){this.#a.emit(`textae-event.selection.${this.#Oe}.change`)}}class bS extends OS{selectedWithAttributeOf(t){return this.all.some(e=>e.attributes.some(e=>e.pred===t))}onlySelectedWithJustOneAttributeOf(t){return this.all.every(e=>1===e.attributes.filter(e=>e.pred===t).length)}selectedWithoutAttributeOf(t){return this.all.some(e=>!e.attributes.some(e=>e.pred===t))}isDuplicatedPredAttributeSelected(t){return this.all.some(e=>e.attributes.filter(e=>e.pred===t).length>1)}findSelectedWithSamePredicateAttribute(t){return this.all.find(e=>e.attributes.find(e=>e.pred===t))}findSelectedAttributeWithSamePredicate(t){const e=this.findSelectedWithSamePredicateAttribute(t);if(e)return e.attributes.find(e=>e.pred===t)}}class xS{#Ht;#Nt;constructor(t,e){this.#Nt=t,this.#Ht=e,this.span=new OS(t,"span",e),this.entity=new bS(t,"entity",e),this.relation=new bS(t,"relation",e),t.on("textae-event.annotation-data.span.remove",t=>this.span.removeInstance(t)).on("textae-event.annotation-data.entity.remove",t=>this.entity.removeInstance(t)).on("textae-event.annotation-data.relation.remove",t=>this.relation.removeInstance(t)).on("textae-event.annotation-data.all.change",()=>{this.span.triggerChange(),this.entity.triggerChange(),this.relation.triggerChange()})}get copyingTargets(){return[...this.#pr].map(({typeValues:t})=>t)}get cuttingTargets(){return this.#pr}add(t,e){console.assert(this[t]);for(const i of e)this[t].add(i);"entity"===t&&this.#mr(e[e.length-1])&&this.#Nt.emit("textae-event.selection-model.last-selected-denotation-id.change",e[e.length-1])}remove(t,e){console.assert(this[t]),this[t].remove(e)}removeAll(){this.span.removeAll(),this.entity.removeAll(),this.relation.removeAll()}selectSpan(t){this.removeAll(),this.span.add(t)}selectSpanRange(t){this.removeAll();for(const e of t)this.span.add(e)}selectEntity(t){this.removeAll(),this.entity.add(t),this.#mr(t)&&this.#Nt.emit("textae-event.selection-model.last-selected-denotation-id.change",t)}selectDenotation(t){if(!this.#mr(t))throw new Error(`Denotation ${t} not found`);this.selectEntity(t)}selectRelation(t){this.removeAll(),this.relation.add(t)}get#pr(){return new Set(this.span.all.map(t=>t.entities).flat().concat(this.entity.all))}#mr(t){return this.#Ht.entityInstanceContainer.hasDenotation(t)}}class wS{#At;#Ht;#Nt;#gr;#vr;#yr;#Or;constructor(t,i,n,s,o){t.tabIndex=-1,jx()&&t.classList.add("textae-editor--android"),function(t){t.addEventListener("mousedown",t=>{t.shiftKey&&t.preventDefault()}),r()(t,".textae-editor__signboard","mousedown",t=>t.preventDefault())}(t);const a=new iS.EventEmitter;!function(t){t.on("textae-event.resource.annotation.format.error",({displayName:t})=>e().error(`${t} is not a annotation file or its format is invalid.`)).on("textae-event.resource.configuration.format.error",({displayName:t})=>e().error(`${t} is not a configuration file or its format is invalid.!`)).on("textae-event.annotation-data.all.change",(t,e)=>{e.some(t=>t.hasError)&&new gS(e).open()}).on("textae-event.annotation-data.events-observer.unsaved-change",t=>{window.onbeforeunload=jx()||t?()=>!0:null}),t.on("textae-event.clip-board.change",(t,e)=>{for(const e of t)e.startCut();for(const t of e)t.cancelCut()}),t.on("textae-event.commander.attributes.change",t=>{for(const e of t.reduce((t,e)=>t.add(e.subjectInstance),new Set))e.updateElement()})}(a);const l=new oS(t);!function(t,e){t.on("textae-event.resource.startLoad",()=>e.startWait()).on("textae-event.resource.endLoad",()=>e.endWait()).on("textae-event.resource.startSave",()=>e.startWait()).on("textae-event.resource.endSave",()=>e.endWait())}(a,l);const c=new sS(t),h=new ze(i,t,a,l,s,o,"true"===c.configLock,c.additionalPaddingTop);this.#At=t,this.#Ht=h,this.#Nt=a;const u=new xS(a,h);if(this.#Or=new eS(t,i,n,a,h,c,u),c.inspect){const t=t=>{const e=document.querySelector(`#${c.inspect}`);e&&(e.textContent=JSON.stringify(t,null,2))};this.#br(t)}this.#yr=this.#xr(h,t),je(this,()=>this.#Or,["copyEntitiesToSystemClipboard","cutEntitiesToSystemClipboard","pasteEntitiesFromSystemClipboard","activate","deactivate","applyTextSelectionWithTouchDevice","showContextMenu","hideContextMenu","focusDenotation"]),je(this,()=>u,["selectDenotation"]),je(this,()=>h,["drawGridsInSight","reLayout"])}updateDenotationEntitiesWidth(){for(const t of this.#Ht.spanInstanceContainer.allDenotationSpans)t.updateDenotationEntitiesWidth()}load(t){px(this.#Nt,t)}setInspector(t){this.#gr&&(this.#gr.dispose(),this.#gr=null),"function"==typeof t&&(this.#gr=this.#br(t))}setLastSelectedDenotationIDCallback(t){this.#vr&&(this.#vr.dispose(),this.#vr=null),"function"==typeof t&&(this.#vr=new vS(this.#Nt,["textae-event.selection-model.last-selected-denotation-id.change"],t))}setAutocompletionFunction(t){if("function"!=typeof t)throw new TypeError("autocompletionFunction must be a function");this.#Ht.autocompletionFunction=t}get HTMLElementID(){return this.#At.id}dispose(){for(const t of this.#yr)t.dispose()}focusDenotation(t){if(!this.#Ht.denotations.has(t))throw new Error(`Denotation ${t} not found`);this.#Or.focusDenotation(t)}#xr(t,e){const i=new Set,n=()=>t.drawGridsInSight(),s=new yS(e,"scroll",n);i.add(s);const o=e.closest(".textae-container");if(o){const t=new yS(o,"scroll",n);i.add(t)}return i}#br(t){const e=function(t){let e=t;return function(t,i){bw(e,t)&&(e=t,i(t))}}(this.#wr);return new vS(this.#Nt,["textae-event.annotation-data.events-observer.change","textae-event.editor.selected-text.change"],()=>e(this.#wr,t))}get#wr(){return{...this.#Ht.externalFormat,selectedText:this.#Or.getSelectedText()}}}function _S(t,e){const i=function(t,e){return new wS(t,e.nextID,e.mousePoint,()=>{for(const t of document.querySelectorAll(".ui-dialog"))t.classList.add("textae-editor--wait");for(const t of document.querySelectorAll(".ui-widget-overlay"))t.classList.add("textae-editor--wait")},()=>{for(const t of document.querySelectorAll(".ui-dialog"))t.classList.remove("textae-editor--wait");for(const t of document.querySelectorAll(".ui-widget-overlay"))t.classList.remove("textae-editor--wait")})}(e,t);return t.registerEditor(e,i),e.dataset.textaeInitialized=!0,i}class SS{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)}}const kS=new class{#_r;#Sr;#so;constructor(){this.#_r=new y,this.#Sr=new b,this.#so=x,window.addEventListener("load",()=>{return t=this.#_r,document.body.addEventListener("focus",e=>{const i=e.target.closest(".textae-editor");i&&(t.selected&&t.selected!==i&&(t.selected=null),t.selected=i)},!0),document.body.addEventListener("click",e=>{null===e.target.closest(".textae-editor__dialog")&&null===e.target.closest(".ui-autocomplete")&&null===e.target.closest(".ui-widget-overlay")&&null===e.target.closest(".textae-editor__pallet__content")&&(t.has(e.target.closest(".textae-editor"))||t.selected&&(t.selected=null))}),void new MutationObserver(e=>{for(const i of e)if("childList"===i.type)for(const e of i.removedNodes)if(e instanceof HTMLElement){e.classList.contains("textae-editor")&&t.remove(e);for(const i of e.querySelectorAll(".textae-editor"))t.remove(i)}}).observe(document.body,{childList:!0,subtree:!0});var t}),window.addEventListener("resize",m()(()=>{this.#_r.reLayout(),this.#_r.drawGridsInSight(),this.#_r.updateDenotationEntitiesWidth()},500))}get nextID(){return this.#_r.nextID}get mousePoint(){return this.#so}registerEditor(t,e){this.#Sr.setObserver(t),this.#_r.set(t,e)}};function $S(){return e().set("notifier","position","top-right"),Array.from(document.querySelectorAll(".textae-editor")).filter(t=>!t.dataset.textaeInitialized).map(t=>_S(kS,t)).map(t=>new SS(t))}document.addEventListener("DOMContentLoaded",$S),window.initializeTextAEEditor=$S,console.log(`TextAE Version ${Ji} loaded.`)})()})();