vendor: 4,437 bytes, lines 1-3
1// [email protected] downloaded from https://ga.jspm.io/npm:[email protected]/dist/index.js 2 3import{ReplaceError as e,Fragment as t,Slice as n,MarkType as r,Mark as i}from"prosemirror-model";const a=65535,o=2**16;function s(e,t){return e+t*o}function c(e){return e&a}function l(e){return(e-(e&a))/o}const u=1,d=2,f=4,p=8;class MapResult{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&8)>0}get deletedBefore(){return(this.delInfo&5)>0}get deletedAfter(){return(this.delInfo&6)>0}get deletedAcross(){return(this.delInfo&4)>0}}class StepMap{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&StepMap.empty)return StepMap.empty}recover(e){let t=0,n=c(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[e*3+2]-this.ranges[e*3+1];return this.ranges[n*3]+t+l(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let c=this.ranges[o]-(this.inverted?r:0);if(c>e)break;let l=this.ranges[o+i],u=this.ranges[o+a],d=c+l;if(e<=d){let i=l?e==c?-1:e==d?1:t:t,a=c+r+(i<0?0:u);if(n)return a;let f=e==(t<0?c:d)?null:s(o/3,e-c),p=e==c?2:e==d?1:4;return(t<0?e!=c:e!=d)&&(p|=8),new MapResult(a,p,f)}r+=u-l}return n?e+r:new MapResult(e+r,0,null)}touches(e,t){let n=0,r=c(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let a=this.ranges[r],o=a-(this.inverted?i:0),s=a+(this.inverted?0:i),c=this.ranges[r+t],l=this.ranges[r+n];e(o,o+c,s,s+l),i+=l-c}}invert(){return new StepMap(this.ranges,!this.inverted)}toString(){return(this.inverted?`-`:``)+JSON.stringify(this.ranges)}static offset(e){return e==0?StepMap.empty:new StepMap(e<0?[0,-e,0]:[0,0,e])}}StepMap.empty=new StepMap([]);class Mapping{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new Mapping(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],r!=null&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let e=new Mapping;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this._maps[n].mapResult(e,t);if(i.recover!=null){let t=this.getMirror(n);if(t!=null&&t>n&&t<this.to){n=t,e=this._maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new MapResult(e,r,null)}}const m=Object.create(null);class Step{getMap(){return StepMap.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=m[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in m)throw RangeError(`Duplicate use of step JSON ID `+e);return m[e]=t,t.prototype.jsonID=e,t}}class StepResult{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new StepResult(e,null)}static fail(e){return new StepResult(null,e)}static fromReplace(t,n,r,i){try{return StepResult.ok(t.replace(n,r,i))}catch(t){if(t instanceof e)return StepResult.fail(t.message);throw t}}}function h(e,n,r){let i=[];for(let t=0;t<e.childCount;t++){let a=e.child(t);a.content.size&&(a=a.copy(h(a.content,n,a))),a.isInline&&(a=n(a,r,t)),i.push(a)}return t.fromArray(i)}class AddMarkStep extends Step{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}
vendor: 11,305 bytes, line 3
3apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),a=new n(h(t.content,(e,t)=>!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),i),t.openStart,t.openEnd);return StepResult.fromReplace(e,this.from,this.to,a)}invert(){return new RemoveMarkStep(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new AddMarkStep(t.pos,n.pos,this.mark)}merge(e){return e instanceof AddMarkStep&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new AddMarkStep(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!=`number`||typeof t.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new AddMarkStep(t.from,t.to,e.markFromJSON(t.mark))}}Step.jsonID(`addMark`,AddMarkStep);class RemoveMarkStep extends Step{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),r=new n(h(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return StepResult.fromReplace(e,this.from,this.to,r)}invert(){return new AddMarkStep(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new RemoveMarkStep(t.pos,n.pos,this.mark)}merge(e){return e instanceof RemoveMarkStep&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new RemoveMarkStep(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!=`number`||typeof t.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new RemoveMarkStep(t.from,t.to,e.markFromJSON(t.mark))}}Step.jsonID(`removeMark`,RemoveMarkStep);class AddNodeMarkStep extends Step{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let r=e.nodeAt(this.pos);if(!r)return StepResult.fail(`No node at mark step's position`);let i=r.type.create(r.attrs,null,this.mark.addToSet(r.marks));return StepResult.fromReplace(e,this.pos,this.pos+1,new n(t.from(i),0,+!r.isLeaf))}invert(e){let t=e.nodeAt(this.pos);if(t){let e=this.mark.addToSet(t.marks);if(e.length==t.marks.length){for(let n=0;n<t.marks.length;n++)if(!t.marks[n].isInSet(e))return new AddNodeMarkStep(this.pos,t.marks[n]);return new AddNodeMarkStep(this.pos,this.mark)}}return new RemoveNodeMarkStep(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new AddNodeMarkStep(t.pos,this.mark)}toJSON(){return{stepType:`addNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!=`number`)throw RangeError(`Invalid input for AddNodeMarkStep.fromJSON`);return new AddNodeMarkStep(t.pos,e.markFromJSON(t.mark))}}Step.jsonID(`addNodeMark`,AddNodeMarkStep);class RemoveNodeMarkStep extends Step{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let r=e.nodeAt(this.pos);if(!r)return StepResult.fail(`No node at mark step's position`);let i=r.type.create(r.attrs,null,this.mark.removeFromSet(r.marks));return StepResult.fromReplace(e,this.pos,this.pos+1,new n(t.from(i),0,+!r.isLeaf))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new AddNodeMarkStep(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new RemoveNodeMarkStep(t.pos,this.mark)}toJSON(){return{stepType:`removeNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!=`number`)throw RangeError(`Invalid input for RemoveNodeMarkStep.fromJSON`);return new RemoveNodeMarkStep(t.pos,e.markFromJSON(t.mark))}}Step.jsonID(`removeNodeMark`,RemoveNodeMarkStep);class ReplaceStep extends Step{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&g(e,this.from,this.to)?StepResult.fail(`Structure replace would overwrite content`):StepResult.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new StepMap([this.from,this.to-this.from,this.slice.size])}invert(e){return new ReplaceStep(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),n=this.from==this.to&&ReplaceStep.MAP_BIAS<0?t:e.mapResult(this.from,1);return n.deletedAcross&&t.deletedAcross?null:new ReplaceStep(n.pos,Math.max(n.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof ReplaceStep)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?n.empty:new n(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new ReplaceStep(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?n.empty:new n(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new ReplaceStep(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:`replace`,from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!=`number`||typeof t.to!=`number`)throw RangeError(`Invalid input for ReplaceStep.fromJSON`);return new ReplaceStep(t.from,t.to,n.fromJSON(e,t.slice),!!t.structure)}}ReplaceStep.MAP_BIAS=1,Step.jsonID(`replace`,ReplaceStep);class ReplaceAroundStep extends Step{constructor(e,t,n,r,i,a,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=a,this.structure=o}apply(e){if(this.structure&&(g(e,this.from,this.gapFrom)||g(e,this.gapTo,this.to)))return StepResult.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return StepResult.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?StepResult.fromReplace(e,this.from,this.to,n):StepResult.fail(`Content does not fit in gap`)}getMap(){return new StepMap([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new ReplaceAroundStep(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),r=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||r<t.pos||i>n.pos?null:new ReplaceAroundStep(t.pos,n.pos,r,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:`replaceAround`,from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!=`number`||typeof t.to!=`number`||typeof t.gapFrom!=`number`||typeof t.gapTo!=`number`||typeof t.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new ReplaceAroundStep(t.from,t.to,t.gapFrom,t.gapTo,n.fromJSON(e,t.slice),t.insert,!!t.structure)}}Step.jsonID(`replaceAround`,ReplaceAroundStep);function g(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function _(e,t,n,r){let i=[],a=[],o,s;e.doc.nodesBetween(t,n,(e,c,l)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&l.type.allowsMarkType(r.type)){let l=Math.max(c,t),d=Math.min(c+e.nodeSize,n),f=r.addToSet(u);for(let e=0;e<u.length;e++)u[e].isInSet(f)||(o&&o.to==l&&o.mark.eq(u[e])?o.to=d:i.push(o=new RemoveMarkStep(l,d,u[e])));s&&s.to==l?s.to=d:a.push(s=new AddMarkStep(l,d,r))}}),i.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}function v(e,t,n,i){let a=[],o=0;e.doc.nodesBetween(t,n,(e,s)=>{if(!e.isInline)return;o++;let c=null;if(i instanceof r){let t=e.marks,n;for(;n=i.isInSet(t);)(c||(c=[])).push(n),t=n.removeFromSet(t)}else i?i.isInSet(e.marks)&&(c=[i]):c=e.marks;if(c&&c.length){let r=Math.min(s+e.nodeSize,n);for(let e=0;e<c.length;e++){let n=c[e],i;for(let e=0;e<a.length;e++){let t=a[e];t.step==o-1&&n.eq(a[e].style)&&(i=t)}i?(i.to=r,i.step=o):a.push({style:n,from:Math.max(s,t),to:r,step:o})}}}),a.forEach(t=>e.step(new RemoveMarkStep(t.from,t.to,t.style)))}function y(e,r,i,a=i.contentMatch,o=!0){let s=e.doc.nodeAt(r),c=[],l=r+1;for(let r=0;r<s.childCount;r++){let u=s.child(r),d=l+u.nodeSize,f=a.matchType(u.type);if(!f)c.push(new ReplaceStep(l,d,n.empty));else{a=f;for(let t=0;t<u.marks.length;t++)i.allowsMarkType(u.marks[t].type)||e.step(new RemoveMarkStep(l,d,u.marks[t]));if(o&&u.isText&&i.whitespace!=`pre`){let e,r=/\r?\n|\r/g,a;for(;e=r.exec(u.text);)a||(a=new n(t.from(i.schema.text(` `,i.allowedMarks(u.marks))),0,0)),c.push(new ReplaceStep(l+e.index,l+e.index+e[0].length,a))}}l=d}if(!a.validEnd){let r=a.fillBefore(t.empty,!0);e.replace(l,l,new n(r,0,0))}for(let t=c.length-1;t>=0;t--)e.step(c[t])}function b(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function x(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(n<e.depth&&a.canReplace(o,s,t))return n;if(n==0||a.type.spec.isolating||!b(a,o,s))break;o&&(r=1),s<a.childCount&&(i=1)}return null}function S(e,r,i){let{$from:a,$to:o,depth:s}=r,c=a.before(s+1),l=o.after(s+1),u=c,d=l,f=t.empty,p=0;for(let e=s,n=!1;e>i;e--)n||a.index(e)>0?(n=!0,f=t.from(a.node(e).copy(f)),p++):u--;let m=t.empty,h=0;for(let e=s,n=!1;e>i;e--)n||o.after(e+1)<o.end(e)?(n=!0,m=t.from(o.node(e).copy(m)),h++):d++;e.step(new ReplaceAroundStep(u,d,c,l,new n(f.append(m),p,h),f.size-p,!0))}function C(e,t,n=null,r=e){let i=T(e,t),a=i&&E(r,t);return a?i.map(w).concat({type:t,attrs:n}).concat(a.map(w)):null}function w(e){return{type:e,attrs:null}}function T(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.contentMatchAt(r).findWrapping(t);if(!a)return null;let o=a.length?a[0]:t;return n.canReplaceWith(r,i,o)?a:null}function E(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.child(r),o=t.contentMatch.findWrapping(a.type);if(!o)return null;let s=(o.length?o[o.length-1]:t).contentMatch;for(let e=r;s&&e<i;e++)s=s.matchType(n.child(e).type);return!s||!s.validEnd?null:o}function D(e,r,i){let a=t.empty;for(let e=i.length-1;e>=0;e--){if(a.size){let t=i[e].type.contentMatch.matchFragment(a);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}a=t.from(i[e].type.create(i[e].attrs,a))}let o=r.start,s=r.end;e.step(new ReplaceAroundStep(o,s,o,s,new n(a,0,0),i.length,!0))}function O(e,r,i,a,o){if(!a.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let s=e.steps.length;e.doc.nodesBetween(r,i,(r,i)=>{let c=typeof o==`function`?o(r):o;
vendor: 4,529 bytes, lines 3-4
3if(r.isTextblock&&!r.hasMarkup(a,c)&&j(e.doc,e.mapping.slice(s).map(i),a)){let o=null;if(a.schema.linebreakReplacement){let e=a.whitespace==`pre`,t=!!a.contentMatch.matchType(a.schema.linebreakReplacement);e&&!t?o=!1:!e&&t&&(o=!0)}o===!1&&A(e,r,i,s),y(e,e.mapping.slice(s).map(i,1),a,void 0,o===null);let l=e.mapping.slice(s),u=l.map(i,1),d=l.map(i+r.nodeSize,1);return e.step(new ReplaceAroundStep(u,d,u+1,d-1,new n(t.from(a.create(c,null,r.marks)),0,0),1,!0)),o===!0&&k(e,r,i,s),!1}})}function k(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function A(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(` 4`))}})}function j(e,t,n){let r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function M(e,r,i,a,o){let s=e.doc.nodeAt(r);if(!s)throw RangeError(`No node at given position`);i||(i=s.type);let c=i.create(a,null,o||s.marks);if(s.isLeaf)return e.replaceWith(r,r+s.nodeSize,c);if(!i.validContent(s.content))throw RangeError(`Invalid content for node type `+i.name);e.step(new ReplaceAroundStep(r,r+s.nodeSize,r+1,r+s.nodeSize-1,new n(t.from(c),0,0),1,!0))}function ee(e,t,n=1,r){let i=e.resolve(t),a=i.depth-n,o=r&&r[r.length-1]||i.parent;if(a<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let e=i.depth-1,t=n-2;e>a;e--,t--){let n=i.node(e),a=i.index(e);if(n.type.spec.isolating)return!1;let o=n.content.cutByIndex(a,n.childCount),s=r&&r[t+1];s&&(o=o.replaceChild(0,s.type.create(s.attrs)));let c=r&&r[t]||n;if(!n.canReplace(a+1,n.childCount)||!c.type.validContent(o))return!1}let s=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(s,s,c?c.type:i.node(a+1).type)}function N(e,r,i=1,a){let o=e.doc.resolve(r),s=t.empty,c=t.empty;for(let e=o.depth,n=o.depth-i,r=i-1;e>n;e--,r--){s=t.from(o.node(e).copy(s));let n=a&&a[r];c=t.from(n?n.type.create(n.attrs,c):o.node(e).copy(c))}e.step(new ReplaceStep(r,r,new n(s.append(c),i,i),!0))}function P(e,t){let n=e.resolve(t),r=n.index();return I(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function F(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let i=0;i<t.childCount;i++){let a=t.child(i),o=a.type==r?e.type.schema.nodes.text:a.type;if(n=n.matchType(o),!n||!e.type.allowsMarks(a.marks))return!1}return n.validEnd}function I(e,t){return!!(e&&t&&!e.isLeaf&&F(e,t))}function L(e,t,n=-1){let r=e.resolve(t);for(let e=r.depth;;e--){let i,a,o=r.index(e);if(e==r.depth?(i=r.nodeBefore,a=r.nodeAfter):n>0?(i=r.node(e+1),o++,a=r.node(e).maybeChild(o)):(i=r.node(e).maybeChild(o-1),a=r.node(e+1)),i&&!i.isTextblock&&I(i,a)&&r.node(e).canReplace(o,o+1))return t;if(e==0)break;t=n<0?r.before(e):r.after(e)}}function R(e,t,r){let i=null,{linebreakReplacement:a}=e.doc.type.schema,o=e.doc.resolve(t-r),s=o.node().type;if(a&&s.inlineContent){let e=s.whitespace==`pre`,t=!!s.contentMatch.matchType(a);e&&!t?i=!1:!e&&t&&(i=!0)}let c=e.steps.length;if(i===!1){let n=e.doc.resolve(t+r);A(e,n.node(),n.before(),c)}s.inlineContent&&y(e,t+r-1,s,o.node().contentMatchAt(o.index()),i==null);let l=e.mapping.slice(c),u=l.map(t-r);if(e.step(new ReplaceStep(u,l.map(t+r,-1),n.empty,!0)),i===!0){let t=e.doc.resolve(u);k(e,t.node(),t.before(),e.steps.length)}return e}function z(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(r.parentOffset==0)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t<r.node(e).childCount)return null}return null}function B(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let i=n.content;for(let e=0;e<n.openStart;e++)i=i.firstChild.content;for(let e=1;e<=(n.openStart==0&&n.size?2:1);e++)for(let t=r.depth;t>=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,a=r.index(t)+ +(n>0),o=r.node(t),s=!1;if(e==1)s=o.canReplace(a,a,i);else{let e=o.contentMatchAt(a).findWrapping(i.firstChild.type);s=e&&o.canReplaceWith(a,a,e[0])}if(s)return n==0?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}
vendor: 10,005 bytes, line 4
4function V(e,t,r=t,i=n.empty){if(t==r&&!i.size)return null;let a=e.resolve(t),o=e.resolve(r);return H(a,o,i)?new ReplaceStep(t,r,i):new Fitter(a,o,i).fit()}function H(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}class Fitter{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=t.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let n=e.depth;n>0;n--)this.placed=t.from(e.node(n).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let a=this.placed,o=r.depth,s=i.depth;for(;o&&s&&a.childCount==1;)a=a.firstChild.content,o--,s--;let c=new n(a,o,s);return e>-1?new ReplaceAroundStep(r.pos,e,this.$to.pos,this.$to.end(),c,t):c.size||r.pos!=this.$to.pos?new ReplaceStep(r.pos,i.pos,c):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let i=t.firstChild;if(t.childCount>1&&(r=0),i.type.spec.isolating&&r<=n){e=n;break}t=i.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let e,i=null;r?(i=G(this.unplaced.content,r-1).firstChild,e=i.content):e=this.unplaced.content;let a=e.firstChild;for(let e=this.depth;e>=0;e--){let{type:o,match:s}=this.frontier[e],c,l=null;if(n==1&&(a?s.matchType(a.type)||(l=s.fillBefore(t.from(a),!1)):i&&o.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:e,parent:i,inject:l};if(n==2&&a&&(c=s.findWrapping(a.type)))return{sliceDepth:r,frontierDepth:e,parent:i,wrap:c};if(i&&s.matchType(i.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced;return X(e,-1)<=t?!1:(this.unplaced.size>1&&X(e,1)>r&&r++,this.unplaced=new n(e,t+1,r),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=G(e,t);if(i.childCount<=1&&t>0){let a=e.size-t<=t+i.size;this.unplaced=new n(U(e,t-1,1),t-1,a?t-1:r)}else this.unplaced=new n(U(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:r,parent:i,inject:a,wrap:o}){for(;this.depth>r;)this.closeFrontierNode();if(o)for(let e=0;e<o.length;e++)this.openFrontierNode(o[e]);let s=this.unplaced,c=i?i.content:s.content,l=s.openStart-e,u=0,d=[],{match:f,type:p}=this.frontier[r];if(a){for(let e=0;e<a.childCount;e++)d.push(a.child(e));f=f.matchFragment(a)}let m=c.size+e-(s.content.size-s.openEnd);for(;u<c.childCount;){let e=c.child(u),t=f.matchType(e.type);if(!t)break;u++,(u>1||l==0||e.content.size)&&(f=t,d.push(K(e.mark(p.allowedMarks(e.marks)),u==1?l:0,u==c.childCount?m:-1)))}let h=u==c.childCount;h||(m=-1),this.placed=W(this.placed,r,t.from(d)),this.frontier[r].match=f,h&&m<0&&i&&i.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=c;e<m;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=h?e==0?n.empty:new n(U(s.content,e-1,1),e-1,m<0?s.openEnd:e-1):new n(U(s.content,e,u),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!q(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){scan:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),a=q(e,t,r,n,i);if(a){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],i=q(e,n,r,t,!0);if(!i||i.childCount)continue scan}return{depth:t,fit:a,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=W(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=W(this.placed,this.depth,t.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(t.empty,!0);e.childCount&&(this.placed=W(this.placed,this.frontier.length,e))}}function U(e,t,n){return t==0?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(U(e.firstChild.content,t-1,n)))}function W(e,t,n){return t==0?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(W(e.lastChild.content,t-1,n)))}function G(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function K(e,n,r){if(n<=0)return e;let i=e.content;return n>1&&(i=i.replaceChild(0,K(i.firstChild,n-1,i.childCount==1?r-1:0))),n>0&&(i=e.type.contentMatch.fillBefore(i).append(i),r<=0&&(i=i.append(e.type.contentMatch.matchFragment(i).fillBefore(t.empty,!0)))),e.copy(i)}function q(e,t,n,r,i){let a=e.node(t),o=i?e.indexAfter(t):e.index(t);if(o==a.childCount&&!n.compatibleContent(a.type))return null;let s=r.fillBefore(a.content,!0,o);return s&&!J(n,a.content,o)?s:null}function J(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}function Y(e){return e.spec.defining||e.spec.definingForContent}function X(e,t){for(let n=0;;n++){let r=t<0?e.firstChild:e.lastChild;if(!r||r.isAtom)return n;e=r.content}}function Z(e,t,r,i){if(!i.size)return e.deleteRange(t,r);let a=e.doc.resolve(t),o=e.doc.resolve(r);if(H(a,o,i))return e.step(new ReplaceStep(t,r,i));let s=$(a,o);s[s.length-1]==0&&s.pop();let c=-(a.depth+1);s.unshift(c);for(let e=a.depth,t=a.pos-1;e>0;e--,t--){let n=a.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;s.indexOf(e)>-1?c=e:a.before(e)==t&&s.splice(1,0,-e)}let l=s.indexOf(c),u=[],d=i.openStart;for(let e=i.content,t=0;;t++){let n=e.firstChild;if(u.push(n),t==i.openStart)break;e=n.content}for(let e=d-1;e>=0;e--){let t=u[e],n=Y(t.type);if(n&&!t.sameMarkup(a.node(Math.abs(c)-1)))d=e;else if(n||!t.type.isTextblock)break}for(let t=i.openStart;t>=0;t--){let c=(t+d+1)%(i.openStart+1),f=u[c];if(f)for(let t=0;t<s.length;t++){let u=s[(t+l)%s.length],d=!0;u<0&&(d=!1,u=-u);let p=a.node(u-1),m=a.index(u-1);if(p.canReplaceWith(m,m,f.type,f.marks))return e.replace(a.before(u),d?o.after(u):r,new n(Q(i.content,0,i.openStart,c),c,i.openEnd))}}let f=e.steps.length;for(let n=s.length-1;n>=0&&(e.replace(t,r,i),!(e.steps.length>f));n--){let e=s[n];e<0||(t=a.before(e),r=o.after(e))}}function Q(e,n,r,i,a){if(n<r){let t=e.firstChild;e=e.replaceChild(0,t.copy(Q(t.content,n+1,r,i,t)))}if(n>i){let n=a.contentMatchAt(0),r=n.fillBefore(e).append(e);e=r.append(n.matchFragment(r).fillBefore(t.empty,!0))}return e}function te(e,r,i,a){if(!a.isInline&&r==i&&e.doc.resolve(r).parent.content.size){let t=z(e.doc,r,a.type);t!=null&&(r=i=t)}e.replaceRange(r,i,new n(t.from(a),0,0))}function ne(e,t,n){let r=e.doc.resolve(t),i=e.doc.resolve(n);if(r.parent.isTextblock&&i.parent.isTextblock&&r.start()!=i.start()&&r.parentOffset==0&&i.parentOffset==0){let a=r.sharedDepth(n),o=!1;for(let e=r.depth;e>a;e--)r.node(e).type.spec.isolating&&(o=!0);for(let e=i.depth;e>a;e--)i.node(e).type.spec.isolating&&(o=!0);if(!o){for(let e=r.depth;e>0&&t==r.start(e);e--)t=r.before(e);for(let e=i.depth;e>0&&n==i.start(e);e--)n=i.before(e);r=e.doc.resolve(t),i=e.doc.resolve(n)}}let a=$(r,i);for(let t=0;t<a.length;t++){let n=a[t],o=t==a.length-1;if(o&&n==0||r.node(n).type.contentMatch.validEnd)return e.delete(r.start(n),i.end(n));if(n>0&&(o||r.node(n-1).canReplace(r.index(n-1),i.indexAfter(n-1))))return e.delete(r.before(n),i.after(n))}for(let a=1;a<=r.depth&&a<=i.depth;a++)if(t-r.start(a)==r.depth-a&&n>r.end(a)&&i.end(a)-n!=i.depth-a&&r.start(a-1)==i.start(a-1)&&r.node(a-1).canReplace(r.index(a-1),i.index(a-1)))return e.delete(r.before(a),n);e.delete(t,n)}function $(e,t){let n=[],r=Math.min(e.depth,t.depth);for(let i=r;i>=0;i--){let r=e.start(i);if(r<e.pos-(e.depth-i)||t.end(i)>t.pos+(t.depth-i)||e.node(i).type.spec.isolating||t.node(i).type.spec.isolating)break;(r==t.start(i)||i==e.depth&&i==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&i&&t.start(i-1)==r-1)&&n.push(i)}return n}class AttrStep extends Step{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let r=e.nodeAt(this.pos);if(!r)return StepResult.fail(`No node at attribute step's position`);let i=Object.create(null);for(let e in r.attrs)i[e]=r.attrs[e];i[this.attr]=this.value;let a=r.type.create(i,null,r.marks);return StepResult.fromReplace(e,this.pos,this.pos+1,new n(t.from(a),0,+!r.isLeaf))}getMap(){return StepMap.empty}invert(e){return new AttrStep(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new AttrStep(t.pos,this.attr,this.value)}toJSON(){return{stepType:`attr`,pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!=`number`||typeof t.attr!=`string`)throw RangeError(`Invalid input for AttrStep.fromJSON`);return new AttrStep(t.pos,t.attr,t.value)}}Step.jsonID(`attr`,AttrStep);class DocAttrStep extends Step{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return StepResult.ok(n)}getMap(){return StepMap.empty}invert(e){return new DocAttrStep(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:`docAttr`,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!=`string`)throw RangeError(`Invalid input for DocAttrStep.fromJSON`);return new DocAttrStep(t.attr,t.value)}}Step.jsonID(`docAttr`,DocAttrStep);
vendor: 2,587 bytes, lines 4-5
4let TransformError=class extends Error{};TransformError=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},TransformError.prototype=Object.create(Error.prototype),TransformError.prototype.constructor=TransformError,TransformError.prototype.name=`TransformError`;class Transform{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Mapping}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new TransformError(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let r=this.mapping.maps[n];n&&(e=r.map(e,1),t=r.map(t,-1)),r.forEach((n,r,i,a)=>{e=Math.min(e,i),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=n.empty){let i=V(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,r,i){return this.replace(e,r,new n(t.from(i),0,0))}delete(e,t){return this.replace(e,t,n.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return Z(this,e,t,n),this}replaceRangeWith(e,t,n){return te(this,e,t,n),this}deleteRange(e,t){return ne(this,e,t),this}lift(e,t){return S(this,e,t),this}join(e,t=1){return R(this,e,t),this}wrap(e,t){return D(this,e,t),this}setBlockType(e,t=e,n,r=null){return O(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return M(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new AttrStep(e,t,n)),this}setDocAttribute(e,t){return this.step(new DocAttrStep(e,t)),this}addNodeMark(e,t){return this.step(new AddNodeMarkStep(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw RangeError(`No node at position `+e);if(t instanceof i)t.isInSet(n.marks)&&this.step(new RemoveNodeMarkStep(e,t));else{let r=n.marks,i,a=[];for(;i=t.isInSet(r);)a.push(new RemoveNodeMarkStep(e,i)),r=i.removeFromSet(r);for(let e=a.length-1;e>=0;e--)this.step(a[e])}return this}split(e,t=1,n){return N(this,e,t,n),this}addMark(e,t,n){return _(this,e,t,n),this}removeMark(e,t,n){return v(this,e,t,n),this}clearIncompatible(e,t,n){return y(this,e,t,n),this}}export{AddMarkStep,AddNodeMarkStep,AttrStep,DocAttrStep,MapResult,Mapping,RemoveMarkStep,RemoveNodeMarkStep,ReplaceAroundStep,ReplaceStep,Step,StepMap,StepResult,Transform,TransformError,P as canJoin,ee as canSplit,B as dropPoint,C as findWrapping,z as insertPoint,L as joinPoint,x as liftTarget,V as replaceStep}; 5
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.