/*!
Copyright (c) 2026 Lenovo SSG BASD. All rights reserved.
@license Proprietary

This software is the confidential and proprietary property of Lenovo SSG BASD.
You shall not disclose such Confidential Information and shall use it only in
accordance with the terms of the license agreement.

--- Build Info ---
Version: 1.1.1
Build Time: 2026/2/26 17:21:00
Build Commit: 81e556ed827e2f043668506dae6fae8dbb9ef395
*/
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../prosemirror-model/dist/index.js"),t=require("../../prosemirror-transform/dist/index.js"),r=Object.create(null);class n{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new s(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(t,r=e.Slice.empty){let n=r.content.lastChild,s=null;for(let e=0;e<r.openEnd;e++)s=n,n=n.lastChild;let i=t.steps.length,o=this.ranges;for(let a=0;a<o.length;a++){let{$from:l,$to:c}=o[a],h=t.mapping.slice(i);t.replaceRange(h.map(l.pos),h.map(c.pos),a?e.Slice.empty:r),0==a&&f(t,i,(n?n.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,n=this.ranges;for(let s=0;s<n.length;s++){let{$from:i,$to:o}=n[s],a=e.mapping.slice(r),l=a.map(i.pos),c=a.map(o.pos);s?e.deleteRange(l,c):(e.replaceRangeWith(l,c,t),f(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let n=e.parent.inlineContent?new a(e):d(e.node(0),e.parent,e.pos,e.index(),t,r);if(n)return n;for(let s=e.depth-1;s>=0;s--){let n=t<0?d(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):d(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,r);if(n)return n}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new p(e.node(0))}static atStart(e){return d(e,e,0,0,1)||new p(e)}static atEnd(e){return d(e,e,e.content.size,e.childCount,-1)||new p(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=r[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in r)throw new RangeError("Duplicate use of selection JSON ID "+e);return r[e]=t,t.prototype.jsonID=e,t}getBookmark(){return a.between(this.$anchor,this.$head).getBookmark()}}n.prototype.visible=!0;class s{constructor(e,t){this.$from=e,this.$to=t}}let i=!1;function o(e){i||e.parent.inlineContent||(i=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class a extends n{constructor(e,t=e){o(e),o(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return n.near(r);let s=e.resolve(t.map(this.anchor));return new a(s.parent.inlineContent?s:r,r)}replace(t,r=e.Slice.empty){if(super.replace(t,r),r==e.Slice.empty){let e=this.$from.marksAcross(this.$to);e&&t.ensureMarks(e)}}eq(e){return e instanceof a&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new l(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if("number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new a(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let n=e.resolve(t);return new this(n,r==t?n:e.resolve(r))}static between(e,t,r){let s=e.pos-t.pos;if(r&&!s||(r=s>=0?1:-1),!t.parent.inlineContent){let e=n.findFrom(t,r,!0)||n.findFrom(t,-r,!0);if(!e)return n.near(t,r);t=e.$head}return e.parent.inlineContent||(0==s||(e=(n.findFrom(e,-r,!0)||n.findFrom(e,r,!0)).$anchor).pos<t.pos!=s<0)&&(e=t),new a(e,t)}}n.jsonID("text",a);class l{constructor(e,t){this.anchor=e,this.head=t}map(e){return new l(e.map(this.anchor),e.map(this.head))}resolve(e){return a.between(e.resolve(this.anchor),e.resolve(this.head))}}class c extends n{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:s}=t.mapResult(this.anchor),i=e.resolve(s);return r?n.near(i):new c(i)}content(){return new e.Slice(e.Fragment.from(this.node),0,0)}eq(e){return e instanceof c&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new h(this.anchor)}static fromJSON(e,t){if("number"!=typeof t.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new c(e.resolve(t.anchor))}static create(e,t){return new c(e.resolve(t))}static isSelectable(e){return!e.isText&&!1!==e.type.spec.selectable}}c.prototype.visible=!1,n.jsonID("node",c);class h{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new l(r,r):new h(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&c.isSelectable(r)?new c(t):n.near(t)}}class p extends n{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(t,r=e.Slice.empty){if(r==e.Slice.empty){t.delete(0,t.doc.content.size);let e=n.atStart(t.doc);e.eq(t.selection)||t.setSelection(e)}else super.replace(t,r)}toJSON(){return{type:"all"}}static fromJSON(e){return new p(e)}map(e){return new p(e)}eq(e){return e instanceof p}getBookmark(){return u}}n.jsonID("all",p);const u={map(){return this},resolve:e=>new p(e)};function d(e,t,r,n,s,i=!1){if(t.inlineContent)return a.create(e,r);for(let o=n-(s>0?0:1);s>0?o<t.childCount:o>=0;o+=s){let n=t.child(o);if(n.isAtom){if(!i&&c.isSelectable(n))return c.create(e,r-(s<0?n.nodeSize:0))}else{let t=d(e,n,r+s,s<0?n.childCount:0,s,i);if(t)return t}r+=n.nodeSize*s}return null}function f(e,r,s){let i=e.steps.length-1;if(i<r)return;let o,a=e.steps[i];(a instanceof t.ReplaceStep||a instanceof t.ReplaceAroundStep)&&(e.mapping.maps[i].forEach((e,t,r,n)=>{null==o&&(o=n)}),e.setSelection(n.near(e.doc.resolve(o),s)))}class m extends t.Transform{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=-3&this.updated|1,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=2,this}ensureMarks(t){return e.Mark.sameSet(this.storedMarks||this.selection.$from.marks(),t)||this.setStoredMarks(t),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(e,t){super.addStep(e,t),this.updated=-3&this.updated,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(t,r=!0){let n=this.selection;return r&&(t=t.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||e.Mark.none))),n.replaceWith(this,t),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let s=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(null==r&&(r=t),!e)return this.deleteRange(t,r);let i=this.storedMarks;if(!i){let e=this.doc.resolve(t);i=r==t?e.marks():e.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,s.text(e,i)),this.selection.empty||this.selection.to!=t+e.length||this.setSelection(n.near(this.selection.$to)),this}}setMeta(e,t){return this.meta["string"==typeof e?e:e.key]=t,this}getMeta(e){return this.meta["string"==typeof e?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function g(e,t){return t&&e?e.bind(t):e}class S{constructor(e,t,r){this.name=e,this.init=g(t.init,r),this.apply=g(t.apply,r)}}const y=[new S("doc",{init:e=>e.doc||e.schema.topNodeType.createAndFill(),apply:e=>e.doc}),new S("selection",{init:(e,t)=>e.selection||n.atStart(t.doc),apply:e=>e.selection}),new S("storedMarks",{init:e=>e.storedMarks||null,apply:(e,t,r,n)=>n.selection.$cursor?e.storedMarks:null}),new S("scrollToSelection",{init:()=>0,apply:(e,t)=>e.scrolledIntoView?t+1:t})];class k{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=y.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw new RangeError("Adding different instances of a keyed plugin ("+e.key+")");this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new S(e.key,e.spec.state,e))})}}class w{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){let t=this.config.plugins[r];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),n=null;for(;;){let s=!1;for(let i=0;i<this.config.plugins.length;i++){let o=this.config.plugins[i];if(o.spec.appendTransaction){let a=n?n[i].n:0,l=n?n[i].state:this,c=a<t.length&&o.spec.appendTransaction.call(o,a?t.slice(a):t,l,r);if(c&&r.filterTransaction(c,i)){if(c.setMeta("appendedTransaction",e),!n){n=[];for(let e=0;e<this.config.plugins.length;e++)n.push(e<i?{state:r,n:t.length}:{state:this,n:0})}t.push(c),r=r.applyInner(c),s=!0}n&&(n[i]={state:r,n:t.length})}}if(!s)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new w(this.config),r=this.config.fields;for(let n=0;n<r.length;n++){let s=r[n];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new m(this)}static create(e){let t=new k(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new w(t);for(let n=0;n<t.fields.length;n++)r[t.fields[n].name]=t.fields[n].init(e,r);return r}reconfigure(e){let t=new k(this.schema,e.plugins),r=t.fields,n=new w(t);for(let s=0;s<r.length;s++){let t=r[s].name;n[t]=this.hasOwnProperty(t)?this[t]:r[s].init(e,n)}return n}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(e=>e.toJSON())),e&&"object"==typeof e)for(let r in e){if("doc"==r||"selection"==r)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let n=e[r],s=n.spec.state;s&&s.toJSON&&(t[r]=s.toJSON.call(n,this[n.key]))}return t}static fromJSON(t,r,s){if(!r)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let i=new k(t.schema,t.plugins),o=new w(i);return i.fields.forEach(i=>{if("doc"==i.name)o.doc=e.Node.fromJSON(t.schema,r.doc);else if("selection"==i.name)o.selection=n.fromJSON(o.doc,r.selection);else if("storedMarks"==i.name)r.storedMarks&&(o.storedMarks=r.storedMarks.map(t.schema.markFromJSON));else{if(s)for(let e in s){let n=s[e],a=n.spec.state;if(n.key==i.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(r,e))return void(o[i.name]=a.fromJSON.call(n,t,r[e],o))}o[i.name]=i.init(t,o)}}),o}}function $(e,t,r){for(let n in e){let s=e[n];s instanceof Function?s=s.bind(t):"handleDOMEvents"==n&&(s=$(s,t,{})),r[n]=s}return r}const M=Object.create(null);function O(e){return e in M?e+"$"+ ++M[e]:(M[e]=0,e+"$")}exports.AllSelection=p,exports.EditorState=w,exports.NodeSelection=c,exports.Plugin=class{constructor(e){this.spec=e,this.props={},e.props&&$(e.props,this,this.props),this.key=e.key?e.key.key:O("plugin")}getState(e){return e[this.key]}},exports.PluginKey=class{constructor(e="key"){this.key=O(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}},exports.Selection=n,exports.SelectionRange=s,exports.TextSelection=a,exports.Transaction=m;